@kern0x1b/penstock-cli 26.10.0 → 26.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/THIRD-PARTY-NOTICES.md +1646 -0
  2. package/dist/grammars/tree-sitter-c-sharp.wasm +0 -0
  3. package/dist/grammars/tree-sitter-go.wasm +0 -0
  4. package/dist/grammars/tree-sitter-groovy.wasm +0 -0
  5. package/dist/grammars/tree-sitter-java.wasm +0 -0
  6. package/dist/grammars/tree-sitter-javascript.wasm +0 -0
  7. package/dist/grammars/tree-sitter-kotlin.wasm +0 -0
  8. package/dist/grammars/tree-sitter-python.wasm +0 -0
  9. package/dist/grammars/tree-sitter-scala.wasm +0 -0
  10. package/dist/grammars/tree-sitter-typescript.wasm +0 -0
  11. package/dist/grammars/web-tree-sitter.wasm +0 -0
  12. package/dist/penstock.js +1076 -419
  13. package/dist/syntax-worker.js +5 -0
  14. package/dist/web/assets/AgentSettings-B_c5K0Hd.js +1 -0
  15. package/dist/web/assets/AgentsDialog-BtgwT_49.js +1 -0
  16. package/dist/web/assets/BpmnCanvas-BeOwGJEV.js +1905 -0
  17. package/dist/web/assets/BpmnDocument-DioCJiv7.js +24 -0
  18. package/dist/web/assets/ConflictDialog-B9V39KUg.js +1 -0
  19. package/dist/web/assets/DiffDocument-t0gjzCba.js +1 -0
  20. package/dist/web/assets/DmnDocument-ChFDTt1F.js +41 -0
  21. package/dist/web/assets/DmnDocument-VhMjHTN6.css +1 -0
  22. package/dist/web/assets/FormDocument-TEeVD6T7.js +32 -0
  23. package/dist/web/assets/FormDocument-URLcKn84.css +1 -0
  24. package/dist/web/assets/FormStepView-DLNQ8jVN.js +1 -0
  25. package/dist/web/assets/GraphAwareLayoutService-DFtkFUrn.js +21 -0
  26. package/dist/web/assets/NewFileDialog-BPBljAGC.js +34 -0
  27. package/dist/web/assets/QuickOpen-DOe23FAR.js +1 -0
  28. package/dist/web/assets/ScriptPane-DzBYUW23.js +2 -0
  29. package/dist/web/assets/ScriptRunDialog-BtLkIreU.js +1 -0
  30. package/dist/web/assets/SettingsDialog-YoMl6NJ1.js +1 -0
  31. package/dist/web/assets/ShortcutsDialog-D0_aCcNe.js +1 -0
  32. package/dist/web/assets/SourceDocument-p3iREvQI.js +1 -0
  33. package/dist/web/assets/TextDocument-DWg1EqKB.js +1 -0
  34. package/dist/web/assets/UnreadableFileLayer-ep6zQMtt.js +1 -0
  35. package/dist/web/assets/UploadDialog-ZOy1owan.js +1 -0
  36. package/dist/web/assets/Viewer-C7pbHtwq.js +4 -0
  37. package/dist/web/assets/apply-B8eZkNJ6.js +1 -0
  38. package/dist/web/assets/array-move-Bc4mVEdq.js +1 -0
  39. package/dist/web/assets/bpmn-0HrGCizt.svg +228 -0
  40. package/dist/web/assets/bpmn-Cyvp-fAH.eot +0 -0
  41. package/dist/web/assets/bpmnTheme-CebWk9Ei.js +1683 -0
  42. package/dist/web/assets/bridgeInstance-DzSjLJAc.js +600 -0
  43. package/dist/web/assets/clike-DaHM3zHz.js +1 -0
  44. package/dist/web/assets/colors-dark-C7vOziWz.css +1 -0
  45. package/dist/web/assets/colors-dracula-CXhMcc1Z.css +1 -0
  46. package/dist/web/assets/colors-light-CyT40N4M.css +1 -0
  47. package/dist/web/assets/de-DG3quwSS.js +1 -0
  48. package/dist/web/assets/dialog-Cn1DzN2I.js +1 -0
  49. package/dist/web/assets/diff-DMf6xJj1.js +1 -0
  50. package/dist/web/assets/dist--ADMeFWW.js +57 -0
  51. package/dist/web/assets/dist--PmHUHDp.js +1 -0
  52. package/dist/web/assets/dist-2wOiLlcG.js +1 -0
  53. package/dist/web/assets/dist-BYu4mHLv.js +23 -0
  54. package/dist/web/assets/dist-BaWEbDAw.js +1 -0
  55. package/dist/web/assets/dist-BnLLb41E.js +2 -0
  56. package/dist/web/assets/dist-BqwyxNP3.js +1 -0
  57. package/dist/web/assets/dist-BxuUJA8B.js +1 -0
  58. package/dist/web/assets/dist-CHkSydPE.js +1 -0
  59. package/dist/web/assets/dist-CHluRwHI.js +2 -0
  60. package/dist/web/assets/dist-CRJyslwo.js +1 -0
  61. package/dist/web/assets/dist-CxyFqsL2.js +6 -0
  62. package/dist/web/assets/dist-D0cjZCsW.js +13 -0
  63. package/dist/web/assets/dist-DBnQKg4d.js +1 -0
  64. package/dist/web/assets/dist-DIdDTNn9.js +2 -0
  65. package/dist/web/assets/dist-DXXc07IK.js +1 -0
  66. package/dist/web/assets/dist-DgvQWhKm.js +6 -0
  67. package/dist/web/assets/dist-DlbES2QN.js +1 -0
  68. package/dist/web/assets/dist-Dup2uTdL.js +6 -0
  69. package/dist/web/assets/dist-TNwbKIWT.js +1 -0
  70. package/dist/web/assets/dist-f4FXNtig.js +1 -0
  71. package/dist/web/assets/dist-zHmj1-pd.js +5 -0
  72. package/dist/web/assets/dmn-2EwrEScy.eot +0 -0
  73. package/dist/web/assets/dmn-eH1_eUsy.svg +90 -0
  74. package/dist/web/assets/dockLayout-CxOMo-Nl.js +1 -0
  75. package/dist/web/assets/documentBridge-BXU6mgKl.js +240 -0
  76. package/dist/web/assets/documents-XvKodSic.js +1 -0
  77. package/dist/web/assets/duplicate-CKn70NtG.js +342 -0
  78. package/dist/web/assets/ed25519-DTYhEcYX.js +1 -0
  79. package/dist/web/assets/engine-BPUfS3r2.js +1 -0
  80. package/dist/web/assets/engines-BaW52xZ_.js +5 -0
  81. package/dist/web/assets/es-PcpRjhXP.js +1 -0
  82. package/dist/web/assets/files-Chpd_QD0.js +1 -0
  83. package/dist/web/assets/formChecks-TAsEqw2_.js +1 -0
  84. package/dist/web/assets/fr-BQIO41QS.js +1 -0
  85. package/dist/web/assets/frontend-By89859W.js +1 -0
  86. package/dist/web/assets/go-C1TRUqzB.js +1 -0
  87. package/dist/web/assets/groovy-C2AgVf_z.js +1 -0
  88. package/dist/web/assets/html2canvas-DEOnTJc-.js +5 -0
  89. package/dist/web/assets/httpHost-DPT9cNRG.js +1 -0
  90. package/dist/web/assets/index.es-DXehkcd9.js +4 -0
  91. package/dist/web/assets/index.es-fKIKPRSg.js +78 -0
  92. package/dist/web/assets/index.esm-CTLpq4ik.js +3 -0
  93. package/dist/web/assets/intelligence-_ijxuAw5.js +3 -0
  94. package/dist/web/assets/ja-CJkgGd9w.js +1 -0
  95. package/dist/web/assets/jspdf.es.min-DXxYWA_o.js +79 -0
  96. package/dist/web/assets/ko-BaifpU2V.js +1 -0
  97. package/dist/web/assets/lib--h_vArmx.js +1 -0
  98. package/dist/web/assets/libavoid-BRQRZjmQ.wasm +0 -0
  99. package/dist/web/assets/libavoid.wasm +0 -0
  100. package/dist/web/assets/platform-_nC9EyYA.js +2 -0
  101. package/dist/web/assets/preferences-Cfvg8oqM.js +1 -0
  102. package/dist/web/assets/preload-helper-VRuDKI9K.js +1 -0
  103. package/dist/web/assets/properties-C3HzGRE2.js +1 -0
  104. package/dist/web/assets/pt-BR-DkBw_2Tc.js +1 -0
  105. package/dist/web/assets/purify.es-CyDa74pG.js +3 -0
  106. package/dist/web/assets/python-CvnBFxgv.js +1 -0
  107. package/dist/web/assets/resource/ArchitectsDaughter-OFL.txt +93 -0
  108. package/dist/web/assets/resource/ArchitectsDaughter-Regular.ttf +0 -0
  109. package/dist/web/assets/resource/JetBrainsMono-Italic.woff2 +0 -0
  110. package/dist/web/assets/resource/JetBrainsMono-Medium.woff2 +0 -0
  111. package/dist/web/assets/resource/JetBrainsMono-OFL.txt +52 -0
  112. package/dist/web/assets/resource/JetBrainsMono-Regular.woff2 +0 -0
  113. package/dist/web/assets/resource/JetBrainsMono-SemiBold.woff2 +0 -0
  114. package/dist/web/assets/rolldown-runtime-B8BYMn-z.js +1 -0
  115. package/dist/web/assets/ru-DhjXKaLT.js +1 -0
  116. package/dist/web/assets/run-CgRiIIgd.js +1 -0
  117. package/dist/web/assets/samples-CeaUa4Fn.js +1 -0
  118. package/dist/web/assets/shortcut-DONH578b.js +1 -0
  119. package/dist/web/assets/source-frame-C6KIof5s.js +2 -0
  120. package/dist/web/assets/stackblur-es-Djj-lnDR.js +2 -0
  121. package/dist/web/assets/syntax-DBcQvmbn.js +6 -0
  122. package/dist/web/assets/testCaseRuns-Bw2AfAfR.js +1 -0
  123. package/dist/web/assets/translator-Dt_jCGPm.js +1 -0
  124. package/dist/web/assets/typing-CXvbBSPr.js +1 -0
  125. package/dist/web/assets/ui-DDJuNJWb.js +1 -0
  126. package/dist/web/assets/useTrace-Rwk8eJY1.js +1 -0
  127. package/dist/web/assets/vendor-NJP34MHU.js +1 -0
  128. package/dist/web/assets/web-C3yK7kgI.js +148 -0
  129. package/dist/web/assets/web-CSZhWpVp.css +1 -0
  130. package/dist/web/assets/zh-tAs09DKy.js +1 -0
  131. package/dist/web/icon.svg +9 -0
  132. package/dist/web/index.html +63 -0
  133. package/dist/web/manifest.webmanifest +14 -0
  134. package/package.json +11 -8
@@ -0,0 +1,148 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BpmnDocument-DioCJiv7.js","./rolldown-runtime-B8BYMn-z.js","./vendor-NJP34MHU.js","./translator-Dt_jCGPm.js","./preload-helper-VRuDKI9K.js","./frontend-By89859W.js","./bridgeInstance-DzSjLJAc.js","./dist-CRJyslwo.js","./dist-DgvQWhKm.js","./engine-BPUfS3r2.js","./dist-BqwyxNP3.js","./engines-BaW52xZ_.js","./BpmnCanvas-BeOwGJEV.js","./platform-_nC9EyYA.js","./dialog-Cn1DzN2I.js","./httpHost-DPT9cNRG.js","./bpmnTheme-CebWk9Ei.js","./lib--h_vArmx.js","./dist-CHluRwHI.js","./dist-TNwbKIWT.js","./Viewer-C7pbHtwq.js","./dist--PmHUHDp.js","./dist-D0cjZCsW.js","./dist-DlbES2QN.js","./dist-f4FXNtig.js","./dist-CHkSydPE.js","./dist-Dup2uTdL.js","./dist-zHmj1-pd.js","./ui-DDJuNJWb.js","./preferences-Cfvg8oqM.js","./duplicate-CKn70NtG.js","./typing-CXvbBSPr.js","./dist-2wOiLlcG.js","./stackblur-es-Djj-lnDR.js","./array-move-Bc4mVEdq.js","./dist-DIdDTNn9.js","./groovy-C2AgVf_z.js","./dist-BYu4mHLv.js","./apply-B8eZkNJ6.js","./dockLayout-CxOMo-Nl.js","./samples-CeaUa4Fn.js","./dist-CxyFqsL2.js","./syntax-DBcQvmbn.js","./testCaseRuns-Bw2AfAfR.js","./useTrace-Rwk8eJY1.js","./documentBridge-BXU6mgKl.js","./shortcut-DONH578b.js","./AgentSettings-B_c5K0Hd.js","./formChecks-TAsEqw2_.js","./DmnDocument-ChFDTt1F.js","./UnreadableFileLayer-ep6zQMtt.js","./DmnDocument-VhMjHTN6.css","./FormDocument-TEeVD6T7.js","./index.es-fKIKPRSg.js","./purify.es-CyDa74pG.js","./FormDocument-URLcKn84.css","./TextDocument-DWg1EqKB.js","./files-Chpd_QD0.js","./source-frame-C6KIof5s.js","./intelligence-_ijxuAw5.js","./SourceDocument-p3iREvQI.js","./DiffDocument-t0gjzCba.js","./index.esm-CTLpq4ik.js","./diff-DMf6xJj1.js","./ScriptPane-DzBYUW23.js","./NewFileDialog-BPBljAGC.js","./QuickOpen-DOe23FAR.js","./ShortcutsDialog-D0_aCcNe.js","./SettingsDialog-YoMl6NJ1.js","./AgentsDialog-BtgwT_49.js","./ConflictDialog-B9V39KUg.js","./UploadDialog-ZOy1owan.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,l as h,n as g,o as _,r as v}from"./translator-Dt_jCGPm.js";import{t as y}from"./preload-helper-VRuDKI9K.js";import{n as b,t as x,v as S,x as C}from"./frontend-By89859W.js";import{Ht as w,J as T,Mt as E,Y as D,an as O,in as k,r as A,t as j}from"./bridgeInstance-DzSjLJAc.js";import{a as M,s as N,u as P}from"./engine-BPUfS3r2.js";import{Ct as F,St as I,n as L,t as R}from"./BpmnCanvas-BeOwGJEV.js";import{a as z,i as B,n as V,o as ee,r as H,t as U}from"./platform-_nC9EyYA.js";import{s as te}from"./engines-BaW52xZ_.js";import{s as ne}from"./testCaseRuns-Bw2AfAfR.js";import{t as re}from"./shortcut-DONH578b.js";import{_ as ie,a as W,c as G,d as ae,f as oe,g as se,h as ce,i as le,l as ue,m as de,o as fe,p as pe,s as me,t as he,u as ge,v as K}from"./AgentSettings-B_c5K0Hd.js";import{t as _e}from"./typing-CXvbBSPr.js";import{a as q}from"./httpHost-DPT9cNRG.js";import{k as ve}from"./bpmnTheme-CebWk9Ei.js";import{a as ye,c as be,f as J,g as xe,i as Se,l as Ce,m as we,n as Y,o as Te,p as X,r as Z,s as Ee,t as De,u as Oe}from"./ui-DDJuNJWb.js";import{i as Q,n as ke,o as Ae,r as je,t as Me}from"./preferences-Cfvg8oqM.js";import{a as Ne,d as Pe,f as Fe,i as $,n as Ie,o as Le,p as Re,r as ze,s as Be,u as Ve}from"./files-Chpd_QD0.js";import{n as He,t as Ue}from"./documents-XvKodSic.js";import{Nn as We}from"./duplicate-CKn70NtG.js";import{I as Ge}from"./dist-D0cjZCsW.js";import{a as Ke,o as qe}from"./dist-f4FXNtig.js";import{a as Je,i as Ye,o as Xe,r as Ze,t as Qe}from"./dockLayout-CxOMo-Nl.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)}})();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 $e=`properties`,et=280,tt=.3,nt=320,rt=480;function initialSidebar(){return{hidden:!1,tab:$e,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(rt,Math.max(nt,Math.round(e*tt))):nt}function widthLimits(e){return Number.isFinite(e)?{min:et,max:Math.max(et,Math.floor(e/2))}:{min:et,max:et}}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 D(e,T,t)}function titleCommit(e,t){let n=t.trim();return n===``||n===e?null:n}function isRenameKey(e){return e===`F2`}var it=`.bio-properties-panel, .dmn-decision-table-container`;function localisePanel(e){if(e.nodeType!==Node.ELEMENT_NODE)return;let t=e,n=t.closest(it)===null?[...t.querySelectorAll(it)]:[t];for(let e of n)I(e),e.querySelectorAll(`[title], [aria-label]`).forEach(I),e.querySelectorAll(`button`).forEach(F)}function translatePanelLabels(){localisePanel(document.body),new MutationObserver(e=>{for(let t of e)t.type===`attributes`?t.target.closest(it)&&I(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(Ee,{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 at=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)||at.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 ot=``+new URL(`colors-dark-C7vOziWz.css`,import.meta.url).href,st=``+new URL(`colors-dracula-CXhMcc1Z.css`,import.meta.url).href,ct=``+new URL(`colors-light-CyT40N4M.css`,import.meta.url).href,lt={light:{isDark:!1},dark:{isDark:!0},dracula:{isDark:!0}},ut=`light`;function themeNameFor(e,t){let n=e?.toLowerCase();return n&&n in lt?n:t?`dark`:ut}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":ot,"./colors-dracula.css":st,"./colors-light.css":ct})[`./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 lt?e:ut}function toggleDarkMode(){let e=lt[getCurrentTheme()].isDark?`light`:`dark`;return applyTheme(e),e}var dt=`--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(`.`),ft=/^#[0-9a-f]{6}([0-9a-f]{2})?$/i;function applyIdeTheme(e){clearIdeTheme();let t=new Set(dt),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`&&ft.test(a)&&(n.style.setProperty(e,a),i+=1)}return i}function clearIdeTheme(){let e=document.documentElement;for(let t of dt)e.style.removeProperty(t)}var pt=[`ide`,`light`,`dark`,`dracula`],mt=null,ht=null,gt=null;function themeChoiceOf(e){return typeof e==`string`&&e!==`ide`&&e in lt?e:`ide`}function currentThemeChoice(){return themeChoiceOf(Q()?.theme)}function nameOf$1(e){let t=e?.toLowerCase();return t&&t in lt?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(),mt&&applyIdeTheme(mt);let e=nameOf$1(mt?.theme)??ht;e?announce(e,e):window.dispatchEvent(new CustomEvent(`bpmn-theme-changed`,{detail:{theme:null}}))}function applyThemeChoice(){let e=currentThemeChoice();gt=e,e===`ide`?showHostTheme():(clearIdeTheme(),document.documentElement.setAttribute(`data-theme-choice`,e),announce(e,e))}function chooseTheme(e){Ae({theme:e}),applyThemeChoice()}function rememberHostTheme(e){ht=e}function receiveHostThemeName(e){let t=nameOf$1(e);t?(ht=t,mt=null,currentThemeChoice()===`ide`&&(clearIdeTheme(),announce(t,e))):console.warn(`[Theme] Ignoring unknown theme from window.setTheme:`,e)}function followThemeChoice(){return je(()=>{currentThemeChoice()!==gt&&applyThemeChoice()})}var _t=`penstock-web`,vt=`drafts`,yt=`root`,bt=`penstock-page:`,xt=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(_t,1);n.onupgradeneeded=()=>{n.result.createObjectStore(vt,{keyPath:`id`}).createIndex(yt,`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(vt,`readwrite`),r=n.objectStore(vt);t.forEach(e=>r.delete(e)),e.forEach(e=>r.put(e)),await finished(n)}async list(e){return request((await this.database()).transaction(vt,`readonly`).objectStore(vt).index(yt).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(`${bt}${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(bt)).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??xt,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()}},St={open:new Set,shut:new Set},Ct=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,Ct)),shut:new Set(t.slice(0,Ct))}}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,Ct),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 wt=`doc:`,Tt=8,Et=64,docPanel=e=>`${wt}${e}`,pathOfPanel=e=>e.startsWith(wt)?e.slice(4):null,Dt=`script:`,scriptPanel=e=>`${Dt}${e}`,scriptIdOf=e=>e.startsWith(Dt)?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:`${wt}${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>Tt)return null;let c=e;if(c.t===`g`){if(a>=Et)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(wt)){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(wt)?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 Ot=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,Ct),toolShut:[...t.tool?.shut??[]].slice(0,Ct)}}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,Ot);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 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 kt=new Map,At=new Map;function focusSource(e,t){kt.set(e,t),At.get(e)?.forEach(e=>e(t))}function lineWanted(e){return kt.get(e)??null}function onSourceFocus(e,t){let n=At.get(e);return n||(n=new Set,At.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&At.delete(e)}}var jt=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=Re(`source`,e);focusSource(n,t??null),await this.store.open(n,`source`)}async openText(e){await this.store.open(Re(`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??Be(e);n===`bpmn`||n===`dmn`||n===`form`||n===`testCase`||n===`template`?await this.store.open(e,n):await this.openSource(e)}async openDiff(e){let t=Re(`diff`,e),n=m(`app.webHost.compare.tab`,{name:Ie(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),jt);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)}}},Mt=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=Mt){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))}},Nt={bpmn:()=>y(()=>import(`./BpmnDocument-DioCJiv7.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]),import.meta.url),dmn:()=>y(()=>import(`./DmnDocument-ChFDTt1F.js`).then(e=>e.DmnDocument),__vite__mapDeps([49,1,2,3,4,5,6,7,8,9,10,11,13,14,15,44,45,43,46,47,28,29,31,16,17,18,19,20,21,22,23,24,25,26,27,39,30,32,50,51]),import.meta.url),form:()=>y(()=>import(`./FormDocument-TEeVD6T7.js`).then(e=>e.FormDocument),__vite__mapDeps([52,1,2,3,4,6,7,8,9,10,11,13,5,14,15,45,43,46,47,28,29,31,16,17,18,19,20,21,22,23,24,25,26,27,39,32,34,53,41,54,48,50,55]),import.meta.url),text:()=>y(()=>import(`./TextDocument-DWg1EqKB.js`).then(e=>e.TextDocument),__vite__mapDeps([56,1,2,3,4,57,22,18,35,23,24,25,58,59,6,7,8,9,10,11,13,5,14,15]),import.meta.url),code:()=>y(()=>import(`./SourceDocument-p3iREvQI.js`).then(e=>e.SourceDocument),__vite__mapDeps([60,1,2,3,4,57,22,18,35,23,24,25,58,59,6,7,8,9,10,11,13,5,14,15]),import.meta.url),diff:()=>y(()=>import(`./DiffDocument-t0gjzCba.js`).then(e=>e.DiffDocument),__vite__mapDeps([61,1,2,3,4,28,6,7,8,9,10,11,14]),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=ze(t);if(Fe(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`?ee(r,t()??``):r;return{stored:o,stamp:await e.saveProjectFile(ze(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(we,{locale:g(),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(J,{title:e.title,size:`small`,destructive:e.warning,onClose:()=>t(!1),onSubmit:()=>t(!0),footer:l(X,{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 Pt=`
3
+ .bpmn-preview {
4
+ display: flex;
5
+ flex-direction: column;
6
+ width: 100%;
7
+ height: 100vh;
8
+ background: var(--theme-bg-primary);
9
+ color: var(--theme-fg-primary);
10
+ font-size: var(--type-size-body);
11
+ }
12
+
13
+ .bpmn-preview__toolbar {
14
+ flex: 0 0 auto;
15
+ display: flex;
16
+ align-items: center;
17
+ gap: 4px;
18
+ min-height: 32px;
19
+ padding: 4px 12px;
20
+ background: var(--theme-bg-primary);
21
+ border-bottom: 1px solid var(--theme-border-secondary);
22
+ }
23
+ .bpmn-preview__button {
24
+ display: inline-flex;
25
+ align-items: center;
26
+ height: 28px;
27
+ padding: 0 8px;
28
+ font: inherit;
29
+ font-size: var(--type-size-small);
30
+ font-weight: 500;
31
+ color: var(--theme-fg-primary);
32
+ background: transparent;
33
+ border: none;
34
+ border-radius: 6px;
35
+ cursor: pointer;
36
+ transition: background-color var(--motion-fast) var(--motion-ease-out), color var(--motion-fast) var(--motion-ease-out);
37
+ }
38
+ .bpmn-preview__button:hover { background: var(--theme-bg-hover); }
39
+ .bpmn-preview__button:active { background: var(--theme-bg-tertiary); }
40
+ .bpmn-preview__button--active { background: var(--theme-bg-hover); color: var(--theme-accent-primary); }
41
+ .bpmn-preview__button--primary { background: var(--theme-accent-primary); color: var(--theme-fg-on-accent); }
42
+ .bpmn-preview__button--primary:hover { background: var(--theme-accent-hover); }
43
+ .bpmn-preview__button--primary:active { background: var(--theme-accent-pressed); }
44
+ .bpmn-preview__button:focus-visible { outline: 2px solid var(--theme-accent-primary); outline-offset: 1px; }
45
+ .bpmn-preview__spacer { flex: 1 1 auto; }
46
+ .bpmn-preview__summary { display: flex; align-items: center; gap: 12px; font-size: var(--type-size-small); color: var(--theme-fg-secondary); }
47
+ .bpmn-preview__stat { display: inline-flex; align-items: center; gap: 5px; }
48
+
49
+ .bpmn-preview__body { flex: 1 1 auto; display: flex; min-height: 0; }
50
+ .bpmn-preview__panes { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
51
+ .bpmn-preview__panes--columns { flex-direction: row; }
52
+ .bpmn-preview__pane { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
53
+ .bpmn-preview__panes--rows > .bpmn-preview__pane + .bpmn-preview__pane { border-top: 1px solid var(--theme-border-secondary); }
54
+ .bpmn-preview__panes--columns > .bpmn-preview__pane + .bpmn-preview__pane { border-left: 1px solid var(--theme-border-secondary); }
55
+
56
+ .bpmn-preview__title {
57
+ flex: 0 0 auto;
58
+ display: flex;
59
+ align-items: center;
60
+ height: 28px;
61
+ padding: 0 12px;
62
+ font-size: var(--type-size-small);
63
+ font-weight: 600;
64
+ color: var(--theme-fg-secondary);
65
+ background: var(--theme-bg-secondary);
66
+ border-bottom: 1px solid var(--theme-border-secondary);
67
+ }
68
+ .bpmn-preview__canvas { flex: 1 1 auto; min-height: 0; position: relative; }
69
+ .bpmn-preview__canvas > .bpmn-canvas-container { width: 100%; height: 100%; }
70
+ .bpmn-preview__empty {
71
+ display: flex;
72
+ align-items: center;
73
+ justify-content: center;
74
+ height: 100%;
75
+ font-size: var(--type-size-small);
76
+ color: var(--theme-fg-tertiary);
77
+ }
78
+
79
+ .bpmn-preview__changes {
80
+ flex: 0 0 264px;
81
+ display: flex;
82
+ flex-direction: column;
83
+ min-height: 0;
84
+ background: var(--theme-bg-secondary);
85
+ border-left: 1px solid var(--theme-border-secondary);
86
+ }
87
+ .bpmn-preview__changes-list { flex: 1 1 auto; overflow-y: auto; padding: 4px 0; }
88
+ .bpmn-preview__change {
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 8px;
92
+ width: 100%;
93
+ height: 26px;
94
+ padding: 0 12px;
95
+ font: inherit;
96
+ font-size: var(--type-size-small);
97
+ color: var(--theme-fg-primary);
98
+ background: transparent;
99
+ border: none;
100
+ text-align: left;
101
+ cursor: pointer;
102
+ }
103
+ .bpmn-preview__change:hover { background: var(--theme-bg-hover); }
104
+ .bpmn-preview__change--selected { background: var(--theme-bg-selected); }
105
+ .bpmn-preview__dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; }
106
+ .bpmn-preview__change-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
107
+ .bpmn-preview__change-type { flex: 0 0 auto; font-size: var(--type-size-tiny); color: var(--theme-fg-tertiary); }
108
+
109
+ .bpmn-preview__dot--added { background: var(--theme-success); }
110
+ .bpmn-preview__dot--removed { background: var(--theme-error); }
111
+ .bpmn-preview__dot--changed { background: var(--theme-syntax-yellow); }
112
+ .bpmn-preview__dot--moved { background: var(--theme-accent-primary); }
113
+ .bpmn-preview__dot--resized { background: var(--theme-syntax-purple); }
114
+
115
+ .bpmn-preview .djs-palette,
116
+ .bpmn-preview .djs-context-pad,
117
+ .bpmn-preview .bjsl-button,
118
+ .bpmn-preview .bjsl-overlay,
119
+ .bpmn-preview .bts-toggle-mode { display: none !important; }
120
+
121
+ .diff-added .djs-visual > :first-child { stroke: var(--theme-success) !important; stroke-width: 3px !important; }
122
+ .diff-removed .djs-visual > :first-child { stroke: var(--theme-error) !important; stroke-width: 3px !important; }
123
+ .diff-changed .djs-visual > :first-child { stroke: var(--theme-syntax-yellow) !important; stroke-width: 3px !important; }
124
+ .diff-moved .djs-visual > :first-child { stroke: var(--theme-accent-primary) !important; stroke-width: 3px !important; }
125
+ .diff-resized .djs-visual > :first-child { stroke: var(--theme-syntax-purple) !important; stroke-width: 3px !important; }
126
+ `;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([y(()=>import(`./dist-DgvQWhKm.js`).then(e=>e.n),__vite__mapDeps([8,1,7]),import.meta.url),y(()=>import(`./index.esm-CTLpq4ik.js`),__vite__mapDeps([62,1,7]),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(R,{ref:a,xml:t,modelerFactory:e=>L({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=Pt,document.head.appendChild(e)}function PlacePicker({title:e,places:n,relative:r,done:i}){let[a,o]=t(0);return l(J,{title:e,size:`medium`,onClose:()=>i(null),onSubmit:()=>i(a),footer:l(X,{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(J,{title:m(`app.webHost.rename.title`),size:`medium`,onClose:()=>!i&&r(!1),onSubmit:()=>void run(),footer:l(X,{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(Oe,{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=Te(),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 x=y!==null||p.length>0&&!u,convert=()=>{v.submit(),!x&&i({choice:`CONVERT`,folder:a.trim(),replace:u})},cancel=()=>i({choice:`CANCEL`,folder:``,replace:!1}),S=c(()=>e.open.filter(e=>e.manual).length,[e]);return l(J,{title:m(`app.webHost.migration.title`,{name:e.name,target:e.target}),size:`large`,onClose:cancel,onSubmit:convert,footer:l(X,{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:S})}),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(Ce,{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(Ce,{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`,x=i&&!i.detail&&i.trialDaysLeft!=null&&i.trialDaysLeft>0?m(`app.webHost.licence.trial`,{days:i.trialDaysLeft}):null;return l(J,{title:m(`app.webHost.licence.title`),size:`medium`,onClose:r,onSubmit:()=>void activate(),footer:l(X,{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`),x&&l(`span`,{class:`type-help`,children:[` `,x]})]}),n&&!y&&l(`p`,{class:`type-help web-host__intro`,children:m(`app.webHost.licence.needed`)}),l(Ce,{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(Ce,{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(b.PRO),children:m(`app.webHost.licence.buyPro`)}),l(`button`,{type:`button`,class:`ui-button`,disabled:d,onClick:()=>void buy(b.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(J,{title:m(e===`copy`?`app.webHost.clipboard.copyTitle`:`app.webHost.clipboard.pasteTitle`),size:`medium`,onClose:()=>r(null),footer:l(X,{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 Ft=new Set;function onLicenceChange(e){return Ft.add(e),()=>{Ft.delete(e)}}function announceLicenceChange(){for(let e of Ft)e()}function desktopCapability(e){let t=(e??(typeof window>`u`?{}:window)).penstockDesktop;return!t||typeof t.onCommand!=`function`||typeof t.confirm!=`function`||typeof t.setActiveFile!=`function`?null:t}function routeDesktopCommand(e,t,n){if(!Object.hasOwn(e,t))return!1;let r=e[t];return typeof r==`function`&&(r(n),!0)}var It=`download://`,Lt=`upload://`,Rt=1500;function environment(){return{confirm:e=>{let t=desktopCapability();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 zt=/\.(bpmn(\.xml)?|dmn|form)$/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 V{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 x(this.config)}bindActiveFile(e){this.active.read=()=>{let t=e();return t?ze(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}}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?H.error(e):H.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(We));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&&(zt.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=H.info(m(`app.webHost.rename.offer`,{count:t.sites.length,from:e.from,summary:n}),{label:m(`app.webHost.rename.review`),run:()=>{H.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(),H.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),H.info(m(`app.webHost.licence.needed`),{label:m(`app.webHost.licence.activate`),run:()=>void this.showLicence()})),!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 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 z(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??B(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}`:`${It}${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`${It}${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),Rt);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=`${Lt}${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(It))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(B(this.getBpmnFilePath(),`svg`,m(`app.export.untitledFile`)),new Blob([e],{type:`image/svg+xml`}))}async exportPng(e){download(B(this.getBpmnFilePath(),`png`,m(`app.export.untitledFile`)),e)}async exportPdf(e){download(B(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 Bt={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`)??Bt.background,n=resolvedColour(`--theme-fg-primary`)??Bt.foreground,r=currentThemeChoice();e.setTheme(r===`ide`?`system`:r===`light`?`light`:`dark`),e.setTitleBarColours({background:t,foreground:n})}function installDesktop(e){let t=desktopCapability();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 Vt=[{command:`quickOpen`,keys:`Mod+P`,typing:`allow`},{command:`actions`,keys:`Mod+Shift+P`,typing:`allow`},{command:`save`,keys:`Mod+S`,typing:`allow`},{command:`saveAll`,keys:`Mod+Shift+S`,typing:`allow`},{command:`closeTab`,keys:`Mod+W`,typing:`allow`},{command:`closeTab`,keys:`Mod+Alt+W`,typing:`allow`},{command:`nextTab`,keys:`Ctrl+Tab`,typing:`allow`},{command:`previousTab`,keys:`Ctrl+Shift+Tab`,typing:`allow`},{command:`nextTab`,keys:`Mod+Alt+PageDown`,typing:`allow`},{command:`previousTab`,keys:`Mod+Alt+PageUp`,typing:`allow`},{command:`toggleSidebar`,keys:`Mod+B`,typing:`block`},{command:`askAgent`,keys:`Mod+Alt+A`,typing:`allow`},{command:`splitView`,keys:`Mod+\\`,typing:`allow`},{command:`newFile`,keys:`Mod+Alt+N`,typing:`allow`},{command:`shortcuts`,keys:`Mod+/`,typing:`block`},...[1,2,3,4,5,6,7,8,9].map(e=>({command:`tab${e}`,keys:`Mod+${e}`,typing:`allow`}))];function commandFor(e,t){for(let n of Vt)if(D(e,n.keys,t))return n.typing===`block`&&_e(e.target??null)?null:n.command;return null}var Ht=[{action:`undo`,keys:`Mod+Z`},{action:`redo`,keys:`Mod+Shift+Z`},{action:`redo`,keys:`Mod+Y`}];function historyFor(e,t){return Ht.find(n=>D(e,n.keys,t))?.action??null}var Ut={newFile:[`Mod+N`]};function keysBoundTo(e,t){return(t?Ut[e]:void 0)||Vt.filter(t=>t.command===e).map(e=>e.keys)}function keysOf(e,t,n=desktopCapability()!==null){let r=keysBoundTo(e,n)[0];return r?re(r,t):void 0}function allKeysOf(e,t,n=desktopCapability()!==null){return keysBoundTo(e,n).map(e=>re(e,t)??e)}function withKeys(e,t,n){let r=keysOf(t,n);return r?`${e} (${r})`:e}function tabIndexFor(e,t){let n=/^tab([1-9])$/.exec(e);if(!n||t===0)return null;let r=Number(n[1]);return r===9?t-1:r<=t?r-1:null}var Wt={undo:qe,redo:Ke};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?Ge.findFromDOM(n):null;return r?(Wt[e](r),!0):!1}var Gt=new Set([`cut`,`copy`]),Kt=null;function registerEditCommands(e,t){return Kt={owner:e,read:t},()=>{Kt?.owner===e&&(Kt=null)}}function runEditCommand(e,t){if(_e(t.focus))return runCodeEditorHistory(e,t.focus);if(t.textSelected&&Gt.has(e))return!1;let n=Kt?.read()[e];if(!n)return!1;try{n()}catch(t){console.error(`Penstock could not ${e}:`,t)}return!0}var qt=`application/x-penstock-panel`,Jt=null,Yt=new Set;function dragging(){return Jt}function beginDrag(e,t){t.dataTransfer?.setData(qt,e),t.dataTransfer?.setData(`text/plain`,e),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`),Jt=e,Yt.forEach(e=>e())}function endDrag(){Jt!==null&&(Jt=null,Yt.forEach(e=>e()))}function useDragging(){let[,e]=t(0);return f(()=>{let listener=()=>e(e=>e+1);return Yt.add(listener),()=>void Yt.delete(listener)},[]),Jt}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 Xt={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}},Zt=new Set([`cut`,`copy`,`paste`]);function editRequest(e,t,n,r){if(t||n&&Zt.has(e))return{native:!0,key:null};let{key:i,shift:a}=Xt[e];return{native:!1,key:{key:i,metaKey:r,ctrlKey:!r,shiftKey:a}}}function replayEdit(e){let t=document.activeElement??document.body,n=desktopCapability(),r=editRequest(e,_e(t),t.closest(`.djs-container`)!==null,n?.platform===`darwin`);r.native?n?.editField?n.editField(e):document.execCommand(e):r.key&&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=desktopCapability();if(e)return e.onCommand((e,n)=>{routeDesktopCommand(t.current,e,n)})},[])}var Qt={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},$t=8;function visibleWindow(e,t,n){return{start:Math.max(0,Math.floor(e/28)-$t),end:Math.min(n,Math.ceil((e+t)/28)+$t)}}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 en={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:en[e]}})}e(Icon$1,`Icon`);var tn=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&&tn.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 nn=600,rn=12,an=800,on=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,T]=t(null),[E,D]=t(0),[O,k]=t(nn),A=o(null),j=o({text:``,at:0}),M=o(new Map),N=o(null),[P,F]=t(null),I=o(`web-tool-${Math.random().toString(36).slice(2,8)}`),L=o(r);L.current=r;let R=c(()=>flattenTool(_.roots,r,v),[_.roots,r,v]),z=c(()=>nodeCount(_.roots),[_.roots]);f(()=>{if(_.phase!==`ready`||_.roots.length===0)return;let e=pruneExpansion(L.current,_.roots);sameExpansion(e,L.current)||(L.current=e,i(e))},[_.roots]),u(()=>{let e=A.current;if(!e)return;let measure=()=>k(e.clientHeight||nn);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[R.length===0]);let B=n(e=>e===null?-1:R.findIndex(t=>t.node.id===e),[R]),V=B(b)>=0?B(b):R.length>0?0:-1,ee=R[V],H=n(e=>{let t=A.current;if(!t||e<0)return;let n=e*28,r=t.clientHeight||nn;n<t.scrollTop?t.scrollTop=n:n+28>t.scrollTop+r&&(t.scrollTop=n+28-r),D(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,L.current));if(n.length>0){let e=L.current;for(let t of n)e=setOpen(e,t,!0);L.current=e,i(e)}y(``),x(e),T(e)},[h?.serial]),f(()=>{if(!w)return;let e=R.findIndex(e=>e.node.id===w);e<0||(H(e),A.current?.focus({preventScroll:!0}),T(null))},[w,R]);let U=n((e,t)=>{if(!hasChildren(e))return;let n=L.current,r=setOpen(n,e,t??!isOpen(e,n));L.current=r,i(r)},[i]),te=n(t=>{t&&e.run(t)},[e]),activate=e=>{x(e.node.id),e.node.open?te(e.node.open):U(e.node)},shortcutOf=e=>{if(e===`FIND_USAGES`)return re(`Alt+F7`,s)??void 0;if(e===`COPY`)return re(`Mod+C`,s)??void 0;if(e===`GO_TO_IMPLEMENTATION`)return re(`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:()=>te(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:()=>te(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=R[V];if(!t)return;if(e.key===`ContextMenu`||e.key===`F10`&&e.shiftKey){e.preventDefault();let n=A.current?.getBoundingClientRect(),r=V*28-(A.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(),te(n));return}if(e.altKey&&e.key===`F7`){let n=keyedAction(t.node,`FIND_USAGES`);n&&(e.preventDefault(),te(n));return}if(e.key===`F4`&&!e.altKey&&!e.ctrlKey&&!e.metaKey){let n=keyedAction(t.node,`GO_TO_IMPLEMENTATION`);n&&(e.preventDefault(),te(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-j.current.at>an?e.key:j.current.text+e.key;j.current={text:n,at:t};let r=typeAhead(R,V,n);r>=0&&(e.preventDefault(),x(R[r].node.id),H(r));return}let n=Math.max(1,Math.floor((A.current?.clientHeight||nn)/28)-1),r=nextCursor(R,V,e.key,n);if(!r)return;e.preventDefault();let i=R[r.index];r.toggle&&i&&U(i.node,r.toggle===`open`),i&&(x(i.node.id),H(r.index))},serial=e=>{let t=M.current.get(e);return t===void 0&&(t=M.current.size+1,M.current.set(e,t)),t},{start:ne,end:ie}=visibleWindow(E,O,R.length),W=R.slice(ne,ie),G=_.roots.length>0,ae=_.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:()=>te(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),D(0),A.current&&(A.current.scrollTop=0)},onKeyDown:e=>{e.key===`ArrowDown`&&R.length>0&&(e.preventDefault(),A.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`)})]}),ae&&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:z})}),_.phase===`loading`&&!G&&l(`p`,{class:`web-tool__status type-help`,role:`status`,children:m(`app.web.toolPanel.loading`)}),_.phase===`error`&&!G&&l(Ee,{title:m(`app.web.toolPanel.error`),hint:_.error??void 0,actions:[{label:m(`app.common.retry`),run:()=>void e.refresh()}]}),_.phase===`ready`&&!G&&!ae&&l(Ee,{title:m(`app.web.toolPanel.empty`),hint:m(`app.web.toolPanel.emptyHint`),actions:[{label:m(`app.web.toolPanel.refresh`),run:()=>void e.refresh()}]}),G&&R.length===0&&l(`p`,{class:`web-tool__status type-help`,role:`status`,children:m(`app.web.toolPanel.noMatch`)}),l(`div`,{ref:A,class:`web-tool__list`,role:`tree`,"aria-label":m(`app.web.toolPanel.label`),tabIndex:R.length>0?0:-1,hidden:R.length===0,"aria-activedescendant":ee?`${I.current}-${serial(ee.node.id)}`:void 0,onKeyDown,onScroll:e=>D(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:`${R.length*28}px`},children:W.map((e,t)=>{let n=ne+t,{node:r}=e,i=n===V,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:`${I.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`:``}${P===r.id?` is-drop`:``}`,"aria-current":c?`true`:void 0,draggable:!!o,onDragStart:e=>{o&&(N.current=o,e.dataTransfer?.setData(`application/x-penstock-entry`,r.id),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`))},onDragEnd:()=>{N.current=null,F(null)},onDragOver:e=>{let t=N.current;d&&t&&s!==null&&d.canDrop(t,s)&&(e.preventDefault(),e.stopPropagation(),F(r.id))},onDrop:e=>{let t=N.current;N.current=null,F(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*rn}px`},title:tooltipOf(r),onClick:()=>{A.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(),A.current?.focus({preventScroll:!0}),x(r.id),U(r,e.expanded!==!0))},children:hasChildren(r)&&l(Icon$1,{name:`chevron`})}),l(Icon$1,{class:`web-tool__icon${r.icon&&on.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(Se,{label:m(`app.web.toolPanel.menu`),at:S.at,items:S.items,returnFocusTo:S.opener,onClose:()=>C(null)}),d?.dialogs]})}var sn={file:()=>null,check:async()=>void 0,element:async()=>null,peek:()=>null,subscribe:()=>()=>void 0,openFile:()=>void 0,openElement:()=>void 0,openCode:()=>void 0},cn=i(sn);function useLinks(){return r(cn)}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 j().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=j();return!t?.requestFeature||!await t.requestFeature(e)?!1:(await a(),!0)}catch{return!1}},[a]),refresh:a}}var ln=`app.agent.exited`,un=`app.agent.installFailed`,dn=`app.agent.npmMissing`,fn=new Set([ln,un,dn,`app.agent.unpublished`,`app.agent.serviceExited`,`app.agent.serviceNotStarted`]);function isRawOutput(e){return fn.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 pn=/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`||pn.test(`${e.key} ${e.detail}`))?`signedOut`:`ended`}var mn={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)||(mn[t&&mn[t]?t:e.find(e=>e.source===`preset`&&mn[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 hn=/^(?:mcp__penstock__|penstock_|penstock\/)([A-Za-z0-9_]+)/,gn=/^mcp__[A-Za-z0-9-]+__([A-Za-z0-9_]+)/,_n=new Set([`listDiagrams`,`showDiagram`,`editDiagram`,`checkDiagram`,`analyzeFlow`,`listScenarios`,`checkCodeLinks`]),vn=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=hn.exec(e);if(t)return t[1];let n=gn.exec(e);return n?n[1]:e}function ownToolName(e){let t=hn.exec(e.title.trim());if(!t)return null;let n=camel(t[1]);return _n.has(n)?n:null}function isBookkeeping(e){return vn.has(bareName(e.title.trim()).replace(/[\s_-]+/g,``).toLowerCase())}function toolTitle(e){let t=e.title.trim(),n=hn.exec(t);if(n){let e=camel(n[1]);return _n.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 yn=/```[^\n]*\n([\s\S]*?)```/g,bn=/<\?xml|<bpmn:definitions|<definitions\b/;function longestFence(e){let t=0;for(let n of e.matchAll(yn))t=Math.max(t,n[1].split(`
127
+ `).length);return t}var xn=/<\/(?:bpmn:)?definitions>/;function masked(e){return e.replace(yn,e=>` `.repeat(e.length))}function fenceDocument(e){let t=masked(e),n=t.search(bn);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(`
128
+ `)?``:`
129
+ `,c=o===``||o.startsWith(`
130
+ `)?``:`
131
+ `;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(bn.test(t.text.replace(yn,``)))return`document`;if(longestFence(t.text)>12)return`long`}return null}var Sn={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-${Sn[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:`${w(t)} · ${e}`,"aria-label":m(`app.aiBlocks.selectElement`,{type:w(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 Cn=new Set([`bpmn`,`dmn`,`form`]),wn={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=Cn.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?wn.diagram:wn.code}}),l(`span`,{class:`element-chip__name`,children:e})]})}var Tn={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"/>`,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"/>`,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:Tn[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 En=2e5,Dn=300,On=/^ {0,3}(`{3,}|~{3,})\s*([\w+#.-]*)\s*$/,kn=/^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/,An=/^(\s*)[-*+]\s+(.*)$/,jn=/^(\s*)(\d{1,9})[.)]\s+(.*)$/,Mn=/\.(?:bpmn|dmn|form)$/i,Nn=/^((?:[\w.@-]+\/)*[\w.@-]+\.[A-Za-z][A-Za-z0-9]{1,9})(?:#([A-Za-z_][\w.-]*)|:(\d{1,7}))?$/,Pn=/^https?:\/\//i,Fn=/([\s,;()[\]{}<>"'`]+)/,In=/[.,;:!?]+$/;function safeUrl(e){let t=e.trim();if(!Pn.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>Dn||e.length<3)return null;let t=Nn.exec(e);if(!t)return null;let n=t[1],r=t[2]??null;return r!==null&&!Mn.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>Dn*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(Fn),n=[],r=``,flush=()=>{r&&n.push({kind:`text`,text:r}),r=``};for(let e of t){if(e===``||e.length>Dn){r+=e;continue}if(Pn.test(e)){let t=e.replace(In,``),i=safeUrl(t);if(i){flush(),n.push({kind:`link`,href:i,label:t}),r+=e.slice(t.length);continue}}let t=e.replace(In,``),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(`
132
+ `)){flush();let r=e.slice(a+t,o).trim(),i=referenceOf(r.replace(In,``));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(`
133
+ `)){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(`
134
+ `)&&!r.includes(`[`)){let o=matching(e,t+2),s=o>t?e.slice(t+2,o):``;if(o>t&&s&&!s.includes(`
135
+ `)){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 Ln=/[\p{L}\p{N}_]/u;function emphasisEnd(e,t,n,r){let i=e[t+1];if(!i||/\s/.test(i)||n===`_`&&t>0&&Ln.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===`
136
+ `)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&&Ln.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+Dn*2;r+=1){let t=e[r];if(t===`
137
+ `)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>En,n=(t?e.slice(0,En):e).split(`
138
+ `),r=[],i=[],a={list:null},o=null,endParagraph=()=>{i.length>0&&r.push({kind:`paragraph`,children:inlines(i.join(`
139
+ `))}),i=[]},endList=()=>{a.list=null};for(let e of n){if(o){let t=On.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(`
140
+ `),open:!1}),o=null):o.body.push(e);continue}let t=On.exec(e);if(t){endParagraph(),endList(),o={mark:t[1],lang:t[2],body:[]};continue}if(e.trim()===``){endParagraph(),endList();continue}let n=kn.exec(e);if(n){endParagraph(),endList(),r.push({kind:`heading`,level:n[1].length,children:inlines(n[2])});continue}let s=An.exec(e),c=s?null:jn.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(`
141
+ `),open:!0}),endParagraph(),{blocks:r,truncated:t}}var Rn=/\.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=Rn.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 zn=/"([^"\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(zn)){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&&Bn.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 Bn=/[\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 Vn=16,Hn=120,Un=60;function unionOf(e){if(e.length===0)return{x:0,y:0,width:Hn,height:Un};let t=Math.min(...e.map(e=>e.x))-Vn,n=Math.min(...e.map(e=>e.y))-Vn,r=Math.max(...e.map(e=>e.x+e.width))+Vn,i=Math.max(...e.map(e=>e.y+e.height))+Vn,a=Math.max(Hn,r-t),o=Math.max(Un,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 Wn=`Arial, sans-serif`,Gn=11,Kn=1.25,qn=.58,Jn=200,Yn=560,Xn=2,Zn=.55,Qn=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)?``:w(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/(Gn*qn)),r?Xn:Math.max(1,Math.min(3,Math.floor(e.bounds.height*t/(Gn*Kn))-0))),outside:r}}e(labelOf$1,`labelOf`);function fitted(e,t){let n=layoutOf(e,t);if(n.scale>=Zn)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(Qn,t/n.width,Jn/n.height),i=n,a=new Map;for(let o=0;o<3;o+=1){let o=Gn/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*qn,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*Kn+4)}i={x:s,y:n.y,width:c-s,height:l-n.y},r=Math.min(Qn,t/i.width,Jn/i.height)}return{view:i,scale:r,labels:a,size:Gn/r}}function Label({shape:e,label:t,size:n}){let{x:r,y:i,width:a,height:o}=e.bounds,s=n*Kn,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":Wn,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?`${w(e.type)} · ${e.name}`:w(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 $n=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*$n,y:t.y-a*$n};return`M${t.x},${t.y} L${o.x-a*$n*.4},${o.y+i*$n*.4} L${o.x+a*$n*.4},${o.y-i*$n*.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(Yn);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 er=1500,tr=2e5;function split(e){return e===``?[]:e.replace(/\r\n/g,`
142
+ `).split(`
143
+ `)}function shortestEdit(e,t){let n=e.length,r=t.length,i=Math.min(n+r,er),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>tr||r.length>tr)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(J,{title:e.title,subtitle:e.path,size:`large`,onClose:t,class:`assistant-diff-dialog`,footer:l(X,{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=pe(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=j();return e.openDiff&&U(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=pe(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 nr=``,rr=``;function compose(e,t){let n=Object.keys(t),r=e(Object.fromEntries(n.map((e,t)=>[e,`${nr}${t}${rr}`]))),i=[],a=RegExp(`${nr}(\\d+)${rr}`,`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=w(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 ir=/\.bpmn(\.xml)?$/i,ar=120;function isBpmnDiff(e){return ir.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 or={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`},sr=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,sr).join(`, `);return m(or[e],{ids:n.length>sr?`${r}, ...`:r,type:t[0].type?w(t[0].type):``})})}var cr=new Map;async function computeChange(e){if(e.newText.length>2e6||(e.oldText?.length??0)>2e6)return null;try{let{diffDiagrams:t}=await y(async()=>{let{diffDiagrams:e}=await import(`./diff-DMf6xJj1.js`);return{diffDiagrams:e}},__vite__mapDeps([63,1,9,7,8,38,3,4]),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=cr.get(t);if(n)return cr.delete(t),cr.set(t,n),n;let r=computeChange(e);return cr.set(t,r),cr.size>ar&&cr.delete(cr.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}},lr=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(w(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(pe(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,lr),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 ChipView({chip:e}){let t=useLinks();return e.kind===`file`?l(FileReference,{reference:{path:e.path,id:null,line:null},raw:e.label??pe(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 ur=new Map,dr=new Set,fr=100;function reportCheck(e,t){ur.delete(e),ur.set(e,t),ur.size>fr&&ur.delete(ur.keys().next().value);for(let e of[...dr])e()}function forgetCheck(e){if(ur.delete(e))for(let e of[...dr])e()}function checkOf(e){let t=`permission:${e}:`,n=null;for(let[e,r]of ur)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 dr.add(listener),()=>{dr.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`)}}function connectReviews(e){let t=new Map,n=!1,withdraw=t=>{for(let n of t.ids)e.canvas.channel.withdraw(n),forgetCheck(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)||!de(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)}},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 pr={allow:`app.assistant.question.allow`,reject:`app.assistant.question.deny`,allowAlways:`app.assistant.question.allowAlways`,rejectAlways:`app.assistant.question.denyAlways`};function labelOf(e){return pr[e.kind]?m(pr[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(Y,{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(Y,{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})})]}),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`)})]})]})}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(`
144
+ `),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 mr={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 Mark({status:e}){return e===`running`?l(`span`,{class:`assistant-mark is-running`,children:l(Z,{})}):e===`done`?l(`span`,{class:`assistant-mark is-done`,children:l(Y,{name:`check`})}):e===`failed`||e===`stopped`?l(`span`,{class:`assistant-mark is-failed`,children:l(Y,{name:`failed`})}):l(`span`,{class:`assistant-mark is-pending`,children:l(Y,{name:`pending`})})}function linesOf(e){return e.split(`
145
+ `).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(mr[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(Y,{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):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(Z,{}),` `,m(`app.assistant.working`)]}),r&&l(Question,{store:e,chatId:t,permission:r,focus:c,onShow:s?e=>s(r,e):void 0})]})}var hr=24,gr=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)>gr&&(a.current=!1)}else r.current=n.scrollHeight-n.scrollTop-n.clientHeight<hr}}}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(C.AI_CHAT)),h=d===`signedOut`&&i?.error?.signIn===!0,signIn=()=>{u(!0),e.signIn(r.id,()=>s(C.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(De,{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(Y,{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(Y,{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(Y,{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(Y,{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(Z,{}),` `,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(Z,{}),` `,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 _r=[dn,un];function FailureNotice({failure:e,choices:t,onRetry:n,onSettings:r}){let i=failureSummary(e,``),a=_r.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(De,{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 vr=i(!0),yr=vr.Provider;function useEditorActive(){return r(vr)}var br=i(null),xr=br.Provider;function useEditorElement(e){let t=r(br);return t?t.current?Xe(e,t.current):null:Xe(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 Sr=`penstock-chip-hover`,Cr=`penstock-chip-flash`,wr=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||wr.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,Sr):r.removeMarker(e,Sr))}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,Cr),clearTimeout(this.flashing.get(r)),this.flashing.set(r,setTimeout(()=>{this.flashing.delete(r),n.removeMarker(r,Cr)},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}}},Tr=new CanvasRegistry,Er=new Map,Dr=new Map,Or=new Set;function changed(){for(let e of[...Or])e()}function installScenarioOpener(e,t){return Dr.set(e,t),()=>{Dr.get(e)===t&&Dr.delete(e)}}function requestScenario(e,t){Er.set(e,t),changed(),Dr.get(e)?.()}function takeScenarioRequest(e){let t=Er.get(e)??null;return t!==null&&(Er.delete(e),changed()),t}function useScenarioRequest(e){let[,n]=t(0);return f(()=>{let again=()=>n(e=>e+1);return Or.add(again),()=>{Or.delete(again)}},[]),e===null?null:Er.get(e)??null}var kr=/\.(java|kt|kts|groovy|scala|py|js|mjs|cjs|ts|go|cs)$/,Ar=[[/\.bpmn(\.xml)?$/i,`bpmn`],[/\.dmn$/i,`dmn`],[/\.form$/i,`form`]],jr=Ar[0][0],Mr=250,Nr=1e3,Pr=/^([A-Za-z]:)?[\\/]/;async function parse(e){let{inspectModel:t}=await y(async()=>{let{inspectModel:e}=await import(`./apply-B8eZkNJ6.js`).then(e=>e.n);return{inspectModel:e}},__vite__mapDeps([38,1,3,4,9,7,8]),import.meta.url),n=await t(e,M(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 Ar.find(([t])=>t.test(e))?.[1]??null}async function projectRootOf(){return(await j().getProjectFiles()).root}function absoluteOf(e,t){return Pr.test(t)||e===``?t:`${e.replace(/[\\/]+$/,``)}/${t}`}async function scenarioNamesOf(e){let t=await j().readFile(e),{parsed:n}=await ne(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 Tr.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()},Mr))},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 j().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&&de(n.file,t)},liveOf=(e,t)=>own(e)?Tr.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)&&kr.test(e)){await settle();try{let t=await j().readCodeSnippet?.(absolute(e),1,1);o.set(e,(t?.lines.length??0)>0)}catch{o.set(e,!1)}}},async element(e,t){if(!jr.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(!jr.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(()=>j().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)?Tr.find(n):void 0)?.select(t)||await j().revealElement(n,t)}).catch(e=>console.error(`The element could not be revealed:`,e))},named(t){let n=e();if(!n?.file||!jr.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||!jr.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||!jr.test(t.file))return;await settle();let n=absolute(t.file),r=i.get(n);r&&Date.now()-r.at<Nr||await readScenarioNames(n)},openScenario(e,t){requestScenario(e,t)},highlight(e,t,n){let r=absolute(e);own(r)&&Tr.find(r)?.mark(t,n)},flash(e,t){let n=absolute(e);own(n)&&Tr.find(n)?.flash(t)},openCode(e,t){settle().then(()=>j().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 Fr=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=G(),n=useEditorActive();f(()=>{t&&t.start()},[t]),f(()=>ue(),[]),f(()=>{Fr.set(e.key,e);let t=e.canvas?Tr.set(e.key,e.canvas):void 0;return()=>{Fr.get(e.key)===e&&Fr.delete(e.key),t?.()}},[e]);let r=W(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 Ir=/\.(bpmn|dmn|form)$/i;function latestDiagramOf(e){return[...e.files].reverse().find(e=>Ir.test(e))??null}var Lr={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`?le(e.updated,t):m(Lr[e.state])}function Dot({state:e}){return e===`working`||e===`connecting`?l(`span`,{class:`assistant-chat__mark`,children:l(Z,{})}):l(`span`,{class:`assistant-chat__mark`,children:l(`i`,{class:`assistant-chat__dot is-${e}`})})}async function confirmDelete(e){return j().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=W(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=[...Fr.values()].find(e=>e.file!==null&&de(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(Y,{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 ce(),children:l(Y,{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(Se,{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(Y,{name:`chat`,class:`assistant-switch__icon`}),l(`span`,{class:`assistant-switch__title`,children:d}),l(Y,{name:`chevronDown`,class:`assistant-switch__chevron`})]}),c&&l(be,{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(Y,{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 Rr=40;function useFiles(){let[e,n]=t(null);return f(()=>{let e=!0;return j().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} ${w(e.type)}`.toLowerCase().includes(d)).slice(0,Rr),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,Rr);return l(be,{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:w(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:pe(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 zr=[],Br=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(`
146
+ `)}\n\n${t}`}function AssistantInput({store:e,editor:n,chat:r,transcript:i,surface:s,hint:d}){let{unlock:p}=useLicence(),h=W(e.subscribe,e.snapshot),g=h.drafts[n.key]??e.draft(n.key),_=n.selection,v=W(_?_.subscribe:noSubscribe,_?_.read:()=>zr,sameElements),y=v.map(e=>e.id).join(`
147
+ `);f(()=>e.releaseDismissed(n.key,y===``?[]:y.split(`
148
+ `)),[y]);let b=o(null),x=o(null),S=o(null),[w,T]=t(!1),[E,D]=t(!1),O=isBusy(r),k=g.text.trim()===``,A=c(()=>v.filter(e=>!g.dismissed.includes(`element:${e.id}`)),[v,g.dismissed]),j=Math.max(0,A.length-Br),M=h.choices.filter(e=>e.available),N=r?.agentId??h.agentId??M[0]?.id??``,P=i?.queue??[],F=oe(h,n.key,r,N),I=s===`dock`&&r!==null&&O&&(h.shown[r.id]!==!0||h.folded[r.id]===!0),L=s===`dock`&&k&&!w&&P.length===0&&!I,R=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(k||E)return;D(!0);let t=g.text;try{let r=await e.send({editor:n.key,text:messageOf(g),context:contextOf(n,A,g),authorize:()=>p(C.AI_CHAT)});(r===`sent`||r===`queued`)&&e.draft(n.key).text===t&&e.clearDraft(n.key)}finally{D(!1)}},stop=()=>{r&&e.stop(r.id)};return l(`form`,{class:`assistant-input${O?` is-busy`:``}${L?` is-resting`:``}`,"aria-label":m(`app.assistant.input.label`),onSubmit:e=>{e.preventDefault(),submit()},children:[I&&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(Y,{name:`hand`,class:`assistant-input__hand`}):l(Z,{}),l(`span`,{children:r.state===`waiting`||i?.permission?m(`app.assistant.input.stateWaiting`):m(`app.assistant.input.stateWorking`)})]}),P.length>0&&l(`ul`,{class:`assistant-input__queue`,"aria-label":m(`app.assistant.input.queued`),children:P.map(t=>l(`li`,{class:`assistant-input__queued`,children:[l(Y,{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(Y,{name:`close`})})]},t.id))}),l(`div`,{class:`assistant-input__chips`,role:`group`,"aria-label":m(`app.assistant.input.context`),children:[A.slice(0,Br).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(Y,{name:`close`})})]},t.id)),j>0&&l(`span`,{class:`assistant-chip type-help`,children:m(`app.assistant.input.more`,{count:j})}),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,ae(t)),children:l(Y,{name:`close`})})]},ae(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:R,"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())}}),L&&l(`span`,{class:`assistant-input__hint type-input`,"aria-hidden":`true`,children:R}),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":w,onClick:()=>T(e=>!e),children:l(Y,{name:`plus`})}),w&&l(Mentions,{store:e,editor:n,anchor:x.current,onClose:()=>T(!1)}),l(he,{store:e,state:h,editor:n.key,chat:r,agentId:N,options:F,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(Y,{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:k||E,children:E?l(Z,{}):l(Y,{name:`send`})})]})]})}var Vr=`.djs-palette, .fjs-palette-container`,Hr=`.bjs-powered-by, .fjs-powered-by-link`,Ur=`.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 Wr=`.assistant-dock`,Gr=`.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(Ur)].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=Ze(t,Ye(e).map(e=>e.getBoundingClientRect())),o=Math.max(0,Math.min(460,t.width-32)),s=cornerLayout({canvas:t.width,palette:widthOf(Vr),watermark:widthOf(Hr),card:widthOf(Ur),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 Kr=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+Kr):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(`${Vr}, ${Hr}, ${Ur}, ${Wr}, ${Gr}`));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 qr={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(qr),[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=qr,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(()=>G());return e}e(useStore$1,`useStore`);var Jr=e(()=>()=>void 0,`none`),Yr=360;function AssistantDock({editor:e,hidden:n,onAgentSettings:i}){let s=useStore$1(),c=W(s?s.subscribe:Jr,s?s.snapshot:()=>null),u=o(null),d=r(cn),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<Yr?`true`:`false`,e.dataset.coverLeft=r.coveredLeft>0?`true`:`false`,x(r.mode),y?.setCover(v?Qe(i,n,a):null)};publish();let n=observeCorner(t,[e],publish),r=Je(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 D=s.activeChat(e.key),O=D?c.transcripts[D.id]??null:null,k=D!==null&&c.shown[D.id]===!0&&(D.state===`failed`||c.folded[D.id]!==!0),A=b===`collapsed`&&!T,j=D&&(D.state===`working`||D.state===`connecting`)?`working`:D&&(D.state===`waiting`||O?.permission)?`waiting`:null,collapse=()=>{C(!1),requestAnimationFrame(()=>u.current?.querySelector(`.assistant-ask`)?.focus())};return l(cn.Provider,{value:d===sn?p:d,children:l(`div`,{ref:u,class:`assistant-dock${A?` is-collapsed`:``}${T?` is-overlay`:``}`,onKeyDown:e=>{e.key===`Escape`&&(D&&k&&D.state!==`failed`?(e.stopPropagation(),s.setFolded(D.id,!0)):b===`collapsed`&&S&&!w&&(e.stopPropagation(),collapse()))},children:A?l(`button`,{type:`button`,class:`assistant-ask${j?` is-${j}`:``}`,"aria-label":m(`app.assistant.input.ask`),title:m(`app.assistant.input.ask`),onClick:()=>C(!0),children:j===`working`?l(Z,{}):l(Y,{name:j===`waiting`?`hand`:`chat`})}):l(a,{children:[D&&k&&l(AssistantCard,{store:s,state:c,editor:e,chat:D,transcript:O,peeking:E,onChooseAgent:()=>u.current?.querySelector(`.assistant-settings`)?.click(),onAgentSettings:i??(()=>void ce())}),!k&&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(Y,{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(Y,{name:`close`})})})]}),l(`div`,{class:`assistant-card__body`,children:l(FailureNotice,{failure:c.failure,choices:c.choices,onRetry:()=>void s.resync(),onSettings:i??(()=>void ce())})})]}),l(AssistantInput,{store:s,editor:e,chat:D,transcript:O,surface:`dock`})]})})})}var Xr=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=W(e.subscribe,e.snapshot),i=r(cn),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(cn.Provider,{value:i===sn?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(Y,{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(Ee,{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(Z,{}),` `,m(`app.assistant.card.loading`)]}),s&&c?.status===`failed`&&l(Ee,{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(Ee,{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 ce()})]}),l(`div`,{class:`assistant-tab__input`,children:l(AssistantInput,{store:e,editor:t,chat:o,transcript:c,surface:`tab`})})]})})}function ChatTab(){let e=r(Xr),[n]=t(()=>G());return!n||!e?null:l(ChatTabBody,{store:n,editor:e})}var Zr={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);G()?.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?pe(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(()=>G());return W(e?e.subscribe:none,()=>e?e.snapshot().place:`off`)}function useChatStatus(e){let[n]=t(()=>G());return W(n?n.subscribe:none,()=>n?chatStatusOf(n.snapshot(),e):null)}function useRevealCount(e){let[n]=t(()=>G());return W(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&&G()?.returnToCard(e),n.current=t},[e,t])}function useChatAction(e,t){let n=useAiChatPlace(),r=useChatStatus(e);return{available:K(n).toolbarButton,open:t===Zr.id,status:r}}var Qr=null,$r=null,ei=new Set;function sameFacts(e,t){return JSON.stringify(e)===JSON.stringify(t)}function publishFacts(e,t){Qr===e&&sameFacts($r,t)||(Qr=e,$r=t,ei.forEach(e=>e()))}function retractFacts(e){Qr===e&&(Qr=null,$r=null,ei.forEach(e=>e()))}function useEditorFacts(){let[,e]=t(0);return f(()=>{let listener=()=>e(e=>e+1);return ei.add(listener),()=>void ei.delete(listener)},[]),$r}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(Z,{})}),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 ti=`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(ti));return Number.isFinite(t)&&t>=96?Math.round(t):null}catch{return null}}function saveChatsHeight(e,t){try{t===null?e?.removeItem(ti):e?.setItem(ti,String(Math.round(t)))}catch{}}function browserStore(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}var ni=16;function clampSidebar(e){return Math.min(400,Math.max(240,Math.round(e)))}var ri=[{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=G(),_=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:ri.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-ni));else if(t.key===`ArrowRight`)n(clampSidebar(e+ni));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=>He(e))}async park(e){let t=this.openIn(e);for(let e of t)if(He(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`?Le(a,s):Le(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()}},ii=/[\\/\0-\u001f:*?"<>|]/;function nameFault(e){return e.trim()===``?m(`app.web.entry.nameEmpty`):ii.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=Te(),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(J,{title:m(`app.web.entry.newFolderTitle`),size:`small`,onClose:r,onSubmit:()=>void create(),footer:l(X,{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(Ce,{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(Oe,{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=Te(),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(J,{title:m(`app.web.entry.renameTitle`,{name:i}),size:`small`,onClose:r,onSubmit:()=>void rename(),footer:l(X,{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(Ce,{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(Oe,{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(J,{title:m(f?`app.web.entry.deleteFolderTitle`:`app.web.entry.deleteFileTitle`,{name:d}),size:`small`,destructive:!0,onClose:a,footer:l(X,{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(Oe,{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(J,{title:m(`app.web.entry.moveTitle`,{name:p}),size:`small`,onClose:i,onSubmit:()=>void run(),footer:l(X,{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(Ce,{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(Oe,{children:d})]})}var ai=i(null);function useProject(){return r(ai)}function targetOfNode(e,t){if(!e.path)return null;if(e.id.startsWith(`file:`)){let n=ze(e.path),r=t.files.find(e=>e.path===n)??t.files.find(e=>e.rel===Ve(t.root,n));return r?{kind:`file`,file:r}:null}if(e.id.startsWith(`folder:`)){let n=Ve(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(()=>H.info(m(`app.web.entry.copied`)),()=>H.error(m(`app.web.tree.copyFailed`))):H.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=>H.error(messageFrom$1(e)),run=e=>void e.catch(report),revealRel=t=>e(Le(listing().root,t)),pathOf=(e,t)=>{let n=e.kind===`file`?e.file.rel:e.rel;return t?n:Le(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=>H.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(J,{title:m(`app.web.expired.title`),size:`small`,backdrop:`keep`,onClose:e,onSubmit:e,footer:l(X,{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 oi=[{id:`process`,kinds:[`bpmn`]},{id:`decision`,kinds:[`dmn`]},{id:`form`,kinds:[`form`]},{id:`testCase`,kinds:[`testCase`]},{id:`template`,kinds:[`template`]}];function groupOfKind(e){return oi.find(t=>t.kinds.includes(e))?.id??`process`}var si=8;function placeMenu(e,t,n){let r=Math.max(si,Math.min(e.x,n.width-t.width-si)),i=e.y+t.height+si>n.height?Math.max(si,e.y-t.height):e.y;return{left:r,top:Math.max(si,Math.min(i,n.height-t.height-si))}}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:He(e)?m(`app.web.tabs.unsaved`,{name:e.rel}):e.rel,tabId:domId(`web-tab`,e.path),controls:domId(`web-pane`,e.path),dirty:He(e),saving:e.saving,failed:!!e.saveError,problem:e.disk!==`in-sync`||!!e.saveError,closeLabel:m(`app.web.tabs.close`,{name:e.name}),closeTitle:withKeys(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=$(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(Ee,{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),b=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:[b&&l(`div`,{class:`web-pane__banner is-${b.tone}`,role:`alert`,children:[l(`span`,{class:`web-pane__banner-text type-body`,children:b.text}),b.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(Ee,{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(ye,{onReload:()=>g(e=>e+1),children:l(yr,{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 y(()=>import(`./ScriptPane-DzBYUW23.js`).then(t=>e&&r(()=>t.ScriptPane)),__vite__mapDeps([64,1,2,3,4,6,7,8,9,10,11,13,5,14,15,22,18,23,25,35,24,42,19,58]),import.meta.url),()=>{e=!1}},[]),n?l(n,{...e}):null}var ci=`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`:He(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:`${ci} · ${lineEnding(r.current)}`}),l(`button`,{type:`button`,class:`web-status__tool`,"aria-label":m(`app.web.shortcuts.open`),title:withKeys(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(be,{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(J,{title:m(`app.web.unsaved.title`,{name:e}),size:`small`,destructive:!0,onClose:i,footer:l(X,{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 li={off:S.OFF,bottom:S.BOTTOM,sidebar:S.SIDEBAR};function hostPreferences(){return{aiChat:()=>ie(Q().aiChat),setAiChat:e=>Ae({aiChat:li[e]}),subscribe:je}}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(He(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 ui=3e3,di=3e4;function pollDelay(e,t){return Math.min(e*2**Math.min(t,5),Math.max(e,di))}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}function suggestsNextBlock(){return Q().suggestNextBlock!==!1}function suggestsFields(){return Q().suggestions!==!1}var fi=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform),pi=!1,mi=new Set;function toggleFocusCanvas(){pi=!pi;for(let e of mi)e(pi)}function useFocusCanvas(){let[e,n]=t(pi);return f(()=>(mi.add(n),n(pi),()=>{mi.delete(n)}),[]),e}function useFocusCanvasShortcut(){let e=o(null),t=useEditorActive();f(()=>{if(!t)return;let onKey=t=>{if(!D(t,`Mod+Alt+Shift+M`,fi))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 hi={newFile:()=>y(()=>import(`./NewFileDialog-BPBljAGC.js`).then(e=>e.NewFileDialog),__vite__mapDeps([65,1,2,3,4,6,7,8,9,10,11,28,14,57]),import.meta.url),quick:()=>y(()=>import(`./QuickOpen-DOe23FAR.js`).then(e=>e.QuickOpen),__vite__mapDeps([66,1,2,3,4]),import.meta.url),shortcuts:()=>y(()=>import(`./ShortcutsDialog-D0_aCcNe.js`).then(e=>e.ShortcutsDialog),__vite__mapDeps([67,1,2,3,4,47,6,7,8,9,10,11,15,28,14,29]),import.meta.url),settings:()=>y(()=>import(`./SettingsDialog-YoMl6NJ1.js`).then(e=>e.SettingsDialog),__vite__mapDeps([68,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url),agents:()=>y(()=>import(`./AgentsDialog-BtgwT_49.js`).then(e=>e.AgentsDialog),__vite__mapDeps([69,1,2,3,4,6,7,8,9,10,11,47,15,28,14,29]),import.meta.url),conflict:()=>y(()=>import(`./ConflictDialog-B9V39KUg.js`).then(e=>e.ConflictDialog),__vite__mapDeps([70,1,2,3,4,28,6,7,8,9,10,11,14]),import.meta.url)};function useLazy(e,n){let[r,i]=t(null);return f(()=>{if(!n||r)return;let t=!0;return hi[e]().then(e=>t&&i({component:e})),()=>{t=!1}},[n]),r?.component??null}var gi=`(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=ui,env:p}){let h=c(()=>({...Qt,...p}),[p]),g=useStore(e),_=useStore(r.tabs),v=useMedia(gi),[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()),[M,N]=t(defaultDock),[P,F]=t(St),[I,L]=t([]),[R,z]=t(!1),[B,V]=t(!1),[ee,H]=t(null),[U,te]=t(()=>h.autosave()),[ne,re]=t(()=>h.theme()),[ie,W]=t(null),ae=o(!1),oe=o(new Set),ce=useLazy(`newFile`,y),le=useLazy(`quick`,x!==null||g.listed),ue=useLazy(`shortcuts`,C===`shortcuts`),de=useLazy(`settings`,C===`settings`),pe=useLazy(`agents`,C===`agents`),me=useLazy(`conflict`,T!==null),he=g.order.map(e=>g.docs.get(e)).filter(Boolean),ge=c(()=>new Set(g.order.filter(e=>He(g.docs.get(e)))),[g.docs,g.order]),K=g.listing.root,q=g.active?g.docs.get(g.active)??null:null;usePolling(e,d);let[ve]=t(()=>j().agentsHost?.()??null);f(()=>se(()=>w(`agents`)),[]),f(()=>{e.setAutosave(U)},[e,U]),f(()=>{let e=!0,read=()=>void h.licence().then(t=>e&&W(t));read();let t=onLicenceChange(read);return()=>{e=!1,t()}},[h]),f(()=>{if(ae.current||!g.listed)return;ae.current=!0;let t=h.loadSession(g.listing.root);if(t){let n=restoreSession(e,g.listing,t);n.dock&&N(n.dock),(n.toolOpen.length>0||n.toolShut.length>0)&&F(expansionOf(n.toolOpen,n.toolShut))}let n=s?Pe(s):null;if(n){let t=g.listing.files.find(e=>e.rel===n);e.open(t?.path??Le(g.listing.root,n),t?.kind)}V(!0);let r=h.journal;r&&r.orphans(g.listing.root).then(e=>L(e))},[g.listed]),f(()=>{if(!B)return;let e=oe.current;oe.current=new Set,N(t=>syncDocs(t,g.order,e,groupWidth(t.focus)))},[g.order,B]),f(()=>{let e=g.active;e&&N(t=>activate(t,docPanel(e)))},[g.active,g.order]);let sessionNow=()=>sessionOf(e.snapshot(),{dock:M,tool:P});f(()=>{N(e=>syncScripts(e,_.tabs.map(e=>e.id)))},[_.tabs]),f(()=>{let e=_.focus;e&&N(t=>activate(t,scriptPanel(e)))},[_.focus]);let ye=o([]);f(()=>{let e=ye.current.filter(e=>!g.order.includes(e));ye.current=g.order,e.forEach(e=>void r.closeDocument(e))},[g.order,r]),f(()=>{if(!B||!K)return;let e=setTimeout(()=>h.saveSession(K,sessionNow()),h.sessionDelayMs);return()=>clearTimeout(e)},[B,K,g.order,g.active,g.recent,M,P]),f(()=>{let e=g.active?g.docs.get(g.active):void 0;syncAddress(e?e.rel:null)},[g.active]);let be=ge.size>0;f(()=>{showTitle(titleFor(g.active?g.docs.get(g.active)?.name??null:null,K?Ie(K):m(`app.web.tree.project`),be)),showFavicon(be)},[g.active,g.docs,K,be]),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(),B&&K&&h.saveSession(K,sessionNow())}),f(()=>{let hidden=()=>{document.visibilityState===`hidden`&&h.journal?.flush()};return document.addEventListener(`visibilitychange`,hidden),()=>document.removeEventListener(`visibilitychange`,hidden)},[h]);let J=useCloseQueue(e,n(t=>e.close(t),[e])),xe=J.head?g.docs.get(J.head):void 0,closeTabs=e=>J.request(e),Se=n(t=>{N(t);let n=pathOfPanel(focused$1(t)?.active??``);n&&n!==e.snapshot().active&&e.activate(n)},[e]),Ce=n((t,n=!1)=>{if(n){let e=docPanel(t.path);has(M,e)?N(moveTab(M,e,{group:M.focus,zone:`right`,width:groupWidth(M.focus)})):oe.current.add(t.path)}e.open(t.path,t.kind),v&&O(!1)},[e,v,M]),we=n(async(t,n)=>{let r=await e.create(t,n);r&&await e.open(r)},[e]),Y=n(e=>{A(e),h.setSidebar(e)},[h]),Te=n(()=>{v?O(e=>!e):Y({...k,open:!k.open})},[v,k,Y]),X=useFocusCanvas(),Z=n(()=>{let t=e.snapshot().active?e.doc(e.snapshot().active)?.rel??null:null;t&&G()?.focusInput(t)},[e]),Ee=g.active?g.docs.get(g.active)?.rel??null:null,De=n(()=>{let e=focused$1(M),t=e?.active??null;e&&t&&e.tabs.length>1?Se(moveTab(M,t,{group:e.id,zone:`right`,width:groupWidth(e.id)})):S({initial:``,side:!0})},[M,Se]),Oe=n(()=>{leaves(M.root).length>1?Se(mergeGroups(M)):De()},[M,Se,De]),Q=n(async()=>{let t=e.snapshot().active;t&&!await e.save(t)&&e.doc(t)?.disk===`changed`&&E(t)},[e]),ke=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(M);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,M]),Me=n(e=>{v?O(!0):k.open||Y({...k,open:!0}),H(t=>({path:ze(e),serial:(t?.serial??0)+1}))},[v,k,Y]),Fe=useEntryActions(Me),$=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`:Q();return;case`saveAll`:ke();return;case`closeTab`:n.active&&closeTabs([n.active]);return;case`nextTab`:je(1);return;case`previousTab`:je(-1);return;case`toggleSidebar`:Te();return;case`askAgent`:Z();return;case`splitView`:Oe();return;case`newFile`:b(!0);return;case`shortcuts`:w(`shortcuts`);return;case`settings`:w(`settings`);return;default:{let n=(focused$1(M)?.tabs??[]).map(pathOfPanel).filter(e=>e!==null),r=tabIndexFor(t,n.length);r!==null&&e.activate(n[r])}}},[e,h,M,Q,ke,je,Te,Z,Oe]);useWindowEvent(`keydown`,e=>{if(e.isComposing||e.repeat)return;let t=historyFor(e,h.mac);if(t){let n=e.target instanceof Element?e.target:null;if(document.querySelector(`.ui-dialog-overlay, .palette-overlay`)||_e(n)||n?.closest(`.djs-container`))return;runEditCommand(t,{focus:n,textSelected:!1})&&e.preventDefault();return}let n=commandFor(e,h.mac);n&&(e.preventDefault(),!document.querySelector(`.ui-dialog-overlay, .palette-overlay`)&&$(n))},!0);let Re=c(()=>[{id:`newFile`,title:m(`app.web.command.newFile`),keys:keysOf(`newFile`,h.mac),run:()=>$(`newFile`)},{id:`save`,title:m(`app.web.command.save`),keys:keysOf(`save`,h.mac),run:()=>$(`save`)},{id:`saveAll`,title:m(`app.web.command.saveAll`),keys:keysOf(`saveAll`,h.mac),run:()=>$(`saveAll`)},{id:`closeTab`,title:m(`app.web.command.closeTab`),keys:keysOf(`closeTab`,h.mac),run:()=>$(`closeTab`)},{id:`closeAll`,title:m(`app.web.command.closeAll`),run:()=>closeTabs(e.snapshot().order)},{id:`splitView`,title:leaves(M.root).length>1?m(`app.web.command.closeSplit`):m(`app.web.command.splitView`),keys:keysOf(`splitView`,h.mac),run:()=>$(`splitView`)},{id:`toggleSidebar`,title:m(`app.web.command.toggleSidebar`),keys:keysOf(`toggleSidebar`,h.mac),run:()=>$(`toggleSidebar`)},...fe()&&Ee?[{id:`askAgent`,title:m(`app.web.command.askAgent`),keys:keysOf(`askAgent`,h.mac),run:()=>$(`askAgent`)}]:[],{id:`resetLayout`,title:m(`app.web.command.resetLayout`),run:()=>N(syncDocs(defaultDock(),e.snapshot().order))},{id:`actions`,title:m(`app.web.command.actions`),keys:keysOf(`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:`shortcuts`,title:m(`app.web.command.shortcuts`),keys:keysOf(`shortcuts`,h.mac),run:()=>$(`shortcuts`)},{id:`reconnect`,title:m(`app.web.command.reconnect`),run:()=>void e.refresh()}],[h.mac,$,M,e,Ee]),Be=c(()=>new Map([...docTabs(he,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);N(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)},Ve=n(t=>{let n=pathOfPanel(t),r=groupOf(M,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:keysOf(`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&&Se(moveTab(M,t,{group:r.id,zone:`right`,width:groupWidth(r.id)}))},{id:`splitDown`,label:m(`app.web.menu.splitDown`),disabled:!i,run:()=>r&&Se(moveTab(M,t,{group:r.id,zone:`bottom`}))},{id:`reveal`,label:m(`app.web.menu.reveal`),run:()=>Me(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,M,Se,Me]),restoreDrafts=async()=>{z(!0);let t=new Map(e.snapshot().listing.files.map(e=>[e.path,e]));for(let n of I){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)}L([]),z(!1)},discardDrafts=async()=>{z(!0),await h.journal?.discard(I),L([]),z(!1)},openPath=t=>{if(!t)return;let n=g.listing.files.find(e=>e.rel===t);e.open(n?.path??Le(g.listing.root,t),n?.kind)};useDesktopCommands({"file.newFile":()=>$(`newFile`),"file.save":()=>$(`save`),"file.closeTab":()=>{let t=e.snapshot().active;t?closeTabs([t]):desktopCapability()?.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=desktopCapability()?.platform===`darwin`;document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`'`,code:`Quote`,altKey:!0,metaKey:e,ctrlKey:!e,bubbles:!0,cancelable:!0}))},"help.shortcuts":()=>$(`shortcuts`)});let Ue=K?Ie(K):m(`app.web.tree.project`),We=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 Ge=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&&Ce(t)},Ke=c(()=>new Map(leaves(M.root).map(e=>[e.active,e.id])),[M]),content=t=>{let n=Ke.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===M.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===M.focus,loaders:i,onClose:()=>closeTabs([s.path]),onCompare:()=>E(s.path)}):null},qe=leaves(M.root).at(-1)?.id??null,header=e=>{let t=e.tabs.map(e=>Be.get(e)).filter(e=>!!e),n=leaves(M.root).length>1;return l(TabStrip,{tabs:t,active:e.active,onSelect:selectPanel,onClose:closePanelTab,onDropTab:(t,n)=>Se(moveTab(M,t,{group:e.id,zone:`center`,index:n})),menuFor:Ve,trailing:e.id===qe&&!v&&he.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:withKeys(m(n?`app.web.command.closeSplit`:`app.web.command.splitView`),`splitView`,h.mac),onClick:Oe,children:l(Icon$1,{name:`split`})}):null})},empty=()=>l(Welcome$1,{recent:Ge,onOpen:openRel,onQuickOpen:()=>S({initial:``,side:!1}),onNew:()=>b(!0),quickKeys:keysOf(`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:Ue,file:q?.name??null,dirty:!!q&&He(q),onSettings:()=>w(`settings`),onSearch:()=>$(`quickOpen`),searchKeys:keysOf(`quickOpen`,h.mac)??``,onToggleSidebar:Te,sidebarKeys:keysOf(`toggleSidebar`,h.mac)??``}),l(`div`,{class:`web-shell${v?` is-narrow`:``}`,children:[!X&&(v?D:k.open)&&l(ShellSidebar,{width:k.width,onWidth:e=>Y({...k,width:e}),drawer:v,onClose:()=>O(!1),runAction:h.runEditorAction,focusedEditor:Ee,openFile:openPath,children:u&&l(ToolPanel,{store:u,expansion:P,onExpansion:F,onUnlock:h.showLicence,mac:h.mac,entries:Fe,activePath:q&&!Ne(q.kind)?ze(q.path):null,reveal:ee,newKeys:keysOf(`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`)})]}),I.length>0&&l(DraftNotice,{count:I.length,busy:R,onRestore:()=>void restoreDrafts(),onDiscard:()=>void discardDrafts()}),l(DockView,{dock:M,onDock:Se,header,content,empty,label,single:v})]})]}),l(StatusBar,{engine:engineName(a),licence:ie,connection:g.connection,doc:q,autosave:U,mac:h.mac,onRetry:()=>void e.refresh(),onShortcuts:()=>w(`shortcuts`),onLicence:h.showLicence}),y&&ce&&l(ce,{files:g.listing.files,engine:a,onCreate:we,onClose:()=>b(!1)}),x&&le&&l(le,{files:g.listing.files,recent:g.recent,open:new Set(g.order),commands:Re,initial:x.initial,side:x.side,onClose:()=>S(null),onPick:(e,t)=>{S(null),Ce(e,t)},onRun:e=>{S(null),setTimeout(e.run,0)}}),C===`shortcuts`&&ue&&l(ue,{mac:h.mac,onClose:()=>w(null)}),C===`settings`&&de&&l(de,{theme:ne,autosave:U,onAgents:()=>w(`agents`),onTheme:e=>{re(e),h.setTheme(e)},onAutosave:e=>{te(e),h.setAutosave(e)},suggestNextBlock:suggestsNextBlock(),onSuggestNextBlock:e=>Ae({suggestNextBlock:e}),suggestions:suggestsFields(),onSuggestions:e=>Ae({suggestions:e}),onClose:()=>w(null)}),C===`agents`&&pe&&ve&&l(pe,{host:ve,preferences:hostPreferences(),onClose:()=>w(null)}),We&&We.diskText!==null&&me&&!y&&!xe&&C===null&&l(me,{name:We.name,mine:We.current,theirs:We.diskText,onClose:()=>E(null),onTakeTheirs:()=>{e.reloadFromDisk(We.path),E(null)},onKeepMine:()=>{e.keepMine(We.path),E(null)}}),xe&&l(UnsavedDialog,{name:xe.name,busy:J.busy,onCancel:J.cancel,onDiscard:J.discard,onSave:J.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 _i={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=_i;listeners=new Set;api;effects;pollMs;attached=0;timer;flight=null;again=!1;failures=0;controller=null;constructor(e,t,n=ui){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`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 E(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:N(n),root:t}),accept:m(`app.runs.create`),decline:m(`app.common.cancel`)}))return!1;let r=[];for(let[i,a]of Object.entries(k(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:N(n),root:t})),!0}function targetLabel(e){return e?.profile??`default`}async function deployWithHost(e,t,n,r){try{let i=j(),a=e?.profile??null;if(!e||!P(String(e.engine))||!e.deployment)return{ok:!1,status:0,message:m(`app.project.chooseCamunda7Camunda8`),definitions:[],lines:[]};let o=Array.isArray(t)?t:[],s=await te({...e.deployment,engine:e.engine},o,{ask:e=>i.askEngine(a,e,n),hook:(e,t)=>i.runHook(e,t,a,n,r),watch:r});if(s.ok)try{await i.recordDeployment(a,o.map(e=>e.name))}catch{}return s}catch(e){return{ok:!1,status:0,message:e instanceof Error?e.message:String(e),definitions:[],lines:[]}}}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,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=>{O(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 vi=8,yi=320;function folderWindow(e,t,n){return{start:Math.max(0,Math.floor(e/28)-vi),end:Math.min(n,Math.ceil((e+t)/28)+vi)}}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,x]=t(i??``),[S,C]=t(null),[w,T]=t(!1),[E,D]=t(null),[O,k]=t(0),[A,j]=t(yi),M=o(null),N=o(0),P=o(`web-folders-${Math.random().toString(36).slice(2,8)}`),F=n(async(t,n)=>{N.current+=1;let r=N.current;h(!0);try{let i=await e(t,n);if(r!==N.current)return;d(i),x(i.path),C(null),_(null),k(0),M.current&&(M.current.scrollTop=0)}catch(e){if(r!==N.current)return;_(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`))}finally{r===N.current&&h(!1)}},[e]);f(()=>{F(i,!1)},[]),u(()=>{let e=M.current;if(!e)return;let measure=()=>j(e.clientHeight||yi);if(measure(),typeof ResizeObserver>`u`)return;let t=new ResizeObserver(measure);return t.observe(e),()=>t.disconnect()},[]);let I=c?visibleEntries(c.entries,v):[],L=c?.separator??`/`,R=S===null?-1:I.findIndex(e=>e.name===S),z=c?S!==null&&R>=0?joinFolder(c.path,S,L):c.path:null,scrollTo=e=>{let t=M.current;if(!t||e<0)return;let n=e*28,r=t.clientHeight||yi;n<t.scrollTop?t.scrollTop=n:n+28>t.scrollTop+r&&(t.scrollTop=n+28-r),k(t.scrollTop)},descend=e=>{c&&F(joinFolder(c.path,e,L),v)},choose=async()=>{if(!(!z||w||p)){if(c&&b.trim()!==c.path)F(b,v);else{T(!0),D(null);try{await a(z)}catch(e){D(e instanceof Error&&e.message?e.message:m(`app.web.unknownFailure`)),T(!1)}}}},onListKey=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return;let t=Math.max(1,Math.floor((M.current?.clientHeight||yi)/28)-1),n=null;e.key===`ArrowDown`?n=Math.min(I.length-1,R+1):e.key===`ArrowUp`?n=Math.max(0,R<0?0:R-1):e.key===`Home`?n=0:e.key===`End`?n=I.length-1:e.key===`PageDown`?n=Math.min(I.length-1,R+t):e.key===`PageUp`&&(n=Math.max(0,R-t)),n===null?(e.key===`Enter`||e.key===`ArrowRight`)&&R>=0?(e.preventDefault(),e.stopPropagation(),descend(I[R].name)):(e.key===`Backspace`||e.key===`ArrowLeft`)&&c?.parent&&(e.preventDefault(),F(c.parent,v)):(e.preventDefault(),I[n]&&(C(I[n].name),scrollTo(n)))},{start:B,end:V}=folderWindow(O,A,I.length),ee=[];c&&(ee.push({id:`home`,label:m(`app.web.folders.home`),path:c.home}),c.roots.forEach(e=>ee.push({id:`root:${e}`,label:e===`/`?m(`app.web.folders.computer`):e,path:e})));let H=r.filter(e=>e.present).slice(0,6),U=c?breadcrumbs(c.path,L):[];return l(J,{title:m(`app.web.folders.title`),size:`large`,body:`split`,onClose:s,onSubmit:()=>void choose(),footer:l(X,{help:z?m(`app.web.folders.willOpen`,{folder:z}):void 0,actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:s,disabled:w},{id:`open`,label:m(`app.web.folders.open`),role:`primary`,onClick:()=>void choose(),busy:w,disabled:!z}]}),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`)}),ee.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.path,onClick:()=>void F(e.path,v),children:[l(Icon$1,{name:`folder`}),l(`span`,{class:`web-folders__place-name`,children:e.label})]},e.id)),H.length>0&&l(`p`,{class:`web-folders__heading type-section-heading`,children:m(`app.web.folders.recent`)}),H.map(e=>l(`button`,{type:`button`,class:`web-folders__place type-body`,title:e.folder,onClick:()=>void F(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(Ce,{label:m(`app.web.folders.path`),layout:`top`,error:g,children:e=>l(`input`,{...e,value:b,spellcheck:!1,autocomplete:`off`,onInput:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),e.stopPropagation(),F(b,v))},onBlur:()=>{c&&b.trim()!==``&&b!==c.path&&!p&&F(b,v)}})}),c&&l(`ol`,{class:`web-folders__crumbs type-help`,"aria-label":m(`app.web.folders.location`),children:U.map((e,t)=>l(`li`,{class:`web-folders__crumb`,children:l(`button`,{type:`button`,class:`web-folders__crumb-button`,"aria-current":t===U.length-1?`location`:void 0,onClick:()=>void F(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&&F(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:M,id:P.current,class:`web-folders__list`,role:`listbox`,tabIndex:0,"aria-label":m(`app.web.folders.list`),"aria-busy":p||void 0,"aria-activedescendant":R>=0?`${P.current}-${R}`:void 0,onKeyDown:onListKey,onScroll:e=>k(e.currentTarget.scrollTop),children:[l(`div`,{class:`web-folders__canvas`,style:{height:`${I.length*28}px`},children:I.slice(B,V).map((e,t)=>{let n=B+t;return l(`div`,{id:`${P.current}-${n}`,role:`option`,"aria-selected":n===R,class:`web-folders__row type-body${n===R?` is-selected`:``}`,style:{top:`${n*28}px`},title:e.link?m(`app.web.folders.link`,{name:e.name}):e.name,onClick:()=>{M.current?.focus({preventScroll:!0}),C(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&&I.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})}),E&&l(Oe,{children:E})]})]})}var bi=`.bpmn,.dmn,.form,.xml`;function acceptedUpload(e){let t=Be(e);return t===`bpmn`||t===`dmn`||t===`form`}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,b]=t(null),[x,S]=t(!1),[C,w]=t(null),[T,E]=t(null),[D,O]=t(!1),[k,A]=t(null),[j,M]=t(null),[N,P]=t(null),F=o(null),I=o(0),L=p.project.name??m(`app.web.tree.project`),R=h.active?h.docs.get(h.active):void 0,z=!!R&&R.phase===`ready`&&R.current!==R.baseline;f(()=>{document.title=pageTitle({app:m(`app.web.pageTitle`),project:p.project.open?L:null,file:R?R.rel:null,dirty:z})},[L,R?.rel,z,p.project.open]),f(()=>e.start(),[e]),useDesktopCommands({"project.refresh":()=>void e.adopt().then(()=>Promise.all([r.refresh(),u?.refresh()]))}),f(()=>{if(!T||k)return;let e=!0;return y(()=>import(`./UploadDialog-ZOy1owan.js`).then(t=>e&&A({component:t.UploadDialog})),__vite__mapDeps([71,1,2,3,4,28,6,7,8,9,10,11,14,57]),import.meta.url),()=>{e=!1}},[T]),f(()=>{if(j===null||N)return;let e=!0;return y(()=>import(`./NewFileDialog-BPBljAGC.js`).then(t=>e&&P({component:t.NewFileDialog})),__vite__mapDeps([65,1,2,3,4,6,7,8,9,10,11,28,14,57]),import.meta.url),()=>{e=!1}},[j]);let B=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){H.error(messageFrom(e)),S(!1),b(null)}},[e,r]),V=n(e=>{r.dirtyPaths().length===0?B(e):(w(null),b(e))},[r,B]),ee=n(e=>{let t=e.filter(e=>acceptedUpload(e.name));t.length<e.length&&H.error(m(`app.web.upload.ignored`)),t.length>0&&E(t)},[]);f(()=>{let over=e=>{carriesFiles(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},enter=e=>{carriesFiles(e)&&(I.current+=1,O(!0))},exit=e=>{carriesFiles(e)&&(I.current=Math.max(0,I.current-1),I.current===0&&O(!1))},drop=e=>{carriesFiles(e)&&(e.preventDefault(),I.current=0,O(!1),ee(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)}},[ee]);let U=c(()=>({session:e,store:r,entries:i,engine:s,browse:()=>_(!0),switchTo:e=>V({kind:`open`,folder:e}),closeProject:()=>V({kind:`close`}),upload:()=>F.current?.click(),newFile:e=>M(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=>H.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=>H.error(messageFrom(e)))}}),[e,r,i,s,V,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(ai.Provider,{value:U,children:[d,l(`input`,{ref:F,class:`web-projects__picker`,type:`file`,multiple:!0,accept:bi,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=e.target;ee(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:L})}),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:()=>V({kind:`close`}),children:m(`app.web.project.close`)})]}),D&&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),V({kind:`open`,folder:e}))},onClose:()=>_(!1)}),v&&l(J,{title:v.kind===`open`?m(`app.web.project.unsavedOpenTitle`):m(`app.web.project.unsavedCloseTitle`),size:`small`,destructive:!0,onClose:()=>!x&&b(null),footer:l(X,{actions:[{id:`cancel`,label:m(`app.common.cancel`),role:`cancel`,onClick:()=>b(null),disabled:x},{id:`discard`,label:m(`app.web.unsaved.discard`),role:`secondary`,onClick:()=>void B(v),disabled:x},{id:`save`,label:m(`app.web.project.saveAll`),role:`primary`,busy:x,onClick:()=>{S(!0),w(null),r.saveAll().then(e=>{e?B(v):(S(!1),w(m(`app.web.project.saveAllFailed`)))})}}]}),children:[l(`p`,{class:`web-dialog-text type-body`,children:m(`app.web.project.unsavedText`,{count:te})}),C&&l(`p`,{class:`web-dialog-text type-error-message`,role:`alert`,children:C})]}),T&&k&&l(k.component,{files:T,existing:h.listing.files,folders:h.listing.folders,onUpload:addFiles,onClose:()=>E(null)}),j!==null&&N&&l(N.component,{files:h.listing.files,engine:s,initialFolder:j,onCreate:(e,t)=>addFiles([{rel:e,content:t}]),onClose:()=>M(null)}),p.away&&l(J,{title:m(`app.web.project.awayTitle`),size:`small`,backdrop:`keep`,onClose:()=>e.reloadPage(),footer:l(X,{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(Oe,{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 xi=null,Si=null;function setSuggestionProvider(e){xi=e}function setProjectSuggestionProvider(e){Si=e}function currentSuggestionProvider(){return xi??Si}function startingLocale(e){let t=Q().locale;if(t)return h(t);let n=e?.locale;return n?h(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(ut)}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||{},pluginVersion:e?.pluginVersion??null,gitUserName:e?.gitUserName??null,get isDarkMode(){return getCurrentTheme()===`dark`},get isDraculaMode(){return getCurrentTheme()===`dracula`},get isSketchyMode(){return Q().rendering===`sketchy`},async fetchConfig(){}},window.setTheme=receiveHostThemeName,window.setSuggestionProvider=setSuggestionProvider}function environmentFor(e,t){return{mac:/Mac|iPhone|iPad/.test(navigator.platform),journal:t,loadSession:e=>sessionFrom(Q().webSessions?.[e]),saveSession:(e,t)=>{let n={...Q().webSessions??{}};delete n[e],n[e]={...t,dock:t.dock},Ae({webSessions:n})},autosave:()=>Q().webAutosaveSeconds??null,setAutosave:e=>Ae({webAutosaveSeconds:e}),theme:()=>currentThemeChoice(),setTheme:e=>chooseTheme(e),sidebar:()=>({open:Q().projectTreeHidden!==!0,width:clampSidebar(Q().projectTreeWidth??272)}),setSidebar:e=>Ae({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?H.error(e):H.info(e),copy:async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}}}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;A(t);let n=await ve().bpmn.getConfig?.().catch(()=>null)??null;await ke(),await xe(),Me();let r=startingLocale(n);await _(r).catch(e=>console.error(`[i18n] The catalogue for`,r,`did not load, English is shown:`,e)),v(r),document.documentElement.lang=g(),translatePanelLabels(),followSystemTheme(n),setupGlobalAppConfig(n);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(we,{locale:g(),children:l(ye,{onReload:()=>window.location.reload(),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={store:null},d=new Ue({host:bridgeHost(t,()=>window.appConfig?.pluginVersion,e=>u.store?.doc(e)?.current??null),notify:(e,t)=>t?H.error(e):H.info(e),drafts:c}),f=environmentFor(t,c);u.store=d;let p=new ScriptHub;t.bindWorkspace(new Workspace({store:d,scripts:p})),installDesktop(d),t.bindActiveFile(()=>d.snapshot().active),d.subscribe(()=>{let e=d.snapshot().active,n=window.appConfig;n&&(n.bpmnFilePath=e?ze(e):``),t.bindActiveDocument(e?t=>d.edit(e,t):null)});let h=new URLSearchParams(window.location.search).get(`file`),y=me();ge(y),window.addEventListener(`pagehide`,()=>y?.dispose());let b=new ToolWindowStore(toolApi(t),toolEffects(t,{notify:(e,t)=>t?H.error(e):H.info(e),copy:async e=>f.copy?.(e)??!1,showLicence:()=>f.showLicence?.(),files:()=>d.snapshot().listing.files,refreshProject:()=>d.refresh()})),Root=()=>l(ProjectFrame,{session:a,store:d,entries:i,readText:e=>t.readFile(e),engine:n?.engine,toolWindow:b,children:l(WebShell,{store:d,scripts:p,loaders:Nt,engine:n?.engine,deepLink:h,toolWindow:b,env:f})});s(l(we,{locale:g(),children:l(ye,{onReload:()=>window.location.reload(),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{lineWanted as $,observeCorner as A,widthLimits as At,compareTexts as B,useRevealCount as C,selectTab as Ct,AssistantDock as D,toPreferences as Dt,Zr as E,titleCommit as Et,motionMs as F,Icon$1 as G,TabIcon as H,reducedMotion as I,allKeysOf as J,iconOfGroup as K,xr as L,installScenarioOpener as M,takeScenarioRequest as N,Vr as O,toggleCollapsed as Ot,useScenarioRequest as P,unpackComparison as Q,useEditorActive as R,useLeaveChatTab as S,resolveWidth as St,Xr as T,tabList as Tt,useLicence as U,hunksOf as V,paidTier as W,computeChanges as X,PreviewPane as Y,ensurePreviewStyle as Z,publishFacts as _,isRepeatOfPress as _t,targetLabel as a,ut as at,useChatAction as b,pushView as bt,useFocusCanvasShortcut as c,toggleDarkMode as ct,domId as d,badgeLabel as dt,onSourceFocus as et,groupOfKind as f,badgeText as ft,ToolbarButton as g,isRenameKey as gt,Icon as h,isDrawer as ht,deployWithHost as i,lt as it,AssistantRuntime as j,measureCorner as k,toggleHidden as kt,suggestsFields as l,cleanTemplates as lt,nameFault as m,fromPreferences as mt,setProjectSuggestionProvider as n,chooseTheme as nt,toggleFocusCanvas as o,applyTheme as ot,messageFrom$1 as p,droppedTabs as pt,registerEditCommands as q,acceptedUpload as r,currentThemeChoice as rt,useFocusCanvas as s,getCurrentTheme as st,currentSuggestionProvider as t,pt as tt,suggestsNextBlock as u,arrowTab as ut,retractFacts as v,isSidebarShortcut as vt,useAssistantEditor as w,shownTab as wt,useChatStatus as x,resetViews as xt,useAiChatPlace as y,popView as yt,useEditorElement as z};