semiotic 3.8.3 → 3.8.5

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 (215) hide show
  1. package/CLAUDE.md +13 -10
  2. package/README.md +52 -45
  3. package/ai/componentMetadata.cjs +1 -1
  4. package/ai/dist/mcp-server.js +4 -2
  5. package/ai/examples.md +168 -1
  6. package/ai/schema.json +3756 -327
  7. package/ai/surface-manifest.json +6 -4
  8. package/ai/system-prompt.md +1 -1
  9. package/dist/chunk-chartContainerDataAudit-74TLKIP6.module.min.js +2 -0
  10. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +0 -1
  11. package/dist/chunk-chunk-4AANPFOX.module.min.js +2 -0
  12. package/dist/{chunk-chunk-JNCHKRIR.module.min.js → chunk-chunk-5I3UZV4Q.module.min.js} +1 -1
  13. package/dist/chunk-chunk-74CCPVXB.module.min.js +1 -0
  14. package/dist/{chunk-chunk-VVCA3DB7.module.min.js → chunk-chunk-7ALTGHK6.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ACLDBMRH.module.min.js +2 -0
  16. package/dist/chunk-chunk-AVBI6GDT.module.min.js +1 -0
  17. package/dist/{chunk-chunk-XQYVEKEJ.module.min.js → chunk-chunk-BANTPINB.module.min.js} +1 -1
  18. package/dist/chunk-chunk-C4YA6TDR.module.min.js +1 -0
  19. package/dist/chunk-chunk-C57LR3YG.module.min.js +1 -0
  20. package/dist/chunk-chunk-CKMD5NV3.module.min.js +2 -0
  21. package/dist/chunk-chunk-CO5KQMGH.module.min.js +1 -0
  22. package/dist/chunk-chunk-CWQ5YIHX.module.min.js +2 -0
  23. package/dist/chunk-chunk-E6TXX6MI.module.min.js +1 -0
  24. package/dist/{chunk-chunk-7FW6EGLP.module.min.js → chunk-chunk-I36PJ4OC.module.min.js} +1 -1
  25. package/dist/chunk-chunk-IY7RYD4S.module.min.js +1 -0
  26. package/dist/chunk-chunk-K3DMEW22.module.min.js +1 -0
  27. package/dist/chunk-chunk-KT2VAZMZ.module.min.js +1 -0
  28. package/dist/{chunk-chunk-AZJUDQRM.module.min.js → chunk-chunk-L6EA5V3G.module.min.js} +1 -1
  29. package/dist/{chunk-chunk-SANERMIZ.module.min.js → chunk-chunk-LJLS6DY7.module.min.js} +1 -1
  30. package/dist/chunk-chunk-LJPCLYSC.module.min.js +2 -0
  31. package/dist/chunk-chunk-LRIFN2HK.module.min.js +1 -0
  32. package/dist/chunk-chunk-N5DDKCCF.module.min.js +1 -0
  33. package/dist/chunk-chunk-NEVE562N.module.min.js +1 -0
  34. package/dist/chunk-chunk-NLO44TOS.module.min.js +2 -0
  35. package/dist/{chunk-chunk-FYY2ACNJ.module.min.js → chunk-chunk-PRDGLMJT.module.min.js} +1 -1
  36. package/dist/chunk-chunk-PZJ2SBLL.module.min.js +2 -0
  37. package/dist/chunk-chunk-QUJ6TTLY.module.min.js +1 -0
  38. package/dist/chunk-chunk-RBIDBUT4.module.min.js +2 -0
  39. package/dist/chunk-chunk-RFLAG356.module.min.js +1 -0
  40. package/dist/chunk-chunk-RPU4IZAV.module.min.js +2 -0
  41. package/dist/chunk-chunk-SKMBCFIL.module.min.js +2 -0
  42. package/dist/chunk-chunk-TAE7W424.module.min.js +2 -0
  43. package/dist/{chunk-chunk-OQTLSTGI.module.min.js → chunk-chunk-TMWIZL3K.module.min.js} +1 -1
  44. package/dist/chunk-chunk-TUBMTZMU.module.min.js +2 -0
  45. package/dist/chunk-chunk-UFFEXJQY.module.min.js +1 -0
  46. package/dist/chunk-chunk-XSCHTS4D.module.min.js +2 -0
  47. package/dist/chunk-chunk-XXWSHGPL.module.min.js +2 -0
  48. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +1 -0
  49. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +2 -0
  50. package/dist/chunk-minimapBrushOverlay-JU57U7NM.module.min.js +2 -0
  51. package/dist/chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js +2 -0
  52. package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +1 -0
  53. package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +1 -0
  54. package/dist/components/ChartContainer.d.ts +12 -2
  55. package/dist/components/ai/chartCapabilities.d.ts +2 -1
  56. package/dist/components/ai/chartCapabilityTypes.d.ts +19 -0
  57. package/dist/components/chartContainerDataAudit.d.ts +10 -0
  58. package/dist/components/charts/geo/ChoroplethMap.d.ts +2 -0
  59. package/dist/components/charts/geo/DistanceCartogram.d.ts +35 -5
  60. package/dist/components/charts/geo/FlowMap.d.ts +4 -0
  61. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +3 -1
  62. package/dist/components/charts/index.d.ts +1 -0
  63. package/dist/components/charts/network/ForceDirectedGraph.d.ts +36 -1
  64. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +6 -1
  65. package/dist/components/charts/physics/CrucibleChart.capability.d.ts +8 -0
  66. package/dist/components/charts/physics/CrucibleChart.d.ts +63 -0
  67. package/dist/components/charts/physics/GaltonBoardChart.d.ts +6 -1
  68. package/dist/components/charts/physics/crucibleBodyRenderers.d.ts +27 -0
  69. package/dist/components/charts/physics/crucibleChartProps.d.ts +90 -0
  70. package/dist/components/charts/physics/crucibleChrome.d.ts +47 -0
  71. package/dist/components/charts/physics/crucibleController.d.ts +59 -0
  72. package/dist/components/charts/physics/crucibleEffects.d.ts +30 -0
  73. package/dist/components/charts/physics/cruciblePhysics.d.ts +54 -0
  74. package/dist/components/charts/physics/crucibleProgram.d.ts +38 -0
  75. package/dist/components/charts/physics/crucibleTypes.d.ts +415 -0
  76. package/dist/components/charts/physics/gauntletChartProps.d.ts +7 -1
  77. package/dist/components/charts/physics/gauntletChrome.d.ts +2 -1
  78. package/dist/components/charts/physics/gauntletPhysics.d.ts +19 -4
  79. package/dist/components/charts/physics/gauntletRuntime.d.ts +3 -0
  80. package/dist/components/charts/physics/physicsHocUtils.d.ts +12 -0
  81. package/dist/components/charts/shared/chartMode.d.ts +8 -0
  82. package/dist/components/charts/shared/chartSpecCore.d.ts +10 -2
  83. package/dist/components/charts/shared/crucibleWireSchema.d.ts +5 -0
  84. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  85. package/dist/components/charts/shared/hatchPattern.d.ts +8 -3
  86. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  87. package/dist/components/charts/shared/lineSeriesSsr.d.ts +55 -0
  88. package/dist/components/charts/shared/types.d.ts +2 -2
  89. package/dist/components/charts/shared/validateProps.d.ts +1 -1
  90. package/dist/components/charts/xy/AreaChart.d.ts +10 -0
  91. package/dist/components/charts/xy/minimapBrushOverlay.d.ts +17 -0
  92. package/dist/components/charts/xy/minimapBrushOverlayLazy.d.ts +4 -0
  93. package/dist/components/charts/xy/scatterplotMatrixBrushOverlay.d.ts +8 -0
  94. package/dist/components/charts/xy/scatterplotMatrixBrushOverlayLazy.d.ts +3 -0
  95. package/dist/components/data/auditData.d.ts +51 -0
  96. package/dist/components/data/dataAuditPresentation.d.ts +18 -0
  97. package/dist/components/data/dataAuditSources.d.ts +9 -0
  98. package/dist/components/data/numericContracts.d.ts +59 -0
  99. package/dist/components/data/numericFieldProfiler.d.ts +23 -0
  100. package/dist/components/realtime/types.d.ts +5 -0
  101. package/dist/components/recipes/gridObservatory.d.ts +176 -0
  102. package/dist/components/recipes/netEnsembleLayout.d.ts +167 -0
  103. package/dist/components/recipes/netEnsembleOverlays.d.ts +20 -0
  104. package/dist/components/recipes/recipeChrome.d.ts +24 -0
  105. package/dist/components/recipes/sequenceLayout.d.ts +139 -0
  106. package/dist/components/recipes/wordTrails.d.ts +156 -0
  107. package/dist/components/recipes/wordTrailsProgressiveReveal.d.ts +42 -0
  108. package/dist/components/semiotic-ai-core.d.ts +3 -0
  109. package/dist/components/semiotic-ai-data-audit.d.ts +4 -0
  110. package/dist/components/semiotic-ai.d.ts +7 -5
  111. package/dist/components/semiotic-physics.d.ts +1 -0
  112. package/dist/components/semiotic-recipes-core.d.ts +10 -2
  113. package/dist/components/semiotic-utils-core.d.ts +3 -0
  114. package/dist/components/semiotic.d.ts +1 -1
  115. package/dist/components/server/renderEvidence.d.ts +27 -0
  116. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  117. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  118. package/dist/components/server/staticAnnotations.d.ts +15 -1
  119. package/dist/components/stream/GeoPipelineStore.d.ts +1 -0
  120. package/dist/components/stream/GeoSVGOverlay.d.ts +7 -0
  121. package/dist/components/stream/SceneToSVG.d.ts +6 -6
  122. package/dist/components/stream/SceneToSVGOrdinal.d.ts +12 -0
  123. package/dist/components/stream/geoCartogram.d.ts +7 -0
  124. package/dist/components/stream/geoTypes.d.ts +17 -2
  125. package/dist/components/stream/networkFrameHandleTypes.d.ts +4 -0
  126. package/dist/components/stream/networkFramePaint.d.ts +2 -0
  127. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +18 -2
  128. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +8 -0
  129. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +7 -0
  130. package/dist/components/stream/physics/physicsPipelineEviction.d.ts +15 -0
  131. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +1 -1
  132. package/dist/components/stream/physics/physicsPipelineQuiescence.d.ts +20 -0
  133. package/dist/components/stream/sceneToSVGShared.d.ts +30 -1
  134. package/dist/components/stream/types.d.ts +4 -0
  135. package/dist/components/stream/useHydration.d.ts +7 -1
  136. package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +1 -1
  137. package/dist/components/useChartContainerDataAudit.d.ts +7 -0
  138. package/dist/forceLayoutWorker.js +1 -1
  139. package/dist/geo.min.js +1 -1
  140. package/dist/geo.module.min.js +1 -1
  141. package/dist/network.min.js +1 -1
  142. package/dist/network.module.min.js +1 -1
  143. package/dist/ordinal.min.js +1 -1
  144. package/dist/ordinal.module.min.js +1 -1
  145. package/dist/physics.min.js +1 -1
  146. package/dist/physics.module.min.js +1 -1
  147. package/dist/physicsWorker.js +1 -1
  148. package/dist/realtime.min.js +1 -1
  149. package/dist/realtime.module.min.js +1 -1
  150. package/dist/rough.min.js +1 -1
  151. package/dist/rough.module.min.js +1 -1
  152. package/dist/semiotic-ai-core.d.ts +3 -0
  153. package/dist/semiotic-ai-core.min.js +1 -1
  154. package/dist/semiotic-ai-core.module.min.js +1 -1
  155. package/dist/semiotic-ai.d.ts +7 -5
  156. package/dist/semiotic-ai.min.js +1 -1
  157. package/dist/semiotic-ai.module.min.js +1 -1
  158. package/dist/semiotic-experimental.min.js +1 -1
  159. package/dist/semiotic-experimental.module.min.js +1 -1
  160. package/dist/semiotic-physics.d.ts +1 -0
  161. package/dist/semiotic-realtime-core.min.js +1 -1
  162. package/dist/semiotic-realtime-core.module.min.js +1 -1
  163. package/dist/semiotic-recipes-core.d.ts +10 -2
  164. package/dist/semiotic-recipes-core.min.js +1 -1
  165. package/dist/semiotic-recipes-core.module.min.js +1 -1
  166. package/dist/semiotic-recipes.min.js +1 -1
  167. package/dist/semiotic-recipes.module.min.js +1 -1
  168. package/dist/semiotic-server-edge.min.js +1 -1
  169. package/dist/semiotic-server-edge.module.min.js +1 -1
  170. package/dist/semiotic-server-node.min.js +1 -1
  171. package/dist/semiotic-server-node.module.min.js +1 -1
  172. package/dist/semiotic-utils-core.d.ts +3 -0
  173. package/dist/semiotic-utils-core.min.js +1 -1
  174. package/dist/semiotic-utils-core.module.min.js +1 -1
  175. package/dist/semiotic-utils.min.js +1 -1
  176. package/dist/semiotic-utils.module.min.js +1 -1
  177. package/dist/semiotic-value.module.min.js +1 -1
  178. package/dist/semiotic.d.ts +1 -1
  179. package/dist/semiotic.min.js +1 -1
  180. package/dist/semiotic.module.min.js +1 -1
  181. package/dist/server.min.js +1 -1
  182. package/dist/server.module.min.js +1 -1
  183. package/dist/xy.min.js +1 -1
  184. package/dist/xy.module.min.js +1 -1
  185. package/package.json +4 -3
  186. package/dist/chunk-chunk-255KDHW5.module.min.js +0 -1
  187. package/dist/chunk-chunk-2CCFBTQC.module.min.js +0 -2
  188. package/dist/chunk-chunk-2RXP3FS3.module.min.js +0 -1
  189. package/dist/chunk-chunk-2WVCH4PL.module.min.js +0 -1
  190. package/dist/chunk-chunk-4TMZXLCR.module.min.js +0 -1
  191. package/dist/chunk-chunk-5APBQXZA.module.min.js +0 -1
  192. package/dist/chunk-chunk-6HSGDMTA.module.min.js +0 -2
  193. package/dist/chunk-chunk-7OEOSCBP.module.min.js +0 -1
  194. package/dist/chunk-chunk-A63CTACR.module.min.js +0 -2
  195. package/dist/chunk-chunk-B6V35LMY.module.min.js +0 -2
  196. package/dist/chunk-chunk-BOSVL645.module.min.js +0 -2
  197. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +0 -1
  198. package/dist/chunk-chunk-F25UA5HT.module.min.js +0 -1
  199. package/dist/chunk-chunk-FRIO6MCV.module.min.js +0 -1
  200. package/dist/chunk-chunk-GWSWSPXN.module.min.js +0 -1
  201. package/dist/chunk-chunk-I6C3KR5H.module.min.js +0 -2
  202. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  203. package/dist/chunk-chunk-J3ELI22J.module.min.js +0 -1
  204. package/dist/chunk-chunk-J5RL6GXU.module.min.js +0 -2
  205. package/dist/chunk-chunk-L3H6DQCR.module.min.js +0 -2
  206. package/dist/chunk-chunk-M337NY6L.module.min.js +0 -1
  207. package/dist/chunk-chunk-M7VYYHCE.module.min.js +0 -2
  208. package/dist/chunk-chunk-MC35ILYP.module.min.js +0 -2
  209. package/dist/chunk-chunk-N72SWNBV.module.min.js +0 -1
  210. package/dist/chunk-chunk-OBQRFTIL.module.min.js +0 -2
  211. package/dist/chunk-chunk-QRIBHZYW.module.min.js +0 -1
  212. package/dist/chunk-chunk-SA3D43RA.module.min.js +0 -2
  213. package/dist/chunk-chunk-UHSZEB74.module.min.js +0 -1
  214. package/dist/chunk-chunk-Y6AXCRVO.module.min.js +0 -1
  215. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +0 -2
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{MobileStandardControls as e,auditVisualizationControls as t}from"./chunk-chunk-RCF52Z42.module.min.js";import{resolveAccessor as i,resolveRawAccessor as n}from"./chunk-chunk-L6EA5V3G.module.min.js";import{filterAnnotationsByStatus as r}from"./chunk-chunk-XXWSHGPL.module.min.js";import{DataSummaryProvider as o,LinkedCharts as a,annotationStableId as s,resolveResponsiveRules as l,useChartObserver as c,useDataSummaryToggle as d,useLinkedChartsActive as u,useObservationSelector as m,useSelection as p}from"./chunk-chunk-CWQ5YIHX.module.min.js";import{getMinMax as h}from"./chunk-chunk-JJ2OOIET.module.min.js";import{ChartErrorBoundary as f}from"./chunk-chunk-ACLDBMRH.module.min.js";async function g(e,t){const{format:i="png",filename:n="chart",scale:r=2,background:o="white"}=t||{},a=e.querySelector("svg");if(!a)throw Error("No SVG element found in the container");const s=a.cloneNode(!0),l=a.getBoundingClientRect();if(s.getAttribute("width")||s.setAttribute("width",l.width+""),s.getAttribute("height")||s.setAttribute("height",l.height+""),s.getAttribute("xmlns")||s.setAttribute("xmlns","http://www.w3.org/2000/svg"),b(a,s),"svg"===i){const e=(new XMLSerializer).serializeToString(s);y(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const t=l.width*r,i=l.height*r,a=document.createElement("canvas");a.width=t,a.height=i;const c=a.getContext("2d");c.fillStyle=o,c.fillRect(0,0,t,i),c.scale(r,r);const d=e.querySelector("canvas");d&&c.drawImage(d,0,0,l.width,l.height);const u=(new XMLSerializer).serializeToString(s),m=new Blob([u],{type:"image/svg+xml;charset=utf-8"}),p=URL.createObjectURL(m),h=new Image;h.width=l.width,h.height=l.height,await new Promise((e,t)=>{h.onload=()=>{c.drawImage(h,0,0),a.toBlob(i=>{i?(y(i,n+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(p)},h.onerror=()=>{URL.revokeObjectURL(p),t(Error("Failed to load SVG image"))},h.src=p})}}function b(e,t){const i=e.children,n=t.children,r=window.getComputedStyle(e),o=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of o){const i=r.getPropertyValue(e);i&&"none"!==i&&""!==i&&t.style?.setProperty(e,i)}for(let e=0;Math.min(i.length,n.length)>e;e++)b(i[e],n[e])}function y(e,t){const i=URL.createObjectURL(e),n=document.createElement("a");n.href=i,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(i)}function v(e){return x(e),e}function x(e){if(!e||"object"!=typeof e)throw Error("Chart recipe must be an object.");if("string"!=typeof e.id||""===e.id.trim())throw Error("Chart recipe requires a non-empty id.");if("string"!=typeof e.name||""===e.name.trim())throw Error(`Chart recipe "${e.id}" requires a non-empty name.`);if(!Array.isArray(e.dataRoles)||0===e.dataRoles.length)throw Error(`Chart recipe "${e.id}" requires at least one data role.`);if(!Array.isArray(e.intents)||0===e.intents.length)throw Error(`Chart recipe "${e.id}" requires at least one intent.`);for(const t of e.intents)if("string"!=typeof t&&(!t||"string"!=typeof t.id&&"string"!=typeof t.name))throw Error(`Chart recipe "${e.id}" has an intent without an id or name.`);if(!e.designContract?.whyCustom)throw Error(`Chart recipe "${e.id}" requires designContract.whyCustom.`);if(!e.accessibility||"object"!=typeof e.accessibility)throw Error(`Chart recipe "${e.id}" requires accessibility expectations.`);if(void 0!==e.controls){const i=t({controls:e.controls}).findings.filter(e=>"fail"===e.status);if(i.length>0)throw Error(`Chart recipe "${e.id}" has invalid controls: ${i.map(e=>e.message).join(" ")}`)}if("portable"===e.portability){if(!w(e.layout))throw Error(`Portable chart recipe "${e.id}" must reference a registered layout by id.`);const t=e.layoutConfigSchema??e.portabilityConfig?.schema;if(!t)throw Error(`Portable chart recipe "${e.id}" requires a serializable layout config schema.`);if(!k(t))throw Error(`Portable chart recipe "${e.id}" has a layout config schema that is not JSON-safe.`)}}function w(e){return!!e&&"object"==typeof e&&"string"==typeof e.id}function k(e,t=new Set){if(null===e)return!0;const i=typeof e;if("string"===i||"boolean"===i)return!0;if("number"===i)return Number.isFinite(e);if("object"!==i)return!1;if(t.has(e))return!1;t.add(e);const n=Array.isArray(e)?e.every(e=>k(e,t)):Object.entries(e).every(([,e])=>k(e,t));return t.delete(e),n}function $(e){return"string"==typeof e?e:e.id??e.name}function C(e){return"string"==typeof e?3:"number"==typeof e.score&&Number.isFinite(e.score)?Math.max(0,Math.min(5,e.score>1?e.score:5*e.score)):"primary"===e.strength?5:"secondary"===e.strength?3:"supporting"===e.strength?2:3}function S(e){const t=new Set(e.intents.map($));return t.has("geo")?"geo":t.has("hierarchy")?"hierarchy":t.has("flow")?"flow":t.has("relationship")?"network":t.has("distribution")?"distribution":t.has("correlation")?"relationship":t.has("trend")||t.has("composition-over-time")?"time-series":t.has("compare-categories")||t.has("rank")||t.has("part-to-whole")?"categorical":"custom"}function A(e){const t=Object.values(e.audience?.familiarity??{}),i=t.find(e=>"number"==typeof e);if(void 0!==i)return Math.max(1,Math.min(5,Math.round(i)));const n=t.filter(e=>"string"==typeof e);return n.includes("high")?4:n.includes("medium")?3:n.includes("low")?2:e.reception?.memorableForm?3:2}function j(e,t){return"nodes"===t?e.network?.nodes??[]:"edges"===t?e.network?.edges??[]:"areas"===t?e.geo?.features??[]:"points"===t?e.geo?.points??[]:"lines"===t?e.geo?.flows??[]:e.data}function N(e,t,i){return j(e,t.source).some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,i))}function I(e,t,i){if(t.field&&N(i,t,t.field))return t.field;if("nodes"===t.source||"edges"===t.source){const e="node-id"===t.role?"id":"edge-source"===t.role?"source":"edge-target"===t.role?"target":void 0;if(e&&N(i,t,e))return e}switch(t.semanticType){case"quantitative":return i.primary.y??i.primary.size??i.primary.x;case"temporal":return i.primary.time??i.primary.x;case"nominal":case"ordinal":return i.primary.category??i.primary.series;case"identifier":{const e=j(i,t.source);return["id","key","name"].find(t=>e.some(e=>null!=e&&Object.prototype.hasOwnProperty.call(e,t)))}case"geographic":return i.hasGeo?t.field:void 0;default:return t.field}}function L(e){const t={},i=[];for(const n of e.intents){const e=$(n);e&&(t[e]=C(n),"string"!=typeof n&&n.rationale&&i.push(n.rationale))}i.push(...(e.reception?.strengths??[]).map(e=>"Reception strength: "+e));const n=e.reception?.risks??[],r=e.designContract.misuse??[],o=[...e.designContract.caveats??[],...e.caveats??[]];return{component:e.id,displayName:e.name,candidateKind:"recipe",family:S(e),renderingFamily:e.frameFamily,importPath:"semiotic/ai",rubric:{familiarity:A(e),accuracy:4,precision:n.some(e=>/precis|comparison/i.test(e))?2:3},fits:t=>function(e,t){for(const i of e.dataRoles)if(!1!==i.required&&!I(0,i,t))return`needs data role "${i.role}" (${i.semanticType})`;const i=e.audit?.maxCategories;return"number"==typeof i&&"number"==typeof t.categoryCount&&t.categoryCount>i?`${t.categoryCount} categories exceeds this recipe's declared maximum of ${i}`:null}(e,t),intentScores:t,caveats:()=>[...n,...r,...o],buildProps:t=>function(e,t){const i={};for(const n of e.dataRoles){const e=I(0,n,t);e&&n.accessor&&(i[n.accessor]=e)}const n={recipeId:e.id,layoutConfig:i};e.frameFamily.startsWith("Network")?(n.nodes=t.network?.nodes??t.data,n.edges=t.network?.edges??[]):e.frameFamily.startsWith("Geo")?(n.areas=t.geo?.features??[],n.points=t.geo?.points??t.data,n.lines=t.geo?.flows??[]):n.data=t.data;const r=e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0);return r&&(n.mobileSemantics=r),n}(e,t),mobile:e.mobile??("number"==typeof e.accessibility.minimumHitTarget?{minimumHitTarget:e.accessibility.minimumHitTarget}:void 0),recipe:e,positiveRationale:i,whyCustom:{defaultAlternative:e.designContract.defaultAlternative,reason:e.designContract.whyNotDefault??e.designContract.whyCustom,tradeoff:e.designContract.tradeoff??(n.length>0?n[0]:void 0)}}}var P=Symbol.for("semiotic.chartRecipeRegistry");function R(){const e=globalThis;return e[P]||(e[P]={recipes:new Map,capabilities:new Map,layouts:new Map}),e[P]}function M(e){x(e),R().recipes.set(e.id,e),R().capabilities.set(e.id,L(e))}function B(e){R().recipes.delete(e),R().capabilities.delete(e)}function z(e){return R().recipes.get(e)}function T(){return Array.from(R().recipes.values())}function F(){return Array.from(R().capabilities.values())}function D(){return R().capabilities.size>0}function E(e,t){if(!e)throw Error("Recipe layout requires a non-empty id.");if("function"!=typeof t)throw Error(`Recipe layout "${e}" must be a function.`);R().layouts.set(e,t)}function O(e){R().layouts.delete(e)}function H(e){return R().layouts.get(e)}function W(e){return"string"==typeof e?z(e):e&&"object"==typeof e&&"string"==typeof e.id?e:void 0}var V=["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","RidgelinePlot","DotPlot","PieChart","DonutChart","GaugeChart","FunnelChart","SwimlaneChart","LikertChart","LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","BubbleChart","Heatmap","QuadrantChart","MultiAxisLineChart","CandlestickChart","ConnectedScatterplot","ScatterplotMatrix","MinimapChart","ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram","TreeDiagram","Treemap","CirclePack","OrbitDiagram","ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram","RealtimeLineChart","RealtimeHistogram","TemporalHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","GaltonBoardChart","EventDropChart","PhysicsPileChart","CollisionSwarmChart","GauntletChart","CrucibleChart","ProcessFlowChart","PhysicalFlowChart","BigNumber"],G=new Set(V);function U(e){return G.has(e)}function q(e){return"string"==typeof e?e:e.id??e.name}function J(e){return e.layoutConfig&&"object"==typeof e.layoutConfig?e.layoutConfig:{}}function X(e){return Array.isArray(e.data)?e.data:Array.isArray(e.nodes)?e.nodes:Array.isArray(e.points)?e.points:Array.isArray(e.areas)?e.areas:[]}function _(e,t,i){return i??W(t.recipe)??W(t.recipeId)??z(e)}function Q(e,t,i=[]){const n=e.accessor?t[e.accessor]:void 0;if("string"==typeof n&&n)return n;if(e.field)return e.field;const r=i.find(e=>e&&"object"==typeof e);if(!r)return;const o=Object.entries(r).filter(([e,t])=>!e.startsWith("_")&&null!=t);return"quantitative"===e.semanticType?o.find(([,e])=>"number"==typeof e)?.[0]:"identifier"===e.semanticType?["id","key","name"].find(e=>e in r):o.find(([,e])=>"string"==typeof e)?.[0]}function K(e,t){return e.dataRoles.find(e=>e.role===t)}function Z(e,t){return e.dataRoles.find(e=>t.includes(e.semanticType))}function Y(e,t,i,n,r,o={}){const a={...o};if(t)for(const[e,i]of Object.entries(t))a[e]=i;for(const e of i.dataRoles){const i=Q(e,n,r),o=t&&i?t[i]:i;void 0!==o&&(a[e.role]=o)}return e.replace(/\{([^}]+)\}/g,(e,t)=>{const i=a[t];return null==i?`{${t}}`:i+""})}var ee=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend","recipe","layout"]),te=new Set(["data","nodes","edges","points","areas","lines","flows"]);function ie(e){if(null==e)return e;if("function"==typeof e)return;if("object"!=typeof e)return e;if(e.$$typeof)return;if(Array.isArray(e))return e.map(ie).filter(e=>void 0!==e);if(e instanceof Date)return e;const t={};for(const[i,n]of Object.entries(e)){if("function"==typeof n)continue;if(n&&"object"==typeof n&&n.$$typeof)continue;const e=ie(n);void 0!==e&&(t[i]=e)}return t}function ne(e,t){return!!te.has(e)&&("areas"!==e||"string"!=typeof t)}var re="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function oe(e,t,i){const n=z(e)??W(t.recipe)??W(t.recipeId);if(n)return function(e,t,i){const n=function(e,t,i){const n={};for(const[r,o]of Object.entries(e))if(null!=o&&!ee.has(r)&&"recipeId"!==r&&(t||!ne(r,o)))if("function"==typeof o||o?.$$typeof){if(i)throw Error(`Portable recipe prop "${r}" is not JSON-safe.`)}else if(k(o))n[r]=re(o);else if(i)throw Error(`Portable recipe prop "${r}" is not JSON-safe.`);return n}(t,!1!==i?.includeData,"portable"===e.portability),r=e.intents.map(q).filter(e=>!!e),o={name:e.name,intents:r,...e.audience?.primary?{audience:[e.audience.primary]}:{},frameFamily:e.frameFamily};if("portable"===e.portability){if(!k(n))throw Error(`Portable recipe "${e.id}" contains non-JSON-safe props or layoutConfig.`);return{component:"ChartRecipe",recipeId:e.id,portable:!0,props:n,manifest:o,version:"1",createdAt:(new Date).toISOString(),...i?.selections?{selections:i.selections}:{}}}return{component:"ChartRecipe",recipeId:e.id,portable:!1,reason:"Recipe contains or may depend on non-serializable local layout callbacks.",warnings:["This config is inspectable but cannot be rendered remotely by CLI or MCP."],props:n,manifest:o,version:"1",createdAt:(new Date).toISOString(),...i?.selections?{selections:i.selections}:{}}}(n,t,i);if(!U(e))throw Error(`Unknown component "${e}". Known components: ${V.join(", ")}`);const r=!1!==i?.includeData,o={};for(const[e,i]of Object.entries(t))if(null!=i&&!ee.has(e)&&(r||!ne(e,i))&&"function"!=typeof i&&!i?.$$typeof)try{o[e]=re(ie(i))}catch{}return{component:e,props:o,version:"1",createdAt:(new Date).toISOString(),...i?.selections?{selections:i.selections}:{}}}function ae(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if("ChartRecipe"===e.component||"LocalChartRecipe"===e.component){if(!e.recipeId)throw Error("Invalid chart recipe config: missing recipeId");const t=z(e.recipeId);if(!t)throw Error(`Unknown chart recipe "${e.recipeId}". Register it before deserializing this config.`);if("LocalChartRecipe"!==e.component&&!1!==e.portable&&"portable"!==t.portability)throw Error(`Chart recipe "${e.recipeId}" is registered as local, not portable.`);return{componentName:"ChartRecipe",props:{...re(e.props),recipeId:e.recipeId}}}if(!U(e.component))throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:re(e.props)}}function se(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function le(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const i=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(escape(atob(i)));return JSON.parse(n)}async function ce(e,t="json"){const i="jsx"===t?de(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");await navigator.clipboard.writeText(i)}function de(e){const{props:t}=e,i=["<"+("LocalChartRecipe"===e.component?"ChartRecipe":e.component)];e.recipeId&&i.push(` recipeId="${e.recipeId}"`);for(const[e,n]of Object.entries(t))if("string"==typeof n)i.push(` ${e}="${n}"`);else if("boolean"==typeof n&&!0===n)i.push(" "+e);else if("boolean"==typeof n&&!1===n)i.push(` ${e}={false}`);else if("number"==typeof n)i.push(` ${e}={${n}}`);else{const t=JSON.stringify(n);i.push(80>t.length?` ${e}={${t}}`:` ${e}={${JSON.stringify(n,null,2)}}`)}return i.push("/>"),i.join("\n")}function ue(e){const t={};for(const[i,n]of e){const e=[];for(const[,t]of n.clauses){const i={};for(const[e,n]of Object.entries(t.fields))i[e]="point"===n.type?{type:"point",values:Array.from(n.values)}:{type:"interval",range:n.range};e.push({clientId:t.clientId,type:t.type,fields:i})}t[i]={name:n.name,resolution:n.resolution,clauses:e}}return t}function me(e){const t=new Map;for(const[i,n]of Object.entries(e)){const e=new Map;for(const t of n.clauses){const i={};for(const[e,n]of Object.entries(t.fields))i[e]="point"===n.type?{type:"point",values:new Set(n.values)}:{type:"interval",range:n.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:i})}t.set(i,{name:n.name,resolution:n.resolution,clauses:e})}return t}function pe(e){return"nominal"===e||"ordinal"===e}function he(e){return"quantitative"===e||"temporal"===e}var fe={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},ge={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},be={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function ye(e){e=function(e){if(!function(e){return e.usermeta?.idid}(e)||!Array.isArray(e.layer))return e;const t=e.layer.filter(e=>!function(e){return"annotation-layer"===e.usermeta?.idid?.role}(e));if(1!==t.length)return e;const{layer:i,...n}=e,{usermeta:r,...o}=t[0];return{...n,...o}}(e);const t=[],{type:i,markProps:n}=function(e){if(!e)return{type:"",markProps:{}};if("string"==typeof e)return{type:e,markProps:{}};const{type:t,...i}=e;return{type:t,markProps:i}}(e.mark),r=e.encoding||{},o=r.x,a=r.y,s=r.color,l=r.size,c=r.theta,d=r.opacity;let u;e.data?.values?u=e.data.values:e.data?.url&&t.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&t.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&t.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&t.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||r.facet||r.row||r.column)&&t.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&t.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&t.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const m={};e.width&&(m.width=e.width),e.height&&(m.height=e.height);const p=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(p&&(m.title=p),s?.field&&(m.colorBy=s.field,s.scale?.scheme)){const e=fe[s.scale.scheme];e&&(m.colorScheme=e)}void 0!==d?.value&&(m.pointOpacity=d.value);const f=o?.aggregate,g=a?.aggregate;if(u&&(f||g)){const e=g?a:o,t=g?o:a,i=be[e.aggregate];if(i&&t?.field&&e.field)u=function(e,t){const{groupBy:i,value:n,agg:r="sum"}=t,o=new Map;for(const t of e){const e=t[i]+"";o.has(e)||o.set(e,[]),o.get(e).push(Number(t[n]))}const a=[];for(const[e,t]of o){let n;switch(r){case"count":n=t.length;break;case"mean":n=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":n=h(t)[0];break;case"max":n=h(t)[1];break;default:n=t.reduce((e,t)=>e+t,0)}a.push({[i]:e,value:n})}return a}(u,{groupBy:t.field,value:e.field,agg:i});else if(("count"===i||"count"===e.aggregate)&&t?.field&&u){const e=new Map;for(const i of u){const n=i[t.field]+"";e.set(n,(e.get(n)||0)+1)}u=Array.from(e,([e,i])=>({[t.field]:e,value:i}))}}if(o?.bin||a?.bin){const e="Histogram";u&&(m.data=u),o?.bin?(m.valueAccessor=o.field,a?.field&&(m.categoryAccessor=a.field),o.axis?.title&&(m.valueLabel=o.axis.title)):a?.bin&&(m.valueAccessor=a.field,o?.field&&(m.categoryAccessor=o.field),a.axis?.title&&(m.valueLabel=a.axis.title));const i=o?.bin||a?.bin,n="object"==typeof i?i.maxbins:void 0;return n&&(m.bins=n),xe(e,m,t)}let b;switch(i){case"bar":b=function(e,t,i,n,r,o,a){let s;return i?.field&&!1!==e?.stack&&!1!==t?.stack&&null!==e?.stack&&null!==t?.stack?(s="StackedBarChart",n.stackBy=i.field):s="BarChart",pe(e?.type)&&he(t?.type)?(n.categoryAccessor=e.field,n.valueAccessor=a?"value":t.field,e?.axis?.title&&(n.categoryLabel=e.axis.title),t?.axis?.title&&(n.valueLabel=t.axis.title)):he(e?.type)&&pe(t?.type)?(n.categoryAccessor=t.field,n.valueAccessor=o?"value":e.field,n.orientation="horizontal",t?.axis?.title&&(n.categoryLabel=t.axis.title),e?.axis?.title&&(n.valueLabel=e.axis.title)):(e?.field&&(n.categoryAccessor=e.field),t?.field&&(n.valueAccessor=a?"value":t.field),e?.axis?.title&&(n.categoryLabel=e.axis.title),t?.axis?.title&&(n.valueLabel=t.axis.title)),r&&(n.data=r),s}(o,a,s,m,u,f,g);break;case"line":if(b="LineChart",ve(o,a,m,f,g),s?.field&&(m.lineBy=s.field),n.interpolate){const e=ge[n.interpolate];e&&(m.curve=e)}!0===n.point&&(m.showPoints=!0),u&&(m.data=u);break;case"area":if(s?.field?(b="StackedAreaChart",m.areaBy=s.field):b="AreaChart",ve(o,a,m,f,g),n.interpolate){const e=ge[n.interpolate];e&&(m.curve=e)}void 0!==n.opacity&&(m.areaOpacity=n.opacity),u&&(m.data=u);break;case"point":case"circle":case"square":l?.field?(b="BubbleChart",m.sizeBy=l.field,l.scale?.range&&(m.sizeRange=l.scale.range)):b="Scatterplot",ve(o,a,m,f,g),u&&(m.data=u);break;case"rect":b="Heatmap",o?.field&&(m.xAccessor=o.field),a?.field&&(m.yAccessor=a.field),s?.field&&(m.valueAccessor=s.field,delete m.colorBy),o?.axis?.title&&(m.xLabel=o.axis.title),a?.axis?.title&&(m.yLabel=a.axis.title),u&&(m.data=u);break;case"arc":n.innerRadius&&n.innerRadius>0?(b="DonutChart",m.innerRadius=n.innerRadius):b="PieChart",c?.field?m.valueAccessor=c.field:a?.field&&(m.valueAccessor=g?"value":a.field),s?.field&&(m.categoryAccessor=s.field),o?.field&&!c?.field&&(m.categoryAccessor=o.field),u&&(m.data=u);break;case"tick":b="DotPlot",pe(o?.type)?(m.categoryAccessor=o.field,a?.field&&(m.valueAccessor=g?"value":a.field),o?.axis?.title&&(m.categoryLabel=o.axis.title),a?.axis?.title&&(m.valueLabel=a.axis.title)):pe(a?.type)?(m.categoryAccessor=a.field,o?.field&&(m.valueAccessor=f?"value":o.field),m.orientation="horizontal",a?.axis?.title&&(m.categoryLabel=a.axis.title),o?.axis?.title&&(m.valueLabel=o.axis.title)):(o?.field&&(m.categoryAccessor=o.field),a?.field&&(m.valueAccessor=g?"value":a.field)),u&&(m.data=u);break;default:t.push(`Unsupported mark type "${i}". Defaulting to Scatterplot.`),b="Scatterplot",ve(o,a,m,f,g),u&&(m.data=u)}return xe(b,m,t)}function ve(e,t,i,n,r){e?.field&&(i.xAccessor=n?"value":e.field),t?.field&&(i.yAccessor=r?"value":t.field),e?.axis?.title&&(i.xLabel=e.axis.title),t?.axis?.title&&(i.yLabel=t.axis.title)}function xe(e,t,i){const n={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(i.length>0){n.warnings=i;for(const e of i)console.warn("[semiotic/fromVegaLite] "+e)}return n}function we(e,t,i={}){const n=X(t),r=J(t),o=i.locale??"en",a="function"==typeof e.description?e.description({data:n,config:r,locale:o}):void 0,s=a?.levels??function(e,t,i,n){const r=Z(e,["nominal","ordinal"]),o=Z(e,["quantitative"]),a=r?Q(r,i,t):void 0,s=o?Q(o,i,t):void 0,l=r?.role??a??"category",c=o?.role??s??"value",d=e.encodings??[],u=d.length?d.slice(0,3).map(e=>e.meaning.replace(/\.$/,"")).join("; "):`${l} and ${c} are mapped through the recipe's declared visual semantics`,{number:m,percent:p}=function(e){try{return{number:new Intl.NumberFormat(e,{maximumFractionDigits:2}),percent:new Intl.NumberFormat(e,{style:"percent",maximumFractionDigits:1})}}catch{return{number:new Intl.NumberFormat("en",{maximumFractionDigits:2}),percent:new Intl.NumberFormat("en",{style:"percent",maximumFractionDigits:1})}}}(n),h=new Map;if(a&&s)for(const e of t){const t=(e[a]??"Uncategorized")+"",i=Number(e[s]);Number.isFinite(i)&&h.set(t,(h.get(t)??0)+i)}const f=[...h].sort((e,t)=>t[1]-e[1]),g=f.reduce((e,[,t])=>e+t,0),b=f[0],y=f[1],v=g>0?((b?.[1]??0)+(y?.[1]??0))/g:0,x=e.intents.map(e=>({id:q(e),strength:"string"==typeof e?void 0:e.strength})).sort((e,t)=>"primary"===e.strength?-1:"primary"===t.strength?1:0)[0]?.id,w=e.audience?.primary??e.audienceFit?.find(e=>"strong"===e.fit)?.audience;return{l1:`A ${e.name.toLowerCase()} encodes ${l} and ${c}. ${k=u,k?k.charAt(0).toUpperCase()+k.slice(1):k}.`,l2:f.length>0?`${f.length} categories total ${m.format(g)}. ${b[0]} accounts for ${m.format(b[1])}${g>0?` (${p.format(b[1]/g)})`:""}${y?`, followed by ${y[0]} at ${m.format(y[1])}`:""}.`:`${t.length} data ${1===t.length?"item is":"items are"} represented.`,l3:2>f.length?b?b[0]+" is the only represented category.":"No quantitative pattern can be derived from the available data.":.5>v?`The total is distributed across ${f.length} categories without the first two forming a majority.`:`Most of the total is concentrated in ${b[0]} and ${y[0]}, which together account for ${p.format(v)}.`,l4:`The chart is intended for ${x??"explanation"}${w?` with a ${w} audience`:""}: ${e.designContract.whyCustom}`};var k}(e,n,r,o),l=i.levels??["l1","l2","l3","l4"],c={};for(const e of l)s[e]&&(c[e]=s[e]);const d=["l1","l2","l3","l4"].map(e=>c[e]).filter(e=>!!e).join(" "),u=i.includeCaveats?[...e.reception?.risks??[],...e.caveats??[],...(e.designContract.misuse??[]).map(e=>"Misuse: "+e)]:void 0;return{text:d,levels:c,...u?.length?{caveats:u}:{}}}var ke=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),$e=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),Ce=new Set(["PieChart","DonutChart","FunnelChart"]),Se=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function Ae(e,t){return $e.has(e)||Ce.has(e)||"SwimlaneChart"===e||"GaugeChart"===e?{measure:t.valueAccessor,measureFallback:"value",dimension:t.categoryAccessor??t.stepAccessor,dimensionFallback:"category"}:{measure:t.yAccessor??t.valueAccessor,measureFallback:"y",dimension:t.xAccessor,dimensionFallback:"x"}}function je(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const i=e[t];if("string"==typeof i&&i)return i}}function Ne(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}var Ie={LineChart:"line chart",AreaChart:"area chart",StackedAreaChart:"stacked area chart",DifferenceChart:"difference chart",Scatterplot:"scatter plot",BubbleChart:"bubble chart",ConnectedScatterplot:"connected scatter plot",QuadrantChart:"quadrant chart",MultiAxisLineChart:"dual-axis line chart",CandlestickChart:"candlestick chart",Heatmap:"heatmap",MinimapChart:"line chart",BarChart:"bar chart",StackedBarChart:"stacked bar chart",GroupedBarChart:"grouped bar chart",DotPlot:"dot plot",Histogram:"histogram",BoxPlot:"box plot",ViolinPlot:"violin plot",RidgelinePlot:"ridgeline plot",SwarmPlot:"swarm plot",PieChart:"pie chart",DonutChart:"donut chart",FunnelChart:"funnel chart",GaugeChart:"gauge",LikertChart:"Likert chart",SwimlaneChart:"swimlane chart",ForceDirectedGraph:"network graph",SankeyDiagram:"Sankey diagram",ProcessSankey:"temporal Sankey diagram",ChordDiagram:"chord diagram",TreeDiagram:"tree diagram",Treemap:"treemap",CirclePack:"circle-packing chart",OrbitDiagram:"orbit diagram",ChoroplethMap:"choropleth map",ProportionalSymbolMap:"proportional-symbol map",FlowMap:"flow map",DistanceCartogram:"distance cartogram",BigNumber:"single value",StreamPhysicsFrame:"physics stream frame",EventDropChart:"event-drop physics chart",GaltonBoardChart:"Galton board chart",PhysicsPileChart:"physics pile chart",CollisionSwarmChart:"collision swarm chart",PhysicalFlowChart:"physical flow chart",ProcessFlowChart:"process flow physics chart",CrucibleChart:"crucible physics chart",PhysicsCustomChart:"custom physics chart"},Le=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]),Pe=new Set(["StreamPhysicsFrame","EventDropChart","GaltonBoardChart","PhysicsPileChart","CollisionSwarmChart","PhysicalFlowChart","ProcessFlowChart","GauntletChart","CrucibleChart","PhysicsCustomChart"]);function Re(e){return Ie[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}function Me(e){const t="number"==typeof e?e:"string"==typeof e?Number(e):NaN;return Number.isFinite(t)?t:void 0}var Be=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),ze={"outlier-detection":"alerting","change-detection":"alerting",trend:"tracking","composition-over-time":"apportioning","compare-series":"comparing","compare-categories":"comparing",rank:"ranking","part-to-whole":"apportioning",distribution:"characterizing",correlation:"relating",flow:"tracing",hierarchy:"nesting",geo:"locating"},Te={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},Fe=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],De={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function Ee(e){return ze[e]}function Oe(e,t){const i=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,i={};for(const[e,n]of Object.entries(t.intentScores))"number"==typeof n&&Number.isFinite(n)&&(i[e]=n);return{family:t.family,intentScores:Object.keys(i).length?i:void 0}}return e}}(t);if(i?.act)return i.act;if(i?.intentScores){const e=function(e){let t,i=0;for(const[n,r]of Object.entries(e))if("number"==typeof r&&r>0)if(r>i)t=n,i=r;else if(r===i&&void 0!==t){const e=Fe.indexOf(n),i=Fe.indexOf(t);-1===e||-1!==i&&e>=i||(t=n)}return t}(i.intentScores);if(e&&ze[e]&&(i.intentScores[e]??0)>=3)return ze[e]}return i?.family?Te[i.family]:function(e){return Ce.has(e)||"StackedAreaChart"===e?"apportioning":Be.has(e)?"relating":$e.has(e)?"comparing":Se.has(e)?"characterizing":ke.has(e)?"tracking":Le.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}var He=new Set(["y-threshold","x-threshold","band","x-band","callout","label"]),We=new Set(["system","agent","watcher"]),Ve=new Set(["ai","agent","system","computed","dbt","great-expectations"]),Ge=new Set(["rule","statistical-test","llm-inference","computed"]);function Ue(e){const t=e.annotations;return!!Array.isArray(t)&&t.some(e=>{if(!e||"object"!=typeof e)return!1;const t=e;if("string"!=typeof t.type||!He.has(t.type))return!1;const i=t.provenance;return!(!i||"object"!=typeof i)&&(We.has(i.authorKind)||Ve.has(i.source)||Ge.has(i.basis))})}function qe(e="en"){let t,i;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),i=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch{t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),i=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?i.format(e):t.format(e):e+""}var Je={"y-threshold":"a threshold line","x-threshold":"a threshold line",band:"a highlighted band","x-band":"a highlighted band",label:"a label",callout:"a callout","callout-circle":"a callout","callout-rect":"a callout",text:"a text note",bracket:"a bracket",enclose:"an enclosure","rect-enclose":"an enclosure",highlight:"a highlight",widget:"a widget",trend:"a trend line",envelope:"an envelope","anomaly-band":"an anomaly band",forecast:"a forecast","category-highlight":"a category highlight"};function Xe(e){const t=Je["string"==typeof e.type?e.type:"annotation"]||"an annotation",i=function(e){const t=e.provenance&&"object"==typeof e.provenance?e.provenance:null,i=t?.authorKind??t?.source??t?.basis;return"watcher"===i?"a watcher-flagged ":"agent"===i||"ai"===i||"llm-inference"===i?"an AI-suggested ":""}(e),n=i?i+t.replace(/^an? /,""):t,r="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return r?`${n} labeled "${r}"`:n}function _e(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const i=r(t.filter(e=>!!e&&"object"==typeof e));if(0===i.length)return;const n=i.map(Xe),o=n.slice(0,5),a=n.length-o.length,s=function(e){return e.length>1?2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`:e[0]??""}(o)+(a>0?`, and ${a} more`:""),l=i.length;return`The author has marked ${1===l?"one feature":l+" features"} on this chart: ${s}.`}function Qe(e,t,r={}){const o=void 0!==r.levels,a=new Set(r.levels??["l1","l2","l3"]);o||!r.capability&&!Ue(t)||a.add("l4");const s=_(e,t,r.recipe);if(s){const e=["l1","l2","l3","l4"].filter(e=>a.has(e));o||e.includes("l4")||e.push("l4");const i=we(s,t,{levels:e,locale:r.locale,audience:r.audience,includeCaveats:r.includeCaveats}),n=_e(t);return{...i,text:n?`${n} ${i.text}`.trim():i.text,...n?{annotations:n}:{}}}const l=qe(r.locale??"en"),c=Re(e),d=Array.isArray(t.data)?t.data:null,u=je(t),m=Pe.has(e)?function(e,t){const i=e.physics&&"object"==typeof e.physics?e.physics:null,n=e.settledProjection&&"object"==typeof e.settledProjection?e.settledProjection:null,r=[e.settledProjectionRows,e.projectionRows,n?.rows,i?.settledProjectionRows,i?.projectionRows,i?.settledProjection&&"object"==typeof i.settledProjection?i.settledProjection.rows:void 0].find(e=>Array.isArray(e));return Array.isArray(r)?r.map((e,i)=>{if(!e||"object"!=typeof e)return null;const n=e,r=Me(n.count??n.value??n.total??n.bodies??n.events);if(null==r)return null;const o=n.label??n.id??n.name??"container "+(i+1),a=Me(n.secondary??n.secondaryCount),s=Me(n.observed??n.observedCount);return{label:Ne(o,t),count:r,...null!=a?{secondary:a}:{},..."string"==typeof n.secondaryLabel&&n.secondaryLabel?{secondaryLabel:n.secondaryLabel}:{},...null!=s?{observed:s}:{}}}).filter(e=>null!=e):null}(t,l):null,{measure:p,measureFallback:h,dimension:f,dimensionFallback:g}=Ae(e,t),b="string"==typeof p&&p?p:h,y="string"==typeof f&&f?f:g,v={};if(Pe.has(e)&&function(e,t,i,n,r,o){const a=function(e){return"EventDropChart"===e?"time window":"GaltonBoardChart"===e?"bin":"CollisionSwarmChart"===e?"group lane":"PhysicalFlowChart"===e?"flow node":"CrucibleChart"===e?"result group":"container"}(e),s=function(e){return"EventDropChart"===e?"event":"GaltonBoardChart"===e?"sample":"CollisionSwarmChart"===e?"point":"PhysicalFlowChart"===e?"packet":"CrucibleChart"===e?"settled item":"body"}(e);if(r.has("l1")&&(n.l1=function(e,t){return"EventDropChart"===e?"An event-drop physics chart that collapses moving events into a settled projection by event-time window.":"GaltonBoardChart"===e?"A Galton board chart that collapses falling samples into a settled histogram projection.":"PhysicsPileChart"===e?"A physics pile chart that collapses moving bodies into a settled bar-style projection by container.":"CollisionSwarmChart"===e?"A collision swarm chart that separates overlapping points while preserving their quantitative axis position.":"PhysicalFlowChart"===e?"A physical flow chart that keeps authored routes visible while packet bodies show throughput and proximity events.":"CrucibleChart"===e?"A crucible physics chart that replays authored phases and events into declared products and outlets; the settled ledger, not collisions, determines the result.":`A ${t} whose accessible reading is the settled projection rather than individual trajectories.`}(e,t)),!r.has("l2")&&!r.has("l3"))return;if(!i||0===i.length)return void(r.has("l2")&&(n.l2="No settled projection is loaded yet."));const l=i.reduce((e,t)=>e+t.count,0),c=i.filter(e=>e.count>0).sort((e,t)=>t.count-e.count),d=c[0]??i.slice().sort((e,t)=>t.count-e.count)[0];if(!d)return;const u=i.reduce((e,t)=>e+(t.secondary??0),0),m=i.find(e=>e.secondaryLabel)?.secondaryLabel??"secondary";if(r.has("l2"))if(0===c.length)n.l2=`The settled projection contains ${o(l)} ${Ze(l,s)} across ${i.length} ${Ze(i.length,a)}; no ${Ze(2,a)} are non-empty yet.`;else{const e=u>0?` ${o(u)} ${Ze(u,s)} ${1===u?"is":"are"} marked ${m}.`:"";n.l2=`The settled projection contains ${o(l)} ${Ze(l,s)} across ${i.length} ${Ze(i.length,a)}; ${c.length} ${Ze(c.length,a)} ${1===c.length?"is":"are"} non-empty. The largest ${a} is ${d.label} with ${o(d.count)} ${Ze(d.count,s)}.${e}`}if(r.has("l3")&&l>0&&c.length>0){const e=c.find(e=>e!==d),t=function(e,t){if(0>=t)return"0%";const i=e/t*100;return(10>i?Math.round(10*i)/10:Math.round(i))+"%"}(d.count,l);n.l3=e?`The settled projection is most concentrated in ${d.label}, which holds ${o(d.count)} ${Ze(d.count,s)} (${t}); ${e.label} follows with ${o(e.count)} ${Ze(e.count,s)}.`:`The settled projection is concentrated in ${d.label}, which holds all ${o(d.count)} ${Ze(d.count,s)}.`}}(e,c,m,v,a,l),a.has("l1")&&!Pe.has(e))if(ke.has(e)||$e.has(e))v.l1=`A ${c} of ${b} by ${y}`+(u?`, split by ${u}.`:".");else if(Ce.has(e))v.l1=`A ${c} showing ${b} across ${y} categories.`;else if(Se.has(e))v.l1=`A ${c} of the distribution of ${b}`+(u?` by ${u}.`:".");else if(Le.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,i=Array.isArray(t.edges)?t.edges.length:void 0,n=[null!=e?`${e} ${Ze(e,"node")}`:null,null!=i?`${i} ${Ze(i,"edge")}`:null].filter(Boolean);v.l1=`A ${c}${n.length?" with "+n.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:b;v.l1=`A single value${e?" for "+e:""}.`}else v.l1=`A ${c}.`;const x=ke.has(e)||$e.has(e)||Ce.has(e)||Se.has(e);let w=null;if((a.has("l2")||a.has("l3")||a.has("l4"))&&x&&d&&d.length>0&&(w=function(e,t,i,n){let r=0,o=0,a=1/0,s=-1/0,l=null,c=null,d=0,u=0,m=null,p=null,h=NaN,f=NaN;for(const i of e){const e=t(i);Number.isFinite(e)&&(0===r&&(h=e,m=i),f=e,p=i,a>e&&(a=e,l=i,d=r),e>s&&(s=e,c=i,u=r),r++,o+=e)}return 0===r?null:{count:r,min:a,max:s,mean:o/r,minLabel:Ne(null!=l?i(l):null,n),maxLabel:Ne(null!=c?i(c):null,n),first:h,last:f,firstLabel:Ne(null!=m?i(m):null,n),lastLabel:Ne(null!=p?i(p):null,n),minIndex:d,maxIndex:u}}(d,i(p,h),n(f,g),l)),a.has("l2")&&x&&(d&&0!==d.length?w&&(v.l2=Ce.has(e)?`${w.count} segments totaling ${l(function(e){return e.mean*e.count}(w))}. Largest is ${w.maxLabel} at ${l(w.max)}; smallest is ${w.minLabel} at ${l(w.min)}.`:`${b} ranges from ${l(w.min)} (${w.minLabel}) to ${l(w.max)} (${w.maxLabel}), with a mean of ${l(w.mean)} across ${w.count} points.`):v.l2="No data is loaded yet."),a.has("l3")&&w&&!u&&ke.has(e)?v.l3=function(e,t,i){const{first:n,last:r,min:o,max:a,maxLabel:s,minLabel:l,firstLabel:c,lastLabel:d,minIndex:u,maxIndex:m,count:p}=e,h=a-o,f=r-n;if(0===h)return`${Ke(t)} is constant at ${i(n)} across the series.`;if(.04>h/(Math.abs(e.mean)||1))return`${Ke(t)} ends roughly where it started (${i(n)} at ${c} to ${i(r)} at ${d}), ranging between ${i(o)} and ${i(a)}.`;const g=m>0&&p-1>m,b=u>0&&p-1>u,y=(a-Math.max(n,r))/h,v=(Math.min(n,r)-o)/h;return g&&y>.15?`Overall ${t} climbs to a peak of ${i(a)} (${s}), then falls to ${i(r)} (${d}).`:b&&v>.15?`Overall ${t} drops to a low of ${i(o)} (${l}), then recovers to ${i(r)} (${d}).`:.05>Math.abs(f)/h?`${Ke(t)} ends roughly where it started (${i(n)} at ${c} to ${i(r)} at ${d}), ranging between ${i(o)} and ${i(a)}.`:f>0?m===p-1?`Overall ${t} rises from ${i(n)} (${c}) to a peak of ${i(r)} (${d}).`:`Overall ${t} rises from ${i(n)} (${c}) to ${i(r)} (${d}), after peaking at ${i(a)} (${s}).`:u===p-1?`Overall ${t} falls from ${i(n)} (${c}) to a low of ${i(r)} (${d}).`:`Overall ${t} falls from ${i(n)} (${c}) to ${i(r)} (${d}), after dipping to ${i(o)} (${l}).`}(w,b,l):a.has("l3")&&w&&!u&&$e.has(e)&&(v.l3=`The highest ${y} is ${w.maxLabel} and the lowest is ${w.minLabel}.`),a.has("l4")){const i=Ue(t)?"alerting":Oe(e,r.capability);i&&(v.l4=function(e,t,i,n,r,o,a,s){const l=De[e],c=/^[aeiou]/i.test(l)?"an":"a";let d,u;switch(e){case"locating":d="This is a map",u="read values by location";break;case"presenting":d="This is a single-value display",u=`read ${"string"==typeof i.label&&i.label?i.label:r} as the headline number`;break;case"tracing":d=`This is ${c} ${l} chart`,u="follow the movement between states";break;case"nesting":d=`This is ${c} ${l} chart`,u="read it for nested structure and how children sum into their parents";break;case"relating":d=`This is ${c} ${l} chart`,u=`read it for whether ${o} and ${r} move together`;break;default:d=`This is ${c} ${l} chart`,u=function(e,t,i,n,r,o){if(!t)switch(e){case"alerting":return"watch for points that break from the rest";case"tracking":return"read it for the overall direction of "+i;case"comparing":return`compare ${i} across ${n}`;case"ranking":return"read it top to bottom by "+i;case"apportioning":return`read each ${n}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+i;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,i){if($e.has(i)||Ce.has(i))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:n,last:r,min:o,max:a,minLabel:s,maxLabel:l,lastLabel:c,minIndex:d,maxIndex:u,count:m}=e,p=a-o;if(p>0){const e=u>0&&m-1>u,i=d>0&&m-1>d,h=(a-Math.max(n,r))/p,f=(Math.min(n,r)-o)/p;if(e&&h>.15)return`the peak of ${t(a)} at ${l} is the point to investigate`;if(i&&f>.15)return`the dip to ${t(o)} at ${s} is the point to investigate`;if(r>=a)return`the climb to ${t(r)} at ${c} warrants a closer look`;if(o>=r)return`the drop to ${t(r)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(a)}) and ${s} (${t(o)}) — are the points to check`}(t,r,o);case"tracking":return`read it for the trajectory of ${i}, which ${function(e){const t=e.max-e.min,i=e.last-e.first;return 0===t||.05>Math.abs(i)/t?"holds roughly steady":i>0?"rises":"falls"}(t)} from ${r(t.first)} (${t.firstLabel}) to ${r(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${i} across ${n}; ${t.maxLabel} leads at ${r(t.max)}`;case"ranking":return`read it top to bottom by ${i}; ${t.maxLabel} ranks highest at ${r(t.max)}`;case"apportioning":{const e=t.mean*t.count,i=e>0?Math.round(t.max/e*100):null;return`read each ${n}'s share of the ${r(e)} total; ${t.maxLabel} is the largest at ${r(t.max)}${null!=i?` (${i}%)`:""}`}case"characterizing":return`read it for the spread of ${i}, from ${r(t.min)} to ${r(t.max)}`;default:return"read the highlighted features"}}(e,n,r,o,a,t)}return`${d}; ${u}.${function(e,t){if(!t)return"";const i=t.familiarity?.[e];return"number"!=typeof i||i>2?"":` This ${Re(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,s)}`}(i,e,t,u?null:w,b,y,l,r.audience))}const k=["l1","l2","l3","l4"].filter(e=>a.has(e)&&v[e]).map(e=>v[e]).join(" "),$=_e(t);return{text:$?`${$} ${k}`.trim():k,levels:v,...$?{annotations:$}:{}}}function Ke(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function Ze(e,t){return 1!==e&&"body"===t?"bodies":1===e?t:t+"s"}function Ye(e){return((e??"unknown")+"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"unknown"}function et(e,t,i={}){const n=X(t),r=J(t),o=Math.max(1,i.maxLeaves??200);if("function"==typeof e.navigation)return e.navigation({data:n,config:r,locale:i.locale??"en"});const a=(s=e.navigation)&&"object"==typeof s?e.navigation:void 0;var s;const l=(a?.groupByRole?K(e,a.groupByRole):void 0)??(a?.groupBy?.[0]?K(e,a.groupBy[0])??e.dataRoles.find(e=>e.field===a.groupBy?.[0]):void 0)??Z(e,["nominal","ordinal"]),c=l?Q(l,r,n):void 0,d=(a?.idRole?K(e,a.idRole):void 0)??Z(e,["identifier"]),u=d?Q(d,r,n):void 0,m={id:"root",role:"chart",label:a?.summaryTemplate?Y(a.summaryTemplate,void 0,e,r,n,{count:n.length}):`${e.name}: ${n.length} ${1===n.length?"item":"items"} represented.`,level:1,children:[]};let p=0;const h=(t,i,o)=>{const s=u?t[u]:void 0,l=a?.itemLabelTemplate?Y(a.itemLabelTemplate,t,e,r,n,{count:n.length}):function(e,t,i,n){const r=Z(t,["nominal","ordinal"]),o=t.dataRoles.filter(e=>"quantitative"===e.semanticType),a=r?Q(r,i,n):void 0,s=[];a&&null!=e[a]&&s.push(e[a]+"");for(const t of o){const r=Q(t,i,n);r&&null!=e[r]&&s.push(`${t.role}: ${e[r]+""}`)}return s.length>0?s.join(", "):"Data item"}(t,e,r,n);return{id:"datum-"+Ye(s??i),role:"datum",label:l,level:o,datum:t}};if(c){const e=new Map;for(const t of n){const i=(t[c]??"Uncategorized")+"",n=e.get(i);n?n.push(t):e.set(i,[t])}m.children=[...e].map(([e,t],i)=>{const n=t.slice(0,Math.max(0,o-p));p+=n.length;const r=n.map((e,t)=>h(e,1e5*i+t,3));return t.length>n.length&&r.push({id:"more-"+Ye(e),role:"datum",label:`…and ${t.length-n.length} more items`,level:3}),{id:"group-"+Ye(e),role:"series",label:`${e}: ${t.length} ${1===t.length?"item":"items"}.`,level:2,children:r}})}else{const e=n.slice(0,o);m.children=e.map((e,t)=>h(e,t,2)),n.length>e.length&&m.children.push({id:"more",role:"datum",label:`…and ${n.length-e.length} more items`,level:2})}return m}function tt(e,t,o={}){const a=o.locale??"en",s=Math.max(1,o.maxLeaves??200),l=qe(a),c=_(e,t,o.recipe);if(c)return et(c,t,{maxLeaves:s,locale:a});const d={id:"root",role:"chart",label:Qe(e,t,{locale:a}).text||"Chart.",level:1,children:[]},u=function(e,t){const i=Array.isArray(e.annotations)?e.annotations:null;if(!i)return null;const n=r(i.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return null;let o=0;const a=n.slice(0,t).map(e=>{const t=e.lifecycle?.status,i=t&&"accepted"!==t?` (${t})`:"";return{id:"annotation-"+o++,role:"annotation",level:3,label:`${n=Xe(e),n?n.charAt(0).toUpperCase()+n.slice(1):n}${i}.`,datum:e};var n});n.length>t&&a.push({id:"annotation-"+o++,role:"annotation",level:3,label:`…and ${n.length-t} more annotations.`});const s=n.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===s?"one marked feature":s+" marked features"}.`,children:a}}(t,s),m=Array.isArray(t.data)?t.data:null,p=ke.has(e)||$e.has(e)||Ce.has(e)||Se.has(e);if(!m||0===m.length||!p)return u&&(d.children=[u]),d;const{measure:h,measureFallback:f,dimension:g,dimensionFallback:b}=Ae(e,t),y=i(h,f),v=n(g,b),x="string"==typeof h&&h?h:f,w="string"==typeof g&&g?g:b,k=je(t);let $=0;const C=e=>`${e}-${$++}`,S=(e,t)=>{const i=e.slice(0,s).map(e=>((e,t)=>{const i=y(e),n=Ne(v(e),l);return{id:C("datum"),role:"datum",level:t,label:`${n}: ${Number.isFinite(i)?l(i):"—"}`,value:Number.isFinite(i)?i:void 0,datum:e}})(e,t));return e.length>s&&i.push({id:C("more"),role:"datum",level:t,label:`…and ${e.length-s} more points`}),i},A=[];if(ke.has(e)||$e.has(e)){let t=1/0,i=-1/0,n=1/0,r=-1/0;const o=[];let a=!0;for(const e of m){const s=y(e);Number.isFinite(s)&&(t>s&&(t=s),s>i&&(i=s));const l=v(e);o.push(l),"number"==typeof l&&Number.isFinite(l)?(n>l&&(n=l),l>r&&(r=l)):a=!1}const s=new Set,c=[];for(const e of o){const t=e+"";s.has(t)||(s.add(t),c.push(e))}const d=a?`${l(n)} to ${l(r)}`:`${Ne(c[0],l)} to ${Ne(c[c.length-1],l)} (${$e.has(e)?c.length+" categories":m.length+" points"})`;A.push({id:C("axis"),role:"axis",level:2,label:`${$e.has(e)?"Category axis":"X axis"}: ${w}, ${d}.`}),t>i||A.push({id:C("axis"),role:"axis",level:2,label:`Value axis: ${x}, ${l(t)} to ${l(i)}.`})}if(k){const i=n(k,k),r=new Map;for(const e of m){const t=(i(e)??"—")+"",n=r.get(t);n?n.push(e):r.set(t,[e])}const o=[];for(const[i,n]of r){const r=Qe(e,{...t,data:n},{levels:["l2","l3"],locale:a}).text;o.push({id:C("series"),role:"series",level:2,label:`Series ${i}: ${r}`,children:S(n,3)})}d.children=[...A,...o]}else d.children=[...A,...S(m,2)];return u&&d.children.push(u),d}function it(e,t){const i=[],n=e=>{if(i.push(e),e.children&&e.children.length>0&&t.has(e.id))for(const t of e.children)n(t)};return n(e),i}function nt(e){let t=1;if(e.children)for(const i of e.children)t+=nt(i);return t}var rt=null,ot=new Set,at=new Set,st=1e3;function lt(e,t,i){const n=e??t;if(!Number.isFinite(n)||0>=n)throw new RangeError(`${i} must be a positive number, got ${n+""}`);return Math.floor(n)}function ct(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function dt(e,t){try{const i=t();i&&"function"==typeof i.then&&Promise.resolve(i).catch(t=>ct(e,t))}catch(t){ct(e,t)}}function ut(e){if(e)return e;try{return globalThis.localStorage??null}catch{return null}}function mt(e,t){if(!e)return[];try{return function(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return ct("localStorage load",e),[]}}(e.getItem(t))}catch(e){return ct("localStorage read",e),[]}}var pt=Object.freeze([]),ht=pt,ft=!1;function gt(){return ft?(ht=rt?Object.freeze(rt.buffer.slice()):pt,ft=!1,ht):ht}function bt(){ft=!0}var yt=new Set;function vt(){for(const e of yt)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function xt(e){return yt.add(e),()=>{yt.delete(e)}}function wt(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return at.add(e),()=>{at.delete(e)}}function kt(e={}){const t=e.key??"semiotic:conversation-arc",i=lt(e.maxEvents,st,"createLocalStorageConversationArcSink: maxEvents");return{record(n){const r=ut(e.storage),o=mt(r,t);o.push(n),function(e,t,i,n){if(e)try{e.setItem(t,JSON.stringify(i.slice(-n)))}catch(e){ct("localStorage write",e)}}(r,t,o,i)},clear(){const i=ut(e.storage);if(i)try{i.removeItem(t)}catch(e){ct("localStorage clear",e)}},load:()=>mt(ut(e.storage),t)}}function $t(e={}){const t=e.dbName??"semiotic-conversation-arc",i=e.storeName??"events",n=lt(e.maxEvents,st,"createIndexedDBConversationArcSink: maxEvents");let r=null;const o=()=>(r??(r=function(e,t,i){const n=function(e){if(e)return e;try{return globalThis.indexedDB??null}catch{return null}}(i);return n?new Promise(i=>{let r;try{r=n.open(e,1)}catch(e){return ct("IndexedDB open",e),void i(null)}r.onupgradeneeded=()=>{const e=r.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id",autoIncrement:!0})},r.onsuccess=()=>i(r.result),r.onerror=()=>{ct("IndexedDB open",r.error),i(null)},r.onblocked=()=>{ct("IndexedDB open",Error("upgrade blocked")),i(null)}}):Promise.resolve(null)}(t,i,e.indexedDB)),r);return{async record(e){const t=await o();t&&(await new Promise(n=>{try{const r=t.transaction(i,"readwrite");r.objectStore(i).add({event:e}),r.oncomplete=()=>n(),r.onerror=()=>{ct("IndexedDB record",r.error),n()}}catch(e){ct("IndexedDB record",e),n()}}),await function(e,t,i){return e?new Promise(n=>{try{const r=e.transaction(t,"readwrite"),o=r.objectStore(t),a=o.getAll();a.onsuccess=()=>{const e=Array.isArray(a.result)?a.result:[],t=e.length-i;if(t>0)for(const i of e.slice(0,t))null!=i.id&&o.delete(i.id)},a.onerror=()=>ct("IndexedDB trim",a.error),r.oncomplete=()=>n(),r.onerror=()=>{ct("IndexedDB trim",r.error),n()}}catch(e){ct("IndexedDB trim",e),n()}}):Promise.resolve()}(t,i,n))},async clear(){const e=await o();e&&await new Promise(t=>{try{const n=e.transaction(i,"readwrite");n.objectStore(i).clear(),n.oncomplete=()=>t(),n.onerror=()=>{ct("IndexedDB clear",n.error),t()}}catch(e){ct("IndexedDB clear",e),t()}})},load:async()=>function(e,t){return e?new Promise(i=>{try{const n=e.transaction(t,"readonly").objectStore(t).getAll();n.onsuccess=()=>{i((Array.isArray(n.result)?n.result:[]).map(e=>e.event).filter(Boolean))},n.onerror=()=>{ct("IndexedDB load",n.error),i([])}}catch(e){ct("IndexedDB load",e),i([])}}):Promise.resolve([])}(await o(),i)}}function Ct(e){if(!e.url)throw new TypeError("createWebhookConversationArcSink: url is required");const t=e.method??"POST";return{record(i){const n=e.fetch??globalThis.fetch;if(!n)return;const r=e.mapEvent?e.mapEvent(i):i;return n(e.url,{method:t,headers:{"Content-Type":"application/json",...e.headers},body:JSON.stringify(r)}).then(()=>{})}}}function St(e,t={}){const i=Array.isArray(e)?e.slice():[],n=lt(t.capacity,Math.max(rt?.capacity??st,i.length,1),"loadConversationArc: capacity"),r=t.sessionId??i[0]?.sessionId??rt?.sessionId??It();for(rt?(rt.enabled=t.enabled??!1,rt.sessionId=r,rt.capacity=n):rt={enabled:t.enabled??!1,sessionId:r,capacity:n,buffer:[]},t.append||(rt.buffer=[]),rt.buffer.push(...i);rt.buffer.length>rt.capacity;)rt.buffer.shift();return bt(),vt(),gt()}function At(e,t={}){return St(e,t)}function jt(e,t,i){return Bt.record({type:"audience-set",audience:e,previous:t??void 0,...i})}function Nt(e,t){return Bt.record({type:"annotation-status-changed",toStatus:e,annotationId:t?.annotationId,fromStatus:t?.fromStatus,chartId:t?.chartId,arcId:t?.arcId,meta:t?.meta})}function It(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Lt(){return rt}function Pt(e={}){const t=e.capacity??1e3;if(!Number.isFinite(t)||0>=t)throw new RangeError("enableConversationArc: capacity must be a positive number, got "+t);if(rt){if(rt.enabled=!0,e.sessionId&&(rt.sessionId=e.sessionId),null!=e.capacity){for(rt.capacity=t;rt.buffer.length>rt.capacity;)rt.buffer.shift();bt()}}else rt={enabled:!0,sessionId:e.sessionId??It(),capacity:t,buffer:[]},bt();return vt(),Bt}function Rt(){rt&&(rt.enabled=!1,vt())}function Mt(){return Bt}var Bt={get enabled(){return rt?.enabled??!1},get sessionId(){return rt?.sessionId??null},get capacity(){return rt?.capacity??0},record(e){const t=Lt();if(!t||!t.enabled)return null;const i={...e,timestamp:e.timestamp??Date.now(),sessionId:e.sessionId??t.sessionId};for(t.buffer.push(i);t.buffer.length>t.capacity;)t.buffer.shift();bt(),vt();for(const e of ot)try{e(i)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of at)t.record&&dt("sink record",()=>t.record?.(e))}(i),i},flush(){const e=Lt();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],bt(),vt(),function(e){for(const t of at)t.flush&&dt("sink flush",()=>t.flush?.(e))}(t),t},getEvents:()=>gt(),subscribe:e=>(ot.add(e),()=>{ot.delete(e)}),clear(){const e=Lt();e&&(e.buffer=[],bt(),vt()),function(){for(const e of at)e.clear&&dt("sink clear",()=>e.clear?.())}()},reset(){if(ot.clear(),at.clear(),ht=pt,ft=!1,!rt)return vt(),void yt.clear();rt.buffer=[],rt.enabled=!1,rt=null,vt(),yt.clear()}};import*as zt from"react";import{jsx as Tt,jsxs as Ft}from"react/jsx-runtime";var Dt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function Et({tree:e,label:t,visible:i=!1,className:n,onActiveChange:r,activeId:o,chartId:a,onObservation:l,onAnnotationActivate:c}){const[d,u]=zt.useState(()=>new Set([e.id])),[p,h]=zt.useState(e.id),f=void 0!==o,g=f?o:p,b=zt.useRef(null),y=zt.useRef(new Map),v=m(e=>e.pushObservation),x=zt.useCallback(e=>{l?.(e),v?.(e)},[l,v]),w=zt.useMemo(()=>function(e){const t=new Map,i=e=>{for(const n of e.children??[])t.set(n.id,e),i(n)};return i(e),t}(e),[e]),k=zt.useMemo(()=>it(e,d),[e,d]);zt.useEffect(()=>{f||k.some(e=>e.id===p)||h(e.id)},[k,p,e.id,f]),zt.useEffect(()=>{const e=[];let t=w.get(g);for(;t;)e.push(t.id),t=w.get(t.id);e.length>0&&u(t=>{if(e.every(e=>t.has(e)))return t;const i=new Set(t);for(const t of e)i.add(t);return i})},[g,w]),zt.useEffect(()=>{b.current?.contains(document.activeElement)&&y.current.get(g)?.focus()},[g]);const $=zt.useCallback((e,t,i)=>{const n=Mt();n.enabled&&n.record("focus"===t?{type:"nav-node-focused",chartId:a,nodeId:e.id,role:e.role,level:e.level,label:e.label.length>200?e.label.slice(0,200):e.label}:{type:"nav-branch-expanded",chartId:a,nodeId:e.id,role:e.role,level:e.level,expanded:!!i})},[a]),C=zt.useCallback(e=>{e.id!==g&&(f||h(e.id),r?.(e),$(e,"focus"),e.datum&&x({type:"focus",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:a}))},[r,f,$,g,x,a]),S=zt.useCallback(e=>{if(e.datum){if("annotation"===e.role){const t=s(e.datum);return c?.({annotation:e.datum,annotationId:t,chartId:a,inputType:"navigation-tree"}),void(t&&x({type:"annotation-activate",annotationId:t,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:a}))}x({type:"activate",datum:e.datum,inputType:"navigation-tree",timestamp:Date.now(),chartType:"AccessibleNavTree",chartId:a})}},[a,x,c]),A=e=>{u(t=>new Set(t).add(e.id)),$(e,"toggle",!0)},j=e=>{u(t=>{const i=new Set(t);return i.delete(e.id),i}),$(e,"toggle",!1)},N=(e,t,n)=>{const r=!!e.children&&e.children.length>0,o=d.has(e.id);return Ft("li",{role:"treeitem","aria-label":e.label,"aria-level":e.level,"aria-posinset":t,"aria-setsize":n,"aria-expanded":r?o:void 0,"aria-selected":e.id===g,tabIndex:e.id===g?0:-1,ref:t=>{y.current.set(e.id,t)},onClick:t=>{t.stopPropagation(),C(e),r?(o?j:A)(e):S(e)},style:i?{listStyle:"none",padding:"2px 6px",paddingLeft:6+16*(e.level-1),cursor:r?"pointer":"default",fontSize:13,color:"var(--semiotic-text, currentColor)",background:e.id===g?"var(--semiotic-surface, var(--semiotic-grid, var(--semiotic-bg, #f0f4f8)))":"transparent",outline:"none"}:void 0,children:[Ft("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+e.role,children:[i&&r?o?"▾ ":"▸ ":"",e.label]}),r&&o&&Tt("ul",{role:"group",style:i?{margin:0,padding:0}:void 0,children:e.children.map((t,i)=>N(t,i+1,e.children.length))})]},e.id)};return Tt("div",{ref:b,className:"semiotic-nav-tree"+(n?" "+n:""),style:i?void 0:Dt,onKeyDown:e=>{const t=k.findIndex(e=>e.id===g);if(-1===t)return;const i=k[t],n=!!i.children&&i.children.length>0,r=d.has(i.id);let o=!0;switch(e.key){case"ArrowDown":C(k[Math.min(t+1,k.length-1)]);break;case"ArrowUp":C(k[Math.max(t-1,0)]);break;case"Home":C(k[0]);break;case"End":C(k[k.length-1]);break;case"ArrowRight":n&&!r?A(i):n&&r?C(i.children[0]):o=!1;break;case"ArrowLeft":if(n&&r)j(i);else{const e=w.get(i.id);e?C(e):o=!1}break;case"Enter":case" ":n?(r?j:A)(i):S(i);break;default:o=!1}o&&(e.preventDefault(),e.stopPropagation())},children:Tt("ul",{role:"tree","aria-label":t||"Chart navigation",style:i?{margin:0,padding:0}:void 0,children:N(e,1,1)})})}var Ot=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart","RealtimeLineChart","RealtimeHeatmap"]),Ht=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),Wt={Scatterplot:["pointRadius","hoverRadius"],BubbleChart:["pointRadius","hoverRadius"],ConnectedScatterplot:["pointRadius","hoverRadius"],QuadrantChart:["pointRadius","hoverRadius"],SwarmPlot:["pointRadius","hoverRadius"],DotPlot:["dotRadius","hoverRadius"]};function Vt(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Gt(e){return"string"==typeof e&&e.trim().length>0}function Ut(e){const t=Vt(e.capability)?e.capability:null,i=Vt(e.recipe)?e.recipe:null,n=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,i?.mobile];for(const e of n)if(Vt(e))return e;return null}function qt(e){return Array.isArray(e)&&e.length>=2&&"number"==typeof e[0]&&"number"==typeof e[1]&&Number.isFinite(e[0])&&Number.isFinite(e[1])?[e[0],e[1]]:null}function Jt(e){return qt(e.size)||qt(Vt(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function Xt(e,t){e.push({...t,status:"pass"})}function _t(e,t){e.push({...t,status:"warn"})}function Qt(e,t){e.push({...t,status:"manual"})}function Kt(e,t={},i={}){const n=i.viewportWidth??390,r=i.targetSize??44,o=Jt(t),a=l(t,{width:n,height:o?.[1]}),s=[],c=Jt(t=a.props),d=Ut(t),u=function(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}(e,t),m=function(e){const t=Ut(e);return!0===e.responsive||!0===e.mobile||!0===t?.responsive||!0===t?.supportsResponsiveLayout||Array.isArray(t?.breakpoints)||"number"==typeof t?.minViewportWidth||"responsive"===t?.strategy||"small-multiples"===t?.strategy||"summary-cards"===t?.strategy||null!=e.mobileLayout||null!=e.responsiveRules||"mobile-readable"===e.density}(t),p=!0===i.inChartContainer,h=Gt(t.title)||Gt(t.summary)||Gt(t.description)||!0===d?.summary||Gt(d?.summary);if(a.matches.length>0&&Xt(s,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${a.matches.length} responsive rule(s) applied for the ${n}px mobile audit.`}),c){const[t,i]=c;t>n&&!m?_t(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${n}px mobile viewport with no responsive/mobile transform hint.`,fix:"Use responsive sizing, responsiveRules/mobileLayout, or an explicit mobile variant that preserves the task instead of clipping the desktop chart."}):Xt(s,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof d?.minViewportWidth&&d.minViewportWidth>n&&_t(s,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${d.minViewportWidth}px minimum, wider than the audited ${n}px viewport.`,fix:"Add a narrower breakpoint, summary-card fallback, or explicit horizontal-scroll affordance with a non-visual equivalent."});const r=t/Math.max(1,i);430>=n&&r>2.4&&"BigNumber"!==e&&_t(s,{id:"layout.wide-aspect-ratio",category:"layout",impact:"medium",message:`Chart aspect ratio is ${r.toFixed(1)}:1, which tends to compress phone charts vertically.`,fix:"Prefer stacked sections, small multiples, cards plus a sparkline, or a taller mobile-specific chart ratio."}),160>i&&"BigNumber"!==e&&_t(s,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${i}px; most phone charts need enough vertical room for marks plus readable labels.`,fix:"Reserve more vertical space, remove nonessential axes, or switch to a card/sparkline pattern with external labels."})}else Qt(s,{id:"layout.unknown-size",category:"layout",impact:"medium",message:"No explicit size is available to audit. This may be responsive, but static mobile overflow cannot be checked.",fix:"Audit rendered widths at 320, 360, 390, and 430px, or pass size/responsiveRules metadata into the config."});const f=function(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,Vt(e.frameProps)?e.frameProps.data:void 0];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i}(t);f>0&&(f>("number"==typeof d?.maxMarks?d.maxMarks:Ot.has(e)?1.25*n:Ht.has(e)?Math.max(8,Math.floor(n/34)):n)?_t(s,{id:"density.mark-budget",category:"density",impact:Ot.has(e)?"medium":"high",message:`${f} data item(s) exceed the rough mobile density budget for ${e} at ${n}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):Xt(s,{id:"density.mark-budget",category:"density",impact:"medium",message:f+" data item(s) are within the rough mobile density budget for this component."}));const g=function(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i>0?i:null}(t),b=!1!==t.showAxes&&!1!==t.axis;if(b&&null!=g){const e=Math.max(3,Math.floor(n/58));g>e&&_t(s,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${g} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${n}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else b&&(Ot.has(e)||Ht.has(e))&&Qt(s,{id:"density.axis-label-collision",category:"density",impact:"medium",message:"Axes are enabled, but label collision depends on rendered tick text and cannot be checked statically.",fix:"Verify tick labels at phone widths or provide explicit mobile tick density."});!function(e){const t=Vt(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=Ut(e),i=Vt(e.mobileInteraction)?e.mobileInteraction:null;return null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||null!=e.selection||null!=e.onClick||null!=e.onSelect||!0===e.mobileInteraction||!0===i?.tapToSelect||!0===i?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||Gt(t?.interaction?.hoverFallback)}(e)}(t)?Xt(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):_t(s,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"The chart exposes tooltip/hover detail without an obvious tap, selection, or control alternative.",fix:"Enable tap-to-select, a persistent details panel, visible segment buttons, or another non-hover path for the same information."});const y=function(e,t){const i=Wt[e];if(!i)return null;let n=i.includes("hoverRadius")?30:null;for(const e of i){const i=t[e];"number"==typeof i&&Number.isFinite(i)&&i>0&&(n=null==n?i:Math.max(n,i))}return null==n?null:2*n}(e,t),v=Vt(t.mobileInteraction)?t.mobileInteraction:null,x=y??("number"==typeof v?.targetSize?v.targetSize:!0===t.mobileInteraction?44:"number"==typeof d?.minimumHitTarget?d.minimumHitTarget:"number"==typeof d?.interaction?.targetSize?d.interaction.targetSize:null);null!=x&&(24>x?_t(s,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${x}px pointer target, below WCAG's 24px minimum.`,fix:"Increase mark radius/hoverRadius, add tap snapping to nearest datum, or provide larger external controls."}):r>x?_t(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${x}px, above 24px but below the ${r}px comfortable phone target.`,fix:"Use hoverRadius/tapRadius near 44px while keeping the visible mark small if needed."}):Xt(s,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${x}px, meeting the configured ${r}px target.`}));const w=[];null==t.brush&&null==t.onBrush||w.push("brush"),!0===t.zoomable&&w.push("pan/zoom"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||w.push("legend filtering"),w.length>0&&!function(e,t){const i=Ut(e),n=Vt(e.mobileInteraction)?e.mobileInteraction:null,r=n?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(i?.interaction?.alternatives)&&i.interaction.alternatives.length>0)||!0===r||"all"===r||t.every(e=>"brush"===e?Array.isArray(r)?r.includes("brush"):"brush"===r:"pan/zoom"===e?Array.isArray(r)?r.includes("zoom"):"zoom"===r:"legend filtering"===e&&(Array.isArray(r)?r.includes("legend"):"legend"===r))}(t,w)&&_t(s,{id:"interaction.complex-gesture-alternative",category:"interaction",impact:"high",message:`Mobile-hostile complex interaction detected: ${w.join(", ")} without standard control alternatives.`,fix:"Pair gestures with buttons, range inputs, chips, or a details panel that works with touch and keyboard."}),!1===t.showLegend||!1===t.legend||!0!==t.showLegend&&!0!==t.legend&&null==t.colorBy&&null==t.groupBy&&null==t.lineBy&&null==t.areaBy&&null==t.stackBy||!0===t.directLabel||!0===t.showLabels||"direct"===t.labelStrategy||"direct-end"===t.labelStrategy||"direct"===d?.labels?.strategy||"inline"===d?.labels?.strategy||"external"===d?.labels?.strategy||n>430||_t(s,{id:"semantics.legend-over-direct-labels",category:"semantics",impact:"medium",message:"The chart appears to rely on a legend instead of direct labels at phone width.",fix:"Prefer direct end labels, inline labels, or a compact chip selector so readers do not bounce between plot and legend."});const k=Array.isArray(t.annotations)?t.annotations.filter(e=>Vt(e)):[];if(k.length>("number"==typeof d?.maxAnnotations?d.maxAnnotations:3)&&430>=n&&_t(s,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:k.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),k.length>0){const e=k.filter(e=>!Gt(e.mobileText)&&!Gt(e.shortText)&&!Gt(e.label));e.length>0&&Qt(s,{id:"annotation.mobile-copy",category:"annotation",impact:"low",message:e.length+" annotation(s) lack explicit short/mobile copy.",fix:"Add mobileText or shortText for notes that need to survive narrow layouts."})}m||"BigNumber"===e||Qt(s,{id:"layout.no-responsive-transform",category:"layout",impact:"low",message:"No explicit responsive transformation hint is present.",fix:"Declare responsiveRules/mobileLayout or a density/label strategy so the mobile version is a designed transformation, not an accidental resize."}),u&&(d?(Xt(s,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart/recipe provides a mobileSemantics/mobile contract, so the audit can inspect its authored phone behavior."}),!1===d.custom?.dataBearingSceneNodes?_t(s,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"medium",message:"Custom mobile contract says emitted scene nodes are not data-bearing.",fix:"Preserve datum references, semantic roles, or accessible-table fields so intelligence, navigation, and tap details can recover the chart's meaning."}):!0!==d.custom?.dataBearingSceneNodes&&Qt(s,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"low",message:"Custom chart mobile contract does not state whether scene nodes are data-bearing.",fix:"Set mobile.custom.dataBearingSceneNodes and mobile.custom.navigationGranularity for custom layouts and interoperability adapters."})):Qt(s,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart layout is opaque to static mobile analysis because no mobileSemantics/mobile contract is present.",fix:"Declare mobileSemantics with strategy, breakpoints, mark budgets, touch target size, interaction alternatives, and custom scene semantics."})),h||p||_t(s,{id:"semantics.no-mobile-summary",category:"semantics",impact:"medium",message:"No title, summary, description, or ChartContainer context is visible from the config.",fix:"Add title/summary text or wrap in ChartContainer so the small-screen reader gets the task before the chart."});const $=s.filter(e=>"warn"===e.status),C={highRisk:$.filter(e=>"high"===e.impact).length,warnings:$.length,manual:s.filter(e=>"manual"===e.status).length,passes:s.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:n,ok:0===C.highRisk,summary:C,findings:s,reference:"Mobile visualization audit: informed by MobileVisFixer, mobile exploratory interaction research, small-multiple mobile studies, responsive visualization grammars, constraint-based breakpoints, and WCAG 2.2 input modalities."}}var Zt={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},Yt=["layout","density","interaction","annotation","semantics"];function ei(e){const t=[],i=e.summary,n=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${i.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${n} - ${i.warnings} warning(s) - ${i.manual} manual check(s)`);for(const i of Yt){const n=e.findings.filter(e=>e.category===i&&"not-applicable"!==e.status);if(0!==n.length){t.push(""),t.push(" "+i.toUpperCase());for(const e of n)t.push(` ${Zt[e.status]} [${e.impact}] ${e.id}: ${e.message}`),!e.fix||"warn"!==e.status&&"manual"!==e.status||t.push(" -> "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function ti(){return["Static audit only: rendered label collision, CSS-resolved type size, and actual touch behavior still require viewport testing.","Use multiple widths, usually 320, 360, 390, 430, and 768 CSS pixels.","A mobile pass means no high-risk static warnings, not that the chart is perceptually or ergonomically optimal."]}import*as ii from"react";import*as ni from"react";var ri,oi=[];function ai(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function si(e){return e&&"object"==typeof e&&"number"==typeof e.targetSize?e.targetSize:void 0}function li(e){return Array.isArray(e)?e.length>0:!!e}import{Fragment as ci,jsx as di,jsxs as ui}from"react/jsx-runtime";var mi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function pi(){const e=d();return e?di("button",{className:"semiotic-chart-action",onClick:e,title:"Data summary","aria-label":"Toggle data summary",style:$i,children:ui("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[di("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),di("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),di("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}var hi={info:"var(--semiotic-info, #2563eb)",success:"var(--semiotic-success, #16a34a)",warning:"var(--semiotic-warning, #d97706)",error:"var(--semiotic-error, var(--semiotic-danger, #dc2626))",neutral:"var(--semiotic-text-secondary, #6b7280)"},fi={error:4,warning:3,info:2,success:1,neutral:0};function gi({level:e}){const t={width:15,height:15,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(e){case"error":case"warning":return ui("svg",{...t,children:[di("path",{d:"M8 1.8 15 14H1L8 1.8Z"}),di("path",{d:"M8 6.4v3.4"}),di("circle",{cx:"8",cy:"11.8",r:"0.5",fill:"currentColor",stroke:"none"})]});case"success":return ui("svg",{...t,children:[di("circle",{cx:"8",cy:"8",r:"6.4"}),di("path",{d:"M5 8.2 7 10.2 11 5.8"})]});case"info":return ui("svg",{...t,children:[di("circle",{cx:"8",cy:"8",r:"6.4"}),di("path",{d:"M8 7.4V11"}),di("circle",{cx:"8",cy:"5",r:"0.5",fill:"currentColor",stroke:"none"})]});default:return ui("svg",{...t,children:[di("path",{d:"M8 2a3.5 3.5 0 0 0-3.5 3.5c0 4-1.5 5-1.5 5h10s-1.5-1-1.5-5A3.5 3.5 0 0 0 8 2Z"}),di("path",{d:"M6.5 13a1.5 1.5 0 0 0 3 0"})]})}}function bi({notification:e,level:t,onDismiss:i}){const n=hi[t]??hi.info,r=!1!==e.dismissible;return ui("div",{className:"semiotic-chart-notification semiotic-chart-notification--"+t,style:{display:"flex",alignItems:"flex-start",gap:8,padding:"6px 10px",borderRadius:4,borderLeft:"3px solid "+n,background:"var(--semiotic-surface, rgba(127, 127, 127, 0.08))"},children:[ui("div",{style:{flex:1,minWidth:0},children:[e.source&&di("div",{className:"semiotic-chart-notification-source",style:{fontSize:9,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--semiotic-text-secondary, #666)"},children:e.source}),e.title&&di("div",{className:"semiotic-chart-notification-title",style:{fontSize:12,fontWeight:600,color:n},children:e.title}),di("div",{className:"semiotic-chart-notification-message",style:{fontSize:12,lineHeight:1.45,color:"var(--semiotic-text, #333)"},children:e.message})]}),r&&di("button",{className:"semiotic-chart-notification-dismiss","aria-label":e.title?"Dismiss notification: "+e.title:"Dismiss notification",title:"Dismiss",onClick:i,style:{...$i,width:18,height:18,fontSize:13,lineHeight:1,flex:"none"},children:"×"})]})}function yi({visible:e,onDismiss:t}){const[i,n]=ii.useState(!1),r=ii.useRef(null),o=ii.useRef(null);if(ii.useEffect(()=>{0===e.length&&i&&n(!1)},[e.length,i]),ii.useEffect(()=>{if(!i)return;const e=e=>{r.current&&!r.current.contains(e.target)&&n(!1)},t=e=>{"Escape"===e.key&&(n(!1),o.current?.focus())};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[i]),0===e.length)return null;const a=e.reduce((e,t)=>fi[t.level]>fi[e]?t.level:e,e[0].level),s=hi[a]??hi.info,l=e.length,c=`${l} chart notification${1===l?"":"s"}, most severe: ${a}`;return ui("div",{ref:r,className:"semiotic-chart-notifications",style:{position:"relative",display:"inline-flex"},children:[di("span",{style:mi,role:"status","aria-live":"polite",children:c}),ui("button",{ref:o,className:"semiotic-chart-action semiotic-chart-notifications-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-label":`${c}. ${i?"Hide":"Show"} notifications`,title:c,onClick:()=>n(e=>!e),style:{...$i,color:s,position:"relative"},children:[di(gi,{level:a}),di("span",{className:"semiotic-chart-notifications-badge","aria-hidden":"true",style:{position:"absolute",top:-3,right:-3,minWidth:15,height:15,padding:"0 3px",boxSizing:"border-box",borderRadius:8,background:s,color:"#fff",fontSize:9,fontWeight:700,lineHeight:"15px",textAlign:"center"},children:l>99?"99+":l})]}),i&&di("div",{className:"semiotic-chart-notifications-popover",role:"dialog","aria-label":"Chart notifications",style:{position:"absolute",top:"calc(100% + 6px)",right:0,zIndex:20,width:320,maxWidth:"min(360px, 90vw)",maxHeight:320,overflowY:"auto",display:"flex",flexDirection:"column",gap:6,padding:10,textAlign:"left",background:"var(--semiotic-bg, #fff)",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:6,boxShadow:"0 6px 24px rgba(0, 0, 0, 0.16)"},children:e.map(e=>di(bi,{notification:e.notification,level:e.level,onDismiss:()=>t(e)},e.key))})]})}var vi={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function xi({height:e}){return di("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:e,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function wi({error:e}){return di("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:di("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:e})})}var ki=ii.forwardRef(function({title:t,subtitle:i,children:n,width:r="100%",height:a=400,actions:s,chartConfig:l,describe:c,navigable:d,controls:u,banner:m,notifications:p,dataAudit:h,onNotificationDismiss:b,loading:y=!1,error:v,errorBoundary:x=!1,status:w,detailsPanel:k,mobile:$,mobileAudit:C,className:S,style:A},j){const N=ii.useRef(null),I=ii.useRef(null),[L,P]=ii.useState(!1),R=function(e,t){const[i,n]=ni.useState(oi),r=e?.component,o=e?.props,a=!!t,s="object"==typeof t?t.checkOutliers:void 0,l="object"==typeof t?t.errorsOnly:void 0,c="object"==typeof t?t.max:void 0;return ni.useEffect(()=>{let e=!0;return a&&r&&o?((ri??(ri=import("./chunk-chartContainerDataAudit-74TLKIP6.module.min.js").catch(e=>{throw ri=void 0,e})),ri).then(({buildChartDataAuditNotifications:t})=>{e&&n(t({component:r,props:o},{checkOutliers:s,errorsOnly:l,max:c}))}).catch(()=>{e&&n(oi)}),()=>{e=!1}):(n(e=>0===e.length?e:oi),()=>{e=!1})},[s,r,a,l,c,o]),i}(l,h),M=ii.useMemo(()=>[...p??[],...R],[p,R]),[B,z]=ii.useState(()=>new Set);ii.useEffect(()=>{z(e=>{if(0===e.size)return e;const t=new Set(M.map((e,t)=>e.id??t+""));let i=!1;const n=new Set;for(const r of e)t.has(r)?n.add(r):i=!0;return i?n:e})},[M]);const T=ii.useMemo(()=>M.map((e,t)=>({notification:e,index:t,key:e.id??t+"",level:e.level??"info"})).filter(({key:e})=>!B.has(e)),[M,B]),F=ii.useCallback(e=>{z(t=>new Set(t).add(e.key)),b?.(e.notification,e.index)},[b]),D=!1!==s?.export&&void 0!==s?.export,E=!1!==s?.fullscreen&&void 0!==s?.fullscreen,O=!1!==s?.copyConfig&&void 0!==s?.copyConfig&&l,H=!0===s?.dataSummary,W=ii.useMemo(()=>{if(!c||!l?.component||!l?.props)return"";const e="object"==typeof c?c.levels:void 0;try{return Qe(l.component,l.props,e?{levels:e}:{}).text}catch{return""}},[c,l]),V="object"==typeof c&&!0===c.visible,G=ii.useMemo(()=>{if(!d||!l?.component||!l?.props)return null;const e="object"==typeof d?d.maxLeaves:void 0;try{return tt(l.component,l.props,e?{maxLeaves:e}:{})}catch{return null}},[d,l]),U="object"==typeof d&&!0===d.visible,q=ii.useMemo(()=>"object"==typeof s?.export?s.export:{},[s?.export]),J="object"==typeof s?.copyConfig?s.copyConfig.format:"json",X=ii.useCallback(async e=>{I.current&&await g(I.current,{...q,...e})},[q]),_=ii.useCallback(()=>{N.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):N.current.requestFullscreen().catch(()=>{}))},[]),Q=ii.useCallback(async e=>{l&&await ce({...l,version:l.version??"1",createdAt:l.createdAt??(new Date).toISOString()},e||J||"json")},[l,J]);ii.useEffect(()=>{const e=()=>{P(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),ii.useImperativeHandle(j,()=>({export:X,toggleFullscreen:_,copyConfig:Q,element:N.current}),[X,_,Q]);const K=!0===$?{}:$&&"object"==typeof $?$:null,Z=!!$,Y=K?.breakpoint??480,ee=void 0===K?.chartMode?"mobile":K.chartMode,te=K?.semantics,ie=K?.mobileInteraction??(!!Z||void 0),ne=K?.standardControls,re=ai(ne)?ne:null,oe=re?.controls??(ai(ne)?void 0:ne)??function(e){return e&&"object"==typeof e?e.standardControls:void 0}(ie),ae=ii.useMemo(()=>function(e,t){return li(t)?e&&"object"==typeof e?{...e,standardControls:t}:!1===e||null==e?e:{standardControls:t}:e}(ie,oe),[ie,oe]),se=Z&&li(oe)?di(e,{controls:oe,targetSize:re?.targetSize??si(ie)??44,compact:re?.compact??!0,className:re?.className,style:re?.style,ariaLabel:re?.ariaLabel,brush:re?.brush,zoom:re?.zoom,legend:re?.legend}):null,le=K?.summary,de=!0===K?.allowHorizontalScroll,ue=!0===K?.hideToolbar,me=ii.useMemo(()=>{if(!C||!l?.component||!l?.props)return null;const e="object"==typeof C?C:{},t=l.props;try{return Kt(l.component,{...t,mobileSemantics:t.mobileSemantics??te,mobileInteraction:t.mobileInteraction??ae},{viewportWidth:e.viewportWidth??390,targetSize:e.targetSize??44,inChartContainer:!0})}catch{return null}},[C,l,te,ae]);ii.useEffect(()=>{if(!me||me.ok)return;const e=me.findings.filter(e=>"pass"!==e.status).slice(0,5);console.warn(`[Semiotic mobile audit] ${l?.component}: ${me.summary.highRisk} high-risk mobile finding(s), ${me.summary.warnings} warning(s).`,e)},[me,l?.component]);const pe=me&&!me.ok&&"object"==typeof C&&!0===C.visible?ui("div",{className:"semiotic-chart-mobile-audit",role:"status",style:{padding:"8px 12px",fontSize:12,lineHeight:1.45,color:"var(--semiotic-warning, #6b3f00)",background:"color-mix(in srgb, var(--semiotic-warning, #d97706) 14%, var(--semiotic-bg, #fff))",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:["Mobile audit: ",me.summary.highRisk," high-risk finding",1===me.summary.highRisk?"":"s"," and"," ",me.summary.warnings," warning",1===me.summary.warnings?"":"s"," at"," ",("object"==typeof C?C.viewportWidth:void 0)??390,"px."]}):null,he=T.length>0,fe=t||i||u||D||E||O||H||w||he,ge=ii.useMemo(()=>{if(!Z||!ii.isValidElement(n))return n;if(!function(e){const t=e.type;return"function"==typeof t||"object"==typeof t&&null!==t}(n))return n;const e=n.props,t={};return ee&&null==e.mode&&(t.mode=ee),te&&null==e.mobileSemantics&&(t.mobileSemantics=te),void 0!==ae&&null==e.mobileInteraction&&(t.mobileInteraction=ae),Object.keys(t).length>0?ii.cloneElement(n,t):n},[n,Z,ee,te,ae]),be=y?di(xi,{height:a}):v?di(wi,{error:v}):x?di(f,{children:ge}):ge;return ye=ui(ci,{children:[di("style",{dangerouslySetInnerHTML:{__html:`@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}\n@media (max-width: ${Y}px) {\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-header {\n padding: 10px 12px !important;\n gap: 10px !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-title-area {\n flex-basis: 100% !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-toolbar {\n width: 100% !important;\n margin-left: 0 !important;\n justify-content: flex-start !important;\n overflow-x: auto !important;\n -webkit-overflow-scrolling: touch;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"][data-semiotic-mobile-hide-toolbar="true"] .semiotic-chart-toolbar {\n display: none !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-action {\n min-width: 32px !important;\n min-height: 32px !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-mobile-summary {\n display: block !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"] .semiotic-chart-mobile-standard-controls {\n display: block !important;\n }\n .semiotic-chart-container[data-semiotic-mobile="true"][data-semiotic-mobile-scroll="true"] .semiotic-chart-body {\n overflow-x: auto !important;\n justify-content: flex-start !important;\n -webkit-overflow-scrolling: touch;\n }\n}`}}),ui("div",{ref:N,className:"semiotic-chart-container"+(S?" "+S:""),"data-semiotic-mobile":Z?"true":void 0,"data-semiotic-mobile-scroll":de?"true":void 0,"data-semiotic-mobile-hide-toolbar":ue?"true":void 0,style:{width:r,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative",...L?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{},...A},children:[fe&&ui("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",flexWrap:"wrap",gap:8,borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[ui("div",{className:"semiotic-chart-title-area",style:{minWidth:0,flex:"1 1 200px"},children:[t&&di("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:t}),i&&di("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0},children:i})]}),ui("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[u,he&&di(yi,{visible:T,onDismiss:F}),D&&di("button",{className:"semiotic-chart-action",onClick:()=>X(),title:"Export chart","aria-label":"Export chart",style:$i,children:ui("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[di("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),di("path",{d:"M2 12h10"})]})}),H&&di(pi,{}),E&&di("button",{className:"semiotic-chart-action",onClick:_,title:L?"Exit fullscreen":"Fullscreen","aria-label":L?"Exit fullscreen":"Enter fullscreen",style:$i,children:di("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:ui(ci,L?{children:[di("path",{d:"M9 1v4h4"}),di("path",{d:"M5 13V9H1"}),di("path",{d:"M13 5H9V1"}),di("path",{d:"M1 9h4v4"})]}:{children:[di("path",{d:"M1 5V1h4"}),di("path",{d:"M13 9v4H9"}),di("path",{d:"M9 1h4v4"}),di("path",{d:"M5 13H1V9"})]})})}),O&&di("button",{className:"semiotic-chart-action",onClick:()=>Q(),title:"Copy config","aria-label":"Copy chart configuration",style:$i,children:ui("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[di("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),di("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),w&&di("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:vi[w].bg,color:vi[w].color,lineHeight:"18px"},children:w})]})]}),m&&di("div",{className:"semiotic-chart-banner",children:m}),pe,le&&di("div",{className:"semiotic-chart-mobile-summary",style:{display:"none",padding:"8px 12px",fontSize:12,lineHeight:1.45,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:le}),se&&di("div",{className:"semiotic-chart-mobile-standard-controls",style:{display:"none",padding:"10px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-surface, var(--semiotic-bg, #f6f8fa))"},children:se}),W&&di("div",{className:"semiotic-chart-description",role:"note",style:V?{padding:"8px 16px",fontSize:12,lineHeight:1.5,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}:mi,children:W}),G&&di("div",{className:"semiotic-chart-nav",style:U?{padding:"8px 8px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",maxHeight:240,overflow:"auto"}:void 0,children:di(Et,{tree:G,label:"string"==typeof t&&t?t+" — navigable structure":"Chart navigable structure",visible:U,chartId:"string"==typeof l?.props?.chartId?l.props.chartId:void 0})}),ui("div",{className:"semiotic-chart-body",ref:I,style:{position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",...L?{flex:1}:{height:a}},children:[be,k]})]})]}),H?di(o,{children:ye}):ye;var ye}),$i={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};import*as Ci from"react";import{jsx as Si,jsxs as Ai}from"react/jsx-runtime";function ji({children:e,controls:t,mobile:i,breakpoint:n=480,chartMode:r="mobile",mobileInteraction:o=!0,mobileSemantics:a,mobileSummary:s,chips:l=[],activeChip:c,onChipChange:d,detail:u,detailTitle:m="Details",detailMode:p="sheet",initialDetailOpen:h=!1,allowHorizontalScroll:f=!1,hideToolbar:g=!1,chartDefaults:b,...y}){const[v,x]=Ci.useState(()=>c??l.find(e=>!e.disabled)?.id),[w,k]=Ci.useState(h);Ci.useEffect(()=>{void 0===c&&(l.length?l.some(e=>e.id===v&&!e.disabled)||x(l.find(e=>!e.disabled)?.id):x(void 0))},[c,l,v]);const $=c??v,C=Ci.useCallback(e=>{e.disabled||(void 0===c&&x(e.id),d?.(e))},[c,d]),S=l.length?Si("div",{className:"semiotic-mobile-chip-row",role:"list","aria-label":"Mobile chart controls",children:l.map(e=>Ai("button",{type:"button",className:"semiotic-mobile-chip","aria-pressed":e.id===$,disabled:e.disabled,onClick:()=>C(e),title:"string"==typeof e.description?e.description:void 0,children:[Si("span",{children:e.label}),e.description&&Si("small",{className:"semiotic-mobile-chip-description",children:e.description})]},e.id))}):null,A=s||S?Ai("div",{className:"semiotic-mobile-summary-card",children:[s&&Si("div",{className:"semiotic-mobile-summary-copy",children:s}),S]}):i?.summary,j={breakpoint:n,chartMode:r,mobileInteraction:o,semantics:a,allowHorizontalScroll:f,hideToolbar:g,...i,summary:A},N=Ci.useMemo(()=>{if(!b||!Ci.isValidElement(e))return e;const t=e.props,i={};for(const[e,n]of Object.entries(b))null==t[e]&&(i[e]=n);return Object.keys(i).length>0?Ci.cloneElement(e,i):e},[e,b]),I=!!u&&"sheet"===p,L=!!u&&"inline"===p||I&&w,P=I?Si("button",{type:"button",className:"semiotic-mobile-detail-toggle","aria-expanded":w,onClick:()=>k(e=>!e),children:w?"Hide details":"Show details"}):null,R=t||P?Ai("div",{className:"semiotic-mobile-control-stack",children:[t,P]}):void 0;return Ai("div",{className:"semiotic-mobile-chart-shell",children:[Si("style",{children:`\n .semiotic-mobile-chart-shell {\n display: grid;\n gap: 10px;\n width: 100%;\n }\n .semiotic-mobile-summary-card {\n display: grid;\n gap: 10px;\n }\n .semiotic-mobile-summary-copy {\n font-size: 13px;\n line-height: 1.45;\n }\n .semiotic-mobile-chip-row {\n display: flex;\n gap: 8px;\n overflow-x: auto;\n padding-bottom: 2px;\n -webkit-overflow-scrolling: touch;\n }\n .semiotic-mobile-chip {\n display: inline-flex;\n flex: 0 0 auto;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n min-height: 40px;\n min-width: 44px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 999px;\n padding: 7px 12px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n font: inherit;\n font-size: 12px;\n font-weight: 700;\n cursor: pointer;\n }\n .semiotic-mobile-chip[aria-pressed="true"] {\n border-color: var(--semiotic-accent, #1f7a6d);\n background: color-mix(in srgb, var(--semiotic-accent, #1f7a6d) 14%, transparent);\n }\n .semiotic-mobile-chip:disabled {\n cursor: not-allowed;\n opacity: 0.45;\n }\n .semiotic-mobile-chip-description {\n display: block;\n max-width: 160px;\n margin-top: 2px;\n color: var(--semiotic-text-secondary, #666);\n font-size: 10px;\n font-weight: 500;\n line-height: 1.2;\n }\n .semiotic-mobile-control-stack {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n flex-wrap: wrap;\n }\n .semiotic-mobile-detail-toggle {\n min-height: 32px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 999px;\n padding: 5px 10px;\n background: transparent;\n color: var(--semiotic-text, #222);\n font: inherit;\n font-size: 12px;\n font-weight: 700;\n cursor: pointer;\n }\n .semiotic-mobile-detail-panel {\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 16px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16);\n overflow: hidden;\n }\n .semiotic-mobile-detail-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n padding: 10px 12px;\n border-bottom: 1px solid var(--semiotic-border, #d8d8d8);\n font-size: 13px;\n font-weight: 800;\n }\n .semiotic-mobile-detail-body {\n padding: 12px;\n font-size: 13px;\n line-height: 1.5;\n }\n @media (max-width: ${n}px) {\n .semiotic-mobile-detail-panel[data-mode="sheet"] {\n position: sticky;\n bottom: 8px;\n z-index: 2;\n max-height: min(55vh, 420px);\n overflow: auto;\n }\n }\n `}),Si(ki,{...y,controls:R,mobile:j,children:N}),L&&Ai("section",{className:"semiotic-mobile-detail-panel","data-mode":p,"aria-label":"string"==typeof m?m:"Chart details",children:[Ai("div",{className:"semiotic-mobile-detail-header",children:[Si("span",{children:m}),I&&Si("button",{type:"button",className:"semiotic-mobile-detail-toggle",onClick:()=>k(!1),children:"Close"})]}),Si("div",{className:"semiotic-mobile-detail-body",children:u})]})]})}import*as Ni from"react";import{jsx as Ii,jsxs as Li}from"react/jsx-runtime";function Pi(e,t){if(t)return"function"==typeof t?t(e):e?.[t]}function Ri(e,t){const i="function"==typeof t?t(e):e[t];return Array.isArray(i)?i:[]}function Mi(e){return{strategy:"small-multiples",responsive:!0,supportsResponsiveLayout:!0,summary:`${e} vertically stacked small multiple panel${1===e?"":"s"} with shared scale guidance.`,interaction:{primary:"tap",alternatives:["panel summary","linked selection"],hoverFallback:"tap-to-lock",targetSize:44},labels:{strategy:"external",minFontSize:12}}}function Bi(e,t){if(!Ni.isValidElement(e))return e;const i=e.props,n={};for(const[e,r]of Object.entries(t))void 0!==r&&null==i[e]&&(n[e]=r);return Object.keys(n).length>0?Ni.cloneElement(e,n):e}function zi({items:e,children:t,columns:i=3,tabletColumns:n=2,mobileColumns:r=1,mobileBreakpoint:o=480,tabletBreakpoint:s=860,gap:l=12,mode:c="mobile",chartHeight:d=220,sharedExtent:m=!0,valueAccessor:p,dataAccessor:h="data",extentProps:f=["yExtent","valueExtent"],linkedHover:g,selection:b,linkedBy:y,linkProvider:v="auto",selections:x,showLegend:w=!1,legendPosition:k,legendInteraction:$,legendSelectionName:C,legendField:S,mobileInteraction:A=!0,mobileSemantics:j,labelMode:N="panel",chartDefaults:I,className:L,style:P}){const R=u(),M=e||"function"==typeof t?[]:Ni.Children.toArray(t),B=e??M.map((e,t)=>({id:"panel-"+(t+1)})),z=B.length,T=Ni.useMemo(()=>function(e,t,i,n){if(t&&"object"==typeof t)return t;if(!1===t)return{};const r=[],o=[];for(const t of e)if(t.extent&&r.push(t.extent[0],t.extent[1]),n)for(const e of Ri(t,i))o.push(Pi(e,n));const a=function(e){let t=1/0,i=-1/0;for(const n of e){const e=Number(n);Number.isFinite(e)&&(t>e&&(t=e),e>i&&(i=e))}if(Number.isFinite(t)&&Number.isFinite(i))return t===i?[t-1,i+1]:[t,i]}(o.length?o:r);return a?{yExtent:a,valueExtent:a}:{}}(B,m,h,p),[B,m,h,p]),F=Ni.useMemo(()=>{if(!y)return{name:void 0,fields:void 0,linkedHover:g,selection:b};const e=Array.isArray(y)?"small-multiples":y.name||"small-multiples",t=Array.isArray(y)?y:y.fields||[];return{name:e,fields:t,linkedHover:g??{name:e,fields:t},selection:b??{name:e}}},[y,g,b]),D=Ni.useMemo(()=>({linkedHover:F.linkedHover,selection:F.selection}),[F.linkedHover,F.selection]),E=Ni.useMemo(()=>{const e={mode:c,height:d,responsiveWidth:!0,mobileInteraction:A,mobileSemantics:j??Mi(z),...D,...I};"legend"!==N&&(e.showLegend=!1),"direct"===N&&(e.directLabel=!0);for(const t of f)t in T&&(e[t]=T[t]);return e},[c,d,A,j,z,D,I,N,f,T]),O=Li("section",{className:["semiotic-small-multiple-chart",L].filter(Boolean).join(" "),style:P,"data-semiotic-small-multiple":"true",children:[Ii("style",{children:`\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${i};\n --semiotic-small-multiple-gap: ${l}px;\n display: grid;\n grid-template-columns: repeat(var(--semiotic-small-multiple-columns), minmax(0, 1fr));\n gap: var(--semiotic-small-multiple-gap);\n width: 100%;\n }\n .semiotic-small-multiple-panel {\n min-width: 0;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 16px;\n background: var(--semiotic-bg, #fff);\n overflow: hidden;\n }\n .semiotic-small-multiple-heading {\n display: grid;\n gap: 3px;\n padding: 10px 12px 0;\n }\n .semiotic-small-multiple-title {\n margin: 0;\n color: var(--semiotic-text, #222);\n font-size: 13px;\n font-weight: 800;\n line-height: 1.25;\n }\n .semiotic-small-multiple-subtitle,\n .semiotic-small-multiple-summary {\n margin: 0;\n color: var(--semiotic-text-secondary, #666);\n font-size: 11px;\n line-height: 1.35;\n }\n .semiotic-small-multiple-plot {\n min-width: 0;\n padding: 4px 6px 8px;\n overflow: hidden;\n }\n @media (max-width: ${s}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${n};\n }\n }\n @media (max-width: ${o}px) {\n .semiotic-small-multiple-chart {\n --semiotic-small-multiple-columns: ${r};\n }\n .semiotic-small-multiple-panel {\n border-radius: 14px;\n }\n .semiotic-small-multiple-heading {\n padding: 9px 10px 0;\n }\n }\n `}),B.map((e,i)=>{const n={...E},r="function"==typeof t?t(e,{item:e,index:i,count:z,chartProps:n,sharedExtent:T}):M[i];return Li("article",{className:"semiotic-small-multiple-panel","aria-label":"string"==typeof e.title?e.title:void 0,children:[(e.title||e.subtitle||e.summary)&&Li("header",{className:"semiotic-small-multiple-heading",children:[e.title&&Ii("h3",{className:"semiotic-small-multiple-title",children:e.title}),e.subtitle&&Ii("p",{className:"semiotic-small-multiple-subtitle",children:e.subtitle}),e.summary&&Ii("p",{className:"semiotic-small-multiple-summary",children:e.summary})]}),Ii("div",{className:"semiotic-small-multiple-plot",children:Bi(r,n)})]},e.id??i)})]});return!0===v||"auto"===v&&(y||g||b||x||!0===w)&&!R?Ii(a,{selections:x,showLegend:w,legendPosition:k,legendInteraction:$,legendSelectionName:C??F.name??"small-multiples",legendField:S??F.fields?.[0]??"category",children:O}):O}import*as Ti from"react";import{Fragment as Fi,jsx as Di,jsxs as Ei}from"react/jsx-runtime";function Oi({children:e,columns:t="auto",minCellWidth:i=300,gap:n=16,tabletColumns:r,mobileColumns:o=1,mobileBreakpoint:a=480,tabletBreakpoint:s=860,chartDefaults:l,className:c,style:d}){const u="semiotic-chart-grid-"+Ti.useId().replace(/[^a-zA-Z0-9_-]/g,""),m="number"==typeof t?t:void 0,p="auto"===t?`repeat(auto-fill, minmax(${i}px, 1fr))`:`repeat(${t}, 1fr)`,h=["semiotic-chart-grid",u,c].filter(Boolean).join(" ");return Ei(Fi,{children:[Di("style",{children:`\n ${r?`\n @media (max-width: ${s}px) {\n .${u} {\n grid-template-columns: repeat(${r}, minmax(0, 1fr)) !important;\n }\n }`:""}\n @media (max-width: ${a}px) {\n .${u} {\n grid-template-columns: repeat(${o}, minmax(0, 1fr)) !important;\n }\n .${u} > [data-semiotic-chart-grid-primary="true"] {\n grid-column: span ${o} !important;\n }\n }\n `}),Di("div",{className:h,style:{display:"grid",gridTemplateColumns:p,gap:n,width:"100%",...d},children:Ti.Children.map(e,e=>{if(!Ti.isValidElement(e))return e;const t=e.props,i={};if(l)for(const[e,n]of Object.entries(l))null==t[e]&&(i[e]=n);const n=Object.keys(i).length>0?Ti.cloneElement(e,i):e;return"primary"!==e.props.emphasis||void 0!==m&&2>m?n:Di("div",{"data-semiotic-chart-grid-primary":"true",style:{gridColumn:"span 2",minWidth:0},children:n})})})]})}Oi.displayName="ChartGrid";import*as Hi from"react";import{Fragment as Wi,jsx as Vi,jsxs as Gi}from"react/jsx-runtime";function Ui({children:e,context:t,position:i="right",contextSize:n=250,mobilePosition:r="bottom",mobileBreakpoint:o=480,gap:a=12,className:s,style:l}){const c="semiotic-context-layout-"+Hi.useId().replace(/[^a-zA-Z0-9_-]/g,""),d="left"===i||"right"===i,u="left"===i||"top"===i,m={display:"flex",flexDirection:d?u?"row-reverse":"row":u?"column-reverse":"column",gap:a,width:"100%",...l},p=d?{flex:`0 0 ${n}px`,width:n,minHeight:0}:{flex:`0 0 ${n}px`,height:n,minWidth:0};return Gi(Wi,{children:[Vi("style",{children:`\n @media (max-width: ${o}px) {\n .${c}[data-mobile-position="bottom"] {\n flex-direction: column !important;\n }\n .${c}[data-mobile-position="top"] {\n flex-direction: column-reverse !important;\n }\n .${c}[data-mobile-position="bottom"] > .semiotic-context-panel,\n .${c}[data-mobile-position="top"] > .semiotic-context-panel {\n flex: 0 0 auto !important;\n width: 100% !important;\n height: auto !important;\n }\n }\n `}),Gi("div",{className:["semiotic-context-layout",c,s].filter(Boolean).join(" "),"data-mobile-position":r,style:m,children:[Vi("div",{className:"semiotic-context-primary",style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:e}),Vi("div",{className:"semiotic-context-panel",style:p,children:t})]})]})}Ui.displayName="ContextLayout";import{useState as qi,useEffect as Ji,useRef as Xi,useCallback as _i}from"react";import{jsx as Qi,jsxs as Ki}from"react/jsx-runtime";function Zi({children:e,position:t="right",size:i=300,trigger:n="click",chartId:r,observation:o,dismissOnEmpty:a=!0,showClose:s=!0,onToggle:l,className:d,style:u}){const[m,p]=qi(null),[h,f]=qi(null),[g,b]=qi(!1),[y,v]=qi(!1),x=Xi(null),w=Xi(void 0),k="click"===n?["click","click-end"]:["hover","hover-end"],{latest:$}=c({types:k,chartId:r,limit:1}),C=void 0!==o?o:$,S=_i(()=>{v(!0),b(!1),clearTimeout(w.current),w.current=setTimeout(()=>{v(!1),p(null),f(null)},200)},[]);if(Ji(()=>{if(C)if("click"===C.type||"hover"===C.type){const e=C;p(e.datum),f(e),b(e=>(e||(v(!0),clearTimeout(w.current),w.current=setTimeout(()=>v(!1),200)),!0))}else!a||"click-end"!==C.type&&"hover-end"!==C.type||S()},[a,S,C]),Ji(()=>{l?.(g)},[g,l]),Ji(()=>()=>clearTimeout(w.current),[]),!m&&!y)return null;const A=m&&h?e(m,h):null;if(null===A&&!y)return null;const j=function(e,t,i,n){const r={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:n?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return"right"===e?{...r,top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:i?"translateX(0)":`translateX(${t}px)`,opacity:i?1:0}:"bottom"===e?{...r,bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:i?"translateY(0)":`translateY(${t}px)`,opacity:i?1:0}:{...r,top:"50%",left:"50%",transform:i?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:i?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"}}(t,i,g,y);return Ki("div",{ref:x,className:`semiotic-details-panel semiotic-details-${t}${d?" "+d:""}`,style:{...j,...u},children:[s&&Qi("button",{className:"semiotic-details-close",onClick:S,"aria-label":"Close details",style:Yi,children:Qi("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:Qi("path",{d:"M2 2l8 8M10 2l-8 8"})})}),Qi("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:A})]})}var Yi={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};function en(e){const t=e.designContract?.chartFamily??e.title??"chart",i=e.audience?.primary?" for "+e.audience.primary:"",n=e.designContract?.whyThisForm;return`${t}: ${e.intent.primary}${i}${n?". "+n:""}`}function tn(e,t){const i=e.intents.map(e=>"string"==typeof e?e:e.id??e.name).filter(e=>!!e),n=e.intents.find(e=>"string"!=typeof e&&"primary"===e.strength),r=("object"==typeof n?n.id??n.name:void 0)??i[0]??"explanation";return{ididVersion:"0.1",chartId:t.chartId,title:t.title??e.name,intent:{primary:r,secondary:i.filter(e=>e!==r)},audience:{primary:e.audience?.primary,familiarityAssumptions:Object.fromEntries(Object.entries(e.audience?.familiarity??{}).map(([e,t])=>[e,t+""])),literacyTargets:e.audience?.literacyTargets?.map(e=>({feature:e.concept,rationale:e.rationale}))},reception:e.reception?{channels:e.reception.channels,strengths:e.reception.strengths,risks:e.reception.risks,scaffolds:e.reception.scaffolds,memorableForm:e.reception.memorableForm}:void 0,designContract:{chartFamily:e.frameFamily,whyThisForm:e.designContract.whyThisForm??e.designContract.whyCustom,whyNotDefault:e.designContract.whyNotDefault,risks:e.reception?.risks,misuse:e.designContract.misuse},accessibility:{description:t.description,navigation:"required"===e.accessibility.keyboardNavigation||null!=e.navigation,dataFallback:!0===e.accessibility.fallbackTable||"required"===e.accessibility.accessibleTable||!0===e.accessibility.requiresAccessibleTable,manualChecks:["real screen-reader behavior","keyboard order quality","custom metaphor comprehension","animation distraction"]},provenance:t.dataSources||t.reviewStatus?{dataSources:t.dataSources,reviewStatus:t.reviewStatus,generatedBy:"Semiotic recipe intelligence"}:void 0}}Zi.displayName="DetailsPanel";import*as nn from"react";import{jsx as rn,jsxs as on}from"react/jsx-runtime";function an({manifest:e,label:t="Intent Mark",className:i,showSummary:n=!0}){const[r,o]=nn.useState(!1),a=nn.useMemo(()=>JSON.stringify(e,null,2),[e]),s=nn.useCallback(async()=>{"undefined"!=typeof navigator&&navigator.clipboard&&(await navigator.clipboard.writeText(a),o(!0),window.setTimeout(()=>o(!1),1200))},[a]);return on("details",{className:i?"semiotic-intent-mark "+i:"semiotic-intent-mark",style:{border:"1px solid var(--semiotic-border, #c8c8c8)",borderRadius:6,background:"var(--semiotic-surface, #fff)",color:"var(--semiotic-text, #222)",fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[on("summary",{style:{cursor:"pointer",padding:"7px 10px",fontSize:12,fontWeight:700,letterSpacing:"0.04em",textTransform:"uppercase"},children:[t," · ",e.intent.primary]}),on("div",{style:{padding:"0 10px 10px"},children:[n&&rn("p",{style:{margin:"4px 0 10px",fontSize:13,lineHeight:1.45},children:en(e)}),rn("button",{type:"button",onClick:s,style:{border:"1px solid currentColor",borderRadius:4,background:"transparent",color:"inherit",padding:"4px 8px",font:"inherit",fontSize:12,cursor:"pointer"},children:r?"Copied":"Copy manifest"}),rn("pre",{style:{maxHeight:280,overflow:"auto",margin:"10px 0 0",padding:10,background:"var(--semiotic-background, #f5f5f5)",fontSize:11,lineHeight:1.45,whiteSpace:"pre-wrap"},children:a})]})]})}import{useCallback as sn,useEffect as ln,useMemo as cn,useRef as dn,useState as un}from"react";var mn=["hover","click","focus","activate"];function pn(e){if("datum"===e.role&&e.datum)return e.datum;for(const t of e.children??[]){const e=pn(t);if(e)return e}return null}function hn(e,t){return e?t.map(t=>e[t]+"").join(""):""}function fn(e,t){if(e.id===t)return e;for(const i of e.children??[]){const e=fn(i,t);if(e)return e}return null}function gn(e){const{tree:t,chartId:i,observe:n=mn}=e,r=e.selectionName??"__semiotic-nav-sync"+(i?":"+i:""),o=cn(()=>{if(e.matchFields)return e.matchFields;const i=pn(t);return i?Object.keys(i).filter(e=>{return!e.startsWith("_")&&(null==(t=i[e])||"string"==typeof t||"number"==typeof t||"boolean"==typeof t);var t}):[]},[e.matchFields,t]),a=cn(()=>{const e=new Map,i=t=>{if("datum"===t.role&&t.datum){const i=hn(t.datum,o);e.has(i)||e.set(i,t.id)}for(const e of t.children??[])i(e)};return i(t),e},[t,o]),{selectPoints:s,clear:l}=p({name:r,fields:o}),d=cn(()=>[...n,"hover-end"],[n]),{latest:u}=c({chartId:i,types:d,limit:1}),[m,h]=un(t.id),f=dn(m);f.current=m;const g=dn(t);ln(()=>{const e=g.current;g.current=t;const i=fn(e,f.current),n=fn(t,f.current);"datum"===i?.role&&"datum"===n?.role&&i.datum&&n.datum&&o.length>0&&hn(i.datum,o)===hn(n.datum,o)||i&&n&&"datum"!==i.role&&"datum"!==n.role||(h(t.id),l())},[t,l,o]);const b=sn(e=>{if(h(e.id),"datum"===e.role&&e.datum&&o.length>0){const t={};for(const i of o)t[i]=[e.datum[i]];s(t)}else l()},[o,s,l]),y=e.annotations,v=cn(()=>{const e=new Set;if(0===o.length||!y)return e;for(const t of y){const i=a.get(hn(t,o));i&&e.add(i)}return e},[y,a,o]),x=sn(e=>{const t="number"==typeof e?y?.[e]:e;if(!t||0===o.length)return!1;const i=a.get(hn(t,o));if(!i)return!1;h(i);const n={};for(const e of o)n[e]=[t[e]];return s(n),!0},[y,a,o,s]),w=dn(null),k=sn(e=>{if(i&&e.chartId!==i)return;if("hover-end"===e.type){if(e===w.current)return;return void(w.current=e)}if(!function(e){return"hover"===e.type||"click"===e.type||"focus"===e.type||"activate"===e.type}(e))return;if(!n.includes(e.type))return;if(e===w.current)return;if(w.current=e,0===o.length)return;const t=function(e){const t=e,i=t.data;if(!i||"object"!=typeof i||Array.isArray(i))return e;const n=e=>e.every(e=>"number"==typeof t[e]),r=n(["x0","x1","y0","y1","width","height","value"]),o=n(["y0","y1","sankeyWidth","value"])&&"source"in t&&"target"in t;return r||o?i:e}(e.datum),r=a.get(hn(t,o));r&&h(e=>e===r?e:r)},[i,n,a,o]),$=dn(null);return ln(()=>{u&&u!==$.current&&($.current=u,k(u))},[u,k]),{activeId:m,onActiveChange:b,selection:{name:r},onObservation:k,handleObservation:k,annotatedIds:v,focusAnnotation:x}}import{Fragment as bn,jsx as yn,jsxs as vn}from"react/jsx-runtime";function xn({items:e,title:t="Additional notes",empty:i=null,ordered:n=!0,renderItem:r,className:o,style:a}){if(!e.length)return i?yn(bn,{children:i}):null;const s=n?"ol":"ul";return vn("section",{className:["semiotic-mobile-annotation-callouts",o].filter(Boolean).join(" "),style:a,children:[yn("style",{children:"\n .semiotic-mobile-annotation-callouts {\n display: grid;\n gap: 8px;\n padding: 10px 12px;\n border: 1px solid var(--semiotic-border, #d8d8d8);\n border-radius: 14px;\n background: var(--semiotic-bg, #fff);\n color: var(--semiotic-text, #222);\n }\n .semiotic-mobile-annotation-callouts h3 {\n margin: 0;\n font-size: 13px;\n font-weight: 800;\n line-height: 1.25;\n }\n .semiotic-mobile-annotation-callouts ol,\n .semiotic-mobile-annotation-callouts ul {\n display: grid;\n gap: 8px;\n margin: 0;\n padding-left: 18px;\n }\n .semiotic-mobile-annotation-callouts li {\n font-size: 13px;\n line-height: 1.45;\n }\n .semiotic-mobile-annotation-callouts small {\n display: block;\n margin-top: 2px;\n color: var(--semiotic-text-secondary, #666);\n font-size: 11px;\n line-height: 1.3;\n }\n "}),t&&yn("h3",{children:t}),yn(s,{children:e.map((e,t)=>yn("li",{children:r?r(e,t):vn(bn,{children:[yn("span",{children:e.label}),(e.source||e.emphasis)&&yn("small",{children:[e.emphasis,e.source].filter(Boolean).join(" - ")})]})},e.id))})]})}export{g as exportChart,v as defineChartRecipe,x as validateChartRecipe,w as isRegisteredRecipeLayout,k as isJsonSafe,I as resolveRecipeRoleField,L as recipeToChartCapability,M as registerChartRecipe,B as unregisterChartRecipe,z as getChartRecipe,T as listChartRecipes,F as getRegisteredRecipeCapabilities,D as hasRegisteredRecipeCapabilities,E as registerRecipeLayout,O as unregisterRecipeLayout,H as getRecipeLayout,W as resolveChartRecipe,q as recipeIntentId,J as recipeConfig,Q as fieldForRole,oe as toConfig,ae as fromConfig,se as toURL,le as fromURL,ce as copyConfig,de as configToJSX,ue as serializeSelections,me as deserializeSelections,ye as fromVegaLite,we as describeRecipeChart,Ee as communicativeActForIntent,Oe as resolveCommunicativeAct,Qe as describeChart,et as buildRecipeNavigationTree,tt as buildNavigationTree,it as flattenVisible,nt as countNodes,xt as subscribeToConversationArcChange,wt as registerConversationArcSink,kt as createLocalStorageConversationArcSink,$t as createIndexedDBConversationArcSink,Ct as createWebhookConversationArcSink,St as loadConversationArc,At as replayConversationArc,jt as recordAudienceChange,Nt as recordAnnotationStatusChange,Pt as enableConversationArc,Rt as disableConversationArc,Mt as getConversationArcStore,Et as AccessibleNavTree,Kt as auditMobileVisualization,ei as formatMobileVisualizationAudit,ti as mobileVisualizationCaveats,ki as ChartContainer,ji as MobileChartContainer,zi as SmallMultipleChart,Oi as ChartGrid,Ui as ContextLayout,Zi as DetailsPanel,en as summarizeIntentManifest,tn as intentManifestFromRecipe,an as IntentMark,gn as useNavigationSync,xn as MobileAnnotationCalloutList};
@@ -0,0 +1 @@
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.supportedThisStep.add(e.id),e.sleeping&&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.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})))}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 U(t){return!1!==t&&{...t}}function G(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(G),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:U(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:U(t.bodyBudget??{}),kernel:J(t.world.options)},this.bodyBudget=U(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(G),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};
@@ -0,0 +1 @@
1
+ import{contrastRatio as e,fieldForRole as t,recipeConfig as i,recipeIntentId as a}from"./chunk-chunk-UFFEXJQY.module.min.js";import{extractAllRows as n,resolveResponsiveRules as r}from"./chunk-chunk-CO5KQMGH.module.min.js";import*as s from"react";function o(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),i=Math.abs(t);return 1e9>i?1e6>i?1e4>i?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}var l=864e5;function c(e){return 10>e?"0"+e:e+""}var u=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function d(e){let t,i=e;return(a,n,r)=>{const s=a instanceof Date?a:new Date(a);e||!r||2>r.length||r===t||(t=r,i=function(e){if(2>e.length)return"days";const t=[];for(let i=1;e.length>i;i++)t.push(e[i]-e[i-1]);t.sort((e,t)=>e-t);const i=t[Math.floor(t.length/2)];return 12e4>i?"seconds":72e5>i?"minutes":2*l>i?"hours":60*l>i?"days":400*l>i?"months":"years"}(r));const o=i||"days";return null!=n&&0!==n&&r&&0!==r.length?function(e,t,i){const a=e.getUTCFullYear()!==t.getUTCFullYear(),n=a||e.getUTCMonth()!==t.getUTCMonth(),r=n||e.getUTCDate()!==t.getUTCDate(),s=r||e.getUTCHours()!==t.getUTCHours(),o=s||e.getUTCMinutes()!==t.getUTCMinutes(),l=u[e.getUTCMonth()],d=e.getUTCDate(),m=e.getUTCFullYear(),h=c(e.getUTCHours()),p=c(e.getUTCMinutes()),g=c(e.getUTCSeconds());switch(i){case"seconds":return a?`${l} ${d}, ${m} ${h}:${p}:${g}`:r?`${l} ${d} ${h}:${p}:${g}`:s?`${h}:${p}:${g}`:o?`${p}:${g}`:":"+g;case"minutes":return a?`${l} ${d}, ${m} ${h}:${p}`:r?`${l} ${d} ${h}:${p}`:s?`${h}:${p}`:":"+p;case"hours":return a?`${l} ${d}, ${m} ${h}:00`:n?`${l} ${d} ${h}:${p}`:r?`${l} ${d} ${h}:00`:h+":00";case"days":return a?`${l} ${d}, ${m}`:n?`${l} ${d}`:""+d;case"months":return a?`${l} ${m}`:""+l;case"years":return""+m}}(s,new Date(r[n-1]),o):function(e,t){const i=u[e.getUTCMonth()],a=e.getUTCDate(),n=e.getUTCFullYear(),r=c(e.getUTCHours()),s=c(e.getUTCMinutes()),o=c(e.getUTCSeconds());switch(t){case"seconds":return`${i} ${a}, ${n} ${r}:${s}:${o}`;case"minutes":case"hours":return`${i} ${a}, ${n} ${r}:${s}`;case"days":return`${i} ${a}, ${n}`;case"months":return`${i} ${n}`;case"years":return""+n}}(s,o)}}var m=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart","RealtimeLineChart","RealtimeHeatmap"]),h=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),p={Scatterplot:["pointRadius","hoverRadius"],BubbleChart:["pointRadius","hoverRadius"],ConnectedScatterplot:["pointRadius","hoverRadius"],QuadrantChart:["pointRadius","hoverRadius"],SwarmPlot:["pointRadius","hoverRadius"],DotPlot:["dotRadius","hoverRadius"]};function g(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function y(e){return"string"==typeof e&&e.trim().length>0}function b(e){const t=g(e.capability)?e.capability:null,i=g(e.recipe)?e.recipe:null,a=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,i?.mobile];for(const e of a)if(g(e))return e;return null}function f(e){return Array.isArray(e)&&e.length>=2&&"number"==typeof e[0]&&"number"==typeof e[1]&&Number.isFinite(e[0])&&Number.isFinite(e[1])?[e[0],e[1]]:null}function v(e){return f(e.size)||f(g(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function x(e,t){e.push({...t,status:"pass"})}function w(e,t){e.push({...t,status:"warn"})}function k(e,t){e.push({...t,status:"manual"})}function $(e,t={},i={}){const a=i.viewportWidth??390,n=i.targetSize??44,s=v(t),o=r(t,{width:a,height:s?.[1]}),l=[],c=v(t=o.props),u=b(t),d=function(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}(e,t),f=function(e){const t=b(e);return!0===e.responsive||!0===e.mobile||!0===t?.responsive||!0===t?.supportsResponsiveLayout||Array.isArray(t?.breakpoints)||"number"==typeof t?.minViewportWidth||"responsive"===t?.strategy||"small-multiples"===t?.strategy||"summary-cards"===t?.strategy||null!=e.mobileLayout||null!=e.responsiveRules||"mobile-readable"===e.density}(t),$=!0===i.inChartContainer,C=y(t.title)||y(t.summary)||y(t.description)||!0===u?.summary||y(u?.summary);if(o.matches.length>0&&x(l,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${o.matches.length} responsive rule(s) applied for the ${a}px mobile audit.`}),c){const[t,i]=c;t>a&&!f?w(l,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${a}px mobile viewport with no responsive/mobile transform hint.`,fix:"Use responsive sizing, responsiveRules/mobileLayout, or an explicit mobile variant that preserves the task instead of clipping the desktop chart."}):x(l,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof u?.minViewportWidth&&u.minViewportWidth>a&&w(l,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${u.minViewportWidth}px minimum, wider than the audited ${a}px viewport.`,fix:"Add a narrower breakpoint, summary-card fallback, or explicit horizontal-scroll affordance with a non-visual equivalent."});const n=t/Math.max(1,i);430>=a&&n>2.4&&"BigNumber"!==e&&w(l,{id:"layout.wide-aspect-ratio",category:"layout",impact:"medium",message:`Chart aspect ratio is ${n.toFixed(1)}:1, which tends to compress phone charts vertically.`,fix:"Prefer stacked sections, small multiples, cards plus a sparkline, or a taller mobile-specific chart ratio."}),160>i&&"BigNumber"!==e&&w(l,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${i}px; most phone charts need enough vertical room for marks plus readable labels.`,fix:"Reserve more vertical space, remove nonessential axes, or switch to a card/sparkline pattern with external labels."})}else k(l,{id:"layout.unknown-size",category:"layout",impact:"medium",message:"No explicit size is available to audit. This may be responsive, but static mobile overflow cannot be checked.",fix:"Audit rendered widths at 320, 360, 390, and 430px, or pass size/responsiveRules metadata into the config."});const A=function(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,g(e.frameProps)?e.frameProps.data:void 0];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i}(t);A>0&&(A>("number"==typeof u?.maxMarks?u.maxMarks:m.has(e)?1.25*a:h.has(e)?Math.max(8,Math.floor(a/34)):a)?w(l,{id:"density.mark-budget",category:"density",impact:m.has(e)?"medium":"high",message:`${A} data item(s) exceed the rough mobile density budget for ${e} at ${a}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):x(l,{id:"density.mark-budget",category:"density",impact:"medium",message:A+" data item(s) are within the rough mobile density budget for this component."}));const T=function(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i>0?i:null}(t),S=!1!==t.showAxes&&!1!==t.axis;if(S&&null!=T){const e=Math.max(3,Math.floor(a/58));T>e&&w(l,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${T} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${a}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else S&&(m.has(e)||h.has(e))&&k(l,{id:"density.axis-label-collision",category:"density",impact:"medium",message:"Axes are enabled, but label collision depends on rendered tick text and cannot be checked statically.",fix:"Verify tick labels at phone widths or provide explicit mobile tick density."});!function(e){const t=g(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=b(e),i=g(e.mobileInteraction)?e.mobileInteraction:null;return null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||null!=e.selection||null!=e.onClick||null!=e.onSelect||!0===e.mobileInteraction||!0===i?.tapToSelect||!0===i?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||y(t?.interaction?.hoverFallback)}(e)}(t)?x(l,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):w(l,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"The chart exposes tooltip/hover detail without an obvious tap, selection, or control alternative.",fix:"Enable tap-to-select, a persistent details panel, visible segment buttons, or another non-hover path for the same information."});const R=function(e,t){const i=p[e];if(!i)return null;let a=i.includes("hoverRadius")?30:null;for(const e of i){const i=t[e];"number"==typeof i&&Number.isFinite(i)&&i>0&&(a=null==a?i:Math.max(a,i))}return null==a?null:2*a}(e,t),M=g(t.mobileInteraction)?t.mobileInteraction:null,z=R??("number"==typeof M?.targetSize?M.targetSize:!0===t.mobileInteraction?44:"number"==typeof u?.minimumHitTarget?u.minimumHitTarget:"number"==typeof u?.interaction?.targetSize?u.interaction.targetSize:null);null!=z&&(24>z?w(l,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${z}px pointer target, below WCAG's 24px minimum.`,fix:"Increase mark radius/hoverRadius, add tap snapping to nearest datum, or provide larger external controls."}):n>z?w(l,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${z}px, above 24px but below the ${n}px comfortable phone target.`,fix:"Use hoverRadius/tapRadius near 44px while keeping the visible mark small if needed."}):x(l,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${z}px, meeting the configured ${n}px target.`}));const U=[];null==t.brush&&null==t.onBrush||U.push("brush"),!0===t.zoomable&&U.push("pan/zoom"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||U.push("legend filtering"),U.length>0&&!function(e,t){const i=b(e),a=g(e.mobileInteraction)?e.mobileInteraction:null,n=a?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(i?.interaction?.alternatives)&&i.interaction.alternatives.length>0)||!0===n||"all"===n||t.every(e=>"brush"===e?Array.isArray(n)?n.includes("brush"):"brush"===n:"pan/zoom"===e?Array.isArray(n)?n.includes("zoom"):"zoom"===n:"legend filtering"===e&&(Array.isArray(n)?n.includes("legend"):"legend"===n))}(t,U)&&w(l,{id:"interaction.complex-gesture-alternative",category:"interaction",impact:"high",message:`Mobile-hostile complex interaction detected: ${U.join(", ")} without standard control alternatives.`,fix:"Pair gestures with buttons, range inputs, chips, or a details panel that works with touch and keyboard."}),!1===t.showLegend||!1===t.legend||!0!==t.showLegend&&!0!==t.legend&&null==t.colorBy&&null==t.groupBy&&null==t.lineBy&&null==t.areaBy&&null==t.stackBy||!0===t.directLabel||!0===t.showLabels||"direct"===t.labelStrategy||"direct-end"===t.labelStrategy||"direct"===u?.labels?.strategy||"inline"===u?.labels?.strategy||"external"===u?.labels?.strategy||a>430||w(l,{id:"semantics.legend-over-direct-labels",category:"semantics",impact:"medium",message:"The chart appears to rely on a legend instead of direct labels at phone width.",fix:"Prefer direct end labels, inline labels, or a compact chip selector so readers do not bounce between plot and legend."});const P=Array.isArray(t.annotations)?t.annotations.filter(e=>g(e)):[];if(P.length>("number"==typeof u?.maxAnnotations?u.maxAnnotations:3)&&430>=a&&w(l,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:P.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),P.length>0){const e=P.filter(e=>!y(e.mobileText)&&!y(e.shortText)&&!y(e.label));e.length>0&&k(l,{id:"annotation.mobile-copy",category:"annotation",impact:"low",message:e.length+" annotation(s) lack explicit short/mobile copy.",fix:"Add mobileText or shortText for notes that need to survive narrow layouts."})}f||"BigNumber"===e||k(l,{id:"layout.no-responsive-transform",category:"layout",impact:"low",message:"No explicit responsive transformation hint is present.",fix:"Declare responsiveRules/mobileLayout or a density/label strategy so the mobile version is a designed transformation, not an accidental resize."}),d&&(u?(x(l,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart/recipe provides a mobileSemantics/mobile contract, so the audit can inspect its authored phone behavior."}),!1===u.custom?.dataBearingSceneNodes?w(l,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"medium",message:"Custom mobile contract says emitted scene nodes are not data-bearing.",fix:"Preserve datum references, semantic roles, or accessible-table fields so intelligence, navigation, and tap details can recover the chart's meaning."}):!0!==u.custom?.dataBearingSceneNodes&&k(l,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"low",message:"Custom chart mobile contract does not state whether scene nodes are data-bearing.",fix:"Set mobile.custom.dataBearingSceneNodes and mobile.custom.navigationGranularity for custom layouts and interoperability adapters."})):k(l,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart layout is opaque to static mobile analysis because no mobileSemantics/mobile contract is present.",fix:"Declare mobileSemantics with strategy, breakpoints, mark budgets, touch target size, interaction alternatives, and custom scene semantics."})),C||$||w(l,{id:"semantics.no-mobile-summary",category:"semantics",impact:"medium",message:"No title, summary, description, or ChartContainer context is visible from the config.",fix:"Add title/summary text or wrap in ChartContainer so the small-screen reader gets the task before the chart."});const I=l.filter(e=>"warn"===e.status),F={highRisk:I.filter(e=>"high"===e.impact).length,warnings:I.length,manual:l.filter(e=>"manual"===e.status).length,passes:l.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:a,ok:0===F.highRisk,summary:F,findings:l,reference:"Mobile visualization audit: informed by MobileVisFixer, mobile exploratory interaction research, small-multiple mobile studies, responsive visualization grammars, constraint-based breakpoints, and WCAG 2.2 input modalities."}}var C={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},A=["layout","density","interaction","annotation","semantics"];function T(e){const t=[],i=e.summary,a=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${i.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${a} - ${i.warnings} warning(s) - ${i.manual} manual check(s)`);for(const i of A){const a=e.findings.filter(e=>e.category===i&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+i.toUpperCase());for(const e of a)t.push(` ${C[e.status]} [${e.impact}] ${e.id}: ${e.message}`),!e.fix||"warn"!==e.status&&"manual"!==e.status||t.push(" -> "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function S(){return["Static audit only: rendered label collision, CSS-resolved type size, and actual touch behavior still require viewport testing.","Use multiple widths, usually 320, 360, 390, 430, and 768 CSS pixels.","A mobile pass means no high-risk static warnings, not that the chart is perceptually or ergonomically optimal."]}function R(e){const t={};for(const[i,a]of e){const e=[];for(const[,t]of a.clauses){const i={};for(const[e,a]of Object.entries(t.fields))i[e]="point"===a.type?{type:"point",values:Array.from(a.values)}:{type:"interval",range:a.range};e.push({clientId:t.clientId,type:t.type,fields:i})}t[i]={name:a.name,resolution:a.resolution,clauses:e}}return t}function M(e){const t=new Map;for(const[i,a]of Object.entries(e)){const e=new Map;for(const t of a.clauses){const i={};for(const[e,a]of Object.entries(t.fields))i[e]="point"===a.type?{type:"point",values:new Set(a.values)}:{type:"interval",range:a.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:i})}t.set(i,{name:a.name,resolution:a.resolution,clauses:e})}return t}async function z(e,t){const{format:i="png",filename:a="chart",scale:n=2,background:r="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const o=s.cloneNode(!0),l=s.getBoundingClientRect();if(o.getAttribute("width")||o.setAttribute("width",l.width+""),o.getAttribute("height")||o.setAttribute("height",l.height+""),o.getAttribute("xmlns")||o.setAttribute("xmlns","http://www.w3.org/2000/svg"),U(s,o),"svg"===i){const e=(new XMLSerializer).serializeToString(o);P(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),a+".svg")}else{const t=l.width*n,i=l.height*n,s=document.createElement("canvas");s.width=t,s.height=i;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,i),c.scale(n,n);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(o),m=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(m),p=new Image;p.width=l.width,p.height=l.height,await new Promise((e,t)=>{p.onload=()=>{c.drawImage(p,0,0),s.toBlob(i=>{i?(P(i,a+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(h)},p.onerror=()=>{URL.revokeObjectURL(h),t(Error("Failed to load SVG image"))},p.src=h})}}function U(e,t){const i=e.children,a=t.children,n=window.getComputedStyle(e),r=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of r){const i=n.getPropertyValue(e);i&&"none"!==i&&""!==i&&t.style?.setProperty(e,i)}for(let e=0;Math.min(i.length,a.length)>e;e++)U(i[e],a[e])}function P(e,t){const i=URL.createObjectURL(e),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function I(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function F(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function N(e){return"number"==typeof e&&Number.isFinite(e)}function L(e){if(N(e.x)&&N(e.y)&&N(e.w)&&N(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(N(e.x)&&N(e.y)&&N(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(N(e.cx)&&N(e.cy)&&N(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(N(e.cx)&&N(e.cy)&&N(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&N(e[0])&&N(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function B(e,t){const i=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),a=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return a>0?i/a:0}function D(e,i,a,n,r){if(e===i)return!0;const s=a.dataRoles.map(e=>t(e,n,r)).filter(e=>!!e).filter(t=>null!=e[t]&&null!=i[t]);return s.length>0&&s.every(t=>e[t]+""==i[t]+"")}function j(e,t,i,a,n,r="warn",s){return{id:e,category:t,status:i?"pass":r,message:i?a:n,...s?{evidence:s}:{}}}function q(r){const{recipe:s}=r,o=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(r.scene),l=r.layoutConfig??i({layoutConfig:r.layoutConfig}),c=r.dimensions.plot??{x:0,y:0,width:r.dimensions.width,height:r.dimensions.height},u=c.x??0,d=c.y??0,m=[],h=o.filter(e=>null!=F(e)),p=o.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||function(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));m.push(j("geometry.finite","geometry",0===p.length,"All emitted geometry is finite.",p.length+" marks contain non-finite geometry.","fail",{count:p.length}));const g=o.map(L),y=g.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;m.push(j("geometry.nonzero-area","geometry",0===y,"All bounded marks have positive area.",y+" marks have zero or negative area.","warn",{count:y}));const b=g.filter(e=>e&&(u>e.x0||d>e.y0||e.x1>u+c.width||e.y1>d+c.height)).length;m.push(j("geometry.bounds","geometry",0===b,"All bounded marks stay inside the plot.",b+" marks extend outside the plot bounds.","warn",{count:b}));const f=s.audit?.minimumHitTargetSize??s.accessibility.minimumHitTarget??24,v=g.filter(e=>!!e&&(f>e.x1-e.x0||f>e.y1-e.y0)).length;m.push(j("interaction.target-size","interaction",0===v,`All bounded targets meet the declared ${f}px minimum.`,`${v} targets are smaller than ${f}px in at least one dimension.`,"warn",{count:v,minimumTarget:f}));const x=h.map(I),w=x.filter(e=>!e).length,k=new Set,$=x.filter(e=>!(!e||!k.has(e)&&(k.add(e),1)));m.push(j("identity.stable-ids","identity",0===w,"Every data-bearing mark exposes a stable id.",w+" data-bearing marks have no pointId, id, or transition key.",s.audit?.requireStableIds?"fail":"warn",{missing:w})),m.push(j("identity.unique-ids","identity",0===$.length,"Stable mark ids are unique.",$.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set($)].slice(0,10)}));const C=x.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;C>0&&m.push({id:"identity.index-pattern",category:"identity",status:"warn",message:C+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const A=new Set;let T=0;const S=r.inputData;for(const e of h){const t=F(e),i=Array.isArray(t)?t:[t];let a=!1;for(const e of i)if(e&&"object"==typeof e)for(let t=0;S.length>t;t+=1)D(e,S[t],s,l,S)&&(A.add(t),a=!0);a||(T+=1)}const R=Math.max(0,S.length-A.size);m.push(j("coverage.input-data","coverage",0===R,"Every input datum is represented by the observed scene.",R+" input data items have no matching scene mark.",s.audit?.requireDatumCoverage?"fail":"warn",{represented:A.size,input:S.length})),m.push(j("coverage.scene-data","coverage",0===T,"Every data-bearing scene mark maps back to input data.",T+" scene marks do not map back to an input datum.","warn",{count:T}));const M=s.encodings?.some(e=>"count"===e.channel);!M&&h.length>A.size&&A.size>0&&m.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const z=h.filter(e=>!1===e.interactive).length;m.push(j("interaction.hit-targets","interaction",0===z&&h.length>0,"Every observed data-bearing scene node participates in hit testing.",0===h.length?"No data-bearing scene nodes were emitted for interaction.":z+" data-bearing marks explicitly disable interaction.","fail"));const U=(r.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),P=U.filter(e=>!k.has(e));m.push(j("coverage.annotation-anchors","coverage",0===P.length,U.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",P.length+" annotations point to missing scene ids.","fail",{unresolved:P}));const N=(r.chart?.selectedIds??[]).filter(e=>!k.has(e));r.chart?.selectedIds&&m.push(j("interaction.selection-reachability","interaction",0===N.length,"Selected/highlighted states resolve to observed marks.",N.length+" selected ids are not reachable in the scene.","fail",{missing:N}));const q=n(o),V=(s.accessibility.tableFields??s.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const i=e.role?s.dataRoles.find(t=>t.role===e.role):void 0;return i?t(i,l,S):void 0}).filter(e=>!!e),E=new Set(q.flatMap(e=>Object.keys(e.values))),W=V.filter(e=>!E.has(e));m.push(j("accessibility.table-fields","accessibility",0===W.length,V.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${W.join(", ")}.`,"fail",{expectedFields:V,observedFields:[...E]})),new Set(S.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=E.size&&[...E].every(e=>"category"===e||"value"===e)&&m.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const H=(s.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);m.push(j("accessibility.color-only","accessibility",0===H.length,"Every declared color encoding names a redundant cue.",H.length+" color encodings have no declared redundant cue.","warn"));const O=r.chart;if(O){for(const[e,t]of[["title",s.accessibility.requiresTitle],["summary",s.accessibility.requiresSummary],["description","required"===s.accessibility.description]])t&&m.push(j("accessibility."+e,"accessibility","string"==typeof O[e]&&O[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(s.accessibility.requiresAccessibleTable||"required"===s.accessibility.accessibleTable||s.accessibility.fallbackTable)&&m.push(j("accessibility.fallback-table","accessibility",!1!==O.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),O.navigationTree&&m.push(j("accessibility.navigation-depth","accessibility",(O.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const Y=r.theme?.background??"#ffffff",G=o.filter(t=>{const i=t.style?.fill??t.fill;if("string"!=typeof i||!i.startsWith("#")||!Y.startsWith("#"))return!1;const a=e(i,Y);return null!=a&&3>a}).length;m.push(j("visual.contrast","visual",0===G,"All statically checkable mark fills meet 3:1 contrast.",G+" marks have fill contrast below 3:1.","warn",{background:Y}));let J=0;const Q=g.filter(e=>!!e).slice(0,500);for(let e=0;Q.length>e;e+=1)for(let t=e+1;Q.length>t;t+=1).8>B(Q[e],Q[t])||(J+=1);J>Q.length&&m.push({id:"visual.overlap-density",category:"visual",status:"warn",message:J+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const K=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),X={dataRoles:s.dataRoles.map(e=>e.role),intents:s.intents.map(a).filter(e=>!!e),accessibilityExpectations:[...s.accessibility.requirements??[],...s.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===s.accessibility.fallbackTable||"required"===s.accessibility.accessibleTable||!0===s.accessibility.requiresAccessibleTable,designContractDeclared:!!s.designContract?.whyCustom},_=[...m,...K],Z=m.filter(e=>"fail"===e.status).length;return{recipeId:s.id,ok:0===Z,summary:{marks:o.length,passes:_.filter(e=>"pass"===e.status).length,warnings:_.filter(e=>"warn"===e.status).length,failures:Z,manual:_.filter(e=>"manual"===e.status).length},declaredSemantics:X,observedSceneEvidence:m,manualATChecks:K}}export{o as smartTickFormat,d as adaptiveTimeTicks,$ as auditMobileVisualization,T as formatMobileVisualizationAudit,S as mobileVisualizationCaveats,R as serializeSelections,M as deserializeSelections,z as exportChart,q as auditObservedScene};
@@ -0,0 +1 @@
1
+ function t(t){if(null==t)return()=>{};const n="function"==typeof t?t:n=>n[t];return t=>r(n(t))}function n(n,e){const r=t(n),o=t(e);return(t,n)=>{const e=o(t);return{value:e,x:r(t),y:e,category:n}}}function e(n,e){const r=t(e??"value"),o=null==n?void 0:"function"==typeof n?n:t=>t[n];return t=>{const n=o?o(t):void 0;return{value:r(t),category:null==n?void 0:n+""}}}function r(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,e){const o=null!=t.axis?e[t.axis]:null!=t.field?n[t.field]:e.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 i=r(o);if(void 0===i)return!1;if(void 0!==t.gt&&t.gt>=i)return!1;if(void 0!==t.gte&&t.gte>i)return!1;if(void 0!==t.lt&&i>=t.lt)return!1;if(void 0!==t.lte&&i>t.lte)return!1;if(void 0!==t.within){const[n,e]=t.within;if(n>i||i>e)return!1}if(void 0!==t.outside){const[n,e]=t.outside;if(i>=n&&e>=i)return!1}return!0}function i(t,n,e){const r=t.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(n,e):o(r,n,e))}function u(t,n,e){if(!n||0===n.length)return{};let r={};for(const o of n){if(!i(o,t,e))continue;const n="function"==typeof o.style?o.style(t,e):o.style;n&&(r={...r,...n})}return r}function a(t,n,e,r=t=>t){const o=t??(()=>({}));return n&&0!==n.length?(t,i)=>{const a=r(t),s={...o(t,i)};return Object.assign(s,u(a,n,e(a,i))),s}:o}function s(t,n,e){return t&&0!==t.length?(r,o)=>{const i=u(r,t,n(r,o)),a=e?e(r,o):void 0;return a?{...i,...a}:i}:e}function f(t,n,r,o){if(!t||0===t.length)return o;const i=e(n,r);return(n,e)=>{const r=n&&n.data||n,a=u(r,t,i(r)),s=o?o(n,e):void 0;return s?{...a,...s}:a}}function c(t,e,r,o){return s(t,n(e,r),o)}function l(t,n){const e=t.length,r=n.length,o=Array(r+1);for(let t=0;r>=t;t++)o[t]=t;for(let i=1;e>=i;i++){let e=o[0];o[0]=i;for(let u=1;r>=u;u++){const r=o[u];o[u]=t[i-1]===n[u-1]?e:1+Math.min(e,o[u],o[u-1]),e=r}}return o[r]}function d(t,n,e=3){let r,o=e+1;for(const e of n){const n=l(t.toLowerCase(),e.toLowerCase());o>n&&(o=n,r=e)}return o>e?void 0:r}function y(t){return t.length>3?[t[0],t[Math.floor(t.length/2)],t[t.length-1]]:[...t]}function v(t,n){if(0===n.length)return null;const e=t.toLowerCase();return n.find(t=>t.toLowerCase().includes(e)||e.includes(t.toLowerCase()))||(d(t,n,3)??null)}function h({componentName:t,data:n,accessors:e,requiredProps:r}){if(r)for(const[n,e]of Object.entries(r))if(null==e)return`${t}: ${n} is required. Provide a field name or function.`;if(null==n)return null;if(!Array.isArray(n)&&"object"==typeof n)return t+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(!Array.isArray(n)||0===n.length)return t+": No data provided. Pass a non-empty array to the data prop.";if(e){const r=y(n).find(t=>t&&"object"==typeof t);if(r){const n=Object.keys(r);for(const[o,i]of Object.entries(e))if(i&&"string"==typeof i&&!(i in r)){const e=v(i,n),r=e?` Try ${o}="${e}".`:"";return`${t}: ${o} "${i}" not found in data. Available fields: ${n.join(", ")}.${r}`}}}return null}function g({componentName:t,data:n,dataLabel:e="data"}){return null==n?`${t}: No ${e} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(n)?`${t}: ${e} 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 p({componentName:t,nodes:n,edges:e,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==n&&null==e)return null;if(o&&(!e||!Array.isArray(e)||0===e.length))return t+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!n||!Array.isArray(n)||0===n.length))return t+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&n&&n.length>0){const e=y(n).find(t=>t&&"object"==typeof t);if(e){const n=Object.keys(e);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in e)){const e=v(o,n),i=e?` Try ${r}="${e}".`:"";return`${t}: ${r} "${o}" not found in node data. Available fields: ${n.join(", ")}.${i}`}}}return null}export{t as makeRuleValueResolver,n as makeXYRuleContext,e as makeNodeRuleContext,o as matchesThreshold,i as ruleMatches,u as resolveStyleRules,a as composeStyleRules,s as makeStyleRuleStyleFn,f as styleRulesToNodeStyle,c as styleRulesToXYStyle,d as closestMatch,h as validateArrayData,g as validateObjectData,p as validateNetworkData};