@kern0x1b/penstock-cli 26.11.0 → 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,982 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BpmnDocument-Ce5F4K1e.js","./rolldown-runtime-B8BYMn-z.js","./vendor-NJP34MHU.js","./frontend-uXAWaalt.js","./bridgeInstance-qzSInqLW.js","./documentBridge-CHw4XsZH.js","./translator-BLCeE6UY.js","./preload-helper-DExCAR_V.js","./platform-G53Cenyw.js","./dialog-BDJ5dDiU.js","./xml-DIWt4von.js","./dist-BT_v6mN5.js","./httpHost-C973OTRe.js","./trace-DXQU2N_l.js","./ui-BLtm3Y1J.js","./docs-B2ZDPeJU.js","./preferences-BcLlKYFq.js","./descriptors-B5VIyY5g.js","./testCaseRuns-liAhWMg7.js","./moddle-f0Q4Guwd.js","./dist-B7TL-7R3.js","./dist-CRJyslwo.js","./file-BbVBUuIH.js","./steps-BB_6M1MU.js","./engines-lyEvb0pH.js","./list-TmXvCwja.js","./say-C7KqKcFr.js","./shortcut-BRxHV_3d.js","./AgentSettings-D24jOuht.js","./typing-CXvbBSPr.js","./dockLayout-CxOMo-Nl.js","./BpmnCanvas-BcQRQ2Br.js","./lib-DrkEMJ65.js","./dist-DHrd1AHo.js","./dist-CdHwU8_m.js","./duplicate-D_ic-m62.js","./Viewer-BcpDlvg_.js","./dist-BqwyxNP3.js","./bpmnTheme-pKgl9Mrn.js","./dist-BrFvWnvj.js","./dist-Bb5-DGtZ.js","./dist-DDNYYQtV.js","./dist-BEpeEbIu.js","./dist-_eOLjmnv.js","./dist-DDE6BjgI.js","./dist-CWjAtsKe.js","./kind-DDHnk6dW.js","./stackblur-es-Djj-lnDR.js","./array-move-Bc4mVEdq.js","./dist-DN6jzqTC.js","./dist-CJx_2eBF.js","./groovy-DASguM_i.js","./dist-27z6Phtg.js","./workerVariables-O6VqwDzr.js","./dmn-Cgoh6wXm.js","./apply-Nsj6ek02.js","./samples-BL3jA_Vd.js","./dist-C-q1IWjr.js","./syntax-00Hk6Xv7.js","./migrationHost-DCWBb3L6.js","./sharedReader-BsXfiBT8.js","./types-BL-9oaVm.js","./sections-LJKSRDTS.js","./useTrace-dZdQ805W.js","./pathGeometry-DJTK9no3.js","./formChecks-CSClH9sH.js","./open-Vkx72dYx.js","./nudges-DPG3WpyV.js","./template-BQP7ZXdK.js","./say-BkdZMivA.js","./model-afHgSxJs.js","./DmnDocument-vtnARy7Q.js","./UnreadableFileLayer-CRW3MM7w.js","./DmnDocument-DZ9u2uk2.css","./FormDocument-DHBUBUzO.js","./index.es-GbdJvMnO.js","./purify.es-DBLk-NVl.js","./FormDocument-B0q8DF9v.css","./CmmnDocument-C_UlPowC.js","./CmmnDocument-B4A9_w5C.css","./TemplateDocument-BRyFsofH.js","./source-frame-DC4W0A5-.js","./data-CdiToGOq.js","./TextDocument-DB2hEuMA.js","./intelligence-DNqJNmdB.js","./files-DI8LgQfb.js","./SourceDocument-Cj8cGsoS.js","./DiffDocument-BOPdBEN3.js","./index.esm-Ba6q0zSu.js","./diff-BhYqTg4l.js","./ScriptPane-BQLMNYzc.js","./NewFileDialog-Dev41oA1.js","./QuickOpen-ps-rMjiS.js","./ShortcutsDialog-DLXnv4Vm.js","./commands-GT3J_YEC.js","./SettingsDialog-DI0vZ6Ay.js","./AgentsDialog-DbY2O6O5.js","./ConnectionsDialog-BaYtHD5h.js","./AgentsDialog-BMWv3Gyk.js","./data-wU6sw6RY.js","./MigrationDialog-DA3Vrzgw.js","./executable--4381_Lf.js","./PolicyDialog-qR19Csji.js","./DriftDialog-dIbCbSK2.js","./ConflictDialog-DfFp8F7n.js","./UploadDialog-D-X6GG98.js"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-B8BYMn-z.js";import{c as t,d as n,f as r,g as i,h as a,i as o,m as s,o as c,r as l,s as u,t as d,u as f}from"./vendor-NJP34MHU.js";import{c as p,i as m,n as h,o as g,r as _,u as v}from"./translator-BLCeE6UY.js";import{m as y}from"./trace-DXQU2N_l.js";import{a as b,d as x,f as S,g as C,h as w,i as T,m as E,n as D,o as O,r as k,s as A,t as j,u as M,v as N}from"./ui-BLtm3Y1J.js";import{i as P,n as F,o as I,r as L,s as R,t as z}from"./platform-G53Cenyw.js";import{i as B,n as ee,o as V,r as H,t as U}from"./preferences-BcLlKYFq.js";import{n as W,t as te}from"./documents-CEtohzAC.js";import{a as ne,d as re,f as ie,i as ae,n as G,o as oe,p as se,r as ce,s as le,u as ue}from"./files-DI8LgQfb.js";import{t as K}from"./preload-helper-DExCAR_V.js";import{C as de,n as fe,r as pe,t as me,y as he}from"./frontend-uXAWaalt.js";import{Ln as ge}from"./duplicate-D_ic-m62.js";import{a as q}from"./httpHost-C973OTRe.js";import{Dt as _e,Ot as ve,n as ye,t as be}from"./BpmnCanvas-BcQRQ2Br.js";import{a as xe,c as Se,i as J,n as Ce,o as we,r as Te,s as Ee}from"./commands-GT3J_YEC.js";import{t as De}from"./typing-CXvbBSPr.js";import{a as Oe,o as Y}from"./dist-DDNYYQtV.js";import{I as ke}from"./dist-BrFvWnvj.js";import{o as Ae,s as je,t as Me}from"./shortcut-BRxHV_3d.js";import{_ as Ne,a as X,c as Pe,d as Fe,f as Ie,g as Le,h as Re,i as ze,l as Be,m as Ve,o as He,p as Ue,s as We,t as Ge,u as Ke,v as qe}from"./AgentSettings-D24jOuht.js";import{t as Z}from"./say-C7KqKcFr.js";import{r as Je,t as Q}from"./bridgeInstance-qzSInqLW.js";import{t as Ye}from"./executable--4381_Lf.js";import{a as Xe,i as $,o as Ze,r as Qe,t as $e}from"./dockLayout-CxOMo-Nl.js";import{S as et,_ as tt,c as nt,d as rt,f as it,g as at,m as ot,t as st,x as ct}from"./descriptors-B5VIyY5g.js";import{c as lt,g as ut}from"./testCaseRuns-liAhWMg7.js";import{n as dt}from"./types-BL-9oaVm.js";import{n as ft}from"./file-BbVBUuIH.js";import{d as pt}from"./engines-lyEvb0pH.js";(function polyfill(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))processPreload(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&processPreload(e)}).observe(document,{childList:!0,subtree:!0});function getFetchOpts(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function processPreload(e){if(e.ep)return;e.ep=!0;let t=getFetchOpts(e);fetch(e.href,t)}})();var mt=`.bio-properties-panel, .dmn-decision-table-container`;function localisePanel(e){if(e.nodeType!==Node.ELEMENT_NODE)return;let t=e,n=t.closest(mt)===null?[...t.querySelectorAll(mt)]:[t];for(let e of n)_e(e),e.querySelectorAll(`[title], [aria-label]`).forEach(_e),e.querySelectorAll(`button`).forEach(ve)}function translatePanelLabels(){localisePanel(document.body),new MutationObserver(e=>{for(let t of e)t.type===`attributes`?t.target.closest(mt)&&_e(t.target):t.addedNodes.forEach(localisePanel)}).observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`title`,`aria-label`]})}function startupFailureMessage(e){if(e instanceof Error)return e.message;if(typeof e==`string`)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}function StartupFailure({message:e}){return l(`div`,{class:`startup-failure`,role:`alert`,children:l(`div`,{class:`startup-failure__inner`,children:[l(A,{title:m(`app.startup.theEditorCouldNotStart`),hint:m(`app.startup.retryingReloadsTheEditorAnd`),actions:[{label:m(`app.common.retry`),run:()=>window.location.reload()}]}),l(`pre`,{class:`startup-failure__message`,children:e})]})})}function showStartupFailure(e,t){if(!e||typeof document>`u`)return;let n=document.createElement(`div`);e.replaceChildren(n),s(l(StartupFailure,{message:startupFailureMessage(t)}),n)}var ht=new Set([`properties`,`appliesTo`]);function isEmpty(e){return Array.isArray(e)?e.length===0:typeof e==`object`&&!!e&&Object.keys(e).length===0}function withoutNulls(e){return typeof e!=`object`||!e||Array.isArray(e)?e:Object.fromEntries(Object.entries(e).filter(([,e])=>e!=null))}function cleanTemplate(e){let t={};for(let[n,r]of Object.entries(e))r!=null&&(!isEmpty(r)||ht.has(n))&&(t[n]=n===`groups`&&Array.isArray(r)?r.map(withoutNulls):r);return t}function cleanTemplates(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e).map(cleanTemplate):[]}var gt=``+new URL(`colors-dark-C7vOziWz.css`,import.meta.url).href,_t=``+new URL(`colors-dracula-CXhMcc1Z.css`,import.meta.url).href,vt=``+new URL(`colors-light-CyT40N4M.css`,import.meta.url).href,yt={light:{isDark:!1},dark:{isDark:!0},dracula:{isDark:!0}},bt=`light`;function themeNameFor(e,t){let n=e?.toLowerCase();return n&&n in yt?n:t?`dark`:bt}function applyTheme(e){document.documentElement.setAttribute(`data-theme`,e);let t=document.createElement(`link`);return t.rel=`stylesheet`,t.href=new URL(Object.assign({"./colors-dark.css":gt,"./colors-dracula.css":_t,"./colors-light.css":vt})[`./colors-${e}.css`],import.meta.url).href,document.querySelectorAll(`link[data-theme-css]`).forEach(e=>e.remove()),t.setAttribute(`data-theme-css`,`true`),document.head.appendChild(t),t}function announceThemeApplied(e,t){let announce=()=>{window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:t}))},n=applyTheme(e);announce(),n.addEventListener(`load`,announce,{once:!0})}function getCurrentTheme(){let e=document.documentElement.getAttribute(`data-theme`);return e&&e in yt?e:bt}function toggleDarkMode(){let e=yt[getCurrentTheme()].isDark?`light`:`dark`;return applyTheme(e),e}var xt=`--theme-bg-primary.--theme-bg-secondary.--theme-bg-sidebar.--theme-bg-tertiary.--theme-bg-input.--theme-bg-hover.--theme-bg-hover-strong.--theme-bg-pressed.--theme-bg-selected.--theme-bg-selected-muted.--theme-bg-selected-inactive.--theme-fg-primary.--theme-fg-selected.--theme-fg-secondary.--theme-fg-tertiary.--theme-fg-disabled.--theme-fg-on-accent.--theme-fg-code.--theme-border-primary.--theme-border-secondary.--theme-border-light.--theme-border-strong.--theme-separator.--theme-accent-primary.--theme-accent-hover.--theme-accent-pressed.--theme-accent-subtle.--theme-accent-solid.--theme-accent-solid-hover.--theme-accent-solid-pressed.--theme-on-accent.--theme-icon-default.--theme-icon-muted.--theme-icon-on-accent.--theme-link.--theme-link-hover.--theme-focus-ring.--theme-success.--theme-warning.--theme-error.--theme-error-subtle.--theme-error-subtle-alt.--theme-error-border.--theme-error-dark.--theme-error-critical.--theme-success-subtle.--theme-success-border.--theme-warning-subtle.--theme-warning-border.--theme-badge-bg.--theme-badge-fg.--theme-grid-pattern.--theme-lasso.--theme-white.--theme-white-subtle.--theme-black.--theme-black-subtle-10.--theme-black-subtle-30.--theme-scrim.--theme-shadow-float.--theme-shadow-popup.--theme-shadow-low.--theme-shadow-hairline.--theme-shadow-dialog.--type-size-body.--type-size-small.--type-size-tiny`.split(`.`),St=/^#[0-9a-f]{6}([0-9a-f]{2})?$/i;function applyIdeTheme(e){clearIdeTheme();let t=new Set(xt),n=document.documentElement,r=e.tokens,i=0;for(let e of Object.keys(r??{})){let a=r[e];t.has(e)&&typeof a==`string`&&St.test(a)&&(n.style.setProperty(e,a),i+=1)}return i}function clearIdeTheme(){let e=document.documentElement;for(let t of xt)e.style.removeProperty(t)}var Ct=[`ide`,`light`,`dark`,`dracula`],wt=null,Tt=null,Et=null;function themeChoiceOf(e){return typeof e==`string`&&e!==`ide`&&e in yt?e:`ide`}function currentThemeChoice(){return themeChoiceOf(B()?.theme)}function nameOf$1(e){let t=e?.toLowerCase();return t&&t in yt?t:null}e(nameOf$1,`nameOf`);function announce(e,t){announceThemeApplied(e,{theme:t});let n=window.appConfig;n&&(n.theme=t)}function showHostTheme(){document.documentElement.removeAttribute(`data-theme-choice`),clearIdeTheme(),wt&&applyIdeTheme(wt);let e=nameOf$1(wt?.theme)??Tt;e?announce(e,e):window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:{theme:null}}))}function applyThemeChoice(){let e=currentThemeChoice();Et=e,e===`ide`?showHostTheme():(clearIdeTheme(),document.documentElement.setAttribute(`data-theme-choice`,e),announce(e,e))}function chooseTheme(e){V({theme:e}),applyThemeChoice()}function rememberHostTheme(e){Tt=e}function receiveHostThemeName(e){let t=nameOf$1(e);t?(Tt=t,wt=null,currentThemeChoice()===`ide`&&(clearIdeTheme(),announce(t,e))):console.warn(`[Theme] Ignoring unknown theme from window.setTheme:`,e)}function followThemeChoice(){return H(()=>{currentThemeChoice()!==Et&&applyThemeChoice()})}var Dt=`penstock-web`,Ot=`drafts`,kt=`root`,At=`penstock-page:`,jt=250;function draftId(e,t){return`${e}\n${t}`}function request(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`IndexedDB request failed`))})}function finished(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error??Error(`IndexedDB transaction failed`)),e.onabort=()=>n(e.error??Error(`IndexedDB transaction aborted`))})}var IndexedDbDrafts=class{opened=null;database(){return this.opened??=new Promise((e,t)=>{let n=indexedDB.open(Dt,1);n.onupgradeneeded=()=>{n.result.createObjectStore(Ot,{keyPath:`id`}).createIndex(kt,`root`)},n.onsuccess=()=>{let t=n.result;t.onversionchange=()=>{t.close(),this.opened=null},e(t)},n.onerror=()=>t(n.error??Error(`IndexedDB did not open`)),n.onblocked=()=>t(Error(`IndexedDB is blocked`))}).catch(e=>{throw this.opened=null,e}),this.opened}async write(e,t){let n=(await this.database()).transaction(Ot,`readwrite`),r=n.objectStore(Ot);t.forEach(e=>r.delete(e)),e.forEach(e=>r.put(e)),await finished(n)}async list(e){return request((await this.database()).transaction(Ot,`readonly`).objectStore(Ot).index(kt).getAll(e))}},MemoryDrafts=class{records=new Map;failing=!1;async write(e,t){if(this.failing)throw Error(`the draft store is not available`);t.forEach(e=>this.records.delete(e)),e.forEach(e=>this.records.set(e.id,e))}async list(e){if(this.failing)throw Error(`the draft store is not available`);return[...this.records.values()].filter(t=>t.root===e)}};function pageLock(e){let t=null,take=()=>{if(!t)try{navigator.locks?.request(`${At}${e}`,()=>new Promise(e=>{t=e})).then(()=>{t=null})}catch{}};take(),typeof window<`u`&&(window.addEventListener(`pagehide`,()=>{t?.(),t=null}),window.addEventListener(`pageshow`,e=>{e.persisted&&take()}))}var livePages=async()=>{try{let e=(await navigator.locks?.query())?.held??[];return new Set(e.map(e=>e.name??``).filter(e=>e.startsWith(At)).map(e=>e.slice(14)))}catch{return new Set}},DraftJournal=class{backend;owner;delay;now;live;pending=new Map;timer=null;writing=Promise.resolve();failures=0;constructor(e,t){this.backend=e,this.owner=t.owner,this.delay=t.delayMs??jt,this.now=t.now??Date.now,this.live=t.live??livePages}keep(e,t){let n=draftId(e,t.path);this.pending.set(n,{...t,id:n,root:e,owner:this.owner,savedAt:this.now()}),this.schedule()}drop(e,t){this.pending.set(draftId(e,t),null),this.schedule()}schedule(){this.timer||=setTimeout(()=>{this.timer=null,this.flush()},this.delay)}flush(){if(this.timer&&=(clearTimeout(this.timer),null),this.pending.size===0)return this.writing;let e=[...this.pending];this.pending.clear();let t=e.flatMap(([,e])=>e?[e]:[]),n=e.flatMap(([e,t])=>t?[]:[e]);return this.writing=this.writing.then(()=>this.backend.write(t,n)).catch(e=>{this.failures+=1,console.warn(`The unsaved changes could not be kept in this browser:`,e)}),this.writing}async orphans(e){await this.flush();let t;try{t=await this.backend.list(e)}catch(e){return console.warn(`The unsaved changes of the last session could not be read:`,e),[]}let n=await this.live();return t.filter(e=>e.owner!==this.owner&&!n.has(e.owner)&&typeof e.text==`string`&&e.text!==e.baseline).sort((e,t)=>t.savedAt-e.savedAt)}async discard(e){e.forEach(e=>this.pending.set(e.id,null)),await this.flush()}},ICON=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="#3574F0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><style>@media (prefers-color-scheme: dark){svg{stroke:#548AF7}}</style><circle cx="6" cy="16" r="3.5"/><rect x="13" y="11" width="8" height="10" rx="2"/><circle cx="27" cy="16" r="2.5" stroke-width="3"/><path d="M9.5 16h3.5M21 16h3.5"/>${e?`<circle cx="25" cy="25" r="6" fill="#E55765" stroke="none"/>`:``}</svg>`;function faviconHref(e){return`data:image/svg+xml,${encodeURIComponent(ICON(e))}`}function titleFor(e,t,n){let r=e?m(`app.web.title.document`,{name:e,project:t}):m(`app.web.title.project`,{project:t});return n?`● ${r}`:r}function ensureLink(e){let t=document.head.querySelector(`link[rel="${e}"][data-penstock]`);if(t)return t;let n=document.createElement(`link`);return n.rel=e,n.dataset.penstock=`true`,document.head.querySelectorAll(`link[rel="${e}"]`).forEach(e=>e.remove()),document.head.appendChild(n),n}function showFavicon(e){let t=ensureLink(`icon`);t.type=`image/svg+xml`;let n=faviconHref(e);t.getAttribute(`href`)!==n&&t.setAttribute(`href`,n)}function showTitle(e){document.title!==e&&(document.title=e)}function showThemeColour(){let e=document.head.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e));let t=getComputedStyle(document.documentElement).getPropertyValue(`--theme-bg-primary`).trim();t&&(e.content=t)}var Mt=new Map,Nt=new Map;function focusSource(e,t){Mt.set(e,t),Nt.get(e)?.forEach(e=>e(t))}function lineWanted(e){return Mt.get(e)??null}function onSourceFocus(e,t){let n=Nt.get(e);return n||(n=new Set,Nt.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Nt.delete(e)}}var Pt=2e4,Workspace=class{store;scripts;revealers=new Map;waiting=new Map;constructor(e){this.store=e.store,this.scripts=e.scripts}async openScript(e){await this.openDiagram(e.diagramPath),await this.scripts.open(e.diagramPath,e)}activePath(){return this.store.snapshot().active}root(){return this.store.snapshot().listing.root}async refresh(){await this.store.refresh()}async openSource(e,t){let n=se(`source`,e);focusSource(n,t??null),await this.store.open(n,`source`)}async openText(e){await this.store.open(se(`text`,e),`template`)}async openDiagram(e){let t=this.store.snapshot().listing.files.find(t=>t.path===e);t||=(await this.store.refresh(),this.store.snapshot().listing.files.find(t=>t.path===e));let n=t?.kind??le(e);n===`bpmn`||n===`dmn`||n===`form`||n===`cmmn`||n===`testCase`||n===`template`?await this.store.open(e,n):await this.openSource(e)}async openDiff(e){let t=se(`diff`,e),n=m(`app.webHost.compare.tab`,{name:G(e)});this.store.doc(t)?(this.store.activate(t),await this.store.reload(t)):await this.store.open(t,`diff`,n)}registerRevealer(e,t){this.revealers.set(e,t);let n=this.waiting.get(e);return n&&(clearTimeout(n.timer),this.waiting.delete(e),setTimeout(()=>this.deliver(e,n.elementId),0)),()=>{this.revealers.get(e)===t&&this.revealers.delete(e)}}async revealElement(e,t){if(await this.openDiagram(e),this.store.activate(e),this.revealers.has(e)){setTimeout(()=>this.deliver(e,t),0);return}let n=this.waiting.get(e);n&&clearTimeout(n.timer);let r=setTimeout(()=>this.waiting.delete(e),Pt);this.waiting.set(e,{elementId:t,timer:r})}deliver(e,t){try{this.revealers.get(e)?.(t)}catch(e){console.error(`The element could not be revealed:`,e)}}},Ft=100;function slotKey(e){return`${e.elementId}\u0000${e.owner}\u0000${e.index}`}var ScriptSessions=class{byOwner=new Map;byId=new Map;editors;debounceMs;constructor(e,t=Ft){this.editors=e,this.debounceMs=t}async open(e,t,n,r,i,a=[]){let o=this.find(e,t);if(o){o.variables=a,await this.editors.focus(o.id);return}let s=await this.editors.open({title:i,language:n,text:r}),c={id:s,owner:e,slot:t,text:r,known:r,diagramText:null,variables:a,timer:void 0};this.sessionsOf(e).set(slotKey(t),c),this.byId.set(s,c),this.publish(e)}report(e,t,n){let r=this.find(e,t);r&&r.known!==n&&(n===r.text?(r.known=n,this.settle(r)):r.text===r.known?(r.known=n,r.text=n,this.editors.replace(r.id,n)):(r.diagramText=n,this.editors.conflict(r.id,n)))}changed(e,t){let n=this.byId.get(e);n&&(n.text=t,n.diagramText!==null&&t===n.diagramText?(n.known=t,this.settle(n)):this.schedule(n))}resolve(e,t){let n=this.byId.get(e);if(!n||n.diagramText===null)return;let r=n.diagramText;n.diagramText=null,this.editors.conflict(e,null),t===`tab`?this.schedule(n):(n.known=r,n.text=r,this.clearTimer(n),this.editors.replace(e,r))}contextOf(e){return this.byId.get(e)?.variables}ownerOf(e){return this.byId.get(e)?.owner}openSlots(e){return[...this.byOwner.get(e)?.values()??[]].map(e=>e.slot)}closed(e){let t=this.byId.get(e);t&&(this.clearTimer(t),this.flush(t),this.byId.delete(e),this.forget(t),this.publish(t.owner))}async closeAll(e){let t=this.byOwner.get(e);if(t){this.byOwner.delete(e);for(let e of t.values())this.clearTimer(e),this.byId.delete(e.id),await this.editors.close(e.id)}}find(e,t){return this.byOwner.get(e)?.get(slotKey(t))}sessionsOf(e){let t=this.byOwner.get(e);return t||(t=new Map,this.byOwner.set(e,t)),t}forget(e){let t=this.byOwner.get(e.owner);t&&(t.delete(slotKey(e.slot)),t.size===0&&this.byOwner.delete(e.owner))}settle(e){this.clearTimer(e),e.diagramText!==null&&(e.diagramText=null,this.editors.conflict(e.id,null))}schedule(e){this.clearTimer(e),e.timer=setTimeout(()=>this.flush(e),this.debounceMs)}clearTimer(e){e.timer!==void 0&&clearTimeout(e.timer),e.timer=void 0}flush(e){this.clearTimer(e),e.diagramText===null&&e.text!==e.known&&(e.known=e.text,e.owner.post({type:`scriptSlotChanged`,slot:e.slot,value:e.text}))}publish(e){e.post({type:`scriptTabsChanged`,slots:this.openSlots(e)})}},ScriptTabStore=class{state={tabs:[],focus:null};listeners=new Set;snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}add(e,t){let n={id:e,title:t.title,language:t.language,text:t.text,conflict:null,revision:0};this.publish({tabs:[...this.state.tabs,n],focus:e})}focus(e){this.state.focus!==e&&this.publish({...this.state,focus:e})}edit(e,t){this.state={...this.state,tabs:this.change(e,e=>({...e,text:t}))}}replace(e,t){this.publish({...this.state,tabs:this.change(e,e=>({...e,text:t,revision:e.revision+1}))})}setConflict(e,t){this.publish({...this.state,tabs:this.change(e,e=>({...e,conflict:t}))})}remove(e){let t=this.state.tabs.filter(t=>t.id!==e),n=this.state.focus===e?t.at(-1)?.id??null:this.state.focus;this.publish({tabs:t,focus:n})}change(e,t){return this.state.tabs.map(n=>n.id===e?t(n):n)}publish(e){this.state=e,this.listeners.forEach(e=>e())}},ScriptEditorsPort=class{tabs;serial=0;constructor(e){this.tabs=e}async open(e){this.serial+=1;let t=`script-${this.serial}`;return this.tabs.add(t,e),t}async focus(e){this.tabs.focus(e)}async close(e){this.tabs.remove(e)}replace(e,t){this.tabs.replace(e,t)}conflict(e,t){this.tabs.setConflict(e,t)}};function coreSlotOf(e){return{elementId:e.elementId,owner:e.owner,index:e.index}}function slotOf(e){return{elementId:e.elementId,owner:e.owner,index:e.index}}var ScriptHub=class{tabs=new ScriptTabStore;sessions;owners=new Map;diagrams=new Map;constructor(e){this.sessions=new ScriptSessions(new ScriptEditorsPort(this.tabs),e)}documentScripts(e){return{reportScriptSlot:async(t,n)=>this.sessions.report(this.ownerOf(e),coreSlotOf(t),n),connect:t=>(this.diagrams.set(e,t),t.setOpen(this.sessions.openSlots(this.ownerOf(e)).map(slotOf)),()=>{this.diagrams.get(e)===t&&this.diagrams.delete(e)})}}async open(e,t){await this.sessions.open(this.ownerOf(e),coreSlotOf(t.slot),t.language,t.text,t.title,t.variables)}changed(e,t){this.tabs.edit(e,t),this.sessions.changed(e,t)}resolve(e,t){this.sessions.resolve(e,t)}closed(e){this.sessions.closed(e),this.tabs.remove(e)}diagramOf(e){return this.sessions.ownerOf(e)?.diagram}history(e,t){let n=this.diagramOf(e);n&&this.diagrams.get(n)?.history(t)}contextOf(e){return this.sessions.contextOf(e)??[]}async closeDocument(e){this.diagrams.delete(e);let t=this.owners.get(e);t&&(this.owners.delete(e),await this.sessions.closeAll(t))}ownerOf(e){let t=this.owners.get(e);if(t)return t;let n={post:t=>this.deliver(e,t),diagram:e};return this.owners.set(e,n),n}deliver(e,t){let n=this.diagrams.get(e);n&&(t.type===`scriptTabsChanged`?n.setOpen(t.slots.map(slotOf)):n.applyHostWrite(slotOf(t.slot),t.value))}},It={bpmn:()=>K(()=>import(`./BpmnDocument-Ce5F4K1e.js`).then(e=>e.BpmnDocument),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70]),import.meta.url),dmn:()=>K(()=>import(`./DmnDocument-vtnARy7Q.js`).then(e=>e.DmnDocument),__vite__mapDeps([71,1,2,17,36,37,21,20,11,19,4,32,6,7,33,34,35,38,39,40,41,42,43,44,45,29,14,9,15,63,13,3,8,10,12,23,18,22,24,25,26,27,5,16,28,30,66,46,54,62,67,72,73]),import.meta.url),form:()=>K(()=>import(`./FormDocument-DHBUBUzO.js`).then(e=>e.FormDocument),__vite__mapDeps([74,1,2,17,37,4,75,21,32,6,7,33,34,76,57,36,20,11,39,45,38,40,41,42,43,44,48,14,9,15,65,62,46,25,26,5,3,8,10,12,13,16,18,19,22,23,24,27,28,29,30,66,54,67,72,77]),import.meta.url),cmmn:()=>K(()=>import(`./CmmnDocument-C_UlPowC.js`).then(e=>e.CmmnDocument),__vite__mapDeps([78,1,2,6,7,5,3,8,9,10,11,12,4,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,79]),import.meta.url),template:()=>K(()=>import(`./TemplateDocument-BRyFsofH.js`).then(e=>e.TemplateDocument),__vite__mapDeps([80,1,2,6,7,5,3,8,9,10,11,12,4,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,49,67,50,39,33,41,40,42,81,82,60,53,54,37,68]),import.meta.url),text:()=>K(()=>import(`./TextDocument-DB2hEuMA.js`).then(e=>e.TextDocument),__vite__mapDeps([83,1,2,50,39,33,41,40,42,6,7,84,8,3,9,10,11,12,4,85,46,81]),import.meta.url),code:()=>K(()=>import(`./SourceDocument-Cj8cGsoS.js`).then(e=>e.SourceDocument),__vite__mapDeps([86,1,2,50,39,33,41,40,42,6,7,84,8,3,9,10,11,12,4,85,46,81]),import.meta.url),diff:()=>K(()=>import(`./DiffDocument-BOPdBEN3.js`).then(e=>e.DiffDocument),__vite__mapDeps([87,1,2,6,7,14,9,4,15]),import.meta.url)};function packComparison(e){return JSON.stringify(e)}function unpackComparison(e){try{let t=JSON.parse(e);return typeof t.after==`string`?{before:typeof t.before==`string`?t.before:null,after:t.after,against:typeof t.against==`string`?t.against:``}:null}catch{return null}}function bridgeHost(e,t=null,n=()=>null){return{list:()=>e.listProject?e.listProject():e.getProjectFiles(),read:async t=>{let r=ce(t);if(ie(t)!==`diff`)return e.readFile(r);let[i,a]=await Promise.all([e.compareWithHead?.(r)??Promise.resolve({tracked:!1,before:null}),e.readFile(r)]);if(!i.tracked)throw Error(m(`app.webHost.compare.notTracked`));return packComparison({before:i.before,after:n(r)??a,against:`HEAD`})},write:async(n,r,i,a)=>{let o=i===`bpmn`?R(r,t??``):r;return{stored:o,stamp:await e.saveProjectFile(ce(n),o,a)}},create:(t,n)=>e.createProjectFiles(t,n)}}function decodeHandle(e){let t=/^file:\/\/([^#]*)(?:#L(\d+))?$/.exec(e);if(!t)return null;let n;try{n=decodeURIComponent(t[1])}catch{return null}return/^\/[A-Za-z]:/.test(n)&&(n=n.slice(1)),n===``?null:{path:n,line:t[2]?Number(t[2]):1}}function decodeHandles(e){let t=new Set,n=[];for(let r of e){let e=decodeHandle(r);if(!e)continue;let i=`${e.path}#${e.line}`;t.has(i)||(t.add(i),n.push(e))}return n}function showInPage(e,t,n=document.body){return new Promise(r=>{let i=document.createElement(`div`);i.className=`web-dialog-host`,n.appendChild(i);let a=!1,finish=e=>{a||(a=!0,s(null,i),i.remove(),r(e))};try{s(l(C,{locale:h(),children:e(finish)}),i)}catch(e){console.error(`A dialog could not be shown:`,e),finish(t)}})}function confirmInPage(e,t=document.body){return showInPage(t=>l(E,{title:e.title,size:`small`,destructive:e.warning,onClose:()=>t(!1),onSubmit:()=>t(!0),footer:l(w,{actions:[{id:`decline`,label:e.decline,role:`cancel`,onClick:()=>t(!1)},{id:`accept`,label:e.accept,role:`primary`,onClick:()=>t(!0)}]}),children:l(`p`,{class:`type-body web-dialog-text`,children:e.text})}),!1,t)}function download(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),3e4)}function safeExternalUrl(e){try{let t=new URL(e,window.location.href);return t.protocol===`http:`||t.protocol===`https:`||t.protocol===`mailto:`?t.href:null}catch{return null}}var Lt=`https://raw.githubusercontent.com/kern0x1b/penstock-release/main/docs/schema/penstock.schema.json`;function platformOf(e){return e===`camunda-8`?{name:dt,version:`8.9.0`,namespaces:`xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"`}:{name:nt[e].platform,version:rt[e].version,namespaces:`xmlns:${at(e)}="${nt[e].bpmn}"`}}var Rt={approve:{attributes:``,extension:`
3
+ <bpmn:extensionElements>
4
+ <zeebe:userTask />
5
+ <zeebe:formDefinition formId="approve-order" />
6
+ </bpmn:extensionElements>`},charge:{attributes:``,extension:`
7
+ <bpmn:extensionElements>
8
+ <zeebe:taskDefinition type="charge-card" />
9
+ </bpmn:extensionElements>`},decide:{attributes:``,extension:`
10
+ <bpmn:extensionElements>
11
+ <zeebe:calledDecision decisionId="shipping-method" resultVariable="shipping" />
12
+ </bpmn:extensionElements>`},receipt:{attributes:``,extension:`
13
+ <bpmn:extensionElements>
14
+ <zeebe:taskDefinition type="send-receipt" />
15
+ </bpmn:extensionElements>`},message:`<bpmn:message id="Message_shipment" name="shipment-confirmed">
16
+ <bpmn:extensionElements>
17
+ <zeebe:subscription correlationKey="=orderId" />
18
+ </bpmn:extensionElements>
19
+ </bpmn:message>`,process:``};function attributesOf(e){if(e===`camunda-8`)return Rt;let t=at(e);return{approve:{attributes:` ${t}:formRef="approve-order" ${t}:formRefBinding="latest"`,extension:``},charge:{attributes:` ${t}:type="external" ${t}:topic="charge-card"`,extension:``},decide:{attributes:` ${t}:decisionRef="shipping-method" ${t}:decisionRefBinding="latest" ${t}:resultVariable="shipping" ${t}:mapDecisionResult="singleEntry"`,extension:``},receipt:{attributes:` ${t}:delegateExpression="\${sendReceipt}"`,extension:``},message:`<bpmn:message id="Message_shipment" name="shipment-confirmed" />`,process:` ${t}:historyTimeToLive="P30D"`}}function processXml$1(e){let t=platformOf(e),n=attributesOf(e);return`<?xml version="1.0" encoding="UTF-8"?>
20
+ <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" ${t.namespaces} xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_order" targetNamespace="http://bpmn.io/schema/bpmn" modeler:executionPlatform="${t.name}" modeler:executionPlatformVersion="${t.version}">
21
+ <bpmn:process id="order-process" name="Order" isExecutable="true"${n.process}>
22
+ <bpmn:startEvent id="order_received" name="Order received">
23
+ <bpmn:outgoing>Flow_1</bpmn:outgoing>
24
+ </bpmn:startEvent>
25
+ <bpmn:userTask id="approve_order" name="Approve order"${n.approve.attributes}>${n.approve.extension}
26
+ <bpmn:incoming>Flow_1</bpmn:incoming>
27
+ <bpmn:outgoing>Flow_2</bpmn:outgoing>
28
+ </bpmn:userTask>
29
+ <bpmn:serviceTask id="charge_card" name="Charge card"${n.charge.attributes}>${n.charge.extension}
30
+ <bpmn:incoming>Flow_2</bpmn:incoming>
31
+ <bpmn:outgoing>Flow_3</bpmn:outgoing>
32
+ </bpmn:serviceTask>
33
+ <bpmn:boundaryEvent id="card_declined" name="Card declined" attachedToRef="charge_card">
34
+ <bpmn:outgoing>Flow_7</bpmn:outgoing>
35
+ <bpmn:errorEventDefinition id="ErrorEventDefinition_declined" errorRef="Error_declined" />
36
+ </bpmn:boundaryEvent>
37
+ <bpmn:businessRuleTask id="decide_shipping" name="Decide shipping method"${n.decide.attributes}>${n.decide.extension}
38
+ <bpmn:incoming>Flow_3</bpmn:incoming>
39
+ <bpmn:outgoing>Flow_4</bpmn:outgoing>
40
+ </bpmn:businessRuleTask>
41
+ <bpmn:intermediateCatchEvent id="shipment_confirmed" name="Shipment confirmed">
42
+ <bpmn:incoming>Flow_4</bpmn:incoming>
43
+ <bpmn:outgoing>Flow_5</bpmn:outgoing>
44
+ <bpmn:messageEventDefinition id="MessageEventDefinition_shipment" messageRef="Message_shipment" />
45
+ </bpmn:intermediateCatchEvent>
46
+ <bpmn:serviceTask id="send_receipt" name="Send receipt"${n.receipt.attributes}>${n.receipt.extension}
47
+ <bpmn:incoming>Flow_5</bpmn:incoming>
48
+ <bpmn:outgoing>Flow_6</bpmn:outgoing>
49
+ </bpmn:serviceTask>
50
+ <bpmn:endEvent id="order_completed" name="Order completed">
51
+ <bpmn:incoming>Flow_6</bpmn:incoming>
52
+ </bpmn:endEvent>
53
+ <bpmn:endEvent id="payment_declined" name="Payment declined">
54
+ <bpmn:incoming>Flow_7</bpmn:incoming>
55
+ </bpmn:endEvent>
56
+ <bpmn:sequenceFlow id="Flow_1" sourceRef="order_received" targetRef="approve_order" />
57
+ <bpmn:sequenceFlow id="Flow_2" sourceRef="approve_order" targetRef="charge_card" />
58
+ <bpmn:sequenceFlow id="Flow_3" sourceRef="charge_card" targetRef="decide_shipping" />
59
+ <bpmn:sequenceFlow id="Flow_4" sourceRef="decide_shipping" targetRef="shipment_confirmed" />
60
+ <bpmn:sequenceFlow id="Flow_5" sourceRef="shipment_confirmed" targetRef="send_receipt" />
61
+ <bpmn:sequenceFlow id="Flow_6" sourceRef="send_receipt" targetRef="order_completed" />
62
+ <bpmn:sequenceFlow id="Flow_7" sourceRef="card_declined" targetRef="payment_declined" />
63
+ </bpmn:process>
64
+ <bpmn:error id="Error_declined" name="Card declined" errorCode="CARD_DECLINED" />
65
+ ${n.message}
66
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
67
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="order-process">
68
+ <bpmndi:BPMNShape id="order_received_di" bpmnElement="order_received">
69
+ <dc:Bounds x="152" y="102" width="36" height="36" />
70
+ <bpmndi:BPMNLabel>
71
+ <dc:Bounds x="132" y="145" width="76" height="27" />
72
+ </bpmndi:BPMNLabel>
73
+ </bpmndi:BPMNShape>
74
+ <bpmndi:BPMNShape id="approve_order_di" bpmnElement="approve_order">
75
+ <dc:Bounds x="240" y="80" width="100" height="80" />
76
+ </bpmndi:BPMNShape>
77
+ <bpmndi:BPMNShape id="charge_card_di" bpmnElement="charge_card">
78
+ <dc:Bounds x="400" y="80" width="100" height="80" />
79
+ </bpmndi:BPMNShape>
80
+ <bpmndi:BPMNShape id="decide_shipping_di" bpmnElement="decide_shipping">
81
+ <dc:Bounds x="560" y="80" width="100" height="80" />
82
+ </bpmndi:BPMNShape>
83
+ <bpmndi:BPMNShape id="shipment_confirmed_di" bpmnElement="shipment_confirmed">
84
+ <dc:Bounds x="712" y="102" width="36" height="36" />
85
+ <bpmndi:BPMNLabel>
86
+ <dc:Bounds x="691" y="145" width="78" height="27" />
87
+ </bpmndi:BPMNLabel>
88
+ </bpmndi:BPMNShape>
89
+ <bpmndi:BPMNShape id="send_receipt_di" bpmnElement="send_receipt">
90
+ <dc:Bounds x="800" y="80" width="100" height="80" />
91
+ </bpmndi:BPMNShape>
92
+ <bpmndi:BPMNShape id="order_completed_di" bpmnElement="order_completed">
93
+ <dc:Bounds x="952" y="102" width="36" height="36" />
94
+ <bpmndi:BPMNLabel>
95
+ <dc:Bounds x="930" y="145" width="80" height="27" />
96
+ </bpmndi:BPMNLabel>
97
+ </bpmndi:BPMNShape>
98
+ <bpmndi:BPMNShape id="payment_declined_di" bpmnElement="payment_declined">
99
+ <dc:Bounds x="432" y="232" width="36" height="36" />
100
+ <bpmndi:BPMNLabel>
101
+ <dc:Bounds x="410" y="275" width="80" height="27" />
102
+ </bpmndi:BPMNLabel>
103
+ </bpmndi:BPMNShape>
104
+ <bpmndi:BPMNShape id="card_declined_di" bpmnElement="card_declined">
105
+ <dc:Bounds x="432" y="142" width="36" height="36" />
106
+ <bpmndi:BPMNLabel>
107
+ <dc:Bounds x="474" y="185" width="52" height="27" />
108
+ </bpmndi:BPMNLabel>
109
+ </bpmndi:BPMNShape>
110
+ <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1">
111
+ <di:waypoint x="188" y="120" />
112
+ <di:waypoint x="240" y="120" />
113
+ </bpmndi:BPMNEdge>
114
+ <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2">
115
+ <di:waypoint x="340" y="120" />
116
+ <di:waypoint x="400" y="120" />
117
+ </bpmndi:BPMNEdge>
118
+ <bpmndi:BPMNEdge id="Flow_3_di" bpmnElement="Flow_3">
119
+ <di:waypoint x="500" y="120" />
120
+ <di:waypoint x="560" y="120" />
121
+ </bpmndi:BPMNEdge>
122
+ <bpmndi:BPMNEdge id="Flow_4_di" bpmnElement="Flow_4">
123
+ <di:waypoint x="660" y="120" />
124
+ <di:waypoint x="712" y="120" />
125
+ </bpmndi:BPMNEdge>
126
+ <bpmndi:BPMNEdge id="Flow_5_di" bpmnElement="Flow_5">
127
+ <di:waypoint x="748" y="120" />
128
+ <di:waypoint x="800" y="120" />
129
+ </bpmndi:BPMNEdge>
130
+ <bpmndi:BPMNEdge id="Flow_6_di" bpmnElement="Flow_6">
131
+ <di:waypoint x="900" y="120" />
132
+ <di:waypoint x="952" y="120" />
133
+ </bpmndi:BPMNEdge>
134
+ <bpmndi:BPMNEdge id="Flow_7_di" bpmnElement="Flow_7">
135
+ <di:waypoint x="450" y="178" />
136
+ <di:waypoint x="450" y="232" />
137
+ </bpmndi:BPMNEdge>
138
+ </bpmndi:BPMNPlane>
139
+ </bpmndi:BPMNDiagram>
140
+ </bpmn:definitions>
141
+ `}e(processXml$1,`processXml`);function dmnNamespaceOf(e){return nt[e===`camunda-8`?`camunda-7`:e].dmn}function ttlOf(e){if(e===`camunda-8`)return{namespace:``,attribute:``};let t=at(e);return{namespace:` xmlns:${t}="${dmnNamespaceOf(e)}"`,attribute:` ${t}:historyTimeToLive="P30D"`}}function decisionXml(e){let t=platformOf(e),n=ttlOf(e);return`<?xml version="1.0" encoding="UTF-8"?>
142
+ <definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/"${n.namespace} xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_shipping" name="Shipping" namespace="${dmnNamespaceOf(e)}" modeler:executionPlatform="${t.name}" modeler:executionPlatformVersion="${t.version}">
143
+ <decision id="shipping-method" name="Shipping method"${n.attribute}>
144
+ <decisionTable id="DecisionTable_shipping" hitPolicy="FIRST">
145
+ <input id="Input_country" label="Country">
146
+ <inputExpression id="InputExpression_country" typeRef="string">
147
+ <text>country</text>
148
+ </inputExpression>
149
+ </input>
150
+ <input id="Input_amount" label="Amount">
151
+ <inputExpression id="InputExpression_amount" typeRef="number">
152
+ <text>amount</text>
153
+ </inputExpression>
154
+ </input>
155
+ <output id="Output_shipping" label="Shipping" name="shipping" typeRef="string" />
156
+ <rule id="Rule_express">
157
+ <description>Big orders always go express</description>
158
+ <inputEntry id="Rule_express_country">
159
+ <text></text>
160
+ </inputEntry>
161
+ <inputEntry id="Rule_express_amount">
162
+ <text>&gt;= 100</text>
163
+ </inputEntry>
164
+ <outputEntry id="Rule_express_shipping">
165
+ <text>"express"</text>
166
+ </outputEntry>
167
+ </rule>
168
+ <rule id="Rule_standard">
169
+ <description>Home market</description>
170
+ <inputEntry id="Rule_standard_country">
171
+ <text>"DE"</text>
172
+ </inputEntry>
173
+ <inputEntry id="Rule_standard_amount">
174
+ <text></text>
175
+ </inputEntry>
176
+ <outputEntry id="Rule_standard_shipping">
177
+ <text>"standard"</text>
178
+ </outputEntry>
179
+ </rule>
180
+ <rule id="Rule_international">
181
+ <description>Everything else</description>
182
+ <inputEntry id="Rule_international_country">
183
+ <text></text>
184
+ </inputEntry>
185
+ <inputEntry id="Rule_international_amount">
186
+ <text></text>
187
+ </inputEntry>
188
+ <outputEntry id="Rule_international_shipping">
189
+ <text>"international"</text>
190
+ </outputEntry>
191
+ </rule>
192
+ </decisionTable>
193
+ </decision>
194
+ <dmndi:DMNDI>
195
+ <dmndi:DMNDiagram id="DMNDiagram_shipping">
196
+ <dmndi:DMNShape id="DMNShape_shipping" dmnElementRef="shipping-method">
197
+ <dc:Bounds height="80" width="180" x="160" y="100" />
198
+ </dmndi:DMNShape>
199
+ </dmndi:DMNDiagram>
200
+ </dmndi:DMNDI>
201
+ </definitions>
202
+ `}function formJson(e){let t=platformOf(e);return`${JSON.stringify({components:[{text:`# Approve order
203
+ Check the order and decide whether it goes ahead.`,type:`text`,id:`Field_intro`},{label:`Order`,type:`textfield`,id:`Field_order`,key:`orderId`,readonly:!0},{label:`Amount`,type:`number`,id:`Field_amount`,key:`amount`,readonly:!0},{label:`Approved`,type:`checkbox`,id:`Field_approved`,key:`approved`}],type:`default`,id:`approve-order`,executionPlatform:t.name,executionPlatformVersion:t.version,schemaVersion:18},null,2)}\n`}var zt={orderId:`A-1001`,amount:40,country:`DE`};function testCasesJson(e){let t={processDefinitionId:`order-process`},instance=e=>({type:`CREATE_PROCESS_INSTANCE`,processDefinitionSelector:t,variables:e}),n={type:`COMPLETE_USER_TASK`,userTaskSelector:{elementId:`approve_order`},variables:{approved:!0}},r={type:`MOCK_JOB_WORKER_COMPLETE_JOB`,jobType:`charge-card`,variables:{paymentId:`pay-1`}},i={type:`CORRELATE_MESSAGE`,name:`shipment-confirmed`,...e===`camunda-8`?{correlationKey:`A-1001`}:{}},a={type:`MOCK_JOB_WORKER_COMPLETE_JOB`,jobType:`send-receipt`},finished=e=>({type:`ASSERT_PROCESS_INSTANCE`,processInstanceSelector:t,state:e}),shipping=e=>({type:`ASSERT_VARIABLES`,processInstanceSelector:t,variables:{shipping:e}}),o=e===`camunda-8`?[a]:[];return`${JSON.stringify({$schema:ft,testCases:[{name:`A home order is approved, paid, shipped standard and completed`,description:`The whole way through, with the workers mocked`,instructions:[instance(zt),n,r,i,...o,shipping(`standard`),finished(`IS_COMPLETED`)]},{name:`An order from abroad ships internationally`,instructions:[instance({...zt,country:`US`}),n,r,i,...o,shipping(`international`),finished(`IS_COMPLETED`)]},{name:`A declined card ends the order without a shipment`,instructions:[instance({...zt,amount:5e3}),n,{type:`MOCK_JOB_WORKER_THROW_BPMN_ERROR`,jobType:`charge-card`,errorCode:`CARD_DECLINED`,errorMessage:`The card was declined`},{type:`ASSERT_ELEMENT_INSTANCE`,processInstanceSelector:t,elementSelector:{elementId:`payment_declined`},state:`IS_COMPLETED`},{type:`ASSERT_ELEMENT_INSTANCES`,processInstanceSelector:t,elementSelectors:[{elementId:`decide_shipping`}],state:`IS_NOT_ACTIVATED`},finished(`IS_COMPLETED`)]}]},null,2)}\n`}var Bt=`# yaml-language-server: $schema=${Lt}
204
+ # What this project is. Commit it.
205
+
206
+ engine: camunda-8
207
+
208
+ deployment:
209
+ url: http://localhost:8080/v2
210
+ name: order-example
211
+ `,Vt=`<?xml version="1.0" encoding="UTF-8"?>
212
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
213
+ <modelVersion>4.0.0</modelVersion>
214
+ <parent>
215
+ <groupId>org.springframework.boot</groupId>
216
+ <artifactId>spring-boot-starter-parent</artifactId>
217
+ <version>4.0.8</version>
218
+ <relativePath/>
219
+ </parent>
220
+ <groupId>io.penstock.example</groupId>
221
+ <artifactId>order-workers</artifactId>
222
+ <version>1.0.0</version>
223
+ <properties>
224
+ <java.version>17</java.version>
225
+ <camunda.version>8.9.21</camunda.version>
226
+ </properties>
227
+ <dependencies>
228
+ <dependency>
229
+ <groupId>io.camunda</groupId>
230
+ <artifactId>camunda-spring-boot-starter</artifactId>
231
+ <version>\${camunda.version}</version>
232
+ </dependency>
233
+ <dependency>
234
+ <groupId>org.springframework.boot</groupId>
235
+ <artifactId>spring-boot-starter</artifactId>
236
+ </dependency>
237
+ </dependencies>
238
+ <build>
239
+ <plugins>
240
+ <plugin>
241
+ <groupId>org.springframework.boot</groupId>
242
+ <artifactId>spring-boot-maven-plugin</artifactId>
243
+ </plugin>
244
+ </plugins>
245
+ </build>
246
+ </project>
247
+ `,Ht=`camunda:
248
+ client:
249
+ mode: self-managed
250
+ rest-address: http://localhost:8080
251
+ grpc-address: http://localhost:26500
252
+ `,Ut=`package io.penstock.example;
253
+
254
+ import org.springframework.boot.SpringApplication;
255
+ import org.springframework.boot.autoconfigure.SpringBootApplication;
256
+
257
+ @SpringBootApplication
258
+ public class OrderWorkersApplication {
259
+
260
+ public static void main(String[] args) {
261
+ SpringApplication.run(OrderWorkersApplication.class, args);
262
+ }
263
+ }
264
+ `,Wt=`package io.penstock.example;
265
+
266
+ import io.camunda.client.annotation.JobWorker;
267
+ import io.camunda.client.annotation.Variable;
268
+ import io.camunda.client.exception.BpmnError;
269
+ import java.util.Map;
270
+ import java.util.UUID;
271
+ import org.springframework.stereotype.Component;
272
+
273
+ @Component
274
+ public class ChargeCardWorker {
275
+
276
+ private static final double CARD_LIMIT = 1000;
277
+
278
+ @JobWorker(type = "charge-card")
279
+ public Map<String, Object> chargeCard(@Variable String orderId, @Variable Number amount) {
280
+ if (amount.doubleValue() > CARD_LIMIT) {
281
+ throw new BpmnError("CARD_DECLINED", "Order " + orderId + " is over the card limit");
282
+ }
283
+ return Map.of("paymentId", "pay-" + UUID.randomUUID());
284
+ }
285
+ }
286
+ `,Gt=`${JSON.stringify({name:`order-node-worker`,version:`1.0.0`,private:!0,type:`module`,scripts:{start:`node index.js`},engines:{node:`>=20`},dependencies:{"@camunda8/sdk":`8.8.13`}},null,2)}\n`,Kt=`import { Camunda8 } from '@camunda8/sdk';
287
+
288
+ const camunda = new Camunda8({
289
+ CAMUNDA_AUTH_STRATEGY: 'NONE',
290
+ ZEEBE_REST_ADDRESS: process.env.ZEEBE_REST_ADDRESS ?? 'http://localhost:8080',
291
+ });
292
+
293
+ camunda.getCamundaRestClient().createJobWorker({
294
+ type: 'send-receipt',
295
+ worker: 'order-node-worker',
296
+ timeout: 30000,
297
+ maxJobsToActivate: 5,
298
+ jobHandler: async (job) => {
299
+ console.log(\`Receipt for order \${job.variables.orderId}, shipped \${job.variables.shipping}\`);
300
+ return job.complete({ receiptSentAt: new Date().toISOString() });
301
+ },
302
+ });
303
+ `,qt=`target/
304
+ node_modules/
305
+ `,Jt=`# Order process on Camunda 8
306
+
307
+ A small order process that runs from the first minute: a user task with a Camunda Form approves the order, a service task
308
+ charges the card (and ends the order when the card is declined), a decision picks the shipping method, the process waits for
309
+ a message that the parcel has shipped, and a second service task sends the receipt.
310
+
311
+ | File | What it is |
312
+ |---|---|
313
+ | \`src/main/resources/order-process.bpmn\` | the process |
314
+ | \`src/main/resources/shipping-method.dmn\` | the decision |
315
+ | \`src/main/resources/approve-order.form\` | the Camunda Form of the user task |
316
+ | \`src/main/java/io/penstock/example/ChargeCardWorker.java\` | the \`charge-card\` job worker, Spring Boot |
317
+ | \`node-worker/index.js\` | the \`send-receipt\` job worker, Node |
318
+ | \`src/test/resources/test-cases/order-process.json\` | test cases in the Camunda test-case format |
319
+ | \`penstock.yaml\` | what Penstock needs to know: the engine and where to deploy |
320
+
321
+ ## You need
322
+
323
+ - Java 17 or newer and Maven 3.9 or newer for the Spring Boot worker, Node 20 or newer for the Node worker
324
+ - a local Camunda 8, for example [Camunda 8 Run](https://github.com/camunda/camunda/tree/main/c8run) (it needs a JDK 21 or newer)
325
+ - Penstock: the plugin in your IDE, or the \`penstock\` command line
326
+
327
+ ## Run it
328
+
329
+ 1. Start Camunda 8 Run and leave it running: \`./start.sh\` in its folder (\`c8run.exe start\` on Windows). Operate and Tasklist
330
+ open at http://localhost:8080, the login is demo / demo.
331
+ 2. Look at the diagrams in the editor, or check them from the terminal: \`penstock check .\`
332
+ 3. Deploy the process, the decision and the form: \`penstock deploy .\`
333
+ 4. Start the workers, each in its own terminal:
334
+ - \`mvn spring-boot:run\`
335
+ - \`cd node-worker && npm install && npm start\`
336
+ 5. Start an order. A home order under 1000 is paid and ships standard; use \`"amount": 5000\` to see the card declined:
337
+
338
+ \`\`\`
339
+ curl -X POST http://localhost:8080/v2/process-instances -H 'Content-Type: application/json' \\
340
+ -d '{"processDefinitionId":"order-process","variables":{"orderId":"A-1001","amount":40,"country":"DE"}}'
341
+ \`\`\`
342
+
343
+ 6. Open Tasklist, approve the order, then tell the process the parcel has shipped:
344
+
345
+ \`\`\`
346
+ curl -X POST http://localhost:8080/v2/messages/correlation -H 'Content-Type: application/json' \\
347
+ -d '{"name":"shipment-confirmed","correlationKey":"A-1001"}'
348
+ \`\`\`
349
+
350
+ ## Run the test cases
351
+
352
+ \`penstock scenarios run .\` deploys a test build of the process, mocks the job workers and runs the three cases in
353
+ \`src/test/resources/test-cases/order-process.json\` against your local engine. The first run on a local engine asks once
354
+ whether it may. Test-case runs are a Penstock Pro feature and every machine starts with a 30 day Pro trial.
355
+
356
+ ## Where the versions come from
357
+
358
+ - Spring Boot worker: \`io.camunda:camunda-spring-boot-starter\` 8.9.21 on Spring Boot 4.0.8,
359
+ see [Camunda Spring Boot Starter](https://docs.camunda.io/docs/apis-tools/camunda-spring-boot-starter/getting-started/).
360
+ Before 8.10 it was published as \`spring-boot-starter-camunda-sdk\`.
361
+ - Node worker: \`@camunda8/sdk\` 8.8.13, see [the Camunda 8 JavaScript SDK](https://github.com/camunda/camunda-8-js-sdk).
362
+ - Local engine: [Camunda 8 Run](https://docs.camunda.io/docs/8.7/self-managed/setup/deploy/local/c8run/) and its
363
+ [readme](https://github.com/camunda/camunda/blob/main/c8run/README.md).
364
+ `;function camunda8Files(){return{"penstock.yaml":Bt,"README.md":Jt,".gitignore":qt,"pom.xml":Vt,"src/main/resources/application.yaml":Ht,"src/main/resources/order-process.bpmn":processXml$1(`camunda-8`),"src/main/resources/shipping-method.dmn":decisionXml(`camunda-8`),"src/main/resources/approve-order.form":formJson(`camunda-8`),"src/main/java/io/penstock/example/OrderWorkersApplication.java":Ut,"src/main/java/io/penstock/example/ChargeCardWorker.java":Wt,"src/test/resources/test-cases/order-process.json":testCasesJson(`camunda-8`),"node-worker/package.json":Gt,"node-worker/index.js":Kt}}function penstockYaml$1(e){return`# yaml-language-server: $schema=${Lt}
365
+ # What this project is. Commit it.
366
+
367
+ engine: ${e}
368
+
369
+ deployment:
370
+ url: http://localhost:8080/engine-rest
371
+ name: order-example
372
+ `}e(penstockYaml$1,`penstockYaml`);function pom$1(e,t){return`<?xml version="1.0" encoding="UTF-8"?>
373
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
374
+ <modelVersion>4.0.0</modelVersion>
375
+ <parent>
376
+ <groupId>org.springframework.boot</groupId>
377
+ <artifactId>spring-boot-starter-parent</artifactId>
378
+ <version>${e.springBoot}</version>
379
+ <relativePath/>
380
+ </parent>
381
+ <groupId>io.penstock.example</groupId>
382
+ <artifactId>order-engine</artifactId>
383
+ <version>1.0.0</version>
384
+ <properties>
385
+ <java.version>17</java.version>
386
+ <${t}.version>${e.version}</${t}.version>
387
+ </properties>
388
+ <dependencies>
389
+ <dependency>
390
+ <groupId>${e.springBootGroup}</groupId>
391
+ <artifactId>${e.rest}</artifactId>
392
+ <version>\${${t}.version}</version>
393
+ </dependency>
394
+ <dependency>
395
+ <groupId>${e.springBootGroup}</groupId>
396
+ <artifactId>${e.webapp}</artifactId>
397
+ <version>\${${t}.version}</version>
398
+ </dependency>
399
+ <dependency>
400
+ <groupId>com.h2database</groupId>
401
+ <artifactId>h2</artifactId>
402
+ <scope>runtime</scope>
403
+ </dependency>
404
+ </dependencies>
405
+ <build>
406
+ <plugins>
407
+ <plugin>
408
+ <groupId>org.springframework.boot</groupId>
409
+ <artifactId>spring-boot-maven-plugin</artifactId>
410
+ </plugin>
411
+ </plugins>
412
+ </build>
413
+ </project>
414
+ `}e(pom$1,`pom`);function workerPom(e,t){return`<?xml version="1.0" encoding="UTF-8"?>
415
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
416
+ <modelVersion>4.0.0</modelVersion>
417
+ <groupId>io.penstock.example</groupId>
418
+ <artifactId>order-worker</artifactId>
419
+ <version>1.0.0</version>
420
+ <properties>
421
+ <maven.compiler.release>17</maven.compiler.release>
422
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
423
+ <${t}.version>${e.version}</${t}.version>
424
+ </properties>
425
+ <dependencies>
426
+ <dependency>
427
+ <groupId>${e.bpmGroup}</groupId>
428
+ <artifactId>${e.client}</artifactId>
429
+ <version>\${${t}.version}</version>
430
+ </dependency>
431
+ <dependency>
432
+ <groupId>org.slf4j</groupId>
433
+ <artifactId>slf4j-simple</artifactId>
434
+ <version>2.0.17</version>
435
+ </dependency>
436
+ </dependencies>
437
+ <build>
438
+ <plugins>
439
+ <plugin>
440
+ <groupId>org.codehaus.mojo</groupId>
441
+ <artifactId>exec-maven-plugin</artifactId>
442
+ <version>3.5.0</version>
443
+ <configuration>
444
+ <mainClass>io.penstock.example.worker.ChargeCardWorker</mainClass>
445
+ </configuration>
446
+ </plugin>
447
+ </plugins>
448
+ </build>
449
+ </project>
450
+ `}function applicationYaml(e){return`server:
451
+ port: 8080
452
+
453
+ ${e}:
454
+ bpm:
455
+ admin-user:
456
+ id: demo
457
+ password: demo
458
+ filter:
459
+ create: All tasks
460
+ `}var Yt=`package io.penstock.example;
461
+
462
+ import org.springframework.boot.SpringApplication;
463
+ import org.springframework.boot.autoconfigure.SpringBootApplication;
464
+
465
+ @SpringBootApplication
466
+ public class OrderApplication {
467
+
468
+ public static void main(String[] args) {
469
+ SpringApplication.run(OrderApplication.class, args);
470
+ }
471
+ }
472
+ `;function delegate(e){return`package io.penstock.example;
473
+
474
+ import java.time.Instant;
475
+ import ${e}.bpm.engine.delegate.DelegateExecution;
476
+ import ${e}.bpm.engine.delegate.JavaDelegate;
477
+ import org.slf4j.Logger;
478
+ import org.slf4j.LoggerFactory;
479
+ import org.springframework.stereotype.Component;
480
+
481
+ @Component("sendReceipt")
482
+ public class SendReceiptDelegate implements JavaDelegate {
483
+
484
+ private static final Logger LOG = LoggerFactory.getLogger(SendReceiptDelegate.class);
485
+
486
+ @Override
487
+ public void execute(DelegateExecution execution) {
488
+ LOG.info("Receipt for order {}, shipped {}", execution.getVariable("orderId"), execution.getVariable("shipping"));
489
+ execution.setVariable("receiptSentAt", Instant.now().toString());
490
+ }
491
+ }
492
+ `}function worker(e){return`package io.penstock.example.worker;
493
+
494
+ import java.util.Map;
495
+ import java.util.UUID;
496
+ import ${e}.bpm.client.ExternalTaskClient;
497
+ import ${e}.bpm.client.task.ExternalTask;
498
+ import ${e}.bpm.client.task.ExternalTaskService;
499
+
500
+ public class ChargeCardWorker {
501
+
502
+ private static final double CARD_LIMIT = 1000;
503
+
504
+ public static void main(String[] args) {
505
+ String engine = System.getenv().getOrDefault("ENGINE_REST_URL", "http://localhost:8080/engine-rest");
506
+ ExternalTaskClient client = ExternalTaskClient.create()
507
+ .baseUrl(engine)
508
+ .asyncResponseTimeout(10000)
509
+ .build();
510
+ client.subscribe("charge-card")
511
+ .lockDuration(30000)
512
+ .handler(ChargeCardWorker::chargeCard)
513
+ .open();
514
+ }
515
+
516
+ private static void chargeCard(ExternalTask task, ExternalTaskService service) {
517
+ String orderId = task.getVariable("orderId");
518
+ Number amount = task.getVariable("amount");
519
+ if (amount.doubleValue() > CARD_LIMIT) {
520
+ service.handleBpmnError(task, "CARD_DECLINED", "Order " + orderId + " is over the card limit");
521
+ return;
522
+ }
523
+ service.complete(task, Map.of("paymentId", "pay-" + UUID.randomUUID()));
524
+ }
525
+ }
526
+ `}var Xt=`target/
527
+ `,Zt=`See the [Spring Boot integration](https://docs.camunda.org/manual/latest/user-guide/spring-boot-integration/) and the
528
+ [External Task Client](https://docs.camunda.org/manual/latest/user-guide/ext-client/) in the Camunda documentation.
529
+ 7.24.0 is the last community release on Maven Central.
530
+ `;function readme$1(e,t){let n=ot(e);return`# Order process on ${n}
531
+
532
+ A small order process that runs from the first minute: a user task with a form approves the order, an external task
533
+ charges the card (and ends the order when the card is declined), a decision picks the shipping method, the process waits for
534
+ a message that the parcel has shipped, and a Java delegate sends the receipt.
535
+
536
+ | File | What it is |
537
+ |---|---|
538
+ | \`src/main/resources/order-process.bpmn\` | the process |
539
+ | \`src/main/resources/shipping-method.dmn\` | the decision |
540
+ | \`src/main/resources/approve-order.form\` | the form of the user task |
541
+ | \`src/main/java/io/penstock/example/SendReceiptDelegate.java\` | the Java delegate behind \`send_receipt\` |
542
+ | \`worker/\` | the external task worker for the topic \`charge-card\`, a plain Java client |
543
+ | \`src/test/resources/test-cases/order-process.json\` | test cases in the Camunda test-case format |
544
+ | \`penstock.yaml\` | what Penstock needs to know: the engine and where to deploy |
545
+
546
+ ## You need
547
+
548
+ - Java 17 or newer and Maven 3.9 or newer
549
+ - Penstock: the plugin in your IDE, or the \`penstock\` command line
550
+
551
+ The engine is part of the example: a Spring Boot application with the ${n} engine, its REST API and the web apps,
552
+ on an in-memory H2 database.
553
+
554
+ ## Run it
555
+
556
+ 1. Start the engine and leave it running: \`mvn spring-boot:run\`. Cockpit and Tasklist are at http://localhost:8080,
557
+ the login is demo / demo. The process, the decision and the form are deployed when it starts.
558
+ 2. Look at the diagrams in the editor, or check them from the terminal: \`penstock check .\`
559
+ 3. After you change a diagram, deploy it again: \`penstock deploy .\`
560
+ 4. Start the external task worker in a second terminal: \`mvn -f worker/pom.xml compile exec:java\`
561
+ 5. Start an order. A home order under 1000 is paid and ships standard; use \`"amount": 5000\` to see the card declined:
562
+
563
+ \`\`\`
564
+ curl -X POST http://localhost:8080/engine-rest/process-definition/key/order-process/start -H 'Content-Type: application/json' \\
565
+ -d '{"businessKey":"A-1001","variables":{"orderId":{"value":"A-1001"},"amount":{"value":40},"country":{"value":"DE"}}}'
566
+ \`\`\`
567
+
568
+ 6. Open Tasklist, approve the order, then tell the process the parcel has shipped:
569
+
570
+ \`\`\`
571
+ curl -X POST http://localhost:8080/engine-rest/message -H 'Content-Type: application/json' \\
572
+ -d '{"messageName":"shipment-confirmed","businessKey":"A-1001"}'
573
+ \`\`\`
574
+
575
+ ## Run the test cases
576
+
577
+ \`penstock scenarios run .\` deploys a test build of the process, mocks the external task and runs the three cases in
578
+ \`src/test/resources/test-cases/order-process.json\` against the running engine. The delegate runs for real, so keep the
579
+ engine from step 1 running. The first run on a local engine asks once whether it may. Test-case runs are a Penstock Pro
580
+ feature and every machine starts with a 30 day Pro trial.
581
+
582
+ ## Where the versions come from
583
+
584
+ ${[`- Engine: \`${t.rest}\` and \`${t.webapp}\` ${t.version} on Spring Boot ${t.springBoot}, from \`${t.springBootGroup}\`.`,`- Worker: \`${t.client}\` ${t.version}, from \`${t.bpmGroup}\`.`].join(`
585
+ `)}
586
+ ${e===`camunda-7`?`\n${Zt}`:``}`}e(readme$1,`readme`);function sevenFamilyFiles(e,t=`3`){let n=et(e,t);if(!n)throw Error(`${ot(e)} has no Spring Boot ${t} starters`);let r=n.client.replace(/-external-task-client$/,``),i=ct(e);return{"penstock.yaml":penstockYaml$1(e),"README.md":readme$1(e,n),".gitignore":Xt,"pom.xml":pom$1(n,r),"src/main/resources/application.yaml":applicationYaml(nt[e].settings),"src/main/resources/order-process.bpmn":processXml$1(e),"src/main/resources/shipping-method.dmn":decisionXml(e),"src/main/resources/approve-order.form":formJson(e),"src/main/java/io/penstock/example/OrderApplication.java":Yt,"src/main/java/io/penstock/example/SendReceiptDelegate.java":delegate(i),"src/test/resources/test-cases/order-process.json":testCasesJson(e),"worker/pom.xml":workerPom(n,r),"worker/src/main/java/io/penstock/example/worker/ChargeCardWorker.java":worker(i)}}var Qt={flowable:{group:`org.flowable`,artifact:`flowable-engine`,version:`7.1.0`,name:`flowable`},activiti:{group:`org.activiti`,artifact:`activiti-engine`,version:`7.1.0.M6`,name:`activiti`}};function penstockYaml(e){return`# yaml-language-server: $schema=${Lt}
587
+ # What this project is. Commit it.
588
+
589
+ engine: ${e}
590
+ `}function pom(e){let{group:t,artifact:n,version:r,name:i}=Qt[e];return`<?xml version="1.0" encoding="UTF-8"?>
591
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
592
+ <modelVersion>4.0.0</modelVersion>
593
+ <groupId>io.penstock.example</groupId>
594
+ <artifactId>order-engine</artifactId>
595
+ <version>1.0.0</version>
596
+ <properties>
597
+ <maven.compiler.release>17</maven.compiler.release>
598
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
599
+ <${i}.version>${r}</${i}.version>
600
+ </properties>
601
+ <dependencies>
602
+ <dependency>
603
+ <groupId>${t}</groupId>
604
+ <artifactId>${n}</artifactId>
605
+ <version>\${${i}.version}</version>
606
+ </dependency>
607
+ <dependency>
608
+ <groupId>com.h2database</groupId>
609
+ <artifactId>h2</artifactId>
610
+ <version>2.3.232</version>
611
+ </dependency>
612
+ <dependency>
613
+ <groupId>org.slf4j</groupId>
614
+ <artifactId>slf4j-simple</artifactId>
615
+ <version>2.0.17</version>
616
+ </dependency>
617
+ </dependencies>
618
+ <build>
619
+ <plugins>
620
+ <plugin>
621
+ <groupId>org.codehaus.mojo</groupId>
622
+ <artifactId>exec-maven-plugin</artifactId>
623
+ <version>3.5.0</version>
624
+ <configuration>
625
+ <mainClass>io.penstock.example.OrderApplication</mainClass>
626
+ </configuration>
627
+ </plugin>
628
+ </plugins>
629
+ </build>
630
+ </project>
631
+ `}function application(e){return`package io.penstock.example;
632
+
633
+ import java.util.List;
634
+ import java.util.Map;
635
+ import ${e}.engine.ProcessEngine;
636
+ import ${e}.engine.ProcessEngineConfiguration;
637
+ import ${e}.engine.RepositoryService;
638
+ import ${e}.engine.RuntimeService;
639
+ import ${e}.engine.TaskService;
640
+ import ${e}.engine.task.Task;
641
+
642
+ public class OrderApplication {
643
+
644
+ public static void main(String[] args) {
645
+ ProcessEngineConfiguration configuration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
646
+ configuration.setBeans(Map.of("sendReceipt", new SendReceiptDelegate()));
647
+ ProcessEngine engine = configuration.buildProcessEngine();
648
+ try {
649
+ RepositoryService repository = engine.getRepositoryService();
650
+ repository.createDeployment().addClasspathResource("processes/order-process.bpmn").name("order-example").deploy();
651
+
652
+ RuntimeService runtime = engine.getRuntimeService();
653
+ String instance = runtime.startProcessInstanceByKey("order-process", Map.of("orderId", "A-1001", "amount", 40)).getId();
654
+
655
+ TaskService tasks = engine.getTaskService();
656
+ List<Task> waiting = tasks.createTaskQuery().processInstanceId(instance).taskCandidateGroup("managers").list();
657
+ System.out.println("Waiting for approval: " + waiting.get(0).getName());
658
+ tasks.complete(waiting.get(0).getId(), Map.of("approved", true));
659
+
660
+ boolean finished = runtime.createProcessInstanceQuery().processInstanceId(instance).count() == 0;
661
+ System.out.println("Order finished: " + finished);
662
+ } finally {
663
+ engine.close();
664
+ }
665
+ }
666
+ }
667
+ `}function chargeDelegate(e){return`package io.penstock.example;
668
+
669
+ import ${e}.engine.delegate.DelegateExecution;
670
+ import ${e}.engine.delegate.JavaDelegate;
671
+
672
+ public class ChargeCardDelegate implements JavaDelegate {
673
+
674
+ private static final double CARD_LIMIT = 1000;
675
+
676
+ @Override
677
+ public void execute(DelegateExecution execution) {
678
+ Number amount = (Number) execution.getVariable("amount");
679
+ execution.setVariable("paid", amount.doubleValue() <= CARD_LIMIT);
680
+ }
681
+ }
682
+ `}function receiptDelegate(e){return`package io.penstock.example;
683
+
684
+ import java.time.Instant;
685
+ import ${e}.engine.delegate.DelegateExecution;
686
+ import ${e}.engine.delegate.JavaDelegate;
687
+
688
+ public class SendReceiptDelegate implements JavaDelegate {
689
+
690
+ @Override
691
+ public void execute(DelegateExecution execution) {
692
+ System.out.println("Receipt for order " + execution.getVariable("orderId"));
693
+ execution.setVariable("receiptSentAt", Instant.now().toString());
694
+ }
695
+ }
696
+ `}function processXml(e){let t=e;return`<?xml version="1.0" encoding="UTF-8"?>
697
+ <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:${t}="${st[e]}" id="Definitions_order" targetNamespace="http://bpmn.io/schema/bpmn">
698
+ <bpmn:process id="order-process" name="Order" isExecutable="true">
699
+ <bpmn:startEvent id="order_received" name="Order received">
700
+ <bpmn:outgoing>Flow_1</bpmn:outgoing>
701
+ </bpmn:startEvent>
702
+ <bpmn:userTask id="approve_order" name="Approve order" ${t}:candidateGroups="managers" ${t}:formKey="approve-order">
703
+ <bpmn:incoming>Flow_1</bpmn:incoming>
704
+ <bpmn:outgoing>Flow_2</bpmn:outgoing>
705
+ </bpmn:userTask>
706
+ <bpmn:exclusiveGateway id="is_approved" name="Approved?" default="Flow_4">
707
+ <bpmn:incoming>Flow_2</bpmn:incoming>
708
+ <bpmn:outgoing>Flow_3</bpmn:outgoing>
709
+ <bpmn:outgoing>Flow_4</bpmn:outgoing>
710
+ </bpmn:exclusiveGateway>
711
+ <bpmn:serviceTask id="charge_card" name="Charge card" ${t}:class="io.penstock.example.ChargeCardDelegate">
712
+ <bpmn:incoming>Flow_3</bpmn:incoming>
713
+ <bpmn:outgoing>Flow_5</bpmn:outgoing>
714
+ </bpmn:serviceTask>
715
+ <bpmn:serviceTask id="send_receipt" name="Send receipt" ${t}:delegateExpression="\${sendReceipt}">
716
+ <bpmn:incoming>Flow_5</bpmn:incoming>
717
+ <bpmn:outgoing>Flow_6</bpmn:outgoing>
718
+ </bpmn:serviceTask>
719
+ <bpmn:endEvent id="order_completed" name="Order completed">
720
+ <bpmn:incoming>Flow_6</bpmn:incoming>
721
+ </bpmn:endEvent>
722
+ <bpmn:endEvent id="order_rejected" name="Order rejected">
723
+ <bpmn:incoming>Flow_4</bpmn:incoming>
724
+ </bpmn:endEvent>
725
+ <bpmn:sequenceFlow id="Flow_1" sourceRef="order_received" targetRef="approve_order" />
726
+ <bpmn:sequenceFlow id="Flow_2" sourceRef="approve_order" targetRef="is_approved" />
727
+ <bpmn:sequenceFlow id="Flow_3" name="Yes" sourceRef="is_approved" targetRef="charge_card">
728
+ <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">\${approved}</bpmn:conditionExpression>
729
+ </bpmn:sequenceFlow>
730
+ <bpmn:sequenceFlow id="Flow_4" name="No" sourceRef="is_approved" targetRef="order_rejected" />
731
+ <bpmn:sequenceFlow id="Flow_5" sourceRef="charge_card" targetRef="send_receipt" />
732
+ <bpmn:sequenceFlow id="Flow_6" sourceRef="send_receipt" targetRef="order_completed" />
733
+ </bpmn:process>
734
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
735
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="order-process">
736
+ <bpmndi:BPMNShape id="order_received_di" bpmnElement="order_received">
737
+ <dc:Bounds x="152" y="102" width="36" height="36" />
738
+ <bpmndi:BPMNLabel>
739
+ <dc:Bounds x="132" y="145" width="76" height="27" />
740
+ </bpmndi:BPMNLabel>
741
+ </bpmndi:BPMNShape>
742
+ <bpmndi:BPMNShape id="approve_order_di" bpmnElement="approve_order">
743
+ <dc:Bounds x="240" y="80" width="100" height="80" />
744
+ </bpmndi:BPMNShape>
745
+ <bpmndi:BPMNShape id="is_approved_di" bpmnElement="is_approved" isMarkerVisible="true">
746
+ <dc:Bounds x="395" y="95" width="50" height="50" />
747
+ <bpmndi:BPMNLabel>
748
+ <dc:Bounds x="396" y="65" width="48" height="14" />
749
+ </bpmndi:BPMNLabel>
750
+ </bpmndi:BPMNShape>
751
+ <bpmndi:BPMNShape id="charge_card_di" bpmnElement="charge_card">
752
+ <dc:Bounds x="500" y="80" width="100" height="80" />
753
+ </bpmndi:BPMNShape>
754
+ <bpmndi:BPMNShape id="send_receipt_di" bpmnElement="send_receipt">
755
+ <dc:Bounds x="660" y="80" width="100" height="80" />
756
+ </bpmndi:BPMNShape>
757
+ <bpmndi:BPMNShape id="order_completed_di" bpmnElement="order_completed">
758
+ <dc:Bounds x="822" y="102" width="36" height="36" />
759
+ <bpmndi:BPMNLabel>
760
+ <dc:Bounds x="800" y="145" width="80" height="27" />
761
+ </bpmndi:BPMNLabel>
762
+ </bpmndi:BPMNShape>
763
+ <bpmndi:BPMNShape id="order_rejected_di" bpmnElement="order_rejected">
764
+ <dc:Bounds x="402" y="222" width="36" height="36" />
765
+ <bpmndi:BPMNLabel>
766
+ <dc:Bounds x="383" y="265" width="74" height="14" />
767
+ </bpmndi:BPMNLabel>
768
+ </bpmndi:BPMNShape>
769
+ <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1">
770
+ <di:waypoint x="188" y="120" />
771
+ <di:waypoint x="240" y="120" />
772
+ </bpmndi:BPMNEdge>
773
+ <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2">
774
+ <di:waypoint x="340" y="120" />
775
+ <di:waypoint x="395" y="120" />
776
+ </bpmndi:BPMNEdge>
777
+ <bpmndi:BPMNEdge id="Flow_3_di" bpmnElement="Flow_3">
778
+ <di:waypoint x="445" y="120" />
779
+ <di:waypoint x="500" y="120" />
780
+ <bpmndi:BPMNLabel>
781
+ <dc:Bounds x="463" y="102" width="19" height="14" />
782
+ </bpmndi:BPMNLabel>
783
+ </bpmndi:BPMNEdge>
784
+ <bpmndi:BPMNEdge id="Flow_4_di" bpmnElement="Flow_4">
785
+ <di:waypoint x="420" y="145" />
786
+ <di:waypoint x="420" y="222" />
787
+ <bpmndi:BPMNLabel>
788
+ <dc:Bounds x="428" y="180" width="15" height="14" />
789
+ </bpmndi:BPMNLabel>
790
+ </bpmndi:BPMNEdge>
791
+ <bpmndi:BPMNEdge id="Flow_5_di" bpmnElement="Flow_5">
792
+ <di:waypoint x="600" y="120" />
793
+ <di:waypoint x="660" y="120" />
794
+ </bpmndi:BPMNEdge>
795
+ <bpmndi:BPMNEdge id="Flow_6_di" bpmnElement="Flow_6">
796
+ <di:waypoint x="760" y="120" />
797
+ <di:waypoint x="822" y="120" />
798
+ </bpmndi:BPMNEdge>
799
+ </bpmndi:BPMNPlane>
800
+ </bpmndi:BPMNDiagram>
801
+ </bpmn:definitions>
802
+ `}function readme(e){let t=ot(e),{group:n,artifact:r,version:i}=Qt[e];return`# Order process on ${t}
803
+
804
+ A small order process that runs from the first minute: a user task for the managers group approves the order, a gateway
805
+ sends a rejected order to its own end, and an approved one is charged by a Java delegate named by class and receives its
806
+ receipt from a delegate named by expression.
807
+
808
+ | File | What it is |
809
+ |---|---|
810
+ | \`src/main/resources/processes/order-process.bpmn\` | the process, with the \`${e}:\` extensions the engine reads |
811
+ | \`src/main/java/io/penstock/example/OrderApplication.java\` | builds an in-memory engine, deploys the process, starts an order and approves it |
812
+ | \`src/main/java/io/penstock/example/ChargeCardDelegate.java\` | the delegate behind \`charge_card\`, named by class |
813
+ | \`src/main/java/io/penstock/example/SendReceiptDelegate.java\` | the delegate behind \`send_receipt\`, named by expression |
814
+ | \`penstock.yaml\` | what Penstock needs to know: the engine |
815
+
816
+ ## You need
817
+
818
+ - Java 17 or newer and Maven 3.9 or newer
819
+ - Penstock: the plugin in your IDE, or the \`penstock\` command line
820
+
821
+ ## Run it
822
+
823
+ 1. Look at the diagram in the editor, or check it from the terminal: \`penstock check .\`
824
+ 2. Run the engine: \`mvn compile exec:java\`. It deploys the process, starts order A-1001, completes the approval and prints
825
+ the result.
826
+
827
+ Penstock reads and checks ${t} diagrams, and its editor has a properties panel for the ${e}: attributes. Deploying
828
+ from Penstock, test-case runs and generated tests are not part of the ${t} profile; deploy with the engine's own tools.
829
+
830
+ ## Where the versions come from
831
+
832
+ - Engine: \`${r}\` ${i}, from \`${n}\`, on an in-memory H2 database.
833
+
834
+ ${e===`flowable`?`See the [Flowable documentation](https://documentation.flowable.org/latest/) for the BPMN constructs the engine supports.`:`See the [Activiti documentation](https://www.activiti.org/documentation) for the BPMN constructs the engine supports.`}
835
+ `}function flowableFamilyFiles(e){let t=ct(e);return{"penstock.yaml":penstockYaml(e),"README.md":readme(e),".gitignore":`target/
836
+ `,"pom.xml":pom(e),"src/main/resources/processes/order-process.bpmn":processXml(e),"src/main/java/io/penstock/example/OrderApplication.java":application(t),"src/main/java/io/penstock/example/ChargeCardDelegate.java":chargeDelegate(t),"src/main/java/io/penstock/example/SendReceiptDelegate.java":receiptDelegate(t)}}var $t=[`camunda-8`,`camunda-7`,`operaton`,`cib-seven`,`flowable`,`activiti`];function isExample(e){return $t.includes(e)}function exampleFiles(e,t=`3`){return e===`camunda-8`?camunda8Files():e===`flowable`||e===`activiti`?flowableFamilyFiles(e):sevenFamilyFiles(e,t)}function tabList(e){let t=e.map(e=>e.id),n=t.find((e,n)=>t.indexOf(e)!==n);if(n!==void 0)throw Error(`the tab ${n} is listed twice`);return e}function shownTab(e,t){return e.hidden||t&&e.collapsed?null:e.tab}function droppedTabs(e,t,n,r){let i=e.reduce((e,t)=>e+t.width,0);if(i<=n)return[];let a=i,o=[];for(let i=e.length-1;i>=0&&a+r>n;--i){let n=e[i];n.id!==t&&(o.unshift(n.id),a-=n.width)}return o}var en=`properties`,tn=280,nn=.3,rn=320,an=480;function initialSidebar(){return{hidden:!1,tab:en,width:null,collapsed:!1,stacks:{}}}function selectTab(e,t,n){return t.includes(n)?{...e,tab:n,hidden:!1,collapsed:!1}:e}function toggleHidden(e){return{...e,hidden:!e.hidden}}function toggleCollapsed(e){return{...e,collapsed:!e.collapsed}}function stackOf(e,t){return e.stacks&&Object.hasOwn(e.stacks,t)?e.stacks[t]:[]}function pushView(e,t,n){return{...e,stacks:{...e.stacks,[t]:[...stackOf(e,t),n]}}}function popView(e,t){return{...e,stacks:{...e.stacks,[t]:stackOf(e,t).slice(0,-1)}}}function resetViews(e,t){return{...e,stacks:{...e.stacks,[t]:[]}}}function defaultWidth(e){return Number.isFinite(e)?Math.min(an,Math.max(rn,Math.round(e*nn))):rn}function widthLimits(e){return Number.isFinite(e)?{min:tn,max:Math.max(tn,Math.floor(e/2))}:{min:tn,max:tn}}function resolveWidth(e,t){let{min:n,max:r}=widthLimits(t),i=e!==null&&Number.isFinite(e)?e:defaultWidth(t);return Math.min(r,Math.max(n,i))}function isDrawer(e){return e<960}var isRecord=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function sidebarOf(e,t){let n=isRecord(e)?e.sidebarByEditor:void 0,r=isRecord(n)&&Object.hasOwn(n,t)?n[t]:void 0;return isRecord(r)?r:{}}function toPreferences(e,t,n={}){let r=isRecord(n)?n.sidebarByEditor:void 0,i=isRecord(r)?{...r}:{};return delete i[t],{sidebarWidth:e.width,sidebarByEditor:{...i,[t]:{tab:e.tab,hidden:e.hidden,collapsed:e.collapsed}}}}function fromPreferences(e,t,n){let r=sidebarOf(e,n),i=typeof r.tab==`string`&&t.includes(r.tab)?r.tab:t[0]??`properties`,a=isRecord(e)?e.sidebarWidth:void 0;return{...initialSidebar(),tab:i,width:typeof a==`number`&&Number.isFinite(a)?a:null,hidden:r.hidden===!0,collapsed:r.collapsed===!0}}function arrowTab(e,t,n){let r=e.indexOf(t);return r<0||e.length===0?null:n===`ArrowRight`?e[(r+1)%e.length]:n===`ArrowLeft`?e[(r-1+e.length)%e.length]:n===`Home`?e[0]:n===`End`?e[e.length-1]:null}function badgeText(e){return e?e>99?`99+`:String(e):``}function badgeLabel(e){return e?m(e>99?`app.sidebar.moreThan99Findings`:`app.sidebar.findingCount`,{count:e}):``}function isRepeatOfPress(e,t){return e!==null&&t-e<300}function isSidebarShortcut(e,t){return je(e,Ae,t)}function titleCommit(e,t){let n=t.trim();return n===``||n===e?null:n}function isRenameKey(e){return e===`F2`}var on=`
837
+ .bpmn-preview {
838
+ display: flex;
839
+ flex-direction: column;
840
+ width: 100%;
841
+ height: 100vh;
842
+ background: var(--theme-bg-primary);
843
+ color: var(--theme-fg-primary);
844
+ font-size: var(--type-size-body);
845
+ }
846
+
847
+ .bpmn-preview__toolbar {
848
+ flex: 0 0 auto;
849
+ display: flex;
850
+ align-items: center;
851
+ gap: 4px;
852
+ min-height: 32px;
853
+ padding: 4px 12px;
854
+ background: var(--theme-bg-primary);
855
+ border-bottom: 1px solid var(--theme-border-secondary);
856
+ }
857
+ .bpmn-preview__button {
858
+ display: inline-flex;
859
+ align-items: center;
860
+ height: 28px;
861
+ padding: 0 8px;
862
+ font: inherit;
863
+ font-size: var(--type-size-small);
864
+ font-weight: 500;
865
+ color: var(--theme-fg-primary);
866
+ background: transparent;
867
+ border: none;
868
+ border-radius: 6px;
869
+ cursor: pointer;
870
+ transition: background-color var(--motion-fast) var(--motion-ease-out), color var(--motion-fast) var(--motion-ease-out);
871
+ }
872
+ .bpmn-preview__button:hover { background: var(--theme-bg-hover); }
873
+ .bpmn-preview__button:active { background: var(--theme-bg-tertiary); }
874
+ .bpmn-preview__button--active { background: var(--theme-bg-hover); color: var(--theme-accent-primary); }
875
+ .bpmn-preview__button--primary { background: var(--theme-accent-primary); color: var(--theme-fg-on-accent); }
876
+ .bpmn-preview__button--primary:hover { background: var(--theme-accent-hover); }
877
+ .bpmn-preview__button--primary:active { background: var(--theme-accent-pressed); }
878
+ .bpmn-preview__button:focus-visible { outline: 2px solid var(--theme-accent-primary); outline-offset: 1px; }
879
+ .bpmn-preview__spacer { flex: 1 1 auto; }
880
+ .bpmn-preview__summary { display: flex; align-items: center; gap: 12px; font-size: var(--type-size-small); color: var(--theme-fg-secondary); }
881
+ .bpmn-preview__stat { display: inline-flex; align-items: center; gap: 5px; }
882
+
883
+ .bpmn-preview__body { flex: 1 1 auto; display: flex; min-height: 0; }
884
+ .bpmn-preview__panes { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
885
+ .bpmn-preview__panes--columns { flex-direction: row; }
886
+ .bpmn-preview__pane { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
887
+ .bpmn-preview__panes--rows > .bpmn-preview__pane + .bpmn-preview__pane { border-top: 1px solid var(--theme-border-secondary); }
888
+ .bpmn-preview__panes--columns > .bpmn-preview__pane + .bpmn-preview__pane { border-left: 1px solid var(--theme-border-secondary); }
889
+
890
+ .bpmn-preview__title {
891
+ flex: 0 0 auto;
892
+ display: flex;
893
+ align-items: center;
894
+ height: 28px;
895
+ padding: 0 12px;
896
+ font-size: var(--type-size-small);
897
+ font-weight: 600;
898
+ color: var(--theme-fg-secondary);
899
+ background: var(--theme-bg-secondary);
900
+ border-bottom: 1px solid var(--theme-border-secondary);
901
+ }
902
+ .bpmn-preview__canvas { flex: 1 1 auto; min-height: 0; position: relative; }
903
+ .bpmn-preview__canvas > .bpmn-canvas-container { width: 100%; height: 100%; }
904
+ .bpmn-preview__empty {
905
+ display: flex;
906
+ align-items: center;
907
+ justify-content: center;
908
+ height: 100%;
909
+ font-size: var(--type-size-small);
910
+ color: var(--theme-fg-tertiary);
911
+ }
912
+
913
+ .bpmn-preview__changes {
914
+ flex: 0 0 264px;
915
+ display: flex;
916
+ flex-direction: column;
917
+ min-height: 0;
918
+ background: var(--theme-bg-secondary);
919
+ border-left: 1px solid var(--theme-border-secondary);
920
+ }
921
+ .bpmn-preview__changes-list { flex: 1 1 auto; overflow-y: auto; padding: 4px 0; }
922
+ .bpmn-preview__change {
923
+ display: flex;
924
+ align-items: center;
925
+ gap: 8px;
926
+ width: 100%;
927
+ height: 26px;
928
+ padding: 0 12px;
929
+ font: inherit;
930
+ font-size: var(--type-size-small);
931
+ color: var(--theme-fg-primary);
932
+ background: transparent;
933
+ border: none;
934
+ text-align: left;
935
+ cursor: pointer;
936
+ }
937
+ .bpmn-preview__change:hover { background: var(--theme-bg-hover); }
938
+ .bpmn-preview__change--selected { background: var(--theme-bg-selected); }
939
+ .bpmn-preview__dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
940
+ .bpmn-preview__change-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
941
+ .bpmn-preview__change-type { flex: 0 0 auto; font-size: var(--type-size-tiny); color: var(--theme-fg-tertiary); }
942
+
943
+ .bpmn-preview__dot--added { background: var(--theme-success); }
944
+ .bpmn-preview__dot--removed { background: var(--theme-error); }
945
+ .bpmn-preview__dot--changed { background: var(--theme-syntax-yellow); }
946
+ .bpmn-preview__dot--moved { background: var(--theme-accent-primary); }
947
+ .bpmn-preview__dot--resized { background: var(--theme-syntax-purple); }
948
+
949
+ .bpmn-preview .djs-palette,
950
+ .bpmn-preview .djs-context-pad,
951
+ .bpmn-preview .bjsl-button,
952
+ .bpmn-preview .bjsl-overlay,
953
+ .bpmn-preview .bts-toggle-mode { display: none !important; }
954
+
955
+ .diff-added .djs-visual > :first-child { stroke: var(--theme-success) !important; stroke-width: 3px !important; }
956
+ .diff-removed .djs-visual > :first-child { stroke: var(--theme-error) !important; stroke-width: 3px !important; }
957
+ .diff-changed .djs-visual > :first-child { stroke: var(--theme-syntax-yellow) !important; stroke-width: 3px !important; }
958
+ .diff-moved .djs-visual > :first-child { stroke: var(--theme-accent-primary) !important; stroke-width: 3px !important; }
959
+ .diff-resized .djs-visual > :first-child { stroke: var(--theme-syntax-purple) !important; stroke-width: 3px !important; }
960
+ `;function collectBounds(e){let t=new Map;return(e?.diagrams||[]).forEach(e=>{(e?.plane?.planeElement||[]).forEach(e=>{let n=e?.bpmnElement?.id;if(n&&e.bounds){let{x:r,y:i,width:a,height:o}=e.bounds;t.set(n,{x:r,y:i,width:a,height:o})}})}),t}async function computeChanges(e,t){let[{BpmnModdle:n},{diff:r}]=await Promise.all([K(()=>import(`./dist-B7TL-7R3.js`).then(e=>e.n),__vite__mapDeps([20,1,21,11]),import.meta.url),K(()=>import(`./index.esm-Ba6q0zSu.js`),__vite__mapDeps([88,1,21]),import.meta.url)]),i=new n,[{rootElement:a},{rootElement:o}]=await Promise.all([i.fromXML(e),i.fromXML(t)]);return{changes:r(a,o),beforeBounds:collectBounds(a),afterBounds:collectBounds(o)}}function markChanges(e,t,n){if(!n)return;let r=e.get(`canvas`),mark=(e,t)=>Object.keys(e||{}).forEach(e=>{try{r.addMarker(e,t)}catch{}});mark(t===`before`?n._removed:n._added,t===`before`?`diff-removed`:`diff-added`),mark(n._changed,`diff-changed`),t===`after`&&mark(n._layoutChanged,`diff-moved`)}function PreviewPane({title:e,xml:t,side:n,changes:r,onModeler:i}){let a=o(null),s=o(null),fit=()=>(a.current?.getModeler()?.get(`canvas`))?.zoom(`fit-viewport`,`auto`);return f(()=>{if(!s.current||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>fit());return e.observe(s.current),()=>e.disconnect()},[]),l(`div`,{class:`bpmn-preview__pane`,children:[l(`div`,{class:`bpmn-preview__title`,children:e}),l(`div`,{class:`bpmn-preview__canvas`,ref:s,children:t?l(be,{ref:a,xml:t,modelerFactory:e=>ye({container:e}),contextMenuEnabled:!1,onReady:()=>{let e=a.current?.getModeler();e&&(markChanges(e,n,r),i?.(e)),requestAnimationFrame(fit)}}):l(`div`,{class:`bpmn-preview__empty`,children:m(n===`before`?`app.preview.fileAdded`:`app.preview.fileDeleted`)})})]})}function ensurePreviewStyle(){if(document.head.querySelector(`style[data-penstock-preview]`))return;let e=document.createElement(`style`);e.setAttribute(`data-penstock-preview`,`true`),e.textContent=on,document.head.appendChild(e)}function PlacePicker({title:e,places:n,relative:r,done:i}){let[a,o]=t(0);return l(E,{title:e,size:`medium`,onClose:()=>i(null),onSubmit:()=>i(a),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>i(null)},{id:`open`,label:m(`app.webHost.places.open`),role:`primary`,onClick:()=>i(a)}]}),children:[l(`p`,{class:`type-help web-host__intro`,children:m(`app.webHost.places.hint`)}),l(`ul`,{class:`web-host__list`,role:`listbox`,"aria-label":e,children:n.map((e,t)=>l(`li`,{children:l(`button`,{type:`button`,role:`option`,"aria-selected":t===a,class:`web-host__row${t===a?` is-selected`:``}`,onClick:()=>o(t),onDblClick:()=>i(t),children:[l(`span`,{class:`web-host__row-main type-body`,children:e.label}),l(`span`,{class:`web-host__row-side type-help`,children:[r(e.path),`:`,e.line]})]})},`${e.path}:${e.line}`))})]})}function choosePlace(e,t,n){return showInPage(r=>l(PlacePicker,{title:e,places:t,relative:n,done:r}),null)}function RenameDialog$1({review:e,apply:n,done:r}){let[i,a]=t(!1),[o,s]=t(null),run=async()=>{a(!0),s(null);let e=await n();e===null?r(!0):(s(e),a(!1))};return l(E,{title:m(`app.webHost.rename.title`),size:`medium`,onClose:()=>!i&&r(!1),onSubmit:()=>void run(),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>r(!1),disabled:i},{id:`rename`,label:m(`app.webHost.rename.apply`),role:`primary`,onClick:()=>void run(),busy:i}],help:e.summary}),children:[l(`p`,{class:`type-body web-host__intro`,children:m(`app.webHost.rename.intro`,{from:e.from,to:e.to})}),l(`ul`,{class:`web-host__list`,children:e.sites.map(t=>l(`li`,{class:`web-host__site`,children:[l(`span`,{class:`web-host__tag type-help`,children:m(`app.webHost.rename.where.${t.where}`)}),l(`span`,{class:`web-host__row-main type-body`,children:t.label}),l(`span`,{class:`web-host__row-side type-help`,children:[e.relative(t.path),`:`,t.line]})]},`${t.path}:${t.line}:${t.label}`))}),o&&l(S,{children:o})]})}e(RenameDialog$1,`RenameDialog`);function reviewRename(e,t){return showInPage(n=>l(RenameDialog$1,{review:e,apply:t,done:n}),!1)}function insideOf(e,t){let n=e.replace(/[\\/]+$/,``),r=t.trim().replace(/[\\/]+$/,``);return!r||/(^|[\\/])\.\.([\\/]|$)/.test(r)?!1:r===n||r.startsWith(`${n}/`)||r.startsWith(`${n}\\`)}function MigrationDialog({preview:e,root:n,exists:r,done:i}){let[a,s]=t(e.folder),[u,d]=t(!1),[p,h]=t([]),[g,_]=t(null),v=O(),y=insideOf(n,a)?null:m(`app.webHost.migration.folderOutside`),b=o(0);f(()=>{if(y){h([]);return}let t=b.current+=1,n=setTimeout(()=>{r(a,e.files).then(e=>t===b.current&&h(e),()=>t===b.current&&h([]))},200);return()=>clearTimeout(n)},[a,y]),f(()=>{if(e.kind!==`BPMN`)return;ensurePreviewStyle();let t=!0;return computeChanges(e.beforeText,e.afterText).then(e=>t&&_(e.changes),e=>console.error(`The conversion could not be compared:`,e)),()=>{t=!1}},[e]);let S=y!==null||p.length>0&&!u,convert=()=>{v.submit(),S||i({choice:`CONVERT`,folder:a.trim(),replace:u})},cancel=()=>i({choice:`CANCEL`,folder:``,replace:!1}),C=c(()=>e.open.filter(e=>e.manual).length,[e]);return l(E,{title:m(`app.webHost.migration.title`,{name:e.name,target:e.target}),size:`large`,onClose:cancel,onSubmit:convert,footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:cancel},{id:`convert`,label:m(`app.webHost.migration.convert`),role:`primary`,onClick:convert}],help:m(`app.webHost.migration.summary`,{changes:e.changes.length,open:e.open.length,manual:C})}),children:[e.kind===`BPMN`&&l(`div`,{class:`web-host__diff`,children:l(`div`,{class:`bpmn-preview`,children:l(`div`,{class:`bpmn-preview__body`,children:l(`div`,{class:`bpmn-preview__panes bpmn-preview__panes--columns`,children:[l(PreviewPane,{title:m(`app.preview.before`),xml:e.beforeText,side:`before`,changes:g}),l(PreviewPane,{title:m(`app.preview.after`),xml:e.afterText,side:`after`,changes:g})]})})})}),l(x,{label:m(`app.webHost.migration.folder`),hint:m(`app.webHost.migration.folderHint`),error:v.errorOf(`folder`,y),children:e=>l(`input`,{...e,value:a,spellcheck:!1,autocomplete:`off`,onInput:e=>s(e.target.value),onBlur:()=>v.touch(`folder`)})}),p.length>0&&l(x,{label:m(`app.webHost.migration.replace`),hint:m(`app.webHost.migration.replaceHint`,{count:p.length,files:p.join(`, `)}),group:`group`,children:e=>l(`label`,{class:`web-host__check type-body`,id:e.id,children:[l(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked)}),l(`span`,{children:m(`app.webHost.migration.replaceBox`)})]})}),l(`h3`,{class:`type-section-heading web-host__heading`,children:m(`app.webHost.migration.changes`)}),l(`ul`,{class:`web-host__list web-host__list--plain`,children:[e.changes.map((e,t)=>l(`li`,{class:`web-host__change type-body`,children:[l(`span`,{class:`web-host__row-main`,children:e.plain??`${e.where}: ${e.before} → ${e.after}`}),l(`span`,{class:`web-host__row-side type-help`,children:e.where})]},t)),e.changes.length===0&&l(`li`,{class:`type-help`,children:m(`app.webHost.migration.noChanges`)})]}),l(`h3`,{class:`type-section-heading web-host__heading`,children:m(`app.webHost.migration.open`)}),l(`ul`,{class:`web-host__list web-host__list--plain`,children:[e.open.map((e,t)=>l(`li`,{class:`web-host__change type-body`,children:[l(`span`,{class:`web-host__row-main`,children:[e.title,l(`span`,{class:`type-help web-host__action`,children:[` `,e.action]})]}),l(`span`,{class:`web-host__row-side type-help`,children:e.manual?m(`app.webHost.migration.byHand`):e.where})]},t)),e.open.length===0&&l(`li`,{class:`type-help`,children:m(`app.webHost.migration.nothingOpen`)})]})]})}function reviewMigration(e,t,n){return showInPage(r=>l(MigrationDialog,{preview:e,root:t,exists:n,done:r}),{choice:`CANCEL`,folder:``,replace:!1})}function tierName(e){return m(e===`TEAM`?`app.webHost.licence.tier.team`:e===`PRO`?`app.webHost.licence.tier.pro`:`app.webHost.licence.tier.free`)}function describeFailure(e){return e instanceof Error?e.message:String(e)}function LicenceDialog({actions:e,needed:n,done:r}){let[i,a]=t(null),[o,s]=t(``),[c,u]=t(``),[d,p]=t(!1),[h,g]=t(null),[_,v]=t(null);f(()=>{let t=!0;return e.status().then(e=>t&&a(e),e=>t&&g(describeFailure(e))),()=>{t=!1}},[]);let guarded=async e=>{p(!0),g(null),v(null);try{await e()}catch(e){g(describeFailure(e))}finally{p(!1)}},activate=()=>guarded(async()=>{if(!o.trim()){g(m(`app.webHost.licence.keyEmpty`));return}let t=await e.activate(o.trim());a(t),s(``),v(m(`app.webHost.licence.activated`,{tier:tierName(t.tier)}))}),buy=t=>guarded(async()=>{e.open(await e.checkout(t,c.trim())),v(m(`app.webHost.licence.checkoutOpened`))}),release=()=>guarded(async()=>{a(await e.release()),v(m(`app.webHost.licence.released`))}),y=i!==null&&i.tier!==`FREE`,b=i&&!i.detail&&i.trialDaysLeft!=null&&i.trialDaysLeft>0?m(`app.webHost.licence.trial`,{days:i.trialDaysLeft}):null;return l(E,{title:m(`app.webHost.licence.title`),size:`medium`,onClose:r,onSubmit:()=>void activate(),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r},{id:`activate`,label:m(`app.webHost.licence.activate`),role:`primary`,onClick:()=>void activate(),busy:d,disabled:o.trim()===``}]}),children:[l(`p`,{class:`type-body web-host__intro`,"data-testid":`licence-state`,children:[i?m(`app.webHost.licence.plan`,{tier:tierName(i.tier),detail:i.detail}):m(`app.webHost.licence.loading`),b&&l(`span`,{class:`type-help`,children:[` `,b]})]}),n&&!y&&l(`p`,{class:`type-help web-host__intro`,children:m(`app.webHost.licence.needed`)}),l(x,{label:m(`app.webHost.licence.key`),hint:m(`app.webHost.licence.keyHint`),error:h,children:e=>l(`input`,{...e,type:`password`,value:o,spellcheck:!1,autocomplete:`off`,onInput:e=>s(e.target.value)})}),l(x,{label:m(`app.webHost.licence.email`),optional:!0,hint:m(`app.webHost.licence.emailHint`),children:e=>l(`input`,{...e,type:`email`,value:c,spellcheck:!1,autocomplete:`email`,onInput:e=>u(e.target.value)})}),l(`div`,{class:`web-host__buttons`,children:[l(`button`,{type:`button`,class:`ui-button`,disabled:d,onClick:()=>void buy(fe.PRO),children:m(`app.webHost.licence.buyPro`)}),l(`button`,{type:`button`,class:`ui-button`,disabled:d,onClick:()=>void buy(fe.TEAM),children:m(`app.webHost.licence.buyTeam`)}),y&&i.detail!==``&&l(`button`,{type:`button`,class:`ui-button`,disabled:d,onClick:()=>void release(),children:m(`app.webHost.licence.release`)})]}),_&&l(`p`,{class:`type-help web-host__note`,role:`status`,children:_})]})}function showLicence(e,t){return showInPage(n=>l(LicenceDialog,{actions:e,needed:t,done:()=>n()}),void 0)}function ClipboardDialog({mode:e,text:n,done:r}){let[i,a]=t(n),s=o(null);f(()=>{s.current?.focus(),e===`copy`&&s.current?.select()},[]);let accept=()=>{if(e===`copy`){s.current?.select();let e=!1;try{e=document.execCommand(`copy`)}catch{e=!1}r(e?n:null)}else r(i)};return l(E,{title:m(e===`copy`?`app.webHost.clipboard.copyTitle`:`app.webHost.clipboard.pasteTitle`),size:`medium`,onClose:()=>r(null),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>r(null)},{id:`accept`,label:m(e===`copy`?`app.webHost.clipboard.copy`:`app.common.paste`),role:`primary`,onClick:accept,disabled:e===`paste`&&i===``}]}),children:[l(`p`,{class:`type-help web-host__intro`,children:m(e===`copy`?`app.webHost.clipboard.copyText`:`app.webHost.clipboard.pasteText`)}),l(`textarea`,{ref:s,class:`ui-input web-host__area`,value:i,readOnly:e===`copy`,spellcheck:!1,"aria-label":m(e===`copy`?`app.webHost.clipboard.copyTitle`:`app.webHost.clipboard.pasteTitle`),onInput:e=>a(e.target.value)})]})}function copyByHand(e){return showInPage(t=>l(ClipboardDialog,{mode:`copy`,text:e,done:t}),null).then(e=>e!==null)}function pasteByHand(){return showInPage(e=>l(ClipboardDialog,{mode:`paste`,text:``,done:e}),null)}var sn=new Set;function onLicenceChange(e){return sn.add(e),()=>{sn.delete(e)}}function announceLicenceChange(){for(let e of sn)e()}var cn=`download://`,ln=`upload://`,un=1500;function environment(){return{confirm:e=>{let t=Ee();return t?t.confirm(e):confirmInPage(e)},open:e=>{window.open(e,`_blank`,`noopener,noreferrer`)},copyByHand:e=>copyByHand(e),mac:typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)}}function bytesOf(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function blobTypeOf(e){let t=e.split(`.`).pop()?.toLowerCase();return t===`svg`?`image/svg+xml`:t===`png`?`image/png`:t===`pdf`?`application/pdf`:t===`json`||t===`form`?`application/json`:t===`bpmn`||t===`dmn`||t===`xml`?`application/xml`:`text/plain`}var dn=/\.(bpmn(\.xml)?|dmn|form|cmmn|cmmn11\.xml)$/i;function pageId(){return`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`}function naming(e,t,n,r){return(async(i,a)=>{let o=new Headers(a?.headers);o.set(`X-Penstock-Client`,t);let s=n.read();s&&o.set(`X-Penstock-Resource`,encodeURIComponent(s));let c=r.read();c&&o.set(`X-Penstock-Project`,c);let l=await(e??fetch)(i,{...a,headers:o});return r.seen(l.headers.get(`X-Penstock-Project`)),l})}var WebPlatformBridge=class extends F{env;uploads=new Map;uploadCount=0;sink=null;copied=null;active;project;web;workspace=null;suggested=new Set;constructor(e=``,t=environment(),n){let r={read:(()=>null)},i={read:()=>null,seen:()=>void 0};super(e,naming(n,pageId(),r,i)),this.env=t,this.active=r,this.project=i,this.web=new me(this.config)}bindActiveFile(e){this.active.read=()=>{let t=e();return t?ce(t):null}}bindWorkspace(e){this.workspace=e}projectRoot(){return this.workspace?.root()??``}supports(e){return e===`compare`||e===`codeBridge`||e===`externalScripts`||e===`editorTheme`}registerRevealer(e,t){return this.workspace?.registerRevealer(e,t)??(()=>{})}bindProject(e,t){this.project.read=e,this.project.seen=t}async listProject(){let e=await this.projectApi.getProjectFiles();return{root:e?.root??``,files:e?.files??[],folders:e?.folders,reports:e?.reports??[],sources:e?.sources,testCases:e?.testCases,templates:e?.templates,connections:e?.connections}}bindActiveDocument(e){this.sink=e}async saveBpmnXml(e){if(!this.sink)throw Error(m(`app.web.noDocumentOpen`));this.sink(e)}async confirmWithUser(e){return this.env.confirm(e)}async notifyUser(e,t){t?L.error(e):L.info(e)}async openExternalLink(e){let t=safeExternalUrl(e);t?this.env.open(t):console.warn(`Refusing to open a link that is not http, https or mailto:`,e)}async getDialogButtonOrder(){return this.env.mac?`primary-right`:`primary-left`}async getTheme(){return null}async publishToolWindow(){}async publishCodeLenses(){}async publishActions(){}async reportSnapshot(){}async reportFindings(){}async getClipboard(){if(await this.mayReadClipboard())try{let e=await navigator.clipboard.readText();if(typeof e==`string`&&e!==``)return e}catch{}return this.copied}async readClipboardNow(){let e=await navigator.clipboard.readText();return e===``?null:e}async mayReadClipboard(){try{return(await navigator.permissions?.query({name:`clipboard-read`}))?.state===`granted`}catch{return!1}}async saveClipboard(e){if(!e)return;this.copied=e,window.dispatchEvent(new Event(ge));let t=!1;try{await navigator.clipboard.writeText(e),t=!0}catch{}!t&&!e.startsWith(`bpmn-js-clip----`)&&await this.env.copyByHand(e)}async pasteFromUser(){return await this.getClipboard()??pasteByHand()}async saveClipboardImage(e){if(!e)return!1;let t=typeof navigator<`u`?navigator.clipboard:void 0;if(!t||typeof ClipboardItem>`u`)return!1;try{return await t.write([new ClipboardItem({"image/png":new Blob([bytesOf(e)],{type:`image/png`})})]),!0}catch(e){return console.error(`Failed to put the image on the clipboard:`,e),!1}}async revealElement(e,t){let n=this.workspace;n&&(t?await n.revealElement(e,t):await n.openDiagram(e))}async openAsText(e,t){let n=this.workspace;n&&(dn.test(e)?await n.openText(e):await n.openSource(e,t??null))}async openCode(e,t){let n=decodeHandles(e);n.length===0?await this.notifyUser(m(`app.webHost.places.none`,{name:t}),!0):await this.showPlaces(t,n.map(e=>({...e,label:e.path.split(/[\\/]/).pop()??e.path})))}async openPlaces(e,t){await this.showPlaces(e,t)}async navigateToClass(e,t=`JAVA_CLASS`){if(!e)return!1;try{let n=await this.web.locateCode({locateRequest:{kind:t,value:e}});return n.places.length===0?(await this.notifyUser(m(`app.webHost.places.none`,{name:e}),!0),!1):(await this.showPlaces(e,n.places),!0)}catch(e){return console.error(`Failed to find the code:`,e),await this.notifyUser(await q(e),!0),!1}}async findCodeStatus(e,t){let n=await this.web.findCodeStatus({codeBridgeRequest:{diagram:e,elements:t}});return{licensed:n.licensed,statuses:n.statuses}}async readCodeSnippet(e,t,n){let r=await this.web.readCodeSnippet({codeSnippetRequest:{path:e,line:t,count:n}});return{path:r.path,line:r.line,lines:r.lines}}async runTestHandles(){await this.notifyUser(m(`app.webHost.testsNeedTheIde`),!0)}async openScriptFile(e,t,n,r,i=[],a){let o=this.workspace;if(!o)return;let s=a??o.activePath();s?await o.openScript({diagramPath:s,slot:n,language:e,text:t,title:r,variables:i}):await this.notifyUser(m(`app.web.script.noDiagram`),!0)}async reportScriptSlot(){}async offerLinkedRename(e){let t;try{t=await this.web.planLinkedRename({linkedRenameOffer:e})}catch(e){return console.warn(`The rename could not be planned:`,e),{places:0,offered:!1}}if(!t.offered||t.sites.length===0)return{places:0,offered:!1,detail:t.detail};let n=t.summary??``,r=L.info(m(`app.webHost.rename.offer`,{count:t.sites.length,from:e.from,summary:n}),{label:m(`app.webHost.rename.review`),run:()=>{L.hide(r),this.reviewLinkedRename(e,t)}});return{places:t.sites.length,offered:!0,summary:n}}async reviewLinkedRename(e,t){let n={places:0,files:0};await reviewRename({from:e.from,to:e.to,summary:t.summary??``,sites:t.sites,relative:e=>this.shortPath(e)},async()=>{try{let r=await this.web.applyLinkedRename({linkedRenameApply:{...e,files:t.files}});return n.places=r.places,n.files=r.files,null}catch(e){return m(`app.webHost.rename.failed`,{reason:await q(e)})}})&&(await this.workspace?.refresh(),L.info(m(`app.webHost.rename.done`,{from:e.from,to:e.to,places:n.places,files:n.files})))}async previewMigration(e){return await reviewMigration(e,this.workspace?.root()??``,async(e,t)=>{let n=e.replace(/[\\/]+$/,``);return(await Promise.all(t.map(async e=>await this.readFileIfPresent(`${n}/${e}`)===null?null:e))).filter(e=>e!==null)})}async requestFeature(e){return await super.requestFeature(e)?!0:(this.suggested.has(e)||(this.suggested.add(e),L.info(m(`app.webHost.licence.needed`),{label:m(`app.webHost.licence.activate`),run:()=>void this.showLicence()})),!1)}async showLicenceOffer(e,t){if(e===`FREE_NOTICE`||e===`TRIAL_ENDING`)return await this.showLicence(),!0;try{let e=await this.guard(async()=>this.web.startLicenceCheckout({licenceCheckout:{tier:`PRO`}}));return await this.openExternalLink(e.url),L.info(m(`app.webHost.licence.checkoutOpened`)),!0}catch(e){return L.error(e instanceof Error?e.message:String(e)),!1}}async showLicence(){let view=e=>this.viewOf(e);await showLicence({status:async()=>{let e=await this.getLicense();return{tier:e?.tier??`FREE`,detail:e?.detail??``,trialDaysLeft:e?.trialDaysLeft}},activate:async e=>this.guard(async()=>{let t=await view(await this.web.activateLicence({licenceKey:{key:e}}));return announceLicenceChange(),t}),checkout:async(e,t)=>this.guard(async()=>(await this.web.startLicenceCheckout({licenceCheckout:{tier:e,email:t||void 0}})).url),release:async()=>this.guard(async()=>{let e=await view(await this.web.deactivateLicence());return announceLicenceChange(),e}),open:e=>void this.openExternalLink(e)},!1)}async openComparison(e){await this.workspace?.openDiff(e)}async buildEvidence(e){let t=await this.web.buildEvidence({evidenceRequest:{since:e.since,force:e.force,format:e.format===`dir`?pe.DIR:pe.ZIP}});return{ok:t.ok,pack:t.pack??null,files:t.files,sealed:t.sealed??null,lines:t.lines}}async planRefactor(e){return await this.web.planRefactor({refactorRequest:e})}async applyRefactor(e){try{let t=await this.web.applyRefactor({refactorRequest:e});return await this.workspace?.refresh(),{files:t.files,edits:t.edits,created:t.created??null}}catch(e){throw Error(await q(e))}}async compareWithHead(e){let t=await this.web.compareWithHead({compareRequest:{path:e}});return{tracked:t.tracked,before:t.before??null}}async saveProjectFile(e,t,n){try{return(await this.web.saveProjectFile({saveProjectFileRequest:{path:e,content:t,stamp:n}})).stamp}catch(e){throw e?.response?.status===409?e:Error(await q(e))}}async guard(e){try{return await e()}catch(e){throw Error(await q(e))}}async viewOf(e){return{tier:(await I(e))?.tier??`FREE`,detail:e.detail,trialDaysLeft:e.trialDaysLeft}}shortPath(e){let t=this.workspace?.root().replace(/[\\/]+$/,``)??``;return t&&e.startsWith(`${t}/`)?e.slice(t.length+1):e}async showPlaces(e,t){let n=this.workspace;if(!n)return;let r=t[0];if(t.length>1){let n=await choosePlace(e,t.map(e=>({path:e.path,line:e.line,label:`label`in e?e.label:this.shortPath(e.path)})),e=>this.shortPath(e));if(n===null)return;r=t[n]}await n.openSource(r.path,r.line)}async chooseFile(e,t){if(t?.mode!==`open`){let n=t?.defaultFileName??P(this.getBpmnFilePath(),e,m(`app.export.untitledFile`)),r=this.workspace?.root().replace(/[\\/]+$/,``);if(e===`bpmn`&&r)return this.freeNameIn(r,n);let i=t?.defaultDirectory?.replace(/[\\/]+$/,``);return r&&i&&(i===r||i.startsWith(`${r}/`))?`${i}/${n}`:`${cn}${n}`}return t.selectFolders?null:this.pickUpload(e)}async freeNameIn(e,t){let n=t.indexOf(`.`),r=n<0?t:t.slice(0,n),i=n<0?``:t.slice(n);for(let t=1;t<1e3;t+=1){let n=`${e}/${t===1?r:`${r}-${t}`}${i}`;if(await this.readFileIfPresent(n)===null)return n}return`${cn}${t}`}pickUpload(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,e&&(n.accept=e.split(`,`).map(e=>`.${e.trim().replace(/^\./,``)}`).join(`,`));let r=!1,finish=e=>{r||(r=!0,window.removeEventListener(`focus`,onFocus),t(e))},onFocus=()=>setTimeout(()=>finish(n.files&&n.files.length>0?this.keep(n.files[0]):null),un);n.addEventListener(`change`,()=>finish(n.files&&n.files.length>0?this.keep(n.files[0]):null)),n.addEventListener(`cancel`,()=>finish(null)),window.addEventListener(`focus`,onFocus),n.click()})}keep(e){this.uploadCount+=1;let t=`${ln}${this.uploadCount}/${e.name}`;return this.uploads.set(t,e),t}async readFile(e){let t=this.uploads.get(e);return t?t.text():super.readFile(e)}async readFileIfPresent(e){let t=this.uploads.get(e);return t?t.text():super.readFileIfPresent(e)}async readFileBytes(e){let t=this.uploads.get(e);return t?new Uint8Array(await t.arrayBuffer()):super.readFileBytes(e)}async saveFile(e,t,n){if(!e.startsWith(cn))return super.saveFile(e,t,n);let r=e.slice(11),i=n?.isBase64?bytesOf(t):t;download(r,new Blob([i],{type:blobTypeOf(r)}))}async exportSvg(e){download(P(this.getBpmnFilePath(),`svg`,m(`app.export.untitledFile`)),new Blob([e],{type:`image/svg+xml`}))}async exportPng(e){download(P(this.getBpmnFilePath(),`png`,m(`app.export.untitledFile`)),e)}async exportPdf(e){download(P(this.getBpmnFilePath(),`pdf`,m(`app.export.untitledFile`)),e)}};function hexOf(e){let t=e.trim(),n=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t);if(n)return`#${n[1].toLowerCase()}`;let r=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(t);if(r)return`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`.toLowerCase();let i=/^rgba?\(\s*(\d{1,3})[\s,]+(\d{1,3})[\s,]+(\d{1,3})/i.exec(t);return i?`#${[i[1],i[2],i[3]].map(e=>Math.min(255,Number(e))).map(e=>e.toString(16).padStart(2,`0`)).join(``)}`:null}function resolvedColour(e,t=document){let n=t.createElement(`span`);n.style.color=`var(${e})`,n.style.display=`none`,t.body.appendChild(n);let r=getComputedStyle(n).color;return n.remove(),hexOf(r)}var fn={background:`#ffffff`,foreground:`#27282e`};function classesFor(e){return[`desktop`,e===`darwin`?`desktop-mac`:e===`win32`?`desktop-win`:`desktop-linux`]}function publishColours(e){let t=resolvedColour(`--theme-bg-primary`)??fn.background,n=resolvedColour(`--theme-fg-primary`)??fn.foreground,r=currentThemeChoice();e.setTheme(r===`ide`?`system`:r===`light`?`light`:`dark`),e.setTitleBarColours({background:t,foreground:n})}function installDesktop(e){let t=Ee();if(!t)return null;let n=document.documentElement;n.classList.add(...classesFor(t.platform)),n.classList.toggle(`desktop-fullscreen`,t.isFullScreen()),t.onFullScreen(e=>n.classList.toggle(`desktop-fullscreen`,e));let r=0,publish=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>publishColours(t))};window.addEventListener(`bpmn-theme-changed`,publish),publish();let i,a,sync=()=>{let n=e.snapshot();n.active!==i&&(i=n.active,t.setActiveFile(i));let r=e.dirtyPaths().length>0;r!==a&&(a=r,t.setDirty(r))};return e.subscribe(sync),sync(),t}var pn={undo:Y,redo:Oe};function isHistoryAction(e){return e===`undo`||e===`redo`}function runCodeEditorHistory(e,t){if(!t||!isHistoryAction(e))return!1;let n=t.closest(`.cm-editor`),r=n?ke.findFromDOM(n):null;return r?(pn[e](r),!0):!1}var mn=new Set([`cut`,`copy`]),hn=null;function registerEditCommands(e,t){return hn={owner:e,read:t},()=>{hn?.owner===e&&(hn=null)}}function runEditCommand(e,t){if(De(t.focus))return runCodeEditorHistory(e,t.focus);if(t.textSelected&&mn.has(e))return!1;let n=hn?.read()[e];if(!n)return!1;try{n()}catch(t){console.error(`Penstock could not ${e}:`,t)}return!0}var gn={open:new Set,shut:new Set},_n=2e3;function hasChildren(e){return(e.children?.length??0)>0}function defaultOpen(e){let t=e.children?.length??0;return t===0?!1:e.expand===`ALWAYS`||e.expand===`SINGLE_CHILD`&&t===1}function isOpen(e,t){return!hasChildren(e)||t.shut.has(e.id)?!1:t.open.has(e.id)?!0:defaultOpen(e)}function setOpen(e,t,n){let r=new Set(e.shut),i=new Set(e.open);return r.delete(t.id),i.delete(t.id),n!==defaultOpen(t)&&(n?i:r).add(t.id),{open:i,shut:r}}function expansionOf(e,t){return{open:new Set(e.slice(0,_n)),shut:new Set(t.slice(0,_n))}}function idsOf(e){let t=new Set,n=[...e];for(;n.length>0;){let e=n.pop();t.add(e.id),e.children&&n.push(...e.children)}return t}function pruneExpansion(e,t){if(e.open.size===0&&e.shut.size===0)return e;let n=idsOf(t),keep=e=>[...e].filter(e=>n.has(e)).slice(0,_n),r=keep(e.open),i=keep(e.shut);return r.length===e.open.size&&i.length===e.shut.size?e:{open:new Set(r),shut:new Set(i)}}function sameExpansion(e,t){let same=(e,t)=>e.size===t.size&&[...e].every(e=>t.has(e));return same(e.open,t.open)&&same(e.shut,t.shut)}function matches(e,t){return e.label.toLowerCase().includes(t)||(e.detail?.toLowerCase().includes(t)??!1)}function flattenTool(e,t,n=``){let r=n.trim().toLowerCase(),i=[],visit=(e,n,a)=>{let o=i.length,s=hasChildren(e),c={node:e,depth:n,parent:a,position:1,siblings:1,expanded:s?r===``&&isOpen(e,t):null};i.push(c);let l=[];if(s&&(r!==``||c.expanded)){for(let t of e.children){let r=i.length;visit(t,n+1,e.id)&&l.push(i[r])}l.forEach((e,t)=>{e.position=t+1,e.siblings=l.length})}return r===``?!0:l.length>0?(c.expanded=!0,!0):matches(e,r)?!0:(i.length=o,!1)},a=[];for(let t of e){let e=i.length;visit(t,0,null)&&a.push(i[e])}return a.forEach((e,t)=>{e.position=t+1,e.siblings=a.length}),i}function typeAhead(e,t,n){let r=n.toLowerCase();if(r===``||e.length===0)return-1;let i=[...r].every(e=>e===r[0]),a=i?r[0]:r,o=r.length===1||i?1:0;for(let n=o;n<e.length+o;n+=1){let r=(Math.max(t,0)+n)%e.length;if(e[r].node.label.toLowerCase().startsWith(a))return r}return-1}function tooltipOf(e){return e.tooltip??(e.detail?`${e.label} ${e.detail}`:e.label)}function keyedAction(e,t){return e.actions?.find(e=>String(e.keys)===t)?.id??null}function findNode(e,t){let n=[...e];for(;n.length>0;){let e=n.pop();if(e.id===t)return e;e.children&&n.push(...e.children)}return null}function trailTo(e,t){let walk=(e,n)=>{for(let r of e){if(r.id===t)return n;let e=r.children?walk(r.children,[...n,r.id]):null;if(e)return e}return null};return walk(e,[])}function nodeCount(e){let t=0,n=[...e];for(;n.length>0;){let e=n.pop();t+=1,e.children&&n.push(...e.children)}return t}var vn=`doc:`,yn=8,bn=64,docPanel=e=>`${vn}${e}`,pathOfPanel=e=>e.startsWith(vn)?e.slice(4):null,xn=`script:`,scriptPanel=e=>`${xn}${e}`,scriptIdOf=e=>e.startsWith(xn)?e.slice(7):null;function leaves(e){return e.kind===`group`?[e]:e.children.flatMap(leaves)}function findGroup(e,t){return leaves(e.root).find(e=>e.id===t)??null}function groupOf(e,t){return leaves(e.root).find(e=>e.tabs.includes(t))??null}function panels(e){return leaves(e.root).flatMap(e=>e.tabs)}function has(e,t){return groupOf(e,t)!==null}function focused$1(e){return findGroup(e,e.focus)}e(focused$1,`focused`);function next(e,t){let n=e.serial+1;return{dock:{...e,serial:n},id:`${t}${n}`}}function sizesFor(e,t){return e.map((e,n)=>{let r=t[n];return typeof r==`number`&&Number.isFinite(r)&&r>0?r:1})}function tidy(e,t){if(e.kind===`group`){if(e.tabs.length===0&&e.id!==t)return null;let n=e.active&&e.tabs.includes(e.active)?e.active:e.tabs[e.tabs.length-1]??null;return n===e.active?e:{...e,active:n}}let n=[],r=[];return e.children.forEach((i,a)=>{let o=tidy(i,t);o&&(n.push(o),r.push(e.sizes[a]))}),n.length===0?null:n.length===1?n[0]:{...e,children:n,sizes:sizesFor(n,r)}}function normalize(e){let t=leaves(e.root),n=(t.find(e=>e.tabs.length>0)??t.find(t=>t.id===e.focus)??t[0]).id,r=tidy(e.root,n),i=leaves(r),a=i.some(t=>t.id===e.focus)?e.focus:i[0].id;return{...e,root:r,focus:a}}function mapNode(e,t,n){return e.id===t?n(e):e.kind===`group`?e:{...e,children:e.children.map(e=>mapNode(e,t,n))}}function withoutPanel(e,t){let n=groupOf(e,t);if(!n)return e;let r=n.tabs.indexOf(t),i=n.tabs.filter(e=>e!==t),a=n.active===t?i[Math.min(r,i.length-1)]??null:n.active;return{...e,root:mapNode(e.root,n.id,e=>({...e,tabs:i,active:a}))}}function parentOf$1(e,t){if(e.kind===`group`)return null;if(e.children.some(e=>e.id===t))return e;for(let n of e.children){let e=parentOf$1(n,t);if(e)return e}return null}e(parentOf$1,`parentOf`);function edgeDirection(e){return e===`left`||e===`right`?`row`:`col`}function roomToSplit(e,t){return e===void 0||edgeDirection(t)===`col`||(e-8)/2>=480}function insertBeside(e,t,n,r){let i=edgeDirection(r),a=r===`left`||r===`top`,o=parentOf$1(e.root,t),s=mapFind(e.root,t);if(o&&o.dir===i){let r=o.children.findIndex(e=>e.id===t),i=[...o.children],s=[...o.sizes],c=a?r:r+1;i.splice(c,0,n);let l=1;if(s[r]>0){let e=s[r]/2;s[r]=e,l=e}return s.splice(c,0,l),{...e,root:mapNode(e.root,o.id,e=>({...e,children:i,sizes:s}))}}let c=next(e,`s`),l=a?[n,s]:[s,n],u={kind:`split`,id:c.id,dir:i,children:l,sizes:[1,1]};return o?{...c.dock,root:mapNode(c.dock.root,t,()=>u)}:{...c.dock,root:u}}function mapFind(e,t){if(e.id===t)return e;if(e.kind===`group`)return null;for(let n of e.children){let e=mapFind(n,t);if(e)return e}return null}function focusGroup(e,t){return e.focus===t||!findGroup(e,t)?e:{...e,focus:t}}function activate(e,t){let n=groupOf(e,t);return!n||n.active===t&&e.focus===n.id?e:{...e,focus:n.id,root:mapNode(e.root,n.id,e=>({...e,active:t}))}}function canMove(e,t,n){let r=groupOf(e,t),i=findGroup(e,n.group);return!(!r||!i||n.zone!==`center`&&r.id===i.id&&r.tabs.length===1||n.zone!==`center`&&!roomToSplit(n.width,n.zone))}function groupFor(e,t){let n=next(e,`g`);return{dock:n.dock,group:{kind:`group`,id:n.id,tabs:[t],active:t}}}function moveTab(e,t,n){if(!canMove(e,t,n))return e;let r=groupOf(e,t);if(n.zone===`center`&&r.id===n.group)return reorder(e,t,n.index??r.tabs.length);let i=withoutPanel(e,t);if(n.zone===`center`){let e=findGroup(i,n.group),r=[...e.tabs];r.splice(Math.max(0,Math.min(n.index??r.length,r.length)),0,t),i={...i,focus:e.id,root:mapNode(i.root,e.id,e=>({...e,tabs:r,active:t}))}}else{let e=groupFor(i,t);i=insertBeside(e.dock,n.group,e.group,n.zone),i={...i,focus:e.group.id}}return normalize(i)}function reorder(e,t,n){let r=groupOf(e,t);if(!r)return e;let i=r.tabs.filter(e=>e!==t);return i.splice(Math.max(0,Math.min(n,i.length)),0,t),i.every((e,t)=>e===r.tabs[t])?e:{...e,root:mapNode(e.root,r.id,e=>({...e,tabs:i}))}}function mergeGroups(e){let[t,...n]=leaves(e.root);if(!t||n.length===0)return e;let r=[...t.tabs,...n.flatMap(e=>e.tabs)],i=focused$1(e)?.active??t.active,a=mapNode(e.root,t.id,e=>({...e,tabs:r,active:i&&r.includes(i)?i:e.active}));for(let e of n)a=mapNode(a,e.id,e=>({...e,tabs:[],active:null}));return normalize({...e,root:a,focus:t.id})}function setSizes(e,t,n){let r=mapFind(e.root,t);if(!r||r.kind!==`split`||n.length!==r.children.length)return e;let i=n.map((e,t)=>Number.isFinite(e)&&e>0?e:r.sizes[t]);return i.every((e,t)=>e===r.sizes[t])?e:{...e,root:mapNode(e.root,t,e=>({...e,sizes:i}))}}function resizeBy(e,t,n,r,i){let a=mapFind(e.root,t);if(!a||a.kind!==`split`||n<0||n>=a.children.length-1||i.reduce((e,t)=>e+t,0)<=0)return e;let o=i[n]+i[n+1],s=a.dir===`row`?480:160;if(o<s*2)return e;let c=Math.max(s,Math.min(i[n]+r,o-s)),l=a.sizes[n]+a.sizes[n+1],u=[...a.sizes];return u[n]=c/o*l,u[n+1]=(o-c)/o*l,setSizes(e,t,u)}function addToFocused(e,t){let n=focused$1(e)??leaves(e.root)[0];return{...e,focus:n.id,root:mapNode(e.root,n.id,e=>({...e,tabs:[...e.tabs,t],active:t}))}}function syncDocs(e,t,n=new Set,r){let i=new Set(t.map(docPanel)),a=e;for(let t of panels(e))pathOfPanel(t)!==null&&!i.has(t)&&(a=withoutPanel(a,t));a=normalize(a);for(let e of t){let t=docPanel(e);if(has(a,t))continue;let i=focused$1(a)??leaves(a.root)[0];if(n.has(e)&&i.tabs.length>0&&roomToSplit(r,`right`)){let e=groupFor(a,t);a={...insertBeside(e.dock,i.id,e.group,`right`),focus:e.group.id}}else a=addToFocused(a,t)}return normalize(a)}function syncScripts(e,t){let n=new Set(t.map(scriptPanel)),r=e;for(let t of panels(e))scriptIdOf(t)!==null&&!n.has(t)&&(r=withoutPanel(r,t));r=normalize(r);for(let e of t){let t=scriptPanel(e);has(r,t)||(r=addToFocused(r,t))}return normalize(r)}function defaultDock(){return{root:{kind:`group`,id:`g1`,tabs:[],active:null},focus:`g1`,serial:1}}function toSaved(e,t){let n=0,r=0,savedId=e=>{let n=pathOfPanel(e);if(n===null)return null;let r=t(n);return r===null?null:`${vn}${r}`},save=t=>{if(t.kind===`group`){t.id===e.focus&&(n=r),r+=1;let i=t.tabs.map(savedId).filter(e=>e!==null),a=t.active?savedId(t.active):null;return{t:`g`,tabs:i,active:a&&i.includes(a)?a:null}}return{t:`s`,dir:t.dir,children:t.children.map(save),sizes:t.sizes}};return{root:save(e.root),focus:n}}function fromSaved(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=new Set,i=0,a=0,o=typeof n.focus==`number`?n.focus:0,s=null,build=(e,n)=>{if(!e||typeof e!=`object`||n>yn)return null;let c=e;if(c.t===`g`){if(a>=bn)return null;let e=[];if(Array.isArray(c.tabs))for(let n of c.tabs){if(typeof n!=`string`)continue;let i=null;if(n.startsWith(vn)){let e=t(n.slice(4));i=e===null?null:docPanel(e)}i&&!r.has(i)&&(r.add(i),e.push(i))}i+=1;let n=`g${i}`;a===o&&(s=n),a+=1;let l=null;if(typeof c.active==`string`){let n=c.active.startsWith(vn)?t(c.active.slice(4)):null,r=n===null?null:docPanel(n);r&&e.includes(r)&&(l=r)}return{kind:`group`,id:n,tabs:e,active:l}}if(c.t===`s`&&(c.dir===`row`||c.dir===`col`)&&Array.isArray(c.children)&&c.children.length>=2){let e=[],t=[];return c.children.forEach((r,i)=>{let a=build(r,n+1);if(!a)return;e.push(a);let o=Array.isArray(c.sizes)?c.sizes[i]:void 0;t.push(typeof o==`number`?o:0)}),e.length===0?null:(i+=1,{kind:`split`,id:`s${i}`,dir:c.dir,children:e,sizes:sizesFor(e,t)})}return null},c=build(n.root,0);return c?normalize({root:c,focus:s??leaves(c)[0].id,serial:i}):null}var Sn=50;function relOf$1(e,t){return t?e.docs.get(t)?.rel??null:null}e(relOf$1,`relOf`);function sessionOf(e,t){return{tabs:e.order.map(t=>relOf$1(e,t)).filter(e=>e!==null),active:relOf$1(e,e.active),dock:toSaved(t.dock,t=>relOf$1(e,t)),recent:[...e.recent],toolOpen:[...t.tool?.open??[]].slice(0,_n),toolShut:[...t.tool?.shut??[]].slice(0,_n)}}function sessionFrom(e){if(!e||typeof e!=`object`)return null;let t=e,list=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`&&e!==``):[],text=e=>typeof e==`string`&&e!==``?e:null;return{tabs:list(t.tabs),active:text(t.active),dock:t.dock&&typeof t.dock==`object`?t.dock:null,recent:list(t.recent),toolOpen:list(t.toolOpen),toolShut:list(t.toolShut)}}function restoreSession(e,t,n){let r=new Map(t.files.map(e=>[e.rel,e])),i=n.tabs.filter(e=>r.has(e)).slice(0,Sn);for(let t of i){let n=r.get(t);e.open(n.path,n.kind)}let pick=e=>e&&i.includes(e)?r.get(e).path:null,a=pick(n.active)??(i.length>0?r.get(i[i.length-1]).path:null);a&&e.activate(a),e.setRecent(n.recent.filter(e=>r.has(e)));let o=new Set(i);return{dock:n.dock?fromSaved(n.dock,e=>o.has(e)?r.get(e).path:null):null,toolOpen:n.toolOpen,toolShut:n.toolShut,opened:i.length}}var Cn=`application/x-penstock-panel`,wn=null,Tn=new Set;function dragging(){return wn}function beginDrag(e,t){t.dataTransfer?.setData(Cn,e),t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),wn=e,Tn.forEach(e=>e())}function endDrag(){wn!==null&&(wn=null,Tn.forEach(e=>e()))}function useDragging(){let[,e]=t(0);return f(()=>{let listener=()=>e(e=>e+1);return Tn.add(listener),()=>void Tn.delete(listener)},[]),wn}function zoneAt(e,t,n,r){if(e.width<=0||e.height<=0)return`center`;let i=(t-e.left)/e.width,a=(n-e.top)/e.height;if(!r)return`center`;let o=[[`left`,i],[`right`,1-i],[`top`,a],[`bottom`,1-a]].reduce((e,t)=>t[1]<e[1]?t:e);return o[1]<.25?o[0]:`center`}function highlightOf(e){switch(e){case`left`:return{left:`0`,top:`0`,width:`50%`,height:`100%`};case`right`:return{left:`50%`,top:`0`,width:`50%`,height:`100%`};case`top`:return{left:`0`,top:`0`,width:`100%`,height:`50%`};case`bottom`:return{left:`0`,top:`50%`,width:`100%`,height:`50%`};default:return{left:`0`,top:`0`,width:`100%`,height:`100%`}}}var PanelHosts=class{elements=new Map;hostOf(e){let t=this.elements.get(e);return t||(t=document.createElement(`div`),t.className=`dock-host`,t.dataset.panel=e,this.elements.set(e,t)),t}release(e){this.elements.get(e)?.remove(),this.elements.delete(e)}keep(e){let t=new Set(e);for(let e of[...this.elements.keys()])t.has(e)||this.release(e)}attach(e,t,n){t.forEach((t,r)=>{let i=this.hostOf(t);(i.parentElement!==e||e.children[r]!==i)&&e.insertBefore(i,e.children[r]??null);let a=t===n;i.classList.toggle(`is-inactive`,!a),i.inert=!a});for(let n of[...e.children]){let r=n.dataset?.panel;n.classList.contains(`dock-host`)&&r&&!t.includes(r)&&e.removeChild(n)}}},dragged=e=>dragging()??e.dataTransfer?.getData(`application/x-penstock-panel`)??null;function Sash({split:e,boundary:t,shared:n}){let r=e.dir===`row`,measure=e=>[...e.parentElement?.children??[]].filter(e=>e.classList.contains(`dock-cell`)).map(e=>r?e.getBoundingClientRect().width:e.getBoundingClientRect().height),start=i=>{if(i.button!==0)return;i.preventDefault();let a=i.currentTarget,o=measure(a),s=r?i.clientX:i.clientY,c=n.dock,move=i=>n.onDock(resizeBy(c,e.id,t,(r?i.clientX:i.clientY)-s,o)),end=()=>{window.removeEventListener(`pointermove`,move),window.removeEventListener(`pointerup`,end),window.removeEventListener(`pointercancel`,end)};window.addEventListener(`pointermove`,move),window.addEventListener(`pointerup`,end),window.addEventListener(`pointercancel`,end)},key=i=>{let a=i.shiftKey?64:16,o=r?`ArrowLeft`:`ArrowUp`,s=r?`ArrowRight`:`ArrowDown`;(i.key===o||i.key===s)&&(i.preventDefault(),n.onDock(resizeBy(n.dock,e.id,t,i.key===s?a:-a,measure(i.currentTarget))))};return l(`div`,{class:`dock-sash is-${e.dir}`,role:`separator`,"aria-orientation":r?`vertical`:`horizontal`,"aria-label":m(`app.web.dock.resize`),tabIndex:0,onPointerDown:start,onKeyDown:key})}function cellStyle(e,t){return{flex:`${e.sizes[t]} 1 0px`}}function GroupView({group:e,shared:t,edges:n=!0}){let{dock:r,hosts:i}=t,a=o(null),s=useDragging(),c=t.hover?.group===e.id?t.hover.zone:null,d=t.header(e);u(()=>{a.current&&i.attach(a.current,e.tabs,e.active)},[e.tabs.join(`\0`),e.active]);let over=i=>{let a=dragged(i);if(!a)return;let o=i.currentTarget.getBoundingClientRect(),s=zoneAt({left:o.left,top:o.top,width:o.width,height:o.height},i.clientX,i.clientY,n),c=s!==`center`&&!roomToSplit(o.width,s)?`center`:s;canMove(r,a,{group:e.id,zone:c,width:o.width})?(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=`move`),(t.hover?.group!==e.id||t.hover.zone!==c)&&t.setHover({group:e.id,zone:c})):t.hover&&t.setHover(null)},drop=n=>{let i=dragged(n),a=t.hover?.group===e.id?t.hover.zone:null;t.setHover(null),endDrag(),i&&a&&(n.preventDefault(),t.onDock(moveTab(r,i,{group:e.id,zone:a,width:n.currentTarget.getBoundingClientRect().width})))},f=c&&s?highlightOf(c):null;return l(`section`,{class:`dock-group${r.focus===e.id?` is-focused`:``}`,"data-group":e.id,"aria-label":e.active?t.label(e.active):void 0,onPointerDownCapture:()=>{r.focus!==e.id&&t.onDock(focusGroup(r,e.id))},onDragOver:over,onDragLeave:n=>{!n.currentTarget.contains(n.relatedTarget)&&t.hover?.group===e.id&&t.setHover(null)},onDrop:drop,children:[d&&l(`div`,{class:`dock-header`,children:d}),l(`div`,{ref:a,class:`dock-body`,children:e.tabs.length===0&&l(`div`,{class:`dock-empty`,children:t.empty(e)})}),f&&l(`div`,{class:`dock-drop`,style:f,"aria-hidden":`true`})]})}function NodeView({node:e,shared:t}){return e.kind===`group`?l(GroupView,{group:e,shared:t}):l(`div`,{class:`dock-split is-${e.dir}`,"data-split":e.id,children:e.children.flatMap((n,r)=>{let i=l(`div`,{class:`dock-cell`,style:cellStyle(e,r),children:l(NodeView,{node:n,shared:t})},n.id);return r===0?[i]:[l(Sash,{split:e,boundary:r-1,shared:t},`${e.id}:${r}`),i]})})}function DockView(e){let{dock:n,single:r=!1}=e,i=c(()=>new PanelHosts,[]),[a,o]=t(null),s=useDragging(),u=panels(n),d={...e,hosts:i,hover:a,setHover:o};f(()=>{i.keep(u)},[u.join(`\0`)]),f(()=>{s||o(null)},[s]),f(()=>{let finish=()=>endDrag();return window.addEventListener(`dragend`,finish),window.addEventListener(`drop`,finish),()=>{window.removeEventListener(`dragend`,finish),window.removeEventListener(`drop`,finish)}},[]);let p=r?leaves(n.root).find(e=>e.id===n.focus)??leaves(n.root)[0]:null;return l(`div`,{class:`dock`,children:[p?l(GroupView,{group:p,shared:d,edges:!1}):l(NodeView,{node:n.root,shared:d}),u.map(t=>l(PortalOf,{host:i.hostOf(t),children:e.content(t)},t))]})}function PortalOf({host:e,children:t}){return d(t,e)}var En={undo:{key:`z`,shift:!1},redo:{key:`z`,shift:!0},cut:{key:`x`,shift:!1},copy:{key:`c`,shift:!1},paste:{key:`v`,shift:!1},selectAll:{key:`a`,shift:!1}},Dn=new Set([`cut`,`copy`,`paste`]);function editRequest(e,t,n,r){if(t||n&&Dn.has(e))return{native:!0,key:null};let{key:i,shift:a}=En[e];return{native:!1,key:{key:i,metaKey:r,ctrlKey:!r,shiftKey:a}}}function replayEdit(e){let t=document.activeElement??document.body,n=Ee(),r=editRequest(e,De(t),t.closest(`.djs-container`)!==null,n?.platform===`darwin`);r.native?n?.editField?n.editField(e):document.execCommand(e):t.dispatchEvent(new KeyboardEvent(`keydown`,{...r.key,code:`Key${r.key.key.toUpperCase()}`,bubbles:!0,cancelable:!0}))}function useDesktopCommands(e){let t=o(e);t.current=e,f(()=>{let e=Ee();if(e)return e.onCommand((e,n)=>{Se(t.current,e,n)})},[])}var On={mac:!1,loadSession:()=>null,saveSession:()=>void 0,journal:null,autosave:()=>null,setAutosave:()=>void 0,theme:()=>`ide`,setTheme:()=>void 0,sidebar:()=>({open:!0,width:272}),setSidebar:()=>void 0,runEditorAction:()=>!1,licence:async()=>null,showLicence:()=>void 0,notify:()=>void 0,copy:async()=>!1,sessionDelayMs:400},kn=8;function visibleWindow(e,t,n){return{start:Math.max(0,Math.floor(e/28)-kn),end:Math.min(n,Math.ceil((e+t)/28)+kn)}}function nextCursor(e,t,n,r){let i=e[t];if(!i)return e.length>0?{index:0}:null;switch(n){case`ArrowDown`:return{index:Math.min(e.length-1,t+1)};case`ArrowUp`:return{index:Math.max(0,t-1)};case`Home`:return{index:0};case`End`:return{index:e.length-1};case`PageDown`:return{index:Math.min(e.length-1,t+r)};case`PageUp`:return{index:Math.max(0,t-r)};case`ArrowRight`:return i.expanded===!1?{index:t,toggle:`open`}:i.expanded===!0&&e[t+1]?.parent===i.node.id?{index:t+1}:{index:t};case`ArrowLeft`:{if(i.expanded===!0)return{index:t,toggle:`close`};let n=e.findIndex(e=>e.node.id===i.parent);return{index:n>=0?n:t}}default:return null}}var An={process:`<path d="M8 1.5 14.5 8 8 14.5 1.5 8Z"/><path d="M8 5.5v5M5.5 8h5"/>`,decision:`<rect x="1.5" y="2.5" width="13" height="11" rx="1.5"/><path d="M1.5 6.5h13M6.5 6.5v7M10.5 6.5v7"/>`,form:`<rect x="2.5" y="1.5" width="11" height="13" rx="1.5"/><path d="M4.5 4.5h7M4.5 7.5h7M4.5 10.5h4"/>`,testCase:`<path d="M6 2.5h4M7 2.5v4L3.5 12.5a1 1 0 0 0 .9 1.5h7.2a1 1 0 0 0 .9-1.5L9 6.5v-4"/><path d="M5 10.5h6"/>`,template:`<path d="M4 2.5h6l3 3v8h-9z"/><path d="M10 2.5v3h3M6 9h4M6 11.5h4"/>`,source:`<path d="M6 4.5L2.5 8 6 11.5M10 4.5L13.5 8 10 11.5"/>`,diff:`<rect x="2" y="2.5" width="5" height="11" rx="1"/><rect x="9" y="2.5" width="5" height="11" rx="1"/>`,folder:`<path d="M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z"/>`,chevron:`<path d="M6 3.5L10.5 8 6 12.5"/>`,plus:`<path d="M8 3v10M3 8h10"/>`,close:`<path d="M4 4l8 8M12 4l-8 8"/>`,panel:`<rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M6 2.5v11"/>`,list:`<path d="M3 4.5h10M3 8h10M3 11.5h10"/>`,settings:`<path d="M6.62 3.19 6.94 1.33h2.12l.32 1.86 1.04.44 1.55-1.09 1.49 1.49-1.09 1.55.44 1.04 1.86.32v2.12l-1.86.32-.44 1.04 1.09 1.55-1.49 1.49-1.55-1.09-1.04.44-.32 1.86H6.94l-.32-1.86-1.04-.44-1.55 1.09-1.49-1.49 1.09-1.55-.44-1.04-1.86-.32V6.94l1.86-.32.44-1.04-1.09-1.55 1.49-1.49 1.55 1.09z"/><circle cx="8" cy="8" r="2"/>`,keyboard:`<rect x="1.5" y="4" width="13" height="8" rx="1.5"/><path d="M4 6.75h.01M6.5 6.75h.01M9 6.75h.01M11.5 6.75h.01M4 9.25h.01M11.5 9.25h.01M6.5 9.25h3"/>`,split:`<rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M8 2.5v11"/>`,search:`<circle cx="7" cy="7" r="4"/><path d="M10 10l3.5 3.5"/>`,more:`<circle cx="3.5" cy="8" r=".75"/><circle cx="8" cy="8" r=".75"/><circle cx="12.5" cy="8" r=".75"/>`,agent:`<path d="M7 2.5c.5 3 1.5 4 4.5 4.5-3 .5-4 1.5-4.5 4.5-.5-3-1.5-4-4.5-4.5C5.5 6.5 6.5 5.5 7 2.5Z"/><path d="M12 10.5c.2 1.2.8 1.8 2 2-1.2.2-1.8.8-2 2-.2-1.2-.8-1.8-2-2 1.2-.2 1.8-.8 2-2Z"/>`,swap:`<path d="M3 5.5h9M9.5 3 12 5.5 9.5 8M13 10.5H4M6.5 8 4 10.5 6.5 13"/>`,send:`<path d="M8 13V3.5M4 7.5l4-4 4 4"/>`,stop:`<rect x="4.5" y="4.5" width="7" height="7" rx="1"/>`,check:`<path d="M3 8.5 6.5 12 13 4.5"/>`,tool:`<path d="M9.8 2.8a3 3 0 0 0-2.6 4L2.8 11.2a1.2 1.2 0 0 0 1.7 1.7L8.9 8.5a3 3 0 0 0 4-2.6L11 7.8 9 7 8.2 5Z"/>`,penstock:`<path d="M8 1.5 14.5 8 8 14.5 1.5 8Z"/><path d="M8 5v6M5 8h6"/>`,event:`<circle cx="8" cy="8" r="6"/><circle cx="8" cy="8" r="3.5"/>`,gateway:`<path d="M8 1.5 14.5 8 8 14.5 1.5 8Z"/><path d="M5.5 5.5l5 5M10.5 5.5l-5 5"/>`,task:`<rect x="1.5" y="3" width="13" height="10" rx="2"/>`,message:`<rect x="1.5" y="3.5" width="13" height="9" rx="1.5"/><path d="M2 4.5 8 9l6-4.5"/>`,worker:`<path d="M6.62 3.19 6.94 1.33h2.12l.32 1.86 1.04.44 1.55-1.09 1.49 1.49-1.09 1.55.44 1.04 1.86.32v2.12l-1.86.32-.44 1.04 1.09 1.55-1.49 1.49-1.55-1.09-1.04.44-.32 1.86H6.94l-.32-1.86-1.04-.44-1.55 1.09-1.49-1.49 1.09-1.55-.44-1.04-1.86-.32V6.94l1.86-.32.44-1.04-1.09-1.55 1.49-1.49 1.55 1.09z"/><circle cx="8" cy="8" r="2"/>`,variable:`<path d="M5.5 2.5C4 2.5 3.5 3.5 3.5 5v1.5c0 .8-.5 1.5-1.5 1.5 1 0 1.5.7 1.5 1.5V11c0 1.5.5 2.5 2 2.5M10.5 2.5c1.5 0 2 1 2 2.5v1.5c0 .8.5 1.5 1.5 1.5-1 0-1.5.7-1.5 1.5V11c0 1.5-.5 2.5-2 2.5"/>`,test:`<path d="M6 2.5h4M7 2.5v4L3.5 12.5a1 1 0 0 0 .9 1.5h7.2a1 1 0 0 0 .9-1.5L9 6.5v-4"/><path d="M5 10.5h6"/>`,codeTests:`<rect x="2" y="2" width="12" height="12" rx="2"/><path d="M6 6 4.5 8 6 10M10 6l1.5 2L10 10"/>`,deploy:`<path d="M4.5 10.5a3 3 0 0 1-.3-6 4 4 0 0 1 7.6 1 2.5 2.5 0 0 1-.3 5"/><path d="M8 13.5V7.5M5.8 9.5 8 7.3l2.2 2.2"/>`,class:`<circle cx="8" cy="8" r="6"/><path d="M10 6.2A3 3 0 1 0 10 9.8"/>`,method:`<path d="M8 1.5 14 4.8v6.4L8 14.5 2 11.2V4.8Z"/><path d="M2.2 4.9 8 8.2l5.8-3.3M8 8.2v6.2"/>`,file:`<path d="M4 1.5h5.5l3 3v10H4z"/><path d="M9.5 1.5v3h3"/>`,calls:`<path d="M2.5 8h11M10 4.5 13.5 8 10 11.5"/>`,calledBy:`<path d="M13.5 8h-11M6 4.5 2.5 8 6 11.5"/>`,debug:`<rect x="5" y="5" width="6" height="8" rx="3"/><path d="M6.5 3.5 8 5l1.5-1.5M5 8H2.5M11 8h2.5M5.2 11 3 12.5M10.8 11 13 12.5"/>`,paused:`<path d="M6 3.5v9M10 3.5v9"/>`,active:`<path d="M5 3 12.5 8 5 13Z"/>`,copy:`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"/>`,migration:`<path d="M3 5.5h9M9.5 3 12 5.5 9.5 8M13 10.5H4M6.5 8 4 10.5 6.5 13"/>`,script:`<path d="M3.5 2.5h6l3 3v8h-9z"/><path d="M5.5 8.5 7 10l-1.5 1.5M8.5 11.5h2"/>`,flow:`<path d="M2.5 8h10M9 4.5 12.5 8 9 11.5"/>`,find:`<circle cx="7" cy="7" r="4"/><path d="M10 10l3.5 3.5"/>`,run:`<path d="M5 3 12.5 8 5 13Z"/>`,runAll:`<path d="M2.5 3 8 8 2.5 13ZM8.5 3 14 8 8.5 13Z"/>`,implementation:`<path d="M4 1.5h5.5l3 3v10H4z"/><path d="M6 9h4M8.5 7 10.5 9 8.5 11"/>`,groupByFiles:`<path d="M5.5 1.5h4l2 2v8h-6z"/><path d="M3.5 4v10h6"/>`,folders:`<path d="M2 4.5a1 1 0 0 1 1-1h3l1.5 1.5H13a1 1 0 0 1 1 1V12a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1z"/><path d="M2.5 8.5h11"/>`,open:`<path d="M4 1.5h5.5l3 3v10H4z"/><path d="M6 9h4M8.5 7 10.5 9 8.5 11"/>`,config:`<path d="M6.62 3.19 6.94 1.33h2.12l.32 1.86 1.04.44 1.55-1.09 1.49 1.49-1.09 1.55.44 1.04 1.86.32v2.12l-1.86.32-.44 1.04 1.09 1.55-1.49 1.49-1.55-1.09-1.04.44-.32 1.86H6.94l-.32-1.86-1.04-.44-1.55 1.09-1.49-1.49 1.09-1.55-.44-1.04-1.86-.32V6.94l1.86-.32.44-1.04-1.09-1.55 1.49-1.49 1.55 1.09z"/><circle cx="8" cy="8" r="2"/>`,reload:`<path d="M13 8a5 5 0 1 1-1.5-3.5M13 2.5v2.5h-2.5"/>`,error:`<circle cx="8" cy="8" r="6"/><path d="M5.5 5.5l5 5M10.5 5.5l-5 5"/>`,circle:`<circle cx="8" cy="8" r="3"/>`,alert:`<path d="M8 2l6.5 11.5h-13z"/><path d="M8 6.5v3M8 11.5v.01"/>`};function Icon$1({name:e,class:t}){return l(`svg`,{class:t,viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:An[e]}})}e(Icon$1,`Icon`);var jn=new Set(`process.decision.form.event.gateway.task.message.error.worker.variable.test.codeTests.folder.deploy.class.method.file.calls.calledBy.debug.paused.active.copy.migration.find.run.runAll.implementation.groupByFiles.folders.open.config.reload.script.flow`.split(`.`));function iconOfNode(e,t=!1){return t?`alert`:e&&jn.has(e)?e:`circle`}function iconOfGroup(e){return e===`decision`?`decision`:e===`form`?`form`:e===`testCase`?`testCase`:e===`template`?`template`:`process`}function iconOfKind(e,t){return e===`source`?`source`:e===`diff`?`diff`:iconOfGroup(t)}var Mn=600,Nn=12,Pn=800,Fn=new Set([`process`,`decision`,`form`]);function useToolState(e){let[,n]=t(0);return f(()=>{let t=e.subscribe(()=>n(e=>e+1)),r=e.attach();return()=>{t(),r()}},[e]),e.snapshot()}function ToolPanel({store:e,expansion:r,onExpansion:i,onUnlock:a,mac:s,entries:d=null,activePath:p=null,reveal:h=null,newKeys:g}){let _=useToolState(e),[v,y]=t(``),[b,x]=t(null),[S,C]=t(null),[w,E]=t(null),[D,O]=t(0),[k,j]=t(Mn),M=o(null),N=o({text:``,at:0}),P=o(new Map),F=o(null),[I,L]=t(null),R=o(`web-tool-${Math.random().toString(36).slice(2,8)}`),z=o(r);z.current=r;let B=c(()=>flattenTool(_.roots,r,v),[_.roots,r,v]),ee=c(()=>nodeCount(_.roots),[_.roots]);f(()=>{if(_.phase!==`ready`||_.roots.length===0)return;let e=pruneExpansion(z.current,_.roots);sameExpansion(e,z.current)||(z.current=e,i(e))},[_.roots]),u(()=>{let e=M.current;if(!e)return;let measure=()=>j(e.clientHeight||Mn);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[B.length===0]);let V=n(e=>e===null?-1:B.findIndex(t=>t.node.id===e),[B]),H=V(b)>=0?V(b):B.length>0?0:-1,U=B[H],W=n(e=>{let t=M.current;if(!t||e<0)return;let n=e*28,r=t.clientHeight||Mn;n<t.scrollTop?t.scrollTop=n:n+28>t.scrollTop+r&&(t.scrollTop=n+28-r),O(t.scrollTop)},[]);f(()=>{if(!h)return;let e=`file:${h.path}`,t=trailTo(_.roots,e);if(!t)return;let n=t.map(e=>findNode(_.roots,e)).filter(e=>!!e&&!isOpen(e,z.current));if(n.length>0){let e=z.current;for(let t of n)e=setOpen(e,t,!0);z.current=e,i(e)}y(``),x(e),E(e)},[h?.serial]),f(()=>{if(!w)return;let e=B.findIndex(e=>e.node.id===w);e<0||(W(e),M.current?.focus({preventScroll:!0}),E(null))},[w,B]);let te=n((e,t)=>{if(!hasChildren(e))return;let n=z.current,r=setOpen(n,e,t??!isOpen(e,n));z.current=r,i(r)},[i]),ne=n(t=>{t&&e.run(t)},[e]),activate=e=>{x(e.node.id),e.node.open?ne(e.node.open):te(e.node)},shortcutOf=e=>{if(e===`FIND_USAGES`)return Me(`Alt+F7`,s)??void 0;if(e===`COPY`)return Me(`Mod+C`,s)??void 0;if(e===`GO_TO_IMPLEMENTATION`)return Me(`F4`,s)??void 0},itemsFor=e=>{let t=[];if(e.open){let n=e.open;t.push({id:`open`,label:m(`app.web.toolPanel.open`),run:()=>ne(n)})}return(e.actions??[]).forEach((e,n)=>{t.push({id:`a-${n}`,label:e.label,shortcut:shortcutOf(e.keys),separated:t.length>0&&n===0,run:()=>ne(e.id)})}),(d?.itemsFor(e)??[]).forEach((e,n)=>t.push(n===0&&t.length>0?{...e,separated:!0}:e)),t},openMenuAt=(e,t)=>{let n=itemsFor(t);n.length>0&&C({at:e,items:n})},onKeyDown=e=>{let t=B[H];if(!t)return;if(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey){e.preventDefault();let n=M.current?.getBoundingClientRect(),r=H*28-(M.current?.scrollTop??0);openMenuAt({x:(n?.left??0)+24,y:(n?.top??0)+r+28},t.node);return}if(d&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&(e.key===`F2`||e.key===`Delete`||e.key===`Backspace`&&e.metaKey)){let n=e.key===`F2`?`rename`:`delete`,r=d.itemsFor(t.node).find(e=>e.id===n);if(r){e.preventDefault(),r.run();return}}if((s?e.metaKey:e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`c`){let n=keyedAction(t.node,`COPY`);n&&(e.preventDefault(),ne(n));return}if(e.altKey&&e.key===`F7`){let n=keyedAction(t.node,`FIND_USAGES`);n&&(e.preventDefault(),ne(n));return}if(e.key===`F4`&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let n=keyedAction(t.node,`GO_TO_IMPLEMENTATION`);n&&(e.preventDefault(),ne(n));return}if(e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`Enter`||e.key===` `){e.preventDefault(),activate(t);return}if(e.key.length===1){let t=Date.now(),n=t-N.current.at>Pn?e.key:N.current.text+e.key;N.current={text:n,at:t};let r=typeAhead(B,H,n);r>=0&&(e.preventDefault(),x(B[r].node.id),W(r));return}let n=Math.max(1,Math.floor((M.current?.clientHeight||Mn)/28)-1),r=nextCursor(B,H,e.key,n);if(!r)return;e.preventDefault();let i=B[r.index];r.toggle&&i&&te(i.node,r.toggle===`open`),i&&(x(i.node.id),W(r.index))},serial=e=>{let t=P.current.get(e);return t===void 0&&(t=P.current.size+1,P.current.set(e,t)),t},{start:re,end:ie}=visibleWindow(D,k,B.length),ae=B.slice(re,ie),G=_.roots.length>0,oe=_.error!==null;return l(`div`,{class:`web-tool`,"aria-busy":_.busy!==null||_.phase===`loading`,children:[l(`div`,{class:`web-tool__header`,children:[l(`h2`,{class:`web-tool__title type-section-heading`,children:m(`app.web.tree.project`)}),l(`div`,{class:`web-tool__toolbar`,role:`toolbar`,"aria-label":m(`app.web.toolPanel.toolbar`),children:[d&&l(`button`,{type:`button`,class:`web-tool__tool`,"aria-label":m(`app.web.tree.newFile`),title:g?`${m(`app.web.tree.newFile`)} (${g})`:m(`app.web.tree.newFile`),onClick:d.newFile,children:l(Icon$1,{name:`plus`})}),_.toolbar.map(e=>l(`button`,{type:`button`,class:`web-tool__tool${e.selected?` is-on`:``}`,"aria-label":e.label,"aria-pressed":e.selected===void 0?void 0:e.selected,title:e.label,onClick:()=>ne(e.id),children:l(Icon$1,{name:iconOfNode(e.icon)})},e.id)),d?l(`button`,{type:`button`,class:`web-tool__tool`,"aria-haspopup":`menu`,"aria-label":m(`app.web.tree.more`),title:m(`app.web.tree.more`),onClick:e=>{let t=e.currentTarget,n=t.getBoundingClientRect();C({at:{x:n.left,y:n.bottom+4},items:d.headerItems(p),opener:t})},children:l(Icon$1,{name:`more`})}):l(`button`,{type:`button`,class:`web-tool__tool`,"aria-label":m(`app.web.toolPanel.refresh`),title:m(`app.web.toolPanel.refresh`),onClick:()=>void e.refresh(),children:l(Icon$1,{name:`reload`})})]})]}),G&&l(`div`,{class:`web-tool__filter`,children:l(`input`,{type:`search`,class:`web-tool__filter-input type-input`,"aria-label":m(`app.web.toolPanel.filter`),placeholder:m(`app.web.toolPanel.filter`),value:v,onInput:e=>{y(e.target.value),O(0),M.current&&(M.current.scrollTop=0)},onKeyDown:e=>{e.key===`ArrowDown`&&B.length>0&&(e.preventDefault(),M.current?.focus({preventScroll:!0}))}})}),_.codeLinks===`locked`&&G&&l(`div`,{class:`web-tool__notice`,role:`status`,children:[l(`span`,{class:`web-tool__notice-text type-help`,children:m(`app.web.toolPanel.locked`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:a,children:m(`app.web.toolPanel.unlock`)})]}),oe&&G&&l(`div`,{class:`web-tool__notice is-error`,role:`alert`,children:[l(`span`,{class:`web-tool__notice-text type-help`,children:m(`app.web.toolPanel.refreshFailed`,{reason:_.error??``})}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>void e.refresh(),children:m(`app.common.retry`)})]}),_.truncated&&G&&l(`p`,{class:`web-tool__status type-help`,role:`status`,children:m(`app.web.toolPanel.truncated`,{count:ee})}),_.phase===`loading`&&!G&&l(`p`,{class:`web-tool__status type-help`,role:`status`,children:m(`app.web.toolPanel.loading`)}),_.phase===`error`&&!G&&l(A,{title:m(`app.web.toolPanel.error`),hint:_.error??void 0,actions:[{label:m(`app.common.retry`),run:()=>void e.refresh()}]}),_.phase===`ready`&&!G&&!oe&&l(A,{title:m(`app.web.toolPanel.empty`),hint:m(`app.web.toolPanel.emptyHint`),actions:[{label:m(`app.web.toolPanel.refresh`),run:()=>void e.refresh()}]}),G&&B.length===0&&l(`p`,{class:`web-tool__status type-help`,role:`status`,children:m(`app.web.toolPanel.noMatch`)}),l(`div`,{ref:M,class:`web-tool__list`,role:`tree`,"aria-label":m(`app.web.toolPanel.label`),tabIndex:B.length>0?0:-1,hidden:B.length===0,"aria-activedescendant":U?`${R.current}-${serial(U.node.id)}`:void 0,onKeyDown,onScroll:e=>O(e.currentTarget.scrollTop),onContextMenu:e=>{d&&e.target===e.currentTarget&&(e.preventDefault(),C({at:{x:e.clientX,y:e.clientY},items:d.backgroundItems()}))},children:l(`div`,{class:`web-tool__canvas`,style:{height:`${B.length*28}px`},children:ae.map((e,t)=>{let n=re+t,{node:r}=e,i=n===H,a=iconOfNode(r.icon,r.warning===!0),o=d?.targetOf(r)??null,s=d?d.dropFolderOf(r):null,c=p!==null&&r.id.startsWith(`file:`)&&r.path===p;return l(`div`,{id:`${R.current}-${serial(r.id)}`,role:`treeitem`,"aria-level":e.depth+1,"aria-setsize":e.siblings,"aria-posinset":e.position,"aria-expanded":e.expanded===null?void 0:e.expanded,"aria-selected":i,class:`web-tool__row type-body${i?` is-selected`:``}${c?` is-current`:``}${r.warning?` is-warning`:``}${I===r.id?` is-drop`:``}`,"aria-current":c?`true`:void 0,draggable:!!o,onDragStart:e=>{o&&(F.current=o,e.dataTransfer?.setData(`application/x-penstock-entry`,r.id),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`))},onDragEnd:()=>{F.current=null,L(null)},onDragOver:e=>{let t=F.current;d&&t&&s!==null&&d.canDrop(t,s)&&(e.preventDefault(),e.stopPropagation(),L(r.id))},onDrop:e=>{let t=F.current;F.current=null,L(null),d&&t&&s!==null&&d.canDrop(t,s)&&(e.preventDefault(),e.stopPropagation(),d.drop(t,s))},style:{top:`${n*28}px`,paddingLeft:`${8+e.depth*Nn}px`},title:tooltipOf(r),onClick:()=>{M.current?.focus({preventScroll:!0}),x(r.id)},onDblClick:()=>activate(e),onContextMenu:e=>{e.preventDefault(),x(r.id),openMenuAt({x:e.clientX,y:e.clientY},r)},children:[l(`span`,{class:`web-tool__chevron${e.expanded?` is-open`:``}`,onClick:t=>{hasChildren(r)&&(t.stopPropagation(),M.current?.focus({preventScroll:!0}),x(r.id),te(r,e.expanded!==!0))},children:hasChildren(r)&&l(Icon$1,{name:`chevron`})}),l(Icon$1,{class:`web-tool__icon${r.icon&&Fn.has(r.icon)?` web-tool__icon--file`:``}`,name:a}),l(`span`,{class:`web-tool__label`,children:r.label}),r.detail&&l(`span`,{class:`web-tool__detail type-help`,children:r.detail})]},r.id)})})}),S&&l(T,{label:m(`app.web.toolPanel.menu`),at:S.at,items:S.items,returnFocusTo:S.opener,onClose:()=>C(null)}),d?.dialogs]})}var In={file:()=>null,check:async()=>void 0,element:async()=>null,peek:()=>null,subscribe:()=>()=>void 0,openFile:()=>void 0,openElement:()=>void 0,openCode:()=>void 0},Ln=i(In);function useLinks(){return r(Ln)}function useLinkUpdates(){let e=useLinks(),[,n]=t(0);f(()=>{let t=!0,again=()=>{t&&n(e=>e+1)};e.refreshScenarios?.().then(again);let r=e.subscribe(again);return()=>{t=!1,r()}},[e])}function useElementFacts(e,n){let r=useLinks(),[,i]=t(0),a=r.peek(e,n);return f(()=>{let t=!0,again=()=>t&&i(e=>e+1);r.element(e,n).then(again);let a=r.subscribe(again);return()=>{t=!1,a()}},[r,e,n]),a===void 0?{state:`loading`}:a===null?{state:`missing`}:{state:`found`,facts:a}}function useFile(e){let n=useLinks(),[,r]=t(0),i=n.file(e)===null;return f(()=>{if(!i)return;let t=!0;return n.check(e).then(()=>t&&r(e=>e+1)),()=>{t=!1}},[n,e,i]),n.file(e)}function paidTier(e){return!e||typeof e!=`object`?!1:e.tier===`PRO`||e.tier===`TEAM`}function useLicence(){let[e,r]=t({flow:!1,code:!1}),i=o(!0);f(()=>(i.current=!0,()=>{i.current=!1}),[]);let a=n(async()=>{let e=null;try{e=await Q().getLicense().catch(()=>null)}catch{e=null}let t=paidTier(e);i.current&&r({flow:t,code:t})},[]);return f(()=>{a()},[a]),{flags:e,unlock:n(async e=>{try{let t=Q();return!t?.requestFeature||!await t.requestFeature(e)?!1:(await a(),!0)}catch{return!1}},[a]),refresh:a}}var Rn=`app.agent.exited`,zn=`app.agent.installFailed`,Bn=`app.agent.npmMissing`,Vn=new Set([Rn,zn,Bn,`app.agent.unpublished`,`app.agent.serviceExited`,`app.agent.serviceNotStarted`]);function isRawOutput(e){return Vn.has(e)}function failureLine(e){return isRawOutput(e.key)?m(e.key):m(e.key,{detail:e.detail})}function failureDetails(e){return isRawOutput(e.key)&&e.detail.trim()!==``?e.detail:null}function failureSummary(e,t){return e?isRawOutput(e.key)?{text:failureLine(e),details:failureDetails(e)}:{text:e.detail||t,details:null}:{text:t,details:null}}var Hn=/sign[ -]?in|log[ -]?in|logged in|authenticat|unauthori[sz]ed|credential|api key/i;function classify(e,t,n){return n&&!t.some(e=>e.available)?`noAgent`:e&&(e.key===`app.agent.authRequired`||Hn.test(`${e.key} ${e.detail}`))?`signedOut`:`ended`}var Un={claude:`npm install -g @agentclientprotocol/claude-agent-acp`,codex:`npm install -g @zed-industries/codex-acp`,gemini:`npm install -g @google/gemini-cli`,opencode:`npm install -g opencode-ai`};function installCommand(e,t){return((t?e.find(e=>e.id===t)?.install:null)??e.find(e=>e.source===`preset`&&e.install)?.install)||(Un[t&&Un[t]?t:e.find(e=>e.source===`preset`&&Un[e.id])?.id??`claude`]??null)}function FailureDetails({text:e}){return l(`details`,{class:`assistant-failure-details`,children:[l(`summary`,{class:`type-help`,children:m(`app.assistant.showDetails`)}),l(`pre`,{class:`assistant-failure-details__text type-code`,children:e})]})}var Wn=/^(?:mcp__penstock__|penstock_|penstock\/)([A-Za-z0-9_]+)/,Gn=/^mcp__[A-Za-z0-9-]+__([A-Za-z0-9_]+)/,Kn=new Set([`listDiagrams`,`showDiagram`,`editDiagram`,`checkDiagram`,`analyzeFlow`,`listScenarios`,`checkCodeLinks`]),qn=new Set([`toolsearch`,`todowrite`,`exitplanmode`]);function camel(e){return e.replace(/_([a-z0-9])/g,(e,t)=>t.toUpperCase())}function words$1(e){let t=e.replace(/[_-]+/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}e(words$1,`words`);function bareName(e){let t=Wn.exec(e);if(t)return t[1];let n=Gn.exec(e);return n?n[1]:e}function ownToolName(e){let t=Wn.exec(e.title.trim());if(!t)return null;let n=camel(t[1]);return Kn.has(n)?n:null}function isBookkeeping(e){return qn.has(bareName(e.title.trim()).replace(/[\s_-]+/g,``).toLowerCase())}function toolTitle(e){let t=e.title.trim(),n=Wn.exec(t);if(n){let e=camel(n[1]);return Kn.has(e)?m(`app.assistant.tool.penstock.${e}`):words$1(n[1])}return Gn.test(t)||/^[A-Za-z]+(?:[A-Z][a-z0-9]+)+$/.test(t)||/^[a-z0-9]+(?:_[a-z0-9]+)+$/.test(t)?words$1(bareName(t)):t}var isWork=e=>e.kind===`thought`||e.kind===`tool`||e.kind===`plan`;function blocksOf(e){let t=[];for(let n of e)if(n.kind===`tool`&&n.tool.diffs.length>0&&n.tool.status===`done`)t.push({kind:`applied`,id:`applied:${n.id}`,entry:n});else if(isWork(n)){let e=t[t.length-1];e?.kind===`work`?e.steps.push(n):t.push({kind:`work`,id:`work:${n.id}`,steps:[n]})}else t.push({kind:`entry`,id:n.id,entry:n});return t}function stepOf(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind===`plan`){let e=n.items.find(e=>e.status===`running`)??n.items.find(e=>e.status===`pending`);if(e)return e.text}}for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind===`tool`&&!isBookkeeping(n.tool))return toolTitle(n.tool)}return m(`app.assistant.thinking`)}function countSteps(e,t){let n=0;for(let r of e)r.kind===`tool`?(t||!isBookkeeping(r.tool))&&(n+=1):r.kind===`plan`?n+=r.items.length:n+=1;return n}var Jn=/```[^\n]*\n([\s\S]*?)```/g,Yn=/<\?xml|<bpmn:definitions|<definitions\b/;function longestFence(e){let t=0;for(let n of e.matchAll(Jn))t=Math.max(t,n[1].replace(/\n$/,``).split(`
961
+ `).length);return t}var Xn=/<\/(?:bpmn:)?definitions>/;function masked(e){return e.replace(Jn,e=>` `.repeat(e.length))}function fenceDocument(e){let t=masked(e),n=t.search(Yn);if(n<0)return e;let r=Xn.exec(t.slice(n)),i=r?n+r.index+r[0].length:e.length,a=e.slice(0,n),o=e.slice(i),s=a===``||a.endsWith(`
962
+ `)?``:`
963
+ `,c=o===``||o.startsWith(`
964
+ `)?``:`
965
+ `;return`${a}${s}\`\`\`xml\n${e.slice(n,i)}\n\`\`\`${c}${o}`}function expandReason(e){if(e.filter(e=>e.kind===`user`).length>3)return`long`;for(let t of e)if(t.kind===`agent`){if(Yn.test(t.text.replace(Jn,``)))return`document`;if(longestFence(t.text)>12)return`long`}return null}var Zn={StartEvent:`start-event-none`,EndEvent:`end-event-none`,IntermediateCatchEvent:`intermediate-event-none`,IntermediateThrowEvent:`intermediate-event-none`,BoundaryEvent:`intermediate-event-none`,ExclusiveGateway:`gateway-xor`,ParallelGateway:`gateway-parallel`,InclusiveGateway:`gateway-or`,EventBasedGateway:`gateway-eventbased`,SubProcess:`subprocess-expanded`,CallActivity:`call-activity`,SequenceFlow:`connection`,UserTask:`user-task`,ServiceTask:`service-task`,ScriptTask:`script-task`,SendTask:`send-task`,ReceiveTask:`receive-task`,BusinessRuleTask:`business-rule-task`,ManualTask:`manual-task`};function iconClassOf(e){return`bpmn-icon-${Zn[e.includes(`:`)?e.slice(e.indexOf(`:`)+1):e]??`task`}`}function ElementChip({id:e,type:t,name:n,selected:r,removed:i,onSelect:a,onHover:o}){let s=n||e;return l(`button`,{type:`button`,class:`element-chip type-body${r?` is-selected`:``}${i?` is-removed`:``}`,"aria-pressed":r?`true`:void 0,title:`${Z(t)} · ${e}`,"aria-label":m(`app.aiBlocks.selectElement`,{type:Z(t),name:s}),onClick:()=>a(e),onPointerEnter:o?()=>o(e,!0):void 0,onPointerLeave:o?()=>o(e,!1):void 0,onFocus:o?()=>o(e,!0):void 0,onBlur:o?()=>o(e,!1):void 0,children:[l(`span`,{class:`element-chip__icon ${iconClassOf(t)}`,"aria-hidden":`true`}),l(`span`,{class:`element-chip__name`,children:s})]})}var Qn=new Set([`bpmn`,`dmn`,`form`]),$n={diagram:`<path d="M4 1.5h5.5l3 3v10H4zM9.5 1.5v3h3"/>`,code:`<path d="M6 4.5 2.5 8 6 11.5M10 4.5 13.5 8 10 11.5"/>`};function FileChip({name:e,kind:t,title:n,onOpen:r}){let i=Qn.has(t);return l(`button`,{type:`button`,class:`element-chip element-chip--file type-body is-${i?`diagram`:`code`}`,title:n,onClick:r,children:[l(`svg`,{class:`element-chip__icon element-chip__glyph`,viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:i?$n.diagram:$n.code}}),l(`span`,{class:`element-chip__name`,children:e})]})}var er={properties:`<path d="M2 4h5M11 4h3M2 8h2M8 8h6M2 12h7M13 12h1"/><circle cx="9" cy="4" r="1.5"/><circle cx="6" cy="8" r="1.5"/><circle cx="11" cy="12" r="1.5"/>`,scenarios:`<path d="M2 3.5h6M2 8h6M2 12.5h6M10.5 5.5l3.5 2.5-3.5 2.5z"/>`,tests:`<path d="M2 3.5l1.2 1.2L5.5 2.5M2 8.5l1.2 1.2L5.5 7.5M2 13.5l1.2 1.2 2.3-2.2M8 4h6M8 9h6M8 14h6"/>`,preview:`<path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/>`,problems:`<path d="M8 1.5l6.5 6.5-6.5 6.5L1.5 8z"/><path d="M5.5 8l1.8 1.8 3.2-3.5"/>`,monitor:`<path d="M1.5 8h3l1.5-4 3 8 1.5-4h4"/>`,debug:`<circle cx="4.5" cy="8" r="2"/><path d="M8.5 3.5v9M8.5 8h5M11.5 5.5 14 8l-2.5 2.5"/>`,chat:`<path d="M2.5 2.5h11a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8.5L5 13.5v-3H2.5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1z"/><path d="M5 6.5h.01M8 6.5h.01M11 6.5h.01"/>`,comments:`<path d="M3.5 2.5h9v11h-9z"/><path d="M5.5 6h5M5.5 9h3.5"/>`,code:`<path d="M5.5 4L2 8l3.5 4M10.5 4L14 8l-3.5 4"/>`,aiagents:`<rect x="2.5" y="5.5" width="11" height="8" rx="2"/><path d="M8 5.5V3"/><circle cx="8" cy="2.5" r=".5"/><path d="M5.8 9.5h.01M10.2 9.5h.01M6.5 11.5h3"/>`,back:`<path d="M10 3.5L5.5 8l4.5 4.5"/>`,forward:`<path d="M6 3.5L10.5 8 6 12.5"/>`,close:`<path d="M4 4l8 8M12 4l-8 8"/>`,expand:`<path d="M4 10l4-4 4 4"/>`,more:`<path d="M3.5 8h.01M8 8h.01M12.5 8h.01"/>`};function TabIcon({name:e}){return l(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:er[e]??``}})}function ScenarioChip({name:e,onOpen:t}){let n=m(`app.aiBlocks.openScenario`,{name:e});return l(`button`,{type:`button`,class:`element-chip element-chip--scenario type-body`,title:n,"aria-label":n,onClick:t,children:[l(`span`,{class:`element-chip__icon`,"aria-hidden":`true`,children:l(TabIcon,{name:`scenarios`})}),l(`span`,{class:`element-chip__name`,children:e})]})}var tr=2e5,nr=300,rr=/^ {0,3}(`{3,}|~{3,})\s*([\w+#.-]*)\s*$/,ir=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,ar=/^(\s*)[-*+]\s+(.*)$/,or=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,sr=/\.(?:bpmn|dmn|form)$/i,cr=/^((?:[\w.@-]+\/)*[\w.@-]+\.[A-Za-z][A-Za-z0-9]{1,9})(?:#([A-Za-z_][\w.-]*)|:(\d{1,7}))?$/,lr=/^https?:\/\//i,ur=/([\s,;()[\]{}<>"'`]+)/,dr=/[.,;:!?]+$/;function safeUrl(e){let t=e.trim();if(!lr.test(t)||/[\s<>"]/.test(t))return null;try{let e=new URL(t);return e.protocol===`http:`||e.protocol===`https:`?e.href:null}catch{return null}}function referenceOf(e){if(e.length>nr||e.length<3)return null;let t=cr.exec(e);if(!t)return null;let n=t[1],r=t[2]??null;return r!==null&&!sr.test(n)?null:{path:n,id:r,line:t[3]?Number(t[3]):null}}function penstockReference(e){let t=e.trim();if(!/^penstock:/i.test(t))return null;let n=t.slice(9).replace(/^\/\//,``);try{n=decodeURIComponent(n)}catch{return null}if(n.length>nr*2)return null;let r=n.indexOf(`#`),i=r<0?n:n.slice(0,r),a=r<0?null:n.slice(r+1);if(!i||i.startsWith(`/`)||i.split(`/`).includes(`..`)||/[\s<>"\\]/.test(i)||a!==null&&!/^[A-Za-z_][\w.-]*$/.test(a))return null;let o=/^(.*):(\d{1,7})$/.exec(i);return a===null&&o?{path:o[1],id:null,line:Number(o[2])}:{path:i,id:a,line:null}}function words(e){let t=e.split(ur),n=[],r=``,flush=()=>{r&&n.push({kind:`text`,text:r}),r=``};for(let e of t){if(e===``||e.length>nr){r+=e;continue}if(lr.test(e)){let t=e.replace(dr,``),i=safeUrl(t);if(i){flush(),n.push({kind:`link`,href:i,label:t}),r+=e.slice(t.length);continue}}let t=e.replace(dr,``),i=referenceOf(t);i?(flush(),n.push({kind:`reference`,reference:i,raw:t}),r+=e.slice(t.length)):r+=e}return flush(),n}function inlines(e,t=0){let n=[],r={"*":new Uint8Array(e.length),_:new Uint8Array(e.length)},i=``,a=0,flush=()=>{i&&n.push(...words(i)),i=``};for(;a<e.length;){let o=e[a];if(o==="`"){let t=1;for(;e[a+t]==="`";)t+=1;let r="`".repeat(t),o=e.indexOf(r,a+t);if(o>a+t&&!e.slice(a+t,o).includes(`
966
+ `)){flush();let r=e.slice(a+t,o).trim(),i=referenceOf(r.replace(dr,``));n.push({kind:`code`,text:r,...i?{reference:i}:{}}),a=o+t;continue}i+=r,a+=t}else{if(o===`*`&&e[a+1]===`*`&&t<2){let r=e.indexOf(`**`,a+2),i=r>a+2?e.slice(a+2,r):``;if(i&&!/^\s|\s$/.test(i)&&!i.includes(`
967
+ `)){flush(),n.push({kind:`strong`,children:inlines(i,t+1)}),a=r+2;continue}}if((o===`*`||o===`_`)&&e[a+1]!==o&&t<2){let i=emphasisEnd(e,a,o,r[o]);if(i>a){flush(),n.push({kind:`emphasis`,children:inlines(e.slice(a+1,i),t+1)}),a=i+1;continue}}if(o===`[`){let t=e.indexOf(`](`,a+1),r=t>a?e.slice(a+1,t):``;if(t>a&&r&&!r.includes(`
968
+ `)&&!r.includes(`[`)){let o=matching(e,t+2),s=o>t?e.slice(t+2,o):``;if(o>t&&s&&!s.includes(`
969
+ `)){let e=safeUrl(s),t=e?null:penstockReference(s);if(e){flush(),n.push({kind:`link`,href:e,label:r}),a=o+1;continue}if(t){flush(),n.push({kind:`reference`,reference:t,label:r,raw:r}),a=o+1;continue}i+=r,a=o+1;continue}}}i+=o,a+=1}}return flush(),n}var fr=/[\p{L}\p{N}_]/u;function emphasisEnd(e,t,n,r){let i=e[t+1];if(!i||/\s/.test(i)||n===`_`&&t>0&&fr.test(e[t-1]))return-1;let a=[],fail=()=>{for(let e of a)e>=t+2&&(r[e]=1);return-1};for(let i=t+1;i<e.length;i+=1){if(r[i]===1)return fail();a.push(i);let o=e[i];if(o===`
970
+ `)return fail();if(o==="`"){let t=e.indexOf("`",i+1);if(t<0)return fail();i=t}else if(o===n){if(e[i+1]===n||e[i-1]===n)i+=1;else if(!/\s/.test(e[i-1])&&!(n===`_`&&i+1<e.length&&fr.test(e[i+1])))return i>t+1?i:-1}}return fail()}function matching(e,t){let n=0;for(let r=t;r<e.length&&r<t+nr*2;r+=1){let t=e[r];if(t===`
971
+ `)return-1;if(t===`(`)n+=1;else if(t===`)`){if(n===0)return r;--n}}return-1}function indentOf(e){return Math.min(2,Math.floor(e.replace(/\t/g,` `).length/2))}function parseMarkdown(e){let t=e.length>tr,n=(t?e.slice(0,tr):e).split(`
972
+ `),r=[],i=[],a={list:null},o=null,endParagraph=()=>{i.length>0&&r.push({kind:`paragraph`,children:inlines(i.join(`
973
+ `))}),i=[]},endList=()=>{a.list=null};for(let e of n){if(o){let t=rr.exec(e);t&&t[1][0]===o.mark[0]&&t[1].length>=o.mark.length&&t[2]===``?(r.push({kind:`code`,lang:o.lang,text:o.body.join(`
974
+ `),open:!1}),o=null):o.body.push(e);continue}let t=rr.exec(e);if(t){endParagraph(),endList(),o={mark:t[1],lang:t[2],body:[]};continue}if(e.trim()===``){endParagraph(),endList();continue}let n=ir.exec(e);if(n){endParagraph(),endList(),r.push({kind:`heading`,level:n[1].length,children:inlines(n[2])});continue}let s=ar.exec(e),c=s?null:or.exec(e);if(s||c){endParagraph();let e=!!c;a.list&&a.list.ordered===e||(a.list={kind:`list`,ordered:e,start:c?Number(c[2]):1,items:[]},r.push(a.list)),a.list.items.push({depth:indentOf((s??c)[1]),children:inlines(s?s[2]:c[3])})}else if(a.list&&/^\s+\S/.test(e)&&a.list.items.length>0){let t=a.list.items[a.list.items.length-1];t.children=[...t.children,{kind:`text`,text:` `},...inlines(e.trim())]}else endList(),i.push(e)}return o&&r.push({kind:`code`,lang:o.lang,text:o.body.join(`
975
+ `),open:!0}),endParagraph(),{blocks:r,truncated:t}}var pr=/\.bpmn(\.xml)?$/i;function reasonOf(e,t,n){return e===`file`?m(`app.assistant.chip.noFile`,{file:n}):m(`app.assistant.chip.noElement`,{id:t,file:n})}function InertChip({id:e,path:t,reason:n}){return l(`span`,{class:`element-chip element-chip--inert type-body`,title:`${t}#${e}`,"aria-busy":n===`loading`?`true`:void 0,children:[l(`span`,{class:`element-chip__icon bpmn-icon-task`,"aria-hidden":`true`}),l(`span`,{class:`element-chip__name`,children:e}),n!==`loading`&&l(`span`,{class:`element-chip__note type-help`,children:reasonOf(n,e,t)})]})}function ElementReference({reference:e,label:t}){let n=useLinks(),r=e.id,i=useFile(e.path),a=pr.test(e.path),o=useElementFacts(e.path,r);return i?a&&o.state===`found`?l(ElementChip,{id:r,type:o.facts.type,name:t??o.facts.name,onSelect:()=>n.openElement(i.rel,r),onHover:(e,t)=>n.highlight?.(i.rel,e,t)}):a&&o.state===`loading`?l(InertChip,{id:r,path:e.path,reason:`loading`}):a?l(InertChip,{id:r,path:e.path,reason:`element`}):l(FileChip,{name:t??`${baseOf(i.rel)}#${r}`,kind:i.kind,title:`${i.rel}#${r}`,onOpen:()=>n.openFile(i.rel)}):l(InertChip,{id:r,path:e.path,reason:`file`})}function baseOf(e){return e.split(`/`).pop()??e}function FileReference({reference:e,label:t,raw:n,code:r}){let i=useLinks(),o=useFile(e.path);if(!o)return r?l(`code`,{class:`agent-code type-code`,children:n}):l(a,{children:n});let s=o.kind===`bpmn`||o.kind===`dmn`||o.kind===`form`,c=s?null:e.line,u=t??n,d=c===null?m(`app.assistant.openFile`,{path:o.rel}):m(`app.assistant.openAtLine`,{path:o.rel,line:c});return l(FileChip,{name:u,kind:o.kind,title:d,onOpen:()=>c!==null||!s?i.openCode(o.rel,c):i.openFile(o.rel)})}var mr=/"([^"\n]{2,80})"|“([^”\n]{2,80})”|«([^»\n]{2,80})»/g;function isNamed(e,t){return!!e.named?.(t)||!!e.scenario?.(t)}function NamedChip({name:e}){let t=useLinks(),n=t.named?.(e);if(n)return l(ElementChip,{id:n.id,type:n.type,name:n.name,onSelect:e=>{t.openElement(n.file,e),t.flash?.(n.file,[e])},onHover:(e,r)=>t.highlight?.(n.file,e,r)});let r=t.scenario?.(e);return r?l(ScenarioChip,{name:e,onOpen:()=>t.openScenario?.(r.file,r.name)}):null}function QuotedText({text:e}){let t=useLinks();useLinkUpdates();let n=[],r=0;for(let i of e.matchAll(mr)){let a=i[1]??i[2]??i[3];if(!isNamed(t,a))continue;let o=i.index??0;o>r&&n.push(l(`span`,{children:e.slice(r,o)},`t${o}`)),n.push(l(NamedChip,{name:a},`c${o}`)),r=o+i[0].length}return n.length===0?l(a,{children:e}):(r<e.length&&n.push(l(`span`,{children:e.slice(r)},`end`)),l(a,{children:n}))}function NamedText({text:e}){let t=useLinks();return!t.named&&!t.scenario||!e.includes(`"`)&&!e.includes(`“`)&&!e.includes(`«`)?l(a,{children:e}):l(QuotedText,{text:e})}function NamedCode({text:e}){let t=useLinks();return useLinkUpdates(),isNamed(t,e)?l(NamedChip,{name:e}):l(`code`,{class:`agent-code type-code`,children:e})}function InlineView({item:e}){switch(e.kind){case`text`:return l(NamedText,{text:e.text});case`code`:return e.reference?e.reference.id===null?l(FileReference,{reference:e.reference,raw:e.text,code:!0}):l(ElementReference,{reference:e.reference}):l(NamedCode,{text:e.text});case`strong`:return l(`strong`,{class:`agent-strong`,children:e.children.map((e,t)=>l(InlineView,{item:e},t))});case`emphasis`:return l(`em`,{class:`agent-emphasis`,children:e.children.map((e,t)=>l(InlineView,{item:e},t))});case`link`:return l(`a`,{class:`agent-link type-body`,href:e.href,target:`_blank`,rel:`noopener noreferrer`,children:e.label});case`reference`:return e.reference.id===null?l(FileReference,{reference:e.reference,label:e.label,raw:e.raw}):l(ElementReference,{reference:e.reference,label:e.label})}}function idReference(e){return e?(e.kind===`reference`||e.kind===`code`&&!!e.reference)&&e.reference.id!==null:!1}function plainOf(e){return e.map(e=>e.kind===`text`?e.text:e.kind===`strong`||e.kind===`emphasis`?plainOf(e.children):``).join(``)}function segmentsOf(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(!idReference(r)){t.push({kind:`item`,item:r});continue}let i=e[n+1],a=``,o=!1,s=``,c=t[t.length-1];if(c?.kind===`item`&&c.item.kind===`text`){let e=/\(\s*$/.exec(c.item.text);e&&i?.kind===`text`&&/^\s*\)/.test(i.text)?(o=!0,a=c.item.text.slice(0,e.index)):a=c.item.text,t.pop()}let l=null,u=t[t.length-1];a.trim()===``&&u?.kind===`item`&&(u.item.kind===`strong`||u.item.kind===`emphasis`)&&(l=u.item,t.pop()),o&&i?.kind===`text`&&(s=i.text.replace(/^\s*\)/,``),n+=1),t.push({kind:`echo`,bearer:l,head:a,ref:r,paren:o,tail:s})}return t}function sameName(e,t){return e.trim().toLocaleLowerCase()===t.trim().toLocaleLowerCase()}function EchoedReference({segment:e}){let{ref:t,bearer:n,head:r,paren:i,tail:o}=e,s=t.reference,c=useElementFacts(s.path,s.id),u=(t.kind===`reference`?t.label:void 0)??(c.state===`found`?c.facts.name:void 0),d=!!u&&!!n&&sameName(plainOf([n]),u),f=r.trimEnd(),p=!!u&&!d&&f.length>=u.length&&sameName(f.slice(f.length-u.length),u)&&!(f.length>u.length&&hr.test(f[f.length-u.length-1]));return d||p?l(a,{children:[p?f.slice(0,f.length-u.length):r,l(InlineView,{item:t}),o]}):l(a,{children:[n&&l(InlineView,{item:n}),r,i&&`(`,l(InlineView,{item:t}),i&&`)`,o]})}var hr=/[\p{L}\p{N}_]/u;function Inlines({items:e}){return l(a,{children:segmentsOf(e).map((e,t)=>e.kind===`item`?l(InlineView,{item:e.item},t):l(EchoedReference,{segment:e},t))})}function BlockView({block:e,code:t}){switch(e.kind){case`paragraph`:return l(`p`,{class:`assistant-rich__text type-body`,children:l(Inlines,{items:e.children})});case`heading`:return l(`p`,{class:`assistant-rich__text assistant-rich__heading type-body`,children:l(Inlines,{items:e.children})});case`list`:{let t=e.ordered?`ol`:`ul`;return l(t,{class:`assistant-rich__list type-body`,start:e.ordered&&e.start!==1?e.start:void 0,children:e.items.map((e,t)=>l(`li`,{class:`assistant-rich__item is-depth-${e.depth}`,children:l(Inlines,{items:e.children})},t))})}case`code`:return t?t({text:e.text,lang:e.lang}):l(`pre`,{class:`assistant-rich__code type-code`,"data-lang":e.lang||void 0,children:e.text})}}function RichText({text:e,code:t}){let n=c(()=>parseMarkdown(e),[e]);return l(a,{children:[n.blocks.map((e,n)=>l(BlockView,{block:e,code:t},n)),n.truncated&&l(`p`,{class:`assistant-rich__text type-help`,children:m(`app.assistant.truncated`)})]})}var gr=16,_r=120,vr=60;function unionOf(e){if(e.length===0)return{x:0,y:0,width:_r,height:vr};let t=Math.min(...e.map(e=>e.x))-gr,n=Math.min(...e.map(e=>e.y))-gr,r=Math.max(...e.map(e=>e.x+e.width))+gr,i=Math.max(...e.map(e=>e.y+e.height))+gr,a=Math.max(_r,r-t),o=Math.max(vr,i-n);return{x:t-(a-(r-t))/2,y:n-(o-(i-n))/2,width:a,height:o}}function boxOfPoints(e){let t=e.map(e=>e.x),n=e.map(e=>e.y);return{x:Math.min(...t),y:Math.min(...n),width:Math.max(...t)-Math.min(...t),height:Math.max(...n)-Math.min(...n)}}function buildMiniDiff(e,t){let n=new Map,r=new Map,i=new Map,a=new Set,o={added:0,removed:0,changed:0},shape=(e,t,i=e.bounds)=>{i&&(r.set(e.id,{id:e.id,type:e.type,bounds:i,mark:t,...e.name?{name:e.name}:{}}),n.set(e.id,t))},flow=(e,t)=>{e.waypoints&&e.waypoints.length>1&&i.set(e.id,{id:e.id,points:e.waypoints,mark:t,...e.source?{source:e.source}:{},...e.target?{target:e.target}:{}});for(let n of[e.source,e.target])n&&t!==`context`&&a.add(n)};for(let r of t)if(!r.error){for(let e of r.added)shape(e,`added`),o.added+=1;for(let e of r.addedFlows)flow(e,`added`);for(let e of r.removed)e.waypoints?flow(e,`removed`):(shape(e,`removed`),o.removed+=1,a.add(e.id));for(let t of r.moved){let n=e.nodes.find(e=>e.id===t.id);shape({id:t.id,type:n?.type??`bpmn:Task`,...n?.name?{name:n.name}:{}},`changed`,t.to),a.add(t.id),o.changed+=1}for(let t of r.changed){let r=e.nodes.find(e=>e.id===t.id),i=e.flows.find(e=>e.id===t.id);r&&!n.has(r.id)?(shape(r,`changed`),o.changed+=1):i&&(flow(i,`changed`),o.changed+=1),a.add(t.id)}}for(let t of e.flows)if(!i.has(t.id)&&(t.source&&a.has(t.source)||t.target&&a.has(t.target))){flow(t,`context`);for(let n of[t.source,t.target]){let t=e.nodes.find(e=>e.id===n);t&&!r.has(t.id)&&shape(t,`context`)}}for(let t of a){let n=e.nodes.find(e=>e.id===t);n&&!r.has(t)&&shape(n,`context`)}let s=[...r.values()].map(e=>e.bounds).concat([...i.values()].map(e=>boxOfPoints(e.points)));return{shapes:[...r.values()],flows:[...i.values()],viewBox:unionOf(s),counts:o}}function viewOf(e,t){return unionOf(e.map(e=>e.bounds).concat(t.map(e=>boxOfPoints(e.points))))}function narrowDiff(e){let t=new Set(e.shapes.filter(e=>e.mark!==`context`).map(e=>e.id));for(let n of e.flows)n.mark!==`context`&&(n.source&&t.add(n.source),n.target&&t.add(n.target));let n=e.shapes.filter(e=>t.has(e.id)),r=e.flows.filter(e=>e.mark!==`context`||e.source&&e.target&&t.has(e.source)&&t.has(e.target));return n.length===e.shapes.length&&r.length===e.flows.length?e:{...e,shapes:n,flows:r,viewBox:viewOf(n,r)}}var yr=`Arial, sans-serif`,br=11,xr=1.25,Sr=.58,Cr=200,wr=560,Tr=2,Er=.55,Dr=1.25,isEvent=e=>/Event$/.test(e),isGateway=e=>/Gateway$/.test(e),isOutside=e=>isEvent(e)||isGateway(e);function wrapLabel(e,t,n){let r=Math.max(4,t),i=[],a=``;for(let t of e.split(/\s+/).filter(Boolean)){let e=a?`${a} ${t}`:t;e.length<=r?a=e:(a&&i.push(a),a=t)}a&&i.push(a);let cut=e=>e.length>r?`${e.slice(0,r-1)}…`:e;if(i.length<=n)return i.map(cut);let o=i.slice(0,n);return o[n-1]=cut(`${o[n-1]} ${i.slice(n).join(` `)}`.slice(0,r*2)),o.map(cut)}function labelOf$1(e,t){let n=e.name??(isOutside(e.type)?``:Z(e.type));if(!n)return null;let r=isOutside(e.type),i=r?Math.max(e.bounds.width+48,96):e.bounds.width-8;return{lines:wrapLabel(n,Math.floor(i*t/(br*Sr)),r?Tr:Math.max(1,Math.min(3,Math.floor(e.bounds.height*t/(br*xr))-0))),outside:r}}e(labelOf$1,`labelOf`);function fitted(e,t){let n=layoutOf(e,t);if(n.scale>=Er)return{data:e,layout:n};let r=narrowDiff(e);return r===e?{data:e,layout:n}:{data:r,layout:layoutOf(r,t)}}function layoutOf(e,t){let n=e.viewBox,r=Math.min(Dr,t/n.width,Cr/n.height),i=n,a=new Map;for(let o=0;o<3;o+=1){let o=br/r;a=new Map;let s=n.x,c=n.x+n.width,l=n.y+n.height;for(let t of e.shapes){let e=labelOf$1(t,r);if(!e||(a.set(t.id,e),!e.outside))continue;let n=Math.max(...e.lines.map(e=>e.length))*o*Sr,i=t.bounds.x+t.bounds.width/2;s=Math.min(s,i-n/2-4),c=Math.max(c,i+n/2+4),l=Math.max(l,t.bounds.y+t.bounds.height+4+e.lines.length*o*xr+4)}i={x:s,y:n.y,width:c-s,height:l-n.y},r=Math.min(Dr,t/i.width,Cr/i.height)}return{view:i,scale:r,labels:a,size:br/r}}function Label({shape:e,label:t,size:n}){let{x:r,y:i,width:a,height:o}=e.bounds,s=n*xr,c=t.outside?i+o+4+n:i+o/2-(t.lines.length-1)*s/2+n*.35;return l(`text`,{class:`mini-diff__label`,x:r+a/2,y:c,"text-anchor":`middle`,"font-size":n,"font-family":yr,children:t.lines.length===1?t.lines[0]:t.lines.map((e,t)=>l(`tspan`,{x:r+a/2,dy:t===0?0:s,children:e},t))})}function Shape({shape:e}){let{x:t,y:n,width:r,height:i}=e.bounds,a=`mini-diff__shape mini-diff__shape--${e.mark}`,o=l(`title`,{children:e.name?`${Z(e.type)} · ${e.name}`:Z(e.type)});return isEvent(e.type)?l(`circle`,{class:a,cx:t+r/2,cy:n+i/2,r:r/2,children:o}):isGateway(e.type)?l(`polygon`,{class:a,points:`${t+r/2},${n} ${t+r},${n+i/2} ${t+r/2},${n+i} ${t},${n+i/2}`,children:o}):l(`rect`,{class:a,x:t,y:n,width:r,height:i,rx:10,children:o})}var Or=8;function head(e){let t=e.points[e.points.length-1],n=e.points[e.points.length-2],r=Math.hypot(t.x-n.x,t.y-n.y)||1,i=(t.x-n.x)/r,a=(t.y-n.y)/r,o={x:t.x-i*Or,y:t.y-a*Or};return`M${t.x},${t.y} L${o.x-a*Or*.4},${o.y+i*Or*.4} L${o.x+a*Or*.4},${o.y-i*Or*.4} z`}function Flow({flow:e}){let t=e.points.map((e,t)=>`${t===0?`M`:`L`}${e.x},${e.y}`).join(` `);return l(`g`,{class:`mini-diff__flow mini-diff__flow--${e.mark}`,children:[l(`path`,{class:`mini-diff__line`,d:t}),l(`path`,{class:`mini-diff__head`,d:head(e)})]})}function Strike({bounds:e}){return l(`path`,{class:`mini-diff__strike`,d:`M${e.x-3},${e.y+e.height+3} L${e.x+e.width+3},${e.y-3}`})}function summaryOf(e){return m(`app.aiBlocks.diffSummary`,e)}function MiniDiagramDiff({data:e,label:n,lazy:r=!0}){let i=o(null),[a,s]=t(!r||typeof IntersectionObserver>`u`);f(()=>{if(a||!i.current)return;let e=new IntersectionObserver(t=>{t.some(e=>e.isIntersecting)&&(s(!0),e.disconnect())});return e.observe(i.current),()=>e.disconnect()},[a]);let[c,u]=t(wr);f(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let measure=()=>{let t=getComputedStyle(e),n=e.clientWidth-parseFloat(t.paddingLeft||`0`)-parseFloat(t.paddingRight||`0`);n>0&&u(n)};measure();let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[]);let{data:d,layout:p}=fitted(e,c),{view:m}=p,h=summaryOf(e.counts);return l(`figure`,{class:`mini-diff`,ref:i,"aria-label":n??h,"data-lazy":a?void 0:`true`,children:[a?l(`svg`,{class:`mini-diff__svg`,viewBox:`${m.x} ${m.y} ${m.width} ${m.height}`,width:m.width*p.scale,height:m.height*p.scale,role:`img`,"aria-label":h,children:[d.flows.map(e=>l(Flow,{flow:e},e.id)),d.shapes.map(e=>l(Shape,{shape:e},e.id)),d.shapes.map(e=>{let t=p.labels.get(e.id);return t?l(Label,{shape:e,label:t,size:p.size},`label-${e.id}`):null}),d.shapes.filter(e=>e.mark===`removed`).map(e=>l(Strike,{bounds:e.bounds},`strike-${e.id}`))]}):l(`div`,{class:`mini-diff__placeholder`}),l(`figcaption`,{class:`mini-diff__caption type-help`,children:h})]})}var kr=1500,Ar=2e5;function split(e){return e===``?[]:e.replace(/\r\n/g,`
976
+ `).split(`
977
+ `)}function shortestEdit(e,t){let n=e.length,r=t.length,i=Math.min(n+r,kr),a=2*i+2,o=i+1,s=new Int32Array(a),c=[],l=-1;for(let a=0;a<=i&&l<0;a+=1){c.push(s.slice());let i=s;for(let s=-a;s<=a;s+=2){let c;c=s===-a||s!==a&&i[o+s-1]<i[o+s+1]?i[o+s+1]:i[o+s-1]+1;let u=c-s;for(;c<n&&u<r&&e[c]===t[u];)c+=1,u+=1;if(i[o+s]=c,c>=n&&u>=r){l=a;break}}s=i}if(l<0)return null;let u=[],d=n,f=r;for(let e=l;e>0;--e){let t=c[e],n=d-f,r=n===-e||n!==e&&t[o+n-1]<t[o+n+1],i=r?n+1:n-1,a=t[o+i],s=a-i;for(;d>a&&f>s;)u.push(`keep`),--d,--f;u.push(r?`add`:`drop`),d=a,f=s}for(;d>0&&f>0;)u.push(`keep`),--d,--f;return{script:u.reverse()}}function compareTexts(e,t){let n=split(e),r=split(t);if(n.length>Ar||r.length>Ar)return null;let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=n.slice(i,n.length-a),s=r.slice(i,r.length-a),c=o.length===0&&s.length===0?{script:[]}:shortestEdit(o,s);if(!c)return null;let l=[];for(let e=0;e<i;e+=1)l.push({kind:`same`,text:n[e],mineAt:e+1,theirsAt:e+1});let u=0,d=0;for(let e of c.script)e===`keep`?(l.push({kind:`same`,text:o[u],mineAt:i+u+1,theirsAt:i+d+1}),u+=1,d+=1):e===`drop`?(l.push({kind:`mine`,text:o[u],mineAt:i+u+1,theirsAt:null}),u+=1):(l.push({kind:`theirs`,text:s[d],mineAt:null,theirsAt:i+d+1}),d+=1);for(let e=0;e<a;e+=1){let t=n.length-a+e;l.push({kind:`same`,text:n[t],mineAt:t+1,theirsAt:r.length-a+e+1})}return{lines:l,mine:l.filter(e=>e.kind===`mine`).length,theirs:l.filter(e=>e.kind===`theirs`).length}}function hunksOf(e,t=3){let{lines:n}=e,r=new Uint8Array(n.length);n.forEach((e,i)=>{if(e.kind!==`same`)for(let e=Math.max(0,i-t);e<=Math.min(n.length-1,i+t);e+=1)r[e]=1});let i=[],a=null;return n.forEach((e,t)=>{r[t]?(a||(a=[],i.push({lines:a})),a.push(e)):a=null}),i}function rowOf(e){return e.kind===`mine`?{kind:`del`,text:e.text,at:e.mineAt??0}:e.kind===`theirs`?{kind:`add`,text:e.text,at:e.theirsAt??0}:{kind:`same`,text:e.text,at:e.theirsAt??e.mineAt??0}}function sourceDiff(e,t,n=3){let r=compareTexts(e??``,t);if(!r)return null;let{lines:i}=r,a=new Uint8Array(i.length);i.forEach((e,t)=>{if(e.kind!==`same`)for(let e=Math.max(0,t-n);e<=Math.min(i.length-1,t+n);e+=1)a[e]=1});let o=[],s=[],flush=()=>{s.length!==0&&(s.length===1?o.push(s[0]):o.push({kind:`fold`,from:s[0].kind===`fold`?0:s[0].at,lines:s}),s=[])};return i.forEach((e,t)=>{let n=rowOf(e);a[t]?(flush(),o.push(n)):s.push(n)}),flush(),{rows:o,added:r.theirs,removed:r.mine}}function visibleRows(e,t){let n=[];for(let r of e.rows)r.kind===`fold`&&t.has(r.from)?n.push(...r.lines):n.push(r);return n.slice(0,600)}function SourceView({before:e,after:n,label:r,large:i}){let a=c(()=>sourceDiff(e,n),[e,n]),[o,s]=t(new Set);if(!a)return l(`p`,{class:`assistant-source__big type-help`,children:m(`app.assistant.diffTooLarge`)});let u=visibleRows(a,o);return l(`div`,{class:`assistant-source${i?` is-large`:``}`,role:`region`,"aria-label":r,tabIndex:0,children:u.map((e,t)=>e.kind===`fold`?l(`button`,{type:`button`,class:`assistant-source__fold type-help`,onClick:()=>s(new Set([...o,e.from])),children:m(`app.assistant.view.folded`,{count:e.lines.length})},`fold-${e.from}-${t}`):l(`div`,{class:`assistant-source__row is-${e.kind}`,children:[l(`span`,{class:`assistant-source__at type-code`,"aria-hidden":`true`,children:e.at}),l(`span`,{class:`assistant-source__sign type-code`,"aria-hidden":`true`,children:e.kind===`add`?`+`:e.kind===`del`?`-`:` `}),l(`span`,{class:`assistant-source__text type-code`,children:e.text})]},`${e.kind}-${t}`))})}function DiffDialog({request:e,onClose:t}){return l(E,{title:e.title,subtitle:e.path,size:`large`,onClose:t,class:`assistant-diff-dialog`,footer:l(w,{actions:[{id:`close`,label:m(`app.common.close`),role:`primary`,onClick:t}]}),children:l(SourceView,{before:e.before,after:e.after,label:m(`app.assistant.view.sourceLabel`),large:!0})})}function initialMode(e){return e?`picture`:`source`}function requestOf(e){let t=Ue(e.path);return{title:m(`app.assistant.view.diffTitle`,{name:t}),path:e.path,before:e.oldText,after:e.newText}}function viewer(){try{let e=Q();return e.openDiff&&z(e,`diffViewer`)?t=>e.openDiff(t):null}catch{return null}}async function openDiff(e){let t=viewer();if(!t)return!1;try{return await t(e),!0}catch{return!1}}function ChangePanel({diff:e,mini:n,initial:r}){let[i,a]=t(r===void 0?initialMode(n):r),[o,s]=t(null),c=Ue(e.path),choose=e=>a(t=>t===e&&r===null?null:e),show=async()=>{let t=requestOf(e);await openDiff(t)||s(t)};return l(`div`,{class:`assistant-change`,children:[l(`div`,{class:`assistant-change__bar`,children:[l(`div`,{class:`assistant-switch-view`,role:`group`,"aria-label":m(`app.assistant.view.label`),children:[n&&l(`button`,{type:`button`,class:`assistant-switch-view__choice type-help`,"aria-pressed":i===`picture`,onClick:()=>choose(`picture`),children:m(`app.assistant.view.picture`)}),l(`button`,{type:`button`,class:`assistant-switch-view__choice type-help`,"aria-pressed":i===`source`,onClick:()=>choose(`source`),children:m(`app.assistant.view.source`)})]}),l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>void show(),children:m(`app.assistant.view.openDiff`)}),l(`span`,{class:`assistant-change__name type-help`,title:e.path,children:c})]}),i===`picture`&&n&&l(MiniDiagramDiff,{data:n,lazy:!1,label:m(`app.assistant.changeLabel`,{name:c})}),i===`source`&&l(SourceView,{before:e.oldText,after:e.newText,label:m(`app.assistant.view.sourceLabel`)}),o&&d(l(DiffDialog,{request:o,onClose:()=>s(null)}),document.body)]})}var jr=``,Mr=``;function compose(e,t){let n=Object.keys(t),r=e(Object.fromEntries(n.map((e,t)=>[e,`${jr}${t}${Mr}`]))),i=[],a=RegExp(`${jr}(\\d+)${Mr}`,`g`),o=0;for(let e of r.matchAll(a))e.index>o&&i.push(r.slice(o,e.index)),i.push(t[n[Number(e[1])]]),o=e.index+e[0].length;return o<r.length&&i.push(r.slice(o)),i}function plain(e){return e.map(e=>typeof e==`string`?e:e.kind===`file`?e.label??e.path.split(/[\\/]/).pop()??e.path:e.name??e.id).join(``)}function endName(e){if(!e)return null;if(e.name)return e.name;if(!e.type)return null;let t=Z(e.type);return t?t.charAt(0).toUpperCase()+t.slice(1):null}function flowName(e,t){let n=endName(e),r=endName(t);return n&&r?`${n} → ${r}`:void 0}var Nr=/\.bpmn(\.xml)?$/i,Pr=120;function isBpmnDiff(e){return Nr.test(e.path)}function fingerprint(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t=Math.imul(t^e.charCodeAt(n),16777619)>>>0;return`${e.length}:${t.toString(36)}`}function miniOf(e){let t={index:0,operation:{op:`remove`,id:``},summary:``,added:e.added,addedFlows:e.addedFlows,removed:e.removed,changed:e.changed,moved:e.moved,touched:[]};return buildMiniDiff(e.before,[t])}var Fr={element:`app.assistant.loose.element`,attach:`app.assistant.loose.attach`,scope:`app.assistant.loose.scope`,type:`app.assistant.loose.type`,reconnect:`app.assistant.loose.reconnect`,resize:`app.assistant.loose.resize`,property:`app.assistant.loose.property`,event:`app.assistant.loose.event`},Ir=3;function notesOf(e){let t=new Map;for(let n of e)t.set(n.kind,[...t.get(n.kind)??[],n]);return[...t].map(([e,t])=>{let n=[...new Set(t.map(e=>e.id))],r=n.slice(0,Ir).join(`, `);return m(Fr[e],{ids:n.length>Ir?`${r}, ...`:r,type:t[0].type?Z(t[0].type):``})})}var Lr=new Map;async function computeChange(e){if(e.newText.length>2e6||(e.oldText?.length??0)>2e6)return null;try{let{diffDiagrams:t}=await K(async()=>{let{diffDiagrams:e}=await import(`./diff-BhYqTg4l.js`);return{diffDiagrams:e}},__vite__mapDeps([89,1,17,55,6,7,19,20,21,11]),import.meta.url),n=await t(e.oldText,e.newText);return n?{path:e.path,diff:n,mini:miniOf(n),notes:notesOf(n.loose),readable:n.operations.length>0}:null}catch(e){return console.error(`The change to a diagram could not be read:`,e),null}}function changeOf(e){let t=`${e.path}\u0000${fingerprint(e.oldText??``)}\u0000${fingerprint(e.newText)}`,n=Lr.get(t);if(n)return Lr.delete(t),Lr.set(t,n),n;let r=computeChange(e);return Lr.set(t,r),Lr.size>Pr&&Lr.delete(Lr.keys().next().value),r}var PictureBudget=class{spent=!1;take(){return!this.spent&&(this.spent=!0,!0)}},PictureBudgets=class{answers=new Map;of(e){let t=this.answers.get(e);if(t)return t;let n=new PictureBudget;return this.answers.set(e,n),n}},Rr=8;function capital(e){return e.charAt(0).toUpperCase()+e.slice(1)}function chipOf(e,t,n,r=[]){let i=t?.name||(t?.source&&t.target?flowName(r.find(e=>e.id===t.source),r.find(e=>e.id===t.target)):void 0);return{kind:`element`,path:e,id:n,...t?{type:t.type}:{},...i?{name:i}:{}}}function lineOf(e,t){return{mark:e,parts:t,text:plain(t)}}function nodeLine(e,t,n){return lineOf(e,[`${capital(Z(n.type))} `,chipOf(t,n,n.id)])}function flowLine(e,t,n,r){let i=r.find(e=>e.id===n.source),a=r.find(e=>e.id===n.target),o={};return n.source&&(o.from=chipOf(t,i,n.source)),n.target&&(o.to=chipOf(t,a,n.target)),lineOf(e,compose(e=>m(`app.assistant.change.flow`,{from:e.from??``,to:e.to??``}),o))}async function diagramLines(e){let t=await changeOf(e);if(!t)return null;let{diff:n}=t,r=[...n.after.nodes,...n.before.nodes],i=[],a=[],o=e.path;for(let e of n.added)i.push(nodeLine(`+`,o,e)),a.push(chipOf(o,e,e.id));for(let e of n.addedFlows)i.push(flowLine(`+`,o,e,r)),a.push(chipOf(o,e,e.id,r));for(let e of n.removed)i.push(e.type.toLowerCase().includes(`flow`)?flowLine(`-`,o,e,r):nodeLine(`-`,o,e));for(let e of n.changed){let t=chipOf(o,r.find(t=>t.id===e.id),e.id,r);a.push(t),i.push(lineOf(`~`,e.keys.length>0?compose(t=>m(`app.assistant.change.changed`,{name:t.name,what:e.keys.join(`, `)}),{name:t}):[t]))}for(let e of n.moved){let t=chipOf(o,r.find(t=>t.id===e.id),e.id,r);a.push(t),i.push(lineOf(`~`,compose(e=>m(`app.assistant.change.moved`,{name:e.name}),{name:t})))}return{lines:i,mini:t.mini.shapes.length+t.mini.flows.length>0&&t.mini.counts.added+t.mini.counts.removed+t.mini.counts.changed>0?t.mini:null,elements:a}}function textLine(e){let t=compareTexts(e.oldText??``,e.newText),n={kind:`file`,path:e.path};return e.oldText===null?lineOf(`+`,compose(e=>m(`app.assistant.change.created`,{name:e.name}),{name:n})):t?lineOf(`~`,compose(e=>m(`app.assistant.change.lines`,{name:e.name,added:t.theirs,removed:t.mine}),{name:n})):lineOf(`~`,compose(e=>m(`app.assistant.change.file`,{name:e.name}),{name:n}))}async function summarise(e){return summariseDiffs(e.tool.diffs)}async function summariseDiffs(e,t=new PictureBudget){let n=[],r=new Set,i=[];for(let a of e){r.add(Ue(a.path));let e=isBpmnDiff(a)?await diagramLines(a).catch(()=>null):null;e&&e.lines.length>0?n.push(...e.lines):n.push(textLine(a));let o=e?.mini??null,s=o&&t.take()?o:null;i.push({diff:a,mini:s,drawable:o!==null,elements:e?.elements??[]})}let a=n.length;return{lines:n.slice(0,Rr),files:[...r],count:a,diffs:i}}function questionOf(e,t){if(!t||t.count===0)return toolTitle(e.tool);let n=t.files.length===1?t.files[0]:m(`app.assistant.question.files`,{count:t.files.length});return m(`app.assistant.question.apply`,{count:t.count,file:n})}function Mark({status:e}){return e===`running`?l(`span`,{class:`assistant-mark is-running`,children:l(k,{})}):e===`done`?l(`span`,{class:`assistant-mark is-done`,children:l(D,{name:`check`})}):e===`failed`||e===`stopped`?l(`span`,{class:`assistant-mark is-failed`,children:l(D,{name:`failed`})}):l(`span`,{class:`assistant-mark is-pending`,children:l(D,{name:`pending`})})}function ChipView({chip:e}){let t=useLinks();return e.kind===`file`?l(FileReference,{reference:{path:e.path,id:null,line:null},raw:e.label??Ue(e.path)}):e.type?l(ElementChip,{id:e.id,type:e.type,name:e.name,onSelect:n=>{t.openElement(e.path,n),t.flash?.(e.path,[n])},onHover:(n,r)=>t.highlight?.(e.path,n,r)}):l(ElementReference,{reference:{path:e.path,id:e.id,line:null}})}function PartsView({parts:e}){return l(a,{children:e.map((e,t)=>typeof e==`string`?l(`span`,{children:e},t):l(ChipView,{chip:e},t))})}function ChipRow({chips:e,max:t}){if(e.length===0)return null;let n=e.slice(0,t),r=e.length-n.length;return l(`span`,{class:`assistant-chips`,children:[n.map((e,t)=>l(ChipView,{chip:e},t)),r>0&&l(`span`,{class:`assistant-chips__more type-help`,children:m(`app.assistant.sentence.more`,{count:r})})]})}var zr=18e5,Br=100,Vr=new Map,Hr=new Set,Ur=new Map,Wr=null;function changed$1(){for(let e of[...Hr])e()}e(changed$1,`changed`);function armVerifier(e,t,n=Date.now){Wr={verifier:e,chat:t,until:n()+zr}}function disarmVerifier(){Wr=null}function verifierFor(e,t,n=Date.now){return!Wr||Wr.chat!==t||n()>Wr.until||!Ve(Wr.verifier.file,e)?null:Wr.verifier}function reportFix(e,t){Vr.delete(e),Vr.set(e,t),Vr.size>Br&&Vr.delete(Vr.keys().next().value),changed$1()}function forgetFix(e){Ur.delete(e),Vr.delete(e)&&changed$1()}function verifyProposal(e,t,n,r,i=[]){let a=verifierFor(t,r);a&&(disarmVerifier(),i.length>0?(Ur.set(e,{verifier:a,xml:n}),reportFix(e,{state:`needsClick`,element:a.element,executable:i})):start$1(e,a,n,`auto`))}function pendingProposalOf(e,t){if(t&&Ur.has(t))return t;if(!e)return null;let n=`permission:${e}:`;for(let e of Ur.keys())if(e.startsWith(n))return e;return null}function checkPending(e){let t=Ur.get(e);t&&(Ur.delete(e),start$1(e,t.verifier,t.xml,`manual`))}function start$1(e,t,n,r){reportFix(e,{state:`running`,element:t.element}),t.run(n,r).then(t=>{Vr.has(e)&&reportFix(e,t)},n=>{Vr.has(e)&&reportFix(e,{state:`unavailable`,element:t.element,reason:n instanceof Error?n.message:String(n)})})}e(start$1,`start`);function fixOfPermission(e){let t=`permission:${e}:`;for(let[e,n]of Vr)if(e.startsWith(t))return n;return null}function useFixVerdict(e,n=null){let[,r]=t(0);return f(()=>{let listener=()=>r(e=>e+1);return Hr.add(listener),()=>{Hr.delete(listener)}},[]),n&&Vr.has(n)?Vr.get(n)??null:e?fixOfPermission(e):null}function executableText(e){return e.map(e=>m(`app.incident.fix.executable.${e.kind}`,{element:e.element||m(`app.incident.fix.executable.unknownElement`)})).join(`, `)}function FixVerdict({permission:e,proposal:t}){let n=useFixVerdict(e??null,t??null);if(!n)return null;if(n.state===`needsClick`){let r=pendingProposalOf(e??null,t??null);return l(`p`,{class:`fix-verdict fix-verdict--needsClick type-help`,role:`status`,"data-testid":`fix-verdict`,children:[l(`span`,{children:m(`app.incident.fix.needsClick`,{what:executableText(n.executable)})}),r&&l(`button`,{type:`button`,class:`ui-button fix-verdict__check`,"data-testid":`fix-check`,onClick:()=>checkPending(r),children:m(`app.incident.fix.check`)})]})}let r=n.state===`running`?m(`app.incident.fix.running`,{element:n.element}):n.state===`passes`?m(`app.incident.fix.passes`,{element:n.element}):n.state===`fails`?n.reason?m(`app.incident.fix.failsWhy`,{element:n.element,reason:n.reason}):m(`app.incident.fix.fails`,{element:n.element}):m(`app.incident.fix.unavailable`,{reason:n.reason});return l(`p`,{class:`fix-verdict fix-verdict--${n.state} type-help`,role:`status`,"data-testid":`fix-verdict`,children:r})}var Gr=new Map,Kr=new Set,qr=100;function reportCheck(e,t){Gr.delete(e),Gr.set(e,t),Gr.size>qr&&Gr.delete(Gr.keys().next().value);for(let e of[...Kr])e()}function forgetCheck(e){if(Gr.delete(e))for(let e of[...Kr])e()}function checkOf(e){let t=`permission:${e}:`,n=null;for(let[e,r]of Gr)e.startsWith(t)&&(n=n?{errors:n.errors+r.errors,warnings:n.warnings+r.warnings,resolved:n.resolved+r.resolved}:r);return n}function useProposalCheck(e){let[,n]=t(0);return f(()=>{let listener=()=>n(e=>e+1);return Kr.add(listener),()=>{Kr.delete(listener)}},[]),e?checkOf(e):null}function proposalId(e,t){return`permission:${e.id}:${t}`}function answerOptions(e){let t=e.tool.diffs.length>0,pick=(n,r)=>e.options.find(e=>e.kind===n)??(t?null:e.options.find(e=>e.kind===r)??null);return{allow:pick(`allow`,`allowAlways`),reject:pick(`reject`,`rejectAlways`)}}async function executableOf(e,t){try{return await Ye(e,t)}catch{return[{kind:`other`,element:``}]}}function connectReviews(e){let t=new Map,n=!1,withdraw=t=>{for(let n of t.ids)e.canvas.channel.withdraw(n),forgetCheck(n),forgetFix(n)},offer=async(r,i,a)=>{let o=e.file();if(!o)return;let{allow:s,reject:c}=answerOptions(i);if(s&&c)for(let l of i.tool.diffs){if(!isBpmnDiff(l)||!Ve(l.path,o))continue;let u=await changeOf(l);if(n||t.get(r)!==a)return;if(!u||u.diff.operations.length===0)continue;let d=proposalId(i,l.path),f={id:d,patch:{operations:u.diff.operations,title:toolTitle(i.tool)},source:`agent`,title:toolTitle(i.tool),createdAt:Date.now(),notes:u.notes,after:u.diff.after,checked:e=>reportCheck(d,e),whole:{accept:()=>void e.store.answer(r,i.id,s.id),reject:()=>void e.store.answer(r,i.id,c.id)}};a.ids.push(d),e.canvas.channel.offer(f);let p=verifierFor(o,r)?await executableOf(l.oldText??``,l.newText):[];if(n||t.get(r)!==a)return;verifyProposal(d,o,l.newText,r,p)}},sync=()=>{if(n)return;let r=e.store.snapshot().transcripts;for(let[e,n]of[...t])r[e]?.permission?.id!==n.key&&(t.delete(e),withdraw(n));for(let[e,n]of Object.entries(r)){let r=n.permission;if(!r||t.get(e)?.key===r.id)continue;let i={key:r.id,ids:[]};t.set(e,i),offer(e,r,i).catch(e=>console.error(`The change could not be shown on the canvas:`,e))}},r=e.store.subscribe(sync);return sync(),()=>{n=!0,r();for(let e of t.values())withdraw(e);t.clear()}}var Jr={allow:`app.assistant.question.allow`,reject:`app.assistant.question.deny`,allowAlways:`app.assistant.question.allowAlways`,rejectAlways:`app.assistant.question.denyAlways`};function labelOf(e){return Jr[e.kind]?m(Jr[e.kind]):e.label}function useSummary(e){let[n,r]=t(null);return f(()=>{let t=!0;return r(null),summarise(e).then(e=>t&&r(e)).catch(()=>t&&r({lines:[],files:[],count:0,diffs:[]})),()=>{t=!1}},[e.id]),n}function Question({store:e,chatId:t,permission:n,focus:r=!0,onShow:i}){let a=useLinks(),s=useSummary(n),c=useProposalCheck(n.id),u=o(null),d=n.tool.diffs.length>0,{allow:p,reject:h}=answerOptions(n),g=d?[]:n.options.filter(e=>e!==p&&e!==h),_=n.tool.diffs.find(e=>/\.bpmn(\.xml)?$/i.test(e.path))??null;f(()=>{r&&u.current?.focus()},[n.id,r]);let answer=r=>void e.answer(t,n.id,r);return l(`div`,{class:`assistant-question`,role:`group`,"aria-label":m(`app.assistant.question.label`),children:[l(`p`,{class:`assistant-question__title`,children:[l(D,{name:`hand`,class:`assistant-question__mark`}),l(`span`,{children:questionOf(n,s)})]}),s&&s.lines.length>0&&l(`ul`,{class:`assistant-question__changes type-code`,children:s.lines.map((e,t)=>l(`li`,{class:`assistant-question__change is-${e.mark===`+`?`added`:e.mark===`-`?`removed`:`changed`}`,children:[l(`span`,{class:`assistant-question__mark-line`,"aria-hidden":`true`,children:e.mark}),l(`span`,{class:`assistant-question__text`,children:l(PartsView,{parts:e.parts})})]},t))}),c&&l(`p`,{class:`assistant-question__check${c.errors>0?` is-error`:c.warnings>0?` is-warning`:``}`,children:[l(D,{name:c.errors>0||c.warnings>0?`alert`:`check`}),l(`span`,{children:c.errors+c.warnings===0?m(`app.assistant.question.clean`):m(`app.assistant.question.problems`,{count:c.errors+c.warnings})})]}),l(FixVerdict,{permission:n.id}),s&&s.diffs.map(e=>l(ChangePanel,{diff:e.diff,mini:e.mini},e.diff.path)),l(`div`,{class:`assistant-question__actions`,children:[h&&l(`button`,{ref:u,type:`button`,class:`assistant-button assistant-button--secondary`,onClick:()=>answer(h.id),onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()},children:labelOf(h)}),p&&l(`button`,{type:`button`,class:`assistant-button assistant-button--primary`,onClick:()=>answer(p.id),children:labelOf(p)}),g.map(e=>l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:()=>answer(e.id),children:labelOf(e)},e.id)),_&&l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>i?.(_.path)?void 0:a.openFile(_.path),children:m(`app.assistant.question.showOnCanvas`)}),d&&l(`span`,{class:`assistant-question__note type-help`,children:m(`app.assistant.question.undo`)})]})]})}var Yr=8388608;function newProblemsOf(e){return e.checks.freshCount.errors+e.checks.freshCount.warnings+e.connections.introduced.length}var Xr={verified:`app.receipt.verdict.verified`,findings:`app.receipt.verdict.findings`,"not-verified":`app.receipt.verdict.notVerified`},Zr={"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 verdictWord(e){return m(Xr[e])}function reasonWords(e){return m(Zr[e],{files:200,megabytes:Yr/1048576})}function outcomeWord(e){return m(`app.receipt.outcome.${e}`)}function scenarioWords(e,t,n){return n?t>0?m(`app.receipt.scenariosSomeFailed`,{count:e+t,failed:t}):m(`app.receipt.scenariosPassed`,{count:e}):m(`app.receipt.scenariosNotRun`)}function summaryLine(e){let t=`preview`in e,n=t?e.newProblems:newProblemsOf(e),r=t?e.scenarios:{passed:e.scenarios.passed,failed:e.scenarios.failed,ran:e.scenarios.status===`ran`};return m(`app.receipt.summary`,{verdict:verdictWord(e.verdict.status),problems:m(`app.receipt.newProblems`,{count:n}),scenarios:scenarioWords(r.passed,r.failed,r.ran)})}function diffWords(e){if(e.formattingOnly)return m(`app.receipt.formattingOnly`);if(!e.diff)return``;let{added:t,removed:n,changed:r,moved:i}=e.diff,a=[m(`app.receipt.diffCounts`,{added:t,removed:n,changed:r})];return i>0&&a.push(m(`app.receipt.moved`,{count:i})),a.join(`, `)}function parsed(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t.startsWith(`[`)&&!t.startsWith(`{`))return e;try{return JSON.parse(t)}catch{return e}}function unwrap(e,t=0){if(t>4)return e;let n=parsed(e);if(Array.isArray(n)){let e=n.filter(e=>!!e&&typeof e==`object`&&e.type===`text`&&typeof e.text==`string`);return e.length>0&&e.length===n.length?unwrap(e.map(e=>e.text).join(`
978
+ `),t+1):n}if(n&&typeof n==`object`){let e=n;if(Array.isArray(e.content))return unwrap(e.content,t+1);if(typeof e.text==`string`&&Object.keys(e).length<=2)return unwrap(e.text,t+1);if(`result`in e&&Object.keys(e).length===1)return unwrap(e.result,t+1)}return n}function inputOf(e){let t=parsed(e.raw?.input);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}function listOf(e){if(e.raw?.output===void 0)return null;let t=unwrap(e.raw.output);return Array.isArray(t)?t:null}function deadEndsOnly(e){return e.every(e=>typeof e==`object`&&!!e&&e.kind===`DEAD-ELEMENT`)}function elementChips(e,t){let n=new Set,r=[];for(let i of e){let e=i&&typeof i==`object`?i:{},a=[...Array.isArray(e.elements)?e.elements:[],...typeof e.elementId==`string`?[e.elementId]:[]];for(let e of a)typeof e!=`string`||n.has(e)||(n.add(e),r.push({kind:`element`,path:t,id:e}))}return r}var key=e=>`app.assistant.sentence.${e}`;function worded(e){return plain(e)}function build(e,t){let{input:n,file:r,list:i,done:a}=t,o=r?{kind:`file`,path:r}:null,withFile=(e,t={})=>o?compose(n=>m(key(e),{...t,file:n.file}),{file:o}):[m(key(e),{...t,file:``}).trim()],say=(e,t={})=>[m(key(e),t)],found=(e,t=[])=>({parts:e,chips:t,failed:!1});switch(e){case`listDiagrams`:return found(a?i?say(`listed`,{count:i.length}):say(`listedPlain`):say(`listing`));case`showDiagram`:return found(withFile(a?`read`:`reading`));case`checkDiagram`:return a?i?found(i.length===0?withFile(`checkedClean`):withFile(`checked`,{count:i.length}),r?elementChips(i,r):[]):found(withFile(`checkedPlain`)):found(withFile(`checking`));case`analyzeFlow`:return a?i?found(i.length===0?say(`analysedClean`):say(deadEndsOnly(i)?`analysedDeadEnds`:`analysed`,{count:i.length}),r?elementChips(i,r):[]):found(withFile(`analysedPlain`)):found(withFile(`analysing`));case`listScenarios`:{if(!a)return found(withFile(`scenariosListing`));if(!i)return found(withFile(`scenariosPlain`));let e=i.filter(e=>!!e&&typeof e==`object`&&typeof e.passed==`boolean`);return i.length>0&&e.length===i.length?found(say(`scenariosRan`,{count:i.length,passed:e.filter(e=>e.passed).length})):found(say(`scenariosListed`,{count:i.length}))}case`checkCodeLinks`:return found(a?i?i.length===0?say(`codeClean`):say(`codeChecked`,{count:i.length}):say(`codePlain`):say(`codeChecking`));default:{let e=n.dryRun===!0;return found(withFile(a?e?`previewed`:`edited`:e?`previewing`:`editing`))}}}function sentenceOf(e){let t=ownToolName(e);if(!t)return null;let n={input:inputOf(e),file:null,list:listOf(e),done:e.status===`done`};if(n.file=typeof n.input.file==`string`?n.input.file:null,e.status===`failed`){let e=worded(build(t,{...n,list:null,done:!1}).parts);return{parts:[m(key(`unfinished`),{step:e})],chips:[],failed:!0}}return build(t,n)}var Qr=8;function markOf(e){return e===`verified`?`done`:e===`findings`?`failed`:`pending`}function elementChip(e,t){return{kind:`element`,path:e,id:t.id,type:t.type,...t.name?{name:t.name}:{}}}function findingChips(e){let t=new Set,n=[];for(let r of e)for(let e of r.elements){let i=`${r.file}\u0000${e}`;t.has(i)||(t.add(i),n.push({kind:`element`,path:r.file,id:e}))}return n}function summaryChips(e){let t=findingChips([...e.checks.fresh,...e.connections.introduced]);return t.length>0?t:e.files.filter(e=>e.change!==`removed`).map(e=>({kind:`file`,path:e.path}))}function changedElements(e){if(!e.diff)return[];let{addedElements:t,changedElements:n,removedElements:r}=e.diff;return[...t,...n,...r].slice(0,Qr).map(t=>elementChip(e.path,t))}function Row({mark:e,text:t,chips:n}){return l(`li`,{class:`assistant-row assistant-receipt__item`,children:[e!==null&&l(Mark,{status:e}),l(`span`,{class:`assistant-row__text`,children:t}),n&&n.length>0&&l(ChipRow,{chips:n,max:Qr})]})}function Details({receipt:e}){let{checks:t,scenarios:n}=e,problems=e=>e.errors+e.warnings;return l(`ul`,{class:`assistant-rows assistant-receipt__details`,children:[e.verdict.reasons.map(e=>l(Row,{mark:`failed`,text:reasonWords(e)},e)),e.files.map(e=>{let t=diffWords(e);return l(Row,{mark:null,text:`${e.path}: ${m(`app.receipt.change.${e.change}`)}${t===``?``:`, ${t}`}`,chips:changedElements(e)},e.path)}),t.ran&&l(Row,{mark:null,text:m(`app.receipt.checkLine`,{before:problems(t.before),after:problems(t.after),resolved:t.resolved})}),[...t.fresh,...e.connections.introduced].map((e,t)=>l(Row,{mark:e.severity===`error`?`failed`:`pending`,text:m(`app.receipt.freshLine`,{severity:m(`app.receipt.severity.${e.severity}`),rule:e.rule,file:e.file,where:``}),chips:findingChips([e])},`${e.rule}-${t}`)),t.rulesReason&&l(Row,{mark:`pending`,text:m(`app.receipt.rules.${t.rulesReason}`)}),e.executable.map((e,t)=>l(Row,{mark:`pending`,text:m(`app.receipt.executableLine`,{kind:m(`app.receipt.kind.${e.kind}`),element:e.element,file:e.file})},`${e.element}-${t}`)),n.results.map((e,t)=>l(Row,{mark:e.outcome===`passed`?`done`:e.outcome===`failed`?`failed`:`pending`,text:`${e.name}: ${outcomeWord(e.outcome)}${e.previous===null?``:` ${m(`app.receipt.wasBefore`,{outcome:outcomeWord(e.previous)})}`}`},`${e.diagram}-${e.name}-${t}`)),n.status===`skipped`&&n.reason&&l(Row,{mark:null,text:m(`app.receipt.scenariosSkipped`,{reason:m(`app.receipt.skip.${n.reason}`)})}),e.layout.applied&&l(Row,{mark:null,text:m(`app.receipt.layoutApplied`,{count:e.layout.moved})}),e.attempts.map(e=>l(Row,{mark:null,text:m(e.handedBack?`app.receipt.attemptHandedBack`:`app.receipt.attempt`,{n:e.n,count:e.newFindings})},e.n)),e.exhausted&&l(Row,{mark:`failed`,text:m(`app.receipt.exhausted`,{count:e.maxAttempts})})]})}function ReceiptView({receipt:e,surface:t}){let n=e.verdict.status;return l(`div`,{class:`assistant-receipt is-${n}`,role:`group`,"aria-label":m(`app.receipt.title`),children:[l(`p`,{class:`assistant-receipt__row type-body`,children:[l(Mark,{status:markOf(n)}),l(`span`,{class:`assistant-receipt__label`,children:summaryLine(e)}),t===`card`&&l(ChipRow,{chips:summaryChips(e),max:3})]}),t===`tab`&&l(Details,{receipt:e})]})}var $r={pending:`app.assistant.tool.pending`,running:`app.assistant.tool.running`,done:`app.assistant.tool.done`,failed:`app.assistant.tool.failed`,stopped:`app.assistant.tool.stopped`};function linesOf(e){return e.split(`
979
+ `).length}function FoldedCode({text:e,lang:n}){let[r,i]=t(!1);return l(`details`,{class:`assistant-code`,onToggle:e=>i(e.currentTarget.open),children:[l(`summary`,{class:`assistant-code__summary type-help`,children:`${m(`app.assistant.view.showSource`)} · ${linesOf(e)}`}),r&&l(`pre`,{class:`assistant-rich__code type-code`,"data-lang":n||void 0,children:e})]})}function AnswerText({text:e}){return l(RichText,{text:fenceDocument(e),code:e=>l(FoldedCode,{text:e.text,lang:e.lang})})}function ToolStep({tool:e,surface:t}){let n=sentenceOf(e),r=e.status;return l(`li`,{class:`assistant-row is-${r}`,children:[l(Mark,{status:r}),l(`span`,{class:`assistant-row__text`,title:n?plain(n.parts):toolTitle(e),children:n?l(PartsView,{parts:n.parts}):toolTitle(e)}),n&&n.chips.length>0&&l(ChipRow,{chips:n.chips,max:3}),t===`tab`&&l(`span`,{class:`assistant-row__state type-help`,children:m($r[r])})]})}function StepRow({step:e,surface:t}){switch(e.kind){case`tool`:return t===`card`&&isBookkeeping(e.tool)?null:l(ToolStep,{tool:e.tool,surface:t});case`plan`:return l(a,{children:e.items.map((t,n)=>l(`li`,{class:`assistant-row is-${t.status}`,children:[l(Mark,{status:t.status}),l(`span`,{class:`assistant-row__text`,children:t.text})]},`${e.id}-${n}`))});case`thought`:return t===`card`?null:l(`li`,{class:`assistant-row is-thought`,children:l(`span`,{class:`assistant-row__text type-help`,children:e.text})})}}function currentStep(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.kind===`tool`&&!isBookkeeping(n.tool)){let e=sentenceOf(n.tool);if(e)return plain(e.parts);break}}return stepOf(e)}function WorkRow({steps:e,running:t,surface:n}){let r=countSteps(e,n===`tab`);if(r===0&&!t)return null;let i=e.some(e=>e.kind===`tool`&&e.tool.status===`failed`);return l(`details`,{class:`assistant-work`,open:n===`tab`||void 0,children:[l(`summary`,{class:`assistant-work__summary`,"aria-label":m(`app.assistant.work.label`),children:[l(Mark,{status:t?`running`:i?`failed`:`done`}),l(`span`,{class:`assistant-work__label type-body`,children:t?currentStep(e):m(`app.assistant.work.steps`,{count:r})}),l(D,{name:`chevronDown`,class:`assistant-work__chevron`})]}),l(`ul`,{class:`assistant-rows`,children:e.map(e=>l(StepRow,{step:e,surface:n},e.id))})]})}function distinctElements(e){let t=new Set;return e.filter(e=>{let n=JSON.stringify(e.kind===`element`?[e.path,e.id]:[e.path]);return!t.has(n)&&(t.add(n),!0)})}function AppliedRow({entry:e,pictures:n}){let[r,i]=t(null);f(()=>{let t=!0;return summariseDiffs(e.tool.diffs,n).then(e=>t&&i(e)).catch(()=>t&&i({lines:[],files:[],count:0,diffs:[]})),()=>{t=!1}},[e.id]);let a=distinctElements(r?r.diffs.flatMap(e=>e.elements):[]),o=e.tool.diffs[0];return l(`div`,{class:`assistant-applied`,children:[l(`p`,{class:`assistant-applied__row type-body`,children:[l(Mark,{status:`done`}),l(`span`,{class:`assistant-applied__label`,children:a.length>0?m(`app.assistant.view.applied`,{count:a.length}):l(PartsView,{parts:r?.lines[0]?.parts??[m(`app.assistant.view.appliedFile`,{file:o.path.split(/[\\/]/).pop()??o.path})]})}),a.length>0&&l(ChipRow,{chips:a,max:3})]}),r&&r.diffs.map(e=>l(ChangePanel,{diff:e.diff,mini:e.mini,initial:e.drawable?null:`source`},e.diff.path))]})}function TranscriptView({store:e,chatId:t,entries:n,permission:r,running:i,surface:a,onShow:s,focus:c}){let u=blocksOf(n),d=u[u.length-1],f=i&&!r,p=o(new PictureBudgets).current,h=``;return l(`div`,{class:`assistant-transcript is-${a}`,children:[u.map(e=>{switch(e.kind){case`work`:return l(WorkRow,{steps:e.steps,running:f&&e===d,surface:a},e.id);case`applied`:return l(AppliedRow,{entry:e.entry,pictures:p.of(h)},e.id);case`entry`:{let t=e.entry;return t.kind===`user`?(h=e.id,l(`div`,{class:`assistant-entry is-user`,children:l(RichText,{text:t.text})},e.id)):t.kind===`agent`?l(`div`,{class:`assistant-entry is-agent`,children:l(AnswerText,{text:t.text})},e.id):t.kind===`receipt`?l(`div`,{class:`assistant-entry is-receipt`,children:l(ReceiptView,{receipt:t.receipt,surface:a})},e.id):l(`p`,{class:`assistant-entry is-notice type-help`,children:t.text},e.id)}}}),f&&(!d||d.kind!==`work`)&&l(`p`,{class:`assistant-transcript__working type-help`,children:[l(k,{}),` `,m(`app.assistant.working`)]}),r&&l(Question,{store:e,chatId:t,permission:r,focus:c,onShow:s?e=>s(r,e):void 0})]})}var ei=24,ti=2;function useFollow(e,t){let n=o(null),r=o(!0),i=o(null),a=o(!1),s=o(0),anchor=()=>{let e=n.current,t=e?.querySelector(`.assistant-question`);e&&t&&(s.current=t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop,e.scrollTop=s.current)};return u(()=>{let t=n.current;t&&(e?(r.current=!1,i.current!==e&&(i.current=e,a.current=!0,anchor())):(i.current!==null&&(i.current=null,a.current=!1,r.current=!0),r.current&&(t.scrollTop=t.scrollHeight)))},[e,t]),u(()=>{let t=e?n.current?.querySelector(`.assistant-question`):null;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{a.current&&anchor()});return r.observe(t),()=>r.disconnect()},[e]),{ref:n,onScroll:t=>{let n=t.currentTarget;if(e){let e=Math.min(s.current,n.scrollHeight-n.clientHeight);Math.abs(n.scrollTop-e)>ti&&(a.current=!1)}else r.current=n.scrollHeight-n.scrollTop-n.clientHeight<ei}}}function agentName(e,t){return e.choices.find(e=>e.id===t.agentId)?.name??t.agentId}function Failure({store:e,state:n,chat:r,transcript:i,onChooseAgent:a,onAgentSettings:o}){let{unlock:s}=useLicence(),[c,u]=t(!1),d=classify(i?.error??null,n.choices,n.loaded),f=installCommand(n.choices,r.agentId),p=failureSummary(i?.error??null,r.detail??``),retry=()=>void e.tryAgain(r.id,()=>s(de.AI_CHAT)),h=d===`signedOut`&&i?.error?.signIn===!0,signIn=()=>{u(!0),e.signIn(r.id,()=>s(de.AI_CHAT)).finally(()=>u(!1))};return d===`noAgent`?l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:m(`app.assistant.noAgent.text`)}),f&&l(j,{command:f}),l(`div`,{class:`assistant-empty__actions`,children:[a&&l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:a,children:m(`app.assistant.noAgent.choose`)}),o&&l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:o,children:m(`app.assistant.noAgent.settings`)})]})]}):l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:p.text||m(d===`signedOut`?`app.assistant.signedOut.text`:`app.assistant.ended.text`)}),p.details&&l(FailureDetails,{text:p.details}),l(`div`,{class:`assistant-empty__actions`,children:[h&&l(`button`,{type:`button`,class:`assistant-button assistant-button--primary`,disabled:c,onClick:signIn,children:m(`app.assistant.signIn`)}),l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:retry,children:m(`app.assistant.tryAgain`)})]})]})}function AssistantCard({store:e,state:t,editor:n,chat:r,transcript:i,peeking:a,onChooseAgent:o,onAgentSettings:s}){let c=r.state===`failed`,u=c?classify(i?.error??null,t.choices,t.loaded):null,d=i?.permission??null,f=r.state===`connecting`,p=r.state===`working`||r.state===`waiting`||f,h=i?.entries??[],g=expandReason(h),_=h[h.length-1],v=useFollow(d?.id??null,`${h.length}:${_&&`text`in _?_.text.length:0}:${r.state}`),y=u===`noAgent`?m(`app.assistant.noAgent.title`):u===`signedOut`?m(`app.assistant.signedOut.title`,{agent:agentName(t,r)}):u===`ended`?m(`app.assistant.ended.title`):r.title,showHere=(t,i)=>{if(!n.canvas?.channel.has(proposalId(t,i)))return!1;e.setFolded(r.id,!0);let a=n.canvas.channel;return requestAnimationFrame(()=>requestAnimationFrame(()=>a.fit())),!0};return l(`section`,{class:`assistant-card${d?` is-asking`:``}${c?` is-failed`:``}${a&&!d&&!c?` is-peeking`:``}`,"aria-label":m(`app.assistant.card.label`),"data-editor":n.key,children:[l(`header`,{class:`assistant-card__head`,children:[l(D,{name:c?`alert`:`chat`,class:`assistant-card__icon${c?` is-warning`:``}`}),l(`span`,{class:`assistant-card__title`,title:y,children:y}),!c&&l(`span`,{class:`assistant-card__agent type-help`,children:`· ${agentName(t,r)}`}),l(`span`,{class:`assistant-card__buttons`,children:[!c&&l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.newChat`),title:m(`app.assistant.card.newChat`),disabled:p||d!==null,onClick:()=>e.select(n.key,null),children:l(D,{name:`plus`})}),!c&&l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.expand`),title:m(`app.assistant.card.expand`),onClick:()=>e.reveal(n.key),children:l(D,{name:`expand`})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(c?`app.assistant.card.close`:`app.assistant.card.fold`),title:m(c?`app.assistant.card.close`:`app.assistant.card.fold`),onClick:()=>c?e.dismissCard(r.id):e.setFolded(r.id,!0),children:l(D,{name:c?`close`:`chevronDown`})})]})]}),!c&&g&&l(`p`,{class:`assistant-card__suggest type-help`,children:[l(`span`,{children:m(g===`long`?`app.assistant.card.suggestLong`:`app.assistant.card.suggestDocument`)}),l(`button`,{type:`button`,class:`assistant-link type-link`,onClick:()=>e.reveal(n.key),children:m(`app.assistant.card.suggest`)})]}),l(`div`,{class:`assistant-card__body`,ref:v.ref,onScroll:v.onScroll,children:[c&&l(Failure,{store:e,state:t,chat:r,transcript:i,onChooseAgent:o,onAgentSettings:s}),!c&&f&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(k,{}),` `,m(`app.assistant.card.connecting`)]}),!c&&!f&&i?.status===`loading`&&h.length===0&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(k,{}),` `,m(`app.assistant.card.loading`)]}),!c&&i&&l(TranscriptView,{store:e,chatId:r.id,entries:h,permission:d,running:p,surface:`card`,onShow:showHere})]})]})}var ni=[Bn,zn];function FailureNotice({failure:e,choices:t,onRetry:n,onSettings:r}){let i=failureSummary(e,``),a=ni.includes(e.key)?installCommand(t,null):null;return l(`div`,{class:`assistant-empty`,children:[l(`p`,{class:`assistant-empty__text`,children:i.text||m(`app.assistant.ended.text`)}),a&&l(j,{command:a}),i.details&&l(FailureDetails,{text:i.details}),l(`div`,{class:`assistant-empty__actions`,children:[l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:n,children:m(`app.assistant.tryAgain`)}),l(`button`,{type:`button`,class:`assistant-button assistant-button--secondary`,onClick:r,children:m(`app.assistant.noAgent.settings`)})]})]})}var ri=i(!0),ii=ri.Provider;function useEditorActive(){return r(ri)}var ai=i(null),oi=ai.Provider;function useEditorElement(e){let t=r(ai);return t?t.current?Ze(e,t.current):null:Ze(e)}var ReviewChannel=class{listeners=new Set;withdrawals=new Set;pending=new Map;counter=0;covering=null;coverListeners=new Set;fitListeners=new Set;subscribe(e){this.listeners.add(e);for(let t of[...this.pending.values()])e(t);return()=>{this.listeners.delete(e)}}onWithdraw(e){return this.withdrawals.add(e),()=>{this.withdrawals.delete(e)}}propose(e){let t=Object.hasOwn(e,`patch`)?e:{patch:e};this.counter+=1;let n={id:`channel-${this.counter}`,patch:t.patch,source:t.source??`channel`,createdAt:Date.now(),...t.title?{title:t.title}:{}};return this.offer(n),n}offer(e){this.pending.set(e.id,e);for(let t of[...this.listeners])t(e);this.coverChanged()}withdraw(e){if(this.pending.delete(e)){for(let t of[...this.withdrawals])t(e);this.coverChanged()}}setCover(e){e===this.covering||e!==null&&this.covering!==null&&e.left===this.covering.left&&e.bottom===this.covering.bottom&&(e.right??0)===(this.covering.right??0)||(this.covering=e,this.coverChanged())}cover=()=>this.pending.size>0?this.covering:null;onCover=e=>(this.coverListeners.add(e),()=>{this.coverListeners.delete(e)});fit(){for(let e of[...this.fitListeners])e()}onFit=e=>(this.fitListeners.add(e),()=>{this.fitListeners.delete(e)});coverChanged(){for(let e of[...this.coverListeners])e()}proposedFacts(e){for(let t of this.pending.values()){let n=t.after?.nodes??[],r=[...n,...t.after?.flows??[]].find(t=>t.id===e);if(!r)continue;let i=r.name||(r.source&&r.target?flowName(n.find(e=>e.id===r.source),n.find(e=>e.id===r.target)):void 0);return{type:r.type,...i?{name:i}:{}}}return null}has(e){return this.pending.has(e)}get size(){return this.pending.size}};function motionMs(e){let t=parseFloat(getComputedStyle(document.documentElement).getPropertyValue(e));return Number.isFinite(t)?t:0}function reducedMotion(){return typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}var si=`penstock-chip-hover`,ci=`penstock-chip-flash`,li=new Set([`bpmn:Process`,`bpmn:Collaboration`]);function endOf(e){return e?{name:e.name,type:e.$type}:null}function factsOf(e){let t=e?.businessObject;if(!e||!t||e.type===`label`||!t.$type||li.has(t.$type))return null;let n=t.name?String(t.name):t.$type===`bpmn:SequenceFlow`?flowName(endOf(t.sourceRef),endOf(t.targetRef)):void 0;return{id:e.id,type:t.$type,...n?{name:n}:{}}}var EditorCanvas=class{channel=new ReviewChannel;feed=this.channel;picked=[];flashing=new Map;modeler=null;listeners=new Set;commenter;constructor(e=()=>void 0){this.commenter=e}onComment=(e,t)=>{this.commenter(e,t)};read=()=>this.picked;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});changed(){for(let e of[...this.listeners])e()}follow=()=>{let e=(this.modeler?.get(`selection`,!1)?.get?.()??[]).map(factsOf).filter(e=>e!==null);e.length===this.picked.length&&e.every((e,t)=>e.id===this.picked[t].id&&e.name===this.picked[t].name&&e.type===this.picked[t].type)||(this.picked=e,this.changed())};attach=e=>{this.detach(),this.modeler=e,(e?.get?.(`eventBus`,!1))?.on([`selection.changed`,`element.changed`,`import.done`],this.follow),this.follow()};detach=()=>{(this.modeler?.get?.(`eventBus`,!1))?.off([`selection.changed`,`element.changed`,`import.done`],this.follow),this.modeler=null,this.picked.length>0&&(this.picked=[],this.changed())};describe(e){let t=factsOf(this.modeler?.get?.(`elementRegistry`,!1)?.get(e));if(t)return t;let n=this.channel.proposedFacts(e);return n?{id:e,...n}:null}elements=()=>{let e=this.modeler?.get?.(`elementRegistry`,!1);return e?(e.getAll?.()??[]).filter(e=>!e.waypoints).map(factsOf).filter(e=>e!==null):[]};mark(e,t){let n=this.modeler?.get?.(`elementRegistry`,!1),r=this.modeler?.get?.(`canvas`,!1);r&&n?.get(e)&&(t?r.addMarker(e,si):r.removeMarker(e,si))}flash(e){let t=this.modeler?.get?.(`elementRegistry`,!1),n=this.modeler?.get?.(`canvas`,!1);if(n&&t)for(let r of e)t.get(r)&&(n.addMarker(r,ci),clearTimeout(this.flashing.get(r)),this.flashing.set(r,setTimeout(()=>{this.flashing.delete(r),n.removeMarker(r,ci)},motionMs(`--motion-flash`))))}select(e){let t=(this.modeler?.get?.(`elementRegistry`,!1))?.get(e);return t?(this.modeler.get(`selection`,!1)?.select(t),!0):!1}},CanvasRegistry=class{entries=new Map;set(e,t){return this.entries.set(e,t),()=>{this.entries.get(e)===t&&this.entries.delete(e)}}get(e){return this.entries.get(e)}find(e){let t=this.entries.get(e);if(t)return t;let n=e.replace(/\\/g,`/`);for(let[e,t]of this.entries){let r=e.replace(/\\/g,`/`);if(r===n||r.endsWith(`/${n}`)||n.endsWith(`/${r}`))return t}}},ui=new CanvasRegistry,di=new Map,fi=new Map,pi=new Set;function changed(){for(let e of[...pi])e()}function installScenarioOpener(e,t){return fi.set(e,t),()=>{fi.get(e)===t&&fi.delete(e)}}function requestScenario(e,t){di.set(e,t),changed(),fi.get(e)?.()}function takeScenarioRequest(e){let t=di.get(e)??null;return t!==null&&(di.delete(e),changed()),t}function useScenarioRequest(e){let[,n]=t(0);return f(()=>{let again=()=>n(e=>e+1);return pi.add(again),()=>{pi.delete(again)}},[]),e===null?null:di.get(e)??null}var mi=/\.(java|kt|kts|groovy|scala|py|js|mjs|cjs|ts|go|cs)$/,hi=[[/\.bpmn(\.xml)?$/i,`bpmn`],[/\.dmn$/i,`dmn`],[/\.form$/i,`form`]],gi=hi[0][0],_i=250,vi=1e3,yi=/^([A-Za-z]:)?[\\/]/;async function parse(e){let{inspectModel:t}=await K(async()=>{let{inspectModel:e}=await import(`./apply-Nsj6ek02.js`).then(e=>e.n);return{inspectModel:e}},__vite__mapDeps([55,1,17,6,7,19,20,21,11]),import.meta.url),n=await t(e,it(e)??`classic`),r=new Map;if(!n)return r;for(let e of n.elements)r.set(e.id,{type:e.type.includes(`:`)?e.type:`bpmn:${e.type}`,...e.name?{name:e.name}:{}});for(let e of n.flows){let t=r.get(e.id);if(!t||t.name)continue;let i=flowName(n.nodes.find(t=>t.id===e.source),n.nodes.find(t=>t.id===e.target));i&&r.set(e.id,{...t,name:i})}return r}function kindOf(e){return hi.find(([t])=>t.test(e))?.[1]??null}async function projectRootOf(){return(await Q().getProjectFiles()).root}function absoluteOf(e,t){return yi.test(t)||e===``?t:`${e.replace(/[\\/]+$/,``)}/${t}`}async function scenarioNamesOf(e){let t=await Q().readFile(e),{parsed:n}=await lt(e,t),r=new Map;for(let e of n.file?.testCases??[])r.set(e.name,(r.get(e.name)??0)+1);return r}function ownElements(e){return ui.find(e)?.elements()??[]}function createBridgeLinks(e,t=projectRootOf){let n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=new Set,c=null,l=null,u=null,notify=()=>{c===null&&(c=setTimeout(()=>{c=null;for(let e of[...s])e()},_i))},settle=()=>(u??=(async()=>{try{l=await t()}catch{l=``}notify()})(),u),absolute=e=>absoluteOf(l??``,e),load=e=>{let t=r.get(e);if(t)return t;let i=(async()=>{try{let t=await Q().readFile(e);n.set(e,await parse(t))}catch{n.set(e,null)}notify()})();return r.set(e,i),i.finally(()=>r.delete(e)),i},readScenarioNames=e=>{let t=a.get(e);if(t)return t;let n=scenarioNamesOf(e).catch(()=>new Map).then(t=>{i.set(e,{names:t,at:Date.now()}),notify()});return a.set(e,n),n.finally(()=>a.delete(e)),n},own=t=>{let n=e();return!!n?.file&&Ve(n.file,t)},liveOf=(e,t)=>own(e)?ui.find(e)?.describe(t):null;return{file(e){let t=kindOf(e);return t?n.get(absolute(e))===null?null:{rel:e,kind:t}:o.get(e)===!0?{rel:e,kind:`source`}:null},async check(e){if(!o.has(e)&&mi.test(e)){await settle();try{let t=await Q().readCodeSnippet?.(absolute(e),1,1);o.set(e,(t?.lines.length??0)>0)}catch{o.set(e,!1)}}},async element(e,t){if(!gi.test(e))return null;await settle();let r=absolute(e),i=liveOf(r,t);return i?{type:i.type,...i.name?{name:i.name}:{}}:(await load(r),n.get(r)?.get(t)??null)},peek(e,t){if(!gi.test(e))return null;if(l===null)return;let r=absolute(e),i=liveOf(r,t);if(i)return{type:i.type,...i.name?{name:i.name}:{}};if(n.has(r))return n.get(r)?.get(t)??null},subscribe(e){return s.add(e),()=>{s.delete(e)}},openFile(e){settle().then(()=>Q().revealElement(absolute(e))).catch(e=>console.error(`The file could not be opened:`,e))},openElement(e,t){settle().then(async()=>{let n=absolute(e);(own(n)?ui.find(n):void 0)?.select(t)||await Q().revealElement(n,t)}).catch(e=>console.error(`The element could not be revealed:`,e))},named(t){let n=e();if(!n?.file||!gi.test(n.file))return null;let r=ownElements(n.file).filter(e=>e.name===t);return r.length===1?{file:n.file,id:r[0].id,type:r[0].type,name:t}:null},scenario(t){let n=e();return!n?.file||!gi.test(n.file)||ownElements(n.file).some(e=>e.name===t)?null:i.get(absolute(n.file))?.names.get(t)===1?{file:n.file,name:t}:null},async refreshScenarios(){let t=e();if(!t?.file||!gi.test(t.file))return;await settle();let n=absolute(t.file),r=i.get(n);r&&Date.now()-r.at<vi||await readScenarioNames(n)},openScenario(e,t){requestScenario(e,t)},highlight(e,t,n){let r=absolute(e);own(r)&&ui.find(r)?.mark(t,n)},flash(e,t){let n=absolute(e);own(n)&&ui.find(n)?.flash(t)},openCode(e,t){settle().then(()=>Q().openAsText(absolute(e),t??void 0)).catch(e=>console.error(`The file could not be opened:`,e))},dispose(){c!==null&&clearTimeout(c),s.clear()}}}var bi=new Map;function useBridgeLinks(e){let t=o(e);t.current=e;let n=c(()=>createBridgeLinks(()=>t.current),[]);return f(()=>()=>n.dispose(),[n]),n}function AssistantRuntime({editor:e}){let t=Pe(),n=useEditorActive();f(()=>{t&&t.start()},[t]),f(()=>Be(),[]),f(()=>{bi.set(e.key,e);let t=e.canvas?ui.set(e.key,e.canvas):void 0;return()=>{bi.get(e.key)===e&&bi.delete(e.key),t?.()}},[e]);let r=X(t?t.subscribe:()=>()=>void 0,()=>t?.snapshot().loaded??!1);return f(()=>{t&&r&&t.settle(e.key,e.file)},[t,r,e.key,e.file]),f(()=>{t&&n&&t.focus(e.key)},[t,n,e.key]),f(()=>()=>t?.unfocus(e.key),[t,e.key]),f(()=>{if(t&&e.canvas)return connectReviews({store:t,canvas:e.canvas,file:()=>e.file})},[t,e.canvas,e.file]),null}var xi=/\.(bpmn|dmn|form)$/i;function latestDiagramOf(e){return[...e.files].reverse().find(e=>xi.test(e))??null}var Si={idle:`app.assistant.state.idle`,connecting:`app.assistant.state.connecting`,working:`app.assistant.state.working`,waiting:`app.assistant.state.waiting`,failed:`app.assistant.state.failed`};function stateLine(e,t=Date.now()){return e.detail?e.detail:e.state===`idle`?ze(e.updated,t):m(Si[e.state])}function Dot({state:e}){return e===`working`||e===`connecting`?l(`span`,{class:`assistant-chat__mark`,children:l(k,{})}):l(`span`,{class:`assistant-chat__mark`,children:l(`i`,{class:`assistant-chat__dot is-${e}`})})}async function confirmDelete(e){return Q().confirmWithUser({title:m(`app.assistant.delete.title`),text:m(`app.assistant.delete.text`,{title:e.title}),accept:m(`app.assistant.delete.accept`),decline:m(`app.common.cancel`),warning:!0})}function ChatsSection({store:e,editor:n,onOpen:r,onOpenFile:i}){let a=X(e.subscribe,e.snapshot),[o,s]=t(null),[c,u]=t(null),d=n?a.active[n]:null;if(f(()=>{e.start()},[e]),!a.enabled)return null;let open=t=>{if(n)e.select(n,t.id),e.reveal(n);else{let n=latestDiagramOf(t);if(n){let r=[...bi.values()].find(e=>e.file!==null&&Ve(e.file,n));r?(e.select(r.key,t.id),e.reveal(r.key)):e.expectChat(t.id,n),i?.(n)}}r?.(t)},create=async()=>{await e.create(n)&&n&&e.reveal(n)},remove=async t=>{await confirmDelete(t)&&await e.remove(t.id)},items=e=>[{id:`rename`,label:m(`app.assistant.rename`),run:()=>u(e.id)},{id:`delete`,label:m(`app.assistant.delete.action`),danger:!0,run:()=>void remove(e)}];return l(`section`,{class:`assistant-chats`,"aria-label":m(`app.assistant.chats.label`),children:[l(`div`,{class:`assistant-chats__head`,children:[l(`h2`,{class:`assistant-chats__title type-section-heading`,children:m(`app.assistant.chats.title`)}),l(`span`,{class:`assistant-chats__buttons`,children:[l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.chats.new`),title:m(`app.assistant.chats.new`),onClick:()=>void create(),children:l(D,{name:`plus`})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.chats.agents`),title:m(`app.assistant.chats.agents`),onClick:()=>void Re(),children:l(D,{name:`settings`})})]})]}),a.loaded&&a.chats.length===0&&l(`p`,{class:`assistant-chats__empty type-help`,children:m(`app.assistant.chats.empty`)}),l(`ul`,{class:`assistant-chats__list`,children:a.chats.map(t=>l(`li`,{children:c===t.id?l(Rename,{chat:t,onDone:n=>{u(null),n!==null&&n!==t.title&&e.rename(t.id,n)}}):l(`button`,{type:`button`,class:`assistant-chat${d===t.id?` is-selected`:``} is-${t.state}`,"aria-current":d===t.id?`true`:void 0,onClick:()=>open(t),onContextMenu:e=>{e.preventDefault(),s({at:{x:e.clientX,y:e.clientY},chat:t})},onKeyDown:e=>{if(e.key===`F2`)e.preventDefault(),u(t.id);else if(e.key===`Delete`)e.preventDefault(),remove(t);else if(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey){e.preventDefault();let n=e.currentTarget.getBoundingClientRect();s({at:{x:n.left+24,y:n.bottom},chat:t})}},children:[l(Dot,{state:t.state}),l(`span`,{class:`assistant-chat__body`,children:[l(`span`,{class:`assistant-chat__title type-body`,children:t.title}),l(`span`,{class:`assistant-chat__state type-help`,children:stateLine(t)})]})]})},t.id))}),o&&l(T,{label:m(`app.assistant.chats.menu`),at:o.at,items:items(o.chat),onClose:()=>s(null)})]})}function Rename({chat:e,onDone:t}){let n=o(null),r=o(!1),finish=e=>{r.current||(r.current=!0,t(e))};return f(()=>{n.current?.focus(),n.current?.select()},[]),l(`input`,{ref:n,class:`assistant-chat__rename type-input`,"aria-label":m(`app.assistant.rename`),defaultValue:e.title,maxLength:200,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),finish(e.currentTarget.value.trim()||null)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),finish(null))},onBlur:e=>finish(e.currentTarget.value.trim()||null)})}function ChatSwitcher({store:e,state:n,editor:r,chat:i}){let s=o(null),[c,u]=t(!1),d=i?.title??m(`app.assistant.chats.new`),choose=t=>{e.select(r,t),u(!1),e.focusInput(r)};return l(a,{children:[l(`button`,{ref:s,type:`button`,class:`assistant-switch type-help`,title:d,"aria-label":`${m(`app.assistant.switch.label`)}: ${d}`,"aria-haspopup":`listbox`,"aria-expanded":c,onClick:()=>u(e=>!e),children:[l(D,{name:`chat`,class:`assistant-switch__icon`}),l(`span`,{class:`assistant-switch__title`,children:d}),l(D,{name:`chevronDown`,class:`assistant-switch__chevron`})]}),c&&l(M,{anchor:s.current,label:m(`app.assistant.switch.list`),onClose:()=>u(!1),width:288,class:`assistant-switch__popover`,children:l(`ul`,{class:`assistant-switch__list`,role:`listbox`,"aria-label":m(`app.assistant.switch.list`),children:[l(`li`,{role:`presentation`,children:l(`button`,{type:`button`,role:`option`,"aria-selected":i===null,class:`assistant-switch__item assistant-switch__item--new type-body`,onClick:()=>choose(null),children:[l(D,{name:`plus`}),l(`span`,{class:`assistant-switch__name`,children:m(`app.assistant.chats.new`)})]})}),n.chats.map(e=>l(`li`,{role:`presentation`,children:l(`button`,{type:`button`,role:`option`,"aria-selected":e.id===i?.id,class:`assistant-switch__item type-body`,onClick:()=>choose(e.id),children:[l(`span`,{class:`assistant-switch__name`,title:e.title,children:e.title}),l(`span`,{class:`assistant-switch__state type-help`,children:stateLine(e)})]})},e.id))]})})]})}var Ci=40;function useFiles(){let[e,n]=t(null);return f(()=>{let e=!0;return Q().getProjectFiles().then(t=>e&&n({root:t.root,paths:t.files.map(e=>e.path)})).catch(()=>e&&n({root:``,paths:[]})),()=>{e=!1}},[]),e}function Mentions({store:e,editor:n,anchor:r,onClose:i}){let[a,o]=t(``),s=useFiles(),u=c(()=>n.canvas?n.canvas.elements():n.elements?.()??[],[n]),d=a.trim().toLowerCase(),f=u.filter(e=>!d||`${e.name??``} ${e.id} ${Z(e.type)}`.toLowerCase().includes(d)).slice(0,Ci),p=s?.root.replace(/\\/g,`/`).replace(/\/$/,``)??``,h=(s?.paths??[]).map(e=>({path:e,rel:e.replace(/\\/g,`/`).startsWith(`${p}/`)?e.replace(/\\/g,`/`).slice(p.length+1):e})).filter(e=>!d||e.rel.toLowerCase().includes(d)).slice(0,Ci);return l(M,{anchor:r,label:m(`app.assistant.mention.label`),onClose:i,width:320,class:`assistant-mentions`,children:[l(`input`,{type:`search`,class:`assistant-mentions__search type-input`,"aria-label":m(`app.assistant.mention.search`),placeholder:m(`app.assistant.mention.search`),value:a,onInput:e=>o(e.currentTarget.value)}),l(`div`,{class:`assistant-mentions__list`,children:[u.length>0&&l(`p`,{class:`assistant-mentions__heading type-section-heading`,children:m(`app.assistant.mention.elements`)}),f.map(t=>l(`button`,{type:`button`,class:`assistant-mentions__item type-body`,onClick:()=>{e.mention(n.key,{kind:`element`,id:t.id,type:t.type,...t.name?{name:t.name}:{}}),i()},children:[l(`span`,{class:`assistant-mentions__name`,children:t.name||t.id}),l(`span`,{class:`assistant-mentions__kind type-help`,children:Z(t.type)})]},t.id)),l(`p`,{class:`assistant-mentions__heading type-section-heading`,children:m(`app.assistant.mention.files`)}),h.map(t=>l(`button`,{type:`button`,class:`assistant-mentions__item type-body`,title:t.path,onClick:()=>{e.mention(n.key,{kind:`file`,path:t.rel,name:Ue(t.rel)}),i()},children:l(`span`,{class:`assistant-mentions__name`,children:t.rel})},t.path)),s!==null&&h.length===0&&f.length===0&&l(`p`,{class:`assistant-mentions__empty type-help`,children:m(`app.assistant.mention.none`)})]})]})}function chooseFit(e){for(let t=0;t<4;t+=1)if(e(t))return t;return 4}function fitRow(e){let t=chooseFit(t=>(e.dataset.fit=String(t),e.scrollWidth<=e.clientWidth+1));return e.dataset.fit=String(t),t}var wi=[],Ti=4;function sizeField(e){e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`}var sameElements=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.name===t[n].name&&e.type===t[n].type),noSubscribe=()=>()=>void 0;function isBusy(e){return e?.state===`working`||e?.state===`waiting`||e?.state===`connecting`}function contextOf(e,t,n){let r=[...t.map(e=>e.id),...n.mentions.filter(e=>e.kind===`element`).map(e=>e.id)];return{file:e.file,elementIds:[...new Set(r)]}}function messageOf(e){let t=e.text.trim(),n=e.mentions.filter(e=>e.kind===`file`);return n.length===0?t:`${n.map(e=>`@${e.path}`).join(`
980
+ `)}\n\n${t}`}function AssistantInput({store:e,editor:n,chat:r,transcript:i,surface:s,hint:d}){let{unlock:p}=useLicence(),h=X(e.subscribe,e.snapshot),g=h.drafts[n.key]??e.draft(n.key),_=n.selection,v=X(_?_.subscribe:noSubscribe,_?_.read:()=>wi,sameElements),y=v.map(e=>e.id).join(`
981
+ `);f(()=>e.releaseDismissed(n.key,y===``?[]:y.split(`
982
+ `)),[y]);let b=o(null),x=o(null),S=o(null),[C,w]=t(!1),[T,E]=t(!1),O=isBusy(r),A=g.text.trim()===``,j=c(()=>v.filter(e=>!g.dismissed.includes(`element:${e.id}`)),[v,g.dismissed]),M=Math.max(0,j.length-Ti),N=h.choices.filter(e=>e.available),P=r?.agentId??h.agentId??N[0]?.id??``,F=i?.queue??[],I=Ie(h,n.key,r,P),L=s===`dock`&&r!==null&&O&&(h.shown[r.id]!==!0||h.folded[r.id]===!0),R=s===`dock`&&A&&!C&&F.length===0&&!L,z=d??m(s===`tab`?`app.assistant.input.ask`:`app.assistant.input.placeholder`);u(()=>{b.current&&sizeField(b.current)},[g.text]),u(()=>{S.current&&fitRow(S.current)}),f(()=>{let e=S.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientWidth,n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,fitRow(e),b.current&&sizeField(b.current))});return n.observe(e),()=>n.disconnect()},[]),f(()=>{g.focus>0&&b.current?.focus()},[g.focus]);let submit=async()=>{if(A||T)return;E(!0);let t=g.text;try{let r=await e.send({editor:n.key,text:messageOf(g),context:contextOf(n,j,g),authorize:()=>p(de.AI_CHAT)});(r===`sent`||r===`queued`)&&e.draft(n.key).text===t&&e.clearDraft(n.key)}finally{E(!1)}},stop=()=>{r&&e.stop(r.id)};return l(`form`,{class:`assistant-input${O?` is-busy`:``}${R?` is-resting`:``}`,"aria-label":m(`app.assistant.input.label`),onSubmit:e=>{e.preventDefault(),submit()},children:[L&&r&&l(`button`,{type:`button`,class:`assistant-input__state type-help`,title:m(`app.assistant.input.showCard`),onClick:()=>e.showCard(r.id),children:[r.state===`waiting`||i?.permission?l(D,{name:`hand`,class:`assistant-input__hand`}):l(k,{}),l(`span`,{children:r.state===`waiting`||i?.permission?m(`app.assistant.input.stateWaiting`):m(`app.assistant.input.stateWorking`)})]}),F.length>0&&l(`ul`,{class:`assistant-input__queue`,"aria-label":m(`app.assistant.input.queued`),children:F.map(t=>l(`li`,{class:`assistant-input__queued`,children:[l(D,{name:`queue`}),l(`span`,{class:`assistant-input__queued-text type-help`,title:t.text,children:m(`app.assistant.input.queuedText`,{text:t.text})}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.input.unqueue`),title:m(`app.assistant.input.unqueue`),onClick:()=>r&&void e.unqueue(r.id,t.id,n.key),children:l(D,{name:`close`})})]},t.id))}),l(`div`,{class:`assistant-input__chips`,role:`group`,"aria-label":m(`app.assistant.input.context`),children:[j.slice(0,Ti).map(t=>l(`span`,{class:`assistant-chip assistant-chip--element`,children:[l(ElementChip,{id:t.id,type:t.type,name:t.name,onSelect:e=>n.canvas?.select(e)}),l(`button`,{type:`button`,class:`assistant-chip__remove`,"aria-label":m(`app.assistant.input.removeChip`,{name:t.name||t.id}),title:m(`app.assistant.input.removeChip`,{name:t.name||t.id}),onClick:()=>e.unmention(n.key,`element:${t.id}`),children:l(D,{name:`close`})})]},t.id)),M>0&&l(`span`,{class:`assistant-chip type-help`,children:m(`app.assistant.input.more`,{count:M})}),g.mentions.map(t=>l(`span`,{class:`assistant-chip assistant-chip--${t.kind}`,children:[t.kind===`element`?l(ElementChip,{id:t.id,type:t.type,name:t.name,onSelect:e=>n.canvas?.select(e)}):l(`span`,{class:`assistant-chip__label type-help`,title:t.path,children:t.name}),l(`button`,{type:`button`,class:`assistant-chip__remove`,"aria-label":m(`app.assistant.input.removeChip`,{name:t.kind===`element`?t.name||t.id:t.name}),title:m(`app.assistant.input.removeChip`,{name:t.kind===`element`?t.name||t.id:t.name}),onClick:()=>e.unmention(n.key,Fe(t)),children:l(D,{name:`close`})})]},Fe(t))),l(`span`,{class:`assistant-chip assistant-chip--file type-help`,title:n.file??n.name,children:n.name})]}),l(`textarea`,{ref:b,class:`assistant-input__text type-input`,rows:1,value:g.text,placeholder:z,"aria-label":m(`app.assistant.input.placeholder`),onInput:t=>e.setText(n.key,t.currentTarget.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.altKey||e.isComposing||(e.preventDefault(),submit())}}),R&&l(`span`,{class:`assistant-input__hint type-input`,"aria-hidden":`true`,children:z}),l(`div`,{ref:S,class:`assistant-input__row`,children:[l(ChatSwitcher,{store:e,state:h,editor:n.key,chat:r}),l(`button`,{ref:x,type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.input.add`),title:m(`app.assistant.input.add`),"aria-haspopup":`dialog`,"aria-expanded":C,onClick:()=>w(e=>!e),children:l(D,{name:`plus`})}),C&&l(Mentions,{store:e,editor:n,anchor:x.current,onClose:()=>w(!1)}),l(Ge,{store:e,state:h,editor:n.key,chat:r,agentId:P,options:I,busy:O,started:r!==null&&(i?.entries.length??0)>0}),l(`span`,{class:`assistant-input__keys type-help`,"aria-hidden":`true`,children:[l(`kbd`,{class:`assistant-key`,children:m(`app.assistant.input.keyEnter`)}),l(`span`,{children:m(O?`app.assistant.input.keyQueue`:`app.assistant.input.keySend`)}),!O&&l(a,{children:[l(`kbd`,{class:`assistant-key`,children:m(`app.assistant.input.keyShiftEnter`)}),l(`span`,{children:m(`app.assistant.input.keyNewline`)})]})]}),O?l(`button`,{type:`button`,class:`assistant-button assistant-button--stop`,"aria-label":m(`app.assistant.input.stop`),title:m(`app.assistant.input.stop`),onClick:stop,children:l(D,{name:`stop`})}):l(`button`,{type:`submit`,class:`assistant-button assistant-button--send`,"aria-label":m(`app.assistant.input.send`),title:m(`app.assistant.input.send`),disabled:A||T,children:T?l(k,{}):l(D,{name:`send`})})]})]})}var Ei=`.djs-palette, .fjs-palette-container`,Di=`.bjs-powered-by, .fjs-powered-by-link`,Oi=`.diagram-check, .bjsl-button, .trace-pill`;function cornerLayout(e){let t=Math.max(0,Math.min(e.coveredLeft??0,e.canvas)),n=Math.max(0,Math.min(e.covered??0,e.canvas-t)),r=e.canvas-n,edge=e=>e>0?16+e:0,i=Math.max(edge(e.palette),edge(e.watermark),t),a=e.cardFull>0,room=e=>r-e-32,o=e.dock&&a&&room(Math.max(i,edge(e.cardFull)))<440,s=r-16,span=e=>s-(e+16),c=Math.max(i,edge(e.card)),l=`full`;e.dock&&e.canvas>0&&span(c)<240&&(span(i)>=240?(c=i,l=`overlap`):l=`collapsed`);let u=i,d=Math.min(e.canvas-16,Math.max(s,u+16+240)),f=Math.max(0,e.canvas-16-d),p=c+16,m=Math.min(600,Math.max(0,s-p)),h=p+(s-p-m)/2;return{inset:c,folded:o,mode:l,overlayInset:u,overlayCovered:f,covered:n,coveredLeft:t,dock:{left:h,right:h+m}}}var ki=`.assistant-dock`,Ai=`.assistant-input, .assistant-ask`;function insetOf(e,t){return t===null||!Number.isFinite(t)?0:Math.max(0,Math.round(e-t))}function viewportHeight(){return typeof window>`u`?0:window.innerHeight}function shown(e){if(!e)return null;let t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null}function measureCorner(e){let t=e.getBoundingClientRect(),widthOf=n=>{let r=0;return e.querySelectorAll(n).forEach(e=>{let n=shown(e);n&&(r=Math.max(r,n.right-t.left-16))}),Math.max(0,Math.round(r))},n=[...e.querySelectorAll(Oi)].map(shown).filter(e=>e!==null),r=e.querySelector(`.diagram-check:not(.trace-card)`)!==null,i=n.reduce((e,t)=>Math.min(e,t.top),1/0),a=Qe(t,$(e).map(e=>e.getBoundingClientRect())),o=Math.max(0,Math.min(460,t.width-32)),s=cornerLayout({canvas:t.width,palette:widthOf(Ei),watermark:widthOf(Di),card:widthOf(Oi),cardFull:Math.max(r?o:0,Math.min(o,fullWidth(e,`.trace-card`)),Math.min(o,fullWidth(e,`.bjsl-button`))),dock:e.querySelector(`.assistant-dock`)!==null,covered:a.right,coveredLeft:a.left});return{inset:Math.round(s.inset),dock:insetOf(t.bottom,shown(e.querySelector(`.assistant-dock`))?.top??null),input:insetOf(t.bottom,shown(e.querySelector(`.assistant-input, .assistant-ask`))?.top??null),height:n.length>0?Math.max(0,Math.round(t.bottom-i))+16:0,folded:s.folded,left:Math.round(t.left),bottom:Math.max(0,Math.round(viewportHeight()-t.bottom)),mode:s.mode,overlayInset:Math.round(s.overlayInset),overlayCovered:Math.round(s.overlayCovered),covered:Math.round(s.covered),coveredLeft:Math.round(s.coveredLeft),traceLeft:traceLeftOf(e,t)}}var ji=8;function fullWidth(e,t){let n=e.querySelector(t),r=shown(n);return!n||!r?0:(e.classList.contains(`is-corner-folded`)||(n.dataset.fullWidth=String(Math.round(r.width))),Number(n.dataset.fullWidth??Math.round(r.width)))}function traceLeftOf(e,t){let n=shown(e.querySelector(`.bjsl-button`))??shown(e.querySelector(`.trace-pill`));return n?Math.round(n.right-t.left+ji):16}function observeCorner(e,t,n){let r=0,schedule=()=>{r||=requestAnimationFrame(()=>{r=0,n()})};if(typeof ResizeObserver>`u`)return()=>void 0;let i=new ResizeObserver(schedule);i.observe(e),t.forEach(e=>i.observe(e));let a=new Set,watch=()=>{let t=new Set(e.querySelectorAll(`${Ei}, ${Di}, ${Oi}, ${ki}, ${Ai}`));for(let e of a)t.has(e)||(a.delete(e),i.unobserve(e));for(let e of t)a.has(e)||(a.add(e),i.observe(e))};watch();let o=new MutationObserver(()=>{watch(),schedule()});return o.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`class`]}),()=>{i.disconnect(),o.disconnect(),r&&cancelAnimationFrame(r)}}var Mi={peeking:!1,over:!1,focused:!1,asking:!1};function peekAfter(e,t){switch(t){case`canvas`:return e.asking||e.over?e:{...e,peeking:!0};case`selection`:return e.asking||e.over||e.focused?e:{...e,peeking:!0};case`hover`:return{...e,over:!0,peeking:!1};case`leave`:return{...e,over:!1};case`focus`:return{...e,focused:!0,peeking:!1};case`blur`:return{...e,focused:!1};case`asking`:return{...e,asking:!0,peeking:!1};case`answered`:return{...e,asking:!1}}}var inside=(e,t)=>t instanceof Node&&e.contains(t);function usePeek(e,n,r,i){let a=o(Mi),[s,c]=t(!1),apply=e=>{let t=peekAfter(a.current,e);a.current=t,c(t.peeking)};return f(()=>{apply(r?`asking`:`answered`)},[r]),f(()=>{let t=e.current,r=t?.closest(`.editor-canvas`);if(!t||!r||!i){a.current=Mi,c(!1);return}let worked=e=>{inside(t,e.target)||apply(`canvas`)},over=e=>{e.target?.closest?.(`.assistant-card`)&&apply(`hover`)},out=e=>{e.relatedTarget?.closest?.(`.assistant-card`)||apply(`leave`)},focus=()=>apply(`focus`),blur=e=>{inside(t,e.relatedTarget)||apply(`blur`)},o=n?.subscribe(()=>apply(`selection`));return r.addEventListener(`pointerdown`,worked,!0),r.addEventListener(`wheel`,worked,{capture:!0,passive:!0}),t.addEventListener(`mouseover`,over),t.addEventListener(`mouseout`,out),t.addEventListener(`focusin`,focus),t.addEventListener(`focusout`,blur),()=>{o?.(),r.removeEventListener(`pointerdown`,worked,!0),r.removeEventListener(`wheel`,worked,!0),t.removeEventListener(`mouseover`,over),t.removeEventListener(`mouseout`,out),t.removeEventListener(`focusin`,focus),t.removeEventListener(`focusout`,blur)}},[e,n,i]),s&&!r}function useStore$1(){let[e]=t(()=>Pe());return e}e(useStore$1,`useStore`);var Ni=e(()=>()=>void 0,`none`),Pi=360;function AssistantDock({editor:e,hidden:n,onAgentSettings:i}){let s=useStore$1(),c=X(s?s.subscribe:Ni,s?s.snapshot:()=>null),u=o(null),d=r(Ln),p=useBridgeLinks(e),h=c?.enabled===!0&&c.place===`bottom`&&!n,g=s&&c?s.activeChat(e.key):null,_=!!c&&!!g&&c.shown[g.id]===!0&&c.folded[g.id]!==!0&&c.transcripts[g.id]?.permission!=null,v=!!c&&!!g&&c.transcripts[g.id]?.permission!=null,y=e.canvas?.channel,[b,x]=t(`full`),[S,C]=t(!1),w=v||g?.state===`waiting`,T=b===`collapsed`&&(S||w),E=usePeek(u,e.selection,_,h);if(f(()=>{let e=u.current,t=e?.closest(`.editor-canvas`);if(!e||!t)return;let publish=()=>{let n=e.offsetHeight,r=measureCorner(t),i=r.mode===`collapsed`&&T?r.overlayInset:r.inset,a=r.mode===`collapsed`&&T?r.overlayCovered:r.covered;t.style.setProperty(`--assistant-canvas-height`,`${t.clientHeight}px`),t.style.setProperty(`--assistant-inset-left`,`${i}px`),t.style.setProperty(`--assistant-inset-right`,`${a}px`),e.dataset.narrow=e.offsetWidth<Pi?`true`:`false`,e.dataset.coverLeft=r.coveredLeft>0?`true`:`false`,x(r.mode),y?.setCover(v?$e(i,n,a):null)};publish();let n=observeCorner(t,[e],publish),r=Xe(t,publish);return()=>{n(),r(),t.style.removeProperty(`--assistant-canvas-height`),t.style.removeProperty(`--assistant-inset-left`),t.style.removeProperty(`--assistant-inset-right`),y?.setCover(null)}},[h,v,y,T]),f(()=>{if(b!==`collapsed`||!S)return;let away=e=>{let t=e.target;t instanceof Element&&!t.closest(`.assistant-dock, .ui-popover`)&&C(!1)};return document.addEventListener(`pointerdown`,away,!0),()=>document.removeEventListener(`pointerdown`,away,!0)},[b,S]),f(()=>{S&&s&&s.focusInput(e.key)},[S]),!s||!c||!h)return null;let O=s.activeChat(e.key),A=O?c.transcripts[O.id]??null:null,j=O!==null&&c.shown[O.id]===!0&&(O.state===`failed`||c.folded[O.id]!==!0),M=b===`collapsed`&&!T,N=O&&(O.state===`working`||O.state===`connecting`)?`working`:O&&(O.state===`waiting`||A?.permission)?`waiting`:null,collapse=()=>{C(!1),requestAnimationFrame(()=>u.current?.querySelector(`.assistant-ask`)?.focus())};return l(Ln.Provider,{value:d===In?p:d,children:l(`div`,{ref:u,class:`assistant-dock${M?` is-collapsed`:``}${T?` is-overlay`:``}`,onKeyDown:e=>{e.key===`Escape`&&(O&&j&&O.state!==`failed`?(e.stopPropagation(),s.setFolded(O.id,!0)):b===`collapsed`&&S&&!w&&(e.stopPropagation(),collapse()))},children:M?l(`button`,{type:`button`,class:`assistant-ask${N?` is-${N}`:``}`,"aria-label":m(`app.assistant.input.ask`),title:m(`app.assistant.input.ask`),onClick:()=>C(!0),children:N===`working`?l(k,{}):l(D,{name:N===`waiting`?`hand`:`chat`})}):l(a,{children:[O&&j&&l(AssistantCard,{store:s,state:c,editor:e,chat:O,transcript:A,peeking:E,onChooseAgent:()=>u.current?.querySelector(`.assistant-settings`)?.click(),onAgentSettings:i??(()=>void Re())}),!j&&c.failure&&l(`section`,{class:`assistant-card is-failed`,role:`alert`,"aria-label":m(`app.assistant.card.label`),children:[l(`header`,{class:`assistant-card__head`,children:[l(D,{name:`alert`,class:`assistant-card__icon is-warning`}),l(`span`,{class:`assistant-card__title`,children:m(`app.assistant.unreachable`)}),l(`span`,{class:`assistant-card__buttons`,children:l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.close`),title:m(`app.assistant.card.close`),onClick:()=>s.dismissFailure(),children:l(D,{name:`close`})})})]}),l(`div`,{class:`assistant-card__body`,children:l(FailureNotice,{failure:c.failure,choices:c.choices,onRetry:()=>void s.resync(),onSettings:i??(()=>void Re())})})]}),l(AssistantInput,{store:s,editor:e,chat:O,transcript:A,surface:`dock`})]})})})}var Fi=i(null);function TranscriptFailure({error:e}){let t=failureSummary(e,``);return l(a,{children:[l(`p`,{class:`assistant-entry is-notice type-help`,role:`alert`,children:t.text}),t.details&&l(FailureDetails,{text:t.details})]})}function ChatTabBody({store:e,editor:t}){let n=X(e.subscribe,e.snapshot),i=r(Ln),a=useBridgeLinks(t),o=e.activeChat(t.key),s=o?.id??null,c=s?n.transcripts[s]??null:null,u=c?.entries??[],d=c?.permission??null,p=u[u.length-1],h=useFollow(d?.id??null,`${u.length}:${p&&`text`in p?p.text.length:0}:${o?.state??``}`);f(()=>{s&&e.open(s)},[e,s]);let g=o?.state===`working`||o?.state===`connecting`||o?.state===`waiting`,_=o?.state===`failed`;return l(Ln.Provider,{value:i===In?a:i,children:l(`section`,{class:`assistant-tab`,"aria-label":m(`app.assistant.tab.label`),children:[o&&l(`header`,{class:`assistant-tab__head`,children:[l(`span`,{class:`assistant-tab__title`,title:o.title,children:o.title}),l(`button`,{type:`button`,class:`assistant-button assistant-button--icon`,"aria-label":m(`app.assistant.card.newChat`),title:m(`app.assistant.card.newChat`),disabled:g||d!==null,onClick:()=>e.select(t.key,null),children:l(D,{name:`plus`})})]}),l(`div`,{ref:h.ref,class:`assistant-tab__feed`,role:`log`,"aria-live":`off`,"aria-label":m(`app.assistant.tab.transcript`),onScroll:h.onScroll,children:[!o&&!n.failure&&l(A,{title:m(`app.assistant.tab.empty`),hint:m(`app.assistant.tab.emptyHint`)}),c?.status===`loading`&&u.length===0&&l(`p`,{class:`assistant-card__status type-help`,role:`status`,children:[l(k,{}),` `,m(`app.assistant.card.loading`)]}),s&&c?.status===`failed`&&l(A,{title:m(`app.assistant.tab.unreadable`),hint:m(`app.assistant.tab.unreadableHint`),actions:[{label:m(`app.assistant.tryAgain`),run:()=>void e.retry(s,null)}]}),o&&c?.status===`ready`&&u.length===0&&!d&&l(A,{title:m(`app.assistant.tab.emptyChat`),hint:m(`app.assistant.tab.emptyChatHint`)}),c&&l(TranscriptView,{store:e,chatId:s??``,entries:u,permission:d,running:g,surface:`tab`,onShow:(e,n)=>{if(!t.canvas?.channel.has(proposalId(e,n)))return!1;let r=t.canvas.channel;return requestAnimationFrame(()=>requestAnimationFrame(()=>r.fit())),!0}}),_&&c?.error&&l(TranscriptFailure,{error:c.error}),n.failure&&l(FailureNotice,{failure:n.failure,choices:n.choices,onRetry:()=>void e.resync(),onSettings:()=>void Re()})]}),l(`div`,{class:`assistant-tab__input`,children:l(AssistantInput,{store:e,editor:t,chat:o,transcript:c,surface:`tab`})})]})})}function ChatTab(){let e=r(Fi),[n]=t(()=>Pe());return!n||!e?null:l(ChatTabBody,{store:n,editor:e})}var Ii={id:`chat`,icon:`chat`,component:ChatTab,needs:`ai-chat`};function chatStatusOf(e,t){let n=t?e.active[t]:null;if(!n)return null;let r=e.chats.find(e=>e.id===n);return r?r.state===`waiting`||e.transcripts[n]?.permission?`waiting`:r.state===`working`||r.state===`connecting`?`working`:null:null}function useEditorCanvas(e){let t=o(e);return t.current=e,c(()=>{let e=new EditorCanvas((n,r)=>{let i=e.describe(n);Pe()?.compose(t.current,{kind:`element`,id:n,type:i?.type??`bpmn:Task`,...i?.name?{name:i.name}:{}},r)});return e},[])}function useAssistantEditor({kind:e,file:t,fallbackName:n,selection:r,elements:i}){let a=t??null,o=a??n,s=useEditorCanvas(o),l=e===`bpmn`?s:void 0;return c(()=>({key:o,file:a,name:a?Ue(a):n,kind:e,canvas:l,selection:r??l,elements:i??l?.elements}),[o,a,n,e,l,r,i])}var none=()=>()=>void 0;function useAiChatPlace(){let[e]=t(()=>Pe());return X(e?e.subscribe:none,()=>e?e.snapshot().place:`off`)}function useChatStatus(e){let[n]=t(()=>Pe());return X(n?n.subscribe:none,()=>n?chatStatusOf(n.snapshot(),e):null)}function useRevealCount(e){let[n]=t(()=>Pe());return X(n?n.subscribe:none,()=>n&&e?n.snapshot().revealed[e]??0:0)}function useLeaveChatTab(e,t){let n=o(t);f(()=>{n.current&&!t&&e&&Pe()?.returnToCard(e),n.current=t},[e,t])}function useChatAction(e,t){let n=useAiChatPlace(),r=useChatStatus(e);return{available:qe(n).toolbarButton,open:t===Ii.id,status:r}}var Li=null,Ri=null,zi=new Set;function sameFacts(e,t){return JSON.stringify(e)===JSON.stringify(t)}function publishFacts(e,t){Li===e&&sameFacts(Ri,t)||(Li=e,Ri=t,zi.forEach(e=>e()))}function retractFacts(e){Li===e&&(Li=null,Ri=null,zi.forEach(e=>e()))}function useEditorFacts(){let[,e]=t(0);return f(()=>{let listener=()=>e(e=>e+1);return zi.add(listener),()=>void zi.delete(listener)},[]),Ri}function ToolbarButton({id:e,label:n,icon:r,action:i,disabled:a=!1,tooltip:s,description:c,isActive:u=!1,checked:d,status:p}){let[h,g]=t(!1),_=o(null);f(()=>()=>{_.current!==null&&window.clearTimeout(_.current),_.current=null},[]);let handleClick=()=>{a||(i(),g(!0),_.current!==null&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>{_.current=null,g(!1)},motionMs(`--motion-base`)))},handleKeyDown=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),handleClick())};return l(`button`,{id:e,className:`toolbar-button type-toolbar-button ${a?`disabled`:``} ${u||h?`active`:``}`,onClick:handleClick,onKeyDown:handleKeyDown,disabled:a,title:s||n,"aria-label":n,"aria-description":c??(p?m(`app.sidebar.status.${p}`):void 0),"aria-pressed":d===void 0?void 0:d,type:`button`,children:[l(`span`,{className:`toolbar-button-icon icon-${r}`,role:`presentation`,children:l(`svg`,{className:`toolbar-icon-svg`,viewBox:`0 0 16 16`,width:`16`,height:`16`,stroke:`currentColor`,fill:`none`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,dangerouslySetInnerHTML:{__html:getIconPath(r)}})}),p===`working`&&l(`span`,{className:`toolbar-button-status is-working`,"aria-hidden":`true`,children:l(k,{})}),p===`waiting`&&l(`span`,{className:`toolbar-button-status is-waiting`,"aria-hidden":`true`})]})}function getIconPath(e){return{refresh:`<path d="M2.5 9V8a5.5 5.5 0 0 1 8.5-4.6"/><path d="M5 12.6A5.5 5.5 0 0 0 13.5 8V7"/><path d="M1.5 7.5l2 2 2-2"/><path d="M10.5 8.5l2-2 2 2"/>`,undo:`<path d="M5 3.5 2.5 6 5 8.5"/><path d="M2.5 6h7a3.5 3.5 0 0 1 0 7h-3"/>`,redo:`<path d="M11 3.5 13.5 6 11 8.5"/><path d="M13.5 6h-7a3.5 3.5 0 0 0 0 7h3"/>`,copy:`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"/><path d="M10.5 3.5V3a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h.5"/>`,paste:`<path d="M5.5 3h-1A1.5 1.5 0 0 0 3 4.5v8A1.5 1.5 0 0 0 4.5 14h7a1.5 1.5 0 0 0 1.5-1.5v-8A1.5 1.5 0 0 0 11.5 3h-1"/><rect x="5.5" y="1.5" width="5" height="3" rx="1"/>`,"auto-layout":`<rect x="1.5" y="6.5" width="4" height="3" rx="0.5"/><rect x="10.5" y="2.5" width="4" height="3" rx="0.5"/><rect x="10.5" y="10.5" width="4" height="3" rx="0.5"/><path d="M5.5 8h2.5V4h2.5M8 8v4h2.5"/>`,"diagram-check":`<path d="M8 1.5 14.5 8 8 14.5 1.5 8Z"/><path d="M5.5 8.2 7.2 9.9 10.5 6.3"/>`,migration:`<path d="M6 3.5 10.5 8 6 12.5 1.5 8Z"/><path d="M10.5 8h4M13 6.5 14.5 8 13 9.5"/>`,live:`<path d="M1.5 8.5h3l1.5-4 3 8 1.5-4h4"/>`,runs:`<path d="M2.5 4.5l1.5 1.5 3-3"/><path d="M9.5 4.5h4"/><path d="M2.5 11l1.5 1.5 3-3"/><path d="M9.5 11h4"/>`,debug:`<circle cx="4.5" cy="8" r="2"/><path d="M8.5 3.5v9M8.5 8h5M11.5 5.5 14 8l-2.5 2.5"/>`,breakpoint:`<circle cx="8" cy="8" r="5"/><circle cx="8" cy="8" r="2"/>`,coverage:`<rect x="1.5" y="4.5" width="4" height="4" rx="1"/><rect x="10.5" y="4.5" width="4" height="4" rx="1"/><path d="M5.5 6.5h5"/><path d="M1.5 12.5h13" opacity="0.4"/><path d="M1.5 12.5h8"/>`,export:`<path d="M8 2.5v7M5 6.5l3 3 3-3"/><path d="M2.5 10v2A1.5 1.5 0 0 0 4 13.5h8a1.5 1.5 0 0 0 1.5-1.5v-2"/>`,share:`<path d="M9.5 2.5h4v4M13.5 2.5 8 8"/><path d="M12.5 9v3a1.5 1.5 0 0 1-1.5 1.5H4A1.5 1.5 0 0 1 2.5 12V5A1.5 1.5 0 0 1 4 3.5h3"/>`,import:`<path d="M9 2.5H4.5a1 1 0 0 0-1 1v9a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1V6Z"/><path d="M9 2.5V6h3.5"/><path d="M8 8v4M6 10l2 2 2-2"/>`,"token-simulation":`<path d="M5 3.3v9.4a.5.5 0 0 0 .77.42l7.1-4.7a.5.5 0 0 0 0-.84L5.77 2.88A.5.5 0 0 0 5 3.3Z"/>`,minimap:`<path d="M2.5 4 6 2.5l4 1.5 3.5-1.5V12L10 13.5 6 12l-3.5 1.5Z"/><path d="M6 2.5V12M10 4v9.5"/>`,"trace-paths":`<rect x="5.5" y="4.5" width="5" height="7" rx="1"/><path d="M1.5 2H3V6H5.5M1.5 14H3V10H5.5M10.5 6H13V2H14.5M10.5 10H13V14H14.5"/>`,deploy:`<path d="M8 14V7.5M5.5 10 8 7.5l2.5 2.5"/><path d="M5 12h-.75a3 3 0 0 1-.4-5.97 4.5 4.5 0 0 1 8.3 0A3 3 0 0 1 11.75 12H11"/>`,marketplace:`<rect x="2.5" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="9" y="2.5" width="4.5" height="4.5" rx="1"/><rect x="2.5" y="9" width="4.5" height="4.5" rx="1"/><rect x="9" y="9" width="4.5" height="4.5" rx="1"/>`,sketchy:`<path d="M2.5 10.5c1.5-3 3-3 4.5 0s3 3 4.5 0 1.5-2 2-2.5"/><path d="M2.5 6c1-1.5 2-1.5 3 0"/>`,"panel-toggle":`<rect x="2.5" y="2.5" width="11" height="11" rx="2"/><path d="M9.5 2.5v11"/><path d="M11.5 5h.5M11.5 7h.5M11.5 9h.5"/>`,preview:`<path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8Z"/><circle cx="8" cy="8" r="2"/>`,transaction:`<rect x="1.5" y="4.5" width="4" height="7" rx="1"/><rect x="10.5" y="4.5" width="4" height="7" rx="1"/><path d="M8 2.5v11"/>`,fit:`<path d="M2.5 6V2.5H6M10 2.5h3.5V6M13.5 10v3.5H10M6 13.5H2.5V10"/>`,"focus-canvas":`<path d="M2.5 5.5v-2a1 1 0 0 1 1-1h2M10.5 2.5h2a1 1 0 0 1 1 1v2M13.5 10.5v2a1 1 0 0 1-1 1h-2M5.5 13.5h-2a1 1 0 0 1-1-1v-2"/><rect x="5.5" y="5.5" width="5" height="5" rx="1"/>`,"zoom-in":`<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14M5 7h4M7 5v4"/>`,"zoom-out":`<circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14M5 7h4"/>`,tour:`<path d="M3.5 14V2.5"/><path d="M3.5 3h9v6h-9"/>`,compare:`<rect x="1.5" y="3.5" width="5" height="9" rx="1"/><rect x="9.5" y="3.5" width="5" height="9" rx="1"/><path d="M6.5 8h3"/>`,licence:`<circle cx="5.5" cy="10.5" r="3"/><path d="M7.7 8.3 13.5 2.5M11 5l1.5 1.5"/>`,documentation:`<path d="M3.5 12.5v-9a1 1 0 0 1 1-1h8v10h-8a1 1 0 0 0-1 1 1 1 0 0 0 1 1h8"/><path d="M6.5 5.5h4"/>`,sun:`<circle cx="8" cy="8" r="2.5"/><path d="M8 1.5V3M8 13v1.5M1.5 8H3M13 8h1.5M3.4 3.4l1.1 1.1M11.5 11.5l1.1 1.1M3.4 12.6l1.1-1.1M11.5 4.5l1.1-1.1"/>`,keyboard:`<rect x="1.5" y="4" width="13" height="8" rx="1.5"/><path d="M4 6.75h.01M6.5 6.75h.01M9 6.75h.01M11.5 6.75h.01M4 9.25h.01M11.5 9.25h.01M6.5 9.25h3"/>`,pin:`<path d="M6 2.5h4M7 2.5v4L4.5 9.5h7L9 6.5v-4M8 9.5v4"/>`,lock:`<rect x="3.5" y="7" width="9" height="6.5" rx="1.5"/><path d="M5.5 7V5a2.5 2.5 0 0 1 5 0v2"/>`,check:`<path d="M3.5 8.5 6.5 11.5 12.5 4.5"/>`,chevron:`<path d="M5 6.5 8 9.5l3-3"/>`,settings:`<path d="M2.5 4.5h6M11.5 4.5h2M2.5 11.5h2M7.5 11.5h6"/><circle cx="10" cy="4.5" r="1.5"/><circle cx="6" cy="11.5" r="1.5"/>`,more:`<circle cx="3.5" cy="8" r="0.75" fill="currentColor"/><circle cx="8" cy="8" r="0.75" fill="currentColor"/><circle cx="12.5" cy="8" r="0.75" fill="currentColor"/>`,delete:`<path d="M2.5 4.5h11M6.5 4.5v-1a1 1 0 0 1 1-1h1a1 1 0 0 1 1 1v1"/><path d="M4 4.5l.6 8.1a1 1 0 0 0 1 .9h4.8a1 1 0 0 0 1-.9l.6-8.1"/><path d="M6.8 7v4M9.2 7v4"/>`,"skip-back":`<path d="M4 3.5v9"/><path d="M12.5 4v8L6.5 8Z"/>`,"step-back":`<path d="M10 3.5 5.5 8l4.5 4.5"/>`,"step-forward":`<path d="M6 3.5 10.5 8 6 12.5"/>`,"skip-forward":`<path d="M12 3.5v9"/><path d="M3.5 4v8L9.5 8Z"/>`,pause:`<path d="M6 3.5v9M10 3.5v9"/>`,close:`<path d="M4 4l8 8M12 4l-8 8"/>`,code:`<path d="M5.5 4L2 8l3.5 4M10.5 4L14 8l-3.5 4"/>`,chat:`<path d="M2.5 2.5h11a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H8.5L5 13.5v-3H2.5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1z"/><path d="M5 6.5h.01M8 6.5h.01M11 6.5h.01"/>`,comments:`<path d="M3.5 2.5h9v11h-9z"/><path d="M5.5 6h5M5.5 9h3.5"/>`}[e]||`<circle cx="8" cy="8" r="1"/>`}function Icon({name:e,className:t=`toolbar-icon-svg`}){return l(`svg`,{className:t,viewBox:`0 0 16 16`,width:`16`,height:`16`,stroke:`currentColor`,fill:`none`,"stroke-width":`1`,"stroke-linecap":`round`,"stroke-linejoin":`round`,"aria-hidden":`true`,dangerouslySetInnerHTML:{__html:getIconPath(e)}})}var Bi=`penstock.web.chatsHeight`;function clampChats(e,t){let n=Math.max(96,t-96);return Math.min(n,Math.max(96,Math.round(e)))}function loadChatsHeight(e){try{let t=Number(e?.getItem(Bi));return Number.isFinite(t)&&t>=96?Math.round(t):null}catch{return null}}function saveChatsHeight(e,t){try{t===null?e?.removeItem(Bi):e?.setItem(Bi,String(Math.round(t)))}catch{}}function browserStore(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var Vi=16;function clampSidebar(e){return Math.min(400,Math.max(240,Math.round(e)))}var Hi=[{id:`check`,action:`diagram-check`,icon:`diagram-check`,label:()=>m(`app.web.sidebar.check`)},{id:`scenarios`,action:`runs`,icon:`runs`,label:()=>m(`app.web.sidebar.scenarios`)},{id:`monitor`,action:`live`,icon:`live`,label:()=>m(`app.web.sidebar.monitor`)},{id:`debug`,action:`debug-process`,icon:`debug`,label:()=>m(`app.web.sidebar.debug`)},{id:`layout`,action:`auto-layout`,icon:`auto-layout`,label:()=>m(`app.web.sidebar.layout`)}];function countOf(e,t){return t?e.id===`check`&&t.problems?{text:String(t.problems),title:m(`app.web.sidebar.countProblems`,{count:t.problems}),error:!0}:e.id===`scenarios`&&t.scenarios?{text:`${t.scenarios.passed}/${t.scenarios.all}`,title:m(`app.web.sidebar.countScenarios`,{passed:t.scenarios.passed,all:t.scenarios.all}),error:!1}:e.id===`monitor`&&t.waiting?{text:String(t.waiting),title:m(`app.web.sidebar.countWaiting`,{count:t.waiting}),error:!1}:null:null}function useChatsOn(e){let[n,r]=t(()=>e?.snapshot().enabled===!0);return f(()=>{if(e)return r(e.snapshot().enabled===!0),e.subscribe(()=>r(e.snapshot().enabled===!0))},[e]),n}function ShellSidebar({width:e,onWidth:n,drawer:r,onClose:i,runAction:s,openFile:c,focusedEditor:u,chatsStore:d,children:f}){let p=useEditorFacts(),h=o(null),g=Pe(),_=o(null),v=o(null),y=o(null),[b,x]=t(()=>loadChatsHeight(d??browserStore())),S=useChatsOn(g),available=()=>(_.current?.querySelector(`.web-sidebar__project`)?.getBoundingClientRect().height??0)+(v.current?.getBoundingClientRect().height??0),resize=(e,t,n=available())=>{let r=e===null?null:clampChats(e,n);x(r),t&&saveChatsHeight(d??browserStore(),r)},current=()=>v.current?.getBoundingClientRect().height??0;return l(a,{children:[r&&l(`div`,{class:`web-sidebar__scrim`,onPointerDown:i}),l(`aside`,{ref:_,class:`web-sidebar${r?` is-drawer`:``}`,style:r?void 0:{width:`${e}px`},"aria-label":m(`app.web.sidebar.label`),children:[l(`h2`,{class:`web-sidebar__heading type-section-heading`,children:m(`app.web.sidebar.actions`)}),l(`nav`,{class:`web-sidebar__actions`,"aria-label":m(`app.web.sidebar.actions`),children:Hi.map(e=>{let t=!!p&&p.actions.includes(e.action),n=countOf(e,p);return l(`button`,{type:`button`,class:`web-action type-body`,disabled:!t,title:t?void 0:m(`app.web.sidebar.unavailable`),"data-action":e.id,onClick:()=>{s(e.action)&&r&&i()},children:[l(Icon,{name:e.icon,className:`web-action__icon`}),l(`span`,{class:`web-action__label`,children:e.label()}),n&&l(`span`,{class:`web-action__count type-help${n.error?` is-error`:``}`,title:n.title,"aria-label":n.title,children:n.text})]},e.id)})}),l(`section`,{class:`web-sidebar__project`,children:f}),g&&l(`div`,{ref:v,class:`web-sidebar__chats${b===null?``:` is-sized`}`,style:b===null?void 0:{flexBasis:`${b}px`},children:[S&&l(`div`,{class:`web-sidebar__chats-sash`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":m(`app.web.sidebar.resizeChats`),tabIndex:0,onPointerDown:e=>{e.preventDefault(),y.current={y:e.clientY,height:current(),available:available()},e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove:e=>{let t=y.current;t&&resize(t.height-(e.clientY-t.y),!1,t.available)},onPointerUp:e=>{let t=y.current;y.current=null,t&&resize(t.height-(e.clientY-t.y),!0,t.available)},onDblClick:()=>resize(null,!0),onKeyDown:e=>{if(e.key===`ArrowUp`)resize(current()+16,!0);else if(e.key===`ArrowDown`)resize(current()-16,!0);else if(e.key===`Home`)resize(null,!0);else return;e.preventDefault()}}),l(ChatsSection,{store:g,editor:u,onOpen:r?i:void 0,onOpenFile:c})]}),!r&&l(`div`,{class:`web-sidebar__sash`,role:`separator`,"aria-orientation":`vertical`,"aria-label":m(`app.web.sidebar.resize`),"aria-valuemin":240,"aria-valuemax":400,"aria-valuenow":e,tabIndex:0,onPointerDown:t=>{t.preventDefault(),h.current={x:t.clientX,width:e},t.currentTarget.setPointerCapture?.(t.pointerId)},onPointerMove:e=>{h.current&&n(clampSidebar(h.current.width+e.clientX-h.current.x))},onPointerUp:()=>{h.current=null},onKeyDown:t=>{if(t.key===`ArrowLeft`)n(clampSidebar(e-Vi));else if(t.key===`ArrowRight`)n(clampSidebar(e+Vi));else return;t.preventDefault()}})]})]})}function relOf(e){return e.kind===`file`?e.file.rel:e.rel}function parentOf(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function nameOf(e){return e.slice(e.lastIndexOf(`/`)+1)}function insideFolder(e,t){return e===t||e.startsWith(`${t}/`)}function canMoveInto(e,t){let n=relOf(e);return!(parentOf(n)===t||e.kind===`folder`&&insideFolder(t,n))}var EntryOps=class{store;host;constructor(e,t){this.store=e,this.host=t}async fresh(){await this.store.refresh(),await this.store.refresh()}openIn(e){let t=this.store.snapshot(),n=t.order.map(e=>t.docs.get(e)).filter(e=>!!e);return e.kind===`file`?n.filter(t=>t.path===e.file.path):n.filter(t=>t.rel.startsWith(`${e.rel}/`))}unsavedIn(e){return this.openIn(e).filter(e=>W(e))}async park(e){let t=this.openIn(e);for(let e of t)if(W(this.store.doc(e.path))&&!await this.store.save(e.path))throw Error(this.store.doc(e.path)?.saveError??e.name);let n=this.store.snapshot().active;for(let e of t)this.store.close(e.path);return{docs:t,active:n}}async restore(e,t){let n=[...e.docs].sort((t,n)=>Number(t.path===e.active)-Number(n.path===e.active));for(let e of n)await this.store.open(t(e),e.kind)}async change(e,t,n){let r=await this.park(e),i;try{i=await t()}catch(e){throw await this.restore(r,e=>e.path),e}await this.fresh();let a=this.store.snapshot().listing.root,o=relOf(e),s=n(i);return await this.restore(r,t=>e.kind===`file`?oe(a,s):oe(a,`${s}${t.rel.slice(o.length)}`)),s}async rename(e,t){let n=relOf(e),r=parentOf(n);return this.change(e,()=>this.host.rename(n,t,null),()=>r===``?t:`${r}/${t}`)}async move(e,t){let n=relOf(e),r=nameOf(n);return this.change(e,()=>this.host.move(n,t,null),()=>t===``?r:`${t}/${r}`)}async duplicate(e){let t=await this.host.duplicate(e.rel);return await this.fresh(),t}async remove(e){await this.fresh();let t=relOf(e),n=e.kind===`file`?this.store.snapshot().listing.files.find(e=>e.rel===t)?.stamp??null:null;await this.host.remove(t,n);for(let t of this.openIn(e))this.store.close(t.path);await this.fresh()}async createFolder(e){await this.host.createFolder(e),await this.fresh()}},Ui=/[\\/\0-\u001f:*?"<>|]/;function nameFault(e){return e.trim()===``?m(`app.web.entry.nameEmpty`):Ui.test(e)?m(`app.web.entry.nameCharacters`):e===`.`||e===`..`||/[. ]$/.test(e)||/^ /.test(e)?m(`app.web.entry.nameEnds`):null}function messageFrom$1(e){return e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)}e(messageFrom$1,`messageFrom`);function NewFolderDialog({parent:e,onCreate:n,onClose:r}){let[i,a]=t(``),[o,s]=t(!1),[c,u]=t(null),d=O(),f=nameFault(i),create=async()=>{if(d.submit(),f)requestAnimationFrame(()=>document.querySelector(`.ui-dialog [aria-invalid="true"]`)?.focus());else{s(!0),u(null);try{await n(e===``?i:`${e}/${i}`),r()}catch(e){u(messageFrom$1(e)),s(!1)}}};return l(E,{title:m(`app.web.entry.newFolderTitle`),size:`small`,onClose:r,onSubmit:()=>void create(),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r,disabled:o},{id:`create`,label:m(`app.web.entry.createFolder`),role:`primary`,onClick:()=>void create(),busy:o}]}),children:[l(x,{label:m(`app.web.entry.name`),hint:e===``?m(`app.web.entry.insideProject`):m(`app.web.entry.inside`,{folder:e}),error:d.errorOf(`name`,f),children:e=>l(`input`,{...e,value:i,spellcheck:!1,autocomplete:`off`,onInput:e=>a(e.target.value),onBlur:()=>d.touch(`name`)})}),c&&l(S,{children:c})]})}function RenameDialog({target:e,onRename:n,onClose:r}){let i=e.kind===`file`?e.file.name:e.name,[a,o]=t(i),[s,c]=t(!1),[u,d]=t(null),f=O(),p=nameFault(a),rename=async()=>{if(f.submit(),p)requestAnimationFrame(()=>document.querySelector(`.ui-dialog [aria-invalid="true"]`)?.focus());else if(a===i)r();else{c(!0),d(null);try{await n(a),r()}catch(e){d(messageFrom$1(e)),c(!1)}}};return l(E,{title:m(`app.web.entry.renameTitle`,{name:i}),size:`small`,onClose:r,onSubmit:()=>void rename(),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:r,disabled:s},{id:`rename`,label:m(`app.web.entry.rename`),role:`primary`,onClick:()=>void rename(),busy:s}]}),children:[l(x,{label:m(`app.web.entry.renameLabel`),error:f.errorOf(`name`,p),children:t=>l(`input`,{...t,value:a,spellcheck:!1,autocomplete:`off`,ref:t=>{if(t&&!t.dataset.selected){t.dataset.selected=`yes`;let n=i.lastIndexOf(`.`);t.setSelectionRange(0,n>0&&e.kind===`file`?n:i.length)}},onInput:e=>o(e.target.value),onBlur:()=>f.touch(`name`)})}),u&&l(S,{children:u})]})}function DeleteDialog({target:e,files:n,unsaved:r,onDelete:i,onClose:a}){let[o,s]=t(!1),[c,u]=t(null),d=e.kind===`file`?e.file.name:e.name,f=e.kind===`folder`,run=async()=>{s(!0),u(null);try{await i(),a()}catch(e){u(messageFrom$1(e)),s(!1)}};return l(E,{title:m(f?`app.web.entry.deleteFolderTitle`:`app.web.entry.deleteFileTitle`,{name:d}),size:`small`,destructive:!0,onClose:a,footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:a,disabled:o},{id:`delete`,label:m(f?`app.web.entry.deleteFolder`:`app.web.entry.deleteFile`),role:`primary`,onClick:()=>void run(),busy:o}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:f?m(`app.web.entry.deleteFolderText`,{name:d,count:n}):m(`app.web.entry.deleteFileText`,{name:d})}),r>0&&l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.entry.deleteUnsaved`,{count:r})}),c&&l(S,{children:c})]})}function MoveDialog({target:e,folders:n,onMove:r,onClose:i}){let a=[``,...n].filter(t=>canMoveInto(e,t)),[o,s]=t(a[0]??``),[c,u]=t(!1),[d,f]=t(null),p=e.kind===`file`?e.file.name:nameOf(e.rel),run=async()=>{u(!0),f(null);try{await r(o),i()}catch(e){f(messageFrom$1(e)),u(!1)}};return l(E,{title:m(`app.web.entry.moveTitle`,{name:p}),size:`small`,onClose:i,onSubmit:()=>void run(),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:i,disabled:c},{id:`move`,label:m(`app.web.entry.move`),role:`primary`,onClick:()=>void run(),busy:c,disabled:a.length===0}]}),children:[a.length===0?l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.entry.noFolders`)}):l(x,{label:m(`app.web.entry.moveTo`),children:e=>l(`select`,{...e,value:o,onChange:e=>s(e.target.value),children:a.map(e=>l(`option`,{value:e,children:e===``?m(`app.web.entry.projectFolder`):e},e))})}),d&&l(S,{children:d})]})}var Wi=i(null);function useProject(){return r(Wi)}function targetOfNode(e,t){if(!e.path)return null;if(e.id.startsWith(`file:`)){let n=ce(e.path),r=t.files.find(e=>e.path===n)??t.files.find(e=>e.rel===ue(t.root,n));return r?{kind:`file`,file:r}:null}if(e.id.startsWith(`folder:`)){let n=ue(t.root,e.path);return n===``?null:{kind:`folder`,rel:n,name:n.slice(n.lastIndexOf(`/`)+1)}}return null}function copyText(e){let t=navigator.clipboard?.writeText?.(e);t?t.then(()=>L.info(m(`app.web.entry.copied`)),()=>L.error(m(`app.web.tree.copyFailed`))):L.error(m(`app.web.tree.copyFailed`))}function useEntryActions(e){let n=useProject(),r=c(()=>n?new EntryOps(n.store,n.entries):null,[n]),[i,o]=t(null),[s,u]=t(null),[d,f]=t(null),[p,h]=t(null);return c(()=>{if(!n||!r)return null;let listing=()=>n.store.snapshot().listing,report=e=>L.error(messageFrom$1(e)),run=e=>void e.catch(report),revealRel=t=>e(oe(listing().root,t)),pathOf=(e,t)=>{let n=e.kind===`file`?e.file.rel:e.rel;return t?n:oe(listing().root,n)},targetOf=e=>targetOfNode(e,listing()),itemsFor=t=>{let i=targetOf(t);if(!i)return[];let a=[];return i.kind===`folder`&&(a.push({id:`new-file`,label:m(`app.web.tree.newFile`),run:()=>n.newFile(i.rel)}),a.push({id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(i.rel)})),a.push({id:`rename`,label:m(`app.web.entry.rename`),shortcut:`F2`,separated:a.length>0,run:()=>o(i)}),i.kind===`file`&&a.push({id:`duplicate`,label:m(`app.web.entry.duplicate`),run:()=>run(r.duplicate(i.file).then(t=>e(t)))}),a.push({id:`move`,label:m(`app.web.entry.moveAction`),run:()=>h(i)}),a.push({id:`delete`,label:m(`app.web.entry.delete`),shortcut:`Del`,danger:!0,run:()=>f(i)}),a.push({id:`copy-path`,label:m(`app.web.entry.copyPath`),separated:!0,run:()=>copyText(pathOf(i,!1))}),a.push({id:`copy-relative`,label:m(`app.web.entry.copyRelative`),run:()=>copyText(pathOf(i,!0))}),i.kind===`file`&&a.push({id:`download`,label:m(`app.web.entry.download`),run:()=>n.downloadFile(i.file)}),a},backgroundItems=()=>[{id:`new-file`,label:m(`app.web.tree.newFile`),run:()=>n.newFile(``)},{id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(``)},{id:`refresh`,label:m(`app.web.tree.refresh`),separated:!0,run:()=>run(n.store.refresh())}],headerItems=e=>{let t=e?listing().files.find(t=>t.path===e):void 0;return[{id:`new-folder`,label:m(`app.web.entry.newFolder`),run:()=>u(``)},{id:`upload`,label:m(`app.web.upload.button`),run:n.upload},{id:`download-file`,label:m(`app.web.entry.downloadActive`),disabled:!t,run:()=>t&&n.downloadFile(t)},{id:`download-project`,label:m(`app.web.project.downloadZip`),run:n.downloadArchive},{id:`refresh`,label:m(`app.web.tree.refresh`),separated:!0,run:()=>run(n.store.refresh())}]},dropFolderOf=e=>{let t=targetOf(e);return t?t.kind===`folder`?t.rel:parentOf(t.file.rel):null},drop=(e,t)=>{let n=e.kind===`file`?e.file.name:e.name;r.move(e,t).then(revealRel,e=>L.error(m(`app.web.entry.moveFailed`,{name:n,reason:messageFrom$1(e)})))},t=listing().files;return{targetOf,itemsFor,backgroundItems,headerItems,dropFolderOf,canDrop:canMoveInto,drop,newFile:()=>n.newFile(``),dialogs:i||s!==null||d||p?l(a,{children:[i&&l(RenameDialog,{target:i,onRename:async e=>{revealRel(await r.rename(i,e))},onClose:()=>o(null)}),s!==null&&l(NewFolderDialog,{parent:s,onCreate:async e=>{await r.createFolder(e),revealRel(e)},onClose:()=>u(null)}),d&&l(DeleteDialog,{target:d,files:d.kind===`folder`?t.filter(e=>e.rel.startsWith(`${d.rel}/`)).length:1,unsaved:r.unsavedIn(d).length,onDelete:()=>r.remove(d),onClose:()=>f(null)}),p&&l(MoveDialog,{target:p,folders:listing().folders,onMove:async e=>{revealRel(await r.move(p,e))},onClose:()=>h(null)})]}):null}},[n,r,i,s,d,p,e])}function DraftNotice({count:e,busy:t,onRestore:n,onDiscard:r}){return l(`div`,{class:`web-shell__notice web-pane__banner is-warning`,role:`region`,"aria-label":m(`app.web.drafts.label`),children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-pane__banner-text type-body`,children:m(`app.web.drafts.found`,{count:e})}),l(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,disabled:t,onClick:n,children:m(`app.web.drafts.restore`)}),l(`button`,{type:`button`,class:`ui-button type-button`,disabled:t,onClick:r,children:m(`app.web.drafts.discard`)})]})}function SessionEnded({onRetry:e}){return l(E,{title:m(`app.web.expired.title`),size:`small`,backdrop:`keep`,onClose:e,onSubmit:e,footer:l(w,{actions:[{id:`retry`,label:m(`app.web.expired.retry`),role:`primary`,onClick:e}]}),children:[l(`p`,{class:`type-body web-dialog-text`,children:m(`app.web.expired.text`)}),l(`p`,{class:`type-help web-dialog-text`,children:m(`app.web.expired.hint`)})]})}function Welcome$1({recent:e,onOpen:t,onQuickOpen:n,onNew:r,quickKeys:i,empty:a}){return l(`div`,{class:`web-welcome`,children:[l(`p`,{class:`ui-empty__title type-body`,children:m(a?`app.web.tree.empty`:`app.web.empty.title`)}),l(`p`,{class:`ui-empty__hint type-help`,children:m(a?`app.web.tree.emptyHint`:`app.web.empty.hint`)}),l(`div`,{class:`ui-empty__actions`,children:[!a&&l(`button`,{type:`button`,class:`ui-button type-button`,onClick:n,children:i?`${m(`app.web.command.quickOpen`)} (${i})`:m(`app.web.command.quickOpen`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:r,children:m(`app.web.tree.newFile`)})]}),e.length>0&&l(`section`,{class:`web-welcome__recent`,"aria-label":m(`app.web.quick.recent`),children:[l(`h3`,{class:`web-welcome__heading type-section-heading`,children:m(`app.web.quick.recent`)}),l(`ul`,{class:`web-welcome__list`,children:e.map(e=>l(`li`,{children:l(`button`,{type:`button`,class:`web-welcome__file type-body`,title:e.rel,onClick:()=>t(e.rel),children:[l(`span`,{class:`web-welcome__name`,children:e.name}),l(`span`,{class:`web-welcome__where type-help`,children:e.rel.includes(`/`)?e.rel.slice(0,e.rel.lastIndexOf(`/`)):``})]})},e.rel))})]})]})}e(Welcome$1,`Welcome`);var Gi=[{id:`process`,kinds:[`bpmn`]},{id:`decision`,kinds:[`dmn`]},{id:`form`,kinds:[`form`]},{id:`testCase`,kinds:[`testCase`]},{id:`template`,kinds:[`template`]}];function groupOfKind(e){return Gi.find(t=>t.kinds.includes(e))?.id??`process`}var Ki=8;function placeMenu(e,t,n){let r=Math.max(Ki,Math.min(e.x,n.width-t.width-Ki)),i=e.y+t.height+Ki>n.height?Math.max(Ki,e.y-t.height):e.y;return{left:r,top:Math.max(Ki,Math.min(i,n.height-t.height-Ki))}}function nextEnabled(e,t,n){if(e.every(e=>e.disabled))return-1;let r=t;for(let t=0;t<e.length;t+=1)if(r=(r+n+e.length)%e.length,!e[r].disabled)return r;return-1}function Menu({items:e,label:n,at:r,onClose:i,returnFocusTo:a}){let s=o(null),[c,d]=t(null),[p,m]=t(()=>nextEnabled(e,-1,1)),h=o(i);h.current=i,u(()=>{let e=s.current;e&&d(placeMenu(r,{width:e.offsetWidth,height:e.offsetHeight},{width:window.innerWidth,height:window.innerHeight}))},[r.x,r.y,e.length]),f(()=>{let away=e=>{e.target instanceof Node&&!s.current?.contains(e.target)&&h.current()},blur=()=>h.current();return document.addEventListener(`pointerdown`,away,!0),window.addEventListener(`blur`,blur),window.addEventListener(`resize`,blur),()=>{document.removeEventListener(`pointerdown`,away,!0),window.removeEventListener(`blur`,blur),window.removeEventListener(`resize`,blur);let e=document.activeElement;(e===document.body||e===null||s.current?.contains(e))&&a?.isConnected&&a.focus()}},[]),f(()=>{c&&s.current?.querySelector(`[data-index="${p}"]`)?.focus()},[p,c!==null]);let choose=e=>{e.disabled||(h.current(),setTimeout(e.run,0))},onKeyDown=t=>{t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),h.current()):t.key===`ArrowDown`?(t.preventDefault(),m(t=>nextEnabled(e,t,1))):t.key===`ArrowUp`?(t.preventDefault(),m(t=>nextEnabled(e,t,-1))):t.key===`Home`?(t.preventDefault(),m(nextEnabled(e,-1,1))):t.key===`End`?(t.preventDefault(),m(nextEnabled(e,0,-1))):t.key===`Tab`&&(t.preventDefault(),h.current())};return l(`div`,{ref:s,class:`web-menu`,role:`menu`,"aria-label":n,style:{left:`${c?.left??r.x}px`,top:`${c?.top??r.y}px`,visibility:c?`visible`:`hidden`},onKeyDown,onContextMenu:e=>e.preventDefault(),children:e.map((e,t)=>l(`div`,{role:`none`,children:[e.separatorBefore&&l(`div`,{class:`web-menu__separator`,role:`separator`}),l(`button`,{type:`button`,role:e.marked===void 0?`menuitem`:`menuitemradio`,"aria-checked":e.marked===void 0?void 0:e.marked,class:`web-menu__item type-body`,"data-index":t,tabIndex:t===p?0:-1,disabled:e.disabled,onMouseMove:()=>!e.disabled&&m(t),onClick:()=>choose(e),children:[l(`span`,{class:`web-menu__label`,children:e.label}),e.keys&&l(`span`,{class:`web-menu__keys type-help`,children:e.keys})]})]},e.id))})}function tabLabels(e){let t=new Map;e.forEach(e=>t.set(e.name,(t.get(e.name)??0)+1));let n=new Map;return e.forEach(e=>{let r=e.rel.lastIndexOf(`/`),i=(r<0?``:e.rel.slice(0,r)).split(`/`).pop()??``;n.set(e.path,{name:e.name,where:(t.get(e.name)??0)>1?i:``})}),n}function scriptTabItems(e){return e.map(e=>({id:scriptPanel(e.id),label:e.title,where:``,icon:`script`,title:e.title,tabId:domId(`web-tab`,e.id),controls:domId(`web-pane`,e.id),dirty:!1,saving:!1,failed:!1,problem:e.conflict!==null,closeLabel:m(`app.web.tabs.close`,{name:e.title}),closeTitle:m(`app.web.tabs.close`,{name:e.title}),unsavedLabel:e.title,closable:!0}))}function docTabs(e,t){let n=tabLabels(e);return e.map(e=>({id:docPanel(e.path),label:n.get(e.path)?.name??e.name,where:n.get(e.path)?.where??``,icon:iconOfKind(e.kind,groupOfKind(e.kind)),title:W(e)?m(`app.web.tabs.unsaved`,{name:e.rel}):e.rel,tabId:domId(`web-tab`,e.path),controls:domId(`web-pane`,e.path),dirty:W(e),saving:e.saving,failed:!!e.saveError,problem:e.disk!==`in-sync`||!!e.saveError,closeLabel:m(`app.web.tabs.close`,{name:e.name}),closeTitle:we(m(`app.web.tabs.close`,{name:e.name}),`closeTab`,t),unsavedLabel:m(`app.web.tabs.unsaved`,{name:e.name}),closable:!0}))}function dropIndex(e,t,n){let r=n===`before`?t:t+1;return e<r?r-1:r}function domId(e,t){let n=2166136261;for(let e=0;e<t.length;e+=1)n=Math.imul(n^t.charCodeAt(e),16777619)>>>0;return`${e}-${n.toString(36)}`}function TabStrip({tabs:e,active:n,onSelect:r,onClose:i,onDropTab:a,menuFor:s,menuLabel:c,leading:u,trailing:d}){let p=o(null),[h,g]=t(null),[_,v]=t(null),[y,b]=t(!1),[x,S]=t(null);f(()=>{(p.current?.querySelector(`[aria-selected="true"]`))?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[n,e.length]),f(()=>{let e=p.current;if(!e)return;let measure=()=>b(e.scrollWidth>e.clientWidth+1);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[e.length]);let focusTab=e=>requestAnimationFrame(()=>p.current?.querySelector(`[data-panel="${CSS.escape(e)}"]`)?.focus()),openMenu=(t,n,r)=>{let i=s?.(t)??[];i.length>0&&g({items:i,at:n,label:c?.(t)??m(`app.web.tabs.menu`,{name:e.find(e=>e.id===t)?.label??``}),opener:r})},openList=t=>{let i=t.getBoundingClientRect();g({items:e.map(e=>({id:e.id,label:`${e.dirty?`● `:``}${e.label}${e.where?` ${e.where}`:``}`,marked:e.id===n,run:()=>{r(e.id),focusTab(e.id)}})),at:{x:i.right-240,y:i.bottom+4},label:m(`app.web.tabs.all`),opener:t})},move=(t,n)=>{let o=e.length-1;if(t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`){t.preventDefault();let r=t.currentTarget.getBoundingClientRect();openMenu(e[n].id,{x:r.left,y:r.bottom},t.currentTarget);return}if(t.altKey&&t.shiftKey&&(t.key===`ArrowLeft`||t.key===`ArrowRight`)){t.preventDefault(),a?.(e[n].id,t.key===`ArrowLeft`?n-1:n+1),focusTab(e[n].id);return}let s=-1;if(t.key===`ArrowRight`)s=n===o?0:n+1;else if(t.key===`ArrowLeft`)s=n===0?o:n-1;else if(t.key===`Home`)s=0;else if(t.key===`End`)s=o;else if(t.key===`Delete`&&e[n].closable){t.preventDefault(),i(e[n].id);return}else return;t.preventDefault();let c=e[s];c&&(r(c.id),focusTab(c.id))},finish=()=>{S(null),v(null),endDrag()},dropOn=t=>{let n=dragging(),r=_;if(t.preventDefault(),t.stopPropagation(),finish(),!n||!a)return;if(!r){a(n,e.length);return}let i=e.findIndex(e=>e.id===r.id);if(i<0)return;let o=e.findIndex(e=>e.id===n);a(n,o>=0?dropIndex(o,i,r.side):r.side===`before`?i:i+1)};return l(`div`,{class:`web-tabs`,children:[u,l(`div`,{ref:p,class:`web-tabs__list`,role:`tablist`,"aria-label":m(`app.web.tabs.label`),onDragOver:t=>{dragging()&&a&&(t.preventDefault(),t.stopPropagation(),t.target===t.currentTarget&&e.length>0&&v({id:e[e.length-1].id,side:`after`}))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||v(null)},onDrop:dropOn,children:e.map((e,t)=>{let o=e.id===n,c=_?.id===e.id?` is-drop-${_.side}`:``;return l(`div`,{class:`web-tabs__tab${o?` is-selected`:``}${e.problem?` has-problem`:``}${x===e.id?` is-dragging`:``}${c}`,draggable:!!a,onDragStart:t=>{beginDrag(e.id,t),S(e.id)},onDragOver:t=>{if(!dragging()||!a)return;t.preventDefault(),t.stopPropagation();let n=t.currentTarget.getBoundingClientRect(),r=t.clientX<n.left+n.width/2?`before`:`after`;(_?.id!==e.id||_.side!==r)&&v({id:e.id,side:r})},onDragEnd:finish,onContextMenu:t=>{s&&(t.preventDefault(),openMenu(e.id,{x:t.clientX,y:t.clientY},t.currentTarget))},children:[l(`button`,{type:`button`,role:`tab`,id:e.tabId,class:`web-tabs__select type-chrome`,"data-panel":e.id,"aria-selected":o,"aria-controls":e.controls,tabIndex:o?0:-1,title:e.title,onClick:()=>r(e.id),onAuxClick:t=>{t.button===1&&e.closable&&(t.preventDefault(),i(e.id))},onMouseDown:e=>{e.button===1&&e.preventDefault()},onKeyDown:e=>move(e,t),children:[l(Icon$1,{class:`web-tabs__icon`,name:e.icon}),l(`span`,{class:`web-tabs__name`,children:e.label}),e.where&&l(`span`,{class:`web-tabs__where type-chrome-small`,children:e.where})]}),e.saving&&l(`span`,{class:`web-tabs__saving`,role:`img`,"aria-label":m(`app.web.state.saving`),title:m(`app.web.state.saving`)}),!e.saving&&e.failed&&l(Icon$1,{class:`web-tabs__failed`,name:`alert`}),e.dirty&&!e.saving&&l(`span`,{class:`web-tabs__dot`,role:`img`,"aria-label":e.unsavedLabel}),e.closable&&l(`button`,{type:`button`,class:`web-tabs__close`,tabIndex:-1,"aria-label":e.closeLabel,title:e.closeTitle,onClick:()=>i(e.id),children:l(Icon$1,{name:`close`})})]},e.id)})}),y&&l(`button`,{type:`button`,class:`web-tabs__all`,"aria-haspopup":`menu`,"aria-label":m(`app.web.tabs.all`),title:m(`app.web.tabs.all`),onClick:e=>openList(e.currentTarget),children:l(Icon$1,{name:`list`})}),d,h&&l(Menu,{items:h.items,at:h.at,label:h.label,returnFocusTo:h.opener,onClose:()=>g(null)})]})}function handleFor(e,t,n,r,i){return{path:t,get rel(){return e.doc(t)?.rel??t},name:r,kind:n,scriptTabs:i,get initialText(){return e.doc(t)?.current??``},edit:n=>e.edit(t,n),onReload:n=>e.subscribeReload(t,n),save:()=>void e.save(t)}}function LazyEditor({doc:e,loaders:n,handle:r}){let i=ae(e.kind),[a,o]=t(null),[s,c]=t(null),[u,d]=t(0);if(f(()=>{let e=!0;return c(null),n[i]().then(t=>e&&o({component:t}),t=>e&&c(t instanceof Error?t.message:String(t))),()=>{e=!1}},[i,u]),s!==null)return l(A,{title:m(`app.web.pane.editorFailed`),hint:s||m(`app.web.pane.editorFailedHint`),actions:[{label:m(`app.common.retry`),run:()=>d(e=>e+1)}]});if(!a)return l(`p`,{class:`web-pane__status type-help`,role:`status`,children:m(`app.web.pane.loadingEditor`)});let p=a.component;return l(p,{handle:r})}function bannerFor(e,t,n,r){return e.disk===`deleted`?{tone:`error`,text:m(`app.web.banner.deleted`,{name:e.name}),actions:[{label:m(`app.common.save`),run:()=>void t.save(e.path)},{label:m(`app.web.banner.closeTab`),run:n}]}:e.disk===`changed`?{tone:`warning`,text:m(`app.web.banner.changed`,{name:e.name}),actions:[...r&&e.diskText!==null?[{label:m(`app.web.banner.compare`),run:r}]:[],{label:m(`app.web.banner.reload`),run:()=>t.reloadFromDisk(e.path)},{label:m(`app.web.banner.keep`),run:()=>t.keepMine(e.path)}]}:e.saveError?{tone:`error`,text:m(`app.web.banner.saveFailed`,{reason:e.saveError}),actions:[{label:m(`app.common.retry`),run:()=>void t.save(e.path)}]}:null}function DocumentPane({store:e,scripts:n,doc:r,shown:i,focused:a,loaders:s,onClose:u,onCompare:d}){let p=c(()=>handleFor(e,r.path,r.kind,r.name,n.documentScripts(r.path)),[e,n,r.path]),[h,g]=t(0),[_,v]=t(i),y=o(null),x=r.phase===`ready`?bannerFor(r,e,u,d):null;return f(()=>{i&&!_&&v(!0)},[i]),f(()=>{let e=y.current;e&&(e.inert=!i)},[i]),l(`div`,{ref:y,id:domId(`web-pane`,r.path),class:`web-pane`,role:`tabpanel`,"aria-labelledby":domId(`web-tab`,r.path),"data-path":r.path,"data-active":i?`true`:`false`,"data-focused":a?`true`:`false`,"aria-hidden":!i||void 0,children:[x&&l(`div`,{class:`web-pane__banner is-${x.tone}`,role:`alert`,children:[l(`span`,{class:`web-pane__banner-text type-body`,children:x.text}),x.actions.map(e=>l(`button`,{type:`button`,class:`ui-button type-button`,onClick:e.run,children:e.label},e.label))]}),l(`div`,{class:`web-pane__body`,children:[r.phase===`loading`&&l(`p`,{class:`web-pane__status type-help`,role:`status`,children:m(`app.web.pane.opening`,{name:r.name})}),r.phase===`failed`&&l(A,{title:m(`app.web.pane.failed`,{name:r.name}),hint:r.loadError??void 0,actions:[{label:m(`app.common.retry`),run:()=>void e.open(r.path)},{label:m(`app.web.banner.closeTab`),run:u}]}),r.phase===`ready`&&_&&l(b,{onReload:()=>g(e=>e+1),children:l(ii,{value:i&&a,children:l(LazyEditor,{doc:r,loaders:s,handle:p})})},h)]})]})}function LazyScriptPane(e){let[n,r]=t(null);return f(()=>{let e=!0;return K(()=>import(`./ScriptPane-BQLMNYzc.js`).then(t=>e&&r(()=>t.ScriptPane)),__vite__mapDeps([90,1,2,39,33,6,7,58,34,21,8,3,9,10,11,12,4,40,42,50,41,81]),import.meta.url),()=>{e=!1}},[]),n?l(n,{...e}):null}var qi=`UTF-8`;function saveStateOf(e){return!e||e.phase!==`ready`?`none`:e.saving?`saving`:e.disk===`changed`?`conflict`:e.disk===`deleted`?`deleted`:e.saveError?`failed`:W(e)?`unsaved`:`saved`}function lineEnding(e){let t=(e.match(/\r\n/g)??[]).length;return t>(e.match(/\n/g)??[]).length-t?`CRLF`:`LF`}function saveText(e,t){switch(e){case`saving`:return m(`app.web.state.saving`);case`unsaved`:return t?m(`app.web.state.unsavedAuto`,{seconds:t}):m(`app.web.state.unsaved`);case`failed`:return m(`app.web.state.failed`);case`conflict`:return m(`app.web.state.conflict`);case`deleted`:return m(`app.web.state.deleted`);case`saved`:return m(`app.web.state.saved`);default:return``}}function StatusBar({engine:e,licence:t,connection:n,doc:r,autosave:i,mac:a,onRetry:o,onShortcuts:s,onLicence:c}){let u=saveStateOf(r),d=n===`ok`;return l(`footer`,{class:`web-status`,"aria-label":m(`app.web.status.label`),children:[l(`span`,{class:`web-status__item web-status__connection type-chrome-small${d?``:` is-offline`}`,children:[l(`span`,{class:`web-status__dot`,"aria-hidden":`true`}),l(`span`,{role:`status`,children:m(d?`app.web.status.connected`:n===`denied`?`app.web.status.expired`:`app.web.status.offline`)}),!d&&n===`lost`&&l(`button`,{type:`button`,class:`web-status__link type-link`,onClick:o,children:m(`app.common.retry`)})]}),l(`span`,{class:`web-status__item web-status__item--saved type-chrome-small`,role:`status`,"aria-live":`polite`,"data-state":u,children:saveText(u,i)}),l(`span`,{class:`web-status__spacer`}),e&&l(`span`,{class:`web-status__item web-status__item--engine type-chrome-small`,title:m(`app.web.status.engine`),children:e}),t&&l(`button`,{type:`button`,class:`web-status__item web-status__licence type-chrome-small`,title:m(`app.web.status.licence`),onClick:c,children:t}),r&&r.phase===`ready`&&l(`span`,{class:`web-status__item web-status__item--detail type-chrome-small`,title:m(`app.web.status.encoding`),children:`${qi} · ${lineEnding(r.current)}`}),l(`button`,{type:`button`,class:`web-status__tool`,"aria-label":m(`app.web.shortcuts.open`),title:we(m(`app.web.shortcuts.open`),`shortcuts`,a),onClick:s,children:l(Icon$1,{name:`keyboard`})})]})}function useSession(e){let[,n]=t(0),r=e.snapshot();return f(()=>{let t=e.subscribe(()=>n(e=>e+1));return e.snapshot()!==r&&n(e=>e+1),t},[e]),r}function ProjectSwitcher({name:e,fallback:t=null}){let n=useProject();return n?l(Switcher,{project:n,name:e}):t}function Switcher({project:e,name:n}){let[r,i]=t(null),[o,s]=t(!1),c=useSession(e.session);f(()=>{o&&e.session.loadRecent().catch(()=>void 0)},[o]);let u=c.project.folder??null,d=(c.recent??[]).filter(e=>e.folder!==u).slice(0,8),close=()=>s(!1);return l(a,{children:[l(`button`,{type:`button`,ref:i,class:`web-switcher type-chrome-title`,"aria-haspopup":`dialog`,"aria-expanded":o,title:u??n,onClick:()=>s(e=>!e),children:[l(`span`,{class:`web-switcher__name`,children:n}),l(Icon$1,{class:`web-switcher__chevron`,name:`chevron`})]}),o&&l(M,{anchor:r,label:m(`app.web.project.switcher`),onClose:close,width:296,class:`web-switcher__popover`,children:[l(`div`,{class:`web-switcher__current`,children:[l(`span`,{class:`web-switcher__current-name type-body`,children:n}),u&&l(`span`,{class:`web-switcher__current-folder type-help`,children:u})]}),d.length>0&&l(a,{children:[l(`p`,{class:`web-switcher__heading type-section-heading`,children:m(`app.web.project.recent`)}),l(`ul`,{class:`web-switcher__list`,children:d.map(t=>l(`li`,{children:l(`button`,{type:`button`,class:`web-switcher__item type-body`,disabled:!t.present,title:t.present?t.folder:m(`app.web.welcome.missing`,{folder:t.folder}),onClick:()=>{close(),e.switchTo(t.folder)},children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-switcher__item-name`,children:t.name})]})},t.folder))})]}),l(`div`,{class:`web-switcher__actions`,children:[l(`button`,{type:`button`,class:`web-switcher__item type-body`,onClick:()=>{close(),e.browse()},children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-switcher__item-name`,children:m(`app.web.project.openAnother`)})]}),l(`button`,{type:`button`,class:`web-switcher__item type-body`,onClick:()=>{close(),e.closeProject()},children:[l(Icon$1,{name:`close`}),l(`span`,{class:`web-switcher__item-name`,children:m(`app.web.project.close`)})]})]})]})]})}function TitleBar({project:e,file:t,dirty:n,onSettings:r,onSearch:i,searchKeys:a,onToggleSidebar:o,sidebarKeys:s}){return l(`header`,{class:`web-title`,"aria-label":m(`app.web.titleBar.label`),children:[l(`div`,{class:`web-title__brand type-chrome-title`,children:[l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.sidebar.toggle`),title:s?`${m(`app.web.sidebar.toggle`)} (${s})`:m(`app.web.sidebar.toggle`),onClick:o,children:l(Icon$1,{name:`panel`})}),l(`span`,{class:`web-title__dot`,"aria-hidden":`true`}),l(`span`,{class:`web-title__name`,children:m(`app.name`)})]}),l(`div`,{class:`web-title__centre`,children:[l(ProjectSwitcher,{name:e,fallback:l(`span`,{class:`web-title__project type-chrome-title`,title:e,children:e})}),t&&l(`span`,{class:`web-title__file type-chrome`,title:t,children:[n&&l(`span`,{class:`web-title__unsaved`,"aria-label":m(`app.web.tree.unsaved`)}),t]})]}),l(`div`,{class:`web-title__actions`,children:[l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.command.quickOpen`),title:a?`${m(`app.web.command.quickOpen`)} (${a})`:m(`app.web.command.quickOpen`),onClick:i,children:l(Icon$1,{name:`search`})}),l(`button`,{type:`button`,class:`web-title__tool`,"aria-label":m(`app.web.settings.title`),title:m(`app.web.settings.title`),onClick:r,children:l(Icon$1,{name:`settings`})})]})]})}function UnsavedDialog({name:e,busy:t,onSave:n,onDiscard:r,onCancel:i}){return l(E,{title:m(`app.web.unsaved.title`,{name:e}),size:`small`,destructive:!0,onClose:i,footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:i,disabled:t},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:r,disabled:t},{id:`save`,label:m(`app.common.save`),role:`primary`,onClick:n,busy:t}]}),children:l(`p`,{class:`type-body`,children:m(`app.web.unsaved.text`,{name:e})})})}var Ji={off:he.OFF,bottom:he.BOTTOM,sidebar:he.SIDEBAR};function hostPreferences(){return{aiChat:()=>Ne(B().aiChat),setAiChat:e=>V({aiChat:Ji[e]}),subscribe:H}}function useCloseQueue(e,r){let[i,a]=t([]),[o,s]=t(!1),c=n(t=>{let n=t;for(;n.length>0;){let[t,...i]=n;if(!e.doc(t))n=i;else if(W(e.doc(t)))break;else r(t),n=i}a(n)},[e,r]),l=n(e=>c(e),[c]),u=i[0]??null;return{head:u,busy:o,request:l,cancel:()=>a([]),discard:()=>{u!==null&&(r(u),c(i.slice(1)))},save:()=>{u!==null&&(s(!0),e.save(u).then(e=>{s(!1),e?(r(u),c(i.slice(1))):a([])}))}}}function useMedia(e,n=!1){let read=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(e).matches:n,[r,i]=t(read);return f(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),update=()=>i(t.matches);return update(),t.addEventListener?.(`change`,update),()=>t.removeEventListener?.(`change`,update)},[e]),r}var Yi=3e3,Xi=3e4;function pollDelay(e,t){return Math.min(e*2**Math.min(t,5),Math.max(e,Xi))}function useWindowEvent(e,t,n=!1){let r=o(t);r.current=t,f(()=>{let handler=e=>r.current(e);return window.addEventListener(e,handler,n),()=>window.removeEventListener(e,handler,n)},[e,n])}function usePolling(e,t){f(()=>{let n,r=!1,i=0,visible=()=>document.visibilityState===`visible`,schedule=()=>{!r&&visible()&&(n&&clearTimeout(n),n=setTimeout(tick,pollDelay(t,i)))},tick=async()=>{visible()&&await e.refresh(),i=e.snapshot().connection===`ok`?0:i+1,schedule()},wake=()=>{n&&clearTimeout(n),n=void 0,visible()&&!r&&e.refresh().then(()=>{i=e.snapshot().connection===`ok`?0:i+1,schedule()})};return wake(),document.addEventListener(`visibilitychange`,wake),window.addEventListener(`focus`,wake),()=>{r=!0,n&&clearTimeout(n),document.removeEventListener(`visibilitychange`,wake),window.removeEventListener(`focus`,wake)}},[e,t])}function useStore(e){let[,n]=t(0),r=e.snapshot();return f(()=>{let t=e.subscribe(()=>n(e=>e+1));return e.snapshot()!==r&&n(e=>e+1),t},[e]),r}var Zi=null;function registerConnectionsOpener(e){return Zi=e,()=>{Zi===e&&(Zi=null)}}function openConnectionsScreen(){return Zi?(Zi(),!0):!1}var Qi=null;function registerAiAgentsOpener(e){return Qi=e,()=>{Qi===e&&(Qi=null)}}var $i=null;function registerMigrationOpener(e){return $i=e,()=>{$i===e&&($i=null)}}function openMigrationScreen(){return $i?($i(),!0):!1}var ea=null;function registerPolicyOpener(e){return ea=e,()=>{ea===e&&(ea=null)}}var ta=null;function registerDriftOpener(e){return ta=e,()=>{ta===e&&(ta=null)}}function suggestsNextBlock(){return B().suggestNextBlock!==!1}function suggestsFields(){return B().suggestions!==!1}var na=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),ra=!1,ia=new Set;function toggleFocusCanvas(){ra=!ra;for(let e of ia)e(ra)}function useFocusCanvas(){let[e,n]=t(ra);return f(()=>(ia.add(n),n(ra),()=>{ia.delete(n)}),[]),e}function useFocusCanvasShortcut(){let e=o(null),t=useEditorActive();f(()=>{if(!t)return;let onKey=t=>{if(!je(t,`Mod+Alt+Shift+M`,na))return;t.preventDefault();let n=Date.now();isRepeatOfPress(e.current,n)||(e.current=n,toggleFocusCanvas())};return window.addEventListener(`keydown`,onKey),()=>window.removeEventListener(`keydown`,onKey)},[t])}var aa={newFile:()=>K(()=>import(`./NewFileDialog-Dev41oA1.js`).then(e=>e.NewFileDialog),__vite__mapDeps([91,1,2,6,7,14,9,4,15,85,17]),import.meta.url),quick:()=>K(()=>import(`./QuickOpen-ps-rMjiS.js`).then(e=>e.QuickOpen),__vite__mapDeps([92,1,2,6,7]),import.meta.url),shortcuts:()=>K(()=>import(`./ShortcutsDialog-DLXnv4Vm.js`).then(e=>e.ShortcutsDialog),__vite__mapDeps([93,1,6,7,14,2,9,4,15,28,12,16,94,27,29]),import.meta.url),settings:()=>K(()=>import(`./SettingsDialog-DI0vZ6Ay.js`).then(e=>e.SettingsDialog),__vite__mapDeps([95,1,2,6,7,14,9,4,15]),import.meta.url),agents:()=>K(()=>import(`./AgentsDialog-DbY2O6O5.js`).then(e=>e.AgentsDialog),__vite__mapDeps([96,1,2,6,7,14,9,4,15,28,12,16]),import.meta.url),connections:()=>K(()=>import(`./ConnectionsDialog-BaYtHD5h.js`).then(e=>e.ConnectionsDialog),__vite__mapDeps([97,1,2,6,7,14,9,4,15,60,53,19,20,21,11,17,54,37,23,69,25,3,82]),import.meta.url),aiagents:()=>K(()=>import(`./AgentsDialog-BMWv3Gyk.js`).then(e=>e.AiAgentsDialog),__vite__mapDeps([98,1,2,6,7,14,9,4,15,60,53,19,20,21,11,17,54,37,23,70,99,82]),import.meta.url),migration:()=>K(()=>import(`./MigrationDialog-DA3Vrzgw.js`).then(e=>e.MigrationDialog),__vite__mapDeps([100,1,2,6,7,14,9,4,15,59,10,11,19,20,21,17,53,54,37,23,60,61,22,24,18,3,25,26,62,46,101]),import.meta.url),policy:()=>K(()=>import(`./PolicyDialog-qR19Csji.js`).then(e=>e.PolicyDialog),__vite__mapDeps([102,1,6,7,14,2,9,4,15]),import.meta.url),drift:()=>K(()=>import(`./DriftDialog-dIbCbSK2.js`).then(e=>e.DriftDialog),__vite__mapDeps([103,1,2,6,7,14,9,4,15,3]),import.meta.url),conflict:()=>K(()=>import(`./ConflictDialog-DfFp8F7n.js`).then(e=>e.ConflictDialog),__vite__mapDeps([104,1,2,6,7,14,9,4,15]),import.meta.url)};function useLazy(e,n){let[r,i]=t(null);return f(()=>{if(!n||r)return;let t=!0;return aa[e]().then(e=>t&&i({component:e})),()=>{t=!1}},[n]),r?.component??null}var oa=`(width < 900px)`;function groupWidth(e){let t=document.querySelector(`[data-group="${e}"]`)?.getBoundingClientRect().width??0;return t>0?t:void 0}function syncAddress(e){try{let t=new URL(window.location.href);e?t.searchParams.set(`file`,e):t.searchParams.delete(`file`);let n=`${t.pathname}${t.search}${t.hash}`;n!==`${window.location.pathname}${window.location.search}${window.location.hash}`&&window.history.replaceState(window.history.state,``,n)}catch{}}function engineName(e){if(!e)return null;let t=/^CAMUNDA_(\d+)$/.exec(e);return t?`Camunda ${t[1]}`:e.charAt(0)+e.slice(1).toLowerCase().replace(/_/g,` `)}function WebShell({store:e,scripts:r,loaders:i,engine:a,deepLink:s,toolWindow:u=null,pollMs:d=Yi,env:p}){let h=c(()=>({...On,...p}),[p]),g=useStore(e),_=useStore(r.tabs),v=useMedia(oa),[y,b]=t(!1),[x,S]=t(null),[C,w]=t(null),[T,E]=t(null),[D,O]=t(!1),[k,A]=t(()=>h.sidebar()),[j,M]=t(defaultDock),[N,P]=t(gn),[F,I]=t([]),[L,R]=t(!1),[z,B]=t(!1),[ee,H]=t(null),[U,te]=t(()=>h.autosave()),[ie,ae]=t(()=>h.theme()),[se,le]=t(null),ue=o(!1),K=o(new Set),de=useLazy(`newFile`,y),fe=useLazy(`quick`,x!==null||g.listed),pe=useLazy(`shortcuts`,C===`shortcuts`),me=useLazy(`settings`,C===`settings`),he=useLazy(`agents`,C===`agents`),ge=useLazy(`connections`,C===`connections`),q=useLazy(`aiagents`,C===`aiagents`),_e=useLazy(`migration`,C===`migration`),ve=useLazy(`policy`,C===`policy`),ye=useLazy(`drift`,C===`drift`),be=useLazy(`conflict`,T!==null),Se=g.order.map(e=>g.docs.get(e)).filter(Boolean),Oe=c(()=>new Set(g.order.filter(e=>W(g.docs.get(e)))),[g.docs,g.order]),Y=g.listing.root,ke=g.active?g.docs.get(g.active)??null:null;usePolling(e,d);let[Ae]=t(()=>Q().agentsHost?.()??null);f(()=>Le(()=>w(`agents`)),[]),f(()=>registerConnectionsOpener(()=>w(`connections`)),[]),f(()=>registerAiAgentsOpener(()=>w(`aiagents`)),[]),f(()=>registerMigrationOpener(()=>w(`migration`)),[]),f(()=>registerPolicyOpener(()=>w(`policy`)),[]),f(()=>registerDriftOpener(()=>w(`drift`)),[]),f(()=>{e.setAutosave(U)},[e,U]),f(()=>{let e=!0,read=()=>void h.licence().then(t=>e&&le(t));read();let t=onLicenceChange(read);return()=>{e=!1,t()}},[h]),f(()=>{if(ue.current||!g.listed)return;ue.current=!0;let t=h.loadSession(g.listing.root);if(t){let n=restoreSession(e,g.listing,t);n.dock&&M(n.dock),(n.toolOpen.length>0||n.toolShut.length>0)&&P(expansionOf(n.toolOpen,n.toolShut))}let n=s?re(s):null;if(n){let t=g.listing.files.find(e=>e.rel===n);e.open(t?.path??oe(g.listing.root,n),t?.kind)}B(!0);let r=h.journal;r&&r.orphans(g.listing.root).then(e=>I(e))},[g.listed]),f(()=>{if(!z)return;let e=K.current;K.current=new Set,M(t=>syncDocs(t,g.order,e,groupWidth(t.focus)))},[g.order,z]),f(()=>{let e=g.active;e&&M(t=>activate(t,docPanel(e)))},[g.active,g.order]);let sessionNow=()=>sessionOf(e.snapshot(),{dock:j,tool:N});f(()=>{M(e=>syncScripts(e,_.tabs.map(e=>e.id)))},[_.tabs]),f(()=>{let e=_.focus;e&&M(t=>activate(t,scriptPanel(e)))},[_.focus]);let je=o([]);f(()=>{let e=je.current.filter(e=>!g.order.includes(e));je.current=g.order,e.forEach(e=>void r.closeDocument(e))},[g.order,r]),f(()=>{if(!z||!Y)return;let e=setTimeout(()=>h.saveSession(Y,sessionNow()),h.sessionDelayMs);return()=>clearTimeout(e)},[z,Y,g.order,g.active,g.recent,j,N]),f(()=>{let e=g.active?g.docs.get(g.active):void 0;syncAddress(e?e.rel:null)},[g.active]);let Me=Oe.size>0;f(()=>{showTitle(titleFor(g.active?g.docs.get(g.active)?.name??null:null,Y?G(Y):m(`app.web.tree.project`),Me)),showFavicon(Me)},[g.active,g.docs,Y,Me]),f(()=>(showThemeColour(),window.addEventListener(`bpmn-theme-changed`,showThemeColour),()=>window.removeEventListener(`bpmn-theme-changed`,showThemeColour)),[]),useWindowEvent(`beforeunload`,t=>{e.dirtyPaths().length!==0&&(t.preventDefault(),t.returnValue=``)}),useWindowEvent(`pagehide`,()=>{h.journal?.flush(),z&&Y&&h.saveSession(Y,sessionNow())}),f(()=>{let hidden=()=>{document.visibilityState===`hidden`&&h.journal?.flush()};return document.addEventListener(`visibilitychange`,hidden),()=>document.removeEventListener(`visibilitychange`,hidden)},[h]);let Ne=useCloseQueue(e,n(t=>e.close(t),[e])),X=Ne.head?g.docs.get(Ne.head):void 0,closeTabs=e=>Ne.request(e),Fe=n(t=>{M(t);let n=pathOfPanel(focused$1(t)?.active??``);n&&n!==e.snapshot().active&&e.activate(n)},[e]),Ie=n((t,n=!1)=>{if(n){let e=docPanel(t.path);has(j,e)?M(moveTab(j,e,{group:j.focus,zone:`right`,width:groupWidth(j.focus)})):K.current.add(t.path)}e.open(t.path,t.kind),v&&O(!1)},[e,v,j]),Re=n(async(t,n)=>{let r=await e.create(t,n);r&&await e.open(r)},[e]),ze=n(e=>{A(e),h.setSidebar(e)},[h]),Be=n(()=>{v?O(e=>!e):ze({...k,open:!k.open})},[v,k,ze]),Ve=useFocusCanvas(),Ue=n(()=>{let t=e.snapshot().active?e.doc(e.snapshot().active)?.rel??null:null;t&&Pe()?.focusInput(t)},[e]),We=g.active?g.docs.get(g.active)?.rel??null:null,Ge=n(()=>{let e=focused$1(j),t=e?.active??null;e&&t&&e.tabs.length>1?Fe(moveTab(j,t,{group:e.id,zone:`right`,width:groupWidth(e.id)})):S({initial:``,side:!0})},[j,Fe]),Ke=n(()=>{leaves(j.root).length>1?Fe(mergeGroups(j)):Ge()},[j,Fe,Ge]),qe=n(async()=>{let t=e.snapshot().active;t&&!await e.save(t)&&e.doc(t)?.disk===`changed`&&E(t)},[e]),Z=n(async()=>{await e.saveAll();let t=e.snapshot().order.find(t=>e.doc(t)?.disk===`changed`);t&&E(t)},[e]),Je=n(t=>{let n=focused$1(j);if(!n)return;let r=n.tabs.map(pathOfPanel).filter(e=>e!==null),i=pathOfPanel(n.active??``);if(r.length<2||!i)return;let a=r.indexOf(i);e.activate(r[(a+t+r.length)%r.length])},[e,j]),Ye=n(e=>{v?O(!0):k.open||ze({...k,open:!0}),H(t=>({path:ce(e),serial:(t?.serial??0)+1}))},[v,k,ze]),Xe=useEntryActions(Ye),$=n(t=>{let n=e.snapshot();switch(t){case`quickOpen`:S({initial:``,side:!1});return;case`actions`:h.runEditorAction(`palette`)||S({initial:`>`,side:!1});return;case`save`:qe();return;case`saveAll`:Z();return;case`closeTab`:n.active&&closeTabs([n.active]);return;case`nextTab`:Je(1);return;case`previousTab`:Je(-1);return;case`toggleSidebar`:Be();return;case`askAgent`:Ue();return;case`splitView`:Ke();return;case`newFile`:b(!0);return;case`shortcuts`:w(`shortcuts`);return;case`settings`:w(`settings`);return;default:{let n=(focused$1(j)?.tabs??[]).map(pathOfPanel).filter(e=>e!==null),r=xe(t,n.length);r!==null&&e.activate(n[r])}}},[e,h,j,qe,Z,Je,Be,Ue,Ke]);useWindowEvent(`keydown`,e=>{if(e.isComposing||e.repeat)return;let t=Te(e,h.mac);if(t){let n=e.target instanceof Element?e.target:null;if(document.querySelector(`.ui-dialog-overlay, .palette-overlay`)||De(n)||n?.closest(`.djs-container`))return;runEditCommand(t,{focus:n,textSelected:!1})&&e.preventDefault();return}let n=Ce(e,h.mac);n&&(e.preventDefault(),document.querySelector(`.ui-dialog-overlay, .palette-overlay`)||$(n))},!0);let Ze=c(()=>[{id:`newFile`,title:m(`app.web.command.newFile`),keys:J(`newFile`,h.mac),run:()=>$(`newFile`)},{id:`save`,title:m(`app.web.command.save`),keys:J(`save`,h.mac),run:()=>$(`save`)},{id:`saveAll`,title:m(`app.web.command.saveAll`),keys:J(`saveAll`,h.mac),run:()=>$(`saveAll`)},{id:`closeTab`,title:m(`app.web.command.closeTab`),keys:J(`closeTab`,h.mac),run:()=>$(`closeTab`)},{id:`closeAll`,title:m(`app.web.command.closeAll`),run:()=>closeTabs(e.snapshot().order)},{id:`splitView`,title:leaves(j.root).length>1?m(`app.web.command.closeSplit`):m(`app.web.command.splitView`),keys:J(`splitView`,h.mac),run:()=>$(`splitView`)},{id:`toggleSidebar`,title:m(`app.web.command.toggleSidebar`),keys:J(`toggleSidebar`,h.mac),run:()=>$(`toggleSidebar`)},...He()&&We?[{id:`askAgent`,title:m(`app.web.command.askAgent`),keys:J(`askAgent`,h.mac),run:()=>$(`askAgent`)}]:[],{id:`resetLayout`,title:m(`app.web.command.resetLayout`),run:()=>M(syncDocs(defaultDock(),e.snapshot().order))},{id:`actions`,title:m(`app.web.command.actions`),keys:J(`actions`,h.mac),run:()=>$(`actions`)},{id:`settings`,title:m(`app.web.command.settings`),run:()=>$(`settings`)},{id:`agents`,title:m(`app.web.command.agents`),run:()=>w(`agents`)},{id:`connections`,title:m(`app.web.command.connections`),run:()=>w(`connections`)},{id:`aiagents`,title:m(`app.web.command.aiAgents`),run:()=>w(`aiagents`)},{id:`migration`,title:m(`app.web.command.migration`),run:()=>w(`migration`)},{id:`policy`,title:m(`app.web.command.policy`),run:()=>w(`policy`)},{id:`drift`,title:m(`app.web.command.drift`),run:()=>w(`drift`)},{id:`shortcuts`,title:m(`app.web.command.shortcuts`),keys:J(`shortcuts`,h.mac),run:()=>$(`shortcuts`)},{id:`reconnect`,title:m(`app.web.command.reconnect`),run:()=>void e.refresh()}],[h.mac,$,j,e,We]),Qe=c(()=>new Map([...docTabs(Se,h.mac),...scriptTabItems(_.tabs)].map(e=>[e.id,e])),[g.docs,g.order,h.mac,_.tabs]),selectPanel=t=>{let n=pathOfPanel(t),i=scriptIdOf(t);M(e=>activate(e,t)),n&&e.activate(n),i&&r.tabs.focus(i)},closePanelTab=e=>{let t=pathOfPanel(e),n=scriptIdOf(e);t&&closeTabs([t]),n&&r.closed(n)},$e=n(t=>{let n=pathOfPanel(t),r=groupOf(j,t),i=r?r.tabs.length>1:!1;if(n===null)return[];let{order:a}=e.snapshot(),o=a.indexOf(n),s=e.doc(n);return[{id:`close`,label:m(`app.web.menu.close`),keys:J(`closeTab`,h.mac),run:()=>closeTabs([n])},{id:`others`,label:m(`app.web.menu.closeOthers`),disabled:a.length<2,run:()=>closeTabs(a.filter(e=>e!==n))},{id:`right`,label:m(`app.web.menu.closeRight`),disabled:o<0||o===a.length-1,run:()=>closeTabs(a.slice(o+1))},{id:`all`,label:m(`app.web.menu.closeAll`),run:()=>closeTabs(a)},{id:`splitRight`,label:m(`app.web.menu.splitRight`),separatorBefore:!0,disabled:!i||!roomToSplit(r?groupWidth(r.id):void 0,`right`),run:()=>r&&Fe(moveTab(j,t,{group:r.id,zone:`right`,width:groupWidth(r.id)}))},{id:`splitDown`,label:m(`app.web.menu.splitDown`),disabled:!i,run:()=>r&&Fe(moveTab(j,t,{group:r.id,zone:`bottom`}))},{id:`reveal`,label:m(`app.web.menu.reveal`),run:()=>Ye(n)},{id:`copyPath`,label:m(`app.web.menu.copyPath`),separatorBefore:!0,run:()=>void h.copy(n).then(e=>h.notify(m(e?`app.web.menu.copied`:`app.web.menu.copyFailed`),!e))},{id:`copyRel`,label:m(`app.web.menu.copyRelative`),run:()=>void h.copy(s?.rel??n).then(e=>h.notify(m(e?`app.web.menu.copied`:`app.web.menu.copyFailed`),!e))}]},[e,h,j,Fe,Ye]),restoreDrafts=async()=>{R(!0);let t=new Map(e.snapshot().listing.files.map(e=>[e.path,e]));for(let n of F){let r=t.get(n.path);r?(await e.open(n.path,r.kind),e.applyDraft(n.path,n)):e.adoptMissing(n.path,n.path.endsWith(`.dmn`)?`dmn`:n.path.endsWith(`.form`)?`form`:`bpmn`,n)}I([]),R(!1)},discardDrafts=async()=>{R(!0),await h.journal?.discard(F),I([]),R(!1)},openPath=t=>{if(!t)return;let n=g.listing.files.find(e=>e.rel===t);e.open(n?.path??oe(g.listing.root,t),n?.kind)};useDesktopCommands({"file.newFile":()=>$(`newFile`),"file.save":()=>$(`save`),"file.closeTab":()=>{let t=e.snapshot().active;t?closeTabs([t]):Ee()?.closeWindow()},"edit.undo":()=>replayEdit(`undo`),"edit.redo":()=>replayEdit(`redo`),"edit.cut":()=>replayEdit(`cut`),"edit.copy":()=>replayEdit(`copy`),"edit.paste":()=>replayEdit(`paste`),"edit.selectAll":()=>replayEdit(`selectAll`),"file.openPath":openPath,"view.toggleTree":()=>$(`toggleSidebar`),"view.toggleSidebar":()=>{let e=Ee()?.platform===`darwin`;document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`'`,code:`Quote`,altKey:!0,metaKey:e,ctrlKey:!e,bubbles:!0,cancelable:!0}))},"help.shortcuts":()=>$(`shortcuts`)});let et=Y?G(Y):m(`app.web.tree.project`),tt=T?g.docs.get(T):void 0;f(()=>{T&&g.docs.get(T)?.disk!==`changed`&&E(null)},[T,g.docs]),f(()=>{v||O(!1)},[v]);let nt=g.recent.map(e=>g.listing.files.find(t=>t.rel===e)).filter(e=>!!e&&!g.docs.has(e.path)).slice(0,6).map(e=>({rel:e.rel,name:e.name})),openRel=e=>{let t=g.listing.files.find(t=>t.rel===e);t&&Ie(t)},rt=c(()=>new Map(leaves(j.root).map(e=>[e.active,e.id])),[j]),content=t=>{let n=rt.get(t),a=scriptIdOf(t);if(a!==null){let e=_.tabs.find(e=>e.id===a);return e?l(LazyScriptPane,{hub:r,tab:e,shown:!!n,focused:n===j.focus},e.id):null}let o=pathOfPanel(t),s=o?g.docs.get(o):void 0;return s?l(DocumentPane,{store:e,scripts:r,doc:s,shown:!!n,focused:n===j.focus,loaders:i,onClose:()=>closeTabs([s.path]),onCompare:()=>E(s.path)}):null},it=leaves(j.root).at(-1)?.id??null,header=e=>{let t=e.tabs.map(e=>Qe.get(e)).filter(e=>!!e),n=leaves(j.root).length>1;return l(TabStrip,{tabs:t,active:e.active,onSelect:selectPanel,onClose:closePanelTab,onDropTab:(t,n)=>Fe(moveTab(j,t,{group:e.id,zone:`center`,index:n})),menuFor:$e,trailing:e.id===it&&!v&&Se.length>0?l(`button`,{type:`button`,class:`web-tabs__split${n?` is-on`:``}`,"aria-pressed":n,"aria-label":m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),title:we(m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),`splitView`,h.mac),onClick:Ke,children:l(Icon$1,{name:`split`})}):null})},empty=()=>l(Welcome$1,{recent:nt,onOpen:openRel,onQuickOpen:()=>S({initial:``,side:!1}),onNew:()=>b(!0),quickKeys:J(`quickOpen`,h.mac),empty:g.listed&&g.listing.files.length===0}),label=e=>{let t=pathOfPanel(e);return(t?g.docs.get(t)?.name:null)??``};return l(`div`,{class:`web-app`,children:[l(`a`,{class:`web-skip type-body`,href:`#web-main`,onClick:e=>{e.preventDefault(),document.getElementById(`web-main`)?.focus()},children:m(`app.web.skip`)}),l(TitleBar,{project:et,file:ke?.name??null,dirty:!!ke&&W(ke),onSettings:()=>w(`settings`),onSearch:()=>$(`quickOpen`),searchKeys:J(`quickOpen`,h.mac)??``,onToggleSidebar:Be,sidebarKeys:J(`toggleSidebar`,h.mac)??``}),l(`div`,{class:`web-shell${v?` is-narrow`:``}`,children:[!Ve&&(v?D:k.open)&&l(ShellSidebar,{width:k.width,onWidth:e=>ze({...k,width:e}),drawer:v,onClose:()=>O(!1),runAction:h.runEditorAction,focusedEditor:We,openFile:openPath,children:u&&l(ToolPanel,{store:u,expansion:N,onExpansion:P,onUnlock:h.showLicence,mac:h.mac,entries:Xe,activePath:ke&&!ne(ke.kind)?ce(ke.path):null,reveal:ee,newKeys:J(`newFile`,h.mac)})}),l(`main`,{id:`web-main`,class:`web-workspace`,tabIndex:-1,"aria-label":m(`app.web.main.label`),children:[g.connection===`lost`&&l(`div`,{class:`web-shell__connection`,role:`alert`,children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-shell__connection-text type-body`,children:m(`app.web.connection.lost`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>void e.refresh(),children:m(`app.common.retry`)})]}),F.length>0&&l(DraftNotice,{count:F.length,busy:L,onRestore:()=>void restoreDrafts(),onDiscard:()=>void discardDrafts()}),l(DockView,{dock:j,onDock:Fe,header,content,empty,label,single:v})]})]}),l(StatusBar,{engine:engineName(a),licence:se,connection:g.connection,doc:ke,autosave:U,mac:h.mac,onRetry:()=>void e.refresh(),onShortcuts:()=>w(`shortcuts`),onLicence:h.showLicence}),y&&de&&l(de,{files:g.listing.files,engine:a,onCreate:Re,onClose:()=>b(!1)}),x&&fe&&l(fe,{files:g.listing.files,recent:g.recent,open:new Set(g.order),commands:Ze,initial:x.initial,side:x.side,onClose:()=>S(null),onPick:(e,t)=>{S(null),Ie(e,t)},onRun:e=>{S(null),setTimeout(e.run,0)}}),C===`shortcuts`&&pe&&l(pe,{mac:h.mac,onClose:()=>w(null)}),C===`settings`&&me&&l(me,{theme:ie,autosave:U,onAgents:()=>w(`agents`),onTheme:e=>{ae(e),h.setTheme(e)},onAutosave:e=>{te(e),h.setAutosave(e)},suggestNextBlock:suggestsNextBlock(),onSuggestNextBlock:e=>V({suggestNextBlock:e}),suggestions:suggestsFields(),onSuggestions:e=>V({suggestions:e}),onClose:()=>w(null)}),C===`agents`&&he&&Ae&&l(he,{host:Ae,preferences:hostPreferences(),onClose:()=>w(null)}),C===`connections`&&ge&&l(ge,{onClose:()=>w(null)}),C===`aiagents`&&q&&l(q,{onClose:()=>w(null)}),C===`migration`&&_e&&l(_e,{onClose:()=>w(null)}),C===`policy`&&ve&&l(ve,{onClose:()=>w(null)}),C===`drift`&&ye&&l(ye,{onClose:()=>w(null)}),tt&&tt.diskText!==null&&be&&!y&&!X&&C===null&&l(be,{name:tt.name,mine:tt.current,theirs:tt.diskText,onClose:()=>E(null),onTakeTheirs:()=>{e.reloadFromDisk(tt.path),E(null)},onKeepMine:()=>{e.keepMine(tt.path),E(null)}}),X&&l(UnsavedDialog,{name:X.name,busy:Ne.busy,onCancel:Ne.cancel,onDiscard:Ne.discard,onSave:Ne.save}),g.connection===`denied`&&l(SessionEnded,{onRetry:()=>void e.refresh()})]})}async function answered(e){try{return await e}catch(e){throw Error(await q(e))}}function webHost(e){return{current:()=>answered(e.getCurrentProject()),open:t=>answered(e.openProject({openProjectRequest:{folder:t}})),close:()=>answered(e.closeProject()),recent:async()=>(await answered(e.listRecentProjects())).projects,forget:async t=>(await answered(e.forgetRecentProject({openProjectRequest:{folder:t}}))).projects,folders:(t,n)=>answered(e.listFolders({folderListRequest:{path:t??null,hidden:n}})),createFolder:t=>answered(e.createFolder({createFolderRequest:{path:t}})),rename:async(t,n,r)=>(await answered(e.renameEntry({renameEntryRequest:{path:t,name:n,stamp:r}}))).path,move:async(t,n,r)=>(await answered(e.moveEntry({moveEntryRequest:{path:t,folder:n,stamp:r}}))).path,duplicate:async t=>(await answered(e.duplicateEntry({duplicateEntryRequest:{path:t}}))).path,archiveUrl:async t=>{let n=await e.downloadProjectArchiveRequestOpts({expect:t??void 0}),r=new URLSearchParams;return Object.entries(n.query??{}).forEach(([e,t])=>r.set(e,t)),`${n.path}${r.size>0?`?${r}`:``}`},remove:(t,n)=>answered(e.deleteEntry({deleteEntryRequest:{path:t,stamp:n}}))}}function scriptOf(e){let{path:t,slot:n,language:r,script:i,title:a}=e;return!t||!n||r===void 0||i===void 0||a===void 0?null:{path:t,slot:n,language:r,text:i,title:a,variables:e.variables??[]}}var sa={phase:`loading`,revision:null,roots:[],toolbar:[],codeLinks:`open`,truncated:!1,error:null,busy:null};function statusOf(e){return e?.response?.status??null}var ToolWindowStore=class{state=sa;listeners=new Set;api;effects;pollMs;attached=0;timer;flight=null;again=!1;failures=0;controller=null;constructor(e,t,n=Yi){this.api=e,this.effects=t,this.pollMs=n}snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}set(e){this.state={...this.state,...e},[...this.listeners].forEach(e=>e())}attach(){this.attached+=1,this.attached===1&&(document.addEventListener(`visibilitychange`,this.wake),window.addEventListener(`focus`,this.wake),this.refresh().then(()=>this.schedule()));let e=!1;return()=>{e||(e=!0,--this.attached,this.attached>0||(document.removeEventListener(`visibilitychange`,this.wake),window.removeEventListener(`focus`,this.wake),this.timer&&clearTimeout(this.timer),this.timer=void 0,this.controller?.abort()))}}wake=()=>{this.attached!==0&&document.visibilityState===`visible`&&(this.timer&&clearTimeout(this.timer),this.timer=void 0,this.refresh().then(()=>this.schedule()))};schedule(){this.attached!==0&&document.visibilityState===`visible`&&(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.refresh().then(()=>this.schedule())},pollDelay(this.pollMs,this.failures)))}refresh(){if(this.flight)return this.again=!0,this.flight;let e=this.load().finally(()=>{this.flight=null,this.again&&this.attached>0&&(this.again=!1,this.refresh()),this.again=!1});return this.flight=e,e}async load(){let e=new AbortController;this.controller=e;try{let t=await this.api.snapshot(this.state.revision,e.signal);if(this.failures=0,t.unchanged&&this.state.revision===t.revision){(this.state.phase!==`ready`||this.state.error)&&this.set({phase:`ready`,error:null});return}this.set({phase:`ready`,revision:t.revision,roots:t.roots??[],toolbar:t.toolbar??[],codeLinks:t.codeLinks===`locked`?`locked`:`open`,truncated:t.truncated===!0,error:null})}catch(t){if(e.signal.aborted)return;if(this.failures+=1,this.state.revision!==null&&statusOf(t)===null){this.state.error!==null&&this.set({error:null});return}this.set({phase:this.state.revision===null?`error`:`ready`,error:await q(t)})}finally{this.controller===e&&(this.controller=null)}}async run(e){let t=this.state.revision;if(t!==null&&this.state.busy===null){this.set({busy:e});try{let n;try{n=await this.api.perform(e,t)}catch(e){statusOf(e)===409?(await this.refresh(),this.effects.notify(m(`app.web.toolPanel.stale`),!0)):this.effects.notify(await q(e),!0);return}await this.carry(n)}finally{this.set({busy:null})}}}async carry(e){let t=this.effects;try{switch(e.kind){case`reveal`:e.path&&await t.reveal(e.path,e.elementId);return;case`openCode`:case`findUsages`:{let n=e.title??``,r=e.places??[];r.length===0?t.notify(m(`app.webHost.places.none`,{name:n}),!0):await t.openPlaces(n,r);return}case`openScript`:{let n=scriptOf(e);n&&await t.openScript(n);return}case`copy`:await t.copy(e.text??``)?t.notify(m(`app.web.toolPanel.copied`)):t.notify(m(`app.web.tree.copyFailed`),!0);return;case`preference`:case`refresh`:await this.refresh();return;case`deploy`:await t.deploy(e.paths??[],e.profile,e.confirm===!0),await this.refresh();return;case`createExample`:e.example&&await t.createExample(e.example),await this.refresh();return;case`unlockCode`:t.unlock();return;case`openConnections`:t.openConnections();return;case`openMigration`:t.openMigration();return;case`notify`:t.notify(e.text??``,e.error===!0);return;case`unsupported`:t.notify(e.reason??m(`app.web.toolPanel.unsupported`),!1);return}}catch(e){t.notify(await q(e),!0)}}};function baseName(e){return e.split(/[\\/]/).pop()??e}function label(e){return e.profile??`default`}async function deployPaths(e,t,n,r){let i=n??m(`app.deploy.profileInForce`);if(r&&!await e.confirmWithUser({title:m(`app.deploy.title`),text:m(`app.deploy.confirm`,{what:t.length===1?baseName(t[0]):m(`app.deploy.files`,{count:t.length}),where:i}),accept:m(`app.deploy.title`),decline:m(`app.common.cancel`)}))return;let a=new Map;for(let r of t){let t=await e.targets(r),i=n===void 0?t.active??null:n,o=t.targets.find(e=>(e.profile??null)===i);if(!o?.ready){await e.notifyUser(m(`app.deploy.notReady`,{name:baseName(r),target:label({profile:i})}),!0);continue}let s=JSON.stringify([o.profile,o.engine,o.url,o.deployment]),c=a.get(s)??{target:o,paths:[]};c.paths.push(r),a.set(s,c)}for(let{target:t,paths:n}of a.values()){let r=await Promise.all(n.map(async t=>({path:t,content:await e.readFile(t)}))),i=(await e.projectFiles()).map(t=>({path:t,read:()=>e.readFile(t)})),a=(await ut(r,i)).map(e=>({name:e.name,content:e.content})),o=await e.deploy(t,a,n[0]),s=o.status===401||o.status===403;await e.notifyUser(o.ok?m(`app.deploy.succeededOn`,{message:o.message,target:t.url??label(t)}):s?m(`app.deploy.signInHint`,{message:o.message}):o.message,!o.ok)}}async function createExample(e,t,n){if(!await e.confirmWithUser({title:m(`app.project.startFromAnExample`),text:m(`app.project.writeTheOrderExampleInto`,{example:ot(n),root:t}),accept:m(`app.runs.create`),decline:m(`app.common.cancel`)}))return!1;let r=[];for(let[i,a]of Object.entries(exampleFiles(n)))(i!==`.gitignore`||await e.readFileIfPresent(`${t}/${i}`)===null)&&r.push({path:i,content:a});try{await e.createProjectFiles(t,r)}catch(t){return await e.notifyUser(m(`app.project.theExampleWasNotWritten`,{failure:t instanceof Error?t.message:String(t)}),!0),!1}return await e.notifyUser(m(`app.project.theExampleIsInIts`,{example:ot(n),root:t})),!0}function targetLabel(e){return e?.profile??`default`}async function deployWithHost(e,t,n,r,i){try{let a=i??Q(),o=e?.profile??null;if(!e||!tt(String(e.engine))||!e.deployment)return{ok:!1,status:0,message:m(`app.project.chooseCamunda7Camunda8`),definitions:[],lines:[]};let s=Array.isArray(t)?t:[],c=await pt({...e.deployment,engine:e.engine},s,{ask:e=>a.askEngine(o,e,n),hook:(e,t)=>a.runHook(e,t,o,n,r),watch:r});if(c.ok)try{await a.recordDeployment(o,s.map(e=>e.name))}catch{}return c}catch(e){return{ok:!1,status:0,message:e instanceof Error?e.message:String(e),definitions:[],lines:[]}}}function toolEnvironment(e,t){return{notify:e.notify,copy:e.copy,showLicence:e.showLicence,files:()=>t.snapshot().listing.files,refreshProject:()=>t.refresh()}}function toolApi(e){return{snapshot:(t,n)=>e.web.getToolWindow({revision:t??void 0},n?{signal:n}:void 0),perform:(t,n)=>e.web.performToolWindowAction({toolWindowPerformRequest:{id:t,revision:n}})}}function toolEffects(e,t){return{reveal:(t,n)=>e.revealElement(t,n),openPlaces:(t,n)=>e.openPlaces(t,n),openScript:t=>e.openScriptFile(t.language,t.text,t.slot,t.title,t.variables,t.path),copy:t.copy,notify:t.notify,unlock:t.showLicence,openConnections:()=>{openConnectionsScreen()||t.notify(m(`app.web.toolPanel.unsupported`),!1)},openMigration:()=>{openMigrationScreen()||t.notify(m(`app.web.toolPanel.unsupported`),!1)},deploy:async(n,r,i)=>{await deployPaths({confirmWithUser:t=>e.confirmWithUser(t),targets:async t=>e.getDeployTargets(t),notifyUser:async(e,n)=>t.notify(e,n),readFile:t=>e.readFile(t),projectFiles:async()=>t.files().filter(e=>e.kind===`bpmn`||e.kind===`dmn`||e.kind===`form`).map(e=>e.path),deploy:(e,t,n)=>deployWithHost(e,t,n)},n,r,i),await t.refreshProject()},createExample:async n=>{isExample(n)&&await createExample({readFileIfPresent:t=>e.readFileIfPresent(t),confirmWithUser:t=>e.confirmWithUser(t),notifyUser:async(e,n)=>t.notify(e,n),createProjectFiles:(t,n)=>e.createProjectFiles(t,n)},e.projectRoot(),n)&&await t.refreshProject()}}}var ProjectSession=class{host;identity;reload;listeners=new Set;state;timer=null;running=null;pollMs;constructor(e,t,n={}){this.host=e,this.identity={id:t.id??null,folder:t.folder??null},this.reload=n.reload??(()=>window.location.assign(window.location.pathname)),this.pollMs=n.pollMs??4e3,this.state={project:t,recent:null,gone:t.open&&!t.available,away:!1,moving:!1}}get id(){return this.identity.id}snapshot(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}commit(e){this.state={...this.state,...e},[...this.listeners].forEach(e=>{try{e()}catch(e){console.error(`A session listener failed:`,e)}})}start(){let schedule=()=>{this.timer=setTimeout(()=>{this.check().finally(()=>{this.timer!==null&&schedule()})},this.pollMs)};return schedule(),()=>{this.timer!==null&&clearTimeout(this.timer),this.timer=null}}check(){if(this.running)return this.running;let e=(async()=>{let e;try{e=await this.host.current()}catch{return}if(this.state.moving)return;let t=(e.id??null)!==this.id,n=!t&&e.open&&!e.available;(t!==this.state.away||n!==this.state.gone)&&this.commit({away:t,gone:n})})();return this.running=e.finally(()=>{this.running=null}),this.running}async adopt(){let e;try{e=await this.host.current()}catch{return}let t=e.id??null;e.open&&t!==null&&e.folder===this.identity.folder&&(this.identity={...this.identity,id:t}),await this.check()}noticeProjectId(e){e!==null&&this.id!==null&&e!==this.id&&!this.state.away&&!this.state.moving&&this.check()}async loadRecent(){let e=await this.host.recent();return this.commit({recent:e}),e}async forget(e){this.commit({recent:await this.host.forget(e)})}async open(e){this.commit({moving:!0});try{await this.host.open(e)}catch(e){throw this.commit({moving:!1}),e}this.reload()}async close(){this.commit({moving:!0});try{await this.host.close()}catch(e){throw this.commit({moving:!1}),e}this.reload()}reloadPage(){this.reload()}};function pageTitle({app:e,project:t,file:n,dirty:r}){let i=[];return n&&i.push(`${r?`● `:``}${n}`),t&&i.push(t),i.push(e),i.join(` - `)}function breadcrumbs(e,t){let n=[],r=t===`\\`,i=e.split(t).filter(e=>e!==``),a=``;r&&/^[A-Za-z]:$/.test(i[0]??``)?(a=`${i[0]}\\`,n.push({label:`${i[0]}\\`,path:a}),i.shift()):r||(a=`/`,n.push({label:`/`,path:`/`}));for(let e of i)a=a===``||a.endsWith(t)?`${a}${e}`:`${a}${t}${e}`,n.push({label:e,path:a});return n}function visibleEntries(e,t){return t?[...e]:e.filter(e=>!e.hidden)}function joinFolder(e,t,n){return e.endsWith(n)?`${e}${t}`:`${e}${n}${t}`}var ca=8,la=320;function folderWindow(e,t,n){return{start:Math.max(0,Math.floor(e/28)-ca),end:Math.min(n,Math.ceil((e+t)/28)+ca)}}function FolderBrowser({folders:e,recent:r,start:i,onChoose:a,onClose:s}){let[c,d]=t(null),[p,h]=t(!0),[g,_]=t(null),[v,y]=t(!1),[b,C]=t(i??``),[T,D]=t(null),[O,k]=t(!1),[A,j]=t(null),[M,N]=t(0),[P,F]=t(la),I=o(null),L=o(0),R=o(`web-folders-${Math.random().toString(36).slice(2,8)}`),z=n(async(t,n)=>{L.current+=1;let r=L.current;h(!0);try{let i=await e(t,n);if(r!==L.current)return;d(i),C(i.path),D(null),_(null),N(0),I.current&&(I.current.scrollTop=0)}catch(e){if(r!==L.current)return;_(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`))}finally{r===L.current&&h(!1)}},[e]);f(()=>{z(i,!1)},[]),u(()=>{let e=I.current;if(!e)return;let measure=()=>F(e.clientHeight||la);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[]);let B=c?visibleEntries(c.entries,v):[],ee=c?.separator??`/`,V=T===null?-1:B.findIndex(e=>e.name===T),H=c?T!==null&&V>=0?joinFolder(c.path,T,ee):c.path:null,scrollTo=e=>{let t=I.current;if(!t||e<0)return;let n=e*28,r=t.clientHeight||la;n<t.scrollTop?t.scrollTop=n:n+28>t.scrollTop+r&&(t.scrollTop=n+28-r),N(t.scrollTop)},descend=e=>{c&&z(joinFolder(c.path,e,ee),v)},choose=async()=>{if(!(!H||O||p)){if(c&&b.trim()!==c.path)z(b,v);else{k(!0),j(null);try{await a(H)}catch(e){j(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),k(!1)}}}},onListKey=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.floor((I.current?.clientHeight||la)/28)-1),n=null;e.key===`ArrowDown`?n=Math.min(B.length-1,V+1):e.key===`ArrowUp`?n=Math.max(0,V<0?0:V-1):e.key===`Home`?n=0:e.key===`End`?n=B.length-1:e.key===`PageDown`?n=Math.min(B.length-1,V+t):e.key===`PageUp`&&(n=Math.max(0,V-t)),n===null?(e.key===`Enter`||e.key===`ArrowRight`)&&V>=0?(e.preventDefault(),e.stopPropagation(),descend(B[V].name)):(e.key===`Backspace`||e.key===`ArrowLeft`)&&c?.parent&&(e.preventDefault(),z(c.parent,v)):(e.preventDefault(),B[n]&&(D(B[n].name),scrollTo(n)))},{start:U,end:W}=folderWindow(M,P,B.length),te=[];c&&(te.push({id:`home`,label:m(`app.web.folders.home`),path:c.home}),c.roots.forEach(e=>te.push({id:`root:${e}`,label:e===`/`?m(`app.web.folders.computer`):e,path:e})));let ne=r.filter(e=>e.present).slice(0,6),re=c?breadcrumbs(c.path,ee):[];return l(E,{title:m(`app.web.folders.title`),size:`large`,body:`split`,onClose:s,onSubmit:()=>void choose(),footer:l(w,{help:H?m(`app.web.folders.willOpen`,{folder:H}):void 0,actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:s,disabled:O},{id:`open`,label:m(`app.web.folders.open`),role:`primary`,onClick:()=>void choose(),busy:O,disabled:!H}]}),children:[l(`nav`,{class:`web-folders__places`,"aria-label":m(`app.web.folders.places`),children:[l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.places`)}),te.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.path,onClick:()=>void z(e.path,v),children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-folders__place-name`,children:e.label})]},e.id)),ne.length>0&&l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.recent`)}),ne.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.folder,onClick:()=>void z(e.folder,v),children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-folders__place-name`,children:e.name})]},e.folder))]}),l(`div`,{class:`web-folders__main`,children:[l(x,{label:m(`app.web.folders.path`),layout:`top`,error:g,children:e=>l(`input`,{...e,value:b,spellcheck:!1,autocomplete:`off`,onInput:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),z(b,v))},onBlur:()=>{c&&b.trim()!==``&&b!==c.path&&!p&&z(b,v)}})}),c&&l(`ol`,{class:`web-folders__crumbs type-help`,"aria-label":m(`app.web.folders.location`),children:re.map((e,t)=>l(`li`,{class:`web-folders__crumb`,children:l(`button`,{type:`button`,class:`web-folders__crumb-button`,"aria-current":t===re.length-1?`location`:void 0,onClick:()=>void z(e.path,v),children:e.label})},e.path))}),l(`div`,{class:`web-folders__bar`,children:[l(`label`,{class:`web-folders__toggle type-body`,children:[l(`input`,{type:`checkbox`,checked:v,onChange:e=>{let t=e.target.checked;y(t),c&&z(c.path,t)}}),l(`span`,{children:c&&c.hiddenCount>0?m(`app.web.folders.showHiddenCount`,{count:c.hiddenCount}):m(`app.web.folders.showHidden`)})]}),c?.project&&l(`span`,{class:`web-folders__hint type-help`,role:`status`,children:c.project.config?m(`app.web.folders.hereConfig`):m(`app.web.folders.hereDiagrams`,{count:c.project.diagrams})})]}),l(`div`,{ref:I,id:R.current,class:`web-folders__list`,role:`listbox`,tabIndex:0,"aria-label":m(`app.web.folders.list`),"aria-busy":p||void 0,"aria-activedescendant":V>=0?`${R.current}-${V}`:void 0,onKeyDown:onListKey,onScroll:e=>N(e.currentTarget.scrollTop),children:[l(`div`,{class:`web-folders__canvas`,style:{height:`${B.length*28}px`},children:B.slice(U,W).map((e,t)=>{let n=U+t;return l(`div`,{id:`${R.current}-${n}`,role:`option`,"aria-selected":n===V,class:`web-folders__row type-body${n===V?` is-selected`:``}`,style:{top:`${n*28}px`},title:e.link?m(`app.web.folders.link`,{name:e.name}):e.name,onClick:()=>{I.current?.focus({preventScroll:!0}),D(e.name)},onDblClick:()=>descend(e.name),children:[l(Icon$1,{class:`web-folders__icon`,name:`folder`}),l(`span`,{class:`web-folders__name`,children:e.name}),e.link&&l(`span`,{class:`web-folders__tag type-help`,children:m(`app.web.folders.linkTag`)}),e.project&&l(`span`,{class:`web-folders__tag is-project type-help`,children:m(`app.web.folders.projectTag`)})]},e.name)})}),c&&B.length===0&&!p&&l(`p`,{class:`web-folders__empty type-help`,children:m(`app.web.folders.noFolders`)})]}),c?.truncated&&l(`p`,{class:`web-folders__note type-help`,children:m(`app.web.folders.truncated`,{shown:c.entries.length,total:c.total})}),A&&l(S,{children:A})]})]})}var ua=`.bpmn,.dmn,.form,.cmmn,.xml`;function acceptedUpload(e){let t=le(e);return t===`bpmn`||t===`dmn`||t===`form`||t===`cmmn`}function messageFrom(e){return e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)}function carriesFiles(e){return Array.from(e.dataTransfer?.types??[]).includes(`Files`)}function ProjectFrame({session:e,store:r,entries:i,readText:a,engine:s,toolWindow:u=null,children:d}){let p=useSession(e),h=useStore(r),[g,_]=t(!1),[v,y]=t(null),[b,x]=t(!1),[S,C]=t(null),[T,D]=t(null),[O,k]=t(!1),[A,j]=t(null),[M,N]=t(null),[P,F]=t(null),I=o(null),R=o(0),z=p.project.name??m(`app.web.tree.project`),B=h.active?h.docs.get(h.active):void 0,ee=!!B&&B.phase===`ready`&&B.current!==B.baseline;f(()=>{document.title=pageTitle({app:m(`app.web.pageTitle`),project:p.project.open?z:null,file:B?B.rel:null,dirty:ee})},[z,B?.rel,ee,p.project.open]),f(()=>e.start(),[e]),useDesktopCommands({"project.refresh":()=>void e.adopt().then(()=>Promise.all([r.refresh(),u?.refresh()]))}),f(()=>{if(!T||A)return;let e=!0;return K(()=>import(`./UploadDialog-D-X6GG98.js`).then(t=>e&&j({component:t.UploadDialog})),__vite__mapDeps([105,1,2,6,7,14,9,4,15,85]),import.meta.url),()=>{e=!1}},[T]),f(()=>{if(M===null||P)return;let e=!0;return K(()=>import(`./NewFileDialog-Dev41oA1.js`).then(t=>e&&F({component:t.NewFileDialog})),__vite__mapDeps([91,1,2,6,7,14,9,4,15,85,17]),import.meta.url),()=>{e=!1}},[M]);let V=n(async t=>{for(let e of[...r.snapshot().order])r.close(e);try{t.kind===`open`?await e.open(t.folder):await e.close()}catch(e){L.error(messageFrom(e)),x(!1),y(null)}},[e,r]),H=n(e=>{r.dirtyPaths().length===0?V(e):(C(null),y(e))},[r,V]),U=n(e=>{let t=e.filter(e=>acceptedUpload(e.name));t.length<e.length&&L.error(m(`app.web.upload.ignored`)),t.length>0&&D(t)},[]);f(()=>{let over=e=>{carriesFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},enter=e=>{carriesFiles(e)&&(R.current+=1,k(!0))},exit=e=>{carriesFiles(e)&&(R.current=Math.max(0,R.current-1),R.current===0&&k(!1))},drop=e=>{carriesFiles(e)&&(e.preventDefault(),R.current=0,k(!1),U(Array.from(e.dataTransfer?.files??[])))};return window.addEventListener(`dragover`,over),window.addEventListener(`dragenter`,enter),window.addEventListener(`dragleave`,exit),window.addEventListener(`drop`,drop),()=>{window.removeEventListener(`dragover`,over),window.removeEventListener(`dragenter`,enter),window.removeEventListener(`dragleave`,exit),window.removeEventListener(`drop`,drop)}},[U]);let W=c(()=>({session:e,store:r,entries:i,engine:s,browse:()=>_(!0),switchTo:e=>H({kind:`open`,folder:e}),closeProject:()=>H({kind:`close`}),upload:()=>I.current?.click(),newFile:e=>N(e),downloadFile:e=>{let t=r.doc(e.path);(t&&t.phase===`ready`?Promise.resolve(t.current):a(e.path)).then(t=>download(e.name,new Blob([t],{type:`application/octet-stream`})),e=>L.error(messageFrom(e)))},downloadArchive:()=>{i.archiveUrl(e.id).then(e=>{let t=document.createElement(`a`);t.href=e,t.rel=`noopener`,t.download=``,document.body.appendChild(t),t.click(),t.remove()},e=>L.error(messageFrom(e)))}}),[e,r,i,s,H,a]),te=r.dirtyPaths().length,addFiles=async e=>{for(let t of e)await r.create(t.rel,t.content);await r.refresh();let t=r.snapshot().listing.files.find(t=>t.rel===e[0]?.rel);t&&await r.open(t.path,t.kind)};return l(Wi.Provider,{value:W,children:[d,l(`input`,{ref:I,class:`web-projects__picker`,type:`file`,multiple:!0,accept:ua,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=e.target;U(Array.from(t.files??[])),t.value=``}}),p.gone&&!p.away&&l(`div`,{class:`web-projects__gone`,role:`alert`,children:[l(Icon$1,{name:`alert`}),l(`span`,{class:`web-projects__gone-text type-body`,children:m(`app.web.project.gone`,{name:z})}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>_(!0),children:m(`app.web.project.openAnother`)}),l(`button`,{type:`button`,class:`ui-button type-button`,onClick:()=>H({kind:`close`}),children:m(`app.web.project.close`)})]}),O&&l(`div`,{class:`web-projects__drop`,"aria-hidden":`true`,children:l(`p`,{class:`web-projects__drop-text type-body`,children:m(`app.web.upload.drop`)})}),g&&l(FolderBrowser,{folders:e.host.folders,recent:p.recent??[],onChoose:async e=>{e===p.project.folder?_(!1):(_(!1),H({kind:`open`,folder:e}))},onClose:()=>_(!1)}),v&&l(E,{title:v.kind===`open`?m(`app.web.project.unsavedOpenTitle`):m(`app.web.project.unsavedCloseTitle`),size:`small`,destructive:!0,onClose:()=>!b&&y(null),footer:l(w,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>y(null),disabled:b},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:()=>void V(v),disabled:b},{id:`save`,label:m(`app.web.project.saveAll`),role:`primary`,busy:b,onClick:()=>{x(!0),C(null),r.saveAll().then(e=>{e?V(v):(x(!1),C(m(`app.web.project.saveAllFailed`)))})}}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.unsavedText`,{count:te})}),S&&l(`p`,{class:`web-dialog-text type-error-message`,role:`alert`,children:S})]}),T&&A&&l(A.component,{files:T,existing:h.listing.files,folders:h.listing.folders,onUpload:addFiles,onClose:()=>D(null)}),M!==null&&P&&l(P.component,{files:h.listing.files,engine:s,initialFolder:M,onCreate:(e,t)=>addFiles([{rel:e,content:t}]),onClose:()=>N(null)}),p.away&&l(E,{title:m(`app.web.project.awayTitle`),size:`small`,backdrop:`keep`,onClose:()=>e.reloadPage(),footer:l(w,{actions:[{id:`reload`,label:m(`app.common.reload`),role:`primary`,onClick:()=>e.reloadPage()}]}),children:l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.awayText`)})})]})}function Welcome({session:e}){let n=useSession(e),[r,i]=t(!1),[a,o]=t(null),[s,c]=t(null),[u,d]=t(!1);f(()=>{e.loadRecent().catch(()=>d(!0))},[e]);let openFolder=async t=>{o(null),c(t);try{await e.open(t)}catch(e){throw o(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),c(null),e}},p=n.recent??[];return l(`main`,{class:`web-start`,children:[l(`section`,{class:`web-start__card`,"aria-labelledby":`web-start-title`,children:[l(`h1`,{id:`web-start-title`,class:`web-start__title type-dialog-title`,children:m(`app.web.welcome.title`)}),l(`p`,{class:`web-start__text type-body`,children:m(`app.web.welcome.text`)}),l(`div`,{class:`web-start__actions`,children:l(`button`,{type:`button`,class:`ui-button ui-button--primary type-button`,onClick:()=>i(!0),disabled:s!==null,children:m(`app.web.welcome.open`)})}),l(`h2`,{class:`web-start__heading type-section-heading`,children:m(`app.web.welcome.recent`)}),n.recent!==null&&p.length===0&&l(`p`,{class:`web-start__none type-help`,children:m(`app.web.welcome.noRecent`)}),u&&l(`p`,{class:`web-start__none type-help`,children:m(`app.web.welcome.recentFailed`)}),p.length>0&&l(`ul`,{class:`web-start__recent`,"aria-label":m(`app.web.welcome.recent`),children:p.map(t=>l(`li`,{class:`web-start__item`,children:[l(`button`,{type:`button`,class:`web-start__project type-body`,disabled:!t.present||s!==null,title:t.present?t.folder:m(`app.web.welcome.missing`,{folder:t.folder}),onClick:()=>void openFolder(t.folder).catch(()=>void 0),children:[l(Icon$1,{name:`process`}),l(`span`,{class:`web-start__name`,children:t.name}),l(`span`,{class:`web-start__folder type-help`,children:t.present?t.folder:m(`app.web.welcome.notFound`)})]}),l(`button`,{type:`button`,class:`web-start__forget`,"aria-label":m(`app.web.welcome.forget`,{name:t.name}),title:m(`app.web.welcome.forget`,{name:t.name}),disabled:s!==null,onClick:()=>void e.forget(t.folder).catch(()=>void 0),children:l(Icon$1,{name:`close`})})]},t.folder))}),a&&!r&&l(`div`,{role:`alert`,children:l(S,{children:a})}),l(`p`,{class:`web-start__hint type-help`,children:m(`app.web.welcome.hint`)})]}),r&&l(FolderBrowser,{folders:e.host.folders,recent:p,onChoose:openFolder,onClose:()=>i(!1)})]})}var da=[`__proto__`,`constructor`,`prototype`];function isMap(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function rulesTable(e){if(!isMap(e))return null;let t=e.rules;return isMap(t)?t:null}function overlayRules(e,t){let n=Object.keys(t);if(n.length===0||!isMap(e))return e;let r=rulesTable(e)??{},i=Object.create(null);for(let e of Object.keys(r))da.includes(e)||(i[e]=r[e]);for(let e of n){let n=t[e];(n.forced||!Object.hasOwn(r,e))&&(i[e]=n.severity)}return{...e,rules:{...i}}}function effectivePalette(e,t){let n=e&&e.length>0?e:null;if(!t||t.length===0)return n?[...n]:null;if(!n)return[...t];let r=n.filter(e=>t.includes(e));return r.length>0?r:[...t]}function effectiveConventions(e,t){if(!t)return isMap(e)?e:null;let n=isMap(e)?e:{},r=Object.create(null);for(let[e,n]of Object.entries(t.defaults??{}))r[e]={...n};for(let[e,t]of Object.entries(n.defaults??{}))da.includes(e)||(r[e]={...r[e]??{},...t});let i={...t.ids??{},...n.ids??{}};return{...Object.keys(i).length>0?{ids:i}:{},...Object.keys(r).length>0?{defaults:{...r}}:{}}}function ruleKeysOf(e){let t=[e];return e.startsWith(`bpmnlint/`)&&t.push(e.slice(9)),e.startsWith(`compat/`)&&t.push(`camunda-compat/${e.slice(7)}`),e.startsWith(`engine/`)&&t.push(`penstock-engine/${e.slice(7)}`),t}function policyRuleOf(e,t){return t?ruleKeysOf(e).find(e=>Object.hasOwn(t,e))??null:null}var fa=null;function setPolicy(e){fa=e&&e.present?e:null}function policyRules(e=fa){let t=Object.create(null);if(!e||e.refused.length>0)return t;for(let n of e.rules)t[n.rule]={severity:n.severity,forced:n.forced};return t}function policyHeader(e=fa){return e?e.refused.length>0||!e.name||e.version===null||e.version===void 0?m(`app.policy.header.refused`):m(`app.policy.header.${e.pin}`,{name:e.name,version:e.version}):null}function policyOfRule(e,t=fa){return!e||!t||!t.name||t.refused.length>0||policyRuleOf(e,policyRules(t))===null?null:t.name}function withPolicyRules(e,t=fa){return overlayRules(e,policyRules(t))}function configUnderPolicy(e,t){return!t||!t.present||t.refused.length>0?{...e,policy:t&&t.present?t:null}:{...e,palette:effectivePalette(e.palette,t.palette),conventions:effectiveConventions(e.conventions,t.conventions??null)??e.conventions,policy:t}}async function loadPolicy(e){let t=await e.getPolicy?.().catch(()=>null)??null;setPolicy(t);let n=window.appConfig;if(!n)return;let r=configUnderPolicy({palette:n.palette,conventions:n.conventions},t);n.palette=r.palette,n.conventions=r.conventions,n.policy=r.policy}var pa=null,ma=null;function setSuggestionProvider(e){pa=e}function setProjectSuggestionProvider(e){ma=e}function currentSuggestionProvider(){return pa??ma}function webShellEnvironment(e,t){return{...On,mac:/Mac|iPhone|iPad/.test(navigator.platform),journal:t,loadSession:e=>sessionFrom(B().webSessions?.[e]),saveSession:(e,t)=>{V({webSessions:{[e]:{...t,dock:t.dock}}})},autosave:()=>B().webAutosaveSeconds??null,setAutosave:e=>V({webAutosaveSeconds:e}),theme:()=>currentThemeChoice(),setTheme:e=>chooseTheme(e),sidebar:()=>({open:B().projectTreeHidden!==!0,width:clampSidebar(B().projectTreeWidth??272)}),setSidebar:e=>V({projectTreeWidth:e.width,projectTreeHidden:!e.open}),runEditorAction:e=>{let t=window.penstockRunAction;return t?(t(e),!0):!1},licence:async()=>{try{let t=await e.getLicense();return t?t.detail||String(t.tier):null}catch{return null}},showLicence:()=>void e.showLicence(),notify:(e,t)=>t?L.error(e):L.info(e),copy:async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}}}function startingLocale(e){let t=B().locale;if(t)return v(t);let n=e?.locale;return n?v(n):p()}function followSystemTheme(e){let t=window.matchMedia?.(`(prefers-color-scheme: dark)`),n=themeNameFor(e?.theme,!!t?.matches);rememberHostTheme(n);try{applyTheme(n)}catch(e){console.error(`[Theme] Failed to initialize theme:`,e),applyTheme(bt)}applyThemeChoice(),followThemeChoice(),e?.theme&&e.theme.toUpperCase()!==`SYSTEM`||t?.addEventListener?.(`change`,e=>receiveHostThemeName(e.matches?`dark`:`light`))}function setupGlobalAppConfig(e){window.appConfig={theme:e?.theme||`light`,engine:e?.engine||null,scriptFormat:e?.scriptType||null,showBrowserToolBar:!1,project:e?.project||`Project`,bpmnFilePath:``,bpmnXml:``,elementTemplatesContent:cleanTemplates(e?.elementTemplatesContent),conventions:e?.conventions||{},palette:e?.palette??null,policy:null,pluginVersion:e?.pluginVersion??null,gitUserName:e?.gitUserName??null,get isDarkMode(){return getCurrentTheme()===`dark`},get isDraculaMode(){return getCurrentTheme()===`dracula`},get isSketchyMode(){return B().rendering===`sketchy`},async fetchConfig(){}},window.setTheme=receiveHostThemeName,window.setSuggestionProvider=setSuggestionProvider}function reloadPage(){window.location.reload()}async function start(){let e=document.getElementById(`app`);try{if(!e)throw Error(`Root element with id "app" not found in HTML`);let t=new WebPlatformBridge;Je(t);let n=await y().bpmn.getConfig();await ee(),await N(),U();let r=startingLocale(n);await g(r).catch(e=>console.error(`[i18n] The catalogue for`,r,`did not load, English is shown:`,e)),_(r),document.documentElement.lang=h(),translatePanelLabels(),followSystemTheme(n),setupGlobalAppConfig(n),await loadPolicy(t);let i=webHost(t.web),a=new ProjectSession(i,await i.current());if(t.bindProject(()=>a.id,e=>a.noticeProjectId(e)),!a.snapshot().project.open){s(l(C,{locale:h(),children:l(b,{onReload:reloadPage,children:l(Welcome,{session:a})})}),e),document.title=m(`app.web.pageTitle`);return}let o=`p${Date.now().toString(36)}${Math.random().toString(36).slice(2,10)}`;pageLock(o);let c=new DraftJournal(typeof indexedDB>`u`?new MemoryDrafts:new IndexedDbDrafts,{owner:o}),u=webShellEnvironment(t,c),d={store:null},f=new te({host:bridgeHost(t,n?.pluginVersion??null,e=>d.store?.doc(e)?.current??null),notify:u.notify,drafts:c});d.store=f;let p=new ScriptHub;t.bindWorkspace(new Workspace({store:f,scripts:p})),installDesktop(f),t.bindActiveFile(()=>f.snapshot().active),f.subscribe(()=>{let e=f.snapshot().active,n=window.appConfig;n&&(n.bpmnFilePath=e?ce(e):``),t.bindActiveDocument(e?t=>f.edit(e,t):null)});let v=new URLSearchParams(window.location.search).get(`file`),x=We();Ke(x),window.addEventListener(`pagehide`,()=>x?.dispose());let S=new ToolWindowStore(toolApi(t),toolEffects(t,toolEnvironment(u,f))),Root=()=>l(ProjectFrame,{session:a,store:f,entries:i,readText:e=>t.readFile(e),engine:n?.engine,toolWindow:S,children:l(WebShell,{store:f,scripts:p,loaders:It,engine:n?.engine,deepLink:v,toolWindow:S,env:u})});s(l(C,{locale:h(),children:l(b,{onReload:reloadPage,children:l(Root,{})})}),e),document.title=m(`app.web.pageTitle`),showFavicon(!1)}catch(t){console.error(`[Init] The web editor could not start:`,t),showStartupFailure(e,t)}}start();export{PreviewPane as $,AssistantDock as A,ttlOf as At,oi as B,toggleDarkMode as Bt,useChatAction as C,processXml as Ct,useAssistantEditor as D,formJson as Dt,useRevealCount as E,dmnNamespaceOf as Et,installScenarioOpener as F,chooseTheme as Ft,compareTexts as G,useEditorElement as H,takeScenarioRequest as I,currentThemeChoice as It,useLicence as J,hunksOf as K,useScenarioRequest as L,yt as Lt,measureCorner as M,lineWanted as Mt,observeCorner as N,onSourceFocus as Nt,Fi as O,platformOf as Ot,AssistantRuntime as P,Ct as Pt,registerEditCommands as Q,motionMs as R,applyTheme as Rt,useAiChatPlace as S,widthLimits as St,useLeaveChatTab as T,decisionXml as Tt,FixVerdict as U,useEditorActive as V,cleanTemplates as Vt,armVerifier as W,Icon$1 as X,paidTier as Y,iconOfGroup as Z,nameFault as _,tabList as _t,withPolicyRules as a,droppedTabs as at,publishFacts as b,toggleCollapsed as bt,targetLabel as c,isRenameKey as ct,useFocusCanvasShortcut as d,popView as dt,computeChanges as et,suggestsFields as f,pushView as ft,messageFrom$1 as g,shownTab as gt,groupOfKind as h,selectTab as ht,policyOfRule as i,badgeText as it,Ei as j,unpackComparison as jt,Ii as k,processXml$1 as kt,toggleFocusCanvas as l,isRepeatOfPress as lt,domId as m,resolveWidth as mt,setProjectSuggestionProvider as n,arrowTab as nt,acceptedUpload as o,fromPreferences as ot,suggestsNextBlock as p,resetViews as pt,TabIcon as q,policyHeader as r,badgeLabel as rt,deployWithHost as s,isDrawer as st,currentSuggestionProvider as t,ensurePreviewStyle as tt,useFocusCanvas as u,isSidebarShortcut as ut,Icon as v,titleCommit as vt,useChatStatus as w,attributesOf as wt,retractFacts as x,toggleHidden as xt,ToolbarButton as y,toPreferences as yt,reducedMotion as z,getCurrentTheme as zt};