semiotic 3.5.1 → 3.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +21 -19
- package/README.md +22 -16
- package/ai/chartSuggestions.cjs +191 -3
- package/ai/componentMetadata.cjs +3 -3
- package/ai/dist/mcp-server.js +266 -48
- package/ai/examples.md +68 -0
- package/ai/schema.json +900 -1
- package/ai/system-prompt.md +4 -1
- package/dist/components/Tooltip/FlippingTooltip.d.ts +16 -1
- package/dist/components/charts/geo/FlowMap.d.ts +13 -4
- package/dist/components/charts/index.d.ts +6 -0
- package/dist/components/charts/network/OrbitDiagram.d.ts +5 -5
- package/dist/components/charts/network/ProcessSankey.d.ts +141 -0
- package/dist/components/charts/network/processSankey/algorithm.d.ts +136 -0
- package/dist/components/charts/network/processSankey/buildScenes.d.ts +45 -0
- package/dist/components/charts/network/processSankey/ribbonInputs.d.ts +32 -0
- package/dist/components/charts/network/processSankey/streamingLayout.d.ts +58 -0
- package/dist/components/charts/network/processSankey/tooltipUtils.d.ts +41 -0
- package/dist/components/charts/ordinal/BarChart.d.ts +12 -0
- package/dist/components/charts/ordinal/DotPlot.d.ts +9 -0
- package/dist/components/charts/ordinal/GaugeChart.d.ts +20 -0
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +5 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +14 -11
- package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +19 -0
- package/dist/components/charts/shared/axisExtent.d.ts +59 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +75 -0
- package/dist/components/charts/shared/colorUtils.d.ts +8 -2
- package/dist/components/charts/shared/networkUtils.d.ts +3 -5
- package/dist/components/charts/shared/radialGeometry.d.ts +99 -0
- package/dist/components/charts/shared/regressionUtils.d.ts +59 -0
- package/dist/components/charts/shared/selectionUtils.d.ts +8 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +5 -0
- package/dist/components/charts/shared/types.d.ts +13 -0
- package/dist/components/charts/shared/useAreaSeriesSetup.d.ts +75 -0
- package/dist/components/charts/shared/useEncodingDomain.d.ts +48 -0
- package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +1 -1
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +148 -0
- package/dist/components/charts/shared/useOrdinalPieceStyle.d.ts +87 -0
- package/dist/components/charts/shared/useSeriesFeatures.d.ts +57 -0
- package/dist/components/charts/shared/useStreamStatus.d.ts +33 -0
- package/dist/components/charts/shared/useXYLineStyle.d.ts +69 -0
- package/dist/components/charts/shared/useXYPointStyle.d.ts +87 -0
- package/dist/components/charts/xy/AreaChart.d.ts +24 -0
- package/dist/components/charts/xy/BubbleChart.d.ts +9 -0
- package/dist/components/charts/xy/ConnectedScatterplot.d.ts +16 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +172 -0
- package/dist/components/charts/xy/Scatterplot.d.ts +34 -0
- package/dist/components/geometry/ribbonGeometry.d.ts +76 -0
- package/dist/components/semiotic-ai.d.ts +2 -0
- package/dist/components/semiotic-network.d.ts +4 -0
- package/dist/components/semiotic-realtime.d.ts +2 -0
- package/dist/components/semiotic-utils.d.ts +4 -0
- package/dist/components/semiotic-xy.d.ts +2 -0
- package/dist/components/semiotic.d.ts +3 -3
- package/dist/components/server/serverChartConfigs.d.ts +2 -0
- package/dist/components/stream/GeoPipelineStore.d.ts +21 -0
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +8 -0
- package/dist/components/stream/PipelineStore.d.ts +5 -0
- package/dist/components/stream/SVGOverlay.d.ts +18 -0
- package/dist/components/stream/annotationAccessorResolver.d.ts +39 -0
- package/dist/components/stream/geoTypes.d.ts +12 -0
- package/dist/components/stream/ordinalTypes.d.ts +12 -0
- package/dist/components/stream/renderers/cornerRadii.d.ts +33 -0
- package/dist/components/stream/types.d.ts +23 -0
- package/dist/components/types/legendTypes.d.ts +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +2 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +4 -0
- package/dist/semiotic-realtime.d.ts +2 -0
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-utils.d.ts +4 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +2 -0
- package/dist/semiotic.d.ts +3 -3
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +10 -5
package/dist/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),e=require("react"),i=require("react-dom/server"),o=require("d3-scale"),r=require("d3-quadtree"),n=require("d3-array"),s=require("d3-interpolate"),a=require("d3-force"),c=require("d3-chord"),l=require("d3-shape"),u=require("d3-hierarchy"),h=require("d3-geo");function d(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const f=d(e),g=d(i);function y(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class p{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 i of t){const t=this.push(i);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 i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.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 i}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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 m{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 i of t){const t=e?e(i):i;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 x(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function v(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);Number.isFinite(t)&&Number.isFinite(n)&&s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function b(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function k(t,e,i,o){var r,n,s;const a=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const r of e)t+=i(r,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 n=t[o-1],s=t[o];let c=0,l=0,u=0;for(const t of e){const e=i(t,s)||0;c+=(2*u+e)*(e-(i(t,n)||0)),l+=e,u+=e}const h=null!==(r=a.get(n))&&void 0!==r?r:0;a.set(s,h-(l>0?c/(2*l):0))}if(t.length>0){let o=0;for(const r of t){let t=0;for(const o of e)t+=i(o,r)||0;o+=(null!==(n=a.get(r))&&void 0!==n?n:0)+t/2}const r=o/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-r)}}else for(const e of t)a.set(e,0);return a}function A(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function w(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function S(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function _(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function P(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function j(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function M(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function O(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function E(t,e,i){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function L(t){const e=t.map(O),i=e.length-1;return t=>{if(0>=t){const[t,i,o]=e[0];return E(t,i,o)}if(t>=1){const[t,o,r]=e[i];return E(t,o,r)}const o=t*i,r=Math.floor(o),n=o-r,[s,a,c]=e[r],[l,u,h]=e[r+1];return E(Math.round(s+(l-s)*n),Math.round(a+(u-a)*n),Math.round(c+(h-c)*n))}}const T=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],D=L(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),z=L(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),$=L(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),R=L(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),C=L(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),N=L(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),F=L(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),B=L(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),W=L(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Y=L(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),I=L(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),X=L(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);L(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),L(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),L(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),L(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),L(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),L(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),L(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const q={category10:T,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:D,reds:z,greens:$,oranges:R,purples:C,viridis:F,plasma:B},G=T,V=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],H=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 Q(t,e,i="category10"){const r=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),n=r.every(t=>!isNaN(Number(t)));if(Array.isArray(i))return o.scaleOrdinal().domain(r).range(i).unknown("#999");const s=q[i]||q.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of r){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:G;return o.scaleOrdinal().domain(r).range(t).unknown("#999")}}function U(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function Z(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function K(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function J(t,e){return Math.min((t-e.startTime)/e.duration,1)}function tt(t,e,i){return t+(e-t)*i}function et(){return"undefined"!=typeof performance?performance.now():Date.now()}function it(t,e,i){var o,r,n,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 i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function ot(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function rt(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=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!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=A(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const nt={blues:D,reds:z,greens:$,viridis:F,oranges:R,purples:C,greys:N,plasma:B,inferno:W,magma:Y,cividis:I,turbo:X},st=new Map;class at{constructor(t){if(this.xExtent=new m,this.yExtent=new m,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 p(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=P(t.timeAccessor||t.xAccessor,"time"),this.getY=P(t.valueAccessor||t.yAccessor,"value")):(this.getX=P(t.xAccessor,"x"),this.getY=P(t.yAccessor,"y")),this.getGroup=M(t.groupAccessor),this.getCategory=M(t.categoryAccessor),this.getSize=t.sizeAccessor?P(t.sizeAccessor,"size"):void 0,this.getColor=M(t.colorAccessor),this.getBounds=t.boundsAccessor?P(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?P(t.y0Accessor,"y0"):void 0,this.getPointId=M(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?P(t.openAccessor,"open"):void 0,this.getHigh=P(t.highAccessor,"high"),this.getLow=P(t.lowAccessor,"low"),this.getClose=i?P(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new p(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))}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?P(this.config.timeAccessor||this.config.xAccessor,"time"):P(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i 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(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(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!0}computeScene(t){var e,i,r,n,s,a,c,l,u,h,d,f,g,y;const{config:p,buffer:m}=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(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),b=this.xExtent.extent,A=this.yExtent.extent;let w=p.xExtent?[null!==(i=p.xExtent[0])&&void 0!==i?i:b[0],null!==(r=p.xExtent[1])&&void 0!==r?r:b[1]]:b,S=p.yExtent?[null!==(n=p.yExtent[0])&&void 0!==n?n:A[0],null!==(s=p.yExtent[1])&&void 0!==s?s:A[1]]:A;const _=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1];if("stackedarea"===p.chartType&&!_&&m.size>0)if(p.normalize)S=[0,1+p.extentPadding];else{const t=`${m.size}:${this._ingestVersion}:${null!==(a=p.baseline)&&void 0!==a?a:"zero"}:${null!==(c=p.stackOrder)&&void 0!==c?c:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)S=this._stackExtentCache.yDomain;else{const e=this.groupData(v),i=new Map,o=new Set;let r=0;const n=new Map,s=new Map;for(const t of e){const e=new Map;let a=0;for(const i of t.data){const t=this.getX(i),s=this.getY(i);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),o.add(t),a+=s;const c=(n.get(t)||0)+s;n.set(t,c),c>r&&(r=c)}i.set(t.key,e),s.set(t.key,a)}const a=null!==(l=p.stackOrder)&&void 0!==l?l:"key",c=(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 i,o;const r=(null!==(i=s.get(e))&&void 0!==i?i:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==r?r:c(t,e)}),i=[],o=[];let r=0,n=0;for(const e of t)n>r?(i.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0):(o.push(e),n+=null!==(h=s.get(e))&&void 0!==h?h:0);g=[...o.reverse(),...i]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var i,o;const r=(null!==(i=s.get(t))&&void 0!==i?i:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==r?r:c(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var i,o;const r=(null!==(i=s.get(e))&&void 0!==i?i:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==r?r:c(t,e)}):e.map(t=>t.key).sort(c);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=k(t,g,(t,e)=>{var o;return(null===(o=i.get(t))||void 0===o?void 0:o.get(e))||0},p.baseline);let r=1/0,s=-1/0;for(const i of t){const t=null!==(d=e.get(i))&&void 0!==d?d:0,o=null!==(f=n.get(i))&&void 0!==f?f:0;r>t&&(r=t),t+o>s&&(s=t+o)}Number.isFinite(r)&&Number.isFinite(s)||(r=0,s=0);const a=s-r,c=a>0?a*p.extentPadding:1;S=[r-c,s+c]}else S=[0,r+(r>0?r*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:S}}}else if("bar"===p.chartType&&p.binSize&&!_&&m.size>0){const[,t]=function(t,e,i,o,r){const n=x(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(m,this.getX,this.getY,p.binSize,this.getCategory);S=[0,t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!_&&m.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(m,this.getY),i=e-t,o=i>0?i*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.getBounds)for(const t of v){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>S[1]&&(S[1]=e+i),S[0]>e-i&&(S[0]=e-i))}const t=S[1]-S[0],e=t>0?t*p.extentPadding:1,i=null===(g=p.yExtent)||void 0===g?void 0:g[0],o=null===(y=p.yExtent)||void 0===y?void 0:y[1];S=[null!=i?S[0]:S[0]-e,null!=o?S[1]:S[1]+e],"log"===p.yScaleType&&0>=S[0]&&A[0]>0&&(S[0]=null!=i?S[0]:A[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(w[0]===1/0||w[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();w=[t-864e5,t]}else w=[0,1];S[0]!==1/0&&S[1]!==-1/0||(S=[0,1]);const P="streaming"===p.runtimeMode,j=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(M=p.arrowOfTime)||"down"===M?"y":"x")){const e="right"===p.arrowOfTime?[j,t.width-j]:[t.width-j,j];this.scales={x:o.scaleLinear().domain(w).range(e),y:o.scaleLinear().domain(S).range([t.height-j,j])}}else{const e="down"===p.arrowOfTime?[j,t.height-j]:[t.height-j,j];this.scales={x:o.scaleLinear().domain(S).range([j,t.width-j]),y:o.scaleLinear().domain(w).range(e)}}else{const e=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(i).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(i):o.scaleLinear().domain(e).range(i)};this.scales={x:e(p.xScaleType,w,[j,t.width-j]),y:e(p.yScaleType,S,[t.height-j,j])}}var M;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),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,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,at.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let n=0;for(const t of this.scene)"point"===t.type&&(o[n++]=t);this._quadtree=r.quadtree().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,i=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]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const r=this.scales.x.domain(),n=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(i).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(i):o.scaleLinear().domain(e).range(i)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:c(this.config.xScaleType,r,s[0]>s[1]?[t.width-l,l]:[l,t.width-l]),y:c(this.config.yScaleType,n,u?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(t,e){var i,o,r,n,s,a,c;const{config:l,scales:u}=this;if(!u)return[];if(l.customLayout){const c=null!==(i=l.layoutMargin)&&void 0!==i?i:{top:0,right:0,bottom:0,left:0},h={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:c,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(o=l.themeSemantic)&&void 0!==o?o:{},categorical:null!==(r=l.themeCategorical)&&void 0!==r?r:V},resolveColor:(t,e)=>{var i,o;const r=this.resolveGroupColor(t);if(r)return r;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:null!==(o=null===(i=l.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==o?o:"#4e79a7"},config:null!==(n=l.layoutConfig)&&void 0!==n?n:{}};let d;try{d=l.customLayout(h)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=d.overlays)&&void 0!==s?s:null,null!==(a=d.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const h={scales:u,config:l,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,getBounds:this.getBounds,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(l.chartType){case"line":return function(t,e){var i;const o=t.groupData(e),r=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of o){const i=ot(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=v(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return rt(t,o,r),r}(h,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=b(e.data,t.scales,t.getX,t.getY,r,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return rt(t,i,o),o}(h,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=b(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=v(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return rt(t,i,o),o}(h,e);case"stackedarea":return function(t,e){var i,o,r,n;const s=t.groupData(e),a=null!==(i=t.config.stackOrder)&&void 0!==i?i:"key",c=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)c();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const i of s){let o=0;for(const e of i.data){const i=t.getX(e),r=t.getY(e);Number.isFinite(i)&&Number.isFinite(r)&&(o+=r)}e.set(i.key,o)}const i=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,o)=>{var r,n;const s=(null!==(r=e.get(t.key))&&void 0!==r?r:0)-(null!==(n=e.get(o.key))&&void 0!==n?n:0);return 0!==s?s:i(t.key,o.key)});else if("desc"===a)s.sort((t,o)=>{var r,n;const s=(null!==(r=e.get(o.key))&&void 0!==r?r:0)-(null!==(n=e.get(t.key))&&void 0!==n?n:0);return 0!==s?s:i(t.key,o.key)});else{const t=[...s].sort((t,o)=>{var r,n;const s=(null!==(r=e.get(o.key))&&void 0!==r?r:0)-(null!==(n=e.get(t.key))&&void 0!==n?n:0);return 0!==s?s:i(t.key,o.key)}),n=[],a=[];let c=0,l=0;for(const i of t)l>c?(n.push(i),c+=null!==(o=e.get(i.key))&&void 0!==o?o:0):(a.push(i),l+=null!==(r=e.get(i.key))&&void 0!==r?r:0);s.length=0,s.push(...a.reverse(),...n)}}else c();const l=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(n=t.config.baseline)&&void 0!==n?n:"zero",{nodes:h,stackedTops:d}=function(t,e,i,o,r,n,s,a="zero"){var c,l;const u=new Set;for(const e of t)for(const t of e.data){const e=i(t);Number.isFinite(e)&&u.add(e)}const h=Array.from(u).sort((t,e)=>t-e),d=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);Number.isFinite(e)&&Number.isFinite(n)&&t.set(e,(t.get(e)||0)+n)}d.set(e.key,t)}let f;if(n){f=new Map;for(const e of h){let i=0;for(const o of t)i+=(null===(c=d.get(o.key))||void 0===c?void 0:c.get(e))||0;f.set(e,i||1)}}const g=k(h,t.map(t=>t.key),(t,e)=>{var i;return(null===(i=d.get(t))||void 0===i?void 0:i.get(e))||0},a),y=[],p=new Map,m=new Map;for(const t of h)m.set(t,null!==(l=g.get(t))&&void 0!==l?l:0);for(const i of t){const t=d.get(i.key),o=[],a=[],c=new Map;for(const i of h){let r=t.get(i)||0;const s=m.get(i);n&&(r/=f.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),o.push([u,e.y(l)]),m.set(i,l),c.set(i,l)}p.set(i.key,c);const l={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(l.curve=s),y.push(l)}return{nodes:y,stackedTops:p}}(s,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,l,u),f=h;if(t.config.pointStyle){const e=new WeakMap;for(const i of s){const o=d.get(i.key);if(o)for(const r of i.data){const i=t.getX(r),n=t.getY(r);null==i||Number.isNaN(i)||null==n||Number.isNaN(n)||!o.has(i)||e.set(r,o.get(i))}}const i=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};rt(t,s,f,i)}return f}(h,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,u=A(i,t.scales,t.getX,t.getY,n,e,l);u&&o.push(u)}return o}(h,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=P(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(h-u||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>h)continue;const f=h*s+c;m[f]++;const p=l(o);x[f]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const k=b-v||1,A=i.width/s,w=i.height/a,_=t.config.showValues,j=t.config.heatmapValueFormat,M=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=x[o];break;case"mean":r=x[o]/m[o];break;default:r=m[o]}const n=(r-v)/k;M.push(S(i*A,(a-1-t)*w,A,w,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:x[o],xCenter:u+(i+.5)*g,yCenter:d+(t+.5)*y,agg:c},_?{value:r,showValues:!0,valueFormat:j}:void 0))}}return M}(t,e,i);if(0===e.length)return[];const o=P(t.config.valueAccessor,"value"),r=j(t.config.xAccessor,"x"),n=j(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=r(i),u=n(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),g=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),v=new Map;let b=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(c[t]),n=a.get(l[t]);if(void 0===r||void 0===n)continue;const h=o(i),d=n*u+r,f=v.get(d);let g;void 0!==f?g=f:(g=b++,v.set(d,g)),p[g]=d,m[g]=h,x[g]=i}let k=1/0,A=-1/0;for(let t=0;b>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>A&&(A=e))}if(!isFinite(k)||!isFinite(A))return[];const w=function(t){const e=t in nt?t:"blues";let i=st.get(e);if(i)return i;i=Array(256);const o=nt[e]||D;for(let t=0;256>t;t++)i[t]=o(t/255);return st.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(A-k||1),M=i.width/u,O=i.height/h,E=t.config.showValues,L=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const i=p[t],o=i%u;T.push(S(o*M,(h-1-(i-o)/u)*O,M,O,w[Math.min((e-k)*_+.5|0,255)],x[t],E?{value:e,showValues:!0,valueFormat:L}:void 0))}return T}(h,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=x(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),u=t.config.barStyle,h=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==u?void 0:u.gap,f="number"!=typeof d||0>d?1:d,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 r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,x=Math.min(d,y)+m/2,v=Math.max(p-m,1);if(v>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==u?void 0:u.fill)||h||"#4e79a7";s.push(w(x,Math.min(c,l),v,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(w(x,Math.min(t,i),v,Math.abs(t-i),Object.assign({fill:(null==u?void 0:u.fill)||h||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(h,e);return this._barCategoryCache=null!==(c=h.barCategoryCache)&&void 0!==c?c:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n,s,a;const c=[],l=t.config.swarmStyle||{},u=null!==(i=l.radius)&&void 0!==i?i:3,h=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),n=t.scales.y(o);let s=h;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:u,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(h,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const u=[],h=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,x=null==d?void 0:d.strokeWidth,v=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=h.x(r),l=0!==a?h.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const S=h.y(b),_=h.y(s),P=Math.min(S,_),j=Math.abs(S-_),M={fill:0>n?y:g,stroke:m,strokeWidth:x};null!=v&&(M.opacity=v),u.push(w(k,P,A,j,M,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return u}(h,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),d=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(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-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 i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(h,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?U(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=U(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=U(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=U(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=U(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=Z(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=Z(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-n}(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,i,o){var r,n,s,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],u=it(t,l,c);u&&("point"===l.type?i.set(u,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(u,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(u,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(u,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;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],r=it(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{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,i,o,r){var n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b,k,A,w,S,_,P,j,M,O,E,L,T,D,z,$,R,C,N,F,B,W,Y,I,X,q;if(0===o.size&&0===r.size)return i;const G=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let V=!1;const H=new Set,Q=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],E=it(t,n,e);if(!E)continue;if(n._transitionKey=E,"line"===n.type||"area"===n.type){const t=r.get(E);if(t){if(Q.add(E),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];V=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];V=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;continue}const L=o.get(E);if("point"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=L.x,n.y=L.y,n.r=null!==(h=L.r)&&void 0!==h?h:n.r,V=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("rect"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(g=L.w)&&void 0!==g?g:n.w,n.h=null!==(y=L.h)&&void 0!==y?y:n.h,V=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("heatcell"===n.type)if(L){H.add(E);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(x=null===(m=n.style)||void 0===m?void 0:m.opacity)&&void 0!==x?x:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(v=L.w)&&void 0!==v?v:n.w,n.h=null!==(b=L.h)&&void 0!==b?b:n.h,V=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0;else if("candlestick"===n.type)if(L&&null!=L.openY){H.add(E);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.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)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=L.x,n.openY=L.openY,n.closeY=null!==(_=L.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=L.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(j=L.lowY)&&void 0!==j?j:n.lowY,V=!0)}else n._targetOpacity=null!==(O=null===(M=n.style)||void 0===M?void 0:M.opacity)&&void 0!==O?O:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0}for(const[t,e]of r)if(!Q.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=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!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!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}for(const[t,e]of o)if(!H.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(T=e.r)&&void 0!==T?T:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==($=e.h)&&void 0!==$?$:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(C=e.w)&&void 0!==C?C: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};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(B=e.openY)&&void 0!==B?B:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(W=e.closeY)&&void 0!==W?W:o,highY:null!==(Y=e.highY)&&void 0!==Y?Y:o,lowY:null!==(I=e.lowY)&&void 0!==I?I:o,bodyWidth:null!==(X=e.w)&&void 0!==X?X:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(q=e.opacity)&&void 0!==q?q:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}V=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),V&&(i.activeTransition={startTime:et(),duration:G}),i}(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},i=function(t,e,i,o){var r,n,s,a,c,l;if(!i.activeTransition)return!1;const u=J(t,i.activeTransition),h=K(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=tt(n,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),t.y=tt(i.y,t._targetY,h),void 0!==t._targetR&&void 0!==i.r&&(t.r=tt(i.r,t._targetR,h))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=tt(r,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),t.y=tt(i.y,t._targetY,h),void 0!==i.w&&(t.w=tt(i.w,t._targetW,h)),void 0!==i.h&&(t.h=tt(i.h,t._targetH,h))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:tt(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),t.y=tt(i.y,t._targetY,h),void 0!==i.w&&(t.w=tt(i.w,t._targetW,h)),void 0!==i.h&&(t.h=tt(i.h,t._targetH,h))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:tt(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),void 0!==i.openY&&(t.openY=tt(i.openY,t._targetOpenY,h)),void 0!==i.closeY&&(t.closeY=tt(i.closeY,t._targetCloseY,h)),void 0!==i.highY&&(t.highY=tt(i.highY,t._targetHighY,h)),void 0!==i.lowY&&(t.lowY=tt(i.lowY,t._targetLowY,h))}else if("line"===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:tt(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=tt(e[o][0],i[o][0],h),t.path[o][1]=tt(e[o][1],i[o][1],h)}else if("area"===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:tt(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=tt(e[i][0],o[i][0],h),t.topPath[i][1]=tt(e[i][1],o[i][1],h);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=tt(i[e][0],r[e][0],h),t.bottomPath[e][1]=tt(i[e][1],r[e][1],h)}}if(u>=1){for(const t of i.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 i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.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,i}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 i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}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 i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||V,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#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 i=(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)||V;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>at.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]),i=this.getPointId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);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.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)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)=>{r.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++,n}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,i,o,r;const n=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||"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 c="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(c||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const l=c||!_(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),u=c||!_(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(l||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=P(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=P(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=P(this.config.xAccessor,"x"),this.getY=P(this.config.yAccessor,"y")),s=!0,a=!0)}if("groupAccessor"in t&&!_(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?M(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!_(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?M(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!_(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?P(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!_(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!_(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?P(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),"boundsAccessor"in t&&!_(t.boundsAccessor,n.boundsAccessor)&&(this.getBounds=this.config.boundsAccessor?P(this.config.boundsAccessor,"bounds"):void 0,s=!0,a=!0),"pointIdAccessor"in t&&!_(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?M(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(c||"openAccessor"in t&&!_(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!_(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!_(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!_(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?P(this.config.openAccessor,"open"):void 0,this.getHigh=P(this.config.highAccessor,"high"),this.getLow=P(this.config.lowAccessor,"low"),this.getClose=e?P(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 i of e)if(t[i]!==n[i]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function ct(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function lt(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);o.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=d}return o}function ut(t){return t.y0-t.y1>0?"up":"down"}function ht(t,e){return e(t.source)==e(t.target)}function dt(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function ft(t){return t.target.x0-t.source.x1}function gt(t,e){var i=pt(t),o=ft(e)/Math.tan(i);return"up"==ut(t)?t.y1-o:t.y1+o}function yt(t,e){var i=pt(t),o=ft(e)/Math.tan(i);return"up"==ut(t)?t.y1+o:t.y1-o}function pt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function mt(t,e){return e(t)}function xt(t){return bt(t.source)}function vt(t){return bt(t.target)}function bt(t){return(t.y0+t.y1)/2}function kt(t){return t.virtual?0:t.value}function At(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!ht(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!ht(t,e)?o+1:o}),i+o}function wt(t){return t.target.depth}function St(t,e){return t.sourceLinks.length?t.depth:e-1}function _t(t,e){return t.y0-e.y0}function Pt(t,e){return e.y0-t.y0}function jt(t,e){return t.y1-e.y1}function Mt(t,e){return e.y1-t.y1}function Ot(t,e){return Lt(t.source,e.source)||t.index-e.index}function Et(t,e){return Lt(t.target,e.target)||t.index-e.index}function Lt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Tt(t,e){return Dt(t)==Dt(e)?"bottom"==t.circularLinkType?Pt(t,e):_t(t,e):Dt(e)-Dt(t)}function Dt(t){return t.target.column-t.source.column}function zt(t,e){return $t(t)==$t(e)}function $t(t){return t.y0-t.y1>0?"up":"down"}function Rt(t,e,i,o,r){let s=t;var a=Math.max(8,.15*(s.y1-s.y0));s.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var c=n.min(s.links,function(t){return t.source.y0});s.links.forEach(function(t){t.circular&&(t.circularPathData={})});var l=s.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}),Ct(s.links.filter(function(t){return"top"==t.circularLinkType}),e,i),Ct(s.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),s.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,ht(t,e)&&dt(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+r+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-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var n=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==n&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?Pt:_t);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),n=t.target.column,(l=s.links.filter(function(t){return t.target.column==n&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?Mt:jt),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-r-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,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),s}function Ct(t,e,i){t.sort(Tt);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(ht(t,e)&&dt(t))t.circularPathData.verticalBuffer=n+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&&Nt(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function Nt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Ft(t){return function(){return t}}function Bt(t){return t.index}function Wt(t){return t.nodes}function Yt(t){return t.links}function It(t,e,i){var o=n.groups(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(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=bt(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=bt(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=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(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?At(e,i)-At(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){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==At(e,i)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function Xt(t,e,i,o,r,s){var a=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});h();for(var c=1,l=s;l>0;--l)u(c*=.99,i),h();function u(e,i){var o=a.length;a.forEach(function(r){var s=r.length,a=r[0].depth;r.forEach(function(r){var c;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&At(r,i)>0){var l=n.mean(r.sourceLinks,vt),u=n.mean(r.targetLinks,xt),h=l&&u?(l+u)/2:l||u;if(h){var d=(h-bt(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(a==o-1&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)c=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+c;else{var f=n.mean(r.sourceLinks,vt),g=n.mean(r.targetLinks,xt),y=((f&&g?(f+g)/2:f||g)-bt(r))*e;r.y0+=y,r.y1+=y}})})}function h(){a.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||Lt),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function qt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Et),t.targetLinks.sort(Ot)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=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=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function Gt(){var t=0,e=0,i=1,o=1,r=24,s=8,a=null,c=Bt,l=St,u=void 0,h=32,d=2,f=Wt,g=Yt;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=o,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return n.group(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=ct(i,o)),"object"!=typeof r&&(r=t.target=ct(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(f,c),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=lt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(f,u),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){mt(t,e)!=mt(r.source,e)&&mt(t,e)!=mt(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),ht(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(n.sum(t.sourceLinks,kt),n.sum(t.targetLinks,kt)),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)})})}(f),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-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,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(f,u,l);var g=s;if(null!==a){var y=n.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=n.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(o-e)*a/(p-1)))}(function(t,e,i){var o=n.groups(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 r=n.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/n.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var s=n.max(t.nodes,function(t){return t.column});t.nodes.forEach(s>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/s),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(f,g,r),It(f,u,c),Xt(f,u,c,g,g,h),qt(f),Rt(f,c,d,10,8),It(f,u,c),Xt(f,u,c,g,g,h),qt(f),Rt(f,c,d,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return mt(i.source,e)==mt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!zt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=gt(e,t);return t.y1-i}if(e.target.column>t.target.column)return gt(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 n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(f,c),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return mt(i.target,e)==mt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!zt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=yt(e,t);return t.y0-i}if(e.source.column>t.source.column)return yt(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 n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(f,c),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var s=n.min(e,function(t){return t.y0}),a=n.max(e,function(t){return t.y1}),c=(t.y1-t.y0)/(a-s);function l(e){return(e-s)/(a-s)*(t.y1-t.y0)+t.y0}1>c?(e.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1)}),i.forEach(function(t){t.y0=l(t.y0),t.y1=l(t.y1),t.width=t.width*c})):e.forEach(function(t){var e=t.y1-t.y0,i=l(t.y0)-t.y0;t.y0=l(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(f),Rt(f,c,d,10,8)}(y),y}return y.update=function(t){return qt(t),Rt(t,c,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(r=+t,y):r},y.nodePadding=function(t){return arguments.length?(s=+t,y):s},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Ft(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:Ft(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:Ft(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:Ft(t),y):l},y.nodeSort=function(t){return arguments.length?(u=t,y):u},y.iterations=function(t){return arguments.length?(h=+t,y):h},y.circularLinkGap=function(t){return arguments.length?(d=+t,y):d},y.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],y):[[t,e],[i,o]]},y.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],y):[i-t,o-e]},y}at.GROUP_COLOR_MAP_CAP=1e3,at.QUADTREE_THRESHOLD=500;const Vt=t=>{let e,i,o,r,n,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,a=t.target.x0,c=s.interpolateNumber(n,a),l=c(.5),u=c(.5),`M${e},${n}C${e},${l} ${i},${u} ${i},${a}L${o},${a}C${o},${u} ${r},${l} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,c=s.interpolateNumber(e,i),o=c(.5),r=c(.5),n=t.y0-t.sankeyWidth/2,a=t.y1-t.sankeyWidth/2,l=t.y1+t.sankeyWidth/2,u=t.y0+t.sankeyWidth/2,`M${e},${n}C${o},${n} ${r},${a} ${i},${a}L${i},${l}C${r},${l} ${o},${u} ${e},${u}Z`)};function Ht(t){var e;const i=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,o=r.sourceY,n=r.targetX,s=r.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*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${h+d*o-d*f}L${l+o-f},${h+d*o}L${u-o+f},${h+d*o}L${u-o},${h+d*o-d*f}L${u-o},${c-d*i+d*f}L${u-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${u+o},${c+d*i}L${u+o},${h-d*o}L${l-o},${h-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Qt=new Set,Ut=new WeakMap;function Zt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=Ut.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Ut.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Qt.has(t)||(Qt.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}const Kt={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(wt))-1:0},justify:St};function Jt(t){return"string"==typeof t?t:t.id}const te={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=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 x;x="down"===h?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const v=Gt().extent(x).links(m).nodes(p).nodeAlign(Kt[d]||St).nodeId(t=>t.id).nodeWidth(f).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,u=o[0],h=o[1];if(n>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/n,h/s),o=-t*e+(u-n*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.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=Jt(t.source),i=Jt(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);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=h;const r=b.get(e),n=b.get(i);r&&(o.source=r),n&&(o.target=n)}}},buildScene(t,e,i,o){var r,n,s,a,c,l;const u="vertical"===i.orientation?"down":"right",h=i.nodeStyle,d=i.edgeStyle,f=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:T,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],x=[],v=[],b=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=h?h(Zt(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.set(e.id,("string"==typeof r.fill?r.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,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 r=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";r="function"==typeof g?g(t)||r:"target"===g?b.get(o.id)||p.get(o.id)||r:b.get(e.id)||p.get(e.id)||r;const u=d?d(Zt(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),n=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||r;x.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}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}}),x.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-n},${e.targetY-i}L${e.targetX-n},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:s,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-n,x1:e.targetX}});continue}let h;if(h=t.circular&&t.circularPathData?Ht(t):Vt(t),!h)continue;const y={fill:u.fill||r,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};x.push({type:"bezier",pathD:h,bezierCache:t.bezier,style:y,datum:t})}if(!1!==i.showLabels){const e=(A=i.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,c;"down"===u?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="start"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),v.push({x:s,y:a,text:n+"",anchor:"down"===u?"middle":c,baseline:"middle",fontSize:11})}}var A;return{sceneNodes:m,sceneEdges:x,labels:v}}},ee={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,c=o[0]/2,l=o[1]/2,u=i.__previousPositions;let h=0;const d=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=null==u?void 0:u.get(e.id);t?h++:i?(e.x=i.x,e.y=i.y,h++):d.push(e)}const f=h>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of d){const o=ie(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=oe(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=oe(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=c+o*Math.cos(i),t.y=l+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=c+t*Math.cos(r),o.y=l+t*Math.sin(r)}}}const g=null!==(n=i.iterations)&&void 0!==n?n:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),y=0===i.iterations?0:f?40:g,p=re(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=a.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=a.forceSimulation().force("charge",a.forceManyBody().strength(t=>-25*m(t))).force("center",a.forceCenter(c,l).strength(.8)).force("x",a.forceX(c).strength(.15)).force("y",a.forceY(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}));o.force("link",i),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;y>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=m(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 x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=x.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=x.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){var r,n,s,a,c,l,u;const h=i.nodeStyle,d=i.edgeStyle,f=re(i.nodeSize,i.nodeSizeRange,t),g=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:T,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],x=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Zt(e,"nodeSize")),o=h?h(Zt(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),o="object"==typeof t.target?t.target:v.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=d?d(Zt(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(a=i.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=i.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(u=r.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(b=i.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=f(Zt(i,"nodeSize"));x.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:x}}};function ie(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function oe(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function re(t,e,i){var r,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],c=i.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>a[0];const l=null!==(r=n.min(c))&&void 0!==r?r:0,u=null!==(s=n.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=o.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?a[0]:h(o)}}const ne=T,se={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,u=a-n,h=o[0]/2,d=o[1]/2,f=(g=i.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const p=t.length,m=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=y.get("string"==typeof t.source?t.source:t.source.id),o=y.get(e);if(void 0===i||void 0===o)continue;const r=f(t);m[i][o]=r}const x=c.chord().padAngle(r);s&&x.sortGroups(s);const v=x(m),b=v.groups,k=l.arc().innerRadius(u).outerRadius(a);for(const e of b){const i=t[e.index],o=k.centroid({innerRadius:u,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});i.x=o[0]+h,i.y=o[1]+d,i.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const A=new Map;for(const e of t)A.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=A.get("string"==typeof t.source?t.source:t.source.id),o=A.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.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 v){const i=t[e.source.index].id,o=t[e.target.index].id,r=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);r&&(r.__chordData=e)}},buildScene(t,e,i,o){var r,n,s,a;const{groupWidth:l=20,edgeOpacity:u=.5}=i,h=Math.min(o[0],o[1])/2,d=h-l,f=o[0]/2,g=o[1]/2,y=i.nodeStyle,p=i.edgeStyle,m=i.edgeColorBy||"source",x=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:ne,v=new Map;t.forEach((t,e)=>{v.set(t.id,x[e%x.length])});const b=c.ribbon().radius(d),k=[],A=[],w=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.__arcData;if(!o)continue;let n;n=y?y(Zt(i,"nodeStyle")).fill||v.get(i.id)||x[e%x.length]:v.get(i.id)||x[e%x.length];const s=y?y(Zt(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:d,outerR:h,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=b(e);if(!o)continue;const r=ae(o,f,g);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)c=p(Zt(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===m&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const l=p?p(Zt(t,"edgeStyle")):{},h={fill:c,fillOpacity:null!==(a=l.fillOpacity)&&void 0!==a?a:u,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};A.push({type:"ribbon",pathD:r,style:h,datum:t})}if(!1!==i.showLabels){const e=(S=i.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=h+12;for(const i of t){const t=i.__arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;w.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:A,labels:w}}};function ae(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const ce=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function le(t){const[e,i,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*i+.114*o>150?"#222":"#fff"}function ue(t,e,i){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-"+i}function he(t){return t?"function"==typeof t?t:e=>{var i;return(null===(i=e.data)||void 0===i?void 0:i[t])||e[t]||e.id}:null}function de(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:ce}function fe(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 ge(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const ye={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="function"==typeof c?c:"string"==typeof c?t=>Number(t[c])||0:t=>Number(t.value)||0,h=u.hierarchy(n,a);h.sum(l),h.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[d,f]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.tree();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.cluster();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=u.treemap().size([i,o]).tile(u.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,d,f);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;u.pack().size([i,o]).padding(n)(t)}(h,i,d,f);break;case"partition":!function(t,e,i,o){var r;u.partition().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,d,f)}const g=h.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const o=g[e],n={id:ue(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?pe(n,o,i):"treemap"===s||"partition"===s?me(n,o):"circlepack"===s&&xe(n,o),n.__hierarchyNode=o,t.push(n),y.set(o,n)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const i=y.get(t.parent),o=y.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",x="radial"===m,v=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;x&&(t+=v,o+=b);const n=r(Zt(e,"nodeStyle"));let c=n.fill||fe(i);if(i.colorByDepth&&void 0!==e.depth){const t=de(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.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 r=e.x,s=e.y,a=o.x,c=o.y;x&&(r+=v,s+=b,a+=v,c+=b);const f=ge(r,s,a,c,m),g=n(Zt(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(u=i.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(h=g.strokeWidth)&&void 0!==h?h:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=he(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(x&&(s+=v,a+=b),x){const t=s-v,e=a-b,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],u=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o(Zt(i,"nodeStyle"));let c=a.fill||fe(e);if(e.colorByDepth&&void 0!==i.depth){const t=de(e);c=t[i.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=he(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,h=l.y1-l.y0;if(0>=t||0>=h)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>h)continue;let g=o(Zt(l,"nodeStyle")).fill||fe(e);if(e.colorByDepth&&void 0!==l.depth){const t=de(e);g=t[l.depth%t.length]}const y="string"==typeof g?le(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";u.push(d?{x:l.x0+t/2,y:l.y0+h/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,h)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,u,h,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o(Zt(i,"nodeStyle"));let l=c.fill||fe(e);if(e.colorByDepth&&void 0!==i.depth){const t=de(e);l=t[i.depth%t.length]}const u={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=he(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o(Zt(r,"nodeStyle")).fill||fe(e);if(e.colorByDepth&&void 0!==r.depth){const t=de(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?le(a):null!==(h=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==h?h:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.push({x:r.x,y:r.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(d=e.themeSemantic)||void 0===d?void 0:d.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pe(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-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 me(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 xe(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i: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 ve(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const be={sankey:te,force:ee,chord:se,tree:ye,cluster:ye,treemap:ye,circlepack:ye,partition:ye,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),h=null!==(n=i.orbitSize)&&void 0!==n?n:2.95,d=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof h?()=>h:h,g="number"==typeof d?()=>d:d,y=ve(i);y.metaMap.clear(),o.length=0,r.length=0;const p=new Map;function m(t){var e;const i=null!==(e=p.get(t))&&void 0!==e?e:0;return p.set(t,i+1),0===i?t:`${t}__${i}`}const x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));o.push({id:k,x:x,y:v,x0:x,x1:x,y0:v,y1:v,width:0,height:0,value:0,depth:0,data:t}),y.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,n,s,h,d,p){const x=a(e);if(!(null==x?void 0:x.length))return;const v=x.length;let b=0,k=0,A=0;for(;v>k;)k+=u[Math.min(A,u.length-1)],A++,b++;let w=0;for(let v=0;b>v;v++){const k=u[Math.min(v,u.length-1)],A=x.slice(w,w+k);if(!A.length)break;const S=(v+1)/b,_={id:i,depth:d,data:e,parentId:i},P=p?h/f(_)*S:h*S,j=l.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=j(A),O=g(_);for(let e=0;A.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=A[e],u=m(c(l)),h=n+P*Math.sin(a),f=s+P*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:l}),y.metaMap.set(u,{ring:P,angle:a,depth:d,parentId:i,eccentricity:O}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,h,f,P,d+1,!0)}w+=k}}(t,k,x,v,b,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,u;const h=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];if(!1!==i.orbitShowRings){const e=ve(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;y.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Zt(e,"nodeSize")),o=h?h(Zt(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,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),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=f(Zt(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(u=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==u?u:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=ve(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.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 i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+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())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.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,i),!0)}};function ke(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,u=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function Ae(t){var e,i,o;const r=t.length,s=t[0],a=t[r-1];return{n:r,min:s,q1:null!==(e=n.quantile(t,.25))&&void 0!==e?e:s,median:null!==(i=n.quantile(t,.5))&&void 0!==i?i:(s+a)/2,q3:null!==(o=n.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/r}}function we(t){return 0===t.length?()=>"#4e79a7":e=>{var i;let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return null!==(i=t[Math.abs(o)%t.length])&&void 0!==i?i:"#4e79a7"}}const Se={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:u}=t,{r:h,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);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 i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=u(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=h(0>a?r:o+a),i=0>a?h(r+a)-h(r):h(o)-h(o+a);f.push(w(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=h(0>a?r+a:o),i=0>a?h(r)-h(r+a):h(o+a)-h(o);f.push(w(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const x="vertical"===d,v=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===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=x?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(v>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),i=e.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});t.length>0&&(t.reduce(x?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=v),i.length>0&&(i.reduce(x?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=v)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],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),d.push(t))}const g=d.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(w(n,Math.min(a,h),o,Math.abs(a-h),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(w(Math.min(a,h),n,Math.abs(h-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return u},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],d="vertical"===u,f="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[r]||l,m=c(e,t.name),x=m.r||5;let v,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else d?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),u=n(o,t.name),h=u.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:h,style:u,datum:o})}}return c},pie:ke,donut:ke,boxplot:function(t,e){var i,o,r,s,a,c;const{scales:l,columns:u,config:h,getR:d,resolveSummaryStyle:f}=t,{r:g,projection:y}=l,p=[],m="vertical"===y,x=!1!==h.showOutliers;for(const e of Object.values(u)){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 u=l[0],h=l[l.length-1],y=null!==(i=n.quantile(l,.25))&&void 0!==i?i:u,v=null!==(o=n.quantile(l,.5))&&void 0!==o?o:(u+h)/2,b=null!==(r=n.quantile(l,.75))&&void 0!==r?r:h,k=b-y,A=y-1.5*k,w=b+1.5*k,S=null!==(s=l.find(t=>t>=A))&&void 0!==s?s:u,_=null!==(a=[...l].reverse().find(t=>w>=t))&&void 0!==a?a:h,P=f(e.pieceData[0],e.name),j=[];if(x)for(const t of e.pieceData){const i=d(t);if(A>i||i>w){const o=m?e.middle:g(i),r=m?g(i):e.middle;j.push({px:o,py:r,value:i,datum:t})}}if(p.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(y),medianPos:g(v),q3Pos:g(b),maxPos:g(_),stats:{n:l.length,min:S,q1:y,median:v,q3:b,max:_,mean:l.reduce((t,e)=>t+e,0)/l.length},style:P,datum:e.pieceData,category:e.name,outliers:j}),x)for(const e of j)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:P.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var i,o,r;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:d}=s,f=[],g="vertical"===d,y=c.bins||20,p=!1!==c.showIQR;for(const t of Object.values(a)){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 s=e[0],a=e[e.length-1],c=(a-s)/y||1,d=Array(y).fill(0);for(const t of e)d[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...d,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const i=h(s+(e+.5)*c);v+=` L ${t.middle+d[e]/m*x} ${i}`}v+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const i=h(s+(e+.5)*c);v+=` L ${t.middle-d[e]/m*x} ${i}`}v+=" Z"}else{v=`M ${h(s)} ${t.middle}`;for(let e=0;y>e;e++)v+=` L ${h(s+(e+.5)*c)} ${t.middle-d[e]/m*x}`;v+=` L ${h(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)v+=` L ${h(s+(e+.5)*c)} ${t.middle+d[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=n.quantile(e,.25))&&void 0!==i?i:s,l=null!==(o=n.quantile(e,.5))&&void 0!==o?o:(s+a)/2,u=null!==(r=n.quantile(e,.75))&&void 0!==r?r:a;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const A=g?{x:t.x,y:Math.min(h(a),h(s)),width:t.width,height:Math.abs(h(a)-h(s))}:{x:Math.min(h(s),h(a)),y:t.x,width:Math.abs(h(a)-h(s)),height:t.width};f.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:Ae(e),style:b,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],u=n.bins||25,h=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),u-1)]++;const d=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const o=(h?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(w(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,u=[],h=n.bins||20,d="horizontal"===l,f=n.amplitude||1.5;for(const t of Object.values(r)){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],r=e[e.length-1],n=(r-o)/h||1,l=Array(h).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;h>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const x=d?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Ae(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(w(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(w(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){var i,r,n,s,a,c,l,u;const{columns:h,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,x=t.scales.o.domain().map(t=>h[t]).filter(Boolean);if(0===x.length)return y;const v=[],b=new Set;for(const t of x)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),v.push(t))}const k=v.length>1&&"_default"!==v[0],A=[];let S=0;for(const t of x){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>S&&(S=i)}if(k)for(const t of A){let e=0,i=0;for(let o=0;v.length>o;o++){const r=t.groups.get(v[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>S&&(S=o)}if(0===S)return y;const _=new Map;for(const t of v){const e=A[0].groups.get(t);_.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const P=A[0].stepTotal,j=k?.95*p:.9*e.width,M=o.scaleLinear().domain([0,S]).range([0,j]),O=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let E=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,r=0===e,h=o.width,d=.55*h,f=o.x+(h-d)/2,x=new Map;if(k){let t=0;for(const e of v){const o=i.groups.get(e);o&&(t+=M(o.total))}let e=p,n=p;for(let s=0;v.length>s;s++){const c=v[s],l=i.groups.get(c);if(!l)continue;const u=M(l.total),h=s%2==0,b=h?e:n-u;h?e+=u:n-=u;const k=g(l.pieces[0],c),A=null!==(a=_.get(c))&&void 0!==a?a:l.total,S=A>0?l.total/A*100:0,P=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(P.__funnelStepLabel=o.name,P.__funnelStepLabelX=p,P.__funnelStepLabelY=f,P.__funnelRowWidth=t),P.__funnelValueLabelX=b+u/2,P.__funnelValueLabelY=f,P.__funnelBarW=u),y.push(w(b,f,u,d,k,P,c)),x.set(c,{x:b,y:f,w:u,h:d})}}else{const t=i.stepTotal,e=M(t),a=p-e/2,c=v[0],l="_default"!==c,u=null!==(s=null===(n=i.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==s?s:o.pieceData[0],h=l?c:o.name,b=g(u,h),k=P>0?t/P*100:0,A=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:r,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(w(a,f,e,d,b,A,h)),x.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&E.size>0){const e=k?v:[v[0]];for(const r of e){const e=E.get(r),n=x.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:O},datum:null!==(u=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}E=x}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],d=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return h;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of f){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const x=u.r,v=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,v=null!==(r=m.get(d))&&void 0!==r?r:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(d),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,S=o?0:Math.max(0,A-p),_=i.x+t*a+c/2,P=x(p),j=x(0)-P,M=l(g.pieces[0],y?d:i.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:S,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:_+u/2,__barFunnelLabelY:x(p+S)});if(h.push(w(_,P,u,j,M,O,y?d:i.name)),S>0){const t=x(p+S),e=P-t,o=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:S,__barFunnelPercent:v>0?S/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});h.push(w(_,t,u,e,o,r,y?d:i.name))}}}return h},swimlane:function(t,e){var i;const{scales:o,columns:r,getR:n,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=o,u=[],h="horizontal"===l,d=t.config.gradientFill,f=h?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(i=g.opacity)&&void 0!==i?i:1,[o,n]=c.range(),s=Math.min(o,n),a=Math.abs(n-o);for(const i of Object.values(r)){const o={fill:t,opacity:e},r=h?w(s,i.x,a,i.width,o,null,"__track__"):w(i.x,s,i.width,a,o,null,"__track__");u.push(r)}}for(const t of Object.values(r)){let e=0;for(const i of t.pieceData){const o=Math.abs(n(i));if(0===o)continue;const r=s?s(i):t.name,l=a(i,r);let g;if(h){const n=c(e),s=c(e+o);g=w(n,t.x,s-n,t.width,l,i,r)}else{const n=c(e+o),s=c(e);g=w(t.x,n,t.width,s-n,l,i,r)}d&&(g.fillGradient=d,g.roundedEdge=f),u.push(g),e+=o}}return u}};class _e{constructor(t){this.rExtent=new m,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 p(t.windowSize),this.getO=M(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>P(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new m)):(this.getR=P(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=M(t.stackBy),this.getGroup=M(t.groupBy),this.getColor=M(t.colorAccessor),this.getConnector=M(t.connectorAccessor),this.getDataId=M(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new p(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 i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),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 i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const r=i.toArray(),n=e.projection||"vertical",s=e.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),c="horizontal"===n,l="radial"===n,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===n?t.width:t.height):.1));let h,d;if(l){h=o.scaleBand().domain(s).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,r=e.innerRadius||0;d=o.scaleLinear().domain(a).range([r,i])}else c?(h=o.scaleBand().domain(s).range([0,t.height]).padding(u),d=o.scaleLinear().domain(a).range([0,t.width])):(h=o.scaleBand().domain(s).range([0,t.width]).padding(u),d=o.scaleLinear().domain(a).range([t.height,0]));this.scales={o:h,r:d,projection:n},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((r,n)=>{var s;const a=this.rExtents[n];a.dirty&&a.recalculate(i,r);let[l,u]=a.extent;l===1/0&&(l=0,u=1);const h=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=u-l,f=d>0?d*h:1;return l-=f,u+=f,l>0&&(l=0),c?o.scaleLinear().domain([l,u]).range([0,t.width]):o.scaleLinear().domain([l,u]).range([t.height,0])}):[];let f=r;this.rAccessors.length>1&&(f=r.flatMap(t=>this.rAccessors.map((e,i)=>Object.assign(Object.assign({},t),{__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(f,s,h,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),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,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.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 n.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 i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));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),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,i,o,r){var n;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 c=0;if("radial"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==o){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,d=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,f;u?(l=d,f=u.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}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 i,o;if(!this.scales)return[];if(this.config.customLayout){const r=this.buildLayoutContext(t,e);let n;try{n=this.config.customLayout(r)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(i=n.overlays)&&void 0!==i?i:null,null!==(o=n.nodes)&&void 0!==o?o:[]}this.customLayoutOverlays=null;const r=this.getSceneContext(),n=Se[this.config.chartType];let s=n?n(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),u.has(i)||u.set(i,[]),u.get(i).push({x:o,y:r,datum:e,category:a(e)})}const h=r.o.domain(),d=n.connectorStyle;for(const[e,r]of u)if(r.length>=2){r.sort((t,e)=>h.indexOf(t.category)-h.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(r,s);s=[...t,...s]}return s}buildLayoutContext(t,e){var i,o,r;const n=this.config,s=null!==(i=n.layoutMargin)&&void 0!==i?i:{top:0,right:0,bottom:0,left:0},a=function(t,e,i){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=q[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:i}(n.colorScheme,n.themeCategorical,V),c=this.scales;return{data:t,scales:{o:c.o,r:c.r,projection:c.projection},dimensions:{width:e.width,height:e.height,margin:s,plot:"radial"===c.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=n.themeSemantic)&&void 0!==o?o:{},categorical:[...a]},resolveColor:we(a),config:null!==(r=n.layoutConfig)&&void 0!==r?r:{}}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}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 i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||V,o=i[this._colorSchemeIndex%i.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 i=this.config.decay;return i&&e>1?U(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);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,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,_e.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._pointQuadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=this.getDatumIndexMap(e);let u=null;for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/s;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}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(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=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===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,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!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{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,i,o,r,n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b;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 A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],u=this.getNodeKey(l,S);if(!u)continue;l._transitionKey=u;const h=this.prevPositionMap.get(u);if("point"===l.type)h?(w.add(u),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(h.x!==l.x||h.y!==l.y||void 0!==h.r&&h.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=h.x,l.y=h.y,void 0!==h.r&&(l.r=h.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)h?(w.add(u),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,h.x===l.x&&h.y===l.y&&h.w===l.w&&h.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=h.x,l.y=h.y,l.w=null!==(r=h.w)&&void 0!==r?r:l.w,l.h=null!==(n=h.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(h)w.add(u),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,h.startAngle===l.startAngle&&h.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=h.startAngle,l.endAngle=h.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(u,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l: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!==(h=e.w)&&void 0!==h?h:0,h:null!==(d=e.h)&&void 0!==d?d: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 i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(x=e.startAngle)&&void 0!==x?x:0,endAngle:null!==(v=e.endAngle)&&void 0!==v?v:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:et(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=J(t,this.activeTransition),s=K(n,"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),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=tt(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=tt(o.x,t._targetX,s),t.y=tt(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=tt(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=tt(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,s),t.y=tt(i.y,t._targetY,s),void 0!==i.w&&(t.w=tt(i.w,t._targetW,s),t.h=tt(i.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:tt(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=tt(i.startAngle,t._targetStartAngle,s),t.endAngle=tt(i.endAngle,t._targetEndAngle,s))}}}if(n>=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]),i=this.getDataId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,n}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&&!_(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!_(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!_(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(_(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=M(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!_(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>P(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new m)):(this.getR=P(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!_(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?M(this.config.stackBy):void 0),"groupBy"in t&&!_(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?M(this.config.groupBy):void 0),"colorAccessor"in t&&!_(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!_(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?M(this.config.connectorAccessor):void 0)}}_e.QUADTREE_THRESHOLD=500;const Pe={mercator:h.geoMercator,equalEarth:h.geoEqualEarth,albersUsa:h.geoAlbersUsa,orthographic:h.geoOrthographic,naturalEarth:h.geoNaturalEarth1,equirectangular:h.geoEquirectangular};function je(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Me(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Oe(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function Ee(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function Le(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function Te(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function De(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class ze{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}initStreaming(t=500){this.pointBuffer=new p(t),this.timestampBuffer=new p(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 i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="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(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.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(i(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 h.geoEqualEarth();if("string"==typeof t){const e=Pe[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),h.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=Pe[t.type],i=e?e():h.geoEqualEarth();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=h.geoPath(this.projection),this.fitProjection(t),this.geoPath=h.geoPath(this.projection);const i=this.projection;this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.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,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=je(a.xAccessor,"lon"),u=je(a.yAccessor,"lat"),h=this.getPoints();if(h.length>0){const t=h.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const d=Me(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i: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,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=h.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.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 i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=h.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.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 i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=h.geoPath(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.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,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i: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 i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,ze.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=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=je(n.xAccessor,"lon"),l=je(n.yAccessor,"lat"),u=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),f=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=h.geoGraticule();e.step&&i.step(e.step);const o=a(i())||"";o&&r.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 i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=Oe(n.areaStyle,t,u);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const g=Me(n.lineDataAccessor);for(const e of this.lineData){const i=g(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=h.geoDistance(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=h.geoInterpolate(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=Oe(n.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?Te(o,u):De(o[0],o[o.length-1],0,0,u)):o=Le(o[0],o[o.length-1]);const f=Ee(o,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&f[0]||o,style:a,datum:e})}const y=this.getPoints(),p=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,x=m>0?m*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(i=b[0])&&void 0!==i?i:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let t=0;y.length>t;t++){const e=y[t],i=c(e),o=l(e);if(null!=x&&h.geoDistance([i,o],k)>x)continue;const a=s([i,o]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},f),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};r.push(d)}return r}applyCartogramTransform(t,e){var i,r,n;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(i=t.strength)&&void 0!==i?i:1;if(0===a)return;const c=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],u=s.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const h=u.x,d=u.y,f=s.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=o.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:d,maxCost:g,availableRadius:y},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 s){if(t===u)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=h+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,x=e.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of s)t.x+=v,t.y+=b;this.cartogramLayout={cx:m,cy:x,maxCost:g,availableRadius:y};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of k){const i=null===(r=e.datum)||void 0===r?void 0:r.source,o=null===(n=e.datum)||void 0===n?void 0:n.target;if(i&&o){const r=t.get(i+""),n=t.get(o+"");r&&n&&(e.path=[r,n])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=U(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=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<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=r.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=J(t,this.activeTransition),i=K(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=tt(t.x,t._targetX,i),t.y=tt(e,t._targetY,i)}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}}ze.QUADTREE_THRESHOLD=500;const $e={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Re(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function Ce(e,i,o){var r,n,s,a,c;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+i)}case"area":{const c=e;if(0===c.topPath.length)return null;const l=`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 e=`${o?o+"-":""}area-clip-${i}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t.jsx("path",{d:l,fill:Re(c.style.fill),fillOpacity:null!==(n=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==n?n:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+i)}return t.jsx("path",{d:l,fill:Re(c.style.fill),fillOpacity:null!==(a=null!==(s=c.style.fillOpacity)&&void 0!==s?s:c.style.opacity)&&void 0!==a?a:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+i)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Re(o.style.fill),opacity:null!==(c=o.style.opacity)&&void 0!==c?c:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Re(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=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,n,s]=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),a=.299*r+.587*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:e})]},"heatcell-"+i)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}function Ne(e,i){var o,r,n,s,a;const c=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",u=t=>`ord-${e.type}-${c}-${i}-${t}`,h=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e,o=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(h)+"-grad",r=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];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 i=0;e.length>i;i++)c.push(t.jsx("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=Re(e.style.fill);c.push(t.jsx("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t.jsx("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(i,o),n=r?`url(#${o})`:Re(i.style.fill);if(i.roundedTop&&i.roundedTop>0){const e=Math.min(i.roundedTop,i.w/2,i.h/2),{x:o,y:s,w:a,h:c}=i;let l;switch(i.roundedEdge){case"right":l=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o},${s+c} Z`;break;case"left":l=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+c-e} A${e},${e} 0 0 0 ${o+e},${s+c} L${o+a},${s+c} Z`;break;case"bottom":l=`M${o},${s} L${o+a},${s} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o+e},${s+c} A${e},${e} 0 0 1 ${o},${s+c-e} Z`;break;default:l=`M${o},${s+c} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c} Z`}return t.jsxs(f.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("path",{d:l,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}return t.jsxs(f.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:Re(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}case"wedge":{const i=e,o=l.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&o.cornerRadius(i.cornerRadius);const r=o($e)||"";return t.jsx("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:Re(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},h)}case"boxplot":{const i=e,o=i.columnWidth/2;return t.jsxs("g","vertical"===i.projection?{children:[t.jsx("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:Re(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("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.jsx("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.jsx("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:Re(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("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.jsx("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1})]},h)}case"violin":{const i=e,o=[t.jsx("path",{d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:Re(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1},u("path"))];if(i.iqrLine&&i.bounds){const e=i.bounds,r=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:r,y1:i.iqrLine.q1Pos,x2:r,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:r,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med"))):o.push(t.jsx("line",{x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med")))}return t.jsx("g",{children:o},h)}case"connector":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5},h);case"trapezoid":{const i=e,o=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:Re(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}default:return null}}function Fe(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:Be})})),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 Be=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],We={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}},Ye={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}},Ie={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Be,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 Xe(t,e){if("light"===e)return We;if("dark"===e)return Ye;if("high-contrast"===e)return Ie;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?Ye:We;return Fe(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 Fe(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||{})}))}!function(t,e){const i=new EventTarget;let o=Object.assign(Object.assign({},t(function(t){o=Object.assign(Object.assign({},o),t(o)),i.dispatchEvent(new Event("update"))})),null!=e?e:{})}(t=>({theme:We,setTheme(e){t(t=>({theme:Xe(t.theme,e)}))}}));const qe={light:We,dark:Ye,"high-contrast":Ie,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 Ge(t){if(!t)return We;if("string"==typeof t){if("light"===t)return We;if("dark"===t)return Ye;if("high-contrast"===t)return Ie;return qe[t]||We}const e="dark"===t.mode?Ye:We;return Fe(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 Ve(t){var e,i,o,r;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!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function He(e){const{categories:i,colorScheme:r,theme:n,position:s="right",totalWidth:a,totalHeight:c,margin:l,hasTitle:u=!1}=e;if(!i||0===i.length)return null;const h=function(t,e,i){const r=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:T;return o.scaleOrdinal().domain(t).range(r)}(i,r,n),d="top"===s||"bottom"===s;let f,g;if("left"===s?(f=4,g=l.top):"top"===s?(f=l.left,g=u?32:8):"bottom"===s?(f=l.left,g=Math.min(c-l.bottom+38,c-16)):(f=a-l.right+10,g=l.top),d){let e=0;const o=i.map((i,o)=>{const r=e;return e+=22+6.5*i.length+8,t.jsxs("g",{transform:`translate(${r},0)`,children:[t.jsx("rect",{width:14,height:14,fill:h(i),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily,children:i})]},"legend-"+o)});return t.jsx("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:o})}const y=i.map((e,i)=>t.jsxs("g",{transform:`translate(0,${20*i})`,children:[t.jsx("rect",{width:14,height:14,fill:h(e),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily,children:e})]},"legend-"+i));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:y})}function Qe(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function Ue(t,e){return t.color||e.colors.annotation||e.colors.text}function Ze(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):"number"==typeof t.x?t.x:null}function Ke(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):"number"==typeof t.y?t.y:null}function Je(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=ti(i[t],t,e);r&&o.push(r)}return o.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function ti(e,i,o){var r,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:d}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=Ue(e,u),a=e.label,h=e.labelPosition||"right",d=e.strokeDasharray||"6,4",f=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const e=c.r(n);return null==e?null:t.jsxs("g",{children:[t.jsx("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}case"x-threshold":{const o=e.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const s=Ue(e,u),a=e.label,h=e.labelPosition||"top",d=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.jsxs("g",{children:[t.jsx("line",{x1:r,y1:0,x2:r,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:r+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-xthresh-"+i)}case"band":{const o=null!=e.y0&&c.y?c.y(e.y0):null,r=null!=e.y1&&c.y?c.y(e.y1):null;if(null==o||null==r)return null;const n=Math.min(o,r),a=Math.abs(r-o),h=e.fill||Ue(e,u),d=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:n,width:l.width,height:a,fill:h,opacity:d}),e.label&&t.jsx("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:h,fontFamily:u.typography.fontFamily,children:e.label})]},"ann-band-"+i)}case"category-highlight":{if(!e.category||!c.o)return null;const r=c.o(e.category);if(null==r)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=Ue(e,u),h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:r,width:l.width,height:n,fill:s,opacity:h}:{x:r,y:0,width:n,height:l.height,fill:s,opacity:h},"ann-cathighlight-"+i)}case"label":case"text":{const{x:o,y:r}=function(t,e,i,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const i=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:Ze(t,e,i),y:Ke(t,e,o)}}(e,c,h,d);if(null==o||null==r)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.jsxs("g",{children:["label"===e.type&&t.jsx("line",{x1:o,y1:r,x2:o+n,y2:r+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.jsx("text",{x:o+n,y:r+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight,children:e.label||e.title})]},"ann-label-"+i)}default:return null}}function ei(t,e,i){return"function"==typeof t?t(i):i[t||e]}function ii(t){return t instanceof Date?t.getTime():Number(t)}function oi(t,e){return F(1===e?.5:t/(e-1))}const ri={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.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,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>{var n,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const i=e.xAccessor||"x",o=e.yAccessor||"y",r=e.orderAccessor?[...t].sort((t,i)=>null==t||"object"!=typeof t?1:null==i||"object"!=typeof i?-1:ii(ei(e.orderAccessor,"order",t))-ii(ei(e.orderAccessor,"order",i))):t,n=new WeakMap;let s=0;for(const t of r){if(null==t||"object"!=typeof t)continue;const e=ii(ei(i,"x",t)),r=ii(ei(o,"y",t));Number.isFinite(e)&&Number.isFinite(r)&&s++}let a=0;for(const t of r){if(null==t||"object"!=typeof t)continue;const e=ii(ei(i,"x",t)),r=ii(ei(o,"y",t));Number.isFinite(e)&&Number.isFinite(r)&&n.set(t,{idx:a++,total:s})}return{data:r,orderMap:n}}(t,r),c=null!==(n=r.pointRadius)&&void 0!==n?n:4;return Object.assign({chartType:"line",data:a.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle||{stroke:r.stroke||"#6366f1",strokeWidth:null!==(s=r.strokeWidth)&&void 0!==s?s:c,opacity:r.opacity},pointStyle:t=>{var e,i;const o=a.orderMap.get(t),r=null!==(e=null==o?void 0:o.idx)&&void 0!==e?e:0,n=null!==(i=null==o?void 0:o.total)&&void 0!==i?i:1;return{fill:n>0?oi(r,n):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1}}},o)}},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,u=null!==(s=r.max)&&void 0!==s?s:100,h=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-h)/2,g=r.thresholds||[{value:u,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[x,v]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(x-(m.left||0)-(m.right||0),v-(m.top||0)-(m.bottom||0))/2*(1-d)),sweepAngle:h,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:d,value:r.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const u=(Array.isArray(t)?t:null)||r.flows||[],h=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),x=new Map;for(const t of m)x.set(t[h]+"",t);const v=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof v,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=x.get(t.source+""),i=x.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=v?b?Q(k.map(t=>({[A]:v(t)})),A,i||"category10"):Q(k,v,i||"category10"):null,S=t=>v&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||H.has(e)}(o)?i(o):o}const o=(null==t?void 0:t[e])+"";return i?i(o):G[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o))%G.length]}(t,v,w):"#007bff";let _=1/0,P=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(_>e&&(_=e),e>P&&(P=e))}const j=P>_?P-_:0,[M,O]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],E=O-M,L=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,T=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=M+Math.max(0,Math.min(1,j>0?((Number.isFinite(e)?e:_)-_)/j:0))*E;return{stroke:S(t),strokeWidth:i,strokeLinecap:T,opacity:L,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}},ni=Object.freeze([]);function si(t){if(!t)return ni;let e=!1;for(let i=0;t.length>i;i++){const o=t[i];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const i=[];for(const e of t)null!=e&&"object"==typeof e&&i.push(e);return i}function ai(t){return Math.round(100*t)/100+""}function ci(e,i){const o=Ve(i.theme),r=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?r+"semiotic-title":void 0,a=i.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("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:[n&&t.jsx("title",{id:s,children:n}),i.description&&t.jsx("desc",{id:a,children:i.description}),i.defs&&t.jsx("defs",{children:i.defs}),i.background&&"transparent"!==i.background&&t.jsx("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.jsx("g",{id:r+"data-area",transform:i.innerTransform,children:e}),n&&t.jsx("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:n}),i.legend&&t.jsx("g",{id:r+"legend",children:i.legend}),i.outerElements]})}function li(e){var i,o,r,n;const s=Ge(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=si(e.data),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?c.left=Math.max(c.left,100):"bottom"===u?c.bottom=Math.max(c.bottom,70):"top"===u&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const h=a[0]-c.left-c.right,d=a[1]-c.top-c.bottom,y="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),p={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:y&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:y?void 0:e.xAccessor,yAccessor:y?void 0:e.yAccessor,timeAccessor:y?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},m=new at(p);if(e.data&&m.ingest({inserts:l,bounded:!0}),m.computeScene({width:h,height:d}),!m.scales||0===m.scene.length)return g.renderToStaticMarkup(ci(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const x=e._idPrefix,v=e.showGrid?function(e,i,o,r){const{grid:n}=Ve(o),s=r?r+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,r)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5},"gx-"+r)}),c.map((o,r)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5},"gy-"+r)})]})}(m.scales,{width:h,height:d},s,x):null,b=m.scene.map((t,e)=>Ce(t,e,x)).filter(Boolean),k=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l;const u=Ve(r),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||ai)(t)})),d=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||ai)(t)}));return t.jsxs("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),d.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+i)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:o.yLabel})]})}(m.scales,{width:h,height:d},e,s,x):null,A=e.annotations?Je({annotations:e.annotations,scales:{x:m.scales.x,y:m.scales.y},layout:{width:h,height:d},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:x}):null,w=e.showLegend?(()=>{const t=Qe(l,e.colorAccessor||e.groupAccessor);return 0===t.length?null:He({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,S=f.isValidElement(e.legend)?e.legend:w,_=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,v,b,k,A,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(_,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:S,idPrefix:e._idPrefix}))}function ui(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const hi=new Set(["tree","cluster","treemap","circlepack","partition"]);function di(e){const i=Ge(e.theme),o=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=e.legendPosition;e.showLegend&&(s&&"right"!==s?"left"===s?n.left=Math.max(n.left,100):"bottom"===s?n.bottom=Math.max(n.bottom,70):"top"===s&&(n.top=Math.max(n.top,40)):n.right=Math.max(n.right,100));const a=r[0]-n.left-n.right,c=r[1]-n.top-n.bottom,u=function(t){return be[t]}(o);if(!u)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:o,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let d,y;if(hi.has(o)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g.renderToStaticMarkup(ci(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));h.__hierarchyRoot=t,d=[],y=[]}else{const t=si(e.nodes||[]),o=Array.isArray(e.edges)?si(e.edges):[];if(0===t.length&&0===o.length)return g.renderToStaticMarkup(ci(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(y=function(t,e){const i=ui(e.sourceAccessor,"source"),o=ui(e.targetAccessor,"target"),r=ui(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,h),0===t.length&&y.length>0){const t=new Set;for(const e of y){const i="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(i)}d=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 d=function(t,e){const i=ui(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(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,h)}u.computeLayout(d,y,h,[a,c]);const{sceneNodes:p,sceneEdges:m,labels:x}=u.buildScene(d,y,h,[a,c]),v=Ve(i);for(const t of x)t.fill||(t.fill=v.text);const b=m.map((e,i)=>function(e,i){switch(e.type){case"line":return t.jsx("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-"+i);case"bezier":{const o=e;return t.jsx("path",{d:o.pathD,fill:Re(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t.jsx("path",{d:o.pathD,fill:Re(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t.jsx("path",{d:o.pathD,fill:Re(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),k=p.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Re(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Re(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=l.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)($e)||"";return t.jsx("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Re(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),A=x.map((e,i)=>function(e,i){return t.jsx("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-"+i)}(e,i)).filter(Boolean),w=e.annotations?Je({annotations:e.annotations,scales:{},layout:{width:a,height:c},theme:i,idPrefix:e._idPrefix}):null,S=e.showLegend?(()=>{const t=t=>"string"==typeof t||"function"==typeof t,o=t(e.colorBy)?e.colorBy:t(e.nodeIDAccessor)?e.nodeIDAccessor:void 0,s=Qe(d.length>0?d.map(t=>t.data||{id:t.id}):Array.from(new Set(y.flatMap(t=>{var e,i;return["string"==typeof t.source?t.source:null===(e=t.source)||void 0===e?void 0:e.id,"string"==typeof t.target?t.target:null===(i=t.target)||void 0===i?void 0:i.id]}).filter(Boolean))).map(t=>({id:t})),o);return 0===s.length?null:He({categories:s,colorScheme:e.colorScheme,theme:i,position:e.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:n,hasTitle:!!e.title})})():null,_=f.isValidElement(e.legend)?e.legend:S,P=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,b,k,A,w,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(P,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,legend:_,idPrefix:e._idPrefix}))}function fi(e){var i,o,r,n,s;const a=Ge(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=si(e.data),h=e.legendPosition;e.showLegend&&(h&&"right"!==h?"left"===h?l.left=Math.max(l.left,100):"bottom"===h?l.bottom=Math.max(l.bottom,70):"top"===h&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const d=c[0]-l.left-l.right,y=c[1]-l.top-l.bottom,p=e.projection||"vertical",m="radial"===p,x={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:p,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},v=new _e(x);if(e.data&&v.ingest({inserts:u,bounded:!0}),v.computeScene({width:d,height:y}),!v.scales||0===v.scene.length)return g.renderToStaticMarkup(ci(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const b=e._idPrefix,k=e.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=Ve(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.jsx("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(v,{width:d,height:y},a,b):null,A=v.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let w=null;if(A){const i=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 i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of v.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");w=Array.from(o).map((e,o)=>function(e){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:c,height:c,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:n}),t.jsx("line",{x1:s,y1:0,x2:s,y2:c,stroke:r,strokeWidth:n})]},i)}({id:`funnel-hatch-${i}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${i}-${e}`));for(const t of v.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__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 S=v.scene.map((t,e)=>Ne(t,e)).filter(Boolean),_=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=Ve(r),p="vertical"===g.projection,m=o.categoryFormat||o.oFormat,x=o.valueFormat||o.rFormat,v=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),A=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(x||ai)(t)}));return t.jsxs("g",p?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),v&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:v}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:b})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),v&&t.jsx("text",{x:15-(null!==(h=null===(u=o.margin)||void 0===u?void 0:u.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!==(f=null===(d=o.margin)||void 0===d?void 0:d.left)&&void 0!==f?f:40)}, ${i.height/2})`,children:v})]})}(v,{width:d,height:y},e,a,b):null,P=e.annotations?Je({annotations:e.annotations,scales:{r:v.scales.r,y:"vertical"===v.scales.projection?v.scales.r:void 0},layout:{width:d,height:y},theme:a,projection:p,idPrefix:b}):null,j=e.showLegend?(()=>{const t=Qe(u,e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:He({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,M=f.isValidElement(e.legend)?e.legend:j,O=m?l.left+d/2:l.left,E=m?l.top+y/2:l.top,L=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,k,S,_,P,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(L,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${O},${E})`,legend:M,defs:w,idPrefix:e._idPrefix}))}function gi(e){var i,o,r,n,s,a,c,l,u,h,d,y,p,m;const x=Ge(e.theme),v=e.size||[e.width||600,e.height||400],b=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),k=Array.isArray(e.areas)?si(e.areas):e.areas,A=si(e.points),w=si(e.lines),S=e.legendPosition;e.showLegend&&(S&&"right"!==S?"left"===S?b.left=Math.max(null!==(o=b.left)&&void 0!==o?o:0,100):"bottom"===S?b.bottom=Math.max(null!==(r=b.bottom)&&void 0!==r?r:0,70):"top"===S&&(b.top=Math.max(null!==(n=b.top)&&void 0!==n?n:0,40)):b.right=Math.max(null!==(i=b.right)&&void 0!==i?i:0,100));const _=v[0]-(null!==(s=b.left)&&void 0!==s?s:0)-(null!==(a=b.right)&&void 0!==a?a:0),P=v[1]-(null!==(c=b.top)&&void 0!==c?c:0)-(null!==(l=b.bottom)&&void 0!==l?l:0),j=new ze({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(k){if("string"==typeof k)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${k}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${k}')\` before calling renderGeoToStaticSVG.`);j.setAreas(k)}if(e.points&&j.setPoints(A),e.lines&&j.setLines(w),j.computeScene({width:_,height:P}),0===j.scene.length){const i=e.backgroundGraphics||e.foregroundGraphics||e.annotations?t.jsxs(t.Fragment,{children:[e.backgroundGraphics,e.annotations?Je({annotations:e.annotations,scales:{geoProjection:(null===(u=j.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>j.scales.projectedPoint(t,e):void 0},layout:{width:_,height:P},theme:x,idPrefix:e._idPrefix}):null,e.foregroundGraphics]}):null;return g.renderToStaticMarkup(ci(i,{width:v[0],height:v[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:x,innerTransform:`translate(${null!==(h=b.left)&&void 0!==h?h:0},${null!==(d=b.top)&&void 0!==d?d:0})`,idPrefix:e._idPrefix}))}const M=j.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.jsx("path",{d:n.pathData,fill:Re(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1},"geoarea-"+i):null}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Re(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.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-"+i)}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1},"line-"+i)}default:return null}}(e,i)).filter(Boolean),O=e.annotations?Je({annotations:e.annotations,scales:{geoProjection:(null===(y=j.scales)||void 0===y?void 0:y.projectedPoint)?([t,e])=>j.scales.projectedPoint(t,e):void 0},layout:{width:_,height:P},theme:x,idPrefix:e._idPrefix}):null,E=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;const o=Qe(A.length>0?A:Array.isArray(k)&&k.length>0?"string"==typeof t?k.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):k:[],t);return 0===o.length?null:He({categories:o,colorScheme:e.colorScheme,theme:x,position:e.legendPosition||"right",totalWidth:v[0],totalHeight:v[1],margin:b,hasTitle:!!e.title})})():null,L=f.isValidElement(e.legend)?e.legend:E,T=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,M,O,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(T,{width:v[0],height:v[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:x,innerTransform:`translate(${null!==(p=b.left)&&void 0!==p?p:0},${null!==(m=b.top)&&void 0!==m?m:0})`,legend:L,idPrefix:e._idPrefix}))}function yi(t,e){switch(t){case"xy":return li(e);case"ordinal":return fi(e);case"network":return di(e);case"geo":return gi(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function pi(e,i,o){var r;const{data:n,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,margin:m,colorScheme:x,colorBy:v,legendPosition:b}=i,k=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),A=[s,a],w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},k.frameProps||{}),{theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==b&&{legendPosition:b}),{_idPrefix:k._idPrefix}),S=ri[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const _=S.buildProps(n,v,x,w,k);let P=(0,{xy:li,ordinal:fi,network:di,geo:gi}[S.frameType])(_);if("GaugeChart"===e&&_.__gauge){const e=_.__gauge,i=w.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,l=Math.min(o,n)/2*.85,u=i.left+o/2,h=i.top+n/2,d=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(d-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,y=Ge(c).colors.text,p=g.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:h,x2:u+l*Math.cos(f),y2:h+l*Math.sin(f),stroke:y,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:h,r:4,fill:y})]}));P=P.replace("</svg>",p+"</svg>")}return P}function mi(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,g=i.height||400,y=Ge(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},d&&{decay:d}),c=new _e(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(bi(c.scene,f,g,y,p))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new at(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(w.push(vi(v.scene,f,g,y,p,b)),l>0&&o>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),w.push(vi(v.scene,f,g,y,p,b))}}return w}function xi(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function vi(e,i,o,r,n,s){const a=Ve(r),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=o-c.top-c.bottom,h=xi(n,r),d=e.map((t,e)=>Ce(t,e)).filter(Boolean),f=function(e,i,o,r,n,s){var a;if(!e||0===e.length)return null;const c=Ve(r),l=[];for(let r=0;e.length>r;r++){const u=e[r];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,r=i-t;if(0===r)continue;e=o-(u.value-t)/r*o}if(null==e)continue;const h=u.color||c.primary,d=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";l.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:d,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?i/2:i-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily,children:u.label})]},"ann-"+r))}}return l.length>0?t.jsx(t.Fragment,{children:l}):null}(n.annotations,l,u,r,n.yExtent,null==s?void 0:s.y),y="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,m=y?"semiotic-title":void 0,x=p?"semiotic-desc":void 0,v=[m,x].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":v,style:{fontFamily:a.fontFamily},children:[y&&t.jsx("title",{id:m,children:y}),p&&t.jsx("desc",{id:x,children:p}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[f,d]}),y&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:y})]});return g.renderToStaticMarkup(b)}function bi(e,i,o,r,n){const s=Ve(r),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(o-a.top-a.bottom)/2:a.top,h=xi(n,r),d=e.map((t,e)=>Ne(t,e)).filter(Boolean),f="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=f?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:p,children:f}),y&&t.jsx("desc",{id:m,children:y}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsx("g",{transform:`translate(${l},${u})`,children:d}),f&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return g.renderToStaticMarkup(v)}exports.generateFrameSVGs=mi,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return pi(t,Object.assign(Object.assign({},i),e))}catch(t){return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})},exports.renderChart=pi,exports.renderDashboard=function(e,i={}){var o;const{title:r,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=Ve(Ge(s)),d=l.columns||2,f=null!==(o=l.gap)&&void 0!==o?o:16;let y=0;r&&(y+=30),n&&(y+=20),y>0&&(y+=10);const p=Math.floor((a-f-f*(d-1))/d),m=[];let x=0,v=y+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,d),i=t.props.height||300;x+e>d&&(v+=b+f,x=0,b=0),m.push({chart:t,x:f/2+x*(p+f),y:v,w:p*e+f*(e-1),h:i}),b=Math.max(b,i),x+=e}const k=c||v+b+f,A=m.map((e,i)=>{const{chart:o,x:r,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},o.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=o.component?pi(o.component,l):o.frameType?yi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.jsx("g",{transform:`translate(${r},${n})`,children:t.jsx("foreignObject",{width:a,height:c,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+i)}),w=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t.jsx("title",{children:r}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),r&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),n&&t.jsx("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:n}),A]});return g.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return gi(t)},exports.renderNetworkToStaticSVG=function(t){return di(t)},exports.renderOrdinalToStaticSVG=function(t){return fi(t)},exports.renderToAnimatedGif=function(t,e,i){return y(this,arguments,void 0,function*(t,e,i,o={}){var r,n,s,a,c,l,u,h,d,f,g,y,p,m,x,v;const{fps:b=12,loop:k=!0,scale:A=1,background:w}=o,S=i.height||400,_=Math.round((i.width||600)*A),P=Math.round(S*A),j=mi(t,e,w?Object.assign(Object.assign({},i),{background:w}):i,o);if(0===j.length)throw Error("No frames generated — check that data is not empty");let M,O,E,L;try{const t="sharp",e=yield import(t);M=null!==(r=e.default)&&void 0!==r?r:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);O=null!==(a=null!==(n=e.GIFEncoder)&&void 0!==n?n:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(l=null===(c=e.default)||void 0===c?void 0:c.default)||void 0===l?void 0:l.GIFEncoder,E=null!==(d=null!==(u=e.quantize)&&void 0!==u?u:null===(h=e.default)||void 0===h?void 0:h.quantize)&&void 0!==d?d:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,L=null!==(m=null!==(y=e.applyPalette)&&void 0!==y?y:null===(p=e.default)||void 0===p?void 0:p.applyPalette)&&void 0!==m?m:null===(v=null===(x=e.default)||void 0===x?void 0:x.default)||void 0===v?void 0:v.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const T=Math.round(1e3/b),D=O();for(let t=0;j.length>t;t++){const e=j[t],i=yield M(Buffer.from(e),{density:72*A}).resize(_,P).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=E(o,256),n=L(o,r);D.writeFrame(n,_,P,{palette:r,delay:T,repeat:k?0:-1})}return D.finish(),Buffer.from(D.bytes())})},exports.renderToImage=function(t,e){return y(this,arguments,void 0,function*(t,e,i={}){var o,r,n;const{format:s="png",scale:a=1,background:c}=i;let l,u;l=["xy","ordinal","network","geo"].includes(t)?yi(t,e):pi(t,e),c&&(l=l.replace(/<svg /,`<svg style="background:${c}" `));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 h=e.width||(null===(r=e.size)||void 0===r?void 0:r[0])||600,d=e.height||(null===(n=e.size)||void 0===n?void 0:n[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(l):(new TextEncoder).encode(l),{density:72*a}).resize(Math.round(h*a),Math.round(d*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=yi,exports.renderXYToStaticSVG=function(t){return li(t)},exports.resolveTheme=Ge,exports.themeStyles=Ve;
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),e=require("react"),n=require("react-dom/server"),o=require("d3-scale"),i=require("d3-quadtree"),r=require("d3-array"),s=require("d3-interpolate"),a=require("d3-force"),l=require("d3-chord"),c=require("d3-shape"),u=require("d3-hierarchy"),d=require("d3-geo"),h=require("d3-selection"),f=require("d3-brush"),g=require("regression");function p(t){return t&&t.__esModule?t:{default:t}}function y(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const n in t)if("default"!==n){const o=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,o.get?o:{enumerable:!0,get:function(){return t[n]}})}return e.default=t,Object.freeze(e)}const m=y(e),v=y(n),x=p(g);function b(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 k{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 w{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 A(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 S(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 j(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 M(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,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 P(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 O(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 T(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function C(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function L(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function $(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function E(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function D(t,e,n){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(n)}`}function R(t){const e=t.map(E),n=e.length-1;return t=>{if(0>=t){const[t,n,o]=e[0];return D(t,n,o)}if(t>=1){const[t,o,i]=e[n];return D(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 D(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const z=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],B=R(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),F=R(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),N=R(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),W=R(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),I=R(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Y=R(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),H=R(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),G=R(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),q=R(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),X=R(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),V=R(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),U=R(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);R(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),R(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),R(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),R(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),R(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),R(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),R(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const Z={category10:z,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:B,reds:F,greens:N,oranges:W,purples:I,viridis:H,plasma:G},K=z,Q=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],J=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 tt(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")||J.has(e)}(o)?n(o):o}const o=(null==t?void 0:t[e])+"";return n?n(o):K[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))%K.length]}function et(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+""))),r=i.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const s=Z[n]||Z.category10;if(r&&"function"==typeof s){let t=-1/0;for(const e of i){const n=Number(e);n>t&&(t=n)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:K;return o.scaleOrdinal().domain(i).range(t).unknown("#999")}}function nt(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 ot(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 it(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function rt(t,e){return Math.min((t-e.startTime)/e.duration,1)}function st(t,e,n){return t+(e-t)*n}function at(){return"undefined"!=typeof performance?performance.now():Date.now()}function lt(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 ct(t,e,n){if(!t.getBounds||!t.scales)return null;const o=[],i=[];for(const n of e){const e=t.getX(n),r=t.getY(n);if(null==e||null==r||Number.isNaN(e)||Number.isNaN(r))continue;const s=t.getBounds(n),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(r+s)]),i.push([a,t.scales.y(r-s)]);else{const e=t.scales.y(r);o.push([a,e]),i.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:t.resolveBoundsStyle(n,e[0]),datum:e,group:n,interactive:!1}}function ut(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=_(s,t.scales,t.getX,r,a,o,l);c&&n.push(c)}}}const dt={blues:B,reds:F,greens:N,viridis:H,oranges:W,purples:I,greys:Y,plasma:G,inferno:q,magma:X,cividis:V,turbo:U},ht=new Map;class ft{constructor(t){if(this.xExtent=new w,this.yExtent=new w,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 k(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=C(t.timeAccessor||t.xAccessor,"time"),this.getY=C(t.valueAccessor||t.yAccessor,"value")):(this.getX=C(t.xAccessor,"x"),this.getY=C(t.yAccessor,"y")),this.getGroup=$(t.groupAccessor),this.getCategory=$(t.categoryAccessor),this.getSize=t.sizeAccessor?C(t.sizeAccessor,"size"):void 0,this.getColor=$(t.colorAccessor),this.getBounds=t.boundsAccessor?C(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?C(t.y0Accessor,"y0"):void 0,this.getPointId=$(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,n=null!=t.closeAccessor;this.getOpen=e?C(t.openAccessor,"open"):void 0,this.getHigh=C(t.highAccessor,"high"),this.getLow=C(t.lowAccessor,"low"),this.getClose=n?C(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!n}t.pulse&&(this.timestampBuffer=new k(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))}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?C(this.config.timeAccessor||this.config.xAccessor,"time"):C(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)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))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n)))}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);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))):(this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n))),null!=t&&(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!0}computeScene(t){var e,n,i,r,s,a,l,c,u,d,h,f,g,p;const{config:y,buffer:m}=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(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),x=this.xExtent.extent,b=this.yExtent.extent;let k=y.xExtent?[null!==(n=y.xExtent[0])&&void 0!==n?n:x[0],null!==(i=y.xExtent[1])&&void 0!==i?i:x[1]]:x,w=y.yExtent?[null!==(r=y.yExtent[0])&&void 0!==r?r:b[0],null!==(s=y.yExtent[1])&&void 0!==s?s:b[1]]:b;const S=y.yExtent&&null!=y.yExtent[0]&&null!=y.yExtent[1],j="exact"===y.axisExtent;if("stackedarea"===y.chartType&&!S&&m.size>0)if(y.normalize)w=[0,j?1:1+y.extentPadding];else{const t=`${m.size}:${this._ingestVersion}:${null!==(a=y.baseline)&&void 0!==a?a:"zero"}:${null!==(l=y.stackOrder)&&void 0!==l?l:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)w=this._stackExtentCache.yDomain;else{const e=this.groupData(v),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!==(c=y.stackOrder)&&void 0!==c?c:"key",l=(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:l(t,e)}),n=[],o=[];let i=0,r=0;for(const e of t)r>i?(n.push(e),i+=null!==(u=s.get(e))&&void 0!==u?u:0):(o.push(e),r+=null!==(d=s.get(e))&&void 0!==d?d: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:l(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:l(t,e)}):e.map(t=>t.key).sort(l);if("wiggle"===y.baseline||"silhouette"===y.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=M(t,g,(t,e)=>{var o;return(null===(o=n.get(t))||void 0===o?void 0:o.get(e))||0},y.baseline);let i=1/0,s=-1/0;for(const n of t){const t=null!==(h=e.get(n))&&void 0!==h?h:0,o=null!==(f=r.get(n))&&void 0!==f?f: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=j?0:a>0?a*y.extentPadding:1;w=[i-l,s+l]}else w=[0,i+(j?0:i>0?i*y.extentPadding:1)];this._stackExtentCache={key:t,yDomain:w}}}else if("bar"===y.chartType&&y.binSize&&!S&&m.size>0){const[,t]=function(t,e,n,o,i){const r=A(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]}(m,this.getX,this.getY,y.binSize,this.getCategory);w=[0,j?t:t+t*y.extentPadding]}else if("waterfall"===y.chartType&&!S&&m.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]}(m,this.getY),n=e-t,o=j?0:n>0?n*y.extentPadding:1;w=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!S&&w[0]!==1/0){if(this.getBounds)for(const t of v){const e=this.getY(t),n=this.getBounds(t);null!=e&&!Number.isNaN(e)&&n&&(e+n>w[1]&&(w[1]=e+n),w[0]>e-n&&(w[0]=e-n))}const t=w[1]-w[0],e=j?0:t>0?t*y.extentPadding:1,n=null===(g=y.yExtent)||void 0===g?void 0:g[0],o=null===(p=y.yExtent)||void 0===p?void 0:p[1];w=[null!=n?w[0]:w[0]-e,null!=o?w[1]:w[1]+e],"log"!==y.yScaleType||w[0]>0||0>=b[0]||j||(w[0]=null!=n?w[0]:b[0]/(1+y.extentPadding))}if(y.yExtent&&!S){const t=y.yExtent[0],e=y.yExtent[1];null==t&&null==e||(w=[null!=t?t:w[0],null!=e?e:w[1]])}if(k[0]===1/0||k[1]===-1/0)if("time"===y.xScaleType){const t=Date.now();k=[t-864e5,t]}else k=[0,1];w[0]!==1/0&&w[1]!==-1/0||(w=[0,1]);const _="streaming"===y.runtimeMode,P=Math.max(0,Math.min(y.scalePadding||0,Math.min(t.width,t.height)/2-1));if(_)if("x"==("up"===(O=y.arrowOfTime)||"down"===O?"y":"x")){const e="right"===y.arrowOfTime?[P,t.width-P]:[t.width-P,P];this.scales={x:o.scaleLinear().domain(k).range(e),y:o.scaleLinear().domain(w).range([t.height-P,P])}}else{const e="down"===y.arrowOfTime?[P,t.height-P]:[t.height-P,P];this.scales={x:o.scaleLinear().domain(w).range([P,t.width-P]),y:o.scaleLinear().domain(k).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 o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)};this.scales={x:e(y.xScaleType,k,[P,t.width-P]),y:e(y.yScaleType,w,[t.height-P,P])}}var O;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),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,ft.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=i.quadtree().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 i=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(t,e,n)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(n).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(n):o.scaleLinear().domain(e).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,i,s[0]>s[1]?[t.width-c,c]:[c,t.width-c]),y:l(this.config.yScaleType,r,u?[c,t.height-c]:[t.height-c,c])},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:Q},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,getBounds:this.getBounds,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.getBounds)for(const e of o){const n=ct(t,e.data,e.key);n&&i.push(n)}for(const e of o){const n=t.resolveLineStyle(e.key,e.data[0]),o=S(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 ut(t,o,i),i}(d,e);case"area":return function(t,e){const n=t.groupData(e),o=[],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=j(e.data,t.scales,t.getX,t.getY,i,n,e.key,r);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return ut(t,n,o),o}(d,e);case"mixed":return function(t,e){const n=t.groupData(e),o=[],i=t.config.areaGroups||new Set,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=j(e.data,t.scales,t.getX,t.getY,r,n,e.key,s);t.config.gradientFill&&(i.fillGradient=t.config.gradientFill),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=S(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 ut(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=M(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)};ut(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=_(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=C(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 x=1/0,b=-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]}x>e&&(x=e),e>b&&(b=e)}if(!isFinite(x))return[];const k=b-x||1,w=n.width/s,A=n.height/a,S=t.config.showValues,j=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-x)/k;M.push(O(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:j}:void 0))}}return M}(t,e,n);if(0===e.length)return[];const o=C(t.config.valueAccessor,"value"),i=L(t.config.xAccessor,"x"),r=L(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),x=new Map;let b=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=x.get(h);let g;void 0!==f?g=f:(g=b++,x.set(h,g)),y[g]=h,m[g]=d,v[g]=n}let k=1/0,w=-1/0;for(let t=0;b>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 dt?t:"blues";let n=ht.get(e);if(n)return n;n=Array(256);const o=dt[e]||B;for(let t=0;256>t;t++)n[t]=o(t/255);return ht.set(e,n),n}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),S=255/(w-k||1),j=n.width/u,M=n.height/d,_=t.config.showValues,P=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const n=y[t],o=n%u;T.push(O(o*j,(d-1-(n-o)/u)*M,j,M,A[Math.min((e-k)*S+.5|0,255)],v[t],_?{value:e,showValues:!0,valueFormat:P}: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=A(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,x=Math.max(y-m,1);if(x>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(P(v,Math.min(l,c),x,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(P(v,Math.min(t,n),x,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,x=null==h?void 0:h.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],i=t.getX(o),r=t.getY(o),s=b+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){b=s;continue}const A=d.y(b),S=d.y(s),j=Math.min(A,S),M=Math.abs(A-S),_={fill:0>r?p:g,stroke:m,strokeWidth:v};null!=x&&(_.opacity=x),u.push(P(k,j,w,M,_,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),b=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?nt(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]=nt(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]=nt(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=nt(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=nt(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=ot(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=ot(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=lt(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=lt(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,x,b,k,w,A,S,j,M,_,P,O,T,C,L,$,E,D,R,z,B,F,N,W,I,Y,H,G;if(0===o.size&&0===i.size)return n;const q=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 X=!1;const V=new Set,U=new Set;for(let e=0;n.scene.length>e;e++){const r=n.scene[e],T=lt(t,r,e);if(!T)continue;if(r._transitionKey=T,"line"===r.type||"area"===r.type){const t=i.get(T);if(t){if(U.add(T),"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]];X=!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]];X=!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}),X=!0;continue}const C=o.get(T);if("point"===r.type)if(C){V.add(T);const t={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,C.x===t.x&&C.y===t.y&&C.r===t.r||(r._targetX=t.x,r._targetY=t.y,r._targetR=t.r,r.x=C.x,r.y=C.y,r.r=null!==(d=C.r)&&void 0!==d?d:r.r,X=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("rect"===r.type)if(C){V.add(T);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,C.x===t.x&&C.y===t.y&&C.w===t.w&&C.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=C.x,r.y=C.y,r.w=null!==(g=C.w)&&void 0!==g?g:r.w,r.h=null!==(p=C.h)&&void 0!==p?p:r.h,X=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("heatcell"===r.type)if(C){V.add(T);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,C.x===t.x&&C.y===t.y&&C.w===t.w&&C.h===t.h||(r._targetX=t.x,r._targetY=t.y,r._targetW=t.w,r._targetH=t.h,r.x=C.x,r.y=C.y,r.w=null!==(x=C.w)&&void 0!==x?x:r.w,r.h=null!==(b=C.h)&&void 0!==b?b:r.h,X=!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}),X=!0;else if("candlestick"===r.type)if(C&&null!=C.openY){V.add(T);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,(C.x!==t.x||C.openY!==t.openY||C.closeY!==t.closeY||C.highY!==t.highY||C.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=C.x,r.openY=C.openY,r.closeY=null!==(j=C.closeY)&&void 0!==j?j:r.closeY,r.highY=null!==(M=C.highY)&&void 0!==M?M:r.highY,r.lowY=null!==(_=C.lowY)&&void 0!==_?_:r.lowY,X=!0)}else r._targetOpacity=null!==(O=null===(P=r.style)||void 0===P?void 0:P.opacity)&&void 0!==O?O:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!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!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),X=!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!==(C=e.opacity)&&void 0!==C?C:1},_targetOpacity:0,_transitionKey:t,datum:null};n.exitNodes.push(o),X=!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!==($=e.opacity)&&void 0!==$?$: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!==(E=e.w)&&void 0!==E?E:0,h:null!==(D=e.h)&&void 0!==D?D:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R: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!==(z=e.w)&&void 0!==z?z:0,h:null!==(B=e.h)&&void 0!==B?B: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!==(N=e.openY)&&void 0!==N?N: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)}X=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),X&&(n.activeTransition={startTime:at(),duration:q}),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=rt(t,n.activeTransition),d=it(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=st(r,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=st(n.x,t._targetX,d),t.y=st(n.y,t._targetY,d),void 0!==t._targetR&&void 0!==n.r&&(t.r=st(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=st(i,t._targetOpacity,d)}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=st(n.x,t._targetX,d),t.y=st(n.y,t._targetY,d),void 0!==n.w&&(t.w=st(n.w,t._targetW,d)),void 0!==n.h&&(t.h=st(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:st(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=st(n.x,t._targetX,d),t.y=st(n.y,t._targetY,d),void 0!==n.w&&(t.w=st(n.w,t._targetW,d)),void 0!==n.h&&(t.h=st(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:st(i,t._targetOpacity,d)})}if(void 0===t._targetX)continue;if(!e)continue;const n=o.get(e);if(!n)continue;t.x=st(n.x,t._targetX,d),void 0!==n.openY&&(t.openY=st(n.openY,t._targetOpenY,d)),void 0!==n.closeY&&(t.closeY=st(n.closeY,t._targetCloseY,d)),void 0!==n.highY&&(t.highY=st(n.highY,t._targetHighY,d)),void 0!==n.lowY&&(t.lowY=st(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:st(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]=st(e[o][0],n[o][0],d),t.path[o][1]=st(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:st(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]=st(e[n][0],o[n][0],d),t.topPath[n][1]=st(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]=st(n[e][0],i[e][0],d),t.bottomPath[e][1]=st(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||Q,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)||Q;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>ft.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||"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||!T(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!T(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=C(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=C(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=C(this.config.xAccessor,"x"),this.getY=C(this.config.yAccessor,"y")),s=!0,a=!0)}if("groupAccessor"in t&&!T(t.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?$(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!T(t.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?$(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!T(t.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?C(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!T(t.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?$(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!T(t.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?C(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),"boundsAccessor"in t&&!T(t.boundsAccessor,r.boundsAccessor)&&(this.getBounds=this.config.boundsAccessor?C(this.config.boundsAccessor,"bounds"):void 0,s=!0,a=!0),"pointIdAccessor"in t&&!T(t.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?$(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in t&&!T(t.openAccessor,r.openAccessor)||"closeAccessor"in t&&!T(t.closeAccessor,r.closeAccessor)||"highAccessor"in t&&!T(t.highAccessor,r.highAccessor)||"lowAccessor"in t&&!T(t.lowAccessor,r.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?C(this.config.openAccessor,"open"):void 0,this.getHigh=C(this.config.highAccessor,"high"),this.getLow=C(this.config.lowAccessor,"low"),this.getClose=e?C(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 gt(t,e){var n=t.get(e);if(!n)throw Error("missing: "+e);return n}function pt(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 x=l[g];if(i[x]=!1,y.push(x),m.push(a[x]),v+=a[x].length,s[x]=d.length,x===e){l.length=g;break}}d.push(y);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];h.push(b)}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 yt(t){return t.y0-t.y1>0?"up":"down"}function mt(t,e){return e(t.source)==e(t.target)}function vt(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 xt(t){return t.target.x0-t.source.x1}function bt(t,e){var n=wt(t),o=xt(e)/Math.tan(n);return"up"==yt(t)?t.y1-o:t.y1+o}function kt(t,e){var n=wt(t),o=xt(e)/Math.tan(n);return"up"==yt(t)?t.y1+o:t.y1-o}function wt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function At(t,e){return e(t)}function St(t){return Mt(t.source)}function jt(t){return Mt(t.target)}function Mt(t){return(t.y0+t.y1)/2}function _t(t){return t.virtual?0:t.value}function Pt(t,e){var n=0;t.sourceLinks.forEach(function(t){n=t.circular&&!mt(t,e)?n+1:n});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!mt(t,e)?o+1:o}),n+o}function Ot(t){return t.target.depth}function Tt(t,e){return t.sourceLinks.length?t.depth:e-1}function Ct(t,e){return t.y0-e.y0}function Lt(t,e){return e.y0-t.y0}function $t(t,e){return t.y1-e.y1}function Et(t,e){return e.y1-t.y1}function Dt(t,e){return zt(t.source,e.source)||t.index-e.index}function Rt(t,e){return zt(t.target,e.target)||t.index-e.index}function zt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Bt(t,e){return Ft(t)==Ft(e)?"bottom"==t.circularLinkType?Lt(t,e):Ct(t,e):Ft(e)-Ft(t)}function Ft(t){return t.target.column-t.source.column}function Nt(t,e){return Wt(t)==Wt(e)}function Wt(t){return t.y0-t.y1>0?"up":"down"}function It(t,e,n,o,i){let s=t;var a=Math.max(8,.15*(s.y1-s.y0));s.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var l=r.min(s.links,function(t){return t.source.y0});s.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=s.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),Yt(s.links.filter(function(t){return"top"==t.circularLinkType}),e,n),Yt(s.links.filter(function(t){return"bottom"==t.circularLinkType}),e,n),s.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,mt(t,e)&&vt(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 r=t.source.column,a=t.circularLinkType,c=s.links.filter(function(t){return t.source.column==r&&t.circularLinkType==a});c.sort("bottom"==t.circularLinkType?Lt:Ct);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}),r=t.target.column,(c=s.links.filter(function(t){return t.target.column==r&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?Et:$t),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(s.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=l-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)}),s}function Yt(t,e,n){t.sort(Bt);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(mt(t,e)&&vt(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&&Ht(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 Ht(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Gt(t){return function(){return t}}function qt(t){return t.index}function Xt(t){return t.nodes}function Vt(t){return t.links}function Ut(t,e,n){var o=r.groups(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+=Mt(t.source)*e,o+=e}}),n.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=Mt(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?Pt(e,n)-Pt(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==Pt(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 Zt(t,e,n,o,i,s){var a=r.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});d();for(var l=1,c=s;c>0;--c)u(l*=.99,n),d();function u(e,n){var o=a.length;a.forEach(function(i){var s=i.length,a=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Pt(i,n)>0){var c=r.mean(i.sourceLinks,jt),u=r.mean(i.targetLinks,St),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Mt(i))*e*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==s)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(a==o-1&&1==s)i.y0=t.y1/2-(l=i.y1-i.y0)/2,i.y1=t.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var f=r.mean(i.sourceLinks,jt),g=r.mean(i.targetLinks,St),p=((f&&g?(f+g)/2:f||g)-Mt(i))*e;i.y0+=p,i.y1+=p}})})}function d(){a.forEach(function(n){var r,s,a,l=t.y0,c=n.length;for(n.sort(e||zt),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 Kt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Rt),t.targetLinks.sort(Dt)}),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 Qt(){var t=0,e=0,n=1,o=1,i=24,s=8,a=null,l=qt,c=Tt,u=void 0,d=32,h=2,f=Xt,g=Vt;function p(){var p={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=n,f.y1=o,f.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 r.group(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=gt(n,o)),"object"!=typeof i&&(i=t.target=gt(n,i)),o.sourceLinks.push(t),i.targetLinks.push(t)})}(f,l),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=pt(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++)})}(f,u),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){At(t,e)!=At(i.source,e)&&At(t,e)!=At(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),mt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,l),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(r.sum(t.sourceLinks,_t),r.sum(t.targetLinks,_t)),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)})})}(f),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})}(f,u,c);var g=s;if(null!==a){var p=r.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=r.max(p,function(t){return t.length});y>1&&(g=Math.max(1,(o-e)*a/(y-1)))}(function(t,e,n){var o=r.groups(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=r.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/r.sum(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var s=r.max(t.nodes,function(t){return t.column});t.nodes.forEach(s>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-n)/s),e.x1=e.x0+n}:function(e){e.x0=t.x0,e.x1=e.x0+n})})(f,g,i),Ut(f,u,l),Zt(f,u,l,g,g,d),Kt(f),It(f,l,h,10,8),Ut(f,u,l),Zt(f,u,l,g,g,d),Kt(f),It(f,l,h,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 At(n.source,e)==At(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(!Nt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var n=bt(e,t);return t.y1-n}if(e.target.column>t.target.column)return bt(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}})})}(f,l),function(t,e){let n=t;n.nodes.forEach(function(t){var o=n.links.filter(function(n){return At(n.target,e)==At(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(!Nt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var n=kt(e,t);return t.y0-n}if(e.source.column>t.source.column)return kt(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}})})}(f,l),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 s=r.min(e,function(t){return t.y0}),a=r.max(e,function(t){return t.y1}),l=(t.y1-t.y0)/(a-s);function c(e){return(e-s)/(a-s)*(t.y1-t.y0)+t.y0}1>l?(e.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1)}),n.forEach(function(t){t.y0=c(t.y0),t.y1=c(t.y1),t.width=t.width*l})):e.forEach(function(t){var e=t.y1-t.y0,n=c(t.y0)-t.y0;t.y0=c(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})})}}(f),It(f,l,h,10,8)}(p),p}return p.update=function(t){return Kt(t),It(t,l,h,10,8),t},p.nodeWidth=function(t){return arguments.length?(i=+t,p):i},p.nodePadding=function(t){return arguments.length?(s=+t,p):s},p.nodePaddingRatio=function(t){return arguments.length?(a=+t,p):a},p.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Gt(t),p):f},p.links=function(t){return arguments.length?(g="function"==typeof t?t:Gt(t),p):g},p.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Gt(t),p):l},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Gt(t),p):c},p.nodeSort=function(t){return arguments.length?(u=t,p):u},p.iterations=function(t){return arguments.length?(d=+t,p):d},p.circularLinkGap=function(t){return arguments.length?(h=+t,p):h},p.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],n=+i[1][0],o=+i[1][1],p):[[t,e],[n,o]]},p.size=function(i){return arguments.length?(t=e=0,n=+i[0],o=+i[1],p):[n-t,o-e]},p}function Jt(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}}}ft.GROUP_COLOR_MAP_CAP=1e3,ft.QUADTREE_THRESHOLD=500;const te=t=>{let e,n,o,i,r,a,l,c,u;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,a=t.target.x0,l=s.interpolateNumber(r,a),c=l(.5),u=l(.5),`M${e},${r}C${e},${c} ${n},${u} ${n},${a}L${o},${a}C${o},${u} ${i},${c} ${i},${r}Z`;const d=t.sankeyWidth/2,h=s.interpolateNumber(t.source.x1,t.target.x0),{pathD:f}=Jt({sx:t.source.x1,sTop:t.y0-d,sBot:t.y0+d,tx:t.target.x0,tTop:t.y1-d,tBot:t.y1+d,cp1X:h(.5),cp2X:h(.5)});return f};function ee(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 ne=new Set,oe=new WeakMap;function ie(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let n=oe.get(t);if(n){const t=n.get(e);if(t)return t}else n=new Map,oe.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}`;ne.has(t)||(ne.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 re={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(Ot))-1:0},justify:Tt};function se(t){return"string"==typeof t?t:t.id}const ae={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 x=Qt().extent(v).links(m).nodes(y).nodeAlign(re[h]||Tt).nodeId(t=>t.id).nodeWidth(f).iterations(p);x.nodePaddingRatio&&x.nodePaddingRatio(g),x();{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 b=new Map;for(const e of t)b.set(e.id,e);for(const t of y){const e=b.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=se(t.source),n=se(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=b.get(e),r=b.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:z,y=new Map;t.forEach((t,e)=>{y.set(t.id,p[e%p.length])});const m=[],v=[],x=[],b=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(ie(e,"nodeStyle")):{},i={fill:o.fill||y.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.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?b.get(o.id)||y.get(o.id)||i:b.get(e.id)||y.get(e.id)||i;const u=h?h(ie(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?ee(t):te(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),x.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:x}}},le={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,l=o[0]/2,c=o[1]/2,u=n.__previousPositions;let d=0;const h=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),n=null==u?void 0:u.get(e.id);t?d++:n?(e.x=n.x,e.y=n.y,d++):h.push(e)}const f=d>0&&.3>=(t.length>0?h.length/t.length:1);if(f){const n=new Map;for(const e of t)n.set(e.id,e);for(const t of h){const o=ce(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=ue(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=ue(t.id),n=e%360*(Math.PI/180),o=15+e%30;t.x=l+o*Math.cos(n),t.y=c+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=l+t*Math.cos(i),o.y=c+t*Math.sin(i)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),p=0===n.iterations?0:f?40:g,y=de(n.nodeSize,n.nodeSizeRange,t),m=t=>y(t);if(p>0){const n=a.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=a.forceSimulation().force("charge",a.forceManyBody().strength(t=>-25*m(t))).force("center",a.forceCenter(l,c).strength(.8)).force("x",a.forceX(l).strength(.15)).force("y",a.forceY(c).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}));o.force("link",n),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;p>t;++t)o.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=m(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 v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=v.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=v.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=de(n.nodeSize,n.nodeSizeRange,t),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:z,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(ie(e,"nodeSize")),o=d?d(ie(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 x=new Map;for(const e of t)x.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:x.get(t.source),o="object"==typeof t.target?t.target:x.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(ie(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=(b=n.nodeLabel)?"function"==typeof b?b:t=>t[b]||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(ie(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:y,sceneEdges:m,labels:v}}};function ce(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 ue(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 de(t,e,n){var i,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],l=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===l.length)return()=>a[0];const c=null!==(i=r.min(l))&&void 0!==i?i:0,u=null!==(s=r.max(l))&&void 0!==s?s:1;if(c===u)return()=>(a[0]+a[1])/2;const d=o.scaleLinear().domain([c,u]).range(a).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?a[0]:d(o)}}const he=z,fe={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,u=a-r,d=o[0]/2,h=o[1]/2,f=(g=n.valueAccessor)?"function"==typeof g?g:t=>{var e;return null!==(e=t[g])&&void 0!==e?e:1}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:1};var g;const p=new Map;for(let e=0;t.length>e;e++)p.set(t[e].id,e);const y=t.length,m=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=p.get("string"==typeof t.source?t.source:t.source.id),o=p.get(e);if(void 0===n||void 0===o)continue;const i=f(t);m[n][o]=i}const v=l.chord().padAngle(i);s&&v.sortGroups(s);const x=v(m),b=x.groups,k=c.arc().innerRadius(u).outerRadius(a);for(const e of b){const n=t[e.index],o=k.centroid({innerRadius:u,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});n.x=o[0]+d,n.y=o[1]+h,n.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const w=new Map;for(const e of t)w.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,n=w.get("string"==typeof t.source?t.source:t.source.id),o=w.get(e);n&&(t.source=n),o&&(t.target=o)}const A=new Map;for(const t of e)A.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 x){const n=t[e.source.index].id,o=t[e.target.index].id,i=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);i&&(i.__chordData=e)}},buildScene(t,e,n,o){var i,r,s,a;const{groupWidth:c=20,edgeOpacity:u=.5}=n,d=Math.min(o[0],o[1])/2,h=d-c,f=o[0]/2,g=o[1]/2,p=n.nodeStyle,y=n.edgeStyle,m=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:he,x=new Map;t.forEach((t,e)=>{x.set(t.id,v[e%v.length])});const b=l.ribbon().radius(h),k=[],w=[],A=[];for(let e=0;t.length>e;e++){const n=t[e],o=n.__arcData;if(!o)continue;let r;r=p?p(ie(n,"nodeStyle")).fill||x.get(n.id)||v[e%v.length]:x.get(n.id)||v[e%v.length];const s=p?p(ie(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:h,outerR:d,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=ge(o,f,g);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(y)l=y(ie(t,"edgeStyle")).fill||l;else{const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;"target"===m&&n?l=x.get(n.id)||l:e&&(l=x.get(e.id)||l)}const c=y?y(ie(t,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=c.fillOpacity)&&void 0!==a?a:u,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:t})}if(!1!==n.showLabels){const e=(S=n.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=d+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;A.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:w,labels:A}}};function ge(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 pe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ye(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 me(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 ve(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 xe(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:pe}function be(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 ke(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 we={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,d=u.hierarchy(r,a);d.sum(c),d.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[h,f]=o;switch(s){case"tree":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=u.tree();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(d,n,h,f);break;case"cluster":!function(t,e,n,o){const i=e.treeOrientation||"vertical",r=u.cluster();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(t)}(d,n,h,f);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=u.treemap().size([n,o]).tile(u.treemapBinary).padding(s);a>0&&l.paddingTop(a),l(t)}(d,n,h,f);break;case"circlepack":!function(t,e,n,o){var i;const r=null!==(i=e.padding)&&void 0!==i?i:4;u.pack().size([n,o]).padding(r)(t)}(d,n,h,f);break;case"partition":!function(t,e,n,o){var i;u.partition().size([n,o]).padding(null!==(i=e.padding)&&void 0!==i?i:1)(t)}(d,n,h,f)}const g=d.descendants();t.length=0,e.length=0;const p=new Map;for(let e=0;g.length>e;e++){const o=g[e],r={id:me(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?Ae(r,o,n):"treemap"===s||"partition"===s?Se(r,o):"circlepack"===s&&je(r,o),r.__hierarchyNode=o,t.push(r),p.set(o,r)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const n=p.get(t.parent),o=p.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,x=o[0]/2,b=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+=x,o+=b);const r=i(ie(e,"nodeStyle"));let l=r.fill||be(n);if(n.colorByDepth&&void 0!==e.depth){const t=xe(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+=x,s+=b,a+=x,l+=b);const f=ke(i,s,a,l,m),g=r(ie(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=ve(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+=x,a+=b),v){const t=s-x,e=a-b,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(ie(n,"nodeStyle"));let l=a.fill||be(e);if(e.colorByDepth&&void 0!==n.depth){const t=xe(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=ve(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(ie(c,"nodeStyle")).fill||be(e);if(e.colorByDepth&&void 0!==c.depth){const t=xe(e);g=t[c.depth%t.length]}const p="string"==typeof g?ye(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(ie(n,"nodeStyle"));let c=l.fill||be(e);if(e.colorByDepth&&void 0!==n.depth){const t=xe(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=ve(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(ie(i,"nodeStyle")).fill||be(e);if(e.colorByDepth&&void 0!==i.depth){const t=xe(e);a=t[i.depth%t.length]}if(s){const n="string"==typeof a?ye(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 Ae(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 Se(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 je(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 Me(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const _e={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),u=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,h=null!==(s=n.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,p=Me(n);p.metaMap.clear(),o.length=0,i.length=0;const y=new Map;function m(t){var e;const n=null!==(e=y.get(t))&&void 0!==e?e:0;return y.set(t,n+1),0===n?t:`${t}__${n}`}const v=e[0]/2,x=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(l(t));o.push({id:k,x:v,y:x,x0:v,x1:v,y0:x,y1:x,width:0,height:0,value:0,depth:0,data:t}),p.metaMap.set(k,{ring:b,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,n,r,s,d,h,y){const v=a(e);if(!(null==v?void 0:v.length))return;const x=v.length;let b=0,k=0,w=0;for(;x>k;)k+=u[Math.min(w,u.length-1)],w++,b++;let A=0;for(let x=0;b>x;x++){const k=u[Math.min(x,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const S=(x+1)/b,j={id:n,depth:h,data:e,parentId:n},M=y?d/f(j)*S:d*S,_=c.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),P=_(w),O=g(j);for(let e=0;w.length>e;e++){const a=(P[e].startAngle+P[e].endAngle)/2,c=w[e],u=m(l(c)),d=r+M*Math.sin(a),f=s+M*Math.cos(a)*O;o.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:c}),p.metaMap.set(u,{ring:M,angle:a,depth:h,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,d,f,M,h+1,!0)}A+=k}}(t,k,v,x,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=Me(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(ie(e,"nodeSize")),o=d?d(ie(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(ie(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=Me(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)},Pe={sankey:ae,force:le,chord:fe,tree:we,cluster:we,treemap:we,circlepack:we,partition:we,orbit:_e};function Oe(t,e,n){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=Z[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function Te(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 Ce(t,e){const{columns:n,config:o,resolvePieceStyle:i}=t,r=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,l=-Math.PI/2+(o.startAngle||0)*Math.PI/180,c=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(n)){const e=l+t.pctStart*c,n=l+(t.pctStart+t.pct)*c,u=i(t.pieceData[0],t.name);r.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:n},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return r}function Le(t){var e,n,o;const i=t.length,s=t[0],a=t[i-1];return{n:i,min:s,q1:null!==(e=r.quantile(t,.25))&&void 0!==e?e:s,median:null!==(n=r.quantile(t,.5))&&void 0!==n?n:(s+a)/2,q3:null!==(o=r.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/i}}const $e={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(P(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(P(e,t.x,Math.abs(n),t.width,l,h,r)),0>a?i+=a:o+=a}}}const v="vertical"===h,x=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(x>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=x),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=x)}}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(P(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(P(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 x,b;if(f){const e=y+(t.pctStart+t.pct/2)*p,n=u(r);x=Math.cos(e)*n,b=Math.sin(e)*n}else h?(x=t.middle,b=u(r)):(x=u(r),b=t.middle);d.push({type:"point",x:x,y:b,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:Ce,donut:Ce,boxplot:function(t,e){var n,o,i,s,a,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:f}=t,{r:g,projection:p}=c,y=[],m="vertical"===p,v=!1!==d.showOutliers;for(const e of Object.values(u)){const c=e.pieceData.map(t=>h(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===c.length)continue;const u=c[0],d=c[c.length-1],p=null!==(n=r.quantile(c,.25))&&void 0!==n?n:u,x=null!==(o=r.quantile(c,.5))&&void 0!==o?o:(u+d)/2,b=null!==(i=r.quantile(c,.75))&&void 0!==i?i:d,k=b-p,w=p-1.5*k,A=b+1.5*k,S=null!==(s=c.find(t=>t>=w))&&void 0!==s?s:u,j=null!==(a=[...c].reverse().find(t=>A>=t))&&void 0!==a?a:d,M=f(e.pieceData[0],e.name),_=[];if(v)for(const t of e.pieceData){const n=h(t);if(w>n||n>A){const o=m?e.middle:g(n),i=m?g(n):e.middle;_.push({px:o,py:i,value:n,datum:t})}}if(y.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(p),medianPos:g(x),q3Pos:g(b),maxPos:g(j),stats:{n:c.length,min:S,q1:p,median:x,q3:b,max:j,mean:c.reduce((t,e)=>t+e,0)/c.length},style:M,datum:e.pieceData,category:e.name,outliers:_}),v)for(const e of _)y.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:M.fill||(null===(l=t.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:e.datum})}return y},violin:function(t,e){var n,o,i;const{scales:s,columns:a,config:l,getR:c,resolveSummaryStyle:u}=t,{r:d,projection:h}=s,f=[],g="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const t of Object.values(a)){const e=t.pieceData.map(t=>c(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const s=e[0],a=e[e.length-1],l=(a-s)/p||1,h=Array(p).fill(0);for(const t of e)h[Math.min(Math.floor((t-s)/l),p-1)]++;const m=Math.max(...h,1),v=t.width/2*.9;let x="";if(g){x=`M ${t.middle} ${d(s)}`;for(let e=0;p>e;e++){const n=d(s+(e+.5)*l);x+=` L ${t.middle+h[e]/m*v} ${n}`}x+=` L ${t.middle} ${d(a)}`;for(let e=p-1;e>=0;e--){const n=d(s+(e+.5)*l);x+=` L ${t.middle-h[e]/m*v} ${n}`}x+=" Z"}else{x=`M ${d(s)} ${t.middle}`;for(let e=0;p>e;e++)x+=` L ${d(s+(e+.5)*l)} ${t.middle-h[e]/m*v}`;x+=` L ${d(a)} ${t.middle}`;for(let e=p-1;e>=0;e--)x+=` L ${d(s+(e+.5)*l)} ${t.middle+h[e]/m*v}`;x+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(y&&e.length>=4){const l=null!==(n=r.quantile(e,.25))&&void 0!==n?n:s,c=null!==(o=r.quantile(e,.5))&&void 0!==o?o:(s+a)/2,u=null!==(i=r.quantile(e,.75))&&void 0!==i?i:a;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:t.middle,isVertical:g}}const w=g?{x:t.x,y:Math.min(d(a),d(s)),width:t.width,height:Math.abs(d(a)-d(s))}:{x:Math.min(d(s),d(a)),y:t.x,width:Math.abs(d(a)-d(s)),height:t.width};f.push({type:"violin",pathString:x,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Le(e),style:b,datum:t.pieceData,category:t.name})}return f},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(P(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:Le(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(P(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(P(t.x,n,t.width,i-n,u,e,t.name))}}return l},funnel:function(t,e){var n,i,r,s,a,l,c,u;const{columns:d,getR:h,getStack:f,resolvePieceStyle:g}=t,p=[],y=e.width/2,m=!1!==t.config.showLabels,v=t.scales.o.domain().map(t=>d[t]).filter(Boolean);if(0===v.length)return p;const x=[],b=new Set;for(const t of v)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),x.push(t))}const k=x.length>1&&"_default"!==x[0],w=[];let A=0;for(const t of v){const e=new Map;let n=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const i=e.get(t),r=h(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;x.length>o;o++){const i=t.groups.get(x[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 p;const S=new Map;for(const t of x){const e=w[0].groups.get(t);S.set(t,null!==(n=null==e?void 0:e.total)&&void 0!==n?n:0)}const j=w[0].stepTotal,M=k?.95*y:.9*e.width,_=o.scaleLinear().domain([0,A]).range([0,M]),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],o=n.col,i=0===e,d=o.width,h=.55*d,f=o.x+(d-h)/2,v=new Map;if(k){let t=0;for(const e of x){const o=n.groups.get(e);o&&(t+=_(o.total))}let e=y,r=y;for(let s=0;x.length>s;s++){const l=x[s],c=n.groups.get(l);if(!c)continue;const u=_(c.total),d=s%2==0,b=d?e:r-u;d?e+=u:r-=u;const k=g(c.pieces[0],l),w=null!==(a=S.get(l))&&void 0!==a?a:c.total,A=w>0?c.total/w*100:0,j=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:A,__funnelStep:o.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});m&&(0===s&&(j.__funnelStepLabel=o.name,j.__funnelStepLabelX=y,j.__funnelStepLabelY=f,j.__funnelRowWidth=t),j.__funnelValueLabelX=b+u/2,j.__funnelValueLabelY=f,j.__funnelBarW=u),p.push(P(b,f,u,h,k,j,l)),v.set(l,{x:b,y:f,w:u,h:h})}}else{const t=n.stepTotal,e=_(t),a=y-e/2,l=x[0],c="_default"!==l,u=null!==(s=null===(r=n.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],d=c?l:o.name,b=g(u,d),k=j>0?t/j*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:i,category:c?l:o.name});m&&(w.__funnelStepLabel=o.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=f,w.__funnelRowWidth=e,w.__funnelValueLabelX=y,w.__funnelValueLabelY=f,w.__funnelBarW=e),p.push(P(a,f,e,h,b,w,d)),v.set(l,{x:a,y:f,w:e,h:h})}if(e>0&&T.size>0){const e=k?x:[x[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 g(t?t.pieces[0]:o.pieceData[0],"_default"===i?o.name:i)})(),a={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===(l=t.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:O},datum:null!==(u=null===(c=n.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===i?o.name:i};p.push(a)}}T=v}return p},"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,x=p?f.length:1,b=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/x,l=a*b,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,x=null!==(i=m.get(h))&&void 0!==i?i:y,b=x>0?y/x*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,j=v(y),M=v(0)-j,_=c(g.pieces[0],p?h:n.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:b,__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(P(S,j,u,M,_,O,p?h:n.name)),A>0){const t=v(y+A),e=j-t,o=Object.assign({},_),i=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:x>0?A/x*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(P(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?P(s,n.x,a,n.width,o,null,"__track__"):P(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=P(r,t.x,s-r,t.width,c,n,i)}else{const r=l(e+o),s=l(e);g=P(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 Ee{constructor(t){this.rExtent=new w,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 k(t.windowSize),this.getO=$(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>C(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new w)):(this.getR=C(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=$(t.stackBy),this.getGroup=$(t.groupBy),this.getColor=$(t.colorAccessor),this.getConnector=$(t.connectorAccessor),this.getDataId=$(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new k(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(),r=e.projection||"vertical",s=e.oExtent||this.resolveCategories(i),a=this.computeValueDomain(i,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===r?t.width:t.height):.1));let d,h;if(c){d=o.scaleBand().domain(s).range([0,1]).padding(0);const n=Math.min(t.width,t.height)/2,i=e.innerRadius||0;h=o.scaleLinear().domain(a).range([i,n])}else l?(d=o.scaleBand().domain(s).range([0,t.height]).padding(u),h=o.scaleLinear().domain(a).range([0,t.width])):(d=o.scaleBand().domain(s).range([0,t.width]).padding(u),h=o.scaleLinear().domain(a).range([t.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((i,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(n,i);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=e.extentPadding)&&void 0!==s?s:.05,h=u-c,f=h>0?h*d:1;return c-=f,u+=f,c>0&&(c=0),l?o.scaleLinear().domain([c,u]).range([0,t.width]):o.scaleLinear().domain([c,u]).range([t.height,0])}):[];let f=i;this.rAccessors.length>1&&(f=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(f,s,d,r,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,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,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=$e[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=Oe(r.colorScheme,r.themeCategorical,Q),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:Te(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||Q,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?nt(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,Ee.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=i.quadtree().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,x,b;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!==(x=e.endAngle)&&void 0!==x?x:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b: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:at(),duration:k})}advanceTransition(t){var e,n,o,i;if(!this.activeTransition)return!1;const r=rt(t,this.activeTransition),s=it(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=st(i,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=st(o.x,t._targetX,s),t.y=st(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=st(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=st(i,t._targetOpacity,s)}if(void 0===t._targetX)continue;const n=this.prevPositionMap.get(e);if(!n)continue;t.x=st(n.x,t._targetX,s),t.y=st(n.y,t._targetY,s),void 0!==n.w&&(t.w=st(n.w,t._targetW,s),t.h=st(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:st(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=st(n.startAngle,t._targetStartAngle,s),t.endAngle=st(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&&!T(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!T(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!T(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(T(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=$(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)=>!T(t,r[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>C(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new w)):(this.getR=C(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!T(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?$(this.config.stackBy):void 0),"groupBy"in t&&!T(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?$(this.config.groupBy):void 0),"colorAccessor"in t&&!T(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?$(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!T(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?$(this.config.connectorAccessor):void 0)}}Ee.QUADTREE_THRESHOLD=500;const De={mercator:d.geoMercator,equalEarth:d.geoEqualEarth,albersUsa:d.geoAlbersUsa,orthographic:d.geoOrthographic,naturalEarth:d.geoNaturalEarth1,equirectangular:d.geoEquirectangular};function Re(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ze(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Be(t,e,n){return t?Object.assign(Object.assign({},n),"function"==typeof t?t(e):t):Object.assign({},n)}function Fe(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 Ne(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 We(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 Ie(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 Ye{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 k(t),this.timestampBuffer=new k(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 d.geoEqualEarth();if("string"==typeof t){const e=De[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),d.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=De[t.type],n=e?e():d.geoEqualEarth();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=d.geoPath(this.projection),this.fitProjection(t),this.geoPath=d.geoPath(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=Re(a.xAccessor,"lon"),u=Re(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=ze(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=d.geoPath(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=d.geoPath(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=d.geoPath(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,Ye.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=i.quadtree().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=Re(r.xAccessor,"lon"),c=Re(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),h=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(r),f=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=d.geoGraticule();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=Be(r.areaStyle,t,u);i.push({type:"geoarea",pathData:e,centroid:n,bounds:o,screenArea:s,style:l,datum:t,interactive:!0})}const g=ze(r.lineDataAccessor);for(const e of this.lineData){const n=g(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=d.geoDistance(n,i)||0,a=Math.max(2,Math.ceil(r/(Math.PI/180))),l=d.geoInterpolate(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=Be(r.lineStyle,e,h),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?We(o,u):Ie(o[0],o[o.length-1],0,0,u)):o=Ne(o[0],o[o.length-1]);const f=Fe(o,t.width);if(f.length>1)for(const t of f){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&&f[0]||o,style:a,datum:e})}const p=this.getPoints(),y=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:t=>t[r.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,v=m>0?m*Math.PI/180:null,x=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(n=b[0])&&void 0!==n?n:0)-x[0],(null!==(o=b[1])&&void 0!==o?o:0)-x[1]];for(let t=0;p.length>t;t++){const e=p[t],n=l(e),o=c(e);if(null!=v&&d.geoDistance([n,o],k)>v)continue;const a=s([n,o]);if(!a)continue;const u=r.pointStyle?r.pointStyle(e):Object.assign({},f),h={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:y?y(e)+"":void 0};i.push(h)}return i}applyCartogramTransform(t,e){var n,i,r;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(n=t.strength)&&void 0!==n?n:1;if(0===a)return;const l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=s.find(e=>e.datum&&l(e.datum)+""==t.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`));const d=u.x,h=u.y,f=s.map(t=>t.datum?c(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),p=Math.min(e.width,e.height)/2,y=o.scaleLinear().domain([0,g]).range([0,p]);this.cartogramLayout={cx:d,cy:h,maxCost:g,availableRadius:p},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 s){if(t===u)continue;if(!t.datum)continue;const e=Math.atan2(t.y-h,t.x-d),n=Math.sqrt(Math.pow(t.x-d,2)+Math.pow(t.y-h,2)),o=c(t.datum),i=n+((isFinite(o)?y(o):n)-n)*a;t.x=d+Math.cos(e)*i,t.y=h+Math.sin(e)*i}const m=e.width/2,v=e.height/2,x=m-u.x,b=v-u.y;if(Math.abs(x)>.5||Math.abs(b)>.5)for(const t of s)t.x+=x,t.y+=b;this.cartogramLayout={cx:m,cy:v,maxCost:g,availableRadius:p};const k=this.scene.filter(t=>"line"===t.type);if(k.length>0&&"fractional"!==t.lineMode){const t=new Map;for(const e of s)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,o=null===(r=e.datum)||void 0===r?void 0:r.target;if(n&&o){const i=t.get(n+""),r=t.get(o+"");i&&r&&(e.path=[i,r])}}}}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=nt(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=rt(t,this.activeTransition),n=it(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=st(t.x,t._targetX,n),t.y=st(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 He(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 Ge(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)}}Ye.QUADTREE_THRESHOLD=500;const qe={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Xe(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function Ve(e,n,o){var i,r,s,a,l;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const i="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+n)}case"area":{const l=e;if(0===l.topPath.length)return null;const c=`M${l.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...l.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(l.clipRect){const e=`${o?o+"-":""}area-clip-${n}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:l.clipRect.x,y:l.clipRect.y,width:l.clipRect.width,height:l.clipRect.height})})}),t.jsx("path",{d:c,fill:Xe(l.style.fill),fillOpacity:null!==(r=null!==(i=l.style.fillOpacity)&&void 0!==i?i:l.style.opacity)&&void 0!==r?r:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+n)}return t.jsx("path",{d:c,fill:Xe(l.style.fill),fillOpacity:null!==(a=null!==(s=l.style.fillOpacity)&&void 0!==s?s:l.style.opacity)&&void 0!==a?a:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth},"area-"+n)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Xe(o.style.fill),opacity:null!==(l=o.style.opacity)&&void 0!==l?l:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+n)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Xe(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+n)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=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),[i,r,s]=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),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:e})]},"heatcell-"+n)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+n)}case"candlestick":{const o=e,i=Math.min(o.openY,o.closeY),r=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}function Ue(e,n){var o,i,r,s,a;const l=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",u=t=>`ord-${e.type}-${l}-${n}-${t}`,d=`ord-${e.type}-${l}-${n}`;switch(e.type){case"rect":{const n=e,o=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(d)+"-grad",i=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.jsx("stop",{offset:e[n].offset,stopColor:e[n].color},n))}else{const n=Xe(e.style.fill);l.push(t.jsx("stop",{offset:0,stopColor:n,stopOpacity:o.topOpacity},"0")),l.push(t.jsx("stop",{offset:1,stopColor:n,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(n,o),r=i?`url(#${o})`:Xe(n.style.fill);if(n.cornerRadii&&He(n.cornerRadii)){const e=function(t){const{x:e,y:n,w:o,h:i}=t,{tl:r,tr:s,br:a,bl:l}=Ge(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}(n);return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("path",{d:e,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},d)}if(n.roundedTop&&n.roundedTop>0){const e=Math.min(n.roundedTop,n.w/2,n.h/2),{x:o,y:s,w:a,h:l}=n;let c;switch(n.roundedEdge){case"right":c=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+l-e} A${e},${e} 0 0 1 ${o+a-e},${s+l} L${o},${s+l} Z`;break;case"left":c=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+l-e} A${e},${e} 0 0 0 ${o+e},${s+l} L${o+a},${s+l} Z`;break;case"bottom":c=`M${o},${s} L${o+a},${s} L${o+a},${s+l-e} A${e},${e} 0 0 1 ${o+a-e},${s+l} L${o+e},${s+l} A${e},${e} 0 0 1 ${o},${s+l-e} Z`;break;default:c=`M${o},${s+l} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+l} Z`}return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("path",{d:c,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},d)}return t.jsxs(m.Fragment,{children:[i&&t.jsx("defs",{children:i}),t.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},d)}case"point":{const n=e;return t.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:Xe(n.style.fill),opacity:null!==(o=n.style.opacity)&&void 0!==o?o:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},d)}case"wedge":{const n=e,o=c.arc().innerRadius(n.innerRadius).outerRadius(n.outerRadius).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2);n.cornerRadius&&o.cornerRadius(n.cornerRadius);const i=o(qe)||"";return t.jsx("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:Xe(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},d)}case"boxplot":{const n=e,o=n.columnWidth/2;return t.jsxs("g","vertical"===n.projection?{children:[t.jsx("line",{x1:n.x,y1:n.minPos,x2:n.x,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:n.x-o,y:Math.min(n.q1Pos,n.q3Pos),width:n.columnWidth,height:Math.abs(n.q3Pos-n.q1Pos),fill:Xe(n.style.fill),fillOpacity:null!==(i=n.style.fillOpacity)&&void 0!==i?i:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.x-o,y1:n.medianPos,x2:n.x+o,y2:n.medianPos,stroke:n.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:n.x-.5*o,y1:n.minPos,x2:n.x+.5*o,y2:n.minPos,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.x-.5*o,y1:n.maxPos,x2:n.x+.5*o,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1})]}:{children:[t.jsx("line",{x1:n.minPos,y1:n.y,x2:n.maxPos,y2:n.y,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(n.q1Pos,n.q3Pos),y:n.y-o,width:Math.abs(n.q3Pos-n.q1Pos),height:n.columnWidth,fill:Xe(n.style.fill),fillOpacity:null!==(r=n.style.fillOpacity)&&void 0!==r?r:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.medianPos,y1:n.y-o,x2:n.medianPos,y2:n.y+o,stroke:n.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:n.minPos,y1:n.y-.5*o,x2:n.minPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:n.maxPos,y1:n.y-.5*o,x2:n.maxPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1})]},d)}case"violin":{const n=e,o=[t.jsx("path",{d:n.pathString,transform:n.translateX||n.translateY?`translate(${n.translateX},${n.translateY})`:void 0,fill:Xe(n.style.fill),fillOpacity:null!==(s=n.style.fillOpacity)&&void 0!==s?s:.6,stroke:n.style.stroke||"#333",strokeWidth:n.style.strokeWidth||1},u("path"))];if(n.iqrLine&&n.bounds){const e=n.bounds,i=e.x+e.width/2,r=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:i,y1:n.iqrLine.q1Pos,x2:i,y2:n.iqrLine.q3Pos,stroke:n.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:i,cy:n.iqrLine.medianPos,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},u("med"))):o.push(t.jsx("line",{x1:n.iqrLine.q1Pos,y1:r,x2:n.iqrLine.q3Pos,y2:r,stroke:n.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:n.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},u("med")))}return t.jsx("g",{children:o},d)}case"connector":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5},d);case"trapezoid":{const n=e,o=n.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:Xe(n.style.fill,"#999"),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},d)}default:return null}}const Ze="undefined"==typeof window||"undefined"==typeof document;function Ke(n){let o=null;const i=()=>(o||(o=e.createContext(null)),o),r=Qe(n);return[function({children:o,initialState:r}){const s=e.useRef(r),a=e.useMemo(()=>Qe(n,s.current),[]),l=i();return t.jsx(l.Provider,{value:a,children:o})},t=>{var n;const o=i(),s=null!==(n=e.useContext(o))&&void 0!==n?n:r,a=e.useRef(t);a.current=t;const l=e.useCallback(()=>a.current(s.getState()),[s]),c=e.useCallback(()=>a.current(s.getState()),[s]);return e.useSyncExternalStore(s.subscribe,l,c)}]}function Qe(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 Je(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 tn(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:en})})),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 en=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],nn={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}},on={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}},rn={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:en,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 sn(t,e){if("light"===e)return nn;if("dark"===e)return on;if("high-contrast"===e)return rn;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?on:nn;return tn(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 tn(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[an,ln]=Ke(t=>({theme:nn,setTheme(e){t(t=>({theme:sn(t.theme,e)}))}})),cn={light:nn,dark:on,"high-contrast":rn,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 un(t){if(!t)return nn;if("string"==typeof t){if("light"===t)return nn;if("dark"===t)return on;if("high-contrast"===t)return rn;return cn[t]||nn}const e="dark"===t.mode?on:nn;return tn(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 dn(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 hn(e){const{categories:n,colorScheme:i,theme:r,position:s="right",totalWidth:a,totalHeight:l,margin:c,hasTitle:u=!1}=e;if(!n||0===n.length)return null;const d=function(t,e,n){const i=Array.isArray(e)?e:n.colors.categorical.length>0?n.colors.categorical:z;return o.scaleOrdinal().domain(t).range(i)}(n,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 e=0;const o=n.map((n,o)=>{const i=e;return e+=22+6.5*n.length+8,t.jsxs("g",{transform:`translate(${i},0)`,children:[t.jsx("rect",{width:14,height:14,fill:d(n),rx:2}),t.jsx("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.jsx("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:o})}const p=n.map((e,n)=>t.jsxs("g",{transform:`translate(0,${20*n})`,children:[t.jsx("rect",{width:14,height:14,fill:d(e),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:r.typography.tickSize,fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e})]},"legend-"+n));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:p})}function fn(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 gn(t,e){return t.color||e.colors.annotation||e.colors.text}function pn(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 yn(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 mn(e){const{annotations:n}=e;if(!n||0===n.length)return null;const o=[];for(let t=0;n.length>t;t++){const i=vn(n[t],t,e);i&&o.push(i)}return o.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function vn(e,n,o){var i,r,s,a;const{scales:l,layout:c,theme:u,xAccessor:d,yAccessor:h}=o;switch(e.type){case"y-threshold":{const r=e.value;if(null==r)return null;const s=gn(e,u),a=e.label,d=e.labelPosition||"right",h=e.strokeDasharray||"6,4",f=null!==(i=e.strokeWidth)&&void 0!==i?i:1.5;if("horizontal"===o.projection&&l.r){const e=l.r(r);return null==e?null:t.jsxs("g",{children:[t.jsx("line",{x1:e,y1:0,x2:e,y2:c.height,stroke:s,strokeWidth:f,strokeDasharray:h}),a&&t.jsx("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+n)}const g=l.y?l.y(r):l.r?l.r(r):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:c.width,y2:g,stroke:s,strokeWidth:f,strokeDasharray:h}),a&&t.jsx("text",{x:"left"===d?4:"center"===d?c.width/2:c.width-4,y:g-6,textAnchor:"left"===d?"start":"center"===d?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+n)}case"x-threshold":{const o=e.value;if(null==o||!l.x)return null;const i=l.x(o);if(null==i)return null;const s=gn(e,u),a=e.label,d=e.labelPosition||"top",h=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;return t.jsxs("g",{children:[t.jsx("line",{x1:i,y1:0,x2:i,y2:c.height,stroke:s,strokeWidth:h,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:i+4,y:"bottom"===d?c.height-4:"center"===d?c.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-xthresh-"+n)}case"band":{const o=null!=e.y0&&l.y?l.y(e.y0):null,i=null!=e.y1&&l.y?l.y(e.y1):null;if(null==o||null==i)return null;const r=Math.min(o,i),a=Math.abs(i-o),d=e.fill||gn(e,u),h=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:r,width:c.width,height:a,fill:d,opacity:h}),e.label&&t.jsx("text",{x:c.width-4,y:r+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:d,fontFamily:u.typography.fontFamily,children:e.label})]},"ann-band-"+n)}case"category-highlight":{if(!e.category||!l.o)return null;const i=l.o(e.category);if(null==i)return null;const r=l.o.bandwidth?l.o.bandwidth():40,s=gn(e,u),d=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:i,width:c.width,height:r,fill:s,opacity:d}:{x:i,y:0,width:r,height:c.height,fill:s,opacity:d},"ann-cathighlight-"+n)}case"label":case"text":{const{x:o,y:i}=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:pn(t,e,n),y:yn(t,e,o)}}(e,l,d,h);if(null==o||null==i)return null;const r=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.jsxs("g",{children:["label"===e.type&&t.jsx("line",{x1:o,y1:i,x2:o+r,y2:i+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.jsx("text",{x:o+r,y:i+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight,children:e.label||e.title})]},"ann-label-"+n)}default:return null}}function xn(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 bn(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,x=0,b=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>x&&(x=m+v),m>b&&(b=m),v>k&&(k=v),w.push({t:t.time,topMass:m,botMass:v})}const S=[];let j=0;for(;w.length>j;){let t=j;for(;w.length>t+1&&w[t+1].t===w[j].t;)t++;S.push(w[j]);for(let e=j+1;t>=e;e++){const t=S[S.length-1];w[e].topMass===t.topMass&&w[e].botMass===t.botMass||S.push(w[e])}j=t+1}const M=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;if(S.length>0){const t=S[S.length-1];null!=M&&M>t.t&&t.topMass+t.botMass>0&&S.push({t:M,topMass:t.topMass,botMass:t.botMass});const e=S[0];null!=c&&e.t>c&&e.topMass+e.botMass>0&&S.unshift({t:c,topMass:e.topMass,botMass:e.botMass})}return{samples:S,peak:x,topPeak:b,botPeak:k,localAttachments:A}}function kn(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function wn(t,e){return t.map(t=>({t:kn(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function An(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 Sn(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 jn(t,e){return 1e3*An(t,e)+Sn(t,e)}function Mn(t,e){return{slots:t.map(t=>({peak:Object.assign({},t.peak),occupants:t.occupants.slice()})),map:Object.assign({},e)}}function _n(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=Mn(t,e),s=jn(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=jn(e,n);if(s>d)s=d,r=Mn(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=jn(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=jn(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=jn(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 Pn(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,x={},b={};for(const e of t)x[e.id]=n[e.id].topPeak||0,b[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);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)}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,x[t.id]),S[n].peak.botPeak=Math.max(S[n].peak.botPeak,b[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:x[t.id],botPeak:b[t.id]}}),A[t.id]=e});let j=null,M=null,_=null,P=null;const O=()=>{j=An(A,e),_=Sn(A,e)},T=()=>{M=An(A,e),P=Sn(A,e)};"crossing-min"===m?(O(),_n(S,A,e),T()):"inside-out"===m?(O(),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),T()):"crossing-min+inside-out"===m&&(O(),_n(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=jn(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=jn(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),T());const C=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},$=[];for(let t=0;S.length-1>t;t++){const e=C[t],n=C[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)}$.push(i)}const E=[];let D=g+(null!==(h=null===(d=S[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;S.length>0&&E.push(D);for(let t=1;S.length>t;t++)D+=$[t-1]*p+g,E.push(D);if(S.length>0&&(D+=S[S.length-1].peak.botPeak*p+g),D>f){const t=f/D;for(let e=0;E.length>e;e++)E[e]*=t}const R=0===S.length?0:S[0].peak.topPeak+$.reduce((t,e)=>t+e,0)+S[S.length-1].peak.botPeak,z={};for(const e of t)z[e.id]=E[A[e.id]];return{effectiveSlotsHeight:R,centerlines:z,laneLifetime:w,slots:S,slotByNode:A,slotCenter:E,crossingsBefore:j,crossingsAfter:M,lengthBefore:_,lengthAfter:P}}function On(t){const{nodes:e,edges:n,domain:i,plotW:r,plotH:s,ribbonLane:a,edgeOpacity:l,colorOf:c,layoutOpts:u}=t,d=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,i),h=o.scaleTime().domain(i).range([0,r]);if(d.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:d,xScale:h};const f=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]=bn(e,c,u);const h=Pn(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]=bn(e,c,u);const g=Pn(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=Pn(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:s},u)),{centerlines:g,nodeData:p,valueScale:y}=f,m=[],v=[];e.forEach((t,e)=>{var n;const o=p[t.id];if(!o||0===o.samples.length)return;const r=function(t,e,n,o,i){if(0===t.length)return null;const r=wn(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"}(o.samples,g[t.id],y,h,i);if(!r)return;const s=wn(o.samples,i),a=s.find(t=>t.topMass+t.botMass>0)||s[0],l=g[t.id]+(a.botMass-a.topMass)*y/2,u=c(t.id,e);m.push({id:t.id,pathD:r,fill:u,stroke:u,strokeWidth:.5,rawDatum:null!==(n=t.__raw)&&void 0!==n?n:t,labelX:h(a.t)-4,labelY:l,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),n.forEach(t=>{var e,n,o,r;const s=null===(e=p[t.source])||void 0===e?void 0:e.localAttachments.get(t.id),u=null===(n=p[t.target])||void 0===n?void 0:n.localAttachments.get(t.id);if(!s||!u)return;const d=null!==(o=x.get(t.source))&&void 0!==o?o:0,f=c(t.source,d),m=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,x;"top"===t.side?(y=e-g,m=y+h):(m=e+g,y=m-h),"top"===n.side?(v=o-p,x=v+f):(x=o+p,v=x-f);const b="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:x,cp1X:b,cp2X:b}}(s,g[t.source],u,g[t.target],y,h,a,i),{pathD:b,bezier:k}=Jt(m);v.push({id:t.id,pathD:b,fill:f,opacity:l,rawDatum:null!==(r=t.__raw)&&void 0!==r?r:t,bezier:k})}),{layout:f,layoutConfig:{bands:m,ribbons:v,showLabels:!0},issues:[],xScale:h}}const Tn=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)s.push({type:"bezier",pathD:t.pathD,style:{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}},Cn=Object.freeze([]);function Ln(t){if(!t)return Cn;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 $n={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 En(t,e){return"function"==typeof e?e(t):t[e]}function Dn(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 Rn(e={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const l=[];if(o){const t=En(e,o);a=Dn(t,i)}if(n&&n.length>0)n.forEach(t=>{let n,o,r;"string"==typeof t?(n=t,o=t,r=i):(n=t.label,o=t.accessor||t.key||"",r=t.format||i);const s=En(e,o);l.push({label:n,value:Dn(s,r)})});else if(!o){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=Dn(e[n],i);break}if(!a){const t=Object.keys(e).filter(t=>!t.startsWith("_"));t.length>0&&(a=Dn(e[t[0]],i))}}const c=Object.assign(Object.assign({},$n),r);return t.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&t.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((e,n)=>t.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[e.label&&t.jsxs("span",{children:[e.label,": "]}),e.value]},n))]})}}function zn(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 Bn(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 Fn({width:n,height:o,totalWidth:i,totalHeight:r,margin:s,dimension:a,scales:l,onBrush:c,binSize:u,snap:d,binBoundaries:g,snapDuring:p,streaming:y}){const m=e.useRef(null),v=e.useRef(null),x=e.useRef(c);x.current=c;const b=e.useRef(l);b.current=l;const k=e.useMemo(()=>g?[...g].sort((t,e)=>t-e):void 0,[g]),w=e.useRef(k);w.current=k;const A=e.useRef(!1),S=e.useRef(null);return e.useEffect(()=>{if(!m.current)return;const t=h.select(m.current).select(".brush-g"),e="x"===a?f.brushX():"y"===a?f.brushY():f.brush();return e.extent([[0,0],[n,o]]),e.on("brush end",i=>{if(A.current)return;const r=b.current;if(!r)return;if(!i.selection)return S.current=null,void x.current(null);let s,l;if("x"===a){const[t,e]=i.selection;s=[r.x.invert(t),r.x.invert(e)],l=[r.y.invert(o),r.y.invert(0)]}else if("y"===a){const[t,e]=i.selection;s=[r.x.invert(0),r.x.invert(n)],l=[r.y.invert(e),r.y.invert(t)]}else{const[[t,e],[n,o]]=i.selection;s=[r.x.invert(t),r.x.invert(n)],l=[r.y.invert(o),r.y.invert(e)]}if("bin"===d&&"y"!==a&&("end"===i.type||"brush"===i.type&&p)){const n=w.current;n&&n.length>0?s=function(t,e){return 0===e.length?t:[zn(t[0],e),Bn(t[1],e)]}(s,n):u&&u>0&&(s=[Math.floor(s[0]/u)*u,Math.ceil(s[1]/u)*u]);const o=r.x(s[0]),l=r.x(s[1]);if(A.current=!0,"x"===a)t.call(e.move,[o,l]);else if("xy"===a){const n=i.selection;t.call(e.move,[[o,n[0][1]],[l,n[1][1]]])}A.current=!1}const c={x:s,y:l};S.current=c,x.current(c)}),t.call(e),v.current=e,t.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{e.on("brush end",null),v.current=null}},[n,o,a,d,u,p]),e.useEffect(()=>{if(!(y&&l&&v.current&&S.current))return;if(!m.current)return;if("y"===a)return;const t=S.current,e=l.x.domain()[0],n=h.select(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 x.current(null);let o=t.x[0],i=!1;if(e>t.x[0]){if(o=e,"bin"===d){const t=w.current;t&&t.length>0?o=Bn(e,t):u&&u>0&&(o=Math.ceil(e/u)*u)}if(o>=t.x[1])return A.current=!0,n.call(v.current.move,null),A.current=!1,S.current=null,void x.current(null);i=!0}const r=l.x(o),s=l.x(t.x[1]);if(A.current=!0,"x"===a)n.call(v.current.move,[r,s]);else{const e=l.y(t.y[1]),o=l.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,x.current(e)}},[l,y,a,d,u]),t.jsx("svg",{ref:m,width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:t.jsx("g",{className:"brush-g",transform:`translate(${s.left},${s.top})`})})}class Nn{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=Ln(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=Ln(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 Wn(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:m.createElement(m.Fragment,null,...e)}function In(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 Yn(t,e=30){return Math.max((null!=t?t:4)+5,12,e)}function Hn(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function Gn(t,e){const n=Hn(t);if(!n)return!1;const o=Hn(e);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}const qn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Xn=new WeakMap;let Vn=0,Un=!1,Zn=null,Kn=null,Qn=null;function Jn(t,e){var n,o;if(!e)return e;const i=qn.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(Un)return;if("undefined"==typeof window||"undefined"==typeof document)return;Un=!0;const t=()=>{Vn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Zn=new MutationObserver(t),Zn.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Kn=window.matchMedia("(prefers-color-scheme: dark)"),Qn=t,"function"==typeof Kn.addEventListener?Kn.addEventListener("change",Qn):"function"==typeof Kn.addListener&&Kn.addListener(Qn)}catch(t){}}();let s=Xn.get(r);s&&s.version===Vn||(s={version:Vn,map:new Map},Xn.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 to(t){switch(t){case"monotoneX":return c.curveMonotoneX;case"monotoneY":return c.curveMonotoneY;case"cardinal":return c.curveCardinal;case"catmullRom":return c.curveCatmullRom;case"step":return c.curveStep;case"stepBefore":return c.curveStepBefore;case"stepAfter":return c.curveStepAfter;case"basis":return c.curveBasis;case"natural":return c.curveNatural;default:return null}}function eo(t,e,n){return null==e?n:"string"!=typeof e?e:Jn(t,e)||n}function no(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 oo(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 io=new WeakMap;function ro(t,e){const n=to(e);if(!n)return t;const o=io.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 c.line().x(t=>t[0]).y(t=>t[1]).curve(e).context(r)(t),o}(t,n);return io.set(t,i),i}function so(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);Yn(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=lo(r,e,n,o);break;case"line":t=co(r,e,n,o);break;case"rect":if(null==r.datum)break;t=ho(r,e,n);break;case"heatcell":t=fo(r,e,n);break;case"area":if(!1===r.interactive)break;t=po(r,e,n);break;case"candlestick":t=go(r,e,n)}t&&o>t.distance&&(s&&t.distance>=s.distance||(s=t))}return s}function ao(t,e,n){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=yo(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 lo(t,e,n,o=30){const i=e-t.x,r=n-t.y,s=Math.sqrt(i*i+r*r);return s>Yn(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function co(t,e,n,o=30){var i,r,s,a;if(0===t.path.length)return null;const l=yo(t.path,e);if(0>l)return null;const[c,u]=t.path[l];let d;if(t.path.length>1){let o=1/0;const i=Math.max(0,l-1),r=Math.min(t.path.length-2,l);for(let s=i;r>=s;s++){const[i,r]=t.path[s],[a,l]=t.path[s+1],c=uo(e,n,i,r,a,l);o>c&&(o=c)}d=o}else{const t=e-c,o=n-u;d=Math.sqrt(t*t+o*o)}const h=null!==(a=null!==(r=null===(i=t.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(s=t.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:c,y:u,distance:d}}function uo(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 ho(t,e,n){const o=In(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function fo(t,e,n){const o=In(e,n,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function go(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 po(t,e,n){if(0===t.topPath.length)return null;const o=yo(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 yo(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 mo(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 vo(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}const xo={fill:e=>t.jsx("rect",{style:e,width:16,height:16}),line:e=>t.jsx("line",{style:e,x1:0,y1:0,x2:16,y2:16})};function bo(t,e,n,o){let i;return i="function"==typeof n?n(t):(0,xo[n])(o(t,e)),i}function ko(){return t.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function wo(t,e,n){return n&&n.size>0?n.has(t.label)?1:.3:null!=e?t.label===e?1:.3:1}const Ao=(e,n,o,i,r,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let p=0;const y=!(!n&&!o),m="isolate"===u||void 0===u&&null!=r;return f.forEach((e,u)=>{const v=bo(e,u,d,h),x=wo(e,i,r),b=r&&r.size>0&&r.has(e.label);g.push(t.jsxs("g",{transform:`translate(0,${p})`,onClick:n?()=>n(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:y?l===s&&u===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?b||!1:void 0,"aria-current":y&&!m&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:y?t=>{var o;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowDown"===t.key||"ArrowUp"===t.key){t.preventDefault();const e=(u+("ArrowDown"===t.key?1:-1)+f.length)%f.length;c(l,e);const n=null===(o=t.currentTarget.parentElement)||void 0===o?void 0:o.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:y?t=>{c(l,u),o&&o(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:y?t=>{o&&o(null);const e=t.currentTarget.querySelector(".semiotic-legend-focus-ring");e&&e.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:x,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,b&&t.jsx(ko,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),p+=22}),g};function So({config:e,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:s,format:a}=e,l=a||(t=>Math.round(100*t)/100+""),c="grad-legend-"+m.useId();if("horizontal"===n){const e=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&t.jsx("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("rect",{x:a,y:0,width:n,height:e,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),t.jsx("text",{x:a+n,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let e=0;64>=e;e++){const n=e/64;u.push(t.jsx("stop",{offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))},e))}return t.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&t.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),t.jsx("defs",{children:t.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),t.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),t.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])}),t.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function jo(e){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=e,[h,f]=m.useState(0),[g,p]=m.useState(0),y=m.useCallback((t,e)=>{f(t),p(e)},[]),v="vertical"===d?(({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.jsx("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.jsx("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.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:Ao(e,o,i,r,s,a,l,f,c,u)},"legend-group-"+f)),d+=22*e.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}):(({legendGroups:e,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];e.forEach((e,n)=>{let g=0;e.label&&(g+=16);const p=((e,n,o,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,p=[];let y=0,m=0;const v=!(!n&&!o),x="isolate"===u||void 0===u&&null!=r;g.forEach((e,u)=>{const b=bo(e,u,h,f),k=wo(e,i,r),w=r&&r.size>0&&r.has(e.label),A=26+7*e.label.length;d&&d>0&&y>0&&y+A>d&&(m++,y=0),p.push(t.jsxs("g",{transform:`translate(${y},${22*m})`,onClick:n?()=>n(e):void 0,onMouseEnter:o?()=>o(e):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?l===s&&u===a?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&x?w||!1:void 0,"aria-current":v&&!x&&null!=i&&e.label===i||void 0,"aria-label":e.label,onKeyDown:v?t=>{var o;if("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n&&n(e)),"ArrowRight"===t.key||"ArrowLeft"===t.key){t.preventDefault();const e=(u+("ArrowRight"===t.key?1:-1)+g.length)%g.length;c(l,e);const n=null===(o=t.currentTarget.parentElement)||void 0===o?void 0:o.children[e];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:v?t=>{c(l,u),o&&o(e);const n=t.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.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:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&t.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*e.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,w&&t.jsx(ko,{}),t.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),y+=A});let b=0,k=0;for(const t of g){const e=26+7*t.label.length;d&&d>0&&k>0&&k+e>d?(b=Math.max(b,k),k=e):k+=e}b=Math.max(b,k);const w=m+1;return{items:p,offset:b,totalRows:w,totalHeight:22*w}})(e,i,r,s,a,l,c,n,u,d,o);g+=p.offset+5,f.push(Object.assign(Object.assign({label:e.label},p),{offset:g,totalRows:p.totalRows,totalHeight:p.totalHeight})),h+=g+12});let g=h>o?0:Math.max(0,(o-h)/2);const p=[];return f.forEach((o,i)=>{const r=e[i];r.label&&(p.push(t.jsx("text",{transform:`translate(${g},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)),g+=16),p.push(t.jsx("g",{className:"legend-item",transform:`translate(${g},0)`,children:o.items},"legend-group-"+i)),g+=o.offset+5,e[i+1]&&p.push(t.jsx("line",{stroke:"gray",x1:g,y1:-8,x2:g,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+i)),g+=12}),t.jsx("g",{children:p})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:y,legendInteraction:a}),x=!(!o&&!i);return t.jsxs("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==a&&(void 0!==a||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===d&&t.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),v]})}function Mo(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function _o(t){return"object"==typeof t&&null!==t&&"gradient"in t}function Po(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.jsx("g",{transform:`translate(${g}, ${p})`,children:_o(n)?t.jsx(So,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?o:100}):Mo(n)?t.jsx(jo,{legendGroups:n.legendGroups,title:"",width:f?o:100,orientation:f?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n})}function Oo(t){return"string"==typeof t?{type:t}:t}function To({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=e.useMemo(()=>{if(0===i.length)return null;const e=s.domain(),o=a-8;if("boxplot"===c.type){const e=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(!e)return null;const{q1:r,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=e,f=Math.min(.5*o,20),g=(o-f)/2+4;if(u){const e=s(r),o=s(l),i=s(a),u=s(d),p=s(h),y="top"===n?-1:1,m=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:u,y1:m+y*(g+f/2),x2:p,y2:m+y*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:u,y1:m+y*g,x2:u,y2:m+y*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:p,y1:m+y*g,x2:p,y2:m+y*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:Math.min(e,o),y:"top"===n?m-g-f:m+g,width:Math.abs(o-e),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:i,y1:"top"===n?m-g-f:m+g,x2:i,y2:"top"===n?m-g:m+g+f,stroke:c.fill,strokeWidth:2})]})}{const e=s(r),o=s(l),i=s(a),u=s(d),p=s(h),y="left"===n?-1:1,m=0;return t.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[t.jsx("line",{x1:m+y*(g+f/2),y1:u,x2:m+y*(g+f/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:m+y*g,y1:u,x2:m+y*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:m+y*g,y1:p,x2:m+y*(g+f),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),t.jsx("rect",{x:"left"===n?m-g-f:m+g,y:Math.min(e,o),width:f,height:Math.abs(o-e),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),t.jsx("line",{x1:"left"===n?m-g-f:m+g,y1:i,x2:"left"===n?m-g:m+g+f,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=r.bin().domain(e).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.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const r=e.length/h*o;if(u){const o=s(e.x0),a=s(e.x1)-s(e.x0);return t.jsx("rect",{x:o,y:"top"===n?-4-r:4,width:Math.max(a,.5),height:r,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const o=s(e.x0),a=s(e.x1)-s(e.x0);return t.jsx("rect",{x:"left"===n?-4-r:4,y:Math.min(o,o+a),width:r,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const e=o/2+4,i=[];for(const t of d){if(null==t.x0||null==t.x1)continue;const r=t.length/h*(o/2),a=s((t.x0+t.x1)/2);i.push(u?`${a},${"top"===n?-(e-r):e-r}`:`${"left"===n?-(e-r):e-r},${a}`)}for(let t=d.length-1;t>=0;t--){const r=d[t];if(null==r.x0||null==r.x1)continue;const a=r.length/h*(o/2),l=s((r.x0+r.x1)/2);i.push(u?`${l},${"top"===n?-(e+a):e+a}`:`${"left"===n?-(e+a):e+a},${l}`)}return t.jsx("g",{"data-testid":"marginal-violin-"+n,children:t.jsx("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*o,r=s((t.x0+t.x1)/2);e.push(`L${r},${"top"===n?-i-4:i+4}`)}const r=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${r},${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*o,r=s((t.x0+t.x1)/2);e.push(`L${"left"===n?-i-4:i+4},${r}`)}const r=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;e.push(`L${t},${r}`),e.push("Z")}return t.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:t.jsx("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.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function Co(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 Lo(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 $o(e,n,o,i){if(!e)return t.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=e;if(!r&&!s)return t.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,p=s?u?[s]:Co(s,c):[],y=r?u?[r]:Co(r,c):[],m="leftRight"===d?"end"===f?-4:4:0;let v=0;const x=[],b=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(x.push(t.jsx("text",{className:"annotation-note-title",fill:b,textAnchor:f,fontWeight:"bold",children:p.map((e,n)=>t.jsx("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-title")),v=p.length*g),y.length>0&&x.push(t.jsx("text",{className:"annotation-note-label",fill:b,textAnchor:f,y:v,children:y.map((e,n)=>t.jsx("tspan",{x:m,dy:0===n?0:g,children:e},n))},"annotation-note-label"));let k=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===d){const e=Math.min(c,120);let n=0,o=e;"end"===f?(n=-e,o=0):"middle"===f&&(n=-e/2,o=e/2),k=t.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*g+(y.length>0?g:0);let n=0,o=e;"bottom"===h?(n=-e,o=0):"middle"===h&&(n=-e/2,o=e/2),k=t.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*g;let A=0;return"topBottom"===d?A=0>o?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+g+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>o?-(w+2):18),t.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[t.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:x}),k]})}function Eo(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.jsx("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.jsx("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.jsx("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.jsx("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.jsx("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.jsx("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.jsx("path",{d:Lo((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.jsx("g",{className:"annotation-subject",children:a})}function Do(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.jsx("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.jsx("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.jsx("g",{className:"annotation-connector",children:a})}function Ro(e){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}=e,m=new Set(Array.isArray(g)?g:[]);let v=i||0,x=r||0;null!=s&&(v=s-n),null!=a&&(x=a-o);const b="string"==typeof d?d:"label";if("bracket"===b&&u&&0===v&&0===x)if(void 0!==u.width){v=u.width/2;const t=u.depth||30;x=t+(0>t?-5:5)}else if(void 0!==u.height){const t=u.depth||30;v=t+(0>t?-5:5),x=u.height/2}return t.jsxs("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":y},p,{children:[!m.has("connector")&&Do(v,x,c,h,b,u),!m.has("subject")&&Eo(b,u,h,n,o),!m.has("note")&&$o(l,v,x,h)]}))}function zo(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.jsx(Ro,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return t.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return t.jsx(Ro,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Bo(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 Fo(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 No(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=Bo(t,n),c=Fo(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 Wo(t,e,n,o=50){return!(-o>t||t>(n.width||0)+o||-o>e||e>(n.height||0)+o)}const Io={linear:c.curveLinear,monotoneX:c.curveMonotoneX,monotoneY:c.curveMonotoneY,step:c.curveStep,stepAfter:c.curveStepAfter,stepBefore:c.curveStepBefore,basis:c.curveBasis,cardinal:c.curveCardinal,catmullRom:c.curveCatmullRom};let Yo={positions:new Map};const Ho=new Set;function Go(){for(const t of Ho)t()}function qo(t,e){const n=Yo.positions.get(t);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==e)return;const o=new Map(Yo.positions);o.delete(t),Yo={positions:o},Go()}function Xo(t,e){const n=Yo.positions.get(t);if(!(null==n?void 0:n.locked))return;if(e&&n.sourceId!==e)return;const o=new Map(Yo.positions);o.delete(t),Yo={positions:o},Go()}function Vo(){return Yo}function Uo(t){return Ho.add(t),()=>Ho.delete(t)}const Zo={positions:new Map};function Ko(){return()=>{}}function Qo(){return Zo}function Jo(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 ti(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function ei(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 ni(n){const{width:o,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f,axisExtent:g}=n,p=e.useMemo(()=>{var t,e;if(!l)return[];const n=null==u?void 0:u.find(t=>"bottom"===t.orient),i=(null==n?void 0:n.tickFormat)||h||oi,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:Jo(l.x,"exact"===g?Math.max(2,s):Math.min(s,r),g),c=a.map(t=>t.valueOf()),d=a.map((t,e)=>({value:t,pixel:l.x(t),label:i(t,e,c)})),f=d.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 ii(d,Math.max(55,f+8))},[l,u,h,o,g]),y=e.useMemo(()=>{var t,e;if(!l)return[];const n=null==u?void 0:u.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||f||oi,r=Math.max(2,Math.floor(i/30)),s=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;return ii((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Jo(l.y,"exact"===g?Math.max(2,s):Math.min(s,r),g)).map(t=>({value:t,pixel:l.y(t),label:o(t)})),22)},[l,u,f,i,g]),m=d&&l,v=c&&l;if(!m&&!v)return null;const x=null==u?void 0:u.find(t=>"bottom"===t.orient),b=null==u?void 0:u.find(t=>"left"===t.orient),k=v&&(!x||!1!==x.baseline),w=v&&(!b||!1!==b.baseline),A=(null==x?void 0:x.jaggedBase)||!1,S=(null==b?void 0:b.jaggedBase)||!1,j="var(--semiotic-border, #ccc)";return t.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:t.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[m&&(()=>{var e,n;const r=ti(null===(e=null==u?void 0:u.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),s=ti(null===(n=null==u?void 0:u.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[p.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),y.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:o,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),k&&!A&&t.jsx("line",{x1:0,y1:i,x2:o,y2:i,stroke:j,strokeWidth:1}),A&&t.jsx("path",{d:ei("bottom",o,i),fill:"none",stroke:j,strokeWidth:1}),w&&!S&&t.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:j,strokeWidth:1}),S&&t.jsx("path",{d:ei("left",o,i),fill:"none",stroke:j,strokeWidth:1})]})})}function oi(t,e,n){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function ii(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 ri(n){var o,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:d,scales:h,showAxes:f,axes:g,xLabel:p,yLabel:y,yLabelRight:m,xFormat:v,yFormat:b,axisExtent:k,showGrid:w,title:A,legend:S,legendHoverBehavior:j,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:P,legendPosition:O="right",foregroundGraphics:T,marginalGraphics:C,xValues:L,yValues:$,annotations:E,svgAnnotationRules:D,xAccessor:R,yAccessor:z,annotationData:B,pointNodes:F,curve:N,underlayRendered:W,canvasObscuresUnderlay:I=!0,linkedCrosshairName:Y,linkedCrosshairSourceId:H,children:G}=n,q=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"bottom"===t.orient),o=(null==n?void 0:n.tickFormat)||v||oi,i=Math.max(2,Math.floor(r/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:Jo(h.x,"exact"===k?Math.max(2,s):Math.min(s,i),k),l=a.map(t=>t.valueOf()),c=a.map((t,e)=>({value:t,pixel:h.x(t),label:o(t,e,l)})),u=c.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 p=ii(c,d);if(p.length>1&&(p=p.filter((t,e)=>0===e||t.label+""!=p[e-1].label+"")),(null==n?void 0:n.includeMax)&&p.length>0&&"exact"!==k&&!(null==n?void 0:n.tickValues)){const t=h.x.domain()[1],e=h.x(t),n=p[p.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t,p.length,l);d>e-n&&p.length>1&&(p=p.slice(0,-1)),p.push({value:t,pixel:e,label:i})}}return p},[f,h,g,v,r,k]),X=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"left"===t.orient),o=(null==n?void 0:n.tickFormat)||b||oi,i=Math.max(2,Math.floor(s/30)),r=null!==(t=null==n?void 0:n.ticks)&&void 0!==t?t:5;let a=ii((null!==(e=null==n?void 0:n.tickValues)&&void 0!==e?e:Jo(h.y,"exact"===k?Math.max(2,r):Math.min(r,i),k)).map(t=>({value:t,pixel:h.y(t),label:o(t)})),22);if(a.length>1&&(a=a.filter((t,e)=>0===e||t.label+""!=a[e-1].label+"")),(null==n?void 0:n.includeMax)&&a.length>0&&"exact"!==k&&!(null==n?void 0:n.tickValues)){const t=h.y.domain()[1],e=h.y(t),n=a[a.length-1].pixel;if(Math.abs(e-n)>1){const i=o(t);22>Math.abs(e-n)&&a.length>1&&(a=a.slice(0,-1)),a.push({value:t,pixel:e,label:i})}}return a},[f,h,g,b,s,k]),V=e.useMemo(()=>{var t,e;if(!f||!h)return[];const n=null==g?void 0:g.find(t=>"right"===t.orient);if(!n)return[];const o=n.tickFormat||b||oi,i=Math.max(2,Math.floor(s/30)),r=null!==(t=n.ticks)&&void 0!==t?t:5;return ii((null!==(e=n.tickValues)&&void 0!==e?e:Jo(h.y,"exact"===k?Math.max(2,r):Math.min(r,i),k)).map(t=>({value:t,pixel:h.y(t),label:o(t)})),22)},[f,h,g,b,s,k]),U=e.useRef(new Map),Z=e.useRef(null!==(o=null==E?void 0:E.length)&&void 0!==o?o:0),K=null!==(i=null==E?void 0:E.length)&&void 0!==i?i:0;Z.current!==K&&(Z.current=K,U.current=new Map);const Q=e.useMemo(()=>{if(!E||0===E.length)return null;const e=function(e,n,o){var i,r,s,a,l,d,h,f,g,p,y,m,v,b,k,w,A,S,j,M,_,P,O,T,C,L,$,E,D,R,z,B,F,N,W,I,Y,H,G,q,X,V,U,Z,K,Q,J,tt;switch(e.type){case"label":{const i=No(e,n,o);if(!i)return null;const{x:r,y:s}=i;return Wo(r,s,o)?t.jsx(zo,{noteData:{x:r,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"label",connector:e.connector||{end:"arrow"},color:e.color}},"ann-"+n):null}case"callout":{const i=No(e,n,o);if(!i)return null;const{x:r,y:s}=i;return Wo(r,s,o)?t.jsx(zo,{noteData:{x:r,y:s,dx:e.dx||30,dy:e.dy||-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"callout-circle",subject:{radius:e.radius||12},connector:e.connector||{end:"arrow"},color:e.color}},"ann-"+n):null}case"x-threshold":{const i=Bo(null!=e.value?Object.assign(Object.assign({},e),{x:e.value}):e,o);if(null==i)return null;const r=e.color||"#f97316",s=e.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,t.jsxs("g",{children:[t.jsx("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:i+4,y:a,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"y-threshold":{const i=Fo(null!=e.value?Object.assign(Object.assign({},e),{y:e.value}):e,o);if(null==i)return null;const r=e.color||"#f97316",s=e.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(o.width||0)/2,l="middle"):(a=(o.width||0)-4,l="end"),t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",children:e.label})]},"ann-"+n)}case"enclose":{const i=(e.coordinates||[]).map(t=>({x:Bo(Object.assign(Object.assign({},t),{type:"point"}),o),y:Fo(Object.assign(Object.assign({},t),{type:"point"}),o),r:1})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=u.packEnclose(i),s=e.padding||10;return t.jsxs("g",{children:[t.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"rect-enclose":{const i=(e.coordinates||[]).map(t=>({x:Bo(Object.assign(Object.assign({},t),{type:"point"}),o),y:Fo(Object.assign(Object.assign({},t),{type:"point"}),o)})).filter(t=>null!=t.x&&null!=t.y);if(2>i.length)return null;const r=e.padding||10,s=i.map(t=>t.x),a=i.map(t=>t.y),l=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...a)-r,d=Math.max(...a)+r;return t.jsxs("g",{children:[t.jsx("rect",{x:l,y:u,width:c-l,height:d-u,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&t.jsx("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:e.label})]},"ann-"+n)}case"highlight":{const i=o.data||[],r="function"==typeof e.filter?i.filter(e.filter):e.field&&null!=e.value?i.filter(t=>t[e.field]===e.value):[],s={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return t.jsx("g",{children:r.map((n,i)=>{const r=Bo(n,o),a=Fo(n,o);if(null==r||null==a)return null;const l="function"==typeof e.r?e.r(n):e.r||6,c="function"==typeof e.style?e.style(n):e.style||s;return t.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+n)}case"bracket":{const i=Bo(e,o),r=Fo(e,o);return t.jsx(zo,{noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const c=o.data||[];if(2>c.length)return null;const u=o.xAccessor||"x",f=o.yAccessor||"y",g="ordinal"===o.frameType,p="horizontal"===o.projection,y=g?u:null,m=g?f:null;let v;const b=[],k=new Map;if(g&&y&&m){for(const t of c){const e=t[y];if(null==e)continue;const n=e+"";k.has(n)||(k.set(n,b.length),b.push(n))}v=c.map(t=>{const e=t[y],n=t[m];if(null==e||null==n)return null;const o=k.get(e+"");return null!=o?[o,+n]:null}).filter(t=>null!==t)}else v=c.map(t=>[t[u],t[f]]).filter(t=>null!=t[0]&&null!=t[1]);if(2>v.length)return null;const w=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(s=o.scales)||void 0===s?void 0:s.time,A=null!==(l=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==l?l:null===(d=o.scales)||void 0===d?void 0:d.value;if(!w||!A)return null;const S=t=>e=>{const n=Math.max(0,Math.floor(e)),o=Math.min(b.length-1,n+1),i=e-n,r=t(b[n]);return r+(t(b[o])-r)*i},j=w,M=A;let _;if(g)if(p){const t=S(M);_=(e,n)=>[j(n),t(e)]}else{const t=S(j);_=(e,n)=>[t(e),M(n)]}else _=(t,e)=>[j(t),M(e)];const P=e.method||"linear";let O;O="loess"===P?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}(v,null!==(h=e.bandwidth)&&void 0!==h?h:.3):("polynomial"===P?x.default.polynomial(v,{order:e.order||2}):x.default.linear(v)).points;const T=O.map(([t,e])=>{const[n,o]=_(t,e);return`${n},${o}`}).join(" "),C=e.color||"#6366f1",L=O[O.length-1],[$,E]=_(L[0],L[1]);return t.jsxs("g",{children:[t.jsx("polyline",{points:T,fill:"none",stroke:C,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&t.jsx("text",{x:$+4,y:E-4,fill:C,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const i=null!==(g=null===(f=o.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(p=o.scales)||void 0===p?void 0:p.value,r=null!==(y=null==i?void 0:i(e.y0))&&void 0!==y?y:0,s=null!==(m=null==i?void 0:i(e.y1))&&void 0!==m?m:o.height||0;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:e.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:e.fillOpacity||.1}),e.label&&t.jsx("text",{x:(o.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:e.label})]},"ann-"+n)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=null!==(b=null===(v=o.scales)||void 0===v?void 0:v.x)&&void 0!==b?b:null===(k=o.scales)||void 0===k?void 0:k.time,a=null!==(A=null===(w=o.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(S=o.scales)||void 0===S?void 0:S.value;if(!s||!a)return null;const l=e.upperAccessor||"upperBounds",u=e.lowerAccessor||"lowerBounds",d=e.filter,h=i.filter(t=>null!=t[l]&&null!=t[u]&&!(d&&!d(t))).sort((t,e)=>t[r]-e[r]);if(2>h.length)return null;const f=Io[o.curve||"linear"]||c.curveLinear,g=c.area().x(t=>s(t[r])).y0(t=>a(t[u])).y1(t=>a(t[l])).curve(f)(h);if(!g)return null;const p=e.fill||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:g,fill:p,fillOpacity:null!==(j=e.fillOpacity)&&void 0!==j?j:.15,stroke:"none"}),e.label&&h.length>0&&t.jsx("text",{x:s(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==(_=null===(M=o.scales)||void 0===M?void 0:M.x)&&void 0!==_?_:null===(P=o.scales)||void 0===P?void 0:P.time,a=null!==(T=null===(O=o.scales)||void 0===O?void 0:O.y)&&void 0!==T?T:null===(C=o.scales)||void 0===C?void 0:C.value;if(!s||!a)return null;const l=i.map(t=>t[r]).filter(t=>null!=t&&isFinite(t));if(2>l.length)return null;const c=l.reduce((t,e)=>t+e,0)/l.length,u=l.reduce((t,e)=>t+Math.pow(e-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(L=e.threshold)&&void 0!==L?L:2,f=c-h*d,g=!1!==e.showBand,p=e.fill||"#6366f1",y=null!==($=e.fillOpacity)&&void 0!==$?$:.1,m=e.anomalyColor||"#ef4444",v=null!==(E=e.anomalyRadius)&&void 0!==E?E:6,x=a(c+h*d),b=a(f),k=i.filter(t=>{const e=t[r];return null!=e&&Math.abs(e-c)>h*d});return t.jsxs("g",{children:[g&&t.jsx("rect",{x:0,y:Math.min(x,b),width:o.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),k.map((e,n)=>{const i=Bo(e,o),r=Fo(e,o);return null==i||null==r?null:t.jsx("circle",{cx:i,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),e.label&&t.jsx("text",{x:(o.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(R=null===(D=o.scales)||void 0===D?void 0:D.x)&&void 0!==R?R:null===(z=o.scales)||void 0===z?void 0:z.time,l=null!==(F=null===(B=o.scales)||void 0===B?void 0:B.y)&&void 0!==F?F:null===(N=o.scales)||void 0===N?void 0:N.value;if(!a||!l)return null;const c=i.map(t=>[t[r],t[s]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,e)=>t[0]-e[0]);if(3>c.length)return null;let u;if("polynomial"===(e.method||"linear")){const t=x.default.polynomial(c,{order:e.order||2}).equation;u=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const t=c.length;let e=0,n=0,o=0,i=0;for(const[t,r]of c)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;u=t=>a+s*t}const d=c.length,h=c.map(([t,e])=>e-u(t)).reduce((t,e)=>t+e*e,0),f=Math.sqrt(h/Math.max(d-2,1)),g=c.reduce((t,e)=>t+e[0],0)/d,p=c.reduce((t,e)=>t+Math.pow(e[0]-g,2),0),y=null!==(W=e.confidence)&&void 0!==W?W:.95,m=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,v=null!==(I=e.steps)&&void 0!==I?I:5,b=c[d-1][0],k=(b-c[0][0])/Math.max(d-1,1),w=[];for(let t=1;v>=t;t++)w.push(b+t*k);const A=[];for(const t of w){const e=u(t),n=f*Math.sqrt(1+1/d+(p>0?Math.pow(t-g,2)/p:0))*m;A.push({x:t,yCenter:e,yUpper:e+n,yLower:e-n})}const S=`M${A.map(t=>`${a(t.x)},${l(t.yUpper)}`).join(" L")} L${A.slice().reverse().map(t=>`${a(t.x)},${l(t.yLower)}`).join(" L")} Z`,j=A.map(t=>`${a(t.x)},${l(t.yCenter)}`).join(" "),M=`${a(b)},${l(u(b))}`,_=e.strokeColor||"#6366f1";return t.jsxs("g",{children:[t.jsx("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:null!==(Y=e.fillOpacity)&&void 0!==Y?Y:.15,stroke:"none"}),t.jsx("polyline",{points:`${M} ${j}`,fill:"none",stroke:_,strokeWidth:null!==(H=e.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(G=e.strokeDasharray)&&void 0!==G?G:"6,3"}),e.label&&A.length>0&&t.jsx("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let i=null,r=null;if(null!=e.px&&null!=e.py)i=e.px,r=e.py;else{const t=No(e,n,o);if(!t)return null;i=t.x,r=t.y}if(null==i||null==r)return null;if(!Wo(i,r,o))return null;const s=null!==(q=e.dx)&&void 0!==q?q:0,a=null!==(X=e.dy)&&void 0!==X?X:0,l=null!==(V=e.width)&&void 0!==V?V:32,c=null!==(U=e.height)&&void 0!==U?U:32,u=null!==(Z=e.content)&&void 0!==Z?Z:t.jsx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return t.jsx("foreignObject",{x:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:t.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const i=No(e,n,o);if(!i)return null;const{x:r,y:s}=i;return t.jsx("text",{x:r+(e.dx||0),y:s+(e.dy||0),fill:e.color||"var(--semiotic-text, #333)",fontSize:e.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label},"ann-text-"+n)}case"category-highlight":{const i=e.category;if(null==i)return null;const r=null===(K=o.scales)||void 0===K?void 0:K.o,s=null===(Q=o.scales)||void 0===Q?void 0:Q.x,a=null===(J=o.scales)||void 0===J?void 0:J.y,l=(null==r?void 0:r.bandwidth)?r:(null==s?void 0:s.bandwidth)?s:(null==a?void 0:a.bandwidth)?a:null;if(!l)return null;const c=l(i);if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=null!==(tt=e.opacity)&&void 0!==tt?tt:.15,f=e.label;return t.jsxs("g",(o.projection?"vertical"===o.projection:l===s)?{children:[t.jsx("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[t.jsx("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:h}),f&&t.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:R,yAccessor:z,width:r,height:s,data:B,frameType:"xy",pointNodes:F,curve:N,stickyPositionCache:U.current};return E.map((t,o)=>{if(D){const i=D(t,o,n);return null!=i?i:e(t,o,n)}return e(t,o,n)}).filter(Boolean)},[E,D,r,s,R,z,B,h,F,N]),J=function(t){var n;const o=e.useSyncExternalStore(t?Uo:Ko,t?Vo:Qo,t?Vo:Qo);return t&&null!==(n=o.positions.get(t))&&void 0!==n?n:null}(Y);return e.useEffect(()=>{if(!(null==J?void 0:J.locked)||!Y)return;const t=t=>{"Escape"===t.key&&Xo(Y)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[null==J?void 0:J.locked,Y]),f||A||S||T||C||Q&&Q.length>0||w||G||J?t.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[t.jsx("title",{children:"string"==typeof A?A:"XY Chart"}),t.jsx("desc",{children:"string"==typeof A?A+" — XY data visualization":"XY data visualization"}),t.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[w&&h&&(!W||I)&&(()=>{var e,n;const o=ti(null===(e=null==g?void 0:g.find(t=>"bottom"===t.orient))||void 0===e?void 0:e.gridStyle),i=ti(null===(n=null==g?void 0:g.find(t=>"left"===t.orient))||void 0===n?void 0:n.gridStyle);return t.jsxs("g",{className:"stream-grid",children:[q.map((e,n)=>t.jsx("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),X.map((e,n)=>t.jsx("line",{x1:0,y1:e.pixel,x2:r,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),f&&h&&(()=>{const e=null==g?void 0:g.find(t=>"left"===t.orient),n=null==g?void 0:g.find(t=>"bottom"===t.orient),o=!e||!1!==e.baseline,i=!n||!1!==n.baseline,a=(null==e?void 0:e.jaggedBase)||!1,l=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==e?void 0:e.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!(null==n?void 0:n.autoRotate)&&q.length>1&&(()=>{const t=r/Math.max(q.length-1,1);return q.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})();return t.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(!W||I)&&i&&!l&&t.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:h,strokeWidth:1}),(!W||I)&&l&&t.jsx("path",{d:ei("bottom",r,s),fill:"none",stroke:h,strokeWidth:1}),q.map((e,n)=>{const o=!!c&&("function"==typeof c?c(e.value,n):Gn(e.value,n>0?q[n-1].value:void 0));return t.jsxs("g",{transform:`translate(${e.pixel},${s})`,children:[t.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{y:x?10:18,textAnchor:x?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},transform:x?"rotate(-45)":void 0,children:e.label}):t.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:e.label})})]},"xtick-"+n)}),p&&t.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:v,style:{userSelect:"none"},children:p}),(!W||I)&&o&&!a&&t.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:h,strokeWidth:1}),(!W||I)&&a&&t.jsx("path",{d:ei("left",r,s),fill:"none",stroke:h,strokeWidth:1}),X.map((e,n)=>{const o=!!u&&("function"==typeof u?u(e.value,n):Gn(e.value,n>0?X[n-1].value:void 0));return t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-"+n)}),(()=>{const n=(null==e?void 0:e.label)||y;return n?t.jsx("text",{x:15-d.left,y:s/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(-90, ${15-d.left}, ${s/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const e=null==g?void 0:g.find(t=>"right"===t.orient);if(!e||0===V.length)return null;const n=e.landmarkTicks,o=e.label||m;return t.jsxs(t.Fragment,{children:[!1!==e.baseline&&t.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:h,strokeWidth:1}),V.map((e,o)=>{const i=!!n&&("function"==typeof n?n(e.value,o):Gn(e.value,o>0?V[o-1].value:void 0));return t.jsxs("g",{transform:`translate(${r},${e.pixel})`,children:[t.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?t.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},children:e.label}):t.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:t.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:e.label})})]},"ytick-r-"+o)}),o&&t.jsx("text",{x:r+d.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:v,transform:`rotate(90, ${r+d.right-15}, ${s/2})`,style:{userSelect:"none"},children:o})]})})()]})})(),Q,C&&h&&L&&$&&t.jsxs(t.Fragment,{children:[C.top&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(To,{orient:"top",config:Oo(C.top),values:L,scale:h.x,size:d.top,length:r})}),C.bottom&&t.jsx("g",{transform:`translate(0, ${s})`,children:t.jsx(To,{orient:"bottom",config:Oo(C.bottom),values:L,scale:h.x,size:d.bottom,length:r})}),C.left&&t.jsx("g",{transform:"translate(0, 0)",children:t.jsx(To,{orient:"left",config:Oo(C.left),values:$,scale:h.y,size:d.left,length:s})}),C.right&&t.jsx("g",{transform:`translate(${r}, 0)`,children:t.jsx(To,{orient:"right",config:Oo(C.right),values:$,scale:h.y,size:d.right,length:s})})]}),T,J&&J.sourceId!==H&&(null==h?void 0:h.x)&&(()=>{const e=h.x(J.xValue);if(null==e||0>e||e>r)return null;const n=J.locked;return t.jsx("line",{x1:e,y1:0,x2:e,y2:s,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"})})(),G]}),A&&t.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof A?A:null}),Po({legend:S,totalWidth:a,totalHeight:l,margin:d,legendPosition:O,title:A,legendHoverBehavior:j,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:P})]}):null}const si="undefined"!=typeof window?e.useLayoutEffect:e.useEffect,ai=()=>()=>{},li=()=>!1,ci=()=>!0;function ui(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 di(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 hi(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 fi=m.createContext(null),gi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function pi(t,e){if(!t||0===t.length)return e+", empty";const n={};for(const e of t)n[e.type]=(n[e.type]||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 yi=t=>{if(null==t)return"";const e=Math.round(100*t)/100;return Number.isNaN(e)?"":e+""},mi={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"},vi={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},xi={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)"},bi={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ki={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)"},wi={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Ai={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Si({scene:e,chartType:n,tableId:o,chartTitle:i}){var r;const[s,a]=m.useState(!1),l=m.useContext(fi),c=null!==(r=null==l?void 0:l.visible)&&void 0!==r&&r,u=s||c,d=m.useRef(null),h=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n,f=m.useCallback(()=>{s||c||a(!0)},[s,c]),g=m.useCallback(t=>{var e;c||(null===(e=d.current)||void 0===e?void 0:e.contains(t.relatedTarget))||a(!1)},[c]);if(!e||0===e.length)return o?t.jsx("span",{id:o,tabIndex:-1,style:gi}):null;if(!u)return t.jsx("div",{id:o,tabIndex:-1,onFocus:f,style:gi,role:"region","aria-label":h,children:t.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," elements)"]})});const p=function(t){var e,n,o,i,r,s,a,l,c,u,d,h,f,g,p,y,m,v,x,b,k,w,A,S,j;const M=[];if(!Array.isArray(t))return M;for(const _ of t)if(_&&"object"==typeof _)try{switch(_.type){case"point":M.push({label:"Point",values:{x:_.x,y:_.y}});break;case"line":{const t=_.path,e=Array.isArray(_.datum)?_.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=_.topPath,e=Array.isArray(_.datum)?_.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!=_.datum&&"object"==typeof _.datum?_.datum:{},r=null!==(n=null!==(e=t.category)&&void 0!==e?e:_.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:_.x,y:_.y,value:_.value}});break;case"wedge":M.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=_.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=_.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=_.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=_.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=_.cx)&&void 0!==f?f:_.x,y:null!==(g=_.cy)&&void 0!==g?g:_.y}});break;case"arc":M.push({label:"Arc",values:{id:null!==(y=null===(p=_.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=_.cx)&&void 0!==m?m:_.x,y:null!==(v=_.cy)&&void 0!==v?v:_.y}});break;case"candlestick":M.push({label:"Candlestick",values:{x:_.x,open:_.open,high:_.high,low:_.low,close:_.close}});break;case"geoarea":M.push({label:"Region",values:{name:null!==(A=null!==(k=null===(b=null===(x=_.datum)||void 0===x?void 0:x.properties)||void 0===b?void 0:b.name)&&void 0!==k?k:null===(w=_.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(j=null===(S=_.datum)||void 0===S?void 0:S.value)&&void 0!==j?j:""}})}}catch(t){}return M}(e),y=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}(p),v=function(t,e){const n=[t+" data points."];for(const t of e)if(t.numeric)n.push(`${t.name}: ${yi(t.min)} to ${yi(t.max)}, mean ${yi(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(" ")}(p.length,y),x=p.slice(0,5),b=new Set;for(const t of x)for(const e of Object.keys(t.values))b.add(e);const k=Array.from(b);return t.jsxs("div",{ref:d,id:o,tabIndex:-1,onBlur:g,style:mi,role:"region","aria-label":h,children:[t.jsx("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:xi,children:"×"}),t.jsx("div",{role:"note",style:vi,children:v}),t.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:bi,children:[t.jsxs("caption",{style:Ai,children:["First ",x.length," of ",p.length," data points"]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{style:ki,children:"type"}),k.map(e=>t.jsx("th",{style:ki,children:e},e))]})}),t.jsx("tbody",{children:x.map((e,n)=>t.jsxs("tr",{children:[t.jsx("td",{style:wi,children:e.label}),k.map(n=>{return t.jsx("td",{style:wi,children:(o=e.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":yi(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]})]})}function ji({summary:e}){return e?t.jsx("div",{role:"note",style:gi,children:e}):null}function Mi({tableId:e}){return t.jsx("a",{href:"#"+e,style:gi,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,gi)},children:"Skip to data table"})}function _i({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.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:gi,children:n})}const Pi="var(--semiotic-focus, #005fcc)";function Oi({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.jsx("rect",{x:l-e/2-3,y:c-n/2-3,width:e+6,height:n+6,rx:3,fill:"none",stroke:Pi,strokeWidth:2,strokeDasharray:"4,2"})}else u=t.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Pi,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Pi,strokeWidth:2,strokeDasharray:"4,2"});return t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function Ti({x:e,y:n,containerWidth:o,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(e)&&Number.isFinite(n),u=m.useRef(null),[d,h]=m.useState(null);m.useLayoutEffect(()=>{const t=u.current;if(!t)return;const e=t.getBoundingClientRect();h(t=>t&&t.width===e.width&&t.height===e.height?t:{width:e.width,height:e.height})},[s,a,o,i]);let f;f=d?`translate(${d.width+12>o-e?"calc(-100% - 12px)":"12px"}, ${d.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const g=function(t){if(!m.isValidElement(t))return!1;const e=t.props;if("string"==typeof e.className&&e.className.trim().length>0)return!0;const n=e.style;if(n&&"object"==typeof n){if(null!=n.background&&""!==n.background)return!0;if(null!=n.backgroundColor&&""!==n.backgroundColor)return!0}return!1}(s),p=g?null:$n;return c?t.jsx("div",{ref:u,className:g?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},p||{}),{position:"absolute",left:r.left+e,top:r.top+n,transform:f,pointerEvents:"none",zIndex:l,width:"max-content"}),children:s}):null}const Ci="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function Li(t,e,n){return"function"==typeof t?t({size:e,margin:n}):t}function $i(t){const n=function(){const[t,n]=e.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return e.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(prefers-reduced-motion: reduce)");return n(t.matches),function(t,e){return"function"==typeof t.addEventListener?(t.addEventListener("change",e),()=>t.removeEventListener("change",e)):(t.addListener(e),()=>t.removeListener(e))}(t,t=>n(t.matches))},[]),t}(),o=e.useRef(n);o.current=n;const[i,r]=function(t,n,o){const i=e.useRef(null),[r,s]=e.useState(null);return e.useEffect(()=>{if(!n&&!o)return;const t=i.current;if(!t)return;const e=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 e.observe(t),()=>e.disconnect()},[n,o]),[i,[n&&r?r.w:t[0],o&&r?r.h:t[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),s=e.useMemo(()=>Object.assign(Object.assign({},t.marginDefault),t.userMargin),[t.marginDefault,t.userMargin]),a=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,c=Li(t.foregroundGraphics,r,s),u=Li(t.backgroundGraphics,r,s),d=ln(t=>t.theme),{transition:h,introEnabled:f}=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),g="semiotic-table-"+m.useId(),p=e.useRef(0),y=e.useRef(()=>{}),v=e.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>y.current()))},[]);e.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const x=e.useRef(()=>{}),b=e.useRef(()=>{}),k=e.useRef(null),w=e.useRef(0),A=e.useCallback(()=>{w.current=0;const t=k.current;k.current=null,t&&x.current(t)},[]),S=e.useCallback(t=>{k.current={clientX:t.clientX,clientY:t.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),j=e.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),b.current()},[]);e.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const M=t.themeDirtyRef;return Ci(()=>{M&&(Vn++,M.current=!0,v())},[d,v,M]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:p,renderFnRef:y,scheduleRender:v,hoverHandlerRef:x,hoverLeaveRef:b,onPointerMove:S,onPointerLeave:j}}function Ei(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 Di(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 Ri(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 zi=(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 u=a.style.stroke||"#007bff",d=Jn(t,u)||u,h=a.style.strokeWidth||2,f=a.colorThresholds,g=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=h,t.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const v=null!==(i=a.style.opacity)&&void 0!==i?i:1;Ri(t,a.path,d,h,v,a.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const p=to(a.curve),y=f&&f.length>0&&g&&g.length===a.path.length,m=a._decayOpacities;if(m&&m.length===a.path.length&&!y){t.strokeStyle=d;const x=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let b=0;a.path.length-1>b;b++)t.globalAlpha=.5*(m[b]+m[b+1])*x,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(y){let k=null,w=null,A=null,S=null,j=!1;function M(e,n,o){t.beginPath(),t.strokeStyle=e,t.moveTo(n,o),j=!0}function _(){j&&(t.stroke(),j=!1)}for(let P=0;a.path.length>P;P++){const[O,T]=a.path[P],C=g[P],L=Di(C,f,d);if(null!==k&&null!==S&&null!==A){if(L===S)t.lineTo(O,T);else{const $=[];for(const E of f){const D=E.value;(A>D||D>C)&&(D>A||C>D)||A===D||C===D||$.push({t:(D-A)/(C-A)})}$.sort((t,e)=>t.t-e.t);for(const R of $){const z=k+(O-k)*R.t,B=w+(T-w)*R.t,F=Di(A+(C-A)*Math.min(R.t+1e-4,1),f,d);t.lineTo(z,B),_(),M(F,z,B)}t.lineTo(O,T)}k=O,w=T,A=C,S=L}else M(L,O,T),k=O,w=T,A=C,S=L}_()}else{t.beginPath();const N=a.strokeGradient&&a.path.length>=2?oo(t,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(t.strokeStyle=N||d,p)c.line().x(t=>t[0]).y(t=>t[1]).curve(p).context(t)(a.path);else{const[W,I]=a.path[0];t.moveTo(W,I);for(let Y=1;a.path.length>Y;Y++)t.lineTo(a.path[Y][0],a.path[Y][1])}t.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=a.style.fillOpacity,t.fillStyle=eo(t,a.style.fill,a.style.fill),p&&!y)c.line().x(t=>t[0]).y(t=>t[1]).curve(p).context(t)(a.path);else{const[G,q]=a.path[0];t.moveTo(G,q);for(let X=1;a.path.length>X;X++)t.lineTo(a.path[X][0],a.path[X][1])}const H=a.path[0][0];t.lineTo(a.path[a.path.length-1][0],o.height),t.lineTo(H,o.height),t.closePath(),t.fill()}void 0!==l&&1>l&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Bi(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function Fi(t,e,n=.3){Bi(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 Ni(t,e,n=.6){var o,i,r,s,a;if(!Bi(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 Wi(t,e,n,o=.35){Bi(e)&&(t.globalAlpha=e._pulseIntensity*o,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fill())}function Ii(t,e){const n=to(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=c.area().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 Yi=(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=eo(t,e.style.fill,"#4e79a7"),u=e._decayOpacities;if(u&&u.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*(u[o]+u[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=Jn(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*(u[n]+u[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 d=null!==(r=e.style.opacity)&&void 0!==r?r:1;if(Ii(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=no(t,e.fillGradient,"string"==typeof l?l:"#4e79a7",0,n,0,o);t.fillStyle=i||l,t.globalAlpha=d}else{const n=null!==(s=e.style.fillOpacity)&&void 0!==s?s:.7;t.globalAlpha=n*d,t.fillStyle=l}if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Ii(t,e),Wi(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=d;const n=e.strokeGradient&&e.topPath.length>=2?oo(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=n||Jn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=to(e.curve);if(t.beginPath(),o)c.line().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}},Hi=(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=eo(t,e.style.fill,"#4e79a7"),t.fill(),e.style.stroke&&(t.strokeStyle=eo(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth||1,t.stroke()),Ni(t,e),t.globalAlpha=1}}finally{t.restore()}}};function Gi(t,e){const{x:n,y:o,w:i,h:r}=e,{tl:s,tr:a,br:l,bl:c}=Ge(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 qi(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 Xi=(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)Vi(t,e);else if(e.cornerRadii&&He(e.cornerRadii)){const n=eo(t,e.style.fill,Jn(t,"var(--semiotic-primary, #007bff)")),o=qi(e),i=e.fillGradient&&"string"==typeof n?no(t,e.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;t.fillStyle=i||n,Gi(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Jn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const n=eo(t,e.style.fill,Jn(t,"var(--semiotic-primary, #007bff)")),o=qi(e),i=e.fillGradient&&"string"==typeof n?no(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=Jn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const n=eo(t,e.style.fill,Jn(t,"var(--semiotic-primary, #007bff)")),o=qi(e),i=e.fillGradient&&"string"==typeof n?no(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=Jn(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}Fi(t,e),t.globalAlpha=1}};function Vi(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 Ui(t,e,n,o){return Object.assign({data:t,x:e,y:n,__semioticHoverData:!0},o)}function Zi(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 Ki(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}const Qi=(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=Jn(t,"var(--semiotic-surface, #fff)"),t.lineWidth=1,t.strokeRect(e.x,e.y,e.w,e.h),Fi(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):Ki(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=Zi(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(n,i,r)}}}finally{t.restore()}},Ji=(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=Jn(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=Jn(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 tr(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 er=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function nr(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`${er[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*n>e?t=>{const e=new Date(t);return`${er[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}const or={line:[Yi,zi,Hi],area:[Yi,Hi],stackedarea:[Yi,Hi],scatter:[Hi],bubble:[Hi],heatmap:[Qi],bar:[Xi],swarm:[Hi],waterfall:[(t,e,n,o)=>{var i,r,s;Xi(t,e);const a=e.filter(t=>"rect"===t.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){t.save(),t.strokeStyle=Jn(t,c)||c,t.lineWidth=null!==(i=null==l?void 0:l._connectorWidth)&&void 0!==i?i:1,t.setLineDash([]);for(let e=0;a.length-1>e;e++){const o=a[e],i=a[e+1];if(!(null===(r=o.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=i.datum)||void 0===s?void 0:s.baseline))continue;const l=n.y(o.datum.cumEnd),c=o.x+o.w,u=i.x;t.beginPath(),t.moveTo(c,l),t.lineTo(u,l),t.stroke()}t.restore()}}],candlestick:[Ji],mixed:[Yi,zi,Hi],custom:[Yi,Xi,Qi,zi,Hi,Ji]},ir={top:20,right:20,bottom:30,left:40},rr={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 sr(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 ar={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 lr({hover:e}){var n,o,i;const r=t=>null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+"",s=null!==(n=e.data)&&void 0!==n?n:{},a=null!==(o=s.y)&&void 0!==o?o:s.value,l=null!==(i=s.x)&&void 0!==i?i:s.time;return t.jsxs("div",{className:"semiotic-tooltip",style:ar,children:[t.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(a)}),t.jsx("div",{style:{opacity:.7,fontSize:11},children:r(l)})]})}const cr=e.forwardRef(function(n,o){var i,r,s,a,l,c,u,d,h,f,g,p,y;const{chartType:v,runtimeMode:x,data:b,chunkThreshold:k,chunkSize:w,xAccessor:A,yAccessor:S,colorAccessor:j,sizeAccessor:M,groupAccessor:_,lineDataAccessor:P,curve:O,normalize:T,baseline:C,stackOrder:L,binSize:$,valueAccessor:E,arrowOfTime:D="right",windowMode:R="sliding",windowSize:z=200,timeAccessor:B,xExtent:F,yExtent:N,extentPadding:W=.1,scalePadding:I,sizeRange:Y,size:H=[500,300],responsiveWidth:G,responsiveHeight:q,margin:X,className:V,background:U,lineStyle:Z,pointStyle:K,areaStyle:Q,barStyle:J,waterfallStyle:tt,swarmStyle:et,barColors:nt,colorScheme:ot,boundsAccessor:it,boundsStyle:rt,y0Accessor:st,gradientFill:at,lineGradient:lt,areaGroups:ct,openAccessor:ut,highAccessor:dt,lowAccessor:ht,closeAccessor:gt,candlestickStyle:pt,showAxes:yt=!0,axes:mt,xLabel:vt,yLabel:xt,yLabelRight:bt,xFormat:kt,yFormat:wt,axisExtent:At,tickFormatTime:St,tickFormatValue:jt,hoverAnnotation:Mt,tooltipContent:_t,customHoverBehavior:Pt,customClickBehavior:Ot,enableHover:Tt,hoverRadius:Ct=30,tooltipMode:Lt,annotations:$t,svgAnnotationRules:Et,showGrid:Dt,legend:Rt,legendHoverBehavior:zt,legendClickBehavior:Bt,legendHighlightedCategory:Ft,legendIsolatedCategories:Nt,legendPosition:Wt,legendCategoryAccessor:It,onCategoriesChange:Yt,backgroundGraphics:Ht,foregroundGraphics:Gt,canvasPreRenderers:qt,svgPreRenderers:Xt,title:Vt,categoryAccessor:Ut,brush:Zt,onBrush:Kt,decay:Qt,pulse:Jt,transition:te,animate:ee,staleness:ne,heatmapAggregation:oe,heatmapXBins:ie,heatmapYBins:re,showValues:se,heatmapValueFormat:ae,marginalGraphics:le,pointIdAccessor:ce,xScaleType:ue,yScaleType:de,accessibleTable:he=!0,description:fe,summary:ge,linkedCrosshairName:pe,linkedCrosshairSourceId:ye,customLayout:me,layoutConfig:ve}=n,xe=e.useId().replace(/:/g,""),be=e.useRef(!1),ke=$i({sizeProp:H,responsiveWidth:G,responsiveHeight:q,userMargin:X,marginDefault:ir,animate:ee,transitionProp:te,themeDirtyRef:be}),we=function(){const[t,n]=e.useState(!1);return si(()=>{n(!0)},[]),t}(),Ae=function(){const t=e.useSyncExternalStore(ai,li,ci);return e.useRef(t).current}(),{reducedMotionRef:Se,responsiveRef:je,size:Me,currentTheme:_e,transition:Pe,introEnabled:Oe,tableId:Te,rafRef:Ce,renderFnRef:Le,scheduleRender:$e}=ke;let Ee=ke.margin;if(le){const t=60,e=Object.assign({},ke.margin);le.top&&t>e.top&&(e.top=t),le.bottom&&t>e.bottom&&(e.bottom=t),le.left&&t>e.left&&(e.left=t),le.right&&t>e.right&&(e.right=t),Ee=e}const De="function"==typeof Gt?Gt({size:Me,margin:Ee}):Gt,Re="function"==typeof Ht?Ht({size:Me,margin:Ee}):Ht,ze=Me[0]-Ee.left-Ee.right,Be=Me[1]-Ee.top-Ee.bottom,Fe=e.useMemo(()=>Ln(b),[b]),Ne=null!=Mt?Mt:Tt,We=e.useRef(null),Ie=e.useRef(null),[Ye,He]=e.useState(0),[Ge,qe]=e.useState(null),Xe=e.useRef(null),Ue=e.useRef(null),[Ke,Qe]=e.useState(null),tn=e.useRef(rr.primary),en=e.useRef([]),nn=e.useRef(It),on=e.useRef(Yt);nn.current=It,on.current=Yt;const[rn,sn]=e.useState(!1),[an,ln]=e.useState([]),[cn,un]=e.useState([]),dn="streaming"===x||["bar","swarm","waterfall"].includes(v),hn=e.useMemo(()=>{var t,e,n;return{chartType:v,runtimeMode:dn?"streaming":"bounded",windowSize:z,windowMode:R,arrowOfTime:dn?D:"right",extentPadding:W,scalePadding:I,axisExtent:At,xAccessor:A,yAccessor:S,timeAccessor:dn?B:void 0,valueAccessor:E,colorAccessor:j,sizeAccessor:M,groupAccessor:_||(P?"_lineGroup":void 0),categoryAccessor:Ut,lineDataAccessor:P,xScaleType:ue,yScaleType:de,xExtent:F,yExtent:N,sizeRange:Y,binSize:$,normalize:T,baseline:C,stackOrder:L,boundsAccessor:it,boundsStyle:rt,y0Accessor:st,gradientFill:!0===at?{topOpacity:.8,bottomOpacity:.05}:!1===at?void 0:at,areaGroups:ct?new Set(ct):void 0,lineGradient:lt,openAccessor:ut,highAccessor:dt,lowAccessor:ht,closeAccessor:gt,candlestickStyle:pt,lineStyle:Z,pointStyle:K,areaStyle:Q,swarmStyle:et,waterfallStyle:tt,colorScheme:ot,barColors:nt,barStyle:J,annotations:$t,decay:Qt,pulse:Jt,transition:Pe,introAnimation:Oe,staleness:ne,heatmapAggregation:oe,heatmapXBins:ie,heatmapYBins:re,showValues:se,heatmapValueFormat:ae,pointIdAccessor:ce,curve:O,themeCategorical:null===(t=null==_e?void 0:_e.colors)||void 0===t?void 0:t.categorical,themeSemantic:Je(_e),themeSequential:null===(e=null==_e?void 0:_e.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(n=null==_e?void 0:_e.colors)||void 0===n?void 0:n.diverging,customLayout:me,layoutConfig:ve,layoutMargin:Ee}},[v,z,R,D,W,I,At,A,S,B,E,ue,de,j,M,_,Ut,P,F,N,Y,$,T,C,L,it,rt,st,at,lt,ct,ut,dt,ht,gt,pt,Z,K,Q,et,tt,J,ot,nt,$t,Qt,Jt,null==Pe?void 0:Pe.duration,null==Pe?void 0:Pe.easing,Oe,ne,oe,ie,re,se,ae,dn,ce,O,_e,me,ve,Ee]),fn=function(t){const n=e.useRef(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return di(t,e);if(!hi(t)||!hi(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(!di(n,i))return!1}else{if(!hi(n)||!hi(i))return!1;if(!ui(n,i))return!1}}return!0}(n.current,t)||(n.current=t),n.current}(hn),gn=e.useRef(null);gn.current||(gn.current=new ft(fn));const pn=e.useCallback(()=>{var t,e;const n=nn.current,o=on.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=gn.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,en.current)||(en.current=i,o(i))},[]);e.useEffect(()=>{var t;null===(t=gn.current)||void 0===t||t.updateConfig(fn),be.current=!0,$e()},[fn,$e]);const yn=e.useRef(null);yn.current||(yn.current=new Nn(t=>{const e=gn.current;e&&e.ingest(t)&&(be.current=!0,$e())},{chunkThreshold:k,chunkSize:w})),e.useEffect(()=>{var t;null===(t=yn.current)||void 0===t||t.updateChunkOptions({chunkThreshold:k,chunkSize:w})},[k,w]);const mn=e.useCallback(t=>{var e;null===(e=yn.current)||void 0===e||e.push(t)},[]),vn=e.useCallback(t=>{var e;null===(e=yn.current)||void 0===e||e.pushMany(t)},[]),xn=e.useCallback(()=>{var t,e;null===(t=yn.current)||void 0===t||t.clear(),null===(e=gn.current)||void 0===e||e.clear(),be.current=!0,$e()},[$e]);e.useImperativeHandle(o,()=>({push:mn,pushMany:vn,remove:t=>{var e,n,o;null===(e=yn.current)||void 0===e||e.flush();const i=null!==(o=null===(n=gn.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[];return i.length>0&&(Xe.current&&i.some(t=>{var e;return t===(null===(e=Xe.current)||void 0===e?void 0:e.data)})&&(Xe.current=null,Qe(null)),be.current=!0,$e()),i},update:(t,e)=>{var n,o,i;null===(n=yn.current)||void 0===n||n.flush();const r=null!==(i=null===(o=gn.current)||void 0===o?void 0:o.update(t,e))&&void 0!==i?i:[];return r.length>0&&(be.current=!0,$e()),r},clear:xn,getData:()=>{var t,e,n;return null===(t=yn.current)||void 0===t||t.flush(),null!==(n=null===(e=gn.current)||void 0===e?void 0:e.getData())&&void 0!==n?n:[]},getScales:()=>{var t,e;return null!==(e=null===(t=gn.current)||void 0===t?void 0:t.scales)&&void 0!==e?e:null},getExtents:()=>{var t,e;return null!==(e=null===(t=gn.current)||void 0===t?void 0:t.getExtents())&&void 0!==e?e:null}}),[mn,vn,xn,$e]),e.useEffect(()=>{var t,e;if(b){if(P&&Fe.length>0&&"object"==typeof Fe[0]&&null!==Fe[0]){const e="string"==typeof P?P:"coordinates";if(Array.isArray(Fe[0][e])){const n=[];for(const t of Fe){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=yn.current)||void 0===t||t.setBoundedData(n))}}null===(e=yn.current)||void 0===e||e.setBoundedData(Fe)}},[b,Fe,P]);const{hoverHandlerRef:bn,hoverLeaveRef:kn,onPointerMove:wn,onPointerLeave:An}=ke;bn.current=t=>{var e,n,o;if(!Ne)return;const i=We.current;if(!i)return;const r=i.getBoundingClientRect(),s=t.clientX-r.left-Ee.left,a=t.clientY-r.top-Ee.top;if(0>s||s>ze||0>a||a>Be)return void(Xe.current&&(Xe.current=null,Ue.current=null,Qe(null),Pt&&(Pt(null),be.current=!0),$e()));const l=gn.current;if(!l||0===l.scene.length)return;const c=so(l.scene,s,a,Ct,l.quadtree,l.maxPointRadius),u="multi"===Lt,d=()=>{Xe.current&&(Xe.current=null,Ue.current=null,Qe(null),Pt&&Pt(null),$e())};if(!c&&!u)return void d();const h=u||!c?s:c.x,f=u||!c?a:c.y;let g=Ui(null!==(e=null==c?void 0:c.datum)&&void 0!==e?e:{},h,f);if(u&&l.scene.length>0&&l.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=ao(ro(t.path,t.curve),e,n);if(null===r)continue;const s=yo(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=ro(t.topPath,t.curve),s=ro(t.bottomPath,t.curve),a=ao(r,e,n);if(null===a)continue;const l=ao(s,e,n),c=yo(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}(l.scene,h,Math.max(Ct,ze));if(t.length>0){const e=l.scales.y.invert,n=l.scales.x.invert,o=tn.current,i=n?n(h):h;if(c)g.xValue=i,g.xPx=h;else{const t={xValue:i};"string"==typeof A&&(t[A]=i),g=Ui(t,h,f,{xValue:i,xPx:h})}g.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"===v&&null!=i?n-i:n,valuePx:t.y,color:t.color||o,datum:t.datum}})}}c||(null===(n=g.allSeries)||void 0===n?void 0:n.length)?(Xe.current=g,Ue.current=null!==(o=null==c?void 0:c.node)&&void 0!==o?o:null,Qe(g),Pt&&(Pt(g),be.current=!0),$e()):d()},kn.current=()=>{Xe.current&&(Xe.current=null,Ue.current=null,Qe(null),Pt&&(Pt(null),be.current=!0),$e())};const Sn=e.useRef(()=>{});Sn.current=t=>{if(!Ot)return;const e=We.current;if(!e)return;const n=e.getBoundingClientRect(),o=t.clientX-n.left-Ee.left,i=t.clientY-n.top-Ee.top;if(0>o||o>ze||0>i||i>Be)return void Ot(null);const r=gn.current;if(!r||0===r.scene.length)return void Ot(null);const s=so(r.scene,o,i,Ct,r.quadtree,r.maxPointRadius);Ot(s?Ui(s.datum||{},s.x,s.y):null)};const jn=e.useCallback(t=>Sn.current(t),[]),Mn=e.useRef(-1),_n=e.useRef(null),Pn=e.useRef(null),On=e.useCallback(t=>{const e=gn.current;if(!e||0===e.scene.length)return;const n=e.version;let o;if(Pn.current&&Pn.current.version===n)o=Pn.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),Pn.current={version:n,graph:o}}const i=Mn.current;if(0>i){if("Escape"===t.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key))return;t.preventDefault(),Mn.current=0;const e=o.flat[0];_n.current={shape:e.shape,w:e.w,h:e.h};const n=vo(e);return Xe.current=n,Qe(n),Pt&&Pt(n),void $e()}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?mo(n,n.groups[t+1],r[i]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(o);return t>0?mo(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 Mn.current=-1,_n.current=null,Xe.current=null,Ue.current=null,Qe(null),Pt&&Pt(null),void $e();Mn.current=s;const a=o.flat[s];_n.current={shape:a.shape,w:a.w,h:a.h};const l=vo(a);Xe.current=l,Qe(l),Pt&&Pt(l),$e()},[Pt,$e]),Tn=e.useCallback(t=>{Mn.current=-1,_n.current=null,wn(t)},[wn]);Le.current=()=>{var t,e;Ce.current=0;const n=We.current,o=Ie.current;if(!n||!o)return;const i=gn.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(Se.current?r+1e6:r),a=!Se.current&&s,l=be.current||s;l&&!a&&(i.computeScene({width:ze,height:Be}),pn());const c="undefined"!=typeof window&&window.devicePixelRatio||1,u=function(t){if(!t)return rr;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||rr.axisStroke,tickText:s||rr.tickText,crosshair:s?sr(s,"66"):rr.crosshair,hoverFill:c?sr(c,"4D"):rr.hoverFill,hoverStroke:s?sr(s,"99"):rr.hoverStroke,pointRing:c||rr.pointRing,primary:r||rr.primary}:rr}(n);tn.current=u.primary;const d=null!==(t=null==ne?void 0:ne.threshold)&&void 0!==t?t:5e3,h=ne&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const t=Ei(n,Me,Ee,c);if(t){if(t.clearRect(-Ee.left,-Ee.top,Me[0],Me[1]),h&&(t.globalAlpha=null!==(e=null==ne?void 0:ne.dimOpacity)&&void 0!==e?e:.5),"transparent"!==U&&!Ht){const e=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=U||(e&&"transparent"!==e?e:null),i=o?Jn(t,o):null;i&&(t.fillStyle=i,t.fillRect(-Ee.left,-Ee.top,Me[0],Me[1]))}if(t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,ze,Be),t.clip()),qt&&i.scales)for(const e of qt)t.save(),e(t,i.scene,i.scales,{width:ze,height:Be}),t.restore();const o=me?or.custom:or[v];if(o&&i.scales)for(const e of o)e(t,i.scene,i.scales,{width:ze,height:Be});t.restore(),h&&(t.globalAlpha=1)}}{const t=Ei(o,Me,Ee,c);if(t&&(t.clearRect(-Ee.left,-Ee.top,Me[0],Me[1]),Ne&&Xe.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,Xe.current,ze,Be,"object"==typeof Ne?Ne:{},Ue.current,u),Ue.current&&Array.isArray(Mt))){const e=Mt.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,n,o,i){var r;if(!n)return;const s=n.group;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,Ue.current,e,u)}}l&&n&&n.setAttribute("aria-label",pi(i.scene,v+" chart"));const f=be.current;if(be.current=!1,f&&i.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!Ge||t(Ge.x.domain()[0])!==t(i.scales.x.domain()[0])||t(Ge.x.domain()[1])!==t(i.scales.x.domain()[1])||t(Ge.y.domain()[0])!==t(i.scales.y.domain()[0])||t(Ge.y.domain()[1])!==t(i.scales.y.domain()[1])||Ge.x.range()[0]!==i.scales.x.range()[0]||Ge.x.range()[1]!==i.scales.x.range()[1]||Ge.y.range()[0]!==i.scales.y.range()[0]||Ge.y.range()[1]!==i.scales.y.range()[1])&&qe(i.scales),le){const t=i.getData(),e="function"==typeof A?A:t=>t[A||"x"],n="function"==typeof S?S:t=>t[S||"y"];ln(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),un(t.map(t=>n(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}f&&$t&&$t.length>0&&He(t=>t+1),(null==ne?void 0:ne.showBadge)&&sn(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Ce.current=requestAnimationFrame(()=>Le.current()))},function(t){const{hydrated:n,wasHydratingFromSSR:o,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=t;si(()=>{var t,e;n&&o&&(null===(e=null===(t=i.current)||void 0===t?void 0:t.cancelIntroAnimation)||void 0===e||e.call(t)),r.current=!0,s.current()},[n,o]);const l=e.useRef(a);l.current=a,e.useEffect(()=>()=>{var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)},[])}({hydrated:we,wasHydratingFromSSR:Ae,storeRef:gn,dirtyRef:be,renderFnRef:Le,cleanup:()=>{var t;return null===(t=yn.current)||void 0===t?void 0:t.clear()}}),e.useEffect(()=>{be.current=!0,$e()},[v,ze,Be,yt,U,Z,qt,$e]),function(t,n,o,i,r,s){e.useEffect(()=>{if(!t)return;const e=setInterval(()=>{var e;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(e=t.threshold)&&void 0!==e?e:5e3,u=l-a.lastIngestTime>c;u!==r&&(s(u),o.current=!0,i())},1e3);return()=>clearInterval(e)},[t,r,i])}(ne,gn,be,$e,rn,sn);const Cn=e.useMemo(()=>{if(kt||St)return;const t=gn.current;return(null==t?void 0:t.xIsDate)&&Ge?nr(Ge.x.domain()):void 0},[kt,St,Ge]),$n=kt||St||Cn,En=Ne&&Ke?_t?_t(Ke):t.jsx(lr,{hover:Ke}):null,Dn=En?t.jsx(Ti,{x:Ke.x,y:Ke.y,containerWidth:ze,containerHeight:Be,margin:Ee,className:"stream-frame-tooltip",children:En}):null,Rn=_n.current,zn=t.jsx(Oi,{active:Mn.current>=0,hoverPoint:Ke,margin:Ee,size:Me,shape:null==Rn?void 0:Rn.shape,width:null==Rn?void 0:Rn.w,height:null==Rn?void 0:Rn.h}),Bn=tr(A,B,"__semiotic_resolvedX","__semiotic_resolvedTime"),In=tr(S,E,"__semiotic_resolvedY","__semiotic_resolvedValue"),Yn=Bn.key,Hn=In.key,Gn=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}}(Bn,In,$t&&$t.length>0||!1);if(Ze||!we&&Ae){const e=gn.current;e&&b&&(e.ingest({inserts:Fe,bounded:!0}),e.computeScene({width:ze,height:Be}));const n=null!==(i=null==e?void 0:e.scene)&&void 0!==i?i:[],o=null!==(r=null==e?void 0:e.scales)&&void 0!==r?r:null,a=$n||(()=>{if((null==e?void 0:e.xIsDate)&&o)return nr(o.x.domain())})();return t.jsxs("div",{ref:je,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":fe||("string"==typeof Vt?Vt:"XY chart"),style:{position:"relative",width:G?"100%":Me[0],height:q?"100%":Me[1]},children:[t.jsx(ji,{summary:ge}),t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Me[0],height:Me[1],style:{position:"absolute",left:0,top:0},children:[t.jsx("g",{transform:`translate(${Ee.left},${Ee.top})`,children:Re}),t.jsxs("g",{transform:`translate(${Ee.left},${Ee.top})`,children:[U&&t.jsx("rect",{x:0,y:0,width:ze,height:Be,fill:U}),Xt&&o&&Xt.map((e,i)=>t.jsx(m.Fragment,{children:e(n,o,{width:ze,height:Be})},"svgpre-"+i)),n.map((t,e)=>Ve(t,e,xe)).filter(Boolean)]})]}),t.jsx(ri,{width:ze,height:Be,totalWidth:Me[0],totalHeight:Me[1],margin:Ee,scales:o,showAxes:yt,axes:mt,xLabel:vt,yLabel:xt,yLabelRight:bt,xFormat:a,yFormat:wt||jt,axisExtent:At,showGrid:Dt,title:Vt,legend:Rt,legendHoverBehavior:zt,legendClickBehavior:Bt,legendHighlightedCategory:Ft,legendIsolatedCategories:Nt,legendPosition:Wt,foregroundGraphics:Wn(De,null===(s=gn.current)||void 0===s?void 0:s.customLayoutOverlays),marginalGraphics:le,xValues:[],yValues:[],annotations:$t,svgAnnotationRules:Et,annotationFrame:0,xAccessor:Yn,yAccessor:Hn,annotationData:Gn(null==e?void 0:e.getData()),pointNodes:null==e?void 0:e.scene.filter(t=>"point"===t.type),curve:"string"==typeof O?O:void 0,linkedCrosshairName:pe,linkedCrosshairSourceId:ye})]})}return t.jsxs("div",{ref:je,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":fe||("string"==typeof Vt?Vt:"XY chart"),tabIndex:0,style:{position:"relative",width:G?"100%":Me[0],height:q?"100%":Me[1],overflow:"visible"},onKeyDown:On,children:[he&&t.jsx(Mi,{tableId:Te}),he&&t.jsx(Si,{scene:null!==(l=null===(a=gn.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:v+" chart",tableId:Te,chartTitle:"string"==typeof Vt?Vt:void 0}),t.jsx(ji,{summary:ge}),t.jsxs("div",{role:"img","aria-label":fe||("string"==typeof Vt?Vt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ne?Tn:void 0,onMouseLeave:Ne?An:void 0,onClick:Ot?jn:void 0,children:[Re&&t.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Me[0],height:Me[1],pointerEvents:"none"},children:t.jsx("g",{transform:`translate(${Ee.left},${Ee.top})`,children:Re})}),t.jsx(ni,{width:ze,height:Be,totalWidth:Me[0],totalHeight:Me[1],margin:Ee,scales:Ge,showAxes:yt,axes:mt,showGrid:Dt,xFormat:$n,yFormat:wt||jt,axisExtent:At}),t.jsx("canvas",{ref:We,"aria-label":pi(null!==(u=null===(c=gn.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],v+" chart"),style:{position:"absolute",left:0,top:0}}),t.jsx("canvas",{ref:Ie,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),t.jsx(_i,{hoverPoint:Ke}),t.jsx(ri,{width:ze,height:Be,totalWidth:Me[0],totalHeight:Me[1],margin:Ee,scales:Ge,showAxes:yt,axes:mt,xLabel:vt,yLabel:xt,yLabelRight:bt,xFormat:$n,yFormat:wt||jt,axisExtent:At,showGrid:Dt,title:Vt,legend:Rt,legendHoverBehavior:zt,legendClickBehavior:Bt,legendHighlightedCategory:Ft,legendIsolatedCategories:Nt,legendPosition:Wt,foregroundGraphics:Wn(De,null===(d=gn.current)||void 0===d?void 0:d.customLayoutOverlays),marginalGraphics:le,xValues:an,yValues:cn,annotations:$t,svgAnnotationRules:Et,annotationFrame:Ye,xAccessor:Yn,yAccessor:Hn,annotationData:Gn(null===(h=gn.current)||void 0===h?void 0:h.getData()),pointNodes:null===(f=gn.current)||void 0===f?void 0:f.scene.filter(t=>"point"===t.type),curve:"string"==typeof O?O:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==U&&!Ht,linkedCrosshairName:pe,linkedCrosshairSourceId:ye}),(Zt||Kt)&&t.jsx(Fn,{width:ze,height:Be,totalWidth:Me[0],totalHeight:Me[1],margin:Ee,dimension:null!==(g=null==Zt?void 0:Zt.dimension)&&void 0!==g?g:"xy",scales:Ge,onBrush:null!=Kt?Kt:()=>{},binSize:$,snap:null==Zt?void 0:Zt.snap,binBoundaries:null!==(p=null==Zt?void 0:Zt.binBoundaries)&&void 0!==p?p:"bar"===v?null===(y=gn.current)||void 0===y?void 0:y.getBinBoundaries():void 0,snapDuring:null==Zt?void 0:Zt.snapDuring,streaming:"streaming"===x}),(null==ne?void 0:ne.showBadge)&&t.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ne.badgePosition?{top:4,left:4}:"bottom-left"===ne.badgePosition?{bottom:4,left:4}:"bottom-right"===ne.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:rn?"#dc3545":"#28a745",color:"white"}),children:rn?"STALE":"LIVE"}),zn,Dn]})]})});cr.displayName="StreamXYFrame";const ur=e.createContext(null);function dr(){return e.useContext(ur)}function hr(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 fr(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}const[gr,pr]=Ke(t=>({selections:new Map,setClause(e,n){t(t=>{const o=new Map(t.selections),i=fr(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=fr(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}})}})),[yr,mr]=Ke(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 vr(t){const n=e.useId(),o=t.clientId||n,{name:i}=t,r=pr(t=>t.selections.get(i)),s=pr(t=>t.setClause),a=pr(t=>t.clearClause),l=e.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:e.useMemo(()=>r&&0!==r.clauses.size?function(t,e){const n=[];for(const[o,i]of t.clauses)"crossfilter"===t.resolution&&o===e||n.push(hr(i));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(r,o):()=>!0,[r,o]),isActive:l,selectPoints:e.useCallback(t=>{const e={};for(const[n,o]of Object.entries(t))e[n]={type:"point",values:new Set(o)};s(i,{clientId:o,type:"point",fields:e})},[o,i,s]),selectInterval:e.useCallback(t=>{const e={};for(const[n,o]of Object.entries(t))e[n]={type:"interval",range:o};s(i,{clientId:o,type:"interval",fields:e})},[o,i,s]),clear:e.useCallback(()=>{a(i,o)},[a,i,o]),clientId:o}}const xr=e.createContext(!1),br=e.createContext(null),kr="undefined"==typeof window?e.useEffect:e.useLayoutEffect;function wr(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 Ar(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 Sr(){var t;const e=ln(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 jr({data:t,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=e.useContext(xr),u=null!==e.useContext(br),d=void 0!==i?i:!c&&!!n,h=!!n&&(d||u),f=e.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const e=new Set;for(const o of t){const t="function"==typeof n?n(o):o[n];null!=t&&e.add(t+"")}return Array.from(e)},[l,n,t,h]);!function(t){const n=e.useContext(br),o=e.useId(),i=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=e.useRef([]);(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 s=r.current;kr(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),kr(()=>{n&&n.registerCategories(o,s)},[n,o,s])}(u&&n?f:[]);const g=e.useMemo(()=>{if(!d||!n)return;const e=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):Q[r%Q.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:n,colorScale:o,getColor:tt,categories:f});return 0!==e.legendGroups.reduce((t,e)=>t+e.items.length,0)?e:void 0},[d,n,t,o,f]),p=e.useMemo(()=>{const t="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},e=Object.assign(Object.assign({},a),t);return g&&("right"===r&&110>e.right?e.right=110:"left"===r&&110>e.left?e.left=110:"top"===r&&50>e.top?e.top=50:"bottom"===r&&80>e.bottom&&(e.bottom=80)),e},[a,s,g,r]);return{legend:g,margin:p,legendPosition:r}}m.createContext(void 0);const Mr={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 _r(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 Pr({componentName:e,message:n,diagnosticHint:o,width:i,height:r}){return t.jsx("div",{role:"alert",style:{width:i,height:Math.max(r,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:t.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[t.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),t.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&t.jsx("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 Or extends m.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.jsx(Pr,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Tr({componentName:e,width:n,height:o,children:i}){return t.jsx(Or,{fallback:i=>t.jsx(Pr,{componentName:e,message:i.message,width:n,height:o}),children:i})}"undefined"!=typeof process&&process;const Cr={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"},Lr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function $r(n){const{data:o,rawData:i,colorBy:r,colorScheme:s,legendInteraction:a,legendPosition:l,selection:c,linkedHover:u,fallbackFields:d,unwrapData:h=!1,onObservation:f,chartType:g,chartId:p,showLegend:y,userMargin:m,marginDefaults:v,onClick:x,hoverHighlight:b,loading:k,emptyContent:w,width:A,height:S}=n,j=void 0===i,M=e.useMemo(()=>Ln(o),[o]),[_,P]=e.useState([]),O=e.useCallback(t=>{P(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t)},[]),T="string"==typeof n.colorBy?n.colorBy:void 0,{activeSelectionHook:C,hoverSelectionHook:L,customHoverBehavior:$,customClickBehavior:E,crosshairSourceId:D}=function({selection:t,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=e.useId(),h=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}(n,o),f=vr({name:(null==t?void 0:t.name)||"__unused__"}),g=function(t){const n=t.name||"hover",{fields:o}=t,{predicate:i,isActive:r,selectPoints:s,clear:a}=vr({name:n});return{onHover:e.useCallback(t=>{if(!t)return void a();const e={};for(const n of o){const o=t[n];void 0!==o&&(e[n]=[o])}Object.keys(e).length>0&&s(e)},[o,s,a,n]),predicate:i,isActive:r}}({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),p=mr(t=>t.pushObservation),y=t?{isActive:f.isActive,predicate:f.predicate}:null,[m,v]=e.useState(null),x=u||o[0],b=e.useMemo(()=>{if(!c||null==m||!x)return null;const t=m,e=x;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[e]?n[e]:(null!==(o=n[e])&&void 0!==o?o:"")+"")===t}}},[c,m,x]),k=e.useCallback(t=>{var e,o;if(n)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=wr(t,e,h.xField);null!=n&&function(t,e,n){const o=Yo.positions.get(t);(null==o?void 0:o.locked)||o&&o.xValue===e&&o.sourceId===n||(Yo={positions:new Map(Yo.positions).set(t,{xValue:e,sourceId:n})},Go())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&g.onHover(e)}else"x-position"===(null==h?void 0:h.mode)&&qo(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&g.onHover(null);if(c&&x)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=null==e?void 0:e[x];v(null!=n?n+"":null)}else v(null);if(r||p){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){const i=Ar(t),s=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(t),p&&p(t)}}},[n,g,h,d,r,s,a,p,c,x]),w=e.useCallback(t=>{var e,n,o,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=wr(t,e,h.xField);null!=n&&function(t,e,n){const o=Yo.positions.get(t);if(null==o?void 0:o.locked){const e=new Map(Yo.positions);return e.delete(t),Yo={positions:e},Go(),!1}Yo={positions:new Map(Yo.positions).set(t,{xValue:e,sourceId:n,locked:!0})},Go()}(h.name||"hover",n,d)}if(t&&l){let o=t.data||t.datum||t;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(n=t.y)&&void 0!==n?n:0})}if(r||p){const e={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(t){const n=Ar(t),s=Object.assign(Object.assign({},e),{type:"click",datum:n||{},x:null!==(o=t.x)&&void 0!==o?o:0,y:null!==(i=t.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const t=Object.assign(Object.assign({},e),{type:"click-end"});r&&r(t),p&&p(t)}}},[l,r,p,s,a,h,d]);return e.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const t=h.name||"hover";return()=>{Xo(t,d),qo(t,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:b,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}({selection:c,linkedHover:u,fallbackFields:d,unwrapData:h,onObservation:f,chartType:g,chartId:p,onClick:x,hoverHighlight:b,colorByField:T}),R=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}}(u,D),z=function(t,n,o){const i=dr(),r=Sr();return e.useMemo(()=>{var e;if(!n)return;const s=null!==(e=null!=o?o:r&&r.length>0?r:void 0)&&void 0!==e?e:"category10";if(0!==t.length){if("function"==typeof n){const e=Array.from(new Set(t.map(t=>n(t)+"")));if(i&&Object.keys(i).length>0){const t=et(e.map(t=>({_cat:t})),"_cat",s);return e=>i[e]||t(e)}return et(e.map(t=>({_cat:t})),"_cat",s)}if(i&&Object.keys(i).length>0){const e=et(t,n,s);return t=>i[t]||e(t)}return et(t,n,s)}if(i&&Object.keys(i).length>0){const t=et([{_:"a"}],"_",s);return e=>i[e]||t(e)}},[t,n,o,i,r])}(M,r,s),B=e.useMemo(()=>{if(!r)return[];const t=new Set;for(const e of M){const n="function"==typeof r?r(e):e[r];null!=n&&t.add(n+"")}return Array.from(t)},[M,r]),F=e.useMemo(()=>j&&_.length>0?_:B,[j,_,B]),N=function(t,n,o){const[i,r]=e.useState(null),[s,a]=e.useState(new Set),l=e.useCallback(e=>{"highlight"===t&&r(e?e.label:null)},[t]),c=e.useCallback(e=>{"isolate"===t&&a(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===o.length?new Set:n})},[t,o.length]),u=e.useMemo(()=>{if(!t||"none"===t||!n)return null;const e="string"==typeof n?n:null;return"highlight"===t&&null!=i?{isActive:!0,predicate:t=>(e?t[e]:"function"==typeof n?n(t):null)===i}:"isolate"===t&&s.size>0?{isActive:!0,predicate:t=>{const o=e?t[e]:"function"==typeof n?n(t):null;return s.has(o)}}:null},[t,n,i,s]);return{highlightedCategory:"highlight"===t?i:null,isolatedCategories:"isolate"===t?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(a,r,F),W=e.useMemo(()=>L||(N.legendSelectionHook?N.legendSelectionHook:C),[L,N.legendSelectionHook,C]),I=function(t){const n=ln(t=>t.theme.colors.selectionOpacity);return e.useMemo(()=>{var e,o;if(void 0!==t||void 0!==n)return Object.assign(Object.assign({name:null!==(e=null==t?void 0:t.name)&&void 0!==e?e:""},t),{unselectedOpacity:null!==(o=null==t?void 0:t.unselectedOpacity)&&void 0!==o?o:n})},[t,n])}(c),Y=Sr(),H=dr(),G=e.useMemo(()=>{if(z)return z;if(!r||0===F.length)return;const t=Array.isArray(s)&&s.length>0||"string"==typeof s&&s.length>0?s:Y&&Y.length>0?Y:Q,e="__streamCat",n=et(F.map(t=>({[e]:t})),e,t);return t=>(null==H?void 0:H[t])||n(t)||"#999"},[z,r,F,s,Y,H]),{legend:q,margin:X,legendPosition:V}=jr({data:M,colorBy:r,colorScale:G,showLegend:y,legendPosition:l,userMargin:m,defaults:v,categories:F}),U=e.useMemo(()=>{const t={};return q&&(t.legend=q,t.legendPosition=V),a&&"none"!==a&&(t.legendHoverBehavior=N.onLegendHover,t.legendClickBehavior=N.onLegendClick,t.legendHighlightedCategory=N.highlightedCategory,t.legendIsolatedCategories=N.isolatedCategories),j&&r&&(t.legendCategoryAccessor=r,t.onCategoriesChange=O),t},[q,V,a,N.onLegendHover,N.onLegendClick,N.highlightedCategory,N.isolatedCategories,j,r,O]),Z=Array.isArray(i)?Ln(i):i,K=function(e,n,o){if(!e)return null;const i=Math.min(5,Math.floor(o/40)),r=Math.max(8,Math.floor(o/(3*i))),s=Math.max(6,Math.floor(o/(2.5*i))),a=Math.floor((o-(i*(r+s)-s))/2);return t.jsx("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:i},(e,o)=>t.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Lr),{position:"absolute",top:a+o*(r+s),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:r,opacity:.5+o%2*.2})},o))})}(k,A,S),J=K?null:function(e,n,o,i){return!1===i||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?t.jsx("div",{style:Object.assign(Object.assign({},Cr),{width:n,height:o}),children:i||"No data available"}):null}(Z,A,S,w);return{data:M,colorScale:z,allCategories:F,legendState:N,effectiveSelectionHook:W,activeSelectionHook:C,customHoverBehavior:$,customClickBehavior:E,legend:q,margin:X,legendPosition:V,earlyReturn:K||J||null,legendBehaviorProps:U,crosshairProps:R,resolvedSelection:I}}function Er(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 Dr(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 Rr=e.forwardRef(function(n,o){const i=e.useRef(null),r=function(t,e){var n,o,i,r,s,a,l;const c=Mr[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:_r(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:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",seriesAAccessor:h="a",seriesBAccessor:f="b",seriesALabel:g="A",seriesBLabel:p="B",seriesAColor:y="var(--semiotic-danger, #dc2626)",seriesBColor:m="var(--semiotic-info, #2563eb)",showLines:v=!0,lineWidth:x=1.5,showPoints:b=!1,pointRadius:k=3,curve:w="linear",areaOpacity:A=.6,gradientFill:S,tooltip:j,annotations:M,xExtent:_,yExtent:P,frameProps:O={},selection:T,linkedHover:C,onObservation:L,onClick:$,hoverHighlight:E,chartId:D,loading:R,emptyContent:z,legendInteraction:B,legendPosition:F,pointIdAccessor:N,windowSize:W}=n,{width:I,height:Y,enableHover:H,showGrid:G,showLegend:q,title:X,description:V,summary:U,accessibleTable:Z,xLabel:K,yLabel:Q}=r,J=e.useMemo(()=>"function"==typeof d?t=>Er(d(t)):t=>Er(t[d]),[d]),tt=e.useMemo(()=>"function"==typeof h?t=>Er(h(t)):t=>Er(t[h]),[h]),et=e.useMemo(()=>"function"==typeof f?t=>Er(f(t)):t=>Er(t[f]),[f]),[nt,ot]=e.useState([]),it=e.useRef([]),rt=null==s,st=e.useMemo(()=>Ln(rt?nt:s),[rt,nt,s]),at=e.useMemo(()=>Dr(st,J,tt,et),[st,J,tt,et]),lt=e.useMemo(()=>v?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}(st,J,tt,et):[],[v,st,J,tt,et]),ct=e.useMemo(()=>[...at,...lt],[at,lt]),ut=e.useMemo(()=>{const t=new Set;for(const e of at)t.add(e.__diffSegment);return Array.from(t)},[at]);e.useImperativeHandle(o,()=>{const t=t=>{const e=W&&t.length>W?t.slice(t.length-W):t;it.current=e,ot(e)},e=N?"function"==typeof N?N:t=>t[N]:null;return{push:e=>t([...it.current,e]),pushMany:e=>t([...it.current,...e]),remove:n=>{if(!e)return[];const o=Array.isArray(n)?n:[n],i=[],r=[];for(const t of it.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=it.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:()=>rt?it.current:st,getScales:()=>{var t,e;return null!==(e=null===(t=i.current)||void 0===t?void 0:t.getScales())&&void 0!==e?e:null}}},[rt,st,N,W]);const dt=$r({data:st,rawData:s,colorBy:"__diffWinner",colorScheme:[y,m],legendInteraction:B,legendPosition:F,selection:T,linkedHover:C,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:L,onClick:$,hoverHighlight:E,chartType:"DifferenceChart",chartId:D,showLegend:q,userMargin:a,marginDefaults:r.marginDefaults,loading:R,emptyContent:z,width:I,height:Y}),ht=e.useMemo(()=>{if(!1!==q)return{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:g,color:y},{label:p,color:m}]}]}},[q,g,p,y,m]),ft=e.useCallback(t=>{const e=t.__diffSegment;return{fill:"A"==((null==e?void 0:e.endsWith("-A"))?"A":"B")?y:m,stroke:"none",fillOpacity:A}},[y,m,A]),gt=e.useCallback(t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?y:m,strokeWidth:x,fill:"none"}),[y,m,x]),pt=e.useCallback(t=>({fill:"A"==("line-A"===t.__diffSegment?"A":"B")?y:m,r:k}),[y,m,k]),yt=e.useCallback(e=>{const n=e.data,o=null==n?void 0:n.__x;let i=null==n?void 0:n.__valA,r=null==n?void 0:n.__valB;if(null!=o&&(null==i||null==r)){const t=st.find(t=>J(t)===o);t&&(i=tt(t),r=et(t))}const s=t=>null!=t&&Number.isFinite(t)?""+Math.round(100*t)/100:"—",a=c&&null!=o?c(o):null!=o?o+"":"";return t.jsxs("div",{className:"semiotic-tooltip",style:$n,children:[a&&t.jsx("div",{style:{fontWeight:600,marginBottom:4},children:a}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),t.jsxs("span",{children:[g,": ",s(i)]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),t.jsxs("span",{children:[p,": ",s(r)]})]}),null!=i&&null!=r&&Number.isFinite(i)&&Number.isFinite(r)&&t.jsxs("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",s(i-r)]})]})},[st,J,tt,et,c,y,m,g,p]),mt=e.useMemo(()=>{if(!1===j)return()=>null;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.jsx("div",{className:"semiotic-tooltip",style:$n,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Rn(e):Rn())}}(j);return e||yt},[j,yt]),vt=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:ct,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:ut,curve:w,areaStyle:ft,lineStyle:gt},b&&{pointStyle:pt}),{size:[I,Y],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:dt.margin,showAxes:r.showAxes,xLabel:K,yLabel:Q,xFormat:c,yFormat:u,enableHover:H,showGrid:G}),S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S}),ht&&{legend:ht,legendPosition:dt.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:X,description:V,summary:U,accessibleTable:Z,className:l,animate:n.animate,axisExtent:n.axisExtent})),{tooltipContent:mt}),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:C,onObservation:L,onClick:$,hoverHighlight:E,customHoverBehavior:dt.customHoverBehavior,customClickBehavior:dt.customClickBehavior})),M&&M.length>0&&{annotations:M}),_&&{xExtent:_}),P&&{yExtent:P}),dt.crosshairProps),O);return dt.earlyReturn?dt.earlyReturn:t.jsx(Tr,{componentName:"DifferenceChart",width:I,height:Y,children:t.jsx(cr,Object.assign({ref:i},vt))})});function zr(t,e,n){return"function"==typeof t?t(n):n[t||e]}function Br(t){return t instanceof Date?t.getTime():Number(t)}function Fr(t,e){return H(1===e?.5:t/(e-1))}"function"==typeof Rr&&(Rr.displayName="DifferenceChart");const Nr={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=>Br(zr(a,"x",t)),d=t=>Br(zr(l,"a",t)),h=t=>Br(zr(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=Dr(Array.isArray(t)?t:[],u,d,h),x=[];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)&&x.push({__x:e,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&x.push({__x:e,__y:o,__diffSegment:"line-B"})}}const b=[...v,...x],k=Array.from(new Set(v.map(t=>t.__diffSegment)));return Object.assign({chartType:"mixed",data:b,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:Br(zr(e.orderAccessor,"order",t))-Br(zr(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=Br(zr(n,"x",t)),i=Br(zr(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=Br(zr(n,"x",t)),i=Br(zr(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?Fr(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1}}},o)}},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,x]=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),x-(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.xExtentAccessor||"xExtent",m=i.edgeIdAccessor||"id",v=(t,e)=>"function"==typeof t?t(e):e[t],x=Array.isArray(i.edges)?i.edges:[],b=Array.isArray(i.nodes)?i.nodes:[],k=b.length>0?b: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,x,u,d),w=[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=k.map(t=>{const e=v(f,t)+"",n=v(y,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}),S=x.map((t,e)=>{const n=v(m,t);return{id:null!=n?n+"":`${v(u,t)}-${v(d,t)}-${e}`,source:v(u,t)+"",target:v(d,t)+"",value:Number(v(h,t)),startTime:c(v(g,t)),endTime:c(v(p,t)),__raw:t}}),[j,M]=null!==(a=o.size)&&void 0!==a?a:[600,400],_=Object.assign({top:20,right:20,bottom:20,left:20},o.margin),P=null!==(l=o.legendPosition)&&void 0!==l?l:"right";o.showLegend&&("right"===P?_.right=Math.max(_.right,100):"left"===P?_.left=Math.max(_.left,100):"bottom"===P?_.bottom=Math.max(_.bottom,70):"top"===P&&(_.top=Math.max(_.top,40)));const O=_,T=j-O.left-O.right,C=M-O.top-O.bottom,L=Array.isArray(n)?n:null,$=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],E="function"==typeof e?e:null,D=E?k.map(t=>({_cat:E(t)})):k,R=E?"_cat":"string"==typeof e?e:void 0,z=R?et(D,R,n):null,B=new Map;for(const t of A)B.set(t.id,t.__raw);const{layoutConfig:F,issues:N}=On({nodes:A,edges:S,domain:w,plotW:T,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 E?tt({_cat:E(n)},"_cat",null!=z?z:void 0):tt(n,e,null!=z?z:void 0)}const o=L||$;return o[n%o.length]},layoutOpts:{pairing:i.pairing||"temporal",packing:i.packing||"reuse",laneOrder:i.laneOrder||"crossing-min",lifetimeMode:i.lifetimeMode||"half"}});if(N.length>0){const t=N.map(xn).join("; ");throw Error("ProcessSankey: data invalid — "+t)}return Object.assign(Object.assign({chartType:"force",nodes:k,edges:x,customNetworkLayout:Tn,layoutConfig:F,sourceAccessor:u,targetAccessor:d,valueAccessor:h,nodeIDAccessor:f,colorBy:e,colorScheme:n},o),{margin:O})}},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:{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 x=null!==(r=i.edgeColorBy)&&void 0!==r?r:e,b="function"==typeof x,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=x?b?et(k.map(t=>({[w]:x(t)})),w,n||"category10"):et(k,x,n||"category10"):null,S=t=>x&&A?tt(t,x,A):"#007bff";let j=1/0,M=-1/0;for(const t of k){const e=Number(null!==(s=t[h])&&void 0!==s?s:0);isFinite(e)&&(j>e&&(j=e),e>M&&(M=e))}const _=M>j?M-j:0,[P,O]=null!==(a=i.edgeWidthRange)&&void 0!==a?a:[1,8],T=O-P,C=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=P+Math.max(0,Math.min(1,_>0?((Number.isFinite(e)?e:j)-j)/_:0))*T;return{stroke:S(t),strokeWidth:n,strokeLinecap:L,opacity:C,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function Wr(t){return Math.round(100*t)/100+""}function Ir(e,n){const o=dn(n.theme),i=n.idPrefix?n.idPrefix+"-":"",r="string"==typeof n.title?n.title:void 0,s=r?i+"semiotic-title":void 0,a=n.description?i+"semiotic-desc":void 0,l=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:n.className,width:n.width,height:n.height,role:"img","aria-labelledby":l,style:{fontFamily:o.fontFamily},children:[r&&t.jsx("title",{id:s,children:r}),n.description&&t.jsx("desc",{id:a,children:n.description}),n.defs&&t.jsx("defs",{children:n.defs}),n.background&&"transparent"!==n.background&&t.jsx("rect",{x:0,y:0,width:n.width,height:n.height,fill:n.background}),t.jsx("g",{id:i+"data-area",transform:n.innerTransform,children:e}),r&&t.jsx("text",{id:i+"chart-title",x:n.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:r}),n.legend&&t.jsx("g",{id:i+"legend",children:n.legend}),n.outerElements]})}function Yr(e){var n,o,i,r;const s=un(e.theme),a=e.size||[500,300],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),c=Ln(e.data),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?l.left=Math.max(l.left,100):"bottom"===u?l.bottom=Math.max(l.bottom,70):"top"===u&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const d=a[0]-l.left-l.right,h=a[1]-l.top-l.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),g={chartType:e.chartType,windowSize:null!==(n=e.windowSize)&&void 0!==n?n:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:f&&null!==(i=e.arrowOfTime)&&void 0!==i?i:"right",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.1,xAccessor:f?void 0:e.xAccessor,yAccessor:f?void 0:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},p=new ft(g);if(e.data&&p.ingest({inserts:c,bounded:!0}),p.computeScene({width:d,height:h}),!p.scales||0===p.scene.length)return v.renderToStaticMarkup(Ir(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const y=e._idPrefix,x=e.showGrid?function(e,n,o,i){const{grid:r}=dn(o),s=i?i+"-":"",a=e.x.ticks(5),l=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,i)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:n.height,stroke:r,strokeWidth:.5},"gx-"+i)}),l.map((o,i)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:n.width,y2:s,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(p.scales,{width:d,height:h},s,y):null,b=p.scene.map((t,e)=>Ve(t,e,y)).filter(Boolean),k=!1!==e.showAxes?function(e,n,o,i,r){var s,a,l,c;const u=dn(i),d=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||Wr)(t)})),h=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||Wr)(t)}));return t.jsxs("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:u.border,strokeWidth:1}),d.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:u.border,strokeWidth:1}),h.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+n)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:n.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(l=o.margin)||void 0===l?void 0:l.left)&&void 0!==c?c:40)}, ${n.height/2})`,children:o.yLabel})]})}(p.scales,{width:d,height:h},e,s,y):null,w=e.annotations?mn({annotations:e.annotations,scales:{x:p.scales.x,y:p.scales.y},layout:{width:d,height:h},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:y}):null,A=e.showLegend?(()=>{const t=fn(c,e.colorAccessor||e.groupAccessor);return 0===t.length?null:hn({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:l,hasTitle:!!e.title})})():null,S=m.isValidElement(e.legend)?e.legend:A,j=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,x,b,k,w,e.foregroundGraphics]});return v.renderToStaticMarkup(Ir(j,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${l.left},${l.top})`,legend:S,idPrefix:e._idPrefix}))}function Hr(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Gr=new Set(["tree","cluster","treemap","circlepack","partition"]);function qr(e){var n,o,i,r,s;const a=un(e.theme),l=e.chartType||"force",u=e.size||[500,500],d=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),h=e.legendPosition;e.showLegend&&(h&&"right"!==h?"left"===h?d.left=Math.max(d.left,100):"bottom"===h?d.bottom=Math.max(d.bottom,70):"top"===h&&(d.top=Math.max(d.top,40)):d.right=Math.max(d.right,100));const f=u[0]-d.left-d.right,g=u[1]-d.top-d.bottom,p=function(t){return Pe[t]}(l);if(!p)throw Error(`No layout plugin found for chart type: "${l}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const y={chartType:l,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||a.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let x,b;if(Gr.has(l)){const t=e.data||e.edges;if(!t||Array.isArray(t))return v.renderToStaticMarkup(Ir(null,{width:u[0],height:u[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${d.left},${d.top})`,idPrefix:e._idPrefix}));y.__hierarchyRoot=t,x=[],b=[]}else{const t=Ln(e.nodes||[]),n=Array.isArray(e.edges)?Ln(e.edges):[];if(0===t.length&&0===n.length)return v.renderToStaticMarkup(Ir(null,{width:u[0],height:u[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${d.left},${d.top})`,idPrefix:e._idPrefix}));if(b=function(t,e){const n=Hr(e.sourceAccessor,"source"),o=Hr(e.targetAccessor,"target"),i=Hr(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}))}(n,y),0===t.length&&b.length>0){const t=new Set;for(const e of b){const n="string"==typeof e.target?e.target:e.target.id;t.add("string"==typeof e.source?e.source:e.source.id),t.add(n)}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=Hr(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,y)}let k=[],w=[],A=[],S=null;if(y.customNetworkLayout){const t=Oe(y.colorScheme,a.colors.categorical,z),e=Te(t),l={nodes:x,edges:b,dimensions:{width:f,height:g,plot:{x:0,y:0,width:f,height:g}},theme:{semantic:a.colors,categorical:[...t]},resolveColor:e,config:null!==(n=y.layoutConfig)&&void 0!==n?n:{}},c=y.customNetworkLayout(l);k=null!==(o=c.sceneNodes)&&void 0!==o?o:[],w=null!==(i=c.sceneEdges)&&void 0!==i?i:[],A=null!==(r=c.labels)&&void 0!==r?r:[],S=null!==(s=c.overlays)&&void 0!==s?s:null}else{p.computeLayout(x,b,y,[f,g]);const t=p.buildScene(x,b,y,[f,g]);k=t.sceneNodes,w=t.sceneEdges,A=t.labels}const j=dn(a);for(const t of A)t.fill||(t.fill=j.text);const M=w.map((e,n)=>function(e,n){switch(e.type){case"line":return t.jsx("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.jsx("path",{d:o.pathD,fill:Xe(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.jsx("path",{d:o.pathD,fill:Xe(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.jsx("path",{d:o.pathD,fill:Xe(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),_=k.map((e,n)=>function(e,n){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Xe(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.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Xe(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=e,i=c.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(qe)||"";return t.jsx("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:Xe(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),P=A.map((e,n)=>function(e,n){return t.jsx("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),O=e.annotations?mn({annotations:e.annotations,scales:{},layout:{width:f,height:g},theme:a,idPrefix:e._idPrefix}):null,T=e.showLegend?(()=>{const t=t=>"string"==typeof t||"function"==typeof t,n=t(e.colorBy)?e.colorBy:t(e.nodeIDAccessor)?e.nodeIDAccessor:void 0,o=x.length>0?x.map(t=>t.data||{id:t.id}):Array.from(new Set(b.flatMap(t=>{var e,n;return["string"==typeof t.source?t.source:null===(e=t.source)||void 0===e?void 0:e.id,"string"==typeof t.target?t.target:null===(n=t.target)||void 0===n?void 0:n.id]}).filter(Boolean))).map(t=>({id:t})),i=fn(o,n);return 0===i.length?null:hn({categories:i,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:u[0],totalHeight:u[1],margin:d,hasTitle:!!e.title})})():null,C=m.isValidElement(e.legend)?e.legend:T,L=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,M,_,P,O,e.foregroundGraphics,S]});return v.renderToStaticMarkup(Ir(L,{width:u[0],height:u[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${d.left},${d.top})`,legend:C,idPrefix:e._idPrefix}))}function Xr(e){var n,o,i,r,s;const a=un(e.theme),l=e.size||[500,400],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=Ln(e.data),d=e.legendPosition;e.showLegend&&(d&&"right"!==d?"left"===d?c.left=Math.max(c.left,100):"bottom"===d?c.bottom=Math.max(c.bottom,70):"top"===d&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const h=l[0]-c.left-c.right,f=l[1]-c.top-c.bottom,g=e.projection||"vertical",p="radial"===g,y={chartType:e.chartType,windowSize:null!==(n=e.windowSize)&&void 0!==n?n:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(i=e.extentPadding)&&void 0!==i?i:.05,projection:g,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},x=new Ee(y);if(e.data&&x.ingest({inserts:u,bounded:!0}),x.computeScene({width:h,height:f}),!x.scales||0===x.scene.length)return v.renderToStaticMarkup(Ir(null,{width:l[0],height:l[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const b=e._idPrefix,k=e.showGrid?function(e,n,o,i){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:s}=dn(o),a=i?i+"-":"",l="vertical"===r.projection,c=r.r.ticks(5);return t.jsx("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,o)=>{const i=r.r(e);return t.jsx("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.jsx("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(x,{width:h,height:f},a,b):null,w=x.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let A=null;if(w){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)}(e),o=new Set;for(const t of x.scene)"rect"===t.type&&(null===(r=t.datum)||void 0===r?void 0:r.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");A=Array.from(o).map((e,o)=>function(e){const{id:n,background:o="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:s=6,angle:a=45}=e,l=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:n,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:l,height:l,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:l,stroke:i,strokeWidth:r}),t.jsx("line",{x1:s,y1:0,x2:s,y2:l,stroke:i,strokeWidth:r})]},n)}({id:`funnel-hatch-${n}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const i=new Map;Array.from(o).forEach((t,e)=>i.set(t,`funnel-hatch-${n}-${e}`));for(const t of x.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${i.get(e)})`})}}const S=x.scene.map((t,e)=>Ue(t,e)).filter(Boolean),j=!1!==e.showAxes?function(e,n,o,i,r){var s,a,l,c,u,d,h,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const p=dn(i),y="vertical"===g.projection,m=o.categoryFormat||o.oFormat,v=o.valueFormat||o.rFormat,x=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),w=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(v||Wr)(t)}));return t.jsxs("g",y?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:p.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:p.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:e.label})]},"oxtick-"+o)),x&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:x}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:p.border,strokeWidth:1}),w.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:p.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:e.label})]},"oytick-"+n)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:n.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(c=null===(l=o.margin)||void 0===l?void 0:l.left)&&void 0!==c?c:40)}, ${n.height/2})`,children:b})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:n.height,x2:n.width,y2:n.height,stroke:p.border,strokeWidth:1}),w.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${n.height})`,children:[t.jsx("line",{y2:5,stroke:p.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:n.width/2,y:n.height+40,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:n.height,stroke:p.border,strokeWidth:1}),k.map((e,n)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:p.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:p.tickSize,fill:p.textSecondary,fontFamily:p.fontFamily,children:e.label})]},"oytick-"+n)),x&&t.jsx("text",{x:15-(null!==(d=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==d?d:40),y:n.height/2,textAnchor:"middle",fontSize:p.labelSize,fill:p.text,fontFamily:p.fontFamily,transform:`rotate(-90, ${15-(null!==(f=null===(h=o.margin)||void 0===h?void 0:h.left)&&void 0!==f?f:40)}, ${n.height/2})`,children:x})]})}(x,{width:h,height:f},e,a,b):null,M=e.annotations?mn({annotations:e.annotations,scales:{r:x.scales.r,y:"vertical"===x.scales.projection?x.scales.r:void 0},layout:{width:h,height:f},theme:a,projection:g,idPrefix:b}):null,_=e.showLegend?(()=>{const t=fn(u,e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:hn({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:l[0],totalHeight:l[1],margin:c,hasTitle:!!e.title})})():null,P=m.isValidElement(e.legend)?e.legend:_,O=p?c.left+h/2:c.left,T=p?c.top+f/2:c.top,C=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,k,S,j,M,e.foregroundGraphics]});return v.renderToStaticMarkup(Ir(C,{width:l[0],height:l[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${O},${T})`,legend:P,defs:A,idPrefix:e._idPrefix}))}function Vr(e){var n,o,i,r,s,a,l,c,u,d,h,f,g,p;const y=un(e.theme),x=e.size||[e.width||600,e.height||400],b=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),k=Array.isArray(e.areas)?Ln(e.areas):e.areas,w=Ln(e.points),A=Ln(e.lines),S=e.legendPosition;e.showLegend&&(S&&"right"!==S?"left"===S?b.left=Math.max(null!==(o=b.left)&&void 0!==o?o:0,100):"bottom"===S?b.bottom=Math.max(null!==(i=b.bottom)&&void 0!==i?i:0,70):"top"===S&&(b.top=Math.max(null!==(r=b.top)&&void 0!==r?r:0,40)):b.right=Math.max(null!==(n=b.right)&&void 0!==n?n:0,100));const j=x[0]-(null!==(s=b.left)&&void 0!==s?s:0)-(null!==(a=b.right)&&void 0!==a?a:0),M=x[1]-(null!==(l=b.top)&&void 0!==l?l:0)-(null!==(c=b.bottom)&&void 0!==c?c:0),_=new Ye({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(k){if("string"==typeof k)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${k}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${k}')\` before calling renderGeoToStaticSVG.`);_.setAreas(k)}if(e.points&&_.setPoints(w),e.lines&&_.setLines(A),_.computeScene({width:j,height:M}),0===_.scene.length){const n=e.backgroundGraphics||e.foregroundGraphics||e.annotations?t.jsxs(t.Fragment,{children:[e.backgroundGraphics,e.annotations?mn({annotations:e.annotations,scales:{geoProjection:(null===(u=_.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:j,height:M},theme:y,idPrefix:e._idPrefix}):null,e.foregroundGraphics]}):null;return v.renderToStaticMarkup(Ir(n,{width:x[0],height:x[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:y,innerTransform:`translate(${null!==(d=b.left)&&void 0!==d?d:0},${null!==(h=b.top)&&void 0!==h?h:0})`,idPrefix:e._idPrefix}))}const P=_.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.jsx("path",{d:r.pathData,fill:Xe(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.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Xe(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.jsx("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),O=e.annotations?mn({annotations:e.annotations,scales:{geoProjection:(null===(f=_.scales)||void 0===f?void 0:f.projectedPoint)?([t,e])=>_.scales.projectedPoint(t,e):void 0},layout:{width:j,height:M},theme:y,idPrefix:e._idPrefix}):null,T=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;const o=fn(w.length>0?w:Array.isArray(k)&&k.length>0?"string"==typeof t?k.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):k:[],t);return 0===o.length?null:hn({categories:o,colorScheme:e.colorScheme,theme:y,position:e.legendPosition||"right",totalWidth:x[0],totalHeight:x[1],margin:b,hasTitle:!!e.title})})():null,C=m.isValidElement(e.legend)?e.legend:T,L=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,P,O,e.foregroundGraphics]});return v.renderToStaticMarkup(Ir(L,{width:x[0],height:x[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:y,innerTransform:`translate(${null!==(g=b.left)&&void 0!==g?g:0},${null!==(p=b.top)&&void 0!==p?p:0})`,legend:C,idPrefix:e._idPrefix}))}function Ur(t,e){switch(t){case"xy":return Yr(e);case"ordinal":return Xr(e);case"network":return qr(e);case"geo":return Vr(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Zr(e,n,o){var i;const{data:r,width:s=600,height:a=400,theme:l,title:c,description:u,showLegend:d,showGrid:h,background:f,className:g,annotations:p,margin:y,colorScheme:m,colorBy:x,legendPosition:b}=n,k=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}(n,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),w=[s,a],A=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},k.frameProps||{}),{theme:l,title:c,description:u,showLegend:d,showGrid:h,background:f,className:g,annotations:p,size:w}),void 0!==y&&{margin:y}),void 0!==m&&{colorScheme:m}),void 0!==b&&{legendPosition:b}),{_idPrefix:k._idPrefix}),S=Nr[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const j=S.buildProps(r,x,m,A,k);let M=(0,{xy:Yr,ordinal:Xr,network:qr,geo:Vr}[S.frameType])(j);if("GaugeChart"===e&&j.__gauge){const e=j.__gauge,n=A.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-n.left-n.right,r=(a||300)-n.top-n.bottom,c=Math.min(o,r)/2*.85,u=n.left+o/2,d=n.top+r/2,h=Math.max(e.gMin,Math.min(e.gMax,null!==(i=e.value)&&void 0!==i?i:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(h-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,g=un(l).colors.text,p=v.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:d,x2:u+c*Math.cos(f),y2:d+c*Math.sin(f),stroke:g,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:d,r:4,fill:g})]}));M=M.replace("</svg>",p+"</svg>")}return M}function Kr(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=un(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 x=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),k=f-b.left-b.right,w=g-b.top-b.bottom,A=[];if(x)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 Ee(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:k,height:w}),l.scene.length>0&&A.push(ts(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}}),x=new ft(m);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:w}),0===x.scene.length)continue;const b=x.scales?{y:x.scales.y}:void 0;if(A.push(Jr(x.scene,f,g,p,y,b)),c>0&&o>0&&x.activeTransition){const t=c*(1e3/u);for(let e=1;c>=e;e++)x.advanceTransition(x.activeTransition.startTime+e/c*t),A.push(Jr(x.scene,f,g,p,y,b))}}return A}function Qr(t,e){const n=t.background||e.colors.background;return n&&"transparent"!==n?n:null}function Jr(e,n,o,i,r,s){const a=dn(i),l=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),c=n-l.left-l.right,u=o-l.top-l.bottom,d=Qr(r,i),h=e.map((t,e)=>Ve(t,e)).filter(Boolean),f=function(e,n,o,i,r,s){var a;if(!e||0===e.length)return null;const l=dn(i),c=[];for(let i=0;e.length>i;i++){const u=e[i];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(r){const[t,n]=r,i=n-t;if(0===i)continue;e=o-(u.value-t)/i*o}if(null==e)continue;const d=u.color||l.primary,h=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";c.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:n,y2:e,stroke:d,strokeWidth:h,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?n/2:n-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:l.tickSize,fill:d,fontFamily:l.fontFamily,children:u.label})]},"ann-"+i))}}return c.length>0?t.jsx(t.Fragment,{children:c}):null}(r.annotations,c,u,i,r.yExtent,null==s?void 0:s.y),g="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,y=g?"semiotic-title":void 0,m=p?"semiotic-desc":void 0,x=[y,m].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:o,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily},children:[g&&t.jsx("title",{id:y,children:g}),p&&t.jsx("desc",{id:m,children:p}),d&&t.jsx("rect",{x:0,y:0,width:n,height:o,fill:d}),t.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[f,h]}),g&&t.jsx("text",{x:n/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:g})]});return v.renderToStaticMarkup(b)}function ts(e,n,o,i,r){const s=dn(i),a=Object.assign({top:20,right:20,bottom:30,left:40},r.margin),l="radial"===r.projection,c=l?a.left+(n-a.left-a.right)/2:a.left,u=l?a.top+(o-a.top-a.bottom)/2:a.top,d=Qr(r,i),h=e.map((t,e)=>Ue(t,e)).filter(Boolean),f="string"==typeof r.title?r.title:void 0,g="string"==typeof r.description?r.description:void 0,p=f?"semiotic-title":void 0,y=g?"semiotic-desc":void 0,m=[p,y].filter(Boolean).join(" ")||void 0,x=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:o,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:p,children:f}),g&&t.jsx("desc",{id:y,children:g}),d&&t.jsx("rect",{x:0,y:0,width:n,height:o,fill:d}),t.jsx("g",{transform:`translate(${c},${u})`,children:h}),f&&t.jsx("text",{x:n/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return v.renderToStaticMarkup(x)}exports.generateFrameSVGs=Kr,exports.generateFrameSequence=function(t,e,n={}){return e.map(e=>{try{return Zr(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>`}})},exports.renderChart=Zr,exports.renderDashboard=function(e,n={}){var o;const{title:i,subtitle:r,theme:s,width:a=1200,height:l,layout:c={},background:u}=n,d=dn(un(s)),h=c.columns||2,f=null!==(o=c.gap)&&void 0!==o?o:16;let g=0;i&&(g+=30),r&&(g+=20),g>0&&(g+=10);const p=Math.floor((a-f-f*(h-1))/h),y=[];let m=0,x=g+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,h),n=t.props.height||300;m+e>h&&(x+=b+f,m=0,b=0),y.push({chart:t,x:f/2+m*(p+f),y:x,w:p*e+f*(e-1),h:n}),b=Math.max(b,n),m+=e}const k=l||x+b+f,w=y.map((e,n)=>{const{chart:o,x:i,y:r,w:a,h:l}=e,c=Object.assign(Object.assign({},o.props),{width:a,height:l,theme:s,_idPrefix:"chart-"+n});let u;return u=o.component?Zr(o.component,c):o.frameType?Ur(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${l}"></svg>`,t.jsx("g",{transform:`translate(${i},${r})`,children:t.jsx("foreignObject",{width:a,height:l,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+n)}),A=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":i||"Dashboard",style:{fontFamily:d.fontFamily},children:[i&&t.jsx("title",{children:i}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),i&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:d.titleSize+4,fontWeight:"bold",fill:d.text,fontFamily:d.fontFamily,children:i}),r&&t.jsx("text",{x:a/2,y:i?46:20,textAnchor:"middle",fontSize:d.labelSize,fill:d.textSecondary,fontFamily:d.fontFamily,children:r}),w]});return v.renderToStaticMarkup(A)},exports.renderGeoToStaticSVG=function(t){return Vr(t)},exports.renderNetworkToStaticSVG=function(t){return qr(t)},exports.renderOrdinalToStaticSVG=function(t){return Xr(t)},exports.renderToAnimatedGif=function(t,e,n){return b(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,x;const{fps:b=12,loop:k=!0,scale:w=1,background:A}=o,S=n.height||400,j=Math.round((n.width||600)*w),M=Math.round(S*w),_=Kr(t,e,A?Object.assign(Object.assign({},n),{background:A}):n,o);if(0===_.length)throw Error("No frames generated — check that data is not empty");let P,O,T,C;try{const t="sharp",e=yield import(t);P=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);O=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,T=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,C=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===(x=null===(v=e.default)||void 0===v?void 0:v.default)||void 0===x?void 0:x.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const L=Math.round(1e3/b),$=O();for(let t=0;_.length>t;t++){const e=_[t],n=yield P(Buffer.from(e),{density:72*w}).resize(j,M).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),i=T(o,256),r=C(o,i);$.writeFrame(r,j,M,{palette:i,delay:L,repeat:k?0:-1})}return $.finish(),Buffer.from($.bytes())})},exports.renderToImage=function(t,e){return b(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)?Ur(t,e):Zr(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()})},exports.renderToStaticSVG=Ur,exports.renderXYToStaticSVG=function(t){return Yr(t)},exports.resolveTheme=un,exports.themeStyles=dn;
|