semiotic 3.5.3 → 3.5.4

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 (63) hide show
  1. package/CLAUDE.md +2 -2
  2. package/README.md +5 -5
  3. package/ai/componentMetadata.cjs +9 -2
  4. package/ai/dist/mcp-server.js +4 -1
  5. package/ai/examples.md +27 -0
  6. package/ai/schema.json +286 -41
  7. package/ai/system-prompt.md +1 -1
  8. package/dist/components/charts/index.d.ts +3 -3
  9. package/dist/components/charts/network/Treemap.d.ts +8 -0
  10. package/dist/components/charts/ordinal/GaugeChart.d.ts +10 -0
  11. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +22 -0
  12. package/dist/components/charts/shared/gaugeGradient.d.ts +62 -0
  13. package/dist/components/charts/shared/hooks.d.ts +2 -2
  14. package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -2
  15. package/dist/components/charts/shared/types.d.ts +11 -2
  16. package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
  17. package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
  18. package/dist/components/charts/xy/AreaChart.d.ts +15 -0
  19. package/dist/components/semiotic-ai.d.ts +1 -1
  20. package/dist/components/semiotic-realtime.d.ts +3 -3
  21. package/dist/components/semiotic-server.d.ts +1 -0
  22. package/dist/components/semiotic-xy.d.ts +1 -1
  23. package/dist/components/semiotic.d.ts +5 -4
  24. package/dist/components/server/renderToStaticSVG.d.ts +2 -0
  25. package/dist/components/server/staticLegend.d.ts +35 -0
  26. package/dist/components/store/ThemeStore.d.ts +2 -0
  27. package/dist/components/stream/NetworkSVGOverlay.d.ts +2 -1
  28. package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -1
  29. package/dist/components/stream/SVGOverlay.d.ts +2 -1
  30. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  31. package/dist/components/stream/geoTypes.d.ts +2 -1
  32. package/dist/components/stream/hoverUtils.d.ts +1 -0
  33. package/dist/components/stream/legendRenderer.d.ts +2 -1
  34. package/dist/components/stream/networkTypes.d.ts +2 -1
  35. package/dist/components/stream/ordinalTypes.d.ts +16 -2
  36. package/dist/components/stream/renderers/wedgePathBuilder.d.ts +31 -0
  37. package/dist/components/stream/types.d.ts +2 -1
  38. package/dist/components/types/legendTypes.d.ts +15 -0
  39. package/dist/components/types/marginType.d.ts +17 -3
  40. package/dist/geo.min.js +1 -1
  41. package/dist/geo.module.min.js +1 -1
  42. package/dist/network.min.js +1 -1
  43. package/dist/network.module.min.js +1 -1
  44. package/dist/ordinal.min.js +1 -1
  45. package/dist/ordinal.module.min.js +1 -1
  46. package/dist/realtime.min.js +1 -1
  47. package/dist/realtime.module.min.js +1 -1
  48. package/dist/semiotic-ai.d.ts +1 -1
  49. package/dist/semiotic-ai.min.js +1 -1
  50. package/dist/semiotic-ai.module.min.js +1 -1
  51. package/dist/semiotic-realtime.d.ts +3 -3
  52. package/dist/semiotic-server.d.ts +1 -0
  53. package/dist/semiotic-utils.min.js +1 -1
  54. package/dist/semiotic-utils.module.min.js +1 -1
  55. package/dist/semiotic-xy.d.ts +1 -1
  56. package/dist/semiotic.d.ts +5 -4
  57. package/dist/semiotic.min.js +1 -1
  58. package/dist/semiotic.module.min.js +1 -1
  59. package/dist/server.min.js +1 -1
  60. package/dist/server.module.min.js +1 -1
  61. package/dist/xy.min.js +1 -1
  62. package/dist/xy.module.min.js +1 -1
  63. package/package.json +13 -21
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as o from"react";import{useRef as i,useMemo as r,useContext as s,useCallback as a,useSyncExternalStore as l,createContext as c,useEffect as u,useState as d,useLayoutEffect as h,forwardRef as f,useId as g,useImperativeHandle as p}from"react";import*as y from"react-dom/server";import{scaleOrdinal as m,scaleLinear as v,scaleLog as b,scaleTime as x,scaleBand as k}from"d3-scale";import{quadtree as w}from"d3-quadtree";import{min as A,groups as S,max as _,sum as M,mean as P,group as O,quantile as T,bin as $}from"d3-array";import{interpolateNumber as j}from"d3-interpolate";import{forceLink as L,forceSimulation as C,forceManyBody as D,forceCenter as E,forceX as z,forceY as R}from"d3-force";import{ribbon as N,chord as F}from"d3-chord";import{arc as B,pie as W,curveNatural as I,curveBasis as Y,curveStepAfter as H,curveStepBefore as G,curveStep as X,curveCatmullRom as q,curveCardinal as V,curveMonotoneY as U,curveMonotoneX as Z,line as Q,area as K,curveLinear as J}from"d3-shape";import{hierarchy as tt,partition as et,pack as nt,treemap as ot,treemapBinary as it,cluster as rt,tree as st,packEnclose as at}from"d3-hierarchy";import{geoPath as lt,geoGraticule as ct,geoDistance as ut,geoInterpolate as dt,geoEqualEarth as ht,geoEquirectangular as ft,geoNaturalEarth1 as gt,geoOrthographic as pt,geoAlbersUsa as yt,geoMercator as mt}from"d3-geo";import{select as vt}from"d3-selection";import{brushX as bt,brushY as xt,brush as kt}from"d3-brush";import wt from"regression";function At(t,e,n,o){return new(n||(n=Promise))(function(i,r){function s(t){try{l(o.next(t))}catch(t){r(t)}}function a(t){try{l(o.throw(t))}catch(t){r(t)}}function l(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}l((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class St{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(o=>{t(o)?n.push(o):e.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class _t{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function Mt(t,e,n,o,i){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const t=i(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function Pt(t,e,n,o,i,r){const s=[];for(const i of t){const t=n(i),r=o(i);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:i})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function Ot(t,e,n,o,i,r,s,a){const l=[];for(const r of t){const t=n(r),s=o(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):i;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function Tt(t,e,n,o){var i,r,s;const a=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;a.set(o,-t/2)}else if("wiggle"===o){t.length>0&&a.set(t[0],0);for(let o=1;t.length>o;o++){const r=t[o-1],s=t[o];let l=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;l+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(i=a.get(r))&&void 0!==i?i:0;a.set(s,d-(c>0?l/(2*c):0))}if(t.length>0){let o=0;for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;o+=(null!==(r=a.get(i))&&void 0!==r?r:0)+t/2}const i=o/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-i)}}else for(const e of t)a.set(e,0);return a}function $t(t,e,n,o,i,r,s){const a=n(t),l=o(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:i,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function jt(t,e,n,o,i,r,s){return{type:"rect",x:t,y:e,w:n,h:o,style:i,datum:r,group:s}}function Lt(t,e,n,o,i,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:o,fill:i,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Ct(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Dt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Et(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function zt(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function Rt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Nt(t,e,n){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function Ft(t){const e=t.map(Rt),n=e.length-1;return t=>{if(0>=t){const[t,n,o]=e[0];return Nt(t,n,o)}if(t>=1){const[t,o,i]=e[n];return Nt(t,o,i)}const o=t*n,i=Math.floor(o),r=o-i,[s,a,l]=e[i],[c,u,d]=e[i+1];return Nt(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const Bt=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Wt=Ft(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),It=Ft(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Yt=Ft(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Ht=Ft(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),Gt=Ft(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Xt=Ft(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),qt=Ft(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Vt=Ft(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Ut=Ft(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Zt=Ft(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Qt=Ft(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Kt=Ft(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);Ft(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Ft(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Ft(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Ft(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Ft(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Ft(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Ft(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const Jt={category10:Bt,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Wt,reds:It,greens:Yt,oranges:Ht,purples:Gt,viridis:qt,plasma:Vt},te=Bt,ee=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],ne=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function oe(t,e,n){if("function"==typeof e){const o=e(t);return n&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||ne.has(e)}(o)?n(o):o}const o=(null==t?void 0:t[e])+"";return n?n(o):te[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(o))%te.length]}function ie(t,e,n="category10"){const o=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),i=o.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return m().domain(o).range(n).unknown("#999");const r=Jt[n]||Jt.category10;if(i&&"function"==typeof r){let t=-1/0;for(const e of o){const n=Number(e);n>t&&(t=n)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:te;return m().domain(o).range(t).unknown("#999")}}function re(t,e,n){var o,i,r;if(1>=n)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=n-1-e;switch(t.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const e=null!==(i=t.halfLife)&&void 0!==i?i:n/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function se(t,e,n){var o;const i=null!==(o=t.duration)&&void 0!==o?o:500,r=n-e;return i>r?1-r/i:0}function ae(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function le(t,e){return Math.min((t-e.startTime)/e.duration,1)}function ce(t,e,n){return t+(e-t)*n}function ue(){return"undefined"!=typeof performance?performance.now():Date.now()}function de(t,e,n){var o,i,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(i=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==i?i:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function he(t,e,n,o){return"function"==typeof e.style?e.style(o||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,o)}function fe(t,e,n,o){if(!t.scales)return null;const i=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:he(t,o,n,e[0]),datum:e,group:n,interactive:o.interactive}}function ge(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const o of t)o.perSeries?e.push(o):n.push(o);return{perSeries:e,aggregate:n}}function pe(t,e,n){const o=[];for(const i of n){const n=fe(t,e,"__ribbon_aggregate",i);n&&o.push(n)}return o}function ye(t,e,n,o){const i=[];for(const r of o){const o=fe(t,e,n,r);o&&i.push(o)}return i}function me(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const o of e){if("band"!==o.kind)continue;const e=o.getTop(t),i=o.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&n.push({y0:i,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function ve(t,e,n,o){var i;if(!t.config.pointStyle)return;const r=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(i=o.r)&&void 0!==i?i:3,l=t.getPointId?t.getPointId(s)+"":void 0,c=$t(s,t.scales,t.getX,r,a,o,l);c&&n.push(c)}}}const be={topOpacity:.8,bottomOpacity:.05};function xe(t){var e,n;if(t)return!0===t?be:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:be.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:be.bottomOpacity}}const ke={blues:Wt,reds:It,greens:Yt,viridis:qt,oranges:Ht,purples:Gt,greys:Xt,plasma:Vt,inferno:Ut,magma:Zt,cividis:Qt,turbo:Kt},we=new Map;function Ae(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function Se(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=Ae(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=Dt(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e+i:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const i=n(t);return Number.isFinite(i)&&0!==i?e-i:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:Ae(t.y1Accessor,"y1"),getBottom:Ae(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class _e{constructor(t){if(this.xExtent=new _t,this.yExtent=new _t,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new St(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Dt(t.timeAccessor||t.xAccessor,"time"),this.getY=Dt(t.valueAccessor||t.yAccessor,"value")):(this.getX=Dt(t.xAccessor,"x"),this.getY=Dt(t.yAccessor,"y")),this.getGroup=zt(t.groupAccessor),this.getCategory=zt(t.categoryAccessor),this.getSize=t.sizeAccessor?Dt(t.sizeAccessor,"size"):void 0,this.getColor=zt(t.colorAccessor),this.getY0=t.y0Accessor?Dt(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Se(t),this.getPointId=zt(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Dt(t.openAccessor,"open"):void 0,this.getHigh=Dt(t.highAccessor,"high"),this.getLow=Dt(t.lowAccessor,"low"),this.getClose=n?Dt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new St(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?Dt(this.config.timeAccessor||this.config.xAccessor,"time"):Dt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(e):e[n||"x"],i=o instanceof Date,r="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=i||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)if(this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);if(this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),o=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(o)&&this.yExtent.push(o)}}if(null!=t)if(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t));else{this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}}return!0}computeScene(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g;const{config:p,buffer:y}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(y,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const m=this.getBufferArray(),k=this.xExtent.extent,w=this.yExtent.extent;let A=p.xExtent?[null!==(n=p.xExtent[0])&&void 0!==n?n:k[0],null!==(o=p.xExtent[1])&&void 0!==o?o:k[1]]:k,S=p.yExtent?[null!==(i=p.yExtent[0])&&void 0!==i?i:w[0],null!==(r=p.yExtent[1])&&void 0!==r?r:w[1]]:w;const _=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1],M="exact"===p.axisExtent;if("stackedarea"===p.chartType&&!_&&y.size>0)if(p.normalize)S=[0,M?1:1+p.extentPadding];else{const t=`${y.size}:${this._ingestVersion}:${null!==(s=p.baseline)&&void 0!==s?s:"zero"}:${null!==(a=p.stackOrder)&&void 0!==a?a:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)S=this._stackExtentCache.yDomain;else{const e=this.groupData(m),n=new Map,o=new Set;let i=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let a=0;for(const n of t.data){const t=this.getX(n),s=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),o.add(t),a+=s;const l=(r.get(t)||0)+s;r.set(t,l),l>i&&(i=l)}n.set(t.key,e),s.set(t.key,a)}const a=null!==(l=p.stackOrder)&&void 0!==l?l:"key",f=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===a){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:f(t,e)}),n=[],o=[];let i=0,r=0;for(const e of t)r>i?(n.push(e),i+=null!==(c=s.get(e))&&void 0!==c?c:0):(o.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0);g=[...o.reverse(),...n]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==i?i:f(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:f(t,e)}):e.map(t=>t.key).sort(f);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=Tt(t,g,(t,e)=>{var o;return(null===(o=n.get(t))||void 0===o?void 0:o.get(e))||0},p.baseline);let i=1/0,s=-1/0;for(const n of t){const t=null!==(d=e.get(n))&&void 0!==d?d:0,o=null!==(h=r.get(n))&&void 0!==h?h:0;i>t&&(i=t),t+o>s&&(s=t+o)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=M?0:a>0?a*p.extentPadding:1;S=[i-l,s+l]}else S=[0,i+(M?0:i>0?i*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:S}}}else if("bar"===p.chartType&&p.binSize&&!_&&y.size>0){const[,t]=function(t,e,n,o,i){const r=Mt(t,e,n,o,i);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(y,this.getX,this.getY,p.binSize,this.getCategory);S=[0,M?t:t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!_&&y.size>0){const[t,e]=function(t,e){let n=0,o=0,i=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(i+=t,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(y,this.getY),n=e-t,o=M?0:n>0?n*p.extentPadding:1;S=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!_&&S[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of m)for(const e of this.resolvedRibbons){const n=e.getTop(t),o=e.getBottom(t);Number.isFinite(n)&&(S[0]>n&&(S[0]=n),n>S[1]&&(S[1]=n)),Number.isFinite(o)&&(S[0]>o&&(S[0]=o),o>S[1]&&(S[1]=o))}const t=S[1]-S[0],e=M?0:t>0?t*p.extentPadding:1,n=null===(f=p.yExtent)||void 0===f?void 0:f[0],o=null===(g=p.yExtent)||void 0===g?void 0:g[1];S=[null!=n?S[0]:S[0]-e,null!=o?S[1]:S[1]+e],"log"!==p.yScaleType||S[0]>0||0>=w[0]||M||(S[0]=null!=n?S[0]:w[0]/(1+p.extentPadding))}if(p.yExtent&&!_){const t=p.yExtent[0],e=p.yExtent[1];null==t&&null==e||(S=[null!=t?t:S[0],null!=e?e:S[1]])}if(A[0]===1/0||A[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();A=[t-864e5,t]}else A=[0,1];S[0]!==1/0&&S[1]!==-1/0||(S=[0,1]);const P="streaming"===p.runtimeMode,O=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(T=p.arrowOfTime)||"down"===T?"y":"x")){const e="right"===p.arrowOfTime?[O,t.width-O]:[t.width-O,O];this.scales={x:v().domain(A).range(e),y:v().domain(S).range([t.height-O,O])}}else{const e="down"===p.arrowOfTime?[O,t.height-O]:[t.height-O,O];this.scales={x:v().domain(S).range([O,t.width-O]),y:v().domain(A).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)};this.scales={x:e(p.xScaleType,A,[O,t.width-O]),y:e(p.yScaleType,S,[t.height-O,O])}}var T;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,m),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,_e.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let i=0;for(const t of this.scene)"point"===t.type&&(o[i++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=n;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=n;for(const o of t.bottomPath)o[0]*=e,o[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const o=this.scales.x.domain(),i=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,r[0]>r[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,i,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,o,i,r,s,a,l;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const l=null!==(n=c.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},d={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:l,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(o=c.themeSemantic)&&void 0!==o?o:{},categorical:null!==(i=c.themeCategorical)&&void 0!==i?i:ee},resolveColor:(t,e)=>{var n,o;const i=this.resolveGroupColor(t);if(i)return i;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(o=null===(n=c.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==o?o:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null,null!==(a=h.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(c.chartType){case"line":return function(t,e){var n;const o=t.groupData(e),i=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=ge(t.ribbons);if(r.length>0&&i.push(...pe(t,e,r)),n.length>0)for(const e of o)i.push(...ye(t,e.data,e.key,n))}for(const e of o){const n=t.resolveLineStyle(e.key,e.data[0]),o=Pt(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(o.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return ve(t,o,i),i}(d,e);case"area":return function(t,e){const n=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=ge(t.ribbons);if(r.length>0&&o.push(...pe(t,e,r)),i.length>0)for(const e of n)o.push(...ye(t,e.data,e.key,i))}const i=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?i:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=Ot(e.data,t.scales,t.getX,t.getY,i,n,e.key,r),a=xe(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return ve(t,n,o),o}(d,e);case"mixed":return function(t,e){const n=t.groupData(e),o=[],i=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:r}=ge(t.ribbons);if(r.length>0&&o.push(...pe(t,e,r)),i.length>0)for(const e of n)o.push(...ye(t,e.data,e.key,i))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(i.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),i=Ot(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=xe(t.config.gradientFill);a&&(i.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}else{const n=t.resolveLineStyle(e.key,e.data[0]),i=Pt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return ve(t,n,o),o}(d,e);case"stackedarea":return function(t,e){var n,o,i,r;const s=t.groupData(e),a=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",l=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const n of s){let o=0;for(const e of n.data){const n=t.getX(e),i=t.getY(e);Number.isFinite(n)&&Number.isFinite(i)&&(o+=i)}e.set(n.key,o)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(t.key))&&void 0!==i?i:0)-(null!==(r=e.get(o.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else if("desc"===a)s.sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)});else{const t=[...s].sort((t,o)=>{var i,r;const s=(null!==(i=e.get(o.key))&&void 0!==i?i:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,o.key)}),r=[],a=[];let l=0,c=0;for(const n of t)c>l?(r.push(n),l+=null!==(o=e.get(n.key))&&void 0!==o?o:0):(a.push(n),c+=null!==(i=e.get(n.key))&&void 0!==i?i:0);s.length=0,s.push(...a.reverse(),...r)}}else l();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,o,i,r,s,a="zero"){var l,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=n(i),r=o(i);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const o of t)n+=(null===(l=h.get(o.key))||void 0===l?void 0:l.get(e))||0;f.set(e,n||1)}}const g=Tt(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},a),p=[],y=new Map,m=new Map;for(const t of d)m.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),o=[],a=[],l=new Map;for(const n of d){let i=t.get(n)||0;const s=m.get(n);r&&(i/=f.get(n));const c=s+i,u=e.x(n);a.push([u,e.y(s)]),o.push([u,e.y(c)]),m.set(n,c),l.set(n,c)}y.set(n.key,l);const c={type:"area",topPath:o,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),p.push(c)}return{nodes:p,stackedTops:y}}(s,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of s){const o=h.get(n.key);if(o)for(const i of n.data){const n=t.getX(i),r=t.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||e.set(i,o.get(n))}}const n=n=>{var o;return null!==(o=e.get(n))&&void 0!==o?o:t.getY(n)};ve(t,s,f,n)}return f}(d,e);case"scatter":case"bubble":return function(t,e){var n;const o=[],i="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const o of n)t>o&&(t=o),o>e&&(e=o);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const a=t.getColor?t.resolveColorMap(e):null,l=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:l,opacity:.8},r=e.r||i;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(n);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=$t(n,t.scales,t.getX,t.getY,r,e,c);u&&o.push(u)}return o}(d,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var o,i,r;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(i=t.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Dt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,p=(f-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;e.length>n;n++){const o=e[n],i=t.getX(o),r=t.getY(o);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/g),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const y=c(o);v[f]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let t=0;y>t;t++){if(0===m[t])continue;let e;switch(l){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}b>e&&(b=e),e>x&&(x=e)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/s,A=n.height/a,S=t.config.showValues,_=t.config.heatmapValueFormat,M=[];for(let t=0;a>t;t++){const e=t*s;for(let n=0;s>n;n++){const o=e+n;if(0===m[o])continue;let i;switch(l){case"sum":i=v[o];break;case"mean":i=v[o]/m[o];break;default:i=m[o]}const r=(i-b)/k;M.push(Lt(n*w,(a-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:i,count:m[o],sum:v[o],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*p,agg:l},S?{value:i,showValues:!0,valueFormat:_}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const o=Dt(t.config.valueAccessor,"value"),i=Et(t.config.xAccessor,"x"),r=Et(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],o=i(n),u=r(n);l[t]=o,c[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),p=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(p){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const y=new Float64Array(e.length),m=new Float64Array(e.length),v=Array(e.length),b=new Map;let x=0;for(let t=0;e.length>t;t++){const n=e[t],i=s.get(l[t]),r=a.get(c[t]);if(void 0===i||void 0===r)continue;const d=o(n),h=r*u+i,f=b.get(h);let g;void 0!==f?g=f:(g=x++,b.set(h,g)),y[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;x>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in ke?t:"blues";let n=we.get(e);if(n)return n;n=Array(256);const o=ke[e]||Wt;for(let t=0;256>t;t++)n[t]=o(t/255);return we.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/d,P=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;x>t;t++){const e=m[t];if(!isFinite(e))continue;const n=y[t],o=n%u;T.push(Lt(o*_,(d-1-(n-o)/u)*M,_,M,A[Math.min((e-k)*S+.5|0,255)],v[t],P?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}(d,e,t);case"bar":{const t=function(t,e){var n,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=Mt(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(n),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=n.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:l,order:r})}const s=[],a=t.scales,[l,c]=a.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of i.values()){const n=Math.max(e.start,l),i=Math.min(e.end,c);if(n>=i)continue;const h=a.x(n),p=a.x(i),y=Math.abs(p-h),m=y>f+1?f:0,v=Math.min(h,p)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&e.categories.size>0){let n=0;for(const i of r){const r=e.categories.get(i)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(o=t.config.barColors)||void 0===o?void 0:o[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(jt(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:i,categoryValue:r},i)),n+=r}}else{const t=a.y(0),n=a.y(e.total);s.push(jt(v,Math.min(t,n),b,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const p=new Set;for(const t of i.values())p.add(t.start),p.add(t.end);return{nodes:s,binBoundaries:Array.from(p).sort((t,e)=>t-e)}}(d,e);return this._barCategoryCache=null!==(l=d.barCategoryCache)&&void 0!==l?l:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,o,i,r,s,a;const l=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(o=c.fill)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),o=t.getY(n);if(null==o||Number.isNaN(o))continue;const i=t.scales.x(e),r=t.scales.y(o);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),l.push(c)}return l}(d,e);case"waterfall":return function(t,e,n){var o,i,r,s,a,l,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),o=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(r=null!==(o=null==h?void 0:h.positiveColor)&&void 0!==o?o:null===(i=t.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",p=null!==(l=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==l?l:"#dc3545",y=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,m=null==h?void 0:h.stroke,v=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let e=0;f.length>e;e++){const o=f[e],i=t.getX(o),r=t.getY(o),s=x+r;let a;a=f.length-1>e?t.getX(f[e+1])-i:e>0?i-t.getX(f[e-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+n.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const A=d.y(x),S=d.y(s),_=Math.min(A,S),M=Math.abs(A-S),P={fill:0>r?p:g,stroke:m,strokeWidth:v};null!=b&&(P.opacity=b),u.push(jt(k,_,w,M,P,Object.assign(Object.assign({},o),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(d,e,t);case"candlestick":return function(t,e){var n,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const i=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=i?a:s.upColor||"#28a745",c=i?a:s.downColor||"#dc3545",u=i?a:s.wickColor||"#333",d=s.wickWidth||(i?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(n),s=t.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=i?o:t.getOpen(n),h=i?s:t.getClose(n);if(!i&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=a,p={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};i&&(p.isRange=!0),r.push(p)}return r}(d,e);default:return[]}}resolveBoundsStyle(t,e){var n;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?re(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var o,i;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const o=Array(e.length);let i=!1;for(let n=0;e.length>n;n++){const a=s.get(e[n]);null!=a?(o[n]=re(t,a,r),1>o[n]&&(i=!0)):o[n]=1}i&&(n._decayOpacities=o);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:e.length;if(2>o)continue;if(e.length===o){const i=Array(o);let a=!1;for(let n=0;e.length>n;n++){const o=s.get(e[n]);null!=o?(i[n]=re(t,o,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of e){const e=s.get(n);if(null!=e){const n=re(t,e,r);i>n&&(i=n)}}if(1>i){const t=Array(o);t.fill(i),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const a=re(t,e,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(i=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,o){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=t.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let i=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=o.get(e);if(null==r)continue;const a=se(t,r,s);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const i=o.get(e);if(null==i)continue;const r=se(t,i,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&i>o-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,o){var i,r,s,a;n.clear(),o.clear();for(let l=0;e.length>l;l++){const c=e[l],u=de(t,c,l);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(i=c.style)||void 0===i?void 0:i.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?o.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&o.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=de(this.transitionContext,e,t);i&&("point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(i,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(i,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(i,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,o,i){var r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,_,M,P,O,T,$,j,L,C,D,E,z,R,N,F,B,W,I,Y,H,G;if(0===o.size&&0===i.size)return n;const X=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let q=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],$=de(t,r,e);if(!$)continue;if(r._transitionKey=$,"line"===r.type||"area"===r.type){const t=i.get($);if(t){if(U.add($),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];q=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];q=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=t.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;continue}const j=o.get($);if("point"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,j.x===t.x&&j.y===t.y&&j.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=j.x,r.y=j.y,r.r=null!==(d=j.r)&&void 0!==d?d:r.r,q=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("rect"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,j.x===t.x&&j.y===t.y&&j.w===t.w&&j.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=j.x,r.y=j.y,r.w=null!==(g=j.w)&&void 0!==g?g:r.w,r.h=null!==(p=j.h)&&void 0!==p?p:r.h,q=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("heatcell"===r.type)if(j){V.add($);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(v=null===(m=r.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,j.x===t.x&&j.y===t.y&&j.w===t.w&&j.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=j.x,r.y=j.y,r.w=null!==(b=j.w)&&void 0!==b?b:r.w,r.h=null!==(x=j.h)&&void 0!==x?x:r.h,q=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0;else if("candlestick"===r.type)if(j&&null!=j.openY){V.add($);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(j.x!==t.x||j.openY!==t.openY||j.closeY!==t.closeY||j.highY!==t.highY||j.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=j.x,r.openY=j.openY,r.closeY=null!==(_=j.closeY)&&void 0!==_?_:r.closeY,r.highY=null!==(M=j.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(P=j.lowY)&&void 0!==P?P:r.lowY,q=!0)}else r._targetOpacity=null!==(T=null===(O=r.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0}for(const[t,e]of i)if(!U.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(j=e.opacity)&&void 0!==j?j:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),q=!0}for(const[t,e]of o)if(!V.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(L=e.r)&&void 0!==L?L:3,style:{opacity:null!==(C=e.opacity)&&void 0!==C?C:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(D=e.w)&&void 0!==D?D:0,h:null!==(E=e.h)&&void 0!==E?E:0,style:{opacity:null!==(z=e.opacity)&&void 0!==z?z:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(R=e.w)&&void 0!==R?R:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(B=e.openY)&&void 0!==B?B:e.y,i={type:"candlestick",x:e.x,openY:o,closeY:null!==(W=e.closeY)&&void 0!==W?W:o,highY:null!==(I=e.highY)&&void 0!==I?I:o,lowY:null!==(Y=e.lowY)&&void 0!==Y?Y:o,bodyWidth:null!==(H=e.w)&&void 0!==H?H:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(G=e.opacity)&&void 0!==G?G:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}q=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),q&&(n.activeTransition={startTime:ue(),duration:X}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,o){var i,r,s,a,l,c;if(!n.activeTransition)return!1;const u=le(t,n.activeTransition),d=ae(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=ce(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=ce(n.x,t._targetX,d),t.y=ce(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=ce(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=ce(i,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=ce(n.x,t._targetX,d),t.y=ce(n.y,t._targetY,d),void 0!==n.w&&(t.w=ce(n.w,t._targetW,d)),void 0!==n.h&&(t.h=ce(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ce(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=ce(n.x,t._targetX,d),t.y=ce(n.y,t._targetY,d),void 0!==n.w&&(t.w=ce(n.w,t._targetW,d)),void 0!==n.h&&(t.h=ce(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?o.get(e):void 0,i=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:ce(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=ce(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=ce(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=ce(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=ce(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=ce(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ce(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=ce(e[o][0],n[o][0],d),t.path[o][1]=ce(e[o][1],n[o][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ce(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,o=t._targetTopPath,i=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=ce(e[n][0],o[n][0],d),t.topPath[n][1]=ce(e[n][1],o[n][1],d);if(n&&i&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=ce(n[e][0],i[e][0],d),t.bottomPath[e][1]=ce(n[e][1],i[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ee,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],i[t%i.length]);return this._colorMapCache={key:o,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const i=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,o;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||ee;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>_e.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,o=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{i.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,o,i;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=l||!Ct(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!Ct(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Dt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Dt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Dt(this.config.xAccessor,"x"),this.getY=Dt(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Se(this.config)),s=!0,a=!0)}if("groupAccessor"in t&&!Ct(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?zt(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!Ct(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?zt(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!Ct(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Dt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!Ct(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?zt(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!Ct(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Dt(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in t&&!Ct(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=Se(this.config),s=!0,a=!0),"pointIdAccessor"in t&&!Ct(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?zt(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!Ct(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!Ct(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!Ct(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!Ct(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Dt(this.config.openAccessor,"open"):void 0,this.getHigh=Dt(this.config.highAccessor,"high"),this.getLow=Dt(this.config.lowAccessor,"low"),this.getClose=e?Dt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,a=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Me(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Pe(t,e){var n,o=[],i=[],r=[],s={},a=[];function l(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&l(e)})}function c(t){var e,o,d=!1;for(i.push(t),r[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===n?(u(n,i),d=!0):r[o]||(d=c(o));if(d)l(t);else for(e=0;a[t].length>e;e++){var h=s[o=a[t][e]];h||(s[o]=h={}),h[o]=!0}return i.pop(),d}function u(t,e){var n=[].concat(e).concat(t);o.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,o=function(t){for(var e=t.length,n=Array(e),o=Array(e),i=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,o[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(e){var l=[e],c=[e];for(n[e]=o[e]=u,i[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var p=f[g];if(0>n[p]){n[p]=o[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(o[e]=0|Math.min(o[e],o[p])),0>s[p]||a[e].push(s[p])}r[e]=g}else{if(o[e]===n[e]){var y=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(i[b]=!1,y.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===e){l.length=g;break}}d.push(y);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&c.push(g[p]);h[l]=c}}return{components:d,adjacencyList:h}}(t),i=o.components.filter(function(t){return t.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],n=s);var l=i[n];if(!l)return!1;var c=t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var p=0;a[g].length>p;p++){var y=a[g][p];r[+y]=!1,s[y]={}}c(n),n+=1}else n=h}return o}function Oe(t){return t.y0-t.y1>0?"up":"down"}function Te(t,e){return e(t.source)==e(t.target)}function $e(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function je(t){return t.target.x0-t.source.x1}function Le(t,e){var n=De(t),o=je(e)/Math.tan(n);return"up"==Oe(t)?t.y1-o:t.y1+o}function Ce(t,e){var n=De(t),o=je(e)/Math.tan(n);return"up"==Oe(t)?t.y1+o:t.y1-o}function De(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Ee(t,e){return e(t)}function ze(t){return Ne(t.source)}function Re(t){return Ne(t.target)}function Ne(t){return(t.y0+t.y1)/2}function Fe(t){return t.virtual?0:t.value}function Be(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Te(t,e)?n+1:n});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Te(t,e)?o+1:o}),n+o}function We(t){return t.target.depth}function Ie(t,e){return t.sourceLinks.length?t.depth:e-1}function Ye(t,e){return t.y0-e.y0}function He(t,e){return e.y0-t.y0}function Ge(t,e){return t.y1-e.y1}function Xe(t,e){return e.y1-t.y1}function qe(t,e){return Ue(t.source,e.source)||t.index-e.index}function Ve(t,e){return Ue(t.target,e.target)||t.index-e.index}function Ue(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ze(t,e){return Qe(t)==Qe(e)?"bottom"==t.circularLinkType?He(t,e):Ye(t,e):Qe(e)-Qe(t)}function Qe(t){return t.target.column-t.source.column}function Ke(t,e){return Je(t)==Je(e)}function Je(t){return t.y0-t.y1>0?"up":"down"}function tn(t,e,n,o,i){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=A(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=r.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),en(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),en(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Te(t,e)&&$e(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?He:Ye);var u=0;c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Xe:Ge),u=0,c.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+i*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,o=t.target.x0,i=t.y1,r=(e+o)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+i+" "+o+","+i}(t)}),r}function en(t,e,n){t.sort(Ze);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Te(t,e)&&$e(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&nn(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function nn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function on(t){return function(){return t}}function rn(t){return t.index}function sn(t){return t.nodes}function an(t){return t.links}function ln(t,e,n){var o=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(i,r){var s=i.length;if(e)i.sort(e);else if(r>0){var a=new Map;i.forEach(function(t,e){var n,o,i,r=(o=0,i=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Ne(t.source)*e,o+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Ne(t.target)*e,o+=e}}),o>0?i/o:NaN);a.set(t,{bc:r,idx:e})}),i.sort(function(t,e){var n=a.get(t),o=a.get(e),i=n.bc,r=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?n.idx-o.idx:1:-1:i-r})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Be(e,n)-Be(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Be(e,n)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+i,e.y1=e.y0+e.value*t.ky)})})}function cn(t,e,n,o,i,r){var s=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,l=r;l>0;--l)c(a*=.99,n),u();function c(e,n){var o=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var a;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Be(i,n)>0){var l=P(i.sourceLinks,Re),c=P(i.targetLinks,ze),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Ne(i))*e*.3;i.y0+=d,i.y1+=d}}else if(0==s&&1==r)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(s==o-1&&1==r)i.y0=t.y1/2-(a=i.y1-i.y0)/2,i.y1=t.y1/2+a/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)a=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+a;else{var h=P(i.sourceLinks,Re),f=P(i.targetLinks,ze),g=((h&&f?(h+f)/2:h||f)-Ne(i))*e;i.y0+=g,i.y1+=g}})})}function u(){s.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||Ue),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+o;if((s=l-o-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function un(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Ve),t.targetLinks.sort(qe)}),t.nodes.forEach(function(t){var e=t.y0,n=e,o=t.y1,i=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function dn(){var t=0,e=0,n=1,o=1,i=24,r=8,s=null,a=rn,l=Ie,c=void 0,u=32,d=2,h=sn,f=an;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=o,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return O(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,i=t.target;"object"!=typeof o&&(o=t.source=Me(n,o)),"object"!=typeof i&&(i=t.target=Me(n,i)),o.sourceLinks.push(t),i.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var o=[],i=0;t.links.length>i;i++){var r=t.links[i],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=Pe(o);l.sort(function(t,e){return t.length-e.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||c[o]&&c[o][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,o=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:o>n?"top":"bottom","top"==i.circularLinkType?n++:o++,t.nodes.forEach(function(t){Ee(t,e)!=Ee(i.source,e)&&Ee(t,e)!=Ee(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Te(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(M(t.sourceLinks,Fe),M(t.targetLinks,Fe)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var o,i,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(o=t.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,l);var f=r;if(null!==s){var g=S(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=_(g,function(t){return t.length});p>1&&(f=Math.max(1,(o-e)*s/(p-1)))}(function(t,e,n){var o=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var i=A(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/M(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var r=_(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,i),ln(h,c,a),cn(h,c,a,f,f,u),un(h),tn(h,a,d,10,8),ln(h,c,a),cn(h,c,a,f,f,u),un(h),tn(h,a,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var o=n.links.filter(function(n){return Ee(n.source,e)==Ee(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!Ke(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Le(e,t);return t.y1-n}if(e.target.column>t.target.column)return Le(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y0=t.y1-s-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var o=n.links.filter(function(n){return Ee(n.target,e)==Ee(t,e)}),i=o.length;i>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!Ke(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Ce(e,t);return t.y0-n}if(e.source.column>t.source.column)return Ce(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;o.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),o.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;e.y1=t.y1-s-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,o=!1,i=!1;if(n.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==o||0==i){var r=A(e,function(t){return t.y0}),s=_(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function l(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),n.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),tn(h,a,d,10,8)}(g),g}return g.update=function(t){return un(t),tn(t,a,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(i=+t,g):i},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:on(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:on(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:on(t),g):a},g.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:on(t),g):l},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],o=+i[1][1],g):[[t,e],[n,o]]},g.size=function(i){return arguments.length?(t=e=0,n=+i[0],o=+i[1],g):[n-t,o-e]},g}function hn(t){const{sx:e,sTop:n,sBot:o,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+o)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(o-n)/2}}}_e.GROUP_COLOR_MAP_CAP=1e3,_e.QUADTREE_THRESHOLD=500;const fn=t=>{let e,n,o,i,r,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=j(r,s),l=a(.5),c=a(.5),`M${e},${r}C${e},${l} ${n},${c} ${n},${s}L${o},${s}C${o},${c} ${i},${l} ${i},${r}Z`;const u=t.sankeyWidth/2,d=j(t.source.x1,t.target.x0),{pathD:h}=hn({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function gn(t){var e;const n=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const e=i.sourceX,o=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-e))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${e},${o-n}L${e+a},${o-n}L${e+a},${o+n}L${e},${o+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}Z`}const r=i.sourceX,s=i.sourceY,a=i.targetX,l=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+o},${s-h*n+h*f}L${c+o},${d+h*o-h*f}L${c+o-f},${d+h*o}L${u-o+f},${d+h*o}L${u-o},${d+h*o-h*f}L${u-o},${l-h*n+h*f}L${u-o+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${s+h*n}L${r},${s+h*n}Z`}const pn=new Set,yn=new WeakMap;function mn(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=yn.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,yn.set(t,n);const o=new Proxy(t,{get(t,n,o){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;pn.has(t)||(pn.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,o)}});return n.set(e,o),o}const vn={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(We))-1:0},justify:Ie};function bn(t){return"string"==typeof t?t:t.id}const xn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r,s,a,l,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=n.iterations)&&void 0!==s?s:100,y=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===d?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=dn().extent(v).links(m).nodes(y).nodeAlign(vn[h]||Ie).nodeId(t=>t.id).nodeWidth(f).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let t=1/0,e=-1/0,n=1/0,i=-1/0;for(const o of y)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),n>o.y0&&(n=o.y0),o.y1>i&&(i=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(null!==(l=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==l?l:0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=e-t,s=i-n,u=o[0],d=o[1];if(r>0&&s>0&&(0>t||0>n||e>u||i>d)){const e=Math.min(u/r,d/s),o=-t*e+(u-r*e)/2,i=-n*e+(d-s*e)/2;for(const t of y)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of m)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+o,n.targetX=n.targetX*e+o,n.sourceY=n.sourceY*e+i,n.targetY=n.targetY*e+i,n.rightFullExtent=n.rightFullExtent*e+o,n.leftFullExtent=n.leftFullExtent*e+o,n.verticalFullExtent=n.verticalFullExtent*e+i,n.rightInnerExtent=n.rightInnerExtent*e+o,n.leftInnerExtent=n.leftInnerExtent*e+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+i,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of y){const e=x.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=bn(t.source),n=bn(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=d;const i=x.get(e),r=x.get(n);i&&(o.source=i),r&&(o.target=r)}}},buildScene(t,e,n,o){var i,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Bt,y=new Map;t.forEach((t,e)=>{y.set(t.id,p[e%p.length])});const m=[],v=[],b=[],x=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const o=d?d(mn(e,"nodeStyle")):{},i={fill:o.fill||y.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};x.set(e.id,("string"==typeof i.fill?i.fill:null)||y.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:i,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:i,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof g?g(t)||i:"target"===g?x.get(o.id)||y.get(o.id)||i:x.get(e.id)||y.get(e.id)||i;const u=h?h(mn(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||i;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+o},${e.sourceY-n}L${e.sourceX+o},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?gn(t):fn(t),!d)continue;const p={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:p,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,i=n.y1-n.y0;if(0>=t||0>=i)continue;const r=e?e(n):n.id;if(!r)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(o[0]/2>n.x0+t/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+i/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},kn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,o){var i,r;if(0===t.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,a=o[0]/2,l=o[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const o=wn(t.id,e,n);if(o.length>0){let e=0,n=0;for(const t of o)e+=t.x,n+=t.y;const i=An(t.id),r=i%360*(Math.PI/180),s=10+i%20;t.x=e/o.length+s*Math.cos(r),t.y=n/o.length+s*Math.sin(r)}else{const e=An(t.id),n=e%360*(Math.PI/180),o=15+e%30;t.x=a+o*Math.cos(n),t.y=l+o*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const o=t[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(n+.5),i=n*e;o.x=a+t*Math.cos(i),o.y=l+t*Math.sin(i)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,p=Sn(n.nodeSize,n.nodeSizeRange,t),y=t=>p(t);if(g>0){const n=L().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=C().force("charge",D().strength(t=>-25*y(t))).force("center",E(a,l).strength(.8)).force("x",z(a).strength(.15)).force("y",R(l).strength(.15));if(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));n.links(t),o.force("link",n)}h?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;g>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=y(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Sn(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Bt,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const y=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(mn(e,"nodeSize")),o=d?d(mn(e,"nodeStyle")):{},a={fill:o.fill||p.get(e.id)||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};y.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const i=h?h(mn(t,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=i.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=i.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(x=n.nodeLabel)?"function"==typeof x?x:t=>t[x]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const o=f(mn(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}};function wn(t,e,n){const o=[];for(const i of e){const e="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function An(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function Sn(t,e,n){var o,i;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],s=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>r[0];const a=null!==(o=A(s))&&void 0!==o?o:0,l=null!==(i=_(s))&&void 0!==i?i:1;if(a===l)return()=>(r[0]+r[1])/2;const c=v().domain([a,l]).range(r).clamp(!0);return e=>{var n;const o=null===(n=e.data)||void 0===n?void 0:n[t];return null==o||"number"!=typeof o?r[0]:c(o)}}const _n=Bt,Mn={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,o){if(0===t.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(o[0],o[1])/2,l=a-r,c=o[0]/2,u=o[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===n||void 0===o)continue;const i=d(t);p[n][o]=i}const y=F().padAngle(i);s&&y.sortGroups(s);const m=y(p),v=m.groups,b=B().innerRadius(l).outerRadius(a);for(const e of v){const n=t[e.index],o=b.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=o[0]+c,n.y=o[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=x.get("string"==typeof t.source?t.source:t.source.id),o=x.get(e);n&&(t.source=n),o&&(t.target=o)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,o=t[e.target.index].id,i=k.get(`${n}\0${o}`)||k.get(`${o}\0${n}`);i&&(i.__chordData=e)}},buildScene(t,e,n,o){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=n,u=Math.min(o[0],o[1])/2,d=u-l,h=o[0]/2,f=o[1]/2,g=n.nodeStyle,p=n.edgeStyle,y=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:_n,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const b=N().radius(d),x=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],o=n.__arcData;if(!o)continue;let r;r=g?g(mn(n,"nodeStyle")).fill||v.get(n.id)||m[e%m.length]:v.get(n.id)||m[e%m.length];const s=g?g(mn(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=b(e);if(!o)continue;const i=Pn(o,h,f);let l=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)l=p(mn(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?l=v.get(n.id)||l:e&&(l=v.get(e.id)||l)}const u=p?p(mn(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:i,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,o=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const i=e?e(n):n.id;if(!i)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;w.push({x:h+Math.cos(s)*o,y:f+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:x,sceneEdges:k,labels:w}}};function Pn(t,e,n){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const i=[];let r=0;for(;o.length>r;){const t=o[r];if("M"===t||"L"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("C"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;3>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("Q"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)for(let t=0;2>t&&o.length>r&&!isNaN(Number(o[r]));t++)i.push(Number(o[r])+e+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("A"===t)for(i.push(t),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&(i.push(Number(o[r])+e+""),r++),o.length>r&&(i.push(Number(o[r])+n+""),r++);else"Z"===t||"z"===t?(i.push(t),r++):(i.push(o[r]),r++)}return i.join(" ")}const On=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Tn(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>150?"#222":"#fff"}function $n(t,e,n){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function jn(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Ln(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:On}function Cn(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Dn(t,e,n,o,i){if("horizontal"===i){const i=(t+n)/2;return`M ${t},${e} C ${i},${e} ${i},${o} ${n},${o}`}if("radial"===i){const i=(t+n)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+o)/2} T ${n},${o}`}{const i=(e+o)/2;return`M ${t},${e} C ${t},${i} ${n},${i} ${n},${o}`}}const En={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,o){var i;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),l=n.hierarchySum,c="function"==typeof l?l:"string"==typeof l?t=>Number(t[l])||0:t=>Number(t.value)||0,u=tt(r,a);u.sum(c),u.sort((t,e)=>{var n,o;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[d,h]=o;switch(s){case"tree":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=st();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=rt();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,o){var i,r;const s=null!==(i=e.padding)&&void 0!==i?i:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=ot().size([n,o]).tile(it).padding(s);a>0&&l.paddingTop(a),l(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,o){var i;const r=null!==(i=e.padding)&&void 0!==i?i:4;nt().size([n,o]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,o){var i;et().size([n,o]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const o=f[e],r={id:$n(o,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=o.value)&&void 0!==i?i:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?zn(r,o,n):"treemap"===s||"partition"===s?Rn(r,o):"circlepack"===s&&Nn(r,o),r.__hierarchyNode=o,t.push(r),g.set(o,r)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const n=g.get(t.parent),o=g.get(t);n&&o&&e.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,o){const i=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=[],p=[],y=[],m=n.treeOrientation||"vertical",v="radial"===m,b=o[0]/2,x=o[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,o=e.y;v&&(t+=b,o+=x);const r=i(mn(e,"nodeStyle"));let l=r.fill||Cn(n);if(n.colorByDepth&&void 0!==e.depth){const t=Ln(n);l=t[e.depth%t.length]}const c={fill:l,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let i=e.x,s=e.y,a=o.x,l=o.y;v&&(i+=b,s+=x,a+=b,l+=x);const f=Dn(i,s,a,l,m),g=r(mn(t,"edgeStyle")),y={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};p.push({type:"curved",pathD:f,style:y,datum:t})}if(!1!==n.showLabels){const e=jn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let o,i,r,s=n.x,a=n.y;if(v&&(s+=b,a+=x),v){const t=s-b,e=a-x,n=Math.sqrt(t*t+e*e);n>0?(o=s+t/n*10,i=a+e/n*10,r=0>t?"end":"start"):(o=s,i=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=s-k-6,r="end"):(o=s+k+6,r="start"),i=a):(o=s,i=a+k+14,r="middle");y.push({x:o,y:i,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:p,labels:y}}(t,e,n,o,i,r);case"treemap":case"partition":return function(t,e,n,o){var i,r,s,a,l;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const a=o(mn(n,"nodeStyle"));let l=a.fill||Cn(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ln(e);l=t[n.depth%t.length]}const u={fill:l,stroke:a.stroke||(null===(i=e.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=jn(e.nodeLabel),i=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===i&&!h)continue;if("parent"===i&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=o(mn(c,"nodeStyle")).fill||Cn(e);if(e.colorByDepth&&void 0!==c.depth){const t=Ln(e);g=t[c.depth%t.length]}const p="string"==typeof g?Tn(g):null!==(l=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:p}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,i);case"circlepack":return function(t,e,n,o){var i,r,s,a,l,c,u,d,h,f;const g=[],p=[];for(const n of t){const t=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=t)continue;const l=o(mn(n,"nodeStyle"));let c=l.fill||Cn(e);if(e.colorByDepth&&void 0!==n.depth){const t=Ln(e);c=t[n.depth%t.length]}const u={fill:c,stroke:l.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=jn(e.nodeLabel);for(const i of t){const t=null!==(l=i.__radius)&&void 0!==l?l:5,r=n?n(i):i.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=o(mn(i,"nodeStyle")).fill||Cn(e);if(e.colorByDepth&&void 0!==i.depth){const t=Ln(e);a=t[i.depth%t.length]}if(s){const n="string"==typeof a?Tn(a):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";p.push({x:i.x,y:i.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else p.push({x:i.x,y:i.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:p}}(t,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function zn(t,e,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=e.x,o=e.y;t.x=o*Math.cos(n-Math.PI/2),t.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Rn(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Nn(t,e){var n;const o=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function Fn(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const Bn={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,o){const i=n.__hierarchyRoot;i&&function(t,e,n,o,i){var r,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),l=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=Fn(n);g.metaMap.clear(),o.length=0,i.length=0;const p=new Map;function y(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,x=y(l(t));o.push({id:x,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(x,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,u,d,p){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let b=0,x=0,k=0;for(;v>x;)x+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let v=0;b>v;v++){const x=c[Math.min(v,c.length-1)],k=m.slice(w,w+x);if(!k.length)break;const A=(v+1)/b,S={id:n,depth:d,data:e,parentId:n},_=p?u/h(S)*A:u*A,M=W().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=M(k),O=f(S);for(let e=0;k.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=y(l(c)),h=r+_*Math.sin(a),f=s+_*Math.cos(a)*O;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:_,angle:a,depth:d,parentId:n,eccentricity:O}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,_,d+1,!0)}w+=x}}(t,x,m,v,b,1,!1)}(i,o,n,t,e)},buildScene(t,e,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],p=[],y=[];if(!1!==n.orbitShowRings){const e=Fn(n),o=new Map;for(const e of t)o.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;i.has(n)||i.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:o}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,l=(i+1)/r*Math.PI*2;p.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*o,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(mn(e,"nodeSize")),o=d?d(mn(e,"nodeStyle")):{},c={fill:o.fill||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),n="object"==typeof t.target?t.target:m.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&p.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(mn(n,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;y.push({x:n.x,y:n.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:p,labels:y}},tick:(t,e,n,o,i)=>!1!==n.orbitAnimated&&(function(t,e){var n,o;const i=Fn(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const o=t.angle+a*l*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(o),e.y=n.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Wn={sankey:xn,force:kn,chord:Mn,tree:En,cluster:En,treemap:En,circlepack:En,partition:En,orbit:Bn};function In(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=Jt[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function Yn(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(o)%t.length])&&void 0!==n?n:"#4e79a7"}}function Hn(t,e){var n;const{columns:o,config:i,resolvePieceStyle:r}=t,s=[],a=Math.min(e.width,e.height)/2-4,l="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,u=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,d=null!=i.sweepAngle&&360>i.sweepAngle&&Object.keys(o).length>1&&(null!==(n=i.cornerRadius)&&void 0!==n?n:0)>0,h=Object.values(o);for(let t=0;h.length>t;t++){const e=h[t],n=c+e.pctStart*u,o=c+(e.pctStart+e.pct)*u,f=r(e.pieceData[0],e.name),g=0===t,p=t===h.length-1,y=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:n,endAngle:o},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:f,datum:e.pieceData,category:e.name});d&&(y.roundedEnds={start:g,end:p}),s.push(y)}return s}function Gn(t){var e,n,o;const i=t.length,r=t[0],s=t[i-1];return{n:i,min:r,q1:null!==(e=T(t,.25))&&void 0!==e?e:r,median:null!==(n=T(t,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(o=T(t,.75))&&void 0!==o?o:s,max:s,mean:t.reduce((t,e)=>t+e,0)/i}}const Xn={bar:function(t,e){var n,o,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,p="horizontal"===h,y=a.normalize,m=[];if(c){const t=new Set;for(const e of Object.values(s))for(const n of e.pieceData){const e=c(n);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=l(n),o.pieces.push(n)}let n=0;if(y)for(const t of e.values())n+=Math.abs(t.total);let o=0,i=0;for(const r of m){const s=e.get(r);if(!s)continue;let a=s.total;y&&n>0&&(a/=n);const l=u(s.pieces[0],c?r:t.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=d(0>a?i:o+a),n=0>a?d(i+a)-d(i):d(o)-d(o+a);f.push(jt(t.x,e,t.width,Math.abs(n),l,h,r)),0>a?i+=a:o+=a}else if(p){const e=d(0>a?i+a:o),n=0>a?d(i)-d(i+a):d(o+a)-d(o);f.push(jt(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?i+=a:o+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(n=t.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(b>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const n=(null===(i=e.datum)||void 0===i?void 0:i.category)||"";t.has(n)||t.set(n,[]),t.get(n).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,n;return(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)>=0}),n=e.filter(t=>{var e,n;return 0>(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=b),n.length>0&&(n.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=b)}}return f},clusterbar:function(t,e){const{scales:n,columns:o,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const g=h.length||1;for(const t of Object.values(o)){const e=t.width/g,n=.2*e,o=e-n,i=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";i.has(t)||i.set(t,[]),i.get(t).push(e)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),f=a(i,h[s]);if(d){const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(jt(r,Math.min(a,d),o,Math.abs(a-d),f,i,h[s]))}else{const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(jt(Math.min(a,d),r,Math.abs(d-a),o,f,i,h[s]))}}}}const p=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);p>0&&(t.roundedTop=p),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",i.gradientFill&&(t.fillGradient=i.gradientFill)}return u},point:function(t,e){var n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=t,{r:c,projection:u}=i,d=[],h="vertical"===u,f="radial"===u,g=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(r))for(const e of t.pieceData){const i=null!==(n=e.__rIndex)&&void 0!==n?n:0,r=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[i]||c,m=l(e,t.name),v=m.r||5;let b,x;if(f){const e=y+(t.pctStart+t.pct/2)*p,n=u(r);b=Math.cos(e)*n,x=Math.sin(e)*n}else h?(b=t.middle,x=u(r)):(b=u(r),x=t.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:e})}return d},swarm:function(t,e){const{scales:n,columns:o,getR:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const o=t.pieceData[n],a=i(o),u=r(o,t.name),d=u.r||4,h=(7919*n%100/100-.5)*e*.8,f=c?t.middle+h:s(a),g=c?s(a):t.middle+h;l.push({type:"point",x:f,y:g,r:d,style:u,datum:o})}}return l},pie:Hn,donut:Hn,boxplot:function(t,e){var n,o,i,r,s,a;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=t,{r:f,projection:g}=l,p=[],y="vertical"===g,m=!1!==u.showOutliers;for(const e of Object.values(c)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const c=l[0],u=l[l.length-1],g=null!==(n=T(l,.25))&&void 0!==n?n:c,v=null!==(o=T(l,.5))&&void 0!==o?o:(c+u)/2,b=null!==(i=T(l,.75))&&void 0!==i?i:u,x=b-g,k=g-1.5*x,w=b+1.5*x,A=null!==(r=l.find(t=>t>=k))&&void 0!==r?r:c,S=null!==(s=[...l].reverse().find(t=>w>=t))&&void 0!==s?s:u,_=h(e.pieceData[0],e.name),M=[];if(m)for(const t of e.pieceData){const n=d(t);if(k>n||n>w){const o=y?e.middle:f(n),i=y?f(n):e.middle;M.push({px:o,py:i,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(A),q1Pos:f(g),medianPos:f(v),q3Pos:f(b),maxPos:f(S),stats:{n:l.length,min:A,q1:g,median:v,q3:b,max:S,mean:l.reduce((t,e)=>t+e,0)/l.length},style:_,datum:e.pieceData,category:e.name,outliers:M}),m)for(const e of M)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:_.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var n,o,i;const{scales:r,columns:s,config:a,getR:l,resolveSummaryStyle:c}=t,{r:u,projection:d}=r,h=[],f="vertical"===d,g=a.bins||20,p=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],s=e[e.length-1],a=(s-r)/g||1,d=Array(g).fill(0);for(const t of e)d[Math.min(Math.floor((t-r)/a),g-1)]++;const y=Math.max(...d,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${u(r)}`;for(let e=0;g>e;e++){const n=u(r+(e+.5)*a);v+=` L ${t.middle+d[e]/y*m} ${n}`}v+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const n=u(r+(e+.5)*a);v+=` L ${t.middle-d[e]/y*m} ${n}`}v+=" Z"}else{v=`M ${u(r)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${u(r+(e+.5)*a)} ${t.middle-d[e]/y*m}`;v+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${u(r+(e+.5)*a)} ${t.middle+d[e]/y*m}`;v+=" Z"}const b=c(t.pieceData[0],t.name);let x;if(p&&e.length>=4){const a=null!==(n=T(e,.25))&&void 0!==n?n:r,l=null!==(o=T(e,.5))&&void 0!==o?o:(r+s)/2,c=null!==(i=T(e,.75))&&void 0!==i?i:s;x={q1Pos:u(a),medianPos:u(l),q3Pos:u(c),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(u(s),u(r)),width:t.width,height:Math.abs(u(s)-u(r))}:{x:Math.min(u(r),u(s)),y:t.x,width:Math.abs(u(s)-u(r)),height:t.width};h.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:x,stats:Gn(e),style:b,datum:t.pieceData,category:t.name})}return h},histogram:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l}=o,c=[],u=r.bins||25,d=r.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),f=h?+h[0]:void 0,g=h?+h[1]:void 0;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const n=null!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),i=(o-n)/u||1,r=Array(u).fill(0);for(const t of e)n>t||t>o||r[Math.min(Math.floor((t-n)/i),u-1)]++;const h=e.length,p=Math.max(...r,1),y=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===r[e])continue;const o=(d?r[e]/h:r[e]/p)*t.width*.9,s=l(n+e*i),a=l(n+(e+1)*i);c.push(jt(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,y,{bin:e,count:r[e],range:[n+e*i,n+(e+1)*i],category:t.name},t.name))}}return c},ridgeline:function(t,e){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l,projection:c}=o,u=[],d=r.bins||20,h="horizontal"===c,f=r.amplitude||1.5;for(const t of Object.values(i)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],i=e[e.length-1],r=(i-o)/d||1,c=Array(d).fill(0);for(const t of e)o>t||t>i||c[Math.min(Math.floor((t-o)/r),d-1)]++;const g=Math.max(...c,1),p=a(t.pieceData[0],t.name),y=t.width*f;let m="";if(h){const e=t.x+t.width;m=`M ${l(o)} ${e}`;for(let t=0;d>t;t++)m+=` L ${l(o+(t+.5)*r)} ${e-c[t]/g*y}`;m+=` L ${l(i)} ${e} Z`}else{const e=t.x;m=`M ${e} ${l(o)}`;for(let t=0;d>t;t++){const n=l(o+(t+.5)*r);m+=` L ${e+c[t]/g*y} ${n}`}m+=` L ${e} ${l(i)} Z`}const v=h?{x:Math.min(l(o),l(i)),y:t.x,width:Math.abs(l(i)-l(o)),height:t.width}:{x:t.x,y:Math.min(l(i),l(o)),width:t.width,height:Math.abs(l(i)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:Gn(e),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const n=i(e);if(!n)continue;const[o,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push(jt(n,t.x,i-n,t.width,u,e,t.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push(jt(t.x,n,t.width,i-n,u,e,t.name))}}return l},funnel:function(t,e){var n,o,i,r,s,a,l,c;const{columns:u,getR:d,getStack:h,resolvePieceStyle:f}=t,g=[],p=e.width/2,y=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const b=[],x=new Set;for(const t of m)for(const e of t.pieceData){const t=h?h(e):"_default";x.has(t)||(x.add(t),b.push(t))}const k=b.length>1&&"_default"!==b[0],w=[];let A=0;for(const t of m){const e=new Map;let n=0;for(const o of t.pieceData){const t=h?h(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=d(o);i.total+=r,i.pieces.push(o),n+=r}w.push({col:t,groups:e,stepTotal:n}),k||n>A&&(A=n)}if(k)for(const t of w){let e=0,n=0;for(let o=0;b.length>o;o++){const i=t.groups.get(b[o]);i&&(o%2==0?e+=i.total:n+=i.total)}const o=Math.max(e,n);o>A&&(A=o)}if(0===A)return g;const S=new Map;for(const t of b){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const _=w[0].stepTotal,M=k?.95*p:.9*e.width,P=v().domain([0,A]).range([0,M]),O=null!==(o=t.config.connectorOpacity)&&void 0!==o?o:.3;let T=new Map;for(let e=0;w.length>e;e++){const n=w[e],o=n.col,u=0===e,d=o.width,h=.55*d,m=o.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of b){const o=n.groups.get(e);o&&(t+=P(o.total))}let e=p,i=p;for(let r=0;b.length>r;r++){const a=b[r],l=n.groups.get(a);if(!l)continue;const c=P(l.total),d=r%2==0,x=d?e:i-c;d?e+=c:i-=c;const k=f(l.pieces[0],a),w=null!==(s=S.get(a))&&void 0!==s?s:l.total,A=w>0?l.total/w*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:A,__funnelStep:o.name,__funnelIsFirstStep:u,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:a});y&&(0===r&&(_.__funnelStepLabel=o.name,_.__funnelStepLabelX=p,_.__funnelStepLabelY=m,_.__funnelRowWidth=t),_.__funnelValueLabelX=x+c/2,_.__funnelValueLabelY=m,_.__funnelBarW=c),g.push(jt(x,m,c,h,k,_,a)),v.set(a,{x:x,y:m,w:c,h:h})}}else{const t=n.stepTotal,e=P(t),s=p-e/2,a=b[0],l="_default"!==a,c=null!==(r=null===(i=n.groups.get(a))||void 0===i?void 0:i.pieces[0])&&void 0!==r?r:o.pieceData[0],d=l?a:o.name,x=f(c,d),k=_>0?t/_*100:0,w=Object.assign(Object.assign({},c),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:u,category:l?a:o.name});y&&(w.__funnelStepLabel=o.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=m,w.__funnelRowWidth=e,w.__funnelValueLabelX=p,w.__funnelValueLabelY=m,w.__funnelBarW=e),g.push(jt(s,m,e,h,x,w,d)),v.set(a,{x:s,y:m,w:e,h:h})}if(e>0&&T.size>0){const e=k?b:[b[0]];for(const i of e){const e=T.get(i),r=v.get(i);if(!e||!r)continue;const s=(()=>{const t=n.groups.get(i);return f(t?t.pieces[0]:o.pieceData[0],"_default"===i?o.name:i)})(),u={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:O},datum:null!==(c=null===(l=n.groups.get(i))||void 0===l?void 0:l.pieces[0])&&void 0!==c?c:o.pieceData[0],category:"_default"===i?o.name:i};g.push(u)}}T=v}return g},"bar-funnel":function(t,e){var n,o,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=t,d=[],h=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===h.length)return d;const f=[],g=new Set;for(const t of h)for(const e of t.pieceData){const t=l?l(e):"_default";g.has(t)||(g.add(t),f.push(t))}const p=f.length>1&&"_default"!==f[0],y=[];for(const t of h){const e=new Map;let n=0;for(const o of t.pieceData){const t=l?l(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=a(o);i.total+=r,i.pieces.push(o),n+=r}y.push({col:t,groups:e,stepTotal:n})}const m=new Map;for(const t of f){const e=null===(n=y[0])||void 0===n?void 0:n.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const v=u.r,b=p?f.length:1,x=p?.15:0;for(let t=0;y.length>t;t++){const e=y[t],n=e.col,o=0===t,s=t>0?y[t-1]:null,a=n.width/b,l=a*x,u=a-l;for(let t=0;f.length>t;t++){const h=f[t],g=e.groups.get(h);if(!g)continue;const y=g.total,b=null!==(i=m.get(h))&&void 0!==i?i:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,A=o?0:Math.max(0,w-y),S=n.x+t*a+l/2,_=v(y),M=v(0)-_,P=c(g.pieces[0],p?h:n.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(y+A)});if(d.push(jt(S,_,u,M,P,O,p?h:n.name)),A>0){const t=v(y+A),e=_-t,o=Object.assign({},P),i=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(jt(S,t,u,e,o,i,p?h:n.name))}}}return d},swimlane:function(t,e){var n;const{scales:o,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=o,u=[],d="horizontal"===c,h=t.config.gradientFill,f=d?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(n=g.opacity)&&void 0!==n?n:1,[o,r]=l.range(),s=Math.min(o,r),a=Math.abs(r-o);for(const n of Object.values(i)){const o={fill:t,opacity:e},i=d?jt(s,n.x,a,n.width,o,null,"__track__"):jt(n.x,s,n.width,a,o,null,"__track__");u.push(i)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(i)){let e=0;const n=u.length;for(const n of t.pieceData){const o=Math.abs(r(n));if(0===o)continue;const i=s?s(n):t.name,c=a(n,i);let g;if(d){const r=l(e),s=l(e+o);g=jt(r,t.x,s-r,t.width,c,n,i)}else{const r=l(e+o),s=l(e);g=jt(t.x,r,t.width,s-r,c,n,i)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),e+=o}if(p>0&&u.length>n){const t=u.slice(n),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:d?(e.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return u}};class qn{constructor(t){this.rExtent=new _t,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new St(t.windowSize),this.getO=zt(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>Dt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new _t)):(this.getR=Dt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=zt(t.stackBy),this.getGroup=zt(t.groupBy),this.getColor=zt(t.colorAccessor),this.getConnector=zt(t.connectorAccessor),this.getDataId=zt(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new St(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const n="function"==typeof e?e(t):t[e];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(t){const{config:e,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),i=e.projection||"vertical",r=e.oExtent||this.resolveCategories(o),s=this.computeValueDomain(o,r),a="horizontal"===i,l="radial"===i,c=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===i?t.width:t.height):.1));let u,d;if(l){u=k().domain(r).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,o=e.innerRadius||0;d=v().domain(s).range([o,n])}else a?(u=k().domain(r).range([0,t.height]).padding(c),d=v().domain(s).range([0,t.width])):(u=k().domain(r).range([0,t.width]).padding(c),d=v().domain(s).range([t.height,0]));this.scales={o:u,r:d,projection:i},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,i)=>{var r;const s=this.rExtents[i];s.dirty&&s.recalculate(n,o);let[l,c]=s.extent;l===1/0&&(l=0,c=1);const u=null!==(r=e.extentPadding)&&void 0!==r?r:.05,d=c-l,h=d>0?d*u:1;return l-=h,c+=h,l>0&&(l=0),a?v().domain([l,c]).range([0,t.width]):v().domain([l,c]).range([t.height,0])}):[];let h=o;this.rAccessors.length>1&&(h=o.flatMap(t=>this.rAccessors.map((e,n)=>Object.assign(Object.assign({},t),{__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(h,r,u,i,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(e)?e[t]:e;return"string"==typeof n?n:"value"+t}resolveCategories(t){const e=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let i=null;if(n){i=new Set;for(const e of t)i.add(this.getO(e))}const r=i?Array.from(this.categories).filter(t=>i.has(t)):Array.from(this.categories);if(n&&void 0===o){const t=Math.max(50,3*i.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;i.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===o)return r;if("function"==typeof o)return r.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var n,o,i,r,s;const a=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,n=new Map;for(const o of t){const t=this.getO(o),i=this.getR(o);0>i?n.set(t,(n.get(t)||0)+i):e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t);for(const t of n.values())c>t&&(c=t)}else if("bar"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=this.getR(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),c>t&&(c=t)}else if("swimlane"===a){const e=new Map;for(const n of t){const t=this.getO(n),o=Math.abs(this.getR(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const t=u-c,e=t>0?t*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[c,u]}buildColumns(t,e,n,o,i){var r;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=0;if("radial"===o)for(const e of t)l+=Math.abs(this.getR(e));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let t=0;for(const n of e){const e=a.get(n)||[];let o;o="string"==typeof c?e.reduce((t,e)=>t+(Number(e[c])||0),0):c(e),u.set(n,o),t+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*e.length;if(t>0)for(const[e,n]of u)u.set(e,n/t*r)}let d=0,h=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),i=l>0?o/l:0;let c,f;u?(c=h,f=u.get(t)||n.bandwidth(),h+=f+n.padding()*n.step()):(c=null!==(r=n(t))&&void 0!==r?r:0,f=n.bandwidth()),s[t]={name:t,x:c,y:0,width:f,middle:c+f/2,padding:n.padding()*n.step(),pieceData:e,pct:i,pctStart:d},d+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){var n,o;if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(t,e);let r;try{r=this.config.customLayout(i)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(n=r.overlays)&&void 0!==n?n:null,null!==(o=r.nodes)&&void 0!==o?o:[]}this.customLayoutOverlays=null;const i=this.getSceneContext(),r=Xn[this.config.chartType];let s=r?r(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var n,o;const{scales:i,config:r,getConnector:s,getO:a}=t;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=s(e);if(!n)continue;let o,i;"point"===t.type?(o=t.x,i=t.y):(o=t.x+t.w/2,i=t.y+("vertical"===c?0:t.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:o,y:i,datum:e,category:a(e)})}const d=i.o.domain(),h=r.connectorStyle;for(const[e,i]of u)if(i.length>=2){i.sort((t,e)=>d.indexOf(t.category)-d.indexOf(e.category));for(let r=0;i.length-1>r;r++){const s=i[r],a=i[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:e})}}return l}(i,s);s=[...t,...s]}return s}buildLayoutContext(t,e){var n,o,i;const r=this.config,s=null!==(n=r.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},a=In(r.colorScheme,r.themeCategorical,ee),l=this.scales;return{data:t,scales:{o:l.o,r:l.r,projection:l.projection},dimensions:{width:e.width,height:e.height,margin:s,plot:"radial"===l.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(o=r.themeSemantic)&&void 0!==o?o:{},categorical:[...a]},resolveColor:Yn(a),config:null!==(i=r.layoutConfig)&&void 0!==i?i:{}}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(t,e);return n&&!n.fill&&e?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(e)}):n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ee,o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?re(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,n="function"==typeof e,o=n?null:e||"category",i=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[o];let l=i.get(a);l||(l=[],i.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:i},i}rebuildPointQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,qn.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const n=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._pointQuadtree=w().x(t=>t.x).y(t=>t.y).addAll(n)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var n,o;if(!this.config.decay)return;const i=e.length;if(1>=i)return;const r=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,i),a=null!==(o=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(e);let u=null;for(const n of t){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const t=n.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let i=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const n=r-e;if(s>n){const t=1-n/s;t>i&&(i=t)}}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const i=r-o;s>i&&(n._pulseIntensity=1-i/s,n._pulseColor=a,n._pulseGlowRadius=l)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&n>e-o}synthesizeIntroPositions(){var t,e,n,o,i;this.prevPositionMap.clear();const r=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(n=this.scales)||void 0===n?void 0:n.projection);let l;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeKey(e,r);n&&("rect"===e.type?this.prevPositionMap.set(n,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===l&&(l=e.startAngle),this.prevPositionMap.set(n,{x:e.cx,y:e.cy,startAngle:l,endAngle:l,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var n,o,i;if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(n)||0;return e.set(n,o+1),`${n}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(i=t.category)&&void 0!==i?i:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let n=0;this.scene.length>n;n++){const o=this.scene[n],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,n,o,i,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let w=!1;const A=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const c=this.scene[t],u=this.getNodeKey(c,S);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(e=c.style.opacity)&&void 0!==e?e:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(i=d.w)&&void 0!==i?i:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const t=c.startAngle;c.startAngle=t,c.endAngle=t,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:t,endAngle:t,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!A.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(c=e.r)&&void 0!==c?c:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(d=e.w)&&void 0!==d?d:0,h:null!==(h=e.h)&&void 0!==h?h:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const n=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(p=e.endAngle)&&void 0!==p?p:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(y=e.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(b=e.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,category:t.slice(2),_targetStartAngle:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:ue(),duration:k})}advanceTransition(t){var e,n,o,i;if(!this.activeTransition)return!1;const r=le(t,this.activeTransition),s=ae(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;t.style.opacity=ce(i,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=ce(o.x,t._targetX,s),t.y=ce(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=ce(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=ce(i,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=ce(n.x,t._targetX,s),t.y=ce(n.y,t._targetY,s),void 0!==n.w&&(t.w=ce(n.w,t._targetW,s),t.h=ce(n.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:ce(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const n=this.prevPositionMap.get(e);n&&void 0!==n.startAngle&&(t.startAngle=ce(n.startAngle,t._targetStartAngle,s),t.endAngle=ce(n.endAngle,t._targetEndAngle,s))}}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getDataId,o=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{o(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const t of i)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,i}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,i=new Set;this.buffer.forEach((t,e)=>{n.has(o(t))&&i.add(e)});const r=this.buffer.update(t=>n.has(o(t)),e);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),i.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!Ct(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!Ct(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!Ct(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(Ct(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=zt(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const n=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,i=Array.isArray(n)?n:[n],r=Array.isArray(o)?o:[o];if(i.length!==r.length||i.some((t,e)=>!Ct(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>Dt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new _t)):(this.getR=Dt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!Ct(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?zt(this.config.stackBy):void 0),"groupBy"in t&&!Ct(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?zt(this.config.groupBy):void 0),"colorAccessor"in t&&!Ct(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?zt(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!Ct(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?zt(this.config.connectorAccessor):void 0)}}qn.QUADTREE_THRESHOLD=500;const Vn={mercator:mt,equalEarth:ht,albersUsa:yt,orthographic:pt,naturalEarth:gt,equirectangular:ft};function Un(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Zn(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Qn(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function Kn(t,e){if(2>t.length)return[t];const n=.4*e,o=[];let i=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>i.length||o.push(i),i=[r]):i.push(r)}return 2>i.length||o.push(i),o}function Jn(t,e,n=24){const o=e[0]-t[0],i=e[1]-t[1],r=Math.sqrt(o*o+i*i);if(0===r)return[t,e];const s=-i/r,a=o/r,l=Math.min(.3*r,80),c=(t[0]+e[0])/2+s*l,u=(t[1]+e[1])/2+a*l,d=[];for(let o=0;n>=o;o++){const i=o/n,r=1-i;d.push([r*r*t[0]+2*r*i*c+i*i*e[0],r*r*t[1]+2*r*i*u+i*i*e[1]])}return d}function to(t,e){if(2>t.length)return t;const n=e/2+1,o=[];for(let e=0;t.length>e;e++){const i=t[e];let r,s;0===e?(r=t[1][0]-i[0],s=t[1][1]-i[1]):e===t.length-1?(r=i[0]-t[e-1][0],s=i[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;o.push([i[0]+s/a*n,i[1]+-r/a*n])}return o}function eo(t,e,n,o,i){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const l=s/a,c=-r/a,u=i/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}class no{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t.slice()}initStreaming(t=500){this.pointBuffer=new St(t),this.timestampBuffer=new St(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const n of t)this.pointBuffer.push(n),this.timestampBuffer.push(e);this.lastIngestTime=e}pushLine(t){null!=t&&"object"==typeof t&&(this.lineData.push(t),this.version++)}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return;const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){for(const t of e)this.lineData.push(t);this.version++}}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),i=[];return this.lineData=this.lineData.filter(t=>!o.has(n(t)+"")||(i.push(t),!1)),i.length>0&&this.version++,i}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(n(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&n.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)n.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(n(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return ht();if("string"==typeof t){const e=Vn[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),ht())}if("object"==typeof t&&"type"in t){const e=Vn[t.type],n=e?e():ht();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=lt(this.projection),this.fitProjection(t),this.geoPath=lt(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null};const o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,n,o,i,r;const s=this.projection,a=this.config,l=[...this.areas],c=Un(a.xAccessor,"lon"),u=Un(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const t=d.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const h=Zn(a.lineDataAccessor);for(const t of this.lineData){const e=h(t);if(e&&e.length>0){const t=e.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==l.length){if(a.projectionExtent){const[[e,n],[o,i]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,n],[o,n],[o,i],[e,i],[e,n]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(n=a.fitPadding)&&void 0!==n?n:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,n=t.width*e,i=t.height*e;s.fitExtent([[n,i],[t.width-n,t.height-i]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(r=null===(i=s.rotate)||void 0===i?void 0:i.call(s))&&void 0!==r?r:[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=lt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=lt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;n&&n.rotate&&(n.rotate(t),this.geoPath=lt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,n;return null!==(n=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxPointRadius=t,no.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const n=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(n[o++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,n,o;const i=[],{config:r}=this,s=this.projection,a=this.geoPath,l=Un(r.xAccessor,"lon"),c=Un(r.yAccessor,"lat"),u=function(t){var e,n;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(n=t.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(r),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),h=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(r);if(r.graticule){const e=!0===r.graticule?{}:r.graticule,n=ct();e.step&&n.step(e.step);const o=a(n())||"";o&&i.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const n=a.centroid(t),o=a.bounds(t),s=a.area(t),l=Qn(r.areaStyle,t,u);i.push({type:"geoarea",pathData:e,centroid:n,bounds:o,screenArea:s,style:l,datum:t,interactive:!0})}const f=Zn(r.lineDataAccessor);for(const e of this.lineData){const n=f(e);if(!n||2>n.length)continue;let o=[];if("geo"===r.lineType){const t=Array(n.length);for(let e=0;n.length>e;e++)t[e]=[l(n[e]),c(n[e])];for(let e=0;t.length-1>e;e++){const n=t[e],i=t[e+1],r=ut(n,i)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=dt(n,i);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const n=s(l(t/a));null!=n&&o.push(n)}}}else for(let t=0;n.length>t;t++){const e=n[t],i=s([l(e),c(e)]);null!=i&&o.push(i)}if(2>o.length)continue;const a=Qn(r.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==n.length||2>o.length||"arc"!==r.flowStyle?2!==n.length||2>o.length||"offset"!==r.flowStyle||(o="geo"===r.lineType?to(o,u):eo(o[0],o[o.length-1],0,0,u)):o=Jn(o[0],o[o.length-1]);const h=Kn(o,t.width);if(h.length>1)for(const t of h){if(2>t.length)continue;const n={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};i.push(n)}else i.push({type:"line",path:2>o.length&&h[0]||o,style:a,datum:e})}const g=this.getPoints(),p=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,y=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=y>0?y*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],x=[(null!==(n=b[0])&&void 0!==n?n:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],n=l(e),o=c(e);if(null!=m&&ut([n,o],x)>m)continue;const a=s([n,o]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},h),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};i.push(d)}return i}applyCartogramTransform(t,e){var n,o,i;const r=this.scene.filter(t=>"point"===t.type);if(2>r.length)return;const s=null!==(n=t.strength)&&void 0!==n?n:1;if(0===s)return;const a=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&a(e.datum)+""==t.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=c.x,d=c.y,h=r.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),f=Math.max(...h,1),g=Math.min(e.width,e.height)/2,p=v().domain([0,f]).range([0,g]);this.cartogramLayout={cx:u,cy:d,maxCost:f,availableRadius:g},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of r){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-u),n=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),o=l(t.datum),i=n+((isFinite(o)?p(o):n)-n)*s;t.x=u+Math.cos(e)*i,t.y=d+Math.sin(e)*i}const y=e.width/2,m=e.height/2,b=y-c.x,x=m-c.y;if(Math.abs(b)>.5||Math.abs(x)>.5)for(const t of r)t.x+=b,t.y+=x;this.cartogramLayout={cx:y,cy:m,maxCost:f,availableRadius:g};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of r)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const n=null===(o=e.datum)||void 0===o?void 0:o.source,r=null===(i=e.datum)||void 0===i?void 0:i.target;if(n&&r){const o=t.get(n+""),i=t.get(r+"");o&&i&&(e.path=[o,i])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let o=0;n.length>o;o++){const i=re(t,o,e);n[o]._decayOpacity=i,n[o].style=Object.assign(Object.assign({},n[o].style),{opacity:i})}}applyPulse(){var t,e;const n=this.config.pulse;if(!n||!this.timestampBuffer)return;const o=null!==(t=n.duration)&&void 0!==t?t:500,i=performance.now(),r=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;r.length>t&&s.length>t;t++){const a=i-s[t];o>a&&(r[t]._pulseIntensity=1-a/o,r[t]._pulseColor=n.color||"rgba(255,255,255,0.6)",r[t]._pulseGlowRadius=null!==(e=n.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const n=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<n}startTransition(t){var e,n;const o=null!==(n=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==n?n:300;if(0>=o)return;const i=new Map;for(const e of t)"point"===e.type&&e.pointId&&i.set(e.pointId,[e.x,e.y]);const r=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of r)if(t.pointId){const e=i.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=le(t,this.activeTransition),n=ae(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ce(t.x,t._targetX,n),t.y=ce(e,t._targetY,n)}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function oo(t){var e,n,o,i;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(o=t.br)&&void 0!==o?o:0)>0||(null!==(i=t.bl)&&void 0!==i?i:0)>0}function io(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}no.QUADTREE_THRESHOLD=500;const ro=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function so(t){var e,n;const{innerRadius:o,outerRadius:i,startAngle:r,endAngle:s}=t,a=0>=o;if(0>=(null!==(e=t.cornerRadius)&&void 0!==e?e:0)||!t.roundStart&&!t.roundEnd){if(a){const t=ro(i,r),e=ro(i,s);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${s-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=ro(i,r),e=ro(i,s),n=ro(o,s),l=ro(o,r),c=s-r>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${c} 1 ${e.x},${e.y} L${n.x},${n.y} A${o},${o} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=t.cornerRadius)&&void 0!==n?n:0,(i-o)/2));if(0===l)return so(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,i-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,o+l))),d=(s-r)/2,h=!!t.roundStart&&d>c,f=!!t.roundEnd&&d>c;if(!h&&!f)return so(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const g=r+(h?c:0),p=s-(f?c:0),y=r+(h?u:0),m=s-(f?u:0),v=ro(i,g),b=ro(i,p),x=(i-l)*Math.cos(c),k=ro(x,r),w=ro(x,s),A=a?null:ro(o,m),S=a?null:ro(o,y),_=a?0:(o+l)*Math.cos(u),M=a?null:ro(_,r),P=a?null:ro(_,s),O=p-g>Math.PI?1:0,T=a?0:m-y>Math.PI?1:0;let $="";if(h)$+=`M${k.x},${k.y}`,$+=` A${l},${l} 0 0 1 ${v.x},${v.y}`;else{const t=ro(i,r);$+=`M${t.x},${t.y}`}if(f)$+=` A${i},${i} 0 ${O} 1 ${b.x},${b.y}`,$+=` A${l},${l} 0 0 1 ${w.x},${w.y}`;else{const t=ro(i,s);$+=` A${i},${i} 0 ${O} 1 ${t.x},${t.y}`}if(a)$+=" L0,0";else{if(f)$+=` L${P.x},${P.y}`,$+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const t=ro(o,s);$+=` L${t.x},${t.y}`}if(h)$+=` A${o},${o} 0 ${T} 0 ${S.x},${S.y}`,$+=` A${l},${l} 0 0 1 ${M.x},${M.y}`;else{const t=ro(o,r);$+=` A${o},${o} 0 ${T} 0 ${t.x},${t.y}`}}return $+=" Z",$}const ao={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function lo(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function co(n,o,i){var r,s,a,l,c;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const i="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:i,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+o)}case"area":{const c=n;if(0===c.topPath.length)return null;const u=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const n=`${i?i+"-":""}area-clip-${o}`;return e("g",{children:[t("defs",{children:t("clipPath",{id:n,children:t("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t("path",{d:u,fill:lo(c.style.fill),fillOpacity:null!==(s=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==s?s:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${n})`})]},"area-"+o)}return t("path",{d:u,fill:lo(c.style.fill),fillOpacity:null!==(l=null!==(a=c.style.fillOpacity)&&void 0!==a?a:c.style.opacity)&&void 0!==l?l:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+o)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:lo(e.style.fill),opacity:null!==(c=e.style.opacity)&&void 0!==c?c:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+o)}case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:lo(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+o)}case"heatcell":{const i=n;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const n=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[r,s,a]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),l=.299*r+.587*s+.114*a>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return e("g",{children:[t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),t("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:c+"px",children:n})]},"heatcell-"+o)}return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+o)}case"candlestick":{const i=n,r=Math.min(i.openY,i.closeY),s=Math.max(Math.abs(i.openY-i.closeY),1),a=i.isUp?i.upColor:i.downColor;return e("g",{children:[t("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),t("rect",{x:i.x-i.bodyWidth/2,y:r,width:i.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+o)}default:return null}}function uo(n,i){var r,s,a,l,c;const u=("category"in n?n.category:void 0)||("group"in n?n.group:void 0)||"",d=t=>`ord-${n.type}-${u}-${i}-${t}`,h=`ord-${n.type}-${u}-${i}`;switch(n.type){case"rect":{const i=n,r=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(h)+"-grad",s=function(e,n){const o=e.fillGradient;if(!o)return null;let i=e.x,r=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,a=e.y):"right"===e.roundedEdge?(i=e.x+e.w,r=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(i=e.x,r=e.y,s=e.x+e.w,a=e.y);const l=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let n=0;e.length>n;n++)l.push(t("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=lo(e.style.fill);l.push(t("stop",{offset:0,stopColor:n,stopOpacity:o.topOpacity},"0")),l.push(t("stop",{offset:1,stopColor:n,stopOpacity:o.bottomOpacity},"1"))}return t("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(i,r),a=s?`url(#${r})`:lo(i.style.fill);if(i.cornerRadii&&oo(i.cornerRadii)){const n=function(t){const{x:e,y:n,w:o,h:i}=t,{tl:r,tr:s,br:a,bl:l}=io(t);let c=`M${e+r},${n}`;return c+=` L${e+o-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+o},${n+s}`),c+=` L${e+o},${n+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+o-a},${n+i}`),c+=` L${e+l},${n+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+i-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(i);return e(o.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:n,fill:a,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}if(i.roundedTop&&i.roundedTop>0){const n=Math.min(i.roundedTop,i.w/2,i.h/2),{x:r,y:l,w:c,h:u}=i;let d;switch(i.roundedEdge){case"right":d=`M${r},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r},${l+u} Z`;break;case"left":d=`M${r+c},${l} L${r+n},${l} A${n},${n} 0 0 0 ${r},${l+n} L${r},${l+u-n} A${n},${n} 0 0 0 ${r+n},${l+u} L${r+c},${l+u} Z`;break;case"bottom":d=`M${r},${l} L${r+c},${l} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r+n},${l+u} A${n},${n} 0 0 1 ${r},${l+u-n} Z`;break;default:d=`M${r},${l+u} L${r},${l+n} A${n},${n} 0 0 1 ${r+n},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u} Z`}return e(o.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:d,fill:a,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}return e(o.Fragment,{children:[s&&t("defs",{children:s}),t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:a,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:lo(e.style.fill),opacity:null!==(r=e.style.opacity)&&void 0!==r?r:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},h)}case"wedge":{const e=n;let o;if(e.roundedEnds)o=so({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundedEnds.start,roundEnd:e.roundedEnds.end});else{const t=B().innerRadius(e.innerRadius).outerRadius(e.outerRadius).startAngle(e.startAngle+Math.PI/2).endAngle(e.endAngle+Math.PI/2);e.cornerRadius&&t.cornerRadius(e.cornerRadius),o=t(ao)||""}return t("path",{d:o,transform:`translate(${e.cx},${e.cy})`,fill:lo(e.style.fill),stroke:e.style.stroke,strokeWidth:e.style.strokeWidth,opacity:e.style.opacity},h)}case"boxplot":{const o=n,i=o.columnWidth/2;return e("g","vertical"===o.projection?{children:[t("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:o.x-i,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:lo(o.style.fill),fillOpacity:null!==(s=o.style.fillOpacity)&&void 0!==s?s:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-i,y1:o.medianPos,x2:o.x+i,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.x-.5*i,y1:o.minPos,x2:o.x+.5*i,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.x-.5*i,y1:o.maxPos,x2:o.x+.5*i,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-i,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:lo(o.style.fill),fillOpacity:null!==(a=o.style.fillOpacity)&&void 0!==a?a:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.medianPos,y1:o.y-i,x2:o.medianPos,y2:o.y+i,stroke:o.style.stroke||"#333",strokeWidth:2}),t("line",{x1:o.minPos,y1:o.y-.5*i,x2:o.minPos,y2:o.y+.5*i,stroke:o.style.stroke||"#333",strokeWidth:1}),t("line",{x1:o.maxPos,y1:o.y-.5*i,x2:o.maxPos,y2:o.y+.5*i,stroke:o.style.stroke||"#333",strokeWidth:1})]},h)}case"violin":{const e=n,o=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:lo(e.style.fill),fillOpacity:null!==(l=e.style.fillOpacity)&&void 0!==l?l:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},d("path"))];if(e.iqrLine&&e.bounds){const n=e.bounds,i=n.x+n.width/2,r=n.y+n.height/2;n.height>n.width?o.push(t("line",{x1:i,y1:e.iqrLine.q1Pos,x2:i,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},d("iqr")),t("circle",{cx:i,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},d("med"))):o.push(t("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},d("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},d("med")))}return t("g",{children:o},h)}case"connector":return t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:null!==(c=n.style.opacity)&&void 0!==c?c:.5},h);case"trapezoid":{const e=n,o=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:o,fill:lo(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},h)}default:return null}}const ho="undefined"==typeof window||"undefined"==typeof document;function fo(e){let n=null;const o=()=>(n||(n=c(null)),n),u=go(e);return[function({children:n,initialState:s}){const a=i(s),l=r(()=>go(e,a.current),[]),c=o();return t(c.Provider,{value:l,children:n})},t=>{var e;const n=o(),r=null!==(e=s(n))&&void 0!==e?e:u,c=i(t);c.current=t;const d=a(()=>c.current(r.getState()),[r]),h=a(()=>c.current(r.getState()),[r]);return l(r.subscribe,d,h)}]}function go(t,e){const n=new EventTarget;let o=Object.assign(Object.assign({},t(function(t){o=Object.assign(Object.assign({},o),t(o)),n.dispatchEvent(new Event("update"))})),null!=e?e:{});return{getState:()=>o,subscribe:function(t){return n.addEventListener("update",t),()=>n.removeEventListener("update",t)}}}function po(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function yo(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:mo})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const mo=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],vo={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},bo={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},xo={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:mo,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function ko(t,e){if("light"===e)return vo;if("dark"===e)return bo;if("high-contrast"===e)return xo;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?bo:vo;return yo(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return yo(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[wo,Ao]=fo(t=>({theme:vo,setTheme(e){t(t=>({theme:ko(t.theme,e)}))}})),So={light:vo,dark:bo,"high-contrast":xo,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function _o(t){if(!t)return vo;if("string"==typeof t){if("light"===t)return vo;if("dark"===t)return bo;if("high-contrast"===t)return xo;return So[t]||vo}const e="dark"===t.mode?bo:vo;return yo(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})}))}function Mo(t){var e,n,o,i;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(n=t.typography.legendSize)&&void 0!==n?n:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(i=t.typography.tickFontFamily)&&void 0!==i?i:t.typography.fontFamily}}function Po(n){const{categories:o,colorScheme:i,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=n;if(!o||0===o.length)return null;const d=function(t,e,n){const o=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:Bt;return m().domain(t).range(o)}(o,i,r),h="top"===s||"bottom"===s;let f,g;if("left"===s?(f=4,g=c.top):"top"===s?(f=c.left,g=u?32:8):"bottom"===s?(f=c.left,g=Math.min(l-c.bottom+38,l-16)):(f=a-c.right+10,g=c.top),h){let n=0;const i=o.map((o,i)=>{const s=n;return n+=22+6.5*o.length+8,e("g",{transform:`translate(${s},0)`,children:[t("rect",{width:14,height:14,fill:d(o),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily,children:o})]},"legend-"+i)});return t("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:i})}const p=o.map((n,o)=>e("g",{transform:`translate(0,${20*o})`,children:[t("rect",{width:14,height:14,fill:d(n),rx:2}),t("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n})]},"legend-"+o));return t("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:p})}function Oo(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=n(e);null!=t&&o.add(t+"")}return Array.from(o)}function To(t,e){return t.color||e.colors.annotation||e.colors.text}function $o(t,e,n){return null!=t.x&&e.x?e.x(t.x):n&&null!=t[n]&&e.x?e.x(t[n]):"number"==typeof t.x?t.x:null}function jo(t,e,n){return null!=t.y&&e.y?e.y(t.y):n&&null!=t[n]&&e.y?e.y(t[n]):"number"==typeof t.y?t.y:null}function Lo(e){const{annotations:n}=e;if(!n||0===n.length)return null;const o=[];for(let t=0;n.length>t;t++){const i=Co(n[t],t,e);i&&o.push(i)}return o.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function Co(n,o,i){var r,s,a,l;const{scales:c,layout:u,theme:d,xAccessor:h,yAccessor:f}=i;switch(n.type){case"y-threshold":{const s=n.value;if(null==s)return null;const a=To(n,d),l=n.label,h=n.labelPosition||"right",f=n.strokeDasharray||"6,4",g=null!==(r=n.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===i.projection&&c.r){const n=c.r(s);return null==n?null:e("g",{children:[t("line",{x1:n,y1:0,x2:n,y2:u.height,stroke:a,strokeWidth:g,strokeDasharray:f}),l&&t("text",{x:n+4,y:12,textAnchor:"start",fontSize:d.typography.tickSize,fill:a,fontFamily:d.typography.fontFamily,children:l})]},"ann-ythresh-"+o)}const p=c.y?c.y(s):c.r?c.r(s):null;return null==p?null:e("g",{children:[t("line",{x1:0,y1:p,x2:u.width,y2:p,stroke:a,strokeWidth:g,strokeDasharray:f}),l&&t("text",{x:"left"===h?4:"center"===h?u.width/2:u.width-4,y:p-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:d.typography.tickSize,fill:a,fontFamily:d.typography.fontFamily,children:l})]},"ann-ythresh-"+o)}case"x-threshold":{const i=n.value;if(null==i||!c.x)return null;const r=c.x(i);if(null==r)return null;const a=To(n,d),l=n.label,h=n.labelPosition||"top",f=null!==(s=n.strokeWidth)&&void 0!==s?s:1.5;return e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:u.height,stroke:a,strokeWidth:f,strokeDasharray:n.strokeDasharray||"6,4"}),l&&t("text",{x:r+4,y:"bottom"===h?u.height-4:"center"===h?u.height/2:12,textAnchor:"start",fontSize:d.typography.tickSize,fill:a,fontFamily:d.typography.fontFamily,children:l})]},"ann-xthresh-"+o)}case"band":{const i=null!=n.y0&&c.y?c.y(n.y0):null,r=null!=n.y1&&c.y?c.y(n.y1):null;if(null==i||null==r)return null;const s=Math.min(i,r),l=Math.abs(r-i),h=n.fill||To(n,d),f=null!==(a=n.opacity)&&void 0!==a?a:.1;return e("g",{children:[t("rect",{x:0,y:s,width:u.width,height:l,fill:h,opacity:f}),n.label&&t("text",{x:u.width-4,y:s+12,textAnchor:"end",fontSize:d.typography.tickSize,fill:h,fontFamily:d.typography.fontFamily,children:n.label})]},"ann-band-"+o)}case"category-highlight":{if(!n.category||!c.o)return null;const e=c.o(n.category);if(null==e)return null;const r=c.o.bandwidth?c.o.bandwidth():40,s=To(n,d),a=null!==(l=n.opacity)&&void 0!==l?l:.1;return t("rect","horizontal"===i.projection?{x:0,y:e,width:u.width,height:r,fill:s,opacity:a}:{x:e,y:0,width:r,height:u.height,fill:s,opacity:a},"ann-cathighlight-"+o)}case"label":case"text":{const{x:i,y:r}=function(t,e,n,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const n=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:$o(t,e,n),y:jo(t,e,o)}}(n,c,h,f);if(null==i||null==r)return null;const s=n.dx||0,a=n.dy||0,l=n.color||d.colors.text;return e("g",{children:["label"===n.type&&t("line",{x1:i,y1:r,x2:i+s,y2:r+a,stroke:d.colors.textSecondary,strokeWidth:1}),t("text",{x:i+s,y:r+a,textAnchor:n.textAnchor||"start",fontSize:n.fontSize||d.typography.labelSize,fill:l,fontFamily:d.typography.fontFamily,fontWeight:n.fontWeight,children:n.label||n.title})]},"ann-label-"+o)}default:return null}}function Do(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function Eo(t,e,n){const o=e.incoming[t.id],i=e.outgoing[t.id],r=[];for(const t of o)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of i)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:n.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>{var n,o;return t.time-e.time||(null!==(n=s[t.kind])&&void 0!==n?n:99)-(null!==(o=s[e.kind])&&void 0!==o?o:99)})},l=r.length?Math.min(...r.map(t=>t.time)):null,c=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),h=new Map;for(let t=1;d.length>t;t++)h.set(d[t],d[t-1]);const f=t=>{const e=h.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const g=[];let p=0,y=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?p:y);if(n>0){const e="top"===t.side?"bot":"top",o=Math.min(n,"top"===e?p:y);if(o>0){const i=f(t.time);g.push({time:i,delta:-o,kind:"transfer-out",side:e}),g.push({time:i,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?p-=o:y-=o,"top"===t.side?p+=o:y+=o,n-=o}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?p+=n:y+=n)}"top"===t.side?p-=e:y-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?p+=e:y+=e}r.push(...g),a();let m=0,v=0,b=0,x=0,k=0;const w=[],A=new Map;for(const t of r){if(w.push({t:t.time,topMass:m,botMass:v}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:v;A.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:v+=t.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let _=0;for(;w.length>_;){let t=_;for(;w.length>t+1&&w[t+1].t===w[_].t;)t++;S.push(w[_]);for(let e=_+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[e])}_=t+1}const M=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of i)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let O=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===O||t.systemOutTime>O)&&(O=t.systemOutTime);if(S.length>0){const t=S[S.length-1],e=Math.max(null!=M?M:-1/0,null!=O?O:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&S.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=S[0],o=Math.min(null!=c?c:1/0,null!=P?P:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&S.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:S,peak:b,topPeak:x,botPeak:k,localAttachments:A}}function zo(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Ro(t,e){return t.map(t=>({t:zo(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function No(t,e,n){const o=t.value*n;if("out"===t.kind){const i=t.sideMassBefore*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}const i=t.sideMassAfter*n;if("top"===t.side){const t=e-i;return[t,t+o]}const r=e+i;return[r-o,r]}function Fo(t,e){let n=0;for(let o=0;e.length>o;o++)for(let i=o+1;e.length>i;i++){const r=e[o],s=e[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&n++)}return n}function Bo(t,e){let n=0;for(const o of e)n+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return n}function Wo(t,e){return 1e3*Fo(t,e)+Bo(t,e)}function Io(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function Yo(t,e,n){t.length>8||n.length>40?(function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=Io(t,e),s=Wo(e,n);for(let a=0;o>a;a++){const o=Array(i).fill(0),a=Array(i).fill(0);for(const t of n){const n=e[t.source],i=e[t.target];o[n]+=i*(t.value||1),a[n]+=t.value||1,o[i]+=n*(t.value||1),a[i]+=t.value||1}const l=Array.from({length:i},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),c=l.map(e=>t[e]),u=new Map;l.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e);const d=Wo(e,n);if(s>d)s=d,r=Io(t,e);else if(d===s)break}!function(t,e,n){t.length=0;for(const e of n.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(n.map))e[t]=n.map[t]}(t,e,r)}(t,e,n,6),function(t,e,n,o=6){const i=t.length;if(1>=i)return;let r=Wo(e,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;i-1>s;s++){const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Wo(e,n);if(r>a)r=a,o=!0;else{const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,n,6)):function(t,e,n){const o=t.length;if(1>=o)return;const i=Object.assign({},e),r=Object.keys(i),s=Array.from({length:o},(t,e)=>e),a=s.slice(),l=Object.assign({},i);let c=s.slice(),u=1/0;const d=()=>{for(const t of r)l[t]=a[i[t]];const t=Wo(l,n);u>t&&(u=t,c=s.slice())},h=(t,e)=>{const n=s[t],o=s[e];s[t]=o,s[e]=n,a[n]=e,a[o]=t};d();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const p=c.map(e=>t[e]),y=new Map;c.forEach((t,e)=>y.set(t,e));for(const t of Object.keys(e))e[t]=y.get(e[t]);t.length=0;for(const e of p)t.push(e)}(t,e,n)}function Ho(t,e,n,o,i){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:p,packing:y,laneOrder:m,lifetimeMode:v="full"}=i,b={},x={};for(const e of t)b[e.id]=n[e.id].topPeak||0,x[e.id]=n[e.id].botPeak||0;const k="half"===v,w={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,n=Array.isArray(e.xExtent)?e.xExtent[1]:null;let i=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of o.outgoing[e.id]){i>t.startTime&&(i=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&i>t.systemInTime&&(i=t.systemInTime);const e=k?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of o.incoming[e.id]){const e=k?(t.startTime+t.endTime)/2:t.startTime;i>e&&(i=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}w[e.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},S=[];if("reuse"===y){const n=new Map;for(const e of t)n.set(e.id,0);const i=new Map;for(const e of t)i.set(e.id,0);for(const t of e)i.set(t.target,(null!==(r=i.get(t.target))&&void 0!==r?r:0)+1);const d=[];for(const e of t)0===(null!==(s=i.get(e.id))&&void 0!==s?s:0)&&d.push(e.id);for(;d.length;){const t=d.shift();for(const e of null!==(a=o.outgoing[t])&&void 0!==a?a:[]){const o=(null!==(l=n.get(t))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(e.target))&&void 0!==c?c:0)&&n.set(e.target,o),i.set(e.target,i.get(e.target)-1),0===i.get(e.target)&&d.push(e.target)}}const h=[...t].filter(t=>null!==w[t.id].start).sort((t,e)=>{var o,i;const r=null!==(o=n.get(t.id))&&void 0!==o?o:0,s=null!==(i=n.get(e.id))&&void 0!==i?i:0;return r!==s?r-s:w[t.id].start-w[e.id].start}),f=t.filter(t=>null===w[t.id].start);for(const t of[...h,...f]){const e=w[t.id];let n=-1;for(let t=0;S.length>t;t++){const o=S[t].occupants[S[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){n=t;break}}-1===n&&(S.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=S.length-1),S[n].occupants.push({id:t.id,end:null!==(u=null==e?void 0:e.end)&&void 0!==u?u:-1/0}),S[n].peak.topPeak=Math.max(S[n].peak.topPeak,b[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,x[t.id]),A[t.id]=n}}else t.forEach((t,e)=>{var n,o;S.push({occupants:[{id:t.id,end:null!==(o=null===(n=w[t.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-1/0}],peak:{topPeak:b[t.id],botPeak:x[t.id]}}),A[t.id]=e});let _=null,M=null,P=null,O=null;const T=()=>{_=Fo(A,e),P=Bo(A,e)},$=()=>{M=Fo(A,e),O=Bo(A,e)};"crossing-min"===m?(T(),Yo(S,A,e),$()):"inside-out"===m?(T(),function(t,e){const n=t.length;if(1>=n)return;const o=t=>t.peak.topPeak+t.peak.botPeak,i=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let t=1;i.length>t;t++)t%2==1&&n>l||0>a?r[l++]=i[t].idx:r[a--]=i[t].idx;const c=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e)}(S,A),$()):"crossing-min+inside-out"===m&&(T(),Yo(S,A,e),function(t,e,n){const o=t.length;if(1>=o)return;const i=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((o-1)/2);let s=Wo(e,n);for(const{slot:a}of i){const i=t.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=t[i];t.splice(i,1),t.splice(l,0,c);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(l>i){for(let t=i+1;l>=t;t++)u.set(t,t-1);u.set(i,l)}else{for(let t=l;i>t;t++)u.set(t,t+1);u.set(i,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=Wo(e,n);if(d>s){const n=t[l];t.splice(l,1),t.splice(i,0,n);const r=new Map;for(let t=0;o>t;t++)r.set(t,t);if(i>l){for(let t=l+1;i>=t;t++)r.set(t,t-1);r.set(l,i)}else{for(let t=i;l>t;t++)r.set(t,t+1);r.set(l,i)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(S,A,e),$());const j=S.map(t=>{const e=new Map;for(const o of t.occupants){const t=n[o.id];if(t)for(const n of t.samples){const t=e.get(n.t)||{top:0,bot:0};e.set(n.t,{top:Math.max(t.top,n.topMass),bot:Math.max(t.bot,n.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),L=(t,e)=>{let n={top:0,bot:0};for(const[o,i]of t){if(o>e)break;n=i}return n},C=[];for(let t=0;S.length-1>t;t++){const e=j[t],n=j[t+1],o=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let i=0;for(const t of o){const o=L(e,t),r=L(n,t);o.bot+r.top>i&&(i=o.bot+r.top)}C.push(i)}const D=[];let E=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;S.length>0&&D.push(E);for(let t=1;S.length>t;t++)E+=C[t-1]*p+g,D.push(E);if(S.length>0&&(E+=S[S.length-1].peak.botPeak*p+g),E>f){const t=f/E;for(let e=0;D.length>e;e++)D[e]*=t}const z=0===S.length?0:S[0].peak.topPeak+C.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,R={};for(const e of t)R[e.id]=D[A[e.id]];return{effectiveSlotsHeight:z,centerlines:R,laneLifetime:w,slots:S,slotByNode:A,slotCenter:D,crossingsBefore:_,crossingsAfter:M,lengthBefore:P,lengthAfter:O}}function Go(t){const{nodes:e,edges:n,domain:o,plotW:i,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:l,layoutOpts:c}=t,u=function(t,e,n){const o=[],i=new Set(t.map(t=>t.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)i.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),i.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,n,o),d=x().domain(o).range([0,i]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(t,e,n){var o;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(t,e){const n={},o={};for(const e of t)n[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:o}}(t,e),u=function(t,e,n,o="value"){const i="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const n=new Map;for(const o of t){const t=o[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=n.get(t);i.edges.push(o),i.total+=o.value,i.earliestStart=Math.min(i.earliestStart,o.startTime),i.latestEnd=Math.max(i.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(t,n)=>"target"===e?t.earliestStart-n.earliestStart:t.latestEnd-n.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:i);return s};for(const e of t){const t=n.outgoing[e.id],o=n.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=n});else if(0===t.length)a(o,"source").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=n});else{const e=a(o,"source"),n=a(t,"target"),i=Math.max(e.length,n.length);for(let t=0;i>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=o;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,r);let d={};for(const e of t)d[e.id]=Eo(e,c,u);const h=Ho(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),f=new Set;for(const t of e){const e=h.slotByNode[t.source],n=h.slotByNode[t.target];if(void 0===e||void 0===n)continue;const o=u.get(t.id);e!==n?e>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],o=new Set(t.map(t=>u.get(t.id).sourceSide)),i=new Set(n.map(t=>u.get(t.id).targetSide));if(1===o.size&&n.length>0){const t=[...o][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(u.get(e.id).targetSide=t)}if(1===i.size&&t.length>0){const e=[...i][0];for(const n of t)h.slotByNode[n.source]===h.slotByNode[n.target]&&(u.get(n.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],n=c.outgoing[e.id];if(0===t.length||0===n.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===u.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===u.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},i=(t,e)=>{const i=o(),r="top"===t?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===e?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=n.filter(e=>!f.has(e.id)&&u.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=e,!0)};let r=n.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const e of t)d[e.id]=Eo(e,c,u);const g=Ho(t,e,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),p=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),m=p>0?Math.max(0,(i-y*(g.slots.length+1))/p):1,v=Ho(t,e,d,c,{plotH:i,padding:y,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:y,compressedPadding:12>y,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(e,n,Object.assign({plotH:r},c)),{centerlines:f,nodeData:g,valueScale:p}=h,y=[],m=[];e.forEach((t,e)=>{var i;const r=g[t.id];if(!r||0===r.samples.length)return;const s=function(t,e,n,o,i){if(0===t.length)return null;const r=Ro(t,i),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${o(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${o(r[t].t)},${s(t)}`;l+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${o(r[t].t)},${a(t)}`;return l+" Z"}(r.samples,f[t.id],p,d,o);if(!s)return;const a=Ro(r.samples,o),c=a.find(t=>t.topMass+t.botMass>0)||a[0],u=f[t.id]+(c.botMass-c.topMass)*p/2,m=l(t.id,e),v=function(t,e,n,o,i){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=Ro(r.samples,i),c=l.find(t=>t.topMass+t.botMass>0)||l[0],u=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],d=o(c.t),h=o(u.t),f=t=>o(zo(t,i)),g=[],p=(t,e,n,o)=>`M${t},${e} L${n},${e} L${n},${o} L${t},${o} Z`;for(const n of e){if(n.source===t&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const t=r.localAttachments.get(n.id);if(t&&"out"===t.kind&&n.startTime>n.systemInTime){const e=f(n.systemInTime),o=f(n.startTime),i=e-20,r=Math.max(d,i);if(o>r){const[n,l]=No(t,a,s);g.push({pathD:p(r,n,o,l),x0:i,x1:e,from:0,to:1})}}}if(n.target===t&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const t=r.localAttachments.get(n.id);if(t&&"in"===t.kind&&n.systemOutTime>n.endTime){const e=f(n.systemOutTime),o=f(n.endTime),i=e+20,r=Math.min(h,i);if(r>o){const[n,l]=No(t,a,s);g.push({pathD:p(o,n,r,l),x0:e,x1:i,from:1,to:0})}}}}return g}(t.id,n,h,d,o);y.push(Object.assign(Object.assign({id:t.id,pathD:s,fill:m,stroke:m,strokeWidth:.5},v.length>0&&{gradientStubs:v}),{rawDatum:null!==(i=t.__raw)&&void 0!==i?i:t,labelX:d(c.t)-4,labelY:u,labelText:t.id}))});const v=new Map;return e.forEach((t,e)=>v.set(t.id,e)),n.forEach(t=>{var e,n,i,r;const c=null===(e=g[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=g[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!c||!u)return;const h=null!==(i=v.get(t.source))&&void 0!==i?i:0,y=l(t.source,h),b=function(t,e,n,o,i,r,s,a){const l=i,c=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(c(t.time)),d=r(c(n.time)),h=t.value*l,f=n.value*l,g=t.sideMassBefore*l,p=n.sideMassAfter*l;let y,m,v,b;"top"===t.side?(y=e-g,m=y+h):(m=e+g,y=m-h),"top"===n.side?(v=o-p,b=v+f):(b=o+p,v=b-f);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:y,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,f[t.source],u,f[t.target],p,d,s,o),{pathD:x,bezier:k}=hn(b);m.push({id:t.id,pathD:x,fill:y,opacity:a,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:h,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:d}}const Xo=t=>{var e,n;const{bands:o=[],ribbons:i=[],showLabels:r=!0}=t.config,s=[];for(const t of i)s.push(Object.assign(Object.assign({type:"bezier",pathD:t.pathD},t.bezier&&{bezierCache:t.bezier}),{style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}}));for(const t of o)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const n=t.gradientStubs[e];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of o)s.push({type:"bezier",pathD:t.pathD,style:Object.assign(Object.assign({},t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86}),{stroke:null!==(e=t.stroke)&&void 0!==e?e:t.fill,strokeWidth:null!==(n=t.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:t.rawDatum,id:t.id}});const a=r?o.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:s,labels:a}},qo=Object.freeze([]);function Vo(t){if(!t)return qo;let e=!1;for(let n=0;t.length>n;n++){const o=t[n];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}const Uo={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Zo(t,e){return"function"==typeof e?e(t):t[e]}function Qo(t,e){if(e)return e(t);if(null==t)return"";if("number"==typeof t){if(!Number.isFinite(t))return t+"";const e=Number.isInteger(t)?t:parseFloat(t.toPrecision(6));return Math.abs(e)>9999?e.toLocaleString():e+""}return t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function Ko(n={}){const{fields:o,title:i,format:r,style:s={},className:a=""}=n;return n=>{if(!n||"object"!=typeof n)return null;let l;const c=[];if(i){const t=Zo(n,i);l=Qo(t,r)}if(o&&o.length>0)o.forEach(t=>{let e,o,i;"string"==typeof t?(e=t,o=t,i=r):(e=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=Zo(n,o);c.push({label:e,value:Qo(s,i)})});else if(!i){const t=["value","y","name","id","label"];for(const e of t)if(void 0!==n[e]){l=Qo(n[e],r);break}if(!l){const t=Object.keys(n).filter(t=>!t.startsWith("_"));t.length>0&&(l=Qo(n[t[0]],r))}}const u=Object.assign(Object.assign({},Uo),s);return e("div",{className:("semiotic-tooltip "+a).trim(),style:u,children:[l&&t("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:l}),c.map((t,n)=>e("div",{style:{marginTop:0===n&&l?"4px":0},children:[t.label&&e("span",{children:[t.label,": "]}),t.value]},n))]})}}function Jo(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o+1>>1;e[i]>t?o=i-1:n=i}return e[n]}function ti(t,e){let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i]?n=i+1:o=i}return e[n]}function ei({width:e,height:n,totalWidth:o,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:p,streaming:y}){const m=i(null),v=i(null),b=i(d);b.current=d;const x=i(c);x.current=c;const k=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=i(k);w.current=k;const A=i(!1),S=i(null);return u(()=>{if(!m.current)return;const t=vt(m.current).select(".brush-g"),o="x"===l?bt():"y"===l?xt():kt();return o.extent([[0,0],[e,n]]),o.on("brush end",i=>{if(A.current)return;const r=x.current;if(!r)return;if(!i.selection)return S.current=null,void b.current(null);let s,a;if("x"===l){const[t,e]=i.selection;s=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(0)]}else if("y"===l){const[t,n]=i.selection;s=[r.x.invert(0),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,o]]=i.selection;s=[r.x.invert(t),r.x.invert(n)],a=[r.y.invert(o),r.y.invert(e)]}if("bin"===f&&"y"!==l&&("end"===i.type||"brush"===i.type&&p)){const e=w.current;e&&e.length>0?s=function(t,e){return 0===e.length?t:[Jo(t[0],e),ti(t[1],e)]}(s,e):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const n=r.x(s[0]),a=r.x(s[1]);if(A.current=!0,"x"===l)t.call(o.move,[n,a]);else if("xy"===l){const e=i.selection;t.call(o.move,[[n,e[0][1]],[a,e[1][1]]])}A.current=!1}const c={x:s,y:a};S.current=c,b.current(c)}),t.call(o),v.current=o,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{o.on("brush end",null),v.current=null}},[e,n,l,f,h,p]),u(()=>{if(!(y&&c&&v.current&&S.current))return;if(!m.current)return;if("y"===l)return;const t=S.current,e=c.x.domain()[0],n=vt(m.current).select(".brush-g");if(e>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);let o=t.x[0],i=!1;if(e>t.x[0]){if(o=e,"bin"===f){const t=w.current;t&&t.length>0?o=ti(e,t):h&&h>0&&(o=Math.ceil(e/h)*h)}if(o>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);i=!0}const r=c.x(o),s=c.x(t.x[1]);if(A.current=!0,"x"===l)n.call(v.current.move,[r,s]);else{const e=c.y(t.y[1]),o=c.y(t.y[0]);n.call(v.current.move,[[r,e],[s,o]])}if(A.current=!1,i){const e={x:[o,t.x[1]],y:t.y};S.current=e,b.current(e)}},[c,y,l,f,h]),t("svg",{ref:m,width:o,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class ni{constructor(t,e){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==e?void 0:e.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=Vo(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=Vo(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,o),bounded:!1}),e=o,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const o=t[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function oi(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:o.createElement(o.Fragment,null,...e)}function ii(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function ri(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function si(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function ai(t,e){const n=si(t);if(!n)return!1;const o=si(e);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}const li=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,ci=new WeakMap;let ui=0,di=!1,hi=null,fi=null,gi=null;function pi(t,e){var n,o;if(!e)return e;const i=li.exec(e);if(!i)return e;const r=t.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||e;!function(){if(di)return;if("undefined"==typeof window||"undefined"==typeof document)return;di=!0;const t=()=>{ui++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(hi=new MutationObserver(t),hi.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{fi=window.matchMedia("(prefers-color-scheme: dark)"),gi=t,"function"==typeof fi.addEventListener?fi.addEventListener("change",gi):"function"==typeof fi.addListener&&fi.addListener(gi)}catch(t){}}();let s=ci.get(r);s&&s.version===ui||(s={version:ui,map:new Map},ci.set(r,s));const a=s.map.get(e);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(o=i[2])||void 0===o?void 0:o.trim())||e;return s.map.set(e,l),l}function yi(t){switch(t){case"monotoneX":return Z;case"monotoneY":return U;case"cardinal":return V;case"catmullRom":return q;case"step":return X;case"stepBefore":return G;case"stepAfter":return H;case"basis":return Y;case"natural":return I;default:return null}}function mi(t,e,n){return null==e?n:"string"!=typeof e?e:pi(t,e)||n}function vi(t,e,n,o,i,r,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const a=t.createLinearGradient(o,i,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),d=t.createLinearGradient(o,i,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,o="#010203";try{t.fillStyle=o,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const i=t.fillStyle;if(t.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&e.trim().toLowerCase()!==o)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const r=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function bi(t,e,n,o,i,r){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const a=t.createLinearGradient(n,o,i,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}const xi=new WeakMap;function ki(t,e){const n=yi(e);if(!n)return t;const o=xi.get(t);if(o)return o;const i=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const o=[];let i=null;const r={moveTo(t,e){i=[t,e],o.push([t,e])},lineTo(t,e){i=[t,e],o.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!i)return i=[a,l],void o.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const d=i/n,h=1-d;o.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){i=[n,r],o.push([n,r])}};return Q().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),o}(t,n);return xi.set(t,i),i}function wi(t,e,n,o=30,i,r=0){let s=null;if(i){const t=function(t,e,n,o,i){const r=Math.max(o,i+5,12),s=e-r,a=e+r,l=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,i,r,h,f)=>{if(i>a||s>h||r>c||l>f)return!0;if(!t.length){let i=t;do{const t=i.data,r=t.x-e,s=t.y-n,a=Math.sqrt(r*r+s*s);ri(t.r,o)>=a&&d>a&&(u=t,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}(i,e,n,o,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(i)break;t=Si(r,e,n,o);break;case"line":t=_i(r,e,n,o);break;case"rect":if(null==r.datum)break;t=Pi(r,e,n);break;case"heatcell":t=Oi(r,e,n);break;case"area":if(!1===r.interactive)break;t=$i(r,e,n);break;case"candlestick":t=Ti(r,e,n)}t&&o>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function Ai(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=ji(t,e);if(0>o)return null;if(Math.abs(t[o][0]-e)>n)return null;let i=o,r=o;o>0&&t[o][0]>=e?(i=o-1,r=o):t.length-1>o&&(i=o,r=o+1);const[s,a]=t[i],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function Si(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>ri(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function _i(t,e,n,o=30){var i,r;if(0===t.path.length)return null;const s=ji(t.path,e);if(0>s)return null;const[a,l]=t.path[s];let c;if(t.path.length>1){let o=1/0;const i=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=i;r>=s;s++){const[i,r]=t.path[s],[a,l]=t.path[s+1],c=Mi(e,n,i,r,a,l);o>c&&(o=c)}c=o}else{const t=e-a,o=n-l;c=Math.sqrt(t*t+o*o)}const u=t.style,d=null!==(r=null!==(i=u.strokeWidth)&&void 0!==i?i:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:a,y:l,distance:c}}function Mi(t,e,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-o,2));let c=((t-n)*s+(e-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function Pi(t,e,n){const o=ii(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function Oi(t,e,n){const o=ii(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function Ti(t,e,n){const o=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>n||n>t.lowY+3)){const o=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,r=e-t.x,s=n-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function $i(t,e,n){if(0===t.topPath.length)return null;const o=ji(t.topPath,e);if(0>o)return null;const[i,r]=t.topPath[o],s=e-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:i,y:r,distance:l}}function ji(t,e){if(0===t.length)return-1;let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i][0]?n=i+1:o=i}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Li(t,e,n){const o=t.byGroup.get(e);let i=0,r=Math.abs(o[0].x-n.x);for(let t=1;o.length>t;t++){const e=Math.abs(o[t].x-n.x);r>e&&(r=e,i=t)}return o[i]._flatIndex}function Ci(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const Di={fill:e=>t("rect",{style:e,width:16,height:16}),line:e=>t("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function Ei(t,e,n,o){let i;return i="function"==typeof n?n(t):(0,Di[n])(o(t,e)),i}function zi(){return t("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ri(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Ni=(n,o,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=n,p=[];let y=0;const m=!(!o&&!i),v="isolate"===d||void 0===d&&null!=s;return g.forEach((n,d)=>{const b=Ei(n,d,h,f),x=Ri(n,r,s),k=s&&s.size>0&&s.has(n.label);p.push(e("g",{transform:`translate(0,${y})`,onClick:o?()=>o(n):void 0,onMouseEnter:i?()=>i(n):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:m?c===a&&d===l?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&v?k||!1:void 0,"aria-current":m&&!v&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:m?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o&&o(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+g.length)%g.length;u(c,n);const o=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:m?t=>{u(c,d),i&&i(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:m?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,k&&t(zi,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),y+=22}),p};function Fi({config:n,orientation:i="vertical",width:r=100}){const{colorFn:s,domain:a,label:l,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+o.useId();if("horizontal"===i){const n=12,o=Math.min(r,200),i=Math.max(0,(r-o)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:s(a[0]+n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),l&&t("text",{x:i+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("rect",{x:i,y:0,width:o,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:i,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])}),t("text",{x:i+o,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:s(a[1]-n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[l&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])})]})}function Bi(n){const{legendGroups:i,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical"}=n,[g,p]=o.useState(0),[y,m]=o.useState(0),v=o.useCallback((t,e)=>{p(t),m(e)},[]),b="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return e.forEach((e,f)=>{d+=5,h.push(t("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,e.label&&(d+=16,h.push(t("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d+=8),h.push(t("g",{className:"legend-item",transform:`translate(0,${d})`,children:Ni(e,o,i,r,s,a,l,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:i||[],width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:g,focusedItemIndex:y,onFocusedIndexChange:v,legendInteraction:c}):(({legendGroups:n,height:o,width:i,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h})=>{let f=0;const g=[];n.forEach((n,o)=>{let p=0;n.label&&(p+=16);const y=((n,o,i,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:p}=n,y=[];let m=0,v=0;const b=!(!o&&!i),x="isolate"===d||void 0===d&&null!=s;p.forEach((n,d)=>{const k=Ei(n,d,f,g),w=Ri(n,r,s),A=s&&s.size>0&&s.has(n.label),S=26+7*n.label.length;h&&h>0&&m>0&&m+S>h&&(v++,m=0),y.push(e("g",{transform:`translate(${m},${22*v})`,onClick:o?()=>o(n):void 0,onMouseEnter:i?()=>i(n):void 0,onMouseLeave:i?()=>i(null):void 0,tabIndex:b?c===a&&d===l?0:-1:void 0,role:b?"option":void 0,"aria-selected":b&&x?A||!1:void 0,"aria-current":b&&!x&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:b?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o&&o(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(d+("ArrowRight"===t.key?1:-1)+p.length)%p.length;u(c,n);const o=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:b?t=>{u(c,d),i&&i(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:b?t=>{i&&i(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:b?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[b&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*n.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,A&&t(zi,{}),t("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),m+=S});let k=0,w=0;for(const t of p){const e=26+7*t.label.length;h&&h>0&&w>0&&w+e>h?(k=Math.max(k,w),w=e):w+=e}k=Math.max(k,w);const A=v+1;return{items:y,offset:k,totalRows:A,totalHeight:22*A}})(n,r,s,a,l,c,u,o,d,h,i);p+=y.offset+5,g.push(Object.assign(Object.assign({label:n.label},y),{offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight})),f+=p+12});let p=f>i?0:Math.max(0,(i-f)/2);const y=[];return g.forEach((e,i)=>{const r=n[i];r.label&&(y.push(t("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+i)),p+=16),y.push(t("g",{className:"legend-item",transform:`translate(${p},0)`,children:e.items},"legend-group-"+i)),p+=e.offset+5,n[i+1]&&y.push(t("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(e.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+i)),p+=12}),t("g",{children:y})})({legendGroups:i||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:g,focusedItemIndex:y,onFocusedIndexChange:v,legendInteraction:c}),x=!(!r&&!s);return e("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==c&&(void 0!==c||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),b]})}function Wi(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Ii(t){return"object"==typeof t&&null!==t&&"gradient"in t}function Yi(e){const{legend:n,totalWidth:o,totalHeight:i,margin:r,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!n)return null;const f="top"===s||"bottom"===s;let g,p;return"left"===s?(g=4,p=r.top):"top"===s?(g=0,p=a?32:8):"bottom"===s?(g=0,p=i-r.bottom+50):(g=o-r.right+10,p=r.top),t("g",{transform:`translate(${g}, ${p})`,children:Ii(n)?t(Fi,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?o:100}):Wi(n)?t(Bi,{legendGroups:n.legendGroups,title:"",width:f?o:100,orientation:f?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function Hi(t){return"string"==typeof t?{type:t}:t}function Gi({orient:n,config:o,values:i,scale:s,size:a,length:l}){const c=function(t){var e,n,o,i,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=t.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=t.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(o),u="top"===n||"bottom"===n,d=r(()=>{if(0===i.length)return null;const o=s.domain(),r=a-8;if("boxplot"===c.type){const o=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const o=e[Math.floor(.25*n)],i=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(e[0],o-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(i);if(!o)return null;const{q1:a,median:l,q3:d,whiskerLow:h,whiskerHigh:f}=o,g=Math.min(.5*r,20),p=(r-g)/2+4;if(u){const o=s(a),i=s(d),r=s(l),u=s(h),y=s(f),m="top"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:v+m*(p+g/2),x2:y,y2:v+m*(p+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:v+m*p,x2:u,y2:v+m*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:y,y1:v+m*p,x2:y,y2:v+m*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(o,i),y:"top"===n?v-p-g:v+p,width:Math.abs(i-o),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?v-p-g:v+p,x2:r,y2:"top"===n?v-p:v+p+g,stroke:c.fill,strokeWidth:2})]})}{const o=s(a),i=s(d),r=s(l),u=s(h),y=s(f),m="left"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:v+m*(p+g/2),y1:u,x2:v+m*(p+g/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*p,y1:u,x2:v+m*(p+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*p,y1:y,x2:v+m*(p+g),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?v-p-g:v+p,y:Math.min(o,i),width:g,height:Math.abs(i-o),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?v-p-g:v+p,y1:r,x2:"left"===n?v-p:v+p+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=$().domain(o).thresholds(c.bins)(i);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,o)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/h*r;if(u){const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:r,y:"top"===n?-4-i:4,width:Math.max(a,.5),height:i,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}{const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:"left"===n?-4-i:4,y:Math.min(r,r+a),width:i,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},o)}})});if("violin"===c.type){const e=r/2+4,o=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*(r/2),a=s((t.x0+t.x1)/2);o.push(u?`${a},${"top"===n?-(e-i):e-i}`:`${"left"===n?-(e-i):e-i},${a}`)}for(let t=d.length-1;t>=0;t--){const i=d[t];if(null==i.x0||null==i.x1)continue;const a=i.length/h*(r/2),l=s((i.x0+i.x1)/2);o.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:o.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,o=null!=d[0].x0?s(d[0].x0):0;e.push(`M${o},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*r,i=s((t.x0+t.x1)/2);e.push(`L${i},${"top"===n?-o-4:o+4}`)}const i=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${i},${t}`),e.push("Z")}else{const t=0,o=null!=d[0].x0?s(d[0].x0):0;e.push(`M${t},${o}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*r,i=s((t.x0+t.x1)/2);e.push(`L${"left"===n?-o-4:o+4},${i}`)}const i=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${t},${i}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,s,c,a,l,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function Xi(t,e=120,n=8){if(!t)return[];const o=Math.max(1,Math.floor(e/n)),i=t.split(/\s+/),r=[];let s="";for(const t of i)s&&s.length+1+t.length>o?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function qi(t,e,n,o){return"curly"===t?o?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:o?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function Vi(n,o,i,r){if(!n)return t("g",{className:"annotation-note"});const{label:s,title:a,orientation:l,align:c,wrap:u=120,noWrap:d}=n;if(!s&&!a)return t("g",{className:"annotation-note"});let h=l;h||(h=Math.abs(o)>Math.abs(i)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>o?"right":"left":0>i?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>o?"end":"start";const p=16,y=a?d?[a]:Xi(a,u):[],m=s?d?[s]:Xi(s,u):[],v="leftRight"===h?"end"===g?-4:4:0;let b=0;const x=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:y.map((e,n)=>t("tspan",{x:v,dy:0===n?0:p,children:e},n))},"annotation-note-title")),b=y.length*p),m.length>0&&x.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:b,children:m.map((e,n)=>t("tspan",{x:v,dy:0===n?0:p,children:e},n))},"annotation-note-label"));let w=null;if((a||s)&&(0!==o||0!==i))if("topBottom"===h){const e=Math.min(u,120);let n=0,o=e;"end"===g?(n=-e,o=0):"middle"===g&&(n=-e/2,o=e/2),w=t("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+m.length)*p+(m.length>0?p:0);let n=0,o=e;"bottom"===f?(n=-e,o=0):"middle"===f&&(n=-e/2,o=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,y.length+m.length-1)*p;let S=0;return"topBottom"===h?S=0>i?-(A+2):18:"leftRight"===h&&(S="middle"===f?-(A+p+(m.length>0&&y.length>0?2:0))/2+8:"bottom"===f||0>i?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${o},${i})`,children:[t("g",{className:"annotation-note-content",transform:0!==S?`translate(0,${S})`:void 0,children:x}),w]})}function Ui(e,n,o,i,r){var s;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t("circle",{r:e,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(e>0||i>0)&&a.push(t("rect",{width:e,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-e;a.push(t("line",{x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(t("line",{x1:(n.x1||0)-e,y1:i,x2:(n.x2||0)-e,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&a.push(t("path",{d:qi((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:a})}function Zi(e,n,o,i,r,s){const a=[];let l=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,o=s.height||0;if(t>0||o>0){const i=t/2,r=o/2,s=e-i,a=n-r;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),u=t/2,d=o/2,h=e*d>n*u?u/e:d/n;l=i+s*h,c=r+a*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(l=t/2,c=n):void 0!==e&&(l=n,c=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const o=Math.atan2(n,e);l=Math.cos(o)*t,c=Math.sin(o)*t}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(n-c,2))>.5&&(a.push(t("line",{x1:l,y1:c,x2:e,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,s=Math.atan2(n-c,e-l);a.push(t("path",{d:`M${l},${c}L${l+o*Math.cos(s+r)},${c+o*Math.sin(s+r)}L${l+o*Math.cos(s-r)},${c+o*Math.sin(s-r)}Z`,fill:i||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t("g",{className:"annotation-connector",children:a})}function Qi(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:p={},"data-testid":y}=t,m=new Set(Array.isArray(g)?g:[]);let v=i||0,b=r||0;null!=s&&(v=s-n),null!=a&&(b=a-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const t=u.depth||30;b=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;v=t+(0>t?-5:5),b=u.height/2}return e("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":y},p,{children:[!m.has("connector")&&Zi(v,b,c,h,x,u),!m.has("subject")&&Ui(x,u,h,n,o),!m.has("note")&&Vi(l,v,b,h)]}))}function Ki(e){var n,o;const{noteData:i}=e,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const e=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t(Qi,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return t("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return t(Qi,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Ji(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function tr(t,e){var n,o,i;const r=null!==(o=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=e.scales)||void 0===i?void 0:i.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function er(t,e,n){var o,i,r,s;const a=t.anchor||"fixed";if("latest"===a){if(null!=t.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===t.pointId){const t={x:r.x,y:r.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(e,t),t}}const r=function(t){var e,n,o,i,r,s;const a=t.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(o=t.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=t.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[t.xAccessor||"x"],h=l[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(i=n.stickyPositionCache)||void 0===i||i.set(e,r)),r}let l=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(l=e.x,c=e.y)}if(null!=l&&null!=c||(l=Ji(t,n),c=tr(t,n)),null!=l&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const t=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(e);if(t)return t}return null}function nr(t,e,n,o=50){return!(-o>t||t>(n.width||0)+o||-o>e||e>(n.height||0)+o)}const or={linear:J,monotoneX:Z,monotoneY:U,step:X,stepAfter:H,stepBefore:G,basis:Y,cardinal:V,catmullRom:q};let ir={positions:new Map};const rr=new Set;function sr(){for(const t of rr)t()}function ar(t,e){const n=ir.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const o=new Map(ir.positions);o.delete(t),ir={positions:o},sr()}function lr(t,e){const n=ir.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const o=new Map(ir.positions);o.delete(t),ir={positions:o},sr()}function cr(){return ir}function ur(t){return rr.add(t),()=>rr.delete(t)}const dr={positions:new Map};function hr(){return()=>{}}function fr(){return dr}function gr(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),o=n[0],i=n[n.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,a=i instanceof Date?i.getTime():i;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function pr(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function yr(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function mr(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const o of t)e>o.pixel&&(e=o.pixel),o.pixel>n&&(n=o.pixel);return{min:e,max:n}}function vr(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function br(t,e,n){if("left"===t||"right"===t){const o="left"===t?n:0,i="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+o;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${o+4*i}`,s+=`L${Math.min(n,e)},${o}`}return s}{const o="bottom"===t?0:e,i="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${o+4*i},${Math.min(8*t+4,n)}`,s+=`L${o},${Math.min(e,n)}`}return s}}function xr(n){const{width:o,height:i,totalWidth:s,totalHeight:a,margin:l,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g,axisExtent:p}=n,y=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||f||kr,r=Math.max(2,Math.floor(o/70)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:gr(c.x,"exact"===p?Math.max(2,s):Math.min(s,r),p),l=a.map(t=>t.valueOf()),u=a.map((t,e)=>({value:t,pixel:c.x(t),label:i(t,e,l)})),h=u.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return wr(u,Math.max(55,h+8))},[c,d,f,o,p]),m=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||g||kr,r=Math.max(2,Math.floor(i/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return wr((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:gr(c.y,"exact"===p?Math.max(2,s):Math.min(s,r),p)).map(t=>({value:t,pixel:c.y(t),label:o(t)})),22)},[c,d,g,i,p]),v=h&&c,b=u&&c;if(!v&&!b)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),k=null==d?void 0:d.find(t=>"left"===t.orient),w=b&&(!x||!1!==x.baseline),A=b&&(!k||!1!==k.baseline),S=(null==x?void 0:x.jaggedBase)||!1,_=(null==k?void 0:k.jaggedBase)||!1,M="var(--semiotic-border, #ccc)";return t("svg",{width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${l.left},${l.top})`,children:[v&&(()=>{var n,r;const s=vr(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),a=vr(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[y.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"xgrid-"+n)),m.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:a},"ygrid-"+n))]})})(),w&&!S&&t("line",{x1:0,y1:i,x2:o,y2:i,stroke:M,strokeWidth:1}),S&&t("path",{d:br("bottom",o,i),fill:"none",stroke:M,strokeWidth:1}),A&&!_&&t("line",{x1:0,y1:0,x2:0,y2:i,stroke:M,strokeWidth:1}),_&&t("path",{d:br("left",o,i),fill:"none",stroke:M,strokeWidth:1})]})})}function kr(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function wr(t,e){if(2>=t.length)return t;const n=[t[0]];for(let o=1;t.length-1>o;o++)e>Math.abs(t[o].pixel-n[n.length-1].pixel)||n.push(t[o]);const o=t[t.length-1];return e>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Ar(o){var s,a;const{width:c,height:d,totalWidth:h,totalHeight:f,margin:g,scales:p,showAxes:y,axes:m,xLabel:v,yLabel:b,yLabelRight:x,xFormat:k,yFormat:w,axisExtent:A,showGrid:S,title:_,legend:M,legendHoverBehavior:P,legendClickBehavior:O,legendHighlightedCategory:T,legendIsolatedCategories:$,legendPosition:j="right",foregroundGraphics:L,marginalGraphics:C,xValues:D,yValues:E,annotations:z,svgAnnotationRules:R,xAccessor:N,yAccessor:F,annotationData:B,pointNodes:W,curve:I,underlayRendered:Y,canvasObscuresUnderlay:H=!0,linkedCrosshairName:G,linkedCrosshairSourceId:X,children:q}=o,V=r(()=>{var t,e;if(!y||!p)return[];const n=null==m?void 0:m.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||k||kr,i=Math.max(2,Math.floor(c/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,s=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:gr(p.x,"exact"===A?Math.max(2,r):Math.min(r,i),A),a=s.map(t=>t.valueOf()),l=s.map((t,e)=>({value:t,pixel:p.x(t),label:o(t,e,a)})),u=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),d=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(u+8,55)):Math.max(55,u+8);let h=wr(l,d);if(h.length>1&&(h=h.filter((t,e)=>0===e||t.label+""!=h[e-1].label+"")),(null==n?void 0:n.includeMax)&&h.length>0&&"exact"!==A&&!(null==n?void 0:n.tickValues)){const t=p.x.domain()[1],e=p.x(t),n=h[h.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t,h.length,a);d>e-n&&h.length>1&&(h=h.slice(0,-1)),h.push({value:t,pixel:e,label:i})}}return h},[y,p,m,k,c,A]),U=r(()=>{var t,e;if(!y||!p)return[];const n=null==m?void 0:m.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||w||kr,i=Math.max(2,Math.floor(d/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=wr((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:gr(p.y,"exact"===A?Math.max(2,r):Math.min(r,i),A)).map(t=>({value:t,pixel:p.y(t),label:o(t)})),22);if(s.length>1&&(s=s.filter((t,e)=>0===e||t.label+""!=s[e-1].label+"")),(null==n?void 0:n.includeMax)&&s.length>0&&"exact"!==A&&!(null==n?void 0:n.tickValues)){const t=p.y.domain()[1],e=p.y(t),n=s[s.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:i})}}return s},[y,p,m,w,d,A]),Z=r(()=>{var t,e;if(!y||!p)return[];const n=null==m?void 0:m.find(t=>"right"===t.orient);if(!n)return[];const o=n.tickFormat||w||kr,i=Math.max(2,Math.floor(d/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return wr((null!==(e=n.tickValues)&&void 0!==e?e:gr(p.y,"exact"===A?Math.max(2,r):Math.min(r,i),A)).map(t=>({value:t,pixel:p.y(t),label:o(t)})),22)},[y,p,m,w,d,A]),Q=i(new Map),tt=i(null!==(s=null==z?void 0:z.length)&&void 0!==s?s:0),et=null!==(a=null==z?void 0:z.length)&&void 0!==a?a:0;tt.current!==et&&(tt.current=et,Q.current=new Map);const nt=r(()=>{if(!z||0===z.length)return null;const n=function(n,o,i){var r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,_,M,P,O,T,$,j,L,C,D,E,z,R,N,F,B,W,I,Y,H,G,X,q,V,U,Z,Q,tt;switch(n.type){case"label":{const e=er(n,o,i);if(!e)return null;const{x:r,y:s}=e;return nr(r,s,i)?t(Ki,{noteData:{x:r,y:s,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"label",connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+o):null}case"callout":{const e=er(n,o,i);if(!e)return null;const{x:r,y:s}=e;return nr(r,s,i)?t(Ki,{noteData:{x:r,y:s,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"callout-circle",subject:{radius:n.radius||12},connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+o):null}case"x-threshold":{const r=Ji(null!=n.value?Object.assign(Object.assign({},n),{x:n.value}):n,i);if(null==r)return null;const s=n.color||"#f97316",a=n.labelPosition||"top";let l;return l="bottom"===a?(i.height||0)-4:"center"===a?(i.height||0)/2:12,e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:i.height||0,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:r+4,y:l,fill:s,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+o)}case"y-threshold":{const r=tr(null!=n.value?Object.assign(Object.assign({},n),{y:n.value}):n,i);if(null==r)return null;const s=n.color||"#f97316",a=n.labelPosition||"right";let l,c;return"left"===a?(l=4,c="start"):"center"===a?(l=(i.width||0)/2,c="middle"):(l=(i.width||0)-4,c="end"),e("g",{children:[t("line",{x1:0,y1:r,x2:i.width||0,y2:r,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:l,y:r-4,textAnchor:c,fill:s,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+o)}case"enclose":{const r=(n.coordinates||[]).map(t=>({x:Ji(Object.assign(Object.assign({},t),{type:"point"}),i),y:tr(Object.assign(Object.assign({},t),{type:"point"}),i),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const s=at(r),a=n.padding||10;return e("g",{children:[t("circle",{cx:s.x,cy:s.y,r:s.r+a,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:s.x,y:s.y-s.r-a-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+o)}case"rect-enclose":{const r=(n.coordinates||[]).map(t=>({x:Ji(Object.assign(Object.assign({},t),{type:"point"}),i),y:tr(Object.assign(Object.assign({},t),{type:"point"}),i)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const s=n.padding||10,a=r.map(t=>t.x),l=r.map(t=>t.y),c=Math.min(...a)-s,u=Math.max(...a)+s,d=Math.min(...l)-s,h=Math.max(...l)+s;return e("g",{children:[t("rect",{x:c,y:d,width:u-c,height:h-d,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+o)}case"highlight":{const e=i.data||[],r="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],s={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:r.map((e,o)=>{const r=Ji(e,i),a=tr(e,i);if(null==r||null==a)return null;const l="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||s;return t("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+o)})},"ann-"+o)}case"bracket":{const e=Ji(n,i),r=tr(n,i);return t(Ki,{noteData:{x:null!=e?e:0,y:null!=r?r:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+o)}case"trend":{const h=i.data||[];if(2>h.length)return null;const f=i.xAccessor||"x",g=i.yAccessor||"y",p="ordinal"===i.frameType,y="horizontal"===i.projection,m=p?f:null,v=p?g:null;let b;const x=[],k=new Map;if(p&&m&&v){for(const t of h){const e=t[m];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,x.length),x.push(n))}b=h.map(t=>{const e=t[m],n=t[v];if(null==e||null==n)return null;const o=k.get(e+"");return null!=o?[o,+n]:null}).filter(t=>null!==t)}else b=h.map(t=>[t[f],t[g]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>b.length)return null;const w=null!==(s=null===(r=i.scales)||void 0===r?void 0:r.x)&&void 0!==s?s:null===(a=i.scales)||void 0===a?void 0:a.time,A=null!==(c=null===(l=i.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=i.scales)||void 0===u?void 0:u.value;if(!w||!A)return null;const S=t=>e=>{const n=Math.max(0,Math.floor(e)),o=Math.min(x.length-1,n+1),i=e-n,r=t(x[n]);return r+(t(x[o])-r)*i},_=w,M=A;let P;if(p)if(y){const t=S(M);P=(e,n)=>[_(n),t(e)]}else{const t=S(_);P=(e,n)=>[t(e),M(n)]}else P=(t,e)=>[_(t),M(e)];const O=n.method||"linear";let T;T="loess"===O?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const o=t.slice().sort((t,e)=>t[0]-e[0]),i=o.map(t=>t[0]),r=o.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=i[t],o=i.map(t=>Math.abs(t-e)),l=o.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:o[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*i[t],h+=e*r[t],f+=e*i[t]*i[t],g+=e*i[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const p=u*f-d*d;if(1e-12>Math.abs(p))a.push([e,h/u]);else{const t=(u*g-d*h)/p;a.push([e,(h-t*d)/u+t*e])}}return a}(b,null!==(d=n.bandwidth)&&void 0!==d?d:.3):("polynomial"===O?wt.polynomial(b,{order:n.order||2}):wt.linear(b)).points;const $=T.map(([t,e])=>{const[n,o]=P(t,e);return`${n},${o}`}).join(" "),j=n.color||"#6366f1",L=T[T.length-1],[C,D]=P(L[0],L[1]);return e("g",{children:[t("polyline",{points:$,fill:"none",stroke:j,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:C+4,y:D-4,fill:j,fontSize:11,children:n.label})]},"ann-"+o)}case"band":{const r=null!==(f=null===(h=i.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=i.scales)||void 0===g?void 0:g.value,s=null!==(p=null==r?void 0:r(n.y0))&&void 0!==p?p:0,a=null!==(y=null==r?void 0:r(n.y1))&&void 0!==y?y:i.height||0;return e("g",{children:[t("rect",{x:0,y:Math.min(s,a),width:i.width||0,height:Math.abs(a-s),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(i.width||0)-4,y:Math.min(s,a)-4,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:n.label})]},"ann-"+o)}case"envelope":{const r=i.data||[];if(2>r.length)return null;const s=i.xAccessor||"x",a=null!==(v=null===(m=i.scales)||void 0===m?void 0:m.x)&&void 0!==v?v:null===(b=i.scales)||void 0===b?void 0:b.time,l=null!==(k=null===(x=i.scales)||void 0===x?void 0:x.y)&&void 0!==k?k:null===(w=i.scales)||void 0===w?void 0:w.value;if(!a||!l)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=r.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[s]-e[s]);if(2>h.length)return null;const f=or[i.curve||"linear"]||J,g=K().x(t=>a(t[s])).y0(t=>l(t[u])).y1(t=>l(t[c])).curve(f)(h);if(!g)return null;const p=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:p,fillOpacity:null!==(A=n.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:a(h[h.length-1][s])+4,y:l(h[h.length-1][c])-4,fill:p,fontSize:11,children:n.label})]},"ann-"+o)}case"anomaly-band":{const r=i.data||[];if(2>r.length)return null;const s=i.yAccessor||"y",a=null!==(_=null===(S=i.scales)||void 0===S?void 0:S.x)&&void 0!==_?_:null===(M=i.scales)||void 0===M?void 0:M.time,l=null!==(O=null===(P=i.scales)||void 0===P?void 0:P.y)&&void 0!==O?O:null===(T=i.scales)||void 0===T?void 0:T.value;if(!a||!l)return null;const c=r.map(t=>t[s]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==($=n.threshold)&&void 0!==$?$:2,g=u-f*h,p=!1!==n.showBand,y=n.fill||"#6366f1",m=null!==(j=n.fillOpacity)&&void 0!==j?j:.1,v=n.anomalyColor||"#ef4444",b=null!==(L=n.anomalyRadius)&&void 0!==L?L:6,x=l(u+f*h),k=l(g),w=r.filter(t=>{const e=t[s];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[p&&t("rect",{x:0,y:Math.min(x,k),width:i.width||0,height:Math.abs(k-x),fill:y,fillOpacity:m}),w.map((e,n)=>{const o=Ji(e,i),r=tr(e,i);return null==o||null==r?null:t("circle",{cx:o,cy:r,r:b,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(i.width||0)-4,y:Math.min(x,k)-4,textAnchor:"end",fill:y,fontSize:11,children:n.label})]},"ann-"+o)}case"forecast":{const r=i.data||[];if(3>r.length)return null;const s=i.xAccessor||"x",a=i.yAccessor||"y",l=null!==(D=null===(C=i.scales)||void 0===C?void 0:C.x)&&void 0!==D?D:null===(E=i.scales)||void 0===E?void 0:E.time,c=null!==(R=null===(z=i.scales)||void 0===z?void 0:z.y)&&void 0!==R?R:null===(N=i.scales)||void 0===N?void 0:N.value;if(!l||!c)return null;const u=r.map(t=>[t[s],t[a]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=wt.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const t=u.length;let e=0,n=0,o=0,i=0;for(const[t,r]of u)e+=t,n+=r,o+=t*t,i+=t*r;const r=t*o-e*e;if(1e-12>Math.abs(r))return null;const s=(t*i-e*n)/r,a=(n-s*e)/t;d=t=>a+s*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),p=u.reduce((t,e)=>t+e[0],0)/h,y=u.reduce((t,e)=>t+Math.pow(e[0]-p,2),0),m=null!==(F=n.confidence)&&void 0!==F?F:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(B=n.steps)&&void 0!==B?B:5,x=u[h-1][0],k=(x-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;b>=t;t++)w.push(x+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(y>0?Math.pow(t-p,2)/y:0))*v;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${c(t.yLower)}`).join(" L")} Z`,_=A.map(t=>`${l(t.x)},${c(t.yCenter)}`).join(" "),M=`${l(x)},${c(d(x))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:S,fill:n.fill||"#6366f1",fillOpacity:null!==(W=n.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),t("polyline",{points:`${M} ${_}`,fill:"none",stroke:P,strokeWidth:null!==(I=n.strokeWidth)&&void 0!==I?I:2,strokeDasharray:null!==(Y=n.strokeDasharray)&&void 0!==Y?Y:"6,3"}),n.label&&A.length>0&&t("text",{x:l(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+o)}case"widget":{let e=null,r=null;if(null!=n.px&&null!=n.py)e=n.px,r=n.py;else{const t=er(n,o,i);if(!t)return null;e=t.x,r=t.y}if(null==e||null==r)return null;if(!nr(e,r,i))return null;const s=null!==(H=n.dx)&&void 0!==H?H:0,a=null!==(G=n.dy)&&void 0!==G?G:0,l=null!==(X=n.width)&&void 0!==X?X:32,c=null!==(q=n.height)&&void 0!==q?q:32,u=null!==(V=n.content)&&void 0!==V?V:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const e=er(n,o,i);if(!e)return null;const{x:r,y:s}=e;return t("text",{x:r+(n.dx||0),y:s+(n.dy||0),fill:n.color||"var(--semiotic-text, #333)",fontSize:n.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label},"ann-text-"+o)}case"category-highlight":{const r=n.category;if(null==r)return null;const s=t=>"function"==typeof t&&"function"==typeof t.bandwidth,a=null===(U=i.scales)||void 0===U?void 0:U.o,l=null===(Z=i.scales)||void 0===Z?void 0:Z.x,c=null===(Q=i.scales)||void 0===Q?void 0:Q.y,u=s(a)?a:s(l)?l:s(c)?c:null;if(!u)return null;const d=u(r+"");if(null==d)return null;const h=u.bandwidth(),f=n.color||"var(--semiotic-primary, #4589ff)",g=null!==(tt=n.opacity)&&void 0!==tt?tt:.15,p=n.label;return e("g",(i.projection?"vertical"===i.projection:u===l)?{children:[t("rect",{x:d,y:0,width:h,height:i.height||0,fill:f,fillOpacity:g}),p&&t("text",{x:d+h/2,y:12,textAnchor:"middle",fill:f,fontSize:12,fontWeight:"bold",children:p})]}:{children:[t("rect",{x:0,y:d,width:i.width||0,height:h,fill:f,fillOpacity:g}),p&&t("text",{x:12,y:d+h/2,dominantBaseline:"middle",fill:f,fontSize:12,fontWeight:"bold",children:p})]},"ann-"+o)}default:return null}},o={scales:p?{x:p.x,y:p.y,time:p.x,value:p.y}:null,timeAxis:"x",xAccessor:N,yAccessor:F,width:c,height:d,data:B,frameType:"xy",pointNodes:W,curve:I,stickyPositionCache:Q.current};return z.map((t,e)=>{if(R){const i=R(t,e,o);return null!=i?i:n(t,e,o)}return n(t,e,o)}).filter(Boolean)},[z,R,c,d,N,F,B,p,W,I]),ot=function(t){var e;const n=l(t?ur:hr,t?cr:fr,t?cr:fr);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(G);return u(()=>{if(!(null==ot?void 0:ot.locked)||!G)return;const t=t=>{"Escape"===t.key&&lr(G)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==ot?void 0:ot.locked,G]),y||_||M||L||C||nt&&nt.length>0||S||q||ot?e("svg",{role:"img",width:h,height:f,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof _?_:"XY Chart"}),t("desc",{children:"string"==typeof _?_+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${g.left},${g.top})`,children:[S&&p&&(!Y||H)&&(()=>{var n,o;const i=vr(null===(n=null==m?void 0:m.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=vr(null===(o=null==m?void 0:m.find(t=>"left"===t.orient))||void 0===o?void 0:o.gridStyle);return e("g",{className:"stream-grid",children:[V.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:d,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"xgrid-"+n)),U.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:c,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),y&&p&&(()=>{const n=null==m?void 0:m.find(t=>"left"===t.orient),o=null==m?void 0:m.find(t=>"bottom"===t.orient),i=!n||!1!==n.baseline,r=!o||!1!==o.baseline,s=(null==n?void 0:n.jaggedBase)||!1,a=(null==o?void 0:o.jaggedBase)||!1,l=null==o?void 0:o.landmarkTicks,u=null==n?void 0:n.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",y=!!(null==o?void 0:o.autoRotate)&&V.length>1&&(()=>{const t=c/Math.max(V.length-1,1),e=V.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})(),k={fontSize:"var(--semiotic-tick-font-size, 10px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 10px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=null==o?void 0:o.tickAnchor,_=null==n?void 0:n.tickAnchor,M=mr(V),P=mr(U);return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!Y||H)&&r&&!a&&t("line",{x1:0,y1:d,x2:c,y2:d,stroke:h,strokeWidth:1}),(!Y||H)&&a&&t("path",{d:br("bottom",c,d),fill:"none",stroke:h,strokeWidth:1}),V.map((n,o)=>{const i=!!l&&("function"==typeof l?l(n.value,o):ai(n.value,o>0?V[o-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${d})`,children:[t("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:y?10:18,textAnchor:y?"end":pr(S,n.pixel===M.min,n.pixel===M.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?w:k),transform:y?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"center",userSelect:"none"},k),children:n.label})})]},"xtick-"+o)}),v&&t("text",{x:c/2,y:d+40,textAnchor:"middle",fill:p,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:v})]}),e("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!Y||H)&&i&&!s&&t("line",{x1:0,y1:0,x2:0,y2:d,stroke:h,strokeWidth:1}),(!Y||H)&&s&&t("path",{d:br("left",c,d),fill:"none",stroke:h,strokeWidth:1}),U.map((n,o)=>{const i=!!u&&("function"==typeof u?u(n.value,o):ai(n.value,o>0?U[o-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:yr(_,n.pixel===P.min,n.pixel===P.max),fontWeight:i?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?w:k),children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"right",userSelect:"none"},k),children:n.label})})]},"ytick-"+o)}),(()=>{const e=(null==n?void 0:n.label)||b;return e?t("text",{x:15-g.left,y:d/2,textAnchor:"middle",fill:p,transform:`rotate(-90, ${15-g.left}, ${d/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:e}):null})()]}),(()=>{const n=null==m?void 0:m.find(t=>"right"===t.orient);if(!n||0===Z.length)return null;const o=!1!==n.baseline,i=n.landmarkTicks,r=n.label||x,s=n.tickAnchor,a=mr(Z);return e("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&t("line",{x1:c,y1:0,x2:c,y2:d,stroke:h,strokeWidth:1}),Z.map((n,o)=>{const r=!!i&&("function"==typeof i?i(n.value,o):ai(n.value,o>0?Z[o-1].value:void 0));return e("g",{transform:`translate(${c},${n.pixel})`,children:[t("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:yr(s,n.pixel===a.min,n.pixel===a.max),fontWeight:r?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},r?w:k),children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"left",userSelect:"none"},k),children:n.label})})]},"ytick-r-"+o)}),r&&t("text",{x:c+g.right-15,y:d/2,textAnchor:"middle",fill:p,transform:`rotate(90, ${c+g.right-15}, ${d/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:r})]})})()]})})(),nt,C&&p&&D&&E&&e(n,{children:[C.top&&t("g",{transform:"translate(0, 0)",children:t(Gi,{orient:"top",config:Hi(C.top),values:D,scale:p.x,size:g.top,length:c})}),C.bottom&&t("g",{transform:`translate(0, ${d})`,children:t(Gi,{orient:"bottom",config:Hi(C.bottom),values:D,scale:p.x,size:g.bottom,length:c})}),C.left&&t("g",{transform:"translate(0, 0)",children:t(Gi,{orient:"left",config:Hi(C.left),values:E,scale:p.y,size:g.left,length:d})}),C.right&&t("g",{transform:`translate(${c}, 0)`,children:t(Gi,{orient:"right",config:Hi(C.right),values:E,scale:p.y,size:g.right,length:d})})]}),L,ot&&ot.sourceId!==X&&(null==p?void 0:p.x)&&(()=>{const e=p.x(ot.xValue);if(null==e||0>e||e>c)return null;const n=ot.locked;return t("line",{x1:e,y1:0,x2:e,y2:d,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),q]}),_&&t("text",{x:h/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof _?_:null}),Yi({legend:M,totalWidth:h,totalHeight:f,margin:g,legendPosition:j,title:_,legendHoverBehavior:P,legendClickBehavior:O,legendHighlightedCategory:T,legendIsolatedCategories:$})]}):null}const Sr="undefined"!=typeof window?h:u,_r=()=>()=>{},Mr=()=>!1,Pr=()=>!0;function Or(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;if(!Object.is(t[o],e[o]))return!1}return!0}function Tr(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function $r(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const jr=o.createContext(null),Lr={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Cr(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){const t=e.type+"";n[t]=(n[t]||0)+1}const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),o=r.indexOf(e);return(-1===n?999:n)-(-1===o?999:o)});for(const t of s)o.push(`${n[t]} ${i[t]||t}`);return`${e}, ${o.join(", ")}`}const Dr=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},Er={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},zr={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Rr={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Nr={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Fr={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Br={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Wr={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Ir({scene:n,chartType:i,tableId:r,chartTitle:s}){var a;const[l,c]=o.useState(!1),u=o.useContext(jr),d=null!==(a=null==u?void 0:u.visible)&&void 0!==a&&a,h=l||d,f=o.useRef(null),g=s?"Data summary for "+s:r?`Data summary for ${i} ${r}`:"Data summary for "+i,p=o.useCallback(()=>{l||d||c(!0)},[l,d]),y=o.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[d]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:Lr}):null;if(!h)return t("div",{id:r,tabIndex:-1,onFocus:p,style:Lr,role:"region","aria-label":g,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const m=function(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,_;const M=[];if(!Array.isArray(t))return M;for(const P of t)if(P&&"object"==typeof P)try{switch(P.type){case"point":M.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const t=P.path,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=P.topPath,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&M.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=P.datum&&"object"==typeof P.datum?P.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.group)&&void 0!==n?n:"",s=null!==(i=null!==(o=t.value)&&void 0!==o?o:t.__aggregateValue)&&void 0!==i?i:t.total;M.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":M.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":M.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=P.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=P.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":M.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(g=P.cy)&&void 0!==g?g:P.y}});break;case"arc":M.push({label:"Arc",values:{id:null!==(y=null===(p=P.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=P.cx)&&void 0!==m?m:P.x,y:null!==(v=P.cy)&&void 0!==v?v:P.y}});break;case"candlestick":M.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":M.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=P.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(_=null===(S=P.datum)||void 0===S?void 0:S.value)&&void 0!==_?_:""}})}}catch(t){}return M}(n),v=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const o of e){const e=[],i=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[o];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&i.add(t+""))}if(e.length>0){let t=e[0],i=e[0],r=0;for(const n of e)t>n&&(t=n),n>i&&(i=n),r+=n;n.push({name:o,count:e.length,numeric:!0,min:t,max:i,mean:r/e.length})}else if(i.size>0){const t=Array.from(i);n.push({name:o,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(m),b=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Dr(t.min)} to ${Dr(t.max)}, mean ${Dr(t.mean)}.`);else{const e=t.uniqueValues,o=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${o}.`)}return n.join(" ")}(m.length,v),x=m.slice(0,5),k=new Set;for(const t of x)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return e("div",{ref:f,id:r,tabIndex:-1,onBlur:y,style:Er,role:"region","aria-label":g,children:[t("button",{type:"button",onClick:()=>{d&&u&&u.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:Rr,children:"×"}),t("div",{role:"note",style:zr,children:b}),e("table",{role:"table","aria-label":"Sample data for "+i,style:Nr,children:[e("caption",{style:Wr,children:["First ",x.length," of ",m.length," data points"]}),t("thead",{children:e("tr",{children:[t("th",{style:Fr,children:"type"}),w.map(e=>t("th",{style:Fr,children:e},e))]})}),t("tbody",{children:x.map((n,o)=>e("tr",{children:[t("td",{style:Br,children:n.label}),w.map(e=>{return t("td",{style:Br,children:(o=n.values[e],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Dr(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},e);var o})]},o))})]})]})}function Yr({summary:e}){return e?t("div",{role:"note",style:Lr,children:e}):null}function Hr({tableId:e}){return t("a",{href:"#"+e,style:Lr,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Lr)},children:"Skip to data table"})}function Gr({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t("div",{"aria-live":"polite","aria-atomic":"true",style:Lr,children:n})}const Xr="var(--semiotic-focus, #005fcc)";function qr({active:e,hoverPoint:n,margin:o,size:i,shape:r="circle",width:s,height:a}){if(!e||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=s&&null!=a){const e=Math.max(s,4),n=Math.max(a,4);u=t("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Xr,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Xr,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Xr,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Vr({x:e,y:n,containerWidth:i,containerHeight:r,margin:s,children:a,className:l="stream-frame-tooltip",zIndex:c=1}){const u=Number.isFinite(e)&&Number.isFinite(n),d=o.useRef(null),[h,f]=o.useState(null);o.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=t.getBoundingClientRect();f(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[a,l,i,r]);let g;g=h?`translate(${h.width+12>i-e?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*i?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const p=function(t){if(!o.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const i=n.style;if(i&&"object"==typeof i){if(null!=i.background&&""!==i.background)return!0;if(null!=i.backgroundColor&&""!==i.backgroundColor)return!0}return!1}(a),y=p?null:Uo;return u?t("div",{ref:d,className:p?l:(l+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:s.left+e,top:s.top+n,transform:g,pointerEvents:"none",zIndex:c,width:"max-content"}),children:a}):null}const Ur="undefined"==typeof window?u:h;function Zr(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function Qr(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return u(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>e(t.matches))},[]),t}(),n=i(e);n.current=e;const[s,l]=function(t,e,n){const o=i(null),[r,s]=d(null);return u(()=>{if(!e&&!n)return;const t=o.current;if(!t)return;const i=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return i.observe(t),()=>i.disconnect()},[e,n]),[o,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),c=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=l[0]-c.left-c.right,f=l[1]-c.top-c.bottom,g=Zr(t.foregroundGraphics,l,c),p=Zr(t.backgroundGraphics,l,c),y=Ao(t=>t.theme),{transition:m,introEnabled:v}=function(t,e){var n,o;if(!1===t)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(o=t.duration)&&void 0!==o?o:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(i||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),b="semiotic-table-"+o.useId(),x=i(0),k=i(()=>{}),w=a(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);u(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const A=i(()=>{}),S=i(()=>{}),_=i(null),M=i(0),P=a(()=>{M.current=0;const t=_.current;_.current=null,t&&A.current(t)},[]),O=a(t=>{_.current={clientX:t.clientX,clientY:t.clientY},0===M.current&&(M.current=requestAnimationFrame(P))},[P]),T=a(()=>{_.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0),S.current()},[]);u(()=>()=>{_.current=null,0!==M.current&&(cancelAnimationFrame(M.current),M.current=0)},[]);const $=t.themeDirtyRef;return Ur(()=>{$&&(ui++,$.current=!0,w())},[y,w,$]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:l,margin:c,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:p,currentTheme:y,transition:m,introEnabled:v,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:S,onPointerMove:O,onPointerLeave:T}}function Kr(t,e,n,o){const i=t.getContext("2d");if(!i)return null;const r=e[0]*o,s=e[1]*o,a=e[0]+"px",l=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==l&&(t.style.height=l),t.width===r&&t.height===s||(t.width=r,t.height=s),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function Jr(t,e,n){let o=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(o=n.color):t>n.value&&(o=n.color);return o}function ts(t,e,n,o,i,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],o=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=o,t.lineCap=r;for(let n=0;e.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const es=(t,e,n,o)=>{var i,r;const s=e.filter(t=>"line"===t.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,o.width*l,o.height),t.clip());const c=a.style.stroke||"#007bff",u=pi(t,c)||c,d=a.style.strokeWidth||2,h=a.colorThresholds,f=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=d,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;ts(t,a.path,u,d,m,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=yi(a.curve),p=h&&h.length>0&&f&&f.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){t.strokeStyle=u;const v=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(y[b]+y[b+1])*v,t.beginPath(),t.moveTo(a.path[b][0],a.path[b][1]),t.lineTo(a.path[b+1][0],a.path[b+1][1]),t.stroke()}else if(p){let x=null,k=null,w=null,A=null,S=!1;function _(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),S=!0}function M(){S&&(t.stroke(),S=!1)}for(let P=0;a.path.length>P;P++){const[O,T]=a.path[P],$=f[P],j=Jr($,h,u);if(null!==x&&null!==A&&null!==w){if(j===A)t.lineTo(O,T);else{const L=[];for(const C of h){const D=C.value;(w>D||D>$)&&(D>w||$>D)||w===D||$===D||L.push({t:(D-w)/($-w)})}L.sort((t,e)=>t.t-e.t);for(const E of L){const z=x+(O-x)*E.t,R=k+(T-k)*E.t,N=Jr(w+($-w)*Math.min(E.t+1e-4,1),h,u);t.lineTo(z,R),M(),_(N,z,R)}t.lineTo(O,T)}x=O,k=T,w=$,A=j}else _(j,O,T),x=O,k=T,w=$,A=j}M()}else{t.beginPath();const F=a.strokeGradient&&a.path.length>=2?bi(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=F||u,g)Q().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[B,W]=a.path[0];t.moveTo(B,W);for(let I=1;a.path.length>I;I++)t.lineTo(a.path[I][0],a.path[I][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=mi(t,a.style.fill,a.style.fill),g&&!p)Q().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[H,G]=a.path[0];t.moveTo(H,G);for(let X=1;a.path.length>X;X++)t.lineTo(a.path[X][0],a.path[X][1])}const Y=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],o.height),t.lineTo(Y,o.height),t.closePath(),t.fill()}void 0!==l&&1>l&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function ns(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function os(t,e,n=.3){ns(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function is(t,e,n=.6){var o,i,r,s,a;if(!ns(e))return;const l=null!==(o=e._pulseGlowRadius)&&void 0!==o?o:4,c=e.r+l*e._pulseIntensity,u=null!==(r=null!==(i=e.cx)&&void 0!==i?i:e.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function rs(t,e,n,o=.35){ns(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function ss(t,e){const n=yi(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const o=K().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),o(e.topPath)}}const as=(t,e,n,o)=>{var i,r,s;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const a=e._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,o.width*a,o.height),t.clip());const l=mi(t,e.style.fill,"#4e79a7"),c=e._decayOpacities;if(c&&c.length===e.topPath.length){const n=null!==(i=e.style.fillOpacity)&&void 0!==i?i:.7;t.fillStyle=l;for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(c[o]+c[o+1])*n,t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.lineTo(e.bottomPath[o+1][0],e.bottomPath[o+1][1]),t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=pi(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(c[n]+c[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(ss(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const i=vi(t,e.fillGradient,"string"==typeof l?l:"#4e79a7",0,n,0,o);t.fillStyle=i||l,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(ss(t,e),rs(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=u;const n=e.strokeGradient&&e.topPath.length>=2?bi(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||pi(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=yi(e.curve);if(t.beginPath(),o)Q().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==a&&1>a&&t.restore(),n&&t.restore(),t.globalAlpha=1}},ls=(t,e,n,o)=>{var i;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(i=e.style.opacity)&&void 0!==i?i:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=mi(t,e.style.fill,"#4e79a7"),t.fill(),e.style.stroke&&(t.strokeStyle=mi(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth||1,t.stroke()),is(t,e),t.globalAlpha=1}}finally{t.restore()}}};function cs(t,e){const{x:n,y:o,w:i,h:r}=e,{tl:s,tr:a,br:l,bl:c}=io(e);t.beginPath(),t.moveTo(n+s,o),t.lineTo(n+i-a,o),a>0&&t.arcTo(n+i,o,n+i,o+a,a),t.lineTo(n+i,o+r-l),l>0&&t.arcTo(n+i,o+r,n+i-l,o+r,l),t.lineTo(n+c,o+r),c>0&&t.arcTo(n,o+r,n,o+r-c,c),t.lineTo(n,o+s),s>0&&t.arcTo(n,o,n+s,o,s),t.closePath()}function us(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const ds=(t,e,n,o)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)hs(t,e);else if(e.cornerRadii&&oo(e.cornerRadii)){const n=mi(t,e.style.fill,pi(t,"var(--semiotic-primary, #007bff)")),o=us(e),i=e.fillGradient&&"string"==typeof n?vi(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,cs(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=pi(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=mi(t,e.style.fill,pi(t,"var(--semiotic-primary, #007bff)")),o=us(e),i=e.fillGradient&&"string"==typeof n?vi(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+c-r),t.arcTo(s,a+c,s+r,a+c,r),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s+r,a+c),t.arcTo(s,a+c,s,a+c-r,r);break;default:t.moveTo(s,a+c),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=pi(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=mi(t,e.style.fill,pi(t,"var(--semiotic-primary, #007bff)")),o=us(e),i=e.fillGradient&&"string"==typeof n?vi(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=pi(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}os(t,e),t.globalAlpha=1}};function hs(t,e){const n=e.style.icon,o=e.style.iconPadding||2,i=Math.min(e.w,e.h)-o;if(0>=i)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=i+o,s=e.x+(e.w-i)/2;for(let o=e.y+e.h-i;o>=e.y-i;o-=r)t.drawImage(n,s,o,i,i)}else{const r=i+o,s=e.y+(e.h-i)/2;for(let o=e.x;e.x+e.w>o;o+=r)t.drawImage(n,o,s,i,i)}t.restore()}function fs(t,e,n,o){return Object.assign({data:t,x:e,y:n,__semioticHoverData:!0},o)}function gs(t){const[e,n,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*o>128?"#000":"#fff"}function ps(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const ys=(t,e,n,o)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=pi(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),os(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):ps(e.value),o=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=gs(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,r)}}}finally{t.restore()}},ms=(t,e,n,o)=>{var i,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const a=(null!==(i=e._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(t.globalAlpha=a);const l=pi(t,e.wickColor)||e.wickColor,c=60>o.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=l,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*o.height));t.fillStyle=l,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor,r=pi(t,i)||i;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(o,1))}c&&d(),t.restore()}};function vs(t,e,n,o){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:{key:void 0,fn:null}}const bs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function xs(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${bs[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${bs[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const ks={line:[as,es,ls],area:[as,ls],stackedarea:[as,ls],scatter:[ls],bubble:[ls],heatmap:[ys],bar:[ds],swarm:[ls],waterfall:[(t,e,n,o)=>{var i;ds(t,e);const r=e.filter(t=>"rect"===t.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){t.save(),t.strokeStyle=pi(t,a)||a,t.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const o=r[e],i=r[e+1],s=o.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=o.x+o.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[ms],mixed:[as,es,ls],custom:[as,ds,ys,es,ls,ms]},ws={top:20,right:20,bottom:30,left:40},As={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function Ss(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],o=n[2],i=n[3];return`#${t}${t}${o}${o}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const _s={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Ms({hover:n}){var o,i,r;const s=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",a=null!==(o=n.data)&&void 0!==o?o:{},l=null!==(i=a.y)&&void 0!==i?i:a.value,c=null!==(r=a.x)&&void 0!==r?r:a.time;return e("div",{className:"semiotic-tooltip",style:_s,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:s(l)}),t("div",{style:{opacity:.7,fontSize:11},children:s(c)})]})}Ms.ownsChrome=!0;const Ps=f(function(n,s){var c,h,f,y,m,v,b,x,k,w,A,S,_;const{chartType:M,runtimeMode:P,data:O,chunkThreshold:T,chunkSize:$,xAccessor:j,yAccessor:L,colorAccessor:C,sizeAccessor:D,groupAccessor:E,lineDataAccessor:z,curve:R,normalize:N,baseline:F,stackOrder:B,binSize:W,valueAccessor:I,arrowOfTime:Y="right",windowMode:H="sliding",windowSize:G=200,timeAccessor:X,xExtent:q,yExtent:V,extentPadding:U=.1,scalePadding:Z,sizeRange:Q,size:K=[500,300],responsiveWidth:J,responsiveHeight:tt,margin:et,className:nt,background:ot,lineStyle:it,pointStyle:rt,areaStyle:st,barStyle:at,waterfallStyle:lt,swarmStyle:ct,barColors:ut,colorScheme:dt,boundsAccessor:ht,boundsStyle:ft,y0Accessor:gt,band:pt,gradientFill:yt,lineGradient:mt,areaGroups:vt,openAccessor:bt,highAccessor:xt,lowAccessor:kt,closeAccessor:wt,candlestickStyle:At,showAxes:St=!0,axes:_t,xLabel:Mt,yLabel:Pt,yLabelRight:Ot,xFormat:Tt,yFormat:$t,axisExtent:jt,tickFormatTime:Lt,tickFormatValue:Ct,hoverAnnotation:Dt,tooltipContent:Et,customHoverBehavior:zt,customClickBehavior:Rt,enableHover:Nt,hoverRadius:Ft=30,tooltipMode:Bt,annotations:Wt,svgAnnotationRules:It,showGrid:Yt,legend:Ht,legendHoverBehavior:Gt,legendClickBehavior:Xt,legendHighlightedCategory:qt,legendIsolatedCategories:Vt,legendPosition:Ut,legendCategoryAccessor:Zt,onCategoriesChange:Qt,backgroundGraphics:Kt,foregroundGraphics:Jt,canvasPreRenderers:te,svgPreRenderers:ee,title:ne,categoryAccessor:oe,brush:ie,onBrush:re,decay:se,pulse:ae,transition:le,animate:ce,staleness:ue,heatmapAggregation:de,heatmapXBins:he,heatmapYBins:fe,showValues:ge,heatmapValueFormat:pe,marginalGraphics:ye,pointIdAccessor:ve,xScaleType:be,yScaleType:xe,accessibleTable:ke=!0,description:we,summary:Ae,linkedCrosshairName:Se,linkedCrosshairSourceId:Me,customLayout:Pe,layoutConfig:Oe}=n,Te=g().replace(/:/g,""),$e=i(!1),je=Qr({sizeProp:K,responsiveWidth:J,responsiveHeight:tt,userMargin:et,marginDefault:ws,animate:ce,transitionProp:le,themeDirtyRef:$e}),Le=function(){const[t,e]=d(!1);return Sr(()=>{e(!0)},[]),t}(),Ce=function(){const t=l(_r,Mr,Pr);return i(t).current}(),{reducedMotionRef:De,responsiveRef:Ee,size:ze,currentTheme:Re,transition:Ne,introEnabled:Fe,tableId:Be,rafRef:We,renderFnRef:Ie,scheduleRender:Ye}=je;let He=je.margin;if(ye){const t=60,e=Object.assign({},je.margin);ye.top&&t>e.top&&(e.top=t),ye.bottom&&t>e.bottom&&(e.bottom=t),ye.left&&t>e.left&&(e.left=t),ye.right&&t>e.right&&(e.right=t),He=e}const Ge="function"==typeof Jt?Jt({size:ze,margin:He}):Jt,Xe="function"==typeof Kt?Kt({size:ze,margin:He}):Kt,qe=ze[0]-He.left-He.right,Ve=ze[1]-He.top-He.bottom,Ue=r(()=>Vo(O),[O]),Ze=null!=Dt?Dt:Nt,Qe=i(null),Ke=i(null),[Je,tn]=d(0),[en,nn]=d(null),on=i(null),rn=i(null),[sn,an]=d(null),ln=i(As.primary),cn=i([]),un=i(Zt),dn=i(Qt);un.current=Zt,dn.current=Qt;const[hn,fn]=d(!1),[gn,pn]=d([]),[yn,mn]=d([]),vn="streaming"===P||["bar","swarm","waterfall"].includes(M),bn=r(()=>{var t,e,n;return{chartType:M,runtimeMode:vn?"streaming":"bounded",windowSize:G,windowMode:H,arrowOfTime:vn?Y:"right",extentPadding:U,scalePadding:Z,axisExtent:jt,xAccessor:j,yAccessor:L,timeAccessor:vn?X:void 0,valueAccessor:I,colorAccessor:C,sizeAccessor:D,groupAccessor:E||(z?"_lineGroup":void 0),categoryAccessor:oe,lineDataAccessor:z,xScaleType:be,yScaleType:xe,xExtent:q,yExtent:V,sizeRange:Q,binSize:W,normalize:N,baseline:F,stackOrder:B,boundsAccessor:ht,boundsStyle:ft,y0Accessor:gt,band:pt,gradientFill:!0===yt?{topOpacity:.8,bottomOpacity:.05}:!1===yt?void 0:yt,areaGroups:vt?new Set(vt):void 0,lineGradient:mt,openAccessor:bt,highAccessor:xt,lowAccessor:kt,closeAccessor:wt,candlestickStyle:At,lineStyle:it,pointStyle:rt,areaStyle:st,swarmStyle:ct,waterfallStyle:lt,colorScheme:dt,barColors:ut,barStyle:at,annotations:Wt,decay:se,pulse:ae,transition:Ne,introAnimation:Fe,staleness:ue,heatmapAggregation:de,heatmapXBins:he,heatmapYBins:fe,showValues:ge,heatmapValueFormat:pe,pointIdAccessor:ve,curve:R,themeCategorical:null===(t=null==Re?void 0:Re.colors)||void 0===t?void 0:t.categorical,themeSemantic:po(Re),themeSequential:null===(e=null==Re?void 0:Re.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Re?void 0:Re.colors)||void 0===n?void 0:n.diverging,customLayout:Pe,layoutConfig:Oe,layoutMargin:He}},[M,G,H,Y,U,Z,jt,j,L,X,I,be,xe,C,D,E,oe,z,q,V,Q,W,N,F,B,ht,ft,gt,pt,yt,mt,vt,bt,xt,kt,wt,At,it,rt,st,ct,lt,at,dt,ut,Wt,se,ae,null==Ne?void 0:Ne.duration,null==Ne?void 0:Ne.easing,Fe,ue,de,he,fe,ge,pe,vn,ve,R,Re,Pe,Oe,He]),xn=function(t){const e=i(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return Tr(t,e);if(!$r(t)||!$r(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))return!1;const n=t[o],i=e[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!Tr(n,i))return!1}else{if(!$r(n)||!$r(i))return!1;if(!Or(n,i))return!1}}return!0}(e.current,t)||(e.current=t),e.current}(bn),kn=i(null);kn.current||(kn.current=new _e(xn));const wn=a(()=>{var t,e;const n=un.current,o=dn.current;if(!o||!n)return;const i=function(t,e){if(!e)return[];const n=new Set,o=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),o.push(r))}return o}(null!==(e=null===(t=kn.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(i,cn.current)||(cn.current=i,o(i))},[]);u(()=>{var t;null===(t=kn.current)||void 0===t||t.updateConfig(xn),$e.current=!0,Ye()},[xn,Ye]);const An=i(null);An.current||(An.current=new ni(t=>{const e=kn.current;e&&e.ingest(t)&&($e.current=!0,Ye())},{chunkThreshold:T,chunkSize:$})),u(()=>{var t;null===(t=An.current)||void 0===t||t.updateChunkOptions({chunkThreshold:T,chunkSize:$})},[T,$]);const Sn=a(t=>{var e;null===(e=An.current)||void 0===e||e.push(t)},[]),_n=a(t=>{var e;null===(e=An.current)||void 0===e||e.pushMany(t)},[]),Mn=a(()=>{var t,e;null===(t=An.current)||void 0===t||t.clear(),null===(e=kn.current)||void 0===e||e.clear(),$e.current=!0,Ye()},[Ye]);p(s,()=>({push:Sn,pushMany:_n,remove:t=>{var e,n,o;null===(e=An.current)||void 0===e||e.flush();const i=null!==(o=null===(n=kn.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[];return i.length>0&&(on.current&&i.some(t=>{var e;return t===(null===(e=on.current)||void 0===e?void 0:e.data)})&&(on.current=null,an(null)),$e.current=!0,Ye()),i},update:(t,e)=>{var n,o,i;null===(n=An.current)||void 0===n||n.flush();const r=null!==(i=null===(o=kn.current)||void 0===o?void 0:o.update(t,e))&&void 0!==i?i:[];return r.length>0&&($e.current=!0,Ye()),r},clear:Mn,getData:()=>{var t,e,n;return null===(t=An.current)||void 0===t||t.flush(),null!==(n=null===(e=kn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=kn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=kn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Sn,_n,Mn,Ye]),u(()=>{var t,e;if(O){if(z&&Ue.length>0&&"object"==typeof Ue[0]&&null!==Ue[0]){const e="string"==typeof z?z:"coordinates";if(Array.isArray(Ue[0][e])){const n=[];for(const t of Ue){const o=t[e];if(Array.isArray(o)){const e=t.label||t.id||t.key;if(null!=e)for(const t of o)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of o)n.push(t)}}return void(null===(t=An.current)||void 0===t||t.setBoundedData(n))}}null===(e=An.current)||void 0===e||e.setBoundedData(Ue)}},[O,Ue,z]);const{hoverHandlerRef:Pn,hoverLeaveRef:On,onPointerMove:Tn,onPointerLeave:$n}=je;Pn.current=t=>{var e,n;if(!Ze)return;const o=Qe.current;if(!o)return;const i=o.getBoundingClientRect(),r=t.clientX-i.left-He.left,s=t.clientY-i.top-He.top;if(0>r||r>qe||0>s||s>Ve)return void(on.current&&(on.current=null,rn.current=null,an(null),zt&&(zt(null),$e.current=!0),Ye()));const a=kn.current;if(!a||0===a.scene.length)return;const l=wi(a.scene,r,s,Ft,a.quadtree,a.maxPointRadius),c="multi"===Bt,u=()=>{on.current&&(on.current=null,rn.current=null,an(null),zt&&zt(null),Ye())};if(!l&&!c)return void u();const d=c||!l?r:l.x,h=c||!l?s:l.y;let f=fs((null==l?void 0:l.datum)?me(l.datum,a.resolvedRibbons):{},d,h);if(c&&a.scene.length>0&&a.scales){const t=function(t,e,n=30){const o=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const r=Ai(ki(t.path,t.curve),e,n);if(null===r)continue;const s=ji(t.path,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=ki(t.topPath,t.curve),s=ki(t.bottomPath,t.curve),a=Ai(r,e,n);if(null===a)continue;const l=Ai(s,e,n),c=ji(t.topPath,e);o.push({node:i,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:null!=l?l:void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return o}(a.scene,d,Math.max(Ft,qe));if(t.length>0){const e=a.scales.y.invert,n=a.scales.x.invert,o=ln.current,i=n?n(d):d;if(l)f.xValue=i,f.xPx=d;else{const t={xValue:i};"string"==typeof j&&(t[j]=i),f=fs(t,d,h,{xValue:i,xPx:d})}f.allSeries=t.map(t=>{const n=e?e(t.y):t.y,i=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===M&&null!=i?n-i:n,valuePx:t.y,color:t.color||o,datum:me(t.datum,a.resolvedRibbons)}})}}l||(null===(e=f.allSeries)||void 0===e?void 0:e.length)?(on.current=f,rn.current=null!==(n=null==l?void 0:l.node)&&void 0!==n?n:null,an(f),zt&&(zt(f),$e.current=!0),Ye()):u()},On.current=()=>{on.current&&(on.current=null,rn.current=null,an(null),zt&&(zt(null),$e.current=!0),Ye())};const jn=i(()=>{});jn.current=t=>{if(!Rt)return;const e=Qe.current;if(!e)return;const n=e.getBoundingClientRect(),o=t.clientX-n.left-He.left,i=t.clientY-n.top-He.top;if(0>o||o>qe||0>i||i>Ve)return void Rt(null);const r=kn.current;if(!r||0===r.scene.length)return void Rt(null);const s=wi(r.scene,o,i,Ft,r.quadtree,r.maxPointRadius);Rt(s?fs(s.datum||{},s.x,s.y):null)};const Ln=a(t=>jn.current(t),[]),Cn=i(-1),Dn=i(null),En=i(null),zn=a(t=>{const e=kn.current;if(!e||0===e.scene.length)return;const n=e.version;let o;if(En.current&&En.current.version===n)o=En.current.graph;else{const t=function(t){var e,n,o;const i=[];for(const r of t)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],o=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)i.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:o});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],o=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)i.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:o});break}case"rect":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(o=r.group)&&void 0!==o?o:"_default"});break;case"heatcell":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return i.sort((t,e)=>t.x-e.x||t.y-e.y),i}(e.scene);if(0===t.length)return;o=function(t){var e,n;const o=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let i=o.get(t);i||(i=[],o.set(t,i)),i.push(n)}for(const t of o.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const i=Array.from(o.keys()).sort((t,e)=>{const n=o.get(t),i=o.get(e);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(o.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:i,byGroup:o,idToIdx:s}}(t),En.current={version:n,graph:o}}const i=Cn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Cn.current=0;const n=o.flat[0];Dn.current={shape:n.shape,w:n.w,h:n.h};const i=Ci(Object.assign(Object.assign({},n),{datum:me(n.datum,e.resolvedRibbons)}));return on.current=i,an(i),zt&&zt(i),void Ye()}const r=function(t,e){var n,o;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[i];return{flatIndex:i,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=r._groupIndex)&&void 0!==o?o:0}}(o,i),s=function(t,e,n){const{group:o,indexInGroup:i}=e,r=n.byGroup.get(o);switch(t){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(o);return n.groups.length-1>t?Li(n,n.groups[t+1],r[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(o);return t>0?Li(n,n.groups[t-1],r[i]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(t.key,r,o);if(null===s)return;if(t.preventDefault(),0>s)return Cn.current=-1,Dn.current=null,on.current=null,rn.current=null,an(null),zt&&zt(null),void Ye();Cn.current=s;const a=o.flat[s];Dn.current={shape:a.shape,w:a.w,h:a.h};const l=Ci(Object.assign(Object.assign({},a),{datum:me(a.datum,e.resolvedRibbons)}));on.current=l,an(l),zt&&zt(l),Ye()},[zt,Ye]),Rn=a(t=>{Cn.current=-1,Dn.current=null,Tn(t)},[Tn]);Ie.current=()=>{var t,e;We.current=0;const n=Qe.current,o=Ke.current;if(!n||!o)return;const i=kn.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(De.current?r+1e6:r),a=!De.current&&s,l=$e.current||s;l&&!a&&(i.computeScene({width:qe,height:Ve}),wn());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return As;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),o=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=o||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=i||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||As.axisStroke,tickText:s||As.tickText,crosshair:s?Ss(s,"66"):As.crosshair,hoverFill:c?Ss(c,"4D"):As.hoverFill,hoverStroke:s?Ss(s,"99"):As.hoverStroke,pointRing:c||As.pointRing,primary:r||As.primary}:As}(n);ln.current=u.primary;const d=null!==(t=null==ue?void 0:ue.threshold)&&void 0!==t?t:5e3,h=ue&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const t=Kr(n,ze,He,c);if(t){if(t.clearRect(-He.left,-He.top,ze[0],ze[1]),h&&(t.globalAlpha=null!==(e=null==ue?void 0:ue.dimOpacity)&&void 0!==e?e:.5),"transparent"!==ot&&!Kt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=ot||(e&&"transparent"!==e?e:null),i=o?pi(t,o):null;i&&(t.fillStyle=i,t.fillRect(-He.left,-He.top,ze[0],ze[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,qe,Ve),t.clip()),te&&i.scales)for(const e of te)t.save(),e(t,i.scene,i.scales,{width:qe,height:Ve}),t.restore();const o=Pe?ks.custom:ks[M];if(o&&i.scales)for(const e of o)e(t,i.scene,i.scales,{width:qe,height:Ve});t.restore(),h&&(t.globalAlpha=1)}}{const t=Kr(o,ze,He,c);if(t&&(t.clearRect(-He.left,-He.top,ze[0],ze[1]),Ze&&on.current&&i.scales&&function(t,e,n,o,i,r,s){var a;if(!1===i.crosshair)return;const l=e.allSeries,c=l&&l.length>0,u=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,o),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of l)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=i.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,on.current,qe,Ve,"object"==typeof Ze?Ze:{},rn.current,u),rn.current&&Array.isArray(Dt))){const e=Dt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,o,i){var r;if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||i.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,i.scene,rn.current,e,u)}}l&&n&&n.setAttribute("aria-label",Cr(i.scene,M+" chart"));const f=$e.current;if($e.current=!1,f&&i.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!en||t(en.x.domain()[0])!==t(i.scales.x.domain()[0])||t(en.x.domain()[1])!==t(i.scales.x.domain()[1])||t(en.y.domain()[0])!==t(i.scales.y.domain()[0])||t(en.y.domain()[1])!==t(i.scales.y.domain()[1])||en.x.range()[0]!==i.scales.x.range()[0]||en.x.range()[1]!==i.scales.x.range()[1]||en.y.range()[0]!==i.scales.y.range()[0]||en.y.range()[1]!==i.scales.y.range()[1])&&nn(i.scales),ye){const t=i.getData(),e="function"==typeof j?j:t=>t[j||"x"],n="function"==typeof L?L:t=>t[L||"y"];pn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),mn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Wt&&Wt.length>0&&tn(t=>t+1),(null==ue?void 0:ue.showBadge)&&fn(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(We.current=requestAnimationFrame(()=>Ie.current()))},function(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:s,cleanup:a}=t;Sr(()=>{var t,i;e&&n&&(null===(i=null===(t=o.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===i||i.call(t)),r.current=!0,s.current()},[e,n]);const l=i(a);l.current=a,u(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:Le,wasHydratingFromSSR:Ce,storeRef:kn,dirtyRef:$e,renderFnRef:Ie,cleanup:()=>{var t;return null===(t=An.current)||void 0===t?void 0:t.clear()}}),u(()=>{$e.current=!0,Ye()},[M,qe,Ve,St,ot,it,te,Ye]),function(t,e,n,o,i,r){u(()=>{if(!t)return;const s=setInterval(()=>{var s;const a=e.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(s=t.threshold)&&void 0!==s?s:5e3,u=l-a.lastIngestTime>c;u!==i&&(r(u),n.current=!0,o())},1e3);return()=>clearInterval(s)},[t,i,o])}(ue,kn,$e,Ye,hn,fn);const Nn=r(()=>{if(Tt||Lt)return;const t=kn.current;return(null==t?void 0:t.xIsDate)&&en?xs(en.x.domain()):void 0},[Tt,Lt,en]),Fn=Tt||Lt||Nn,Bn=Ze&&sn?Et?Et(sn):t(Ms,{hover:sn}):null,Wn=Bn?t(Vr,{x:sn.x,y:sn.y,containerWidth:qe,containerHeight:Ve,margin:He,className:"stream-frame-tooltip",children:Bn}):null,In=Dn.current,Yn=t(qr,{active:Cn.current>=0,hoverPoint:sn,margin:He,size:ze,shape:null==In?void 0:In.shape,width:null==In?void 0:In.w,height:null==In?void 0:In.h}),Hn=vs(j,X,"__semiotic_resolvedX","__semiotic_resolvedTime"),Gn=vs(L,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),Xn=Hn.key,qn=Gn.key,Vn=function(t,e,n){return o=>{if(!o||!n||!t.fn&&!e.fn)return o;let i=!1;const r=o.map(n=>{const o=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!o&&!r)return n;i=!0;const s=Object.assign({},n);return o&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return i?r:o}}(Hn,Gn,Wt&&Wt.length>0||!1);if(ho||!Le&&Ce){const n=kn.current;n&&O&&(n.ingest({inserts:Ue,bounded:!0}),n.computeScene({width:qe,height:Ve}));const i=null!==(c=null==n?void 0:n.scene)&&void 0!==c?c:[],r=null!==(h=null==n?void 0:n.scales)&&void 0!==h?h:null,s=Fn||(()=>{if((null==n?void 0:n.xIsDate)&&r)return xs(r.x.domain())})();return e("div",{ref:Ee,className:"stream-xy-frame"+(nt?" "+nt:""),role:"img","aria-label":we||("string"==typeof ne?ne:"XY chart"),style:{position:"relative",width:J?"100%":ze[0],height:tt?"100%":ze[1]},children:[t(Yr,{summary:Ae}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:ze[0],height:ze[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${He.left},${He.top})`,children:Xe}),e("g",{transform:`translate(${He.left},${He.top})`,children:[ot&&t("rect",{x:0,y:0,width:qe,height:Ve,fill:ot}),ee&&r&&ee.map((e,n)=>t(o.Fragment,{children:e(i,r,{width:qe,height:Ve})},"svgpre-"+n)),i.map((t,e)=>co(t,e,Te)).filter(Boolean)]})]}),t(Ar,{width:qe,height:Ve,totalWidth:ze[0],totalHeight:ze[1],margin:He,scales:r,showAxes:St,axes:_t,xLabel:Mt,yLabel:Pt,yLabelRight:Ot,xFormat:s,yFormat:$t||Ct,axisExtent:jt,showGrid:Yt,title:ne,legend:Ht,legendHoverBehavior:Gt,legendClickBehavior:Xt,legendHighlightedCategory:qt,legendIsolatedCategories:Vt,legendPosition:Ut,foregroundGraphics:oi(Ge,null===(f=kn.current)||void 0===f?void 0:f.customLayoutOverlays),marginalGraphics:ye,xValues:[],yValues:[],annotations:Wt,svgAnnotationRules:It,annotationFrame:0,xAccessor:Xn,yAccessor:qn,annotationData:Vn(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof R?R:void 0,linkedCrosshairName:Se,linkedCrosshairSourceId:Me})]})}return e("div",{ref:Ee,className:"stream-xy-frame"+(nt?" "+nt:""),role:"group","aria-label":we||("string"==typeof ne?ne:"XY chart"),tabIndex:0,style:{position:"relative",width:J?"100%":ze[0],height:tt?"100%":ze[1],overflow:"visible"},onKeyDown:zn,children:[ke&&t(Hr,{tableId:Be}),ke&&t(Ir,{scene:null!==(m=null===(y=kn.current)||void 0===y?void 0:y.scene)&&void 0!==m?m:[],chartType:M+" chart",tableId:Be,chartTitle:"string"==typeof ne?ne:void 0}),t(Yr,{summary:Ae}),e("div",{role:"img","aria-label":we||("string"==typeof ne?ne:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ze?Rn:void 0,onMouseLeave:Ze?$n:void 0,onClick:Rt?Ln:void 0,children:[Xe&&t("svg",{style:{position:"absolute",left:0,top:0,width:ze[0],height:ze[1],pointerEvents:"none"},children:t("g",{transform:`translate(${He.left},${He.top})`,children:Xe})}),t(xr,{width:qe,height:Ve,totalWidth:ze[0],totalHeight:ze[1],margin:He,scales:en,showAxes:St,axes:_t,showGrid:Yt,xFormat:Fn,yFormat:$t||Ct,axisExtent:jt}),t("canvas",{ref:Qe,"aria-label":Cr(null!==(b=null===(v=kn.current)||void 0===v?void 0:v.scene)&&void 0!==b?b:[],M+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:Ke,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t(Gr,{hoverPoint:sn}),t(Ar,{width:qe,height:Ve,totalWidth:ze[0],totalHeight:ze[1],margin:He,scales:en,showAxes:St,axes:_t,xLabel:Mt,yLabel:Pt,yLabelRight:Ot,xFormat:Fn,yFormat:$t||Ct,axisExtent:jt,showGrid:Yt,title:ne,legend:Ht,legendHoverBehavior:Gt,legendClickBehavior:Xt,legendHighlightedCategory:qt,legendIsolatedCategories:Vt,legendPosition:Ut,foregroundGraphics:oi(Ge,null===(x=kn.current)||void 0===x?void 0:x.customLayoutOverlays),marginalGraphics:ye,xValues:gn,yValues:yn,annotations:Wt,svgAnnotationRules:It,annotationFrame:Je,xAccessor:Xn,yAccessor:qn,annotationData:Vn(null===(k=kn.current)||void 0===k?void 0:k.getData()),pointNodes:null===(w=kn.current)||void 0===w?void 0:w.scene.filter(t=>"point"===t.type),curve:"string"==typeof R?R:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==ot&&!Kt,linkedCrosshairName:Se,linkedCrosshairSourceId:Me}),(ie||re)&&t(ei,{width:qe,height:Ve,totalWidth:ze[0],totalHeight:ze[1],margin:He,dimension:null!==(A=null==ie?void 0:ie.dimension)&&void 0!==A?A:"xy",scales:en,onBrush:null!=re?re:()=>{},binSize:W,snap:null==ie?void 0:ie.snap,binBoundaries:null!==(S=null==ie?void 0:ie.binBoundaries)&&void 0!==S?S:"bar"===M?null===(_=kn.current)||void 0===_?void 0:_.getBinBoundaries():void 0,snapDuring:null==ie?void 0:ie.snapDuring,streaming:"streaming"===P}),(null==ue?void 0:ue.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ue.badgePosition?{top:4,left:4}:"bottom-left"===ue.badgePosition?{bottom:4,left:4}:"bottom-right"===ue.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:hn?"#dc3545":"#28a745",color:"white"}),children:hn?"STALE":"LIVE"}),Yn,Wn]})]})});Ps.displayName="StreamXYFrame";const Os=c(null);function Ts(){return s(Os)}function $s(t){const e=[];for(const[n,o]of Object.entries(t.fields))if("point"===o.type)e.push(t=>o.values.has(t[n]));else{const[t,i]=o.range;e.push(e=>{const o=e[n];return o>=t&&i>=o})}return t=>e.every(e=>e(t))}function js(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}const[Ls,Cs]=fo(t=>({selections:new Map,setClause(e,n){t(t=>{const o=new Map(t.selections),i=js(o,e),r=new Map(i.clauses);return r.set(n.clientId,n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},clearClause(e,n){t(t=>{const o=t.selections.get(e);if(!o)return{};const i=new Map(t.selections),r=new Map(o.clauses);return r.delete(n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(e,n){t(t=>{const o=new Map(t.selections),i=js(o,e);return o.set(e,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(e){t(t=>{const n=new Map(t.selections),o=n.get(e);return o&&n.set(e,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Ds,Es]=fo(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function zs(t){const e=g(),n=t.clientId||e,{name:o}=t,i=Cs(t=>t.selections.get(o)),s=Cs(t=>t.setClause),l=Cs(t=>t.clearClause),c=r(()=>!!i&&i.clauses.size>0,[i]);return{predicate:r(()=>i&&0!==i.clauses.size?function(t,e){const n=[];for(const[o,i]of t.clauses)"crossfilter"===t.resolution&&o===e||n.push($s(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(i,n):()=>!0,[i,n]),isActive:c,selectPoints:a(t=>{const e={};for(const[n,o]of Object.entries(t))e[n]={type:"point",values:new Set(o)};s(o,{clientId:n,type:"point",fields:e})},[n,o,s]),selectInterval:a(t=>{const e={};for(const[n,o]of Object.entries(t))e[n]={type:"interval",range:o};s(o,{clientId:n,type:"interval",fields:e})},[n,o,s]),clear:a(()=>{l(o,n)},[l,o,n]),clientId:n}}const Rs=c(!1),Ns=c(null),Fs="undefined"==typeof window?u:h;function Bs(t,e,n){var o;const i=null!==(o=t.xValue)&&void 0!==o?o:null==e?void 0:e[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function Ws(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function Is(){var t;const e=Ao(t=>t.theme),n=null===(t=null==e?void 0:e.colors)||void 0===t?void 0:t.categorical;return n&&n.length>0?n:void 0}function Ys({data:t,colorBy:e,colorScale:n,showLegend:o,legendPosition:a="right",userMargin:l,defaults:c={top:50,bottom:60,left:70,right:40},categories:u}){const d=s(Rs),h=null!==s(Ns),f=void 0!==o?o:!d&&!!e,p=!!e&&(f||h),y=r(()=>{if(!p)return[];if(void 0!==u)return u;const n=new Set;for(const o of t){const t="function"==typeof e?e(o):o[e];null!=t&&n.add(t+"")}return Array.from(n)},[u,e,t,p]);!function(t){const e=s(Ns),n=g(),o=function(t){const e=new Set,n=[];for(const o of t)e.has(o)||(e.add(o),n.push(o));return n}(t),r=i([]);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(r.current,o)||(r.current=o);const a=r.current;Fs(()=>{if(e)return()=>e.unregisterCategories(n)},[e,n]),Fs(()=>{e&&e.registerCategories(n,a)},[e,n,a])}(h&&e?y:[]);const m=r(()=>{if(!f||!e)return;const o=function({data:t,colorBy:e,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((i,r)=>{const s=t.find("function"==typeof e?t=>e(t)===i:t=>t[e]===i),a=s?o(s,e,n):n?n(i):ee[r%ee.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}({data:t,colorBy:e,colorScale:n,getColor:oe,categories:y}),i=o.legendGroups.reduce((t,e)=>t+e.items.length,0);return 0!==i?o:void 0},[f,e,t,n,y]),v=r(()=>{const t="number"==typeof l?{top:l,bottom:l,left:l,right:l}:null!=l?l:{},e=Object.assign(Object.assign({},c),t),n=e=>null!=t[e];return m&&("right"===a&&!n("right")&&110>e.right?e.right=110:"left"===a&&!n("left")&&110>e.left?e.left=110:"top"===a&&!n("top")&&50>e.top?e.top=50:"bottom"===a&&!n("bottom")&&80>e.bottom&&(e.bottom=80)),e},[c,l,m,a]);return{legend:m,margin:v,legendPosition:a}}o.createContext(void 0);const Hs={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Gs(t,e,n){if(!1!==e)return t;const o=Object.assign({},t);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Xs({componentName:n,message:o,diagnosticHint:i,width:r,height:s}){return t("div",{role:"alert",style:{width:r,height:Math.max(s,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:e("div",{style:{textAlign:"center",maxWidth:400},children:[t("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:n}),t("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:o}),i&&t("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:i})]})})}class qs extends o.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,t,e)}render(){if(this.state.error){const{fallback:e}=this.props,n=this.state.error;return"function"==typeof e?e(n):void 0!==e?e:t(Xs,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Vs({componentName:e,width:n,height:o,children:i}){return t(qs,{fallback:i=>t(Xs,{componentName:e,message:i.message,width:n,height:o}),children:i})}"undefined"!=typeof process&&process;const Us={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Zs={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Qs(e){const{data:n,rawData:o,colorBy:i,colorScheme:s,legendInteraction:l,legendPosition:c,selection:h,linkedHover:f,fallbackFields:p,unwrapData:y=!1,onObservation:m,chartType:v,chartId:b,showLegend:x,userMargin:k,marginDefaults:w,onClick:A,hoverHighlight:S,loading:_,loadingContent:M,emptyContent:P,width:O,height:T}=e,$=void 0===o,j=r(()=>Vo(n),[n]),[L,C]=d([]),D=a(t=>{C(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),E="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:z,hoverSelectionHook:R,customHoverBehavior:N,customClickBehavior:F,crosshairSourceId:B}=function({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:s,chartId:l,onClick:c,hoverHighlight:h,colorByField:f}){const p=g(),y=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(e,n),m=zs({name:(null==t?void 0:t.name)||"__unused__"}),v=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:o,isActive:i,selectPoints:r,clear:s}=zs({name:e});return{onHover:a(t=>{if(!t)return void s();const e={};for(const o of n){const n=t[o];void 0!==n&&(e[o]=[n])}Object.keys(e).length>0&&r(e)},[n,r,s,e]),predicate:o,isActive:i}}({name:(null==y?void 0:y.name)||"hover",fields:(null==y?void 0:y.fields)||n||[]}),b=Es(t=>t.pushObservation),x=t?{isActive:m.isActive,predicate:m.predicate}:null,[k,w]=d(null),A=f||n[0],S=r(()=>{if(!h||null==k||!A)return null;const t=k,e=A;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[e]?n[e]:(null!==(o=n[e])&&void 0!==o?o:"")+"")===t}}},[h,k,A]),_=a(t=>{var n,o;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==y?void 0:y.mode)&&y.xField){const n=Bs(t,e,y.xField);null!=n&&function(t,e,n){const o=ir.positions.get(t);(null==o?void 0:o.locked)||o&&o.xValue===e&&o.sourceId===n||(ir={positions:new Map(ir.positions).set(t,{xValue:e,sourceId:n})},sr())}(y.name||"hover",n,p)}"x-position"!==(null==y?void 0:y.mode)&&v.onHover(e)}else"x-position"===(null==y?void 0:y.mode)&&ar(y.name||"hover",p),"x-position"!==(null==y?void 0:y.mode)&&v.onHover(null);if(h&&A)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[A];w(null!=n?n+"":null)}else w(null);if(i||b){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const r=Ws(t),s=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(o=t.y)&&void 0!==o?o:0});i&&i(s),b&&b(s)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});i&&i(t),b&&b(t)}}},[e,v,y,p,i,s,l,b,h,A]),M=a(t=>{var e,n,o,r;if("x-position"===(null==y?void 0:y.mode)&&y.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=Bs(t,e,y.xField);null!=n&&function(t,e,n){const o=ir.positions.get(t);if(null==o?void 0:o.locked){const e=new Map(ir.positions);return e.delete(t),ir={positions:e},sr(),!1}ir={positions:new Map(ir.positions).set(t,{xValue:e,sourceId:n,locked:!0})},sr()}(y.name||"hover",n,p)}if(t&&c){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]),c(o,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(i||b){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const n=Ws(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(o=t.x)&&void 0!==o?o:0,y:null!==(r=t.y)&&void 0!==r?r:0});i&&i(s),b&&b(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});i&&i(t),b&&b(t)}}},[c,i,b,s,l,y,p]);return u(()=>{if("x-position"!==(null==y?void 0:y.mode))return;const t=y.name||"hover";return()=>{lr(t,p),ar(t,p)}},[null==y?void 0:y.mode,null==y?void 0:y.name,p]),{activeSelectionHook:x,hoverSelectionHook:S,customHoverBehavior:_,customClickBehavior:M,crosshairSourceId:p}}({selection:h,linkedHover:f,fallbackFields:p,unwrapData:y,onObservation:m,chartType:v,chartId:b,onClick:A,hoverHighlight:S,colorByField:E}),W=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(f,B),I=function(t,e,n){const o=Ts(),i=Is();return r(()=>{var r;if(!e)return;const s=null!==(r=null!=n?n:i&&i.length>0?i:void 0)&&void 0!==r?r:"category10";if(0!==t.length){if("function"==typeof e){const n=Array.from(new Set(t.map(t=>e(t)+"")));if(o&&Object.keys(o).length>0){const t=ie(n.map(t=>({_cat:t})),"_cat",s);return e=>o[e]||t(e)}return ie(n.map(t=>({_cat:t})),"_cat",s)}if(o&&Object.keys(o).length>0){const n=ie(t,e,s);return t=>o[t]||n(t)}return ie(t,e,s)}if(o&&Object.keys(o).length>0){const t=ie([{_:"a"}],"_",s);return e=>o[e]||t(e)}},[t,e,n,o,i])}(j,i,s),Y=r(()=>{if(!i)return[];const t=new Set;for(const e of j){const n="function"==typeof i?i(e):e[i];null!=n&&t.add(n+"")}return Array.from(t)},[j,i]),H=r(()=>$&&L.length>0?L:Y,[$,L,Y]),G=function(t,e,n){const[o,i]=d(null),[s,l]=d(new Set),c=a(e=>{"highlight"===t&&i(e?e.label:null)},[t]),u=a(e=>{"isolate"===t&&l(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===n.length?new Set:o})},[t,n.length]),h=r(()=>{if(!t||"none"===t||!e)return null;const n="string"==typeof e?e:null;return"highlight"===t&&null!=o?{isActive:!0,predicate:t=>(n?t[n]:"function"==typeof e?e(t):null)===o}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=n?t[n]:"function"==typeof e?e(t):null;return s.has(o)}}:null},[t,e,o,s]);return{highlightedCategory:"highlight"===t?o:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:c,onLegendClick:u,legendSelectionHook:h}}(l,i,H),X=r(()=>R||(G.legendSelectionHook?G.legendSelectionHook:z),[R,G.legendSelectionHook,z]),q=function(t){const e=Ao(t=>t.theme.colors.selectionOpacity);return r(()=>{var n,o;if(void 0!==t||void 0!==e)return Object.assign(Object.assign({name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:""},t),{unselectedOpacity:null!==(o=null==t?void 0:t.unselectedOpacity)&&void 0!==o?o:e})},[t,e])}(h),V=Is(),U=Ts(),Z=r(()=>{if(I)return I;if(!i||0===H.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:V&&V.length>0?V:ee,e="__streamCat",n=ie(H.map(t=>({[e]:t})),e,t);return t=>(null==U?void 0:U[t])||n(t)||"#999"},[I,i,H,s,V,U]),{legend:Q,margin:K,legendPosition:J}=Ys({data:j,colorBy:i,colorScale:Z,showLegend:x,legendPosition:c,userMargin:k,defaults:w,categories:H}),tt=r(()=>{const t={};return Q&&(t.legend=Q,t.legendPosition=J),l&&"none"!==l&&(t.legendHoverBehavior=G.onLegendHover,t.legendClickBehavior=G.onLegendClick,t.legendHighlightedCategory=G.highlightedCategory,t.legendIsolatedCategories=G.isolatedCategories),$&&i&&(t.legendCategoryAccessor=i,t.onCategoriesChange=D),t},[Q,J,l,G.onLegendHover,G.onLegendClick,G.highlightedCategory,G.isolatedCategories,$,i,D]),et=Array.isArray(o)?Vo(o):o,nt=function(e,n,o,i){if(!e)return null;if(!1===i)return null;if(null!=i)return t("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(o/40)),s=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),l=Math.floor((o-(r*(s+a)-a))/2);return t("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,o)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Zs),{position:"absolute",top:l+o*(s+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:s,opacity:.5+o%2*.2})},o))})}(_,O,T,M),ot=nt?null:function(e,n,o,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},Us),{width:n,height:o}),children:i||"No data available"}):null}(et,O,T,P);return{data:j,colorScale:I,allCategories:H,legendState:G,effectiveSelectionHook:X,activeSelectionHook:z,customHoverBehavior:N,customClickBehavior:F,legend:Q,margin:K,legendPosition:J,earlyReturn:nt||ot||null,legendBehaviorProps:tt,crosshairProps:W,resolvedSelection:q}}function Ks(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("string"==typeof t){if(""===t.trim())return NaN;const e=+t;return Number.isFinite(e)?e:NaN}return NaN}function Js(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,l=null,c=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;i.length>t;t++){const r=i[t],g=e(r),p=n(r),y=o(r);if(!Number.isFinite(g)||!Number.isFinite(p)||!Number.isFinite(y))continue;const m=u(p,y);if(null!==m)if(null!=a){if(l&&l.w!==m){let t,e;if(c.length>0)t=c[0].x,e=c[0].y;else{const n=p-l.a-(y-l.b);if(0!==n){const o=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+o*(g-l.x),e=l.a+o*(p-l.a)}else t=l.x,e=l.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;c.length>t;t++)f(c[t],a)}else for(const t of c)f(t,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else{a=m;for(const t of c)f(t,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else c.push({x:g,y:p,datum:r})}for(const t of c)f(t,null!=a?a:"A");return r}const ta=f(function(n,o){const s=i(null),l=function(t,e){var n,o,i,r,s,a,l;const c=Hs[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(n=e.width)&&void 0!==n?n:c.width,height:null!==(o=e.height)&&void 0!==o?o:c.height,showAxes:null!==(i=e.showAxes)&&void 0!==i?i:c.showAxes,showGrid:null!==(r=e.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=e.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:Gs(c.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:u}}(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:c,margin:u,className:h,xFormat:f,yFormat:g,xAccessor:y="x",seriesAAccessor:m="a",seriesBAccessor:v="b",seriesALabel:b="A",seriesBLabel:x="B",seriesAColor:k="var(--semiotic-danger, #dc2626)",seriesBColor:w="var(--semiotic-info, #2563eb)",showLines:A=!0,lineWidth:S=1.5,showPoints:_=!1,pointRadius:M=3,curve:P="linear",areaOpacity:O=.6,gradientFill:T,tooltip:$,annotations:j,xExtent:L,yExtent:C,frameProps:D={},selection:E,linkedHover:z,onObservation:R,onClick:N,hoverHighlight:F,chartId:B,loading:W,loadingContent:I,emptyContent:Y,legendInteraction:H,legendPosition:G,pointIdAccessor:X,windowSize:q}=n,{width:V,height:U,enableHover:Z,showGrid:Q,showLegend:K,title:J,description:tt,summary:et,accessibleTable:nt,xLabel:ot,yLabel:it}=l,rt=r(()=>"function"==typeof y?t=>Ks(y(t)):t=>Ks(t[y]),[y]),st=r(()=>"function"==typeof m?t=>Ks(m(t)):t=>Ks(t[m]),[m]),at=r(()=>"function"==typeof v?t=>Ks(v(t)):t=>Ks(t[v]),[v]),[lt,ct]=d([]),ut=i([]),dt=null==c,ht=r(()=>Vo(dt?lt:c),[dt,lt,c]),ft=r(()=>Js(ht,rt,st,at),[ht,rt,st,at]),gt=r(()=>A?function(t,e,n,o){if(!t.length)return[];const i=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of i){const i=e(t),s=n(t),a=o(t);Number.isFinite(s)&&r.push({__x:i,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:i,__y:a,__diffSegment:"line-B"})}return r}(ht,rt,st,at):[],[A,ht,rt,st,at]),pt=r(()=>[...ft,...gt],[ft,gt]),yt=r(()=>{const t=new Set;for(const e of ft)t.add(e.__diffSegment);return Array.from(t)},[ft]);p(o,()=>{const t=t=>{const e=q&&t.length>q?t.slice(t.length-q):t;ut.current=e,ct(e)},e=X?"function"==typeof X?X:t=>t[X]:null;return{push:e=>t([...ut.current,e]),pushMany:e=>t([...ut.current,...e]),remove:n=>{if(!e)return[];const o=Array.isArray(n)?n:[n],i=[],r=[];for(const t of ut.current)o.includes(e(t))?i.push(t):r.push(t);return t(r),i},update:(n,o)=>{if(!e)return[];const i=Array.isArray(n)?n:[n],r=[],s=ut.current.map(t=>{if(i.includes(e(t))){const e=o(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>dt?ut.current:ht,getScales:()=>{var t,e;return null!==(e=null===(t=s.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[dt,ht,X,q]);const mt=Qs({data:ht,rawData:c,colorBy:"__diffWinner",colorScheme:[k,w],legendInteraction:H,legendPosition:G,selection:E,linkedHover:z,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:N,hoverHighlight:F,chartType:"DifferenceChart",chartId:B,showLegend:K,userMargin:u,marginDefaults:l.marginDefaults,loading:W,loadingContent:I,emptyContent:Y,width:V,height:U}),vt=r(()=>{if(!1!==K)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:b,color:k},{label:x,color:w}]}]}},[K,b,x,k,w]),bt=a(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?k:w,stroke:"none",fillOpacity:O}},[k,w,O]),xt=a(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,strokeWidth:S,fill:"none"}),[k,w,S]),kt=a(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,r:M}),[k,w,M]),wt=a(n=>{var o;const i=n.data,r=n.allSeries,s=null!==(o=n.xValue)&&void 0!==o?o:null==i?void 0:i.__x;let a=null==i?void 0:i.__valA,l=null==i?void 0:i.__valB;if(r&&r.length>0){const t=r.find(t=>"line-A"===t.group),e=r.find(t=>"line-B"===t.group);null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(a=t.value),null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(l=e.value)}if(null!=s&&(null==a||null==l)){const t=ht.find(t=>rt(t)===s);t&&(null==a&&(a=st(t)),null==l&&(l=at(t)))}const c=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",u=f&&null!=s?f(s):null!=s?s+"":"";return e("div",{className:"semiotic-tooltip",style:Uo,children:[u&&t("div",{style:{fontWeight:600,marginBottom:4},children:u}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:k,display:"inline-block",borderRadius:2}}),e("span",{children:[b,": ",c(a)]})]}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:w,display:"inline-block",borderRadius:2}}),e("span",{children:[x,": ",c(l)]})]}),null!=a&&null!=l&&Number.isFinite(a)&&Number.isFinite(l)&&e("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",c(a-l)]})]})},[ht,rt,st,at,f,k,w,b,x]),At="multi"===$,St=r(()=>{if(!1===$)return()=>null;if(At)return wt;const e=function(e){if(!0!==e){if("function"==typeof e){const n=e;return e=>{var o;const i=!0===(null==e?void 0:e.__semioticHoverData)||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?null!==(o=e.data)&&void 0!==o?o:{}:e,r=n(i);return null==r?null:t("div",{className:"semiotic-tooltip",style:Uo,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Ko(e):Ko())}}($);return e||wt},[$,At,wt]),_t=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"mixed",data:pt,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:yt,curve:P,areaStyle:bt,lineStyle:xt},_&&{pointStyle:kt}),{size:[V,U],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:mt.margin,showAxes:l.showAxes,xLabel:ot,yLabel:it,xFormat:f,yFormat:g,enableHover:Z,showGrid:Q}),T&&{gradientFill:!0===T?{topOpacity:.85,bottomOpacity:.15}:T}),vt&&{legend:vt,legendPosition:mt.legendPosition}),function(t){const{title:e,description:n,summary:o,accessibleTable:i,className:r,animate:s,axisExtent:a}=t,l={};return e&&(l.title=e),n&&(l.description=n),o&&(l.summary=o),void 0!==i&&(l.accessibleTable=i),r&&(l.className=r),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),l}({title:J,description:tt,summary:et,accessibleTable:nt,className:h,animate:n.animate,axisExtent:n.axisExtent})),{tooltipContent:St}),At&&{tooltipMode:"multi"}),function(t){const{linkedHover:e,onObservation:n,onClick:o,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=t,l={};return(e||n||o||i)&&(l.customHoverBehavior=r),(a?n||o||e:n||o)&&(l.customClickBehavior=s),l}({linkedHover:z,onObservation:R,onClick:N,hoverHighlight:F,customHoverBehavior:mt.customHoverBehavior,customClickBehavior:mt.customClickBehavior})),j&&j.length>0&&{annotations:j}),L&&{xExtent:L}),C&&{yExtent:C}),mt.crosshairProps),D);return mt.earlyReturn?mt.earlyReturn:t(Vs,{componentName:"DifferenceChart",width:V,height:U,children:t(Ps,Object.assign({ref:s},_t))})});function ea(t,e,n){return"function"==typeof t?t(n):n[t||e]}function na(t){return t instanceof Date?t.getTime():Number(t)}function oa(t,e){return qt(1===e?.5:t/(e-1))}"function"==typeof ta&&(ta.displayName="DifferenceChart");const ia={frameType:"geo",buildProps:(t,e,n,o,i)=>{var r,s,a,l,c;const u=(Array.isArray(t)?t:null)||i.flows||[],d=i.nodeIdAccessor||"id",h=i.valueAccessor||"value",f=i.xAccessor||"lon",g=i.yAccessor||"lat",p="function"==typeof f?f:t=>t[f],y="function"==typeof g?g:t=>t[g],m=(i.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:p(t),y:y(t)})),v=new Map;for(const t of m)v.set(t[d]+"",t);const b=null!==(r=i.edgeColorBy)&&void 0!==r?r:e,x="function"==typeof b,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),n=v.get(t.target+"");return e&&n?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}):null}).filter(Boolean),w="__flowMapEdgeColor",A=b?x?ie(k.map(t=>({[w]:b(t)})),w,n||"category10"):ie(k,b,n||"category10"):null,S=t=>b&&A?oe(t,b,A):"#007bff";let _=1/0,M=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(_>e&&(_=e),e>M&&(M=e))}const P=M>_?M-_:0,[O,T]=null!==(a=i.edgeWidthRange)&&void 0!==a?a:[1,8],$=T-O,j=null!==(l=i.edgeOpacity)&&void 0!==l?l:.6,L=null!==(c=i.edgeLinecap)&&void 0!==c?c:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:i.lineType||"geo",flowStyle:i.flowStyle||"basic",areas:i.areas,areaStyle:i.areaStyle,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(null==t?void 0:t[h]),n=O+Math.max(0,Math.min(1,P>0?((Number.isFinite(e)?e:_)-_)/P:0))*$;return{stroke:S(t),strokeWidth:n,strokeLinecap:L,opacity:j,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}},ra={Sparkline:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"line",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"area",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",y0Accessor:i.y0Accessor,groupAccessor:i.areaBy||e,colorAccessor:e,colorScheme:n},o)},DifferenceChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=i.xAccessor||"x",l=i.seriesAAccessor||"a",c=i.seriesBAccessor||"b",u=t=>na(ea(a,"x",t)),d=t=>na(ea(l,"a",t)),h=t=>na(ea(c,"b",t)),f=i.seriesAColor||"var(--semiotic-danger, #dc2626)",g=i.seriesBColor||"var(--semiotic-info, #2563eb)",p=null!==(r=i.areaOpacity)&&void 0!==r?r:.6,y=null!==(s=i.lineWidth)&&void 0!==s?s:1.5,m=!1!==i.showLines,v=Js(Array.isArray(t)?t:[],u,d,h),b=[];if(m&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(u(t))).sort((t,e)=>u(t)-u(e));for(const t of e){const e=u(t),n=d(t),o=h(t);Number.isFinite(n)&&b.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&b.push({__x:e,__y:o,__diffSegment:"line-B"})}}const x=[...v,...b],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:x,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:k,areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?f:g,stroke:"none",fillOpacity:p}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?f:g,strokeWidth:y,fill:"none"}),curve:i.curve||"linear"},o)}},StackedAreaChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",groupAccessor:i.areaBy,colorAccessor:e||i.areaBy,colorScheme:n,normalize:i.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,colorScheme:n},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"candlestick",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.highAccessor||"high",highAccessor:i.highAccessor||"high",lowAccessor:i.lowAccessor||"low",openAccessor:i.openAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"scatter",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,sizeAccessor:i.sizeBy,sizeRange:i.sizeRange||[5,40],colorScheme:n},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,n,o,i)=>{var r,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",o=e.yAccessor||"y",i=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:na(ea(e.orderAccessor,"order",t))-na(ea(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=na(ea(n,"x",t)),i=na(ea(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&s++}let a=0;for(const t of i){if(null==t||"object"!=typeof t)continue;const e=na(ea(n,"x",t)),i=na(ea(o,"y",t));Number.isFinite(e)&&Number.isFinite(i)&&r.set(t,{idx:a++,total:s})}return{data:i,orderMap:r}}(t,i),l=null!==(r=i.pointRadius)&&void 0!==r?r:4;return Object.assign({chartType:"line",data:a.data,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:i.lineStyle||{stroke:i.stroke||"#6366f1",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:l,opacity:i.opacity},pointStyle:t=>{var e,n;const o=a.orderMap.get(t),i=null!==(e=null==o?void 0:o.idx)&&void 0!==e?e:0,r=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:r>0?oa(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},o)}},QuadrantChart:{frameType:"xy",buildProps:(t,e,n,i,r)=>{var s,a;const l=r.xCenter,c=r.yCenter,u=r.quadrants,d=r.centerlineStyle||{},h=!1!==r.showQuadrantLabels,f=null!==(s=r.quadrantLabelSize)&&void 0!==s?s:12,g=d.stroke||"#999",p=null!==(a=d.strokeWidth)&&void 0!==a?a:1,y=Array.isArray(d.strokeDasharray)?d.strokeDasharray.join(","):d.strokeDasharray,m=o.createElement,v=u?[(t,e,n)=>{if(!(null==e?void 0:e.x)||!(null==e?void 0:e.y))return null;const i=n.width,r=n.height,s=null!=l?e.x(l):i/2,a=null!=c?e.y(c):r/2;if(null!=l&&!Number.isFinite(s))return null;if(null!=c&&!Number.isFinite(a))return null;const d=Math.max(0,Math.min(i,s)),v=Math.max(0,Math.min(r,a)),b=[{c:u.topLeft,x:0,y:0,w:d,h:v},{c:u.topRight,x:d,y:0,w:i-d,h:v},{c:u.bottomLeft,x:0,y:v,w:d,h:r-v},{c:u.bottomRight,x:d,y:v,w:i-d,h:r-v}],x=h?[m("text",{key:"ltl",x:8,y:8+f,fill:u.topLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.topLeft.label),m("text",{key:"ltr",x:i-8,y:8+f,fill:u.topRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.topRight.label),m("text",{key:"lbl",x:8,y:r-8,fill:u.bottomLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.bottomLeft.label),m("text",{key:"lbr",x:i-8,y:r-8,fill:u.bottomRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.bottomRight.label)]:[];return m(o.Fragment,null,...b.map((t,e)=>{var n;return t.w>0&&t.h>0?m("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:null!==(n=t.c.opacity)&&void 0!==n?n:.08}):null}),m("line",{key:"vc",x1:d,y1:0,x2:d,y2:r,stroke:g,strokeWidth:p,strokeDasharray:y}),m("line",{key:"hc",x1:0,y1:v,x2:i,y2:v,stroke:g,strokeWidth:p,strokeDasharray:y}),...x)}]:void 0;return Object.assign(Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle},i),v&&{svgPreRenderers:v})}},Heatmap:{frameType:"xy",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"heatmap",data:t,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",valueAccessor:i.valueAccessor,colorScheme:n||i.colorScheme||"blues",showValues:i.showValues,cellBorderColor:i.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,colorAccessor:e,colorScheme:n,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.stackBy,colorAccessor:e||i.stackBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",normalize:i.normalize,oSort:null!==(r=i.sort)&&void 0!==r&&r},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",groupBy:i.groupBy,colorAccessor:e||i.groupBy,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical",oSort:null!==(r=i.sort)&&void 0!==r&&r,barPadding:i.barPadding},null!=i.roundedTop&&{roundedTop:i.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"radial",innerRadius:i.innerRadius||60,colorAccessor:e||i.categoryAccessor,colorScheme:n},null!=i.cornerRadius&&{cornerRadius:i.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"histogram",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",projection:"horizontal",bins:i.bins,colorAccessor:e,colorScheme:n},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"boxplot",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorScheme:n},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"violin",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,colorScheme:n},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swarm",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",colorAccessor:e,colorScheme:n},o),{showGrid:null===(r=o.showGrid)||void 0===r||r})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"swimlane",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.subcategoryAccessor,colorAccessor:e||i.subcategoryAccessor,categoryAccessor:i.categoryAccessor,subcategoryAccessor:i.subcategoryAccessor,colorScheme:n,projection:"horizontal"===i.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",bins:i.bins,amplitude:i.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"bar",data:t,oAccessor:i.categoryAccessor||"category",rAccessor:i.valueAccessor||"value",stackBy:i.levelAccessor||"level",colorAccessor:e||i.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===i.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{const r="vertical"===i.orientation;return Object.assign({chartType:r?"bar-funnel":"funnel",data:t,oAccessor:i.stepAccessor||"step",rAccessor:i.valueAccessor||"value",colorAccessor:e||i.categoryAccessor,categoryAccessor:i.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,colorScheme:n},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=null!==(r=i.min)&&void 0!==r?r:0,u=null!==(s=i.max)&&void 0!==s?s:100,d=null!==(a=i.sweep)&&void 0!==a?a:240,h=null!==(l=i.arcWidth)&&void 0!==l?l:.3,f=180+(360-d)/2,g=i.thresholds||[{value:u,color:"#4e79a7"}],p=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:c)})),y={};g.forEach((t,e)=>{y[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[v,b]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:p,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),b-(m.top||0)-(m.bottom||0))/2*(1-h)),sweepAngle:d,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:y[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:c,gMax:u,sweep:d,arcWidth:h,value:i.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"force",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,colorBy:e,colorScheme:n,iterations:i.iterations,forceStrength:i.forceStrength,showLabels:i.showLabels,nodeLabel:i.nodeLabel,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"sankey",nodes:i.nodes,edges:i.edges,nodeIDAccessor:i.nodeIdAccessor||i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,orientation:i.orientation,nodeAlign:i.nodeAlign,nodeWidth:i.nodeWidth,nodePaddingRatio:i.nodePaddingRatio,showLabels:i.showLabels,nodeLabel:i.nodeLabel,colorBy:e,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,colorScheme:n},o)},ProcessSankey:{frameType:"network",buildProps:(t,e,n,o,i)=>{var r,s,a,l;const c=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),u=i.sourceAccessor||"source",d=i.targetAccessor||"target",h=i.valueAccessor||"value",f=i.nodeIdAccessor||"id",g=i.startTimeAccessor||"startTime",p=i.endTimeAccessor||"endTime",y=i.systemInTimeAccessor,m=i.systemOutTimeAccessor,v=i.xExtentAccessor||"xExtent",b=i.edgeIdAccessor||"id",x=(t,e)=>"function"==typeof t?t(e):e[t],k=Array.isArray(i.edges)?i.edges:[],w=Array.isArray(i.nodes)?i.nodes:[],A=w.length>0?w:function(t,e,n,o){const i=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof o?o(t):t[o];i.add(e),i.add(r)}),Array.from(i).map(t=>({id:t}))}(0,k,u,d),S=[c(null===(r=i.domain)||void 0===r?void 0:r[0]),c(null===(s=i.domain)||void 0===s?void 0:s[1])],_=A.map(t=>{const e=x(f,t)+"",n=x(v,t),o={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=c(n[0]),e=c(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),M=k.map((t,e)=>{const n=x(b,t),o={id:null!=n?n+"":`${x(u,t)}-${x(d,t)}-${e}`,source:x(u,t)+"",target:x(d,t)+"",value:Number(x(h,t)),startTime:c(x(g,t)),endTime:c(x(p,t)),__raw:t};if(y){const e=c(x(y,t));Number.isFinite(e)&&(o.systemInTime=e)}if(m){const e=c(x(m,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[P,O]=null!==(a=o.size)&&void 0!==a?a:[600,400],T=Object.assign({top:20,right:20,bottom:20,left:20},o.margin),$=null!==(l=o.legendPosition)&&void 0!==l?l:"right";o.showLegend&&("right"===$?T.right=Math.max(T.right,100):"left"===$?T.left=Math.max(T.left,100):"bottom"===$?T.bottom=Math.max(T.bottom,70):"top"===$&&(T.top=Math.max(T.top,40)));const j=T,L=P-j.left-j.right,C=O-j.top-j.bottom,D=Array.isArray(n)?n:null,E=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],z="function"==typeof e?e:null,R=z?A.map(t=>({_cat:z(t)})):A,N=z?"_cat":"string"==typeof e?e:void 0,F=N?ie(R,N,n):null,B=new Map;for(const t of _)B.set(t.id,t.__raw);const{layoutConfig:W,issues:I}=Go({nodes:_,edges:M,domain:S,plotW:L,plotH:C,ribbonLane:i.ribbonLane||"both",edgeOpacity:"number"==typeof i.edgeOpacity?i.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&B.has(t)){const n=B.get(t);return z?oe({_cat:z(n)},"_cat",null!=F?F:void 0):oe(n,e,null!=F?F:void 0)}const o=D||E;return o[n%o.length]},layoutOpts:{pairing:i.pairing||"temporal",packing:i.packing||"reuse",laneOrder:i.laneOrder||"crossing-min",lifetimeMode:i.lifetimeMode||"half"}});if(I.length>0){const t=I.map(Do).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:A,edges:k,customNetworkLayout:Xo,layoutConfig:W,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},o),{margin:j})}},ChordDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"chord",nodes:i.nodes,edges:i.edges,valueAccessor:i.valueAccessor,padAngle:i.padAngle,groupWidth:i.groupWidth,showLabels:i.showLabels,colorBy:e,edgeColorBy:i.edgeColorBy,colorScheme:n},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"cluster"===i.layout?"cluster":"tree",data:t,childrenAccessor:i.childrenAccessor,colorBy:e,colorByDepth:i.colorByDepth,orientation:i.orientation,showLabels:i.showLabels,colorScheme:n},o)},Treemap:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,showLabels:i.showLabels,colorScheme:n},o)},CirclePack:{frameType:"network",buildProps:(t,e,n,o,i)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:i.childrenAccessor,hierarchySum:i.valueAccessor,colorBy:e,colorByDepth:i.colorByDepth,colorScheme:n},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({areas:i.areas,projection:i.projection||"equalEarth",areaStyle:i.areaStyle,valueAccessor:i.valueAccessor,colorScheme:n||"blues",graticule:i.graticule,fitPadding:i.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,o,i)=>Object.assign({points:t||i.points,xAccessor:i.xAccessor||"lon",yAccessor:i.yAccessor||"lat",areas:i.areas,areaStyle:i.areaStyle,sizeBy:i.sizeBy,colorBy:e,colorScheme:n,projection:i.projection||"equalEarth",graticule:i.graticule,fitPadding:i.fitPadding},o)},FlowMap:ia};function sa(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function aa(t){return Math.round(100*t)/100+""}function la(n,o){const i=Mo(o.theme),r=o.idPrefix?o.idPrefix+"-":"",s="string"==typeof o.title?o.title:void 0,a=s?r+"semiotic-title":void 0,l=o.description?r+"semiotic-desc":void 0,c=[a,l].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:o.className,width:o.width,height:o.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[s&&t("title",{id:a,children:s}),o.description&&t("desc",{id:l,children:o.description}),o.defs&&t("defs",{children:o.defs}),o.background&&"transparent"!==o.background&&t("rect",{x:0,y:0,width:o.width,height:o.height,fill:o.background}),t("g",{id:r+"data-area",transform:o.innerTransform,children:n}),s&&t("text",{id:r+"chart-title",x:o.width/2,y:16,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:s}),o.legend&&t("g",{id:r+"legend",children:o.legend}),o.outerElements]})}function ca(i){var r,s,a,l;const c=_o(i.theme),u=i.size||[500,300],d=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),i.margin),h=Vo(i.data),f=i.legendPosition;i.showLegend&&(f&&"right"!==f?"left"===f?d.left=Math.max(d.left,100):"bottom"===f?d.bottom=Math.max(d.bottom,70):"top"===f&&(d.top=Math.max(d.top,40)):d.right=Math.max(d.right,100));const g=u[0]-d.left-d.right,p=u[1]-d.top-d.bottom,m="streaming"===i.runtimeMode||["bar","swarm","waterfall"].includes(i.chartType),v=i.colorScheme||c.colors.categorical,b={chartType:i.chartType,windowSize:null!==(r=i.windowSize)&&void 0!==r?r:200,windowMode:null!==(s=i.windowMode)&&void 0!==s?s:"sliding",arrowOfTime:m&&null!==(a=i.arrowOfTime)&&void 0!==a?a:"right",extentPadding:null!==(l=i.extentPadding)&&void 0!==l?l:.1,xAccessor:m?void 0:i.xAccessor,yAccessor:m?void 0:i.yAccessor,timeAccessor:m?i.timeAccessor:void 0,valueAccessor:i.valueAccessor,colorAccessor:i.colorAccessor,sizeAccessor:i.sizeAccessor,groupAccessor:i.groupAccessor,categoryAccessor:i.categoryAccessor,lineDataAccessor:i.lineDataAccessor,xExtent:i.xExtent,yExtent:i.yExtent,sizeRange:i.sizeRange,binSize:i.binSize,normalize:i.normalize,boundsAccessor:i.boundsAccessor,boundsStyle:i.boundsStyle,y0Accessor:i.y0Accessor,areaGroups:i.areaGroups?i.areaGroups instanceof Set?i.areaGroups:new Set(i.areaGroups):void 0,curve:i.curve,gradientFill:!0===i.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===i.gradientFill?void 0:i.gradientFill,lineGradient:i.lineGradient,openAccessor:i.openAccessor,highAccessor:i.highAccessor,lowAccessor:i.lowAccessor,closeAccessor:i.closeAccessor,candlestickStyle:i.candlestickStyle,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,colorScheme:v,barColors:i.barColors},x=new _e(b);if(i.data&&x.ingest({inserts:h,bounded:!0}),x.computeScene({width:g,height:p}),!x.scales||0===x.scene.length)return y.renderToStaticMarkup(la(null,{width:u[0],height:u[1],className:"stream-xy-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:c,innerTransform:`translate(${d.left},${d.top})`,idPrefix:i._idPrefix}));const k=i._idPrefix,w=i.showGrid?function(n,o,i,r){const{grid:s}=Mo(i),a=r?r+"-":"",l=n.x.ticks(5),c=n.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((e,i)=>{const r=n.x(e);return t("line",{x1:r,y1:0,x2:r,y2:o.height,stroke:s,strokeWidth:.5},"gx-"+i)}),c.map((e,i)=>{const r=n.y(e);return t("line",{x1:0,y1:r,x2:o.width,y2:r,stroke:s,strokeWidth:.5},"gy-"+i)})]})}(x.scales,{width:g,height:p},c,k):null,A=x.scene.map((t,e)=>co(t,e,k)).filter(Boolean),S=!1!==i.showAxes?function(n,o,i,r,s){var a,l,c,u;const d=Mo(r),h=n.x.ticks(5).map(t=>({pixel:n.x(t),label:(i.xFormat||i.tickFormatTime||aa)(t)})),f=n.y.ticks(5).map(t=>({pixel:n.y(t),label:(i.yFormat||i.tickFormatValue||aa)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:d.border,strokeWidth:1}),h.map((n,i)=>e("g",{transform:`translate(${n.pixel},${o.height})`,children:[t("line",{y2:5,stroke:d.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"xtick-"+i)),i.xLabel&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,children:i.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:d.border,strokeWidth:1}),f.map((n,o)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:d.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"ytick-"+o)),i.yLabel&&t("text",{x:15-(null!==(l=null===(a=i.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:o.height/2,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=i.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${o.height/2})`,children:i.yLabel})]})}(x.scales,{width:g,height:p},i,c,k):null,_=i.annotations?Lo({annotations:i.annotations,scales:{x:x.scales.x,y:x.scales.y},layout:{width:g,height:p},theme:c,xAccessor:"string"==typeof i.xAccessor?i.xAccessor:void 0,yAccessor:"string"==typeof i.yAccessor?i.yAccessor:void 0,idPrefix:k}):null,M=i.svgPreRenderers&&x.scales?i.svgPreRenderers.map((e,n)=>{try{return t(o.Fragment,{children:e(x.scene,x.scales,{width:g,height:p})},"pre-"+n)}catch(t){return null}}).filter(Boolean):null,P=i.showLegend?(()=>{const t=Oo(h,i.colorAccessor||i.groupAccessor);return 0===t.length?null:Po({categories:t,colorScheme:i.colorScheme,theme:c,position:i.legendPosition||"right",totalWidth:u[0],totalHeight:u[1],margin:d,hasTitle:!!i.title})})():null,O=o.isValidElement(i.legend)?i.legend:P,T=e(n,{children:[i.backgroundGraphics,M,w,A,S,_,i.foregroundGraphics]});return y.renderToStaticMarkup(la(T,{width:u[0],height:u[1],className:"stream-xy-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:c,innerTransform:`translate(${d.left},${d.top})`,legend:O,idPrefix:i._idPrefix}))}function ua(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const da=new Set(["tree","cluster","treemap","circlepack","partition"]);function ha(i){var r,s,a,l,c;const u=_o(i.theme),d=i.chartType||"force",h=i.size||[500,500],f=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),i.margin),g=i.legendPosition;i.showLegend&&(g&&"right"!==g?"left"===g?f.left=Math.max(f.left,100):"bottom"===g?f.bottom=Math.max(f.bottom,70):"top"===g&&(f.top=Math.max(f.top,40)):f.right=Math.max(f.right,100));const p=h[0]-f.left-f.right,m=h[1]-f.top-f.bottom,v=function(t){return Wn[t]}(d);if(!v)throw Error(`No layout plugin found for chart type: "${d}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const b={chartType:d,nodeIDAccessor:i.nodeIDAccessor,sourceAccessor:i.sourceAccessor,targetAccessor:i.targetAccessor,valueAccessor:i.valueAccessor,childrenAccessor:i.childrenAccessor,hierarchySum:i.hierarchySum,orientation:i.orientation,nodeAlign:i.nodeAlign,nodePaddingRatio:i.nodePaddingRatio,nodeWidth:i.nodeWidth,iterations:i.iterations,forceStrength:i.forceStrength,padAngle:i.padAngle,groupWidth:i.groupWidth,sortGroups:i.sortGroups,edgeSort:i.edgeSort,treeOrientation:i.treeOrientation,edgeType:i.edgeType,padding:i.padding,paddingTop:i.paddingTop,nodeStyle:i.nodeStyle,edgeStyle:i.edgeStyle,nodeLabel:i.nodeLabel,showLabels:i.showLabels,colorBy:i.colorBy,colorScheme:i.colorScheme||u.colors.categorical,edgeColorBy:i.edgeColorBy,edgeOpacity:i.edgeOpacity,colorByDepth:i.colorByDepth,nodeSize:i.nodeSize,nodeSizeRange:i.nodeSizeRange,customNetworkLayout:i.customNetworkLayout,layoutConfig:i.layoutConfig};let x,k;if(da.has(d)){const t=i.data||i.edges;if(!t||Array.isArray(t))return y.renderToStaticMarkup(la(null,{width:h[0],height:h[1],className:"stream-network-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:u,innerTransform:`translate(${f.left},${f.top})`,idPrefix:i._idPrefix}));b.__hierarchyRoot=t,x=[],k=[]}else{const t=Vo(i.nodes||[]),e=Array.isArray(i.edges)?Vo(i.edges):[];if(0===t.length&&0===e.length)return y.renderToStaticMarkup(la(null,{width:h[0],height:h[1],className:"stream-network-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:u,innerTransform:`translate(${f.left},${f.top})`,idPrefix:i._idPrefix}));if(k=function(t,e){const n=ua(e.sourceAccessor,"source"),o=ua(e.targetAccessor,"target"),i=ua(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:o(t)+"",value:Number(i(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(e,b),0===t.length&&k.length>0){const t=new Set;for(const e of k){const n=sa(e.source),o=sa(e.target);n&&t.add(n),o&&t.add(o)}x=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else x=function(t,e){const n=ua(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:n(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,b)}let w=[],A=[],S=[],_=null;if(b.customNetworkLayout){const t=In(b.colorScheme,u.colors.categorical,Bt),e=Yn(t),n={nodes:x,edges:k,dimensions:{width:p,height:m,plot:{x:0,y:0,width:p,height:m}},theme:{semantic:u.colors,categorical:[...t]},resolveColor:e,config:null!==(r=b.layoutConfig)&&void 0!==r?r:{}},o=b.customNetworkLayout(n);w=null!==(s=o.sceneNodes)&&void 0!==s?s:[],A=null!==(a=o.sceneEdges)&&void 0!==a?a:[],S=null!==(l=o.labels)&&void 0!==l?l:[],_=null!==(c=o.overlays)&&void 0!==c?c:null}else{v.computeLayout(x,k,b,[p,m]);const t=v.buildScene(x,k,b,[p,m]);w=t.sceneNodes,A=t.sceneEdges,S=t.labels}const M=Mo(u);for(const t of S)t.fill||(t.fill=M.text);const P=A.map((e,n)=>function(e,n){switch(e.type){case"line":return t("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const o=e;return t("path",{d:o.pathD,fill:lo(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=e;return t("path",{d:o.pathD,fill:lo(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=e;return t("path",{d:o.pathD,fill:lo(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),O=w.map((e,n)=>function(e,n){switch(e.type){case"circle":{const o=e;return t("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:lo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=e;return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:lo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=e,i=B().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(ao)||"";return t("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:lo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),T=S.map((e,n)=>function(e,n){return t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean),$=i.annotations?Lo({annotations:i.annotations,scales:{},layout:{width:p,height:m},theme:u,idPrefix:i._idPrefix}):null,j=i.showLegend?(()=>{const t=t=>"string"==typeof t||"function"==typeof t,e=t(i.colorBy)?i.colorBy:t(i.nodeIDAccessor)?i.nodeIDAccessor:void 0,n=Oo(x.length>0?x.map(t=>t.data||{id:t.id}):Array.from(new Set(k.flatMap(t=>[sa(t.source),sa(t.target)]).filter(Boolean))).map(t=>({id:t})),e);return 0===n.length?null:Po({categories:n,colorScheme:i.colorScheme,theme:u,position:i.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:f,hasTitle:!!i.title})})():null,L=o.isValidElement(i.legend)?i.legend:j,C=e(n,{children:[i.backgroundGraphics,P,O,T,$,i.foregroundGraphics,_]});return y.renderToStaticMarkup(la(C,{width:h[0],height:h[1],className:"stream-network-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:u,innerTransform:`translate(${f.left},${f.top})`,legend:L,idPrefix:i._idPrefix}))}function fa(i){var r,s,a,l,c;const u=_o(i.theme),d=i.size||[500,400],h=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),i.margin),f=Vo(i.data),g=i.legendPosition;i.showLegend&&(g&&"right"!==g?"left"===g?h.left=Math.max(h.left,100):"bottom"===g?h.bottom=Math.max(h.bottom,70):"top"===g&&(h.top=Math.max(h.top,40)):h.right=Math.max(h.right,100));const p=d[0]-h.left-h.right,m=d[1]-h.top-h.bottom,v=i.projection||"vertical",b="radial"===v,x={chartType:i.chartType,windowSize:null!==(r=i.windowSize)&&void 0!==r?r:1e4,windowMode:null!==(s=i.windowMode)&&void 0!==s?s:"sliding",extentPadding:null!==(a=i.extentPadding)&&void 0!==a?a:.05,projection:v,oAccessor:i.oAccessor,rAccessor:i.rAccessor,colorAccessor:i.colorAccessor,stackBy:i.stackBy,groupBy:i.groupBy,categoryAccessor:i.categoryAccessor,valueAccessor:i.valueAccessor,timeAccessor:i.timeAccessor,rExtent:i.rExtent,oExtent:i.oExtent,barPadding:i.barPadding,roundedTop:i.roundedTop,innerRadius:i.innerRadius,cornerRadius:i.cornerRadius,normalize:i.normalize,startAngle:i.startAngle,sweepAngle:i.sweepAngle,bins:i.bins,showOutliers:i.showOutliers,showIQR:i.showIQR,amplitude:i.amplitude,oSort:i.oSort,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,dynamicColumnWidth:i.dynamicColumnWidth,pieceStyle:i.pieceStyle,summaryStyle:i.summaryStyle,colorScheme:i.colorScheme||u.colors.categorical,barColors:i.barColors},k=new qn(x);if(i.data&&k.ingest({inserts:f,bounded:!0}),k.computeScene({width:p,height:m}),!k.scales||0===k.scene.length)return y.renderToStaticMarkup(la(null,{width:d[0],height:d[1],className:"stream-ordinal-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:u,innerTransform:`translate(${h.left},${h.top})`,idPrefix:i._idPrefix}));const w=i._idPrefix,A=i.showGrid?function(e,n,o,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=Mo(o),a=i?i+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t("line",{x1:0,y1:i,x2:n.width,y2:i,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(k,{width:p,height:m},u,w):null,S=k.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let _=null;if(S){const n=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;n.length>t;t++)o=31*o+n.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(i),o=new Set;for(const t of k.scene)"rect"===t.type&&(null===(l=t.datum)||void 0===l?void 0:l.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");_=Array.from(o).map((o,i)=>function(n){const{id:o,background:i="transparent",stroke:r="#000",lineWidth:s=1.5,spacing:a=6,angle:l=45}=n,c=Math.max(8,Math.ceil(2*a));return e("pattern",{id:o,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==l?`rotate(${l})`:void 0,children:[i&&"transparent"!==i&&t("rect",{width:c,height:c,fill:i}),t("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:c,stroke:r,strokeWidth:s})]},o)}({id:`funnel-hatch-${n}-${i}`,background:o,stroke:"transparent"===u.colors.background?"#fff":u.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${n}-${e}`));for(const t of k.scene)if("rect"===t.type&&(null===(c=t.datum)||void 0===c?void 0:c.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const M=k.scene.map((t,e)=>uo(t,e)).filter(Boolean),P=!1!==i.showAxes?function(n,o,i,r,s){var a,l,c,u,d,h,f,g;const p=n.scales;if(!p)return null;if("radial"===p.projection)return null;const y=Mo(r),m="vertical"===p.projection,v=i.categoryFormat||i.oFormat,b=i.valueFormat||i.rFormat,x=i.categoryLabel||i.oLabel,k=i.valueLabel||i.rLabel,w=Object.values(n.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),A=p.r.ticks(5).map(t=>({pixel:p.r(t),label:(b||aa)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:y.border,strokeWidth:1}),w.map((n,i)=>e("g",{transform:`translate(${n.pixel},${o.height})`,children:[t("line",{y2:5,stroke:y.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oxtick-"+i)),x&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:x}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:y.border,strokeWidth:1}),A.map((n,o)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:y.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oytick-"+o)),k&&t("text",{x:15-(null!==(l=null===(a=i.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:o.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=i.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${o.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:o.height,x2:o.width,y2:o.height,stroke:y.border,strokeWidth:1}),A.map((n,i)=>e("g",{transform:`translate(${n.pixel},${o.height})`,children:[t("line",{y2:5,stroke:y.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oxtick-"+i)),k&&t("text",{x:o.width/2,y:o.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:o.height,stroke:y.border,strokeWidth:1}),w.map((n,o)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:y.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oytick-"+o)),x&&t("text",{x:15-(null!==(h=null===(d=i.margin)||void 0===d?void 0:d.left)&&void 0!==h?h:40),y:o.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=i.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${o.height/2})`,children:x})]})}(k,{width:p,height:m},i,u,w):null,O=i.annotations?Lo({annotations:i.annotations,scales:{r:k.scales.r,y:"vertical"===k.scales.projection?k.scales.r:void 0},layout:{width:p,height:m},theme:u,projection:v,idPrefix:w}):null,T=i.showLegend?(()=>{const t=Oo(f,i.colorAccessor||i.stackBy||i.groupBy);return 0===t.length?null:Po({categories:t,colorScheme:i.colorScheme,theme:u,position:i.legendPosition||"right",totalWidth:d[0],totalHeight:d[1],margin:h,hasTitle:!!i.title})})():null,$=o.isValidElement(i.legend)?i.legend:T,j=b?h.left+p/2:h.left,L=b?h.top+m/2:h.top,C=e(n,{children:[i.backgroundGraphics,A,M,P,O,i.foregroundGraphics]});return y.renderToStaticMarkup(la(C,{width:d[0],height:d[1],className:"stream-ordinal-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:u,innerTransform:`translate(${j},${L})`,legend:$,defs:_,idPrefix:i._idPrefix}))}function ga(i){var r,s,a,l,c,u,d,h,f,g,p,m,v,b;const x=_o(i.theme),k=i.size||[i.width||600,i.height||400],w=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),i.margin),A=Array.isArray(i.areas)?Vo(i.areas):i.areas,S=Vo(i.points),_=Vo(i.lines),M=i.legendPosition;i.showLegend&&(M&&"right"!==M?"left"===M?w.left=Math.max(null!==(s=w.left)&&void 0!==s?s:0,100):"bottom"===M?w.bottom=Math.max(null!==(a=w.bottom)&&void 0!==a?a:0,70):"top"===M&&(w.top=Math.max(null!==(l=w.top)&&void 0!==l?l:0,40)):w.right=Math.max(null!==(r=w.right)&&void 0!==r?r:0,100));const P=k[0]-(null!==(c=w.left)&&void 0!==c?c:0)-(null!==(u=w.right)&&void 0!==u?u:0),O=k[1]-(null!==(d=w.top)&&void 0!==d?d:0)-(null!==(h=w.bottom)&&void 0!==h?h:0),T=new no({projection:i.projection||"equalEarth",xAccessor:i.xAccessor,yAccessor:i.yAccessor,lineDataAccessor:i.lineDataAccessor,pointIdAccessor:i.pointIdAccessor,lineType:i.lineType,areaStyle:i.areaStyle,pointStyle:i.pointStyle,lineStyle:i.lineStyle,graticule:i.graticule,fitPadding:i.fitPadding,projectionTransform:i.projectionTransform});if(A){if("string"==typeof A)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${A}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${A}')\` before calling renderGeoToStaticSVG.`);T.setAreas(A)}if(i.points&&T.setPoints(S),i.lines&&T.setLines(_),T.computeScene({width:P,height:O}),0===T.scene.length){const t=i.backgroundGraphics||i.foregroundGraphics||i.annotations?e(n,{children:[i.backgroundGraphics,i.annotations?Lo({annotations:i.annotations,scales:{geoProjection:(null===(f=T.scales)||void 0===f?void 0:f.projectedPoint)?([t,e])=>T.scales.projectedPoint(t,e):void 0},layout:{width:P,height:O},theme:x,idPrefix:i._idPrefix}):null,i.foregroundGraphics]}):null;return y.renderToStaticMarkup(la(t,{width:k[0],height:k[1],className:"stream-geo-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:x,innerTransform:`translate(${null!==(g=w.left)&&void 0!==g?g:0},${null!==(p=w.top)&&void 0!==p?p:0})`,idPrefix:i._idPrefix}))}const $=T.scene.map((e,n)=>function(e,n){var o,i,r,s,a,l;switch(e.type){case"geoarea":{const r=e;return r.pathData?t("path",{d:r.pathData,fill:lo(r.style.fill,"#e0e0e0"),fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(i=r._decayOpacity)&&void 0!==i?i:1},"geoarea-"+n):null}case"point":{const o=e;return t("circle",{cx:o.x,cy:o.y,r:o.r,fill:lo(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const o=e;if(2>o.path.length)return null;const i="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(e,n)).filter(Boolean),j=i.annotations?Lo({annotations:i.annotations,scales:{geoProjection:(null===(m=T.scales)||void 0===m?void 0:m.projectedPoint)?([t,e])=>T.scales.projectedPoint(t,e):void 0},layout:{width:P,height:O},theme:x,idPrefix:i._idPrefix}):null,L=i.showLegend?(()=>{const t="string"==typeof(e=i.colorBy)||"function"==typeof e?i.colorBy:void 0;var e;const n=Oo(S.length>0?S:Array.isArray(A)&&A.length>0?"string"==typeof t?A.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):A:[],t);return 0===n.length?null:Po({categories:n,colorScheme:i.colorScheme,theme:x,position:i.legendPosition||"right",totalWidth:k[0],totalHeight:k[1],margin:w,hasTitle:!!i.title})})():null,C=o.isValidElement(i.legend)?i.legend:L,D=e(n,{children:[i.backgroundGraphics,$,j,i.foregroundGraphics]});return y.renderToStaticMarkup(la(D,{width:k[0],height:k[1],className:"stream-geo-frame"+(i.className?" "+i.className:""),title:i.title,description:i.description,background:i.background,theme:x,innerTransform:`translate(${null!==(v=w.left)&&void 0!==v?v:0},${null!==(b=w.top)&&void 0!==b?b:0})`,legend:C,idPrefix:i._idPrefix}))}function pa(t,e){switch(t){case"xy":return ca(e);case"ordinal":return fa(e);case"network":return ha(e);case"geo":return ga(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function ya(t){return ca(t)}function ma(t){return fa(t)}function va(t){return ha(t)}function ba(t){return ga(t)}function xa(o,i,r){var s;const{data:a,width:l=600,height:c=400,theme:u,title:d,description:h,showLegend:f,showGrid:g,background:p,className:m,annotations:v,margin:b,colorScheme:x,colorBy:k,legendPosition:w}=i,A=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);o.length>i;i++)0>e.indexOf(o[i])&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(n[o[i]]=t[o[i]])}return n}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),S=[l,c],_=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},A.frameProps||{}),{theme:u,title:d,description:h,showLegend:f,showGrid:g,background:p,className:m,annotations:v,size:S}),void 0!==b&&{margin:b}),void 0!==x&&{colorScheme:x}),void 0!==w&&{legendPosition:w}),{_idPrefix:A._idPrefix}),M=ra[o];if(!M)throw Error(`Unknown chart component: "${o}". See CLAUDE.md for supported chart types.`);const P=M.buildProps(a,k,x,_,A);let O=(0,{xy:ca,ordinal:fa,network:ha,geo:ga}[M.frameType])(P);if("GaugeChart"===o&&P.__gauge){const o=P.__gauge,i=_.margin||{top:20,right:20,bottom:30,left:40},r=(l||300)-i.left-i.right,a=(c||300)-i.top-i.bottom,d=Math.min(r,a)/2*.85,h=i.left+r/2,f=i.top+a/2,g=Math.max(o.gMin,Math.min(o.gMax,null!==(s=o.value)&&void 0!==s?s:o.gMin)),p=(o.startAngleDeg+(o.gMax===o.gMin?0:(g-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,m=_o(u).colors.text,v=y.renderToStaticMarkup(e(n,{children:[t("line",{x1:h,y1:f,x2:h+d*Math.cos(p),y2:f+d*Math.sin(p),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:h,cy:f,r:4,fill:m})]}));O=O.replace("</svg>",v+"</svg>")}return O}function ka(t,e){return At(this,arguments,void 0,function*(t,e,n={}){var o,i,r;const{format:s="png",scale:a=1,background:l}=n;let c,u;c=["xy","ordinal","network","geo"].includes(t)?pa(t,e):xa(t,e),l&&(c=c.replace(/<svg /,`<svg style="background:${l}" `));try{const t="sharp",e=yield import(t);u=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const d=e.width||(null===(i=e.size)||void 0===i?void 0:i[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*a}).resize(Math.round(d*a),Math.round(h*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})}function wa(n,o={}){var i;const{title:r,subtitle:s,theme:a,width:l=1200,height:c,layout:u={},background:d}=o,h=Mo(_o(a)),f=u.columns||2,g=null!==(i=u.gap)&&void 0!==i?i:16;let p=0;r&&(p+=30),s&&(p+=20),p>0&&(p+=10);const m=Math.floor((l-g-g*(f-1))/f),v=[];let b=0,x=p+g,k=0;for(const t of n){const e=Math.min(t.colSpan||1,f),n=t.props.height||300;b+e>f&&(x+=k+g,b=0,k=0),v.push({chart:t,x:g/2+b*(m+g),y:x,w:m*e+g*(e-1),h:n}),k=Math.max(k,n),b+=e}const w=c||x+k+g,A=v.map((e,n)=>{const{chart:o,x:i,y:r,w:s,h:l}=e,c=Object.assign(Object.assign({},o.props),{width:s,height:l,theme:a,_idPrefix:"chart-"+n});let u;return u=o.component?xa(o.component,c):o.frameType?pa(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${l}"></svg>`,t("g",{transform:`translate(${i},${r})`,children:t("foreignObject",{width:s,height:l,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:w,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t("title",{children:r}),d&&t("rect",{x:0,y:0,width:l,height:w,fill:d}),r&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),s&&t("text",{x:l/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:s}),A]});return y.renderToStaticMarkup(S)}function Aa(t,e,n,o={}){const{stepSize:i,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=o,f=n.width||600,g=n.height||400,p=_o(n.theme),y=Object.assign(Object.assign(Object.assign({},n),a&&{xExtent:a}),l&&{yExtent:l});if(!e||0===e.length)return[];const m=i||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),x=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-x.left-x.right,w=g-x.top-x.bottom,A=[];if(b)for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||p.colors.categorical},h&&{decay:h}),l=new qn(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(Pa(l.scene,f,g,p,y))}else for(let o=0;v.length>o;o++){const i=v[o],s=e.slice(r?Math.max(0,i-r):0,i),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:l,colorScheme:n.colorScheme||p.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange},h&&{decay:h}),c>0&&{transition:{duration:c*(1e3/u),easing:d}}),b=new _e(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:k,height:w}),0===b.scene.length)continue;const x=b.scales?{y:b.scales.y}:void 0;if(A.push(Ma(b.scene,f,g,p,y,x)),c>0&&o>0&&b.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/c*t),A.push(Ma(b.scene,f,g,p,y,x))}}return A}function Sa(t,e,n={}){return e.map(e=>{try{return xa(t,Object.assign(Object.assign({},n),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})}function _a(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function Ma(o,i,r,s,a,l){const c=Mo(s),u=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),d=i-u.left-u.right,h=r-u.top-u.bottom,f=_a(a,s),g=o.map((t,e)=>co(t,e)).filter(Boolean),p=function(o,i,r,s,a,l){var c;if(!o||0===o.length)return null;const u=Mo(s),d=[];for(let n=0;o.length>n;n++){const s=o[n];if("y-threshold"===s.type&&null!=s.value){let o=null;if(l)o=l(s.value);else if(a){const[t,e]=a,n=e-t;if(0===n)continue;o=r-(s.value-t)/n*r}if(null==o)continue;const h=s.color||u.primary,f=null!==(c=s.strokeWidth)&&void 0!==c?c:1.5,g=s.labelPosition||"right";d.push(e("g",{children:[t("line",{x1:0,y1:o,x2:i,y2:o,stroke:h,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?i/2:i-4,y:o-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:u.tickSize,fill:h,fontFamily:u.fontFamily,children:s.label})]},"ann-"+n))}}return d.length>0?t(n,{children:d}):null}(a.annotations,d,h,s,a.yExtent,null==l?void 0:l.y),m="string"==typeof a.title?a.title:void 0,v="string"==typeof a.description?a.description:void 0,b=m?"semiotic-title":void 0,x=v?"semiotic-desc":void 0,k=[b,x].filter(Boolean).join(" ")||void 0,w=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:r,role:"img","aria-labelledby":k,style:{fontFamily:c.fontFamily},children:[m&&t("title",{id:b,children:m}),v&&t("desc",{id:x,children:v}),f&&t("rect",{x:0,y:0,width:i,height:r,fill:f}),e("g",{transform:`translate(${u.left},${u.top})`,children:[p,g]}),m&&t("text",{x:i/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:m})]});return y.renderToStaticMarkup(w)}function Pa(n,o,i,r,s){const a=Mo(r),l=Object.assign({top:20,right:20,bottom:30,left:40},s.margin),c="radial"===s.projection,u=c?l.left+(o-l.left-l.right)/2:l.left,d=c?l.top+(i-l.top-l.bottom)/2:l.top,h=_a(s,r),f=n.map((t,e)=>uo(t,e)).filter(Boolean),g="string"==typeof s.title?s.title:void 0,p="string"==typeof s.description?s.description:void 0,m=g?"semiotic-title":void 0,v=p?"semiotic-desc":void 0,b=[m,v].filter(Boolean).join(" ")||void 0,x=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:i,role:"img","aria-labelledby":b,style:{fontFamily:a.fontFamily},children:[g&&t("title",{id:m,children:g}),p&&t("desc",{id:v,children:p}),h&&t("rect",{x:0,y:0,width:o,height:i,fill:h}),t("g",{transform:`translate(${u},${d})`,children:f}),g&&t("text",{x:o/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return y.renderToStaticMarkup(x)}function Oa(t,e,n){return At(this,arguments,void 0,function*(t,e,n,o={}){var i,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b;const{fps:x=12,loop:k=!0,scale:w=1,background:A}=o,S=n.height||400,_=Math.round((n.width||600)*w),M=Math.round(S*w),P=Aa(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,o);if(0===P.length)throw Error("No frames generated — check that data is not empty");let O,T,$,j;try{const t="sharp",e=yield import(t);O=null!==(i=e.default)&&void 0!==i?i:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);T=null!==(a=null!==(r=e.GIFEncoder)&&void 0!==r?r:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(c=null===(l=e.default)||void 0===l?void 0:l.default)||void 0===c?void 0:c.GIFEncoder,$=null!==(h=null!==(u=e.quantize)&&void 0!==u?u:null===(d=e.default)||void 0===d?void 0:d.quantize)&&void 0!==h?h:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,j=null!==(m=null!==(p=e.applyPalette)&&void 0!==p?p:null===(y=e.default)||void 0===y?void 0:y.applyPalette)&&void 0!==m?m:null===(b=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===b?void 0:b.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const L=Math.round(1e3/x),C=T();for(let t=0;P.length>t;t++){const e=P[t],n=yield O(Buffer.from(e),{density:72*w}).resize(_,M).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),i=$(o,256),r=j(o,i);C.writeFrame(r,_,M,{palette:i,delay:L,repeat:k?0:-1})}return C.finish(),Buffer.from(C.bytes())})}export{Aa as generateFrameSVGs,Sa as generateFrameSequence,xa as renderChart,wa as renderDashboard,ba as renderGeoToStaticSVG,va as renderNetworkToStaticSVG,ma as renderOrdinalToStaticSVG,Oa as renderToAnimatedGif,ka as renderToImage,pa as renderToStaticSVG,ya as renderXYToStaticSVG,_o as resolveTheme,Mo as themeStyles};
1
+ import{jsx as t,jsxs as e,Fragment as n}from"react/jsx-runtime";import*as i from"react";import{useRef as o,useMemo as r,useContext as s,useCallback as a,useSyncExternalStore as l,createContext as c,useEffect as u,useState as d,useLayoutEffect as h,forwardRef as f,useId as g,useImperativeHandle as p}from"react";import*as y from"react-dom/server";import{scaleOrdinal as m,scaleLinear as v,scaleLog as b,scaleTime as x,scaleBand as k}from"d3-scale";import{quadtree as w}from"d3-quadtree";import{min as A,groups as S,max as M,sum as _,mean as P,group as O,quantile as T,bin as $}from"d3-array";import{interpolateNumber as L}from"d3-interpolate";import{forceLink as j,forceSimulation as z,forceManyBody as C,forceCenter as E,forceX as D,forceY as R}from"d3-force";import{ribbon as F,chord as N}from"d3-chord";import{arc as B,pie as W,curveNatural as I,curveBasis as Y,curveStepAfter as G,curveStepBefore as H,curveStep as X,curveCatmullRom as q,curveCardinal as V,curveMonotoneY as U,curveMonotoneX as Z,line as Q,area as K,curveLinear as J}from"d3-shape";import{hierarchy as tt,partition as et,pack as nt,treemap as it,treemapBinary as ot,cluster as rt,tree as st,packEnclose as at}from"d3-hierarchy";import{geoPath as lt,geoGraticule as ct,geoDistance as ut,geoInterpolate as dt,geoEqualEarth as ht,geoEquirectangular as ft,geoNaturalEarth1 as gt,geoOrthographic as pt,geoAlbersUsa as yt,geoMercator as mt}from"d3-geo";import{select as vt}from"d3-selection";import{brushX as bt,brushY as xt,brush as kt}from"d3-brush";import wt from"regression";function At(t,e,n,i){return new(n||(n=Promise))(function(o,r){function s(t){try{l(i.next(t))}catch(t){r(t)}}function a(t){try{l(i.throw(t))}catch(t){r(t)}}function l(t){t.done?o(t.value):function(t){return t instanceof n?t:new n(function(e){e(t)})}(t.value).then(s,a)}l((i=i.apply(t,e||[])).next())})}function St(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Mt(t){return"object"==typeof t&&null!==t&&"gradient"in t}"function"==typeof SuppressedError&&SuppressedError;class _t{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const n of t){const t=this.push(n);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t(this.buffer[(e+n)%this._capacity],n)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)t[n]=this.buffer[(e+n)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),n=[];for(;e.length>t;)n.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return n}update(t,e){const n=[],i=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(i+o)%this._capacity,s=this.buffer[r];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(t),this.buffer[r]=e(s)}}return n}remove(t){const e=[],n=[];if(this.forEach(i=>{t(i)?n.push(i):e.push(i)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class Pt{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const n of t){const t=e?e(n):n;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function Ot(t,e,n,i,o){const r=new Map;for(const s of t){const t=e(s),a=n(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/i)*i;let c=r.get(l);if(c||(c={start:l,end:l+i,total:0,categories:new Map},r.set(l,c)),c.total+=a,o){const t=o(s);c.categories.set(t,(c.categories.get(t)||0)+a)}}return r}function Tt(t,e,n,i,o,r){const s=[];for(const o of t){const t=n(o),r=i(o);Number.isFinite(t)&&Number.isFinite(r)&&s.push({px:e.x(t),py:e.y(r),rawY:r,d:o})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],l[t]=e.rawY,c[t]=e.d}return{type:"line",path:a,rawValues:l,style:o,datum:c,group:r}}function $t(t,e,n,i,o,r,s,a){const l=[];for(const r of t){const t=n(r),s=i(r);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const c=e.x(t),u=a?a(r):o;l.push({px:c,topY:e.y(s),botY:e.y(u)})}l.sort((t,e)=>t.px-e.px);const c=Array(l.length),u=Array(l.length);for(let t=0;l.length>t;t++){const e=l[t];c[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:t,group:s}}function Lt(t,e,n,i){var o,r,s;const a=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const o of e)t+=n(o,i)||0;a.set(i,-t/2)}else if("wiggle"===i){t.length>0&&a.set(t[0],0);for(let i=1;t.length>i;i++){const r=t[i-1],s=t[i];let l=0,c=0,u=0;for(const t of e){const e=n(t,s)||0;l+=(2*u+e)*(e-(n(t,r)||0)),c+=e,u+=e}const d=null!==(o=a.get(r))&&void 0!==o?o:0;a.set(s,d-(c>0?l/(2*c):0))}if(t.length>0){let i=0;for(const o of t){let t=0;for(const i of e)t+=n(i,o)||0;i+=(null!==(r=a.get(o))&&void 0!==r?r:0)+t/2}const o=i/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-o)}}else for(const e of t)a.set(e,0);return a}function jt(t,e,n,i,o,r,s){const a=n(t),l=i(t);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:e.x(a),y:e.y(l),r:o,style:r,datum:t};return void 0!==s&&(c.pointId=s),c}function zt(t,e,n,i,o,r,s){return{type:"rect",x:t,y:e,w:n,h:i,style:o,datum:r,group:s}}function Ct(t,e,n,i,o,r,s){const a={type:"heatcell",x:t,y:e,w:n,h:i,fill:o,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Et(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function Dt(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function Rt(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function Ft(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function Nt(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function Bt(t,e,n){const i=t=>t.toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Wt(t){const e=t.map(Nt),n=e.length-1;return t=>{if(0>=t){const[t,n,i]=e[0];return Bt(t,n,i)}if(t>=1){const[t,i,o]=e[n];return Bt(t,i,o)}const i=t*n,o=Math.floor(i),r=i-o,[s,a,l]=e[o],[c,u,d]=e[o+1];return Bt(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const It=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Yt=Wt(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Gt=Wt(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Ht=Wt(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Xt=Wt(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),qt=Wt(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Vt=Wt(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Ut=Wt(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Zt=Wt(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Qt=Wt(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Kt=Wt(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Jt=Wt(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),te=Wt(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);Wt(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Wt(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Wt(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Wt(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Wt(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Wt(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Wt(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const ee={category10:It,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Yt,reds:Gt,greens:Ht,oranges:Xt,purples:qt,viridis:Ut,plasma:Zt},ne=It,ie=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],oe=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function re(t,e,n){if("function"==typeof e){const i=e(t);return n&&i&&"string"==typeof i&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||oe.has(e)}(i)?n(i):i}const i=(null==t?void 0:t[e])+"";return n?n(i):ne[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(i))%ne.length]}function se(t,e,n="category10"){const i=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),o=i.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return m().domain(i).range(n).unknown("#999");const r=ee[n]||ee.category10;if(o&&"function"==typeof r){let t=-1/0;for(const e of i){const n=Number(e);n>t&&(t=n)}return e=>r(Number(e)/t)}{const t=Array.isArray(r)?r:ne;return m().domain(i).range(t).unknown("#999")}}function ae(t,e,n){var i,o,r;if(1>=n)return 1;const s=null!==(i=t.minOpacity)&&void 0!==i?i:.1,a=n-1-e;switch(t.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const e=null!==(o=t.halfLife)&&void 0!==o?o:n/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(r=t.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function le(t,e,n){var i;const o=null!==(i=t.duration)&&void 0!==i?i:500,r=n-e;return o>r?1-r/o:0}function ce(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function ue(t,e){return Math.min((t-e.startTime)/e.duration,1)}function de(t,e,n){return t+(e-t)*n}function he(){return"undefined"!=typeof performance?performance.now():Date.now()}function fe(t,e,n){var i,o,r,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const n=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${n}:${i}`;if(null!=n&&null!=i)return`p:${n}:${i}`}return"p:"+n;case"rect":return`r:${e.group||""}:${null!==(s=null!==(o=null===(i=e.datum)||void 0===i?void 0:i.binStart)&&void 0!==o?o:null===(r=e.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+n:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function ge(t,e,n,i){return"function"==typeof e.style?e.style(i||{},n):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(n,i)}function pe(t,e,n,i){if(!t.scales)return null;const o=[],r=[];for(const n of e){const e=t.getX(n);if(!Number.isFinite(e))continue;const s=i.getTop(n),a=i.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=t.scales.x(e),c=t.scales.y(s),u=t.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(o.push([l,c]),r.push([l,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:ge(t,i,n,e[0]),datum:e,group:n,interactive:i.interactive}}function ye(t){const e=[],n=[];if(!t)return{perSeries:e,aggregate:n};for(const i of t)i.perSeries?e.push(i):n.push(i);return{perSeries:e,aggregate:n}}function me(t,e,n){const i=[];for(const o of n){const n=pe(t,e,"__ribbon_aggregate",o);n&&i.push(n)}return i}function ve(t,e,n,i){const o=[];for(const r of i){const i=pe(t,e,n,r);i&&o.push(i)}return o}function be(t,e){if(!t)return{};if(!e||0===e.length)return t;const n=[];for(const i of e){if("band"!==i.kind)continue;const e=i.getTop(t),o=i.getBottom(t);Number.isFinite(o)&&Number.isFinite(e)&&n.push({y0:o,y1:e})}return 0===n.length?t:Object.assign(Object.assign({},t),{band:n[0],bands:n})}function xe(t,e,n,i){var o;if(!t.config.pointStyle)return;const r=null!=i?i:t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const s of i.data){let i=t.config.pointStyle(s);!i.fill&&e&&(i=Object.assign(Object.assign({},i),{fill:e}));const a=null!==(o=i.r)&&void 0!==o?o:3,l=t.getPointId?t.getPointId(s)+"":void 0,c=jt(s,t.scales,t.getX,r,a,i,l);c&&n.push(c)}}}const ke={topOpacity:.8,bottomOpacity:.05};function we(t){var e,n;if(t)return!0===t?ke:"colorStops"in t?t:{topOpacity:null!==(e=t.topOpacity)&&void 0!==e?e:ke.topOpacity,bottomOpacity:null!==(n=t.bottomOpacity)&&void 0!==n?n:ke.bottomOpacity}}const Ae={blues:Yt,reds:Gt,greens:Ht,viridis:Ut,oranges:Xt,purples:qt,greys:Vt,plasma:Zt,inferno:Qt,magma:Kt,cividis:Jt,turbo:te},Se=new Map;function Me(t,e){const n="function"==typeof t?t:n=>n[t||e];return t=>{const e=n(t);return null==e?NaN:+e}}function _e(t){const e=[],n=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=Me(n&&t.valueAccessor||t.yAccessor,n?"value":"y");if(t.boundsAccessor){const n=Dt(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e+o:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const o=n(t);return Number.isFinite(o)&&0!==o?e-o:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const n=Array.isArray(t.band)?t.band:[t.band];for(const t of n)e.push({kind:"band",getTop:Me(t.y1Accessor,"y1"),getBottom:Me(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}class Pe{constructor(t){if(this.xExtent=new Pt,this.yExtent=new Pt,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new _t(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=Dt(t.timeAccessor||t.xAccessor,"time"),this.getY=Dt(t.valueAccessor||t.yAccessor,"value")):(this.getX=Dt(t.xAccessor,"x"),this.getY=Dt(t.yAccessor,"y")),this.getGroup=Ft(t.groupAccessor),this.getCategory=Ft(t.categoryAccessor),this.getSize=t.sizeAccessor?Dt(t.sizeAccessor,"size"):void 0,this.getColor=Ft(t.colorAccessor),this.getY0=t.y0Accessor?Dt(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=_e(t),this.getPointId=Ft(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?Dt(t.openAccessor,"open"):void 0,this.getHigh=Dt(t.highAccessor,"high"),this.getLow=Dt(t.lowAccessor,"low"),this.getClose=n?Dt(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new _t(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(i)&&this.yExtent.push(i)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){if(this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?Dt(this.config.timeAccessor||this.config.xAccessor,"time"):Dt(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],n=this.config.xAccessor,i="function"==typeof n?n(e):e[n||"x"],o=i instanceof Date,r="string"==typeof i&&i.length>=10&&!isNaN(new Date(i).getTime())&&isNaN(Number(i));if(this.xIsDate=o||r,r){const t="string"==typeof n?n:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(n(t)instanceof Date?n(t):new Date(n(t)))}}const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)if(this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),i=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(i)&&this.yExtent.push(i)}}}else for(const n of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(n);if(this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const t of this.resolvedRibbons){const e=t.getTop(n),i=t.getBottom(n);Number.isFinite(e)&&this.yExtent.push(e),Number.isFinite(i)&&this.yExtent.push(i)}}if(null!=t)if(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t));else{this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(i)&&this.yExtent.evict(i)}}}return!0}computeScene(t){var e,n,i,o,r,s,a,l,c,u,d,h,f,g;const{config:p,buffer:y}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(y,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const m=this.getBufferArray(),k=this.xExtent.extent,w=this.yExtent.extent;let A=p.xExtent?[null!==(n=p.xExtent[0])&&void 0!==n?n:k[0],null!==(i=p.xExtent[1])&&void 0!==i?i:k[1]]:k,S=p.yExtent?[null!==(o=p.yExtent[0])&&void 0!==o?o:w[0],null!==(r=p.yExtent[1])&&void 0!==r?r:w[1]]:w;const M=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1],_="exact"===p.axisExtent;if("stackedarea"===p.chartType&&!M&&y.size>0)if(p.normalize)S=[0,_?1:1+p.extentPadding];else{const t=`${y.size}:${this._ingestVersion}:${null!==(s=p.baseline)&&void 0!==s?s:"zero"}:${null!==(a=p.stackOrder)&&void 0!==a?a:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)S=this._stackExtentCache.yDomain;else{const e=this.groupData(m),n=new Map,i=new Set;let o=0;const r=new Map,s=new Map;for(const t of e){const e=new Map;let a=0;for(const n of t.data){const t=this.getX(n),s=this.getY(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),i.add(t),a+=s;const l=(r.get(t)||0)+s;r.set(t,l),l>o&&(o=l)}n.set(t.key,e),s.set(t.key,a)}const a=null!==(l=p.stackOrder)&&void 0!==l?l:"key",f=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===a){const t=[...e].map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}),n=[],i=[];let o=0,r=0;for(const e of t)r>o?(n.push(e),o+=null!==(c=s.get(e))&&void 0!==c?c:0):(i.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0);g=[...i.reverse(),...n]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(i=s.get(e))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var n,i;const o=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(i=s.get(t))&&void 0!==i?i:0);return 0!==o?o:f(t,e)}):e.map(t=>t.key).sort(f);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(i).sort((t,e)=>t-e),e=Lt(t,g,(t,e)=>{var i;return(null===(i=n.get(t))||void 0===i?void 0:i.get(e))||0},p.baseline);let o=1/0,s=-1/0;for(const n of t){const t=null!==(d=e.get(n))&&void 0!==d?d:0,i=null!==(h=r.get(n))&&void 0!==h?h:0;o>t&&(o=t),t+i>s&&(s=t+i)}Number.isFinite(o)&&Number.isFinite(s)||(o=0,s=0);const a=s-o,l=_?0:a>0?a*p.extentPadding:1;S=[o-l,s+l]}else S=[0,o+(_?0:o>0?o*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:S}}}else if("bar"===p.chartType&&p.binSize&&!M&&y.size>0){const[,t]=function(t,e,n,i,o){const r=Ot(t,e,n,i,o);if(0===r.size)return[0,0];let s=0;for(const t of r.values())t.total>s&&(s=t.total);return[0,s]}(y,this.getX,this.getY,p.binSize,this.getCategory);S=[0,_?t:t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!M&&y.size>0){const[t,e]=function(t,e){let n=0,i=0,o=0;for(const r of t){const t=e(r);null==t||Number.isNaN(t)||(o+=t,n>o&&(n=o),o>i&&(i=o))}return[n,i]}(y,this.getY),n=e-t,i=_?0:n>0?n*p.extentPadding:1;S=[Math.min(0,t-Math.abs(i)),Math.max(0,e+Math.abs(i))]}else if(!M&&S[0]!==1/0){if(this.resolvedRibbons.length>0)for(const t of m)for(const e of this.resolvedRibbons){const n=e.getTop(t),i=e.getBottom(t);Number.isFinite(n)&&(S[0]>n&&(S[0]=n),n>S[1]&&(S[1]=n)),Number.isFinite(i)&&(S[0]>i&&(S[0]=i),i>S[1]&&(S[1]=i))}const t=S[1]-S[0],e=_?0:t>0?t*p.extentPadding:1,n=null===(f=p.yExtent)||void 0===f?void 0:f[0],i=null===(g=p.yExtent)||void 0===g?void 0:g[1];S=[null!=n?S[0]:S[0]-e,null!=i?S[1]:S[1]+e],"log"!==p.yScaleType||S[0]>0||0>=w[0]||_||(S[0]=null!=n?S[0]:w[0]/(1+p.extentPadding))}if(p.yExtent&&!M){const t=p.yExtent[0],e=p.yExtent[1];null==t&&null==e||(S=[null!=t?t:S[0],null!=e?e:S[1]])}if(A[0]===1/0||A[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();A=[t-864e5,t]}else A=[0,1];S[0]!==1/0&&S[1]!==-1/0||(S=[0,1]);const P="streaming"===p.runtimeMode,O=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(T=p.arrowOfTime)||"down"===T?"y":"x")){const e="right"===p.arrowOfTime?[O,t.width-O]:[t.width-O,O];this.scales={x:v().domain(A).range(e),y:v().domain(S).range([t.height-O,O])}}else{const e="down"===p.arrowOfTime?[O,t.height-O]:[t.height-O,O];this.scales={x:v().domain(S).range([O,t.width-O]),y:v().domain(A).range(e)}}else{const e=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)};this.scales={x:e(p.xScaleType,A,[O,t.width-O]),y:e(p.yScaleType,S,[t.height-O,O])}}var T;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,m),this.config.decay&&this.applyDecay(this.scene,m),this.config.pulse&&this.applyPulse(this.scene,m),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,n=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>n&&(n=t.r));if(this._maxPointRadius=n,Pe.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,n=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=n;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=n;for(const i of t.bottomPath)i[0]*=e,i[1]*=n;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*n,width:t.clipRect.width*e,height:t.clipRect.height*n});break;case"point":t.x*=e,t.y*=n;break;case"rect":case"heatcell":t.x*=e,t.y*=n,t.w*=e,t.h*=n;break;case"candlestick":t.x*=e,t.openY*=n,t.closeY*=n,t.highY*=n,t.lowY*=n}const i=this.scales.x.domain(),o=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return b().domain(t).range(n).clamp(!0)}return"time"===t?x().domain([new Date(e[0]),new Date(e[1])]).range(n):v().domain(e).range(n)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,i,r[0]>r[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,o,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var n,i,o,r,s,a,l;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const l=null!==(n=c.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},d={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:l,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(i=c.themeSemantic)&&void 0!==i?i:{},categorical:null!==(o=c.themeCategorical)&&void 0!==o?o:ie},resolveColor:(t,e)=>{var n,i;const o=this.resolveGroupColor(t);if(o)return o;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(i=null===(n=c.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==i?i:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null,null!==(a=h.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(c.chartType){case"line":return function(t,e){var n;const i=t.groupData(e),o=[],r=null===(n=t.config.annotations)||void 0===n?void 0:n.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:r}=ye(t.ribbons);if(r.length>0&&o.push(...me(t,e,r)),n.length>0)for(const e of i)o.push(...ve(t,e.data,e.key,n))}for(const e of i){const n=t.resolveLineStyle(e.key,e.data[0]),i=Tt(e.data,t.scales,t.getX,t.getY,n,e.key);r&&r.length>0&&(i.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),o.push(i)}return xe(t,i,o),o}(d,e);case"area":return function(t,e){const n=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=ye(t.ribbons);if(r.length>0&&i.push(...me(t,e,r)),o.length>0)for(const e of n)i.push(...ve(t,e.data,e.key,o))}const o=t.scales.y.domain()[0],r=t.getY0?e=>{const n=t.getY0(e);return null==n?o:n}:void 0;for(const e of n){const n=t.resolveAreaStyle(e.key,e.data[0]),s=$t(e.data,t.scales,t.getX,t.getY,o,n,e.key,r),a=we(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),i.push(s)}return xe(t,n,i),i}(d,e);case"mixed":return function(t,e){const n=t.groupData(e),i=[],o=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:o,aggregate:r}=ye(t.ribbons);if(r.length>0&&i.push(...me(t,e,r)),o.length>0)for(const e of n)i.push(...ve(t,e.data,e.key,o))}const r=t.scales.y.domain()[0],s=t.getY0?e=>{const n=t.getY0(e);return null==n?r:n}:void 0;for(const e of n)if(o.has(e.key)){const n=t.resolveAreaStyle(e.key,e.data[0]),o=$t(e.data,t.scales,t.getX,t.getY,r,n,e.key,s),a=we(t.config.gradientFill);a&&(o.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}else{const n=t.resolveLineStyle(e.key,e.data[0]),o=Tt(e.data,t.scales,t.getX,t.getY,n,e.key);t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return xe(t,n,i),i}(d,e);case"stackedarea":return function(t,e){var n,i,o,r;const s=t.groupData(e),a=null!==(n=t.config.stackOrder)&&void 0!==n?n:"key",l=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const n of s){let i=0;for(const e of n.data){const n=t.getX(e),o=t.getY(e);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}e.set(n.key,i)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(t.key))&&void 0!==o?o:0)-(null!==(r=e.get(i.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else if("desc"===a)s.sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)});else{const t=[...s].sort((t,i)=>{var o,r;const s=(null!==(o=e.get(i.key))&&void 0!==o?o:0)-(null!==(r=e.get(t.key))&&void 0!==r?r:0);return 0!==s?s:n(t.key,i.key)}),r=[],a=[];let l=0,c=0;for(const n of t)c>l?(r.push(n),l+=null!==(i=e.get(n.key))&&void 0!==i?i:0):(a.push(n),c+=null!==(o=e.get(n.key))&&void 0!==o?o:0);s.length=0,s.push(...a.reverse(),...r)}}else l();const c=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(r=t.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(t,e,n,i,o,r,s,a="zero"){var l,c;const u=new Set;for(const e of t)for(const t of e.data){const e=n(t);Number.isFinite(e)&&u.add(e)}const d=Array.from(u).sort((t,e)=>t-e),h=new Map;for(const e of t){const t=new Map;for(const o of e.data){const e=n(o),r=i(o);Number.isFinite(e)&&Number.isFinite(r)&&t.set(e,(t.get(e)||0)+r)}h.set(e.key,t)}let f;if(r){f=new Map;for(const e of d){let n=0;for(const i of t)n+=(null===(l=h.get(i.key))||void 0===l?void 0:l.get(e))||0;f.set(e,n||1)}}const g=Lt(d,t.map(t=>t.key),(t,e)=>{var n;return(null===(n=h.get(t))||void 0===n?void 0:n.get(e))||0},a),p=[],y=new Map,m=new Map;for(const t of d)m.set(t,null!==(c=g.get(t))&&void 0!==c?c:0);for(const n of t){const t=h.get(n.key),i=[],a=[],l=new Map;for(const n of d){let o=t.get(n)||0;const s=m.get(n);r&&(o/=f.get(n));const c=s+o,u=e.x(n);a.push([u,e.y(s)]),i.push([u,e.y(c)]),m.set(n,c),l.set(n,c)}y.set(n.key,l);const c={type:"area",topPath:i,bottomPath:a,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),p.push(c)}return{nodes:p,stackedTops:y}}(s,t.scales,t.getX,t.getY,(e,n)=>t.resolveAreaStyle(e,n),t.config.normalize,c,u),f=d;if(t.config.pointStyle){const e=new WeakMap;for(const n of s){const i=h.get(n.key);if(i)for(const o of n.data){const n=t.getX(o),r=t.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||e.set(o,i.get(n))}}const n=n=>{var i;return null!==(i=e.get(n))&&void 0!==i?i:t.getY(n)};xe(t,s,f,n)}return f}(d,e);case"scatter":case"bubble":return function(t,e){var n;const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const n=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(n.length>0){let t=1/0,e=-1/0;for(const i of n)t>i&&(t=i),i>e&&(e=i);s=n=>t===e?(r[0]+r[1])/2:r[0]+(n-t)/(e-t)*(r[1]-r[0])}}const a=t.getColor?t.resolveColorMap(e):null,l=(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:l,opacity:.8},r=e.r||o;if(s&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(r=s(e))}if(a&&t.getColor&&!e.fill){const i=t.getColor(n);i&&a.has(i)&&(e=Object.assign(Object.assign({},e),{fill:a.get(i)}))}const c=t.getPointId?t.getPointId(n)+"":void 0,u=jt(n,t.scales,t.getX,t.getY,r,e,c);u&&i.push(u)}return i}(d,e);case"heatmap":return function(t,e,n){if(t.config.heatmapAggregation)return function(t,e,n){var i,o,r;const s=Math.max(1,Math.floor(null!==(i=t.config.heatmapXBins)&&void 0!==i?i:20)),a=Math.max(1,Math.floor(null!==(o=t.config.heatmapYBins)&&void 0!==o?o:20)),l=null!==(r=t.config.heatmapAggregation)&&void 0!==r?r:"count",c=Dt(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,d]=t.scales.x.domain(),[h,f]=t.scales.y.domain(),g=(d-u||1)/s,p=(f-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;e.length>n;n++){const i=e[n],o=t.getX(i),r=t.getY(i);if(!isFinite(o)||!isFinite(r))continue;const l=Math.min(Math.floor((o-u)/g),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const y=c(i);v[f]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let t=0;y>t;t++){if(0===m[t])continue;let e;switch(l){case"sum":e=v[t];break;case"mean":e=v[t]/m[t];break;default:e=m[t]}b>e&&(b=e),e>x&&(x=e)}if(!isFinite(b))return[];const k=x-b||1,w=n.width/s,A=n.height/a,S=t.config.showValues,M=t.config.heatmapValueFormat,_=[];for(let t=0;a>t;t++){const e=t*s;for(let n=0;s>n;n++){const i=e+n;if(0===m[i])continue;let o;switch(l){case"sum":o=v[i];break;case"mean":o=v[i]/m[i];break;default:o=m[i]}const r=(o-b)/k;_.push(Ct(n*w,(a-1-t)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:t,value:o,count:m[i],sum:v[i],xCenter:u+(n+.5)*g,yCenter:h+(t+.5)*p,agg:l},S?{value:o,showValues:!0,valueFormat:M}:void 0))}}return _}(t,e,n);if(0===e.length)return[];const i=Dt(t.config.valueAccessor,"value"),o=Rt(t.config.xAccessor,"x"),r=Rt(t.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(e.length),c=Array(e.length);for(let t=0;e.length>t;t++){const n=e[t],i=o(n),u=r(n);l[t]=i,c[t]=u,s.has(i)||s.set(i,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),g=h.every(t=>"number"==typeof t&&!isNaN(t)),p=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){h.sort((t,e)=>t-e),s.clear();for(let t=0;h.length>t;t++)s.set(h[t],t)}if(p){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const y=new Float64Array(e.length),m=new Float64Array(e.length),v=Array(e.length),b=new Map;let x=0;for(let t=0;e.length>t;t++){const n=e[t],o=s.get(l[t]),r=a.get(c[t]);if(void 0===o||void 0===r)continue;const d=i(n),h=r*u+o,f=b.get(h);let g;void 0!==f?g=f:(g=x++,b.set(h,g)),y[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;x>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in Ae?t:"blues";let n=Se.get(e);if(n)return n;n=Array(256);const i=Ae[e]||Yt;for(let t=0;256>t;t++)n[t]=i(t/255);return Se.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),M=n.width/u,_=n.height/d,P=t.config.showValues,O=t.config.heatmapValueFormat,T=[];for(let t=0;x>t;t++){const e=m[t];if(!isFinite(e))continue;const n=y[t],i=n%u;T.push(Ct(i*M,(d-1-(n-i)/u)*_,M,_,A[Math.min((e-k)*S+.5|0,255)],v[t],P?{value:e,showValues:!0,valueFormat:O}:void 0))}return T}(d,e,t);case"bar":{const t=function(t,e){var n,i;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const o=Ot(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===o.size)return{nodes:[],binBoundaries:[]};let r=null;if(t.getCategory){const e=new Set;for(const t of o.values())for(const n of t.categories.keys())e.add(n);const n=t.config.barColors?Object.keys(t.config.barColors):[],i=new Set(n),s=Array.from(e).filter(t=>!i.has(t)).sort(),a=n.filter(t=>e.has(t)),l=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?r=t.barCategoryCache.order:(r=[...a,...s],t.barCategoryCache={key:l,order:r})}const s=[],a=t.scales,[l,c]=a.x.domain(),u=t.config.barStyle,d=null===(n=t.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of o.values()){const n=Math.max(e.start,l),o=Math.min(e.end,c);if(n>=o)continue;const h=a.x(n),p=a.x(o),y=Math.abs(p-h),m=y>f+1?f:0,v=Math.min(h,p)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&e.categories.size>0){let n=0;for(const o of r){const r=e.categories.get(o)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(i=t.config.barColors)||void 0===i?void 0:i[o])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(zt(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},g),{binStart:e.start,binEnd:e.end,total:e.total,category:o,categoryValue:r},o)),n+=r}}else{const t=a.y(0),n=a.y(e.total);s.push(zt(v,Math.min(t,n),b,Math.abs(t-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const p=new Set;for(const t of o.values())p.add(t.start),p.add(t.end);return{nodes:s,binBoundaries:Array.from(p).sort((t,e)=>t-e)}}(d,e);return this._barCategoryCache=null!==(l=d.barCategoryCache)&&void 0!==l?l:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var n,i,o,r,s,a;const l=[],c=t.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(i=c.fill)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of e){const e=t.getX(n),i=t.getY(n);if(null==i||Number.isNaN(i))continue;const o=t.scales.x(e),r=t.scales.y(i);let s=d;if(t.getCategory){const e=t.getCategory(n);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const c={type:"point",x:o,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};t.getPointId&&(c.pointId=t.getPointId(n)+""),l.push(c)}return l}(d,e);case"waterfall":return function(t,e,n){var i,o,r,s,a,l,c;const u=[],d=t.scales,h=t.config.waterfallStyle,f=e.filter(e=>{const n=t.getY(e),i=t.getX(e);return null!=n&&!Number.isNaN(n)&&null!=i&&isFinite(i)});if(0===f.length)return u;const g=null!==(r=null!==(i=null==h?void 0:h.positiveColor)&&void 0!==i?i:null===(o=t.config.themeSemantic)||void 0===o?void 0:o.success)&&void 0!==r?r:"#28a745",p=null!==(l=null!==(s=null==h?void 0:h.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==l?l:"#dc3545",y=null!==(c=null==h?void 0:h.gap)&&void 0!==c?c:1,m=null==h?void 0:h.stroke,v=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let e=0;f.length>e;e++){const i=f[e],o=t.getX(i),r=t.getY(i),s=x+r;let a;a=f.length-1>e?t.getX(f[e+1])-o:e>0?o-t.getX(f[e-1]):0;const l=d.x(o),c=0!==a?d.x(o+a):l+n.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const A=d.y(x),S=d.y(s),M=Math.min(A,S),_=Math.abs(A-S),P={fill:0>r?p:g,stroke:m,strokeWidth:v};null!=b&&(P.opacity=b),u.push(zt(k,M,w,_,P,Object.assign(Object.assign({},i),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(d,e,t);case"candlestick":return function(t,e){var n,i;if(!t.getHigh||!t.getLow||!t.scales)return[];const o=null!==(n=t.config.candlestickRangeMode)&&void 0!==n&&n;if(!(o||t.getOpen&&t.getClose))return[];const r=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=o?a:s.upColor||"#28a745",c=o?a:s.downColor||"#dc3545",u=o?a:s.wickColor||"#333",d=s.wickWidth||(o?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(i=s.bodyWidth)&&void 0!==i?i:0;if(null==s.bodyWidth)if(h.length>1){let e=1/0;for(let n=1;h.length>n;n++){const i=Math.abs(t.scales.x(h[n])-t.scales.x(h[n-1]));i>0&&e>i&&(e=i)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const i=t.getHigh(n),s=t.getLow(n);if(null==i||Number.isNaN(i)||null==s||Number.isNaN(s))continue;const a=o?i:t.getOpen(n),h=o?s:t.getClose(n);if(!o&&[a,h].some(t=>null==t||Number.isNaN(t)))continue;const g=h>=a,p={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(h),highY:t.scales.y(i),lowY:t.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};o&&(p.isRange=!0),r.push(p)}return r}(d,e);default:return[]}}resolveBoundsStyle(t,e){var n;const i=this.config.boundsStyle;return"function"==typeof i?i(e||{},t):i&&"object"==typeof i?i:{fill:this.resolveLineStyle(t,e).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?ae(n,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,n){var i,o;const r=n.length;if(1>=r)return;const s=new Map;for(let t=0;n.length>t;t++)s.set(n[t],t);for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const i=Array(e.length);let o=!1;for(let n=0;e.length>n;n++){const a=s.get(e[n]);null!=a?(i[n]=ae(t,a,r),1>i[n]&&(o=!0)):i[n]=1}o&&(n._decayOpacities=i);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:e.length;if(2>i)continue;if(e.length===i){const o=Array(i);let a=!1;for(let n=0;e.length>n;n++){const i=s.get(e[n]);null!=i?(o[n]=ae(t,i,r),1>o[n]&&(a=!0)):o[n]=1}a&&(n._decayOpacities=o)}else{let o=1;for(const n of e){const e=s.get(n);if(null!=e){const n=ae(t,e,r);o>n&&(o=n)}}if(1>o){const t=Array(i);t.fill(o),n._decayOpacities=t}}continue}const e=s.get(n.datum);if(null==e)continue;const a=ae(t,e,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const t=null!==(o=null===(i=n.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;n.style=Object.assign(Object.assign({},n.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,n,i){var o,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(o=t.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",l=null!==(r=t.glowRadius)&&void 0!==r?r:4,c=new Map;for(let t=0;n.length>t;t++)c.set(n[t],t);for(const n of e){if("line"===n.type)continue;if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[n.datum];let o=0;for(const n of e){const e=c.get(n);if(null==e)continue;const r=i.get(e);if(null==r)continue;const a=le(t,r,s);a>o&&(o=a)}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const o=i.get(e);if(null==o)continue;const r=le(t,o,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var n;if(!e||0===e.size)return!1;const i="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(n=t.duration)&&void 0!==n?n:500,r=e.peek();return null!=r&&o>i-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,n,i){var o,r,s,a;n.clear(),i.clear();for(let l=0;e.length>l;l++){const c=e[l],u=fe(t,c,l);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(o=c.style)||void 0===o?void 0:o.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?i.set(u,{path:c.path.map(t=>[t[0],t[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&i.set(u,{topPath:c.topPath.map(t=>[t[0],t[1]]),bottomPath:c.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const i=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],o=fe(this.transitionContext,e,t);o&&("point"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(o,{x:e.x,y:i,w:e.w,h:0,opacity:null!==(n=e.style.opacity)&&void 0!==n?n:1}):"heatcell"===e.type?this.prevPositionMap.set(o,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(o,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(o,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,n,i,o){var r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,M,_,P,O,T,$,L,j,z,C,E,D,R,F,N,B,W,I,Y,G,H;if(0===i.size&&0===o.size)return n;const X=null!==(r=e.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}let q=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],$=fe(t,r,e);if(!$)continue;if(r._transitionKey=$,"line"===r.type||"area"===r.type){const t=o.get($);if(t){if(U.add($),"line"===r.type&&t.path&&t.path.length===r.path.length){r._targetPath=r.path.map(t=>[t[0],t[1]]),r._prevPath=t.path;for(let e=0;r.path.length>e;e++)r.path[e]=[t.path[e][0],t.path[e][1]];q=!0}else if("area"===r.type&&t.topPath&&t.bottomPath&&t.topPath.length===r.topPath.length&&t.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(t=>[t[0],t[1]]),r._targetBottomPath=r.bottomPath.map(t=>[t[0],t[1]]),r._prevTopPath=t.topPath,r._prevBottomPath=t.bottomPath;for(let e=0;r.topPath.length>e;e++)r.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;r.bottomPath.length>e;e++)r.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];q=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=t.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;continue}const L=i.get($);if("point"===r.type)if(L){V.add($);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=L.x,r.y=L.y,r.r=null!==(d=L.r)&&void 0!==d?d:r.r,q=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("rect"===r.type)if(L){V.add($);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=L.x,r.y=L.y,r.w=null!==(g=L.w)&&void 0!==g?g:r.w,r.h=null!==(p=L.h)&&void 0!==p?p:r.h,q=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),q=!0;else if("heatcell"===r.type)if(L){V.add($);const t={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(v=null===(m=r.style)||void 0===m?void 0:m.opacity)&&void 0!==v?v:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=L.x,r.y=L.y,r.w=null!==(b=L.w)&&void 0!==b?b:r.w,r.h=null!==(x=L.h)&&void 0!==x?x:r.h,q=!0)}else r._targetOpacity=null!==(w=null===(k=r.style)||void 0===k?void 0:k.opacity)&&void 0!==w?w:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0;else if("candlestick"===r.type)if(L&&null!=L.openY){V.add($);const t={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(S=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.lowY!==t.lowY)&&(r._targetX=t.x,r._targetOpenY=t.openY,r._targetCloseY=t.closeY,r._targetHighY=t.highY,r._targetLowY=t.lowY,r.x=L.x,r.openY=L.openY,r.closeY=null!==(M=L.closeY)&&void 0!==M?M:r.closeY,r.highY=null!==(_=L.highY)&&void 0!==_?_:r.highY,r.lowY=null!==(P=L.lowY)&&void 0!==P?P:r.lowY,q=!0)}else r._targetOpacity=null!==(T=null===(O=r.style)||void 0===O?void 0:O.opacity)&&void 0!==T?T:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),q=!0}for(const[t,e]of o)if(!U.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==($=e.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(i),q=!0}for(const[t,e]of i)if(!V.has(t)){if(t.startsWith("p:")){const i={type:"point",x:e.x,y:e.y,r:null!==(j=e.r)&&void 0!==j?j:3,style:{opacity:null!==(z=e.opacity)&&void 0!==z?z:1},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("r:")){const i={type:"rect",x:e.x,y:e.y,w:null!==(C=e.w)&&void 0!==C?C:0,h:null!==(E=e.h)&&void 0!==E?E:0,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("h:")){const i={type:"heatcell",x:e.x,y:e.y,w:null!==(R=e.w)&&void 0!==R?R:0,h:null!==(F=e.h)&&void 0!==F?F:0,fill:"#999",datum:null,style:{opacity:null!==(N=e.opacity)&&void 0!==N?N:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(i)}else if(t.startsWith("c:")){const i=null!==(B=e.openY)&&void 0!==B?B:e.y,o={type:"candlestick",x:e.x,openY:i,closeY:null!==(W=e.closeY)&&void 0!==W?W:i,highY:null!==(I=e.highY)&&void 0!==I?I:i,lowY:null!==(Y=e.lowY)&&void 0!==Y?Y:i,bodyWidth:null!==(G=e.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(H=e.opacity)&&void 0!==H?H:1},_targetOpacity:0,_transitionKey:t};n.exitNodes.push(o)}q=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),q&&(n.activeTransition={startTime:he(),duration:X}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(t,e,n,i){var o,r,s,a,l,c;if(!n.activeTransition)return!1;const u=ue(t,n.activeTransition),d=ce(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of n.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,r=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style.opacity=de(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=de(n.x,t._targetX,d),t.y=de(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=de(n.r,t._targetR,d))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;t.style.opacity=de(o,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=de(n.x,t._targetX,d),t.y=de(n.y,t._targetY,d),void 0!==n.w&&(t.w=de(n.w,t._targetW,d)),void 0!==n.h&&(t.h=de(n.h,t._targetH,d))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:de(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=de(n.x,t._targetX,d),t.y=de(n.y,t._targetY,d),void 0!==n.w&&(t.w=de(n.w,t._targetW,d)),void 0!==n.h&&(t.h=de(n.h,t._targetH,d))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const n=e?i.get(e):void 0,o=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:de(o,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=i.get(e);if(!n)continue;t.x=de(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=de(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=de(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=de(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=de(n.lowY,t._targetLowY,d))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:de(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevPath,n=t._targetPath;if(e&&n&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=de(e[i][0],n[i][0],d),t.path[i][1]=de(e[i][1],n[i][1],d)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:de(e,t._targetOpacity,d)})}void 0!==t._introClipFraction&&(t._introClipFraction=d);const e=t._prevTopPath,n=t._prevBottomPath,i=t._targetTopPath,o=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let n=0;t.topPath.length>n;n++)t.topPath[n][0]=de(e[n][0],i[n][0],d),t.topPath[n][1]=de(e[n][1],i[n][1],d);if(n&&o&&n.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=de(n[e][0],o[e][0],d),t.bottomPath[e][1]=de(n[e][1],o[e][1],d)}}if(u>=1){for(const t of n.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let n=0;t.path.length>n;n++)t.path[n]=e[n];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,n=t._targetBottomPath;if(e)for(let n=0;t.topPath.length>n;n++)t.topPath[n]=e[n];if(n)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=n[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(n.exitNodes.length>0){const t=new Set(n.exitNodes);n.scene=n.scene.filter(e=>!t.has(e)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const n of t){const t=this.getGroup(n);e.has(t)||e.set(t,[]),e.get(t).push(n)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const n of t){const t=this.getColor(n);t&&e.add(t)}const n=Array.from(e).sort(),i=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===i)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ie,r=new Map;for(let t=0;n.length>t;t++)r.set(n[t],o[t%o.length]);return this._colorMapCache={key:i,map:r,version:this._ingestVersion},r}resolveLineStyle(t,e){var n;const i=this.config.lineStyle;if("function"==typeof i){const n=i(e||{},t);if(n&&!n.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{stroke:e})}return n}const o=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:this.resolveGroupColor(t)||o||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var n,i;if(this.config.areaStyle){const n=this.config.areaStyle(e||{});if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const o=this.config.lineStyle;if("function"==typeof o){const n=o(e||{},t);if(n&&!n.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},n),{fill:e,stroke:n.stroke||e})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:null!==(i=o.fillOpacity)&&void 0!==i?i:.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=this.resolveGroupColor(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||ie;if(0===n.length)return null;const i=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,i),this._groupColorMap.size>Pe.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getPointId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,o}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{o.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,n,i,o;const r=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,t);const l="chartType"in t&&t.chartType!==r.chartType||"runtimeMode"in t&&t.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=l||!Et(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!Et(null!==(i=t.yAccessor)&&void 0!==i?i:t.valueAccessor,null!==(o=r.yAccessor)&&void 0!==o?o:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Dt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Dt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Dt(this.config.xAccessor,"x"),this.getY=Dt(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=_e(this.config)),s=!0,a=!0)}if("groupAccessor"in t&&!Et(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Ft(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!Et(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Ft(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!Et(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Dt(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!Et(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Ft(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!Et(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Dt(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in t&&!Et(t.boundsAccessor,r.boundsAccessor)||"band"in t&&t.band!==r.band||"boundsStyle"in t&&t.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=_e(this.config),s=!0,a=!0),"pointIdAccessor"in t&&!Et(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Ft(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!Et(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!Et(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!Et(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!Et(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?Dt(this.config.openAccessor,"open"):void 0,this.getHigh=Dt(this.config.highAccessor,"high"),this.getLow=Dt(this.config.lowAccessor,"low"),this.getClose=e?Dt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,a=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of e)if(t[n]!==r[n]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Oe(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function Te(t,e){var n,i=[],o=[],r=[],s={},a=[];function l(t){r[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],r[e]&&l(e)})}function c(t){var e,i,d=!1;for(o.push(t),r[t]=!0,e=0;a[t].length>e;e++)(i=a[t][e])===n?(u(n,o),d=!0):r[i]||(d=c(i));if(d)l(t);else for(e=0;a[t].length>e;e++){var h=s[i=a[t][e]];h||(s[i]=h={}),h[i]=!0}return o.pop(),d}function u(t,e){var n=[].concat(e).concat(t);i.push(n)}function d(e){!function(e){for(var n=0;t.length>n;n++)n>=e&&t[n]||(t[n]=[]),t[n]=t[n].filter(function(t){return t>=e})}(e);for(var n,i=function(t){for(var e=t.length,n=Array(e),i=Array(e),o=Array(e),r=Array(e),s=Array(e),a=Array(e),l=0;e>l;++l)n[l]=-1,i[l]=0,o[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(e){var l=[e],c=[e];for(n[e]=i[e]=u,o[e]=!0,u+=1;c.length>0;){var f=t[e=c[c.length-1]];if(f.length>r[e]){for(var g=r[e];f.length>g;++g){var p=f[g];if(0>n[p]){n[p]=i[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(i[e]=0|Math.min(i[e],i[p])),0>s[p]||a[e].push(s[p])}r[e]=g}else{if(i[e]===n[e]){var y=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(o[b]=!1,y.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===e){l.length=g;break}}d.push(y);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}c.pop()}}}for(l=0;e>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(t,e){return t-e}),c=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&c.push(g[p]);h[l]=c}}return{components:d,adjacencyList:h}}(t),o=i.components.filter(function(t){return t.length>1}),r=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)r>o[s][a]&&(r=o[s][a],n=s);var l=o[n];if(!l)return!1;var c=t.map(function(t,e){return-1===l.indexOf(e)?[]:t.filter(function(t){return-1!==l.indexOf(t)})});return{leastVertex:r,adjList:c}}n=0;for(var h=t.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var p=0;a[g].length>p;p++){var y=a[g][p];r[+y]=!1,s[y]={}}c(n),n+=1}else n=h}return i}function $e(t){return t.y0-t.y1>0?"up":"down"}function Le(t,e){return e(t.source)==e(t.target)}function je(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var n=0;return t.target.targetLinks.forEach(function(t){n=t.circular?n+1:n}),1>=e&&1>=n}function ze(t){return t.target.x0-t.source.x1}function Ce(t,e){var n=De(t),i=ze(e)/Math.tan(n);return"up"==$e(t)?t.y1-i:t.y1+i}function Ee(t,e){var n=De(t),i=ze(e)/Math.tan(n);return"up"==$e(t)?t.y1+i:t.y1-i}function De(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Re(t,e){return e(t)}function Fe(t){return Be(t.source)}function Ne(t){return Be(t.target)}function Be(t){return(t.y0+t.y1)/2}function We(t){return t.virtual?0:t.value}function Ie(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!Le(t,e)?n+1:n});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Le(t,e)?i+1:i}),n+i}function Ye(t){return t.target.depth}function Ge(t,e){return t.sourceLinks.length?t.depth:e-1}function He(t,e){return t.y0-e.y0}function Xe(t,e){return e.y0-t.y0}function qe(t,e){return t.y1-e.y1}function Ve(t,e){return e.y1-t.y1}function Ue(t,e){return Qe(t.source,e.source)||t.index-e.index}function Ze(t,e){return Qe(t.target,e.target)||t.index-e.index}function Qe(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Ke(t,e){return Je(t)==Je(e)?"bottom"==t.circularLinkType?Xe(t,e):He(t,e):Je(e)-Je(t)}function Je(t){return t.target.column-t.source.column}function tn(t,e){return en(t)==en(e)}function en(t){return t.y0-t.y1>0?"up":"down"}function nn(t,e,n,i,o){let r=t;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=A(r.links,function(t){return t.source.y0});r.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=r.links.filter(function(t){return t.circular});return l.sort(function(t,e){return e.value-t.value}),l.forEach(function(t,e){t._circularStub=e>=4}),on(r.links.filter(function(t){return"top"==t.circularLinkType}),e,n),on(r.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),r.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Le(t,e)&&je(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,l=t.circularLinkType,c=r.links.filter(function(t){return t.source.column==s&&t.circularLinkType==l});c.sort("bottom"==t.circularLinkType?Xe:He);var u=0;c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),s=t.target.column,(c=r.links.filter(function(t){return t.target.column==s&&t.circularLinkType==l})).sort("bottom"==t.circularLinkType?Ve:qe),u=0,c.forEach(function(e,o){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+o*n+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(r.y1,t.source.y1,t.target.y1)+o+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-o-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,n=t.y0,i=t.target.x0,o=t.y1,r=(e+i)/2;return"M"+e+","+n+"C"+r+","+n+" "+r+","+o+" "+i+","+o}(t)}),r}function on(t,e,n){t.sort(Ke);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,o){var r=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Le(t,e)&&je(t))t.circularPathData.verticalBuffer=r+t._circularWidth/2;else{for(var s=0;i.length>s;s++){var a=i[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&rn(t,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}t.circularPathData.verticalBuffer=r+t._circularWidth/2}}),t}function rn(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function sn(t){return function(){return t}}function an(t){return t.index}function ln(t){return t.nodes}function cn(t){return t.links}function un(t,e,n){var i=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(o,r){var s=o.length;if(e)o.sort(e);else if(r>0){var a=new Map;o.forEach(function(t,e){var n,i,o,r=(i=0,o=0,(n=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Be(t.source)*e,i+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;o+=Be(t.target)*e,i+=e}}),i>0?o/i:NaN);a.set(t,{bc:r,idx:e})}),o.sort(function(t,e){var n=a.get(t),i=a.get(e),o=n.bc,r=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(o)||isNaN(r)?isNaN(o)?isNaN(r)?n.idx-i.idx:1:-1:o-r})}else o.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ie(e,n)-Ie(t,n):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});o.forEach(function(e,o){e.depth==i.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Ie(e,n)?(e.y0=t.y1/2+o,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+o,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-o,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*o,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+o,e.y1=e.y0+e.value*t.ky)})})}function dn(t,e,n,i,o,r){var s=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,l=r;l>0;--l)c(a*=.99,n),u();function c(e,n){var i=s.length;s.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Ie(o,n)>0){var l=P(o.sourceLinks,Ne),c=P(o.targetLinks,Fe),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-Be(o))*e*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(s==i-1&&1==r)o.y0=t.y1/2-(a=o.y1-o.y0)/2,o.y1=t.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=P(o.sourceLinks,Ne),f=P(o.targetLinks,Fe),g=((h&&f?(h+f)/2:h||f)-Be(o))*e;o.y0+=g,o.y1+=g}})})}function u(){s.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||Qe),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+i;if((s=l-i-t.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+o-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function hn(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Ze),t.targetLinks.sort(Ue)}),t.nodes.forEach(function(t){var e=t.y0,n=e,i=t.y1,o=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=o-t.width/2,o-=t.width):(t.y1=n+t.width/2,n+=t.width)})})}function fn(){var t=0,e=0,n=1,i=1,o=24,r=8,s=null,a=an,l=Ge,c=void 0,u=32,d=2,h=ln,f=cn;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=t,h.y0=e,h.x1=n,h.y1=i,h.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var n=function(t,e){var n=new Map;return O(t,e).forEach(function(t,e){n.set(e,t[0])}),n}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,o=t.target;"object"!=typeof i&&(i=t.source=Oe(n,i)),"object"!=typeof o&&(o=t.target=Oe(n,o)),i.sourceLinks.push(t),o.targetLinks.push(t)})}(h,a),function(t,e){var n=0;if(null==e){for(var i=[],o=0;t.links.length>o;o++){var r=t.links[o],s=r.source.index,a=r.target.index;i[s]||(i[s]=[]),i[a]||(i[a]=[]),-1===i[s].indexOf(a)&&i[s].push(a)}var l=Te(i);l.sort(function(t,e){return t.length-e.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||c[i]&&c[i][e]?(t.circular=!0,t.circularLinkID=n++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=n++)})}(h,c),function(t,e){var n=0,i=0;t.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:i>n?"top":"bottom","top"==o.circularLinkType?n++:i++,t.nodes.forEach(function(t){Re(t,e)!=Re(o.source,e)&&Re(t,e)!=Re(o.target,e)||(t.circularLinkType=o.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Le(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(h,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(_(t.sourceLinks,We),_(t.targetLinks,We)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(h),function(t,e,n){var i,o,r;if(null!=e){t.nodes.sort(function(t,n){return e(t)<e(n)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.depth=r,t.sourceLinks.forEach(function(t){0>o.indexOf(t.target)&&!t.circular&&o.push(t.target)})});for(i=t.nodes,o=[],r=0;i.length;++r,i=o,o=[])i.forEach(function(t){t.height=r,t.targetLinks.forEach(function(t){0>o.indexOf(t.source)&&!t.circular&&o.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?n(t,r):t.column})}(h,c,l);var f=r;if(null!==s){var g=S(h.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=M(g,function(t){return t.length});p>1&&(f=Math.max(1,(i-e)*s/(p-1)))}(function(t,e,n){var i=S(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var o=A(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/_(e,function(t){return t.value})});t.ky=o,t.links.forEach(function(e){e.width=e.value*t.ky});var r=M(t.nodes,function(t){return t.column});t.nodes.forEach(r>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/r),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(h,f,o),un(h,c,a),dn(h,c,a,f,f,u),hn(h),nn(h,a,d,10,8),un(h,c,a),dn(h,c,a,f,f,u),hn(h),nn(h,a,d,10,8),function(t,e){let n=t;n.nodes.forEach(function(t){t.y+(t.y1-t.y0)>n.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-n.y1));var i=n.links.filter(function(n){return Re(n.source,e)==Re(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!tn(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=Ce(e,t);return t.y1-n}if(e.target.column>t.target.column)return Ce(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y0=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y0=t.y1-s-e.width/2}})})}(h,a),function(t,e){let n=t;n.nodes.forEach(function(t){var i=n.links.filter(function(n){return Re(n.target,e)==Re(t,e)}),o=i.length;o>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!tn(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=Ee(e,t);return t.y0-n}if(e.source.column>t.source.column)return Ee(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var r=t.y0;i.forEach(function(t){t.y1=r+t.width/2,r+=t.width}),i.forEach(function(e,n){if("bottom"==e.circularLinkType){for(var r=n+1,s=0;o>r;r++)s+=i[r].width;e.y1=t.y1-s-e.width/2}})})}(h,a),function(t){var e=t.nodes,n=t.links,i=!1,o=!1;if(n.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(o=!0)}),0==i||0==o){var r=A(e,function(t){return t.y0}),s=M(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-r);function l(e){return(e-r)/(s-r)*(t.y1-t.y0)+t.y0}1>a?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),n.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,n=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+n}),t.targetLinks.forEach(function(t){t.y1=t.y1+n})})}}(h),nn(h,a,d,10,8)}(g),g}return g.update=function(t){return hn(t),nn(t,a,d,10,8),t},g.nodeWidth=function(t){return arguments.length?(o=+t,g):o},g.nodePadding=function(t){return arguments.length?(r=+t,g):r},g.nodePaddingRatio=function(t){return arguments.length?(s=+t,g):s},g.nodes=function(t){return arguments.length?(h="function"==typeof t?t:sn(t),g):h},g.links=function(t){return arguments.length?(f="function"==typeof t?t:sn(t),g):f},g.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:sn(t),g):a},g.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:sn(t),g):l},g.nodeSort=function(t){return arguments.length?(c=t,g):c},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(d=+t,g):d},g.extent=function(o){return arguments.length?(t=+o[0][0],e=+o[0][1],n=+o[1][0],i=+o[1][1],g):[[t,e],[n,i]]},g.size=function(o){return arguments.length?(t=e=0,n=+o[0],i=+o[1],g):[n-t,i-e]},g}function gn(t){const{sx:e,sTop:n,sBot:i,tx:o,tTop:r,tBot:s,cp1X:a,cp2X:l}=t,c=(n+i)/2,u=(r+s)/2;return{pathD:[`M${e},${n}`,`C${a},${n} ${l},${r} ${o},${r}`,`L${o},${s}`,`C${l},${s} ${a},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(i-n)/2}}}Pe.GROUP_COLOR_MAP_CAP=1e3,Pe.QUADTREE_THRESHOLD=500;const pn=t=>{let e,n,i,o,r,s,a,l,c;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,n=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,o=t.y0+t.sankeyWidth/2,r=t.source.x1,s=t.target.x0,a=L(r,s),l=a(.5),c=a(.5),`M${e},${r}C${e},${l} ${n},${c} ${n},${s}L${i},${s}C${i},${c} ${o},${l} ${o},${r}Z`;const u=t.sankeyWidth/2,d=L(t.source.x1,t.target.x0),{pathD:h}=gn({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function yn(t){var e;const n=t.sankeyWidth/2,i=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const e=o.sourceX,i=o.sourceY,r=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-e))),l=Math.max(15,Math.min(40,.33*(r-o.leftFullExtent)));return`M${e},${i-n}L${e+a},${i-n}L${e+a},${i+n}L${e},${i+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}Z`}const r=o.sourceX,s=o.sourceY,a=o.targetX,l=o.targetY,c=o.rightFullExtent,u=o.leftFullExtent,d=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(i,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+i},${s-h*n+h*f}L${c+i},${d+h*i-h*f}L${c+i-f},${d+h*i}L${u-i+f},${d+h*i}L${u-i},${d+h*i-h*f}L${u-i},${l-h*n+h*f}L${u-i+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+i},${l+h*n}L${u+i},${d-h*i}L${c-i},${d-h*i}L${c-i},${s+h*n}L${r},${s+h*n}Z`}const mn=new Set,vn=new WeakMap;function bn(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=vn.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,vn.set(t,n);const i=new Proxy(t,{get(t,n,i){if("string"==typeof n&&!(n in t)&&t.data&&n in t.data){const t=`${e}:${n}`;mn.has(t)||(mn.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,n,i)}});return n.set(e,i),i}const xn={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Ye))-1:0},justify:Ge};function kn(t){return"string"==typeof t?t:t.id}const wn={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r,s,a,l,c,u;if(0===t.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(o=n.nodeWidth)&&void 0!==o?o:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=n.iterations)&&void 0!==s?s:100,y=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let v;v="down"===d?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const b=fn().extent(v).links(m).nodes(y).nodeAlign(xn[h]||Ge).nodeId(t=>t.id).nodeWidth(f).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let t=1/0,e=-1/0,n=1/0,o=-1/0;for(const i of y)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),n>i.y0&&(n=i.y0),i.y1>o&&(o=i.y1);for(const i of m){if(!i.circular||!i.circularPathData)continue;const r=i.circularPathData,s=(null!==(l=null!==(a=i._circularWidth)&&void 0!==a?a:i.width)&&void 0!==l?l:0)/2;t>r.leftFullExtent-s&&(t=r.leftFullExtent-s),r.rightFullExtent+s>e&&(e=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>o&&(o=r.verticalFullExtent+s)}const r=e-t,s=o-n,u=i[0],d=i[1];if(r>0&&s>0&&(0>t||0>n||e>u||o>d)){const e=Math.min(u/r,d/s),i=-t*e+(u-r*e)/2,o=-n*e+(d-s*e)/2;for(const t of y)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+o,t.y1=t.y1*e+o;for(const t of m)if(t.y0=t.y0*e+o,t.y1=t.y1*e+o,t.width=(null!==(c=t.width)&&void 0!==c?c:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const n=t.circularPathData;n.sourceX=n.sourceX*e+i,n.targetX=n.targetX*e+i,n.sourceY=n.sourceY*e+o,n.targetY=n.targetY*e+o,n.rightFullExtent=n.rightFullExtent*e+i,n.leftFullExtent=n.leftFullExtent*e+i,n.verticalFullExtent=n.verticalFullExtent*e+o,n.rightInnerExtent=n.rightInnerExtent*e+i,n.leftInnerExtent=n.leftInnerExtent*e+i,n.verticalRightInnerExtent=n.verticalRightInnerExtent*e+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*e+o,n.rightSmallArcRadius*=e,n.rightLargeArcRadius*=e,n.leftSmallArcRadius*=e,n.leftLargeArcRadius*=e,n.sourceWidth*=e,n.rightNodeBuffer*=e,n.leftNodeBuffer*=e,n.arcRadius*=e}}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of y){const e=x.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=kn(t.source),n=kn(t.target),i=k.get(t._edgeKey?t._edgeKey:`${e}\0${n}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=d;const o=x.get(e),r=x.get(n);o&&(i.source=o),r&&(i.target=r)}}},buildScene(t,e,n,i){var o,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(o=n.edgeOpacity)&&void 0!==o?o:.5,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:It,y=new Map;t.forEach((t,e)=>{y.set(t.id,p[e%p.length])});const m=[],v=[],b=[],x=new Map;for(const e of t){const t=e.x1-e.x0,n=e.y1-e.y0;if(0>=t||0>=n)continue;const i=d?d(bn(e,"nodeStyle")):{},o={fill:i.fill||y.get(e.id)||"#4d430c",stroke:i.stroke,strokeWidth:i.strokeWidth,opacity:i.opacity};x.set(e.id,("string"==typeof o.fill?o.fill:null)||y.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:n,h:t,style:o,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:n,style:o,datum:e,id:e.id,label:e.id})}const k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";o="function"==typeof g?g(t)||o:"target"===g?x.get(i.id)||y.get(i.id)||o:x.get(e.id)||y.get(e.id)||o;const u=h?h(bn(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,n=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),r=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||o;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-n}L${e.sourceX+i},${e.sourceY-n}L${e.sourceX+i},${e.sourceY+n}L${e.sourceX},${e.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-n}L${e.targetX-r},${e.targetY-n}L${e.targetX-r},${e.targetY+n}L${e.targetX},${e.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-r,x1:e.targetX}});continue}let d;if(d=t.circular&&t.circularPathData?yn(t):pn(t),!d)continue;const p={fill:u.fill||o,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:t.bezier,style:p,datum:t})}if(!1!==n.showLabels){const e=(w=n.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const n of t){const t=n.x1-n.x0,o=n.y1-n.y0;if(0>=t||0>=o)continue;const r=e?e(n):n.id;if(!r)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(i[0]/2>n.x0+t/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+o/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},An={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,n,i){var o,r;if(0===t.length)return;const s=null!==(o=n.forceStrength)&&void 0!==o?o:.1,a=i[0]/2,l=i[1]/2,c=n.__previousPositions;let u=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==c?void 0:c.get(e.id);t?u++:n?(e.x=n.x,e.y=n.y,u++):d.push(e)}const h=u>0&&.3>=(t.length>0?d.length/t.length:1);if(h){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of d){const i=Sn(t.id,e,n);if(i.length>0){let e=0,n=0;for(const t of i)e+=t.x,n+=t.y;const o=Mn(t.id),r=o%360*(Math.PI/180),s=10+o%20;t.x=e/i.length+s*Math.cos(r),t.y=n/i.length+s*Math.sin(r)}else{const e=Mn(t.id),n=e%360*(Math.PI/180),i=15+e%30;t.x=a+i*Math.cos(n),t.y=l+i*Math.sin(n)}}}else{const e=2.399963229728653;for(let n=0;t.length>n;n++){const i=t[n];if(null==i.x||null==i.y||0===i.x&&0===i.y){const t=10*Math.sqrt(n+.5),o=n*e;i.x=a+t*Math.cos(o),i.y=l+t*Math.sin(o)}}}const f=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),g=0===n.iterations?0:h?40:f,p=_n(n.nodeSize,n.nodeSizeRange,t),y=t=>p(t);if(g>0){const n=j().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),i=z().force("charge",C().strength(t=>-25*y(t))).force("center",E(a,l).strength(.8)).force("x",D(a).strength(.15)).force("y",R(l).strength(.15));if(i.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));n.links(t),i.force("link",n)}h?i.alpha(.3):.1>i.alpha()&&i.alpha(1),i.stop();for(let t=0;g>t;++t)i.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=y(e);e.x=Math.max(t,Math.min(i[0]-t,e.x)),e.y=Math.max(t,Math.min(i[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=m.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=m.get(t.target);e&&(t.target=e)}}},buildScene(t,e,n,i){var o,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=_n(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:It,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const y=[],m=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(bn(e,"nodeSize")),i=d?d(bn(e,"nodeStyle")):{},a={fill:i.fill||p.get(e.id)||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#007bff",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:2,opacity:i.opacity};y.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),i="object"==typeof t.target?t.target:b.get(t.target);if(!e||!i)continue;if(null==e.x||null==e.y)continue;if(null==i.x||null==i.y)continue;const o=h?h(bn(t,"edgeStyle")):{},r={stroke:o.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=o.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=o.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:r,datum:t})}if(!1!==n.showLabels){const e=(x=n.nodeLabel)?"function"==typeof x?x:t=>t[x]||t.id:null;for(const n of t){if(null==n.x||null==n.y)continue;const t=e?e(n):n.id;if(!t)continue;const i=f(bn(n,"nodeSize"));v.push({x:n.x,y:n.y-i-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}};function Sn(t,e,n){const i=[];for(const o of e){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id;let s=null;if(e===t?s=r:r===t&&(s=e),s){const t=n.get(s);!t||0===t.x&&0===t.y||i.push({x:t.x,y:t.y})}}return i}function Mn(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return Math.abs(e)}function _n(t,e,n){var i,o;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const r=e||[5,20],s=n.map(e=>{var n;return null===(n=e.data)||void 0===n?void 0:n[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===s.length)return()=>r[0];const a=null!==(i=A(s))&&void 0!==i?i:0,l=null!==(o=M(s))&&void 0!==o?o:1;if(a===l)return()=>(r[0]+r[1])/2;const c=v().domain([a,l]).range(r).clamp(!0);return e=>{var n;const i=null===(n=e.data)||void 0===n?void 0:n[t];return null==i||"number"!=typeof i?r[0]:c(i)}}const Pn=It,On={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,n,i){if(0===t.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=n,a=Math.min(i[0],i[1])/2,l=a-r,c=i[0]/2,u=i[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:t=>{var e;return null!==(e=t[h])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var h;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const g=t.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=f.get("string"==typeof t.source?t.source:t.source.id),i=f.get(e);if(void 0===n||void 0===i)continue;const o=d(t);p[n][i]=o}const y=N().padAngle(o);s&&y.sortGroups(s);const m=y(p),v=m.groups,b=B().innerRadius(l).outerRadius(a);for(const e of v){const n=t[e.index],i=b.centroid({innerRadius:l,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=i[0]+c,n.y=i[1]+u,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=x.get("string"==typeof t.source?t.source:t.source.id),i=x.get(e);n&&(t.source=n),i&&(t.target=i)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const n=t[e.source.index].id,i=t[e.target.index].id,o=k.get(`${n}\0${i}`)||k.get(`${i}\0${n}`);o&&(o.__chordData=e)}},buildScene(t,e,n,i){var o,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=n,u=Math.min(i[0],i[1])/2,d=u-l,h=i[0]/2,f=i[1]/2,g=n.nodeStyle,p=n.edgeStyle,y=n.edgeColorBy||"source",m=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Pn,v=new Map;t.forEach((t,e)=>{v.set(t.id,m[e%m.length])});const b=F().radius(d),x=[],k=[],w=[];for(let e=0;t.length>e;e++){const n=t[e],i=n.__arcData;if(!i)continue;let r;r=g?g(bn(n,"nodeStyle")).fill||v.get(n.id)||m[e%m.length]:v.get(n.id)||m[e%m.length];const s=g?g(bn(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(o=s.strokeWidth)&&void 0!==o?o:1,opacity:s.opacity};x.push({type:"arc",cx:h,cy:f,innerR:d,outerR:u,startAngle:i.startAngle-Math.PI/2,endAngle:i.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const i=b(e);if(!i)continue;const o=Tn(i,h,f);let l=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)l=p(bn(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===y&&n?l=v.get(n.id)||l:e&&(l=v.get(e.id)||l)}const u=p?p(bn(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};k.push({type:"ribbon",pathD:o,style:d,datum:t})}if(!1!==n.showLabels){const e=(A=n.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null,i=u+12;for(const n of t){const t=n.__arcData;if(!t)continue;const o=e?e(n):n.id;if(!o)continue;const r=(t.startAngle+t.endAngle)/2,s=r-Math.PI/2;w.push({x:h+Math.cos(s)*i,y:f+Math.sin(s)*i,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:x,sceneEdges:k,labels:w}}};function Tn(t,e,n){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const o=[];let r=0;for(;i.length>r;){const t=i[r];if("M"===t||"L"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("C"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;3>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("Q"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)for(let t=0;2>t&&i.length>r&&!isNaN(Number(i[r]));t++)o.push(Number(i[r])+e+""),r++,i.length>r&&!isNaN(Number(i[r]))&&(o.push(Number(i[r])+n+""),r++);else if("A"===t)for(o.push(t),r++;i.length>r&&!isNaN(Number(i[r]));)o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&o.push(i[r++]),i.length>r&&(o.push(Number(i[r])+e+""),r++),i.length>r&&(o.push(Number(i[r])+n+""),r++);else"Z"===t||"z"===t?(o.push(t),r++):(o.push(i[r]),r++)}return o.join(" ")}const $n=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ln(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>150?"#222":"#fff"}function jn(t,e,n){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+n}function zn(t){return t?"function"==typeof t?t:e=>{var n;return(null===(n=e.data)||void 0===n?void 0:n[t])||e[t]||e.id}:null}function Cn(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:$n}function En(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Dn(t,e,n,i,o){if("horizontal"===o){const o=(t+n)/2;return`M ${t},${e} C ${o},${e} ${o},${i} ${n},${i}`}if("radial"===o){const o=(t+n)/2;return`M ${t},${e} Q ${o},${e} ${o},${(e+i)/2} T ${n},${i}`}{const o=(e+i)/2;return`M ${t},${e} C ${t},${o} ${n},${o} ${n},${i}`}}const Rn={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,n,i){var o;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(n.childrenAccessor),l=n.hierarchySum,c="function"==typeof l?l:"string"==typeof l?t=>Number(t[l])||0:t=>Number(t.value)||0,u=tt(r,a);u.sum(c),u.sort((t,e)=>{var n,i;return(null!==(n=e.value)&&void 0!==n?n:0)-(null!==(i=t.value)&&void 0!==i?i:0)});const[d,h]=i;switch(s){case"tree":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=st();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"cluster":!function(t,e,n,i){const o=e.treeOrientation||"vertical",r=rt();r.size("horizontal"===o?[i,n]:"radial"===o?[2*Math.PI,Math.min(n,i)/2*.8]:[n,i]),r(t)}(u,n,d,h);break;case"treemap":!function(t,e,n,i){var o,r;const s=null!==(o=e.padding)&&void 0!==o?o:4,a=null!==(r=e.paddingTop)&&void 0!==r?r:0,l=it().size([n,i]).tile(ot).padding(s);a>0&&l.paddingTop(a),l(t)}(u,n,d,h);break;case"circlepack":!function(t,e,n,i){var o;const r=null!==(o=e.padding)&&void 0!==o?o:4;nt().size([n,i]).padding(r)(t)}(u,n,d,h);break;case"partition":!function(t,e,n,i){var o;et().size([n,i]).padding(null!==(o=e.padding)&&void 0!==o?o:1)(t)}(u,n,d,h)}const f=u.descendants();t.length=0,e.length=0;const g=new Map;for(let e=0;f.length>e;e++){const i=f[e],r={id:jn(i,n,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(o=i.value)&&void 0!==o?o:0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===s||"cluster"===s?Fn(r,i,n):"treemap"===s||"partition"===s?Nn(r,i):"circlepack"===s&&Bn(r,i),r.__hierarchyNode=i,t.push(r),g.set(i,r)}if("tree"===s||"cluster"===s)for(const t of f)if(t.parent){const n=g.get(t.parent),i=g.get(t);n&&i&&e.push({source:n,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,n,i){const o=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(t,e,n,i,o,r){var s,a,l,c,u,d,h,f;const g=[],p=[],y=[],m=n.treeOrientation||"vertical",v="radial"===m,b=i[0]/2,x=i[1]/2,k="number"==typeof(w=n.nodeSize)?w:5;var w;for(const e of t){let t=e.x,i=e.y;v&&(t+=b,i+=x);const r=o(bn(e,"nodeStyle"));let l=r.fill||En(n);if(n.colorByDepth&&void 0!==e.depth){const t=Cn(n);l=t[e.depth%t.length]}const c={fill:l,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};g.push({type:"circle",cx:t,cy:i,r:k,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const A=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;if(!e||!i)continue;let o=e.x,s=e.y,a=i.x,l=i.y;v&&(o+=b,s+=x,a+=b,l+=x);const f=Dn(o,s,a,l,m),g=r(bn(t,"edgeStyle")),y={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};p.push({type:"curved",pathD:f,style:y,datum:t})}if(!1!==n.showLabels){const e=zn(n.nodeLabel);for(const n of t){const t=e?e(n):n.id;if(!t)continue;let i,o,r,s=n.x,a=n.y;if(v&&(s+=b,a+=x),v){const t=s-b,e=a-x,n=Math.sqrt(t*t+e*e);n>0?(i=s+t/n*10,o=a+e/n*10,r=0>t?"end":"start"):(i=s,o=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(i=s-k-6,r="end"):(i=s+k+6,r="start"),o=a):(i=s,o=a+k+14,r="middle");y.push({x:i,y:o,text:t+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:p,labels:y}}(t,e,n,i,o,r);case"treemap":case"partition":return function(t,e,n,i){var o,r,s,a,l;const c=[],u=[];for(const n of t){const t=n.x1-n.x0,s=n.y1-n.y0;if(0>=t||0>=s)continue;const a=i(bn(n,"nodeStyle"));let l=a.fill||En(e);if(e.colorByDepth&&void 0!==n.depth){const t=Cn(e);l=t[n.depth%t.length]}const u={fill:l,stroke:a.stroke||(null===(o=e.themeSemantic)||void 0===o?void 0:o.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};c.push({type:"rect",x:n.x0,y:n.y0,w:t,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=zn(e.nodeLabel),o=e.labelMode||"leaf",r="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,d=c.y1-c.y0;if(0>=t||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===o&&!h)continue;if("parent"===o&&h)continue}const f=n?n(c):c.id;if(!f)continue;if((h?30:40)>t||(h?16:14)>d)continue;let g=i(bn(c,"nodeStyle")).fill||En(e);if(e.colorByDepth&&void 0!==c.depth){const t=Cn(e);g=t[c.depth%t.length]}const p="string"==typeof g?Ln(g):null!==(l=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+t/2,y:c.y0+d/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,d)/6)),fill:p}:{x:c.x0+4,y:c.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(t,n,0,o);case"circlepack":return function(t,e,n,i){var o,r,s,a,l,c,u,d,h,f;const g=[],p=[];for(const n of t){const t=null!==(o=n.__radius)&&void 0!==o?o:5;if(0>=t)continue;const l=i(bn(n,"nodeStyle"));let c=l.fill||En(e);if(e.colorByDepth&&void 0!==n.depth){const t=Cn(e);c=t[n.depth%t.length]}const u={fill:c,stroke:l.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:n.x,cy:n.y,r:t,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==e.showLabels){const n=zn(e.nodeLabel);for(const o of t){const t=null!==(l=o.__radius)&&void 0!==l?l:5,r=n?n(o):o.id;if(!r)continue;if(15>t)continue;const s=!((null===(c=o.data)||void 0===c?void 0:c.children)&&o.data.children.length>0);let a=i(bn(o,"nodeStyle")).fill||En(e);if(e.colorByDepth&&void 0!==o.depth){const t=Cn(e);a=t[o.depth%t.length]}if(s){const n="string"==typeof a?Ln(a):null!==(d=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";p.push({x:o.x,y:o.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:n})}else p.push({x:o.x,y:o.y-t+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(h=e.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:p}}(t,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Fn(t,e,n){const i=n.treeOrientation||"vertical";if("radial"===i){const n=e.x,i=e.y;t.x=i*Math.cos(n-Math.PI/2),t.y=i*Math.sin(n-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function Nn(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function Bn(t,e){var n;const i=null!==(n=e.r)&&void 0!==n?n:0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}function Wn(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const In={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,n,i){const o=n.__hierarchyRoot;o&&function(t,e,n,i,o){var r,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(n.childrenAccessor),l=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var n;return(null!==(n=t[e])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),c=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),u=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,d=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,h="number"==typeof u?()=>u:u,f="number"==typeof d?()=>d:d,g=Wn(n);g.metaMap.clear(),i.length=0,o.length=0;const p=new Map;function y(t){var e;const n=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,n+1),0===n?t:`${t}__${n}`}const m=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,x=y(l(t));i.push({id:x,x:m,y:v,x0:m,x1:m,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),g.metaMap.set(x,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,u,d,p){const m=a(e);if(!(null==m?void 0:m.length))return;const v=m.length;let b=0,x=0,k=0;for(;v>x;)x+=c[Math.min(k,c.length-1)],k++,b++;let w=0;for(let v=0;b>v;v++){const x=c[Math.min(v,c.length-1)],k=m.slice(w,w+x);if(!k.length)break;const A=(v+1)/b,S={id:n,depth:d,data:e,parentId:n},M=p?u/h(S)*A:u*A,_=W().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(k),O=f(S);for(let e=0;k.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,c=k[e],u=y(l(c)),h=r+M*Math.sin(a),f=s+M*Math.cos(a)*O;i.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:c}),g.metaMap.set(u,{ring:M,angle:a,depth:d,parentId:n,eccentricity:O}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),t(c,u,h,f,M,d+1,!0)}w+=x}}(t,x,m,v,b,1,!1)}(o,i,n,t,e)},buildScene(t,e,n,i){var o,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],p=[],y=[];if(!1!==n.orbitShowRings){const e=Wn(n),i=new Map;for(const e of t)i.set(e.id,e);const o=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const n=`${t.parentId}:${t.ring}`;o.has(n)||o.set(n,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:n,ecc:i}]of o)for(let o=0;r>o;o++){const a=o/r*Math.PI*2,l=(o+1)/r*Math.PI*2;p.push({type:"line",x1:t+n*Math.sin(a),y1:e+n*Math.cos(a)*i,x2:t+n*Math.sin(l),y2:e+n*Math.cos(l)*i,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(bn(e,"nodeSize")),i=d?d(bn(e,"nodeStyle")):{},c={fill:i.fill||(null===(o=n.themeSemantic)||void 0===o?void 0:o.primary)||"#6366f1",stroke:i.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=i.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=i.opacity)&&void 0!==a?a:0===(null!==(l=e.depth)&&void 0!==l?l:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:c,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),n="object"==typeof t.target?t.target:m.get(t.target);e&&n&&(null!=e.x&&null!=n.x&&p.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(n.showLabels){const e=n.nodeLabel;for(const n of t){const t=f(bn(n,"nodeSize"));if(4>=t)continue;const i="function"==typeof e?e(n):e&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[e])&&void 0!==u?u:n.id;y.push({x:n.x,y:n.y+t+12,text:i+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:p,labels:y}},tick:(t,e,n,i,o)=>!1!==n.orbitAnimated&&(function(t,e){var n,i;const o=Wn(e),r=null!==(n=e.orbitSpeed)&&void 0!==n?n:.25,s=null!==(i=e.orbitRevolution)&&void 0!==i?i:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const n=null!==(e=t.depth)&&void 0!==e?e:0;return(n%2==0?1:-1)/(n+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const e of t)c.set(e.id,e);for(const e of t){const t=o.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=c.get(t.parentId);if(!n)continue;const i=t.angle+a*l*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(i),e.y=n.y+t.ring*Math.cos(i)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,n),!0)},Yn={sankey:wn,force:An,chord:On,tree:Rn,cluster:Rn,treemap:Rn,circlepack:Rn,partition:Rn,orbit:In};function Gn(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=ee[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function Hn(t){return 0===t.length?()=>"#4e79a7":e=>{var n;let i=0;for(let t=0;e.length>t;t++)i=31*i+e.charCodeAt(t)|0;return null!==(n=t[Math.abs(i)%t.length])&&void 0!==n?n:"#4e79a7"}}function Xn(t,e){var n;const{columns:i,config:o,resolvePieceStyle:r}=t,s=[],a=Math.min(e.width,e.height)/2-4,l="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,u=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,d=null!=o.sweepAngle&&360>o.sweepAngle,h=Object.values(i),f=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),g=d&&!f&&h.length>1&&(null!==(n=o.cornerRadius)&&void 0!==n?n:0)>0;for(let t=0;h.length>t;t++){const e=h[t],n=e.pieceData[0],i="number"==typeof(null==n?void 0:n._pctStart)?n._pctStart:e.pctStart,d=c+i*u,f=c+(i+("number"==typeof(null==n?void 0:n._pct)?n._pct:e.pct))*u,p=r(e.pieceData[0],e.name),y=0===t,m=t===h.length-1,v=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:d,endAngle:f},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:p,datum:(null==n?void 0:n._nonInteractive)?null:e.pieceData,category:e.name});(null==n?void 0:n._roundedEnds)?v.roundedEnds=n._roundedEnds:g&&(v.roundedEnds={start:y,end:m}),(null==n?void 0:n._gradientBand)&&(v._gradientBand=n._gradientBand),s.push(v)}return s}function qn(t){var e,n,i;const o=t.length,r=t[0],s=t[o-1];return{n:o,min:r,q1:null!==(e=T(t,.25))&&void 0!==e?e:r,median:null!==(n=T(t,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(i=T(t,.75))&&void 0!==i?i:s,max:s,mean:t.reduce((t,e)=>t+e,0)/o}}const Vn={bar:function(t,e){var n,i,o;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=t,{r:d,projection:h}=r,f=[],g="vertical"===h,p="horizontal"===h,y=a.normalize,m=[];if(c){const t=new Set;for(const e of Object.values(s))for(const n of e.pieceData){const e=c(n);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const n of t.pieceData){const t=c?c(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t);i.total+=l(n),i.pieces.push(n)}let n=0;if(y)for(const t of e.values())n+=Math.abs(t.total);let i=0,o=0;for(const r of m){const s=e.get(r);if(!s)continue;let a=s.total;y&&n>0&&(a/=n);const l=u(s.pieces[0],c?r:t.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=d(0>a?o:i+a),n=0>a?d(o+a)-d(o):d(i)-d(i+a);f.push(zt(t.x,e,t.width,Math.abs(n),l,h,r)),0>a?o+=a:i+=a}else if(p){const e=d(0>a?o+a:i),n=0>a?d(o)-d(o+a):d(i+a)-d(i);f.push(zt(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?o+=a:i+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==i?i:0;t.roundedEdge=v?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(b>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const n=(null===(o=e.datum)||void 0===o?void 0:o.category)||"";t.has(n)||t.set(n,[]),t.get(n).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,n;return(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)>=0}),n=e.filter(t=>{var e,n;return 0>(null!==(n=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==n?n:0)});t.length>0&&(t.reduce(v?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=b),n.length>0&&(n.reduce(v?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=b)}}return f},clusterbar:function(t,e){const{scales:n,columns:i,config:o,getR:r,getGroup:s,resolvePieceStyle:a}=t,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],f=new Set;for(const t of Object.values(i))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),h.push(t))}const g=h.length||1;for(const t of Object.values(i)){const e=t.width/g,n=.2*e,i=e-n,o=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";o.has(t)||o.set(t,[]),o.get(t).push(e)}for(let s=0;h.length>s;s++){const c=o.get(h[s])||[];for(const o of c){const c=r(o),f=a(o,h[s]);if(d){const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(zt(r,Math.min(a,d),i,Math.abs(a-d),f,o,h[s]))}else{const r=t.x+s*e+n/2,a=l(0),d=l(c);u.push(zt(Math.min(a,d),r,Math.abs(d-a),i,f,o,h[s]))}}}}const p=o.roundedTop&&o.roundedTop>0?Math.max(0,o.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=r(t.datum);p>0&&(t.roundedTop=p),t.roundedEdge=d?0>e?"bottom":"top":0>e?"left":"right",o.gradientFill&&(t.fillGradient=o.gradientFill)}return u},point:function(t,e){var n,i;const{scales:o,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=t,{r:c,projection:u}=o,d=[],h="vertical"===u,f="radial"===u,g=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(r))for(const e of t.pieceData){const o=null!==(n=e.__rIndex)&&void 0!==n?n:0,r=null!==(i=e.__rValue)&&void 0!==i?i:s(e),u=g&&a[o]||c,m=l(e,t.name),v=m.r||5;let b,x;if(f){const e=y+(t.pctStart+t.pct/2)*p,n=u(r);b=Math.cos(e)*n,x=Math.sin(e)*n}else h?(b=t.middle,x=u(r)):(b=u(r),x=t.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:e})}return d},swarm:function(t,e){const{scales:n,columns:i,getR:o,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="vertical"===a;for(const t of Object.values(i)){const e=t.width/2;for(let n=0;t.pieceData.length>n;n++){const i=t.pieceData[n],a=o(i),u=r(i,t.name),d=u.r||4,h=(7919*n%100/100-.5)*e*.8,f=c?t.middle+h:s(a),g=c?s(a):t.middle+h;l.push({type:"point",x:f,y:g,r:d,style:u,datum:i})}}return l},pie:Xn,donut:Xn,boxplot:function(t,e){var n,i,o,r,s,a;const{scales:l,columns:c,config:u,getR:d,resolveSummaryStyle:h}=t,{r:f,projection:g}=l,p=[],y="vertical"===g,m=!1!==u.showOutliers;for(const e of Object.values(c)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const c=l[0],u=l[l.length-1],g=null!==(n=T(l,.25))&&void 0!==n?n:c,v=null!==(i=T(l,.5))&&void 0!==i?i:(c+u)/2,b=null!==(o=T(l,.75))&&void 0!==o?o:u,x=b-g,k=g-1.5*x,w=b+1.5*x,A=null!==(r=l.find(t=>t>=k))&&void 0!==r?r:c,S=null!==(s=[...l].reverse().find(t=>w>=t))&&void 0!==s?s:u,M=h(e.pieceData[0],e.name),_=[];if(m)for(const t of e.pieceData){const n=d(t);if(k>n||n>w){const i=y?e.middle:f(n),o=y?f(n):e.middle;_.push({px:i,py:o,value:n,datum:t})}}if(p.push({type:"boxplot",x:y?e.middle:0,y:y?0:e.middle,projection:y?"vertical":"horizontal",columnWidth:.6*e.width,minPos:f(A),q1Pos:f(g),medianPos:f(v),q3Pos:f(b),maxPos:f(S),stats:{n:l.length,min:A,q1:g,median:v,q3:b,max:S,mean:l.reduce((t,e)=>t+e,0)/l.length},style:M,datum:e.pieceData,category:e.name,outliers:_}),m)for(const e of _)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:M.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var n,i,o;const{scales:r,columns:s,config:a,getR:l,resolveSummaryStyle:c}=t,{r:u,projection:d}=r,h=[],f="vertical"===d,g=a.bins||20,p=!1!==a.showIQR;for(const t of Object.values(s)){const e=t.pieceData.map(t=>l(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const r=e[0],s=e[e.length-1],a=(s-r)/g||1,d=Array(g).fill(0);for(const t of e)d[Math.min(Math.floor((t-r)/a),g-1)]++;const y=Math.max(...d,1),m=t.width/2*.9;let v="";if(f){v=`M ${t.middle} ${u(r)}`;for(let e=0;g>e;e++){const n=u(r+(e+.5)*a);v+=` L ${t.middle+d[e]/y*m} ${n}`}v+=` L ${t.middle} ${u(s)}`;for(let e=g-1;e>=0;e--){const n=u(r+(e+.5)*a);v+=` L ${t.middle-d[e]/y*m} ${n}`}v+=" Z"}else{v=`M ${u(r)} ${t.middle}`;for(let e=0;g>e;e++)v+=` L ${u(r+(e+.5)*a)} ${t.middle-d[e]/y*m}`;v+=` L ${u(s)} ${t.middle}`;for(let e=g-1;e>=0;e--)v+=` L ${u(r+(e+.5)*a)} ${t.middle+d[e]/y*m}`;v+=" Z"}const b=c(t.pieceData[0],t.name);let x;if(p&&e.length>=4){const a=null!==(n=T(e,.25))&&void 0!==n?n:r,l=null!==(i=T(e,.5))&&void 0!==i?i:(r+s)/2,c=null!==(o=T(e,.75))&&void 0!==o?o:s;x={q1Pos:u(a),medianPos:u(l),q3Pos:u(c),centerPos:t.middle,isVertical:f}}const k=f?{x:t.x,y:Math.min(u(s),u(r)),width:t.width,height:Math.abs(u(s)-u(r))}:{x:Math.min(u(r),u(s)),y:t.x,width:Math.abs(u(s)-u(r)),height:t.width};h.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:k,iqrLine:x,stats:qn(e),style:b,datum:t.pieceData,category:t.name})}return h},histogram:function(t,e){var n;const{scales:i,columns:o,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l}=i,c=[],u=r.bins||25,d=r.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),f=h?+h[0]:void 0,g=h?+h[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const n=null!=f&&isFinite(f)?f:Math.min(...e),i=null!=g&&isFinite(g)?g:Math.max(...e),o=(i-n)/u||1,r=Array(u).fill(0);for(const t of e)n>t||t>i||r[Math.min(Math.floor((t-n)/o),u-1)]++;const h=e.length,p=Math.max(...r,1),y=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===r[e])continue;const i=(d?r[e]/h:r[e]/p)*t.width*.9,s=l(n+e*o),a=l(n+(e+1)*o);c.push(zt(Math.min(s,a),t.x+t.width-i,Math.abs(a-s),i,y,{bin:e,count:r[e],range:[n+e*o,n+(e+1)*o],category:t.name},t.name))}}return c},ridgeline:function(t,e){var n;const{scales:i,columns:o,config:r,getR:s,resolveSummaryStyle:a}=t,{r:l,projection:c}=i,u=[],d=r.bins||20,h="horizontal"===c,f=r.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],r=(o-i)/d||1,c=Array(d).fill(0);for(const t of e)i>t||t>o||c[Math.min(Math.floor((t-i)/r),d-1)]++;const g=Math.max(...c,1),p=a(t.pieceData[0],t.name),y=t.width*f;let m="";if(h){const e=t.x+t.width;m=`M ${l(i)} ${e}`;for(let t=0;d>t;t++)m+=` L ${l(i+(t+.5)*r)} ${e-c[t]/g*y}`;m+=` L ${l(o)} ${e} Z`}else{const e=t.x;m=`M ${e} ${l(i)}`;for(let t=0;d>t;t++){const n=l(i+(t+.5)*r);m+=` L ${e+c[t]/g*y} ${n}`}m+=` L ${e} ${l(o)} Z`}const v=h?{x:Math.min(l(i),l(o)),y:t.x,width:Math.abs(l(o)-l(i)),height:t.width}:{x:t.x,y:Math.min(l(o),l(i)),width:t.width,height:Math.abs(l(o)-l(i))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:qn(e),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:n,columns:i,getRawRange:o,resolvePieceStyle:r}=t,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const t of Object.values(i))for(const e of t.pieceData){const n=o(e);if(!n)continue;const[i,a]=n,u=r(e,t.name);if(c){const n=s(Math.min(i,a)),o=s(Math.max(i,a));l.push(zt(n,t.x,o-n,t.width,u,e,t.name))}else{const n=s(Math.max(i,a)),o=s(Math.min(i,a));l.push(zt(t.x,n,t.width,o-n,u,e,t.name))}}return l},funnel:function(t,e){var n,i,o,r,s,a,l,c;const{columns:u,getR:d,getStack:h,resolvePieceStyle:f}=t,g=[],p=e.width/2,y=!1!==t.config.showLabels,m=t.scales.o.domain().map(t=>u[t]).filter(Boolean);if(0===m.length)return g;const b=[],x=new Set;for(const t of m)for(const e of t.pieceData){const t=h?h(e):"_default";x.has(t)||(x.add(t),b.push(t))}const k=b.length>1&&"_default"!==b[0],w=[];let A=0;for(const t of m){const e=new Map;let n=0;for(const i of t.pieceData){const t=h?h(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),r=d(i);o.total+=r,o.pieces.push(i),n+=r}w.push({col:t,groups:e,stepTotal:n}),k||n>A&&(A=n)}if(k)for(const t of w){let e=0,n=0;for(let i=0;b.length>i;i++){const o=t.groups.get(b[i]);o&&(i%2==0?e+=o.total:n+=o.total)}const i=Math.max(e,n);i>A&&(A=i)}if(0===A)return g;const S=new Map;for(const t of b){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const M=w[0].stepTotal,_=k?.95*p:.9*e.width,P=v().domain([0,A]).range([0,_]),O=null!==(i=t.config.connectorOpacity)&&void 0!==i?i:.3;let T=new Map;for(let e=0;w.length>e;e++){const n=w[e],i=n.col,u=0===e,d=i.width,h=.55*d,m=i.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of b){const i=n.groups.get(e);i&&(t+=P(i.total))}let e=p,o=p;for(let r=0;b.length>r;r++){const a=b[r],l=n.groups.get(a);if(!l)continue;const c=P(l.total),d=r%2==0,x=d?e:o-c;d?e+=c:o-=c;const k=f(l.pieces[0],a),w=null!==(s=S.get(a))&&void 0!==s?s:l.total,A=w>0?l.total/w*100:0,M=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:A,__funnelStep:i.name,__funnelIsFirstStep:u,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:a});y&&(0===r&&(M.__funnelStepLabel=i.name,M.__funnelStepLabelX=p,M.__funnelStepLabelY=m,M.__funnelRowWidth=t),M.__funnelValueLabelX=x+c/2,M.__funnelValueLabelY=m,M.__funnelBarW=c),g.push(zt(x,m,c,h,k,M,a)),v.set(a,{x:x,y:m,w:c,h:h})}}else{const t=n.stepTotal,e=P(t),s=p-e/2,a=b[0],l="_default"!==a,c=null!==(r=null===(o=n.groups.get(a))||void 0===o?void 0:o.pieces[0])&&void 0!==r?r:i.pieceData[0],d=l?a:i.name,x=f(c,d),k=M>0?t/M*100:0,w=Object.assign(Object.assign({},c),{__funnelValue:t,__funnelPercent:k,__funnelStep:i.name,__funnelIsFirstStep:u,category:l?a:i.name});y&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=p,w.__funnelStepLabelY=m,w.__funnelRowWidth=e,w.__funnelValueLabelX=p,w.__funnelValueLabelY=m,w.__funnelBarW=e),g.push(zt(s,m,e,h,x,w,d)),v.set(a,{x:s,y:m,w:e,h:h})}if(e>0&&T.size>0){const e=k?b:[b[0]];for(const o of e){const e=T.get(o),r=v.get(o);if(!e||!r)continue;const s=(()=>{const t=n.groups.get(o);return f(t?t.pieces[0]:i.pieceData[0],"_default"===o?i.name:o)})(),u={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(a=t.config.themeSemantic)||void 0===a?void 0:a.secondary)||"#999",opacity:O},datum:null!==(c=null===(l=n.groups.get(o))||void 0===l?void 0:l.pieces[0])&&void 0!==c?c:i.pieceData[0],category:"_default"===o?i.name:o};g.push(u)}}T=v}return g},"bar-funnel":function(t,e){var n,i,o,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=t,d=[],h=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===h.length)return d;const f=[],g=new Set;for(const t of h)for(const e of t.pieceData){const t=l?l(e):"_default";g.has(t)||(g.add(t),f.push(t))}const p=f.length>1&&"_default"!==f[0],y=[];for(const t of h){const e=new Map;let n=0;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t),r=a(i);o.total+=r,o.pieces.push(i),n+=r}y.push({col:t,groups:e,stepTotal:n})}const m=new Map;for(const t of f){const e=null===(n=y[0])||void 0===n?void 0:n.groups.get(t);m.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const v=u.r,b=p?f.length:1,x=p?.15:0;for(let t=0;y.length>t;t++){const e=y[t],n=e.col,i=0===t,s=t>0?y[t-1]:null,a=n.width/b,l=a*x,u=a-l;for(let t=0;f.length>t;t++){const h=f[t],g=e.groups.get(h);if(!g)continue;const y=g.total,b=null!==(o=m.get(h))&&void 0!==o?o:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,A=i?0:Math.max(0,w-y),S=n.x+t*a+l/2,M=v(y),_=v(0)-M,P=c(g.pieces[0],p?h:n.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:v(y+A)});if(d.push(zt(S,M,u,_,P,O,p?h:n.name)),A>0){const t=v(y+A),e=M-t,i=Object.assign({},P),o=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(zt(S,t,u,e,i,o,p?h:n.name))}}}return d},swimlane:function(t,e){var n;const{scales:i,columns:o,getR:r,getStack:s,resolvePieceStyle:a}=t,{r:l,projection:c}=i,u=[],d="horizontal"===c,h=t.config.gradientFill,f=d?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(n=g.opacity)&&void 0!==n?n:1,[i,r]=l.range(),s=Math.min(i,r),a=Math.abs(r-i);for(const n of Object.values(o)){const i={fill:t,opacity:e},o=d?zt(s,n.x,a,n.width,i,null,"__track__"):zt(n.x,s,n.width,a,i,null,"__track__");u.push(o)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(o)){let e=0;const n=u.length;for(const n of t.pieceData){const i=Math.abs(r(n));if(0===i)continue;const o=s?s(n):t.name,c=a(n,o);let g;if(d){const r=l(e),s=l(e+i);g=zt(r,t.x,s-r,t.width,c,n,o)}else{const r=l(e+i),s=l(e);g=zt(t.x,r,t.width,s-r,c,n,o)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),e+=i}if(p>0&&u.length>n){const t=u.slice(n),e=t[0],i=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:d?(e.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return u}};class Un{constructor(t){this.rExtent=new Pt,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new _t(t.windowSize),this.getO=Ft(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>Dt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Pt)):(this.getR=Dt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Ft(t.stackBy),this.getGroup=Ft(t.groupBy),this.getColor=Ft(t.colorAccessor),this.getConnector=Ft(t.connectorAccessor),this.getDataId=Ft(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new _t(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=t.totalSize||t.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of t.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of t.inserts){const t=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(n)),this.pushValueExtent(n),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const n="function"==typeof e?e(t):t[e];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(t){const{config:e,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const i=n.toArray(),o=e.projection||"vertical",r=e.oExtent||this.resolveCategories(i),s=this.computeValueDomain(i,r),a="horizontal"===o,l="radial"===o,c=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===o?t.width:t.height):.1));let u,d;if(l){u=k().domain(r).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,i=e.innerRadius||0;d=v().domain(s).range([i,n])}else a?(u=k().domain(r).range([0,t.height]).padding(c),d=v().domain(s).range([0,t.width])):(u=k().domain(r).range([0,t.width]).padding(c),d=v().domain(s).range([t.height,0]));this.scales={o:u,r:d,projection:o},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((i,o)=>{var r;const s=this.rExtents[o];s.dirty&&s.recalculate(n,i);let[l,c]=s.extent;l===1/0&&(l=0,c=1);const u=null!==(r=e.extentPadding)&&void 0!==r?r:.05,d=c-l,h=d>0?d*u:1;return l-=h,c+=h,l>0&&(l=0),a?v().domain([l,c]).range([0,t.width]):v().domain([l,c]).range([t.height,0])}):[];let h=i;this.rAccessors.length>1&&(h=i.flatMap(t=>this.rAccessors.map((e,n)=>Object.assign(Object.assign({},t),{__rIndex:n,__rValue:e(t),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(h,r,u,o,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(h,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,n=Array.isArray(e)?e[t]:e;return"string"==typeof n?n:"value"+t}resolveCategories(t){const e=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===e?void 0:e;let o=null;if(n){o=new Set;for(const e of t)o.add(this.getO(e))}const r=o?Array.from(this.categories).filter(t=>o.has(t)):Array.from(this.categories);if(n&&void 0===i){const t=Math.max(50,3*o.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;o.has(t)||(this.categories.delete(t),e--)}}return r}if(!1===i)return r;if("function"==typeof i)return r.sort(i);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return r.sort("asc"===i?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var n,i,o,r,s;const a=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,n=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);0>o?n.set(t,(n.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t);for(const t of n.values())c>t&&(c=t)}else if("bar"===a){const e=new Map;for(const n of t){const t=this.getO(n),i=this.getR(n);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t),c>t&&(c=t)}else if("swimlane"===a){const e=new Map;for(const n of t){const t=this.getO(n),i=Math.abs(this.getR(n));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),c>t&&(c=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(c=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[0])&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const t=u-c,e=t>0?t*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[c,u]}buildColumns(t,e,n,i,o){var r;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let l=0;if("radial"===i)for(const e of t)l+=Math.abs(this.getR(e));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==i){u=new Map;let t=0;for(const n of e){const e=a.get(n)||[];let i;i="string"==typeof c?e.reduce((t,e)=>t+(Number(e[c])||0),0):c(e),u.set(n,i),t+=i}const r=("horizontal"===i?o.height:o.width)-n.padding()*n.step()*e.length;if(t>0)for(const[e,n]of u)u.set(e,n/t*r)}let d=0,h=0;for(const t of e){const e=a.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),o=l>0?i/l:0;let c,f;u?(c=h,f=u.get(t)||n.bandwidth(),h+=f+n.padding()*n.step()):(c=null!==(r=n(t))&&void 0!==r?r:0,f=n.bandwidth()),s[t]={name:t,x:c,y:0,width:f,middle:c+f/2,padding:n.padding()*n.step(),pieceData:e,pct:o,pctStart:d},d+=o}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){var n,i;if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(t,e);let r;try{r=this.config.customLayout(o)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(n=r.overlays)&&void 0!==n?n:null,null!==(i=r.nodes)&&void 0!==i?i:[]}this.customLayoutOverlays=null;const o=this.getSceneContext(),r=Vn[this.config.chartType];let s=r?r(o,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var n,i;const{scales:o,config:r,getConnector:s,getO:a}=t;if(!s||!o)return[];const l=[],{projection:c}=o,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const n=s(e);if(!n)continue;let i,o;"point"===t.type?(i=t.x,o=t.y):(i=t.x+t.w/2,o=t.y+("vertical"===c?0:t.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:i,y:o,datum:e,category:a(e)})}const d=o.o.domain(),h=r.connectorStyle;for(const[e,o]of u)if(o.length>=2){o.sort((t,e)=>d.indexOf(t.category)-d.indexOf(e.category));for(let r=0;o.length-1>r;r++){const s=o[r],a=o[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(n=t.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:e})}}return l}(o,s);s=[...t,...s]}return s}buildLayoutContext(t,e){var n,i,o;const r=this.config,s=null!==(n=r.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},a=Gn(r.colorScheme,r.themeCategorical,ie),l=this.scales;return{data:t,scales:{o:l.o,r:l.r,projection:l.projection},dimensions:{width:e.width,height:e.height,margin:s,plot:"radial"===l.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(i=r.themeSemantic)&&void 0!==i?i:{},categorical:[...a]},resolveColor:Hn(a),config:null!==(o=r.layoutConfig)&&void 0!==o?o:{}}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(t,e);return n&&!n.fill&&e?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(e)}):n}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ie,i=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,i),i}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const n=this.config.decay;return n&&e>1?ae(n,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,n="function"==typeof e,i=n?null:e||"category",o=new Map;for(let r=0;t.length>r;r++){const s=t[r],a=n?e(s):s[i];let l=o.get(a);l||(l=[],o.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:o},o}rebuildPointQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,Un.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const n=Array(t);let i=0;for(const t of this.scene)"point"===t.type&&(n[i++]=t);this._pointQuadtree=w().x(t=>t.x).y(t=>t.y).addAll(n)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var n,i;if(!this.config.decay)return;const o=e.length;if(1>=o)return;const r=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=r.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,o),a=null!==(i=null===(n=e.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var n,i,o;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(i=this.config.pulse.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(o=this.config.pulse.glowRadius)&&void 0!==o?o:4,c=this.getDatumIndexMap(e);let u=null;for(const n of t){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const t=n.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const i=u.get(t);if(!i)continue;let o=0;for(let t=0;i.length>t;t++){const e=this.timestampBuffer.get(i[t]);if(null==e)continue;const n=r-e;if(s>n){const t=1-n/s;t>o&&(o=t)}}o>0&&(n._pulseIntensity=o,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const i=this.timestampBuffer.get(t);if(null==i)continue;const o=r-i;s>o&&(n._pulseIntensity=1-o/s,n._pulseColor=a,n._pulseGlowRadius=l)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),n=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,i=this.timestampBuffer.peek();return null!=i&&n>e-i}synthesizeIntroPositions(){var t,e,n,i,o;this.prevPositionMap.clear();const r=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(n=this.scales)||void 0===n?void 0:n.projection);let l;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],n=this.getNodeKey(e,r);n&&("rect"===e.type?this.prevPositionMap.set(n,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}):"point"===e.type?this.prevPositionMap.set(n,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===l&&(l=e.startAngle),this.prevPositionMap.set(n,{x:e.cx,y:e.cy,startAngle:l,endAngle:l,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var n,i,o;if("point"===t.type){const n=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,i=e.get(n)||0;return e.set(n,i+1),`${n}:${i}`}return"rect"===t.type?`r:${t.group||""}:${null!==(i=null===(n=t.datum)||void 0===n?void 0:n.category)&&void 0!==i?i:""}`:"wedge"===t.type?"w:"+(null!==(o=t.category)&&void 0!==o?o:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let n=0;this.scene.length>n;n++){const i=this.scene[n],o=this.getNodeKey(i,e);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"wedge"===i.type&&this.prevPositionMap.set(o,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:null!==(t=i.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,n,i,o,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let w=!1;const A=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const c=this.scene[t],u=this.getNodeKey(c,S);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(e=c.style.opacity)&&void 0!==e?e:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(i=c.style.opacity)&&void 0!==i?i:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(o=d.w)&&void 0!==o?o:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const t=c.startAngle;c.startAngle=t,c.endAngle=t,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:t,endAngle:t,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!A.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(c=e.r)&&void 0!==c?c:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(d=e.w)&&void 0!==d?d:0,h:null!==(h=e.h)&&void 0!==h?h:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const n=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(p=e.endAngle)&&void 0!==p?p:0))/2,i={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(y=e.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=e.startAngle)&&void 0!==v?v:0,endAngle:null!==(b=e.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=e.opacity)&&void 0!==x?x:1},datum:null,category:t.slice(2),_targetStartAngle:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(i)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:he(),duration:k})}advanceTransition(t){var e,n,i,o;if(!this.activeTransition)return!1;const r=ue(t,this.activeTransition),s=ce(r,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=de(o,t._targetOpacity,s)}const i=this.prevPositionMap.get(e);void 0!==t._targetX&&i&&(t.x=de(i.x,t._targetX,s),t.y=de(i.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==i?void 0:i.r)&&(t.r=de(i.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;t.style.opacity=de(o,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=de(n.x,t._targetX,s),t.y=de(n.y,t._targetY,s),void 0!==n.w&&(t.w=de(n.w,t._targetW,s),t.h=de(n.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const n=this.prevPositionMap.get(e),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:de(i,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const n=this.prevPositionMap.get(e);n&&void 0!==n.startAngle&&(t.startAngle=de(n.startAngle,t._targetStartAngle,s),t.endAngle=de(n.endAngle,t._targetEndAngle,s))}}}if(r>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),n=this.getDataId,i=t=>e.has(n(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,n)=>{i(t)&&e.add(n)}),this.timestampBuffer.clear();for(let n=0;t.length>n;n++)e.has(n)||this.timestampBuffer.push(t[n])}const o=this.buffer.remove(i);if(0===o.length)return o;for(const t of o)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,o}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=new Set;this.buffer.forEach((t,e)=>{n.has(i(t))&&o.add(e)});const r=this.buffer.update(t=>n.has(i(t)),e);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),o.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!Et(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!Et(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!Et(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(Et(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=Ft(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const n=t.valueAccessor||t.rAccessor,i=e.valueAccessor||e.rAccessor,o=Array.isArray(n)?n:[n],r=Array.isArray(i)?i:[i];if(o.length!==r.length||o.some((t,e)=>!Et(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>Dt(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Pt)):(this.getR=Dt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!Et(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?Ft(this.config.stackBy):void 0),"groupBy"in t&&!Et(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?Ft(this.config.groupBy):void 0),"colorAccessor"in t&&!Et(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Ft(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!Et(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Ft(this.config.connectorAccessor):void 0)}}Un.QUADTREE_THRESHOLD=500;const Zn={mercator:mt,equalEarth:ht,albersUsa:yt,orthographic:pt,naturalEarth:gt,equirectangular:ft};function Qn(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Kn(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Jn(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function ti(t,e){if(2>t.length)return[t];const n=.4*e,i=[];let o=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>o.length||i.push(o),o=[r]):o.push(r)}return 2>o.length||i.push(o),i}function ei(t,e,n=24){const i=e[0]-t[0],o=e[1]-t[1],r=Math.sqrt(i*i+o*o);if(0===r)return[t,e];const s=-o/r,a=i/r,l=Math.min(.3*r,80),c=(t[0]+e[0])/2+s*l,u=(t[1]+e[1])/2+a*l,d=[];for(let i=0;n>=i;i++){const o=i/n,r=1-o;d.push([r*r*t[0]+2*r*o*c+o*o*e[0],r*r*t[1]+2*r*o*u+o*o*e[1]])}return d}function ni(t,e){if(2>t.length)return t;const n=e/2+1,i=[];for(let e=0;t.length>e;e++){const o=t[e];let r,s;0===e?(r=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(r=o[0]-t[e-1][0],s=o[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;i.push([o[0]+s/a*n,o[1]+-r/a*n])}return i}function ii(t,e,n,i,o){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const l=s/a,c=-r/a,u=o/2+1;return[[t[0]+l*u,t[1]+c*u],[e[0]+l*u,e[1]+c*u]]}class oi{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t.slice()}initStreaming(t=500){this.pointBuffer=new _t(t),this.timestampBuffer=new _t(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const n of t)this.pointBuffer.push(n),this.timestampBuffer.push(e);this.lastIngestTime=e}pushLine(t){null!=t&&"object"==typeof t&&(this.lineData.push(t),this.version++)}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return;const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){for(const t of e)this.lineData.push(t);this.version++}}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]),o=[];return this.lineData=this.lineData.filter(t=>!i.has(n(t)+"")||(o.push(t),!1)),o.length>0&&this.version++,o}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(n(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((e,i)=>{t(e)&&n.add(i)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)n.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!i.has(n(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return ht();if("string"==typeof t){const e=Zn[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),ht())}if("object"==typeof t&&"type"in t){const e=Zn[t.type],n=e?e():ht();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=lt(this.projection),this.fitProjection(t),this.geoPath=lt(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null};const i=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,i=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&i.length>0&&this.startTransition(i),this.version++}fitProjection(t){var e,n,i,o,r;const s=this.projection,a=this.config,l=[...this.areas],c=Qn(a.xAccessor,"lon"),u=Qn(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const t=d.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const h=Kn(a.lineDataAccessor);for(const t of this.lineData){const e=h(t);if(e&&e.length>0){const t=e.map(t=>[c(t),u(t)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==l.length){if(a.projectionExtent){const[[e,n],[i,o]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,n],[i,n],[i,o],[e,o],[e,n]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(n=a.fitPadding)&&void 0!==n?n:0,i=Math.min(t.width,t.height);s.scale(i/2-i*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,n=t.width*e,o=t.height*e;s.fitExtent([[n,o],[t.width-n,t.height-o]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(r=null===(o=s.rotate)||void 0===o?void 0:o.call(s))&&void 0!==r?r:[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=lt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;n&&(n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=lt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;n&&n.rotate&&(n.rotate(t),this.geoPath=lt(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,n;return null!==(n=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const n of this.scene)"point"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxPointRadius=t,oi.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const n=Array(e);let i=0;for(const t of this.scene)"point"===t.type&&(n[i++]=t);this._quadtree=w().x(t=>t.x).y(t=>t.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,n,i;const o=[],{config:r}=this,s=this.projection,a=this.geoPath,l=Qn(r.xAccessor,"lon"),c=Qn(r.yAccessor,"lat"),u=function(t){var e,n;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(n=t.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(r),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),h=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(r);if(r.graticule){const e=!0===r.graticule?{}:r.graticule,n=ct();e.step&&n.step(e.step);const i=a(n())||"";i&&o.push({type:"geoarea",pathData:i,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const n=a.centroid(t),i=a.bounds(t),s=a.area(t),l=Jn(r.areaStyle,t,u);o.push({type:"geoarea",pathData:e,centroid:n,bounds:i,screenArea:s,style:l,datum:t,interactive:!0})}const f=Kn(r.lineDataAccessor);for(const e of this.lineData){const n=f(e);if(!n||2>n.length)continue;let i=[];if("geo"===r.lineType){const t=Array(n.length);for(let e=0;n.length>e;e++)t[e]=[l(n[e]),c(n[e])];for(let e=0;t.length-1>e;e++){const n=t[e],o=t[e+1],r=ut(n,o)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=dt(n,o);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const n=s(l(t/a));null!=n&&i.push(n)}}}else for(let t=0;n.length>t;t++){const e=n[t],o=s([l(e),c(e)]);null!=o&&i.push(o)}if(2>i.length)continue;const a=Jn(r.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==n.length||2>i.length||"arc"!==r.flowStyle?2!==n.length||2>i.length||"offset"!==r.flowStyle||(i="geo"===r.lineType?ni(i,u):ii(i[0],i[i.length-1],0,0,u)):i=ei(i[0],i[i.length-1]);const h=ti(i,t.width);if(h.length>1)for(const t of h){if(2>t.length)continue;const n={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};o.push(n)}else o.push({type:"line",path:2>i.length&&h[0]||i,style:a,datum:e})}const g=this.getPoints(),p=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,y=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,m=y>0?y*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],x=[(null!==(n=b[0])&&void 0!==n?n:0)-v[0],(null!==(i=b[1])&&void 0!==i?i:0)-v[1]];for(let t=0;g.length>t;t++){const e=g[t],n=l(e),i=c(e);if(null!=m&&ut([n,i],x)>m)continue;const a=s([n,i]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},h),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};o.push(d)}return o}applyCartogramTransform(t,e){var n,i,o;const r=this.scene.filter(t=>"point"===t.type);if(2>r.length)return;const s=null!==(n=t.strength)&&void 0!==n?n:1;if(0===s)return;const a=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&a(e.datum)+""==t.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const u=c.x,d=c.y,h=r.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),f=Math.max(...h,1),g=Math.min(e.width,e.height)/2,p=v().domain([0,f]).range([0,g]);this.cartogramLayout={cx:u,cy:d,maxCost:f,availableRadius:g},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of r){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-u),n=Math.sqrt(Math.pow(t.x-u,2)+Math.pow(t.y-d,2)),i=l(t.datum),o=n+((isFinite(i)?p(i):n)-n)*s;t.x=u+Math.cos(e)*o,t.y=d+Math.sin(e)*o}const y=e.width/2,m=e.height/2,b=y-c.x,x=m-c.y;if(Math.abs(b)>.5||Math.abs(x)>.5)for(const t of r)t.x+=b,t.y+=x;this.cartogramLayout={cx:y,cy:m,maxCost:f,availableRadius:g};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of r)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const n=null===(i=e.datum)||void 0===i?void 0:i.source,r=null===(o=e.datum)||void 0===o?void 0:o.target;if(n&&r){const i=t.get(n+""),o=t.get(r+"");i&&o&&(e.path=[i,o])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let i=0;n.length>i;i++){const o=ae(t,i,e);n[i]._decayOpacity=o,n[i].style=Object.assign(Object.assign({},n[i].style),{opacity:o})}}applyPulse(){var t,e;const n=this.config.pulse;if(!n||!this.timestampBuffer)return;const i=null!==(t=n.duration)&&void 0!==t?t:500,o=performance.now(),r=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;r.length>t&&s.length>t;t++){const a=o-s[t];i>a&&(r[t]._pulseIntensity=1-a/i,r[t]._pulseColor=n.color||"rgba(255,255,255,0.6)",r[t]._pulseGlowRadius=null!==(e=n.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const n=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,i=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-i<n}startTransition(t){var e,n;const i=null!==(n=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==n?n:300;if(0>=i)return;const o=new Map;for(const e of t)"point"===e.type&&e.pointId&&o.set(e.pointId,[e.x,e.y]);const r=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of r)if(t.pointId){const e=o.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:i})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=ue(t,this.activeTransition),n=ce(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=de(t.x,t._targetX,n),t.y=de(e,t._targetY,n)}if(e>=1){for(const t of i)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function ri(t){var e,n,i,o;return(null!==(e=t.tl)&&void 0!==e?e:0)>0||(null!==(n=t.tr)&&void 0!==n?n:0)>0||(null!==(i=t.br)&&void 0!==i?i:0)>0||(null!==(o=t.bl)&&void 0!==o?o:0)>0}function si(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,i=t=>Math.max(0,Math.min(null!=t?t:0,n));return{tl:i(e.tl),tr:i(e.tr),br:i(e.br),bl:i(e.bl)}}oi.QUADTREE_THRESHOLD=500;const ai=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function li(t){var e,n;const{innerRadius:i,outerRadius:o,startAngle:r,endAngle:s}=t,a=0>=i;if(0>=(null!==(e=t.cornerRadius)&&void 0!==e?e:0)||!t.roundStart&&!t.roundEnd){if(a){const t=ai(o,r),e=ai(o,s);return`M0,0 L${t.x},${t.y} A${o},${o} 0 ${s-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=ai(o,r),e=ai(o,s),n=ai(i,s),l=ai(i,r),c=s-r>Math.PI?1:0;return`M${t.x},${t.y} A${o},${o} 0 ${c} 1 ${e.x},${e.y} L${n.x},${n.y} A${i},${i} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=t.cornerRadius)&&void 0!==n?n:0,(o-i)/2));if(0===l)return li(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,o-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,i+l))),d=s-r,h=t.roundStart&&t.roundEnd?d/2:d,f=!!t.roundStart&&h>c,g=!!t.roundEnd&&h>c;if(!f&&!g)return li(Object.assign(Object.assign({},t),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const p=r+(f?c:0),y=s-(g?c:0),m=r+(f?u:0),v=s-(g?u:0),b=ai(o,p),x=ai(o,y),k=(o-l)*Math.cos(c),w=ai(k,r),A=ai(k,s),S=a?null:ai(i,v),M=a?null:ai(i,m),_=a?0:(i+l)*Math.cos(u),P=a?null:ai(_,r),O=a?null:ai(_,s),T=y-p>Math.PI?1:0,$=a?0:v-m>Math.PI?1:0;let L="";if(f)L+=`M${w.x},${w.y}`,L+=` A${l},${l} 0 0 1 ${b.x},${b.y}`;else{const t=ai(o,r);L+=`M${t.x},${t.y}`}if(g)L+=` A${o},${o} 0 ${T} 1 ${x.x},${x.y}`,L+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const t=ai(o,s);L+=` A${o},${o} 0 ${T} 1 ${t.x},${t.y}`}if(a)L+=" L0,0";else{if(g)L+=` L${O.x},${O.y}`,L+=` A${l},${l} 0 0 1 ${S.x},${S.y}`;else{const t=ai(i,s);L+=` L${t.x},${t.y}`}if(f)L+=` A${i},${i} 0 ${$} 0 ${M.x},${M.y}`,L+=` A${l},${l} 0 0 1 ${P.x},${P.y}`;else{const t=ai(i,r);L+=` A${i},${i} 0 ${$} 0 ${t.x},${t.y}`}}return L+=" Z",L}const ci={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ui(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function di(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function hi(n,i,o){var r,s,a,l,c;switch(n.type){case"line":{const e=n;if(0===e.path.length)return null;const o="M"+e.path.map(([t,e])=>`${t},${e}`).join("L");return t("path",{d:o,fill:"none",stroke:e.style.stroke||"#4e79a7",strokeWidth:e.style.strokeWidth||2,strokeDasharray:e.style.strokeDasharray,opacity:e.style.opacity},"line-"+i)}case"area":{const c=n;if(0===c.topPath.length)return null;const u=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const n=`${o?o+"-":""}area-clip-${i}`;return e("g",{children:[t("defs",{children:t("clipPath",{id:n,children:t("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t("path",{d:u,fill:ui(c.style.fill),fillOpacity:null!==(s=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==s?s:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${n})`})]},"area-"+i)}return t("path",{d:u,fill:ui(c.style.fill),fillOpacity:null!==(l=null!==(a=c.style.fillOpacity)&&void 0!==a?a:c.style.opacity)&&void 0!==l?l:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+i)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:ui(e.style.fill),opacity:null!==(c=e.style.opacity)&&void 0!==c?c:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"point-"+i)}case"rect":{const e=n;return t("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:ui(e.style.fill),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=n;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const n=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,s,a]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),l=.299*r+.587*s+.114*a>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e("g",{children:[t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:l,fontSize:c+"px",children:n})]},"heatcell-"+i)}return t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=n,r=Math.min(o.openY,o.closeY),s=Math.max(Math.abs(o.openY-o.closeY),1),a=o.isUp?o.upColor:o.downColor;return e("g",{children:[t("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:s,fill:a,stroke:a,strokeWidth:1})]},"candle-"+i)}default:return null}}function fi(n,o,r){var s,a,l,c,u,d,h,f,g;const p=("category"in n?n.category:void 0)||("group"in n?n.group:void 0)||"",y=t=>`ord-${n.type}-${p}-${o}-${t}`,m=`ord-${n.type}-${p}-${o}`;switch(n.type){case"rect":{const o=n,r=di(m)+"-grad",s=function(e,n){const i=e.fillGradient;if(!i)return null;let o=e.x,r=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,a=e.y):"right"===e.roundedEdge?(o=e.x+e.w,r=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(o=e.x,r=e.y,s=e.x+e.w,a=e.y);const l=[];if("colorStops"in i){const e=i.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let n=0;e.length>n;n++)l.push(t("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=ui(e.style.fill);l.push(t("stop",{offset:0,stopColor:n,stopOpacity:i.topOpacity},"0")),l.push(t("stop",{offset:1,stopColor:n,stopOpacity:i.bottomOpacity},"1"))}return t("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:s,y2:a,children:l})}(o,r),a=s?`url(#${r})`:ui(o.style.fill);if(o.cornerRadii&&ri(o.cornerRadii)){const n=function(t){const{x:e,y:n,w:i,h:o}=t,{tl:r,tr:s,br:a,bl:l}=si(t);let c=`M${e+r},${n}`;return c+=` L${e+i-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+i},${n+s}`),c+=` L${e+i},${n+o-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+i-a},${n+o}`),c+=` L${e+l},${n+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+o-l}`),c+=` L${e},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${e+r},${n}`),c+=" Z",c}(o);return e(i.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:n,fill:a,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}if(o.roundedTop&&o.roundedTop>0){const n=Math.min(o.roundedTop,o.w/2,o.h/2),{x:r,y:l,w:c,h:u}=o;let d;switch(o.roundedEdge){case"right":d=`M${r},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r},${l+u} Z`;break;case"left":d=`M${r+c},${l} L${r+n},${l} A${n},${n} 0 0 0 ${r},${l+n} L${r},${l+u-n} A${n},${n} 0 0 0 ${r+n},${l+u} L${r+c},${l+u} Z`;break;case"bottom":d=`M${r},${l} L${r+c},${l} L${r+c},${l+u-n} A${n},${n} 0 0 1 ${r+c-n},${l+u} L${r+n},${l+u} A${n},${n} 0 0 1 ${r},${l+u-n} Z`;break;default:d=`M${r},${l+u} L${r},${l+n} A${n},${n} 0 0 1 ${r+n},${l} L${r+c-n},${l} A${n},${n} 0 0 1 ${r+c},${l+n} L${r+c},${l+u} Z`}return e(i.Fragment,{children:[s&&t("defs",{children:s}),t("path",{d:d,fill:a,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}return e(i.Fragment,{children:[s&&t("defs",{children:s}),t("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:a,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}case"point":{const e=n;return t("circle",{cx:e.x,cy:e.y,r:e.r,fill:ui(e.style.fill),opacity:null!==(s=e.style.opacity)&&void 0!==s?s:.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},m)}case"wedge":{const i=n;if(i._gradientBand&&i._gradientBand.colors.length>0){const n=di(`${r?r+"-":""}gauge-grad-${i.category||m}-${o}`),{clipPath:s,slices:d}=function(t){const e=li({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],i=t.colors;if(i.length>0){const e=(t.endAngle-t.startAngle)/i.length;for(let o=0;i.length>o;o++)n.push({d:li({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+o*e,endAngle:t.endAngle}),color:i[o]})}return{clipPath:e,slices:n}}({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:null===(l=null===(a=i.roundedEnds)||void 0===a?void 0:a.start)||void 0===l||l,roundEnd:null===(u=null===(c=i.roundedEnds)||void 0===c?void 0:c.end)||void 0===u||u,colors:i._gradientBand.colors});return e("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[t("defs",{children:t("clipPath",{id:n,children:t("path",{d:s})})}),t("g",{clipPath:`url(#${n})`,children:d.map((e,n)=>t("path",{d:e.d,fill:ui(e.color)},n))}),i.style.stroke&&"none"!==i.style.stroke&&t("path",{d:s,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},m)}let s;if(i.roundedEnds)s=li({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const t=B().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&t.cornerRadius(i.cornerRadius),s=t(ci)||""}return t("path",{d:s,transform:`translate(${i.cx},${i.cy})`,fill:ui(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},m)}case"boxplot":{const i=n,o=i.columnWidth/2;return e("g","vertical"===i.projection?{children:[t("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:ui(i.style.fill),fillOpacity:null!==(d=i.style.fillOpacity)&&void 0!==d?d:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})]}:{children:[t("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:ui(i.style.fill),fillOpacity:null!==(h=i.style.fillOpacity)&&void 0!==h?h:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1})]},m)}case"violin":{const e=n,i=[t("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:ui(e.style.fill),fillOpacity:null!==(f=e.style.fillOpacity)&&void 0!==f?f:.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},y("path"))];if(e.iqrLine&&e.bounds){const n=e.bounds,o=n.x+n.width/2,r=n.y+n.height/2;n.height>n.width?i.push(t("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},y("iqr")),t("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},y("med"))):i.push(t("line",{x1:e.iqrLine.q1Pos,y1:r,x2:e.iqrLine.q3Pos,y2:r,stroke:e.style.stroke||"#333",strokeWidth:2},y("iqr")),t("circle",{cx:e.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},y("med")))}return t("g",{children:i},m)}case"connector":return t("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:null!==(g=n.style.opacity)&&void 0!==g?g:.5},m);case"trapezoid":{const e=n,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t("polygon",{points:i,fill:ui(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},m)}default:return null}}const gi="undefined"==typeof window||"undefined"==typeof document;function pi(e){let n=null;const i=()=>(n||(n=c(null)),n),u=yi(e);return[function({children:n,initialState:s}){const a=o(s),l=r(()=>yi(e,a.current),[]),c=i();return t(c.Provider,{value:l,children:n})},t=>{var e;const n=i(),r=null!==(e=s(n))&&void 0!==e?e:u,c=o(t);c.current=t;const d=a(()=>c.current(r.getState()),[r]),h=a(()=>c.current(r.getState()),[r]);return l(r.subscribe,d,h)}]}function yi(t,e){const n=new EventTarget;let i=Object.assign(Object.assign({},t(function(t){i=Object.assign(Object.assign({},i),t(i)),n.dispatchEvent(new Event("update"))})),null!=e?e:{});return{getState:()=>i,subscribe:function(t){return n.addEventListener("update",t),()=>n.removeEventListener("update",t)}}}function mi(t){if(!(null==t?void 0:t.colors))return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function vi(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:bi})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const bi=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],xi={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},ki={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},wi={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:bi,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Ai(t,e){if("light"===e)return xi;if("dark"===e)return ki;if("high-contrast"===e)return wi;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?ki:xi;return vi(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}return vi(Object.assign(Object.assign(Object.assign({},t),e),{colors:Object.assign(Object.assign({},t.colors),e.colors||{}),typography:Object.assign(Object.assign({},t.typography),e.typography||{})}))}const[Si,Mi]=pi(t=>({theme:xi,setTheme(e){t(t=>({theme:Ai(t.theme,e)}))}})),_i={light:xi,dark:ki,"high-contrast":wi,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Pi(t){if(!t)return xi;if("string"==typeof t){if("light"===t)return xi;if("dark"===t)return ki;if("high-contrast"===t)return wi;return _i[t]||xi}const e="dark"===t.mode?ki:xi;return vi(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{}),tooltip:Object.assign(Object.assign({},e.tooltip),t.tooltip||{})}))}function Oi(t){var e,n,i,o;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(n=t.typography.legendSize)&&void 0!==n?n:t.typography.labelSize,titleFontSize:null!==(i=t.typography.titleFontSize)&&void 0!==i?i:t.typography.titleSize,tickFontFamily:null!==(o=t.typography.tickFontFamily)&&void 0!==o?o:t.typography.fontFamily}}function Ti(t){return"left"===t?"start":"right"===t?"end":null!=t?t:"start"}function $i(t){var e,n;return Number(null!==(n=null!==(e=t.typography.legendSize)&&void 0!==e?e:t.typography.labelSize)&&void 0!==n?n:t.typography.tickSize)||11}function Li(t,e,n,i){const o=$i(i);return e+n+Math.ceil(t.length*o*.58)}function ji(t){var e,n,i,o,r;const{categories:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),p=Math.max(0,null!==(i=null==h?void 0:h.itemGap)&&void 0!==i?i:8),y=Math.max(f,null!==(o=null==h?void 0:h.rowHeight)&&void 0!==o?o:20),m=f+g,v=Math.min(2,f/2),b="top"===l||"bottom"===l,x=Math.max(f,c-d.left-d.right),k=Math.max(y,u-d.top-d.bottom),w=s.map(t=>Li(t,f,g,a));if(b){const t=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:x),e=[];let n=0,i=0;w.forEach((o,r)=>{const s=0===i?o:i+p+o;i>0&&s>t?(e.push({start:n,end:r,width:i}),n=r,i=o):i=s}),s.length>0&&e.push({start:n,end:s.length,width:i});const o=Ti(null==h?void 0:h.align),a=[];return e.forEach((e,n)=>{let i="center"===o?Math.max(0,(t-e.width)/2):"end"===o?Math.max(0,t-e.width):0;for(let t=e.start;e.end>t;t++)a.push({category:s[t],width:w[t],x:i,y:n*y}),i+=w[t]+p}),{items:a,width:Math.max(0,...e.map(t=>t.width)),height:e.length*y,swatchSize:f,labelOffset:m,swatchRadius:v}}const A=Math.max(0,...w),S=Math.max(1,Math.floor(k/y)),M=Math.max(1,Math.ceil(s.length/S));return{items:s.map((t,e)=>({category:t,width:w[e],x:Math.floor(e/S)*(A+p),y:e%S*y})),width:M*A+Math.max(0,M-1)*p,height:Math.min(s.length,S)*y,swatchSize:f,labelOffset:m,swatchRadius:v}}function zi(t){var e,n,i,o,r;const{legendGroups:s,theme:a,position:l="right",totalWidth:c,totalHeight:u,margin:d,legendLayout:h}=t,f=Math.max(1,null!==(e=null==h?void 0:h.swatchSize)&&void 0!==e?e:14),g=Math.max(0,null!==(n=null==h?void 0:h.labelGap)&&void 0!==n?n:6),p=Math.max(0,null!==(i=null==h?void 0:h.itemGap)&&void 0!==i?i:8),y=Math.max(f,null!==(o=null==h?void 0:h.rowHeight)&&void 0!==o?o:20),m=f+g,v=Math.min(2,f/2),b=Math.max(12,$i(a)),x="top"===l||"bottom"===l,k=Math.max(f,c-d.left-d.right),w=Math.max(y,u-d.top-d.bottom);if(x){const e=Math.max(f,null!==(r=null==h?void 0:h.maxWidth)&&void 0!==r?r:k),n=Ti(null==h?void 0:h.align);let i=0,o=0;const l=[];for(const n of s){const r=n.items.map(t=>t.label),s=ji(Object.assign(Object.assign({},t),{categories:r,legendLayout:Object.assign(Object.assign({},h),{maxWidth:Math.max(f,e-b-8),align:"start"})})),c=n.label?b:0,u=n.label?Li(n.label,0,0,a):0,d=c>0?c+8:0,g=d+s.width,p=Math.max(s.height,u);l.push({group:n,x:i,y:0,itemOffsetX:d,itemOffsetY:0,width:g,height:p,items:s.items}),i+=g+12,o=Math.max(o,p)}const c=l.length>0?i-12:0,u=c>e?0:"center"===n?Math.max(0,(e-c)/2):"end"===n?Math.max(0,e-c):0;return{groups:l.map(t=>Object.assign(Object.assign({},t),{x:t.x+u})),width:c,height:o,swatchSize:f,labelOffset:m,swatchRadius:v}}let A=0,S=0;const M=[];for(const t of s){const e=t.items.map(t=>t.label).map(t=>Li(t,f,g,a)),n=Math.max(0,...e),i=Math.max(1,Math.min(t.items.length||1,Math.max(1,Math.floor(Math.max(y,w-A)/y)))),o=Math.max(1,Math.ceil(t.items.length/i)),r=t.items.map((t,o)=>({category:t.label,width:e[o],x:Math.floor(o/i)*(n+p),y:o%i*y})),s=o*n+Math.max(0,o-1)*p,l=Math.min(t.items.length,i)*y,c=t.label?Li(t.label,0,0,a):0,u=t.label?b+8:0,d=u+l+12,h=Math.max(s,c);M.push({group:t,x:0,y:A,itemOffsetX:0,itemOffsetY:u,width:h,height:d,items:r}),S=Math.max(S,h),A+=d}return{groups:M,width:S,height:Math.max(0,A),swatchSize:f,labelOffset:m,swatchRadius:v}}function Ci(t){var e,n;return"top"===t.position||"bottom"===t.position?{width:Math.min(null!==(n=null===(e=t.legendLayout)||void 0===e?void 0:e.maxWidth)&&void 0!==n?n:Math.max(1,t.totalWidth-t.margin.left-t.margin.right),200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function Ei(n){const{categories:i,colorScheme:o,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=n;if(!i||0===i.length)return null;const d=function(t,e,n){const i=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:It;return m().domain(t).range(i)}(i,o,r),h="top"===s||"bottom"===s,f=ji(n);let g,p;if("left"===s?(g=Math.max(4,c.left-f.width-10),p=c.top):"top"===s?(g=c.left,p=u?32:8):"bottom"===s?(g=c.left,p=Math.min(l-c.bottom+38,l-f.height-2)):(g=Math.min(a-f.width-4,a-c.right+10),p=c.top),h){const n=f.items.map((n,i)=>e("g",{transform:`translate(${n.x},${n.y})`,children:[t("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(n.category),rx:f.swatchRadius}),t("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:$i(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n.category})]},"legend-"+i));return t("g",{className:"semiotic-legend",transform:`translate(${g},${p})`,children:n})}const y=f.items.map((n,i)=>e("g",{transform:`translate(${n.x},${n.y})`,children:[t("rect",{width:f.swatchSize,height:f.swatchSize,fill:d(n.category),rx:f.swatchRadius}),t("text",{x:f.labelOffset,y:f.swatchSize/2,dominantBaseline:"central",fontSize:$i(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:n.category})]},"legend-"+i));return t("g",{className:"semiotic-legend",transform:`translate(${g},${p})`,children:y})}function Di(t,e){if(!e||!t||0===t.length)return[];const n="function"==typeof e?e:t=>t[e],i=new Set;for(const e of t){const t=n(e);null!=t&&i.add(t+"")}return Array.from(i)}function Ri(t,e){return t.color||e.colors.annotation||e.colors.text}function Fi(t,e,n){return null!=t.x&&e.x?e.x(t.x):n&&null!=t[n]&&e.x?e.x(t[n]):"number"==typeof t.x?t.x:null}function Ni(t,e,n){return null!=t.y&&e.y?e.y(t.y):n&&null!=t[n]&&e.y?e.y(t[n]):"number"==typeof t.y?t.y:null}function Bi(e){const{annotations:n}=e;if(!n||0===n.length)return null;const i=[];for(let t=0;n.length>t;t++){const o=Wi(n[t],t,e);o&&i.push(o)}return i.length>0?t("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:i}):null}function Wi(n,i,o){var r,s,a,l;const{scales:c,layout:u,theme:d,xAccessor:h,yAccessor:f}=o;switch(n.type){case"y-threshold":{const s=n.value;if(null==s)return null;const a=Ri(n,d),l=n.label,h=n.labelPosition||"right",f=n.strokeDasharray||"6,4",g=null!==(r=n.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const n=c.r(s);return null==n?null:e("g",{children:[t("line",{x1:n,y1:0,x2:n,y2:u.height,stroke:a,strokeWidth:g,strokeDasharray:f}),l&&t("text",{x:n+4,y:12,textAnchor:"start",fontSize:d.typography.tickSize,fill:a,fontFamily:d.typography.fontFamily,children:l})]},"ann-ythresh-"+i)}const p=c.y?c.y(s):c.r?c.r(s):null;return null==p?null:e("g",{children:[t("line",{x1:0,y1:p,x2:u.width,y2:p,stroke:a,strokeWidth:g,strokeDasharray:f}),l&&t("text",{x:"left"===h?4:"center"===h?u.width/2:u.width-4,y:p-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:d.typography.tickSize,fill:a,fontFamily:d.typography.fontFamily,children:l})]},"ann-ythresh-"+i)}case"x-threshold":{const o=n.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const a=Ri(n,d),l=n.label,h=n.labelPosition||"top",f=null!==(s=n.strokeWidth)&&void 0!==s?s:1.5;return e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:u.height,stroke:a,strokeWidth:f,strokeDasharray:n.strokeDasharray||"6,4"}),l&&t("text",{x:r+4,y:"bottom"===h?u.height-4:"center"===h?u.height/2:12,textAnchor:"start",fontSize:d.typography.tickSize,fill:a,fontFamily:d.typography.fontFamily,children:l})]},"ann-xthresh-"+i)}case"band":{const o=null!=n.y0&&c.y?c.y(n.y0):null,r=null!=n.y1&&c.y?c.y(n.y1):null;if(null==o||null==r)return null;const s=Math.min(o,r),l=Math.abs(r-o),h=n.fill||Ri(n,d),f=null!==(a=n.opacity)&&void 0!==a?a:.1;return e("g",{children:[t("rect",{x:0,y:s,width:u.width,height:l,fill:h,opacity:f}),n.label&&t("text",{x:u.width-4,y:s+12,textAnchor:"end",fontSize:d.typography.tickSize,fill:h,fontFamily:d.typography.fontFamily,children:n.label})]},"ann-band-"+i)}case"category-highlight":{if(!n.category||!c.o)return null;const e=c.o(n.category);if(null==e)return null;const r=c.o.bandwidth?c.o.bandwidth():40,s=Ri(n,d),a=null!==(l=n.opacity)&&void 0!==l?l:.1;return t("rect","horizontal"===o.projection?{x:0,y:e,width:u.width,height:r,fill:s,opacity:a}:{x:e,y:0,width:r,height:u.height,fill:s,opacity:a},"ann-cathighlight-"+i)}case"label":case"text":{const{x:o,y:r}=function(t,e,n,i){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const n=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:Fi(t,e,n),y:Ni(t,e,i)}}(n,c,h,f);if(null==o||null==r)return null;const s=n.dx||0,a=n.dy||0,l=n.color||d.colors.text;return e("g",{children:["label"===n.type&&t("line",{x1:o,y1:r,x2:o+s,y2:r+a,stroke:d.colors.textSecondary,strokeWidth:1}),t("text",{x:o+s,y:r+a,textAnchor:n.textAnchor||"start",fontSize:n.fontSize||d.typography.labelSize,fill:l,fontFamily:d.typography.fontFamily,fontWeight:n.fontWeight,children:n.label||n.title})]},"ann-label-"+i)}default:return null}}function Ii(t){return Math.max(0,Math.min(1,t))}function Yi(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const n=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const t=[Number(n[1]),Number(n[2]),Number(n[3])];if(t.every(Number.isFinite))return t}return null}function Gi(t,e,n){const i=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${i(t)}${i(e)}${i(n)}`}function Hi(t,e){const n=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Ii(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const i=Ii(e);if(n[0].offset>=i)return n[0].color;if(i>=n[n.length-1].offset)return n[n.length-1].color;for(let t=0;n.length-1>t;t++){const e=n[t],o=n[t+1];if(e.offset>i||i>o.offset)continue;const r=o.offset-e.offset,s=r>0?(i-e.offset)/r:0,a=Yi(e.color),l=Yi(o.color);if(!a||!l)return.5>s?e.color:o.color;const[c,u,d]=a,[h,f,g]=l;return Gi(c+(h-c)*s,u+(f-u)*s,d+(g-d)*s)}return n[n.length-1].color}function Xi(t,e,n){return`${t}-${e}`}function qi(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function Vi(t,e,n){const i=e.incoming[t.id],o=e.outgoing[t.id],r=[];for(const t of i)r.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:n.get(t.id).targetSide});for(const t of o)r.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:n.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((t,e)=>{var n,i;return t.time-e.time||(null!==(n=s[t.kind])&&void 0!==n?n:99)-(null!==(i=s[e.kind])&&void 0!==i?i:99)})},l=r.length?Math.min(...r.map(t=>t.time)):null,c=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(t=>t.time))].sort((t,e)=>t-e),h=new Map;for(let t=1;d.length>t;t++)h.set(d[t],d[t-1]);const f=t=>{const e=h.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const g=[];let p=0,y=0;for(const t of r)if("out"===t.kind){const e=Math.abs(t.delta);let n=e-("top"===t.side?p:y);if(n>0){const e="top"===t.side?"bot":"top",i=Math.min(n,"top"===e?p:y);if(i>0){const o=f(t.time);g.push({time:o,delta:-i,kind:"transfer-out",side:e}),g.push({time:o,delta:+i,kind:"transfer-in",side:t.side}),"top"===e?p-=i:y-=i,"top"===t.side?p+=i:y+=i,n-=i}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:t.side}),"top"===t.side?p+=n:y+=n)}"top"===t.side?p-=e:y-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?p+=e:y+=e}r.push(...g),a();let m=0,v=0,b=0,x=0,k=0;const w=[],A=new Map;for(const t of r){if(w.push({t:t.time,topMass:m,botMass:v}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:v;A.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:v+=t.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let M=0;for(;w.length>M;){let t=M;for(;w.length>t+1&&w[t+1].t===w[M].t;)t++;S.push(w[M]);for(let e=M+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[e])}M=t+1}const _=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of o)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let O=null;for(const t of i)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===O||t.systemOutTime>O)&&(O=t.systemOutTime);if(S.length>0){const t=S[S.length-1],e=Math.max(null!=_?_:-1/0,null!=O?O:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&S.push({t:e,topMass:t.topMass,botMass:t.botMass});const n=S[0],i=Math.min(null!=c?c:1/0,null!=P?P:1/0);Number.isFinite(i)&&n.t>i&&n.topMass+n.botMass>0&&S.unshift({t:i,topMass:n.topMass,botMass:n.botMass})}return{samples:S,peak:b,topPeak:x,botPeak:k,localAttachments:A}}function Ui(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Zi(t,e){return t.map(t=>({t:Ui(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Qi(t,e,n){const i=t.value*n;if("out"===t.kind){const o=t.sideMassBefore*n;if("top"===t.side){const t=e-o;return[t,t+i]}const r=e+o;return[r-i,r]}const o=t.sideMassAfter*n;if("top"===t.side){const t=e-o;return[t,t+i]}const r=e+o;return[r-i,r]}function Ki(t,e){let n=0;for(let i=0;e.length>i;i++)for(let o=i+1;e.length>o;o++){const r=e[i],s=e[o];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&t[s.source]>t[r.source]!=t[s.target]>t[r.target]&&n++)}return n}function Ji(t,e){let n=0;for(const i of e)n+=Math.abs(t[i.source]-t[i.target])*(i.value||1);return n}function to(t,e){return 1e3*Ki(t,e)+Ji(t,e)}function eo(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function no(t,e,n){t.length>8||n.length>40?(function(t,e,n,i=6){const o=t.length;if(1>=o)return;let r=eo(t,e),s=to(e,n);for(let a=0;i>a;a++){const i=Array(o).fill(0),a=Array(o).fill(0);for(const t of n){const n=e[t.source],o=e[t.target];i[n]+=o*(t.value||1),a[n]+=t.value||1,i[o]+=n*(t.value||1),a[o]+=t.value||1}const l=Array.from({length:o},(t,e)=>e).sort((t,e)=>(a[t]>0?i[t]/a[t]:t)-(a[e]>0?i[e]/a[e]:e)),c=l.map(e=>t[e]),u=new Map;l.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e);const d=to(e,n);if(s>d)s=d,r=eo(t,e);else if(d===s)break}!function(t,e,n){t.length=0;for(const e of n.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(n.map))e[t]=n.map[t]}(t,e,r)}(t,e,n,6),function(t,e,n,i=6){const o=t.length;if(1>=o)return;let r=to(e,n);for(let s=0;i>s;s++){let i=!1;for(let s=0;o-1>s;s++){const o=t[s];t[s]=t[s+1],t[s+1]=o;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=to(e,n);if(r>a)r=a,i=!0;else{const n=t[s];t[s]=t[s+1],t[s+1]=n;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!i)break}}(t,e,n,6)):function(t,e,n){const i=t.length;if(1>=i)return;const o=Object.assign({},e),r=Object.keys(o),s=Array.from({length:i},(t,e)=>e),a=s.slice(),l=Object.assign({},o);let c=s.slice(),u=1/0;const d=()=>{for(const t of r)l[t]=a[o[t]];const t=to(l,n);u>t&&(u=t,c=s.slice())},h=(t,e)=>{const n=s[t],i=s[e];s[t]=i,s[e]=n,a[n]=e,a[i]=t};d();const f=Array(i).fill(0);let g=0;for(;i>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const p=c.map(e=>t[e]),y=new Map;c.forEach((t,e)=>y.set(t,e));for(const t of Object.keys(e))e[t]=y.get(e[t]);t.length=0;for(const e of p)t.push(e)}(t,e,n)}function io(t,e,n,i,o){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:p,packing:y,laneOrder:m,lifetimeMode:v="full"}=o,b={},x={};for(const e of t)b[e.id]=n[e.id].topPeak||0,x[e.id]=n[e.id].botPeak||0;const k="half"===v,w={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,n=Array.isArray(e.xExtent)?e.xExtent[1]:null;let o=null!=t&&Number.isFinite(t)?t:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const t of i.outgoing[e.id]){o>t.startTime&&(o=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&o>t.systemInTime&&(o=t.systemInTime);const e=k?(t.startTime+t.endTime)/2:t.endTime;e>r&&(r=e)}for(const t of i.incoming[e.id]){const e=k?(t.startTime+t.endTime)/2:t.startTime;o>e&&(o=e),t.endTime>r&&(r=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>r&&(r=t.systemOutTime)}w[e.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(r)?r:null}}const A={},S=[];if("reuse"===y){const n=new Map;for(const e of t)n.set(e.id,0);const o=new Map;for(const e of t)o.set(e.id,0);for(const t of e)o.set(t.target,(null!==(r=o.get(t.target))&&void 0!==r?r:0)+1);const d=[];for(const e of t)0===(null!==(s=o.get(e.id))&&void 0!==s?s:0)&&d.push(e.id);for(;d.length;){const t=d.shift();for(const e of null!==(a=i.outgoing[t])&&void 0!==a?a:[]){const i=(null!==(l=n.get(t))&&void 0!==l?l:0)+1;i>(null!==(c=n.get(e.target))&&void 0!==c?c:0)&&n.set(e.target,i),o.set(e.target,o.get(e.target)-1),0===o.get(e.target)&&d.push(e.target)}}const h=[...t].filter(t=>null!==w[t.id].start).sort((t,e)=>{var i,o;const r=null!==(i=n.get(t.id))&&void 0!==i?i:0,s=null!==(o=n.get(e.id))&&void 0!==o?o:0;return r!==s?r-s:w[t.id].start-w[e.id].start}),f=t.filter(t=>null===w[t.id].start);for(const t of[...h,...f]){const e=w[t.id];let n=-1;for(let t=0;S.length>t;t++){const i=S[t].occupants[S[t].occupants.length-1];if(null===e.start||void 0===i||e.start>=i.end){n=t;break}}-1===n&&(S.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=S.length-1),S[n].occupants.push({id:t.id,end:null!==(u=null==e?void 0:e.end)&&void 0!==u?u:-1/0}),S[n].peak.topPeak=Math.max(S[n].peak.topPeak,b[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,x[t.id]),A[t.id]=n}}else t.forEach((t,e)=>{var n,i;S.push({occupants:[{id:t.id,end:null!==(i=null===(n=w[t.id])||void 0===n?void 0:n.end)&&void 0!==i?i:-1/0}],peak:{topPeak:b[t.id],botPeak:x[t.id]}}),A[t.id]=e});let M=null,_=null,P=null,O=null;const T=()=>{M=Ki(A,e),P=Ji(A,e)},$=()=>{_=Ki(A,e),O=Ji(A,e)};"crossing-min"===m?(T(),no(S,A,e),$()):"inside-out"===m?(T(),function(t,e){const n=t.length;if(1>=n)return;const i=t=>t.peak.topPeak+t.peak.botPeak,o=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>i(e.slot)-i(t.slot)),r=Array(n),s=Math.floor((n-1)/2);r[s]=o[0].idx;let a=s-1,l=s+1;for(let t=1;o.length>t;t++)t%2==1&&n>l||0>a?r[l++]=o[t].idx:r[a--]=o[t].idx;const c=r.map(e=>t[e]),u=new Map;r.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of c)t.push(e)}(S,A),$()):"crossing-min+inside-out"===m&&(T(),no(S,A,e),function(t,e,n){const i=t.length;if(1>=i)return;const o=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),r=Math.floor((i-1)/2);let s=to(e,n);for(const{slot:a}of o){const o=t.indexOf(a);if(0>o)continue;const l=r;if(o===l)continue;const c=t[o];t.splice(o,1),t.splice(l,0,c);const u=new Map;for(let t=0;i>t;t++)u.set(t,t);if(l>o){for(let t=o+1;l>=t;t++)u.set(t,t-1);u.set(o,l)}else{for(let t=l;o>t;t++)u.set(t,t+1);u.set(o,l)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const d=to(e,n);if(d>s){const n=t[l];t.splice(l,1),t.splice(o,0,n);const r=new Map;for(let t=0;i>t;t++)r.set(t,t);if(o>l){for(let t=l+1;o>=t;t++)r.set(t,t-1);r.set(l,o)}else{for(let t=o;l>t;t++)r.set(t,t+1);r.set(l,o)}for(const t of Object.keys(e))e[t]=r.get(e[t])}else s=d}}(S,A,e),$());const L=S.map(t=>{const e=new Map;for(const i of t.occupants){const t=n[i.id];if(t)for(const n of t.samples){const t=e.get(n.t)||{top:0,bot:0};e.set(n.t,{top:Math.max(t.top,n.topMass),bot:Math.max(t.bot,n.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),j=(t,e)=>{let n={top:0,bot:0};for(const[i,o]of t){if(i>e)break;n=o}return n},z=[];for(let t=0;S.length-1>t;t++){const e=L[t],n=L[t+1],i=new Set([...e.map(t=>t[0]),...n.map(t=>t[0])]);let o=0;for(const t of i){const i=j(e,t),r=j(n,t);i.bot+r.top>o&&(o=i.bot+r.top)}z.push(o)}const C=[];let E=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;S.length>0&&C.push(E);for(let t=1;S.length>t;t++)E+=z[t-1]*p+g,C.push(E);if(S.length>0&&(E+=S[S.length-1].peak.botPeak*p+g),E>f){const t=f/E;for(let e=0;C.length>e;e++)C[e]*=t}const D=0===S.length?0:S[0].peak.topPeak+z.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,R={};for(const e of t)R[e.id]=C[A[e.id]];return{effectiveSlotsHeight:D,centerlines:R,laneLifetime:w,slots:S,slotByNode:A,slotCenter:C,crossingsBefore:M,crossingsAfter:_,lengthBefore:P,lengthAfter:O}}function oo(t){const{nodes:e,edges:n,domain:i,plotW:o,plotH:r,ribbonLane:s,edgeOpacity:a,colorOf:l,layoutOpts:c}=t,u=function(t,e,n){const i=[],o=new Set(t.map(t=>t.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||i.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||i.push({kind:"invalid-node-time",id:e.id}));for(const t of e)o.has(t.source)||i.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),o.has(t.target)||i.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||i.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||i.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):i.push({kind:"invalid-edge-time",id:t.id});return i}(e,n,i),d=x().domain(i).range([0,o]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(t,e,n){var i;const{plotH:o,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(t,e){const n={},i={};for(const e of t)n[e.id]=[],i[e.id]=[];for(const t of e)i[t.source]&&i[t.source].push(t),n[t.target]&&n[t.target].push(t);return{incoming:n,outgoing:i}}(t,e),u=function(t,e,n,i="value"){const o="temporal"===i?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,r="temporal"===i?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const n=new Map;for(const i of t){const t=i[e];n.has(t)||n.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(t);o.edges.push(i),o.total+=i.value,o.earliestStart=Math.min(o.earliestStart,i.startTime),o.latestEnd=Math.max(o.latestEnd,i.endTime)}const s=[...n.values()];s.sort("temporal"===i?(t,n)=>"target"===e?t.earliestStart-n.earliestStart:t.latestEnd-n.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?r:o);return s};for(const e of t){const t=n.outgoing[e.id],i=n.incoming[e.id];if(0===i.length)a(t,"target").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=n});else if(0===t.length)a(i,"source").forEach((t,e)=>{const n=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=n});else{const e=a(i,"source"),n=a(t,"target"),o=Math.max(e.length,n.length);for(let t=0;o>t;t++){const i=t%2==0?"top":"bot";if(e[t])for(const n of e[t].edges)s.get(n.id).targetSide=i;if(n[t])for(const e of n[t].edges)s.get(e.id).sourceSide=i}}}return s}(t,e,c,r);let d={};for(const e of t)d[e.id]=Vi(e,c,u);const h=io(t,e,d,c,{plotH:o,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),f=new Set;for(const t of e){const e=h.slotByNode[t.source],n=h.slotByNode[t.target];if(void 0===e||void 0===n)continue;const i=u.get(t.id);e!==n?e>n?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(f.add(t.id),i.sourceSide="bot",i.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],n=c.incoming[e.id],i=new Set(t.map(t=>u.get(t.id).sourceSide)),o=new Set(n.map(t=>u.get(t.id).targetSide));if(1===i.size&&n.length>0){const t=[...i][0];for(const e of n)h.slotByNode[e.source]===h.slotByNode[e.target]&&(u.get(e.id).targetSide=t)}if(1===o.size&&t.length>0){const e=[...o][0];for(const n of t)h.slotByNode[n.source]===h.slotByNode[n.target]&&(u.get(n.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],n=c.outgoing[e.id];if(0===t.length||0===n.length)continue;const i=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of t)"top"===u.get(n.id).targetSide?e.inTop+=n.value:e.inBot+=n.value;for(const t of n)"top"===u.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},o=(t,e)=>{const o=i(),r="top"===t?o.outTop-o.inTop:o.outBot-o.inBot,s="top"===e?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=n.filter(e=>!f.has(e.id)&&u.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=e,!0)};let r=n.length+1;for(;r-- >0&&(o("top","bot")||o("bot","top")););}d={};for(const e of t)d[e.id]=Vi(e,c,u);const g=io(t,e,d,c,{plotH:o,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),p=null!==(i=g.effectiveSlotsHeight)&&void 0!==i?i:g.slots.reduce((t,e)=>t+e.peak.topPeak+e.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(g.slots.length+1,1)),m=p>0?Math.max(0,(o-y*(g.slots.length+1))/p):1,v=io(t,e,d,c,{plotH:o,padding:y,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:y,compressedPadding:12>y,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(e,n,Object.assign({plotH:r},c)),{centerlines:f,nodeData:g,valueScale:p}=h,y=[],m=[];e.forEach((t,e)=>{var o;const r=g[t.id];if(!r||0===r.samples.length)return;const s=function(t,e,n,i,o){if(0===t.length)return null;const r=Zi(t,o),s=t=>e-r[t].topMass*n,a=t=>e+r[t].botMass*n;let l=`M${i(r[0].t)},${s(0)}`;for(let t=1;r.length>t;t++)l+=` L${i(r[t].t)},${s(t)}`;l+=` L${i(r[r.length-1].t)},${a(r.length-1)}`;for(let t=r.length-2;t>=0;t--)l+=` L${i(r[t].t)},${a(t)}`;return l+" Z"}(r.samples,f[t.id],p,d,i);if(!s)return;const a=Zi(r.samples,i),c=a.find(t=>t.topMass+t.botMass>0)||a[0],u=f[t.id]+(c.botMass-c.topMass)*p/2,m=l(t.id,e),v=function(t,e,n,i,o){const r=n.nodeData[t];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[t],l=Zi(r.samples,o),c=l.find(t=>t.topMass+t.botMass>0)||l[0],u=[...l].reverse().find(t=>t.topMass+t.botMass>0)||l[l.length-1],d=i(c.t),h=i(u.t),f=t=>i(Ui(t,o)),g=[],p=(t,e,n,i)=>`M${t},${e} L${n},${e} L${n},${i} L${t},${i} Z`;for(const n of e){if(n.source===t&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const t=r.localAttachments.get(n.id);if(t&&"out"===t.kind&&n.startTime>n.systemInTime){const e=f(n.systemInTime),i=f(n.startTime),o=e-20,r=Math.max(d,o);if(i>r){const[n,l]=Qi(t,a,s);g.push({pathD:p(r,n,i,l),x0:o,x1:e,from:0,to:1})}}}if(n.target===t&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const t=r.localAttachments.get(n.id);if(t&&"in"===t.kind&&n.systemOutTime>n.endTime){const e=f(n.systemOutTime),i=f(n.endTime),o=e+20,r=Math.min(h,o);if(r>i){const[n,l]=Qi(t,a,s);g.push({pathD:p(i,n,r,l),x0:e,x1:o,from:1,to:0})}}}}return g}(t.id,n,h,d,i);y.push(Object.assign(Object.assign({id:t.id,pathD:s,fill:m,stroke:m,strokeWidth:.5},v.length>0&&{gradientStubs:v}),{rawDatum:null!==(o=t.__raw)&&void 0!==o?o:t,labelX:d(c.t)-4,labelY:u,labelText:t.id}))});const v=new Map;return e.forEach((t,e)=>v.set(t.id,e)),n.forEach(t=>{var e,n,o,r;const c=null===(e=g[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=g[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!c||!u)return;const h=null!==(o=v.get(t.source))&&void 0!==o?o:0,y=l(t.source,h),b=function(t,e,n,i,o,r,s,a){const l=o,c=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=r(c(t.time)),d=r(c(n.time)),h=t.value*l,f=n.value*l,g=t.sideMassBefore*l,p=n.sideMassAfter*l;let y,m,v,b;"top"===t.side?(y=e-g,m=y+h):(m=e+g,y=m-h),"top"===n.side?(v=i-p,b=v+f):(b=i+p,v=b-f);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:y,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,f[t.source],u,f[t.target],p,d,s,i),{pathD:x,bezier:k}=gn(b);m.push({id:t.id,pathD:x,fill:y,opacity:a,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:h,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:d}}const ro=t=>{var e,n;const{bands:i=[],ribbons:o=[],showLabels:r=!0}=t.config,s=[];for(const t of o)s.push(Object.assign(Object.assign({type:"bezier",pathD:t.pathD},t.bezier&&{bezierCache:t.bezier}),{style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}}));for(const t of i)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const n=t.gradientStubs[e];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of i)s.push({type:"bezier",pathD:t.pathD,style:Object.assign(Object.assign({},t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86}),{stroke:null!==(e=t.stroke)&&void 0!==e?e:t.fill,strokeWidth:null!==(n=t.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:t.rawDatum,id:t.id}});const a=r?i.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:i.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:s,labels:a}},so=Object.freeze([]);function ao(t){if(!t)return so;let e=!1;for(let n=0;t.length>n;n++){const i=t[n];if(null==i||"object"!=typeof i){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}function lo(t){return Array.isArray(t)?t[0]:t}function co(t,e,n,i){return Object.assign({data:lo(t),x:e,y:n,__semioticHoverData:!0},i)}const uo={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function ho(t,e){return"function"==typeof e?e(t):t[e]}function fo(t,e){if(e)return e(t);if(null==t)return"";if("number"==typeof t){if(!Number.isFinite(t))return t+"";const e=Number.isInteger(t)?t:parseFloat(t.toPrecision(6));return Math.abs(e)>9999?e.toLocaleString():e+""}return t instanceof Date?t.toLocaleDateString():"object"==typeof t&&null!==t?void 0!==t.id?t.id+"":void 0!==t.name?t.name+"":JSON.stringify(t):t+""}function go(n={}){const{fields:i,title:o,format:r,style:s={},className:a=""}=n;return n=>{if(!n||"object"!=typeof n)return null;let l;const c=[];if(o){const t=ho(n,o);l=fo(t,r)}if(i&&i.length>0)i.forEach(t=>{let e,i,o;"string"==typeof t?(e=t,i=t,o=r):(e=t.label,i=t.accessor||t.key||"",o=t.format||r);const s=ho(n,i);c.push({label:e,value:fo(s,o)})});else if(!o){const t=["value","y","name","id","label"];for(const e of t)if(void 0!==n[e]){l=fo(n[e],r);break}if(!l){const t=Object.keys(n).filter(t=>!t.startsWith("_"));t.length>0&&(l=fo(n[t[0]],r))}}const u=Object.assign(Object.assign({},uo),s);return e("div",{className:("semiotic-tooltip "+a).trim(),style:u,children:[l&&t("div",{style:{fontWeight:c.length>0?"bold":"normal"},children:l}),c.map((t,n)=>e("div",{style:{marginTop:0===n&&l?"4px":0},children:[t.label&&e("span",{children:[t.label,": "]}),t.value]},n))]})}}function po(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i+1>>1;e[o]>t?i=o-1:n=o}return e[n]}function yo(t,e){let n=0,i=e.length-1;for(;i>n;){const o=n+i>>1;t>e[o]?n=o+1:i=o}return e[n]}function mo({width:e,height:n,totalWidth:i,totalHeight:s,margin:a,dimension:l,scales:c,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:p,streaming:y}){const m=o(null),v=o(null),b=o(d);b.current=d;const x=o(c);x.current=c;const k=r(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=o(k);w.current=k;const A=o(!1),S=o(null);return u(()=>{if(!m.current)return;const t=vt(m.current).select(".brush-g"),i="x"===l?bt():"y"===l?xt():kt();return i.extent([[0,0],[e,n]]),i.on("brush end",o=>{if(A.current)return;const r=x.current;if(!r)return;if(!o.selection)return S.current=null,void b.current(null);let s,a;if("x"===l){const[t,e]=o.selection;s=[r.x.invert(t),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(0)]}else if("y"===l){const[t,n]=o.selection;s=[r.x.invert(0),r.x.invert(e)],a=[r.y.invert(n),r.y.invert(t)]}else{const[[t,e],[n,i]]=o.selection;s=[r.x.invert(t),r.x.invert(n)],a=[r.y.invert(i),r.y.invert(e)]}if("bin"===f&&"y"!==l&&("end"===o.type||"brush"===o.type&&p)){const e=w.current;e&&e.length>0?s=function(t,e){return 0===e.length?t:[po(t[0],e),yo(t[1],e)]}(s,e):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const n=r.x(s[0]),a=r.x(s[1]);if(A.current=!0,"x"===l)t.call(i.move,[n,a]);else if("xy"===l){const e=o.selection;t.call(i.move,[[n,e[0][1]],[a,e[1][1]]])}A.current=!1}const c={x:s,y:a};S.current=c,b.current(c)}),t.call(i),v.current=i,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{i.on("brush end",null),v.current=null}},[e,n,l,f,h,p]),u(()=>{if(!(y&&c&&v.current&&S.current))return;if(!m.current)return;if("y"===l)return;const t=S.current,e=c.x.domain()[0],n=vt(m.current).select(".brush-g");if(e>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);let i=t.x[0],o=!1;if(e>t.x[0]){if(i=e,"bin"===f){const t=w.current;t&&t.length>0?i=yo(e,t):h&&h>0&&(i=Math.ceil(e/h)*h)}if(i>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void b.current(null);o=!0}const r=c.x(i),s=c.x(t.x[1]);if(A.current=!0,"x"===l)n.call(v.current.move,[r,s]);else{const e=c.y(t.y[1]),i=c.y(t.y[0]);n.call(v.current.move,[[r,e],[s,i]])}if(A.current=!1,o){const e={x:[i,t.x[1]],y:t.y};S.current=e,b.current(e)}},[c,y,l,f,h]),t("svg",{ref:m,width:i,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t("g",{className:"brush-g",transform:`translate(${a.left},${a.top})`})})}class vo{constructor(t,e){var n,i;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=null!==(n=null==e?void 0:e.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(i=null==e?void 0:e.chunkSize)&&void 0!==i?i:5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=ao(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(t){if(t=ao(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const n=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const i=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,i),bounded:!1}),e=i,this.chunkTimer=t.length>e?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let n=0;t.length>n;n++){const i=t[n];null!=i&&"object"==typeof i&&(this.pushBuffer.push(i),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function bo(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:i.createElement(i.Fragment,null,...e)}function xo(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function ko(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function wo(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Ao(t,e){const n=wo(t);if(!n)return!1;const i=wo(e);return!i||n.getFullYear()!==i.getFullYear()||n.getMonth()!==i.getMonth()}const So=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Mo=new WeakMap;let _o=0,Po=!1,Oo=null,To=null,$o=null;function Lo(t,e){var n,i;if(!e)return e;const o=So.exec(e);if(!o)return e;const r=t.canvas;if(!r)return(null===(n=o[2])||void 0===n?void 0:n.trim())||e;!function(){if(Po)return;if("undefined"==typeof window||"undefined"==typeof document)return;Po=!0;const t=()=>{_o++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Oo=new MutationObserver(t),Oo.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{To=window.matchMedia("(prefers-color-scheme: dark)"),$o=t,"function"==typeof To.addEventListener?To.addEventListener("change",$o):"function"==typeof To.addListener&&To.addListener($o)}catch(t){}}();let s=Mo.get(r);s&&s.version===_o||(s={version:_o,map:new Map},Mo.set(r,s));const a=s.map.get(e);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(o[1]).trim()||(null===(i=o[2])||void 0===i?void 0:i.trim())||e;return s.map.set(e,l),l}function jo(t){switch(t){case"monotoneX":return Z;case"monotoneY":return U;case"cardinal":return V;case"catmullRom":return q;case"step":return X;case"stepBefore":return H;case"stepAfter":return G;case"basis":return Y;case"natural":return I;default:return null}}function zo(t,e,n){return null==e?n:"string"!=typeof e?e:Lo(t,e)||n}function Co(t,e,n,i,o,r,s){if("colorStops"in e){const n=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>n.length)return null;const a=t.createLinearGradient(i,o,r,s);for(const t of n)a.addColorStop(t.offset,t.color);return a}const{topOpacity:a,bottomOpacity:l}=e;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),d=t.createLinearGradient(i,o,r,s),[h,f,g]=function(t,e){const n=t.fillStyle,i="#010203";try{t.fillStyle=i,t.fillStyle=e}catch(e){return t.fillStyle=n,[78,121,167]}const o=t.fillStyle;if(t.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===i&&e.trim().toLowerCase()!==i)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const r=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}(t,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function Eo(t,e,n,i,o,r){const s=e.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>s.length)return null;const a=t.createLinearGradient(n,i,o,r);for(const t of s)a.addColorStop(t.offset,t.color);return a}const Do=new WeakMap;function Ro(t,e){const n=jo(e);if(!n)return t;const i=Do.get(t);if(i)return i;const o=function(t,e,n=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const i=[];let o=null;const r={moveTo(t,e){o=[t,e],i.push([t,e])},lineTo(t,e){o=[t,e],i.push([t,e])},bezierCurveTo(t,e,r,s,a,l){if(!o)return o=[a,l],void i.push([a,l]);const[c,u]=o;for(let o=1;n>=o;o++){const d=o/n,h=1-d;i.push([h*h*h*c+3*h*h*d*t+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*e+3*h*d*d*s+d*d*d*l])}o=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,n,r){o=[n,r],i.push([n,r])}};return Q().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),i}(t,n);return Do.set(t,o),o}function Fo(t,e,n,i=30,o,r=0){let s=null;if(o){const t=function(t,e,n,i,o){const r=Math.max(i,o+5,12),s=e-r,a=e+r,l=n-r,c=n+r;let u=null,d=1/0;return t.visit((t,o,r,h,f)=>{if(o>a||s>h||r>c||l>f)return!0;if(!t.length){let o=t;do{const t=o.data,r=t.x-e,s=t.y-n,a=Math.sqrt(r*r+s*s);ko(t.r,i)>=a&&d>a&&(u=t,d=a),o=o.next}while(o)}return!1}),u?{node:u,distance:d}:null}(o,e,n,i,r);t&&(s={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const r of t){let t=null;switch(r.type){case"point":if(o)break;t=Bo(r,e,n,i);break;case"line":t=Wo(r,e,n,i);break;case"rect":if(null==r.datum)break;t=Yo(r,e,n);break;case"heatcell":t=Go(r,e,n);break;case"area":if(!1===r.interactive)break;t=Xo(r,e,n);break;case"candlestick":t=Ho(r,e,n)}t&&i>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function No(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const i=qo(t,e);if(0>i)return null;if(Math.abs(t[i][0]-e)>n)return null;let o=i,r=i;i>0&&t[i][0]>=e?(o=i-1,r=i):t.length-1>i&&(o=i,r=i+1);const[s,a]=t[o],[l,c]=t[r];return l===s?a:a+Math.max(0,Math.min(1,(e-s)/(l-s)))*(c-a)}function Bo(t,e,n,i=30){const o=e-t.x,r=n-t.y,s=Math.sqrt(o*o+r*r);return s>ko(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Wo(t,e,n,i=30){var o,r;if(0===t.path.length)return null;const s=qo(t.path,e);if(0>s)return null;const[a,l]=t.path[s];let c;if(t.path.length>1){let i=1/0;const o=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=o;r>=s;s++){const[o,r]=t.path[s],[a,l]=t.path[s+1],c=Io(e,n,o,r,a,l);i>c&&(i=c)}c=i}else{const t=e-a,i=n-l;c=Math.sqrt(t*t+i*i)}const u=t.style,d=null!==(r=null!==(o=u.strokeWidth)&&void 0!==o?o:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,i)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:a,y:l,distance:c}}function Io(t,e,n,i,o,r){const s=o-n,a=r-i,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(t-n,2)+Math.pow(e-i,2));let c=((t-n)*s+(e-i)*a)/l;c=Math.max(0,Math.min(1,c));const u=i+c*a;return Math.sqrt(Math.pow(t-(n+c*s),2)+Math.pow(e-u,2))}function Yo(t,e,n){const i=xo(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Go(t,e,n){const i=xo(e,n,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Ho(t,e,n){const i=t.bodyWidth/2,o=Math.min(t.openY,t.closeY);if(!(t.x-i-3>e||e>t.x+i+3||t.highY-3>n||n>t.lowY+3)){const i=o+Math.max(Math.max(t.openY,t.closeY)-o,1)/2,r=e-t.x,s=n-i;return{node:t,datum:t.datum,x:t.x,y:i,distance:Math.sqrt(r*r+s*s)}}return null}function Xo(t,e,n){if(0===t.topPath.length)return null;const i=qo(t.topPath,e);if(0>i)return null;const[o,r]=t.topPath[i],s=e-o,a=n-r,l=Math.sqrt(s*s+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:r,distance:l}}function qo(t,e){if(0===t.length)return-1;let n=0,i=t.length-1;for(;i>n;){const o=n+i>>1;e>t[o][0]?n=o+1:i=o}return n>0&&Math.abs(t[n][0]-e)>=Math.abs(t[n-1][0]-e)?n-1:n}function Vo(t,e,n){const i=t.byGroup.get(e);let o=0,r=Math.abs(i[0].x-n.x);for(let t=1;i.length>t;t++){const e=Math.abs(i[t].x-n.x);r>e&&(r=e,o=t)}return i[o]._flatIndex}function Uo(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const Zo={fill:(e,n)=>t("rect",{style:e,width:n,height:n}),line:(e,n)=>t("line",{style:e,x1:0,y1:0,x2:n,y2:n})};function Qo(t,e,n,i,o){let r;return r="function"==typeof n?n(t):(0,Zo[n])(i(t,e),o),r}function Ko({swatchSize:e}){return t("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Jo(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const tr=(n,i,o,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:p}=n,y=[];let m=0;const v=!(!i&&!o),b="isolate"===d||void 0===d&&null!=s,{swatchSize:x,labelGap:k,rowHeight:w}=h;return p.forEach((n,d)=>{const h=Qo(n,d,f,g,x),A=Jo(n,r,s),S=s&&s.size>0&&s.has(n.label);y.push(e("g",{transform:`translate(0,${m})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?c===a&&d===l?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?S||!1:void 0,"aria-current":v&&!b&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:v?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const n=(d+("ArrowDown"===t.key?1:-1)+p.length)%p.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:v?t=>{u(c,d),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:v?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+k+2+7*n.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),h,S&&t(Ko,{swatchSize:x}),t("text",{y:x/2,x:x+k,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+d)),m+=w}),y};function er({config:n,orientation:o="vertical",width:r=100}){const{colorFn:s,domain:a,label:l,format:c}=n,u=c||(t=>Math.round(100*t)/100+""),d="grad-legend-"+i.useId();if("horizontal"===o){const n=12,i=Math.min(r,200),o=Math.max(0,(r-i)/2),c=[];for(let e=0;64>=e;e++){const n=e/64;c.push(t("stop",{offset:100*n+"%",stopColor:s(a[0]+n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),l&&t("text",{x:o+i/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("rect",{x:o,y:0,width:i,height:n,fill:`url(#${d})`,rx:2}),t("text",{x:o,y:n+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])}),t("text",{x:o+i,y:n+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])})]})}const h=[];for(let e=0;64>=e;e++){const n=e/64;h.push(t("stop",{offset:100*n+"%",stopColor:s(a[1]-n*(a[1]-a[0]))},e))}return e("g",{"aria-label":l||"Gradient legend",children:[l&&t("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),t("defs",{children:t("linearGradient",{id:d,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:h})}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${d})`,rx:2}),t("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[1])}),t("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:u(a[0])})]})}function nr(n){const{legendGroups:o,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,legendInteraction:c,title:u="Legend",width:d=100,height:h=20,orientation:f="vertical",legendLayout:g}=n,p=function(t){var e,n,i,o,r;const s=Math.max(1,null!==(e=null==t?void 0:t.swatchSize)&&void 0!==e?e:16),a=Math.max(s,null!==(n=null==t?void 0:t.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(i=null==t?void 0:t.labelGap)&&void 0!==i?i:6),itemGap:Math.max(0,null!==(o=null==t?void 0:t.itemGap)&&void 0!==o?o:10),rowHeight:a,align:"left"===(null==t?void 0:t.align)?"start":"right"===(null==t?void 0:t.align)?"end":null!==(r=null==t?void 0:t.align)&&void 0!==r?r:"start",maxWidth:null==t?void 0:t.maxWidth}}(g),[y,m]=i.useState(0),[v,b]=i.useState(0),x=i.useCallback((t,e)=>{m(t),b(e)},[]),k="vertical"===f?(({legendGroups:e,width:n,customClickBehavior:i,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return e.forEach((e,g)=>{h+=5,f.push(t("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,e.label&&(h+=16,f.push(t("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+g)),h+=8),f.push(t("g",{className:"legend-item",transform:`translate(0,${h})`,children:tr(e,i,o,r,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=e.items.length*d.rowHeight+8}),f})({legendGroups:o||[],width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:y,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:c,metrics:p}):(({legendGroups:n,height:i,width:o,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:c,focusedItemIndex:u,onFocusedIndexChange:d,legendInteraction:h,metrics:f})=>{var g;let p=0;const y=[];n.forEach((n,i)=>{var g;let m=0;n.label&&(m+=16);const v=((n,i,o,r,s,a,l,c,u,d,h,f)=>{const{type:g="fill",styleFn:p,items:y}=n,m=[],{swatchSize:v,labelGap:b,itemGap:x,rowHeight:k,align:w}=h,A=!(!i&&!o),S="isolate"===d||void 0===d&&null!=s,M=y.map(t=>v+b+7*t.label.length),_=[];let P=0,O=0;M.forEach((t,e)=>{const n=0===O?t:O+x+t;f&&f>0&&O>0&&n>f?(_.push({start:P,end:e,width:O}),P=e,O=t):O=n}),y.length>0&&_.push({start:P,end:y.length,width:O}),_.forEach((n,d)=>{let h="center"===w?Math.max(0,((null!=f?f:n.width)-n.width)/2):"end"===w?Math.max(0,(null!=f?f:n.width)-n.width):0;for(let f=n.start;n.end>f;f++){const n=y[f],w=Qo(n,f,g,p,v),_=Jo(n,r,s),P=s&&s.size>0&&s.has(n.label);m.push(e("g",{transform:`translate(${h},${d*k})`,onClick:i?()=>i(n):void 0,onMouseEnter:o?()=>o(n):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:A?c===a&&f===l?0:-1:void 0,role:A?"option":void 0,"aria-selected":A&&S?P||!1:void 0,"aria-current":A&&!S&&null!=r&&n.label===r||void 0,"aria-label":n.label,onKeyDown:A?t=>{var e;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),i&&i(n)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const n=(f+("ArrowRight"===t.key?1:-1)+y.length)%y.length;u(c,n);const i=null===(e=t.currentTarget.parentElement)||void 0===e?void 0:e.children[n];i instanceof SVGElement&&i.focus()}}:void 0,onFocus:A?t=>{u(c,f),o&&o(n);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","visible")}:void 0,onBlur:A?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:A?"pointer":"default",opacity:_,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[A&&t("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+b+2+7*n.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),w,P&&t(Ko,{swatchSize:v}),t("text",{y:v/2,x:v+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:n.label})]},"legend-item-"+f)),h+=M[f]+x}});const T=Math.max(0,..._.map(t=>t.width)),$=_.length;return{items:m,offset:T,totalRows:$,totalHeight:$*k}})(n,r,s,a,l,c,u,i,d,h,f,null!==(g=f.maxWidth)&&void 0!==g?g:o);m+=v.offset+5,y.push(Object.assign(Object.assign({label:n.label},v),{offset:m,totalRows:v.totalRows,totalHeight:v.totalHeight})),p+=m+12});const m=null!==(g=f.maxWidth)&&void 0!==g?g:o;let v=p>m?0:"center"===f.align?Math.max(0,(m-p)/2):"end"===f.align?Math.max(0,m-p):0;const b=[];return y.forEach((e,o)=>{const r=n[o];r.label&&(b.push(t("text",{transform:`translate(${v},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),v+=16),b.push(t("g",{className:"legend-item",transform:`translate(${v},0)`,children:e.items},"legend-group-"+o)),v+=e.offset+5,n[o+1]&&b.push(t("line",{stroke:"gray",x1:v,y1:-8,x2:v,y2:(e.totalHeight||i)+0+8},"legend-top-line legend-symbol-"+o)),v+=12}),t("g",{children:b})})({legendGroups:o||[],title:u,height:h,width:d,customClickBehavior:r,customHoverBehavior:s,highlightedCategory:a,isolatedCategories:l,focusedGroupIndex:y,focusedItemIndex:v,onFocusedIndexChange:x,legendInteraction:c,metrics:p}),w=!(!r&&!s);return e("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"isolate"!==c&&(void 0!==c||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==u&&""!==u&&"vertical"===f&&t("text",{className:"legend-title",y:16,x:d/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:u}),k]})}function ir(e){var n;const{legend:i,totalWidth:o,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=e;if(!i)return null;const p="top"===a||"bottom"===a,y=!!c,m=Math.max(1,p?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n:Math.max(0,o-s.left-s.right):100);let v,b;return"left"===a?(v=Math.max(4,s.left-m-10),b=s.top):"top"===a?(v=s.left,b=y?32:8):"bottom"===a?(v=s.left,b=r-s.bottom+38):(v=o-s.right+10,b=s.top),t("g",{transform:`translate(${v}, ${b})`,children:Mt(i)?t(er,{config:i.gradient,orientation:p?"horizontal":"vertical",width:m}):St(i)?t(nr,{legendGroups:i.legendGroups,title:"",width:m,orientation:p?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):i})}function or(t){return"string"==typeof t?{type:t}:t}function rr({orient:n,config:i,values:o,scale:s,size:a,length:l}){const c=function(t){var e,n,i,o,r;return{type:t.type,bins:null!==(e=t.bins)&&void 0!==e?e:20,fill:null!==(n=t.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(i=t.fillOpacity)&&void 0!==i?i:.5,stroke:null!==(o=t.stroke)&&void 0!==o?o:"none",strokeWidth:null!==(r=t.strokeWidth)&&void 0!==r?r:1}}(i),u="top"===n||"bottom"===n,d=r(()=>{if(0===o.length)return null;const i=s.domain(),r=a-8;if("boxplot"===c.type){const i=function(t){const e=[...t].sort((t,e)=>t-e),n=e.length;if(0===n)return null;const i=e[Math.floor(.25*n)],o=e[Math.floor(.5*n)],r=e[Math.floor(.75*n)],s=r-i;return{q1:i,median:o,q3:r,whiskerLow:Math.max(e[0],i-1.5*s),whiskerHigh:Math.min(e[n-1],r+1.5*s)}}(o);if(!i)return null;const{q1:a,median:l,q3:d,whiskerLow:h,whiskerHigh:f}=i,g=Math.min(.5*r,20),p=(r-g)/2+4;if(u){const i=s(a),o=s(d),r=s(l),u=s(h),y=s(f),m="top"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:u,y1:v+m*(p+g/2),x2:y,y2:v+m*(p+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:u,y1:v+m*p,x2:u,y2:v+m*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:y,y1:v+m*p,x2:y,y2:v+m*(p+g),stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:Math.min(i,o),y:"top"===n?v-p-g:v+p,width:Math.abs(o-i),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:r,y1:"top"===n?v-p-g:v+p,x2:r,y2:"top"===n?v-p:v+p+g,stroke:c.fill,strokeWidth:2})]})}{const i=s(a),o=s(d),r=s(l),u=s(h),y=s(f),m="left"===n?-1:1,v=0;return e("g",{"data-testid":"marginal-boxplot-"+n,children:[t("line",{x1:v+m*(p+g/2),y1:u,x2:v+m*(p+g/2),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*p,y1:u,x2:v+m*(p+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t("line",{x1:v+m*p,y1:y,x2:v+m*(p+g),y2:y,stroke:c.fill,strokeWidth:c.strokeWidth}),t("rect",{x:"left"===n?v-p-g:v+p,y:Math.min(i,o),width:g,height:Math.abs(o-i),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t("line",{x1:"left"===n?v-p-g:v+p,y1:r,x2:"left"===n?v-p:v+p+g,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=$().domain(i).thresholds(c.bins)(o);if(0===d.length)return null;const h=Math.max(...d.map(t=>t.length));if(0===h)return null;if("histogram"===c.type)return t("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const o=e.length/h*r;if(u){const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:r,y:"top"===n?-4-o:4,width:Math.max(a,.5),height:o,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const r=s(e.x0),a=s(e.x1)-s(e.x0);return t("rect",{x:"left"===n?-4-o:4,y:Math.min(r,r+a),width:o,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=r/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const o=t.length/h*(r/2),a=s((t.x0+t.x1)/2);i.push(u?`${a},${"top"===n?-(e-o):e-o}`:`${"left"===n?-(e-o):e-o},${a}`)}for(let t=d.length-1;t>=0;t--){const o=d[t];if(null==o.x0||null==o.x1)continue;const a=o.length/h*(r/2),l=s((o.x0+o.x1)/2);i.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t("g",{"data-testid":"marginal-violin-"+n,children:t("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const e=[];if(u){const t=0,i=null!=d[0].x0?s(d[0].x0):0;e.push(`M${i},${t}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=s((t.x0+t.x1)/2);e.push(`L${o},${"top"===n?-i-4:i+4}`)}const o=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${o},${t}`),e.push("Z")}else{const t=0,i=null!=d[0].x0?s(d[0].x0):0;e.push(`M${t},${i}`);for(const t of d){if(null==t.x0||null==t.x1)continue;const i=t.length/h*r,o=s((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${o}`)}const o=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${t},${o}`),e.push("Z")}return t("g",{"data-testid":"marginal-ridgeline-"+n,children:t("path",{d:e.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[o,s,c,a,l,n,u,4]);return d?t("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function sr(t,e=120,n=8){if(!t)return[];const i=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),r=[];let s="";for(const t of o)s&&s.length+1+t.length>i?(r.push(s),s=t):s=s?`${s} ${t}`:t;return s&&r.push(s),r}function ar(t,e,n,i){return"curly"===t?i?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:i?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function lr(n,i,o,r){if(!n)return t("g",{className:"annotation-note"});const{label:s,title:a,orientation:l,align:c,wrap:u=120,noWrap:d}=n;if(!s&&!a)return t("g",{className:"annotation-note"});let h=l;h||(h=Math.abs(i)>Math.abs(o)?"leftRight":"topBottom");let f=c;f&&"dynamic"!==f||(f="topBottom"===h?0>i?"right":"left":0>o?"bottom":"top");let g="start";"topBottom"===h?"right"===f?g="end":"middle"===f&&(g="middle"):g=0>i?"end":"start";const p=16,y=a?d?[a]:sr(a,u):[],m=s?d?[s]:sr(s,u):[],v="leftRight"===h?"end"===g?-4:4:0;let b=0;const x=[],k=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";y.length>0&&(x.push(t("text",{className:"annotation-note-title",fill:k,textAnchor:g,fontWeight:"bold",children:y.map((e,n)=>t("tspan",{x:v,dy:0===n?0:p,children:e},n))},"annotation-note-title")),b=y.length*p),m.length>0&&x.push(t("text",{className:"annotation-note-label",fill:k,textAnchor:g,y:b,children:m.map((e,n)=>t("tspan",{x:v,dy:0===n?0:p,children:e},n))},"annotation-note-label"));let w=null;if((a||s)&&(0!==i||0!==o))if("topBottom"===h){const e=Math.min(u,120);let n=0,i=e;"end"===g?(n=-e,i=0):"middle"===g&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:n,x2:i,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+m.length)*p+(m.length>0?p:0);let n=0,i=e;"bottom"===f?(n=-e,i=0):"middle"===f&&(n=-e/2,i=e/2),w=t("line",{className:"note-line",x1:0,x2:0,y1:n,y2:i,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const A=Math.max(0,y.length+m.length-1)*p;let S=0;return"topBottom"===h?S=0>o?-(A+2):18:"leftRight"===h&&(S="middle"===f?-(A+p+(m.length>0&&y.length>0?2:0))/2+8:"bottom"===f||0>o?-(A+2):18),e("g",{className:"annotation-note",transform:`translate(${i},${o})`,children:[t("g",{className:"annotation-note-content",transform:0!==S?`translate(0,${S})`:void 0,children:x}),w]})}function cr(e,n,i,o,r){var s;const a=[];switch(e){case"callout-circle":{const e=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);e>0&&a.push(t("circle",{r:e,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=(null==n?void 0:n.width)||0,o=(null==n?void 0:n.height)||0;(e>0||o>0)&&a.push(t("rect",{width:e,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const o=(n.x||0)-e;a.push(t("line",{x1:o,y1:(n.y1||0)-s,x2:o,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const o=(n.y||0)-s;a.push(t("line",{x1:(n.x1||0)-e,y1:o,x2:(n.x2||0)-e,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(t("line",{x1:(n.x1||0)-e,y1:0,x2:(n.x2||0)-e,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(t("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==e&&a.push(t("path",{d:ar((null==n?void 0:n.type)||"curly",e,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return t("g",{className:"annotation-subject",children:a})}function ur(e,n,i,o,r,s){const a=[];let l=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const t=s.width||0,i=s.height||0;if(t>0||i>0){const o=t/2,r=i/2,s=e-o,a=n-r;if(0!==s||0!==a){const e=Math.abs(s),n=Math.abs(a),u=t/2,d=i/2,h=e*d>n*u?u/e:d/n;l=o+s*h,c=r+a*h}}}else if("bracket"===r&&s){const t=s.width,e=s.height,n=s.depth||30;void 0!==t?(l=t/2,c=n):void 0!==e&&(l=n,c=e/2)}}else{const t=(s.radius||0)+(s.radiusPadding||0);if(t>0&&(0!==e||0!==n)){const i=Math.atan2(n,e);l=Math.cos(i)*t,c=Math.sin(i)*t}}if(Math.sqrt(Math.pow(e-l,2)+Math.pow(n-c,2))>.5&&(a.push(t("line",{x1:l,y1:c,x2:e,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==i?void 0:i.end))){const i=10,r=16/180*Math.PI,s=Math.atan2(n-c,e-l);a.push(t("path",{d:`M${l},${c}L${l+i*Math.cos(s+r)},${c+i*Math.sin(s+r)}L${l+i*Math.cos(s-r)},${c+i*Math.sin(s-r)}Z`,fill:o||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return t("g",{className:"annotation-connector",children:a})}function dr(t){const{x:n=0,y:i=0,dx:o,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:f,disable:g,events:p={},"data-testid":y}=t,m=new Set(Array.isArray(g)?g:[]);let v=o||0,b=r||0;null!=s&&(v=s-n),null!=a&&(b=a-i);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const t=u.depth||30;b=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;v=t+(0>t?-5:5),b=u.height/2}return e("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${i})`,"data-testid":y},p,{children:[!m.has("connector")&&ur(v,b,c,h,x,u),!m.has("subject")&&cr(x,u,h,n,i),!m.has("note")&&lr(l,v,b,h)]}))}function hr(e){var n,i;const{noteData:o}=e,{screenCoordinates:r}=o,s="string"==typeof o.type?o.type:"label",a=o.eventListeners||o.events||{};if(o.coordinates&&r){const e=o.nx||r[0][0]+(null!==(n=o.dx)&&void 0!==n?n:0),a=o.ny||r[0][1]+(null!==(i=o.dy)&&void 0!==i?i:0),l=r.map((n,i)=>{const r=Object.assign({},o,{note:0===i?o.note:{label:""},x:n[0],y:n[1],nx:e,ny:a});return t(dr,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+i)});return t("g",{children:l})}const l=o.note||{title:"none",label:o.label},c=`${l.label}-${l.title}-${o.i}`;return t(dr,Object.assign({"data-testid":"semiotic-annotation",events:a},o,{type:s}),c)}function fr(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.x)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.time;return r?null!=t.x?r(t.x):e.xAccessor&&null!=t[e.xAccessor]?r(t[e.xAccessor]):null:null}function gr(t,e){var n,i,o;const r=null!==(i=null===(n=e.scales)||void 0===n?void 0:n.y)&&void 0!==i?i:null===(o=e.scales)||void 0===o?void 0:o.value;return r?null!=t.y?r(t.y):e.yAccessor&&null!=t[e.yAccessor]?r(t[e.yAccessor]):null:null}function pr(t,e,n){var i,o,r,s;const a=t.anchor||"fixed";if("latest"===a){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){const t={x:r.x,y:r.y};return null===(i=n.stickyPositionCache)||void 0===i||i.set(e,t),t}}const r=function(t){var e,n,i,o,r,s;const a=t.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(e=t.scales)||void 0===e?void 0:e.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time,u=null!==(r=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==r?r:null===(s=t.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[t.xAccessor||"x"],h=l[t.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(o=n.stickyPositionCache)||void 0===o||o.set(e,r)),r}let l=null,c=null;if(null!=t.pointId&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===t.pointId);e&&(l=e.x,c=e.y)}if(null!=l&&null!=c||(l=fr(t,n),c=gr(t,n)),null!=l&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(e,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const t=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(e);if(t)return t}return null}function yr(t,e,n,i=50){return!(-i>t||t>(n.width||0)+i||-i>e||e>(n.height||0)+i)}const mr={linear:J,monotoneX:Z,monotoneY:U,step:X,stepAfter:G,stepBefore:H,basis:Y,cardinal:V,catmullRom:q};let vr={positions:new Map};const br=new Set;function xr(){for(const t of br)t()}function kr(t,e){const n=vr.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const i=new Map(vr.positions);i.delete(t),vr={positions:i},xr()}function wr(t,e){const n=vr.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const i=new Map(vr.positions);i.delete(t),vr={positions:i},xr()}function Ar(){return vr}function Sr(t){return br.add(t),()=>br.delete(t)}const Mr={positions:new Map};function _r(){return()=>{}}function Pr(){return Mr}function Or(t,e,n){return"exact"===n?function(t,e){const n=t.domain(),i=n[0],o=n[n.length-1],r=i instanceof Date,s=i instanceof Date?i.getTime():i,a=o instanceof Date?o.getTime():o;if(2>e||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(e-1),c=Array(e);for(let t=0;e>t;t++){const n=t===e-1?a:s+t*l;c[t]=r?new Date(n):n}return c}(t,e):t.ticks(e)}function Tr(t,e,n){if("edges"===t){if(e)return"start";if(n)return"end"}return"middle"}function $r(t,e,n){if("edges"===t){if(e)return"hanging";if(n)return"auto"}return"middle"}function Lr(t){if(0===t.length)return{min:null,max:null};let e=1/0,n=-1/0;for(const i of t)e>i.pixel&&(e=i.pixel),i.pixel>n&&(n=i.pixel);return{min:e,max:n}}function jr(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function zr(t,e,n){if("left"===t||"right"===t){const i="left"===t?n:0,o="left"===t?-1:1,r=Math.ceil(e/8);let s="M0,"+i;for(let t=0;r>t;t++){const n=8*(t+1);s+=`L${Math.min(8*t+4,e)},${i+4*o}`,s+=`L${Math.min(n,e)},${i}`}return s}{const i="bottom"===t?0:e,o="bottom"===t?1:-1,r=Math.ceil(n/8);let s=`M${i},0`;for(let t=0;r>t;t++){const e=8*(t+1);s+=`L${i+4*o},${Math.min(8*t+4,n)}`,s+=`L${i},${Math.min(e,n)}`}return s}}function Cr(n){const{width:i,height:o,totalWidth:s,totalHeight:a,margin:l,scales:c,showAxes:u,axes:d,showGrid:h,xFormat:f,yFormat:g,axisExtent:p}=n,y=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||f||Er,r=Math.max(2,Math.floor(i/70)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,a=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Or(c.x,"exact"===p?Math.max(2,s):Math.min(s,r),p),l=a.map(t=>t.valueOf()),u=a.map((t,e)=>({value:t,pixel:c.x(t),label:o(t,e,l)})),h=u.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Dr(u,Math.max(55,h+8))},[c,d,f,i,p]),m=r(()=>{var t,e;if(!c)return[];const n=null==d?void 0:d.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||g||Er,r=Math.max(2,Math.floor(o/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return Dr((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Or(c.y,"exact"===p?Math.max(2,s):Math.min(s,r),p)).map(t=>({value:t,pixel:c.y(t),label:i(t)})),22)},[c,d,g,o,p]),v=h&&c,b=u&&c;if(!v&&!b)return null;const x=null==d?void 0:d.find(t=>"bottom"===t.orient),k=null==d?void 0:d.find(t=>"left"===t.orient),w=b&&(!x||!1!==x.baseline),A=b&&(!k||!1!==k.baseline),S=(null==x?void 0:x.jaggedBase)||!1,M=(null==k?void 0:k.jaggedBase)||!1,_="var(--semiotic-border, #ccc)";return t("svg",{width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e("g",{transform:`translate(${l.left},${l.top})`,children:[v&&(()=>{var n,r;const s=jr(null===(n=null==d?void 0:d.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),a=jr(null===(r=null==d?void 0:d.find(t=>"left"===t.orient))||void 0===r?void 0:r.gridStyle);return e("g",{className:"stream-grid",children:[y.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"xgrid-"+n)),m.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:i,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:a},"ygrid-"+n))]})})(),w&&!S&&t("line",{x1:0,y1:o,x2:i,y2:o,stroke:_,strokeWidth:1}),S&&t("path",{d:zr("bottom",i,o),fill:"none",stroke:_,strokeWidth:1}),A&&!M&&t("line",{x1:0,y1:0,x2:0,y2:o,stroke:_,strokeWidth:1}),M&&t("path",{d:zr("left",i,o),fill:"none",stroke:_,strokeWidth:1})]})})}function Er(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Dr(t,e){if(2>=t.length)return t;const n=[t[0]];for(let i=1;t.length-1>i;i++)e>Math.abs(t[i].pixel-n[n.length-1].pixel)||n.push(t[i]);const i=t[t.length-1];return e>Math.abs(i.pixel-n[n.length-1].pixel)?n[n.length-1]=i:n.push(i),n}function Rr(i){var s,a;const{width:c,height:d,totalWidth:h,totalHeight:f,margin:g,scales:p,showAxes:y,axes:m,xLabel:v,yLabel:b,yLabelRight:x,xFormat:k,yFormat:w,axisExtent:A,showGrid:S,title:M,legend:_,legendHoverBehavior:P,legendClickBehavior:O,legendHighlightedCategory:T,legendIsolatedCategories:$,legendPosition:L="right",legendLayout:j,foregroundGraphics:z,marginalGraphics:C,xValues:E,yValues:D,annotations:R,svgAnnotationRules:F,xAccessor:N,yAccessor:B,annotationData:W,pointNodes:I,curve:Y,underlayRendered:G,canvasObscuresUnderlay:H=!0,linkedCrosshairName:X,linkedCrosshairSourceId:q,children:V}=i,U=r(()=>{var t,e;if(!y||!p)return[];const n=null==m?void 0:m.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||k||Er,o=Math.max(2,Math.floor(c/70)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5,s=null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Or(p.x,"exact"===A?Math.max(2,r):Math.min(r,o),A),a=s.map(t=>t.valueOf()),l=s.map((t,e)=>({value:t,pixel:p.x(t),label:i(t,e,a)})),u=l.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),d=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(u+8,55)):Math.max(55,u+8);let h=Dr(l,d);if(h.length>1&&(h=h.filter((t,e)=>0===e||t.label+""!=h[e-1].label+"")),(null==n?void 0:n.includeMax)&&h.length>0&&"exact"!==A&&!(null==n?void 0:n.tickValues)){const t=p.x.domain()[1],e=p.x(t),n=h[h.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t,h.length,a);d>e-n&&h.length>1&&(h=h.slice(0,-1)),h.push({value:t,pixel:e,label:o})}}return h},[y,p,m,k,c,A]),Z=r(()=>{var t,e;if(!y||!p)return[];const n=null==m?void 0:m.find(t=>"left"===t.orient),i=(null==n?void 0:n.tickFormat)||w||Er,o=Math.max(2,Math.floor(d/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let s=Dr((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Or(p.y,"exact"===A?Math.max(2,r):Math.min(r,o),A)).map(t=>({value:t,pixel:p.y(t),label:i(t)})),22);if(s.length>1&&(s=s.filter((t,e)=>0===e||t.label+""!=s[e-1].label+"")),(null==n?void 0:n.includeMax)&&s.length>0&&"exact"!==A&&!(null==n?void 0:n.tickValues)){const t=p.y.domain()[1],e=p.y(t),n=s[s.length-1].pixel;if(Math.abs(e-n)>1){const o=i(t);22>Math.abs(e-n)&&s.length>1&&(s=s.slice(0,-1)),s.push({value:t,pixel:e,label:o})}}return s},[y,p,m,w,d,A]),Q=r(()=>{var t,e;if(!y||!p)return[];const n=null==m?void 0:m.find(t=>"right"===t.orient);if(!n)return[];const i=n.tickFormat||w||Er,o=Math.max(2,Math.floor(d/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return Dr((null!==(e=n.tickValues)&&void 0!==e?e:Or(p.y,"exact"===A?Math.max(2,r):Math.min(r,o),A)).map(t=>({value:t,pixel:p.y(t),label:i(t)})),22)},[y,p,m,w,d,A]),tt=o(new Map),et=o(null!==(s=null==R?void 0:R.length)&&void 0!==s?s:0),nt=null!==(a=null==R?void 0:R.length)&&void 0!==a?a:0;et.current!==nt&&(et.current=nt,tt.current=new Map);const it=r(()=>{if(!R||0===R.length)return null;const n=function(n,i,o){var r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,M,_,P,O,T,$,L,j,z,C,E,D,R,F,N,B,W,I,Y,G,H,X,q,V,U,Z,Q,tt;switch(n.type){case"label":{const e=pr(n,i,o);if(!e)return null;const{x:r,y:s}=e;return yr(r,s,o)?t(hr,{noteData:{x:r,y:s,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"label",connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"callout":{const e=pr(n,i,o);if(!e)return null;const{x:r,y:s}=e;return yr(r,s,o)?t(hr,{noteData:{x:r,y:s,dx:n.dx||30,dy:n.dy||-30,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"callout-circle",subject:{radius:n.radius||12},connector:n.connector||{end:"arrow"},color:n.color}},"ann-"+i):null}case"x-threshold":{const r=fr(null!=n.value?Object.assign(Object.assign({},n),{x:n.value}):n,o);if(null==r)return null;const s=n.color||"#f97316",a=n.labelPosition||"top";let l;return l="bottom"===a?(o.height||0)-4:"center"===a?(o.height||0)/2:12,e("g",{children:[t("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:r+4,y:l,fill:s,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"y-threshold":{const r=gr(null!=n.value?Object.assign(Object.assign({},n),{y:n.value}):n,o);if(null==r)return null;const s=n.color||"#f97316",a=n.labelPosition||"right";let l,c;return"left"===a?(l=4,c="start"):"center"===a?(l=(o.width||0)/2,c="middle"):(l=(o.width||0)-4,c="end"),e("g",{children:[t("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:s,strokeWidth:n.strokeWidth||1.5,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:l,y:r-4,textAnchor:c,fill:s,fontSize:12,fontWeight:"bold",children:n.label})]},"ann-"+i)}case"enclose":{const r=(n.coordinates||[]).map(t=>({x:fr(Object.assign(Object.assign({},t),{type:"point"}),o),y:gr(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const s=at(r),a=n.padding||10;return e("g",{children:[t("circle",{cx:s.x,cy:s.y,r:s.r+a,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:s.x,y:s.y-s.r-a-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"rect-enclose":{const r=(n.coordinates||[]).map(t=>({x:fr(Object.assign(Object.assign({},t),{type:"point"}),o),y:gr(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>r.length)return null;const s=n.padding||10,a=r.map(t=>t.x),l=r.map(t=>t.y),c=Math.min(...a)-s,u=Math.max(...a)+s,d=Math.min(...l)-s,h=Math.max(...l)+s;return e("g",{children:[t("rect",{x:c,y:d,width:u-c,height:h-d,fill:n.fill||"none",fillOpacity:n.fillOpacity||.1,stroke:n.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),n.label&&t("text",{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:n.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:n.label})]},"ann-"+i)}case"highlight":{const e=o.data||[],r="function"==typeof n.filter?e.filter(n.filter):n.field&&null!=n.value?e.filter(t=>t[n.field]===n.value):[],s={stroke:n.color||"#f97316",strokeWidth:2,fill:"none"};return t("g",{children:r.map((e,i)=>{const r=fr(e,o),a=gr(e,o);if(null==r||null==a)return null;const l="function"==typeof n.r?n.r(e):n.r||6,c="function"==typeof n.style?n.style(e):n.style||s;return t("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+i)}case"bracket":{const e=fr(n,o),r=gr(n,o);return t(hr,{noteData:{x:null!=e?e:0,y:null!=r?r:0,dx:n.dx||0,dy:n.dy||0,note:{label:n.label,title:n.title,wrap:n.wrap||120},type:"bracket",subject:{type:n.bracketType||"curly",width:n.width,height:n.height,depth:n.depth||30},color:n.color}},"ann-"+i)}case"trend":{const h=o.data||[];if(2>h.length)return null;const f=o.xAccessor||"x",g=o.yAccessor||"y",p="ordinal"===o.frameType,y="horizontal"===o.projection,m=p?f:null,v=p?g:null;let b;const x=[],k=new Map;if(p&&m&&v){for(const t of h){const e=t[m];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,x.length),x.push(n))}b=h.map(t=>{const e=t[m],n=t[v];if(null==e||null==n)return null;const i=k.get(e+"");return null!=i?[i,+n]:null}).filter(t=>null!==t)}else b=h.map(t=>[t[f],t[g]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>b.length)return null;const w=null!==(s=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==s?s:null===(a=o.scales)||void 0===a?void 0:a.time,A=null!==(c=null===(l=o.scales)||void 0===l?void 0:l.y)&&void 0!==c?c:null===(u=o.scales)||void 0===u?void 0:u.value;if(!w||!A)return null;const S=t=>e=>{const n=Math.max(0,Math.floor(e)),i=Math.min(x.length-1,n+1),o=e-n,r=t(x[n]);return r+(t(x[i])-r)*o},M=w,_=A;let P;if(p)if(y){const t=S(_);P=(e,n)=>[M(n),t(e)]}else{const t=S(M);P=(e,n)=>[t(e),_(n)]}else P=(t,e)=>[M(t),_(e)];const O=n.method||"linear";let T;T="loess"===O?function(t,e=.3){const n=t.length;if(2>n)return t.slice();const i=t.slice().sort((t,e)=>t[0]-e[0]),o=i.map(t=>t[0]),r=i.map(t=>t[1]),s=Math.max(2,Math.ceil(e*n)),a=[];for(let t=0;n>t;t++){const e=o[t],i=o.map(t=>Math.abs(t-e)),l=i.slice().sort((t,e)=>t-e)[Math.min(s-1,n-1)]||1,c=[];for(let t=0;n>t;t++){const e=0===l?0:i[t]/l;c[t]=1>e?Math.pow(1-Math.pow(e,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let t=0;n>t;t++){const e=c[t];0!==e&&(u+=e,d+=e*o[t],h+=e*r[t],f+=e*o[t]*o[t],g+=e*o[t]*r[t])}if(0===u){a.push([e,r[t]]);continue}const p=u*f-d*d;if(1e-12>Math.abs(p))a.push([e,h/u]);else{const t=(u*g-d*h)/p;a.push([e,(h-t*d)/u+t*e])}}return a}(b,null!==(d=n.bandwidth)&&void 0!==d?d:.3):("polynomial"===O?wt.polynomial(b,{order:n.order||2}):wt.linear(b)).points;const $=T.map(([t,e])=>{const[n,i]=P(t,e);return`${n},${i}`}).join(" "),L=n.color||"#6366f1",j=T[T.length-1],[z,C]=P(j[0],j[1]);return e("g",{children:[t("polyline",{points:$,fill:"none",stroke:L,strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray||"6,3"}),n.label&&t("text",{x:z+4,y:C-4,fill:L,fontSize:11,children:n.label})]},"ann-"+i)}case"band":{const r=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value,s=null!==(p=null==r?void 0:r(n.y0))&&void 0!==p?p:0,a=null!==(y=null==r?void 0:r(n.y1))&&void 0!==y?y:o.height||0;return e("g",{children:[t("rect",{x:0,y:Math.min(s,a),width:o.width||0,height:Math.abs(a-s),fill:n.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:n.fillOpacity||.1}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(s,a)-4,textAnchor:"end",fill:n.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:n.label})]},"ann-"+i)}case"envelope":{const r=o.data||[];if(2>r.length)return null;const s=o.xAccessor||"x",a=null!==(v=null===(m=o.scales)||void 0===m?void 0:m.x)&&void 0!==v?v:null===(b=o.scales)||void 0===b?void 0:b.time,l=null!==(k=null===(x=o.scales)||void 0===x?void 0:x.y)&&void 0!==k?k:null===(w=o.scales)||void 0===w?void 0:w.value;if(!a||!l)return null;const c=n.upperAccessor||"upperBounds",u=n.lowerAccessor||"lowerBounds",d=n.filter,h=r.filter(t=>null!=t[c]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[s]-e[s]);if(2>h.length)return null;const f=mr[o.curve||"linear"]||J,g=K().x(t=>a(t[s])).y0(t=>l(t[u])).y1(t=>l(t[c])).curve(f)(h);if(!g)return null;const p=n.fill||"#6366f1";return e("g",{children:[t("path",{d:g,fill:p,fillOpacity:null!==(A=n.fillOpacity)&&void 0!==A?A:.15,stroke:"none"}),n.label&&h.length>0&&t("text",{x:a(h[h.length-1][s])+4,y:l(h[h.length-1][c])-4,fill:p,fontSize:11,children:n.label})]},"ann-"+i)}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const s=o.yAccessor||"y",a=null!==(M=null===(S=o.scales)||void 0===S?void 0:S.x)&&void 0!==M?M:null===(_=o.scales)||void 0===_?void 0:_.time,l=null!==(O=null===(P=o.scales)||void 0===P?void 0:P.y)&&void 0!==O?O:null===(T=o.scales)||void 0===T?void 0:T.value;if(!a||!l)return null;const c=r.map(t=>t[s]).filter(t=>null!=t&&isFinite(t));if(2>c.length)return null;const u=c.reduce((t,e)=>t+e,0)/c.length,d=c.reduce((t,e)=>t+Math.pow(e-u,2),0)/c.length,h=Math.sqrt(d),f=null!==($=n.threshold)&&void 0!==$?$:2,g=u-f*h,p=!1!==n.showBand,y=n.fill||"#6366f1",m=null!==(L=n.fillOpacity)&&void 0!==L?L:.1,v=n.anomalyColor||"#ef4444",b=null!==(j=n.anomalyRadius)&&void 0!==j?j:6,x=l(u+f*h),k=l(g),w=r.filter(t=>{const e=t[s];return null!=e&&Math.abs(e-u)>f*h});return e("g",{children:[p&&t("rect",{x:0,y:Math.min(x,k),width:o.width||0,height:Math.abs(k-x),fill:y,fillOpacity:m}),w.map((e,n)=>{const i=fr(e,o),r=gr(e,o);return null==i||null==r?null:t("circle",{cx:i,cy:r,r:b,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+n)}),n.label&&t("text",{x:(o.width||0)-4,y:Math.min(x,k)-4,textAnchor:"end",fill:y,fontSize:11,children:n.label})]},"ann-"+i)}case"forecast":{const r=o.data||[];if(3>r.length)return null;const s=o.xAccessor||"x",a=o.yAccessor||"y",l=null!==(C=null===(z=o.scales)||void 0===z?void 0:z.x)&&void 0!==C?C:null===(E=o.scales)||void 0===E?void 0:E.time,c=null!==(R=null===(D=o.scales)||void 0===D?void 0:D.y)&&void 0!==R?R:null===(F=o.scales)||void 0===F?void 0:F.value;if(!l||!c)return null;const u=r.map(t=>[t[s],t[a]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>u.length)return null;let d;if("polynomial"===(n.method||"linear")){const t=wt.polynomial(u,{order:n.order||2}).equation;d=e=>t.reduce((t,n,i)=>t+n*Math.pow(e,i),0)}else{const t=u.length;let e=0,n=0,i=0,o=0;for(const[t,r]of u)e+=t,n+=r,i+=t*t,o+=t*r;const r=t*i-e*e;if(1e-12>Math.abs(r))return null;const s=(t*o-e*n)/r,a=(n-s*e)/t;d=t=>a+s*t}const h=u.length,f=u.map(([t,e])=>e-d(t)).reduce((t,e)=>t+e*e,0),g=Math.sqrt(f/Math.max(h-2,1)),p=u.reduce((t,e)=>t+e[0],0)/h,y=u.reduce((t,e)=>t+Math.pow(e[0]-p,2),0),m=null!==(N=n.confidence)&&void 0!==N?N:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(B=n.steps)&&void 0!==B?B:5,x=u[h-1][0],k=(x-u[0][0])/Math.max(h-1,1),w=[];for(let t=1;b>=t;t++)w.push(x+t*k);const A=[];for(const t of w){const e=d(t),n=g*Math.sqrt(1+1/h+(y>0?Math.pow(t-p,2)/y:0))*v;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${l(t.x)},${c(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${l(t.x)},${c(t.yLower)}`).join(" L")} Z`,M=A.map(t=>`${l(t.x)},${c(t.yCenter)}`).join(" "),_=`${l(x)},${c(d(x))}`,P=n.strokeColor||"#6366f1";return e("g",{children:[t("path",{d:S,fill:n.fill||"#6366f1",fillOpacity:null!==(W=n.fillOpacity)&&void 0!==W?W:.15,stroke:"none"}),t("polyline",{points:`${_} ${M}`,fill:"none",stroke:P,strokeWidth:null!==(I=n.strokeWidth)&&void 0!==I?I:2,strokeDasharray:null!==(Y=n.strokeDasharray)&&void 0!==Y?Y:"6,3"}),n.label&&A.length>0&&t("text",{x:l(A[A.length-1].x)+4,y:c(A[A.length-1].yCenter)-4,fill:P,fontSize:11,children:n.label})]},"ann-"+i)}case"widget":{let e=null,r=null;if(null!=n.px&&null!=n.py)e=n.px,r=n.py;else{const t=pr(n,i,o);if(!t)return null;e=t.x,r=t.y}if(null==e||null==r)return null;if(!yr(e,r,o))return null;const s=null!==(G=n.dx)&&void 0!==G?G:0,a=null!==(H=n.dy)&&void 0!==H?H:0,l=null!==(X=n.width)&&void 0!==X?X:32,c=null!==(q=n.height)&&void 0!==q?q:32,u=null!==(V=n.content)&&void 0!==V?V:t("span",{style:{fontSize:18,cursor:"default"},title:n.label||"Info",children:"ℹ️"});return t("foreignObject",{x:e+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+i)}case"text":{const e=pr(n,i,o);if(!e)return null;const{x:r,y:s}=e;return t("text",{x:r+(n.dx||0),y:s+(n.dy||0),fill:n.color||"var(--semiotic-text, #333)",fontSize:n.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:n.label},"ann-text-"+i)}case"category-highlight":{const r=n.category;if(null==r)return null;const s=t=>"function"==typeof t&&"function"==typeof t.bandwidth,a=null===(U=o.scales)||void 0===U?void 0:U.o,l=null===(Z=o.scales)||void 0===Z?void 0:Z.x,c=null===(Q=o.scales)||void 0===Q?void 0:Q.y,u=s(a)?a:s(l)?l:s(c)?c:null;if(!u)return null;const d=u(r+"");if(null==d)return null;const h=u.bandwidth(),f=n.color||"var(--semiotic-primary, #4589ff)",g=null!==(tt=n.opacity)&&void 0!==tt?tt:.15,p=n.label;return e("g",(o.projection?"vertical"===o.projection:u===l)?{children:[t("rect",{x:d,y:0,width:h,height:o.height||0,fill:f,fillOpacity:g}),p&&t("text",{x:d+h/2,y:12,textAnchor:"middle",fill:f,fontSize:12,fontWeight:"bold",children:p})]}:{children:[t("rect",{x:0,y:d,width:o.width||0,height:h,fill:f,fillOpacity:g}),p&&t("text",{x:12,y:d+h/2,dominantBaseline:"middle",fill:f,fontSize:12,fontWeight:"bold",children:p})]},"ann-"+i)}default:return null}},i={scales:p?{x:p.x,y:p.y,time:p.x,value:p.y}:null,timeAxis:"x",xAccessor:N,yAccessor:B,width:c,height:d,data:W,frameType:"xy",pointNodes:I,curve:Y,stickyPositionCache:tt.current};return R.map((t,e)=>{if(F){const o=F(t,e,i);return null!=o?o:n(t,e,i)}return n(t,e,i)}).filter(Boolean)},[R,F,c,d,N,B,W,p,I,Y]),ot=function(t){var e;const n=l(t?Sr:_r,t?Ar:Pr,t?Ar:Pr);return t&&null!==(e=n.positions.get(t))&&void 0!==e?e:null}(X);return u(()=>{if(!(null==ot?void 0:ot.locked)||!X)return;const t=t=>{"Escape"===t.key&&wr(X)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==ot?void 0:ot.locked,X]),y||M||_||z||C||it&&it.length>0||S||V||ot?e("svg",{role:"img",width:h,height:f,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t("title",{children:"string"==typeof M?M:"XY Chart"}),t("desc",{children:"string"==typeof M?M+" — XY data visualization":"XY data visualization"}),e("g",{transform:`translate(${g.left},${g.top})`,children:[S&&p&&(!G||H)&&(()=>{var n,i;const o=jr(null===(n=null==m?void 0:m.find(t=>"bottom"===t.orient))||void 0===n?void 0:n.gridStyle),r=jr(null===(i=null==m?void 0:m.find(t=>"left"===t.orient))||void 0===i?void 0:i.gridStyle);return e("g",{className:"stream-grid",children:[U.map((e,n)=>t("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:d,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),Z.map((e,n)=>t("line",{x1:0,y1:e.pixel,x2:c,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),y&&p&&(()=>{const n=null==m?void 0:m.find(t=>"left"===t.orient),i=null==m?void 0:m.find(t=>"bottom"===t.orient),o=!n||!1!==n.baseline,r=!i||!1!==i.baseline,s=(null==n?void 0:n.jaggedBase)||!1,a=(null==i?void 0:i.jaggedBase)||!1,l=null==i?void 0:i.landmarkTicks,u=null==n?void 0:n.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",y=!!(null==i?void 0:i.autoRotate)&&U.length>1&&(()=>{const t=c/Math.max(U.length-1,1),e=U.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0);return e+8>t})(),k={fontSize:"var(--semiotic-tick-font-size, 10px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 10px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=null==i?void 0:i.tickAnchor,M=null==n?void 0:n.tickAnchor,_=Lr(U),P=Lr(Z);return e("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!G||H)&&r&&!a&&t("line",{x1:0,y1:d,x2:c,y2:d,stroke:h,strokeWidth:1}),(!G||H)&&a&&t("path",{d:zr("bottom",c,d),fill:"none",stroke:h,strokeWidth:1}),U.map((n,i)=>{const o=!!l&&("function"==typeof l?l(n.value,i):Ao(n.value,i>0?U[i-1].value:void 0));return e("g",{transform:`translate(${n.pixel},${d})`,children:[t("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{y:y?10:18,textAnchor:y?"end":Tr(S,n.pixel===_.min,n.pixel===_.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w:k),transform:y?"rotate(-45)":void 0,children:n.label}):t("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"center",userSelect:"none"},k),children:n.label})})]},"xtick-"+i)}),v&&t("text",{x:c/2,y:d+40,textAnchor:"middle",fill:p,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:v})]}),e("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!G||H)&&o&&!s&&t("line",{x1:0,y1:0,x2:0,y2:d,stroke:h,strokeWidth:1}),(!G||H)&&s&&t("path",{d:zr("left",c,d),fill:"none",stroke:h,strokeWidth:1}),Z.map((n,i)=>{const o=!!u&&("function"==typeof u?u(n.value,i):Ao(n.value,i>0?Z[i-1].value:void 0));return e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:-8,textAnchor:"end",dominantBaseline:$r(M,n.pixel===P.min,n.pixel===P.max),fontWeight:o?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w:k),children:n.label}):t("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"right",userSelect:"none"},k),children:n.label})})]},"ytick-"+i)}),(()=>{const e=(null==n?void 0:n.label)||b;return e?t("text",{x:15-g.left,y:d/2,textAnchor:"middle",fill:p,transform:`rotate(-90, ${15-g.left}, ${d/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:e}):null})()]}),(()=>{const n=null==m?void 0:m.find(t=>"right"===t.orient);if(!n||0===Q.length)return null;const i=!1!==n.baseline,o=n.landmarkTicks,r=n.label||x,s=n.tickAnchor,a=Lr(Q);return e("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[i&&t("line",{x1:c,y1:0,x2:c,y2:d,stroke:h,strokeWidth:1}),Q.map((n,i)=>{const r=!!o&&("function"==typeof o?o(n.value,i):Ao(n.value,i>0?Q[i-1].value:void 0));return e("g",{transform:`translate(${c},${n.pixel})`,children:[t("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.label?t("text",{x:8,textAnchor:"start",dominantBaseline:$r(s,n.pixel===a.min,n.pixel===a.max),fontWeight:r?600:400,fill:f,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},r?w:k),children:n.label}):t("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t("div",{style:Object.assign({textAlign:"left",userSelect:"none"},k),children:n.label})})]},"ytick-r-"+i)}),r&&t("text",{x:c+g.right-15,y:d/2,textAnchor:"middle",fill:p,transform:`rotate(90, ${c+g.right-15}, ${d/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},A),children:r})]})})()]})})(),it,C&&p&&E&&D&&e(n,{children:[C.top&&t("g",{transform:"translate(0, 0)",children:t(rr,{orient:"top",config:or(C.top),values:E,scale:p.x,size:g.top,length:c})}),C.bottom&&t("g",{transform:`translate(0, ${d})`,children:t(rr,{orient:"bottom",config:or(C.bottom),values:E,scale:p.x,size:g.bottom,length:c})}),C.left&&t("g",{transform:"translate(0, 0)",children:t(rr,{orient:"left",config:or(C.left),values:D,scale:p.y,size:g.left,length:d})}),C.right&&t("g",{transform:`translate(${c}, 0)`,children:t(rr,{orient:"right",config:or(C.right),values:D,scale:p.y,size:g.right,length:d})})]}),z,ot&&ot.sourceId!==q&&(null==p?void 0:p.x)&&(()=>{const e=p.x(ot.xValue);if(null==e||0>e||e>c)return null;const n=ot.locked;return t("line",{x1:e,y1:0,x2:e,y2:d,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),V]}),M&&t("text",{x:h/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof M?M:null}),ir({legend:_,totalWidth:h,totalHeight:f,margin:g,legendPosition:L,title:M,legendLayout:j,legendHoverBehavior:P,legendClickBehavior:O,legendHighlightedCategory:T,legendIsolatedCategories:$})]}):null}const Fr="undefined"!=typeof window?h:u,Nr=()=>()=>{},Br=()=>!1,Wr=()=>!0;function Ir(t,e){const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;if(!Object.is(t[i],e[i]))return!1}return!0}function Yr(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function Gr(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}const Hr=i.createContext(null),Xr={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function qr(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t){if(null===(null==e?void 0:e.datum))continue;const t=e.type+"";n[t]=(n[t]||0)+1}if(0===Object.keys(n).length)return e+", empty";const i=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((t,e)=>{const n=r.indexOf(t),i=r.indexOf(e);return(-1===n?999:n)-(-1===i?999:i)});for(const t of s)i.push(`${n[t]} ${o[t]||t}`);return`${e}, ${i.join(", ")}`}const Vr=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},Ur="semiotic-accessible-data-table",Zr=Ur+" semiotic-accessible-data-table-hidden",Qr=Ur+" semiotic-accessible-data-table-visible",Kr={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Jr={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},ts={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},es={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ns={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},is={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},os={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #999))",marginBottom:4,fontStyle:"italic"};function rs({scene:n,chartType:o,tableId:r,chartTitle:s}){var a;const[l,c]=i.useState(!1),u=i.useContext(Hr),d=null!==(a=null==u?void 0:u.visible)&&void 0!==a&&a,h=l||d,f=i.useRef(null),g=s?"Data summary for "+s:r?`Data summary for ${o} ${r}`:"Data summary for "+o,p=i.useCallback(()=>{l||d||c(!0)},[l,d]),y=i.useCallback(t=>{var e;d||(null===(e=f.current)||void 0===e?void 0:e.contains(t.relatedTarget))||c(!1)},[d]);if(!n||0===n.length)return r?t("span",{id:r,tabIndex:-1,style:Xr}):null;if(!h)return t("div",{id:r,className:Zr,tabIndex:-1,onFocus:p,style:Xr,role:"region","aria-label":g,children:e("button",{type:"button",onClick:()=>c(!0),children:["View data summary (",n.length," elements)"]})});const m=function(t){var e,n,i,o,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,k,w,A,S,M;const _=[];if(!Array.isArray(t))return _;for(const P of t)if(P&&"object"==typeof P&&null!==P.datum)try{switch(P.type){case"point":_.push({label:"Point",values:{x:P.x,y:P.y}});break;case"line":{const t=P.path,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Line point",values:{x:e[0],y:e[1]}})}break}case"area":{const t=P.topPath,e=Array.isArray(P.datum)?P.datum:[];if(!Array.isArray(t))break;for(let n=0;t.length>n&&e.length>n;n++){const e=t[n];Array.isArray(e)&&_.push({label:"Area point",values:{x:e[0],y:e[1]}})}break}case"rect":{const t=null!=P.datum&&"object"==typeof P.datum?P.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:P.group)&&void 0!==n?n:"",s=null!==(o=null!==(i=t.value)&&void 0!==i?i:t.__aggregateValue)&&void 0!==o?o:t.total;_.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":_.push({label:"Cell",values:{x:P.x,y:P.y,value:P.value}});break;case"wedge":_.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=P.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=P.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=P.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":_.push({label:"Node",values:{id:null!==(h=null===(d=P.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=P.cx)&&void 0!==f?f:P.x,y:null!==(g=P.cy)&&void 0!==g?g:P.y}});break;case"arc":_.push({label:"Arc",values:{id:null!==(y=null===(p=P.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=P.cx)&&void 0!==m?m:P.x,y:null!==(v=P.cy)&&void 0!==v?v:P.y}});break;case"candlestick":_.push({label:"Candlestick",values:{x:P.x,open:P.open,high:P.high,low:P.low,close:P.close}});break;case"geoarea":_.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=P.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=P.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(M=null===(S=P.datum)||void 0===S?void 0:S.value)&&void 0!==M?M:""}})}}catch(t){}return _}(n),v=function(t){if(!t||0===t.length)return[];const e=new Set;for(const n of t)if(n&&n.values)for(const t of Object.keys(n.values))e.add(t);const n=[];for(const i of e){const e=[],o=new Set;for(const n of t){if(!n||!n.values)continue;const t=n.values[i];null!=t&&""!==t&&("number"==typeof t&&!Number.isNaN(t)&&Number.isFinite(t)?e.push(t):"number"==typeof t||"object"!=typeof t&&"function"!=typeof t&&o.add(t+""))}if(e.length>0){let t=e[0],o=e[0],r=0;for(const n of e)t>n&&(t=n),n>o&&(o=n),r+=n;n.push({name:i,count:e.length,numeric:!0,min:t,max:o,mean:r/e.length})}else if(o.size>0){const t=Array.from(o);n.push({name:i,count:t.length,numeric:!1,uniqueValues:t.slice(0,5)})}}return n}(m),b=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${Vr(t.min)} to ${Vr(t.max)}, mean ${Vr(t.mean)}.`);else{const e=t.uniqueValues,i=e.length>3?`${e.slice(0,3).join(", ")}… (${t.count} unique)`:e.join(", ");n.push(`${t.name}: ${i}.`)}return n.join(" ")}(m.length,v),x=m.slice(0,5),k=new Set;for(const t of x)for(const e of Object.keys(t.values))k.add(e);const w=Array.from(k);return e("div",{ref:f,id:r,className:Qr,tabIndex:-1,onBlur:y,style:Kr,role:"region","aria-label":g,children:[t("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&u&&u.setVisible(!1),c(!1)},"aria-label":"Close data summary",style:ts,children:"×"}),t("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Jr,children:b}),e("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+o,style:es,children:[e("caption",{className:"semiotic-accessible-data-table-caption",style:os,children:["First ",x.length," of ",m.length," data points"]}),t("thead",{children:e("tr",{children:[t("th",{style:ns,children:"type"}),w.map(e=>t("th",{style:ns,children:e},e))]})}),t("tbody",{children:x.map((n,i)=>e("tr",{children:[t("td",{style:is,children:n.label}),w.map(e=>{return t("td",{style:is,children:(i=n.values[e],null==i||""===i?"—":"number"==typeof i?Number.isNaN(i)?"—":Vr(i):"boolean"==typeof i?i?"true":"false":"object"==typeof i?"—":i+"")},e);var i})]},i))})]})]})}function ss({summary:e}){return e?t("div",{role:"note",style:Xr,children:e}):null}function as({tableId:e}){return t("a",{href:"#"+e,style:Xr,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:t=>{Object.assign(t.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:t=>{const e=t.currentTarget;e.removeAttribute("style"),Object.assign(e.style,Xr)},children:"Skip to data table"})}function ls({hoverPoint:e}){let n="";if(e){const t=e.data||e;n="object"==typeof t?"Focused on data point: "+Object.entries(t).filter(([,t])=>"object"!=typeof t&&"function"!=typeof t).map(([t,e])=>`${t}: ${e}`).join(", "):"Focused on data point: "+t}return t("div",{"aria-live":"polite","aria-atomic":"true",style:Xr,children:n})}const cs="var(--semiotic-focus, #005fcc)";function us({active:e,hoverPoint:n,margin:i,size:o,shape:r="circle",width:s,height:a}){if(!e||!n)return null;const l=n.x+i.left,c=n.y+i.top;let u;if("rect"===r&&null!=s&&null!=a){const e=Math.max(s,4),n=Math.max(a,4);u=t("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:cs,strokeWidth:2,strokeDasharray:"4,2"})}else u=t("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:cs,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:cs,strokeWidth:2,strokeDasharray:"4,2"});return t("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function ds({x:e,y:n,containerWidth:o,containerHeight:r,margin:s,children:a,className:l="stream-frame-tooltip",zIndex:c=1}){const u=Number.isFinite(e)&&Number.isFinite(n),d=i.useRef(null),[h,f]=i.useState(null);i.useLayoutEffect(()=>{const t=d.current;if(!t)return;const e=t.getBoundingClientRect();f(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[a,l,o,r]);let g;g=h?`translate(${h.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${h.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`;const p=function(t){if(!i.isValidElement(t))return!1;const e=t.type;if("string"!=typeof e&&e&&!0===e.ownsChrome)return!0;const n=t.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(a),y=p?null:uo;return u?t("div",{ref:d,className:p?l:(l+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:s.left+e,top:s.top+n,transform:g,pointerEvents:"none",zIndex:c,width:"max-content"}),children:a}):null}const hs="undefined"==typeof window?u:h;function fs(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function gs(t){const e=function(){const[t,e]=d(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return u(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return e(t.matches),function(t,e){if("function"==typeof t.addEventListener)return t.addEventListener("change",e),()=>t.removeEventListener("change",e);const n=t;return n.addListener(e),()=>n.removeListener(e)}(t,t=>e(t.matches))},[]),t}(),n=o(e);n.current=e;const[s,l]=function(t,e,n){const i=o(null),[r,s]=d(null);return u(()=>{if(!e&&!n)return;const t=i.current;if(!t)return;const o=new ResizeObserver(t=>{for(const e of t){const{width:t,height:n}=e.contentRect;s(e=>e&&e.w===t&&e.h===n?e:{w:t,h:n})}});return o.observe(t),()=>o.disconnect()},[e,n]),[i,[e&&r?r.w:t[0],n&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),c=r(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),h=l[0]-c.left-c.right,f=l[1]-c.top-c.bottom,g=fs(t.foregroundGraphics,l,c),p=fs(t.backgroundGraphics,l,c),y=Mi(t=>t.theme),{transition:m,introEnabled:v}=function(t,e){var n,i;if(!1===t)return{transition:void 0,introEnabled:!1};const o="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:t?!0===t?{duration:300}:{duration:null!==(i=t.duration)&&void 0!==i?i:300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(o||!t||!0!==t&&!1===t.intro)}}(t.animate,t.transitionProp),b="semiotic-table-"+i.useId(),x=o(0),k=o(()=>{}),w=a(()=>{x.current||(x.current=requestAnimationFrame(()=>k.current()))},[]);u(()=>()=>{x.current&&(cancelAnimationFrame(x.current),x.current=0)},[]);const A=o(()=>{}),S=o(()=>{}),M=o(null),_=o(0),P=a(()=>{_.current=0;const t=M.current;M.current=null,t&&A.current(t)},[]),O=a(t=>{M.current={clientX:t.clientX,clientY:t.clientY},0===_.current&&(_.current=requestAnimationFrame(P))},[P]),T=a(()=>{M.current=null,0!==_.current&&(cancelAnimationFrame(_.current),_.current=0),S.current()},[]);u(()=>()=>{M.current=null,0!==_.current&&(cancelAnimationFrame(_.current),_.current=0)},[]);const $=t.themeDirtyRef;return hs(()=>{$&&(_o++,$.current=!0,w())},[y,w,$]),{reducedMotion:e,reducedMotionRef:n,responsiveRef:s,size:l,margin:c,adjustedWidth:h,adjustedHeight:f,resolvedForeground:g,resolvedBackground:p,currentTheme:y,transition:m,introEnabled:v,tableId:b,rafRef:x,renderFnRef:k,scheduleRender:w,hoverHandlerRef:A,hoverLeaveRef:S,onPointerMove:O,onPointerLeave:T}}function ps(t,e,n,i){const o=t.getContext("2d");if(!o)return null;const r=e[0]*i,s=e[1]*i,a=e[0]+"px",l=e[1]+"px";return t.style.width!==a&&(t.style.width=a),t.style.height!==l&&(t.style.height=l),t.width===r&&t.height===s||(t.width=r,t.height=s),o.setTransform(i,0,0,i,0,0),o.translate(n.left,n.top),o}function ys(t,e,n){let i=n;for(const n of e)"lesser"===n.thresholdType?n.value>t&&(i=n.color):t>n.value&&(i=n.color);return i}function ms(t,e,n,i,o,r){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const n=e[t][0]-e[t-1][0],i=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(n*n+i*i))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);t.strokeStyle=n,t.lineWidth=i,t.lineCap=r;for(let n=0;e.length-1>n;n++){const i=(s[n]+s[n+1])/2;let r=o;l>i&&(r*=i/l),l>a-i&&(r*=(a-i)/l),t.globalAlpha=Math.max(0,r),t.beginPath(),t.moveTo(e[n][0],e[n][1]),t.lineTo(e[n+1][0],e[n+1][1]),t.stroke()}}const vs=(t,e,n,i)=>{var o,r;const s=e.filter(t=>"line"===t.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(t.save(),t.beginPath(),t.rect(0,0,i.width*l,i.height),t.clip());const c=a.style.stroke||"#007bff",u=Lo(t,c)||c,d=a.style.strokeWidth||2,h=a.colorThresholds,f=a.rawValues;if(t.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(t.globalAlpha=a.style.opacity),t.lineWidth=d,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(o=a.style.opacity)&&void 0!==o?o:1;ms(t,a.path,u,d,m,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const g=jo(a.curve),p=h&&h.length>0&&f&&f.length===a.path.length,y=a._decayOpacities;if(y&&y.length===a.path.length&&!p){t.strokeStyle=u;const v=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(y[b]+y[b+1])*v,t.beginPath(),t.moveTo(a.path[b][0],a.path[b][1]),t.lineTo(a.path[b+1][0],a.path[b+1][1]),t.stroke()}else if(p){let x=null,k=null,w=null,A=null,S=!1;function M(e,n,i){t.beginPath(),t.strokeStyle=e,t.moveTo(n,i),S=!0}function _(){S&&(t.stroke(),S=!1)}for(let P=0;a.path.length>P;P++){const[O,T]=a.path[P],$=f[P],L=ys($,h,u);if(null!==x&&null!==A&&null!==w){if(L===A)t.lineTo(O,T);else{const j=[];for(const z of h){const C=z.value;(w>C||C>$)&&(C>w||$>C)||w===C||$===C||j.push({t:(C-w)/($-w)})}j.sort((t,e)=>t.t-e.t);for(const E of j){const D=x+(O-x)*E.t,R=k+(T-k)*E.t,F=ys(w+($-w)*Math.min(E.t+1e-4,1),h,u);t.lineTo(D,R),_(),M(F,D,R)}t.lineTo(O,T)}x=O,k=T,w=$,A=L}else M(L,O,T),x=O,k=T,w=$,A=L}_()}else{t.beginPath();const N=a.strokeGradient&&a.path.length>=2?Eo(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=N||u,g)Q().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[B,W]=a.path[0];t.moveTo(B,W);for(let I=1;a.path.length>I;I++)t.lineTo(a.path[I][0],a.path[I][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=zo(t,a.style.fill,a.style.fill),g&&!p)Q().x(t=>t[0]).y(t=>t[1]).curve(g).context(t)(a.path);else{const[G,H]=a.path[0];t.moveTo(G,H);for(let X=1;a.path.length>X;X++)t.lineTo(a.path[X][0],a.path[X][1])}const Y=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],i.height),t.lineTo(Y,i.height),t.closePath(),t.fill()}void 0!==l&&1>l&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function bs(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function xs(t,e,n=.3){bs(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function ks(t,e,n=.6){var i,o,r,s,a;if(!bs(e))return;const l=null!==(i=e._pulseGlowRadius)&&void 0!==i?i:4,c=e.r+l*e._pulseIntensity,u=null!==(r=null!==(o=e.cx)&&void 0!==o?o:e.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=e.cy)&&void 0!==s?s:e.y)&&void 0!==a?a:0;t.beginPath(),t.arc(u,d,c,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function ws(t,e,n,i=.35){bs(e)&&(t.globalAlpha=e._pulseIntensity*i,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function As(t,e){const n=jo(e.curve);if(!n||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1]);for(let n=e.bottomPath.length-1;n>=0;n--)t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]);t.closePath()}else{const i=K().x(t=>t[0]).y0((t,n)=>e.bottomPath[n][1]).y1(t=>t[1]).curve(n).context(t);t.beginPath(),i(e.topPath)}}const Ss=(t,e,n,i)=>{var o,r,s;const a=e.filter(t=>"area"===t.type);for(const e of a){if(2>e.topPath.length)continue;let n=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),n=!0);const a=e._introClipFraction;void 0!==a&&1>a&&(t.save(),t.beginPath(),t.rect(0,0,i.width*a,i.height),t.clip());const l=zo(t,e.style.fill,"#4e79a7"),c=e._decayOpacities;if(c&&c.length===e.topPath.length){const n=null!==(o=e.style.fillOpacity)&&void 0!==o?o:.7;t.fillStyle=l;for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(c[i]+c[i+1])*n,t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.lineTo(e.bottomPath[i+1][0],e.bottomPath[i+1][1]),t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Lo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(c[n]+c[n+1]),t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.stroke()}t.globalAlpha=1;continue}const u=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(As(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let n=1/0;for(const t of e.topPath)n>t[1]&&(n=t[1]);let i=-1/0;for(const t of e.bottomPath)t[1]>i&&(i=t[1]);const o=Co(t,e.fillGradient,"string"==typeof l?l:"#4e79a7",0,n,0,i);t.fillStyle=o||l,t.globalAlpha=u}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*u,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(As(t,e),ws(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=u;const n=e.strokeGradient&&e.topPath.length>=2?Eo(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Lo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const i=jo(e.curve);if(t.beginPath(),i)Q().x(t=>t[0]).y(t=>t[1]).curve(i).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let n=1;e.topPath.length>n;n++)t.lineTo(e.topPath[n][0],e.topPath[n][1])}t.stroke()}void 0!==a&&1>a&&t.restore(),n&&t.restore(),t.globalAlpha=1}},Ms=(t,e,n,i)=>{var o;const r=e.filter(t=>"point"===t.type);if(0!==r.length){t.save();try{for(const e of r){t.beginPath(),t.arc(e.x,e.y,e.r,0,2*Math.PI);const n=null!==(o=e.style.opacity)&&void 0!==o?o:e.style.fillOpacity;null!=n&&(t.globalAlpha=n),t.fillStyle=zo(t,e.style.fill,"#4e79a7"),t.fill(),e.style.stroke&&(t.strokeStyle=zo(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth||1,t.stroke()),ks(t,e),t.globalAlpha=1}}finally{t.restore()}}};function _s(t,e){const{x:n,y:i,w:o,h:r}=e,{tl:s,tr:a,br:l,bl:c}=si(e);t.beginPath(),t.moveTo(n+s,i),t.lineTo(n+o-a,i),a>0&&t.arcTo(n+o,i,n+o,i+a,a),t.lineTo(n+o,i+r-l),l>0&&t.arcTo(n+o,i+r,n+o-l,i+r,l),t.lineTo(n+c,i+r),c>0&&t.arcTo(n,i+r,n,i+r-c,c),t.lineTo(n,i+s),s>0&&t.arcTo(n,i,n+s,i,s),t.closePath()}function Ps(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}const Os=(t,e,n,i)=>{const o=e.filter(t=>"rect"===t.type);for(const e of o){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Ts(t,e);else if(e.cornerRadii&&ri(e.cornerRadii)){const n=zo(t,e.style.fill,Lo(t,"var(--semiotic-primary, #007bff)")),i=Ps(e),o=e.fillGradient&&"string"==typeof n?Co(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,_s(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Lo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=zo(t,e.style.fill,Lo(t,"var(--semiotic-primary, #007bff)")),i=Ps(e),o=e.fillGradient&&"string"==typeof n?Co(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n;const r=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:s,y:a,w:l,h:c}=e;switch(e.roundedEdge){case"right":t.moveTo(s,a),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s,a+c);break;case"left":t.moveTo(s+l,a),t.lineTo(s+r,a),t.arcTo(s,a,s,a+r,r),t.lineTo(s,a+c-r),t.arcTo(s,a+c,s+r,a+c,r),t.lineTo(s+l,a+c);break;case"bottom":t.moveTo(s,a),t.lineTo(s+l,a),t.lineTo(s+l,a+c-r),t.arcTo(s+l,a+c,s+l-r,a+c,r),t.lineTo(s+r,a+c),t.arcTo(s,a+c,s,a+c-r,r);break;default:t.moveTo(s,a+c),t.lineTo(s,a+r),t.arcTo(s,a,s+r,a,r),t.lineTo(s+l-r,a),t.arcTo(s+l,a,s+l,a+r,r),t.lineTo(s+l,a+c)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Lo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=zo(t,e.style.fill,Lo(t,"var(--semiotic-primary, #007bff)")),i=Ps(e),o=e.fillGradient&&"string"==typeof n?Co(t,e.fillGradient,n,i.x0,i.y0,i.x1,i.y1):null;t.fillStyle=o||n,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Lo(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}xs(t,e),t.globalAlpha=1}};function Ts(t,e){const n=e.style.icon,i=e.style.iconPadding||2,o=Math.min(e.w,e.h)-i;if(0>=o)return;const r=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),r){const r=o+i,s=e.x+(e.w-o)/2;for(let i=e.y+e.h-o;i>=e.y-o;i-=r)t.drawImage(n,s,i,o,o)}else{const r=o+i,s=e.y+(e.h-o)/2;for(let i=e.x;e.x+e.w>i;i+=r)t.drawImage(n,i,s,o,o)}t.restore()}function $s(t){const[e,n,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*n+.114*i>128?"#000":"#fff"}function Ls(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const js=(t,e,n,i)=>{const o=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of o){const n=e.style;if(null!=(null==n?void 0:n.opacity)&&(t.globalAlpha=n.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h),t.strokeStyle=Lo(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),xs(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const n=e.valueFormat?e.valueFormat(e.value):Ls(e.value),i=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),o=e.x+e.w/2,r=e.y+e.h/2;t.fillStyle=$s(e.fill),t.font=i+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,o,r)}}}finally{t.restore()}},zs=(t,e,n,i)=>{var o,r,s;for(const n of e){if("candlestick"!==n.type)continue;const e=n;t.save();const a=(null!==(o=e._decayOpacity)&&void 0!==o?o:1)*(null!==(s=null===(r=e.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(t.globalAlpha=a);const l=Lo(t,e.wickColor)||e.wickColor,c=60>i.height,u=c?Math.max(e.wickWidth,2):e.wickWidth,d=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=l,t.lineWidth=u,t.stroke()};if(c||d(),e.isRange){const n=Math.max(2,Math.min(e.bodyWidth/2,.12*i.height));t.fillStyle=l,t.beginPath(),t.arc(e.x,e.highY,n,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,n,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const n=Math.min(e.openY,e.closeY),i=Math.abs(e.openY-e.closeY),o=e.isUp?e.upColor:e.downColor,r=Lo(t,o)||o;t.fillStyle=r,t.fillRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1)),t.strokeStyle=r,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,n,e.bodyWidth,Math.max(i,1))}c&&d(),t.restore()}};function Cs(t,e,n,i){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:i,fn:e}:{key:void 0,fn:null}}const Es=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ds(t){const e=t[1]-t[0],n=3156e7;return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:n>e?t=>{const e=new Date(t);return`${Es[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${Es[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const Rs={line:[Ss,vs,Ms],area:[Ss,Ms],stackedarea:[Ss,Ms],scatter:[Ms],bubble:[Ms],heatmap:[js],bar:[Os],swarm:[Ms],waterfall:[(t,e,n,i)=>{var o;Os(t,e);const r=e.filter(t=>"rect"===t.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){t.save(),t.strokeStyle=Lo(t,a)||a,t.lineWidth=null!==(o=null==s?void 0:s._connectorWidth)&&void 0!==o?o:1,t.setLineDash([]);for(let e=0;r.length-1>e;e++){const i=r[e],o=r[e+1],s=i.datum,a=o.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=i.x+i.w,u=o.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[zs],mixed:[Ss,vs,Ms],custom:[Ss,Os,js,vs,Ms,zs]},Fs={top:20,right:20,bottom:30,left:40},Ns={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff"};function Bs(t,e){const n=t.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const t=n[1],i=n[2],o=n[3];return`#${t}${t}${i}${i}${o}${o}${e}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${e}`;const i=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return i?`rgba(${i[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:n}const Ws={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Is({hover:n}){var i,o,r;const s=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",a=null!==(i=n.data)&&void 0!==i?i:{},l=null!==(o=a.y)&&void 0!==o?o:a.value,c=null!==(r=a.x)&&void 0!==r?r:a.time;return e("div",{className:"semiotic-tooltip",style:Ws,children:[t("div",{style:{fontWeight:600,marginBottom:2},children:s(l)}),t("div",{style:{opacity:.7,fontSize:11},children:s(c)})]})}Is.ownsChrome=!0;const Ys=f(function(n,s){var c,h,f,y,m,v,b,x,k,w,A,S,M;const{chartType:_,runtimeMode:P,data:O,chunkThreshold:T,chunkSize:$,xAccessor:L,yAccessor:j,colorAccessor:z,sizeAccessor:C,groupAccessor:E,lineDataAccessor:D,curve:R,normalize:F,baseline:N,stackOrder:B,binSize:W,valueAccessor:I,arrowOfTime:Y="right",windowMode:G="sliding",windowSize:H=200,timeAccessor:X,xExtent:q,yExtent:V,extentPadding:U=.1,scalePadding:Z,sizeRange:Q,size:K=[500,300],responsiveWidth:J,responsiveHeight:tt,margin:et,className:nt,background:it,lineStyle:ot,pointStyle:rt,areaStyle:st,barStyle:at,waterfallStyle:lt,swarmStyle:ct,barColors:ut,colorScheme:dt,boundsAccessor:ht,boundsStyle:ft,y0Accessor:gt,band:pt,gradientFill:yt,lineGradient:mt,areaGroups:vt,openAccessor:bt,highAccessor:xt,lowAccessor:kt,closeAccessor:wt,candlestickStyle:At,showAxes:St=!0,axes:Mt,xLabel:_t,yLabel:Pt,yLabelRight:Ot,xFormat:Tt,yFormat:$t,axisExtent:Lt,tickFormatTime:jt,tickFormatValue:zt,hoverAnnotation:Ct,tooltipContent:Et,customHoverBehavior:Dt,customClickBehavior:Rt,enableHover:Ft,hoverRadius:Nt=30,tooltipMode:Bt,annotations:Wt,svgAnnotationRules:It,showGrid:Yt,legend:Gt,legendHoverBehavior:Ht,legendClickBehavior:Xt,legendHighlightedCategory:qt,legendIsolatedCategories:Vt,legendPosition:Ut,legendLayout:Zt,legendCategoryAccessor:Qt,onCategoriesChange:Kt,backgroundGraphics:Jt,foregroundGraphics:te,canvasPreRenderers:ee,svgPreRenderers:ne,title:ie,categoryAccessor:oe,brush:re,onBrush:se,decay:ae,pulse:le,transition:ce,animate:ue,staleness:de,heatmapAggregation:he,heatmapXBins:fe,heatmapYBins:ge,showValues:pe,heatmapValueFormat:ye,marginalGraphics:me,pointIdAccessor:ve,xScaleType:xe,yScaleType:ke,accessibleTable:we=!0,description:Ae,summary:Se,linkedCrosshairName:Me,linkedCrosshairSourceId:_e,customLayout:Oe,layoutConfig:Te}=n,$e=g().replace(/:/g,""),Le=o(!1),je=gs({sizeProp:K,responsiveWidth:J,responsiveHeight:tt,userMargin:et,marginDefault:Fs,animate:ue,transitionProp:ce,themeDirtyRef:Le}),ze=function(){const[t,e]=d(!1);return Fr(()=>{e(!0)},[]),t}(),Ce=function(){const t=l(Nr,Br,Wr);return o(t).current}(),{reducedMotionRef:Ee,responsiveRef:De,size:Re,currentTheme:Fe,transition:Ne,introEnabled:Be,tableId:We,rafRef:Ie,renderFnRef:Ye,scheduleRender:Ge}=je;let He=je.margin;if(me){const t=60,e=Object.assign({},je.margin);me.top&&t>e.top&&(e.top=t),me.bottom&&t>e.bottom&&(e.bottom=t),me.left&&t>e.left&&(e.left=t),me.right&&t>e.right&&(e.right=t),He=e}const Xe="function"==typeof te?te({size:Re,margin:He}):te,qe="function"==typeof Jt?Jt({size:Re,margin:He}):Jt,Ve=Re[0]-He.left-He.right,Ue=Re[1]-He.top-He.bottom,Ze=r(()=>ao(O),[O]),Qe=null!=Ct?Ct:Ft,Ke=o(null),Je=o(null),[tn,en]=d(0),[nn,on]=d(null),rn=o(null),sn=o(null),[an,ln]=d(null),cn=o(Ns.primary),un=o([]),dn=o(Qt),hn=o(Kt);dn.current=Qt,hn.current=Kt;const[fn,gn]=d(!1),[pn,yn]=d([]),[mn,vn]=d([]),bn="streaming"===P||["bar","swarm","waterfall"].includes(_),xn=r(()=>{var t,e,n;return{chartType:_,runtimeMode:bn?"streaming":"bounded",windowSize:H,windowMode:G,arrowOfTime:bn?Y:"right",extentPadding:U,scalePadding:Z,axisExtent:Lt,xAccessor:L,yAccessor:j,timeAccessor:bn?X:void 0,valueAccessor:I,colorAccessor:z,sizeAccessor:C,groupAccessor:E||(D?"_lineGroup":void 0),categoryAccessor:oe,lineDataAccessor:D,xScaleType:xe,yScaleType:ke,xExtent:q,yExtent:V,sizeRange:Q,binSize:W,normalize:F,baseline:N,stackOrder:B,boundsAccessor:ht,boundsStyle:ft,y0Accessor:gt,band:pt,gradientFill:!0===yt?{topOpacity:.8,bottomOpacity:.05}:!1===yt?void 0:yt,areaGroups:vt?new Set(vt):void 0,lineGradient:mt,openAccessor:bt,highAccessor:xt,lowAccessor:kt,closeAccessor:wt,candlestickStyle:At,lineStyle:ot,pointStyle:rt,areaStyle:st,swarmStyle:ct,waterfallStyle:lt,colorScheme:dt,barColors:ut,barStyle:at,annotations:Wt,decay:ae,pulse:le,transition:Ne,introAnimation:Be,staleness:de,heatmapAggregation:he,heatmapXBins:fe,heatmapYBins:ge,showValues:pe,heatmapValueFormat:ye,pointIdAccessor:ve,curve:R,themeCategorical:null===(t=null==Fe?void 0:Fe.colors)||void 0===t?void 0:t.categorical,themeSemantic:mi(Fe),themeSequential:null===(e=null==Fe?void 0:Fe.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==Fe?void 0:Fe.colors)||void 0===n?void 0:n.diverging,customLayout:Oe,layoutConfig:Te,layoutMargin:He}},[_,H,G,Y,U,Z,Lt,L,j,X,I,xe,ke,z,C,E,oe,D,q,V,Q,W,F,N,B,ht,ft,gt,pt,yt,mt,vt,bt,xt,kt,wt,At,ot,rt,st,ct,lt,at,dt,ut,Wt,ae,le,null==Ne?void 0:Ne.duration,null==Ne?void 0:Ne.easing,Be,de,he,fe,ge,pe,ye,bn,ve,R,Fe,Oe,Te,He]),kn=function(t){const e=o(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return Yr(t,e);if(!Gr(t)||!Gr(e))return!1;const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const i of n){if(!Object.prototype.hasOwnProperty.call(e,i))return!1;const n=t[i],o=e[i];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!Yr(n,o))return!1}else{if(!Gr(n)||!Gr(o))return!1;if(!Ir(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}(xn),wn=o(null);wn.current||(wn.current=new Pe(kn));const An=a(()=>{var t,e;const n=dn.current,i=hn.current;if(!i||!n)return;const o=function(t,e){if(!e)return[];const n=new Set,i=[];for(const o of t){if(!o||"object"!=typeof o)continue;const t="function"==typeof e?e(o):o[e];if(null==t)continue;const r=t+"";n.has(r)||(n.add(r),i.push(r))}return i}(null!==(e=null===(t=wn.current)||void 0===t?void 0:t.getData())&&void 0!==e?e:[],n);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(o,un.current)||(un.current=o,i(o))},[]);u(()=>{var t;null===(t=wn.current)||void 0===t||t.updateConfig(kn),Le.current=!0,Ge()},[kn,Ge]);const Sn=o(null);Sn.current||(Sn.current=new vo(t=>{const e=wn.current;e&&e.ingest(t)&&(Le.current=!0,Ge())},{chunkThreshold:T,chunkSize:$})),u(()=>{var t;null===(t=Sn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:T,chunkSize:$})},[T,$]);const Mn=a(t=>{var e;null===(e=Sn.current)||void 0===e||e.push(t)},[]),_n=a(t=>{var e;null===(e=Sn.current)||void 0===e||e.pushMany(t)},[]),Pn=a(()=>{var t,e;null===(t=Sn.current)||void 0===t||t.clear(),null===(e=wn.current)||void 0===e||e.clear(),Le.current=!0,Ge()},[Ge]);p(s,()=>({push:Mn,pushMany:_n,remove:t=>{var e,n,i;null===(e=Sn.current)||void 0===e||e.flush();const o=null!==(i=null===(n=wn.current)||void 0===n?void 0:n.remove(t))&&void 0!==i?i:[];return o.length>0&&(rn.current&&o.some(t=>{var e;return t===(null===(e=rn.current)||void 0===e?void 0:e.data)})&&(rn.current=null,ln(null)),Le.current=!0,Ge()),o},update:(t,e)=>{var n,i,o;null===(n=Sn.current)||void 0===n||n.flush();const r=null!==(o=null===(i=wn.current)||void 0===i?void 0:i.update(t,e))&&void 0!==o?o:[];return r.length>0&&(Le.current=!0,Ge()),r},clear:Pn,getData:()=>{var t,e,n;return null===(t=Sn.current)||void 0===t||t.flush(),null!==(n=null===(e=wn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=wn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=wn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[Mn,_n,Pn,Ge]),u(()=>{var t,e;if(O){if(D&&Ze.length>0&&"object"==typeof Ze[0]&&null!==Ze[0]){const e="string"==typeof D?D:"coordinates";if(Array.isArray(Ze[0][e])){const n=[];for(const t of Ze){const i=t[e];if(Array.isArray(i)){const e=t.label||t.id||t.key;if(null!=e)for(const t of i)n.push(Object.assign(Object.assign({},t),{_lineGroup:e}));else for(const t of i)n.push(t)}}return void(null===(t=Sn.current)||void 0===t||t.setBoundedData(n))}}null===(e=Sn.current)||void 0===e||e.setBoundedData(Ze)}},[O,Ze,D]);const{hoverHandlerRef:On,hoverLeaveRef:Tn,onPointerMove:$n,onPointerLeave:Ln}=je;On.current=t=>{var e,n;if(!Qe)return;const i=Ke.current;if(!i)return;const o=i.getBoundingClientRect(),r=t.clientX-o.left-He.left,s=t.clientY-o.top-He.top;if(0>r||r>Ve||0>s||s>Ue)return void(rn.current&&(rn.current=null,sn.current=null,ln(null),Dt&&(Dt(null),Le.current=!0),Ge()));const a=wn.current;if(!a||0===a.scene.length)return;const l=Fo(a.scene,r,s,Nt,a.quadtree,a.maxPointRadius),c="multi"===Bt,u=()=>{rn.current&&(rn.current=null,sn.current=null,ln(null),Dt&&Dt(null),Ge())};if(!l&&!c)return void u();const d=c||!l?r:l.x,h=c||!l?s:l.y;let f=co((null==l?void 0:l.datum)?be(l.datum,a.resolvedRibbons):{},d,h);if(c&&a.scene.length>0&&a.scales){const t=function(t,e,n=30){const i=[];for(const o of t)if("line"===o.type){const t=o;if(2>t.path.length)continue;const r=No(Ro(t.path,t.curve),e,n);if(null===r)continue;const s=qo(t.path,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:t.path[s][0],y:r,group:t.group,color:t.style.stroke})}else if("area"===o.type){const t=o;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const r=Ro(t.topPath,t.curve),s=Ro(t.bottomPath,t.curve),a=No(r,e,n);if(null===a)continue;const l=No(s,e,n),c=qo(t.topPath,e);i.push({node:o,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:null!=l?l:void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return i}(a.scene,d,Math.max(Nt,Ve));if(t.length>0){const e=a.scales.y.invert,n=a.scales.x.invert,i=cn.current,o=n?n(d):d;if(l)f.xValue=o,f.xPx=d;else{const t={xValue:o};"string"==typeof L&&(t[L]=o),f=co(t,d,h,{xValue:o,xPx:d})}f.allSeries=t.map(t=>{const n=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===_&&null!=o?n-o:n,valuePx:t.y,color:t.color||i,datum:be(t.datum,a.resolvedRibbons)}})}}l||(null===(e=f.allSeries)||void 0===e?void 0:e.length)?(rn.current=f,sn.current=null!==(n=null==l?void 0:l.node)&&void 0!==n?n:null,ln(f),Dt&&(Dt(f),Le.current=!0),Ge()):u()},Tn.current=()=>{rn.current&&(rn.current=null,sn.current=null,ln(null),Dt&&(Dt(null),Le.current=!0),Ge())};const jn=o(()=>{});jn.current=t=>{if(!Rt)return;const e=Ke.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-He.left,o=t.clientY-n.top-He.top;if(0>i||i>Ve||0>o||o>Ue)return void Rt(null);const r=wn.current;if(!r||0===r.scene.length)return void Rt(null);const s=Fo(r.scene,i,o,Nt,r.quadtree,r.maxPointRadius);Rt(s?co(s.datum||{},s.x,s.y):null)};const zn=a(t=>jn.current(t),[]),Cn=o(-1),En=o(null),Dn=o(null),Rn=a(t=>{const e=wn.current;if(!e||0===e.scene.length)return;const n=e.version;let i;if(Dn.current&&Dn.current.version===n)i=Dn.current.graph;else{const t=function(t){var e,n,i;const o=[];for(const r of t)switch(r.type){case"point":o.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=null!==(e=t.group)&&void 0!==e?e:"_default";for(let e=0;t.path.length>e&&n.length>e;e++)o.push({x:t.path[e][0],y:t.path[e][1],datum:n[e],shape:"circle",group:i});break}case"area":{const t=r,e=Array.isArray(t.datum)?t.datum:[],i=null!==(n=t.group)&&void 0!==n?n:"_default";for(let n=0;t.topPath.length>n&&e.length>n;n++)o.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:e[n],shape:"circle",group:i});break}case"rect":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(i=r.group)&&void 0!==i?i:"_default"});break;case"heatcell":o.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return o.sort((t,e)=>t.x-e.x||t.y-e.y),o}(e.scene);if(0===t.length)return;i=function(t){var e,n;const i=new Map;for(const n of t){const t=null!==(e=n.group)&&void 0!==e?e:"_default";let o=i.get(t);o||(o=[],i.set(t,o)),o.push(n)}for(const t of i.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const o=Array.from(i.keys()).sort((t,e)=>{const n=i.get(t),o=i.get(e);return(n.length>0?n[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(i.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const s=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=null===(n=r[t].datum)||void 0===n?void 0:n.id;null!=e&&s.set(e+"",t)}return{flat:r,groups:o,byGroup:i,idToIdx:s}}(t),Dn.current={version:n,graph:i}}const o=Cn.current;if(0>o){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Cn.current=0;const n=i.flat[0];En.current={shape:n.shape,w:n.w,h:n.h};const o=Uo(Object.assign(Object.assign({},n),{datum:be(n.datum,e.resolvedRibbons)}));return rn.current=o,ln(o),Dt&&Dt(o),void Ge()}const r=function(t,e){var n,i;if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const o=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[o];return{flatIndex:o,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(i=r._groupIndex)&&void 0!==i?i:0}}(i,o),s=function(t,e,n){const{group:i,indexInGroup:o}=e,r=n.byGroup.get(i);switch(t){case"ArrowRight":return r.length-1>o?r[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?r[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(i);return n.groups.length-1>t?Vo(n,n.groups[t+1],r[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(i);return t>0?Vo(n,n.groups[t-1],r[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(t.key,r,i);if(null===s)return;if(t.preventDefault(),0>s)return Cn.current=-1,En.current=null,rn.current=null,sn.current=null,ln(null),Dt&&Dt(null),void Ge();Cn.current=s;const a=i.flat[s];En.current={shape:a.shape,w:a.w,h:a.h};const l=Uo(Object.assign(Object.assign({},a),{datum:be(a.datum,e.resolvedRibbons)}));rn.current=l,ln(l),Dt&&Dt(l),Ge()},[Dt,Ge]),Fn=a(t=>{Cn.current=-1,En.current=null,$n(t)},[$n]);Ye.current=()=>{var t,e;Ie.current=0;const n=Ke.current,i=Je.current;if(!n||!i)return;const o=wn.current;if(!o)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=o.advanceTransition(Ee.current?r+1e6:r),a=!Ee.current&&s,l=Le.current||s;l&&!a&&(o.computeScene({width:Ve,height:Ue}),An());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return Ns;const e=getComputedStyle(t),n=e.getPropertyValue("--semiotic-border").trim(),i=e.getPropertyValue("--semiotic-text-secondary").trim(),o=e.getPropertyValue("--semiotic-bg").trim(),r=e.getPropertyValue("--semiotic-primary").trim(),s=i||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=n||e.getPropertyValue("--surface-3").trim(),c=o||e.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||Ns.axisStroke,tickText:s||Ns.tickText,crosshair:s?Bs(s,"66"):Ns.crosshair,hoverFill:c?Bs(c,"4D"):Ns.hoverFill,hoverStroke:s?Bs(s,"99"):Ns.hoverStroke,pointRing:c||Ns.pointRing,primary:r||Ns.primary}:Ns}(n);cn.current=u.primary;const d=null!==(t=null==de?void 0:de.threshold)&&void 0!==t?t:5e3,h=de&&o.lastIngestTime>0&&r-o.lastIngestTime>d;if(l){const t=ps(n,Re,He,c);if(t){if(t.clearRect(-He.left,-He.top,Re[0],Re[1]),h&&(t.globalAlpha=null!==(e=null==de?void 0:de.dimOpacity)&&void 0!==e?e:.5),"transparent"!==it&&!Jt){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),i=it||(e&&"transparent"!==e?e:null),o=i?Lo(t,i):null;o&&(t.fillStyle=o,t.fillRect(-He.left,-He.top,Re[0],Re[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Ve,Ue),t.clip()),ee&&o.scales)for(const e of ee)t.save(),e(t,o.scene,o.scales,{width:Ve,height:Ue}),t.restore();const i=Oe?Rs.custom:Rs[_];if(i&&o.scales)for(const e of i)e(t,o.scene,o.scales,{width:Ve,height:Ue});t.restore(),h&&(t.globalAlpha=1)}}{const t=ps(i,Re,He,c);if(t&&(t.clearRect(-He.left,-He.top,Re[0],Re[1]),Qe&&rn.current&&o.scales&&function(t,e,n,i,o,r,s){var a;if(!1===o.crosshair)return;const l=e.allSeries,c=l&&l.length>0,u=null!==(a=e.xPx)&&void 0!==a?a:e.x;t.save();const d="object"==typeof o.crosshair?o.crosshair:{};if(t.strokeStyle=d.stroke||s.crosshair,t.lineWidth=d.strokeWidth||1,t.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?u:e.x,0),t.lineTo(c?u:e.x,i),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(n,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=s.pointRing;for(const e of l)null!=e.valuePx&&(t.beginPath(),t.arc(u,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||s.primary,t.fill(),t.stroke())}else{const n=o.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const n="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||n||null:n||e.stroke||null}(r)||s.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=n,t.fill(),t.strokeStyle=s.pointRing,t.lineWidth=2,t.stroke()}}(t,rn.current,Ve,Ue,"object"==typeof Qe?Qe:{},sn.current,u),sn.current&&Array.isArray(Ct))){const e=Ct.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,i,o){var r;if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of e){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const e="function"==typeof i.style?n.datum?i.style(n.datum):{}:i.style||{};t.save(),t.beginPath(),t.moveTo(n.path[0][0],n.path[0][1]);for(let e=1;n.path.length>e;e++)t.lineTo(n.path[e][0],n.path[e][1]);t.strokeStyle=e.stroke||n.style.stroke||o.primary,t.lineWidth=e.strokeWidth||(n.style.strokeWidth||2)+2,t.globalAlpha=null!==(r=e.opacity)&&void 0!==r?r:1,t.stroke(),t.restore()}}(t,o.scene,sn.current,e,u)}}l&&n&&n.setAttribute("aria-label",qr(o.scene,_+" chart"));const f=Le.current;if(Le.current=!1,f&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!nn||t(nn.x.domain()[0])!==t(o.scales.x.domain()[0])||t(nn.x.domain()[1])!==t(o.scales.x.domain()[1])||t(nn.y.domain()[0])!==t(o.scales.y.domain()[0])||t(nn.y.domain()[1])!==t(o.scales.y.domain()[1])||nn.x.range()[0]!==o.scales.x.range()[0]||nn.x.range()[1]!==o.scales.x.range()[1]||nn.y.range()[0]!==o.scales.y.range()[0]||nn.y.range()[1]!==o.scales.y.range()[1])&&on(o.scales),me){const t=o.getData(),e="function"==typeof L?L:t=>t[L||"x"],n="function"==typeof j?j:t=>t[j||"y"];yn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),vn(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&Wt&&Wt.length>0&&en(t=>t+1),(null==de?void 0:de.showBadge)&&gn(!!h),(a||null!=o.activeTransition||o.hasActivePulses)&&(Ie.current=requestAnimationFrame(()=>Ye.current()))},function(t){const{hydrated:e,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=t;Fr(()=>{var t,o;e&&n&&(null===(o=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===o||o.call(t)),r.current=!0,s.current()},[e,n]);const l=o(a);l.current=a,u(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:ze,wasHydratingFromSSR:Ce,storeRef:wn,dirtyRef:Le,renderFnRef:Ye,cleanup:()=>{var t;return null===(t=Sn.current)||void 0===t?void 0:t.clear()}}),u(()=>{Le.current=!0,Ge()},[_,Ve,Ue,St,it,ot,ee,Ge]),function(t,e,n,i,o,r){u(()=>{if(!t)return;const s=setInterval(()=>{var s;const a=e.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(s=t.threshold)&&void 0!==s?s:5e3,u=l-a.lastIngestTime>c;u!==o&&(r(u),n.current=!0,i())},1e3);return()=>clearInterval(s)},[t,o,i])}(de,wn,Le,Ge,fn,gn);const Nn=r(()=>{if(Tt||jt)return;const t=wn.current;return(null==t?void 0:t.xIsDate)&&nn?Ds(nn.x.domain()):void 0},[Tt,jt,nn]),Bn=Tt||jt||Nn,Wn=Qe&&an?Et?Et(an):t(Is,{hover:an}):null,In=Wn?t(ds,{x:an.x,y:an.y,containerWidth:Ve,containerHeight:Ue,margin:He,className:"stream-frame-tooltip",children:Wn}):null,Yn=En.current,Gn=t(us,{active:Cn.current>=0,hoverPoint:an,margin:He,size:Re,shape:null==Yn?void 0:Yn.shape,width:null==Yn?void 0:Yn.w,height:null==Yn?void 0:Yn.h}),Hn=Cs(L,X,"__semiotic_resolvedX","__semiotic_resolvedTime"),Xn=Cs(j,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),qn=Hn.key,Vn=Xn.key,Un=function(t,e,n){return i=>{if(!i||!n||!t.fn&&!e.fn)return i;let o=!1;const r=i.map(n=>{const i=t.fn&&t.key&&!(t.key in n),r=e.fn&&e.key&&!(e.key in n);if(!i&&!r)return n;o=!0;const s=Object.assign({},n);return i&&(s[t.key]=t.fn(n)),r&&(s[e.key]=e.fn(n)),s});return o?r:i}}(Hn,Xn,Wt&&Wt.length>0||!1);if(gi||!ze&&Ce){const n=wn.current;n&&O&&(n.ingest({inserts:Ze,bounded:!0}),n.computeScene({width:Ve,height:Ue}));const o=null!==(c=null==n?void 0:n.scene)&&void 0!==c?c:[],r=null!==(h=null==n?void 0:n.scales)&&void 0!==h?h:null,s=Bn||(()=>{if((null==n?void 0:n.xIsDate)&&r)return Ds(r.x.domain())})();return e("div",{ref:De,className:"stream-xy-frame"+(nt?" "+nt:""),role:"img","aria-label":Ae||("string"==typeof ie?ie:"XY chart"),style:{position:"relative",width:J?"100%":Re[0],height:tt?"100%":Re[1]},children:[t(ss,{summary:Se}),e("svg",{xmlns:"http://www.w3.org/2000/svg",width:Re[0],height:Re[1],style:{position:"absolute",left:0,top:0},children:[t("g",{transform:`translate(${He.left},${He.top})`,children:qe}),e("g",{transform:`translate(${He.left},${He.top})`,children:[it&&t("rect",{x:0,y:0,width:Ve,height:Ue,fill:it}),ne&&r&&ne.map((e,n)=>t(i.Fragment,{children:e(o,r,{width:Ve,height:Ue})},"svgpre-"+n)),o.map((t,e)=>hi(t,e,$e)).filter(Boolean)]})]}),t(Rr,{width:Ve,height:Ue,totalWidth:Re[0],totalHeight:Re[1],margin:He,scales:r,showAxes:St,axes:Mt,xLabel:_t,yLabel:Pt,yLabelRight:Ot,xFormat:s,yFormat:$t||zt,axisExtent:Lt,showGrid:Yt,title:ie,legend:Gt,legendHoverBehavior:Ht,legendClickBehavior:Xt,legendHighlightedCategory:qt,legendIsolatedCategories:Vt,legendPosition:Ut,legendLayout:Zt,foregroundGraphics:bo(Xe,null===(f=wn.current)||void 0===f?void 0:f.customLayoutOverlays),marginalGraphics:me,xValues:[],yValues:[],annotations:Wt,svgAnnotationRules:It,annotationFrame:0,xAccessor:qn,yAccessor:Vn,annotationData:Un(null==n?void 0:n.getData()),pointNodes:null==n?void 0:n.scene.filter(t=>"point"===t.type),curve:"string"==typeof R?R:void 0,linkedCrosshairName:Me,linkedCrosshairSourceId:_e})]})}return e("div",{ref:De,className:"stream-xy-frame"+(nt?" "+nt:""),role:"group","aria-label":Ae||("string"==typeof ie?ie:"XY chart"),tabIndex:0,style:{position:"relative",width:J?"100%":Re[0],height:tt?"100%":Re[1],overflow:"visible"},onKeyDown:Rn,children:[we&&t(as,{tableId:We}),we&&t(rs,{scene:null!==(m=null===(y=wn.current)||void 0===y?void 0:y.scene)&&void 0!==m?m:[],chartType:_+" chart",tableId:We,chartTitle:"string"==typeof ie?ie:void 0}),t(ss,{summary:Se}),e("div",{role:"img","aria-label":Ae||("string"==typeof ie?ie:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Qe?Fn:void 0,onMouseLeave:Qe?Ln:void 0,onClick:Rt?zn:void 0,children:[qe&&t("svg",{style:{position:"absolute",left:0,top:0,width:Re[0],height:Re[1],pointerEvents:"none"},children:t("g",{transform:`translate(${He.left},${He.top})`,children:qe})}),t(Cr,{width:Ve,height:Ue,totalWidth:Re[0],totalHeight:Re[1],margin:He,scales:nn,showAxes:St,axes:Mt,showGrid:Yt,xFormat:Bn,yFormat:$t||zt,axisExtent:Lt}),t("canvas",{ref:Ke,"aria-label":qr(null!==(b=null===(v=wn.current)||void 0===v?void 0:v.scene)&&void 0!==b?b:[],_+" chart"),style:{position:"absolute",left:0,top:0}}),t("canvas",{ref:Je,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t(ls,{hoverPoint:an}),t(Rr,{width:Ve,height:Ue,totalWidth:Re[0],totalHeight:Re[1],margin:He,scales:nn,showAxes:St,axes:Mt,xLabel:_t,yLabel:Pt,yLabelRight:Ot,xFormat:Bn,yFormat:$t||zt,axisExtent:Lt,showGrid:Yt,title:ie,legend:Gt,legendHoverBehavior:Ht,legendClickBehavior:Xt,legendHighlightedCategory:qt,legendIsolatedCategories:Vt,legendPosition:Ut,legendLayout:Zt,foregroundGraphics:bo(Xe,null===(x=wn.current)||void 0===x?void 0:x.customLayoutOverlays),marginalGraphics:me,xValues:pn,yValues:mn,annotations:Wt,svgAnnotationRules:It,annotationFrame:tn,xAccessor:qn,yAccessor:Vn,annotationData:Un(null===(k=wn.current)||void 0===k?void 0:k.getData()),pointNodes:null===(w=wn.current)||void 0===w?void 0:w.scene.filter(t=>"point"===t.type),curve:"string"==typeof R?R:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==it&&!Jt,linkedCrosshairName:Me,linkedCrosshairSourceId:_e}),(re||se)&&t(mo,{width:Ve,height:Ue,totalWidth:Re[0],totalHeight:Re[1],margin:He,dimension:null!==(A=null==re?void 0:re.dimension)&&void 0!==A?A:"xy",scales:nn,onBrush:null!=se?se:()=>{},binSize:W,snap:null==re?void 0:re.snap,binBoundaries:null!==(S=null==re?void 0:re.binBoundaries)&&void 0!==S?S:"bar"===_?null===(M=wn.current)||void 0===M?void 0:M.getBinBoundaries():void 0,snapDuring:null==re?void 0:re.snapDuring,streaming:"streaming"===P}),(null==de?void 0:de.showBadge)&&t("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===de.badgePosition?{top:4,left:4}:"bottom-left"===de.badgePosition?{bottom:4,left:4}:"bottom-right"===de.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:fn?"#dc3545":"#28a745",color:"white"}),children:fn?"STALE":"LIVE"}),Gn,In]})]})});Ys.displayName="StreamXYFrame";const Gs=c(null);function Hs(){return s(Gs)}function Xs(t){const e=[];for(const[n,i]of Object.entries(t.fields))if("point"===i.type)e.push(t=>i.values.has(t[n]));else{const[t,o]=i.range;e.push(e=>{const i=e[n];return i>=t&&o>=i})}return t=>e.every(e=>e(t))}function qs(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}const[Vs,Us]=pi(t=>({selections:new Map,setClause(e,n){t(t=>{const i=new Map(t.selections),o=qs(i,e),r=new Map(o.clauses);return r.set(n.clientId,n),i.set(e,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},clearClause(e,n){t(t=>{const i=t.selections.get(e);if(!i)return{};const o=new Map(t.selections),r=new Map(i.clauses);return r.delete(n),o.set(e,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},setResolution(e,n){t(t=>{const i=new Map(t.selections),o=qs(i,e);return i.set(e,Object.assign(Object.assign({},o),{resolution:n})),{selections:i}})},clearSelection(e){t(t=>{const n=new Map(t.selections),i=n.get(e);return i&&n.set(e,Object.assign(Object.assign({},i),{clauses:new Map})),{selections:n}})}})),[Zs,Qs]=pi(t=>({observations:[],maxObservations:100,version:0,pushObservation(e){t(t=>{const n=t.observations;return n.push(e),n.length>t.maxObservations&&n.shift(),{version:t.version+1}})},clearObservations(){t(()=>({observations:[],version:0}))}}));function Ks(t){const e=g(),n=t.clientId||e,{name:i}=t,o=Us(t=>t.selections.get(i)),s=Us(t=>t.setClause),l=Us(t=>t.clearClause),c=r(()=>!!o&&o.clauses.size>0,[o]);return{predicate:r(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[i,o]of t.clauses)"crossfilter"===t.resolution&&i===e||n.push(Xs(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:c,selectPoints:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"point",values:new Set(i)};s(i,{clientId:n,type:"point",fields:e})},[n,i,s]),selectInterval:a(t=>{const e={};for(const[n,i]of Object.entries(t))e[n]={type:"interval",range:i};s(i,{clientId:n,type:"interval",fields:e})},[n,i,s]),clear:a(()=>{l(i,n)},[l,i,n]),clientId:n}}const Js=c(!1),ta=c(null),ea="undefined"==typeof window?u:h;function na(t,e,n){var i;const o=null!==(i=t.xValue)&&void 0!==i?i:null==e?void 0:e[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function ia(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?Object.assign(Object.assign({},e),{xValue:t.xValue}):e||{}}function oa(){var t;const e=Mi(t=>t.theme),n=null===(t=null==e?void 0:e.colors)||void 0===t?void 0:t.categorical;return n&&n.length>0?n:void 0}function ra({data:t,colorBy:e,colorScale:n,showLegend:i,legendPosition:a="right",userMargin:l,defaults:c={top:50,bottom:60,left:70,right:40},categories:u}){const d=s(Js),h=null!==s(ta),f=void 0!==i?i:!d&&!!e,p=!!e&&(f||h),y=r(()=>{if(!p)return[];if(void 0!==u)return u;const n=new Set;for(const i of t){const t="function"==typeof e?e(i):i[e];null!=t&&n.add(t+"")}return Array.from(n)},[u,e,t,p]);!function(t){const e=s(ta),n=g(),i=function(t){const e=new Set,n=[];for(const i of t)e.has(i)||(e.add(i),n.push(i));return n}(t),r=o([]);(function(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(t[n]!==e[n])return!1;return!0})(r.current,i)||(r.current=i);const a=r.current;ea(()=>{if(e)return()=>e.unregisterCategories(n)},[e,n]),ea(()=>{e&&e.registerCategories(n,a)},[e,n,a])}(h&&e?y:[]);const m=r(()=>{if(!f||!e)return;const i=function({data:t,colorBy:e,colorScale:n,getColor:i,strokeColor:o,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(t.map(t=>"function"==typeof e?e(t):t[e])))).map((o,r)=>{const s=t.find("function"==typeof e?t=>e(t)===o:t=>t[e]===o),a=s?i(s,e,n):n?n(o):ie[r%ie.length];return{label:o+"",color:a}});return{legendGroups:[{styleFn:t=>{const e=t.color||"#333",n={fill:e,stroke:e};return void 0!==o&&(n.stroke=o),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}({data:t,colorBy:e,colorScale:n,getColor:re,categories:y}),o=i.legendGroups.reduce((t,e)=>t+e.items.length,0);return 0!==o?i:void 0},[f,e,t,n,y]),v=r(()=>{const t="number"==typeof l?{top:l,bottom:l,left:l,right:l}:null!=l?l:{},e=e=>{const n=t[e];return"number"==typeof n?n:c[e]},n={top:e("top"),right:e("right"),bottom:e("bottom"),left:e("left")},i=e=>"number"==typeof t[e];return m&&("right"===a&&!i("right")&&110>n.right?n.right=110:"left"===a&&!i("left")&&110>n.left?n.left=110:"top"===a&&!i("top")&&50>n.top?n.top=50:"bottom"===a&&!i("bottom")&&80>n.bottom&&(n.bottom=80)),n},[c,l,m,a]);return{legend:m,margin:v,legendPosition:a}}i.createContext(void 0);const sa={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function aa(t,e,n){if(!1!==e)return t;const i=Object.assign({},t);return"horizontal"===n?i.left=Math.min(i.left,15):i.bottom=Math.min(i.bottom,15),i}function la({componentName:n,message:i,diagnosticHint:o,width:r,height:s}){return t("div",{role:"alert",style:{width:r,height:Math.max(s,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:e("div",{style:{textAlign:"center",maxWidth:400},children:[t("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:n}),t("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:i}),o&&t("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class ca extends i.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,e){var n,i;null===(i=(n=this.props).onError)||void 0===i||i.call(n,t,e)}render(){if(this.state.error){const{fallback:e}=this.props,n=this.state.error;return"function"==typeof e?e(n):void 0!==e?e:t(la,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function ua({componentName:e,width:n,height:i,children:o}){return t(ca,{fallback:o=>t(la,{componentName:e,message:o.message,width:n,height:i}),children:o})}"undefined"!=typeof process&&process;const da={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},ha={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function fa(e){const{data:n,rawData:i,colorBy:o,colorScheme:s,legendInteraction:l,legendPosition:c,selection:h,linkedHover:f,fallbackFields:p,unwrapData:y=!1,onObservation:m,chartType:v,chartId:b,showLegend:x,userMargin:k,marginDefaults:w,onClick:A,hoverHighlight:S,loading:M,loadingContent:_,emptyContent:P,width:O,height:T}=e,$=void 0===i,L=r(()=>ao(n),[n]),[j,z]=d([]),C=a(t=>{z(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),E="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:D,hoverSelectionHook:R,customHoverBehavior:F,customClickBehavior:N,crosshairSourceId:B}=function({selection:t,linkedHover:e,fallbackFields:n=[],unwrapData:i=!1,onObservation:o,chartType:s,chartId:l,onClick:c,hoverHighlight:h,colorByField:f}){const p=g(),y=function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField}:null}(e,n),m=Ks({name:(null==t?void 0:t.name)||"__unused__"}),v=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:i,isActive:o,selectPoints:r,clear:s}=Ks({name:e});return{onHover:a(t=>{if(!t)return void s();const e={};for(const i of n){const n=t[i];void 0!==n&&(e[i]=[n])}Object.keys(e).length>0&&r(e)},[n,r,s,e]),predicate:i,isActive:o}}({name:(null==y?void 0:y.name)||"hover",fields:(null==y?void 0:y.fields)||n||[]}),b=Qs(t=>t.pushObservation),x=t?{isActive:m.isActive,predicate:m.predicate}:null,[k,w]=d(null),A=f||n[0],S=r(()=>{if(!h||null==k||!A)return null;const t=k,e=A;return{isActive:!0,predicate:n=>{var i;return("string"==typeof n[e]?n[e]:(null!==(i=n[e])&&void 0!==i?i:"")+"")===t}}},[h,k,A]),M=a(t=>{var n,i;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==y?void 0:y.mode)&&y.xField){const n=na(t,e,y.xField);null!=n&&function(t,e,n){const i=vr.positions.get(t);(null==i?void 0:i.locked)||i&&i.xValue===e&&i.sourceId===n||(vr={positions:new Map(vr.positions).set(t,{xValue:e,sourceId:n})},xr())}(y.name||"hover",n,p)}"x-position"!==(null==y?void 0:y.mode)&&v.onHover(e)}else"x-position"===(null==y?void 0:y.mode)&&kr(y.name||"hover",p),"x-position"!==(null==y?void 0:y.mode)&&v.onHover(null);if(h&&A)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[A];w(null!=n?n+"":null)}else w(null);if(o||b){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const r=ia(t),s=Object.assign(Object.assign({},e),{type:"hover",datum:r||{},x:null!==(n=t.x)&&void 0!==n?n:0,y:null!==(i=t.y)&&void 0!==i?i:0});o&&o(s),b&&b(s)}else{const t=Object.assign(Object.assign({},e),{type:"hover-end"});o&&o(t),b&&b(t)}}},[e,v,y,p,o,s,l,b,h,A]),_=a(t=>{var e,n,i,r;if("x-position"===(null==y?void 0:y.mode)&&y.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=na(t,e,y.xField);null!=n&&function(t,e,n){const i=vr.positions.get(t);if(null==i?void 0:i.locked){const e=new Map(vr.positions);return e.delete(t),vr={positions:e},xr(),!1}vr={positions:new Map(vr.positions).set(t,{xValue:e,sourceId:n,locked:!0})},xr()}(y.name||"hover",n,p)}if(t&&c){let i=t.data||t.datum||t;Array.isArray(i)&&(i=i[0]),c(i,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(o||b){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:l};if(t){const n=ia(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(i=t.x)&&void 0!==i?i:0,y:null!==(r=t.y)&&void 0!==r?r:0});o&&o(s),b&&b(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});o&&o(t),b&&b(t)}}},[c,o,b,s,l,y,p]);return u(()=>{if("x-position"!==(null==y?void 0:y.mode))return;const t=y.name||"hover";return()=>{wr(t,p),kr(t,p)}},[null==y?void 0:y.mode,null==y?void 0:y.name,p]),{activeSelectionHook:x,hoverSelectionHook:S,customHoverBehavior:M,customClickBehavior:_,crosshairSourceId:p}}({selection:h,linkedHover:f,fallbackFields:p,unwrapData:y,onObservation:m,chartType:v,chartId:b,onClick:A,hoverHighlight:S,colorByField:E}),W=function(t,e){const n="object"==typeof t&&null!==t?t:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:e}}(f,B),I=function(t,e,n){const i=Hs(),o=oa();return r(()=>{var r;if(!e)return;const s=null!==(r=null!=n?n:o&&o.length>0?o:void 0)&&void 0!==r?r:"category10";if(0!==t.length){if("function"==typeof e){const n=Array.from(new Set(t.map(t=>e(t)+"")));if(i&&Object.keys(i).length>0){const t=se(n.map(t=>({_cat:t})),"_cat",s);return e=>i[e]||t(e)}return se(n.map(t=>({_cat:t})),"_cat",s)}if(i&&Object.keys(i).length>0){const n=se(t,e,s);return t=>i[t]||n(t)}return se(t,e,s)}if(i&&Object.keys(i).length>0){const t=se([{_:"a"}],"_",s);return e=>i[e]||t(e)}},[t,e,n,i,o])}(L,o,s),Y=r(()=>{if(!o)return[];const t=new Set;for(const e of L){const n="function"==typeof o?o(e):e[o];null!=n&&t.add(n+"")}return Array.from(t)},[L,o]),G=r(()=>$&&j.length>0?j:Y,[$,j,Y]),H=function(t,e,n){const[i,o]=d(null),[s,l]=d(new Set),c=a(e=>{"highlight"===t&&o(e?e.label:null)},[t]),u=a(e=>{"isolate"===t&&l(t=>{const i=new Set(t);return i.has(e.label)?i.delete(e.label):i.add(e.label),i.size===n.length?new Set:i})},[t,n.length]),h=r(()=>{if(!t||"none"===t||!e)return null;const n="string"==typeof e?e:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(n?t[n]:"function"==typeof e?e(t):null)===i}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const i=n?t[n]:"function"==typeof e?e(t):null;return s.has(i)}}:null},[t,e,i,s]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:c,onLegendClick:u,legendSelectionHook:h}}(l,o,G),X=r(()=>R||(H.legendSelectionHook?H.legendSelectionHook:D),[R,H.legendSelectionHook,D]),q=function(t){const e=Mi(t=>t.theme.colors.selectionOpacity);return r(()=>{var n,i;if(void 0!==t||void 0!==e)return Object.assign(Object.assign({name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:""},t),{unselectedOpacity:null!==(i=null==t?void 0:t.unselectedOpacity)&&void 0!==i?i:e})},[t,e])}(h),V=oa(),U=Hs(),Z=r(()=>{if(I)return I;if(!o||0===G.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:V&&V.length>0?V:ie,e="__streamCat",n=se(G.map(t=>({[e]:t})),e,t);return t=>(null==U?void 0:U[t])||n(t)||"#999"},[I,o,G,s,V,U]),{legend:Q,margin:K,legendPosition:J}=ra({data:L,colorBy:o,colorScale:Z,showLegend:x,legendPosition:c,userMargin:k,defaults:w,categories:G}),tt=r(()=>{const t={};return Q&&(t.legend=Q,t.legendPosition=J),l&&"none"!==l&&(t.legendHoverBehavior=H.onLegendHover,t.legendClickBehavior=H.onLegendClick,t.legendHighlightedCategory=H.highlightedCategory,t.legendIsolatedCategories=H.isolatedCategories),$&&o&&(t.legendCategoryAccessor=o,t.onCategoriesChange=C),t},[Q,J,l,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,$,o,C]),et=Array.isArray(i)?ao(i):i,nt=function(e,n,i,o){if(!e)return null;if(!1===o)return null;if(null!=o)return t("div",{style:{width:n,height:i,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(i/40)),s=Math.max(8,Math.floor(i/(3*r))),a=Math.max(6,Math.floor(i/(2.5*r))),l=Math.floor((i-(r*(s+a)-a))/2);return t("div",{style:{width:n,height:i,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,i)=>t("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},ha),{position:"absolute",top:l+i*(s+a),left:Math.floor(.1*n),width:30+(37*i+13)%50+"%",height:s,opacity:.5+i%2*.2})},i))})}(M,O,T,_),it=nt?null:function(e,n,i,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t("div",{style:Object.assign(Object.assign({},da),{width:n,height:i}),children:o||"No data available"}):null}(et,O,T,P);return{data:L,colorScale:I,allCategories:G,legendState:H,effectiveSelectionHook:X,activeSelectionHook:D,customHoverBehavior:F,customClickBehavior:N,legend:Q,margin:K,legendPosition:J,earlyReturn:nt||it||null,legendBehaviorProps:tt,crosshairProps:W,resolvedSelection:q}}function ga(t){if(null==t)return NaN;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("string"==typeof t){if(""===t.trim())return NaN;const e=+t;return Number.isFinite(e)?e:NaN}return NaN}function pa(t,e,n,i){if(!t.length)return[];const o=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];let s=0,a=null,l=null,c=[];const u=(t,e)=>t>e?"A":e>t?"B":null,d=t=>`seg-${s}-${t}`,h=t=>r.push(t),f=(t,e)=>{h({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:d(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;o.length>t;t++){const r=o[t],g=e(r),p=n(r),y=i(r);if(!Number.isFinite(g)||!Number.isFinite(p)||!Number.isFinite(y))continue;const m=u(p,y);if(null!==m)if(null!=a){if(l&&l.w!==m){let t,e;if(c.length>0)t=c[0].x,e=c[0].y;else{const n=p-l.a-(y-l.b);if(0!==n){const i=Math.max(0,Math.min(1,(l.b-l.a)/n));t=l.x+i*(g-l.x),e=l.a+i*(p-l.a)}else t=l.x,e=l.a}h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,h({__x:t,__y:e,__y0:e,__diffSegment:d(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;c.length>t;t++)f(c[t],a)}else for(const t of c)f(t,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else{a=m;for(const t of c)f(t,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else c.push({x:g,y:p,datum:r})}for(const t of c)f(t,null!=a?a:"A");return r}const ya=f(function(n,i){const s=o(null),l=function(t,e){var n,i,o,r,s,a,l;const c=sa[t||"primary"],u="context"===t||"sparkline"===t;return{width:null!==(n=e.width)&&void 0!==n?n:c.width,height:null!==(i=e.height)&&void 0!==i?i:c.height,showAxes:null!==(o=e.showAxes)&&void 0!==o?o:c.showAxes,showGrid:null!==(r=e.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(s=e.enableHover)&&void 0!==s?s:!!e.linkedHover||c.enableHover,showLegend:null!==(a=e.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(l=e.showLabels)&&void 0!==l?l:c.showLabels,title:u?void 0:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:u?void 0:e.xLabel,yLabel:u?void 0:e.yLabel,categoryLabel:u?void 0:e.categoryLabel,valueLabel:u?void 0:e.valueLabel,marginDefaults:aa(c.marginDefaults,e.showCategoryTicks,e.orientation),compactMode:u}}(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:c,margin:u,className:h,xFormat:f,yFormat:g,xAccessor:y="x",seriesAAccessor:m="a",seriesBAccessor:v="b",seriesALabel:b="A",seriesBLabel:x="B",seriesAColor:k="var(--semiotic-danger, #dc2626)",seriesBColor:w="var(--semiotic-info, #2563eb)",showLines:A=!0,lineWidth:S=1.5,showPoints:M=!1,pointRadius:_=3,curve:P="linear",areaOpacity:O=.6,gradientFill:T,tooltip:$,annotations:L,xExtent:j,yExtent:z,frameProps:C={},selection:E,linkedHover:D,onObservation:R,onClick:F,hoverHighlight:N,chartId:B,loading:W,loadingContent:I,emptyContent:Y,legendInteraction:G,legendPosition:H,pointIdAccessor:X,windowSize:q}=n,{width:V,height:U,enableHover:Z,showGrid:Q,showLegend:K,title:J,description:tt,summary:et,accessibleTable:nt,xLabel:it,yLabel:ot}=l,rt=r(()=>"function"==typeof y?t=>ga(y(t)):t=>ga(t[y]),[y]),st=r(()=>"function"==typeof m?t=>ga(m(t)):t=>ga(t[m]),[m]),at=r(()=>"function"==typeof v?t=>ga(v(t)):t=>ga(t[v]),[v]),[lt,ct]=d([]),ut=o([]),dt=null==c,ht=r(()=>ao(dt?lt:c),[dt,lt,c]),ft=r(()=>pa(ht,rt,st,at),[ht,rt,st,at]),gt=r(()=>A?function(t,e,n,i){if(!t.length)return[];const o=t.filter(t=>Number.isFinite(e(t))).sort((t,n)=>e(t)-e(n)),r=[];for(const t of o){const o=e(t),s=n(t),a=i(t);Number.isFinite(s)&&r.push({__x:o,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:o,__y:a,__diffSegment:"line-B"})}return r}(ht,rt,st,at):[],[A,ht,rt,st,at]),pt=r(()=>[...ft,...gt],[ft,gt]),yt=r(()=>{const t=new Set;for(const e of ft)t.add(e.__diffSegment);return Array.from(t)},[ft]);p(i,()=>{const t=t=>{const e=q&&t.length>q?t.slice(t.length-q):t;ut.current=e,ct(e)},e=X?"function"==typeof X?X:t=>t[X]:null;return{push:e=>t([...ut.current,e]),pushMany:e=>t([...ut.current,...e]),remove:n=>{if(!e)return[];const i=Array.isArray(n)?n:[n],o=[],r=[];for(const t of ut.current)i.includes(e(t))?o.push(t):r.push(t);return t(r),o},update:(n,i)=>{if(!e)return[];const o=Array.isArray(n)?n:[n],r=[],s=ut.current.map(t=>{if(o.includes(e(t))){const e=i(t);return r.push(e),e}return t});return t(s),r},clear:()=>t([]),getData:()=>dt?ut.current:ht,getScales:()=>{var t,e;return null!==(e=null===(t=s.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[dt,ht,X,q]);const mt=fa({data:ht,rawData:c,colorBy:"__diffWinner",colorScheme:[k,w],legendInteraction:G,legendPosition:H,selection:E,linkedHover:D,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:F,hoverHighlight:N,chartType:"DifferenceChart",chartId:B,showLegend:K,userMargin:u,marginDefaults:l.marginDefaults,loading:W,loadingContent:I,emptyContent:Y,width:V,height:U}),vt=r(()=>{if(!1!==K)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:b,color:k},{label:x,color:w}]}]}},[K,b,x,k,w]),bt=a(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?k:w,stroke:"none",fillOpacity:O}},[k,w,O]),xt=a(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,strokeWidth:S,fill:"none"}),[k,w,S]),kt=a(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?k:w,r:_}),[k,w,_]),wt=a(n=>{var i;const o=n.data,r=n.allSeries,s=null!==(i=n.xValue)&&void 0!==i?i:null==o?void 0:o.__x;let a=null==o?void 0:o.__valA,l=null==o?void 0:o.__valB;if(r&&r.length>0){const t=r.find(t=>"line-A"===t.group),e=r.find(t=>"line-B"===t.group);null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(a=t.value),null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(l=e.value)}if(null!=s&&(null==a||null==l)){const t=ht.find(t=>rt(t)===s);t&&(null==a&&(a=st(t)),null==l&&(l=at(t)))}const c=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",u=f&&null!=s?f(s):null!=s?s+"":"";return e("div",{className:"semiotic-tooltip",style:uo,children:[u&&t("div",{style:{fontWeight:600,marginBottom:4},children:u}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:k,display:"inline-block",borderRadius:2}}),e("span",{children:[b,": ",c(a)]})]}),e("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t("span",{style:{width:10,height:10,background:w,display:"inline-block",borderRadius:2}}),e("span",{children:[x,": ",c(l)]})]}),null!=a&&null!=l&&Number.isFinite(a)&&Number.isFinite(l)&&e("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",c(a-l)]})]})},[ht,rt,st,at,f,k,w,b,x]),At="multi"===$,St=r(()=>{if(!1===$)return()=>null;if(At)return wt;const e=function(e){if(!0!==e){if("function"==typeof e){const n=e;return e=>{var i;const o=lo(!0===(null==e?void 0:e.__semioticHoverData)||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?null!==(i=e.data)&&void 0!==i?i:{}:e),r=n(o);return null==r?null:t("div",{className:"semiotic-tooltip",style:uo,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?go(e):go())}}($);return e||wt},[$,At,wt]),Mt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"mixed",data:pt,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:yt,curve:P,areaStyle:bt,lineStyle:xt},M&&{pointStyle:kt}),{size:[V,U],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:mt.margin,showAxes:l.showAxes,xLabel:it,yLabel:ot,xFormat:f,yFormat:g,enableHover:Z,showGrid:Q}),T&&{gradientFill:!0===T?{topOpacity:.85,bottomOpacity:.15}:T}),vt&&{legend:vt,legendPosition:mt.legendPosition}),function(t){const{title:e,description:n,summary:i,accessibleTable:o,className:r,animate:s,axisExtent:a}=t,l={};return e&&(l.title=e),n&&(l.description=n),i&&(l.summary=i),void 0!==o&&(l.accessibleTable=o),r&&(l.className=r),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),l}({title:J,description:tt,summary:et,accessibleTable:nt,className:h,animate:n.animate,axisExtent:n.axisExtent})),{tooltipContent:St}),At&&{tooltipMode:"multi"}),function(t){const{linkedHover:e,onObservation:n,onClick:i,hoverHighlight:o,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=t,l={};return(e||n||i||o)&&(l.customHoverBehavior=r),(a?n||i||e:n||i)&&(l.customClickBehavior=s),l}({linkedHover:D,onObservation:R,onClick:F,hoverHighlight:N,customHoverBehavior:mt.customHoverBehavior,customClickBehavior:mt.customClickBehavior})),L&&L.length>0&&{annotations:L}),j&&{xExtent:j}),z&&{yExtent:z}),mt.crosshairProps),C);return mt.earlyReturn?mt.earlyReturn:t(ua,{componentName:"DifferenceChart",width:V,height:U,children:t(Ys,Object.assign({ref:s},Mt))})});function ma(t,e,n){return"function"==typeof t?t(n):n[t||e]}function va(t){return t instanceof Date?t.getTime():Number(t)}function ba(t,e){return Ut(1===e?.5:t/(e-1))}"function"==typeof ya&&(ya.displayName="DifferenceChart");const xa={frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r,s,a,l;const c=null!==(r=o.min)&&void 0!==r?r:0,u=null!==(s=o.max)&&void 0!==s?s:100,d=null!==(a=o.sweep)&&void 0!==a?a:240,h=null!==(l=o.arcWidth)&&void 0!==l?l:.3,f=180+(360-d)/2,g=o.thresholds||[{value:u,color:o.color||"#4e79a7"}],p=i.gradientFill,y=function(t){const{min:e,max:n,value:i,thresholds:o,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=t,d=n-e||1,h=(Math.max(e,Math.min(n,i))-e)/d;let f=o&&o.length>0?[...o].sort((t,e)=>t.value-e.value):[{value:n,color:r||"#007bff"}];f=f.map(t=>Object.assign(Object.assign({},t),{value:Math.max(e,Math.min(n,t.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const g=!!c&&c.colorStops.length>=2,p=[],y=new Map,m=[];if(g){const t=a?h:1,e=Xi("bg",0);if(p.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(e,Math.round(t*e))),i=[];for(let e=0;n>e;e++)i.push(Hi(c.colorStops,t*(e+.5)/n));const o=Xi("fill",0);p.push({category:o,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),y.set(o,{fill:i[0]||s})}}else{let t=e;for(let n=0;f.length>n;n++){const i=f[n],o=(i.value-t)/d,r=(t-e)/d,l=(i.value-e)/d,c=Math.max(0,(a?Math.min(h,l):l)-r),u=a?Math.max(0,o-c):0;if(c>0){const t=Xi("fill",n);p.push({category:t,value:c,_zone:i.label||"Zone "+(n+1),_isFill:!0}),y.set(t,{fill:i.color})}if(u>0){const t=Xi("bg",n);p.push({category:t,value:u,_zone:i.label||"Zone "+(n+1),_isFill:!1}),y.set(t,{fill:s,opacity:.4})}t=i.value}}if(l&&o&&o.length>0)for(const t of o)t.value>e&&n>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:p,pieceStyle:(t,e)=>y.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:c,max:u,value:o.value,thresholds:g,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:!1!==o.fillZones,showScaleLabels:!1!==o.showScaleLabels,gradientFill:p&&"object"==typeof p&&"colorStops"in p?p:void 0}),m=i.margin||{top:20,right:20,bottom:30,left:40},[v,b]=i.size||[300,300];return Object.assign(Object.assign(Object.assign({chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(v-(m.left||0)-(m.right||0),b-(m.top||0)-(m.bottom||0))/2*(1-h)),sweepAngle:d,startAngle:f,oSort:!1,pieceStyle:y.pieceStyle},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i),{showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:c,gMax:u,sweep:d,arcWidth:h,value:o.value,startAngleDeg:f,thresholds:g}})}},ka={frameType:"geo",buildProps:(t,e,n,i,o)=>{var r,s,a,l,c;const u=(Array.isArray(t)?t:null)||o.flows||[],d=o.nodeIdAccessor||"id",h=o.valueAccessor||"value",f=o.xAccessor||"lon",g=o.yAccessor||"lat",p="function"==typeof f?f:t=>t[f],y="function"==typeof g?g:t=>t[g],m=(o.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:p(t),y:y(t)})),v=new Map;for(const t of m)v.set(t[d]+"",t);const b=null!==(r=o.edgeColorBy)&&void 0!==r?r:e,x="function"==typeof b,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=v.get(t.source+""),n=v.get(t.target+"");return e&&n?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:n.x,y:n.y}]}):null}).filter(Boolean),w="__flowMapEdgeColor",A=b?x?se(k.map(t=>({[w]:b(t)})),w,n||"category10"):se(k,b,n||"category10"):null,S=t=>b&&A?re(t,b,A):"#007bff";let M=1/0,_=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(M>e&&(M=e),e>_&&(_=e))}const P=_>M?_-M:0,[O,T]=null!==(a=o.edgeWidthRange)&&void 0!==a?a:[1,8],$=T-O,L=null!==(l=o.edgeOpacity)&&void 0!==l?l:.6,j=null!==(c=o.edgeLinecap)&&void 0!==c?c:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:n,lineStyle:t=>{const e=Number(null==t?void 0:t[h]),n=O+Math.max(0,Math.min(1,P>0?((Number.isFinite(e)?e:M)-M)/P:0))*$;return{stroke:S(t),strokeWidth:n,strokeLinecap:j,opacity:L,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},i)}},wa={Sparkline:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e},i),{showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"line",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||e,colorAccessor:e,colorScheme:n,lineStyle:o.lineStyle},i)},AreaChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"area",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||e,colorAccessor:e,colorScheme:n},i)},DifferenceChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>{var r,s;const a=o.xAccessor||"x",l=o.seriesAAccessor||"a",c=o.seriesBAccessor||"b",u=t=>va(ma(a,"x",t)),d=t=>va(ma(l,"a",t)),h=t=>va(ma(c,"b",t)),f=o.seriesAColor||"var(--semiotic-danger, #dc2626)",g=o.seriesBColor||"var(--semiotic-info, #2563eb)",p=null!==(r=o.areaOpacity)&&void 0!==r?r:.6,y=null!==(s=o.lineWidth)&&void 0!==s?s:1.5,m=!1!==o.showLines,v=pa(Array.isArray(t)?t:[],u,d,h),b=[];if(m&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(u(t))).sort((t,e)=>u(t)-u(e));for(const t of e){const e=u(t),n=d(t),i=h(t);Number.isFinite(n)&&b.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(i)&&b.push({__x:e,__y:i,__diffSegment:"line-B"})}}const x=[...v,...b],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:x,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:k,areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?f:g,stroke:"none",fillOpacity:p}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?f:g,strokeWidth:y,fill:"none"}),curve:o.curve||"linear"},i)}},StackedAreaChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:e||o.areaBy,colorScheme:n,normalize:o.normalize},i)},Scatterplot:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,colorScheme:n},i)},CandlestickChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"candlestick",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle},i)},BubbleChart:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"scatter",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:n},i)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,n,i,o)=>{var r,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const n=e.xAccessor||"x",i=e.yAccessor||"y",o=e.orderAccessor?[...t].sort((t,n)=>null==t||"object"!=typeof t?1:null==n||"object"!=typeof n?-1:va(ma(e.orderAccessor,"order",t))-va(ma(e.orderAccessor,"order",n))):t,r=new WeakMap;let s=0;for(const t of o){if(null==t||"object"!=typeof t)continue;const e=va(ma(n,"x",t)),o=va(ma(i,"y",t));Number.isFinite(e)&&Number.isFinite(o)&&s++}let a=0;for(const t of o){if(null==t||"object"!=typeof t)continue;const e=va(ma(n,"x",t)),o=va(ma(i,"y",t));Number.isFinite(e)&&Number.isFinite(o)&&r.set(t,{idx:a++,total:s})}return{data:o,orderMap:r}}(t,o),l=null!==(r=o.pointRadius)&&void 0!==r?r:4;return Object.assign({chartType:"line",data:a.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:e,colorScheme:n,lineStyle:o.lineStyle||{stroke:o.stroke||"#6366f1",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:l,opacity:o.opacity},pointStyle:t=>{var e,n;const i=a.orderMap.get(t),o=null!==(e=null==i?void 0:i.idx)&&void 0!==e?e:0,r=null!==(n=null==i?void 0:i.total)&&void 0!==n?n:1;return{fill:r>0?ba(o,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},i)}},QuadrantChart:{frameType:"xy",buildProps:(t,e,n,o,r)=>{var s,a;const l=r.xCenter,c=r.yCenter,u=r.quadrants,d=r.centerlineStyle||{},h=!1!==r.showQuadrantLabels,f=null!==(s=r.quadrantLabelSize)&&void 0!==s?s:12,g=d.stroke||"#999",p=null!==(a=d.strokeWidth)&&void 0!==a?a:1,y=Array.isArray(d.strokeDasharray)?d.strokeDasharray.join(","):d.strokeDasharray,m=i.createElement,v=u?[(t,e,n)=>{if(!(null==e?void 0:e.x)||!(null==e?void 0:e.y))return null;const o=n.width,r=n.height,s=null!=l?e.x(l):o/2,a=null!=c?e.y(c):r/2;if(null!=l&&!Number.isFinite(s))return null;if(null!=c&&!Number.isFinite(a))return null;const d=Math.max(0,Math.min(o,s)),v=Math.max(0,Math.min(r,a)),b=[{c:u.topLeft,x:0,y:0,w:d,h:v},{c:u.topRight,x:d,y:0,w:o-d,h:v},{c:u.bottomLeft,x:0,y:v,w:d,h:r-v},{c:u.bottomRight,x:d,y:v,w:o-d,h:r-v}],x=h?[m("text",{key:"ltl",x:8,y:8+f,fill:u.topLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.topLeft.label),m("text",{key:"ltr",x:o-8,y:8+f,fill:u.topRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.topRight.label),m("text",{key:"lbl",x:8,y:r-8,fill:u.bottomLeft.color,fontWeight:600,fontSize:f,opacity:.5},u.bottomLeft.label),m("text",{key:"lbr",x:o-8,y:r-8,fill:u.bottomRight.color,fontWeight:600,fontSize:f,opacity:.5,textAnchor:"end"},u.bottomRight.label)]:[];return m(i.Fragment,null,...b.map((t,e)=>{var n;return t.w>0&&t.h>0?m("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:null!==(n=t.c.opacity)&&void 0!==n?n:.08}):null}),m("line",{key:"vc",x1:d,y1:0,x2:d,y2:r,stroke:g,strokeWidth:p,strokeDasharray:y}),m("line",{key:"hc",x1:0,y1:v,x2:o,y2:v,stroke:g,strokeWidth:p,strokeDasharray:y}),...x)}]:void 0;return Object.assign(Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange,colorScheme:n,pointStyle:r.pointStyle},o),v&&{svgPreRenderers:v})}},Heatmap:{frameType:"xy",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"heatmap",data:t,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,colorScheme:n||o.colorScheme||"blues",showValues:o.showValues,cellBorderColor:o.cellBorderColor},i)},BarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(r=o.sort)&&void 0!==r&&r,colorAccessor:e,colorScheme:n,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:e||o.stackBy,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",normalize:o.normalize,oSort:null!==(r=o.sort)&&void 0!==r&&r,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:e||o.groupBy,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:null!==(r=o.sort)&&void 0!==r&&r,barPadding:o.barPadding},null!=o.roundedTop&&{roundedTop:o.roundedTop}),i)}},PieChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:e||o.categoryAccessor,colorScheme:n},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i)},DonutChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",innerRadius:o.innerRadius||60,colorAccessor:e||o.categoryAccessor,colorScheme:n},null!=o.cornerRadius&&{cornerRadius:o.cornerRadius}),i)},Histogram:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"histogram",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal",bins:o.bins,colorAccessor:e,colorScheme:n},i)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"boxplot",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorScheme:n},i)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"violin",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,colorScheme:n},i)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"swarm",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:n},i)},DotPlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{var r;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:e,colorScheme:n},i),{showGrid:null===(r=i.showGrid)||void 0===r||r})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"swimlane",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:e||o.subcategoryAccessor,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical"},i)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",bins:o.bins,amplitude:o.amplitude},i)},LikertChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"bar",data:t,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.levelAccessor||"level",colorAccessor:e||o.levelAccessor||"level",colorScheme:n,normalize:!0,projection:"vertical"===o.orientation?"vertical":"horizontal"},i)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,n,i,o)=>{const r="vertical"===o.orientation;return Object.assign({chartType:r?"bar-funnel":"funnel",data:t,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:e||o.categoryAccessor,categoryAccessor:o.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:n},i)}},GaugeChart:xa,ForceDirectedGraph:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:e,colorScheme:n,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle},i)},SankeyDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:e,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle,colorScheme:n},i)},ProcessSankey:{frameType:"network",buildProps:(t,e,n,i,o)=>{var r,s,a,l;const c=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),u=o.sourceAccessor||"source",d=o.targetAccessor||"target",h=o.valueAccessor||"value",f=o.nodeIdAccessor||"id",g=o.startTimeAccessor||"startTime",p=o.endTimeAccessor||"endTime",y=o.systemInTimeAccessor,m=o.systemOutTimeAccessor,v=o.xExtentAccessor||"xExtent",b=o.edgeIdAccessor||"id",x=(t,e)=>"function"==typeof t?t(e):e[t],k=Array.isArray(o.edges)?o.edges:[],w=Array.isArray(o.nodes)?o.nodes:[],A=w.length>0?w:function(t,e,n,i){const o=new Set;return e.forEach(t=>{const e="function"==typeof n?n(t):t[n],r="function"==typeof i?i(t):t[i];o.add(e),o.add(r)}),Array.from(o).map(t=>({id:t}))}(0,k,u,d),S=[c(null===(r=o.domain)||void 0===r?void 0:r[0]),c(null===(s=o.domain)||void 0===s?void 0:s[1])],M=A.map(t=>{const e=x(f,t)+"",n=x(v,t),i={id:e,__raw:t};if(Array.isArray(n)&&2===n.length){const t=c(n[0]),e=c(n[1]);Number.isFinite(t)&&Number.isFinite(e)&&(i.xExtent=[t,e])}return i}),_=k.map((t,e)=>{const n=x(b,t),i={id:null!=n?n+"":`${x(u,t)}-${x(d,t)}-${e}`,source:x(u,t)+"",target:x(d,t)+"",value:Number(x(h,t)),startTime:c(x(g,t)),endTime:c(x(p,t)),__raw:t};if(y){const e=c(x(y,t));Number.isFinite(e)&&(i.systemInTime=e)}if(m){const e=c(x(m,t));Number.isFinite(e)&&(i.systemOutTime=e)}return i}),[P,O]=null!==(a=i.size)&&void 0!==a?a:[600,400],T=Object.assign({top:20,right:20,bottom:20,left:20},i.margin),$=null!==(l=i.legendPosition)&&void 0!==l?l:"right";i.showLegend&&("right"===$?T.right=Math.max(T.right,100):"left"===$?T.left=Math.max(T.left,100):"bottom"===$?T.bottom=Math.max(T.bottom,70):"top"===$&&(T.top=Math.max(T.top,40)));const L=T,j=P-L.left-L.right,z=O-L.top-L.bottom,C=Array.isArray(n)?n:null,E=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],D="function"==typeof e?e:null,R=D?A.map(t=>({_cat:D(t)})):A,F=D?"_cat":"string"==typeof e?e:void 0,N=F?se(R,F,n):null,B=new Map;for(const t of M)B.set(t.id,t.__raw);const{layoutConfig:W,issues:I}=oo({nodes:M,edges:_,domain:S,plotW:j,plotH:z,ribbonLane:o.ribbonLane||"both",edgeOpacity:"number"==typeof o.edgeOpacity?o.edgeOpacity:.35,colorOf:(t,n)=>{if(e&&B.has(t)){const n=B.get(t);return D?re({_cat:D(n)},"_cat",null!=N?N:void 0):re(n,e,null!=N?N:void 0)}const i=C||E;return i[n%i.length]},layoutOpts:{pairing:o.pairing||"temporal",packing:o.packing||"reuse",laneOrder:o.laneOrder||"crossing-min",lifetimeMode:o.lifetimeMode||"half"}});if(I.length>0){const t=I.map(qi).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:A,edges:k,customNetworkLayout:ro,layoutConfig:W,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},i),{margin:L})}},ChordDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:e,edgeColorBy:o.edgeColorBy,colorScheme:n},i)},TreeDiagram:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"cluster"===o.layout?"cluster":"tree",data:t,childrenAccessor:o.childrenAccessor,colorBy:e,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,colorScheme:n},i)},Treemap:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,showLabels:o.showLabels,colorScheme:n},i)},CirclePack:{frameType:"network",buildProps:(t,e,n,i,o)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:e,colorByDepth:o.colorByDepth,colorScheme:n},i)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,n,i,o)=>Object.assign({areas:o.areas,projection:o.projection||"equalEarth",areaStyle:o.areaStyle,valueAccessor:o.valueAccessor,colorScheme:n||"blues",graticule:o.graticule,fitPadding:o.fitPadding},i)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,n,i,o)=>Object.assign({points:t||o.points,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle,sizeBy:o.sizeBy,colorBy:e,colorScheme:n,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding},i)},FlowMap:ka};function Aa(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function Sa(t,e){if(0===e.categories.length)return;const n=e.position||"right",i=function(t){const{width:e,height:n,swatchSize:i}=ji(t);return{width:e,height:n,swatchSize:i}}({categories:e.categories,theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,legendLayout:e.legendLayout});"right"===n?t.right=Math.max(t.right,i.width+14):"left"===n?t.left=Math.max(t.left,i.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+i.height+4):t.bottom=Math.max(t.bottom,38+i.height+4)}function Ma(t,e){const n=e.position||"right",i={theme:e.theme,position:n,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},o=St(e.legend)?function(t){const{width:e,height:n,swatchSize:i}=zi(t);return{width:e,height:n,swatchSize:i}}(Object.assign(Object.assign({},i),{legendGroups:e.legend.legendGroups})):Mt(e.legend)?Ci(Object.assign(Object.assign({},i),{gradient:e.legend.gradient})):null;o&&("right"===n?t.right=Math.max(t.right,o.width+14):"left"===n?t.left=Math.max(t.left,o.width+14):"top"===n?t.top=Math.max(t.top,(e.hasTitle?32:8)+o.height+4):t.bottom=Math.max(t.bottom,38+o.height+4))}function _a(n,i){const o={theme:i.theme,position:i.position||"right",totalWidth:i.size[0],totalHeight:i.size[1],margin:i.margin,hasTitle:i.hasTitle,legendLayout:i.legendLayout,idPrefix:i.idPrefix};return St(n)?function(n){if(0===(i=n.legendGroups,i.flatMap(t=>t.items.map((e,n)=>({group:t,item:e,itemIndex:n,label:e.label})))).length)return null;var i;const o=zi(n),r="top"===n.position||"bottom"===n.position,s=n.theme.colors.grid||n.theme.colors.textSecondary;let a,l;"left"===n.position?(a=Math.max(4,n.margin.left-o.width-10),l=n.margin.top):"top"===n.position?(a=n.margin.left,l=n.hasTitle?32:8):"bottom"===n.position?(a=n.margin.left,l=Math.min(n.totalHeight-n.margin.bottom+38,n.totalHeight-o.height-2)):(a=Math.min(n.totalWidth-o.width-4,n.totalWidth-n.margin.right+10),l=n.margin.top);const c=o.groups.flatMap((i,a)=>{var l;const{group:c}=i,u=null!==(l=c.type)&&void 0!==l?l:"fill",d=[];if(c.label&&d.push(t("text",r?{transform:`translate(${i.x},${i.y}) rotate(90)`,textAnchor:"start",fontSize:$i(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:c.label}:{x:i.x,y:i.y+$i(n.theme),fontSize:$i(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:c.label},"legend-group-label-"+a)),d.push(...i.items.map((r,s)=>{const l=c.items[s],d=c.styleFn(l,s),h="function"==typeof u?u(l):"line"===u?t("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:d}):t("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:d});return e("g",{transform:`translate(${i.x+i.itemOffsetX+r.x},${i.y+i.itemOffsetY+r.y})`,children:[h,t("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:$i(n.theme),fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:r.category})]},`legend-${a}-${s}`)})),!r&&o.groups.length-1>a)d.push(t("line",{x1:0,y1:i.y+i.height-6,x2:o.width,y2:i.y+i.height-6,stroke:s},"legend-group-separator-"+a));else if(r&&o.groups.length-1>a){const e=i.x+i.width+6;d.push(t("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:s},"legend-group-separator-"+a))}return d});return t("g",{className:"semiotic-legend",transform:`translate(${a},${l})`,"data-orientation":r?"horizontal":"vertical",children:c})}(Object.assign(Object.assign({},o),{legendGroups:n.legendGroups})):Mt(n)?function(n){const i=Ci(n),o="top"===n.position||"bottom"===n.position,r=(n.idPrefix?n.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=n.gradient.format||(t=>Math.round(100*t)/100+"");let a,l;"left"===n.position?(a=Math.max(4,n.margin.left-i.width-10),l=n.margin.top):"top"===n.position?(a=n.margin.left,l=n.hasTitle?32:8):"bottom"===n.position?(a=n.margin.left,l=Math.min(n.totalHeight-n.margin.bottom+38,n.totalHeight-i.height-2)):(a=Math.min(n.totalWidth-i.width-4,n.totalWidth-n.margin.right+10),l=n.margin.top);const c=Array.from({length:17},(e,i)=>{const r=i/16;return t("stop",{offset:100*r+"%",stopColor:n.gradient.colorFn(o?n.gradient.domain[0]+r*(n.gradient.domain[1]-n.gradient.domain[0]):n.gradient.domain[1]-r*(n.gradient.domain[1]-n.gradient.domain[0]))},i)});if(o){const o=12,u=n.gradient.label?0:void 0,d=n.gradient.label?8:0;return e("g",{className:"semiotic-legend",transform:`translate(${a},${l})`,children:[t("defs",{children:t("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),n.gradient.label&&t("text",{x:i.width/2,y:u,textAnchor:"middle",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:n.gradient.label}),t("rect",{x:0,y:d,width:i.width,height:o,fill:`url(#${r})`,rx:2}),t("text",{x:0,y:d+o+12,textAnchor:"start",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[0])}),t("text",{x:i.width,y:d+o+12,textAnchor:"end",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[1])})]})}const u=n.gradient.label?-6:void 0;return e("g",{className:"semiotic-legend",transform:`translate(${a},${l+(n.gradient.label?12:0)})`,children:[t("defs",{children:t("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),n.gradient.label&&t("text",{x:7,y:u,textAnchor:"middle",fontSize:n.theme.typography.tickSize,fill:n.theme.colors.text,fontFamily:n.theme.typography.fontFamily,children:n.gradient.label}),t("rect",{x:0,y:0,width:14,height:100,fill:`url(#${r})`,rx:2}),t("text",{x:19,y:10,fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[1])}),t("text",{x:19,y:100,fontSize:n.theme.typography.tickSize,fill:n.theme.colors.textSecondary,fontFamily:n.theme.typography.fontFamily,children:s(n.gradient.domain[0])})]})}(Object.assign(Object.assign({},o),{gradient:n.gradient})):null}function Pa(t){return Math.round(100*t)/100+""}function Oa(n,i){const o=Oi(i.theme),r=i.idPrefix?i.idPrefix+"-":"",s="string"==typeof i.title?i.title:void 0,a=s?r+"semiotic-title":void 0,l=i.description?r+"semiotic-desc":void 0,c=[a,l].filter(Boolean).join(" ")||void 0;return e("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[s&&t("title",{id:a,children:s}),i.description&&t("desc",{id:l,children:i.description}),i.defs&&t("defs",{children:i.defs}),i.background&&"transparent"!==i.background&&t("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t("g",{id:r+"data-area",transform:i.innerTransform,children:n}),s&&t("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:s}),i.legend&&t("g",{id:r+"legend",children:i.legend}),i.outerElements]})}function Ta(o){var r,s,a,l;const c=Pi(o.theme),u=o.size||[500,300],d=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),o.margin),h=ao(o.data),f=o.showLegend?Di(h,o.colorAccessor||o.groupAccessor):[],g=o.legendPosition;St(o.legend)||Mt(o.legend)?Ma(d,{legend:o.legend,theme:c,position:g||"right",size:u,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&f.length>0&&Sa(d,{categories:f,theme:c,position:g||"right",size:u,hasTitle:!!o.title,legendLayout:o.legendLayout});const p=u[0]-d.left-d.right,m=u[1]-d.top-d.bottom,v="streaming"===o.runtimeMode||["bar","swarm","waterfall"].includes(o.chartType),b=o.colorScheme||c.colors.categorical,x={chartType:o.chartType,windowSize:null!==(r=o.windowSize)&&void 0!==r?r:200,windowMode:null!==(s=o.windowMode)&&void 0!==s?s:"sliding",arrowOfTime:v&&null!==(a=o.arrowOfTime)&&void 0!==a?a:"right",extentPadding:null!==(l=o.extentPadding)&&void 0!==l?l:.1,xAccessor:v?void 0:o.xAccessor,yAccessor:v?void 0:o.yAccessor,timeAccessor:v?o.timeAccessor:void 0,valueAccessor:o.valueAccessor,colorAccessor:o.colorAccessor,sizeAccessor:o.sizeAccessor,groupAccessor:o.groupAccessor,categoryAccessor:o.categoryAccessor,lineDataAccessor:o.lineDataAccessor,xExtent:o.xExtent,yExtent:o.yExtent,sizeRange:o.sizeRange,xScaleType:o.xScaleType,yScaleType:o.yScaleType,scalePadding:o.scalePadding,binSize:o.binSize,normalize:o.normalize,boundsAccessor:o.boundsAccessor,boundsStyle:o.boundsStyle,y0Accessor:o.y0Accessor,areaGroups:o.areaGroups?o.areaGroups instanceof Set?o.areaGroups:new Set(o.areaGroups):void 0,curve:o.curve,gradientFill:!0===o.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===o.gradientFill?void 0:o.gradientFill,lineGradient:o.lineGradient,openAccessor:o.openAccessor,highAccessor:o.highAccessor,lowAccessor:o.lowAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,barStyle:o.barStyle,waterfallStyle:o.waterfallStyle,swarmStyle:o.swarmStyle,colorScheme:b,barColors:o.barColors},k=new Pe(x);if(o.data&&k.ingest({inserts:h,bounded:!0}),k.computeScene({width:p,height:m}),!k.scales||0===k.scene.length)return y.renderToStaticMarkup(Oa(null,{width:u[0],height:u[1],className:"stream-xy-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:c,innerTransform:`translate(${d.left},${d.top})`,idPrefix:o._idPrefix}));const w=o._idPrefix,A=o.showGrid?function(n,i,o,r){const{grid:s}=Oi(o),a=r?r+"-":"",l=n.x.ticks(5),c=n.y.ticks(5);return e("g",{id:a+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((e,o)=>{const r=n.x(e);return t("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gx-"+o)}),c.map((e,o)=>{const r=n.y(e);return t("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gy-"+o)})]})}(k.scales,{width:p,height:m},c,w):null,S=k.scene.map((t,e)=>hi(t,e,w)).filter(Boolean),M=!1!==o.showAxes?function(n,i,o,r,s){var a,l,c,u;const d=Oi(r),h=n.x.ticks(5).map(t=>({pixel:n.x(t),label:(o.xFormat||o.tickFormatTime||Pa)(t)})),f=n.y.ticks(5).map(t=>({pixel:n.y(t),label:(o.yFormat||o.tickFormatValue||Pa)(t)}));return e("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[t("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:d.border,strokeWidth:1}),h.map((n,o)=>e("g",{transform:`translate(${n.pixel},${i.height})`,children:[t("line",{y2:5,stroke:d.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"xtick-"+o)),o.xLabel&&t("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,children:o.xLabel}),t("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:d.border,strokeWidth:1}),f.map((n,i)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:d.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:d.tickSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:n.label})]},"ytick-"+i)),o.yLabel&&t("text",{x:15-(null!==(l=null===(a=o.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:i.height/2,textAnchor:"middle",fontSize:d.labelSize,fill:d.text,fontFamily:d.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${i.height/2})`,children:o.yLabel})]})}(k.scales,{width:p,height:m},o,c,w):null,_=o.annotations?Bi({annotations:o.annotations,scales:{x:k.scales.x,y:k.scales.y},layout:{width:p,height:m},theme:c,xAccessor:"string"==typeof o.xAccessor?o.xAccessor:void 0,yAccessor:"string"==typeof o.yAccessor?o.yAccessor:void 0,idPrefix:w}):null,P=o.svgPreRenderers&&k.scales?o.svgPreRenderers.map((e,n)=>{try{return t(i.Fragment,{children:e(k.scene,k.scales,{width:p,height:m})},"pre-"+n)}catch(t){return null}}).filter(Boolean):null,O=o.showLegend?0===f.length?null:Ei({categories:f,colorScheme:o.colorScheme,theme:c,position:o.legendPosition||"right",totalWidth:u[0],totalHeight:u[1],margin:d,hasTitle:!!o.title,legendLayout:o.legendLayout}):null,T=i.isValidElement(o.legend)?o.legend:_a(o.legend,{theme:c,position:o.legendPosition||"right",size:u,margin:d,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||O,$=e(n,{children:[o.backgroundGraphics,P,A,S,M,_,o.foregroundGraphics]});return y.renderToStaticMarkup(Oa($,{width:u[0],height:u[1],className:"stream-xy-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:c,innerTransform:`translate(${d.left},${d.top})`,legend:T,idPrefix:o._idPrefix}))}function $a(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const La=new Set(["tree","cluster","treemap","circlepack","partition"]);function ja(o){var r,s,a,l,c;const u=Pi(o.theme),d=o.chartType||"force",h=o.size||[500,500],f=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),o.margin),g=o.showLegend?(()=>{const t="string"==typeof(e=o.colorBy)||"function"==typeof e?o.colorBy:void 0;var e;if(!t)return[];const n=ao(o.nodes||[]);if(n.length>0)return Di(n,t);const i=Array.isArray(o.edges)?ao(o.edges):[];if(0===i.length)return[];const r=$a(o.sourceAccessor,"source"),s=$a(o.targetAccessor,"target");return Di(Array.from(new Set(i.flatMap(t=>[r(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),t)})():[],p=o.legendPosition;St(o.legend)||Mt(o.legend)?Ma(f,{legend:o.legend,theme:u,position:p||"right",size:h,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&g.length>0&&Sa(f,{categories:g,theme:u,position:p||"right",size:h,hasTitle:!!o.title,legendLayout:o.legendLayout});const m=h[0]-f.left-f.right,v=h[1]-f.top-f.bottom,b=function(t){return Yn[t]}(d);if(!b)throw Error(`No layout plugin found for chart type: "${d}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const x={chartType:d,nodeIDAccessor:o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,childrenAccessor:o.childrenAccessor,hierarchySum:o.hierarchySum,orientation:o.orientation,nodeAlign:o.nodeAlign,nodePaddingRatio:o.nodePaddingRatio,nodeWidth:o.nodeWidth,iterations:o.iterations,forceStrength:o.forceStrength,padAngle:o.padAngle,groupWidth:o.groupWidth,sortGroups:o.sortGroups,edgeSort:o.edgeSort,treeOrientation:o.treeOrientation,edgeType:o.edgeType,padding:o.padding,paddingTop:o.paddingTop,nodeStyle:o.nodeStyle,edgeStyle:o.edgeStyle,nodeLabel:o.nodeLabel,showLabels:o.showLabels,colorBy:o.colorBy,colorScheme:o.colorScheme||u.colors.categorical,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,colorByDepth:o.colorByDepth,nodeSize:o.nodeSize,nodeSizeRange:o.nodeSizeRange,customNetworkLayout:o.customNetworkLayout,layoutConfig:o.layoutConfig};let k,w;if(La.has(d)){const t=o.data||o.edges;if(!t||Array.isArray(t))return y.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-network-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:u,innerTransform:`translate(${f.left},${f.top})`,idPrefix:o._idPrefix}));x.__hierarchyRoot=t,k=[],w=[]}else{const t=ao(o.nodes||[]),e=Array.isArray(o.edges)?ao(o.edges):[];if(0===t.length&&0===e.length)return y.renderToStaticMarkup(Oa(null,{width:h[0],height:h[1],className:"stream-network-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:u,innerTransform:`translate(${f.left},${f.top})`,idPrefix:o._idPrefix}));if(w=function(t,e){const n=$a(e.sourceAccessor,"source"),i=$a(e.targetAccessor,"target"),o=$a(e.valueAccessor,"value");return t.map(t=>({source:n(t)+"",target:i(t)+"",value:Number(o(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(e,x),0===t.length&&w.length>0){const t=new Set;for(const e of w){const n=Aa(e.source),i=Aa(e.target);n&&t.add(n),i&&t.add(i)}k=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else k=function(t,e){const n=$a(e.nodeIDAccessor,"id");return t.map(t=>{var e,i;return{id:n(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(i=t.y)&&void 0!==i?i:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,x)}let A=[],S=[],M=[],_=null;if(x.customNetworkLayout){const t=Gn(x.colorScheme,u.colors.categorical,It),e=Hn(t),n={nodes:k,edges:w,dimensions:{width:m,height:v,plot:{x:0,y:0,width:m,height:v}},theme:{semantic:u.colors,categorical:[...t]},resolveColor:e,config:null!==(r=x.layoutConfig)&&void 0!==r?r:{}},i=x.customNetworkLayout(n);A=null!==(s=i.sceneNodes)&&void 0!==s?s:[],S=null!==(a=i.sceneEdges)&&void 0!==a?a:[],M=null!==(l=i.labels)&&void 0!==l?l:[],_=null!==(c=i.overlays)&&void 0!==c?c:null}else{b.computeLayout(k,w,x,[m,v]);const t=b.buildScene(k,w,x,[m,v]);A=t.sceneNodes,S=t.sceneEdges,M=t.labels}const P=Oi(u);for(const t of M)t.fill||(t.fill=P.text);const O=S.map((e,n)=>function(e,n){switch(e.type){case"line":return t("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+n);case"bezier":{const i=e;return t("path",{d:i.pathD,fill:ui(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"ribbon":{const i=e;return t("path",{d:i.pathD,fill:ui(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+n)}case"curved":{const i=e;return t("path",{d:i.pathD,fill:ui(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+n)}default:return null}}(e,n)).filter(Boolean),T=A.map((e,n)=>function(e,n){switch(e.type){case"circle":{const i=e;return t("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:ui(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-circle-"+n)}case"rect":{const i=e;return t("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:ui(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-rect-"+n)}case"arc":{const i=e,o=B().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(ci)||"";return t("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:ui(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-arc-"+n)}default:return null}}(e,n)).filter(Boolean),$=M.map((e,n)=>function(e,n){return t("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+n)}(e,n)).filter(Boolean),L=o.annotations?Bi({annotations:o.annotations,scales:{},layout:{width:m,height:v},theme:u,idPrefix:o._idPrefix}):null,j=o.showLegend?(()=>{const t="string"==typeof(e=o.colorBy)||"function"==typeof e?o.colorBy:void 0;var e;if(!t)return[];const n=Di(k.length>0?k.map(t=>t.data||{id:t.id}):Array.from(new Set(w.flatMap(t=>[Aa(t.source),Aa(t.target)]).filter(Boolean))).map(t=>({id:t})),t);return 0===n.length?null:Ei({categories:n,colorScheme:o.colorScheme,theme:u,position:o.legendPosition||"right",totalWidth:h[0],totalHeight:h[1],margin:f,hasTitle:!!o.title,legendLayout:o.legendLayout})})():null,z=i.isValidElement(o.legend)?o.legend:_a(o.legend,{theme:u,position:o.legendPosition||"right",size:h,margin:f,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||j,C=e(n,{children:[o.backgroundGraphics,O,T,$,L,o.foregroundGraphics,_]});return y.renderToStaticMarkup(Oa(C,{width:h[0],height:h[1],className:"stream-network-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:u,innerTransform:`translate(${f.left},${f.top})`,legend:z,idPrefix:o._idPrefix}))}function za(o){var r,s,a,l,c;const u=Pi(o.theme),d=o.size||[500,400],h=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),o.margin),f=ao(o.data),g=o.showLegend?Di(f,o.colorAccessor||o.stackBy||o.groupBy):[],p=o.legendPosition;St(o.legend)||Mt(o.legend)?Ma(h,{legend:o.legend,theme:u,position:p||"right",size:d,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&g.length>0&&Sa(h,{categories:g,theme:u,position:p||"right",size:d,hasTitle:!!o.title,legendLayout:o.legendLayout});const m=d[0]-h.left-h.right,v=d[1]-h.top-h.bottom,b=o.projection||"vertical",x="radial"===b,k={chartType:o.chartType,windowSize:null!==(r=o.windowSize)&&void 0!==r?r:1e4,windowMode:null!==(s=o.windowMode)&&void 0!==s?s:"sliding",extentPadding:null!==(a=o.extentPadding)&&void 0!==a?a:.05,projection:b,oAccessor:o.oAccessor,rAccessor:o.rAccessor,colorAccessor:o.colorAccessor,stackBy:o.stackBy,groupBy:o.groupBy,categoryAccessor:o.categoryAccessor,valueAccessor:o.valueAccessor,timeAccessor:o.timeAccessor,rExtent:o.rExtent,oExtent:o.oExtent,barPadding:o.barPadding,roundedTop:o.roundedTop,innerRadius:o.innerRadius,cornerRadius:o.cornerRadius,normalize:o.normalize,startAngle:o.startAngle,sweepAngle:o.sweepAngle,bins:o.bins,showOutliers:o.showOutliers,showIQR:o.showIQR,amplitude:o.amplitude,oSort:o.oSort,connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,dynamicColumnWidth:o.dynamicColumnWidth,pieceStyle:o.pieceStyle,summaryStyle:o.summaryStyle,colorScheme:o.colorScheme||u.colors.categorical,barColors:o.barColors},w=new Un(k);if(o.data&&w.ingest({inserts:f,bounded:!0}),w.computeScene({width:m,height:v}),!w.scales||0===w.scene.length)return y.renderToStaticMarkup(Oa(null,{width:d[0],height:d[1],className:"stream-ordinal-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:u,innerTransform:`translate(${h.left},${h.top})`,idPrefix:o._idPrefix}));const A=o._idPrefix,S=o.showGrid?function(e,n,i,o){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=Oi(i),a=o?o+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,i)=>{const o=r.r(e);return t("line",{x1:0,y1:o,x2:n.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,i)=>{const o=r.r(e);return t("line",{x1:o,y1:0,x2:o,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}(w,{width:m,height:v},u,A):null,M=w.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let _=null;if(M){const n=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const n=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let i=0;for(let t=0;n.length>t;t++)i=31*i+n.charCodeAt(t)|0;return"c"+(i>>>0).toString(36)}(o),i=new Set;for(const t of w.scene)"rect"===t.type&&(null===(l=t.datum)||void 0===l?void 0:l.__barFunnelIsDropoff)&&i.add("string"==typeof t.style.fill?t.style.fill:"#666");_=Array.from(i).map((i,o)=>function(n){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:s=1.5,spacing:a=6,angle:l=45}=n,c=Math.max(8,Math.ceil(2*a));return e("pattern",{id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==l?`rotate(${l})`:void 0,children:[o&&"transparent"!==o&&t("rect",{width:c,height:c,fill:o}),t("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:s}),t("line",{x1:a,y1:0,x2:a,y2:c,stroke:r,strokeWidth:s})]},i)}({id:`funnel-hatch-${n}-${o}`,background:i,stroke:"transparent"===u.colors.background?"#fff":u.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((t,e)=>r.set(t,`funnel-hatch-${n}-${e}`));for(const t of w.scene)if("rect"===t.type&&(null===(c=t.datum)||void 0===c?void 0:c.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const P=w.scene.map((t,e)=>fi(t,e,A)).filter(Boolean),O=!1!==o.showAxes?function(n,i,o,r,s){var a,l,c,u,d,h,f,g;const p=n.scales;if(!p)return null;if("radial"===p.projection)return null;const y=Oi(r),m="vertical"===p.projection,v=o.categoryFormat||o.oFormat,b=o.valueFormat||o.rFormat,x=o.categoryLabel||o.oLabel,k=o.valueLabel||o.rLabel,w=Object.values(n.columns).map(t=>({pixel:t.middle,label:(v||String)(t.name)})),A=p.r.ticks(5).map(t=>({pixel:p.r(t),label:(b||Pa)(t)}));return e("g",m?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),w.map((n,o)=>e("g",{transform:`translate(${n.pixel},${i.height})`,children:[t("line",{y2:5,stroke:y.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oxtick-"+o)),x&&t("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:x}),t("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((n,i)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:y.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oytick-"+i)),k&&t("text",{x:15-(null!==(l=null===(a=o.margin)||void 0===a?void 0:a.left)&&void 0!==l?l:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(u=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==u?u:40)}, ${i.height/2})`,children:k})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[t("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((n,o)=>e("g",{transform:`translate(${n.pixel},${i.height})`,children:[t("line",{y2:5,stroke:y.border,strokeWidth:1}),t("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oxtick-"+o)),k&&t("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:k}),t("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),w.map((n,i)=>e("g",{transform:`translate(0,${n.pixel})`,children:[t("line",{x2:-5,stroke:y.border,strokeWidth:1}),t("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:n.label})]},"oytick-"+i)),x&&t("text",{x:15-(null!==(h=null===(d=o.margin)||void 0===d?void 0:d.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(g=null===(f=o.margin)||void 0===f?void 0:f.left)&&void 0!==g?g:40)}, ${i.height/2})`,children:x})]})}(w,{width:m,height:v},o,u,A):null,T=o.annotations?Bi({annotations:o.annotations,scales:{r:w.scales.r,y:"vertical"===w.scales.projection?w.scales.r:void 0},layout:{width:m,height:v},theme:u,projection:b,idPrefix:A}):null,$=o.showLegend?0===g.length?null:Ei({categories:g,colorScheme:o.colorScheme,theme:u,position:o.legendPosition||"right",totalWidth:d[0],totalHeight:d[1],margin:h,hasTitle:!!o.title,legendLayout:o.legendLayout}):null,L=i.isValidElement(o.legend)?o.legend:_a(o.legend,{theme:u,position:o.legendPosition||"right",size:d,margin:h,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||$,j=x?h.left+m/2:h.left,z=x?h.top+v/2:h.top,C=e(n,{children:[o.backgroundGraphics,S,P,O,T,o.foregroundGraphics]});return y.renderToStaticMarkup(Oa(C,{width:d[0],height:d[1],className:"stream-ordinal-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:u,innerTransform:`translate(${j},${z})`,legend:L,defs:_,idPrefix:o._idPrefix}))}function Ca(o){var r,s,a,l,c,u,d,h,f,g;const p=Pi(o.theme),m=o.size||[o.width||600,o.height||400],v=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),o.margin),b=Array.isArray(o.areas)?ao(o.areas):o.areas,x=ao(o.points),k=ao(o.lines),w=o.showLegend?(()=>{const t="string"==typeof(e=o.colorBy)||"function"==typeof e?o.colorBy:void 0;var e;return Di(x.length>0?x:Array.isArray(b)&&b.length>0?"string"==typeof t?b.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):b:[],t)})():[],A=o.legendPosition;St(o.legend)||Mt(o.legend)?Ma(v,{legend:o.legend,theme:p,position:A||"right",size:m,hasTitle:!!o.title,legendLayout:o.legendLayout}):o.showLegend&&w.length>0&&Sa(v,{categories:w,theme:p,position:A||"right",size:m,hasTitle:!!o.title,legendLayout:o.legendLayout});const S=m[0]-(null!==(r=v.left)&&void 0!==r?r:0)-(null!==(s=v.right)&&void 0!==s?s:0),M=m[1]-(null!==(a=v.top)&&void 0!==a?a:0)-(null!==(l=v.bottom)&&void 0!==l?l:0),_=new oi({projection:o.projection||"equalEarth",xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineDataAccessor:o.lineDataAccessor,pointIdAccessor:o.pointIdAccessor,lineType:o.lineType,areaStyle:o.areaStyle,pointStyle:o.pointStyle,lineStyle:o.lineStyle,graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:o.projectionTransform});if(b){if("string"==typeof b)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${b}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${b}')\` before calling renderGeoToStaticSVG.`);_.setAreas(b)}if(o.points&&_.setPoints(x),o.lines&&_.setLines(k),_.computeScene({width:S,height:M}),0===_.scene.length){const t=o.backgroundGraphics||o.foregroundGraphics||o.annotations?e(n,{children:[o.backgroundGraphics,o.annotations?Bi({annotations:o.annotations,scales:{geoProjection:(null===(c=_.scales)||void 0===c?void 0:c.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:S,height:M},theme:p,idPrefix:o._idPrefix}):null,o.foregroundGraphics]}):null;return y.renderToStaticMarkup(Oa(t,{width:m[0],height:m[1],className:"stream-geo-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:p,innerTransform:`translate(${null!==(u=v.left)&&void 0!==u?u:0},${null!==(d=v.top)&&void 0!==d?d:0})`,idPrefix:o._idPrefix}))}const P=_.scene.map((e,n)=>function(e,n){var i,o,r,s,a,l;switch(e.type){case"geoarea":{const r=e;return r.pathData?t("path",{d:r.pathData,fill:ui(r.style.fill,"#e0e0e0"),fillOpacity:null!==(i=r.style.fillOpacity)&&void 0!==i?i:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(o=r._decayOpacity)&&void 0!==o?o:1},"geoarea-"+n):null}case"point":{const i=e;return t("circle",{cx:i.x,cy:i.y,r:i.r,fill:ui(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:null!==(s=i._decayOpacity)&&void 0!==s?s:null!==(a=i.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const i=e;if(2>i.path.length)return null;const o="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return t("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(l=i.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(e,n)).filter(Boolean),O=o.annotations?Bi({annotations:o.annotations,scales:{geoProjection:(null===(h=_.scales)||void 0===h?void 0:h.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:S,height:M},theme:p,idPrefix:o._idPrefix}):null,T=o.showLegend?0===w.length?null:Ei({categories:w,colorScheme:o.colorScheme,theme:p,position:o.legendPosition||"right",totalWidth:m[0],totalHeight:m[1],margin:v,hasTitle:!!o.title,legendLayout:o.legendLayout}):null,$=i.isValidElement(o.legend)?o.legend:_a(o.legend,{theme:p,position:o.legendPosition||"right",size:m,margin:v,hasTitle:!!o.title,legendLayout:o.legendLayout,idPrefix:o._idPrefix})||T,L=e(n,{children:[o.backgroundGraphics,P,O,o.foregroundGraphics]});return y.renderToStaticMarkup(Oa(L,{width:m[0],height:m[1],className:"stream-geo-frame"+(o.className?" "+o.className:""),title:o.title,description:o.description,background:o.background,theme:p,innerTransform:`translate(${null!==(f=v.left)&&void 0!==f?f:0},${null!==(g=v.top)&&void 0!==g?g:0})`,legend:$,idPrefix:o._idPrefix}))}function Ea(t,e){switch(t){case"xy":return Ta(e);case"ordinal":return za(e);case"network":return ja(e);case"geo":return Ca(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Da(t){return Ta(t)}function Ra(t){return za(t)}function Fa(t){return ja(t)}function Na(t){return Ca(t)}const Ba=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Wa(i,o,r){var s;const{data:a,width:l=600,height:c=400,theme:u,title:d,description:h,showLegend:f,showGrid:g,background:p,className:m,annotations:v,margin:b,colorScheme:x,colorBy:k,legendPosition:w}=o,A=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&0>e.indexOf(i)&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);i.length>o;o++)0>e.indexOf(i[o])&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}(o,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),S=[l,c],M=A.frameProps||{},_=function(t,e){const n={};for(const i of e)void 0!==t[i]&&(n[i]=t[i]);return n}(A,Ba),P=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},M),_),{theme:u,title:d,description:h,showLegend:f,showGrid:g,background:p,className:m,annotations:v,size:S}),void 0!==b&&{margin:b}),void 0!==x&&{colorScheme:x}),void 0!==w&&{legendPosition:w}),{_idPrefix:A._idPrefix}),O=wa[i];if(!O)throw Error(`Unknown chart component: "${i}". See CLAUDE.md for supported chart types.`);const T=O.buildProps(a,k,x,P,A);let $=(0,{xy:Ta,ordinal:za,network:ja,geo:Ca}[O.frameType])(T);if("GaugeChart"===i&&T.__gauge){const i=T.__gauge,o=P.margin||{top:20,right:20,bottom:30,left:40},r=(l||300)-o.left-o.right,a=(c||300)-o.top-o.bottom,d=Math.min(r,a)/2*.85,h=o.left+r/2,f=o.top+a/2,g=Math.max(i.gMin,Math.min(i.gMax,null!==(s=i.value)&&void 0!==s?s:i.gMin)),p=(i.startAngleDeg+(i.gMax===i.gMin?0:(g-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,m=Pi(u).colors.text,v=y.renderToStaticMarkup(e(n,{children:[t("line",{x1:h,y1:f,x2:h+d*Math.cos(p),y2:f+d*Math.sin(p),stroke:m,strokeWidth:2.5,strokeLinecap:"round"}),t("circle",{cx:h,cy:f,r:4,fill:m})]}));$=$.replace("</svg>",v+"</svg>")}return $}function Ia(t,e){return At(this,arguments,void 0,function*(t,e,n={}){var i,o,r;const{format:s="png",scale:a=1,background:l}=n;let c,u;c=["xy","ordinal","network","geo"].includes(t)?Ea(t,e):Wa(t,e),l&&(c=c.replace(/<svg /,`<svg style="background:${l}" `));try{const t="sharp",e=yield import(t);u=null!==(i=e.default)&&void 0!==i?i:e}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const d=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*a}).resize(Math.round(d*a),Math.round(h*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})}function Ya(n,i={}){var o;const{title:r,subtitle:s,theme:a,width:l=1200,height:c,layout:u={},background:d}=i,h=Oi(Pi(a)),f=u.columns||2,g=null!==(o=u.gap)&&void 0!==o?o:16;let p=0;r&&(p+=30),s&&(p+=20),p>0&&(p+=10);const m=Math.floor((l-g-g*(f-1))/f),v=[];let b=0,x=p+g,k=0;for(const t of n){const e=Math.min(t.colSpan||1,f),n=t.props.height||300;b+e>f&&(x+=k+g,b=0,k=0),v.push({chart:t,x:g/2+b*(m+g),y:x,w:m*e+g*(e-1),h:n}),k=Math.max(k,n),b+=e}const w=c||x+k+g,A=v.map((e,n)=>{const{chart:i,x:o,y:r,w:s,h:l}=e,c=Object.assign(Object.assign({},i.props),{width:s,height:l,theme:a,_idPrefix:"chart-"+n});let u;return u=i.component?Wa(i.component,c):i.frameType?Ea(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${l}"></svg>`,t("g",{transform:`translate(${o},${r})`,children:t("foreignObject",{width:s,height:l,children:t("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),S=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:w,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t("title",{children:r}),d&&t("rect",{x:0,y:0,width:l,height:w,fill:d}),r&&t("text",{x:l/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),s&&t("text",{x:l/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:s}),A]});return y.renderToStaticMarkup(S)}function Ga(t,e,n,i={}){const{stepSize:o,windowSize:r,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:d="ease-out",decay:h}=i,f=n.width||600,g=n.height||400,p=Pi(n.theme),y=Object.assign(Object.assign(Object.assign({},n),a&&{xExtent:a}),l&&{yExtent:l});if(!e||0===e.length)return[];const m=o||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),v=[];for(let t=m;e.length>=t;t+=m)v.push(t);v[v.length-1]!==e.length&&v.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),x=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-x.left-x.right,w=g-x.top-x.bottom,A=[];if(b)for(let i=0;v.length>i;i++){const o=v[i],s=e.slice(r?Math.max(0,o-r):0,o),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||p.colors.categorical},h&&{decay:h}),l=new Un(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(Va(l.scene,f,g,p,y))}else for(let i=0;v.length>i;i++){const o=v[i],s=e.slice(r?Math.max(0,o-r):0,o),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:l,colorScheme:n.colorScheme||p.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange},h&&{decay:h}),c>0&&{transition:{duration:c*(1e3/u),easing:d}}),b=new Pe(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:k,height:w}),0===b.scene.length)continue;const x=b.scales?{y:b.scales.y}:void 0;if(A.push(qa(b.scene,f,g,p,y,x)),c>0&&i>0&&b.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/c*t),A.push(qa(b.scene,f,g,p,y,x))}}return A}function Ha(t,e,n={}){return e.map(e=>{try{return Wa(t,Object.assign(Object.assign({},n),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||e.width||600}" height="${n.height||e.height||400}"></svg>`}})}function Xa(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function qa(i,o,r,s,a,l){const c=Oi(s),u=Object.assign({top:20,right:20,bottom:30,left:40},a.margin),d=o-u.left-u.right,h=r-u.top-u.bottom,f=Xa(a,s),g=i.map((t,e)=>hi(t,e)).filter(Boolean),p=function(i,o,r,s,a,l){var c;if(!i||0===i.length)return null;const u=Oi(s),d=[];for(let n=0;i.length>n;n++){const s=i[n];if("y-threshold"===s.type&&null!=s.value){let i=null;if(l)i=l(s.value);else if(a){const[t,e]=a,n=e-t;if(0===n)continue;i=r-(s.value-t)/n*r}if(null==i)continue;const h=s.color||u.primary,f=null!==(c=s.strokeWidth)&&void 0!==c?c:1.5,g=s.labelPosition||"right";d.push(e("g",{children:[t("line",{x1:0,y1:i,x2:o,y2:i,stroke:h,strokeWidth:f,strokeDasharray:s.strokeDasharray||"6,4"}),s.label&&t("text",{x:"left"===g?4:"center"===g?o/2:o-4,y:i-5,textAnchor:"left"===g?"start":"center"===g?"middle":"end",fontSize:u.tickSize,fill:h,fontFamily:u.fontFamily,children:s.label})]},"ann-"+n))}}return d.length>0?t(n,{children:d}):null}(a.annotations,d,h,s,a.yExtent,null==l?void 0:l.y),m="string"==typeof a.title?a.title:void 0,v="string"==typeof a.description?a.description:void 0,b=m?"semiotic-title":void 0,x=v?"semiotic-desc":void 0,k=[b,x].filter(Boolean).join(" ")||void 0,w=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:r,role:"img","aria-labelledby":k,style:{fontFamily:c.fontFamily},children:[m&&t("title",{id:b,children:m}),v&&t("desc",{id:x,children:v}),f&&t("rect",{x:0,y:0,width:o,height:r,fill:f}),e("g",{transform:`translate(${u.left},${u.top})`,children:[p,g]}),m&&t("text",{x:o/2,y:16,textAnchor:"middle",fontSize:c.titleSize,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:m})]});return y.renderToStaticMarkup(w)}function Va(n,i,o,r,s){const a=Oi(r),l=Object.assign({top:20,right:20,bottom:30,left:40},s.margin),c="radial"===s.projection,u=c?l.left+(i-l.left-l.right)/2:l.left,d=c?l.top+(o-l.top-l.bottom)/2:l.top,h=Xa(s,r),f=n.map((t,e)=>fi(t,e)).filter(Boolean),g="string"==typeof s.title?s.title:void 0,p="string"==typeof s.description?s.description:void 0,m=g?"semiotic-title":void 0,v=p?"semiotic-desc":void 0,b=[m,v].filter(Boolean).join(" ")||void 0,x=e("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":b,style:{fontFamily:a.fontFamily},children:[g&&t("title",{id:m,children:g}),p&&t("desc",{id:v,children:p}),h&&t("rect",{x:0,y:0,width:i,height:o,fill:h}),t("g",{transform:`translate(${u},${d})`,children:f}),g&&t("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return y.renderToStaticMarkup(x)}function Ua(t,e,n){return At(this,arguments,void 0,function*(t,e,n,i={}){var o,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b;const{fps:x=12,loop:k=!0,scale:w=1,background:A}=i,S=n.height||400,M=Math.round((n.width||600)*w),_=Math.round(S*w),P=Ga(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,i);if(0===P.length)throw Error("No frames generated — check that data is not empty");let O,T,$,L;try{const t="sharp",e=yield import(t);O=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);T=null!==(a=null!==(r=e.GIFEncoder)&&void 0!==r?r:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(c=null===(l=e.default)||void 0===l?void 0:l.default)||void 0===c?void 0:c.GIFEncoder,$=null!==(h=null!==(u=e.quantize)&&void 0!==u?u:null===(d=e.default)||void 0===d?void 0:d.quantize)&&void 0!==h?h:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,L=null!==(m=null!==(p=e.applyPalette)&&void 0!==p?p:null===(y=e.default)||void 0===y?void 0:y.applyPalette)&&void 0!==m?m:null===(b=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===b?void 0:b.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const j=Math.round(1e3/x),z=T();for(let t=0;P.length>t;t++){const e=P[t],n=yield O(Buffer.from(e),{density:72*w}).resize(M,_).ensureAlpha().raw().toBuffer(),i=new Uint8Array(n),o=$(i,256),r=L(i,o);z.writeFrame(r,M,_,{palette:o,delay:j,repeat:k?0:-1})}return z.finish(),Buffer.from(z.bytes())})}export{Ga as generateFrameSVGs,Ha as generateFrameSequence,Wa as renderChart,Ya as renderDashboard,Na as renderGeoToStaticSVG,Fa as renderNetworkToStaticSVG,Ra as renderOrdinalToStaticSVG,Ua as renderToAnimatedGif,Ia as renderToImage,Ea as renderToStaticSVG,Da as renderXYToStaticSVG,Pi as resolveTheme,Oi as themeStyles};