isorite 0.12.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +6 -5
  2. package/dist/main.js +6018 -8942
  3. package/docs/setup-for-agents.md +44 -102
  4. package/docs/setup.md +27 -90
  5. package/docs/terminal.md +54 -55
  6. package/guide/AGENTS.md +4 -0
  7. package/guide/atlas/find-what-it-rests-on.md +9 -0
  8. package/guide/atlas/the-atlas.md +21 -0
  9. package/guide/atlas/the-switches/satellites.svg +17 -0
  10. package/guide/atlas/the-switches.md +27 -0
  11. package/guide/iso/agents-md.md +13 -0
  12. package/guide/iso/artifacts/the-guide.csv +8 -0
  13. package/guide/iso/artifacts/the-guide.html +35 -0
  14. package/guide/iso/artifacts.md +15 -0
  15. package/guide/iso/ask-iso.md +7 -0
  16. package/guide/iso/give-it-notes.md +9 -0
  17. package/guide/iso/in-hand.md +18 -0
  18. package/guide/iso/iso-writes-marked.md +15 -0
  19. package/guide/iso/iso.md +17 -0
  20. package/guide/iso/let-it-write.md +11 -0
  21. package/guide/iso/write-agents-md.md +11 -0
  22. package/guide/notes/a-note-is-markdown.md +17 -0
  23. package/guide/notes/a-notes-details.md +23 -0
  24. package/guide/notes/diagrams-and-code.md +43 -0
  25. package/guide/notes/every-change-is-kept.md +14 -0
  26. package/guide/notes/folders.md +11 -0
  27. package/guide/notes/go-back-a-version.md +9 -0
  28. package/guide/notes/link-your-notes.md +9 -0
  29. package/guide/notes/links-and-their-kinds.md +23 -0
  30. package/guide/notes/make-move-delete.md +9 -0
  31. package/guide/notes/write-in-your-notes.md +9 -0
  32. package/guide/out-of-the-base/web-and-code-links.md +13 -0
  33. package/guide/questions-and-problems/ask-a-question.md +9 -0
  34. package/guide/questions-and-problems/how-iso-reads-you.md +9 -0
  35. package/guide/questions-and-problems/problems.md +15 -0
  36. package/guide/questions-and-problems/questions.md +27 -0
  37. package/guide/questions-and-problems/resolve-a-question.md +9 -0
  38. package/guide/questions-and-problems/why-markdown-links.md +7 -0
  39. package/guide/solve-this-one.md +11 -0
  40. package/guide/start-here.md +39 -0
  41. package/guide/terminal/let-the-agent-remember.md +9 -0
  42. package/guide/terminal/memory.md +13 -0
  43. package/guide/terminal/your-own-agent.md +24 -0
  44. package/guide/your-notes.md +6 -0
  45. package/guide/your-own-base/keeping-a-base-well.md +16 -0
  46. package/guide/your-own-base/starting-a-base.md +21 -0
  47. package/package.json +4 -7
  48. package/web/_app/immutable/assets/0.BPP604gH.css +1 -0
  49. package/web/_app/immutable/assets/4.fOHsAKBF.css +1 -0
  50. package/web/_app/immutable/assets/drawn.D6lJzDcc.css +1 -0
  51. package/web/_app/immutable/chunks/{D5XlJBy8.js → B-DzK7Gb.js} +1 -1
  52. package/web/_app/immutable/chunks/{BuUzVkG2.js → B35sQTcK.js} +1 -1
  53. package/web/_app/immutable/chunks/{Dh1lBxfx.js → BA78_vo5.js} +1 -1
  54. package/web/_app/immutable/chunks/{tUSDgbpy.js → BCGaqnao.js} +1 -1
  55. package/web/_app/immutable/chunks/{DT2w6KyY.js → BGW1TKtR.js} +1 -1
  56. package/web/_app/immutable/chunks/{EMo1IeTW.js → BK31dpt6.js} +1 -1
  57. package/web/_app/immutable/chunks/BPrp4s2r.js +1 -0
  58. package/web/_app/immutable/chunks/{DlXrOzlh.js → BT_btfh0.js} +1 -1
  59. package/web/_app/immutable/chunks/{Xm0YTnxV.js → BWE_HS0c.js} +1 -1
  60. package/web/_app/immutable/chunks/{BLmF1B2i.js → BXBhaEho.js} +1 -1
  61. package/web/_app/immutable/chunks/{BAclEN0O.js → Bb_N98K9.js} +1 -1
  62. package/web/_app/immutable/chunks/{gPtCGHiy.js → Bd-WxALw.js} +1 -1
  63. package/web/_app/immutable/chunks/{BA8Hpxhg.js → BhEqJU15.js} +1 -1
  64. package/web/_app/immutable/chunks/{DkxkvOjx.js → BiATTH-R.js} +1 -1
  65. package/web/_app/immutable/chunks/{D5vocsTl.js → Bj-5n5Pb.js} +1 -1
  66. package/web/_app/immutable/chunks/{DRX-TQzj.js → BqipEJXw.js} +1 -1
  67. package/web/_app/immutable/chunks/{DXTK-eyo.js → BvPxdlBc.js} +1 -1
  68. package/web/_app/immutable/chunks/{DfCZPwp1.js → C2npZzkn.js} +1 -1
  69. package/web/_app/immutable/chunks/{DF89zyH-.js → C5Z-Y7Lu.js} +1 -1
  70. package/web/_app/immutable/chunks/{CD6xPodA.js → C8h1oeAZ.js} +1 -1
  71. package/web/_app/immutable/chunks/{CFEI5lV9.js → CAlIuau0.js} +1 -1
  72. package/web/_app/immutable/chunks/{9z49435t.js → CFf_dAzX.js} +1 -1
  73. package/web/_app/immutable/chunks/{rq7JUohF.js → CIYFNih-.js} +1 -1
  74. package/web/_app/immutable/chunks/{D3-rqfsM.js → CMIt1Ma8.js} +1 -1
  75. package/web/_app/immutable/chunks/{-2Meesge.js → CMikI1NP.js} +3 -3
  76. package/web/_app/immutable/chunks/{CxAq1aod.js → CPSlCQsu.js} +74 -74
  77. package/web/_app/immutable/chunks/{Czz9qOh8.js → CT4_O9X_.js} +1 -1
  78. package/web/_app/immutable/chunks/{DX4bJJO0.js → CTDYUZPz.js} +1 -1
  79. package/web/_app/immutable/chunks/{By4S_gy5.js → CdY1G_wk.js} +1 -1
  80. package/web/_app/immutable/chunks/{DBC2xjOo.js → CdmC_l9F.js} +1 -1
  81. package/web/_app/immutable/chunks/{DbNETcPs.js → Cf-5I5_6.js} +1 -1
  82. package/web/_app/immutable/chunks/Cl5gQm2e.js +1 -0
  83. package/web/_app/immutable/chunks/{BWVMfAMh.js → CryuQgNh.js} +1 -1
  84. package/web/_app/immutable/chunks/{CT_Ry4q8.js → Ct_EK1xu.js} +1 -1
  85. package/web/_app/immutable/chunks/{BymwHy7o.js → CtkUy_15.js} +1 -1
  86. package/web/_app/immutable/chunks/{Dpa4Syyy.js → CzYPMYd4.js} +1 -1
  87. package/web/_app/immutable/chunks/{RlApGeew.js → D1LK3xRu.js} +1 -1
  88. package/web/_app/immutable/chunks/{DXK7PB4g.js → D6sVhEz3.js} +1 -1
  89. package/web/_app/immutable/chunks/{94XMxKlw.js → DBLoWLMb.js} +1 -1
  90. package/web/_app/immutable/chunks/{rghE0CVz.js → DCZYeMlH.js} +1 -1
  91. package/web/_app/immutable/chunks/{RFxekmX-.js → DDAG55ce.js} +1 -1
  92. package/web/_app/immutable/chunks/DFKYo3Wx.js +1 -0
  93. package/web/_app/immutable/chunks/{CyFLqlvP.js → DFuPQaNa.js} +1 -1
  94. package/web/_app/immutable/chunks/{BXAOBcPb.js → DHJ8FcFD.js} +1 -1
  95. package/web/_app/immutable/chunks/{Bt7VOT5H.js → DKqMzyyE.js} +1 -1
  96. package/web/_app/immutable/chunks/{Bq2GBAJ0.js → DRcTlHZP.js} +1 -1
  97. package/web/_app/immutable/chunks/{C_amgxV1.js → DjUnonHY.js} +1 -1
  98. package/web/_app/immutable/chunks/{whhiiiga.js → Djr0h_v1.js} +1 -1
  99. package/web/_app/immutable/chunks/{vfDvz3qP.js → DrVtdHUW.js} +1 -1
  100. package/web/_app/immutable/chunks/DxVFSMVD.js +523 -0
  101. package/web/_app/immutable/chunks/{BBHd0LvJ.js → DymLl-qY.js} +1 -1
  102. package/web/_app/immutable/chunks/{DSYLdqdc.js → Dzi94aDH.js} +1 -1
  103. package/web/_app/immutable/chunks/{CmExTt6_.js → NyWzYSz1.js} +1 -1
  104. package/web/_app/immutable/chunks/{oWM_kgYq.js → PsfIQCJ1.js} +1 -1
  105. package/web/_app/immutable/chunks/{Cl5zRP_n.js → TanDZqdf.js} +1 -1
  106. package/web/_app/immutable/chunks/{D95RKsvN.js → UDPiRmKc.js} +1 -1
  107. package/web/_app/immutable/chunks/X3aTZRe_.js +1 -0
  108. package/web/_app/immutable/chunks/{BTclWEfx.js → ZwM5k8r0.js} +1 -1
  109. package/web/_app/immutable/chunks/e2LGvGEb.js +3 -0
  110. package/web/_app/immutable/chunks/ej_0XxR7.js +1 -0
  111. package/web/_app/immutable/chunks/{CjtKPNlv.js → kG4HctVa.js} +1 -1
  112. package/web/_app/immutable/chunks/{CQd9D8Nc.js → l1LsK1sB.js} +1 -1
  113. package/web/_app/immutable/entry/app.BzA5QYtw.js +2 -0
  114. package/web/_app/immutable/entry/start.BOh0Gj31.js +1 -0
  115. package/web/_app/immutable/nodes/0.BmaxMLzC.js +2 -0
  116. package/web/_app/immutable/nodes/1.IQDu8pD1.js +1 -0
  117. package/web/_app/immutable/nodes/2.D2Oi-ADx.js +1 -0
  118. package/web/_app/immutable/nodes/3.CF1W85jb.js +1 -0
  119. package/web/_app/immutable/nodes/4.BMYBn904.js +15 -0
  120. package/web/_app/immutable/nodes/5.1vm6WZdM.js +1 -0
  121. package/web/_app/immutable/nodes/6.C9ia8cDm.js +1 -0
  122. package/web/_app/version.json +1 -1
  123. package/web/index.html +16 -19
  124. package/dist/core.js +0 -2464
  125. package/plugin/assets/mark-lapis.png +0 -0
  126. package/plugin/assets/mark-quartz.png +0 -0
  127. package/plugin/assets/wordmark-lapis.png +0 -0
  128. package/plugin/assets/wordmark-quartz.png +0 -0
  129. package/plugin/isorite.ts +0 -65
  130. package/plugin/logo.ts +0 -99
  131. package/plugin/notepage.tsx +0 -165
  132. package/plugin/notes.ts +0 -10
  133. package/plugin/noteview.ts +0 -60
  134. package/plugin/oneatlas.ts +0 -83
  135. package/plugin/palette.ts +0 -21
  136. package/plugin/play.ts +0 -104
  137. package/plugin/server.ts +0 -76
  138. package/plugin/sources.ts +0 -18
  139. package/plugin/tui.tsx +0 -556
  140. package/plugin/wordmark.ts +0 -180
  141. package/web/_app/immutable/assets/0.DqoJ_jEe.css +0 -1
  142. package/web/_app/immutable/assets/4.CUdclsPi.css +0 -1
  143. package/web/_app/immutable/assets/5.rBvyRuST.css +0 -1
  144. package/web/_app/immutable/assets/Drawing.Q7J9MyIo.css +0 -1
  145. package/web/_app/immutable/assets/NoteEditor.S3q5lmKq.css +0 -1
  146. package/web/_app/immutable/assets/Timeline.LsRXYIBv.css +0 -1
  147. package/web/_app/immutable/chunks/9TpKhtgt.js +0 -1
  148. package/web/_app/immutable/chunks/BMcDEv5V.js +0 -1
  149. package/web/_app/immutable/chunks/BqrMZ9MX.js +0 -1
  150. package/web/_app/immutable/chunks/ChbZenhA.js +0 -7
  151. package/web/_app/immutable/chunks/CnR51TY0.js +0 -1
  152. package/web/_app/immutable/chunks/DMzXaGgk.js +0 -523
  153. package/web/_app/immutable/chunks/DshHzxgH.js +0 -1
  154. package/web/_app/immutable/chunks/Iqr2CudW.js +0 -3
  155. package/web/_app/immutable/chunks/wQPxmN7w.js +0 -1
  156. package/web/_app/immutable/entry/app.Z7pwf_yI.js +0 -2
  157. package/web/_app/immutable/entry/start.B_WWh0TE.js +0 -1
  158. package/web/_app/immutable/nodes/0.zgVqViQf.js +0 -26
  159. package/web/_app/immutable/nodes/1.D06ogNcd.js +0 -1
  160. package/web/_app/immutable/nodes/2.Xq8_UpCY.js +0 -1
  161. package/web/_app/immutable/nodes/3.CgpZ3cDm.js +0 -1
  162. package/web/_app/immutable/nodes/4.DQfZbhoQ.js +0 -2
  163. package/web/_app/immutable/nodes/5.BqLxxB44.js +0 -9
  164. package/web/_app/immutable/nodes/6.Dg2_pK7R.js +0 -1
  165. package/web/_app/immutable/nodes/7.BpxHVHoY.js +0 -1
  166. /package/web/_app/immutable/assets/{7.C00vyVPo.css → 6.C00vyVPo.css} +0 -0
@@ -1,2 +1,2 @@
1
- import{_ as e,a as t,c as n,i as r,m as i,o as a,r as o,t as s,u as c,x as l}from"./DfCZPwp1.js";import{n as u}from"./DciMwFJ1.js";import{a as d,s as f}from"./BLmF1B2i.js";import{c as p,d as m,f as h,g,h as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./DX4bJJO0.js";import{t as D}from"./CQd9D8Nc.js";import{PeleError as O,u as ee}from"./-2Meesge.js";var k=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let n=this.nodes.get(t);n&&(n.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=new Map;for(let[e,t]of this.nodes)this.labels.has(t.label)||this.labels.set(t.label,e)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!=`number`||typeof t.y!=`number`)throw new O(`Node "${t.label}" is missing coordinates`,`semantic`,{type:`wardley`});e.push(t)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}};function A(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new O(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,`semantic`,{type:`wardley`});return n}function j(e,t,n){return{x:A(t,`${n} evolution`),y:A(e,`${n} visibility`)}}function M(e){return e===`+<>`?`bidirectional`:e===`+<`?`backward`:e===`+>`?`forward`:void 0}function te(e){if(!e?.startsWith(`+`))return{};let t=e.indexOf(`'`,2),n=e[1]===`'`&&t!==-1?e.slice(2,t):void 0;return e.includes(`<>`)?{flow:`bidirectional`,label:n}:e.includes(`<`)?{flow:`backward`,label:n}:e.includes(`>`)?{flow:`forward`,label:n}:{label:n}}function N(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function ne(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(e=>e.secondName?`${e.name.trim()} / ${e.secondName.trim()}`:e.name.trim()),stageBoundaries:e.evolution.stages.filter(e=>e.boundary!==void 0).map(e=>e.boundary)});for(let n of e.anchors){let e=j(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`anchor`})}for(let n of e.components){let e=j(n.visibility,n.evolution,`Component "${n.name}"`),[r,i]=N(n.label);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`component`,labelOffsetX:r,labelOffsetY:i,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let e=j(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:e.x,y:e.y})}for(let n of e.pipelines){let e=t.getNode(n.parent);if(!e||typeof e.y!=`number`)throw new O(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,`semantic`,{type:`wardley`});let r=e.y;t.startPipeline(n.parent);for(let e of n.components){let i=`${n.parent}_${e.name}`,[a,o]=N(e.label),s=A(e.evolution,`Pipeline component "${e.name}" evolution`);t.addNode({id:i,label:e.name,x:s,y:r,className:`pipeline-component`,labelOffsetX:a,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,i)}}for(let n of e.links){let e=!!n.arrow&&(n.arrow.includes(`-.->`)||n.arrow.includes(`.-.`)),r=te(n.arrow),i=M(n.fromPort)??M(n.toPort)??r.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:e,label:r.label??n.linkLabel,flow:i})}for(let n of e.evolves){let e=t.getNode(n.component);e?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:A(n.target,`Evolve target for "${n.component}"`),targetY:e.y})}if(e.annotations.length>0){let n=j(e.annotations[0].x,e.annotations[0].y,`Annotations box`);t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let e=j(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:e.x,y:e.y}],text:n.text})}for(let n of e.accelerators){let e=j(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:e.x,y:e.y})}for(let n of e.deaccelerators){let e=j(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:e.x,y:e.y})}}function P(e,t){let n=new k;return ne(e,n),{type:`wardley`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
1
+ import{_ as e,a as t,c as n,i as r,m as i,o as a,r as o,t as s,u as c,x as l}from"./C2npZzkn.js";import{n as u}from"./DciMwFJ1.js";import{a as d,s as f}from"./BXBhaEho.js";import{c as p,d as m,f as h,g,h as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E}from"./CTDYUZPz.js";import{t as D}from"./l1LsK1sB.js";import{PeleError as O,u as ee}from"./CMikI1NP.js";var k=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let n=this.nodes.get(t);n&&(n.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=new Map;for(let[e,t]of this.nodes)this.labels.has(t.label)||this.labels.set(t.label,e)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!=`number`||typeof t.y!=`number`)throw new O(`Node "${t.label}" is missing coordinates`,`semantic`,{type:`wardley`});e.push(t)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}};function A(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new O(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,`semantic`,{type:`wardley`});return n}function j(e,t,n){return{x:A(t,`${n} evolution`),y:A(e,`${n} visibility`)}}function M(e){return e===`+<>`?`bidirectional`:e===`+<`?`backward`:e===`+>`?`forward`:void 0}function te(e){if(!e?.startsWith(`+`))return{};let t=e.indexOf(`'`,2),n=e[1]===`'`&&t!==-1?e.slice(2,t):void 0;return e.includes(`<>`)?{flow:`bidirectional`,label:n}:e.includes(`<`)?{flow:`backward`,label:n}:e.includes(`>`)?{flow:`forward`,label:n}:{label:n}}function N(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function ne(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map(e=>e.secondName?`${e.name.trim()} / ${e.secondName.trim()}`:e.name.trim()),stageBoundaries:e.evolution.stages.filter(e=>e.boundary!==void 0).map(e=>e.boundary)});for(let n of e.anchors){let e=j(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`anchor`})}for(let n of e.components){let e=j(n.visibility,n.evolution,`Component "${n.name}"`),[r,i]=N(n.label);t.addNode({id:n.name,label:n.name,x:e.x,y:e.y,className:`component`,labelOffsetX:r,labelOffsetY:i,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let e=j(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:e.x,y:e.y})}for(let n of e.pipelines){let e=t.getNode(n.parent);if(!e||typeof e.y!=`number`)throw new O(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,`semantic`,{type:`wardley`});let r=e.y;t.startPipeline(n.parent);for(let e of n.components){let i=`${n.parent}_${e.name}`,[a,o]=N(e.label),s=A(e.evolution,`Pipeline component "${e.name}" evolution`);t.addNode({id:i,label:e.name,x:s,y:r,className:`pipeline-component`,labelOffsetX:a,labelOffsetY:o,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,i)}}for(let n of e.links){let e=!!n.arrow&&(n.arrow.includes(`-.->`)||n.arrow.includes(`.-.`)),r=te(n.arrow),i=M(n.fromPort)??M(n.toPort)??r.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:e,label:r.label??n.linkLabel,flow:i})}for(let n of e.evolves){let e=t.getNode(n.component);e?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:A(n.target,`Evolve target for "${n.component}"`),targetY:e.y})}if(e.annotations.length>0){let n=j(e.annotations[0].x,e.annotations[0].y,`Annotations box`);t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let e=j(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:e.x,y:e.y}],text:n.text})}for(let n of e.accelerators){let e=j(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:e.x,y:e.y})}for(let n of e.deaccelerators){let e=j(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:e.x,y:e.y})}}function P(e,t){let n=new k;return ne(e,n),{type:`wardley`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
2
2
  `):void 0,...n.build()}}function F(e,t){let n=t;for(let t=e.charCodeAt(n);t>=48&&t<=57;t=e.charCodeAt(n))n++;return n}function I(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=F(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let i=F(n,t+1);return i>t+1?i:-1}}var L={name:`ARROW`,pattern:/->/y,first:`-`},R={name:`LINK_ARROW`,pattern:/-->|-\.->|>|\+'[^']*'<>|\+'[^']*'<|\+'[^']*'>/y,first:`->+`},z=(e,t)=>({name:e,pattern:new RegExp(t,`y`),first:t[0]}),re=[{name:`[`,pattern:`[`},{name:`,`,pattern:`,`},{name:`]`,pattern:`]`},{name:`@`,pattern:`@`},{name:`/`,pattern:`/`},{name:`(`,pattern:`(`},{name:`)`,pattern:`)`},{name:`-`,pattern:`-`,longer:[L,R,C]},{name:`{`,pattern:`{`},{name:`}`,pattern:`}`},{name:`WARDLEY_NUMBER`,pattern:/[0-9]+\.[0-9]+/y,first:`0123456789`,scanner:I},L,{name:`LINK_PORT`,pattern:/\+<>|\+>|\+</y,first:`+`},R,{name:`LINK_LABEL`,pattern:/;[^\n\r]+/y,first:`;`},{name:`STRATEGY`,pattern:/build|buy|outsource|market/y,first:`bom`},z(`KW_WARDLEY`,`wardley-beta`),z(`KW_SIZE`,`size`),z(`KW_EVOLUTION`,`evolution`),z(`KW_ANCHOR`,`anchor`),z(`KW_COMPONENT`,`component`),z(`KW_LABEL`,`label`),z(`KW_INERTIA`,`inertia`),z(`KW_EVOLVE`,`evolve`),z(`KW_PIPELINE`,`pipeline`),z(`KW_NOTE`,`note`),z(`KW_ANNOTATIONS`,`annotations`),z(`KW_ANNOTATION`,`annotation`),z(`KW_ACCELERATOR`,`accelerator`),z(`KW_DEACCELERATOR`,`deaccelerator`),{name:`NAME_WITH_SPACES`,pattern:/(?!title\s|accTitle|accDescr)[A-Za-z](?:[A-Za-z0-9_()&]|-(?!>))*(?:[ \t]+[A-Za-z(](?:[A-Za-z0-9_()&]|-(?!>))*)*/y,first:`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`},{name:`WS`,pattern:/[ \t]+/y,hidden:!0,first:` `},D(),T,S,{name:`INT`,pattern:/0|[1-9][0-9]*(?!\.)/y,first:`0123456789`},y,{name:`ID`,pattern:/[\w]([-\w]*\w)?/y,first:`_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`},v,E,C,x,w];function B(e){let t=new _(b(e,re,`wardley`),re,`wardley`),n={$type:`Wardley`,anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=e=>t.kinds[t.i]===e,i=()=>r(36)||r(37)||r(30),a=()=>r(36)?h(t.take()):r(37)||r(30)?t.take():t.fail(`a name`),o=()=>Number(t.expect(10)),s=()=>parseInt(t.expect(35)),c=()=>r(10)?Number(t.take()):parseInt(t.expect(35)),l=()=>{if(!r(-1))for(r(38)||t.fail(`a line break or the end of input`);r(38);)t.i++},u=e=>{t.expect(0);let n=e();t.expect(1);let r=e();return t.expect(2),[n,r]},d=()=>{t.expect(21),t.expect(0);let e=t.accept(7),n=s();t.expect(1);let r=t.accept(7),i=s();return t.expect(2),{$type:`Label`,negX:e,offsetX:n,negY:r,offsetY:i}},f=()=>{let e={$type:`EvolutionStage`,name:a()};return t.accept(3)&&(e.boundary=o()),t.accept(4)&&(e.secondName=a()),e};for(;r(38);)t.i++;for(t.expect(16);!r(-1);)switch(t.kind){case 38:t.i++;break;case 32:n.accDescr=p(t.take()),l();break;case 33:n.accTitle=g(t.take()),l();break;case 34:n.title=m(t.take()),l();break;case 17:{t.i++;let[e,r]=u(s);l(),n.size={$type:`Size`,width:e,height:r};break}case 18:{t.i++;let e=[f()];for(t.expect(11),e.push(f());t.accept(11);)e.push(f());l(),n.evolution={$type:`Evolution`,stages:e};break}case 19:{t.i++;let e=a(),[r,i]=u(o);l(),n.anchors.push({$type:`Anchor`,name:e,visibility:r,evolution:i});break}case 20:{t.i++;let e={$type:`Component`,name:a(),visibility:0,evolution:0,inertia:!1};[e.visibility,e.evolution]=u(o),r(21)&&(e.label=d()),r(5)&&t.kinds[t.i+1]===15&&(t.i++,e.decorator={$type:`Decorator`,strategy:t.take()},t.expect(6)),t.accept(22)?e.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),e.inertia=!0),l(),n.components.push(e);break}case 23:{t.i++;let e=a(),r=o();l(),n.evolves.push({$type:`Evolve`,component:e,target:r});break}case 24:{t.i++;let e=a();for(t.expect(8),t.expect(38);r(38);)t.i++;let i=[];do{t.expect(20);let e={$type:`PipelineComponent`,name:a(),evolution:0};t.expect(0),e.evolution=o(),t.expect(2),r(21)&&(e.label=d()),l(),i.push(e)}while(r(20));t.expect(9),l(),n.pipelines.push({$type:`Pipeline`,parent:e,components:i});break}case 25:{t.i++;let e=h(t.expect(36)),[r,i]=u(o);l(),n.notes.push({$type:`Note`,text:e,visibility:r,evolution:i});break}case 26:{t.i++;let[e,r]=u(c);l(),n.annotations.push({$type:`Annotations`,x:e,y:r});break}case 27:{t.i++;let e=s();t.expect(1);let[r,i]=u(c),a=h(t.expect(36));l(),n.annotation.push({$type:`Annotation`,number:e,x:r,y:i,text:a});break}case 28:case 29:{let e=t.kind===29;t.i++;let r=a(),[i,s]=u(o);l(),e?n.deaccelerators.push({$type:`Deaccelerator`,name:r,x:i,y:s}):n.accelerators.push({$type:`Accelerator`,name:r,x:i,y:s});break}default:{i()||t.fail(`a statement`);let e={$type:`Link`,from:a(),to:``};r(12)&&(e.fromPort=t.take()),(r(13)||r(11))&&(e.arrow=t.take()),e.to=a(),r(12)&&(e.toPort=t.take()),r(14)&&(e.linkLabel=t.take().substring(1).trim()),l(),n.links.push(e)}}return n}var ie=[`Genesis`,`Custom Built`,`Product`,`Commodity`],V=48,H=6,U=10,ae=8,W=15,G=60,oe=30,se=20,K=`var(--_c)`,q=`var(--_l)`;function ce(e,t,n,r,i){let a=e[`wardley-beta`]?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function J(e,t,n){return e<t?t:e>n?n:e}function le(e,r,a,o){let c=n(e),u=``,d=a;for(let n of e.lines){let a=!0;for(let e of n){if(e.icon!==void 0)continue;let n=i(e.style&~c);u+=`<tspan${a?` x="${l(r)}" y="${l(d)}"`:``}${n}>${t(e.text)}</tspan>`,a=!1}d+=e.lineHeight}return u===``?``:`<text${s(o,c)} xml:space="preserve">${u}</text>`}function ue(e,t,n,r){return J(typeof t==`number`&&Number.isFinite(t)?t:ce(e,n,r,1,1e6),200,1e4)-2*V}function Y(e,t,n){let r=ue(t,e.size?.width,`width`,900);return u(n,r,160,(i,a)=>X(e,t,n,i,r,a))}function X(t,n,i,s,u,p){let m=i.fontSize??16,h=Math.round(m*.8125),g=Math.round(m*.6875),_=i.measurer??ee(i.fontFamily,i.fontFamilyMono),v=i.padding??8,y=ue(n,t.size?.height,`height`,600)*Math.max(.75,s/u),b=n[`wardley-beta`]?.showGrid===!0,x=0,S=0,C=s,w=y,T=(e,t,n,r)=>{e<x&&(x=e),t<S&&(S=t),n>C&&(C=n),r>w&&(w=r)},E=(e,t,n,r)=>(T(t-e.width/2,n-e.height/2,t+e.width/2,n+e.height/2),a(e,t,n,r,i.icons)),D=(e,t,n,r)=>(T(t,n-e.size,t+e.width,n-e.size+e.height+4),le(e,t,n,r)),O=(e,t,n=p?Math.max(64,Math.min(120,s/2)):4e3,r=0)=>c(e,!1,_,t,n,r),k=e=>e/100*s,A=e=>y-e/100*y,j=t.axes.stages&&t.axes.stages.length>0?t.axes.stages:ie,M=t.axes.stageBoundaries,te=M!==void 0&&M.length===j.length,N=``,ne=``,P=y,F=0;if(j.forEach((e,t)=>{let n=te?F:t/j.length,r=te?J(M[t],0,1):(t+1)/j.length;F=r,t>0&&(N+=`<path class="pele-wardley-stage" d="M${l(n*s)},0V${l(y)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let i=O(e,h,Math.max(48,Math.abs(r-n)*s-12));ne+=E(i,(n+r)/2*s,y+8+i.height/2,` class="pele-wardley-stage-label" font-size="${h}" fill="var(--_m)"`),P=Math.max(P,y+8+i.height)}),b)for(let e=1;e<4;e++)N+=`<path class="pele-wardley-grid" d="M${l(s*e/4)},0V${l(y)}M0,${l(y*e/4)}H${l(s)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;N+=`<path class="pele-wardley-axis" d="M0,0V${l(y)}H${l(s)}" stroke="${q}"/>`;let I=O(t.axes.xLabel??`Evolution`,h),L=O(t.axes.yLabel??`Visibility`,h),R=` class="pele-wardley-axis-label" font-size="${h}" font-weight="var(--_hw)"`,z=E(I,s/2,P+6+I.height/2,R)+a(L,-16,y/2,`${R} transform="rotate(-90 -16 ${l(y/2)})"`);T(-16-L.height/2,0,0,0);let re=P+6+I.height+10,B=new Map;for(let e of t.nodes)B.set(e.id,{x:k(e.x),y:A(e.y),node:e});let V=``,ce=new Map;for(let e of t.pipelines){ce.set(e.nodeId,new Set(e.componentIds));let t=[];for(let n of e.componentIds){let e=B.get(n);e&&t.push(e)}if(t.length===0)continue;t.sort((e,t)=>e.x-t.x);let n=t[0].x,i=t[t.length-1].x,a=t[0].y,s=a-2*H,c=B.get(e.nodeId);c&&(c.x=(n+i)/2,c.y=s-U/6),T(n-W,s,i+W,s+4*H),V+=`<g class="pele-wardley-pipeline" data-id="${r(e.nodeId)}"><rect x="${l(n-W)}" y="${l(s)}" width="${l(i-n+2*W)}" height="${l(4*H)}" fill="var(--_s)" stroke="var(--_b)"${o}/>`+(t.length>1?`<path d="M${l(n)},${l(a)}H${l(i)}" stroke="${q}" stroke-dasharray="4 4"/>`:``)+`</g>`}let Y=new Map,X=(e,t,n)=>{let r=e.node;if(r.className===`anchor`){let e=Y.get(r);return e||Y.set(r,e=O(r.label,h,p?Math.max(64,s/2):4e3,1)),1/Math.hypot(t/(e.width/2+5),n/(h*.8))}return r.isPipelineParent?U/Math.SQRT2:r.sourceStrategy?2*H:H},Z=new Map,de=(e,t,n)=>{Math.abs(t)<.25||Math.abs(n)<.25||Z.set(e,(Z.get(e)??0)|(t>0?n<0?1:2:n<0?4:8))},fe=``;for(let e of t.links){let t=B.get(e.source),n=B.get(e.target);if(!t||!n||t===n||ce.get(e.target)?.has(e.source))continue;let i=n.x-t.x,a=n.y-t.y,o=Math.hypot(i,a);if(o<.01)continue;let s=i/o,c=a/o,u=X(t,s,c),p=X(n,s,c);if(u+p>=o)continue;de(t,s,c),de(n,-s,-c);let m=t.x+s*u,h=t.y+c*u,_=n.x-s*p,v=n.y-c*p,y=``;(e.flow===`forward`||e.flow===`bidirectional`)&&(y+=f(`arrow_point`,_,v,s,c,q),_-=s*d(`arrow_point`),v-=c*d(`arrow_point`)),(e.flow===`backward`||e.flow===`bidirectional`)&&(y+=f(`arrow_point`,m,h,-s,-c,q),m+=s*d(`arrow_point`),h+=c*d(`arrow_point`));let b=``;if(e.label){let r=O(e.label,g+1,200),i=s>=0?1:-1,a=c*i,o=-s*i,l=5+Math.abs(a)*r.width/2+Math.abs(o)*r.height/2;b=E(r,(t.x+n.x)/2+a*l,(t.y+n.y)/2+o*l,` class="pele-edge-label" font-size="${g+1}" fill="var(--_m)"`)}fe+=`<g class="pele-edge${e.dashed?` pele-wardley-dashed`:``}" data-id="${r(e.source)}-${r(e.target)}"><path d="M${l(m)},${l(h)}L${l(_)},${l(v)}" stroke="${q}"${e.dashed?` stroke-dasharray="6 6"`:``}/>`+y+b+`</g>`}let pe=``;for(let e of t.trends){let t=B.get(e.nodeId);if(!t)continue;let n=k(e.targetX),i=A(e.targetY),a=n-t.x,o=i-t.y,s=Math.hypot(a,o),c=``,u=s>0?X(t,a/s,o/s):0;if(s>u+H+4){let e=a/s,r=o/s,p=n-e*(H+2),m=i-r*(H+2);c=`<path d="M${l(t.x+e*u)},${l(t.y+r*u)}L${l(p-e*d(`arrow_point`))},${l(m-r*d(`arrow_point`))}" stroke="${K}" stroke-dasharray="4 4"/>`+f(`arrow_point`,p,m,e,r,K)}T(n-H,i-H,n+H,i+H),pe+=`<g class="pele-wardley-trend" data-id="${r(e.nodeId)}">${c}<circle cx="${l(n)}" cy="${l(i)}" r="${H}" fill="var(--_bg)" stroke="${K}"/></g>`}let me=``,Q=1.2*H,he=.7*H;for(let e of B.values()){let t=e.node,{x:n,y:i}=e,a=t.className===`anchor`,o=t.sourceStrategy,c=``;if(o){let e=o===`outsource`?`var(--_m)`:o===`buy`?`var(--_a)`:o===`build`?`var(--_s)`:`var(--_bg)`;c+=`<circle class="pele-wardley-${o}" cx="${l(n)}" cy="${l(i)}" r="${2*H}" fill="${e}" stroke="${q}"/>`}if(o===`market`){let e=Q*Math.cos(Math.PI/6),t=i+Q*Math.sin(Math.PI/6);c+=`<path d="M${l(n)},${l(i-Q)}L${l(n-e)},${l(t)}H${l(n+e)}Z" fill="none" stroke="${q}"/>`;for(let[r,a]of[[n,i-Q],[n-e,t],[n+e,t]])c+=`<circle cx="${l(r)}" cy="${l(a)}" r="${l(he)}" fill="var(--_bg)" stroke="${q}"/>`}else t.isPipelineParent?c+=`<rect x="${l(n-U/2)}" y="${l(i-U/2)}" width="${U}" height="${U}" fill="var(--_bg)" stroke="${q}"/>`:a||(c+=`<circle cx="${l(n)}" cy="${l(i)}" r="${H}" fill="var(--_bg)" stroke="${q}"/>`);if(t.inertia===!0){let e=(t.isPipelineParent?U/2:H)+10+(o?H+4:0);c+=`<rect class="pele-wardley-inertia" x="${l(n+e)}" y="${l(i-H)}" width="4" height="${2*H}" fill="${q}"/>`}let u=t.labelOffsetX===void 0?void 0:J(t.labelOffsetX,-5e3,5e3),d=t.labelOffsetY===void 0?void 0:J(t.labelOffsetY,-5e3,5e3),f;if(a)f=E(Y.get(t)??O(t.label,h,p?Math.max(64,s/2):4e3,1),n+(u??0),i+(d??-3),` class="pele-label" font-size="${h}" font-weight="var(--_hw)"`);else{let r=O(t.label,h),a=` class="pele-label" font-size="${h}"`,s=ae+(o?10:0);if(u!==void 0||d!==void 0)f=D(r,n+(u??s),i+(d??-s),a);else if(t.inPipeline)f=E(r,n,i+2*H+4+r.height/2,a);else{let t=Z.get(e)??0,o=t&1?t&2?t&4?t&8?1:8:4:2:1,c=o===1||o===2,l=o===1||o===4;f=D(r,c?n+s:n-s-r.width,l?i-s:i+s+h*.75,a)}}T(n-2*H,i-2*H,n+2*H+20,i+2*H),me+=`<g class="pele-node pele-wardley-${a?`anchor`:t.isPipelineParent?`pipeline-parent`:t.inPipeline?`pipeline-component`:`component`}" data-id="${r(t.id)}">${c}${f}</g>`}let ge=``;for(let e of t.annotations){let t=O(String(e.number),g,4e3,1),n=``;for(let r of e.coordinates){let e=k(r.x),i=A(r.y),o=Math.max(10,t.width/2+4);T(e-o,i-o,e+o,i+o),n+=`<circle cx="${l(e)}" cy="${l(i)}" r="${l(o)}" fill="var(--_bg)" stroke="${q}"/>`+a(t,e,i,` font-size="${g}" font-weight="var(--_hw)"`)}ge+=`<g class="pele-wardley-annotation" data-id="${r(String(e.number))}">${n}</g>`}let _e=t.annotations.filter(e=>e.text).sort((e,t)=>e.number-t.number);if(_e.length>0){let e=_e.map(e=>O(`${e.number}. ${e.text}`,h,p?Math.max(80,s-20):320)),n=0,r=0;for(let t of e)n=Math.max(n,t.width),r+=t.height;n+=20,r+=14;let i=t.annotationsBox,a=i?J(k(i.x),0,Math.max(0,s-n)):0,c=i?J(A(i.y),0,Math.max(0,y-r)):re;T(a,c,a+n,c+r);let u=``,d=c+7;for(let t of e)u+=le(t,a+10,d+t.lineHeight/2+h*.35,` font-size="${h}"`),d+=t.height;ge+=`<g class="pele-wardley-annotations"><rect x="${l(a)}" y="${l(c)}" width="${l(n)}" height="${l(r)}" fill="var(--_bg)" stroke="var(--_b)"${o}/>${u}</g>`}let ve=``;for(let e of t.notes)ve+=D(O(e.text,h,Math.min(360,s*.6),1),k(e.x),A(e.y),` class="pele-wardley-note" font-size="${h}" font-weight="var(--_hw)"`);let ye=``,be=(e,t,n,i)=>{let a=k(t),o=A(n),s=oe/2,c=i?a+G:a,u=i?a:a+G,d=i?a+G-se:a+se,f=`M${l(u)},${l(o-s)}H${l(d)}V${l(o-s-8)}L${l(c)},${l(o)}L${l(d)},${l(o+s+8)}V${l(o+s)}H${l(u)}Z`;T(a,o-s-8,a+G,o+s+8),ye+=`<g class="pele-wardley-${i?`accelerator`:`deaccelerator`}" data-id="${r(e)}"><path d="${f}" fill="var(--_s)" stroke="${q}"/>`+E(O(e,g+1,160,1),a+G/2,o+s+8+12,` font-size="${g+1}" font-weight="var(--_hw)"`)+`</g>`};for(let e of t.accelerators)be(e.name,e.x,e.y,!0);for(let e of t.deaccelerators)be(e.name,e.x,e.y,!1);let $=c(t.title,!1,_,m,p?Math.max(80,s):4e3,1),xe=$.height>0?$.height+12:0,Se=Math.min(x,s/2-$.width/2),Ce=Math.max(C,s/2+$.width/2),we=v-Se,Te=v+xe-S,Ee=Math.ceil(Ce-Se+2*v),De=Math.ceil(w-S+xe+2*v),Oe=a($,we+s/2,v+$.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${l(we)},${l(Te)})"><g class="pele-wardley-frame" fill="none">${N}</g>`+ne+z+V+(fe?`<g class="pele-edges" fill="none">${fe}</g>`:``)+(pe?`<g class="pele-wardley-trends" fill="none">${pe}</g>`:``)+me+ge+ve+ye+`</g>`;return{svg:e(`wardley`,Ee,De,m,i,t,Oe),width:Ee,height:De,links:[]}}var Z={type:`wardley`,section:`wardley-beta`,parse:(e,t,n)=>P(B(e),n),render:Y};export{Z as wardley};
@@ -0,0 +1 @@
1
+ import{A as e,C as t,E as n,F as r,I as i,L as a,M as o,O as s,Q as c,W as l,Y as u,Z as d,d as f,dt as p,et as m,g as h,i as g,l as _,nt as v,ot as y,st as b,tt as x,u as S,z as C}from"./e2LGvGEb.js";import"./xihTtKlq.js";import{a as w}from"./CPSlCQsu.js";var T=o(`<li role="option"><button type="button" tabindex="-1" class="svelte-35e6rs"><span class="dir svelte-35e6rs"> </span><span class="detail svelte-35e6rs"> </span></button></li>`),E=o(`<ul class="suggest svelte-35e6rs" role="listbox" aria-label="folders"></ul>`),D=o(`<span class="field-wrap svelte-35e6rs"><input autocomplete="off" spellcheck="false" role="combobox" aria-autocomplete="list"/> <!></span>`);function O(r,o){b(o,!0);let O=g(o,`value`,15,``),k=g(o,`placeholder`,3,``),A=g(o,`id`,3,`folder`),j=g(o,`quiet`,3,!1),M=x(!1),N=x(0),P=v(()=>O().trim().replace(/^\/+|\/+$/g,``).toLowerCase()),F=e=>w.listing.notes.filter(t=>t.dir===e).length,I=v(()=>{let e=w.listing.dirs.filter(e=>e.toLowerCase().includes(C(P))),t=e=>e.split(`/`).at(-1).toLowerCase().startsWith(C(P))?0:e.toLowerCase().startsWith(C(P))?1:2,n=e.sort((e,n)=>t(e)-t(n)||e.localeCompare(n)).map(e=>({dir:e,made:!1}));return C(P)&&!w.listing.dirs.some(e=>e.toLowerCase()===C(P))&&n.push({dir:O().trim().replace(/^\/+|\/+$/g,``),made:!0}),n.slice(0,8)});function L(e){O(e),m(M,!1),o.onpick?.(e)}function R(e){if(C(M)&&C(I).length){if(e.key===`ArrowDown`){m(N,(C(N)+1)%C(I).length),e.preventDefault();return}if(e.key===`ArrowUp`){m(N,(C(N)-1+C(I).length)%C(I).length),e.preventDefault();return}if((e.key===`Enter`||e.key===`Tab`)&&C(I)[C(N)]&&(e.key===`Enter`||C(P))){e.key===`Enter`&&e.preventDefault(),L(C(I)[C(N)].dir);return}if(e.key===`Escape`){m(M,!1),e.stopPropagation();return}}o.onkeydown?.(e)}var z=D(),B=u(z);S(B);let V;var H=c(B,2),U=n=>{var r=E();t(r,23,()=>C(I),e=>e.dir+e.made,(t,n,r)=>{var o=T();let g;var _=u(o),v=u(_),y=d(v,!0),b=c(v),x=d(b,!0);p(_),p(o),l(e=>{f(o,`id`,`${A()??``}-opt-${C(r)??``}`),f(o,`aria-selected`,C(r)===C(N)),g=h(o,1,`svelte-35e6rs`,null,g,{at:C(r)===C(N)}),s(y,C(n).dir),s(x,e)},[()=>C(n).made?`new folder`:`${F(C(n).dir)} ${F(C(n).dir)===1?`note`:`notes`}`]),i(`mousedown`,_,e=>e.preventDefault()),i(`click`,_,()=>L(C(n).dir)),a(`mouseenter`,_,()=>m(N,C(r),!0)),e(t,o)}),p(r),l(()=>f(r,`id`,`${A()??``}-list`)),e(n,r)};n(H,e=>{C(M)&&C(I).length&&e(U)}),p(z),l(()=>{f(B,`id`,A()),V=h(B,1,`mono svelte-35e6rs`,null,V,{field:!j(),quiet:j()}),f(B,`placeholder`,k()),f(B,`aria-label`,o.label),f(B,`aria-expanded`,C(M)&&C(I).length>0),f(B,`aria-controls`,`${A()??``}-list`),f(B,`aria-activedescendant`,C(M)&&C(I)[C(N)]?`${A()}-opt-${C(N)}`:void 0)}),a(`focus`,B,()=>{m(M,!0),m(N,0)}),i(`input`,B,()=>{m(M,!0),m(N,0)}),a(`blur`,B,()=>setTimeout(()=>m(M,!1),120)),i(`keydown`,B,R),_(B,O),e(r,z),y()}r([`input`,`keydown`,`mousedown`,`click`]);export{O as t};
@@ -1,2 +1,2 @@
1
- import{_ as e,f as t,i as n,o as r,r as i,u as a,x as o}from"./DfCZPwp1.js";import{a as s,s as c}from"./BLmF1B2i.js";import{a as l,c as u,d,f,g as p,h as m,i as h,l as g,m as ee,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./DX4bJJO0.js";import{u as te}from"./-2Meesge.js";var w=class{domains=new Map;transitions=[];setDomains(e){if(e)for(let t of e){let e=t.domain;this.domains.set(e,{name:e,items:(t.items??[]).map(e=>({label:e.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(e=>e.from!==e.to).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))}};function T(e,t){let n=new w;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:`cynefin`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
1
+ import{_ as e,f as t,i as n,o as r,r as i,u as a,x as o}from"./C2npZzkn.js";import{a as s,s as c}from"./BXBhaEho.js";import{a as l,c as u,d,f,g as p,h as m,i as h,l as g,m as ee,n as _,o as v,p as y,r as b,s as x,t as S,u as C}from"./CTDYUZPz.js";import{u as te}from"./CMikI1NP.js";var w=class{domains=new Map;transitions=[];setDomains(e){if(e)for(let t of e){let e=t.domain;this.domains.set(e,{name:e,items:(t.items??[]).map(e=>({label:e.label}))})}}setTransitions(e){e&&(this.transitions=e.filter(e=>e.from!==e.to).map(e=>({from:e.from,to:e.to,label:e.label||void 0})))}};function T(e,t){let n=new w;return n.setDomains(e.domains),n.setTransitions(e.transitions),{type:`cynefin`,title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,``):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
2
2
  `):void 0,domains:n.domains,transitions:n.transitions}}var E=[{name:`cynefin-beta:`,pattern:`cynefin-beta:`},h(`cynefin-beta`),{name:`-->`,pattern:`-->`},{name:`:`,pattern:`:`},{name:`DOMAIN_NAME`,pattern:/complex|complicated|clear|chaotic|confusion/y},l,S,y,ee,g,C,b,v,x];function D(e){let t=new m(_(e,E,`cynefin`),E,`cynefin`),n={$type:`Cynefin`,domains:[],transitions:[]},r=()=>{for(;t.kinds[t.i]===9;)t.i++},i=()=>{t.kind!==-1&&(t.kind!==9&&t.fail(`a line break or the end of input`),r())};for(r(),t.kind!==1&&t.kind!==0&&t.fail(`'cynefin-beta'`),t.i++;t.kind!==-1;)switch(t.kind){case 9:t.i++;break;case 5:n.accDescr=u(t.take()),i();break;case 6:n.accTitle=p(t.take()),i();break;case 7:n.title=d(t.take()),i();break;case 4:{let e=t.take();if(t.accept(2)){let r={$type:`Transition`,from:e,to:t.expect(4)};t.accept(3)&&(r.label=f(t.expect(8))),i(),n.transitions.push(r);break}let a={$type:`DomainBlock`,domain:e,items:[]};for(r();t.kinds[t.i]===8;)a.items.push({$type:`DomainItem`,label:f(t.take())}),r();n.domains.push(a);break}default:t.fail(`a domain, a transition, a title, or a line break`)}return n}function O(e){let t=e+1831565813|0;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function k(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}function ne(e,t){return typeof e==`number`&&Number.isFinite(e)&&e!==0?e:k(t)}var re={segments:7,vertical:!0,pointStep:17,controlStep:31,controlShift:7},A={segments:7,vertical:!1,pointStep:23,controlStep:37,controlShift:11};function j(e,t,n,r,i,a){let o=(t-e)/a.segments,s=[],c=[];for(let t=0;t<=a.segments;t++){let l=t===0&&a.pinStart||t===a.segments&&a.pinEnd;s.push(e+t*o),c.push(l?n:n+O(r+t*a.pointStep)*i*2-i)}let l=a.vertical?[c[0],s[0]]:[s[0],c[0]];for(let e=0;e<a.segments;e++){let t=(s[e]+s[e+1])/2,n=i*1.5*(e%2==0?1:-1)*O(r+e*a.controlStep+a.controlShift);a.vertical?l.push(c[e]+n,t,c[e+1]-n,t,c[e+1],s[e+1]):l.push(t,c[e]+n,t,c[e+1]-n,s[e+1],c[e+1])}return l}function ie(e,t,n,r){let i=n-t;return[e,t,e+r,t+i*.2,e-r*1.5,t+i*.55,e+r*.5,t+i*.75,e-r,t+i*.85,e+r*.3,t+i*.95,e,n]}function M(e){let t=``;for(let n=2;n<e.length;n+=6)t+=`C${o(e[n])},${o(e[n+1])} ${o(e[n+2])},${o(e[n+3])} ${o(e[n+4])},${o(e[n+5])}`;return t}function N(e){let t=``;for(let n=e.length-6;n>=2;n-=6)t+=`C${o(e[n+2])},${o(e[n+3])} ${o(e[n])},${o(e[n+1])} ${o(e[n-2])},${o(e[n-1])}`;return t}function P(e){return`M${o(e[0])},${o(e[1])}${M(e)}`}function F(e,t,n,r){let i=`${o(n)},${o(r)}`;return`M${o(e-n)},${o(t)}A${i} 0 1,1 ${o(e+n)},${o(t)}A${i} 0 1,1 ${o(e-n)},${o(t)}Z`}var I=[[`complex`,0,0,0],[`complicated`,1,0,1],[`chaotic`,0,1,3],[`clear`,1,1,2]],ae=4,L=new Map([[`complex`,[`Complex`,`Probe → Sense → Respond`,`Emergent Practices`]],[`complicated`,[`Complicated`,`Sense → Analyse → Respond`,`Good Practices`]],[`clear`,[`Clear`,`Sense → Categorise → Respond`,`Best Practices`]],[`chaotic`,[`Chaotic`,`Act → Sense → Respond`,`Novel Practices`]],[`confusion`,[`Confusion`,``,`Disorder`]]]),oe=3,se=200,ce=10,le=4,R=6,ue=10,de=20,z=10;function B(e,t,n,r,i){let a=e.cynefin?.[t];return typeof a==`number`&&a>=r&&a<=i?a:n}function V(l,u,d){let f=d.fontSize??16,p=Math.round(f*.8125),m=Math.round(f*.875),h=d.measurer??te(d.fontFamily,d.fontFamilyMono),g=d.padding??8,ee=d.icons,_=u.cynefin?.showDomainDescriptions!==!1,v=B(u,`boundaryAmplitude`,8,0,50),y=ne(B(u,`seed`,0,-0x38d7ea4c68000,0x38d7ea4c68000),d.idPrefix??`pele`),b=Math.round(m*1.5),x=(e,t)=>{let n=a(e,!1,h,m,se);return{text:e,label:n,w:n.width+2*ce,h:Math.max(n.height,b)+2*le,overflow:t}},S=e=>{let t=L.get(e),n=a(t[0],!1,h,f,4e3,1),r=[];if(_)for(let e of[t[1],t[2]])e&&r.push(a(e,!1,h,p,4e3,2));let i=l.domains.get(e)?.items??[],o=e===`confusion`&&i.length>oe?oe:i.length,s=[];for(let e=0;e<o;e++)s.push(x(i[e].label,!1));o<i.length&&s.push(x(`+${i.length-o} more`,!0));let c=n.width,u=n.height;for(let e of r)c=Math.max(c,e.width),u+=e.height;s.length>0&&(u+=ue-R);for(let e of s)c=Math.max(c,e.w),u+=R+e.h;return{name:e,title:n,subtitles:r,badges:s,w:c,h:u,cx:0,cy:0}},C=I.map(([e])=>S(e)),w=S(`confusion`),T=Math.max(88,w.w*.71+8),E=Math.max(64,w.h*.71+6),D=B(u,`width`,640,100,1e4)/2,O=B(u,`height`,440,100,1e4)/2;for(let e of C)D=Math.max(D,e.w+2*de),O=Math.max(O,e.h+2*de);for(let e of C){let t=(D-e.w)/2,n=(O-e.h)/2;if((t/(T+z))**2+(n/(E+z))**2>=1)continue;let r=e.w+2*(T+z),i=e.h+2*(E+z);r*O<=D*i?D=Math.max(D,r):O=Math.max(O,i)}let k=a(l.title,!1,h,f,4e3,1),V=k.height>0?k.height+12:0,H=2*D,fe=2*O,U=g,W=g+V,G=U+D,K=W+O,q=U+H,pe=W+fe,J=j(W,K,G,y,v,{...re,segments:4,pinEnd:!0}),Y=j(U,G,K,y+100,v,{...A,segments:4,pinEnd:!0}),X=j(G,q,K,y+200,v,{...A,segments:4,pinStart:!0}),Z=ie(G,K,pe,H*.03),Q=(e,t)=>t?`${o(e[e.length-2])},${o(e[e.length-1])}`:`${o(e[0])},${o(e[1])}`,me=new Map([[`complex`,`M${o(U)},${o(W)}L${Q(J,!1)}${M(J)}${N(Y)}Z`],[`complicated`,`M${Q(J,!1)}L${o(q)},${o(W)}L${Q(X,!0)}${N(X)}${N(J)}Z`],[`chaotic`,`M${Q(Y,!1)}${M(Y)}${M(Z)}L${o(U)},${o(pe)}Z`],[`clear`,`M${Q(X,!1)}${M(X)}L${o(q)},${o(pe)}L${Q(Z,!0)}${N(Z)}Z`]]),he=``;for(let[e,,,n]of I)he+=`<path class="pele-cynefin-region" data-id="${e}" d="${me.get(e)}" fill="${t(n)}" fill-opacity="0.14"/>`;let ge=`<g class="pele-cynefin-boundaries" fill="none" stroke="var(--_b)" stroke-dasharray="6 3"><path d="${P(J)}"/><path d="${P(Y)}"/><path d="${P(X)}"/><path class="pele-cynefin-cliff" d="${P(Z)}" stroke="var(--_l)" stroke-width="2" stroke-dasharray="none" stroke-linecap="round"/></g>`,_e=F(G,K,T,E),ve=`<path d="${_e}" fill="var(--_bg)"/><path class="pele-cynefin-region" data-id="confusion" d="${_e}" fill="${t(ae)}" fill-opacity="0.18" stroke="var(--_b)" stroke-dasharray="4 2"/>`,ye=e=>{let t=e.cy-e.h/2,a=r(e.title,e.cx,t+e.title.height/2,` class="pele-label" font-weight="var(--_hw)"`);t+=e.title.height;for(let n of e.subtitles)a+=r(n,e.cx,t+n.height/2,` class="pele-cynefin-subtitle" font-size="${p}" font-style="italic" fill="var(--_m)"`),t+=n.height;t+=ue-R;for(let s of e.badges)t+=R,a+=`<g class="pele-node${s.overflow?` pele-cynefin-overflow`:``}"${s.overflow?``:` data-id="${n(s.text)}"`}><rect x="${o(e.cx-s.w/2)}" y="${o(t)}" width="${o(s.w)}" height="${o(s.h)}" fill="var(--_bg)" stroke="var(--_b)"${s.overflow?` stroke-dasharray="3 2"`:``}${i}/>`+r(s.label,e.cx,t+s.h/2,` class="pele-label" font-size="${m}"${s.overflow?` fill="var(--_m)"`:``}`,ee)+`</g>`,t+=s.h;return`<g class="pele-cynefin-domain" data-id="${e.name}">${a}</g>`},$=new Map,be=``;I.forEach(([e,t,n],r)=>{let i=C[r];i.cx=U+D*(t+.5),i.cy=W+O*(n+.5),$.set(e,i),be+=ye(i)}),w.cx=G,w.cy=K,$.set(`confusion`,w),be+=ye(w);let xe=(e,t,n)=>e===w?((t-G)/(T+4))**2+((n-K)/(E+4))**2<=1:Math.abs(t-e.cx)<=e.w/2+8&&Math.abs(n-e.cy)<=e.h/2+8,Se=``,Ce=new Map;for(let e of l.transitions){let t=$.get(e.from),n=$.get(e.to);if(!t||!n||t===n)continue;let i=e.from<e.to?`${e.from} ${e.to}`:`${e.to} ${e.from}`,l=Ce.get(i)??0;Ce.set(i,l+1);let u=n.cx-t.cx,d=n.cy-t.cy,f=Math.hypot(u,d)||1,m=(t.cx+n.cx)/2,g=(t.cy+n.cy)/2,_=-d*(m-G)+u*(g-K)>=0?1:-1,v=-d/f*_,y=u/f*_,b=(t!==w&&n!==w&&Math.abs(u)>1&&Math.abs(d)>1?2*(Math.hypot(T*v,E*y)+16):f*.15)+l*56,x=m+v*b,S=g+y*b,C=e=>{let r=1-e;return[r*r*t.cx+2*r*e*x+e*e*n.cx,r*r*t.cy+2*r*e*S+e*e*n.cy]},te=(e,t,n,r)=>{for(let i=0;i<16;i++){let i=(t+n)/2;xe(e,...C(i))===r?t=i:n=i}return(t+n)/2},D=1;for(;D<=48&&xe(t,...C(D/48));)D++;if(D>48)continue;let O=te(t,(D-1)/48,D/48,!0);for(;D<=48&&!xe(n,...C(D/48));)D++;let k=D>48?1:te(n,(D-1)/48,D/48,!1),[ne,re]=C(O),[A,j]=C(k),ie=(e,t,n)=>(1-O)*(1-k)*e+((1-O)*k+O*(1-k))*t+O*k*n,M=ie(t.cx,x,n.cx),N=ie(t.cy,S,n.cy),P=Math.hypot(A-M,j-N)||1,F=(A-M)/P,I=(j-N)/P,ae=c(`arrow_point`,A,j,F,I,`var(--_l)`);A-=F*s(`arrow_point`),j-=I*s(`arrow_point`);let L=``;if(e.label){let t=a(e.label,!1,h,p,se),[n,i]=C((O+k)/2),o=Math.abs(v)*t.width/2+Math.abs(y)*t.height/2+6,s=t.width/2+4,c=Math.min(Math.max(n+v*o,U+s),Math.max(q-s,U+s));L=r(t,c,i+y*o,` class="pele-edge-label" font-size="${p}"`,ee)}Se+=`<g class="pele-edge" data-id="${e.from}-${e.to}"><path d="M${o(ne)},${o(re)}Q${o(M)},${o(N)} ${o(A)},${o(j)}" fill="none" stroke="var(--_l)"/>`+ae+L+`</g>`}let we=Math.ceil(Math.max(H,k.width)+2*g),Te=Math.ceil(fe+V+2*g),Ee=r(k,U+H/2,g+k.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g class="pele-cynefin-regions">${he}</g>`+ge+ve+be+(Se?`<g class="pele-edges">${Se}</g>`:``);return{svg:e(`cynefin`,we,Te,f,d,l,Ee),width:we,height:Te,links:[]}}var H={type:`cynefin`,parse:(e,t,n)=>T(D(e),n),render:V};export{H as cynefin};
@@ -1,2 +1,2 @@
1
- import{i as e,n as t,t as n}from"./Czz9qOh8.js";import{_ as r,f as i,i as a,o,r as s,x as c}from"./DfCZPwp1.js";import{n as l,t as u}from"./BymwHy7o.js";import{t as d}from"./DciMwFJ1.js";import{g as f,h as p,s as m,u as h}from"./-2Meesge.js";function g(e){let t=new Set;for(let n of e)for(let e of n.people)t.add(e);return[...t].sort()}var _=class{type=`journey`;title;accTitle;accDescr;sections=[];tasks=[];currentSection=``;setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
1
+ import{i as e,n as t,t as n}from"./CT4_O9X_.js";import{_ as r,f as i,i as a,o,r as s,x as c}from"./C2npZzkn.js";import{n as l,t as u}from"./CtkUy_15.js";import{t as d}from"./DciMwFJ1.js";import{g as f,h as p,s as m,u as h}from"./CMikI1NP.js";function g(e){let t=new Set;for(let n of e)for(let e of n.people)t.add(e);return[...t].sort()}var _=class{type=`journey`;title;accTitle;accDescr;sections=[];tasks=[];currentSection=``;setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
2
2
  `)}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t){let n=t.substring(1).split(`:`),r=n.length===1?[]:n[1].split(`,`).map(e=>e.trim());this.tasks.push({task:e,score:Number(n[0]),people:r,section:this.currentSection})}getActors(){return g(this.tasks)}},v=[`$end`,`EOF`,`INVALID`,`NEWLINE`,`journey`,`title`,`acc_title`,`acc_title_value`,`acc_descr`,`acc_descr_value`,`acc_descr_multiline_value`,`section`,`taskName`,`taskData`,`:`];function y(e,t,n){let r=e.length,i=t;for(;i<r;i++){let t=e.charCodeAt(i);if(t===35||t===10||t===59||n&&t===58)break}return i}function b(r){let i=r.length,a=[],o=[],s=[],c={types:a,texts:o,starts:s},l=0,u=(e,t)=>{a.push(e),o.push(r.slice(l,t)),s.push(l),l=t};for(;l=t(r,l),!(l>=i);){let t=r.charCodeAt(l),a=l+1;if(t===10){for(;r.charCodeAt(a)===10;)a++;u(3,a)}else if(n(r,l,`journey`)&&!f(r.charCodeAt(l+7)))u(4,l+7);else{if(n(r,l,`title`)){for(a=l+5;r.charCodeAt(a)!==10&&p(r.charCodeAt(a));)a++;if(a===i||r.charCodeAt(a)===10){l=a;continue}let e=r.charCodeAt(l+5);if(e!==13&&p(e)&&(a=y(r,l+6,!1),a>l+6)){u(5,a);continue}}a=e(r,l,c,6),a===l?n(r,l,`section`)&&p(r.charCodeAt(l+7))&&(a=y(r,l+8,!0),a>l+8)?u(11,a):t===58?(a=y(r,l+1,!1),u(a>l+1?13:14,a>l+1?a:l+1)):t===59?u(2,l+1):u(12,y(r,l+1,!0)):l=a}}return(s.length===0||s[s.length-1]<i)&&u(1,i),u(0,i),c}var x=`'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'taskName'`;function S(e,t){let{types:n,texts:r,starts:i}=b(e),a=(t,r)=>{let a=n[t]===0?`1`:v[n[t]];throw m(`journey`,e,i[t],`Expecting ${r}, got '${a}'`)};n[0]!==4&&a(0,`'journey'`);for(let e=1;;e++){let i=r[e];switch(n[e]){case 3:break;case 5:t.setDiagramTitle(i.substring(6));break;case 6:t.setAccTitle(r[++e].trim());break;case 8:t.setAccDescription(r[++e].trim());break;case 10:t.setAccDescription(i.trim());break;case 11:t.addSection(i.substring(8));break;case 12:n[++e]!==13&&a(e,`'taskData'`),t.addTask(i,r[e]);break;case 1:return;default:a(e,x)}}}var C=10,w=8,T=124,E=200,D=12,ee=6,O=24,k=26,A=11,j=5,te=13,ne=20,M=`<circle cx="-3.6" cy="-2.8" r="1.3"/><circle cx="3.6" cy="-2.8" r="1.3"/>`,N={happy:`M-5,2A6,6 0 0 0 5,2`,neutral:`M-4.5,4.5H4.5`,sad:`M-5,6.5A6,6 0 0 1 5,6.5`};function re(e,t,n){return`<g class="pele-face pele-face-${n}" transform="translate(${c(e)},${c(t)})"><circle r="${A}" fill="var(--_bg)" stroke="var(--_l)"/><g fill="var(--_l)">${M}</g><path d="${N[n]}" fill="none" stroke="var(--_l)" stroke-linecap="round"/></g>`}function P(e,t,n){return d(n,r=>F(e,t,n,r))}function F(e,t,n,d){let f=n.fontSize??16,p=Math.round(f*.875),m=Math.round(f*.75),_=n.measurer??h(n.fontFamily,n.fontFamilyMono),v=n.padding??8;if(d)return ie(e,n);let y=e.tasks,b=y.length,x=g(y).filter(e=>e!==``),S=new Map;x.forEach((e,t)=>S.set(e,t));let M=T,N=y.map(e=>l(e.task,_,p,M)),P=0;for(let e of N)P=Math.max(P,e.width);P>M&&(M=Math.min(Math.ceil(P),E),N=y.map(e=>u(e.task,_,p,M)));let F=M+2*C,I=F+D,L=b>0?b*I-D:0,R=Math.round(p*1.5),ae=Math.max(L,240),z=[],B=0,V=0,H=0;for(let e of x){let t=u(e,_,p,ae-2*j-6),n=2*j+6+t.width;H>0&&H+n>ae&&(H=0,V+=4);let r=H>0?z[z.length-1].y:V,i=Math.max(t.height,R);z.push({name:e,label:t,x:H,y:r,h:i}),H+=n,B=Math.max(B,H),V=Math.max(V,r+i),H+=ne}let U=b>0?O+L:0,W=u(e.title,_,f,Math.max(U,320),1),oe=W.height>0?W.height+16:0,G=Math.max(U,W.width,b>0?O+B:0),K=v+(G-U)/2+O,q=v+oe,se=[],J=0;for(let e=0;e<b;){let t=e+1;for(;t<b&&y[t].section===y[e].section;)t++;let n;y[e].section!==``&&(n=u(y[e].section,_,p,(t-e)*I-D-2*C,1),J=Math.max(J,Math.max(n.height,R)+2*ee)),se.push({start:e,count:t-e,label:n}),e=t}let Y=R;for(let e of N)Y=Math.max(Y,e.height);let ce=x.length>0?2*j+6:0,X=Y+ce+2*w,Z=q+(J>0?J+ee:0),le=Z+X+A+16,ue=le+4*k,de=K+L,Q=``,$=q;if(b>0){let e=``,t=``;for(let n=5;n>=1;n--){let r=le+(5-n)*k;e+=`M${c(K-6)},${c(r)}H${c(de)}`,t+=`<text x="${c(K-12)}" y="${c(r+m*.35)}">${n}</text>`}Q+=`<path class="pele-grid" d="${e}" fill="none" stroke="var(--_a)"/><g class="pele-scale" font-size="${m}" text-anchor="end" fill="var(--_m)">${t}</g>`;let n=``,r=``,l=``,u=[];y.forEach((e,t)=>{let d=K+t*I,f=d+F/2,m=e.score,h=le+(5-(Number.isNaN(m)?3:Math.min(5,Math.max(1,m))))*k;n+=`${t===0?`M`:`L`}${c(f)},${c(h)}`,r+=`M${c(f)},${c(Z+X)}V${c(h-A)}`,l+=re(f,h,m>3?`happy`:m<3?`sad`:`neutral`);let g=``,_=e.people.filter(e=>e!==``),v=Math.min(te,(F-2*C-2*j)/Math.max(_.length-1,1));_.forEach((e,t)=>{g+=`<circle class="pele-actor" cx="${c(f+(t-(_.length-1)/2)*v)}" cy="${c(Z+X-w-j)}" r="${j}" fill="${i(S.get(e)??0)}" stroke="var(--_s)"><title>${a(e)}</title></circle>`}),u.push(`<g class="pele-node pele-task" data-id="${a(e.task.trim())}"><rect x="${c(d)}" y="${c(Z)}" width="${c(F)}" height="${c(X)}" fill="var(--_s)" stroke="var(--_b)"${s}/>`+o(N[t],f,Z+w+Y/2,` font-size="${p}"`)+g+`</g>`)}),Q+=`<path class="pele-stems" d="${r}" fill="none" stroke="var(--_b)" stroke-dasharray="2 3"/>`+(b>1?`<path class="pele-edge" d="${n}" fill="none" stroke="var(--_l)" stroke-linejoin="round"/>`:``)+l;for(let e of se){let t=u.slice(e.start,e.start+e.count).join(``);if(!e.label){Q+=t;continue}let n=K+e.start*I,r=e.count*I-D;Q+=`<g class="pele-cluster pele-section" data-id="${a(y[e.start].section.trim())}"><rect x="${c(n)}" y="${c(q)}" width="${c(r)}" height="${c(J)}" fill="var(--_a)"${s}/>`+o(e.label,n+r/2,q+J/2,` font-size="${p}" font-weight="var(--_hw)"`)+t+`</g>`}if($=ue+A,z.length>0){let e=K+(L-B)/2,t=$+16,n=``;for(let r of z){let s=t+r.y+r.h/2;n+=`<g class="pele-legend-item" data-id="${a(r.name)}"><circle cx="${c(e+r.x+j)}" cy="${c(s)}" r="${j}" fill="${i(S.get(r.name)??0)}"/>`+o(r.label,e+r.x+2*j+6+r.label.width/2,s,``)+`</g>`}Q+=`<g class="pele-legend" font-size="${p}">${n}</g>`,$=t+V}}let fe=Math.ceil(G+2*v),pe=Math.ceil(Math.max($,v)+v),me=o(W,v+G/2,v+W.height/2,` class="pele-title" font-weight="var(--_tw)"`)+Q;return{svg:r(`journey`,fe,pe,f,n,e,me),width:fe,height:pe,links:[]}}function ie(e,t){let n=t.fontSize??16,a=Math.round(n*.875),l=t.measurer??h(t.fontFamily,t.fontFamilyMono),d=t.padding??8,f=Math.max(140,(t.maxWidth??320)-2*d),p=u(e.title,l,n,f,1),m=g(e.tasks).filter(e=>e!==``),_=new Map(m.map((e,t)=>[e,t])),v=d+(p.height?p.height+16:0),y,b=``,x=p.width;e.tasks.forEach((t,r)=>{if(t.section!==y){y=t.section;let e=u(y,l,n,f-16,1);e.height&&(b+=o(e,d+8+e.width/2,v+e.height/2,` class="pele-cluster-label" font-weight="var(--_hw)"`),x=Math.max(x,e.width+16),v+=e.height+8)}let p=u(t.task,l,a,f-72),m=t.people.filter(e=>e!==``).map(e=>({name:e,label:u(e,l,a,f-44)})),h=Math.max(p.height,42),g=2*w+h;for(let e of m)g+=Math.max(16,e.label.height)+4;let S=Math.max(f,p.width+72);b+=`<g class="pele-node pele-journey-step" data-id="${r}"><rect x="${c(d)}" y="${c(v)}" width="${c(S)}" height="${c(g)}" fill="var(--_s)" stroke="var(--_b)"${s}/>`,b+=o(p,d+C+p.width/2,v+w+p.height/2,` class="pele-label"`);let T=d+S-28;b+=re(T,v+w+A,t.score>3?`happy`:t.score<3?`sad`:`neutral`),Number.isNaN(t.score)||(b+=`<text class="pele-journey-score" x="${c(T)}" y="${c(v+w+2*A+a)}" font-size="${a}" text-anchor="middle">${c(Math.min(5,Math.max(1,t.score)))}</text>`);let E=v+w+h+4;for(let e of m){let t=Math.max(16,e.label.height);b+=`<circle class="pele-actor" cx="${c(d+16)}" cy="${c(E+t/2)}" r="${j}" fill="${i(_.get(e.name))}"/>`+o(e.label,d+28+e.label.width/2,E+t/2,` class="pele-journey-actor" font-size="${a}"`),E+=t+4}b+=`</g>`,v+=g,r+1<e.tasks.length&&(b+=`<path class="pele-edge" d="M${c(d+S/2)},${c(v)}v16" fill="none" stroke="var(--_l)"/>`),v+=16,x=Math.max(x,S)});let S=Math.ceil(x+2*d),T=Math.ceil(Math.max(d+p.height,v-(e.tasks.length?16:0))+d),E=o(p,S/2,d+p.height/2,` class="pele-title" font-weight="var(--_tw)"`)+b;return{svg:r(`journey`,S,T,n,t,e,E),width:S,height:T,links:[]}}var I={type:`journey`,parse(e,t,n){let r=new _;return r.title=n,S(e,r),r},render:P};export{I as journey};
@@ -1 +1 @@
1
- import{i as e,o as t,x as n}from"./DfCZPwp1.js";function r(e,t,n=0){return{w:e,h:t,kind:n,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function i(e,t,n=1,r=0,i=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var a=24,o=2e4,s=16,c=8,l=.125,u=3,d=18,f=10,p=14,m=2,h=28,g=12,_=12,v=8,y=4,b=.5,x=.5,S=12,C=40,w=400,T=16,E=new Float64Array(2*T+2),D=new Float64Array(2*T+2);function O(e){return e===1||e===2}function k(e,t,n,r){for(let i=t+1;i<n;i++){let n=e[i],a=r[n],o=i-1;for(;o>=t&&(r[e[o]]>a||r[e[o]]===a&&e[o]>n);)e[o+1]=e[o],o--;e[o+1]=n}}function A(e,t,n,r,i,a){let o=(e,t)=>n[e]<n[t]||n[e]===n[t]&&(i?r[e]>r[t]:r[e]<r[t]);for(let n=0;n<t;n+=8)for(let r=n+1,i=Math.min(t,n+8);r<i;r++){let t=e[r],i=r-1;for(;i>=n&&o(t,e[i]);)e[i+1]=e[i],i--;e[i+1]=t}let s=e,c=a;for(let e=8;e<t;e*=2){for(let n=0;n<t;n+=2*e){let r=Math.min(t,n+e),i=Math.min(t,n+2*e),a=n,l=r,u=n;for(;a<r&&l<i;)c[u++]=o(s[l],s[a])?s[l++]:s[a++];for(;a<r;)c[u++]=s[a++];for(;l<i;)c[u++]=s[l++]}let n=s;s=c,c=n}if(s!==e)for(let n=0;n<t;n++)e[n]=s[n]}function j(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let i=t.length;if(r===1&&i===0&&e[0].kind===0){let t=e[0];return t.rank=0,t.x=t.w/2,t.y=t.h/2,{width:t.w,height:t.h}}let a=1;if(i>0){let e=new Set;for(let n of t){let t=Math.min(n.tail,n.head),i=Math.max(n.tail,n.head),o=t*r+i;if(n.labelW>0||e.has(o)){a=2;break}e.add(o)}}M(e,t),N(e,t,a);let s=new Int32Array(i),c=0;for(let n=0;n<i;n++){let r=t[n];s[n]=Math.abs(e[r.head].rank-e[r.tail].rank),s[n]>1&&(c+=s[n]-1)}let _=new Uint8Array(i);if(c>o){let e=[];for(let t=0;t<i;t++)s[t]>1&&e.push(t);e.sort((e,t)=>s[t]-s[e]||e-t);for(let t of e){if(c<=o)break;_[t]=1,c-=s[t]-1}}let v=r+c,y=new Float64Array(v),b=new Float64Array(v),x=new Uint8Array(v),S=new Int32Array(v),C=0;for(let t=0;t<r;t++){let n=e[t];y[t]=n.w,b[t]=n.h,x[t]=n.kind,S[t]=n.rank,n.rank>C&&(C=n.rank)}let w=0;for(let e=0;e<i;e++)_[e]||(w+=s[e]);let T=new Int32Array(w),E=new Int32Array(w),D=new Float64Array(w),O=new Float64Array(w),k=new Int32Array(i).fill(-1),A=new Uint8Array(C+1),j=new Int32Array(i).fill(-1),P=!1;for(let t=0;t<r;t++)e[t].span>0&&e[t].kind===0&&(P=!0);let I=P?new Uint8Array(w):void 0,R=P?new Uint8Array(w):void 0,B=new Int32Array(i).fill(-1),ce=new Int32Array(i).fill(-1),V=new Float64Array(v).fill(NaN);for(let t=0;t<r;t++)V[t]=e[t].key;let H=!1;{let e=r,n=0;for(let r=0;r<i;r++){if(_[r])continue;let i=t[r],o=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head,c=i.reversed?i.headDx:i.tailDx,l=i.reversed?i.tailDx:i.headDx;(c!==0||l!==0)&&(H=!0);let u=S[o],d=S[s],f=-1;i.labelW>0&&(f=u+(d-u>>1),a===2&&d-u>=4?(f&1)==1&&(f+=i.reversed?1:-1):a===2&&!(f&1)&&(f+=i.reversed?1:-1));let p=o;d-u>1&&(k[r]=e),B[r]=n,I&&!(i.reversed?i.headFixed:i.tailFixed)&&(I[n]=i.reversed?2:1);for(let t=u+1;t<d;t++){let a=e++;S[a]=t,V[a]=V[o]+(V[s]-V[o])*(t-u)/(d-u),t===f?(y[a]=i.labelW,b[a]=i.labelH,x[a]=2,j[r]=a,A[t]|=i.reversed?2:1):x[a]=1,T[n]=p,E[n]=a,D[n]=p===o?c:0,n++,p=a}T[n]=p,E[n]=s,D[n]=p===o?c:0,O[n]=l,R&&!(i.reversed?i.tailFixed:i.headFixed)&&(R[n]=i.reversed?1:2),ce[r]=n,n++}}let le;if(n.groups){let{of:e,parent:a}=n.groups;le=new Int32Array(v);for(let t=0;t<r;t++)le[t]=e[t];let o=e=>{let t=0;for(;e>=0;e=a[e])t++;return t},c=(e,t)=>{let n=o(e),r=o(t);for(;n>r;n--)e=a[e];for(;r>n;r--)t=a[t];for(;e!==t;)e=a[e],t=a[t];return e};for(let n=0;n<i;n++){if(k[n]<0)continue;let r=t[n],i=c(e[r.tail],e[r.head]);for(let e=k[n],t=e+s[n]-1;e<t;e++)le[e]=i}}let U=new Int32Array(v+1),W=new Int32Array(v+1);for(let e=0;e<w;e++)U[T[e]+1]++,W[E[e]+1]++;for(let e=0;e<v;e++)U[e+1]+=U[e],W[e+1]+=W[e];let ue=new Int32Array(w),de=new Int32Array(w);{let e=U.slice(0,v),t=W.slice(0,v);for(let n=0;n<w;n++)ue[e[T[n]]++]=n,de[t[E[n]]++]=n}let G=new Int32Array(C+2);for(let e=0;e<v;e++)G[S[e]+1]++;for(let e=0;e<=C;e++)G[e+1]+=G[e];let K=new Int32Array(v),fe=new Int32Array(v);{let e=new Int32Array(v),t=G.slice(0,C+1);for(let n=0;n<v;n++)e[t[S[n]]++]=n;for(let e=0;e<=C;e++)t[e]=G[e];let n=new Uint8Array(v),r=[];for(let i=0;i<v;i++)if(!n[e[i]])for(r.push(e[i]);r.length>0;){let e=r.pop();if(!n[e]){n[e]=1,K[t[S[e]]++]=e;for(let t=U[e+1]-1;t>=U[e];t--){let e=E[ue[t]];n[e]||r.push(e)}}}}let pe=(e,t)=>{let n=G[e],r=G[e+1];if(r-n<2)return!1;for(let e=n;e<r;e++)if(Number.isNaN(t(K[e])))return!1;let i=Array.from(K.subarray(n,r)),a=new Map;return i.forEach((e,t)=>a.set(e,t)),i.sort((e,n)=>t(e)-t(n)||a.get(e)-a.get(n)),K.set(i,n),!0};for(let e=0;e<=C;e++)pe(e,e=>V[e]);let me=!1;for(let t=0;t<r;t++)e[t].pin!==0&&(me=!0);if(me)for(let t=0;t<=C;t++){let n=Array.from(K.subarray(G[t],G[t+1])),i=new Map;n.forEach((e,t)=>i.set(e,t));let a=t=>t<r?e[t].pin:0;n.sort((e,t)=>a(e)-a(t)||i.get(e)-i.get(t)),K.set(n,G[t])}let he=new Uint8Array(C+1),ge=t=>t<r&&(e[t].kind===3||e[t].kind===4)?e[t].hint:NaN;for(let e of[0,C])pe(e,ge)&&(he[e]=1);let _e=()=>{for(let e=0;e<=C;e++){let t=G[e];for(let n=t,r=G[e+1];n<r;n++)fe[K[n]]=n-t}};_e();let q={n:v,real:r,maxRank:C,W:y,KIND:x,RANK:S,EF:T,ET:E,EFD:D,ETD:O,succStart:U,succE:ue,predStart:W,predE:de,layerStart:G,order:K,pos:fe,offsets:H,fixed:he,GRP:le,groupParent:n.groups?.parent},ve=0,ye=0;if(w>0&&C>0&&([ve,ye]=oe(q,e),_e()),n.orderOnly){let a=se(q,n);for(let t=0;t<r;t++)e[t].x=a[t];for(let e=0;e<i;e++){let n=t[e],r=n.reversed?n.head:n.tail,i=n.reversed?n.tail:n.head,o=[S[r],a[r]];if(!_[e]&&k[e]>=0)for(let t=k[e],n=t+s[e]-1;t<n;t++)o.push(S[t],a[t]);o.push(S[i],a[i]),n.points=o}return{width:0,height:0,crossings:ve,declared:ye}}I&&R&&F(q,e,I,R);let J=se(q,n),Y=re(q);if(I&&R){let r=L(q,I,R);ee(q,e,J,r,n,Y),te(q,e,J,I,R,r,Y),ne(q,J,Y,n);for(let e=0;e<i;e++){if(_[e])continue;let n=t[e],r=D[B[e]],i=O[ce[e]];n.tailDx=n.reversed?i:r,n.headDx=n.reversed?r:i}}let be=new Uint8Array(v);Y&&!n.tracks&&ie(q,J,Y,k,s,n.apart?0:n.edgeSep,be),n.tracks||ae(q,J,k,s,n.edgeSep,be);let xe=new Int32Array(i+1),X=n.tracks||I&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,Se=new Int32Array(C+1);if(X){for(let e=0;e<i;e++){if(xe[e]=X.from.length,_[e])continue;let t=k[e],r=!1;for(let i=t,a=t<0?t:t+s[e]-1;i<a;i++){let e=Y!==void 0&&Y[S[i]]===1;!n.tracks&&e!==(be[i]===1)&&(r=!0)}if(r)continue;let i=J[T[B[e]]]+D[B[e]],a=S[T[B[e]]];for(let n=t,r=t<0?t:t+s[e]-1;n<r;n++)Y&&Y[S[n]]||(X.from.push(i),X.to.push(J[n]),X.rank.push(a),X.lower.push(n),i=J[n],a=S[n]);X.from.push(i),X.to.push(J[E[ce[e]]]+O[ce[e]]),X.rank.push(a),X.lower.push(-1)}xe[i]=X.from.length}let Ce=(e,t)=>{let n=!1;for(let r=G[e];r<G[e+1];r++){let e=x[K[r]];if(e===t)n=!0;else if(e!==1)return!1}return n},we=Ce(0,3)?a:0,Te=Ce(C,4)?a:0,Ee=new Float64Array(C+1);for(let e=0;e<w;e++){let t=Math.abs(J[T[e]]+D[e]-J[E[e]]-O[e]);t>Ee[S[T[e]]]&&(Ee[S[T[e]]]=t)}let Z=new Float64Array(C+1),Q=new Float64Array(C+1),De=e=>(e<we||e>=C-Te?n.portSep:n.rankSep)/a,Oe=new Float64Array(C+1);for(let e=0;e<C;e++)Oe[e]=X?De(e):Math.max(De(e),Math.min(u*n.rankSep/a,Ee[e]*l));let ke=new Uint8Array(C+1).fill(1);for(let e=0;e<r;e++)ke[S[e]]=0;for(let e=1;e<C;e++){if(n.tracks||!ke[e]||A[e]!==1&&A[e]!==2)continue;let t=Math.min((n.headRoom??0)/2,Oe[A[e]===1?e-1:e]/2);Oe[e-1]+=A[e]===1?-t:t,Oe[e]+=A[e]===1?t:-t}let Ae=e=>x[e]===1&&ke[S[e]]&&!n.tracks?(Q[S[e]]-Z[S[e]])/4:0,je=n.tracks?d:h,Me=n.tracks?f:g,Ne=n.tracks?p:g,Pe=new Int32Array(C+1);if(X){let e=new Float64Array(C+1);for(let t=0;t<C;t++){if(Y&&Y[t])continue;let n=t+1;for(e[t]=Oe[t];n<C&&Y&&Y[n];)e[t]+=Oe[n++];Pe[t]=n}for(let t=0;t<X.from.length;t++)X.wide.push(+(Math.abs(X.from[t]-X.to[t])>m*e[X.rank[t]]));let t=new Float64Array(C+1);z(X,Se,!n.tracks,e,t);for(let r=0;r<C;r++)Se[r]>0?Oe[r]+=Math.max(0,2*je+(Se[r]-1)*Me-e[r]):t[r]>0&&(Oe[r]+=Math.max(0,Math.min(u*n.rankSep,t[r])-e[r]))}let Fe=0;for(let e=0;e<=C;e++){let t=0;for(let n=G[e];n<G[e+1];n++)b[K[n]]>t&&(t=b[K[n]]);Z[e]=Fe,Q[e]=Fe+t,Fe+=t+Oe[e]}let Ie=Fe,Le=(e,t=X.track[e])=>{let r=X.rank[e],i=Q[r],a=Z[Pe[r]],o=n.tracks?Se[r]:X.levels[e],s=o>1?Math.min(Ne,(a-i-2*je)/(o-1)):0;return(i+a)/2+(t-(o-1)/2)*s},$=1/0,Re=-1/0;for(let e=0;e<v;e++){let t=y[e]/2;J[e]-t<$&&($=J[e]-t),J[e]+t>Re&&(Re=J[e]+t)}let ze=new Uint8Array(C+1),Be=new Uint8Array(C+1);for(let e=0;e<r;e++)x[e]!==0||!I||(W[e+1]>W[e]&&(ze[S[e]]=1),U[e+1]>U[e]&&(Be[S[e]]=1));for(let t=0;t<r;t++){let n=e[t],r=n.rank;n.x=J[t]-$,n.y=x[t]===0&&Be[r]&&!ze[r]?Q[r]-n.h/2:x[t]===0&&ze[r]&&!Be[r]?Z[r]+n.h/2:(Z[r]+Q[r])/2}for(let r=0;r<i;r++){let i=t[r],a=e[i.reversed?i.head:i.tail],o=e[i.reversed?i.tail:i.head],c=[a.x+(i.reversed?i.headDx:i.tailDx),a.y+a.h/2],l=k[r];if(X&&xe[r+1]>xe[r])for(let e=xe[r];e<xe[r+1];e++){if(X.track[e]>=0&&(n.tracks||X.wide[e]===1)){let t=Le(e);c.push(X.from[e]-$,t,X.to[e]-$,t)}else X.track[e]>0&&c.push(X.from[e]-$,Le(e,X.track[e]-1));let t=X.lower[e];t<0||(c.push(J[t]-$,Z[S[t]]+Ae(t)),Q[S[t]]>Z[S[t]]&&c.push(J[t]-$,Q[S[t]]-Ae(t)))}else if(l>=0)for(let e=l,t=l+s[r]-1;e<t;e++){if(be[e])continue;let t=J[e]-$,n=Z[S[e]],r=Q[S[e]];c.push(t,n+Ae(e)),r>n&&c.push(t,r-Ae(e))}if(c.push(o.x+(i.reversed?i.tailDx:i.headDx),o.y-o.h/2),i.reversed)for(let e=0,t=c.length-2;e<t;e+=2,t-=2){let n=c[e],r=c[e+1];c[e]=c[t],c[e+1]=c[t+1],c[t]=n,c[t+1]=r}i.points=c;let u=j[r];u>=0?(i.labelX=J[u]-$,i.labelY=(Z[S[u]]+Q[S[u]])/2):i.labelW>0&&(i.labelX=(c[0]+c[c.length-2])/2,i.labelY=(c[1]+c[c.length-1])/2)}return{width:Re-$,height:Ie}}function M(e,t){let n=e.length,r=t.length,i=new Int32Array(n+1);for(let n=0;n<r;n++){let r=t[n];r.reversed=e[r.head].kind===3||e[r.tail].kind===4,r.reversed||i[r.tail+1]++}for(let e=0;e<n;e++)i[e+1]+=i[e];let a=new Int32Array(i[n]);{let e=i.slice(0,n);for(let n=0;n<r;n++)t[n].reversed||(a[e[t[n].tail]++]=n)}let o=new Uint8Array(n),s=i.slice(0,n),c=[];for(let e=0;e<n;e++)if(o[e]===0)for(c.push(e),o[e]=1;c.length>0;){let e=c[c.length-1];if(s[e]<i[e+1]){let n=t[a[s[e]++]],r=n.head;o[r]===1?n.reversed=!0:o[r]===0&&(o[r]=1,c.push(r))}else o[e]=2,c.pop()}}function N(e,t,n){let r=e.length,i=t.length,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array(i),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let e=0;e<i;e++){let r=t[e],i=r.reversed?r.head:r.tail,u=r.reversed?r.tail:r.head;a[e]=i,o[e]=u,s[e]=Math.max(1,r.minlen)*n,c[i+1]++,l[u+1]++}for(let e=0;e<r;e++)c[e+1]+=c[e],l[e+1]+=l[e];let u=new Int32Array(i),d=new Int32Array(i);{let e=c.slice(0,r),t=l.slice(0,r);for(let n=0;n<i;n++)u[e[a[n]]++]=n,d[t[o[n]]++]=n}let f=new Int32Array(r),p=new Int32Array(r);for(let e=0;e<r;e++)p[e]=l[e+1]-l[e];let m=new Int32Array(r),h=0;for(let e=0;e<r;e++)p[e]===0&&(m[h++]=e);for(let e=0;e<h;e++){let t=m[e];for(let e=c[t];e<c[t+1];e++){let n=u[e],r=o[n];f[t]+s[n]>f[r]&&(f[r]=f[t]+s[n]),--p[r]===0&&(m[h++]=r)}}for(let e=0;e<8;e++){let e=!1;for(let t=h-1;t>=0;t--){let n=m[t],r=l[n+1]-l[n],i=c[n+1]-c[n];if(r===0&&i===0)continue;let p=-1/0,h=1/0;for(let e=l[n];e<l[n+1];e++){let t=d[e];p=Math.max(p,f[a[t]]+s[t])}for(let e=c[n];e<c[n+1];e++){let t=u[e];h=Math.min(h,f[o[t]]-s[t])}let g=f[n];i>r&&h!==1/0?g=h:r>i&&p!==-1/0&&(g=p),g!==f[n]&&(f[n]=g,e=!0)}if(!e)break}let g=1/0,_=-1/0,v=!1;for(let t=0;t<r;t++){let n=e[t].kind;n===3&&(v=!0),n!==3&&n!==4&&(f[t]<g&&(g=f[t]),f[t]>_&&(_=f[t]))}g===1/0&&(g=0,_=0);for(let t=0;t<r;t++)e[t].kind===3?f[t]=g-n:e[t].kind===4&&(f[t]=_+n);v&&(g-=n);for(let t=0;t<r;t++)e[t].rank=f[t]-g}function P(e,t,n,r,i,a,o){let l=n===0?e.predStart:e.succStart,u=n===0?e.predE:e.succE,d=n===0?e.EF:e.ET,f=e.pos;for(let e=l[t];e<l[t+1];e++)i[u[e]]!==0&&a.push(u[e]);if(a.length<2)return 0;a.sort((e,t)=>f[d[e]]-f[d[t]]||e-t);let p=e=>{let t=0;o[0]=0;for(let n=1;n<a.length;n++){let r=i[a[n]]===i[a[n-1]];o[n]=e(r&&i[a[n]]===1,r),t+=o[n]}return t},m=p(()=>1);if(r/m<c&&(m=p(e=>e?.5:1)),r/m<c&&(m=p((e,t)=>+!t)),m===0)return 0;let h=Math.min(s,r/m);for(let e=1;e<a.length;e++)o[e]*=h;return m*h}function F(e,t,n,r){let{real:i,W:a,EFD:o,ETD:s}=e;for(let c=0;c<i;c++){let i=Math.min(t[c].span,a[c]);if(!(i<=0||t[c].kind!==0))for(let t=0;t<2;t++){let a=[],l=[],u=P(e,c,t,i,t===0?r:n,a,l);if(u===0)continue;let d=t===0?s:o,f=-u/2;for(let e=0;e<a.length;e++)f+=l[e],d[a[e]]=f}}}function I(e,t,n,r){if(!t)return n;let{KIND:i,RANK:a,EF:o,ET:s,succStart:c,succE:l,predStart:u,predE:d}=e;for(let e=0;e<1e5;e++){let e=r===0?o[n]:s[n];if(i[e]!==1||!t[a[e]])break;n=r===0?d[u[e]]:l[c[e]]}return n}function L(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)n[i]!==0&&r[0][e.ET[i]]++,t[i]!==0&&r[1][e.EF[i]]++;return r}function R(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function ee(e,t,n,r,i,a){let o=i.edgeSep,{n:s,real:c,maxRank:l,KIND:u,RANK:d,W:f,EF:p,ET:m,EFD:h,ETD:g,succStart:_,succE:v,predStart:y,predE:b,layerStart:x,order:S,pos:C}=e,w=e=>u[e]===2||u[e]===1&&(a===void 0||a[d[e]]!==1),T=(e,i)=>{let a=i===0?p[e]:m[e];return[i===0?n[a]+h[e]:n[a]+g[e],a<c&&t[a].kind===0?r[1-i][a]:0]},E=e=>{let t=x[d[e]],r=t+C[e],a=t=>f[t]/2+f[e]/2+(u[t]===0?i.nodeSep/2+o/2:u[t]===u[e]?o:o/2);return[r>t?n[S[r-1]]+a(S[r-1]):-1/0,r+1<x[d[e]+1]?n[S[r+1]]-a(S[r+1]):1/0]},D=(e,t,n,r,i)=>{let a=(t[1]===n[1]?Math.abs(t[0]-e)<=Math.abs(n[0]-e):t[1]<n[1])?[t[0],n[0]]:[n[0],t[0]];return a.find(e=>e>=r&&e<=i)??Math.max(r,Math.min(i,a[0]))},k=new Uint8Array(s),A=[];for(let t=1;t<l;t++)for(let r=x[t];r<x[t+1];r++){if(!w(S[r])||k[S[r]])continue;let t=S[r];for(;O(u[p[b[y[t]]]]);)t=p[b[y[t]]];let i=t,o=-1/0,s=1/0;A.length=0;for(let e=t;O(u[e]);e=m[v[_[e]]]){if(i=e,!w(e))continue;k[e]=1,A.push(e);let[t,n]=E(e);t>o&&(o=t),n<s&&(s=n)}if(o<=s){let e=D(n[A[0]],T(b[y[t]],0),T(v[_[i]],1),o,s);for(let t of A)n[t]=e}else for(let t of A){let[r,i]=E(t);r>i||(n[t]=D(n[t],T(I(e,a,b[y[t]],0),0),T(I(e,a,v[_[t]],1),1),r,i))}}}function te(e,t,n,r,i,a,o){let{real:c,W:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,pos:v}=e,y=(s,m,h,g,_)=>{if(a[m][h]<2)return 0;s=I(e,o,s,m);let v=m===0?u[s]:d[s],y=m===0?n[v]+f[s]:n[v]+p[s];if(_&&Math.abs(y-n[h])<=g/2+x)return Math.max(-g/2,Math.min(g/2,y-n[h]));let b=y,S=0;v<c&&t[v].kind===0&&(m===0?r:i)[s]!==0&&a[1-m][v]>=2&&(S=Math.max(0,Math.min(t[v].span,l[v])),S>0&&(b=n[v]));let w=Math.max(n[h]-g/2,b-S/2),T=Math.min(n[h]+g/2,b+S/2);if(w>T+x){let e=Math.max(0,g/2-C);return Math.max(-e,Math.min(e,y-n[h]))}let E=(n[h]*S+b*g)/(S+g);return Math.max(w,Math.min(T,E))-n[h]},b=[];for(let n=0;n<c;n++){let a=Math.min(t[n].span,l[n]);if(!(a<=0||t[n].kind!==0))for(let t=0;t<2;t++){let o=t===0?u:d,s=t===0?g:m,c=t===0?_:h,l=[],f=[];if(P(e,n,t,a,t===0?i:r,l,f),l.length===0)continue;l.length===1&&(f[0]=0);let p=[];for(let e=s[n];e<s[n+1];e++)p.push(c[e]);p.sort((e,t)=>v[o[e]]-v[o[t]]||e-t),b.push({v:n,side:t,span:a,ids:l,room:f,all:p})}}for(let e=0,t=!0;t&&e<6;e++){t=!1;for(let{v:n,side:a,span:o,ids:c,room:l,all:u}of b){let d=a===0?i:r,m=a===0?p:f,h=0,g=-o/2;for(let r=0;r<=u.length;r++){let i=r<u.length&&d[u[r]]===0;if(r<u.length&&!i)continue;let f=0;for(let e=r-1;e>=0&&d[u[e]]!==0;e--)f++;let p=i?m[u[r]]-s:o/2;if(f>0){let r=[],i=[],s=0;for(let t=0;t<f;t++){t>0&&(s+=l[h+t]),r.push(y(c[h+t],a,n,o,e>0)-s),i.push(1);let u=t>0&&l[h+t]===0;for(;r.length>1&&(u||r[r.length-2]/i[i.length-2]>r[r.length-1]/i[i.length-1]);){u=!1;let e=r.pop(),t=i.pop();r[r.length-1]+=e,i[i.length-1]+=t}}let u=s,d=0;s=0;for(let e=0;e<r.length;e++){let n=p-u<g?(g+p-u)/2:Math.max(g,Math.min(p-u,r[e]/i[e]));for(let r=0;r<i[e];r++,d++)d>0&&(s+=l[h+d]),Math.abs(m[c[h+d]]-n-s)>.01&&(t=!0),m[c[h+d]]=n+s}h+=f}i&&(g=m[u[r]]+s)}}}}function ne(e,t,n,r){let{n:i,KIND:a,RANK:o,EF:s,ET:c,EFD:l,ETD:u,layerStart:d,order:f,pos:p}=e,m=e=>n!==void 0&&a[e]===1&&n[o[e]]===1,h=[],g=[],_=[],v=[];for(let t=0;t<s.length;t++){if(m(s[t]))continue;let r=I(e,n,t,1);h.push(s[t]),g.push(c[r]),_.push(l[t]),v.push(u[r])}let y=e=>t[g[e]]+v[e]-t[h[e]]-_[e],b=new Int32Array(i),x=[];for(let e=0;e<i;e++)b[e]=e,x.push([e]);let C=(e,t)=>{let n=b[e],r=b[t];if(n!==r){x[n].length<x[r].length&&([n,r]=[r,n]);for(let e of x[r])b[e]=n,x[n].push(e);x[r]=[]}},w=[];for(let e=0;e<h.length;e++){let t=Math.abs(y(e));t<.01?C(h[e],g[e]):t<=S&&w.push(e)}if(w.length===0)return;w.sort((e,t)=>Math.abs(y(e))-Math.abs(y(t))||e-t);let T=t=>B(e,r,t),E=(e,n)=>{for(let r of x[e]){let i=d[o[r]],a=d[o[r]+1],s=i+p[r];if(s>i&&b[f[s-1]]!==e&&t[r]+n-t[f[s-1]]<T(r)+T(f[s-1])-.01||s+1<a&&b[f[s+1]]!==e&&t[f[s+1]]-t[r]-n<T(r)+T(f[s+1])-.01)return!1}return!0};for(let e of w){let n=y(e);if(Math.abs(n)<.01){C(h[e],g[e]);continue}if(Math.abs(n)>S||b[h[e]]===b[g[e]])continue;let r=b[h[e]],i=b[g[e]],a=x[r].length<=x[i].length?r:i;for(let o of[a,a===r?i:r]){let i=o===r?n:-n;if(E(o,i)){for(let e of x[o])t[e]+=i;C(h[e],g[e]);break}}}}function re(e){let{maxRank:t,KIND:n,layerStart:r,order:i}=e,a=new Uint8Array(t+1),o=!1;for(let e=1;e<t;e++){let t=r[e+1]>r[e];for(let a=r[e];t&&a<r[e+1];a++)n[i[a]]!==1&&(t=!1);t&&(a[e]=1,o=!0)}return o?a:void 0}function z(e,t,n,r,i){let{from:a,to:o,rank:s,track:c,levels:l,wide:u}=e,d=a.length,f=new Map;for(let e=0;e<d;e++){if(c.push(-1),l.push(0),Math.abs(a[e]-o[e])<x)continue;let t=f.get(s[e]);t?t.push(e):f.set(s[e],[e])}if(f.size===0)return;let p=new Float64Array(d),m=new Float64Array(d);for(let e=0;e<d;e++)p[e]=Math.min(a[e],o[e]),m[e]=Math.max(a[e],o[e]);let h=(e,t)=>+(e>=p[t]-x&&e<=m[t]+x),g=(e,t)=>Math.abs(a[e]-a[t])<x||Math.abs(o[e]-o[t])<x,S=(e,t)=>p[e]<m[t]-x&&p[t]<m[e]-x,C=(e,t)=>S(e,t)&&!g(e,t),O=(e,t)=>S(e,t)||h(o[e],t)+h(a[t],e)+h(o[t],e)+h(a[e],t)>0,k=(e,t)=>h(o[e],t)+h(a[t],e),A=e=>{let t=e.map((e,t)=>t).sort((t,n)=>p[e[t]]-p[e[n]]),n=[];for(let r=0;r<t.length;r++){let i=t[r],a=m[e[i]]+4*x;for(let o=r+1;o<t.length&&p[e[t[o]]]<=a;o++){let e=t[o];n.push(Math.min(i,e),Math.max(i,e))}}return n},j=e=>{e.sort((e,t)=>m[t]-p[t]-(m[e]-p[e])||p[e]-p[t]||e-t);let t=e.length,r=[],i=e.map((e,t)=>t),a=e=>{for(;i[e]!==e;)e=i[e]=i[i[e]];return e},o=t<=w,s=o?A(e):[],u=o?e.map(()=>[]):[];for(let t=0;t<s.length;t+=2){let n=s[t],r=s[t+1];C(e[n],e[r])&&(u[n].push(r),u[r].push(n))}let d=e.map((e,t)=>t);if(o){let n=new Int32Array(t),o=[];for(let e=0;e<t;e++)r.push([]),o.push([]);for(let t=0;t<s.length;t+=2){let c=s[t],l=s[t+1],u=e[c],d=e[l];if(!O(u,d))continue;i[a(c)]=a(l);let f=k(u,d),p=k(d,u);if(f===p)continue;let m=f<p?c:l,h=f<p?l:c;r[h].push(m),o[m].push(h),n[h]++}let c=new Uint8Array(t);d=[];for(let e=0;e<t;e++){let e=-1;for(let r=0;r<t&&!(!c[r]&&((e<0||n[r]<n[e])&&(e=r),n[r]===0));r++);c[e]=1,d.push(e);for(let t of o[e])n[t]--}}let f=new Set,h=[],g=0;for(let t of d){let n=e[t],i=0;for(let n of r[t]??[])c[e[n]]>=i&&(i=c[e[n]]+1);if(o){f.clear();for(let n of u[t])f.add(c[e[n]]);for(;f.has(i);)i++}else{for(;h[i]?.some(e=>C(n,e));)i++;(h[i]??=[]).push(n)}c[n]=i,i>=g&&(g=i+1)}let _=new Int32Array(t).fill(g),v=new Int32Array(t).fill(-1);for(let n=0;n<t;n++){let t=a(n);_[t]=Math.min(_[t],c[e[n]]),v[t]=Math.max(v[t],c[e[n]])}for(let r=0;r<t;r++){let t=a(r);l[e[r]]=v[t]-_[t]+1,n&&(c[e[r]]-=_[t])}return g},M=(e,t,n)=>{let r=R(o[e]-a[e],t);for(let i=0;i<=T;i++){let s=i/T,c=1-s;n[2*i]=a[e]+(o[e]-a[e])*s*s*(3-2*s),n[2*i+1]=t*(3*r*s*c*c+3*(1-r)*s*s*c+s*s*s)}},N=(e,t,n)=>{let r=n*n*1.000000001;for(let i=0;i<=T;i++){let a=e[2*i],o=e[2*i+1];for(let e=0;e<T;e++){let i=t[2*e+2]-t[2*e],s=t[2*e+3]-t[2*e+1],c=Math.max(0,Math.min(1,((a-t[2*e])*i+(o-t[2*e+1])*s)/(i*i+s*s||1))),l=a-t[2*e]-c*i,u=o-t[2*e+1]-c*s;if(l*l+u*u<r&&Math.hypot(l,u)<n)return!0}}return!1},P=(e,t,n,r)=>{let i=Math.max(n/2,n-2*_);return M(e,i,E),M(t,i,D),N(E,D,r)||N(D,E,r)};for(let[e,s]of f){if(!n){t[e]=j(s);continue}if(s.length>w)continue;let d=s.filter(e=>u[e]===1);j(d);let f=new Set(d.filter(e=>l[e]>1)),h=A(s);for(let t=0;t<h.length;t+=2){let n=s[h[t]],i=s[h[t+1]];f.has(n)&&f.has(i)||!C(n,i)||a[n]<o[n]!=a[i]<o[i]||P(n,i,r[e],u[n]===1||u[i]===1?v:y)&&f.add(n).add(i)}for(let e of d)c[e]=-1,l[e]=0;if(f.size===0)continue;let _=0,x=0,T=new Set;for(let e=0;e<h.length;e+=2){let t=s[h[e]],n=s[h[e+1]];if(f.has(t)&&f.has(n)){if(!S(t,n))continue;a[t]<o[t]==a[n]<o[n]?g(t,n)||x++:_++}else(f.has(t)||f.has(n))&&O(t,n)&&T.add(t).add(n)}if(_>x){for(let t of s)(m[t]-p[t])*b>i[e]&&(i[e]=(m[t]-p[t])*b);continue}let E=s.filter(e=>f.has(e)||u[e]!==1&&T.has(e));j(E);let D=0;for(let e of E)l[e]>D&&(D=l[e]);t[e]=D}}function ie(e,t,n,r,i,a,o){let{maxRank:s,EF:c,ET:l,EFD:u,ETD:d,succStart:f,succE:p,predStart:m,predE:h,layerStart:g,order:_}=e,v=new Float64Array(t.length),y=new Float64Array(t.length),b=new Float64Array(t.length);for(let a=0;a<r.length;a++){let o=r[a];if(o<0)continue;let s=o+i[a]-1,g=e.RANK[o];for(let e=o;e<s;e++){if(!n[g+e-o])continue;let r=e;for(;r+1<s&&n[g+r+1-o];)r++;let i=h[m[e]],a=p[f[r]],_=t[c[i]]+u[i],x=t[l[a]]+d[a],S=r-e+2;for(let t=e;t<=r;t++)v[t]=_+(x-_)*(t-e+1)/S,y[t]=_,b[t]=x;e=r}}let x=[];for(let r=1;r<s;r++){if(!n[r])continue;let i=g[r],s=g[r+1],c=Array.from(_.subarray(i,s)).sort((e,t)=>y[e]-y[t]||b[e]-b[t]||e-t);for(let n=0;n<c.length;){x.length=0;let r=n;for(;r<c.length&&Math.abs(y[c[r]]-y[c[n]])<1&&Math.abs(b[c[r]]-b[c[n]])<1;r++)x.push(c[r]);x.sort((t,n)=>e.pos[t]-e.pos[n]);for(let e=0;e<x.length;e++){let n=x[e];t[n]=v[n]+(e-(x.length-1)/2)*a,(x.length===1||a===0)&&(o[n]=1)}n=r}}}function ae(e,t,n,r,i,a){let{maxRank:o,W:s,KIND:c,RANK:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,layerStart:v,order:y}=e,b=new Uint8Array(o+1),x=!1;for(let e=1;e<o;e++){let t=!1,n=!1;for(let r=v[e];r<v[e+1];r++){let e=c[y[r]];e===2?t=!0:e!==1&&(n=!0)}t&&!n&&(b[e]=1,x=!0)}if(x)for(let e=0;e<n.length;e++){let o=n[e];if(!(o<0))for(let n=o,x=o+r[e]-1;n<x;n++){if(c[n]!==1||!b[l[n]])continue;let e=n,r=n;for(;e>o&&a[e-1];)e--;for(;r+1<x&&a[r+1];)r++;let S=_[g[e]],C=h[m[r]],w=t[u[S]]+f[S],T=t[d[C]]+p[C],E=Math.min(w,T)-i,D=Math.max(w,T)+i,O=!0,k=l[n];for(let e=v[k];O&&e<v[k+1];e++){let n=y[e];c[n]===2&&t[n]+s[n]/2>E&&t[n]-s[n]/2<D&&(O=!1)}if(!O)continue;a[n]=1;let A=r-e+2;for(let n=e;n<=r;n++)t[n]=w+(T-w)*(n-e+1)/A}}}function oe(e,t){let{n,real:r,maxRank:i,W:o,EF:s,ET:c,EFD:l,ETD:u,succStart:d,succE:f,predStart:p,predE:m,layerStart:h,order:g,pos:_,offsets:v,fixed:y,GRP:b,groupParent:x}=e,S=0;for(let e=0;e<=i;e++)S=Math.max(S,h[e+1]-h[e]);if(S<2)return[0,0];let C=v?new Int32Array(s.length):void 0,w=new Int32Array(C?s.length:0),T=new Int32Array(C?n:0),E=C?f.slice():f,D=new Uint8Array(C?n:0);if(C){let e=m.slice(),t=(e,t,n,r)=>{for(let i=t+1;i<n;i++)if(r[e[i]]!==r[e[t]])return e.subarray(t,n).sort((e,t)=>r[e]-r[t]),!0;return!1};for(let r=0;r<n;r++){if(T[r]=1,t(e,p[r],p[r+1],u))for(let t=p[r]+1;t<p[r+1];t++)u[e[t]]!==u[e[t-1]]&&T[r]++,w[e[t]]=T[r]-1;t(E,d[r],d[r+1],l)&&(D[r]=1)}}let O=1;for(;O<(C?S+s.length:S);)O<<=1;let k=new Int32Array(2*O),j=new Int32Array(s.length),M=()=>{let e=0;for(let t=0;t<i;t++){let n=h[t+2]-h[t+1];if(C){let e=0;for(let n=h[t+1];n<h[t+2];n++){let t=g[n];for(let n=p[t];n<p[t+1];n++)C[m[n]]=e+w[m[n]];e+=T[t]}n=e}if(n<2)continue;let r=0;for(let e=h[t];e<h[t+1];e++){let t=g[e],n=d[t],i=d[t+1],a=r;for(let e=n;e<i;e++)j[r++]=C?C[E[e]]:_[c[f[e]]];let o=r-a;if(!(o<2)){if(C&&D[t])for(let e=a+1;e<r;e++){let t=j[e],r=l[E[n+e-a]],i=e-1;for(;i>=a&&l[E[n+i-a]]===r&&j[i]>t;)j[i+1]=j[i],i--;j[i+1]=t}else if(o<=12)for(let e=a+1;e<r;e++){let t=j[e],n=e-1;for(;n>=a&&j[n]>t;)j[n+1]=j[n],n--;j[n+1]=t}else j.subarray(a,r).sort()}}if(r<2)continue;let i=1;for(;i<n;)i<<=1;k.fill(0,0,2*i);for(let t=0;t<r;t++){let n=j[t]+i;for(k[n]++;n>1;)!(n&1)&&(e+=k[n+1]),n>>=1,k[n]++}}return e},N=M(),P=new Float64Array(n),F=new Int32Array(S),I=new Int32Array(S),L=x?x.length:0,R=new Int32Array(L);for(let e=0;e<L;e++)for(let t=e;t>=0;t=x[t])R[e]++;let ee=new Float64Array(L),te=new Int32Array(L),ne=new Int32Array(L),re=(e,t)=>{let r=h[e],i=h[e+1];for(let e=r;e<i;e++)for(let t=b[g[e]];t>=0;t=x[t])ee[t]=0,te[t]=0;for(let e=r;e<i;e++){let n=g[e];for(let r=b[n];r>=0;r=x[r])te[r]===0&&(ne[r]=e),ee[r]+=t[n],te[r]++}let a=e=>e>=n?ee[e-n]/te[e-n]:t[e],o=e=>e>=n?ne[e-n]:r+_[e],s=Array.from(g.subarray(r,i)).sort((e,t)=>{let r=e,i=t,s=b[e],c=b[t],l=s<0?0:R[s],u=c<0?0:R[c];for(;l>u;l--)r=n+s,s=x[s];for(;u>l;u--)i=n+c,c=x[c];for(;s!==c;)r=n+s,s=x[s],i=n+c,c=x[c];return a(r)-a(i)||o(r)-o(i)});g.set(s,r);for(let e=r;e<i;e++)_[g[e]]=e-r};if(b){let e=new Float64Array(n);for(let t=0;t<=i;t++){for(let n=h[t];n<h[t+1];n++)e[g[n]]=n-h[t];re(t,e)}}let z=b?M():N;if(z===0)return[0,N];let ie=g.slice(),ae=Math.min(z,N),oe=(e,n)=>{let a=e?p:d,x=e?m:f,S=e?s:c,C=e?l:u;for(let s=1;s<=i;s++){let c=e?s:i-s;if(y[c])continue;let l=h[c],u=h[c+1],d=0;for(let n=l;n<u;n++){let i=g[n],s=i<r?t[i].pin:0;if(s!==0){P[i]=s*1e9,F[d++]=i;continue}let f=a[i],p=a[i+1];if(f===p){if(b){let t=e?h[c]-h[c-1]:h[c+2]-h[c+1];P[i]=(n-l)*t/(u-l);continue}P[i]=-1;continue}let m=0;for(let e=f;e<p;e++){let t=S[x[e]];m+=_[t],v&&o[t]>0&&(m+=C[x[e]]/o[t])}P[i]=m/(p-f),F[d++]=i}if(b){re(c,P);continue}if(d<2)continue;A(F,d,P,_,n,I);let f=0;for(let e=l;e<u;e++)P[g[e]]!==-1&&(g[e]=F[f++]);for(let e=l;e<u;e++)_[g[e]]=e-l}},B=()=>{let e=0;for(let t=0;t<=i;t++)for(let n=h[t];n<h[t+1];n++)if(!(g[n]>=r))for(let r=n+1;r<h[t+1];r++)g[r]<g[n]&&e++;return e},se=()=>{for(let e=0;e<=i;e++)for(let t=h[e];t<h[e+1];t++)_[g[t]]=t-h[e]},ce=e=>e<r?t[e].pin:0,V=(e,t)=>{let n=t?s[e]:c[e];return v&&o[n]>0?_[n]+(t?l[e]:u[e])/o[n]:_[n]},H=(e,t)=>{let n=0;for(let r=p[e];r<p[e+1];r++){let e=V(m[r],!0);for(let r=p[t];r<p[t+1];r++)e>V(m[r],!0)&&n++}for(let r=d[e];r<d[e+1];r++){let e=V(f[r],!1);for(let r=d[t];r<d[t+1];r++)e>V(f[r],!1)&&n++}return n},le=()=>{for(let e=0;e<8;e++){let e=!1;for(let t=0;t<=i;t++){if(y[t])continue;let n=h[t];for(let r=n;r+1<h[t+1];r++){let t=g[r],i=g[r+1];ce(t)!==ce(i)||b&&b[t]!==b[i]||H(i,t)>=H(t,i)||(g[r]=i,g[r+1]=t,_[i]=r-n,_[t]=r+1-n,e=!0)}}if(!e)break}},U=g.slice(),W=n<=600,ue=ie,de=1/0;for(let e=0;e<(W?2:1);e++){e>0&&(g.set(U),se());let t=ae,n=U.slice();for(let r=0,i=0;i<4&&r<a;r++,i++){oe((r+e)%2==0,r%4>=2);let a=M();if(a<t&&(t=a,n.set(g),i=0,a===0))break}if(g.set(n),W&&t>0){se(),le();let e=M();e<t&&(t=e,n.set(g))}let r=W?B():0;(e===0||t<z||t===z&&r<de)&&(z=t,ue=n,de=r)}if(g.set(ue),se(),ie.set(ue),b&&(z=M()),!W)return[z,N];for(let e=0;e<r;e++)if(t[e].pin!==0)return[z,N];if(de===0||y[0]||y[i])return[z,N];for(let e=0;e<=i;e++)g.subarray(h[e],h[e+1]).reverse();return se(),(M()>z||B()>=de)&&g.set(ie),[z,N]}function B(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function se(e,t){let{n,maxRank:r,W:i,KIND:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g}=e,_=o.length,v=new Float64Array(n);for(let r=0;r<n;r++)v[r]=B(e,t,r);let y=new Int32Array(_);for(let e=0;e<_;e++)y[e]=g[s[e]];for(let e=0;e<n;e++)u[e+1]-u[e]>1&&k(d,u[e],u[e+1],y);for(let e=0;e<_;e++)y[e]=g[o[e]];for(let e=0;e<n;e++)f[e+1]-f[e]>1&&k(p,f[e],f[e+1],y);let b=new Uint8Array(_);for(let e=1;e<=r;e++){let t=m[e]-m[e-1],n=m[e],r=m[e+1],i=0,s=n;for(let e=n;e<r;e++){let n=h[e],c=-1;if(O(a[n])){let e=o[p[f[n]]];O(a[e])&&(c=e)}let l=c>=0?g[c]:t;if(c>=0||e===r-1){for(let t=s;t<=e;t++){let e=h[t],n=O(a[e]);for(let t=f[e];t<f[e+1];t++){let e=p[t],r=g[o[e]];(r<i||l<r)&&!(n&&O(a[o[e]]))&&(b[e]=1)}}s=e+1,i=l}}}let x=[],S=new Int32Array(n),C=new Int32Array(n),w=new Float64Array(n),T=new Int32Array(n),E=new Int32Array(n),D=new Float64Array(n),A=new Int32Array(n),j=new Int32Array(n+1),M=new Int32Array(n),N=new Int32Array(n),P=new Int32Array(n),F=new Float64Array(n);for(let e=0;e<4;e++){let t=e<2,i=(e&1)==1,a=t?f:u,_=t?p:d,y=t?o:s,O=t?l:c,k=t?c:l;for(let e=0;e<n;e++)S[e]=e,C[e]=e,w[e]=0,A[e]=0,j[e+1]=0,F[e]=0;for(let e=0;e<=r;e++){let n=t?e:r-e,o=m[n],s=m[n+1],c=t?n-1:n+1,l=c>=0&&c<=r?m[c+1]-m[c]-1:0,u=-1;for(let e=i?s-1:o;i?e>=o:e<s;i?e--:e++){let t=h[e],n=a[t],r=a[t+1]-n;if(r===0)continue;let o=n+(r-1>>1),s=n+(r>>1);for(let e=0;e<2&&(e!==1||o!==s);e++){let n=_[e===0===i?s:o],r=y[n],a=i?l-g[r]:g[r];C[t]===t&&u<a&&b[n]===0&&(C[r]=t,C[t]=S[t]=S[r],w[t]=w[r]+k[n]-O[n],u=a)}}}let I=0;for(let e=0;e<=r;e++){let t=m[e],n=m[e+1];for(let e=t+1;e<n;e++){let t=i?h[e]:h[e-1],n=i?h[e-1]:h[e],r=v[t]+v[n];T[I]=S[t],E[I]=S[n],D[I]=i?r-w[t]+w[n]:r+w[t]-w[n],A[S[n]]++,j[S[t]+1]++,I++}}for(let e=0;e<n;e++)j[e+1]+=j[e];for(let e=0;e<n;e++)N[e]=j[e];for(let e=0;e<I;e++)M[N[T[e]]++]=e;let L=0;for(let e=0;e<n;e++)S[e]===e&&A[e]===0&&(P[L++]=e);for(let e=0;e<L;e++){let t=P[e];for(let e=j[t];e<j[t+1];e++){let n=M[e],r=E[n];F[t]+D[n]>F[r]&&(F[r]=F[t]+D[n]),--A[r]===0&&(P[L++]=r)}}for(let e=L-1;e>=0;e--){let t=P[e],n=1/0;for(let e=j[t];e<j[t+1];e++){let t=M[e],r=F[E[t]]-D[t];r<n&&(n=r)}n!==1/0&&n>F[t]&&(F[t]=n)}let R=new Float64Array(n);for(let e=0;e<n;e++)R[e]=(i?-F[S[e]]:F[S[e]])+w[e];x.push(R)}let I=0,L=1/0,R=[],ee=[];for(let e=0;e<4;e++){let t=1/0,r=-1/0,a=x[e];for(let e=0;e<n;e++){let n=i[e]/2;a[e]-n<t&&(t=a[e]-n),a[e]+n>r&&(r=a[e]+n)}R.push(t),ee.push(r),r-t<L&&(L=r-t,I=e)}for(let e=0;e<4;e++){let t=e&1?ee[I]-ee[e]:R[I]-R[e];if(t!==0){let r=x[e];for(let e=0;e<n;e++)r[e]+=t}}let te=new Float64Array(n);for(let e=0;e<n;e++){let t=x[0][e],n=x[1][e],r=x[2][e],i=x[3][e],a;t>n&&(a=t,t=n,n=a),r>i&&(a=r,r=i,i=a),t>r&&(a=t,t=r,r=a),n>i&&(a=n,n=i,i=a),n>r&&(a=n,n=r,r=a),te[e]=(n+r)/2}return te}var ce=12,V=.62,H=6;function le(){let e=new Map;return{add(t,n,r){let i=W(r);n>=0&&i>0&&i+H>(e.get(t*4+n)??0)&&e.set(t*4+n,i+H)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function U(e,t,r,i,a=r>0?r+H:0,o=i>0?i+H:0){let s=t===`linear`,c=t===`step`||t===`stepBefore`||t===`stepAfter`,l=[],u=[],d=[],f=(e,t,n,r)=>Math.abs(e-n)<.01&&Math.abs(t-r)<.01;for(let n=0;n<e.length;n+=3){let r=e[n],i=e[n+1],a=e[n+2],o=l.length-1;if(c&&o>=0&&Math.abs(r-l[o])>=.01&&Math.abs(i-u[o])>=.01){let e=l[o],n=u[o],s=t===`stepBefore`?n:t===`stepAfter`?i:(n+i)/2,c=t===`stepBefore`?e:t===`stepAfter`?r:(e+r)/2,p=a===0?[e,s,r,s]:[c,n,c,i];for(let t=0;t<4;t+=2)f(p[t],p[t+1],e,n)||f(p[t],p[t+1],r,i)||(l.push(p[t]),u.push(p[t+1]),d.push(a))}l.push(r),u.push(i),d.push(a)}let p=l.length-1,m=e=>Math.abs(l[e]-l[e-1])<.01||Math.abs(u[e]-u[e-1])<.01,h=e=>s||m(e),g=(e,t,n)=>{if(!h(Math.max(e,t)))return n===0?[0,Math.sign(u[t]-u[e])||1]:[Math.sign(l[t]-l[e])||1,0];let r=l[t]-l[e],i=u[t]-u[e],a=Math.hypot(r,i)||1;return[r/a,i/a]},[_,v]=g(0,1,d[1]),[y,b]=g(p-1,p,d[p]),x=l[0],S=u[0],C=l[p],w=u[p];l[0]+=_*r,u[0]+=v*r,l[p]-=y*i,u[p]-=b*i;let T=e=>Math.abs(l[e]-l[e-1])+Math.abs(u[e]-u[e-1]),E=e=>!s&&e>0&&e<p&&m(e)&&m(e+1)&&T(e)>=.01&&T(e+1)>=.01&&Math.abs(l[e]-l[e-1])<.01!=Math.abs(l[e+1]-l[e])<.01,D=(e,t,n)=>Math.abs(l[e]-l[e-1])*Math.abs(t)+Math.abs(u[e]-u[e-1])*Math.abs(n),O=(e,t,n)=>{let r=Math.min(Math.max(0,e-H-t),n/4);return r+Math.min(e-t-r,(n-r)/4)},k=o>i&&(!h(p)||E(p-1))?O(o,i,D(p,y,b)):0,A=a>r&&(!h(1)||E(1))?O(a,r,D(1,_,v)):0;k>=1&&(l.splice(p,0,l[p]-y*k),u.splice(p,0,u[p]-b*k),d.splice(p,0,d[p]),p++),A>=1&&(l.splice(1,0,l[0]+_*A),u.splice(1,0,u[0]+v*A),d.splice(1,0,d[1]),p++);let j=`M${n(l[0])},${n(u[0])}`,M=l[0],N=u[0],P=(e,t)=>{f(e,t,M,N)||(j+=`L${n(e)},${n(t)}`,M=e,N=t)};for(let e=1;e<=p;e++){let t=l[e],r=u[e];if(!h(e)){let i=d[e]===0,a=i?r-N:t-M,o=Math.abs(a)*R(i?t-M:r-N,a),s=i?0:Math.sign(a)*o,c=i?Math.sign(a)*o:0;j+=`C${n(M+s)},${n(N+c)} ${n(t-s)},${n(r-c)} ${n(t)},${n(r)}`,M=t,N=r;continue}if(!E(e)){if(e<p&&m(e)&&m(e+1)&&(t-l[e-1])*(l[e+1]-t)+(r-u[e-1])*(u[e+1]-r)>0)continue;P(t,r);continue}let i=E(e-1)?T(e)/2:T(e),a=E(e+1)?T(e+1)/2:T(e+1);c&&(i=a=Math.min(ce,i,a));let[o,s]=g(e-1,e,d[e]),[f,_]=g(e,e+1,d[e+1]);P(t-o*i,r-s*i),M=t+f*a,N=r+_*a,j+=c?`Q${n(t)},${n(r)} ${n(M)},${n(N)}`:`C${n(t-o*i*(1-V))},${n(r-s*i*(1-V))} ${n(t+f*a*(1-V))},${n(r+_*a*(1-V))} ${n(M)},${n(N)}`}return{d:j,sx:x,sy:S,sdx:-_,sdy:-v,ex:C,ey:w,edx:y,edy:b}}function W(e){return e===`arrow_point`?7:e===`arrow_circle`?8:e===`arrow_cross`?4:0}function ue(e,t,r,i,a,o){let s=-a,c=i;if(e===`arrow_point`){let e=t-i*8,l=r-a*8,u=3.36;return`<path class="pele-marker" d="M${n(t)},${n(r)}L${n(e+s*u)},${n(l+c*u)}L${n(e-s*u)},${n(l-c*u)}Z" fill="${o}" stroke="none"/>`}if(e===`arrow_circle`)return`<circle class="pele-marker" cx="${n(t-i*4)}" cy="${n(r-a*4)}" r="3.5" fill="${o}" stroke="none"/>`;if(e===`arrow_cross`){let e=t-i*4,o=r-a*4,l=3.5,u=(i+s)*l,d=(a+c)*l,f=(i-s)*l,p=(a-c)*l;return`<path class="pele-marker" d="M${n(e-u)},${n(o-d)}L${n(e+u)},${n(o+d)}M${n(e-f)},${n(o-p)}L${n(e+f)},${n(o+p)}"/>`}return``}function de(r,i,a,o,s,c){let l=i.width+8,u=i.height;return`<g class="pele-edge-label" data-id="${e(r)}"><rect x="${n(a-l/2)}" y="${n(o-u/2)}" width="${n(l)}" height="${n(u)}" rx="3" fill="var(--_bg)"/>`+t(i,a,o,s,c)+`</g>`}function G(e,t,r,i,a,o,s,c){let l=(a?t:r)/2,u=Math.min(l-4,8+i*6),d=o+i*8,f=Math.hypot(d,u)||1,p=(i,o)=>a?`${n(e.x+o)},${n(e.y+r/2+i)}`:`${n(e.x+t/2+i)},${n(e.y+o)}`,m=d/f*s,h=u/f*s;return a?(c.labelX=e.x,c.labelY=e.y+r/2+d+4+c.labelH/2):(c.labelX=e.x+t/2+d+4+c.labelW/2,c.labelY=e.y),{d:`M${p(0,-u)}C${p(d,-u*2)} ${p(d,u*2)} ${p(m,u+h)}`,sx:a?e.x-u:e.x+t/2,sy:a?e.y+r/2:e.y-u,sdx:a?0:-1,sdy:a?-1:0,ex:a?e.x+u:e.x+t/2,ey:a?e.y+r/2:e.y+u,edx:a?-u/f:-d/f,edy:a?-d/f:-u/f}}export{W as a,j as c,le as d,M as f,de as i,U as l,N as n,r as o,R as r,ue as s,i as t,G as u};
1
+ import{i as e,o as t,x as n}from"./C2npZzkn.js";function r(e,t,n=0){return{w:e,h:t,kind:n,pin:0,hint:NaN,key:NaN,span:0,x:0,y:0,rank:0}}function i(e,t,n=1,r=0,i=0){return{tail:e,head:t,minlen:n,labelW:r,labelH:i,tailDx:0,headDx:0,tailFixed:!1,headFixed:!1,reversed:!1,points:[],labelX:0,labelY:0}}var a=24,o=2e4,s=16,c=8,l=.125,u=3,d=18,f=10,p=14,m=2,h=28,g=12,_=12,v=8,y=4,b=.5,x=.5,S=12,C=40,w=400,T=16,E=new Float64Array(2*T+2),D=new Float64Array(2*T+2);function O(e){return e===1||e===2}function k(e,t,n,r){for(let i=t+1;i<n;i++){let n=e[i],a=r[n],o=i-1;for(;o>=t&&(r[e[o]]>a||r[e[o]]===a&&e[o]>n);)e[o+1]=e[o],o--;e[o+1]=n}}function A(e,t,n,r,i,a){let o=(e,t)=>n[e]<n[t]||n[e]===n[t]&&(i?r[e]>r[t]:r[e]<r[t]);for(let n=0;n<t;n+=8)for(let r=n+1,i=Math.min(t,n+8);r<i;r++){let t=e[r],i=r-1;for(;i>=n&&o(t,e[i]);)e[i+1]=e[i],i--;e[i+1]=t}let s=e,c=a;for(let e=8;e<t;e*=2){for(let n=0;n<t;n+=2*e){let r=Math.min(t,n+e),i=Math.min(t,n+2*e),a=n,l=r,u=n;for(;a<r&&l<i;)c[u++]=o(s[l],s[a])?s[l++]:s[a++];for(;a<r;)c[u++]=s[a++];for(;l<i;)c[u++]=s[l++]}let n=s;s=c,c=n}if(s!==e)for(let n=0;n<t;n++)e[n]=s[n]}function j(e,t,n){let r=e.length;if(r===0)return{width:0,height:0};let i=t.length;if(r===1&&i===0&&e[0].kind===0){let t=e[0];return t.rank=0,t.x=t.w/2,t.y=t.h/2,{width:t.w,height:t.h}}let a=1;if(i>0){let e=new Set;for(let n of t){let t=Math.min(n.tail,n.head),i=Math.max(n.tail,n.head),o=t*r+i;if(n.labelW>0||e.has(o)){a=2;break}e.add(o)}}M(e,t),N(e,t,a);let s=new Int32Array(i),c=0;for(let n=0;n<i;n++){let r=t[n];s[n]=Math.abs(e[r.head].rank-e[r.tail].rank),s[n]>1&&(c+=s[n]-1)}let _=new Uint8Array(i);if(c>o){let e=[];for(let t=0;t<i;t++)s[t]>1&&e.push(t);e.sort((e,t)=>s[t]-s[e]||e-t);for(let t of e){if(c<=o)break;_[t]=1,c-=s[t]-1}}let v=r+c,y=new Float64Array(v),b=new Float64Array(v),x=new Uint8Array(v),S=new Int32Array(v),C=0;for(let t=0;t<r;t++){let n=e[t];y[t]=n.w,b[t]=n.h,x[t]=n.kind,S[t]=n.rank,n.rank>C&&(C=n.rank)}let w=0;for(let e=0;e<i;e++)_[e]||(w+=s[e]);let T=new Int32Array(w),E=new Int32Array(w),D=new Float64Array(w),O=new Float64Array(w),k=new Int32Array(i).fill(-1),A=new Uint8Array(C+1),j=new Int32Array(i).fill(-1),P=!1;for(let t=0;t<r;t++)e[t].span>0&&e[t].kind===0&&(P=!0);let I=P?new Uint8Array(w):void 0,R=P?new Uint8Array(w):void 0,B=new Int32Array(i).fill(-1),ce=new Int32Array(i).fill(-1),V=new Float64Array(v).fill(NaN);for(let t=0;t<r;t++)V[t]=e[t].key;let H=!1;{let e=r,n=0;for(let r=0;r<i;r++){if(_[r])continue;let i=t[r],o=i.reversed?i.head:i.tail,s=i.reversed?i.tail:i.head,c=i.reversed?i.headDx:i.tailDx,l=i.reversed?i.tailDx:i.headDx;(c!==0||l!==0)&&(H=!0);let u=S[o],d=S[s],f=-1;i.labelW>0&&(f=u+(d-u>>1),a===2&&d-u>=4?(f&1)==1&&(f+=i.reversed?1:-1):a===2&&!(f&1)&&(f+=i.reversed?1:-1));let p=o;d-u>1&&(k[r]=e),B[r]=n,I&&!(i.reversed?i.headFixed:i.tailFixed)&&(I[n]=i.reversed?2:1);for(let t=u+1;t<d;t++){let a=e++;S[a]=t,V[a]=V[o]+(V[s]-V[o])*(t-u)/(d-u),t===f?(y[a]=i.labelW,b[a]=i.labelH,x[a]=2,j[r]=a,A[t]|=i.reversed?2:1):x[a]=1,T[n]=p,E[n]=a,D[n]=p===o?c:0,n++,p=a}T[n]=p,E[n]=s,D[n]=p===o?c:0,O[n]=l,R&&!(i.reversed?i.tailFixed:i.headFixed)&&(R[n]=i.reversed?1:2),ce[r]=n,n++}}let le;if(n.groups){let{of:e,parent:a}=n.groups;le=new Int32Array(v);for(let t=0;t<r;t++)le[t]=e[t];let o=e=>{let t=0;for(;e>=0;e=a[e])t++;return t},c=(e,t)=>{let n=o(e),r=o(t);for(;n>r;n--)e=a[e];for(;r>n;r--)t=a[t];for(;e!==t;)e=a[e],t=a[t];return e};for(let n=0;n<i;n++){if(k[n]<0)continue;let r=t[n],i=c(e[r.tail],e[r.head]);for(let e=k[n],t=e+s[n]-1;e<t;e++)le[e]=i}}let U=new Int32Array(v+1),W=new Int32Array(v+1);for(let e=0;e<w;e++)U[T[e]+1]++,W[E[e]+1]++;for(let e=0;e<v;e++)U[e+1]+=U[e],W[e+1]+=W[e];let ue=new Int32Array(w),de=new Int32Array(w);{let e=U.slice(0,v),t=W.slice(0,v);for(let n=0;n<w;n++)ue[e[T[n]]++]=n,de[t[E[n]]++]=n}let G=new Int32Array(C+2);for(let e=0;e<v;e++)G[S[e]+1]++;for(let e=0;e<=C;e++)G[e+1]+=G[e];let K=new Int32Array(v),fe=new Int32Array(v);{let e=new Int32Array(v),t=G.slice(0,C+1);for(let n=0;n<v;n++)e[t[S[n]]++]=n;for(let e=0;e<=C;e++)t[e]=G[e];let n=new Uint8Array(v),r=[];for(let i=0;i<v;i++)if(!n[e[i]])for(r.push(e[i]);r.length>0;){let e=r.pop();if(!n[e]){n[e]=1,K[t[S[e]]++]=e;for(let t=U[e+1]-1;t>=U[e];t--){let e=E[ue[t]];n[e]||r.push(e)}}}}let pe=(e,t)=>{let n=G[e],r=G[e+1];if(r-n<2)return!1;for(let e=n;e<r;e++)if(Number.isNaN(t(K[e])))return!1;let i=Array.from(K.subarray(n,r)),a=new Map;return i.forEach((e,t)=>a.set(e,t)),i.sort((e,n)=>t(e)-t(n)||a.get(e)-a.get(n)),K.set(i,n),!0};for(let e=0;e<=C;e++)pe(e,e=>V[e]);let me=!1;for(let t=0;t<r;t++)e[t].pin!==0&&(me=!0);if(me)for(let t=0;t<=C;t++){let n=Array.from(K.subarray(G[t],G[t+1])),i=new Map;n.forEach((e,t)=>i.set(e,t));let a=t=>t<r?e[t].pin:0;n.sort((e,t)=>a(e)-a(t)||i.get(e)-i.get(t)),K.set(n,G[t])}let he=new Uint8Array(C+1),ge=t=>t<r&&(e[t].kind===3||e[t].kind===4)?e[t].hint:NaN;for(let e of[0,C])pe(e,ge)&&(he[e]=1);let _e=()=>{for(let e=0;e<=C;e++){let t=G[e];for(let n=t,r=G[e+1];n<r;n++)fe[K[n]]=n-t}};_e();let q={n:v,real:r,maxRank:C,W:y,KIND:x,RANK:S,EF:T,ET:E,EFD:D,ETD:O,succStart:U,succE:ue,predStart:W,predE:de,layerStart:G,order:K,pos:fe,offsets:H,fixed:he,GRP:le,groupParent:n.groups?.parent},ve=0,ye=0;if(w>0&&C>0&&([ve,ye]=oe(q,e),_e()),n.orderOnly){let a=se(q,n);for(let t=0;t<r;t++)e[t].x=a[t];for(let e=0;e<i;e++){let n=t[e],r=n.reversed?n.head:n.tail,i=n.reversed?n.tail:n.head,o=[S[r],a[r]];if(!_[e]&&k[e]>=0)for(let t=k[e],n=t+s[e]-1;t<n;t++)o.push(S[t],a[t]);o.push(S[i],a[i]),n.points=o}return{width:0,height:0,crossings:ve,declared:ye}}I&&R&&F(q,e,I,R);let J=se(q,n),Y=re(q);if(I&&R){let r=L(q,I,R);ee(q,e,J,r,n,Y),te(q,e,J,I,R,r,Y),ne(q,J,Y,n);for(let e=0;e<i;e++){if(_[e])continue;let n=t[e],r=D[B[e]],i=O[ce[e]];n.tailDx=n.reversed?i:r,n.headDx=n.reversed?r:i}}let be=new Uint8Array(v);Y&&!n.tracks&&ie(q,J,Y,k,s,n.apart?0:n.edgeSep,be),n.tracks||ae(q,J,k,s,n.edgeSep,be);let xe=new Int32Array(i+1),X=n.tracks||I&&!n.straight?{from:[],to:[],rank:[],lower:[],track:[],levels:[],wide:[]}:void 0,Se=new Int32Array(C+1);if(X){for(let e=0;e<i;e++){if(xe[e]=X.from.length,_[e])continue;let t=k[e],r=!1;for(let i=t,a=t<0?t:t+s[e]-1;i<a;i++){let e=Y!==void 0&&Y[S[i]]===1;!n.tracks&&e!==(be[i]===1)&&(r=!0)}if(r)continue;let i=J[T[B[e]]]+D[B[e]],a=S[T[B[e]]];for(let n=t,r=t<0?t:t+s[e]-1;n<r;n++)Y&&Y[S[n]]||(X.from.push(i),X.to.push(J[n]),X.rank.push(a),X.lower.push(n),i=J[n],a=S[n]);X.from.push(i),X.to.push(J[E[ce[e]]]+O[ce[e]]),X.rank.push(a),X.lower.push(-1)}xe[i]=X.from.length}let Ce=(e,t)=>{let n=!1;for(let r=G[e];r<G[e+1];r++){let e=x[K[r]];if(e===t)n=!0;else if(e!==1)return!1}return n},we=Ce(0,3)?a:0,Te=Ce(C,4)?a:0,Ee=new Float64Array(C+1);for(let e=0;e<w;e++){let t=Math.abs(J[T[e]]+D[e]-J[E[e]]-O[e]);t>Ee[S[T[e]]]&&(Ee[S[T[e]]]=t)}let Z=new Float64Array(C+1),Q=new Float64Array(C+1),De=e=>(e<we||e>=C-Te?n.portSep:n.rankSep)/a,Oe=new Float64Array(C+1);for(let e=0;e<C;e++)Oe[e]=X?De(e):Math.max(De(e),Math.min(u*n.rankSep/a,Ee[e]*l));let ke=new Uint8Array(C+1).fill(1);for(let e=0;e<r;e++)ke[S[e]]=0;for(let e=1;e<C;e++){if(n.tracks||!ke[e]||A[e]!==1&&A[e]!==2)continue;let t=Math.min((n.headRoom??0)/2,Oe[A[e]===1?e-1:e]/2);Oe[e-1]+=A[e]===1?-t:t,Oe[e]+=A[e]===1?t:-t}let Ae=e=>x[e]===1&&ke[S[e]]&&!n.tracks?(Q[S[e]]-Z[S[e]])/4:0,je=n.tracks?d:h,Me=n.tracks?f:g,Ne=n.tracks?p:g,Pe=new Int32Array(C+1);if(X){let e=new Float64Array(C+1);for(let t=0;t<C;t++){if(Y&&Y[t])continue;let n=t+1;for(e[t]=Oe[t];n<C&&Y&&Y[n];)e[t]+=Oe[n++];Pe[t]=n}for(let t=0;t<X.from.length;t++)X.wide.push(+(Math.abs(X.from[t]-X.to[t])>m*e[X.rank[t]]));let t=new Float64Array(C+1);z(X,Se,!n.tracks,e,t);for(let r=0;r<C;r++)Se[r]>0?Oe[r]+=Math.max(0,2*je+(Se[r]-1)*Me-e[r]):t[r]>0&&(Oe[r]+=Math.max(0,Math.min(u*n.rankSep,t[r])-e[r]))}let Fe=0;for(let e=0;e<=C;e++){let t=0;for(let n=G[e];n<G[e+1];n++)b[K[n]]>t&&(t=b[K[n]]);Z[e]=Fe,Q[e]=Fe+t,Fe+=t+Oe[e]}let Ie=Fe,Le=(e,t=X.track[e])=>{let r=X.rank[e],i=Q[r],a=Z[Pe[r]],o=n.tracks?Se[r]:X.levels[e],s=o>1?Math.min(Ne,(a-i-2*je)/(o-1)):0;return(i+a)/2+(t-(o-1)/2)*s},$=1/0,Re=-1/0;for(let e=0;e<v;e++){let t=y[e]/2;J[e]-t<$&&($=J[e]-t),J[e]+t>Re&&(Re=J[e]+t)}let ze=new Uint8Array(C+1),Be=new Uint8Array(C+1);for(let e=0;e<r;e++)x[e]!==0||!I||(W[e+1]>W[e]&&(ze[S[e]]=1),U[e+1]>U[e]&&(Be[S[e]]=1));for(let t=0;t<r;t++){let n=e[t],r=n.rank;n.x=J[t]-$,n.y=x[t]===0&&Be[r]&&!ze[r]?Q[r]-n.h/2:x[t]===0&&ze[r]&&!Be[r]?Z[r]+n.h/2:(Z[r]+Q[r])/2}for(let r=0;r<i;r++){let i=t[r],a=e[i.reversed?i.head:i.tail],o=e[i.reversed?i.tail:i.head],c=[a.x+(i.reversed?i.headDx:i.tailDx),a.y+a.h/2],l=k[r];if(X&&xe[r+1]>xe[r])for(let e=xe[r];e<xe[r+1];e++){if(X.track[e]>=0&&(n.tracks||X.wide[e]===1)){let t=Le(e);c.push(X.from[e]-$,t,X.to[e]-$,t)}else X.track[e]>0&&c.push(X.from[e]-$,Le(e,X.track[e]-1));let t=X.lower[e];t<0||(c.push(J[t]-$,Z[S[t]]+Ae(t)),Q[S[t]]>Z[S[t]]&&c.push(J[t]-$,Q[S[t]]-Ae(t)))}else if(l>=0)for(let e=l,t=l+s[r]-1;e<t;e++){if(be[e])continue;let t=J[e]-$,n=Z[S[e]],r=Q[S[e]];c.push(t,n+Ae(e)),r>n&&c.push(t,r-Ae(e))}if(c.push(o.x+(i.reversed?i.tailDx:i.headDx),o.y-o.h/2),i.reversed)for(let e=0,t=c.length-2;e<t;e+=2,t-=2){let n=c[e],r=c[e+1];c[e]=c[t],c[e+1]=c[t+1],c[t]=n,c[t+1]=r}i.points=c;let u=j[r];u>=0?(i.labelX=J[u]-$,i.labelY=(Z[S[u]]+Q[S[u]])/2):i.labelW>0&&(i.labelX=(c[0]+c[c.length-2])/2,i.labelY=(c[1]+c[c.length-1])/2)}return{width:Re-$,height:Ie}}function M(e,t){let n=e.length,r=t.length,i=new Int32Array(n+1);for(let n=0;n<r;n++){let r=t[n];r.reversed=e[r.head].kind===3||e[r.tail].kind===4,r.reversed||i[r.tail+1]++}for(let e=0;e<n;e++)i[e+1]+=i[e];let a=new Int32Array(i[n]);{let e=i.slice(0,n);for(let n=0;n<r;n++)t[n].reversed||(a[e[t[n].tail]++]=n)}let o=new Uint8Array(n),s=i.slice(0,n),c=[];for(let e=0;e<n;e++)if(o[e]===0)for(c.push(e),o[e]=1;c.length>0;){let e=c[c.length-1];if(s[e]<i[e+1]){let n=t[a[s[e]++]],r=n.head;o[r]===1?n.reversed=!0:o[r]===0&&(o[r]=1,c.push(r))}else o[e]=2,c.pop()}}function N(e,t,n){let r=e.length,i=t.length,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array(i),c=new Int32Array(r+1),l=new Int32Array(r+1);for(let e=0;e<i;e++){let r=t[e],i=r.reversed?r.head:r.tail,u=r.reversed?r.tail:r.head;a[e]=i,o[e]=u,s[e]=Math.max(1,r.minlen)*n,c[i+1]++,l[u+1]++}for(let e=0;e<r;e++)c[e+1]+=c[e],l[e+1]+=l[e];let u=new Int32Array(i),d=new Int32Array(i);{let e=c.slice(0,r),t=l.slice(0,r);for(let n=0;n<i;n++)u[e[a[n]]++]=n,d[t[o[n]]++]=n}let f=new Int32Array(r),p=new Int32Array(r);for(let e=0;e<r;e++)p[e]=l[e+1]-l[e];let m=new Int32Array(r),h=0;for(let e=0;e<r;e++)p[e]===0&&(m[h++]=e);for(let e=0;e<h;e++){let t=m[e];for(let e=c[t];e<c[t+1];e++){let n=u[e],r=o[n];f[t]+s[n]>f[r]&&(f[r]=f[t]+s[n]),--p[r]===0&&(m[h++]=r)}}for(let e=0;e<8;e++){let e=!1;for(let t=h-1;t>=0;t--){let n=m[t],r=l[n+1]-l[n],i=c[n+1]-c[n];if(r===0&&i===0)continue;let p=-1/0,h=1/0;for(let e=l[n];e<l[n+1];e++){let t=d[e];p=Math.max(p,f[a[t]]+s[t])}for(let e=c[n];e<c[n+1];e++){let t=u[e];h=Math.min(h,f[o[t]]-s[t])}let g=f[n];i>r&&h!==1/0?g=h:r>i&&p!==-1/0&&(g=p),g!==f[n]&&(f[n]=g,e=!0)}if(!e)break}let g=1/0,_=-1/0,v=!1;for(let t=0;t<r;t++){let n=e[t].kind;n===3&&(v=!0),n!==3&&n!==4&&(f[t]<g&&(g=f[t]),f[t]>_&&(_=f[t]))}g===1/0&&(g=0,_=0);for(let t=0;t<r;t++)e[t].kind===3?f[t]=g-n:e[t].kind===4&&(f[t]=_+n);v&&(g-=n);for(let t=0;t<r;t++)e[t].rank=f[t]-g}function P(e,t,n,r,i,a,o){let l=n===0?e.predStart:e.succStart,u=n===0?e.predE:e.succE,d=n===0?e.EF:e.ET,f=e.pos;for(let e=l[t];e<l[t+1];e++)i[u[e]]!==0&&a.push(u[e]);if(a.length<2)return 0;a.sort((e,t)=>f[d[e]]-f[d[t]]||e-t);let p=e=>{let t=0;o[0]=0;for(let n=1;n<a.length;n++){let r=i[a[n]]===i[a[n-1]];o[n]=e(r&&i[a[n]]===1,r),t+=o[n]}return t},m=p(()=>1);if(r/m<c&&(m=p(e=>e?.5:1)),r/m<c&&(m=p((e,t)=>+!t)),m===0)return 0;let h=Math.min(s,r/m);for(let e=1;e<a.length;e++)o[e]*=h;return m*h}function F(e,t,n,r){let{real:i,W:a,EFD:o,ETD:s}=e;for(let c=0;c<i;c++){let i=Math.min(t[c].span,a[c]);if(!(i<=0||t[c].kind!==0))for(let t=0;t<2;t++){let a=[],l=[],u=P(e,c,t,i,t===0?r:n,a,l);if(u===0)continue;let d=t===0?s:o,f=-u/2;for(let e=0;e<a.length;e++)f+=l[e],d[a[e]]=f}}}function I(e,t,n,r){if(!t)return n;let{KIND:i,RANK:a,EF:o,ET:s,succStart:c,succE:l,predStart:u,predE:d}=e;for(let e=0;e<1e5;e++){let e=r===0?o[n]:s[n];if(i[e]!==1||!t[a[e]])break;n=r===0?d[u[e]]:l[c[e]]}return n}function L(e,t,n){let r=[new Int32Array(e.n),new Int32Array(e.n)];for(let i=0;i<e.EF.length;i++)n[i]!==0&&r[0][e.ET[i]]++,t[i]!==0&&r[1][e.EF[i]]++;return r}function R(e,t){return Math.max(.25,Math.min(.5,4*Math.abs(t)/(Math.abs(e)||1)))}function ee(e,t,n,r,i,a){let o=i.edgeSep,{n:s,real:c,maxRank:l,KIND:u,RANK:d,W:f,EF:p,ET:m,EFD:h,ETD:g,succStart:_,succE:v,predStart:y,predE:b,layerStart:x,order:S,pos:C}=e,w=e=>u[e]===2||u[e]===1&&(a===void 0||a[d[e]]!==1),T=(e,i)=>{let a=i===0?p[e]:m[e];return[i===0?n[a]+h[e]:n[a]+g[e],a<c&&t[a].kind===0?r[1-i][a]:0]},E=e=>{let t=x[d[e]],r=t+C[e],a=t=>f[t]/2+f[e]/2+(u[t]===0?i.nodeSep/2+o/2:u[t]===u[e]?o:o/2);return[r>t?n[S[r-1]]+a(S[r-1]):-1/0,r+1<x[d[e]+1]?n[S[r+1]]-a(S[r+1]):1/0]},D=(e,t,n,r,i)=>{let a=(t[1]===n[1]?Math.abs(t[0]-e)<=Math.abs(n[0]-e):t[1]<n[1])?[t[0],n[0]]:[n[0],t[0]];return a.find(e=>e>=r&&e<=i)??Math.max(r,Math.min(i,a[0]))},k=new Uint8Array(s),A=[];for(let t=1;t<l;t++)for(let r=x[t];r<x[t+1];r++){if(!w(S[r])||k[S[r]])continue;let t=S[r];for(;O(u[p[b[y[t]]]]);)t=p[b[y[t]]];let i=t,o=-1/0,s=1/0;A.length=0;for(let e=t;O(u[e]);e=m[v[_[e]]]){if(i=e,!w(e))continue;k[e]=1,A.push(e);let[t,n]=E(e);t>o&&(o=t),n<s&&(s=n)}if(o<=s){let e=D(n[A[0]],T(b[y[t]],0),T(v[_[i]],1),o,s);for(let t of A)n[t]=e}else for(let t of A){let[r,i]=E(t);r>i||(n[t]=D(n[t],T(I(e,a,b[y[t]],0),0),T(I(e,a,v[_[t]],1),1),r,i))}}}function te(e,t,n,r,i,a,o){let{real:c,W:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,pos:v}=e,y=(s,m,h,g,_)=>{if(a[m][h]<2)return 0;s=I(e,o,s,m);let v=m===0?u[s]:d[s],y=m===0?n[v]+f[s]:n[v]+p[s];if(_&&Math.abs(y-n[h])<=g/2+x)return Math.max(-g/2,Math.min(g/2,y-n[h]));let b=y,S=0;v<c&&t[v].kind===0&&(m===0?r:i)[s]!==0&&a[1-m][v]>=2&&(S=Math.max(0,Math.min(t[v].span,l[v])),S>0&&(b=n[v]));let w=Math.max(n[h]-g/2,b-S/2),T=Math.min(n[h]+g/2,b+S/2);if(w>T+x){let e=Math.max(0,g/2-C);return Math.max(-e,Math.min(e,y-n[h]))}let E=(n[h]*S+b*g)/(S+g);return Math.max(w,Math.min(T,E))-n[h]},b=[];for(let n=0;n<c;n++){let a=Math.min(t[n].span,l[n]);if(!(a<=0||t[n].kind!==0))for(let t=0;t<2;t++){let o=t===0?u:d,s=t===0?g:m,c=t===0?_:h,l=[],f=[];if(P(e,n,t,a,t===0?i:r,l,f),l.length===0)continue;l.length===1&&(f[0]=0);let p=[];for(let e=s[n];e<s[n+1];e++)p.push(c[e]);p.sort((e,t)=>v[o[e]]-v[o[t]]||e-t),b.push({v:n,side:t,span:a,ids:l,room:f,all:p})}}for(let e=0,t=!0;t&&e<6;e++){t=!1;for(let{v:n,side:a,span:o,ids:c,room:l,all:u}of b){let d=a===0?i:r,m=a===0?p:f,h=0,g=-o/2;for(let r=0;r<=u.length;r++){let i=r<u.length&&d[u[r]]===0;if(r<u.length&&!i)continue;let f=0;for(let e=r-1;e>=0&&d[u[e]]!==0;e--)f++;let p=i?m[u[r]]-s:o/2;if(f>0){let r=[],i=[],s=0;for(let t=0;t<f;t++){t>0&&(s+=l[h+t]),r.push(y(c[h+t],a,n,o,e>0)-s),i.push(1);let u=t>0&&l[h+t]===0;for(;r.length>1&&(u||r[r.length-2]/i[i.length-2]>r[r.length-1]/i[i.length-1]);){u=!1;let e=r.pop(),t=i.pop();r[r.length-1]+=e,i[i.length-1]+=t}}let u=s,d=0;s=0;for(let e=0;e<r.length;e++){let n=p-u<g?(g+p-u)/2:Math.max(g,Math.min(p-u,r[e]/i[e]));for(let r=0;r<i[e];r++,d++)d>0&&(s+=l[h+d]),Math.abs(m[c[h+d]]-n-s)>.01&&(t=!0),m[c[h+d]]=n+s}h+=f}i&&(g=m[u[r]]+s)}}}}function ne(e,t,n,r){let{n:i,KIND:a,RANK:o,EF:s,ET:c,EFD:l,ETD:u,layerStart:d,order:f,pos:p}=e,m=e=>n!==void 0&&a[e]===1&&n[o[e]]===1,h=[],g=[],_=[],v=[];for(let t=0;t<s.length;t++){if(m(s[t]))continue;let r=I(e,n,t,1);h.push(s[t]),g.push(c[r]),_.push(l[t]),v.push(u[r])}let y=e=>t[g[e]]+v[e]-t[h[e]]-_[e],b=new Int32Array(i),x=[];for(let e=0;e<i;e++)b[e]=e,x.push([e]);let C=(e,t)=>{let n=b[e],r=b[t];if(n!==r){x[n].length<x[r].length&&([n,r]=[r,n]);for(let e of x[r])b[e]=n,x[n].push(e);x[r]=[]}},w=[];for(let e=0;e<h.length;e++){let t=Math.abs(y(e));t<.01?C(h[e],g[e]):t<=S&&w.push(e)}if(w.length===0)return;w.sort((e,t)=>Math.abs(y(e))-Math.abs(y(t))||e-t);let T=t=>B(e,r,t),E=(e,n)=>{for(let r of x[e]){let i=d[o[r]],a=d[o[r]+1],s=i+p[r];if(s>i&&b[f[s-1]]!==e&&t[r]+n-t[f[s-1]]<T(r)+T(f[s-1])-.01||s+1<a&&b[f[s+1]]!==e&&t[f[s+1]]-t[r]-n<T(r)+T(f[s+1])-.01)return!1}return!0};for(let e of w){let n=y(e);if(Math.abs(n)<.01){C(h[e],g[e]);continue}if(Math.abs(n)>S||b[h[e]]===b[g[e]])continue;let r=b[h[e]],i=b[g[e]],a=x[r].length<=x[i].length?r:i;for(let o of[a,a===r?i:r]){let i=o===r?n:-n;if(E(o,i)){for(let e of x[o])t[e]+=i;C(h[e],g[e]);break}}}}function re(e){let{maxRank:t,KIND:n,layerStart:r,order:i}=e,a=new Uint8Array(t+1),o=!1;for(let e=1;e<t;e++){let t=r[e+1]>r[e];for(let a=r[e];t&&a<r[e+1];a++)n[i[a]]!==1&&(t=!1);t&&(a[e]=1,o=!0)}return o?a:void 0}function z(e,t,n,r,i){let{from:a,to:o,rank:s,track:c,levels:l,wide:u}=e,d=a.length,f=new Map;for(let e=0;e<d;e++){if(c.push(-1),l.push(0),Math.abs(a[e]-o[e])<x)continue;let t=f.get(s[e]);t?t.push(e):f.set(s[e],[e])}if(f.size===0)return;let p=new Float64Array(d),m=new Float64Array(d);for(let e=0;e<d;e++)p[e]=Math.min(a[e],o[e]),m[e]=Math.max(a[e],o[e]);let h=(e,t)=>+(e>=p[t]-x&&e<=m[t]+x),g=(e,t)=>Math.abs(a[e]-a[t])<x||Math.abs(o[e]-o[t])<x,S=(e,t)=>p[e]<m[t]-x&&p[t]<m[e]-x,C=(e,t)=>S(e,t)&&!g(e,t),O=(e,t)=>S(e,t)||h(o[e],t)+h(a[t],e)+h(o[t],e)+h(a[e],t)>0,k=(e,t)=>h(o[e],t)+h(a[t],e),A=e=>{let t=e.map((e,t)=>t).sort((t,n)=>p[e[t]]-p[e[n]]),n=[];for(let r=0;r<t.length;r++){let i=t[r],a=m[e[i]]+4*x;for(let o=r+1;o<t.length&&p[e[t[o]]]<=a;o++){let e=t[o];n.push(Math.min(i,e),Math.max(i,e))}}return n},j=e=>{e.sort((e,t)=>m[t]-p[t]-(m[e]-p[e])||p[e]-p[t]||e-t);let t=e.length,r=[],i=e.map((e,t)=>t),a=e=>{for(;i[e]!==e;)e=i[e]=i[i[e]];return e},o=t<=w,s=o?A(e):[],u=o?e.map(()=>[]):[];for(let t=0;t<s.length;t+=2){let n=s[t],r=s[t+1];C(e[n],e[r])&&(u[n].push(r),u[r].push(n))}let d=e.map((e,t)=>t);if(o){let n=new Int32Array(t),o=[];for(let e=0;e<t;e++)r.push([]),o.push([]);for(let t=0;t<s.length;t+=2){let c=s[t],l=s[t+1],u=e[c],d=e[l];if(!O(u,d))continue;i[a(c)]=a(l);let f=k(u,d),p=k(d,u);if(f===p)continue;let m=f<p?c:l,h=f<p?l:c;r[h].push(m),o[m].push(h),n[h]++}let c=new Uint8Array(t);d=[];for(let e=0;e<t;e++){let e=-1;for(let r=0;r<t&&!(!c[r]&&((e<0||n[r]<n[e])&&(e=r),n[r]===0));r++);c[e]=1,d.push(e);for(let t of o[e])n[t]--}}let f=new Set,h=[],g=0;for(let t of d){let n=e[t],i=0;for(let n of r[t]??[])c[e[n]]>=i&&(i=c[e[n]]+1);if(o){f.clear();for(let n of u[t])f.add(c[e[n]]);for(;f.has(i);)i++}else{for(;h[i]?.some(e=>C(n,e));)i++;(h[i]??=[]).push(n)}c[n]=i,i>=g&&(g=i+1)}let _=new Int32Array(t).fill(g),v=new Int32Array(t).fill(-1);for(let n=0;n<t;n++){let t=a(n);_[t]=Math.min(_[t],c[e[n]]),v[t]=Math.max(v[t],c[e[n]])}for(let r=0;r<t;r++){let t=a(r);l[e[r]]=v[t]-_[t]+1,n&&(c[e[r]]-=_[t])}return g},M=(e,t,n)=>{let r=R(o[e]-a[e],t);for(let i=0;i<=T;i++){let s=i/T,c=1-s;n[2*i]=a[e]+(o[e]-a[e])*s*s*(3-2*s),n[2*i+1]=t*(3*r*s*c*c+3*(1-r)*s*s*c+s*s*s)}},N=(e,t,n)=>{let r=n*n*1.000000001;for(let i=0;i<=T;i++){let a=e[2*i],o=e[2*i+1];for(let e=0;e<T;e++){let i=t[2*e+2]-t[2*e],s=t[2*e+3]-t[2*e+1],c=Math.max(0,Math.min(1,((a-t[2*e])*i+(o-t[2*e+1])*s)/(i*i+s*s||1))),l=a-t[2*e]-c*i,u=o-t[2*e+1]-c*s;if(l*l+u*u<r&&Math.hypot(l,u)<n)return!0}}return!1},P=(e,t,n,r)=>{let i=Math.max(n/2,n-2*_);return M(e,i,E),M(t,i,D),N(E,D,r)||N(D,E,r)};for(let[e,s]of f){if(!n){t[e]=j(s);continue}if(s.length>w)continue;let d=s.filter(e=>u[e]===1);j(d);let f=new Set(d.filter(e=>l[e]>1)),h=A(s);for(let t=0;t<h.length;t+=2){let n=s[h[t]],i=s[h[t+1]];f.has(n)&&f.has(i)||!C(n,i)||a[n]<o[n]!=a[i]<o[i]||P(n,i,r[e],u[n]===1||u[i]===1?v:y)&&f.add(n).add(i)}for(let e of d)c[e]=-1,l[e]=0;if(f.size===0)continue;let _=0,x=0,T=new Set;for(let e=0;e<h.length;e+=2){let t=s[h[e]],n=s[h[e+1]];if(f.has(t)&&f.has(n)){if(!S(t,n))continue;a[t]<o[t]==a[n]<o[n]?g(t,n)||x++:_++}else(f.has(t)||f.has(n))&&O(t,n)&&T.add(t).add(n)}if(_>x){for(let t of s)(m[t]-p[t])*b>i[e]&&(i[e]=(m[t]-p[t])*b);continue}let E=s.filter(e=>f.has(e)||u[e]!==1&&T.has(e));j(E);let D=0;for(let e of E)l[e]>D&&(D=l[e]);t[e]=D}}function ie(e,t,n,r,i,a,o){let{maxRank:s,EF:c,ET:l,EFD:u,ETD:d,succStart:f,succE:p,predStart:m,predE:h,layerStart:g,order:_}=e,v=new Float64Array(t.length),y=new Float64Array(t.length),b=new Float64Array(t.length);for(let a=0;a<r.length;a++){let o=r[a];if(o<0)continue;let s=o+i[a]-1,g=e.RANK[o];for(let e=o;e<s;e++){if(!n[g+e-o])continue;let r=e;for(;r+1<s&&n[g+r+1-o];)r++;let i=h[m[e]],a=p[f[r]],_=t[c[i]]+u[i],x=t[l[a]]+d[a],S=r-e+2;for(let t=e;t<=r;t++)v[t]=_+(x-_)*(t-e+1)/S,y[t]=_,b[t]=x;e=r}}let x=[];for(let r=1;r<s;r++){if(!n[r])continue;let i=g[r],s=g[r+1],c=Array.from(_.subarray(i,s)).sort((e,t)=>y[e]-y[t]||b[e]-b[t]||e-t);for(let n=0;n<c.length;){x.length=0;let r=n;for(;r<c.length&&Math.abs(y[c[r]]-y[c[n]])<1&&Math.abs(b[c[r]]-b[c[n]])<1;r++)x.push(c[r]);x.sort((t,n)=>e.pos[t]-e.pos[n]);for(let e=0;e<x.length;e++){let n=x[e];t[n]=v[n]+(e-(x.length-1)/2)*a,(x.length===1||a===0)&&(o[n]=1)}n=r}}}function ae(e,t,n,r,i,a){let{maxRank:o,W:s,KIND:c,RANK:l,EF:u,ET:d,EFD:f,ETD:p,succStart:m,succE:h,predStart:g,predE:_,layerStart:v,order:y}=e,b=new Uint8Array(o+1),x=!1;for(let e=1;e<o;e++){let t=!1,n=!1;for(let r=v[e];r<v[e+1];r++){let e=c[y[r]];e===2?t=!0:e!==1&&(n=!0)}t&&!n&&(b[e]=1,x=!0)}if(x)for(let e=0;e<n.length;e++){let o=n[e];if(!(o<0))for(let n=o,x=o+r[e]-1;n<x;n++){if(c[n]!==1||!b[l[n]])continue;let e=n,r=n;for(;e>o&&a[e-1];)e--;for(;r+1<x&&a[r+1];)r++;let S=_[g[e]],C=h[m[r]],w=t[u[S]]+f[S],T=t[d[C]]+p[C],E=Math.min(w,T)-i,D=Math.max(w,T)+i,O=!0,k=l[n];for(let e=v[k];O&&e<v[k+1];e++){let n=y[e];c[n]===2&&t[n]+s[n]/2>E&&t[n]-s[n]/2<D&&(O=!1)}if(!O)continue;a[n]=1;let A=r-e+2;for(let n=e;n<=r;n++)t[n]=w+(T-w)*(n-e+1)/A}}}function oe(e,t){let{n,real:r,maxRank:i,W:o,EF:s,ET:c,EFD:l,ETD:u,succStart:d,succE:f,predStart:p,predE:m,layerStart:h,order:g,pos:_,offsets:v,fixed:y,GRP:b,groupParent:x}=e,S=0;for(let e=0;e<=i;e++)S=Math.max(S,h[e+1]-h[e]);if(S<2)return[0,0];let C=v?new Int32Array(s.length):void 0,w=new Int32Array(C?s.length:0),T=new Int32Array(C?n:0),E=C?f.slice():f,D=new Uint8Array(C?n:0);if(C){let e=m.slice(),t=(e,t,n,r)=>{for(let i=t+1;i<n;i++)if(r[e[i]]!==r[e[t]])return e.subarray(t,n).sort((e,t)=>r[e]-r[t]),!0;return!1};for(let r=0;r<n;r++){if(T[r]=1,t(e,p[r],p[r+1],u))for(let t=p[r]+1;t<p[r+1];t++)u[e[t]]!==u[e[t-1]]&&T[r]++,w[e[t]]=T[r]-1;t(E,d[r],d[r+1],l)&&(D[r]=1)}}let O=1;for(;O<(C?S+s.length:S);)O<<=1;let k=new Int32Array(2*O),j=new Int32Array(s.length),M=()=>{let e=0;for(let t=0;t<i;t++){let n=h[t+2]-h[t+1];if(C){let e=0;for(let n=h[t+1];n<h[t+2];n++){let t=g[n];for(let n=p[t];n<p[t+1];n++)C[m[n]]=e+w[m[n]];e+=T[t]}n=e}if(n<2)continue;let r=0;for(let e=h[t];e<h[t+1];e++){let t=g[e],n=d[t],i=d[t+1],a=r;for(let e=n;e<i;e++)j[r++]=C?C[E[e]]:_[c[f[e]]];let o=r-a;if(!(o<2)){if(C&&D[t])for(let e=a+1;e<r;e++){let t=j[e],r=l[E[n+e-a]],i=e-1;for(;i>=a&&l[E[n+i-a]]===r&&j[i]>t;)j[i+1]=j[i],i--;j[i+1]=t}else if(o<=12)for(let e=a+1;e<r;e++){let t=j[e],n=e-1;for(;n>=a&&j[n]>t;)j[n+1]=j[n],n--;j[n+1]=t}else j.subarray(a,r).sort()}}if(r<2)continue;let i=1;for(;i<n;)i<<=1;k.fill(0,0,2*i);for(let t=0;t<r;t++){let n=j[t]+i;for(k[n]++;n>1;)!(n&1)&&(e+=k[n+1]),n>>=1,k[n]++}}return e},N=M(),P=new Float64Array(n),F=new Int32Array(S),I=new Int32Array(S),L=x?x.length:0,R=new Int32Array(L);for(let e=0;e<L;e++)for(let t=e;t>=0;t=x[t])R[e]++;let ee=new Float64Array(L),te=new Int32Array(L),ne=new Int32Array(L),re=(e,t)=>{let r=h[e],i=h[e+1];for(let e=r;e<i;e++)for(let t=b[g[e]];t>=0;t=x[t])ee[t]=0,te[t]=0;for(let e=r;e<i;e++){let n=g[e];for(let r=b[n];r>=0;r=x[r])te[r]===0&&(ne[r]=e),ee[r]+=t[n],te[r]++}let a=e=>e>=n?ee[e-n]/te[e-n]:t[e],o=e=>e>=n?ne[e-n]:r+_[e],s=Array.from(g.subarray(r,i)).sort((e,t)=>{let r=e,i=t,s=b[e],c=b[t],l=s<0?0:R[s],u=c<0?0:R[c];for(;l>u;l--)r=n+s,s=x[s];for(;u>l;u--)i=n+c,c=x[c];for(;s!==c;)r=n+s,s=x[s],i=n+c,c=x[c];return a(r)-a(i)||o(r)-o(i)});g.set(s,r);for(let e=r;e<i;e++)_[g[e]]=e-r};if(b){let e=new Float64Array(n);for(let t=0;t<=i;t++){for(let n=h[t];n<h[t+1];n++)e[g[n]]=n-h[t];re(t,e)}}let z=b?M():N;if(z===0)return[0,N];let ie=g.slice(),ae=Math.min(z,N),oe=(e,n)=>{let a=e?p:d,x=e?m:f,S=e?s:c,C=e?l:u;for(let s=1;s<=i;s++){let c=e?s:i-s;if(y[c])continue;let l=h[c],u=h[c+1],d=0;for(let n=l;n<u;n++){let i=g[n],s=i<r?t[i].pin:0;if(s!==0){P[i]=s*1e9,F[d++]=i;continue}let f=a[i],p=a[i+1];if(f===p){if(b){let t=e?h[c]-h[c-1]:h[c+2]-h[c+1];P[i]=(n-l)*t/(u-l);continue}P[i]=-1;continue}let m=0;for(let e=f;e<p;e++){let t=S[x[e]];m+=_[t],v&&o[t]>0&&(m+=C[x[e]]/o[t])}P[i]=m/(p-f),F[d++]=i}if(b){re(c,P);continue}if(d<2)continue;A(F,d,P,_,n,I);let f=0;for(let e=l;e<u;e++)P[g[e]]!==-1&&(g[e]=F[f++]);for(let e=l;e<u;e++)_[g[e]]=e-l}},B=()=>{let e=0;for(let t=0;t<=i;t++)for(let n=h[t];n<h[t+1];n++)if(!(g[n]>=r))for(let r=n+1;r<h[t+1];r++)g[r]<g[n]&&e++;return e},se=()=>{for(let e=0;e<=i;e++)for(let t=h[e];t<h[e+1];t++)_[g[t]]=t-h[e]},ce=e=>e<r?t[e].pin:0,V=(e,t)=>{let n=t?s[e]:c[e];return v&&o[n]>0?_[n]+(t?l[e]:u[e])/o[n]:_[n]},H=(e,t)=>{let n=0;for(let r=p[e];r<p[e+1];r++){let e=V(m[r],!0);for(let r=p[t];r<p[t+1];r++)e>V(m[r],!0)&&n++}for(let r=d[e];r<d[e+1];r++){let e=V(f[r],!1);for(let r=d[t];r<d[t+1];r++)e>V(f[r],!1)&&n++}return n},le=()=>{for(let e=0;e<8;e++){let e=!1;for(let t=0;t<=i;t++){if(y[t])continue;let n=h[t];for(let r=n;r+1<h[t+1];r++){let t=g[r],i=g[r+1];ce(t)!==ce(i)||b&&b[t]!==b[i]||H(i,t)>=H(t,i)||(g[r]=i,g[r+1]=t,_[i]=r-n,_[t]=r+1-n,e=!0)}}if(!e)break}},U=g.slice(),W=n<=600,ue=ie,de=1/0;for(let e=0;e<(W?2:1);e++){e>0&&(g.set(U),se());let t=ae,n=U.slice();for(let r=0,i=0;i<4&&r<a;r++,i++){oe((r+e)%2==0,r%4>=2);let a=M();if(a<t&&(t=a,n.set(g),i=0,a===0))break}if(g.set(n),W&&t>0){se(),le();let e=M();e<t&&(t=e,n.set(g))}let r=W?B():0;(e===0||t<z||t===z&&r<de)&&(z=t,ue=n,de=r)}if(g.set(ue),se(),ie.set(ue),b&&(z=M()),!W)return[z,N];for(let e=0;e<r;e++)if(t[e].pin!==0)return[z,N];if(de===0||y[0]||y[i])return[z,N];for(let e=0;e<=i;e++)g.subarray(h[e],h[e+1]).reverse();return se(),(M()>z||B()>=de)&&g.set(ie),[z,N]}function B(e,t,n){return e.W[n]/2+(e.KIND[n]===0?t.nodeSep:t.edgeSep)/2}function se(e,t){let{n,maxRank:r,W:i,KIND:a,EF:o,ET:s,EFD:c,ETD:l,succStart:u,succE:d,predStart:f,predE:p,layerStart:m,order:h,pos:g}=e,_=o.length,v=new Float64Array(n);for(let r=0;r<n;r++)v[r]=B(e,t,r);let y=new Int32Array(_);for(let e=0;e<_;e++)y[e]=g[s[e]];for(let e=0;e<n;e++)u[e+1]-u[e]>1&&k(d,u[e],u[e+1],y);for(let e=0;e<_;e++)y[e]=g[o[e]];for(let e=0;e<n;e++)f[e+1]-f[e]>1&&k(p,f[e],f[e+1],y);let b=new Uint8Array(_);for(let e=1;e<=r;e++){let t=m[e]-m[e-1],n=m[e],r=m[e+1],i=0,s=n;for(let e=n;e<r;e++){let n=h[e],c=-1;if(O(a[n])){let e=o[p[f[n]]];O(a[e])&&(c=e)}let l=c>=0?g[c]:t;if(c>=0||e===r-1){for(let t=s;t<=e;t++){let e=h[t],n=O(a[e]);for(let t=f[e];t<f[e+1];t++){let e=p[t],r=g[o[e]];(r<i||l<r)&&!(n&&O(a[o[e]]))&&(b[e]=1)}}s=e+1,i=l}}}let x=[],S=new Int32Array(n),C=new Int32Array(n),w=new Float64Array(n),T=new Int32Array(n),E=new Int32Array(n),D=new Float64Array(n),A=new Int32Array(n),j=new Int32Array(n+1),M=new Int32Array(n),N=new Int32Array(n),P=new Int32Array(n),F=new Float64Array(n);for(let e=0;e<4;e++){let t=e<2,i=(e&1)==1,a=t?f:u,_=t?p:d,y=t?o:s,O=t?l:c,k=t?c:l;for(let e=0;e<n;e++)S[e]=e,C[e]=e,w[e]=0,A[e]=0,j[e+1]=0,F[e]=0;for(let e=0;e<=r;e++){let n=t?e:r-e,o=m[n],s=m[n+1],c=t?n-1:n+1,l=c>=0&&c<=r?m[c+1]-m[c]-1:0,u=-1;for(let e=i?s-1:o;i?e>=o:e<s;i?e--:e++){let t=h[e],n=a[t],r=a[t+1]-n;if(r===0)continue;let o=n+(r-1>>1),s=n+(r>>1);for(let e=0;e<2&&(e!==1||o!==s);e++){let n=_[e===0===i?s:o],r=y[n],a=i?l-g[r]:g[r];C[t]===t&&u<a&&b[n]===0&&(C[r]=t,C[t]=S[t]=S[r],w[t]=w[r]+k[n]-O[n],u=a)}}}let I=0;for(let e=0;e<=r;e++){let t=m[e],n=m[e+1];for(let e=t+1;e<n;e++){let t=i?h[e]:h[e-1],n=i?h[e-1]:h[e],r=v[t]+v[n];T[I]=S[t],E[I]=S[n],D[I]=i?r-w[t]+w[n]:r+w[t]-w[n],A[S[n]]++,j[S[t]+1]++,I++}}for(let e=0;e<n;e++)j[e+1]+=j[e];for(let e=0;e<n;e++)N[e]=j[e];for(let e=0;e<I;e++)M[N[T[e]]++]=e;let L=0;for(let e=0;e<n;e++)S[e]===e&&A[e]===0&&(P[L++]=e);for(let e=0;e<L;e++){let t=P[e];for(let e=j[t];e<j[t+1];e++){let n=M[e],r=E[n];F[t]+D[n]>F[r]&&(F[r]=F[t]+D[n]),--A[r]===0&&(P[L++]=r)}}for(let e=L-1;e>=0;e--){let t=P[e],n=1/0;for(let e=j[t];e<j[t+1];e++){let t=M[e],r=F[E[t]]-D[t];r<n&&(n=r)}n!==1/0&&n>F[t]&&(F[t]=n)}let R=new Float64Array(n);for(let e=0;e<n;e++)R[e]=(i?-F[S[e]]:F[S[e]])+w[e];x.push(R)}let I=0,L=1/0,R=[],ee=[];for(let e=0;e<4;e++){let t=1/0,r=-1/0,a=x[e];for(let e=0;e<n;e++){let n=i[e]/2;a[e]-n<t&&(t=a[e]-n),a[e]+n>r&&(r=a[e]+n)}R.push(t),ee.push(r),r-t<L&&(L=r-t,I=e)}for(let e=0;e<4;e++){let t=e&1?ee[I]-ee[e]:R[I]-R[e];if(t!==0){let r=x[e];for(let e=0;e<n;e++)r[e]+=t}}let te=new Float64Array(n);for(let e=0;e<n;e++){let t=x[0][e],n=x[1][e],r=x[2][e],i=x[3][e],a;t>n&&(a=t,t=n,n=a),r>i&&(a=r,r=i,i=a),t>r&&(a=t,t=r,r=a),n>i&&(a=n,n=i,i=a),n>r&&(a=n,n=r,r=a),te[e]=(n+r)/2}return te}var ce=12,V=.62,H=6;function le(){let e=new Map;return{add(t,n,r){let i=W(r);n>=0&&i>0&&i+H>(e.get(t*4+n)??0)&&e.set(t*4+n,i+H)},of:(t,n)=>n>=0?e.get(t*4+n)??0:0}}function U(e,t,r,i,a=r>0?r+H:0,o=i>0?i+H:0){let s=t===`linear`,c=t===`step`||t===`stepBefore`||t===`stepAfter`,l=[],u=[],d=[],f=(e,t,n,r)=>Math.abs(e-n)<.01&&Math.abs(t-r)<.01;for(let n=0;n<e.length;n+=3){let r=e[n],i=e[n+1],a=e[n+2],o=l.length-1;if(c&&o>=0&&Math.abs(r-l[o])>=.01&&Math.abs(i-u[o])>=.01){let e=l[o],n=u[o],s=t===`stepBefore`?n:t===`stepAfter`?i:(n+i)/2,c=t===`stepBefore`?e:t===`stepAfter`?r:(e+r)/2,p=a===0?[e,s,r,s]:[c,n,c,i];for(let t=0;t<4;t+=2)f(p[t],p[t+1],e,n)||f(p[t],p[t+1],r,i)||(l.push(p[t]),u.push(p[t+1]),d.push(a))}l.push(r),u.push(i),d.push(a)}let p=l.length-1,m=e=>Math.abs(l[e]-l[e-1])<.01||Math.abs(u[e]-u[e-1])<.01,h=e=>s||m(e),g=(e,t,n)=>{if(!h(Math.max(e,t)))return n===0?[0,Math.sign(u[t]-u[e])||1]:[Math.sign(l[t]-l[e])||1,0];let r=l[t]-l[e],i=u[t]-u[e],a=Math.hypot(r,i)||1;return[r/a,i/a]},[_,v]=g(0,1,d[1]),[y,b]=g(p-1,p,d[p]),x=l[0],S=u[0],C=l[p],w=u[p];l[0]+=_*r,u[0]+=v*r,l[p]-=y*i,u[p]-=b*i;let T=e=>Math.abs(l[e]-l[e-1])+Math.abs(u[e]-u[e-1]),E=e=>!s&&e>0&&e<p&&m(e)&&m(e+1)&&T(e)>=.01&&T(e+1)>=.01&&Math.abs(l[e]-l[e-1])<.01!=Math.abs(l[e+1]-l[e])<.01,D=(e,t,n)=>Math.abs(l[e]-l[e-1])*Math.abs(t)+Math.abs(u[e]-u[e-1])*Math.abs(n),O=(e,t,n)=>{let r=Math.min(Math.max(0,e-H-t),n/4);return r+Math.min(e-t-r,(n-r)/4)},k=o>i&&(!h(p)||E(p-1))?O(o,i,D(p,y,b)):0,A=a>r&&(!h(1)||E(1))?O(a,r,D(1,_,v)):0;k>=1&&(l.splice(p,0,l[p]-y*k),u.splice(p,0,u[p]-b*k),d.splice(p,0,d[p]),p++),A>=1&&(l.splice(1,0,l[0]+_*A),u.splice(1,0,u[0]+v*A),d.splice(1,0,d[1]),p++);let j=`M${n(l[0])},${n(u[0])}`,M=l[0],N=u[0],P=(e,t)=>{f(e,t,M,N)||(j+=`L${n(e)},${n(t)}`,M=e,N=t)};for(let e=1;e<=p;e++){let t=l[e],r=u[e];if(!h(e)){let i=d[e]===0,a=i?r-N:t-M,o=Math.abs(a)*R(i?t-M:r-N,a),s=i?0:Math.sign(a)*o,c=i?Math.sign(a)*o:0;j+=`C${n(M+s)},${n(N+c)} ${n(t-s)},${n(r-c)} ${n(t)},${n(r)}`,M=t,N=r;continue}if(!E(e)){if(e<p&&m(e)&&m(e+1)&&(t-l[e-1])*(l[e+1]-t)+(r-u[e-1])*(u[e+1]-r)>0)continue;P(t,r);continue}let i=E(e-1)?T(e)/2:T(e),a=E(e+1)?T(e+1)/2:T(e+1);c&&(i=a=Math.min(ce,i,a));let[o,s]=g(e-1,e,d[e]),[f,_]=g(e,e+1,d[e+1]);P(t-o*i,r-s*i),M=t+f*a,N=r+_*a,j+=c?`Q${n(t)},${n(r)} ${n(M)},${n(N)}`:`C${n(t-o*i*(1-V))},${n(r-s*i*(1-V))} ${n(t+f*a*(1-V))},${n(r+_*a*(1-V))} ${n(M)},${n(N)}`}return{d:j,sx:x,sy:S,sdx:-_,sdy:-v,ex:C,ey:w,edx:y,edy:b}}function W(e){return e===`arrow_point`?7:e===`arrow_circle`?8:e===`arrow_cross`?4:0}function ue(e,t,r,i,a,o){let s=-a,c=i;if(e===`arrow_point`){let e=t-i*8,l=r-a*8,u=3.36;return`<path class="pele-marker" d="M${n(t)},${n(r)}L${n(e+s*u)},${n(l+c*u)}L${n(e-s*u)},${n(l-c*u)}Z" fill="${o}" stroke="none"/>`}if(e===`arrow_circle`)return`<circle class="pele-marker" cx="${n(t-i*4)}" cy="${n(r-a*4)}" r="3.5" fill="${o}" stroke="none"/>`;if(e===`arrow_cross`){let e=t-i*4,o=r-a*4,l=3.5,u=(i+s)*l,d=(a+c)*l,f=(i-s)*l,p=(a-c)*l;return`<path class="pele-marker" d="M${n(e-u)},${n(o-d)}L${n(e+u)},${n(o+d)}M${n(e-f)},${n(o-p)}L${n(e+f)},${n(o+p)}"/>`}return``}function de(r,i,a,o,s,c){let l=i.width+8,u=i.height;return`<g class="pele-edge-label" data-id="${e(r)}"><rect x="${n(a-l/2)}" y="${n(o-u/2)}" width="${n(l)}" height="${n(u)}" rx="3" fill="var(--_bg)"/>`+t(i,a,o,s,c)+`</g>`}function G(e,t,r,i,a,o,s,c){let l=(a?t:r)/2,u=Math.min(l-4,8+i*6),d=o+i*8,f=Math.hypot(d,u)||1,p=(i,o)=>a?`${n(e.x+o)},${n(e.y+r/2+i)}`:`${n(e.x+t/2+i)},${n(e.y+o)}`,m=d/f*s,h=u/f*s;return a?(c.labelX=e.x,c.labelY=e.y+r/2+d+4+c.labelH/2):(c.labelX=e.x+t/2+d+4+c.labelW/2,c.labelY=e.y),{d:`M${p(0,-u)}C${p(d,-u*2)} ${p(d,u*2)} ${p(m,u+h)}`,sx:a?e.x-u:e.x+t/2,sy:a?e.y+r/2:e.y-u,sdx:a?0:-1,sdy:a?-1:0,ex:a?e.x+u:e.x+t/2,ey:a?e.y+r/2:e.y+u,edx:a?-u/f:-d/f,edy:a?-d/f:-u/f}}export{W as a,j as c,le as d,M as f,de as i,U as l,N as n,r as o,R as r,ue as s,i as t,G as u};
@@ -1,2 +1,2 @@
1
- import{i as e,n as t,r as n,t as r}from"./Czz9qOh8.js";import{_ as i,d as a,f as o,i as s,o as c,x as l}from"./DfCZPwp1.js";import{n as u,t as d}from"./BymwHy7o.js";import{t as f}from"./DciMwFJ1.js";import{s as p}from"./BLmF1B2i.js";import{PeleError as m,g as h,h as g,s as _,u as ee}from"./-2Meesge.js";var v=class{type=`timeline`;title;accTitle;accDescr;direction=`LR`;sections=[];periods=[];currentSection=``;getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
1
+ import{i as e,n as t,r as n,t as r}from"./CT4_O9X_.js";import{_ as i,d as a,f as o,i as s,o as c,x as l}from"./C2npZzkn.js";import{n as u,t as d}from"./CtkUy_15.js";import{t as f}from"./DciMwFJ1.js";import{s as p}from"./BXBhaEho.js";import{PeleError as m,g as h,h as g,s as _,u as ee}from"./CMikI1NP.js";var v=class{type=`timeline`;title;accTitle;accDescr;direction=`LR`;sections=[];periods=[];currentSection=``;getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
2
2
  `)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,n){this.periods.push({text:e,events:n?[n]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new m(`An event needs a time period before it.`,`semantic`,{type:`timeline`});t.events.push(e)}},y=[`$end`,`EOF`,`INVALID`,`NEWLINE`,`timeline`,`timeline_lr`,`timeline_td`,`title`,`acc_title`,`acc_title_value`,`acc_descr`,`acc_descr_value`,`acc_descr_multiline_value`,`section`,`period`,`event`];function b(i){let a=i.length,o=[],s=[],c=[],l={types:o,texts:s,starts:c},u=0,d=(e,t)=>{o.push(e),s.push(i.slice(u,t)),c.push(u),u=t};for(;u=t(i,u),!(u>=a);){let t=i.charCodeAt(u),o=u+1;if(t===10){for(;i.charCodeAt(o)===10;)o++;d(3,o)}else{if(r(i,u,`timeline`)){for(o=u+8;i.charCodeAt(o)===32||i.charCodeAt(o)===9;)o++;let e=r(i,o,`lr`);if(o>u+8&&(e||r(i,o,`td`))&&!h(i.charCodeAt(o+2))){d(e?5:6,o+2);continue}if(!h(i.charCodeAt(u+8))){d(4,u+8);continue}}if(r(i,u,`title`)){for(o=u+5;i.charCodeAt(o)!==10&&g(i.charCodeAt(o));)o++;if(o===a||i.charCodeAt(o)===10){u=o;continue}let e=i.charCodeAt(u+5);if(e!==13&&g(e)){d(7,n(i,u+6));continue}}if(o=e(i,u,l,8),o!==u)u=o;else{if(r(i,u,`section`)&&g(i.charCodeAt(u+7))){for(o=u+8;o<a&&i.charCodeAt(o)!==58&&i.charCodeAt(o)!==10;)o++;if(o>u+8){d(13,o);continue}}if(t!==58){o=u+1;for(let e=i.charCodeAt(o);o<a&&e!==35&&e!==58&&e!==10;e=i.charCodeAt(++o));d(14,o)}else{if(g(i.charCodeAt(u+1))){for(o=u+2;o<a;o++){let e=i.charCodeAt(o);if(e===10||e===58&&g(i.charCodeAt(o+1)))break}if(o>u+2){d(15,o);continue}}d(2,u+1)}}}}return(c.length===0||c[c.length-1]<a)&&d(1,a),d(0,a),l}var x=`'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'`;function S(e,t){let{types:n,texts:r,starts:i}=b(e),a=(t,r)=>{let a=n[t]===0?`1`:y[n[t]];throw _(`timeline`,e,i[t],`Expecting ${r}, got '${a}'`)},o=n[0];o!==4&&o!==5&&o!==6&&a(0,`'timeline', 'timeline_lr', 'timeline_td'`),o!==4&&t.setDirection(o===5?`LR`:`TD`);for(let e=1;;e++){let i=r[e];switch(n[e]){case 3:break;case 7:t.getCommonDb().setDiagramTitle(i.substring(6));break;case 8:t.getCommonDb().setAccTitle(r[++e].trim());break;case 10:t.getCommonDb().setAccDescription(r[++e].trim());break;case 12:t.getCommonDb().setAccDescription(i.trim());break;case 13:t.addSection(i.substring(8));break;case 14:t.addTask(i,0,``);break;case 15:t.addEvent(i.substring(2));break;case 1:return;default:a(e,x)}}}var C=12,te=8,ne=152,re=216,ie=264,w=20,T=20,E=14,D=8,O=8,k=12,A=` fill="var(--_bg)"`,ae=` fill="none" stroke="var(--_b)"`;function j(e,t,n,r,i){return`<rect x="${l(e)}" y="${l(t)}" width="${l(n)}" height="${l(r)}"${a(i)}/>`}function M(e,t,n){return e.direction===`TD`?N(e,t,n,!0):f(n,r=>N(e,t,n,r))}function N(e,t,n,r){let a=n.fontSize??16,f=Math.round(a*.875),m=n.measurer??ee(n.fontFamily,n.fontFamilyMono),h=n.padding??8,g=t.timeline?.disableMulticolor!==!0,_=e.periods,v=e.sections.length>0,y=e.sections.map((e,t)=>({section:t,periods:[]})),b={section:-1,periods:[]};_.forEach((e,t)=>(y[e.sectionIndex]??b).periods.push(t)),b.periods.length>0&&y.unshift(b);let x=r&&n.maxWidth!==void 0&&n.maxWidth>0?n.maxWidth-2*h:1/0,S=T+E*2+4*C,M=Math.min(ne,Math.max(80,Math.round((x-S)*.38))),N=Math.min(ie,Math.max(110,x-S-M)),P=M,F=()=>r?N:P,I=_.map(e=>u(e.text,m,a,P)),L=_.map(e=>e.events.map(e=>u(e,m,f,F()))),R=0;for(let e of I)R=Math.max(R,e.width);if(!r)for(let e of L)for(let t of e)R=Math.max(R,t.width);let oe=R>P;if(r)for(let e of L)for(let t of e)oe||=t.width>N;oe&&(P=Math.min(Math.max(Math.ceil(R),M),x===1/0?re:M),I=_.map(e=>d(e.text,m,a,P)),L=_.map(e=>e.events.map(e=>d(e,m,f,F()))));let se=Math.round(a*1.5),z=P+2*C,B=F()+2*C,V=e=>Math.max(e.height,se)+2*te,H=e=>Math.max(e.height,Math.round(f*1.5))+2*te,ce=(e,t)=>e.section>=0?o(e.section):v?`var(--_m)`:o(g?t:0),le=!1;for(let e of L)e.length>0&&(le=!0);let U=0;for(let e of y)U+=Math.max(e.periods.length,1);let W=z+w,G=_.length>0,K=r?z+(le?T+E*2+B:G?T+k:0):U>0?U*W-w+(G?k+8:0):0,q=d(e.title,m,a,Math.max(K,320),1),ue=q.height>0?q.height+16:0,de=Math.max(K,q.width),J=h+(de-K)/2,Y=h+ue,fe=(t,n)=>d(e.sections[t.section],m,a,n-2*C,1),X=(e,t,n,r,i,a)=>j(n,r,i,a,` fill="${o(e.section)}"`)+c(t,n+i/2,r+a/2,` font-weight="var(--_hw)"`+A),pe=(e,t,n,r,i)=>j(n,r,z,i,` fill="${t}"`)+c(I[e],n+z/2,r+i/2,A),me=(e,t,n,r,i)=>`<g class="pele-node pele-event">`+j(n,r,B,i,` fill="${t}" fill-opacity="0.16"`)+c(e,n+B/2,r+i/2,` font-size="${f}"`)+`</g>`,he=(e,t,n)=>`<circle class="pele-dot" cx="${l(e)}" cy="${l(t)}" r="4" fill="${n}" stroke="var(--_bg)" stroke-width="2"/>`,ge=t=>t.section>=0?`<g class="pele-cluster pele-section" data-id="${s(e.sections[t.section].trim())}">`:``,_e=e=>`<g class="pele-node pele-period" data-id="${s(_[e].text.trim())}">`,Z=``,Q;if(r){let e=J+z+T,t=e+E,n=t+E,r=Y;for(let i of y){if(Z+=ge(i),i.section>=0){let e=fe(i,K),t=V(e);Z+=X(i,e,J,r,K,t),r+=t+O+4}for(let a of i.periods){let o=ce(i,a),s=V(I[a]),c=L[a].length>0?H(L[a][0]):s,u=r+Math.max(s,c)/2,d=`M${l(J+z)},${l(u)}H${l(e)}`,f=``,p=u-c/2,m=u;for(let e of L[a]){let r=H(e);m=p+r/2,d+=`M${l(t)},${l(m)}H${l(n)}`,f+=me(e,o,n,p,r),p+=r+D}f&&(d+=`M${l(e)},${l(u)}H${l(t)}V${l(m)}`),Z+=_e(a)+pe(a,o,J,u-s/2,s)+`<path class="pele-edge" d="${d}"${ae}/>`+he(e,u,o)+f+`</g>`,r=Math.max(u+s/2,p-D)+w}i.periods.length===0&&(r+=w-O-4),i.section>=0&&(Z+=`</g>`)}if(y.length>0&&(r-=w),G){let t=r+k+8;Z=`<path class="pele-axis" d="M${l(e)},${l(Y)}V${l(t-8+1)}" fill="none" stroke="var(--_l)"/>`+p(`arrow_point`,e,t,0,1,`var(--_l)`)+Z,r=t}Q=r+h}else{let e=0,t=y.map(t=>{if(t.section<0)return;let n=fe(t,Math.max(t.periods.length,1)*W-w);return e=Math.max(e,V(n)),n}),n=0;for(let e of I)n=Math.max(n,V(e));let r=Y+(v?e+O:0),i=r+n+(n>0?T:0),a=i+T,o=G?i+k:Y+e,s=0;if(y.forEach((c,u)=>{let d=Math.max(c.periods.length,1),f=J+s*W;Z+=ge(c);let p=t[u];p&&(Z+=X(c,p,f,Y,d*W-w,e)),c.periods.forEach((e,t)=>{let s=ce(c,e),u=f+t*W,d=u+z/2,p=`M${l(d)},${l(r+n)}V${l(L[e].length>0?a:i)}`,m=``,h=a;for(let t of L[e]){let e=H(t);h>a&&(p+=`M${l(d)},${l(h-D)}V${l(h)}`),m+=me(t,s,u,h,e),h+=e+D}o=Math.max(o,h-D),Z+=_e(e)+pe(e,s,u,r,n)+`<path class="pele-edge" d="${p}"${ae}/>`+he(d,i,s)+m+`</g>`}),c.section>=0&&(Z+=`</g>`),s+=d}),G){let e=J+K;Z=`<path class="pele-axis" d="M${l(J)},${l(i)}H${l(e-8+1)}" fill="none" stroke="var(--_l)"/>`+p(`arrow_point`,e,i,1,0,`var(--_l)`)+Z}Q=o+h}let $=Math.ceil(de+2*h),ve=Math.ceil(Math.max(Q,h*2)),ye=c(q,$/2,h+q.height/2,` class="pele-title" font-weight="var(--_tw)"`)+Z;return{svg:i(`timeline`,$,ve,a,n,e,ye),width:$,height:ve,links:[]}}var P={type:`timeline`,parse(e,t,n){let r=new v;return r.title=n,S(e,r),r},render:M};export{P as timeline};
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,b as n,d as r,i,o as a,s as o,u as s,x as c}from"./DfCZPwp1.js";import{a as l,o as u,r as d,t as f}from"./DciMwFJ1.js";import{a as p,d as m,i as h,l as g,s as _,u as v}from"./BLmF1B2i.js";import{t as y}from"./RFxekmX-.js";import{a as b,i as x,n as S,r as C,s as w,t as T}from"./Dh1lBxfx.js";import{a as E,i as D,n as O,r as k,t as ee}from"./Bt7VOT5H.js";import{t as A}from"./D6QVYUu9.js";import{i as te,n as ne,r as re,t as ie}from"./tUSDgbpy.js";import{i as ae,n as oe,r as se,t as ce}from"./RlApGeew.js";import{n as le,t as ue}from"./CggtIYAM.js";import{PeleError as j,c as M,d as de,g as N,h as P,i as F,n as I,s as fe,u as pe}from"./-2Meesge.js";function L(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}function me(e){return e.startsWith(`"`)&&e.endsWith(`"`)?e.substring(1,e.length-1):e}function R(e,t){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function z(e){let t=e.trim(),n=`arrow_open`;switch(t[0]){case`<`:n=`arrow_point`,t=t.slice(1);break;case`x`:n=`arrow_cross`,t=t.slice(1);break;case`o`:n=`arrow_circle`,t=t.slice(1)}let r=`normal`;return t.includes(`=`)&&(r=`thick`),t.includes(`.`)&&(r=`dotted`),{type:n,stroke:r}}function B(e){let t=e.trim(),n=t.slice(0,-1),r=`arrow_open`;switch(t.slice(-1)){case`x`:r=`arrow_cross`,t.startsWith(`x`)&&(r=`double_`+r,n=n.slice(1));break;case`>`:r=`arrow_point`,t.startsWith(`<`)&&(r=`double_`+r,n=n.slice(1));break;case`o`:r=`arrow_circle`,t.startsWith(`o`)&&(r=`double_`+r,n=n.slice(1))}let i=`normal`,a=n.length-1;n.startsWith(`=`)&&(i=`thick`),n.startsWith(`~`)&&(i=`invisible`);let o=R(`.`,n);return o&&(i=`dotted`,a=o),{type:r,stroke:i,length:a}}var V=class{type=`flowchart`;direction;nodes=new Map;edges=[];subgraphs=[];classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=new Map;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;options;constructor(e={}){this.options=e}addVertex(e,t,n,r,i,a,o,s){if(!e||e.trim().length===0)return;let c;if(s!==void 0){let t=s.includes(`
1
+ import{_ as e,a as t,b as n,d as r,i,o as a,s as o,u as s,x as c}from"./C2npZzkn.js";import{a as l,o as u,r as d,t as f}from"./DciMwFJ1.js";import{a as p,d as m,i as h,l as g,s as _,u as v}from"./BXBhaEho.js";import{t as y}from"./DDAG55ce.js";import{a as b,i as x,n as S,r as C,s as w,t as T}from"./BA78_vo5.js";import{a as E,i as D,n as O,r as k,t as ee}from"./DKqMzyyE.js";import{t as A}from"./D6QVYUu9.js";import{i as te,n as ne,r as re,t as ie}from"./BCGaqnao.js";import{i as ae,n as oe,r as se,t as ce}from"./D1LK3xRu.js";import{n as le,t as ue}from"./CggtIYAM.js";import{PeleError as j,c as M,d as de,g as N,h as P,i as F,n as I,s as fe,u as pe}from"./CMikI1NP.js";function L(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}function me(e){return e.startsWith(`"`)&&e.endsWith(`"`)?e.substring(1,e.length-1):e}function R(e,t){let n=0;for(let r=0;r<t.length;r++)t[r]===e&&n++;return n}function z(e){let t=e.trim(),n=`arrow_open`;switch(t[0]){case`<`:n=`arrow_point`,t=t.slice(1);break;case`x`:n=`arrow_cross`,t=t.slice(1);break;case`o`:n=`arrow_circle`,t=t.slice(1)}let r=`normal`;return t.includes(`=`)&&(r=`thick`),t.includes(`.`)&&(r=`dotted`),{type:n,stroke:r}}function B(e){let t=e.trim(),n=t.slice(0,-1),r=`arrow_open`;switch(t.slice(-1)){case`x`:r=`arrow_cross`,t.startsWith(`x`)&&(r=`double_`+r,n=n.slice(1));break;case`>`:r=`arrow_point`,t.startsWith(`<`)&&(r=`double_`+r,n=n.slice(1));break;case`o`:r=`arrow_circle`,t.startsWith(`o`)&&(r=`double_`+r,n=n.slice(1))}let i=`normal`,a=n.length-1;n.startsWith(`=`)&&(i=`thick`),n.startsWith(`~`)&&(i=`invisible`);let o=R(`.`,n);return o&&(i=`dotted`,a=o),{type:r,stroke:i,length:a}}var V=class{type=`flowchart`;direction;nodes=new Map;edges=[];subgraphs=[];classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;title;accTitle;accDescr;subgraphLookup=new Map;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;options;constructor(e={}){this.options=e}addVertex(e,t,n,r,i,a,o,s){if(!e||e.trim().length===0)return;let c;if(s!==void 0){let t=s.includes(`
2
2
  `)?s+`
3
3
  `:`{
4
4
  `+s+`
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,b as n,d as r,f as i,i as a,o,s,u as c,x as l}from"./DfCZPwp1.js";import{a as u,t as d}from"./DciMwFJ1.js";import{a as f,i as p,l as m,s as h,u as g}from"./BLmF1B2i.js";import{a as _,i as v,t as y}from"./Dh1lBxfx.js";import{a as ee,i as b,r as x,t as S}from"./Bt7VOT5H.js";import{t as C}from"./D6QVYUu9.js";import{n as w,r as T}from"./tUSDgbpy.js";import{i as E,n as te,r as D,t as O}from"./RlApGeew.js";import{n as k,t as A}from"./CggtIYAM.js";import{PeleError as j,c as M,d as ne,g as N,h as P,i as F,n as I,o as L,s as R,u as z}from"./-2Meesge.js";var B=new Map([[`task`,`roundedRect`],[`tool`,`subroutine`],[`input`,`lean-right`],[`decision`,`diamond`],[`refdoc`,`lin-doc`],[`action`,`hexagon`],[`round`,`rect`]]),V=new Set(`doc.stadium.terminal.circle.trapezoid.inv_trapezoid.inv-trapezoid.doublecircle.double-circle.typeDeclaration.procs.lean_left.lean-left.in-out.cylinder.ellipse.odd.tag-rect.tagged-rectangle.delay.half-rounded-rectangle.lin-rect.lined-rectangle.win-pane.window-pane.curv-trap.curved-trapezoid`.split(`.`)),re=new Set([`roundedRect`,`subroutine`,`subprocess`,`subproc`,`framed-rectangle`,`lean-right`,`diamond`,`lin-doc`,`lined-document`,`hexagon`,`hex`,`connector`,`collapsedGroup`]),H=`roundedRect`;function U(e){return e&&(B.get(e)??e)}function W(e){return A(e)||e===`constructor`}function ie(e,t){for(let n of e)n.isGroup||((!n.shape||n.shape===`squareRect`||n.shape===`rect`)&&(n.shape=H),V.has(n.shape)?(t.emitError(`SHAPE_REMOVED`,`shape "${n.shape}" was removed in v0.8.1, using "${H}"`,{nodeId:n.id}),n.shape=H):re.has(n.shape)||(t.emitWarning(`SHAPE_UNSUPPORTED`,`shape "${n.shape}" is not supported, using "${H}"`,{nodeId:n.id}),n.shape=H))}var G=new Set([`shape`,`view`,`icon`,`img`,`form`,`pos`,`w`,`h`,`class`,`style`,`labelType`]),ae=new Set([`subroutine`,`subprocess`,`subproc`,`framed-rectangle`,`tool`]);function oe(e){return ae.has(e.type)}function K(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}function q(e){return e.startsWith(`"`)&&e.endsWith(`"`)?e.substring(1,e.length-1):e}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function se(e){let t=e=>Array.isArray(e)?[]:J(e)?{}:e,n=t(e),r=[[e,n]];for(;r.length>0;){let[e,n]=r.pop();if(Array.isArray(e))for(let i of e){let e=t(i);n.push(e),typeof i==`object`&&i&&r.push([i,e])}else if(J(e))for(let i of Object.keys(e)){if(i===`__proto__`||i===`constructor`||i===`prototype`)continue;let a=e[i],o=t(a);n[i]=o,typeof a==`object`&&a&&r.push([a,o])}}return n}function Y(e,t){return Object.assign(e??{},t)}var ce=/:\s*[>|][\d+-]*\s*$/,le=/,([\t ]*)$/;function X(e){let t=!1,n=!1,r=0,i,a=[];for(let o of e.split(`
1
+ import{_ as e,a as t,b as n,d as r,f as i,i as a,o,s,u as c,x as l}from"./C2npZzkn.js";import{a as u,t as d}from"./DciMwFJ1.js";import{a as f,i as p,l as m,s as h,u as g}from"./BXBhaEho.js";import{a as _,i as v,t as y}from"./BA78_vo5.js";import{a as ee,i as b,r as x,t as S}from"./DKqMzyyE.js";import{t as C}from"./D6QVYUu9.js";import{n as w,r as T}from"./BCGaqnao.js";import{i as E,n as te,r as D,t as O}from"./D1LK3xRu.js";import{n as k,t as A}from"./CggtIYAM.js";import{PeleError as j,c as M,d as ne,g as N,h as P,i as F,n as I,o as L,s as R,u as z}from"./CMikI1NP.js";var B=new Map([[`task`,`roundedRect`],[`tool`,`subroutine`],[`input`,`lean-right`],[`decision`,`diamond`],[`refdoc`,`lin-doc`],[`action`,`hexagon`],[`round`,`rect`]]),V=new Set(`doc.stadium.terminal.circle.trapezoid.inv_trapezoid.inv-trapezoid.doublecircle.double-circle.typeDeclaration.procs.lean_left.lean-left.in-out.cylinder.ellipse.odd.tag-rect.tagged-rectangle.delay.half-rounded-rectangle.lin-rect.lined-rectangle.win-pane.window-pane.curv-trap.curved-trapezoid`.split(`.`)),re=new Set([`roundedRect`,`subroutine`,`subprocess`,`subproc`,`framed-rectangle`,`lean-right`,`diamond`,`lin-doc`,`lined-document`,`hexagon`,`hex`,`connector`,`collapsedGroup`]),H=`roundedRect`;function U(e){return e&&(B.get(e)??e)}function W(e){return A(e)||e===`constructor`}function ie(e,t){for(let n of e)n.isGroup||((!n.shape||n.shape===`squareRect`||n.shape===`rect`)&&(n.shape=H),V.has(n.shape)?(t.emitError(`SHAPE_REMOVED`,`shape "${n.shape}" was removed in v0.8.1, using "${H}"`,{nodeId:n.id}),n.shape=H):re.has(n.shape)||(t.emitWarning(`SHAPE_UNSUPPORTED`,`shape "${n.shape}" is not supported, using "${H}"`,{nodeId:n.id}),n.shape=H))}var G=new Set([`shape`,`view`,`icon`,`img`,`form`,`pos`,`w`,`h`,`class`,`style`,`labelType`]),ae=new Set([`subroutine`,`subprocess`,`subproc`,`framed-rectangle`,`tool`]);function oe(e){return ae.has(e.type)}function K(e){return e===`markdown`||e===`string`||e===`text`?e:`markdown`}function q(e){return e.startsWith(`"`)&&e.endsWith(`"`)?e.substring(1,e.length-1):e}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function se(e){let t=e=>Array.isArray(e)?[]:J(e)?{}:e,n=t(e),r=[[e,n]];for(;r.length>0;){let[e,n]=r.pop();if(Array.isArray(e))for(let i of e){let e=t(i);n.push(e),typeof i==`object`&&i&&r.push([i,e])}else if(J(e))for(let i of Object.keys(e)){if(i===`__proto__`||i===`constructor`||i===`prototype`)continue;let a=e[i],o=t(a);n[i]=o,typeof a==`object`&&a&&r.push([a,o])}}return n}function Y(e,t){return Object.assign(e??{},t)}var ce=/:\s*[>|][\d+-]*\s*$/,le=/,([\t ]*)$/;function X(e){let t=!1,n=!1,r=0,i,a=[];for(let o of e.split(`
2
2
  `)){if(i!==void 0){let e=o.length-o.trimStart().length;if(o.trim()===``||e>i){a.push(o);continue}i=void 0}let e=-1;for(let i=0;i<o.length;i++){let a=o[i];if(n)a===`\\`?i++:a===`"`&&(n=!1);else if(t)a===`'`&&(t=!1);else if(a===`"`)n=!0;else if(a===`'`)t=!0;else if(a===`#`&&(i===0||o[i-1]===` `||o[i-1]===` `)){e=i;break}else a===`[`||a===`{`?r++:(a===`]`||a===`}`)&&(r=Math.max(0,r-1))}if(t||n||r>0){a.push(o);continue}let s=e>=0?o.slice(0,e):o,c=e>=0?o.slice(e):``;ce.test(s)?(i=o.length-o.trimStart().length,a.push(o)):a.push(s.replace(le,`$1`)+c)}return a.join(`
3
3
  `)}function ue(e,t){if(e===`arrow_point`&&t===`normal`)return`sequence`;if(e===`arrow_cross`&&t===`normal`)return`failure`;if(e===`arrow_open`&&t===`dotted`)return`reference`}function de(e){let t=e.trim(),n=t.slice(0,-1),r=`arrow_open`;switch(t.slice(-1)){case`x`:r=`arrow_cross`;break;case`>`:r=`arrow_point`;break;case`-`:case`.`:n=t}let i=`normal`,a=n.length-1,o=0;for(let e=0;e<n.length;e++)n[e]===`.`&&o++;return o>0&&(i=`dotted`,a=o),{type:r,stroke:i,length:a}}function fe(e){if(!e)return;let t={},n=!1;for(let r of Object.keys(e))G.has(r)||(t[r]=e[r],n=!0);return n?t:void 0}var pe=class{type=`agentflow`;direction;nodes=new Map;edges=[];subgraphs=[];connectors=new Map;classes=new Map;tooltips=new Map;defaultEdgeStyle;defaultInterpolate;mappings=[];diagnostics=[];title;accTitle;accDescr;lineOffset;subgraphLookup=new Map;globalNodes=new Set;members=new Set;edgeById=new Map;pairCount=new Map;subCount=0;bareMappings=new Set;firstMapping=new Map;reported=new Map;options;constructor(e={}){this.options=e,this.lineOffset=e.lineOffset??0}metadata(e,t,n){let r=t.includes(`
4
4
  `),i;try{i=I(r?t+`
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,b as n,c as r,d as i,i as a,m as o,o as s,p as c,s as l,t as u,u as d,v as f,x as p,y as m}from"./DfCZPwp1.js";import{a as h,t as g}from"./DciMwFJ1.js";import{i as _,l as v}from"./BLmF1B2i.js";import{t as y}from"./RFxekmX-.js";import{i as b,r as x,t as ee}from"./RlApGeew.js";import{PeleError as S,_ as C,g as w,h as T,s as E,u as te}from"./-2Meesge.js";var D={REQUIREMENT:`Requirement`,FUNCTIONAL_REQUIREMENT:`Functional Requirement`,INTERFACE_REQUIREMENT:`Interface Requirement`,PERFORMANCE_REQUIREMENT:`Performance Requirement`,PHYSICAL_REQUIREMENT:`Physical Requirement`,DESIGN_CONSTRAINT:`Design Constraint`},O={LOW_RISK:`Low`,MED_RISK:`Medium`,HIGH_RISK:`High`},k={VERIFY_ANALYSIS:`Analysis`,VERIFY_DEMONSTRATION:`Demonstration`,VERIFY_INSPECTION:`Inspection`,VERIFY_TEST:`Test`},A={CONTAINS:`contains`,COPIES:`copies`,DERIVES:`derives`,SATISFIES:`satisfies`,VERIFIES:`verifies`,REFINES:`refines`,TRACES:`traces`},j=1e6,M=class{type=`requirement`;direction=`TB`;requirements=new Map;elements=new Map;relations=[];classes=new Map;title;accTitle;accDescr;newId=``;newText=``;newRisk=``;newVerifyMethod=``;newElementType=``;newDocRef=``;styleCopies=0;copy(e,t){if(this.styleCopies+=t.length,this.styleCopies>j)throw new S(`Requirement diagram applies too many style declarations.`,`limit`,{type:`requirement`});for(let n of t)e.push(n)}setDirection(e){this.direction=e}addRequirement(e,t){let n=this.requirements.get(e);return n===void 0&&(n={name:e,type:t,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:[`default`]},this.requirements.set(e,n)),this.newId=this.newText=this.newRisk=this.newVerifyMethod=``,n}setNewReqId(e){this.newId=e}setNewReqText(e){this.newText=e}setNewReqRisk(e){this.newRisk=e}setNewReqVerifyMethod(e){this.newVerifyMethod=e}addElement(e){let t=this.elements.get(e);return t===void 0&&(t={name:e,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:[`default`]},this.elements.set(e,t)),this.newElementType=this.newDocRef=``,t}setNewElementType(e){this.newElementType=e}setNewElementDocRef(e){this.newDocRef=e}addRelationship(e,t,n){this.relations.push({type:e,src:t,dst:n})}node(e){return this.requirements.get(e)??this.elements.get(e)}setCssStyle(e,t){for(let n of e){let e=this.node(n);if(!t||!e)return;for(let n of t)this.copy(e.cssStyles,n.includes(`,`)?n.split(`,`):[n])}}setClass(e,t){for(let n of e){let e=this.node(n);if(e)for(let n of t){e.classes.push(n);let t=this.classes.get(n)?.styles;t&&this.copy(e.cssStyles,t)}}}defineClass(e,t){for(let n of e){let e=this.classes.get(n);e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e));for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n);let r=t.flatMap(e=>e.split(`,`));for(let e of this.requirements.values())e.classes.includes(n)&&this.copy(e.cssStyles,r);for(let e of this.elements.values())e.classes.includes(n)&&this.copy(e.cssStyles,r)}}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
1
+ import{_ as e,a as t,b as n,c as r,d as i,i as a,m as o,o as s,p as c,s as l,t as u,u as d,v as f,x as p,y as m}from"./C2npZzkn.js";import{a as h,t as g}from"./DciMwFJ1.js";import{i as _,l as v}from"./BXBhaEho.js";import{t as y}from"./DDAG55ce.js";import{i as b,r as x,t as ee}from"./D1LK3xRu.js";import{PeleError as S,_ as C,g as w,h as T,s as E,u as te}from"./CMikI1NP.js";var D={REQUIREMENT:`Requirement`,FUNCTIONAL_REQUIREMENT:`Functional Requirement`,INTERFACE_REQUIREMENT:`Interface Requirement`,PERFORMANCE_REQUIREMENT:`Performance Requirement`,PHYSICAL_REQUIREMENT:`Physical Requirement`,DESIGN_CONSTRAINT:`Design Constraint`},O={LOW_RISK:`Low`,MED_RISK:`Medium`,HIGH_RISK:`High`},k={VERIFY_ANALYSIS:`Analysis`,VERIFY_DEMONSTRATION:`Demonstration`,VERIFY_INSPECTION:`Inspection`,VERIFY_TEST:`Test`},A={CONTAINS:`contains`,COPIES:`copies`,DERIVES:`derives`,SATISFIES:`satisfies`,VERIFIES:`verifies`,REFINES:`refines`,TRACES:`traces`},j=1e6,M=class{type=`requirement`;direction=`TB`;requirements=new Map;elements=new Map;relations=[];classes=new Map;title;accTitle;accDescr;newId=``;newText=``;newRisk=``;newVerifyMethod=``;newElementType=``;newDocRef=``;styleCopies=0;copy(e,t){if(this.styleCopies+=t.length,this.styleCopies>j)throw new S(`Requirement diagram applies too many style declarations.`,`limit`,{type:`requirement`});for(let n of t)e.push(n)}setDirection(e){this.direction=e}addRequirement(e,t){let n=this.requirements.get(e);return n===void 0&&(n={name:e,type:t,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:[`default`]},this.requirements.set(e,n)),this.newId=this.newText=this.newRisk=this.newVerifyMethod=``,n}setNewReqId(e){this.newId=e}setNewReqText(e){this.newText=e}setNewReqRisk(e){this.newRisk=e}setNewReqVerifyMethod(e){this.newVerifyMethod=e}addElement(e){let t=this.elements.get(e);return t===void 0&&(t={name:e,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:[`default`]},this.elements.set(e,t)),this.newElementType=this.newDocRef=``,t}setNewElementType(e){this.newElementType=e}setNewElementDocRef(e){this.newDocRef=e}addRelationship(e,t,n){this.relations.push({type:e,src:t,dst:n})}node(e){return this.requirements.get(e)??this.elements.get(e)}setCssStyle(e,t){for(let n of e){let e=this.node(n);if(!t||!e)return;for(let n of t)this.copy(e.cssStyles,n.includes(`,`)?n.split(`,`):[n])}}setClass(e,t){for(let n of e){let e=this.node(n);if(e)for(let n of t){e.classes.push(n);let t=this.classes.get(n)?.styles;t&&this.copy(e.cssStyles,t)}}}defineClass(e,t){for(let n of e){let e=this.classes.get(n);e===void 0&&(e={id:n,styles:[],textStyles:[]},this.classes.set(n,e));for(let n of t)n.includes(`color`)&&e.textStyles.push(n.replace(`fill`,`bgFill`)),e.styles.push(n);let r=t.flatMap(e=>e.split(`,`));for(let e of this.requirements.values())e.classes.includes(n)&&this.copy(e.cssStyles,r);for(let e of this.elements.values())e.classes.includes(n)&&this.copy(e.cssStyles,r)}}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,``)}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
2
2
  `)}},N=`$end.INVALID.title.acc_title.acc_title_value.acc_descr.acc_descr_value.acc_descr_multiline_value.direction_tb.direction_bt.direction_rl.direction_lr.NEWLINE.EOF.RD.STRUCT_START.STRUCT_STOP.STYLE_SEPARATOR.COLONSEP.ID.TEXT.RISK.VERIFYMTHD.REQUIREMENT.FUNCTIONAL_REQUIREMENT.INTERFACE_REQUIREMENT.PERFORMANCE_REQUIREMENT.PHYSICAL_REQUIREMENT.DESIGN_CONSTRAINT.LOW_RISK.MED_RISK.HIGH_RISK.VERIFY_ANALYSIS.VERIFY_DEMONSTRATION.VERIFY_INSPECTION.VERIFY_TEST.ELEMENT.CONTAINS.COPIES.DERIVES.SATISFIES.VERIFIES.REFINES.TRACES.TYPE.DOCREF.STYLE.CLASSDEF.CLASS.ALPHA.COLON.SEMICOLON.PERCENT.MINUS.BRKT.END_ARROW_L.END_ARROW_R.LINE.qString.unqString.COMMA`.split(`.`),P=new Map([[`requirementdiagram`,14],[`id`,19],[`text`,20],[`risk`,21],[`verifymethod`,22],[`requirement`,23],[`functionalrequirement`,24],[`interfacerequirement`,25],[`performancerequirement`,26],[`physicalrequirement`,27],[`designconstraint`,28],[`low`,29],[`medium`,30],[`high`,31],[`analysis`,32],[`demonstration`,33],[`inspection`,34],[`test`,35],[`element`,36],[`contains`,37],[`copies`,38],[`derives`,39],[`satisfies`,40],[`verifies`,41],[`refines`,42],[`traces`,43],[`type`,44],[`docref`,45],[`style`,46],[`classdef`,47],[`class`,48]]),F=/accTitle\s*:\s*/iy,I=/accDescr\s*:\s*/iy,L=/accDescr\s*\{\s*/iy,R=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi,z=/[\n\r\u2028\u2029]/g,B=22,V=new Uint8Array(128);for(let e of`:,\r
3
3
  {<>-=`)V[e.charCodeAt(0)]=1;function ne(e){let t=e.length,n=[],r=[],i=[],a=[],o=0,s=0,c=[[],[],[],[]],l=[[],[],[],[]],u=[0,0,0,0],d=!1,f=-1;R.lastIndex=0;for(let t=R.exec(e);t!==null;t=R.exec(e)){let e=t[1]===void 0?t[2]===void 0?t[3]===void 0?3:2:1:0;c[e].push(t.index),l[e].push(R.lastIndex),d=!0}let p=(t,a,o)=>{n.push(t),r.push(e.slice(a,o)),i.push(a),s=o},m=e=>{a.push(o),o=e},h=()=>{a.length>0&&(o=a.pop())},g=(t,n)=>(t.lastIndex=n,t.test(e)?t.lastIndex:-1),_=n=>{let r=e.indexOf(`
4
4
  `,n);return r===-1?t:r},v=()=>{if(f<s){z.lastIndex=s,f=z.test(e)?z.lastIndex-1:t;for(let e=0;e<4;e++){let t=c[e],n=u[e];for(;n<t.length&&t[n]<=f;)n++;u[e]=n}}for(let e=0;e<4;e++){let t=u[e]-1;if(t>=0&&c[e][t]>=s)return p(8+e,s,_(l[e][t])),!0}return!1},y=a=>{let o=a|32;if(o===116&&e.slice(s+1,s+5).toLowerCase()===`itle`&&T(e.charCodeAt(s+5))){let n=s+6;for(;n<t;){let t=e.charCodeAt(n);if(t===35||t===10||t===59)break;n++}if(n>s+6)return p(2,s,n),!0}if(o===97&&(e.charCodeAt(s+1)|32)==99&&(e.charCodeAt(s+2)|32)==99){let e;if((e=g(F,s))>=0)return m(3),p(3,s,e),!0;if((e=g(I,s))>=0)return m(4),p(5,s,e),!0;if((e=g(L,s))>=0)return m(5),s=e,!0}if(d&&!C(a)&&v())return!0;if(a===10||a===13&&e.charCodeAt(s+1)===10){let n=s;for(;n<t;){let t=e.charCodeAt(n);if(t===10)n++;else if(t===13&&e.charCodeAt(n+1)===10)n+=2;else break}return p(12,s,n),!0}if(T(a)){for(s++;s<t&&T(e.charCodeAt(s));)s++;return!0}if(a===35||a===37)return s=_(s),!0;if(w(a)){let a=s+1;for(;a<t&&w(e.charCodeAt(a));)a++;if(a-s<=B){let t=P.get(e.slice(s,a).toLowerCase());if(t!==void 0)return(t===46||t===47||t===48)&&m(2),p(t,s,a),!0}for(;a<t;){let t=e.charCodeAt(a);if(t<128&&V[t]===1)break;a++}return n.push(59),r.push(e.slice(s,a).trim()),i.push(s),s=a,!0}switch(a){case 123:return p(15,s,s+1),!0;case 125:return p(16,s,s+1),!0;case 58:return e.charCodeAt(s+1)===58&&e.charCodeAt(s+2)===58?p(17,s,s+3):p(18,s,s+1),!0;case 60:return e.charCodeAt(s+1)===45&&(p(55,s,s+2),!0);case 45:return e.charCodeAt(s+1)===62?p(56,s,s+2):p(57,s,s+1),!0;case 34:return m(1),s++,!0;case 44:return p(60,s,s+1),!0}return!1},b=n=>{if(w(n)){let n=s+1;for(;n<t&&w(e.charCodeAt(n));)n++;return p(49,s,n),!0}switch(n){case 58:return p(50,s,s+1),!0;case 59:return p(51,s,s+1),!0;case 37:return p(52,s,s+1),!0;case 45:return p(53,s,s+1),!0;case 35:return p(54,s,s+1),!0;case 32:return s++,!0;case 34:return m(1),s++,!0;case 10:return h(),s++,!0;case 44:return p(60,s,s+1),!0}return!1};for(;s<t;){let a=e.charCodeAt(s),c=!0;switch(o){case 0:c=y(a);break;case 2:c=b(a);break;case 1:if(a===34)h(),s++;else{let n=e.indexOf(`"`,s);p(58,s,n===-1?t:n)}break;case 3:h(),p(4,s,_(s));break;case 4:h(),p(6,s,_(s));break;case 5:if(a===125)h(),s++;else{let n=e.indexOf(`}`,s);p(7,s,n===-1?t:n)}}if(!c)return n.push(1),r.push(``),i.push(s),{types:n,texts:r,starts:i}}let x=o===0?13:o===1?58:o===3?4:o===4?6:o===5?7:-1;return x!==-1&&p(x,t,t),p(0,t,t),{types:n,texts:r,starts:i}}var re=[D.REQUIREMENT,D.FUNCTIONAL_REQUIREMENT,D.INTERFACE_REQUIREMENT,D.PERFORMANCE_REQUIREMENT,D.PHYSICAL_REQUIREMENT,D.DESIGN_CONSTRAINT,O.LOW_RISK,O.MED_RISK,O.HIGH_RISK,k.VERIFY_ANALYSIS,k.VERIFY_DEMONSTRATION,k.VERIFY_INSPECTION,k.VERIFY_TEST,``,A.CONTAINS,A.COPIES,A.DERIVES,A.SATISFIES,A.VERIFIES,A.REFINES,A.TRACES];function H(e){return e===49||e===50||e===54||e===53||e===51}function ie(e,t){let{types:n,texts:r,starts:i}=ne(e),a=0,o=[],s=[],c=(t,r=t,...o)=>{let s=n[a];if(s===1)throw E(`requirement`,e,i[a],``,!0);for(let e=r;e>=t;e--)o.unshift(e);let c=o.map(e=>`'${N[e]}'`).join(`, `);throw E(`requirement`,e,i[a],`Expecting ${c}, got '${N[s]}'`)},l=e=>(n[a]!==e&&c(e),r[a++]),u=(e,t)=>{let r=n[a];return(r<e||r>t)&&c(e,t),a++,re[r-23]},d=()=>{let e=n[a];return e!==59&&e!==58&&c(58,59),r[a++]},f=()=>{let e=n[a];if(e===3)a++,t.setAccTitle(l(4).trim());else if(e===5)a++,t.setAccDescription(l(6).trim());else if(e===7)t.setAccDescription(r[a++].trim());else return!1;return!0},p=()=>{let e=[];for(;;){let t=n[a];if(t!==49&&t!==59&&t!==58&&c(58,59,49),e.push(r[a++]),n[a]!==60)return e;a++}},m=()=>{let e=[];for(;;){H(n[a])||c(49,51,53,54);let t=r[a++];for(;H(n[a]);)t+=r[a++];if(e.push(t),n[a]!==60)return e;a++}},h=()=>{let e;return n[a]===17?(a++,e=p(),l(15)):n[a]===15?a++:c(15,15,17),l(12),e},g=e=>{for(o.length=0,s.length=0;;){let t=n[a];if(t===16){a++;break}t===12?a++:((e?t<19||t>22:t!==44&&t!==45)&&(e&&c(19,22,12,16),c(44,45,12,16)),a++,l(18),s.push(t===21?u(29,31):t===22?u(32,35):d()),o.push(t),l(12))}for(let e=o.length-1;e>=0;e--){let n=s[e];switch(o[e]){case 19:t.setNewReqId(n);break;case 20:t.setNewReqText(n);break;case 21:t.setNewReqRisk(n);break;case 22:t.setNewReqVerifyMethod(n);break;case 44:t.setNewElementType(n);break;default:t.setNewElementDocRef(n)}}};for(;f();)n[a]===12&&a++;for(n[a]!==14&&c(14,14,3,5,7),a++,l(12);;){let e=n[a];if(e===13)return;if(e===12)a++;else{if(f())continue;if(e>=8&&e<=11)a++,t.setDirection(e===8?`TB`:e===9?`BT`:e===10?`RL`:`LR`);else if(e>=23&&e<=28){let e=u(23,28),n=d(),r=h();g(!0),t.addRequirement(n,e),r&&t.setClass([n],r)}else if(e===36){a++;let e=d(),n=h();g(!1),t.addElement(e),n&&t.setClass([e],n)}else if(e===46){a++;let e=p();t.setCssStyle(e,m())}else if(e===47){a++;let e=p();t.defineClass(e,m())}else if(e===48){a++;let e=p();t.setClass(e,p())}else if(e===59||e===58){let e=r[a++],i=n[a];if(i===17)a++,t.setClass([e],p());else if(i===55||i===57){a++;let n=u(37,43);l(i===57?56:57);let r=d();i===57?t.addRelationship(n,e,r):t.addRelationship(n,r,e)}else c(17,17,55,57)}else c(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}function ae(e){let t=[];for(let n of e.requirements.values())t.push({id:n.name,requirement:n,element:void 0,cssStyles:n.cssStyles,cssClasses:n.classes.join(` `)});for(let n of e.elements.values())t.push({id:n.name,requirement:void 0,element:n,cssStyles:n.cssStyles,cssClasses:n.classes.join(` `)});let n=t=>e.requirements.has(t)||e.elements.has(t)?t:void 0;return{nodes:t,edges:e.relations.map((e,t)=>({id:`${e.src}-${e.dst}-${t}`,start:n(e.src),end:n(e.dst),type:e.type,contains:e.type===A.CONTAINS})),direction:e.direction}}var oe=40,se=16,ce=56,U=14,W=10,G=2,K=12,le=120,ue=280,de=240,q=26,J=6,Y=9,X=4.5,fe=28,pe=14;function Z(e,t,n){if(t===0||e.lines.length===0)return e;let r=0,i=[],a=e.lines.map(a=>{let o=0,s=a.map(r=>{let i=r.style|t,a=r.icon!==void 0||r.math?r.width:n.width(r.text,e.size,i);return o+=a,{...r,style:i,width:a}});return i.push(o),o>r&&(r=o),s});return{...e,lines:a,widths:i,width:r}}function Q(e,n,i,a){let l=r(e),d=``,h=``;for(let r=0;r<e.lines.length;r++){let u=e.lines[r],g=i+c(e,r);if(f(u)){h+=s(m(e,r),n+e.widths[r]/2,g,a);continue}let _=g+e.size*.35,v=!0;for(let e of u)e.icon!==void 0||e.text===``||(d+=`<tspan${v?` x="${p(n)}" y="${p(_)}"`:``}${o(e.style&~l)}>${t(e.text)}</tspan>`,v=!1)}return(d===``?``:`<text${u(a,l)} text-anchor="start" xml:space="preserve">${d}</text>`)+h}function me(e,t,n,r){let i=J,a=e-n*i,o=t-r*i;return`<circle class="pele-marker" cx="${p(a)}" cy="${p(o)}" r="${i}"/><path class="pele-marker" d="M${p(a-n*i)},${p(o-r*i)}L${p(a+n*i)},${p(o+r*i)}M${p(a+r*i)},${p(o-n*i)}L${p(a-r*i)},${p(o+n*i)}"/>`}function he(e,t,n,r){let i=e-n*Y,a=t-r*Y;return`<path class="pele-marker" d="M${p(i-r*X)},${p(a+n*X)}L${p(e)},${p(t)}L${p(i+r*X)},${p(a-n*X)}" stroke-linejoin="round"/>`}function ge(e,t,n){let r=new Map;for(let n of t){let t=n.route;if(!(n.src===n.dst||t.length<6))for(let i of[0,t.length-3]){let a=i===0?n.src:n.dst,o=e[a],s=t[i]-o.x,c=t[i+1]-o.y,l=i===0?3:i-3,u;if(Math.abs(Math.abs(c)-o.h/2)<.5)u=c<0?0:2;else if(Math.abs(Math.abs(s)-o.w/2)<.5)u=s<0?3:1;else continue;let d=a*4+u,f={route:t,at:i,toward:t[u%2==0?l:l+1]},p=r.get(d);p?p.push(f):r.set(d,[f])}}for(let[t,i]of r){if(i.length<2)continue;let r=t>>2,a=t%2==1,o=(a?n[r].h:n[r].w)-2*pe,s=Math.max(0,Math.min(fe,o/(i.length-1)));i.sort((e,t)=>e.toward-t.toward);for(let t=0;t<i.length;t++){let n=(t-(i.length-1)/2)*s;a?i[t].route[i[t].at+1]=e[r].y+n:i[t].route[i[t].at]=e[r].x+n}}}function _e(e,t,n){return h(e.direction)?g(n,r=>$(e,t,n,r)):$(e,t,n,!1)}function $(t,r,o,c){let u=ae(t),f=o.fontSize??16,m=Math.round(f*.875),h=o.measurer??te(o.fontFamily,o.fontFamilyMono),g=o.padding??8,S=new Map,C=[],w=[];for(let e of u.nodes){let t=l(e.cssStyles),n=+!!t.bold|(t.italic?2:0),r=t.fontSize??f,i=t.fontSize??m,a=e.requirement,o=e.element,s=Z(d(`«${a?a.type:`Element`}»`,!1,h,i,4e3),n,h),c=Z(d(e.id,!0,h,r,ue),n|1,h),u=a?[[`ID`,a.requirementId],[`Text`,a.text],[`Risk`,a.risk],[`Verification`,a.verifyMethod]]:[[`Type`,o.type],[`Doc Ref`,o.docRef]],p=[],g=0,_=0,v=0;for(let[e,t]of u){if(!t)continue;let r=Z(d(e,!1,h,i,4e3),n,h),a=Z(d(t,!0,h,i,de),n,h),o=Math.max(r.height,a.height);p.push({key:r,value:a,height:o}),g=Math.max(g,r.width),_=Math.max(_,a.width),v+=o+G}p.length>0&&(v+=2*W-G);let y=2*W+s.height+c.height,b=Math.max(le,Math.max(s.width,c.width)+2*U,p.length>0?g+K+_+2*U:0);S.has(e.id)||S.set(e.id,C.length);let x=ee(b,y+v);x.seq=C.length,C.push({node:e,style:t,kind:s,name:c,rows:p,keyWidth:g,headHeight:y,w:b,h:y+v}),w.push(x)}let T=c?`TB`:x(u.direction),E=T===`LR`||T===`RL`,D=[],O=[],k=[];for(let e of u.edges){let t=e.start===void 0?void 0:S.get(e.start),n=e.end===void 0?void 0:S.get(e.end);if(t===void 0||n===void 0)continue;let r=d(`«${e.type}»`,!1,h,m,4e3);t===n&&(E?w[t].h+=2*(q+r.height+8):w[t].w+=2*(q+r.width+12)),k.push(e),O.push(r),D.push({src:t,dst:n,minlen:1,labelW:r.width+12,labelH:r.height+4,route:[],labelX:0,labelY:0})}let A=b(w,D,T,{nodeSep:oe,edgeSep:se,rankSep:ce,portSep:20});ge(w,D,C);let j=y(t.title,h,f,4e3),M=j.height>0?j.height+12:0,N=Math.max(A.width,j.width),P=g+(N-A.width)/2,F=g+M,I=Math.ceil(N+2*g),L=Math.ceil(A.height+M+2*g),R=``;for(let e=0;e<C.length;e++){let t=C[e],{w:r,h:o,style:c}=t,l=-r/2,u=-o/2,d=`<rect x="${p(l)}" y="${p(u)}" width="${p(r)}" height="${p(o)}" fill="var(--_s)" stroke="var(--_b)"${i(c.shape)}/>`+s(t.kind,0,u+W+t.kind.height/2,` class="pele-stereotype" font-size="${t.kind.size}" fill="var(--_m)"${c.text}`)+s(t.name,0,u+W+t.kind.height+t.name.height/2,` class="pele-label" font-size="${t.name.size}" font-weight="var(--_hw)"${c.text}`);if(t.rows.length>0){let e=u+t.headHeight;d+=`<path class="pele-divider" d="M${p(l)},${p(e)}H${p(-l)}" stroke="var(--_b)"${c.line}/>`;let n=e+W,r=``;for(let e of t.rows)r+=Q(e.key,l+U,n,` class="pele-field" fill="var(--_m)"${c.text}`)+Q(e.value,l+U+t.keyWidth+K,n,` class="pele-value"${c.text}`),n+=e.height+G;d+=`<g class="pele-fields" font-size="${t.rows[0].key.size}">${r}</g>`}R+=`<g class="pele-node ${t.node.requirement?`pele-requirement`:`pele-element`}${n(t.node.cssClasses.replace(/^default\s?/,``))}" data-id="${a(t.node.id)}" transform="translate(${p(w[e].x+P)},${p(w[e].y+F)})">${d}</g>`}let z=``,B=``,V=new Map;for(let e=0;e<D.length;e++){let t=D[e],n=k[e],r=O[e],i=n.contains?2*J:0,o,s=t.labelX+P,c=t.labelY+F;if(t.src===t.dst){let e=C[t.src],n=w[t.src].x+P,r=w[t.src].y+F,a=V.get(t.src)??0;V.set(t.src,a+1);let l=(E?e.w:e.h)/2,u=Math.min(l-4,12+a*6),d=q+a*8,f=(t,i)=>E?`${p(n+i)},${p(r+e.h/2+t)}`:`${p(n+e.w/2+t)},${p(r+i)}`,m=d/.75;o={d:`M${f(i,-u)}C${f(m,-u)} ${f(m,u)} ${f(0,u)}`,sx:E?n-u:n+e.w/2,sy:E?r+e.h/2:r-u,sdx:E?0:-1,sdy:E?-1:0,ex:E?n+u:n+e.w/2,ey:E?r+e.h/2:r+u,edx:E?0:-1,edy:E?-1:0},E?(s=n,c=r+e.h/2+d+4+t.labelH/2):(s=n+e.w/2+d+4+t.labelW/2,c=r)}else{let e=t.route.slice();for(let t=0;t<e.length;t+=3)e[t]+=P,e[t+1]+=F;o=v(e,void 0,i,0)}z+=`<g class="pele-edge pele-relationship-${n.contains?`contains`:`arrow`}" data-id="${a(n.id)}"><path d="${o.d}"${n.contains?``:` stroke-dasharray="5 4"`}/>`+(n.contains?me(o.sx,o.sy,o.sdx,o.sdy):he(o.ex,o.ey,o.edx,o.edy))+`</g>`,B+=_(n.id,r,s,c,``)}return{svg:e(`requirement`,I,L,f,o,t,s(j,I/2,g+j.height/2,` class="pele-title" font-weight="var(--_tw)"`)+(z?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${z}</g>`:``)+(B?`<g class="pele-edge-labels" font-size="${m}" fill="var(--_m)">${B}</g>`:``)+`<g class="pele-nodes">${R}</g>`),width:I,height:L,links:[]}}var ve={type:`requirement`,math:!0,parse(e,t,n){let r=new M;return n&&(r.title=n),ie(e,r),r},render:_e};export{ve as requirement};
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,d as n,i as r,o as i,s as a,u as o,x as s}from"./DfCZPwp1.js";import{o as c,r as l}from"./DciMwFJ1.js";import{a as u,s as d}from"./BLmF1B2i.js";import{a as f}from"./Dh1lBxfx.js";import{o as p,t as m}from"./Bt7VOT5H.js";import{n as h}from"./CD6xPodA.js";import{PeleError as g,g as _,h as v,s as y,u as b}from"./-2Meesge.js";var x=new Set([`label`,`type`,`descr`,`techn`,`sprite`,`tags`,`link`,`bgColor`,`fontColor`,`borderColor`,`shadowing`,`shape`,`legendText`,`legendSprite`]),S=new Set([`label`,`descr`,`techn`,`sprite`,`tags`,`link`,`textColor`,`lineColor`]);function C(e,t){let{key:n,value:r}=t;`from`in e&&(n===`offsetX`||n===`offsetY`)?e[n]=parseInt(r):(`from`in e?S:x).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function w(e,t,n){n!==void 0&&(typeof n==`string`?e[t]=n:C(e,n))}function T(e,t,n){n===void 0?e[t]??=``:w(e,t,n)}function E(e,t){e.labelAttr=void 0,typeof t==`object`?(e.label=``,e.labelAttr=t,C(e,t)):e.label=t??``}var D=class{type=`c4`;c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:`global`,label:`global`,type:`global`,parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
1
+ import{_ as e,a as t,d as n,i as r,o as i,s as a,u as o,x as s}from"./C2npZzkn.js";import{o as c,r as l}from"./DciMwFJ1.js";import{a as u,s as d}from"./BXBhaEho.js";import{a as f}from"./BA78_vo5.js";import{o as p,t as m}from"./DKqMzyyE.js";import{n as h}from"./C8h1oeAZ.js";import{PeleError as g,g as _,h as v,s as y,u as b}from"./CMikI1NP.js";var x=new Set([`label`,`type`,`descr`,`techn`,`sprite`,`tags`,`link`,`bgColor`,`fontColor`,`borderColor`,`shadowing`,`shape`,`legendText`,`legendSprite`]),S=new Set([`label`,`descr`,`techn`,`sprite`,`tags`,`link`,`textColor`,`lineColor`]);function C(e,t){let{key:n,value:r}=t;`from`in e&&(n===`offsetX`||n===`offsetY`)?e[n]=parseInt(r):(`from`in e?S:x).has(n)?e[n]=r:(e.extra??=new Map).set(n,r)}function w(e,t,n){n!==void 0&&(typeof n==`string`?e[t]=n:C(e,n))}function T(e,t,n){n===void 0?e[t]??=``:w(e,t,n)}function E(e,t){e.labelAttr=void 0,typeof t==`object`?(e.label=``,e.labelAttr=t,C(e,t)):e.label=t??``}var D=class{type=`c4`;c4Type;title;accTitle;accDescr;shapes=[];boundaries=[{alias:`global`,label:`global`,type:`global`,parent:void 0}];rels=[];shapeInRow=4;boundaryInRow=2;shapeIndex=new Map;boundaryIndex=new Map;relIndex=new Map;current=this.boundaries[0];stack=[];setC4Type(e){this.c4Type=e}setTitle(e){this.title=e}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
2
2
  `)}element(e,t,n,r){let i=typeof n==`string`?t.get(n):void 0;return i===void 0&&(i={alias:``,label:``,parent:void 0},e.push(i),typeof n==`string`?(i.alias=n,t.set(n,i)):(i.aliasAttr=n,C(i,n))),E(i,r),i}addPersonOrSystem(e,t){let n=this.element(this.shapes,this.shapeIndex,t[0],t[1]);T(n,`descr`,t[2]),this.finishShape(n,e,t,3)}addContainer(e,t){let n=this.element(this.shapes,this.shapeIndex,t[0],t[1]);T(n,`techn`,t[2]),T(n,`descr`,t[3]),this.finishShape(n,e,t,4)}addComponent(e,t){this.addContainer(e,t)}finishShape(e,t,n,r){w(e,`sprite`,n[r]),w(e,`tags`,n[r+1]),w(e,`link`,n[r+2]),e.kind=t,e.parent=this.current}boundary(e,t){let n=this.element(this.boundaries,this.boundaryIndex,e[0],e[1]);return e[2]===void 0?n.type=t:w(n,`type`,e[2]),n}open(e){e.parent=this.current,this.stack.push(this.current),this.current=e}addPersonOrSystemBoundary(e,t=`system`){let n=this.boundary(e,t);w(n,`tags`,e[3]),w(n,`link`,e[4]),this.open(n)}addContainerBoundary(e){this.addPersonOrSystemBoundary(e,`container`)}addDeploymentNode(e,t){let n=this.boundary(t,`node`);T(n,`descr`,t[3]),w(n,`sprite`,t[4]),w(n,`tags`,t[5]),w(n,`link`,t[6]),n.nodeType=e,this.open(n)}popBoundaryParseStack(){this.current=this.stack.pop()??this.boundaries[0]}addRel(e,t){let n=t[0],r=t[1];if(n===void 0||r===void 0||t[2]===void 0)return;let i=typeof n==`string`&&typeof r==`string`,a=i?this.relIndex.get(n)?.get(r):void 0;if(a===void 0){if(a={type:e,from:``,to:``,label:``},this.rels.push(a),i){let e=this.relIndex.get(n);e===void 0&&this.relIndex.set(n,e=new Map),e.set(r,a)}typeof n==`string`?a.from=n:a.fromAttr=n,typeof r==`string`?a.to=r:a.toAttr=r}a.type=e,E(a,t[2]),T(a,`techn`,t[3]),T(a,`descr`,t[4]),w(a,`sprite`,t[5]),w(a,`tags`,t[6]),w(a,`link`,t[7])}getC4Shape(e){return this.shapeIndex.get(e)??this.boundaryIndex.get(e)}updateElStyle(e,t){let n=typeof t[0]==`string`?this.getC4Shape(t[0]):void 0;n!==void 0&&(w(n,`bgColor`,t[1]),w(n,`fontColor`,t[2]),w(n,`borderColor`,t[3]),w(n,`shadowing`,t[4]),w(n,`shape`,t[5]),w(n,`sprite`,t[6]),w(n,`techn`,t[7]),w(n,`legendText`,t[8]),w(n,`legendSprite`,t[9]))}updateRelStyle(e,t){let n=t[0],r=t[1],i=typeof n==`string`&&typeof r==`string`?this.relIndex.get(n)?.get(r):void 0;if(i===void 0)return;w(i,`textColor`,t[2]),w(i,`lineColor`,t[3]);let a=t[4],o=t[5];typeof a==`string`?i.offsetX=parseInt(a):a!==void 0&&C(i,a),typeof o==`string`?i.offsetY=parseInt(o):o!==void 0&&C(i,o)}updateLayoutConfig(e,t){let n=e=>e===void 0?NaN:parseInt(typeof e==`string`?e:e.value),r=n(t[0]),i=n(t[1]);r>=1&&(this.shapeInRow=r),i>=1&&(this.boundaryInRow=i)}},O=`$end.INVALID.direction_tb.direction_bt.direction_rl.direction_lr.title.accDescription.acc_title.acc_title_value.acc_descr.acc_descr_value.acc_descr_multiline_value.NEWLINE.C4_CONTEXT.C4_CONTAINER.C4_COMPONENT.C4_DYNAMIC.C4_DEPLOYMENT.PERSON.PERSON_EXT.SYSTEM.SYSTEM_DB.SYSTEM_QUEUE.SYSTEM_EXT.SYSTEM_EXT_DB.SYSTEM_EXT_QUEUE.CONTAINER.CONTAINER_DB.CONTAINER_QUEUE.CONTAINER_EXT.CONTAINER_EXT_DB.CONTAINER_EXT_QUEUE.COMPONENT.COMPONENT_DB.COMPONENT_QUEUE.COMPONENT_EXT.COMPONENT_EXT_DB.COMPONENT_EXT_QUEUE.ENTERPRISE_BOUNDARY.SYSTEM_BOUNDARY.BOUNDARY.CONTAINER_BOUNDARY.NODE.NODE_L.NODE_R.REL.BIREL.REL_U.REL_D.REL_L.REL_R.REL_B.REL_INDEX.UPDATE_EL_STYLE.UPDATE_REL_STYLE.UPDATE_LAYOUT_CONFIG.EOF_IN_STRUCT.ATTRIBUTE_EMPTY.STR.STR_KEY.STR_VALUE.LBRACE.RBRACE.EOF`.split(`.`),k=new Map([[`C4Context`,14],[`C4Container`,15],[`C4Component`,16],[`C4Dynamic`,17],[`C4Deployment`,18],[`Person`,19],[`Person_Ext`,20],[`System`,21],[`SystemDb`,22],[`SystemQueue`,23],[`System_Ext`,24],[`SystemDb_Ext`,25],[`SystemQueue_Ext`,26],[`Container`,27],[`ContainerDb`,28],[`ContainerQueue`,29],[`Container_Ext`,30],[`ContainerDb_Ext`,31],[`ContainerQueue_Ext`,32],[`Component`,33],[`ComponentDb`,34],[`ComponentQueue`,35],[`Component_Ext`,36],[`ComponentDb_Ext`,37],[`ComponentQueue_Ext`,38],[`Enterprise_Boundary`,39],[`System_Boundary`,40],[`Boundary`,41],[`Container_Boundary`,42],[`Deployment_Node`,43],[`Node`,43],[`Node_L`,44],[`Node_R`,45],[`Rel`,46],[`BiRel`,47],[`Rel_Up`,48],[`Rel_U`,48],[`Rel_Down`,49],[`Rel_D`,49],[`Rel_Left`,50],[`Rel_L`,50],[`Rel_Right`,51],[`Rel_R`,51],[`Rel_Back`,52],[`RelIndex`,53],[`UpdateElementStyle`,54],[`UpdateRelStyle`,55],[`UpdateLayoutConfig`,56]]),A=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y],j=/[\n\r\u2028\u2029]/g,M=/title[^\S\r\n]*(?=[\r\n]|$)\s*/y;function N(e){let t=e.length,n=[],r=[],i=[],a=0,o=9,s=0,c=!1,l=-2,u=-1,d=0,f=(e,t,a)=>{n.push(e),r.push(t),i.push(a),s=a},p=n=>{for(;n<t&&v(e.charCodeAt(n));)n++;return n},m=(n,r)=>{let i=e.indexOf(n,r);return i===-1?t:i},h=(n,r)=>{let i=s+n.length;if(!e.startsWith(n,s)||!v(e.charCodeAt(i)))return!1;let a=++i;for(;i<t;){let t=e.charCodeAt(i);if(t===35||t===10||t===59)break;i++}return i!==a&&(f(r,s,i),!0)};for(;;){if(c){f(0,t,t);break}s>=t&&(c=!0);let n=e.charCodeAt(s);if(a===0){if(s>=t){f(64,t,t);continue}if(l!==-1&&s>=d&&(l<s&&(l=e.indexOf(`direction`,s)),l!==-1&&(u<s&&(j.lastIndex=s,u=j.test(e)?j.lastIndex-1:t),l<u))){let t=!1;for(let n=0;n<4&&!t;n++)A[n].lastIndex=s,A[n].test(e)&&(f(2+n,s,A[n].lastIndex),t=!0);if(t)continue;d=u}if(n===116){if(M.lastIndex=s,M.test(e)){s=M.lastIndex;continue}if(h(`title`,6))continue}if(n===97){if(h(`accDescription`,7))continue;let t=e.startsWith(`accTitle`,s);if(t||e.startsWith(`accDescr`,s)){let n=p(s+8),r=e.charCodeAt(n);if(r===58){f(t?8:10,s,p(n+1)),o=t?9:11,a=7;continue}if(r===123&&!t){s=p(n+1),a=8;continue}}}if(n===37&&e.charCodeAt(s+1)===37){let n=m(`
3
3
  `,s+2);for(;n<t&&(e.charCodeAt(n)===10||e.charCodeAt(n)===13);)n++;s=n;continue}if(v(n)){let n=s,r=-1;for(;n<t;){let t=e.charCodeAt(n);if(!v(t))break;t===10&&(r=n),n++}r===-1?s=n:f(13,s,r+1);continue}if(n===123){f(62,s,s+1);continue}if(n===125){f(63,s,s+1);continue}if(_(n)){let n=s+1;for(;n<t&&_(e.charCodeAt(n));)n++;let r=n-s<=19?k.get(e.slice(s,n)):void 0;if(r!==void 0){r>18&&(a=1),f(r,s,n);continue}}f(1,s,s);break}if(a===1){if(s>=t)f(57,t,t);else if(n===40){let t=s+1;for(;e.charCodeAt(t)===32;)t++;e.charCodeAt(t)===44?f(58,s,t+1):s++,a=2}else if(n===41)s++,a=0;else{f(1,s,s);break}}else if(a===2){if(s>=t)continue;if(n===41)s++,a=0;else if(n===44)e.charCodeAt(s+1)===44?f(58,s,s+2):s++;else{let t=s;for(;e.charCodeAt(t)===32;)t++;let n=e.charCodeAt(t);n===34?e.charCodeAt(t+1)===34?f(58,s,t+2):(s=t+1,a=3):n===36?(s=t+1,a=4):f(59,s,m(`,`,s))}}else if(a===3)n===34?(s++,a=2):f(59,s,m(`"`,s));else if(a===4)f(60,s,m(`=`,s)),a=5;else if(a===5){if(s>=t)continue;let r=s+1;if(n===61)for(;e.charCodeAt(r)===32;)r++;if(n!==61||e.charCodeAt(r)!==34){f(1,s,s);break}s=r+1,a=6}else if(a===6){if(s>=t)continue;n===34?(s++,a=2):f(61,s,m(`"`,s))}else a===7?(f(o,s,m(`
4
4
  `,s)),a=0):n===125?(s++,a=0):f(12,s,m(`}`,s))}return{types:n,starts:r,ends:i}}var P=[`person`,`external_person`,`system`,`system_db`,`system_queue`,`external_system`,`external_system_db`,`external_system_queue`,`container`,`container_db`,`container_queue`,`external_container`,`external_container_db`,`external_container_queue`,`component`,`component_db`,`component_queue`,`external_component`,`external_component_db`,`external_component_queue`],F=[`rel`,`birel`,`rel_u`,`rel_d`,`rel_l`,`rel_r`,`rel_b`,`rel`],I=[`node`,`nodeL`,`nodeR`],ee=`'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'C4_CONTEXT', 'C4_CONTAINER', 'C4_COMPONENT', 'C4_DYNAMIC', 'C4_DEPLOYMENT'`,te=`'STR', 'STR_KEY', 'ATTRIBUTE', 'ATTRIBUTE_EMPTY'`;function L(e){return e===6||e===7||e===8||e===10||e===12}function ne(e){return e>=19&&e<=56}function R(e,t){let{types:n,starts:r,ends:i}=N(e),a=0,o=t=>e.slice(r[t],i[t]),s=t=>{let i=n[a];throw i===1?y(`c4`,e,r[a],``,!0):y(`c4`,e,r[a],`Expecting ${t}, got '${O[i]}'`)},c=e=>{n[a]!==e&&s(`'${O[e]}'`),a++},l=()=>{let e=[];for(;;){let t=n[a];if(t===59)e.push(o(a++).trim());else if(t===58)e.push(``),a++;else if(t===60)a++,n[a]!==61&&s(`'STR_VALUE'`),e.push({key:o(a-1).trim(),value:o(a).trim()}),a++;else break}return e.length===0&&s(te),e},u=e=>{e===6?t.setTitle(o(a++).substring(6)):e===7?t.setAccDescription(o(a++).substring(15)):e===12?t.setAccDescription(o(a++).trim()):(a++,e===8?(n[a]!==9&&s(`'acc_title_value'`),t.setTitle(o(a++).trim())):(n[a]!==11&&s(`'acc_descr_value'`),t.setAccDescription(o(a++).trim())))},d=e=>{a++;let r=l();if(e<=26)t.addPersonOrSystem(P[e-19],r);else if(e<=32)t.addContainer(P[e-19],r);else if(e<=38)t.addComponent(P[e-19],r);else{if(e<=45)return e===39?r.splice(2,0,`ENTERPRISE`):e===40?r.splice(2,0,`SYSTEM`):e===42&&r.splice(2,0,`CONTAINER`),e>=43?t.addDeploymentNode(I[e-43],r):e===42?t.addContainerBoundary(r):t.addPersonOrSystemBoundary(r),n[a]===62?(a++,c(13)):n[a]===13?(a++,c(62),n[a]===13&&a++):s(`'NEWLINE', 'LBRACE'`),!0;e<=53?(e===53&&r.splice(0,1),t.addRel(F[e-46],r)):e===54?t.updateElStyle(`update_el_style`,r):e===55?t.updateRelStyle(`update_rel_style`,r):t.updateLayoutConfig(`update_layout_config`,r)}return!1},f=n[a];(f<14||f>18)&&s(ee),a++,c(13);let p=0,m=0;for(;;){let e=n[a];if(m===3||m===4){if(e===13){a++,m=2;continue}if(m===3&&ne(e)){m=1;continue}}else if(ne(e)){d(e)?(p++,m=1):m=4;continue}else if(L(e)&&m!==1){u(e),m=3;continue}else m!==2&&s(`'title', 'accDescription', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'PERSON', 'REL'`);if(p>0)e!==63&&s(`'NEWLINE', 'RBRACE'`),a++,t.popBoundaryParseStack(),p--,m=4;else{e!==64&&s(`'NEWLINE', 'EOF'`),a++,c(0),t.setC4Type(o(0));return}}}var z=28,B=20,V=7,H=8,U=30,W=88,G=160,re=8,ie=26,ae=e=>Math.min(12,Math.max(6,e/14)),oe=e=>Math.min(12,e/4);function K(e,t,n,r,i,a,o,s){let c=0,l=1;if(o===0){if(i<e||i>n)return 1/0}else{let t=(e-i)/o,r=(n-i)/o;c=Math.max(c,Math.min(t,r)),l=Math.min(l,Math.max(t,r))}if(s===0){if(a<t||a>r)return 1/0}else{let e=(t-a)/s,n=(r-a)/s;c=Math.max(c,Math.min(e,n)),l=Math.min(l,Math.max(e,n))}return c<=l?c:1/0}function q(e,t,n,r,i,a,o,s){let c=o/n,l=s/r,u=(i-e)/n,d=(a-t)/r,f=c*c+l*l,p=2*(c*u+l*d),m=u*u+d*d-1,h=p*p-4*f*m;if(f===0||h<0)return 1/0;let g=(-p-Math.sqrt(h))/(2*f);return g>=0&&g<=1?g:m<=0?0:1/0}function J(e,t,n,r,i){let{x:a,y:o,w:s,h:c}=e,l=r-t,u=i-n;if(e.form===`person`)return Math.min(K(a,o+ie,a+s,o+c,t,n,l,u),q(a+s/2,o+14,13,13,t,n,l,u));if(e.form===`cyl`){let e=ae(s);return Math.min(K(a,o+e,a+s,o+c-e,t,n,l,u),q(a+s/2,o+e,s/2,e,t,n,l,u),q(a+s/2,o+c-e,s/2,e,t,n,l,u))}if(e.form===`h-cyl`){let e=oe(c);return Math.min(K(a+e,o,a+s-e,o+c,t,n,l,u),q(a+e,o+c/2,e,c/2,t,n,l,u),q(a+s-e,o+c/2,e,c/2,t,n,l,u))}return K(a,o,a+s,o+c,t,n,l,u)}function se(e,t,n,r,i){for(let a=2;a<e.length;a+=2){let o=e[a-2],s=e[a-1];if(K(t,n,r,i,o,s,e[a]-o,e[a+1]-s)<=1)return!0}return!1}function Y(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.w>=t.x+t.w&&e.y+e.h>=t.y+t.h}function ce(e,t,n){let r=e.x+e.w/2,i=e.y+e.h/2,a=t.x+t.w/2,o=t.y+t.h/2,s=Y(e,t);if(s||Y(t,e)){let n=s?e:t,r=s?t:e,i=r.x+r.w/2,a=r.y+r.h/2,o=r.x-n.x,c=n.x+n.w-r.x-r.w,l=r.y-n.y,u=n.y+n.h-r.y-r.h,d=Math.min(o,c,l,u),f=d===o?n.x:d===c?n.x+n.w:i,p=d===o||d===c?a:d===u?n.y+n.h:n.y,m=Math.min(J(r,f,p,i,a),1),h=f+(i-f)*m,g=p+(a-p)*m;return s?[f,p,h,g]:[h,g,f,p]}let c=r,l=i,u=a,d=o,f=Math.max(e.x,t.x),p=Math.min(e.x+e.w,t.x+t.w),m=Math.max(e.y,t.y),h=Math.min(e.y+e.h,t.y+t.h);f<p?c=u=(f+p)/2:m<h&&(l=d=(m+h)/2);let g=Math.hypot(u-c,d-l)||1,_=-(d-l)/g*n,v=(u-c)/g*n,y=J(e,u+_,d+v,c+_,l+v),b=J(t,c+_,l+v,u+_,d+v);return y<=1&&b<=1?(c+=_,l+=v,u+=_,d+=v):(c=r,l=i,u=a,d=o,y=Math.min(J(e,u,d,c,l),1),b=Math.min(J(t,c,l,u,d),1)),[u+(c-u)*y,d+(l-d)*y,c+(u-c)*b,l+(d-l)*b]}var le=6,ue=3,de=12,fe=class{upright=[];level=[];frames=[[],[]];taken=new Map;squeezed=0;free(e,t,n,r){let i=Math.min(n,r),a=Math.max(n,r),o=(e,n)=>{for(let r=0;r<e.length;r+=3)if(Math.abs(e[r]-t)<n&&e[r+1]<a&&e[r+2]>i)return!0;return!1};return!o(e?this.upright:this.level,le)&&!o(this.frames[+!e],ue)}crossings(e){let t=0;for(let n=2;n<e.length;n+=2){let r=e[n]===e[n-2],i=r?e[n]:e[n+1],a=Math.min(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),o=Math.max(r?e[n-1]:e[n-2],r?e[n+1]:e[n]),s=r?this.level:this.upright;for(let e=0;e<s.length;e+=3)s[e]>a&&s[e]<o&&s[e+1]<i&&s[e+2]>i&&t++}return t}frame(e){this.frames[0].push(e.x,e.y,e.y+e.h,e.x+e.w,e.y,e.y+e.h),this.frames[1].push(e.y,e.x,e.x+e.w,e.y+e.h,e.x,e.x+e.w)}take(e){for(let t=2;t<e.length;t+=2)e[t]===e[t-2]?this.upright.push(e[t],Math.min(e[t-1],e[t+1]),Math.max(e[t-1],e[t+1])):e[t+1]===e[t-1]&&this.level.push(e[t+1],Math.min(e[t-2],e[t]),Math.max(e[t-2],e[t]))}ports(e,t,n,r,i){let a=this.taken.get(e)??[],o=[];for(let e=0;e<9&&o.length<4;e++){let s=n+(e&1?1:-1)*Math.ceil(e/2)*de;if(s<r||s>i)continue;let c=!0;for(let e=0;e<a.length;e+=2)a[e]===t&&Math.abs(a[e+1]-s)<de&&(c=!1);c&&o.push(s)}return o.length?o:[n]}claim(e,t,n){let r=this.taken.get(e);r?r.push(t,n):this.taken.set(e,[t,n])}};function pe(e,t,n){let r=e.length,i=Math.sign(e[2]-e[0]),a=Math.sign(e[3]-e[1]),o=`M${s(e[0]+i*t)},${s(e[1]+a*t)}`;for(let t=2;t<r-2;t+=2){let n=e[t],r=e[t+1],i=Math.sign(n-e[t-2]),a=Math.sign(r-e[t-1]),c=Math.sign(e[t+2]-n),l=Math.sign(e[t+3]-r),u=Math.min(H,Math.abs(n-e[t-2]+r-e[t-1])/2,Math.abs(e[t+2]-n+e[t+3]-r)/2);o+=`${i?`H`+s(n-i*u):`V`+s(r-a*u)}Q${s(n)},${s(r)} ${s(n+c*u)},${s(r+l*u)}`}let c=Math.sign(e[r-2]-e[r-4]),l=Math.sign(e[r-1]-e[r-3]);return o+(c?`H`+s(e[r-2]-c*n):`V`+s(e[r-1]-l*n))}function me(e,t,n,r){for(let i of t)if(i!==n&&i!==r&&se(e,i.x,i.y,i.x+i.w,i.y+i.h))return!1;return!0}function he(e,t,n,r,i){let a=e.length;return{d:pe(e,n,r),sx:e[0],sy:e[1],sdx:-Math.sign(e[2]-e[0]),sdy:-Math.sign(e[3]-e[1]),ex:e[a-2],ey:e[a-1],edx:Math.sign(e[a-2]-e[a-4]),edy:Math.sign(e[a-1]-e[a-3]),x0:e[t],y0:e[t+1],x1:e[t+2],y1:e[t+3],nx:0,ny:0,lean:0,room:G,...i,points:e}}function ge(e,t){let n=[],r=(e+t)/2,i=Math.max(V,(t-e)/4);for(let a=0;a<9;a++){let o=r+(a&1?1:-1)*Math.ceil(a/2)*i;o>=e+le&&o<=t-le&&n.push(o)}return n}function _e(e,t,n,r,i,a){let o=e.x+e.w/2,s=e.y+e.h/2,c=t.x+t.w/2,l=t.y+t.h/2,u,d=(i,a,o)=>{if(!me(i,n,e,t))return;for(let e=2;e<i.length;e+=2){let t=i[e]===i[e-2];if(!r.free(t,t?i[e]:i[e+1],t?i[e-1]:i[e-2],t?i[e+1]:i[e]))return}let s=r.crossings(i)*1e6;for(let e=2;e<i.length;e+=2)s+=Math.abs(i[e]-i[e-2])+Math.abs(i[e+1]-i[e-1]);(!u||s<u.cost)&&(u={points:i,cost:s,upright:a,sides:o})};if(e.x+e.w<=t.x||t.x+t.w<=e.x){let n=c>o,i=Math.sign(l-s),a=n?[1,0]:[0,1],f=ge(n?e.x+e.w:t.x+t.w,n?t.x:e.x);e:for(let n of r.ports(e,a[0],s+i*e.h/4,e.y+8,e.y+e.h-8))for(let s of r.ports(t,a[1],l-i*t.h/4,t.y+8,t.y+t.h-8))for(let r of f){let i=r+(o-r)*Math.min(J(e,r,n,o,n),1),l=r+(c-r)*Math.min(J(t,r,s,c,s),1),f=u;if(d([i,n,r,n,r,s,l,s],!0,a),u!==f)break e}}if(e.y+e.h<=t.y||t.y+t.h<=e.y){let n=l>s,i=Math.sign(c-o),a=n?[3,2]:[2,3],f=ge(n?e.y+e.h:t.y+t.h,n?t.y:e.y);e:for(let n of r.ports(e,a[0],o+i*e.w/4,e.x+8,e.x+e.w-8))for(let o of r.ports(t,a[1],c-i*t.w/4,t.x+8,t.x+t.w-8))for(let r of f){let i=r+(s-r)*Math.min(J(e,n,r,n,s),1),c=r+(l-r)*Math.min(J(t,o,r,o,l),1),f=u;if(d([n,i,n,r,o,r,o,c],!1,a),u!==f)break e}}if(!u)return;let{points:f,upright:p,sides:m}=u;return r.take(f),r.claim(e,m[0],p?f[1]:f[0]),r.claim(t,m[1],p?f[7]:f[6]),he(f,2,i,a,{room:p?W:G})}function ve(e,t,n,r,i,a,o){if(e===t){let t=Math.min(e.h/2-4,10),n=Math.hypot(z,t),r=e.x+e.w,i=e.y+e.h/2,c=z/n,l=t/n;return{d:`M${s(r+c*a)},${s(i-t-l*a)}C${s(r+z)},${s(i-t*2)} ${s(r+z)},${s(i+t*2)} ${s(r+c*o)},${s(i+t+l*o)}`,sx:r,sy:i-t,sdx:-c,sdy:l,ex:r,ey:i+t,edx:-c,edy:-l,x0:r+z+4,y0:i,x1:r+z+4,y1:i,nx:1,ny:0,lean:0,room:64,points:[]}}let[c,l,u,d]=ce(e,t,n),f=c===u,p=!1;if(r&&!Y(e,t)&&!Y(t,e))for(let n of r)n!==e&&n!==t&&K(n.x,n.y,n.x+n.w,n.y+n.h,c,l,u-c,d-l)<=1&&(p=!0);if(r&&p&&!f&&l!==d){let n=_e(e,t,r,i,a,o);if(n)return n;i.squeezed++}if(r&&p&&(f||l===d)){let n=n=>{let i=n?-1/0:1/0,a=e=>{let t=f?e.x:e.y;i=n?Math.max(i,t+(f?e.w:e.h)):Math.min(i,t)};a(e),a(t);for(let n of r)n!==e&&n!==t&&K(n.x,n.y,n.x+n.w,n.y+n.h,c,l,u-c,d-l)<=1&&a(n);return i},s=f?Math.min(e.y,t.y):Math.min(e.x,t.x),p=f?Math.max(e.y+e.h,t.y+t.h):Math.max(e.x+e.w,t.x+t.w),m=(n,i)=>{for(let a of r){if(a===e||a===t)continue;let r=f?a.y<p&&a.y+a.h>s:a.x<p&&a.x+a.w>s,o=f?a.x:a.y,c=o+(f?a.w:a.h);if(r&&(n?c>i:o<i))return!1}return!0},h=e.x+e.w/2,g=e.y+e.h/2,_=t.x+t.w/2,v=t.y+t.h/2,y=Math.sign(f?v-g:_-h),b=a=>{let o=n(a),s=a?1:-1,c=f?+!!a:a?3:2,l=f?i.ports(e,c,g+y*e.h/4,e.y+8,e.y+e.h-8)[0]:i.ports(e,c,h+y*e.w/4,e.x+8,e.x+e.w-8)[0],u=f?i.ports(t,c,v-y*t.h/4,t.y+8,t.y+t.h-8)[0]:i.ports(t,c,_-y*t.w/4,t.x+8,t.x+t.w-8)[0],d=n=>{if(f){let r=n+(h-n)*Math.min(J(e,n,l,h,l),1),i=n+(_-n)*Math.min(J(t,n,u,_,u),1);return[r,l,n,l,n,u,i,u]}let r=n+(g-n)*Math.min(J(e,l,n,l,g),1),i=n+(v-n)*Math.min(J(t,u,n,u,v),1);return[l,r,l,n,u,n,u,i]},p=d(o+s*B);for(let n=0;n<=4;n++){let a=o+s*(B+n*V),m=d(a);if(me(m,r,e,t)&&(p=m,i.free(f,a,l,u)))return{points:p,side:c,p0:l,p1:u,step:n}}return{points:p,side:c,p0:l,p1:u,step:5}},x=f?d>l:u<c,S=m(x,n(x)),C=m(!x,n(!x)),w=b(x),T=S===C?b(!x):void 0,E=e=>i.crossings(e.points)*8+e.step,D=C&&!S||T&&E(T)<E(w)?!x:x,{points:O,side:k,p0:A,p1:j,step:M}=D===x?w:T??b(!x),N=D?1:-1;return M>4&&i.squeezed++,i.take(O),i.claim(e,k,A),i.claim(t,k,j),he(O,2,a,o,f?{nx:N,lean:U,room:W}:{room:G})}let m=Math.hypot(u-c,d-l)||1,h=(u-c)/m,g=(d-l)/m;return(f||l===d)&&i.take([c,l,u,d]),{d:`M${s(c+h*a)},${s(l+g*a)}L${s(u-h*o)},${s(d-g*o)}`,sx:c,sy:l,sdx:-h,sdy:-g,ex:u,ey:d,edx:h,edy:g,x0:c,y0:l,x1:u,y1:d,nx:n?-g:0,ny:n?h:0,lean:0,room:Math.abs(h)>Math.abs(g)?W:G,points:[c,l,u,d]}}var ye=216,be=64,xe=14,Se=12,Ce=W+re+24,we=88,Te=B+8,X=48,Z=16,Ee=10,De=new Map([[`person`,`person`],[`box`,`rect`],[`rounded`,`rect`],[`component`,`rect`],[`cylinder`,`cyl`],[`database`,`cyl`],[`db`,`cyl`],[`queue`,`h-cyl`],[`pipe`,`h-cyl`]]);function Oe(e){let t=De.get((e.shape??``).toLowerCase())??De.get((e.sprite??``).toLowerCase());if(t)return t;if(e.tags)for(let t of e.tags.split(`,`)){let e=De.get(t.trim().toLowerCase());if(e)return e}let n=e.kind;return n.endsWith(`person`)?`person`:n.endsWith(`_db`)?`cyl`:n.endsWith(`_queue`)?`h-cyl`:`rect`}function ke(e,t,n,r,i=ye){let a=Oe(e),s=a===`h-cyl`?36:0,c=a===`person`?ie:a===`cyl`?24:0,l=i-2*xe-s,u=[o(`«`+e.kind.replace(/_/g,` `)+`»`,!1,t,r-1,l),o(e.label,!1,t,n,l,1),o(e.techn?`[${e.techn}]`:void 0,!1,t,r,l),o(e.descr,!1,t,r,l)],d=0,f=u[3].height>0?4:0;for(let e of u)d=Math.max(d,e.width),f+=e.height;return{shape:e,form:a,labels:u,textH:f,x:0,y:0,w:Math.max(i,d+2*xe+s),h:Math.max(be,f+2*Se+c)}}function Ae(e,t,n,r,i){let a=0,o=0;for(let s=0;s<e.length;s+=t){let c=Math.min(e.length,s+t),l=0,u=0;for(let t=s;t<c;t++)u=Math.max(u,e[t].h);for(let t=s;t<c;t++){let r=e[t];r.x=l,r.y=o,i&&(r.h=u),l+=r.w+n}a=Math.max(a,l-n),o+=u+r}return[a,e.length>0?o-r:0]}function je(e,t,n,r,i,a){let s=i===void 0?Te:12,c=new Map;for(let a of e.boundaries){let e=i===void 0?4e3:Math.max(80,i-2*Z-2*Te*2),l=a.parent?[o(a.label,!1,t,n,e,1),o(a.type?`[${a.type}]`:void 0,!1,t,r,e),o(a.descr,!1,t,r,e)]:[],u=0,d=0;for(let e of l)u+=e.height,d=Math.max(d,e.width);c.set(a,{boundary:a,kids:[],nodes:[],labels:l,head:u>0?u+Ee+6+B:s,headW:d,headX:Z,x:0,y:0,w:0,h:0,form:`rect`})}let l=c.get(e.boundaries[0]);for(let e of c.values()){let t=e.boundary.parent;t&&c.get(t)?.kids.push(e)}let u=[l],d=new Map([[l.boundary,0]]);for(let e=0;e<u.length;e++)for(let t of u[e].kids)d.set(t.boundary,d.get(u[e].boundary)+1),u.push(t);for(let a of e.shapes)if(a.parent){let e=d.get(a.parent)??0,o=i===void 0?ye:Math.max(100,Math.min(ye,i-2*e*s-32));c.get(a.parent)?.nodes.push(ke(a,t,n,r,o))}let f=Math.max(1,e.shapeInRow),p=Math.max(1,e.boundaryInRow),m=new Map;for(let e=u.length-1;e>=0;e--){let t=u[e],n=i===void 0?Ce:a,r=(e,t,n)=>{if(i===void 0)return t;let r=1;for(let t of e)r=Math.max(r,t.w);return Math.max(1,Math.min(t,Math.floor((i+n-2*s)/(r+n))))},[o,c]=Ae(t.nodes,r(t.nodes,f,n),n,we,!0),[d,h]=Ae(t.kids,r(t.kids,p,X),X,X,!1),g=c>0&&h>0?X:0,_=t===l?0:s;m.set(t,c+g),t.w=Math.max(o,d,t.headW+2*Z-2*_)+2*_,t.h=(_&&t.head)+c+g+h+_}let h=new Map;for(let e of u){let t=e.x+(e===l?0:s),n=e.y+(e===l?0:e.head);for(let r of e.nodes)r.x+=t,r.y+=n,h.set(r.shape,r);for(let r of e.kids)r.x+=t,r.y+=n+m.get(e);e!==l&&h.set(e.boundary,e)}return{order:u,boxes:h}}var Me=7,Q=36,Ne=24,Pe=2e3,$=8,Fe=[.5,.4,.6,.3,.7,.2,.8],Ie=2e6;function Le(e,t,n){let r=[];return e&&r.push(`fill:`+e),t&&r.push(`stroke:`+t),n&&r.push(`color:`+n),a(r)}function Re(e,t,n,r,i){return t?m(e,p(t.includes(`¶ß`)?t.replace(/\ufb02\u00b0\u00b0?/g,`#`).replace(/\u00b6\u00df/g,`;`):t),n,r,i):e}function ze(e,t,n){return c(n,r=>{if(!r)return Be(e,t,n,!1)[0];let[i,a]=Be(e,t,n,!0,Q);for(let r=Q+Ne;a>0&&r<=Q+3*Ne;r+=Ne){let[o,s]=Be(e,t,n,!0,r);s<a&&([i,a]=[o,s])}return i})}function Be(a,c,p,m,_=Q){let v=p.fontSize??16,y=Math.round(v*.8125),x=p.measurer??b(p.fontFamily,p.fontFamilyMono),S=p.padding??8,C=[],{order:w,boxes:T}=je(a,x,v,y,m?Math.max(80,(p.maxWidth??320)-2*S):void 0,_),E=w[0],D=0,O=0,k=E.w,A=E.h,j=(e,t,n,r)=>{D=Math.min(D,e),O=Math.min(O,t),k=Math.max(k,n),A=Math.max(A,r)},M=[],N=new Map;for(let e of a.rels){let t=e.fromAttr?void 0:a.getC4Shape(e.from),n=e.toAttr?void 0:a.getC4Shape(e.to),r=t&&T.get(t),i=n&&T.get(n);if(!r||!i)throw new g(`C4 rel "${e.from}" -> "${e.to}" references an unknown shape or boundary`,`semantic`,{type:`c4`});M.push(r,i);let o=N.get(r);o||N.set(r,o=new Set),o.add(i)}let P=[],F=[];for(let e of w)for(let t of e.nodes)P.push(t),F.push(t.x+$,t.y+$,t.x+t.w-$,t.y+t.h-$);let I=a.rels.length*(P.length+w.length+3*a.rels.length)<=Ie,ee=(e,t,n,r)=>{let i=0;for(let a=0;a<F.length;a+=4){let o=Math.min(n,F[a+2])-Math.max(e,F[a]);if(o<=0)continue;let s=Math.min(r,F[a+3])-Math.max(t,F[a+1]);s>0&&(i+=o*s)}return i},te=e=>e?Math.max(-Pe,Math.min(Pe,e)):0,L=``,ne=u(`arrow_point`),R=new fe;for(let e of w)e!==E&&R.frame(e);let z=a.rels.map((e,n)=>{let i=M[n*2],a=M[n*2+1],o=Le(void 0,e.lineColor,void 0),s=o.stroke?t(o.stroke):`var(--_l)`,c=e.type===`birel`||e.type===`rel_b`,l=e.type!==`rel_b`,u=ve(i,a,i!==a&&N.get(a)?.has(i)===!0?Me:0,I?P:void 0,R,c?ne:0,l?ne:0);return j(Math.min(u.x0,u.x1),Math.min(u.y0,u.y1),Math.max(u.x0,u.x1),Math.max(u.y0,u.y1)),c&&I&&F.push(u.sx-8,u.sy-8,u.sx+8,u.sy+8),l&&I&&F.push(u.ex-8,u.ey-8,u.ex+8,u.ey+8),L+=`<g class="pele-edge" data-id="${r(e.from+`-`+e.to)}"${o.line}><path d="${u.d}"/>`+(c?d(`arrow_point`,u.sx,u.sy,u.sdx,u.sdy,s):``)+(l?d(`arrow_point`,u.ex,u.ey,u.edx,u.edy,s):``)+`</g>`,u});for(let e of w){if(!I||e.headW===0)continue;let t=e.y+Ee,n=e.y+e.head-B,r=1/0;for(let i of[Z,(e.w-e.headW)/2,e.w-Z-e.headW]){let a=0;for(let r of z)se(r.points,e.x+i-4,t,e.x+i+e.headW+4,n)&&a++;if(a<r&&(r=a,e.headX=i),a===0)break}F.push(e.x+e.headX-4,t,e.x+e.headX+e.headW+4,n)}let V=``;a.rels.forEach((e,t)=>{let n=z[t],c=e.from+`-`+e.to,l=Le(void 0,void 0,e.textColor),u=(a.c4Type===`C4Dynamic`?t+1+`: `:``)+e.label,d=o(u,!1,x,y,n.room),f=o(e.techn?`[${e.techn}]`:void 0,!1,x,y,n.room,2),h=Math.max(d.width,f.width)+re,g=d.height+f.height;if(g===0)return;let _=Math.abs(n.nx)*(h/2)+Math.abs(n.ny)*(g/2)+2,v=n.lean?Math.max(0,Math.min(n.lean,_-14)):_,b=n.nx*v+(m?0:te(e.offsetX)),S=n.ny*v+(m?0:te(e.offsetY)),w=.5;if(I){let e=1/0,t=b!==n.nx*v||S!==n.ny*v;for(let r=0;r<(t?2:1)&&e>0;r++){let t=r?n.nx*v:b,i=r?n.ny*v:S;for(let r of Fe){let a=n.x0+(n.x1-n.x0)*r+t,o=n.y0+(n.y1-n.y0)*r+i,s=ee(a-h/2,o-g/2,a+h/2,o+g/2);if(s<e&&(e=s,w=r,b=t,S=i),s===0)break}}}let T=n.x0+(n.x1-n.x0)*w+b,E=n.y0+(n.y1-n.y0)*w+S-g/2;I&&F.push(T-h/2,E,T+h/2,E+g),j(T-h/2,E,T+h/2,E+g),V+=`<g class="pele-edge-label" data-id="${r(c)}">`+(e.descr?`<title>${r(e.descr)}</title>`:``)+`<rect x="${s(T-h/2)}" y="${s(E)}" width="${s(h)}" height="${s(g)}" rx="3" fill="var(--_bg)"/>`+Re(i(d,T,E+d.height/2,l.text)+i(f,T,E+d.height+f.height/2,` class="pele-c4-techn" fill="var(--_m)"${l.text}`),e.link,c,C,p)+`</g>`});let H=``,U=``;for(let e of w){if(e!==E){let t=e.boundary,i=Le(t.bgColor,t.borderColor,t.fontColor),a=e.x+e.headX,o=e.y+Ee,c=h(e.labels[0],a,o,` class="pele-cluster-label" font-weight="var(--_hw)"${i.text}`);o+=e.labels[0].height,c+=h(e.labels[1],a,o,` class="pele-c4-type" font-size="${y}" fill="var(--_m)"${i.text}`),o+=e.labels[1].height,c+=h(e.labels[2],a,o,` class="pele-c4-descr" font-size="${y}" fill="var(--_m)"${i.text}`),H+=`<g class="pele-cluster pele-c4-${t.nodeType?`node`:`boundary`}" data-id="${r(t.alias)}"><rect x="${s(e.x)}" y="${s(e.y)}" width="${s(e.w)}" height="${s(e.h)}" fill="none" stroke="var(--_b)"${t.nodeType?``:` stroke-dasharray="6 4"`}${n(i.shape)}/>`+Re(c,t.link,t.alias,C,p)+`</g>`}for(let t of e.nodes){let e=t.shape,n=e.kind.startsWith(`external`),a=Le(e.bgColor,e.borderColor,e.fontColor),o=` stroke="var(--_b)"`+(n?` stroke-dasharray="4 3"`:``),{w:c,h:l,form:u,labels:d}=t,m=u===`h-cyl`?-oe(l)/2:0,h=u===`person`?ie/2:u===`cyl`?ae(c)/2:0,g=` fill="var(--_m)"${a.text}`,_=h-t.textH/2,v=i(d[0],m,_+d[0].height/2,` class="pele-c4-type" font-size="${y-1}"${g}`);_+=d[0].height,v+=i(d[1],m,_+d[1].height/2,` class="pele-label" font-weight="var(--_hw)"${a.text}`),_+=d[1].height,v+=i(d[2],m,_+d[2].height/2,` class="pele-c4-techn" font-size="${y}"${g}`),_+=d[2].height+4,v+=i(d[3],m,_+d[3].height/2,` class="pele-c4-descr" font-size="${y}"${a.text}`),U+=`<g class="pele-node pele-shape-${u} pele-c4-${e.kind}${n?` pele-c4-external`:``}" data-id="${r(e.alias)}" transform="translate(${s(t.x+c/2)},${s(t.y+l/2)})">`+Re(f(u,c,l,` fill="var(${n?`--_bg`:`--_s`})"${o}${a.shape}`,o+a.line)+v,e.link,e.alias,C,p)+`</g>`}}let W=o(a.title,!1,x,v,m?l(p):4e3,1),G=W.height>0?W.height+12:0,K=Math.max(k-D,W.width),q=Math.ceil(K+2*S),J=Math.ceil(A-O+G+2*S),Y=S-D+(K-(k-D))/2,ce=S+G-O;return[{svg:e(`c4`,q,J,v,p,a,i(W,q/2,S+W.height/2,` class="pele-title" font-weight="var(--_tw)"`)+`<g transform="translate(${s(Y)},${s(ce)})">`+(H?`<g class="pele-clusters">${H}</g>`:``)+(L?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${L}</g>`:``)+(U?`<g class="pele-nodes">${U}</g>`:``)+(V?`<g class="pele-edge-labels" font-size="${y}">${V}</g>`:``)+`</g>`),width:q,height:J,links:C},R.squeezed]}var Ve={type:`c4`,parse(e,t,n){let r=new D;return n&&(r.title=n),R(e,r),r},render:ze};export{Ve as c4};
@@ -1,4 +1,4 @@
1
- import{_ as e,a as t,b as n,i as r,o as i,r as a,u as o,x as s}from"./DfCZPwp1.js";import{o as c,r as l}from"./DciMwFJ1.js";import{c as u,d,g as f,h as p,i as m,n as h,p as g,t as _}from"./DX4bJJO0.js";import{n as v,t as y}from"./CD6xPodA.js";import{t as b}from"./CQd9D8Nc.js";import{PeleError as x,d as S,o as C,u as ee,v as w}from"./-2Meesge.js";var T=/[─━│┃└┗├┣]/,E=/[└┗├┣]/,D=/[─━]/,O=/^[\s│┃]+$/,k=/^[\s─━│┃└┗├┣]+$/,A=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,j=/^\s*%%/,M=` `;function N(e){return e.some(e=>T.test(e))}function P(e){for(let t of e){let e=E.exec(t);if(e?.index&&e.index>0)return e.index}return 4}function F(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(e,n)=>{let r=t.get(parseInt(n,10));return r?`line ${r}`:e})}function I(e,t){let n=0;for(let r=1;r<t;r++)n=e.indexOf(`
1
+ import{_ as e,a as t,b as n,i as r,o as i,r as a,u as o,x as s}from"./C2npZzkn.js";import{o as c,r as l}from"./DciMwFJ1.js";import{c as u,d,g as f,h as p,i as m,n as h,p as g,t as _}from"./CTDYUZPz.js";import{n as v,t as y}from"./C8h1oeAZ.js";import{t as b}from"./l1LsK1sB.js";import{PeleError as x,d as S,o as C,u as ee,v as w}from"./CMikI1NP.js";var T=/[─━│┃└┗├┣]/,E=/[└┗├┣]/,D=/[─━]/,O=/^[\s│┃]+$/,k=/^[\s─━│┃└┗├┣]+$/,A=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,j=/^\s*%%/,M=` `;function N(e){return e.some(e=>T.test(e))}function P(e){for(let t of e){let e=E.exec(t);if(e?.index&&e.index>0)return e.index}return 4}function F(e,t){return e.replace(/\bline\s+(\d+)\b/gi,(e,n)=>{let r=t.get(parseInt(n,10));return r?`line ${r}`:e})}function I(e,t){let n=0;for(let r=1;r<t;r++)n=e.indexOf(`
2
2
  `,n)+1;return n}function L(e,t,n){let{line:r}=C(e,I(e,t+1));throw new x(`Line ${r}: ${n}`,`syntax`,{type:`treeView`,line:r})}function R(e,t){let n=0;for(let r=0;n<e.length&&r<t;n++)r+=e[n]===` `?4:1;return n}function z(e){let t=new Map,n=new Map;if(!T.test(e))return{text:e,lineMap:t,columns:n};let r=e.split(`
3
3
  `),i=-1;for(let e=0;e<r.length;e++)if(r[e].trim()===`treeView-beta`){i=e;break}if(i===-1)return{text:e,lineMap:t,columns:n};let a=e=>e.trim()===``||j.test(e)||A.test(e),o=[];for(let e=i+1;e<r.length;e++){let t=r[e];a(t)||O.test(t)||o.push(t.replace(/\t/g,` `))}if(!N(o))return{text:e,lineMap:t,columns:n};let s=P(o),c=[],l=(e,r,i)=>{c.push(e),t.set(c.length,r+1),i&&n.set(c.length,i)};for(let e=0;e<=i;e++)l(r[e],e);for(let t=i+1;t<r.length;t++){let n=r[t];if(a(n)){l(n,t);continue}if(O.test(n))continue;let i=n.replace(/\t/g,` `),o=E.exec(i);if(o){let r=Math.round(o.index/s)+1,a=o.index+1;for(;a<i.length&&D.test(i[a]);)a++;for(;a<i.length&&i[a]===` `;)a++;let c=i.slice(a).trimEnd();c||L(e,t,`Empty node — expected a filename or directory name after the box-drawing prefix`);let u=M.repeat(r);l(u+c,t,e=>R(n,a+Math.max(e-u.length,0)))}else{if(k.test(i))continue;T.test(i)?l(n,t):/^\s+/.test(i)?L(e,t,`Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes.`):l(n,t)}}return{text:c.join(`
4
4
  `),lineMap:t,columns:n}}function B(e,t){if(e.startsWith(`##`,t)||e.startsWith(`icon(`,t))return!0;if(!e.startsWith(`:::`,t))return!1;let n=t+3;for(;w(e.charCodeAt(n));)n++;let r=e.charCodeAt(n);return r>=65&&r<=90||r>=97&&r<=122||r===95}function V(e,t){let n=e.charCodeAt(t);if(w(n)||n===10||n===13||n===34||n===39||e.startsWith(`:::`,t)||e.startsWith(`icon(`,t)||e.startsWith(`##`,t))return-1;let r=e.length,i=t+1;for(;i<r;){let t=e.charCodeAt(i);if(t===10||t===13)break;if(w(t)){let t=i+1;for(;w(e.charCodeAt(t));)t++;if(B(e,t))break;i=t}else i++}return i}var H={name:`BARE_NAME`,pattern:/(?!:::|icon\(|##)[^ \t\n\r"'](?:(?![ \t]+:::[ \t]*[A-Za-z_]|[ \t]+icon\(|[ \t]+##)[^\n\r])*/y,match:V},U=[{...m(`treeView-beta`),longer:[H]},b(),_,g,{name:`CLASS_ANNOTATION`,pattern:/[ \t]+:::[ \t]*[A-Za-z_][\w-]*/y},{name:`ICON_ANNOTATION`,pattern:/[ \t]+icon\([\w-]*(?::[\w-]+)?\)/y},{name:`DESC_ANNOTATION`,pattern:/[ \t]+##[^\n\r]*/y},{name:`INDENTATION`,pattern:/[ \t]{1,}/y},{name:`QUOTED_NAME`,pattern:/"[^"]*"|'[^']*'/y},{name:`WS`,pattern:/[ \t]+/y,hidden:!0},{name:`ML_COMMENT`,pattern:/\%\%[^\n]*/y,hidden:!0},{name:`NL`,pattern:/\r?\n/y,hidden:!0},H];function W(e){let t=e.length;for(;t>0&&w(e.charCodeAt(t-1));)t--;return t===e.length?e:e.slice(0,t)}function G(e,t){switch(e){case`INDENTATION`:return t?.length||0;case`QUOTED_NAME`:return t.substring(1,t.length-1);case`BARE_NAME`:return W(t);case`CLASS_ANNOTATION`:return t.trim().substring(3).trim();case`ICON_ANNOTATION`:{let e=t.trim();return e.substring(5,e.length-1)}case`DESC_ANNOTATION`:return t.trim().substring(2).trim();default:return}}function K(e){let t=new p(h(e,U,`treeView`),U,`treeView`),n={$type:`TreeView`,nodes:[]};for(t.expect(0);;)if(t.kind===1)n.accDescr=u(t.take());else if(t.kind===2)n.accTitle=f(t.take());else if(t.kind===3)n.title=d(t.take());else break;for(;t.kind!==-1;){let e={$type:`TreeNode`,name:``};if(t.kind===7&&(e.indent=t.take().length),t.kind===8){let n=t.take();e.name=n.substring(1,n.length-1)}else t.kind===12?e.name=W(t.take()):t.fail(`a name`);for(;;)if(t.kind===4)e.classAnnotation=G(`CLASS_ANNOTATION`,t.take());else if(t.kind===5)e.iconAnnotation=G(`ICON_ANNOTATION`,t.take());else if(t.kind===6)e.descAnnotation=G(`DESC_ANNOTATION`,t.take());else break;n.nodes.push(e)}return n}var q=class{count=1;root={id:0,level:-1,name:`/`,nodeType:`directory`,children:[]};stack=[this.root];addNode(e,t,n,r,i,a){let o=this.stack;for(;e<=o[o.length-1].level;)o.pop();let s={id:this.count++,level:e,name:t,nodeType:n,icon:i,cssClass:r,description:a,children:[]};o[o.length-1].children.push(s),o.push(s)}};function J(e,t){for(let n of e.nodes){let e=typeof n.indent==`number`?n.indent:0,r=n.name,i=r.endsWith(`/`);i&&(r=r.slice(0,-1));let a=n.iconAnnotation;t.addNode(e,r,i?`directory`:`file`,n.classAnnotation||void 0,a===void 0?void 0:a||`none`,n.descAnnotation||void 0)}}function te(e){let{text:t,lineMap:n,columns:r}=z(e);try{return K(t)}catch(i){if(!(i instanceof x)||t===e)throw i;let a=n.get(i.line);if(a===void 0)throw i;let o=i.column>0?r.get(i.line)?.(i.column-1)??i.column-1:0,s=C(e,I(e,a)+o),c=i.message.includes(`