semiotic 3.13.2 → 3.13.3

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 (214) hide show
  1. package/README.md +47 -46
  2. package/ai/artifact-surface-inventory.json +1 -1
  3. package/ai/dist/mcp-server.js +4 -4
  4. package/ai/reference.md +23 -12
  5. package/ai/schema.json +258 -96
  6. package/ai/surface-manifest.json +1 -1
  7. package/ai/task-packets/compare-category-totals.json +5 -5
  8. package/ai/task-packets/compare-category-totals.md +2 -2
  9. package/ai/task-packets/correct-published-chart.json +5 -5
  10. package/ai/task-packets/correct-published-chart.md +2 -2
  11. package/ai/task-packets/index.json +6 -6
  12. package/ai/task-packets/update-live-chart.json +5 -5
  13. package/ai/task-packets/update-live-chart.md +2 -2
  14. package/dist/c-2YFVDRU4.min.js +1 -0
  15. package/dist/c-4OVDIXAR.min.js +1 -0
  16. package/dist/c-57IIWW46.min.js +1 -0
  17. package/dist/c-62UTMRQE.min.js +1 -0
  18. package/dist/c-6QV6F3U7.min.js +1 -0
  19. package/dist/c-7S46KBYD.min.js +2 -0
  20. package/dist/c-AJSS332Z.min.js +2 -0
  21. package/dist/c-B3X2IJRQ.min.js +1 -0
  22. package/dist/c-BLLDBVFK.min.js +38 -0
  23. package/dist/c-C7TT4J7K.min.js +1 -0
  24. package/dist/{c-ZMB3VTD4.min.js → c-CJ5GA7DM.min.js} +1 -1
  25. package/dist/c-D7YDFHLY.min.js +1 -0
  26. package/dist/{c-BR2TOCUN.min.js → c-DMDFJQU4.min.js} +1 -1
  27. package/dist/{c-JDU4Y4IW.min.js → c-FRVHZIGR.min.js} +1 -1
  28. package/dist/{c-MSZ3ZDAP.min.js → c-HAZCVHI7.min.js} +1 -1
  29. package/dist/c-HN5U72U7.min.js +1 -0
  30. package/dist/c-JA5F7ITS.min.js +1 -0
  31. package/dist/{c-ISHYKYII.min.js → c-JVZRD4GL.min.js} +1 -1
  32. package/dist/{c-OOR2LN4A.min.js → c-KJGJEOSV.min.js} +1 -1
  33. package/dist/c-M2TPZE7P.min.js +1 -0
  34. package/dist/c-OA6RJZ7S.min.js +1 -0
  35. package/dist/c-OBBSIOYU.min.js +1 -0
  36. package/dist/{c-SQQZPFVY.min.js → c-QPHM7AWW.min.js} +1 -1
  37. package/dist/{c-HOMJ3C6B.min.js → c-QSEAAHEU.min.js} +1 -1
  38. package/dist/c-RQWI623R.min.js +1 -0
  39. package/dist/{c-WFSEQ2XG.min.js → c-RWFADOKS.min.js} +1 -1
  40. package/dist/{c-SDGGMIYI.min.js → c-TJGC5JEM.min.js} +1 -1
  41. package/dist/{c-H5THWQI4.min.js → c-TOXWQRXS.min.js} +3 -3
  42. package/dist/c-VBDWHTC7.min.js +1 -0
  43. package/dist/c-VBIPDCE7.min.js +1 -0
  44. package/dist/c-WTNRBWZZ.min.js +51 -0
  45. package/dist/{c-3GIPT46Z.min.js → c-XG4LL2VI.min.js} +1 -1
  46. package/dist/c-XPNBS3W2.min.js +1 -0
  47. package/dist/c-XT3G3YWU.min.js +1 -0
  48. package/dist/c-ZP6O6UHV.min.js +1 -0
  49. package/dist/c-ZVL7ULNH.min.js +1 -0
  50. package/dist/components/ChartErrorBoundary.d.ts +5 -1
  51. package/dist/components/ai/intentWeights.d.ts +22 -0
  52. package/dist/components/ai/streamSchema.d.ts +98 -0
  53. package/dist/components/ai/streamingTypes.d.ts +27 -4
  54. package/dist/components/ai/suggestCharts.d.ts +10 -2
  55. package/dist/components/ai/suggestStreamCharts.d.ts +60 -13
  56. package/dist/components/ai/suggestStreamDashboard.d.ts +9 -1
  57. package/dist/components/charts/network/processSankey/frameMargins.d.ts +1 -1
  58. package/dist/components/charts/network/processSankey/labelPlacement.d.ts +1 -1
  59. package/dist/components/charts/physics/physicsHocUtils.d.ts +1 -1
  60. package/dist/components/charts/realtime/RealtimeAccumulator.d.ts +7 -0
  61. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +9 -2
  62. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +13 -1
  63. package/dist/components/charts/realtime/RealtimeLineChart.types.d.ts +5 -1
  64. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +5 -1
  65. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +7 -1
  66. package/dist/components/charts/realtime/TemporalHistogram.capability.d.ts +5 -3
  67. package/dist/components/charts/realtime/aggregate.d.ts +11 -12
  68. package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +9 -0
  69. package/dist/components/charts/realtime/eventTime.d.ts +7 -1
  70. package/dist/components/charts/realtime/useRealtimeLineIngestion.d.ts +13 -0
  71. package/dist/components/charts/shared/ChartError.d.ts +4 -6
  72. package/dist/components/charts/shared/GaugeReadout.d.ts +39 -4
  73. package/dist/components/charts/shared/axisExtent.d.ts +2 -1
  74. package/dist/components/charts/shared/chartMode.d.ts +2 -2
  75. package/dist/components/charts/shared/gaugeLayout.d.ts +69 -0
  76. package/dist/components/charts/shared/types.d.ts +3 -0
  77. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +3 -0
  78. package/dist/components/charts/shared/useStreamStatus.d.ts +2 -2
  79. package/dist/components/charts/shared/withChartErrorBoundary.d.ts +14 -0
  80. package/dist/components/charts/xy/Scatterplot.streamCapability.d.ts +2 -0
  81. package/dist/components/charts/xy/WaterfallChart.d.ts +2 -0
  82. package/dist/components/charts/xy/WaterfallIndex.d.ts +12 -0
  83. package/dist/components/charts/xy/lineGapStrategy.d.ts +15 -3
  84. package/dist/components/legendGeometry.d.ts +148 -0
  85. package/dist/components/legendLayout.d.ts +20 -38
  86. package/dist/components/realtime/ReorderBuffer.d.ts +14 -0
  87. package/dist/components/realtime/SlidingExtent.d.ts +18 -0
  88. package/dist/components/realtime/WindowAccumulator.d.ts +5 -1
  89. package/dist/components/realtime/renderers/types.d.ts +1 -0
  90. package/dist/components/realtime/renderers/waterfallRenderer.d.ts +1 -1
  91. package/dist/components/recipes/compositional/edgeRouting.d.ts +9 -0
  92. package/dist/components/recipes/compositional/metrics.d.ts +2 -2
  93. package/dist/components/recipes/compositional/projection.d.ts +3 -1
  94. package/dist/components/recipes/compositional/routing.d.ts +3 -1
  95. package/dist/components/recipes/compositional/testFixtures.d.ts +4 -0
  96. package/dist/components/recipes/compositional/topology.d.ts +2 -0
  97. package/dist/components/recipes/compositional/types.d.ts +10 -1
  98. package/dist/components/recipes/compositional/useCompositionalInterfaces.d.ts +20 -0
  99. package/dist/components/semiotic-ai-core.d.ts +3 -2
  100. package/dist/components/semiotic-ai-stream.d.ts +3 -2
  101. package/dist/components/semiotic-recipes-react.d.ts +2 -0
  102. package/dist/components/semiotic-utils-core.d.ts +2 -0
  103. package/dist/components/server/serverChartConfigHeatmap.d.ts +13 -0
  104. package/dist/components/server/staticLegend.d.ts +5 -0
  105. package/dist/components/server/staticLegendText.d.ts +13 -0
  106. package/dist/components/server/staticSVGChrome.d.ts +2 -2
  107. package/dist/components/stream/DataSourceAdapter.d.ts +15 -62
  108. package/dist/components/stream/FrameRuntime.d.ts +3 -0
  109. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  110. package/dist/components/stream/IngestActivity.d.ts +9 -0
  111. package/dist/components/stream/NetworkPipelineStore.d.ts +3 -1
  112. package/dist/components/stream/OrdinalPipelineStore.d.ts +5 -2
  113. package/dist/components/stream/OrdinalSVGOverlay.d.ts +1 -1
  114. package/dist/components/stream/PipelineStore.d.ts +8 -3
  115. package/dist/components/stream/accessibleDataRows.d.ts +1 -0
  116. package/dist/components/stream/axisTickUtils.d.ts +25 -5
  117. package/dist/components/stream/frameDefaultMargins.d.ts +26 -4
  118. package/dist/components/stream/frameKeyboardNavigation.d.ts +8 -1
  119. package/dist/components/stream/geoTypes.d.ts +2 -0
  120. package/dist/components/stream/graphKeyboardNavigation.d.ts +4 -2
  121. package/dist/components/stream/hitTestUtils.d.ts +7 -0
  122. package/dist/components/stream/keyboardNav.d.ts +3 -1
  123. package/dist/components/stream/navigationGraph.d.ts +10 -3
  124. package/dist/components/stream/networkFrameKeyboardNavigation.d.ts +2 -0
  125. package/dist/components/stream/networkNavGroups.d.ts +3 -0
  126. package/dist/components/stream/networkPipelineConfig.d.ts +1 -0
  127. package/dist/components/stream/networkSceneTypes.d.ts +10 -0
  128. package/dist/components/stream/networkSpatialNavigation.d.ts +3 -0
  129. package/dist/components/stream/networkTypes.d.ts +2 -0
  130. package/dist/components/stream/ordinalAxisTicks.d.ts +27 -0
  131. package/dist/components/stream/ordinalSceneBuilders/pieScene.d.ts +10 -0
  132. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
  133. package/dist/components/stream/ordinalTypes.d.ts +11 -2
  134. package/dist/components/stream/pipelineBufferUtils.d.ts +9 -0
  135. package/dist/components/stream/pipelineConfig.d.ts +7 -0
  136. package/dist/components/stream/pipelineDomainResolution.d.ts +3 -2
  137. package/dist/components/stream/roundScaleDomain.d.ts +9 -0
  138. package/dist/components/stream/stalenessBands.d.ts +1 -1
  139. package/dist/components/stream/svgOverlayUtils.d.ts +12 -0
  140. package/dist/components/stream/types.d.ts +10 -2
  141. package/dist/components/stream/useFrame.d.ts +7 -4
  142. package/dist/components/stream/useOrdinalFrameHandle.d.ts +4 -14
  143. package/dist/components/stream/useStalenessCheck.d.ts +5 -3
  144. package/dist/components/stream/useStreamingDataHandle.d.ts +24 -0
  145. package/dist/components/stream/useXYFrameHandle.d.ts +4 -14
  146. package/dist/components/stream/xyDateTicks.d.ts +33 -4
  147. package/dist/components/stream/xyFrameAxisTypes.d.ts +2 -0
  148. package/dist/components/stream/xyPlugins/registry.d.ts +7 -0
  149. package/dist/components/stream/xySceneBuilders/heatmapScene.d.ts +11 -2
  150. package/dist/components/stream/xySceneBuilders/types.d.ts +4 -0
  151. package/dist/components/types/legendTypes.d.ts +12 -1
  152. package/dist/geo.min.js +155 -152
  153. package/dist/geo.module.min.js +1 -1
  154. package/dist/network.module.min.js +1 -1
  155. package/dist/ordinal.module.min.js +1 -1
  156. package/dist/physics.module.min.js +1 -1
  157. package/dist/processSankeyLayoutWorker.js +1 -1
  158. package/dist/semiotic-ai-core.d.ts +3 -2
  159. package/dist/semiotic-ai-core.min.js +5 -5
  160. package/dist/semiotic-ai-core.module.min.js +4 -4
  161. package/dist/semiotic-ai.module.min.js +2 -2
  162. package/dist/semiotic-artifact.min.js +6 -6
  163. package/dist/semiotic-artifact.module.min.js +5 -5
  164. package/dist/semiotic-atlas-selection.module.min.js +1 -1
  165. package/dist/semiotic-atlas.module.min.js +1 -1
  166. package/dist/semiotic-client-cjs-shared.min.js +1022 -1018
  167. package/dist/semiotic-client-compositional.module.min.js +1 -1
  168. package/dist/semiotic-client-shared.module.min.js +1 -1
  169. package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
  170. package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
  171. package/dist/semiotic-line.module.min.js +1 -1
  172. package/dist/semiotic-realtime-core.module.min.js +1 -1
  173. package/dist/semiotic-realtime-react.module.min.js +1 -1
  174. package/dist/semiotic-recipes-core-cjs-base.min.js +101 -101
  175. package/dist/semiotic-recipes-core.module.min.js +1 -1
  176. package/dist/semiotic-recipes-react.d.ts +2 -0
  177. package/dist/semiotic-recipes-react.min.js +8 -8
  178. package/dist/semiotic-server-edge-node.module.min.js +3 -3
  179. package/dist/semiotic-server-edge.min.js +399 -394
  180. package/dist/semiotic-server-edge.module.min.js +3 -3
  181. package/dist/semiotic-server-node.min.js +399 -394
  182. package/dist/semiotic-utils-core.d.ts +2 -0
  183. package/dist/semiotic-utils-core.min.js +11 -11
  184. package/dist/semiotic-utils-core.module.min.js +3 -3
  185. package/dist/semiotic-value.module.min.js +1 -1
  186. package/dist/semiotic.module.min.js +1 -1
  187. package/dist/server.min.js +399 -394
  188. package/dist/server.module.min.js +3 -3
  189. package/dist/xy.module.min.js +1 -1
  190. package/package.json +11 -11
  191. package/dist/c-27SDQN3J.min.js +0 -1
  192. package/dist/c-2N7IU2NY.min.js +0 -1
  193. package/dist/c-4EUQNA7N.min.js +0 -2
  194. package/dist/c-5EPR4KFB.min.js +0 -1
  195. package/dist/c-5KZ3NO6X.min.js +0 -1
  196. package/dist/c-7UN2WUMI.min.js +0 -1
  197. package/dist/c-BRBTXINY.min.js +0 -1
  198. package/dist/c-C3Z7ZRAA.min.js +0 -1
  199. package/dist/c-C4WRRUZ5.min.js +0 -1
  200. package/dist/c-CXDAWBOW.min.js +0 -1
  201. package/dist/c-DJ6DT5BL.min.js +0 -51
  202. package/dist/c-DNBFFE3P.min.js +0 -1
  203. package/dist/c-HR5AH3MA.min.js +0 -1
  204. package/dist/c-HTL37JCD.min.js +0 -1
  205. package/dist/c-JS2D7A2P.min.js +0 -1
  206. package/dist/c-L6OT4OVA.min.js +0 -1
  207. package/dist/c-NB2UEX5C.min.js +0 -1
  208. package/dist/c-OU7A3IUL.min.js +0 -1
  209. package/dist/c-PNLTF6YG.min.js +0 -37
  210. package/dist/c-QVKOXC3S.min.js +0 -1
  211. package/dist/c-SIQVOV6A.min.js +0 -1
  212. package/dist/c-TBMFC5CR.min.js +0 -1
  213. package/dist/c-XF5ILLBG.min.js +0 -1
  214. package/dist/c-YQHGEETR.min.js +0 -2
@@ -1,168 +1,168 @@
1
1
  "use strict";function e(e,t){let n=1/0,o=-1/0;for(const r of e){const e=t?t(r):r;e<n&&(n=e),e>o&&(o=e)}return[n,o]}function t(e,t=1/0){let n=t;for(const t of e)t<n&&(n=t);return n}function n(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function o(e,t=[],n){const o=void 0===n?void 0:new Set("string"==typeof n?[n]:n),r=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&o?.has(e.partition)),i=new Set(r.map(e=>e.id)),s=new Set(r.map(e=>e.entityId)),a=/* @__PURE__ */new Map;let c=0;for(const t of e){if(void 0!==n&&"string"==typeof t.roles.occurrence&&!i.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===n&&(c+=t.entityCount);for(const[t,o]of e)(void 0===n||s.has(t))&&a.set(t,o)}return[...a.values()].reduce((e,t)=>e+t,c)}function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function i(e,t){return r(e,t)?e[t]:void 0}function s(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function a(){/* @__PURE__ */
2
- return Object.create(null)}function c(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function l(e,t,n){return t.has(e)?"node":i(n.nodeIdsBySection,e)?"section":"global"}function d(e,t,n){const o=[],r=new Set(t.nodes.map(e=>e.id)),c=/* @__PURE__ */new Set;for(const s of t.measureValues){const t=i(e.measures,s.measureId);if(!t)continue;const a=l(s.subjectId,r,n);o.push({measureId:s.measureId,subjectId:s.subjectId,subjectKind:a,value:s.value,status:s.status,unitKind:t.unitKind,countUnit:t.countUnit,timeDenominator:t.timeDenominator}),"section"===a&&c.add(JSON.stringify([s.measureId,s.subjectId]))}const d=a();for(const e of t.nodes)s(d,e.id,e);const u=/* @__PURE__ */new Map;for(const e of o){if("node"!==e.subjectKind)continue;const t=d[e.subjectId];if(!t?.sectionId)continue;const n=JSON.stringify([e.measureId,t.sectionId]);if(c.has(n))continue;const o=u.get(n);o?(o.value+=e.value,Td[e.status]>Td[o.status]&&(o.status=e.status)):u.set(n,{...e,subjectId:t.sectionId,subjectKind:"section"})}for(const e of u.values())o.push(e);return{entries:o}}function u(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function h(e){const t=e.spec.comparison;if(!t)return;const n=t.partitions.map(n=>{const r=u(e.ledger,t.denominatorMeasureId,n)?.value??0,i={};return i["repeated-state-episode"]=o(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,n),{partition:n,assigned:r,motifUsers:i,outcomes:{purchases:u(e.ledger,"purchases",n)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:n}}function p(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return u(e.ledger,n,t)?.value}function f(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function m(e,t){const n=a();for(const t of e.nodes)s(n,t.id,t.completeness??"known");const o=a();for(const e of t.unsupportedTemplates)s(o,e,"unsupported-template");if(t.incompleteCandidates.length>0){const e=new Set(t.incompleteCandidates.map(e=>e.template));for(const t of e)s(o,t,"incomplete")}const r=t.matches.find(e=>e.truncation),i={nodes:n,motifs:o,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return r?.truncation&&(i.truncation={disclosed:!0,template:r.template,omitted:r.truncation.omitted}),i}function g(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}function y(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}function x(e){const t=e.nodes.map(e=>e.id).sort(),n=new Map(t.map((e,t)=>[e,t])),o=t.map(()=>[]),r=t.map(()=>[]);for(const t of e.edges){const e=n.get(t.source),i=n.get(t.target);o[e].push(i),r[i].push(e)}const i=/* @__PURE__ */new Set,s=[];for(const e of y(o,t.map((e,t)=>t)).reverse()){if(i.has(e))continue;const n=[],o=[e];for(i.add(e);o.length;){const e=o.pop();n.push(t[e]);for(const t of r[e])i.has(t)||(i.add(t),o.push(t))}s.push(n.sort())}return s.sort((e,t)=>e[0].localeCompare(t[0]))}function b(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=g(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),d=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!d.has(e.id)).map(e=>e.id)}}}function w(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}function M(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return Boolean(o?.sectionId&&t.coordinate.sectionIds.includes(o.sectionId))}function v(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function k(e,t){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return b(t,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const n=t.edges.map(e=>e.id),o=e.forest.display.rankingPolicyId??"main-transport",{mode:r,order:i}=w(o),c=n=>M(t,e,n.source)&&M(t,e,n.target),l=/* @__PURE__ */new Map;for(const e of t.nodes)l.set(e.id,[]);for(const e of t.edges)l.has(e.target)||l.set(e.target,[]),l.get(e.target).push(e);const d=a(),u=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:t.nodes[0]?[t.nodes[0].id]:[],h=new Set(u);for(const e of t.nodes){if(h.has(e.id))continue;const t=v(l.get(e.id)??[],i),n=t.find(e=>c(e))??t[0];n&&s(d,e.id,n.id)}let p;p="tree-only"===r?Object.values(d):t.edges.filter(e=>c(e)).map(e=>e.id);const f=new Set(p),m=n.filter(e=>!f.has(e));return{forest:{kind:"rooted-backbone",roots:[...u],rankingPolicyId:o,backboneEdgeIds:p,primaryParentEdgeIdByNode:d},residual:{residualEdgeIds:m,originalEdgeIds:n}}}function I(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw new Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw new Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw new Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw new Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw new Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw new Error("original edge IDs != backbone ⊎ residual")}function S(e){const t=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),n=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),o=/* @__PURE__ */new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=/* @__PURE__ */new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}function $(e,t){return e.sectionByNode.get(t)}function N(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){const t=$(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function E(e,t,n){return e.pairs.get(t)?.get(n)??[]}function A(e){return e.entityCount??1}function C(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=A(r));return{entityIds:n,entityCount:o}}function O(e,t){return null==t||e.length<=t?{kept:e}:{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}}function T(e,t,n,o,r,i){if(n.length<2)return;const{kept:s,truncation:c}=O(n,i),l=[t,...s],d=[];for(const n of s){const o="fan-out"===e?E(r,t,n):E(r,n,t);d.push(...o)}const u=N(r,[t,...n]),h=C(o.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:s}:{destination:t,sources:s},nodePath:l,edgeIds:d,startSectionId:u[0],completionSectionId:u[u.length-1],intersectSectionIds:u,entityIds:h.entityIds,entityWeights:a(),entityCount:h.entityCount,flags:{occurrence:h.entityIds.length>0,temporal:!1,trajectorySupported:h.entityIds.length>0,enriched:!1},truncation:c}}function P(e,t,n){return 1===t.length&&1===n.length}function R(e,t){const n=t.incoming,o=t.outgoing,r=[];for(const i of e.nodes){const s=n.get(i.id)??[],c=o.get(i.id)??[];if(1!==c.length)continue;const l=1===s.length&&P(s[0],n.get(s[0])??[],o.get(s[0])??[]);if(P(i.id,s,c)&&l)continue;const d=[i.id];let u=i.id;const h=/* @__PURE__ */new Set([u]);for(;;){const e=(o.get(u)??[])[0];if(!e||h.has(e))break;if(d.push(e),h.add(e),!P(0,n.get(e)??[],o.get(e)??[]))break;u=e}if(d.length<2)continue;const p=[];for(let e=0;e<d.length-1;e++)p.push(...E(t,d[e],d[e+1]));const f=N(t,d),m=C(e.occurrences??[],d[0]);r.push({id:`serial-chain:${d.join(">")}`,template:"serial-chain",roles:{nodes:d,start:d[0],end:d[d.length-1]},nodePath:d,edgeIds:p,startSectionId:f[0],completionSectionId:f[f.length-1],intersectSectionIds:f,entityIds:m.entityIds,entityWeights:a(),entityCount:m.entityCount,flags:{occurrence:m.entityIds.length>0,temporal:!1,trajectorySupported:m.entityIds.length>0,enriched:!1}})}return r}function j(e,t){const n=t.occurrences??[];if(0!==n.length)for(const t of e){if("repeated-state-episode"===t.template)continue;const e=t.nodePath,o=a();for(const t of n)t.missingPrehistory||e.some(e=>t.nodePath.includes(e))&&s(o,t.entityId,A(t));const r=Object.keys(o);t.entityIds=r,t.entityWeights=o,t.entityCount=r.reduce((e,t)=>e+(o[t]??0),0),t.flags={...t.flags,occurrence:r.length>0,trajectorySupported:r.length>0}}}function F(e,t){const n=[];for(const o of e.occurrences??[]){if(o.missingPrehistory)continue;const e=/* @__PURE__ */new Map,r=/* @__PURE__ */new Set;for(const[i,c]of o.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,i);continue}if(r.has(c))continue;r.add(c);const d=o.nodePath.slice(l,i+1),u=N(t,d),h=a();s(h,o.entityId,A(o)),n.push({id:`repeated-state-episode:${o.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:o.id},nodePath:d,edgeIds:[],startSectionId:$(t,d[0]),completionSectionId:$(t,d[d.length-1]),intersectSectionIds:u,entityIds:[o.entityId],entityWeights:h,entityCount:A(o),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return n}function L(e,t){const n=e.motifs.matchBudget,o=S(t),r=[];for(const e of t.nodes){const i=T("fan-out",e.id,o.outgoing.get(e.id)??[],t,o,n);i&&r.push(i);const s=T("fan-in",e.id,o.incoming.get(e.id)??[],t,o,n);s&&r.push(s)}r.push(...R(t,o)),r.push(...F(t,o)),j(r,t);const i=[];for(const e of t.occurrences??[])e.missingPrehistory&&(i.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),i.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const s=Rd.filter(e=>!Fd.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:r,incompleteCandidates:i,unsupportedTemplates:s}}function z(e){return e.entityCount??1}function D(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function _(e,t={}){function n(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const o={id:"",stateId:"",prefix:[],children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map};for(const t of e){if(t.missingPrehistory)continue;const e=z(t);let n=o;n.occurrenceIds.push(t.id),n.entityCount+=e,D(n,t.partition,e);for(const o of t.nodePath){const r=[...n.prefix,o],i=c(r,r.length-1);let s=n.children.get(o);s||(s={id:i,stateId:o,prefix:r,children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map},n.children.set(o,s)),s.occurrenceIds.push(t.id),s.entityCount+=e,D(s,t.partition,e),n=s}}const r=[],i=[],l=t.referencePartition;return function e(t,o){if(t.id){const e=a();for(const[n,o]of t.partitionCounts)s(e,n,o);r.push({id:t.id,stateId:t.stateId,prefix:t.prefix,parentId:o,childIds:n(t).map(e=>t.children.get(e).id),entityCount:t.entityCount,occurrenceIds:[...t.occurrenceIds],partitionCounts:e}),i.push(t.id)}for(const o of n(t))e(t.children.get(o),t.id||null)}(o,null),{kind:"observed-prefix",rootIds:n(o).map(e=>o.children.get(e).id),nodes:r,order:i,referencePartition:l}}function W(e,t){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:a()};const n=a();for(const t of e.coordinate.sectionIds)s(n,t,[]);for(const e of t.nodes){if(!e.sectionId)continue;const t=n[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:n}}function q(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}function G(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;o<e.length-1;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}function B(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=y(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),d=/* @__PURE__ */new Map([[r,r]]),u=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=d.get(e):t=d.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>d.has(e)).reduce(u);d.get(e)!==t&&(d.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>d.has(t)?[[e,d.get(t)===r?null:n[d.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>d.has(t)),unreachableNodeIds:n.filter((e,t)=>!d.has(t))}}function Y(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof Date||e instanceof Map||e instanceof Set)}function V(e,t){return Array.isArray(t)?t.includes(e):"strings"===t?Array.isArray(e)&&Array.from(e).every(e=>"string"==typeof e):"object"===t?Y(e):"count"===t||"budget"===t?"number"==typeof e&&Number.isFinite(e)&&e>=0&&("budget"!==t||Number.isSafeInteger(e)):typeof e===t}function H(e,t){const n=[],o=(e,t,o)=>{n.push({kind:e,severity:"fatal",message:`${t} must be ${o}`})},r=(e,t,n)=>{if(!Y(e))return o(n,n,"an object"),!1;for(const[r,i]of Object.entries(t)){const t=r.endsWith("?"),s=t?r.slice(0,-1):r;t&&void 0===e[s]||V(e[s],i)||o(n,s,Array.isArray(i)?i.join(" or "):String(i))}return!0};if(!r(e,{relations:"object",coordinate:"object",forest:"object",measures:"object",motifs:"object",temporal:"object",dataRevision:"string",evidencePolicyId:"string"},"input-shape")||!r(t,{graphRef:"string",revision:"string"},"source-shape")||n.length)return n;const i=e,s=t,{coordinate:a,forest:c,measures:l,motifs:d,temporal:u}=i;"ordinal"===a.kind&&r(a,{sectionIds:"strings"},"coordinate"),r(c.display,{"roots?":"strings","rankingPolicyId?":"string","referencePartition?":"string"},"forest")&&"rooted-backbone"===c.display.kind&&(r(c.display,{roots:"strings"},"missing-root"),r(c.display,{rankingPolicyId:"string"},"forest")),void 0!==c.requiredPaths&&r(c.requiredPaths,{roots:"strings"},"required-path-roots"),void 0!==i.comparison&&r(i.comparison,{partitions:"strings",denominatorMeasureId:"string","referencePartition?":"string"},"comparison");for(const e of Object.values(l))r(e,{unitKind:["stock","rate","capacity"],countUnit:Ld,"timeDenominator?":"string","description?":"string"},"measures");r(d,{catalogId:"string",catalogVersion:"string",countUnit:Ld,anchor:["completion"],"denominatorRef?":"string","timeWindowMs?":"count","matchBudget?":"budget"},"motifs"),r(u,{kind:["snapshot","window"]},"temporal"),"window"!==u.kind||Number.isFinite(u.start)&&Number.isFinite(u.end)&&!(u.end<u.start)||o("temporal","window bounds","finite and ordered");for(const e of["nodes","edges","measureValues","occurrences"]){const t=s[e];if("occurrences"===e&&void 0===t)continue;if(!Array.isArray(t)){o("source-shape",e,"an array");continue}const n="nodes"===e?{id:"string","sectionId?":"string","completeness?":["known","unknown","incomplete","truncated","unsupported-template"]}:"edges"===e?{id:"string",source:"string",target:"string"}:"measureValues"===e?{measureId:"string",subjectId:"string",status:["exact","estimated","unknown","incomplete"]}:{id:"string",entityId:"string",complete:"boolean","missingPrehistory?":"boolean","entityCount?":"count","partition?":"string"};for(const i of t)r(i,n,"occurrences"===e?"occurrence":"source-shape")&&"occurrences"===e&&(r(i,{nodePath:"strings"},"occurrence-node"),void 0===i.groupKeys||Y(i.groupKeys)&&!Object.values(i.groupKeys).some(e=>"string"!=typeof e)||o("occurrence","groupKeys","a string map"))}return n}function U(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function X(e,t){const n=H(e,t);if(n.length)return{ok:!1,issues:n};e.schemaVersion!==Pd&&U(n,"schema-version",`expected schemaVersion ${Pd}`),!0===e.relations.directed&&!0===e.relations.edgeIdRequired&&"keep-by-id"===e.relations.parallelEdges&&"keep-by-id"===e.relations.selfLoops||U(n,"relations","Phase 1 requires directed edges, preserving parallel edges and self-loops by id"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&U(n,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&U(n,"coordinate","Phase 1 kernel uses ordinal sections");const o=a();for(const r of t.nodes)r.id?(o[r.id]&&U(n,"duplicate-node","duplicate node id",r.id),s(o,r.id,!0),"ordinal"===e.coordinate.kind&&r.sectionId&&!e.coordinate.sectionIds.includes(r.sectionId)&&U(n,"section-membership",`node section ${r.sectionId} is not in the coordinate`,r.id)):U(n,"node-id","node is missing id");const r=a();for(const e of t.edges)e.id?(r[e.id]&&U(n,"duplicate-edge","duplicate edge id",e.id),s(r,e.id,!0),o[e.source]||U(n,"dangling-source","edge source is not a node",e.id),o[e.target]||U(n,"dangling-target","edge target is not a node",e.id)):U(n,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])o[t]||U(n,"missing-root","display root is not a node",t);const c=e.forest.requiredPaths;if(c)if("directed-admitted"!==c.relationScopeId&&U(n,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(c.roots)&&0!==c.roots.length)for(const e of c.roots)o[e]||U(n,"required-path-roots","required-path root is not a node",e);else U(n,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&U(n,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(e.comparison.partitions.length<2&&U(n,"comparison","comparison requires at least two partitions"),i(e.measures,e.comparison.denominatorMeasureId)||U(n,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(l=e.measures)||"object"!=typeof l||Array.isArray(l))U(n,"measures","measures must be an object");else for(const[t,o]of Object.entries(e.measures))"rate"!==o.unitKind||o.timeDenominator||U(n,"rate-denominator","rate measures require a timeDenominator",t);var l;const d=/* @__PURE__ */new Map;for(const o of t.measureValues){let t=d.get(o.measureId);t||(t=/* @__PURE__ */new Set,d.set(o.measureId,t)),t.has(o.subjectId)&&U(n,"duplicate-measure-value","measureValue must be unique per measureId and subjectId",o.subjectId),t.add(o.subjectId),i(e.measures,o.measureId)?Number.isFinite(o.value)||U(n,"non-finite-measure","measure value is not finite",o.measureId):U(n,"unknown-measure","measureValue refers to an undeclared measure",o.measureId)}const u=/* @__PURE__ */new Set;for(const e of t.occurrences??[])if(e.id&&e.entityId){u.has(e.id)&&U(n,"duplicate-occurrence","occurrence id must be unique",e.id),u.add(e.id),void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||e<0)||U(n,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)o[t]||U(n,"occurrence-node","occurrence path references a missing node",e.id)}else U(n,"occurrence","occurrence needs id and entityId");return{ok:n.every(e=>"fatal"!==e.severity),issues:n}}function K(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function J(e,t,n={}){const o=X(e,t);if(!o.ok)return{ok:!1,issues:o.issues};if(!Y(n)||void 0!==n.generation&&(!Number.isSafeInteger(n.generation)||n.generation<0))return{ok:!1,issues:[{kind:"generation",severity:"fatal",message:"generation must be a nonnegative safe integer"}]};const r=n.generation??1;let i;try{i=K(e,t,r)}catch{return{ok:!1,issues:[{kind:"spec-serialization",severity:"fatal",message:"atlas spec must be serializable as JSON"}]}}const s=W(e,t),a=L(e,t),c=k(e,t);I(c.residual,c.forest);const l=d(e,t,s),u=m(t,a),p=G(t),f="observed-prefix"===e.forest.display.kind||(t.occurrences?.length??0)>0?_(t.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,g={sourceGraphRef:t.graphRef,analysisRevision:i,spec:e,source:t,sections:s,motifs:a,forest:c.forest,residualEdges:c.residual,ports:p,ledger:l,completeness:u,provenance:{sourceRevision:t.revision,analysisRevision:i,generation:r,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?`ordinal:${e.coordinate.sectionIds.join(",")}`:`numeric:${e.coordinate.field}`,forestRoots:[...e.forest.display.roots??c.forest.roots],rankingPolicyId:c.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:f,...e.forest.requiredPaths&&{requiredPaths:B(t,e.forest.requiredPaths)}};return g.comparison=h(g),{ok:!0,atlas:g,issues:o.issues}}function Z(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function Q(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.has(e.template)).map(e=>{const t="string"==typeof e.roles.state?e.roles.state:e.nodePath[0],n=e.nodePath[e.nodePath.length-1];return{id:`capsule:${e.id}`,matchId:e.id,template:e.template,entryState:t,exitState:n,entityCount:e.entityCount,occurrenceIds:Z(e),selected:!1}}).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=/* @__PURE__ */new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}function ee(e,t={}){const n=t.templates??["repeated-state-episode"],r="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],i=void 0!==t.partition?p(e,t.partition)??0:e.spec.comparison?e.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:e.ledger.entries.find(t=>"global"===t.subjectKind&&t.measureId===e.spec.motifs.denominatorRef)?.value??0,s=n=>o(n,e.source.occurrences,t.partition??e.spec.comparison?.partitions),a=[],c=e.motifs.incompleteCandidates.length>0;for(const o of n)for(const n of r){const r=e.motifs.matches.filter(e=>e.template===o),l=s(r.filter(e=>e.completionSectionId===n)),d=s(r.filter(e=>e.intersectSectionIds.includes(n)));a.push({template:o,sectionId:n,partition:t.partition,completionCount:l,intersectionCount:d,denominator:i,status:c?"incomplete":"exact"})}return{templates:n,sections:r,cells:a}}function te(e){return e.entityCount??1}function ne(e){if(!e.missingPrehistory)return{id:`group:${e.id}`,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:te(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:c(e.nodePath,e.nodePath.length-1)}}function oe(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:ee(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(ne).filter(e=>Boolean(e)),o=/* @__PURE__ */new Map;for(const e of n){const n=t.order.indexOf(e.signature),r=o.get(e.signature),i=-1===n?t.order.length:n;(null==r||i<r)&&o.set(e.signature,i)}const r=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(o.get(e)??0)-(o.get(t)??0);return 0!==n?n:e.localeCompare(t)}),i=[];for(const e of n)for(let t=0;t<e.nodePath.length-1;t++){const n=c(e.nodePath,t),o=c(e.nodePath,t+1);i.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:o,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const s=Q(e.motifs.matches),a=e.comparison??h(e),l=[];if(a&&a.partitions.length>=2){const e=a.rows[0],t=a.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;l.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:f(o,r,n),denominator:n}),l.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:f(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const d={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:i.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:r,ribbons:i,capsules:s,profile:ee(e),differences:l,prefixForest:t,sceneSeeds:d}}function re(e,t){return e.groups.some(e=>q(e.nodePath,t))}function ie(t,n,o){if(o.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=n||[5,20],i=[];for(const e of o){const n=e.data?.[t];"number"==typeof n&&i.push(n)}if(0===i.length)return()=>r[0];const[s,a]=e(i);if(s===a)return()=>(r[0]+r[1])/2;const c=(0,yu.scaleLinear)().domain([s,a]).range(r).clamp(!0);return e=>{const n=e.data?.[t];return null==n||"number"!=typeof n?r[0]:c(n)}}function se(e){const t=e.data?.weight??e.weight;return"number"==typeof t&&Number.isFinite(t)?t:Number.isFinite(e.value)?e.value:1}function ae(e,t,n,o,r=xu){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}function ce(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function le(e,t,n,o,r){const i=ie(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=e,n=r?.get(e.id),o=!1!==e.__hasPosition&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e.x:n?.x??0,s=!1!==e.__hasPosition&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e.y:n?.y??0;return{id:e.id,__hasPosition:!1!==e.__hasPosition||void 0!==n,x:o,y:s,vx:t.vx,vy:t.vy,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>({source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:e.value,y0:0,y1:0,sankeyWidth:0,data:{weight:se(e)}})),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed,__previousPositions:r??n.__previousPositions},size:o}}function de(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:`/${t}`;return new URL(`./${e}`,`file:${n}`)}throw new Error(`Cannot resolve module worker asset: ${e}`)}function ue(e){if("undefined"!=typeof DOMException)return new DOMException(`${e} aborted`,"AbortError");const t=new Error(`${e} aborted`);return t.name="AbortError",t}function he(e){const t=new Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function pe(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Malformed worker response");const t=e;if(void 0!==t.requestId&&(!Number.isInteger(t.requestId)||t.requestId<1)||void 0!==t.error&&(!t.error||"string"!=typeof t.error.message||[t.error.name,t.error.stack].some(e=>void 0!==e&&"string"!=typeof e)))throw new Error("Malformed worker response");return{requestId:t.requestId,error:t.error}}function fe(e){let t=null,n=null;return{get available(){return!n&&!t?.failure},get:()=>{if(n||t?.failure)throw n||t?.failure;if(!t||t.isDead)try{t=e()}catch(e){throw n=e instanceof Error?e:new Error(String(e)),n}return t},resetForTest:()=>{if(n=null,t){try{t.terminate()}catch{}t=null}}}}function me(){return"string"==typeof wu.url&&wu.url?new Worker(new URL("./forceLayoutWorker.js",wu.url),{type:"module",name:"semiotic-force-layout"}):new Worker(de("forceLayoutWorker.js"),{type:"module",name:"semiotic-force-layout"})}function ge(){vu.resetForTest()}async function ye(e,t){return ce()?vu.get().request(e,t):Promise.reject(new Error("Web Workers are unavailable"))}function xe(e,t,n){return Math.max(t,Math.min(n,e))}function be(e){return"function"==typeof e?e:t=>t[e]}function we(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function Me(e){if(null==e)return null;const t=e;return t.data??t.datum??e}function ve(e,t){const n=/* @__PURE__ */new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function ke(e){const t=/* @__PURE__ */Object.create(null);return e((e,n)=>{t[e]=n}),t}function Ie(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&String(o[e.field])!==String(e.value))return!1;return!0}function Se(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!Ie(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function $e(e){return e.join("|")}function Ne(e){return(0,Pu.interpolateLab)(e,e)(0)===(0,Pu.interpolateLab)(e,"white")(0)?e:null}function Ee(e,t=.72){const n=Ne(e),o=null===n,r=null===n?null:(0,Pu.interpolateLab)(n,"#ffffff"),i=null===n?null:(0,Pu.interpolateLab)(n,"#000000"),s=null===n?e:r(0),a=xe(t,0,1);return t=>{const n=xe(t,0,1);if(.5===n)return s;const c=2*Math.abs(n-.5)*a;return c?o?`color-mix(in lab, ${e} ${100*(1-c)}%, ${n<.5?"white":"black"})`:n<.5?r(c):i(c):s}}function Ae(e,t,n=.72){return Ee(e,n)(t)}function Ce(e){return ke(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function Oe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function Te(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function Pe(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function Re(e,t){const n=Number.isFinite(t)?xe(t,0,1):1,o=Ne(e);if(null===o)return 1===n?e:`color-mix(in srgb, ${e} ${100*n}%, transparent)`;const[r,i,s,a=1]=(0,Pu.interpolateLab)(o,o)(0).split(/[(),]/).slice(1,-1).map(Number);return`rgba(${r}, ${i}, ${s}, ${a*n})`}function je(e,t){return e<t?-1:e>t?1:0}function Fe(e,t,n,o,r,{force:i=!1}={}){if(t===n&&!i)return null;const s=`${t} of ${n} ${o} shown`;return(0,ju.createElement)("text",{key:"recipe-notice",x:e.x,y:e.y+e.height-4,fontSize:11,fill:"var(--semiotic-text, currentColor)",pointerEvents:"none",role:"img","aria-label":`${s}. ${r}`},(0,ju.createElement)("title",null,r),s)}function Le(e,t,n){return ze(e,t,n)}function ze(e,t,n,o=!1){const r=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=e=>Number.isFinite(e)?Math.max(0,e):0,s=e.reduce((e,t)=>e+(i(t.weight)>0?1:0),0),a=Math.max(0,Math.floor(n?.minPerCategory??0)),c=s>0?Math.min(a,Math.floor(r/s)):0,l=e.reduce((e,t)=>e+i(t.weight),0);if(r<=0||l<=0)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const d=e.map(e=>{const t=i(e.weight),n=t/l*r;return{...e,exact:n,cells:t>0?Math.max(c,Math.floor(n)):0,remainder:n-Math.floor(n)}});let u=d.reduce((e,t)=>e+t.cells,0);for(;u>r;){const e=d.filter(e=>e.cells>c).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,u--}const h=d.filter(e=>i(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||(o?0:i(t.weight)-i(e.weight)||e.key.localeCompare(t.key)));for(let e=0;u<r;e++)h[e%h.length].cells++,u++;return d}function De(e,t,n,o){const r=/* @__PURE__ */new Set;return e.map((e,i)=>{const s=String(t(e,i)),a=Number(n(e,i));if(!s)throw new Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw new Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||a<0)throw new Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function _e(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null!=n.epsilon&&n.epsilon>=0?n.epsilon:1e-9,s=De(e,n.beforeId,n.beforeValue,"Before"),a=De(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),d=s.reduce((e,t)=>e+t.value,0),u=a.reduce((e,t)=>e+t.value,0),h=Math.abs(d-u)<=i;if(!h&&!n.allowImbalance)throw new Error(`Snapshot totals must match (before ${d}, after ${u}). Pass allowImbalance to inspect residuals.`);const p=[],f=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of f){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&p.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const m=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;y<m.length&&x<g.length;){const e=m[y],t=g[x],n=Math.min(e.value,t.value);n>i&&p.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value<=i&&(y+=1),t.value<=i&&(x+=1)}return{flows:p,beforeTotal:d,afterTotal:u,balanced:h,unmatchedBefore:m.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function We(e){return Number.isFinite(e)?Math.max(0,e):0}function qe(e,t){const n=Number(t.unit),o=We(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(!(n>0)||!(r>0)||o<=0)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=o/n,a=Math.ceil(s-Lu),c=Math.min(r,a),l=a>r,d=[];for(let e=0;e<c;e+=1){const t=e*n,r=Math.min(o,t+n);let i=Math.min(1,Math.max(0,(r-t)/n));1-i<Lu&&(i=1),d.push({index:e,fraction:i,start:t,end:t+i*n,value:i*n})}const u=d[d.length-1];u&&u.fraction<i&&u.fraction<1&&d.pop();const h=d.reduce((e,t)=>e+t.value,0);return{units:d,unit:n,total:o,shown:h,overflow:l}}function Ge(e,t,n){const o=qe(e,n),r=Math.max(We(t),o.total);if(r<=o.total)return{...o,rangeUnits:[],rangeTotal:o.total};const i=qe(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+Lu);let c=Math.min(1,Math.max(0,s-a));c<Lu&&(c=0);const l=[];for(const e of i.units)e.index<a||(e.index===a&&c>0?e.fraction-c>Lu&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function Be(e){function t(){n=n+1831565813|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}let n=e>>>0;return t.getState=()=>n>>>0,t}function Ye(e,t,n={}){const o=n.seed??1,r=n.iterations??260,i=n.repulsion??5200,s=n.linkDistance??165,a=n.linkStrength??.045,c=n.centerStrength??.018,l=n.damping??.84,d=n.nodeRadius??12,u=n.nodePadding??3,h=n.inset??.06,p=Be(o),f=/* @__PURE__ */new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const m=Du/2,g=e.map(e=>({id:e.id,data:e,x:200+600*p(),y:200+600*p()})),y=e=>"function"==typeof d?d(e.data):d,x=new Set(e.map(e=>e.id)),b=t.filter(e=>x.has(e.source)&&x.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,zu.forceSimulation)(g).randomSource(p).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,zu.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",(0,zu.forceCollide)(e=>y(e)+u).strength(.9).iterations(2)).force("center",(0,zu.forceCenter)(m,m).strength(.8)).force("x",(0,zu.forceX)(m).strength(c)).force("y",(0,zu.forceY)(m).strength(c));b.length>0&&e.force("link",(0,zu.forceLink)(b).id(e=>e.id).distance(s).strength(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(f.get(t)??1,f.get(n)??1));return a/.045/o})),e.stop();for(let t=0;t<r;t+=1)e.tick()}let w=1/0,M=1/0,v=-1/0,k=-1/0;for(const e of g){const t=e.x??m,n=e.y??m;t<w&&(w=t),n<M&&(M=n),t>v&&(v=t),n>k&&(k=n)}const I=v-w,S=k-M,$={};for(const e of g){const t={x:0===I?.5:h+((e.x??m)-w)/I*(1-2*h),y:0===S?.5:h+((e.y??m)-M)/S*(1-2*h)};Object.defineProperty($,e.id,{value:t,enumerable:!0,configurable:!0,writable:!0})}return $}function Ve(e){return e?e.map(Number).filter(Number.isFinite):[]}function He(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function Ue(e,t){const n=He(t);return e.length<=n?{tokens:e,overflow:!1}:{tokens:e.slice(0,n),overflow:!0}}function Xe(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:Ve(e),data:e}:e}function Ke(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function Je(e){if(e.samples)return Ve(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function Ze(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=Math.ceil(o),s=o-r;return e[r]*(1-s)+e[i]*s}function Qe(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=Be(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}function et(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function tt(e,t){const n=Ke(t),o=Xe(e);let r,i,s,a,c,l,d,u=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?qe(Te(o.value),e):Ge(Te(o.value),Te(o.rangeValue),e);if(r=t.units.map(e=>et(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,u=t.shown,h=t.overflow,null!=o.rangeValue){const e=t;l=e.rangeTotal,d=e.rangeUnits.map(e=>et(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"}))}}else if("fixed-denominator"===n.countStrategy){a=Math.floor(Te(o.denominator??n.denominator)),s=Te(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>et(n,o,1,{highlighted:o<e,start:o,end:o+1})),i=a,u=r.length,h=!1}else if("quantile"===n.countStrategy){const e=Je(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,He(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=Ze(e,r);return et(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,u=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=Je(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,He(n));r=("random-sample"===n.countStrategy?Qe(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return et(n,o,r,{sample:r,start:r,end:r})}),i=e.length,u=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>et(n,t,1,{datum:e})),i=e.length;else{const e=qe(Te(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>et(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,u=e.shown,h=e.overflow}if(e&&null==o.value){const e=Ue(r,n);r=e.tokens,u=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:u,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:d,diagnostics:ot(n,{visibleTokens:r.length+(d?.length??0)})}}function nt(e,t={}){const n=(o=e,Array.isArray(o)?e:e.tokens);var o;const r=n.length;if(0===r)return[];const i=t.flow??"row",s=t.cellWidth??16,a=t.cellHeight??s,c=t.gutter??2,l=t.anchor??[.5,.5],d=Math.max(1,Math.floor(t.columns??(t.rows?Math.ceil(r/t.rows):Math.ceil(Math.sqrt(r))))),u=Math.max(1,Math.floor(t.rows??Math.ceil(r/d))),h="row"===i?Math.max(u,Math.ceil(r/d)):u,p="column"===i?Math.max(d,Math.ceil(r/u)):d,f=t.x??0,m=t.y??0;return n.map((e,n)=>{let o,r;return"column"===i?(r=Math.floor(n/u),o=n%u):(o=Math.floor(n/d),r=n%d),"left"===t.columnDirection&&(r=p-1-r),"up"===t.rowDirection&&(o=h-1-o),{...e,row:o,column:r,x:f+r*(s+c)+l[0]*s,y:m+o*(a+c)+l[1]*a}})}function ot(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"===r&&Te(e.denominator)<=Wu?Wu:_u);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function rt(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function it(e){const t=rt(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function st(e){const t=rt(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:ot(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:ot(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?`one token represents a unit of ${e.concreteEntity}`:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:ot(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:ot(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function at(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return dt(t);const r=Object.prototype.hasOwnProperty.call(Bu,o)?Bu[o]:Gu.symbolCircle;return(0,Gu.symbol)(r,Math.max(1,t))()??""}function ct(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function lt(e,t,n){if(!n&&"circle"===(e??"circle"))return ct(t);const o=n?`p:${n}`:`s:${e??"circle"}:${t}`,r=Vu.get(o);if(null!=r)return r;const i=at(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;e+1<i.length;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Vu.size>512&&Vu.clear(),Vu.set(o,s),s):ct(t)}function dt(e){const t=1.5*ct(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}function ut(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function ht(e,t,n){return"function"==typeof e?e(t)??n:e??n}function pt(e,t){return"function"==typeof e?e(t):e}function ft(e){return e.sample??e.value??e.index}function mt(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function gt(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}function yt(t,n,o){if(0===t.length)return[];const r=n.x??0,i=n.y??0,s=o?"number"==typeof n.tokenSize?n.tokenSize:12:0,a=o?0:n.cellHeight??("number"==typeof n.tokenSize?n.tokenSize:12),c=n.gutter??2,l=o?n.cellWidth??s+c:12,d=o?n.cellHeight??s+c:a+c,u=o?1:Math.max(1,Math.floor(n.rows??1)),[h,p]=e(t,ft),f=p-h||1,m=o?/* @__PURE__ */new Map:null;return t.map((e,s)=>{const a=ft(e);let c=s%u,p=s,g=n.valueToX?n.valueToX(a,e):r+(a-h)/f*(n.width??Math.max(1,t.length-1)*l);o&&(p=Math.round((g-r)/Math.max(1,l)),c=m.get(p)??0,m.set(p,c+1),g=r+p*l);const y=n.valueToY?n.valueToY(a,e):i+c*d;return{...e,x:g,y:y,row:c,column:p}})}function xt(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:ft(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}function bt(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return gt(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o||"dotplot"===o)return yt(n,t,"dotplot"===o);if("bar-segment"===o){if(!t.valueToX)throw new Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return xt(n,t)}if("beeswarm"===o||"small-multiple"===o)throw new Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:mt(n,t,i);return nt(n,{...t,columns:a,cellWidth:i,cellHeight:s})}function wt(e){if(e)return nh[e]}function Mt(e,t){return void 0!==t.datum?ht(t.datum,e,null):e.datum??null}function vt(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?ht(t.rangeColor,e,ih):ht(t.color,e,oh):ht(t.inactiveColor,e,rh),stroke:"none",...pt(t.style,e)??{}}}function kt(e,t){const n=pt(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:Mt(e,t),accessibleDatum:pt(t.accessibleDatum,e),accessibility:pt(t.accessibility,e),pointId:n,_transitionKey:n}}function It(e,t){const n=ht(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:ht(t.radius,e,n/2),style:vt(e,t),...kt(e,t)}}function St(e,t){const n=ht(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:ht(t.symbolType,e,"circle"),path:pt(t.symbolPath,e),rotation:pt(t.rotation,e),style:vt(e,t),...kt(e,t)}}function $t(e,t,n){const o=vt(e,n),r=ht(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:String(o.fill??oh),accent:ht(n.accent,e,sh),fraction:e.fraction<1?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:ht(n.fractionDirection,e,"horizontal"),ghostColor:e.fraction<1?pt(n.ghostColor,e)??rh:void 0,rotation:pt(n.rotation,e),style:o,...kt(e,n)}}function Nt(e,t,n){if("dot"===n.tokenType)return It(e,t);const o=pt(t.glyph,e)??wt(n.icon);if(o)return $t(e,o,t);const r=(i=n.icon)&&ah.has(i)?i:void 0;var i;return St(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}function Et({input:e,encoding:t,options:n={}}){if(!ut(e)&&!t)throw new Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=ut(e)?{...e,encoding:Ke(e.encoding)}:tt(e,t),r=bt(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>Nt(e,n,o.encoding))}}function At(e){return e<10?`0${e}`:String(e)}function Ct(e,t){return e<t?-1:e>t?1:0}function Ot(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Tt(e,t,n){const o=(t+n.lat)/2*(Math.PI/180);return[111.32*(e-n.lon)*Math.cos(o),110.574*(t-n.lat)]}function Pt(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function Rt(e){return uh.has(e)?e:"monument"}function jt(e,t){const n=Pt(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=Ot(t.idAccessor,"id"),a=Ot(t.nameAccessor,"name"),c=Ot(t.longitudeAccessor,"lon"),l=Ot(t.latitudeAccessor,"lat"),d=Ot(t.kindAccessor,"kind"),u=t.candidatePriorityAccessor?Ot(t.candidatePriorityAccessor,"priority"):()=>0,h=Array.from({length:n*n},(e,t)=>{const i=Math.floor(t/n),s=t%n;return{id:`tile-${i}-${s}`,row:i,column:s,centerXKm:(s+.5)*r-o,centerYKm:o-(i+.5)*r,terrainIndex:(17*i+31*s)%dh.length,landmark:null,landmarks:[]}}),p=[];for(const i of e){const e=Number(c(i)),f=Number(l(i));if(!Number.isFinite(e)||!Number.isFinite(f))continue;const m=String(s(i)??`${e},${f}`),g=String(a(i)??m),y=Rt(d(i)),[x,b]=Tt(e,f,t.center);if(Math.abs(x)>o||Math.abs(b)>o)continue;const w=Math.min(n-1,Math.floor((x+o)/r)),M=Math.min(n-1,Math.floor((o-b)/r)),v=h[M*n+w],k=Number(u(i)),I={...i,id:m,name:g,kind:y,lon:e,lat:f,distanceKm:Math.sqrt(x*x+b*b),row:M,column:w,cellDistanceSq:(x-v.centerXKm)**2+(b-v.centerYKm)**2,candidatePriority:Number.isFinite(k)?k:0};v.landmarks.push(I),m===t.centerId&&p.push(I)}const f=(e,t)=>Ct(e.name,t.name)||Ct(e.id,t.id)||e.lon-t.lon||e.lat-t.lat||Ct(e.kind,t.kind),m=(e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||f(e,t),g=h[i*n+i],y=p.sort(m)[0]??[...g.landmarks].sort((e,t)=>e.candidatePriority-t.candidatePriority||Number("city"===t.kind)-Number("city"===e.kind)||e.distanceKm-t.distanceKm||f(e,t))[0],x=/* @__PURE__ */new Map;y&&x.set(y.kind,1);const b=e=>e.cellDistanceSq+(x.get(e.kind)??0)*r*r*.35,w=(e,t)=>e.candidatePriority-t.candidatePriority||b(e)-b(t)||f(e,t);for(const e of h){const t=e===g;if(e.landmarks=e.landmarks.filter(e=>e!==y).sort(t?m:w),t&&y&&e.landmarks.unshift(y),e.landmark=e.landmarks[0]??null,e.landmark&&e.landmark!==y){const t=e.landmark.kind;x.set(t,(x.get(t)??0)+1)}}return h}function Ft(){const e=(qu??(qu=hh.createContext(null)),qu);return hh.useContext(e)??ph}function Lt(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function zt(e,t){const n=Lt(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Dt(e){return xh.has(e)?e:void 0}function _t(e,t){const n=Lt(e,t),o=Dt("string"==typeof n?n:Lt(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=Lt(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=zt(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}function Wt({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=Ft(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */ /* @__PURE__ */
3
- return(0,fh.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const s=e.landmark,c="city"===s.kind?i:r,l=e.y+n/2,d=a.isActive&&!a.predicate(s)?.28:1;/* @__PURE__ */ /* @__PURE__ */
4
- return(0,fh.jsxs)("g",{opacity:d,children:[
2
+ return Object.create(null)}function c(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function l(e,t,n){return t.has(e)?"node":i(n.nodeIdsBySection,e)?"section":"global"}function d(e,t,n){const o=[],r=new Set(t.nodes.map(e=>e.id)),c=/* @__PURE__ */new Set;for(const s of t.measureValues){const t=i(e.measures,s.measureId);if(!t)continue;const a=l(s.subjectId,r,n);o.push({measureId:s.measureId,subjectId:s.subjectId,subjectKind:a,value:s.value,status:s.status,unitKind:t.unitKind,countUnit:t.countUnit,timeDenominator:t.timeDenominator}),"section"===a&&c.add(JSON.stringify([s.measureId,s.subjectId]))}const d=a();for(const e of t.nodes)s(d,e.id,e);const u=/* @__PURE__ */new Map;for(const e of o){if("node"!==e.subjectKind)continue;const t=d[e.subjectId];if(!t?.sectionId)continue;const n=JSON.stringify([e.measureId,t.sectionId]);if(c.has(n))continue;const o=u.get(n);o?(o.value+=e.value,jd[e.status]>jd[o.status]&&(o.status=e.status)):u.set(n,{...e,subjectId:t.sectionId,subjectKind:"section"})}for(const e of u.values())o.push(e);return{entries:o}}function u(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function h(e){const t=e.spec.comparison;if(!t)return;const n=t.partitions.map(n=>{const r=u(e.ledger,t.denominatorMeasureId,n)?.value??0,i={};return i["repeated-state-episode"]=o(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,n),{partition:n,assigned:r,motifUsers:i,outcomes:{purchases:u(e.ledger,"purchases",n)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:n}}function p(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return u(e.ledger,n,t)?.value}function f(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function m(e,t){const n=a();for(const t of e.nodes)s(n,t.id,t.completeness??"known");const o=a();for(const e of t.unsupportedTemplates)s(o,e,"unsupported-template");if(t.incompleteCandidates.length>0){const e=new Set(t.incompleteCandidates.map(e=>e.template));for(const t of e)s(o,t,"incomplete")}const r=t.matches.find(e=>e.truncation),i={nodes:n,motifs:o,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return r?.truncation&&(i.truncation={disclosed:!0,template:r.template,omitted:r.truncation.omitted}),i}function g(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}function y(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}function x(e){const t=e.nodes.map(e=>e.id).sort(),n=new Map(t.map((e,t)=>[e,t])),o=t.map(()=>[]),r=t.map(()=>[]);for(const t of e.edges){const e=n.get(t.source),i=n.get(t.target);o[e].push(i),r[i].push(e)}const i=/* @__PURE__ */new Set,s=[];for(const e of y(o,t.map((e,t)=>t)).reverse()){if(i.has(e))continue;const n=[],o=[e];for(i.add(e);o.length;){const e=o.pop();n.push(t[e]);for(const t of r[e])i.has(t)||(i.add(t),o.push(t))}s.push(n.sort())}return s.sort((e,t)=>e[0].localeCompare(t[0]))}function b(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=g(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),d=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!d.has(e.id)).map(e=>e.id)}}}function w(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}function M(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return Boolean(o?.sectionId&&t.coordinate.sectionIds.includes(o.sectionId))}function v(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function I(e,t){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return b(t,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const n=t.edges.map(e=>e.id),o=e.forest.display.rankingPolicyId??"main-transport",{mode:r,order:i}=w(o),c=n=>M(t,e,n.source)&&M(t,e,n.target),l=/* @__PURE__ */new Map;for(const e of t.nodes)l.set(e.id,[]);for(const e of t.edges)l.has(e.target)||l.set(e.target,[]),l.get(e.target).push(e);const d=a(),u=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:t.nodes[0]?[t.nodes[0].id]:[],h=new Set(u);for(const e of t.nodes){if(h.has(e.id))continue;const t=v(l.get(e.id)??[],i),n=t.find(e=>c(e))??t[0];n&&s(d,e.id,n.id)}let p;p="tree-only"===r?Object.values(d):t.edges.filter(e=>c(e)).map(e=>e.id);const f=new Set(p),m=n.filter(e=>!f.has(e));return{forest:{kind:"rooted-backbone",roots:[...u],rankingPolicyId:o,backboneEdgeIds:p,primaryParentEdgeIdByNode:d},residual:{residualEdgeIds:m,originalEdgeIds:n}}}function k(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw new Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw new Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw new Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw new Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw new Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw new Error("original edge IDs != backbone ⊎ residual")}function S(e){const t=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),n=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),o=/* @__PURE__ */new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=/* @__PURE__ */new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}function $(e,t){return e.sectionByNode.get(t)}function N(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){const t=$(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function E(e,t,n){return e.pairs.get(t)?.get(n)??[]}function A(e){return e.entityCount??1}function C(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=A(r));return{entityIds:n,entityCount:o}}function O(e,t){return null==t||e.length<=t?{kept:e}:{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}}function T(e,t,n,o,r,i){if(n.length<2)return;const{kept:s,truncation:c}=O(n,i),l=[t,...s],d=[];for(const n of s){const o="fan-out"===e?E(r,t,n):E(r,n,t);d.push(...o)}const u=N(r,[t,...n]),h=C(o.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:s}:{destination:t,sources:s},nodePath:l,edgeIds:d,startSectionId:u[0],completionSectionId:u[u.length-1],intersectSectionIds:u,entityIds:h.entityIds,entityWeights:a(),entityCount:h.entityCount,flags:{occurrence:h.entityIds.length>0,temporal:!1,trajectorySupported:h.entityIds.length>0,enriched:!1},truncation:c}}function P(e,t,n){return 1===t.length&&1===n.length}function R(e,t){const n=t.incoming,o=t.outgoing,r=[];for(const i of e.nodes){const s=n.get(i.id)??[],c=o.get(i.id)??[];if(1!==c.length)continue;const l=1===s.length&&P(s[0],n.get(s[0])??[],o.get(s[0])??[]);if(P(i.id,s,c)&&l)continue;const d=[i.id];let u=i.id;const h=/* @__PURE__ */new Set([u]);for(;;){const e=(o.get(u)??[])[0];if(!e||h.has(e))break;if(d.push(e),h.add(e),!P(0,n.get(e)??[],o.get(e)??[]))break;u=e}if(d.length<2)continue;const p=[];for(let e=0;e<d.length-1;e++)p.push(...E(t,d[e],d[e+1]));const f=N(t,d),m=C(e.occurrences??[],d[0]);r.push({id:`serial-chain:${d.join(">")}`,template:"serial-chain",roles:{nodes:d,start:d[0],end:d[d.length-1]},nodePath:d,edgeIds:p,startSectionId:f[0],completionSectionId:f[f.length-1],intersectSectionIds:f,entityIds:m.entityIds,entityWeights:a(),entityCount:m.entityCount,flags:{occurrence:m.entityIds.length>0,temporal:!1,trajectorySupported:m.entityIds.length>0,enriched:!1}})}return r}function j(e,t){const n=t.occurrences??[];if(0!==n.length)for(const t of e){if("repeated-state-episode"===t.template)continue;const e=t.nodePath,o=a();for(const t of n)t.missingPrehistory||e.some(e=>t.nodePath.includes(e))&&s(o,t.entityId,A(t));const r=Object.keys(o);t.entityIds=r,t.entityWeights=o,t.entityCount=r.reduce((e,t)=>e+(o[t]??0),0),t.flags={...t.flags,occurrence:r.length>0,trajectorySupported:r.length>0}}}function F(e,t){const n=[];for(const o of e.occurrences??[]){if(o.missingPrehistory)continue;const e=/* @__PURE__ */new Map,r=/* @__PURE__ */new Set;for(const[i,c]of o.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,i);continue}if(r.has(c))continue;r.add(c);const d=o.nodePath.slice(l,i+1),u=N(t,d),h=a();s(h,o.entityId,A(o)),n.push({id:`repeated-state-episode:${o.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:o.id},nodePath:d,edgeIds:[],startSectionId:$(t,d[0]),completionSectionId:$(t,d[d.length-1]),intersectSectionIds:u,entityIds:[o.entityId],entityWeights:h,entityCount:A(o),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return n}function L(e,t){const n=e.motifs.matchBudget,o=S(t),r=[];for(const e of t.nodes){const i=T("fan-out",e.id,o.outgoing.get(e.id)??[],t,o,n);i&&r.push(i);const s=T("fan-in",e.id,o.incoming.get(e.id)??[],t,o,n);s&&r.push(s)}r.push(...R(t,o)),r.push(...F(t,o)),j(r,t);const i=[];for(const e of t.occurrences??[])e.missingPrehistory&&(i.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),i.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const s=Ld.filter(e=>!Dd.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:r,incompleteCandidates:i,unsupportedTemplates:s}}function z(e){return e.entityCount??1}function D(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function _(e,t={}){function n(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const o={id:"",stateId:"",prefix:[],children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map};for(const t of e){if(t.missingPrehistory)continue;const e=z(t);let n=o;n.occurrenceIds.push(t.id),n.entityCount+=e,D(n,t.partition,e);for(const o of t.nodePath){const r=[...n.prefix,o],i=c(r,r.length-1);let s=n.children.get(o);s||(s={id:i,stateId:o,prefix:r,children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map},n.children.set(o,s)),s.occurrenceIds.push(t.id),s.entityCount+=e,D(s,t.partition,e),n=s}}const r=[],i=[],l=t.referencePartition;return function e(t,o){if(t.id){const e=a();for(const[n,o]of t.partitionCounts)s(e,n,o);r.push({id:t.id,stateId:t.stateId,prefix:t.prefix,parentId:o,childIds:n(t).map(e=>t.children.get(e).id),entityCount:t.entityCount,occurrenceIds:[...t.occurrenceIds],partitionCounts:e}),i.push(t.id)}for(const o of n(t))e(t.children.get(o),t.id||null)}(o,null),{kind:"observed-prefix",rootIds:n(o).map(e=>o.children.get(e).id),nodes:r,order:i,referencePartition:l}}function W(e,t){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:a()};const n=a();for(const t of e.coordinate.sectionIds)s(n,t,[]);for(const e of t.nodes){if(!e.sectionId)continue;const t=n[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:n}}function q(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}function B(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;o<e.length-1;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}function G(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=y(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),d=/* @__PURE__ */new Map([[r,r]]),u=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=d.get(e):t=d.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>d.has(e)).reduce(u);d.get(e)!==t&&(d.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>d.has(t)?[[e,d.get(t)===r?null:n[d.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>d.has(t)),unreachableNodeIds:n.filter((e,t)=>!d.has(t))}}function Y(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof Date||e instanceof Map||e instanceof Set)}function V(e,t){return Array.isArray(t)?t.includes(e):"strings"===t?Array.isArray(e)&&Array.from(e).every(e=>"string"==typeof e):"object"===t?Y(e):"count"===t||"budget"===t?"number"==typeof e&&Number.isFinite(e)&&e>=0&&("budget"!==t||Number.isSafeInteger(e)):typeof e===t}function H(e,t){const n=[],o=(e,t,o)=>{n.push({kind:e,severity:"fatal",message:`${t} must be ${o}`})},r=(e,t,n)=>{if(!Y(e))return o(n,n,"an object"),!1;for(const[r,i]of Object.entries(t)){const t=r.endsWith("?"),s=t?r.slice(0,-1):r;t&&void 0===e[s]||V(e[s],i)||o(n,s,Array.isArray(i)?i.join(" or "):String(i))}return!0};if(!r(e,{relations:"object",coordinate:"object",forest:"object",measures:"object",motifs:"object",temporal:"object",dataRevision:"string",evidencePolicyId:"string"},"input-shape")||!r(t,{graphRef:"string",revision:"string"},"source-shape")||n.length)return n;const i=e,s=t,{coordinate:a,forest:c,measures:l,motifs:d,temporal:u}=i;"ordinal"===a.kind&&r(a,{sectionIds:"strings"},"coordinate"),r(c.display,{"roots?":"strings","rankingPolicyId?":"string","referencePartition?":"string"},"forest")&&"rooted-backbone"===c.display.kind&&(r(c.display,{roots:"strings"},"missing-root"),r(c.display,{rankingPolicyId:"string"},"forest")),void 0!==c.requiredPaths&&r(c.requiredPaths,{roots:"strings"},"required-path-roots"),void 0!==i.comparison&&r(i.comparison,{partitions:"strings",denominatorMeasureId:"string","referencePartition?":"string"},"comparison");for(const e of Object.values(l))r(e,{unitKind:["stock","rate","capacity"],countUnit:_d,"timeDenominator?":"string","description?":"string"},"measures");r(d,{catalogId:"string",catalogVersion:"string",countUnit:_d,anchor:["completion"],"denominatorRef?":"string","timeWindowMs?":"count","matchBudget?":"budget"},"motifs"),r(u,{kind:["snapshot","window"]},"temporal"),"window"!==u.kind||Number.isFinite(u.start)&&Number.isFinite(u.end)&&!(u.end<u.start)||o("temporal","window bounds","finite and ordered");for(const e of["nodes","edges","measureValues","occurrences"]){const t=s[e];if("occurrences"===e&&void 0===t)continue;if(!Array.isArray(t)){o("source-shape",e,"an array");continue}const n="nodes"===e?{id:"string","sectionId?":"string","completeness?":["known","unknown","incomplete","truncated","unsupported-template"]}:"edges"===e?{id:"string",source:"string",target:"string"}:"measureValues"===e?{measureId:"string",subjectId:"string",status:["exact","estimated","unknown","incomplete"]}:{id:"string",entityId:"string",complete:"boolean","missingPrehistory?":"boolean","entityCount?":"count","partition?":"string"};for(const i of t)r(i,n,"occurrences"===e?"occurrence":"source-shape")&&"occurrences"===e&&(r(i,{nodePath:"strings"},"occurrence-node"),void 0===i.groupKeys||Y(i.groupKeys)&&!Object.values(i.groupKeys).some(e=>"string"!=typeof e)||o("occurrence","groupKeys","a string map"))}return n}function U(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function X(e,t){const n=H(e,t);if(n.length)return{ok:!1,issues:n};e.schemaVersion!==Fd&&U(n,"schema-version",`expected schemaVersion ${Fd}`),!0===e.relations.directed&&!0===e.relations.edgeIdRequired&&"keep-by-id"===e.relations.parallelEdges&&"keep-by-id"===e.relations.selfLoops||U(n,"relations","Phase 1 requires directed edges, preserving parallel edges and self-loops by id"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&U(n,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&U(n,"coordinate","Phase 1 kernel uses ordinal sections");const o=a();for(const r of t.nodes)r.id?(o[r.id]&&U(n,"duplicate-node","duplicate node id",r.id),s(o,r.id,!0),"ordinal"===e.coordinate.kind&&r.sectionId&&!e.coordinate.sectionIds.includes(r.sectionId)&&U(n,"section-membership",`node section ${r.sectionId} is not in the coordinate`,r.id)):U(n,"node-id","node is missing id");const r=a();for(const e of t.edges)e.id?(r[e.id]&&U(n,"duplicate-edge","duplicate edge id",e.id),s(r,e.id,!0),o[e.source]||U(n,"dangling-source","edge source is not a node",e.id),o[e.target]||U(n,"dangling-target","edge target is not a node",e.id)):U(n,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])o[t]||U(n,"missing-root","display root is not a node",t);const c=e.forest.requiredPaths;if(c)if("directed-admitted"!==c.relationScopeId&&U(n,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(c.roots)&&0!==c.roots.length)for(const e of c.roots)o[e]||U(n,"required-path-roots","required-path root is not a node",e);else U(n,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&U(n,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(e.comparison.partitions.length<2&&U(n,"comparison","comparison requires at least two partitions"),i(e.measures,e.comparison.denominatorMeasureId)||U(n,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(l=e.measures)||"object"!=typeof l||Array.isArray(l))U(n,"measures","measures must be an object");else for(const[t,o]of Object.entries(e.measures))"rate"!==o.unitKind||o.timeDenominator||U(n,"rate-denominator","rate measures require a timeDenominator",t);var l;const d=/* @__PURE__ */new Map;for(const o of t.measureValues){let t=d.get(o.measureId);t||(t=/* @__PURE__ */new Set,d.set(o.measureId,t)),t.has(o.subjectId)&&U(n,"duplicate-measure-value","measureValue must be unique per measureId and subjectId",o.subjectId),t.add(o.subjectId),i(e.measures,o.measureId)?Number.isFinite(o.value)||U(n,"non-finite-measure","measure value is not finite",o.measureId):U(n,"unknown-measure","measureValue refers to an undeclared measure",o.measureId)}const u=/* @__PURE__ */new Set;for(const e of t.occurrences??[])if(e.id&&e.entityId){u.has(e.id)&&U(n,"duplicate-occurrence","occurrence id must be unique",e.id),u.add(e.id),void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||e<0)||U(n,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)o[t]||U(n,"occurrence-node","occurrence path references a missing node",e.id)}else U(n,"occurrence","occurrence needs id and entityId");return{ok:n.every(e=>"fatal"!==e.severity),issues:n}}function K(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function J(e,t,n={}){const o=X(e,t);if(!o.ok)return{ok:!1,issues:o.issues};if(!Y(n)||void 0!==n.generation&&(!Number.isSafeInteger(n.generation)||n.generation<0))return{ok:!1,issues:[{kind:"generation",severity:"fatal",message:"generation must be a nonnegative safe integer"}]};const r=n.generation??1;let i;try{i=K(e,t,r)}catch{return{ok:!1,issues:[{kind:"spec-serialization",severity:"fatal",message:"atlas spec must be serializable as JSON"}]}}const s=W(e,t),a=L(e,t),c=I(e,t);k(c.residual,c.forest);const l=d(e,t,s),u=m(t,a),p=B(t),f="observed-prefix"===e.forest.display.kind||(t.occurrences?.length??0)>0?_(t.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,g={sourceGraphRef:t.graphRef,analysisRevision:i,spec:e,source:t,sections:s,motifs:a,forest:c.forest,residualEdges:c.residual,ports:p,ledger:l,completeness:u,provenance:{sourceRevision:t.revision,analysisRevision:i,generation:r,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?`ordinal:${e.coordinate.sectionIds.join(",")}`:`numeric:${e.coordinate.field}`,forestRoots:[...e.forest.display.roots??c.forest.roots],rankingPolicyId:c.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:f,...e.forest.requiredPaths&&{requiredPaths:G(t,e.forest.requiredPaths)}};return g.comparison=h(g),{ok:!0,atlas:g,issues:o.issues}}function Z(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function Q(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.has(e.template)).map(e=>{const t="string"==typeof e.roles.state?e.roles.state:e.nodePath[0],n=e.nodePath[e.nodePath.length-1];return{id:`capsule:${e.id}`,matchId:e.id,template:e.template,entryState:t,exitState:n,entityCount:e.entityCount,occurrenceIds:Z(e),selected:!1}}).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=/* @__PURE__ */new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}function ee(e,t={}){const n=t.templates??["repeated-state-episode"],r="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],i=void 0!==t.partition?p(e,t.partition)??0:e.spec.comparison?e.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:e.ledger.entries.find(t=>"global"===t.subjectKind&&t.measureId===e.spec.motifs.denominatorRef)?.value??0,s=n=>o(n,e.source.occurrences,t.partition??e.spec.comparison?.partitions),a=[],c=e.motifs.incompleteCandidates.length>0;for(const o of n)for(const n of r){const r=e.motifs.matches.filter(e=>e.template===o),l=s(r.filter(e=>e.completionSectionId===n)),d=s(r.filter(e=>e.intersectSectionIds.includes(n)));a.push({template:o,sectionId:n,partition:t.partition,completionCount:l,intersectionCount:d,denominator:i,status:c?"incomplete":"exact"})}return{templates:n,sections:r,cells:a}}function te(e){return e.entityCount??1}function ne(e){if(!e.missingPrehistory)return{id:`group:${e.id}`,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:te(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:c(e.nodePath,e.nodePath.length-1)}}function oe(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:ee(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(ne).filter(e=>Boolean(e)),o=/* @__PURE__ */new Map;for(const e of n){const n=t.order.indexOf(e.signature),r=o.get(e.signature),i=-1===n?t.order.length:n;(null==r||i<r)&&o.set(e.signature,i)}const r=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(o.get(e)??0)-(o.get(t)??0);return 0!==n?n:e.localeCompare(t)}),i=[];for(const e of n)for(let t=0;t<e.nodePath.length-1;t++){const n=c(e.nodePath,t),o=c(e.nodePath,t+1);i.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:o,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const s=Q(e.motifs.matches),a=e.comparison??h(e),l=[];if(a&&a.partitions.length>=2){const e=a.rows[0],t=a.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;l.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:f(o,r,n),denominator:n}),l.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:f(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const d={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:i.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:r,ribbons:i,capsules:s,profile:ee(e),differences:l,prefixForest:t,sceneSeeds:d}}function re(e,t){return e.groups.some(e=>q(e.nodePath,t))}function ie(t,n,o){if(o.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=n||[5,20],i=[];for(const e of o){const n=e.data?.[t];"number"==typeof n&&i.push(n)}if(0===i.length)return()=>r[0];const[s,a]=e(i);if(s===a)return()=>(r[0]+r[1])/2;const c=(0,wu.scaleLinear)().domain([s,a]).range(r).clamp(!0);return e=>{const n=e.data?.[t];return null==n||"number"!=typeof n?r[0]:c(n)}}function se(e){const t=e.data?.weight??e.weight;return"number"==typeof t&&Number.isFinite(t)?t:Number.isFinite(e.value)?e.value:1}function ae(e,t,n,o,r=Mu){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}function ce(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function le(e,t,n,o,r){const i=ie(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=e,n=r?.get(e.id),o=!1!==e.__hasPosition&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e.x:n?.x??0,s=!1!==e.__hasPosition&&Number.isFinite(e.x)&&Number.isFinite(e.y)?e.y:n?.y??0;return{id:e.id,__hasPosition:!1!==e.__hasPosition||void 0!==n,x:o,y:s,vx:t.vx,vy:t.vy,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>({source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:e.value,y0:0,y1:0,sankeyWidth:0,data:{weight:se(e)}})),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed,__previousPositions:r??n.__previousPositions},size:o}}function de(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:`/${t}`;return new URL(`./${e}`,`file:${n}`)}throw new Error(`Cannot resolve module worker asset: ${e}`)}function ue(e){if("undefined"!=typeof DOMException)return new DOMException(`${e} aborted`,"AbortError");const t=new Error(`${e} aborted`);return t.name="AbortError",t}function he(e){const t=new Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function pe(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Malformed worker response");const t=e;if(void 0!==t.requestId&&(!Number.isInteger(t.requestId)||t.requestId<1)||void 0!==t.error&&(!t.error||"string"!=typeof t.error.message||[t.error.name,t.error.stack].some(e=>void 0!==e&&"string"!=typeof e)))throw new Error("Malformed worker response");return{requestId:t.requestId,error:t.error}}function fe(e){let t=null,n=null;return{get available(){return!n&&!t?.failure},get:()=>{if(n||t?.failure)throw n||t?.failure;if(!t||t.isDead)try{t=e()}catch(e){throw n=e instanceof Error?e:new Error(String(e)),n}return t},resetForTest:()=>{if(n=null,t){try{t.terminate()}catch{}t=null}}}}function me(){return"string"==typeof Iu.url&&Iu.url?new Worker(new URL("./forceLayoutWorker.js",Iu.url),{type:"module",name:"semiotic-force-layout"}):new Worker(de("forceLayoutWorker.js"),{type:"module",name:"semiotic-force-layout"})}function ge(){Su.resetForTest()}async function ye(e,t){return ce()?Su.get().request(e,t):Promise.reject(new Error("Web Workers are unavailable"))}function xe(e,t,n){return Math.max(t,Math.min(n,e))}function be(e){return"function"==typeof e?e:t=>t[e]}function we(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function Me(e){if(null==e)return null;const t=e;return t.data??t.datum??e}function ve(e,t){const n=/* @__PURE__ */new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function Ie(e){const t=/* @__PURE__ */Object.create(null);return e((e,n)=>{t[e]=n}),t}function ke(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&String(o[e.field])!==String(e.value))return!1;return!0}function Se(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!ke(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function $e(e){return e.join("|")}function Ne(e){return(0,Fu.interpolateLab)(e,e)(0)===(0,Fu.interpolateLab)(e,"white")(0)?e:null}function Ee(e,t=.72){const n=Ne(e),o=null===n,r=null===n?null:(0,Fu.interpolateLab)(n,"#ffffff"),i=null===n?null:(0,Fu.interpolateLab)(n,"#000000"),s=null===n?e:r(0),a=xe(t,0,1);return t=>{const n=xe(t,0,1);if(.5===n)return s;const c=2*Math.abs(n-.5)*a;return c?o?`color-mix(in lab, ${e} ${100*(1-c)}%, ${n<.5?"white":"black"})`:n<.5?r(c):i(c):s}}function Ae(e,t,n=.72){return Ee(e,n)(t)}function Ce(e){return Ie(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function Oe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function Te(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function Pe(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function Re(e,t){const n=Number.isFinite(t)?xe(t,0,1):1,o=Ne(e);if(null===o)return 1===n?e:`color-mix(in srgb, ${e} ${100*n}%, transparent)`;const[r,i,s,a=1]=(0,Fu.interpolateLab)(o,o)(0).split(/[(),]/).slice(1,-1).map(Number);return`rgba(${r}, ${i}, ${s}, ${a*n})`}function je(e,t){return e<t?-1:e>t?1:0}function Fe(e,t,n,o,r,{force:i=!1}={}){if(t===n&&!i)return null;const s=`${t} of ${n} ${o} shown`;return(0,zu.createElement)("text",{key:"recipe-notice",x:e.x,y:e.y+e.height-4,fontSize:11,fill:"var(--semiotic-text, currentColor)",pointerEvents:"none",role:"img","aria-label":`${s}. ${r}`},(0,zu.createElement)("title",null,r),s)}function Le(e,t,n){return ze(e,t,n)}function ze(e,t,n,o=!1){const r=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=e=>Number.isFinite(e)?Math.max(0,e):0,s=e.reduce((e,t)=>e+(i(t.weight)>0?1:0),0),a=Math.max(0,Math.floor(n?.minPerCategory??0)),c=s>0?Math.min(a,Math.floor(r/s)):0,l=e.reduce((e,t)=>e+i(t.weight),0);if(r<=0||l<=0)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const d=e.map(e=>{const t=i(e.weight),n=t/l*r;return{...e,exact:n,cells:t>0?Math.max(c,Math.floor(n)):0,remainder:n-Math.floor(n)}});let u=d.reduce((e,t)=>e+t.cells,0);for(;u>r;){const e=d.filter(e=>e.cells>c).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,u--}const h=d.filter(e=>i(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||(o?0:i(t.weight)-i(e.weight)||e.key.localeCompare(t.key)));for(let e=0;u<r;e++)h[e%h.length].cells++,u++;return d}function De(e,t,n,o){const r=/* @__PURE__ */new Set;return e.map((e,i)=>{const s=String(t(e,i)),a=Number(n(e,i));if(!s)throw new Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw new Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||a<0)throw new Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function _e(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null!=n.epsilon&&n.epsilon>=0?n.epsilon:1e-9,s=De(e,n.beforeId,n.beforeValue,"Before"),a=De(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),d=s.reduce((e,t)=>e+t.value,0),u=a.reduce((e,t)=>e+t.value,0),h=Math.abs(d-u)<=i;if(!h&&!n.allowImbalance)throw new Error(`Snapshot totals must match (before ${d}, after ${u}). Pass allowImbalance to inspect residuals.`);const p=[],f=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of f){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&p.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const m=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;y<m.length&&x<g.length;){const e=m[y],t=g[x],n=Math.min(e.value,t.value);n>i&&p.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value<=i&&(y+=1),t.value<=i&&(x+=1)}return{flows:p,beforeTotal:d,afterTotal:u,balanced:h,unmatchedBefore:m.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function We(e){return Number.isFinite(e)?Math.max(0,e):0}function qe(e,t){const n=Number(t.unit),o=We(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(!(n>0)||!(r>0)||o<=0)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=o/n,a=Math.ceil(s-_u),c=Math.min(r,a),l=a>r,d=[];for(let e=0;e<c;e+=1){const t=e*n,r=Math.min(o,t+n);let i=Math.min(1,Math.max(0,(r-t)/n));1-i<_u&&(i=1),d.push({index:e,fraction:i,start:t,end:t+i*n,value:i*n})}const u=d[d.length-1];u&&u.fraction<i&&u.fraction<1&&d.pop();const h=d.reduce((e,t)=>e+t.value,0);return{units:d,unit:n,total:o,shown:h,overflow:l}}function Be(e,t,n){const o=qe(e,n),r=Math.max(We(t),o.total);if(r<=o.total)return{...o,rangeUnits:[],rangeTotal:o.total};const i=qe(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+_u);let c=Math.min(1,Math.max(0,s-a));c<_u&&(c=0);const l=[];for(const e of i.units)e.index<a||(e.index===a&&c>0?e.fraction-c>_u&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function Ge(e){function t(){n=n+1831565813|0;let e=Math.imul(n^n>>>15,1|n);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}let n=e>>>0;return t.getState=()=>n>>>0,t}function Ye(e,t,n={}){const o=n.seed??1,r=n.iterations??260,i=n.repulsion??5200,s=n.linkDistance??165,a=n.linkStrength??.045,c=n.centerStrength??.018,l=n.damping??.84,d=n.nodeRadius??12,u=n.nodePadding??3,h=n.inset??.06,p=Ge(o),f=/* @__PURE__ */new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const m=qu/2,g=e.map(e=>({id:e.id,data:e,x:200+600*p(),y:200+600*p()})),y=e=>"function"==typeof d?d(e.data):d,x=new Set(e.map(e=>e.id)),b=t.filter(e=>x.has(e.source)&&x.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,Wu.forceSimulation)(g).randomSource(p).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,Wu.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",(0,Wu.forceCollide)(e=>y(e)+u).strength(.9).iterations(2)).force("center",(0,Wu.forceCenter)(m,m).strength(.8)).force("x",(0,Wu.forceX)(m).strength(c)).force("y",(0,Wu.forceY)(m).strength(c));b.length>0&&e.force("link",(0,Wu.forceLink)(b).id(e=>e.id).distance(s).strength(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(f.get(t)??1,f.get(n)??1));return a/.045/o})),e.stop();for(let t=0;t<r;t+=1)e.tick()}let w=1/0,M=1/0,v=-1/0,I=-1/0;for(const e of g){const t=e.x??m,n=e.y??m;t<w&&(w=t),n<M&&(M=n),t>v&&(v=t),n>I&&(I=n)}const k=v-w,S=I-M,$={};for(const e of g){const t={x:0===k?.5:h+((e.x??m)-w)/k*(1-2*h),y:0===S?.5:h+((e.y??m)-M)/S*(1-2*h)};Object.defineProperty($,e.id,{value:t,enumerable:!0,configurable:!0,writable:!0})}return $}function Ve(e){return e?e.map(Number).filter(Number.isFinite):[]}function He(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function Ue(e,t){const n=He(t);return e.length<=n?{tokens:e,overflow:!1}:{tokens:e.slice(0,n),overflow:!0}}function Xe(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:Ve(e),data:e}:e}function Ke(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function Je(e){if(e.samples)return Ve(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function Ze(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=Math.ceil(o),s=o-r;return e[r]*(1-s)+e[i]*s}function Qe(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=Ge(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}function et(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function tt(e,t){const n=Ke(t),o=Xe(e);let r,i,s,a,c,l,d,u=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?qe(Te(o.value),e):Be(Te(o.value),Te(o.rangeValue),e);if(r=t.units.map(e=>et(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,u=t.shown,h=t.overflow,null!=o.rangeValue){const e=t;l=e.rangeTotal,d=e.rangeUnits.map(e=>et(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"}))}}else if("fixed-denominator"===n.countStrategy){a=Math.floor(Te(o.denominator??n.denominator)),s=Te(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>et(n,o,1,{highlighted:o<e,start:o,end:o+1})),i=a,u=r.length,h=!1}else if("quantile"===n.countStrategy){const e=Je(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,He(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=Ze(e,r);return et(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,u=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=Je(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,He(n));r=("random-sample"===n.countStrategy?Qe(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return et(n,o,r,{sample:r,start:r,end:r})}),i=e.length,u=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>et(n,t,1,{datum:e})),i=e.length;else{const e=qe(Te(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>et(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,u=e.shown,h=e.overflow}if(e&&null==o.value){const e=Ue(r,n);r=e.tokens,u=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:u,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:d,diagnostics:ot(n,{visibleTokens:r.length+(d?.length??0)})}}function nt(e,t={}){const n=(o=e,Array.isArray(o)?e:e.tokens);var o;const r=n.length;if(0===r)return[];const i=t.flow??"row",s=t.cellWidth??16,a=t.cellHeight??s,c=t.gutter??2,l=t.anchor??[.5,.5],d=Math.max(1,Math.floor(t.columns??(t.rows?Math.ceil(r/t.rows):Math.ceil(Math.sqrt(r))))),u=Math.max(1,Math.floor(t.rows??Math.ceil(r/d))),h="row"===i?Math.max(u,Math.ceil(r/d)):u,p="column"===i?Math.max(d,Math.ceil(r/u)):d,f=t.x??0,m=t.y??0;return n.map((e,n)=>{let o,r;return"column"===i?(r=Math.floor(n/u),o=n%u):(o=Math.floor(n/d),r=n%d),"left"===t.columnDirection&&(r=p-1-r),"up"===t.rowDirection&&(o=h-1-o),{...e,row:o,column:r,x:f+r*(s+c)+l[0]*s,y:m+o*(a+c)+l[1]*a}})}function ot(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"===r&&Te(e.denominator)<=Gu?Gu:Bu);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function rt(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function it(e){const t=rt(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function st(e){const t=rt(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:ot(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:ot(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?`one token represents a unit of ${e.concreteEntity}`:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:ot(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:ot(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function at(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return dt(t);const r=Object.prototype.hasOwnProperty.call(Hu,o)?Hu[o]:Vu.symbolCircle;return(0,Vu.symbol)(r,Math.max(1,t))()??""}function ct(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function lt(e,t,n){if(!n&&"circle"===(e??"circle"))return ct(t);const o=n?`p:${n}`:`s:${e??"circle"}:${t}`,r=Xu.get(o);if(null!=r)return r;const i=at(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;e+1<i.length;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Xu.size>512&&Xu.clear(),Xu.set(o,s),s):ct(t)}function dt(e){const t=1.5*ct(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}function ut(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function ht(e,t,n){return"function"==typeof e?e(t)??n:e??n}function pt(e,t){return"function"==typeof e?e(t):e}function ft(e){return e.sample??e.value??e.index}function mt(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function gt(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}function yt(t,n,o){if(0===t.length)return[];const r=n.x??0,i=n.y??0,s=o?"number"==typeof n.tokenSize?n.tokenSize:12:0,a=o?0:n.cellHeight??("number"==typeof n.tokenSize?n.tokenSize:12),c=n.gutter??2,l=o?n.cellWidth??s+c:12,d=o?n.cellHeight??s+c:a+c,u=o?1:Math.max(1,Math.floor(n.rows??1)),[h,p]=e(t,ft),f=p-h||1,m=o?/* @__PURE__ */new Map:null;return t.map((e,s)=>{const a=ft(e);let c=s%u,p=s,g=n.valueToX?n.valueToX(a,e):r+(a-h)/f*(n.width??Math.max(1,t.length-1)*l);o&&(p=Math.round((g-r)/Math.max(1,l)),c=m.get(p)??0,m.set(p,c+1),g=r+p*l);const y=n.valueToY?n.valueToY(a,e):i+c*d;return{...e,x:g,y:y,row:c,column:p}})}function xt(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:ft(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}function bt(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return gt(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o||"dotplot"===o)return yt(n,t,"dotplot"===o);if("bar-segment"===o){if(!t.valueToX)throw new Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return xt(n,t)}if("beeswarm"===o||"small-multiple"===o)throw new Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:mt(n,t,i);return nt(n,{...t,columns:a,cellWidth:i,cellHeight:s})}function wt(e){if(e)return ih[e]}function Mt(e,t){return void 0!==t.datum?ht(t.datum,e,null):e.datum??null}function vt(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?ht(t.rangeColor,e,ch):ht(t.color,e,sh):ht(t.inactiveColor,e,ah),stroke:"none",...pt(t.style,e)??{}}}function It(e,t){const n=pt(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:Mt(e,t),accessibleDatum:pt(t.accessibleDatum,e),accessibility:pt(t.accessibility,e),pointId:n,_transitionKey:n}}function kt(e,t){const n=ht(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:ht(t.radius,e,n/2),style:vt(e,t),...It(e,t)}}function St(e,t){const n=ht(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:ht(t.symbolType,e,"circle"),path:pt(t.symbolPath,e),rotation:pt(t.rotation,e),style:vt(e,t),...It(e,t)}}function $t(e,t,n){const o=vt(e,n),r=ht(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:String(o.fill??sh),accent:ht(n.accent,e,lh),fraction:e.fraction<1?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:ht(n.fractionDirection,e,"horizontal"),ghostColor:e.fraction<1?pt(n.ghostColor,e)??ah:void 0,rotation:pt(n.rotation,e),style:o,...It(e,n)}}function Nt(e,t,n){if("dot"===n.tokenType)return kt(e,t);const o=pt(t.glyph,e)??wt(n.icon);if(o)return $t(e,o,t);const r=(i=n.icon)&&dh.has(i)?i:void 0;var i;return St(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}function Et({input:e,encoding:t,options:n={}}){if(!ut(e)&&!t)throw new Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=ut(e)?{...e,encoding:Ke(e.encoding)}:tt(e,t),r=bt(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>Nt(e,n,o.encoding))}}function At(e){return e<10?`0${e}`:String(e)}function Ct(e,t){return e<t?-1:e>t?1:0}function Ot(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Tt(e,t,n){const o=(t+n.lat)/2*(Math.PI/180);return[111.32*(e-n.lon)*Math.cos(o),110.574*(t-n.lat)]}function Pt(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function Rt(e){return fh.has(e)?e:"monument"}function jt(e,t){const n=Pt(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=Ot(t.idAccessor,"id"),a=Ot(t.nameAccessor,"name"),c=Ot(t.longitudeAccessor,"lon"),l=Ot(t.latitudeAccessor,"lat"),d=Ot(t.kindAccessor,"kind"),u=t.candidatePriorityAccessor?Ot(t.candidatePriorityAccessor,"priority"):()=>0,h=Array.from({length:n*n},(e,t)=>{const i=Math.floor(t/n),s=t%n;return{id:`tile-${i}-${s}`,row:i,column:s,centerXKm:(s+.5)*r-o,centerYKm:o-(i+.5)*r,terrainIndex:(17*i+31*s)%ph.length,landmark:null,landmarks:[]}}),p=[];for(const i of e){const e=Number(c(i)),f=Number(l(i));if(!Number.isFinite(e)||!Number.isFinite(f))continue;const m=String(s(i)??`${e},${f}`),g=String(a(i)??m),y=Rt(d(i)),[x,b]=Tt(e,f,t.center);if(Math.abs(x)>o||Math.abs(b)>o)continue;const w=Math.min(n-1,Math.floor((x+o)/r)),M=Math.min(n-1,Math.floor((o-b)/r)),v=h[M*n+w],I=Number(u(i)),k={...i,id:m,name:g,kind:y,lon:e,lat:f,distanceKm:Math.sqrt(x*x+b*b),row:M,column:w,cellDistanceSq:(x-v.centerXKm)**2+(b-v.centerYKm)**2,candidatePriority:Number.isFinite(I)?I:0};v.landmarks.push(k),m===t.centerId&&p.push(k)}const f=(e,t)=>Ct(e.name,t.name)||Ct(e.id,t.id)||e.lon-t.lon||e.lat-t.lat||Ct(e.kind,t.kind),m=(e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||f(e,t),g=h[i*n+i],y=p.sort(m)[0]??[...g.landmarks].sort((e,t)=>e.candidatePriority-t.candidatePriority||Number("city"===t.kind)-Number("city"===e.kind)||e.distanceKm-t.distanceKm||f(e,t))[0],x=/* @__PURE__ */new Map;y&&x.set(y.kind,1);const b=e=>e.cellDistanceSq+(x.get(e.kind)??0)*r*r*.35,w=(e,t)=>e.candidatePriority-t.candidatePriority||b(e)-b(t)||f(e,t);for(const e of h){const t=e===g;if(e.landmarks=e.landmarks.filter(e=>e!==y).sort(t?m:w),t&&y&&e.landmarks.unshift(y),e.landmark=e.landmarks[0]??null,e.landmark&&e.landmark!==y){const t=e.landmark.kind;x.set(t,(x.get(t)??0)+1)}}return h}function Ft(){const e=(Yu??(Yu=mh.createContext(null)),Yu);return mh.useContext(e)??gh}function Lt(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function zt(e,t){const n=Lt(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Dt(e){return Mh.has(e)?e:void 0}function _t(e,t){const n=Lt(e,t),o=Dt("string"==typeof n?n:Lt(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=Lt(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=zt(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}function Wt({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=Ft(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */ /* @__PURE__ */
3
+ return(0,yh.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const s=e.landmark,c="city"===s.kind?i:r,l=e.y+n/2,d=a.isActive&&!a.predicate(s)?.28:1;/* @__PURE__ */ /* @__PURE__ */
4
+ return(0,yh.jsxs)("g",{opacity:d,children:[
5
5
  /* @__PURE__ */
6
- /* @__PURE__ */(0,fh.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),
6
+ /* @__PURE__ */(0,yh.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),
7
7
  /* @__PURE__ */
8
- /* @__PURE__ */(0,fh.jsx)(Gt,{kind:s.kind,href:zt(o,s.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&/* @__PURE__ */ /* @__PURE__ */(0,fh.jsx)(qt,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},e.id)}),s&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);/* @__PURE__ */ /* @__PURE__ */
9
- return(0,fh.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[
8
+ /* @__PURE__ */(0,yh.jsx)(Bt,{kind:s.kind,href:zt(o,s.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&/* @__PURE__ */ /* @__PURE__ */(0,yh.jsx)(qt,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},e.id)}),s&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);/* @__PURE__ */ /* @__PURE__ */
9
+ return(0,yh.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[
10
10
  /* @__PURE__ */
11
- /* @__PURE__ */(0,fh.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),
11
+ /* @__PURE__ */(0,yh.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),
12
12
  /* @__PURE__ */
13
- /* @__PURE__ */(0,fh.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},`${e.landmark.id}-label`)})]})}function qt({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i=`+${n}`,s=Math.max(r,i.length*r*.58);/* @__PURE__ */ /* @__PURE__ */
14
- return(0,fh.jsxs)("g",{transform:`translate(${e},${t})`,children:[
13
+ /* @__PURE__ */(0,yh.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},`${e.landmark.id}-label`)})]})}function qt({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i=`+${n}`,s=Math.max(r,i.length*r*.58);/* @__PURE__ */ /* @__PURE__ */
14
+ return(0,yh.jsxs)("g",{transform:`translate(${e},${t})`,children:[
15
15
  /* @__PURE__ */
16
- /* @__PURE__ */(0,fh.jsx)("rect",{x:-s/2,y:-r/2,width:s,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),
16
+ /* @__PURE__ */(0,yh.jsx)("rect",{x:-s/2,y:-r/2,width:s,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),
17
17
  /* @__PURE__ */
18
- /* @__PURE__ */(0,fh.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function Gt({kind:e,href:t,x:n,y:o,size:r}){if(t)/* @__PURE__ */ /* @__PURE__ */
19
- return(0,fh.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=wh[e],s=Mh[e];/* @__PURE__ */ /* @__PURE__ */
20
- return(0,fh.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:i.flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:/* @__PURE__ */ /* @__PURE__ */(0,fh.jsx)("rect",{x:n,y:t,width:1,height:1,fill:s[e]},`${t}-${n}`)))})}function Bt(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Yt(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(o<t&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function Vt(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function Ht(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=xe(Number.isFinite(t.occupancy)?Number(t.occupancy):kh,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):Ih;let i=Bt(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),s=Bt(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));i*s<n.length&&(null!=t.columns&&null==t.rows?s=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/s):s=Math.ceil(n.length/i));const a=Yt(n.map(e=>e.x)),c=Yt(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:Vt(e.x,a)*Math.max(0,i-1),desiredRow:Vt(e.y,c)*Math.max(0,s-1)})),d=(i-1)/2,u=(s-1)/2;l.sort((e,t)=>{const n=(e.desiredColumn-d)**2+(e.desiredRow-u)**2;return(t.desiredColumn-d)**2+(t.desiredRow-u)**2-n||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index});const h=/* @__PURE__ */new Set;for(let e=0;e<s;e+=1)for(let t=0;t<i;t+=1)h.add(e*i+t);const p=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=Math.floor(o/i),s=(o%i-e.desiredColumn)**2+(r-e.desiredRow)**2;(s<n||s===n&&o<t)&&(t=o,n=s)}t<0||(h.delete(t),p.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return p.sort((e,t)=>e.index-t.index),p.map(({index:e,...t})=>t)}function Ut(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function Xt(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??`area-${t}`;return{...n,id:String(o)}}function Kt(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function Jt(e,t,n){const o=[];for(let r=0;r<6;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return Kt(o)}function Zt(e){return e.areas.map((t,n)=>{const o=Xt(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function Qt(e){return e.points.map(t=>{const n=Number(Ut(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(Ut(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function en(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(Ut(e,t.columnAccessor)),y:Number(Ut(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}function tn({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=Ft();/* @__PURE__ */ /* @__PURE__ */
21
- return(0,vh.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const s=!i.isActive||i.predicate(e.datum);/* @__PURE__ */ /* @__PURE__ */
22
- return(0,vh.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function nn(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function on(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function rn(e){if(Number.isFinite(e)&&!(Number(e)<=0))return Number(e)}function sn(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function an(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function cn(e,t){const n=an(e);return String(e.id??n.id??n.name??`feature-${t}`)}function ln(e,t){if(0===e.length)return null;const n={type:"FeatureCollection",features:e},o=t.bounds(n);return Number.isFinite(o[0][0])&&Number.isFinite(o[0][1])&&Number.isFinite(o[1][0])&&Number.isFinite(o[1][1])?o:null}function dn(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function un(e){if(!e)return 0;const t=Oh.get(e);if(t)return t;const n=Th;return Th+=1,Oh.set(e,n),n}function hn(e){return e.map((e,t)=>{if(Ch.has(e))return{feature:e,index:t,bounds:Ch.get(e)??null};try{const n=nn();return Ch.set(e,n),{feature:e,index:t,bounds:n}}catch{return Ch.set(e,null),{feature:e,index:t,bounds:null}}})}function pn(e,t){return!t||e[1]>=t[0][1]&&e[1]<=t[1][1]&&(n=e[0],(o=t[0][0])<=(r=t[1][0])?n>=o&&n<=r:n>=o||n<=r);var n,o,r}function fn(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&pn(t,n.bounds))try{if(on())return{feature:e,index:o}}catch{}}return null}function mn(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=ln(r,t.geoPath);if(!i)return{dots:[],cellSize:Nh,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[xe(i[0][0],s,Math.max(s,n.width-s)),xe(i[0][1],s,Math.max(s,n.height-s))],[xe(i[1][0],s,Math.max(s,n.width-s)),xe(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:Nh,features:r};const d=rn(o.columns);let u=Math.max(2,d?c/d:rn(o.cellSize)??Nh);const h=Math.max(100,Math.round(rn(o.maxSamples)??Eh)),p=Math.ceil(c/u)*Math.ceil(l/u);p>h&&(u*=Math.sqrt(p/h));const f=o.gridOrigin?.[0]??0,m=o.gridOrigin?.[1]??0,[g,y]=dn(a[0][0],a[1][0],f,u),[x,b]=dn(a[0][1],a[1][1],m,u),w=[],M=hn(r);for(let e=x;e<=b;e+=1){const n=m+(e+.5)*u;for(let r=g;r<=y;r+=1){const i=f+(r+.5)*u,s=t.invertedPoint(i,n);if(!s||!Number.isFinite(s[0])||!Number.isFinite(s[1]))continue;const a=fn(M,s);if(!a)continue;const c={...an(a.feature),featureId:cn(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:r,longitude:s[0],latitude:s[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(c,w.length)||w.push(c)}}return{dots:w,cellSize:u,features:r}}function gn(e){return Math.round(1e4*e)/1e4}function yn(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${gn(Number(e[0]))},${gn(Number(e[1]))}`:"null"}function xn(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function bn(e){return"number"==typeof e&&Number.isFinite(e)?String(gn(e)):null===e?"null":"unavailable"}function wn(e){const t=e.scales.projection;return[bn(xn(t,"scale")),yn(xn(t,"translate")),yn(xn(t,"center")),(n=xn(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>gn(Number(e))).join(","):"unavailable"),bn(xn(t,"clipAngle")),bn(xn(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>yn(e.scales.projectedPoint(t,n)))].join("|");var n}function Mn(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",un(t.featureFilter),un(t.dotFilter),wn(e)].join("::")}function vn(e){let t=Ah.get(e.areas);t||(t=/* @__PURE__ */new Map,Ah.set(e.areas,t));const n=Mn(e),o=t.get(n);if(o)return o;const r=mn(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}function kn(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function In(e,t,n){return kn([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}function Sn(e,t,n){return kn(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}function $n(e,t,n){const o=e.data??e,r=o.x??e.x,i=o.y??e.y,s=e.createdByFrame&&0===e.width?void 0:e.width,a=e.createdByFrame&&0===e.height?void 0:e.height,c=o.width??s??t,l=o.height??a??n;if(!("number"!=typeof r||"number"!=typeof i||"number"!=typeof c||"number"!=typeof l||![r,i,c,l].every(Number.isFinite)||c<=0||l<=0))return{x:r,y:i,w:c,h:l}}function Nn(e,t,n){const{nodeWidth:o,nodeHeight:r,waypoints:i=[]}=n,s="none"===n.fit?"none":"contain";let a=1/0,c=1/0,l=-1/0,d=-1/0;const u=(e,t)=>{a=Math.min(a,e),c=Math.min(c,t),l=Math.max(l,e),d=Math.max(d,t)};let h=!1;for(const t of e){const e=$n(t,o,r);e&&(h=!0,u(e.x-e.w/2,e.y-e.h/2),u(e.x+e.w/2,e.y+e.h/2))}for(const e of i)u(e.x,e.y);let p=1,f=0,m=0;if("contain"===s&&h){const e=l-a,n=d-c;if(![e,n,t.x,t.y,t.width,t.height].every(Number.isFinite)||e<=0||n<=0||t.width<=0||t.height<=0)h=!1;else{const o=Math.min(1,t.width/4,t.height/4);p=Math.min(1,(t.width-2*o)/e,(t.height-2*o)/n),f=t.x+(t.width-e*p)/2-a*p,m=t.y+(t.height-n*p)/2-c*p}}const g=({x:e,y:t})=>({x:e*p+f,y:t*p+m});return{fit:s,scale:p,dx:f,dy:m,bounds:h?{x:a,y:c,width:l-a,height:d-c}:null,project:g,invert:({x:e,y:t})=>({x:(e-f)/p,y:(t-m)/p}),nodeBounds:e=>{const t=h?$n(e,o,r):void 0;if(!t)return;const{x:n,y:i}=g(t),s=t.w*p,a=t.h*p;return{x:n-s/2,y:i-a/2,width:s,height:a,cx:n,cy:i}}}}function En(e,t,n,o=[]){const r=Nn(e.nodes,e.dimensions.plot,{nodeWidth:t.nodeWidth,nodeHeight:t.nodeHeight,fit:t.fit,waypoints:o}),i=/* @__PURE__ */new Map,s=[],a=[];for(const o of e.nodes){const c=r.nodeBounds(o);if(!c)continue;const{cx:l,cy:d,width:u,height:h}=c;i.set(o.id,{x:l,y:d,w:u,h:h});const p=o.data??o,f=t.labelAccessor??"id",m=String("function"==typeof f?f(p):p[f]??o.id);s.push({type:"rect",x:c.x,y:c.y,w:u,h:h,style:{fill:t.nodeFill??e.resolveColor(o.id),stroke:n,strokeWidth:Math.min(1.5,u/2,h/2)},datum:p,id:o.id,label:m}),!1!==t.showLabels&&a.push({x:l,y:d,text:m,anchor:"middle",baseline:"middle",fontSize:11*r.scale})}return{positions:i,sceneNodes:s,labels:a,project:r.project}}function An(e,t,n={}){return Nn(e,t,{nodeWidth:n.nodeWidth??80,nodeHeight:n.nodeHeight??30,fit:n.fit})}function Cn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.min(0===n?1/0:e.w/2/Math.abs(n),0===o?1/0:e.h/2/Math.abs(o));return Number.isFinite(r)?{x:e.x+n*r,y:e.y+o*r}:{x:e.x,y:e.y}}function On(e,t,n,o,r,i=1){const s=t.x-n.x,a=t.y-n.y,c=Math.hypot(s,a);if(0===c||r<=0)return null;const l=Math.min(r,c)/c,d=s*l,u=a*l;return(0,Fh.createElement)("polygon",{key:e,className:"recipe-edge-arrow",points:`${t.x},${t.y} ${t.x-d-u/2},${t.y-u+d/2} ${t.x-d+u/2},${t.y-u-d/2}`,fill:o,opacity:i,"aria-hidden":!0,style:{pointerEvents:"none"}})}function Tn(e){const t=e.data??e,n=Array.isArray(t.points)?t.points:e.points;return Array.isArray(n)&&n.length>=2&&n.every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y))?n:[]}function Pn(e,t,n,o={}){return Nn(e,n,{nodeWidth:o.nodeWidth??100,nodeHeight:o.nodeHeight??36,fit:o.fit,waypoints:t.flatMap(Tn)})}function Rn(e,t){const n="function"==typeof t?t(e):e[t];return Wh(n)?n:void 0}function jn(e){return[...e].sort((e,t)=>je(e,t))}function Fn(e,t){const n=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}function Ln(e){const t=new Set(e.keys()),n=[];for(const o of jn(t)){if(!t.has(o))continue;const r=[o],i=[];t.delete(o);for(let n=0;n<r.length;n++){const o=r[n];i.push(o);for(const n of jn(e.get(o)??[]))t.has(n)&&(t.delete(n),r.push(n))}n.push(i.sort((e,t)=>je(e,t)))}return n.sort((e,t)=>t.length-e.length||je(e[0],t[0]))}function zn(e,t,n){const o=/* @__PURE__ */new Map([[e,0]]),r=[e];for(let e=0;e<r.length;e++){const i=r[e],s=o.get(i);for(const e of jn(n.get(i)??[]))t.has(e)&&!o.has(e)&&(o.set(e,s+1),r.push(e))}return o}function Dn(e,t,n){const o=zn(e,t,n);let r=e,i=-1;for(const[e,t]of o)(t>i||t===i&&je(e,r)<0)&&(r=e,i=t);return r}function _n(e,t,n){const o=new Set(e),r=e.filter(e=>(t.get(e)?.size??0)<=1)[0]??e[0],i=zn(n&&o.has(n)?n:Dn(Dn(r,o,t),o,t),o,t);let s=0;for(const e of i.values())s=Math.max(s,e);const a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>je(e,t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?Number.POSITIVE_INFINITY:n.reduce((e,t)=>e+t,0)/n.length},i=new Map(a[e].map(e=>[e,r(e)]));a[e].sort((e,t)=>i.get(e)-i.get(t)||je(e,t))};for(let e=0;e<4;e+=1){for(let e=1;e<a.length;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function Wn(e,t,n,o,r,i){const s=Fn(e.map(e=>e.id),t),a=Ln(s),c=new Map(e.map(e=>[e.id,e.data])),l=/* @__PURE__ */new Map,d=Math.max(0,n.width),u=Math.max(0,n.height),h=Math.min(o,d/2),p=Math.min(o,u/2),f=Math.max(0,u-2*p),m=a.length>1?Math.min(r,f/a.length):0,g=Math.max(0,f-m*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=p;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=_n(e,s,i),o=Math.max(0,d-2*h);n.forEach((e,r)=>{const i=1===n.length?d/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{const r=1===e.length?x+t/2:x+o/(e.length-1)*t;l.set(n,{id:n,x:i,y:r,data:c.get(n)})})}),x+=t+m}return l}function qn(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:Rn(e.data,s),authoredY:Rn(e.data,a)})),l=c.length>0&&c.every(e=>Wh(e.authoredX)&&Wh(e.authoredY)),d="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,u=[];if(d&&!l&&u.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!d||!l){l||"automatic"===o.layoutMode||u.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=Wn(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:u,projectAuthoredPoint:e=>e}}let h=1/0,p=-1/0,f=1/0,m=-1/0;for(const e of c)h=Math.min(h,e.authoredX),p=Math.max(p,e.authoredX),f=Math.min(f,e.authoredY),m=Math.max(m,e.authoredY);const g=Math.max(1,n.width-2*r),y=Math.max(1,n.height-2*r),x=e=>({x:p===h?n.width/2:r+(e.x-h)/(p-h)*g,y:m===f?n.height/2:r+(e.y-f)/(m-f)*y}),b=/* @__PURE__ */new Map;for(const e of c){const t=x({x:e.authoredX,y:e.authoredY});b.set(e.id,{id:e.id,...t,data:e.data})}return{positions:b,mode:"authored",warnings:u,projectAuthoredPoint:x}}function Gn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(r<.001||i<.001||Math.abs(r-i)<.001)return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function Bn(e,t){if(0===t||e.length<2)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=r<e.length-1?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(l<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const d=a*s.x+c*s.y;if(Math.abs(d)<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};const u=4*Math.abs(t),h=t/d,p=Math.max(-u,Math.min(u,h));return{x:o.x+a*p,y:o.y+c*p}})}function Yn(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;t<e.length-1;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(l<=.001){o+=` L${i.x},${i.y}`;continue}const d={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},u={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${d.x},${d.y} Q${i.x},${i.y} ${u.x},${u.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function Vn(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):we(e.data,t.labelAccessor??"label",e.id)}function Hn(e){return"string"==typeof e?e:e.id}function Un(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:String(e.id)}:{id:String(e)});return t.length>0?t:[{id:"network"}]}function Xn(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,Un(o)}function Kn(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function Jn(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=/* @__PURE__ */new Map,l=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(const e of a){const t={id:e.id,label:String(Vn(e,n)),color:Kn(e,n,o)},r=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=/* @__PURE__ */new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const d=e=>[...e].sort((e,t)=>je(e.id,t.id));return{byEdge:new Map(t.map(e=>[e,d(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,d(l.get(e.id)?.values()??[])]))}}function Zn(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function Qn(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=r.source<r.target?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:/* @__PURE__ */new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??Xn(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>je(e.key,t.key))}function eo(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??Number.POSITIVE_INFINITY)-(n.get(t)??Number.POSITIVE_INFINITY)||je(e,t))}function to(e,t){const n=e.authoredOrder??t.lineOrder??[],o=new Map(n.map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(o.get(e.descriptor.id)??Number.POSITIVE_INFINITY)-(o.get(t.descriptor.id)??Number.POSITIVE_INFINITY)||je(e.descriptor.id,t.descriptor.id))}function no(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>{const n=e;return"number"==typeof n.x&&"number"==typeof n.y?t.projectAuthoredPoint({x:n.x,y:n.y}):null}).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function oo(e,t){return ke(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function ro(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||je(e.id,t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):String(we(e.data,i.labelAccessor??"label",e.id)))||e.id,d=Math.max(2*s,l.length*s*.58),u=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,p=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-d},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-d/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-d/2}].map((e,t)=>{const n={left:e.left,right:e.left+d,top:e.y-u/2,bottom:e.y+u/2},o=a.filter(e=>{return o=e,(t=n).left<o.right&&t.right>o.left&&t.top<o.bottom&&t.bottom>o.top;var t,o}).length,i=Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height);return{candidate:e,box:n,score:1e4*o+10*i+t}}).sort((e,t)=>e.score-t.score)[0];a.push(p.box),c.push({x:p.candidate.x,y:p.candidate.y,anchorPoint:[n.x,n.y],text:l,anchor:p.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function io(e,t,n={}){const o=n.layerAccessor??"x",r=n.rowAccessor??"y";let i=1/0,s=-1/0,a=1/0,c=-1/0;for(const t of e){const e=Number(we(t,o,0)),n=Number(we(t,r,0));Number.isFinite(e)&&Number.isFinite(n)&&(i=Math.min(i,e),s=Math.max(s,e),a=Math.min(a,n),c=Math.max(c,n))}if(i===1/0&&(i=s=a=c=0),Number.isFinite(n.layerCount)&&n.layerCount>0&&(i=Math.min(i,0),s=Math.max(s,n.layerCount-1)),Number.isFinite(n.maxLayerSize)&&n.maxLayerSize>0){const e=Math.max(0,n.maxLayerSize-1)/2;a=Math.min(a,-e),c=Math.max(c,e)}const l=s-i,d=Math.max(1,c-a),u=(a+c-d)/2,h=l+1,p=c-a+1,f=t.width/Math.max(1,h),m=t.height/Math.max(1,p);let g=Math.min(n.nodeWidth??172,Math.max(8,f-(n.minGapX??26))),y=Math.min(n.nodeHeight??54,Math.max(8,m-(n.minGapY??18)));const x=n.lod&&"auto"!==n.lod?n.lod:g<16?"dot":g<48?"icon":g<108?"compact":"full";if("dot"===x){const e=Math.min(g,y,11);g=e,y=e}const b=Math.max(1,t.width-g),w=Math.max(1,t.height-y),{x:M,y:v}=t,k=(e,t)=>({x:M+g/2+(l>0?(e-i)/l:.5)*b,y:v+y/2+(t-u)/d*w});return{layerCount:h,maxLayerSize:p,nodeWidth:g,nodeHeight:y,lod:x,project:k,invert:(e,t)=>({layer:l>0?i+(e-M-g/2)/b*l:null,row:(t-v-y/2)/w*d+u}),nodeBounds:e=>{const t=k(Number(we(e,o,0)),Number(we(e,r,0)));return{x:t.x-g/2,y:t.y-y/2,width:g,height:y,cx:t.x,cy:t.y}}}}function so(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function ao(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(t.length<=2)return t;const n=[];for(const e of t){for(;n.length>=2&&so(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&so(o[o.length-2],o[o.length-1],n)<=0;)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}function co(e,t){if(0===t||e.length<3)return e;const n=e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)>=0?1:-1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},d=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},u={x:l.x+d.x,y:l.y+d.y},h=Math.hypot(u.x,u.y);if(h<1e-9)return{x:o.x+d.x*t,y:o.y+d.y*t};const p=u.x/h,f=u.y/h,m=Math.max(1e-6,p*d.x+f*d.y),g=t/m;return{x:o.x+p*g,y:o.y+f*g}})}function lo(e){return String(Math.abs(e)<1e-12?0:e)}function uo(e,t){if(0===e.length)return"";if(e.length<3||0===t)return`${e.map((e,t)=>`${0===t?"M":"L"}${lo(e.x)},${lo(e.y)}`).join(" ")} Z`;const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${lo(o.x)},${lo(o.y)}`;for(let e=1;e<n.length;e++){const t=n[e];r+=` L${lo(t.incoming.x)},${lo(t.incoming.y)}`,r+=` Q${lo(t.point.x)},${lo(t.point.y)} ${lo(t.outgoing.x)},${lo(t.outgoing.y)}`}const i=n[0];return r+=` L${lo(i.incoming.x)},${lo(i.incoming.y)}`,r+=` Q${lo(i.point.x)},${lo(i.point.y)} ${lo(i.outgoing.x)},${lo(i.outgoing.y)} Z`,r}function ho(t,n){const o=[];for(const[r,i]of t){const t=co(ao(i.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),n.padding);if(!t.length)continue;const[s,a]=e(t,e=>e.x),[c,l]=e(t,e=>e.y);o.push({x:s,y:c,width:a-s,height:l-c});const d=n.label?.(r);d&&o.push({x:s+8,y:c+14,z:0,extent:[0,6.6*d.length,12,3]})}return o}function po(e,n){const o=Array.from(e.entries()).sort(([e],[t])=>e<t?-1:e>t?1:0);/* @__PURE__ */ /* @__PURE__ */
23
- return(0,Yh.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:o.map(([e,o])=>{const r=co(ao(o.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),n.padding),i=uo(r,n.radius),s=Object.prototype.hasOwnProperty.call(n.colors??{},e)?n.colors?.[e]??n.resolveColor(e):n.resolveColor(e),a=o.every(e=>!0===n.dimById.get(e.id)&&e.id!==n.selectedId),c=t(r.map(e=>e.x)),l=t(r.map(e=>e.y)),d=n.label?.(e);/* @__PURE__ */ /* @__PURE__ */
24
- return(0,Yh.jsxs)("g",{"data-lineage-hull":e,opacity:a?n.dimOpacity:void 0,children:[
18
+ /* @__PURE__ */(0,yh.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function Bt({kind:e,href:t,x:n,y:o,size:r}){if(t)/* @__PURE__ */ /* @__PURE__ */
19
+ return(0,yh.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=Ih[e],s=kh[e];/* @__PURE__ */ /* @__PURE__ */
20
+ return(0,yh.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:i.flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:/* @__PURE__ */ /* @__PURE__ */(0,yh.jsx)("rect",{x:n,y:t,width:1,height:1,fill:s[e]},`${t}-${n}`)))})}function Gt(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Yt(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(o<t&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function Vt(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function Ht(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=xe(Number.isFinite(t.occupancy)?Number(t.occupancy):$h,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):Nh;let i=Gt(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),s=Gt(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));i*s<n.length&&(null!=t.columns&&null==t.rows?s=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/s):s=Math.ceil(n.length/i));const a=Yt(n.map(e=>e.x)),c=Yt(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:Vt(e.x,a)*Math.max(0,i-1),desiredRow:Vt(e.y,c)*Math.max(0,s-1)})),d=(i-1)/2,u=(s-1)/2;l.sort((e,t)=>{const n=(e.desiredColumn-d)**2+(e.desiredRow-u)**2;return(t.desiredColumn-d)**2+(t.desiredRow-u)**2-n||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index});const h=/* @__PURE__ */new Set;for(let e=0;e<s;e+=1)for(let t=0;t<i;t+=1)h.add(e*i+t);const p=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=Math.floor(o/i),s=(o%i-e.desiredColumn)**2+(r-e.desiredRow)**2;(s<n||s===n&&o<t)&&(t=o,n=s)}t<0||(h.delete(t),p.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return p.sort((e,t)=>e.index-t.index),p.map(({index:e,...t})=>t)}function Ut(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function Xt(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??`area-${t}`;return{...n,id:String(o)}}function Kt(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function Jt(e,t,n){const o=[];for(let r=0;r<6;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return Kt(o)}function Zt(e){return e.areas.map((t,n)=>{const o=Xt(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function Qt(e){return e.points.map(t=>{const n=Number(Ut(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(Ut(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function en(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(Ut(e,t.columnAccessor)),y:Number(Ut(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}function tn({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=Ft();/* @__PURE__ */ /* @__PURE__ */
21
+ return(0,Sh.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const s=!i.isActive||i.predicate(e.datum);/* @__PURE__ */ /* @__PURE__ */
22
+ return(0,Sh.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function nn(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function on(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function rn(e){if(Number.isFinite(e)&&!(Number(e)<=0))return Number(e)}function sn(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function an(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function cn(e,t){const n=an(e);return String(e.id??n.id??n.name??`feature-${t}`)}function ln(e,t){if(0===e.length)return null;const n={type:"FeatureCollection",features:e},o=t.bounds(n);return Number.isFinite(o[0][0])&&Number.isFinite(o[0][1])&&Number.isFinite(o[1][0])&&Number.isFinite(o[1][1])?o:null}function dn(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function un(e){if(!e)return 0;const t=Rh.get(e);if(t)return t;const n=jh;return jh+=1,Rh.set(e,n),n}function hn(e){return e.map((e,t)=>{if(Ph.has(e))return{feature:e,index:t,bounds:Ph.get(e)??null};try{const n=nn();return Ph.set(e,n),{feature:e,index:t,bounds:n}}catch{return Ph.set(e,null),{feature:e,index:t,bounds:null}}})}function pn(e,t){return!t||e[1]>=t[0][1]&&e[1]<=t[1][1]&&(n=e[0],(o=t[0][0])<=(r=t[1][0])?n>=o&&n<=r:n>=o||n<=r);var n,o,r}function fn(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&pn(t,n.bounds))try{if(on())return{feature:e,index:o}}catch{}}return null}function mn(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=ln(r,t.geoPath);if(!i)return{dots:[],cellSize:Ch,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[xe(i[0][0],s,Math.max(s,n.width-s)),xe(i[0][1],s,Math.max(s,n.height-s))],[xe(i[1][0],s,Math.max(s,n.width-s)),xe(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:Ch,features:r};const d=rn(o.columns);let u=Math.max(2,d?c/d:rn(o.cellSize)??Ch);const h=Math.max(100,Math.round(rn(o.maxSamples)??Oh)),p=Math.ceil(c/u)*Math.ceil(l/u);p>h&&(u*=Math.sqrt(p/h));const f=o.gridOrigin?.[0]??0,m=o.gridOrigin?.[1]??0,[g,y]=dn(a[0][0],a[1][0],f,u),[x,b]=dn(a[0][1],a[1][1],m,u),w=[],M=hn(r);for(let e=x;e<=b;e+=1){const n=m+(e+.5)*u;for(let r=g;r<=y;r+=1){const i=f+(r+.5)*u,s=t.invertedPoint(i,n);if(!s||!Number.isFinite(s[0])||!Number.isFinite(s[1]))continue;const a=fn(M,s);if(!a)continue;const c={...an(a.feature),featureId:cn(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:r,longitude:s[0],latitude:s[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(c,w.length)||w.push(c)}}return{dots:w,cellSize:u,features:r}}function gn(e){return Math.round(1e4*e)/1e4}function yn(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${gn(Number(e[0]))},${gn(Number(e[1]))}`:"null"}function xn(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function bn(e){return"number"==typeof e&&Number.isFinite(e)?String(gn(e)):null===e?"null":"unavailable"}function wn(e){const t=e.scales.projection;return[bn(xn(t,"scale")),yn(xn(t,"translate")),yn(xn(t,"center")),(n=xn(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>gn(Number(e))).join(","):"unavailable"),bn(xn(t,"clipAngle")),bn(xn(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>yn(e.scales.projectedPoint(t,n)))].join("|");var n}function Mn(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",un(t.featureFilter),un(t.dotFilter),wn(e)].join("::")}function vn(e){let t=Th.get(e.areas);t||(t=/* @__PURE__ */new Map,Th.set(e.areas,t));const n=Mn(e),o=t.get(n);if(o)return o;const r=mn(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}function In(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function kn(e,t,n){return In([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}function Sn(e,t,n){return In(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}function $n(e,t,n){const o=e.data??e,r=o.x??e.x,i=o.y??e.y,s=e.createdByFrame&&0===e.width?void 0:e.width,a=e.createdByFrame&&0===e.height?void 0:e.height,c=o.width??s??t,l=o.height??a??n;if(!("number"!=typeof r||"number"!=typeof i||"number"!=typeof c||"number"!=typeof l||![r,i,c,l].every(Number.isFinite)||c<=0||l<=0))return{x:r,y:i,w:c,h:l}}function Nn(e,t,n){const{nodeWidth:o,nodeHeight:r,waypoints:i=[]}=n,s="none"===n.fit?"none":"contain";let a=1/0,c=1/0,l=-1/0,d=-1/0;const u=(e,t)=>{a=Math.min(a,e),c=Math.min(c,t),l=Math.max(l,e),d=Math.max(d,t)};let h=!1;for(const t of e){const e=$n(t,o,r);e&&(h=!0,u(e.x-e.w/2,e.y-e.h/2),u(e.x+e.w/2,e.y+e.h/2))}for(const e of i)u(e.x,e.y);let p=1,f=0,m=0;if("contain"===s&&h){const e=l-a,n=d-c;if(![e,n,t.x,t.y,t.width,t.height].every(Number.isFinite)||e<=0||n<=0||t.width<=0||t.height<=0)h=!1;else{const o=Math.min(1,t.width/4,t.height/4);p=Math.min(1,(t.width-2*o)/e,(t.height-2*o)/n),f=t.x+(t.width-e*p)/2-a*p,m=t.y+(t.height-n*p)/2-c*p}}const g=({x:e,y:t})=>({x:e*p+f,y:t*p+m});return{fit:s,scale:p,dx:f,dy:m,bounds:h?{x:a,y:c,width:l-a,height:d-c}:null,project:g,invert:({x:e,y:t})=>({x:(e-f)/p,y:(t-m)/p}),nodeBounds:e=>{const t=h?$n(e,o,r):void 0;if(!t)return;const{x:n,y:i}=g(t),s=t.w*p,a=t.h*p;return{x:n-s/2,y:i-a/2,width:s,height:a,cx:n,cy:i}}}}function En(e,t,n,o=[]){const r=Nn(e.nodes,e.dimensions.plot,{nodeWidth:t.nodeWidth,nodeHeight:t.nodeHeight,fit:t.fit,waypoints:o}),i=/* @__PURE__ */new Map,s=[],a=[];for(const o of e.nodes){const c=r.nodeBounds(o);if(!c)continue;const{cx:l,cy:d,width:u,height:h}=c;i.set(o.id,{x:l,y:d,w:u,h:h});const p=o.data??o,f=t.labelAccessor??"id",m=String("function"==typeof f?f(p):p[f]??o.id);s.push({type:"rect",x:c.x,y:c.y,w:u,h:h,style:{fill:t.nodeFill??e.resolveColor(o.id),stroke:n,strokeWidth:Math.min(1.5,u/2,h/2)},datum:p,id:o.id,label:m}),!1!==t.showLabels&&a.push({x:l,y:d,text:m,anchor:"middle",baseline:"middle",fontSize:11*r.scale})}return{positions:i,sceneNodes:s,labels:a,project:r.project}}function An(e,t,n={}){return Nn(e,t,{nodeWidth:n.nodeWidth??80,nodeHeight:n.nodeHeight??30,fit:n.fit})}function Cn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.min(0===n?1/0:e.w/2/Math.abs(n),0===o?1/0:e.h/2/Math.abs(o));return Number.isFinite(r)?{x:e.x+n*r,y:e.y+o*r}:{x:e.x,y:e.y}}function On(e,t,n,o,r,i=1){const s=t.x-n.x,a=t.y-n.y,c=Math.hypot(s,a);if(0===c||r<=0)return null;const l=Math.min(r,c)/c,d=s*l,u=a*l;return(0,Dh.createElement)("polygon",{key:e,className:"recipe-edge-arrow",points:`${t.x},${t.y} ${t.x-d-u/2},${t.y-u+d/2} ${t.x-d+u/2},${t.y-u-d/2}`,fill:o,opacity:i,"aria-hidden":!0,style:{pointerEvents:"none"}})}function Tn(e){const t=e.data??e,n=Array.isArray(t.points)?t.points:e.points;return Array.isArray(n)&&n.length>=2&&n.every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y))?n:[]}function Pn(e,t,n,o={}){return Nn(e,n,{nodeWidth:o.nodeWidth??100,nodeHeight:o.nodeHeight??36,fit:o.fit,waypoints:t.flatMap(Tn)})}function Rn(e,t){const n="function"==typeof t?t(e):e[t];return Gh(n)?n:void 0}function jn(e){return[...e].sort((e,t)=>je(e,t))}function Fn(e,t){const n=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}function Ln(e){const t=new Set(e.keys()),n=[];for(const o of jn(t)){if(!t.has(o))continue;const r=[o],i=[];t.delete(o);for(let n=0;n<r.length;n++){const o=r[n];i.push(o);for(const n of jn(e.get(o)??[]))t.has(n)&&(t.delete(n),r.push(n))}n.push(i.sort((e,t)=>je(e,t)))}return n.sort((e,t)=>t.length-e.length||je(e[0],t[0]))}function zn(e,t,n){const o=/* @__PURE__ */new Map([[e,0]]),r=[e];for(let e=0;e<r.length;e++){const i=r[e],s=o.get(i);for(const e of jn(n.get(i)??[]))t.has(e)&&!o.has(e)&&(o.set(e,s+1),r.push(e))}return o}function Dn(e,t,n){const o=zn(e,t,n);let r=e,i=-1;for(const[e,t]of o)(t>i||t===i&&je(e,r)<0)&&(r=e,i=t);return r}function _n(e,t,n){const o=new Set(e),r=e.filter(e=>(t.get(e)?.size??0)<=1)[0]??e[0],i=zn(n&&o.has(n)?n:Dn(Dn(r,o,t),o,t),o,t);let s=0;for(const e of i.values())s=Math.max(s,e);const a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>je(e,t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?Number.POSITIVE_INFINITY:n.reduce((e,t)=>e+t,0)/n.length},i=new Map(a[e].map(e=>[e,r(e)]));a[e].sort((e,t)=>i.get(e)-i.get(t)||je(e,t))};for(let e=0;e<4;e+=1){for(let e=1;e<a.length;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function Wn(e,t,n,o,r,i){const s=Fn(e.map(e=>e.id),t),a=Ln(s),c=new Map(e.map(e=>[e.id,e.data])),l=/* @__PURE__ */new Map,d=Math.max(0,n.width),u=Math.max(0,n.height),h=Math.min(o,d/2),p=Math.min(o,u/2),f=Math.max(0,u-2*p),m=a.length>1?Math.min(r,f/a.length):0,g=Math.max(0,f-m*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=p;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=_n(e,s,i),o=Math.max(0,d-2*h);n.forEach((e,r)=>{const i=1===n.length?d/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{const r=1===e.length?x+t/2:x+o/(e.length-1)*t;l.set(n,{id:n,x:i,y:r,data:c.get(n)})})}),x+=t+m}return l}function qn(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:Rn(e.data,s),authoredY:Rn(e.data,a)})),l=c.length>0&&c.every(e=>Gh(e.authoredX)&&Gh(e.authoredY)),d="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,u=[];if(d&&!l&&u.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!d||!l){l||"automatic"===o.layoutMode||u.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=Wn(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:u,projectAuthoredPoint:e=>e}}let h=1/0,p=-1/0,f=1/0,m=-1/0;for(const e of c)h=Math.min(h,e.authoredX),p=Math.max(p,e.authoredX),f=Math.min(f,e.authoredY),m=Math.max(m,e.authoredY);const g=Math.max(1,n.width-2*r),y=Math.max(1,n.height-2*r),x=e=>({x:p===h?n.width/2:r+(e.x-h)/(p-h)*g,y:m===f?n.height/2:r+(e.y-f)/(m-f)*y}),b=/* @__PURE__ */new Map;for(const e of c){const t=x({x:e.authoredX,y:e.authoredY});b.set(e.id,{id:e.id,...t,data:e.data})}return{positions:b,mode:"authored",warnings:u,projectAuthoredPoint:x}}function Bn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(r<.001||i<.001||Math.abs(r-i)<.001)return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function Gn(e,t){if(0===t||e.length<2)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=r<e.length-1?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(l<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const d=a*s.x+c*s.y;if(Math.abs(d)<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};const u=4*Math.abs(t),h=t/d,p=Math.max(-u,Math.min(u,h));return{x:o.x+a*p,y:o.y+c*p}})}function Yn(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;t<e.length-1;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(l<=.001){o+=` L${i.x},${i.y}`;continue}const d={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},u={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${d.x},${d.y} Q${i.x},${i.y} ${u.x},${u.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function Vn(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):we(e.data,t.labelAccessor??"label",e.id)}function Hn(e){return"string"==typeof e?e:e.id}function Un(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:String(e.id)}:{id:String(e)});return t.length>0?t:[{id:"network"}]}function Xn(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,Un(o)}function Kn(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function Jn(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=/* @__PURE__ */new Map,l=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(const e of a){const t={id:e.id,label:String(Vn(e,n)),color:Kn(e,n,o)},r=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=/* @__PURE__ */new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const d=e=>[...e].sort((e,t)=>je(e.id,t.id));return{byEdge:new Map(t.map(e=>[e,d(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,d(l.get(e.id)?.values()??[])]))}}function Zn(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function Qn(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=r.source<r.target?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:/* @__PURE__ */new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??Xn(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>je(e.key,t.key))}function eo(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??Number.POSITIVE_INFINITY)-(n.get(t)??Number.POSITIVE_INFINITY)||je(e,t))}function to(e,t){const n=e.authoredOrder??t.lineOrder??[],o=new Map(n.map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(o.get(e.descriptor.id)??Number.POSITIVE_INFINITY)-(o.get(t.descriptor.id)??Number.POSITIVE_INFINITY)||je(e.descriptor.id,t.descriptor.id))}function no(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>{const n=e;return"number"==typeof n.x&&"number"==typeof n.y?t.projectAuthoredPoint({x:n.x,y:n.y}):null}).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function oo(e,t){return Ie(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function ro(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||je(e.id,t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):String(we(e.data,i.labelAccessor??"label",e.id)))||e.id,d=Math.max(2*s,l.length*s*.58),u=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,p=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-d},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-d/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-d/2}].map((e,t)=>{const n={left:e.left,right:e.left+d,top:e.y-u/2,bottom:e.y+u/2},o=a.filter(e=>{return o=e,(t=n).left<o.right&&t.right>o.left&&t.top<o.bottom&&t.bottom>o.top;var t,o}).length,i=Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height);return{candidate:e,box:n,score:1e4*o+10*i+t}}).sort((e,t)=>e.score-t.score)[0];a.push(p.box),c.push({x:p.candidate.x,y:p.candidate.y,anchorPoint:[n.x,n.y],text:l,anchor:p.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function io(e,t,n={}){const o=n.layerAccessor??"x",r=n.rowAccessor??"y";let i=1/0,s=-1/0,a=1/0,c=-1/0;for(const t of e){const e=Number(we(t,o,0)),n=Number(we(t,r,0));Number.isFinite(e)&&Number.isFinite(n)&&(i=Math.min(i,e),s=Math.max(s,e),a=Math.min(a,n),c=Math.max(c,n))}if(i===1/0&&(i=s=a=c=0),Number.isFinite(n.layerCount)&&n.layerCount>0&&(i=Math.min(i,0),s=Math.max(s,n.layerCount-1)),Number.isFinite(n.maxLayerSize)&&n.maxLayerSize>0){const e=Math.max(0,n.maxLayerSize-1)/2;a=Math.min(a,-e),c=Math.max(c,e)}const l=s-i,d=Math.max(1,c-a),u=(a+c-d)/2,h=l+1,p=c-a+1,f=t.width/Math.max(1,h),m=t.height/Math.max(1,p);let g=Math.min(n.nodeWidth??172,Math.max(8,f-(n.minGapX??26))),y=Math.min(n.nodeHeight??54,Math.max(8,m-(n.minGapY??18)));const x=n.lod&&"auto"!==n.lod?n.lod:g<16?"dot":g<48?"icon":g<108?"compact":"full";if("dot"===x){const e=Math.min(g,y,11);g=e,y=e}const b=Math.max(1,t.width-g),w=Math.max(1,t.height-y),{x:M,y:v}=t,I=(e,t)=>({x:M+g/2+(l>0?(e-i)/l:.5)*b,y:v+y/2+(t-u)/d*w});return{layerCount:h,maxLayerSize:p,nodeWidth:g,nodeHeight:y,lod:x,project:I,invert:(e,t)=>({layer:l>0?i+(e-M-g/2)/b*l:null,row:(t-v-y/2)/w*d+u}),nodeBounds:e=>{const t=I(Number(we(e,o,0)),Number(we(e,r,0)));return{x:t.x-g/2,y:t.y-y/2,width:g,height:y,cx:t.x,cy:t.y}}}}function so(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function ao(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(t.length<=2)return t;const n=[];for(const e of t){for(;n.length>=2&&so(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&so(o[o.length-2],o[o.length-1],n)<=0;)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}function co(e,t){if(0===t||e.length<3)return e;const n=e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)>=0?1:-1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},d=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},u={x:l.x+d.x,y:l.y+d.y},h=Math.hypot(u.x,u.y);if(h<1e-9)return{x:o.x+d.x*t,y:o.y+d.y*t};const p=u.x/h,f=u.y/h,m=Math.max(1e-6,p*d.x+f*d.y),g=t/m;return{x:o.x+p*g,y:o.y+f*g}})}function lo(e){return String(Math.abs(e)<1e-12?0:e)}function uo(e,t){if(0===e.length)return"";if(e.length<3||0===t)return`${e.map((e,t)=>`${0===t?"M":"L"}${lo(e.x)},${lo(e.y)}`).join(" ")} Z`;const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${lo(o.x)},${lo(o.y)}`;for(let e=1;e<n.length;e++){const t=n[e];r+=` L${lo(t.incoming.x)},${lo(t.incoming.y)}`,r+=` Q${lo(t.point.x)},${lo(t.point.y)} ${lo(t.outgoing.x)},${lo(t.outgoing.y)}`}const i=n[0];return r+=` L${lo(i.incoming.x)},${lo(i.incoming.y)}`,r+=` Q${lo(i.point.x)},${lo(i.point.y)} ${lo(i.outgoing.x)},${lo(i.outgoing.y)} Z`,r}function ho(t,n){const o=[];for(const[r,i]of t){const t=co(ao(i.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),n.padding);if(!t.length)continue;const[s,a]=e(t,e=>e.x),[c,l]=e(t,e=>e.y);o.push({x:s,y:c,width:a-s,height:l-c});const d=n.label?.(r);d&&o.push({x:s+8,y:c+14,z:0,extent:[0,6.6*d.length,12,3]})}return o}function po(e,n){const o=Array.from(e.entries()).sort(([e],[t])=>e<t?-1:e>t?1:0);/* @__PURE__ */ /* @__PURE__ */
23
+ return(0,Uh.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:o.map(([e,o])=>{const r=co(ao(o.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),n.padding),i=uo(r,n.radius),s=Object.prototype.hasOwnProperty.call(n.colors??{},e)?n.colors?.[e]??n.resolveColor(e):n.resolveColor(e),a=o.every(e=>!0===n.dimById.get(e.id)&&e.id!==n.selectedId),c=t(r.map(e=>e.x)),l=t(r.map(e=>e.y)),d=n.label?.(e);/* @__PURE__ */ /* @__PURE__ */
24
+ return(0,Uh.jsxs)("g",{"data-lineage-hull":e,opacity:a?n.dimOpacity:void 0,children:[
25
25
  /* @__PURE__ */
26
- /* @__PURE__ */(0,Yh.jsx)(Bh.NetworkPerspectiveGround,{children:/* @__PURE__ */ /* @__PURE__ */(0,Yh.jsx)("path",{className:"lineage-dag-hull",d:i,fill:s,fillOpacity:n.fillOpacity,stroke:s,strokeOpacity:n.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}})}),d?/* @__PURE__ */ /* @__PURE__ */(0,Yh.jsx)(Bh.NetworkPerspectiveBillboard,{x:c+8,y:l+14,z:0,children:/* @__PURE__ */ /* @__PURE__ */(0,Yh.jsx)("text",{className:"lineage-dag-hull-label",x:c+8,y:l+14,fill:s,fillOpacity:Math.max(n.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:d})}):null]},e)})})}function fo(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:String(e.storeName??""),slotIndex:e.slotIndex??t}):[]}function mo(e,t){return Number.isFinite(e)?xe(e,0,1):t}function go(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),s=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",a="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:s,node:e.node}):yo(e.semantic,e.partition,i),l="full"===r,d="icon"!==r,u="full"===r&&t.showChips&&e.stores.length>0;/* @__PURE__ */ /* @__PURE__ */
27
- return(0,Vh.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[
26
+ /* @__PURE__ */(0,Uh.jsx)(Hh.NetworkPerspectiveGround,{children:/* @__PURE__ */ /* @__PURE__ */(0,Uh.jsx)("path",{className:"lineage-dag-hull",d:i,fill:s,fillOpacity:n.fillOpacity,stroke:s,strokeOpacity:n.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}})}),d?/* @__PURE__ */ /* @__PURE__ */(0,Uh.jsx)(Hh.NetworkPerspectiveBillboard,{x:c+8,y:l+14,z:0,children:/* @__PURE__ */ /* @__PURE__ */(0,Uh.jsx)("text",{className:"lineage-dag-hull-label",x:c+8,y:l+14,fill:s,fillOpacity:Math.max(n.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:d})}):null]},e)})})}function fo(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:String(e.storeName??""),slotIndex:e.slotIndex??t}):[]}function mo(e,t){return Number.isFinite(e)?xe(e,0,1):t}function go(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),s=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",a="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:s,node:e.node}):yo(e.semantic,e.partition,i),l="full"===r,d="icon"!==r,u="full"===r&&t.showChips&&e.stores.length>0;/* @__PURE__ */ /* @__PURE__ */
27
+ return(0,Xh.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[
28
28
  /* @__PURE__ */
29
- /* @__PURE__ */(0,Vh.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),d&&
29
+ /* @__PURE__ */(0,Xh.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),d&&
30
30
  /* @__PURE__ */
31
- /* @__PURE__ */(0,Vh.jsx)("foreignObject",{x:a,y:l?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),u&&e.stores.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}function yo(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";/* @__PURE__ */ /* @__PURE__ */
32
- return(0,Vh.jsxs)("g",{children:[
31
+ /* @__PURE__ */(0,Xh.jsx)("foreignObject",{x:a,y:l?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),u&&e.stores.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}function yo(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";/* @__PURE__ */ /* @__PURE__ */
32
+ return(0,Xh.jsxs)("g",{children:[
33
33
  /* @__PURE__ */
34
- /* @__PURE__ */(0,Vh.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),
34
+ /* @__PURE__ */(0,Xh.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),
35
35
  /* @__PURE__ */
36
- /* @__PURE__ */(0,Vh.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}async function xo(e,t,n={}){const{prepareNetworkAtlas:o}=await Promise.resolve().then(()=>(pu(),hu));return o(e,t,n)}async function bo(e){const{prepareMotifBraid:t}=await Promise.resolve().then(()=>(ku(),gu));return t(e)}function wo(e){const t=[e[0]];for(let n=1;n<e.length-1;n++){const o=e[n-1],r=e[n],i=e[n+1],s=Jh(o,r),a=Jh(r,i),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=Kh(r,o,c/s),d=Kh(r,i,c/a);t.push(l);for(let e=1;e<=12;e++){const n=e/12;t.push(Kh(Kh(l,r,n),Kh(r,d,n),n))}}return t.push(e[e.length-1]),t.filter((e,n)=>0===n||Jh(t[n-1],e)>1e-8)}function Mo(e,t,n){if(e.length<2)return"";const o=wo(e);if(o.length<2)return"";const r=[0];for(let e=1;e<o.length;e++)r.push(r[e-1]+Jh(o[e-1],o[e]));const i=r[r.length-1],s=Bn(o,1),a=[1,-1].map(e=>o.map((o,a)=>{const c=t+(n-t)*r[a]/i;return Kh(o,s[a],e*c/2)}));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function vo(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const n=t+e/2;return t+=e+3,n})}function ko(e){let t="";return e.split(">").map((e,n)=>t=n?`${t}>${e}`:e)}function Io(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=ko(n.signature);n.nodePath.forEach((o,r)=>{const i=e[r];let s=t.get(i);s||(s={id:i,state:o,depth:r+1,signatures:/* @__PURE__ */new Set},t.set(i,s)),s.signatures.add(n.signature)})}return[...t.values()]}function So(e,t){return e.length>t?`${e.slice(0,Math.max(1,t-1))}…`:e}function $o(e,t,n,o,r,i,s,a){const c=t-o/2,l=n-r/2,d={fill:i,stroke:s,strokeWidth:a};switch(e){case"diamond":{const e=`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`;/* @__PURE__ */ /* @__PURE__ */
37
- return(0,op.jsx)("polygon",{points:e,...d})}case"circle":/* @__PURE__ */ /* @__PURE__ */
38
- return(0,op.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...d});case"stadium":case"round":/* @__PURE__ */ /* @__PURE__ */
39
- return(0,op.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...d});case"hexagon":{const e=Math.min(.18*o,16),i=`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`;/* @__PURE__ */ /* @__PURE__ */
40
- return(0,op.jsx)("polygon",{points:i,...d})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,n=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;/* @__PURE__ */ /* @__PURE__ */
41
- return(0,op.jsxs)("g",{children:[
36
+ /* @__PURE__ */(0,Xh.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}async function xo(e,t,n={}){const{prepareNetworkAtlas:o}=await Promise.resolve().then(()=>(gu(),mu));return o(e,t,n)}async function bo(e){const{prepareMotifBraid:t}=await Promise.resolve().then(()=>($u(),bu));return t(e)}function wo(e){const t=[e[0]];for(let n=1;n<e.length-1;n++){const o=e[n-1],r=e[n],i=e[n+1],s=ep(o,r),a=ep(r,i),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=Qh(r,o,c/s),d=Qh(r,i,c/a);t.push(l);for(let e=1;e<=12;e++){const n=e/12;t.push(Qh(Qh(l,r,n),Qh(r,d,n),n))}}return t.push(e[e.length-1]),t.filter((e,n)=>0===n||ep(t[n-1],e)>1e-8)}function Mo(e,t,n){if(e.length<2)return"";const o=wo(e);if(o.length<2)return"";const r=[0];for(let e=1;e<o.length;e++)r.push(r[e-1]+ep(o[e-1],o[e]));const i=r[r.length-1],s=Gn(o,1),a=[1,-1].map(e=>o.map((o,a)=>{const c=t+(n-t)*r[a]/i;return Qh(o,s[a],e*c/2)}));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function vo(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const n=t+e/2;return t+=e+3,n})}function Io(e){let t="";return e.split(">").map((e,n)=>t=n?`${t}>${e}`:e)}function ko(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=Io(n.signature);n.nodePath.forEach((o,r)=>{const i=e[r];let s=t.get(i);s||(s={id:i,state:o,depth:r+1,signatures:/* @__PURE__ */new Set},t.set(i,s)),s.signatures.add(n.signature)})}return[...t.values()]}function So(e,t){return e.length>t?`${e.slice(0,Math.max(1,t-1))}…`:e}function $o(e,t,n,o,r,i,s,a){const c=t-o/2,l=n-r/2,d={fill:i,stroke:s,strokeWidth:a};switch(e){case"diamond":{const e=`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`;/* @__PURE__ */ /* @__PURE__ */
37
+ return(0,sp.jsx)("polygon",{points:e,...d})}case"circle":/* @__PURE__ */ /* @__PURE__ */
38
+ return(0,sp.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...d});case"stadium":case"round":/* @__PURE__ */ /* @__PURE__ */
39
+ return(0,sp.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...d});case"hexagon":{const e=Math.min(.18*o,16),i=`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`;/* @__PURE__ */ /* @__PURE__ */
40
+ return(0,sp.jsx)("polygon",{points:i,...d})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,n=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;/* @__PURE__ */ /* @__PURE__ */
41
+ return(0,sp.jsxs)("g",{children:[
42
42
  /* @__PURE__ */
43
- /* @__PURE__ */(0,op.jsx)("path",{d:t,...d}),
43
+ /* @__PURE__ */(0,sp.jsx)("path",{d:t,...d}),
44
44
  /* @__PURE__ */
45
- /* @__PURE__ */(0,op.jsx)("path",{d:n,fill:"none",stroke:s,strokeWidth:a})]})}case"subroutine":{const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
46
- return(0,op.jsxs)("g",{children:[
45
+ /* @__PURE__ */(0,sp.jsx)("path",{d:n,fill:"none",stroke:s,strokeWidth:a})]})}case"subroutine":{const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
46
+ return(0,sp.jsxs)("g",{children:[
47
47
  /* @__PURE__ */
48
- /* @__PURE__ */(0,op.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...d}),
48
+ /* @__PURE__ */(0,sp.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...d}),
49
49
  /* @__PURE__ */
50
- /* @__PURE__ */(0,op.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:s,strokeWidth:a}),
50
+ /* @__PURE__ */(0,sp.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:s,strokeWidth:a}),
51
51
  /* @__PURE__ */
52
- /* @__PURE__ */(0,op.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:s,strokeWidth:a})]})}default:/* @__PURE__ */ /* @__PURE__ */
53
- return(0,op.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...d})}}function No(e,t,n,o,r){const i=Math.max(0,Math.min(r,n/2,o/2)),s=e+n,a=t+o;return`M${e+i},${t} H${s-i} A${i},${i} 0 0 1 ${s},${t+i} V${a-i} A${i},${i} 0 0 1 ${s-i},${a} H${e+i} A${i},${i} 0 0 1 ${e},${a-i} V${t+i} A${i},${i} 0 0 1 ${e+i},${t} Z`}function Eo(e,t,n,o,r){const i=t-o/2,s=n-r/2;switch(e){case"diamond":return`M${t},${s} L${t+o/2},${n} L${t},${n+r/2} L${i},${n} Z`;case"circle":{const e=Math.min(o,r)/2;return`M${t-e},${n} A${e},${e} 0 1 1 ${t+e},${n} A${e},${e} 0 1 1 ${t-e},${n} Z`}case"stadium":case"round":return No(i,s,o,r,"stadium"===e?r/2:8);case"hexagon":{const e=Math.min(.18*o,16);return`M${i+e},${s} L${t+o/2-e},${s} L${t+o/2},${n} L${t+o/2-e},${n+r/2} L${i+e},${n+r/2} L${i},${n} Z`}case"cylinder":{const e=Math.min(.16*r,8);return`M${i},${s+e} A${o/2},${e} 0 0 1 ${i+o},${s+e} V${s+r-e} A${o/2},${e} 0 0 1 ${i},${s+r-e} Z`}case"subroutine":return No(i,s,o,r,3);default:return No(i,s,o,r,4)}}function Ao(e,t,n,o,r,i){const s=t-o/2,a=n-r/2;if("cylinder"===e){const e=Math.min(.16*r,8);/* @__PURE__ */ /* @__PURE__ */
54
- return(0,op.jsx)("path",{d:`M${s},${a+e} a${o/2},${e} 0 0 0 ${o},0`,fill:"none",stroke:i,strokeWidth:1.5})}if("subroutine"===e){const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
55
- return(0,op.jsx)("path",{d:`M${s+e},${a} V${a+r} M${s+o-e},${a} V${a+r}`,fill:"none",stroke:i,strokeWidth:1.5})}return null}function Co(e,t){const n=x({nodes:e.map(e=>({id:e})),edges:e.flatMap(e=>[...t.get(e)].map(t=>({source:e,target:t})))}),o=/* @__PURE__ */new Map;n.forEach((e,t)=>e.forEach(e=>o.set(e,t)));const r=n.length,i=Array.from({length:r},()=>/* @__PURE__ */new Set),s=Array.from({length:r},()=>/* @__PURE__ */new Set);for(const n of e){const e=o.get(n);for(const r of t.get(n)){const t=o.get(r);e!==t&&(s[e].add(t),i[t].add(e))}}const a=s.map(e=>e.size),c=a.flatMap((e,t)=>0===e?[t]:[]),l=c.length,d=i.filter(e=>0===e.size).length,u=new Int32Array(r);let h=0;for(let e=0;e<c.length;e++){const t=c[e];for(const e of i[t])u[e]=Math.max(u[e],u[t]+1),h=Math.max(h,u[e]),0===--a[e]&&c.push(e)}return{sinkCount:l,sourceCount:d,layerCount:h+1,layer:new Map(e.map(e=>[e,h-u[o.get(e)]]))}}function Oo(e,t=2166136261){let n=t;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function To(e){return Oo(e)/4294967295}function Po(e){/* @__PURE__ */ /* @__PURE__ */
56
- return(0,ap.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Ro(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;t.x-e<n&&(n=t.x-e),t.x+e>r&&(r=t.x+e),t.y-e<o&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function jo(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);t.x<r&&(r=t.x),t.y<i&&(i=t.y),t.x+e>s&&(s=t.x+e),t.y+n>a&&(a=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:s-r+2*n,height:a-i+2*o}:null}function Fo(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,ap.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function Lo(e){const t=e.spacing??8,n=e.color??"currentColor";return{def:/* @__PURE__ */ /* @__PURE__ */(0,ap.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:/* @__PURE__ */ /* @__PURE__ */(0,ap.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:n,strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function zo(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,s=e.labelGap??4,a=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,d=e.format??(e=>String(e)),u="top"===t||"left"===t?-1:1,h=e.ticks.length-1,p=e.ticks.map((p,f)=>{const m=e.scale(p),g=o+u*r,y=o-u*i,x=g+u*s;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===f?"start":e.edgeAnchor&&f===h?"end":"middle":"left"===t?"end":"start";const w=n?{x1:m,x2:m,y1:g,y2:y}:{x1:g,x2:y,y1:m,y2:m},M=n?"top"===t?"auto":"hanging":"middle",v=n?{x:m,y:x}:{x:x,y:m};/* @__PURE__ */ /* @__PURE__ */
57
- return(0,ap.jsxs)("g",{children:[(r>0||i>0)&&/* @__PURE__ */ /* @__PURE__ */(0,ap.jsx)("line",{...w,stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),
52
+ /* @__PURE__ */(0,sp.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:s,strokeWidth:a})]})}default:/* @__PURE__ */ /* @__PURE__ */
53
+ return(0,sp.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...d})}}function No(e,t,n,o,r){const i=Math.max(0,Math.min(r,n/2,o/2)),s=e+n,a=t+o;return`M${e+i},${t} H${s-i} A${i},${i} 0 0 1 ${s},${t+i} V${a-i} A${i},${i} 0 0 1 ${s-i},${a} H${e+i} A${i},${i} 0 0 1 ${e},${a-i} V${t+i} A${i},${i} 0 0 1 ${e+i},${t} Z`}function Eo(e,t,n,o,r){const i=t-o/2,s=n-r/2;switch(e){case"diamond":return`M${t},${s} L${t+o/2},${n} L${t},${n+r/2} L${i},${n} Z`;case"circle":{const e=Math.min(o,r)/2;return`M${t-e},${n} A${e},${e} 0 1 1 ${t+e},${n} A${e},${e} 0 1 1 ${t-e},${n} Z`}case"stadium":case"round":return No(i,s,o,r,"stadium"===e?r/2:8);case"hexagon":{const e=Math.min(.18*o,16);return`M${i+e},${s} L${t+o/2-e},${s} L${t+o/2},${n} L${t+o/2-e},${n+r/2} L${i+e},${n+r/2} L${i},${n} Z`}case"cylinder":{const e=Math.min(.16*r,8);return`M${i},${s+e} A${o/2},${e} 0 0 1 ${i+o},${s+e} V${s+r-e} A${o/2},${e} 0 0 1 ${i},${s+r-e} Z`}case"subroutine":return No(i,s,o,r,3);default:return No(i,s,o,r,4)}}function Ao(e,t,n,o,r,i){const s=t-o/2,a=n-r/2;if("cylinder"===e){const e=Math.min(.16*r,8);/* @__PURE__ */ /* @__PURE__ */
54
+ return(0,sp.jsx)("path",{d:`M${s},${a+e} a${o/2},${e} 0 0 0 ${o},0`,fill:"none",stroke:i,strokeWidth:1.5})}if("subroutine"===e){const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
55
+ return(0,sp.jsx)("path",{d:`M${s+e},${a} V${a+r} M${s+o-e},${a} V${a+r}`,fill:"none",stroke:i,strokeWidth:1.5})}return null}function Co(e,t){const n=x({nodes:e.map(e=>({id:e})),edges:e.flatMap(e=>[...t.get(e)].map(t=>({source:e,target:t})))}),o=/* @__PURE__ */new Map;n.forEach((e,t)=>e.forEach(e=>o.set(e,t)));const r=n.length,i=Array.from({length:r},()=>/* @__PURE__ */new Set),s=Array.from({length:r},()=>/* @__PURE__ */new Set);for(const n of e){const e=o.get(n);for(const r of t.get(n)){const t=o.get(r);e!==t&&(s[e].add(t),i[t].add(e))}}const a=s.map(e=>e.size),c=a.flatMap((e,t)=>0===e?[t]:[]),l=c.length,d=i.filter(e=>0===e.size).length,u=new Int32Array(r);let h=0;for(let e=0;e<c.length;e++){const t=c[e];for(const e of i[t])u[e]=Math.max(u[e],u[t]+1),h=Math.max(h,u[e]),0===--a[e]&&c.push(e)}return{sinkCount:l,sourceCount:d,layerCount:h+1,layer:new Map(e.map(e=>[e,h-u[o.get(e)]]))}}function Oo(e,t=2166136261){let n=t;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function To(e){return Oo(e)/4294967295}function Po(e){/* @__PURE__ */ /* @__PURE__ */
56
+ return(0,dp.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Ro(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;t.x-e<n&&(n=t.x-e),t.x+e>r&&(r=t.x+e),t.y-e<o&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function jo(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);t.x<r&&(r=t.x),t.y<i&&(i=t.y),t.x+e>s&&(s=t.x+e),t.y+n>a&&(a=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:s-r+2*n,height:a-i+2*o}:null}function Fo(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,dp.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function Lo(e){const t=e.spacing??8,n=e.color??"currentColor";return{def:/* @__PURE__ */ /* @__PURE__ */(0,dp.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:/* @__PURE__ */ /* @__PURE__ */(0,dp.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:n,strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function zo(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,s=e.labelGap??4,a=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,d=e.format??(e=>String(e)),u="top"===t||"left"===t?-1:1,h=e.ticks.length-1,p=e.ticks.map((p,f)=>{const m=e.scale(p),g=o+u*r,y=o-u*i,x=g+u*s;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===f?"start":e.edgeAnchor&&f===h?"end":"middle":"left"===t?"end":"start";const w=n?{x1:m,x2:m,y1:g,y2:y}:{x1:g,x2:y,y1:m,y2:m},M=n?"top"===t?"auto":"hanging":"middle",v=n?{x:m,y:x}:{x:x,y:m};/* @__PURE__ */ /* @__PURE__ */
57
+ return(0,dp.jsxs)("g",{children:[(r>0||i>0)&&/* @__PURE__ */ /* @__PURE__ */(0,dp.jsx)("line",{...w,stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),
58
58
  /* @__PURE__ */
59
- /* @__PURE__ */(0,ap.jsx)("text",{x:v.x,y:v.y,textAnchor:b,dominantBaseline:M,fontSize:a,fontWeight:e.fontWeight,fill:c,children:d(p)})]},`tick-${p}-${f}`)});/* @__PURE__ */ /* @__PURE__ */
60
- return(0,ap.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:p},e.keyId)}function Do(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,s=Math.hypot(r,i)||1,a=e.markX+r/s*o,c=e.markY+i/s*o;let l;return l="elbow"===e.connector?`M${a},${c} L${a},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${a},${c} Q${(a+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${a},${c} L${e.labelX},${e.labelY}`,/* @__PURE__ */ /* @__PURE__ */(0,ap.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&/* @__PURE__ */ /* @__PURE__ */(0,ap.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),
59
+ /* @__PURE__ */(0,dp.jsx)("text",{x:v.x,y:v.y,textAnchor:b,dominantBaseline:M,fontSize:a,fontWeight:e.fontWeight,fill:c,children:d(p)})]},`tick-${p}-${f}`)});/* @__PURE__ */ /* @__PURE__ */
60
+ return(0,dp.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:p},e.keyId)}function Do(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,s=Math.hypot(r,i)||1,a=e.markX+r/s*o,c=e.markY+i/s*o;let l;return l="elbow"===e.connector?`M${a},${c} L${a},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${a},${c} Q${(a+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${a},${c} L${e.labelX},${e.labelY}`,/* @__PURE__ */ /* @__PURE__ */(0,dp.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&/* @__PURE__ */ /* @__PURE__ */(0,dp.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),
61
61
  /* @__PURE__ */
62
- /* @__PURE__ */(0,ap.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),
62
+ /* @__PURE__ */(0,dp.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),
63
63
  /* @__PURE__ */
64
- /* @__PURE__ */(0,ap.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function _o(e,t,n,o){if(!t)return{bands:e};const r=e=>o?(n?48:4)+Math.max(13*e.descriptor.length*.6,11*`×${e.count} · ${e.directed?"converges to 1 sink":"branches to ≥2 sinks"}`.length*.56):n?44:0,i=e.map(e=>({...e,width:Math.min(e.width,Math.max(e.contentWidth??e.width,r(e)))}));return{bands:i,bounds:i.flatMap(e=>[{x:e.x-6,y:e.y-4,width:e.width+12,height:e.height+4},{x:e.x,y:e.y,z:0,extent:[0,r(e),2,32]}])}}function Wo(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor,r=[];if(n.push(
64
+ /* @__PURE__ */(0,dp.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function _o(e,t,n,o){if(!t)return{bands:e};const r=e=>o?(n?48:4)+Math.max(13*e.descriptor.length*.6,11*`×${e.count} · ${e.directed?"converges to 1 sink":"branches to ≥2 sinks"}`.length*.56):n?44:0,i=e.map(e=>({...e,width:Math.min(e.width,Math.max(e.contentWidth??e.width,r(e)))}));return{bands:i,bounds:i.flatMap(e=>[{x:e.x-6,y:e.y-4,width:e.width+12,height:e.height+4},{x:e.x,y:e.y,z:0,extent:[0,r(e),2,32]}])}}function Wo(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor,r=[];if(n.push(
65
65
  /* @__PURE__ */
66
- /* @__PURE__ */(0,cp.jsx)(sp.NetworkPerspectiveGround,{children:Po({keyId:`band-${o.motif}`,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})},`ground-${o.motif}`)),t.showExemplars&&o.exemplar){const n=o.exemplar;r.push(
66
+ /* @__PURE__ */(0,up.jsx)(lp.NetworkPerspectiveGround,{children:Po({keyId:`band-${o.motif}`,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})},`ground-${o.motif}`)),t.showExemplars&&o.exemplar){const n=o.exemplar;r.push(
67
67
  /* @__PURE__ */
68
- /* @__PURE__ */(0,cp.jsxs)("g",{style:{pointerEvents:"none"},children:[n.edges.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,cp.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},`exe-${n}`)),n.nodes.map(t=>/* @__PURE__ */ /* @__PURE__ */(0,cp.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},`exn-${t.id}`))]},`ex-${o.motif}`))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);r.push(
68
+ /* @__PURE__ */(0,up.jsxs)("g",{style:{pointerEvents:"none"},children:[n.edges.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,up.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},`exe-${n}`)),n.nodes.map(t=>/* @__PURE__ */ /* @__PURE__ */(0,up.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},`exn-${t.id}`))]},`ex-${o.motif}`))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);r.push(
69
69
  /* @__PURE__ */
70
- /* @__PURE__ */(0,cp.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},`bl-${o.motif}`)),r.push(
70
+ /* @__PURE__ */(0,up.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},`bl-${o.motif}`)),r.push(
71
71
  /* @__PURE__ */
72
- /* @__PURE__ */(0,cp.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},`bc-${o.motif}`))}r.length&&n.push(
72
+ /* @__PURE__ */(0,up.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},`bc-${o.motif}`))}r.length&&n.push(
73
73
  /* @__PURE__ */
74
- /* @__PURE__ */(0,cp.jsx)(sp.NetworkPerspectiveBillboard,{x:o.x,y:o.y,z:0,children:r},`header-${o.motif}`))}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push(
74
+ /* @__PURE__ */(0,up.jsx)(lp.NetworkPerspectiveBillboard,{x:o.x,y:o.y,z:0,children:r},`header-${o.motif}`))}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push(
75
75
  /* @__PURE__ */
76
- /* @__PURE__ */(0,cp.jsxs)("g",{style:{pointerEvents:"none"},children:[
76
+ /* @__PURE__ */(0,up.jsxs)("g",{style:{pointerEvents:"none"},children:[
77
77
  /* @__PURE__ */
78
- /* @__PURE__ */(0,cp.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),
78
+ /* @__PURE__ */(0,up.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),
79
79
  /* @__PURE__ */
80
- /* @__PURE__ */(0,cp.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),
80
+ /* @__PURE__ */(0,up.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),
81
81
  /* @__PURE__ */
82
- /* @__PURE__ */(0,cp.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),
82
+ /* @__PURE__ */(0,up.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),
83
83
  /* @__PURE__ */
84
- /* @__PURE__ */(0,cp.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;/* @__PURE__ */ /* @__PURE__ */
85
- return(0,cp.jsx)("g",{className:"net-ensemble-overlays",children:n})}function qo(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=/* @__PURE__ */new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{components:s}=Ko(r,t,o),a=s.map(e=>({ids:[...e.ids],nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Ho(e)})),c=/* @__PURE__ */new Map;for(const e of a){const t=c.get(e.motif);t?t.count+=1:c.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:a,motifs:[...c.values()].sort((e,t)=>t.count-e.count),directedCount:a.filter(e=>e.directed).length,branchingCount:a.filter(e=>!e.directed).length}}function Go(e){return Oo(e).toString(36)}function Bo(e){return"string"==typeof e?e:e?.id}function Yo(e,t,n,o,r){const i=new Set(e);let s=/* @__PURE__ */new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;o<r;o+=1){const o=/* @__PURE__ */new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,Go(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return Go(`${e.length}#${o}#${a.join(";")}`)}function Vo(e,t,n,o,r){function i(e){let t=0,r=0;for(const o of n.get(e)??[]){const e=h.get(o);p.has(o)&&e&&(t+=e.x,r+=1)}return r>0?t/r:o.x+d/2}const{layer:s,layerCount:a}=e,c=Array.from({length:a},()=>[]);for(const t of e.ids)c[s.get(t)].push(t);const l=.14*Math.min(o.width,o.height),d=Math.max(1,o.width-2*l),u=Math.max(1,o.height-2*l),h=/* @__PURE__ */new Map,p=new Set(e.ids);for(let e=0;e<a;e+=1){let t=c[e];e>0&&(t=[...t].sort((e,t)=>i(e)-i(t)));const n=t.length,r=o.y+l+(1===a?.5:e/(a-1))*u;t.forEach((e,t)=>{const i=o.x+l+(1===n?.5:t/(n-1))*d;h.set(e,{x:i,y:r})})}const f=c.reduce((e,t)=>Math.max(e,t.length),1),m=xe(Math.min(r,d/(2.4*f),u/(2.4*a)),1.4,r),g=e.ids.map(e=>{const t=h.get(e);return{id:e,cx:t.x,cy:t.y,r:m,datum:Ce({id:e}),category:""}}),y=[];for(const n of e.ids){const e=h.get(n);for(const o of t.get(n)??[]){if(!p.has(o))continue;const t=h.get(o);y.push({source:n,target:o,x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:g,edges:y}}function Ho(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?`chain of ${t}`:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:`branching → ${o}`}function Uo(e,t){const n=new Set(e),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const t of e)o.set(t,/* @__PURE__ */new Set),r.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function Xo(e,t,n,o,r){const i=/* @__PURE__ */new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}c.sort();const l=Co(c,t),{sinkCount:d,sourceCount:u}=l;let h=0;for(const e of c)h+=t.get(e).size;s.push({...l,ids:c,nodeCount:c.length,edgeCount:h,sinkCount:d,sourceCount:u,directed:1===d,motif:Yo(c,t,n,h,r)})}return s}function Ko(e,t,n){const o=[...e].sort(),r=t.map(e=>[e.source,e.target]).sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0),i=JSON.stringify([n,o,r]);return lp.getOrCompute(i,()=>{const{outAdj:e,inAdj:t,undirected:s}=Uo(o,r.map(([e,t])=>({source:e,target:t})));return{key:i,outAdj:e,inAdj:t,components:Xo(o,e,t,s,n)}})}function Jo(e,t){const{plot:n}=t,o=n.width,r=(()=>{for(let r=Math.min(t.maxCellSize,o);r>=Math.max(1,t.minCellSize);r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e){const e=Math.ceil(n.length/i);s+=t.headerHeight+e*(r+t.cellGap)+t.bandGap}if(s<=n.height)return{cell:r,cols:i}}return null})();if(!r){const t=e.flatMap(([,e])=>e),o=Math.max(1,Math.ceil(Math.sqrt(t.length*n.width/n.height))),r=Math.ceil(t.length/o),i=n.width/o,s=n.height/r;return{bands:[],cells:t.map((e,t)=>({component:e,lod:"glyph",cx:n.x+(t%o+.5)*i,cy:n.y+(Math.floor(t/o)+.5)*s,glyphR:Math.min(i,s)*(e.directed?.36:.28),nodes:[],edges:[]}))}}const{cell:i,cols:s}=r,a=[],c=[];let l=n.y;for(const[r,d]of e){const e=Math.ceil(d.length/s),u=l,h=u+t.headerHeight,p=i>=t.minCellForFull;d.forEach((e,o)=>{const r=o%s,c=Math.floor(o/s),l=n.x+r*(i+t.cellGap),d=h+c*(i+t.cellGap),u={x:l,y:d,width:i,height:i};if(p){const n=Vo(e,t.outAdj,t.inAdj,u,t.nodeRadius);a.push({component:e,lod:"full",cx:l+i/2,cy:d+i/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:l+i/2,cy:d+i/2,glyphR:Math.max(2.5,.36*i),nodes:[],edges:[]})});const f=Zo(d[0],t,{x:n.x,y:u+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});c.push({motif:r,descriptor:Ho(d[0]),count:d.length,directed:d[0].directed,x:n.x,y:u,width:o,height:t.headerHeight+e*(i+t.cellGap),contentWidth:Math.min(d.length,s)*(i+t.cellGap)-t.cellGap,exemplar:f}),l=h+e*(i+t.cellGap)+t.bandGap}return{cells:a,bands:c}}function Zo(e,t,n){return e?Vo(e,t.outAdj,t.inAdj,n,3):null}function Qo(e){return Me(e)??e}function er(e){return"string"==typeof e?e:e.id}function tr(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function nr(e){return String(Math.round(100*e)/100)}function or(e,t){if(e.length<2)return"";let n=`M${nr(e[0][0])},${nr(e[0][1])}`;for(let o=1;o<e.length-1;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(l<=0){n+=`L${nr(i[0])},${nr(i[1])}`;continue}const d=[(i[0]-r[0])/a,(i[1]-r[1])/a],u=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-d[0]*l,i[1]-d[1]*l],p=[i[0]+u[0]*l,i[1]+u[1]*l];n+=`L${nr(h[0])},${nr(h[1])}Q${nr(i[0])},${nr(i[1])} ${nr(p[0])},${nr(p[1])}`}const o=e[e.length-1];return`${n}L${nr(o[0])},${nr(o[1])}`}function rr(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,d=t-s*o*.44,u=[l+a*r*.5,d+i*r*.5],h=[l-a*r*.5,d-i*r*.5];return`M${nr(c[0])},${nr(c[1])}L${nr(u[0])},${nr(u[1])}L${nr(h[0])},${nr(h[1])}Z`}function ir(e,t){return`${t}\0${e}`}function sr(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=er(r.source),i=er(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=Qo(r),l=tr("function"==typeof n.valueAccessor?n.valueAccessor(c):we(c,n.valueAccessor??"value",r.value??1),0);if(l<=0)continue;let d=o.get(e);d||(d=/* @__PURE__ */new Map,o.set(e,d));const u=d.get(i);u?(u.value+=l,u.edgeCount+=1,u.memberEdges.push(c)):d.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=ke(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}function ar(e,t,n){const o=/* @__PURE__ */new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(ir(t.source,t.targetIndex>=t.sourceIndex?"out-right":"out-left"),t),r(ir(t.target,t.sourceIndex<t.targetIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=lr(t,n);let s=null==n.flowScale?Number.POSITIVE_INFINITY:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=dr(e.length,t,n),a=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(s=Math.min(s,a/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??Number.POSITIVE_INFINITY);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=dr(e.length,t,n),s=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(l=Math.min(l,s/o))}if(l<1)for(const t of e)t.width*=l;return o}function cr(e,t,n,o){const r=/* @__PURE__ */new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=dr(s.length,n,o);let d=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=d+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),d+=e.width+l}}return r}function lr(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function dr(e,t,n){if(e<=1)return 0;const o=Math.max(0,n.flowGap??.75),r=lr(t,n),i=Math.min(.1,r);return Math.min(o,Math.max(0,(r-i)/(e-1)))}function ur(e,t,n){const o="function"==typeof t?t(e):we(e,t,n);return null==o||""===o?n:String(o)}function hr(e,t){const n="function"==typeof t?t(e):we(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:String(e)}return String(n)}}function pr(e,t){const n="function"==typeof t?t(e):we(e,t,1);return Number(n)}function fr(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function mr(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),d=n.includeInternalFlows??!0,u=[],h=/* @__PURE__ */new Map,p=/* @__PURE__ */new Map;for(const t of e){const e=ur(t,o,String(u.length));if(h.has(e))continue;const n=ur(t,i,e),s=ur(t,r,e),a={id:e,label:n,group:s,datum:t};u.push(a),h.set(e,a);const c=p.get(s);c?c.push(a):p.set(s,[a])}const f=new Set(u.map(e=>e.id)),m=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(const[e,t]of p){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=fr(`${n.groupIdPrefix??"group:"}${e}`,f),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};m.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};m.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map;let M=0;for(const e of t){const t=hr(e,s),n=hr(e,a),o=pr(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!r||!i||!Number.isFinite(o)||o<=0){M+=1;continue}const l=h.get(t)?.group,d=h.get(n)?.group;if(l&&d&&l===d){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(d){const e=b.get(d);e&&(e.incomingValue+=o)}}let u=w.get(r);u||(u=/* @__PURE__ */new Map,w.set(r,u));const p=u.get(i);p?(p.value+=o,p.edgeCount+=1,p.memberEdges.push(e)):u.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:m,edges:d?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function gr(e,t){const n=t.showEnclosures?e.enclosures.map(e=>({x:e.x,y:e.y,width:e.w,height:e.h})):[];if(t.showColumnHeaders)for(const o of e.colBands){const e=gp((t.columnLabel??String)(o.col),t.headerFontSize)/2;n.push({x:o.x+o.w/2,y:t.headerY,z:0,extent:[e,e,t.headerFontSize,4]})}if(t.showRowLabels)for(const[o,r]of e.rowLabelY){const e=gp((t.rowLabel??String)(o),t.labelFontSize);n.push({x:t.labelX,y:r,z:0,extent:[e,0,t.labelFontSize,t.labelFontSize]})}for(const e of t.callouts){const t=gp("string"==typeof e.label?e.label:"",e.fontSize??11)/2,o=e.labelX-e.markX,r=e.labelY-e.markY;n.push({x:e.markX,y:e.markY,extent:[Math.max(0,t-o),Math.max(0,o+t),Math.max(0,14-r),Math.max(0,r)]})}return n}function yr(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=String(e),n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function xr(e,t,n){return e<t?t:e>n?n:e}function br(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function wr(e,t){const n=/* @__PURE__ */new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=t.columnGap*Math.max(0,o.length-1),i=Math.max(1,t.innerW-r),s=t.proportionExponent,a=o.map(e=>Math.pow(n.get(e).length,s)),c=a.reduce((e,t)=>e+t,0)||1,l=e=>"uniform"===t.cellSizing?i/o.length:a[e]/c*i,d=/* @__PURE__ */new Map,u=[];let h=t.innerX;for(let e=0;e<o.length;e++)u.push({col:o[e],x:h,w:l(e)}),h+=l(e)+t.columnGap;let p=1;const f=/* @__PURE__ */new Map,m=[],g=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),t-o<r.minX&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),n-o<r.minY&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=Mr(a,n,o,r,i,t.packPadding,t.iterations,p++);let l=1/0,u=1/0,h=-1/0,f=-1/0;for(const e of a){const t=c.get(e.id);d.set(e.id,{px:t.px,py:t.py}),g(s,t.px,t.py,e.r),t.px-e.r<l&&(l=t.px-e.r),t.px+e.r>h&&(h=t.px+e.r),t.py-e.r<u&&(u=t.py-e.r),t.py+e.r>f&&(f=t.py+e.r)}return Number.isFinite(l)?{x:l-wp,y:u-wp,w:h-l+2*wp,h:f-u+2*wp}:null};if("banded"===t.rowMode){const r=/* @__PURE__ */new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e),s)),h=l.reduce((e,t)=>e+t,0)||1,p=/* @__PURE__ */new Map;let m=t.innerY+t.innerH;for(let e=0;e<i.length;e++){const n="uniform"===t.cellSizing?c/i.length:l[e]/h*c,o=m-n;p.set(i[e],{y:o,h:n}),m=o-t.rowGap}o.forEach((e,t)=>{const o=ve(n.get(e),e=>e.row);for(const e of i){const n=o.get(e),r=p.get(e);n&&r&&y(n,u[t].x,r.y,u[t].w,r.h,e)}});const g=[],x=/* @__PURE__ */new Map;for(const e of i){const t=p.get(e);x.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-wp,y:n.minY-wp,w:n.maxX-n.minX+2*wp,h:n.maxY-n.minY+2*wp})}return{positions:d,enclosures:g,colBands:u,rowLabelY:x}}const x=/* @__PURE__ */new Map;o.forEach((e,o)=>{const r=ve(n.get(e),e=>e.row),i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e).length,s)),d=l.reduce((e,t)=>e+t,0)||1;let h=t.innerY+t.innerH;i.forEach((e,n)=>{const s="uniform"===t.cellSizing?c/i.length:l[n]/d*c,a=h-s,p=y(r.get(e),u[o].x,a,u[o].w,s,e);if(p){m.push(p);const t=x.get(e)??{sum:0,n:0};t.sum+=p.y+p.h/2,t.n+=1,x.set(e,t)}h=a-t.rowGap})});const b=/* @__PURE__ */new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:d,enclosures:m,colBands:u,rowLabelY:b}}function Mr(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,d=/* @__PURE__ */new Map,u=e.length;if(0===u)return d;if(1===u)return d.set(e[0].id,{px:c,py:l}),d;const h=br(a),p=new Float64Array(u);let f=0;for(let t=0;t<u;t++)p[t]=e[t].r+i,p[t]>f&&(f=p[t]);const m=Math.max(1,Math.round(Math.sqrt(u*o/Math.max(1,r)))),g=new Float64Array(u),y=new Float64Array(u),x=o/m,b=r/Math.ceil(u/m);for(let e=0;e<u;e++){const o=e%m,r=Math.floor(e/m);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*f),v=/* @__PURE__ */new Map,k=Math.max(1,Math.ceil(o/M)+3),I=(e,t)=>(t+1)*k+(e+1);for(let e=0;e<w;e++){v.clear();for(let e=0;e<u;e++){const o=I(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;e<u;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;t<=1;t++)for(let n=-1;n<=1;n++){const i=v.get(I(o+t,r+n));if(i)for(let t=0;t<i.length;t++){const n=i[t];if(n<=e)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=p[e]+p[n],a=o*o+r*r;if(!(a>=s*s))if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*p[e],y[e]+=Math.sin(t)*p[e]}}}}for(let e=0;e<u;e++){const i=p[e],s=t+i,a=t+o-i,d=n+i,u=n+r-i;g[e]=a>s?xr(g[e],s,a):c,y[e]=u>d?xr(y[e],d,u):l}}for(let t=0;t<u;t++)d.set(e[t].id,{px:g[t],py:y[t]});return d}function vr(e){let t=2166136261;for(const n of e)t=Oo(n.row,Oo(n.col,Oo(n.id,t))),t^=Math.round(8*n.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function kr(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e),r=(e,t,n,o)=>/* @__PURE__ */ /* @__PURE__ */(0,yp.jsx)(mp.NetworkPerspectiveBillboard,{x:t,y:n,onGround:!0,children:o},e),i=(e,t,n,o,r)=>/* @__PURE__ */ /* @__PURE__ */(0,yp.jsx)(mp.NetworkPerspectiveBillboard,{x:t,y:n,z:o,children:r},e);/* @__PURE__ */ /* @__PURE__ */
86
- return(0,yp.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[
84
+ /* @__PURE__ */(0,up.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;/* @__PURE__ */ /* @__PURE__ */
85
+ return(0,up.jsx)("g",{className:"net-ensemble-overlays",children:n})}function qo(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=/* @__PURE__ */new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{components:s}=Ko(r,t,o),a=s.map(e=>({ids:[...e.ids],nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Ho(e)})),c=/* @__PURE__ */new Map;for(const e of a){const t=c.get(e.motif);t?t.count+=1:c.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:a,motifs:[...c.values()].sort((e,t)=>t.count-e.count),directedCount:a.filter(e=>e.directed).length,branchingCount:a.filter(e=>!e.directed).length}}function Bo(e){return Oo(e).toString(36)}function Go(e){return"string"==typeof e?e:e?.id}function Yo(e,t,n,o,r){const i=new Set(e);let s=/* @__PURE__ */new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;o<r;o+=1){const o=/* @__PURE__ */new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,Bo(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return Bo(`${e.length}#${o}#${a.join(";")}`)}function Vo(e,t,n,o,r){function i(e){let t=0,r=0;for(const o of n.get(e)??[]){const e=h.get(o);p.has(o)&&e&&(t+=e.x,r+=1)}return r>0?t/r:o.x+d/2}const{layer:s,layerCount:a}=e,c=Array.from({length:a},()=>[]);for(const t of e.ids)c[s.get(t)].push(t);const l=.14*Math.min(o.width,o.height),d=Math.max(1,o.width-2*l),u=Math.max(1,o.height-2*l),h=/* @__PURE__ */new Map,p=new Set(e.ids);for(let e=0;e<a;e+=1){let t=c[e];e>0&&(t=[...t].sort((e,t)=>i(e)-i(t)));const n=t.length,r=o.y+l+(1===a?.5:e/(a-1))*u;t.forEach((e,t)=>{const i=o.x+l+(1===n?.5:t/(n-1))*d;h.set(e,{x:i,y:r})})}const f=c.reduce((e,t)=>Math.max(e,t.length),1),m=xe(Math.min(r,d/(2.4*f),u/(2.4*a)),1.4,r),g=e.ids.map(e=>{const t=h.get(e);return{id:e,cx:t.x,cy:t.y,r:m,datum:Ce({id:e}),category:""}}),y=[];for(const n of e.ids){const e=h.get(n);for(const o of t.get(n)??[]){if(!p.has(o))continue;const t=h.get(o);y.push({source:n,target:o,x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:g,edges:y}}function Ho(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?`chain of ${t}`:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:`branching → ${o}`}function Uo(e,t){const n=new Set(e),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const t of e)o.set(t,/* @__PURE__ */new Set),r.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function Xo(e,t,n,o,r){const i=/* @__PURE__ */new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}c.sort();const l=Co(c,t),{sinkCount:d,sourceCount:u}=l;let h=0;for(const e of c)h+=t.get(e).size;s.push({...l,ids:c,nodeCount:c.length,edgeCount:h,sinkCount:d,sourceCount:u,directed:1===d,motif:Yo(c,t,n,h,r)})}return s}function Ko(e,t,n){const o=[...e].sort(),r=t.map(e=>[e.source,e.target]).sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0),i=JSON.stringify([n,o,r]);return hp.getOrCompute(i,()=>{const{outAdj:e,inAdj:t,undirected:s}=Uo(o,r.map(([e,t])=>({source:e,target:t})));return{key:i,outAdj:e,inAdj:t,components:Xo(o,e,t,s,n)}})}function Jo(e,t){const{plot:n}=t,o=n.width,r=(()=>{for(let r=Math.min(t.maxCellSize,o);r>=Math.max(1,t.minCellSize);r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e){const e=Math.ceil(n.length/i);s+=t.headerHeight+e*(r+t.cellGap)+t.bandGap}if(s<=n.height)return{cell:r,cols:i}}return null})();if(!r){const t=e.flatMap(([,e])=>e),o=Math.max(1,Math.ceil(Math.sqrt(t.length*n.width/n.height))),r=Math.ceil(t.length/o),i=n.width/o,s=n.height/r;return{bands:[],cells:t.map((e,t)=>({component:e,lod:"glyph",cx:n.x+(t%o+.5)*i,cy:n.y+(Math.floor(t/o)+.5)*s,glyphR:Math.min(i,s)*(e.directed?.36:.28),nodes:[],edges:[]}))}}const{cell:i,cols:s}=r,a=[],c=[];let l=n.y;for(const[r,d]of e){const e=Math.ceil(d.length/s),u=l,h=u+t.headerHeight,p=i>=t.minCellForFull;d.forEach((e,o)=>{const r=o%s,c=Math.floor(o/s),l=n.x+r*(i+t.cellGap),d=h+c*(i+t.cellGap),u={x:l,y:d,width:i,height:i};if(p){const n=Vo(e,t.outAdj,t.inAdj,u,t.nodeRadius);a.push({component:e,lod:"full",cx:l+i/2,cy:d+i/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:l+i/2,cy:d+i/2,glyphR:Math.max(2.5,.36*i),nodes:[],edges:[]})});const f=Zo(d[0],t,{x:n.x,y:u+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});c.push({motif:r,descriptor:Ho(d[0]),count:d.length,directed:d[0].directed,x:n.x,y:u,width:o,height:t.headerHeight+e*(i+t.cellGap),contentWidth:Math.min(d.length,s)*(i+t.cellGap)-t.cellGap,exemplar:f}),l=h+e*(i+t.cellGap)+t.bandGap}return{cells:a,bands:c}}function Zo(e,t,n){return e?Vo(e,t.outAdj,t.inAdj,n,3):null}function Qo(e){return Me(e)??e}function er(e){return"string"==typeof e?e:e.id}function tr(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function nr(e){return String(Math.round(100*e)/100)}function or(e,t){if(e.length<2)return"";let n=`M${nr(e[0][0])},${nr(e[0][1])}`;for(let o=1;o<e.length-1;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(l<=0){n+=`L${nr(i[0])},${nr(i[1])}`;continue}const d=[(i[0]-r[0])/a,(i[1]-r[1])/a],u=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-d[0]*l,i[1]-d[1]*l],p=[i[0]+u[0]*l,i[1]+u[1]*l];n+=`L${nr(h[0])},${nr(h[1])}Q${nr(i[0])},${nr(i[1])} ${nr(p[0])},${nr(p[1])}`}const o=e[e.length-1];return`${n}L${nr(o[0])},${nr(o[1])}`}function rr(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,d=t-s*o*.44,u=[l+a*r*.5,d+i*r*.5],h=[l-a*r*.5,d-i*r*.5];return`M${nr(c[0])},${nr(c[1])}L${nr(u[0])},${nr(u[1])}L${nr(h[0])},${nr(h[1])}Z`}function ir(e,t){return`${t}\0${e}`}function sr(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=er(r.source),i=er(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=Qo(r),l=tr("function"==typeof n.valueAccessor?n.valueAccessor(c):we(c,n.valueAccessor??"value",r.value??1),0);if(l<=0)continue;let d=o.get(e);d||(d=/* @__PURE__ */new Map,o.set(e,d));const u=d.get(i);u?(u.value+=l,u.edgeCount+=1,u.memberEdges.push(c)):d.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=Ie(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}function ar(e,t,n){const o=/* @__PURE__ */new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(ir(t.source,t.targetIndex>=t.sourceIndex?"out-right":"out-left"),t),r(ir(t.target,t.sourceIndex<t.targetIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=lr(t,n);let s=null==n.flowScale?Number.POSITIVE_INFINITY:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=dr(e.length,t,n),a=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(s=Math.min(s,a/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??Number.POSITIVE_INFINITY);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=dr(e.length,t,n),s=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(l=Math.min(l,s/o))}if(l<1)for(const t of e)t.width*=l;return o}function cr(e,t,n,o){const r=/* @__PURE__ */new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=dr(s.length,n,o);let d=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=d+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),d+=e.width+l}}return r}function lr(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function dr(e,t,n){if(e<=1)return 0;const o=Math.max(0,n.flowGap??.75),r=lr(t,n),i=Math.min(.1,r);return Math.min(o,Math.max(0,(r-i)/(e-1)))}function ur(e,t,n){const o="function"==typeof t?t(e):we(e,t,n);return null==o||""===o?n:String(o)}function hr(e,t){const n="function"==typeof t?t(e):we(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:String(e)}return String(n)}}function pr(e,t){const n="function"==typeof t?t(e):we(e,t,1);return Number(n)}function fr(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function mr(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),d=n.includeInternalFlows??!0,u=[],h=/* @__PURE__ */new Map,p=/* @__PURE__ */new Map;for(const t of e){const e=ur(t,o,String(u.length));if(h.has(e))continue;const n=ur(t,i,e),s=ur(t,r,e),a={id:e,label:n,group:s,datum:t};u.push(a),h.set(e,a);const c=p.get(s);c?c.push(a):p.set(s,[a])}const f=new Set(u.map(e=>e.id)),m=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(const[e,t]of p){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=fr(`${n.groupIdPrefix??"group:"}${e}`,f),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};m.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};m.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map;let M=0;for(const e of t){const t=hr(e,s),n=hr(e,a),o=pr(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!r||!i||!Number.isFinite(o)||o<=0){M+=1;continue}const l=h.get(t)?.group,d=h.get(n)?.group;if(l&&d&&l===d){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(d){const e=b.get(d);e&&(e.incomingValue+=o)}}let u=w.get(r);u||(u=/* @__PURE__ */new Map,w.set(r,u));const p=u.get(i);p?(p.value+=o,p.edgeCount+=1,p.memberEdges.push(e)):u.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:m,edges:d?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function gr(e,t){const n=t.showEnclosures?e.enclosures.map(e=>({x:e.x,y:e.y,width:e.w,height:e.h})):[];if(t.showColumnHeaders)for(const o of e.colBands){const e=bp((t.columnLabel??String)(o.col),t.headerFontSize)/2;n.push({x:o.x+o.w/2,y:t.headerY,z:0,extent:[e,e,t.headerFontSize,4]})}if(t.showRowLabels)for(const[o,r]of e.rowLabelY){const e=bp((t.rowLabel??String)(o),t.labelFontSize);n.push({x:t.labelX,y:r,z:0,extent:[e,0,t.labelFontSize,t.labelFontSize]})}for(const e of t.callouts){const t=bp("string"==typeof e.label?e.label:"",e.fontSize??11)/2,o=e.labelX-e.markX,r=e.labelY-e.markY;n.push({x:e.markX,y:e.markY,extent:[Math.max(0,t-o),Math.max(0,o+t),Math.max(0,14-r),Math.max(0,r)]})}return n}function yr(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=String(e),n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function xr(e,t,n){return e<t?t:e>n?n:e}function br(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function wr(e,t){const n=/* @__PURE__ */new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=t.columnGap*Math.max(0,o.length-1),i=Math.max(1,t.innerW-r),s=t.proportionExponent,a=o.map(e=>Math.pow(n.get(e).length,s)),c=a.reduce((e,t)=>e+t,0)||1,l=e=>"uniform"===t.cellSizing?i/o.length:a[e]/c*i,d=/* @__PURE__ */new Map,u=[];let h=t.innerX;for(let e=0;e<o.length;e++)u.push({col:o[e],x:h,w:l(e)}),h+=l(e)+t.columnGap;let p=1;const f=/* @__PURE__ */new Map,m=[],g=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),t-o<r.minX&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),n-o<r.minY&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=Mr(a,n,o,r,i,t.packPadding,t.iterations,p++);let l=1/0,u=1/0,h=-1/0,f=-1/0;for(const e of a){const t=c.get(e.id);d.set(e.id,{px:t.px,py:t.py}),g(s,t.px,t.py,e.r),t.px-e.r<l&&(l=t.px-e.r),t.px+e.r>h&&(h=t.px+e.r),t.py-e.r<u&&(u=t.py-e.r),t.py+e.r>f&&(f=t.py+e.r)}return Number.isFinite(l)?{x:l-Ip,y:u-Ip,w:h-l+2*Ip,h:f-u+2*Ip}:null};if("banded"===t.rowMode){const r=/* @__PURE__ */new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e),s)),h=l.reduce((e,t)=>e+t,0)||1,p=/* @__PURE__ */new Map;let m=t.innerY+t.innerH;for(let e=0;e<i.length;e++){const n="uniform"===t.cellSizing?c/i.length:l[e]/h*c,o=m-n;p.set(i[e],{y:o,h:n}),m=o-t.rowGap}o.forEach((e,t)=>{const o=ve(n.get(e),e=>e.row);for(const e of i){const n=o.get(e),r=p.get(e);n&&r&&y(n,u[t].x,r.y,u[t].w,r.h,e)}});const g=[],x=/* @__PURE__ */new Map;for(const e of i){const t=p.get(e);x.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-Ip,y:n.minY-Ip,w:n.maxX-n.minX+2*Ip,h:n.maxY-n.minY+2*Ip})}return{positions:d,enclosures:g,colBands:u,rowLabelY:x}}const x=/* @__PURE__ */new Map;o.forEach((e,o)=>{const r=ve(n.get(e),e=>e.row),i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e).length,s)),d=l.reduce((e,t)=>e+t,0)||1;let h=t.innerY+t.innerH;i.forEach((e,n)=>{const s="uniform"===t.cellSizing?c/i.length:l[n]/d*c,a=h-s,p=y(r.get(e),u[o].x,a,u[o].w,s,e);if(p){m.push(p);const t=x.get(e)??{sum:0,n:0};t.sum+=p.y+p.h/2,t.n+=1,x.set(e,t)}h=a-t.rowGap})});const b=/* @__PURE__ */new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:d,enclosures:m,colBands:u,rowLabelY:b}}function Mr(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,d=/* @__PURE__ */new Map,u=e.length;if(0===u)return d;if(1===u)return d.set(e[0].id,{px:c,py:l}),d;const h=br(a),p=new Float64Array(u);let f=0;for(let t=0;t<u;t++)p[t]=e[t].r+i,p[t]>f&&(f=p[t]);const m=Math.max(1,Math.round(Math.sqrt(u*o/Math.max(1,r)))),g=new Float64Array(u),y=new Float64Array(u),x=o/m,b=r/Math.ceil(u/m);for(let e=0;e<u;e++){const o=e%m,r=Math.floor(e/m);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*f),v=/* @__PURE__ */new Map,I=Math.max(1,Math.ceil(o/M)+3),k=(e,t)=>(t+1)*I+(e+1);for(let e=0;e<w;e++){v.clear();for(let e=0;e<u;e++){const o=k(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;e<u;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;t<=1;t++)for(let n=-1;n<=1;n++){const i=v.get(k(o+t,r+n));if(i)for(let t=0;t<i.length;t++){const n=i[t];if(n<=e)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=p[e]+p[n],a=o*o+r*r;if(!(a>=s*s))if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*p[e],y[e]+=Math.sin(t)*p[e]}}}}for(let e=0;e<u;e++){const i=p[e],s=t+i,a=t+o-i,d=n+i,u=n+r-i;g[e]=a>s?xr(g[e],s,a):c,y[e]=u>d?xr(y[e],d,u):l}}for(let t=0;t<u;t++)d.set(e[t].id,{px:g[t],py:y[t]});return d}function vr(e){let t=2166136261;for(const n of e)t=Oo(n.row,Oo(n.col,Oo(n.id,t))),t^=Math.round(8*n.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Ir(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e),r=(e,t,n,o)=>/* @__PURE__ */ /* @__PURE__ */(0,wp.jsx)(xp.NetworkPerspectiveBillboard,{x:t,y:n,onGround:!0,children:o},e),i=(e,t,n,o,r)=>/* @__PURE__ */ /* @__PURE__ */(0,wp.jsx)(xp.NetworkPerspectiveBillboard,{x:t,y:n,z:o,children:r},e);/* @__PURE__ */ /* @__PURE__ */
86
+ return(0,wp.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[
87
87
  /* @__PURE__ */
88
- /* @__PURE__ */(0,yp.jsx)(mp.NetworkPerspectiveGround,{children:t.showEnclosures&&e.enclosures.map((e,n)=>Po({keyId:`enc-${n}`,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity}))}),t.iconMarks.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,yp.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>r(`ic-${n}`,e.x,e.y,
88
+ /* @__PURE__ */(0,wp.jsx)(xp.NetworkPerspectiveGround,{children:t.showEnclosures&&e.enclosures.map((e,n)=>Po({keyId:`enc-${n}`,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity}))}),t.iconMarks.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,wp.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>r(`ic-${n}`,e.x,e.y,
89
89
  /* @__PURE__ */
90
- /* @__PURE__ */(0,yp.jsx)("path",{d:at(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity})))}),t.markerDots.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,yp.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>r(`mk-${n}`,e.x,e.y,/* @__PURE__ */ /* @__PURE__ */(0,yp.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor})))}),t.showColumnHeaders&&e.colBands.map((e,o)=>i(`col-${o}`,e.x+e.w/2,t.headerY,0,Fo({keyId:`col-${o}`,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor}))),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>i(`row-${e}`,t.labelX,n,0,Fo({keyId:`row-${e}`,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor}))),t.callouts.map(e=>i(String(e.keyId),e.markX,e.markY,"top",Do(e)))]})}function Ir(e,t,n){const o=e.map((e,o)=>Fo({keyId:`marimekko-label-${o}`,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return Mp.createElement(Mp.Fragment,null,...o)}function Sr(e,t,n){const o=/* @__PURE__ */new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function $r(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}function Nr(e,t){const n=Math.min(1,Math.max(0,t/e.height));return e.bottomRadius*(1-n)+e.topRadius*n}function Er(e,t){return $r(Nr(e,t),e.bottomRadius,t)}function Ar(e,t){if(t<=0)return 0;if(t>=Er(e,e.height))return e.height;let n=0,o=e.height;for(let r=0;r<60;r++){const r=n+(o-n)/2;Er(e,r)<t?n=r:o=r}return n+(o-n)/2}function Cr(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Or(e,t){if(!(t>0)||!Number.isFinite(e)||t>e)return[];if(e<2*t)return[{x:0,y:0}];const n=[];let o=e-t;for(;n.length<Op;){let e=Math.min(Op,Math.floor(Math.PI*o/t));e<1&&(e=1);const r=o*Math.cos(0),i=o*Math.sin(0),s=o*Math.cos(2*Math.PI/e),a=o*Math.sin(2*Math.PI/e);Math.hypot(r-s,i-a)<2*t&&e>1&&e--;for(let t=0;t<e&&n.length<Op;t++)n.push({x:o*Math.cos(2*t*Math.PI/e),y:o*Math.sin(2*t*Math.PI/e)});const c=o-2*t;if(!(c>=t)){o>2*t&&n.length<Op&&n.push({x:0,y:0});break}o=c}return n}function Tr(e,t,n){const o=[];let r=Math.min(n,Op),i=0;for(;r>0&&i<60;){const n=t*(1+2*i);if(n+t>e.height)break;const s=Or(Nr(e,n),t),a=s.length-r,c=a>0?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Cr(97*i+t,.15),z:l+Cr(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function Pr(e,t,n){let o=n,r=0;for(;o>0&&r<60;){const n=t+.875*(1+2*r);if(n+.875>e.height)break;const i=Nr(e,n);if(2*i<Ap)break;o-=Math.max(1,Math.floor(2*i/Ap)),r++}return r}function Rr(e,t,n,o){if(o<=0)return[];const r=Pr(e,t,o=Math.min(o,Op)),i=r*Ap,s=Math.max(t,n-i)+.875,a=[];let c=0;for(let t=0;t<r&&c<o;t++){const n=s+Ap*t,r=Nr(e,n),i=Math.max(1,Math.floor(2*r/Ap)),l=(2*r-i*Ap)/(i+1),d=-r+l,u=e.height-n-.875-.1;for(let e=0;e<i&&c<o;e++){const n=d+(l+Ap)*e;a.push({cx:n+.875,cy:u+.875,rotation:Cr(53*t+e,10)}),c++}}return a}function jr(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Fr(e,t){const n=jr(e,t);return n>0?n:t}function Lr(e){if(!e)return null;const t=e[Rp];return t&&t.length>0?t:null}function zr(e,t){if(t instanceof Date){const n=t.getTime();return Number.isFinite(n)?e.find(e=>e.label instanceof Date&&e.label.getTime()===n)?.value??null:null}if("number"==typeof t&&Number.isFinite(t)){const n=e.find(e=>"number"==typeof e.label&&e.label===t);return n?n.value:e.find(e=>e.label instanceof Date&&e.label.getTime()===t)?.value??null}return"string"==typeof t?e.find(e=>"string"==typeof e.label&&e.label===t)?.value??null:null}function Dr(e,t){if(!e)return null;const n=Lr(e);if(!n)return e(t);const o=zr(n,t);return null==o?null:e(o)}function _r(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?Dr(n,e.x):t.xAccessor&&null!=e[t.xAccessor]?Dr(n,e[t.xAccessor]):null:null}function Wr(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?Dr(n,e.y):t.yAccessor&&null!=e[t.yAccessor]?Dr(n,e[t.yAccessor]):null:null}function qr(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=e.xAccessor||"x",s=e.yAccessor||"y",a=n[i],c=n[s];if(null==a||null==c)return null;const l=Dr(o,a),d=Dr(r,c);return null==l||null==d?null:{x:l,y:d}}function Gr(e){return null==e?null:String(e)}function Br(e){return Gr(e.provenance?.stableId??e.stableId)}function Yr(e){return Gr(e.stableId??e.id??e.provenance?.stableId)}function Vr(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Hr(e,t,n){const o=Br(e);if(!o)return null;const r=n.pointNodes?.find(e=>Gr(e.pointId)===o);if(r)return Vr(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>Yr(e)===o);if(!i)return null;const s=_r(i,n),a=Wr(i,n);return null==s||null==a?null:Vr(t,n,{x:s,y:a})}function Ur(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return Vr(t,n,{x:r.x,y:r.y})}const o=qr(n);return o?Vr(t,n,o):null}if("semantic"===o){const o=Hr(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=_r(e,n),i=Wr(e,n)),null!=r&&null!=i)return Vr(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Xr(e){return"string"==typeof e?.type?e.type:""}function Kr(e){return!!e&&"object"==typeof e&&jp.has(Xr(e))}function Jr(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function Zr(e){return"primary"===e?.emphasis||!0===e?.defensive}function Qr(e,t,n={}){if("number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations))return Math.max(0,Math.floor(n.maxAnnotations));if(!(e>0&&t>0))return 1/0;const o=n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:Fp;return Math.max(1,Math.round(e*t/o))}function ei(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*xe(o,0,1)),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function ti(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??Lp),i=Qr(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Kr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||a.length<=i)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Zr(e.annotation)),l=a.filter(e=>!Zr(e.annotation)).sort((e,t)=>ei(t.annotation)-ei(e.annotation)||e.index-t.index),d=Math.max(0,i-c.length),u=Math.max(0,r-c.length),h=Math.min(l.length,Math.max(d,u)),p=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,h).map(e=>e.index)]),f=[],m=[];for(const{annotation:e,index:t,note:n}of s)!n||p.has(t)?f.push(e):m.push(e);return{visible:f,deferred:m,budget:i}}function ni(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:Gp,dy:Bp}}function oi(e){const t=e?.familiarity;if(!t)return Hp;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?Hp:n.reduce((e,t)=>e+t,0)/n.length}function ri(e){if(!e)return 1;const t=oi(e);return t<=2?1.5:t>=4?.6:1}function ii(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(Up,t.source)?Up[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?`${Math.round(100*Math.max(0,Math.min(1,t.confidence)))}%`:null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function si(e,t){let n=!1;const o=e.map(e=>li(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}function ai(e){if(!li(e))return e;const t="string"==typeof e.mobileText?e.mobileText:void 0,n="string"==typeof e.shortText?e.shortText:void 0,o=t??n;return!o||"string"!=typeof e.label&&null!=e.label?e:{...e,label:o}}function ci(e){if("text"!==e.type||"string"!=typeof e.color)return e;const t="number"==typeof e.dx?e.dx:0,n="number"==typeof e.dy?e.dy:0;return Math.hypot(t,n)<Yp?e:{...e,_redundantConnector:!0}}function li(e){return Kr(e)}function di(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...Jr("string"==typeof e.title?e.title:void 0,o,7),...Jr("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}function ui(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:n>=0?i+4:i-r.width-4,y:o<0?s-r.height:s,width:r.width,height:r.height}:{x:n>=0?i:i-r.width,y:o<0?s-r.height-4:s+4,width:r.width,height:r.height}}function hi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function pi(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function fi(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y),s=Math.max(0,e.x+e.width-(t-o)),a=Math.max(0,e.y+e.height-(n-o));return(r+s)*e.height+(i+a)*e.width}function mi(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function gi(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}function yi(e,t,n,o,r,i,s,a){const c=hi(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*fi(c,r,i,a);for(const e of n)l+=12*pi(c,e);for(const e of o)l+=4*pi(c,e);return l}function xi(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ur(e,t,n):{x:e.x,y:e.y}}function bi(e){const{annotations:t,context:n,defaultOffset:o=zp,notePadding:r=Dp,markPadding:i=_p,edgePadding:s=Wp,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=qp,density:d,progressiveDisclosure:u=!1,redundantCues:h=!1,responsive:p,mobile:f,cohesion:m,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof f?f:{},w=b.breakpoint??Vp,M=!!f&&y<=w,v=M&&!1!==b.preferShortText?t.map(ai):t,k=M&&!d?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:d,I=u||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!p?b.responsive??{minWidth:w}:p,$=M&&!m?b.cohesion:m;if(0===v.length||y<=0||x<=0)return v.slice();const N=[],E=gi(n,i);let A=!1;const C=v.map((e,t)=>{if(!li(e))return e;const i=xi(e,t,n);if(!i)return e;const d=di(!0===e.defensive?ii(e):e);if(a&&("number"==typeof(u=e).dx||"number"==typeof u.dy)){const t=ni(e),n="number"==typeof e.dx?e.dx:t.dx,o="number"==typeof e.dy?e.dy:t.dy;return N.push(hi(ui(i.x,i.y,n,o,d),r)),e}var u;let h=null,p=1/0;for(const e of mi(o)){const t=yi(ui(i.x,i.y,e.dx,e.dy,d),e,N,E,y,x,r,s);t<p&&(h=e,p=t)}if(!h)return e;const f=hi(ui(i.x,i.y,h.dx,h.dy,d),r);N.push(f);const m=Math.hypot(h.dx,h.dy),g=c&&m>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return A=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),O=A?C:v.slice();let T=O;if(h){let e=!1;const t=O.map(t=>{const n=ci(t);return n!==t&&(e=!0),n});T=e?t:O}{let e=!1;const t=T.map(t=>{if(!0!==t?.defensive)return t;const n=ii(t);return n!==t&&(e=!0),n});T=e?t:T}const P=/* @__PURE__ */new Set;if(k){const e="object"==typeof k?k:{},t=ri(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Qr(y,x,e))*t))},{deferred:o}=ti({annotations:T,width:y,height:x,...n});for(const e of o)P.add(e)}if(S){const e="object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:Vp;if(y<=e)for(const e of T)li(e)&&"secondary"===e.emphasis&&P.add(e)}if(P.size>0)for(const e of T)!0===e?.defensive&&P.delete(e);let R;return R=0===P.size?T:I?T.map(e=>P.has(e)?{...e,_annotationDeferred:!0}:e):T.filter(e=>!P.has(e)),$?si(R,$):R}function wi(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function Mi(e){const t=wi(e.tight,Jp.tight),n=Math.max(t,wi(e.watch,Jp.watch));return{tight:t,watch:n,comfortable:Math.max(n,wi(e.comfortable,Jp.comfortable))}}function vi(e={}){const{tight:t,watch:n,comfortable:o}=Mi(e);return[{id:"tight",name:"Tight",label:`Tight (< ${t}%)`,max:t,color:Zp.tight},{id:"watch",name:"Watch",label:`Watch (${t}% to < ${n}%)`,min:t,max:n,color:Zp.watch},{id:"moderate",name:"Moderate",label:`Moderate (${n}% to < ${o}%)`,min:n,max:o,color:Zp.moderate},{id:"comfortable",name:"Comfortable",label:`Comfortable (≥ ${o}%)`,min:o,color:Zp.comfortable}].filter(e=>null==e.min||null==e.max||e.max>e.min)}function ki(e,t={}){return Number.isFinite(e)?vi(t).find(t=>(null==t.min||e>=t.min)&&(null==t.max||e<t.max))??null:null}function Ii(e,t={}){const n=t.fuels??Xp,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=wi(t.fuels?.[e]);!o&&n<=0||r.push({t:t.t,fuel:e,fuelLabel:Kp[e],mw:n,ba:t.ba})}return r}function Si(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=wi(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function $i(e){const t=wi(e.demand);if(t<=0)return 0;const n=wi(e.capacityOrNetGen),o=wi(e.interchange);return(n+(o<0?-o:0)-t)/t*100}function Ni(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=wi(e.demandMw),n=wi(e.netGenMw),o=$i({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw}),r=Math.max(0,wi(e.fuels?.wind))+Math.max(0,wi(e.fuels?.solar));return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t-r,demandMw:t,netGenMw:n}})}function Ei(e={},t={}){const n=t.field,o=n?{field:n}:{},r=t.tightHatch??{type:"hatch",background:Zp.tight,stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9},i={comfortable:{fill:t.comfortableFill??Zp.comfortable,fillOpacity:.85},moderate:{fill:t.moderateFill??Zp.moderate,fillOpacity:.85},watch:{fill:t.watchFill??Zp.watch,fillOpacity:.9},tight:{fill:r,stroke:t.tightFill??Zp.tight,strokeWidth:1,fillOpacity:1}};return vi(e).reverse().map(e=>({id:`reserve-${e.id}`,label:e.label,when:{...o,...null!=e.min?{gte:e.min}:{},...null!=e.max?{lt:e.max}:{}},style:i[e.id]}))}function Ai(e={},t={}){const{tight:n,comfortable:o}=Mi(e),[r,i]=t.extent??[],s=Math.min(n,wi(r,-50)),a=Math.max(o,wi(i,Math.max(o+30,40))),c={tight:.12,watch:.1,moderate:.08,comfortable:.06};return vi(e).map(e=>({type:"band",y0:e.min??s,y1:e.max??a,label:e.name,color:e.color,fillOpacity:c[e.id],emphasis:"secondary"}))}function Ci(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>e.t<=t);o=e.length?e[e.length-1]:n[0]}const r=wi(o.demandMw),i=wi(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=$i({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,d=0,u=0;for(const e of Xp){const t=wi(o.fuels?.[e]);t<=0||(u+=t,c[e]=t,t>d&&(d=t,l=e))}if(u>0)for(const e of Object.keys(c))c[e]=c[e]/u;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:u>0?d/u:0,topFuelMw:d,fuelShares:c}}function Oi(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const i=(e.start+e.end)/2,s=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:i,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",..."number"==typeof t.confidence&&Number.isFinite(t.confidence)?{confidence:Math.min(1,Math.max(0,t.confidence))}:{},createdAt:s,stableId:e.id,dataVersion:String(e.start)},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Ti(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Pi(e,t=0){return Number.isFinite(e)?`${e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})} MW`:"—"}function Ri(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function ji(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function Fi(e,t={}){const n=ji(t.start,"start"),o=ji(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new tf;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function Li(e,t){const n=ji(t.start,"start"),o=ji(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(!Number.isFinite(r)||!Number.isFinite(i)||r>i||!Number.isFinite(s)||s<=0)return[];const c=(i-r)/s;if(c>=Number.MAX_SAFE_INTEGER||r<i&&(r+s<=r||i-s>=i))return[];const l=Math.min(.25,4*Number.EPSILON*Math.max(1,c)),d=Math.floor(c+l),u=c>Math.log2(e.length+1),h=[],p=[];if(u){for(const t of e){const e=n(t),r=o(t);e<=r&&(h.push(e),p.push(r))}h.sort((e,t)=>e-t),p.sort((e,t)=>e-t)}let f=0,m=0;const g=[];for(let t=0;t<=d;t++){const y=t>0&&t===d&&Math.abs(t-c)<=l?i:r+t*s;let x=0;if(u){for(;f<h.length&&h[f]<=y;)f++;for(;m<p.length&&(a?p[m]<=y:p[m]<y);)m++;x=f-m}else for(const t of e){const e=n(t),r=o(t);e<=y&&(a?y<r:y<=r)&&x++}g.push({value:y,count:x})}return g}function zi(e,t,n){const o="x"===t?"width":"height",r=new Float64Array(e.length),i=new Float64Array(e.length),s=Array.from({length:e.length},(e,t)=>t);let a=0;const c=()=>{for(let s=0;s<e.length;s++){const a=(e[s][o]+Math.max(0,n))/2;r[s]=e[s][t]-a,i[s]=e[s][t]+a}s.sort((e,t)=>r[e]-r[t]||e-t),a=0;for(let e=0;e<s.length;e++){let t=e+1,n=s.length;for(;t<n;){const o=t+n>>>1;r[s[o]]<=i[s[e]]?t=o+1:n=o}a+=t-e-1}};return c(),{lower:r,upper:i,order:s,update:c,get pairs(){return a}}}function Di(e,t,n,o,r=!1){const i="x"===t?"y":"x",s="x"===t?"width":"height",a="x"===t?"height":"width",c=zi(e,t,n),l=zi(e,i,n),d=new Float64Array(e.length);return()=>{d.fill(0),c.update(),r||l.update();const{order:u,lower:h,upper:p}=c.pairs<l.pairs?c:l;for(let r=0;r<u.length;r++){const c=u[r],l=e[c];for(let f=r+1;f<u.length&&h[u[f]]<=p[c];f++){const r=u[f],h=e[r];if(Math.abs(l[i]-h[i])>(l[a]+h[a])/2+n)continue;const p=h[t]-l[t]||(l.id<h.id?-.5:.5),m=(l[s]+h[s])/2+n-Math.abs(p);if(m<=0)continue;const g=m*o*Math.sign(p);d[c]-=g,d[r]+=g}}return d}}function _i(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(Math.abs(t.y-e.y)<i){const n=e.x<=t.x?1:-1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(Math.abs(t.x-e.x)<i){const n=e.y<=t.y?1:-1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function Wi(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function qi(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function Gi(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function Bi(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function Yi(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function Vi(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function Hi(e,t){const n=Di(e,t?.axis??"x",t?.padding??0,t?.strength??.5)(),o=/* @__PURE__ */new Map;return e.forEach((e,t)=>o.set(e.id,(o.get(e.id)??0)+n[t])),o}function Ui(e,t,n=!1){if("function"==typeof e)return n?t=>e(Me(t)??t):e;const o=e??t;return e=>we(e,o,void 0)}function Xi(e,t,n,o){return Ki(e,t,n,o,!1)}function Ki(e,t,n,o,r){const i=o.fixedAxis??"y",s=Ui(o.fixedAccessor,"fixed",r),a=e=>String(Ui(o.sourceAccessor,"source",r)(e)),c=e=>String(Ui(o.targetAccessor,"target",r)(e)),l=o.size??(()=>of),d=o.iterations??180,u=o.attraction??.012,h=o.anchorStrength??.003,p=o.collisionStrength??.12,f=o.collisionPadding??15,m=o.edgePadding??42,g=o.fixedPadding??16,y=o.damping??.72,x=o.spread??1,[b,w]=o.fixedDomain;if(![b,w,n.x,n.y,n.width,n.height].every(Number.isFinite)||n.width<=0||n.height<=0)return{positioned:[],byId:/* @__PURE__ */new Map};const M=w-b||1,v=("y"===i?n.y:n.x)+g,k=("y"===i?n.y+n.height:n.x+n.width)-g,I=("y"===i?n.x:n.y)+m,S=("y"===i?n.x+n.width:n.y+n.height)-m,$=Math.max(1,S-I),N=e.flatMap(e=>{const t=s(e);if("number"!=typeof t&&("string"!=typeof t||!t.trim()))return[];const n=Number(t),i=v+(n-b)/M*(k-v);if(!Number.isFinite(n)||!Number.isFinite(i))return[];const a=Me(e)??e,c=(d=e,String(Ui(o.idAccessor,"id",r)(d)));var d;const{width:u,height:h}=l(a);if(![u,h].every(e=>Number.isFinite(e)&&e>0))return[];const p=I+To(c)*$;return[{data:a,id:c,width:u,height:h,fixedValue:n,fixed:i,free:p,anchor:p}]}),E=e=>"y"===i?e.width:e.height,A=new Map(N.map((e,t)=>[e.id,t])),C=[];for(const e of t){const t=A.get(a(e)),n=A.get(c(e));void 0!==t&&void 0!==n&&C.push([t,n])}const O=N.map(e=>({id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height})),T="y"===i?"x":"y",P=Di(O,T,f,p,!0),R=new Float64Array(N.length);for(let e=0;e<d;e++){R.fill(0);for(const[e,t]of C){const n=(N[t].free-N[e].free)*u;R[e]+=n,R[t]-=n}for(let e=0;e<N.length;e++){const t=N[e];R[e]+=(t.anchor-t.free)*h,O[e][T]=t.free}const e=P();for(let t=0;t<N.length;t++){const n=N[t];n.free+=(R[t]+e[t])*y;const o=E(n)/2;n.free=Math.max(I+o,Math.min(S-o,n.free))}}if(1!==x){const e=(I+S)/2;for(const t of N){const n=E(t)/2;t.free=Math.max(I+n,Math.min(S-n,e+(t.free-e)*x))}}const j=N.map(e=>({data:e.data,id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:j,byId:new Map(j.map(e=>[e.id,e]))}}function Ji(e){let t=0;for(const n of e)t+=cf[n]??(n>="0"&&n<="9"?lf:(n.codePointAt(0)??0)>=11904?uf:df);return t}function Zi(e,t){return Math.max(8,Ji(e)*t*hf+pf)}function Qi(e,t,n){if(!n)return{w:e,h:t};const o=Math.abs(n)*Math.PI/180,r=Math.cos(o),i=Math.sin(o);return{w:e*r+t*i,h:e*i+t*r}}function es(e,t){let n=t>>>0;for(const t of e){n=Oo(t.col,n);for(const e of t.rows)n=Oo(`${e.text}␟${e.weight}␟${e.segment}`,n)}return(n>>>0).toString(36)}function ts(e){const{plans:t,colW:n,bodyH:o,yTop:r,yBot:i,segToY:s,collisionPadding:a}=e,c=n*o;let l=1/0,d=1/0;for(const o of t){let t=0;for(const e of o.rows){const o=Ji(e.text)*hf;t+=o*sf*e.baseFont*e.baseFont;const r=Qi(o,sf,e.rotation);d=Math.min(d,(n-8-pf)/(r.w*e.baseFont))}t>0&&(l=Math.min(l,Math.sqrt(e.packingDensity*c/t)))}const u=e=>{const o=[],c=[];return t.forEach((t,l)=>{if(n<=0)return;const d=t.colLeft+4,u=t.colLeft+n-4,h=t.rows.map((t,o)=>{const r=e*t.baseFont,i=Math.max(af,r),a=Qi(Zi(t.text,i),i*sf+2,t.rotation);return{rowIndex:o,id:t.id,font:i,floored:t.floored||r<af,rotation:t.rotation,w:a.w,h:a.h,anchorY:s(t.segment),seed:(To(t.id)-.5)*Math.min(.5*n,80)}}).sort((e,t)=>t.font-e.font||(e.id<t.id?-1:1)),p=new ff(mf);for(const e of h){const n=e.w/2,s=e.h/2,h=xe(t.center+e.seed,d+n,u-n),f=e.anchorY;let m=null;for(let t=0;t<gf;t++){const o=3.2*Math.sqrt(t),c=2.399963229728653*t,l={x:xe(h+o*Math.cos(c),d+n,u-n),y:xe(f+o*Math.sin(c),r+s,i-s),w:e.w,h:e.h};if(!p.collides(l,a)){m=l;break}}m?(p.insert(m),o.push({planIndex:l,rowIndex:e.rowIndex,id:e.id,x:m.x,y:m.y,fontSize:e.font,rotation:e.rotation,w:e.w,h:e.h,floored:e.floored})):c.push({planIndex:l,rowIndex:e.rowIndex})}}),{placements:o,unplaced:c}};let h=e.scaleToFit?Math.min(1,l,d):Math.min(1,d),p=u(h);if(e.scaleToFit)for(let e=0;e<6&&p.unplaced.length>0&&h>.1;e++)h*=.88,p=u(h);return p}function ns(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=r<o?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?xe((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?xe(n,0,1):t},d=l(e.oldestOpacity,.25),u=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return u;const r=xe(n/c,0,1);return d+(u-d)*r}}}function os(e){const t=e.config,{plot:n}=e.dimensions,o={nodes:[],unplaced:[],sizeFloored:[]};if(n.width<=0||n.height<=0||0===e.data.length)return o;const r=be(t.textAccessor),i=e=>{const n=Number(be(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},s=be(t.columnAccessor),a=e=>Number(be(t.segmentAccessor)(e)),c=t.minFontSize??11,l=t.maxFontSize??42,d=t.columnGutter??18,u=t.collisionPadding??2,h=!1!==t.showColumnLabels,p=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,m=t.segmentTickFormat??(e=>String(Math.round(e))),g=t.rotate??0,y=!0===t.repeatWords,x=!1!==t.scaleToFit,b=t.packingDensity??.6,w="string"==typeof t.textAccessor?t.textAccessor:"word",M="string"==typeof t.weightAccessor?t.weightAccessor:"weight",v="string"==typeof t.columnAccessor?t.columnAccessor:"column",k="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",I=[],S=/* @__PURE__ */new Map;let $=1/0,N=-1/0;for(let t=0;t<e.data.length;t++){const n=e.data[t],o=String(s(n)),c=String(r(n)),l=i(n),d=a(n);c&&Number.isFinite(d)&&(S.has(o)||(I.push(o),S.set(o,[])),S.get(o).push({col:o,text:c,weight:l,segment:d,datum:n,dataIndex:t}),d<$&&($=d),d>N&&(N=d))}if(0===I.length)return o;if(!y)for(const[e,t]of S){const n=/* @__PURE__ */new Map;for(const e of t){const t=n.get(e.text);(!t||e.weight>t.weight)&&n.set(e.text,e)}S.set(e,[...n.values()])}let E=1/0,A=-1/0;for(const e of S.values())for(const t of e)t.weight<E&&(E=t.weight),t.weight>A&&(A=t.weight);if(!Number.isFinite(E))return o;const C=t.columnOrder?[...t.columnOrder.filter(e=>S.has(e)),...I.filter(e=>!t.columnOrder.includes(e))]:I,O=new Map(C.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[T,P]=t.segmentDomain??[$,N],R=P-T||1,j=A-E||1,F=h?22:0,L=p?52:0,z=n.x+L,D=n.y+F,_=Math.max(0,n.width-L),W=Math.max(0,n.height-F),q=C.length,G=Math.max(0,_-d*Math.max(0,q-1)),B=q>0?G/q:0,Y=D+14,V=D+W-14,H=e=>Y+(e-T)/R*(V-Y),U=C.map((e,n)=>{const o=O.get(e),r=(S.get(e)??[]).map((r,i)=>{const s={word:r.text,column:r.col,weight:r.weight,segment:r.segment,datum:r.datum,dataIndex:r.dataIndex,columnIndex:n,resolvedColumnColor:o},a=t.wordOpacity?Number(t.wordOpacity(s)):1,d=t.wordColor?.(s),u=`${e}::${r.text}::${i}`,h=(p=r.weight,A>0?l*Math.sqrt(p/A):0);var p;return{id:u,text:r.text,weight:r.weight,segment:r.segment,baseFont:Math.max(c,h),floored:h<c,rotation:g>0?2*(To(u+"r")-.5)*g:0,opacity:Number.isFinite(a)?xe(a,0,1):0,color:d||o,info:s}});return 0===r.length?null:{col:e,colLeft:z+n*(B+d),center:z+n*(B+d)+B/2,rows:r}}).filter(e=>null!==e),X=$e([n.x,n.y,n.width,n.height,F,L,d,u,c,l,g,x,b,T,P,U.length,es(U,2166136261),es(U,16777619)]),K=xf.getOrCompute(X,()=>ts({plans:U,colW:B,bodyH:W,yTop:Y,yBot:V,segToY:H,collisionPadding:u,packingDensity:b,scaleToFit:x})),J=(e,t)=>U[e].rows[t],Z=K.unplaced.map(({planIndex:e,rowIndex:t})=>J(e,t).info),Q=K.placements.map(e=>{const t=J(e.planIndex,e.rowIndex),n=U[e.planIndex].col,o=Math.sqrt((t.weight-E)/j);return{id:e.id,text:t.text,x:e.x,y:e.y,w:e.w,h:e.h,fontSize:e.fontSize,rotation:e.rotation,floored:e.floored,color:t.color,opacity:t.opacity,info:t.info,datum:ke(e=>{for(const n of Object.keys(t.info.datum))e(n,t.info.datum[n]);e("word",t.text),e("weight",t.weight),e("column",n),e("segment",t.segment),"word"!==w&&e(w,t.text),"weight"!==M&&e(M,t.weight),"column"!==v&&e(v,n),"segment"!==k&&e(k,t.segment),e("__strength",.5+.5*o)})}}),ee=Q.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{const t=e.rotation?e.w:Zi(e.text,e.fontSize),n=e.rotation?e.h:e.fontSize*sf;return{type:"rect",x:e.x-t/2,y:e.y-n/2,w:t,h:n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:String(e.datum.column),_transitionKey:e.id}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,yf.jsxs)("g",{className:"semiotic-word-trails","data-unplaced-count":Z.length||void 0,children:[p&&rs({x:n.x+L-10,yTop:Y,yBot:V,segLo:T,segHi:P,segToY:H,tickCount:f,tickFormat:m,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),h&&C.map((e,t)=>{if(B<=0)return null;const o=z+t*(B+d);/* @__PURE__ */ /* @__PURE__ */
91
- return(0,yf.jsx)("text",{x:o+B/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:O.get(e),style:{pointerEvents:"none"},children:e},`wt-col-${t}`)}),ee.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,yf.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},`wt-${e.id}`))]}),restyle:()=>{},unplaced:Z,sizeFloored:Q.filter(e=>e.floored).map(e=>e.info)}}function rs(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;o<e.tickCount;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));/* @__PURE__ */ /* @__PURE__ */
92
- return(0,yf.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[
90
+ /* @__PURE__ */(0,wp.jsx)("path",{d:at(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity})))}),t.markerDots.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,wp.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>r(`mk-${n}`,e.x,e.y,/* @__PURE__ */ /* @__PURE__ */(0,wp.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor})))}),t.showColumnHeaders&&e.colBands.map((e,o)=>i(`col-${o}`,e.x+e.w/2,t.headerY,0,Fo({keyId:`col-${o}`,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor}))),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>i(`row-${e}`,t.labelX,n,0,Fo({keyId:`row-${e}`,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor}))),t.callouts.map(e=>i(String(e.keyId),e.markX,e.markY,"top",Do(e)))]})}function kr(e,t,n){const o=e.map((e,o)=>Fo({keyId:`marimekko-label-${o}`,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return kp.createElement(kp.Fragment,null,...o)}function Sr(e,t,n){const o=/* @__PURE__ */new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function $r(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}function Nr(e,t){const n=Math.min(1,Math.max(0,t/e.height));return e.bottomRadius*(1-n)+e.topRadius*n}function Er(e,t){return $r(Nr(e,t),e.bottomRadius,t)}function Ar(e,t){if(t<=0)return 0;if(t>=Er(e,e.height))return e.height;let n=0,o=e.height;for(let r=0;r<60;r++){const r=n+(o-n)/2;Er(e,r)<t?n=r:o=r}return n+(o-n)/2}function Cr(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Or(e,t){if(!(t>0)||!Number.isFinite(e)||t>e)return[];if(e<2*t)return[{x:0,y:0}];const n=[];let o=e-t;for(;n.length<Rp;){let e=Math.min(Rp,Math.floor(Math.PI*o/t));e<1&&(e=1);const r=o*Math.cos(0),i=o*Math.sin(0),s=o*Math.cos(2*Math.PI/e),a=o*Math.sin(2*Math.PI/e);Math.hypot(r-s,i-a)<2*t&&e>1&&e--;for(let t=0;t<e&&n.length<Rp;t++)n.push({x:o*Math.cos(2*t*Math.PI/e),y:o*Math.sin(2*t*Math.PI/e)});const c=o-2*t;if(!(c>=t)){o>2*t&&n.length<Rp&&n.push({x:0,y:0});break}o=c}return n}function Tr(e,t,n){const o=[];let r=Math.min(n,Rp),i=0;for(;r>0&&i<60;){const n=t*(1+2*i);if(n+t>e.height)break;const s=Or(Nr(e,n),t),a=s.length-r,c=a>0?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Cr(97*i+t,.15),z:l+Cr(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function Pr(e,t,n){let o=n,r=0;for(;o>0&&r<60;){const n=t+.875*(1+2*r);if(n+.875>e.height)break;const i=Nr(e,n);if(2*i<Tp)break;o-=Math.max(1,Math.floor(2*i/Tp)),r++}return r}function Rr(e,t,n,o){if(o<=0)return[];const r=Pr(e,t,o=Math.min(o,Rp)),i=r*Tp,s=Math.max(t,n-i)+.875,a=[];let c=0;for(let t=0;t<r&&c<o;t++){const n=s+Tp*t,r=Nr(e,n),i=Math.max(1,Math.floor(2*r/Tp)),l=(2*r-i*Tp)/(i+1),d=-r+l,u=e.height-n-.875-.1;for(let e=0;e<i&&c<o;e++){const n=d+(l+Tp)*e;a.push({cx:n+.875,cy:u+.875,rotation:Cr(53*t+e,10)}),c++}}return a}function jr(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Fr(e,t){const n=jr(e,t);return n>0?n:t}function Lr(e){if(!e)return null;const t=e[Lp];return t&&t.length>0?t:null}function zr(e,t){if(t instanceof Date){const n=t.getTime();return Number.isFinite(n)?e.find(e=>e.label instanceof Date&&e.label.getTime()===n)?.value??null:null}if("number"==typeof t&&Number.isFinite(t)){const n=e.find(e=>"number"==typeof e.label&&e.label===t);return n?n.value:e.find(e=>e.label instanceof Date&&e.label.getTime()===t)?.value??null}return"string"==typeof t?e.find(e=>"string"==typeof e.label&&e.label===t)?.value??null:null}function Dr(e,t){if(!e)return null;const n=Lr(e);if(!n)return e(t);const o=zr(n,t);return null==o?null:e(o)}function _r(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?Dr(n,e.x):t.xAccessor&&null!=e[t.xAccessor]?Dr(n,e[t.xAccessor]):null:null}function Wr(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?Dr(n,e.y):t.yAccessor&&null!=e[t.yAccessor]?Dr(n,e[t.yAccessor]):null:null}function qr(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=e.xAccessor||"x",s=e.yAccessor||"y",a=n[i],c=n[s];if(null==a||null==c)return null;const l=Dr(o,a),d=Dr(r,c);return null==l||null==d?null:{x:l,y:d}}function Br(e){return null==e?null:String(e)}function Gr(e){return Br(e.provenance?.stableId??e.stableId)}function Yr(e){return Br(e.stableId??e.id??e.provenance?.stableId)}function Vr(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Hr(e,t,n){const o=Gr(e);if(!o)return null;const r=n.pointNodes?.find(e=>Br(e.pointId)===o);if(r)return Vr(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>Yr(e)===o);if(!i)return null;const s=_r(i,n),a=Wr(i,n);return null==s||null==a?null:Vr(t,n,{x:s,y:a})}function Ur(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return Vr(t,n,{x:r.x,y:r.y})}const o=qr(n);return o?Vr(t,n,o):null}if("semantic"===o){const o=Hr(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=_r(e,n),i=Wr(e,n)),null!=r&&null!=i)return Vr(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Xr(e){return"string"==typeof e?.type?e.type:""}function Kr(e){return!!e&&"object"==typeof e&&zp.has(Xr(e))}function Jr(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function Zr(e){return"primary"===e?.emphasis||!0===e?.defensive}function Qr(e,t,n={}){if("number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations))return Math.max(0,Math.floor(n.maxAnnotations));if(!(e>0&&t>0))return 1/0;const o=n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:Dp;return Math.max(1,Math.round(e*t/o))}function ei(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*xe(o,0,1)),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function ti(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??_p),i=Qr(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Kr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||a.length<=i)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Zr(e.annotation)),l=a.filter(e=>!Zr(e.annotation)).sort((e,t)=>ei(t.annotation)-ei(e.annotation)||e.index-t.index),d=Math.max(0,i-c.length),u=Math.max(0,r-c.length),h=Math.min(l.length,Math.max(d,u)),p=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,h).map(e=>e.index)]),f=[],m=[];for(const{annotation:e,index:t,note:n}of s)!n||p.has(t)?f.push(e):m.push(e);return{visible:f,deferred:m,budget:i}}function ni(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:Vp,dy:Hp}}function oi(e){const t=e?.familiarity;if(!t)return Kp;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?Kp:n.reduce((e,t)=>e+t,0)/n.length}function ri(e){if(!e)return 1;const t=oi(e);return t<=2?1.5:t>=4?.6:1}function ii(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(Jp,t.source)?Jp[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?`${Math.round(100*Math.max(0,Math.min(1,t.confidence)))}%`:null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function si(e,t){let n=!1;const o=e.map(e=>li(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}function ai(e){if(!li(e))return e;const t="string"==typeof e.mobileText?e.mobileText:void 0,n="string"==typeof e.shortText?e.shortText:void 0,o=t??n;return!o||"string"!=typeof e.label&&null!=e.label?e:{...e,label:o}}function ci(e){if("text"!==e.type||"string"!=typeof e.color)return e;const t="number"==typeof e.dx?e.dx:0,n="number"==typeof e.dy?e.dy:0;return Math.hypot(t,n)<Up?e:{...e,_redundantConnector:!0}}function li(e){return Kr(e)}function di(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...Jr("string"==typeof e.title?e.title:void 0,o,7),...Jr("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}function ui(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:n>=0?i+4:i-r.width-4,y:o<0?s-r.height:s,width:r.width,height:r.height}:{x:n>=0?i:i-r.width,y:o<0?s-r.height-4:s+4,width:r.width,height:r.height}}function hi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function pi(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function fi(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y),s=Math.max(0,e.x+e.width-(t-o)),a=Math.max(0,e.y+e.height-(n-o));return(r+s)*e.height+(i+a)*e.width}function mi(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function gi(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}function yi(e,t,n,o,r,i,s,a){const c=hi(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*fi(c,r,i,a);for(const e of n)l+=12*pi(c,e);for(const e of o)l+=4*pi(c,e);return l}function xi(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Ur(e,t,n):{x:e.x,y:e.y}}function bi(e){const{annotations:t,context:n,defaultOffset:o=Wp,notePadding:r=qp,markPadding:i=Bp,edgePadding:s=Gp,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=Yp,density:d,progressiveDisclosure:u=!1,redundantCues:h=!1,responsive:p,mobile:f,cohesion:m,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof f?f:{},w=b.breakpoint??Xp,M=!!f&&y<=w,v=M&&!1!==b.preferShortText?t.map(ai):t,I=M&&!d?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:d,k=u||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!p?b.responsive??{minWidth:w}:p,$=M&&!m?b.cohesion:m;if(0===v.length||y<=0||x<=0)return v.slice();const N=[],E=gi(n,i);let A=!1;const C=v.map((e,t)=>{if(!li(e))return e;const i=xi(e,t,n);if(!i)return e;const d=di(!0===e.defensive?ii(e):e);if(a&&("number"==typeof(u=e).dx||"number"==typeof u.dy)){const t=ni(e),n="number"==typeof e.dx?e.dx:t.dx,o="number"==typeof e.dy?e.dy:t.dy;return N.push(hi(ui(i.x,i.y,n,o,d),r)),e}var u;let h=null,p=1/0;for(const e of mi(o)){const t=yi(ui(i.x,i.y,e.dx,e.dy,d),e,N,E,y,x,r,s);t<p&&(h=e,p=t)}if(!h)return e;const f=hi(ui(i.x,i.y,h.dx,h.dy,d),r);N.push(f);const m=Math.hypot(h.dx,h.dy),g=c&&m>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return A=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),O=A?C:v.slice();let T=O;if(h){let e=!1;const t=O.map(t=>{const n=ci(t);return n!==t&&(e=!0),n});T=e?t:O}{let e=!1;const t=T.map(t=>{if(!0!==t?.defensive)return t;const n=ii(t);return n!==t&&(e=!0),n});T=e?t:T}const P=/* @__PURE__ */new Set;if(I){const e="object"==typeof I?I:{},t=ri(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Qr(y,x,e))*t))},{deferred:o}=ti({annotations:T,width:y,height:x,...n});for(const e of o)P.add(e)}if(S){const e="object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:Xp;if(y<=e)for(const e of T)li(e)&&"secondary"===e.emphasis&&P.add(e)}if(P.size>0)for(const e of T)!0===e?.defensive&&P.delete(e);let R;return R=0===P.size?T:k?T.map(e=>P.has(e)?{...e,_annotationDeferred:!0}:e):T.filter(e=>!P.has(e)),$?si(R,$):R}function wi(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function Mi(e){const t=wi(e.tight,ef.tight),n=Math.max(t,wi(e.watch,ef.watch));return{tight:t,watch:n,comfortable:Math.max(n,wi(e.comfortable,ef.comfortable))}}function vi(e={}){const{tight:t,watch:n,comfortable:o}=Mi(e);return[{id:"tight",name:"Tight",label:`Tight (< ${t}%)`,max:t,color:tf.tight},{id:"watch",name:"Watch",label:`Watch (${t}% to < ${n}%)`,min:t,max:n,color:tf.watch},{id:"moderate",name:"Moderate",label:`Moderate (${n}% to < ${o}%)`,min:n,max:o,color:tf.moderate},{id:"comfortable",name:"Comfortable",label:`Comfortable (≥ ${o}%)`,min:o,color:tf.comfortable}].filter(e=>null==e.min||null==e.max||e.max>e.min)}function Ii(e,t={}){return Number.isFinite(e)?vi(t).find(t=>(null==t.min||e>=t.min)&&(null==t.max||e<t.max))??null:null}function ki(e,t={}){const n=t.fuels??Zp,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=wi(t.fuels?.[e]);!o&&n<=0||r.push({t:t.t,fuel:e,fuelLabel:Qp[e],mw:n,ba:t.ba})}return r}function Si(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=wi(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function $i(e){const t=wi(e.demand);if(t<=0)return 0;const n=wi(e.capacityOrNetGen),o=wi(e.interchange);return(n+(o<0?-o:0)-t)/t*100}function Ni(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=wi(e.demandMw),n=wi(e.netGenMw),o=$i({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw}),r=Math.max(0,wi(e.fuels?.wind))+Math.max(0,wi(e.fuels?.solar));return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t-r,demandMw:t,netGenMw:n}})}function Ei(e={},t={}){const n=t.field,o=n?{field:n}:{},r=t.tightHatch??{type:"hatch",background:tf.tight,stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9},i={comfortable:{fill:t.comfortableFill??tf.comfortable,fillOpacity:.85},moderate:{fill:t.moderateFill??tf.moderate,fillOpacity:.85},watch:{fill:t.watchFill??tf.watch,fillOpacity:.9},tight:{fill:r,stroke:t.tightFill??tf.tight,strokeWidth:1,fillOpacity:1}};return vi(e).reverse().map(e=>({id:`reserve-${e.id}`,label:e.label,when:{...o,...null!=e.min?{gte:e.min}:{},...null!=e.max?{lt:e.max}:{}},style:i[e.id]}))}function Ai(e={},t={}){const{tight:n,comfortable:o}=Mi(e),[r,i]=t.extent??[],s=Math.min(n,wi(r,-50)),a=Math.max(o,wi(i,Math.max(o+30,40))),c={tight:.12,watch:.1,moderate:.08,comfortable:.06};return vi(e).map(e=>({type:"band",y0:e.min??s,y1:e.max??a,label:e.name,color:e.color,fillOpacity:c[e.id],emphasis:"secondary"}))}function Ci(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>e.t<=t);o=e.length?e[e.length-1]:n[0]}const r=wi(o.demandMw),i=wi(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=$i({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,d=0,u=0;for(const e of Zp){const t=wi(o.fuels?.[e]);t<=0||(u+=t,c[e]=t,t>d&&(d=t,l=e))}if(u>0)for(const e of Object.keys(c))c[e]=c[e]/u;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:u>0?d/u:0,topFuelMw:d,fuelShares:c}}function Oi(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const i=(e.start+e.end)/2,s=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:i,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",..."number"==typeof t.confidence&&Number.isFinite(t.confidence)?{confidence:Math.min(1,Math.max(0,t.confidence))}:{},createdAt:s,stableId:e.id,dataVersion:String(e.start)},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Ti(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Pi(e,t=0){return Number.isFinite(e)?`${e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})} MW`:"—"}function Ri(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function ji(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function Fi(e,t={}){const n=ji(t.start,"start"),o=ji(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new rf;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function Li(e,t){const n=ji(t.start,"start"),o=ji(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(!Number.isFinite(r)||!Number.isFinite(i)||r>i||!Number.isFinite(s)||s<=0)return[];const c=(i-r)/s;if(c>=Number.MAX_SAFE_INTEGER||r<i&&(r+s<=r||i-s>=i))return[];const l=Math.min(.25,4*Number.EPSILON*Math.max(1,c)),d=Math.floor(c+l),u=c>Math.log2(e.length+1),h=[],p=[];if(u){for(const t of e){const e=n(t),r=o(t);e<=r&&(h.push(e),p.push(r))}h.sort((e,t)=>e-t),p.sort((e,t)=>e-t)}let f=0,m=0;const g=[];for(let t=0;t<=d;t++){const y=t>0&&t===d&&Math.abs(t-c)<=l?i:r+t*s;let x=0;if(u){for(;f<h.length&&h[f]<=y;)f++;for(;m<p.length&&(a?p[m]<=y:p[m]<y);)m++;x=f-m}else for(const t of e){const e=n(t),r=o(t);e<=y&&(a?y<r:y<=r)&&x++}g.push({value:y,count:x})}return g}function zi(e,t,n){const o="x"===t?"width":"height",r=new Float64Array(e.length),i=new Float64Array(e.length),s=Array.from({length:e.length},(e,t)=>t);let a=0;const c=()=>{for(let s=0;s<e.length;s++){const a=(e[s][o]+Math.max(0,n))/2;r[s]=e[s][t]-a,i[s]=e[s][t]+a}s.sort((e,t)=>r[e]-r[t]||e-t),a=0;for(let e=0;e<s.length;e++){let t=e+1,n=s.length;for(;t<n;){const o=t+n>>>1;r[s[o]]<=i[s[e]]?t=o+1:n=o}a+=t-e-1}};return c(),{lower:r,upper:i,order:s,update:c,get pairs(){return a}}}function Di(e,t,n,o,r=!1){const i="x"===t?"y":"x",s="x"===t?"width":"height",a="x"===t?"height":"width",c=zi(e,t,n),l=zi(e,i,n),d=new Float64Array(e.length);return()=>{d.fill(0),c.update(),r||l.update();const{order:u,lower:h,upper:p}=c.pairs<l.pairs?c:l;for(let r=0;r<u.length;r++){const c=u[r],l=e[c];for(let f=r+1;f<u.length&&h[u[f]]<=p[c];f++){const r=u[f],h=e[r];if(Math.abs(l[i]-h[i])>(l[a]+h[a])/2+n)continue;const p=h[t]-l[t]||(l.id<h.id?-.5:.5),m=(l[s]+h[s])/2+n-Math.abs(p);if(m<=0)continue;const g=m*o*Math.sign(p);d[c]-=g,d[r]+=g}}return d}}function _i(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(Math.abs(t.y-e.y)<i){const n=e.x<=t.x?1:-1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(Math.abs(t.x-e.x)<i){const n=e.y<=t.y?1:-1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function Wi(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function qi(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function Bi(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function Gi(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function Yi(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function Vi(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function Hi(e,t){const n=Di(e,t?.axis??"x",t?.padding??0,t?.strength??.5)(),o=/* @__PURE__ */new Map;return e.forEach((e,t)=>o.set(e.id,(o.get(e.id)??0)+n[t])),o}function Ui(e,t,n=!1){if("function"==typeof e)return n?t=>e(Me(t)??t):e;const o=e??t;return e=>we(e,o,void 0)}function Xi(e,t,n,o){return Ki(e,t,n,o,!1)}function Ki(e,t,n,o,r){const i=o.fixedAxis??"y",s=Ui(o.fixedAccessor,"fixed",r),a=e=>String(Ui(o.sourceAccessor,"source",r)(e)),c=e=>String(Ui(o.targetAccessor,"target",r)(e)),l=o.size??(()=>af),d=o.iterations??180,u=o.attraction??.012,h=o.anchorStrength??.003,p=o.collisionStrength??.12,f=o.collisionPadding??15,m=o.edgePadding??42,g=o.fixedPadding??16,y=o.damping??.72,x=o.spread??1,[b,w]=o.fixedDomain;if(![b,w,n.x,n.y,n.width,n.height].every(Number.isFinite)||n.width<=0||n.height<=0)return{positioned:[],byId:/* @__PURE__ */new Map};const M=w-b||1,v=("y"===i?n.y:n.x)+g,I=("y"===i?n.y+n.height:n.x+n.width)-g,k=("y"===i?n.x:n.y)+m,S=("y"===i?n.x+n.width:n.y+n.height)-m,$=Math.max(1,S-k),N=e.flatMap(e=>{const t=s(e);if("number"!=typeof t&&("string"!=typeof t||!t.trim()))return[];const n=Number(t),i=v+(n-b)/M*(I-v);if(!Number.isFinite(n)||!Number.isFinite(i))return[];const a=Me(e)??e,c=(d=e,String(Ui(o.idAccessor,"id",r)(d)));var d;const{width:u,height:h}=l(a);if(![u,h].every(e=>Number.isFinite(e)&&e>0))return[];const p=k+To(c)*$;return[{data:a,id:c,width:u,height:h,fixedValue:n,fixed:i,free:p,anchor:p}]}),E=e=>"y"===i?e.width:e.height,A=new Map(N.map((e,t)=>[e.id,t])),C=[];for(const e of t){const t=A.get(a(e)),n=A.get(c(e));void 0!==t&&void 0!==n&&C.push([t,n])}const O=N.map(e=>({id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height})),T="y"===i?"x":"y",P=Di(O,T,f,p,!0),R=new Float64Array(N.length);for(let e=0;e<d;e++){R.fill(0);for(const[e,t]of C){const n=(N[t].free-N[e].free)*u;R[e]+=n,R[t]-=n}for(let e=0;e<N.length;e++){const t=N[e];R[e]+=(t.anchor-t.free)*h,O[e][T]=t.free}const e=P();for(let t=0;t<N.length;t++){const n=N[t];n.free+=(R[t]+e[t])*y;const o=E(n)/2;n.free=Math.max(k+o,Math.min(S-o,n.free))}}if(1!==x){const e=(k+S)/2;for(const t of N){const n=E(t)/2;t.free=Math.max(k+n,Math.min(S-n,e+(t.free-e)*x))}}const j=N.map(e=>({data:e.data,id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:j,byId:new Map(j.map(e=>[e.id,e]))}}function Ji(e){let t=0;for(const n of e)t+=uf[n]??(n>="0"&&n<="9"?hf:(n.codePointAt(0)??0)>=11904?ff:pf);return t}function Zi(e,t){return Math.max(8,Ji(e)*t*mf+gf)}function Qi(e,t,n){if(!n)return{w:e,h:t};const o=Math.abs(n)*Math.PI/180,r=Math.cos(o),i=Math.sin(o);return{w:e*r+t*i,h:e*i+t*r}}function es(e,t){let n=t>>>0;for(const t of e){n=Oo(t.col,n);for(const e of t.rows)n=Oo(`${e.text}␟${e.weight}␟${e.segment}`,n)}return(n>>>0).toString(36)}function ts(e){const{plans:t,colW:n,bodyH:o,yTop:r,yBot:i,segToY:s,collisionPadding:a}=e,c=n*o;let l=1/0,d=1/0;for(const o of t){let t=0;for(const e of o.rows){const o=Ji(e.text)*mf;t+=o*lf*e.baseFont*e.baseFont;const r=Qi(o,lf,e.rotation);d=Math.min(d,(n-8-gf)/(r.w*e.baseFont))}t>0&&(l=Math.min(l,Math.sqrt(e.packingDensity*c/t)))}const u=e=>{const o=[],c=[];return t.forEach((t,l)=>{if(n<=0)return;const d=t.colLeft+4,u=t.colLeft+n-4,h=t.rows.map((t,o)=>{const r=e*t.baseFont,i=Math.max(df,r),a=Qi(Zi(t.text,i),i*lf+2,t.rotation);return{rowIndex:o,id:t.id,font:i,floored:t.floored||r<df,rotation:t.rotation,w:a.w,h:a.h,anchorY:s(t.segment),seed:(To(t.id)-.5)*Math.min(.5*n,80)}}).sort((e,t)=>t.font-e.font||(e.id<t.id?-1:1)),p=new yf(xf);for(const e of h){const n=e.w/2,s=e.h/2,h=xe(t.center+e.seed,d+n,u-n),f=e.anchorY;let m=null;for(let t=0;t<bf;t++){const o=3.2*Math.sqrt(t),c=2.399963229728653*t,l={x:xe(h+o*Math.cos(c),d+n,u-n),y:xe(f+o*Math.sin(c),r+s,i-s),w:e.w,h:e.h};if(!p.collides(l,a)){m=l;break}}m?(p.insert(m),o.push({planIndex:l,rowIndex:e.rowIndex,id:e.id,x:m.x,y:m.y,fontSize:e.font,rotation:e.rotation,w:e.w,h:e.h,floored:e.floored})):c.push({planIndex:l,rowIndex:e.rowIndex})}}),{placements:o,unplaced:c}};let h=e.scaleToFit?Math.min(1,l,d):Math.min(1,d),p=u(h);if(e.scaleToFit)for(let e=0;e<6&&p.unplaced.length>0&&h>.1;e++)h*=.88,p=u(h);return p}function ns(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=r<o?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?xe((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?xe(n,0,1):t},d=l(e.oldestOpacity,.25),u=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return u;const r=xe(n/c,0,1);return d+(u-d)*r}}}function os(e){const t=e.config,{plot:n}=e.dimensions,o={nodes:[],unplaced:[],sizeFloored:[]};if(n.width<=0||n.height<=0||0===e.data.length)return o;const r=be(t.textAccessor),i=e=>{const n=Number(be(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},s=be(t.columnAccessor),a=e=>Number(be(t.segmentAccessor)(e)),c=t.minFontSize??11,l=t.maxFontSize??42,d=t.columnGutter??18,u=t.collisionPadding??2,h=!1!==t.showColumnLabels,p=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,m=t.segmentTickFormat??(e=>String(Math.round(e))),g=t.rotate??0,y=!0===t.repeatWords,x=!1!==t.scaleToFit,b=t.packingDensity??.6,w="string"==typeof t.textAccessor?t.textAccessor:"word",M="string"==typeof t.weightAccessor?t.weightAccessor:"weight",v="string"==typeof t.columnAccessor?t.columnAccessor:"column",I="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",k=[],S=/* @__PURE__ */new Map;let $=1/0,N=-1/0;for(let t=0;t<e.data.length;t++){const n=e.data[t],o=String(s(n)),c=String(r(n)),l=i(n),d=a(n);c&&Number.isFinite(d)&&(S.has(o)||(k.push(o),S.set(o,[])),S.get(o).push({col:o,text:c,weight:l,segment:d,datum:n,dataIndex:t}),d<$&&($=d),d>N&&(N=d))}if(0===k.length)return o;if(!y)for(const[e,t]of S){const n=/* @__PURE__ */new Map;for(const e of t){const t=n.get(e.text);(!t||e.weight>t.weight)&&n.set(e.text,e)}S.set(e,[...n.values()])}let E=1/0,A=-1/0;for(const e of S.values())for(const t of e)t.weight<E&&(E=t.weight),t.weight>A&&(A=t.weight);if(!Number.isFinite(E))return o;const C=t.columnOrder?[...t.columnOrder.filter(e=>S.has(e)),...k.filter(e=>!t.columnOrder.includes(e))]:k,O=new Map(C.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[T,P]=t.segmentDomain??[$,N],R=P-T||1,j=A-E||1,F=h?22:0,L=p?52:0,z=n.x+L,D=n.y+F,_=Math.max(0,n.width-L),W=Math.max(0,n.height-F),q=C.length,B=Math.max(0,_-d*Math.max(0,q-1)),G=q>0?B/q:0,Y=D+14,V=D+W-14,H=e=>Y+(e-T)/R*(V-Y),U=C.map((e,n)=>{const o=O.get(e),r=(S.get(e)??[]).map((r,i)=>{const s={word:r.text,column:r.col,weight:r.weight,segment:r.segment,datum:r.datum,dataIndex:r.dataIndex,columnIndex:n,resolvedColumnColor:o},a=t.wordOpacity?Number(t.wordOpacity(s)):1,d=t.wordColor?.(s),u=`${e}::${r.text}::${i}`,h=(p=r.weight,A>0?l*Math.sqrt(p/A):0);var p;return{id:u,text:r.text,weight:r.weight,segment:r.segment,baseFont:Math.max(c,h),floored:h<c,rotation:g>0?2*(To(u+"r")-.5)*g:0,opacity:Number.isFinite(a)?xe(a,0,1):0,color:d||o,info:s}});return 0===r.length?null:{col:e,colLeft:z+n*(G+d),center:z+n*(G+d)+G/2,rows:r}}).filter(e=>null!==e),X=$e([n.x,n.y,n.width,n.height,F,L,d,u,c,l,g,x,b,T,P,U.length,es(U,2166136261),es(U,16777619)]),K=Mf.getOrCompute(X,()=>ts({plans:U,colW:G,bodyH:W,yTop:Y,yBot:V,segToY:H,collisionPadding:u,packingDensity:b,scaleToFit:x})),J=(e,t)=>U[e].rows[t],Z=K.unplaced.map(({planIndex:e,rowIndex:t})=>J(e,t).info),Q=K.placements.map(e=>{const t=J(e.planIndex,e.rowIndex),n=U[e.planIndex].col,o=Math.sqrt((t.weight-E)/j);return{id:e.id,text:t.text,x:e.x,y:e.y,w:e.w,h:e.h,fontSize:e.fontSize,rotation:e.rotation,floored:e.floored,color:t.color,opacity:t.opacity,info:t.info,datum:Ie(e=>{for(const n of Object.keys(t.info.datum))e(n,t.info.datum[n]);e("word",t.text),e("weight",t.weight),e("column",n),e("segment",t.segment),"word"!==w&&e(w,t.text),"weight"!==M&&e(M,t.weight),"column"!==v&&e(v,n),"segment"!==I&&e(I,t.segment),e("__strength",.5+.5*o)})}}),ee=Q.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{const t=e.rotation?e.w:Zi(e.text,e.fontSize),n=e.rotation?e.h:e.fontSize*lf;return{type:"rect",x:e.x-t/2,y:e.y-n/2,w:t,h:n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:String(e.datum.column),_transitionKey:e.id}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,wf.jsxs)("g",{className:"semiotic-word-trails","data-unplaced-count":Z.length||void 0,children:[p&&rs({x:n.x+L-10,yTop:Y,yBot:V,segLo:T,segHi:P,segToY:H,tickCount:f,tickFormat:m,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),h&&C.map((e,t)=>{if(G<=0)return null;const o=z+t*(G+d);/* @__PURE__ */ /* @__PURE__ */
91
+ return(0,wf.jsx)("text",{x:o+G/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:O.get(e),style:{pointerEvents:"none"},children:e},`wt-col-${t}`)}),ee.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,wf.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},`wt-${e.id}`))]}),restyle:()=>{},unplaced:Z,sizeFloored:Q.filter(e=>e.floored).map(e=>e.info)}}function rs(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;o<e.tickCount;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));/* @__PURE__ */ /* @__PURE__ */
92
+ return(0,wf.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[
93
93
  /* @__PURE__ */
94
- /* @__PURE__ */(0,yf.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);/* @__PURE__ */ /* @__PURE__ */
95
- return(0,yf.jsxs)("g",{children:[
94
+ /* @__PURE__ */(0,wf.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);/* @__PURE__ */ /* @__PURE__ */
95
+ return(0,wf.jsxs)("g",{children:[
96
96
  /* @__PURE__ */
97
- /* @__PURE__ */(0,yf.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),
97
+ /* @__PURE__ */(0,wf.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),
98
98
  /* @__PURE__ */
99
- /* @__PURE__ */(0,yf.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},`wt-tick-${n}`)}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,yf.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function is(e){return null==e?void 0:String(e)}function ss(e){const t=is(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??wf,style:{...bf,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function as(e){return ss(e)}function cs(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...bf,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function ls(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...bf,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:is(e.id)}}function ds(e){const t=is(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...bf,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??wf,style:{...bf,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function us(e){const t={style:{...bf,cursor:e.cursor},datum:e.datum,id:is(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?(e.type&&"curved"!==e.type||(t.style.fill="none"),{type:e.type??"curved",pathD:e.pathD,...t}):{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function hs(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null!=n&&c(n)-c(t)<=r?c(n):c(t)+r:t+1,a.push(e)};let d=null;for(let n=0;n<e.length;n++){const a=t(e[n],n);if(s&&!a){d&&(l(d,d.endIndex,n),d=null);continue}const u=!(o&&n>0)||c(n)-c(n-1)<=r;d&&u&&i(d.value,a)?d.endIndex=n:(d&&l(d,d.endIndex,n),d={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return d&&l(d,d.endIndex,null),a}function ps(e,t,n=0){return t<=0?e:((e-n)%t+t)%t+n}function fs(e,t,n){if(n<=0)return t-e;let o=(t-e)%n;return o>n/2?o-=n:o<=-n/2&&(o+=n),o}function ms(e,t,n){return t<=n?e>=t&&e<=n:e>=t||e<=n}function gs(e,t,n,o){return n<=o?e.filter(e=>ms(t(e),n,o)):[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]}function ys(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw new Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=new Array(r).fill(0);for(let e=1;e<r;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;e<r;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(t.mean<=e.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=c<a?a:c,d=new Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;n<=e.end;n++)d[n]=t+i[n]}return d}function xs(e,t){let n=0,o=e.length-1,r=-1;for(;n<=o;){const i=n+o>>>1;e[i].at<=t?(r=i,n=i+1):o=i-1}return r<0?{at:t,before:0,after:0}:e[r]}function bs(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;r<e.length-1;r++){const i=e[r],s=e[r+1],a=[.../* @__PURE__ */new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=xs(i,e),n=xs(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function ws(e,t,n,o={}){let r=[...e];if(r.length<=1)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;e<c&&a<l;e++){const e=new Map(r.map((e,t)=>[e,t])),c=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const d=n(r);if(a++,d<s)s=d,i=[...r];else if(d===s)break}return i}function Ms(e,t,n={}){const o=[...e];if(o.length<=1)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;e<s&&i<a;e++){let e=!1;for(let n=0;n<o.length-1&&i<a;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,s<r?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function vs(e,t,n={}){const o=[...e],r=o.length;if(r<=1||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,e<c&&(c=e,a=[...o])};l();const d=new Array(r).fill(0);let u=0;for(;u<r&&s<i;)if(d[u]<u){const e=u%2==0?0:d[u];[o[e],o[u]]=[o[u],o[e]],l(),d[u]++,u=0}else d[u]=0,u++;return a}function ks(e,t,n=()=>!0){let o=0;for(let r=0;r<e.length;r++){const[i,s]=t(e[r]);for(let a=r+1;a<e.length;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);(i-c)*(s-l)<0&&o++}}return o}function Is(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=Math.max(0,n-i-s),c=e.length>1?a/(e.length-1):0,l=/* @__PURE__ */new Map;return e.forEach((e,t)=>{l.set(e.id,{id:e.id,x:i+c*t,y:o,index:t})}),l}function Ss(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>$s(e.label??e.id)),d=e.map((e,t)=>Math.max(1,l(e,t))),u=d.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),p=Math.max(0,h-u),f=c&&e.length>1?p/(e.length-1):0,m=/* @__PURE__ */new Map;let g=i;return c||1!==e.length||(g=i+Math.max(0,(h-d[0])/2)),e.forEach((e,t)=>{const n=d[t];m.set(e.id,{id:e.id,x:g+n/2,y:o,index:t,width:n}),g+=n+a+f}),m}function $s(e,t=38,n=7.4,o=20){return Math.max(t,String(e??"").length*n+o)}function Ns(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new tf,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function Es(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t),s=o<=1?i:i/Math.max(1,o-1);return{arcLift:r,levelStep:Math.min(72,Math.max(28,s))}}function As(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Cs(e,t,n){return e-n.arcLift-t*n.levelStep}function Os(e,t=Ts){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=/* @__PURE__ */new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=/* @__PURE__ */new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Ts(e){if(null==e)return String(e);if("object"!=typeof e)return String(e);const t=e;if(null!=t.id)return String(t.id);const n=t.sourceTokenId??t.source,o=t.targetTokenId??t.target,r=t.relation??t.label??"";return`${String(n)}|${String(o)}|${String(r)}`}function Ps(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Rs(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return(Math.atan2(e-o,-(t-r))+vf)%vf}function js(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??vf;return e=>i+(e-n)/r*(s-i)}function Fs(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function Ls(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=Ps(e,t,{center:i});return`${zs(n)},${zs(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),d=t>=e?1:0;if(l>=vf-1e-6){const e=i?.x??0,t=i?.y??0,n=`${zs(e)},${zs(t-c)}`,o=`${zs(e)},${zs(t+c)}`;let r=`M${n} A${zs(c)},${zs(c)} 0 1 1 ${o} A${zs(c)},${zs(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${zs(e)},${zs(t-a)}`,o=`${zs(e)},${zs(t+a)}`;r+=` M${n} A${zs(a)},${zs(a)} 0 1 0 ${o} A${zs(a)},${zs(a)} 0 1 0 ${n} Z`}return r}const u=l>Math.PI?1:0,h=s(e,c),p=s(t,c);if(a<=0){const e=i?.x??0,t=i?.y??0;return`M${zs(e)},${zs(t)} L${h} A${zs(c)},${zs(c)} 0 ${u} ${d} ${p} Z`}const f=s(t,a),m=s(e,a);return`M${h} A${zs(c)},${zs(c)} 0 ${u} ${d} ${p} L${f} A${zs(a)},${zs(a)} 0 ${u} ${1===d?0:1} ${m} Z`}function zs(e){return Math.round(1e3*e)/1e3}function Ds(e,t){return{x:e.x+t.x,y:e.y+t.y}}function _s(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ws(e,t){return{x:e.x*t,y:e.y*t}}function qs(e){return Math.hypot(e.x,e.y)}function Gs(e){const t=qs(e)||1;return{x:e.x/t,y:e.y/t}}function Bs(e,t){const[n,o]=e.viewBox??kf,[r,i]=e.anchor??If,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function Ys(e,t){const n=Bs(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function Vs(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??kf,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a<=s?{x:0,y:0,width:0,height:0}:s<=0&&a>=1?null:"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}}function Hs(e,t){const n=lt(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function Us(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t})),i="line"===o?e=>({stroke:e.color??$f,strokeWidth:2,fill:"none"}):e=>({fill:e.color??$f,stroke:e.color??$f});t.push({type:o,label:e.colorLabel??"",items:r,styleFn:i})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??$f,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;/* @__PURE__ */ /* @__PURE__ */
100
- return(0,Sf.jsx)("path",{d:at(t,Hs(t,Nf-1)),transform:`translate(${Nf},${Nf})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>String(e)),r=e.sizeColor??$f,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>/* @__PURE__ */ /* @__PURE__ */(0,Sf.jsx)("circle",{cx:Nf,cy:Nf,r:e.r,fill:e.color??r})})}return t}function Xs(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,s=e.color??"var(--semiotic-text-secondary, #888)",a=n+o;let c=0;const l=[];return e.entries.forEach((e,d)=>{const u="vertical"===t?0:c,h="vertical"===t?c:0,p=e.color??e.line??s;l.push(
99
+ /* @__PURE__ */(0,wf.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},`wt-tick-${n}`)}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,wf.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function is(e){return null==e?void 0:String(e)}function ss(e){const t=is(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??If,style:{...vf,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function as(e){return ss(e)}function cs(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...vf,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function ls(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...vf,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:is(e.id)}}function ds(e){const t=is(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...vf,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??If,style:{...vf,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function us(e){const t={style:{...vf,cursor:e.cursor},datum:e.datum,id:is(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?(e.type&&"curved"!==e.type||(t.style.fill="none"),{type:e.type??"curved",pathD:e.pathD,...t}):{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function hs(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null!=n&&c(n)-c(t)<=r?c(n):c(t)+r:t+1,a.push(e)};let d=null;for(let n=0;n<e.length;n++){const a=t(e[n],n);if(s&&!a){d&&(l(d,d.endIndex,n),d=null);continue}const u=!(o&&n>0)||c(n)-c(n-1)<=r;d&&u&&i(d.value,a)?d.endIndex=n:(d&&l(d,d.endIndex,n),d={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return d&&l(d,d.endIndex,null),a}function ps(e,t,n=0){return t<=0?e:((e-n)%t+t)%t+n}function fs(e,t,n){if(n<=0)return t-e;let o=(t-e)%n;return o>n/2?o-=n:o<=-n/2&&(o+=n),o}function ms(e,t,n){return t<=n?e>=t&&e<=n:e>=t||e<=n}function gs(e,t,n,o){return n<=o?e.filter(e=>ms(t(e),n,o)):[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]}function ys(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw new Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=new Array(r).fill(0);for(let e=1;e<r;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;e<r;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(t.mean<=e.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=c<a?a:c,d=new Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;n<=e.end;n++)d[n]=t+i[n]}return d}function xs(e,t){let n=0,o=e.length-1,r=-1;for(;n<=o;){const i=n+o>>>1;e[i].at<=t?(r=i,n=i+1):o=i-1}return r<0?{at:t,before:0,after:0}:e[r]}function bs(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;r<e.length-1;r++){const i=e[r],s=e[r+1],a=[.../* @__PURE__ */new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=xs(i,e),n=xs(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function ws(e,t,n,o={}){let r=[...e];if(r.length<=1)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;e<c&&a<l;e++){const e=new Map(r.map((e,t)=>[e,t])),c=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const d=n(r);if(a++,d<s)s=d,i=[...r];else if(d===s)break}return i}function Ms(e,t,n={}){const o=[...e];if(o.length<=1)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;e<s&&i<a;e++){let e=!1;for(let n=0;n<o.length-1&&i<a;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,s<r?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function vs(e,t,n={}){const o=[...e],r=o.length;if(r<=1||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,e<c&&(c=e,a=[...o])};l();const d=new Array(r).fill(0);let u=0;for(;u<r&&s<i;)if(d[u]<u){const e=u%2==0?0:d[u];[o[e],o[u]]=[o[u],o[e]],l(),d[u]++,u=0}else d[u]=0,u++;return a}function Is(e,t,n=()=>!0){let o=0;for(let r=0;r<e.length;r++){const[i,s]=t(e[r]);for(let a=r+1;a<e.length;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);(i-c)*(s-l)<0&&o++}}return o}function ks(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=Math.max(0,n-i-s),c=e.length>1?a/(e.length-1):0,l=/* @__PURE__ */new Map;return e.forEach((e,t)=>{l.set(e.id,{id:e.id,x:i+c*t,y:o,index:t})}),l}function Ss(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>$s(e.label??e.id)),d=e.map((e,t)=>Math.max(1,l(e,t))),u=d.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),p=Math.max(0,h-u),f=c&&e.length>1?p/(e.length-1):0,m=/* @__PURE__ */new Map;let g=i;return c||1!==e.length||(g=i+Math.max(0,(h-d[0])/2)),e.forEach((e,t)=>{const n=d[t];m.set(e.id,{id:e.id,x:g+n/2,y:o,index:t,width:n}),g+=n+a+f}),m}function $s(e,t=38,n=7.4,o=20){return Math.max(t,String(e??"").length*n+o)}function Ns(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new rf,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function Es(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t),s=o<=1?i:i/Math.max(1,o-1);return{arcLift:r,levelStep:Math.min(72,Math.max(28,s))}}function As(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Cs(e,t,n){return e-n.arcLift-t*n.levelStep}function Os(e,t=Ts){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=/* @__PURE__ */new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=/* @__PURE__ */new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Ts(e){if(null==e)return String(e);if("object"!=typeof e)return String(e);const t=e;if(null!=t.id)return String(t.id);const n=t.sourceTokenId??t.source,o=t.targetTokenId??t.target,r=t.relation??t.label??"";return`${String(n)}|${String(o)}|${String(r)}`}function Ps(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Rs(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return(Math.atan2(e-o,-(t-r))+Sf)%Sf}function js(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??Sf;return e=>i+(e-n)/r*(s-i)}function Fs(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function Ls(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=Ps(e,t,{center:i});return`${zs(n)},${zs(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),d=t>=e?1:0;if(l>=Sf-1e-6){const e=i?.x??0,t=i?.y??0,n=`${zs(e)},${zs(t-c)}`,o=`${zs(e)},${zs(t+c)}`;let r=`M${n} A${zs(c)},${zs(c)} 0 1 1 ${o} A${zs(c)},${zs(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${zs(e)},${zs(t-a)}`,o=`${zs(e)},${zs(t+a)}`;r+=` M${n} A${zs(a)},${zs(a)} 0 1 0 ${o} A${zs(a)},${zs(a)} 0 1 0 ${n} Z`}return r}const u=l>Math.PI?1:0,h=s(e,c),p=s(t,c);if(a<=0){const e=i?.x??0,t=i?.y??0;return`M${zs(e)},${zs(t)} L${h} A${zs(c)},${zs(c)} 0 ${u} ${d} ${p} Z`}const f=s(t,a),m=s(e,a);return`M${h} A${zs(c)},${zs(c)} 0 ${u} ${d} ${p} L${f} A${zs(a)},${zs(a)} 0 ${u} ${1===d?0:1} ${m} Z`}function zs(e){return Math.round(1e3*e)/1e3}function Ds(e,t){return{x:e.x+t.x,y:e.y+t.y}}function _s(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ws(e,t){return{x:e.x*t,y:e.y*t}}function qs(e){return Math.hypot(e.x,e.y)}function Bs(e){const t=qs(e)||1;return{x:e.x/t,y:e.y/t}}function Gs(e,t){const[n,o]=e.viewBox??$f,[r,i]=e.anchor??Nf,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function Ys(e,t){const n=Gs(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function Vs(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??$f,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a<=s?{x:0,y:0,width:0,height:0}:s<=0&&a>=1?null:"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}}function Hs(e,t){const n=lt(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function Us(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t})),i="line"===o?e=>({stroke:e.color??Af,strokeWidth:2,fill:"none"}):e=>({fill:e.color??Af,stroke:e.color??Af});t.push({type:o,label:e.colorLabel??"",items:r,styleFn:i})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??Af,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;/* @__PURE__ */ /* @__PURE__ */
100
+ return(0,Ef.jsx)("path",{d:at(t,Hs(t,Cf-1)),transform:`translate(${Cf},${Cf})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>String(e)),r=e.sizeColor??Af,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>/* @__PURE__ */ /* @__PURE__ */(0,Ef.jsx)("circle",{cx:Cf,cy:Cf,r:e.r,fill:e.color??r})})}return t}function Xs(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,s=e.color??"var(--semiotic-text-secondary, #888)",a=n+o;let c=0;const l=[];return e.entries.forEach((e,d)=>{const u="vertical"===t?0:c,h="vertical"===t?c:0,p=e.color??e.line??s;l.push(
101
101
  /* @__PURE__ */
102
- /* @__PURE__ */(0,Sf.jsxs)("g",{transform:`translate(${u},${h})`,children:[Ks(e,n,p,s),
102
+ /* @__PURE__ */(0,Ef.jsxs)("g",{transform:`translate(${u},${h})`,children:[Ks(e,n,p,s),
103
103
  /* @__PURE__ */
104
- /* @__PURE__ */(0,Sf.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:s,children:e.label})]},`legend-${d}`)),c+="vertical"===t?a:n+r+e.label.length*i*.58+o+8}),/* @__PURE__ */ /* @__PURE__ */(0,Sf.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function Ks(e,t,n,o){if(e.shape){const o=Hs(e.shape,t/2-1);/* @__PURE__ */ /* @__PURE__ */
105
- return(0,Sf.jsx)("path",{d:at(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;/* @__PURE__ */ /* @__PURE__ */
106
- return(0,Sf.jsxs)("g",{children:[
104
+ /* @__PURE__ */(0,Ef.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:s,children:e.label})]},`legend-${d}`)),c+="vertical"===t?a:n+r+e.label.length*i*.58+o+8}),/* @__PURE__ */ /* @__PURE__ */(0,Ef.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function Ks(e,t,n,o){if(e.shape){const o=Hs(e.shape,t/2-1);/* @__PURE__ */ /* @__PURE__ */
105
+ return(0,Ef.jsx)("path",{d:at(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;/* @__PURE__ */ /* @__PURE__ */
106
+ return(0,Ef.jsxs)("g",{children:[
107
107
  /* @__PURE__ */
108
- /* @__PURE__ */(0,Sf.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>/* @__PURE__ */ /* @__PURE__ */(0,Sf.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),
108
+ /* @__PURE__ */(0,Ef.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>/* @__PURE__ */ /* @__PURE__ */(0,Ef.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),
109
109
  /* @__PURE__ */
110
- /* @__PURE__ */(0,Sf.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return e.line?/* @__PURE__ */ /* @__PURE__ */(0,Sf.jsx)("rect",{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}):/* @__PURE__ */ /* @__PURE__ */(0,Sf.jsx)("rect",{width:t,height:t,rx:2,fill:n})}function Js(e){const t=e,n=[ta(t,["datum","data"]),ta(t,["datum"]),ta(t,["data","data"]),ta(t,["data"]),ta(t,["node","datum","data"]),ta(t,["node","datum"]),e];for(const e of n){if(!na(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function Zs(e,t={}){const n=Js(e);if(!n)return[];const o=new Set(Ef);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:ea(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):Qs(i)}),r.length>=(t.maxEntries??8)))break;return r}function Qs(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return`${e.length} items`;if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function ea(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function ta(e,t){let n=e;for(const e of t){if(!na(n))return;n=n[e]}return n}function na(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function oa(e,t){const n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,/* @__PURE__ */new Set);for(const e of t)n.has(e.source)||n.set(e.source,/* @__PURE__ */new Set),n.has(e.target)||n.set(e.target,/* @__PURE__ */new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function ra(e,t){const n={};for(const t of e)s(n,t.id,0);for(const e of t)s(n,e.source,(i(n,e.source)??0)+1),s(n,e.target,(i(n,e.target)??0)+1);return n}function ia(e,t){const n={};s(n,t,0);const o=[t];let i=0;for(;i<o.length;){const t=o[i];i+=1;for(const i of e.get(t)||[])r(n,i)||(s(n,i,n[t]+1),o.push(i))}return n}function sa(e,t,n,o){if(n===o)return n?[n]:[];const i=oa(e,t),s=a();s[n]=null;const c=[n];let l=0;for(;l<c.length;){const e=c[l];if(l+=1,e===o)break;for(const t of i.get(e)||[])r(s,t)||(s[t]=e,c.push(t))}if(!r(s,o))return[];const d=[];let u=o;for(;null!=u;)d.unshift(u),u=s[u];return d}function aa(e,t,n,o=1){const r=oa(e,t);if(!r.has(n))/* @__PURE__ */return new Set;const i=ia(r,n),s=/* @__PURE__ */new Set;for(const e of Object.keys(i))i[e]<=o&&s.add(e);return s}function ca(e,t){const n=oa(e,t),o={};for(const t of e)s(o,t.id,0);for(const t of e.map(e=>e.id)){const r=[],c=a(),l=a(),d=a();for(const t of e)c[t.id]=[],l[t.id]=0,d[t.id]=-1;l[t]=1,d[t]=0;const u=[t];let h=0;for(;h<u.length;){const e=u[h];h+=1,r.push(e);for(const t of n.get(e)||[])d[t]<0&&(d[t]=d[e]+1,u.push(t)),d[t]===d[e]+1&&(l[t]+=l[e],c[t].push(e))}const p=a();for(const t of e)p[t.id]=0;for(;r.length;){const e=r.pop();for(const t of c[e])p[t]+=l[t]/l[e]*(1+p[e]);e!==t&&s(o,e,(i(o,e)??0)+p[e])}}for(const e of Object.keys(o))s(o,e,o[e]/2);return o}function la(e,t){const n=oa(e,t),o={};for(const t of e){const e=ia(n,t.id);let r=0,i=0;for(const t of Object.keys(e))r+=e[t],i+=1;s(o,t.id,r>0?(i-1)/r:0)}return o}function da(e,t){const n=oa(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(r<2){s(o,t.id,0);continue}let i=0;for(let t=0;t<e.length;t+=1)for(let o=t+1;o<e.length;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);s(o,t.id,2*i/(r*(r-1)))}return o}function ua(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const o of Object.keys(e))s(n,o,t>0?e[o]/t:0);return n}function ha(e,t,n,o={}){const r=oa(e,t),s=a();for(const t of e)s[t.id]=ia(r,t.id);let c=o.minHops??4,l=o.startThreshold??.08;const d=o.maxThreshold??.2,u=/* @__PURE__ */new Set;let h=0;for(;0===u.size&&h<40;){for(let t=0;t<e.length;t+=1)for(let o=t+1;o<e.length;o+=1){const r=e[t].id,a=e[o].id,d=i(n,r),h=i(n,a);if(!d||!h)continue;const p=void 0===s[r][a]?1/0:s[r][a],f=d.x-h.x,m=d.y-h.y,g=Math.sqrt(f*f+m*m);p>=c&&g<l&&(u.add(r),u.add(a))}0===u.size&&(l+=.02,l>d&&(l=o.startThreshold??.08,c=Math.max(2,c-1))),h+=1}return{problemIds:u,threshold:l,minHops:c}}async function pa(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260;if(!ce()||!ae(o,e.length,t.length,c,i))return Ye(e,t,{...a,nodeRadius:s});const l={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{const{runForceLayoutWorker:e}=await Promise.resolve().then(()=>(Ou(),Au));return(await e(l,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return Ye(e,t,{...a,nodeRadius:s})}}function fa(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=e.reduce((e,t)=>Math.max(e,t[s]),1);return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),d=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:d,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function ma(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],d=e.x+e.width/2,u=e.y+e.height/2,h=(e,t,o,r,i)=>{l.push({id:`${n}-${e}`,shape:{type:"aabb",x:t,y:o,width:r,height:i}})};return o&&h("floor",d,e.y+e.height+c/2,e.width+2*a,c),r&&h("ceiling",d,e.y-c/2,e.width+2*a,c),i&&h("left-wall",e.x-a/2,u,a,e.height+2*c),s&&h("right-wall",e.x+e.width+a/2,u,a,e.height+2*c),l}function ga(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:d=!0,closedBefore:u,lidY:h=s,lidThickness:p=Math.max(2,c)}=e,f=[],m=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(d||l)for(let e=l?0:1;e<=y;e+=1){if(!d&&e>0&&e<n)continue;const s=i(o+e*r);f.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:m,width:c,height:g}})}if(null!=u)for(let e=0;e<n;e+=1){const n=o+e*r,s=n+r;if(s>=u)continue;const a=i(n),l=i(s);f.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:p}})}return f}function ya(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function xa(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function ba(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=ya(e,n),r=xa(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function wa(e,t){return(t??Object.keys(e)).map(t=>ya(e,t)).filter(xa).map(e=>({label:e.label??e.id,value:e.count}))}function Ma(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?ya(s,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),d=e.completion?.threshold,u="threshold"===i?Number.isFinite(d)&&Number(d)>=0?Number(d):c:void 0,h=t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(u??c):0===o.length);return{id:e.id,label:e.label??e.id,mode:i,complete:h,absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:u,missing:o}})}function va(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function ka(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Ia(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),d=(c+l)/2,u=Math.max(1,l-c),h=xe(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,m=xe(u*h+f,.06*u,.5*u),g=m/2,y=d-g,x=d+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw new Error("processStageLayout requires at least one stage");const I=xe(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),S=va(k),$=a-s;let N=s;const E=k.map((e,t)=>{const n=(e.share??1)/S*$,o=N,r=t===k.length-1?a:N+n;return N=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:o,x1:r,x:(o+r)/2,width:r-o,y:d,height:u}}),A=E[I],C=A.x0,O=A.x1,T=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=xe((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=C){const t=xe((e-s)/Math.max(1,C-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=O)return"top"===n?y:x;const o=xe((e-O)/Math.max(1,a-O),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},P=E.map(e=>{const t=Math.min(T(e.x0,"top"),T(e.x1,"top")),n=Math.max(T(e.x0,"bottom"),T(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),R={thickness:v,friction:w,restitution:M},j=[];"lane"===t?j.push(ka(`${b}-top`,s,c,a,c,R),ka(`${b}-bottom`,s,l,a,l,R),ka(`${b}-left`,s,c,s,l,{...R,thickness:Math.max(6,v-2)}),ka(`${b}-right`,a,c,a,l,{...R,thickness:Math.max(6,v)})):"funnel"===t?j.push(ka(`${b}-top`,s,c,a,y,R),ka(`${b}-bottom`,s,l,a,x,R),ka(`${b}-left`,s,c,s,l,{...R,thickness:Math.max(6,v-2)}),ka(`${b}-right`,a,y,a,x,{...R,thickness:Math.max(6,v)})):j.push(ka(`${b}-left-top`,s,c,C,y,R),ka(`${b}-left-bottom`,s,l,C,x,R),ka(`${b}-center-top`,C,y,O,y,R),ka(`${b}-center-bottom`,C,x,O,x,R),ka(`${b}-right-top`,O,y,a,c,R),ka(`${b}-right-bottom`,O,x,a,l,R),ka(`${b}-left`,s,c,s,l,{...R,thickness:Math.max(6,v-2)}),ka(`${b}-right`,a,c,a,l,{...R,thickness:Math.max(6,v)}));const F=e.membraneDampingScale??.5,L=s,z="bowtie"===t?C:a,D=Math.max(1,z-L),_=(e.membranes??[]).map(e=>{const t=L+xe(e.offset,0,1)*D,n=e.width??18+18*e.cost,o=u-16,r=d+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),W=!1===e.includeMembraneRegions?[]:_.map(e=>Ea({id:e.id,label:e.label??e.id,description:e.description??`${e.label??e.id} is a permeable region. It taxes energy and damps velocity while bodies overlap it.`,x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??F,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:d,centerLeft:C,centerRight:O,pinchHeight:m,pinchTop:y,pinchBottom:x,stages:P,membranes:_,colliders:j,regionEffects:W,boundaryY:T}}function Sa(e,t,n){return"function"==typeof t?o=>({...n,...t(o),primitive:e}):{...n,...t,primitive:e}}function $a(e,t,n,o){return{id:e.id,label:e.label,description:e.description,kind:e.kind??t,shape:(r=e.x,i=e.y,s=e.width,a=e.height,{type:"aabb",x:r,y:i,width:s,height:a}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:n?Sa(n,e.attributes,o):e.attributes,onEnter:e.onEnter,onExit:e.onExit};var r,i,s,a}function Na(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...$a({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Ea(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=xe(e.cost,0,2);return{...$a(e,"membrane","membrane",{membraneCost:o}),damping:o*t,energyDelta:-o*n}}function Aa(e){return{...$a(e,"charge-gate","chargeGate"),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Ca(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...$a(e,"force-field","routeSurface"),force:t,damping:e.damping??.015}}function Oa(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...$a(e,"membrane","pressureField",{pressure:t}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function Ta(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...$a(e,"force-field","capacitatedSensor",{capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function Pa(e){return{...$a(e,"force-field","portal",{targetStage:e.targetStage}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function Ra(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...$a(e,"sink","absorb"),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function ja(e){return{...$a(e,"force-field","forceField"),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function Fa(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function La(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[ka(`${t}-top`,e.left,e.top,e.right,e.top,n),ka(`${t}-bottom`,e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(ka(`${t}-left`,e.left,e.top,e.left,e.bottom,n),ka(`${t}-right`,e.right,e.top,e.right,e.bottom,n)),o}function za(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=xe(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),d=xe(c,r.x0+l,r.x1-l),u=e.boundaryY(d,"top")+a,h=e.boundaryY(d,"bottom")-a;return{x:d,y:h<=u?e.midY:u+o()*Math.max(1,h-u)}}function Da(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function _a(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Wa(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function qa(e,t,n,o,r){return"function"==typeof o?o(e,t,n):Wa(e,o??r)}function Ga(e){const t=Number(e.toFixed(Of));return Object.is(t,-0)?0:t}function Ba(e){const t=(e??Af).map(e=>{const t=_a(e);if(null==t||t<0||t>1)throw new RangeError(`physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received ${String(e)}`);return Ga(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function Ya(e){if(Array.isArray(e)){if(e.length>Cf)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Cf} points`);return Array.from(new Set(e.map(_a).filter(e=>null!=e).map(Ga))).sort((e,t)=>e-t)}const t=e,n=_a(t.start),o=_a(t.end),r=_a(t.step);if(null==n||null==o||null==r||r<=0||o<n)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>Cf)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Cf} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;e<i;e+=1){const t=n+e*r;if(t>o+a)break;s.push(Ga(Math.min(t,o)))}if((!s.length||Math.abs(s[s.length-1]-o)>a)&&s.push(Ga(o)),s.length>Cf)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Cf} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}function Va(e,t,n,o){const r=e.flatMap((e,r)=>{const i=_a(qa(e,r,t,n,"time")),s=_a(qa(e,r,t,o,"value"));return null==i||null==s?[]:[{time:Ga(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function Ha(e,t){let n=0,o=e.length;for(;n<o;){const r=n+o>>>1;e[r].time<t?n=r+1:o=r}return n}function Ua(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(t<r.time)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=Ha(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];if("step"===n||!a||a.time===c.time)return c.value;const l=(t-c.time)/(a.time-c.time);return c.value+(a.value-c.value)*l}function Xa(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);if(o===r)return e[o];const i=n-o;return e[o]+(e[r]-e[o])*i}function Ka(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=Ba(e.quantiles),r=Ya(e.sampleAt),i=e.runs.map(t=>Va(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>Ua(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?Xa(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?Xa(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Ja(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function Za(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=_a(t);if(null==n||n<0||n>1)throw new RangeError(`comparePhysicsTrace quantile selectors must be from 0 to 1; received ${String(t)}`);const o=Ga(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw new Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function Qa(e,t,n){return e<t?"below":e>n?"above":"inside"}function ec(e,t){const n=Math.max(0,t.time-e.time);if(!(n>0)||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(e<0&&t>0||e>0&&t<0)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,d=0;for(let o=0;o<a.length-1;o+=1){const r=a[o],i=a[o+1];if(!(i>r))continue;const s=(r+i)/2,u=(i-r)*n,h=Qa(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=u:"above"===h?d+=u:l+=u}return{below:c,inside:l,above:d,observed:n}}function tc(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=Va(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??Ja(t,"lower"),a=n.upper??Ja(t,"upper"),c=t.points.map(e=>{const t=Ua(i,e.time,o,r),n=Za(e,s),c=Za(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError(`comparePhysicsTrace lower band exceeds upper band at time ${e.time}`);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Qa(t,n,c)}});let l=0,d=0,u=0,h=0,p=null,f=0,m=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?d+=1:"above"===e.status&&(u+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,p=e.time),n>f&&(f=n,m=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;e<c.length-1;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=ec(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w),k=l+d+u;return{points:c,sampleCount:c.length,observedSamples:k,belowSamples:l,insideSamples:d,aboveSamples:u,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:p,peakDeficit:f,peakDeficitAt:m}}function nc(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function oc(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function rc(e){return!!oc(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&oc(e.visitsByStage)&&oc(e.firstEnteredAt)&&oc(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function ic(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function sc(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}function ac(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,ic(e)]))}}function cc(e,t,n={}){if("region-enter"!==t.type)return e;const o=sc(t,n),r=e.stages.findIndex(e=>e.id===o);if(r<0)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=nc(e.entities,i),a=rc(s)?s:ic(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),d=Number(t.observation.timestamp),u=Number.isFinite(d)?d:0,h=nc(a.visitsByStage,o),p="number"==typeof h&&Number.isFinite(h)?h:0,f={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:p+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:u}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:u},regressionCount:c>=0&&r<c?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:f}}}function lc(e){const t=e.bodyIds.map(t=>{const n=nc(e.entities,t);return rc(n)?n:ic(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=nc(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function dc(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function uc(e,t){return Boolean(t?.some(t=>Object.is(e,t)))}function hc(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=dc(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!uc(n,t.oneOf)||t.notOneOf&&uc(n,t.notOneOf))}function pc(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function fc(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&String(n).length>0)return String(n)}else if(t){const n=dc(e.datum,t),o=dc(e,t),r=n??o;if(null!=r&&String(r).length>0)return String(r)}return e.id}function mc(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=n-o;return e[o]+(e[r]-e[o])*i}function gc(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(p)}function n(){U+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:p,work:e.total,queuedAt:e.queuedAt}}function r(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:p,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:v.size})}function i(e,t,o,i){const s={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,s),E.delete(e.id),N.set(e.id,t.jobId),z+=1,D+=t.work,n(),r(e,s,o),s}function s(e){if(v.size>=x||0===k.size)return;const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(v.size>=x)break;const t=$.get(n.jobId);t&&I.has(n.jobId)?(k.delete(n.jobId),E.delete(n.bodyId),i(t,n,e,n.sequence)):k.delete(n.jobId)}}function a(){let e=0;for(const t of v.values())e+=t.remaining;return e}function c(){let e=0;for(const t of k.values())e+=t.work;return e}function l(){Y=Math.max(Y,v.size),V=Math.max(V,a())}function d(){const e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);O=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);T=new Map(t.map((e,t)=>[e.bodyId,t])),P=e.length}function u(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&A.push(e);const t=j-b;for(;A.length>0&&A[0].end<t;)A.shift()}function h(){const e=j-b,t=Math.max(0,Math.min(b,j-(F??j)));let n=0,o=0,r=0,i=0,s=0;for(const t of A){if(t.end<e)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;if(a<=0||t.start>=e)s+=t.processedWork;else{const n=Math.max(0,t.end-e);s+=t.processedWork*Math.min(1,n/a)}}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&f>0?Math.max(0,Math.min(1,s/(f*t))):0,pressure:f>0?a/f:0}}const p=e.regionId,f=Math.max(0,e.unitsPerSecond),m=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):Number.POSITIVE_INFINITY,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,N=/* @__PURE__ */new Map,E=/* @__PURE__ */new Map,A=[];let C=0,O=/* @__PURE__ */new Map,T=/* @__PURE__ */new Map,P=0,R=0,j=0,F=null,L=0,z=0,D=0,_=0,W=0,q=0,G=0,B=0,Y=0,V=0,H=0,U=0,X=-1,K=!1;return{id:e.id??`capacity-queue:${p}`,continuous:!1!==e.continuous,tick:r=>{const a=r.controls.readBodies(),c=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(const n of a){if(c.set(n.id,n),!t(n.id,r.getRegionState))continue;if(!hc(n,e.bodyFilter))continue;const o=fc(n,e.jobKey),i=h.get(o)??[];i.push(n),h.set(o,i)}const m=Number.isFinite(r.dt)?Math.max(0,r.dt):0;if(!K){const e=Number.isFinite(r.elapsed)?Math.max(0,r.elapsed):m;j=Math.max(0,e-m),K=!0}const g=j,y=g+m;j=y,F=null==F?g:Math.min(F,g);const b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},A=/* @__PURE__ */new Map;for(const[e,t]of h){const n=I.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];A.set(e,o),$.set(e,o)}for(const[t,i]of I){if(A.has(t))continue;const s=v.get(t),a=c.get(i.bodyId)??$.get(t);if(s){v.delete(t),N.delete(s.bodyId),G+=1,B+=s.remaining,n();const c={...o(s),abandonedAt:j,remainingWork:s.remaining,queueSeconds:Math.max(0,j-s.queuedAt)};a&&e.onAbandoned?.(a,c),r.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:p,work:s.total,remainingWork:s.remaining,jobId:t,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:j,queueSeconds:c.queueSeconds,queueDepth:v.size})}k.delete(t),E.delete(i.bodyId),I.delete(t),$.delete(t)}for(const[t,o]of A){if(I.has(t))continue;const s=(S.get(t)??0)+1;S.set(t,s);const a=pc(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${p}:${t}:${s}`,visit:s,regionId:p,work:a,queuedAt:j};I.set(t,c),L+=1,b.arrivals+=1,b.arrivalWork+=a;const l=C++;if(v.size<x)i(o,c,r,l);else{const i={...c,blockedAt:j,sequence:l};k.set(t,i),E.set(o.id,t),q+=1,n(),e.onBlocked?.(o,i),r.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:p,work:a,jobId:t,visitId:c.visitId,visit:s,queuedAt:j,blockedAt:j,queueDepth:v.size,blockedDepth:k.size})}}s(r),l();const O=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);let T=f*m;for(const t of O){if(!(T>0))break;const i=Math.min(t.remaining,T);if(t.remaining-=i,T-=i,_+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),N.delete(t.bodyId),R+=1,W+=t.total,b.completions+=1,b.completedWork+=t.total;const s=Math.max(0,j-t.queuedAt);H+=s,n();const a=c.get(t.bodyId);if(!a)continue;r.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);const l={...o(t),completedAt:j,queueSeconds:s};e.onProcessed?.(a,l),r.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:p,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:j,queueSeconds:s,queueDepth:v.size})}s(r),l(),d(),u(b);const P=Math.floor(j/w);P!==X&&(X=P,n())},getSnapshot:()=>{const e=a(),t=c(),n=v.size,o=Array.from(v.values()).map(e=>Math.max(0,j-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:p,queueDepth:n,processedCount:R,unitsPerSecond:f,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:k.size,blockedWork:t,arrivalCount:L,admittedCount:z,admittedWork:D,processedWork:_,completedWork:W,blockedCount:q,abandonedCount:G,abandonedWork:B,peakQueueDepth:Y,peakRemainingWork:V,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:mc(o,.5),p95Seconds:mc(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:R>0?H/R:0,window:h(),simulatedAt:j,metricRevision:U}},bodyForce:e=>{if("none"===m)return null;const t=N.get(e.body.id),n=E.get(e.body.id),o=t?v.get(t):void 0,r=n?k.get(n):void 0;if(!o&&!r)return null;const i=o?O.get(e.body.id):T.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;e<a.length;e+=1)if(a[e].id===p){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}if(!s)return{x:8*-Math.sign(e.body.vx||1),y:0};const c=r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*g),l=s.y-(i-((r?k.size:P)-1)/2)*g/Math.max(1,Math.sqrt(r?k.size:P)),d=c-e.body.x,u=l-e.body.y;return{x:d*y,y:u*y*.85}}}}function yc(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function xc(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=yc(n,o.bodyForce(e)));return n}}}function bc(e){const t=/* @__PURE__ */new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??`portal:${e.fromRegionId}`,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function wc(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=/* @__PURE__ */new Map,d=0,u=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:d};return o.set(e,s),r.set(i.id,s),u+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),u+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{d=Math.max(d,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),u+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:d,metricRevision:u}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=o?o.x+(c.x??0):t.home.x,d=o?o.y+(c.y??0):t.home.y,u=n?i:s;return{x:(a-e.body.x)*u,y:(d-e.body.y)*u}}const d=o.get(e.body.id);if(!d||a<=0)return null;const u=l.get(d.resourceBodyId);return u?{x:(u.x-e.body.x)*a,y:(u.y-e.body.y)*a}:null}}}function Mc(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):dc(e.datum,t.deadlineAccessor)??dc(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function vc(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=/* @__PURE__ */new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!hc(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=Mc(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"===a.state&&r>=a.deadlineAt&&t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function kc(e){const t=/* @__PURE__ */new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??`dependency-gate:${e.regionId}`,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),d=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&hc(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=d.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)d.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function Ic(e,t,n,o){const r=e=>n.get(e)??e;return"id"===e?r(t):/^(?:xlink:?)?href$/i.test(e)?"#"===t[0]?`#${r(t.slice(1))}`:t:/^(?:aria-(?:labelledby|describedby|controls|owns|activedescendant|details|errormessage)|for|htmlFor|list|form|headers|itemref|popovertarget)$/.test(e)?t.replace(/\S+/g,r):/^(?:fill|stroke|clip-?path|mask|filter|marker-?(?:start|mid|end)|style|cursor)$/i.test(e)?o?o(t,n):t.replace(/url\(\s*(["']?)#([^\s"')]+)\1\s*\)/g,(e,t,n)=>{const o=r(n);return o===n?e:`url(#${o})`}):t}function Sc({children:e}){const t=(0,Pf.useId)().replace(/[^\w-]/g,"_"),n=/* @__PURE__ */new Map,o=(e,t=!1)=>{const i={...e};for(const[e,s]of Object.entries(i))i[e]="children"!==e||t?"style"===e&&!t&&s&&"object"==typeof s?o(s,!0):"string"==typeof s?Ic(t?"style":e,s,n):s:r(s);return i},r=(e,i=!1)=>"object"!=typeof e?e:Pf.Children.map(e,e=>(0,Pf.isValidElement)(e)?i?("string"==typeof e.props.id&&n.set(e.props.id,`${t}-${e.props.id}`),r(e.props.children,!0),e):(0,Pf.cloneElement)(e,o(e.props)):e);return r(e,!0),r(e)}function $c(e){return e.length*Ff}function Nc(e,t){const n=e.trim();if(n.length<=t)return n;if(t<=1)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&o.length<=t?o:t<=3?n.slice(0,t).toUpperCase():`${n.slice(0,Math.max(1,t-2))}..`}function Ec(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Ff)),r="compact"===n?Nc(e,o):"full"===n||$c(e)<=t?e:Nc(e,o);return{text:r,textLength:$c(r)>t?Math.max(4,t):void 0}}function Ac(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function Cc(e){if(null!=e.capacity){const t=null!=e.queueDepth?` · q ${e.queueDepth}`:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?String(e.capacity):e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function Oc(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:d,left:u,right:h,topY:p,bottomY:f,midY:m,stages:g,groups:y=[]}=e,x=f-p;return(0,Tf.createElement)(Sc,null,
110
+ /* @__PURE__ */(0,Ef.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return e.line?/* @__PURE__ */ /* @__PURE__ */(0,Ef.jsx)("rect",{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}):/* @__PURE__ */ /* @__PURE__ */(0,Ef.jsx)("rect",{width:t,height:t,rx:2,fill:n})}function Js(e){const t=e,n=[ta(t,["datum","data"]),ta(t,["datum"]),ta(t,["data","data"]),ta(t,["data"]),ta(t,["node","datum","data"]),ta(t,["node","datum"]),e];for(const e of n){if(!na(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function Zs(e,t={}){const n=Js(e);if(!n)return[];const o=new Set(Of);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:ea(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):Qs(i)}),r.length>=(t.maxEntries??8)))break;return r}function Qs(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return`${e.length} items`;if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function ea(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function ta(e,t){let n=e;for(const e of t){if(!na(n))return;n=n[e]}return n}function na(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function oa(e,t){const n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,/* @__PURE__ */new Set);for(const e of t)n.has(e.source)||n.set(e.source,/* @__PURE__ */new Set),n.has(e.target)||n.set(e.target,/* @__PURE__ */new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function ra(e,t){const n={};for(const t of e)s(n,t.id,0);for(const e of t)s(n,e.source,(i(n,e.source)??0)+1),s(n,e.target,(i(n,e.target)??0)+1);return n}function ia(e,t){const n={};s(n,t,0);const o=[t];let i=0;for(;i<o.length;){const t=o[i];i+=1;for(const i of e.get(t)||[])r(n,i)||(s(n,i,n[t]+1),o.push(i))}return n}function sa(e,t,n,o){if(n===o)return n?[n]:[];const i=oa(e,t),s=a();s[n]=null;const c=[n];let l=0;for(;l<c.length;){const e=c[l];if(l+=1,e===o)break;for(const t of i.get(e)||[])r(s,t)||(s[t]=e,c.push(t))}if(!r(s,o))return[];const d=[];let u=o;for(;null!=u;)d.unshift(u),u=s[u];return d}function aa(e,t,n,o=1){const r=oa(e,t);if(!r.has(n))/* @__PURE__ */return new Set;const i=ia(r,n),s=/* @__PURE__ */new Set;for(const e of Object.keys(i))i[e]<=o&&s.add(e);return s}function ca(e,t){const n=oa(e,t),o={};for(const t of e)s(o,t.id,0);for(const t of e.map(e=>e.id)){const r=[],c=a(),l=a(),d=a();for(const t of e)c[t.id]=[],l[t.id]=0,d[t.id]=-1;l[t]=1,d[t]=0;const u=[t];let h=0;for(;h<u.length;){const e=u[h];h+=1,r.push(e);for(const t of n.get(e)||[])d[t]<0&&(d[t]=d[e]+1,u.push(t)),d[t]===d[e]+1&&(l[t]+=l[e],c[t].push(e))}const p=a();for(const t of e)p[t.id]=0;for(;r.length;){const e=r.pop();for(const t of c[e])p[t]+=l[t]/l[e]*(1+p[e]);e!==t&&s(o,e,(i(o,e)??0)+p[e])}}for(const e of Object.keys(o))s(o,e,o[e]/2);return o}function la(e,t){const n=oa(e,t),o={};for(const t of e){const e=ia(n,t.id);let r=0,i=0;for(const t of Object.keys(e))r+=e[t],i+=1;s(o,t.id,r>0?(i-1)/r:0)}return o}function da(e,t){const n=oa(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(r<2){s(o,t.id,0);continue}let i=0;for(let t=0;t<e.length;t+=1)for(let o=t+1;o<e.length;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);s(o,t.id,2*i/(r*(r-1)))}return o}function ua(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const o of Object.keys(e))s(n,o,t>0?e[o]/t:0);return n}function ha(e,t,n,o={}){const r=oa(e,t),s=a();for(const t of e)s[t.id]=ia(r,t.id);let c=o.minHops??4,l=o.startThreshold??.08;const d=o.maxThreshold??.2,u=/* @__PURE__ */new Set;let h=0;for(;0===u.size&&h<40;){for(let t=0;t<e.length;t+=1)for(let o=t+1;o<e.length;o+=1){const r=e[t].id,a=e[o].id,d=i(n,r),h=i(n,a);if(!d||!h)continue;const p=void 0===s[r][a]?1/0:s[r][a],f=d.x-h.x,m=d.y-h.y,g=Math.sqrt(f*f+m*m);p>=c&&g<l&&(u.add(r),u.add(a))}0===u.size&&(l+=.02,l>d&&(l=o.startThreshold??.08,c=Math.max(2,c-1))),h+=1}return{problemIds:u,threshold:l,minHops:c}}async function pa(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260;if(!ce()||!ae(o,e.length,t.length,c,i))return Ye(e,t,{...a,nodeRadius:s});const l={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{const{runForceLayoutWorker:e}=await Promise.resolve().then(()=>(Ru(),Tu));return(await e(l,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return Ye(e,t,{...a,nodeRadius:s})}}function fa(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=e.reduce((e,t)=>Math.max(e,t[s]),1);return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),d=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:d,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function ma(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],d=e.x+e.width/2,u=e.y+e.height/2,h=(e,t,o,r,i)=>{l.push({id:`${n}-${e}`,shape:{type:"aabb",x:t,y:o,width:r,height:i}})};return o&&h("floor",d,e.y+e.height+c/2,e.width+2*a,c),r&&h("ceiling",d,e.y-c/2,e.width+2*a,c),i&&h("left-wall",e.x-a/2,u,a,e.height+2*c),s&&h("right-wall",e.x+e.width+a/2,u,a,e.height+2*c),l}function ga(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:d=!0,closedBefore:u,lidY:h=s,lidThickness:p=Math.max(2,c)}=e,f=[],m=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(d||l)for(let e=l?0:1;e<=y;e+=1){if(!d&&e>0&&e<n)continue;const s=i(o+e*r);f.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:m,width:c,height:g}})}if(null!=u)for(let e=0;e<n;e+=1){const n=o+e*r,s=n+r;if(s>=u)continue;const a=i(n),l=i(s);f.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:p}})}return f}function ya(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function xa(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function ba(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=ya(e,n),r=xa(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function wa(e,t){return(t??Object.keys(e)).map(t=>ya(e,t)).filter(xa).map(e=>({label:e.label??e.id,value:e.count}))}function Ma(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?ya(s,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),d=e.completion?.threshold,u="threshold"===i?Number.isFinite(d)&&Number(d)>=0?Number(d):c:void 0,h=t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(u??c):0===o.length);return{id:e.id,label:e.label??e.id,mode:i,complete:h,absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:u,missing:o}})}function va(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function Ia(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function ka(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),d=(c+l)/2,u=Math.max(1,l-c),h=xe(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,m=xe(u*h+f,.06*u,.5*u),g=m/2,y=d-g,x=d+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,I=e.stages;if(!I.length)throw new Error("processStageLayout requires at least one stage");const k=xe(e.centerStageIndex??Math.floor(I.length/2),0,I.length-1),S=va(I),$=a-s;let N=s;const E=I.map((e,t)=>{const n=(e.share??1)/S*$,o=N,r=t===I.length-1?a:N+n;return N=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:o,x1:r,x:(o+r)/2,width:r-o,y:d,height:u}}),A=E[k],C=A.x0,O=A.x1,T=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=xe((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=C){const t=xe((e-s)/Math.max(1,C-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=O)return"top"===n?y:x;const o=xe((e-O)/Math.max(1,a-O),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},P=E.map(e=>{const t=Math.min(T(e.x0,"top"),T(e.x1,"top")),n=Math.max(T(e.x0,"bottom"),T(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),R={thickness:v,friction:w,restitution:M},j=[];"lane"===t?j.push(Ia(`${b}-top`,s,c,a,c,R),Ia(`${b}-bottom`,s,l,a,l,R),Ia(`${b}-left`,s,c,s,l,{...R,thickness:Math.max(6,v-2)}),Ia(`${b}-right`,a,c,a,l,{...R,thickness:Math.max(6,v)})):"funnel"===t?j.push(Ia(`${b}-top`,s,c,a,y,R),Ia(`${b}-bottom`,s,l,a,x,R),Ia(`${b}-left`,s,c,s,l,{...R,thickness:Math.max(6,v-2)}),Ia(`${b}-right`,a,y,a,x,{...R,thickness:Math.max(6,v)})):j.push(Ia(`${b}-left-top`,s,c,C,y,R),Ia(`${b}-left-bottom`,s,l,C,x,R),Ia(`${b}-center-top`,C,y,O,y,R),Ia(`${b}-center-bottom`,C,x,O,x,R),Ia(`${b}-right-top`,O,y,a,c,R),Ia(`${b}-right-bottom`,O,x,a,l,R),Ia(`${b}-left`,s,c,s,l,{...R,thickness:Math.max(6,v-2)}),Ia(`${b}-right`,a,c,a,l,{...R,thickness:Math.max(6,v)}));const F=e.membraneDampingScale??.5,L=s,z="bowtie"===t?C:a,D=Math.max(1,z-L),_=(e.membranes??[]).map(e=>{const t=L+xe(e.offset,0,1)*D,n=e.width??18+18*e.cost,o=u-16,r=d+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),W=!1===e.includeMembraneRegions?[]:_.map(e=>Ea({id:e.id,label:e.label??e.id,description:e.description??`${e.label??e.id} is a permeable region. It taxes energy and damps velocity while bodies overlap it.`,x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??F,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:d,centerLeft:C,centerRight:O,pinchHeight:m,pinchTop:y,pinchBottom:x,stages:P,membranes:_,colliders:j,regionEffects:W,boundaryY:T}}function Sa(e,t,n){return"function"==typeof t?o=>({...n,...t(o),primitive:e}):{...n,...t,primitive:e}}function $a(e,t,n,o){return{id:e.id,label:e.label,description:e.description,kind:e.kind??t,shape:(r=e.x,i=e.y,s=e.width,a=e.height,{type:"aabb",x:r,y:i,width:s,height:a}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:n?Sa(n,e.attributes,o):e.attributes,onEnter:e.onEnter,onExit:e.onExit};var r,i,s,a}function Na(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...$a({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Ea(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=xe(e.cost,0,2);return{...$a(e,"membrane","membrane",{membraneCost:o}),damping:o*t,energyDelta:-o*n}}function Aa(e){return{...$a(e,"charge-gate","chargeGate"),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Ca(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...$a(e,"force-field","routeSurface"),force:t,damping:e.damping??.015}}function Oa(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...$a(e,"membrane","pressureField",{pressure:t}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function Ta(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...$a(e,"force-field","capacitatedSensor",{capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function Pa(e){return{...$a(e,"force-field","portal",{targetStage:e.targetStage}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function Ra(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...$a(e,"sink","absorb"),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function ja(e){return{...$a(e,"force-field","forceField"),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function Fa(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function La(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Ia(`${t}-top`,e.left,e.top,e.right,e.top,n),Ia(`${t}-bottom`,e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Ia(`${t}-left`,e.left,e.top,e.left,e.bottom,n),Ia(`${t}-right`,e.right,e.top,e.right,e.bottom,n)),o}function za(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=xe(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),d=xe(c,r.x0+l,r.x1-l),u=e.boundaryY(d,"top")+a,h=e.boundaryY(d,"bottom")-a;return{x:d,y:h<=u?e.midY:u+o()*Math.max(1,h-u)}}function Da(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function _a(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Wa(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function qa(e,t,n,o,r){return"function"==typeof o?o(e,t,n):Wa(e,o??r)}function Ba(e){const t=Number(e.toFixed(Rf));return Object.is(t,-0)?0:t}function Ga(e){const t=(e??Tf).map(e=>{const t=_a(e);if(null==t||t<0||t>1)throw new RangeError(`physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received ${String(e)}`);return Ba(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function Ya(e){if(Array.isArray(e)){if(e.length>Pf)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Pf} points`);return Array.from(new Set(e.map(_a).filter(e=>null!=e).map(Ba))).sort((e,t)=>e-t)}const t=e,n=_a(t.start),o=_a(t.end),r=_a(t.step);if(null==n||null==o||null==r||r<=0||o<n)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>Pf)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Pf} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;e<i;e+=1){const t=n+e*r;if(t>o+a)break;s.push(Ba(Math.min(t,o)))}if((!s.length||Math.abs(s[s.length-1]-o)>a)&&s.push(Ba(o)),s.length>Pf)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Pf} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}function Va(e,t,n,o){const r=e.flatMap((e,r)=>{const i=_a(qa(e,r,t,n,"time")),s=_a(qa(e,r,t,o,"value"));return null==i||null==s?[]:[{time:Ba(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function Ha(e,t){let n=0,o=e.length;for(;n<o;){const r=n+o>>>1;e[r].time<t?n=r+1:o=r}return n}function Ua(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(t<r.time)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=Ha(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];if("step"===n||!a||a.time===c.time)return c.value;const l=(t-c.time)/(a.time-c.time);return c.value+(a.value-c.value)*l}function Xa(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);if(o===r)return e[o];const i=n-o;return e[o]+(e[r]-e[o])*i}function Ka(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=Ga(e.quantiles),r=Ya(e.sampleAt),i=e.runs.map(t=>Va(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>Ua(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?Xa(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?Xa(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Ja(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function Za(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=_a(t);if(null==n||n<0||n>1)throw new RangeError(`comparePhysicsTrace quantile selectors must be from 0 to 1; received ${String(t)}`);const o=Ba(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw new Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function Qa(e,t,n){return e<t?"below":e>n?"above":"inside"}function ec(e,t){const n=Math.max(0,t.time-e.time);if(!(n>0)||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(e<0&&t>0||e>0&&t<0)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,d=0;for(let o=0;o<a.length-1;o+=1){const r=a[o],i=a[o+1];if(!(i>r))continue;const s=(r+i)/2,u=(i-r)*n,h=Qa(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=u:"above"===h?d+=u:l+=u}return{below:c,inside:l,above:d,observed:n}}function tc(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=Va(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??Ja(t,"lower"),a=n.upper??Ja(t,"upper"),c=t.points.map(e=>{const t=Ua(i,e.time,o,r),n=Za(e,s),c=Za(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError(`comparePhysicsTrace lower band exceeds upper band at time ${e.time}`);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Qa(t,n,c)}});let l=0,d=0,u=0,h=0,p=null,f=0,m=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?d+=1:"above"===e.status&&(u+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,p=e.time),n>f&&(f=n,m=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;e<c.length-1;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=ec(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w),I=l+d+u;return{points:c,sampleCount:c.length,observedSamples:I,belowSamples:l,insideSamples:d,aboveSamples:u,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:p,peakDeficit:f,peakDeficitAt:m}}function nc(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function oc(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function rc(e){return!!oc(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&oc(e.visitsByStage)&&oc(e.firstEnteredAt)&&oc(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function ic(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function sc(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}function ac(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,ic(e)]))}}function cc(e,t,n={}){if("region-enter"!==t.type)return e;const o=sc(t,n),r=e.stages.findIndex(e=>e.id===o);if(r<0)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=nc(e.entities,i),a=rc(s)?s:ic(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),d=Number(t.observation.timestamp),u=Number.isFinite(d)?d:0,h=nc(a.visitsByStage,o),p="number"==typeof h&&Number.isFinite(h)?h:0,f={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:p+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:u}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:u},regressionCount:c>=0&&r<c?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:f}}}function lc(e){const t=e.bodyIds.map(t=>{const n=nc(e.entities,t);return rc(n)?n:ic(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=nc(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function dc(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function uc(e,t){return Boolean(t?.some(t=>Object.is(e,t)))}function hc(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=dc(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!uc(n,t.oneOf)||t.notOneOf&&uc(n,t.notOneOf))}function pc(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function fc(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&String(n).length>0)return String(n)}else if(t){const n=dc(e.datum,t),o=dc(e,t),r=n??o;if(null!=r&&String(r).length>0)return String(r)}return e.id}function mc(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=n-o;return e[o]+(e[r]-e[o])*i}function gc(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(p)}function n(){U+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:p,work:e.total,queuedAt:e.queuedAt}}function r(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:p,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:v.size})}function i(e,t,o,i){const s={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,s),E.delete(e.id),N.set(e.id,t.jobId),z+=1,D+=t.work,n(),r(e,s,o),s}function s(e){if(v.size>=x||0===I.size)return;const t=Array.from(I.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(v.size>=x)break;const t=$.get(n.jobId);t&&k.has(n.jobId)?(I.delete(n.jobId),E.delete(n.bodyId),i(t,n,e,n.sequence)):I.delete(n.jobId)}}function a(){let e=0;for(const t of v.values())e+=t.remaining;return e}function c(){let e=0;for(const t of I.values())e+=t.work;return e}function l(){Y=Math.max(Y,v.size),V=Math.max(V,a())}function d(){const e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);O=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(I.values()).sort((e,t)=>e.sequence-t.sequence);T=new Map(t.map((e,t)=>[e.bodyId,t])),P=e.length}function u(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&A.push(e);const t=j-b;for(;A.length>0&&A[0].end<t;)A.shift()}function h(){const e=j-b,t=Math.max(0,Math.min(b,j-(F??j)));let n=0,o=0,r=0,i=0,s=0;for(const t of A){if(t.end<e)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;if(a<=0||t.start>=e)s+=t.processedWork;else{const n=Math.max(0,t.end-e);s+=t.processedWork*Math.min(1,n/a)}}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&f>0?Math.max(0,Math.min(1,s/(f*t))):0,pressure:f>0?a/f:0}}const p=e.regionId,f=Math.max(0,e.unitsPerSecond),m=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):Number.POSITIVE_INFINITY,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,N=/* @__PURE__ */new Map,E=/* @__PURE__ */new Map,A=[];let C=0,O=/* @__PURE__ */new Map,T=/* @__PURE__ */new Map,P=0,R=0,j=0,F=null,L=0,z=0,D=0,_=0,W=0,q=0,B=0,G=0,Y=0,V=0,H=0,U=0,X=-1,K=!1;return{id:e.id??`capacity-queue:${p}`,continuous:!1!==e.continuous,tick:r=>{const a=r.controls.readBodies(),c=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(const n of a){if(c.set(n.id,n),!t(n.id,r.getRegionState))continue;if(!hc(n,e.bodyFilter))continue;const o=fc(n,e.jobKey),i=h.get(o)??[];i.push(n),h.set(o,i)}const m=Number.isFinite(r.dt)?Math.max(0,r.dt):0;if(!K){const e=Number.isFinite(r.elapsed)?Math.max(0,r.elapsed):m;j=Math.max(0,e-m),K=!0}const g=j,y=g+m;j=y,F=null==F?g:Math.min(F,g);const b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},A=/* @__PURE__ */new Map;for(const[e,t]of h){const n=k.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];A.set(e,o),$.set(e,o)}for(const[t,i]of k){if(A.has(t))continue;const s=v.get(t),a=c.get(i.bodyId)??$.get(t);if(s){v.delete(t),N.delete(s.bodyId),B+=1,G+=s.remaining,n();const c={...o(s),abandonedAt:j,remainingWork:s.remaining,queueSeconds:Math.max(0,j-s.queuedAt)};a&&e.onAbandoned?.(a,c),r.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:p,work:s.total,remainingWork:s.remaining,jobId:t,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:j,queueSeconds:c.queueSeconds,queueDepth:v.size})}I.delete(t),E.delete(i.bodyId),k.delete(t),$.delete(t)}for(const[t,o]of A){if(k.has(t))continue;const s=(S.get(t)??0)+1;S.set(t,s);const a=pc(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${p}:${t}:${s}`,visit:s,regionId:p,work:a,queuedAt:j};k.set(t,c),L+=1,b.arrivals+=1,b.arrivalWork+=a;const l=C++;if(v.size<x)i(o,c,r,l);else{const i={...c,blockedAt:j,sequence:l};I.set(t,i),E.set(o.id,t),q+=1,n(),e.onBlocked?.(o,i),r.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:p,work:a,jobId:t,visitId:c.visitId,visit:s,queuedAt:j,blockedAt:j,queueDepth:v.size,blockedDepth:I.size})}}s(r),l();const O=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);let T=f*m;for(const t of O){if(!(T>0))break;const i=Math.min(t.remaining,T);if(t.remaining-=i,T-=i,_+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),N.delete(t.bodyId),R+=1,W+=t.total,b.completions+=1,b.completedWork+=t.total;const s=Math.max(0,j-t.queuedAt);H+=s,n();const a=c.get(t.bodyId);if(!a)continue;r.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);const l={...o(t),completedAt:j,queueSeconds:s};e.onProcessed?.(a,l),r.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:p,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:j,queueSeconds:s,queueDepth:v.size})}s(r),l(),d(),u(b);const P=Math.floor(j/w);P!==X&&(X=P,n())},getSnapshot:()=>{const e=a(),t=c(),n=v.size,o=Array.from(v.values()).map(e=>Math.max(0,j-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:p,queueDepth:n,processedCount:R,unitsPerSecond:f,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:I.size,blockedWork:t,arrivalCount:L,admittedCount:z,admittedWork:D,processedWork:_,completedWork:W,blockedCount:q,abandonedCount:B,abandonedWork:G,peakQueueDepth:Y,peakRemainingWork:V,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:mc(o,.5),p95Seconds:mc(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:R>0?H/R:0,window:h(),simulatedAt:j,metricRevision:U}},bodyForce:e=>{if("none"===m)return null;const t=N.get(e.body.id),n=E.get(e.body.id),o=t?v.get(t):void 0,r=n?I.get(n):void 0;if(!o&&!r)return null;const i=o?O.get(e.body.id):T.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;e<a.length;e+=1)if(a[e].id===p){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}if(!s)return{x:8*-Math.sign(e.body.vx||1),y:0};const c=r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*g),l=s.y-(i-((r?I.size:P)-1)/2)*g/Math.max(1,Math.sqrt(r?I.size:P)),d=c-e.body.x,u=l-e.body.y;return{x:d*y,y:u*y*.85}}}}function yc(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function xc(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=yc(n,o.bodyForce(e)));return n}}}function bc(e){const t=/* @__PURE__ */new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??`portal:${e.fromRegionId}`,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function wc(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=/* @__PURE__ */new Map,d=0,u=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:d};return o.set(e,s),r.set(i.id,s),u+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),u+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{d=Math.max(d,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),u+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:d,metricRevision:u}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=o?o.x+(c.x??0):t.home.x,d=o?o.y+(c.y??0):t.home.y,u=n?i:s;return{x:(a-e.body.x)*u,y:(d-e.body.y)*u}}const d=o.get(e.body.id);if(!d||a<=0)return null;const u=l.get(d.resourceBodyId);return u?{x:(u.x-e.body.x)*a,y:(u.y-e.body.y)*a}:null}}}function Mc(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):dc(e.datum,t.deadlineAccessor)??dc(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function vc(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=/* @__PURE__ */new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!hc(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=Mc(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"===a.state&&r>=a.deadlineAt&&t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function Ic(e){const t=/* @__PURE__ */new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??`dependency-gate:${e.regionId}`,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),d=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&hc(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=d.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)d.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function kc(e,t,n,o){const r=e=>n.get(e)??e;return"id"===e?r(t):/^(?:xlink:?)?href$/i.test(e)?"#"===t[0]?`#${r(t.slice(1))}`:t:/^(?:aria-(?:labelledby|describedby|controls|owns|activedescendant|details|errormessage)|for|htmlFor|list|form|headers|itemref|popovertarget)$/.test(e)?t.replace(/\S+/g,r):/^(?:fill|stroke|clip-?path|mask|filter|marker-?(?:start|mid|end)|style|cursor)$/i.test(e)?o?o(t,n):t.replace(/url\(\s*(["']?)#([^\s"')]+)\1\s*\)/g,(e,t,n)=>{const o=r(n);return o===n?e:`url(#${o})`}):t}function Sc({children:e}){const t=(0,Ff.useId)().replace(/[^\w-]/g,"_"),n=/* @__PURE__ */new Map,o=(e,t=!1)=>{const i={...e};for(const[e,s]of Object.entries(i))i[e]="children"!==e||t?"style"===e&&!t&&s&&"object"==typeof s?o(s,!0):"string"==typeof s?kc(t?"style":e,s,n):s:r(s);return i},r=(e,i=!1)=>"object"!=typeof e?e:Ff.Children.map(e,e=>(0,Ff.isValidElement)(e)?i?("string"==typeof e.props.id&&n.set(e.props.id,`${t}-${e.props.id}`),r(e.props.children,!0),e):(0,Ff.cloneElement)(e,o(e.props)):e);return r(e,!0),r(e)}function $c(e){return e.length*Df}function Nc(e,t){const n=e.trim();if(n.length<=t)return n;if(t<=1)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&o.length<=t?o:t<=3?n.slice(0,t).toUpperCase():`${n.slice(0,Math.max(1,t-2))}..`}function Ec(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Df)),r="compact"===n?Nc(e,o):"full"===n||$c(e)<=t?e:Nc(e,o);return{text:r,textLength:$c(r)>t?Math.max(4,t):void 0}}function Ac(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function Cc(e){if(null!=e.capacity){const t=null!=e.queueDepth?` · q ${e.queueDepth}`:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?String(e.capacity):e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function Oc(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:d,left:u,right:h,topY:p,bottomY:f,midY:m,stages:g,groups:y=[]}=e,x=f-p;return(0,jf.createElement)(Sc,null,
111
111
  /* @__PURE__ */
112
- /* @__PURE__ */(0,Rf.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:d,viewBox:`0 0 ${l} ${d}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[
112
+ /* @__PURE__ */(0,Lf.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:d,viewBox:`0 0 ${l} ${d}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[
113
113
  /* @__PURE__ */
114
- /* @__PURE__ */(0,Rf.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,Rf.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
114
+ /* @__PURE__ */(0,Lf.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,Lf.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
115
115
  /* @__PURE__ */
116
- /* @__PURE__ */(0,Rf.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),
116
+ /* @__PURE__ */(0,Lf.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),
117
117
  /* @__PURE__ */
118
- /* @__PURE__ */(0,Rf.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),
118
+ /* @__PURE__ */(0,Lf.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),
119
119
  /* @__PURE__ */
120
- /* @__PURE__ */(0,Rf.jsx)("rect",{x:0,y:0,width:l,height:d,fill:"url(#semiotic-process-floor)"}),
120
+ /* @__PURE__ */(0,Lf.jsx)("rect",{x:0,y:0,width:l,height:d,fill:"url(#semiotic-process-floor)"}),
121
121
  /* @__PURE__ */
122
- /* @__PURE__ */(0,Rf.jsx)("rect",{x:u-6,y:p-8,width:h-u+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?/* @__PURE__ */ /* @__PURE__ */(0,Rf.jsx)("line",{x1:u+8,x2:h-8,y1:m,y2:m,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=Ac(e),i=jf[n],c=Math.max(12,e.width-8),l=xe(c-8,22,88),u=Math.max(8,l-10),h=Ec(e.label,u,s),y="none"!==s&&c-8>=22,b=Cc(e),w=Ec(b,Math.max(16,c-10),"auto"),M=r&&!1!==e.showBadge&&c>=32,v=null!=e.count?`n=${e.count}${null!=e.processed?` done ${e.processed}`:""}`:"",k=Ec(v,Math.max(16,c-8),"auto"),I=Math.max(30,p-15),S=I-13;/* @__PURE__ */ /* @__PURE__ */
123
- return(0,Rf.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[
122
+ /* @__PURE__ */(0,Lf.jsx)("rect",{x:u-6,y:p-8,width:h-u+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?/* @__PURE__ */ /* @__PURE__ */(0,Lf.jsx)("line",{x1:u+8,x2:h-8,y1:m,y2:m,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=Ac(e),i=zf[n],c=Math.max(12,e.width-8),l=xe(c-8,22,88),u=Math.max(8,l-10),h=Ec(e.label,u,s),y="none"!==s&&c-8>=22,b=Cc(e),w=Ec(b,Math.max(16,c-10),"auto"),M=r&&!1!==e.showBadge&&c>=32,v=null!=e.count?`n=${e.count}${null!=e.processed?` done ${e.processed}`:""}`:"",I=Ec(v,Math.max(16,c-8),"auto"),k=Math.max(30,p-15),S=k-13;/* @__PURE__ */ /* @__PURE__ */
123
+ return(0,Lf.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[
124
124
  /* @__PURE__ */
125
- /* @__PURE__ */(0,Rf.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:c,height:x-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),t<g.length-1?/* @__PURE__ */ /* @__PURE__ */(0,Rf.jsx)("polygon",{points:`${e.x1-2},${m-7} ${e.x1+8},${m} ${e.x1-2},${m+7}`,fill:i.accent,opacity:.85}):null,y?/* @__PURE__ */ /* @__PURE__ */(0,Rf.jsxs)(Rf.Fragment,{children:[
125
+ /* @__PURE__ */(0,Lf.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:c,height:x-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),t<g.length-1?/* @__PURE__ */ /* @__PURE__ */(0,Lf.jsx)("polygon",{points:`${e.x1-2},${m-7} ${e.x1+8},${m} ${e.x1-2},${m+7}`,fill:i.accent,opacity:.85}):null,y?/* @__PURE__ */ /* @__PURE__ */(0,Lf.jsxs)(Lf.Fragment,{children:[
126
126
  /* @__PURE__ */
127
- /* @__PURE__ */(0,Rf.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:S,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),
127
+ /* @__PURE__ */(0,Lf.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:S,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),
128
128
  /* @__PURE__ */
129
- /* @__PURE__ */(0,Rf.jsxs)("text",{x:e.x,y:I,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:h.textLength,lengthAdjust:h.textLength?"spacingAndGlyphs":void 0,children:[
129
+ /* @__PURE__ */(0,Lf.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:h.textLength,lengthAdjust:h.textLength?"spacingAndGlyphs":void 0,children:[
130
130
  /* @__PURE__ */
131
- /* @__PURE__ */(0,Rf.jsx)("title",{children:e.label}),h.text]})]}):null,M?/* @__PURE__ */ /* @__PURE__ */(0,Rf.jsxs)("text",{x:e.x,y:p+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:w.textLength,lengthAdjust:w.textLength?"spacingAndGlyphs":void 0,children:[
131
+ /* @__PURE__ */(0,Lf.jsx)("title",{children:e.label}),h.text]})]}):null,M?/* @__PURE__ */ /* @__PURE__ */(0,Lf.jsxs)("text",{x:e.x,y:p+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:w.textLength,lengthAdjust:w.textLength?"spacingAndGlyphs":void 0,children:[
132
132
  /* @__PURE__ */
133
- /* @__PURE__ */(0,Rf.jsx)("title",{children:b}),w.text]}):null,o&&null!=e.count?/* @__PURE__ */ /* @__PURE__ */(0,Rf.jsxs)("text",{x:e.x,y:Math.min(d-8,f+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[
133
+ /* @__PURE__ */(0,Lf.jsx)("title",{children:b}),w.text]}):null,o&&null!=e.count?/* @__PURE__ */ /* @__PURE__ */(0,Lf.jsxs)("text",{x:e.x,y:Math.min(d-8,f+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:I.textLength,lengthAdjust:I.textLength?"spacingAndGlyphs":void 0,children:[
134
134
  /* @__PURE__ */
135
- /* @__PURE__ */(0,Rf.jsx)("title",{children:v}),k.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:`feature ${t+1}`,l=xe(Math.max(54,$c(e.label)+18,$c(c)+16),54,104),d=Ec(e.label,l-12,"auto"),u=Ec(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
136
- return(0,Rf.jsxs)("g",{"data-group":e.id,children:[
135
+ /* @__PURE__ */(0,Lf.jsx)("title",{children:v}),I.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:`feature ${t+1}`,l=xe(Math.max(54,$c(e.label)+18,$c(c)+16),54,104),d=Ec(e.label,l-12,"auto"),u=Ec(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
136
+ return(0,Lf.jsxs)("g",{"data-group":e.id,children:[
137
137
  /* @__PURE__ */
138
- /* @__PURE__ */(0,Rf.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),
138
+ /* @__PURE__ */(0,Lf.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),
139
139
  /* @__PURE__ */
140
- /* @__PURE__ */(0,Rf.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[
140
+ /* @__PURE__ */(0,Lf.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[
141
141
  /* @__PURE__ */
142
- /* @__PURE__ */(0,Rf.jsx)("title",{children:e.label}),d.text]}),
142
+ /* @__PURE__ */(0,Lf.jsx)("title",{children:e.label}),d.text]}),
143
143
  /* @__PURE__ */
144
- /* @__PURE__ */(0,Rf.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[
144
+ /* @__PURE__ */(0,Lf.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[
145
145
  /* @__PURE__ */
146
- /* @__PURE__ */(0,Rf.jsx)("title",{children:c}),u.text]})]},e.id)}):null]}))}function Tc(e){if(null==e){const e=Lf.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Pc(e){if("number"==typeof e){const t=Math.max(1,Math.round(e));return Array.from({length:t},(e,t)=>({id:`bin-${t}`,label:String(t)}))}return 0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??String(t)}))}function Rc(e){const[t,n]=e.size,o=e.flow??Lf.flow,r=Tc(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??Lf.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??Lf.chargeExtent),l=a*Math.max(0,e.projectionExtent??Lf.projectionExtent),d=a*Math.max(0,e.destinationExtent??Lf.destinationExtent),u=Math.max(0,a-c-d-l),h=Pc(e.destinations),p=("down"===o?s.width:s.height)/h.length,f="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),m=f(0,c),g=f(c,u),y=c+u,x=f(y,d),b=f(y+d,l),w=h.map((e,t)=>{const n=t*p,r=p*i,a=(p-r)/2;if("down"===o){const o=s.x+n+a;return{id:e.id,label:e.label,order:t,x:o,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*p,centerY:x.y+x.height/2}}const c=s.y+n+a;return{id:e.id,label:e.label,order:t,x:x.x,y:c,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*p}});return{width:t,height:n,flow:o,charge:m,apparatus:g,destinations:w,projection:b}}function jc(e,t){return e.destinations.find(e=>e.id===t)}function Fc(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function Lc(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:`${o}-floor`,shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:`${o}-floor`,shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:`${o}-wall-left`,shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:`${o}-wall-right`,shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function zc(e,t={}){const n=t.charge??"bodies",o=t.apparatus??"the apparatus",r=t.destination??"destinations",i=e.destinations.length,s="down"===e.flow?"downward":"left to right";return`${n} enter at the ${"down"===e.flow?"top":"left"}, travel ${s} through ${o}, and come to rest in ${i} ${r}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Dc(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function _c(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function Wc(e,t,n){return Dc(e[t])??n}function qc(e,t){return"number"==typeof e?e:e?.[t]??0}function Gc(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=/* @__PURE__ */new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}function Bc(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=Gc(t);if(c.length<2)return[];const l=i?0:1,d=i?c.length-1:c.length-2,u=[];for(let e=l;e<=d;e+=1){if(!s&&e>0&&e<c.length-1)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return u}function Yc(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...ma(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...ga({...s,idPrefix:e??`${n}-xbin`,yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...Bc({band:i,idPrefix:i.idPrefix??`${n}-xband`,plot:t,projection:"x"})),s&&a.push(...Bc({band:s,idPrefix:s.idPrefix??`${n}-yband`,plot:t,projection:"y"})),a}function Vc(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:d=.04}=e,u=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===u)return[];const p=u<=1?0:(a-s)/(u-1),f=t.width/h,m=[];for(let e=0;e<u;e+=1){const n=c&&e%2==1?f/2:0;for(let o=0;o<h;o+=1){const a=t.x+f*(o+.5)+n;a<t.x+r||a>t.x+t.width-r||m.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*p,width:2*r,height:2*r},restitution:l,friction:d})}}return m}function Hc(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:d,datum:u}=t,h=Be(l),p=qc(d,"x"),f=qc(d,"y");return e.map((e,l)=>{const d=_c(t.x,e,l,Wc(e,"x",0)),m=_c(t.y,e,l,Wc(e,"y",0)),g=_c(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:d+(h()-.5)*p,y:m+(h()-.5)*f,vx:_c(s,e,l,0),vy:_c(a,e,l,0),mass:_c(i,e,l,1),spawnAt:_c(c,e,l,void 0),shape:y,datum:u?u(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Uc(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=fa(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function Xc(e,t,n){return Dc("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}function Kc(e,n={}){const{timeAccessor:o="arrivalTime",timeScale:r=1,startAt:i=0,rebase:s=!0,sort:a=!0}=n,c=e.map((e,t)=>({spawn:e,time:Xc(e,t,o)??e.spawnAt??t})),l=c.length?t(c.map(e=>e.time)):0;return{initialSpawns:c.map(({spawn:e,time:t})=>({...e,spawnAt:i+(s?t-l:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:i,timeAccessor:"spawnAt",timeScale:r}}}function Jc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Zc(e,t,n="group"){const o=ra(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return n<i?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function Qc(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{Jc(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function el(e,t,n=.55){const o=Math.abs(t.x-e.x),r=(e.x+t.x)/2,i=e.y-o*n;return`M${e.x},${e.y} Q${r},${i} ${t.x},${t.y}`}function tl(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;Jc(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function nl(e,t,n={}){const o=(n.order??Zc(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.source<e.target?`${e.source}${zf}${e.target}`:`${e.target}${zf}${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split(zf),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function ol(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function rl(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function il(e,t){const n=ol(e.note)?e.note:void 0;return t?rl(e.mobileText)||rl(e.shortText)||rl(e.label)||rl(n?.mobileText)||rl(n?.shortText)||rl(n?.label)||rl(n?.title):rl(e.label)||rl(e.mobileText)||rl(e.shortText)||rl(n?.label)||rl(n?.title)}function sl(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}function al(e,t,n){const o=sl(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=String(e.emphasis??"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=ol(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=ol(e.lifecycle)?e.lifecycle:void 0,c=String(a?.freshness??"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function cl(e,t){if(!t)return e;const n=il(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function ll(e,t,n,o){const r=il(e,o);if(!r)return null;const i=rl(e.id)||rl(e.key)||rl(e.pointId)||`annotation-${t+1}`,s=ol(e.provenance)?rl(e.provenance.source)||rl(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:rl(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}function dl(e,t={}){const n=Array.isArray(e)?e.filter(ol):[],o=t.breakpoint??480,r=t.active??(null==t.width||t.width<=o),i=t.strategy??"hybrid",s=!1!==t.preferShortText,a=!1!==t.preservePrimary,c=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===i?1:2)),l=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!r||"plot"===i)return{active:r,strategy:i,budget:n.length,visible:s?n.map(e=>cl(e,s)):n,deferred:[],calloutList:[],hidden:[]};const d=[],u=n.map((e,n)=>({annotation:e,index:n,priority:al(e,n,t)})).filter(e=>!!Kr(e.annotation)||(d.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),h=a?u.filter(e=>"primary"===String(e.annotation.emphasis??"").toLowerCase()):[],p=new Set(h.map(e=>e.index)),f=u.filter(e=>!p.has(e.index)),m=[...h,...f].slice(0,Math.max(c,l)),g=new Set(m.map(e=>e.index)),y=u.filter(e=>!g.has(e.index)),x=[...d,...m.sort((e,t)=>e.index-t.index).map(e=>cl(e.annotation,s))],b=y.sort((e,t)=>e.index-t.index).map(e=>e.annotation),w=Math.max(0,t.maxCalloutItems??6),M=y.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>ll(e.annotation,e.index,e.priority,s)).filter(e=>!!e).slice(0,w),v=new Set(M.map(e=>e.annotation)),k=b.filter(e=>!v.has(e));return{active:r,strategy:i,budget:c,visible:x,deferred:b,calloutList:M,hidden:k}}function ul(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function hl(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function pl(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function fl(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function ml(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:fl(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=hl(e,t),l=ul(t);return{family:e,props:s,responsiveRules:[{id:`${e}-mobile`,description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function gl(e={}){const t=pl(e);return ml("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function yl(e={}){const t=pl(e);return ml("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function xl(e={}){return ml("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function bl(e={}){const t=pl(e);return ml("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function wl(e={}){const t=pl(e);return ml("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function Ml(e={}){return ml("geo",e,{showLegend:e.showLegend??!1})}function vl(e={}){return ml("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function kl(e,t={}){switch(e){case"line":return gl(t);case"area":return yl(t);case"ordinal":return xl(t);case"scatter":return bl(t);case"network":return wl(t);case"geo":return Ml(t);case"small-multiple":return vl(t)}}function Il(e={}){const t=e.targetSize??44,n=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:t,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:n,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:n}}function Sl(e){return JSON.stringify([e.nodeId,e.endpoint.kind,"part"===e.endpoint.kind?e.endpoint.partId:null,e.endpoint.portId??null])}function $l(e,t=Df){return{nodeId:e,endpoint:t}}function Nl(e,t){return e<t?-1:e>t?1:0}function El(e){return Array.isArray(e)?`[${e.map(El).join(",")}]`:e&&"object"==typeof e?`{${Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>Nl(e,t)).map(([e,t])=>`${JSON.stringify(e)}:${El(t)}`).join(",")}}`:JSON.stringify(e)??"null"}function Al(e){if(e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))Al(t)}return e}function Cl(e,t,n={}){throw new _f([{code:e,message:t,severity:"error",...n}])}function Ol(e,t){const n=/* @__PURE__ */new Map;for(const o of e)"string"==typeof o.id&&o.id&&!n.has(o.id)||Cl("IDENTITY_DUPLICATE_OR_EMPTY",`IDs must be nonempty and unique in ${t}.`),n.set(o.id,o);return n}function Tl(e,t){const n=/* @__PURE__ */new Set;for(const o of e.keys()){const r=/* @__PURE__ */new Set;let i=o;for(;void 0!==i&&!n.has(i);){r.has(i)&&Cl("IDENTITY_CONTAINMENT_CYCLE","Containment must be acyclic.");const n=e.get(i);n||Cl("IDENTITY_UNKNOWN_PARENT","Containment references an unknown parent."),r.add(i),i=t(n)}r.forEach(e=>n.add(e))}}function Pl(e,t,n){const o=e.get(t.nodeId);o||Cl("ENDPOINT_UNKNOWN_OWNER","Endpoint owner does not exist.",{endpointRefs:[t]});const r=t.endpoint;"node"!==r.kind&&"part"!==r.kind&&Cl("ENDPOINT_KIND","Unknown endpoint kind.");const i="part"===r.kind?o.parts?.find(e=>e.id===r.partId):void 0;if("part"!==r.kind||i||Cl("ENDPOINT_UNKNOWN_PART","Endpoint part does not exist.",{endpointRefs:[t]}),void 0===r.portId)return;const s=(i?i.ports:o.ports)?.find(e=>e.id===r.portId);s||Cl("ENDPOINT_UNKNOWN_PORT","Endpoint port does not exist.",{endpointRefs:[t]});const a="source"===n||"transfer-target"===n?"out":"in";return n&&s.direction!==a&&"inout"!==s.direction&&Cl("ENDPOINT_DIRECTION","Port direction is incompatible with its use.",{endpointRefs:[t]}),s}function Rl(e,t,n){const o=e.get(t)??[];o.push(n),e.set(t,o)}function jl(e){const t=Wf.get(e);if(t)return t;const n=e.graph,o={nodes:new Map(n.nodes.map(e=>[e.id,e])),endpoints:/* @__PURE__ */new Map,ownerEndpoints:/* @__PURE__ */new Map,tracePolicies:/* @__PURE__ */new Map,incoming:/* @__PURE__ */new Map,outgoing:/* @__PURE__ */new Map,transferIn:/* @__PURE__ */new Map,transferOut:/* @__PURE__ */new Map},r=e=>{const t=Sl(e);return o.endpoints.has(t)||Rl(o.ownerEndpoints,e.nodeId,e),o.endpoints.set(t,e),t},i=new Set(n.transfers?.map(e=>e.nodeId));for(const e of[...n.nodes].sort((e,t)=>Nl(e.id,t.id))){o.tracePolicies.set(e.id,e.tracePolicy??(e.parts?.length||e.ports?.length||i.has(e.id)?"explicit":"atomic")),r($l(e.id));for(const t of e.ports??[])r($l(e.id,{kind:"node",portId:t.id}));for(const t of e.parts??[]){r($l(e.id,{kind:"part",partId:t.id}));for(const n of t.ports??[])r($l(e.id,{kind:"part",partId:t.id,portId:n.id}))}}for(const e of[...n.edges].sort((e,t)=>Nl(e.id,t.id)))Rl(o.outgoing,r($l(e.source,e.sourceEndpoint)),e),Rl(o.incoming,r($l(e.target,e.targetEndpoint)),e);for(const e of[...n.transfers??[]].sort((e,t)=>Nl(e.id,t.id))){Rl(o.transferIn,r($l(e.nodeId,e.target)),e);for(const t of e.sources)Rl(o.transferOut,r($l(e.nodeId,t)),e)}for(const e of o.ownerEndpoints.values())e.sort((e,t)=>Nl(Sl(e),Sl(t)));return Wf.set(e,o),o}function Fl(e){"semiotic.compositional-graph.v0.1"!==e.schemaVersion&&Cl("IDENTITY_SCHEMA","Unknown graph schema."),"string"==typeof e.graphId&&e.graphId&&"string"==typeof e.revision&&e.revision||Cl("IDENTITY_REVISION","Graph ID and revision are required.");const t=Ol(e.nodes,"nodes");Ol(e.edges,"edges"),Ol(e.transfers??[],"transfers"),Tl(t,e=>e.parentId);const n=(e=[])=>{Ol(e,"ports");for(const t of e)["in","out","inout"].includes(t.direction)||Cl("ENDPOINT_DIRECTION","Unknown port direction.")};for(const e of t.values()){e.tracePolicy&&!["atomic","explicit","opaque"].includes(e.tracePolicy)&&Cl("TRACE_POLICY","Unknown trace policy."),n(e.ports);const t=Ol(e.parts??[],"owner parts");Tl(t,e=>e.parentPartId);for(const e of t.values())n(e.ports)}for(const n of e.edges)Pl(t,$l(n.source,n.sourceEndpoint),"source"),Pl(t,$l(n.target,n.targetEndpoint),"target");for(const n of e.transfers??[])n.sources.length&&["identity","all","any","unspecified"].includes(n.combination)&&("identity"!==n.combination||1===n.sources.length)||Cl("ENDPOINT_TRANSFER","Transfers need inputs and a valid combination; identity needs one input."),new Set(n.sources.map(e=>Sl($l(n.nodeId,e)))).size!==n.sources.length&&Cl("ENDPOINT_TRANSFER","Transfer inputs must be distinct."),n.sources.forEach(e=>Pl(t,$l(n.nodeId,e),"transfer-source")),Pl(t,$l(n.nodeId,n.target),"transfer-target");let o;try{o=JSON.parse(JSON.stringify(e,(e,t)=>{if("function"==typeof t||"symbol"==typeof t||"bigint"==typeof t||"number"==typeof t&&!Number.isFinite(t))throw new Error("Non-JSON value");return t}))}catch{Cl("IDENTITY_NONPORTABLE","Graph must be serializable JSON.")}const r=e=>[...e].sort((e,t)=>Nl(e.id,t.id)),i=Al({schemaVersion:"semiotic.prepared-compositional-graph.v0.1",graph:o,semanticHash:El({graphId:o.graphId,nodes:r(o.nodes).map(({id:e,parentId:t,tracePolicy:n,ports:o,parts:i})=>({id:e,parentId:t,tracePolicy:n,ports:r(o??[]).map(({id:e,direction:t})=>({id:e,direction:t})),parts:r(i??[]).map(({id:e,parentPartId:t,ports:n})=>({id:e,parentPartId:t,ports:r(n??[]).map(({id:e,direction:t})=>({id:e,direction:t}))}))})),edges:r(o.edges).map(({data:e,...t})=>t),transfers:r(o.transfers??[])}),diagnostics:[]});return jl(i),i}function Ll(e,t){t.baseRevision===e.graph.revision&&t.revision!==t.baseRevision||Cl("REVISION_PATCH_BASE","Patch requires the current base and a new revision.");const n=(e,t=[],n=[])=>{Ol(n,"patch upserts");const o=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>o.delete(e)),n.forEach(e=>o.set(e.id,e)),[...o.values()]};return Fl({...e.graph,revision:t.revision,nodes:n(e.graph.nodes,t.removeNodeIds,t.upsertNodes),edges:n(e.graph.edges,t.removeEdgeIds,t.upsertEdges),transfers:n(e.graph.transfers??[],t.removeTransferIds,t.upsertTransfers)})}function zl(e,t){(!Number.isInteger(t.maxVisited)||t.maxVisited<1||!Number.isInteger(t.maxDepth)||t.maxDepth<0)&&Cl("TRACE_BUDGET","Trace budgets must be finite nonnegative integers, with at least one visit.");const n=jl(e);Pl(n.nodes,t.start);const o="upstream"===t.direction,r=[{ref:t.start,depth:0}],i=/* @__PURE__ */new Set([Sl(t.start)]),s=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set,l=/* @__PURE__ */new Set,d=[];let u="complete";const h=e=>!t.kinds||t.kinds.includes(e??"unspecified"),p=(e,t,n)=>{a.has(Sl(e))||d.push({code:t,severity:"warning",message:n,endpointRefs:[e]}),a.set(Sl(e),e),"TRACE_BUDGET"===t?u="partial":"complete"===u&&(u="unknown")};for(let e=0;e<r.length;e++){const{ref:a,depth:d}=r[e];s.set(Sl(a),a);const u=n.tracePolicies.get(a.nodeId),f="node"===a.endpoint.kind&&!a.endpoint.portId&&"atomic"!==u,m=f&&d>0&&"conservative-node"!==t.boundaryPolicy;f&&p(a,"TRACE_COARSE_BOUNDARY","Whole-node boundary does not establish exact interface provenance.");const g=e=>{const n=Sl(e);return!!i.has(n)||(d>=t.maxDepth||i.size>=t.maxVisited?(p(a,"TRACE_BUDGET","Trace is partial within the supplied graph: visit or depth budget reached."),!1):(i.add(n),r.push({ref:e,depth:d+1}),!0))};if(!m)for(const e of(o?n.incoming:n.outgoing).get(Sl(a))??[])h(e.kind)&&g(o?$l(e.source,e.sourceEndpoint):$l(e.target,e.targetEndpoint))&&c.add(e.id);for(const e of(o?n.transferIn:n.transferOut).get(Sl(a))??[])if(h(e.kind)){l.add(e.id);for(const t of o?e.sources:[e.target])g($l(e.nodeId,t))}if(f&&"conservative-node"===t.boundaryPolicy)for(const e of n.ownerEndpoints.get(a.nodeId)??[])g(e)}return Al({endpoints:[...s.values()],edgeIds:[...c].sort(Nl),transferIds:[...l].sort(Nl),completeness:u,boundaryRefs:[...a.values()],diagnostics:d})}function Dl(e,t,n=!0){return(!Number.isFinite(e)||n&&e<0)&&Cl("GEOMETRY_NUMBER",`${t} must be finite${n?" and nonnegative":""}.`),e}function _l(e){Dl(e.x,"x",!1),Dl(e.y,"y",!1),Dl(e.width,"width"),Dl(e.height,"height")}function Wl(e){return[..."within-groups"===e.mode?e.groups.flatMap(e=>[...e.ids]):"optimize"===e.mode?e.initialIds:e.ids]}function ql(e,t){const n=Wl(e);(n.length!==t.length||new Set(n).size!==n.length||t.some(e=>!n.includes(e)))&&Cl("ORDER_MEMBERS","An order must contain every participating member exactly once."),"within-groups"===e.mode&&new Set(e.groups.map(e=>e.id)).size!==e.groups.length&&Cl("ORDER_GROUPS","Order group IDs must be unique.")}function Gl(e,t,n){return"optimize"===e.mode||"within-groups"===e.mode&&e.groups.some(e=>!e.fixed&&e.ids.includes(t)&&e.ids.includes(n))}function Bl(e,t,n,o=Wl(t.order)){const r="LR"===n||"RL"===n,i=t.padding;Object.entries(i).forEach(([e,t])=>Dl(t,e)),Dl(t.headerHeight,"headerHeight"),Dl(t.rowGap,"rowGap"),Dl(t.defaultRowHeight,"defaultRowHeight");const s=/* @__PURE__ */new Map;for(const e of t.rowHeights??[])!s.has(e.partId)&&o.includes(e.partId)||Cl("ORDER_ROW_HEIGHT","Row size IDs must be unique participating parts."),s.set(e.partId,Dl(e.height,"rowHeight"));let a=t.headerHeight+(r?i.top:i.left);const c=r?e.width-i.left-i.right:e.height-i.top-i.bottom;Dl(c,"available row breadth");const l=o.map(e=>{const n=s.get(e)??t.defaultRowHeight,o=r?{x:i.left,y:a,width:c,height:n}:{x:a,y:i.top,width:n,height:c};return a+=n+t.rowGap,{partId:e,rect:o}});return a-(l.length?t.rowGap:0)+(r?i.bottom:i.right)>(r?e.height:e.width)+1e-8&&Cl("GEOMETRY_FOOTPRINT","Rows exceed the supplied node footprint.",{nodeIds:[e.nodeId]}),{...e,parts:l,actualPartOrder:o}}function Yl(e,t,n=.5){switch((!Number.isFinite(n)||n<0||n>1)&&Cl("GEOMETRY_FRACTION","Anchor fraction must be in [0,1]."),t){case"north":return{point:{x:e.x+e.width*n,y:e.y},normal:{x:0,y:-1}};case"south":return{point:{x:e.x+e.width*n,y:e.y+e.height},normal:{x:0,y:1}};case"east":return{point:{x:e.x+e.width,y:e.y+e.height*n},normal:{x:1,y:0}};case"west":return{point:{x:e.x,y:e.y+e.height*n},normal:{x:-1,y:0}};default:return Cl("GEOMETRY_SIDE","Unknown anchor side.")}}function Vl(e,t){return{LR:["east","west"],RL:["west","east"],TB:["south","north"],BT:["north","south"]}[e]["source"===t?0:1]}function Hl(e){if(!e.length)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,o=-1/0,r=-1/0;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.width),r=Math.max(r,i.y+i.height);return{x:t,y:n,width:o-t,height:r-n}}function Ul(e){return Hl(e.map(e=>({...e,width:0,height:0})))}function Xl(e,t){return e.x<t.x+t.width-1e-8&&e.x+e.width>t.x+1e-8&&e.y<t.y+t.height-1e-8&&e.y+e.height>t.y+1e-8}function Kl(e,t){return t.x>=e.x-1e-8&&t.x<=e.x+e.width+1e-8&&t.y>=e.y-1e-8&&t.y<=e.y+e.height+1e-8}function Jl(e){const t=/* @__PURE__ */new Map;for(const n of e.nodes){t.has(n.nodeId)&&Cl("GEOMETRY_DUPLICATE","Duplicate node measurement."),Dl(n.width,"width"),Dl(n.height,"height");const e=/* @__PURE__ */new Set;for(const t of n.parts)e.has(t.partId)&&Cl("GEOMETRY_DUPLICATE","Duplicate part measurement."),e.add(t.partId),_l(t.rect),Kl({x:0,y:0,width:n.width,height:n.height},t.rect)&&Kl({x:0,y:0,width:n.width,height:n.height},{x:t.rect.x+t.rect.width,y:t.rect.y+t.rect.height})||Cl("GEOMETRY_PART_BOUNDS","Part measurement exceeds its owner.");const o=/* @__PURE__ */new Set;for(const e of[...(n.markAnchors??[]).map(e=>({...e,key:JSON.stringify(["mark",e.markId,e.anchorName])})),...(n.slotAnchors??[]).map(e=>({...e,key:JSON.stringify(["slot",e.groupId,e.slotId])}))])o.has(e.key)&&Cl("GEOMETRY_DUPLICATE","Duplicate named anchor."),o.add(e.key),Dl(e.point.x,"anchor x",!1),Dl(e.point.y,"anchor y",!1),Dl(e.normal.x,"normal x",!1),Dl(e.normal.y,"normal y",!1);for(const e of[...n.routingChannels??[],...n.obstacleRects??[]])_l(e);t.set(n.nodeId,n)}return t}function Zl(e,t,n){switch(e.kind){case"node-side":return Yl({x:0,y:0,width:t.rect.width,height:t.rect.height},e.side,e.fraction);case"part-side":{const n=t.parts?.find(t=>t.partId===e.partId);return n?Yl(n.rect,e.side,e.fraction):Cl("GEOMETRY_UNKNOWN_PART","Anchor has no solved part rectangle.")}case"point":return e;case"named-mark":{const t=n.markAnchors?.find(t=>t.markId===e.markId&&t.anchorName===e.anchorName);return t||Cl("GEOMETRY_UNKNOWN_MARK","Named mark anchor is unresolved.")}case"slot":{const t=n.slotAnchors?.find(t=>t.groupId===e.groupId&&t.slotId===e.slotId);return t||Cl("GEOMETRY_UNKNOWN_SLOT","Named slot is unresolved.")}}}function Ql(e,t){return JSON.stringify([Sl(e),t])}function ed(e,t,n){return n.some(n=>Math.abs(e.x-t.x)<qf?e.x>n.x+qf&&e.x<n.x+n.width-qf&&Math.max(e.y,t.y)>n.y+qf&&Math.min(e.y,t.y)<n.y+n.height-qf:!(Math.abs(e.y-t.y)<qf)||e.y>n.y+qf&&e.y<n.y+n.height-qf&&Math.max(e.x,t.x)>n.x+qf&&Math.min(e.x,t.x)<n.x+n.width-qf)}function td(e){const t=[];for(const n of e)t.length&&Gf(t[t.length-1],n)<qf||t.push(n);return t}function nd(e,t,n,o,r,i=4e4){const s=e=>e.every((t,o)=>0===o||!ed(e[o-1],t,n)),a=r?(e.x+t.x)/2+o:(e.y+t.y)/2+o,c=r?[e,{x:a,y:e.y},{x:a,y:t.y},t]:[e,{x:e.x,y:a},{x:t.x,y:a},t];if(s(c))return td(c);const l=[],d=[.../* @__PURE__ */new Set([e.x,t.x,...n.flatMap(e=>[e.x,e.x+e.width])])].sort((e,t)=>e-t),u=[.../* @__PURE__ */new Set([e.y,t.y,...n.flatMap(e=>[e.y,e.y+e.height])])].sort((e,t)=>e-t);for(const n of d)l.push([e,{x:n,y:e.y},{x:n,y:t.y},t]);for(const n of u)l.push([e,{x:e.x,y:n},{x:t.x,y:n},t]);const h=l.filter(s).sort((e,t)=>Bf(e)-Bf(t));if(h.length)return td(h[0]);if(d.length*u.length>i)return null;const p=d.length,f=p*u.length,m=u.indexOf(e.y)*p+d.indexOf(e.x),g=u.indexOf(t.y)*p+d.indexOf(t.x),y=new Float64Array(f).fill(1/0),x=new Int32Array(f).fill(-1),b=e=>({x:d[e%p],y:u[Math.floor(e/p)]}),w=[],M=(e,n)=>{const o={id:e,cost:n,priority:n+Gf(b(e),t)};w.push(o);let r=w.length-1;for(;r>0;){const e=r-1>>1;if(w[e].priority<=o.priority)break;w[r]=w[e],r=e}w[r]=o},v=()=>{const e=w[0],t=w.pop();if(w.length){let e=0;for(;2*e+1<w.length;){let n=2*e+1;if(n+1<w.length&&w[n+1].priority<w[n].priority&&n++,w[n].priority>=t.priority)break;w[e]=w[n],e=n}w[e]=t}return e};y[m]=0,M(m,0);let k=0;for(;w.length&&k++<i;){const{id:e,cost:t}=v();if(t!==y[e])continue;if(e===g){const e=[];for(let t=g;t>=0;t=x[t])e.push(b(t));return td(e.reverse())}const o=e%p,r=Math.floor(e/p),i=[o>0?e-1:-1,o+1<p?e+1:-1,r>0?e-p:-1,r+1<u.length?e+p:-1];for(const o of i){if(o<0||ed(b(e),b(o),n))continue;const r=t+Gf(b(e),b(o));r+qf<y[o]&&(y[o]=r,x[o]=e,M(o,r))}}return null}function od(e,t,n,o){const r=[{kind:"M",point:t[0]}];for(let e=1;e<t.length-1;e++){const i=t[e],s=t[e-1],a=t[e+1],c=Math.min(4,Gf(s,i)/3,Gf(a,i)/3),l=e=>({x:i.x+(e.x-i.x)*c/Gf(i,e),y:i.y+(e.y-i.y)*c/Gf(i,e)}),d=l(s),u=l(a),h=Ul([d,i,u]),p=o.some(e=>h.x<e.x+e.width&&h.x+h.width>e.x&&h.y<e.y+e.height&&h.y+h.height>e.y);n&&c>qf&&e>1&&e<t.length-2&&!p?r.push({kind:"L",point:d},{kind:"C",control1:i,control2:i,point:u}):r.push({kind:"L",point:i})}return r.push({kind:"L",point:t[t.length-1]}),{id:e,points:t,commands:r,bounds:Ul(r.flatMap(e=>"C"===e.kind?[e.control1,e.control2,e.point]:[e.point]))}}function rd(e){return(e.commands?.length?e.commands:e.points.map((e,t)=>({kind:t?"L":"M",point:e}))).map(e=>"C"===e.kind?`C${e.control1.x},${e.control1.y} ${e.control2.x},${e.control2.y} ${e.point.x},${e.point.y}`:`${e.kind}${e.point.x},${e.point.y}`).join(" ")}function id(e){const t=[];for(const n of e.commands??[]){if("C"!==n.kind){t.push(n.point);continue}const e=t[t.length-1],o=n.control1,r=n.control2,i=n.point;for(let n=1;n<=24;n++){const s=n/24,a=1-s;t.push({x:a**3*e.x+3*a**2*s*o.x+3*a*s**2*r.x+s**3*i.x,y:a**3*e.y+3*a**2*s*o.y+3*a*s**2*r.y+s**3*i.y})}}return t.length?t:[...e.points]}function sd(e,t,n,o){const r=t.x-e.x,i=t.y-e.y,s=o.x-n.x,a=o.y-n.y,c=r*a-i*s;if(Math.abs(c)<1e-8)return null;const l=((n.x-e.x)*a-(n.y-e.y)*s)/c,d=((n.x-e.x)*i-(n.y-e.y)*r)/c;return l>=0&&l<=1&&d>=0&&d<=1?{x:e.x+l*r,y:e.y+l*i}:null}function ad(e,t,n){let o=0,r=0,i=0,s=0,a=0,c=0;const l=e.map(e=>e.sections.flatMap(id));for(let s=0;s<e.length;s++){const a=e[s],c=l[s];n.has(a.edgeId)&&(i+=Math.abs(t?a.source.anchor.y-a.target.anchor.y:a.source.anchor.x-a.target.anchor.x));for(let e=1;e<c.length;e++)o+=Gf(c[e-1],c[e]),e>1&&Math.abs((c[e-1].x-c[e-2].x)*(c[e].y-c[e-1].y)-(c[e-1].y-c[e-2].y)*(c[e].x-c[e-1].x))>1e-8&&r++}const d=t=>{let n=1/0,o=-1/0;for(const r of e)n=Math.min(n,r.bounds[t]),o=Math.max(o,r.bounds[t]);return e.length?o-n:0},u=d("x")>=d("y")?"x":"y",h="x"===u?"width":"height",p="x"===u?"y":"x",f="x"===u?"height":"width",m=e.map((e,t)=>({e:e,i:t})).sort((e,t)=>e.e.bounds[u]-t.e.bounds[u]);let g=!1;e:for(let e=0;e<m.length;e++)for(let t=e+1;t<m.length;t++){const n=m[e],o=m[t];if(o.e.bounds[u]>n.e.bounds[u]+n.e.bounds[h])break;if(n.e.bounds[p]>o.e.bounds[p]+o.e.bounds[f]||o.e.bounds[p]>n.e.bounds[p]+n.e.bounds[f])continue;const r=/* @__PURE__ */new Set,i=l[n.i],d=l[o.i],y=[n.e.source,n.e.target].flatMap(e=>[o.e.source,o.e.target].filter(t=>Gf(e.anchor,t.anchor)<1e-8&&Gf(e.escape,t.escape)<1e-8).map(()=>[e.anchor,e.escape])),x=e=>y.some(([t,n])=>Math.abs(Gf(t,e)+Gf(e,n)-Gf(t,n))<1e-7);for(let e=1;e<i.length;e++)for(let t=1;t<d.length;t++){if(++a>2e6){g=!0;break e}const n=sd(i[e-1],i[e],d[t-1],d[t]);n&&!x(n)&&r.add(`${n.x.toFixed(6)},${n.y.toFixed(6)}`);const o=i[e-1],s=i[e],l=d[t-1],u=d[t],h=Math.abs(o.x-s.x)<1e-8&&Math.abs(o.x-l.x)<1e-8&&Math.abs(o.x-u.x)<1e-8,p=Math.abs(o.y-s.y)<1e-8&&Math.abs(o.y-l.y)<1e-8&&Math.abs(o.y-u.y)<1e-8;if(h||p){const e=h?"y":"x",t=Math.max(Math.min(o[e],s[e]),Math.min(l[e],u[e])),n=Math.min(Math.max(o[e],s[e]),Math.max(l[e],u[e]));n>t&&!x(h?{x:o.x,y:(t+n)/2}:{x:(t+n)/2,y:o.y})&&(c+=n-t)}}s+=r.size}return{metrics:{crossings:s,channelCongestion:c,alignmentError:i,totalRouteLength:o,bendCount:r,nodeDisplacement:0,reorderedParts:0,hardConstraintViolations:0,routedEdgeCount:e.length,omittedEdgeCount:0,completedSweeps:0},partial:g}}function cd(e,t){const n=/* @__PURE__ */new Map;for(const o of e??[]){const e=t(o);n.has(e)||n.set(e,o)}return n}function ld(e){const{graph:t}=e.prepared,n=new Map(t.nodes.map(e=>[e.id,e])),o=new Map(e.view.nodes.map(e=>[e.nodeId,e]));o.size!==e.view.nodes.length&&Cl("IDENTITY_VIEW","Duplicate node presentations.");for(const e of o.keys())n.has(e)||Cl("IDENTITY_VIEW","Unknown presentation owner.");const r=/* @__PURE__ */new Map;for(const e of t.nodes){let t=e.parentId;for(;t;)"summary"===o.get(t)?.mode&&r.set(e.id,t),t=n.get(t)?.parentId}return{semantics:n,views:o,hidden:r}}function dd(e,t,n,o){const{graph:r}=e.prepared,{semantics:i,views:s,hidden:a}=ld(e),c=[],l=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(const u of[...r.nodes].sort((e,t)=>Nl(e.id,t.id))){if(a.has(u.id))continue;let r=t.get(u.id);r||Cl("GEOMETRY_MISSING","Every visible owner needs geometry.",{nodeIds:[u.id]});const h=s.get(u.id),p=h?.partLayout;if("rows"===p?.kind){ql(p.order,(u.parts??[]).map(e=>e.id));const t=o.get(u.id)??Wl(p.order);"fixed"!==p.order.mode&&(r.markAnchors?.length||r.slotAnchors?.length||e.view.anchors?.some(e=>e.ref.nodeId===u.id&&["point","named-mark","slot"].includes(e.binding.kind)))&&Cl("CONSTRAINT_ABSOLUTE_REORDER","Absolute anchors require fixed row order or a custom reflow adapter.",{nodeIds:[u.id]}),r=Bl(r,p,e.view.direction,t)}"summary"!==h?.mode&&(u.parts??[]).some(e=>!r.parts.some(t=>t.partId===e.id))&&Cl("GEOMETRY_MISSING_PART","Every visible part needs a rectangle.",{nodeIds:[u.id]}),r.parts.some(e=>!u.parts?.some(t=>t.id===e.partId))&&Cl("GEOMETRY_UNKNOWN_PART","Measured part does not exist.");const f=n.get(u.id),m={id:u.id,semantic:$l(u.id),rect:{...f,width:r.width,height:r.height},parts:r.parts.map(e=>({...e,rect:{...e.rect},semantic:$l(u.id,{kind:"part",partId:e.partId})})),partOrder:r.actualPartOrder&&[...r.actualPartOrder],markAnchors:r.markAnchors?.map(Hf),slotAnchors:r.slotAnchors?.map(Hf)};if(c.push(m),l.set(u.id,m),d.set(u.id,r),"exploded"===h?.mode)for(const e of m.parts??[]){const t=JSON.stringify(["part",u.id,e.partId]);i.has(t)&&Cl("IDENTITY_PROJECTION_COLLISION","A semantic ID collides with an exploded display ID."),c.push({id:t,semantic:e.semantic,rect:{...e.rect,x:f.x+e.rect.x,y:f.y+e.rect.y}})}}for(let e=0;e<c.length;e++)for(let t=e+1;t<c.length;t++){const n=c[e],o=c[t];if("part"===n.semantic.endpoint.kind||"part"===o.semantic.endpoint.kind)continue;const r=(e,t)=>{let n=e.parentId;for(;n;){if(n===t)return!0;n=i.get(n)?.parentId}return!1},s=r(i.get(n.id),o.id),a=r(i.get(o.id),n.id);if(s||a){const e=s?n:o,t=s?o:n;Kl(t.rect,e.rect)&&Kl(t.rect,{x:e.rect.x+e.rect.width,y:e.rect.y+e.rect.height})||Cl("CONSTRAINT_CONTAINMENT","Authored child bounds exceed the containing owner.",{nodeIds:[e.id,t.id]})}else Xl(n.rect,o.rect)&&Cl("CONSTRAINT_OVERLAP","Node boxes overlap.",{nodeIds:[n.id,o.id]})}const{view:u}=e;return{nodes:c,hidden:a,bySemantic:l,measures:d,semantics:i,presentations:s,anchors:cd(u.anchors,e=>Ql(e.ref,e.use)),exposures:cd(u.boundaryExposures,e=>Yf(e.containerNodeId,Ql(e.inner,e.use))),portOrders:cd(u.portOrders,e=>Vf(e.nodeId,e.partId,e.use,e.side)),byId:new Map(c.map(e=>[e.id,e]))}}function ud(e,t,n,o,r){const{view:i}=e,{semantics:s}=t,a=t.hidden.get(o.nodeId),c=a??o.nodeId;let l=t.bySemantic.get(c);const d=t.measures.get(c),u=t.presentations.get(c),h="summary"===u?.mode&&("part"===o.endpoint.kind||!!o.endpoint.portId),p=a||h?t.exposures.get(Yf(c,Ql(o,r))):void 0;!a&&!h||p||Cl("ENDPOINT_MISSING_EXPOSURE","Collapsed endpoints need explicit boundary exposures.",{endpointRefs:[o]});const f=t.anchors.get(Ql(o,r));let m=p?.binding??f?.binding;const g=Vl(i.direction,r);if(!m){let e={x:0,y:0,width:l.rect.width,height:l.rect.height};if("part"===o.endpoint.kind){const n=o.endpoint.partId,r=l.parts?.find(e=>e.partId===n);r||Cl("GEOMETRY_MISSING_PART","Endpoint has no solved part geometry.",{endpointRefs:[o]}),e=r.rect,"exploded"===u?.mode&&(l=t.byId.get(JSON.stringify(["part",c,n])),e={...e,x:0,y:0})}let n=.5;if(o.endpoint.portId){const e=s.get(o.nodeId),i="part"===o.endpoint.kind?o.endpoint.partId:void 0,a=((i?e.parts?.find(e=>e.id===i)?.ports:e.ports)??[]).filter(e=>"inout"===e.direction||e.direction===("source"===r?"out":"in")).map(e=>e.id).sort(Nl),c=t.portOrders.get(Vf(o.nodeId,i,r,g));c&&ql(c.order,a);const l=c?Wl(c.order):a;n=(l.indexOf(o.endpoint.portId)+1)/(l.length+1)}const i=Yl(e,g,n).point;n="west"===g||"east"===g?i.y/(l.rect.height||1):i.x/(l.rect.width||1),m={kind:"node-side",side:g,fraction:n}}const y=Zl(m,l,d);Dl(y.point.x,"anchor x",!1),Dl(y.point.y,"anchor y",!1);const x={x:y.normal.x,y:y.normal.y};1===Math.abs(x.x)&&0===x.y||1===Math.abs(x.y)&&0===x.x||Cl("CAPABILITY_NORMAL","The built-in orthogonal adapter requires cardinal unit normals.");const b={x:0,y:0,width:l.rect.width,height:l.rect.height};Kl(b,y.point)||Cl("GEOMETRY_ANCHOR_BOUNDS","Anchor is outside the display node.");const w={x:x.x>0?b.width:x.x<0?0:y.point.x,y:x.y>0?b.height:x.y<0?0:y.point.y};if(!("point"!==m.kind&&"named-mark"!==m.kind&&"slot"!==m.kind||w.x===y.point.x&&w.y===y.point.y)){const e=d.routingChannels??[],t=[0,1,...e.flatMap(e=>x.x?[(e.x-y.point.x)/(w.x-y.point.x),(e.x+e.width-y.point.x)/(w.x-y.point.x)]:[(e.y-y.point.y)/(w.y-y.point.y),(e.y+e.height-y.point.y)/(w.y-y.point.y)])].filter(e=>e>=0&&e<=1).sort((e,t)=>e-t);t.slice(1).some((n,o)=>!e.some(e=>Kl(e,{x:y.point.x+(w.x-y.point.x)*(n+t[o])/2,y:y.point.y+(w.y-y.point.y)*(n+t[o])/2})))&&Cl("CONSTRAINT_INTERIOR_ESCAPE","Interior mark needs a declared straight escape corridor.",{edgeIds:[n]})}const M=(l.parts??[]).filter(e=>"part-side"!==m.kind||e.partId!==m.partId).map(e=>e.rect);ed(y.point,w,[...d.obstacleRects??[],..."part-side"===m.kind?M:[]])&&Cl("CONSTRAINT_INTERIOR_ESCAPE","Terminal escape intersects an obstacle.",{edgeIds:[n]});const v=Math.max(e.options.terminalStub,e.options.obstaclePadding);return{edgeId:n,end:r,semantic:o,displayNodeId:l.id,anchor:{x:l.rect.x+y.point.x,y:l.rect.y+y.point.y},escape:{x:l.rect.x+w.x+x.x*v,y:l.rect.y+w.y+x.y*v},normal:x,precision:p?"proxy":"exact",exposureId:p?.id}}function hd(e){[e.requestId,e.view.revision,e.geometry.revision].every(e=>"string"==typeof e&&e.length>0)||Cl("REVISION_REQUIRED","Request, view and geometry revisions must be nonempty strings.");const t=new Map(e.prepared.graph.nodes.map(e=>[e.id,e])),n=/* @__PURE__ */new Set;for(const o of e.view.anchors??[]){Pl(t,o.ref,o.use);const e=Ql(o.ref,o.use);n.has(e)&&Cl("IDENTITY_ANCHOR","Duplicate endpoint/use anchor."),n.add(e)}const o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Set;for(const n of e.view.boundaryExposures??[]){Pl(t,n.inner,n.use);let e=n.inner.nodeId;for(;e&&e!==n.containerNodeId;)e=t.get(e)?.parentId;e||Cl("ENDPOINT_EXPOSURE_OWNER","Exposure must refer to an endpoint inside its container.");const i=JSON.stringify([n.containerNodeId,Ql(n.inner,n.use)]);(o.has(n.id)||r.has(i))&&Cl("IDENTITY_EXPOSURE","Duplicate boundary exposure."),o.add(n.id),r.add(i)}const i=/* @__PURE__ */new Set;for(const n of e.view.portOrders??[]){const e=n.partId?{kind:"part",partId:n.partId}:{kind:"node"};Pl(t,$l(n.nodeId,e));const o=t.get(n.nodeId),r=((n.partId?o.parts?.find(e=>e.id===n.partId)?.ports:o.ports)??[]).filter(e=>"inout"===e.direction||e.direction===("source"===n.use?"out":"in"));ql(n.order,r.map(e=>e.id));const s=JSON.stringify([n.nodeId,n.partId??null,n.side,n.use]);i.has(s)&&Cl("ORDER_PORT_DUPLICATE","Repeated port order constraint."),i.add(s),"fixed"!==n.order.mode&&Cl("CAPABILITY_PORT_ORDER","This adapter supports fixed port order; port permutation needs another adapter.")}}function pd(e,t){const n=new Map(e.map(e=>[e,0])),o=/* @__PURE__ */new Map;for(const[e,r]of t){const t=o.get(e)??/* @__PURE__ */new Set;t.has(r)||(t.add(r),n.set(r,(n.get(r)??0)+1)),o.set(e,t)}const r=e.filter(e=>!n.get(e)).sort(Nl),i=new Map(e.map(e=>[e,0]));let s=0;for(let e=0;e<r.length;e++){const t=r[e];s++;for(const e of[...o.get(t)??[]].sort(Nl))i.set(e,Math.max(i.get(e)??0,i.get(t)+1)),n.set(e,n.get(e)-1),n.get(e)||r.push(e)}return s===e.length?i:null}function fd(e){const t=/* @__PURE__ */new Set,n=[],o=(e,o)=>{t.add(e),t.add(o),n.push([e,o])};for(const t of e.prepared.graph.edges)o(Sl($l(t.source,t.sourceEndpoint)),Sl($l(t.target,t.targetEndpoint)));for(const t of e.prepared.graph.transfers??[])for(const e of t.sources)o(Sl($l(t.nodeId,e)),Sl($l(t.nodeId,t.target)));pd([...t],n)||"strict-dag"!==e.options.topology||Cl("TOPOLOGY_SEMANTIC_CYCLE","Connections and transfers contain a semantic cycle.")}function md(e,t){const n=t.nodes.filter(e=>"node"===e.semantic.endpoint.kind).map(e=>e.id),o=e=>t.hidden.get(e)??e,r=pd(n,e.prepared.graph.edges.filter(e=>o(e.source)!==o(e.target)).map(e=>[o(e.source),o(e.target)]));return r||"strict-dag"!==e.options.topology||Cl("TOPOLOGY_PROJECTION_CYCLE","The display quotient is cyclic; expand the group or explicitly select feedback mode."),r??new Map(n.sort(Nl).map((e,t)=>[e,t]))}function gd(e){const t=new Map(e.view.constraints?.map(e=>[e.nodeId,e]));t.size!==(e.view.constraints?.length??0)&&Cl("CONSTRAINT_DUPLICATE","Duplicate node constraints.");for(const n of t.values())e.prepared.graph.nodes.some(e=>e.id===n.nodeId)||Cl("CONSTRAINT_OWNER","Unknown constrained node."),!n.position||Number.isFinite(n.position.x)&&Number.isFinite(n.position.y)||Cl("GEOMETRY_POSITION","Positions must be finite."),n.pin&&!n.position&&Cl("CONSTRAINT_PIN","Pinned nodes need a position."),void 0!==n.rank&&(!Number.isInteger(n.rank)||n.rank<0)&&Cl("CONSTRAINT_RANK","Ranks must be nonnegative integers.");const n=/* @__PURE__ */new Map;for(const o of e.prepared.graph.nodes){const r=t.get(o.id);"route-only"!==e.options.mode||r?.position||Cl("CONSTRAINT_POSITION","Route-only mode requires authored positions for every owner.",{nodeIds:[o.id]}),n.set(o.id,r?.position??{x:0,y:0})}return n}function yd(e,t,n){const o="LR"===e.view.direction||"RL"===e.view.direction,r="RL"===e.view.direction||"BT"===e.view.direction,i=new Map(e.view.constraints?.map(e=>[e.nodeId,e])),s=new Map(e.geometry.nodes.map(e=>[e.nodeId,e]));for(const[e,n]of t){const o=i.get(e)?.rank;void 0!==o?t.set(e,o):t.set(e,n)}if("strict-dag"===e.options.topology)for(const n of e.prepared.graph.edges)n.source!==n.target&&t.has(n.source)&&t.has(n.target)&&t.get(n.source)>=t.get(n.target)&&Cl("CONSTRAINT_RANK","Authored ranks conflict with graph direction.",{edgeIds:[n.id]});let a=0;for(const c of[...new Set(t.values())].sort((e,t)=>e-t)){const l=[...t].filter(([,e])=>e===c).map(([e])=>e).sort(Nl);let d=0,u=0;for(const t of l){const c=s.get(t);c||Cl("GEOMETRY_MISSING","Missing node measurement.",{nodeIds:[t]});const l=o?c.width:c.height,h=o?c.height:c.width;u=Math.max(u,l);const p=r?-a-l:a,f=o?{x:p,y:d}:{x:d,y:p},m=i.get(t);n.set(t,{x:"x"===m?.pin||"both"===m?.pin?m.position.x:f.x,y:"y"===m?.pin||"both"===m?.pin?m.position.y:f.y}),d+=h+e.options.nodeGap}a+=u+e.options.rankGap}}function xd(e,t){const n=e.previous;if(!n)return;let o=Uf.get(n);return o||(o=new Map(n.nodes.map(e=>[e.id,e])),Uf.set(n,o)),o.get(t)}function bd(e){return{topology:"strict-dag",routing:"orthogonal",bundles:"none",rankGap:96,nodeGap:32,laneGap:6,terminalStub:12,obstaclePadding:6,maxSweeps:8,seed:0,...e,weights:{crossings:8,alignment:2,length:1,bends:1,congestion:4,displacement:4,reorder:3,...e.weights}}}function wd(e){const t=e.options;["route-only","optimize"].includes(t.mode)&&["strict-dag","feedback"].includes(t.topology)&&["orthogonal","polyline","smooth"].includes(t.routing)&&["none","parallel","overview"].includes(t.bundles)&&["LR","RL","TB","BT"].includes(e.view.direction)||Cl("CAPABILITY_OPTIONS","Unknown layout mode, direction, routing or topology.");for(const e of["rankGap","nodeGap","laneGap","terminalStub","obstaclePadding","maxSweeps"])Dl(t[e],e);(!Number.isInteger(t.maxSweeps)||t.maxSweeps>100)&&Cl("CONSTRAINT_BUDGET","maxSweeps must be an integer in [0,100]."),Number.isSafeInteger(t.seed)||Cl("CONSTRAINT_SEED","Seed must be a safe integer."),Object.entries(t.weights??{}).forEach(([e,t])=>Dl(t,e)),"optimize"===t.mode&&e.prepared.graph.nodes.some(e=>e.parentId)&&Cl("CAPABILITY_COMPOUND_OPTIMIZE","Compound graphs require authored positions in this adapter.");const n=/* @__PURE__ */new Set;for(const t of e.view.edgeHints??[])!n.has(t.edgeId)&&e.prepared.graph.edges.some(e=>e.id===t.edgeId)||Cl("IDENTITY_EDGE_HINT","Edge hints must refer to unique existing edges."),n.add(t.edgeId),void 0!==t.priority&&Dl(t.priority,"priority")}function Md(e){return{schemaVersion:"semiotic.compositional-layout.v0.1",requestId:e.requestId,semanticHash:e.prepared.semanticHash,graphRevision:e.prepared.graph.revision,viewRevision:e.view.revision,geometryRevision:e.geometry.revision,engineId:"semiotic-compositional",engineVersion:"0.1.0",optionsHash:El(e.options),status:"complete",nodes:[],edges:[],bundles:[],bounds:{x:0,y:0,width:0,height:0},metrics:{crossings:0,channelCongestion:0,alignmentError:0,totalRouteLength:0,bendCount:0,nodeDisplacement:0,reorderedParts:0,hardConstraintViolations:0,routedEdgeCount:0,omittedEdgeCount:e.prepared.graph.edges.length,completedSweeps:0},diagnostics:[]}}function vd(e,t,n,o){const r=dd(e,t,n,o),i=md(e,r),s="LR"===e.view.direction||"RL"===e.view.direction,a=[],c=[],l=new Map(e.view.edgeHints?.map(e=>[e.edgeId,e])),d=[...e.prepared.graph.edges].sort((e,t)=>Nl(l.get(e.id)?.laneId??"",l.get(t.id)?.laneId??"")||Nl(e.id,t.id)),u=e=>JSON.stringify([Sl($l(e.source,e.sourceEndpoint)),Sl($l(e.target,e.targetEndpoint))]),h=/* @__PURE__ */new Map;for(const e of d){const t=u(e),n=h.get(t)??[];n.push(e.id),h.set(t,n)}const p=/* @__PURE__ */new Map;for(const e of d){const t=JSON.stringify([e.source,e.target]),n=p.get(t)??[];n.push(e.id),p.set(t,n)}const f=r.nodes.filter(e=>"node"===e.semantic.endpoint.kind),m=e.options.obstaclePadding,g=f.map(e=>({x:e.rect.x-m,y:e.rect.y-m,width:e.rect.width+2*m,height:e.rect.height+2*m})),y=e.prepared.graph.nodes.some(e=>e.parentId);for(const t of d){const n=ud(e,r,t.id,$l(t.source,t.sourceEndpoint),"source"),o=ud(e,r,t.id,$l(t.target,t.targetEndpoint),"target"),a=h.get(u(t)),l=(a.indexOf(t.id)-(a.length-1)/2)*e.options.laneGap;a.length>1&&0===e.options.laneGap&&"none"===e.options.bundles&&Cl("ROUTING_COINCIDENT","Exact duplicates require lane space or an explicit bundle.",{edgeIds:a});const d=(e,t)=>({x:e.x-t.y*l,y:e.y+t.x*l}),m=d(n.escape,n.normal),x=d(o.escape,{x:-o.normal.x,y:-o.normal.y});y&&f.some(e=>e.id!==n.displayNodeId&&e.id!==o.displayNodeId&&e.id!==t.source&&e.id!==t.target&&[n.anchor,o.anchor].some(t=>t.x>e.rect.x&&t.x<e.rect.x+e.rect.width&&t.y>e.rect.y&&t.y<e.rect.y+e.rect.height))&&Cl("CAPABILITY_COMPOUND_ROUTING","Cross-hierarchy routing needs collapsed authored boundary exposures.",{edgeIds:[t.id]});const b=n.displayNodeId!==t.source||o.displayNodeId!==t.target?g.filter((e,r)=>!(n.displayNodeId!==t.source&&f[r].id===t.source||o.displayNodeId!==t.target&&f[r].id===t.target)):g;(ed(n.escape,m,b)||ed(x,o.escape,b))&&Cl("ROUTING_LANE_SPACE","Pinned terminal lanes have insufficient clearance.",{edgeIds:[t.id]});const w=p.get(JSON.stringify([t.source,t.target])),M=nd(m,x,b,(w.indexOf(t.id)-(w.length-1)/2)*e.options.laneGap,s);M||Cl("ROUTING_NO_PATH","No route found within the adapter's visibility-grid budget.",{edgeIds:[t.id]});const v=td([n.anchor,n.escape,...M,o.escape,o.anchor]),k=od(JSON.stringify([t.id,"route"]),v,"smooth"===e.options.routing,b),I=e=>r.hidden.get(e)??e,S=I(t.source)!==I(t.target)&&i.get(I(t.source))>=i.get(I(t.target));c.push({edgeId:t.id,source:n,target:o,sections:[k],bounds:k.bounds,feedback:S})}const x=new Set(d.filter(e=>"none"!==l.get(e.id)?.alignment).map(e=>e.id)),{metrics:b,partial:w}=ad(c,s,x);b.channelCongestion>1e-8&&a.push({code:"ROUTING_CONGESTION",severity:"warning",message:"Some routes share undeclared segments. Every edge is retained; use the connection table to disambiguate.",edgeIds:c.map(e=>e.edgeId)}),w&&a.push({code:"ROUTING_METRIC_BUDGET",severity:"warning",message:"Crossing count is a lower bound after two million segment comparisons."}),"estimated"===e.geometry.basis&&a.push({code:"GEOMETRY_ESTIMATED",severity:"warning",message:"Attachment geometry is provisional."}),"smooth"===e.options.routing&&a.push({code:"ROUTING_CURVE_METRICS",severity:"info",message:"Curve length and crossings use 24 samples per corner; bounds use conservative control envelopes."});const M=[];if("none"!==e.options.bundles){const t=/* @__PURE__ */new Map;for(const e of c){const n=d.find(t=>t.id===e.edgeId),o=JSON.stringify(["bundle",e.source.displayNodeId,e.target.displayNodeId,e.source.exposureId??Sl(e.source.semantic),e.target.exposureId??Sl(e.target.semantic),n.kind??"unspecified",l.get(n.id)?.bundleGroup??null]),r=t.get(o)??[];r.push(e),t.set(o,r)}for(const[n,o]of t)o.length>1&&M.push({id:n,kind:e.options.bundles,memberEdgeIds:o.map(e=>e.edgeId),path:o[0].sections,count:o.length,countStatus:"exact",semanticKind:d.find(e=>e.id===o[0].edgeId)?.kind??"unspecified"})}return{...Md(e),status:w||b.channelCongestion>1e-8||"estimated"===e.geometry.basis?"degraded":"complete",nodes:r.nodes,edges:c,bundles:M,bounds:Hl([...r.nodes.map(e=>e.rect),...c.map(e=>e.bounds)]),metrics:b,diagnostics:a}}function kd(e,t,n){const o=e.metrics,r=bd(t.options).weights,i=Math.max(1,t.options.rankGap),s=t.view.nodes.reduce((e,t)=>"rows"===t.partLayout?.kind?e+Wl(t.partLayout.order).filter((e,o)=>n.get(t.nodeId)?.[o]!==e).length:e,0),a=e.nodes.filter(e=>"node"===e.semantic.endpoint.kind),c=a.reduce((e,n)=>{const o=xd(t,n.id);return e+(o?Gf(o.rect,n.rect):0)},0);return r.crossings*o.crossings+r.alignment*o.alignmentError/i+r.length*o.totalRouteLength/i+r.bends*o.bendCount+r.congestion*o.channelCongestion/i+r.reorder*s/Math.max(1,a.length)+r.displacement*c/i}function Id(e){const t={...e,options:bd(e.options)};try{wd(t),hd(t),fd(t);const e=Jl(t.geometry),n=gd(t),o=/* @__PURE__ */new Map;for(const e of t.view.nodes)"rows"===e.partLayout?.kind&&o.set(e.nodeId,Wl(e.partLayout.order));if("optimize"===t.options.mode){const e=t.prepared.graph,o=pd(e.nodes.map(e=>e.id),e.edges.filter(e=>e.source!==e.target).map(e=>[e.source,e.target]));o||"strict-dag"!==t.options.topology||Cl("TOPOLOGY_PROJECTION_CYCLE","Owner projection is cyclic."),yd(t,o??new Map([...e.nodes].sort((e,t)=>Nl(e.id,t.id)).map((e,t)=>[e.id,t])),n)}let r=vd(t,e,n,o),i=kd(r,t,o),s=0,a=0;const c=()=>{a++;try{const s=vd(t,e,n,o),a=kd(s,t,o);if(a+1e-8<i)return r=s,i=a,!0}catch(e){if(!(e instanceof _f))throw e}return!1};if("optimize"===t.options.mode)for(let e=0;e<t.options.maxSweeps&&a<256;e++){let e=!1;for(const n of[...t.view.nodes].sort((e,t)=>Nl(e.nodeId,t.nodeId))){if("rows"!==n.partLayout?.kind)continue;const t=o.get(n.nodeId);e:for(let r=0;r<t.length-1&&a<256;r++)for(let i=r+1;i<t.length&&a<256;i++){if(!Gl(n.partLayout.order,t[r],t[i]))continue;const s=[...t];if([s[r],s[i]]=[s[i],s[r]],o.set(n.nodeId,s),c()){e=!0;break e}o.set(n.nodeId,t)}}const i="LR"===t.view.direction||"RL"===t.view.direction,l=new Map(r.nodes.map(e=>[e.id,e.semantic.nodeId]));for(const o of r.nodes){if(a>=256)break;if("node"!==o.semantic.endpoint.kind)continue;const s=t.view.constraints?.find(e=>e.nodeId===o.id);if("both"===s?.pin||s?.pin===(i?"y":"x"))continue;const d=r.edges.filter(e=>"none"!==t.view.edgeHints?.find(t=>t.edgeId===e.edgeId)?.alignment).flatMap(e=>l.get(e.source.displayNodeId)===o.id?[i?e.target.anchor.y-e.source.anchor.y:e.target.anchor.x-e.source.anchor.x]:l.get(e.target.displayNodeId)===o.id?[i?e.source.anchor.y-e.target.anchor.y:e.source.anchor.x-e.target.anchor.x]:[]).sort((e,t)=>e-t);if(!d.length)continue;const u=d[Math.floor(d.length/2)],h=n.get(o.id);Math.abs(u)<1e-8||(n.set(o.id,{x:h.x+(i?0:u),y:h.y+(i?u:0)}),c()?e=!0:n.set(o.id,h))}if(s++,!e)break}const l=t.view.nodes.reduce((e,t)=>"rows"===t.partLayout?.kind?e+Wl(t.partLayout.order).filter((e,n)=>o.get(t.nodeId)?.[n]!==e).length:e,0),d=[...r.diagnostics,{code:"LAYOUT_TERMINATION",severity:"info",message:"route-only"===t.options.mode?"Authored positions and order retained.":`Bounded local optimization completed ${s} sweeps and ${a} candidate evaluations${a>=256?" (candidate budget reached)":""}.`}];return Al({...r,metrics:{...r.metrics,completedSweeps:s,reorderedParts:l,nodeDisplacement:r.nodes.reduce((e,n)=>{if("node"!==n.semantic.endpoint.kind)return e;const o=xd(t,n.id);return e+(o?Gf(o.rect,n.rect):0)},0)},diagnostics:d})}catch(e){if(!(e instanceof _f))throw e;return Al({...Md(t),status:"infeasible",diagnostics:e.diagnostics,metrics:{...Md(t).metrics,hardConstraintViolations:1}})}}function Sd(e,t){const{semantics:n,views:o,hidden:r}=ld(e),i=/* @__PURE__ */new Set;for(const e of n.values())if(!r.has(e.id)&&(i.add(Sl($l(e.id))),"exploded"===o.get(e.id)?.mode))for(const t of e.parts??[])i.add(Sl($l(e.id,{kind:"part",partId:t.id})));for(const e of t.nodes){const t=Sl(e.semantic);i.delete(t)||Cl("IDENTITY_SOLVED_NODE","Unknown, hidden or repeated display-node semantics."),_l(e.rect);const r=n.get(e.semantic.nodeId),s="node"===e.semantic.endpoint.kind,a=/* @__PURE__ */new Set;for(const t of e.parts??[])s&&!a.has(t.partId)&&r.parts?.some(e=>e.id===t.partId)&&Sl(t.semantic)===Sl($l(r.id,{kind:"part",partId:t.partId}))||Cl("IDENTITY_SOLVED_PART","Solved parts must retain unique owner-local semantic identities."),a.add(t.partId),_l(t.rect);s&&"summary"!==o.get(r.id)?.mode&&(r.parts??[]).some(e=>!a.has(e.id))&&Cl("IDENTITY_SOLVED_PART","A visible owner is missing solved parts.")}i.size&&Cl("IDENTITY_SOLVED_NODE","A feasible solution must cover the requested visible projection.")}function $d(e,t){if(["complete","degraded","infeasible"].includes(t.status)||Cl("REVISION_STATUS","Unknown layout status."),"infeasible"===t.status)return;const n=new Map(t.nodes.map(e=>[e.id,e])),{hidden:o}=ld(e);n.size!==t.nodes.length&&Cl("IDENTITY_SOLVED_NODE","Duplicate display node ID."),Sd(e,t),_l(t.bounds);const r=new Map(e.prepared.graph.edges.map(e=>[e.id,e])),i=/* @__PURE__ */new Set;for(const e of t.edges){const s=r.get(e.edgeId);s&&!i.has(e.edgeId)||Cl("IDENTITY_SOLVED_EDGE","Unknown or repeated solved edge ID."),i.add(e.edgeId),Sl(e.source.semantic)===Sl($l(s.source,s.sourceEndpoint))&&Sl(e.target.semantic)===Sl($l(s.target,s.targetEndpoint))||Cl("ENDPOINT_SOLVED_RETARGET","An engine changed the semantic endpoint.",{edgeIds:[e.edgeId]}),_l(e.bounds),n.has(e.source.displayNodeId)&&n.has(e.target.displayNodeId)&&e.sections.length||Cl("GEOMETRY_SOLVED_ROUTE","A route needs display owners and path sections.");for(const t of[e.source,e.target]){const r=n.get(t.displayNodeId),i=o.get(t.semantic.nodeId)??t.semantic.nodeId;r.semantic.nodeId===i&&Kl(r.rect,t.anchor)||Cl("GEOMETRY_TERMINAL_OWNER","A terminal must attach to its own display node.",{edgeIds:[e.edgeId]})}let a=e.source.anchor;for(const n of e.sections){_l(n.bounds),(n.points.length<2||Gf(a,n.points[0])>1e-7)&&Cl("GEOMETRY_ROUTE_CONTINUITY","Route skeleton does not meet its terminal or preceding section.");const o=n.commands;o?.length&&("M"!==o[0].kind||Gf(a,o[0].point)>1e-7||Gf(o[o.length-1].point,n.points[n.points.length-1])>1e-7)&&Cl("GEOMETRY_ROUTE_COMMANDS","Final commands and skeleton disagree at terminals.");const r=[...n.points,...(o??[]).flatMap(e=>"C"===e.kind?[e.point,e.control1,e.control2]:[e.point])];for(const o of r)Number.isFinite(o.x)&&Number.isFinite(o.y)&&Kl(n.bounds,o)&&Kl(e.bounds,o)&&Kl(t.bounds,o)||Cl("GEOMETRY_ROUTE_BOUNDS","Route geometry must be finite and within its conservative bounds.");a=n.points[n.points.length-1]}Gf(a,e.target.anchor)>1e-7&&Cl("GEOMETRY_ROUTE_TERMINAL","Route misses its target anchor.")}i.size===r.size&&t.metrics.routedEdgeCount===i.size&&0===t.metrics.omittedEdgeCount||Cl("ROUTING_OMITTED_EDGE","A feasible transaction must represent every requested connection."),"complete"===t.status&&0!==t.metrics.hardConstraintViolations&&Cl("CONSTRAINT_SOLVED","A complete result cannot contain hard constraint violations.");for(const e of t.bundles)(new Set(e.memberEdgeIds).size!==e.memberEdgeIds.length||e.count!==e.memberEdgeIds.length||e.memberEdgeIds.some(e=>!r.has(e)))&&Cl("IDENTITY_BUNDLE","Bundle counts and memberships must match materialized edges.")}async function Nd(e,t,n){const o={...e,options:bd(e.options)};n?.aborted&&Cl("REVISION_CANCELLED","Layout request was cancelled.");const r=t.capabilities,i=[["route-only"===o.options.mode||!!e.view.constraints?.some(e=>!!e.pin),r.fixedPositions,"fixed positions"],[!!e.view.anchors?.length,r.fixedPortPositions,"exact anchors"],[!!e.view.nodes.some(e=>"rows"===e.partLayout?.kind),r.constrainedPartOrder,"part order"],[e.prepared.graph.edges.length>new Set(e.prepared.graph.edges.map(e=>JSON.stringify([e.source,e.target]))).size,r.multiedges,"multiedges"],["orthogonal"===o.options.routing,r.orthogonalRouting,"orthogonal routing"]];for(const[e,t,n]of i)e&&!t&&Cl("CAPABILITY_ENGINE",`Engine does not support ${n}.`);const s=await t.layout(o,n);return n?.aborted&&Cl("REVISION_CANCELLED","Layout request was cancelled."),s.requestId===e.requestId&&s.semanticHash===e.prepared.semanticHash&&s.graphRevision===e.prepared.graph.revision&&s.viewRevision===e.view.revision&&s.geometryRevision===e.geometry.revision&&s.optionsHash===El(o.options)&&s.engineId===t.id&&s.engineVersion===t.version||Cl("REVISION_RESPONSE","Engine response does not match the requested revision tuple."),$d(o,s),Al(s)}function Ed(e){const{prepared:t,solved:n}=e;"infeasible"!==n.status&&n.semanticHash===t.semanticHash&&n.graphRevision===t.graph.revision||Cl("REVISION_SCENE","Scene needs a feasible solution matching the semantic revision.");const o=new Map(t.graph.nodes.map(e=>[e.id,e])),r=new Map(t.graph.edges.map(e=>[e.id,e]));return{sceneNodes:n.nodes.flatMap(t=>{const n=o.get(t.semantic.nodeId),r="node"===t.semantic.endpoint.kind,i={type:"rect",id:t.id,x:t.rect.x,y:t.rect.y,w:t.rect.width,h:t.rect.height,label:n.label??n.id,datum:{...n,semantic:t.semantic},style:{fill:r?e.nodeFill??"#edf2f7":e.partFill??"#c9dce8",stroke:"#556779",strokeWidth:1}};return e.showParts&&r?[i,...(t.parts??[]).filter(e=>!e.clipped).map(o=>({type:"rect",id:JSON.stringify(["part-hit",t.id,o.partId]),x:t.rect.x+o.rect.x,y:t.rect.y+o.rect.y,w:o.rect.width,h:o.rect.height,label:n.parts?.find(e=>e.id===o.partId)?.label??o.partId,datum:{id:o.partId,ownerId:n.id,semantic:o.semantic},style:{fill:e.partFill??"#c9dce8"}}))]:[i]}),sceneEdges:n.edges.map(t=>({type:"curved",id:t.edgeId,pathD:t.sections.map(rd).join(" "),datum:{...r.get(t.edgeId),sourceTerminal:t.source,targetTerminal:t.target},label:t.edgeId,style:{fill:"none",stroke:e.edgeStroke??"#467895",strokeWidth:1.5}}))}}function Ad(e,t=Xf){const n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set;let r=!1;const i=t=>{try{e.postMessage({type:"cancel",requestId:t})}catch{}},s=({data:e})=>{if("result"!==e.type&&"error"!==e.type)return;const t=n.get(e.requestId);t&&(t.clean(),n.delete(e.requestId),"result"===e.type?t.resolve(e.solved):t.reject(new Error(e.message)))},a=e=>{for(const t of n.values())t.clean(),t.reject(new Error(`REVISION_WORKER_FAILED: ${e}`));n.clear()},c=e=>{"messageerror"===e?.type?a("A worker message could not be deserialized."):"error"===e?.type&&a(e.message||"The worker reported an error.")},l=e;return e.addEventListener("message",s),l.addEventListener?.("error",c),l.addEventListener?.("messageerror",c),{...t,layout:(t,s)=>new Promise((a,c)=>{if(r||s?.aborted)return void c(new Error("REVISION_CANCELLED"));if(o.has(t.requestId))return void c(new Error("REVISION_REQUEST_ID: request IDs must be unique for the engine's lifetime."));o.add(t.requestId);const l=()=>{n.delete(t.requestId),s?.removeEventListener("abort",l),c(new Error("REVISION_CANCELLED")),i(t.requestId)};n.set(t.requestId,{resolve:a,reject:c,clean:()=>s?.removeEventListener("abort",l)}),s?.addEventListener("abort",l,{once:!0});try{e.postMessage({type:"solve",request:t})}catch(e){n.delete(t.requestId),s?.removeEventListener("abort",l),c(e)}}),dispose(){r=!0,e.removeEventListener("message",s),l.removeEventListener?.("error",c),l.removeEventListener?.("messageerror",c);for(const[e,t]of n)t.clean(),t.reject(new Error("REVISION_CANCELLED")),i(e);n.clear(),o.clear()}}}function Cd(e,t=Xf){const n=/* @__PURE__ */new Map,o=({data:o})=>{if("cancel"===o.type)return void n.get(o.requestId)?.abort();if("solve"!==o.type)return;const r=o.request,i=new AbortController;n.get(r.requestId)?.abort(),n.set(r.requestId,i),Promise.resolve().then(()=>t.layout(r,i.signal)).then(t=>{i.signal.aborted||e.postMessage({type:"result",requestId:r.requestId,solved:t})}).catch(t=>{if(!i.signal.aborted)try{e.postMessage({type:"error",requestId:r.requestId,message:t instanceof Error?t.message:"Worker layout failed."})}catch{}}).finally(()=>{n.get(r.requestId)===i&&n.delete(r.requestId)})};return e.addEventListener("message",o),()=>{e.removeEventListener("message",o),n.forEach(e=>e.abort()),n.clear()}}function Od(e,t){const n=e.nodes.find(e=>e.id===t.nodeId);n&&"infeasible"!==e.status||Cl("GEOMETRY_SCROLL_OWNER","Scroll projection requires a feasible visible owner."),_l(t.viewport),Dl(t.offsetY,"offsetY");const o=t.viewport;(o.x<0||o.y<0||o.x+o.width>n.rect.width||o.y+o.height>n.rect.height)&&Cl("GEOMETRY_SCROLL_VIEWPORT","Row viewport must be inside the owner.");const r=n.rect.y+o.y,i=r+o.height,s=e=>{if(e.displayNodeId!==n.id||"part"!==e.semantic.endpoint.kind)return e;(0!==e.normal.y||Math.abs(e.anchor.x-n.rect.x)>1e-7&&Math.abs(e.anchor.x-n.rect.x-n.rect.width)>1e-7)&&Cl("CAPABILITY_SCROLL_ANCHOR","This scroll projection requires horizontal boundary row slots.");const o=e.anchor.y-t.offsetY,s=o>=r&&o<=i,a=Math.max(r,Math.min(i,o));return{...e,anchor:{...e.anchor,y:a},escape:{...e.escape,y:a},precision:s?e.precision:"proxy",exposureId:s?e.exposureId:JSON.stringify(["scroll",Sl(e.semantic),e.end])}},a=e.nodes.map(e=>e.id!==n.id?e:{...e,parts:e.parts?.map(e=>{const n={...e.rect,y:e.rect.y-t.offsetY};return{...e,rect:n,clipped:n.y<o.y||n.y+n.height>o.y+o.height}})}),c=e.edges.map(e=>{const t=s(e.source),n=s(e.target);if(t===e.source&&n===e.target)return e;1!==e.sections.length&&Cl("CAPABILITY_SCROLL_SECTIONS","The built-in scroll repair requires a single route section.");const o=e.sections[0],r=o.points.slice(1,-1),i=td([t.anchor,t.escape,...r,n.escape,n.anchor]),a=od(o.id,i,!1,[]);return{...e,source:t,target:n,sections:[a],bounds:a.bounds}}),l=ad(c,!0,new Set(c.map(e=>e.edgeId)));return Al({...e,viewRevision:t.viewRevision,nodes:a,edges:c,bundles:[],bounds:Hl([...a.map(e=>e.rect),...c.map(e=>e.bounds)]),metrics:{...e.metrics,...l.metrics,completedSweeps:0},status:"degraded",diagnostics:[...e.diagnostics,{code:"GEOMETRY_SCROLL_PROXIES",severity:"info",message:"Clipped row endpoints use disclosed continuation proxies; terminal routes were locally repaired without a global solve.",nodeIds:[n.id]}]})}var Td,Pd,Rd,jd,Fd,Ld,zd=Object.create,Dd=Object.defineProperty,_d=Object.getOwnPropertyDescriptor,Wd=Object.getOwnPropertyNames,qd=Object.getPrototypeOf,Gd=Object.prototype.hasOwnProperty,Bd=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[Wd(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},Yd=(e,t)=>{for(var n in t)Dd(e,n,{get:t[n],enumerable:!0})},Vd=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Wd(t))Gd.call(e,r)||r===n||Dd(e,r,{get:()=>t[r],enumerable:!(o=_d(t,r))||o.enumerable});return e},Hd=(e,t,n)=>(n=null!=e?zd(qd(e)):{},Vd(!t&&e&&e.__esModule?n:Dd(n,"default",{value:e,enumerable:!0}),e)),Ud=Bd({"src/components/charts/shared/minMax.ts"(){}}),Xd=Bd({"src/components/recipes/atlas/entityCounts.ts"(){}}),Kd=Bd({"src/components/recipes/atlas/ids.ts"(){}}),Jd=Bd({"src/components/recipes/atlas/ledger.ts"(){Kd(),Td={exact:0,estimated:1,incomplete:2,unknown:3}}}),Zd=Bd({"src/components/recipes/atlas/compare.ts"(){Xd(),Jd()}}),Qd=Bd({"src/components/recipes/atlas/completeness.ts"(){Kd()}}),eu=Bd({"src/components/recipes/atlas/directedGraph.ts"(){}}),tu=Bd({"src/components/recipes/atlas/rootedForest.ts"(){eu()}}),nu=Bd({"src/components/recipes/atlas/forests.ts"(){Kd(),tu()}}),ou=Bd({"src/components/recipes/atlas/types.ts"(){Pd="0.2",Rd=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],jd=["serial-chain","fan-out","fan-in"],Fd=[...jd,"repeated-state-episode"]}}),ru=Bd({"src/components/recipes/atlas/motifs.ts"(){Kd(),ou()}}),iu=Bd({"src/components/recipes/atlas/prefixForest.ts"(){Kd()}}),su=Bd({"src/components/recipes/atlas/sections.ts"(){Kd()}}),au=Bd({"src/components/recipes/atlas/support.ts"(){}}),cu=Bd({"src/components/recipes/atlas/requiredPaths.ts"(){eu()}}),lu=Bd({"src/components/charts/shared/dataRecords.ts"(){}}),du=Bd({"src/components/recipes/atlas/validateShape.ts"(){lu(),Ld=["entity","occurrence","embedding","work-item"]}}),uu=Bd({"src/components/recipes/atlas/validate.ts"(){Kd(),du(),ou()}}),hu={};Yd(hu,{prepareNetworkAtlas:()=>J});var pu=Bd({"src/components/recipes/atlas/prepare.ts"(){Zd(),Qd(),nu(),Jd(),ru(),iu(),su(),au(),cu(),uu(),lu()}}),fu=Bd({"src/components/recipes/atlas/capsules.ts"(){}}),mu=Bd({"src/components/recipes/atlas/profile.ts"(){Xd(),Zd()}}),gu={};Yd(gu,{assignedDenominator:()=>p,prepareMotifBraid:()=>oe,ribbonSupportsRoute:()=>re});var yu,xu,bu,wu,Mu,vu,ku=Bd({"src/components/recipes/atlas/braid.ts"(){fu(),Zd(),au(),Kd(),mu()}}),Iu=Bd({"src/components/stream/layouts/forceLayoutNodeSize.ts"(){yu=require("d3-scale"),Ud()}}),Su=Bd({"src/components/stream/layouts/forceLayoutEdgeWeight.ts"(){}}),$u=Bd({"src/components/stream/layouts/forceLayoutWorkerPolicy.ts"(){Iu(),Su(),xu=4e4}}),Nu=Bd({"src/components/stream/workerModuleUrl.ts"(){}}),Eu=Bd({"src/components/stream/moduleWorkerSession.ts"(){bu=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.failure=null,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{if(this.dead)return;let t;try{t=this.options.parseMessage(e.data)}catch(e){return void this.fail(e instanceof Error?e:new Error(String(e)))}const n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(new Error(`${this.options.name} worker response missing requestId`)));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onmessageerror=()=>{this.fail(new Error(`${this.options.name} worker response could not be deserialized`))},this.worker.onerror=e=>{this.fail(new Error(e.message||`${this.options.name} worker failed`))}}get isDead(){return this.dead}fail(e){this.dead||(this.failure=e,this.rejectAll(e),this.terminate())}request(e,t){if(this.dead)return Promise.reject(new Error(`${this.options.name} worker session is closed`));if(t?.aborted)return Promise.reject(ue(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{let i;const s=()=>{const e=1===this.pending.size;this.pending.delete(n),a(),r(ue(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},a=()=>{t?.removeEventListener("abort",s),clearTimeout(i)};this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",s,{once:!0}),void 0!==this.options.requestTimeoutMs&&(i=setTimeout(()=>{this.fail(new Error(`${this.options.name} worker request timed out`))},this.options.requestTimeoutMs));try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(e instanceof Error?e:new Error(String(e)))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(new Error(`${this.options.name} worker terminated`)),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}}}}),Au={};Yd(Au,{DEFAULT_FORCE_WORKER_THRESHOLD:()=>xu,ForceLayoutWorkerSession:()=>Mu,_resetSharedForceLayoutSessionForTest:()=>ge,canUseForceWorker:()=>ce,createForceLayoutWorker:()=>me,createFrameForceWorkerRequest:()=>le,runForceLayoutWorker:()=>ye,shouldUseForceWorker:()=>ae});var Cu,Ou=Bd({"src/components/stream/layouts/forceLayoutWorkerClient.ts"(){Nu(),Eu(),$u(),$u(),wu={},Mu=class{constructor(e=me()){this.session=new bu({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=pe(t);if(o)return{requestId:n,ok:!1,error:he(o)};if(!t?.positions||"object"!=typeof t.positions||Array.isArray(t.positions)||!Object.values(t.positions).every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y)))throw new Error("Malformed force worker response");return{requestId:n,ok:!0,payload:{positions:t.positions}}}})}get isDead(){return this.session.isDead}get failure(){return this.session.failure}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},vu=/* @__PURE__ */fe(()=>new Mu)}}),Tu={};Yd(Tu,{CompositionalGraphError:()=>_f,CompositionalLayoutController:()=>Kf,CompositionalMeasurementTransaction:()=>Zf,DEFAULT_AREA_PER_ANNOTATION:()=>Fp,DEFAULT_GLYPH_ANCHOR:()=>If,DEFAULT_GLYPH_VIEWBOX:()=>kf,DEFAULT_HIT_RADIUS:()=>wf,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>mh,GRID_FUEL_KEYS:()=>Xp,GRID_FUEL_LABELS:()=>Kp,LayoutCache:()=>Ru,SYMBOL_SEQUENCE:()=>Yu,TAU:()=>vf,absorbRegion:()=>Ra,activeCountOverDomain:()=>Li,addPoints:()=>Ds,adjacencyFlowLayout:()=>fp,adjacencyMatrix:()=>nl,aggregateAdjacencyFlow:()=>mr,aggregateRegionCounts:()=>ba,allocateCells:()=>Le,analyzeNetEnsemble:()=>qo,angleScale:()=>js,annotationBudget:()=>Qr,annotationDensity:()=>ti,annotationLayout:()=>bi,arcLayout:()=>Qc,arcPath:()=>el,arrivalReplay:()=>Kc,axisFixedForceLayout:()=>rf,axisFixedForcePositions:()=>Xi,balanceSnapshotsToFlows:()=>_e,bandLabel:()=>Fo,betweenness:()=>ca,bfsDistances:()=>ia,bobaLayout:()=>Pp,bodyGroupSpec:()=>Fa,boundsOf:()=>Ro,boxEdgeAnchors:()=>qi,buildAdjacency:()=>oa,buildTooltipEntries:()=>Zs,bulletLayout:()=>Ip,calendarLayout:()=>lh,capacitatedRegion:()=>Ta,chargeGateRegion:()=>Aa,circularLayout:()=>tl,clamp:()=>xe,classifyReserve:()=>ki,closeness:()=>la,clustering:()=>da,collidersFromScales:()=>Yc,comparePhysicsTrace:()=>tc,composePhysicsControllers:()=>xc,compositionalDagEngine:()=>Xf,compositionalDagLayout:()=>Jf,compositionalEndpointKey:()=>Sl,compositionalLayoutOptions:()=>bd,compositionalPath:()=>rd,compositionalRowGeometry:()=>Bl,computeTransitDiagramPositions:()=>qn,countPairwiseCrossings:()=>ks,createCapacityQueueController:()=>gc,createCompositionalWorkerEngine:()=>Ad,createDagreFit:()=>Pn,createDependencyGateController:()=>kc,createFlextreeFit:()=>An,createLineageDagFit:()=>io,createPortalController:()=>bc,createProcessJourneyLedger:()=>ac,createServiceLevelController:()=>vc,createServiceResourcePoolController:()=>wc,cubicPath:()=>Vi,cubicPoint:()=>Bi,cubicTangent:()=>Yi,curvedEdgePath:()=>_i,cyclicRangeContains:()=>ms,dagreLayout:()=>zh,degree:()=>ra,demandForecastRows:()=>Si,describePhysicsStageGeography:()=>zc,diagnoseTokenEncoding:()=>ot,dimFor:()=>Se,egoNetwork:()=>aa,emitCompositionalScene:()=>Ed,estimateLabelWidth:()=>$s,extractTooltipDatum:()=>Js,fanOutBend:()=>Gi,flextreeLayout:()=>Rh,forceFieldRegion:()=>ja,forceLayout:()=>Ye,forceLayoutAsync:()=>pa,formatMw:()=>Pi,formatReservePct:()=>Ri,formatTooltipValue:()=>Qs,galtonPegs:()=>Vc,generateTokens:()=>tt,geoAreaHitTarget:()=>cs,geoHitTarget:()=>as,geographicDotGridLayout:()=>Ph,geographicGridLayout:()=>Sh,glyphExtent:()=>Ys,glyphFractionClipRect:()=>Vs,glyphPlacement:()=>Bs,gridEventAnnotations:()=>Oi,gridifyGeographicPoints:()=>Ht,groupBy:()=>ve,groupCompletionRows:()=>Ma,hatchFill:()=>Lo,hitTargetPoint:()=>ss,hitTargetRect:()=>ls,hullFromBoxes:()=>jo,installCompositionalWorker:()=>Cd,intervalLanesLayout:()=>nf,isometricLandmarkLayout:()=>bh,isotypeBoltGlyph:()=>Zu,isotypeBusGlyph:()=>Qu,isotypeChipGlyph:()=>Ju,isotypeGhost:()=>Xu,isotypeInk:()=>Hu,isotypeNetworkGlyphs:()=>nh,isotypePaper:()=>Uu,isotypePersonGlyph:()=>th,isotypePersonPath:()=>eh,isotypeServerGlyph:()=>Ku,layoutChipStrip:()=>Ss,layoutCompositionalGraph:()=>Nd,layoutSequence:()=>Is,layoutTokenGrid:()=>nt,legendGroupsFrom:()=>Us,legendSwatches:()=>Xs,lineageDagLayout:()=>Xh,linearAxis:()=>zo,makeShade:()=>Ee,marimekkoLayout:()=>vp,markCallout:()=>Do,matchesHighlight:()=>Ie,mean:()=>Pe,membraneRegion:()=>Ea,mermaidDagLayout:()=>ip,mobileAnnotationStrategy:()=>dl,mobileAreaChartRecipe:()=>yl,mobileBrushAlternatives:()=>Il,mobileChartFamilyRecipe:()=>kl,mobileGeoChartRecipe:()=>Ml,mobileLineChartRecipe:()=>gl,mobileNetworkChartRecipe:()=>wl,mobileOrdinalChartRecipe:()=>xl,mobileScatterplotRecipe:()=>bl,mobileSmallMultipleRecipe:()=>vl,motifBraidLayout:()=>tp,mulberry32:()=>Be,netEnsembleLayout:()=>up,networkEdgeHitTarget:()=>us,networkHitTarget:()=>ds,nonNegativeFinite:()=>Te,normalizePoint:()=>Gs,normalizeScores:()=>ua,normalizeTokenEncoding:()=>Ke,octilinearRoute:()=>Gn,offsetTransitPath:()=>Bn,orderByBarycenter:()=>ws,orderByGroupDegree:()=>Zc,orderExactSmall:()=>vs,orthogonalEdgePath:()=>Wi,packBandsBySilhouette:()=>bs,packIntervals:()=>Fi,packSpanLevels:()=>Ns,packedClusterMatrix:()=>bp,parallelCoordinatesLayout:()=>Np,partitionSharedEdges:()=>Os,patchCompositionalGraph:()=>Ll,physicsChargePoint:()=>Fc,physicsDestination:()=>jc,physicsReferenceEnvelope:()=>Ka,physicsStageColliders:()=>Lc,physicsStageGeography:()=>Rc,placeWithMinGap:()=>ys,pointMagnitude:()=>qs,polarToXY:()=>Ps,portalRegion:()=>Pa,prepareCompositionalGraph:()=>Fl,prepareMotifBraid:()=>bo,prepareNetworkAtlasAsync:()=>xo,pressureFieldRegion:()=>Oa,processChrome:()=>Oc,processJourneyRows:()=>lc,processLaneWalls:()=>La,processStageLayout:()=>Ia,processStageRegions:()=>Na,processVolumePolygons:()=>Da,projectCompositionalScroll:()=>Od,proximityProblem:()=>ha,radiusScale:()=>Fs,readField:()=>we,rectCollide:()=>Hi,refineByAdjacentSwaps:()=>Ms,regionCountsToProjectionRows:()=>wa,reserveAnnotationBands:()=>Ai,reserveClasses:()=>vi,reserveMarginPct:()=>$i,reserveSeries:()=>Ni,ringArcPath:()=>Ls,roundedEnclosure:()=>Po,roundedTransitPath:()=>Yn,routeCompositionalGraph:()=>Id,routeSurfaceRegion:()=>Ca,runLengthEncode:()=>Mf,runs:()=>hs,sampleGeographicDotGrid:()=>mn,scaleArcBand:()=>Es,scalePoint:()=>Ws,sedimentBake:()=>Uc,selectCyclicRange:()=>gs,selectIsometricLandmarks:()=>jt,shade:()=>Ae,shortestArcDelta:()=>fs,shortestPath:()=>sa,signatureKey:()=>$e,spanArcPath:()=>As,spanArcPeakY:()=>Cs,spawnFromTokens:()=>Hc,stackFuelSeries:()=>Ii,stageTargetInVolume:()=>za,subtractPoints:()=>_s,suggestTokenEncoding:()=>st,summarizeOperatingPoint:()=>Ci,symbolExtent:()=>lt,symbolPathString:()=>at,symbolRadius:()=>ct,thresholdBandsForReserve:()=>Ei,tightestHours:()=>Ti,tokenLayer:()=>Et,tokenTaskIntentToCapabilityIntents:()=>it,traceCompositionalGraph:()=>zl,transitDiagramLayout:()=>qh,unitize:()=>qe,unitizeRange:()=>Ge,unwrapDatum:()=>Me,updateProcessJourney:()=>cc,waffleLayout:()=>Fu,withAlpha:()=>Re,wordTrailsLayout:()=>os,wordTrailsProgressiveReveal:()=>ns,wrapValue:()=>ps,xyToAngle:()=>Rs}),module.exports=(Cu=Tu,Vd(Dd({},"__esModule",{value:!0}),Cu));var Pu=require("d3-interpolate"),Ru=class{constructor(e=12){this.maxSize=e,this.store=/* @__PURE__ */new Map}get(e){return this.store.get(e)}set(e,t){this.store.size>=this.maxSize&&this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},ju=require("react"),Fu=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,{plot:i}=e.dimensions;if(i.width<=0||i.height<=0)return{nodes:[]};const s=()=>({nodes:[],overlays:Fe(i,0,e.data.length,"rows","The grid needs positive integer dimensions and enough space for its gutters.",{force:!0})}),a=n*o;if(!Number.isSafeInteger(n)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a)||n<=0||o<=0||!Number.isFinite(r)||r<0)return s();const c=(i.width-r*(o-1))/o;if(c<=0||i.height<=r*(n-1))return s();const l=null==t.categoryAccessor?()=>"_default":be(t.categoryAccessor),d=null==t.valueAccessor?()=>1:be(t.valueAccessor),u=/* @__PURE__ */new Map;for(const t of e.data){const e=String(l(t)),n=Te(Number(d(t)));u.set(e,(u.get(e)??0)+n)}const h=Array.from(u.values()).reduce((e,t)=>e+t,0);if(!(h>0&&Number.isFinite(h)))return{nodes:[],overlays:Fe(i,0,u.size,"categories","Category values must have a finite positive total.")};const p=[.../* @__PURE__ */new Set([...t.categoryOrder??[],...u.keys()])].filter(e=>u.has(e)),f=ze(p.map(e=>({key:e,weight:u.get(e)??0})),a,void 0,!0),m=f.filter(e=>e.cells>0).length,g=Fe(i,m,p.length,"categories","Zero-valued categories and categories rounded to zero cells are omitted."),y=(i.height-(g?18:0)-r*(n-1))/n;if(y<=0)return s();const x="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",b="string"==typeof t.valueAccessor?t.valueAccessor:"value",w=(e,t,n)=>ke(o=>{o("category",e),o("value",u.get(e)??0),o("share",(u.get(e)??0)/h),"category"!==x&&o(x,e),"value"!==b&&o(b,u.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),M=[];let v=0;for(const t of f){const s=e.resolveColor(t.key);for(let e=0;e<t.cells;e++){const a=v%o,l=n-1-Math.floor(v/o);M.push({type:"rect",x:i.x+a*(c+r),y:i.y+l*(y+r),w:c,h:y,style:{fill:s,stroke:"none"},datum:w(t.key,v,t.cells),group:t.key,_transitionKey:`waffle-${t.key}-${e}`}),v++}}return{nodes:M,overlays:g}},Lu=1e-6,zu=require("d3-force"),Du=1e3,_u=80,Wu=100;Ud();var qu,Gu=require("d3-shape"),Bu={circle:Gu.symbolCircle,square:Gu.symbolSquare,triangle:Gu.symbolTriangle,diamond:Gu.symbolDiamond,star:Gu.symbolStar,cross:Gu.symbolCross,wye:Gu.symbolWye},Yu=["circle","triangle","diamond","star","square","chevron","cross","wye"],Vu=/* @__PURE__ */new Map,Hu="#334155",Uu="#f8fafc",Xu="#cbd5e1",Ku={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},Ju={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Zu={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},Qu={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},eh="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",th={viewBox:[18,40],anchor:[.5,1],parts:[{d:eh,fill:"color",stroke:"color",strokeWidth:1.4}]},nh={server:Ku,chip:Ju,bolt:Zu,bus:Qu,person:th},oh="var(--semiotic-primary, #4e79a7)",rh="var(--semiotic-border, #d1d5db)",ih="var(--semiotic-secondary, #9ca3af)",sh="var(--semiotic-bg, #ffffff)",ah=/* @__PURE__ */new Set(Yu),ch=require("d3-interpolate"),lh=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o="utc"===t.timeZone,r=(e,t,n)=>{const r=/* @__PURE__ */new Date(0);return o?(r.setUTCFullYear(e,t,n),r.setUTCHours(0,0,0,0)):(r.setFullYear(e,t,n),r.setHours(0,0,0,0)),r},i=e=>o?e.getUTCFullYear():e.getFullYear(),s=e=>`${i(e)}-${At(o?e.getUTCMonth()+1:e.getMonth()+1)}-${At(o?e.getUTCDate():e.getDate())}`,a=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];if(n instanceof Date)return n;if("string"==typeof n&&/^\d{4}-\d{2}-\d{2}$/.test(n)){const[e,t,o]=n.split("-").map(Number);return r(e,t-1,o)}return new Date(n)},c=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return null==n?NaN:Number(n)},l=/* @__PURE__ */new Map;let d=null;for(const t of e.data){const e=a(t);if(!isFinite(e.getTime()))continue;null==d&&(d=i(e));const n=s(e),o=c(t);Number.isFinite(o)&&l.set(n,(l.get(n)??0)+o)}const u=t.year??d??i(/* @__PURE__ */new Date);let h=1/0,p=-1/0;for(const[e,t]of l)e.startsWith(`${u}-`)&&(t<h&&(h=t),t>p&&(p=t));h===1/0&&(h=0,p=0);const[f,m]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],g=t.missingColor??e.theme.semantic.grid??"#d1d5db",y=e=>{if(p===h)return f;const t=(e-h)/(p-h);return(0,ch.interpolateRgb)(f,m)(t)},x=t.gutter??2,b=t.labelInset??0,w=n.width-b,M=n.height,v=Math.min((w-53*x)/54,(M-6*x)/7);if(v<=0)return{nodes:[]};const k=r(u,0,1),I=((o?k.getUTCDay():k.getDay())-(t.weekStart??0)+7)%7,S=[];for(let e=0;e<54;e++)for(let t=0;t<7;t++){const o=r(u,0,1-I+7*e+t);if(i(o)!==u)continue;const a=s(o),c=l.get(a),d=null==c?g:y(c);S.push({type:"rect",x:n.x+b+e*(v+x),y:n.y+t*(v+x),w:v,h:v,style:{fill:d,stroke:"none"},datum:{date:o,value:c??null,missing:null==c}})}return{nodes:S}},dh=["#739b58","#83a964","#668d52","#8baa68"],uh=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),hh=Hd(require("react")),ph=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),fh=require("react/jsx-runtime"),mh={resource:32,city:64},gh={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},yh={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},xh=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),bh=e=>{const t=Pt(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:dh,i=t*o,s=e.dimensions.width/2,a=(e.dimensions.height-i)/2+o/2,c=jt(e.points,e.config).map(e=>({...e,x:s+(e.column-e.row)*(n/2),y:a+(e.column+e.row)*(o/2)}));return{nodes:c.map(t=>{const i=_t(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??zt(e.config.terrainPalette,s)??zt(gh,s)??gh.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,zt(yh,l)??yh.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,d,u,h,p;return{type:"geoarea",pathData:(d=t.x,u=t.y,h=n,p=o,[`M${d},${u-p/2}`,`L${d+h/2},${u}`,`L${d},${u+p/2}`,`L${d-h/2},${u}`,"Z"].join("")),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,fh.jsx)(Wt,{tiles:c,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??mh.resource,citySize:e.config.citySpriteSize??mh.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},wh={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},Mh={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},vh=require("react/jsx-runtime"),kh=.72,Ih=1.8,Sh=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=(o?Zt(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,n)=>!t.filter||t.filter(e.datum,n)),i=en(r.map(e=>e.datum),t),s=o?r:Qt({...e,points:r.map(e=>e.datum)}),a=i??Ht(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===a.length)return{nodes:[]};const c=Yt(a.map(e=>e.row)),l=Yt(a.map(e=>e.column)),d=Math.max(1,Math.round(c[1]-c[0])+1),u=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(0,t.layoutPadding??8),p=Math.max(1,e.dimensions.width-2*h),f=Math.max(1,e.dimensions.height-2*h),m=p/u,g=f/d,y=m*u,x=g*d,b=(e.dimensions.width-y)/2,w=(e.dimensions.height-x)/2,M=xe(t.cellPadding??.12,0,.8),v=Math.max(1,.5*Math.min(m,g)*(1-M)),k=t.sizeAccessor?a.map(e=>Number(Ut(e.datum,t.sizeAccessor))):[],I=t.sizeDomain??Yt(k),S=t.sizeRange??[.36,1],$=xe(Math.min(S[0],S[1]),.05,1),N=xe(Math.max(S[0],S[1]),$,1),E=a.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=String(Ut(r,t.idAccessor,["id","key","name"])??`grid-${o}`),s=String(Ut(r,t.labelAccessor,["abbr","code","label","name","id"])??i),a=Math.max(1,t.maxLabelLength??4),d=s.length>a?s.slice(0,a):s,u=Ut(r,t.categoryAccessor),h=null==u?void 0:String(u),p=Ut(r,t.fillAccessor),f=null!=p?String(p):h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",y=t.sizeAccessor?Number(Ut(r,t.sizeAccessor)):NaN,x=t.sizeAccessor&&Number.isFinite(y)?Math.sqrt(xe(Vt(y,I),0,1)):1,M=v*($+x*(N-$)),k="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:d,category:h,row:n.row,column:n.column,x:b+(n.column-l[0]+.5)*m,y:w+(n.row-c[0]+.5)*g,radius:M,style:{fill:f,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...k}}}),A=t.shape??"circle";return{nodes:E.map(e=>{return"circle"===A?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===A?Jt(e.x,e.y,e.radius):(t=e.x,n=e.y,o=e.radius,Kt([[t-o,n-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]])),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===A?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:/* @__PURE__ */ /* @__PURE__ */(0,vh.jsx)(tn,{marks:E,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??xe(.23*Math.min(m,g),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},$h=require("react/jsx-runtime"),Nh=10,Eh=25e3,Ah=/* @__PURE__ */new WeakMap,Ch=/* @__PURE__ */new WeakMap,Oh=/* @__PURE__ */new WeakMap,Th=1,Ph=e=>{const t=vn(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,rn(n.dotRadius)??t.cellSize*xe(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,d=s+(a.gridRow+.5)*t.cellSize,u=sn(a,n.categoryAccessor),h=sn(a,n.fillAccessor),p={fill:null!=h?String(h):null!=u?e.resolveColor(String(u)):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},f=`dot-${a.gridRow}-${a.gridColumn}`;return"circle"===o?{type:"point",x:l,y:d,r:r,style:p,datum:a,interactive:!1,pointId:f,_transitionKey:f}:{type:"geoarea",pathData:"hexagon"===o?Sn(l,d,r):In(l,d,r),centroid:[l,d],bounds:[[l-r,d-r],[l+r,d+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:p,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?/* @__PURE__ */ /* @__PURE__ */(0,$h.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?/* @__PURE__ */ /* @__PURE__ */(0,$h.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},cn(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Rh=e=>{const t=e.config??{},n=t.orientation??"vertical",o=t.edgeCurve??"curved",{positions:r,sceneNodes:i,labels:s}=En(e,{...t,nodeWidth:t.nodeWidth??80,nodeHeight:t.nodeHeight??30},`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`),a=[];for(const t of e.edges){const i="string"==typeof t.source?t.source:t.source.id,s="string"==typeof t.target?t.target:t.target.id,c=r.get(i),l=r.get(s);if(!c||!l)continue;const d="vertical"===n?{x:c.x,y:c.y+c.h/2}:{x:c.x+c.w/2,y:c.y},u="vertical"===n?{x:l.x,y:l.y-l.h/2}:{x:l.x-l.w/2,y:l.y};if("line"===o)a.push({type:"line",x1:d.x,y1:d.y,x2:u.x,y2:u.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t.data??t});else{const o=(d.y+u.y)/2,r=(d.x+u.x)/2,i="vertical"===n?`M${d.x},${d.y} C${d.x},${o} ${u.x},${o} ${u.x},${u.y}`:`M${d.x},${d.y} C${r},${d.y} ${r},${u.y} ${u.x},${u.y}`;a.push({type:"curved",pathD:i,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:a,labels:s}},jh=require("react"),Fh=require("react"),Lh=require("./semiotic-network-placement.min.js"),zh=e=>{const t=e.config??{},n=t.edgeStyle??"polyline",o=new Map(e.edges.map(e=>[e,Tn(e)])),{positions:r,sceneNodes:i,labels:s,project:a}=En(e,{...t,nodeWidth:t.nodeWidth??100,nodeHeight:t.nodeHeight??36,labelAccessor:t.labelAccessor??"label"},`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,[...o.values()].flat()),c=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`;for(let e=0;e<s.length;e++){const t=s[e],n=r.get(i[e].id);if(!n)continue;const o=Math.max(1,Math.floor(n.w/(.6*(t.fontSize??11))-2));t.text.length>o&&(t.text=t.text.slice(0,o-1)+"…")}const l=[],d=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id,s=r.get(e),u=r.get(i);if(!s||!u)continue;const h=o.get(t).map(a);if(h.length<2){const e=Cn(s,u),n=Cn(u,s);l.push(On(l.length,n,e,c,Math.min(7,u.w/4,u.h/3))),d.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:c,strokeWidth:1},datum:t.data??t});continue}const p=h[h.length-1],f=h.slice(0,-1).reverse().find(e=>e.x!==p.x||e.y!==p.y);if(f&&l.push(On(l.length,p,f,c,Math.min(7,u.w/4,u.h/3))),"smooth"===n&&h.length>=3){let e=`M${h[0].x},${h[0].y}`;for(let t=1;t<h.length-1;t++){const n=(h[t].x+h[t+1].x)/2,o=(h[t].y+h[t+1].y)/2;e+=` Q${h[t].x},${h[t].y} ${n},${o}`}const n=h[h.length-1];e+=` T${n.x},${n.y}`,d.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}else{const e="M"+h.map(e=>`${e.x},${e.y}`).join(" L ");d.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:d,labels:s,overlays:l.length?(0,jh.createElement)("g",null,(0,jh.createElement)(Lh.NetworkPerspectiveGround,{z:"top"},l)):null,perspective:"manual"}},Dh=require("react"),_h=require("./semiotic-network-placement.min.js"),Wh=e=>"number"==typeof e&&Number.isFinite(e),qh=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:Me(e),wrapper:e})).sort((e,t)=>je(e.id,t.id)),s=e.edges.map(e=>({source:Hn(e.source),target:Hn(e.target),data:Me(e),wrapper:e})).sort((e,t)=>je(e.source,t.source)||je(e.target,t.target)),a=qn(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?Jn(i,s,t,e.resolveColor):void 0,l=Qn(s,t,c),d=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),u=/* @__PURE__ */new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)d.get(e)?.add(n.id),n.color&&u.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),p=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),f=/* @__PURE__ */new Map,m=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=to(n,t),c=(s.length-1)/2*(h+p)+h/2;for(const e of[n.source,n.target])f.set(e,Math.max(f.get(e)??0,c));s.forEach((c,l)=>{d.get(n.source)?.add(c.descriptor.id),d.get(n.target)?.add(c.descriptor.id);const f=no(c.edge,a,t,c.edge.source!==n.source),g=Bn(f?[o,...f,i]:Gn(o,i),(l-(s.length-1)/2)*(h+p)),y=oo(c.edge,c.descriptor),x=Zn(c.descriptor,c.edge,t,e.resolveColor);u.has(c.descriptor.id)||u.set(c.descriptor.id,x),m.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:Yn(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=/* @__PURE__ */new Map,y=[],x=[],b=[],w=e=>String(Vn(e,t)||e.id);if("minimap"===n){const n=/* @__PURE__ */new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of d.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,f.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||je(e.nodes[0].id,t.nodes[0].id));for(const n of o){const o=eo(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(w).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:ke(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),d={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length<=1?y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&u.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:d,id:c,label:a}):(o.forEach((t,i)=>{const a=-Math.PI/2+i/o.length*Math.PI*2,d=-Math.PI/2+(i+1)/o.length*Math.PI*2,h={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:a,endAngle:d,style:{fill:u.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(h)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:d,id:c,label:a}))}}else for(const o of i){const i=a.positions.get(o.id);if(!i)continue;const s=eo(d.get(o.id)??[],t),c=s.length>1||!0===o.data.interchange||!0===o.data.transfer,l=c?t.interchangeRadius??Math.max("primary"===n?7:5,f.get(o.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(o.id,l);const u=w(o),h=null!=t.renderStation;if(y.push({type:"circle",cx:i.x,cy:i.y,r:l,style:h?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:c?"primary"===n?3:2:1.5,opacity:r(o.data)},datum:o.data,accessibleDatum:o.data,accessibility:{label:`${u}${c?", interchange":""}`,tableFields:{station:u,lines:s.join(", ")}},id:o.id,label:u}),t.renderStation){const a={station:o.data,x:i.x,y:i.y,radius:l,lineIds:s,interchange:c,mode:n},d=t.renderStation(a);if(null!=d){if(e.perspective){const[e,n,o,r]=t.stationBounds?.(a)??[l,l,l,l];b.push("ground"===t.chromePlacement?{x:i.x-e,y:i.y-o,width:e+n,height:o+r,z:"top"}:{x:i.x,y:i.y,extent:[e,n,o,r]})}x.push((0,Dh.createElement)("ground"===t.chromePlacement?_h.NetworkPerspectiveGround:_h.NetworkPerspectiveBillboard,{key:o.id,x:i.x,y:i.y,z:"top"},(0,Dh.createElement)("g",{opacity:r(o.data),style:{pointerEvents:"none"}},d)))}}}const M=x.length>0?(0,Dh.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,v={sceneEdges:m,sceneNodes:y,overlays:M,perspective:"manual",...b.length?{perspectiveBounds:b}:{},labels:ro(i,a.positions,d,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return v;const k=(e,t)=>({opacity:r(e.datum,t)});return{...v,restyle:k,restyleEdge:k}},Gh=require("./semiotic-network-placement.min.js");Ud();var Bh=require("./semiotic-network-placement.min.js"),Yh=require("react/jsx-runtime"),Vh=require("react/jsx-runtime"),Hh={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},Uh={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Xh=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.partitionAccessor??"partition",r=t.semanticAccessor??"semantic",i=t.labelAccessor??"label",s=t.storesAccessor??"stores",a=t.backEdgeAccessor??"isBackEdge",c=t.edgeTypeAccessor??"edgeType",l={...Hh,...t.partitionColors},d=t.partitionStrokeColors??{},u=t.dotStrokeWidth??1,h={...Uh,...t.edgeColors},p=t.accentColor??"var(--semiotic-focus, #ffcc33)",f=t.borderColor??"var(--semiotic-border, #555)",m=t.dimOpacity??.14,g=t.edgeOpacity??.5,y=t.edgeWidth??1.25,x=t.backEdgeWidth??t.edgeWidth??1.5,b=!1!==t.showStoreChips,w=t.storeChipColor??"var(--semiotic-info, #6a8caf)",M=t.hullGroupAccessor,v=io(e.nodes,n,t),{nodeWidth:k,nodeHeight:I,lod:S}=v,$=t.reachableIds?new Set(t.reachableIds):null,N=t.selectedId??null,E=e.selection,A=null!==$||!0===E?.isActive,C=/* @__PURE__ */new Map,O=/* @__PURE__ */new Map,T=[],P=null==M?null:/* @__PURE__ */new Map,R=[];for(const t of e.nodes){const e=t.id,n=String(we(t,o,"processor")),a=String(we(t,r,"processor")),c=String(we(t,i,e)),h=fo(we(t,s,[])),g=t.data??t,{cx:y,cy:x}=v.nodeBounds(t);if(!Number.isFinite(y)||!Number.isFinite(x))continue;C.set(e,{cx:y,cy:x});const b=$?$.has(e):null,w=E?.isActive?E.predicate(g):null,A=null!==b?!b:null!==w&&!w;O.set(e,A);const j=null!=N&&e===N,F=A&&!j?m:1,L=Object.prototype.hasOwnProperty.call(l,n)?l[n]:l.unknown,z=Object.prototype.hasOwnProperty.call(d,n)?d[n]:void 0;if("dot"===S){const t={type:"circle",cx:y,cy:x,r:k/2,style:{fill:L,opacity:F,stroke:j?p:z??"transparent",strokeWidth:j?2:z?u:0},datum:g,id:e,label:c};T.push(t)}else{const t={type:"rect",x:y-k/2,y:x-I/2,w:k,h:I,style:{fill:L,opacity:F,stroke:j?p:z??f,strokeWidth:j?3:1},datum:g,id:e,label:c};T.push(t),R.push({id:e,cx:y,cy:x,partition:n,semantic:a,label:c,stores:h,opacity:F,selected:j,node:g})}if(P&&null!=M){const n=we(t,M,null);if(null!=n){const t=String(n),o=P.get(t)??[];o.push({id:e,x:y-k/2,y:x-I/2,w:k,h:I}),P.set(t,o)}}}const j=[],F=[];for(const o of e.edges){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id,i=C.get(e),s=C.get(r);if(!i||!s)continue;const l=Boolean(we(o,a,null)??i.cx>=s.cx),d=String(we(o,c,"internal")),u=O.get(e)||O.get(r),p=A&&!u,f=u?Math.min(g,1.4*m):p?t.highlightEdgeOpacity??g:g,b=p&&null!=t.highlightEdgeWidth?t.highlightEdgeWidth:l?x:y,w=l?h.back:Object.prototype.hasOwnProperty.call(h,d)?h[d]:h.internal;let M,v,$;if(l){const t=Math.min(i.cy,s.cy)-I/2-n.y,o=n.y+n.height-Math.max(i.cy,s.cy)-I/2,a=(i.cy+s.cy)/2>n.y+n.height/2?t>8?-1:o>8?1:0:o>8?1:t>8?-1:0,c=Math.max(48,.28*Math.abs(i.cx-s.cx))+I,l=a<0?Math.max(n.y+1,Math.min(i.cy,s.cy)-I/2-c):a>0?Math.min(n.y+n.height-1,Math.max(i.cy,s.cy)+I/2+c):(i.cy+s.cy)/2,d=e===r,u=d?k/4:0,h=d&&"dot"===S?Math.sqrt((I/2)**2-u**2):I/2,p=i.cx-u,f=i.cy+Math.sign(l-i.cy)*h;v={x:s.cx+u,y:s.cy+Math.sign(l-s.cy)*h},$={x:v.x,y:l},M=`M${p},${f} C${p},${l} ${$.x},${$.y} ${v.x},${v.y}`}else{const e=Math.sign(s.cx-i.cx)||1,t=i.cx+e*k/2;v={x:s.cx-e*k/2,y:s.cy};const n=(t+v.x)/2;$={x:n,y:v.y},M=`M${t},${i.cy} C${n},${i.cy} ${n},${v.y} ${v.x},${v.y}`}!1!==t.showArrowheads&&F.push(On(F.length,v,$,w,Math.min(7,k/4,I/3),f));const N={type:"curved",pathD:M,style:{stroke:w,strokeWidth:b,fill:"none",opacity:f,...l?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:o.data??o};j.push(N)}const L="ground"===t.chromePlacement?Gh.NetworkPerspectiveGround:Gh.NetworkPerspectiveBillboard,z=0===R.length&&0===F.length?null:/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsxs)("g",{children:[F.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)(Gh.NetworkPerspectiveGround,{z:"top",children:F}),R.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)("g",{className:"lineage-dag-glyphs",children:R.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,Vh.jsx)(L,{x:e.cx,y:e.cy,z:"top",children:go(e,{w:k,h:I,lod:S,partColors:l,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel})},e.id))})]}),D=P&&P.size>0?po(P,{colors:t.hullColors,padding:null==t.hullPadding?16:Te(t.hullPadding),radius:null==t.hullRadius?12:Te(t.hullRadius),fillOpacity:mo(t.hullFillOpacity,.08),strokeOpacity:mo(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:O,selectedId:N,dimOpacity:m}):null,_=e.perspective?[...R.map(e=>"ground"===t.chromePlacement?{x:e.cx-k/2,y:e.cy-I/2,width:k,height:I,z:"top"}:{x:e.cx,y:e.cy,extent:[k/2,k/2,I/2,I/2]}),...P?ho(P,{padding:null==t.hullPadding?16:Te(t.hullPadding),label:t.hullLabel}):[]]:void 0,W=D?{sceneNodes:T,sceneEdges:j,backgrounds:D,overlays:z,perspective:"manual"}:{sceneNodes:T,sceneEdges:j,overlays:z,perspective:"manual"};return _?{...W,perspectiveBounds:_}:W};Ud();var Kh=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Jh=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),Zh={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},Qh=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,ep=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),tp=e=>{const t=e.config.braid,o=e.dimensions.plot,r=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],i=t.groups.filter(e=>r.includes(e.partition)&&e.nodePath.length>0),s=[],a=[],c=[];if(0===i.length)return{sceneNodes:a,sceneEdges:s,labels:c};const l=new Set(i.map(e=>e.signature)),d=[...t.signatureOrder.filter(e=>l.delete(e)),...l],u=new Map(d.map((e,t)=>[e,t])),h=[...i].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),p=r.map(e=>h.filter(t=>t.partition===e)),f=Io(h),m=n(f.map(e=>e.depth)),g=i.map(e=>n(e.stepEntityCounts??[e.entityCount])),y=n(g),x=e=>e<=0?0:Math.max(1,10*e/y),b=new Map(i.map((e,t)=>[e.id,x(g[t])])),w=o.height/r.length,{semantic:M}=e.theme,v=(e,t,n,o={})=>c.push({x:e,y:t,text:n,fill:M.text??"#333",fontSize:10,anchor:"middle",...o}),k={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},I=new Map(f.map(e=>{const t=p.map(t=>t.reduce((t,n)=>t+(e.signatures.has(n.signature)?b.get(n.id)+3:0),5));return[e.id,n(t,24)]})),S=n([...I.values()],24),$=Math.min(o.width/4,S/2+16),N=(o.width-2*$)/Math.max(m-1,1),E=e=>o.x+$+(e-1)*N,A=48+S/2,C=22+S/2,O=(e,t)=>e+A+(u.get(t)+.5)*Math.max(0,w-A-C)/d.length,T=(t,n,o,r,i)=>{const a=Qh(n,r),c=Qh(n,i),l=x(a),d=x(c);if(0===l&&0===d)return;const u=l!==d,h=e.resolveColor(n.signature);s.push({type:"curved",id:o,pathD:u?Mo(t,l,d):Yn(t,8),style:{fill:u?h:"none",fillOpacity:1,stroke:u?"none":h,strokeWidth:u?0:l},datum:{...k,id:o,kind:"braid-track",nodeId:n.nodePath[i],fromNodeId:n.nodePath[r],groupId:n.id,signature:n.signature,partition:n.partition,entityCount:n.entityCount,fromStep:r,toStep:i,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:n.nodePath.join(" → "),partition:n.partition??"all",fromStep:r+1,toStep:i+1,fromCount:a,toCount:c}})};return r.forEach((e,t)=>{const n=o.y+t*w,r=p[t];if(e&&v(o.x+8,n+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===r.length)return;for(let e=1;e<=m;e++)v(E(e),n+34,`Step ${e}`);const i=/* @__PURE__ */new Map;for(const t of f){const o=r.filter(e=>t.signatures.has(e.signature));if(0===o.length)continue;const s=E(t.depth),c=Pe([...t.signatures].map(e=>O(n,e))),l=vo(o.map(e=>b.get(e.id)));i.set(t.id,new Map(o.map((e,t)=>[e.id,{x:s,y:c+l[t],offset:l[t]}])));const d=I.get(t.id),u={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;a.push({type:"glyph",id:h,cx:s,cy:c,size:d,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:Zh,accent:M.border??"#888",style:{fill:M.surface??"#fff"},datum:{...k,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...u},accessibleDatum:u}),v(s,c+d/2+12,t.state,{anchorPoint:[s,c]})}for(const t of r){const n=ko(t.signature);for(let o=1;o<n.length;o++){const r=i.get(n[o-1]).get(t.id),s=i.get(n[o]).get(t.id),a=(r.x+s.x)/2-Math.sign(s.y-r.y)*s.offset,c=Math.abs(r.y-s.y)<1e-8?[r,s]:[r,{x:a,y:r.y},{x:a,y:s.y},s];T(c,t,`step:${e??"all"}:${n[o]}:${t.id}`,o-1,o)}}}),{sceneNodes:a,sceneEdges:s,labels:c,restyle:ep,restyleEdge:ep}},np=require("./semiotic-network-placement.min.js"),op=require("react/jsx-runtime"),rp={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},ip=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,s=t.layerAccessor??"layer",a=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",d=t.edgeLabelAccessor??"label",u=t.nodeFill??"var(--semiotic-surface, #20242d)",h=t.nodeStroke??"var(--semiotic-border, #5a6573)",p=t.textColor??"var(--semiotic-text, #e6e6e6)",f=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",m=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const g=/* @__PURE__ */new Map;let y=0;for(const t of e.nodes){const e=Math.round(Number(we(t,s,0)));y=Math.max(y,e);const n=g.get(e)||[];n.push(t),g.set(e,n)}const x=y+1;let b=1;for(const e of g.values())e.sort((e,t)=>Number(we(e,a,0))-Number(we(t,a,0))),b=Math.max(b,e.length);const w=r?n.width:n.height,M=r?n.height:n.width,v=w/x,k=M/(b+1),I=Math.max(44,Math.min(t.nodeWidth??150,r?v-36:.92*k)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*k:.5*v)),$=(r?I:S)/2+6,N=Math.max(1,w-2*$),E=e=>{const t=x>1?(i?x-1-e:e)/(x-1)*N:N/2;return(r?n.x:n.y)+$+t},A=/* @__PURE__ */new Map,C=null!=e.perspective,O=[],T=[],P=[],R=[];for(const[e,t]of g)t.forEach((o,i)=>{const s=E(e),a=(d=i,f=t.length,(r?n.y:n.x)+(d+1)/(f+1)*M);var d,f;const g=r?s:a,y=r?a:s,x=String(we(o,l,"rect")),b=String(we(o,c,o.id));A.set(o.id,{cx:g,cy:y,shape:x});const w={id:o.id,name:b,type:rp[x]??"process",shape:x},v=So(b,Math.max(4,Math.floor((I-12)/7)));if(C){const e="diamond"===x?m:h;O.push({type:"rect",x:g-I/2,y:y-S/2,w:I,h:S,style:{fill:u,stroke:e,strokeWidth:1.5},_hitPath:{pathD:Eo(x,g,y,I,S),transform:[0,0,1,1],fill:!0,strokeWidth:0},datum:w,id:o.id,label:b}),P.push({x:g,y:y,text:v,anchor:"middle",baseline:"middle",fontSize:13,fill:p,anchorPoint:[g,y]});const t=Ao(x,g,y,I,S,e);return void(t&&R.push(/* @__PURE__ */ /* @__PURE__ */(0,op.jsx)("g",{children:t},`n-${o.id}`)))}O.push({type:"rect",x:g-I/2,y:y-S/2,w:I,h:S,style:{fill:"transparent",stroke:"transparent"},datum:w,id:o.id,label:b}),R.push(
146
+ /* @__PURE__ */(0,Lf.jsx)("title",{children:c}),u.text]})]},e.id)}):null]}))}function Tc(e){if(null==e){const e=_f.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Pc(e){if("number"==typeof e){const t=Math.max(1,Math.round(e));return Array.from({length:t},(e,t)=>({id:`bin-${t}`,label:String(t)}))}return 0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??String(t)}))}function Rc(e){const[t,n]=e.size,o=e.flow??_f.flow,r=Tc(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??_f.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??_f.chargeExtent),l=a*Math.max(0,e.projectionExtent??_f.projectionExtent),d=a*Math.max(0,e.destinationExtent??_f.destinationExtent),u=Math.max(0,a-c-d-l),h=Pc(e.destinations),p=("down"===o?s.width:s.height)/h.length,f="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),m=f(0,c),g=f(c,u),y=c+u,x=f(y,d),b=f(y+d,l),w=h.map((e,t)=>{const n=t*p,r=p*i,a=(p-r)/2;if("down"===o){const o=s.x+n+a;return{id:e.id,label:e.label,order:t,x:o,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*p,centerY:x.y+x.height/2}}const c=s.y+n+a;return{id:e.id,label:e.label,order:t,x:x.x,y:c,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*p}});return{width:t,height:n,flow:o,charge:m,apparatus:g,destinations:w,projection:b}}function jc(e,t){return e.destinations.find(e=>e.id===t)}function Fc(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function Lc(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:`${o}-floor`,shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:`${o}-floor`,shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:`${o}-wall-left`,shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:`${o}-wall-right`,shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function zc(e,t={}){const n=t.charge??"bodies",o=t.apparatus??"the apparatus",r=t.destination??"destinations",i=e.destinations.length,s="down"===e.flow?"downward":"left to right";return`${n} enter at the ${"down"===e.flow?"top":"left"}, travel ${s} through ${o}, and come to rest in ${i} ${r}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Dc(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function _c(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function Wc(e,t,n){return Dc(e[t])??n}function qc(e,t){return"number"==typeof e?e:e?.[t]??0}function Bc(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=/* @__PURE__ */new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}function Gc(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=Bc(t);if(c.length<2)return[];const l=i?0:1,d=i?c.length-1:c.length-2,u=[];for(let e=l;e<=d;e+=1){if(!s&&e>0&&e<c.length-1)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return u}function Yc(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...ma(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...ga({...s,idPrefix:e??`${n}-xbin`,yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...Gc({band:i,idPrefix:i.idPrefix??`${n}-xband`,plot:t,projection:"x"})),s&&a.push(...Gc({band:s,idPrefix:s.idPrefix??`${n}-yband`,plot:t,projection:"y"})),a}function Vc(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:d=.04}=e,u=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===u)return[];const p=u<=1?0:(a-s)/(u-1),f=t.width/h,m=[];for(let e=0;e<u;e+=1){const n=c&&e%2==1?f/2:0;for(let o=0;o<h;o+=1){const a=t.x+f*(o+.5)+n;a<t.x+r||a>t.x+t.width-r||m.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*p,width:2*r,height:2*r},restitution:l,friction:d})}}return m}function Hc(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:d,datum:u}=t,h=Ge(l),p=qc(d,"x"),f=qc(d,"y");return e.map((e,l)=>{const d=_c(t.x,e,l,Wc(e,"x",0)),m=_c(t.y,e,l,Wc(e,"y",0)),g=_c(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:d+(h()-.5)*p,y:m+(h()-.5)*f,vx:_c(s,e,l,0),vy:_c(a,e,l,0),mass:_c(i,e,l,1),spawnAt:_c(c,e,l,void 0),shape:y,datum:u?u(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Uc(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=fa(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function Xc(e,t,n){return Dc("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}function Kc(e,n={}){const{timeAccessor:o="arrivalTime",timeScale:r=1,startAt:i=0,rebase:s=!0,sort:a=!0}=n,c=e.map((e,t)=>({spawn:e,time:Xc(e,t,o)??e.spawnAt??t})),l=c.length?t(c.map(e=>e.time)):0;return{initialSpawns:c.map(({spawn:e,time:t})=>({...e,spawnAt:i+(s?t-l:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:i,timeAccessor:"spawnAt",timeScale:r}}}function Jc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Zc(e,t,n="group"){const o=ra(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return n<i?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function Qc(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{Jc(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function el(e,t,n=.55){const o=Math.abs(t.x-e.x),r=(e.x+t.x)/2,i=e.y-o*n;return`M${e.x},${e.y} Q${r},${i} ${t.x},${t.y}`}function tl(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;Jc(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function nl(e,t,n={}){const o=(n.order??Zc(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.source<e.target?`${e.source}${Wf}${e.target}`:`${e.target}${Wf}${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split(Wf),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function ol(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function rl(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function il(e,t){const n=ol(e.note)?e.note:void 0;return t?rl(e.mobileText)||rl(e.shortText)||rl(e.label)||rl(n?.mobileText)||rl(n?.shortText)||rl(n?.label)||rl(n?.title):rl(e.label)||rl(e.mobileText)||rl(e.shortText)||rl(n?.label)||rl(n?.title)}function sl(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}function al(e,t,n){const o=sl(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=String(e.emphasis??"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=ol(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=ol(e.lifecycle)?e.lifecycle:void 0,c=String(a?.freshness??"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function cl(e,t){if(!t)return e;const n=il(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function ll(e,t,n,o){const r=il(e,o);if(!r)return null;const i=rl(e.id)||rl(e.key)||rl(e.pointId)||`annotation-${t+1}`,s=ol(e.provenance)?rl(e.provenance.source)||rl(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:rl(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}function dl(e,t={}){const n=Array.isArray(e)?e.filter(ol):[],o=t.breakpoint??480,r=t.active??(null==t.width||t.width<=o),i=t.strategy??"hybrid",s=!1!==t.preferShortText,a=!1!==t.preservePrimary,c=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===i?1:2)),l=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!r||"plot"===i)return{active:r,strategy:i,budget:n.length,visible:s?n.map(e=>cl(e,s)):n,deferred:[],calloutList:[],hidden:[]};const d=[],u=n.map((e,n)=>({annotation:e,index:n,priority:al(e,n,t)})).filter(e=>!!Kr(e.annotation)||(d.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),h=a?u.filter(e=>"primary"===String(e.annotation.emphasis??"").toLowerCase()):[],p=new Set(h.map(e=>e.index)),f=u.filter(e=>!p.has(e.index)),m=[...h,...f].slice(0,Math.max(c,l)),g=new Set(m.map(e=>e.index)),y=u.filter(e=>!g.has(e.index)),x=[...d,...m.sort((e,t)=>e.index-t.index).map(e=>cl(e.annotation,s))],b=y.sort((e,t)=>e.index-t.index).map(e=>e.annotation),w=Math.max(0,t.maxCalloutItems??6),M=y.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>ll(e.annotation,e.index,e.priority,s)).filter(e=>!!e).slice(0,w),v=new Set(M.map(e=>e.annotation)),I=b.filter(e=>!v.has(e));return{active:r,strategy:i,budget:c,visible:x,deferred:b,calloutList:M,hidden:I}}function ul(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function hl(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function pl(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function fl(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function ml(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:fl(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=hl(e,t),l=ul(t);return{family:e,props:s,responsiveRules:[{id:`${e}-mobile`,description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function gl(e={}){const t=pl(e);return ml("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function yl(e={}){const t=pl(e);return ml("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function xl(e={}){return ml("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function bl(e={}){const t=pl(e);return ml("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function wl(e={}){const t=pl(e);return ml("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function Ml(e={}){return ml("geo",e,{showLegend:e.showLegend??!1})}function vl(e={}){return ml("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Il(e,t={}){switch(e){case"line":return gl(t);case"area":return yl(t);case"ordinal":return xl(t);case"scatter":return bl(t);case"network":return wl(t);case"geo":return Ml(t);case"small-multiple":return vl(t)}}function kl(e={}){const t=e.targetSize??44,n=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:t,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:n,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:n}}function Sl(e){return JSON.stringify([e.nodeId,e.endpoint.kind,"part"===e.endpoint.kind?e.endpoint.partId:null,e.endpoint.portId??null])}function $l(e,t=qf){return{nodeId:e,endpoint:t}}function Nl(e,t){return e<t?-1:e>t?1:0}function El(e){return Array.isArray(e)?`[${e.map(El).join(",")}]`:e&&"object"==typeof e?`{${Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>Nl(e,t)).map(([e,t])=>`${JSON.stringify(e)}:${El(t)}`).join(",")}}`:JSON.stringify(e)??"null"}function Al(e){if(e&&"object"==typeof e&&!Object.isFrozen(e)){Object.freeze(e);for(const t of Object.values(e))Al(t)}return e}function Cl(e,t,n={}){throw new Bf([{code:e,message:t,severity:"error",...n}])}function Ol(e,t){const n=/* @__PURE__ */new Map;for(const o of e)"string"==typeof o.id&&o.id&&!n.has(o.id)||Cl("IDENTITY_DUPLICATE_OR_EMPTY",`IDs must be nonempty and unique in ${t}.`),n.set(o.id,o);return n}function Tl(e,t){const n=/* @__PURE__ */new Set;for(const o of e.keys()){const r=/* @__PURE__ */new Set;let i=o;for(;void 0!==i&&!n.has(i);){r.has(i)&&Cl("IDENTITY_CONTAINMENT_CYCLE","Containment must be acyclic.");const n=e.get(i);n||Cl("IDENTITY_UNKNOWN_PARENT","Containment references an unknown parent."),r.add(i),i=t(n)}r.forEach(e=>n.add(e))}}function Pl(e,t,n){const o=e.get(t.nodeId);o||Cl("ENDPOINT_UNKNOWN_OWNER","Endpoint owner does not exist.",{endpointRefs:[t]});const r=t.endpoint;"node"!==r.kind&&"part"!==r.kind&&Cl("ENDPOINT_KIND","Unknown endpoint kind.");const i="part"===r.kind?o.parts?.find(e=>e.id===r.partId):void 0;if("part"!==r.kind||i||Cl("ENDPOINT_UNKNOWN_PART","Endpoint part does not exist.",{endpointRefs:[t]}),void 0===r.portId)return;const s=(i?i.ports:o.ports)?.find(e=>e.id===r.portId);s||Cl("ENDPOINT_UNKNOWN_PORT","Endpoint port does not exist.",{endpointRefs:[t]});const a="source"===n||"transfer-target"===n?"out":"in";return n&&s.direction!==a&&"inout"!==s.direction&&Cl("ENDPOINT_DIRECTION","Port direction is incompatible with its use.",{endpointRefs:[t]}),s}function Rl(e,t,n){const o=e.get(t)??[];o.push(n),e.set(t,o)}function jl(e){const t=Gf.get(e);if(t)return t;const n=e.graph,o={nodes:new Map(n.nodes.map(e=>[e.id,e])),endpoints:/* @__PURE__ */new Map,ownerEndpoints:/* @__PURE__ */new Map,tracePolicies:/* @__PURE__ */new Map,incoming:/* @__PURE__ */new Map,outgoing:/* @__PURE__ */new Map,transferIn:/* @__PURE__ */new Map,transferOut:/* @__PURE__ */new Map},r=e=>{const t=Sl(e);return o.endpoints.has(t)||Rl(o.ownerEndpoints,e.nodeId,e),o.endpoints.set(t,e),t},i=new Set(n.transfers?.map(e=>e.nodeId));for(const e of[...n.nodes].sort((e,t)=>Nl(e.id,t.id))){o.tracePolicies.set(e.id,e.tracePolicy??(e.parts?.length||e.ports?.length||i.has(e.id)?"explicit":"atomic")),r($l(e.id));for(const t of e.ports??[])r($l(e.id,{kind:"node",portId:t.id}));for(const t of e.parts??[]){r($l(e.id,{kind:"part",partId:t.id}));for(const n of t.ports??[])r($l(e.id,{kind:"part",partId:t.id,portId:n.id}))}}for(const e of[...n.edges].sort((e,t)=>Nl(e.id,t.id)))Rl(o.outgoing,r($l(e.source,e.sourceEndpoint)),e),Rl(o.incoming,r($l(e.target,e.targetEndpoint)),e);for(const e of[...n.transfers??[]].sort((e,t)=>Nl(e.id,t.id))){Rl(o.transferIn,r($l(e.nodeId,e.target)),e);for(const t of e.sources)Rl(o.transferOut,r($l(e.nodeId,t)),e)}for(const e of o.ownerEndpoints.values())e.sort((e,t)=>Nl(Sl(e),Sl(t)));return Gf.set(e,o),o}function Fl(e){"semiotic.compositional-graph.v0.1"!==e.schemaVersion&&Cl("IDENTITY_SCHEMA","Unknown graph schema."),"string"==typeof e.graphId&&e.graphId&&"string"==typeof e.revision&&e.revision||Cl("IDENTITY_REVISION","Graph ID and revision are required.");const t=Ol(e.nodes,"nodes");Ol(e.edges,"edges"),Ol(e.transfers??[],"transfers"),Tl(t,e=>e.parentId);const n=(e=[])=>{Ol(e,"ports");for(const t of e)["in","out","inout"].includes(t.direction)||Cl("ENDPOINT_DIRECTION","Unknown port direction.")};for(const e of t.values()){e.tracePolicy&&!["atomic","explicit","opaque"].includes(e.tracePolicy)&&Cl("TRACE_POLICY","Unknown trace policy."),n(e.ports);const t=Ol(e.parts??[],"owner parts");Tl(t,e=>e.parentPartId);for(const e of t.values())n(e.ports)}for(const n of e.edges)Pl(t,$l(n.source,n.sourceEndpoint),"source"),Pl(t,$l(n.target,n.targetEndpoint),"target");for(const n of e.transfers??[])n.sources.length&&["identity","all","any","unspecified"].includes(n.combination)&&("identity"!==n.combination||1===n.sources.length)||Cl("ENDPOINT_TRANSFER","Transfers need inputs and a valid combination; identity needs one input."),new Set(n.sources.map(e=>Sl($l(n.nodeId,e)))).size!==n.sources.length&&Cl("ENDPOINT_TRANSFER","Transfer inputs must be distinct."),n.sources.forEach(e=>Pl(t,$l(n.nodeId,e),"transfer-source")),Pl(t,$l(n.nodeId,n.target),"transfer-target");let o;try{o=JSON.parse(JSON.stringify(e,(e,t)=>{if("function"==typeof t||"symbol"==typeof t||"bigint"==typeof t||"number"==typeof t&&!Number.isFinite(t))throw new Error("Non-JSON value");return t}))}catch{Cl("IDENTITY_NONPORTABLE","Graph must be serializable JSON.")}const r=e=>[...e].sort((e,t)=>Nl(e.id,t.id)),i=Al({schemaVersion:"semiotic.prepared-compositional-graph.v0.1",graph:o,semanticHash:El({graphId:o.graphId,nodes:r(o.nodes).map(({id:e,parentId:t,tracePolicy:n,ports:o,parts:i})=>({id:e,parentId:t,tracePolicy:n,ports:r(o??[]).map(({id:e,direction:t})=>({id:e,direction:t})),parts:r(i??[]).map(({id:e,parentPartId:t,ports:n})=>({id:e,parentPartId:t,ports:r(n??[]).map(({id:e,direction:t})=>({id:e,direction:t}))}))})),edges:r(o.edges).map(({data:e,...t})=>t),transfers:r(o.transfers??[])}),diagnostics:[]});return jl(i),i}function Ll(e,t){t.baseRevision===e.graph.revision&&t.revision!==t.baseRevision||Cl("REVISION_PATCH_BASE","Patch requires the current base and a new revision.");const n=(e,t=[],n=[])=>{Ol(n,"patch upserts");const o=new Map(e.map(e=>[e.id,e]));return t.forEach(e=>o.delete(e)),n.forEach(e=>o.set(e.id,e)),[...o.values()]};return Fl({...e.graph,revision:t.revision,nodes:n(e.graph.nodes,t.removeNodeIds,t.upsertNodes),edges:n(e.graph.edges,t.removeEdgeIds,t.upsertEdges),transfers:n(e.graph.transfers??[],t.removeTransferIds,t.upsertTransfers)})}function zl(e,t){(!Number.isInteger(t.maxVisited)||t.maxVisited<1||!Number.isInteger(t.maxDepth)||t.maxDepth<0)&&Cl("TRACE_BUDGET","Trace budgets must be finite nonnegative integers, with at least one visit.");const n=jl(e);Pl(n.nodes,t.start);const o="upstream"===t.direction,r=[{ref:t.start,depth:0}],i=/* @__PURE__ */new Set([Sl(t.start)]),s=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set,l=/* @__PURE__ */new Set,d=[];let u="complete";const h=e=>!t.kinds||t.kinds.includes(e??"unspecified"),p=(e,t,n)=>{a.has(Sl(e))||d.push({code:t,severity:"warning",message:n,endpointRefs:[e]}),a.set(Sl(e),e),"TRACE_BUDGET"===t?u="partial":"complete"===u&&(u="unknown")};for(let e=0;e<r.length;e++){const{ref:a,depth:d}=r[e];s.set(Sl(a),a);const u=n.tracePolicies.get(a.nodeId),f="node"===a.endpoint.kind&&!a.endpoint.portId&&"atomic"!==u,m=f&&d>0&&"conservative-node"!==t.boundaryPolicy;f&&p(a,"TRACE_COARSE_BOUNDARY","Whole-node boundary does not establish exact interface provenance.");const g=e=>{const n=Sl(e);return!!i.has(n)||(d>=t.maxDepth||i.size>=t.maxVisited?(p(a,"TRACE_BUDGET","Trace is partial within the supplied graph: visit or depth budget reached."),!1):(i.add(n),r.push({ref:e,depth:d+1}),!0))};if(!m)for(const e of(o?n.incoming:n.outgoing).get(Sl(a))??[])h(e.kind)&&g(o?$l(e.source,e.sourceEndpoint):$l(e.target,e.targetEndpoint))&&c.add(e.id);for(const e of(o?n.transferIn:n.transferOut).get(Sl(a))??[])if(h(e.kind)){l.add(e.id);for(const t of o?e.sources:[e.target])g($l(e.nodeId,t))}if(f&&"conservative-node"===t.boundaryPolicy)for(const e of n.ownerEndpoints.get(a.nodeId)??[])g(e)}return Al({endpoints:[...s.values()],edgeIds:[...c].sort(Nl),transferIds:[...l].sort(Nl),completeness:u,boundaryRefs:[...a.values()],diagnostics:d})}function Dl(e,t,n=!0){return(!Number.isFinite(e)||n&&e<0)&&Cl("GEOMETRY_NUMBER",`${t} must be finite${n?" and nonnegative":""}.`),e}function _l(e){Dl(e.x,"x",!1),Dl(e.y,"y",!1),Dl(e.width,"width"),Dl(e.height,"height")}function Wl(e){return[..."within-groups"===e.mode?e.groups.flatMap(e=>[...e.ids]):"optimize"===e.mode?e.initialIds:e.ids]}function ql(e,t){const n=Wl(e);(n.length!==t.length||new Set(n).size!==n.length||t.some(e=>!n.includes(e)))&&Cl("ORDER_MEMBERS","An order must contain every participating member exactly once."),"within-groups"===e.mode&&new Set(e.groups.map(e=>e.id)).size!==e.groups.length&&Cl("ORDER_GROUPS","Order group IDs must be unique.")}function Bl(e,t,n){return"optimize"===e.mode||"within-groups"===e.mode&&e.groups.some(e=>!e.fixed&&e.ids.includes(t)&&e.ids.includes(n))}function Gl(e,t,n,o=Wl(t.order)){const r="LR"===n||"RL"===n,i=t.padding;Object.entries(i).forEach(([e,t])=>Dl(t,e)),Dl(t.headerHeight,"headerHeight"),Dl(t.rowGap,"rowGap"),Dl(t.defaultRowHeight,"defaultRowHeight");const s=/* @__PURE__ */new Map;for(const e of t.rowHeights??[])!s.has(e.partId)&&o.includes(e.partId)||Cl("ORDER_ROW_HEIGHT","Row size IDs must be unique participating parts."),s.set(e.partId,Dl(e.height,"rowHeight"));let a=t.headerHeight+(r?i.top:i.left);const c=r?e.width-i.left-i.right:e.height-i.top-i.bottom;Dl(c,"available row breadth");const l=o.map(e=>{const n=s.get(e)??t.defaultRowHeight,o=r?{x:i.left,y:a,width:c,height:n}:{x:a,y:i.top,width:n,height:c};return a+=n+t.rowGap,{partId:e,rect:o}});return a-(l.length?t.rowGap:0)+(r?i.bottom:i.right)>(r?e.height:e.width)+1e-8&&Cl("GEOMETRY_FOOTPRINT","Rows exceed the supplied node footprint.",{nodeIds:[e.nodeId]}),{...e,parts:l,actualPartOrder:o}}function Yl(e,t,n=.5){switch((!Number.isFinite(n)||n<0||n>1)&&Cl("GEOMETRY_FRACTION","Anchor fraction must be in [0,1]."),t){case"north":return{point:{x:e.x+e.width*n,y:e.y},normal:{x:0,y:-1}};case"south":return{point:{x:e.x+e.width*n,y:e.y+e.height},normal:{x:0,y:1}};case"east":return{point:{x:e.x+e.width,y:e.y+e.height*n},normal:{x:1,y:0}};case"west":return{point:{x:e.x,y:e.y+e.height*n},normal:{x:-1,y:0}};default:return Cl("GEOMETRY_SIDE","Unknown anchor side.")}}function Vl(e,t){return{LR:["east","west"],RL:["west","east"],TB:["south","north"],BT:["north","south"]}[e]["source"===t?0:1]}function Hl(e){if(!e.length)return{x:0,y:0,width:0,height:0};let t=1/0,n=1/0,o=-1/0,r=-1/0;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),o=Math.max(o,i.x+i.width),r=Math.max(r,i.y+i.height);return{x:t,y:n,width:o-t,height:r-n}}function Ul(e){return Hl(e.map(e=>({...e,width:0,height:0})))}function Xl(e,t){return e.x<t.x+t.width-1e-8&&e.x+e.width>t.x+1e-8&&e.y<t.y+t.height-1e-8&&e.y+e.height>t.y+1e-8}function Kl(e,t){return t.x>=e.x-1e-8&&t.x<=e.x+e.width+1e-8&&t.y>=e.y-1e-8&&t.y<=e.y+e.height+1e-8}function Jl(e){const t=/* @__PURE__ */new Map;for(const n of e.nodes){t.has(n.nodeId)&&Cl("GEOMETRY_DUPLICATE","Duplicate node measurement."),Dl(n.width,"width"),Dl(n.height,"height");const e=/* @__PURE__ */new Set;for(const t of n.parts)e.has(t.partId)&&Cl("GEOMETRY_DUPLICATE","Duplicate part measurement."),e.add(t.partId),_l(t.rect),Kl({x:0,y:0,width:n.width,height:n.height},t.rect)&&Kl({x:0,y:0,width:n.width,height:n.height},{x:t.rect.x+t.rect.width,y:t.rect.y+t.rect.height})||Cl("GEOMETRY_PART_BOUNDS","Part measurement exceeds its owner.");const o=/* @__PURE__ */new Set;for(const e of[...(n.markAnchors??[]).map(e=>({...e,key:JSON.stringify(["mark",e.markId,e.anchorName])})),...(n.slotAnchors??[]).map(e=>({...e,key:JSON.stringify(["slot",e.groupId,e.slotId])}))])o.has(e.key)&&Cl("GEOMETRY_DUPLICATE","Duplicate named anchor."),o.add(e.key),Dl(e.point.x,"anchor x",!1),Dl(e.point.y,"anchor y",!1),Dl(e.normal.x,"normal x",!1),Dl(e.normal.y,"normal y",!1);for(const e of[...n.routingChannels??[],...n.obstacleRects??[]])_l(e);t.set(n.nodeId,n)}return t}function Zl(e,t,n){switch(e.kind){case"node-side":return Yl({x:0,y:0,width:t.rect.width,height:t.rect.height},e.side,e.fraction);case"part-side":{const n=t.parts?.find(t=>t.partId===e.partId);return n?Yl(n.rect,e.side,e.fraction):Cl("GEOMETRY_UNKNOWN_PART","Anchor has no solved part rectangle.")}case"point":return e;case"named-mark":{const t=n.markAnchors?.find(t=>t.markId===e.markId&&t.anchorName===e.anchorName);return t||Cl("GEOMETRY_UNKNOWN_MARK","Named mark anchor is unresolved.")}case"slot":{const t=n.slotAnchors?.find(t=>t.groupId===e.groupId&&t.slotId===e.slotId);return t||Cl("GEOMETRY_UNKNOWN_SLOT","Named slot is unresolved.")}}}function Ql(e,t){return JSON.stringify([Sl(e),t])}function ed(e,t,n){return n.some(n=>Math.abs(e.x-t.x)<Yf?e.x>n.x+Yf&&e.x<n.x+n.width-Yf&&Math.max(e.y,t.y)>n.y+Yf&&Math.min(e.y,t.y)<n.y+n.height-Yf:!(Math.abs(e.y-t.y)<Yf)||e.y>n.y+Yf&&e.y<n.y+n.height-Yf&&Math.max(e.x,t.x)>n.x+Yf&&Math.min(e.x,t.x)<n.x+n.width-Yf)}function td(e){const t=[];for(const n of e)t.length&&Vf(t[t.length-1],n)<Yf||t.push(n);return t}function nd(e,t,n,o,r,i=4e4){const s=e=>e.every((t,o)=>0===o||!ed(e[o-1],t,n)),a=r?(e.x+t.x)/2+o:(e.y+t.y)/2+o,c=r?[e,{x:a,y:e.y},{x:a,y:t.y},t]:[e,{x:e.x,y:a},{x:t.x,y:a},t];if(s(c))return td(c);const l=[],d=[.../* @__PURE__ */new Set([e.x,t.x,...n.flatMap(e=>[e.x,e.x+e.width])])].sort((e,t)=>e-t),u=[.../* @__PURE__ */new Set([e.y,t.y,...n.flatMap(e=>[e.y,e.y+e.height])])].sort((e,t)=>e-t);for(const n of d)l.push([e,{x:n,y:e.y},{x:n,y:t.y},t]);for(const n of u)l.push([e,{x:e.x,y:n},{x:t.x,y:n},t]);const h=l.filter(s).sort((e,t)=>Hf(e)-Hf(t));if(h.length)return td(h[0]);if(d.length*u.length>i)return null;const p=d.length,f=p*u.length,m=u.indexOf(e.y)*p+d.indexOf(e.x),g=u.indexOf(t.y)*p+d.indexOf(t.x),y=new Float64Array(f).fill(1/0),x=new Int32Array(f).fill(-1),b=e=>({x:d[e%p],y:u[Math.floor(e/p)]}),w=[],M=(e,n)=>{const o={id:e,cost:n,priority:n+Vf(b(e),t)};w.push(o);let r=w.length-1;for(;r>0;){const e=r-1>>1;if(w[e].priority<=o.priority)break;w[r]=w[e],r=e}w[r]=o},v=()=>{const e=w[0],t=w.pop();if(w.length){let e=0;for(;2*e+1<w.length;){let n=2*e+1;if(n+1<w.length&&w[n+1].priority<w[n].priority&&n++,w[n].priority>=t.priority)break;w[e]=w[n],e=n}w[e]=t}return e};y[m]=0,M(m,0);let I=0;for(;w.length&&I++<i;){const{id:e,cost:t}=v();if(t!==y[e])continue;if(e===g){const e=[];for(let t=g;t>=0;t=x[t])e.push(b(t));return td(e.reverse())}const o=e%p,r=Math.floor(e/p),i=[o>0?e-1:-1,o+1<p?e+1:-1,r>0?e-p:-1,r+1<u.length?e+p:-1];for(const o of i){if(o<0||ed(b(e),b(o),n))continue;const r=t+Vf(b(e),b(o));r+Yf<y[o]&&(y[o]=r,x[o]=e,M(o,r))}}return null}function od(e,t,n,o){const r=[{kind:"M",point:t[0]}];for(let e=1;e<t.length-1;e++){const i=t[e],s=t[e-1],a=t[e+1],c=Math.min(4,Vf(s,i)/3,Vf(a,i)/3),l=e=>({x:i.x+(e.x-i.x)*c/Vf(i,e),y:i.y+(e.y-i.y)*c/Vf(i,e)}),d=l(s),u=l(a),h=Ul([d,i,u]),p=o.some(e=>h.x<e.x+e.width&&h.x+h.width>e.x&&h.y<e.y+e.height&&h.y+h.height>e.y);n&&c>Yf&&e>1&&e<t.length-2&&!p?r.push({kind:"L",point:d},{kind:"C",control1:i,control2:i,point:u}):r.push({kind:"L",point:i})}return r.push({kind:"L",point:t[t.length-1]}),{id:e,points:t,commands:r,bounds:Ul(r.flatMap(e=>"C"===e.kind?[e.control1,e.control2,e.point]:[e.point]))}}function rd(e){return(e.commands?.length?e.commands:e.points.map((e,t)=>({kind:t?"L":"M",point:e}))).map(e=>"C"===e.kind?`C${e.control1.x},${e.control1.y} ${e.control2.x},${e.control2.y} ${e.point.x},${e.point.y}`:`${e.kind}${e.point.x},${e.point.y}`).join(" ")}function id(e){const t=[];for(const n of e.commands??[]){if("C"!==n.kind){t.push(n.point);continue}const e=t[t.length-1],o=n.control1,r=n.control2,i=n.point;for(let n=1;n<=24;n++){const s=n/24,a=1-s;t.push({x:a**3*e.x+3*a**2*s*o.x+3*a*s**2*r.x+s**3*i.x,y:a**3*e.y+3*a**2*s*o.y+3*a*s**2*r.y+s**3*i.y})}}return t.length?t:[...e.points]}function sd(e,t,n,o=t.escape,r=n.escape,i=!1,s=!0){const a=[t.anchor,t.escape,...Vf(o,t.escape)?[o]:[],...Vf(r,n.escape)?[r]:[],n.escape,n.anchor];if(!i)return{id:e,points:a,bounds:Ul(a)};const c=s?(o.x+r.x)/2:(o.y+r.y)/2,l=s?{x:c,y:o.y}:{x:o.x,y:c},d=s?{x:c,y:r.y}:{x:r.x,y:c};return{id:e,points:a,commands:[{kind:"M",point:t.anchor},{kind:"L",point:t.escape},...Vf(o,t.escape)?[{kind:"L",point:o}]:[],{kind:"C",control1:l,control2:d,point:r},...Vf(r,n.escape)?[{kind:"L",point:n.escape}]:[],{kind:"L",point:n.anchor}],bounds:Ul([...a,l,d])}}function ad(e,t,n,o){const r=t.x-e.x,i=t.y-e.y,s=o.x-n.x,a=o.y-n.y,c=r*a-i*s;if(Math.abs(c)<1e-8)return null;const l=((n.x-e.x)*a-(n.y-e.y)*s)/c,d=((n.x-e.x)*i-(n.y-e.y)*r)/c;return l>=0&&l<=1&&d>=0&&d<=1?{x:e.x+l*r,y:e.y+l*i}:null}function cd(e,t,n,o="orthogonal",r=/* @__PURE__ */new Set){const i=e.filter(e=>!r.has(e.edgeId)),s="terminals"===o;let a=0,c=0,l=0,d=0,u=0,h=0;const p=i.map(e=>s?[e.source.escape,e.target.escape]:e.sections.flatMap(id));for(let e=0;e<i.length;e++){const o=i[e],r=s?o.sections.flatMap(e=>e.points):p[e];n.has(o.edgeId)&&(l+=Math.abs(t?o.source.anchor.y-o.target.anchor.y:o.source.anchor.x-o.target.anchor.x));for(let e=1;e<r.length;e++)a+=Vf(r[e-1],r[e]),!s&&e>1&&Math.abs((r[e-1].x-r[e-2].x)*(r[e].y-r[e-1].y)-(r[e-1].y-r[e-2].y)*(r[e].x-r[e-1].x))>1e-8&&c++}const f=e=>{let t=1/0,n=-1/0;for(const o of i)t=Math.min(t,o.bounds[e]),n=Math.max(n,o.bounds[e]);return i.length?n-t:0},m=f("x")>=f("y")?"x":"y",g="x"===m?"width":"height",y="x"===m?"y":"x",x="x"===m?"height":"width",b=i.map((e,t)=>({e:e,i:t})).sort((e,t)=>e.e.bounds[m]-t.e.bounds[m]);let w=!1;e:for(let e=0;e<b.length;e++)for(let t=e+1;t<b.length;t++){const n=b[e],o=b[t];if(o.e.bounds[m]>n.e.bounds[m]+n.e.bounds[g])break;if(n.e.bounds[y]>o.e.bounds[y]+o.e.bounds[x]||o.e.bounds[y]>n.e.bounds[y]+n.e.bounds[x])continue;if(s){if(++u>2e6){w=!0;break e}const[e,t]=p[n.i],[r,i]=p[o.i],s=ad(e,t,r,i),a=s&&[e,t].some(e=>Math.abs(e.x-s.x)<1e-8&&Math.abs(e.y-s.y)<1e-8&&[r,i].some(t=>Math.abs(t.x-e.x)<1e-8&&Math.abs(t.y-e.y)<1e-8));s&&!a&&d++;continue}const r=/* @__PURE__ */new Set,i=p[n.i],a=p[o.i],c=[n.e.source,n.e.target].flatMap(e=>[o.e.source,o.e.target].filter(t=>Vf(e.anchor,t.anchor)<1e-8&&Vf(e.escape,t.escape)<1e-8).map(()=>[e.anchor,e.escape])),l=e=>c.some(([t,n])=>Math.abs(Vf(t,e)+Vf(e,n)-Vf(t,n))<1e-7);for(let e=1;e<i.length;e++)for(let t=1;t<a.length;t++){if(++u>2e6){w=!0;break e}const n=ad(i[e-1],i[e],a[t-1],a[t]);n&&!l(n)&&r.add(`${n.x.toFixed(6)},${n.y.toFixed(6)}`);const o=i[e-1],c=i[e],d=a[t-1],p=a[t],f=Math.abs(o.x-c.x)<1e-8&&Math.abs(o.x-d.x)<1e-8&&Math.abs(o.x-p.x)<1e-8,m=Math.abs(o.y-c.y)<1e-8&&Math.abs(o.y-d.y)<1e-8&&Math.abs(o.y-p.y)<1e-8;if(!s&&(f||m)){const e=f?"y":"x",t=Math.max(Math.min(o[e],c[e]),Math.min(d[e],p[e])),n=Math.min(Math.max(o[e],c[e]),Math.max(d[e],p[e]));n>t&&!l(f?{x:o.x,y:(t+n)/2}:{x:(t+n)/2,y:o.y})&&(h+=n-t)}}d+=r.size}return{metrics:{crossings:d,channelCongestion:h,alignmentError:l,totalRouteLength:a,bendCount:c,nodeDisplacement:0,reorderedParts:0,hardConstraintViolations:0,routedEdgeCount:e.length,omittedEdgeCount:0,completedSweeps:0},partial:w}}function ld(e,t){const n=/* @__PURE__ */new Map;for(const o of e??[]){const e=t(o);n.has(e)||n.set(e,o)}return n}function dd(e){const{graph:t}=e.prepared,n=new Map(t.nodes.map(e=>[e.id,e])),o=new Map(e.view.nodes.map(e=>[e.nodeId,e]));o.size!==e.view.nodes.length&&Cl("IDENTITY_VIEW","Duplicate node presentations.");for(const e of o.keys())n.has(e)||Cl("IDENTITY_VIEW","Unknown presentation owner.");const r=/* @__PURE__ */new Map;for(const e of t.nodes){let t=e.parentId;for(;t;)"summary"===o.get(t)?.mode&&r.set(e.id,t),t=n.get(t)?.parentId}return{semantics:n,views:o,hidden:r}}function ud(e,t,n,o,r){const{graph:i}=e.prepared,{semantics:s,views:a,hidden:c}=dd(e),l=[],d=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map;for(const h of[...i.nodes].sort((e,t)=>Nl(e.id,t.id))){if(c.has(h.id))continue;if(r&&r.positions.get(h.id)===n.get(h.id)&&r.orders.get(h.id)===o.get(h.id)){const e=r.bySemantic.get(h.id);if(l.push(e),"exploded"===a.get(h.id)?.mode)for(const t of e.parts??[])l.push(r.byId.get(JSON.stringify(["part",h.id,t.partId])));d.set(h.id,e),u.set(h.id,r.measures.get(h.id));continue}let i=t.get(h.id);i||Cl("GEOMETRY_MISSING","Every visible owner needs geometry.",{nodeIds:[h.id]});const p=a.get(h.id),f=p?.partLayout;if("rows"===f?.kind){ql(f.order,(h.parts??[]).map(e=>e.id));const t=o.get(h.id)??Wl(f.order);"fixed"!==f.order.mode&&(i.markAnchors?.length||i.slotAnchors?.length||e.view.anchors?.some(e=>e.ref.nodeId===h.id&&["point","named-mark","slot"].includes(e.binding.kind)))&&Cl("CONSTRAINT_ABSOLUTE_REORDER","Absolute anchors require fixed row order or a custom reflow adapter.",{nodeIds:[h.id]}),i=Gl(i,f,e.view.direction,t)}"summary"!==p?.mode&&(h.parts??[]).some(e=>!i.parts.some(t=>t.partId===e.id))&&Cl("GEOMETRY_MISSING_PART","Every visible part needs a rectangle.",{nodeIds:[h.id]}),i.parts.some(e=>!h.parts?.some(t=>t.id===e.partId))&&Cl("GEOMETRY_UNKNOWN_PART","Measured part does not exist.");const m=n.get(h.id),g={id:h.id,semantic:$l(h.id),rect:{...m,width:i.width,height:i.height},parts:i.parts.map(e=>({...e,rect:{...e.rect},semantic:$l(h.id,{kind:"part",partId:e.partId})})),partOrder:i.actualPartOrder&&[...i.actualPartOrder],markAnchors:i.markAnchors?.map(Kf),slotAnchors:i.slotAnchors?.map(Kf)};if(l.push(g),d.set(h.id,g),u.set(h.id,i),"exploded"===p?.mode)for(const e of g.parts??[]){const t=JSON.stringify(["part",h.id,e.partId]);s.has(t)&&Cl("IDENTITY_PROJECTION_COLLISION","A semantic ID collides with an exploded display ID."),l.push({id:t,semantic:e.semantic,rect:{...e.rect,x:m.x+e.rect.x,y:m.y+e.rect.y}})}}const h=i.nodes.some(e=>e.parentId),p=l.filter(e=>"node"===e.semantic.endpoint.kind).sort((e,t)=>e.rect.y-t.rect.y),f=r&&l.length===r.nodes.length&&l.every(e=>{const t=r.byId.get(e.id)?.rect;return t&&t.x===e.rect.x&&t.y===e.rect.y&&t.width===e.rect.width&&t.height===e.rect.height});for(let e=0;!f&&e<p.length;e++)for(let t=e+1;t<p.length;t++){const n=p[e],o=p[t];if(o.rect.y>n.rect.y+n.rect.height&&!h)break;const r=(e,t)=>{let n=e.parentId;for(;n;){if(n===t)return!0;n=s.get(n)?.parentId}return!1},i=r(s.get(n.id),o.id),a=r(s.get(o.id),n.id);if(i||a){const e=i?n:o,t=i?o:n;Kl(t.rect,e.rect)&&Kl(t.rect,{x:e.rect.x+e.rect.width,y:e.rect.y+e.rect.height})||Cl("CONSTRAINT_CONTAINMENT","Authored child bounds exceed the containing owner.",{nodeIds:[e.id,t.id]})}else Xl(n.rect,o.rect)&&Cl("CONSTRAINT_OVERLAP","Node boxes overlap.",{nodeIds:[n.id,o.id]})}const{view:m}=e;return{nodes:l,positions:new Map(n),orders:new Map(o),hidden:c,bySemantic:d,measures:u,semantics:s,presentations:a,anchors:ld(m.anchors,e=>Ql(e.ref,e.use)),exposures:ld(m.boundaryExposures,e=>Uf(e.containerNodeId,Ql(e.inner,e.use))),portOrders:ld(m.portOrders,e=>Xf(e.nodeId,e.partId,e.use,e.side)),byId:new Map(l.map(e=>[e.id,e]))}}function hd(e,t,n,o,r){const{view:i}=e,{semantics:s}=t,a=t.hidden.get(o.nodeId),c=a??o.nodeId;let l=t.bySemantic.get(c);const d=t.measures.get(c),u=t.presentations.get(c),h="summary"===u?.mode&&("part"===o.endpoint.kind||!!o.endpoint.portId),p=a||h?t.exposures.get(Uf(c,Ql(o,r))):void 0;!a&&!h||p||Cl("ENDPOINT_MISSING_EXPOSURE","Collapsed endpoints need explicit boundary exposures.",{endpointRefs:[o]});const f=t.anchors.get(Ql(o,r));let m=p?.binding??f?.binding;const g=Vl(i.direction,r);if(!m){let e={x:0,y:0,width:l.rect.width,height:l.rect.height};if("part"===o.endpoint.kind){const n=o.endpoint.partId,r=l.parts?.find(e=>e.partId===n);r||Cl("GEOMETRY_MISSING_PART","Endpoint has no solved part geometry.",{endpointRefs:[o]}),e=r.rect,"exploded"===u?.mode&&(l=t.byId.get(JSON.stringify(["part",c,n])),e={...e,x:0,y:0})}let n=.5;if(o.endpoint.portId){const e=s.get(o.nodeId),i="part"===o.endpoint.kind?o.endpoint.partId:void 0,a=((i?e.parts?.find(e=>e.id===i)?.ports:e.ports)??[]).filter(e=>"inout"===e.direction||e.direction===("source"===r?"out":"in")).map(e=>e.id).sort(Nl),c=t.portOrders.get(Xf(o.nodeId,i,r,g));c&&ql(c.order,a);const l=c?Wl(c.order):a;n=(l.indexOf(o.endpoint.portId)+1)/(l.length+1)}const i=Yl(e,g,n).point;n="west"===g||"east"===g?i.y/(l.rect.height||1):i.x/(l.rect.width||1),m={kind:"node-side",side:g,fraction:n}}const y=Zl(m,l,d);Dl(y.point.x,"anchor x",!1),Dl(y.point.y,"anchor y",!1);const x={x:y.normal.x,y:y.normal.y};1===Math.abs(x.x)&&0===x.y||1===Math.abs(x.y)&&0===x.x||Cl("CAPABILITY_NORMAL","The built-in orthogonal adapter requires cardinal unit normals.");const b={x:0,y:0,width:l.rect.width,height:l.rect.height};Kl(b,y.point)||Cl("GEOMETRY_ANCHOR_BOUNDS","Anchor is outside the display node.");const w={x:x.x>0?b.width:x.x<0?0:y.point.x,y:x.y>0?b.height:x.y<0?0:y.point.y};if(!("point"!==m.kind&&"named-mark"!==m.kind&&"slot"!==m.kind||w.x===y.point.x&&w.y===y.point.y)){const e=d.routingChannels??[],t=[0,1,...e.flatMap(e=>x.x?[(e.x-y.point.x)/(w.x-y.point.x),(e.x+e.width-y.point.x)/(w.x-y.point.x)]:[(e.y-y.point.y)/(w.y-y.point.y),(e.y+e.height-y.point.y)/(w.y-y.point.y)])].filter(e=>e>=0&&e<=1).sort((e,t)=>e-t);t.slice(1).some((n,o)=>!e.some(e=>Kl(e,{x:y.point.x+(w.x-y.point.x)*(n+t[o])/2,y:y.point.y+(w.y-y.point.y)*(n+t[o])/2})))&&Cl("CONSTRAINT_INTERIOR_ESCAPE","Interior mark needs a declared straight escape corridor.",{edgeIds:[n]})}const M=(l.parts??[]).filter(e=>"part-side"!==m.kind||e.partId!==m.partId).map(e=>e.rect);ed(y.point,w,[...d.obstacleRects??[],..."part-side"===m.kind?M:[]])&&Cl("CONSTRAINT_INTERIOR_ESCAPE","Terminal escape intersects an obstacle.",{edgeIds:[n]});const v=Math.max(e.options.terminalStub,e.options.obstaclePadding);return{edgeId:n,end:r,semantic:o,displayNodeId:l.id,anchor:{x:l.rect.x+y.point.x,y:l.rect.y+y.point.y},escape:{x:l.rect.x+w.x+x.x*v,y:l.rect.y+w.y+x.y*v},normal:x,precision:p?"proxy":"exact",exposureId:p?.id}}function pd(e){[e.requestId,e.view.revision,e.geometry.revision].every(e=>"string"==typeof e&&e.length>0)||Cl("REVISION_REQUIRED","Request, view and geometry revisions must be nonempty strings.");const t=new Map(e.prepared.graph.nodes.map(e=>[e.id,e])),n=/* @__PURE__ */new Set;for(const o of e.view.anchors??[]){Pl(t,o.ref,o.use);const e=Ql(o.ref,o.use);n.has(e)&&Cl("IDENTITY_ANCHOR","Duplicate endpoint/use anchor."),n.add(e)}const o=/* @__PURE__ */new Set,r=/* @__PURE__ */new Set;for(const n of e.view.boundaryExposures??[]){Pl(t,n.inner,n.use);let e=n.inner.nodeId;for(;e&&e!==n.containerNodeId;)e=t.get(e)?.parentId;e||Cl("ENDPOINT_EXPOSURE_OWNER","Exposure must refer to an endpoint inside its container.");const i=JSON.stringify([n.containerNodeId,Ql(n.inner,n.use)]);(o.has(n.id)||r.has(i))&&Cl("IDENTITY_EXPOSURE","Duplicate boundary exposure."),o.add(n.id),r.add(i)}const i=/* @__PURE__ */new Set;for(const n of e.view.portOrders??[]){const e=n.partId?{kind:"part",partId:n.partId}:{kind:"node"};Pl(t,$l(n.nodeId,e));const o=t.get(n.nodeId),r=((n.partId?o.parts?.find(e=>e.id===n.partId)?.ports:o.ports)??[]).filter(e=>"inout"===e.direction||e.direction===("source"===n.use?"out":"in"));ql(n.order,r.map(e=>e.id));const s=JSON.stringify([n.nodeId,n.partId??null,n.side,n.use]);i.has(s)&&Cl("ORDER_PORT_DUPLICATE","Repeated port order constraint."),i.add(s),"fixed"!==n.order.mode&&Cl("CAPABILITY_PORT_ORDER","This adapter supports fixed port order; port permutation needs another adapter.")}}function fd(e){const t="LR"===e.view.direction||"RL"===e.view.direction,n=new Map(e.view.edgeHints?.map(e=>[e.edgeId,e])),o=[...e.prepared.graph.edges].sort((e,t)=>Nl(n.get(e.id)?.laneId??"",n.get(t.id)?.laneId??"")||Nl(e.id,t.id)),r=new Set(o.filter(e=>"none"===(n.get(e.id)?.route??(e.source===e.target?"none":"auto"))).map(e=>e.id)),i=new Map(o.map(e=>[e.id,JSON.stringify([Sl($l(e.source,e.sourceEndpoint)),Sl($l(e.target,e.targetEndpoint))])])),s=new Map(o.map(e=>[e.id,JSON.stringify([e.source,e.target])])),a=/* @__PURE__ */new Map;for(const e of o){if(r.has(e.id))continue;const t=i.get(e.id),n=a.get(t)??[];n.push(e.id),a.set(t,n)}const c=/* @__PURE__ */new Map;for(const e of o){if(r.has(e.id))continue;const t=s.get(e.id),n=c.get(t)??[];n.push(e.id),c.set(t,n)}let l;return(d,u)=>{const h=[],p=d.nodes.filter(e=>"node"===e.semantic.endpoint.kind),f=e.options.obstaclePadding,m=p.map(e=>({x:e.rect.x-f,y:e.rect.y-f,width:e.rect.width+2*f,height:e.rect.height+2*f})),g=e.prepared.graph.nodes.some(e=>e.parentId),y=l&&d.nodes.every(e=>{const t=l.projection.byId.get(e.id)?.rect;return t&&t.x===e.rect.x&&t.y===e.rect.y&&t.width===e.rect.width&&t.height===e.rect.height});for(const n of o){const o=l?.edges.get(n.id);if("terminals"===e.options.routing&&o&&d.byId.get(o.source.displayNodeId)===l.projection.byId.get(o.source.displayNodeId)&&d.byId.get(o.target.displayNodeId)===l.projection.byId.get(o.target.displayNodeId)&&y){h.push(o);continue}const f=hd(e,d,n.id,$l(n.source,n.sourceEndpoint),"source"),x=hd(e,d,n.id,$l(n.target,n.targetEndpoint),"target"),b=r.has(n.id),w=b||"terminals"===e.options.routing||"bump"===e.options.routing,M=b?[n.id]:a.get(i.get(n.id)),v=(M.indexOf(n.id)-(M.length-1)/2)*e.options.laneGap;M.length>1&&0===e.options.laneGap&&"none"===e.options.bundles&&Cl("ROUTING_COINCIDENT","Exact duplicates require lane space or an explicit bundle.",{edgeIds:M});const I=(e,t)=>({x:e.x-t.y*v,y:e.y+t.x*v}),k=I(f.escape,f.normal),S=I(x.escape,{x:-x.normal.x,y:-x.normal.y});!w&&g&&p.some(e=>e.id!==f.displayNodeId&&e.id!==x.displayNodeId&&e.id!==n.source&&e.id!==n.target&&[f.anchor,x.anchor].some(t=>t.x>e.rect.x&&t.x<e.rect.x+e.rect.width&&t.y>e.rect.y&&t.y<e.rect.y+e.rect.height))&&Cl("CAPABILITY_COMPOUND_ROUTING","Cross-hierarchy routing needs collapsed authored boundary exposures.",{edgeIds:[n.id]});const $=f.displayNodeId!==n.source||x.displayNodeId!==n.target?m.filter((e,t)=>!(f.displayNodeId!==n.source&&p[t].id===n.source||x.displayNodeId!==n.target&&p[t].id===n.target)):m;(!w||M.length>1)&&(ed(f.escape,k,$)||ed(S,x.escape,$))&&Cl("ROUTING_LANE_SPACE","Pinned terminal lanes have insufficient clearance.",{edgeIds:[n.id]});const N=b?[n.id]:c.get(s.get(n.id)),E=(N.indexOf(n.id)-(N.length-1)/2)*e.options.laneGap,A=w?[k,S]:nd(k,S,$,E,t);A||Cl("ROUTING_NO_PATH","No route found within the adapter's visibility-grid budget.",{edgeIds:[n.id]});const C=td([f.anchor,f.escape,...A,x.escape,x.anchor]),O=w?sd(JSON.stringify([n.id,"route"]),f,x,k,S,!b&&"bump"===e.options.routing,t):od(JSON.stringify([n.id,"route"]),C,"smooth"===e.options.routing,$),T=e=>d.hidden.get(e)??e,P=T(n.source)!==T(n.target)&&u.get(T(n.source))>=u.get(T(n.target));h.push({routing:b?"none":e.options.routing,edgeId:n.id,source:f,target:x,sections:[O],bounds:O.bounds,feedback:P})}return l={projection:d,edges:new Map(h.map(e=>[e.edgeId,e]))},{edges:h,hints:n,sorted:o,excluded:r}}}function md(e,t){const n=new Map(e.map(e=>[e,0])),o=/* @__PURE__ */new Map;for(const[e,r]of t){const t=o.get(e)??/* @__PURE__ */new Set;t.has(r)||(t.add(r),n.set(r,(n.get(r)??0)+1)),o.set(e,t)}const r=e.filter(e=>!n.get(e)).sort(Nl),i=new Map(e.map(e=>[e,0]));let s=0;for(let e=0;e<r.length;e++){const t=r[e];s++;for(const e of[...o.get(t)??[]].sort(Nl))i.set(e,Math.max(i.get(e)??0,i.get(t)+1)),n.set(e,n.get(e)-1),n.get(e)||r.push(e)}return s===e.length?i:null}function gd(e){const t=/* @__PURE__ */new Set,n=[],o=(e,o)=>{t.add(e),t.add(o),n.push([e,o])};for(const t of e.prepared.graph.edges)o(Sl($l(t.source,t.sourceEndpoint)),Sl($l(t.target,t.targetEndpoint)));for(const t of e.prepared.graph.transfers??[])for(const e of t.sources)o(Sl($l(t.nodeId,e)),Sl($l(t.nodeId,t.target)));md([...t],n)||"strict-dag"!==e.options.topology||Cl("TOPOLOGY_SEMANTIC_CYCLE","Connections and transfers contain a semantic cycle.")}function yd(e,t){const n=t.nodes.filter(e=>"node"===e.semantic.endpoint.kind).map(e=>e.id),o=e=>t.hidden.get(e)??e,r=md(n,e.prepared.graph.edges.filter(e=>o(e.source)!==o(e.target)).map(e=>[o(e.source),o(e.target)]));return r||"strict-dag"!==e.options.topology||wd(e)||Cl("TOPOLOGY_PROJECTION_CYCLE","The display quotient is cyclic; expand the group or explicitly select feedback mode."),r??new Map(n.sort(Nl).map((e,t)=>[e,t]))}function xd(e){const t=new Map(e.view.constraints?.map(e=>[e.nodeId,e]));t.size!==(e.view.constraints?.length??0)&&Cl("CONSTRAINT_DUPLICATE","Duplicate node constraints.");const n=new Set(e.prepared.graph.nodes.map(e=>e.id));for(const e of t.values())n.has(e.nodeId)||Cl("CONSTRAINT_OWNER","Unknown constrained node."),!e.position||Number.isFinite(e.position.x)&&Number.isFinite(e.position.y)||Cl("GEOMETRY_POSITION","Positions must be finite."),e.pin&&!e.position&&Cl("CONSTRAINT_PIN","Pinned nodes need a position."),void 0!==e.rank&&(!Number.isInteger(e.rank)||e.rank<0)&&Cl("CONSTRAINT_RANK","Ranks must be nonnegative integers.");const o=/* @__PURE__ */new Map;for(const n of e.prepared.graph.nodes){const r=t.get(n.id);"route-only"!==e.options.mode||r?.position||Cl("CONSTRAINT_POSITION","Route-only mode requires authored positions for every owner.",{nodeIds:[n.id]}),o.set(n.id,r?.position??{x:0,y:0})}return o}function bd(e,t,n){const o="LR"===e.view.direction||"RL"===e.view.direction,r="RL"===e.view.direction||"BT"===e.view.direction,i=new Map(e.view.constraints?.map(e=>[e.nodeId,e])),s=new Map(e.geometry.nodes.map(e=>[e.nodeId,e]));for(const[e,n]of t){const o=i.get(e)?.rank;void 0!==o?t.set(e,o):t.set(e,n)}if("strict-dag"===e.options.topology)for(const n of e.prepared.graph.edges)n.source!==n.target&&t.has(n.source)&&t.has(n.target)&&t.get(n.source)>=t.get(n.target)&&Cl("CONSTRAINT_RANK","Authored ranks conflict with graph direction.",{edgeIds:[n.id]});let a=0;for(const c of[...new Set(t.values())].sort((e,t)=>e-t)){const l=[...t].filter(([,e])=>e===c).map(([e])=>e).sort(Nl);let d=0,u=0;for(const t of l){const c=s.get(t);c||Cl("GEOMETRY_MISSING","Missing node measurement.",{nodeIds:[t]});const l=o?c.width:c.height,h=o?c.height:c.width;u=Math.max(u,l);const p=r?-a-l:a,f=o?{x:p,y:d}:{x:d,y:p},m=i.get(t);n.set(t,{x:"x"===m?.pin||"both"===m?.pin?m.position.x:f.x,y:"y"===m?.pin||"both"===m?.pin?m.position.y:f.y}),d+=h+e.options.nodeGap}a+=u+e.options.rankGap}}function wd(e){const t=new Set(e.view.constraints?.filter(e=>"both"===e.pin&&e.position).map(e=>e.nodeId));return e.prepared.graph.nodes.every(e=>t.has(e.id))}function Md(e,t){const n=e.previous;if(!n)return;let o=Jf.get(n);return o||(o=new Map(n.nodes.map(e=>[e.id,e])),Jf.set(n,o)),o.get(t)}function vd(e){return{topology:"strict-dag",routing:"orthogonal",bundles:"none",rankGap:96,nodeGap:32,laneGap:6,terminalStub:12,obstaclePadding:6,maxSweeps:8,seed:0,...e,weights:{crossings:8,alignment:2,length:1,bends:1,congestion:4,displacement:4,reorder:3,...e.weights}}}function Id(e){const t=e.options;["route-only","optimize"].includes(t.mode)&&["strict-dag","feedback"].includes(t.topology)&&["orthogonal","polyline","smooth","terminals","bump"].includes(t.routing)&&["none","parallel","overview"].includes(t.bundles)&&["LR","RL","TB","BT"].includes(e.view.direction)||Cl("CAPABILITY_OPTIONS","Unknown layout mode, direction, routing or topology.");for(const e of["rankGap","nodeGap","laneGap","terminalStub","obstaclePadding","maxSweeps"])Dl(t[e],e);(!Number.isInteger(t.maxSweeps)||t.maxSweeps>100)&&Cl("CONSTRAINT_BUDGET","maxSweeps must be an integer in [0,100]."),Number.isSafeInteger(t.seed)||Cl("CONSTRAINT_SEED","Seed must be a safe integer."),Object.entries(t.weights??{}).forEach(([e,t])=>Dl(t,e)),"optimize"===t.mode&&!wd(e)&&e.prepared.graph.nodes.some(e=>e.parentId)&&Cl("CAPABILITY_COMPOUND_OPTIMIZE","Compound graphs require authored positions in this adapter.");const n=/* @__PURE__ */new Set,o=new Set(e.prepared.graph.edges.map(e=>e.id));for(const t of e.view.edgeHints??[])!n.has(t.edgeId)&&o.has(t.edgeId)||Cl("IDENTITY_EDGE_HINT","Edge hints must refer to unique existing edges."),n.add(t.edgeId),void 0===t.route||["auto","none"].includes(t.route)||Cl("CAPABILITY_OPTIONS","Unknown edge routing hint."),void 0!==t.priority&&Dl(t.priority,"priority")}function kd(e){return{schemaVersion:"semiotic.compositional-layout.v0.1",direction:e.view.direction,requestId:e.requestId,semanticHash:e.prepared.semanticHash,graphRevision:e.prepared.graph.revision,viewRevision:e.view.revision,geometryRevision:e.geometry.revision,engineId:"semiotic-compositional",engineVersion:"0.1.0",optionsHash:El(e.options),status:"complete",nodes:[],edges:[],bundles:[],bounds:{x:0,y:0,width:0,height:0},metrics:{crossings:0,channelCongestion:0,alignmentError:0,totalRouteLength:0,bendCount:0,nodeDisplacement:0,reorderedParts:0,hardConstraintViolations:0,routedEdgeCount:0,omittedEdgeCount:e.prepared.graph.edges.length,completedSweeps:0},diagnostics:[]}}function Sd(e,t,n,o,r){const i=ud(e,t,n,o,r.projection);r.projection=i;const s=r.ranks??(r.ranks=yd(e,i)),a="LR"===e.view.direction||"RL"===e.view.direction,c=[],{edges:l,hints:d,sorted:u,excluded:h}=r.routeEdges(i,s),p=new Set(u.filter(e=>"none"!==d.get(e.id)?.alignment).map(e=>e.id)),{metrics:f,partial:m}=cd(l,a,p,e.options.routing,h);f.channelCongestion>1e-8&&c.push({code:"ROUTING_CONGESTION",severity:"warning",message:"Some routes share undeclared segments. Every edge is retained; use the connection table to disambiguate.",edgeIds:l.map(e=>e.edgeId)}),m&&c.push({code:"ROUTING_METRIC_BUDGET",severity:"warning",message:"Crossing count is a lower bound after two million segment comparisons."}),"estimated"===e.geometry.basis&&c.push({code:"GEOMETRY_ESTIMATED",severity:"warning",message:"Attachment geometry is provisional."}),"smooth"!==e.options.routing&&"bump"!==e.options.routing||c.push({code:"ROUTING_CURVE_METRICS",severity:"info",message:"Curve length and crossings use 24 samples per cubic; bounds use conservative control envelopes."});const g=new Map(u.map(e=>[e.id,e])),y=[];if("none"!==e.options.bundles){const t=/* @__PURE__ */new Map;for(const e of l){if(h.has(e.edgeId))continue;const n=g.get(e.edgeId),o=JSON.stringify(["bundle",e.source.displayNodeId,e.target.displayNodeId,e.source.exposureId??Sl(e.source.semantic),e.target.exposureId??Sl(e.target.semantic),n.kind??"unspecified",d.get(n.id)?.bundleGroup??null]),r=t.get(o)??[];r.push(e),t.set(o,r)}for(const[n,o]of t)o.length>1&&y.push({id:n,kind:e.options.bundles,memberEdgeIds:o.map(e=>e.edgeId),path:o[0].sections,count:o.length,countStatus:"exact",semanticKind:g.get(o[0].edgeId)?.kind??"unspecified"})}return{...kd(e),status:m&&"terminals"!==e.options.routing||f.channelCongestion>1e-8||"estimated"===e.geometry.basis?"degraded":"complete",nodes:i.nodes,edges:l,bundles:y,bounds:Hl([...i.nodes.map(e=>e.rect),...l.map(e=>e.bounds)]),metrics:f,diagnostics:c}}function $d(e,t,n){const o=e.metrics,r=vd(t.options).weights,i=Math.max(1,t.options.rankGap),s=t.view.nodes.reduce((e,t)=>"rows"===t.partLayout?.kind?e+Wl(t.partLayout.order).filter((e,o)=>n.get(t.nodeId)?.[o]!==e).length:e,0),a=e.nodes.filter(e=>"node"===e.semantic.endpoint.kind),c=a.reduce((e,n)=>{const o=Md(t,n.id);return e+(o?Vf(o.rect,n.rect):0)},0);return r.crossings*o.crossings+r.alignment*o.alignmentError/i+r.length*o.totalRouteLength/i+r.bends*o.bendCount+r.congestion*o.channelCongestion/i+r.reorder*s/Math.max(1,a.length)+r.displacement*c/i}function Nd(e){const t={...e,options:vd(e.options)};try{Id(t),pd(t),gd(t);const e=Jl(t.geometry),n=xd(t),o=/* @__PURE__ */new Map;for(const e of t.view.nodes)"rows"===e.partLayout?.kind&&o.set(e.nodeId,Wl(e.partLayout.order));if("optimize"===t.options.mode&&!wd(t)){const e=t.prepared.graph,o=md(e.nodes.map(e=>e.id),e.edges.filter(e=>e.source!==e.target).map(e=>[e.source,e.target]));o||"strict-dag"!==t.options.topology||Cl("TOPOLOGY_PROJECTION_CYCLE","Owner projection is cyclic."),bd(t,o??new Map([...e.nodes].sort((e,t)=>Nl(e.id,t.id)).map((e,t)=>[e.id,t])),n)}const r={routeEdges:fd(t)},i=new Map(t.view.edgeHints?.map(e=>[e.edgeId,e])),s=new Set(t.prepared.graph.edges.filter(e=>"none"!==i.get(e.id)?.alignment&&"none"!==(i.get(e.id)?.route??(e.source===e.target?"none":"auto"))).map(e=>e.id));let a=Sd(t,e,n,o,r),c=$d(a,t,o),l=0,d=0;const u=()=>{d++;try{const i=Sd(t,e,n,o,r),s=$d(i,t,o);if(s+1e-8<c)return a=i,c=s,!0}catch(e){if(!(e instanceof Bf))throw e}return!1};if("optimize"===t.options.mode)for(let e=0;e<t.options.maxSweeps&&d<256;e++){let e=!1;for(const n of[...t.view.nodes].sort((e,t)=>Nl(e.nodeId,t.nodeId))){if("rows"!==n.partLayout?.kind)continue;const t=o.get(n.nodeId);e:for(let r=0;r<t.length-1&&d<256;r++)for(let i=r+1;i<t.length&&d<256;i++){if(!Bl(n.partLayout.order,t[r],t[i]))continue;const s=[...t];if([s[r],s[i]]=[s[i],s[r]],o.set(n.nodeId,s),u()){e=!0;break e}o.set(n.nodeId,t)}}const r="LR"===t.view.direction||"RL"===t.view.direction,i=new Map(a.nodes.map(e=>[e.id,e.semantic.nodeId]));for(const o of a.nodes){if(d>=256)break;if("node"!==o.semantic.endpoint.kind)continue;const c=t.view.constraints?.find(e=>e.nodeId===o.id);if("both"===c?.pin||c?.pin===(r?"y":"x"))continue;const l=a.edges.filter(e=>s.has(e.edgeId)).flatMap(e=>i.get(e.source.displayNodeId)===o.id?[r?e.target.anchor.y-e.source.anchor.y:e.target.anchor.x-e.source.anchor.x]:i.get(e.target.displayNodeId)===o.id?[r?e.source.anchor.y-e.target.anchor.y:e.source.anchor.x-e.target.anchor.x]:[]).sort((e,t)=>e-t);if(!l.length)continue;const h=l[Math.floor(l.length/2)],p=n.get(o.id);Math.abs(h)<1e-8||(n.set(o.id,{x:p.x+(r?0:h),y:p.y+(r?h:0)}),u()?e=!0:n.set(o.id,p))}if(l++,!e)break}const h=t.view.nodes.reduce((e,t)=>"rows"===t.partLayout?.kind?e+Wl(t.partLayout.order).filter((e,n)=>o.get(t.nodeId)?.[n]!==e).length:e,0),p=[...a.diagnostics,{code:"LAYOUT_TERMINATION",severity:"info",message:"route-only"===t.options.mode?"Authored positions and order retained.":`Bounded local optimization completed ${l} sweeps and ${d} candidate evaluations${d>=256?" (candidate budget reached)":""}.`}];return Al({...a,metrics:{...a.metrics,completedSweeps:l,reorderedParts:h,nodeDisplacement:a.nodes.reduce((e,n)=>{if("node"!==n.semantic.endpoint.kind)return e;const o=Md(t,n.id);return e+(o?Vf(o.rect,n.rect):0)},0)},diagnostics:p})}catch(e){if(!(e instanceof Bf))throw e;return Al({...kd(t),status:"infeasible",diagnostics:e.diagnostics,metrics:{...kd(t).metrics,hardConstraintViolations:1}})}}function Ed(e,t){const{semantics:n,views:o,hidden:r}=dd(e),i=/* @__PURE__ */new Set;for(const e of n.values())if(!r.has(e.id)&&(i.add(Sl($l(e.id))),"exploded"===o.get(e.id)?.mode))for(const t of e.parts??[])i.add(Sl($l(e.id,{kind:"part",partId:t.id})));for(const e of t.nodes){const t=Sl(e.semantic);i.delete(t)||Cl("IDENTITY_SOLVED_NODE","Unknown, hidden or repeated display-node semantics."),_l(e.rect);const r=n.get(e.semantic.nodeId),s="node"===e.semantic.endpoint.kind,a=/* @__PURE__ */new Set;for(const t of e.parts??[])s&&!a.has(t.partId)&&r.parts?.some(e=>e.id===t.partId)&&Sl(t.semantic)===Sl($l(r.id,{kind:"part",partId:t.partId}))||Cl("IDENTITY_SOLVED_PART","Solved parts must retain unique owner-local semantic identities."),a.add(t.partId),_l(t.rect);s&&"summary"!==o.get(r.id)?.mode&&(r.parts??[]).some(e=>!a.has(e.id))&&Cl("IDENTITY_SOLVED_PART","A visible owner is missing solved parts.")}i.size&&Cl("IDENTITY_SOLVED_NODE","A feasible solution must cover the requested visible projection.")}function Ad(e,t){if(["complete","degraded","infeasible"].includes(t.status)||Cl("REVISION_STATUS","Unknown layout status."),"infeasible"===t.status)return;const n=new Map(t.nodes.map(e=>[e.id,e])),{hidden:o}=dd(e);n.size!==t.nodes.length&&Cl("IDENTITY_SOLVED_NODE","Duplicate display node ID."),Ed(e,t),_l(t.bounds);const r=new Map(e.prepared.graph.edges.map(e=>[e.id,e])),i=/* @__PURE__ */new Set;for(const e of t.edges){const s=r.get(e.edgeId);s&&!i.has(e.edgeId)||Cl("IDENTITY_SOLVED_EDGE","Unknown or repeated solved edge ID."),i.add(e.edgeId),Sl(e.source.semantic)===Sl($l(s.source,s.sourceEndpoint))&&Sl(e.target.semantic)===Sl($l(s.target,s.targetEndpoint))||Cl("ENDPOINT_SOLVED_RETARGET","An engine changed the semantic endpoint.",{edgeIds:[e.edgeId]}),_l(e.bounds),n.has(e.source.displayNodeId)&&n.has(e.target.displayNodeId)&&e.sections.length||Cl("GEOMETRY_SOLVED_ROUTE","A route needs display owners and path sections.");for(const t of[e.source,e.target]){const r=n.get(t.displayNodeId),i=o.get(t.semantic.nodeId)??t.semantic.nodeId;r.semantic.nodeId===i&&Kl(r.rect,t.anchor)||Cl("GEOMETRY_TERMINAL_OWNER","A terminal must attach to its own display node.",{edgeIds:[e.edgeId]})}let a=e.source.anchor;for(const n of e.sections){_l(n.bounds),(n.points.length<2||Vf(a,n.points[0])>1e-7)&&Cl("GEOMETRY_ROUTE_CONTINUITY","Route skeleton does not meet its terminal or preceding section.");const o=n.commands;o?.length&&("M"!==o[0].kind||Vf(a,o[0].point)>1e-7||Vf(o[o.length-1].point,n.points[n.points.length-1])>1e-7)&&Cl("GEOMETRY_ROUTE_COMMANDS","Final commands and skeleton disagree at terminals.");const r=[...n.points,...(o??[]).flatMap(e=>"C"===e.kind?[e.point,e.control1,e.control2]:[e.point])];for(const o of r)Number.isFinite(o.x)&&Number.isFinite(o.y)&&Kl(n.bounds,o)&&Kl(e.bounds,o)&&Kl(t.bounds,o)||Cl("GEOMETRY_ROUTE_BOUNDS","Route geometry must be finite and within its conservative bounds.");a=n.points[n.points.length-1]}Vf(a,e.target.anchor)>1e-7&&Cl("GEOMETRY_ROUTE_TERMINAL","Route misses its target anchor.")}i.size===r.size&&t.metrics.routedEdgeCount===i.size&&0===t.metrics.omittedEdgeCount||Cl("ROUTING_OMITTED_EDGE","A feasible transaction must represent every requested connection."),"complete"===t.status&&0!==t.metrics.hardConstraintViolations&&Cl("CONSTRAINT_SOLVED","A complete result cannot contain hard constraint violations.");for(const e of t.bundles)(new Set(e.memberEdgeIds).size!==e.memberEdgeIds.length||e.count!==e.memberEdgeIds.length||e.memberEdgeIds.some(e=>!r.has(e)))&&Cl("IDENTITY_BUNDLE","Bundle counts and memberships must match materialized edges.")}async function Cd(e,t,n){const o={...e,options:vd(e.options)};n?.aborted&&Cl("REVISION_CANCELLED","Layout request was cancelled.");const r=t.capabilities,i=[["route-only"===o.options.mode||!!e.view.constraints?.some(e=>!!e.pin),r.fixedPositions,"fixed positions"],[!!e.view.anchors?.length,r.fixedPortPositions,"exact anchors"],[!!e.view.nodes.some(e=>"rows"===e.partLayout?.kind),r.constrainedPartOrder,"part order"],[e.prepared.graph.edges.length>new Set(e.prepared.graph.edges.map(e=>JSON.stringify([e.source,e.target]))).size,r.multiedges,"multiedges"],["orthogonal"===o.options.routing,r.orthogonalRouting,"orthogonal routing"],["terminals"===o.options.routing,!!r.terminalRouting,"terminal routing"],["bump"===o.options.routing,!!r.bumpRouting,"bump routing"]];for(const[e,t,n]of i)e&&!t&&Cl("CAPABILITY_ENGINE",`Engine does not support ${n}.`);const s=await t.layout(o,n);return n?.aborted&&Cl("REVISION_CANCELLED","Layout request was cancelled."),s.requestId===e.requestId&&s.semanticHash===e.prepared.semanticHash&&s.graphRevision===e.prepared.graph.revision&&s.viewRevision===e.view.revision&&s.geometryRevision===e.geometry.revision&&s.optionsHash===El(o.options)&&s.engineId===t.id&&s.engineVersion===t.version||Cl("REVISION_RESPONSE","Engine response does not match the requested revision tuple."),Ad(o,s),Al(s)}function Od(e){const{prepared:t,solved:n}=e;"infeasible"!==n.status&&n.semanticHash===t.semanticHash&&n.graphRevision===t.graph.revision||Cl("REVISION_SCENE","Scene needs a feasible solution matching the semantic revision.");const o=new Map(t.graph.nodes.map(e=>[e.id,e])),r=new Map(t.graph.edges.map(e=>[e.id,e])),i=new Map(n.nodes.filter(e=>"node"===e.semantic.endpoint.kind).map(e=>[e.semantic.nodeId,e.id])),s=new Set(n.nodes.filter(e=>"part"===e.semantic.endpoint.kind).map(e=>Sl(e.semantic)));return{sceneNodes:n.nodes.flatMap(t=>{const n=o.get(t.semantic.nodeId),r="node"===t.semantic.endpoint.kind,a="part"===t.semantic.endpoint.kind?t.semantic.endpoint.partId:void 0,c=n.parts?.find(e=>e.id===a),l={type:"rect",id:t.id,navParentId:r?void 0:i.get(n.id),x:t.rect.x,y:t.rect.y,w:t.rect.width,h:t.rect.height,label:r?n.label??n.id:c?.label??a,datum:r?{...n,semantic:t.semantic}:{id:a,ownerId:n.id,semantic:t.semantic},style:{fill:r?e.nodeFill??"#edf2f7":e.partFill??"#c9dce8",stroke:"#556779",strokeWidth:1}};return e.showParts&&r?[l,...(t.parts??[]).filter(e=>!e.clipped&&!s.has(Sl(e.semantic))).map(o=>({type:"rect",id:JSON.stringify(["part-hit",t.id,o.partId]),navParentId:t.id,x:t.rect.x+o.rect.x,y:t.rect.y+o.rect.y,w:o.rect.width,h:o.rect.height,label:n.parts?.find(e=>e.id===o.partId)?.label??o.partId,datum:{id:o.partId,ownerId:n.id,semantic:o.semantic},style:{fill:e.partFill??"#c9dce8"}}))]:[l]}),sceneEdges:n.edges.map(t=>({type:"curved",id:t.edgeId,pathD:t.sections.map(rd).join(" "),datum:{...r.get(t.edgeId),sourceTerminal:t.source,targetTerminal:t.target},label:t.edgeId,style:{fill:"none",stroke:e.edgeStroke??"#467895",strokeWidth:1.5}}))}}function Td(e,t=Zf){const n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set;let r=!1;const i=t=>{try{e.postMessage({type:"cancel",requestId:t})}catch{}},s=({data:e})=>{if("result"!==e.type&&"error"!==e.type)return;const t=n.get(e.requestId);t&&(t.clean(),n.delete(e.requestId),"result"===e.type?t.resolve(e.solved):t.reject(new Error(e.message)))},a=e=>{for(const t of n.values())t.clean(),t.reject(new Error(`REVISION_WORKER_FAILED: ${e}`));n.clear()},c=e=>{"messageerror"===e?.type?a("A worker message could not be deserialized."):"error"===e?.type&&a(e.message||"The worker reported an error.")},l=e;return e.addEventListener("message",s),l.addEventListener?.("error",c),l.addEventListener?.("messageerror",c),{...t,layout:(t,s)=>new Promise((a,c)=>{if(r||s?.aborted)return void c(new Error("REVISION_CANCELLED"));if(o.has(t.requestId))return void c(new Error("REVISION_REQUEST_ID: request IDs must be unique for the engine's lifetime."));o.add(t.requestId);const l=()=>{n.delete(t.requestId),s?.removeEventListener("abort",l),c(new Error("REVISION_CANCELLED")),i(t.requestId)};n.set(t.requestId,{resolve:a,reject:c,clean:()=>s?.removeEventListener("abort",l)}),s?.addEventListener("abort",l,{once:!0});try{e.postMessage({type:"solve",request:t})}catch(e){n.delete(t.requestId),s?.removeEventListener("abort",l),c(e)}}),dispose(){r=!0,e.removeEventListener("message",s),l.removeEventListener?.("error",c),l.removeEventListener?.("messageerror",c);for(const[e,t]of n)t.clean(),t.reject(new Error("REVISION_CANCELLED")),i(e);n.clear(),o.clear()}}}function Pd(e,t=Zf){const n=/* @__PURE__ */new Map,o=({data:o})=>{if("cancel"===o.type)return void n.get(o.requestId)?.abort();if("solve"!==o.type)return;const r=o.request,i=new AbortController;n.get(r.requestId)?.abort(),n.set(r.requestId,i),Promise.resolve().then(()=>t.layout(r,i.signal)).then(t=>{i.signal.aborted||e.postMessage({type:"result",requestId:r.requestId,solved:t})}).catch(t=>{if(!i.signal.aborted)try{e.postMessage({type:"error",requestId:r.requestId,message:t instanceof Error?t.message:"Worker layout failed."})}catch{}}).finally(()=>{n.get(r.requestId)===i&&n.delete(r.requestId)})};return e.addEventListener("message",o),()=>{e.removeEventListener("message",o),n.forEach(e=>e.abort()),n.clear()}}function Rd(e,t){const n="TB"!==e.direction&&"BT"!==e.direction,o=e.nodes.find(e=>e.id===t.nodeId);o&&"infeasible"!==e.status||Cl("GEOMETRY_SCROLL_OWNER","Scroll projection requires a feasible visible owner."),_l(t.viewport),Dl(t.offsetY,"offsetY");const r=t.viewport;(r.x<0||r.y<0||r.x+r.width>o.rect.width||r.y+r.height>o.rect.height)&&Cl("GEOMETRY_SCROLL_VIEWPORT","Row viewport must be inside the owner.");const i=o.rect.y+r.y,s=i+r.height,a=e=>{if(e.displayNodeId!==o.id||"part"!==e.semantic.endpoint.kind)return e;(0!==e.normal.y||Math.abs(e.anchor.x-o.rect.x)>1e-7&&Math.abs(e.anchor.x-o.rect.x-o.rect.width)>1e-7)&&Cl("CAPABILITY_SCROLL_ANCHOR","This scroll projection requires horizontal boundary row slots.");const n=e.anchor.y-t.offsetY,r=n>=i&&n<=s,a=Math.max(i,Math.min(s,n));return{...e,anchor:{...e.anchor,y:a},escape:{...e.escape,y:a},precision:r?e.precision:"proxy",exposureId:r?e.exposureId:JSON.stringify(["scroll",Sl(e.semantic),e.end])}},c=e.nodes.map(e=>e.id!==o.id?e:{...e,parts:e.parts?.map(e=>{const n={...e.rect,y:e.rect.y-t.offsetY};return{...e,rect:n,clipped:n.y<r.y||n.y+n.height>r.y+r.height}})}),l=e.edges.map(e=>{const t=a(e.source),o=a(e.target);if(t===e.source&&o===e.target)return e;1!==e.sections.length&&Cl("CAPABILITY_SCROLL_SECTIONS","The built-in scroll repair requires a single route section.");const r=e.sections[0],i=r.points.slice(1,-1),s=td([t.anchor,t.escape,...i,o.escape,o.anchor]),c=(e,t,n)=>({x:e.x+n.escape.x-t.escape.x,y:e.y+n.escape.y-t.escape.y}),l="none"===e.routing||"terminals"===e.routing||"bump"===e.routing?sd(r.id,t,o,r.points.length>4?c(r.points[2],e.source,t):t.escape,r.points.length>4?c(r.points[r.points.length-3],e.target,o):o.escape,"bump"===e.routing,n):od(r.id,s,!1,[]);return{...e,source:t,target:o,sections:[l],bounds:l.bounds}}),d=l.find(e=>"none"!==e.routing)?.routing,u=cd(l,n,new Set(l.map(e=>e.edgeId)),"none"===d?"orthogonal":d,new Set(l.filter(e=>"none"===e.routing).map(e=>e.edgeId)));return Al({...e,viewRevision:t.viewRevision,nodes:c,edges:l,bundles:[],bounds:Hl([...c.map(e=>e.rect),...l.map(e=>e.bounds)]),metrics:{...e.metrics,...u.metrics,completedSweeps:0},status:"degraded",diagnostics:[...e.diagnostics,{code:"GEOMETRY_SCROLL_PROXIES",severity:"info",message:"Clipped row endpoints use disclosed continuation proxies; terminal routes were locally repaired without a global solve.",nodeIds:[o.id]}]})}var jd,Fd,Ld,zd,Dd,_d,Wd=Object.create,qd=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Gd=Object.getOwnPropertyNames,Yd=Object.getPrototypeOf,Vd=Object.prototype.hasOwnProperty,Hd=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[Gd(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},Ud=(e,t)=>{for(var n in t)qd(e,n,{get:t[n],enumerable:!0})},Xd=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Gd(t))Vd.call(e,r)||r===n||qd(e,r,{get:()=>t[r],enumerable:!(o=Bd(t,r))||o.enumerable});return e},Kd=(e,t,n)=>(n=null!=e?Wd(Yd(e)):{},Xd(!t&&e&&e.__esModule?n:qd(n,"default",{value:e,enumerable:!0}),e)),Jd=Hd({"src/components/charts/shared/minMax.ts"(){}}),Zd=Hd({"src/components/recipes/atlas/entityCounts.ts"(){}}),Qd=Hd({"src/components/recipes/atlas/ids.ts"(){}}),eu=Hd({"src/components/recipes/atlas/ledger.ts"(){Qd(),jd={exact:0,estimated:1,incomplete:2,unknown:3}}}),tu=Hd({"src/components/recipes/atlas/compare.ts"(){Zd(),eu()}}),nu=Hd({"src/components/recipes/atlas/completeness.ts"(){Qd()}}),ou=Hd({"src/components/recipes/atlas/directedGraph.ts"(){}}),ru=Hd({"src/components/recipes/atlas/rootedForest.ts"(){ou()}}),iu=Hd({"src/components/recipes/atlas/forests.ts"(){Qd(),ru()}}),su=Hd({"src/components/recipes/atlas/types.ts"(){Fd="0.2",Ld=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],zd=["serial-chain","fan-out","fan-in"],Dd=[...zd,"repeated-state-episode"]}}),au=Hd({"src/components/recipes/atlas/motifs.ts"(){Qd(),su()}}),cu=Hd({"src/components/recipes/atlas/prefixForest.ts"(){Qd()}}),lu=Hd({"src/components/recipes/atlas/sections.ts"(){Qd()}}),du=Hd({"src/components/recipes/atlas/support.ts"(){}}),uu=Hd({"src/components/recipes/atlas/requiredPaths.ts"(){ou()}}),hu=Hd({"src/components/charts/shared/dataRecords.ts"(){}}),pu=Hd({"src/components/recipes/atlas/validateShape.ts"(){hu(),_d=["entity","occurrence","embedding","work-item"]}}),fu=Hd({"src/components/recipes/atlas/validate.ts"(){Qd(),pu(),su()}}),mu={};Ud(mu,{prepareNetworkAtlas:()=>J});var gu=Hd({"src/components/recipes/atlas/prepare.ts"(){tu(),nu(),iu(),eu(),au(),cu(),lu(),du(),uu(),fu(),hu()}}),yu=Hd({"src/components/recipes/atlas/capsules.ts"(){}}),xu=Hd({"src/components/recipes/atlas/profile.ts"(){Zd(),tu()}}),bu={};Ud(bu,{assignedDenominator:()=>p,prepareMotifBraid:()=>oe,ribbonSupportsRoute:()=>re});var wu,Mu,vu,Iu,ku,Su,$u=Hd({"src/components/recipes/atlas/braid.ts"(){yu(),tu(),du(),Qd(),xu()}}),Nu=Hd({"src/components/stream/layouts/forceLayoutNodeSize.ts"(){wu=require("d3-scale"),Jd()}}),Eu=Hd({"src/components/stream/layouts/forceLayoutEdgeWeight.ts"(){}}),Au=Hd({"src/components/stream/layouts/forceLayoutWorkerPolicy.ts"(){Nu(),Eu(),Mu=4e4}}),Cu=Hd({"src/components/stream/workerModuleUrl.ts"(){}}),Ou=Hd({"src/components/stream/moduleWorkerSession.ts"(){vu=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.failure=null,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{if(this.dead)return;let t;try{t=this.options.parseMessage(e.data)}catch(e){return void this.fail(e instanceof Error?e:new Error(String(e)))}const n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(new Error(`${this.options.name} worker response missing requestId`)));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onmessageerror=()=>{this.fail(new Error(`${this.options.name} worker response could not be deserialized`))},this.worker.onerror=e=>{this.fail(new Error(e.message||`${this.options.name} worker failed`))}}get isDead(){return this.dead}fail(e){this.dead||(this.failure=e,this.rejectAll(e),this.terminate())}request(e,t){if(this.dead)return Promise.reject(new Error(`${this.options.name} worker session is closed`));if(t?.aborted)return Promise.reject(ue(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{let i;const s=()=>{const e=1===this.pending.size;this.pending.delete(n),a(),r(ue(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},a=()=>{t?.removeEventListener("abort",s),clearTimeout(i)};this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",s,{once:!0}),void 0!==this.options.requestTimeoutMs&&(i=setTimeout(()=>{this.fail(new Error(`${this.options.name} worker request timed out`))},this.options.requestTimeoutMs));try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(e instanceof Error?e:new Error(String(e)))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(new Error(`${this.options.name} worker terminated`)),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}}}}),Tu={};Ud(Tu,{DEFAULT_FORCE_WORKER_THRESHOLD:()=>Mu,ForceLayoutWorkerSession:()=>ku,_resetSharedForceLayoutSessionForTest:()=>ge,canUseForceWorker:()=>ce,createForceLayoutWorker:()=>me,createFrameForceWorkerRequest:()=>le,runForceLayoutWorker:()=>ye,shouldUseForceWorker:()=>ae});var Pu,Ru=Hd({"src/components/stream/layouts/forceLayoutWorkerClient.ts"(){Cu(),Ou(),Au(),Au(),Iu={},ku=class{constructor(e=me()){this.session=new vu({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=pe(t);if(o)return{requestId:n,ok:!1,error:he(o)};if(!t?.positions||"object"!=typeof t.positions||Array.isArray(t.positions)||!Object.values(t.positions).every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y)))throw new Error("Malformed force worker response");return{requestId:n,ok:!0,payload:{positions:t.positions}}}})}get isDead(){return this.session.isDead}get failure(){return this.session.failure}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},Su=/* @__PURE__ */fe(()=>new ku)}}),ju={};Ud(ju,{CompositionalGraphError:()=>Bf,CompositionalLayoutController:()=>Qf,CompositionalMeasurementTransaction:()=>tm,DEFAULT_AREA_PER_ANNOTATION:()=>Dp,DEFAULT_GLYPH_ANCHOR:()=>Nf,DEFAULT_GLYPH_VIEWBOX:()=>$f,DEFAULT_HIT_RADIUS:()=>If,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>xh,GRID_FUEL_KEYS:()=>Zp,GRID_FUEL_LABELS:()=>Qp,LayoutCache:()=>Lu,SYMBOL_SEQUENCE:()=>Uu,TAU:()=>Sf,absorbRegion:()=>Ra,activeCountOverDomain:()=>Li,addPoints:()=>Ds,adjacencyFlowLayout:()=>yp,adjacencyMatrix:()=>nl,aggregateAdjacencyFlow:()=>mr,aggregateRegionCounts:()=>ba,allocateCells:()=>Le,analyzeNetEnsemble:()=>qo,angleScale:()=>js,annotationBudget:()=>Qr,annotationDensity:()=>ti,annotationLayout:()=>bi,arcLayout:()=>Qc,arcPath:()=>el,arrivalReplay:()=>Kc,axisFixedForceLayout:()=>cf,axisFixedForcePositions:()=>Xi,balanceSnapshotsToFlows:()=>_e,bandLabel:()=>Fo,betweenness:()=>ca,bfsDistances:()=>ia,bobaLayout:()=>Fp,bodyGroupSpec:()=>Fa,boundsOf:()=>Ro,boxEdgeAnchors:()=>qi,buildAdjacency:()=>oa,buildTooltipEntries:()=>Zs,bulletLayout:()=>Np,calendarLayout:()=>hh,capacitatedRegion:()=>Ta,chargeGateRegion:()=>Aa,circularLayout:()=>tl,clamp:()=>xe,classifyReserve:()=>Ii,closeness:()=>la,clustering:()=>da,collidersFromScales:()=>Yc,comparePhysicsTrace:()=>tc,composePhysicsControllers:()=>xc,compositionalDagEngine:()=>Zf,compositionalDagLayout:()=>em,compositionalEndpointKey:()=>Sl,compositionalLayoutOptions:()=>vd,compositionalPath:()=>rd,compositionalRowGeometry:()=>Gl,computeTransitDiagramPositions:()=>qn,countPairwiseCrossings:()=>Is,createCapacityQueueController:()=>gc,createCompositionalWorkerEngine:()=>Td,createDagreFit:()=>Pn,createDependencyGateController:()=>Ic,createFlextreeFit:()=>An,createLineageDagFit:()=>io,createPortalController:()=>bc,createProcessJourneyLedger:()=>ac,createServiceLevelController:()=>vc,createServiceResourcePoolController:()=>wc,cubicPath:()=>Vi,cubicPoint:()=>Gi,cubicTangent:()=>Yi,curvedEdgePath:()=>_i,cyclicRangeContains:()=>ms,dagreLayout:()=>Wh,degree:()=>ra,demandForecastRows:()=>Si,describePhysicsStageGeography:()=>zc,diagnoseTokenEncoding:()=>ot,dimFor:()=>Se,egoNetwork:()=>aa,emitCompositionalScene:()=>Od,estimateLabelWidth:()=>$s,extractTooltipDatum:()=>Js,fanOutBend:()=>Bi,flextreeLayout:()=>Lh,forceFieldRegion:()=>ja,forceLayout:()=>Ye,forceLayoutAsync:()=>pa,formatMw:()=>Pi,formatReservePct:()=>Ri,formatTooltipValue:()=>Qs,galtonPegs:()=>Vc,generateTokens:()=>tt,geoAreaHitTarget:()=>cs,geoHitTarget:()=>as,geographicDotGridLayout:()=>Fh,geographicGridLayout:()=>Eh,glyphExtent:()=>Ys,glyphFractionClipRect:()=>Vs,glyphPlacement:()=>Gs,gridEventAnnotations:()=>Oi,gridifyGeographicPoints:()=>Ht,groupBy:()=>ve,groupCompletionRows:()=>Ma,hatchFill:()=>Lo,hitTargetPoint:()=>ss,hitTargetRect:()=>ls,hullFromBoxes:()=>jo,installCompositionalWorker:()=>Pd,intervalLanesLayout:()=>sf,isometricLandmarkLayout:()=>vh,isotypeBoltGlyph:()=>th,isotypeBusGlyph:()=>nh,isotypeChipGlyph:()=>eh,isotypeGhost:()=>Zu,isotypeInk:()=>Ku,isotypeNetworkGlyphs:()=>ih,isotypePaper:()=>Ju,isotypePersonGlyph:()=>rh,isotypePersonPath:()=>oh,isotypeServerGlyph:()=>Qu,layoutChipStrip:()=>Ss,layoutCompositionalGraph:()=>Cd,layoutSequence:()=>ks,layoutTokenGrid:()=>nt,legendGroupsFrom:()=>Us,legendSwatches:()=>Xs,lineageDagLayout:()=>Zh,linearAxis:()=>zo,makeShade:()=>Ee,marimekkoLayout:()=>Sp,markCallout:()=>Do,matchesHighlight:()=>ke,mean:()=>Pe,membraneRegion:()=>Ea,mermaidDagLayout:()=>cp,mobileAnnotationStrategy:()=>dl,mobileAreaChartRecipe:()=>yl,mobileBrushAlternatives:()=>kl,mobileChartFamilyRecipe:()=>Il,mobileGeoChartRecipe:()=>Ml,mobileLineChartRecipe:()=>gl,mobileNetworkChartRecipe:()=>wl,mobileOrdinalChartRecipe:()=>xl,mobileScatterplotRecipe:()=>bl,mobileSmallMultipleRecipe:()=>vl,motifBraidLayout:()=>rp,mulberry32:()=>Ge,netEnsembleLayout:()=>fp,networkEdgeHitTarget:()=>us,networkHitTarget:()=>ds,nonNegativeFinite:()=>Te,normalizePoint:()=>Bs,normalizeScores:()=>ua,normalizeTokenEncoding:()=>Ke,octilinearRoute:()=>Bn,offsetTransitPath:()=>Gn,orderByBarycenter:()=>ws,orderByGroupDegree:()=>Zc,orderExactSmall:()=>vs,orthogonalEdgePath:()=>Wi,packBandsBySilhouette:()=>bs,packIntervals:()=>Fi,packSpanLevels:()=>Ns,packedClusterMatrix:()=>vp,parallelCoordinatesLayout:()=>Cp,partitionSharedEdges:()=>Os,patchCompositionalGraph:()=>Ll,physicsChargePoint:()=>Fc,physicsDestination:()=>jc,physicsReferenceEnvelope:()=>Ka,physicsStageColliders:()=>Lc,physicsStageGeography:()=>Rc,placeWithMinGap:()=>ys,pointMagnitude:()=>qs,polarToXY:()=>Ps,portalRegion:()=>Pa,prepareCompositionalGraph:()=>Fl,prepareMotifBraid:()=>bo,prepareNetworkAtlasAsync:()=>xo,pressureFieldRegion:()=>Oa,processChrome:()=>Oc,processJourneyRows:()=>lc,processLaneWalls:()=>La,processStageLayout:()=>ka,processStageRegions:()=>Na,processVolumePolygons:()=>Da,projectCompositionalScroll:()=>Rd,proximityProblem:()=>ha,radiusScale:()=>Fs,readField:()=>we,rectCollide:()=>Hi,refineByAdjacentSwaps:()=>Ms,regionCountsToProjectionRows:()=>wa,reserveAnnotationBands:()=>Ai,reserveClasses:()=>vi,reserveMarginPct:()=>$i,reserveSeries:()=>Ni,ringArcPath:()=>Ls,roundedEnclosure:()=>Po,roundedTransitPath:()=>Yn,routeCompositionalGraph:()=>Nd,routeSurfaceRegion:()=>Ca,runLengthEncode:()=>kf,runs:()=>hs,sampleGeographicDotGrid:()=>mn,scaleArcBand:()=>Es,scalePoint:()=>Ws,sedimentBake:()=>Uc,selectCyclicRange:()=>gs,selectIsometricLandmarks:()=>jt,shade:()=>Ae,shortestArcDelta:()=>fs,shortestPath:()=>sa,signatureKey:()=>$e,spanArcPath:()=>As,spanArcPeakY:()=>Cs,spawnFromTokens:()=>Hc,stackFuelSeries:()=>ki,stageTargetInVolume:()=>za,subtractPoints:()=>_s,suggestTokenEncoding:()=>st,summarizeOperatingPoint:()=>Ci,symbolExtent:()=>lt,symbolPathString:()=>at,symbolRadius:()=>ct,thresholdBandsForReserve:()=>Ei,tightestHours:()=>Ti,tokenLayer:()=>Et,tokenTaskIntentToCapabilityIntents:()=>it,traceCompositionalGraph:()=>zl,transitDiagramLayout:()=>Yh,unitize:()=>qe,unitizeRange:()=>Be,unwrapDatum:()=>Me,updateProcessJourney:()=>cc,waffleLayout:()=>Du,withAlpha:()=>Re,wordTrailsLayout:()=>os,wordTrailsProgressiveReveal:()=>ns,wrapValue:()=>ps,xyToAngle:()=>Rs}),module.exports=(Pu=ju,Xd(qd({},"__esModule",{value:!0}),Pu));var Fu=require("d3-interpolate"),Lu=class{constructor(e=12){this.maxSize=e,this.store=/* @__PURE__ */new Map}get(e){return this.store.get(e)}set(e,t){this.store.size>=this.maxSize&&this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},zu=require("react"),Du=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,{plot:i}=e.dimensions;if(i.width<=0||i.height<=0)return{nodes:[]};const s=()=>({nodes:[],overlays:Fe(i,0,e.data.length,"rows","The grid needs positive integer dimensions and enough space for its gutters.",{force:!0})}),a=n*o;if(!Number.isSafeInteger(n)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a)||n<=0||o<=0||!Number.isFinite(r)||r<0)return s();const c=(i.width-r*(o-1))/o;if(c<=0||i.height<=r*(n-1))return s();const l=null==t.categoryAccessor?()=>"_default":be(t.categoryAccessor),d=null==t.valueAccessor?()=>1:be(t.valueAccessor),u=/* @__PURE__ */new Map;for(const t of e.data){const e=String(l(t)),n=Te(Number(d(t)));u.set(e,(u.get(e)??0)+n)}const h=Array.from(u.values()).reduce((e,t)=>e+t,0);if(!(h>0&&Number.isFinite(h)))return{nodes:[],overlays:Fe(i,0,u.size,"categories","Category values must have a finite positive total.")};const p=[.../* @__PURE__ */new Set([...t.categoryOrder??[],...u.keys()])].filter(e=>u.has(e)),f=ze(p.map(e=>({key:e,weight:u.get(e)??0})),a,void 0,!0),m=f.filter(e=>e.cells>0).length,g=Fe(i,m,p.length,"categories","Zero-valued categories and categories rounded to zero cells are omitted."),y=(i.height-(g?18:0)-r*(n-1))/n;if(y<=0)return s();const x="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",b="string"==typeof t.valueAccessor?t.valueAccessor:"value",w=(e,t,n)=>Ie(o=>{o("category",e),o("value",u.get(e)??0),o("share",(u.get(e)??0)/h),"category"!==x&&o(x,e),"value"!==b&&o(b,u.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),M=[];let v=0;for(const t of f){const s=e.resolveColor(t.key);for(let e=0;e<t.cells;e++){const a=v%o,l=n-1-Math.floor(v/o);M.push({type:"rect",x:i.x+a*(c+r),y:i.y+l*(y+r),w:c,h:y,style:{fill:s,stroke:"none"},datum:w(t.key,v,t.cells),group:t.key,_transitionKey:`waffle-${t.key}-${e}`}),v++}}return{nodes:M,overlays:g}},_u=1e-6,Wu=require("d3-force"),qu=1e3,Bu=80,Gu=100;Jd();var Yu,Vu=require("d3-shape"),Hu={circle:Vu.symbolCircle,square:Vu.symbolSquare,triangle:Vu.symbolTriangle,diamond:Vu.symbolDiamond,star:Vu.symbolStar,cross:Vu.symbolCross,wye:Vu.symbolWye},Uu=["circle","triangle","diamond","star","square","chevron","cross","wye"],Xu=/* @__PURE__ */new Map,Ku="#334155",Ju="#f8fafc",Zu="#cbd5e1",Qu={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},eh={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},th={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},nh={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},oh="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",rh={viewBox:[18,40],anchor:[.5,1],parts:[{d:oh,fill:"color",stroke:"color",strokeWidth:1.4}]},ih={server:Qu,chip:eh,bolt:th,bus:nh,person:rh},sh="var(--semiotic-primary, #4e79a7)",ah="var(--semiotic-border, #d1d5db)",ch="var(--semiotic-secondary, #9ca3af)",lh="var(--semiotic-bg, #ffffff)",dh=/* @__PURE__ */new Set(Uu),uh=require("d3-interpolate"),hh=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o="utc"===t.timeZone,r=(e,t,n)=>{const r=/* @__PURE__ */new Date(0);return o?(r.setUTCFullYear(e,t,n),r.setUTCHours(0,0,0,0)):(r.setFullYear(e,t,n),r.setHours(0,0,0,0)),r},i=e=>o?e.getUTCFullYear():e.getFullYear(),s=e=>`${i(e)}-${At(o?e.getUTCMonth()+1:e.getMonth()+1)}-${At(o?e.getUTCDate():e.getDate())}`,a=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];if(n instanceof Date)return n;if("string"==typeof n&&/^\d{4}-\d{2}-\d{2}$/.test(n)){const[e,t,o]=n.split("-").map(Number);return r(e,t-1,o)}return new Date(n)},c=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return null==n?NaN:Number(n)},l=/* @__PURE__ */new Map;let d=null;for(const t of e.data){const e=a(t);if(!isFinite(e.getTime()))continue;null==d&&(d=i(e));const n=s(e),o=c(t);Number.isFinite(o)&&l.set(n,(l.get(n)??0)+o)}const u=t.year??d??i(/* @__PURE__ */new Date);let h=1/0,p=-1/0;for(const[e,t]of l)e.startsWith(`${u}-`)&&(t<h&&(h=t),t>p&&(p=t));h===1/0&&(h=0,p=0);const[f,m]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],g=t.missingColor??e.theme.semantic.grid??"#d1d5db",y=e=>{if(p===h)return f;const t=(e-h)/(p-h);return(0,uh.interpolateRgb)(f,m)(t)},x=t.gutter??2,b=t.labelInset??0,w=n.width-b,M=n.height,v=Math.min((w-53*x)/54,(M-6*x)/7);if(v<=0)return{nodes:[]};const I=r(u,0,1),k=((o?I.getUTCDay():I.getDay())-(t.weekStart??0)+7)%7,S=[];for(let e=0;e<54;e++)for(let t=0;t<7;t++){const o=r(u,0,1-k+7*e+t);if(i(o)!==u)continue;const a=s(o),c=l.get(a),d=null==c?g:y(c);S.push({type:"rect",x:n.x+b+e*(v+x),y:n.y+t*(v+x),w:v,h:v,style:{fill:d,stroke:"none"},datum:{date:o,value:c??null,missing:null==c}})}return{nodes:S}},ph=["#739b58","#83a964","#668d52","#8baa68"],fh=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),mh=Kd(require("react")),gh=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),yh=require("react/jsx-runtime"),xh={resource:32,city:64},bh={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},wh={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},Mh=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),vh=e=>{const t=Pt(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:ph,i=t*o,s=e.dimensions.width/2,a=(e.dimensions.height-i)/2+o/2,c=jt(e.points,e.config).map(e=>({...e,x:s+(e.column-e.row)*(n/2),y:a+(e.column+e.row)*(o/2)}));return{nodes:c.map(t=>{const i=_t(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??zt(e.config.terrainPalette,s)??zt(bh,s)??bh.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,zt(wh,l)??wh.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,d,u,h,p;return{type:"geoarea",pathData:(d=t.x,u=t.y,h=n,p=o,[`M${d},${u-p/2}`,`L${d+h/2},${u}`,`L${d},${u+p/2}`,`L${d-h/2},${u}`,"Z"].join("")),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,yh.jsx)(Wt,{tiles:c,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??xh.resource,citySize:e.config.citySpriteSize??xh.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},Ih={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},kh={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},Sh=require("react/jsx-runtime"),$h=.72,Nh=1.8,Eh=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=(o?Zt(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,n)=>!t.filter||t.filter(e.datum,n)),i=en(r.map(e=>e.datum),t),s=o?r:Qt({...e,points:r.map(e=>e.datum)}),a=i??Ht(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===a.length)return{nodes:[]};const c=Yt(a.map(e=>e.row)),l=Yt(a.map(e=>e.column)),d=Math.max(1,Math.round(c[1]-c[0])+1),u=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(0,t.layoutPadding??8),p=Math.max(1,e.dimensions.width-2*h),f=Math.max(1,e.dimensions.height-2*h),m=p/u,g=f/d,y=m*u,x=g*d,b=(e.dimensions.width-y)/2,w=(e.dimensions.height-x)/2,M=xe(t.cellPadding??.12,0,.8),v=Math.max(1,.5*Math.min(m,g)*(1-M)),I=t.sizeAccessor?a.map(e=>Number(Ut(e.datum,t.sizeAccessor))):[],k=t.sizeDomain??Yt(I),S=t.sizeRange??[.36,1],$=xe(Math.min(S[0],S[1]),.05,1),N=xe(Math.max(S[0],S[1]),$,1),E=a.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=String(Ut(r,t.idAccessor,["id","key","name"])??`grid-${o}`),s=String(Ut(r,t.labelAccessor,["abbr","code","label","name","id"])??i),a=Math.max(1,t.maxLabelLength??4),d=s.length>a?s.slice(0,a):s,u=Ut(r,t.categoryAccessor),h=null==u?void 0:String(u),p=Ut(r,t.fillAccessor),f=null!=p?String(p):h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",y=t.sizeAccessor?Number(Ut(r,t.sizeAccessor)):NaN,x=t.sizeAccessor&&Number.isFinite(y)?Math.sqrt(xe(Vt(y,k),0,1)):1,M=v*($+x*(N-$)),I="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:d,category:h,row:n.row,column:n.column,x:b+(n.column-l[0]+.5)*m,y:w+(n.row-c[0]+.5)*g,radius:M,style:{fill:f,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...I}}}),A=t.shape??"circle";return{nodes:E.map(e=>{return"circle"===A?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===A?Jt(e.x,e.y,e.radius):(t=e.x,n=e.y,o=e.radius,Kt([[t-o,n-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]])),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===A?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:/* @__PURE__ */ /* @__PURE__ */(0,Sh.jsx)(tn,{marks:E,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??xe(.23*Math.min(m,g),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},Ah=require("react/jsx-runtime"),Ch=10,Oh=25e3,Th=/* @__PURE__ */new WeakMap,Ph=/* @__PURE__ */new WeakMap,Rh=/* @__PURE__ */new WeakMap,jh=1,Fh=e=>{const t=vn(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,rn(n.dotRadius)??t.cellSize*xe(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,d=s+(a.gridRow+.5)*t.cellSize,u=sn(a,n.categoryAccessor),h=sn(a,n.fillAccessor),p={fill:null!=h?String(h):null!=u?e.resolveColor(String(u)):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},f=`dot-${a.gridRow}-${a.gridColumn}`;return"circle"===o?{type:"point",x:l,y:d,r:r,style:p,datum:a,interactive:!1,pointId:f,_transitionKey:f}:{type:"geoarea",pathData:"hexagon"===o?Sn(l,d,r):kn(l,d,r),centroid:[l,d],bounds:[[l-r,d-r],[l+r,d+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:p,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?/* @__PURE__ */ /* @__PURE__ */(0,Ah.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?/* @__PURE__ */ /* @__PURE__ */(0,Ah.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},cn(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Lh=e=>{const t=e.config??{},n=t.orientation??"vertical",o=t.edgeCurve??"curved",{positions:r,sceneNodes:i,labels:s}=En(e,{...t,nodeWidth:t.nodeWidth??80,nodeHeight:t.nodeHeight??30},`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`),a=[];for(const t of e.edges){const i="string"==typeof t.source?t.source:t.source.id,s="string"==typeof t.target?t.target:t.target.id,c=r.get(i),l=r.get(s);if(!c||!l)continue;const d="vertical"===n?{x:c.x,y:c.y+c.h/2}:{x:c.x+c.w/2,y:c.y},u="vertical"===n?{x:l.x,y:l.y-l.h/2}:{x:l.x-l.w/2,y:l.y};if("line"===o)a.push({type:"line",x1:d.x,y1:d.y,x2:u.x,y2:u.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t.data??t});else{const o=(d.y+u.y)/2,r=(d.x+u.x)/2,i="vertical"===n?`M${d.x},${d.y} C${d.x},${o} ${u.x},${o} ${u.x},${u.y}`:`M${d.x},${d.y} C${r},${d.y} ${r},${u.y} ${u.x},${u.y}`;a.push({type:"curved",pathD:i,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:a,labels:s}},zh=require("react"),Dh=require("react"),_h=require("./semiotic-network-placement.min.js"),Wh=e=>{const t=e.config??{},n=t.edgeStyle??"polyline",o=new Map(e.edges.map(e=>[e,Tn(e)])),{positions:r,sceneNodes:i,labels:s,project:a}=En(e,{...t,nodeWidth:t.nodeWidth??100,nodeHeight:t.nodeHeight??36,labelAccessor:t.labelAccessor??"label"},`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,[...o.values()].flat()),c=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`;for(let e=0;e<s.length;e++){const t=s[e],n=r.get(i[e].id);if(!n)continue;const o=Math.max(1,Math.floor(n.w/(.6*(t.fontSize??11))-2));t.text.length>o&&(t.text=t.text.slice(0,o-1)+"…")}const l=[],d=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id,s=r.get(e),u=r.get(i);if(!s||!u)continue;const h=o.get(t).map(a);if(h.length<2){const e=Cn(s,u),n=Cn(u,s);l.push(On(l.length,n,e,c,Math.min(7,u.w/4,u.h/3))),d.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:c,strokeWidth:1},datum:t.data??t});continue}const p=h[h.length-1],f=h.slice(0,-1).reverse().find(e=>e.x!==p.x||e.y!==p.y);if(f&&l.push(On(l.length,p,f,c,Math.min(7,u.w/4,u.h/3))),"smooth"===n&&h.length>=3){let e=`M${h[0].x},${h[0].y}`;for(let t=1;t<h.length-1;t++){const n=(h[t].x+h[t+1].x)/2,o=(h[t].y+h[t+1].y)/2;e+=` Q${h[t].x},${h[t].y} ${n},${o}`}const n=h[h.length-1];e+=` T${n.x},${n.y}`,d.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}else{const e="M"+h.map(e=>`${e.x},${e.y}`).join(" L ");d.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:d,labels:s,overlays:l.length?(0,zh.createElement)("g",null,(0,zh.createElement)(_h.NetworkPerspectiveGround,{z:"top"},l)):null,perspective:"manual"}},qh=require("react"),Bh=require("./semiotic-network-placement.min.js"),Gh=e=>"number"==typeof e&&Number.isFinite(e),Yh=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:Me(e),wrapper:e})).sort((e,t)=>je(e.id,t.id)),s=e.edges.map(e=>({source:Hn(e.source),target:Hn(e.target),data:Me(e),wrapper:e})).sort((e,t)=>je(e.source,t.source)||je(e.target,t.target)),a=qn(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?Jn(i,s,t,e.resolveColor):void 0,l=Qn(s,t,c),d=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),u=/* @__PURE__ */new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)d.get(e)?.add(n.id),n.color&&u.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),p=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),f=/* @__PURE__ */new Map,m=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=to(n,t),c=(s.length-1)/2*(h+p)+h/2;for(const e of[n.source,n.target])f.set(e,Math.max(f.get(e)??0,c));s.forEach((c,l)=>{d.get(n.source)?.add(c.descriptor.id),d.get(n.target)?.add(c.descriptor.id);const f=no(c.edge,a,t,c.edge.source!==n.source),g=Gn(f?[o,...f,i]:Bn(o,i),(l-(s.length-1)/2)*(h+p)),y=oo(c.edge,c.descriptor),x=Zn(c.descriptor,c.edge,t,e.resolveColor);u.has(c.descriptor.id)||u.set(c.descriptor.id,x),m.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:Yn(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=/* @__PURE__ */new Map,y=[],x=[],b=[],w=e=>String(Vn(e,t)||e.id);if("minimap"===n){const n=/* @__PURE__ */new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of d.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,f.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||je(e.nodes[0].id,t.nodes[0].id));for(const n of o){const o=eo(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(w).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:Ie(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),d={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length<=1?y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&u.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:d,id:c,label:a}):(o.forEach((t,i)=>{const a=-Math.PI/2+i/o.length*Math.PI*2,d=-Math.PI/2+(i+1)/o.length*Math.PI*2,h={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:a,endAngle:d,style:{fill:u.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(h)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:d,id:c,label:a}))}}else for(const o of i){const i=a.positions.get(o.id);if(!i)continue;const s=eo(d.get(o.id)??[],t),c=s.length>1||!0===o.data.interchange||!0===o.data.transfer,l=c?t.interchangeRadius??Math.max("primary"===n?7:5,f.get(o.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(o.id,l);const u=w(o),h=null!=t.renderStation;if(y.push({type:"circle",cx:i.x,cy:i.y,r:l,style:h?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:c?"primary"===n?3:2:1.5,opacity:r(o.data)},datum:o.data,accessibleDatum:o.data,accessibility:{label:`${u}${c?", interchange":""}`,tableFields:{station:u,lines:s.join(", ")}},id:o.id,label:u}),t.renderStation){const a={station:o.data,x:i.x,y:i.y,radius:l,lineIds:s,interchange:c,mode:n},d=t.renderStation(a);if(null!=d){if(e.perspective){const[e,n,o,r]=t.stationBounds?.(a)??[l,l,l,l];b.push("ground"===t.chromePlacement?{x:i.x-e,y:i.y-o,width:e+n,height:o+r,z:"top"}:{x:i.x,y:i.y,extent:[e,n,o,r]})}x.push((0,qh.createElement)("ground"===t.chromePlacement?Bh.NetworkPerspectiveGround:Bh.NetworkPerspectiveBillboard,{key:o.id,x:i.x,y:i.y,z:"top"},(0,qh.createElement)("g",{opacity:r(o.data),style:{pointerEvents:"none"}},d)))}}}const M=x.length>0?(0,qh.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,v={sceneEdges:m,sceneNodes:y,overlays:M,perspective:"manual",...b.length?{perspectiveBounds:b}:{},labels:ro(i,a.positions,d,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return v;const I=(e,t)=>({opacity:r(e.datum,t)});return{...v,restyle:I,restyleEdge:I}},Vh=require("./semiotic-network-placement.min.js");Jd();var Hh=require("./semiotic-network-placement.min.js"),Uh=require("react/jsx-runtime"),Xh=require("react/jsx-runtime"),Kh={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},Jh={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Zh=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.partitionAccessor??"partition",r=t.semanticAccessor??"semantic",i=t.labelAccessor??"label",s=t.storesAccessor??"stores",a=t.backEdgeAccessor??"isBackEdge",c=t.edgeTypeAccessor??"edgeType",l={...Kh,...t.partitionColors},d=t.partitionStrokeColors??{},u=t.dotStrokeWidth??1,h={...Jh,...t.edgeColors},p=t.accentColor??"var(--semiotic-focus, #ffcc33)",f=t.borderColor??"var(--semiotic-border, #555)",m=t.dimOpacity??.14,g=t.edgeOpacity??.5,y=t.edgeWidth??1.25,x=t.backEdgeWidth??t.edgeWidth??1.5,b=!1!==t.showStoreChips,w=t.storeChipColor??"var(--semiotic-info, #6a8caf)",M=t.hullGroupAccessor,v=io(e.nodes,n,t),{nodeWidth:I,nodeHeight:k,lod:S}=v,$=t.reachableIds?new Set(t.reachableIds):null,N=t.selectedId??null,E=e.selection,A=null!==$||!0===E?.isActive,C=/* @__PURE__ */new Map,O=/* @__PURE__ */new Map,T=[],P=null==M?null:/* @__PURE__ */new Map,R=[];for(const t of e.nodes){const e=t.id,n=String(we(t,o,"processor")),a=String(we(t,r,"processor")),c=String(we(t,i,e)),h=fo(we(t,s,[])),g=t.data??t,{cx:y,cy:x}=v.nodeBounds(t);if(!Number.isFinite(y)||!Number.isFinite(x))continue;C.set(e,{cx:y,cy:x});const b=$?$.has(e):null,w=E?.isActive?E.predicate(g):null,A=null!==b?!b:null!==w&&!w;O.set(e,A);const j=null!=N&&e===N,F=A&&!j?m:1,L=Object.prototype.hasOwnProperty.call(l,n)?l[n]:l.unknown,z=Object.prototype.hasOwnProperty.call(d,n)?d[n]:void 0;if("dot"===S){const t={type:"circle",cx:y,cy:x,r:I/2,style:{fill:L,opacity:F,stroke:j?p:z??"transparent",strokeWidth:j?2:z?u:0},datum:g,id:e,label:c};T.push(t)}else{const t={type:"rect",x:y-I/2,y:x-k/2,w:I,h:k,style:{fill:L,opacity:F,stroke:j?p:z??f,strokeWidth:j?3:1},datum:g,id:e,label:c};T.push(t),R.push({id:e,cx:y,cy:x,partition:n,semantic:a,label:c,stores:h,opacity:F,selected:j,node:g})}if(P&&null!=M){const n=we(t,M,null);if(null!=n){const t=String(n),o=P.get(t)??[];o.push({id:e,x:y-I/2,y:x-k/2,w:I,h:k}),P.set(t,o)}}}const j=[],F=[];for(const o of e.edges){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id,i=C.get(e),s=C.get(r);if(!i||!s)continue;const l=Boolean(we(o,a,null)??i.cx>=s.cx),d=String(we(o,c,"internal")),u=O.get(e)||O.get(r),p=A&&!u,f=u?Math.min(g,1.4*m):p?t.highlightEdgeOpacity??g:g,b=p&&null!=t.highlightEdgeWidth?t.highlightEdgeWidth:l?x:y,w=l?h.back:Object.prototype.hasOwnProperty.call(h,d)?h[d]:h.internal;let M,v,$;if(l){const t=Math.min(i.cy,s.cy)-k/2-n.y,o=n.y+n.height-Math.max(i.cy,s.cy)-k/2,a=(i.cy+s.cy)/2>n.y+n.height/2?t>8?-1:o>8?1:0:o>8?1:t>8?-1:0,c=Math.max(48,.28*Math.abs(i.cx-s.cx))+k,l=a<0?Math.max(n.y+1,Math.min(i.cy,s.cy)-k/2-c):a>0?Math.min(n.y+n.height-1,Math.max(i.cy,s.cy)+k/2+c):(i.cy+s.cy)/2,d=e===r,u=d?I/4:0,h=d&&"dot"===S?Math.sqrt((k/2)**2-u**2):k/2,p=i.cx-u,f=i.cy+Math.sign(l-i.cy)*h;v={x:s.cx+u,y:s.cy+Math.sign(l-s.cy)*h},$={x:v.x,y:l},M=`M${p},${f} C${p},${l} ${$.x},${$.y} ${v.x},${v.y}`}else{const e=Math.sign(s.cx-i.cx)||1,t=i.cx+e*I/2;v={x:s.cx-e*I/2,y:s.cy};const n=(t+v.x)/2;$={x:n,y:v.y},M=`M${t},${i.cy} C${n},${i.cy} ${n},${v.y} ${v.x},${v.y}`}!1!==t.showArrowheads&&F.push(On(F.length,v,$,w,Math.min(7,I/4,k/3),f));const N={type:"curved",pathD:M,style:{stroke:w,strokeWidth:b,fill:"none",opacity:f,...l?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:o.data??o};j.push(N)}const L="ground"===t.chromePlacement?Vh.NetworkPerspectiveGround:Vh.NetworkPerspectiveBillboard,z=0===R.length&&0===F.length?null:/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsxs)("g",{children:[F.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)(Vh.NetworkPerspectiveGround,{z:"top",children:F}),R.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)("g",{className:"lineage-dag-glyphs",children:R.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,Xh.jsx)(L,{x:e.cx,y:e.cy,z:"top",children:go(e,{w:I,h:k,lod:S,partColors:l,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel})},e.id))})]}),D=P&&P.size>0?po(P,{colors:t.hullColors,padding:null==t.hullPadding?16:Te(t.hullPadding),radius:null==t.hullRadius?12:Te(t.hullRadius),fillOpacity:mo(t.hullFillOpacity,.08),strokeOpacity:mo(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:O,selectedId:N,dimOpacity:m}):null,_=e.perspective?[...R.map(e=>"ground"===t.chromePlacement?{x:e.cx-I/2,y:e.cy-k/2,width:I,height:k,z:"top"}:{x:e.cx,y:e.cy,extent:[I/2,I/2,k/2,k/2]}),...P?ho(P,{padding:null==t.hullPadding?16:Te(t.hullPadding),label:t.hullLabel}):[]]:void 0,W=D?{sceneNodes:T,sceneEdges:j,backgrounds:D,overlays:z,perspective:"manual"}:{sceneNodes:T,sceneEdges:j,overlays:z,perspective:"manual"};return _?{...W,perspectiveBounds:_}:W};Jd();var Qh=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),ep=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),tp={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},np=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,op=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),rp=e=>{const t=e.config.braid,o=e.dimensions.plot,r=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],i=t.groups.filter(e=>r.includes(e.partition)&&e.nodePath.length>0),s=[],a=[],c=[];if(0===i.length)return{sceneNodes:a,sceneEdges:s,labels:c};const l=new Set(i.map(e=>e.signature)),d=[...t.signatureOrder.filter(e=>l.delete(e)),...l],u=new Map(d.map((e,t)=>[e,t])),h=[...i].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),p=r.map(e=>h.filter(t=>t.partition===e)),f=ko(h),m=n(f.map(e=>e.depth)),g=i.map(e=>n(e.stepEntityCounts??[e.entityCount])),y=n(g),x=e=>e<=0?0:Math.max(1,10*e/y),b=new Map(i.map((e,t)=>[e.id,x(g[t])])),w=o.height/r.length,{semantic:M}=e.theme,v=(e,t,n,o={})=>c.push({x:e,y:t,text:n,fill:M.text??"#333",fontSize:10,anchor:"middle",...o}),I={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},k=new Map(f.map(e=>{const t=p.map(t=>t.reduce((t,n)=>t+(e.signatures.has(n.signature)?b.get(n.id)+3:0),5));return[e.id,n(t,24)]})),S=n([...k.values()],24),$=Math.min(o.width/4,S/2+16),N=(o.width-2*$)/Math.max(m-1,1),E=e=>o.x+$+(e-1)*N,A=48+S/2,C=22+S/2,O=(e,t)=>e+A+(u.get(t)+.5)*Math.max(0,w-A-C)/d.length,T=(t,n,o,r,i)=>{const a=np(n,r),c=np(n,i),l=x(a),d=x(c);if(0===l&&0===d)return;const u=l!==d,h=e.resolveColor(n.signature);s.push({type:"curved",id:o,pathD:u?Mo(t,l,d):Yn(t,8),style:{fill:u?h:"none",fillOpacity:1,stroke:u?"none":h,strokeWidth:u?0:l},datum:{...I,id:o,kind:"braid-track",nodeId:n.nodePath[i],fromNodeId:n.nodePath[r],groupId:n.id,signature:n.signature,partition:n.partition,entityCount:n.entityCount,fromStep:r,toStep:i,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:n.nodePath.join(" → "),partition:n.partition??"all",fromStep:r+1,toStep:i+1,fromCount:a,toCount:c}})};return r.forEach((e,t)=>{const n=o.y+t*w,r=p[t];if(e&&v(o.x+8,n+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===r.length)return;for(let e=1;e<=m;e++)v(E(e),n+34,`Step ${e}`);const i=/* @__PURE__ */new Map;for(const t of f){const o=r.filter(e=>t.signatures.has(e.signature));if(0===o.length)continue;const s=E(t.depth),c=Pe([...t.signatures].map(e=>O(n,e))),l=vo(o.map(e=>b.get(e.id)));i.set(t.id,new Map(o.map((e,t)=>[e.id,{x:s,y:c+l[t],offset:l[t]}])));const d=k.get(t.id),u={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;a.push({type:"glyph",id:h,cx:s,cy:c,size:d,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:tp,accent:M.border??"#888",style:{fill:M.surface??"#fff"},datum:{...I,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...u},accessibleDatum:u}),v(s,c+d/2+12,t.state,{anchorPoint:[s,c]})}for(const t of r){const n=Io(t.signature);for(let o=1;o<n.length;o++){const r=i.get(n[o-1]).get(t.id),s=i.get(n[o]).get(t.id),a=(r.x+s.x)/2-Math.sign(s.y-r.y)*s.offset,c=Math.abs(r.y-s.y)<1e-8?[r,s]:[r,{x:a,y:r.y},{x:a,y:s.y},s];T(c,t,`step:${e??"all"}:${n[o]}:${t.id}`,o-1,o)}}}),{sceneNodes:a,sceneEdges:s,labels:c,restyle:op,restyleEdge:op}},ip=require("./semiotic-network-placement.min.js"),sp=require("react/jsx-runtime"),ap={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},cp=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,s=t.layerAccessor??"layer",a=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",d=t.edgeLabelAccessor??"label",u=t.nodeFill??"var(--semiotic-surface, #20242d)",h=t.nodeStroke??"var(--semiotic-border, #5a6573)",p=t.textColor??"var(--semiotic-text, #e6e6e6)",f=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",m=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const g=/* @__PURE__ */new Map;let y=0;for(const t of e.nodes){const e=Math.round(Number(we(t,s,0)));y=Math.max(y,e);const n=g.get(e)||[];n.push(t),g.set(e,n)}const x=y+1;let b=1;for(const e of g.values())e.sort((e,t)=>Number(we(e,a,0))-Number(we(t,a,0))),b=Math.max(b,e.length);const w=r?n.width:n.height,M=r?n.height:n.width,v=w/x,I=M/(b+1),k=Math.max(44,Math.min(t.nodeWidth??150,r?v-36:.92*I)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*I:.5*v)),$=(r?k:S)/2+6,N=Math.max(1,w-2*$),E=e=>{const t=x>1?(i?x-1-e:e)/(x-1)*N:N/2;return(r?n.x:n.y)+$+t},A=/* @__PURE__ */new Map,C=null!=e.perspective,O=[],T=[],P=[],R=[];for(const[e,t]of g)t.forEach((o,i)=>{const s=E(e),a=(d=i,f=t.length,(r?n.y:n.x)+(d+1)/(f+1)*M);var d,f;const g=r?s:a,y=r?a:s,x=String(we(o,l,"rect")),b=String(we(o,c,o.id));A.set(o.id,{cx:g,cy:y,shape:x});const w={id:o.id,name:b,type:ap[x]??"process",shape:x},v=So(b,Math.max(4,Math.floor((k-12)/7)));if(C){const e="diamond"===x?m:h;O.push({type:"rect",x:g-k/2,y:y-S/2,w:k,h:S,style:{fill:u,stroke:e,strokeWidth:1.5},_hitPath:{pathD:Eo(x,g,y,k,S),transform:[0,0,1,1],fill:!0,strokeWidth:0},datum:w,id:o.id,label:b}),P.push({x:g,y:y,text:v,anchor:"middle",baseline:"middle",fontSize:13,fill:p,anchorPoint:[g,y]});const t=Ao(x,g,y,k,S,e);return void(t&&R.push(/* @__PURE__ */ /* @__PURE__ */(0,sp.jsx)("g",{children:t},`n-${o.id}`)))}O.push({type:"rect",x:g-k/2,y:y-S/2,w:k,h:S,style:{fill:"transparent",stroke:"transparent"},datum:w,id:o.id,label:b}),R.push(
147
147
  /* @__PURE__ */
148
- /* @__PURE__ */(0,op.jsxs)("g",{children:[$o(x,g,y,I,S,u,"diamond"===x?m:h,1.5),
148
+ /* @__PURE__ */(0,sp.jsxs)("g",{children:[$o(x,g,y,k,S,u,"diamond"===x?m:h,1.5),
149
149
  /* @__PURE__ */
150
- /* @__PURE__ */(0,op.jsx)("text",{x:g,y:y,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:p,style:{pointerEvents:"none"},children:v})]},`n-${o.id}`))});const j=[];e.edges.forEach((e,t)=>{const n="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,i=A.get(n),s=A.get(o);if(!i||!s)return;const a=r?i.cx+I/2:i.cx,c=r?i.cy:i.cy+S/2,l=r?s.cx-I/2:s.cx,u=r?s.cy:s.cy-S/2,m=r?`M${a},${c} C${(a+l)/2},${c} ${(a+l)/2},${u} ${l},${u}`:`M${a},${c} C${a},${(c+u)/2} ${l},${(c+u)/2} ${l},${u}`,g=Math.atan2(u-c,l-a),y=l-9*Math.cos(g),x=u-9*Math.sin(g),b=4.5*-Math.sin(g),w=4.5*Math.cos(g),M=`${l},${u} ${y+b},${x+w} ${y-b},${x-w}`,v=we(e,d,void 0),k=(a+l)/2,$=(c+u)/2;C&&T.push({type:"curved",pathD:m,style:{stroke:f,strokeWidth:1.4,fill:"none"},datum:e.data??e}),j.push(
150
+ /* @__PURE__ */(0,sp.jsx)("text",{x:g,y:y,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:p,style:{pointerEvents:"none"},children:v})]},`n-${o.id}`))});const j=[];e.edges.forEach((e,t)=>{const n="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,i=A.get(n),s=A.get(o);if(!i||!s)return;const a=r?i.cx+k/2:i.cx,c=r?i.cy:i.cy+S/2,l=r?s.cx-k/2:s.cx,u=r?s.cy:s.cy-S/2,m=r?`M${a},${c} C${(a+l)/2},${c} ${(a+l)/2},${u} ${l},${u}`:`M${a},${c} C${a},${(c+u)/2} ${l},${(c+u)/2} ${l},${u}`,g=Math.atan2(u-c,l-a),y=l-9*Math.cos(g),x=u-9*Math.sin(g),b=4.5*-Math.sin(g),w=4.5*Math.cos(g),M=`${l},${u} ${y+b},${x+w} ${y-b},${x-w}`,v=we(e,d,void 0),I=(a+l)/2,$=(c+u)/2;C&&T.push({type:"curved",pathD:m,style:{stroke:f,strokeWidth:1.4,fill:"none"},datum:e.data??e}),j.push(
151
151
  /* @__PURE__ */
152
- /* @__PURE__ */(0,op.jsxs)("g",{children:[!C&&/* @__PURE__ */ /* @__PURE__ */(0,op.jsx)("path",{d:m,fill:"none",stroke:f,strokeWidth:1.4}),
152
+ /* @__PURE__ */(0,sp.jsxs)("g",{children:[!C&&/* @__PURE__ */ /* @__PURE__ */(0,sp.jsx)("path",{d:m,fill:"none",stroke:f,strokeWidth:1.4}),
153
153
  /* @__PURE__ */
154
- /* @__PURE__ */(0,op.jsx)(np.NetworkPerspectiveGround,{z:"top",children:/* @__PURE__ */ /* @__PURE__ */(0,op.jsx)("polygon",{points:M,fill:f})}),"string"==typeof v&&v.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,op.jsx)(np.NetworkPerspectiveBillboard,{x:k,y:$,children:/* @__PURE__ */ /* @__PURE__ */(0,op.jsxs)("g",{children:[
154
+ /* @__PURE__ */(0,sp.jsx)(ip.NetworkPerspectiveGround,{z:"top",children:/* @__PURE__ */ /* @__PURE__ */(0,sp.jsx)("polygon",{points:M,fill:f})}),"string"==typeof v&&v.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,sp.jsx)(ip.NetworkPerspectiveBillboard,{x:I,y:$,children:/* @__PURE__ */ /* @__PURE__ */(0,sp.jsxs)("g",{children:[
155
155
  /* @__PURE__ */
156
- /* @__PURE__ */(0,op.jsx)("rect",{x:k-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),
156
+ /* @__PURE__ */(0,sp.jsx)("rect",{x:I-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),
157
157
  /* @__PURE__ */
158
- /* @__PURE__ */(0,op.jsx)("text",{x:k,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:p,style:{pointerEvents:"none"},children:v})]})})]},`e-${t}`))});const F=/* @__PURE__ */ /* @__PURE__ */(0,op.jsxs)("g",{className:"mermaid-dag",children:[j,C?/* @__PURE__ */ /* @__PURE__ */(0,op.jsx)(np.NetworkPerspectiveGround,{z:"top",children:R}):R]});return C?{sceneNodes:O,sceneEdges:T,labels:P,overlays:F,perspective:"manual"}:{sceneNodes:O,overlays:F}};eu();var sp=require("./semiotic-network-placement.min.js"),ap=require("react/jsx-runtime"),cp=require("react/jsx-runtime"),lp=/* @__PURE__ */new Ru(8),dp=/* @__PURE__ */new Ru(8),up=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length||n.width<=0||n.height<=0)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,d=t.headerHeight??34,u=t.minCellForFull??38,h=t.maxCellSize??120,p=t.minCellSize??12,f=t.fingerprintRounds??3,m=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,String(we(t,s,""))))}const w=[];for(const t of e.edges){const e=Bo(t.source??we(t,o,void 0)),n=Bo(t.target??we(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,components:k,key:I}=Ko(b,w,f),S=/* @__PURE__ */new Map;if(m)for(const e of k){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...k].sort((e,t)=>t.nodeCount-e.nodeCount));const $=[...S.entries()];$.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const N=$e([n.x,n.y,n.width,n.height,c,l,d,u,h,p,f,m,g,a,$.map(([e,t])=>e+":"+t.length).join(","),I]),E=dp.getOrCompute(N,()=>Jo($,{plot:n,cellGap:c,bandGap:l,headerHeight:d,minCellForFull:u,maxCellSize:h,minCellSize:p,nodeRadius:a,outAdj:M,inAdj:v})),A=e.theme.semantic||{},C=t.convergeColor??A.info??"#4c78a8",O=t.branchColor??A.warning??"#e8853a",T=t.edgeColor??A.border??"#9aa0aa",P=t.colorMode??"directedness",R={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},j=t=>"motif"===P?e.resolveColor(t.motif):"category"===P||t.directed?C:O,F=[],L=[];for(const t of E.cells){const n=t.component,o=j(n);if("full"===t.lod){for(const e of t.edges){const t={type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:T,strokeWidth:1,opacity:.5*Math.max(Se(y.get(e.source),R),Se(y.get(e.target),R))},datum:null};L.push(t)}for(const n of t.nodes){const t=y.get(n.id),r=x.get(n.id),s="category"===P&&r?e.resolveColor(r):o,a={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:s,opacity:Se(t,R)},datum:t,id:n.id,label:String(we(t,i,n.id))};F.push(a)}}else{const e=Ce({id:`component-${JSON.stringify(n.ids)}`,motif:n.motif,shape:Ho(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:n.ids.some(e=>1===Se(y.get(e),R))?1:.14,stroke:T,strokeWidth:.75},datum:e,id:String(e.id),label:Ho(n)};F.push(r)}}const z=!1!==t.showExemplars,D=!1!==t.showBandLabels,_=_o(E.bands,!!e.perspective,z,D);return{sceneNodes:F,sceneEdges:L,overlays:Wo(_.bands,{convergeColor:C,branchColor:O,edgeColor:T,plot:n,showBandLabels:D,showExemplars:z,showLegend:!1!==t.showLegend&&"directedness"===P,textColor:A.text??"var(--semiotic-text, #1a1a1a)",subText:A.textSecondary??"var(--semiotic-text-secondary, #888)"}),perspective:"manual",..._.bounds?{perspectiveBounds:_.bounds}:{}}},hp=Hd(require("react")),pp=require("./semiotic-network-placement.min.js"),fp=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:Qo(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[String(e),t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,d=n.x+(n.width-l)/2,u=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),p=h/2,f=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):String(we(e.datum,t.labelAccessor??"label",e.id));return{id:e.id,label:o,datum:e.datum,index:n,cx:d+(n+.5)*c,cy:u+(n+.5)*c}}),m=new Map(f.map(e=>[e.id,e])),g=new Map(f.map(e=>[e.id,e.index])),y=sr(e.edges,g,t),x=cr(ar(y,h,t),m,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",k=e.theme.semantic.grid??v,I=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),S=t.valueFormat??(e=>String(Math.round(100*e)/100)),$=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),N=new Map(f.map(e=>[e.id,0])),E=new Map(f.map(e=>[e.id,0])),A=[],C=[],O=[];for(const n of y){const o=m.get(n.source),r=m.get(n.target);if(!o||!r)continue;N.set(o.id,(N.get(o.id)??0)+n.value),E.set(r.id,(E.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):b);const a=x.get(`${n.key}:source`)??o.cy,l=x.get(`${n.key}:target`)??r.cx;let h,f,g,y,v,k,I;if(n.sourceIndex<n.targetIndex){const e=[o.cx+p,a],t=[l,r.cy-p];h=[e,[t[0],e[1]],t],f=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,v=t[0]-$-4,k=e[1]-n.width/2-3,I="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-p,a],i=[l,r.cy+p];h=[e,[i[0],e[1]],i],f=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,v=i[0]+$+4,k=e[1]+n.width/2+(t.valueFontSize??10),I="start"}else{const e=d+(o.index+1)*c,t=u+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+p+2,e-i),m=Math.max(o.cy+p+2,t-i),x=[o.cx+p,a],b=[l,r.cy+p];h=[x,[s,x[1]],[s,m],[b[0],m],b],f=(s+b[0])/2,g=m,y=Math.PI,v=s-3,k=m-n.width/2-3,I="end"}const T=or(h,$);if(O.push({type:"curved",id:`adjacency-flow-${n.key}`,label:`${o.label} to ${r.label}: ${S(n.value,n.datum)}`,pathD:T,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${S(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&C.push({x:v,y:k,text:S(n.value,n.datum),anchor:I,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(e<=2)continue;const o=Math.max(3,1.08*e);A.push(hp.createElement("path",{key:`arrow-${n.key}`,className:"semiotic-adjacency-flow-arrow",d:rr(f,g,y,o,e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const T=f.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):I);return{type:"rect",id:n.id,label:n.label,x:n.cx-p,y:n.cy-p,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:E.get(n.id)??0,outgoing:N.get(n.id)??0}}}}),P=Math.max(2,t.maxLabelLength??14),R=f.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=P,n.length<=o?n:`${n.slice(0,Math.max(1,o-1))}…`),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??M};var n,o});let j=null;if(t.showGrid??!0){const e=[];for(let t=0;t<=f.length;t+=1){const n=d+t*c,o=u+t*c;e.push(hp.createElement("line",{key:`grid-v-${t}`,x1:n,y1:u,x2:n,y2:u+l,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),hp.createElement("line",{key:`grid-h-${t}`,x1:d,y1:o,x2:d+l,y2:o,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}j=hp.createElement(pp.NetworkPerspectiveGround,null,...e)}return{sceneEdges:O,sceneNodes:T,labels:[...C,...R],backgrounds:j,overlays:hp.createElement(pp.NetworkPerspectiveGround,{z:"top"},...A),perspective:"manual",...e.perspective&&j?{perspectiveBounds:[{x:d,y:u,width:l,height:l}]}:{}}},mp=require("./semiotic-network-placement.min.js"),gp=(e,t)=>e.length*t*.6,yp=require("react/jsx-runtime"),xp=/* @__PURE__ */new Ru(12),bp=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,d=t.iconAccessor,u=t.defaultSymbol??"circle",[h,p]=t.sizeRange??[2,8],f=t.shadeStrength??.72,m=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,k=!1!==t.showEnclosures,I=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,$=I?t.headerHeight??26:0,N=S?t.labelWidth??66:0,E=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,A=n.x+N,C=n.y+$,O=Math.max(1,n.width-N),T=Math.max(1,n.height-$-E),P=[];for(const t of e.nodes){const e=t.data??t;P.push({id:t.id,col:String(we(t,o,"—")),row:String(we(t,r,"—")),sizeVal:i?Number(we(t,i,1)):1,colorKey:s?String(we(t,s,"")):"",symVal:a?String(we(t,a,"")):"",shadeVal:c?yr(we(t,c,null)):NaN,marker:!!l&&Boolean(we(t,l,!1)),iconVal:d?String(we(t,d,"")):"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===P.length)return{sceneNodes:[]};let R=1/0,j=-1/0;if(i)for(const e of P)Number.isFinite(e.sizeVal)&&(e.sizeVal<R&&(R=e.sizeVal),e.sizeVal>j&&(j=e.sizeVal));t.sizeDomain&&([R,j]=t.sizeDomain),Number.isFinite(R)&&Number.isFinite(j)||(R=0,j=1);const F=e=>{if(j<=R)return(h+p)/2;const t=Math.sqrt(xr((e-R)/(j-R),0,1));return h+t*(p-h)};let L=1/0,z=-1/0;if(c)for(const e of P)Number.isFinite(e.shadeVal)&&(e.shadeVal<L&&(L=e.shadeVal),e.shadeVal>z&&(z=e.shadeVal));t.shadeDomain&&([L,z]=t.shadeDomain);const D=e=>{if(!c||!Number.isFinite(e)||z<=L)return.5;const t=xr((e-L)/(z-L),0,1);return m?1-t:t},_=t.colorMap,W=/* @__PURE__ */new Map,q=(t,n)=>{let o=W.get(t);return o||(o=Ee(_&&Object.prototype.hasOwnProperty.call(_,t)&&"string"==typeof _[t]&&_[t]?_[t]:e.resolveColor(t),f),W.set(t,o)),o(n)},G=/* @__PURE__ */new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))G.set(e,n);let B=0;const Y=e=>{if(!a)return u;let t=G.get(e);return t||(t=Yu[B%Yu.length],B++,G.set(e,t)),t},V=t.iconMap,H=e=>d&&V&&Object.prototype.hasOwnProperty.call(V,e)?V[e]??null:null,U=e=>d?"circle":Y(e.symVal),X=t.maxAreaFraction??.4;let K=0;const J=new Array(P.length),Z=new Array(P.length);for(let e=0;e<P.length;e++){const t=P[e],n=F(t.sizeVal);J[e]=n,t.baseShape=U(t),t.iconShape=H(t.iconVal);const o=lt(t.baseShape,Math.PI*n*n);Z[e]=o,K+=Math.PI*o*o}const Q=X*O*T,ee=K>Q?Math.sqrt(Q/K):1;for(let e=0;e<P.length;e++){const t=P[e],n=J[e]*ee;t.size=Math.PI*n*n,t.packR=Z[e]*ee}const te=/* @__PURE__ */new Map,ne=/* @__PURE__ */new Map;for(const e of P)te.set(e.col,(te.get(e.col)??0)+1),ne.set(e.row,(ne.get(e.row)??0)+1);const oe=t.columnOrder?.filter(e=>te.has(e))??[...te.keys()].sort((e,t)=>(te.get(t)??0)-(te.get(e)??0)),re=t.rowOrder?.filter(e=>ne.has(e))??[...ne.keys()].sort((e,t)=>(ne.get(t)??0)-(ne.get(e)??0)),ie=$e([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),$,N,E,g,y,x,b,w,M,v,h,p,R,j,X,oe.join(","),re.join(","),P.length,vr(P)]),se=xp.getOrCompute(ie,()=>wr(P,{columnOrder:oe,rowOrder:re,innerX:A,innerY:C,innerW:O,innerH:T,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),ae=e.selection,ce=ae?.isActive?ae.predicate:null,le=t.highlight??null,de=t.dimOpacity??.16,ue=t.markStroke,he=t.markStrokeWidth??0,pe=t.markerColor??"#ffffff",fe=t.iconColor??"rgba(255,255,255,0.92)",me=t.iconStrokeWidth??1,ge=t.iconScale??.72,ye=[],xe=[],be=[];for(const e of P){const t=se.positions.get(e.id);if(!t)continue;const n=Se(e.datum,{highlight:le,predicate:ce,dimOpacity:de}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:q(e.colorKey,D(e.shadeVal)),opacity:n,...ue?{stroke:ue,strokeWidth:he}:{}},datum:e.datum,id:e.id,label:String(e.id)};if(ye.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ge,r=lt(e.iconShape,100),i=r>0?o/r*100*(o/r):Math.PI*o*o;be.push({x:t.px,y:t.py,size:i,shape:e.iconShape,opacity:n})}e.marker&&n>de+.001&&xe.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Me=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(E>0?.45*E:9),r=[];for(let e=0;e<t.callouts.length;e++){const n=t.callouts[e],o=P.find(e=>String(e.datum[n.field])===String(n.value));if(!o)continue;const i=se.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=/* @__PURE__ */new Map;i.forEach((e,t)=>{s.set(e.ci,A+(t+.5)/i.length*O)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),Me.push({keyId:`callout-${t.ci}`,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const ve={markerDots:xe,markerColor:pe,iconMarks:be,iconColor:fe,iconStrokeWidth:me,callouts:Me,plot:n,showEnclosures:k,showColumnHeaders:I,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*$,labelX:n.x+N-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel};return{sceneNodes:ye,overlays:kr(se,ve),perspective:"manual",...e.perspective?{perspectiveBounds:gr(se,ve)}:{}}},wp=4,Mp=Hd(require("react")),vp=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o=be(t.categoryAccessor),r=be(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",d=(e,t,n)=>ke(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),u=!1!==t.showCategoryLabels,h=t.labelPadding??(u?22:0),p=Math.max(0,n.height-h),f=[],m=/* @__PURE__ */new Map,g=[],y=/* @__PURE__ */new Set,x=/* @__PURE__ */new Map;for(const t of e.data){const e=String(o(t)),n=String(r(t)),s=i(t);m.has(e)||(f.push(e),m.set(e,0),x.set(e,/* @__PURE__ */new Map)),y.has(n)||(y.add(n),g.push(n)),m.set(e,(m.get(e)??0)+s);const a=x.get(e);a.set(n,(a.get(n)??0)+s)}const b=t.categoryOrder?Sr(t.categoryOrder,f,e=>m.has(e)):f,w=t.stackOrder?Sr(t.stackOrder,g,()=>!0):g,M=b.reduce((e,t)=>e+(m.get(t)??0),0);if(M<=0)return{nodes:[]};const v=s*Math.max(0,b.length-1),k=Math.max(0,n.width-v),I=[],S=[];let $=n.x;for(const t of b){const o=m.get(t)??0,r=o/M*k;if(r<=0)continue;S.push({cat:t,x:$,w:r});const i=x.get(t);let a=n.y;for(const n of w){const s=i.get(n)??0;if(s<=0)continue;const c=s/o*p;I.push({type:"rect",x:$,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:d(t,n,s),group:n}),a+=c}$+=r+s}return{nodes:I,overlays:u&&S.length>0?Ir(S,n.y+p+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}};Ud();var kp=Hd(require("react")),Ip=e=>{const t=e.config,{plot:o}=e.dimensions;if(o.width<=0||o.height<=0||0===e.data.length)return{nodes:[]};const r=Math.max(1,Te(t.rowHeight??28)),i=Te(t.rowGap??12),s=!1!==t.showLabels,a=s?Te(t.labelWidth??120):0,c=!1!==t.showTicks,l=c?14:0,d=t.tickFormat??(e=>e.toLocaleString()),u=o.x+a,h=Math.max(0,o.width-a),p=be(t.categoryAccessor),f=be(t.valueAccessor),m=be(t.targetAccessor),g=be(t.rangesAccessor),y="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",x="string"==typeof t.valueAccessor?t.valueAccessor:"value",b="string"==typeof t.targetAccessor?t.targetAccessor:"target",w=t.actualColor??e.theme.semantic.primary??"#3b6cb1",M=e.theme.semantic.text??"currentColor",v=e.theme.semantic.textSecondary??"#888",k=e.theme.semantic.surface??"#e8eaed",I=e.theme.semantic.grid??"#cdd1d6",S=e.theme.semantic.border??"#a3a8af",$=t.targetColor??`var(--semiotic-text, ${M})`,N=[`var(--semiotic-surface, ${k})`,`var(--semiotic-grid, ${I})`,`var(--semiotic-border, ${S})`],E=`var(--semiotic-text, ${M})`,A=`var(--semiotic-text-secondary, ${v})`,C=[],O=e.data.map(e=>{const t=g(e),o=Array.isArray(t)?t.map(Te).sort((e,t)=>e-t):[],r=Te(f(e)),i=Te(m(e));return{label:p(e),ranges:o,actual:r,target:i,maxVal:Math.max(r,i,n(o))}}).filter(e=>e.maxVal>0),T=e=>h>0?Math.max(0,Math.floor((e+i)/(r+i+l))):0,P=Math.min(O.length,T(o.height))<e.data.length,R=O.slice(0,T(o.height-(P?18:0))).map((e,t)=>({...e,yTop:o.y+t*(r+i+l)}));for(const{yTop:e,label:t,ranges:n,actual:o,target:i,maxVal:s}of R){const a=e=>u+e/s*h,c=e=>ke(n=>{n("metric",t),"metric"!==y&&n(y,t),e(n)});let l=u;for(let t=0;t<n.length;t++){const o=a(n[t]),i=o-l;i>0&&C.push({type:"rect",x:l,y:e,w:i,h:r,style:{fill:N[Math.min(t,N.length-1)],stroke:"none"},datum:c(e=>{e("range",t),e("rangeValue",n[t]),e("kind","range")}),group:`range-${t}`}),l=o}const d=Math.min(r,Math.max(6,Math.floor(.45*r)));C.push({type:"rect",x:u,y:e+(r-d)/2,w:a(o)-u,h:d,style:{fill:w,stroke:"none"},datum:c(e=>{e("value",o),e("kind","actual"),"value"!==x&&e(x,o)}),group:"actual"});const p=3,f=.8*r;C.push({type:"rect",x:a(i)-p/2,y:e+(r-f)/2,w:p,h:f,style:{fill:$,stroke:"none"},datum:c(e=>{e("target",i),e("kind","target"),"target"!==b&&e(b,i)}),group:"target"})}const j=[],F=Fe(o,R.length,e.data.length,"rows","Rows without positive values or enough plot space are omitted.");F&&j.push(F);for(let e=0;e<R.length;e++){const t=R[e],n=t.yTop+r/2;if(s&&j.push(Fo({keyId:`bullet-label-${e}`,text:t.label,x:o.x+a-8,y:n,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:E})),c){const n=5,o=t.yTop+r+2;for(let r=0;r<n;r++){const i=t.maxVal*r/(n-1),s=u+i/t.maxVal*h;j.push(kp.createElement("line",{key:`bullet-tick-${e}-${r}`,x1:s,x2:s,y1:o,y2:o+3,stroke:A,strokeWidth:1}),Fo({keyId:`bullet-ticktext-${e}-${r}`,text:d(i),x:s,y:o+12,anchor:0===r?"start":r===n-1?"end":"middle",baseline:"auto",fontSize:10,color:A}))}}}return{nodes:C,overlays:j.length>0?kp.createElement(kp.Fragment,null,...j):null}},Sp=require("react"),$p=require("d3-scale"),Np=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(o.length<2||n.width<=0||n.height<=0)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=/* @__PURE__ */Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(e<i&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,$p.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),d=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>String(e[t.colorBy]??""):null,u=t.opacity??.45,h=t.strokeWidth??1.25,p=e.theme.semantic.primary??"#3b6cb1",f=t.dimmedOpacity??.08,m=t.highlightFn,g=[],y=[];for(const n of e.data){const r=d?e.resolveColor(String(d(n))):p,i=!m||m(n),s=Se(n,{predicate:m,baseOpacity:u,dimOpacity:f,brighten:.4}),a=i?y:g;for(let e=0;e<o.length-1;e++){const t=Number(n[o[e]]),d=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(d))continue;const u={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](d),style:{stroke:r,strokeWidth:m&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(u)}if(t.showPoints)for(let e=0;e<o.length;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,d=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,u=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+s,p=n.y+n.height-a,f=[];for(let e=0;e<o.length;e++){const a=o[e],m=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();f.push((0,Sp.createElement)("line",{key:`pc-axis-line-${e}`,x1:m,x2:m,y1:h,y2:p,stroke:i,strokeWidth:1})),f.push(Fo({keyId:`pc-axis-label-${e}`,text:a,x:m,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:d}));const[x,b]=r[a],w=5;for(let t=0;t<w;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);f.push((0,Sp.createElement)("line",{key:`pc-tick-${e}-${t}`,x1:m-3,x2:m+3,y1:o,y2:o,stroke:i,strokeWidth:1}),Fo({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:m+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:u}))}}x=(0,Sp.createElement)(Sp.Fragment,null,...f)}return{nodes:g.concat(y),overlays:x}},Ep=require("react/jsx-runtime"),Ap=1.75,Cp="#222222",Op=2e3,Tp={height:15.5,topRadius:4.75,bottomRadius:3.75},Pp=e=>{const t=e.config,{plot:n}=e.dimensions;if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return{nodes:[]};const o=be(t.categoryAccessor??"name"),r=be(t.teaVolumeAccessor??"teaVolume"),i=be(t.bobaVolumeAccessor??"bobaVolume"),s=be(t.iceVolumeAccessor??"iceVolume"),a=be(t.cupHeightAccessor??"cupHeight"),c=be(t.cupTopRadiusAccessor??"cupTopRadius"),l=be(t.cupBottomRadiusAccessor??"cupBottomRadius"),d=be(t.bobaRadiusAccessor??"bobaRadius"),u=Fr(t.cupWidthRatio,.82),h=e.scales.o,p=h.bandwidth(),f=Math.max(1,n.height-26-8),m=n.y+8,g=[],y=[];for(const t of e.data){const n=String(o(t)),x=h(n);if(null==x)continue;let b={height:Fr(a(t),Tp.height),topRadius:Fr(c(t),Tp.topRadius),bottomRadius:Fr(l(t),Tp.bottomRadius)};const w=Er(b,b.height);(!Number.isFinite(w)||w<=0)&&(b=Tp);let M=Fr(d(t),.6);const v=Math.max(0,jr(r(t),450)),k=Math.max(0,jr(i(t),110)),I=Math.max(0,jr(s(t),135));let S=Math.PI*M*M;(!Number.isFinite(S)||S<=0||!Number.isFinite(k/S))&&(M=.6,S=Math.PI*M*M);const $=Math.floor(k/S),N=Math.min(k,$*S),E=Math.floor(I/5.359375),A=Math.min(I,E*Ap*Ap*Ap),C=v+N+A;if(!Number.isFinite(C))throw new RangeError("Boba total volume exceeds the finite numeric range");const O=Ar(b,C),T=Math.min(b.height,Math.max(0,O)),P=Nr(b,T),{pearls:R,layers:j}=Tr(b,M,$),F=T,L=Rr(b,j*M*2,F,E),z=b.height-20.32,D=Math.min(0,z),_=b.height-D,W=2*(b.topRadius+1),q=Math.min(p*u/W,f/_),G=x+p/2,B=e=>G+e*q,Y=e=>m+(e-D)*q,V=B(-(b.topRadius+1)),H=B(b.topRadius+1),U=Y(D),X=Y(b.height),K=Ce({name:n,teaVolume:v,bobaVolume:Math.round(N),iceVolume:Math.round(A),totalVolume:Math.round(C),numBobas:$,numIce:E,renderedBobas:R.length,renderedIce:L.length,kind:"boba cup"});g.push({type:"rect",x:V,y:U,w:Math.max(1,H-V),h:Math.max(1,X-U),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:K,group:n,_transitionKey:`boba-${Oe(n)}`});const J=b.height-F,Z=Oe(n),Q=e.resolveColor(n);y.push(
158
+ /* @__PURE__ */(0,sp.jsx)("text",{x:I,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:p,style:{pointerEvents:"none"},children:v})]})})]},`e-${t}`))});const F=/* @__PURE__ */ /* @__PURE__ */(0,sp.jsxs)("g",{className:"mermaid-dag",children:[j,C?/* @__PURE__ */ /* @__PURE__ */(0,sp.jsx)(ip.NetworkPerspectiveGround,{z:"top",children:R}):R]});return C?{sceneNodes:O,sceneEdges:T,labels:P,overlays:F,perspective:"manual"}:{sceneNodes:O,overlays:F}};ou();var lp=require("./semiotic-network-placement.min.js"),dp=require("react/jsx-runtime"),up=require("react/jsx-runtime"),hp=/* @__PURE__ */new Lu(8),pp=/* @__PURE__ */new Lu(8),fp=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length||n.width<=0||n.height<=0)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,d=t.headerHeight??34,u=t.minCellForFull??38,h=t.maxCellSize??120,p=t.minCellSize??12,f=t.fingerprintRounds??3,m=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,String(we(t,s,""))))}const w=[];for(const t of e.edges){const e=Go(t.source??we(t,o,void 0)),n=Go(t.target??we(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,components:I,key:k}=Ko(b,w,f),S=/* @__PURE__ */new Map;if(m)for(const e of I){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...I].sort((e,t)=>t.nodeCount-e.nodeCount));const $=[...S.entries()];$.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const N=$e([n.x,n.y,n.width,n.height,c,l,d,u,h,p,f,m,g,a,$.map(([e,t])=>e+":"+t.length).join(","),k]),E=pp.getOrCompute(N,()=>Jo($,{plot:n,cellGap:c,bandGap:l,headerHeight:d,minCellForFull:u,maxCellSize:h,minCellSize:p,nodeRadius:a,outAdj:M,inAdj:v})),A=e.theme.semantic||{},C=t.convergeColor??A.info??"#4c78a8",O=t.branchColor??A.warning??"#e8853a",T=t.edgeColor??A.border??"#9aa0aa",P=t.colorMode??"directedness",R={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},j=t=>"motif"===P?e.resolveColor(t.motif):"category"===P||t.directed?C:O,F=[],L=[];for(const t of E.cells){const n=t.component,o=j(n);if("full"===t.lod){for(const e of t.edges){const t={type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:T,strokeWidth:1,opacity:.5*Math.max(Se(y.get(e.source),R),Se(y.get(e.target),R))},datum:null};L.push(t)}for(const n of t.nodes){const t=y.get(n.id),r=x.get(n.id),s="category"===P&&r?e.resolveColor(r):o,a={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:s,opacity:Se(t,R)},datum:t,id:n.id,label:String(we(t,i,n.id))};F.push(a)}}else{const e=Ce({id:`component-${JSON.stringify(n.ids)}`,motif:n.motif,shape:Ho(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:n.ids.some(e=>1===Se(y.get(e),R))?1:.14,stroke:T,strokeWidth:.75},datum:e,id:String(e.id),label:Ho(n)};F.push(r)}}const z=!1!==t.showExemplars,D=!1!==t.showBandLabels,_=_o(E.bands,!!e.perspective,z,D);return{sceneNodes:F,sceneEdges:L,overlays:Wo(_.bands,{convergeColor:C,branchColor:O,edgeColor:T,plot:n,showBandLabels:D,showExemplars:z,showLegend:!1!==t.showLegend&&"directedness"===P,textColor:A.text??"var(--semiotic-text, #1a1a1a)",subText:A.textSecondary??"var(--semiotic-text-secondary, #888)"}),perspective:"manual",..._.bounds?{perspectiveBounds:_.bounds}:{}}},mp=Kd(require("react")),gp=require("./semiotic-network-placement.min.js"),yp=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:Qo(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[String(e),t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,d=n.x+(n.width-l)/2,u=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),p=h/2,f=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):String(we(e.datum,t.labelAccessor??"label",e.id));return{id:e.id,label:o,datum:e.datum,index:n,cx:d+(n+.5)*c,cy:u+(n+.5)*c}}),m=new Map(f.map(e=>[e.id,e])),g=new Map(f.map(e=>[e.id,e.index])),y=sr(e.edges,g,t),x=cr(ar(y,h,t),m,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",I=e.theme.semantic.grid??v,k=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),S=t.valueFormat??(e=>String(Math.round(100*e)/100)),$=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),N=new Map(f.map(e=>[e.id,0])),E=new Map(f.map(e=>[e.id,0])),A=[],C=[],O=[];for(const n of y){const o=m.get(n.source),r=m.get(n.target);if(!o||!r)continue;N.set(o.id,(N.get(o.id)??0)+n.value),E.set(r.id,(E.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):b);const a=x.get(`${n.key}:source`)??o.cy,l=x.get(`${n.key}:target`)??r.cx;let h,f,g,y,v,I,k;if(n.sourceIndex<n.targetIndex){const e=[o.cx+p,a],t=[l,r.cy-p];h=[e,[t[0],e[1]],t],f=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,v=t[0]-$-4,I=e[1]-n.width/2-3,k="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-p,a],i=[l,r.cy+p];h=[e,[i[0],e[1]],i],f=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,v=i[0]+$+4,I=e[1]+n.width/2+(t.valueFontSize??10),k="start"}else{const e=d+(o.index+1)*c,t=u+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+p+2,e-i),m=Math.max(o.cy+p+2,t-i),x=[o.cx+p,a],b=[l,r.cy+p];h=[x,[s,x[1]],[s,m],[b[0],m],b],f=(s+b[0])/2,g=m,y=Math.PI,v=s-3,I=m-n.width/2-3,k="end"}const T=or(h,$);if(O.push({type:"curved",id:`adjacency-flow-${n.key}`,label:`${o.label} to ${r.label}: ${S(n.value,n.datum)}`,pathD:T,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${S(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&C.push({x:v,y:I,text:S(n.value,n.datum),anchor:k,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(e<=2)continue;const o=Math.max(3,1.08*e);A.push(mp.createElement("path",{key:`arrow-${n.key}`,className:"semiotic-adjacency-flow-arrow",d:rr(f,g,y,o,e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const T=f.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):k);return{type:"rect",id:n.id,label:n.label,x:n.cx-p,y:n.cy-p,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:E.get(n.id)??0,outgoing:N.get(n.id)??0}}}}),P=Math.max(2,t.maxLabelLength??14),R=f.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=P,n.length<=o?n:`${n.slice(0,Math.max(1,o-1))}…`),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??M};var n,o});let j=null;if(t.showGrid??!0){const e=[];for(let t=0;t<=f.length;t+=1){const n=d+t*c,o=u+t*c;e.push(mp.createElement("line",{key:`grid-v-${t}`,x1:n,y1:u,x2:n,y2:u+l,stroke:I,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),mp.createElement("line",{key:`grid-h-${t}`,x1:d,y1:o,x2:d+l,y2:o,stroke:I,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}j=mp.createElement(gp.NetworkPerspectiveGround,null,...e)}return{sceneEdges:O,sceneNodes:T,labels:[...C,...R],backgrounds:j,overlays:mp.createElement(gp.NetworkPerspectiveGround,{z:"top"},...A),perspective:"manual",...e.perspective&&j?{perspectiveBounds:[{x:d,y:u,width:l,height:l}]}:{}}},xp=require("./semiotic-network-placement.min.js"),bp=(e,t)=>e.length*t*.6,wp=require("react/jsx-runtime"),Mp=/* @__PURE__ */new Lu(12),vp=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,d=t.iconAccessor,u=t.defaultSymbol??"circle",[h,p]=t.sizeRange??[2,8],f=t.shadeStrength??.72,m=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,I=!1!==t.showEnclosures,k=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,$=k?t.headerHeight??26:0,N=S?t.labelWidth??66:0,E=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,A=n.x+N,C=n.y+$,O=Math.max(1,n.width-N),T=Math.max(1,n.height-$-E),P=[];for(const t of e.nodes){const e=t.data??t;P.push({id:t.id,col:String(we(t,o,"—")),row:String(we(t,r,"—")),sizeVal:i?Number(we(t,i,1)):1,colorKey:s?String(we(t,s,"")):"",symVal:a?String(we(t,a,"")):"",shadeVal:c?yr(we(t,c,null)):NaN,marker:!!l&&Boolean(we(t,l,!1)),iconVal:d?String(we(t,d,"")):"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===P.length)return{sceneNodes:[]};let R=1/0,j=-1/0;if(i)for(const e of P)Number.isFinite(e.sizeVal)&&(e.sizeVal<R&&(R=e.sizeVal),e.sizeVal>j&&(j=e.sizeVal));t.sizeDomain&&([R,j]=t.sizeDomain),Number.isFinite(R)&&Number.isFinite(j)||(R=0,j=1);const F=e=>{if(j<=R)return(h+p)/2;const t=Math.sqrt(xr((e-R)/(j-R),0,1));return h+t*(p-h)};let L=1/0,z=-1/0;if(c)for(const e of P)Number.isFinite(e.shadeVal)&&(e.shadeVal<L&&(L=e.shadeVal),e.shadeVal>z&&(z=e.shadeVal));t.shadeDomain&&([L,z]=t.shadeDomain);const D=e=>{if(!c||!Number.isFinite(e)||z<=L)return.5;const t=xr((e-L)/(z-L),0,1);return m?1-t:t},_=t.colorMap,W=/* @__PURE__ */new Map,q=(t,n)=>{let o=W.get(t);return o||(o=Ee(_&&Object.prototype.hasOwnProperty.call(_,t)&&"string"==typeof _[t]&&_[t]?_[t]:e.resolveColor(t),f),W.set(t,o)),o(n)},B=/* @__PURE__ */new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))B.set(e,n);let G=0;const Y=e=>{if(!a)return u;let t=B.get(e);return t||(t=Uu[G%Uu.length],G++,B.set(e,t)),t},V=t.iconMap,H=e=>d&&V&&Object.prototype.hasOwnProperty.call(V,e)?V[e]??null:null,U=e=>d?"circle":Y(e.symVal),X=t.maxAreaFraction??.4;let K=0;const J=new Array(P.length),Z=new Array(P.length);for(let e=0;e<P.length;e++){const t=P[e],n=F(t.sizeVal);J[e]=n,t.baseShape=U(t),t.iconShape=H(t.iconVal);const o=lt(t.baseShape,Math.PI*n*n);Z[e]=o,K+=Math.PI*o*o}const Q=X*O*T,ee=K>Q?Math.sqrt(Q/K):1;for(let e=0;e<P.length;e++){const t=P[e],n=J[e]*ee;t.size=Math.PI*n*n,t.packR=Z[e]*ee}const te=/* @__PURE__ */new Map,ne=/* @__PURE__ */new Map;for(const e of P)te.set(e.col,(te.get(e.col)??0)+1),ne.set(e.row,(ne.get(e.row)??0)+1);const oe=t.columnOrder?.filter(e=>te.has(e))??[...te.keys()].sort((e,t)=>(te.get(t)??0)-(te.get(e)??0)),re=t.rowOrder?.filter(e=>ne.has(e))??[...ne.keys()].sort((e,t)=>(ne.get(t)??0)-(ne.get(e)??0)),ie=$e([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),$,N,E,g,y,x,b,w,M,v,h,p,R,j,X,oe.join(","),re.join(","),P.length,vr(P)]),se=Mp.getOrCompute(ie,()=>wr(P,{columnOrder:oe,rowOrder:re,innerX:A,innerY:C,innerW:O,innerH:T,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),ae=e.selection,ce=ae?.isActive?ae.predicate:null,le=t.highlight??null,de=t.dimOpacity??.16,ue=t.markStroke,he=t.markStrokeWidth??0,pe=t.markerColor??"#ffffff",fe=t.iconColor??"rgba(255,255,255,0.92)",me=t.iconStrokeWidth??1,ge=t.iconScale??.72,ye=[],xe=[],be=[];for(const e of P){const t=se.positions.get(e.id);if(!t)continue;const n=Se(e.datum,{highlight:le,predicate:ce,dimOpacity:de}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:q(e.colorKey,D(e.shadeVal)),opacity:n,...ue?{stroke:ue,strokeWidth:he}:{}},datum:e.datum,id:e.id,label:String(e.id)};if(ye.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ge,r=lt(e.iconShape,100),i=r>0?o/r*100*(o/r):Math.PI*o*o;be.push({x:t.px,y:t.py,size:i,shape:e.iconShape,opacity:n})}e.marker&&n>de+.001&&xe.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Me=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(E>0?.45*E:9),r=[];for(let e=0;e<t.callouts.length;e++){const n=t.callouts[e],o=P.find(e=>String(e.datum[n.field])===String(n.value));if(!o)continue;const i=se.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=/* @__PURE__ */new Map;i.forEach((e,t)=>{s.set(e.ci,A+(t+.5)/i.length*O)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),Me.push({keyId:`callout-${t.ci}`,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const ve={markerDots:xe,markerColor:pe,iconMarks:be,iconColor:fe,iconStrokeWidth:me,callouts:Me,plot:n,showEnclosures:I,showColumnHeaders:k,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*$,labelX:n.x+N-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel};return{sceneNodes:ye,overlays:Ir(se,ve),perspective:"manual",...e.perspective?{perspectiveBounds:gr(se,ve)}:{}}},Ip=4,kp=Kd(require("react")),Sp=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o=be(t.categoryAccessor),r=be(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",d=(e,t,n)=>Ie(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),u=!1!==t.showCategoryLabels,h=t.labelPadding??(u?22:0),p=Math.max(0,n.height-h),f=[],m=/* @__PURE__ */new Map,g=[],y=/* @__PURE__ */new Set,x=/* @__PURE__ */new Map;for(const t of e.data){const e=String(o(t)),n=String(r(t)),s=i(t);m.has(e)||(f.push(e),m.set(e,0),x.set(e,/* @__PURE__ */new Map)),y.has(n)||(y.add(n),g.push(n)),m.set(e,(m.get(e)??0)+s);const a=x.get(e);a.set(n,(a.get(n)??0)+s)}const b=t.categoryOrder?Sr(t.categoryOrder,f,e=>m.has(e)):f,w=t.stackOrder?Sr(t.stackOrder,g,()=>!0):g,M=b.reduce((e,t)=>e+(m.get(t)??0),0);if(M<=0)return{nodes:[]};const v=s*Math.max(0,b.length-1),I=Math.max(0,n.width-v),k=[],S=[];let $=n.x;for(const t of b){const o=m.get(t)??0,r=o/M*I;if(r<=0)continue;S.push({cat:t,x:$,w:r});const i=x.get(t);let a=n.y;for(const n of w){const s=i.get(n)??0;if(s<=0)continue;const c=s/o*p;k.push({type:"rect",x:$,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:d(t,n,s),group:n}),a+=c}$+=r+s}return{nodes:k,overlays:u&&S.length>0?kr(S,n.y+p+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}};Jd();var $p=Kd(require("react")),Np=e=>{const t=e.config,{plot:o}=e.dimensions;if(o.width<=0||o.height<=0||0===e.data.length)return{nodes:[]};const r=Math.max(1,Te(t.rowHeight??28)),i=Te(t.rowGap??12),s=!1!==t.showLabels,a=s?Te(t.labelWidth??120):0,c=!1!==t.showTicks,l=c?14:0,d=t.tickFormat??(e=>e.toLocaleString()),u=o.x+a,h=Math.max(0,o.width-a),p=be(t.categoryAccessor),f=be(t.valueAccessor),m=be(t.targetAccessor),g=be(t.rangesAccessor),y="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",x="string"==typeof t.valueAccessor?t.valueAccessor:"value",b="string"==typeof t.targetAccessor?t.targetAccessor:"target",w=t.actualColor??e.theme.semantic.primary??"#3b6cb1",M=e.theme.semantic.text??"currentColor",v=e.theme.semantic.textSecondary??"#888",I=e.theme.semantic.surface??"#e8eaed",k=e.theme.semantic.grid??"#cdd1d6",S=e.theme.semantic.border??"#a3a8af",$=t.targetColor??`var(--semiotic-text, ${M})`,N=[`var(--semiotic-surface, ${I})`,`var(--semiotic-grid, ${k})`,`var(--semiotic-border, ${S})`],E=`var(--semiotic-text, ${M})`,A=`var(--semiotic-text-secondary, ${v})`,C=[],O=e.data.map(e=>{const t=g(e),o=Array.isArray(t)?t.map(Te).sort((e,t)=>e-t):[],r=Te(f(e)),i=Te(m(e));return{label:p(e),ranges:o,actual:r,target:i,maxVal:Math.max(r,i,n(o))}}).filter(e=>e.maxVal>0),T=e=>h>0?Math.max(0,Math.floor((e+i)/(r+i+l))):0,P=Math.min(O.length,T(o.height))<e.data.length,R=O.slice(0,T(o.height-(P?18:0))).map((e,t)=>({...e,yTop:o.y+t*(r+i+l)}));for(const{yTop:e,label:t,ranges:n,actual:o,target:i,maxVal:s}of R){const a=e=>u+e/s*h,c=e=>Ie(n=>{n("metric",t),"metric"!==y&&n(y,t),e(n)});let l=u;for(let t=0;t<n.length;t++){const o=a(n[t]),i=o-l;i>0&&C.push({type:"rect",x:l,y:e,w:i,h:r,style:{fill:N[Math.min(t,N.length-1)],stroke:"none"},datum:c(e=>{e("range",t),e("rangeValue",n[t]),e("kind","range")}),group:`range-${t}`}),l=o}const d=Math.min(r,Math.max(6,Math.floor(.45*r)));C.push({type:"rect",x:u,y:e+(r-d)/2,w:a(o)-u,h:d,style:{fill:w,stroke:"none"},datum:c(e=>{e("value",o),e("kind","actual"),"value"!==x&&e(x,o)}),group:"actual"});const p=3,f=.8*r;C.push({type:"rect",x:a(i)-p/2,y:e+(r-f)/2,w:p,h:f,style:{fill:$,stroke:"none"},datum:c(e=>{e("target",i),e("kind","target"),"target"!==b&&e(b,i)}),group:"target"})}const j=[],F=Fe(o,R.length,e.data.length,"rows","Rows without positive values or enough plot space are omitted.");F&&j.push(F);for(let e=0;e<R.length;e++){const t=R[e],n=t.yTop+r/2;if(s&&j.push(Fo({keyId:`bullet-label-${e}`,text:t.label,x:o.x+a-8,y:n,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:E})),c){const n=5,o=t.yTop+r+2;for(let r=0;r<n;r++){const i=t.maxVal*r/(n-1),s=u+i/t.maxVal*h;j.push($p.createElement("line",{key:`bullet-tick-${e}-${r}`,x1:s,x2:s,y1:o,y2:o+3,stroke:A,strokeWidth:1}),Fo({keyId:`bullet-ticktext-${e}-${r}`,text:d(i),x:s,y:o+12,anchor:0===r?"start":r===n-1?"end":"middle",baseline:"auto",fontSize:10,color:A}))}}}return{nodes:C,overlays:j.length>0?$p.createElement($p.Fragment,null,...j):null}},Ep=require("react"),Ap=require("d3-scale"),Cp=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(o.length<2||n.width<=0||n.height<=0)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=/* @__PURE__ */Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(e<i&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,Ap.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),d=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>String(e[t.colorBy]??""):null,u=t.opacity??.45,h=t.strokeWidth??1.25,p=e.theme.semantic.primary??"#3b6cb1",f=t.dimmedOpacity??.08,m=t.highlightFn,g=[],y=[];for(const n of e.data){const r=d?e.resolveColor(String(d(n))):p,i=!m||m(n),s=Se(n,{predicate:m,baseOpacity:u,dimOpacity:f,brighten:.4}),a=i?y:g;for(let e=0;e<o.length-1;e++){const t=Number(n[o[e]]),d=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(d))continue;const u={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](d),style:{stroke:r,strokeWidth:m&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(u)}if(t.showPoints)for(let e=0;e<o.length;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,d=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,u=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+s,p=n.y+n.height-a,f=[];for(let e=0;e<o.length;e++){const a=o[e],m=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();f.push((0,Ep.createElement)("line",{key:`pc-axis-line-${e}`,x1:m,x2:m,y1:h,y2:p,stroke:i,strokeWidth:1})),f.push(Fo({keyId:`pc-axis-label-${e}`,text:a,x:m,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:d}));const[x,b]=r[a],w=5;for(let t=0;t<w;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);f.push((0,Ep.createElement)("line",{key:`pc-tick-${e}-${t}`,x1:m-3,x2:m+3,y1:o,y2:o,stroke:i,strokeWidth:1}),Fo({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:m+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:u}))}}x=(0,Ep.createElement)(Ep.Fragment,null,...f)}return{nodes:g.concat(y),overlays:x}},Op=require("react/jsx-runtime"),Tp=1.75,Pp="#222222",Rp=2e3,jp={height:15.5,topRadius:4.75,bottomRadius:3.75},Fp=e=>{const t=e.config,{plot:n}=e.dimensions;if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return{nodes:[]};const o=be(t.categoryAccessor??"name"),r=be(t.teaVolumeAccessor??"teaVolume"),i=be(t.bobaVolumeAccessor??"bobaVolume"),s=be(t.iceVolumeAccessor??"iceVolume"),a=be(t.cupHeightAccessor??"cupHeight"),c=be(t.cupTopRadiusAccessor??"cupTopRadius"),l=be(t.cupBottomRadiusAccessor??"cupBottomRadius"),d=be(t.bobaRadiusAccessor??"bobaRadius"),u=Fr(t.cupWidthRatio,.82),h=e.scales.o,p=h.bandwidth(),f=Math.max(1,n.height-26-8),m=n.y+8,g=[],y=[];for(const t of e.data){const n=String(o(t)),x=h(n);if(null==x)continue;let b={height:Fr(a(t),jp.height),topRadius:Fr(c(t),jp.topRadius),bottomRadius:Fr(l(t),jp.bottomRadius)};const w=Er(b,b.height);(!Number.isFinite(w)||w<=0)&&(b=jp);let M=Fr(d(t),.6);const v=Math.max(0,jr(r(t),450)),I=Math.max(0,jr(i(t),110)),k=Math.max(0,jr(s(t),135));let S=Math.PI*M*M;(!Number.isFinite(S)||S<=0||!Number.isFinite(I/S))&&(M=.6,S=Math.PI*M*M);const $=Math.floor(I/S),N=Math.min(I,$*S),E=Math.floor(k/5.359375),A=Math.min(k,E*Tp*Tp*Tp),C=v+N+A;if(!Number.isFinite(C))throw new RangeError("Boba total volume exceeds the finite numeric range");const O=Ar(b,C),T=Math.min(b.height,Math.max(0,O)),P=Nr(b,T),{pearls:R,layers:j}=Tr(b,M,$),F=T,L=Rr(b,j*M*2,F,E),z=b.height-20.32,D=Math.min(0,z),_=b.height-D,W=2*(b.topRadius+1),q=Math.min(p*u/W,f/_),B=x+p/2,G=e=>B+e*q,Y=e=>m+(e-D)*q,V=G(-(b.topRadius+1)),H=G(b.topRadius+1),U=Y(D),X=Y(b.height),K=Ce({name:n,teaVolume:v,bobaVolume:Math.round(N),iceVolume:Math.round(A),totalVolume:Math.round(C),numBobas:$,numIce:E,renderedBobas:R.length,renderedIce:L.length,kind:"boba cup"});g.push({type:"rect",x:V,y:U,w:Math.max(1,H-V),h:Math.max(1,X-U),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:K,group:n,_transitionKey:`boba-${Oe(n)}`});const J=b.height-F,Z=Oe(n),Q=e.resolveColor(n);y.push(
159
159
  /* @__PURE__ */
160
- /* @__PURE__ */(0,Ep.jsxs)("g",{children:[v>0?/* @__PURE__ */ /* @__PURE__ */(0,Ep.jsx)("path",{d:`M${B(-P)},${Y(J)} L${B(-b.bottomRadius)},${Y(b.height)} L${B(b.bottomRadius)},${Y(b.height)} L${B(P)},${Y(J)} z`,fill:"#D2B799"}):null,R.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,Ep.jsx)("circle",{cx:B(e.x),cy:Y(e.z),r:M*q,fill:"#222222",opacity:.5},`p-${t}`)),L.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,Ep.jsx)("rect",{x:B(e.cx)-.95*Ap*q/2,y:Y(e.cy)-.95*Ap*q/2,width:.95*Ap*q,height:.95*Ap*q,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${B(e.cx)} ${Y(e.cy)})`},`i-${t}`)),
160
+ /* @__PURE__ */(0,Op.jsxs)("g",{children:[v>0?/* @__PURE__ */ /* @__PURE__ */(0,Op.jsx)("path",{d:`M${G(-P)},${Y(J)} L${G(-b.bottomRadius)},${Y(b.height)} L${G(b.bottomRadius)},${Y(b.height)} L${G(P)},${Y(J)} z`,fill:"#D2B799"}):null,R.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,Op.jsx)("circle",{cx:G(e.x),cy:Y(e.z),r:M*q,fill:"#222222",opacity:.5},`p-${t}`)),L.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,Op.jsx)("rect",{x:G(e.cx)-.95*Tp*q/2,y:Y(e.cy)-.95*Tp*q/2,width:.95*Tp*q,height:.95*Tp*q,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${G(e.cx)} ${Y(e.cy)})`},`i-${t}`)),
161
161
  /* @__PURE__ */
162
- /* @__PURE__ */(0,Ep.jsx)("path",{d:`M${B(-b.topRadius)},${Y(0)} L${B(-b.bottomRadius)},${Y(b.height)} L${B(b.bottomRadius)},${Y(b.height)} L${B(b.topRadius)},${Y(0)}`,fill:"none",stroke:Cp,strokeWidth:2.5}),
162
+ /* @__PURE__ */(0,Op.jsx)("path",{d:`M${G(-b.topRadius)},${Y(0)} L${G(-b.bottomRadius)},${Y(b.height)} L${G(b.bottomRadius)},${Y(b.height)} L${G(b.topRadius)},${Y(0)}`,fill:"none",stroke:Pp,strokeWidth:2.5}),
163
163
  /* @__PURE__ */
164
- /* @__PURE__ */(0,Ep.jsx)("line",{x1:B(-(b.topRadius+1)),y1:Y(0),x2:B(b.topRadius+1),y2:Y(0),stroke:Cp,strokeWidth:3,strokeLinecap:"round"}),v>0?/* @__PURE__ */ /* @__PURE__ */(0,Ep.jsx)("path",{d:`M${B(-.635)},${Y(z)} L${B(-.635)},${Y(b.height-.4)} L${B(.635)},${Y(b.height-1.27-.4)} L${B(.635)},${Y(z)} z`,fill:"#4F91CB",stroke:Cp,strokeWidth:1,opacity:.78}):null,
164
+ /* @__PURE__ */(0,Op.jsx)("line",{x1:G(-(b.topRadius+1)),y1:Y(0),x2:G(b.topRadius+1),y2:Y(0),stroke:Pp,strokeWidth:3,strokeLinecap:"round"}),v>0?/* @__PURE__ */ /* @__PURE__ */(0,Op.jsx)("path",{d:`M${G(-.635)},${Y(z)} L${G(-.635)},${Y(b.height-.4)} L${G(.635)},${Y(b.height-1.27-.4)} L${G(.635)},${Y(z)} z`,fill:"#4F91CB",stroke:Pp,strokeWidth:1,opacity:.78}):null,
165
165
  /* @__PURE__ */
166
- /* @__PURE__ */(0,Ep.jsx)("text",{x:G,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),
166
+ /* @__PURE__ */(0,Op.jsx)("text",{x:B,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),
167
167
  /* @__PURE__ */
168
- /* @__PURE__ */(0,Ep.jsx)("text",{x:G,y:X+30,textAnchor:"middle",fontSize:10,fill:Q,children:`${$} pearls${R.length<$?` (${R.length} shown)`:""}${L.length<E?` · ${L.length}/${E} ice shown`:""} · ${Math.round(C)} cm³`})]},`boba-${Z}`))}return{nodes:g,overlays:/* @__PURE__ */ /* @__PURE__ */(0,Ep.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},Rp=(/* @__PURE__ */require("d3-scale"),Symbol.for("semiotic.heatmapBandTicks")),jp=/* @__PURE__ */new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Fp=2e4,Lp=1,zp=32,Dp=6,_p=4,Wp=8,qp=72,Gp=30,Bp=-30,Yp=8,Vp=480,Hp=3,Up={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},Xp=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Kp={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},Jp={tight:5,watch:12,comfortable:20},Zp={tight:"var(--semiotic-danger, #c2410c)",watch:"var(--semiotic-warning, #d97706)",moderate:"var(--semiotic-info, #0891b2)",comfortable:"var(--semiotic-success, #16a34a)"},Qp=Hd(require("react")),ef=require("d3-array"),tf=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]<=e){let t=1;for(;t<this.capacity;)t*=2,this.tree[t]<=e||t++;n=t-this.capacity}else n=this.count++,n===this.capacity&&this.grow();let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return t<=n||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},nf=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0||0===e.data.length||!t?.domain)return{nodes:[]};const o=be(t.laneAccessor),r=be(t.startAccessor),i=be(t.endAccessor),s=t.idAccessor?be(t.idAccessor):null,a=t.unit??0,c=Te(t.barGap??1.5),l=Math.max(0,t.minBarWidth??2),d=Te(t.minBarHeight??3.5)||3.5,u=Te(t.maxBarHeight??10)||10,h=t.cornerRadius??2,p=Te(t.bottomInset??0),f=t.color??((t,n)=>e.resolveColor(n)),[m,g]=t.domain;if(!Number.isFinite(m)||!Number.isFinite(g)||m>g||!Number.isFinite(g-m))return{nodes:[]};const y=g-m||1,x=e=>n.x+(e-m)/y*n.width,b=e.scales?.o?.domain?.()??[],w=t.lanes??(b.length>0?b:[...new Set(e.data.map(o))]),M=Math.max(0,n.height-p)/Math.max(1,w.length);if(M<=0)return{nodes:[]};const v=Math.min(M/4,Te(t.lanePadding??7)),k=e=>x(r(e)),I=e=>Math.max(k(e)+l,x(i(e)+a)),S=[];w.forEach((t,r)=>{const i=n.y+r*M,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:p}=Fi(a,{start:k,end:I}),m=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(const{item:e,track:t}of l){const n=g.get(t);n&&m.set(n,k(e)),g.set(t,e)}const y=(M-2*v)/p,x=Math.min(u,y,Math.max(d,y-c));for(const{item:e,track:n}of l){const o=k(e),r=m.get(e),a=I(e)-o,c=void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,l=i+v+n*y;S.push({type:"rect",x:o,y:l,w:c,h:x,cornerRadii:h>0?{tl:h,tr:h,br:h,bl:h}:void 0,style:{fill:f(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?String(s(e)):void 0})}});const $=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,N=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,E=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,A=[];(t.periods??[]).forEach((e,t)=>{const o=x(e.start),r=Math.max(1,x(e.end+a)-o);A.push(Qp.createElement("rect",{key:`period-${t}`,x:o,y:n.y,width:r,height:n.height,fill:E,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&A.push(Fo({keyId:`period-label-${t}`,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:N}))});const C=!1!==t.showLaneLabels,O=t.laneLabelGap??12;if(w.forEach((e,t)=>{const o=n.y+t*M;A.push(Qp.createElement("line",{key:`lane-sep-${t}`,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:E,opacity:.45})),C&&A.push(Fo({keyId:`lane-label-${t}`,text:e,x:n.x-O,y:o+M/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:$}))}),!1!==t.showAxis){const e=t.axisTicks??(0,ef.ticks)(m,g,7);A.push(zo({keyId:"interval-axis",scale:x,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:N}))}return{nodes:S,overlays:Qp.createElement(Qp.Fragment,null,...A)}},of={width:60,height:34},rf=e=>{const{plot:t}=e.dimensions;if(t.width<=0||t.height<=0||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=Ki(e.nodes,e.edges,t,e.config,!0),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[],a=Ui(e.config.sourceAccessor,"source",!0),c=Ui(e.config.targetAccessor,"target",!0),l=e=>String(a(e)),d=e=>String(c(e));e.edges.forEach((e,t)=>{const o=r.get(l(e)),i=r.get(d(e));if(!o||!i)return;const{from:a,to:c}=qi({cx:o.x,cy:o.y,width:o.width,height:o.height},{cx:i.x,cy:i.y,width:i.width,height:i.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:_i(a,c,{orientation:"y"===n?"vertical":"horizontal",bend:Gi(t,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:Me(e)??e})});const u=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:u}},sf=1.15,af=5,cf={a:.556,b:.611,c:.556,d:.611,e:.556,f:.333,g:.611,h:.611,i:.278,j:.278,k:.556,l:.278,m:.889,n:.611,o:.611,p:.611,q:.611,r:.389,s:.556,t:.333,u:.611,v:.556,w:.778,x:.556,y:.556,z:.5,A:.722,B:.722,C:.722,D:.722,E:.667,F:.611,G:.778,H:.722,I:.278,J:.556,K:.722,L:.611,M:.833,N:.722,O:.778,P:.667,Q:.778,R:.722,S:.667,T:.611,U:.722,V:.667,W:.944,X:.667,Y:.667,Z:.611,"'":.278,"’":.278,"-":.333,".":.278,",":.278," ":.278},lf=.556,df=.65,uf=1,hf=1.05,pf=1,ff=class e{constructor(e){this.cell=e,this.cells=/* @__PURE__ */new Map}span(e,t){return[Math.floor(e/this.cell),Math.floor(t/this.cell)]}static key(e,t){return 65536*(e+32768)+(t+32768)}insert(t){const[n,o]=this.span(t.x-t.w/2,t.x+t.w/2),[r,i]=this.span(t.y-t.h/2,t.y+t.h/2);for(let s=n;s<=o;s++)for(let n=r;n<=i;n++){const o=e.key(s,n),r=this.cells.get(o);r?r.push(t):this.cells.set(o,[t])}}collides(t,n){const[o,r]=this.span(t.x-t.w/2-n,t.x+t.w/2+n),[i,s]=this.span(t.y-t.h/2-n,t.y+t.h/2+n);for(let a=o;a<=r;a++)for(let o=i;o<=s;o++){const r=this.cells.get(e.key(a,o));if(r)for(const e of r)if(Math.abs(t.x-e.x)<(t.w+e.w)/2+n&&Math.abs(t.y-e.y)<(t.h+e.h)/2+n)return!0}return!1}},mf=32,gf=2600,yf=require("react/jsx-runtime"),xf=/* @__PURE__ */new Ru(12),bf={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},wf=8,Mf=hs,vf=2*Math.PI,kf=[40,40],If=[.5,.5],Sf=require("react/jsx-runtime"),$f="var(--semiotic-text, currentColor)",Nf=8,Ef=/* @__PURE__ */new Set(["rows"]);Kd(),$u(),Ud(),Number.POSITIVE_INFINITY;var Af=[.1,.5,.9],Cf=1e6,Of=12,Tf=require("react"),Pf=require("react"),Rf=require("react/jsx-runtime"),jf={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},Ff=6.2,Lf={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1},zf="\0",Df=Object.freeze({kind:"node"}),_f=class extends Error{constructor(e){super(e.map(e=>`${e.code}: ${e.message}`).join("\n")),this.diagnostics=e,this.name="CompositionalGraphError"}},Wf=/* @__PURE__ */new WeakMap,qf=1e-8,Gf=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),Bf=e=>e.slice(1).reduce((t,n,o)=>t+Gf(e[o],n),0),Yf=(e,t)=>JSON.stringify([e,t]),Vf=(e,t,n,o)=>JSON.stringify([e,t??null,n,o]),Hf=e=>({...e,point:{...e.point},normal:{...e.normal}}),Uf=/* @__PURE__ */new WeakMap,Xf={id:"semiotic-compositional",version:"0.1.0",capabilities:{fixedPositions:!0,fixedPortPositions:!0,constrainedPartOrder:!0,multiedges:!0,compoundCrossHierarchy:!1,orthogonalRouting:!0,deterministicSeed:!0},async layout(e,t){if(t?.aborted)throw new Error("REVISION_CANCELLED");return Id(e)}},Kf=class{constructor(){this.generation=0,this.currentDiagnostics=[],this.updating=!1}get solution(){return this.accepted}get diagnostics(){return this.currentDiagnostics}async solve(e,t=Xf){this.abort?.abort();const n=new AbortController,o=++this.generation;this.abort=n,this.updating=!0;try{const r=await Nd(e,t,n.signal);return o===this.generation&&(this.currentDiagnostics=r.diagnostics,"infeasible"!==r.status&&(this.accepted=r,!0))}catch(e){return o===this.generation&&(this.currentDiagnostics=[{code:"REVISION_SOLVE_FAILED",severity:"error",message:e instanceof Error?e.message:"Layout failed."}]),!1}finally{o===this.generation&&(this.updating=!1)}}cancel(){this.generation++,this.abort?.abort(),this.updating=!1}dispose(){this.cancel(),this.accepted=void 0,this.currentDiagnostics=[]}},Jf=e=>Ed(e.config),Zf=class{constructor(e,t){this.current=e,this.accepted=t,this.passes=0}get solution(){return this.accepted}update(e){if(Jl(e),e.basis===this.current.geometry.basis&&El(e.nodes)===El(this.current.geometry.nodes))return this.accepted;if(this.passes>=2)return Al({...this.accepted,status:"degraded",diagnostics:[...this.accepted.diagnostics,{code:"GEOMETRY_UNSTABLE_MEASUREMENT",severity:"warning",message:"Measurement did not converge after two corrections; retaining the last valid scene."}]});if(e.revision===this.current.geometry.revision)return Al({...this.accepted,status:"degraded",diagnostics:[...this.accepted.diagnostics,{code:"REVISION_GEOMETRY",severity:"warning",message:"Changed geometry requires a new revision; retaining the last valid scene."}]});this.passes++;const t={...this.current,requestId:`${this.current.requestId}:measure:${this.passes}`,geometry:e,previous:this.accepted},n=Id(t);return"infeasible"!==n.status&&(this.accepted=n,this.current=t),"infeasible"===n.status?Al({...this.accepted,status:"degraded",diagnostics:[...this.accepted.diagnostics,...n.diagnostics]}):this.accepted}};
168
+ /* @__PURE__ */(0,Op.jsx)("text",{x:B,y:X+30,textAnchor:"middle",fontSize:10,fill:Q,children:`${$} pearls${R.length<$?` (${R.length} shown)`:""}${L.length<E?` · ${L.length}/${E} ice shown`:""} · ${Math.round(C)} cm³`})]},`boba-${Z}`))}return{nodes:g,overlays:/* @__PURE__ */ /* @__PURE__ */(0,Op.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},Lp=(/* @__PURE__ */require("d3-scale"),Symbol.for("semiotic.heatmapBandTicks")),zp=/* @__PURE__ */new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Dp=2e4,_p=1,Wp=32,qp=6,Bp=4,Gp=8,Yp=72,Vp=30,Hp=-30,Up=8,Xp=480,Kp=3,Jp={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},Zp=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Qp={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},ef={tight:5,watch:12,comfortable:20},tf={tight:"var(--semiotic-danger, #c2410c)",watch:"var(--semiotic-warning, #d97706)",moderate:"var(--semiotic-info, #0891b2)",comfortable:"var(--semiotic-success, #16a34a)"},nf=Kd(require("react")),of=require("d3-array"),rf=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]<=e){let t=1;for(;t<this.capacity;)t*=2,this.tree[t]<=e||t++;n=t-this.capacity}else n=this.count++,n===this.capacity&&this.grow();let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return t<=n||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},sf=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0||0===e.data.length||!t?.domain)return{nodes:[]};const o=be(t.laneAccessor),r=be(t.startAccessor),i=be(t.endAccessor),s=t.idAccessor?be(t.idAccessor):null,a=t.unit??0,c=Te(t.barGap??1.5),l=Math.max(0,t.minBarWidth??2),d=Te(t.minBarHeight??3.5)||3.5,u=Te(t.maxBarHeight??10)||10,h=t.cornerRadius??2,p=Te(t.bottomInset??0),f=t.color??((t,n)=>e.resolveColor(n)),[m,g]=t.domain;if(!Number.isFinite(m)||!Number.isFinite(g)||m>g||!Number.isFinite(g-m))return{nodes:[]};const y=g-m||1,x=e=>n.x+(e-m)/y*n.width,b=e.scales?.o?.domain?.()??[],w=t.lanes??(b.length>0?b:[...new Set(e.data.map(o))]),M=Math.max(0,n.height-p)/Math.max(1,w.length);if(M<=0)return{nodes:[]};const v=Math.min(M/4,Te(t.lanePadding??7)),I=e=>x(r(e)),k=e=>Math.max(I(e)+l,x(i(e)+a)),S=[];w.forEach((t,r)=>{const i=n.y+r*M,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:p}=Fi(a,{start:I,end:k}),m=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(const{item:e,track:t}of l){const n=g.get(t);n&&m.set(n,I(e)),g.set(t,e)}const y=(M-2*v)/p,x=Math.min(u,y,Math.max(d,y-c));for(const{item:e,track:n}of l){const o=I(e),r=m.get(e),a=k(e)-o,c=void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,l=i+v+n*y;S.push({type:"rect",x:o,y:l,w:c,h:x,cornerRadii:h>0?{tl:h,tr:h,br:h,bl:h}:void 0,style:{fill:f(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?String(s(e)):void 0})}});const $=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,N=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,E=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,A=[];(t.periods??[]).forEach((e,t)=>{const o=x(e.start),r=Math.max(1,x(e.end+a)-o);A.push(nf.createElement("rect",{key:`period-${t}`,x:o,y:n.y,width:r,height:n.height,fill:E,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&A.push(Fo({keyId:`period-label-${t}`,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:N}))});const C=!1!==t.showLaneLabels,O=t.laneLabelGap??12;if(w.forEach((e,t)=>{const o=n.y+t*M;A.push(nf.createElement("line",{key:`lane-sep-${t}`,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:E,opacity:.45})),C&&A.push(Fo({keyId:`lane-label-${t}`,text:e,x:n.x-O,y:o+M/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:$}))}),!1!==t.showAxis){const e=t.axisTicks??(0,of.ticks)(m,g,7);A.push(zo({keyId:"interval-axis",scale:x,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:N}))}return{nodes:S,overlays:nf.createElement(nf.Fragment,null,...A)}},af={width:60,height:34},cf=e=>{const{plot:t}=e.dimensions;if(t.width<=0||t.height<=0||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=Ki(e.nodes,e.edges,t,e.config,!0),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[],a=Ui(e.config.sourceAccessor,"source",!0),c=Ui(e.config.targetAccessor,"target",!0),l=e=>String(a(e)),d=e=>String(c(e));e.edges.forEach((e,t)=>{const o=r.get(l(e)),i=r.get(d(e));if(!o||!i)return;const{from:a,to:c}=qi({cx:o.x,cy:o.y,width:o.width,height:o.height},{cx:i.x,cy:i.y,width:i.width,height:i.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:_i(a,c,{orientation:"y"===n?"vertical":"horizontal",bend:Bi(t,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:Me(e)??e})});const u=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:u}},lf=1.15,df=5,uf={a:.556,b:.611,c:.556,d:.611,e:.556,f:.333,g:.611,h:.611,i:.278,j:.278,k:.556,l:.278,m:.889,n:.611,o:.611,p:.611,q:.611,r:.389,s:.556,t:.333,u:.611,v:.556,w:.778,x:.556,y:.556,z:.5,A:.722,B:.722,C:.722,D:.722,E:.667,F:.611,G:.778,H:.722,I:.278,J:.556,K:.722,L:.611,M:.833,N:.722,O:.778,P:.667,Q:.778,R:.722,S:.667,T:.611,U:.722,V:.667,W:.944,X:.667,Y:.667,Z:.611,"'":.278,"’":.278,"-":.333,".":.278,",":.278," ":.278},hf=.556,pf=.65,ff=1,mf=1.05,gf=1,yf=class e{constructor(e){this.cell=e,this.cells=/* @__PURE__ */new Map}span(e,t){return[Math.floor(e/this.cell),Math.floor(t/this.cell)]}static key(e,t){return 65536*(e+32768)+(t+32768)}insert(t){const[n,o]=this.span(t.x-t.w/2,t.x+t.w/2),[r,i]=this.span(t.y-t.h/2,t.y+t.h/2);for(let s=n;s<=o;s++)for(let n=r;n<=i;n++){const o=e.key(s,n),r=this.cells.get(o);r?r.push(t):this.cells.set(o,[t])}}collides(t,n){const[o,r]=this.span(t.x-t.w/2-n,t.x+t.w/2+n),[i,s]=this.span(t.y-t.h/2-n,t.y+t.h/2+n);for(let a=o;a<=r;a++)for(let o=i;o<=s;o++){const r=this.cells.get(e.key(a,o));if(r)for(const e of r)if(Math.abs(t.x-e.x)<(t.w+e.w)/2+n&&Math.abs(t.y-e.y)<(t.h+e.h)/2+n)return!0}return!1}},xf=32,bf=2600,wf=require("react/jsx-runtime"),Mf=/* @__PURE__ */new Lu(12),vf={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},If=8,kf=hs,Sf=2*Math.PI,$f=[40,40],Nf=[.5,.5],Ef=require("react/jsx-runtime"),Af="var(--semiotic-text, currentColor)",Cf=8,Of=/* @__PURE__ */new Set(["rows"]);Qd(),Au(),Jd(),Number.POSITIVE_INFINITY;var Tf=[.1,.5,.9],Pf=1e6,Rf=12,jf=require("react"),Ff=require("react"),Lf=require("react/jsx-runtime"),zf={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},Df=6.2,_f={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1},Wf="\0",qf=Object.freeze({kind:"node"}),Bf=class extends Error{constructor(e){super(e.map(e=>`${e.code}: ${e.message}`).join("\n")),this.diagnostics=e,this.name="CompositionalGraphError"}},Gf=/* @__PURE__ */new WeakMap,Yf=1e-8,Vf=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),Hf=e=>e.slice(1).reduce((t,n,o)=>t+Vf(e[o],n),0),Uf=(e,t)=>JSON.stringify([e,t]),Xf=(e,t,n,o)=>JSON.stringify([e,t??null,n,o]),Kf=e=>({...e,point:{...e.point},normal:{...e.normal}}),Jf=/* @__PURE__ */new WeakMap,Zf={id:"semiotic-compositional",version:"0.1.0",capabilities:{fixedPositions:!0,fixedPortPositions:!0,constrainedPartOrder:!0,multiedges:!0,compoundCrossHierarchy:!1,orthogonalRouting:!0,terminalRouting:!0,bumpRouting:!0,deterministicSeed:!0},async layout(e,t){if(t?.aborted)throw new Error("REVISION_CANCELLED");return Nd(e)}},Qf=class{constructor(){this.generation=0,this.currentDiagnostics=[],this.updating=!1}get solution(){return this.accepted}get diagnostics(){return this.currentDiagnostics}async solve(e,t=Zf){this.abort?.abort();const n=new AbortController,o=++this.generation;this.abort=n,this.updating=!0;try{const r=await Cd(e,t,n.signal);return o===this.generation&&(this.currentDiagnostics=r.diagnostics,"infeasible"!==r.status&&(this.accepted=r,!0))}catch(e){return o===this.generation&&(this.currentDiagnostics=[{code:"REVISION_SOLVE_FAILED",severity:"error",message:e instanceof Error?e.message:"Layout failed."}]),!1}finally{o===this.generation&&(this.updating=!1)}}cancel(){this.generation++,this.abort?.abort(),this.updating=!1}dispose(){this.cancel(),this.accepted=void 0,this.currentDiagnostics=[]}},em=e=>Od(e.config),tm=class{constructor(e,t){this.current=e,this.accepted=t,this.passes=0}get solution(){return this.accepted}update(e){if(Jl(e),e.basis===this.current.geometry.basis&&El(e.nodes)===El(this.current.geometry.nodes))return this.accepted;if(this.passes>=2)return Al({...this.accepted,status:"degraded",diagnostics:[...this.accepted.diagnostics,{code:"GEOMETRY_UNSTABLE_MEASUREMENT",severity:"warning",message:"Measurement did not converge after two corrections; retaining the last valid scene."}]});if(e.revision===this.current.geometry.revision)return Al({...this.accepted,status:"degraded",diagnostics:[...this.accepted.diagnostics,{code:"REVISION_GEOMETRY",severity:"warning",message:"Changed geometry requires a new revision; retaining the last valid scene."}]});this.passes++;const t={...this.current,requestId:`${this.current.requestId}:measure:${this.passes}`,geometry:e,previous:this.accepted},n=Nd(t);return"infeasible"!==n.status&&(this.accepted=n,this.current=t),"infeasible"===n.status?Al({...this.accepted,status:"degraded",diagnostics:[...this.accepted.diagnostics,...n.diagnostics]}):this.accepted}};