semiotic 3.8.6 → 3.8.7

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 (213) hide show
  1. package/CLAUDE.md +33 -7
  2. package/README.md +82 -55
  3. package/ai/behaviorContracts.cjs +86 -1
  4. package/ai/componentMetadata.cjs +4 -9
  5. package/ai/dist/mcp-server.js +97 -10
  6. package/ai/examples.md +154 -7
  7. package/ai/schema.json +1611 -145
  8. package/ai/surface-manifest.json +12 -10
  9. package/ai/system-prompt.md +9 -3
  10. package/dist/{chunk-chartContainerDataAudit-FEOD5GTQ.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
  11. package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
  12. package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
  13. package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
  14. package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
  15. package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
  16. package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
  17. package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
  18. package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
  19. package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
  20. package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
  21. package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
  22. package/dist/{chunk-chunk-Q2BS46W2.module.min.js → chunk-chunk-DIVE2DRA.module.min.js} +1 -1
  23. package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
  24. package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
  25. package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
  26. package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
  27. package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
  28. package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
  29. package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
  30. package/dist/{chunk-chunk-RA7JCG7D.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
  31. package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
  32. package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
  33. package/dist/{chunk-chunk-XP3OHHFX.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
  34. package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
  35. package/dist/{chunk-chunk-SMVD3EQJ.module.min.js → chunk-chunk-MX35T6RX.module.min.js} +1 -1
  36. package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
  37. package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
  38. package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
  39. package/dist/{chunk-chunk-GFTVACTO.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
  40. package/dist/{chunk-chunk-OM6NWS4H.module.min.js → chunk-chunk-ONMLEXHR.module.min.js} +1 -1
  41. package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
  42. package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
  43. package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
  44. package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
  45. package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
  46. package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
  47. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  48. package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
  49. package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
  50. package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
  51. package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
  52. package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
  53. package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
  54. package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
  55. package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
  56. package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
  57. package/dist/components/ai/chartCapabilities.d.ts +4 -3
  58. package/dist/components/ai/conversationArc.d.ts +2 -176
  59. package/dist/components/ai/conversationArcTypes.d.ts +202 -0
  60. package/dist/components/ai/readerGrounding.d.ts +12 -0
  61. package/dist/components/ai/vacpAdapter.d.ts +13 -0
  62. package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
  63. package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
  64. package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
  65. package/dist/components/ai/vacpAdapterState.d.ts +3 -0
  66. package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
  67. package/dist/components/ai/vacpTypes.d.ts +160 -0
  68. package/dist/components/charts/index.d.ts +4 -4
  69. package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
  70. package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
  71. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
  72. package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
  73. package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
  74. package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
  75. package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
  76. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
  77. package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
  78. package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
  79. package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
  80. package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
  81. package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
  82. package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
  83. package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
  84. package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
  85. package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
  86. package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
  87. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  88. package/dist/components/charts/shared/useChartLegend.d.ts +8 -1
  89. package/dist/components/charts/shared/useChartSetup.d.ts +7 -0
  90. package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
  91. package/dist/components/data/portability/index.d.ts +2 -0
  92. package/dist/components/legendLayout.d.ts +56 -0
  93. package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
  94. package/dist/components/recipes/geographicGrid.d.ts +100 -0
  95. package/dist/components/recipes/physics.d.ts +2 -0
  96. package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
  97. package/dist/components/semiotic-ai.d.ts +4 -3
  98. package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
  99. package/dist/components/semiotic-experimental.d.ts +6 -3
  100. package/dist/components/semiotic-geo.d.ts +4 -0
  101. package/dist/components/semiotic-physics.d.ts +9 -6
  102. package/dist/components/semiotic-recipes-core.d.ts +6 -1
  103. package/dist/components/server/renderEvidence.d.ts +1 -1
  104. package/dist/components/server/renderToStaticSVG.d.ts +2 -1
  105. package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
  106. package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
  107. package/dist/components/server/serverChartConfigShared.d.ts +16 -0
  108. package/dist/components/server/serverChartConfigs.d.ts +2 -2
  109. package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
  110. package/dist/components/server/serverChartConfigsXY.d.ts +0 -1
  111. package/dist/components/server/staticLegend.d.ts +6 -0
  112. package/dist/components/server/staticSVGChrome.d.ts +10 -2
  113. package/dist/components/server/staticValue.d.ts +8 -0
  114. package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
  115. package/dist/components/stream/legendRenderer.d.ts +8 -0
  116. package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
  117. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
  118. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
  119. package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
  120. package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
  121. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
  122. package/dist/components/stream/types.d.ts +2 -0
  123. package/dist/components/types/legendTypes.d.ts +17 -1
  124. package/dist/controls.min.js +1 -1
  125. package/dist/controls.module.min.js +1 -1
  126. package/dist/geo.min.js +1 -1
  127. package/dist/geo.module.min.js +1 -1
  128. package/dist/network.min.js +1 -1
  129. package/dist/network.module.min.js +1 -1
  130. package/dist/ordinal.min.js +1 -1
  131. package/dist/ordinal.module.min.js +1 -1
  132. package/dist/physics.min.js +1 -1
  133. package/dist/physics.module.min.js +1 -1
  134. package/dist/physicsWorker.js +1 -1
  135. package/dist/realtime.min.js +1 -1
  136. package/dist/realtime.module.min.js +1 -1
  137. package/dist/semiotic-ai-core.min.js +1 -1
  138. package/dist/semiotic-ai-core.module.min.js +1 -1
  139. package/dist/semiotic-ai.d.ts +4 -3
  140. package/dist/semiotic-ai.min.js +1 -1
  141. package/dist/semiotic-ai.module.min.js +1 -1
  142. package/dist/semiotic-data.module.min.js +1 -1
  143. package/dist/semiotic-experimental-vacp.d.ts +11 -0
  144. package/dist/semiotic-experimental-vacp.min.js +1 -0
  145. package/dist/semiotic-experimental-vacp.module.min.js +1 -0
  146. package/dist/semiotic-experimental.d.ts +6 -3
  147. package/dist/semiotic-experimental.min.js +2 -1
  148. package/dist/semiotic-experimental.module.min.js +2 -1
  149. package/dist/semiotic-geo.d.ts +4 -0
  150. package/dist/semiotic-physics.d.ts +9 -6
  151. package/dist/semiotic-realtime-core.min.js +1 -1
  152. package/dist/semiotic-realtime-core.module.min.js +1 -1
  153. package/dist/semiotic-recipes-core.d.ts +6 -1
  154. package/dist/semiotic-recipes-core.min.js +1 -1
  155. package/dist/semiotic-recipes-core.module.min.js +1 -1
  156. package/dist/semiotic-recipes.min.js +1 -1
  157. package/dist/semiotic-recipes.module.min.js +1 -1
  158. package/dist/semiotic-server-edge.min.js +1 -1
  159. package/dist/semiotic-server-edge.module.min.js +1 -1
  160. package/dist/semiotic-server-node.min.js +1 -1
  161. package/dist/semiotic-server-node.module.min.js +1 -1
  162. package/dist/semiotic-utils-core.min.js +1 -1
  163. package/dist/semiotic-utils-core.module.min.js +1 -1
  164. package/dist/semiotic-utils.min.js +1 -1
  165. package/dist/semiotic-utils.module.min.js +1 -1
  166. package/dist/semiotic.min.js +1 -1
  167. package/dist/semiotic.module.min.js +1 -1
  168. package/dist/server.min.js +1 -1
  169. package/dist/server.module.min.js +1 -1
  170. package/dist/xy.min.js +1 -1
  171. package/dist/xy.module.min.js +1 -1
  172. package/package.json +18 -2
  173. package/spec/README.md +94 -2
  174. package/spec/bindings/README.md +14 -3
  175. package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
  176. package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
  177. package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
  178. package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
  179. package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
  180. package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
  181. package/dist/chunk-chunk-2CHN2TA3.module.min.js +0 -1
  182. package/dist/chunk-chunk-3SHB24AG.module.min.js +0 -1
  183. package/dist/chunk-chunk-4MMOOYTX.module.min.js +0 -2
  184. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
  185. package/dist/chunk-chunk-75OTQSXS.module.min.js +0 -1
  186. package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
  187. package/dist/chunk-chunk-A5GRQUOF.module.min.js +0 -1
  188. package/dist/chunk-chunk-AAF5LZAU.module.min.js +0 -2
  189. package/dist/chunk-chunk-ARZGA4LJ.module.min.js +0 -2
  190. package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
  191. package/dist/chunk-chunk-CAFLML4L.module.min.js +0 -2
  192. package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
  193. package/dist/chunk-chunk-FHBN7OEB.module.min.js +0 -2
  194. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
  195. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  196. package/dist/chunk-chunk-ITDWLZXV.module.min.js +0 -2
  197. package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
  198. package/dist/chunk-chunk-LPSPATPC.module.min.js +0 -1
  199. package/dist/chunk-chunk-PX5YQGDP.module.min.js +0 -2
  200. package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
  201. package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
  202. package/dist/chunk-chunk-RNUHEXZA.module.min.js +0 -2
  203. package/dist/chunk-chunk-ROZWKEUG.module.min.js +0 -1
  204. package/dist/chunk-chunk-T2FKJD4O.module.min.js +0 -2
  205. package/dist/chunk-chunk-UDREYOLV.module.min.js +0 -1
  206. package/dist/chunk-chunk-VOWE3SAP.module.min.js +0 -2
  207. package/dist/chunk-chunk-VQPNBUSW.module.min.js +0 -2
  208. package/dist/chunk-chunk-WAWCIHFJ.module.min.js +0 -1
  209. package/dist/chunk-chunk-WYARAXHR.module.min.js +0 -2
  210. package/dist/chunk-chunk-XV3KGYTR.module.min.js +0 -2
  211. package/dist/chunk-chunk-YC2IVEPX.module.min.js +0 -1
  212. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
  213. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
@@ -1 +0,0 @@
1
- import{createStore as e}from"./chunk-chunk-DSNGDNJY.module.min.js";var t={fresh:1,aging:1.5,stale:3};function n(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}function r(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var o=null;function i(e={},t){const{background:n="transparent",stroke:i="#000",lineWidth:a=1.5,spacing:s=6,angle:l=45}=e,c={background:n,stroke:i,lineWidth:a,spacing:s,angle:l},u=Math.max(8,Math.ceil(2*s));let f;try{f=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(o||(o=document.createElement("canvas")),o.width=e,o.height=e,o)}(u)}catch{return r(c)}const d=f.getContext("2d");if(!d)return r(c);n&&"transparent"!==n?(d.fillStyle=n,d.fillRect(0,0,u,u)):d.clearRect(0,0,u,u),d.strokeStyle=i,d.lineWidth=a,d.lineCap="square";const p=l*Math.PI/180;if(45===l||-45===l){const e=l>0?1:-1;for(let t=-u;2*u>=t;t+=s)d.beginPath(),d.moveTo(t,0),d.lineTo(t+e*u,u),d.stroke()}else{d.save(),d.translate(u/2,u/2),d.rotate(p);const e=2*u;for(let t=-e;e>=t;t+=s)d.beginPath(),d.moveTo(-e,t),d.lineTo(e,t),d.stroke();d.restore()}return(t||d).createPattern(f,"repeat")}import{jsx as a,jsxs as s}from"react/jsx-runtime";function l(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function c(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function u(e,t){let n=2166136261;const r=c(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}var f=new Map;function d(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${c(e)}@${n}`,o=f.get(r);if(void 0!==o)return o;const a=i({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),s=l(a)?null:a;return f.set(r,s),s}function p(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:l=45,lineOpacity:c=1}=e,u=Math.max(8,Math.ceil(2*i));return s("pattern",{id:t,width:u,height:u,patternUnits:"userSpaceOnUse",patternTransform:0!==l?`rotate(${l})`:void 0,children:[n&&"transparent"!==n&&a("rect",{width:u,height:u,fill:n}),a("line",{x1:0,y1:0,x2:0,y2:u,stroke:r,strokeWidth:o,strokeOpacity:c}),a("line",{x1:i,y1:0,x2:i,y2:u,stroke:r,strokeWidth:o,strokeOpacity:c})]},t)}function h(e,t,n="#4e79a7"){if(l(e)){const n=u(t,e);return{fill:`url(#${n})`,def:p(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}function m(e,t){return"touch"===t?Math.max(e,24):e}function y(e){return Array.isArray(e)?e[0]:e}function b(e,t,n,r){return{data:y(e),x:t,y:n,__semioticHoverData:!0,...r}}var g=["name","label","title"],v=["type","kind","category","group","class","status","role","shape"],k=["value","amount","total","count","weight","score"],x=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function w(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function N(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&x.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>g.includes(e.lower));const a=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=w(l,v),u=w(l,k),f=new Set(v),d=new Set(k),p=[];c&&p.push({key:c.key,value:c.value}),u&&p.push({key:u.key,value:u.value});for(const e of l){if(p.length>=n)break;e!==c&&e!==u&&(f.has(e.lower)||d.has(e.lower)||p.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:p}}import{jsx as A,jsxs as W}from"react/jsx-runtime";var O={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function S(e,t){return"function"==typeof t?t(e):e[t]}function j(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function C(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=S(e,n);a=j(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=S(e,o);s.push({label:n,value:j(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=j(e[n],r);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=j(e[t[0]],r))}}const l={...O,...o};return W("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&A("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>W("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&W("span",{children:[e.label,": "]}),e.value]},t))]})}}function I(){return e=>{const t=e.allSeries;if(!t||0===t.length)return A("div",{className:"semiotic-tooltip",style:O,children:A("div",{children:j(e.data?.value??e.data?.y)})});const n=e.xValue??e.data?.time??e.data?.x;return W("div",{className:"semiotic-tooltip",style:O,children:[null!=n&&A("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:j(n)}),t.map((e,t)=>W("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[A("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),A("span",{style:{flex:1,fontSize:"0.85em"},children:e.group}),A("span",{style:{fontWeight:500,fontSize:"0.85em"},children:j(e.value)})]},t))]})}}function T(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=y(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const r=t(n);return null==r?null:A("div",{className:"semiotic-tooltip",style:O,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?C(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:r,style:o={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=S(e,n);l.push({value:j(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=j(S(e,o),i);l.push({label:a?n:void 0,value:s})});else{const t=N(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:j(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:a?e.key:void 0,value:j(e.value,r)})})}const c={...O,...o};return Array.isArray(l)&&0!==l.length?A("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>W("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&W("strong",{children:[e.label,s]}),e.value]},t))}):null}}()):C())}}function D(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function E(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function R(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>E(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])D(e[r])&&D(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}function M(e,t){return e===t}function _(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function P(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function F(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var $=/^\d{4}-\d{1,2}$/;function L(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=$.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function z(e){return e instanceof Date?e.getTime():"string"==typeof e?L(e):+e}function H(e,t){if(!e||!t)return{data:e,failed:!1};let n=!1,r=!1;const o=e.map(e=>{const o=e[t];if("string"!=typeof o)return e;const i=L(o);return n=!0,Number.isFinite(i)?{...e,[t]:i}:(r=!0,{...e,[t]:NaN})});return{data:n?o:e,failed:r}}import*as B from"react";var[V,J]=e(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function U(e){const t=J(e=>e.pushObservation),n=B.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return B.useMemo(()=>({...e,onObservation:n}),[n,e])}function q(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}function G(e,t={}){const n=q(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function K(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}function Y(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}function Q(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function X(e){return e&&"object"==typeof e?e:{}}function Z(e){return X(e.accessibility).tableFields??e.accessibleDatum??e.datum}function ee(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:Q(Z(r))});break;case"line":case"area":{const e=Z(r),n=Array.isArray(e)?e:[],o="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:o,values:Q(e)});break}case"rect":{const e=Z(r),n=null!=e&&"object"==typeof e?e:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,a=Q(n);null==a.category&&""!==o&&(a.category=o+""),null==a.value&&null!=i&&(a.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:a});break}case"heatcell":{const e=Q(Z(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Z(r),n=Q(e);if(null==n.category){const t=X(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Q(Z(r))});break;case"arc":t.push({label:"Arc",values:Q(Z(r))});break;case"candlestick":t.push({label:"Candlestick",values:Q(Z(r))});break;case"geoarea":{const e=X(Z(r)),n=Q(e);if(null==n.name){const t=X(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}export{M as accessorsEquivalent,_ as resolveAccessor,P as resolveRawAccessor,F as resolveStringAccessor,L as parseDateLikeString,z as coerceDateLikeValue,H as coerceTemporalStringRows,t as DEFAULT_LIFECYCLE_THRESHOLDS,n as bandFromAge,i as createHatchPattern,l as isHatchFill,c as hatchFillKey,u as hatchFillId,d as resolveHatchCanvasPattern,p as hatchPatternDef,h as resolveSvgFill,J as useObservationSelector,U as useAnnotationActivationOptions,q as annotationStableId,G as annotationActivationProps,K as isAnnotationActivationTarget,Y as filterAnnotationsByStatus,ee as extractAllRows,m as getPointerHitRadius,b as buildHoverData,N as smartTooltipEntries,O as defaultTooltipStyle,I as MultiPointTooltip,T as normalizeTooltip,E as responsiveRuleMatches,R as resolveResponsiveRules};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{useChartSetup as t,useCustomChartScaffold as e}from"./chunk-chunk-VQPNBUSW.module.min.js";import{lineCanvasRenderer as n,resolveNodeColor as i}from"./chunk-chunk-SMVD3EQJ.module.min.js";import{RingBuffer as o,compactTimestampBufferForRemoval as r,computePulseIntensity as s,hasActivePulses as a,pointCanvasRenderer as c,pushWithTimestamp as l,refreshIdlePulse as u,setPulseState as h,useGeoKeyboardNavigation as d,useLegendCategoryEmission as p,useSemanticFrameInteractions as f}from"./chunk-chunk-OM6NWS4H.module.min.js";import{needsDataCanvasPaint as m,needsInteractionCanvasPaint as g,paintCanvasBackground as y}from"./chunk-chunk-GFTVACTO.module.min.js";import{StalenessBadge as v,attachUpdateResultStore as b,buildBaseMetadataProps as w,buildCustomBehaviorProps as P,composeOverlays as x,computeDecayOpacity as R,createCustomLayoutFailureDiagnostic as A,filterAnnotationsByStatus as S,findHitPointInQuadtree as L,formatVal as k,getHitRadius as C,glyphCanvasRenderer as D,paintSceneWithBackend as j,renderPathPulse as M,renderSceneWithBackend as T,useConfigSync as B,useLayoutSelectionSync as _,useStableShallow as I,useStalenessCheck as E,warnCustomLayoutDiagnostics as N}from"./chunk-chunk-WYARAXHR.module.min.js";import{wrapWithCustomLayoutSelection as O}from"./chunk-chunk-5UKL5W76.module.min.js";import{buildResolveColor as W,resolveCustomLayoutPalette as F}from"./chunk-chunk-RA7JCG7D.module.min.js";import{AccessibleDataTable as H,AriaLiveTooltip as z,CanvasFrameBackground as G,FlippingTooltip as q,FocusRing as Z,STREAMING_PALETTE as X,SceneRevisionDiagnosticsObserver as Y,ScreenReaderSummary as U,SkipToTableLink as Q,TITLE_BASELINE as V,UpdateResultTracker as $,annotationLayout as J,coerceCanvasFill as K,computeCanvasAriaLabel as tt,computeEasing as et,computeRawProgress as nt,createDefaultAnnotationRules as it,defaultTooltipStyle as ot,filterSparseArray as rt,geoSceneNodeToSVG as st,getDevicePixelRatio as at,getPointerHitRadius as ct,isAnnotationActivationTarget as lt,isServerEnvironment as ut,lerp as ht,normalizeTooltip as dt,now as pt,observationInputType as ft,prepareCanvas as mt,renderAnnotationPass as gt,renderLegendFromConfig as yt,resolveCSSColor as vt,smartTooltipEntries as bt,useAnnotationActivationOptions as wt,useFrame as Pt,useFrameCanvasHost as xt,useSceneRevisionDiagnostics as Rt}from"./chunk-chunk-PX5YQGDP.module.min.js";import{getMax as At}from"./chunk-chunk-JJ2OOIET.module.min.js";import{resolveThemeSemanticColors as St}from"./chunk-chunk-WCX6U47H.module.min.js";import{glyphHitGeometry as Lt}from"./chunk-chunk-KTWEBFMX.module.min.js";import{SafeRender as kt,useHydration as Ct,useWasHydratingFromSSR as Dt}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useRef as jt,useState as Mt,useEffect as Tt,useMemo as Bt,useCallback as _t,useImperativeHandle as It,forwardRef as Et,memo as Nt}from"react";import{geoPath as Ot}from"d3-geo";import{quadtree as Wt}from"d3-quadtree";import{geoMercator as Ft,geoEqualEarth as Ht,geoAlbersUsa as zt,geoOrthographic as Gt,geoNaturalEarth1 as qt,geoEquirectangular as Zt}from"d3-geo";var Xt={mercator:Ft,equalEarth:Ht,albersUsa:zt,orthographic:Gt,naturalEarth:qt,equirectangular:Zt};function Yt(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Ut(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Qt(t,e,n){return t?"function"==typeof t?{...n,...t(e)}:{...n,...t}:{...n}}function Vt(t,e){if(2>t.length)return[t];const n=.4*e,i=[];let o=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>o.length||i.push(o),o=[r]):o.push(r)}return 2>o.length||i.push(o),i}function $t(t,e,n=24){const i=e[0]-t[0],o=e[1]-t[1],r=Math.sqrt(i*i+o*o);if(0===r)return[t,e];const s=-o/r,a=i/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let i=0;n>=i;i++){const o=i/n,r=1-o;h.push([r*r*t[0]+2*r*o*l+o*o*e[0],r*r*t[1]+2*r*o*u+o*o*e[1]])}return h}function Jt(t,e){if(2>t.length)return t;const n=e/2+1,i=[];for(let e=0;t.length>e;e++){const o=t[e];let r,s;0===e?(r=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(r=o[0]-t[e-1][0],s=o[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;i.push([o[0]+s/a*n,o[1]+-r/a*n])}return i}function Kt(t,e,n,i,o){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const c=s/a,l=-r/a,u=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}import{scaleLinear as te}from"d3-scale";var ee=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ne=["scene-style","data-paint","accessibility","evidence"],ie=(t,e)=>({retainedData:t,invalidations:e}),oe=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],re=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],se=["scene-geometry","data-paint","accessibility","evidence"],ae=["scene-style","data-paint","accessibility","evidence"],ce=["overlay","accessibility","evidence"],le=[],ue={xAccessor:ie("rebuild",oe),yAccessor:ie("rebuild",oe),lineDataAccessor:ie("rebuild",oe),pointIdAccessor:ie("rebuild",se),lineIdAccessor:ie("rebuild",se),windowSize:ie("rebuild",oe),projection:ie("preserve",re),projectionExtent:ie("preserve",re),fitPadding:ie("preserve",re),lineType:ie("preserve",re),flowStyle:ie("preserve",re),graticule:ie("preserve",re),projectionTransform:ie("preserve",re),customLayout:ie("preserve",re),layoutConfig:ie("preserve",re),layoutMargin:ie("preserve",re),areaStyle:ie("preserve",ae),pointStyle:ie("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:ie("preserve",ae),colorScheme:ie("preserve",ae),themeCategorical:ie("preserve",ae),themeDiverging:ie("preserve",ae),themeSemantic:ie("preserve",ae),themeSequential:ie("preserve",ae),decay:ie("preserve",ae),pulse:ie("preserve",ae),layoutSelection:ie("preserve",ae),annotations:ie("preserve",ce),autoPlaceAnnotations:ie("preserve",ce),clock:ie("preserve",le),transition:ie("preserve",le),introAnimation:ie("preserve",le),onLayoutError:ie("preserve",le)},he=ie("preserve",re),de=class{constructor(){this.tracker=new $}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},ee)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},ne):this.recordNoop("restyle")}recordConfig(t,e={}){const n=function(t){let e="preserve";const n=new Set;for(const i of t){const t=ue[i]??he;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)n.add(e)}return{retainedData:e,invalidations:n}}(t),i=new Set(n.invalidations);return e.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:t},i)}};import{geoDistance as pe,geoGraticule as fe,geoInterpolate as me}from"d3-geo";function ge(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var ye=class t{constructor(t){this.updateResults=new de,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(t){return{...t,fitPadding:ge(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??pt()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),n=this.timestampBuffer?.toArray()??[],i=e.slice(-t),r=n.slice(-i.length),s=this.currentTime();this.pointBuffer=new o(t),this.timestampBuffer=new o(t),i.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??s)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:ge(t.fitPadding)}:t}(t),n=this.config,i=this.getConfiguredWindowSize(),o=Object.keys(e).filter(t=>e[t]!==n[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==i;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],r=n.slice(-e),s=i.slice(-r.length),a=this.currentTime();this.pointBuffer=new o(e),this.timestampBuffer=new o(e),r.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(s[e]??a)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();l(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const n of t)l(this.pointBuffer,n,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]),o=[];return this.lineData=this.lineData.filter(t=>!i.has(n(t)+"")||(o.push(t),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(n(t)+"");r(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!i.has(n(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(t){const e=this._customRestyle;if(e){for(const n of this.scene){const i=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...i,...o}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,n=this.projection,i=this.geoPath,o=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return Ht();if("string"==typeof t){const e=Xt[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),Ht())}if("object"==typeof t&&"type"in t){const e=Xt[t.type],n=e?e():Ht();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=Ot(this.projection),this.fitProjection(t),this.geoPath=Ot(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(t,e)=>l([t,e]),invertedPoint:(t,e)=>l.invert?l.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=i,this.scales=o,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,i=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,n=this.config,i=[...this.areas],o=Yt(n.xAccessor,"lon"),r=Yt(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[o(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=Ut(n.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[o(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==i.length){if(n.projectionExtent){const[[i,o],[r,s]]=n.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,o],[i,s],[r,s],[r,o],[i,o]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const i=n.fitPadding??0,o=Math.min(t.width,t.height);e.scale(o/2-o*i),e.translate([t.width/2,t.height/2])}else{const o=n.fitPadding??0,r=t.width*o,s=t.height*o;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:i})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;if(!n)return;const i=this.geoPath,o=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=Ot(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;if(!n)return;const i=this.geoPath,o=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Ot(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;if(!n||!n.rotate)return;const i=this.geoPath,o=this.scales,r=[...n.rotate()];n.rotate(t),this.geoPath=Ot(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(r),this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,n=0;for(const t of this.scene)"point"===t.type&&(n++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const i=Array(n);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=Wt().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,n=this.projection,i=this.geoPath;if(e.customLayout&&this.scales){const n=e.layoutMargin??{top:0,right:0,bottom:0,left:0},i=F(e.colorScheme,e.themeCategorical,X),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:n,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...i]},resolveColor:W(i,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(o)}catch(t){const n=null!==this.lastCustomLayoutResult,i=A("geo",t,n,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return N({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:t,projection:e,path:n,areas:i,points:o,lines:r,layout:s}){const a=Yt(t.xAccessor,"lon"),c=Yt(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,i=fe();e.step&&i.step(e.step);const o=n(i())||"";o&&l.push({type:"geoarea",pathData:o,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of i){const i=n(e);if(!i)continue;const o=n.centroid(e),r=n.bounds(e),s=n.area(e);l.push({type:"geoarea",pathData:i,centroid:o,bounds:r,screenArea:s,style:Qt(t.areaStyle,e,u),datum:e,interactive:!0})}const p=Ut(t.lineDataAccessor);for(const n of r){const i=p(n);if(!i||2>i.length)continue;let o=[];if("geo"===t.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[a(i[e]),c(i[e])];for(let n=0;t.length-1>n;n++){const i=t[n],r=t[n+1],s=pe(i,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=me(i,r);for(let t=0;a>=t;t++){if(n>0&&0===t)continue;const i=e(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const n=i[t],r=e([a(n),c(n)]);null!=r&&o.push(r)}if(2>o.length)continue;const r=Qt(t.lineStyle,n,h),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>o.length||"arc"!==t.flowStyle?2!==i.length||2>o.length||"offset"!==t.flowStyle||(o="geo"===t.lineType?Jt(o,u):Kt(o[0],o[o.length-1],0,0,u)):o=$t(o[0],o[o.length-1]);const d=Vt(o,s.width);if(d.length>1)for(const t of d)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:n});else l.push({type:"line",path:2>o.length&&d[0]||o,style:r,datum:n})}const f=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,m=e.clipAngle?e.clipAngle()??0:0,g=m>0?m*Math.PI/180:null,y=e.rotate?e.rotate():[0,0,0],v="function"==typeof e.center?e.center():[0,0],b=[(v[0]??0)-y[0],(v[1]??0)-y[1]];for(const n of o){const i=a(n),o=c(n);if(null!=g&&pe([i,o],b)>g)continue;const r=e([i,o]);if(!r)continue;const s=t.pointStyle?t.pointStyle(n):{...d},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:n,pointId:f?f(n)+"":void 0};l.push(u)}return l}({config:e,projection:n,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const n=function(t,e,n,i){const o=t.filter(t=>"point"===t.type);if(2>o.length)return null;const r=e.strength??1,s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,a="strip"===e.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,l="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],u=o.find(t=>t.datum&&c(t.datum)+""==e.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const h=o.map(t=>t.datum?Number(l(t.datum)):NaN).filter(t=>isFinite(t)&&t>=0),d=At(h,1);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let e=t.length-1;e>=0;e--){const n=t[e];"geoarea"===n.type&&n.interactive&&t.splice(e,1)}const p="strip"===a?function(t,e,n,i,o){const r=Math.max(3,Math.min(8,.35*o.height)),s=Math.max(1,o.width-2*r),a=o.height/2,c=te().domain([0,i]).range([0,s]);e.x=r,e.y=a;const l=[];for(const o of t){if(o===e)continue;if(!o.datum){o.x=r,o.y=a;continue}const t=Number(n(o.datum)),s=r+(isFinite(t)&&t>=0&&i>0?c(t):0);o.x=s,o.y=a,l.push({node:o,x:s})}l.sort((t,e)=>t.x-e.x);const u=Math.max(0,Math.min(o.height/2-1,6));let h=0;for(;l.length>h;){let t=h+1;for(;l.length>t&&3>Math.abs(l[t].x-l[h].x);)t++;const e=t-h;if(e>1&&u>0)for(let t=0;e>t;t++)l[h+t].node.y=a+(t-(e-1)/2)*Math.min(2.5,2*u/Math.max(1,e-1));h=t}return{cx:r,cy:a,maxCost:i,availableRadius:s,layout:"strip"}}(o,u,l,d,n):function(t,e,n,i,o,r){const s=e.x,a=e.y,c=r.width/2,l=r.height/2,u=Math.min(r.width,r.height)/2,h=te().domain([0,i]).range([0,u]);for(const r of t){if(r===e)continue;if(!r.datum)continue;const t=r.x,u=r.y,d=Math.atan2(u-a,t-s),p=Math.hypot(t-s,u-a),f=Number(n(r.datum)),m=isFinite(f)&&f>=0?i>0?h(f):0:p,g=c+Math.cos(d)*m,y=l+Math.sin(d)*m;r.x=t+(g-t)*o,r.y=u+(y-u)*o}return e.x=s+(c-s)*o,e.y=a+(l-a)*o,{cx:e.x,cy:e.y,maxCost:i,availableRadius:u,layout:"radial"}}(o,u,l,d,s,n),f=t.filter(t=>"line"===t.type);if(f.length>0){const t=new Map;for(const e of o)null!=e.pointId&&t.set(e.pointId+"",[e.x,e.y]);for(const n of f){const i=n.datum?.source,o=n.datum?.target;if(null!=i&&null!=o){const r=t.get(i+""),s=t.get(o+"");if(r&&s)if("fractional"===e.lineMode&&n.path.length>2){const t=n.path[0],e=n.path[n.path.length-1],i=[r[0]-t[0],r[1]-t[1]],o=[s[0]-e[0],s[1]-e[1]],a=[0];for(let t=1;n.path.length>t;t++)a.push(a[t-1]+Math.hypot(n.path[t][0]-n.path[t-1][0],n.path[t][1]-n.path[t-1][1]));const c=a[a.length-1];n.path=n.path.map((t,e)=>{const r=c>0?a[e]/c:e/(n.path.length-1);return[t[0]+i[0]*(1-r)+o[0]*r,t[1]+i[1]*(1-r)+o[1]*r]})}else n.path=[r,s]}}}return p}(this.scene,t,e,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let i=0;n.length>i;i++){const o=R(t,i,e);n[i]._decayOpacity=o,n[i].style={...n[i].style,opacity:o}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const n=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray(),o=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let a=!1;for(let c=0;n.length>c&&i.length>c;c++){const l=s(e,i[c],t);a=h(n[c],l,o,r)||a}return a}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&a(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const n=new Map;for(const e of t)"point"===e.type&&e.pointId&&n.set(e.pointId,[e.x,e.y]);const i=this.scene.filter(t=>"point"===t.type);let o=!1;for(const t of i)if(t.pointId){const e=n.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(o=!0))}for(const t of i)t.pointId&&!n.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=nt(t,this.activeTransition),n=et(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ht(t.x,t._targetX,n),t.y=ht(e,t._targetY,n)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*n})}if(e>=1){for(const t of i)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};ye.QUADTREE_THRESHOLD=500;var ve=ye;function be(t,e,n,i,o,r,s=0,a=i){if(r){const t=L(r,e,n,i,s);if(t)return t}else{let o=null,r=i;for(const s of t){if("point"!==s.type)continue;const t=s.x-e,a=s.y-n,c=Math.sqrt(t*t+a*a);C(s.r,i)>=c&&r>c&&(o=s,r=c)}if(o)return{node:o,distance:r}}let c=null,l=i;for(const o of t){if("glyph"!==o.type)continue;if(null==o.datum)continue;const t=Lt(o.glyph,o.size),r=o.x+t.centerDx-e,s=o.y+t.centerDy-n,a=Math.sqrt(r*r+s*s);C(t.radius,i)>=a&&l>a&&(c=o,l=a)}if(c)return{node:c,distance:l};for(let i=t.length-1;i>=0;i--){const r=t[i];if("geoarea"!==r.type)continue;const s=r;if(!1===s.interactive)continue;const[[a,c],[l,u]]=s.bounds;if(!(a>e||e>l||c>n||n>u)&&(s._cachedPath2D||(s._cachedPath2D=new Path2D(s.pathData)),o.isPointInPath(s._cachedPath2D,e,n)))return{node:s,distance:0}}let u=null,h=a;for(const i of t){if("line"!==i.type)continue;const t=i,{path:o}=t,r=Math.max((t.style.strokeWidth||2)+4,5,a);for(let i=0;o.length-1>i;i++){const[s,a]=o[i],[c,l]=o[i+1],d=we(e,n,s,a,c,l);r>=d&&h>d&&(u=t,h=d)}}return u?{node:u,distance:h}:null}function we(t,e,n,i,o,r){const s=o-n,a=r-i,c=s*s+a*a;if(0===c)return Math.sqrt((t-n)**2+(e-i)**2);let l=((t-n)*s+(e-i)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((t-(n+l*s))**2+(e-(i+l*a))**2)}b(ve);import{useMemo as Pe,useRef as xe}from"react";import{jsx as Re,jsxs as Ae}from"react/jsx-runtime";function Se(t){const{width:e,height:n,totalWidth:i,totalHeight:o,margin:r,showAxes:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:p,legendLayout:f,foregroundGraphics:m,annotations:g,onAnnotationActivate:y,onObservation:v,chartId:b,chartType:w,autoPlaceAnnotations:P,svgAnnotationRules:x,pointNodes:R,geoProjection:A}=t,L=wt({onAnnotationActivate:y,onObservation:v,chartId:b,chartType:w}),k=xe([g?.length??0,new Map]),C=g?.length??0;k.current[0]!==C&&(k.current=[C,new Map]);const D=Pe(()=>{if(!g||0===g.length)return null;const t=S(g),i=A?t.map(t=>{if(!Array.isArray(t.coordinates)||2>t.coordinates.length)return t;const e=A(Number(t.coordinates[0]),Number(t.coordinates[1]));return e?{...t,x:e[0],y:e[1]}:t}):t,o={scales:{x:t=>Number(t),y:t=>Number(t)},timeAxis:"x",width:e,height:n,frameType:"xy",pointNodes:R,stickyPositionCache:k.current[1]},r=P?J({annotations:i,context:o,..."object"==typeof P?P:{}}):i;return gt(r,it("xy",L),x,o)},[g,P,x,e,n,R,L,A]);return s||a||c||m||D&&D.length>0?Ae("svg",{role:"img",width:i,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Re("title",{children:"string"==typeof a?a:"XY Chart"}),Re("desc",{children:"string"==typeof a?a+" (XY data visualization)":"XY data visualization"}),Ae("g",{transform:"translate("+r.left+","+r.top+")",children:[D,m]}),a&&"string"==typeof a?Re("text",{x:i/2,y:V,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?Re("foreignObject",{x:0,y:0,width:i,height:r.top,children:a}):null,yt({legend:c,totalWidth:i,totalHeight:o,margin:r,legendPosition:p,title:a,legendLayout:f,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}):null}import{zoom as Le,zoomIdentity as ke}from"d3-zoom";import{select as Ce}from"d3-selection";function De([t,e,n]){const i=1<<n;return[t-Math.floor(t/i)*i,e,n]}function je(t,e,n,i,o){return"function"==typeof t?t(e,n,i,o):t.replace("{z}",e+"").replace("{x}",n+"").replace("{y}",i+"").replace("{r}",o>1?"@2x":"")}var Me=class{constructor(t=256){this.cache=new Map,this.limit=t}get(t){const e=this.cache.get(t);return e&&(e.lastUsed=performance.now()),e}set(t,e){this.cache.set(t,e),this.cache.size>this.limit&&this.evict()}evict(){for(;this.cache.size>this.limit;){let t,e=1/0;for(const[n,i]of this.cache)e>i.lastUsed&&(e=i.lastUsed,t=n);if(!t)break;{const e=this.cache.get(t);e&&(e.img.onload=null,e.img.onerror=null,e.img.src=""),this.cache.delete(t)}}}clear(){for(const t of this.cache.values())t.img.onload=null,t.img.onerror=null,t.img.src="";this.cache.clear()}};var Te=class{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,lineIndex:0,active:!1,x:0,y:0}}spawn(t,e=Math.random){for(let n=0;this.capacity>n;n++){const i=this.particles[n];if(!i.active)return i.active=!0,i.t=0,i.offset=.6*(e()-.5),i.lineIndex=t,i.x=0,i.y=0,i}return null}step(t,e,n,i){for(let o=0;this.capacity>o;o++){const r=this.particles[o];if(!r.active)continue;const s=n[r.lineIndex];if(!s||2>s.length){r.active=!1;continue}if(r.t+=t*e,r.t>=1){r.active=!1;continue}const a=Be(s),c=_e(s,r.t*a),l=(i[r.lineIndex]||2)/2;r.x=c.x+c.nx*r.offset*l*2,r.y=c.y+c.ny*r.offset*l*2}}countForLine(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].lineIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}};function Be(t){let e=0;for(let n=1;t.length>n;n++){const i=t[n][0]-t[n-1][0],o=t[n][1]-t[n-1][1];e+=Math.sqrt(i*i+o*o)}return e}function _e(t,e){let n=0;for(let i=1;t.length>i;i++){const o=t[i][0]-t[i-1][0],r=t[i][1]-t[i-1][1],s=Math.sqrt(o*o+r*r);if(n+s>=e||i===t.length-1){const a=s>0?(e-n)/s:0,c=s>.001?s:1;return{x:t[i-1][0]+o*a,y:t[i-1][1]+r*a,nx:-r/c,ny:o/c}}n+=s}const i=t[t.length-1];return{x:i[0],y:i[1],nx:0,ny:0}}function Ie(t){if(!t)return;const e=[];for(const n of t)if("point"===n.type)e.push(n);else if("glyph"===n.type){const t=n,i=Lt(t.glyph,t.size);e.push({pointId:t.pointId,x:t.x+i.centerDx,y:t.y+i.centerDy,r:i.radius})}return e}import{jsx as Ee,jsxs as Ne}from"react/jsx-runtime";function Oe({data:t}){if(!t)return null;if(t.properties)return Ee("div",{className:"semiotic-tooltip",style:ot,children:Ee("div",{style:{fontWeight:600},children:t.properties.name||t.properties.NAME||t.properties.id||"Feature"})});const e=null!=t.data?t.data:t;if(!e||"object"!=typeof e)return null;const n=bt(e),i=null!=n.title?n.title+"":null;return null==i&&0===n.entries.length?null:Ne("div",{className:"semiotic-tooltip",style:ot,children:[null!=i&&Ee("div",{style:{fontWeight:600,marginBottom:n.entries.length?2:0},children:i}),n.entries.map(t=>Ne("div",{children:[Ne("span",{style:{opacity:.7},children:[t.key,": "]}),Ee("span",{style:{fontWeight:600},children:k(t.value)})]},t.key))]})}Oe.ownsChrome=!0;var We={top:10,right:10,bottom:10,left:10},Fe=null;function He(){if(null!==Fe)return Fe;if("undefined"==typeof window)return!1;const t="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,e="undefined"!=typeof navigator&&"number"==typeof navigator.hardwareConcurrency&&4>=navigator.hardwareConcurrency,n="undefined"!=typeof navigator&&"number"==typeof navigator.deviceMemory&&4>=navigator.deviceMemory;return Fe=t||e||n}function ze(){return He()?12:30}var Ge={width:28,height:28,border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,background:"rgba(255,255,255,0.9)",color:"#333",fontSize:16,fontWeight:600,lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,boxShadow:"0 1px 3px rgba(0,0,0,0.1)"};function qe(t){return"string"==typeof t?t:"object"==typeof t&&t&&"type"in t?t.type:null}function Ze(t){return t?t.getContext("2d"):null}import{jsx as Xe,jsxs as Ye}from"react/jsx-runtime";var Ue=Nt(Et(function(t,e){const{projection:o,projectionExtent:r,fitPadding:s,projectionTransform:a,areas:l,points:h,lines:b,customLayout:w,layoutConfig:P,layoutSelection:R,onLayoutError:A,xAccessor:S,yAccessor:L,lineDataAccessor:k,pointIdAccessor:C,lineIdAccessor:N,lineType:W="geo",flowStyle:F="basic",graticule:X,zoomable:V,zoomExtent:$,onZoom:J,dragRotate:et,showParticles:nt,particleStyle:it,tileURL:ot,tileAttribution:ht,tileCacheSize:dt,size:pt,width:gt,height:yt,responsiveWidth:bt,responsiveHeight:wt,margin:At,className:Lt,background:kt,windowSize:Et=500,renderMode:Nt,areaStyle:Ot,pointStyle:Wt,lineStyle:Ft,colorScheme:Ht,enableHover:zt=!0,hoverAnnotation:Gt,tooltipContent:qt,allowTooltipOverflow:Zt=!1,customClickBehavior:Xt,customHoverBehavior:Yt,onObservation:Ut,annotationObservationCallback:Qt,chartId:Vt,annotations:$t,onAnnotationActivate:Jt,autoPlaceAnnotations:Kt,svgAnnotationRules:te,decay:ee,pulse:ne,transition:ie,animate:oe,staleness:re,frameScheduler:se,clock:ae,random:ce,seed:le,paused:ue=!1,suspendWhenHidden:he=!0,backgroundGraphics:de,foregroundGraphics:pe,title:fe,legend:me,legendPosition:ge,legendLayout:ye,legendHoverBehavior:we,legendClickBehavior:Pe,legendHighlightedCategory:xe,legendIsolatedCategories:Re,legendCategoryAccessor:Ae,onCategoriesChange:Be,showAxes:_e,accessibleTable:Ee=!0,description:Ne,summary:Fe}=t,{customHoverBehavior:Ue,customClickBehavior:Qe,hasClickBehavior:Ve}=f({customHoverBehavior:Yt,customClickBehavior:Xt,onObservation:Ut,chartId:Vt,chartType:"StreamGeoFrame"}),$e=pt||[gt||600,yt||400],Je=jt(!0),Ke=Pt({sizeProp:$e,responsiveWidth:bt,responsiveHeight:wt,userMargin:At,marginDefault:We,title:fe,legend:me,legendPosition:ge,foregroundGraphics:pe,backgroundGraphics:de,animate:oe,transitionProp:ie,frameScheduler:se,clock:ae,random:ce,seed:le,paused:ue,suspendWhenHidden:he,themeDirtyRef:Je}),{reducedMotionRef:tn,responsiveRef:en,size:nn,margin:on,adjustedWidth:rn,adjustedHeight:sn,resolvedForeground:an,resolvedBackground:cn,transition:ln,introEnabled:un,tableId:hn,frameRuntime:dn,rafRef:pn,renderFnRef:fn,scheduleRender:mn,currentTheme:gn}=Ke,yn=Ct(),vn=Dt(),bn=Bt(()=>Array.isArray(l)?rt(l):l,[l]),wn=Bt(()=>rt(h),[h]),Pn=Bt(()=>rt(b),[b]),xn=Bt(()=>null!=et?et:"orthographic"===qe(o),[et,o]),Rn=Bt(()=>({projection:o,projectionExtent:r,fitPadding:s,xAccessor:S,yAccessor:L,lineDataAccessor:k,lineType:W,flowStyle:F,areaStyle:Ot,pointStyle:Wt,lineStyle:Ft,colorScheme:Ht,themeSemantic:St(gn),themeSequential:gn?.colors?.sequential,themeDiverging:gn?.colors?.diverging,themeCategorical:gn?.colors?.categorical,graticule:X,projectionTransform:a,windowSize:Et,clock:dn.now,decay:ee,pulse:ne,transition:ln,introAnimation:un,annotations:$t,pointIdAccessor:C,lineIdAccessor:N,customLayout:w,layoutConfig:P,onLayoutError:A,layoutMargin:on}),[o,r,s,S,L,k,W,F,Ot,Wt,Ft,Ht,gn,X,a,Et,dn.now,ee,ne,ln,un,$t,C,N,w,P,A,on]),An=I(Rn),Sn=jt(null);Sn.current||(Sn.current=new ve(An));const Ln=jt(null),kn=jt(null),Cn=jt(null);ot&&!Cn.current&&(Cn.current=new Me(dt||256));const Dn=jt($t),jn=jt(null),Mn=jt(ke),Tn=jt(!1),Bn=jt(null),_n=_t(t=>{Bn.current=t,en&&"object"==typeof en&&(en.current=t)},[en]),In=jt(null),En=jt(null),Nn=jt(null),On=jt(0);if(nt&&!Nn.current){const t=it?.maxPerLine??ze();Nn.current=new Te(50*t)}const Wn=jt(null),Fn=jt(null),Hn=jt(!1),zn=jt(!1),Gn=Rt("StreamGeoFrame"),qn=jt(void 0),[Zn,Xn]=Mt(null),[,Yn]=Mt(0),Un=jt(0),[Qn,Vn]=Mt(!1),$n=p(Sn,Ae,Be,t=>t.getPoints());B(Sn,An,Je,mn),_(Sn,R,Je,mn),Tt(()=>{const t=Sn.current;t&&(bn&&t.setAreas(bn),h&&t.setPoints(wn),b&&t.setLines(Pn),Je.current=!0,mn())},[bn,h,wn,b,Pn,mn]);const Jn=_t(t=>{null!=t&&"object"==typeof t&&(Sn.current?.pushPoint(t),Je.current=!0,mn())},[mn]),Kn=_t(t=>{const e=rt(t);0!==e.length&&(Sn.current?.pushMany(e),Je.current=!0,mn())},[mn]),ti=_t(t=>{null!=t&&"object"==typeof t&&(Sn.current?.pushLine(t),Je.current=!0,mn())},[mn]),ei=_t(t=>{const e=rt(t);0!==e.length&&(Sn.current?.pushManyLines(e),Je.current=!0,mn())},[mn]),ni=_t(()=>{Sn.current?.clear(),Je.current=!0,mn()},[mn]);It(e,()=>({push:Jn,pushMany:Kn,removePoint:t=>{const e=Sn.current?.removePoint(t)??[];return e.length>0&&(Je.current=!0,mn()),e},pushLine:ti,pushManyLines:ei,removeLine:t=>{const e=Sn.current?.removeLine(t)??[];return e.length>0&&(Je.current=!0,mn()),e},getLines:()=>Sn.current?.getLines()??[],clear:ni,getProjection:()=>Sn.current?.scales?.projection??null,getGeoPath:()=>Sn.current?.scales?.geoPath??null,getCartogramLayout:()=>Sn.current?.cartogramLayout??null,getCustomLayout:()=>Sn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Sn.current?.lastCustomLayoutFailure??null,getZoom:()=>Mn.current.k,resetZoom:()=>{const t=Bn.current;t&&jn.current&&Ce(t).call(jn.current.transform,ke)},getData:()=>Sn.current?.getPoints()??[]}),[Jn,Kn,ti,ei,ni,mn]);const{hoverHandlerRef:ii,onPointerMove:oi,onPointerLeave:ri}=Ke,{canvasRef:si,interactionCanvasRef:ai}=xt(Ke,{hydrated:yn,wasHydratingFromSSR:vn,storeRef:Sn,dirtyRef:Je,cleanup:()=>Cn.current?.clear(),canvasPaintDependencies:[rn,sn,kt,de,Nt,mn]});Tt(()=>{ii.current=t=>{if(!zt)return;const e=Sn.current;if(!e||!e.scene.length)return;const n=si.current;if(!n)return;const i=n.getBoundingClientRect(),o=t.clientX-i.left-on.left,r=t.clientY-i.top-on.top;if(0>o||o>rn||0>r||r>sn)return Wn.current=null,Fn.current=null,Xn(null),Ue?.(null),void mn();kn.current||(kn.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const s=Ze(kn.current);if(!s)return;const a=ct(30,t.pointerType),c=ct(6,t.pointerType),l=be(e.scene,o,r,a,s,e.quadtree,e.maxPointRadius,c);if(l){const t=l.node,e=t.datum,n=Array.isArray(e)?null:e?.properties?e:e?.data||e;let i,s;"point"===t.type?(i=t.x,s=t.y):"geoarea"===t.type?(i=t.centroid[0],s=t.centroid[1]):(i=o,s=r);const a={...n,...n?.properties||{},data:n,properties:n?.properties,__semioticHoverData:!0,x:i,y:s};Wn.current=a,Fn.current=t,Xn(a),Ue?.(a),mn()}else Wn.current&&(Wn.current=null,Fn.current=null,Xn(null),Ue?.(null),mn())}},[zt,rn,sn,on,Ue,mn,ii,si]),Ke.hoverLeaveRef.current=()=>{Wn.current=null,Fn.current=null,Xn(null),Ue?.(null),mn()};const ci=_t(t=>{if(lt(t.target))return;if(!Qe)return;const e=Sn.current;if(!e||!e.scene.length)return void Qe(null);const n=t.currentTarget.getBoundingClientRect(),i=t.clientX-n.left-on.left,o=t.clientY-n.top-on.top;if(0>i||i>rn||0>o||o>sn)return void Qe(null);kn.current||(kn.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const r=Ze(kn.current);if(!r)return void Qe(null);const s=ct(30,qn.current),a=ct(6,qn.current),c=be(e.scene,i,o,s,r,e.quadtree,e.maxPointRadius,a);if(c){const t=c.node.datum,e=Array.isArray(t)?null:t?.properties?t:t?.data||t,n=e?.properties?{...e,...e.properties}:e;return void Qe({...n,data:e,properties:e?.properties,__semioticHoverData:!0,x:i,y:o,time:i,value:o},{type:"activate",inputType:ft(qn.current)})}Qe(null)},[sn,rn,Qe,on]),{kbFocusIndexRef:li,focusedNavPointRef:ui,onKeyDown:hi}=d({storeRef:Sn,hoverRef:Wn,hoveredNodeRef:Fn,setHoverPoint:Xn,customHoverBehavior:Ue,customClickBehavior:Qe,scheduleRender:mn}),di=_t(t=>{qn.current=t.pointerType,li.current=-1,ui.current=null,oi(t)},[ui,li,oi]),pi=_t(t=>{qn.current=t.pointerType},[]);fn.current=()=>{if(pn.current=null,!dn.isActive)return;const t=si.current,e=Sn.current;if(!t||!e)return;const o=dn.now();let r=!1;const s=En.current;let a=!1;s&&(En.current=null,e.applyRotation(s,{width:rn,height:sn}),a=!0);const l=e.advanceTransition(tn.current?o+1e6:o),h=!tn.current&&l,d=Gn.current.beforeCompute(e.getLastUpdateResult(),h);let p=!1;if(Je.current&&!l){const n={width:rn,height:sn},i=e.hasProjection(),o=xn&&i?e.getRotation():null;e.computeScene(n);const r=Mn.current,s=1!==r.k||0!==r.x||0!==r.y;xn&&o?s?(e.setRotation(o),e.applyZoomScale(r.k,n)):e.applyRotation(o,n):s&&e.applyZoomTransform(r,n),Je.current=!1,p=!0,t.setAttribute("aria-label",tt(e.scene,"Geographic chart")),$n()}Gn.current.afterCompute(d,p,!1);const f=at(),v=nt&&!tn.current&&!!Nn.current,b=e.consumeStylePaintPending(),w=u(e,o,p,zn),P=m({dirtyOrRebuilt:p,transitioning:h,continuous:v,liveEncoding:w.changed,forced:a||b});if(ot&&Cn.current){const t=Ln.current;if(t&&e.scales?.projection){const n=mt(t,nn,on,f);if(n){n.clearRect(-on.left,-on.top,nn[0],nn[1]),n.save(),n.beginPath(),n.rect(0,0,rn,sn),n.clip();const t=function(t,e){const{tileURL:n,projection:i,width:o,height:r,tileCache:s,onTileLoad:a}=e,c=i.scale(),l=i.translate(),u=function(t){const{size:e,scale:n,translate:i,clampX:o=!0,clampY:r=!0}=t,s=Math.max(Math.log(n)/Math.LN2-8,0),a=Math.round(s),c=1<<a,l=Math.pow(2,s-a+8),u=i[0]-n/2,h=i[1]-n/2,d=Math.max(o?0:-1/0,Math.floor((0-u)/l)),p=Math.min(o?c:1/0,Math.ceil((e[0]-u)/l)),f=Math.max(r?0:-1/0,Math.floor((0-h)/l)),m=Math.min(r?c:1/0,Math.ceil((e[1]-h)/l)),g=[];for(let t=f;m>t;++t)for(let e=d;p>e;++e)g.push([e,t,a]);return{tiles:g,translate:[u/l,h/l],scale:l}}({size:[o,r],scale:2*c*Math.PI,translate:l}),h=at();let d=!0;for(const e of u.tiles){const[i,o,r]=De(e),c=`${r}/${i}/${o}`;let l=s.get(c);if(!l){const t=new Image;t.crossOrigin="anonymous";const e={img:t,loaded:!1,key:c,lastUsed:performance.now()};s.set(c,e),t.onload=()=>{e.loaded=!0,a?.()},t.onerror=()=>{e.loaded=!0},t.src=je(n,r,i,o,h),l=e}if(!l.loaded){d=!1;continue}const p=u.scale;t.drawImage(l.img,(e[0]+u.translate[0])*p-.5,(e[1]+u.translate[1])*p-.5,p+1,p+1)}return d}(n,{tileURL:ot,projection:e.scales.projection,width:rn,height:sn,tileCache:Cn.current,onTileLoad:()=>mn()});n.restore(),t||(r=!0)}}}if(P){const i=mt(t,nn,on,f);if(!i)return;i.clearRect(-on.left,-on.top,nn[0],nn[1]),ot||y(i,{background:kt,hasBackgroundGraphics:!!de,width:rn,height:sn}),i.save(),i.beginPath(),i.rect(0,0,rn,sn),i.clip();const s=e.scene,a=e.scales,l={width:rn,height:sn};if(j({context:i,nodes:s,renderMode:Nt,pixelRatio:f,paintBuiltIn:t=>{!function(t,e){const n=e.filter(t=>"geoarea"===t.type);for(const e of n){if(!e.pathData)continue;e._cachedPath2D||(e._cachedPath2D=new Path2D(e.pathData));const n=e._cachedPath2D,i=K(t,e.style.fill)||"#e0e0e0";if("none"!==i&&(t.fillStyle=i,t.globalAlpha=(e._decayOpacity??1)*(e.style.fillOpacity??1),t.fill(n)),e.style.stroke&&"none"!==e.style.stroke){if(t.strokeStyle=vt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||.5,t.globalAlpha=e._decayOpacity??1,e.style.strokeDasharray){const n=e.style.strokeDasharray.split(",").map(Number);t.setLineDash(n)}else t.setLineDash([]);t.stroke(n)}M(t,e,n),t.globalAlpha=1,t.setLineDash([])}}(i,t),n(i,t,a,l),c(i,t,a,l),D(i,t,a,l)}}),v&&Nn.current){const t=Nn.current,e=s.filter(t=>"line"===t.type);if(e.length>0){const n=it||{},s=.3*(n.speedMultiplier??1),a=n.maxPerLine??ze(),c=n.spawnRate??(He()?.06:.15),l=n.radius??2,u=n.opacity??.7,h=o/1e3,d=On.current>0?Math.min(h-On.current,.1):.016;On.current=h;const p=e.map(t=>t.path),f=e.map(t=>t.style.strokeWidth||2);for(let n=0;e.length>n;n++)dn.random()<c&&t.countForLine(n)<a&&t.spawn(n,dn.random);t.step(d,s,p,f),i.globalAlpha=u;for(let o=0;t.particles.length>o;o++){const r=t.particles[o];if(!r.active)continue;const s=e[r.lineIndex],a="function"==typeof n.color?n.color(s?.datum??{}):"source"!==n.color&&n.color?n.color:s?.style.stroke||"#fff";i.beginPath(),i.arc(r.x,r.y,l,0,2*Math.PI),i.fillStyle=a,i.fill()}i.globalAlpha=1,r=!0}}i.restore()}const x=Fn.current,R=!(!x||"geoarea"!==x.type&&"point"!==x.type),A=g(R,Hn.current),S=ai.current;if(S&&A){const t=mt(S,nn,on,f);if(t){if(t.clearRect(-on.left,-on.top,nn[0],nn[1]),x&&"geoarea"===x.type){const e=new Path2D(x.pathData);t.fillStyle="rgba(255, 255, 255, 0.3)",t.fill(e),t.strokeStyle="rgba(0, 0, 0, 0.5)",t.lineWidth=2,t.stroke(e)}if(x&&"point"===x.type){const e=x,n="object"==typeof Gt?Gt:void 0,o=n?.pointColor||i(x);t.beginPath(),t.arc(e.x,e.y,e.r+3,0,2*Math.PI),o?(t.save(),t.globalAlpha=.4,t.fillStyle=o,t.fill(),t.restore()):(t.fillStyle="rgba(255, 255, 255, 0.4)",t.fill()),t.strokeStyle=o||"rgba(0, 0, 0, 0.5)",t.lineWidth=2,t.stroke()}}Hn.current=R}const L=$t!==Dn.current;L&&(Dn.current=$t),(p||L||h&&$t&&$t.length>0)&&(p||L||o-Un.current>=33)&&(Yn(t=>t+1),Un.current=o),(h||null!=e.activeTransition||w.pending||r)&&mn()},E(re,Sn,Je,mn,Qn,Vn),Tt(()=>{if("production"!==process.env.NODE_ENV&&ot){const t=qe(o);t&&"mercator"!==t&&console.warn(`[StreamGeoFrame] tileURL is set but projection is "${t}". Raster tiles use Web Mercator and will not align with other projections.`)}},[ot,o]),Tt(()=>{const t=Bn.current;if(!V||!t)return jn.current&&t&&(Ce(t).on(".zoom",null),jn.current=null),void(t&&Ce(t).on("mousedown.rotate",null).on("touchstart.rotate",null));const[e,n]=$||[1,8],i={width:rn,height:sn};if(xn){let o=Mn.current.k;const r=t=>{o=Math.max(e,Math.min(n,t)),Mn.current=ke.scale(o);const r=Sn.current;r&&(r.applyZoomScale(o,i),Je.current=!1,mn(),r.scales?.projection&&J?.({projection:r.scales.projection,zoom:r.currentZoom}))};jn.current={scaleBy:(t,e)=>r(o*e),transform:(t,e)=>r(e?.k??1)};const s=t=>{t.preventDefault(),r(o*(0>t.deltaY?1.1:1/1.1))},a=t=>{const e=t.target;e&&(e.closest("button")||e.closest(".stream-geo-zoom-controls"))||(t.preventDefault(),r(1.5*o))};t.addEventListener("wheel",s,{passive:!1}),t.addEventListener("dblclick",a);const c=.4,l=e=>{if(0!==e.button)return;const n=e.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const i=Sn.current;if(!i)return;const o=i.getRotation();In.current={x:e.clientX,y:e.clientY,rotation:[...o]},t.setPointerCapture(e.pointerId),e.preventDefault()},u=t=>{const e=In.current;e&&(En.current=[e.rotation[0]+(t.clientX-e.x)*c,Math.max(-90,Math.min(90,e.rotation[1]-(t.clientY-e.y)*c)),e.rotation[2]],mn())},h=e=>{if(!In.current)return;In.current=null,t.releasePointerCapture(e.pointerId);const n=En.current;if(n){En.current=null;const t=Sn.current;t&&(t.applyRotation(n,i),mn())}const o=Sn.current;o?.scales?.projection&&J?.({projection:o.scales.projection,zoom:o.currentZoom})};return t.addEventListener("pointerdown",l),t.addEventListener("pointermove",u),t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h),()=>{t.removeEventListener("wheel",s),t.removeEventListener("dblclick",a),t.removeEventListener("pointerdown",l),t.removeEventListener("pointermove",u),t.removeEventListener("pointerup",h),t.removeEventListener("pointercancel",h),jn.current=null}}const o=Le().scaleExtent([e,n]).extent([[0,0],[nn[0],nn[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",t=>{const e=t.transform;Mn.current=e,Tn.current=!0;const n=Sn.current;n&&(n.applyZoomTransform(e,i),Je.current=!1,mn())}).on("end",t=>{Mn.current=t.transform,Tn.current=!1;const e=Sn.current;e?.scales?.projection&&J?.({projection:e.scales.projection,zoom:e.currentZoom})});return jn.current=o,Ce(t).call(o),()=>{Ce(t).on(".zoom",null)}},[V,$,xn,nn,rn,sn,on,J,mn]);const fi=zt&&!1!==Gt,mi=fi&&Zn?qt?qt(Zn):Xe(Oe,{data:Zn}):null,gi=mi?Xe(q,{x:Zn.x,y:Zn.y,containerWidth:rn,containerHeight:sn,margin:on,className:"stream-frame-tooltip",zIndex:10,children:mi}):null;if(ut||!yn&&vn){const t=Sn.current;t&&(bn||h||b)&&(bn&&t.setAreas(bn),h&&t.setPoints(wn),b&&t.setLines(Pn),t.computeScene({width:rn,height:sn}));const e=t?.scene??[];return Ye("div",{ref:_n,className:"stream-geo-frame"+(Lt?" "+Lt:""),role:"img","aria-label":Ne||("string"==typeof fe?fe:"Geographic chart"),style:{position:"relative",width:bt?"100%":nn[0],height:wt?"100%":nn[1]},children:[Xe(U,{summary:Fe}),Ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:nn[0],height:nn[1],style:{position:"absolute",left:0,top:0},children:[Xe("g",{transform:`translate(${on.left},${on.top})`,children:cn}),Ye("g",{transform:`translate(${on.left},${on.top})`,children:[kt&&Xe("rect",{x:0,y:0,width:rn,height:sn,fill:kt}),e.map((t,e)=>T({node:t,index:e,renderMode:Nt,fallback:()=>st(t,e)}))]})]}),Xe(Se,{width:rn,height:sn,totalWidth:nn[0],totalHeight:nn[1],margin:on,showAxes:!1,title:fe,legend:me,legendPosition:ge,legendLayout:ye,legendHoverBehavior:we,legendClickBehavior:Pe,legendHighlightedCategory:xe,legendIsolatedCategories:Re,foregroundGraphics:x(an,O(Sn.current?.customLayoutOverlays,R??null)),annotations:$t,onAnnotationActivate:Jt,onObservation:Qt??Ut,chartId:Vt,chartType:"StreamGeoFrame",autoPlaceAnnotations:Kt,svgAnnotationRules:te,pointNodes:Ie(e),geoProjection:Sn.current?.scales?.projectedPoint})]})}return Ye("div",{ref:_n,className:"stream-geo-frame"+(Lt?" "+Lt:""),role:"group","aria-label":Ne||("string"==typeof fe?fe:"Geographic chart"),tabIndex:0,style:{position:"relative",width:bt?"100%":nn[0],height:wt?"100%":nn[1],overflow:Zt?"visible":"hidden",...V?{touchAction:"none"}:{}},onKeyDown:hi,children:["production"!==process.env.NODE_ENV&&Sn.current&&Xe(Y,{store:Sn.current,diagnostics:Gn.current}),Ee&&Xe(Q,{tableId:hn}),Ee&&Xe(H,{scene:Sn.current?.scene??[],chartType:"Geographic chart",tableId:hn,chartTitle:"string"==typeof fe?fe:void 0}),Xe(U,{summary:Fe}),Xe(z,{hoverPoint:Zn}),Ye("div",{role:"img","aria-label":Ne||("string"==typeof fe?fe:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:fi?di:void 0,onPointerLeave:fi?ri:void 0,onPointerDown:fi||Ve?pi:void 0,onClick:Ve?ci:void 0,children:[Xe(G,{size:nn,margin:on,children:cn}),ot&&Xe("canvas",{ref:Ln,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Xe("canvas",{ref:si,"aria-label":tt(Sn.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),Xe("canvas",{ref:ai,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Xe(Se,{width:rn,height:sn,totalWidth:nn[0],totalHeight:nn[1],margin:on,showAxes:_e,title:fe,legend:me,legendPosition:ge,legendLayout:ye,legendHoverBehavior:we,legendClickBehavior:Pe,legendHighlightedCategory:xe,legendIsolatedCategories:Re,foregroundGraphics:x(an,O(Sn.current?.customLayoutOverlays,R??null)),annotations:$t,onAnnotationActivate:Jt,onObservation:Qt??Ut,chartId:Vt,chartType:"StreamGeoFrame",autoPlaceAnnotations:Kt,svgAnnotationRules:te,pointNodes:Ie(Sn.current?.scene),geoProjection:Sn.current?.scales?.projectedPoint}),re?.showBadge&&Xe(v,{isStale:Qn,position:re.badgePosition}),V&&Ye("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:on.bottom+8,left:on.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[Xe("button",{type:"button","aria-label":"Zoom in",onClick:t=>{t.stopPropagation();const e=Bn.current,n=jn.current;e&&n?.scaleBy&&n.scaleBy(Ce(e),1.5)},style:Ge,children:"+"}),Xe("button",{type:"button","aria-label":"Zoom out",onClick:t=>{t.stopPropagation();const e=Bn.current,n=jn.current;e&&n?.scaleBy&&n.scaleBy(Ce(e),1/1.5)},style:Ge,children:"−"})]}),ht&&Xe("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:on.bottom+2,right:on.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2},children:ht}),Xe(Z,{active:li.current>=0,hoverPoint:Zn,margin:on,size:nn,shape:ui.current?.shape,width:ui.current?.w,height:ui.current?.h,pathData:ui.current?.pathData}),gi]})]})}));Ue.displayName="StreamGeoFrame";var Qe=Ue;import{forwardRef as Ve,useMemo as $e}from"react";import{jsx as Je}from"react/jsx-runtime";var Ke=Ve(function(n,i){const{points:o,areas:r,lines:s,layout:a,layoutConfig:c,onLayoutError:l,projection:u="equirectangular",xAccessor:h="lon",yAccessor:d="lat",lineDataAccessor:p,colorBy:f,colorScheme:m,tooltip:g,annotations:y,margin:v,selection:b,linkedHover:x,onObservation:R,onClick:A,chartId:S,loading:L,loadingContent:k,emptyContent:C,className:D,frameProps:j={}}=n,{frameRef:M,resolved:T,normalizedMargin:B}=e({imperativeRef:i,imperativeVariant:"geo-points",margin:v,width:n.width,height:n.height,enableHover:n.enableHover,title:n.title,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable,mode:n.mode,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),_=$e(()=>rt(o),[o]),I=$e(()=>rt(r),[r]),E=$e(()=>rt(s),[s]),N=$e(()=>[..._,...E,...I],[_,E,I]),O=t({data:N,rawData:void 0!==o||void 0!==s||void 0!==r?N:void 0,colorBy:f,colorScheme:m,legendInteraction:void 0,selection:b,linkedHover:x,fallbackFields:"string"==typeof f?[f]:[],unwrapData:!1,onObservation:R,onClick:A,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"GeoCustomChart",chartId:S,showLegend:!1,userMargin:B,marginDefaults:T.marginDefaults,loading:L,loadingContent:k,emptyContent:C,width:T.width,height:T.height,hasTitle:!!T.title}),W=O.effectiveSelectionHook,F=$e(()=>W?.isActive?{isActive:!0,predicate:W.predicate}:null,[W?.isActive,W?.predicate]);if(O.earlyReturn)return O.earlyReturn;const{width:H,height:z,enableHover:G,title:q,description:Z,summary:X,accessibleTable:Y}=T,U=dt(g),Q={projection:u,...null!=o&&{points:_},...null!=r&&{areas:I},...null!=s&&{lines:E},xAccessor:h,yAccessor:d,...null!=p&&{lineDataAccessor:p},customLayout:a,layoutConfig:c,onLayoutError:l,layoutSelection:F,colorBy:f,colorScheme:m,size:[H,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:O.margin,enableHover:G,...w({title:q,description:Z,summary:X,accessibleTable:Y,className:D,animate:n.animate,autoPlaceAnnotations:n.autoPlaceAnnotations}),...!1===g?{tooltipContent:()=>null}:U?{tooltipContent:U}:{},...P({linkedHover:x,selection:b,onObservation:R,onClick:A,hoverHighlight:!1,mobileInteraction:O.mobileInteraction,customHoverBehavior:O.customHoverBehavior,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...y&&y.length>0&&{annotations:y},...j};return Je(kt,{componentName:"GeoCustomChart",width:H,height:z,children:Je(Qe,{ref:M,...Q})})});Ke.displayName="GeoCustomChart";export{Qe as StreamGeoFrame_default,Ke as GeoCustomChart};
@@ -1 +0,0 @@
1
- function e(e,t){if("function"==typeof t){const o=t(e);return Number.isFinite(o)&&o>0?Number(o):1}const o=e.datum;if(t&&o&&"object"==typeof o){const e=Number(o[t]);if(Number.isFinite(e)&&e>0)return e}const n=Number(o?.work??o?.reviewWork??o?.value);return Number.isFinite(n)&&n>0?n:1}function t(e,t){if("function"==typeof t){const o=t(e);if(null!=o&&(o+"").length>0)return o+""}else if(t){const o=n(e.datum,t),i=n(e,t),s=o??i;if(null!=s&&(s+"").length>0)return s+""}return e.id}function o(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const o=Math.max(0,Math.min(1,t))*(e.length-1),n=Math.floor(o);return e[n]+(e[Math.ceil(o)]-e[n])*(o-n)}function n(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(null==o||"object"!=typeof o)return;o=o[e]}return o}function i(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const o=n(e,t.property);return!("equals"in t&&!Object.is(o,t.equals)||"notEquals"in t&&Object.is(o,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(o,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(o,e)))}function s(n){const s=n.regionId,d=Math.max(0,n.unitsPerSecond),r=n.queueLayout??"lane",c=n.queueSlotSpacing??14,a=n.queueStiffness??.35,u=Number.isFinite(n.maxQueue)?Math.max(0,Math.floor(Number(n.maxQueue))):1/0,l=Math.max(.25,n.metricWindowSeconds??30),p=Math.max(1/60,n.snapshotIntervalSeconds??.25),f=n.releaseImpulse??{x:90,y:0},y=new Map,m=new Map,b=new Map,g=new Map,h=new Map,I=new Map,v=new Map,x=[];let k=0,M=new Map,A=new Map,q=0,w=0,S=0,j=null,O=0,W=0,R=0,F=0,z=0,N=0,B=0,C=0,D=0,P=0,Q=0,E=0,$=-1,H=!1;function K(e,t){const o=t(e);return!!o&&o.activeRegionIds.includes(s)}function L(){E+=1}function T(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:s,work:e.total,queuedAt:e.queuedAt}}function U(e,t,o,i){const d={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return y.set(t.jobId,d),v.delete(e.id),I.set(e.id,t.jobId),W+=1,R+=t.work,L(),function(e,t,o){const i=T(t);n.onQueued?.(e,i),o.controls.recordObservation({type:"physics-capacity-queued",bodyId:e.id,datum:e.datum,x:e.x,y:e.y,regionId:s,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,queueDepth:y.size})}(e,d,o),d}function G(e){if(y.size>=u||0===m.size)return;const t=Array.from(m.values()).sort((e,t)=>e.sequence-t.sequence);for(const o of t){if(y.size>=u)break;const t=h.get(o.jobId);t&&b.has(o.jobId)?(m.delete(o.jobId),v.delete(o.bodyId),U(t,o,e,o.sequence)):m.delete(o.jobId)}}function J(){let e=0;for(const t of y.values())e+=t.remaining;return e}function V(){D=Math.max(D,y.size),P=Math.max(P,J())}function X(){const e=S-l,t=Math.max(0,Math.min(l,S-(j??S)));let o=0,n=0,i=0,s=0,r=0;for(const t of x){if(e>t.end)continue;o+=t.arrivals,n+=t.arrivalWork,i+=t.completions,s+=t.completedWork;const d=t.end-t.start;r+=d>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/d):t.processedWork}const c=t>0?n/t:0;return{seconds:t,arrivals:o,arrivalWork:n,completions:i,completedWork:s,processedWork:r,arrivalsPerSecond:t>0?o/t:0,throughputPerSecond:t>0?i/t:0,utilization:t>0&&d>0?Math.max(0,Math.min(1,r/(d*t))):0,pressure:d>0?c/d:0}}return{id:n.id??"capacity-queue:"+s,continuous:!1!==n.continuous,tick:o=>{const r=o.controls.readBodies(),c=new Map,a=new Map;for(const e of r){if(c.set(e.id,e),!K(e.id,o.getRegionState))continue;if(!i(e,n.bodyFilter))continue;const s=t(e,n.jobKey),d=a.get(s)??[];d.push(e),a.set(s,d)}const W=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!H){const e=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):W;S=Math.max(0,e-W),H=!0}const R=S,D=R+W;S=D,j=null==j?R:Math.min(j,R);const P={start:R,end:D,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},E=new Map;for(const[e,t]of a){const o=b.get(e)?.bodyId,n=t.find(e=>e.id===o)??t[0];E.set(e,n),h.set(e,n)}for(const[e,t]of b){if(E.has(e))continue;const i=y.get(e),d=c.get(t.bodyId)??h.get(e);if(i){y.delete(e),I.delete(i.bodyId),B+=1,C+=i.remaining,L();const r={...T(i),abandonedAt:S,remainingWork:i.remaining,queueSeconds:Math.max(0,S-i.queuedAt)};d&&n.onAbandoned?.(d,r),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:t.bodyId,datum:d?.datum,x:d?.x,y:d?.y,regionId:s,work:i.total,remainingWork:i.remaining,jobId:e,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,abandonedAt:S,queueSeconds:r.queueSeconds,queueDepth:y.size})}m.delete(e),v.delete(t.bodyId),b.delete(e),h.delete(e)}for(const[t,i]of E){if(b.has(t))continue;const d=(g.get(t)??0)+1;g.set(t,d);const r=e(i,n.unitAccessor),c={bodyId:i.id,jobId:t,visitId:`${s}:${t}:${d}`,visit:d,regionId:s,work:r,queuedAt:S};b.set(t,c),O+=1,P.arrivals+=1,P.arrivalWork+=r;const a=k++;if(u>y.size)U(i,c,o,a);else{const e={...c,blockedAt:S,sequence:a};m.set(t,e),v.set(i.id,t),N+=1,L(),n.onBlocked?.(i,e),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:i.id,datum:i.datum,x:i.x,y:i.y,regionId:s,work:r,jobId:t,visitId:c.visitId,visit:d,queuedAt:S,blockedAt:S,queueDepth:y.size,blockedDepth:m.size})}}G(o),V();const J=Array.from(y.values()).sort((e,t)=>e.sequence-t.sequence);let X=d*W;for(const e of J){if(0>=X)break;const t=Math.min(e.remaining,X);if(e.remaining-=t,X-=t,F+=t,P.processedWork+=t,e.remaining>1e-6)continue;y.delete(e.jobId),I.delete(e.bodyId),w+=1,z+=e.total,P.completions+=1,P.completedWork+=e.total;const i=Math.max(0,S-e.queuedAt);Q+=i,L();const d=c.get(e.bodyId);if(!d)continue;o.controls.applyImpulse(e.bodyId,f.x??0,f.y??0);const r={...T(e),completedAt:S,queueSeconds:i};n.onProcessed?.(d,r),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:e.bodyId,datum:d.datum,x:d.x,y:d.y,regionId:s,work:e.total,jobId:e.jobId,visitId:e.visitId,visit:e.visit,queuedAt:e.queuedAt,completedAt:S,queueSeconds:i,queueDepth:y.size})}G(o),V(),function(){const e=Array.from(y.values()).sort((e,t)=>e.sequence-t.sequence);M=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(m.values()).sort((e,t)=>e.sequence-t.sequence);A=new Map(t.map((e,t)=>[e.bodyId,t])),q=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&x.push(e);const t=S-l;for(;x.length>0&&t>x[0].end;)x.shift()}(P);const Y=Math.floor(S/p);Y!==$&&($=Y,L())},getSnapshot:()=>{const e=J(),t=function(){let e=0;for(const t of m.values())e+=t.work;return e}(),n=y.size,i=Array.from(y.values()).map(e=>Math.max(0,S-e.queuedAt)).sort((e,t)=>e-t),r=i.reduce((e,t)=>e+t,0);return{regionId:s,queueDepth:n,processedCount:w,unitsPerSecond:d,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:m.size,blockedWork:t,arrivalCount:O,admittedCount:W,admittedWork:R,processedWork:F,completedWork:z,blockedCount:N,abandonedCount:B,abandonedWork:C,peakQueueDepth:D,peakRemainingWork:P,queueAge:{count:i.length,meanSeconds:i.length>0?r/i.length:0,p50Seconds:o(i,.5),p95Seconds:o(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:w>0?Q/w:0,window:X(),simulatedAt:S,metricRevision:E}},bodyForce:e=>{if("none"===r)return null;const t=I.get(e.body.id),o=v.get(e.body.id),n=t?y.get(t):void 0,i=o?m.get(o):void 0;if(!n&&!i)return null;const d=n?M.get(e.body.id):A.get(e.body.id);if(null==d)return null;let u;const l=e.regions;if(l)for(let e=0;l.length>e;e+=1)if(l[e].id===s){const t=l[e].shape;t&&"aabb"===t.type&&(u=t);break}return u?{x:((i?u.x-.44*u.width:u.x-.22*u.width-d*(.15*c))-e.body.x)*a,y:(u.y-(d-((i?m.size:q)-1)/2)*c/Math.max(1,Math.sqrt(i?m.size:q))-e.body.y)*a*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function d(e,t){if(!t)return;let o=e;for(const e of t.split(".")){if(null==o||"object"!=typeof o)return;o=o[e]}return o}function r(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const o=d(e,t.property);return!("equals"in t&&!Object.is(o,t.equals)||"notEquals"in t&&Object.is(o,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(o,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(o,e)))}function c(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),o=new Map(t.map(e=>[e.bodyId,e])),n=new Map,i=new Map,s=e.assignmentForce??.45,d=e.returnForce??.35,r=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let a=new Map,u=0,l=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const o=n.get(e);if(o)return o;const s=t.find(e=>!i.has(e.id));if(!s)return null;const d={resourceId:s.id,resourceBodyId:s.bodyId,caseBodyId:e,assignedAt:u};return n.set(e,d),i.set(s.id,d),l+=1,d},release:e=>{const t=n.get(e);return!!t&&(n.delete(e),i.delete(t.resourceId),l+=1,!0)},getAssignment:e=>n.get(e),tick:e=>{u=Math.max(u,e.elapsed),a=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of n)a.has(e)&&a.has(t.resourceBodyId)||(n.delete(e),i.delete(t.resourceId),l+=1)},getSnapshot:()=>({total:t.length,available:t.length-i.size,assigned:i.size,assignments:Array.from(n.values()),simulatedAt:u,metricRevision:l}),bodyForce:e=>{const t=o.get(e.body.id);if(t){const o=i.get(t.id),n=o?a.get(o.caseBodyId):void 0,r=o?s:d;return{x:((n?n.x+(c.x??0):t.home.x)-e.body.x)*r,y:((n?n.y+(c.y??0):t.home.y)-e.body.y)*r}}const u=n.get(e.body.id);if(!u||0>=r)return null;const l=a.get(u.resourceBodyId);return l?{x:(l.x-e.body.x)*r,y:(l.y-e.body.y)*r}:null}}}function a(e,t){const o="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):d(e.datum,t.deadlineAccessor)??d(e,t.deadlineAccessor);return Number.isFinite(Number(o))?Math.max(0,Number(o)):0}function u(e){const t=new Map;let o=0,n=0;function i(o){t.set(o.bodyId,o),n+=1,e.onStateChange?.({...o})}function s(e){const n=t.get(e);return!(!n||null!=n.completedAt||(i({...n,completedAt:o,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=t.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(i({...n,state:"protected",protectedAt:o}),0))},complete:s,getCase:e=>t.get(e),tick:n=>{o=Math.max(o,n.elapsed);for(const d of n.controls.readBodies()){if(!r(d,e.bodyFilter))continue;if(!t.has(d.id)){const t=a(d,e);i({bodyId:d.id,openedAt:o,deadlineAt:o+t,state:"waiting"})}const c=t.get(d.id);c&&null==c.completedAt&&(e.completionRegionId&&n.getRegionState(d.id)?.activeRegionIds.includes(e.completionRegionId)?s(d.id):"waiting"!==c.state||c.deadlineAt>o||i({...c,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(t.values()),i=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:i("waiting"),protected:i("protected"),unhappy:i("unhappy"),resolved:i("resolved"),resolvedUnhappy:i("resolved-unhappy"),simulatedAt:o,metricRevision:n}}}}function l(e){const t=new Set;let o=0,n=0,i=0,s=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:d=>{o=Math.max(o,d.elapsed);const c=s;var a;a=o,s=e.isOpen?e.isOpen(a):null!=e.opensAt&&a>=e.opensAt;const u=d.controls.readBodies(),l=new Map(u.map(e=>[e.id,e]));for(const o of u){const n=d.getRegionState(o.id)?.activeRegionIds.includes(e.regionId);n&&r(o,e.bodyFilter)&&(s||t.has(o.id)||(t.add(o.id),i+=1,e.onHeld?.(o)))}if(s&&!c){for(const o of t){const t=l.get(o);t&&(d.controls.applyImpulse(o,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),n+=1,e.onReleased?.(t))}t.clear(),i+=1}for(const e of t)l.has(e)||(t.delete(e),i+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:s,blocked:t.size,released:n,simulatedAt:o,metricRevision:i}),bodyForce:o=>{if(s||!t.has(o.body.id))return null;const n=o.regions?.find(t=>t.id===e.regionId),i=n?.shape;if(!i||"aabb"!==i.type)return{x:.8*-o.body.vx,y:.8*-o.body.vy};const d=e.holdForce??.4;return{x:(i.x-o.body.x)*d-.45*o.body.vx,y:(i.y-o.body.y)*d-.45*o.body.vy}}}}function p(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function f(e){if(!e?.length)return null;const t=e.slice(),o=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:o,onTick:(e,o,n)=>{const i={result:e,controls:o,dt:n.dt,elapsed:n.elapsed,getRegionState:n.getRegionState};for(const e of t)e.tick(i)},bodyForce:e=>{let o=null;for(const n of t)n.bodyForce&&(o=p(o,n.bodyForce(e)));return o}}}function y(e){const t=new Set,o=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:n=>{const i=n.controls.readBodies();for(const s of i){const i=n.getRegionState(s.id),d=i?.activeRegionIds.includes(e.fromRegionId);d?t.has(s.id)||(t.add(s.id),n.controls.applyImpulse(s.id,o.x??0,o.y??0),e.onPortal?.(s)):t.delete(s.id)}}}}export{s as createCapacityQueueController,c as createServiceResourcePoolController,u as createServiceLevelController,l as createDependencyGateController,f as composePhysicsControllers,y as createPortalController};
@@ -1 +0,0 @@
1
- function t(t){if(null==t)return()=>{};const n="function"==typeof t?t:n=>n[t];return t=>e(n(t))}function n(n,i){const e=t(n),o=t(i);return(t,n)=>{const i=o(t);return{value:i,x:e(t),y:i,category:n}}}function i(n,i){const e=t(i??"value"),o=null==n?void 0:"function"==typeof n?n:t=>t[n];return t=>{const n=o?o(t):void 0;return{value:e(t),category:null==n?void 0:n+""}}}function e(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const n=Number(t);return Number.isFinite(n)?n:void 0}}function o(t,n,i){const o=null!=t.axis?i[t.axis]:null!=t.field?n[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const r=e(o);if(void 0===r)return!1;if(void 0!==t.gt&&t.gt>=r)return!1;if(void 0!==t.gte&&t.gte>r)return!1;if(void 0!==t.lt&&r>=t.lt)return!1;if(void 0!==t.lte&&r>t.lte)return!1;if(void 0!==t.within){const[n,i]=t.within;if(n>r||r>i)return!1}if(void 0!==t.outside){const[n,i]=t.outside;if(r>=n&&i>=r)return!1}return!0}function r(t,n,i){const e=t.when;return void 0===e||!0===e||!1!==e&&("function"==typeof e?e(n,i):o(e,n,i))}function u(t,n,i){if(!n||0===n.length)return{};let e={};for(const o of n){if(!r(o,t,i))continue;const n="function"==typeof o.style?o.style(t,i):o.style;n&&(e={...e,...n})}return e}function f(t,n,i,e=t=>t){const o=t??(()=>({}));return n&&0!==n.length?(t,r)=>{const f=e(t),c={...o(t,r)};return Object.assign(c,u(f,n,i(f,r))),c}:o}function c(t,n,i){return t&&0!==t.length?(e,o)=>{const r=u(e,t,n(e,o)),f=i?i(e,o):void 0;return f?{...r,...f}:r}:i}function s(t,n,e,o){if(!t||0===t.length)return o;const r=i(n,e);return(n,i)=>{const e=n&&n.data||n,f=u(e,t,r(e)),c=o?o(n,i):void 0;return c?{...f,...c}:f}}function d(t,i,e,o){return c(t,n(i,e),o)}export{t as makeRuleValueResolver,n as makeXYRuleContext,i as makeNodeRuleContext,o as matchesThreshold,r as ruleMatches,u as resolveStyleRules,f as composeStyleRules,c as makeStyleRuleStyleFn,s as styleRulesToNodeStyle,d as styleRulesToXYStyle};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{StreamXYFrame_default as e}from"./chunk-chunk-AAF5LZAU.module.min.js";import{buildCustomBehaviorProps as t}from"./chunk-chunk-WYARAXHR.module.min.js";import{normalizeLinkedBrush as n,useBrushSelection as i,useChartLegendAndMargin as s,useChartMode as o,useChartSelection as r}from"./chunk-chunk-PX5YQGDP.module.min.js";import{renderEmptyState as a,renderLoadingState as l}from"./chunk-chunk-ACLDBMRH.module.min.js";var c=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},u=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,i=Math.floor(e/n);for(let s=Math.floor((e-this.size)/n)+1;i>=s;s++)this.bump(s*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new c,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,i=new c;i.push(t);let s=e,o=e;const r=[],a={start:s,end:o,stats:i};for(const t of this.sessions)e-n>t.end||t.start>e+n?r.push(t):(a.stats.merge(t.stats),s>t.start&&(s=t.start),t.end>o&&(o=t.end));a.start=s,a.end=o,r.push(a),r.sort((e,t)=>e.start-t.start),this.sessions=r}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const i=t+this.size;e.push(this.row(t,i,n,i>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,i){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:i}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function m(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function h(e,t,n,i=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const s=m(e,n),o=e.stddev*i;return[s-o,s+o]}var d={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},p=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function g(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;p.lastIndex=0;let n,i=0,s=0;for(;null!==(n=p.exec(t));){const e=parseFloat(n[1]),t=d[n[2]];if(null==t||!Number.isFinite(e))return null;i+=e*t,s+=n[0].length}return s!==t.length?null:i>0?i:null}var v=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const i of this.held)this.getTime(i)>e?n.push(i):t.push(i);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as f,useImperativeHandle as w,forwardRef as y,useCallback as b,useState as x,useEffect as A}from"react";import{jsx as _,jsxs as k}from"react/jsx-runtime";var H={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},S={opacity:.7,marginRight:4};function z(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function I(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function C(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:i="x",yLabel:s="y"}=e;return e=>{const o=e?.data??null,r=z(o,t,"time"),a=z(o,n,"value");return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[k("span",{style:S,children:[i,":"]}),I(r)]}),k("div",{children:[k("span",{style:S,children:[s,":"]}),I(a)]})]})}}function T(e,t){return null!=e?e:Math.max(t?.length??0,200)}var R="time",P="value",F="__aggLower",M="__aggUpper",N="__aggPartial",D="count",E="__aggStart",B="__aggEnd";function O(e,t){const n=t.stat??"mean",i=t.band??"none",s=t.sigma??1;return e.emit().map(e=>{const t={[R]:(e.start+e.end)/2,[P]:m(e,n),[D]:e.count,[N]:e.partial,[E]:e.start,[B]:e.end},o=h(e,i,n,s);return o&&(t[F]=o[0],t[M]=o[1]),t})}import{jsx as j}from"react/jsx-runtime";function L(e,t,n){const i="function"==typeof t?t(e):e[t??n];if(null==i)return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isFinite(s)?s:null}var W=y(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:m,className:h,arrowOfTime:d="right",windowMode:p="sliding",windowSize:y,data:_,timeAccessor:k,valueAccessor:H,timeExtent:S,valueExtent:z,extentPadding:I,stroke:N="#007bff",strokeWidth:D=2,strokeDasharray:E,opacity:B,background:W,tooltipContent:V,tooltip:$,onHover:X,annotations:Y,autoPlaceAnnotations:q,svgAnnotationRules:U,tickFormatTime:G,tickFormatValue:Q,decay:Z,pulse:J,staleness:K,transition:ee,linkedHover:te,selection:ne,onObservation:ie,chartId:se,loading:oe,loadingContent:re,emptyContent:ae,emphasis:le,legendPosition:ce,aggregate:ue,eventTime:me}=n,he=s.showAxes,de=s.enableHover,pe=m??s.marginDefaults,ge=c??[s.width,s.height],ve=V??$??C({timeAccessor:k,valueAccessor:H}),fe=f(null),{customHoverBehavior:we}=r({selection:ne,linkedHover:te,unwrapData:!0,onObservation:ie,chartType:"RealtimeLineChart",chartId:se}),ye=b(e=>{X&&X(e),we(e)},[X,we]),be=null!=ue,[xe,Ae]=x([]),_e=f(null),ke=f(ue);ke.current=ue;const He=f(be);He.current=be;const Se=f(xe);Se.current=xe;const ze=f({timeAccessor:k,valueAccessor:H});ze.current={timeAccessor:k,valueAccessor:H},A(()=>{if(!be)return void(_e.current=null);const e=ke.current,t=function(e){const t=e.window??"tumbling",n=g("session"===t?e.gap??e.size:e.size);if(null==n)return null;const i=null!=e.hop?g(e.hop):void 0,s=null!=e.gap?g(e.gap):void 0;return new u({window:t,size:n,hop:i??void 0,gap:s??void 0,retain:e.retain})}(e);if(_e.current=t,t&&_){const{timeAccessor:e,valueAccessor:n}=ze.current;for(const i of _){const s=L(i,e,"time"),o=L(i,n,"value");null!=s&&null!=o&&t.push(s,o)}}Ae(t?O(t,e):[])},[be?[ue.window??"tumbling",ue.size,ue.hop??"",ue.gap??"",ue.retain??""].join("|"):"",be,_]),A(()=>{be&&_e.current&&Ae(O(_e.current,ke.current))},[ue?.stat,ue?.band,ue?.sigma]);const Ie=b(e=>{const t=_e.current,n=ke.current;if(!t||!n)return;const{timeAccessor:i,valueAccessor:s}=ze.current;for(const n of e){const e=L(n,i,"time"),o=L(n,s,"value");null!=e&&null!=o&&t.push(e,o)}Ae(O(t,n))},[]),Ce=null!=me,Te=f(null),Re=f(me);Re.current=me;const Pe=f(Ce);Pe.current=Ce;const Fe=f(ie);Fe.current=ie;const Me=f(se);Me.current=se,A(()=>{Te.current=Ce?function(e){const t=g(e.lateness);return null==t?null:new v({lateness:t,getTime:e=>L(e,ze.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(Re.current):null},[Ce?`${me.lateness}|${me.latePolicy??"drop"}`:"",Ce]);const Ne=b(e=>{0!==e.length&&(He.current?Ie(e):fe.current?.pushMany(e))},[Ie]),De=b(e=>{const t=Te.current;if(!Pe.current||!t)return void Ne(e);const n=[];for(const i of e){const e=t.push(i);if(e.released.length&&n.push(...e.released),e.late.length){const n=Fe.current;if(n){const{timeAccessor:i}=ze.current,s=Re.current?.latePolicy??"drop";for(const o of e.late)n({type:"late-data",datum:o,eventTime:L(o,i,"time")??NaN,watermark:t.watermark,policy:s,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:Me.current})}}}Ne(n)},[Ne]);w(i,()=>({push:e=>De([e]),pushMany:e=>De(e),remove:e=>He.current?[]:fe.current?.remove(e)??[],update:(e,t)=>He.current?[]:fe.current?.update(e,t)??[],clear:()=>{Te.current?.clear(),He.current?(_e.current?.clear(),Ae([])):fe.current?.clear()},getData:()=>He.current?Se.current:fe.current?.getData()??[],getScales:()=>fe.current?.getScales()??null}),[De]);const Ee=l(oe,ge[0],ge[1],re),Be=Ee?null:a(be?void 0:_,ge[0],ge[1],ae),Oe={stroke:N,strokeWidth:D,strokeDasharray:E};null!=B&&(Oe.opacity=B);const je=T(y,_),Le=be?xe:_,We=be?R:k,Ve=be?P:H,$e=be&&ue&&"none"!==(ue.band??"none")?{y0Accessor:F,y1Accessor:M,perSeries:!1}:void 0;return Ee||Be||j(e,{ref:fe,chartType:"line",runtimeMode:"streaming",size:ge,margin:pe,className:le?`${h||""} semiotic-emphasis-${le}`.trim():h,arrowOfTime:d,windowMode:be?"growing":p,windowSize:be?Math.max(1,ue?.retain??Math.max(xe.length,600)):je,data:Le,timeAccessor:We,valueAccessor:Ve,xExtent:S,yExtent:z,extentPadding:I,band:$e,lineStyle:Oe,showAxes:he,background:W,hoverAnnotation:de,tooltipContent:ve,...t({linkedHover:te,selection:ne,onObservation:ie,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:ye}),annotations:Y,autoPlaceAnnotations:q,svgAnnotationRules:U,tickFormatTime:G,tickFormatValue:Q,decay:Z,pulse:J,staleness:K,transition:ee,pointIdAccessor:n.pointIdAccessor,legendPosition:ce})});W.displayName="RealtimeLineChart";import{useRef as V,useImperativeHandle as $,forwardRef as X,useCallback as Y,useMemo as q}from"react";function U(e,t,n){const i="function"==typeof t?t(e):e[t??n];if(null==i)return null;if(i instanceof Date)return i.getTime();if("string"==typeof i&&""===i.trim())return null;const s=Number(i);return Number.isFinite(s)?s:null}import{jsx as G}from"react/jsx-runtime";var Q=X(function(c,u){const m=o(c.mode,{width:c.size?.[0]??c.width,height:c.size?.[1]??c.height,showAxes:c.showAxes,showLegend:c.showLegend,enableHover:null!=c.enableHover?!!c.enableHover:void 0,linkedHover:c.linkedHover,mobileInteraction:c.mobileInteraction,mobileSemantics:c.mobileSemantics,responsiveRules:c.responsiveRules}),{binSize:h,size:d,margin:p,className:g,arrowOfTime:v="right",windowMode:f="sliding",windowSize:w,data:y,timeAccessor:b,valueAccessor:x,direction:A="up",timeExtent:C,valueExtent:R,extentPadding:P,categoryAccessor:F,colors:M,fill:N,stroke:D,strokeWidth:E,opacity:B,gap:O,background:j,tooltipContent:L,tooltip:W,onHover:X,annotations:Q,autoPlaceAnnotations:Z,svgAnnotationRules:J,tickFormatTime:K,tickFormatValue:ee,linkedHover:te,selection:ne,decay:ie,pulse:se,staleness:oe,transition:re,onObservation:ae,chartId:le,loading:ce,loadingContent:ue,emptyContent:me,emphasis:he,legendPosition:de,legend:pe,brush:ge,onBrush:ve,linkedBrush:fe}=c,we=m.showAxes,ye=m.enableHover,be=d??[m.width,m.height],xe=q(()=>M?e=>M[e]??N??"#999":void 0,[M,N]),{legend:Ae,margin:_e,legendPosition:ke}=s({data:y??[],colorBy:F,colorScale:xe,showLegend:m.showLegend,legendPosition:de,userMargin:p,defaults:m.marginDefaults,additionalLegend:pe,chartWidth:be[0]}),He=L??W??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const i=e?.data??null;if(null==i?.binStart||null==i?.binEnd){const e=z(i,t,"time"),s=z(i,n,"value");return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"x:"}),I(e)]}),k("div",{children:[_("span",{style:S,children:"y:"}),I(s)]})]})}return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"range:"}),I(i.binStart),"–",I(i.binEnd)]}),null!=i.total&&k("div",{children:[_("span",{style:S,children:"count:"}),I(i.total)]}),null!=i.category&&k("div",{children:[_("span",{style:S,children:"category:"}),I(i.category)]})]})}}({timeAccessor:b,valueAccessor:x}),Se=V(null),{customHoverBehavior:ze}=r({selection:ne,linkedHover:te,unwrapData:!0,onObservation:ae,chartType:"RealtimeHistogram",chartId:le}),Ie=Y(e=>{X&&X(e),ze(e)},[X,ze]),Ce=!0===ge?{dimension:"x",snap:"bin"}:"x"===ge?{dimension:"x"}:"object"==typeof ge?ge:void 0,Te=n(fe),Re="string"==typeof b?b:"time",Pe=i({name:Te?.name||"__unused_hist_brush__",xField:Te?.xField||Re,...Te?.yField?{yField:Te.yField}:{}}),Fe=V(Pe.brushInteraction);Fe.current=Pe.brushInteraction;const Me=Y(e=>{if(ve&&ve(e),ae&&ae(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:le}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:le}),Te){const t=Fe.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[ve,ae,le,Te]);$(u,()=>({push:e=>Se.current?.push(e),pushMany:e=>Se.current?.pushMany(e),remove:e=>Se.current?.remove(e)??[],update:(e,t)=>Se.current?.update(e,t)??[],clear:()=>Se.current?.clear(),getData:()=>Se.current?.getData()??[],getScales:()=>Se.current?.getScales()??null}),[]);const Ne=l(ce,be[0],be[1],ue),De=Ne?null:a(y,be[0],be[1],me),Ee={};null!=N&&(Ee.fill=N),null!=D&&(Ee.stroke=D),null!=E&&(Ee.strokeWidth=E),null!=B&&(Ee.opacity=B),null!=O&&(Ee.gap=O);const Be=he?`${g||""} semiotic-emphasis-${he}`.trim():g,Oe=T(w,y),je=q(()=>"down"!==A?R:function({data:e,valueAccessor:t,timeAccessor:n,binSize:i,valueExtent:s,extentPadding:o}){if(s)return[s[1],s[0]];if(!e||0===e.length)return;const r=new Map;for(const s of e){const e=U(s,n,"time"),o=U(s,t,"value");if(null==e||null==o)continue;const a=Math.floor(e/i)*i;r.set(a,(r.get(a)??0)+o)}let a=0;for(const e of r.values())a=Math.max(a,e);return[a>0?a+a*(o??.1):1,0]}({data:y,valueAccessor:x,timeAccessor:b,binSize:h,valueExtent:R,extentPadding:P}),[A,y,x,b,h,R,P]);return Ne||De||G(e,{ref:Se,chartType:"bar",runtimeMode:"streaming",size:be,margin:_e,className:Be,arrowOfTime:v,windowMode:f,windowSize:Oe,data:y,timeAccessor:b,valueAccessor:x,xExtent:C,yExtent:je,extentPadding:P,binSize:h,categoryAccessor:F,barColors:M,barStyle:Ee,showAxes:we,background:j,hoverAnnotation:ye,tooltipContent:He,...t({linkedHover:te,selection:ne,onObservation:ae,forceHoverBehavior:!0,mobileInteraction:m.mobileInteraction,customHoverBehavior:Ie}),annotations:Q,autoPlaceAnnotations:Z,svgAnnotationRules:J,tickFormatTime:K,tickFormatValue:ee,decay:ie,pulse:se,staleness:oe,transition:re,pointIdAccessor:c.pointIdAccessor,legend:Ae,legendPosition:ke,brush:Ce||(fe?{dimension:"x"}:void 0),onBrush:Ce||fe?Me:void 0})});function Z(e){return G(Q,{...e,windowMode:"growing"})}Q.displayName="RealtimeHistogram",Z.displayName="TemporalHistogram";var J=Q;import{useRef as K,useImperativeHandle as ee,forwardRef as te,useCallback as ne}from"react";import{jsx as ie}from"react/jsx-runtime";var se=te(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,timeExtent:w,valueExtent:y,yScaleType:b,extentPadding:x,categoryAccessor:A,colors:_,radius:k,fill:H,opacity:S,stroke:z,strokeWidth:I,pointStyle:R,background:P,tooltipContent:F,tooltip:M,onHover:N,annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,linkedHover:L,selection:W,onObservation:V,chartId:$,loading:X,loadingContent:Y,emptyContent:q,emphasis:U,legendPosition:G}=n,Q=s.showAxes,Z=s.enableHover,J=u??s.marginDefaults,te=c??[s.width,s.height],se=F??M??C({timeAccessor:v,valueAccessor:f}),oe=K(null),{customHoverBehavior:re}=r({selection:W,linkedHover:L,unwrapData:!0,onObservation:V,chartType:"RealtimeSwarmChart",chartId:$}),ae=ne(e=>{N&&N(e),re(e)},[N,re]);ee(i,()=>({push:e=>oe.current?.push(e),pushMany:e=>oe.current?.pushMany(e),remove:e=>oe.current?.remove(e)??[],update:(e,t)=>oe.current?.update(e,t)??[],clear:()=>oe.current?.clear(),getData:()=>oe.current?.getData()??[],getScales:()=>oe.current?.getScales()??null}),[]);const le=l(X,te[0],te[1],Y),ce=le?null:a(g,te[0],te[1],q),ue={};null!=k&&(ue.radius=k),null!=H&&(ue.fill=H),null!=S&&(ue.opacity=S),null!=z&&(ue.stroke=z),null!=I&&(ue.strokeWidth=I);const me=R,he=U?`${m||""} semiotic-emphasis-${U}`.trim():m,de=T(p,g);return le||ce||ie(e,{ref:oe,chartType:"swarm",runtimeMode:"streaming",size:te,margin:J,className:he,arrowOfTime:h,windowMode:d,windowSize:de,data:g,timeAccessor:v,valueAccessor:f,xExtent:w,yExtent:y,yScaleType:b,extentPadding:x,categoryAccessor:A,barColors:_,swarmStyle:ue,pointStyle:me,showAxes:Q,background:P,hoverAnnotation:Z,tooltipContent:se,...t({linkedHover:L,selection:W,onObservation:V,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:ae}),annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,legendPosition:G,pointIdAccessor:n.pointIdAccessor})});se.displayName="RealtimeSwarmChart";import{useRef as oe,useImperativeHandle as re,forwardRef as ae,useCallback as le}from"react";import{jsx as ce}from"react/jsx-runtime";var ue=ae(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,timeExtent:w,valueExtent:y,extentPadding:b,positiveColor:x,negativeColor:A,connectorStroke:C,connectorWidth:R,gap:P,stroke:F,strokeWidth:M,opacity:N,background:D,tooltipContent:E,tooltip:B,onHover:O,annotations:j,autoPlaceAnnotations:L,svgAnnotationRules:W,tickFormatTime:V,tickFormatValue:$,linkedHover:X,selection:Y,onObservation:q,chartId:U,loading:G,loadingContent:Q,emptyContent:Z,emphasis:J,legendPosition:K}=n,ee=s.showAxes,te=s.enableHover,ne=u??s.marginDefaults,ie=c??[s.width,s.height],se=E??B??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const i=e?.data??null,s=z(i,t,"time"),o=i?.delta??z(i,n,"value"),r=i?.cumEnd,a="number"==typeof o?0>o?I(o):"+"+I(o):I(o);return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"x:"}),I(s)]}),k("div",{children:[_("span",{style:S,children:"Δ:"}),a]}),null!=r&&k("div",{children:[_("span",{style:S,children:"total:"}),I(r)]})]})}}({timeAccessor:v,valueAccessor:f}),ae=oe(null),{customHoverBehavior:ue}=r({selection:Y,linkedHover:X,unwrapData:!0,onObservation:q,chartType:"RealtimeWaterfallChart",chartId:U}),me=le(e=>{O&&O(e),ue(e)},[O,ue]);re(i,()=>({push:e=>ae.current?.push(e),pushMany:e=>ae.current?.pushMany(e),remove:e=>ae.current?.remove(e)??[],update:(e,t)=>ae.current?.update(e,t)??[],clear:()=>ae.current?.clear(),getData:()=>ae.current?.getData()??[],getScales:()=>ae.current?.getScales()??null}),[]);const he=l(G,ie[0],ie[1],Q),de=he?null:a(g,ie[0],ie[1],Z),pe={};null!=x&&(pe.positiveColor=x),null!=A&&(pe.negativeColor=A),null!=C&&(pe.connectorStroke=C),null!=R&&(pe.connectorWidth=R),null!=P&&(pe.gap=P),null!=F&&(pe.stroke=F),null!=M&&(pe.strokeWidth=M),null!=N&&(pe.opacity=N);const ge=J?`${m||""} semiotic-emphasis-${J}`.trim():m,ve=T(p,g);return he||de||ce(e,{ref:ae,chartType:"waterfall",runtimeMode:"streaming",size:ie,margin:ne,className:ge,arrowOfTime:h,windowMode:d,windowSize:ve,data:g,timeAccessor:v,valueAccessor:f,xExtent:w,yExtent:y,extentPadding:b,waterfallStyle:pe,showAxes:ee,background:D,hoverAnnotation:te,tooltipContent:se,...t({linkedHover:X,selection:Y,onObservation:q,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:me}),annotations:j,autoPlaceAnnotations:L,svgAnnotationRules:W,tickFormatTime:V,tickFormatValue:$,legendPosition:K,pointIdAccessor:n.pointIdAccessor})});ue.displayName="RealtimeWaterfallChart";import{useRef as me,useImperativeHandle as he,forwardRef as de,useCallback as pe}from"react";import{jsx as ge}from"react/jsx-runtime";var ve=de(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,categoryAccessor:w,timeExtent:y,valueExtent:b,extentPadding:x,heatmapXBins:A=20,heatmapYBins:C=20,aggregation:R="count",background:P,tooltipContent:F,tooltip:M,onHover:N,annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,decay:L,pulse:W,staleness:V,linkedHover:$,selection:X,onObservation:Y,chartId:q,loading:U,loadingContent:G,emptyContent:Q,emphasis:Z,legendPosition:J}=n,K=s.showAxes,ee=s.enableHover,te=u??s.marginDefaults,ne=c??[s.width,s.height],ie=F??M??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:i="x",yLabel:s="y"}=e;return e=>{const o=e?.data??null,r=o?.xCenter??z(o,t,"time"),a=o?.yCenter??z(o,n,"value"),l=o?.count,c=o?.sum,u=o?.value,m=o?.agg??"count";return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[k("span",{style:S,children:[i,":"]}),I(r)]}),k("div",{children:[k("span",{style:S,children:[s,":"]}),I(a)]}),null!=l&&k("div",{children:[_("span",{style:S,children:"count:"}),I(l)]}),"sum"===m&&null!=c&&k("div",{children:[_("span",{style:S,children:"sum:"}),I(c)]}),"mean"===m&&null!=u&&k("div",{children:[_("span",{style:S,children:"mean:"}),I(u)]})]})}}({timeAccessor:v,valueAccessor:f}),se=me(null),{customHoverBehavior:oe}=r({selection:X,linkedHover:$,unwrapData:!0,onObservation:Y,chartType:"RealtimeHeatmap",chartId:q}),re=pe(e=>{N&&N(e),oe(e)},[N,oe]);he(i,()=>({push:e=>se.current?.push(e),pushMany:e=>se.current?.pushMany(e),remove:e=>se.current?.remove(e)??[],update:(e,t)=>se.current?.update(e,t)??[],clear:()=>se.current?.clear(),getData:()=>se.current?.getData()??[],getScales:()=>se.current?.getScales()??null}),[]);const ae=l(U,ne[0],ne[1],G),le=ae?null:a(g,ne[0],ne[1],Q),ce=Z?`${m||""} semiotic-emphasis-${Z}`.trim():m,ue=T(p,g);return ae||le||ge(e,{ref:se,chartType:"heatmap",runtimeMode:"streaming",size:ne,margin:te,className:ce,arrowOfTime:h,windowMode:d,windowSize:ue,data:g,timeAccessor:v,valueAccessor:f,categoryAccessor:w,xExtent:y,yExtent:b,extentPadding:x,heatmapXBins:A,heatmapYBins:C,heatmapAggregation:R,showAxes:K,background:P,hoverAnnotation:ee,tooltipContent:ie,...t({linkedHover:$,selection:X,onObservation:Y,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:re}),annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,decay:L,pulse:W,staleness:V,legendPosition:J,pointIdAccessor:n.pointIdAccessor})});ve.displayName="RealtimeHeatmap";export{c as RunningStats,u as WindowAccumulator,m as statValue,h as bandBounds,g as parseWindowDuration,v as ReorderBuffer,W as RealtimeLineChart,Q as RealtimeHistogram,Z as TemporalHistogram,J as RealtimeTemporalHistogram,se as RealtimeSwarmChart,ue as RealtimeWaterfallChart,ve as RealtimeHeatmap};
@@ -1,2 +0,0 @@
1
- "use client";
2
- function e(e,r){const t=e.length,n=r.length,o=Array(n+1);for(let e=0;n>=e;e++)o[e]=e;for(let a=1;t>=a;a++){let t=o[0];o[0]=a;for(let i=1;n>=i;i++){const n=o[i];o[i]=e[a-1]===r[i-1]?t:1+Math.min(t,o[i],o[i-1]),t=n}}return o[n]}function r(r,t,n=3){let o,a=n+1;for(const n of t){const t=e(r.toLowerCase(),n.toLowerCase());a>t&&(a=t,o=n)}return a>n?void 0:o}function t(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}function n(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(r(e,t,3)??null)}function o({componentName:e,data:r,accessors:o,requiredProps:a}){if(a)for(const[r,t]of Object.entries(a))if(null==t)return`${e}: ${r} is required. Provide a field name or function.`;if(null==r)return null;if(!Array.isArray(r)&&"object"==typeof r)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(!Array.isArray(r)||0===r.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(o){const a=t(r).find(e=>e&&"object"==typeof e);if(a){const r=Object.keys(a);for(const[t,i]of Object.entries(o))if(i&&"string"==typeof i&&!(i in a)){const o=n(i,r),a=o?` Try ${t}="${o}".`:"";return`${e}: ${t} "${i}" not found in data. Available fields: ${r.join(", ")}.${a}`}}}return null}function a({componentName:e,data:r,dataLabel:t="data"}){return null==r?`${e}: No ${t} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(r)?`${e}: ${t} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function i({componentName:e,nodes:r,edges:o,nodesRequired:a=!1,edgesRequired:i=!0,accessors:s}){if(null==r&&null==o)return null;if(i&&(!o||!Array.isArray(o)||0===o.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(a&&(!r||!Array.isArray(r)||0===r.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(s&&r&&r.length>0){const o=t(r).find(e=>e&&"object"==typeof e);if(o){const r=Object.keys(o);for(const[t,a]of Object.entries(s))if(a&&"string"==typeof a&&!(a in o)){const o=n(a,r),i=o?` Try ${t}="${o}".`:"";return`${e}: ${t} "${a}" not found in node data. Available fields: ${r.join(", ")}.${i}`}}}return null}export{r as closestMatch,o as validateArrayData,a as validateObjectData,i as validateNetworkData};
@@ -1 +0,0 @@
1
- import{mulberry32 as t}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{UpdateResultTracker as e}from"./chunk-chunk-5RKXZQ2P.module.min.js";var i={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},s=1e-9,n=.005;function o(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function r(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function a(t,e,i){return Math.max(e,Math.min(i,t))}function d(t){return 0>t?-1:1}function h(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function c(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function l(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function u(t,e,i,s,n,o,r,a){const h=n-t,c=(i+r)/2-Math.abs(h);if(0>=c)return null;const l=o-e,u=(s+a)/2-Math.abs(l);return u>0?u>c?{nx:d(h),ny:0,penetration:c}:{nx:0,ny:d(l),penetration:u}:null}function p(t,e,i,n,o,r,d){const h=r/2,c=d/2;let l=t-a(t,n-h,n+h),u=e-a(e,o-c,o+c);const p=l*l+u*u;if(p>i*i)return null;if(s>=p){const s=Math.abs(t-(n-h)),r=Math.abs(t-(n+h)),a=Math.abs(e-(o-c)),d=Math.abs(e-(o+c)),p=Math.min(s,r,a,d);return p===s?(l=-1,u=0,{nx:l,ny:u,penetration:i+s}):p===r?(l=1,u=0,{nx:l,ny:u,penetration:i+r}):p===a?(l=0,u=-1,{nx:l,ny:u,penetration:i+a}):(l=0,u=1,{nx:l,ny:u,penetration:i+d})}const m=Math.sqrt(p);return{nx:l/m,ny:u/m,penetration:i-m}}function m(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,n,o,r){const a=n-t,d=o-e,h=i+r,c=a*a+d*d;if(c>=h*h)return null;if(s>=c)return{nx:1,ny:0,penetration:h};const l=Math.sqrt(c);return{nx:a/l,ny:d/l,penetration:h-l}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return u(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=p(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?p(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function y(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?p(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):u(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,n,o,r,d,h=0){const c=r-n,l=d-o,u=c*c+l*l,p=u>s?a(((t-n)*c+(e-o)*l)/u,0,1):0,m=i+h/2,y=t-(n+c*p),f=e-(o+l*p),v=y*y+f*f;if(v>=m*m)return null;if(s>=v){const t=Math.sqrt(u);return t>s?{nx:-l/t,ny:c/t,penetration:m}:{nx:1,ny:0,penetration:m}}const b=Math.sqrt(v);return{nx:y/b,ny:f/b,penetration:m-b}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function f(t,e){return`${t}\0${e}`}function v(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function b(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:o(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function g(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function x(t){return{id:t.id,shape:r(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:g(t.bodyFilter),index:t.index}}function S(t,e){return!!e?.some(e=>Object.is(t,e))}function w(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const s=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(s,i.equals)||"notEquals"in i&&Object.is(s,i.notEquals)||i.oneOf&&!S(s,i.oneOf)||i.notOneOf&&S(s,i.notOneOf))}var I=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...i,...e},this.random=t(this.options.seed)}init(e={}){this.options={...i,...e},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(s,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:o(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))v(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:r(e.shape),bodyFilter:g(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const s=this.bodies.get(t);s&&(s.vx+=e/s.mass,s.vy+=i/s.mass,this.wake(s))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const s=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,s>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>s){const i=s/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(i),o=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,n,0===t),this.resolveColliders(i,o,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:o(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(v)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(b),colliders:this.sortedColliders().map(x),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=b(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=x(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const n="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!n)continue;const o=n.x-i.x,r=n.y-i.y,a=Math.sqrt(o*o+r*r);if(s>=a)continue;const d=o/a,h=r/a,c=(a-e.restLength)*e.stiffness+((("vx"in n?n.vx:0)-i.vx)*d+(("vy"in n?n.vy:0)-i.vy)*h)*e.damping;i.vx+=c*d*t/i.mass,i.vy+=c*h*t/i.mass}}resolveBodyPairs(t,e,i){for(const s of e){const[e,n]=s.split(":").map(Number),o=t[e],r=t[n];if(!o||!r)continue;const a=m(o,r);a&&(this.resolveDynamicCollision(o,r,a),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:r.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let s=0;t.length>s;s+=1){if(!1===t[s].bodyCollisions)continue;const n=h(t[s]),o=Math.floor(n.minX/e),r=Math.floor(n.maxX/e),a=Math.floor(n.minY/e),d=Math.floor(n.maxY/e);for(let t=o;r>=t;t+=1)for(let e=a;d>=e;e+=1){const n=`${t}:${e}`,o=i.get(n);o?o.push(s):i.set(n,[s])}}const s=new Set;for(const e of Array.from(i.keys()).sort()){const n=i.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let i=e+1;n.length>i;i+=1){const o=n[e],r=n[i];!1!==t[o].bodyCollisions&&!1!==t[r].bodyCollisions&&l(h(t[o]),h(t[r]))&&s.add(`${o}:${r}`)}}return Array.from(s).sort((t,e)=>{const[i,s]=t.split(":").map(Number),[n,o]=e.split(":").map(Number);return i===n?s-o:i-n})}resolveDynamicCollision(t,e,i){t.sleeping&&this.contactOpposesGravity(i.nx,i.ny)&&this.supportedThisStep.add(e.id),e.sleeping&&this.contactOpposesGravity(-i.nx,-i.ny)&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,r=e.sleeping?0:1/e.mass,a=o+r;if(s>=a)return;const d=Math.max(0,i.penetration-n)/a;t.x-=i.nx*d*o,t.y-=i.ny*d*o,e.x+=i.nx*d*r,e.y+=i.ny*d*r;const h=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(h>0)return;const c=Math.abs(h),l=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*h/a,u=l*i.nx,p=l*i.ny;t.vx-=u*o,t.vy-=p*o,e.vx+=u*r,e.vy+=p*r,this.applyFriction(t,e,i,l,o,r),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,n,o,r){const d=-i.ny,h=i.nx,c=(e.vx-t.vx)*d+(e.vy-t.vy)*h,l=o+r;if(s>=Math.abs(c)||s>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),p=a(-c/l,-n*u,n*u),m=p*d,y=p*h;t.vx-=m*o,t.vy-=y*o,e.vx+=m*r,e.vy+=y*r}resolveColliders(t,e,i){for(const s of t)for(const t of e){if(!w(t,s))continue;if(!l(h(s),c(t)))continue;const e=y(s,t);e&&(this.resolveStaticCollision(s,t,e),this.contactOpposesGravity(e.nx,e.ny)&&this.supportedThisStep.add(s.id),i&&this.lastEvents.push({type:"contact",bodyId:s.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-n),t.y+=i.ny*Math.max(0,i.penetration-n);const s=t.vx*i.nx+t.vy*i.ny;if(0>s){const n=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+n)*s*i.nx,t.vy-=(1+n)*s*i.ny;const o=-i.ny,r=i.nx,a=t.vx*o+t.vy*r,d=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*o*d,t.vy-=a*r*d}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const s of t){const t=h(s);for(const n of i){if(!w(n,s))continue;if(!l(t,c(n)))continue;if(!y(s,n))continue;const i=f(n.id,s.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:s.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:s}=v(t);this.lastEvents.push({type:"sensor-exit",bodyId:s,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const s of t)Math.sqrt(s.vx*s.vx+s.vy*s.vy)>=this.options.sleepSpeed||Math.sqrt((s.x-s.prevX)*(s.x-s.prevX)+(s.y-s.prevY)*(s.y-s.prevY))>=this.options.sleepSpeed*e||i&&!this.supportedThisStep.has(s.id)?s.sleeping?this.wake(s):s.sleepTime=0:(s.sleepTime+=e,s.sleeping||this.options.sleepAfter>s.sleepTime||(s.sleeping=!0,s.vx=0,s.vy=0,this.lastEvents.push({type:"sleep",bodyId:s.id})))}contactOpposesGravity(t,e){const{x:i,y:s}=this.options.gravity,n=Math.hypot(i,s);return 1e-9>=n||-.2>(t*i+e*s)/n}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},M=class{constructor(t={}){this.id="builtin",this.capabilities={...(new I).capabilities,engine:"builtin"},this.world=new I(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function B(t={}){return new M(t)}function k(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):B(e)}var O=["binId","targetBin","category","windowIndex","lane","group"];function q(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function C(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function T(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function R(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function D(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?R(e,t):void 0}function A(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Y(t){const e=C(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:C(t.x),y:C(t.y),value:e}}var F=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=A(D(this.config.binAccessor,t,e))??function(t){for(const e of O){const i=A(R(t,e));if(i)return i}return"sediment"}(t),s=A(D(this.config.labelAccessor,t,e))??i,n=function(t,e,i){if("number"==typeof t)return t;const s="function"==typeof t?t(e,i):"string"==typeof t?R(e,t):1,n="number"==typeof s?s:Number(s);return Number.isFinite(n)?n:1}(this.config.valueAccessor,t,e),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let r=this.bins.get(i);return r||(r={id:i,label:s,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,r)),r.label=s,r.lastBodyId=t.id,r.lastDatum=t.datum,q(r.x,t.x),q(r.y,t.y),q(r.value,n),o>0&&(r.bodyIds.push(t.id),r.bodyIds.length>o&&(r.bodyIds=r.bodyIds.slice(r.bodyIds.length-o))),Y(r)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Y)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:T(e.x),y:T(e.y),value:T(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function E(t,e={}){const{baselineY:i=0,binWidth:s=24,gap:n=2,maxHeight:o=80,value:r="count",x:a}=e,d=Math.max(1,...t.map(t=>t[r]));return t.map((t,e)=>{const h=Math.max(0,t[r]/d*o),c=a?.(t,e)??e*(s+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:c,y:i-h,width:s,height:h,meanX:t.x.mean,meanY:t.y.mean}})}function P(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}function L(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),s=e+i,n=P(t.bodyLimit),o=P(t.engineMaxBodiesHint),r=function(t,e,i){if(!1===i)return;const s=P(i?.warnAt);return null!=s?s:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,o,t.options),a=null==n?0:Math.max(0,e-n),d=a>0?"overflow":null==r||r>s?"ok":"warning";return{action:"overflow"!==d?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:o,liveBodies:e,overflow:a,projectedBodies:s,queuedBodies:i,state:d,warnAt:r}}var X={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},N={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function j(t={},e=N){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function K(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function $(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function W(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function H(t,e={}){const i=$(e.startAt)??0,s=e.pacing??"immediate";if("arrival"===s){const s=t.map((t,i)=>function(t,e,i){return"function"==typeof i?$(i(t,e)):"string"==typeof i?$(W(t,i)):$(t.spawnAt)??$(W(t,"arrivalTime"))??$(W(t,"timestamp"))??$(W(t,"time"))??$(W(t,"eventTime"))}(t,i,e.timeAccessor)),n=s.filter(t=>null!=t),o=n.length>0?Math.min(...n):0,r=$(e.timeScale)??1,a=r>0?r:1;return t.map((t,e)=>{const n=s[e],r=null==n?0:Math.max(0,n-o);return{...K(t),spawnAt:i+r/a}})}if("object"==typeof s){const e=$(s.ratePerSec);if(e&&e>0)return t.map((t,s)=>({...K(t),spawnAt:i+s/e}))}return t.map(t=>({...K(t),spawnAt:i}))}function z(t){return{...K(t),sequence:t.sequence,spawnAt:t.spawnAt}}function V(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function G(t){return!1!==t&&{...t}}function U(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function J(t){return{...t,gravity:{...t.gravity}}}function Q(t,e,i,s){if("circle"===t.shape.type){const n=t.x-e,o=t.y-i,r=t.shape.radius+s,a=n*n+o*o;return a>r*r?null:a}const n=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),o=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),r=n*n+o*o;return r>s*s?null:r}function Z(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function _(t,e={}){const{idPrefix:i="plot",includeFloor:s=!0,includeCeiling:n=!1,includeLeftWall:o=!0,includeRightWall:r=!0,wallThickness:a=20,floorThickness:d=a}=e,h=[],c=t.x+t.width/2,l=t.y+t.height/2;return s&&h.push({id:i+"-floor",shape:{type:"aabb",x:c,y:t.y+t.height+d/2,width:t.width+2*a,height:d}}),n&&h.push({id:i+"-ceiling",shape:{type:"aabb",x:c,y:t.y-d/2,width:t.width+2*a,height:d}}),o&&h.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:l,width:a,height:t.height+2*d}}),r&&h.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:l,width:a,height:t.height+2*d}}),h}function tt(t){const{idPrefix:e="bin",count:i,domainStart:s,domainStep:n,xScale:o,yTop:r,yBottom:a,wallThickness:d=4,includeBoundaryWalls:h=!0,includeInteriorWalls:c=!0,closedBefore:l,lidY:u=r,lidThickness:p=Math.max(2,d)}=t,m=[],y=r+(a-r)/2,f=Math.abs(a-r),v=h?i:i-1;if(c||h)for(let t=h?0:1;v>=t;t+=1){if(!c&&t>0&&i>t)continue;const r=o(s+t*n);m.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:r,y:y,width:d,height:f}})}if(null!=l)for(let t=0;i>t;t+=1){const i=s+t*n,r=i+n;if(r>=l)continue;const a=o(i),h=o(r);m.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,h)+d/2,y1:u,x2:Math.max(a,h)-d/2,y2:u,thickness:p}})}return m}import{quadtree as et}from"d3-quadtree";var it=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,s,n,o=0){const r=this.ensure(t,e);if(!r)return null;let a=null,d=1/0;const h=Math.max(0,o)+this.maxSearchRadius,c=s-h,l=s+h,u=n-h,p=n+h;return r.visit((t,e,r,h,m)=>{if(c>h||e>l||u>m||r>p)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=Q(t,s,n,Math.max(0,o));null!=e&&(d>e||e===d&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,d=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=et().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},st=["data","scene-geometry","data-paint","accessibility","evidence"],nt=["scene-geometry","data-paint","accessibility","evidence"],ot=["overlay","accessibility","evidence"],rt=(t,e)=>({retainedData:t,invalidations:e}),at=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dt=["scene-geometry","data-paint","accessibility","evidence"],ht=[],ct={engine:rt("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:rt("preserve",dt),colliders:rt("preserve",dt),sediment:rt("preserve",dt),bodyBudget:rt("preserve",at),bodyLimit:rt("preserve",at),eviction:rt("preserve",at),fixedDt:rt("preserve",ht),maxDeltaSeconds:rt("preserve",ht),maxSubsteps:rt("preserve",ht),settleStepLimit:rt("preserve",ht),timeScale:rt("preserve",ht),observation:rt("preserve",ht)},lt=rt("preserve",at);function ut(t){let e="preserve";const i=new Set;for(const s of t){const t=ct[s]??lt;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var pt=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function mt(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&pt.every(i=>t[i]===e[i])}function yt(t,e,i,s){return t||!e?"paused":i||!s?"running":"settled"}var ft=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(t){this.speed=function(t){const e=t?.sleepSpeed;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:8}(t)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(t,e,i){if(i>0)return void(this.seconds=0);const s=t.readState(this.scratch),n=this.speed*this.speed;let o=!0;for(const t of s)if(!t.sleeping&&t.vx*t.vx+t.vy*t.vy>=n){o=!1;break}this.seconds=o?this.seconds+Math.max(0,e):0}},vt=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new it,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new e,this.simulationState="settled",this.visible=!0,this.quiescence=new ft;const{bodyBudget:i,colliders:s,engine:n,kernel:o,observation:r,sediment:a,...d}=t;this.config={...X,...d},this.configInput={...t},this.bodyBudget=i??{},this.engineInput=n,this.observation=j(r),this.sediment=new F(a??!1),this.world=k(n,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),s&&this.world.setColliders(V(s))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!mt(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:s,engine:n,kernel:o,observation:r,sediment:a,...d}=t;if(this.config={...this.config,...d},void 0!==s&&(this.bodyBudget=s,!1===s&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=k(n,t.options),this.world.restore(t),this.revision+=1}if(o&&!mt(o,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...o,gravity:{...t.options.gravity,...o.gravity}};this.world.restore({...t,options:e}),this.quiescence.setKernelOptions(e),this.revision+=1}r&&(this.observation=j(r,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(V(i)),this.revision+=1),this.configInput={...this.configInput,...t};const h=ut(e);this.updateResults.record({kind:"config",keys:e},h.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(V(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},ut(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],s=e?H(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of s)this.queue.push({...K(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(U),s.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:s.length},s.length?st:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(K(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},st)}materializeDueSpawns(){const t=this.revision,e=[],i=[];return this.spawnDue(e,i),0===e.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:e.length},this.revision!==t?st:[])),e}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},st)}tick(t){const e=this.revision,i=[],s=[],n=[],o=[],r=[];if(this.paused||!this.visible){const t=this.result(0,i,s,n,o,r,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,r);const d=this.observeBodyBudget(r),h=this.evictOverflow(r);s.push(...h.evicted),n.push(...h.sedimented),this.syncSimulationState(r),this.accumulator+=a;let c=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>c;){this.world.step(this.config.fixedDt);const t=this.world.events();o.push(...t),this.observeKernelEvents(t,r),this.observeSensorTransitions(r),this.accumulator-=this.config.fixedDt,c+=1}c===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),this.quiescence.refresh(this.world,a,i.length),(c>0||i.length>0||s.length>0||n.length>0||o.length>0)&&(this.revision+=1);const l=this.result(c,i,s,n,o,r,void 0,d);return this.updateResults.record({kind:"tick",count:c},this.revision!==e?i.length||s.length||n.length?st:nt:[]),l}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?nt:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],s=[],n=[],o=[],r=[];if(this.paused||!this.visible){const t=this.result(0,i,s,n,o,r,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,r);const a=this.observeBodyBudget(r),d=this.evictOverflow(r);s.push(...d.evicted),n.push(...d.sedimented),this.syncSimulationState(r);let h=0;for(i.length>0&&this.quiescence.reset();t>h&&!this.atRest();){this.world.step(this.config.fixedDt);const t=this.world.events();o.push(...t),this.observeKernelEvents(t,r),this.observeSensorTransitions(r),h+=1,this.quiescence.refresh(this.world,this.config.fixedDt,0)}(h>0||i.length>0||s.length>0||n.length>0||o.length>0)&&(this.revision+=1);const c=this.result(h,i,s,n,o,r,void 0,a);return this.updateResults.record({kind:"settle",count:h},this.revision!==e?i.length||s.length||n.length?st:nt:[]),c}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return E(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:i,chartId:s,...n}=t,o={...n,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:s??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?ot:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?ot:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),s=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>i.has(t)||s.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?st:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},nt),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},nt)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},nt)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,s)=>t.applyImpulse(e,i,s),clear:()=>t.clear(),hitTest:(e,i,s)=>t.hitTest(e,i,s),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:G(this.bodyBudget),config:{...this.config,kernel:J(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(z),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:G(t.bodyBudget??{}),kernel:J(t.world.options)},this.bodyBudget=G(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(t.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(z).sort(U),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??yt(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},st)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,s,n,o,r,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const d=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:n,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:r??(this.queue.length>0||!this.atRest()),sleeping:d,sedimented:s,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const s=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=s.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const s=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===s.size&&0===e.size)return s;const n=new Map(t.readState().map(t=>[t.id,t])),o=(t,e)=>{const{sensorId:s,bodyId:o}=Z(e),r=i.observation.sensors[s],a=n.get(o);i.emit({type:"enter"===t?r?.enterType??"physics-bin-enter":r?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:s,binId:r?.binId??s})};for(const t of Array.from(s).sort())e.has(t)||o("enter",t);for(const t of Array.from(e).sort())s.has(t)||o("exit",t);return s}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(Z(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return L({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=yt(this.paused,this.visible,this.queue.length>0,this.atRest());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){const{evicted:e,sedimented:i,liveBodyOrder:s}=function(t,e,i,s,n,o){const r={evicted:[],sedimented:[],liveBodyOrder:n};if(!1===i)return r;const a=Math.max(0,Math.floor(s));if(!Number.isFinite(a))return r;const d=n.length-a;if(0>=d)return r;const h=function(t,e,i){if("sleeping-first"!==e)return i.slice();const s=new Map(t.readState().map(t=>[t.id,t.sleeping])),n=[],o=[];for(const t of i)s.get(t)?n.push(t):o.push(t);return[...n,...o]}(t,i,n),c=h.slice(0,d);if(0===c.length)return r;const l=function(t,e,i,s){const n=new Map(t.readState().map(t=>[t.id,t])),o=[];for(const t of i){const i=n.get(t);if(!i)continue;const r=e.add(i);r&&(o.push(t),s.emit({type:"physics-sediment",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,bodyId:t,datum:i.datum,x:i.x,y:i.y,binId:r.id,count:r.count,total:r.total}))}return o}(t,e,c,o);t.remove(c);const u=new Set(c);return{evicted:c,sedimented:l,liveBodyOrder:n.filter(t=>!u.has(t))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(t));return e.length>0&&(this.liveBodyOrder=s,this.removeActiveSensorPairsForBodies(new Set(e))),{evicted:e,sedimented:i}}};function bt(t,e){if("region-enter"!==e.type)return t;const i=e.region.id,s=t[i]??{id:i,label:e.region.label??i,count:0,bodyIds:[]};if(s.bodyIds.includes(e.bodyId))return t;const n=[...s.bodyIds,e.bodyId];return{...t,[i]:{...s,count:n.length,bodyIds:n}}}function gt(t,e){return(e??Object.keys(t)).map(e=>t[e]).filter(t=>null!=t).map(t=>({label:t.label??t.id,value:t.count}))}function xt(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],s=e.filter(t=>!i.has(t)),n=e.length-s.length,o=t.completion?.mode??"allMembersAbsorbed",r=t.completion?.valueByBodyId,a=t=>{const e=r?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},d=e.reduce((t,e)=>t+a(e),0),h=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),c=t.completion?.threshold,l="threshold"===o?Number.isFinite(c)&&Number(c)>=0?Number(c):d:void 0;return{id:t.id,label:t.label??t.id,mode:o,complete:e.length>0&&("anyAbsorbed"===o?n>0:"threshold"===o?h>=(l??d):0===s.length),absorbed:n,total:e.length,absorbedValue:h,totalValue:d,threshold:l,missing:s}})}function St(t,e,i){return Math.max(e,Math.min(i,t))}function wt(t,e,i={}){const s=i.random??Math.random,n=t.stages.find(t=>t.id===e)??t.stages[t.stages.length-1],o=St(i.along??.5,.05,.95),r=i.jitterX??0,a=i.padY??20,d=n.x0+(n.x1-n.x0)*o+(2*s()-1)*r,h=Math.min(1,n.width/2),c=St(d,n.x0+h,n.x1-h),l=t.boundaryY(c,"top")+a,u=t.boundaryY(c,"bottom")-a;return{x:c,y:u>l?l+s()*Math.max(1,u-l):t.midY}}function It(t){return"bowtie"===t.shape?[{id:"incoming",role:"incoming",points:[[t.left,t.topY],[t.centerLeft,t.pinchTop],[t.centerLeft,t.pinchBottom],[t.left,t.bottomY]]},{id:"center",role:"center",points:[[t.centerLeft,t.pinchTop],[t.centerRight,t.pinchTop],[t.centerRight,t.pinchBottom],[t.centerLeft,t.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[t.centerRight,t.pinchTop],[t.right,t.topY],[t.right,t.bottomY],[t.centerRight,t.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[t.left,t.topY],[t.right,"funnel"===t.shape?t.pinchTop:t.topY],[t.right,"funnel"===t.shape?t.pinchBottom:t.bottomY],[t.left,t.bottomY]]}]}function Mt(t,e,i){return Math.max(e,Math.min(i,t))}function Bt(t,e,i,s,n,o={}){return{id:t,friction:o.friction,restitution:o.restitution,bodyFilter:o.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:s,y2:n,thickness:o.thickness??8}}}function kt(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),s=Math.max(1,Math.round(t.height)),n=t.padX??46,o=t.padY??72,r=n,a=i-n,d=o,h=s-Math.max(24,Math.round(.45*o)),c=(d+h)/2,l=Math.max(1,h-d),u=Mt(t.pinchRatio??.18,.06,.5),p=Number(t.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,y=Mt(l*u+m,.06*l,.5*l),f=y/2,v=c-f,b=c+f,g=t.idPrefix??"process",x=t.friction??.58,S=t.restitution??.18,w=t.wallThickness??8,I=t.stages;if(!I.length)throw Error("processStageLayout requires at least one stage");const M=Mt(t.centerStageIndex??Math.floor(I.length/2),0,I.length-1),B=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(I),k=a-r;let O=r;const q=I.map((t,e)=>{const i=O,s=e===I.length-1?a:O+(t.share??1)/B*k;return O=s,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:s,x:(i+s)/2,width:s-i,y:c,height:l}}),C=q[M],T=C.x0,R=C.x1,D=(t,i)=>{if("lane"===e)return"top"===i?d:h;if("funnel"===e){const e=Mt((t-r)/Math.max(1,a-r),0,1);return"top"===i?d+(v-d)*e:h+(b-h)*e}if(T>=t){const e=Mt((t-r)/Math.max(1,T-r),0,1);return"top"===i?d+(v-d)*e:h+(b-h)*e}if(R>=t)return"top"===i?v:b;const s=Mt((t-R)/Math.max(1,a-R),0,1);return"top"===i?v+(d-v)*s:b+(h-b)*s},A=q.map(t=>{const e=Math.min(D(t.x0,"top"),D(t.x1,"top")),i=Math.max(D(t.x0,"bottom"),D(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),Y={thickness:w,friction:x,restitution:S},F=[];"lane"===e?F.push(Bt(g+"-top",r,d,a,d,Y),Bt(g+"-bottom",r,h,a,h,Y),Bt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Bt(g+"-right",a,d,a,h,{...Y,thickness:Math.max(6,w)})):"funnel"===e?F.push(Bt(g+"-top",r,d,a,v,Y),Bt(g+"-bottom",r,h,a,b,Y),Bt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Bt(g+"-right",a,v,a,b,{...Y,thickness:Math.max(6,w)})):F.push(Bt(g+"-left-top",r,d,T,v,Y),Bt(g+"-left-bottom",r,h,T,b,Y),Bt(g+"-center-top",T,v,R,v,Y),Bt(g+"-center-bottom",T,b,R,b,Y),Bt(g+"-right-top",R,v,a,d,Y),Bt(g+"-right-bottom",R,b,a,h,Y),Bt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Bt(g+"-right",a,d,a,h,{...Y,thickness:Math.max(6,w)}));const E=t.membraneDampingScale??.5,P=r,L=Math.max(1,("bowtie"===e?T:a)-P),X=(t.membranes??[]).map(t=>{const e=P+Mt(t.offset,0,1)*L,i=t.width??18+18*t.cost,s=l-16,n=c+.25*(t.wobble??0);return{...t,x:e,y:n,width:i,height:s}}),N=!1===t.includeMembraneRegions?[]:X.map(t=>Ct({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??E,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:s,padX:n,padY:o,left:r,right:a,topY:d,bottomY:h,midY:c,centerLeft:T,centerRight:R,pinchHeight:y,pinchTop:v,pinchBottom:b,stages:A,membranes:X,colliders:F,regionEffects:N,boundaryY:D}}function Ot(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,s=t.width,n=t.height,{type:"aabb",x:e,y:i,width:s,height:n}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,s,n}function qt(t,e={}){const i=e.idPrefix??"stage",s=Math.max(0,e.insetX??0),n=Math.max(0,e.insetY??1);return t.stages.map(t=>{const o="function"==typeof e.metadata?e.metadata(t):e.metadata??{};return{...Ot({id:i?`${i}:${t.id}`:t.id,label:t.label??t.id,description:t.description,kind:"region",x:t.x,y:t.y,width:Math.max(1,t.width-2*s),height:Math.max(1,t.height-2*n),bodyFilter:e.bodyFilter,semanticItem:e.semanticItem,attributes:{primitive:"processStage",stageId:t.id,stageIndex:t.index},metadata:{...o,primitive:"processStage",stageId:t.id,stageIndex:t.index}})}})}function Ct(t){const e=t.dampingScale??.5,i=t.energyScale??1,s=Mt(t.cost,0,2);return{...Ot({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:s,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:s*e,energyDelta:-s*i}}function Tt(t){return{...Ot({...t,kind:t.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),charge:t.charge??!0,energyDelta:t.energyDelta,impulseOnEnter:t.impulseOnEnter}}function Rt(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Dt(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,s=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Ot({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*s,energyDelta:n?-e*n:void 0,force:t.force}}function At(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}function Yt(t){return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"portal",targetStage:t.targetStage,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,impulseOnEnter:t.impulseOnEnter,damping:t.damping??.08}}function Ft(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Ot({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}function Et(t){return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}function Pt(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}function Lt(t){const e=t.idPrefix??"lane",i={thickness:t.thickness??8,friction:t.friction??.5,restitution:t.restitution??.16},s=[Bt(e+"-top",t.left,t.top,t.right,t.top,i),Bt(e+"-bottom",t.left,t.bottom,t.right,t.bottom,i)];return t.openEnds||s.push(Bt(e+"-left",t.left,t.top,t.left,t.bottom,i),Bt(e+"-right",t.right,t.top,t.right,t.bottom,i)),s}export{M as BuiltInPhysicsEngineAdapter,B as createDefaultPhysicsEngineAdapter,F as PhysicsSedimentAccumulator,E as sedimentHeightfield,L as evaluatePhysicsBodyBudget,H as schedulePhysicsSpawns,_ as collidersFromPlotBounds,tt as collidersFromXScaleBins,vt as PhysicsPipelineStore,bt as aggregateRegionCounts,gt as regionCountsToProjectionRows,xt as groupCompletionRows,wt as stageTargetInVolume,It as processVolumePolygons,kt as processStageLayout,qt as processStageRegions,Ct as membraneRegion,Tt as chargeGateRegion,Rt as routeSurfaceRegion,Dt as pressureFieldRegion,At as capacitatedRegion,Yt as portalRegion,Ft as absorbRegion,Et as forceFieldRegion,Pt as bodyGroupSpec,Lt as processLaneWalls};