semiotic 3.8.1 → 3.8.2

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 (147) hide show
  1. package/CLAUDE.md +3 -1
  2. package/README.md +53 -52
  3. package/ai/behaviorContracts.cjs +9 -0
  4. package/ai/dist/mcp-server.js +142 -13
  5. package/ai/schema.json +616 -42
  6. package/ai/surface-manifest.json +1 -1
  7. package/ai/system-prompt.md +5 -2
  8. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
  9. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
  10. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
  11. package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
  12. package/dist/chunk-chunk-27HVVXS6.module.min.js +1 -0
  13. package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
  14. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
  15. package/dist/chunk-chunk-2UN3ANRN.module.min.js +2 -0
  16. package/dist/chunk-chunk-2VUEY5TH.module.min.js +1 -0
  17. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  18. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  19. package/dist/chunk-chunk-5WEFWNUW.module.min.js +2 -0
  20. package/dist/chunk-chunk-6F6GEAQU.module.min.js +1 -0
  21. package/dist/chunk-chunk-7LHMKRKE.module.min.js +2 -0
  22. package/dist/chunk-chunk-BHYTYMY2.module.min.js +2 -0
  23. package/dist/chunk-chunk-C6EJ4IOD.module.min.js +2 -0
  24. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  25. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  26. package/dist/chunk-chunk-CYIML3AV.module.min.js +2 -0
  27. package/dist/chunk-chunk-DNY43POY.module.min.js +1 -0
  28. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  29. package/dist/chunk-chunk-E7MIQX7D.module.min.js +2 -0
  30. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  31. package/dist/chunk-chunk-ES4DCG3L.module.min.js +1 -0
  32. package/dist/chunk-chunk-FAKO3RGQ.module.min.js +2 -0
  33. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  34. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  35. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  36. package/dist/chunk-chunk-H4PPRW6N.module.min.js +1 -0
  37. package/dist/chunk-chunk-IFYPMWKY.module.min.js +1 -0
  38. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  39. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  40. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  41. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  42. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  43. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  44. package/dist/chunk-chunk-L6D3I3V7.module.min.js +2 -0
  45. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  46. package/dist/chunk-chunk-NO4MCQVD.module.min.js +1 -0
  47. package/dist/chunk-chunk-ODUZEEBH.module.min.js +2 -0
  48. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +2 -0
  49. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  50. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  51. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  52. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  53. package/dist/chunk-chunk-RH5TSQPH.module.min.js +1 -0
  54. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  55. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  56. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  57. package/dist/chunk-chunk-STZFFTAN.module.min.js +2 -0
  58. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  59. package/dist/chunk-chunk-T27ZEV6A.module.min.js +1 -0
  60. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +2 -0
  61. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  62. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  63. package/dist/chunk-chunk-W3DB2MN4.module.min.js +2 -0
  64. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  65. package/dist/chunk-chunk-WDIN4LRC.module.min.js +1 -0
  66. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  67. package/dist/chunk-chunk-XOYX77KF.module.min.js +2 -0
  68. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  69. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  70. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  71. package/dist/chunk-chunk-Z5KXAVQD.module.min.js +2 -0
  72. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  73. package/dist/chunk-chunk-ZLKRTF5N.module.min.js +2 -0
  74. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +2 -0
  75. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  76. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  77. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  78. package/dist/components/server/staticSVGChrome.d.ts +3 -2
  79. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  80. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  81. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  82. package/dist/controls.min.js +1 -1
  83. package/dist/controls.module.min.js +1 -1
  84. package/dist/geo.min.js +1 -1
  85. package/dist/geo.module.min.js +1 -1
  86. package/dist/network.min.js +1 -1
  87. package/dist/network.module.min.js +1 -1
  88. package/dist/ordinal.min.js +1 -1
  89. package/dist/ordinal.module.min.js +1 -1
  90. package/dist/physics-matter.min.js +1 -1
  91. package/dist/physics-matter.module.min.js +1 -1
  92. package/dist/physics-rapier.min.js +1 -1
  93. package/dist/physics-rapier.module.min.js +1 -1
  94. package/dist/physics.min.js +1 -1
  95. package/dist/physics.module.min.js +1 -1
  96. package/dist/realtime.min.js +1 -1
  97. package/dist/realtime.module.min.js +1 -1
  98. package/dist/rough.min.js +1 -1
  99. package/dist/rough.module.min.js +1 -1
  100. package/dist/semiotic-ai-core.min.js +1 -1
  101. package/dist/semiotic-ai-core.module.min.js +1 -1
  102. package/dist/semiotic-ai.min.js +1 -1
  103. package/dist/semiotic-ai.module.min.js +1 -1
  104. package/dist/semiotic-data.min.js +1 -1
  105. package/dist/semiotic-data.module.min.js +1 -1
  106. package/dist/semiotic-experimental.min.js +1 -1
  107. package/dist/semiotic-experimental.module.min.js +1 -1
  108. package/dist/semiotic-realtime-core.min.js +1 -1
  109. package/dist/semiotic-realtime-core.module.min.js +1 -1
  110. package/dist/semiotic-realtime-react.min.js +1 -1
  111. package/dist/semiotic-realtime-react.module.min.js +1 -1
  112. package/dist/semiotic-recipes-core.min.js +1 -1
  113. package/dist/semiotic-recipes-core.module.min.js +1 -1
  114. package/dist/semiotic-recipes-react.min.js +1 -1
  115. package/dist/semiotic-recipes-react.module.min.js +1 -1
  116. package/dist/semiotic-recipes.min.js +1 -1
  117. package/dist/semiotic-recipes.module.min.js +1 -1
  118. package/dist/semiotic-server-edge.min.js +1 -1
  119. package/dist/semiotic-server-edge.module.min.js +1 -1
  120. package/dist/semiotic-server-node.min.js +1 -1
  121. package/dist/semiotic-server-node.module.min.js +1 -1
  122. package/dist/semiotic-themes-core.min.js +1 -1
  123. package/dist/semiotic-themes-core.module.min.js +1 -1
  124. package/dist/semiotic-themes-react.min.js +1 -1
  125. package/dist/semiotic-themes-react.module.min.js +1 -1
  126. package/dist/semiotic-themes.min.js +1 -1
  127. package/dist/semiotic-themes.module.min.js +1 -1
  128. package/dist/semiotic-utils-core.min.js +1 -1
  129. package/dist/semiotic-utils-core.module.min.js +1 -1
  130. package/dist/semiotic-utils-react.min.js +1 -1
  131. package/dist/semiotic-utils-react.module.min.js +1 -1
  132. package/dist/semiotic-utils.min.js +1 -1
  133. package/dist/semiotic-utils.module.min.js +1 -1
  134. package/dist/semiotic-value.min.js +1 -1
  135. package/dist/semiotic-value.module.min.js +1 -1
  136. package/dist/semiotic.min.js +1 -1
  137. package/dist/semiotic.module.min.js +1 -1
  138. package/dist/server.min.js +1 -1
  139. package/dist/server.module.min.js +1 -1
  140. package/dist/xy.min.js +1 -1
  141. package/dist/xy.module.min.js +1 -1
  142. package/package.json +4 -4
  143. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  144. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  145. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  146. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  147. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -1 +1 @@
1
- import{interpolateLab as t}from"d3-interpolate";function e(t){return"function"==typeof t?t:e=>e[t]}function n(t,e,n){const o=t?.data,r=o?o[e]:void 0;if(null!=r)return r;const i=t?.[e];return null==i?n:i}function o(t){return null==t?null:t.data??t.datum??t}function r(t,e){const n=new Map;for(const o of t){const t=e(o),r=n.get(t);r?r.push(o):n.set(t,[o])}return n}function i(t){const e=Object.create(null);return t((t,n)=>{e[t]=n}),e}function a(t,e){if(!e)return!0;const n=Array.isArray(e)?e:[e],o=t;for(const t of n)if(null!=t.value&&o[t.field]+""!=t.value+"")return!1;return!0}function s(t,e={}){const n=e.baseOpacity??1;return e.highlight||e.predicate?!a(t,e.highlight)||e.predicate&&!e.predicate(t)?e.dimOpacity??.16:Math.min(1,n+(e.brighten??0)):n}function c(t){return t.join("|")}var l=class{constructor(t=12){this.maxSize=t,this.store=new Map}get(t){return this.store.get(t)}set(t,e){this.maxSize>this.store.size||this.store.clear(),this.store.set(t,e)}getOrCompute(t,e){const n=this.store.get(t);if(void 0!==n)return n;const o=e();return this.set(t,o),o}clear(){this.store.clear()}get size(){return this.store.size}};function u(e,n=.72){const o=t(e,"#ffffff"),r=t(e,"#000000"),i=t(e,e)(0);return t=>{const e=0>t?0:t>1?1:t;return.5===e?i:.5>e?o(2*(.5-e)*n):r(2*(e-.5)*n)}}function d(t,e,n=.72){return u(t,n)(e)}function h(t){return i(e=>{for(const[n,o]of Object.entries(t))e(n,o)})}function f(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function m(t,e,n){return Math.max(e,Math.min(n,t))}function p(t){const e=Number(t);return Number.isFinite(e)?Math.max(0,e):0}function y(t){if(0===t.length)return 0;let e=0;for(const n of t)e+=n;return e/t.length}function g(t,e){const n=m(e,0,1),o=t.trim().replace(/^#/,""),r=3===o.length?o.split("").map(t=>t+t).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:t}var x=t=>{const e=t.config,n=e.rows??10,o=e.columns??10,r=e.gutter??2,a=n*o;if(0>=n||0>=o||0>=a)return{nodes:[]};const{plot:s}=t.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};const c=(s.width-r*(o-1))/o,l=(s.height-r*(n-1))/n;if(0>=c||0>=l)return{nodes:[]};const u=(null==(d=e.categoryAccessor)?null:"function"==typeof d?d:t=>t[d])??(()=>"_default");var d;const h=function(t){return null==t?null:"function"==typeof t?t:e=>Number(e[t])}(e.valueAccessor)??(()=>1),f=new Map,m=[];for(const e of t.data){const t=u(e)+"",n=Number(h(e)),o=Number.isFinite(n)?Math.max(0,n):0;f.has(t)||m.push(t),f.set(t,(f.get(t)??0)+o)}const p=Array.from(f.values()).reduce((t,e)=>t+e,0);if(0>=p)return{nodes:[]};let y;if(e.categoryOrder&&e.categoryOrder.length>0){const t=new Set,n=[];for(const o of e.categoryOrder)f.has(o)&&!t.has(o)&&(t.add(o),n.push(o));y=[...n,...m.filter(e=>!t.has(e))]}else y=m;if(0===y.length)return{nodes:[]};const g=y.map(t=>({cat:t,exact:(f.get(t)??0)/p*a})).map(t=>({...t,count:Math.floor(t.exact)})),x=g.reduce((t,e)=>t+e.count,0),b=g.map((t,e)=>({i:e,rem:t.exact-t.count})).sort((t,e)=>e.rem-t.rem);for(let t=0;a-x>t;t++)g[b[t%b.length].i].count+=1;const w="string"==typeof e.categoryAccessor?e.categoryAccessor:"category",M="string"==typeof e.valueAccessor?e.valueAccessor:"value",v=(t,e,n)=>i(o=>{o("category",t),o("value",f.get(t)??0),o("share",(f.get(t)??0)/p),"category"!==w&&o(w,t),"value"!==M&&o(M,f.get(t)??0),o("cells",n),o("_waffleCategory",t),o("_waffleIndex",e)}),k=[];let $=0;for(const e of g){const i=t.resolveColor(e.cat);for(let t=0;e.count>t;t++)k.push({type:"rect",x:s.x+$%o*(c+r),y:s.y+(n-1-Math.floor($/o))*(l+r),w:c,h:l,style:{fill:i,stroke:"none"},datum:v(e.cat,$,e.count),group:e.cat,_transitionKey:`waffle-${e.cat}-${t}`}),$++}return{nodes:k}};function b(t,e,n){const o=Math.max(0,Math.floor(n?.minPerCategory??0)),r=t.reduce((t,e)=>t+Math.max(0,e.weight),0);if(0>=e||0>=r)return t.map(t=>({...t,exact:0,cells:0,remainder:0}));const i=t.map(t=>{const n=Math.max(0,t.weight)/r*e;return{...t,exact:n,cells:Math.max(o,Math.floor(n)),remainder:n-Math.floor(n)}});let a=i.reduce((t,e)=>t+e.cells,0);for(;a>e;){const t=i.filter(t=>t.cells>o).sort((t,e)=>e.cells-t.cells||t.remainder-e.remainder||t.key.localeCompare(e.key))[0];if(!t)break;t.cells--,a--}const s=[...i].sort((t,e)=>e.remainder-t.remainder||e.weight-t.weight||t.key.localeCompare(e.key));for(let t=0;e>a;t++)s[t%s.length].cells++,a++;return i}var w=1e-6;function M(t){return Number.isFinite(t)?Math.max(0,t):0}function v(t,e){const n=Number(e.unit),o=M(t),r=e.maxUnits??1/0,i=e.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const a=Math.ceil(o/n-w),s=Math.min(r,a),c=a>r,l=[];for(let t=0;s>t;t+=1){const e=t*n;let r=Math.min(1,Math.max(0,(Math.min(o,e+n)-e)/n));w>1-r&&(r=1),l.push({index:t,fraction:r,start:e,end:e+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((t,e)=>t+e.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function k(t,e,n){const o=v(t,n),r=Math.max(M(e),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=v(r,{unit:n.unit,maxUnits:n.maxUnits}),a=i.unit>0?o.total/i.unit:0,s=Math.floor(a+w);let c=Math.min(1,Math.max(0,a-s));w>c&&(c=0);const l=[];for(const t of i.units)s>t.index||(t.index===s&&c>0?t.fraction-c>w&&l.push({...t,startFraction:c,start:t.index*i.unit+c*i.unit,value:(t.fraction-c)*i.unit}):l.push({...t,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}import{forceCenter as $,forceCollide as A,forceLink as S,forceManyBody as I,forceSimulation as z,forceX as N,forceY as C}from"d3-force";function T(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function E(t,e,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=T(n.seed??1),f=new Map;for(const e of t)f.set(e.id,0);for(const t of e)f.set(t.source,(f.get(t.source)??0)+1),f.set(t.target,(f.get(t.target)??0)+1);const m=500,p=t.map(t=>({id:t.id,data:t,x:200+600*h(),y:200+600*h()})),y=new Set(t.map(t=>t.id)),g=e.filter(t=>y.has(t.source)&&y.has(t.target)).map(t=>({source:t.source,target:t.target}));if(o>0){const t=z(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",I().strength(t=>{const e=f.get(t.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(e+1)})).force("collide",A(t=>(t=>"function"==typeof l?l(t.data):l)(t)+u).strength(.9).iterations(2)).force("center",$(m,m).strength(.8)).force("x",N(m).strength(s)).force("y",C(m).strength(s));g.length>0&&t.force("link",S(g).id(t=>t.id).distance(i).strength(t=>{const e="string"==typeof t.target?t.target:t.target.id,n=Math.max(1,Math.min(f.get("string"==typeof t.source?t.source:t.source.id)??1,f.get(e)??1));return a/.045/n})),t.stop();for(let e=0;o>e;e+=1)t.tick()}let x=1/0,b=1/0,w=-1/0,M=-1/0;for(const t of p){const e=t.x??m,n=t.y??m;x>e&&(x=e),b>n&&(b=n),e>w&&(w=e),n>M&&(M=n)}const v=w-x,k=M-b,E={};for(const t of p)E[t.id]={x:0===v?.5:d+((t.x??m)-x)/v*(1-2*d),y:0===k?.5:d+((t.y??m)-b)/k*(1-2*d)};return E}function W(t){return t?t.map(Number).filter(Number.isFinite):[]}function L(t){if("fixed-denominator"===t.countStrategy)return 1/0;const e=t.maxTokens??1/0;return e>0?Math.floor(e):0}function F(t){const e=t.unitValue??t.unit,n=t.icon??t.token;return{...t,...null!=e&&{unitValue:e},...null!=n&&{icon:n}}}function j(t){if(t.samples)return W(t.samples);if(!t.data||!t.valueAccessor)return[];const e=t.valueAccessor;return t.data.map(t=>"function"==typeof e?e(t):Number(t[e])).filter(Number.isFinite)}function R(t,e,n,o={}){return{index:e,tokenType:t.tokenType,tokenSemantics:t.tokenSemantics,countStrategy:t.countStrategy,fraction:1,startFraction:0,value:n,start:e,end:e+n,unitValue:t.unitValue,unitMeaning:t.unitMeaning,...o}}function O(t,e){const n=F(e),o=function(t){return"number"==typeof t?{value:t}:Array.isArray(t)?{samples:W(t),data:t}:t}(t);let r,i,a,s,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const t={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},e=null==o.rangeValue?v(p(o.value),t):k(p(o.value),p(o.rangeValue),t);r=e.units.map(t=>R(n,t.index,t.value,{fraction:t.fraction,start:t.start,end:t.end,unitValue:e.unit})),i=e.total,d=e.shown,h=e.overflow,null!=o.rangeValue&&(l=e.rangeTotal,u=e.rangeUnits.map(t=>R(n,t.index,t.value,{fraction:t.fraction,startFraction:t.startFraction,start:t.start,end:t.end,unitValue:e.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){s=Math.floor(p(o.denominator??n.denominator)),a=p(o.numerator??n.numerator??o.value);const t=Math.min(s,Math.max(0,Math.round(a)));r=Array.from({length:s},(e,o)=>R(n,o,1,{highlighted:t>o,start:o,end:o+1})),i=s,d=r.length,h=!1}else if("quantile"===n.countStrategy){const t=j(o).sort((t,e)=>t-e),e=Math.max(0,Math.floor(n.tokenCount??50)),a=t.length>0?Math.min(e,L(n)):0;r=Array.from({length:a},(e,o)=>{const r=(o+.5)/a,i=function(t,e){const n=t.length;if(0===n)return 0;if(1===n)return t[0];const o=(n-1)*Math.min(1,Math.max(0,e)),r=Math.floor(o),i=o-r;return t[r]*(1-i)+t[Math.ceil(o)]*i}(t,r);return R(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=t.length,d=r.length,h=t.length>0&&e>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const t=j(o),e=Math.min(t.length,Math.max(0,Math.floor(n.tokenCount??t.length))),a=Math.min(e,L(n));r=("random-sample"===n.countStrategy?function(t,e=1){const n=Array.from({length:t},(t,e)=>e),o=T(Math.floor(e)||1);for(let t=n.length-1;t>0;t-=1){const e=Math.floor(o()*(t+1)),r=n[t];n[t]=n[e],n[e]=r}return n}(t.length,n.seed).slice(0,a):Array.from({length:a},(e,n)=>Math.floor(n/Math.max(1,a-1)*(t.length-1)))).map((e,o)=>{const r=t[e];return R(n,o,r,{sample:r,start:r,end:r})}),i=t.length,d=r.length,h=e>r.length}else{const t=o.data;if(t&&null==o.value)r=t.map((t,e)=>R(n,e,1,{datum:t})),i=t.length;else{const t=v(p(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=t.units.map(t=>R(n,t.index,t.value,{fraction:t.fraction,start:t.start,end:t.end,unitValue:1})),i=t.total,d=t.shown,h=t.overflow}if(t&&null==o.value){const t=function(t,e){const n=L(e);return t.length>n?{tokens:t.slice(0,n),overflow:!0}:{tokens:t,overflow:!1}}(r,n);r=t.tokens,d=r.length,h=t.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:a,denominator:s,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:q(n,{visibleTokens:r.length+(u?.length??0)})}}function P(t,e={}){const n=Array.isArray(t)?t:t.tokens,o=n.length;if(0===o)return[];const r=e.flow??"row",i=e.cellWidth??16,a=e.cellHeight??i,s=e.gutter??2,c=e.anchor??[.5,.5],l=Math.max(1,Math.floor(e.columns??Math.ceil(e.rows?o/e.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(e.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=e.x??0,m=e.y??0;return n.map((t,n)=>{let o,p;return"column"===r?(p=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),p=n%l),"left"===e.columnDirection&&(p=h-1-p),"up"===e.rowDirection&&(o=d-1-o),{...t,row:o,column:p,x:f+p*(i+s)+c[0]*i,y:m+o*(a+s)+c[1]*a}})}function q(t,e={}){const n=[],o=t.tokenSemantics,r=t.countStrategy,i=e.maxRecommendedTokens??("fixed-denominator"!==r||p(t.denominator)>100?80:100);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==t.tokenType&&"glyph"!==t.tokenType||"icon-only"!==t.labelPolicy&&"token-only"!==t.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=e.visibleTokens&&e.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${e.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==t.tokenType&&"glyph"!==t.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==t.unitValue&&null==t.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||t.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function D(t){return"measure"===t?"precise-comparison":"estimate probability"===t?"probability-estimation":"understand risk"===t?"risk-communication":"remember"===t?"memory":"decide"===t?"support-decision":t}function B(t){const e=D(t);return"precise-comparison"===e?["compare-categories","rank"]:"probability-estimation"===e?["distribution"]:"risk-communication"===e?["part-to-whole","distribution"]:"frequency-reasoning"===e?["distribution","compare-categories"]:"memory"===e||"editorial-engagement"===e?["compare-categories"]:"public-explanation"===e||"support-decision"===e?["distribution","compare-categories"]:["compare-categories"]}function Y(t){const e=D(t.taskIntent),n="small"===(o=t.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===e)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===e){const t={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:t,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:q(t),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===e){const e={tokenType:t.concreteEntity?"icon":"dot",icon:t.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:e,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:q(e,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===e||"editorial-engagement"===e){const e={tokenType:t.concreteEntity?"glyph":"icon",icon:t.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:t.concreteEntity?"one token represents a unit of "+t.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:e,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:q(e),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===e||"public-explanation"===e||"support-decision"===e){const e={tokenType:t.concreteEntity?"icon":"dot",icon:t.concreteEntity,tokenSemantics:"distribution"===t.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===t.dataType?"quantile":"unitized",unitValue:"distribution"===t.dataType?void 0:1,tokenCount:n,layout:"distribution"===t.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===t.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:e,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:q(e),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}import{symbol as V,symbolCircle as H,symbolCross as X,symbolDiamond as _,symbolSquare as G,symbolStar as U,symbolTriangle as K,symbolWye as Q}from"d3-shape";var Z={circle:H,square:G,triangle:K,diamond:_,star:U,cross:X,wye:Q},J=["circle","triangle","diamond","star","square","chevron","cross","wye"];function tt(t,e,n){if(n)return n;const o=t??"circle";return"chevron"===o?function(t){const e=1.5*et(t),n=.92*e;return`M0,${-e}L${n},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-n},${(.78*e).toFixed(3)}Z`}(e):V(Z[o]??H,Math.max(1,e))()??""}function et(t){return Math.sqrt(Math.max(1,t)/Math.PI)}var nt=new Map;function ot(t,e,n){if(!n&&"circle"===(t??"circle"))return et(e);const o=n?"p:"+n:`${t}:${Math.round(e)}`,r=nt.get(o);if(null!=r)return r;const i=(n??tt(t,e)).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let a=0;if(i)for(let t=0;i.length>t+1;t+=2){const e=+i[t],n=+i[t+1],o=Math.sqrt(e*e+n*n);o>a&&(a=o)}return a>0||(a=et(e)),nt.size>512&&nt.clear(),nt.set(o,a),a}var rt="#334155",it="#f8fafc",at="#cbd5e1",st={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},ct={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},lt={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},ut={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},dt="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",ht={viewBox:[18,40],anchor:[.5,1],parts:[{d:dt,fill:"color",stroke:"color",strokeWidth:1.4}]},ft={server:st,chip:ct,bolt:lt,bus:ut,person:ht},mt="var(--semiotic-primary, #4e79a7)",pt="var(--semiotic-border, #d1d5db)";function yt(t){return"object"==typeof t&&null!==t&&"tokens"in t&&"encoding"in t}function gt(t,e,n){return"function"==typeof t?t(e)??n:t??n}function xt(t,e){return"function"==typeof t?t(e):t}function bt(t){return t.sample??t.value??t.index}var wt=new Set(J);function Mt(t,e){return void 0!==e.datum?gt(e.datum,t,null):t.datum??null}function vt(t,e){return{fill:!1!==t.highlighted?"scenario"===t.range?gt(e.rangeColor,t,"var(--semiotic-secondary, #9ca3af)"):gt(e.color,t,mt):gt(e.inactiveColor,t,pt),stroke:"none",...xt(e.style,t)??{}}}function kt(t,e){const n=xt(e.pointId,t)??(e.idPrefix?`${e.idPrefix}-${"scenario"===t.range?"range-":""}${t.index}`:void 0);return{datum:Mt(t,e),accessibleDatum:xt(e.accessibleDatum,t),accessibility:xt(e.accessibility,t),pointId:n,_transitionKey:n}}function $t({input:t,encoding:e,options:n={}}){if(!yt(t)&&!e)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=yt(t)?{...t,encoding:F(t.encoding)}:O(t,e),r=function(t,e){const n=e.includeRange&&t.rangeTokens?[...t.tokens,...t.rangeTokens]:t.tokens;if(e.positionToken)return function(t,e){const n=e.positionToken;return n?t.map((e,o)=>{const r=n(e,o,t);return{...e,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,e);const o=e.layout??t.encoding.layout??"grid";if("quantile-strip"===o)return function(t,e){if(0===t.length)return[];const n=e.x??0,o=e.y??0,r=e.cellHeight??("number"==typeof e.tokenSize?e.tokenSize:12),i=e.gutter??2,a=Math.max(1,Math.floor(e.rows??1)),s=t.map(bt),c=Math.min(...s),l=Math.max(...s)-c||1;return t.map((s,u)=>{const d=bt(s),h=u%a,f=e.valueToX?e.valueToX(d,s):n+(d-c)/l*(e.width??12*Math.max(1,t.length-1)),m=e.valueToY?e.valueToY(d,s):o+h*(r+i);return{...s,x:f,y:m,row:h,column:u}})}(n,e);if("dotplot"===o)return function(t,e){if(0===t.length)return[];const n=e.x??0,o=e.y??0,r="number"==typeof e.tokenSize?e.tokenSize:12,i=e.gutter??2,a=e.cellWidth??r+i,s=e.cellHeight??r+i,c=t.map(bt),l=Math.min(...c),u=Math.max(...c)-l||1,d=new Map;return t.map(r=>{const i=bt(r),c=e.valueToX?e.valueToX(i,r):n+(i-l)/u*(e.width??Math.max(1,t.length-1)*a),h=Math.round((c-n)/Math.max(1,a)),f=d.get(h)??0;d.set(h,f+1);const m=e.valueToY?e.valueToY(i,r):o+f*s;return{...r,x:n+h*a,y:m,row:f,column:h}})}(n,e);if("bar-segment"===o){if(!e.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(t,e){if(!e.valueToX)return[];const n=e.y??0,o=e.cellHeight??("number"==typeof e.tokenSize?e.tokenSize:12),r=e.anchor??[.5,.5];return t.map((t,i)=>{const a=Number.isFinite(t.start)?t.start:bt(t),s=(a+(Number.isFinite(t.end)?t.end:a+t.value))/2,c=e.valueToY?e.valueToY(s,t):n+r[1]*o;return{...t,x:e.valueToX(s,t),y:c,row:0,column:i}})}(n,e)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof e.tokenSize?e.tokenSize:void 0,i=e.cellWidth??r??12,a=e.cellHeight??r??i,s="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===t.encoding.countStrategy&&100===t.denominator?10:function(t,e,n){if(e.columns)return e.columns;if(e.width&&n>0){const t=e.gutter??2;return Math.max(1,Math.floor((e.width+t)/(n+t)))}return t.length>0?Math.ceil(Math.sqrt(t.length)):1}(n,e,i);return P(n,{...e,columns:s,cellWidth:i,cellHeight:a})}(o,n).filter(t=>!n.include||n.include(t));return{tokenSet:o,positionedTokens:r,nodes:r.map(t=>function(t,e,n){if("dot"===n.tokenType)return function(t,e){const n=gt(e.tokenSize,t,12);return{type:"point",x:t.x,y:t.y,r:gt(e.radius,t,n/2),style:vt(t,e),...kt(t,e)}}(t,e);const o=xt(e.glyph,t)??function(t){if(t)return ft[t]}(n.icon);if(o)return function(t,e,n){const o=vt(t,n),r=gt(n.tokenSize,t,12);return{type:"glyph",x:t.x,y:t.y,size:r,glyph:e,color:(o.fill??mt)+"",accent:gt(n.accent,t,"var(--semiotic-bg, #ffffff)"),fraction:1>t.fraction?t.fraction:void 0,fractionStart:t.startFraction>0?t.startFraction:void 0,fractionDirection:gt(n.fractionDirection,t,"horizontal"),ghostColor:1>t.fraction?xt(n.ghostColor,t)??pt:void 0,rotation:xt(n.rotation,t),style:o,...kt(t,n)}}(t,o,e);const r=(i=n.icon)&&wt.has(i)?i:void 0;var i;return function(t,e){const n=gt(e.tokenSize,t,12);return{type:"symbol",x:t.x,y:t.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:gt(e.symbolType,t,"circle"),path:xt(e.symbolPath,t),rotation:xt(e.rotation,t),style:vt(t,e),...kt(t,e)}}(t,r&&null==e.symbolType?{...e,symbolType:r}:e)}(t,n,o.encoding))}}import{interpolateRgb as At}from"d3-interpolate";var St=864e5,It=t=>{const e=t.config,{plot:n}=t.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=t=>{const n="function"==typeof e.dateAccessor?e.dateAccessor(t):t[e.dateAccessor];return n instanceof Date?n:new Date(n)},r=t=>{const n="function"==typeof e.valueAccessor?e.valueAccessor(t):t[e.valueAccessor];return Number(n)},i=new Map;let a=null;for(const e of t.data){const t=o(e);if(!isFinite(t.getTime()))continue;null==a&&(a=t.getUTCFullYear());const n=zt(t),s=r(e);i.set(n,(i.get(n)??0)+(Number.isFinite(s)?s:0))}const s=e.year??a??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const t of i.values())c>t&&(c=t),t>l&&(l=t);c===1/0&&(c=0,l=0);const[u,d]=e.colorRamp??[t.theme.semantic.surface??"#ebedf0",t.theme.semantic.primary??"#216e39"],h=t=>{if(l===c)return u;const e=(t-c)/(l-c);return At(u,d)(e)},f=e.gutter??2,m=e.labelInset??0,p=Math.min((n.width-m-53*f)/54,(n.height-6*f)/7);if(0>=p)return{nodes:[]};const y=new Date(Date.UTC(s,0,1)),g=y.getUTCDay(),x=new Date(y.getTime()-g*St),b=[];for(let t=0;54>t;t++)for(let e=0;7>e;e++){const o=new Date(x.getTime()+(7*t+e)*St);if(o.getUTCFullYear()!==s)continue;const r=zt(o),a=i.get(r),c=null==a?u:h(a);b.push({type:"rect",x:n.x+m+t*(p+f),y:n.y+e*(p+f),w:p,h:p,style:{fill:c,stroke:"none"},datum:{date:o,value:a??0}})}return{nodes:b}};function zt(t){return`${t.getUTCFullYear()}-${Nt(t.getUTCMonth()+1)}-${Nt(t.getUTCDate())}`}function Nt(t){return 10>t?"0"+t:t+""}import*as Ct from"react";import{jsx as Tt}from"react/jsx-runtime";var Et={isActive:!1,predicate:()=>!0},Wt=Ct.createContext(null);function Lt(){return Ct.useContext(Wt)??Et}import{jsx as Ft,jsxs as jt}from"react/jsx-runtime";var Rt={resource:32,city:64},Ot=["#739b58","#83a964","#668d52","#8baa68"],Pt={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},qt={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},Dt=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]);function Bt(t,e){if("function"==typeof t)return t;const n=t??e;return t=>t[n]}function Yt(t,e,n){return[111.32*(t-n.lon)*Math.cos((e+n.lat)/2*(Math.PI/180)),110.574*(e-n.lat)]}function Vt(t){const e=Math.max(3,Math.round(t??5));return e%2==0?e+1:e}function Ht(t){return Dt.has(t)?t:"monument"}function Xt(t,e){const n=Vt(e.gridSize),o=Math.max(1,e.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),a=Bt(e.idAccessor,"id"),s=Bt(e.nameAccessor,"name"),c=Bt(e.longitudeAccessor,"lon"),l=Bt(e.latitudeAccessor,"lat"),u=Bt(e.kindAccessor,"kind"),d=e.candidatePriorityAccessor?Bt(e.candidatePriorityAccessor,"priority"):()=>0,h=new Map;let f=null;for(const m of t){const t=Number(c(m)),p=Number(l(m));if(!Number.isFinite(t)||!Number.isFinite(p))continue;const y=(a(m)??`${t},${p}`)+"",g=(s(m)??y)+"",x=Ht(u(m)),[b,w]=Yt(t,p,e.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,A={...m,id:y,name:g,kind:x,lon:t,lat:p,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(m))||0};(null!=e.centerId&&y===e.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=A);const S=`${v}:${M}`,I=h.get(S)??[];I.push(A),h.set(S,I)}const m=new Map;f&&m.set("city",1);const p=[];for(let t=0;n>t;t++)for(let e=0;n>e;e++){const n=`tile-${t}-${e}`,a=(e+.5)*r-o,s=o-(t+.5)*r;let c,l;if(t===i&&e===i&&f){c=f;const n=(h.get(`${t}:${e}`)??[]).filter(t=>t.id!==f?.id).sort((t,e)=>t.candidatePriority-e.candidatePriority||t.cellDistanceSq-e.cellDistanceSq||t.name.localeCompare(e.name));l=[f,...n]}else{const n=(h.get(`${t}:${e}`)??[]).filter(t=>t.id!==f?.id);n.sort((t,e)=>{const n=t.candidatePriority-e.candidatePriority;if(0!==n)return n;const o=m.get(t.kind)??0,i=m.get(e.kind)??0,a=r*r*.35;return t.cellDistanceSq+o*a-(e.cellDistanceSq+i*a)||t.name.localeCompare(e.name)}),c=n[0]??null,l=n}c&&m.set(c.kind,(m.get(c.kind)??0)+1),p.push({id:n,row:t,column:e,centerXKm:a,centerYKm:s,terrainIndex:Math.abs((17*t+31*e)%Ot.length),landmark:c,landmarks:l})}return p}var _t=t=>{const e=Vt(t.config.gridSize),n=Math.max(20,t.config.tileWidth??80),o=Math.max(10,t.config.tileHeight??40),r=t.config.terrainColors?.length?t.config.terrainColors:Ot,i=t.dimensions.width/2,a=(t.dimensions.height-e*o)/2+o/2,s=Xt(t.points,t.config).map(t=>({...t,x:i+n/2*(t.column-t.row),y:a+(t.column+t.row)*(o/2)}));return{nodes:s.map(e=>{const i=t.config.terrainByCell?.[e.id],a="string"==typeof i?{kind:i}:i,s="city"===e.landmark?.kind?"urban":a?.kind??"land",c=a?.fill??t.config.terrainPalette?.[s]??Pt[s],l=e.landmark?{...e.landmark,gridRow:e.row,gridColumn:e.column,cellId:e.id,terrainKind:s,terrainCoverage:a?.coverage,features:e.landmarks,featureCount:e.landmarks.length}:{id:e.id,name:qt[s],kind:"terrain",terrainKind:s,terrainCoverage:a?.coverage,gridRow:e.row,gridColumn:e.column,cellId:e.id,features:[],featureCount:0};return{type:"geoarea",pathData:(u=e.x,d=e.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[e.x,e.y],bounds:[[e.x-n/2,e.y-o/2],[e.x+n/2,e.y+o/2]],screenArea:n*o/2,style:{fill:a||"urban"===s?c:r[e.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":t.config.tileStroke??"#314934",strokeWidth:1},datum:l,group:e.landmark?.kind??s,interactive:!0};var u,d,h,f}),overlays:Ft(Gt,{tiles:s,tileWidth:n,tileHeight:o,sprites:t.config.sprites,resourceSize:t.config.resourceSpriteSize??32,citySize:t.config.citySpriteSize??64,showCityLabel:!1!==t.config.showCityLabel}),restyle:(t,e)=>e?.isActive&&t.datum&&"terrain"!==t.datum.kind?{fillOpacity:e.predicate(t.datum)?1:.28}:{fillOpacity:1}}};function Gt({tiles:t,tileWidth:e,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:a}){const s=Lt(),c=t.filter(t=>t.landmark).sort((t,e)=>t.y-e.y||t.x-e.x);return jt("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(t=>{const a=t.landmark,c="city"===a.kind?i:r,l=t.y+n/2,u=s.isActive&&!s.predicate(a)?.28:1;return jt("g",{opacity:u,children:[Ft("ellipse",{cx:t.x,cy:t.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),Ft(Zt,{kind:a.kind,href:o?.[a.kind],x:t.x-c/2,y:l-c,size:c}),t.landmarks.length>1&&Ft(Ut,{x:t.x+.3*e,y:t.y-.19*n,count:t.landmarks.length-1,tileHeight:n})]},a.id)}),a&&c.filter(t=>"city"===t.landmark?.kind).map(t=>{const e=t.landmark.name.toUpperCase(),o=Math.max(56,6.4*e.length+14);return jt("g",{transform:`translate(${t.x},${t.y+.72*n})`,children:[Ft("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),Ft("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:e})]},t.landmark.id+"-label")})]})}function Ut({x:t,y:e,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,a=Math.max(r,i.length*r*.58);return jt("g",{transform:`translate(${t},${e})`,children:[Ft("rect",{x:-a/2,y:-r/2,width:a,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),Ft("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}var Kt={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},Qt={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}};function Zt({kind:t,href:e,x:n,y:o,size:r}){if(e)return Ft("image",{href:e,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=Qt[t];return Ft("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:Kt[t].flatMap((t,e)=>[...t].map((t,n)=>"."===t?null:Ft("rect",{x:n,y:e,width:1,height:1,fill:i[t]},`${e}-${n}`)))})}var Jt=t=>{const e=t.config,o=e.nodeWidth??80,r=e.nodeHeight??30,i=e.orientation??"vertical",a=e.edgeCurve??"curved",s=!1!==e.showLabels,c=e.labelAccessor??"id",l="function"==typeof c?c:t=>n(t,c,t.id??"")+"",u=new Map,d=[],h=[],f=t=>{const e=t.data??{};return{x:"number"==typeof e.x?e.x:t.x,y:"number"==typeof e.y?e.y:t.y,w:("number"==typeof e.width?e.width:t.width)??o,h:("number"==typeof e.height?e.height:t.height)??r}};for(const n of t.nodes){const{x:o,y:r,w:i,h:a}=f(n);null!=o&&null!=r&&(u.set(n.id,{x:o,y:r,w:i,h:a}),d.push({type:"rect",x:o-i/2,y:r-a/2,w:i,h:a,style:{fill:e.nodeFill??t.resolveColor(n.id),stroke:`var(--semiotic-surface, ${t.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:l(n)+""}),s&&h.push({x:o,y:r,text:l(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const m=[];for(const e of t.edges){const n="string"==typeof e.target?e.target:e.target.id,o=u.get("string"==typeof e.source?e.source:e.source.id),r=u.get(n);if(!o||!r)continue;const s="vertical"===i?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===i?{x:r.x,y:r.y-r.h/2}:{x:r.x-r.w/2,y:r.y};if("line"===a)m.push({type:"line",x1:s.x,y1:s.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${t.theme.semantic.border??"#999"})`,strokeWidth:1},datum:e});else{const n=(s.y+c.y)/2,o=(s.x+c.x)/2;m.push({type:"curved",pathD:"vertical"===i?`M${s.x},${s.y} C${s.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${s.x},${s.y} C${o},${s.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${t.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:e})}}return{sceneNodes:d,sceneEdges:m,labels:h}},te=t=>{const e=t.config,o=e.nodeWidth??100,r=e.nodeHeight??36,i=e.edgeStyle??"polyline",a=!1!==e.showLabels,s=e.labelAccessor??"label",c="function"==typeof s?s:t=>n(t,s,t.id??"")+"",l=new Map,u=[],d=[],h=t=>{const e=t.data??{};return{x:"number"==typeof e.x?e.x:t.x,y:"number"==typeof e.y?e.y:t.y,w:("number"==typeof e.width?e.width:t.width)??o,h:("number"==typeof e.height?e.height:t.height)??r}};for(const n of t.nodes){const{x:o,y:r,w:i,h:s}=h(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:s}),u.push({type:"rect",x:o-i/2,y:r-s/2,w:i,h:s,style:{fill:e.nodeFill??t.resolveColor(n.id),stroke:`var(--semiotic-border, ${t.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),a&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=e.edgeStroke??`var(--semiotic-border, ${t.theme.semantic.border??"#666"})`,m=[];for(const e of t.edges){const t="string"==typeof e.target?e.target:e.target.id,n=l.get("string"==typeof e.source?e.source:e.source.id),o=l.get(t);if(!n||!o)continue;const r=e.data??{},a=Array.isArray(r.points)?r.points:e.points;if(a&&a.length>=2)if("smooth"!==i||3>a.length){const t="M"+a.map(t=>`${t.x},${t.y}`).join(" L ");m.push({type:"curved",pathD:t,style:{stroke:f,strokeWidth:1,fill:"none"},datum:e})}else{let t=`M${a[0].x},${a[0].y}`;for(let e=1;a.length-1>e;e++)t+=` Q${a[e].x},${a[e].y} ${(a[e].x+a[e+1].x)/2},${(a[e].y+a[e+1].y)/2}`;const n=a[a.length-1];t+=` T${n.x},${n.y}`,m.push({type:"curved",pathD:t,style:{stroke:f,strokeWidth:1,fill:"none"},datum:e})}else m.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:f,strokeWidth:1},datum:e})}return{sceneNodes:u,sceneEdges:m,labels:d}};import{jsx as ee,jsxs as ne}from"react/jsx-runtime";var oe={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},re={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"};function ie(t){return Array.isArray(t)?t.map((t,e)=>"string"==typeof t?{storeName:t,slotIndex:e}:{storeName:(t.storeName??"")+"",slotIndex:t.slotIndex??e}):[]}var ae=t=>{const e=t.config||{},o=t.dimensions.plot,r=e.layerAccessor??"x",i=e.rowAccessor??"y",a=e.partitionAccessor??"partition",s=e.semanticAccessor??"semantic",c=e.labelAccessor??"label",l=e.storesAccessor??"stores",u=e.backEdgeAccessor??"isBackEdge",d=e.edgeTypeAccessor??"edgeType",h={...oe,...e.partitionColors},f={...re,...e.edgeColors},m=e.accentColor??"var(--semiotic-focus, #ffcc33)",p=e.borderColor??"var(--semiotic-border, #555)",y=e.dimOpacity??.14,g=e.edgeOpacity??.5,x=e.edgeWidth??1.25,b=e.backEdgeWidth??e.edgeWidth??1.5,w=!1!==e.showStoreChips,M=e.storeChipColor??"var(--semiotic-info, #6a8caf)";let v=e.layerCount,k=e.maxLayerSize;if(null==v||null==k){let e=0;const o=new Map;for(const i of t.nodes){const t=Math.round(Number(n(i,r,0)));e=Math.max(e,t),o.set(t,(o.get(t)??0)+1)}v=v??e+1,k=k??Math.max(1,...o.values())}const $=o.width/Math.max(1,v),A=o.height/Math.max(1,k);let S=Math.min(e.nodeWidth??172,Math.max(8,$-(e.minGapX??26))),I=Math.min(e.nodeHeight??54,Math.max(8,A-(e.minGapY??18)));const z=e.lod&&"auto"!==e.lod?e.lod:16>S?"dot":48>S?"icon":108>S?"compact":"full";if("dot"===z){const t=Math.min(S,I,11);S=t,I=t}const N=Math.max(1,o.width-S),C=Math.max(1,o.height-I),T=Math.max(1,k-1),E=t=>o.x+S/2+(v>1?t/(v-1):.5)*N,W=t=>o.y+I/2+(t+T/2)/T*C,L=e.reachableIds?new Set(e.reachableIds):null,F=e.selectedId??null,j=t.selection,R=new Map,O=new Map,P=[],q=[];for(const e of t.nodes){const t=e.id,o=Number(n(e,r,0)),u=Number(n(e,i,0)),d=n(e,a,"processor")+"",f=n(e,s,"processor")+"",g=n(e,c,t)+"",x=ie(n(e,l,[])),b=e.data??e,w=E(o),M=W(u);R.set(t,{cx:w,cy:M});const v=L?L.has(t):null,k=j?.isActive?j.predicate(b):null,$=null!==v?!v:null!==k&&!k;O.set(t,$);const A=null!=F&&t===F,N=$&&!A?y:1,C=h[d]??h.unknown;"dot"===z?P.push({type:"circle",cx:w,cy:M,r:S/2,style:{fill:C,opacity:N,stroke:A?m:"transparent",strokeWidth:A?2:0},datum:e,id:t,label:g}):(P.push({type:"rect",x:w-S/2,y:M-I/2,w:S,h:I,style:{fill:C,opacity:N,stroke:A?m:p,strokeWidth:A?3:1},datum:e,id:t,label:g}),q.push({id:t,cx:w,cy:M,partition:d,semantic:f,label:g,stores:x,opacity:N,selected:A,node:b}))}const D=[];for(const e of t.edges){const t="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,r=R.get(t),i=R.get(o);if(!r||!i)continue;const a=!!n(e,u,!1),s=n(e,d,"internal")+"",c=O.get(t)||O.get(o)?Math.min(g,1.4*y):g,l=a?f.back:f[s]??f.internal;let h;if(a){const t=r.cx,e=r.cy+I/2,n=i.cx,o=i.cy+I/2,a=Math.max(48,.28*Math.abs(t-n))+I;h=`M${t},${e} C${t},${e+a} ${n},${o+a} ${n},${o}`}else{const t=r.cx+S/2,e=r.cy,n=i.cx-S/2,o=i.cy,a=(t+n)/2;h=`M${t},${e} C${a},${e} ${a},${o} ${n},${o}`}const m={type:"curved",pathD:h,style:{stroke:l,strokeWidth:a?b:x,fill:"none",opacity:c,...a?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:e};D.push(m)}const B=0===q.length?null:ee("g",{className:"lineage-dag-glyphs",children:q.map(t=>function(t,e){const{w:n,h:o,lod:r}=e,i="icon"===r?Math.min(n,o):Math.min(o-14,26),a="icon"===r?0:8+i+8,s=null!=e.renderIcon?e.renderIcon({semantic:t.semantic,partition:t.partition,size:i,color:e.partColors[t.partition]??e.partColors.unknown??"#5a5a6a",node:t.node}):function(t,e,n){const o=e.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[t]??"PR";return ne("g",{children:[ee("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),ee("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(t.semantic,t.partition,i),c="full"===r,l="icon"!==r,u="full"===r&&e.showChips&&t.stores.length>0;return ne("g",{transform:`translate(${t.cx-n/2}, ${t.cy-o/2})`,opacity:t.opacity,style:{pointerEvents:"none"},children:[ee("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:s}),l&&ee("foreignObject",{x:a,y:c?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:ee("div",{title:t.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t.label})}),c&&ee("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:e.typeLabel?e.typeLabel({semantic:t.semantic,partition:t.partition,node:t.node}):t.partition.startsWith("topic")?"topic":t.semantic}),u&&t.stores.map((t,n)=>ee("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:e.chipColor,children:ee("title",{children:t.storeName})},t.storeName+n))]},t.id)}(t,{w:S,h:I,lod:z,partColors:h,chipColor:M,showChips:w,renderIcon:e.renderIcon,typeLabel:e.typeLabel}))});return{sceneNodes:P,sceneEdges:D,overlays:B}};import{jsx as se,jsxs as ce}from"react/jsx-runtime";function le(t,e){return t.length>e?t.slice(0,Math.max(1,e-1))+"…":t}var ue={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"};function de(t,e,n,o,r,i,a,s){const c=e-o/2,l=n-r/2,u={fill:i,stroke:a,strokeWidth:s};switch(t){case"diamond":return se("polygon",{points:`${e},${l} ${e+o/2},${n} ${e},${n+r/2} ${c},${n}`,...u});case"circle":return se("circle",{cx:e,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return se("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===t?r/2:8,ry:"stadium"===t?r/2:8,...u});case"hexagon":{const t=Math.min(.18*o,16);return se("polygon",{points:`${c+t},${l} ${e+o/2-t},${l} ${e+o/2},${n} ${e+o/2-t},${n+r/2} ${c+t},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const t=Math.min(.16*r,8),e=`M${c},${l+t} a${o/2},${t} 0 0 1 ${o},0`;return ce("g",{children:[se("path",{d:`M${c},${l+t} a${o/2},${t} 0 0 0 ${o},0 v${r-2*t} a${o/2},${t} 0 0 1 ${-o},0 z`,...u}),se("path",{d:e,fill:"none",stroke:a,strokeWidth:s})]})}case"subroutine":{const t=Math.min(8,.08*o);return ce("g",{children:[se("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),se("line",{x1:c+t,y1:l,x2:c+t,y2:l+r,stroke:a,strokeWidth:s}),se("line",{x1:c+o-t,y1:l,x2:c+o-t,y2:l+r,stroke:a,strokeWidth:s})]})}default:return se("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}var he=t=>{const e=t.config||{},o=t.dimensions.plot,r=e.direction??"TD",i="LR"===r||"RL"===r,a="BT"===r||"RL"===r,s=e.layerAccessor??"layer",c=e.rowAccessor??"row",l=e.labelAccessor??"label",u=e.shapeAccessor??"shape",d=e.edgeLabelAccessor??"label",h=e.nodeFill??"var(--semiotic-surface, #20242d)",f=e.nodeStroke??"var(--semiotic-border, #5a6573)",m=e.textColor??"var(--semiotic-text, #e6e6e6)",p=e.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",y=e.accentColor??"var(--semiotic-warning, #d49a00)";if(0===t.nodes.length)return{sceneNodes:[],overlays:null};const g=new Map;let x=0;for(const e of t.nodes){const t=Math.round(Number(n(e,s,0)));x=Math.max(x,t);const o=g.get(t)||[];o.push(e),g.set(t,o)}const b=x+1;let w=1;for(const t of g.values())t.sort((t,e)=>Number(n(t,c,0))-Number(n(e,c,0))),w=Math.max(w,t.length);const M=i?o.width:o.height,v=i?o.height:o.width,k=M/b,$=v/(w+1),A=Math.max(44,Math.min(e.nodeWidth??150,i?k-36:.92*$)),S=Math.max(26,Math.min(e.nodeHeight??46,i?.7*$:.5*k)),I=(i?A:S)/2+6,z=Math.max(1,M-2*I),N=t=>(i?o.x:o.y)+I+(b>1?(a?b-1-t:t)/(b-1)*z:z/2),C=new Map,T=[],E=[];for(const[t,e]of g)e.forEach((r,a)=>{const s=N(t),c=(i?o.y:o.x)+(a+1)/(e.length+1)*v,d=i?s:c,p=i?c:s,g=n(r,u,"rect")+"",x=n(r,l,r.id)+"";C.set(r.id,{cx:d,cy:p,shape:g}),T.push({type:"rect",x:d-A/2,y:p-S/2,w:A,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:r.id,name:x,type:ue[g]??"process",shape:g},id:r.id,label:x}),E.push(ce("g",{children:[de(g,d,p,A,S,h,"diamond"===g?y:f,1.5),se("text",{x:d,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:m,style:{pointerEvents:"none"},children:le(x,Math.max(4,Math.floor((A-12)/7)))})]},"n-"+r.id))});const W=[];return t.edges.forEach((t,e)=>{const o="string"==typeof t.target?t.target:t.target.id,r=C.get("string"==typeof t.source?t.source:t.source.id),a=C.get(o);if(!r||!a)return;const s=i?r.cx+A/2:r.cx,c=i?r.cy:r.cy+S/2,l=i?a.cx-A/2:a.cx,u=i?a.cy:a.cy-S/2,h=i?`M${s},${c} C${(s+l)/2},${c} ${(s+l)/2},${u} ${l},${u}`:`M${s},${c} C${s},${(c+u)/2} ${l},${(c+u)/2} ${l},${u}`,y=Math.atan2(u-c,l-s),g=l-9*Math.cos(y),x=u-9*Math.sin(y),b=4.5*-Math.sin(y),w=4.5*Math.cos(y),M=`${l},${u} ${g+b},${x+w} ${g-b},${x-w}`,v=n(t,d,void 0),k=(s+l)/2,$=(c+u)/2;W.push(ce("g",{children:[se("path",{d:h,fill:"none",stroke:p,strokeWidth:1.4}),se("polygon",{points:M,fill:p}),"string"==typeof v&&v.length>0&&ce("g",{children:[se("rect",{x:k-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:f,strokeWidth:.75}),se("text",{x:k,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:m,style:{pointerEvents:"none"},children:v})]})]},"e-"+e))}),{sceneNodes:T,overlays:ce("g",{className:"mermaid-dag",children:[W,E]})}};import{jsx as fe,jsxs as me}from"react/jsx-runtime";function pe(t){return fe("rect",{className:t.className,x:t.x,y:t.y,width:Math.max(0,t.width),height:Math.max(0,t.height),rx:t.radius??10,ry:t.radius??10,fill:t.fill??"none",stroke:t.stroke,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray,opacity:t.opacity??.6,style:{pointerEvents:"none"}},t.keyId)}function ye(t,e=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const e of t){const t=e.r??0;n>e.x-t&&(n=e.x-t),e.x+t>r&&(r=e.x+t),o>e.y-t&&(o=e.y-t),e.y+t>i&&(i=e.y+t)}return Number.isFinite(n)?{x:n-e,y:o-e,width:r-n+2*e,height:i-o+2*e}:null}function ge(t){const e=t.fontSize??12;return null!=t.maxWidth&&t.text.length*e*.56>t.maxWidth?null:fe("text",{className:t.className,x:t.x,y:t.y,textAnchor:t.anchor??"middle",dominantBaseline:t.baseline??"middle",fontSize:e,fontWeight:t.fontWeight,fill:t.color,style:{pointerEvents:"none"},children:t.text},t.keyId)}function xe(t){const e=t.spacing??8;return{def:fe("pattern",{id:t.id,width:e,height:e,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${t.angle??45})`,children:fe("line",{x1:0,y1:0,x2:0,y2:e,stroke:t.color??"currentColor",strokeWidth:t.strokeWidth??1,opacity:t.opacity??.5})},t.id),fill:`url(#${t.id})`}}function be(t){const e=t.orient??"bottom",n="bottom"===e||"top"===e,o=t.offset??0,r=t.tickLength??6,i=t.gridLength??0,a=t.labelGap??4,s=t.fontSize??11,c=t.color??"var(--semiotic-text-secondary, #888)",l=t.gridColor??c,u=t.format??(t=>t+""),d="top"===e||"left"===e?-1:1,h=t.ticks.length-1,f=t.ticks.map((f,m)=>{const p=t.scale(f),y=o+d*r,g=o-d*i,x=y+d*a;let b;b=t.labelAnchor?t.labelAnchor:n?t.edgeAnchor&&0===m?"start":t.edgeAnchor&&m===h?"end":"middle":"left"===e?"end":"start";const w=n?"top"===e?"auto":"hanging":"middle",M=n?{x:p,y:x}:{x:x,y:p};return me("g",{children:[(r>0||i>0)&&fe("line",{...n?{x1:p,x2:p,y1:y,y2:g}:{x1:y,x2:g,y1:p,y2:p},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?t.gridDasharray:void 0,opacity:i>0?.7:1}),fe("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:s,fontWeight:t.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${m}`)});return fe("g",{className:t.className,style:{pointerEvents:"none"},children:f},t.keyId)}function we(t){const e=t.stroke??"var(--semiotic-text, #f4f4f8)",n=t.strokeWidth??1,o=t.markRadius??0,r=t.labelX-t.markX,i=t.labelY-t.markY,a=Math.hypot(r,i)||1,s=t.markX+r/a*o,c=t.markY+i/a*o;let l;return l="elbow"===t.connector?`M${s},${c} L${s},${t.labelY} L${t.labelX},${t.labelY}`:"curve"===t.connector?`M${s},${c} Q${(s+t.labelX)/2},${c} ${t.labelX},${t.labelY}`:`M${s},${c} L${t.labelX},${t.labelY}`,me("g",{className:t.className,style:{pointerEvents:"none"},children:[o>0&&fe("circle",{cx:t.markX,cy:t.markY,r:o,fill:"none",stroke:e,strokeWidth:n}),fe("path",{d:l,fill:"none",stroke:e,strokeWidth:n}),fe("text",{x:t.labelX,y:t.labelY,textAnchor:t.labelAnchor??"middle",dominantBaseline:t.labelBaseline??"hanging",fontSize:t.fontSize??11,fontWeight:t.fontWeight,fill:t.color??e,children:t.label})]},t.keyId)}import{jsx as Me,jsxs as ve}from"react/jsx-runtime";var ke=new l(12);function $e(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();const e=t+"",n=Number(e);if(!Number.isNaN(n)&&""!==e.trim())return n;const o=Date.parse(e);return Number.isNaN(o)?NaN:o}function Ae(t,e,n){return e>t?e:t>n?n:t}var Se=t=>{const e=t.config||{},o=t.dimensions.plot,i=e.columnAccessor??"column",a=e.rowAccessor??"row",l=e.sizeAccessor,d=e.colorAccessor,h=e.symbolAccessor,f=e.shadeAccessor,m=e.markerAccessor,p=e.iconAccessor,y=e.defaultSymbol??"circle",[g,x]=e.sizeRange??[2,8],b=e.shadeStrength??.72,w=e.shadeReverse??!1,M=e.rowMode??"banded",v=e.cellSizing??"proportional",k=e.proportionExponent??1,$=e.columnGap??16,A=e.rowGap??12,S=e.packPadding??1,I=e.iterations??12,z=!1!==e.showEnclosures,N=!1!==e.showColumnHeaders,C=!1!==e.showRowLabels,T=N?e.headerHeight??26:0,E=C?e.labelWidth??66:0,W=e.callouts&&e.callouts.length>0?e.footerHeight??30:0,L=o.x+E,F=o.y+T,j=Math.max(1,o.width-E),R=Math.max(1,o.height-T-W),O=[];for(const e of t.nodes){const t=e.data??e;O.push({id:e.id,col:n(e,i,"—")+"",row:n(e,a,"—")+"",sizeVal:l?Number(n(e,l,1)):1,colorKey:d?n(e,d,"")+"":"",symVal:h?n(e,h,"")+"":"",shadeVal:f?$e(n(e,f,null)):NaN,marker:!!m&&!!n(e,m,!1),iconVal:p?n(e,p,"")+"":"",datum:t,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===O.length)return{sceneNodes:[]};let P=1/0,q=-1/0;if(l)for(const t of O)Number.isFinite(t.sizeVal)&&(P>t.sizeVal&&(P=t.sizeVal),t.sizeVal>q&&(q=t.sizeVal));e.sizeDomain&&([P,q]=e.sizeDomain),Number.isFinite(P)&&Number.isFinite(q)||(P=0,q=1);const D=t=>{if(P>=q)return(g+x)/2;const e=Math.sqrt(Ae((t-P)/(q-P),0,1));return g+e*(x-g)};let B=1/0,Y=-1/0;if(f)for(const t of O)Number.isFinite(t.shadeVal)&&(B>t.shadeVal&&(B=t.shadeVal),t.shadeVal>Y&&(Y=t.shadeVal));e.shadeDomain&&([B,Y]=e.shadeDomain);const V=t=>{if(!f||!Number.isFinite(t)||B>=Y)return.5;const e=Ae((t-B)/(Y-B),0,1);return w?1-e:e},H=e.colorMap,X=new Map,_=(e,n)=>{let o=X.get(e);return o||(o=u(H&&H[e]||t.resolveColor(e),b),X.set(e,o)),o(n)},G=new Map;if(e.symbolMap)for(const[t,n]of Object.entries(e.symbolMap))G.set(t,n);let U=0;const K=e.iconMap,Q=t=>p&&K&&K[t]?K[t]:null,Z=t=>p?"circle":(t=>{if(!h)return y;let e=G.get(t);return e||(e=J[U%J.length],U++,G.set(t,e)),e})(t.symVal),et=e.maxAreaFraction??.4;let nt=0;const rt=Array(O.length),it=Array(O.length);for(let t=0;O.length>t;t++){const e=O[t],n=D(e.sizeVal);rt[t]=n,e.baseShape=Z(e),e.iconShape=Q(e.iconVal);const o=ot(e.baseShape,Math.PI*n*n);it[t]=o,nt+=Math.PI*o*o}const at=et*j*R,st=nt>at?Math.sqrt(at/nt):1;for(let t=0;O.length>t;t++){const e=O[t],n=rt[t]*st;e.size=Math.PI*n*n,e.packR=it[t]*st}const ct=new Map,lt=new Map;for(const t of O)ct.set(t.col,(ct.get(t.col)??0)+1),lt.set(t.row,(lt.get(t.row)??0)+1);const ut=e.columnOrder?.filter(t=>ct.has(t))??[...ct.keys()].sort((t,e)=>(ct.get(e)??0)-(ct.get(t)??0)),dt=e.rowOrder?.filter(t=>lt.has(t))??[...lt.keys()].sort((t,e)=>(lt.get(e)??0)-(lt.get(t)??0)),ht=c([Math.round(o.x),Math.round(o.y),Math.round(o.width),Math.round(o.height),T,E,W,M,v,k,$,A,S,I,g,x,P,q,et,ut.join(","),dt.join(","),O.length,ze(O)]),ft=ke.getOrCompute(ht,()=>function(t,e){const n=new Map;for(const e of t){let t=n.get(e.col);t||(t=[],n.set(e.col,t)),t.push(e)}const o=e.columnOrder.filter(t=>n.has(t)),i=Math.max(1,e.innerW-e.columnGap*Math.max(0,o.length-1)),a=e.proportionExponent,s=o.map(t=>Math.pow(n.get(t).length,a)),c=s.reduce((t,e)=>t+e,0)||1,l=t=>"uniform"===e.cellSizing?i/o.length:s[t]/c*i,u=new Map,d=[];let h=e.innerX;for(let t=0;o.length>t;t++)d.push({col:o[t],x:h,w:l(t)}),h+=l(t)+e.columnGap;let f=1;const m=new Map,p=[],y=(t,e,n,o)=>{let r=m.get(t);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},m.set(t,r)),r.minX>e-o&&(r.minX=e-o),e+o>r.maxX&&(r.maxX=e+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},g=(t,n,o,r,i,a)=>{const s=t.map(t=>({id:t.id,r:t.packR})),c=function(t,e,n,o,r,i,a,s){const c=e+o/2,l=n+r/2,u=new Map,d=t.length;if(0===d)return u;if(1===d)return u.set(t[0].id,{px:c,py:l}),u;const h=function(t){let e=t>>>0||1;return()=>(e=Math.imul(e,1664525)+1013904223>>>0,e/4294967296)}(s),f=new Float64Array(d);let m=0;for(let e=0;d>e;e++)f[e]=t[e].r+i,f[e]>m&&(m=f[e]);const p=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),y=new Float64Array(d),g=new Float64Array(d),x=o/p,b=r/Math.ceil(d/p);for(let t=0;d>t;t++){const o=t%p,r=Math.floor(t/p);y[t]=e+(o+.3+.4*h())*x,g[t]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(t,e)=>(e+1)*k+(t+1);for(let t=0;w>t;t++){v.clear();for(let t=0;d>t;t++){const o=$(Math.floor((y[t]-e)/M),Math.floor((g[t]-n)/M)),r=v.get(o);r?r.push(t):v.set(o,[t])}for(let t=0;d>t;t++){const o=Math.floor((y[t]-e)/M),r=Math.floor((g[t]-n)/M);for(let e=-1;1>=e;e++)for(let n=-1;1>=n;n++){const i=v.get($(o+e,r+n));if(i)for(let e=0;i.length>e;e++){const n=i[e];if(t>=n)continue;let o=y[n]-y[t],r=g[n]-g[t];const a=f[t]+f[n],s=o*o+r*r;if(a*a>s)if(s>1e-9){const e=Math.sqrt(s),i=(a-e)/2;o/=e,r/=e,y[t]-=o*i,g[t]-=r*i,y[n]+=o*i,g[n]+=r*i}else{const e=2.39996323*t;y[t]+=Math.cos(e)*f[t],g[t]+=Math.sin(e)*f[t]}}}}for(let t=0;d>t;t++){const i=f[t],a=e+i,s=e+o-i,u=n+i,d=n+r-i;y[t]=s>a?Ae(y[t],a,s):c,g[t]=d>u?Ae(g[t],u,d):l}}for(let e=0;d>e;e++)u.set(t[e].id,{px:y[e],py:g[e]});return u}(s,n,o,r,i,e.packPadding,e.iterations,f++);let l=1/0,d=1/0,h=-1/0,m=-1/0;for(const t of s){const e=c.get(t.id);u.set(t.id,{px:e.px,py:e.py}),y(a,e.px,e.py,t.r),l>e.px-t.r&&(l=e.px-t.r),e.px+t.r>h&&(h=e.px+t.r),d>e.py-t.r&&(d=e.py-t.r),e.py+t.r>m&&(m=e.py+t.r)}return Number.isFinite(l)?{x:l-Ie,y:d-Ie,w:h-l+2*Ie,h:m-d+2*Ie}:null};if("banded"===e.rowMode){const i=new Map;for(const e of t)i.set(e.row,(i.get(e.row)??0)+1);const s=e.rowOrder.filter(t=>i.has(t)),c=Math.max(1,e.innerH-e.rowGap*Math.max(0,s.length-1)),l=s.map(t=>Math.pow(i.get(t),a)),h=l.reduce((t,e)=>t+e,0)||1,f=new Map;let p=e.innerY+e.innerH;for(let t=0;s.length>t;t++){const n="uniform"===e.cellSizing?c/s.length:l[t]/h*c,o=p-n;f.set(s[t],{y:o,h:n}),p=o-e.rowGap}o.forEach((t,e)=>{const o=r(n.get(t),t=>t.row);for(const t of s){const n=o.get(t),r=f.get(t);n&&r&&g(n,d[e].x,r.y,d[e].w,r.h,t)}});const y=[],x=new Map;for(const t of s){const e=f.get(t);x.set(t,e.y+e.h/2);const n=m.get(t);n&&Number.isFinite(n.minX)&&y.push({x:n.minX-Ie,y:n.minY-Ie,w:n.maxX-n.minX+2*Ie,h:n.maxY-n.minY+2*Ie})}return{positions:u,enclosures:y,colBands:d,rowLabelY:x}}const x=new Map;o.forEach((t,o)=>{const i=r(n.get(t),t=>t.row),s=e.rowOrder.filter(t=>i.has(t)),c=Math.max(1,e.innerH-e.rowGap*Math.max(0,s.length-1)),l=s.map(t=>Math.pow(i.get(t).length,a)),u=l.reduce((t,e)=>t+e,0)||1;let h=e.innerY+e.innerH;s.forEach((t,n)=>{const r="uniform"===e.cellSizing?c/s.length:l[n]/u*c,a=h-r,f=g(i.get(t),d[o].x,a,d[o].w,r,t);if(f){p.push(f);const e=x.get(t)??{sum:0,n:0};e.sum+=f.y+f.h/2,e.n+=1,x.set(t,e)}h=a-e.rowGap})});const b=new Map;for(const[t,e]of x)b.set(t,e.sum/e.n);return{positions:u,enclosures:p,colBands:d,rowLabelY:b}}(O,{columnOrder:ut,rowOrder:dt,innerX:L,innerY:F,innerW:j,innerH:R,rowMode:M,cellSizing:v,proportionExponent:k,columnGap:$,rowGap:A,packPadding:S,iterations:I})),mt=t.selection,pt=mt?.isActive?mt.predicate:null,yt=e.highlight??null,gt=e.dimOpacity??.16,xt=e.markStroke,bt=e.markStrokeWidth??0,wt=e.markerColor??"#ffffff",Mt=e.iconColor??"rgba(255,255,255,0.92)",vt=e.iconStrokeWidth??1,kt=e.iconScale??.72,$t=[],At=[],St=[];for(const t of O){const e=ft.positions.get(t.id);if(!e)continue;const n=s(t.datum,{highlight:yt,predicate:pt,dimOpacity:gt}),o={type:"symbol",cx:e.px,cy:e.py,size:t.size,symbolType:t.baseShape,style:{fill:_(t.colorKey,V(t.shadeVal)),opacity:n,...xt?{stroke:xt,strokeWidth:bt}:{}},datum:t.datum,id:t.id,label:t.id+""};if($t.push(o),t.iconShape){const o=Math.sqrt(t.size/Math.PI)*kt,r=ot(t.iconShape,100);St.push({x:e.px,y:e.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:t.iconShape,opacity:n})}t.marker&&n>gt+.001&&At.push({x:e.px,y:e.py,r:Math.max(1,.4*Math.sqrt(t.size/Math.PI))})}const It=[];if(e.callouts&&e.callouts.length>0){const t=e.calloutColor??"var(--semiotic-text, #f4f4f8)",n=o.y+o.height-(W>0?.45*W:9),r=[];for(let t=0;e.callouts.length>t;t++){const n=e.callouts[t],o=O.find(t=>t.datum[n.field]+""==n.value+"");if(!o)continue;const i=ft.positions.get(o.id);i&&r.push({c:n,ci:t,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(t=>null==t.c.at).sort((t,e)=>t.px-e.px),a=new Map;i.forEach((t,e)=>{a.set(t.ci,L+(e+.5)/i.length*j)});for(const e of r){const r=e.c;let i=a.get(e.ci)??e.px,s=n;const c=r.connector??(a.has(e.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,s=r.at.y):"number"==typeof r.at&&(s=o.y+r.at*o.height),It.push({keyId:"callout-"+e.ci,markX:e.px,markY:e.py,labelX:i,labelY:s,label:r.label,connector:c,markRadius:Math.max(e.markR+3,7),stroke:t,color:t,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const zt=function(t,e){const n=e.columnLabel??(t=>t),o=e.rowLabel??(t=>t);return ve("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[e.showEnclosures&&t.enclosures.map((t,n)=>pe({keyId:"enc-"+n,x:t.x,y:t.y,width:t.w,height:t.h,radius:e.enclosureRadius,stroke:e.enclosureColor,strokeWidth:e.enclosureWidth,opacity:e.enclosureOpacity})),e.iconMarks.length>0&&Me("g",{className:"packed-cluster-matrix-icons",children:e.iconMarks.map((t,n)=>Me("path",{d:tt(t.shape,t.size),transform:`translate(${t.x},${t.y})`,fill:"none",stroke:e.iconColor,strokeWidth:e.iconStrokeWidth,opacity:t.opacity},"ic-"+n))}),e.markerDots.length>0&&Me("g",{className:"packed-cluster-matrix-markers",children:e.markerDots.map((t,n)=>Me("circle",{cx:t.x,cy:t.y,r:t.r,fill:e.markerColor},"mk-"+n))}),e.showColumnHeaders&&t.colBands.map((t,o)=>ge({keyId:"col-"+o,text:n(t.col),x:t.x+t.w/2,y:e.headerY,anchor:"middle",fontSize:e.headerFontSize,fontWeight:700,color:e.headerColor})),e.showRowLabels&&[...t.rowLabelY].map(([t,n])=>ge({keyId:"row-"+t,text:o(t),x:e.labelX,y:n,anchor:"end",fontSize:e.labelFontSize,fontWeight:600,color:e.labelColor})),e.callouts.map(t=>we(t))]})}(ft,{markerDots:At,markerColor:wt,iconMarks:St,iconColor:Mt,iconStrokeWidth:vt,callouts:It,plot:o,showEnclosures:z,showColumnHeaders:N,showRowLabels:C,enclosureColor:e.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:e.enclosureRadius??9,enclosureOpacity:e.enclosureOpacity??.5,enclosureWidth:e.enclosureWidth??1.5,headerColor:e.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:e.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:e.headerFontSize??13,labelFontSize:e.labelFontSize??11,headerY:o.y+.62*T,labelX:o.x+E-10,columnLabel:e.columnLabel,rowLabel:e.rowLabel});return{sceneNodes:$t,overlays:zt}},Ie=4;function ze(t){let e=2166136261;const n=t=>{for(let n=0;t.length>n;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619)};for(const o of t)n(o.id),n(o.col),n(o.row),e^=Math.round(8*o.packR),e=Math.imul(e,16777619);return(e>>>0).toString(36)}import*as Ne from"react";var Ce=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const r=e(n.categoryAccessor),a=e(n.stackBy),s=t=>{const e="function"==typeof n.valueAccessor?n.valueAccessor(t):t[n.valueAccessor],o=Number(e);return Number.isFinite(o)&&o>0?o:0},c=n.gutter??2,l="string"==typeof n.categoryAccessor?n.categoryAccessor:"category",u="string"==typeof n.stackBy?n.stackBy:"stack",d="string"==typeof n.valueAccessor?n.valueAccessor:"value",h=(t,e,n)=>i(o=>{o("category",t),o("stack",e),o("value",n),"category"!==l&&o(l,t),"stack"!==u&&o(u,e),"value"!==d&&o(d,n)}),f=!1!==n.showCategoryLabels,m=Math.max(0,o.height-(n.labelPadding??(f?22:0))),p=[],y=new Map,g=[],x=new Set,b=new Map;for(const e of t.data){const t=r(e)+"",n=a(e)+"",o=s(e);y.has(t)||(p.push(t),y.set(t,0),b.set(t,new Map)),x.has(n)||(x.add(n),g.push(n)),y.set(t,(y.get(t)??0)+o);const i=b.get(t);i.set(n,(i.get(n)??0)+o)}const w=n.categoryOrder?Te(n.categoryOrder,p,t=>y.has(t)):p,M=n.stackOrder?Te(n.stackOrder,g,()=>!0):g,v=w.reduce((t,e)=>t+(y.get(e)??0),0);if(0>=v)return{nodes:[]};const k=Math.max(0,o.width-c*Math.max(0,w.length-1)),$=[],A=[];let S=o.x;for(const e of w){const n=y.get(e)??0,r=n/v*k;if(0>=r)continue;A.push({cat:e,x:S,w:r});const i=b.get(e);let a=o.y;for(const o of M){const s=i.get(o)??0;if(0>=s)continue;const c=s/n*m;$.push({type:"rect",x:S,y:a,w:r,h:c,style:{fill:t.resolveColor(o),stroke:"none"},datum:h(e,o,s),group:o}),a+=c}S+=r+c}return{nodes:$,overlays:f&&A.length>0?function(t,e,n){const o=t.map((t,o)=>ge({keyId:"marimekko-label-"+o,text:t.cat,x:t.x+t.w/2,y:e+12,anchor:"middle",baseline:"auto",maxWidth:t.w-4,fontSize:12,color:n}));return Ne.createElement(Ne.Fragment,null,...o)}(A,o.y+m+4,`var(--semiotic-text, ${t.theme.semantic.text??"currentColor"})`):null}};function Te(t,e,n){const o=new Set,r=[];for(const e of t)n(e)&&!o.has(e)&&(o.add(e),r.push(e));for(const t of e)o.has(t)||r.push(t);return r}import*as Ee from"react";var We=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height||0===t.data.length)return{nodes:[]};const r=n.rowHeight??28,a=n.rowGap??12,s=!1!==n.showLabels,c=s?n.labelWidth??120:0,l=!1!==n.showTicks,u=l?14:0,d=n.tickFormat??(t=>t.toLocaleString()),h=o.x+c,f=Math.max(0,o.width-c);if(0>=f)return{nodes:[]};const m=e(n.categoryAccessor),p=t=>{const e=Number(t);return Number.isFinite(e)&&e>0?e:0},y=t=>p("function"==typeof n.valueAccessor?n.valueAccessor(t):t[n.valueAccessor]),g=t=>p("function"==typeof n.targetAccessor?n.targetAccessor(t):t[n.targetAccessor]),x=t=>{const e="function"==typeof n.rangesAccessor?n.rangesAccessor(t):t[n.rangesAccessor];return Array.isArray(e)?e.map(p).sort((t,e)=>t-e):[]},b="string"==typeof n.categoryAccessor?n.categoryAccessor:"metric",w="string"==typeof n.valueAccessor?n.valueAccessor:"value",M="string"==typeof n.targetAccessor?n.targetAccessor:"target",v=n.actualColor??t.theme.semantic.primary??"#3b6cb1",k=t.theme.semantic.text??"currentColor",$=n.targetColor??`var(--semiotic-text, ${k})`,A=[`var(--semiotic-surface, ${t.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${t.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${t.theme.semantic.border??"#a3a8af"})`],S=`var(--semiotic-text, ${k})`,I=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,z=[],N=[];for(let e=0;t.data.length>e;e++){const n=t.data[e],s=x(n),c=y(n),l=g(n),d=Math.max(c,l,...s.length?s:[0]);if(0>=d)continue;const p=o.y+e*(r+a+u);if(p+r+u>o.y+o.height)break;N.push({yTop:p,label:m(n),actual:c,target:l,maxVal:d});const k=t=>h+t/d*f,S=m(n),I=t=>i(e=>{e("metric",S),"metric"!==b&&e(b,S),t(e)});let C=h;for(let t=0;s.length>t;t++){const e=k(s[t]),n=e-C;n>0&&z.push({type:"rect",x:C,y:p,w:n,h:r,style:{fill:A[Math.min(t,A.length-1)],stroke:"none"},datum:I(e=>{e("range",t),e("rangeValue",s[t]),e("kind","range")}),group:"range-"+t}),C=e}const T=Math.max(6,Math.floor(.45*r));z.push({type:"rect",x:h,y:p+(r-T)/2,w:k(c)-h,h:T,style:{fill:v,stroke:"none"},datum:I(t=>{t("value",c),t("kind","actual"),"value"!==w&&t(w,c)}),group:"actual"});const E=3,W=Math.floor(.8*r);z.push({type:"rect",x:k(l)-E/2,y:p+(r-W)/2,w:E,h:W,style:{fill:$,stroke:"none"},datum:I(t=>{t("target",l),t("kind","target"),"target"!==M&&t(M,l)}),group:"target"})}const C=[];for(let t=0;N.length>t;t++){const e=N[t];if(s&&C.push(ge({keyId:"bullet-label-"+t,text:e.label,x:o.x+c-8,y:e.yTop+r/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:S})),l){const n=5,o=e.yTop+r+2;for(let r=0;n>r;r++){const i=e.maxVal*r/(n-1),a=h+i/e.maxVal*f;C.push(Ee.createElement("line",{key:`bullet-tick-${t}-${r}`,x1:a,x2:a,y1:o,y2:o+3,stroke:I,strokeWidth:1}),ge({keyId:`bullet-ticktext-${t}-${r}`,text:d(i),x:a,y:o+12,anchor:0===r?"start":r===n-1?"end":"middle",baseline:"auto",fontSize:10,color:I}))}}}return{nodes:z,overlays:C.length>0?Ee.createElement(Ee.Fragment,null,...C):null}};import*as Le from"react";import{scaleLinear as Fe}from"d3-scale";var je=t=>{const e=t.config,{plot:n}=t.dimensions,o=e.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===t.data.length)return{nodes:[]};const r={};for(const n of o){if(e.domains?.[n]){r[n]=e.domains[n];continue}let o=1/0,i=-1/0;for(const e of t.data){const t=Number(e[n]);Number.isFinite(t)&&(o>t&&(o=t),t>i&&(i=t))}r[n]=Number.isFinite(o)&&Number.isFinite(i)&&o!==i?[o,i]:[0,1]}const i=!1!==e.showAxes,a=i?e.axisLabelPadding??24:8,c=i?18:8,l=o.map(t=>Fe().domain(r[t]).range([n.y+n.height-c,n.y+a])),u=o.map((t,e)=>1===o.length?n.x+n.width/2:n.x+e/(o.length-1)*n.width),d=e.colorBy?"function"==typeof e.colorBy?e.colorBy:t=>(t[e.colorBy]??"")+"":null,h=e.opacity??.45,f=e.strokeWidth??1.25,m=t.theme.semantic.primary??"#3b6cb1",p=e.dimmedOpacity??.08,y=e.highlightFn,g=[],x=[];for(const n of t.data){const r=d?t.resolveColor(d(n)+""):m,i=!y||y(n),a=s(n,{predicate:y,baseOpacity:h,dimOpacity:p,brighten:.4}),c=i?x:g;for(let t=0;o.length-1>t;t++){const e=Number(n[o[t]]),s=Number(n[o[t+1]]);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const d={type:"connector",x1:u[t],y1:l[t](e),x2:u[t+1],y2:l[t+1](s),style:{stroke:r,strokeWidth:y&&i?f+.75:f,opacity:a,fill:"none"},datum:n};c.push(d)}if(e.showPoints)for(let t=0;o.length>t;t++){const e=Number(n[o[t]]);if(!Number.isFinite(e))continue;const i={type:"point",x:u[t],y:l[t](e),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,a+.3)},datum:n};c.push(i)}}let b=null;if(i){const i=`var(--semiotic-border, ${t.theme.semantic.border??"#aaa"})`,s=`var(--semiotic-text, ${t.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,h=n.y+a,f=n.y+n.height-c,m=[];for(let t=0;o.length>t;t++){const c=o[t],p=u[t],y=e.tickFormat?.[c]??(t=>t.toLocaleString());m.push(Le.createElement("line",{key:"pc-axis-line-"+t,x1:p,x2:p,y1:h,y2:f,stroke:i,strokeWidth:1})),m.push(ge({keyId:"pc-axis-label-"+t,text:c,x:p,y:n.y+a-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:s}));const[g,x]=r[c],b=5;for(let e=0;b>e;e++){const n=g+(x-g)*e/(b-1),o=l[t](n);m.push(Le.createElement("line",{key:`pc-tick-${t}-${e}`,x1:p-3,x2:p+3,y1:o,y2:o,stroke:i,strokeWidth:1}),ge({keyId:`pc-ticktext-${t}-${e}`,text:y(n),x:p+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}b=Le.createElement(Le.Fragment,null,...m)}return{nodes:g.concat(x),overlays:b}};import{jsx as Re,jsxs as Oe}from"react/jsx-runtime";var Pe=1.75,qe="#222222";function De(t,e){return t.topRadius+(e-t.height)/t.height*(t.topRadius-t.bottomRadius)}function Be(t,e){return function(t,e,n){return Math.PI*n/3*(t*t+t*e+e*e)}(De(t,e),t.bottomRadius,e)}function Ye(t,e){const n=(t.topRadius+t.bottomRadius)/2,o=Math.PI*n*n;let r=e/o,i=e-Be(t,r),a=0;for(;100>a&&Math.abs(i)>1e-4;)r+=i/o,i=e-Be(t,r),a++;return r}function Ve(t,e){const n=43758.5453*Math.sin(12.9898*t+78.233);return 2*(n-Math.floor(n)-.5)*e}function He(t,e){if(e>t||2*e>t)return[{x:0,y:0}];const n=[],o=t=>{let r=Math.floor(2*Math.PI*t/(2*e));1>r&&(r=1);const i=0*t,a=Math.hypot(1*t-t*Math.cos(2*Math.PI/r),i-t*Math.sin(2*Math.PI/r));2*e>a&&r>1&&r--;for(let e=0;r>e;e++)n.push({x:t*Math.cos(2*e*Math.PI/r),y:t*Math.sin(2*e*Math.PI/r)});const s=t-2*e;e>s?t>2*e&&n.push({x:0,y:0}):o(s)};return o(t-e),n}function Xe(t,e,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=e*(1+2*i),a=He(De(t,n),e),s=a.length-r,c=s>1?a.slice(Math.floor(s/2),Math.floor(s/2)+r):a,l=t.height-n;if(c.forEach((t,e)=>{o.push({x:t.x+Ve(97*i+e,.15),z:l+Ve(31*i+e,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function _e(t,e,n,o){if(0>=o)return[];const r=function(t,e,n){let o=n,r=0;for(;o>0&&60>r;){const n=De(t,e+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/Pe)),r++}return r}(t,e,o),i=Math.max(e,n-r*Pe)+.875,a=[];let s=0;for(let e=0;r>e&&o>s;e++){const n=i+Pe*e,r=De(t,n),c=Math.max(1,Math.floor(2*r/Pe)),l=(2*r-c*Pe)/(c+1),u=-r+l,d=t.height-n-.875-.1;for(let t=0;c>t&&o>s;t++)a.push({cx:u+(l+Pe)*t+.875,cy:d+.875,rotation:Ve(53*e+t,10)}),s++}return a}function Ge(t,e){const n=Number(t);return Number.isFinite(n)?n:e}var Ue=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const r=e(n.categoryAccessor??"name"),i=e(n.teaVolumeAccessor??"teaVolume"),a=e(n.bobaVolumeAccessor??"bobaVolume"),s=e(n.iceVolumeAccessor??"iceVolume"),c=e(n.cupHeightAccessor??"cupHeight"),l=e(n.cupTopRadiusAccessor??"cupTopRadius"),u=e(n.cupBottomRadiusAccessor??"cupBottomRadius"),d=e(n.bobaRadiusAccessor??"bobaRadius"),m=n.cupWidthRatio??.82,p=t.scales.o,y=p.bandwidth(),g=Math.max(1,o.height-26-8),x=o.y+8,b=[],w=[];for(const e of t.data){const n=r(e)+"",o=p(n);if(null==o)continue;const M={height:Ge(c(e),15.5),topRadius:Ge(l(e),4.75),bottomRadius:Ge(u(e),3.75)},v=Ge(d(e),.6),k=Math.max(0,Ge(i(e),450)),$=Math.max(0,Ge(a(e),110)),A=Math.max(0,Ge(s(e),135)),S=Math.PI*v*v,I=Math.floor($/S),z=I*S,N=Math.floor(A/5.359375),C=N*Pe*Pe*Pe,T=k+z+C,E=Ye(M,T),W=Math.min(M.height,Math.max(0,E)),L=De(M,W),{pearls:F,layers:j}=Xe(M,v,I),R=W,O=_e(M,j*v*2,R,N),P=M.height-20.32,q=Math.min(0,P),D=Math.min(y*m/(2*(M.topRadius+1)),g/(M.height-q)),B=o+y/2,Y=t=>B+t*D,V=t=>x+(t-q)*D,H=Y(-(M.topRadius+1)),X=Y(M.topRadius+1),_=V(q),G=V(M.height),U=h({name:n,teaVolume:k,bobaVolume:Math.round(z),iceVolume:Math.round(C),totalVolume:Math.round(T),numBobas:I,numIce:N,kind:"boba cup"});b.push({type:"rect",x:H,y:_,w:Math.max(1,X-H),h:Math.max(1,G-_),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:U,group:n,_transitionKey:"boba-"+f(n)});const K=M.height-R,Q=f(n),Z=t.resolveColor(n);w.push(Oe("g",{children:[k>0?Re("path",{d:`M${Y(-L)},${V(K)} L${Y(-M.bottomRadius)},${V(M.height)} L${Y(M.bottomRadius)},${V(M.height)} L${Y(L)},${V(K)} z`,fill:"#D2B799"}):null,F.map((t,e)=>Re("circle",{cx:Y(t.x),cy:V(t.z),r:v*D,fill:"#222222",opacity:.5},"p-"+e)),O.map((t,e)=>Re("rect",{x:Y(t.cx)-.95*Pe*D/2,y:V(t.cy)-.95*Pe*D/2,width:.95*Pe*D,height:.95*Pe*D,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${t.rotation} ${Y(t.cx)} ${V(t.cy)})`},"i-"+e)),Re("path",{d:`M${Y(-M.topRadius)},${V(0)} L${Y(-M.bottomRadius)},${V(M.height)} L${Y(M.bottomRadius)},${V(M.height)} L${Y(M.topRadius)},${V(0)}`,fill:"none",stroke:qe,strokeWidth:2.5}),Re("line",{x1:Y(-(M.topRadius+1)),y1:V(0),x2:Y(M.topRadius+1),y2:V(0),stroke:qe,strokeWidth:3,strokeLinecap:"round"}),k>0?Re("path",{d:`M${Y(-.635)},${V(P)} L${Y(-.635)},${V(M.height-.4)} L${Y(.635)},${V(M.height-1.27-.4)} L${Y(.635)},${V(P)} z`,fill:"#4F91CB",stroke:qe,strokeWidth:1,opacity:.78}):null,Re("text",{x:B,y:G+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),Re("text",{x:B,y:G+30,textAnchor:"middle",fontSize:10,fill:Z,children:`${I} pearls · ${Math.round(T)} cm³`})]},"boba-"+Q))}return{nodes:b,overlays:Re("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:w})}};function Ke(t,e){const n=e.scales?.x??e.scales?.time;return n?null!=t.x?n(t.x):e.xAccessor&&null!=t[e.xAccessor]?n(t[e.xAccessor]):null:null}function Qe(t,e){const n=e.scales?.y??e.scales?.value;return n?null!=t.y?n(t.y):e.yAccessor&&null!=t[e.yAccessor]?n(t[e.yAccessor]):null:null}function Ze(t){return null==t?null:t+""}function Je(t,e,n){return e.stickyPositionCache?.set(t,n),n}var tn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function en(t){return!!t&&"object"==typeof t&&tn.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}new Set(["label","callout","callout-circle","callout-rect"]);var nn=2e4;function on(t){return"primary"===t?.emphasis||!0===t?.defensive}function rn(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function an(t){let e;const n=t?.emphasis;e="primary"===n?100:"secondary"===n?10:50;const o=t?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(e+=15*Math.max(0,Math.min(1,o))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}function sn(t){const{annotations:e,width:n,height:o}=t,r=Math.max(0,t.minVisible??1),i=rn(n,o,t),a=e.map((t,e)=>{return{annotation:t,index:e,note:(n=t,en(n))};var n}),s=a.filter(t=>t.note);if(0===s.length||i>=s.length)return{visible:e.slice(),deferred:[],budget:i};const c=s.filter(t=>on(t.annotation)),l=s.filter(t=>!on(t.annotation)).sort((t,e)=>an(e.annotation)-an(t.annotation)||t.index-e.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),h=[],f=[];for(const{annotation:t,index:e,note:n}of a)!n||d.has(e)?h.push(t):f.push(t);return{visible:h,deferred:f,budget:i}}var cn=32,ln=6,un=4,dn=8,hn=72;var fn={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function mn(t){if(!pn(t))return t;const e=("string"==typeof t.mobileText?t.mobileText:void 0)??("string"==typeof t.shortText?t.shortText:void 0);return!e||"string"!=typeof t.label&&null!=t.label?t:{...t,label:e}}function pn(t){return en(t)}function yn(t,e){if(!t)return[];const n=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),r=[];let i="";for(const t of o)i&&i.length+t.length+1>n?(r.push(i),i=t):i=i?`${i} ${t}`:t;return i&&r.push(i),r}function gn(t,e,n,o,r){const i=t+n,a=e+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function xn(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function bn(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function wn(t,e,n,o,r,i,a,s){const c=xn(t,a);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,n,o){const r=Math.max(0,o-t.x),i=Math.max(0,o-t.y);return(r+Math.max(0,t.x+t.width-(e-o)))*t.height+(i+Math.max(0,t.y+t.height-(n-o)))*t.width}(c,r,i,s);for(const t of n)l+=12*bn(c,t);for(const t of o)l+=4*bn(c,t);return l}function Mn(t,e,n){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const o=t.pointId??t.nodeId;if(null!=o&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===o);if(t)return{x:t.x,y:t.y}}const r=t.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const t=r[0],e=r[1];if("number"==typeof t&&"number"==typeof e){const n=i([t,e]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof t.x||"number"!=typeof t.y?function(t,e,n){const o=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===t.pointId)return Je(e,n,{x:r.x,y:r.y})}const o=function(t){const e=t.data;if(!e||0===e.length)return null;const n=e[e.length-1],o=t.scales?.x??t.scales?.time,r=t.scales?.y??t.scales?.value;if(!o||!r)return null;const i=n[t.xAccessor||"x"],a=n[t.yAccessor||"y"];return null==i||null==a?null:{x:o(i),y:r(a)}}(n);return o?Je(e,n,o):null}if("semantic"===o){const o=function(t,e,n){const o=function(t){return Ze(t.provenance?.stableId??t.stableId)}(t);if(!o)return null;const r=n.pointNodes?.find(t=>Ze(t.pointId)===o);if(r)return Je(e,n,{x:r.x,y:r.y});const i=n.data?.find(t=>function(t){return Ze(t.stableId??t.id??t.provenance?.stableId)}(t)===o);if(!i)return null;const a=Ke(i,n),s=Qe(i,n);return null==a||null==s?null:Je(e,n,{x:a,y:s})}(t,e,n);if(o)return o}let r=null,i=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(r=e.x,i=e.y)}if(null!=r&&null!=i||(r=Ke(t,n),i=Qe(t,n)),null!=r&&null!=i)return Je(e,n,{x:r,y:i});if("sticky"===o){const t=n.stickyPositionCache?.get(e);if(t)return t}return null}(t,e,n):{x:t.x,y:t.y}}function vn(t){const{annotations:e,context:n,defaultOffset:o=cn,notePadding:r=ln,markPadding:i=un,edgePadding:a=dn,preserveManualOffsets:s=!0,routeLongConnectors:c=!0,connectorThreshold:l=hn,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:m,cohesion:p,audience:y}=t,g=n.width||0,x=n.height||0,b="object"==typeof m?m:{},w=b.breakpoint??480,M=!!m&&w>=g,v=M&&!1!==b.preferShortText?e.map(mn):e,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),A=M&&!f?b.responsive??{minWidth:w}:f,S=M&&!p?b.cohesion:p;if(0===v.length||0>=g||0>=x)return v.slice();const I=[],z=function(t,e){return(t.pointNodes||[]).map(t=>{const n=Math.max(1,t.r||1)+e;return{x:t.x-n,y:t.y-n,width:2*n,height:2*n}})}(n,i);let N=!1;const C=v.map((t,e)=>{if(!pn(t))return t;const i=Mn(t,e,n);if(!i)return t;const u=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,n=[...yn("string"==typeof t.title?t.title:void 0,e),...yn("string"==typeof t.label?t.label:void 0,e)],o=n.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*n.length+6)}}(t);if(s&&("number"==typeof(d=t).dx||"number"==typeof d.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:30,dy:-30}}(t);return I.push(xn(gn(i.x,i.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),r)),t}var d;let h=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(o)){const e=wn(gn(i.x,i.y,t.dx,t.dy,u),t,I,z,g,x,r,a);f>e&&(h=t,f=e)}if(!h)return t;const m=xn(gn(i.x,i.y,h.dx,h.dy,u),r);I.push(m);const p=Math.hypot(h.dx,h.dy),y=c&&p>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return N=!0,{...t,dx:h.dx,dy:h.dy,...y?{connector:y}:{}}}),T=N?C:v.slice();let E=T;if(h){let t=!1;const e=T.map(e=>{const n=function(t){return"text"!==t.type||"string"!=typeof t.color||8>Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)?t:{...t,_redundantConnector:!0}}(e);return n!==e&&(t=!0),n});E=t?e:T}{let t=!1;const e=E.map(e=>{if(!0!==e?.defensive)return e;const n=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const n="string"==typeof e.source?fn[e.source]??e.source:null,o="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!n&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof t.label?t.label:"";return i.includes(`(${r})`)?t:{...t,label:i?`${i} (${r})`:`(${r})`}}(e);return n!==e&&(t=!0),n});E=t?e:E}const W=new Set;if(k){const t="object"==typeof k?k:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return 3;const n=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===n.length?3:n.reduce((t,e)=>t+e,0)/n.length}(t);return e>2?4>e?1:.6:1.5}(y),n=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??rn(g,x,t))*e))},{deferred:o}=sn({annotations:E,width:g,height:x,...n});for(const t of o)W.add(t)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:480)>=g)for(const t of E)pn(t)&&"secondary"===t.emphasis&&W.add(t);if(W.size>0)for(const t of E)!0===t?.defensive&&W.delete(t);let L;return L=0===W.size?E:$?E.map(t=>W.has(t)?{...t,_annotationDeferred:!0}:t):E.filter(t=>!W.has(t)),S?function(t,e){let n=!1;const o=t.map(t=>pn(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(n=!0,{...t,cohesion:e}):t);return n?o:t}(L,S):L}import*as kn from"react";function $n(t,e){if("function"==typeof t)return t;const n=t??e;return t=>Number(t[n])}function An(t,e={}){const n=$n(e.start,"start"),o=$n(e.end,"end"),r=!1===e.sort?t.slice():t.slice().sort((t,e)=>n(t)-n(e)||o(e)-o(t)),i=[];return{packed:r.map(t=>{const e=n(t);let r=i.findIndex(t=>e>=t);return-1===r&&(r=i.length),i[r]=o(t),{item:t,track:r}}),trackCount:Math.max(1,i.length)}}function Sn(t,e){const n=$n(e.start,"start"),o=$n(e.end,"end"),[r,i]=e.domain,a=e.step??1,s="half-open"===e.bounds,c=[];for(let e=r;i>=e;e+=a){let r=0;for(const i of t){const t=n(i),a=o(i);t>e||(s?e>=a:e>a)||r++}c.push({value:e,count:r})}return c}function In(t){return"function"==typeof t?t:e=>e[t]}var zn=t=>{const e=t.config,{plot:n}=t.dimensions;if(0>=n.width||0>=n.height||0===t.data.length||!e?.domain)return{nodes:[]};const o=In(e.laneAccessor),r=In(e.startAccessor),i=In(e.endAccessor),a=e.idAccessor?In(e.idAccessor):null,s=e.unit??0,c=e.barGap??1.5,l=Math.max(0,e.minBarWidth??2),u=e.minBarHeight??3.5,d=e.maxBarHeight??10,h=e.lanePadding??7,f=e.cornerRadius??2,m=e.bottomInset??0,p=e.color??((e,n)=>t.resolveColor(n)),[y,g]=e.domain,x=g-y||1,b=t=>n.x+(t-y)/x*n.width,w=t.scales?.o?.domain?.()??[],M=e.lanes??(w.length>0?w:[...new Set(t.data.map(o))]),v=Math.max(0,n.height-m)/Math.max(1,M.length),k=t=>b(r(t)),$=t=>Math.max(k(t)+l,b(i(t)+s)),A=[];M.forEach((e,r)=>{const i=n.y+r*v,s=t.data.filter(t=>o(t)===e);if(0===s.length)return;const{packed:l,trackCount:m}=An(s,{start:k,end:$}),y=new Map,g=new Map;for(const{item:t,track:e}of l){const n=g.get(e);n?n.push(t):g.set(e,[t])}for(const t of g.values()){t.sort((t,e)=>k(t)-k(e));for(let e=0;t.length-1>e;e++)y.set(t[e],k(t[e+1]))}const x=(v-2*h)/m,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:t,track:n}of l){const o=k(t),r=y.get(t),s=$(t)-o;A.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+s>r-1?Math.max(1,r-1-o):s,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:p(t,e),stroke:"none"},datum:t,group:e,_transitionKey:a?a(t)+"":void 0})}});const S=`var(--semiotic-text, ${t.theme.semantic.text??"#1a1a1a"})`,I=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,z=`var(--semiotic-border, ${t.theme.semantic.border??"#94a3b8"})`,N=[];(e.periods??[]).forEach((t,e)=>{const o=b(t.start),r=Math.max(1,b(t.end+s)-o);N.push(kn.createElement("rect",{key:"period-"+e,x:o,y:n.y,width:r,height:n.height,fill:z,opacity:e%2==0?.06:.025,pointerEvents:"none"})),t.name&&N.push(ge({keyId:"period-label-"+e,text:t.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:I}))});const C=!1!==e.showLaneLabels,T=e.laneLabelGap??12;if(M.forEach((t,e)=>{const o=n.y+e*v;N.push(kn.createElement("line",{key:"lane-sep-"+e,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:z,opacity:.45})),C&&N.push(ge({keyId:"lane-label-"+e,text:t,x:n.x-T,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==e.showAxis){const t=e.axisTicks??Array.from({length:8},(t,e)=>Math.round(y+e/7*x));N.push(be({keyId:"interval-axis",scale:b,ticks:t,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:e.tickFormat,color:I}))}return{nodes:A,overlays:kn.createElement(kn.Fragment,null,...N)}};function Nn(t,e,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,a=(t,e)=>(t+e)/2;if("vertical"===o){if(i>Math.abs(e.y-t.y)){const n=t.x>e.x?-1:1,o=a(t.x,e.x)+n*(22+Math.abs(r));return`M${t.x},${t.y} Q${o},${a(t.y,e.y)} ${e.x},${e.y}`}const n=a(t.y,e.y)+r;return`M${t.x},${t.y} C${t.x},${n} ${e.x},${n} ${e.x},${e.y}`}if(i>Math.abs(e.x-t.x)){const n=t.y>e.y?-1:1,o=a(t.y,e.y)+n*(22+Math.abs(r));return`M${t.x},${t.y} Q${a(t.x,e.x)},${o} ${e.x},${e.y}`}const s=a(t.x,e.x)+r;return`M${t.x},${t.y} C${s},${t.y} ${s},${e.y} ${e.x},${e.y}`}function Cn(t,e,n){if("vertical"===(n?.orientation??"vertical")){const n=(t.y+e.y)/2;return`M${t.x},${t.y} L${t.x},${n} L${e.x},${n} L${e.x},${e.y}`}const o=(t.x+e.x)/2;return`M${t.x},${t.y} L${o},${t.y} L${o},${e.y} L${e.x},${e.y}`}function Tn(t,e,n){if("vertical"===(n?.orientation??"vertical")){const n=e.cy>=t.cy;return{from:{x:t.cx,y:t.cy+(n?t.height/2:-t.height/2)},to:{x:e.cx,y:e.cy+(n?-e.height/2:e.height/2)}}}const o=e.cx>=t.cx;return{from:{x:t.cx+(o?t.width/2:-t.width/2),y:t.cy},to:{x:e.cx+(o?-e.width/2:e.width/2),y:e.cy}}}function En(t,e){const n=e?.spread??5;return e?.modulo&&e.modulo>0?(t%e.modulo-(e.modulo-1)/2)*n:(t-((e?.count??1)-1)/2)*n}function Wn(t,e){const n=1-e,o=n*n*n,r=3*n*n*e,i=3*n*e*e,a=e*e*e;return{x:o*t.p0.x+r*t.p1.x+i*t.p2.x+a*t.p3.x,y:o*t.p0.y+r*t.p1.y+i*t.p2.y+a*t.p3.y}}function Ln(t,e){const n=1-e,o=3*n*n,r=6*n*e,i=3*e*e;return{x:o*(t.p1.x-t.p0.x)+r*(t.p2.x-t.p1.x)+i*(t.p3.x-t.p2.x),y:o*(t.p1.y-t.p0.y)+r*(t.p2.y-t.p1.y)+i*(t.p3.y-t.p2.y)}}function Fn(t){return`M${t.p0.x},${t.p0.y} C${t.p1.x},${t.p1.y} ${t.p2.x},${t.p2.y} ${t.p3.x},${t.p3.y}`}function jn(t,e){const n=e?.axis??"x",o=e?.padding??0,r=e?.strength??.5,i="x"===n?"y":"x",a="x"===n?"width":"height",s="x"===n?"height":"width",c=new Map;for(const e of t)c.set(e.id,0);for(let e=0;t.length>e;e++)for(let l=e+1;t.length>l;l++){const u=t[e],d=t[l];if(Math.abs(u[i]-d[i])>(u[s]+d[s])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[a]+d[a])/2+o-Math.abs(h);if(0>=f)continue;const m=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-m),c.set(d.id,(c.get(d.id)??0)+m)}return c}var Rn={width:60,height:34};function On(t,e){if("function"==typeof t)return t;const o=t??e;return t=>n(t,o,void 0)}function Pn(t,e,n,r){const i=r.fixedAxis??"y",a=t=>On(r.sourceAccessor,"source")(t)+"",s=t=>On(r.targetAccessor,"target")(t)+"",c=r.size??(()=>Rn),l=r.iterations??180,u=r.attraction??.012,d=r.anchorStrength??.003,h=r.collisionStrength??.12,f=r.collisionPadding??15,m=r.edgePadding??42,p=r.fixedPadding??16,y=r.damping??.72,g=r.spread??1,[x,b]=r.fixedDomain,w=b-x||1,M=("y"===i?n.y:n.x)+p,v=("y"===i?n.y+n.height:n.x+n.width)-p,k=("y"===i?n.x:n.y)+m,$=("y"===i?n.x+n.width:n.y+n.height)-m,A=Math.max(1,$-k),S=t.map(t=>{const e=o(t)??t,n=(i=t,On(r.idAccessor,"id")(i)+"");var i;const{width:a,height:s}=c(e),l=(t=>Number(On(r.fixedAccessor,"fixed")(t)))(t),u=k+function(t){let e=2166136261;for(let n=0;t.length>n;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0)/4294967295}(n)*A;return{data:e,id:n,width:a,height:s,fixedValue:l,fixed:(d=l,M+(d-x)/w*(v-M)),free:u,anchor:u};var d}),I=new Map(S.map(t=>[t.id,t])),z=t=>"y"===i?t.width:t.height;for(let t=0;l>t;t++){const t=new Map;for(const e of S)t.set(e.id,0);for(const n of e){const e=I.get(a(n)),o=I.get(s(n));if(!e||!o)continue;const r=(o.free-e.free)*u;t.set(e.id,(t.get(e.id)??0)+r),t.set(o.id,(t.get(o.id)??0)-r)}for(const e of S)t.set(e.id,(t.get(e.id)??0)+(e.anchor-e.free)*d);const n=jn(S.map(t=>({id:t.id,x:"y"===i?t.free:t.fixed,y:"y"===i?t.fixed:t.free,width:t.width,height:t.height})),{axis:"y"===i?"x":"y",padding:f,strength:h});for(const e of S)t.set(e.id,(t.get(e.id)??0)+(n.get(e.id)??0));for(const e of S){e.free+=(t.get(e.id)??0)*y;const n=z(e)/2;e.free=Math.max(k+n,Math.min($-n,e.free))}}if(1!==g){const t=(k+$)/2;for(const e of S){const n=z(e)/2;e.free=Math.max(k+n,Math.min($-n,t+(e.free-t)*g))}}const N=S.map(t=>({data:t.data,id:t.id,x:"y"===i?t.free:t.fixed,y:"y"===i?t.fixed:t.free,width:t.width,height:t.height,fixedValue:t.fixedValue}));return{positioned:N,byId:new Map(N.map(t=>[t.id,t]))}}var qn=t=>{const{plot:e}=t.dimensions;if(0>=e.width||0>=e.height||0===t.nodes.length||!t.config?.fixedDomain)return{sceneNodes:[]};const r=t.config.fixedAxis??"y",{positioned:i,byId:a}=Pn(t.nodes,t.edges,e,t.config),s=i.map(e=>({type:"rect",x:e.x-e.width/2,y:e.y-e.height/2,w:e.width,h:e.height,style:{fill:t.resolveColor(e.id),stroke:"none"},datum:e.data,id:e.id,label:e.id})),c=[];t.edges.forEach((e,i)=>{const s=a.get((l=e,("function"==typeof t.config.sourceAccessor?t.config.sourceAccessor(l):n(l,t.config.sourceAccessor??"source",void 0))+""));var l;const u=a.get((e=>("function"==typeof t.config.targetAccessor?t.config.targetAccessor(e):n(e,t.config.targetAccessor??"target",void 0))+"")(e));if(!s||!u)return;const{from:d,to:h}=Tn({cx:s.x,cy:s.y,width:s.width,height:s.height},{cx:u.x,cy:u.y,width:u.width,height:u.height},{orientation:"y"===r?"vertical":"horizontal"});c.push({type:"curved",pathD:Nn(d,h,{orientation:"y"===r?"vertical":"horizontal",bend:En(i,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:o(e)??e})});const l=i.map(t=>({x:t.x,y:t.y,text:t.id}));return{sceneNodes:s,sceneEdges:c,labels:l}},Dn={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Bn=8;function Yn(t){return null==t?void 0:t+""}function Vn(t){const e=Yn(t.id);return{type:"point",x:t.x,y:t.y,r:t.r??8,style:{...Dn},datum:t.datum,pointId:e,_transitionKey:e}}function Hn(t){return Vn(t)}function Xn(t){const[[e,n],[o,r]]=t.bounds;return{type:"geoarea",pathData:t.pathData,centroid:t.centroid,bounds:t.bounds,screenArea:t.screenArea??Math.abs((o-e)*(r-n)),style:{...Dn},datum:t.datum,group:t.group,interactive:!0}}function _n(t){return{type:"rect",x:t.x,y:t.y,w:t.width,h:t.height,style:{...Dn},datum:t.datum,group:t.group,_transitionKey:Yn(t.id)}}function Gn(t){const e=Yn(t.id);return"width"in t&&"height"in t?{type:"rect",x:t.x,y:t.y,w:t.width,h:t.height,style:{...Dn},datum:t.datum,id:e,label:t.label}:{type:"circle",cx:t.x,cy:t.y,r:t.r??8,style:{...Dn},datum:t.datum,id:e,label:t.label}}function Un(t,e,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:a=!1}=n,s=[],c=e=>o?o(t[e],e):e,l=(t,e,n)=>{t.endIndex=e,t.count=e-t.startIndex+1,t.end=o?null==n||c(n)-c(e)>r?c(e)+r:c(n):e+1,s.push(t)};let u=null;for(let n=0;t.length>n;n++){const s=e(t[n],n);if(a&&!s){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,s)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:s,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),s}var Kn=Un;function Qn(t,e,n=0){return e>0?((t-n)%e+e)%e+n:t}function Zn(t,e,n){if(0>=n)return e-t;let o=(e-t)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function Jn(t,e,n){return e>n?t>=e||n>=t:t>=e&&n>=t}function to(t,e,n,o){return n>o?[...t.filter(t=>e(t)>=n),...t.filter(t=>e(t)<=o)]:t.filter(t=>Jn(e(t),n,o))}var eo=2*Math.PI;function no(t,e,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(t)*e,y:r-Math.cos(t)*e}}function oo(t,e,n){return(Math.atan2(t-(n?.center?.x??0),-(e-(n?.center?.y??0)))+eo)%eo}function ro(t,e){const[n,o]=t,r=o-n||1,i=e?.startAngle??0,a=e?.endAngle??eo;return t=>i+(t-n)/r*(a-i)}function io(t,e){const[n,o]=t,[r,i]=e,a=o-n||1;return t=>r+(t-n)/a*(i-r)}function ao(t,e,n,o,r){const i=r?.center,a=(t,e)=>{const{x:n,y:o}=no(t,e,{center:i});return`${so(n)},${so(o)}`},s=Math.max(0,n),c=Math.max(s,o),l=Math.abs(e-t),u=t>e?0:1;if(l>=eo-1e-6){const t=i?.x??0,e=i?.y??0,n=`${so(t)},${so(e-c)}`,o=`${so(t)},${so(e+c)}`;let r=`M${n} A${so(c)},${so(c)} 0 1 1 ${o} A${so(c)},${so(c)} 0 1 1 ${n} Z`;if(s>0){const n=`${so(t)},${so(e-s)}`,o=`${so(t)},${so(e+s)}`;r+=` M${n} A${so(s)},${so(s)} 0 1 0 ${o} A${so(s)},${so(s)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=a(t,c),f=a(e,c);if(0>=s){const t=i?.x??0,e=i?.y??0;return`M${so(t)},${so(e)} L${h} A${so(c)},${so(c)} 0 ${d} ${u} ${f} Z`}const m=a(e,s),p=a(t,s);return`M${h} A${so(c)},${so(c)} 0 ${d} ${u} ${f} L${m} A${so(s)},${so(s)} 0 ${d} ${1===u?0:1} ${p} Z`}function so(t){return Math.round(1e3*t)/1e3}function co(t,e){return{x:t.x+e.x,y:t.y+e.y}}function lo(t,e){return{x:t.x-e.x,y:t.y-e.y}}function uo(t,e){return{x:t.x*e,y:t.y*e}}function ho(t){return Math.hypot(t.x,t.y)}function fo(t){const e=ho(t)||1;return{x:t.x/e,y:t.y/e}}var mo=[40,40],po=[.5,.5];function yo(t,e){const[n,o]=t.viewBox??mo,[r,i]=t.anchor??po,a=o>0?o:1,s=Math.max(0,e)/a,c=(n>0?n:a)*s,l=a*s;return{width:c,height:l,scale:s,offsetX:-r*c,offsetY:-i*l}}function go(t,e){const n=yo(t,e),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[t,e]of o){const n=Math.sqrt(t*t+e*e);n>r&&(r=n)}return r}function xo(t,e,n,o){if("none"!==t)return"color"===t||null==t?e??o:"accent"===t?n:t}function bo(t,e,n=0,o="horizontal"){const[r,i]=t.viewBox??mo,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,e));return s>a?a>0||1>s?"vertical"===o?{x:0,y:i*(1-s),width:r,height:i*(s-a)}:{x:r*a,y:0,width:r*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}import{jsx as wo,jsxs as Mo}from"react/jsx-runtime";var vo="var(--semiotic-text, currentColor)";function ko(t,e){const n=ot(t,100);return n>0?e/n*100*(e/n):Math.PI*e*e}function $o(t){const e=[],n=t.colorMap?Object.entries(t.colorMap):t.keys?t.keys.map(e=>[e,t.color?t.color(e):void 0]):[];if(n.length>0){const o=t.colorType??"fill",r=n.map(([t,e])=>({label:t,color:e}));e.push({type:o,label:t.colorLabel??"",items:r,styleFn:"line"===o?t=>({stroke:t.color??vo,strokeWidth:2,fill:"none"}):t=>({fill:t.color??vo,stroke:t.color??vo})})}if(t.symbolMap&&Object.keys(t.symbolMap).length>0){const n=t.symbolColor??vo,o=Object.entries(t.symbolMap).map(([t,e])=>({label:t,shape:e,color:n}));e.push({label:t.symbolLabel??"",items:o,styleFn:()=>({}),type:t=>{const e=t.shape;return wo("path",{d:tt(e,ko(e,7)),transform:"translate(8,8)",fill:t.color??n})}})}if(t.sizeStops&&t.sizeStops.length>0&&t.sizeRadius){const n=t.sizeRadius,o=t.sizeFormat??(t=>t+""),r=t.sizeColor??vo,i=t.sizeStops.map(t=>({label:o(t),r:Math.max(.5,n(t)),color:r}));e.push({label:t.sizeLabel??"",items:i,styleFn:()=>({}),type:t=>wo("circle",{cx:8,cy:8,r:t.r,fill:t.color??r})})}return e}function Ao(t){const e=t.orientation??"vertical",n=t.swatchSize??14,o=t.gap??8,r=t.labelGap??6,i=t.fontSize??12,a=t.color??"var(--semiotic-text-secondary, #888)",s=n+o;let c=0;const l=[];return t.entries.forEach((t,u)=>{l.push(Mo("g",{transform:`translate(${"vertical"===e?0:c},${"vertical"===e?c:0})`,children:[So(t,n,t.color??t.line??a,a),wo("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:a,children:t.label})]},"legend-"+u)),c+="vertical"===e?s:n+r+t.label.length*i*.58+o+8}),wo("g",{className:t.className,transform:`translate(${t.x},${t.y})`,style:{pointerEvents:"none"},children:l},t.keyId)}function So(t,e,n,o){if(t.shape){const o=ko(t.shape,e/2-1);return wo("path",{d:tt(t.shape,o),transform:`translate(${e/2},${e/2})`,fill:n})}if(t.hatch){const n=t.color??o;return Mo("g",{children:[wo("svg",{width:e,height:e,style:{overflow:"hidden"},children:[-e,-e/2,0,e/2].map((t,o)=>wo("line",{x1:t,y1:e,x2:t+e,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),wo("rect",{width:e,height:e,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return wo("rect",t.line?{y:e/2-1.5,width:e,height:3,rx:1.5,fill:t.line}:{width:e,height:e,rx:2,fill:n})}var Io=new Set(["rows"]);function zo(t){const e=t,n=[Eo(e,["datum","data"]),Eo(e,["datum"]),Eo(e,["data","data"]),Eo(e,["data"]),Eo(e,["node","datum","data"]),Eo(e,["node","datum"]),t];for(const t of n){if(!Wo(t))continue;const e={};for(const[n,o]of Object.entries(t))n.startsWith("_")||"function"==typeof o||(e[n]=o);if(Object.keys(e).length>0)return e}return null}function No(t,e={}){const n=zo(t);if(!n)return[];const o=new Set(Io);if(e.excludeKeys)for(const t of e.excludeKeys)o.add(t);const r=[];for(const[t,i]of Object.entries(n))if((e.includeInternal||!t.startsWith("_"))&&!o.has(t)&&(e.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:t,label:To(t,e.labels),value:i,formatted:e.valueFormat?e.valueFormat(i,t,n):Co(i)}),r.length>=(e.maxEntries??8)))break;return r}function Co(t){if(null==t)return"";if(t instanceof Date)return t.toISOString();if("number"==typeof t)return Number.isInteger(t)?t+"":t.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof t)return t?"true":"false";if(Array.isArray(t))return t.length+" items";if("object"==typeof t)try{return JSON.stringify(t)}catch{return t+""}return t+""}function To(t,e){return"function"==typeof e?e(t):e&&e[t]?e[t]:t}function Eo(t,e){let n=t;for(const t of e){if(!Wo(n))return;n=n[t]}return n}function Wo(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Lo(t,e){const n=new Map;for(const e of t)n.set(e.id,new Set);for(const t of e)n.has(t.source)||n.set(t.source,new Set),n.has(t.target)||n.set(t.target,new Set),n.get(t.source).add(t.target),n.get(t.target).add(t.source);return n}function Fo(t,e){const n={};for(const e of t)n[e.id]=0;for(const t of e)n[t.source]=(n[t.source]||0)+1,n[t.target]=(n[t.target]||0)+1;return n}function jo(t,e){const n={[e]:0},o=[e];let r=0;for(;o.length>r;){const e=o[r];r+=1;for(const r of t.get(e)||[])void 0===n[r]&&(n[r]=n[e]+1,o.push(r))}return n}function Ro(t,e,n,o){if(n===o)return n?[n]:[];const r=Lo(t,e),i={[n]:null},a=[n];let s=0;for(;a.length>s;){const t=a[s];if(s+=1,t===o)break;for(const e of r.get(t)||[])void 0===i[e]&&(i[e]=t,a.push(e))}if(void 0===i[o])return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function Oo(t,e,n,o=1){const r=Lo(t,e);if(!r.has(n))return new Set;const i=jo(r,n),a=new Set;for(const t in i)i[t]>o||a.add(t);return a}function Po(t,e){const n=Lo(t,e),o={};for(const e of t)o[e.id]=0;for(const e of t.map(t=>t.id)){const r=[],i={},a={},s={};for(const e of t)i[e.id]=[],a[e.id]=0,s[e.id]=-1;a[e]=1,s[e]=0;const c=[e];let l=0;for(;c.length>l;){const t=c[l];l+=1,r.push(t);for(const e of n.get(t)||[])0>s[e]&&(s[e]=s[t]+1,c.push(e)),s[e]===s[t]+1&&(a[e]+=a[t],i[e].push(t))}const u={};for(const e of t)u[e.id]=0;for(;r.length;){const t=r.pop();for(const e of i[t])u[e]+=a[e]/a[t]*(1+u[t]);t!==e&&(o[t]+=u[t])}}for(const t in o)o[t]/=2;return o}function qo(t,e){const n=Lo(t,e),o={};for(const e of t){const t=jo(n,e.id);let r=0,i=0;for(const e in t)r+=t[e],i+=1;o[e.id]=r>0?(i-1)/r:0}return o}function Do(t,e){const n=Lo(t,e),o={};for(const e of t){const t=[...n.get(e.id)||[]],r=t.length;if(2>r){o[e.id]=0;continue}let i=0;for(let e=0;t.length>e;e+=1)for(let o=e+1;t.length>o;o+=1)n.get(t[e])?.has(t[o])&&(i+=1);o[e.id]=2*i/(r*(r-1))}return o}function Bo(t){let e=0;for(const n in t)t[n]>e&&(e=t[n]);const n={};for(const o in t)n[o]=e>0?t[o]/e:0;return n}function Yo(t,e,n,o={}){const r=Lo(t,e),i={};for(const e of t)i[e.id]=jo(r,e.id);let a=o.minHops??4,s=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let e=0;t.length>e;e+=1)for(let o=e+1;t.length>o;o+=1){const r=t[e].id,c=t[o].id,u=n[r],d=n[c];if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=a&&s>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(s+=.02,s>c&&(s=o.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:l,threshold:s,minHops:a}}function Vo(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Ho(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const t=Error("Force layout aborted");return t.name="AbortError",t}var Xo=class{constructor(t=function(){const t="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):function(t){if("undefined"!=typeof __filename){const e=__filename.replace(/\\/g,"/"),n=e.startsWith("/")?e:"/"+e;return new URL("./"+t,"file:"+n)}throw Error("Cannot resolve module worker asset: "+t)}("forceLayoutWorker.js");return new Worker(t,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=t,this.worker.onmessage=t=>{const e=t.data,n=e.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n?this.pending.delete(n):this.pending.clear(),o.cleanup(),e.error){const t=Error(e.error.message);return t.name=e.error.name??"Error",e.error.stack&&(t.stack=e.error.stack),void o.reject(t)}o.resolve({positions:e.positions??{}})}},this.worker.onerror=t=>{this.rejectAll(Error(t.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(t,e){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(e?.aborted)return Promise.reject(Ho());const n=this.nextRequestId;this.nextRequestId+=1;const o={requestId:n,request:t};return new Promise((t,r)=>{const i=()=>{this.pending.delete(n),e?.removeEventListener("abort",i),r(Ho())},a=()=>e?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:r,resolve:t}),e?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(t){this.pending.delete(n),a(),r(t instanceof Error?t:Error(t+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(t){for(const e of this.pending.values())e.cleanup(),e.reject(t);this.pending.clear()}},_o=null;async function Go(t,e,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:a,...s}=n,c=s.iterations??260,l=Vo()&&function(t,e,n,o,r=4e4){return"sync"!==t&&("worker"===t||o*(e+n)>=r)}(o,t.length,e.length,c,i);if(!l)return E(t,e,{...s,nodeRadius:a});const u={kind:"normalized",nodes:t.map(t=>({...t})),edges:e.map(t=>({...t})),options:s,nodeRadii:"function"==typeof a?Object.fromEntries(t.map(t=>[t.id,a(t)])):null==a?void 0:Object.fromEntries(t.map(t=>[t.id,a]))};try{return(await function(t,e){return Vo()?e?.aborted?Promise.reject(Ho()):(_o&&!_o.isDead||(_o=new Xo),_o).request(t,e):Promise.reject(Error("Web Workers are unavailable"))}(u,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return E(t,e,{...s,nodeRadius:a})}}function Uo(t,e){if("region-enter"!==e.type)return t;const n=e.region.id,o=t[n]??{id:n,label:e.region.label??n,count:0,bodyIds:[]};if(o.bodyIds.includes(e.bodyId))return t;const r=[...o.bodyIds,e.bodyId];return{...t,[n]:{...o,count:r.length,bodyIds:r}}}function Ko(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 Qo(t,e){const n=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],o=e.filter(t=>!n.has(t)),r=e.length-o.length,i=t.completion?.mode??"allMembersAbsorbed",a=t.completion?.valueByBodyId,s=t=>{const e=a?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},c=e.reduce((t,e)=>t+s(e),0),l=e.reduce((t,e)=>t+(n.has(e)?s(e):0),0),u=t.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:i,complete:e.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:e.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function Zo(t,e,n){return Math.max(e,Math.min(n,t))}function Jo(t,e,n={}){const o=n.random??Math.random,r=t.stages.find(t=>t.id===e)??t.stages[t.stages.length-1],i=Zo(n.along??.5,.05,.95),a=n.jitterX??0,s=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*a,l=Math.min(1,r.width/2),u=Zo(c,r.x0+l,r.x1-l),d=t.boundaryY(u,"top")+s,h=t.boundaryY(u,"bottom")-s;return{x:u,y:h>d?d+o()*Math.max(1,h-d):t.midY}}function tr(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 er(t,e,n){return Math.max(e,Math.min(n,t))}function nr(t,e,n,o,r,i={}){return{id:t,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:e,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function or(t){const e=t.shape??"lane",n=Math.max(1,Math.round(t.width)),o=Math.max(1,Math.round(t.height)),r=t.padX??46,i=t.padY??72,a=r,s=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=er(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,p=er(d*h+m,.06*d,.5*d),y=p/2,g=u-y,x=u+y,b=t.idPrefix??"process",w=t.friction??.58,M=t.restitution??.18,v=t.wallThickness??8,k=t.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=er(t.centerStageIndex??Math.floor(k.length/2),0,k.length-1),A=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(k),S=s-a;let I=a;const z=k.map((t,e)=>{const n=I,o=e===k.length-1?s:I+(t.share??1)/A*S;return I=o,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),N=z[$],C=N.x0,T=N.x1,E=(t,n)=>{if("lane"===e)return"top"===n?c:l;if("funnel"===e){const e=er((t-a)/Math.max(1,s-a),0,1);return"top"===n?c+(g-c)*e:l+(x-l)*e}if(C>=t){const e=er((t-a)/Math.max(1,C-a),0,1);return"top"===n?c+(g-c)*e:l+(x-l)*e}if(T>=t)return"top"===n?g:x;const o=er((t-T)/Math.max(1,s-T),0,1);return"top"===n?g+(c-g)*o:x+(l-x)*o},W=z.map(t=>{const e=Math.min(E(t.x0,"top"),E(t.x1,"top")),n=Math.max(E(t.x0,"bottom"),E(t.x1,"bottom"));return{...t,y:(e+n)/2,height:Math.max(1,n-e)}}),L={thickness:v,friction:w,restitution:M},F=[];"lane"===e?F.push(nr(b+"-top",a,c,s,c,L),nr(b+"-bottom",a,l,s,l,L),nr(b+"-left",a,c,a,l,{...L,thickness:Math.max(6,v-2)}),nr(b+"-right",s,c,s,l,{...L,thickness:Math.max(6,v)})):"funnel"===e?F.push(nr(b+"-top",a,c,s,g,L),nr(b+"-bottom",a,l,s,x,L),nr(b+"-left",a,c,a,l,{...L,thickness:Math.max(6,v-2)}),nr(b+"-right",s,g,s,x,{...L,thickness:Math.max(6,v)})):F.push(nr(b+"-left-top",a,c,C,g,L),nr(b+"-left-bottom",a,l,C,x,L),nr(b+"-center-top",C,g,T,g,L),nr(b+"-center-bottom",C,x,T,x,L),nr(b+"-right-top",T,g,s,c,L),nr(b+"-right-bottom",T,x,s,l,L),nr(b+"-left",a,c,a,l,{...L,thickness:Math.max(6,v-2)}),nr(b+"-right",s,c,s,l,{...L,thickness:Math.max(6,v)}));const j=t.membraneDampingScale??.5,R=a,O=Math.max(1,("bowtie"===e?C:s)-R),P=(t.membranes??[]).map(t=>{const e=R+er(t.offset,0,1)*O,n=t.width??18+18*t.cost,o=d-16,r=u+.25*(t.wobble??0);return{...t,x:e,y:r,width:n,height:o}}),q=!1===t.includeMembraneRegions?[]:P.map(t=>ar({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??j,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:n,height:o,padX:r,padY:i,left:a,right:s,topY:c,bottomY:l,midY:u,centerLeft:C,centerRight:T,pinchHeight:p,pinchTop:g,pinchBottom:x,stages:W,membranes:P,colliders:F,regionEffects:q,boundaryY:E}}function rr(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,n=t.y,o=t.width,r=t.height,{type:"aabb",x:e,y:n,width:o,height:r}),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,n,o,r}function ir(t,e={}){const n=e.idPrefix??"stage",o=Math.max(0,e.insetX??0),r=Math.max(0,e.insetY??1);return t.stages.map(t=>{const i="function"==typeof e.metadata?e.metadata(t):e.metadata??{};return{...rr({id:n?`${n}:${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*o),height:Math.max(1,t.height-2*r),bodyFilter:e.bodyFilter,semanticItem:e.semanticItem,attributes:{primitive:"processStage",stageId:t.id,stageIndex:t.index},metadata:{...i,primitive:"processStage",stageId:t.id,stageIndex:t.index}})}})}function ar(t){const e=t.dampingScale??.5,n=t.energyScale??1,o=er(t.cost,0,2);return{...rr({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o*e,energyDelta:-o*n}}function sr(t){return{...rr({...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 cr(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...rr({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function lr(t){const e=t.pressure??t.occupancy??0,n=t.baseDamping??.08,o=t.dampingPerUnit??.12,r=t.energyPerUnit??0;return{...rr({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:n+e*o,energyDelta:r?-e*r:void 0,force:t.force}}function ur(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...rr({...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 dr(t){return{...rr({...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 hr(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...rr({...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 fr(t){return{...rr({...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 mr(t){const e=t.x??t.anchor?.x??0,n=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:n,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:n},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}function pr(t){const e=t.idPrefix??"lane",n={thickness:t.thickness??8,friction:t.friction??.5,restitution:t.restitution??.16},o=[nr(e+"-top",t.left,t.top,t.right,t.top,n),nr(e+"-bottom",t.left,t.bottom,t.right,t.bottom,n)];return t.openEnds||o.push(nr(e+"-left",t.left,t.top,t.left,t.bottom,n),nr(e+"-right",t.right,t.top,t.right,t.bottom,n)),o}var yr=[.1,.5,.9],gr=1e6;function xr(t){const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function br(t,e,n,o,r){return"function"==typeof o?o(t,e,n):function(t,e){let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}(t,o??r)}function wr(t){const e=Number(t.toFixed(12));return Object.is(e,-0)?0:e}function Mr(t,e,n,o){const r=t.flatMap((t,r)=>{const i=xr(br(t,r,e,n,"time")),a=xr(br(t,r,e,o,"value"));return null==i||null==a?[]:[{time:wr(i),value:a,index:r}]});r.sort((t,e)=>t.time-e.time||t.index-e.index);const i=[];for(const t of r){const e=i[i.length-1];e?.time===t.time?e.value=t.value:i.push({time:t.time,value:t.value})}return i}function vr(t,e,n,o){if(!t.length)return null;const r=t[0],i=t[t.length-1];if(r.time>e)return"clamp"===o?r.value:null;if(e>i.time)return"clamp"===o?i.value:null;const a=function(t,e){let n=0,o=t.length;for(;o>n;){const r=n+o>>>1;e>t[r].time?n=r+1:o=r}return n}(t,e),s=t[a];if(s?.time===e)return s.value;const c=t[Math.max(0,a-1)];return"step"!==n&&s&&s.time!==c.time?c.value+(e-c.time)/(s.time-c.time)*(s.value-c.value):c.value}function kr(t,e){if(1===t.length)return t[0];const n=(t.length-1)*e,o=Math.floor(n),r=Math.ceil(n);return o===r?t[o]:t[o]+(t[r]-t[o])*(n-o)}function $r(t){const e=t.interpolation??"step",n=t.outsideDomain??"omit",o=function(t){const e=(t??yr).map(t=>{const e=xr(t);if(null==e||0>e||e>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+t);return wr(e)});return Array.from(new Set(e)).sort((t,e)=>t-e)}(t.quantiles),r=function(t){if(Array.isArray(t)){if(t.length>gr)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(t.map(xr).filter(t=>null!=t).map(wr))).sort((t,e)=>t-e)}const e=t,n=xr(e.start),o=xr(e.end),r=xr(e.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>gr)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");const a=[],s=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let t=0;i>t;t+=1){const e=n+t*r;if(e>o+s)break;a.push(wr(Math.min(e,o)))}if(a.length&&s>=Math.abs(a[a.length-1]-o)||a.push(wr(o)),a.length>gr)throw new RangeError("physicsReferenceEnvelope sampleAt exceeds 1000000 points");return Array.from(new Set(a)).sort((t,e)=>t-e)}(t.sampleAt),i=t.runs.map(e=>Mr(e.samples,e.id,t.timeAccessor,t.valueAccessor));return{points:r.map(t=>{const r=i.map(o=>vr(o,t,e,n)).filter(t=>null!=t).sort((t,e)=>t-e),a={};for(const t of o)a[t]=r.length?kr(r,t):null;return{time:t,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?kr(r,.5):null,quantiles:a}}),quantiles:o,interpolation:e,outsideDomain:n,runCount:t.runs.length}}function Ar(t,e){return t.quantiles.length?"lower"===e?t.quantiles[0]:t.quantiles[t.quantiles.length-1]:"lower"===e?"min":"max"}function Sr(t,e){if("min"===e||"median"===e||"max"===e)return t[e];const n=xr(e);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+e);const o=wr(n);if(!Object.prototype.hasOwnProperty.call(t.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return t.quantiles[o]??null}function Ir(t,e,n){return e>t?"below":t>n?"above":"inside"}function zr(t,e){const n=Math.max(0,e.time-t.time);if(0>=n||null==t.value||null==t.lower||null==t.upper||null==e.value||null==e.lower||null==e.upper)return{below:0,inside:0,above:0,observed:0};const o=t.value-t.lower,r=e.value-e.lower,i=t.value-t.upper,a=e.value-e.upper,s=[0,1];for(const[t,e]of[[o,r],[i,a]])(0>t&&e>0||t>0&&0>e)&&s.push(-t/(e-t));s.sort((t,e)=>t-e);let c=0,l=0,u=0;for(let o=0;s.length-1>o;o+=1){const r=s[o],i=s[o+1];if(r>=i)continue;const a=(r+i)/2,d=(i-r)*n,h=Ir(t.value+(e.value-t.value)*a,t.lower+(e.lower-t.lower)*a,t.upper+(e.upper-t.upper)*a);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function Nr(t,e,n={}){const o=n.interpolation??e.interpolation,r=n.outsideDomain??e.outsideDomain,i=Mr(t,n.traceId??"trace",n.timeAccessor,n.valueAccessor),a=n.lower??Ar(e,"lower"),s=n.upper??Ar(e,"upper"),c=e.points.map(t=>{const e=vr(i,t.time,o,r),n=Sr(t,a),c=Sr(t,s);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+t.time);return{time:t.time,value:e,lower:n,upper:c,status:null==e||null==n||null==c?"unobserved":Ir(e,n,c)}});let l=0,u=0,d=0,h=0,f=null,m=0,p=null;for(const t of c){if("below"===t.status?l+=1:"inside"===t.status?u+=1:"above"===t.status&&(d+=1),null==t.value||null==t.lower||null==t.upper)continue;const e=Math.max(0,t.value-t.upper),n=Math.max(0,t.lower-t.value);e>h&&(h=e,f=t.time),n>m&&(m=n,p=t.time)}let y=0,g=0,x=0,b=0;for(let t=0;c.length-1>t;t+=1){const e=c[t],n=c[t+1],r=Math.max(0,n.time-e.time);if(r>0){if("linear"===o){const t=zr(e,n);y+=t.below,g+=t.inside,x+=t.above,b+=t.observed;continue}"unobserved"!==e.status&&(b+=r,"below"===e.status?y+=r:"above"===e.status?x+=r:g+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:y,insideDuration:g,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function Cr(t){return{id:t,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function Tr(t){const e=Array.from(new Set(t.bodyIds??[]));return{stages:t.stages.map(t=>({...t})),bodyIds:e,entities:Object.fromEntries(e.map(t=>[t,Cr(t)]))}}function Er(t,e,n={}){if("region-enter"!==e.type)return t;const o=function(t,e){const n=e.stageId?.(t);if(n)return n;const o=t.region.metadata;if(o&&"object"==typeof o){const t=o.stageId;if("string"==typeof t)return t}return t.region.id}(e,n),r=t.stages.findIndex(t=>t.id===o);if(0>r)return t;const i=n.entityId?.(e)??e.bodyId;if(!i)return t;const a=t.entities[i]??Cr(i),s=a.currentStageId?t.stages.findIndex(t=>t.id===a.currentStageId):-1,c=!a.visitedStageIds.includes(o),l=Number(e.observation.timestamp),u=Number.isFinite(l)?l:0,d={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:c?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:(a.visitsByStage[o]??0)+1},firstEnteredAt:c?{...a.firstEnteredAt,[o]:u}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:u},regressionCount:s>=0&&s>r?a.regressionCount+1:a.regressionCount};return{...t,bodyIds:t.bodyIds.includes(i)?t.bodyIds:[...t.bodyIds,i],entities:{...t.entities,[i]:d}}}function Wr(t){const e=t.bodyIds.map(e=>t.entities[e]??Cr(e)),n=e.length;let o=n;return t.stages.map((t,r)=>{const i=e.filter(t=>t.furthestStageIndex>=r).length,a=e.filter(e=>e.visitedStageIds.includes(t.id)).length,s=e.reduce((e,n)=>e+(n.visitsByStage[t.id]??0),0),c={id:t.id,label:t.label??t.id,reached:i,entered:a,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:s,repeatVisits:Math.max(0,s-a)};return o=i,c})}function Lr(t,e){if("function"==typeof e){const n=e(t);return Number.isFinite(n)&&n>0?Number(n):1}const n=t.datum;if(e&&n&&"object"==typeof n){const t=Number(n[e]);if(Number.isFinite(t)&&t>0)return t}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function Fr(t,e){if("function"==typeof e){const n=e(t);if(null!=n&&(n+"").length>0)return n+""}else if(e){const n=Rr(t.datum,e),o=Rr(t,e),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return t.id}function jr(t,e){if(0===t.length)return 0;if(1===t.length)return t[0];const n=Math.max(0,Math.min(1,e))*(t.length-1),o=Math.floor(n);return t[o]+(t[Math.ceil(n)]-t[o])*(n-o)}function Rr(t,e){if(!e)return;let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}function Or(t,e){if(!e)return!0;if("function"==typeof e)return e(t);const n=Rr(t,e.property);return!("equals"in e&&!Object.is(n,e.equals)||"notEquals"in e&&Object.is(n,e.notEquals)||e.oneOf&&!e.oneOf.some(t=>Object.is(n,t))||e.notOneOf&&e.notOneOf.some(t=>Object.is(n,t)))}function Pr(t){const e=t.regionId,n=Math.max(0,t.unitsPerSecond),o=t.queueLayout??"lane",r=t.queueSlotSpacing??14,i=t.queueStiffness??.35,a=Number.isFinite(t.maxQueue)?Math.max(0,Math.floor(Number(t.maxQueue))):1/0,s=Math.max(.25,t.metricWindowSeconds??30),c=Math.max(1/60,t.snapshotIntervalSeconds??.25),l=t.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,m=new Map,p=new Map,y=new Map,g=[];let x=0,b=new Map,w=new Map,M=0,v=0,k=0,$=null,A=0,S=0,I=0,z=0,N=0,C=0,T=0,E=0,W=0,L=0,F=0,j=0,R=-1,O=!1;function P(t,n){const o=n(t);return!!o&&o.activeRegionIds.includes(e)}function q(){j+=1}function D(t){return{bodyId:t.bodyId,jobId:t.jobId,visitId:t.visitId,visit:t.visit,regionId:e,work:t.total,queuedAt:t.queuedAt}}function B(n,o,r,i){const a={bodyId:n.id,jobId:o.jobId,visitId:o.visitId,visit:o.visit,remaining:o.work,total:o.work,queuedAt:o.queuedAt,sequence:i};return u.set(o.jobId,a),y.delete(n.id),p.set(n.id,o.jobId),S+=1,I+=o.work,q(),function(n,o,r){const i=D(o);t.onQueued?.(n,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:e,work:o.total,jobId:o.jobId,visitId:o.visitId,visit:o.visit,queuedAt:o.queuedAt,queueDepth:u.size})}(n,a,r),a}function Y(t){if(u.size>=a||0===d.size)return;const e=Array.from(d.values()).sort((t,e)=>t.sequence-e.sequence);for(const n of e){if(u.size>=a)break;const e=m.get(n.jobId);e&&h.has(n.jobId)?(d.delete(n.jobId),y.delete(n.bodyId),B(e,n,t,n.sequence)):d.delete(n.jobId)}}function V(){let t=0;for(const e of u.values())t+=e.remaining;return t}function H(){W=Math.max(W,u.size),L=Math.max(L,V())}function X(){const t=k-s,e=Math.max(0,Math.min(s,k-($??k)));let o=0,r=0,i=0,a=0,c=0;for(const e of g){if(t>e.end)continue;o+=e.arrivals,r+=e.arrivalWork,i+=e.completions,a+=e.completedWork;const n=e.end-e.start;c+=n>0&&t>e.start?e.processedWork*Math.min(1,Math.max(0,e.end-t)/n):e.processedWork}const l=e>0?r/e:0;return{seconds:e,arrivals:o,arrivalWork:r,completions:i,completedWork:a,processedWork:c,arrivalsPerSecond:e>0?o/e:0,throughputPerSecond:e>0?i/e:0,utilization:e>0&&n>0?Math.max(0,Math.min(1,c/(n*e))):0,pressure:n>0?l/n:0}}return{id:t.id??"capacity-queue:"+e,continuous:!1!==t.continuous,tick:o=>{const r=o.controls.readBodies(),i=new Map,S=new Map;for(const e of r){if(i.set(e.id,e),!P(e.id,o.getRegionState))continue;if(!Or(e,t.bodyFilter))continue;const n=Fr(e,t.jobKey),r=S.get(n)??[];r.push(e),S.set(n,r)}const I=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!O){const t=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):I;k=Math.max(0,t-I),O=!0}const W=k,L=W+I;k=L,$=null==$?W:Math.min($,W);const j={start:W,end:L,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},V=new Map;for(const[t,e]of S){const n=h.get(t)?.bodyId,o=e.find(t=>t.id===n)??e[0];V.set(t,o),m.set(t,o)}for(const[n,r]of h){if(V.has(n))continue;const a=u.get(n),s=i.get(r.bodyId)??m.get(n);if(a){u.delete(n),p.delete(a.bodyId),T+=1,E+=a.remaining,q();const i={...D(a),abandonedAt:k,remainingWork:a.remaining,queueSeconds:Math.max(0,k-a.queuedAt)};s&&t.onAbandoned?.(s,i),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:s?.datum,x:s?.x,y:s?.y,regionId:e,work:a.total,remainingWork:a.remaining,jobId:n,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:k,queueSeconds:i.queueSeconds,queueDepth:u.size})}d.delete(n),y.delete(r.bodyId),h.delete(n),m.delete(n)}for(const[n,r]of V){if(h.has(n))continue;const i=(f.get(n)??0)+1;f.set(n,i);const s=Lr(r,t.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${e}:${n}:${i}`,visit:i,regionId:e,work:s,queuedAt:k};h.set(n,c),A+=1,j.arrivals+=1,j.arrivalWork+=s;const l=x++;if(a>u.size)B(r,c,o,l);else{const a={...c,blockedAt:k,sequence:l};d.set(n,a),y.set(r.id,n),C+=1,q(),t.onBlocked?.(r,a),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:e,work:s,jobId:n,visitId:c.visitId,visit:i,queuedAt:k,blockedAt:k,queueDepth:u.size,blockedDepth:d.size})}}Y(o),H();const X=Array.from(u.values()).sort((t,e)=>t.sequence-e.sequence);let _=n*I;for(const n of X){if(0>=_)break;const r=Math.min(n.remaining,_);if(n.remaining-=r,_-=r,z+=r,j.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),p.delete(n.bodyId),v+=1,N+=n.total,j.completions+=1,j.completedWork+=n.total;const a=Math.max(0,k-n.queuedAt);F+=a,q();const s=i.get(n.bodyId);if(!s)continue;o.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...D(n),completedAt:k,queueSeconds:a};t.onProcessed?.(s,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:s.datum,x:s.x,y:s.y,regionId:e,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:k,queueSeconds:a,queueDepth:u.size})}Y(o),H(),function(){const t=Array.from(u.values()).sort((t,e)=>t.sequence-e.sequence);b=new Map(t.map((t,e)=>[t.bodyId,e]));const e=Array.from(d.values()).sort((t,e)=>t.sequence-e.sequence);w=new Map(e.map((t,e)=>[t.bodyId,e])),M=t.length}(),function(t){(t.end>t.start||t.arrivals>0||t.completions>0||t.processedWork>0)&&g.push(t);const e=k-s;for(;g.length>0&&e>g[0].end;)g.shift()}(j);const G=Math.floor(k/c);G!==R&&(R=G,q())},getSnapshot:()=>{const t=V(),o=function(){let t=0;for(const e of d.values())t+=e.work;return t}(),r=u.size,i=Array.from(u.values()).map(t=>Math.max(0,k-t.queuedAt)).sort((t,e)=>t-e),a=i.reduce((t,e)=>t+e,0);return{regionId:e,queueDepth:r,processedCount:v,unitsPerSecond:n,remainingWork:t,meanRemainingWork:r>0?t/r:0,waitingWork:t+o,blockedDepth:d.size,blockedWork:o,arrivalCount:A,admittedCount:S,admittedWork:I,processedWork:z,completedWork:N,blockedCount:C,abandonedCount:T,abandonedWork:E,peakQueueDepth:W,peakRemainingWork:L,queueAge:{count:i.length,meanSeconds:i.length>0?a/i.length:0,p50Seconds:jr(i,.5),p95Seconds:jr(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:v>0?F/v:0,window:X(),simulatedAt:k,metricRevision:j}},bodyForce:t=>{if("none"===o)return null;const n=p.get(t.body.id),a=y.get(t.body.id),s=n?u.get(n):void 0,c=a?d.get(a):void 0;if(!s&&!c)return null;const l=s?b.get(t.body.id):w.get(t.body.id);if(null==l)return null;let h;const f=t.regions;if(f)for(let t=0;f.length>t;t+=1)if(f[t].id===e){const e=f[t].shape;e&&"aabb"===e.type&&(h=e);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-t.body.x)*i,y:(h.y-(l-((c?d.size:M)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:M))-t.body.y)*i*.85}:{x:8*-Math.sign(t.body.vx||1),y:0}}}}function qr(t,e){if(!e)return;let n=t;for(const t of e.split(".")){if(null==n||"object"!=typeof n)return;n=n[t]}return n}function Dr(t,e){if(!e)return!0;if("function"==typeof e)return e(t);const n=qr(t,e.property);return!("equals"in e&&!Object.is(n,e.equals)||"notEquals"in e&&Object.is(n,e.notEquals)||e.oneOf&&!e.oneOf.some(t=>Object.is(n,t))||e.notOneOf&&e.notOneOf.some(t=>Object.is(n,t)))}function Br(t){const e=t.resources.map(t=>({...t,bodyId:t.bodyId??t.id})),n=new Map(e.map(t=>[t.bodyId,t])),o=new Map,r=new Map,i=t.assignmentForce??.45,a=t.returnForce??.35,s=t.caseAttraction??.08,c=t.assignmentOffset??{x:0,y:0};let l=new Map,u=0,d=0;return{id:t.id??"service-resource-pool",continuous:!0,assign:t=>{const n=o.get(t);if(n)return n;const i=e.find(t=>!r.has(t.id));if(!i)return null;const a={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:t,assignedAt:u};return o.set(t,a),r.set(i.id,a),d+=1,a},release:t=>{const e=o.get(t);return!!e&&(o.delete(t),r.delete(e.resourceId),d+=1,!0)},getAssignment:t=>o.get(t),tick:t=>{u=Math.max(u,t.elapsed),l=new Map(t.controls.readBodies().map(t=>[t.id,t]));for(const[t,e]of o)l.has(t)&&l.has(e.resourceBodyId)||(o.delete(t),r.delete(e.resourceId),d+=1)},getSnapshot:()=>({total:e.length,available:e.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:t=>{const e=n.get(t.body.id);if(e){const n=r.get(e.id),o=n?l.get(n.caseBodyId):void 0,s=n?i:a;return{x:((o?o.x+(c.x??0):e.home.x)-t.body.x)*s,y:((o?o.y+(c.y??0):e.home.y)-t.body.y)*s}}const u=o.get(t.body.id);if(!u||0>=s)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-t.body.x)*s,y:(d.y-t.body.y)*s}:null}}}function Yr(t,e){const n="function"==typeof e.deadlineAccessor?e.deadlineAccessor(t):qr(t.datum,e.deadlineAccessor)??qr(t,e.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function Vr(t){const e=new Map;let n=0,o=0;function r(n){e.set(n.bodyId,n),o+=1,t.onStateChange?.({...n})}function i(t){const o=e.get(t);return!(!o||null!=o.completedAt||(r({...o,completedAt:n,state:"unhappy"===o.state?"resolved-unhappy":"resolved"}),0))}return{id:t.id??"service-level",continuous:!0,protect:t=>{const o=e.get(t);return!(!o||null!=o.completedAt||"unhappy"===o.state||(r({...o,state:"protected",protectedAt:n}),0))},complete:i,getCase:t=>e.get(t),tick:o=>{n=Math.max(n,o.elapsed);for(const a of o.controls.readBodies()){if(!Dr(a,t.bodyFilter))continue;if(!e.has(a.id)){const e=Yr(a,t);r({bodyId:a.id,openedAt:n,deadlineAt:n+e,state:"waiting"})}const s=e.get(a.id);s&&null==s.completedAt&&(t.completionRegionId&&o.getRegionState(a.id)?.activeRegionIds.includes(t.completionRegionId)?i(a.id):"waiting"!==s.state||s.deadlineAt>n||r({...s,state:"unhappy"}))}},getSnapshot:()=>{const t=Array.from(e.values()),r=e=>t.filter(t=>t.state===e).length;return{total:t.length,waiting:r("waiting"),protected:r("protected"),unhappy:r("unhappy"),resolved:r("resolved"),resolvedUnhappy:r("resolved-unhappy"),simulatedAt:n,metricRevision:o}}}}function Hr(t){const e=new Set;let n=0,o=0,r=0,i=!1;return{id:t.id??"dependency-gate:"+t.regionId,continuous:!0,tick:a=>{n=Math.max(n,a.elapsed);const s=i;var c;c=n,i=t.isOpen?t.isOpen(c):null!=t.opensAt&&c>=t.opensAt;const l=a.controls.readBodies(),u=new Map(l.map(t=>[t.id,t]));for(const n of l){const o=a.getRegionState(n.id)?.activeRegionIds.includes(t.regionId);o&&Dr(n,t.bodyFilter)&&(i||e.has(n.id)||(e.add(n.id),r+=1,t.onHeld?.(n)))}if(i&&!s){for(const n of e){const e=u.get(n);e&&(a.controls.applyImpulse(n,t.releaseImpulse?.x??86,t.releaseImpulse?.y??0),o+=1,t.onReleased?.(e))}e.clear(),r+=1}for(const t of e)u.has(t)||(e.delete(t),r+=1)},getSnapshot:()=>({regionId:t.regionId,isOpen:i,blocked:e.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!e.has(n.body.id))return null;const o=n.regions?.find(e=>e.id===t.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const a=t.holdForce??.4;return{x:(r.x-n.body.x)*a-.45*n.body.vx,y:(r.y-n.body.y)*a-.45*n.body.vy}}}}function Xr(t,e){return t||e?{x:(t?.x??0)+(e?.x??0),y:(t?.y??0)+(e?.y??0)}:null}function _r(t){if(!t?.length)return null;const e=t.slice(),n=e.some(t=>!1!==t.continuous);return{controllers:e,continuous:n,onTick:(t,n,o)=>{const r={result:t,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const t of e)t.tick(r)},bodyForce:t=>{let n=null;for(const o of e)o.bodyForce&&(n=Xr(n,o.bodyForce(t)));return n}}}function Gr(t){const e=new Set,n=t.impulse??{x:-60,y:0};return{id:t.id??"portal:"+t.fromRegionId,continuous:!0===t.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),a=r?.activeRegionIds.includes(t.fromRegionId);a?e.has(i.id)||(e.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),t.onPortal?.(i)):e.delete(i.id)}}}}import{Fragment as Ur,jsx as Kr,jsxs as Qr}from"react/jsx-runtime";var Zr={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}};function Jr(t,e,n){return Math.max(e,Math.min(n,t))}function ti(t){return 6.2*t.length}function ei(t,e){const n=t.trim();if(e>=n.length)return n;if(1>=e)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(t=>t[0]).join("").toUpperCase();return o.length>1&&e>=o.length?o:e>3?n.slice(0,Math.max(1,e-2))+"..":n.slice(0,e).toUpperCase()}function ni(t,e,n="auto"){const o=Math.max(1,Math.floor(e/6.2)),r="compact"===n?ei(t,o):"full"===n?t:ti(t)>e?ei(t,o):t;return{text:r,textLength:ti(r)>e?Math.max(4,e):void 0}}function oi(t,e={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:c="process-flow-chrome"}=e,{width:l,height:u,left:d,right:h,topY:f,bottomY:m,midY:p,stages:y,groups:g=[]}=t,x=m-f;return Qr("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":s?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[Kr("defs",{children:Qr("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[Kr("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),Kr("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),Kr("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),Kr("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?Kr("line",{x1:d+8,x2:h-8,y1:p,y2:p,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,y.map((t,e)=>{const n=function(t){return t.absorb?"absorb":t.portalTarget?"portal":null!=t.capacity?"capacity":"flow"}(t),i=Zr[n],c=Math.max(12,t.width-8),l=Jr(c-8,22,88),d=ni(t.label,Math.max(8,l-10),a),h="none"!==a&&c-8>=22,g=function(t){if(null!=t.capacity){const e=null!=t.queueDepth?" · q "+t.queueDepth:"";return t.capacityLabel?`${t.capacityLabel}${e}`:`cap ${Number.isInteger(t.capacity)?t.capacity+"":t.capacity.toFixed(1)}${e}`}return t.absorb?"absorb":t.portalTarget?"portal":"flow"}(t),b=ni(g,Math.max(16,c-10),"auto"),w=r&&!1!==t.showBadge&&c>=32,M=null!=t.count?`n=${t.count}${null!=t.processed?" done "+t.processed:""}`:"",v=ni(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return Qr("g",{"data-stage":t.id,"data-role":n,children:[Kr("rect",{className:"semiotic-process-chrome__stage-bay",x:t.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===n?1:1.6}),y.length-1>e?Kr("polygon",{points:`${t.x1-2},${p-7} ${t.x1+8},${p} ${t.x1-2},${p+7}`,fill:i.accent,opacity:.85}):null,h?Qr(Ur,{children:[Kr("rect",{className:"semiotic-process-chrome__stage-label-bg",x:t.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),Qr("text",{x:t.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[Kr("title",{children:t.label}),d.text]})]}):null,w?Qr("text",{x:t.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[Kr("title",{children:g}),b.text]}):null,o&&null!=t.count?Qr("text",{x:t.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[Kr("title",{children:M}),v.text]}):null]},t.id)}),i?g.map((t,e)=>{const n=t.total??0,o=t.absorbed??0,r=t.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,a=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(e+1),l=Jr(Math.max(54,ti(t.label)+18,ti(c)+16),54,104),u=ni(t.label,l-12,"auto"),d=ni(c,l-12,"auto");return Qr("g",{"data-group":t.id,children:[Kr("rect",{x:t.x-l/2,y:t.y-22,width:l,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),Qr("text",{x:t.x,y:t.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[Kr("title",{children:t.label}),u.text]}),Qr("text",{x:t.x,y:t.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[Kr("title",{children:c}),d.text]})]},t.id)}):null]})}function ri(t){const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function ii(t,e,n,o){const r="function"==typeof t?t(e,n):t;return Number.isFinite(r)?Number(r):o}function ai(t,e,n){return ri(t[e])??n}function si(t,e){return"number"==typeof t?t:t?.[e]??0}function ci(t){const{band:e,idPrefix:n,plot:o,projection:r}=t,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:s=4}=e,c=function(t){const e=t.bandwidth??t.scale.bandwidth?.()??0,n=new Set;for(const o of t.values){const r=t.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+e))}return Array.from(n).sort((t,e)=>t-e)}(e);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let t=i?0:1;l>=t;t+=1){if(!a&&t>0&&c.length-1>t)continue;const e=c[t];u.push({id:`${n}-wall-${t}`,shape:"x"===r?{type:"aabb",x:e,y:o.y+o.height/2,width:s,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:e,width:o.width,height:s}})}return u}function li(t){const{plot:e,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:a}=t,s=[];if(!1!==o&&s.push(...function(t,e={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:c=s}=e,l=[],u=t.x+t.width/2,d=t.y+t.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*s,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*s,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:t.x-s/2,y:d,width:s,height:t.height+2*c}}),a&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:t.x+t.width+s/2,y:d,width:s,height:t.height+2*c}}),l}(e,{idPrefix:n,...o})),r){const{idPrefix:t,yTop:o,yBottom:i,...a}=r;s.push(...function(t){const{idPrefix:e="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:a,yBottom:s,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:f=Math.max(2,c)}=t,m=[],p=a+(s-a)/2,y=Math.abs(s-a),g=l?n:n-1;if(u||l)for(let t=l?0:1;g>=t;t+=1){if(!u&&t>0&&n>t)continue;const a=i(o+t*r);m.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:a,y:p,width:c,height:y}})}if(null!=d)for(let t=0;n>t;t+=1){const n=o+t*r,a=n+r;if(a>=d)continue;const s=i(n),l=i(a);m.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(s,l)+c/2,y1:h,x2:Math.max(s,l)-c/2,y2:h,thickness:f}})}return m}({...a,idPrefix:t??n+"-xbin",yTop:o??e.y,yBottom:i??e.y+e.height}))}return i&&s.push(...ci({band:i,idPrefix:i.idPrefix??n+"-xband",plot:e,projection:"x"})),a&&s.push(...ci({band:a,idPrefix:a.idPrefix??n+"-yband",plot:e,projection:"y"})),s}function ui(t){const{plot:e,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:a=e.y+.18*e.height,yEnd:s=e.y+.58*e.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=t,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(s-a)/(d-1):0,m=e.width/h,p=[];for(let t=0;d>t;t+=1){const n=c&&t%2==1?m/2:0;for(let o=0;h>o;o+=1){const s=e.x+m*(o+.5)+n;e.x+r>s||s>e.x+e.width-r||p.push({id:`${i}-${t}-${o}`,shape:{type:"aabb",x:s,y:a+t*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function di(t,e={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:a,vy:s,spawnAt:c,seed:l=1,jitter:u,datum:d}=e,h=T(l),f=si(u,"x"),m=si(u,"y");return t.map((t,l)=>{const u=ii(e.x,t,l,ai(t,"x",0)),p=ii(e.y,t,l,ai(t,"y",0)),y=ii(o,t,l,5),g="function"==typeof r?r(t,l):r??{type:"circle",radius:y};return{id:`${n}-${t.index??l}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:ii(a,t,l,0),vy:ii(s,t,l,0),mass:ii(i,t,l,1),spawnAt:ii(c,t,l,void 0),shape:g,datum:d?d(t,l):t.datum??t}}).map(t=>{if(Number.isFinite(t.spawnAt))return t;const{spawnAt:e,...n}=t;return n})}function hi(t,e={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:a=.2,...s}=e,c=function(t,e={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:a="count",x:s}=e,c=Math.max(1,...t.map(t=>t[a]));return t.map((t,e)=>{const l=Math.max(0,t[a]/c*i),u=s?.(t,e)??e*(o+r);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:n-l,width:o,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(t,s),l=o?c.filter(t=>t.height>0).map(t=>({id:`${n}-${t.binId}`,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+r/2,width:t.width,height:r},restitution:i,friction:a})):[];return{columns:c,colliders:l}}function fi(t,e={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:a=!0}=e,s=t.map((t,e)=>({spawn:t,time:function(t,e,n){return ri("function"==typeof n?n(t,e):t[n]??t.datum?.[n])}(t,e,n)??t.spawnAt??e})),c=s.length?Math.min(...s.map(t=>t.time)):0;return{initialSpawns:s.map(({spawn:t,time:e})=>({...t,spawnAt:r+(i?e-c:e)})).sort((t,e)=>a?(t.spawnAt??0)-(e.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function mi(t,e,n="group"){const o=Fo(t,e),r=t=>"function"==typeof n?n(t):t[n]??0;return t.slice().sort((t,e)=>{const n=r(t),i=r(e);return i>n?-1:n>i?1:(o[e.id]||0)-(o[t.id]||0)}).map(t=>t.id)}function pi(t,e={}){const n=e.baseline??.62,o=e.inset??.06,r={},i=t.length;return t.forEach((t,e)=>{r[t]={x:i>1?o+e/(i-1)*(1-2*o):.5,y:n}}),r}function yi(t,e,n=.55){return`M${t.x},${t.y} Q${(t.x+e.x)/2},${t.y-Math.abs(e.x-t.x)*n} ${e.x},${e.y}`}function gi(t,e={}){const n=e.radius??.42,o=e.center?.x??.5,r=e.center?.y??.5,i=e.startAngle??0,a={},s=t.length;return t.forEach((t,e)=>{const c=i+e/s*Math.PI*2-Math.PI/2;a[t]={x:o+Math.cos(c)*n,y:r+Math.sin(c)*n}}),a}function xi(t,e,n={}){const o=(n.order??mi(t,e,n.groupAccessor??"group")).slice(),r=new Map(o.map((t,e)=>[t,e])),i=new Map;for(const t of e){if(!r.has(t.source)||!r.has(t.target)||t.source===t.target)continue;const e=t.target>t.source?`${t.source}\0${t.target}`:`${t.target}\0${t.source}`;i.set(e,(i.get(e)||0)+(t.value??1))}const a=[];let s=0;for(const[t,e]of i){const[n,o]=t.split("\0"),i=r.get(n),c=r.get(o);e>s&&(s=e),a.push({row:i,col:c,source:n,target:o,value:e}),a.push({row:c,col:i,source:o,target:n,value:e})}return{order:o,cells:a,size:o.length,maxValue:s}}function bi(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function wi(t){if("string"!=typeof t)return;const e=t.trim();return e.length?e:void 0}function Mi(t,e){const n=bi(t.note)?t.note:void 0;return e?wi(t.mobileText)||wi(t.shortText)||wi(t.label)||wi(n?.mobileText)||wi(n?.shortText)||wi(n?.label)||wi(n?.title):wi(t.label)||wi(t.mobileText)||wi(t.shortText)||wi(n?.label)||wi(n?.title)}function vi(t,e,n){const o=function(t,e,n){if(!n)return;const o="function"==typeof n?n(t,e):t[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(t,e,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-e;const i=((t.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===t.priority&&(r+=5e3),"low"===t.priority&&(r-=1500),"number"==typeof t.priority&&(r+=100*t.priority);const a=bi(t.provenance)?t.provenance:void 0;"number"==typeof a?.confidence&&(r+=100*a.confidence);const s=bi(t.lifecycle)?t.lifecycle:void 0,c=((s?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function ki(t,e){if(!e)return t;const n=Mi(t,!0);return n&&"string"==typeof t.label?{...t,label:n}:t}function $i(t,e={}){const n=Array.isArray(t)?t.filter(bi):[],o=e.active??(null==e.width||(e.breakpoint??480)>=e.width),r=e.strategy??"hybrid",i=!1!==e.preferShortText,a=!1!==e.preservePrimary,s=Math.max(0,e.maxPlotAnnotations??e.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,e.minPlotAnnotations??e.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(t=>ki(t,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((t,n)=>({annotation:t,index:n,priority:vi(t,n,e)})).filter(t=>!!en(t.annotation)||(l.push(t.annotation),!1)).sort((t,e)=>e.priority-t.priority),d=a?u.filter(t=>"primary"===((t.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(t=>t.index)),f=u.filter(t=>!h.has(t.index)),m=[...d,...f].slice(0,Math.max(s,c)),p=new Set(m.map(t=>t.index)),y=u.filter(t=>!p.has(t.index)),g=[...l,...m.sort((t,e)=>t.index-e.index).map(t=>ki(t.annotation,i))],x=y.sort((t,e)=>t.index-e.index).map(t=>t.annotation),b=Math.max(0,e.maxCalloutItems??6),w=y.filter(t=>!e.calloutFilter||e.calloutFilter(t.annotation,t.index)).map(t=>function(t,e,n,o){const r=Mi(t,o);if(!r)return null;const i=wi(t.id)||wi(t.key)||wi(t.pointId)||"annotation-"+(e+1),a=bi(t.provenance)?wi(t.provenance.source)||wi(t.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:wi(t.shortText),pointId:t.pointId,emphasis:"string"==typeof t.emphasis?t.emphasis:void 0,source:a,priority:n,annotation:t}}(t.annotation,t.index,t.priority,i)).filter(t=>!!t).slice(0,b),M=new Set(w.map(t=>t.annotation)),v=x.filter(t=>!M.has(t));return{active:o,strategy:r,budget:s,visible:g,deferred:x,calloutList:w,hidden:v}}function Ai(t){return"dense"===t.density?.75:"compact"===t.density?.9:1}function Si(t,e){const n=!1!==e.keepAxes,o=!1===e.directLabel?12:28;return"ordinal"===t?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===t||"network"===t?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function Ii(t,e,n,o={}){const r={...n},i={mode:!1===e.mode?void 0:"mobile",...r,margin:Si(t,e),...o},a=Object.fromEntries(Object.entries(r).filter(([,t])=>void 0!==t)),s=Object.fromEntries(Object.entries(i).filter(([,t])=>void 0!==t)),c=function(t,e){const n=e.targetSize??44,o=[],r=e.standardControls,i=t=>!0===r||"all"===r||r===t||Array.isArray(r)&&r.includes(t);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${t}-${e.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,e.breakpoint??480,768],maxAnnotations:e.maxAnnotations??2,minimumHitTarget:n,summary:e.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===e.directLabel?"compact":"direct",minFontSize:12}}}(t,e),l=function(t){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:t.targetSize??44,snap:t.snap??"nearestDatum",brushHandleSize:t.targetSize??44,standardControls:t.standardControls??!1}}(e);return{family:t,props:a,responsiveRules:[{id:t+"-mobile",description:`Apply Semiotic's mobile ${t} recipe at phone width.`,when:{maxWidth:e.breakpoint??480},transform:{...s,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function zi(t={}){const e=Ai(t);return Ii("line",t,{showLegend:t.showLegend??!1,directLabel:t.directLabel??!0,lineWidth:"inspect"===t.transformProfile?3:Math.max(1.5,2.5*e),showPoints:"inspect"===t.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:t.maxAnnotations??2,maxCalloutItems:t.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function Ni(t={}){const e=Ai(t);return Ii("area",t,{showLegend:t.showLegend??!1,showPoints:!1,areaOpacity:"compare"===t.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*e),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:t.maxAnnotations??2,maxCalloutItems:t.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function Ci(t={}){return Ii("ordinal",t,{showLegend:t.showLegend??!1,showCategoryTicks:t.keepAxes??!0,sort:"compare"===t.transformProfile?"desc":void 0},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function Ti(t={}){const e=Ai(t);return Ii("scatter",t,{showLegend:t.showLegend??!1,pointRadius:Math.max(4,Math.round((t.targetSize??44)/8*e)),hoverRadius:Math.ceil((t.targetSize??44)/2),pointOpacity:"dense"===t.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:t.maxAnnotations??1,maxCalloutItems:t.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:t.keepAxes??!0,axisExtent:"exact"})}function Ei(t={}){const e=Ai(t);return Ii("network",t,{showLegend:t.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*e)),Math.max(12,Math.round((t.targetSize??44)/2*e))],showLabels:"inspect"===t.transformProfile,edgeOpacity:"dense"===t.density?.28:.44})}function Wi(t={}){return Ii("geo",t,{showLegend:t.showLegend??!1})}function Li(t={}){return Ii("small-multiple",t,{mobileColumns:t.mobileColumns??1,tabletColumns:t.tabletColumns??2,chartHeight:t.chartHeight??180,sharedExtent:!0})}function Fi(t,e={}){switch(t){case"line":return zi(e);case"area":return Ni(e);case"ordinal":return Ci(e);case"scatter":return Ti(e);case"network":return Ei(e);case"geo":return Wi(e);case"small-multiple":return Li(e)}}function ji(t={}){const e=t.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:t.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:e,summary:t.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:e}}import*as Ri from"react";import{Fragment as Oi,jsx as Pi,jsxs as qi}from"react/jsx-runtime";function Di({def:t,color:e,accent:n,paintOverride:o}){return Pi(Oi,{children:t.parts.map((t,r)=>{const i=o?"none"===t.fill?void 0:o:xo(t.fill,e,n),a=o?t.stroke&&"none"!==t.stroke?o:void 0:xo(t.stroke??"none",e,n);return i||a?Pi("path",{d:t.d,fill:i??"none",stroke:a,strokeWidth:a?t.strokeWidth??1:void 0,strokeLinecap:t.strokeLinecap,strokeLinejoin:t.strokeLinejoin,opacity:t.opacity},r):null})})}function Bi({def:t,size:e=24,color:n="currentColor",accent:o="#ffffff",fraction:r=1,fractionStart:i=0,fractionDirection:a="horizontal",ghostColor:s,x:c=0,y:l=0,opacity:u,className:d}){const h=Ri.useId();if(!t?.parts?.length)return null;const[,f]=t.viewBox??mo,m=e/(f>0?f:1);if(0>=m)return null;const p=bo(t,r,i,a),y=p?"glyph-clip"+h.replace(/[^A-Za-z0-9_-]/g,"_"):void 0;return qi("g",{className:d,transform:`translate(${c} ${l}) scale(${m})`,opacity:u,"aria-hidden":"true",children:[p&&y&&Pi("clipPath",{id:y,children:Pi("rect",{x:p.x,y:p.y,width:p.width,height:p.height})}),p&&s?Pi(Di,{def:t,color:n,accent:o,paintOverride:s}):null,p&&y?Pi("g",{clipPath:`url(#${y})`,children:Pi(Di,{def:t,color:n,accent:o})}):Pi(Di,{def:t,color:n,accent:o})]})}export{nn as DEFAULT_AREA_PER_ANNOTATION,po as DEFAULT_GLYPH_ANCHOR,mo as DEFAULT_GLYPH_VIEWBOX,Bn as DEFAULT_HIT_RADIUS,Rt as DEFAULT_ISOMETRIC_SPRITE_SIZES,Bi as Glyph,l as LayoutCache,J as SYMBOL_SEQUENCE,eo as TAU,hr as absorbRegion,Sn as activeCountOverDomain,co as addPoints,xi as adjacencyMatrix,Uo as aggregateRegionCounts,b as allocateCells,ro as angleScale,rn as annotationBudget,sn as annotationDensity,vn as annotationLayout,pi as arcLayout,yi as arcPath,fi as arrivalReplay,qn as axisFixedForceLayout,Pn as axisFixedForcePositions,ge as bandLabel,Po as betweenness,jo as bfsDistances,Ue as bobaLayout,mr as bodyGroupSpec,ye as boundsOf,Tn as boxEdgeAnchors,Lo as buildAdjacency,No as buildTooltipEntries,We as bulletLayout,It as calendarLayout,ur as capacitatedRegion,sr as chargeGateRegion,gi as circularLayout,m as clamp,qo as closeness,Do as clustering,li as collidersFromScales,Nr as comparePhysicsTrace,_r as composePhysicsControllers,Pr as createCapacityQueueController,Hr as createDependencyGateController,Gr as createPortalController,Tr as createProcessJourneyLedger,Vr as createServiceLevelController,Br as createServiceResourcePoolController,Fn as cubicPath,Wn as cubicPoint,Ln as cubicTangent,Nn as curvedEdgePath,Jn as cyclicRangeContains,te as dagreLayout,Fo as degree,q as diagnoseTokenEncoding,s as dimFor,Oo as egoNetwork,zo as extractTooltipDatum,En as fanOutBend,Jt as flextreeLayout,fr as forceFieldRegion,E as forceLayout,Go as forceLayoutAsync,Co as formatTooltipValue,ui as galtonPegs,O as generateTokens,Xn as geoAreaHitTarget,Hn as geoHitTarget,go as glyphExtent,bo as glyphFractionClipRect,yo as glyphPlacement,r as groupBy,Qo as groupCompletionRows,xe as hatchFill,Vn as hitTargetPoint,_n as hitTargetRect,zn as intervalLanesLayout,_t as isometricLandmarkLayout,lt as isotypeBoltGlyph,ut as isotypeBusGlyph,ct as isotypeChipGlyph,at as isotypeGhost,rt as isotypeInk,ft as isotypeNetworkGlyphs,it as isotypePaper,ht as isotypePersonGlyph,dt as isotypePersonPath,st as isotypeServerGlyph,P as layoutTokenGrid,$o as legendGroupsFrom,Ao as legendSwatches,ae as lineageDagLayout,be as linearAxis,u as makeShade,Ce as marimekkoLayout,we as markCallout,a as matchesHighlight,y as mean,ar as membraneRegion,he as mermaidDagLayout,$i as mobileAnnotationStrategy,Ni as mobileAreaChartRecipe,ji as mobileBrushAlternatives,Fi as mobileChartFamilyRecipe,Wi as mobileGeoChartRecipe,zi as mobileLineChartRecipe,Ei as mobileNetworkChartRecipe,Ci as mobileOrdinalChartRecipe,Ti as mobileScatterplotRecipe,Li as mobileSmallMultipleRecipe,T as mulberry32,Gn as networkHitTarget,p as nonNegativeFinite,fo as normalizePoint,Bo as normalizeScores,F as normalizeTokenEncoding,mi as orderByGroupDegree,Cn as orthogonalEdgePath,An as packIntervals,Se as packedClusterMatrix,je as parallelCoordinatesLayout,$r as physicsReferenceEnvelope,ho as pointMagnitude,no as polarToXY,dr as portalRegion,lr as pressureFieldRegion,oi as processChrome,Wr as processJourneyRows,pr as processLaneWalls,or as processStageLayout,ir as processStageRegions,tr as processVolumePolygons,Yo as proximityProblem,io as radiusScale,n as readField,jn as rectCollide,Ko as regionCountsToProjectionRows,ao as ringArcPath,pe as roundedEnclosure,cr as routeSurfaceRegion,Kn as runLengthEncode,Un as runs,uo as scalePoint,hi as sedimentBake,to as selectCyclicRange,Xt as selectIsometricLandmarks,d as shade,Zn as shortestArcDelta,Ro as shortestPath,c as signatureKey,di as spawnFromTokens,Jo as stageTargetInVolume,lo as subtractPoints,Y as suggestTokenEncoding,ot as symbolExtent,tt as symbolPathString,et as symbolRadius,$t as tokenLayer,B as tokenTaskIntentToCapabilityIntents,v as unitize,k as unitizeRange,o as unwrapDatum,Er as updateProcessJourney,Lt as useCustomLayoutSelection,x as waffleLayout,g as withAlpha,Qn as wrapValue,oo as xyToAngle};
1
+ import{DEFAULT_HIT_RADIUS as o,DEFAULT_ISOMETRIC_SPRITE_SIZES as n,TAU as r,activeCountOverDomain as t,addPoints as i,adjacencyMatrix as e,allocateCells as c,angleScale as m,arcLayout as u,arcPath as l,arrivalReplay as h,axisFixedForceLayout as a,axisFixedForcePositions as s,bandLabel as d,betweenness as f,bfsDistances as k,bobaLayout as p,boundsOf as j,boxEdgeAnchors as g,buildAdjacency as y,buildTooltipEntries as v,bulletLayout as x,calendarLayout as O,circularLayout as P,closeness as S,clustering as C,collidersFromScales as D,comparePhysicsTrace as N,createProcessJourneyLedger as H,cubicPath as I,cubicPoint as L,cubicTangent as Q,curvedEdgePath as R,cyclicRangeContains as V,dagreLayout as W,degree as X,egoNetwork as Y,extractTooltipDatum as $,fanOutBend as w,flextreeLayout as z,forceLayoutAsync as A,formatTooltipValue as B,galtonPegs as J,geoAreaHitTarget as T,geoHitTarget as U,hatchFill as M,hitTargetPoint as Z,hitTargetRect as _,intervalLanesLayout as E,isometricLandmarkLayout as G,isotypeBoltGlyph as b,isotypeBusGlyph as q,isotypeChipGlyph as F,isotypeGhost as K,isotypeInk as oo,isotypeNetworkGlyphs as no,isotypePaper as ro,isotypePersonGlyph as to,isotypePersonPath as io,isotypeServerGlyph as eo,legendGroupsFrom as co,legendSwatches as mo,lineageDagLayout as uo,linearAxis as lo,marimekkoLayout as ho,markCallout as ao,mermaidDagLayout as so,mobileAnnotationStrategy as fo,mobileAreaChartRecipe as ko,mobileBrushAlternatives as po,mobileChartFamilyRecipe as jo,mobileGeoChartRecipe as go,mobileLineChartRecipe as yo,mobileNetworkChartRecipe as vo,mobileOrdinalChartRecipe as xo,mobileScatterplotRecipe as Oo,mobileSmallMultipleRecipe as Po,networkHitTarget as So,normalizePoint as Co,normalizeScores as Do,orderByGroupDegree as No,orthogonalEdgePath as Ho,packIntervals as Io,packedClusterMatrix as Lo,parallelCoordinatesLayout as Qo,physicsReferenceEnvelope as Ro,pointMagnitude as Vo,polarToXY as Wo,processChrome as Xo,processJourneyRows as Yo,proximityProblem as $o,radiusScale as wo,rectCollide as zo,ringArcPath as Ao,roundedEnclosure as Bo,runLengthEncode as Jo,runs as To,scalePoint as Uo,sedimentBake as Mo,selectCyclicRange as Zo,selectIsometricLandmarks as _o,shortestArcDelta as Eo,shortestPath as Go,spawnFromTokens as bo,subtractPoints as qo,tokenLayer as Fo,updateProcessJourney as Ko,waffleLayout as on,wrapValue as nn,xyToAngle as rn}from"./chunk-chunk-27HVVXS6.module.min.js";import{composePhysicsControllers as tn,createCapacityQueueController as en,createDependencyGateController as cn,createPortalController as mn,createServiceLevelController as un,createServiceResourcePoolController as ln}from"./chunk-chunk-GMQ5AYTD.module.min.js";import{LayoutCache as hn,clamp as an,diagnoseTokenEncoding as sn,dimFor as dn,forceLayout as fn,generateTokens as kn,groupBy as pn,layoutTokenGrid as jn,makeShade as gn,matchesHighlight as yn,mean as vn,nonNegativeFinite as xn,normalizeTokenEncoding as On,readField as Pn,shade as Sn,signatureKey as Cn,suggestTokenEncoding as Dn,tokenTaskIntentToCapabilityIntents as Nn,unitize as Hn,unitizeRange as In,unwrapDatum as Ln,withAlpha as Qn}from"./chunk-chunk-2CXCXRB4.module.min.js";import{useCustomLayoutSelection as Rn}from"./chunk-chunk-RH5TSQPH.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import{absorbRegion as Vn,aggregateRegionCounts as Wn,bodyGroupSpec as Xn,capacitatedRegion as Yn,chargeGateRegion as $n,forceFieldRegion as wn,groupCompletionRows as zn,membraneRegion as An,portalRegion as Bn,pressureFieldRegion as Jn,processLaneWalls as Tn,processStageLayout as Un,processStageRegions as Mn,processVolumePolygons as Zn,regionCountsToProjectionRows as _n,routeSurfaceRegion as En,stageTargetInVolume as Gn}from"./chunk-chunk-DNY43POY.module.min.js";import{mulberry32 as bn}from"./chunk-chunk-SIRIJ3DY.module.min.js";import"./chunk-chunk-H4PPRW6N.module.min.js";import{DEFAULT_GLYPH_ANCHOR as qn,DEFAULT_GLYPH_VIEWBOX as Fn,SYMBOL_SEQUENCE as Kn,annotationLayout as or,glyphExtent as nr,glyphFractionClipRect as rr,glyphPlacement as tr,resolveGlyphPaint as ir,symbolExtent as er,symbolPathString as cr,symbolRadius as mr}from"./chunk-chunk-NO4MCQVD.module.min.js";import{DEFAULT_AREA_PER_ANNOTATION as ur,annotationBudget as lr,annotationDensity as hr}from"./chunk-chunk-U66USBWU.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import*as ar from"react";import{Fragment as sr,jsx as dr,jsxs as fr}from"react/jsx-runtime";function kr({def:o,color:n,accent:r,paintOverride:t}){return dr(sr,{children:o.parts.map((o,i)=>{const e=t?"none"===o.fill?void 0:t:ir(o.fill,n,r),c=t?o.stroke&&"none"!==o.stroke?t:void 0:ir(o.stroke??"none",n,r);return e||c?dr("path",{d:o.d,fill:e??"none",stroke:c,strokeWidth:c?o.strokeWidth??1:void 0,strokeLinecap:o.strokeLinecap,strokeLinejoin:o.strokeLinejoin,opacity:o.opacity},i):null})})}function pr({def:o,size:n=24,color:r="currentColor",accent:t="#ffffff",fraction:i=1,fractionStart:e=0,fractionDirection:c="horizontal",ghostColor:m,x:u=0,y:l=0,opacity:h,className:a}){const s=ar.useId();if(!o?.parts?.length)return null;const[,d]=o.viewBox??Fn,f=n/(d>0?d:1);if(0>=f)return null;const k=rr(o,i,e,c),p=k?"glyph-clip"+s.replace(/[^A-Za-z0-9_-]/g,"_"):void 0;return fr("g",{className:a,transform:`translate(${u} ${l}) scale(${f})`,opacity:h,"aria-hidden":"true",children:[k&&p&&dr("clipPath",{id:p,children:dr("rect",{x:k.x,y:k.y,width:k.width,height:k.height})}),k&&m?dr(kr,{def:o,color:r,accent:t,paintOverride:m}):null,k&&p?dr("g",{clipPath:`url(#${p})`,children:dr(kr,{def:o,color:r,accent:t})}):dr(kr,{def:o,color:r,accent:t})]})}export{ur as DEFAULT_AREA_PER_ANNOTATION,qn as DEFAULT_GLYPH_ANCHOR,Fn as DEFAULT_GLYPH_VIEWBOX,o as DEFAULT_HIT_RADIUS,n as DEFAULT_ISOMETRIC_SPRITE_SIZES,pr as Glyph,hn as LayoutCache,Kn as SYMBOL_SEQUENCE,r as TAU,Vn as absorbRegion,t as activeCountOverDomain,i as addPoints,e as adjacencyMatrix,Wn as aggregateRegionCounts,c as allocateCells,m as angleScale,lr as annotationBudget,hr as annotationDensity,or as annotationLayout,u as arcLayout,l as arcPath,h as arrivalReplay,a as axisFixedForceLayout,s as axisFixedForcePositions,d as bandLabel,f as betweenness,k as bfsDistances,p as bobaLayout,Xn as bodyGroupSpec,j as boundsOf,g as boxEdgeAnchors,y as buildAdjacency,v as buildTooltipEntries,x as bulletLayout,O as calendarLayout,Yn as capacitatedRegion,$n as chargeGateRegion,P as circularLayout,an as clamp,S as closeness,C as clustering,D as collidersFromScales,N as comparePhysicsTrace,tn as composePhysicsControllers,en as createCapacityQueueController,cn as createDependencyGateController,mn as createPortalController,H as createProcessJourneyLedger,un as createServiceLevelController,ln as createServiceResourcePoolController,I as cubicPath,L as cubicPoint,Q as cubicTangent,R as curvedEdgePath,V as cyclicRangeContains,W as dagreLayout,X as degree,sn as diagnoseTokenEncoding,dn as dimFor,Y as egoNetwork,$ as extractTooltipDatum,w as fanOutBend,z as flextreeLayout,wn as forceFieldRegion,fn as forceLayout,A as forceLayoutAsync,B as formatTooltipValue,J as galtonPegs,kn as generateTokens,T as geoAreaHitTarget,U as geoHitTarget,nr as glyphExtent,rr as glyphFractionClipRect,tr as glyphPlacement,pn as groupBy,zn as groupCompletionRows,M as hatchFill,Z as hitTargetPoint,_ as hitTargetRect,E as intervalLanesLayout,G as isometricLandmarkLayout,b as isotypeBoltGlyph,q as isotypeBusGlyph,F as isotypeChipGlyph,K as isotypeGhost,oo as isotypeInk,no as isotypeNetworkGlyphs,ro as isotypePaper,to as isotypePersonGlyph,io as isotypePersonPath,eo as isotypeServerGlyph,jn as layoutTokenGrid,co as legendGroupsFrom,mo as legendSwatches,uo as lineageDagLayout,lo as linearAxis,gn as makeShade,ho as marimekkoLayout,ao as markCallout,yn as matchesHighlight,vn as mean,An as membraneRegion,so as mermaidDagLayout,fo as mobileAnnotationStrategy,ko as mobileAreaChartRecipe,po as mobileBrushAlternatives,jo as mobileChartFamilyRecipe,go as mobileGeoChartRecipe,yo as mobileLineChartRecipe,vo as mobileNetworkChartRecipe,xo as mobileOrdinalChartRecipe,Oo as mobileScatterplotRecipe,Po as mobileSmallMultipleRecipe,bn as mulberry32,So as networkHitTarget,xn as nonNegativeFinite,Co as normalizePoint,Do as normalizeScores,On as normalizeTokenEncoding,No as orderByGroupDegree,Ho as orthogonalEdgePath,Io as packIntervals,Lo as packedClusterMatrix,Qo as parallelCoordinatesLayout,Ro as physicsReferenceEnvelope,Vo as pointMagnitude,Wo as polarToXY,Bn as portalRegion,Jn as pressureFieldRegion,Xo as processChrome,Yo as processJourneyRows,Tn as processLaneWalls,Un as processStageLayout,Mn as processStageRegions,Zn as processVolumePolygons,$o as proximityProblem,wo as radiusScale,Pn as readField,zo as rectCollide,_n as regionCountsToProjectionRows,Ao as ringArcPath,Bo as roundedEnclosure,En as routeSurfaceRegion,Jo as runLengthEncode,To as runs,Uo as scalePoint,Mo as sedimentBake,Zo as selectCyclicRange,_o as selectIsometricLandmarks,Sn as shade,Eo as shortestArcDelta,Go as shortestPath,Cn as signatureKey,bo as spawnFromTokens,Gn as stageTargetInVolume,qo as subtractPoints,Dn as suggestTokenEncoding,er as symbolExtent,cr as symbolPathString,mr as symbolRadius,Fo as tokenLayer,Nn as tokenTaskIntentToCapabilityIntents,Hn as unitize,In as unitizeRange,Ln as unwrapDatum,Ko as updateProcessJourney,Rn as useCustomLayoutSelection,on as waffleLayout,Qn as withAlpha,nn as wrapValue,rn as xyToAngle};