semiotic 3.4.1 → 3.4.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/ai/schema.json +1 -1
- package/dist/components/export/selectionSerializer.d.ts +1 -1
- package/dist/components/realtime/types.d.ts +5 -5
- package/dist/components/store/SelectionStore.d.ts +1 -1
- package/dist/components/store/TooltipStore.d.ts +5 -1
- package/dist/components/store/useSelection.d.ts +7 -4
- package/dist/components/stream/NetworkSVGOverlay.d.ts +18 -12
- package/dist/components/stream/geoTypes.d.ts +20 -8
- package/dist/components/stream/keyboardNav.d.ts +18 -6
- package/dist/components/stream/networkTypes.d.ts +42 -21
- package/dist/components/stream/ordinalTypes.d.ts +12 -12
- package/dist/components/stream/types.d.ts +13 -9
- 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.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- 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 +3 -4
package/dist/semiotic.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),t=require("react"),o=require("d3-selection"),n=require("d3-brush"),i=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-scale-chromatic"),a=require("d3-array"),l=require("d3-hierarchy"),c=require("d3-shape"),u=require("regression"),d=require("d3-interpolate"),h=require("d3-force"),g=require("d3-chord");function f(e){return e&&e.__esModule?e:{default:e}}function p(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}const y=p(t),v=f(u);function m(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n+1>>1;t[i]>e?n=i-1:o=i}return t[o]}function b(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n>>1;e>t[i]?o=i+1:n=i}return t[o]}function x({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,dimension:c,scales:u,onBrush:d,binSize:h,snap:g,binBoundaries:f,snapDuring:p,streaming:y}){const v=t.useRef(null),x=t.useRef(null),k=t.useRef(d);k.current=d;const w=t.useRef(u);w.current=u;const j=t.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),A=t.useRef(j);A.current=j;const S=t.useRef(!1),O=t.useRef(null);return t.useEffect(()=>{if(!v.current)return;const e=o.select(v.current).select(".brush-g"),t="x"===c?n.brushX():"y"===c?n.brushY():n.brush();return t.extent([[0,0],[i,r]]),t.on("brush end",o=>{if(S.current)return;const n=w.current;if(!n)return;if(!o.selection)return O.current=null,void k.current(null);let s,a;if("x"===c){const[e,t]=o.selection;s=[n.x.invert(e),n.x.invert(t)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===c){const[e,t]=o.selection;s=[n.x.invert(0),n.x.invert(i)],a=[n.y.invert(t),n.y.invert(e)]}else{const[[e,t],[i,r]]=o.selection;s=[n.x.invert(e),n.x.invert(i)],a=[n.y.invert(r),n.y.invert(t)]}if("bin"===g&&"y"!==c&&("end"===o.type||"brush"===o.type&&p)){const i=A.current;i&&i.length>0?s=function(e,t){return 0===t.length?e:[m(e[0],t),b(e[1],t)]}(s,i):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===c)e.call(t.move,[r,a]);else if("xy"===c){const n=o.selection;e.call(t.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const l={x:s,y:a};O.current=l,k.current(l)}),e.call(t),x.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),x.current=null}},[i,r,c,g,h,p]),t.useEffect(()=>{if(!(y&&u&&x.current&&O.current))return;if(!v.current)return;if("y"===c)return;const e=O.current,t=u.x.domain()[0],n=o.select(v.current).select(".brush-g");if(t>=e.x[1])return S.current=!0,n.call(x.current.move,null),S.current=!1,O.current=null,void k.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===g){const e=A.current;e&&e.length>0?i=b(t,e):h&&h>0&&(i=Math.ceil(t/h)*h)}if(i>=e.x[1])return S.current=!0,n.call(x.current.move,null),S.current=!1,O.current=null,void k.current(null);r=!0}const s=u.x(i),a=u.x(e.x[1]);if(S.current=!0,"x"===c)n.call(x.current.move,[s,a]);else{const t=u.y(e.y[1]),o=u.y(e.y[0]);n.call(x.current.move,[[s,t],[a,o]])}if(S.current=!1,r){const t={x:[i,e.x[1]],y:e.y};O.current=t,k.current(t)}},[u,y,c,g,h]),e.jsx("svg",{ref:v,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`})})}class k{constructor(e,t){var o,n;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(o=null==t?void 0:t.chunkThreshold)&&void 0!==o?o:5e3,this.chunkSize=null!==(n=null==t?void 0:t.chunkSize)&&void 0!==n?n:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}setReplacementData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function w(o){const n=t.createContext(null),i=j(o);return[function({children:i}){const r=t.useMemo(()=>j(o),[]);return e.jsx(n.Provider,{value:r,children:i})},e=>{var o;const r=null!==(o=t.useContext(n))&&void 0!==o?o:i,s=t.useRef(e);s.current=e;const a=t.useCallback(()=>s.current(r.getState()),[r]),l=t.useCallback(()=>s.current(r.getState()),[r]);return t.useSyncExternalStore(r.subscribe,a,l)}]}function j(e){const t=new EventTarget;let o=e(function(e){o=Object.assign(Object.assign({},o),e(o)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>o,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function A(e){if(!(null==e?void 0:e.colors))return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function S(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:O})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const O=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],M={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}},C={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}},_={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:O,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"},[P,L]=w(e=>({theme:M,setTheme(t){e(e=>{if("light"===t)return{theme:M};if("dark"===t)return{theme:C};if("high-contrast"===t)return{theme:_};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?C:M;return{theme:S(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||{})}))}}return{theme:S(Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})}))}})}}));class T{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const o of e){const e=this.push(o);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e(this.buffer[(t+o)%this._capacity],o)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e[o]=this.buffer[(t+o)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),o=[];for(;t.length>e;)o.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return o}update(e,t){const o=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(n+i)%this._capacity,s=this.buffer[r];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),o.push(e),this.buffer[r]=t(s)}}return o}remove(e){const t=[],o=[];if(this.forEach(n=>{e(n)?o.push(n):t.push(n)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return o}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 R{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const o of e){const e=t?t(o):o;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}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 B(e,t,o,n,i){const r=new Map;for(const s of e){const e=t(s),a=o(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/n)*n;let c=r.get(l);if(c||(c={start:l,end:l+n,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const e=i(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return r}function I(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function D(e,t){if("function"==typeof e)return t=>+e(t);const o=e||t;return e=>+e[o]}function H(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function N(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}const $={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},W=s.schemeCategory10,F=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],E=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],z=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 Y(e,t,o){if("function"==typeof t){const n=t(e);return o&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||z.has(t)}(n)?o(n):n}const n=null==e?void 0:e[t];return o?o(n):W[Math.abs(function(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return Math.abs(t)}(n+""))%W.length]}function G(e,t,o="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(o))return i.scaleOrdinal().domain(n).range(o).unknown("#999");const s=$[o]||$.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of n){const o=Number(t);o>e&&(e=o)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:W;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function q(e,t,o=[3,20],n){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!n)return i;const[r,s]=n,[a,l]=o;return s===r?(a+l)/2:a+(i-r)/(s-r)*(l-a)}function X(e,t,o){var n,i,r;if(1>=o)return 1;const s=null!==(n=e.minOpacity)&&void 0!==n?n:.1,a=o-1-t;switch(e.type){case"linear":return s+(1-a/(o-1))*(1-s);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:o/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*o)>a?1:s;default:return 1}}function V(e,t,o){var n;const i=null!==(n=e.duration)&&void 0!==n?n:500,r=o-t;return i>r?1-r/i:0}function U(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function K(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Q(e,t,o){return e+(t-e)*o}function Z(){return"undefined"!=typeof performance?performance.now():Date.now()}function J(e,t,o){var n,i,r,s;if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const o=e.getX(t.datum),n=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${o}:${n}`;if(null!=o&&null!=n)return`p:${o}:${n}`}return"p:"+o;case"rect":return`r:${t.group||""}:${null!==(s=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:o}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+o:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function ee(e,t,o,n,i,r){const s=[];for(const i of e){const e=o(i),r=n(i);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||s.push({px:t.x(e),py:t.y(r),rawY:r,d:i})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function te(e,t,o,n,i,r,s,a){const l=[];for(const r of e){const e=o(r),s=n(r);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(r):i;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:e,group:s}}function oe(e,t,o,n,i,r,s){const a=o(e),l=n(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:i,style:r,datum:e};return void 0!==s&&(c.pointId=s),c}function ne(e,t,o,n,i,r,s){return{type:"rect",x:e,y:t,w:o,h:n,style:i,datum:r,group:s}}function ie(e,t,o,n,i,r,s){const a={type:"heatcell",x:e,y:t,w:o,h:n,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 re(e,t,o){if(!e.getBounds||!e.scales)return null;const n=[],i=[];for(const o of t){const t=e.getX(o),r=e.getY(o);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const s=e.getBounds(o),a=e.scales.x(t);if(s&&0!==s)n.push([a,e.scales.y(r+s)]),i.push([a,e.scales.y(r-s)]);else{const t=e.scales.y(r);n.push([a,t]),i.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:e.resolveBoundsStyle(o,t[0]),datum:t,group:o,interactive:!1}}function se(e,t,o,n){var i;if(!e.config.pointStyle)return;const r=null!=n?n:e.getY;for(const n of t){const t=e.resolveGroupColor(n.key);for(const s of n.data){let n=e.config.pointStyle(s);!n.fill&&t&&(n=Object.assign(Object.assign({},n),{fill:t}));const a=null!==(i=n.r)&&void 0!==i?i:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=oe(s,e.scales,e.getX,r,a,n,l);c&&o.push(c)}}}const ae={blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo},le=new Map;class ce{constructor(e){if(this.xExtent=new R,this.yExtent=new R,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.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=e,this.buffer=new T(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=D(e.timeAccessor||e.xAccessor,"time"),this.getY=D(e.valueAccessor||e.yAccessor,"value")):(this.getX=D(e.xAccessor,"x"),this.getY=D(e.yAccessor,"y")),this.getGroup=N(e.groupAccessor),this.getCategory=N(e.categoryAccessor),this.getSize=e.sizeAccessor?D(e.sizeAccessor,"size"):void 0,this.getColor=N(e.colorAccessor),this.getBounds=e.boundsAccessor?D(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?D(e.y0Accessor,"y0"):void 0,this.getPointId=N(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,o=null!=e.closeAccessor;this.getOpen=t?D(e.openAccessor,"open"):void 0,this.getHigh=D(e.highAccessor,"high"),this.getLow=D(e.lowAccessor,"low"),this.getClose=o?D(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!o}e.pulse&&(this.timestampBuffer=new T(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(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?D(this.config.timeAccessor||this.config.xAccessor,"time"):D(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],o=this.config.xAccessor,n="function"==typeof o?o(t):t[o||"x"],i=n instanceof Date,r="string"==typeof n&&n.length>=10&&!isNaN(new Date(n).getTime())&&isNaN(Number(n));if(this.xIsDate=i||r,r){const e="string"==typeof o?o:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(o(e)instanceof Date?o(e):new Date(o(e)))}}const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o))):(this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o)))}else for(const o of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o))):(this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,o,n,r,s,a,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(o=c.xExtent[0])&&void 0!==o?o:h[0],null!==(n=c.xExtent[1])&&void 0!==n?n:h[1]]:h,p=c.yExtent?[null!==(r=c.yExtent[0])&&void 0!==r?r:g[0],null!==(s=c.yExtent[1])&&void 0!==s?s:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),o=new Map;let n=0;for(const e of t)for(const t of e.data){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const r=(o.get(e)||0)+i;o.set(e,r),r>n&&(n=r)}p=[0,n+(n>0?n*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,o,n,i){const r=B(e,t,o,n,i);if(0===r.size)return[0,0];let s=0;for(const e of r.values())e.total>s&&(s=e.total);return[0,s]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.size>0){const[e,t]=function(e,t){let o=0,n=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,o>i&&(o=i),i>n&&(n=i))}return[o,n]}(u,this.getY),o=t-e,n=o>0?o*c.extentPadding:1;p=[Math.min(0,e-Math.abs(n)),Math.max(0,t+Math.abs(n))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),o=this.getBounds(e);null!=t&&!Number.isNaN(t)&&o&&(t+o>p[1]&&(p[1]=t+o),p[0]>t-o&&(p[0]=t-o))}const e=p[1]-p[0],t=e>0?e*c.extentPadding:1,o=null===(a=c.yExtent)||void 0===a?void 0:a[0],n=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=o?p[0]:p[0]-t,null!=n?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=o?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(v)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[m,e.width-m]:[e.width-m,m];this.scales={x:i.scaleLinear().domain(f).range(t),y:i.scaleLinear().domain(p).range([e.height-m,m])}}else{const t="down"===c.arrowOfTime?[m,e.height-m]:[e.height-m,m];this.scales={x:i.scaleLinear().domain(p).range([m,e.width-m]),y:i.scaleLinear().domain(f).range(t)}}else{const t=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)};this.scales={x:t(c.xScaleType,f,[m,e.width-m]),y:t(c.yScaleType,p,[e.height-m,m])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),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:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return this._quadtree=null,void(this._maxPointRadius=0);let t=0,o=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>o&&(o=e.r));if(this._maxPointRadius=o,ce.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const n=Array(t);let i=0;for(const e of this.scene)"point"===e.type&&(n[i++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,o=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const n of e.path)n[0]*=t,n[1]*=o;break;case"area":for(const n of e.topPath)n[0]*=t,n[1]*=o;for(const n of e.bottomPath)n[0]*=t,n[1]*=o;break;case"point":e.x*=t,e.y*=o;break;case"rect":case"heatcell":e.x*=t,e.y*=o,e.w*=t,e.h*=o;break;case"candlestick":e.x*=t,e.openY*=o,e.closeY*=o,e.highY*=o,e.lowY*=o}const n=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,n,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,r,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var o;const{config:n,scales:i}=this;if(!i||0===t.length)return[];const r={scales:i,config:n,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:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){var o;const n=e.groupData(t),i=[],r=null===(o=e.config.annotations)||void 0===o?void 0:o.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of n){const o=re(e,t.data,t.key);o&&i.push(o)}for(const t of n){const o=e.resolveLineStyle(t.key,t.data[0]),n=ee(t.data,e.scales,e.getX,e.getY,o,t.key);r&&r.length>0&&(n.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),i.push(n)}return se(e,n,i),i}(r,t);case"area":return function(e,t){const o=e.groupData(t),n=[],i=e.scales.y.domain()[0],r=e.getY0?t=>{const o=e.getY0(t);return null==o?i:o}:void 0;for(const t of o){const o=e.resolveAreaStyle(t.key,t.data[0]),s=te(t.data,e.scales,e.getX,e.getY,i,o,t.key,r);e.config.gradientFill&&(s.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),n.push(s)}return se(e,o,n),n}(r,t);case"mixed":return function(e,t){const o=e.groupData(t),n=[],i=e.config.areaGroups||new Set,r=e.scales.y.domain()[0],s=e.getY0?t=>{const o=e.getY0(t);return null==o?r:o}:void 0;for(const t of o)if(i.has(t.key)){const o=e.resolveAreaStyle(t.key,t.data[0]),i=te(t.data,e.scales,e.getX,e.getY,r,o,t.key,s);e.config.gradientFill&&(i.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}else{const o=e.resolveLineStyle(t.key,t.data[0]),i=ee(t.data,e.scales,e.getX,e.getY,o,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}return se(e,o,n),n}(r,t);case"stackedarea":return function(e,t){const o=e.groupData(t);o.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const n=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:i,stackedTops:r}=function(e,t,o,n,i,r,s){var a;const l=new Set;for(const t of e)for(const e of t.data){const t=o(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=o(i),r=n(i);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||e.set(t,(e.get(t)||0)+r)}u.set(t.key,e)}let d;if(r){d=new Map;for(const t of c){let o=0;for(const n of e)o+=(null===(a=u.get(n.key))||void 0===a?void 0:a.get(t))||0;d.set(t,o||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const o of e){const e=u.get(o.key),n=[],a=[],l=new Map;for(const o of c){let i=e.get(o)||0;const s=f.get(o);r&&(i/=d.get(o));const c=s+i,u=t.x(o);a.push([u,t.y(s)]),n.push([u,t.y(c)]),f.set(o,c),l.set(o,c)}g.set(o.key,l);const p={type:"area",topPath:n,bottomPath:a,style:i(o.key,o.data[0]),datum:o.data,group:o.key};s&&(p.curve=s),h.push(p)}return{nodes:h,stackedTops:g}}(o,e.scales,e.getX,e.getY,(t,o)=>e.resolveAreaStyle(t,o),e.config.normalize,n),s=i;if(e.config.pointStyle){const t=new WeakMap;for(const n of o){const o=r.get(n.key);if(o)for(const i of n.data){const n=e.getX(i),r=e.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||t.set(i,o.get(n))}}const n=o=>{var n;return null!==(n=t.get(o))&&void 0!==n?n:e.getY(o)};se(e,o,s,n)}return s}(r,t);case"scatter":case"bubble":return function(e,t){var o;const n=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let s=null;if(e.getSize&&!e.config.pointStyle){const o=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(o.length>0){let e=1/0,t=-1/0;for(const n of o)e>n&&(e=n),n>t&&(t=n);s=o=>e===t?(r[0]+r[1])/2:r[0]+(o-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,l=(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7";for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:l,opacity:.8},r=t.r||i;if(s&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(r=s(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(o);n&&a.has(n)&&(t=Object.assign(Object.assign({},t),{fill:a.get(n)}))}const c=e.getPointId?e.getPointId(o)+"":void 0,u=oe(o,e.scales,e.getX,e.getY,r,t,c);u&&n.push(u)}return n}(r,t);case"heatmap":return function(e,t,o){if(e.config.heatmapAggregation)return function(e,t,o){var n,i,r;const s=Math.max(1,Math.floor(null!==(n=e.config.heatmapXBins)&&void 0!==n?n:20)),a=Math.max(1,Math.floor(null!==(i=e.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=e.config.heatmapAggregation)&&void 0!==r?r:"count",c=D(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/s,p=(g-h||1)/a,y=s*a;if(y>1e6)return[];const v=new Int32Array(y),m=new Float64Array(y);for(let o=0;t.length>o;o++){const n=t[o],i=e.getX(n),r=e.getY(n);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/f),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;v[g]++;const y=c(n);m[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===v[e])continue;let t;switch(l){case"sum":t=m[e];break;case"mean":t=m[e]/v[e];break;default:t=v[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,w=o.width/s,j=o.height/a,A=e.config.showValues,S=e.config.heatmapValueFormat,O=[];for(let e=0;a>e;e++){const t=e*s;for(let o=0;s>o;o++){const n=t+o;if(0===v[n])continue;let i;switch(l){case"sum":i=m[n];break;case"mean":i=m[n]/v[n];break;default:i=v[n]}const r=(i-b)/k;O.push(ie(o*w,(a-1-e)*j,w,j,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:o,yi:e,value:i,count:v[n],sum:m[n]},A?{value:i,showValues:!0,valueFormat:S}:void 0))}}return O}(e,t,o);if(0===t.length)return[];const n=D(e.config.valueAccessor,"value"),i=H(e.config.xAccessor,"x"),r=H(e.config.yAccessor,"y"),a=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const o=t[e],n=i(o),s=r(o);c[e]=n,u[e]=s,a.has(n)||a.set(n,a.size),l.has(s)||l.set(s,l.size)}const d=a.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(a.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const v=new Float64Array(t.length),m=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const o=t[e],i=a.get(c[e]),r=l.get(u[e]);if(void 0===i||void 0===r)continue;const s=n(o),h=r*d+i,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),v[f]=h,m[f]=s,b[f]=o}let w=1/0,j=-1/0;for(let e=0;k>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>j&&(j=t))}if(!isFinite(w)||!isFinite(j))return[];const A=function(e){const t=e in ae?e:"blues";let o=le.get(t);if(o)return o;o=Array(256);const n=ae[t]||s.interpolateBlues;for(let e=0;256>e;e++)o[e]=n(e/255);return le.set(t,o),o}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(j-w||1),O=o.width/d,M=o.height/h,C=e.config.showValues,_=e.config.heatmapValueFormat,P=[];for(let e=0;k>e;e++){const t=m[e];if(!isFinite(t))continue;const o=v[e],n=o%d;P.push(ie(n*O,(h-1-(o-n)/d)*M,O,M,A[Math.min((t-w)*S+.5|0,255)],b[e],C?{value:t,showValues:!0,valueFormat:_}:void 0))}return P}(r,t,e);case"bar":{const e=function(e,t){var o,n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=B(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of i.values())for(const o of e.categories.keys())t.add(o);const o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),s=Array.from(t).filter(e=>!n.has(e)).sort(),a=o.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const s=[],a=e.scales,[l,c]=a.x.domain(),u=e.config.barStyle,d=null===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary,h=null==u?void 0:u.gap,g="number"!=typeof h||0>h?1:h,f={};(null==u?void 0:u.stroke)&&(f.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(f.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(f.opacity=u.opacity);for(const t of i.values()){const o=Math.max(t.start,l),i=Math.min(t.end,c);if(o>=i)continue;const h=a.x(o),p=a.x(i),y=Math.abs(p-h),v=y>g+1?g:0,m=Math.min(h,p)+v/2,b=Math.max(y-v,1);if(b>0)if(r&&t.categories.size>0){let o=0;for(const i of r){const r=t.categories.get(i)||0;if(0===r)continue;const l=a.y(o),c=a.y(o+r),h=(null===(n=e.config.barColors)||void 0===n?void 0:n[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(ne(m,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},f),{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:r},i)),o+=r}}else{const e=a.y(0),o=a.y(t.total);s.push(ne(m,Math.min(e,o),b,Math.abs(e-o),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},f),{binStart:t.start,binEnd:t.end,total:t.total}))}}const p=new Set;for(const e of i.values())p.add(e.start),p.add(e.end);return{nodes:s,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=null!==(o=r.barCategoryCache)&&void 0!==o?o:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var o,n,i,r,s,a;const l=[],c=e.config.swarmStyle||{},u=null!==(o=c.radius)&&void 0!==o?o:3,d=null!==(r=null!==(n=c.fill)&&void 0!==n?n:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,g=c.stroke,f=c.strokeWidth;for(const o of t){const t=e.getX(o),n=e.getY(o);if(null==n||Number.isNaN(n))continue;const i=e.scales.x(t),r=e.scales.y(n);let s=d;if(e.getCategory){const t=e.getCategory(o);s=(null===(a=e.config.barColors)||void 0===a?void 0:a[t])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:g,strokeWidth:f},datum:o};e.getPointId&&(c.pointId=e.getPointId(o)+""),l.push(c)}return l}(r,t);case"waterfall":return function(e,t,o){var n,i,r,s,a,l,c;const u=[],d=e.scales,h=e.config.waterfallStyle,g=t.filter(t=>{const o=e.getY(t),n=e.getX(t);return null!=o&&!Number.isNaN(o)&&null!=n&&isFinite(n)});if(0===g.length)return u;const f=null!==(r=null!==(n=null==h?void 0:h.positiveColor)&&void 0!==n?n:null===(i=e.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=e.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,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let t=0;g.length>t;t++){const n=g[t],i=e.getX(n),r=e.getY(n),s=x+r;let a;a=g.length-1>t?e.getX(g[t+1])-i:t>0?i-e.getX(g[t-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+o.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const j=d.y(x),A=d.y(s),S=Math.min(j,A),O=Math.abs(j-A),M={fill:0>r?p:f,stroke:v,strokeWidth:m};null!=b&&(M.opacity=b),u.push(ne(k,S,w,O,M,Object.assign(Object.assign({},n),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(r,t,e);case"candlestick":return function(e,t){var o,n;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(o=e.config.candlestickRangeMode)&&void 0!==o&&o;if(!(i||e.getOpen&&e.getClose))return[];const r=[],s=e.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=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=null!==(n=s.bodyWidth)&&void 0!==n?n:0;if(null==s.bodyWidth)if(h.length>1){let t=1/0;for(let o=1;h.length>o;o++){const n=Math.abs(e.scales.x(h[o])-e.scales.x(h[o-1]));n>0&&t>n&&(t=n)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else g=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const n=e.getHigh(o),s=e.getLow(o);if(null==n||Number.isNaN(n)||null==s||Number.isNaN(s))continue;const a=i?n:e.getOpen(o),h=i?s:e.getClose(o);if(!i&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=a,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(n),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:o};i&&(p.isRange=!0),r.push(p)}return r}(r,t);default:return[]}}resolveBoundsStyle(e,t){var o;const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||(null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?X(o,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,o){var n,i;const r=o.length;if(1>=r)return;const s=new Map;for(let e=0;o.length>e;e++)s.set(o[e],e);for(const o of t){if("line"===o.type){const t=Array.isArray(o.datum)?o.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let o=0;t.length>o;o++){const a=s.get(t[o]);null!=a?(n[o]=X(e,a,r),1>n[o]&&(i=!0)):n[o]=1}i&&(o._decayOpacities=n);continue}if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[],n=o.topPath?o.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let a=!1;for(let o=0;t.length>o;o++){const n=s.get(t[o]);null!=n?(i[o]=X(e,n,r),1>i[o]&&(a=!0)):i[o]=1}a&&(o._decayOpacities=i)}else{let i=1;for(const o of t){const t=s.get(o);if(null!=t){const o=X(e,t,r);i>o&&(i=o)}}if(1>i){const e=Array(n);e.fill(i),o._decayOpacities=e}}continue}const t=s.get(o.datum);if(null==t)continue;const a=X(e,t,r);if("heatcell"===o.type)o.style={opacity:a};else if("candlestick"===o.type)o._decayOpacity=a;else{const e=null!==(i=null===(n=o.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;o.style=Object.assign(Object.assign({},o.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,o,n){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=e.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=e.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;o.length>e;e++)c.set(o[e],e);for(const o of t){if("line"===o.type)continue;if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[o.datum];let i=0;for(const o of t){const t=c.get(o);if(null==t)continue;const r=n.get(t);if(null==r)continue;const a=V(e,r,s);a>i&&(i=a)}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const t=c.get(o.datum);if(null==t)continue;const i=n.get(t);if(null==i)continue;const r=V(e,i,s);r>0&&(o._pulseIntensity=r,o._pulseColor=a,o._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var o;if(!t||0===t.size)return!1;const n="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(o=e.duration)&&void 0!==o?o:500,r=t.peek();return null!=r&&i>n-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,o,n){var i,r,s,a;o.clear(),n.clear();for(let l=0;t.length>l;l++){const c=t[l],u=J(e,c,l);u&&("point"===c.type?o.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?o.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?o.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?o.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?n.set(u,{path:c.path.map(e=>[e[0],e[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&n.set(u,{topPath:c.topPath.map(e=>[e[0],e[1]]),bottomPath:c.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var e,t,o;this.prevPositionMap.clear(),this.prevPathMap.clear();const n=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.y(0))&&void 0!==t?t:0;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],i=J(this.transitionContext,t,e);i&&("point"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,r:0,opacity:0}):"rect"===t.type?this.prevPositionMap.set(i,{x:t.x,y:n,w:t.w,h:0,opacity:null!==(o=t.style.opacity)&&void 0!==o?o:1}):"heatcell"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,w:t.w,h:t.h,opacity:0}):"line"===t.type?(t._introClipFraction=0,this.prevPathMap.set(i,{path:t.path.map(e=>[e[0],e[1]]),opacity:t.style.opacity})):"area"===t.type&&(t._introClipFraction=0,this.prevPathMap.set(i,{topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),opacity:t.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,o,n,i){var r,s,a,l,c,u,d,h,g,f,p,y,v,m,b,x,k,w,j,A,S,O,M,C,_,P,L,T,R,B,I,D,H,N,$,W,F,E,z,Y,G;if(0===n.size&&0===i.size)return o;const q=null!==(r=t.duration)&&void 0!==r?r:300;if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}let X=!1;const V=new Set,U=new Set;for(let t=0;o.scene.length>t;t++){const r=o.scene[t],P=J(e,r,t);if(!P)continue;if(r._transitionKey=P,"line"===r.type||"area"===r.type){const e=i.get(P);if(e){if(U.add(P),"line"===r.type&&e.path&&e.path.length===r.path.length){r._targetPath=r.path.map(e=>[e[0],e[1]]),r._prevPath=e.path;for(let t=0;r.path.length>t;t++)r.path[t]=[e.path[t][0],e.path[t][1]];X=!0}else if("area"===r.type&&e.topPath&&e.bottomPath&&e.topPath.length===r.topPath.length&&e.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(e=>[e[0],e[1]]),r._targetBottomPath=r.bottomPath.map(e=>[e[0],e[1]]),r._prevTopPath=e.topPath,r._prevBottomPath=e.bottomPath;for(let t=0;r.topPath.length>t;t++)r.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;r.bottomPath.length>t;t++)r.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];X=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=e.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 L=n.get(P);if("point"===r.type)if(L){V.add(P);const e={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,L.x===e.x&&L.y===e.y&&L.r===e.r||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=L.x,r.y=L.y,r.r=null!==(d=L.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(L){V.add(P);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(g=r.style.opacity)&&void 0!==g?g:1,L.x===e.x&&L.y===e.y&&L.w===e.w&&L.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=L.x,r.y=L.y,r.w=null!==(f=L.w)&&void 0!==f?f:r.w,r.h=null!==(p=L.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(L){V.add(P);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,L.x===e.x&&L.y===e.y&&L.w===e.w&&L.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=L.x,r.y=L.y,r.w=null!==(b=L.w)&&void 0!==b?b:r.w,r.h=null!==(x=L.h)&&void 0!==x?x:r.h,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(L&&null!=L.openY){V.add(P);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(A=null===(j=r.style)||void 0===j?void 0:j.opacity)&&void 0!==A?A:1,(L.x!==e.x||L.openY!==e.openY||L.closeY!==e.closeY||L.highY!==e.highY||L.lowY!==e.lowY)&&(r._targetX=e.x,r._targetOpenY=e.openY,r._targetCloseY=e.closeY,r._targetHighY=e.highY,r._targetLowY=e.lowY,r.x=L.x,r.openY=L.openY,r.closeY=null!==(S=L.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(O=L.highY)&&void 0!==O?O:r.highY,r.lowY=null!==(M=L.lowY)&&void 0!==M?M:r.lowY,X=!0)}else r._targetOpacity=null!==(_=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==_?_:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0}for(const[e,t]of i)if(!U.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(P=t.opacity)&&void 0!==P?P:1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(n),X=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(L=t.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(n),X=!0}for(const[e,t]of n)if(!V.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(T=t.r)&&void 0!==T?T:3,style:{opacity:null!==(R=t.opacity)&&void 0!==R?R:1},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(B=t.w)&&void 0!==B?B:0,h:null!==(I=t.h)&&void 0!==I?I:0,style:{opacity:null!==(D=t.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(H=t.w)&&void 0!==H?H:0,h:null!==(N=t.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==($=t.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("c:")){const n=null!==(W=t.openY)&&void 0!==W?W:t.y,i={type:"candlestick",x:t.x,openY:n,closeY:null!==(F=t.closeY)&&void 0!==F?F:n,highY:null!==(E=t.highY)&&void 0!==E?E:n,lowY:null!==(z=t.lowY)&&void 0!==z?z:n,bodyWidth:null!==(Y=t.w)&&void 0!==Y?Y:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(G=t.opacity)&&void 0!==G?G:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(i)}X=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),X&&(o.activeTransition={startTime:Z(),duration:q}),o}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},o=function(e,t,o,n){var i,r,s,a,l,c;if(!o.activeTransition)return!1;const u=K(e,o.activeTransition),d=U(u,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of o.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style.opacity=Q(r,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),e.y=Q(o.y,e._targetY,d),void 0!==e._targetR&&void 0!==o.r&&(e.r=Q(o.r,e._targetR,d))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(r=o.opacity)&&void 0!==r?r:1:0;e.style.opacity=Q(i,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),e.y=Q(o.y,e._targetY,d),void 0!==o.w&&(e.w=Q(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Q(o.h,e._targetH,d))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(s=o.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Q(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),e.y=Q(o.y,e._targetY,d),void 0!==o.w&&(e.w=Q(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Q(o.h,e._targetH,d))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(a=o.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Q(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),void 0!==o.openY&&(e.openY=Q(o.openY,e._targetOpenY,d)),void 0!==o.closeY&&(e.closeY=Q(o.closeY,e._targetCloseY,d)),void 0!==o.highY&&(e.highY=Q(o.highY,e._targetHighY,d)),void 0!==o.lowY&&(e.lowY=Q(o.lowY,e._targetLowY,d))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Q(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevPath,o=e._targetPath;if(t&&o&&t.length===e.path.length)for(let n=0;e.path.length>n;n++)e.path[n][0]=Q(t[n][0],o[n][0],d),e.path[n][1]=Q(t[n][1],o[n][1],d)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(c=e._startOpacity)&&void 0!==c?c:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Q(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevTopPath,o=e._prevBottomPath,n=e._targetTopPath,i=e._targetBottomPath;if(t&&n&&t.length===e.topPath.length)for(let o=0;e.topPath.length>o;o++)e.topPath[o][0]=Q(t[o][0],n[o][0],d),e.topPath[o][1]=Q(t[o][1],n[o][1],d);if(o&&i&&o.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Q(o[t][0],i[t][0],d),e.bottomPath[t][1]=Q(o[t][1],i[t][1],d)}}if(u>=1){for(const e of o.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let o=0;e.path.length>o;o++)e.path[o]=t[o];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,o=e._targetBottomPath;if(t)for(let o=0;e.topPath.length>o;o++)e.topPath[o]=t[o];if(o)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=o[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}return o.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,o}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const o of e){const e=this.getGroup(o);t.has(e)||t.set(e,[]),t.get(e).push(o)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const t=new Set;for(const o of e){const e=this.getColor(o);e&&t.add(e)}const o=Array.from(t).sort(),n=o.join("\0");if(this._colorMapCache&&this._colorMapCache.key===n)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||F,r=new Map;for(let e=0;o.length>e;e++)r.set(o[e],i[e%i.length]);return this._colorMapCache={key:n,map:r,version:this._ingestVersion},r}resolveLineStyle(e,t){var o;const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}const i=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;return n&&"object"==typeof n?{stroke:n.stroke||i||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var o,n;if(this.config.areaStyle){const o=this.config.areaStyle(t||{});if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const i=this.config.lineStyle;if("function"==typeof i){const o=i(t||{},e);if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const r=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const o=(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)||F;if(0===o.length)return null;const n=o[this._groupColorCounter%o.length];if(this._groupColorCounter++,this._groupColorMap.set(e,n),this._groupColorMap.size>ce.GROUP_COLOR_MAP_CAP){const e=this._groupColorMap.keys().next().value;void 0!==e&&this._groupColorMap.delete(e)}return n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const o=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(e)),t);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),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.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(e){var t,o,n,i;const r=Object.assign({},this.config);("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let s=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==r.chartType||"runtimeMode"in e&&e.runtimeMode!==r.runtimeMode;if(a||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const l=a||!I(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(o=r.xAccessor)&&void 0!==o?o:r.timeAccessor),c=a||!I(null!==(n=e.yAccessor)&&void 0!==n?n:e.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=D(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=D(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=D(this.config.xAccessor,"x"),this.getY=D(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!I(e.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?N(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!I(e.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?N(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!I(e.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?D(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!I(e.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?N(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!I(e.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?D(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!I(e.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?N(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!I(e.openAccessor,r.openAccessor)||"closeAccessor"in e&&!I(e.closeAccessor,r.closeAccessor)||"highAccessor"in e&&!I(e.highAccessor,r.highAccessor)||"lowAccessor"in e&&!I(e.lowAccessor,r.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?D(this.config.openAccessor,"open"):void 0,this.getHigh=D(this.config.highAccessor,"high"),this.getLow=D(this.config.lowAccessor,"low"),this.getClose=t?D(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0}if(!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of t)if(e[o]!==r[o]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function ue(e,t,o){return o.x>e||e>o.x+o.w||o.y>t||t>o.y+o.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:o.x+o.w/2,cy:o.y+o.h/2}}function de(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function he(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ge(e,t){const o=he(e);if(!o)return!1;const n=he(t);return!n||o.getFullYear()!==n.getFullYear()||o.getMonth()!==n.getMonth()}function fe(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function pe(e,t,o,n,i){const r=Math.max(n,i+5,12),s=t-r,a=t+r,l=o-r,c=o+r;let u=null,d=1/0;return e.visit((e,i,r,h,g)=>{if(i>a||s>h||r>c||l>g)return!0;if(!e.length){let i=e;do{const e=i.data,r=e.x-t,s=e.y-o,a=Math.sqrt(r*r+s*s);de(e.r,n)>=a&&d>a&&(u=e,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}function ye(e,t,o,n=30,i,r=0){let s=null;if(i){const e=pe(i,t,o,n,r);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const r of e){let e=null;switch(r.type){case"point":if(i)break;e=me(r,t,o,n);break;case"line":e=be(r,t,o,n);break;case"rect":e=ke(r,t,o);break;case"heatcell":e=we(r,t,o);break;case"area":if(!1===r.interactive)break;e=Ae(r,t,o);break;case"candlestick":e=je(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function ve(e,t,o){if(0===e.length)return null;const n=Se(e,t);if(0>n)return null;if(Math.abs(e[n][0]-t)>o)return null;let i=n,r=n;n>0&&e[n][0]>=t?(i=n-1,r=n):e.length-1>n&&(i=n,r=n+1);const[s,a]=e[i],[l,c]=e[r];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function me(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>de(e.r,n)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function be(e,t,o,n=30){var i,r,s,a;if(0===e.path.length)return null;const l=Se(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let n=1/0;const i=Math.max(0,l-1),r=Math.min(e.path.length-2,l);for(let s=i;r>=s;s++){const[i,r]=e.path[s],[a,l]=e.path[s+1],c=xe(t,o,i,r,a,l);n>c&&(n=c)}d=n}else{const e=t-c,n=o-u;d=Math.sqrt(e*e+n*n)}const h=null!==(a=null!==(r=null===(i=e.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(s=e.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,n)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function xe(e,t,o,n,i,r){const s=i-o,a=r-n,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-o,2)+Math.pow(t-n,2));let c=((e-o)*s+(t-n)*a)/l;c=Math.max(0,Math.min(1,c));const u=n+c*a;return Math.sqrt(Math.pow(e-(o+c*s),2)+Math.pow(t-u,2))}function ke(e,t,o){const n=ue(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function we(e,t,o){const n=ue(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function je(e,t,o){const n=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-n-3>t||t>e.x+n+3||e.highY-3>o||o>e.lowY+3)){const n=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,s=o-n;return{node:e,datum:e.datum,x:e.x,y:n,distance:Math.sqrt(r*r+s*s)}}return null}function Ae(e,t,o){if(0===e.topPath.length)return null;const n=Se(e.topPath,t);if(0>n)return null;const[i,r]=e.topPath[n],s=t-i,a=o-r,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[n]?e.datum[n]:e.datum,x:i,y:r,distance:l}}function Se(e,t){if(0===e.length)return-1;let o=0,n=e.length-1;for(;n>o;){const i=o+n>>1;t>e[i][0]?o=i+1:n=i}return o>0&&Math.abs(e[o][0]-t)>=Math.abs(e[o-1][0]-t)?o-1:o}function Oe(e){var t,o;const n=new Map;for(const o of e){const e=null!==(t=o.group)&&void 0!==t?t:"_default";let i=n.get(e);i||(i=[],n.set(e,i)),i.push(o)}for(const e of n.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const i=Array.from(n.keys()).sort((e,t)=>{const o=n.get(e),i=n.get(t);return(o.length>0?o[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(n.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=null===(o=r[e].datum)||void 0===o?void 0:o.id;null!=t&&s.set(t+"",e)}return{flat:r,groups:i,byGroup:n,idToIdx:s}}function Me(e,t){var o,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[i];return{flatIndex:i,group:null!==(o=r.group)&&void 0!==o?o:"_default",indexInGroup:null!==(n=r._groupIndex)&&void 0!==n?n:0}}function Ce(e,t,o){const{group:n,indexInGroup:i}=t,r=o.byGroup.get(n);switch(e){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=o.groups.indexOf(n);return o.groups.length-1>e?_e(o,o.groups[e+1],r[i]):t.flatIndex}case"ArrowUp":{const e=o.groups.indexOf(n);return e>0?_e(o,o.groups[e-1],r[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*o.flat.length)),o.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*o.flat.length)),0);case"Home":return 0;case"End":return o.flat.length-1;case"Escape":return-1;default:return null}}function _e(e,t,o){const n=e.byGroup.get(t);let i=0,r=Math.abs(n[0].x-o.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-o.x);r>t&&(r=t,i=e)}return n[i]._flatIndex}function Pe(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function Le(e,o,n,i,r,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=o.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-a.lastIngestTime>c;u!==r&&(s(u),n.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}ce.GROUP_COLOR_MAP_CAP=1e3,ce.QUADTREE_THRESHOLD=500;const Te={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function Re(e,t,o,n){let i;return i="function"==typeof o?o(e):(0,Te[o])(n(e,t)),i}function Be(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Ie(e,t,o){return o&&o.size>0?o.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const De=(t,o,n,i,r,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:g}=t,f=[];let p=0;const y=!(!o&&!n),v="isolate"===u||void 0===u&&null!=r;return g.forEach((t,u)=>{const m=Re(t,u,d,h),b=Ie(t,i,r),x=r&&r.size>0&&r.has(t.label);f.push(e.jsxs("g",{transform:`translate(0,${p})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?l===s&&u===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&v?x||!1:void 0,"aria-current":y&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:y?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:y?e=>{c(l,u),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,x&&e.jsx(Be,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),p+=22}),f};function He({config:t,orientation:o="vertical",width:n=100}){const{colorFn:i,domain:r,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+y.useId();if("horizontal"===o){const t=12,o=Math.min(n,200),a=Math.max(0,(n-o)/2),u=[];for(let t=0;64>=t;t++){const o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[0]+o*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&e.jsx("text",{x:a+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:o,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),e.jsx("text",{x:a+o,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let t=0;64>=t;t++){const o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[1]-o*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function Ne(t){const{legendGroups:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,g]=y.useState(0),[f,p]=y.useState(0),v=y.useCallback((e,t)=>{g(e),p(t)},[]),m="vertical"===d?(({legendGroups:t,width:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,g)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:o,y2:d},"legend-top-line legend-symbol-"+g)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:De(t,n,i,r,s,a,l,g,c,u)},"legend-group-"+g)),d+=22*t.items.length+8}),h})({legendGroups:o||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:v,legendInteraction:a}):(({legendGroups:t,height:o,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const g=[];t.forEach((t,o)=>{let f=0;t.label&&(f+=16);const p=((t,o,n,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:g,items:f}=t,p=[];let y=0,v=0;const m=!(!o&&!n),b="isolate"===u||void 0===u&&null!=r;f.forEach((t,u)=>{const x=Re(t,u,h,g),k=Ie(t,i,r),w=r&&r.size>0&&r.has(t.label),j=26+7*t.label.length;d&&d>0&&y>0&&y+j>d&&(v++,y=0),p.push(e.jsxs("g",{transform:`translate(${y},${22*v})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?l===s&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?w||!1:void 0,"aria-current":m&&!b&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:m?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+f.length)%f.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:m?e=>{c(l,u),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.jsx(Be,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=j});let x=0,k=0;for(const e of f){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=v+1;return{items:p,offset:x,totalRows:w,totalHeight:22*w}})(t,i,r,s,a,l,c,o,u,d,n);f+=p.offset+5,g.push(Object.assign(Object.assign({label:t.label},p),{offset:f,totalRows:p.totalRows,totalHeight:p.totalHeight})),h+=f+12});let f=h>n?0:Math.max(0,(n-h)/2);const p=[];return g.forEach((n,i)=>{const r=t[i];r.label&&(p.push(e.jsx("text",{transform:`translate(${f},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)),f+=16),p.push(e.jsx("g",{className:"legend-item",transform:`translate(${f},0)`,children:n.items},"legend-group-"+i)),f+=n.offset+5,t[i+1]&&p.push(e.jsx("line",{stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+i)),f+=12}),e.jsx("g",{children:p})})({legendGroups:o||[],title:l,height:u,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:v,legendInteraction:a}),b=!(!n&&!i);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"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&&e.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}),m]})}function $e(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function We(e){return"object"==typeof e&&null!==e&&"gradient"in e}function Fe(t){const{legend:o,totalWidth:n,totalHeight:i,margin:r,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!o)return null;const g="top"===s||"bottom"===s;let f,p;return"left"===s?(f=4,p=r.top):"top"===s?(f=0,p=a?32:8):"bottom"===s?(f=0,p=i-r.bottom+50):(f=n-r.right+10,p=r.top),e.jsx("g",{transform:`translate(${f}, ${p})`,children:We(o)?e.jsx(He,{config:o.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):$e(o)?e.jsx(Ne,{legendGroups:o.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):o})}function Ee(e){return"string"==typeof e?{type:e}:e}function ze({orient:o,config:n,values:i,scale:r,size:s,length:l}){const c=function(e){var t,o,n,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(o=e.fill)&&void 0!==o?o:"#4e79a7",fillOpacity:null!==(n=e.fillOpacity)&&void 0!==n?n:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),u="top"===o||"bottom"===o,d=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=s-8;if("boxplot"===c.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),o=t.length;if(0===o)return null;const n=t[Math.floor(.25*o)],i=t[Math.floor(.5*o)],r=t[Math.floor(.75*o)],s=r-n;return{q1:n,median:i,q3:r,whiskerLow:Math.max(t[0],n-1.5*s),whiskerHigh:Math.min(t[o-1],r+1.5*s)}}(i);if(!t)return null;const{q1:s,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=t,g=Math.min(.5*n,20),f=(n-g)/2+4;if(u){const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="top"===o?-1:1,v=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:u,y1:v+y*(f+g/2),x2:p,y2:v+y*(f+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:v+y*f,x2:u,y2:v+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:p,y1:v+y*f,x2:p,y2:v+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,n),y:"top"===o?v-f-g:v+f,width:Math.abs(n-t),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:i,y1:"top"===o?v-f-g:v+f,x2:i,y2:"top"===o?v-f:v+f+g,stroke:c.fill,strokeWidth:2})]})}{const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="left"===o?-1:1,v=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:v+y*(f+g/2),y1:u,x2:v+y*(f+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:v+y*f,y1:u,x2:v+y*(f+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:v+y*f,y1:p,x2:v+y*(f+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===o?v-f-g:v+f,y:Math.min(t,n),width:g,height:Math.abs(n-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===o?v-f-g:v+f,y1:i,x2:"left"===o?v-f:v+f+g,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=a.bin().domain(t).thresholds(c.bins)(i);if(0===d.length)return null;const h=Math.max(...d.map(e=>e.length));if(0===h)return null;if("histogram"===c.type)return e.jsx("g",{"data-testid":"marginal-histogram-"+o,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const s=t.length/h*n;if(u){const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:n,y:"top"===o?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:"left"===o?-4-s:4,y:Math.min(n,n+a),width:s,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const t=n/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(n/2),a=r((e.x0+e.x1)/2);i.push(u?`${a},${"top"===o?-(t-s):t-s}`:`${"left"===o?-(t-s):t-s},${a}`)}for(let e=d.length-1;e>=0;e--){const s=d[e];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===o?-(t+a):t+a}`:`${"left"===o?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+o,children:e.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 t=[];if(u){const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${i},${e}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*n,s=r((e.x0+e.x1)/2);t.push(`L${s},${"top"===o?-i-4:i+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${s},${e}`),t.push("Z")}else{const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${e},${i}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*n,s=r((e.x0+e.x1)/2);t.push(`L${"left"===o?-i-4:i+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${e},${s}`),t.push("Z")}return e.jsx("g",{"data-testid":"marginal-ridgeline-"+o,children:e.jsx("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,r,c,s,l,o,u,4]);return d?e.jsx("g",{className:"marginal-"+o,"data-testid":"marginal-"+o,children:d}):null}function Ye(e,t=120,o=8){if(!e)return[];const n=Math.max(1,Math.floor(t/o)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>n?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function Ge(e,t,o,n){return"curly"===e?n?`M0,0 C${.6*o},0 ${.4*o},${t/2} ${o},${t/2} C${.4*o},${t/2} ${.6*o},${t} 0,${t}`:`M0,0 C0,${.6*o} ${t/2},${.4*o} ${t/2},${o} C${t/2},${.4*o} ${t},${.6*o} ${t},0`:n?`M0,0 L${o},0 L${o},${t} L0,${t}`:`M0,0 L0,${o} L${t},${o} L${t},0`}function qe(t,o,n,i){if(!t)return e.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=t;if(!r&&!s)return e.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(o)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>o?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>o?"end":"start";const f=16,p=s?u?[s]:Ye(s,c):[],y=r?u?[r]:Ye(r,c):[],v="leftRight"===d?"end"===g?-4:4:0;let m=0;const b=[],x=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold",children:p.map((t,o)=>e.jsx("tspan",{x:v,dy:0===o?0:f,children:t},o))},"annotation-note-title")),m=p.length*f),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:g,y:m,children:y.map((t,o)=>e.jsx("tspan",{x:v,dy:0===o?0:f,children:t},o))},"annotation-note-label"));let k=null;if((s||r)&&(0!==o||0!==n))if("topBottom"===d){const t=Math.min(c,120);let o=0,n=t;"end"===g?(o=-t,n=0):"middle"===g&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:o,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let o=0,n=t;"bottom"===h?(o=-t,n=0):"middle"===h&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:o,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let j=0;return"topBottom"===d?j=0>n?-(w+2):18:"leftRight"===d&&(j="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(w+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${o},${n})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==j?`translate(0,${j})`:void 0,children:b}),k]})}function Xe(t,o,n,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==o?void 0:o.radius)||0)+((null==o?void 0:o.radiusPadding)||0);t>0&&a.push(e.jsx("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==o?void 0:o.width)||0,i=(null==o?void 0:o.height)||0;(t>0||i>0)&&a.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==o?void 0:o.custom)&&a.push(...Array.isArray(o.custom)?o.custom:[o.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==o?void 0:o.x)){const i=(o.x||0)-t;a.push(e.jsx("line",{x1:i,y1:(o.y1||0)-s,x2:i,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==o?void 0:o.y)){const i=(o.y||0)-s;a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:i,x2:(o.x2||0)-t,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==o?void 0:o.x1)||void 0!==(null==o?void 0:o.x2)?a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:0,x2:(o.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==o?void 0:o.y1)&&void 0===(null==o?void 0:o.y2)||a.push(e.jsx("line",{x1:0,y1:(o.y1||0)-s,x2:0,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==o?void 0:o.width)&&void 0!==s?s:null==o?void 0:o.height;void 0!==t&&a.push(e.jsx("path",{d:Ge((null==o?void 0:o.type)||"curly",t,(null==o?void 0:o.depth)||30,void 0===(null==o?void 0:o.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function Ve(t,o,n,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 e=s.width||0,n=s.height||0;if(e>0||n>0){const i=e/2,r=n/2,s=t-i,a=o-r;if(0!==s||0!==a){const t=Math.abs(s),o=Math.abs(a),u=e/2,d=n/2,h=t*d>o*u?u/t:d/o;l=i+s*h,c=r+a*h}}}else if("bracket"===r&&s){const e=s.width,t=s.height,o=s.depth||30;void 0!==e?(l=e/2,c=o):void 0!==t&&(l=o,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==o)){const n=Math.atan2(o,t);l=Math.cos(n)*e,c=Math.sin(n)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(o-c,2))>.5&&(a.push(e.jsx("line",{x1:l,y1:c,x2:t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,s=Math.atan2(o-c,t-l);a.push(e.jsx("path",{d:`M${l},${c}L${l+n*Math.cos(s+r)},${c+n*Math.sin(s+r)}L${l+n*Math.cos(s-r)},${c+n*Math.sin(s-r)}Z`,fill:i||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return e.jsx("g",{className:"annotation-connector",children:a})}function Ue(t){const{x:o=0,y:n=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:f,events:p={},"data-testid":y}=t,v=new Set(Array.isArray(f)?f:[]);let m=i||0,b=r||0;null!=s&&(m=s-o),null!=a&&(b=a-n);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===m&&0===b)if(void 0!==u.width){m=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;m=e+(0>e?-5:5),b=u.height/2}return e.jsxs("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${o},${n})`,"data-testid":y},p,{children:[!v.has("connector")&&Ve(m,b,c,h,x,u),!v.has("subject")&&Xe(x,u,h,o,n),!v.has("note")&&qe(l,m,b,h)]}))}function Ke(t){var o,n;const{noteData:i}=t,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(o=i.dx)&&void 0!==o?o:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((o,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:o[0],y:o[1],nx:t,ny:a});return e.jsx(Ue,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+n)});return e.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return e.jsx(Ue,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Qe(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time;return r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function Ze(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.value;return r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function Je(e,t,o){var n,i,r,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let i=o.pointNodes.length-1;i>=0;i--){const r=o.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(n=o.stickyPositionCache)||void 0===n||n.set(t,e),e}}const r=function(e){var t,o,n,i,r,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(o=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==o?o:null===(n=e.scales)||void 0===n?void 0:n.time,u=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(o);return r&&(null===(i=o.stickyPositionCache)||void 0===i||i.set(t,r)),r}let l=null,c=null;if(null!=e.pointId&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Qe(e,o),c=Ze(e,o)),null!=l&&null!=c)return null===(r=o.stickyPositionCache)||void 0===r||r.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=o.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function et(e,t,o,n=50){return!(-n>e||e>(o.width||0)+n||-n>t||t>(o.height||0)+n)}const tt={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};function ot(t){return function(t,o,n){var i,r,s,a,u,d,h,g,f,p,y,m,b,x,k,w,j,A,S,O,M,C,_,P,L,T,R,B,I,D,H,N,$,W,F,E,z,Y,G,q,X,V,U,K,Q,Z,J,ee;switch(t.type){case"label":{const i=Je(t,o,n);if(!i)return null;const{x:r,y:s}=i;return et(r,s,n)?e.jsx(Ke,{noteData:{x:r,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}},"ann-"+o):null}case"callout":{const i=Je(t,o,n);if(!i)return null;const{x:r,y:s}=i;return et(r,s,n)?e.jsx(Ke,{noteData:{x:r,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}},"ann-"+o):null}case"x-threshold":{const i=Qe(t,n);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(n.height||0)-4:"center"===s?(n.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:i+4,y:a,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+o)}case"y-threshold":{const i=Ze(t,n);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(n.width||0)/2,l="middle"):(a=(n.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+o)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Qe(Object.assign(Object.assign({},e),{type:"point"}),n),y:Ze(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=l.packEnclose(i),s=t.padding||10;return e.jsxs("g",{children:[e.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+o)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Qe(Object.assign(Object.assign({},e),{type:"point"}),n),y:Ze(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,s=i.map(e=>e.x),a=i.map(e=>e.y),l=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...a)-r,d=Math.max(...a)+r;return e.jsxs("g",{children:[e.jsx("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+o)}case"highlight":{const i=n.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],s={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.jsx("g",{children:r.map((o,i)=>{const r=Qe(o,n),a=Ze(o,n);if(null==r||null==a)return null;const l="function"==typeof t.r?t.r(o):t.r||6,c="function"==typeof t.style?t.style(o):t.style||s;return e.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+o)}case"bracket":{const i=Qe(t,n),r=Ze(t,n);return e.jsx(Ke,{noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+o)}case"trend":{const l=n.data||[];if(2>l.length)return null;const c=n.xAccessor||"x",g=n.yAccessor||"y",f=l.map(e=>[e[c],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const p=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(s=n.scales)||void 0===s?void 0:s.time,y=null!==(u=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==u?u:null===(d=n.scales)||void 0===d?void 0:d.value;if(!p||!y)return null;const m=t.method||"linear";let b;b="loess"===m?function(e,t=.3){const o=e.length;if(2>o)return e.slice();const n=e.slice().sort((e,t)=>e[0]-t[0]),i=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.max(2,Math.ceil(t*o)),a=[];for(let e=0;o>e;e++){const t=i[e],n=i.map(e=>Math.abs(e-t)),l=n.slice().sort((e,t)=>e-t)[Math.min(s-1,o-1)]||1,c=[];for(let e=0;o>e;e++){const t=0===l?0:n[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;o>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],g+=t*i[e]*i[e],f+=t*i[e]*r[e])}if(0===u){a.push([t,r[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))a.push([t,h/u]);else{const e=(u*f-d*h)/p;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?v.default.polynomial(f,{order:t.order||2}):v.default.linear(f)).points;const x=b.map(([e,t])=>`${p(e)},${y(t)}`).join(" "),k=t.color||"#6366f1";return e.jsxs("g",{children:[e.jsx("polyline",{points:x,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:p(b[b.length-1][0])+4,y:y(b[b.length-1][1])-4,fill:k,fontSize:11,children:t.label})]},"ann-"+o)}case"band":{const i=null!==(f=null===(g=n.scales)||void 0===g?void 0:g.y)&&void 0!==f?f:null===(p=n.scales)||void 0===p?void 0:p.value,r=null!==(y=null==i?void 0:i(t.y0))&&void 0!==y?y:0,s=null!==(m=null==i?void 0:i(t.y1))&&void 0!==m?m:n.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,s),width:n.width||0,height:Math.abs(s-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+o)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",s=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(j=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==j?j:null===(A=n.scales)||void 0===A?void 0:A.value;if(!s||!a)return null;const l=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=i.filter(e=>null!=e[l]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=tt[n.curve||"linear"]||c.curveLinear,f=c.area().x(e=>s(e[r])).y0(e=>a(e[u])).y1(e=>a(e[l])).curve(g)(h);if(!f)return null;const p=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:f,fill:p,fillOpacity:null!==(S=t.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:s(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",s=null!==(M=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==M?M:null===(C=n.scales)||void 0===C?void 0:C.time,a=null!==(P=null===(_=n.scales)||void 0===_?void 0:_.y)&&void 0!==P?P:null===(L=n.scales)||void 0===L?void 0:L.value;if(!s||!a)return null;const l=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(T=t.threshold)&&void 0!==T?T:2,g=c-h*d,f=!1!==t.showBand,p=t.fill||"#6366f1",y=null!==(R=t.fillOpacity)&&void 0!==R?R:.1,v=t.anomalyColor||"#ef4444",m=null!==(B=t.anomalyRadius)&&void 0!==B?B:6,b=a(c+h*d),x=a(g),k=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>h*d});return e.jsxs("g",{children:[f&&e.jsx("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((t,o)=>{const i=Qe(t,n),r=Ze(t,n);return null==i||null==r?null:e.jsx("circle",{cx:i,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+o)}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",s=n.yAccessor||"y",a=null!==(D=null===(I=n.scales)||void 0===I?void 0:I.x)&&void 0!==D?D:null===(H=n.scales)||void 0===H?void 0:H.time,l=null!==($=null===(N=n.scales)||void 0===N?void 0:N.y)&&void 0!==$?$:null===(W=n.scales)||void 0===W?void 0:W.value;if(!a||!l)return null;const c=i.map(e=>[e[r],e[s]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear")){const e=v.default.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,o,n)=>e+o*Math.pow(t,n),0)}else{const e=c.length;let t=0,o=0,n=0,i=0;for(const[e,r]of c)t+=e,o+=r,n+=e*e,i+=e*r;const r=e*n-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*o)/r,a=(o-s*t)/e;u=e=>a+s*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(d-2,1)),f=c.reduce((e,t)=>e+t[0],0)/d,p=c.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),y=null!==(F=t.confidence)&&void 0!==F?F:.95,m=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,b=null!==(E=t.steps)&&void 0!==E?E:5,x=c[d-1][0],k=(x-c[0][0])/Math.max(d-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const j=[];for(const e of w){const t=u(e),o=g*Math.sqrt(1+1/d+(p>0?Math.pow(e-f,2)/p:0))*m;j.push({x:e,yCenter:t,yUpper:t+o,yLower:t-o})}const A=`M${j.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${j.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=j.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),O=`${a(x)},${l(u(x))}`,M=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(z=t.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),e.jsx("polyline",{points:`${O} ${S}`,fill:"none",stroke:M,strokeWidth:null!==(Y=t.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&j.length>0&&e.jsx("text",{x:a(j[j.length-1].x)+4,y:l(j[j.length-1].yCenter)-4,fill:M,fontSize:11,children:t.label})]},"ann-"+o)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=Je(t,o,n);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!et(i,r,n))return null;const s=null!==(q=t.dx)&&void 0!==q?q:0,a=null!==(X=t.dy)&&void 0!==X?X:0,l=null!==(V=t.width)&&void 0!==V?V:32,c=null!==(U=t.height)&&void 0!==U?U:32,u=null!==(K=t.content)&&void 0!==K?K:e.jsx("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return e.jsx("foreignObject",{x:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:e.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const i=Je(t,o,n);if(!i)return null;const{x:r,y:s}=i;return e.jsx("text",{x:r+(t.dx||0),y:s+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label},"ann-text-"+o)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=null===(Q=n.scales)||void 0===Q?void 0:Q.o,s=null===(Z=n.scales)||void 0===Z?void 0:Z.x,a=null===(J=n.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=t.color||"var(--semiotic-primary, #4589ff)",h=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,g=t.label;return e.jsxs("g",(n.projection?"vertical"===n.projection:l===s)?{children:[e.jsx("rect",{x:c,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),g&&e.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:g})]}:{children:[e.jsx("rect",{x:0,y:c,width:n.width||0,height:u,fill:d,fillOpacity:h}),g&&e.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+o)}default:return null}}}let nt={positions:new Map};const it=new Set;function rt(){for(const e of it)e()}function st(e,t){const o=nt.positions.get(e);if(null==o?void 0:o.locked)return;if(!o||o.sourceId!==t)return;const n=new Map(nt.positions);n.delete(e),nt={positions:n},rt()}function at(e,t){const o=nt.positions.get(e);if(!(null==o?void 0:o.locked))return;if(t&&o.sourceId!==t)return;const n=new Map(nt.positions);n.delete(e),nt={positions:n},rt()}function lt(){return nt}function ct(e){return it.add(e),()=>it.delete(e)}const ut={positions:new Map};function dt(){return()=>{}}function ht(){return ut}function gt(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function ft(e,t,o){if("left"===e||"right"===e){const n="left"===e?o:0,i="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+n;for(let e=0;r>e;e++){const o=8*(e+1);s+=`L${Math.min(8*e+4,t)},${n+4*i}`,s+=`L${Math.min(o,t)},${n}`}return s}{const n="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(o/8);let s=`M${n},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${n+4*i},${Math.min(8*e+4,o)}`,s+=`L${n},${Math.min(t,o)}`}return s}}function pt(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:g}=o,f=t.useMemo(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||yt,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,r=l.x.ticks(Math.min(i,Math.max(2,Math.floor(n/70)))),s=r.map(e=>e.valueOf()),a=r.map((e,t)=>({value:e,pixel:l.x(e),label:o(e,t,s)})),c=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return vt(a,Math.max(55,c+8))},[l,u,h,n]),p=t.useMemo(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"left"===e.orient),o=(null==t?void 0:t.tickFormat)||g||yt,n=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return vt(l.y.ticks(Math.min(n,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:l.y(e),label:o(e)})),22)},[l,u,g,i]),y=d&&l,v=c&&l;if(!y&&!v)return null;const m=null==u?void 0:u.find(e=>"bottom"===e.orient),b=null==u?void 0:u.find(e=>"left"===e.orient),x=v&&(!m||!1!==m.baseline),k=v&&(!b||!1!==b.baseline),w=(null==m?void 0:m.jaggedBase)||!1,j=(null==b?void 0:b.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return e.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[y&&(()=>{var t,o;const r=gt(null===(t=null==u?void 0:u.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),s=gt(null===(o=null==u?void 0:u.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[f.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+o)),p.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+o))]})})(),x&&!w&&e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&e.jsx("path",{d:ft("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!j&&e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),j&&e.jsx("path",{d:ft("left",n,i),fill:"none",stroke:A,strokeWidth:1})]})})}function yt(e,t,o){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function vt(e,t){if(2>=e.length)return e;const o=[e[0]];for(let n=1;e.length-1>n;n++)t>Math.abs(e[n].pixel-o[o.length-1].pixel)||o.push(e[n]);const n=e[e.length-1];return t>Math.abs(n.pixel-o[o.length-1].pixel)?o[o.length-1]=n:o.push(n),o}function mt(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,axes:h,xLabel:g,yLabel:f,yLabelRight:p,xFormat:y,yFormat:v,showGrid:m,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:j,legendIsolatedCategories:A,legendPosition:S="right",foregroundGraphics:O,marginalGraphics:M,xValues:C,yValues:_,annotations:P,svgAnnotationRules:L,xAccessor:T,yAccessor:R,annotationData:B,pointNodes:I,curve:D,underlayRendered:H,linkedCrosshairName:N,linkedCrosshairSourceId:$,children:W}=o,F=t.useMemo(()=>{var e;if(!d||!u)return[];const t=null==h?void 0:h.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||y||yt,n=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=u.x.ticks(Math.min(n,Math.max(2,Math.floor(r/70)))),s=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:u.x(e),label:o(e,t,s)})),l=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let g=vt(a,c);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),(null==t?void 0:t.includeMax)&&g.length>0){const e=u.x.domain()[1],t=u.x(e),n=g[g.length-1].pixel;if(Math.abs(t-n)>1){const i=o(e,g.length,s);c>t-n&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:i})}}return g},[d,u,h,y,r]),E=t.useMemo(()=>{var e;if(!d||!u)return[];const t=null==h?void 0:h.find(e=>"left"===e.orient),o=(null==t?void 0:t.tickFormat)||v||yt,n=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let i=vt(u.y.ticks(Math.min(n,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:u.y(e),label:o(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),(null==t?void 0:t.includeMax)&&i.length>0){const e=u.y.domain()[1],t=u.y(e),n=i[i.length-1].pixel;if(Math.abs(t-n)>1){const r=o(e);22>Math.abs(t-n)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:t,label:r})}}return i},[d,u,h,v,s]),z=t.useMemo(()=>{var e;if(!d||!u)return[];const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t)return[];const o=t.tickFormat||v||yt,n=null!==(e=t.ticks)&&void 0!==e?e:5;return vt(u.y.ticks(Math.min(n,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:u.y(e),label:o(e)})),22)},[d,u,h,v,s]),Y=t.useRef(new Map),G=t.useRef(null!==(n=null==P?void 0:P.length)&&void 0!==n?n:0),q=null!==(i=null==P?void 0:P.length)&&void 0!==i?i:0;G.current!==q&&(G.current=q,Y.current=new Map);const X=t.useMemo(()=>{if(!P||0===P.length)return null;const e=ot(),t={scales:u?{x:u.x,y:u.y,time:u.x,value:u.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:r,height:s,data:B,frameType:"xy",pointNodes:I,curve:D,stickyPositionCache:Y.current};return P.map((o,n)=>{if(L){const i=L(o,n,t);return null!=i?i:e(o,n,t)}return e(o,n,t)}).filter(Boolean)},[P,L,r,s,T,R,B,u,I,D]),V=function(e){var o;const n=t.useSyncExternalStore(e?ct:dt,e?lt:ht,e?lt:ht);return e&&null!==(o=n.positions.get(e))&&void 0!==o?o:null}(N);return t.useEffect(()=>{if(!(null==V?void 0:V.locked)||!N)return;const e=e=>{"Escape"===e.key&&at(N)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==V?void 0:V.locked,N]),d||b||x||O||M||X&&X.length>0||m||W||V?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof b?b:"XY Chart"}),e.jsx("desc",{children:"string"==typeof b?b+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[m&&u&&!H&&(()=>{var t,o;const n=gt(null===(t=null==h?void 0:h.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=gt(null===(o=null==h?void 0:h.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[F.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"xgrid-"+o)),E.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+o))]})})(),d&&u&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),o=null==h?void 0:h.find(e=>"bottom"===e.orient),n=!t||!1!==t.baseline,i=!o||!1!==o.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==o?void 0:o.jaggedBase)||!1,u=null==o?void 0:o.landmarkTicks,d=null==t?void 0:t.landmarkTicks,y="var(--semiotic-border, #ccc)",v="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",b=!!(null==o?void 0:o.autoRotate)&&F.length>1&&(()=>{const e=r/Math.max(F.length-1,1);return F.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!H&&i&&!l&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:y,strokeWidth:1}),!H&&l&&e.jsx("path",{d:ft("bottom",r,s),fill:"none",stroke:y,strokeWidth:1}),F.map((t,o)=>{const n=!!u&&("function"==typeof u?u(t.value,o):ge(t.value,o>0?F[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:v,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0,children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"xtick-"+o)}),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:m,style:{userSelect:"none"},children:g}),!H&&n&&!a&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:y,strokeWidth:1}),!H&&a&&e.jsx("path",{d:ft("left",r,s),fill:"none",stroke:y,strokeWidth:1}),E.map((t,o)=>{const n=!!d&&("function"==typeof d?d(t.value,o):ge(t.value,o>0?E[o-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:v,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-"+o)}),(()=>{const o=(null==t?void 0:t.label)||f;return o?e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fontSize:12,fill:m,transform:`rotate(-90, ${15-c.left}, ${s/2})`,style:{userSelect:"none"},children:o}):null})(),(()=>{const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t||0===z.length)return null;const o=t.landmarkTicks,n=t.label||p;return e.jsxs(e.Fragment,{children:[!1!==t.baseline&&e.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:y,strokeWidth:1}),z.map((t,n)=>{const i=!!o&&("function"==typeof o?o(t.value,n):ge(t.value,n>0?z[n-1].value:void 0));return e.jsxs("g",{transform:`translate(${r},${t.pixel})`,children:[e.jsx("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:v,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-r-"+n)}),n&&e.jsx("text",{x:r+c.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:m,transform:`rotate(90, ${r+c.right-15}, ${s/2})`,style:{userSelect:"none"},children:n})]})})()]})})(),X,M&&u&&C&&_&&e.jsxs(e.Fragment,{children:[M.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(ze,{orient:"top",config:Ee(M.top),values:C,scale:u.x,size:c.top,length:r})}),M.bottom&&e.jsx("g",{transform:`translate(0, ${s})`,children:e.jsx(ze,{orient:"bottom",config:Ee(M.bottom),values:C,scale:u.x,size:c.bottom,length:r})}),M.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(ze,{orient:"left",config:Ee(M.left),values:_,scale:u.y,size:c.left,length:s})}),M.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx(ze,{orient:"right",config:Ee(M.right),values:_,scale:u.y,size:c.right,length:s})})]}),O,V&&V.sourceId!==$&&(null==u?void 0:u.x)&&(()=>{const t=u.x(V.xValue);if(null==t||0>t||t>r)return null;const o=V.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),W]}),b&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof b?b:null}),Fe({legend:x,totalWidth:a,totalHeight:l,margin:c,legendPosition:S,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:j,legendIsolatedCategories:A})]}):null}function bt(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const xt="undefined"==typeof window||"undefined"==typeof document,kt=y.createContext(null);function wt({children:t}){const[o,n]=y.useState(!1),i=y.useMemo(()=>({visible:o,setVisible:n}),[o]);return e.jsx(kt.Provider,{value:i,children:t})}function jt(){return y.useContext(kt)}const At={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function St(e,t){if(!e||0===e.length)return t+", empty";const o={};for(const t of e)o[t.type]=(o[t.type]||0)+1;const n=[],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(o).sort((e,t)=>{const o=r.indexOf(e),n=r.indexOf(t);return(-1===o?999:o)-(-1===n?999:n)});for(const e of s)n.push(`${o[e]} ${i[e]||e}`);return`${t}, ${n.join(", ")}`}function Ot(e,t,o){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?o+", empty":`${o}, ${n.join(", ")}`}const Mt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Ct={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"},_t={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Pt={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)"},Lt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Tt={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)"},Rt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Bt={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function It({scene:t,chartType:o,tableId:n,chartTitle:i}){var r;const[s,a]=y.useState(!1),l=jt(),c=null!==(r=null==l?void 0:l.visible)&&void 0!==r&&r,u=s||c,d=y.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${o} ${n}`:"Data summary for "+o,g=y.useCallback(()=>{s||c||a(!0)},[s,c]),f=y.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[c]);if(!t||0===t.length)return n?e.jsx("span",{id:n,tabIndex:-1,style:At}):null;if(!u)return e.jsx("div",{id:n,tabIndex:-1,onFocus:g,style:At,role:"region","aria-label":h,children:e.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",t.length," elements)"]})});const p=function(e){var t,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,v,m,b,x,k,w,j,A,S;const O=[];if(!Array.isArray(e))return O;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":O.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&O.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&O.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},r=null!==(o=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==o?o:"",s=null!==(i=null!==(n=e.value)&&void 0!==n?n:e.__aggregateValue)&&void 0!==i?i:e.total;O.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":O.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":O.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=M.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=M.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":O.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":O.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(v=M.cx)&&void 0!==v?v:M.x,y:null!==(m=M.cy)&&void 0!==m?m:M.y}});break;case"candlestick":O.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":O.push({label:"Region",values:{name:null!==(j=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==j?j:"",value:null!==(S=null===(A=M.datum)||void 0===A?void 0:A.value)&&void 0!==S?S:""}})}}catch(e){}return O}(t),v=function(e){if(!e||0===e.length)return[];const t=new Set;for(const o of e)if(o&&o.values)for(const e of Object.keys(o.values))t.add(e);const o=[];for(const n of t){const t=[],i=new Set;for(const o of e){if(!o||!o.values)continue;const e=o.values[n];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],r=0;for(const o of t)e>o&&(e=o),o>i&&(i=o),r+=o;o.push({name:n,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);o.push({name:n,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return o}(p),m=function(e,t){const o=[e+" data points."];for(const e of t)if(e.numeric)o.push(`${e.name}: ${Mt(e.min)} to ${Mt(e.max)}, mean ${Mt(e.mean)}.`);else{const t=e.uniqueValues,n=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");o.push(`${e.name}: ${n}.`)}return o.join(" ")}(p.length,v),b=p.slice(0,5),x=new Set;for(const e of b)for(const t of Object.keys(e.values))x.add(t);const k=Array.from(x);return e.jsxs("div",{ref:d,id:n,tabIndex:-1,onBlur:f,style:Ct,role:"region","aria-label":h,children:[e.jsx("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Pt,children:"×"}),e.jsx("div",{role:"note",style:_t,children:m}),e.jsxs("table",{role:"table","aria-label":"Sample data for "+o,style:Lt,children:[e.jsxs("caption",{style:Bt,children:["First ",b.length," of ",p.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Tt,children:"type"}),k.map(t=>e.jsx("th",{style:Tt,children:t},t))]})}),e.jsx("tbody",{children:b.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:Rt,children:t.label}),k.map(o=>{return e.jsx("td",{style:Rt,children:(n=t.values[o],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Mt(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},o);var n})]},o))})]})]})}function Dt({nodes:t,edges:o,chartType:n,tableId:i,chartTitle:r}){var s,a,l,c,u,d,h,g,f,p,v,m,b,x;const[k,w]=y.useState(!1),j=jt(),A=null!==(s=null==j?void 0:j.visible)&&void 0!==s&&s,S=k||A,O=r?"Data summary for "+r:i?`Data summary for ${n} ${i}`:"Data summary for "+n,M=y.useRef(null),C=y.useCallback(()=>{k||A||w(!0)},[k,A]),_=y.useCallback(e=>{var t;A||(null===(t=M.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[A]);if(!t||0===t.length)return i?e.jsx("span",{id:i,tabIndex:-1,style:At}):null;if(!S)return e.jsx("div",{id:i,tabIndex:-1,onFocus:C,style:At,role:"region","aria-label":O,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",o.length," edges)"]})});const P=Array.isArray(t)?t:[],L=Array.isArray(o)?o:[],T=new Map,R=new Map,B=new Map,I=new Map;for(const e of L){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,o="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=o&&""!==o){const e=o+"";R.set(e,(null!==(u=R.get(e))&&void 0!==u?u:0)+1),I.set(e,(null!==(d=I.get(e))&&void 0!==d?d:0)+i)}if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(h=T.get(e))&&void 0!==h?h:0)+1),B.set(e,(null!==(g=B.get(e))&&void 0!==g?g:0)+i)}}const D=[];for(let e=0;P.length>e;e++){const t=P[e];if(!t||"object"!=typeof t)continue;const o=null!==(p=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==p?p:t.id,n=null!=o?o+"":"node-"+e,i=null!==(v=T.get(n))&&void 0!==v?v:0,r=null!==(m=R.get(n))&&void 0!==m?m:0,s=null!==(b=B.get(n))&&void 0!==b?b:0,a=null!==(x=I.get(n))&&void 0!==x?x:0;D.push({id:n,degree:i+r,inDeg:i,outDeg:r,wDegree:s+a,wInDeg:s,wOutDeg:a})}D.sort((e,t)=>t.degree-e.degree);let H=0,N=0;if(D.length>0){let e=0;for(const t of D)e+=t.degree,t.degree>N&&(N=t.degree);H=e/D.length}const $=L.some(e=>{var t;const o=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==o?void 0:o.value)&&Number.isFinite(o.value)}),W=[`${D.length} nodes, ${L.length} edges.`];D.length>0&&W.push(`Mean degree: ${Mt(H)}, max degree: ${N}.`);const F=D.slice(0,5);return e.jsxs("div",{ref:M,id:i,tabIndex:-1,onBlur:_,style:Ct,role:"region","aria-label":O,children:[e.jsx("button",{type:"button",onClick:()=>{A&&j&&j.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:Pt,children:"×"}),e.jsx("div",{role:"note",style:_t,children:W.join(" ")}),e.jsxs("table",{role:"table","aria-label":"Node degree summary for "+n,style:Lt,children:[e.jsxs("caption",{style:Bt,children:["Top ",F.length," of ",D.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Tt,children:"id"}),e.jsx("th",{style:Tt,children:"degree"}),e.jsx("th",{style:Tt,children:"in"}),e.jsx("th",{style:Tt,children:"out"}),$&&e.jsx("th",{style:Tt,children:"w. degree"}),$&&e.jsx("th",{style:Tt,children:"w. in"}),$&&e.jsx("th",{style:Tt,children:"w. out"})]})}),e.jsx("tbody",{children:F.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:Rt,children:t.id}),e.jsx("td",{style:Rt,children:t.degree}),e.jsx("td",{style:Rt,children:t.inDeg}),e.jsx("td",{style:Rt,children:t.outDeg}),$&&e.jsx("td",{style:Rt,children:Mt(t.wDegree)}),$&&e.jsx("td",{style:Rt,children:Mt(t.wInDeg)}),$&&e.jsx("td",{style:Rt,children:Mt(t.wOutDeg)})]},o))})]})]})}function Ht({summary:t}){return t?e.jsx("div",{role:"note",style:At,children:t}):null}function Nt({tableId:t}){return e.jsx("a",{href:"#"+t,style:At,onClick:e=>{e.preventDefault();const o=document.getElementById(t);o&&requestAnimationFrame(()=>o.focus())},onFocus:e=>{Object.assign(e.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:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,At)},children:"Skip to data table"})}function $t({hoverPoint:t}){let o="";if(t){const e=t.data||t;o="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:At,children:o})}const Wt="var(--semiotic-focus, #005fcc)";function Ft({active:t,hoverPoint:o,margin:n,size:i,shape:r="circle",width:s,height:a}){if(!t||!o)return null;const l=o.x+n.left,c=o.y+n.top;let u;if("rect"===r&&null!=s&&null!=a){const t=Math.max(s,4),o=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-o/2-3,width:t+6,height:o+6,rx:3,fill:"none",stroke:Wt,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Wt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Wt,strokeWidth:2,strokeDasharray:"4,2"});return e.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 Et({x:t,y:o,containerWidth:n,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=y.useRef(null),[u,d]=y.useState(null);y.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,n,i]);let h;return h=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-o?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>o?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:c,className:a,style:{position:"absolute",left:r.left+t,top:r.top+o,transform:h,pointerEvents:"none",zIndex:l,width:"max-content"},children:s})}function zt(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}function Yt(e,o,n){const i=t.useRef(null),[r,s]=t.useState(null);return t.useEffect(()=>{if(!o&&!n)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:o}=t.contentRect;s(t=>t&&t.w===e&&t.h===o?t:{w:e,h:o})}});return t.observe(e),()=>t.disconnect()},[o,n]),[i,[o&&r?r.w:e[0],n&&r?r.h:e[1]]]}const Gt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,qt=new WeakMap;let Xt=0,Vt=!1,Ut=null,Kt=null,Qt=null;function Zt(e,t){var o,n;if(!t)return t;const i=Gt.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(o=i[2])||void 0===o?void 0:o.trim())||t;!function(){if(Vt)return;if("undefined"==typeof window||"undefined"==typeof document)return;Vt=!0;const e=()=>{Xt++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Ut=new MutationObserver(e),Ut.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Kt=window.matchMedia("(prefers-color-scheme: dark)"),Qt=e,"function"==typeof Kt.addEventListener?Kt.addEventListener("change",Qt):"function"==typeof Kt.addListener&&Kt.addListener(Qt)}catch(e){}}();let s=qt.get(r);s&&s.version===Xt||(s={version:Xt,map:new Map},qt.set(r,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(n=i[2])||void 0===n?void 0:n.trim())||t;return s.map.set(t,l),l}function Jt(e,t,o){return"function"==typeof e?e({size:t,margin:o}):e}function eo(e){const o=function(){const[e,o]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return o(e.matches),zt(e,e=>o(e.matches))},[]),e}(),n=t.useRef(o);n.current=o;const[i,r]=Yt(e.sizeProp,e.responsiveWidth,e.responsiveHeight),s=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),a=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,c=Jt(e.foregroundGraphics,r,s),u=Jt(e.backgroundGraphics,r,s),d=L(e=>e.theme),{transition:h,introEnabled:g}=function(e,t){var o,n;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(o=window.matchMedia)||void 0===o?void 0:o.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(n=e.duration)&&void 0!==n?n:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+y.useId(),p=t.useRef(0),v=t.useRef(()=>{}),m=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);t.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),k=t.useRef(null),w=t.useRef(0),j=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),A=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(j))},[j]),S=t.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),x.current()},[]);t.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const O=e.themeDirtyRef;return t.useEffect(()=>{O&&(Xt++,O.current=!0,m())},[d,m,O]),{reducedMotion:o,reducedMotionRef:n,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:g,tableId:f,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:A,onPointerLeave:S}}function to(e,t,o,n){const i=e.getContext("2d");if(!i)return null;const r=t[0]*n,s=t[1]*n,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===r&&e.height===s||(e.width=r,e.height=s),i.setTransform(n,0,0,n,0,0),i.translate(o.left,o.top),i}function oo(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function no(e){switch(e){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 io(e,t,o){let n=o;for(const o of t)"lesser"===o.thresholdType?o.value>e&&(n=o.color):e>o.value&&(n=o.color);return n}function ro(e,t,o,n,i,r){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const o=t[e][0]-t[e-1][0],n=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(o*o+n*n))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=o,e.lineWidth=n,e.lineCap=r;for(let o=0;t.length-1>o;o++){const n=(s[o]+s[o+1])/2;let r=i;l>n&&(r*=n/l),l>a-n&&(r*=(a-n)/l),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[o][0],t[o][1]),e.lineTo(t[o+1][0],t[o+1][1]),e.stroke()}}const so=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(e.save(),e.beginPath(),e.rect(0,0,n.width*l,n.height),e.clip());const u=a.style.stroke||"#007bff",d=Zt(e,u)||u,h=a.style.strokeWidth||2,g=a.colorThresholds,f=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=h,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;ro(e,a.path,d,h,m,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const p=no(a.curve),y=g&&g.length>0&&f&&f.length===a.path.length,v=a._decayOpacities;if(v&&v.length===a.path.length&&!y){e.strokeStyle=d;const b=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let x=0;a.path.length-1>x;x++)e.globalAlpha=.5*(v[x]+v[x+1])*b,e.beginPath(),e.moveTo(a.path[x][0],a.path[x][1]),e.lineTo(a.path[x+1][0],a.path[x+1][1]),e.stroke()}else if(y){let k=null,w=null,j=null,A=null,S=!1;function O(t,o,n){e.beginPath(),e.strokeStyle=t,e.moveTo(o,n),S=!0}function M(){S&&(e.stroke(),S=!1)}for(let C=0;a.path.length>C;C++){const[_,P]=a.path[C],L=f[C],T=io(L,g,d);if(null!==k&&null!==A&&null!==j){if(T===A)e.lineTo(_,P);else{const R=[];for(const B of g){const I=B.value;(j>I||I>L)&&(I>j||L>I)||j===I||L===I||R.push({t:(I-j)/(L-j)})}R.sort((e,t)=>e.t-t.t);for(const D of R){const H=k+(_-k)*D.t,N=w+(P-w)*D.t,$=io(j+(L-j)*Math.min(D.t+1e-4,1),g,d);e.lineTo(H,N),M(),O($,H,N)}e.lineTo(_,P)}k=_,w=P,j=L,A=T}else O(T,_,P),k=_,w=P,j=L,A=T}M()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=d;else{const W=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const F of a.strokeGradient.colorStops)W.addColorStop(Math.max(0,Math.min(1,F.offset)),F.color);e.strokeStyle=W}if(p)c.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(a.path);else{const[E,z]=a.path[0];e.moveTo(E,z);for(let Y=1;a.path.length>Y;Y++)e.lineTo(a.path[Y][0],a.path[Y][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?Zt(e,a.style.fill):a.style.fill)||a.style.fill,p&&!y)c.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(a.path);else{const[q,X]=a.path[0];e.moveTo(q,X);for(let V=1;a.path.length>V;V++)e.lineTo(a.path[V][0],a.path[V][1])}const G=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],n.height),e.lineTo(G,n.height),e.closePath(),e.fill()}void 0!==l&&1>l&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function ao(e,t){const o=e.fillStyle,n="#010203";try{e.fillStyle=n,e.fillStyle=t}catch(t){return e.fillStyle=o,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=o,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===n&&t.trim().toLowerCase()!==n)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]}function lo(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function co(e,t,o=.3){lo(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function uo(e,t,o=.6){var n,i,r,s,a;if(!lo(t))return;const l=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,c=t.r+l*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*o,e.stroke()}function ho(e,t,o,n=.35){lo(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function go(e){switch(e){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 fo(e,t){const o=go(t.curve);if(!o||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);for(let o=t.bottomPath.length-1;o>=0;o--)e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]);e.closePath()}else{const n=c.area().x(e=>e[0]).y0((e,o)=>t.bottomPath[o][1]).y1(e=>e[1]).curve(o).context(e);e.beginPath(),n(t.topPath)}}const po=(e,t,o,n)=>{var i,r,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,n.width*o,n.height),e.clip());const a=t.style.fill||"#4e79a7",l=t._decayOpacities;if(l&&l.length===t.topPath.length){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=a;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(l[n]+l[n+1])*o,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(l[o]+l[o+1]),e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.stroke()}e.globalAlpha=1;continue}const u=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(fo(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let n=-1/0;for(const e of t.bottomPath)e[1]>n&&(n=e[1]);const i=e.createLinearGradient(0,o,0,n);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const[o,n,r]=ao(e,"string"==typeof a?a:"#4e79a7");i.addColorStop(0,`rgba(${o},${n},${r},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${o},${n},${r},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=u}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*u,e.fillStyle=a}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(fo(e,t),ho(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=u,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke;else{const o=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)o.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=o}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=go(t.curve);if(e.beginPath(),o)c.line().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1])}e.stroke()}void 0!==o&&1>o&&e.restore(),e.globalAlpha=1}},yo=(e,t,o,n)=>{var i;const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const o=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=("string"==typeof t.style.fill?Zt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Zt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),uo(e,t),e.globalAlpha=1}}finally{e.restore()}}};function vo(e,t,o){const n=t.fillGradient;if(!n)return null;const i=t.roundedEdge;let r=t.x,s=t.y,a=t.x,l=t.y+t.h;if("bottom"===i?(s=t.y+t.h,l=t.y):"right"===i?(r=t.x+t.w,s=t.y,a=t.x,l=t.y):"left"===i&&(r=t.x,s=t.y,a=t.x+t.w,l=t.y),"colorStops"in n){const t=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>t.length)return null;const o=e.createLinearGradient(r,s,a,l);for(const e of t)o.addColorStop(e.offset,e.color);return o}const c=e.createLinearGradient(r,s,a,l),[u,d,h]=ao(e,o);return c.addColorStop(0,`rgba(${u},${d},${h},${n.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${n.bottomOpacity})`),c}const mo=(e,t,o,n)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)bo(e,t);else if(t.roundedTop&&t.roundedTop>0){const o=("string"==typeof t.style.fill?Zt(e,t.style.fill):t.style.fill)||Zt(e,"var(--semiotic-primary, #007bff)"),n="string"==typeof o?vo(e,t,o):null;e.fillStyle=n||o;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:r,y:s,w:a,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(r,s),e.lineTo(r+a-i,s),e.arcTo(r+a,s,r+a,s+i,i),e.lineTo(r+a,s+l-i),e.arcTo(r+a,s+l,r+a-i,s+l,i),e.lineTo(r,s+l);break;case"left":e.moveTo(r+a,s),e.lineTo(r+i,s),e.arcTo(r,s,r,s+i,i),e.lineTo(r,s+l-i),e.arcTo(r,s+l,r+i,s+l,i),e.lineTo(r+a,s+l);break;case"bottom":e.moveTo(r,s),e.lineTo(r+a,s),e.lineTo(r+a,s+l-i),e.arcTo(r+a,s+l,r+a-i,s+l,i),e.lineTo(r+i,s+l),e.arcTo(r,s+l,r,s+l-i,i);break;default:e.moveTo(r,s+l),e.lineTo(r,s+i),e.arcTo(r,s,r+i,s,i),e.lineTo(r+a-i,s),e.arcTo(r+a,s,r+a,s+i,i),e.lineTo(r+a,s+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const o=("string"==typeof t.style.fill?Zt(e,t.style.fill):t.style.fill)||Zt(e,"var(--semiotic-primary, #007bff)"),n="string"==typeof o?vo(e,t,o):null;e.fillStyle=n||o,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}co(e,t),e.globalAlpha=1}};function bo(e,t){const o=t.style.icon,n=t.style.iconPadding||2,i=Math.min(t.w,t.h)-n;if(0>=i)return;const r=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),r){const r=i+n,s=t.x+(t.w-i)/2;for(let n=t.y+t.h-i;n>=t.y-i;n-=r)e.drawImage(o,s,n,i,i)}else{const r=i+n,s=t.y+(t.h-i)/2;for(let n=t.x;t.x+t.w>n;n+=r)e.drawImage(o,n,s,i,i)}e.restore()}function xo(e,t,o,n){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:o,time:t,value:o}),n)}function ko(e){const[t,o,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*o+.114*n>128?"#000":"#fff"}function wo(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const jo=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ao(e){const t=e[1]-e[0],o=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:o>t?e=>{const t=new Date(e);return`${jo[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*o>t?e=>{const t=new Date(e);return`${jo[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const So={line:[po,so,yo],area:[po,yo],stackedarea:[po,yo],scatter:[yo],bubble:[yo],heatmap:[(e,t,o,n)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const o=t.style;if(null!=(null==o?void 0:o.opacity)&&(e.globalAlpha=o.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Zt(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),co(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const o=t.valueFormat?t.valueFormat(t.value):wo(t.value),n=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,r=t.y+t.h/2;e.fillStyle=ko(t.fill),e.font=n+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(o,i,r)}}}finally{e.restore()}}],bar:[mo],swarm:[yo],waterfall:[(e,t,o,n)=>{var i,r,s;mo(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=Zt(e,c)||c,e.lineWidth=null!==(i=null==l?void 0:l._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const n=a[t],i=a[t+1];if(!(null===(r=n.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=i.datum)||void 0===s?void 0:s.baseline))continue;const l=o.y(n.datum.cumEnd),c=n.x+n.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,o,n)=>{var i,r,s;for(const o of t){if("candlestick"!==o.type)continue;const t=o;e.save();const a=(null!==(i=t._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(e.globalAlpha=a);const l=Zt(e,t.wickColor)||t.wickColor,c=60>n.height,u=c?Math.max(t.wickWidth,2):t.wickWidth,d=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=l,e.lineWidth=u,e.stroke()};if(c||d(),t.isRange){const o=Math.max(2,Math.min(t.bodyWidth/2,.12*n.height));e.fillStyle=l,e.beginPath(),e.arc(t.x,t.highY,o,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,o,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const o=Math.min(t.openY,t.closeY),n=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,r=Zt(e,i)||i;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1))}c&&d(),e.restore()}}],mixed:[po,so,yo]},Oo={top:20,right:20,bottom:30,left:40},Mo={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 Co(e,t){const o=e.trim();if(/^#[0-9a-f]{3}$/i.test(o)){const e=o[1],n=o[2],i=o[3];return`#${e}${e}${n}${n}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(o))return`${o}${t}`;const n=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return n?`rgba(${n[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:o}const _o={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 Po({hover:t}){const o=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.jsxs("div",{className:"semiotic-tooltip",style:_o,children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:o(t.value)}),e.jsx("div",{style:{opacity:.7,fontSize:11},children:o(t.time)})]})}const Lo=t.forwardRef(function(o,n){var i,r,s,a,l,c,u,d,h,g,f;const{chartType:p,runtimeMode:v,data:m,chunkThreshold:b,chunkSize:w,xAccessor:j,yAccessor:S,colorAccessor:O,sizeAccessor:M,groupAccessor:C,lineDataAccessor:_,curve:P,normalize:L,binSize:T,valueAccessor:R,arrowOfTime:B="right",windowMode:I="sliding",windowSize:D=200,timeAccessor:H,xExtent:N,yExtent:$,extentPadding:W=.1,scalePadding:F,sizeRange:E,size:z=[500,300],responsiveWidth:Y,responsiveHeight:G,margin:q,className:X,background:V,lineStyle:U,pointStyle:K,areaStyle:Q,barStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:oe,boundsAccessor:ne,boundsStyle:ie,y0Accessor:re,gradientFill:se,lineGradient:ae,areaGroups:le,openAccessor:ue,highAccessor:de,lowAccessor:he,closeAccessor:ge,candlestickStyle:fe,showAxes:pe=!0,axes:me,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:we,yFormat:je,tickFormatTime:Ae,tickFormatValue:_e,hoverAnnotation:Te,tooltipContent:Re,customHoverBehavior:Be,customClickBehavior:Ie,enableHover:De,hoverRadius:He=30,tooltipMode:Ne,annotations:$e,svgAnnotationRules:We,showGrid:Fe,legend:Ee,legendHoverBehavior:ze,legendClickBehavior:Ye,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Xe,backgroundGraphics:Ve,foregroundGraphics:Ue,canvasPreRenderers:Ke,svgPreRenderers:Qe,title:Ze,categoryAccessor:Je,brush:et,onBrush:tt,decay:ot,pulse:nt,transition:it,animate:rt,staleness:st,heatmapAggregation:at,heatmapXBins:lt,heatmapYBins:ct,showValues:ut,heatmapValueFormat:dt,marginalGraphics:ht,pointIdAccessor:gt,xScaleType:ft,yScaleType:yt,accessibleTable:vt=!0,description:kt,summary:wt,linkedCrosshairName:jt,linkedCrosshairSourceId:At}=o,Ot=t.useRef(!1),Mt=eo({sizeProp:z,responsiveWidth:Y,responsiveHeight:G,userMargin:q,marginDefault:Oo,animate:rt,transitionProp:it,themeDirtyRef:Ot}),{reducedMotionRef:Ct,responsiveRef:_t,size:Pt,currentTheme:Lt,transition:Tt,introEnabled:Rt,tableId:Bt,rafRef:Dt,renderFnRef:Wt,scheduleRender:zt}=Mt;let Yt=Mt.margin;if(ht){const e=60,t=Object.assign({},Mt.margin);ht.top&&e>t.top&&(t.top=e),ht.bottom&&e>t.bottom&&(t.bottom=e),ht.left&&e>t.left&&(t.left=e),ht.right&&e>t.right&&(t.right=e),Yt=t}const Gt="function"==typeof Ue?Ue({size:Pt,margin:Yt}):Ue,qt="function"==typeof Ve?Ve({size:Pt,margin:Yt}):Ve,Xt=Pt[0]-Yt.left-Yt.right,Vt=Pt[1]-Yt.top-Yt.bottom,Ut=null!=Te?Te:De,Kt=t.useRef(null),Qt=t.useRef(null),[Zt,Jt]=t.useState(0),[no,io]=t.useState(null),ro=t.useRef(null),so=t.useRef(null),[ao,lo]=t.useState(null),co=t.useRef(Mo.primary),[uo,ho]=t.useState(!1),[go,fo]=t.useState([]),[po,yo]=t.useState([]),vo="streaming"===v||["bar","swarm","waterfall"].includes(p),mo=t.useMemo(()=>{var e,t,o;return{chartType:p,runtimeMode:vo?"streaming":"bounded",windowSize:D,windowMode:I,arrowOfTime:vo?B:"right",extentPadding:W,scalePadding:F,xAccessor:vo?void 0:j,yAccessor:vo?void 0:S,timeAccessor:vo?H:void 0,valueAccessor:R,colorAccessor:O,sizeAccessor:M,groupAccessor:C||(_?"_lineGroup":void 0),categoryAccessor:Je,lineDataAccessor:_,xScaleType:ft,yScaleType:yt,xExtent:N,yExtent:$,sizeRange:E,binSize:T,normalize:L,boundsAccessor:ne,boundsStyle:ie,y0Accessor:re,gradientFill:!0===se?{topOpacity:.8,bottomOpacity:.05}:!1===se?void 0:se,areaGroups:le?new Set(le):void 0,lineGradient:ae,openAccessor:ue,highAccessor:de,lowAccessor:he,closeAccessor:ge,candlestickStyle:fe,lineStyle:U,pointStyle:K,areaStyle:Q,swarmStyle:ee,waterfallStyle:J,colorScheme:oe,barColors:te,barStyle:Z,annotations:$e,decay:ot,pulse:nt,transition:Tt,introAnimation:Rt,staleness:st,heatmapAggregation:at,heatmapXBins:lt,heatmapYBins:ct,showValues:ut,heatmapValueFormat:dt,pointIdAccessor:gt,curve:P,themeCategorical:null===(e=null==Lt?void 0:Lt.colors)||void 0===e?void 0:e.categorical,themeSemantic:A(Lt),themeSequential:null===(t=null==Lt?void 0:Lt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==Lt?void 0:Lt.colors)||void 0===o?void 0:o.diverging}},[p,D,I,B,W,F,j,S,H,R,ft,yt,O,M,C,Je,_,N,$,E,T,L,ne,ie,re,se,ae,le,ue,de,he,ge,fe,U,K,Q,ee,J,Z,oe,te,$e,ot,nt,null==Tt?void 0:Tt.duration,null==Tt?void 0:Tt.easing,Rt,st,at,lt,ct,ut,dt,vo,gt,P,Lt]),bo=t.useRef(null);bo.current||(bo.current=new ce(mo)),t.useEffect(()=>{var e;null===(e=bo.current)||void 0===e||e.updateConfig(mo),Ot.current=!0,zt()},[mo,zt]);const ko=t.useRef(null);ko.current||(ko.current=new k(e=>{const t=bo.current;t&&t.ingest(e)&&(Ot.current=!0,zt())},{chunkThreshold:b,chunkSize:w})),t.useEffect(()=>{var e;null===(e=ko.current)||void 0===e||e.updateChunkOptions({chunkThreshold:b,chunkSize:w})},[b,w]);const wo=t.useCallback(e=>{var t;null===(t=ko.current)||void 0===t||t.push(e)},[]),jo=t.useCallback(e=>{var t;null===(t=ko.current)||void 0===t||t.pushMany(e)},[]),_o=t.useCallback(()=>{var e,t;null===(e=ko.current)||void 0===e||e.clear(),null===(t=bo.current)||void 0===t||t.clear(),Ot.current=!0,zt()},[zt]);t.useImperativeHandle(n,()=>({push:wo,pushMany:jo,remove:e=>{var t,o,n;null===(t=ko.current)||void 0===t||t.flush();const i=null!==(n=null===(o=bo.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];return i.length>0&&(ro.current&&i.some(e=>{var t;return e===(null===(t=ro.current)||void 0===t?void 0:t.data)})&&(ro.current=null,lo(null)),Ot.current=!0,zt()),i},update:(e,t)=>{var o,n,i;null===(o=ko.current)||void 0===o||o.flush();const r=null!==(i=null===(n=bo.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(Ot.current=!0,zt()),r},clear:_o,getData:()=>{var e,t,o;return null===(e=ko.current)||void 0===e||e.flush(),null!==(o=null===(t=bo.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=bo.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=bo.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[wo,jo,_o,zt]),t.useEffect(()=>{var e,t;if(m){if(_&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const t="string"==typeof _?_:"coordinates";if(Array.isArray(m[0][t])){const o=[];for(const e of m){const n=e[t];if(Array.isArray(n)){const t=e.label||e.id||e.key;if(null!=t)for(const e of n)o.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of n)o.push(e)}}return void(null===(e=ko.current)||void 0===e||e.setBoundedData(o))}}null===(t=ko.current)||void 0===t||t.setBoundedData(m)}},[m,_]);const{hoverHandlerRef:Lo,hoverLeaveRef:To,onPointerMove:Ro,onPointerLeave:Bo}=Mt;Lo.current=e=>{if(!Ut)return;const t=Kt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-Yt.left,i=e.clientY-o.top-Yt.top;if(0>n||n>Xt||0>i||i>Vt)return void(ro.current&&(ro.current=null,so.current=null,lo(null),Be&&(Be(null),Ot.current=!0),zt()));const r=bo.current;if(!r||0===r.scene.length)return;const s=ye(r.scene,n,i,He,r.quadtree,r.maxPointRadius);if(!s)return void(ro.current&&(ro.current=null,so.current=null,lo(null),Be&&Be(null),zt()));const a=xo(s.datum||{},s.x,s.y);if("multi"===Ne&&r.scene.length>0&&r.scales){const e=function(e,t,o=30){const n=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const r=ve(e.path,t,o);if(null===r)continue;const s=Se(e.path,t);n.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:r,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const r=ve(e.topPath,t,o);if(null===r)continue;const s=Se(e.topPath,t);n.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.topPath[s][0],y:r,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return n}(r.scene,s.x,He),t=r.scales.y.invert,o=r.scales.x.invert;if(e.length>0){const n=o?o(s.x):s.x;a.xValue=n,a.xPx=s.x;const i=co.current;a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||i,datum:e.datum}))}}ro.current=a,so.current=s.node,lo(a),Be&&(Be(a),Ot.current=!0),zt()},To.current=()=>{ro.current&&(ro.current=null,so.current=null,lo(null),Be&&(Be(null),Ot.current=!0),zt())};const Io=t.useRef(()=>{});Io.current=e=>{if(!Ie)return;const t=Kt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-Yt.left,i=e.clientY-o.top-Yt.top;if(0>n||n>Xt||0>i||i>Vt)return void Ie(null);const r=bo.current;if(!r||0===r.scene.length)return void Ie(null);const s=ye(r.scene,n,i,He,r.quadtree,r.maxPointRadius);Ie(s?xo(s.datum||{},s.x,s.y):null)};const Do=t.useCallback(e=>Io.current(e),[]),Ho=t.useRef(-1),No=t.useRef(null),$o=t.useRef(null),Wo=t.useCallback(e=>{const t=bo.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if($o.current&&$o.current.version===o)n=$o.current.graph;else{const e=function(e){var t,o,n,i;const r=[];for(const s of e)switch(s.type){case"point":r.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(t=s.group)&&void 0!==t?t:"_default"});break;case"line":{const e=s,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.path.length>o&&t.length>o;o++)r.push({x:e.path[o][0],y:e.path[o][1],datum:t[o],shape:"circle",group:n});break}case"area":{const e=s,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.topPath.length>n&&t.length>n;n++)r.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:t[n],shape:"circle",group:o});break}case"rect":r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(i=s.group)&&void 0!==i?i:"_default"});break;case"heatcell":r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:"_default"})}return r.sort((e,t)=>e.x-t.x||e.y-t.y),r}(t.scene);if(0===e.length)return;n=Oe(e),$o.current={version:o,graph:n}}const i=Ho.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Ho.current=0;const t=n.flat[0];No.current={shape:t.shape,w:t.w,h:t.h};const o=Pe(t);return ro.current=o,lo(o),Be&&Be(o),void zt()}const r=Me(n,i),s=Ce(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return Ho.current=-1,No.current=null,ro.current=null,so.current=null,lo(null),Be&&Be(null),void zt();Ho.current=s;const a=n.flat[s];No.current={shape:a.shape,w:a.w,h:a.h};const l=Pe(a);ro.current=l,lo(l),Be&&Be(l),zt()},[Be,zt]),Fo=t.useCallback(e=>{Ho.current=-1,No.current=null,Ro(e)},[Ro]);Wt.current=()=>{var e,t;Dt.current=0;const o=Kt.current,n=Qt.current;if(!o||!n)return;const i=bo.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(Ct.current?r+1e6:r),a=!Ct.current&&s,l=Ot.current||s;l&&!a&&i.computeScene({width:Xt,height:Vt});const c=oo(),u=function(e){if(!e)return Mo;const t=getComputedStyle(e),o=t.getPropertyValue("--semiotic-border").trim(),n=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=t.getPropertyValue("--semiotic-primary").trim(),s=n||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=o||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||o||r?{axisStroke:l||Mo.axisStroke,tickText:s||Mo.tickText,crosshair:s?Co(s,"66"):Mo.crosshair,hoverFill:c?Co(c,"4D"):Mo.hoverFill,hoverStroke:s?Co(s,"99"):Mo.hoverStroke,pointRing:c||Mo.pointRing,primary:r||Mo.primary}:Mo}(o);co.current=u.primary;const d=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const e=to(o,Pt,Yt,c);if(e){if(e.clearRect(-Yt.left,-Yt.top,Pt[0],Pt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5),"transparent"!==V&&!Ve){const t=getComputedStyle(o).getPropertyValue("--semiotic-bg").trim(),n=V||(t&&"transparent"!==t?t:null);n&&(e.fillStyle=n,e.fillRect(-Yt.left,-Yt.top,Pt[0],Pt[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Xt,Vt),e.clip()),Ke&&i.scales)for(const t of Ke)e.save(),t(e,i.scene,i.scales,{width:Xt,height:Vt}),e.restore();const n=So[p];if(n&&i.scales)for(const t of n)t(e,i.scene,i.scales,{width:Xt,height:Vt});e.restore(),h&&(e.globalAlpha=1)}}{const e=to(n,Pt,Yt,c);if(e&&(e.clearRect(-Yt.left,-Yt.top,Pt[0],Pt[1]),Ut&&ro.current&&i.scales&&function(e,t,o,n,i,r,s){var a;if(!1===i.crosshair)return;const l=t.allSeries,c=l&&l.length>0,u=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(e.strokeStyle=d.stroke||s.crosshair,e.lineWidth=d.strokeWidth||1,e.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?u:t.x,0),e.lineTo(c?u:t.x,n),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(o,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of l)null!=t.valuePx&&(e.beginPath(),e.arc(u,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const o=i.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const o="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||o||null:o||t.stroke||null}(r)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,ro.current,Xt,Vt,"object"==typeof Ut?Ut:{},so.current,u),so.current&&Array.isArray(Te))){const t=Te.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,o,n,i){var r;if(!o)return;const s=o.group;if(void 0!==s)for(const o of t){if("line"!==o.type)continue;if(o.group!==s)continue;if(2>o.path.length)continue;const t="function"==typeof n.style?n.style(o.datum):n.style||{};e.save(),e.beginPath(),e.moveTo(o.path[0][0],o.path[0][1]);for(let t=1;o.path.length>t;t++)e.lineTo(o.path[t][0],o.path[t][1]);e.strokeStyle=t.stroke||o.style.stroke||i.primary,e.lineWidth=t.strokeWidth||(o.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,i.scene,so.current,t,u)}}l&&o&&o.setAttribute("aria-label",St(i.scene,p+" chart"));const g=Ot.current;if(Ot.current=!1,g&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!no||e(no.x.domain()[0])!==e(i.scales.x.domain()[0])||e(no.x.domain()[1])!==e(i.scales.x.domain()[1])||e(no.y.domain()[0])!==e(i.scales.y.domain()[0])||e(no.y.domain()[1])!==e(i.scales.y.domain()[1])||no.x.range()[0]!==i.scales.x.range()[0]||no.x.range()[1]!==i.scales.x.range()[1]||no.y.range()[0]!==i.scales.y.range()[0]||no.y.range()[1]!==i.scales.y.range()[1])&&io(i.scales),ht){const e=i.getData(),t="function"==typeof j?j:e=>e[j||"x"],o="function"==typeof S?S:e=>e[S||"y"];fo(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),yo(e.map(e=>o(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&$e&&$e.length>0&&Jt(e=>e+1),(null==st?void 0:st.showBadge)&&ho(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Dt.current=requestAnimationFrame(()=>Wt.current()))},t.useEffect(()=>(zt(),()=>{var e;null===(e=ko.current)||void 0===e||e.clear()}),[zt]),t.useEffect(()=>{Ot.current=!0,zt()},[p,Xt,Vt,pe,V,U,Ke,zt]),Le(st,bo,Ot,zt,uo,ho);const Eo=t.useMemo(()=>{if(we||Ae)return;const e=bo.current;return(null==e?void 0:e.xIsDate)&&no?Ao(no.x.domain()):void 0},[we,Ae,no]),zo=we||Ae||Eo,Yo=Ut&&ao?Re?Re(ao):e.jsx(Po,{hover:ao}):null,Go=Yo?e.jsx(Et,{x:ao.x,y:ao.y,containerWidth:Xt,containerHeight:Vt,margin:Yt,className:"stream-frame-tooltip",children:Yo}):null,qo=No.current,Xo=e.jsx(Ft,{active:Ho.current>=0,hoverPoint:ao,margin:Yt,size:Pt,shape:null==qo?void 0:qo.shape,width:null==qo?void 0:qo.w,height:null==qo?void 0:qo.h}),Vo=(e,t,o,n)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:{key:void 0,fn:null},Uo=Vo(j,H,"__semiotic_resolvedX","__semiotic_resolvedTime"),Ko=Vo(S,R,"__semiotic_resolvedY","__semiotic_resolvedValue"),Qo=Uo.key,Zo=Ko.key,Jo=$e&&$e.length>0,en=e=>{if(!e||!Jo||!Uo.fn&&!Ko.fn)return e;let t=!1;const o=e.map(e=>{const o=Uo.fn&&Uo.key&&!(Uo.key in e),n=Ko.fn&&Ko.key&&!(Ko.key in e);if(!o&&!n)return e;t=!0;const i=Object.assign({},e);return o&&(i[Uo.key]=Uo.fn(e)),n&&(i[Ko.key]=Ko.fn(e)),i});return t?o:e};if(xt){const t=bo.current;t&&m&&(t.ingest({inserts:m,bounded:!0}),t.computeScene({width:Xt,height:Vt}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,s=zo||(()=>{if((null==t?void 0:t.xIsDate)&&n)return Ao(n.x.domain())})();return e.jsxs("div",{className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":kt||("string"==typeof Ze?Ze:"XY chart"),style:{position:"relative",width:Pt[0],height:Pt[1]},children:[e.jsx(Ht,{summary:wt}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Pt[0],height:Pt[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Yt.left},${Yt.top})`,children:qt}),e.jsxs("g",{transform:`translate(${Yt.left},${Yt.top})`,children:[V&&e.jsx("rect",{x:0,y:0,width:Xt,height:Vt,fill:V}),Qe&&n&&Qe.map((t,i)=>e.jsx(y.Fragment,{children:t(o,n,{width:Xt,height:Vt})},"svgpre-"+i)),o.map((t,o)=>function(t,o){var n,i,r;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+o)}case"area":{const r=t;if(0===r.topPath.length)return null;const s=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:`M${s}L${a}Z`,fill:bt(r.style.fill),fillOpacity:null!==(i=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+o)}case"point":{const n=t;return e.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:bt(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:bt(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+o)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,r,s]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return e.jsxs("g",{children:[e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),e.jsx("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:t})]},"heatcell-"+o)}return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+o)}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),s=n.isUp?n.upColor:n.downColor;return e.jsxs("g",{children:[e.jsx("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),e.jsx("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+o)}default:return null}}(t,o)).filter(Boolean)]})]}),e.jsx(mt,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,scales:n,showAxes:pe,axes:me,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:s,yFormat:je||_e,showGrid:Fe,title:Ze,legend:Ee,legendHoverBehavior:ze,legendClickBehavior:Ye,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Xe,foregroundGraphics:Gt,marginalGraphics:ht,xValues:[],yValues:[],annotations:$e,svgAnnotationRules:We,annotationFrame:0,xAccessor:Qo,yAccessor:Zo,annotationData:en(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:At})]})}return e.jsxs("div",{ref:_t,className:"stream-xy-frame"+(X?" "+X:""),role:"group","aria-label":kt||("string"==typeof Ze?Ze:"XY chart"),tabIndex:0,style:{position:"relative",width:Y?"100%":Pt[0],height:G?"100%":Pt[1],overflow:"visible"},onKeyDown:Wo,children:[vt&&e.jsx(Nt,{tableId:Bt}),vt&&e.jsx(It,{scene:null!==(a=null===(s=bo.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:p+" chart",tableId:Bt,chartTitle:"string"==typeof Ze?Ze:void 0}),e.jsx(Ht,{summary:wt}),e.jsxs("div",{role:"img","aria-label":kt||("string"==typeof Ze?Ze:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ut?Fo:void 0,onMouseLeave:Ut?Bo:void 0,onClick:Ie?Do:void 0,children:[qt&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Pt[0],height:Pt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Yt.left},${Yt.top})`,children:qt})}),e.jsx(pt,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,scales:no,showAxes:pe,axes:me,showGrid:Fe,xFormat:zo,yFormat:je||_e}),e.jsx("canvas",{ref:Kt,"aria-label":St(null!==(c=null===(l=bo.current)||void 0===l?void 0:l.scene)&&void 0!==c?c:[],p+" chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:Qt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx($t,{hoverPoint:ao}),e.jsx(mt,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,scales:no,showAxes:pe,axes:me,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:zo,yFormat:je||_e,showGrid:Fe,title:Ze,legend:Ee,legendHoverBehavior:ze,legendClickBehavior:Ye,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Xe,foregroundGraphics:Gt,marginalGraphics:ht,xValues:go,yValues:po,annotations:$e,svgAnnotationRules:We,annotationFrame:Zt,xAccessor:Qo,yAccessor:Zo,annotationData:en(null===(u=bo.current)||void 0===u?void 0:u.getData()),pointNodes:null===(d=bo.current)||void 0===d?void 0:d.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:At}),(et||tt)&&e.jsx(x,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,dimension:null!==(h=null==et?void 0:et.dimension)&&void 0!==h?h:"xy",scales:no,onBrush:null!=tt?tt:()=>{},binSize:T,snap:null==et?void 0:et.snap,binBoundaries:null!==(g=null==et?void 0:et.binBoundaries)&&void 0!==g?g:"bar"===p?null===(f=bo.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==et?void 0:et.snapDuring,streaming:"streaming"===v}),(null==st?void 0:st.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:uo?"#dc3545":"#28a745",color:"white"}),children:uo?"STALE":"LIVE"}),Xo,Go]})]})});function To(e,t){const{columns:o,config:n,resolvePieceStyle:i}=e,r=[],s=Math.min(t.width,t.height)/2-4,a="donut"===n.chartType?n.innerRadius||60:0,l=-Math.PI/2+(n.startAngle||0)*Math.PI/180,c=null!=n.sweepAngle?n.sweepAngle*Math.PI/180:2*Math.PI;for(const e of Object.values(o)){const t=l+e.pctStart*c,o=l+(e.pctStart+e.pct)*c,u=i(e.pieceData[0],e.name);r.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:t,endAngle:o},n.cornerRadius&&{cornerRadius:n.cornerRadius}),{style:u,datum:e.pieceData,category:e.name}))}return r}function Ro(e){var t,o,n;const i=e.length,r=e[0],s=e[i-1];return{n:i,min:r,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:r,median:null!==(o=a.quantile(e,.5))&&void 0!==o?o:(r+s)/2,q3:null!==(n=a.quantile(e,.75))&&void 0!==n?n:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}Lo.displayName="StreamXYFrame";const Bo={bar:function(e,t){var o,n,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p="horizontal"===h,y=a.normalize,v=[];if(c){const e=new Set;for(const t of Object.values(s))for(const o of t.pieceData){const t=c(o);e.has(t)||(e.add(t),v.push(t))}}else v.push("_default");for(const e of Object.values(s)){const t=new Map;for(const o of e.pieceData){const e=c?c(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=l(o),n.pieces.push(o)}let o=0;if(y)for(const e of t.values())o+=Math.abs(e.total);let n=0,i=0;for(const r of v){const s=t.get(r);if(!s)continue;let a=s.total;y&&o>0&&(a/=o);const l=u(s.pieces[0],c?r:e.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:e.name});if(f){const t=d(0>a?i:n+a),o=0>a?d(i+a)-d(i):d(n)-d(n+a);g.push(ne(e.x,t,e.width,Math.abs(o),l,h,r)),0>a?i+=a:n+=a}else if(p){const t=d(0>a?i+a:n),o=0>a?d(i)-d(i+a):d(n+a)-d(n);g.push(ne(t,e.x,Math.abs(o),e.width,l,h,r)),0>a?i+=a:n+=a}}}const m="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const e of g){if("rect"!==e.type)continue;const t=null!==(n=null===(o=e.datum)||void 0===o?void 0:o.__aggregateValue)&&void 0!==n?n:0;e.roundedEdge=m?0>t?"bottom":"top":0>t?"left":"right",a.gradientFill&&(e.fillGradient=a.gradientFill)}if(b>0){const e=new Map;for(const t of g){if("rect"!==t.type)continue;const o=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>{var t,o;return(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)>=0}),o=t.filter(e=>{var t,o;return 0>(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)});e.length>0&&(e.reduce(m?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=b),o.length>0&&(o.reduce(m?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=b)}}return g},clusterbar:function(e,t){const{scales:o,columns:n,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h=[],g=new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=s?s(t):"_default";g.has(e)||(g.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(n)){const t=e.width/f,o=.2*t,n=t-o,i=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";i.has(e)||i.set(e,[]),i.get(e).push(t)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),g=a(i,h[s]);if(d){const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push(ne(r,Math.min(a,d),n,Math.abs(a-d),g,i,h[s]))}else{const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push(ne(Math.min(a,d),r,Math.abs(d-a),n,g,i,h[s]))}}}}const p=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;const t=r(e.datum);p>0&&(e.roundedTop=p),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",i.gradientFill&&(e.fillGradient=i.gradientFill)}return u},point:function(e,t){var o,n;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=i,d=[],h="vertical"===u,g="radial"===u,f=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const i=null!==(o=t.__rIndex)&&void 0!==o?o:0,r=null!==(n=t.__rValue)&&void 0!==n?n:s(t),u=f&&a[i]||c,v=l(t,e.name),m=v.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*p,o=u(r);b=Math.cos(t)*o,x=Math.sin(t)*o}else h?(b=e.middle,x=u(r)):(b=u(r),x=e.middle);d.push({type:"point",x:b,y:x,r:m,style:v,datum:t})}return d},swarm:function(e,t){const{scales:o,columns:n,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="vertical"===a;for(const e of Object.values(n)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const n=e.pieceData[o],a=i(n),u=r(n,e.name),d=u.r||4,h=(7919*o%100/100-.5)*t*.8,g=c?e.middle+h:s(a),f=c?s(a):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:n})}}return l},pie:To,donut:To,boxplot:function(e,t){var o,n,i,r,s,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:g}=e,{r:f,projection:p}=c,y=[],v="vertical"===p,m=!1!==d.showOutliers;for(const t of Object.values(u)){const c=t.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===c.length)continue;const u=c[0],d=c[c.length-1],p=null!==(o=a.quantile(c,.25))&&void 0!==o?o:u,b=null!==(n=a.quantile(c,.5))&&void 0!==n?n:(u+d)/2,x=null!==(i=a.quantile(c,.75))&&void 0!==i?i:d,k=x-p,w=p-1.5*k,j=x+1.5*k,A=null!==(r=c.find(e=>e>=w))&&void 0!==r?r:u,S=null!==(s=[...c].reverse().find(e=>j>=e))&&void 0!==s?s:d,O=g(t.pieceData[0],t.name),M=[];if(m)for(const e of t.pieceData){const o=h(e);if(w>o||o>j){const n=v?t.middle:f(o),i=v?f(o):t.middle;M.push({px:n,py:i,value:o,datum:e})}}if(y.push({type:"boxplot",x:v?t.middle:0,y:v?0:t.middle,projection:v?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(A),q1Pos:f(p),medianPos:f(b),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:A,q1:p,median:b,q3:x,max:S,mean:c.reduce((e,t)=>e+t,0)/c.length},style:O,datum:t.pieceData,category:t.name,outliers:M}),m)for(const t of M)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:O.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:t.datum})}return y},violin:function(e,t){var o,n,i;const{scales:r,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],s=t[t.length-1],l=(s-r)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-r)/l),p-1)]++;const v=Math.max(...h,1),m=e.width/2*.9;let b="";if(f){b=`M ${e.middle} ${d(r)}`;for(let t=0;p>t;t++){const o=d(r+(t+.5)*l);b+=` L ${e.middle+h[t]/v*m} ${o}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const o=d(r+(t+.5)*l);b+=` L ${e.middle-h[t]/v*m} ${o}`}b+=" Z"}else{b=`M ${d(r)} ${e.middle}`;for(let t=0;p>t;t++)b+=` L ${d(r+(t+.5)*l)} ${e.middle-h[t]/v*m}`;b+=` L ${d(s)} ${e.middle}`;for(let t=p-1;t>=0;t--)b+=` L ${d(r+(t+.5)*l)} ${e.middle+h[t]/v*m}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(o=a.quantile(t,.25))&&void 0!==o?o:r,c=null!==(n=a.quantile(t,.5))&&void 0!==n?n:(r+s)/2,u=null!==(i=a.quantile(t,.75))&&void 0!==i?i:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(r)),width:e.width,height:Math.abs(d(s)-d(r))}:{x:Math.min(d(r),d(s)),y:e.x,width:Math.abs(d(s)-d(r)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Ro(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l}=n,c=[],u=r.bins||25,d=r.normalize,h=null===(o=l.domain)||void 0===o?void 0:o.call(l),g=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const o=null!=g&&isFinite(g)?g:Math.min(...t),n=null!=f&&isFinite(f)?f:Math.max(...t),i=(n-o)/u||1,r=Array(u).fill(0);for(const e of t)o>e||e>n||r[Math.min(Math.floor((e-o)/i),u-1)]++;const h=t.length,p=Math.max(...r,1),y=a(e.pieceData[0],e.name);for(let t=0;u>t;t++){if(0===r[t])continue;const n=(d?r[t]/h:r[t]/p)*e.width*.9,s=l(o+t*i),a=l(o+(t+1)*i);c.push(ne(Math.min(s,a),e.x+e.width-n,Math.abs(a-s),n,y,{bin:t,count:r[t],range:[o+t*i,o+(t+1)*i],category:e.name},e.name))}}return c},ridgeline:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=n,u=[],d=r.bins||20,h="horizontal"===c,g=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*g;let v="";if(h){const t=e.x+e.width;v=`M ${l(n)} ${t}`;for(let e=0;d>e;e++)v+=` L ${l(n+(e+.5)*r)} ${t-c[e]/f*y}`;v+=` L ${l(i)} ${t} Z`}else{const t=e.x;v=`M ${t} ${l(n)}`;for(let e=0;d>e;e++){const o=l(n+(e+.5)*r);v+=` L ${t+c[e]/f*y} ${o}`}v+=` L ${t} ${l(i)} Z`}const m=h?{x:Math.min(l(n),l(i)),y:e.x,width:Math.abs(l(i)-l(n)),height:e.width}:{x:e.x,y:Math.min(l(i),l(n)),width:e.width,height:Math.abs(l(i)-l(n))};u.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:m,stats:Ro(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(o=p.fillOpacity)&&void 0!==o?o:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:o,columns:n,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const o=i(t);if(!o)continue;const[n,a]=o,u=r(t,e.name);if(c){const o=s(Math.min(n,a)),i=s(Math.max(n,a));l.push(ne(o,e.x,i-o,e.width,u,t,e.name))}else{const o=s(Math.max(n,a)),i=s(Math.min(n,a));l.push(ne(e.x,o,e.width,i-o,u,t,e.name))}}return l},funnel:function(e,t){var o,n,r,s,a,l,c,u;const{columns:d,getR:h,getStack:g,resolvePieceStyle:f}=e,p=[],y=t.width/2,v=!1!==e.config.showLabels,m=e.scales.o.domain().map(e=>d[e]).filter(Boolean);if(0===m.length)return p;const b=[],x=new Set;for(const e of m)for(const t of e.pieceData){const e=g?g(t):"_default";x.has(e)||(x.add(e),b.push(e))}const k=b.length>1&&"_default"!==b[0],w=[];let j=0;for(const e of m){const t=new Map;let o=0;for(const n of e.pieceData){const e=g?g(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=h(n);i.total+=r,i.pieces.push(n),o+=r}w.push({col:e,groups:t,stepTotal:o}),k||o>j&&(j=o)}if(k)for(const e of w){let t=0,o=0;for(let n=0;b.length>n;n++){const i=e.groups.get(b[n]);i&&(n%2==0?t+=i.total:o+=i.total)}const n=Math.max(t,o);n>j&&(j=n)}if(0===j)return p;const A=new Map;for(const e of b){const t=w[0].groups.get(e);A.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const S=w[0].stepTotal,O=k?.95*y:.9*t.width,M=i.scaleLinear().domain([0,j]).range([0,O]),C=null!==(n=e.config.connectorOpacity)&&void 0!==n?n:.3;let _=new Map;for(let t=0;w.length>t;t++){const o=w[t],n=o.col,i=0===t,d=n.width,h=.55*d,g=n.x+(d-h)/2,m=new Map;if(k){let e=0;for(const t of b){const n=o.groups.get(t);n&&(e+=M(n.total))}let t=y,r=y;for(let s=0;b.length>s;s++){const l=b[s],c=o.groups.get(l);if(!c)continue;const u=M(c.total),d=s%2==0,x=d?t:r-u;d?t+=u:r-=u;const k=f(c.pieces[0],l),w=null!==(a=A.get(l))&&void 0!==a?a:c.total,j=w>0?c.total/w*100:0,S=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:j,__funnelStep:n.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});v&&(0===s&&(S.__funnelStepLabel=n.name,S.__funnelStepLabelX=y,S.__funnelStepLabelY=g,S.__funnelRowWidth=e),S.__funnelValueLabelX=x+u/2,S.__funnelValueLabelY=g,S.__funnelBarW=u),p.push(ne(x,g,u,h,k,S,l)),m.set(l,{x:x,y:g,w:u,h:h})}}else{const e=o.stepTotal,t=M(e),a=y-t/2,l=b[0],c="_default"!==l,u=null!==(s=null===(r=o.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:n.pieceData[0],d=c?l:n.name,x=f(u,d),k=S>0?e/S*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:e,__funnelPercent:k,__funnelStep:n.name,__funnelIsFirstStep:i,category:c?l:n.name});v&&(w.__funnelStepLabel=n.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=g,w.__funnelRowWidth=t,w.__funnelValueLabelX=y,w.__funnelValueLabelY=g,w.__funnelBarW=t),p.push(ne(a,g,t,h,x,w,d)),m.set(l,{x:a,y:g,w:t,h:h})}if(t>0&&_.size>0){const t=k?b:[b[0]];for(const i of t){const t=_.get(i),r=m.get(i);if(!t||!r)continue;const s=(()=>{const e=o.groups.get(i);return f(e?e.pieces[0]:n.pieceData[0],"_default"===i?n.name:i)})(),a={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:C},datum:null!==(u=null===(c=o.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:n.pieceData[0],category:"_default"===i?n.name:i};p.push(a)}}_=m}return p},"bar-funnel":function(e,t){var o,n,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=e,d=[],h=u.o.domain().map(e=>s[e]).filter(Boolean);if(0===h.length)return d;const g=[],f=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";f.has(e)||(f.add(e),g.push(e))}const p=g.length>1&&"_default"!==g[0],y=[];for(const e of h){const t=new Map;let o=0;for(const n of e.pieceData){const e=l?l(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=a(n);i.total+=r,i.pieces.push(n),o+=r}y.push({col:e,groups:t,stepTotal:o})}const v=new Map;for(const e of g){const t=null===(o=y[0])||void 0===o?void 0:o.groups.get(e);v.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const m=u.r,b=p?g.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],o=t.col,n=0===e,s=e>0?y[e-1]:null,a=o.width/b,l=a*x,u=a-l;for(let e=0;g.length>e;e++){const h=g[e],f=t.groups.get(h);if(!f)continue;const y=f.total,b=null!==(i=v.get(h))&&void 0!==i?i:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,j=n?0:Math.max(0,w-y),A=o.x+e*a+l/2,S=m(y),O=m(0)-S,M=c(f.pieces[0],p?h:o.name),C=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:j,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name,__barFunnelLabelX:A+u/2,__barFunnelLabelY:m(y+j)});if(d.push(ne(A,S,u,O,M,C,p?h:o.name)),j>0){const e=m(y+j),t=S-e,n=Object.assign({},M),i=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:j,__barFunnelPercent:b>0?j/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name});d.push(ne(A,e,u,t,n,i,p?h:o.name))}}}return d},swimlane:function(e,t){const{scales:o,columns:n,getR:i,getStack:r,resolvePieceStyle:s}=e,{r:a,projection:l}=o,c=[],u="horizontal"===l;for(const e of Object.values(n)){let t=0;for(const o of e.pieceData){const n=Math.abs(i(o));if(0===n)continue;const l=r?r(o):e.name,d=s(o,l);if(u){const i=a(t),r=a(t+n);c.push(ne(i,e.x,r-i,e.width,d,o,l))}else{const i=a(t+n),r=a(t);c.push(ne(e.x,i,e.width,r-i,d,o,l))}t+=n}}return c}};class Io{constructor(e){this.rExtent=new R,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.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new T(e.windowSize),this.getO=N(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>D(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new R)):(this.getR=D(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=N(e.stackBy),this.getGroup=N(e.groupBy),this.getColor=N(e.colorAccessor),this.getConnector=N(e.connectorAccessor),this.getDataId=N(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new T(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=o.toArray(),r=t.projection||"vertical",s=t.oExtent||this.resolveCategories(n),a=this.computeValueDomain(n,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===r?e.width:e.height):.1));let d,h;if(c){d=i.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,n=t.innerRadius||0;h=i.scaleLinear().domain(a).range([n,o])}else l?(d=i.scaleBand().domain(s).range([0,e.height]).padding(u),h=i.scaleLinear().domain(a).range([0,e.width])):(d=i.scaleBand().domain(s).range([0,e.width]).padding(u),h=i.scaleLinear().domain(a).range([e.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((n,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(o,n);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=t.extentPadding)&&void 0!==s?s:.05,h=u-c,g=h>0?h*d:1;return c-=g,u+=g,c>0&&(c=0),l?i.scaleLinear().domain([c,u]).range([0,e.width]):i.scaleLinear().domain([c,u]).range([e.height,0])}):[];let g=n;this.rAccessors.length>1&&(g=n.flatMap(e=>this.rAccessors.map((t,o)=>Object.assign(Object.assign({},e),{__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(g,s,d,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,e),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),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(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,n="auto"===t?void 0:t;let i=null;if(o){i=new Set;for(const t of e)i.add(this.getO(t))}const r=i?Array.from(this.categories).filter(e=>i.has(e)):Array.from(this.categories);if(o&&void 0===n){const e=Math.max(50,3*i.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===n)return r;if("function"==typeof n)return r.sort(n);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===n?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){var o,n,i,r,s;const a=this.config.chartType,l=null!==(o=this.config.extentPadding)&&void 0!==o?o:.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 t=new Map,o=new Map;for(const n of e){const e=this.getO(n),i=this.getR(n);0>i?o.set(e,(o.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>u&&(u=e);for(const e of o.values())c>e&&(c=e)}else if("bar"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=this.getR(o);t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e),c>e&&(c=e)}else if("swimlane"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=Math.abs(this.getR(o));t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e)}else if("clusterbar"===a||"bar-funnel"===a)for(const t of e){const e=this.getR(t);e>u&&(u=e),c>e&&(c=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(c=e),t!==-1/0&&(u=t)}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===(n=this.config.rExtent)||void 0===n?void 0:n[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){const e=u-c,t=e>0?e*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=t),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=t)}return[c,u]}buildColumns(e,t,o,n,i){var r;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===n)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==n){u=new Map;let e=0;for(const o of t){const t=a.get(o)||[];let n;n="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(o,n),e+=n}const r=("horizontal"===n?i.height:i.width)-o.padding()*o.step()*t.length;if(e>0)for(const[t,o]of u)u.set(t,o/e*r)}let d=0,h=0;for(const e of t){const t=a.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?n/l:0;let c,g;u?(c=h,g=u.get(e)||o.bandwidth(),h+=g+o.padding()*o.step()):(c=null!==(r=o(e))&&void 0!==r?r:0,g=o.bandwidth()),s[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:o.padding()*o.step(),pieceData:t,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:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const o=this.getSceneContext(),n=Bo[this.config.chartType];let i=n?n(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){var o,n;const{scales:i,config:r,getConnector:s,getO:a}=e;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let n,i;"point"===e.type?(n=e.x,i=e.y):(n=e.x+e.w/2,i=e.y+("vertical"===c?0:e.h/2)),u.has(o)||u.set(o,[]),u.get(o).push({x:n,y:i,datum:t,category:a(t)})}const d=i.o.domain(),h=r.connectorStyle;for(const[t,i]of u)if(i.length>=2){i.sort((e,t)=>d.indexOf(e.category)-d.indexOf(t.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===(o=e.config.themeSemantic)||void 0===o?void 0:o.border)||(null===(n=e.config.themeSemantic)||void 0===n?void 0:n.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:t})}}return l}(o,i);i=[...e,...i]}return i}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const o=this.config.pieceStyle(e,t);return o&&!o.fill&&t?Object.assign(Object.assign({},o),{fill:this.getColorFromScheme(t)}):o}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||F,n=o[this._colorSchemeIndex%o.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,n),n}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?X(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=new Map;for(let o=0;e.length>o;o++)t.set(e[o],o);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=this.config.categoryAccessor||this.config.oAccessor,o="function"==typeof t,n=o?null:t||"category",i=new Map;for(let r=0;e.length>r;r++){const s=e[r],a=o?t(s):s[n];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 e=0,t=0;for(const o of this.scene)"point"===o.type&&(e++,o.r>t&&(t=o.r));if(this._maxPointRadius=t,Io.QUADTREE_THRESHOLD>=e)return void(this._pointQuadtree=null);const o=Array(e);let n=0;for(const e of this.scene)"point"===e.type&&(o[n++]=e);this._pointQuadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(o)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){var o,n;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const r=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,i),a=null!==(n=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==n?n:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*s})}}applyPulse(e,t){var o,n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=this.config.pulse.duration)&&void 0!==o?o:500,a=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(t);let u=null;for(const o of e){if("connector"===o.type||"violin"===o.type||"boxplot"===o.type)continue;if("wedge"===o.type){const e=o.category;if(!e)continue;u||(u=this.getCategoryIndexMap(t));const n=u.get(e);if(!n)continue;let i=0;for(let e=0;n.length>e;e++){const t=this.timestampBuffer.get(n[e]);if(null==t)continue;const o=r-t;if(s>o){const e=1-o/s;e>i&&(i=e)}}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const e=c.get(o.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const i=r-n;s>i&&(o._pulseIntensity=1-i/s,o._pulseColor=a,o._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,n=this.timestampBuffer.peek();return null!=n&&o>t-n}synthesizeIntroPositions(){var e,t,o,n,i;this.prevPositionMap.clear();const r=new Map,s=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.r(0))&&void 0!==t?t:0,a="horizontal"!==(null===(o=this.scales)||void 0===o?void 0:o.projection);let l;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],o=this.getNodeKey(t,r);o&&("rect"===t.type?this.prevPositionMap.set(o,a?{x:t.x,y:s,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}:{x:s,y:t.y,w:0,h:t.h,opacity:null!==(i=t.style.opacity)&&void 0!==i?i:1}):"point"===t.type?this.prevPositionMap.set(o,{x:t.x,y:t.y,r:0,opacity:0}):"wedge"===t.type&&(void 0===l&&(l=t.startAngle),this.prevPositionMap.set(o,{x:t.cx,y:t.cy,startAngle:l,endAngle:l,innerRadius:t.innerRadius,outerRadius:t.outerRadius,opacity:0})))}}getNodeKey(e,t){var o,n,i;if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,n=t.get(o)||0;return t.set(o,n+1),`${o}:${n}`}return"rect"===e.type?`r:${e.group||""}:${null!==(n=null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==n?n:""}`:"wedge"===e.type?"w:"+(null!==(i=e.category)&&void 0!==i?i:""):null}snapshotPositions(){var e;this.prevPositionMap.clear();const t=new Map;for(let o=0;this.scene.length>o;o++){const n=this.scene[o],i=this.getNodeKey(n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:null!==(e=n.style.opacity)&&void 0!==e?e:1}))}}startTransition(){var e,t,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,v,m,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let w=!1;const j=new Set,A=new Map;for(let e=0;this.scene.length>e;e++){const c=this.scene[e],u=this.getNodeKey(c,A);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(j.add(u),c._targetOpacity=null!==(t=c.style.opacity)&&void 0!==t?t: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!==(o=c.style.opacity)&&void 0!==o?o: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?(j.add(u),c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n: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)j.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 e=c.startAngle;c.startAngle=e,c.endAngle=e,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:e,endAngle:e,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)if(!j.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(c=t.r)&&void 0!==c?c:3,style:{opacity:null!==(u=t.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(d=t.w)&&void 0!==d?d:0,h:null!==(h=t.h)&&void 0!==h?h:0,style:{opacity:null!==(g=t.opacity)&&void 0!==g?g:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const o=((null!==(f=t.startAngle)&&void 0!==f?f:0)+(null!==(p=t.endAngle)&&void 0!==p?p:0))/2;this.exitNodes.push({type:"wedge",cx:t.x,cy:t.y,innerRadius:null!==(y=t.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(v=t.outerRadius)&&void 0!==v?v:100,startAngle:null!==(m=t.startAngle)&&void 0!==m?m:0,endAngle:null!==(b=t.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=t.opacity)&&void 0!==x?x:1},datum:null,category:e.slice(2),_targetStartAngle:o,_targetEndAngle:o,_targetOpacity:0,_transitionKey:e})}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:Z(),duration:k})}advanceTransition(e){var t,o,n,i;if(!this.activeTransition)return!1;const r=K(e,this.activeTransition),s=U(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=Q(i,e._targetOpacity,s)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=Q(n.x,e._targetX,s),e.y=Q(n.y,e._targetY,s)),void 0!==e._targetR&&void 0!==(null==n?void 0:n.r)&&(e.r=Q(n.r,e._targetR,s))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=Q(i,e._targetOpacity,s)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,s),e.y=Q(o.y,e._targetY,s),void 0!==o.w&&(e.w=Q(o.w,e._targetW,s),e.h=Q(o.h,e._targetH,s))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),n=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Q(n,e._targetOpacity,s)})}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Q(o.startAngle,e._targetStartAngle,s),e.endAngle=Q(o.endAngle,e._targetEndAngle,s))}}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);if(0===i.length)return i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,i}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=new Set(Array.isArray(e)?e:[e]),n=this.getDataId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(e)),t);if(0===r.length)return r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),i.has(t)&&this.pushValueExtent(e)}),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(e){const t=Object.assign({},this.config);if(("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!I(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!I(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!I(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),("categoryAccessor"in e||"oAccessor"in e)&&(I(e.categoryAccessor||e.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=N(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in e||"rAccessor"in e){const o=e.valueAccessor||e.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(o)?o:[o],r=Array.isArray(n)?n:[n];if(i.length!==r.length||i.some((e,t)=>!I(e,r[t]))){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>D(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new R)):(this.getR=D(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!I(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?N(this.config.stackBy):void 0),"groupBy"in e&&!I(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?N(this.config.groupBy):void 0),"colorAccessor"in e&&!I(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?N(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!I(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?N(this.config.connectorAccessor):void 0)}}function Do(e,t,o){const n=ue(t,o,e);return n.hit?{datum:e.datum,x:n.cx,y:e.y,distance:0,category:e.group}:null}function Ho(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>de(e.r,n)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function No(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;const s=fe(Math.atan2(i,n)),a=fe(e.startAngle),l=fe(e.endAngle);if(!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function $o(e,t,o){const n=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-n>t||t>e.x+n||Math.min(e.minPos,e.maxPos)>o||o>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const i=e.y-n,r=e.y+n;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>o||o>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function Wo(e,t,o){if(!e.bounds)return null;const{x:n,y:i,width:r,height:s}=e.bounds;return n>t||t>n+r||i>o||o>i+s?null:{datum:e.datum,x:n+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}function Fo(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,showGrid:u,rFormat:d}=o,{rTickValues:h}=o,g="radial"===(null==l?void 0:l.projection),f="horizontal"===(null==l?void 0:l.projection),p=t.useMemo(()=>!l||g?[]:(h||l.r.ticks(5)).map(e=>({value:e,pixel:l.r(e),label:(d||Eo)(e)})),[l,d,g,h]),y=u&&l&&!g,v=c&&l&&!g;return y||v?e.jsx("svg",{width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[y&&e.jsx("g",{className:"ordinal-grid",children:p.map((t,o)=>e.jsx("line",{x1:f?t.pixel:0,y1:f?0:t.pixel,x2:f?t.pixel:n,y2:f?i:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),v&&e.jsx(e.Fragment,{children:e.jsxs(e.Fragment,f?{children:[e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function Eo(e){return Math.round(100*e)/100+""}function zo(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,showCategoryTicks:h,oLabel:g,rLabel:f,oFormat:p,rFormat:y,showGrid:v,title:m,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:j,legendPosition:A="right",foregroundGraphics:S,annotations:O,svgAnnotationRules:M,xAccessor:C,yAccessor:_,annotationData:P,underlayRendered:L,children:T}=o,R="radial"===(null==u?void 0:u.projection),B="horizontal"===(null==u?void 0:u.projection),I=!1!==h,D=t.useMemo(()=>d&&I&&u&&!R?u.o.domain().map((e,t)=>{var o;return{value:e,pixel:(null!==(o=u.o(e))&&void 0!==o?o:0)+u.o.bandwidth()/2,label:p?p(e,t):e}}):[],[d,I,u,p,R]),H=o.rTickValues,N=o.tickLabelEdgeAlign,$=t.useMemo(()=>d&&u&&!R?(H||u.r.ticks(5)).map(e=>({value:e,pixel:u.r(e),label:(y||Eo)(e)})):[],[d,u,y,R,H]),W=t.useRef(new Map),F=t.useRef(null!==(n=null==O?void 0:O.length)&&void 0!==n?n:0),E=null!==(i=null==O?void 0:O.length)&&void 0!==i?i:0;F.current!==E&&(F.current=E,W.current=new Map);const z=t.useMemo(()=>{if(!O||0===O.length)return null;const e=ot(),t="horizontal"===(null==u?void 0:u.projection),o=(null==u?void 0:u.o)?e=>{var t;return(null!==(t=u.o(e))&&void 0!==t?t:0)+u.o.bandwidth()/2}:null,n={scales:u?{x:t?u.r:o||u.r,y:t&&o||u.r,time:u.r,value:u.r,o:u.o}:null,timeAxis:"x",xAccessor:C,yAccessor:_,width:r,height:s,data:P,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return O.map((t,o)=>{if(M){const i=M(t,o,n);return null!=i?i:e(t,o,n)}return e(t,o,n)}).filter(Boolean)},[O,M,r,s,u,C,_,P]);return d||m||b||S||z&&z.length>0||v||T?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof m?m:"Ordinal Chart"}),e.jsx("desc",{children:"string"==typeof m?m+" — ordinal data visualization":"Ordinal data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[v&&u&&!R&&!L&&e.jsx("g",{className:"ordinal-grid",children:$.map((t,o)=>e.jsx("line",{x1:B?t.pixel:0,y1:B?0:t.pixel,x2:B?t.pixel:r,y2:B?s:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),d&&u&&!R&&e.jsx("g",{className:"ordinal-axes",children:e.jsxs(e.Fragment,B?{children:[!L&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),D.map((t,o)=>e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"cat-"+o)),g&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,style:{userSelect:"none"},children:g}),!L&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!L&&(null==u?void 0:u.r)&&(()=>{const t=u.r(0);return t>1&&r-1>t?e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),$.map((t,o)=>{const n=N?0===o?"start":o===$.length-1?"end":"middle":"middle";return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{y:18,textAnchor:n,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label})]},"val-"+o)}),f&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:f})]}:{children:[!L&&(()=>{const t=(null==u?void 0:u.r)?u.r(0):s,o=0>t||t>s?s:t;return e.jsx("line",{x1:0,y1:o,x2:r,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),D.map((t,o)=>e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"cat-"+o)),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:g}),!L&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),$.map((t,o)=>e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label})]},"val-"+o)),f&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,style:{userSelect:"none"},children:f})]})}),z,S,T]}),m&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof m?m:null}),Fe({legend:b,totalWidth:a,totalHeight:l,margin:c,legendPosition:A,title:m,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:j})]}):null}function Yo({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,scales:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(u);g.current=u;const f=t.useRef(c);f.current=c;const p=t.useRef(!1),y=t.useRef(null),v="horizontal"===(null==c?void 0:c.projection),m=t.useRef(v);return m.current=v,t.useEffect(()=>{if(!d.current)return;const e=o.select(d.current).select(".brush-g"),t=v?n.brushX():n.brushY();return t.extent([[0,0],[i,r]]),t.on("brush end",e=>{if(p.current)return;const t=f.current;if(!t)return;if(!e.selection)return y.current=null,void g.current(null);const[o,n]=e.selection;let i;i=m.current?[t.r.invert(o),t.r.invert(n)]:[t.r.invert(n),t.r.invert(o)];const r={r:i};y.current=r,g.current(r)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),h.current=null}},[i,r,v]),t.useEffect(()=>{if(!c||!h.current||!y.current)return;if(!d.current)return;const e=y.current,t=o.select(d.current).select(".brush-g"),n=c.r(e.r[0]),i=c.r(e.r[1]);v?(p.current=!0,t.call(h.current.move,[n,i]),p.current=!1):(p.current=!0,t.call(h.current.move,[i,n]),p.current=!1)},[c,v]),e.jsx("svg",{ref:d,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`,style:{pointerEvents:"all"}})})}function Go(e,t){e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath()}function qo(e,t){const o=c.arc().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle+Math.PI/2).endAngle(t.endAngle+Math.PI/2).cornerRadius(t.cornerRadius)({});if(!o)return;e.save(),e.translate(t.cx,t.cy);const n=new Path2D(o);e.fill(n),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(n),e.restore()}Io.QUADTREE_THRESHOLD=500;const Xo=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"wedge"===e.type);for(const t of s){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:1,n=null!==(r=t.style.opacity)&&void 0!==r?r:1;e.globalAlpha=o*n,e.fillStyle=("string"==typeof t.style.fill?Zt(e,t.style.fill):t.style.fill)||"#007bff",t.cornerRadius?(t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),qo(e,t)):(Go(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())),t._pulseIntensity&&t._pulseIntensity>0&&(Go(e,t),ho(e,t)),e.globalAlpha=1}},Vo=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const o=new Path2D(t.pathString);if(e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6,e.fillStyle=("string"==typeof t.style.fill?Zt(e,t.style.fill):t.style.fill)||"#007bff",e.fill(o),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(o)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const o=t.iqrLine.centerPos,n=!1!==t.iqrLine.isVertical;e.beginPath(),n?(e.moveTo(o,t.iqrLine.q1Pos),e.lineTo(o,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,o),e.lineTo(t.iqrLine.q3Pos,o)),e.stroke(),e.beginPath(),n?e.arc(o,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,o,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},Uo=(e,t,o,n)=>{var i,r,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const o=t[0].style;if(o.fill&&"none"!==o.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const o of t)e.lineTo(o.x2,o.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=o.fillOpacity)&&void 0!==i?i:o.opacity)&&void 0!==r?r:.3,e.fillStyle=o.fill,e.fill(),e.globalAlpha=1}for(const o of t)e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.strokeStyle=Zt(e,o.style.stroke)||("string"==typeof o.style.fill?Zt(e,o.style.fill):o.style.fill)||Zt(e,"var(--semiotic-border, #999)"),e.lineWidth=o.style.strokeWidth||1,e.globalAlpha=null!==(s=o.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}};function Ko(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Qo(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Zo=null;function Jo(e={},t){const{background:o="transparent",stroke:n="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*r));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Zo||(Zo=document.createElement("canvas")),Zo.width=e,Zo.height=e,Zo)}(a)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;o&&"transparent"!==o?(c.fillStyle=o,c.fillRect(0,0,a,a)):c.clearRect(0,0,a,a),c.strokeStyle=n,c.lineWidth=i,c.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=r)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*a,a),c.stroke()}else{c.save(),c.translate(a/2,a/2),c.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=r)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}const en=new Map;function tn(e,t){const o=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,n=en.get(o);if(void 0!==n)return n;const i=Jo({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return en.set(o,i),i}function on(e,t,o,n,i,r){e.moveTo(t+r,o),e.lineTo(t+n-r,o),e.quadraticCurveTo(t+n,o,t+n,o+r),e.lineTo(t+n,o+i-r),e.quadraticCurveTo(t+n,o+i,t+n-r,o+i),e.lineTo(t+r,o+i),e.quadraticCurveTo(t,o+i,t,o+i-r),e.lineTo(t,o+r),e.quadraticCurveTo(t,o,t+r,o),e.closePath()}function nn(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function rn(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const sn=e=>[Uo,...e],an={bar:sn([mo]),clusterbar:sn([mo]),point:sn([yo]),swarm:sn([yo]),pie:[Xo],donut:[Xo],boxplot:sn([(e,t,o,n)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const o=t.columnWidth/2,n="vertical"===t.projection,s=Zt(e,"var(--semiotic-primary, #007bff)"),a=Zt(e,"var(--semiotic-text, #333)"),l=t.style.fill,c="string"==typeof l?Zt(e,l)||l:null!=l?l:s,u=t.style.stroke,d="string"==typeof u?Zt(e,u)||u:a,h=t.style.strokeWidth||1,g=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6;if(e.save(),e.strokeStyle=d,e.lineWidth=h,e.beginPath(),n?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),n?(e.moveTo(t.x-.4*o,t.minPos),e.lineTo(t.x+.4*o,t.minPos),e.moveTo(t.x-.4*o,t.maxPos),e.lineTo(t.x+.4*o,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*o),e.lineTo(t.minPos,t.y+.4*o),e.moveTo(t.maxPos,t.y-.4*o),e.lineTo(t.maxPos,t.y+.4*o)),e.stroke(),e.globalAlpha=g,e.fillStyle=c,n){const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-o,n,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-o,n,t.columnWidth,i)}else{const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(n,t.y-o,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(n,t.y-o,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),n?(e.moveTo(t.x-o,t.medianPos),e.lineTo(t.x+o,t.medianPos)):(e.moveTo(t.medianPos,t.y-o),e.lineTo(t.medianPos,t.y+o)),e.stroke(),e.restore()}},yo]),violin:sn([Vo]),histogram:sn([mo]),ridgeline:sn([Vo]),timeline:sn([mo]),funnel:[mo,(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const o=t.points;if(o.length>=4){e.globalAlpha=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1,e.beginPath(),e.moveTo(o[0][0],o[0][1]);for(let t=1;o.length>t;t++)e.lineTo(o[t][0],o[t][1]);e.closePath(),e.fillStyle=(null===(s=t.style)||void 0===s?void 0:s.fill)||"#999",e.fill(),(null===(a=t.style)||void 0===a?void 0:a.stroke)&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}},(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==l.length&&l.some(e=>null!=e.datum.__funnelStepLabel||null!=e.datum.__funnelValueLabelX)){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const o=t.datum;if(!o.__funnelStepLabel)continue;const n=o.__funnelStepLabel;if(e.measureText(n).width+16>(null!==(r=null!==(i=o.__funnelRowWidth)&&void 0!==i?i:o.__funnelBarW)&&void 0!==r?r:0))continue;const s=o.__funnelStepLabelX,a=o.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(n,s,a),e.fillStyle="#fff",e.fillText(n,s,a)}e.font="bold 13px sans-serif";for(const t of l){const o=t.datum;if(null==o.__funnelValueLabelX)continue;const n=null!==(s=o.__funnelBarW)&&void 0!==s?s:0;if(60>n)continue;const i=o.__funnelValue;if(null==i||0===i)continue;const r=o.__funnelPercent,l=!0===o.__funnelIsFirstStep;let c;if(c=l?Ko(i):null!=r?`${Ko(i)} (${Qo(r)})`:Ko(i),e.measureText(c).width+16>n){if(l||null==r)continue;if(c=Ko(i),e.measureText(c).width+16>n)continue}const u=o.__funnelValueLabelX,d=(null!==(a=o.__funnelValueLabelY)&&void 0!==a?a:t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(c,u,d),e.fillStyle="#fff",e.fillText(c,u,d)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[mo,(e,t,o,n)=>{var i,r;const s=t.filter(e=>{var t;return"rect"===e.type&&!0===(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)});for(const t of s){const o=("string"==typeof t.style.fill?t.style.fill:null)||Zt(e,"var(--semiotic-border, #999)"),n=tn(o,e);e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),n?e.fillStyle=n:(e.fillStyle=o,e.globalAlpha=.4*(null!==(r=t.style.opacity)&&void 0!==r?r:1)),e.fill(),e.globalAlpha=1}},(e,t,o,n)=>{const i=t.filter(e=>{var t,o;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(o=e.datum)||void 0===o?void 0:o.__barFunnelLabelX)});if(0===i.length)return;const r=Zt(e,"var(--semiotic-text, #333)"),s=Zt(e,"var(--semiotic-text-secondary, #666)");for(const t of i){const o=t.datum,n=o.__barFunnelValue;if(null==n)continue;if(25>t.w)continue;const i=o.__barFunnelPercent,a=!(!0===o.__barFunnelIsFirstStep)&&null!=i,l=a?rn(i):"",c=nn(n);e.font="bold 13px sans-serif";const u=a?e.measureText(l).width:0;e.font="11px sans-serif";const d=e.measureText(c).width,h=Math.max(u,d)+12,g=a?32:17,f=o.__barFunnelLabelX,p=f-h/2,y=o.__barFunnelLabelY-g-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle="rgba(255,255,255,0.95)",e.beginPath(),on(e,p,y,h,g,4),e.fill(),e.restore(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.beginPath(),on(e,p,y,h,g,4),e.stroke(),e.textAlign="center",e.textBaseline="top",a?(e.font="bold 13px sans-serif",e.fillStyle=r,e.fillText(l,f,y+3),e.font="11px sans-serif",e.fillStyle=s,e.fillText(c,f,y+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=r,e.fillText(c,f,y+3))}e.lineWidth=1}],swimlane:sn([mo])},ln={top:50,right:40,bottom:60,left:70},cn={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function un({hover:t}){var o,n,i,r,s,a;const l=t.data||{},c=t.stats,u=t.category;if(Array.isArray(l)){const t=u||(null===(o=l[0])||void 0===o?void 0:o.category)||"";if(c)return e.jsxs("div",{className:"semiotic-tooltip",style:cn,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:["n = ",c.n]}),e.jsxs("div",{children:["Min: ",c.min.toLocaleString()]}),e.jsxs("div",{children:["Q1: ",c.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",c.median.toLocaleString()]}),e.jsxs("div",{children:["Q3: ",c.q3.toLocaleString()]}),e.jsxs("div",{children:["Max: ",c.max.toLocaleString()]}),e.jsxs("div",{style:{opacity:.8},children:["Mean: ",c.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const n=l.length;return e.jsxs("div",{className:"semiotic-tooltip",style:cn,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:[n," items"]})]})}if(null!=l.bin&&null!=l.count){const t=l.range||[];return e.jsxs("div",{className:"semiotic-tooltip",style:cn,children:[l.category&&e.jsx("div",{style:{fontWeight:"bold"},children:l.category+""}),e.jsxs("div",{children:["Count: ",l.count]}),2===t.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)]})]})}const d=t.__oAccessor,h=t.__rAccessor,g=t.__chartType;if("swarm"===g||"point"===g){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:cn,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}const f=(d&&null!=l[d]?l[d]:null)||l.category||l.name||l.group||l.__rName||"",p=null!==(a=null!==(s=null!==(r=null!==(i=null!==(n=l.__aggregateValue)&&void 0!==n?n:h&&null!=l[h]?l[h]:null)&&void 0!==i?i:l.value)&&void 0!==r?r:l.__rValue)&&void 0!==s?s:l.pct)&&void 0!==a?a:"";if(!f&&""===p){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:cn,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}return e.jsxs("div",{className:"semiotic-tooltip",style:cn,children:[f&&e.jsx("div",{style:{fontWeight:"bold"},children:f+""}),""!==p&&e.jsx("div",{children:"number"==typeof p?p.toLocaleString():p+""})]})}const dn=t.forwardRef(function(o,n){var i,r,s,a,l,u,d,h,g,f;const{chartType:p,runtimeMode:v,data:m,oAccessor:b="category",rAccessor:x="value",colorAccessor:w,stackBy:j,groupBy:S,multiAxis:O,timeAccessor:M,valueAccessor:C,categoryAccessor:_,projection:P="vertical",size:L=[600,400],responsiveWidth:T,responsiveHeight:R,margin:B,barPadding:I,roundedTop:D,gradientFill:H,baselinePadding:N,innerRadius:$,cornerRadius:W,normalize:F,startAngle:E,sweepAngle:z,dynamicColumnWidth:Y,bins:G,showOutliers:q,showIQR:X,amplitude:V,connectorOpacity:U,showLabels:K,connectorAccessor:Q,connectorStyle:Z,dataIdAccessor:J,rExtent:ee,oExtent:te,extentPadding:oe=.05,oSort:ne,windowMode:ie="sliding",windowSize:re=200,pieceStyle:se,summaryStyle:ae,colorScheme:le,barColors:ce,showAxes:ue=!0,showCategoryTicks:de,categoryLabel:he,valueLabel:ge,categoryFormat:fe,valueFormat:ye,oLabel:ve,rLabel:me,oFormat:be,rFormat:xe,rTickValues:ke,tickLabelEdgeAlign:we,enableHover:je=!0,hoverAnnotation:Ae,tooltipContent:Se,customHoverBehavior:_e,annotations:Te,svgAnnotationRules:Re,showGrid:Be=!1,legend:Ie,legendHoverBehavior:De,legendClickBehavior:He,legendHighlightedCategory:Ne,legendIsolatedCategories:$e,legendPosition:We,backgroundGraphics:Fe,foregroundGraphics:Ee,title:ze,className:Ye,background:Ge,centerContent:qe,decay:Xe,pulse:Ve,transition:Ue,animate:Ke,staleness:Qe,brush:Ze,onBrush:Je,accessibleTable:et=!0,description:tt,summary:ot}=o,nt=t.useRef(!0),it=eo({sizeProp:L,responsiveWidth:T,responsiveHeight:R,userMargin:B,marginDefault:ln,foregroundGraphics:Ee,backgroundGraphics:Fe,animate:Ke,transitionProp:Ue,themeDirtyRef:nt}),{reducedMotionRef:rt,responsiveRef:st,size:at,margin:lt,adjustedWidth:ct,adjustedHeight:ut,resolvedForeground:dt,resolvedBackground:ht,currentTheme:gt,transition:ft,introEnabled:pt,tableId:yt,rafRef:vt,renderFnRef:mt,scheduleRender:kt}=it,wt=null!=he?he:ve,jt=null!=ge?ge:me,At=null!=fe?fe:be,Ot=null!=ye?ye:xe,Mt=t.useRef(null),Ct=t.useRef(null),[_t,Pt]=t.useState(null),[Lt,Tt]=t.useState(null),[Rt,Bt]=t.useState(0),[Dt,Wt]=t.useState(!1),zt=je||Ae,Yt="streaming"===v,Gt=t.useMemo(()=>{var e,t,o;return{chartType:p,runtimeMode:Yt?"streaming":"bounded",windowSize:re,windowMode:ie,extentPadding:oe,projection:P,oAccessor:Yt?void 0:b,rAccessor:Yt?void 0:x,colorAccessor:w,stackBy:j,groupBy:S,multiAxis:O,timeAccessor:Yt?M:void 0,valueAccessor:Yt?C||("string"==typeof x||"function"==typeof x?x:void 0):void 0,categoryAccessor:Yt?_||b:void 0,rExtent:ee,oExtent:te,barPadding:I,roundedTop:D,gradientFill:H,baselinePadding:N,innerRadius:$,cornerRadius:W,normalize:F,startAngle:E,sweepAngle:z,dynamicColumnWidth:Y,bins:G,showOutliers:q,showIQR:X,amplitude:V,connectorOpacity:U,showLabels:K,connectorAccessor:Q,connectorStyle:Z,dataIdAccessor:J,oSort:ne,pieceStyle:se,summaryStyle:ae,colorScheme:le,themeCategorical:null===(e=null==gt?void 0:gt.colors)||void 0===e?void 0:e.categorical,themeSemantic:A(gt),themeSequential:null===(t=null==gt?void 0:gt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==gt?void 0:gt.colors)||void 0===o?void 0:o.diverging,barColors:ce,decay:Xe,pulse:Ve,transition:ft,introAnimation:pt,staleness:Qe}},[p,re,ie,oe,P,b,x,w,j,S,O,M,C,_,ee,te,I,D,H,N,$,W,F,E,z,Y,G,q,X,V,U,K,Q,Z,J,ne,se,ae,le,ce,Xe,Ve,null==ft?void 0:ft.duration,null==ft?void 0:ft.easing,pt,Qe,Yt,gt]),qt=t.useRef(null);qt.current||(qt.current=new Io(Gt)),t.useEffect(()=>{var e;null===(e=qt.current)||void 0===e||e.updateConfig(Gt),nt.current=!0,kt()},[Gt,kt]);const Xt=t.useRef(null);Xt.current||(Xt.current=new k(e=>{const t=qt.current;t&&t.ingest(e)&&(nt.current=!0,kt())}));const Vt=t.useCallback(e=>{var t;null===(t=Xt.current)||void 0===t||t.push(e)},[]),Ut=t.useCallback(e=>{var t;null===(t=Xt.current)||void 0===t||t.pushMany(e)},[]),Kt=t.useCallback(()=>{var e,t;null===(e=Xt.current)||void 0===e||e.clear(),null===(t=qt.current)||void 0===t||t.clear(),nt.current=!0,kt()},[kt]),Qt=t.useCallback(e=>{var t,o;null===(t=Xt.current)||void 0===t||t.clearLastData(),null===(o=Xt.current)||void 0===o||o.setReplacementData(e)},[]);t.useImperativeHandle(n,()=>({push:Vt,pushMany:Ut,replace:Qt,remove:e=>{var t,o,n,i;null===(t=Xt.current)||void 0===t||t.flush();const r=null!==(n=null===(o=qt.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];if(r.length>0){const e=null===(i=Ct.current)||void 0===i?void 0:i.data;!!Ct.current&&r.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(Ct.current=null,Pt(null)),nt.current=!0,kt()}return r},update:(e,t)=>{var o,n,i;null===(o=Xt.current)||void 0===o||o.flush();const r=null!==(i=null===(n=qt.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(nt.current=!0,kt()),r},clear:Kt,getData:()=>{var e,t,o;return null===(e=Xt.current)||void 0===e||e.flush(),null!==(o=null===(t=qt.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=qt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Vt,Ut,Qt,Kt,kt]),t.useEffect(()=>{var e;m&&(null===(e=Xt.current)||void 0===e||e.setBoundedData(m))},[m]);const{hoverHandlerRef:Zt,hoverLeaveRef:Jt,onPointerMove:to,onPointerLeave:no}=it;Zt.current=e=>{if(!zt)return;const t=Mt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-lt.left,i=e.clientY-o.top-lt.top;if(0>n||n>ct||0>i||i>ut)return void(Ct.current&&(Ct.current=null,Pt(null),_e&&_e(null),kt()));const r=qt.current;if(!r||0===r.scene.length)return;const s="radial"===P,a=function(e,t,o,n=30,i,r=0){let s=null;if(i){const e=pe(i,t,o,n,r);e&&(s={datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const r of e){let e=null;switch(r.type){case"rect":e=Do(r,t,o);break;case"point":if(i)break;e=Ho(r,t,o,n);break;case"wedge":e=No(r,t,o);break;case"boxplot":e=$o(r,t,o);break;case"violin":e=Wo(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(r.scene,s?n-ct/2:n,s?i-ut/2:i,30,r.pointQuadtree,r.maxPointRadius);if(!a)return void(Ct.current&&(Ct.current=null,Pt(null),_e&&_e(null),kt()));const l=xo(a.datum||{},a.x,a.y,Object.assign(Object.assign(Object.assign({},a.stats&&{stats:a.stats}),a.category&&{category:a.category}),{__oAccessor:"string"==typeof b?b:void 0,__rAccessor:"string"==typeof x?x:void 0,__chartType:p}));Ct.current=l,Pt(l),_e&&(_e(l),nt.current=!0),kt()},Jt.current=()=>{Ct.current&&(Ct.current=null,Pt(null),_e&&(_e(null),nt.current=!0),kt())};const io=t.useRef(-1),ro=t.useRef(null),so=t.useRef(null),ao=t.useCallback(e=>{const t=qt.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if(so.current&&so.current.version===o)n=so.current.graph;else{const e=function(e){var t,o,n,i;const r=[];for(const s of e)if("rect"===s.type&&null!=s.x){const e=null!==(o=null===(t=s.datum)||void 0===t?void 0:t.category)&&void 0!==o?o:"";r.push({x:s.x+s.w/2,y:s.y+s.h/2,datum:s.datum,shape:"rect",w:s.w,h:s.h,group:null!==(n=s.group)&&void 0!==n?n:e})}else if("point"===s.type)r.push({x:s.x,y:s.y,datum:s.datum,shape:"circle",group:null!==(i=s.group)&&void 0!==i?i:"_default"});else if("wedge"===s.type&&null!=s.cx){const e=((s.startAngle||0)+(s.endAngle||0))/2,t=((s.innerRadius||0)+(s.outerRadius||50))/2;r.push({x:s.cx+Math.cos(e)*t,y:s.cy+Math.sin(e)*t,datum:s.datum,shape:"wedge",group:"_default"})}return r.sort((e,t)=>e.x-t.x||e.y-t.y),r}(t.scene);if(0===e.length)return;n=Oe(e),so.current={version:o,graph:n}}const i=io.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),io.current=0;const t=n.flat[0];ro.current={shape:t.shape,w:t.w,h:t.h};const o=Object.assign(Object.assign({},Pe(t)),{__oAccessor:"string"==typeof b?b:void 0,__rAccessor:"string"==typeof x?x:void 0,__chartType:p});return Ct.current=o,Pt(o),_e&&_e(o),void kt()}const r=Me(n,i),s=Ce(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return io.current=-1,ro.current=null,Ct.current=null,Pt(null),_e&&_e(null),void kt();io.current=s;const a=n.flat[s];ro.current={shape:a.shape,w:a.w,h:a.h};const l=Object.assign(Object.assign({},Pe(a)),{__oAccessor:"string"==typeof b?b:void 0,__rAccessor:"string"==typeof x?x:void 0,__chartType:p});Ct.current=l,Pt(l),_e&&_e(l),kt()},[_e,kt]),lo=t.useCallback(e=>{io.current=-1,ro.current=null,to(e)},[to]);mt.current=()=>{var e,t;vt.current=0;const o=Mt.current;if(!o)return;const n=o.getContext("2d");if(!n)return;const i=qt.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(rt.current?r+1e6:r),a=!rt.current&&s,l=nt.current;l&&!s&&(i.computeScene({width:ct,height:ut}),nt.current=!1),(l||a)&&o.setAttribute("aria-label",St(i.scene,p+" chart"));const c=oo(),u=at[0]*c,d=at[1]*c;o.width===u&&o.height===d||(o.width=u,o.height=d,o.style.width=at[0]+"px",o.style.height=at[1]+"px"),n.setTransform(c,0,0,c,0,0),n.clearRect(0,0,at[0],at[1]);const h=null!==(e=null==Qe?void 0:Qe.threshold)&&void 0!==e?e:5e3,g=Qe&&i.lastIngestTime>0&&r-i.lastIngestTime>h;if(g&&(n.globalAlpha=null!==(t=null==Qe?void 0:Qe.dimOpacity)&&void 0!==t?t:.5),"transparent"!==Ge&&!Fe){const e=o?getComputedStyle(o).getPropertyValue("--semiotic-bg").trim():"",t=Ge||(e&&"transparent"!==e?e:null);t&&(n.fillStyle=t,n.fillRect(0,0,at[0],at[1]))}const f="radial"===P;n.save(),n.beginPath(),n.rect(lt.left,lt.top,ct,ut),n.clip(),f?(n.save(),n.translate(lt.left+ct/2,lt.top+ut/2)):n.translate(lt.left,lt.top);const y=an[p]||[],v={width:ct,height:ut};for(const e of y)e(n,i.scene,i.scales,v);f&&n.restore(),n.restore(),g&&(n.globalAlpha=1),l&&i.scales&&(Tt(i.scales),Bt(e=>e+1)),(null==Qe?void 0:Qe.showBadge)&&Wt(!!g),(a||null!=i.activeTransition||i.hasActivePulses)&&(vt.current=requestAnimationFrame(()=>mt.current()))},t.useEffect(()=>(kt(),()=>{var e;null===(e=Xt.current)||void 0===e||e.clear()}),[kt]),t.useEffect(()=>{nt.current=!0,kt()},[p,ct,ut,ue,Ge,kt]),Le(Qe,qt,nt,kt,Dt,Wt);const co=zt&&_t?Se?Se(_t):e.jsx(un,{hover:_t}):null,uo="radial"===P,ho=co?e.jsx(Et,{x:_t?uo?_t.x+ct/2:_t.x:0,y:_t?uo?_t.y+ut/2:_t.y:0,containerWidth:ct,containerHeight:ut,margin:lt,className:"stream-ordinal-tooltip",children:co}):null;if(xt){const t=qt.current;t&&m&&(t.ingest({inserts:m,bounded:!0}),t.computeScene({width:ct,height:ut}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,s="radial"===P,a=s?lt.left+ct/2:lt.left,l=s?lt.top+ut/2:lt.top;return e.jsxs("div",{className:"stream-ordinal-frame"+(Ye?" "+Ye:""),role:"img","aria-label":tt||("string"==typeof ze?ze:"Ordinal chart"),style:{position:"relative",width:at[0],height:at[1]},children:[e.jsx(Ht,{summary:ot}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:at[0],height:at[1],style:{position:"absolute",left:0,top:0},children:[ht&&e.jsx("g",{transform:`translate(${lt.left},${lt.top})`,children:ht}),e.jsxs("g",{transform:`translate(${a},${l})`,children:[Ge&&e.jsx("rect",{x:0,y:0,width:ct,height:ut,fill:Ge}),o.map((t,o)=>function(t,o){var n,i,r,s,a;const l=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",u=e=>`ord-${t.type}-${l}-${o}-${e}`,d=`ord-${t.type}-${l}-${o}`;switch(t.type){case"rect":{const o=t,n=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(d)+"-grad",i=function(t,o){const n=t.fillGradient;if(!n)return null;let i=t.x,r=t.y,s=t.x,a=t.y+t.h;"bottom"===t.roundedEdge?(r=t.y+t.h,a=t.y):"right"===t.roundedEdge?(i=t.x+t.w,r=t.y,s=t.x,a=t.y):"left"===t.roundedEdge&&(i=t.x,r=t.y,s=t.x+t.w,a=t.y);const l=[];if("colorStops"in n){const t=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>t.length)return null;for(let o=0;t.length>o;o++)l.push(e.jsx("stop",{offset:t[o].offset,stopColor:t[o].color},o))}else{const o=bt(t.style.fill);l.push(e.jsx("stop",{offset:0,stopColor:o,stopOpacity:n.topOpacity},"0")),l.push(e.jsx("stop",{offset:1,stopColor:o,stopOpacity:n.bottomOpacity},"1"))}return e.jsx("linearGradient",{id:o,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(o,n),r=i?`url(#${n})`:bt(o.style.fill);if(o.roundedTop&&o.roundedTop>0){const t=Math.min(o.roundedTop,o.w/2,o.h/2),{x:n,y:s,w:a,h:l}=o;let c;switch(o.roundedEdge){case"right":c=`M${n},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n},${s+l} Z`;break;case"left":c=`M${n+a},${s} L${n+t},${s} A${t},${t} 0 0 0 ${n},${s+t} L${n},${s+l-t} A${t},${t} 0 0 0 ${n+t},${s+l} L${n+a},${s+l} Z`;break;case"bottom":c=`M${n},${s} L${n+a},${s} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n+t},${s+l} A${t},${t} 0 0 1 ${n},${s+l-t} Z`;break;default:c=`M${n},${s+l} L${n},${s+t} A${t},${t} 0 0 1 ${n+t},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l} Z`}return e.jsxs(y.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:c,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}return e.jsxs(y.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:bt(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},d)}case"wedge":{const o=t,n=c.arc().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&n.cornerRadius(o.cornerRadius);const i=n({})||"";return e.jsx("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:bt(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},d)}case"boxplot":{const o=t,n=o.columnWidth/2;return e.jsxs("g","vertical"===o.projection?{children:[e.jsx("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:o.x-n,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:bt(o.style.fill),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-n,y1:o.medianPos,x2:o.x+n,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.x-.5*n,y1:o.minPos,x2:o.x+.5*n,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-.5*n,y1:o.maxPos,x2:o.x+.5*n,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[e.jsx("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-n,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:bt(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.medianPos,y1:o.y-n,x2:o.medianPos,y2:o.y+n,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.minPos,y1:o.y-.5*n,x2:o.minPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.maxPos,y1:o.y-.5*n,x2:o.maxPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1})]},d)}case"violin":{const o=t,n=[e.jsx("path",{d:o.pathString,transform:o.translateX||o.translateY?`translate(${o.translateX},${o.translateY})`:void 0,fill:bt(o.style.fill),fillOpacity:null!==(s=o.style.fillOpacity)&&void 0!==s?s:.6,stroke:o.style.stroke||"#333",strokeWidth:o.style.strokeWidth||1},u("path"))];if(o.iqrLine&&o.bounds){const t=o.bounds,i=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?n.push(e.jsx("line",{x1:i,y1:o.iqrLine.q1Pos,x2:i,y2:o.iqrLine.q3Pos,stroke:o.style.stroke||"#333",strokeWidth:2},u("iqr")),e.jsx("circle",{cx:i,cy:o.iqrLine.medianPos,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},u("med"))):n.push(e.jsx("line",{x1:o.iqrLine.q1Pos,y1:r,x2:o.iqrLine.q3Pos,y2:r,stroke:o.style.stroke||"#333",strokeWidth:2},u("iqr")),e.jsx("circle",{cx:o.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},u("med")))}return e.jsx("g",{children:n},d)}case"connector":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(a=t.style.opacity)&&void 0!==a?a:.5},d);case"trapezoid":{const o=t,n=o.points.map(e=>`${e[0]},${e[1]}`).join(" ");return e.jsx("polygon",{points:n,fill:bt(o.style.fill,"#999"),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},d)}default:return null}}(t,o)).filter(Boolean)]})]}),e.jsx(zo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:n,showAxes:ue,showCategoryTicks:de,oLabel:wt,rLabel:jt,oFormat:At,rFormat:Ot,rTickValues:ke,tickLabelEdgeAlign:we,showGrid:Be,title:ze,legend:Ie,legendHoverBehavior:De,legendClickBehavior:He,legendHighlightedCategory:Ne,legendIsolatedCategories:$e,legendPosition:We,foregroundGraphics:dt,annotations:Te,svgAnnotationRules:Re,annotationFrame:0,xAccessor:"string"==typeof b?b:void 0,yAccessor:"string"==typeof x?x:void 0,annotationData:null==t?void 0:t.getData()}),qe&&"radial"===P&&e.jsx("div",{style:{position:"absolute",left:lt.left+ct/2,top:lt.top+ut/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:qe})]})}return e.jsxs("div",{ref:st,className:"stream-ordinal-frame"+(Ye?" "+Ye:""),role:"group","aria-label":tt||("string"==typeof ze?ze:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:T?"100%":at[0],height:R?"100%":at[1],overflow:"visible"},onKeyDown:ao,children:[et&&e.jsx(Nt,{tableId:yt}),et&&e.jsx(It,{scene:null!==(a=null===(s=qt.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:p+" chart",tableId:yt,chartTitle:"string"==typeof ze?ze:void 0}),e.jsx(Ht,{summary:ot}),e.jsxs("div",{role:"img","aria-label":tt||("string"==typeof ze?ze:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:zt?lo:void 0,onMouseLeave:zt?no:void 0,children:[ht&&e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:at[0],height:at[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${lt.left},${lt.top})`,children:ht})}),e.jsx(Fo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:Lt,showAxes:ue,showGrid:Be,rFormat:Ot,rTickValues:ke}),e.jsx("canvas",{ref:Mt,"aria-label":St(null!==(u=null===(l=qt.current)||void 0===l?void 0:l.scene)&&void 0!==u?u:[],p+" chart"),style:{position:"absolute",top:0,left:0,width:at[0],height:at[1]}}),e.jsx($t,{hoverPoint:_t}),e.jsx(zo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:Lt,showAxes:ue,showCategoryTicks:de,oLabel:wt,rLabel:jt,oFormat:At,rFormat:Ot,showGrid:Be,title:ze,legend:Ie,legendHoverBehavior:De,legendClickBehavior:He,legendHighlightedCategory:Ne,legendIsolatedCategories:$e,legendPosition:We,foregroundGraphics:dt,annotations:Te,svgAnnotationRules:Re,annotationFrame:Rt,xAccessor:"string"==typeof b?b:void 0,yAccessor:"string"==typeof x?x:void 0,annotationData:null===(d=qt.current)||void 0===d?void 0:d.getData(),underlayRendered:!0}),(Ze||Je)&&"radial"!==P&&e.jsx(Yo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:Lt,onBrush:Je||(()=>{})}),qe&&"radial"===P&&e.jsx("div",{style:{position:"absolute",left:lt.left+ct/2,top:lt.top+ut/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:qe}),(null==Qe?void 0:Qe.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Qe.badgePosition?{top:4,left:4}:"bottom-left"===Qe.badgePosition?{bottom:4,left:4}:"bottom-right"===Qe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Dt?"#dc3545":"#28a745",color:"white"}),children:Dt?"STALE":"LIVE"}),e.jsx(Ft,{active:io.current>=0,hoverPoint:_t,margin:lt,size:at,shape:null===(h=ro.current)||void 0===h?void 0:h.shape,width:null===(g=ro.current)||void 0===g?void 0:g.w,height:null===(f=ro.current)||void 0===f?void 0:f.h}),ho]})]})});dn.displayName="StreamOrdinalFrame";const hn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},gn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class fn{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const o=this.particles[t];return o.active=!0,o.t=0,o.offset=Math.random()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,o,n){var i;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const a=o[s.edgeIndex];if(!a||!a.bezier){s.active=!1,this._freeIndices.push(r);continue}const l=n&&null!==(i=n[s.edgeIndex])&&void 0!==i?i:1;s.t+=e*t*l*(a.bezier.circular?.3:1),1>s.t?pn(a.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let o=0;e>o;o++)t.length>o?this.particles[o]=t[o]:(this.particles[o]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(o));this.capacity=e}}function pn(e,t,o,n){if(e.circular&&e.segments)return void function(e,t,o,n,i){const r=e.length,s=t*r,a=Math.min(Math.floor(s),r-1),l=s-a,[c,u,d,h]=e[a];yn(c,u,d,h,l,i);const g=h.x-c.x,f=h.y-c.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;i.x+=-f/p*o*n*2,i.y+=e*o*n*2}}(e.segments,t,o,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[i,r,s,a]=e.points;yn(i,r,s,a,t,n);const l=a.x-i.x,c=a.y-i.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;n.x+=-c/u*o*e.halfWidth*2,n.y+=t*o*e.halfWidth*2}}function yn(e,t,o,n,i,r){const s=1-i,a=s*s,l=a*s,c=i*i,u=c*i;r.x=l*e.x+3*a*i*t.x+3*s*c*o.x+u*n.x,r.y=l*e.y+3*a*i*t.y+3*s*c*o.y+u*n.y}function vn(e,t){var o=e.get(t);if(!o)throw Error("missing: "+t);return o}function mn(e,t){var o,n=[],i=[],r=[],s={},a=[];function l(e){r[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],r[t]&&l(t)})}function c(e){var t,n,d=!1;for(i.push(e),r[e]=!0,t=0;a[e].length>t;t++)(n=a[e][t])===o?(u(o,i),d=!0):r[n]||(d=c(n));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[n=a[e][t]];h||(s[n]=h={}),h[n]=!0}return i.pop(),d}function u(e,t){var o=[].concat(t).concat(e);n.push(o)}function d(t){!function(t){for(var o=0;e.length>o;o++)o>=t&&e[o]||(e[o]=[]),e[o]=e[o].filter(function(e){return e>=t})}(t);for(var o,n=function(e){for(var t=e.length,o=Array(t),n=Array(t),i=Array(t),r=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)o[l]=-1,n[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(o[t]=n[t]=u,i[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>r[t]){for(var f=r[t];g.length>f;++f){var p=g[f];if(0>o[p]){o[p]=n[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(n[t]=0|Math.min(n[t],n[p])),0>s[p]||a[t].push(s[p])}r[t]=f}else{if(n[t]===o[t]){var y=[],v=[],m=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(i[b]=!1,y.push(b),v.push(a[b]),m+=a[b].length,s[b]=d.length,b===t){l.length=f;break}}d.push(y);var x=Array(m);for(f=0;v.length>f;f++)for(var k=0;v[f].length>k;k++)x[--m]=v[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>o[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),i=n.components.filter(function(e){return e.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],o=s);var l=i[o];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:r,adjList:c}}o=0;for(var h=e.length;h>o;){var g=d(o);if(o=g.leastVertex,a=g.adjList){for(var f=0;a.length>f;f++)for(var p=0;a[f].length>p;p++){var y=a[f][p];r[+y]=!1,s[y]={}}c(o),o+=1}else o=h}return n}function bn(e){return e.y0-e.y1>0?"up":"down"}function xn(e,t){return t(e.source)==t(e.target)}function kn(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var o=0;return e.target.targetLinks.forEach(function(e){o=e.circular?o+1:o}),1>=t&&1>=o}function wn(e){return e.target.x0-e.source.x1}function jn(e,t){var o=Sn(e),n=wn(t)/Math.tan(o);return"up"==bn(e)?e.y1-n:e.y1+n}function An(e,t){var o=Sn(e),n=wn(t)/Math.tan(o);return"up"==bn(e)?e.y1+n:e.y1-n}function Sn(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function On(e,t){return t(e)}function Mn(e){return _n(e.source)}function Cn(e){return _n(e.target)}function _n(e){return(e.y0+e.y1)/2}function Pn(e){return e.virtual?0:e.value}function Ln(e,t){var o=0;e.sourceLinks.forEach(function(e){o=e.circular&&!xn(e,t)?o+1:o});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!xn(e,t)?n+1:n}),o+n}function Tn(e){return e.target.depth}function Rn(e,t){return e.sourceLinks.length?e.depth:t-1}function Bn(e,t){return e.y0-t.y0}function In(e,t){return t.y0-e.y0}function Dn(e,t){return e.y1-t.y1}function Hn(e,t){return t.y1-e.y1}function Nn(e,t){return Wn(e.source,t.source)||e.index-t.index}function $n(e,t){return Wn(e.target,t.target)||e.index-t.index}function Wn(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Fn(e,t){return En(e)==En(t)?"bottom"==e.circularLinkType?In(e,t):Bn(e,t):En(t)-En(e)}function En(e){return e.target.column-e.source.column}function zn(e,t){return Yn(e)==Yn(t)}function Yn(e){return e.y0-e.y1>0?"up":"down"}function Gn(e,t,o,n,i){let r=e;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(r.links,function(e){return e.source.y0});r.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=r.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),qn(r.links.filter(function(e){return"top"==e.circularLinkType}),t,o),qn(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,o),r.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,xn(e,t)&&kn(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,a=e.circularLinkType,c=r.links.filter(function(e){return e.source.column==s&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?In:Bn);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=r.links.filter(function(e){return e.target.column==s&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?Hn:Dn),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(r.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,o=e.y0,n=e.target.x0,i=e.y1,r=(t+n)/2;return"M"+t+","+o+"C"+r+","+o+" "+r+","+i+" "+n+","+i}(e)}),r}function qn(e,t,o){e.sort(Fn);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var r=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xn(e,t)&&kn(e))e.circularPathData.verticalBuffer=r+e._circularWidth/2;else{for(var s=0;n.length>s;s++){var a=n[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Xn(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+o;r=l>r?l:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function Xn(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Vn(e){return function(){return e}}function Un(e){return e.index}function Kn(e){return e.nodes}function Qn(e){return e.links}function Zn(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(i,r){var s=i.length;if(t)i.sort(t);else if(r>0){var a=new Map;i.forEach(function(e,t){var o,n,i,r=(n=0,i=0,(o=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=_n(e.source)*t,n+=t}}),o.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=_n(e.target)*t,n+=t}}),n>0?i/n:NaN);a.set(e,{bc:r,idx:t})}),i.sort(function(e,t){var o=a.get(e),n=a.get(t),i=o.bc,r=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?o.idx-n.idx:1:-1:i-r})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Ln(t,o)-Ln(e,o):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==n.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Ln(t,o)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+i,t.y1=t.y0+t.value*e.ky)})})}function Jn(e,t,o,n,i,r){var s=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=r;c>0;--c)u(l*=.99,o),d();function u(t,o){var n=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ln(i,o)>0){var c=a.mean(i.sourceLinks,Cn),u=a.mean(i.targetLinks,Mn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-_n(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==n-1&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.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 g=a.mean(i.sourceLinks,Cn),f=a.mean(i.targetLinks,Mn),p=((g&&f?(g+f)/2:g||f)-_n(i))*t;i.y0+=p,i.y1+=p}})})}function d(){s.forEach(function(o){var r,s,a,l=e.y0,c=o.length;for(o.sort(t||Wn),a=0;c>a;++a)(s=l-(r=o[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+n;if((s=l-n-e.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=o[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function ei(e){e.nodes.forEach(function(e){e.sourceLinks.sort($n),e.targetLinks.sort(Nn)}),e.nodes.forEach(function(e){var t=e.y0,o=t,n=e.y1,i=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=o+e.width/2,o+=e.width)})})}function ti(){var e=0,t=0,o=1,n=1,i=24,r=8,s=null,l=Un,c=Rn,u=void 0,d=32,h=2,g=Kn,f=Qn;function p(){var p={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=o,g.y1=n,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var o=function(e,t){var o=new Map;return a.group(e,t).forEach(function(e,t){o.set(t,e[0])}),o}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,i=e.target;"object"!=typeof n&&(n=e.source=vn(o,n)),"object"!=typeof i&&(i=e.target=vn(o,i)),n.sourceLinks.push(e),i.targetLinks.push(e)})}(g,l),function(e,t){var o=0;if(null==t){for(var n=[],i=0;e.links.length>i;i++){var r=e.links[i],s=r.source.index,a=r.target.index;n[s]||(n[s]=[]),n[a]||(n[a]=[]),-1===n[s].indexOf(a)&&n[s].push(a)}var l=mn(n);l.sort(function(e,t){return e.length-t.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}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=o++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=o++)})}(g,u),function(e,t){var o=0,n=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:n>o?"top":"bottom","top"==i.circularLinkType?o++:n++,e.nodes.forEach(function(e){On(e,t)!=On(i.source,t)&&On(e,t)!=On(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xn(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Pn),a.sum(e.targetLinks,Pn)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,o){var n,i,r;if(null!=t){e.nodes.sort(function(e,o){return t(e)<t(o)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.height=r,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?o(e,r):e.column})}(g,u,c);var f=r;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(n-t)*s/(y-1)))}(function(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=a.min(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var r=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(r>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-o)/r),t.x1=t.x0+o}:function(t){t.x0=e.x0,t.x1=t.x0+o})})(g,f,i),Zn(g,u,l),Jn(g,u,l,f,f,d),ei(g),Gn(g,l,h,10,8),Zn(g,u,l),Jn(g,u,l,f,f,d),ei(g),Gn(g,l,h,10,8),function(e,t){let o=e;o.nodes.forEach(function(e){e.y+(e.y1-e.y0)>o.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-o.y1));var n=o.links.filter(function(o){return On(o.source,t)==On(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!zn(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var o=jn(t,e);return e.y1-o}if(t.target.column>e.target.column)return jn(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y0=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y0=e.y1-s-t.width/2}})})}(g,l),function(e,t){let o=e;o.nodes.forEach(function(e){var n=o.links.filter(function(o){return On(o.target,t)==On(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!zn(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var o=An(t,e);return e.y0-o}if(t.source.column>e.source.column)return An(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y1=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y1=e.y1-s-t.width/2}})})}(g,l),function(e){var t=e.nodes,o=e.links,n=!1,i=!1;if(o.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==n||0==i){var r=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-r);function c(t){return(t-r)/(s-r)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),o.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,o=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+o}),e.targetLinks.forEach(function(e){e.y1=e.y1+o})})}}(g),Gn(g,l,h,10,8)}(p),p}return p.update=function(e){return ei(e),Gn(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(i=+e,p):i},p.nodePadding=function(e){return arguments.length?(r=+e,p):r},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:Vn(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Vn(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Vn(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Vn(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],o=+i[1][0],n=+i[1][1],p):[[e,t],[o,n]]},p.size=function(i){return arguments.length?(e=t=0,o=+i[0],n=+i[1],p):[o-e,n-t]},p}const oi=e=>{let t,o,n,i,r,s,a,l,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,r=e.source.x1,s=e.target.x0,a=d.interpolateNumber(r,s),l=a(.5),c=a(.5),`M${t},${r}C${t},${l} ${o},${c} ${o},${s}L${n},${s}C${n},${c} ${i},${l} ${i},${r}Z`):(t=e.source.x1,o=e.target.x0,a=d.interpolateNumber(t,o),n=a(.5),i=a(.5),r=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${r}C${n},${r} ${i},${s} ${o},${s}L${o},${l}C${i},${l} ${n},${c} ${t},${c}Z`)};function ni(e){var t;const o=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const t=i.sourceX,n=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${t},${n-o}L${t+a},${n-o}L${t+a},${n+o}L${t},${n+o}ZM${r},${s-o}L${r-l},${s-o}L${r-l},${s+o}L${r},${s+o}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"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(n,15));return`M${r},${s-h*o}L${c},${s-h*o}L${c+n},${s-h*o+h*g}L${c+n},${d+h*n-h*g}L${c+n-g},${d+h*n}L${u-n+g},${d+h*n}L${u-n},${d+h*n-h*g}L${u-n},${l-h*o+h*g}L${u-n+g},${l-h*o}L${a},${l-h*o}L${a},${l+h*o}L${u+n},${l+h*o}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${s+h*o}L${r},${s+h*o}Z`}const ii=new Set,ri=new WeakMap;function si(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let o=ri.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,ri.set(e,o);const n=new Proxy(e,{get(e,o,n){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;ii.has(e)||(ii.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,o,n)}});return o.set(t,n),n}const ai={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Tn))-1:0},justify:Rn},li={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r,s,a,l,c,u;if(0===e.length)return;const d="vertical"===o.orientation?"down":"right",h=o.nodeAlign||"justify",g=null!==(i=o.nodeWidth)&&void 0!==i?i:15,f=null!==(r=o.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=o.iterations)&&void 0!==s?s:100,y=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ti().extent(m).links(v).nodes(y).nodeAlign(ai[h]||Rn).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,o=1/0,i=-1/0;for(const n of y)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),o>n.y0&&(o=n.y0),n.y1>i&&(i=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const r=n.circularPathData,s=(null!==(l=null!==(a=n._circularWidth)&&void 0!==a?a:n.width)&&void 0!==l?l:0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),o>r.verticalFullExtent-s&&(o=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=t-e,s=i-o,u=n[0],d=n[1];if(r>0&&s>0&&(0>e||0>o||t>u||i>d)){const t=Math.min(u/r,d/s),n=-e*t+(u-r*t)/2,i=-o*t+(d-s*t)/2;for(const e of y)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of v)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const o=e.circularPathData;o.sourceX=o.sourceX*t+n,o.targetX=o.targetX*t+n,o.sourceY=o.sourceY*t+i,o.targetY=o.targetY*t+i,o.rightFullExtent=o.rightFullExtent*t+n,o.leftFullExtent=o.leftFullExtent*t+n,o.verticalFullExtent=o.verticalFullExtent*t+i,o.rightInnerExtent=o.rightInnerExtent*t+n,o.leftInnerExtent=o.leftInnerExtent*t+n,o.verticalRightInnerExtent=o.verticalRightInnerExtent*t+i,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*t+i,o.rightSmallArcRadius*=t,o.rightLargeArcRadius*=t,o.leftSmallArcRadius*=t,o.leftLargeArcRadius*=t,o.sourceWidth*=t,o.rightNodeBuffer*=t,o.leftNodeBuffer*=t,o.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=e.source,o=e.target,n="object"==typeof t&&null!==t?t.id:t+"",i="object"==typeof o&&null!==o?o.id:o+"",r=k.get(e._edgeKey?e._edgeKey:`${n}\0${i}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=d;const t=x.get(n),o=x.get(i);t&&(r.source=t),o&&(r.target=o)}}},buildScene(e,t,o,n){var i,r,a,l,c,u;const d="vertical"===o.orientation?"down":"right",h=o.nodeStyle,g=o.edgeStyle,f=null!==(i=o.edgeOpacity)&&void 0!==i?i:.5,p=o.edgeColorBy||"source",y=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:s.schemeCategory10,v=new Map;e.forEach((e,t)=>{v.set(e.id,y[t%y.length])});const m=[],b=[],x=[],k=new Map;for(const t of e){const e=t.x1-t.x0,o=t.y1-t.y0;if(0>=e||0>=o)continue;const n=h?h(si(t,"nodeStyle")):{},i={fill:n.fill||v.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};k.set(t.id,("string"==typeof i.fill?i.fill:null)||v.get(t.id)||"#4d430c"),m.push("down"===d?{type:"rect",x:t.y0,y:t.x0,w:o,h:e,style:i,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:o,style:i,datum:t,id:t.id,label:t.id})}const w=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of w){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(a=o.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";i="function"==typeof p?p(e)||i:"target"===p?k.get(n.id)||v.get(n.id)||i:k.get(t.id)||v.get(t.id)||i;const s=g?g(si(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,o=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),r=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=s.fill||i;b.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-o}L${t.sourceX+n},${t.sourceY-o}L${t.sourceX+n},${t.sourceY+o}L${t.sourceX},${t.sourceY+o}Z`,style:{fill:a,fillOpacity:null!==(l=s.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:s.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),b.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-o}L${t.targetX-r},${t.targetY-o}L${t.targetX-r},${t.targetY+o}L${t.targetX},${t.targetY+o}Z`,style:{fill:a,fillOpacity:null!==(c=s.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:s.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-r,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?ni(e):oi(e),!d)continue;const h={fill:s.fill||i,fillOpacity:null!==(u=s.fillOpacity)&&void 0!==u?u:f,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};b.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:h,datum:e})}if(!1!==o.showLabels){const t=(j=o.nodeLabel)?"function"==typeof j?j:e=>e[j]||e.id:null;for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const r=t?t(o):o.id;if(!r)continue;let s,a,l;"down"===d?(s=o.y0+(o.y1-o.y0)/2,a=o.x1+14,l="middle"):(n[0]/2>o.x0+e/2?(s=o.x0-6,l="end"):(s=o.x1+6,l="start"),a=o.y0+i/2),x.push({x:s,y:a,text:r+"",anchor:l,baseline:"middle",fontSize:11})}}var j;return{sceneNodes:m,sceneEdges:b,labels:x}}},ci={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r;if(0===e.length)return;const s=null!==(i=o.forceStrength)&&void 0!==i?i:.1,a=n[0]/2,l=n[1]/2,c=o.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=null==c?void 0:c.get(t.id);e?u++:o?(t.x=o.x,t.y=o.y,u++):d.push(t)}const g=u>0&&.3>=(e.length>0?d.length/e.length:1);if(g){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of d){const n=ui(e.id,t,o);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const i=di(e.id),r=i%360*(Math.PI/180),s=10+i%20;e.x=t/n.length+s*Math.cos(r),e.y=o/n.length+s*Math.sin(r)}else{const t=di(e.id),o=t%360*(Math.PI/180),n=15+t%30;e.x=a+n*Math.cos(o),e.y=l+n*Math.sin(o)}}}else{const t=2.399963229728653;for(let o=0;e.length>o;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5),i=o*t;n.x=a+e*Math.cos(i),n.y=l+e*Math.sin(i)}}}const f=null!==(r=o.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===o.iterations?0:g?40:f,y=hi(o.nodeSize,o.nodeSizeRange,e),v=e=>y(e);if(p>0){const o=h.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),n=h.forceSimulation().force("charge",h.forceManyBody().strength(e=>-25*v(e))).force("center",h.forceCenter(a,l).strength(.8)).force("x",h.forceX(a).strength(.15)).force("y",h.forceY(l).strength(.15));if(n.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));n.force("link",o),n.force("link").links(e)}g?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;p>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=v(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,n){var i,r,a,l,c,u,d;const h=o.nodeStyle,g=o.edgeStyle,f=hi(o.nodeSize,o.nodeSizeRange,e),p=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:s.schemeCategory10,y=new Map;e.forEach((e,t)=>{y.set(e.id,p[t%p.length])});const v=[],m=[],b=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(si(t,"nodeSize")),n=h?h(si(t,"nodeStyle")):{},s={fill:n.fill||y.get(t.id)||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:2,opacity:n.opacity};v.push({type:"circle",cx:t.x,cy:t.y,r:e,style:s,datum:t,id:t.id,label:t.id})}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:x.get(e.source),n="object"==typeof e.target?e.target:x.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const i=g?g(si(e,"edgeStyle")):{},r={stroke:i.stroke||(null===(l=o.themeSemantic)||void 0===l?void 0:l.border)||(null===(c=o.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(u=i.strokeWidth)&&void 0!==u?u:1,opacity:null!==(d=i.opacity)&&void 0!==d?d:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==o.showLabels){const t=(k=o.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=f(si(o,"nodeSize"));b.push({x:o.x,y:o.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:m,labels:b}}};function ui(e,t,o){const n=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(t===e?s=r:r===e&&(s=t),s){const e=o.get(s);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function di(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function hi(e,t,o){var n,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=o.map(t=>{var o;return null===(o=t.data)||void 0===o?void 0:o[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(n=a.min(l))&&void 0!==n?n:0,u=null!==(r=a.max(l))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var o;const n=null===(o=t.data)||void 0===o?void 0:o[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const gi=s.schemeCategory10,fi={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:s}=o,a=Math.min(n[0],n[1])/2,l=a-r,u=n[0]/2,d=n[1]/2,h=(f=o.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const y=e.length,v=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=p.get("string"==typeof e.source?e.source:e.source.id),n=p.get(t);if(void 0===o||void 0===n)continue;const i=h(e);v[o][n]=i}const m=g.chord().padAngle(i);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=c.arc().innerRadius(l).outerRadius(a);for(const t of x){const o=e[t.index],n=k.centroid(t);o.x=n[0]+u,o.y=n[1]+d,o.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);o&&(e.source=o),n&&(e.target=n)}const j=new Map;for(const e of t)j.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const o=e[t.source.index].id,n=e[t.target.index].id,i=j.get(`${o}\0${n}`)||j.get(`${n}\0${o}`);i&&(i.chordData=t)}},buildScene(e,t,o,n){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=o,u=Math.min(n[0],n[1])/2,d=u-l,h=n[0]/2,f=n[1]/2,p=o.nodeStyle,y=o.edgeStyle,v=o.edgeColorBy||"source",m=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:gi,b=new Map;e.forEach((e,t)=>{b.set(e.id,m[t%m.length])});const x=g.ribbon().radius(d),k=[],w=[],j=[];for(let t=0;e.length>t;t++){const o=e[t],n=o.arcData;if(!n)continue;let r;r=p?p(si(o,"nodeStyle")).fill||b.get(o.id)||m[t%m.length]:b.get(o.id)||m[t%m.length];const s=p?p(si(o,"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:h,cy:f,innerR:d,outerR:u,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:o,id:o.id,label:o.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=x(t);if(!n)continue;const i=pi(n,h,f);let l=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=o.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)l=y(si(e,"edgeStyle")).fill||l;else{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;"target"===v&&o?l=b.get(o.id)||l:t&&(l=b.get(t.id)||l)}const u=y?y(si(e,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:e})}if(!1!==o.showLabels){const t=(A=o.nodeLabel)?"function"==typeof A?A:e=>e[A]||e.id:null,n=u+12;for(const o of e){const e=o.arcData;if(!e)continue;const i=t?t(o):o.id;if(!i)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;j.push({x:h+Math.cos(s)*n,y:f+Math.sin(s)*n,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:k,sceneEdges:w,labels:j}}};function pi(e,t,o){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const i=[];let r=0;for(;n.length>r;){const e=n[r];if("M"===e||"L"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("C"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;3>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("Q"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;2>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("A"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&(i.push(Number(n[r])+t+""),r++),n.length>r&&(i.push(Number(n[r])+o+""),r++);else"Z"===e||"z"===e?(i.push(e),r++):(i.push(n[r]),r++)}return i.join(" ")}const yi=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function vi(e){const[t,o,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*o+.114*n>150?"#222":"#fff"}function mi(e,t,o){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+o}function bi(e){return e?"function"==typeof e?e:t=>{var o;return(null===(o=t.data)||void 0===o?void 0:o[e])||t[e]||t.id}:null}function xi(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:yi}function ki(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function wi(e,t,o,n,i){if("horizontal"===i){const i=(e+o)/2;return`M ${e},${t} C ${i},${t} ${i},${n} ${o},${n}`}if("radial"===i){const i=(e+o)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+n)/2} T ${o},${n}`}{const i=(t+n)/2;return`M ${e},${t} C ${e},${i} ${o},${i} ${o},${n}`}}const ji={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,o,n){var i;const r=o.__hierarchyRoot;if(!r)return;const s=o.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(o.childrenAccessor),c=o.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>{var t;return null!==(t=e[c])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=l.hierarchy(r,a);d.sum(u),d.sort((e,t)=>{var o,n;return(null!==(o=t.value)&&void 0!==o?o:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,g]=n;switch(s){case"tree":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.tree();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"cluster":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.cluster();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"treemap":!function(e,t,o,n){var i,r;const s=null!==(i=t.padding)&&void 0!==i?i:4,a=null!==(r=t.paddingTop)&&void 0!==r?r:0,c=l.treemap().size([o,n]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(e)}(d,o,h,g);break;case"circlepack":!function(e,t,o,n){var i;const r=null!==(i=t.padding)&&void 0!==i?i:4;l.pack().size([o,n]).padding(r)(e)}(d,o,h,g);break;case"partition":!function(e,t,o,n){var i;l.partition().size([o,n]).padding(null!==(i=t.padding)&&void 0!==i?i:1)(e)}(d,o,h,g)}const f=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;f.length>t;t++){const n=f[t],r={id:mi(n,o,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=n.value)&&void 0!==i?i:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?Ai(r,n,o):"treemap"===s||"partition"===s?Si(r,n):"circlepack"===s&&Oi(r,n),r.__hierarchyNode=n,e.push(r),p.set(n,r)}if("tree"===s||"cluster"===s)for(const e of f)if(e.parent){const o=p.get(e.parent),n=p.get(e);o&&n&&t.push({source:o,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,o,n){const i=o.nodeStyle||(()=>({})),r=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(e,t,o,n,i,r){var s,a,l,c,u,d,h,g;const f=[],p=[],y=[],v=o.treeOrientation||"vertical",m="radial"===v,b=n[0]/2,x=n[1]/2,k="number"==typeof(w=o.nodeSize)?w:5;var w;for(const t of e){let e=t.x,n=t.y;m&&(e+=b,n+=x);const r=i(si(t,"nodeStyle"));let l=r.fill||ki(o);if(o.colorByDepth&&void 0!==t.depth){const e=xi(o);l=e[t.depth%e.length]}const c={fill:l,stroke:r.stroke||(null===(s=o.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};f.push({type:"circle",cx:e,cy:n,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const j=null!==(l=o.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=t.x,s=t.y,a=n.x,l=n.y;m&&(i+=b,s+=x,a+=b,l+=x);const g=wi(i,s,a,l,v),f=r(si(e,"edgeStyle")),y={fill:"none",stroke:f.stroke||(null===(c=o.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=o.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=f.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=f.opacity)&&void 0!==h?h:j};p.push({type:"curved",pathD:g,style:y,datum:e})}if(!1!==o.showLabels){const t=bi(o.nodeLabel);for(const o of e){const e=t?t(o):o.id;if(!e)continue;let n,i,r,s=o.x,a=o.y;if(m&&(s+=b,a+=x),m){const e=s-b,t=a-x,o=Math.sqrt(e*e+t*t);o>0?(n=s+e/o*10,i=a+t/o*10,r=0>e?"end":"start"):(n=s,i=a-12,r="middle")}else"horizontal"===v?((null===(g=o.data)||void 0===g?void 0:g.children)&&0!==o.data.children.length?(n=s-k-6,r="end"):(n=s+k+6,r="start"),i=a):(n=s,i=a+k+14,r="middle");y.push({x:n,y:i,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:f,sceneEdges:p,labels:y}}(e,t,o,n,i,r);case"treemap":case"partition":return function(e,t,o,n){var i,r,s,a,l;const c=[],u=[];for(const o of e){const e=o.x1-o.x0,s=o.y1-o.y0;if(0>=e||0>=s)continue;const a=n(si(o,"nodeStyle"));let l=a.fill||ki(t);if(t.colorByDepth&&void 0!==o.depth){const e=xi(t);l=e[o.depth%e.length]}const u={fill:l,stroke:a.stroke||(null===(i=t.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:o.x0,y:o.y0,w:e,h:s,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=bi(t.nodeLabel),i=t.labelMode||"leaf",r="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,d=c.y1-c.y0;if(0>=e||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 g=o?o(c):c.id;if(!g)continue;if((h?30:40)>e||(h?16:14)>d)continue;let f=n(si(c,"nodeStyle")).fill||ki(t);if(t.colorByDepth&&void 0!==c.depth){const e=xi(t);f=e[c.depth%e.length]}const p="string"==typeof f?vi(f):null!==(l=null===(a=t.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+e/2,y:c.y0+d/2,text:g+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/6)),fill:p}:{x:c.x0+4,y:c.y0+12,text:g+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,o,0,i);case"circlepack":return function(e,t,o,n){var i,r,s,a,l,c,u,d,h,g;const f=[],p=[];for(const o of e){const e=null!==(i=o.__radius)&&void 0!==i?i:5;if(0>=e)continue;const l=n(si(o,"nodeStyle"));let c=l.fill||ki(t);if(t.colorByDepth&&void 0!==o.depth){const e=xi(t);c=e[o.depth%e.length]}const u={fill:c,stroke:l.stroke||(null===(r=t.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};f.push({type:"circle",cx:o.x,cy:o.y,r:e,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=bi(t.nodeLabel);for(const i of e){const e=null!==(l=i.__radius)&&void 0!==l?l:5,r=o?o(i):i.id;if(!r)continue;if(15>e)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=n(si(i,"nodeStyle")).fill||ki(t);if(t.colorByDepth&&void 0!==i.depth){const e=xi(t);a=e[i.depth%e.length]}if(s){const o="string"==typeof a?vi(a):null!==(d=null===(u=t.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,e/3)),fill:o})}else p.push({x:i.x,y:i.y-e+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(g=t.themeSemantic)||void 0===g?void 0:g.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:f,sceneEdges:[],labels:p}}(e,o,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ai(e,t,o){const n=o.treeOrientation||"vertical";if("radial"===n){const o=t.x,n=t.y;e.x=n*Math.cos(o-Math.PI/2),e.y=n*Math.sin(o-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Si(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Oi(e,t){var o;const n=null!==(o=t.r)&&void 0!==o?o:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function Mi(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Ci={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,o,n){const i=o.__hierarchyRoot;i&&function(e,t,o,n,i){var r,s;const a=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(o.childrenAccessor),l=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var o;return(null!==(o=e[t])&&void 0!==o?o:"")+""}}(o.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),d=null!==(r=o.orbitSize)&&void 0!==r?r:2.95,h=null!==(s=o.orbitEccentricity)&&void 0!==s?s:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=Mi(o);p.metaMap.clear(),n.length=0,i.length=0;const y=new Map;function v(e){var t;const o=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,o+1),0===o?e:`${e}__${o}`}const m=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=v(l(e));n.push({id:k,x:m,y:b,x0:m,x1:m,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,o,r,s,d,h,y){const m=a(t);if(!(null==m?void 0:m.length))return;const b=m.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let j=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=m.slice(j,j+k);if(!w.length)break;const A=(b+1)/x,S={id:o,depth:h,data:t,parentId:o},O=y?d/g(S)*A:d*A,M=c.pie().value(e=>{var t;return(null===(t=a(e))||void 0===t?void 0:t.length)?4:1}).sort(null),C=M(w),_=f(S);for(let t=0;w.length>t;t++){const a=(C[t].startAngle+C[t].endAngle)/2,c=w[t],u=v(l(c)),d=r+O*Math.sin(a),g=s+O*Math.cos(a)*_;n.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:c}),p.metaMap.set(u,{ring:O,angle:a,depth:h,parentId:o,eccentricity:_}),i.push({source:o,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:u}}),e(c,u,d,g,O,h+1,!0)}j+=k}}(e,k,m,b,x,1,!1)}(i,n,o,e,t)},buildScene(e,t,o,n){var i,r,s,a,l,c,u;const d=o.nodeStyle,h=o.nodeSize,g="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,f=[],p=[],y=[];if(!1!==o.orbitShowRings){const t=Mi(o),n=new Map;for(const t of e)n.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const o=`${e.parentId}:${e.ring}`;i.has(o)||i.set(o,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:o,ecc:n}]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:e+o*Math.sin(a),y1:t+o*Math.cos(a)*n,x2:e+o*Math.sin(l),y2:t+o*Math.cos(l)*n,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=g(si(t,"nodeSize")),n=d?d(si(t,"nodeStyle")):{},c={fill:n.fill||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:v.get(e.source),o="object"==typeof e.target?e.target:v.get(e.target);t&&o&&(null!=t.x&&null!=o.x&&p.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(o.showLabels){const t=o.nodeLabel;for(const o of e){const e=g(si(o,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(o):t&&null!==(u=null===(c=o.data)||void 0===c?void 0:c[t])&&void 0!==u?u:o.id;y.push({x:o.x,y:o.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:p,labels:y}},tick:(e,t,o,n,i)=>!1!==o.orbitAnimated&&(function(e,t){var o,n;const i=Mi(t),r=null!==(o=t.orbitSpeed)&&void 0!==o?o:.25,s=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const o=null!==(t=e.depth)&&void 0!==t?t:0;return(o%2==0?1:-1)/(o+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=c.get(e.parentId);if(!o)continue;const n=e.angle+a*l*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(n),t.y=o.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,o),!0)},_i={sankey:li,force:ci,chord:fi,tree:ji,cluster:ji,treemap:ji,circlepack:ji,partition:ji,orbit:Ci};function Pi(e){return _i[e]}class Li{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},hn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new fn(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},hn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new fn(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,o){const{nodeIDAccessor:n="id",sourceAccessor:i="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,a="function"==typeof n?n:e=>e[n],l="function"==typeof i?i:e=>e[i],c="function"==typeof r?r:e=>e[r],u="function"==typeof s?s:e=>{var t;return null!==(t=e[s])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Ti(e)),{data:t}))}for(let e=0;t.length>e;e++){const o=t[e],n=l(o)+"",i=c(o)+"",r=Number(u(o))||1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Ti(n)),{data:o})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Ti(i)),{data:o}));const s=`${n}\0${i}\0${e}`;this.edges.set(s,{source:n,target:i,value:r,y0:0,y1:0,sankeyWidth:0,data:o,_edgeKey:s})}this.runLayout(o)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:o,value:n}=e,i=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Ti(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(o)||(this.nodes.set(o,Ti(o)),this.nodeTimestamps.set(o,s),this.tension+=this.tensionConfig.newNode,r=!0);const a=this.edgeKey(t,o),l=this.edges.get(a);let c=!1;return l?(l.value+=n,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:o,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,r=!0),i||r||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,o,n,i,r,s,a,l;const c=Pi(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const a of u)if(void 0!==a._prevX0){const l=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(o=a._prevX0)&&void 0!==o?o:0),c=(null!==(n=a._prevY1)&&void 0!==n?n:0)-(null!==(i=a._prevY0)&&void 0!==i?i:0);e.set(a.id,{x:(null!==(r=a._prevX0)&&void 0!==r?r:0)+l/2,y:(null!==(s=a._prevY0)&&void 0!==s?s:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,o]of this._lastPositionSnapshot)e.has(t)||e.set(t,o);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],o=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=o,this.edges.set(o,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const o=e.get(t.id);o&&(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const g=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),f=null!==(l=null===(a=this.config.transition)||void 0===a?void 0:a.duration)&&void 0!==l?l:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&f>0){const t=e[0]/2,o=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=o,e._prevY1=o;for(const e of this.edges.values())e._prevY0=o,e._prevY1=o,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f}}else g&&f>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f});this._hasRenderedOnce=!0;const p=new Set(this.nodes.keys()),y=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of p)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)p.has(e)||this.removedNodes.add(e);for(const e of y)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)y.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=p,this.previousEdgeKeys=y,this.layoutVersion++}buildScene(e){const t=Pi(this.config.chartType);if(!t)return;const o=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:r,labels:s}=t.buildScene(o,n,this.config,e);this.sceneNodes=i,this.sceneEdges=r,this.labels=s}get isAnimating(){const e=Pi(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const o=Pi(this.config.chartType);if(!(null==o?void 0:o.tick))return!1;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return o.tick(n,i,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=K(e,this.transition),o=U(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Q(e._prevX0,e._targetX0,o),e.x1=Q(e._prevX1,e._targetX1,o),e.y0=Q(e._prevY0,e._targetY0,o),e.y1=Q(e._prevY1,e._targetY1,o));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Q(e._prevY0,e._targetY0,o),e.y1=Q(e._prevY1,e._targetY1,o),e.sankeyWidth=Q(e._prevSankeyWidth,e._targetSankeyWidth,o));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const o=null==e?void 0:e.get(t.id);o&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const o=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(o){e._prevY0=o.y0,e._prevY1=o.y1,e._prevSankeyWidth=o.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,o="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&o&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,o))}buildStandardBezier(e,t,o){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,r=o.x0,s=d.interpolateNumber(i,r);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:r}],halfWidth:n}}const i=t.x1,r=o.x0,s=d.interpolateNumber(i,r);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:r,y:e.y1}],halfWidth:n}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,o=e.circularPathData;if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(o.rightFullExtent-o.sourceX))),n=Math.max(15,Math.min(40,.33*(o.targetX-o.leftFullExtent)));return{circular:!0,segments:[[{x:o.sourceX,y:o.sourceY},{x:o.sourceX+.33*e,y:o.sourceY},{x:o.sourceX+.66*e,y:o.sourceY},{x:o.sourceX+e,y:o.sourceY}],[{x:o.targetX-n,y:o.targetY},{x:o.targetX-.66*n,y:o.targetY},{x:o.targetX-.33*n,y:o.targetY},{x:o.targetX,y:o.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:o.sourceY,y:o.sourceX},{x:o.sourceY,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.leftFullExtent},{x:o.targetY,y:o.leftFullExtent},{x:o.targetY,y:o.targetX}]:[{x:o.sourceX,y:o.sourceY},{x:o.rightFullExtent,y:o.sourceY},{x:o.rightFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.targetY},{x:o.targetX,y:o.targetY}];const i=[];for(let e=0;n.length-1>e;e++){const t=n[e],o=n[e+1],r=o.x-t.x,s=o.y-t.y;i.push([t,{x:t.x+r/3,y:t.y+s/3},{x:t.x+2*r/3,y:t.y+2*s/3},o])}return{circular:!0,segments:i,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,o,n,i,r;const s=this.config.pulse;if(!s)return;const a=null!==(t=s.duration)&&void 0!==t?t:500,l=null!==(o=s.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=s.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const n=this.nodeTimestamps.get(o);if(!n)continue;const i=e-n;a>i&&(t._pulseIntensity=1-i/a,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const o=t.datum;if(!o)continue;const n="object"==typeof o.source?null===(i=o.source)||void 0===i?void 0:i.id:o.source,s="object"==typeof o.target?null===(r=o.target)||void 0===r?void 0:r.id:o.target;if(!n||!s)continue;const c=this.edgeTimestamps.get(`${n}\0${s}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=l)}}applyDecay(){var e,t;const o=this.config.decay;if(!o)return;const n=this.nodeTimestamps.size;if(1>=n)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const i=this._decaySortedNodes,r=new Map;for(let e=0;i.length>e;e++)r.set(i[e][0],e);for(const i of this.sceneNodes){const s=i.id;if(!s)continue;const a=r.get(s);if(void 0===a)continue;const l=X(o,a,n),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const o=e-this.lastTopologyChangeTime;if(o>=2e3)return;const n=1-o/2e3;for(const e of this.sceneNodes){const o=e.id;o&&this.addedNodes.has(o)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,o;const n=this.config.thresholds;if(!n)return;const i=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",r=null!==(o=n.criticalColor)&&void 0!==o?o:"#ef4444",s=!1!==n.pulse;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const a=this.nodes.get(o);if(!a)continue;const l=n.metric(a);let c=null;void 0===n.critical||n.critical>l?void 0===n.warning||n.warning>l||(c=i):c=r,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),s&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const o=e.metric(t);if(void 0!==e.warning&&o>=e.warning||void 0!==e.critical&&o>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const o="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>o-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var o;const n=this.nodes.get(e);if(!n)return null;const i=n.data?Object.assign({},n.data):{};return n.data=t(null!==(o=n.data)&&void 0!==o?o:{}),this.layoutVersion++,i}updateEdge(e,t,o){var n;const i=this.config.valueAccessor,r="function"==typeof i?i:i?e=>e[i]:e=>e.value,s=[];for(const[,i]of this.edges)if(("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t){s.push(i.data?Object.assign({},i.data):{}),i.data=o(null!==(n=i.data)&&void 0!==n?n:{});const e=r(i.data);null!=e&&(i.value=Number(e))}return s.length>0&&this.layoutVersion++,s}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)!==e&&("string"==typeof o.target?o.target:o.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const o=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,i]of this.edges)i.data&&n(i.data)===e&&o.push(t)}else for(const[n,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&o.push(n);for(const e of o)this.edges.delete(e),this.edgeTimestamps.delete(e);return o.length>0&&this.layoutVersion++,o.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Ti(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Ri(e,t,o,n,i=30){let r=null,s=i,a=1/0;for(const t of e){const e=Bi(t,o,n,i);if(e)if("rect"===t.type){const o=t.w*t.h;a>o&&(r=e,a=o)}else s>e.distance&&(r=e,s=e.distance)}if(r)return r;for(const e of t){const t=$i(e,o,n);t&&s>t.distance&&(r=t,s=t.distance)}return r}function Bi(e,t,o,n=30){switch(e.type){case"circle":return function(e,t,o,n=30){const i=t-e.cx,r=o-e.cy,s=Math.sqrt(i*i+r*r);return s>de(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,o,n);case"rect":return function(e,t,o){const n=ue(t,o,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,o);case"arc":return function(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerR-2>r||r>e.outerR+2)return null;const s=fe(Math.atan2(i,n)),a=fe(e.startAngle),l=fe(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const t=(e.startAngle+e.endAngle)/2,o=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+o*Math.cos(t),y:e.cy+o*Math.sin(t),distance:0}}return null}(e,t,o);default:return null}}let Ii=null,Di=null;function Hi(){return Di||(Ii=document.createElement("canvas"),Ii.width=1,Ii.height=1,Di=Ii.getContext("2d")),Di}function Ni(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function $i(e,t,o){switch(e.type){case"bezier":return function(e,t,o){var n,i;if(!e.pathD)return null;const r=Ni(e),s=Hi();if(!r||!s)return null;try{if(s.isPointInPath(r,t,o)){const r="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,s="object"==typeof(null===(i=e.datum)||void 0===i?void 0:i.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:r&&s?(r.x1+s.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:o,distance:0}}const a=s.lineWidth;s.lineWidth=10;const l=s.isPointInStroke(r,t,o);if(s.lineWidth=a,l)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);case"line":return function(e,t,o){const n=e.x2-e.x1,i=e.y2-e.y1,r=n*n+i*i;if(0===r)return null;let s=((t-e.x1)*n+(o-e.y1)*i)/r;s=Math.max(0,Math.min(1,s));const a=e.x1+s*n,l=e.y1+s*i,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(o-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,o);case"ribbon":case"curved":return function(e,t,o){if(!e.pathD)return null;const n=Ni(e),i=Hi();if(!n||!i)return null;try{if(i.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(n,t,o);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);default:return null}}function Wi(t){const{width:o,height:n,totalWidth:i,totalHeight:r,margin:s,labels:a,title:l,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g,legendPosition:f="right",foregroundGraphics:p,sceneNodes:v,annotations:m,svgAnnotationRules:b}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof l?l:"Network Chart"}),e.jsx("desc",{children:"string"==typeof l?l+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[a.map((t,o)=>e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+o)),m&&m.filter(e=>"widget"!==e.type).map((t,i)=>{if(b){const r=b(t,i,{width:o,height:n,sceneNodes:v});if(r)return e.jsx(y.Fragment,{children:r},"annotation-"+i)}return null}),p]}),l&&"string"==typeof l?e.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:i,height:s.top,children:l}):null,Fe({legend:c,totalWidth:i,totalHeight:r,margin:s,legendPosition:f,title:l,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g})]}),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,o)=>{var n,i,r,a,l,c,u,d,h;const g=v.find(e=>{var o,n,i,r,s;return e.id===t.nodeId||(null===(o=e.datum)||void 0===o?void 0:o.id)===t.nodeId||(null===(i=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===i?void 0:i.id)===t.nodeId||(null===(s=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===t.nodeId});if(!g)return null;const f=s.left+(null!==(n=g.cx)&&void 0!==n?n:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(i=g.x)&&void 0!==i?i:0),p=s.top+(null!==(r=g.cy)&&void 0!==r?r:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(a=g.y)&&void 0!==a?a:0),y=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(c=t.dy)&&void 0!==c?c:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:f+y-b/2,top:p+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+o)})]})}function Fi(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Ei(e,t){var o,n,i,r,s,a;if(!t.pathD)return;e.save();const l=Fi(t);if(t.style.fill&&"none"!==t.style.fill){const s=t._gradient;if(s){const i=e.createLinearGradient(s.x0,0,s.x1,0),r=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,a="string"==typeof t.style.fill?t.style.fill:"#999",l=Zt(e,a)||a;i.addColorStop(0,1===s.from?l:"transparent"),i.addColorStop(1,1===s.to?l:"transparent"),e.fillStyle=i,e.globalAlpha=r}else e.fillStyle="string"==typeof t.style.fill&&Zt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(s=t.style.strokeWidth)&&void 0!==s?s:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function zi(e,t){var o,n;e.save();const i=t.style.stroke||"#999";e.strokeStyle=Zt(e,i)||i,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Yi(e,t){var o,n,i,r;if(!t.pathD)return;e.save();const s=Fi(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Zt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,e.fill(s)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.3*(null!==(r=t.style.opacity)&&void 0!==r?r:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(s)),e.restore()}function Gi(e,t){var o,n;if(!t.pathD)return;e.save();const i=Fi(t),r=t.style.stroke||"#999";e.strokeStyle=Zt(e,r)||r,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(i),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Zt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(i)),e.restore()}Wi.displayName="NetworkSVGOverlay";const qi={top:20,right:80,bottom:20,left:80},Xi={top:40,right:40,bottom:40,left:40},Vi=new Set(["chord","force","circlepack","orbit"]),Ui=[800,600],Ki={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 Qi({data:t}){var o,n,i,r,s,a;if("edge"===t.nodeOrEdge){const o=t.data;return e.jsxs("div",{className:"semiotic-tooltip",style:Ki,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof o.source?o.source.id:o.source," → ","object"==typeof o.target?o.target.id:o.target]}),null!=o.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof o.value?o.value.toLocaleString():o.value+""]})]})}const l=t.data,c=null==l?void 0:l.__hierarchyNode;if(c){const t=[];let s=c;for(;s;){const e=null!==(r=null!==(n=null===(o=s.data)||void 0===o?void 0:o.name)&&void 0!==n?n:null===(i=s.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=e&&t.unshift(e+""),s=s.parent}t.length>1&&t.shift();const a=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:Ki,children:[e.jsx("div",{children:t.map((t,o)=>e.jsxs("span",{children:[o>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),o===a?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},o))}),null!=l.value&&l.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof l.value?l.value.toLocaleString():l.value+""})]})}const u=((null===(s=l.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:Ki,children:[e.jsx("div",{style:{fontWeight:600},children:l.id}),null!=l.value&&l.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const Zi=t.forwardRef(function(o,n){var i,r,s,a,l,u,d,h,g,f,p,y,v,m,b,x,k;const{chartType:w,nodes:j,edges:S,data:O,initialEdges:M,nodeIDAccessor:C="id",sourceAccessor:_="source",targetAccessor:P="target",valueAccessor:L="value",edgeIdAccessor:T,childrenAccessor:R,hierarchySum:B,orientation:I="horizontal",nodeAlign:D="justify",nodePaddingRatio:H=.05,nodeWidth:N=15,iterations:$=300,forceStrength:F=.1,padAngle:E=.01,groupWidth:z=20,sortGroups:Y,edgeSort:G,treeOrientation:q="vertical",edgeType:X="curve",padding:V,paddingTop:U,tensionConfig:K,showParticles:Q=!1,particleStyle:Z,nodeStyle:J,edgeStyle:ee,colorBy:te,colorScheme:oe="category10",edgeColorBy:ne="source",edgeOpacity:ie=.5,colorByDepth:re=!1,nodeSize:se=8,nodeSizeRange:ae=[5,20],nodeLabel:le,showLabels:ce=!0,labelMode:ue,size:de=Ui,responsiveWidth:he,responsiveHeight:ge,margin:fe,className:pe,background:ye,enableHover:ve=!0,tooltipContent:me,customHoverBehavior:be,customClickBehavior:xe,onObservation:ke,chartId:we,onTopologyChange:je,annotations:Ae,svgAnnotationRules:Se,legend:_e,legendPosition:Pe,legendHoverBehavior:Te,legendClickBehavior:Re,legendHighlightedCategory:Be,legendIsolatedCategories:Ie,title:De,foregroundGraphics:He,backgroundGraphics:Ne,decay:$e,pulse:We,transition:Fe,animate:Ee,staleness:ze,thresholds:Ye,accessibleTable:Ge=!0,description:qe,summary:Xe,orbitMode:Ve,orbitSize:Ue,orbitSpeed:Ke,orbitRevolution:Qe,orbitRevolutionStyle:Ze,orbitEccentricity:Je,orbitShowRings:et,orbitAnimated:tt}=o,ot=Vi.has(w)?Xi:qi,nt=t.useRef(!0),it=eo({sizeProp:de,responsiveWidth:he,responsiveHeight:ge,userMargin:fe,marginDefault:ot,foregroundGraphics:He,backgroundGraphics:Ne,animate:Ee,transitionProp:Fe,themeDirtyRef:nt}),{reducedMotionRef:rt,responsiveRef:st,size:at,margin:lt,adjustedWidth:ct,adjustedHeight:ut,resolvedForeground:dt,resolvedBackground:ht,transition:gt,introEnabled:ft,tableId:pt,rafRef:yt,renderFnRef:vt,scheduleRender:mt,currentTheme:kt}=it,wt=t.useMemo(()=>Object.assign(Object.assign({},hn),K),[K]),jt=t.useMemo(()=>Object.assign(Object.assign({},gn),Z),[Z]),At=t.useMemo(()=>{var e;return{chartType:w,nodeIDAccessor:C,sourceAccessor:_,targetAccessor:P,valueAccessor:L,edgeIdAccessor:T,childrenAccessor:R,hierarchySum:B,orientation:I,nodeAlign:D,nodePaddingRatio:H,nodeWidth:N,iterations:$,forceStrength:F,padAngle:E,groupWidth:z,sortGroups:Y,edgeSort:G,treeOrientation:q,edgeType:X,padding:V,paddingTop:U,tensionConfig:wt,showParticles:Q,particleStyle:jt,nodeStyle:J,edgeStyle:ee,nodeLabel:le,showLabels:ce,labelMode:ue,colorBy:te,colorScheme:oe,themeCategorical:null===(e=null==kt?void 0:kt.colors)||void 0===e?void 0:e.categorical,themeSemantic:A(kt),edgeColorBy:ne,edgeOpacity:ie,colorByDepth:re,nodeSize:se,nodeSizeRange:ae,decay:$e,pulse:We,transition:gt,introAnimation:ft,staleness:ze,thresholds:Ye,orbitMode:Ve,orbitSize:Ue,orbitSpeed:Ke,orbitRevolution:Qe,orbitRevolutionStyle:Ze,orbitEccentricity:Je,orbitShowRings:et,orbitAnimated:tt}},[w,C,_,P,L,R,B,I,D,H,N,$,F,E,z,Y,G,q,X,V,U,wt,Q,jt,J,ee,le,ce,ue,te,oe,ne,ie,re,se,ae,$e,We,null==gt?void 0:gt.duration,null==gt?void 0:gt.easing,ft,ze,Ye,Ve,Ue,Ke,Qe,Ze,Je,et,tt,kt]),St=t.useRef(null),Mt=t.useRef(0),Ct=t.useRef(null);Ct.current||(Ct.current=new Li(At));const[_t,Pt]=t.useState(null),[Lt,Tt]=t.useState(0),[Rt,Bt]=t.useState(0),[It,Wt]=t.useState(!1),zt=t.useRef(null),Yt=t.useRef(new Map),Gt=t.useRef(0),qt=t.useCallback(e=>{if("function"==typeof te)return te(e)+"";if("string"==typeof te&&e.data){const t=e.data[te];if(void 0!==t){if(!Yt.current.has(t+"")){const e=Array.isArray(oe)?oe:W;Yt.current.set(t+"",e[Gt.current++%e.length])}return Yt.current.get(t+"")}}if(Yt.current.has(e.id))return Yt.current.get(e.id);const t=Array.isArray(oe)?oe:W,o=te?t[Gt.current++%t.length]:t[0];return Yt.current.set(e.id,o),o},[te,oe]),Xt=(null===(i=null==kt?void 0:kt.colors)||void 0===i?void 0:i.border)||(null===(r=null==kt?void 0:kt.colors)||void 0===r?void 0:r.secondary)||(null===(s=null==kt?void 0:kt.colors)||void 0===s?void 0:s.primary)||"#999",Vt=t.useCallback(e=>{if("function"==typeof ne)return ne(e);const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;return"target"===ne&&o?qt(o):t?qt(t):Xt},[ne,qt,Xt]),Ut=t.useCallback(e=>{if(!(null==Z?void 0:Z.colorBy))return Vt(e);const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;return"target"===jt.colorBy&&o?qt(o):t?qt(t):Xt},[null==Z?void 0:Z.colorBy,jt.colorBy,qt,Vt,Xt]),Kt="sankey"===w&&Q||!!We||null!==(l=null===(a=Ct.current)||void 0===a?void 0:a.isAnimating)&&void 0!==l&&l;t.useEffect(()=>{var e;null===(e=Ct.current)||void 0===e||e.updateConfig(At),nt.current=!0,mt()},[At,mt]),t.useEffect(()=>{var e;const t=Ct.current;if(t){t.buildScene([ct,ut]);for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Yt.current.set(o.id,o.style.fill);nt.current=!0,mt()}},[kt,ct,ut,mt]);const Qt=t.useCallback(()=>{var e;const t=Ct.current;if(!t)return;t.runLayout([ct,ut]),t.buildScene([ct,ut]),nt.current=!0;for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Yt.current.set(o.id,o.style.fill);const o=Array.isArray(oe)?oe:W,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Yt.current.has(t.id)||Yt.current.set(t.id,o[e%o.length])}if(Gt.current=n.length,Tt(t.layoutVersion),je){const{nodes:e,edges:o}=t.getLayoutData();je(e,o)}},[ct,ut,je,oe]),Jt=t.useCallback(e=>{const t=Ct.current;t&&(t.ingestEdge(e)&&Qt(),mt())},[Qt,mt]),no=t.useCallback(e=>{const t=Ct.current;if(!t)return;let o=!1;for(const n of e)t.ingestEdge(n)&&(o=!0);o&&Qt(),mt()},[Qt,mt]),io=t.useCallback(()=>{var e;null===(e=Ct.current)||void 0===e||e.clear(),Yt.current.clear(),Gt.current=0,Tt(0),Pt(null),zt.current=null,nt.current=!0,mt()},[mt]),ro=t.useCallback(()=>{const e=Ct.current;e&&(e.tension+=999,Qt(),mt())},[Qt,mt]);t.useImperativeHandle(n,()=>({push:Jt,pushMany:no,removeNode:e=>{var t,o,n;const i=null!==(o=null===(t=Ct.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==o&&o;if(i){const t=(null===(n=zt.current)||void 0===n?void 0:n.data)?"function"==typeof C?C(zt.current.data):zt.current.data[C]:void 0;zt.current&&"node"===zt.current.nodeOrEdge&&t===e&&(zt.current=null,Pt(null)),Yt.current.delete(e),Qt(),nt.current=!0,mt()}return i},removeEdge:(e,t)=>{var o,n;const i=null!==(n=null===(o=Ct.current)||void 0===o?void 0:o.removeEdge(e,t))&&void 0!==n&&n;if(i){if(zt.current&&"edge"===zt.current.nodeOrEdge){const o=zt.current.data;let n;n=void 0!==t?("object"==typeof(null==o?void 0:o.source)?o.source.id:null==o?void 0:o.source)===e&&("object"==typeof(null==o?void 0:o.target)?o.target.id:null==o?void 0:o.target)===t:!T||!o||("function"==typeof T?T:e=>null==e?void 0:e[T])(o)===e,n&&(zt.current=null,Pt(null))}Qt(),nt.current=!0,mt()}return i},updateNode:(e,t)=>{var o,n;const i=null!==(n=null===(o=Ct.current)||void 0===o?void 0:o.updateNode(e,t))&&void 0!==n?n:null;return i&&(nt.current=!0,mt()),i},updateEdge:(e,t,o)=>{var n,i;const r=null!==(i=null===(n=Ct.current)||void 0===n?void 0:n.updateEdge(e,t,o))&&void 0!==i?i:[];return r.length>0&&(Qt(),nt.current=!0,mt()),r},clear:io,getTopology:()=>{var e,t;return null!==(t=null===(e=Ct.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ct.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:ro,getTension:()=>{var e,t;return null!==(t=null===(e=Ct.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[Jt,no,io,ro,Qt,mt]);const so=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),ao=so?O||(Array.isArray(S)?void 0:S):void 0;t.useEffect(()=>{var e;const t=Ct.current;if(t)if(so&&ao)t.ingestHierarchy(ao,[ct,ut]),t.buildScene([ct,ut]),nt.current=!0,mt();else{const o=j||[],n=Array.isArray(S)?S:[];if(0===o.length&&0===n.length)return;t.ingestBounded(o,n,[ct,ut]),t.buildScene([ct,ut]);for(const o of t.sceneNodes)o.id&&(null===(e=o.style)||void 0===e?void 0:e.fill)&&Yt.current.set(o.id,o.style.fill+"");const i=Array.isArray(oe)?oe:W,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Yt.current.has(t.id)||Yt.current.set(t.id,i[e%i.length])}Gt.current=r.length,nt.current=!0,mt()}},[j,S,O,ao,so,ct,ut,At,mt,oe]),t.useEffect(()=>{M&&M.length>0&&no(M)},[]);const lo=t.useCallback(e=>{if(be&&be(e),ke){const t=Date.now();ke(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[be,ke,we]),ho=t.useCallback(e=>{if(xe&&xe(e),ke){const t=Date.now();ke(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[xe,ke,we]),{hoverHandlerRef:go,hoverLeaveRef:fo,onPointerMove:po,onPointerLeave:yo}=it;go.current=e=>{if(!ve)return;const t=St.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-lt.left,i=e.clientY-o.top-lt.top;if(0>n||n>ct||0>i||i>ut)return void(zt.current&&(zt.current=null,Pt(null),lo&&(lo(null),nt.current=!0),mt()));const r=Ct.current;if(!r)return;const s=Ri(r.sceneNodes,r.sceneEdges,n,i);if(!s)return void(zt.current&&(zt.current=null,Pt(null),lo&&(lo(null),nt.current=!0),mt()));const a=xo(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});zt.current=a,Pt(a),lo&&(lo(a),nt.current=!0),mt()},fo.current=()=>{zt.current&&(zt.current=null,Pt(null),lo&&(lo(null),nt.current=!0),mt())};const vo=t.useRef(()=>{});vo.current=e=>{if(!xe&&!ke)return;const t=St.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-lt.left,i=e.clientY-o.top-lt.top;if(0>n||n>ct||0>i||i>ut)return;const r=Ct.current;if(!r)return;const s=Ri(r.sceneNodes,r.sceneEdges,n,i);ho(s?xo(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const mo=t.useCallback(e=>vo.current(e),[]),bo=t.useRef(-1),ko=t.useRef(null),wo=t.useRef(-1),jo=t.useCallback(e=>{var t;const o=Ct.current;if(!o)return;const n=function(e){var t,o,n,i,r,s;const a=[];for(const l of e)"circle"===l.type&&null!=l.cx?a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(o=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==o?o:"_default"}):"rect"===l.type&&null!=l.x?a.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(i=null===(n=l.datum)||void 0===n?void 0:n.id)&&void 0!==i?i:"_default"}):"arc"===l.type&&null!=l.cx&&a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(s=null===(r=l.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(o.sceneNodes);if(0===n.length)return;const i=Oe(n),r=bo.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),bo.current=0,wo.current=-1;const t=i.flat[0];ko.current={shape:t.shape,w:t.w,h:t.h};const o=xo(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return zt.current=o,Pt(o),lo&&(lo(o),nt.current=!0),void mt()}const s=Me(i,r),a=function(e,t,o,n,i){var r,s,a;const l=o.flat[t.flatIndex];if(!l)return Ce(e,t,o);const c=null===(r=l.datum)||void 0===r?void 0:r.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(s=function(e,t,o){let n=null,i=1/0;for(let r=0;e.flat.length>r;r++){const s=e.flat[r];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(o){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;i>u&&(i=u,n=r)}return n}(o,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==s?s:t.flatIndex;return n!==t.flatIndex&&(i.current=-1),n}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var o,n,i;const r=e+"",s=[];for(const e of t){const t=null!==(o=e.datum)&&void 0!==o?o:e,a="object"==typeof t.source?null===(n=t.source)||void 0===n?void 0:n.id:t.source,l="object"==typeof t.target?null===(i=t.target)||void 0===i?void 0:i.id:t.target,c=null!=a,u=null!=l;c&&a+""===r&&u?s.push(l+""):u&&l+""===r&&c&&s.push(a+"")}return s}(c,n);if(0===e.length)return t.flatIndex;const r=null!==(a=o.idToIdx.get(e[(i.current+1)%e.length]))&&void 0!==a?a:-1;return 0>r?t.flatIndex:(i.current=-1,r)}default:{const n=Ce(e,t,o);return null!==n&&n!==t.flatIndex&&(i.current=-1),n}}}(e.key,s,i,null!==(t=o.sceneEdges)&&void 0!==t?t:[],wo);if(null===a)return;if(e.preventDefault(),0>a)return bo.current=-1,ko.current=null,wo.current=-1,zt.current=null,Pt(null),lo&&(lo(null),nt.current=!0),void mt();bo.current=a;const l=i.flat[a];ko.current={shape:l.shape,w:l.w,h:l.h};const c=l.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:l.x,y:l.y,time:l.x,value:l.y,nodeOrEdge:"node"});zt.current=u,Pt(u),lo&&(lo(u),nt.current=!0),mt()},[lo,mt]),Ao=t.useCallback(e=>{bo.current=-1,ko.current=null,po(e)},[po]);vt.current=()=>{var e,t,o,n,i,r,s;yt.current=0;const a=St.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=Ct.current;if(!c)return;const u=performance.now(),d=Mt.current?Math.min((u-Mt.current)/1e3,.1):.016;Mt.current=u;const h=c.advanceTransition(rt.current?u+1e6:u),g=!rt.current&&h,f=!rt.current&&c.tickAnimation([ct,ut],d);(h||nt.current||f)&&c.buildScene([ct,ut]);const p=oo();if(!to(a,at,lt,p))return;l.clearRect(-lt.left,-lt.top,at[0],at[1]),ye&&(l.fillStyle=ye,l.fillRect(0,0,ct,ut)),$e&&c.applyDecay(),We&&c.applyPulse(u),Ye&&c.applyThresholds(u),c.applyTopologyDiff(u);const y=null!==(e=null==ze?void 0:ze.threshold)&&void 0!==e?e:5e3,v=ze&&c.lastIngestTime>0&&u-c.lastIngestTime>y;if(v&&(l.globalAlpha=null!==(t=null==ze?void 0:ze.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const o of t)switch(o.type){case"bezier":Ei(e,o);break;case"line":zi(e,o);break;case"ribbon":Yi(e,o);break;case"curved":Gi(e,o)}}(l,c.sceneEdges),function(e,t){var o,n,i;for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Zt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.strokeRect(t.x,t.y,t.w,t.h)),co(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("circle"!==r.type)continue;const t=r;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Zt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),uo(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("arc"!==r.type)continue;const t=r;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Zt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Zt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),e.restore()}}(l,c.sceneNodes),Q&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,o,n){var i,r;const s=null!==(i=n.spawnRate)&&void 0!==i?i:gn.spawnRate,a=null!==(r=n.maxPerEdge)&&void 0!==r?r:gn.maxPerEdge;for(let n=0;t.length>n;n++){const i=t[n];if(!i.bezier)continue;if(e.countForEdge(n)>=a)continue;const r=i.value*s*o*(i.bezier.circular?.3:1),l=Math.floor(r),c=r-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<a;t++)e.spawn(n)}}(c.particlePool,e,d,jt);const t=.5*(null!==(o=jt.speedMultiplier)&&void 0!==o?o:1);let n;if(jt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,n),function(e,t,o,n,i){var r,s;const a=null!==(r=n.radius)&&void 0!==r?r:gn.radius,l=null!==(s=n.opacity)&&void 0!==s?s:gn.opacity;e.globalAlpha=l;for(let r=0;t.particles.length>r;r++){const s=t.particles[r];if(!s.active)continue;const l=o[s.edgeIndex];if(l){if("function"==typeof n.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?n.color(l,t):Zt(e,"var(--semiotic-secondary, #666)")}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:i(l);e.beginPath(),e.arc(s.x,s.y,a,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(l,c.particlePool,e,jt,Ut)}}v&&(l.globalAlpha=1);const m=nt.current;if(nt.current=!1,m||g||f){const e=St.current;e&&e.setAttribute("aria-label",Ot(null!==(i=null===(n=c.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==i?i:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}(m||g||f)&&Bt(e=>e+1),(Kt||g||null!=c.transition||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(yt.current=requestAnimationFrame(()=>vt.current()))},t.useEffect(()=>(mt(),()=>{}),[mt]),t.useEffect(()=>{nt.current=!0,mt()},[w,ct,ut,ye,mt]),Le(ze,Ct,nt,mt,It,Wt);const So=ve&&_t?e.jsx(Et,{x:_t.x,y:_t.y,containerWidth:ct,containerHeight:ut,margin:lt,className:"stream-network-tooltip",zIndex:2,children:me?me(_t):e.jsx(Qi,{data:_t})}):null;if(xt){const t=Ct.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),o=e?O||(Array.isArray(S)?void 0:S):void 0;if(e&&o)t.ingestHierarchy(o,[ct,ut]),t.buildScene([ct,ut]);else{const e=j||[],o=Array.isArray(S)?S:[];(e.length>0||o.length>0)&&(t.ingestBounded(e,o,[ct,ut]),t.buildScene([ct,ut]))}}const o=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],n=null!==(d=null==t?void 0:t.sceneEdges)&&void 0!==d?d:[],i=null!==(h=null==t?void 0:t.labels)&&void 0!==h?h:[];return e.jsxs("div",{className:"stream-network-frame"+(pe?" "+pe:""),role:"img","aria-label":qe||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:at[0],height:at[1]},children:[e.jsx(Ht,{summary:Xe}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:at[0],height:at[1],style:{position:"absolute",left:0,top:0},children:[ht&&e.jsx("g",{transform:`translate(${lt.left},${lt.top})`,children:ht}),e.jsxs("g",{transform:`translate(${lt.left},${lt.top})`,children:[ye&&e.jsx("rect",{x:0,y:0,width:ct,height:ut,fill:ye}),n.map((t,o)=>function(t,o){switch(t.type){case"line":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+o);case"bezier":{const n=t;return e.jsx("path",{d:n.pathD,fill:bt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"ribbon":{const n=t;return e.jsx("path",{d:n.pathD,fill:bt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"curved":{const n=t;return e.jsx("path",{d:n.pathD,fill:bt(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+o)}default:return null}}(t,o)).filter(Boolean),o.map((t,o)=>function(t,o){switch(t.type){case"circle":{const n=t;return e.jsx("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:bt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:bt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+o)}case"arc":{const n=t,i=c.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)({})||"";return e.jsx("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:bt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+o)}default:return null}}(t,o)).filter(Boolean),i.map((t,o)=>function(t,o){return e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+o)}(t,o)).filter(Boolean)]})]}),e.jsx(Wi,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,labels:i,sceneNodes:o,title:De,legend:_e,legendPosition:Pe,legendHoverBehavior:Te,legendClickBehavior:Re,legendHighlightedCategory:Be,legendIsolatedCategories:Ie,foregroundGraphics:dt,annotations:Ae,svgAnnotationRules:Se,annotationFrame:0})]})}const Oo=Ct.current;return e.jsxs("div",{ref:st,className:"stream-network-frame"+(pe?" "+pe:""),role:"group","aria-label":qe||("string"==typeof De?De:"Network chart"),tabIndex:0,style:{position:"relative",width:he?"100%":at[0],height:ge?"100%":at[1],overflow:"visible"},onKeyDown:jo,children:[Ge&&e.jsx(Nt,{tableId:pt}),Ge&&e.jsx(Dt,{nodes:null!==(g=null==Oo?void 0:Oo.sceneNodes)&&void 0!==g?g:[],edges:null!==(f=null==Oo?void 0:Oo.sceneEdges)&&void 0!==f?f:[],chartType:"Network chart",tableId:pt,chartTitle:"string"==typeof De?De:void 0}),e.jsx(Ht,{summary:Xe}),e.jsxs("div",{role:"img","aria-label":qe||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ve?Ao:void 0,onMouseLeave:ve?yo:void 0,onClick:xe||ke?mo:void 0,children:[ht&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:at[0],height:at[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${lt.left},${lt.top})`,children:ht})}),e.jsx("canvas",{ref:St,"aria-label":Ot(null!==(y=null===(p=null==Oo?void 0:Oo.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==y?y:0,null!==(m=null===(v=null==Oo?void 0:Oo.sceneEdges)||void 0===v?void 0:v.length)&&void 0!==m?m:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx($t,{hoverPoint:_t}),e.jsx(Wi,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,labels:(null==Oo?void 0:Oo.labels)||[],sceneNodes:null==Oo?void 0:Oo.sceneNodes,title:De,legend:_e,legendPosition:Pe,legendHoverBehavior:Te,legendClickBehavior:Re,legendHighlightedCategory:Be,legendIsolatedCategories:Ie,foregroundGraphics:dt,annotations:Ae,svgAnnotationRules:Se,annotationFrame:Rt}),e.jsx(Ft,{active:bo.current>=0,hoverPoint:_t,margin:lt,size:at,shape:null===(b=ko.current)||void 0===b?void 0:b.shape,width:null===(x=ko.current)||void 0===x?void 0:x.w,height:null===(k=ko.current)||void 0===k?void 0:k.h}),So,(null==ze?void 0:ze.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ze.badgePosition?{top:4,left:4}:"bottom-left"===ze.badgePosition?{bottom:4,left:4}:"bottom-right"===ze.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:It?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:It?"STALE":"LIVE"})]})]})});Zi.displayName="StreamNetworkFrame";const Ji={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 er(e,t){return"function"==typeof t?t(e):e[t]}function tr(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function or(t={}){const{fields:o,title:n,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(n){const e=er(t,n);a=tr(e,i)}if(o&&o.length>0)o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=er(t,n);l.push({label:o,value:tr(s,r)})});else if(!n){const e=["value","y","name","id","label"];for(const o of e)if(void 0!==t[o]){a=tr(t[o],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=tr(t[e[0]],i))}}const c=Object.assign(Object.assign({},Ji),r);return e.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((t,o)=>e.jsxs("div",{style:{marginTop:0===o&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},o))]})}}function nr(t){if(!0===t)return or();if("function"==typeof t){const o=t;return t=>{const n=o(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==n?null:e.jsx("div",{className:"semiotic-tooltip",style:Ji,children:n})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?or(t):or())}function ir(e){return"string"==typeof e?e:"value"}function rr(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function sr(e,t){if(!t)return rr(e);try{const o=t(e);return null==o?rr(e):o}catch(t){return rr(e)}}function ar(e,t){return"function"==typeof t?t(e):e[t]}function lr(t){const o=t.find(e=>"title"===e.role),n=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=o?sr(ar(i,o.accessor),o.format):null;return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[null!=r&&e.jsx("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((t,o)=>{const n=sr(ar(i,t.accessor),t.format);return e.jsxs("div",{style:o>0?{marginTop:2}:void 0,children:[e.jsxs("span",{style:{opacity:.7},children:[t.label,": "]}),e.jsx("span",{children:n})]},o)})]})}}function cr({categoryAccessor:t,valueAccessor:o,groupAccessor:n,groupLabel:i,pieData:r=!1,valueFormat:s}){return a=>{var l;const c=r?(null===(l=a.data)||void 0===l?void 0:l[0])||a.data||a:a.data||a,u=ar(c,t),d=ar(c,o),h=n?ar(c,n):void 0;return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[e.jsx("div",{style:{fontWeight:"bold"},children:rr(u)}),e.jsx("div",{style:{marginTop:4},children:sr(d,s)}),null!=h&&e.jsxs("div",{style:{marginTop:2,opacity:.8},children:[i||ir(n),": ",rr(h)]})]})}}const ur=t.createContext(null);function dr({colors:o,categories:n,colorScheme:i="category10",children:r}){const s=t.useMemo(()=>{if(o)return o;if(n){const e=Array.isArray(i)?i:$[i]||W,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[o,n,i]);return e.jsx(ur.Provider,{value:s,children:r})}function hr(){return t.useContext(ur)}function gr(e){const t=[];for(const[o,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[o]));else{const[e,i]=n.range;t.push(t=>{const n=t[o];return n>=e&&i>=n})}return e=>t.every(t=>t(e))}function fr(e,t){const o=[];for(const[n,i]of e.clauses)"crossfilter"===e.resolution&&n===t||o.push(gr(i));return 0===o.length?()=>!0:"intersect"===e.resolution?e=>o.every(t=>t(e)):e=>o.some(t=>t(e))}function pr(e,t){let o=e.get(t);return o||(o={name:t,resolution:"union",clauses:new Map},e.set(t,o)),o}dr.displayName="CategoryColorProvider";const[yr,vr]=w(e=>({selections:new Map,setClause(t,o){e(e=>{const n=new Map(e.selections),i=pr(n,t),r=new Map(i.clauses);return r.set(o.clientId,o),n.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:n}})},clearClause(t,o){e(e=>{const n=e.selections.get(t);if(!n)return{};const i=new Map(e.selections),r=new Map(n.clauses);return r.delete(o),i.set(t,Object.assign(Object.assign({},n),{clauses:r})),{selections:i}})},setResolution(t,o){e(e=>{const n=new Map(e.selections),i=pr(n,t);return n.set(t,Object.assign(Object.assign({},i),{resolution:o})),{selections:n}})},clearSelection(t){e(e=>{const o=new Map(e.selections),n=o.get(t);return n&&o.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[mr,br]=w(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const o=e.observations;return o.push(t),o.length>e.maxObservations&&o.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function xr(e){const o=t.useId(),n=e.clientId||o,{name:i}=e,r=vr(e=>e.selections.get(i)),s=vr(e=>e.setClause),a=vr(e=>e.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?fr(r,n):()=>!0,[r,n]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"point",values:new Set(n)};s(i,{clientId:n,type:"point",fields:t})},[n,i,s]),selectInterval:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"interval",range:n};s(i,{clientId:n,type:"interval",fields:t})},[n,i,s]),clear:t.useCallback(()=>{a(i,n)},[a,i,n]),clientId:n}}function kr(e){const o=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:s,clear:a}=xr({name:o});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,a,o]),predicate:i,isActive:r}}function wr(e){const{name:o,xField:n,yField:i}=e,{predicate:r,isActive:s,selectInterval:a,clear:l}=xr({name:o}),c=n&&i?"xyBrush":n?"xBrush":"yBrush",u=t.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&Array.isArray(e)&&2===e.length?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Array.isArray(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Array.isArray(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,n,i,a,l]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:l}}function jr(e={}){const{limit:o=50,types:n,chartId:i}=e,r=br(e=>e.version),s=br(e=>e.observations),a=br(e=>e.clearObservations),l=t.useMemo(()=>{let e=s;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return i&&(e=e.filter(e=>e.chartId===i)),e.length>o&&(e=e.slice(e.length-o)),e},[s,n,i,o,r]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:a}}const Ar=t.createContext(!1);function Sr({selections:e}){const o=vr(e=>e.setResolution);return t.useEffect(()=>{for(const[t,n]of Object.entries(e))n.resolution&&o(t,n.resolution)},[e,o]),null}function Or({categoryColors:o,interaction:n,selectionName:i,field:r}){const s=Object.entries(o);if(0===s.length)return null;const a=s.map(([e])=>e),l=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:s.map(([e,t])=>({label:e,color:t})),label:""}],c=kr({name:i,fields:[r]}),u=xr({name:i,clientId:"__linked-legend-isolate__"}),[d,h]=t.useState(new Set),[g,f]=t.useState(null),p=t.useRef(u.selectPoints);p.current=u.selectPoints;const y=t.useRef(u.clear);y.current=u.clear,t.useEffect(()=>{"isolate"===n&&(d.size>0?p.current({[r]:Array.from(d)}):y.current())},[n,d,r]);const v=t.useCallback(e=>{"highlight"===n&&(e?(f(e.label),c.onHover({[r]:e.label})):(f(null),c.onHover(null)))},[n,r,c]),m=t.useCallback(e=>{"isolate"===n&&h(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===a.length?new Set:o})},[n,a.length]),[b,[x]]=Yt([0,0],!0,!1),k=t.useMemo(()=>function(e,t){if(!t||0===e.length)return 1;let o=0,n=1;for(const i of e){const e=26+7*i.length;o>0&&o+e>t&&(n++,o=0),o+=e}return n}(s.map(([e])=>e),x),[s,x]);return e.jsx("div",{ref:b,style:{width:"100%",display:"block"},children:e.jsx("svg",{width:"100%",height:Math.max(30,22*k+8),style:{display:"block",overflow:"visible"},children:e.jsx(Ne,{legendGroups:l,title:!1,orientation:"horizontal",width:x,height:20,customHoverBehavior:"highlight"===n?v:void 0,customClickBehavior:"isolate"===n?m:void 0,highlightedCategory:g,isolatedCategories:d})})})}function Mr({children:t,selections:o,showLegend:n,legendPosition:i="top",legendInteraction:r="none",legendSelectionName:s="legend",legendField:a="category"}){const l=hr(),c=void 0!==n?n:!(!l||0>=Object.keys(l).length);return e.jsx(yr,{children:e.jsxs(mr,{children:[o&&e.jsx(Sr,{selections:o}),e.jsxs(Ar.Provider,{value:c,children:[c&&"top"===i&&l&&e.jsx(Or,{categoryColors:l,interaction:r,selectionName:s,field:a}),t,c&&"bottom"===i&&l&&e.jsx(Or,{categoryColors:l,interaction:r,selectionName:s,field:a})]})]})})}function Cr({data:e,colorBy:t,colorScale:o,getColor:n,strokeColor:i,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((i,r)=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),a=s?n(s,t,o):o?o(i):F[r%F.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",o={fill:t,stroke:t};return void 0!==i&&(o.stroke=i),void 0!==r&&(o.strokeWidth=r),o},type:"fill",items:a,label:""}]}}function _r(e){return e?"string"==typeof e?{name:e}:e:null}function Pr(e,t,o){return t?n=>{var i;const r=Object.assign({},e(n));if(t.isActive)if(t.predicate(n))(null==o?void 0:o.selectedStyle)&&Object.assign(r,o.selectedStyle);else{const e=null!==(i=null==o?void 0:o.unselectedOpacity)&&void 0!==i?i:.5;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==o?void 0:o.unselectedStyle)&&Object.assign(r,o.unselectedStyle)}return r}:e}const Lr={light:M,dark:C,"high-contrast":_,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 Tr(e){return Lr[e]}const Rr=y.createContext(void 0);function Br({theme:e}){const t=L(e=>e.setTheme),o=L(e=>e.theme),n=y.useRef(o);n.current=o;const i=y.useRef(null);return y.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(forced-colors: active)");return o.matches&&(i.current=n.current,t(_)),zt(o,e=>{var o;e.matches?(i.current=n.current,t(_)):(t(null!==(o=i.current)&&void 0!==o?o:M),i.current=null)})},[e,t]),y.useEffect(()=>{if(void 0!==e)if("string"==typeof e){const o=Tr(e);t(o||e)}else t(e)},[e,t]),null}function Ir({children:t}){var o,n,i,r,s;const a=L(e=>e.theme),l=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"relative","--semiotic-bg":a.colors.background,"--semiotic-text":a.colors.text,"--semiotic-text-secondary":a.colors.textSecondary,"--semiotic-grid":a.colors.grid,"--semiotic-border":a.colors.border,"--semiotic-primary":a.colors.primary,"--semiotic-font-family":a.typography.fontFamily},a.colors.focus?{"--semiotic-focus":a.colors.focus}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(n=a.tooltip)||void 0===n?void 0:n.text)?{"--semiotic-tooltip-text":a.tooltip.text}:{}),(null===(i=a.tooltip)||void 0===i?void 0:i.borderRadius)?{"--semiotic-tooltip-radius":a.tooltip.borderRadius}:{}),(null===(r=a.tooltip)||void 0===r?void 0:r.fontSize)?{"--semiotic-tooltip-font-size":a.tooltip.fontSize}:{}),(null===(s=a.tooltip)||void 0===s?void 0:s.shadow)?{"--semiotic-tooltip-shadow":a.tooltip.shadow}:{}),a.borderRadius?{"--semiotic-border-radius":a.borderRadius}:{}),a.colors.selection?{"--semiotic-selection-color":a.colors.selection}:{}),null!=a.colors.selectionOpacity?{"--semiotic-selection-opacity":a.colors.selectionOpacity+""}:{}),a.colors.diverging?{"--semiotic-diverging":a.colors.diverging}:{}),a.colors.annotation?{"--semiotic-annotation-color":a.colors.annotation}:{}),null!=a.typography.legendSize?{"--semiotic-legend-font-size":a.typography.legendSize+"px"}:{}),null!=a.typography.titleFontSize?{"--semiotic-title-font-size":a.typography.titleFontSize+"px"}:{}),null!=a.typography.tickFontFamily?{"--semiotic-tick-font-family":a.typography.tickFontFamily}:{}),{"--semiotic-secondary":a.colors.secondary||a.colors.primary,"--semiotic-surface":a.colors.surface||a.colors.background}),a.colors.success?{"--semiotic-success":a.colors.success}:{}),a.colors.danger?{"--semiotic-danger":a.colors.danger}:{}),a.colors.warning?{"--semiotic-warning":a.colors.warning}:{}),a.colors.error?{"--semiotic-error":a.colors.error}:{}),a.colors.info?{"--semiotic-info":a.colors.info}:{}),c=y.useContext(Rr),u={};return c&&(u["data-semiotic-theme"]=c),e.jsx("div",Object.assign({style:l},u,{children:t}))}function Dr(){return L(e=>e.theme)}const Hr="#007bff";function Nr(){var e;const t=Dr(),o=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return o&&o.length>0?o:void 0}function $r(e,t,o,n,i){if(e)return e;let r;if(Array.isArray(o))r=o;else if(t&&t.length>0)r=t;else if("string"==typeof o){const e=$[o];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=n?(i.has(n)||i.set(n,i.size),r[i.get(n)%r.length]):r[0]:Hr}function Wr(e,o,n){const i=hr(),r=Nr();return t.useMemo(()=>{var t;if(!o)return;const s=null!==(t=null!=n?n:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof o){const t=Array.from(new Set(e.map(e=>o(e)+"")));if(i&&Object.keys(i).length>0){const e=G(t.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return G(t.map(e=>({_cat:e})),"_cat",s)}if(i&&Object.keys(i).length>0){const t=G(e,o,s);return e=>i[e]||t(e)}return G(e,o,s)}if(i&&Object.keys(i).length>0){const e=G([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,o,n,i,r])}function Fr(e,o,n){return t.useMemo(()=>{if(!o||"auto"===o||"function"==typeof o)return e;const t=[...e],i="function"==typeof(r=n)?r:e=>e[r];var r;return t.sort("asc"===o?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,o,n])}function Er({selection:e,linkedHover:o,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(o,n),g=xr({name:(null==e?void 0:e.name)||"__unused__"}),f=kr({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),p=br(e=>e.pushObservation),y=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,m]=t.useState(null),b=u||n[0],x=t.useMemo(()=>{if(!c||null==v||!b)return null;const e=v,t=b;return{isActive:!0,predicate:o=>{var n;return("string"==typeof o[t]?o[t]:(null!==(n=o[t])&&void 0!==n?n:"")+"")===e}}},[c,v,b]),k=t.useCallback(e=>{var t,n;if(o)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,o){const n=nt.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===o||(nt={positions:new Map(nt.positions).set(e,{xValue:t,sourceId:o})},rt())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&st(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const o=null==t?void 0:t[b];m(null!=o?o+"":null)}else m(null);if(r||p){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const s=Object.assign(Object.assign({},o),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});r&&r(e),p&&p(e)}}},[o,f,h,d,r,s,a,p,c,b]),w=t.useCallback(e=>{var t,o,n,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const o=null==t?void 0:t[h.xField];null!=o&&Number.isFinite(Number(o))&&function(e,t,o){const n=nt.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(nt.positions);return t.delete(e),nt={positions:t},rt(),!1}nt={positions:new Map(nt.positions).set(e,{xValue:t,sourceId:o,locked:!0})},rt()}(h.name||"hover",Number(o),d)}if(e&&l){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),l(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0})}if(r||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:o||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),p&&p(e)}}},[l,r,p,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{at(e,d),st(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function zr(e,t){const o="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==o?void 0:o.mode))return{linkedCrosshairName:o.name||"hover",linkedCrosshairSourceId:t}}function Yr({data:e,colorBy:o,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(Ar),u=void 0!==i?i:!c&&!!o,d=t.useMemo(()=>{if(!u||!o)return;const t=Cr({data:e,colorBy:o,colorScale:n,getColor:Y,categories:l});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[u,o,e,n,l]),h=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=Object.assign(Object.assign({},a),e);return d&&("right"===r&&110>t.right?t.right=110:"left"===r&&110>t.left?t.left=110:"top"===r&&50>t.top?t.top=50:"bottom"===r&&80>t.bottom&&(t.bottom=80)),t},[a,s,d,r]);return{legend:d,margin:h,legendPosition:r}}function Gr(e,o,n){const[i,r]=t.useState(null),[s,a]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&r(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&a(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=t.useMemo(()=>{if(!e||"none"===e||!o)return null;const t="string"==typeof o?o:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof o?o(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const n=t?e[t]:"function"==typeof o?o(e):null;return s.has(n)}}:null},[e,o,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const qr={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 Xr(e,t,o){var n,i,r,s,a,l,c;const u=qr[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==o?void 0:o.width)?u.width:o.width,height:null!==(i=t.height)&&void 0!==i?i:e&&"primary"!==e||!(null==o?void 0:o.height)?u.height:o.height,showAxes:null!==(r=t.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Vr(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function Vr(e,t,o){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===o?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function Ur(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>{const n=e(...t)||{};return Object.assign(Object.assign({},n),o)}:(...e)=>Object.assign({},o)}function Kr({componentName:t,message:o,diagnosticHint:n,width:i,height:r}){return e.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:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:o}),n&&e.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:n})]})})}class Qr extends y.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var o,n;null===(n=(o=this.props).onError)||void 0===n||n.call(o,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,o=this.state.error;return"function"==typeof t?t(o):void 0!==t?t:e.jsx(Kr,{componentName:"ChartErrorBoundary",message:o.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function Zr(e,t){const o=e.length,n=t.length,i=Array(n+1);for(let e=0;n>=e;e++)i[e]=e;for(let r=1;o>=r;r++){let o=i[0];i[0]=r;for(let s=1;n>=s;s++){const n=i[s];i[s]=e[r-1]===t[s-1]?o:1+Math.min(o,i[s],i[s-1]),o=n}}return i[n]}function Jr(e,t,o=3){let n,i=o+1;for(const o of t){const t=Zr(e.toLowerCase(),o.toLowerCase());i>t&&(i=t,n=o)}return i>o?void 0:n}function es(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function ts(e,t){var o;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(o=Jr(e,t,3))&&void 0!==o?o:null)}function os({componentName:e,data:t,accessors:o,requiredProps:n}){if(n)for(const[t,o]of Object.entries(n))if(null==o)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(o){const n=es(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[i,r]of Object.entries(o))if(r&&"string"==typeof r&&!(r in n)){const o=ts(r,t),n=o?` Try ${i}="${o}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}function ns({componentName:e,data:t,dataLabel:o="data"}){return null==t?`${e}: No ${o} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${o} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function is({componentName:e,nodes:t,edges:o,nodesRequired:n=!1,edgesRequired:i=!0,accessors:r}){if(null==t&&null==o)return null;if(i&&(!o||!Array.isArray(o)||0===o.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(r&&t&&t.length>0){const o=es(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[n,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in o)){const o=ts(i,t),r=o?` Try ${n}="${o}".`:"";return`${e}: ${n} "${i}" not found in node data. Available fields: ${t.join(", ")}.${r}`}}}return null}const rs={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},ss={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},as={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},ls=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],cs=["vertical","horizontal"],us={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ls},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ls},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ls},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},CandlestickChart:{required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},highAccessor:{type:["string","function"]},lowAccessor:{type:["string","function"]},openAccessor:{type:["string","function"]},closeAccessor:{type:["string","function"]},candlestickStyle:{type:"object"},mode:{type:"string",enum:["primary","context","sparkline"]},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),ss),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:cs},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:cs},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},rs),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},rs),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},rs),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},rs),as),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},rs),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},rs),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:cs},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},rs),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},rs),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},rs),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},rs),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},rs),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},rs),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},rs),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},rs),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},rs),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},rs),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},rs),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function ds(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const hs=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),gs=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),fs=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),ps=new Set(["LineChart","AreaChart","StackedAreaChart"]),ys=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function vs(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[o,n,i]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],r=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*r(o)+.7152*r(n)+.0722*r(i)}function ms(e,t){const o=vs(e),n=vs(t);return null===o||null===n?null:(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}const bs=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];var xs;const ks="undefined"!=typeof process&&"production"!==(null===(xs=process.env)||void 0===xs?void 0:xs.NODE_ENV);function ws({componentName:t,width:o,height:n,chartProps:i,children:r}){return e.jsx(Qr,{fallback:r=>{let s="";if(ks&&i)try{const e=function(e,t){const o=[],n=function(e,t){const o=[],n=us[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(us).join(", ")}`]};for(const i of n.required)null==t[i]&&o.push(`"${i}" is required for ${e}.`);for(const[e,i]of Object.entries(t)){if(null==i)continue;const t=n.props[e];if(t){if(!ds(i,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;o.push(`"${e}" should be ${n}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&o.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const i=Object.keys(n.props),r=new Set(i);for(const n of Object.keys(t))if(void 0!==t[n]&&!r.has(n)){const t=Jr(n,i),r=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${i.join(", ")}.`;o.push(r)}if("array"===n.dataShape){const i=t.data,r={};for(const e of n.dataAccessors){const o=t[e];"string"==typeof o&&(r[e]=o)}const s=os({componentName:e,data:i,accessors:Object.keys(r).length>0?r:void 0});s&&o.push(s)}else if("object"===n.dataShape){const n=ns({componentName:e,data:t.data});n&&o.push(n)}else if("network"===n.dataShape){const i=is({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});i&&o.push(i)}return{valid:0===o.length,errors:o}}(e,t);for(const e of n.errors)o.push({severity:"error",code:"VALIDATION",message:e,fix:""});return us[e]?(function(e,t,o){const n=us[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&o.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&o.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,o),function(e,t,o){const n=t.width,i=t.height;if(void 0===n||"number"==typeof n&&n>0||o.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===i||"number"==typeof i&&i>0||o.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(i)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&o.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,o),function(e,t,o){const n=us[e];if(!n||"array"!==n.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=Object.keys(r);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in r||o.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,o),function(e,t,o){hs.has(e)&&Array.isArray(t.data)&&o.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,o),function(e,t,o){gs.has(e)&&(t.edges||t.data||o.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,o),function(e,t,o){const n=us[e];if(!n||"array"!==n.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=t.xAccessor;"string"==typeof s&&r[s]instanceof Date&&!t.xFormat&&o.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,o),function(e,t,o){t.linkedHover&&!t.selection&&o.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,o),function(e,t,o){var n;if(!fs.has(e))return;const i=t.rExtent||t.yExtent;i&&Array.isArray(i)&&i.length>=1&&null!=i[0]&&0!==i[0]&&o.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${i[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(n=i[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,o),function(e,t,o){if(!ps.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=t.yAccessor||"y";"string"==typeof i&&n.some(e=>{const t=e[i];return null==t||Number.isNaN(t)})&&o.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${i}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,o),function(e,t,o){var n,i;const r=null!==(n=t.width)&&void 0!==n?n:600,s=null!==(i=t.height)&&void 0!==i?i:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);r>l||o.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||o.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,o),function(e,t,o){var n;const i=us[e];if(!i||"array"!==i.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(r.length,5);for(const e of s){let t=!0;for(let o=0;a>o;o++){const i=null===(n=r[o])||void 0===n?void 0:n[e.name];if("number"==typeof i&&Number.isFinite(i)){t=!1;break}}t&&o.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,o),function(e,t,o){if(!ys.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&o.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,o),function(e,t,o){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const i=n.bottom;"number"==typeof i&&70>i&&o.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${i}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,o),function(e,t,o){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const i=t.margin;if(!i||"object"!=typeof i)return;const r=i.right;"number"==typeof r&&100>r&&o.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${r}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,o),function(e,t,o){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=n[0];if(i&&"object"==typeof i)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const r=i[n];"string"==typeof r&&o.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${r}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;const r=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ms(e,i);null!==t&&3>t&&r.push(`${e} (${t.toFixed(1)}:1)`)}r.length>0&&o.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${r.length} color(s) in colorScheme have < 3:1 contrast against background "${i}": ${r.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const i=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>i.length)return;const r=[];for(let e=0;i.length-1>e;e++){const t=ms(i[e],i[e+1]);null!==t&&1.5>t&&r.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}r.length>0&&o.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${r.length} adjacent color pair(s) in colorScheme have very similar luminance: ${r.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,o),function(e,t,o){const n="string"==typeof t.title&&t.title.trim().length>0,i="string"==typeof t.description&&t.description.trim().length>0,r="string"==typeof t.summary&&t.summary.trim().length>0;n||i||r||o.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,o),function(e,t,o){const n=[];for(const e of bs)"function"==typeof t[e]&&n.push(e);n.length>0&&o.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,o),{ok:o.every(e=>"warning"===e.severity),diagnoses:o}):{ok:0===o.length,diagnoses:o}}(t,i);e.ok||(s=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.jsx(Kr,{componentName:t,message:r.message,diagnosticHint:s,width:o,height:n})},children:r})}const js={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"},As={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Ss(t,o,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},js),{width:o,height:n}),children:i||"No data available"}):null}function Os(t,o,n){if(!t)return null;const i=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*i))),s=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(r+s)-s))/2);return e.jsx("div",{style:{width:o,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,n)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},As),{position:"absolute",top:a+n*(r+s),left:Math.floor(.1*o),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})},n))})}function Ms(e,t,o,n){if(!ks)return;if(!t||0===t.length)return;if("string"!=typeof n)return;const i=t[0];if(!i||"object"!=typeof i)return;if(n in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${o} "${n}" not found in data. Available keys: ${r}`)}function Cs(e){const o=L(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,n;if(void 0!==e||void 0!==o)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(n=null==e?void 0:e.unselectedOpacity)&&void 0!==n?n:o})},[e,o])}function _s(e){const{data:o,rawData:n,colorBy:i,colorScheme:r,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:v,onClick:m,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:j}=e,A="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:S,hoverSelectionHook:O,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:_}=Er({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:m,hoverHighlight:b,colorByField:A}),P=zr(c,_),L=Wr(o,i,r),T=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of o){const o="function"==typeof i?i(t):t[i];null!=o&&e.add(o+"")}return Array.from(e)},[o,i]),R=Gr(s,i,T),B=t.useMemo(()=>O||(R.legendSelectionHook?R.legendSelectionHook:S),[O,R.legendSelectionHook,S]),I=Cs(l),{legend:D,margin:H,legendPosition:N}=Yr({data:o,colorBy:i,colorScale:L,showLegend:p,legendPosition:a,userMargin:y,defaults:v}),$=t.useMemo(()=>{const e={};return D&&(e.legend=D,e.legendPosition=N),s&&"none"!==s&&(e.legendHoverBehavior=R.onLegendHover,e.legendClickBehavior=R.onLegendClick,e.legendHighlightedCategory=R.highlightedCategory,e.legendIsolatedCategories=R.isolatedCategories),e},[D,N,s,R.onLegendHover,R.onLegendClick,R.highlightedCategory,R.isolatedCategories]),W=Os(x,w,j),F=W?null:Ss(n,w,j,k);return{colorScale:L,allCategories:T,legendState:R,effectiveSelectionHook:B,activeSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,legend:D,margin:H,legendPosition:N,earlyReturn:W||F||null,legendBehaviorProps:$,crosshairProps:P,resolvedSelection:I}}const Ps=t.forwardRef(function(o,n){const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",colorBy:g,colorScheme:f,sizeBy:p,sizeRange:v=[3,15],pointRadius:m=5,pointOpacity:b=.8,tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:j,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,emptyContent:R,legendInteraction:B,legendPosition:I,color:D,stroke:H,strokeWidth:N,opacity:$}=o,W=r.width,F=r.height,E=r.enableHover,z=r.showGrid,G=r.title,X=r.description,V=r.summary,U=r.accessibleTable,K=r.xLabel,Q=r.yLabel,Z=s||[],J=_s({data:Z,rawData:s,colorBy:g,colorScheme:f,legendInteraction:B,legendPosition:I,selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:C,onClick:_,hoverHighlight:P,chartType:"Scatterplot",chartId:L,showLegend:r.showLegend,userMargin:a,marginDefaults:r.marginDefaults,loading:T,emptyContent:R,width:W,height:F}),ee=_r(M),te=wr({name:(null==ee?void 0:ee.name)||"__unused_brush__",xField:(null==ee?void 0:ee.xField)||("string"==typeof d?d:void 0),yField:(null==ee?void 0:ee.yField)||("string"==typeof h?h:void 0)}),oe=ee?"xyBrush"===te.brushInteraction.brush?"xy":"xBrush"===te.brushInteraction.brush?"x":"y":void 0,ne=y.useRef(te.brushInteraction);ne.current=te.brushInteraction;const ie=t.useCallback(e=>{const t=ne.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(J.earlyReturn)return J.earlyReturn;Ms("Scatterplot",Z,"xAccessor",d),Ms("Scatterplot",Z,"yAccessor",h);const re=t.useMemo(()=>{if(!p||0===Z.length)return;const e=Z.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[Z,p]),se=t.useMemo(()=>e=>{const t={fillOpacity:b};return g?J.colorScale&&(t.fill=Y(e,g,J.colorScale)):t.fill=D||Hr,t.r=p?q(e,p,v,re):m,t},[g,J.colorScale,p,v,re,m,b,D]),ae=t.useMemo(()=>Ur(se,{stroke:H,strokeWidth:N,opacity:$}),[se,H,N,$]),le=t.useMemo(()=>Pr(ae,J.effectiveSelectionHook,J.resolvedSelection),[ae,J.effectiveSelectionHook,J.resolvedSelection]),ce=t.useMemo(()=>lr([{label:K||ir(d),accessor:d,role:"x",format:c},{label:Q||ir(h),accessor:h,role:"y",format:u},...g?[{label:ir(g),accessor:g,role:"color"}]:[],...p?[{label:ir(p),accessor:p,role:"size"}]:[]]),[d,h,K,Q,g,p,c,u]),ue=os({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(ue)return e.jsx(Kr,{componentName:"Scatterplot",message:ue,width:W,height:F});const de=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:Z}),{xAccessor:d,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:p||void 0,sizeRange:v,pointStyle:le,colorScheme:f,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J.margin,showAxes:r.showAxes,xLabel:K,yLabel:Q,xFormat:c,yFormat:u,enableHover:E,showGrid:z}),J.legendBehaviorProps),G&&{title:G}),X&&{description:X}),V&&{summary:V}),void 0!==U&&{accessibleTable:U}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:nr(x)||ce}),(O||C||_||P)&&{customHoverBehavior:J.customHoverBehavior}),(C||_||O)&&{customClickBehavior:J.customClickBehavior}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),j&&j.length>0&&{annotations:j}),ee&&{brush:{dimension:oe},onBrush:ie}),J.crosshairProps),A);return e.jsx(ws,{componentName:"Scatterplot",width:W,height:F,children:e.jsx(Lo,Object.assign({ref:i},de))})});function Ls(e,t){return s.interpolateViridis(1===t?.5:e/(t-1))}Ps.displayName="Scatterplot";const Ts=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const s=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",orderAccessor:g,orderLabel:f,pointRadius:p=4,tooltip:y,pointIdAccessor:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,stroke:_,strokeWidth:P,opacity:L}=o,T=s.width,R=s.height,B=s.enableHover,I=s.showGrid,D=s.title,H=s.description,N=s.summary,$=s.accessibleTable,W=s.xLabel,F=s.yLabel,E=a||[],{safeData:z,orderMap:Y}=t.useMemo(()=>{const e="function"==typeof d?d:e=>e[d],t="function"==typeof h?h:e=>e[h];let o=E;if(g&&E.length>0){const e="function"==typeof g?g:e=>e[g];o=[...E].sort((t,o)=>{const n=e(t),i=e(o);return(n instanceof Date?n.getTime():+n)-(i instanceof Date?i.getTime():+i)})}const n=new WeakMap;let i=0;for(const n of o){const o=e(n),r=t(n);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&i++}let r=0;for(const s of o){const o=e(s),a=t(s);null!=o&&null!=a&&isFinite(o)&&isFinite(a)&&n.set(s,{idx:r++,total:i})}return{safeData:o,orderMap:n}},[E,g,d,h]);Ms("ConnectedScatterplot",z,"xAccessor",d),Ms("ConnectedScatterplot",z,"yAccessor",h);const{activeSelectionHook:G,hoverSelectionHook:q,customHoverBehavior:X,customClickBehavior:V,crosshairSourceId:U}=Er({selection:x,linkedHover:k,fallbackFields:[],onObservation:w,onClick:j,chartType:"ConnectedScatterplot",chartId:S,hoverHighlight:A,colorByField:void 0}),K=Cs(x),Q=zr(k,U),Z=Gr(C,void 0,[]),J=t.useMemo(()=>q||(Z.legendSelectionHook?Z.legendSelectionHook:G),[q,Z.legendSelectionHook,G]),ee=null!==(i=null==K?void 0:K.unselectedOpacity)&&void 0!==i?i:.5,te=t.useMemo(()=>(e,t)=>{var o,n;const i=t.filter(e=>"point"===e.type);if(2>i.length)return;const r=null==J?void 0:J.isActive,s=null==J?void 0:J.predicate,a=100>i.length,l=i.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=i[t],u=i[t+1],d=Ls(t,l),h=!r||!s||s(null!==(o=c.datum)&&void 0!==o?o:c)||s(null!==(n=u.datum)&&void 0!==n?n:u),g=r?h?1:ee:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,J,ee]),oe=t.useMemo(()=>[te],[te]),ne=t.useMemo(()=>(t,o,n)=>{var i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return null;const a=s.length,l=100>a,c=[];for(let t=0;a-1>t;t++){const o=s[t],n=s[t+1],u=Ls(t,a),d="number"==typeof(null===(i=o.style)||void 0===i?void 0:i.opacity)?o.style.opacity:1,h="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(d,h);l&&c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:p+2,strokeLinecap:"round",opacity:.5*g},"halo-"+t)),c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:u,strokeWidth:p,strokeLinecap:"round",opacity:g},"seg-"+t))}return e.jsx(e.Fragment,{children:c})},[p]),ie=t.useMemo(()=>[ne],[ne]),re=t.useMemo(()=>e=>{var t,o;const n=Y.get(e),i=null!==(t=null==n?void 0:n.idx)&&void 0!==t?t:0,r=null!==(o=null==n?void 0:n.total)&&void 0!==o?o:1;return{fill:r>0?Ls(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}},[p,Y]),se=t.useMemo(()=>Ur(re,{stroke:_,strokeWidth:P,opacity:L}),[re,_,P,L]),ae=t.useMemo(()=>Pr(se,J,K),[se,J,K]),le=Object.assign({top:50,right:40,bottom:60,left:70},"number"==typeof o.margin?{top:o.margin,bottom:o.margin,left:o.margin,right:o.margin}:o.margin),ce=f||("string"==typeof g?g:"Order"),ue=t.useMemo(()=>lr([{label:W||ir(d),accessor:d,role:"x",format:c},{label:F||ir(h),accessor:h,role:"y",format:u},...g?[{label:ce,accessor:g,role:"group"}]:[]]),[d,h,W,F,g,ce,c,u]),de=os({componentName:"ConnectedScatterplot",data:a,accessors:{xAccessor:d,yAccessor:h}}),he=Os(O,T,R),ge=he?null:Ss(a,T,R,M),fe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=a&&{data:z}),{xAccessor:d,yAccessor:h,pointStyle:ae,size:[T,R],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:le,showAxes:s.showAxes,xLabel:W,yLabel:F,xFormat:c,yFormat:u,enableHover:B,showGrid:I}),D&&{title:D}),H&&{description:H}),N&&{summary:N}),void 0!==$&&{accessibleTable:$}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===y?()=>null:nr(y)||ue}),(k||w||j||A)&&{customHoverBehavior:X}),(w||j||k)&&{customClickBehavior:V}),v&&{pointIdAccessor:v}),{canvasPreRenderers:oe,svgPreRenderers:ie}),m&&m.length>0&&{annotations:m}),Q),b);return he||ge||(de?e.jsx(Kr,{componentName:"ConnectedScatterplot",message:de,width:T,height:R}):e.jsx(ws,{componentName:"ConnectedScatterplot",width:T,height:R,children:e.jsx(Lo,Object.assign({ref:r},fe))}))});function Rs(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){e.done?i(e.value):function(e){return e instanceof o?e:new o(function(t){t(e)})}(e.value).then(s,a)}l((n=n.apply(e,t||[])).next())})}Ts.displayName="ConnectedScatterplot","function"==typeof SuppressedError&&SuppressedError;const Bs="__forecastSegment";let Is=null;function Ds(){return Rs(this,void 0,void 0,function*(){return Is||(Is=yield Promise.resolve().then(function(){return Ml})),Is})}const Hs=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=s.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const a=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,xAccessor:g="x",yAccessor:f="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:v,colorScheme:m,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:j=.3,lineWidth:A=2,lineGradient:S,tooltip:O,pointIdAccessor:M,annotations:C,directLabel:_,gapStrategy:P="break",anomaly:L,forecast:T,frameProps:R={},selection:B,linkedHover:I,onObservation:D,onClick:H,hoverHighlight:N,hoverRadius:$,chartId:W,loading:F,emptyContent:E,legendInteraction:z,legendPosition:G,xScaleType:q,yScaleType:X,color:V,stroke:U,strokeWidth:K,opacity:Q}=o,Z=a.width,J=a.height,ee=a.enableHover,te=a.showGrid,oe=a.showLegend,ne=a.title,ie=a.description,re=a.summary,se=a.accessibleTable,ae=a.xLabel,le=a.yLabel,ce=Os(F,Z,J),ue=ce?null:Ss(l,Z,J,E),de=l||[];Ms("LineChart",de,"xAccessor",g),Ms("LineChart",de,"yAccessor",f);const he="string"==typeof g?g:"__semiotic_resolvedX",ge="string"==typeof f?f:"__semiotic_resolvedY",[fe,pe]=t.useState(null),[ye,ve]=t.useState([]),me=t.useMemo(()=>{if(!T&&!L)return de;const e="function"==typeof g,t="function"==typeof f;return e||t?de.map(o=>{const n=Object.assign({},o);return e&&(n.__semiotic_resolvedX=g(o)),t&&(n.__semiotic_resolvedY=f(o)),n}):de},[de,T,L,g,f]),be=t.useRef(T),xe=t.useRef(L);t.useEffect(()=>{if(!T&&!L)return void((be.current||xe.current)&&(pe(null),ve([]),be.current=T,xe.current=L));let e=!1;const t=T!==be.current||L!==xe.current;if(be.current=T,xe.current=L,t&&(pe(null),ve([])),T){const t=p&&"string"==typeof p&&"object"==typeof T?Object.assign(Object.assign({},T),{_groupBy:p}):T;(function(...e){return Rs(this,void 0,void 0,function*(){return(yield Ds()).buildForecast(...e)})})(me,he,ge,t,L).then(t=>{e||(pe(t),ve(t.annotations))}).catch(()=>{e||(pe(null),ve([]))})}else L&&function(...e){return Rs(this,void 0,void 0,function*(){return(yield Ds()).buildAnomalyAnnotations(...e)})}(L).then(t=>{e||(pe(null),ve(t))}).catch(()=>{e||ve([])});return()=>{e=!0}},[me,T,L,he,ge]);const ke=fe?fe.processedData:de,we="__compoundGroup",je=!(!T||!p),Ae=je?we:T?Bs:p,Se=t.useMemo(()=>{if(!je)return ke;const e="function"==typeof p?p:e=>e[p];return ke.map(t=>{const o=Object.assign({},t);return o[we]=`${e(t)}__${t[Bs]||"observed"}`,o})},[ke,je,p]),Oe=je?Se:ke,Me=t.useMemo(()=>{if(!T)return;const e=T.upperBounds,t=T.lowerBounds;if(!e&&!t)return;const o="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,n="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let i=1/0,r=-1/0;const s=fe?fe.processedData:de;for(const e of s){const t="function"==typeof f?f(e):+e[f];if(isFinite(t)&&(i>t&&(i=t),t>r&&(r=t)),o){const t=o(e);null!=t&&isFinite(t)&&(t>r&&(r=t),i>t&&(i=t))}if(n){const t=n(e);null!=t&&isFinite(t)&&(i>t&&(i=t),t>r&&(r=t))}}return isFinite(i)&&isFinite(r)?[i,r]:void 0},[T,fe,de,f]),{activeSelectionHook:Ce,hoverSelectionHook:_e,customHoverBehavior:Pe,customClickBehavior:Le,crosshairSourceId:Te}=Er({selection:B,linkedHover:I,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:D,onClick:H,chartType:"LineChart",chartId:W,hoverHighlight:N,colorByField:"string"==typeof v?v:void 0}),Re=Cs(B),Be=zr(I,Te),Ie=t.useCallback(e=>{const t="function"==typeof g?g(e):e[g],o="function"==typeof f?f(e):e[f];return null==t||null==o||Number.isNaN(t)||Number.isNaN(o)},[g,f]),De=void 0!==(null===(i=Oe[0])||void 0===i?void 0:i[y]),He=t.useMemo(()=>{if(De)return Oe;if(Ae){const e=Oe.reduce((e,t)=>{const o="function"==typeof Ae?Ae(t):t[Ae];if(!e[o]){const n={[y]:[]};"string"==typeof Ae&&(n[Ae]=o),je&&(n[Bs]=t[Bs],"string"==typeof p&&(n[p]=t[p])),e[o]=n}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:Oe}]},[Oe,Ae,y,De]),{gapProcessedLineData:Ne,hasGaps:$e}=t.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const o of He){const n=(o[y]||[]).filter(t=>!Ie(t)||(e=!0,!1));n.length>0&&t.push(Object.assign(Object.assign({},o),{[y]:n}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const o of He){const n=o[y]||[];let i=[],r=0;const s=Ae&&"string"==typeof Ae?o[Ae]:void 0;for(const a of n)if(Ie(a))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},o),{[y]:i})),i=[],r++);else{const e=null!=s?`${s}__seg${r}`:"__seg"+r;i.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}i.length>0&&t.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof f?f:"y",o=[];for(const n of He){const i=n[y]||[],r=[];for(const o of i)Ie(o)?(e=!0,r.push(Object.assign(Object.assign({},o),{[t]:0}))):r.push(o);o.push(Object.assign(Object.assign({},n),{[y]:r}))}return{gapProcessedLineData:o,hasGaps:e}}return{gapProcessedLineData:He,hasGaps:!1}},[He,P,y,Ie,Ae,f]),We=Wr(ke,v,m),Fe=t.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of ke){const o="function"==typeof v?v(t):t[v];null!=o&&e.add(o+"")}return Array.from(e)},[ke,v]),Ee=Gr(z,v,Fe),ze=t.useMemo(()=>_e||(Ee.legendSelectionHook?Ee.legendSelectionHook:Ce),[_e,Ee.legendSelectionHook,Ce]),Ye=t.useMemo(()=>(e,t)=>{const o={strokeWidth:A},n=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return v?We&&(o.stroke=Y(e,v,We),n&&(o.fill=o.stroke,o.fillOpacity=j)):(o.stroke=V||Hr,n&&(o.fill=V||Hr,o.fillOpacity=j)),o},[v,We,A,w,j,V]),[Ge,qe]=t.useState(null);t.useEffect(()=>{if(!T)return void qe(null);let e=!1;return function(...e){return Rs(this,void 0,void 0,function*(){return(yield Ds()).createSegmentLineStyle(...e)})}(Ye,T).then(t=>{e||qe(()=>t)}).catch(()=>{e||qe(null)}),()=>{e=!0}},[Ye,T]);const Xe=Ge||Ye,Ve=t.useMemo(()=>Ur(Xe,{stroke:U,strokeWidth:K,opacity:Q}),[Xe,U,K,Q]),Ue=t.useMemo(()=>Pr(Ve,ze,Re),[Ve,ze,Re]),Ke=t.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return v?We&&(t.fill=Y(e.parentLine||e,v,We)):t.fill=V||Hr,t}},[x,k,v,We,V]),Qe=Array.isArray(w)?"mixed":w?"area":"line",Ze="object"==typeof _?_:{},Je=Ze.position||"end",et=Ze.fontSize||11,tt=t.useMemo(()=>{var e,t;if(!_||!v)return[];const o="function"==typeof g?g:e=>e[g],n="function"==typeof f?f:e=>e[f],i="function"==typeof v?v:e=>e[v],r=new Map;for(const o of Ne){const n=o[y]||[];if(0===n.length)continue;const s="end"===Je?n[n.length-1]:n[0],a=null!==(t=null!==(e=i(s))&&void 0!==e?e:i(o))&&void 0!==t?t:"";a&&!r.has(a+"")&&r.set(a+"",s)}const s=Array.from(r.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:o(t),["string"==typeof f?f:"y"]:n(t),dx:"end"===Je?6:-6,dy:0,color:We?We(e):Hr,fontSize:et}));s.sort((e,t)=>{const o="string"==typeof f?f:"y";return e[o]-t[o]});for(let e=1;s.length>e;e++){const t="string"==typeof f?f:"y",o=s[e-1],n=s[e];et+2>Math.abs(n[t]+n.dy-(o[t]+o.dy))&&(n.dy+=et+2)}return s},[_,v,We,Ne,y,g,f,Je,et]),ot=(!_||void 0!==oe)&&oe,nt=t.useMemo(()=>{if(!_)return a.marginDefaults;const e=tt.reduce((e,t)=>{var o;const n=((null===(o=t.label)||void 0===o?void 0:o.length)||0)*(.6*et);return Math.max(e,n)},0),t=e+10,o="end"===Je?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[o]:Math.max(a.marginDefaults[o]||0,t)})},[_,tt,et,Je,a.marginDefaults]),{legend:it,margin:rt,legendPosition:st}=Yr({data:Ne,colorBy:v,colorScale:We,showLegend:ot,legendPosition:G,userMargin:c,defaults:nt}),at=p||v,lt=t.useMemo(()=>lr([{label:ae||ir(g),accessor:g,role:"x",format:d},{label:le||ir(f),accessor:f,role:"y",format:h},...at?[{label:ir(at),accessor:at,role:"group"}]:[]]),[g,f,ae,le,at,d,h]),ct=os({componentName:"LineChart",data:De?(null===(r=ke[0])||void 0===r?void 0:r[y])||[]:l,accessors:{xAccessor:g,yAccessor:f}}),ut=t.useMemo(()=>De||Ae||$e?Ne.flatMap(e=>{const t=e[y]||[];return Ae&&"string"==typeof Ae?t.map(t=>Object.assign(Object.assign({},t),{[Ae]:e[Ae]})):t}):Oe,[Ne,y,De,Ae,Oe,$e]),dt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(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:Qe},Array.isArray(w)&&{areaGroups:w}),S&&{lineGradient:S}),null!=$&&{hoverRadius:$}),null!=l&&{data:ut}),{xAccessor:g,yAccessor:f,xScaleType:q,yScaleType:X}),Me&&{yExtent:Me}),{groupAccessor:"break"===P&&$e?"_gapSegment":Ae||void 0,curve:b,lineStyle:Ue}),x&&{pointStyle:Ke}),{size:[Z,J],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:rt,showAxes:a.showAxes,xLabel:ae,yLabel:le,xFormat:d,yFormat:h,enableHover:ee,showGrid:te}),it&&{legend:it,legendPosition:st}),z&&"none"!==z&&{legendHoverBehavior:Ee.onLegendHover,legendClickBehavior:Ee.onLegendClick,legendHighlightedCategory:Ee.highlightedCategory,legendIsolatedCategories:Ee.isolatedCategories}),ne&&{title:ne}),ie&&{description:ie}),re&&{summary:re}),void 0!==se&&{accessibleTable:se}),u&&{className:u}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===O?()=>null:"multi"===O?t=>{var o,n,i,r,s,a,l,c,u,d;const h=t.allSeries;if(!h||0===h.length){const a=null!==(s=null!==(r=null!==(n=null===(o=t.data)||void 0===o?void 0:o.value)&&void 0!==n?n:null===(i=t.data)||void 0===i?void 0:i.y)&&void 0!==r?r:t.value)&&void 0!==s?s:t.y;return e.jsx("div",{className:"semiotic-tooltip",style:Ji,children:e.jsx("div",{children:tr(a)})})}const g=null!==(d=null!==(c=null!==(a=t.xValue)&&void 0!==a?a:null===(l=t.data)||void 0===l?void 0:l.time)&&void 0!==c?c:null===(u=t.data)||void 0===u?void 0:u.x)&&void 0!==d?d:t.time;return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[null!=g&&e.jsx("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:tr(g)}),h.map((t,o)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:t.color,flexShrink:0}}),e.jsx("span",{style:{flex:1,fontSize:"0.85em"},children:t.group}),e.jsx("span",{style:{fontWeight:500,fontSize:"0.85em"},children:tr(t.value)})]},o))]})}:nr(O)||lt}),"multi"===O&&{tooltipMode:"multi"}),(I||D||H||N)&&{customHoverBehavior:Pe}),(D||H||I)&&{customClickBehavior:Le}),M&&{pointIdAccessor:M}),((null==C?void 0:C.length)||ye.length||tt.length)&&{annotations:[...C||[],...ye,...tt]}),Be),R);return ce||ue||(ct?e.jsx(Kr,{componentName:"LineChart",message:ct,width:Z,height:J}):e.jsx(ws,{componentName:"LineChart",width:Z,height:J,children:e.jsx(Lo,Object.assign({ref:s},dt))}))});Hs.displayName="LineChart";const Ns=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const s=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",areaBy:f,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:v="coordinates",colorBy:m,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:j=!0,lineWidth:A=2,showPoints:S=!1,pointRadius:O=3,tooltip:M,annotations:C,frameProps:_={},selection:P,linkedHover:L,onObservation:T,onClick:R,hoverHighlight:B,chartId:I,loading:D,emptyContent:H,legendInteraction:N,legendPosition:$,color:W,stroke:F,strokeWidth:E,opacity:z}=o,G=s.width,q=s.height,X=s.enableHover,V=s.showGrid,U=s.showLegend,K=s.title,Q=s.description,Z=s.summary,J=s.accessibleTable,ee=s.xLabel,te=s.yLabel,oe=Os(D,G,q),ne=oe?null:Ss(a,G,q,H),ie=a||[];Ms("AreaChart",ie,"xAccessor",h),Ms("AreaChart",ie,"yAccessor",g);const{activeSelectionHook:re,hoverSelectionHook:se,customHoverBehavior:ae,customClickBehavior:le,crosshairSourceId:ce}=Er({selection:P,linkedHover:L,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:T,onClick:R,chartType:"AreaChart",chartId:I,hoverHighlight:B,colorByField:"string"==typeof m?m:void 0}),ue=Cs(P),de=zr(L,ce),he=void 0!==(null===(i=ie[0])||void 0===i?void 0:i[v]),ge=t.useMemo(()=>{if(he)return ie;if(f){const e=ie.reduce((e,t)=>{const o="function"==typeof f?f(t):t[f];if(!e[o]){const t={[v]:[]};"string"==typeof f&&(t[f]=o),e[o]=t}return e[o][v].push(t),e},{});return Object.values(e)}return[{[v]:ie}]},[ie,f,v,he]),fe=Wr(ie,m,b),pe=t.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ie){const o="function"==typeof m?m(t):t[m];null!=o&&e.add(o+"")}return Array.from(e)},[ie,m]),ye=Gr(N,m,pe),ve=t.useMemo(()=>se||(ye.legendSelectionHook?ye.legendSelectionHook:re),[se,ye.legendSelectionHook,re]),me=t.useMemo(()=>e=>{const t={};if(m){if(fe){const o=Y(e,m,fe);t.fill=o,j?(t.stroke=o,t.strokeWidth=A):t.stroke="none"}}else{const e=W||Hr;t.fill=e,j?(t.stroke=e,t.strokeWidth=A):t.stroke="none"}return t.fillOpacity=k,t},[m,fe,W,k,j,A]),be=t.useMemo(()=>Ur(me,{stroke:F,strokeWidth:E,opacity:z}),[me,F,E,z]),xe=t.useMemo(()=>Pr(be,ve,ue),[be,ve,ue]),ke=t.useMemo(()=>{if(S)return e=>{const t={r:O,fillOpacity:1};return m?fe&&(t.fill=Y(e.parentLine||e,m,fe)):t.fill=Hr,t}},[S,O,m,fe]),{legend:we,margin:je,legendPosition:Ae}=Yr({data:ge,colorBy:m,colorScale:fe,showLegend:U,legendPosition:$,userMargin:l,defaults:s.marginDefaults}),Se=f||m,Oe=t.useMemo(()=>lr([{label:ee||ir(h),accessor:h,role:"x",format:u},{label:te||ir(g),accessor:g,role:"y",format:d},...Se?[{label:ir(Se),accessor:Se,role:"group"}]:[]]),[h,g,ee,te,Se,u,d]),Me=os({componentName:"AreaChart",data:a,accessors:{xAccessor:h,yAccessor:g}}),Ce=t.useMemo(()=>he||f?ge.flatMap(e=>{const t=e[v]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):ie,[ge,v,he,f,ie]),_e=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:Ce}),{xAccessor:h,yAccessor:g,groupAccessor:f||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:xe}),S&&ke&&{pointStyle:ke}),{size:[G,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:je,showAxes:s.showAxes,xLabel:ee,yLabel:te,xFormat:u,yFormat:d,enableHover:X}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:V}),we&&{legend:we,legendPosition:Ae}),N&&"none"!==N&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),K&&{title:K}),Q&&{description:Q}),Z&&{summary:Z}),void 0!==J&&{accessibleTable:J}),c&&{className:c}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===M?()=>null:nr(M)||Oe}),(L||T||R||B)&&{customHoverBehavior:ae}),(T||R||L)&&{customClickBehavior:le}),C&&C.length>0&&{annotations:C}),de),_);return oe||ne||(Me?e.jsx(Kr,{componentName:"AreaChart",message:Me,width:G,height:q}):e.jsx(ws,{componentName:"AreaChart",width:G,height:q,children:e.jsx(Lo,Object.assign({ref:r},_e))}))});function $s({isPushMode:e,colorBy:o,colorScheme:n,showLegend:i,legendPosition:r="right"}){const s=t.useRef(new Set),a=t.useRef([]),[l,c]=t.useState(0),u=t.useCallback(e=>{if(!o)return null;const t="function"==typeof o?o(e):e[o];return null!=t?t+"":null},[o]),d=t.useCallback(t=>{if(!e||!o)return;let n=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=u(e);null==t||s.current.has(t)||(s.current.add(t),a.current.push(t),n=!0)}n&&c(e=>e+1)},[e,o,u]),h=t.useCallback(e=>t=>{d([t]),e(t)},[d]),g=t.useCallback(e=>t=>{d(t),e(t)},[d]),f=t.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),p=t.useMemo(()=>{if(!e||!o||!1===i)return;const t=a.current;if(0===t.length)return;const r=Array.isArray(n)?n:F,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],r[e%r.length]);const l="string"==typeof o?o:"__streamCat";return Cr({data:t.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:Y})},[e,o,i,n,l]),y=t.useMemo(()=>{if(p)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[p,r]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}Ns.displayName="AreaChart";const Ws=t.forwardRef(function(o,n){var i;const r=t.useRef(null),s=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",areaBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:v,curve:m="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:j=3,normalize:A=!1,tooltip:S,annotations:O,frameProps:M={},selection:C,linkedHover:_,onObservation:P,onClick:L,hoverHighlight:T,chartId:R,loading:B,emptyContent:I,legendInteraction:D,legendPosition:H,color:N,stroke:$,strokeWidth:W,opacity:F}=o,E=s.width,z=s.height,G=s.enableHover,q=s.showGrid,X=s.showLegend,V=s.title,U=s.description,K=s.summary,Q=s.accessibleTable,Z=s.xLabel,J=s.yLabel,ee=Os(B,E,z),te=ee?null:Ss(a,E,z,I),oe=a||[],ne=$s({isPushMode:void 0===a,colorBy:y||f,colorScheme:v,showLegend:X,legendPosition:H}),ie=t.useCallback(ne.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ne.wrapPush]),re=t.useCallback(ne.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ne.wrapPushMany]);t.useImperativeHandle(n,()=>({push:ie,pushMany:re,remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;ne.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[ie,re,ne.resetCategories]);const{activeSelectionHook:se,hoverSelectionHook:ae,customHoverBehavior:le,customClickBehavior:ce,crosshairSourceId:ue}=Er({selection:C,linkedHover:_,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:L,chartType:"StackedAreaChart",chartId:R,hoverHighlight:T,colorByField:"string"==typeof y?y:void 0}),de=Cs(C),he=zr(_,ue),ge=void 0!==(null===(i=oe[0])||void 0===i?void 0:i[p]),fe=t.useMemo(()=>{if(ge)return oe;if(f){const e=oe.reduce((e,t)=>{const o="function"==typeof f?f(t):t[f];if(!e[o]){const t={[p]:[]};"string"==typeof f&&(t[f]=o),e[o]=t}return e[o][p].push(t),e},{});return Object.values(e)}return[{[p]:oe}]},[oe,f,p,ge]),pe=Wr(oe,y,v),ye=t.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of oe){const o="function"==typeof y?y(t):t[y];null!=o&&e.add(o+"")}return Array.from(e)},[oe,y]),ve=Gr(D,y,ye),me=t.useMemo(()=>ae||(ve.legendSelectionHook?ve.legendSelectionHook:se),[ae,ve.legendSelectionHook,se]),be=t.useMemo(()=>e=>{const t={};if(y&&pe){const o=Y(e,y,pe);t.fill=o,x?(t.stroke=o,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=N||Hr;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,pe,b,x,k,N]),xe=t.useMemo(()=>Ur(be,{stroke:$,strokeWidth:W,opacity:F}),[be,$,W,F]),ke=t.useMemo(()=>Pr(xe,me,de),[xe,me,de]),we=t.useMemo(()=>{if(w)return e=>{const t={r:j,fillOpacity:1};return y?pe&&(t.fill=Y(e.parentLine||e,y,pe)):t.fill=N||Hr,t}},[w,j,y,pe,N]),{legend:je,margin:Ae,legendPosition:Se}=Yr({data:fe,colorBy:y,colorScale:pe,showLegend:X,legendPosition:H,userMargin:l,defaults:s.marginDefaults}),Oe=ne.streamingLegend||je,Me=H||Se,Ce=t.useMemo(()=>{if(ne.streamingMarginAdjust){const e=Object.assign({},Ae);for(const[t,o]of Object.entries(ne.streamingMarginAdjust))o>e[t]&&(e[t]=o);return e}return Ae},[Ae,ne.streamingMarginAdjust]),_e=f||y,Pe=t.useMemo(()=>lr([{label:Z||ir(h),accessor:h,role:"x",format:u},{label:J||ir(g),accessor:g,role:"y",format:d},..._e?[{label:ir(_e),accessor:_e,role:"group"}]:[]]),[h,g,Z,J,_e,u,d]),Le=os({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:h,yAccessor:g}}),Te=t.useMemo(()=>ge||f?fe.flatMap(e=>{const t=e[p]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):oe,[fe,p,ge,f,oe]),Re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=a&&{data:Te}),{xAccessor:h,yAccessor:g,groupAccessor:f||void 0,curve:m,normalize:A,lineStyle:ke}),w&&we&&{pointStyle:we}),{size:[E,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Ce,showAxes:s.showAxes,xLabel:Z,yLabel:J,xFormat:u,yFormat:d,enableHover:G}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:q}),Oe&&{legend:Oe,legendPosition:Me}),D&&"none"!==D&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),V&&{title:V}),U&&{description:U}),K&&{summary:K}),void 0!==Q&&{accessibleTable:Q}),c&&{className:c}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===S?()=>null:nr(S)||Pe}),(_||P||L||T)&&{customHoverBehavior:le}),(P||L||_)&&{customClickBehavior:ce}),O&&O.length>0&&{annotations:O}),he),M);return ee||te||(Le?e.jsx(Kr,{componentName:"StackedAreaChart",message:Le,width:E,height:z}):e.jsx(ws,{componentName:"StackedAreaChart",width:E,height:z,children:e.jsx(Lo,Object.assign({ref:r},Re))}))});Ws.displayName="StackedAreaChart";const Fs=t.forwardRef(function(o,n){var r;const a=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=a.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=a.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const l=Xr(o.mode,{width:o.width,height:o.height,showGrid:void 0,enableHover:o.enableHover,showLegend:void 0,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:c,margin:u,className:d,xAccessor:h="x",yAccessor:g="y",valueAccessor:f="value",xFormat:p,yFormat:y,colorScheme:v,customColorScale:m,showValues:b=!1,valueFormat:x,tooltip:k,annotations:w,frameProps:j={},selection:A,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,emptyContent:L,showLegend:T,legendPosition:R,legendInteraction:B}=o,I=l.width,D=l.height,H=l.enableHover,N=l.title,$=l.description,W=l.summary,F=l.accessibleTable,E=l.xLabel,z=l.yLabel,Y=Os(P,I,D),G=Y?null:Ss(c,I,D,L),q=c||[],X=function(){var e;const t=Dr();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),V=null!==(r=null!=v?v:X)&&void 0!==r?r:"blues",U=null!=T&&T,K=null!=R?R:"right",{margin:Q}=Yr({data:q,colorBy:U?"value":void 0,colorScale:void 0,showLegend:U,legendPosition:K,userMargin:u,defaults:l.marginDefaults}),{customHoverBehavior:Z,customClickBehavior:J,crosshairSourceId:ee}=Er({selection:A,linkedHover:S,fallbackFields:[],onObservation:O,onClick:M,chartType:"Heatmap",chartId:_,hoverHighlight:C,colorByField:void 0});Cs(A);const te=zr(S,ee);Gr(B,void 0,[]);const oe=t.useMemo(()=>"function"==typeof f?e=>f(e):e=>e[f],[f]),ne=t.useMemo(()=>{const e=q.map(oe);return[Math.min(...e),Math.max(...e)]},[q,oe]),ie=t.useMemo(()=>"custom"===V&&m?m:i.scaleSequential({blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo}[V]||s.interpolateBlues).domain(ne),[V,m,ne]),re=t.useMemo(()=>lr([{label:E||ir(h),accessor:h,role:"x",format:p},{label:z||ir(g),accessor:g,role:"y",format:y},{label:ir(f),accessor:f,role:"value",format:x}]),[h,g,E,z,f,p,y,x]),se=os({componentName:"Heatmap",data:c,accessors:{xAccessor:h,yAccessor:g,valueAccessor:f}}),ae=t.useMemo(()=>{if(U)return{gradient:{colorFn:e=>ie(e),domain:ne,label:"string"==typeof f?f:"value",format:x}}},[U,ie,ne,f,x]),le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=c&&{data:q}),{xAccessor:h,yAccessor:g,valueAccessor:f,colorScheme:"custom"!==V?V:void 0,showValues:b,heatmapValueFormat:x,size:[I,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Q,showAxes:l.showAxes,xLabel:E,yLabel:z,xFormat:p,yFormat:y,enableHover:H}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),ae&&{legend:ae,legendPosition:K}),N&&{title:N}),$&&{description:$}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),d&&{className:d}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===k?()=>null:nr(k)||re}),(S||O||M||C)&&{customHoverBehavior:Z}),(O||M||S)&&{customClickBehavior:J}),w&&w.length>0&&{annotations:w}),te),j);return Y||G||(se?e.jsx(Kr,{componentName:"Heatmap",message:se,width:I,height:D}):e.jsx(ws,{componentName:"Heatmap",width:I,height:D,children:e.jsx(Lo,Object.assign({ref:a},le))}))});Fs.displayName="Heatmap";const Es=t.forwardRef(function(o,n){const i=t.useRef(null),r=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:v=.6,bubbleStrokeWidth:m=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:j,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,emptyContent:R,legendInteraction:B,legendPosition:I,color:D,stroke:H,strokeWidth:N,opacity:$}=o,W=r.width,F=r.height,E=r.enableHover,z=r.showGrid,G=r.showLegend,X=r.title,V=r.description,U=r.summary,K=r.accessibleTable,Q=r.xLabel,Z=r.yLabel,J=Os(T,W,F),ee=J?null:Ss(s,W,F,R),te=s||[],oe=void 0===s,ne=t.useRef(null),[ie,re]=t.useState(0),se=t.useCallback(e=>{if(!oe)return;let t=!1;for(const o of e){const e="function"==typeof g?g(o):o[g];null!=e&&isFinite(e)&&(ne.current?(ne.current[0]>e&&(ne.current[0]=e,t=!0),e>ne.current[1]&&(ne.current[1]=e,t=!0)):(ne.current=[e,e],t=!0))}t&&re(e=>e+1)},[oe,g]),ae=$s({isPushMode:oe,colorBy:p,colorScheme:y,showLegend:G,legendPosition:I}),le=t.useCallback(ae.wrapPush(e=>{var t;se([e]),null===(t=i.current)||void 0===t||t.push(e)}),[ae.wrapPush,se]),ce=t.useCallback(ae.wrapPushMany(e=>{var t;se(e),null===(t=i.current)||void 0===t||t.pushMany(e)}),[ae.wrapPushMany,se]);t.useImperativeHandle(n,()=>({push:le,pushMany:ce,remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;ae.resetCategories(),ne.current=null,re(e=>e+1),null===(e=i.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[le,ce,ae.resetCategories]);const{activeSelectionHook:ue,hoverSelectionHook:de,customHoverBehavior:he,customClickBehavior:ge,crosshairSourceId:fe}=Er({selection:S,linkedHover:O,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,onClick:_,chartType:"BubbleChart",chartId:L,hoverHighlight:P,colorByField:"string"==typeof p?p:void 0}),pe=Cs(S),ye=zr(O,fe),ve=_r(M);wr({name:(null==ve?void 0:ve.name)||"__unused_brush__",xField:(null==ve?void 0:ve.xField)||("string"==typeof d?d:void 0),yField:(null==ve?void 0:ve.yField)||("string"==typeof h?h:void 0)});const me=Wr(te,p,y),be=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of te){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[te,p]),xe=Gr(B,p,be),ke=t.useMemo(()=>de||(xe.legendSelectionHook?xe.legendSelectionHook:ue),[de,xe.legendSelectionHook,ue]),we=t.useMemo(()=>{if(oe)return ne.current||[0,1];const e=te.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[te,g,oe,ie]),je=t.useMemo(()=>e=>{const t={fillOpacity:v,strokeWidth:m,stroke:b};return p?me&&(t.fill=Y(e,p,me)):t.fill=D||Hr,t.r=q(e,g,f,we),t},[p,me,g,f,we,v,m,b,D]),Ae=t.useMemo(()=>Ur(je,{stroke:H,strokeWidth:N,opacity:$}),[je,H,N,$]),Se=t.useMemo(()=>Pr(Ae,ke,pe),[Ae,ke,pe]),{legend:Oe,margin:Me,legendPosition:Ce}=Yr({data:te,colorBy:p,colorScale:me,showLegend:G,legendPosition:I,userMargin:a,defaults:r.marginDefaults}),_e=ae.streamingLegend||Oe,Pe=I||Ce,Le=t.useMemo(()=>{if(ae.streamingMarginAdjust){const e=Object.assign({},Me);for(const[t,o]of Object.entries(ae.streamingMarginAdjust))o>e[t]&&(e[t]=o);return e}return Me},[Me,ae.streamingMarginAdjust]),Te=t.useMemo(()=>lr([{label:Q||ir(d),accessor:d,role:"x",format:c},{label:Z||ir(h),accessor:h,role:"y",format:u},{label:ir(g),accessor:g,role:"size"},...p?[{label:ir(p),accessor:p,role:"color"}]:[]]),[d,h,Q,Z,g,p,c,u]),Re=os({componentName:"BubbleChart",data:s,accessors:{xAccessor:d,yAccessor:h},requiredProps:{sizeBy:g}});if(Re)return e.jsx(Kr,{componentName:"BubbleChart",message:Re,width:W,height:F});const Be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=s&&{data:te}),{xAccessor:d,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:Se,colorScheme:y,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Le,showAxes:r.showAxes,xLabel:Q,yLabel:Z,xFormat:c,yFormat:u,enableHover:E,showGrid:z}),_e&&{legend:_e,legendPosition:Pe}),B&&"none"!==B&&{legendHoverBehavior:xe.onLegendHover,legendClickBehavior:xe.onLegendClick,legendHighlightedCategory:xe.highlightedCategory,legendIsolatedCategories:xe.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:nr(x)||Te}),(O||C||_||P)&&{customHoverBehavior:he}),(C||_||O)&&{customClickBehavior:ge}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),j&&j.length>0&&{annotations:j}),ye),A);return J||ee||e.jsx(ws,{componentName:"BubbleChart",width:W,height:F,children:e.jsx(Lo,Object.assign({ref:i},Be))})});Es.displayName="BubbleChart";const zs="__splomIdx",Ys={top:4,bottom:4,left:4,right:4};function Gs({frameRef:i,cellSize:r,onBrush:s}){const a=t.useRef(null),l=r-Ys.left-Ys.right,c=r-Ys.top-Ys.bottom;return t.useEffect(()=>{if(!a.current)return;const e=o.select(a.current).select(".brush-g"),t=n.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const o=null===(t=i.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void s(null);const[[n,r],[a,l]]=e.selection,c=[[o.x.invert(n),o.y.invert(r)],[o.x.invert(a),o.y.invert(l)]];s(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[l,c,i,s]),e.jsx("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0},children:e.jsx("g",{className:"brush-g",transform:`translate(${Ys.left},${Ys.top})`})})}function qs({data:o,xField:n,yField:i,cellSize:r,pointRadius:s,pointOpacity:a,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:h,mode:g,onPointHover:f}){const p=t.useRef(null),y=xr({name:u,clientId:`splom-${n}-${i}`}),v=wr({name:u,xField:n,yField:i}),m=xr({name:d,clientId:"splom-hover-source"}),b=m.selectPoints,x=t.useCallback(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=t.useCallback(e=>{if(!e)return void(null==f||f(null));const t=e.data,o=null==t?void 0:t[zs];void 0!==o&&(b({[zs]:[o]}),null==f||f(t,e.x+Ys.left,e.y+Ys.top))},[b,f]),w=t.useCallback(e=>{const t={opacity:a,r:s};return t.fill=l?Y(e,l,c):Hr,"hover"===g?m.isActive&&m.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):m.isActive&&(t.opacity=.6*a):y.isActive&&!y.predicate(e)&&(t.opacity=h),t},[l,c,a,s,g,y.isActive,y.predicate,m.isActive,m.predicate,h]);return e.jsxs("div",{style:{position:"relative",width:r,height:r},children:[e.jsx(Lo,{ref:p,chartType:"scatter",data:o,size:[r,r],xAccessor:n,yAccessor:i,pointStyle:w,margin:Ys,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&e.jsx(Gs,{frameRef:p,cellSize:r,xField:n,yField:i,onBrush:x})]})}function Xs({data:o,field:n,label:i,cellSize:r,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=xr({name:c,clientId:"splom-diag-"+n}),g=xr({name:u,clientId:`splom-diag-${n}-hover`}),f="hover"===d?g:h,p=f.isActive,y=f.predicate,v=t.useMemo(()=>{const e=o.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const t=Math.min(...e),i=(Math.max(...e)-t)/s||1,l="string"==typeof a?a:null,c=l?[...new Set(o.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(s).fill(0),h=Array(s).fill(0),g=Array.from({length:s},()=>Array(c.length).fill(0)),f=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of o){const o=e[n];if(null==o||isNaN(o))continue;const r=Math.min(Math.floor((o-t)/i),s-1);if(d[r]++,p&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,p&&!y(e)||f[r][t]++)}}const v=Math.max(...d,1),m=g.map((e,t)=>{let o=0;return e.map((e,n)=>{const i=e/v*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=i,a})}),b=f.map((e,t)=>{let o=0;return e.map((e,n)=>{const i=e/v*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=i,a})});return{bars:d.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/v*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/v*(r-24),count:e})),categoryBars:m,selectedCategoryBars:b,max:v,categories:c}},[o,n,s,r,p,y,a]);return e.jsxs("svg",{width:r,height:r,style:{overflow:"hidden"},children:[e.jsx("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:i}),v.categories.length>0?v.categoryBars.map((t,o)=>t.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Hr,opacity:p?.3:.6},`bg-${o}-${n}`))):v.bars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Hr,opacity:p?.3:.6},"bg-"+o)),p&&(v.categories.length>0?v.selectedCategoryBars.map((t,o)=>t.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Hr,opacity:.7},`sel-${o}-${n}`))):v.selectedBars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Hr,opacity:.7},"sel-"+o)))]})}function Vs({label:t,cellSize:o}){return e.jsx("svg",{width:o,height:o,children:e.jsx("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:t})})}function Us(o){const{data:n,fields:i,fieldLabels:r={},colorBy:s,colorScheme:a,cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:d=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:p=!0,unselectedOpacity:v=.1,showGrid:m=!1,tooltip:b,showLegend:x,idAccessor:k,className:w,onObservation:j,chartId:A}=o,S="splom",O="splom-hover",M=p?"hover":f?"brush":"hover",C=vr(e=>e.clearSelection),[_,P]=t.useState(null),L=t.useCallback(()=>{C(O),P(null)},[C,O]),T=t.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[zs]?e:Object.assign(Object.assign({},e),{[zs]:t})),[n]),R=Wr(T,s,a),B=void 0!==x?x:!!s,I=t.useMemo(()=>{if(!B||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(T.map(t=>t[e]))].map(e=>({label:e+"",color:R?R(e+""):Hr})):null},[B,s,T,R]),D=t.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+i.map(()=>l+"px").join(" "),gridTemplateRows:i.map(()=>l+"px").join(" ")+" 40px",gap:c+"px",width:"fit-content"}),[i,l,c,40]);return e.jsxs("div",{className:w,style:{position:"relative"},children:[I&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:I.map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.jsx("span",{style:{fontSize:11},children:t.label})]},t.label))}),e.jsxs("div",{style:D,onMouseLeave:"hover"===M?L:void 0,children:[i.map((t,o)=>e.jsxs(y.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t}),i.map((n,i)=>o===i?"label"===h?e.jsx(Vs,{label:r[t]||t,cellSize:l},"diag-"+t):e.jsx(Xs,{data:T,field:t,label:r[t]||t,cellSize:l,bins:g,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:v,mode:M},"diag-"+t):e.jsx(qs,{data:T,xField:n,yField:t,fieldLabels:r,cellSize:l,pointRadius:u,pointOpacity:d,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:v,showGrid:m,tooltip:b,mode:M,onPointHover:"hover"===M?(e,r,s)=>{e?(P({datum:e,xField:n,yField:t,colIndex:i,rowIndex:o,px:null!=r?r:0,py:null!=s?s:0}),j&&j({type:"hover",datum:e,x:null!=r?r:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(P(null),j&&j({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0},`cell-${t}-${n}`))]},"row-"+t)),e.jsx("div",{})," ",i.map(t=>e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t},"col-label-"+t))]}),_&&"hover"===M&&(()=>{const t=_.datum,o=r[_.xField]||_.xField,n=r[_.yField]||_.yField,i=s?"function"==typeof s?s(t):t[s]:null,a=k?"function"==typeof k?k(t):t[k]:"Row "+t[zs];return e.jsxs("div",{style:{position:"absolute",left:40+_.colIndex*(l+c)+_.px,top:_.rowIndex*(l+c)+_.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10},children:[e.jsx("div",{style:{fontWeight:"bold",marginBottom:2},children:a+""}),e.jsxs("div",{children:[o,": ",null!=t[_.xField]?Number(t[_.xField]).toFixed(1):"–"]}),e.jsxs("div",{children:[n,": ",null!=t[_.yField]?Number(t[_.yField]).toFixed(1):"–"]}),null!=i&&e.jsxs("div",{style:{opacity:.8},children:["string"==typeof s?s:"group",": ",i+""]})]})})()]})}function Ks(t){const{brushMode:o="crossfilter",hoverMode:n=!0}=t,i={};return!n&&o&&(i.splom={resolution:o}),n&&(i["splom-hover"]={resolution:"union"}),e.jsx(Mr,{selections:i,children:e.jsx(Us,Object.assign({},t))})}function Qs({width:i,height:r,margin:s,scales:a,brushDirection:l,extent:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(!1),f=i+s.left+s.right,p=r+s.top+s.bottom;return t.useEffect(()=>{if(!d.current||!a)return;const e=o.select(d.current).select(".brush-group"),t="x"===l?n.brushX().extent([[0,0],[i,r]]):n.brushY().extent([[0,0],[i,r]]);return t.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void u(null);const o=("x"===l?a.x:a.y).invert;if(!o)return;const n=[o(t[0]),o(t[1])];u(n)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,i,r,l,u]),t.useEffect(()=>{if(!h.current||!a||!d.current)return;const e=o.select(d.current).select(".brush-group"),t="x"===l?a.x:a.y;if(g.current=!0,c){const o=[t(c[0]),t(c[1])];e.call(h.current.move,o)}else e.call(h.current.move,null);g.current=!1},[c,a,l]),e.jsx("svg",{ref:d,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`})})}function Zs(o){var n,i;const{data:r,width:s=600,height:a=400,margin:l,className:c,title:u,description:d,summary:h,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:v="x",yAccessor:m="y",lineBy:b,lineDataAccessor:x="coordinates",colorBy:k,colorScheme:w,curve:j="linear",lineWidth:A=2,fillArea:S=!1,areaOpacity:O=.3,showPoints:M=!1,pointRadius:C=3,enableHover:_=!0,showGrid:P=!1,showLegend:L,legendPosition:T,tooltip:R,minimap:B={},renderBefore:I=!1,onBrush:D,brushExtent:H,frameProps:N={},loading:$,emptyContent:W}=o,F=Os($,s,a),E=F?null:Ss(r,s,a,W),z=r||[],[G,q]=t.useState(null),X=null!=H?H:G,V=t.useCallback(e=>{H||q(e),null==D||D(e)},[H,D]),U=t.useRef(null),[K,Q]=t.useState(null);t.useEffect(()=>{let e=0,t=!1;const o=()=>{var n,i;if(t)return;const r=null===(i=null===(n=U.current)||void 0===n?void 0:n.getScales)||void 0===i?void 0:i.call(n);r?Q(r):e=requestAnimationFrame(o)};return e=requestAnimationFrame(o),()=>{t=!0,e&&cancelAnimationFrame(e)}},[r]);const Z=void 0!==(null===(n=z[0])||void 0===n?void 0:n[x]),J=t.useMemo(()=>{if(Z)return z;if(b){const e=z.reduce((e,t)=>{const o="function"==typeof b?b(t):t[b];if(!e[o]){const t={[x]:[]};"string"==typeof b&&(t[b]=o),e[o]=t}return e[o][x].push(t),e},{});return Object.values(e)}return[{[x]:z}]},[z,b,x,Z]),ee=t.useMemo(()=>Z||b?J.flatMap(e=>{const t=e[x]||[];return b&&"string"==typeof b?t.map(t=>Object.assign(Object.assign({},t),{[b]:e[b]})):t}):z,[J,x,Z,b,z]),te=Wr(z,k,w),oe=t.useMemo(()=>e=>{const t={strokeWidth:A};return t.stroke=k?Y(e,k,te):Hr,S&&(t.fill=t.stroke,t.fillOpacity=O),t},[k,te,A,S,O]),ne=t.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=k?Y(e,k,te):Hr,t},[k,te,B.lineStyle]),ie=t.useMemo(()=>{if(M)return e=>{const t={r:C,fillOpacity:1};return t.fill=k?Y(e.parentLine||e,k,te):Hr,t}},[M,C,k,te]),{legend:re,margin:se,legendPosition:ae}=Yr({data:J,colorBy:k,colorScale:te,showLegend:L,legendPosition:T,userMargin:l}),le=B.height||60,ce=t.useMemo(()=>{var e,t,o,n,i,r,s,a;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(n=null===(o=B.margin)||void 0===o?void 0:o.bottom)&&void 0!==n?n:20,left:null!==(r=null===(i=B.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:se.left,right:null!==(a=null===(s=B.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:se.right}},[B.margin,se]),ue=B.brushDirection||"x",de=os({componentName:"MinimapChart",data:r,accessors:{xAccessor:v,yAccessor:m}});if(de)return e.jsx(Kr,{componentName:"MinimapChart",message:de,width:s,height:a});const he=S?"area":"line",ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:he,data:ee,xAccessor:v,yAccessor:m,groupAccessor:b||void 0,curve:j,lineStyle:oe},M&&{pointStyle:ie}),{size:[s,a],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:se,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:_,showGrid:P}),re&&{legend:re,legendPosition:ae}),u&&{title:u}),d&&{description:d}),h&&{summary:h}),R&&{tooltipContent:nr(R)||void 0}),X&&{xExtent:X}),N),fe={chartType:he,data:ee,xAccessor:v,yAccessor:m,groupAccessor:b||void 0,curve:j,lineStyle:ne,size:[s,le+ce.top+ce.bottom],margin:ce,showAxes:null!==(i=B.showAxes)&&void 0!==i&&i,background:B.background,enableHover:!1},pe=e.jsxs("div",{style:{position:"relative",width:s,overflow:"hidden"},children:[e.jsx(Lo,Object.assign({ref:U},fe)),e.jsx(Qs,{width:s-ce.left-ce.right,height:le,margin:ce,scales:K,brushDirection:ue,extent:X,onBrush:V})]},"minimap"),ye=e.jsx("div",{style:{overflow:"hidden"},children:e.jsx(Lo,Object.assign({},ge))},"main");return F||E||e.jsx(ws,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[I?pe:ye,I?ye:pe]})})}Ks.displayName="ScatterplotMatrix",Zs.displayName="MinimapChart";const Js=t.forwardRef(function(o,n){const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:v=!0,quadrantLabelSize:m=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:j=5,pointOpacity:A=.8,tooltip:S,pointIdAccessor:O,annotations:M,frameProps:C={},selection:_,linkedHover:P,onObservation:L,onClick:T,hoverHighlight:R,chartId:B,loading:I,emptyContent:D,legendInteraction:H,legendPosition:N,color:$,stroke:W,strokeWidth:F,opacity:E}=o,z=r.width,G=r.height,X=r.enableHover,V=r.showGrid,U=r.showLegend,K=r.title,Q=r.description,Z=r.summary,J=r.accessibleTable,ee=r.xLabel,te=r.yLabel,oe=Os(I,z,G),ne=oe?null:Ss(s,z,G,D),ie=s||[];Ms("QuadrantChart",ie,"xAccessor",d),Ms("QuadrantChart",ie,"yAccessor",h);const{activeSelectionHook:re,hoverSelectionHook:se,customHoverBehavior:ae,customClickBehavior:le,crosshairSourceId:ce}=Er({selection:_,linkedHover:P,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:T,chartType:"QuadrantChart",chartId:B,hoverHighlight:R,colorByField:"string"==typeof b?b:void 0}),ue=Cs(_),de=zr(P,ce),he=Wr(ie,b,x),ge=t.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of ie){const o="function"==typeof b?b(t):t[b];null!=o&&e.add(o+"")}return Array.from(e)},[ie,b]),fe=Gr(H,b,ge),pe=t.useMemo(()=>se||(fe.legendSelectionHook?fe.legendSelectionHook:re),[se,fe.legendSelectionHook,re]),ye=t.useMemo(()=>{if(!ie.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let o=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of ie){const a=e(s),l=t(s);isFinite(a)&&(o>a&&(o=a),a>n&&(n=a)),isFinite(l)&&(i>l&&(i=l),l>r&&(r=l))}if(null!=g&&isFinite(g)&&(o>g&&(o=g),g>n&&(n=g)),null!=f&&isFinite(f)&&(i>f&&(i=f),f>r&&(r=f)),o===1/0)return;const s=.1*(n-o)||1,a=.1*(r-i)||1;return{xExtent:[o-s,n+s],yExtent:[i-a,r+a]}},[ie,d,h,g,f]),ve=t.useMemo(()=>{if(!k||0===ie.length)return;const e=ie.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[ie,k]),me=t.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),be=t.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),xe=t.useMemo(()=>e=>{const t={fillOpacity:A};if(b)he&&(t.fill=Y(e,b,he));else{const o=me(e),n=be(e),i=null!=g?o>=g:void 0,r=null!=f?n>=f:void 0;t.fill=void 0===r||void 0===i?$||Hr:r&&i?p.topRight.color:r&&!i?p.topLeft.color:!r&&i?p.bottomRight.color:p.bottomLeft.color}return t.r=k?q(e,k,w,ve):j,t},[b,he,k,w,ve,j,A,me,be,g,f,p,$]),ke=t.useMemo(()=>Ur(xe,{stroke:W,strokeWidth:F,opacity:E}),[xe,W,F,E]),we=t.useMemo(()=>Pr(ke,pe,ue),[ke,pe,ue]),{legend:je,margin:Ae,legendPosition:Se}=Yr({data:ie,colorBy:b,colorScale:he,showLegend:U,legendPosition:N,userMargin:a,defaults:r.marginDefaults}),Oe=t.useMemo(()=>{if(!ie.length)return;const e=new Set;"string"==typeof d&&e.add(d),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=ie[0];for(const o of Object.keys(t))if(!o.startsWith("_")&&!e.has(o)&&"string"==typeof t[o])return o},[ie,d,h,b,k]),Me=t.useMemo(()=>lr([...Oe?[{label:Oe,accessor:Oe,role:"title"}]:[],{label:ee||ir(d),accessor:d,role:"x",format:c},{label:te||ir(h),accessor:h,role:"y",format:u},...b?[{label:ir(b),accessor:b,role:"color"}]:[],...k?[{label:ir(k),accessor:k,role:"size"}]:[]]),[Oe,d,h,ee,te,b,k,c,u]),Ce=os({componentName:"QuadrantChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),_e=t.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,o,n,i)=>{var r;if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const s=i.width,a=i.height,l=null!=g?n.x(g):s/2,c=null!=f?n.y(f):a/2;if(null!=g&&!isFinite(l))return;if(null!=f&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:p.topLeft,x:0,y:0,w:u,h:d},{config:p.topRight,x:u,y:0,w:s-u,h:d},{config:p.bottomLeft,x:0,y:d,w:u,h:a-d},{config:p.bottomRight,x:u,y:d,w:s-u,h:a-d}];for(const t of h)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(r=t.config.opacity)&&void 0!==r?r:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,d),e.lineTo(s,d),e.stroke(),e.setLineDash([])}]},[g,f,p,y]),Pe=t.useMemo(()=>v?[..._e,(e,t,o,n)=>{if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const i=n.width,r=n.height,s=null!=g?o.x(g):i/2,a=null!=f?o.y(f):r/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${m}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,i-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,r-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:_e,[_e,v,m,p,g,f]),Le=t.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...Pe,...e]},[Pe,C.canvasPreRenderers]),Te=t.useMemo(()=>{var t;const o={stroke:y.stroke||"#999",strokeWidth:null!==(t=y.strokeWidth)&&void 0!==t?t:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(t,n,i)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=i.width,s=i.height,a=null!=g?n.x(g):r/2,l=null!=f?n.y(f):s/2;if(null!=g&&!isFinite(a))return null;if(null!=f&&!isFinite(l))return null;const c=Math.max(0,Math.min(r,a)),u=Math.max(0,Math.min(s,l));return e.jsxs(e.Fragment,{children:[[{config:p.topLeft,x:0,y:0,w:c,h:u},{config:p.topRight,x:c,y:0,w:r-c,h:u},{config:p.bottomLeft,x:0,y:u,w:c,h:s-u},{config:p.bottomRight,x:c,y:u,w:r-c,h:s-u}].map((t,o)=>{var n;return t.w>0&&t.h>0?e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.config.color,opacity:null!==(n=t.config.opacity)&&void 0!==n?n:.08},"qf-"+o):null}),e.jsx("line",{x1:c,y1:0,x2:c,y2:s,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),e.jsx("line",{x1:0,y1:u,x2:r,y2:u,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),v&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:8,y:8+m,fill:p.topLeft.color,fontWeight:600,fontSize:m,opacity:.5,children:p.topLeft.label}),e.jsx("text",{x:r-8,y:8+m,fill:p.topRight.color,fontWeight:600,fontSize:m,opacity:.5,textAnchor:"end",children:p.topRight.label}),e.jsx("text",{x:8,y:s-8,fill:p.bottomLeft.color,fontWeight:600,fontSize:m,opacity:.5,children:p.bottomLeft.label}),e.jsx("text",{x:r-8,y:s-8,fill:p.bottomRight.color,fontWeight:600,fontSize:m,opacity:.5,textAnchor:"end",children:p.bottomRight.label})]})]})}]},[g,f,p,y,v,m]),Re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:ie}),{xAccessor:d,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:we,colorScheme:x,size:[z,G],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Ae,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),ye&&{xExtent:ye.xExtent,yExtent:ye.yExtent}),je&&{legend:je,legendPosition:Se}),H&&"none"!==H&&{legendHoverBehavior:fe.onLegendHover,legendClickBehavior:fe.onLegendClick,legendHighlightedCategory:fe.highlightedCategory,legendIsolatedCategories:fe.isolatedCategories}),K&&{title:K}),Q&&{description:Q}),Z&&{summary:Z}),void 0!==J&&{accessibleTable:J}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?Me:nr(S)||Me}),(P||L||T||R)&&{customHoverBehavior:ae}),(L||T||P)&&{customClickBehavior:le}),O&&{pointIdAccessor:O}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:Le}),de),C),Le.length>0&&{canvasPreRenderers:Le}),{svgPreRenderers:Te});return oe||ne||(Ce?e.jsx(Kr,{componentName:"QuadrantChart",message:Ce,width:z,height:G}):e.jsx(ws,{componentName:"QuadrantChart",width:z,height:G,children:e.jsx(Lo,Object.assign({ref:i},Re))}))});Js.displayName="QuadrantChart";const ea="__ma_unitized",ta="__ma_series";function oa(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function na(e,t){return t[0]+e*(t[1]-t[0])}const ia=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null),a=t.useRef([]);t.useImperativeHandle(n,()=>({push:e=>{if(!s.current)return;const t=e;for(let e=0;o.series.length>e&&2>e;e++){const n=o.series[e],i=n.extent||a.current[e];if(!i)continue;const r=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(t);null!=r&&isFinite(r)&&s.current.push(Object.assign(Object.assign({},t),{[ea]:oa(r,i),[ta]:n.label||"Series "+(e+1)}))}},pushMany:e=>{if(!s.current)return;const t=[];for(const n of e)for(let e=0;o.series.length>e&&2>e;e++){const i=o.series[e],r=i.extent||a.current[e];if(!r)continue;const s=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(n);null!=s&&isFinite(s)&&t.push(Object.assign(Object.assign({},n),{[ea]:oa(s,r),[ta]:i.label||"Series "+(e+1)}))}s.current.pushMany(t)},remove:e=>{var t,o;return null!==(o=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=s.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const l=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,accessibleTable:o.accessibleTable},{width:800,height:400}),{data:c,margin:u,className:d,xFormat:h,xAccessor:g="x",series:f,colorScheme:p,curve:v="monotoneX",lineWidth:m=2,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:j,onObservation:A,onClick:S,hoverHighlight:O,chartId:M,loading:C,emptyContent:_,legendInteraction:P,legendPosition:L,stroke:T,strokeWidth:R,opacity:B}=o,I=l.width,D=l.height,H=l.enableHover,N=l.showGrid,F=null===(i=l.showLegend)||void 0===i||i,E=l.title,z=l.description,Y=l.summary,G=l.accessibleTable,q=l.xLabel,X=2===f.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||X||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${f.length}. Rendering as a standard multi-line chart.`);const V=Os(C,I,D),U=V?null:Ss(c,I,D,_),K=c||[],Q=Nr(),Z=t.useMemo(()=>{let e;if(Array.isArray(p))e=p;else if(Q&&Q.length>0)e=Q;else{const t=$[p];e=Array.isArray(t)?t:W}return f.map((t,o)=>t.color||e[o%e.length])},[f,p,Q]),J=t.useMemo(()=>f.map((e,t)=>e.label||"Series "+(t+1)),[f]),{unitizedData:ee,extents:te}=t.useMemo(()=>{if(0===K.length){const e=f.map(e=>e.extent||null).filter(Boolean);return e.length===f.length&&(a.current=e),{unitizedData:[],extents:e.length===f.length?e:[]}}const e=f.map(e=>e.extent||function(e,t){let o=1/0,n=-1/0;const i="function"==typeof t?t:e=>e[t];for(const t of e){const e=i(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>n&&(n=e))}if(!isFinite(o)||!isFinite(n))return[0,1];if(o===n){const e=0===o?1:.1*Math.abs(o);return[o-e,n+e]}return[o,n]}(K,e.yAccessor));if(a.current=e,!X){const t=[];for(const e of K)for(let o=0;f.length>o;o++){const n=f[o],i=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(e);null!=i&&t.push(Object.assign(Object.assign({},e),{[ea]:i,[ta]:J[o]}))}return{unitizedData:t,extents:e}}const t=[];for(const o of K)for(let n=0;2>n;n++){const i=f[n],r=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(o);null!=r&&t.push(Object.assign(Object.assign({},o),{[ea]:oa(r,e[n]),[ta]:J[n]}))}return{unitizedData:t,extents:e}},[K,f,X,J]),oe=t.useMemo(()=>{if(X&&te.length>=2)return[{orient:"left",label:J[0],tickFormat:f[0].format||(e=>{const t=na(e,te[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:J[1],tickFormat:f[1].format||(e=>{const t=na(e,te[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[X,te,f,J]),ne=_s({data:t.useMemo(()=>ee.length>0?ee:J.map(e=>({[ta]:e})),[ee,J]),rawData:c,colorBy:ta,colorScheme:Z,legendInteraction:P,legendPosition:L,selection:w,linkedHover:j,fallbackFields:[ta],unwrapData:!1,onObservation:A,onClick:S,hoverHighlight:O,chartType:"MultiAxisLineChart",chartId:M,showLegend:F,userMargin:u,marginDefaults:X?Object.assign(Object.assign({},l.marginDefaults),{left:70,right:70}):l.marginDefaults,loading:C,emptyContent:_,width:I,height:D});if(ne.earlyReturn)return ne.earlyReturn;const ie=t.useMemo(()=>{const e=new Map;return J.forEach((t,o)=>e.set(t,Z[o])),t=>({stroke:e.get(t[ta])||Z[0],strokeWidth:m,fill:"none"})},[J,Z,m]),re=t.useMemo(()=>Ur(ie,{stroke:T,strokeWidth:R,opacity:B}),[ie,T,R,B]),se=t.useMemo(()=>Pr(re,ne.effectiveSelectionHook,ne.resolvedSelection),[re,ne.effectiveSelectionHook,ne.resolvedSelection]),ae=t.useMemo(()=>{if(!1===b)return()=>null;return nr(b)||(e=>{var t;const o=e.data||e,n=o[ta],i=J.indexOf(n),r=o[ea],s=X&&i>=0&&te[i]?na(r,te[i]):r,a=i>=0&&(null===(t=f[i])||void 0===t?void 0:t.format)?f[i].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(o):o[g];return y.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},y.createElement("div",{style:{fontWeight:600,marginBottom:4,color:Z[i]||"inherit"}},n),y.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),y.createElement("div",null,`${n}: ${a(s)}`))})},[b,J,Z,te,X,f,g]),le=os({componentName:"MultiAxisLineChart",data:c,accessors:{xAccessor:g}}),ce=X?[0,1]:void 0,ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=c&&{data:ee}),{xAccessor:g,yAccessor:ea,groupAccessor:ta,lineStyle:se,colorScheme:Z,size:[I,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne.margin,showAxes:l.showAxes}),oe&&{axes:oe}),{xLabel:q}),X?{}:{yLabel:J[0]}),{xFormat:h}),X&&ce&&{yExtent:ce}),{enableHover:H}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:N,curve:v}),ne.legendBehaviorProps),E&&{title:E}),z&&{description:z}),Y&&{summary:Y}),void 0!==G&&{accessibleTable:G}),d&&{className:d}),null!=o.animate&&{animate:o.animate}),{tooltipContent:ae}),x&&{annotations:x}),(j||A||S||O)&&{customHoverBehavior:ne.customHoverBehavior}),(A||S||j)&&{customClickBehavior:ne.customClickBehavior}),ne.crosshairProps),k);return V||U||(le?e.jsx(Kr,{componentName:"MultiAxisLineChart",message:le,width:I,height:D}):e.jsx(ws,{componentName:"MultiAxisLineChart",width:I,height:D,children:e.jsx(Lo,Object.assign({ref:s},ue))}))});ia.displayName="MultiAxisLineChart";const ra=t.forwardRef(function(o,n){const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",highAccessor:h="high",lowAccessor:g="low",openAccessor:f,closeAccessor:p,candlestickStyle:y,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,chartId:A,loading:S,emptyContent:O}=o,M=r.width,C=r.height,_=r.enableHover,P=r.showGrid,L=r.title,T=r.description,R=r.summary,B=r.accessibleTable,I=r.xLabel,D=r.yLabel,H=Os(S,M,C),N=H?null:Ss(s,M,C,O),$=s||[],W=null==f||null==p;Ms("CandlestickChart",$,"xAccessor",d),Ms("CandlestickChart",$,"highAccessor",h),Ms("CandlestickChart",$,"lowAccessor",g),W||(Ms("CandlestickChart",$,"openAccessor",f),Ms("CandlestickChart",$,"closeAccessor",p));const{customHoverBehavior:F,customClickBehavior:E,crosshairSourceId:z}=Er({selection:x,linkedHover:k,onObservation:w,onClick:j,chartType:"CandlestickChart",chartId:A}),Y=zr(k,z),G=t.useMemo(()=>{const e=r.marginDefaults,t="sparkline"===o.mode?Object.assign(Object.assign({},e),{top:0,bottom:0}):e;return null==a?t:"number"==typeof a?{top:a,bottom:a,left:a,right:a}:Object.assign(Object.assign({},t),a)},[a,r.marginDefaults,o.mode]),q=t.useMemo(()=>{const e=[{label:I||ir(d),accessor:d,role:"x",format:c}];return W?(e.push({label:"High",accessor:h,role:"y",format:u}),e.push({label:"Low",accessor:g,format:u})):(e.push({label:"Open",accessor:f,format:u}),e.push({label:"High",accessor:h,format:u}),e.push({label:"Low",accessor:g,format:u}),e.push({label:"Close",accessor:p,format:u})),lr(e)},[d,I,c,u,h,g,f,p,W]),X=os({componentName:"CandlestickChart",data:s,accessors:Object.assign({xAccessor:d,highAccessor:h,lowAccessor:g},!W&&{openAccessor:f,closeAccessor:p})}),V=Math.max(2,Math.min(12,Math.round(M/40))),U=M>200?.1:.02,K=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"candlestick"},null!=s&&{data:$}),{xAccessor:d,yAccessor:h,highAccessor:h,lowAccessor:g}),!W&&{openAccessor:f,closeAccessor:p}),y&&{candlestickStyle:y}),{scalePadding:V,extentPadding:U,size:[M,C],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:I,yLabel:D,xFormat:c,yFormat:u,enableHover:_,showGrid:P}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),L&&{title:L}),T&&{description:T}),R&&{summary:R}),void 0!==B&&{accessibleTable:B}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:nr(v)||q}),(k||w||j)&&{customHoverBehavior:F}),(w||j||k)&&{customClickBehavior:E}),m&&m.length>0&&{annotations:m}),Y),b);return H||N||(X?e.jsx(Kr,{componentName:"CandlestickChart",message:X,width:M,height:C}):e.jsx(ws,{componentName:"CandlestickChart",width:M,height:C,children:e.jsx(Lo,Object.assign({ref:i},K))}))});ra.displayName="CandlestickChart";const sa=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sort:p=!1,barPadding:y=40,roundedTop:v,gradientFill:m=!1,baselinePadding:b=!1,tooltip:x,annotations:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,showCategoryTicks:H,categoryFormat:N,dataIdAccessor:$}=o,W=i.width,F=i.height,E=i.enableHover,z=i.showGrid,G=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.categoryLabel,K=i.valueLabel,Q=s||[],Z=_s({data:Q,rawData:s,colorBy:g,colorScheme:f,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"BarChart",chartId:C,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:W,height:F});if(Z.earlyReturn)return Z.earlyReturn;Ms("BarChart",Q,"categoryAccessor",c),Ms("BarChart",Q,"valueAccessor",u);const J=Fr(Q,p,u),ee=Nr(),te=t.useMemo(()=>new Map,[Q]),oe=t.useMemo(()=>(e,t)=>{const o={};return o.fill=g?Y(e,g,Z.colorScale):$r(R,ee,f,void 0,te),o},[g,Z.colorScale,R,ee,f,te]),ne=t.useMemo(()=>{const e=null==w?void 0:w.pieceStyle;return Ur(e&&"function"==typeof e?(t,o)=>Object.assign(Object.assign({},oe(t,o)),e(t,o)||{}):oe,{stroke:B,strokeWidth:I,opacity:D})},[oe,w,B,I,D]),ie=t.useMemo(()=>Pr(ne,Z.effectiveSelectionHook,Z.resolvedSelection),[ne,Z.effectiveSelectionHook,Z.resolvedSelection]),re=t.useMemo(()=>cr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",valueFormat:h}),[c,u,g,h]),se=os({componentName:"BarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(se)return e.jsx(Kr,{componentName:"BarChart",message:se,width:W,height:F});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=s&&{data:J}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ie,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z.margin,barPadding:y}),null!=v&&{roundedTop:v}),m&&{gradientFill:!0===m?{topOpacity:.8,bottomOpacity:.05}:m}),$&&{dataIdAccessor:$}),{baselinePadding:b,enableHover:E,showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:h}),N&&{oFormat:N}),{showGrid:z,showCategoryTicks:H,oSort:p}),Z.legendBehaviorProps),G&&{title:G}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:nr(x)||re}),(A||S||O||M)&&{customHoverBehavior:Z.customHoverBehavior}),(S||O||A)&&{customClickBehavior:Z.customClickBehavior}),k&&k.length>0&&{annotations:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"BarChart",width:W,height:F,children:e.jsx(dn,Object.assign({ref:r},ae))})});function aa({ref:e,frameRef:o,isPushMode:n,colorBy:i,colorScheme:r,showLegend:s,legendPosition:a,setup:l}){const c=$s({isPushMode:n,colorBy:i,colorScheme:r,showLegend:s,legendPosition:a}),u=t.useCallback(c.wrapPush(e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)}),[c.wrapPush]),d=t.useCallback(c.wrapPushMany(e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)}),[c.wrapPushMany]);return t.useImperativeHandle(e,()=>({push:u,pushMany:d,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,i;return null!==(i=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[]},clear:()=>{var e;c.resetCategories(),null===(e=o.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[u,d,c.resetCategories]),{effectiveLegendProps:t.useMemo(()=>c.streamingLegend?Object.assign(Object.assign({},l.legendBehaviorProps),{legend:c.streamingLegend,legendPosition:a||l.legendPosition}):l.legendBehaviorProps,[l.legendBehaviorProps,l.legendPosition,c.streamingLegend,a]),effectiveMargin:t.useMemo(()=>{if(c.streamingMarginAdjust){const e=Object.assign({},l.margin);for(const[t,o]of Object.entries(c.streamingMarginAdjust))o>e[t]&&(e[t]=o);return e}return l.margin},[l.margin,c.streamingMarginAdjust])}}sa.displayName="BarChart";const la=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",stackBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,normalize:y=!1,sort:v=!1,barPadding:m=40,roundedTop:b,baselinePadding:x=!1,tooltip:k,annotations:w,frameProps:j={},selection:A,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,emptyContent:L,legendInteraction:T,legendPosition:R,color:B,stroke:I,strokeWidth:D,opacity:H,categoryFormat:N}=o,$=i.width,W=i.height,F=i.enableHover,E=i.showGrid,z=i.showLegend,G=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.categoryLabel,K=i.valueLabel,Q=s||[],Z=f||u,J=void 0===s,ee=_s({data:Q,rawData:s,colorBy:Z,colorScheme:p,legendInteraction:T,legendPosition:R,selection:A,linkedHover:S,fallbackFields:Z?["string"==typeof Z?Z:""]:[],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:C,chartType:"StackedBarChart",chartId:_,showLegend:z,userMargin:a,marginDefaults:i.marginDefaults,loading:P,emptyContent:L,width:$,height:W});if(ee.earlyReturn)return ee.earlyReturn;const te=Nr(),oe=t.useMemo(()=>new Map,[Q]),ne=t.useMemo(()=>(e,t)=>Z?ee.colorScale?{fill:Y(e,Z,ee.colorScale)}:{}:{fill:$r(B,te,p,t,oe)},[Z,ee.colorScale,B,te,p,oe]),ie=t.useMemo(()=>{const e=null==j?void 0:j.pieceStyle;return Ur(e&&"function"==typeof e?(t,o)=>{const n=ne(t,o),i=e(t,o)||{};return Object.assign(Object.assign({},n),i)}:ne,{stroke:I,strokeWidth:D,opacity:H})},[ne,j,I,D,H]),re=t.useMemo(()=>Pr(ie,ee.effectiveSelectionHook,ee.resolvedSelection),[ie,ee.effectiveSelectionHook,ee.resolvedSelection]),se=t.useMemo(()=>cr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),ae=os({componentName:"StackedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{stackBy:u}}),{effectiveLegendProps:le,effectiveMargin:ce}=aa({ref:n,frameRef:r,isPushMode:J,colorBy:Z,colorScheme:p,showLegend:z,legendPosition:R,setup:ee}),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=s&&{data:Q}),{oAccessor:c,rAccessor:d,stackBy:u,normalize:y,oSort:v,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:re,size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ce,barPadding:m}),null!=b&&{roundedTop:b}),{baselinePadding:x,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:g}),N&&{oFormat:N}),{showGrid:E}),le),G&&{title:G}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===k?()=>null:nr(k)||se}),(S||O||M||C)&&{customHoverBehavior:ee.customHoverBehavior}),(O||M||S)&&{customClickBehavior:ee.customClickBehavior}),w&&w.length>0&&{annotations:w}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return ae?e.jsx(Kr,{componentName:"StackedBarChart",message:ae,width:$,height:W}):e.jsx(ws,{componentName:"StackedBarChart",width:$,height:W,children:e.jsx(dn,Object.assign({ref:r},ue))})});la.displayName="StackedBarChart";const ca={RdBu:s.interpolateRdBu,PiYG:s.interpolatePiYG,PRGn:s.interpolatePRGn,BrBG:s.interpolateBrBG,RdYlBu:s.interpolateRdYlBu,RdYlGn:s.interpolateRdYlGn,Spectral:s.interpolateSpectral},ua="__likert_neutral_neg",da="__likert_neutral_pos";function ha(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function ga(e,t,o,n,i,r){const s=new Map,a=new Set(t);for(const l of e){const e=o(l);s.has(e)||s.set(e,new Map);const c=s.get(e);if(n){const e=n(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const i=t[o];c.set(i,(c.get(i)||0)+1)}else if(i&&r){const e=i(l),t=r(l);if(!a.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,o]of s){let n=0;for(const e of t)n+=o.get(e)||0;if(0!==n)for(let i=0;t.length>i;i++){const r=t[i],s=o.get(r)||0;l.push({__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/n*100,__likertLevelIndex:i})}}return l}function fa(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(n&&e===i){const e=t.__likertPct/2;r.push(Object.assign(Object.assign({},t),{__likertLevel:ua,__likertPct:-e})),r.push(Object.assign(Object.assign({},t),{__likertLevel:da,__likertPct:e}))}else r.push(i>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return r}function pa(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=new Map;for(const t of e){const e=r.get(t.__likertCategory)||[];e.push(t),r.set(t.__likertCategory,e)}const s=[];for(const[,e]of r){const t=new Map;let r,a;for(const o of e)o.__likertLevel===ua?r=o:o.__likertLevel===da?a=o:t.set(o.__likertLevelIndex,o);n&&r&&s.push(r);for(let e=i-1;e>=0;e--){const o=t.get(e);o&&s.push(o)}n&&a&&s.push(a);for(let e=n?i+1:i;o>e;e++){const o=t.get(e);o&&s.push(o)}}return s}const ya=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="question",valueAccessor:u,levelAccessor:d,countAccessor:h="count",levels:g,orientation:f="horizontal",colorScheme:p,barPadding:v=20,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:j,onClick:A,hoverHighlight:S,chartId:O,valueFormat:M,loading:C,emptyContent:_,legendInteraction:P,legendPosition:L,categoryFormat:T,stroke:R,strokeWidth:B,opacity:I}=o,D=i.width,H=i.height,N=i.enableHover,$=i.showGrid,W=i.showLegend,F=i.title,E=i.description,z=i.summary,Y=i.accessibleTable,G=i.categoryLabel,q=i.valueLabel,X="horizontal"===f,V=void 0===s,U=!d,K=function(){var e;const t=Dr();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.diverging)||void 0}(),Q=t.useMemo(()=>p&&Array.isArray(p)&&p.length>=g.length?p:function(e,t){if(0>=e)return[];if(t){const o=ca[t];if(o){if(1===e)return[o(.5)];const t=[];for(let n=0;e>n;n++)t.push(o(n/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],i="#a8a8a8";if(1===e)return[i];const r=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);r&&a.push(i);for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);return a}(g.length,K),[p,g.length,K]),Z=t.useMemo(()=>{const e=new Map;for(let t=0;g.length>t;t++)e.set(g[t],Q[t]||"#888");return e},[g,Q]),{processedData:J,reAggregate:ee,accumulatorRef:te}=function({data:e,levels:o,categoryAccessor:n,valueAccessor:i,levelAccessor:r,countAccessor:s,isDiverging:a,frameRef:l}){const c=!r,u=t.useMemo(()=>ha(n,"question"),[n]),d=t.useMemo(()=>c?ha(i,"score"):null,[c,i]),h=t.useMemo(()=>c?null:ha(r,"level"),[c,r]),g=t.useMemo(()=>c?null:ha(s,"count"),[c,s]),f=e||[],p=t.useRef([]),y=t.useMemo(()=>{if(0===f.length)return[];let e=ga(f,o,u,d,h,g);return a&&(e=fa(e,o),e=pa(e,o)),e},[f,o,u,d,h,g,a]),v=t.useCallback(e=>{var t;let n=ga(e,o,u,d,h,g);a&&(n=fa(n,o),n=pa(n,o)),null===(t=l.current)||void 0===t||t.replace(n)},[o,u,d,h,g,a,l]);return{processedData:y,reAggregate:v,accumulatorRef:p}}({data:s,levels:g,categoryAccessor:c,valueAccessor:u,levelAccessor:d,countAccessor:h,isDiverging:X,frameRef:r}),oe="__likertLevelLabel",ne=$s({isPushMode:V,colorBy:oe,colorScheme:Q,showLegend:W,legendPosition:L}),ie=t.useCallback(ne.wrapPush(e=>{te.current.push(e),ee(te.current)}),[ne.wrapPush,ee,te]),re=t.useCallback(ne.wrapPushMany(e=>{te.current.push(...e),ee(te.current)}),[ne.wrapPushMany,ee,te]);t.useImperativeHandle(n,()=>({push:ie,pushMany:re,remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;te.current=[],ne.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[ie,re,ne.resetCategories,te]);const se=_s({data:J,rawData:s,colorBy:oe,colorScheme:Q,legendInteraction:P,legendPosition:L,selection:k,linkedHover:w,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:j,onClick:A,hoverHighlight:S,chartType:"LikertChart",chartId:O,showLegend:W,userMargin:a,marginDefaults:i.marginDefaults,loading:C,emptyContent:_,width:D,height:H});if(se.earlyReturn)return se.earlyReturn;const ae=t.useMemo(()=>{const e=g.length;return e%2!=0&&Z.get(g[Math.floor(e/2)])||"#888"},[g,Z]),le=x.pieceStyle,ce=t.useMemo(()=>(e,t)=>{var o,n;const i=e.__likertLevelLabel||(null===(o=e.data)||void 0===o?void 0:o.__likertLevelLabel),r=e.__likertLevel||(null===(n=e.data)||void 0===n?void 0:n.__likertLevel);let s;if(r===ua||r===da)s={fill:ae};else{const e=i||r;s=e&&Z.has(e)?{fill:Z.get(e)}:{fill:"#888"}}if(le){const o=le(e,t);o.stroke&&(s.stroke=o.stroke),null!=o.strokeWidth&&(s.strokeWidth=o.strokeWidth),null!=o.strokeOpacity&&(s.strokeOpacity=o.strokeOpacity)}return s},[Z,ae,le]),ue=t.useMemo(()=>Ur(ce,{stroke:R,strokeWidth:B,opacity:I}),[ce,R,B,I]),de=t.useMemo(()=>Pr(ue,se.effectiveSelectionHook,se.resolvedSelection),[ue,se.effectiveSelectionHook,se.resolvedSelection]),he=t.useMemo(()=>{const e=g.length;return e%2!=0?g[Math.floor(e/2)]:""},[g]),ge=t.useMemo(()=>e=>{const t=e.data||e,o=t.__likertLevel||"Unknown",n=o===ua||o===da?he:o,i=t.__likertCategory||"",r=Math.abs(t.__likertPct||0),s=o===ua||o===da?2*r:r,a=t.__likertCount||0;return y.createElement("div",{className:"semiotic-tooltip",style:Ji},y.createElement("div",{style:{fontWeight:"bold"}},i),y.createElement("div",{style:{marginTop:4}},`${n}: ${s.toFixed(1)}% (n=${a})`))},[he]),fe=t.useMemo(()=>{if(!g||2>g.length)return"LikertChart requires `levels` with at least 2 entries.";if(u&&d)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(d&&!h)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==s&&0===s.length)return null;const e={categoryAccessor:c};return U?u&&(e.valueAccessor=u):(d&&(e.levelAccessor=d),h&&(e.countAccessor=h)),os({componentName:"LikertChart",data:s,accessors:e,requiredProps:{levels:g}})},[s,c,u,d,h,g,U]),pe=t.useMemo(()=>[{styleFn:e=>({fill:Z.get(e.label)||"#888"}),items:g.map(e=>({label:e})),label:""}],[g,Z]),ye=t.useMemo(()=>!1!==W?Object.assign(Object.assign({},se.legendBehaviorProps),{legend:{legendGroups:pe},legendPosition:L||se.legendPosition||"bottom"}):se.legendBehaviorProps,[se.legendBehaviorProps,se.legendPosition,L,W,pe]),ve=t.useMemo(()=>{const e=Object.assign({},se.margin);if(V&&!1!==W){const t=L||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(ne.streamingMarginAdjust)for(const[t,o]of Object.entries(ne.streamingMarginAdjust))o>e[t]&&(e[t]=o);return X&&100>e.left&&(e.left=100),e},[se.margin,ne.streamingMarginAdjust,X,V,W,L]),me=t.useMemo(()=>M||(X?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[X,M]),be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=s&&{data:J}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:X?"horizontal":"vertical",pieceStyle:de,size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ve,barPadding:v,enableHover:N}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:G,rLabel:q||(X?void 0:"Percentage"),rFormat:me}),T&&{oFormat:T}),{showGrid:$}),ye),F&&{title:F}),E&&{description:E}),z&&{summary:z}),void 0!==Y&&{accessibleTable:Y}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:!0===m?ge:nr(m)||ge}),(w||j||A||S)&&{customHoverBehavior:se.customHoverBehavior}),(j||A||w)&&{customClickBehavior:se.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return fe?e.jsx(Kr,{componentName:"LikertChart",message:fe,width:D,height:H}):e.jsx(ws,{componentName:"LikertChart",width:D,height:H,children:e.jsx(dn,Object.assign({ref:r},be))})});function va({brushProp:e,onBrushProp:o,linkedBrush:n,valueAccessor:i}){const r=_r("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),s=wr({name:(null==r?void 0:r.name)||"__unused_ordinal_brush__",xField:(null==r?void 0:r.xField)||("string"==typeof i?i:"value")}),a=t.useRef(s.brushInteraction);a.current=s.brushInteraction;const l=t.useCallback(e=>{if(r){a.current.end(e?e.r:null)}null==o||o(e)},[o,r]),c=!!(e||n||o);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}ya.displayName="LikertChart";const ma=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,8],pointRadius:v=4,pointOpacity:m=.7,categoryPadding:b=20,tooltip:x,annotations:k,brush:w,onBrush:j,linkedBrush:A,frameProps:S={},selection:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,emptyContent:R,legendInteraction:B,legendPosition:I,color:D,stroke:H,strokeWidth:N,opacity:$,showCategoryTicks:W,categoryFormat:F}=o,E=i.width,z=i.height,G=i.enableHover,X=i.showGrid,V=i.title,U=i.description,K=i.summary,Q=i.accessibleTable,Z=i.categoryLabel,J=i.valueLabel,ee=s||[],te=_s({data:ee,rawData:s,colorBy:g,colorScheme:f,legendInteraction:B,legendPosition:I,selection:O,linkedHover:M,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:C,onClick:_,hoverHighlight:P,chartType:"SwarmPlot",chartId:L,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:T,emptyContent:R,width:E,height:z}),oe=va({brushProp:w,onBrushProp:j,linkedBrush:A,valueAccessor:u});if(te.earlyReturn)return te.earlyReturn;const ne=t.useMemo(()=>{if(!p)return;const e=ee.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[ee,p]),ie=Nr(),re=t.useMemo(()=>new Map,[ee]),se=S.pieceStyle,ae=t.useMemo(()=>(e,t)=>{const o={fillOpacity:m};if(o.fill=g?Y(e,g,te.colorScale):$r(D,ie,f,void 0,re),o.r=p?q(e,p,y,ne):v,se){const n=se(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[g,te.colorScale,p,y,ne,v,m,D,ie,f,re,se]),le=t.useMemo(()=>Ur(ae,{stroke:H,strokeWidth:N,opacity:$}),[ae,H,N,$]),ce=t.useMemo(()=>Pr(le,te.effectiveSelectionHook,te.resolvedSelection),[le,te.effectiveSelectionHook,te.resolvedSelection]),ue=t.useMemo(()=>cr({categoryAccessor:c,valueAccessor:u,groupAccessor:g||void 0,valueFormat:h}),[c,u,g,h]),de=os({componentName:"SwarmPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(de)return e.jsx(Kr,{componentName:"SwarmPlot",message:de,width:E,height:z});const he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm"},null!=s&&{data:ee}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ce,size:[E,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:te.margin,barPadding:b,enableHover:G}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Z,rLabel:J,rFormat:h}),F&&{oFormat:F}),{showGrid:X,showCategoryTicks:W}),te.legendBehaviorProps),V&&{title:V}),U&&{description:U}),K&&{summary:K}),void 0!==Q&&{accessibleTable:Q}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:nr(x)||ue}),(M||C||_||P)&&{customHoverBehavior:te.customHoverBehavior}),(C||_||M)&&{customClickBehavior:te.customClickBehavior}),k&&k.length>0&&{annotations:k}),oe.brushStreamProps),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"SwarmPlot",width:E,height:z,children:e.jsx(dn,Object.assign({ref:r},he))})});function ba(t){return o=>{var n;const i=o.category||o.data&&(null===(n=o.data[0])||void 0===n?void 0:n.category)||"",r=o.stats||(o.data||o).stats;if(r&&null!=r.median)return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),null!=r.n&&e.jsxs("div",{children:["n = ",r.n]}),null!=r.min&&e.jsxs("div",{children:["Min: ",r.min.toLocaleString()]}),null!=r.q1&&e.jsxs("div",{children:["Q1: ",r.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",r.median.toLocaleString()]}),null!=r.q3&&e.jsxs("div",{children:["Q3: ",r.q3.toLocaleString()]}),null!=r.max&&e.jsxs("div",{children:["Max: ",r.max.toLocaleString()]}),null!=r.mean&&e.jsxs("div",{style:{opacity:.8},children:["Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});if(null==t?void 0:t.valueAccessor){const n=t.valueAccessor,r=(Array.isArray(o.data)?o.data:[]).map(e=>Number("function"==typeof n?n(e):e[n])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),s=r.length,a=s>0?s%2!=0?r[Math.floor(s/2)]:(r[s/2-1]+r[s/2])/2:null;return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),s>0&&e.jsxs("div",{children:["n = ",s]}),null!=a&&e.jsxs("div",{children:["Median: ",a.toLocaleString()]})]})}return e.jsx("div",{className:"semiotic-tooltip",style:Ji,children:e.jsx("div",{style:{fontWeight:"bold"},children:i+""})})}}ma.displayName="SwarmPlot";const xa=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,showOutliers:p=!0,categoryPadding:y=20,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R,showCategoryTicks:B,categoryFormat:I}=o,D=i.width,H=i.height,N=i.enableHover,$=i.showGrid,W=i.title,F=i.description,E=i.summary,z=i.accessibleTable,G=i.categoryLabel,q=i.valueLabel,X=s||[],V=_s({data:X,rawData:s,colorBy:g,colorScheme:f,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"BoxPlot",chartId:S,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:O,emptyContent:M,width:D,height:H});if(V.earlyReturn)return V.earlyReturn;const U=Nr(),K=t.useMemo(()=>new Map,[X]),Q=t.useMemo(()=>e=>{const t=g?Y(e,g,V.colorScale):$r(P,U,f,void 0,K);return{fill:t,stroke:t,fillOpacity:.8}},[g,V.colorScale,P,U,f,K]),Z=t.useMemo(()=>Ur(Q,{stroke:L,strokeWidth:T,opacity:R}),[Q,L,T,R]),J=t.useMemo(()=>Pr(Z,V.effectiveSelectionHook,V.resolvedSelection),[Z,V.effectiveSelectionHook,V.resolvedSelection]),ee=t.useMemo(()=>ba(),[]),te=os({componentName:"BoxPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(te)return e.jsx(Kr,{componentName:"BoxPlot",message:te,width:D,height:H});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot"},null!=s&&{data:X}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:J,showOutliers:p,size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:V.margin,barPadding:y,enableHover:N}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:G,rLabel:q,rFormat:h}),I&&{oFormat:I}),{showGrid:$,showCategoryTicks:B}),V.legendBehaviorProps),W&&{title:W}),F&&{description:F}),E&&{summary:E}),void 0!==z&&{accessibleTable:z}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:nr(v)||ee}),(k||w||j||A)&&{customHoverBehavior:V.customHoverBehavior}),(w||j||k)&&{customClickBehavior:V.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"BoxPlot",width:D,height:H,children:e.jsx(dn,Object.assign({ref:r},oe))})});xa.displayName="BoxPlot";const ka=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:"horizontal"}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",bins:d=25,relative:h=!1,valueFormat:g,colorBy:f,colorScheme:p,categoryPadding:y=20,tooltip:v,annotations:m,brush:b,onBrush:x,linkedBrush:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,showCategoryTicks:H,categoryFormat:N}=o,$=i.width,W=i.height,F=i.enableHover,E=i.showGrid,z=i.title,G=i.description,q=i.summary,X=i.accessibleTable,V=i.categoryLabel,U=i.valueLabel,K=s||[],Q=_s({data:K,rawData:s,colorBy:f,colorScheme:p,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"Histogram",chartId:C,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:$,height:W}),Z=va({brushProp:b,onBrushProp:x,linkedBrush:k,valueAccessor:u});if(Q.earlyReturn)return Q.earlyReturn;const J=t.useMemo(()=>{if(0===K.length)return;const e="function"==typeof u?u:e=>e[u];let t=1/0,o=-1/0;for(const n of K){const i=e(n);null!=i&&isFinite(i)&&(t>i&&(t=i),i>o&&(o=i))}return t>o?void 0:[t,o]},[K,u]),ee=Nr(),te=t.useMemo(()=>new Map,[K]),oe=t.useMemo(()=>e=>{const t=f?Y(e,f,Q.colorScale):$r(R,ee,p,void 0,te);return{fill:t,stroke:t,fillOpacity:.8}},[f,Q.colorScale,R,ee,p,te]),ne=t.useMemo(()=>Ur(oe,{stroke:B,strokeWidth:I,opacity:D}),[oe,B,I,D]),ie=t.useMemo(()=>Pr(ne,Q.effectiveSelectionHook,Q.resolvedSelection),[ne,Q.effectiveSelectionHook,Q.resolvedSelection]),re=t.useMemo(()=>t=>{const o=t.data||t,n=o.category||t.category||"",i=o.count,r=o.range;return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[n&&e.jsx("div",{style:{fontWeight:"bold"},children:n+""}),null!=i&&e.jsxs("div",{children:["Count: ",i]}),r&&2===r.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]),se=os({componentName:"Histogram",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(se)return e.jsx(Kr,{componentName:"Histogram",message:se,width:$,height:W});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram"},null!=s&&{data:K}),{oAccessor:c,rAccessor:u,projection:"horizontal",summaryStyle:ie,bins:d,normalize:h}),J&&{rExtent:J}),{size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Q.margin,barPadding:y,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:U,rFormat:g}),N&&{oFormat:N}),{showGrid:E,showCategoryTicks:H}),Q.legendBehaviorProps),z&&{title:z}),G&&{description:G}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:nr(v)||re}),(A||S||O||M)&&{customHoverBehavior:Q.customHoverBehavior}),(S||O||A)&&{customClickBehavior:Q.customClickBehavior}),m&&m.length>0&&{annotations:m}),Z.brushStreamProps),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"Histogram",width:$,height:W,children:e.jsx(dn,Object.assign({ref:r},ae))})});ka.displayName="Histogram";const wa=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",bins:h=25,showIQR:g=!0,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:v=20,tooltip:m,annotations:b,brush:x,onBrush:k,linkedBrush:w,frameProps:j={},selection:A,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,emptyContent:L,legendInteraction:T,legendPosition:R,color:B,stroke:I,strokeWidth:D,opacity:H,showCategoryTicks:N,categoryFormat:$}=o,W=i.width,F=i.height,E=i.enableHover,z=i.showGrid,G=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.categoryLabel,K=i.valueLabel,Q=s||[],Z=_s({data:Q,rawData:s,colorBy:p,colorScheme:y,legendInteraction:T,legendPosition:R,selection:A,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:C,chartType:"ViolinPlot",chartId:_,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:P,emptyContent:L,width:W,height:F}),J=va({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:u});if(Z.earlyReturn)return Z.earlyReturn;const ee=Nr(),te=t.useMemo(()=>new Map,[Q]),oe=t.useMemo(()=>e=>{const t=p?Y(e,p,Z.colorScale):$r(B,ee,y,void 0,te);return{fill:t,stroke:t,fillOpacity:.6}},[p,Z.colorScale,B,ee,y,te]),ne=t.useMemo(()=>Ur(oe,{stroke:I,strokeWidth:D,opacity:H}),[oe,I,D,H]),ie=t.useMemo(()=>Pr(ne,Z.effectiveSelectionHook,Z.resolvedSelection),[ne,Z.effectiveSelectionHook,Z.resolvedSelection]),re=t.useMemo(()=>ba({valueAccessor:u}),[u]),se=os({componentName:"ViolinPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(se)return e.jsx(Kr,{componentName:"ViolinPlot",message:se,width:W,height:F});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin"},null!=s&&{data:Q}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ie,bins:h,showIQR:g,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z.margin,barPadding:v,enableHover:E}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:f}),$&&{oFormat:$}),{showGrid:z,showCategoryTicks:N}),Z.legendBehaviorProps),G&&{title:G}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:nr(m)||re}),(S||O||M||C)&&{customHoverBehavior:Z.customHoverBehavior}),(O||M||S)&&{customClickBehavior:Z.customClickBehavior}),b&&b.length>0&&{annotations:b}),J.brushStreamProps),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"ViolinPlot",width:W,height:F,children:e.jsx(dn,Object.assign({ref:r},ae))})});wa.displayName="ViolinPlot";const ja=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",bins:h=20,amplitude:g=1.5,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:v=5,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:j,onClick:A,hoverHighlight:S,chartId:O,loading:M,emptyContent:C,legendInteraction:_,legendPosition:P,color:L,stroke:T,strokeWidth:R,opacity:B,showCategoryTicks:I,categoryFormat:D}=o,H=i.width,N=i.height,$=i.enableHover,W=i.showGrid,F=i.title,E=i.description,z=i.summary,G=i.accessibleTable,q=i.categoryLabel,X=i.valueLabel,V=s||[],U=_s({data:V,rawData:s,colorBy:p,colorScheme:y,legendInteraction:_,legendPosition:P,selection:k,linkedHover:w,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:j,onClick:A,hoverHighlight:S,chartType:"RidgelinePlot",chartId:O,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:M,emptyContent:C,width:H,height:N});if(U.earlyReturn)return U.earlyReturn;const K=Nr(),Q=t.useMemo(()=>new Map,[V]),Z=t.useMemo(()=>e=>{const t=p?Y(e,p,U.colorScale):$r(L,K,y,void 0,Q);return{fill:t,stroke:t,fillOpacity:.5}},[p,U.colorScale,L,K,y,Q]),J=t.useMemo(()=>Ur(Z,{stroke:T,strokeWidth:R,opacity:B}),[Z,T,R,B]),ee=t.useMemo(()=>Pr(J,U.effectiveSelectionHook,U.resolvedSelection),[J,U.effectiveSelectionHook,U.resolvedSelection]),te=t.useMemo(()=>ba(),[]),oe=os({componentName:"RidgelinePlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(oe)return e.jsx(Kr,{componentName:"RidgelinePlot",message:oe,width:H,height:N});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline"},null!=s&&{data:V}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ee,bins:h,size:[H,N],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:U.margin,barPadding:v,enableHover:$}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:q,rLabel:X,rFormat:f}),D&&{oFormat:D}),{showGrid:W,showCategoryTicks:I,oSort:!1,amplitude:g}),U.legendBehaviorProps),F&&{title:F}),E&&{description:E}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:nr(m)||te}),(w||j||A||S)&&{customHoverBehavior:U.customHoverBehavior}),(j||A||w)&&{customClickBehavior:U.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"RidgelinePlot",width:H,height:N,children:e.jsx(dn,Object.assign({ref:r},ne))})});ja.displayName="RidgelinePlot";const Aa=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:!1,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:!1}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,stepAccessor:c="step",valueAccessor:u="value",categoryAccessor:d,colorBy:h,colorScheme:g,orientation:f="horizontal",connectorOpacity:p=.3,showLabels:y=!0,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R,categoryFormat:B}=o,I="vertical"===f,D=i.width,H=i.height,N=i.enableHover,$=i.title,W=i.description,F=i.summary,E=i.accessibleTable,z=s||[],G=h||d,q=!G,X=_s({data:z,rawData:s,colorBy:G,colorScheme:g,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:G?["string"==typeof G?G:""]:[],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"FunnelChart",chartId:S,showLegend:i.showLegend,userMargin:a,marginDefaults:I?{top:$?60:40,right:20,bottom:60,left:60}:{top:$?40:10,right:10,bottom:10,left:10},loading:O,emptyContent:M,width:D,height:H});if(X.earlyReturn)return X.earlyReturn;Ms("FunnelChart",z,"stepAccessor",c),Ms("FunnelChart",z,"valueAccessor",u);const V=Nr(),U=t.useMemo(()=>new Map,[z]),K=t.useMemo(()=>{if(q)return P||((null==V?void 0:V[0])?V[0]:Array.isArray(g)&&g[0]?g[0]:"#4e79a7")},[q,P,V,g]),Q=b.pieceStyle,Z=t.useMemo(()=>(e,t)=>{const o={};if(o.fill=K||(G?Y(e,G,X.colorScale):$r(P,V,g,t,U)),Q){const n=Q(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[K,G,X.colorScale,P,V,g,U,Q]),J=t.useMemo(()=>Ur(Z,{stroke:L,strokeWidth:T,opacity:R}),[Z,L,T,R]),ee=t.useMemo(()=>Pr(J,X.effectiveSelectionHook,X.resolvedSelection),[J,X.effectiveSelectionHook,X.resolvedSelection]),te=t.useMemo(()=>t=>{var o,n,i,r,s,a;const l=(null==t?void 0:t.data)||t,c=(null==l?void 0:l.__funnelStep)||(null==l?void 0:l.__barFunnelStep)||(null==l?void 0:l.step)||"",u=null!==(i=null!==(n=null!==(o=null==l?void 0:l.__funnelValue)&&void 0!==o?o:null==l?void 0:l.__barFunnelValue)&&void 0!==n?n:null==l?void 0:l.value)&&void 0!==i?i:"",d=null!==(r=null==l?void 0:l.__funnelPercent)&&void 0!==r?r:null==l?void 0:l.__barFunnelPercent,h=null!==(s=null==l?void 0:l.__funnelIsFirstStep)&&void 0!==s?s:null==l?void 0:l.__barFunnelIsFirstStep,g=null==l?void 0:l.__barFunnelIsDropoff,f=null!==(a=null==l?void 0:l.__barFunnelCategory)&&void 0!==a?a:null==l?void 0:l.category,p=null==d||h?"":` (${.05>Math.abs(d-Math.round(d))?Math.round(d)+"%":d.toFixed(1)+"%"})`;return e.jsxs("div",{className:"semiotic-tooltip",style:Ji,children:[c&&e.jsx("div",{style:{fontWeight:"bold"},children:c+""}),f&&f!==c&&e.jsx("div",{style:{marginTop:2,opacity:.8},children:f+""}),g&&e.jsx("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),e.jsxs("div",{style:{marginTop:4},children:[u+"",p]})]})},[]),oe=os({componentName:"FunnelChart",data:s,accessors:{stepAccessor:c,valueAccessor:u}});if(oe)return e.jsx(Kr,{componentName:"FunnelChart",message:oe,width:D,height:H});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:I?"bar-funnel":"funnel"},null!=s&&{data:z}),{oAccessor:c,rAccessor:u}),d&&{stackBy:d}),{projection:I?"vertical":"horizontal",barPadding:I?40:0,pieceStyle:ee,size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:X.margin,enableHover:N}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:I,showCategoryTicks:I}),B&&{oFormat:B}),{showGrid:I}),!I&&{connectorOpacity:p}),{showLabels:y}),X.legendBehaviorProps),$&&{title:$}),W&&{description:W}),F&&{summary:F}),void 0!==E&&{accessibleTable:E}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:!0===v||null==v?te:nr(v)||te}),(k||w||j||A)&&{customHoverBehavior:X.customHoverBehavior}),(w||j||k)&&{customClickBehavior:X.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"FunnelChart",width:D,height:H,children:e.jsx(dn,Object.assign({ref:r},ne))})});Aa.displayName="FunnelChart";const Sa=t.forwardRef(function(o,n){var i;const r=Xr(o.mode,{width:o.width,height:o.height,showGrid:null===(i=o.showGrid)||void 0===i||i,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),s=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=s.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:a,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,sort:y="auto",dotRadius:v=5,categoryPadding:m=10,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:j,onObservation:A,onClick:S,hoverHighlight:O,chartId:M,loading:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:I,categoryFormat:D}=o,H=r.width,N=r.height,$=r.enableHover,W=r.showGrid,F=r.title,E=r.description,z=r.summary,G=r.accessibleTable,q=r.categoryLabel,X=r.valueLabel,V=a||[],U=_s({data:V,rawData:a,colorBy:f,colorScheme:p,legendInteraction:P,legendPosition:L,selection:w,linkedHover:j,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof u?u:""],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"DotPlot",chartId:M,showLegend:r.showLegend,userMargin:l,marginDefaults:r.marginDefaults,loading:C,emptyContent:_,width:H,height:N});if(U.earlyReturn)return U.earlyReturn;const K=Fr(V,y,d),Q=Nr(),Z=t.useMemo(()=>new Map,[V]),J=k.pieceStyle,ee=t.useMemo(()=>(e,t)=>{const o={r:v,fillOpacity:.8};if(o.fill=f?Y(e,f,U.colorScale):$r(T,Q,p,void 0,Z),J){const n=J(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[f,U.colorScale,v,T,Q,p,Z,J]),te=t.useMemo(()=>Ur(ee,{stroke:R,strokeWidth:B,opacity:I}),[ee,R,B,I]),oe=t.useMemo(()=>Pr(te,U.effectiveSelectionHook,U.resolvedSelection),[te,U.effectiveSelectionHook,U.resolvedSelection]),ne=t.useMemo(()=>cr({categoryAccessor:u,valueAccessor:d,valueFormat:g}),[u,d,g]),ie=os({componentName:"DotPlot",data:a,accessors:{categoryAccessor:u,valueAccessor:d}});if(ie)return e.jsx(Kr,{componentName:"DotPlot",message:ie,width:H,height:N});const re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point"},null!=a&&{data:K}),{oAccessor:u,rAccessor:d,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:oe,size:[H,N],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:U.margin,barPadding:m,enableHover:$}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:r.showAxes,oLabel:q,rLabel:X,rFormat:g}),D&&{oFormat:D}),{showGrid:W,oSort:y}),U.legendBehaviorProps),F&&{title:F}),E&&{description:E}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),c&&{className:c}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===b?()=>null:nr(b)||ne}),(j||A||S||O)&&{customHoverBehavior:U.customHoverBehavior}),(A||S||j)&&{customClickBehavior:U.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return e.jsx(ws,{componentName:"DotPlot",width:H,height:N,children:e.jsx(dn,Object.assign({ref:s},re))})});Sa.displayName="DotPlot";const Oa=t.forwardRef(function(o,n){var i,r;const s=Xr(o.mode,{width:null!==(i=o.width)&&void 0!==i?i:400,height:null!==(r=o.height)&&void 0!==r?r:400,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:o.showCategoryTicks}),a=t.useRef(null),{data:l,margin:c,className:u,categoryAccessor:d="category",valueAccessor:h="value",colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R}=o,B=s.width,I=s.height,D=s.enableHover,H=s.showLegend,N=s.title,$=s.description,W=s.summary,F=s.accessibleTable,E=l||[],z=g||d,G=void 0===l,q=_s({data:E,rawData:l,colorBy:z,colorScheme:f,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"PieChart",chartId:S,showLegend:H,userMargin:c,marginDefaults:s.marginDefaults,loading:O,emptyContent:M,width:B,height:I});if(q.earlyReturn)return q.earlyReturn;const X=Nr(),V=t.useMemo(()=>new Map,[E]),U=t.useMemo(()=>(e,t)=>z?q.colorScale?{fill:Y(e,z,q.colorScale)}:{}:{fill:$r(P,X,f,t,V)},[z,q.colorScale,P,X,f,V]),K=t.useMemo(()=>{const e=null==b?void 0:b.pieceStyle;return Ur(e&&"function"==typeof e?(t,o)=>Object.assign(Object.assign({},U(t,o)),e(t,o)||{}):U,{stroke:L,strokeWidth:T,opacity:R})},[U,b,L,T,R]),Q=t.useMemo(()=>Pr(K,q.effectiveSelectionHook,q.resolvedSelection),[K,q.effectiveSelectionHook,q.resolvedSelection]),Z=t.useMemo(()=>cr({categoryAccessor:d,valueAccessor:h,groupAccessor:g&&g!==d?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[d,h,g]),J=os({componentName:"PieChart",data:l,accessors:{categoryAccessor:d,valueAccessor:h}}),{effectiveLegendProps:ee,effectiveMargin:te}=aa({ref:n,frameRef:a,isPushMode:G,colorBy:z,colorScheme:f,showLegend:H,legendPosition:_,setup:q}),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie"},null!=l&&{data:E}),{oAccessor:d,rAccessor:h,projection:"radial",pieceStyle:Q,startAngle:p}),null!=y&&{cornerRadius:y}),{size:[B,I],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:te,enableHover:D}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),ee),N&&{title:N}),$&&{description:$}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),u&&{className:u}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:nr(v)||Z}),(k||w||j||A)&&{customHoverBehavior:q.customHoverBehavior}),(w||j||k)&&{customClickBehavior:q.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return J?e.jsx(Kr,{componentName:"PieChart",message:J,width:B,height:I}):e.jsx(ws,{componentName:"PieChart",width:B,height:I,children:e.jsx(dn,Object.assign({ref:a},oe))})});Oa.displayName="PieChart";const Ma=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover,showCategoryTicks:o.showCategoryTicks},{width:400,height:400}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:d,centerContent:h,colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R}=o,B=i.width,I=i.height,D=i.enableHover,H=i.showLegend,N=i.title,$=i.description,W=i.summary,F=i.accessibleTable,E=s||[],z=g||c,G=void 0===s,q=_s({data:E,rawData:s,colorBy:z,colorScheme:f,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"DonutChart",chartId:S,showLegend:H,userMargin:a,marginDefaults:i.marginDefaults,loading:O,emptyContent:M,width:B,height:I});if(q.earlyReturn)return q.earlyReturn;const X=null!=d?d:Math.max(2,.15*Math.min(B,I)),V=Nr(),U=t.useMemo(()=>new Map,[E]),K=b.pieceStyle,Q=t.useMemo(()=>(e,t)=>{let o;if(o=z?q.colorScale?{fill:Y(e,z,q.colorScale)}:{}:{fill:$r(P,V,f,t,U)},K){const n=K(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[z,q.colorScale,P,V,f,U,K]),Z=t.useMemo(()=>Ur(Q,{stroke:L,strokeWidth:T,opacity:R}),[Q,L,T,R]),J=t.useMemo(()=>Pr(Z,q.effectiveSelectionHook,q.resolvedSelection),[Z,q.effectiveSelectionHook,q.resolvedSelection]),ee=t.useMemo(()=>cr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,u,g]),te=os({componentName:"DonutChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}}),{effectiveLegendProps:oe,effectiveMargin:ne}=aa({ref:n,frameRef:r,isPushMode:G,colorBy:z,colorScheme:f,showLegend:H,legendPosition:_,setup:q}),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut"},null!=s&&{data:E}),{oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:J,innerRadius:X,startAngle:p}),null!=y&&{cornerRadius:y}),{centerContent:h,size:[B,I],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne,enableHover:D}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),oe),N&&{title:N}),$&&{description:$}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:nr(v)||ee}),(k||w||j||A)&&{customHoverBehavior:q.customHoverBehavior}),(w||j||k)&&{customClickBehavior:q.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return te?e.jsx(Kr,{componentName:"DonutChart",message:te,width:B,height:I}):e.jsx(ws,{componentName:"DonutChart",width:B,height:I,children:e.jsx(dn,Object.assign({ref:r},ie))})});Ma.displayName="DonutChart";const Ca=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:!1,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:300,height:250}),r=t.useRef(null),s="context"===o.mode,{compactMode:a}=i,{value:l,min:c=0,max:u=100,thresholds:d,color:h,backgroundColor:g="var(--semiotic-grid, #e0e0e0)",arcWidth:f=.3,showNeedle:p=!0,needleColor:y="var(--semiotic-text, #333)",centerContent:v,valueFormat:m,showScaleLabels:b=!a,sweep:x=240,fillZones:k=!0,tooltip:w,annotations:j,frameProps:A={},className:S,stroke:O,strokeWidth:M,opacity:C}=o,_=i.width,P=i.height,L=i.title,T=i.description,R=i.summary,B=i.accessibleTable,I=Math.max(c,Math.min(u,l)),D=u-c||1,H=(I-c)/D,{gaugeData:N,pieceStyle:$,gaugeAnnotations:W}=t.useMemo(()=>{const e=[],t=new Map,o=[];let n=d&&d.length>0?[...d].sort((e,t)=>e.value-t.value):[{value:u,color:h||"var(--semiotic-primary, #007bff)"}];n=n.map(e=>Object.assign(Object.assign({},e),{value:Math.max(c,Math.min(u,e.value))})),u>n[n.length-1].value&&n.push({value:u,color:n[n.length-1].color});let i=c;for(let o=0;n.length>o;o++){const r=n[o],s=(r.value-i)/D;if(k){const n=(i-c)/D,a=Math.max(0,Math.min(H,(r.value-c)/D)-n),l=s-a;if(a>0){const n="fill-"+o;e.push({category:n,value:a,_zone:r.label||"Zone "+(o+1),_isFill:!0}),t.set(n,{fill:r.color})}if(l>0){const n="bg-"+o;e.push({category:n,value:l,_zone:r.label||"Zone "+(o+1),_isFill:!1}),t.set(n,{fill:g,opacity:.4})}}else{const n="zone-"+o;e.push({category:n,value:s,_zone:r.label||"Zone "+(o+1),_isFill:!0}),t.set(n,{fill:r.color})}i=r.value}if(b&&d&&d.length>0)for(const e of d)e.value>c&&u>e.value&&o.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:e,pieceStyle:(e,o)=>t.get(o||e.category)||{fill:g},gaugeAnnotations:o}},[l,c,u,d,h,g,H,D,b,k]),F=t.useMemo(()=>Ur($,{stroke:O,strokeWidth:M,opacity:C}),[$,O,M,C]),E=x*Math.PI/180,z=180+(360-x)/2,Y=Math.min(10,Math.max(1,Math.min(_,P)/12)),G=-Math.PI/2+z*Math.PI/180,q=[[Math.cos(G),Math.sin(G)],[Math.cos(G+E),Math.sin(G+E)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-G)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>E+.001||q.push([Math.cos(e),Math.sin(e)]);const X=Math.min(...q.map(e=>e[0])),V=Math.max(...q.map(e=>e[0])),U=Math.min(...q.map(e=>e[1])),K=Math.max(...q.map(e=>e[1])),Q=(U+K)/2,Z=(X+V)/2,J=Math.max(4,Math.min((_-2*Y)/(V-X),(P-2*Y)/(K-U))-2),ee=Math.max(0,Math.min(J-1.5,J*(1-f))),te=_/2-Z*J,oe=P/2-Q*J,ne=2*(J+4),ie=t.useMemo(()=>{if(a&&null==v)return null;if(null!=v)return"function"==typeof v?v(I,c,u):v;const t=m?m(I):Math.round(I)+"";return e.jsxs("div",{style:{textAlign:"center",lineHeight:1.2},children:[e.jsx("div",{style:{fontSize:Math.max(16,.3*J),fontWeight:700,color:"var(--semiotic-text, #333)"},children:t}),b&&e.jsxs("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[c," – ",u]})]})},[v,I,c,u,m,b,J,a]),re=t.useMemo(()=>s&&null==v?{type:"gauge-value",text:m?m(I):Math.round(I)+""}:null,[s,v,I,m]),se=t.useMemo(()=>{if(!p)return null;const e=-Math.PI/2+z*Math.PI/180+H*E,t=ee>20?ee-8:J-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:y}},[p,H,z,E,ee,y]),ae=t.useMemo(()=>(t,o,n)=>{if("gauge-needle"===t.type){const i=(n.width||_)/2,r=(n.height||P)/2,s=Math.max(1,J-ee),a=Math.max(1,Math.min(2.5,.4*s)),l=Math.max(1,Math.min(5,.6*s));return e.jsxs("g",{transform:`translate(${i},${r})`,children:[e.jsx("line",{x1:0,y1:0,x2:t.tipX,y2:t.tipY,stroke:t.color,strokeWidth:a,strokeLinecap:"round"}),e.jsx("circle",{cx:0,cy:0,r:l,fill:t.color})]},"gauge-needle-"+o)}if("gauge-label"===t.type){const i=-Math.PI/2+z*Math.PI/180+(t.value-c)/D*E,r=ee-14,s=(n.height||P)/2;return e.jsx("text",{x:(n.width||_)/2+Math.cos(i)*r,y:s+Math.sin(i)*r,textAnchor:"middle",dominantBaseline:"middle",fontSize:9,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label},"gauge-label-"+o)}return"gauge-value"===t.type?e.jsx("text",{x:(n.width||_)/2,y:(n.height||P)/2-.2*ee,textAnchor:"middle",dominantBaseline:"middle",fontSize:Math.max(12,Math.min(22,.28*J)),fontWeight:700,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:t.text},"gauge-value-"+o):null},[_,P,c,D,z,E,ee,J]),le=t.useMemo(()=>{const e=[...W,...j||[]];return se&&e.push(se),re&&e.push(re),e},[W,j,se,re]),ce=t.useMemo(()=>t=>{var o;const n=(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o[0])||(null==t?void 0:t.data)||t,i=null==n?void 0:n._isFill;return e.jsxs("div",{className:"semiotic-tooltip",style:{padding:"6px 10px",background:"var(--semiotic-tooltip-bg, white)",borderRadius:"var(--semiotic-tooltip-radius, 6px)",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0,0,0,0.15))"},children:[e.jsx("div",{style:{fontWeight:600},children:(null==n?void 0:n._zone)||""}),e.jsx("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:i?"Current: "+Math.round(I):"Remaining"})]})},[I]);if(0===N.length)return e.jsx(Kr,{componentName:"GaugeChart",message:"No data to display",width:_,height:P});const ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:N,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:F,innerRadius:ee,startAngle:z,sweepAngle:x,centerContent:ie,size:[_,P],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:{top:oe-ne/2,bottom:P-oe-ne/2,left:te-ne/2,right:_-te-ne/2},enableHover:i.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===w?()=>null:nr(w)||ce,svgAnnotationRules:ae},le.length>0&&{annotations:le}),L&&{title:L}),T&&{description:T}),R&&{summary:R}),void 0!==B&&{accessibleTable:B}),S&&{className:S}),null!=o.animate&&{animate:o.animate}),A);return e.jsx(ws,{componentName:"GaugeChart",width:_,height:P,children:e.jsx(dn,Object.assign({ref:r},ue))})});Ca.displayName="GaugeChart";const _a=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",groupBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,sort:y=!1,barPadding:v=60,roundedTop:m,baselinePadding:b=!1,tooltip:x,annotations:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,categoryFormat:H}=o,N=i.width,$=i.height,W=i.enableHover,F=i.showGrid,E=i.showLegend,z=i.title,G=i.description,q=i.summary,X=i.accessibleTable,V=i.categoryLabel,U=i.valueLabel,K=s||[],Q=f||u,Z=void 0===s,J=_s({data:K,rawData:s,colorBy:Q,colorScheme:p,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:Q?["string"==typeof Q?Q:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"GroupedBarChart",chartId:C,showLegend:E,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:N,height:$});if(J.earlyReturn)return J.earlyReturn;const ee=Nr(),te=t.useMemo(()=>new Map,[K]),oe=w.pieceStyle,ne=t.useMemo(()=>(e,t)=>{const o=Q?J.colorScale?{fill:Y(e,Q,J.colorScale)}:{}:{fill:$r(R,ee,p,t,te)};if(oe){const n=oe(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[Q,J.colorScale,R,ee,p,te,oe]),ie=t.useMemo(()=>Ur(ne,{stroke:B,strokeWidth:I,opacity:D}),[ne,B,I,D]),re=t.useMemo(()=>Pr(ie,J.effectiveSelectionHook,J.resolvedSelection),[ie,J.effectiveSelectionHook,J.resolvedSelection]),se=t.useMemo(()=>cr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),ae=os({componentName:"GroupedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{groupBy:u}}),{effectiveLegendProps:le,effectiveMargin:ce}=aa({ref:n,frameRef:r,isPushMode:Z,colorBy:Q,colorScheme:p,showLegend:E,legendPosition:T,setup:J}),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar"},null!=s&&{data:K}),{oAccessor:c,rAccessor:d,groupBy:u,oSort:y,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:re,size:[N,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ce,barPadding:v}),null!=m&&{roundedTop:m}),{baselinePadding:b,enableHover:W}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:U,rFormat:g}),H&&{oFormat:H}),{showGrid:F}),le),z&&{title:z}),G&&{description:G}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:nr(x)||se}),(A||S||O||M)&&{customHoverBehavior:J.customHoverBehavior}),(S||O||A)&&{customClickBehavior:J.customClickBehavior}),k&&k.length>0&&{annotations:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return ae?e.jsx(Kr,{componentName:"GroupedBarChart",message:ae,width:N,height:$}):e.jsx(ws,{componentName:"GroupedBarChart",width:N,height:$,children:e.jsx(dn,Object.assign({ref:r},ue))})});_a.displayName="GroupedBarChart";const Pa=t.forwardRef(function(o,n){const i=Xr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",subcategoryAccessor:u,valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,barPadding:y,tooltip:v,annotations:m,brush:b,onBrush:x,linkedBrush:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,categoryFormat:H,rTickValues:N,tickLabelEdgeAlign:$,showCategoryTicks:W}=o,F=i.width,E=i.height,z=i.enableHover,G=i.showGrid,q=i.showLegend,X=i.title,V=i.description,U=i.summary,K=i.accessibleTable,Q=i.categoryLabel,Z=i.valueLabel,J=s||[],ee=f||u,te=void 0===s,oe=t.useMemo(()=>{if(null!=y)return y;if("sparkline"!==o.mode)return 40;const e=new Set(J.map(e=>"function"==typeof c?c(e):e[c])),t=Math.max(1,e.size);return t>1?Math.max(0,Math.min(1,(("horizontal"===h?E:F)-2*t)/(t-1))):1},[y,o.mode,J,c,h,F,E]),ne=_s({data:J,rawData:s,colorBy:ee,colorScheme:p,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:ee?["string"==typeof ee?ee:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"SwimlaneChart",chartId:C,showLegend:q,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:F,height:E}),ie=va({brushProp:b,onBrushProp:x,linkedBrush:k,valueAccessor:d});if(ne.earlyReturn)return ne.earlyReturn;const re=Nr(),se=t.useMemo(()=>new Map,[J]),ae=w.pieceStyle,le=t.useMemo(()=>(e,t)=>{const o=ee?ne.colorScale?{fill:Y(e,ee,ne.colorScale)}:{}:{fill:$r(R,re,p,t,se)};if(ae){const n=ae(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[ee,ne.colorScale,R,re,p,se,ae]),ce=t.useMemo(()=>Ur(le,{stroke:B,strokeWidth:I,opacity:D}),[le,B,I,D]),ue=t.useMemo(()=>Pr(ce,ne.effectiveSelectionHook,ne.resolvedSelection),[ce,ne.effectiveSelectionHook,ne.resolvedSelection]),de=t.useMemo(()=>cr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),he=os({componentName:"SwimlaneChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d,subcategoryAccessor:u},requiredProps:{subcategoryAccessor:u}}),{effectiveLegendProps:ge,effectiveMargin:fe}=aa({ref:n,frameRef:r,isPushMode:te,colorBy:ee,colorScheme:p,showLegend:q,legendPosition:T,setup:ne}),pe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swimlane"},null!=s&&{data:J}),{oAccessor:c,rAccessor:d,stackBy:u,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ue,size:[F,E],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:fe,barPadding:oe,enableHover:z}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:!1===W?void 0:Q,rLabel:Z,rFormat:g}),N&&{rTickValues:N}),null!=$&&{tickLabelEdgeAlign:$}),H&&{oFormat:H}),void 0!==W&&{showCategoryTicks:W}),{showGrid:G}),ge),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:nr(v)||de}),(A||S||O||M)&&{customHoverBehavior:ne.customHoverBehavior}),(S||O||A)&&{customClickBehavior:ne.customClickBehavior}),m&&m.length>0&&{annotations:m}),ie.brushStreamProps),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return he?e.jsx(Kr,{componentName:"SwimlaneChart",message:he,width:F,height:E}):e.jsx(ws,{componentName:"SwimlaneChart",width:F,height:E,children:e.jsx(dn,Object.assign({ref:r},pe))})});Pa.displayName="SwimlaneChart";const La=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o,n,i,s;const a=Array.isArray(e)?e:[e],l=null!==(n=null===(o=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==n?n:[],c=[];for(const e of a){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(s=r.current)||void 0===s||s.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var o;const n=null===(o=r.current)||void 0===o?void 0:o.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}));const s=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:g="target",nodeLabel:f,colorBy:p,colorScheme:y,nodeSize:v=8,nodeSizeRange:m=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:w=300,forceStrength:j=.1,tooltip:A,frameProps:S={},onObservation:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,emptyContent:T,legendInteraction:R,legendPosition:B,stroke:I,strokeWidth:D,opacity:H}=o,N=s.width,F=s.height,E=s.enableHover,z=s.showLegend,G=null!==(i=s.showLabels)&&void 0!==i&&i,q=s.title,X=s.description,V=s.summary,U=s.accessibleTable,K=Os(L,N,F),Q=K?null:Ss(a,N,F,T),Z=a||[],J=l||[],ee=Wr(Z,p,y),te=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Z){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[Z,p]),oe=Gr(R,p,te),ne=Nr(),ie=t.useMemo(()=>new Map,[]),re=t.useMemo(()=>{if(Array.isArray(y))return y;if(ne&&ne.length>0)return ne;const e=$[y];return Array.isArray(e)?e:W},[y,ne]),se=t.useMemo(()=>e=>{const t={};return t.fill=p?Y(e.data||e,p,ee):$r(void 0,ne,y,void 0,ie),"number"==typeof v&&(t.r=v),t},[p,ee,v,ne,y,ie]),ae=t.useMemo(()=>Ur(se,{stroke:I,strokeWidth:D,opacity:H}),[se,I,D,H]),le=t.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),ce=t.useMemo(()=>Ur(le,{stroke:I,strokeWidth:D,opacity:H}),[le,I,D,H]),ue=t.useMemo(()=>{if(G&&f)return"function"==typeof f?f:e=>{var t,o,n;return null!==(n=null!==(o=null===(t=e.data)||void 0===t?void 0:t[f])&&void 0!==o?o:e[f])&&void 0!==n?n:e.id}},[G,f]),{legend:de,margin:he,legendPosition:ge}=Yr({data:Z,colorBy:p,colorScale:ee,showLegend:z,legendPosition:B,userMargin:c,defaults:s.marginDefaults}),{customHoverBehavior:fe,customClickBehavior:pe}=Er({selection:_,linkedHover:P,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:O,onClick:M,chartType:"ForceDirectedGraph",chartId:C}),ye=is({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ye?e.jsx(Kr,{componentName:"ForceDirectedGraph",message:ye,width:N,height:F}):K||Q||e.jsx(ws,{componentName:"ForceDirectedGraph",width:N,height:F,children:e.jsx(Zi,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:Z},null!=l&&{edges:J},{size:[N,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:he,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:g,iterations:w,forceStrength:j,nodeStyle:ae,edgeStyle:ce,colorBy:p,colorScheme:re,nodeSize:v,nodeSizeRange:m,nodeLabel:ue,showLabels:G,enableHover:E,tooltipContent:!1===A?()=>null:nr(A)||void 0,customHoverBehavior:P||O||M?fe:void 0,customClickBehavior:O||M?pe:void 0,legend:de,legendPosition:ge},R&&"none"!==R&&{legendHoverBehavior:oe.onLegendHover,legendClickBehavior:oe.onLegendClick,legendHighlightedCategory:oe.highlightedCategory,legendIsolatedCategories:oe.isolatedCategories},{className:u,title:q,description:X,summary:V,accessibleTable:U},null!=o.animate&&{animate:o.animate},S))})});function Ta(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function Ra(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function Ba(e){return"function"==typeof e?e:t=>t[e]||1}function Ia({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a=Object.assign({fillOpacity:i},r);if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=Y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=Y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}La.displayName="ForceDirectedGraph";const Da=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o,n,i,s;const a=Array.isArray(e)?e:[e],l=null!==(n=null===(o=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==n?n:[],c=[];for(const e of a){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(s=r.current)||void 0===s||s.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var o;const n=null===(o=r.current)||void 0===o?void 0:o.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}));const s=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:g="value",nodeIdAccessor:f="id",colorBy:p,colorScheme:y,edgeColorBy:v="source",padAngle:m=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:j,frameProps:A={},onObservation:S,onClick:O,chartId:M,selection:C,linkedHover:_,loading:P,emptyContent:L,legendInteraction:T,stroke:R,strokeWidth:B,opacity:I}=o,D=s.width,H=s.height,N=s.enableHover,F=null===(i=s.showLabels)||void 0===i||i,E=s.title,z=s.description,G=s.summary,q=s.accessibleTable,X=Os(P,D,H),V=X?null:Ss(l,D,H,L),U=l||[],K=t.useMemo(()=>Ra(a,U,d,h),[a,U,d,h]),Q=Wr(K,p,y),Z=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of K){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[K,p]),J=Gr(T,p,Z),ee=Nr(),te=t.useMemo(()=>new Map,[]),oe=t.useMemo(()=>{if(Array.isArray(y))return y;if(ee&&ee.length>0)return ee;const e=$[y];return Array.isArray(e)?e:W},[y,ee]),ne=K.length>0,ie=t.useMemo(()=>{if(ne)return(e,t)=>{var o,n;const i={stroke:"black",strokeWidth:1};if(p)i.fill=Y(e.data||e,p,Q);else{const r=Array.isArray(y)?y:$[y]||W,s=Array.isArray(r)?r:W,a=null!==(n=null!==(o=e.index)&&void 0!==o?o:t)&&void 0!==n?n:0;i.fill=s[a%s.length]}return i}},[ne,p,Q,y]),re=t.useMemo(()=>ie?Ur(ie,{stroke:R,strokeWidth:B,opacity:I}):void 0,[ie,R,B,I]),se=t.useMemo(()=>{if(ne)return Ia({edgeColorBy:v,colorBy:p,colorScale:Q,nodeStyleFn:re||(e=>({fill:$r(void 0,ee,y,void 0,te)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[ne,v,p,Q,re,w,ee,y,te]),ae=t.useMemo(()=>se?Ur(se,{stroke:R,strokeWidth:B,opacity:I}):void 0,[se,R,B,I]),le=t.useMemo(()=>{if(!F)return;const e=k||f;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[F,k,f]),ce=Object.assign(Object.assign({},s.marginDefaults),"number"==typeof c?{top:c,bottom:c,left:c,right:c}:c),{customHoverBehavior:ue,customClickBehavior:de}=Er({selection:C,linkedHover:_,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:S,onClick:O,chartType:"ChordDiagram",chartId:M}),he=is({componentName:"ChordDiagram",edges:l,edgesRequired:!0});return he?e.jsx(Kr,{componentName:"ChordDiagram",message:he,width:D,height:H}):X||V||e.jsx(ws,{componentName:"ChordDiagram",width:D,height:H,children:e.jsx(Zi,Object.assign({ref:r,chartType:"chord"},K.length>0&&{nodes:K},null!=l&&{edges:U},{size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ce,nodeIDAccessor:f,sourceAccessor:d,targetAccessor:h,valueAccessor:g,padAngle:m,groupWidth:b,sortGroups:x,nodeStyle:re,edgeStyle:ae,colorBy:p,colorScheme:oe,edgeColorBy:v,edgeOpacity:w,nodeLabel:le,showLabels:F,enableHover:N,tooltipContent:!1===j?()=>null:nr(j)||void 0,customHoverBehavior:_||S||O?ue:void 0,customClickBehavior:S||O?de:void 0},T&&"none"!==T&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories},{className:u,title:E,description:z,summary:G,accessibleTable:q},null!=o.animate&&{animate:o.animate},A))})});Da.displayName="ChordDiagram";const Ha=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o,n,i,s;const a=Array.isArray(e)?e:[e],l=null!==(n=null===(o=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==n?n:[],c=[];for(const e of a){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(s=r.current)||void 0===s||s.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var o;const n=null===(o=r.current)||void 0===o?void 0:o.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}));const s=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:800,height:600}),{nodes:a,edges:l,margin:c,className:u,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:g="value",nodeIdAccessor:f="id",colorBy:p,colorScheme:y,edgeColorBy:v="source",orientation:m="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:j=.5,edgeSort:A,tooltip:S,frameProps:O={},onObservation:M,onClick:C,chartId:_,selection:P,linkedHover:L,loading:T,emptyContent:R,legendInteraction:B,stroke:I,strokeWidth:D,opacity:H}=o,N=s.width,F=s.height,E=s.enableHover,z=null===(i=s.showLabels)||void 0===i||i,G=s.title,q=s.description,X=s.summary,V=s.accessibleTable,U=Os(T,N,F),K=U?null:Ss(l,N,F,R),Q=l||[],Z=t.useMemo(()=>Ra(a,Q,d,h),[a,Q,d,h]),J=Wr(Z,p,y),ee=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Z){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[Z,p]),te=Gr(B,p,ee),oe=Nr(),ne=t.useMemo(()=>new Map,[]),ie=t.useMemo(()=>{if(Array.isArray(y))return y;if(oe&&oe.length>0)return oe;const e=$[y];return Array.isArray(e)?e:W},[y,oe]),re=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?Y(e.data||e,p,J):$r(void 0,oe,y,void 0,ne),t},[p,J,oe,y,ne]),se=t.useMemo(()=>Ur(re,{stroke:I,strokeWidth:D,opacity:H}),[re,I,D,H]),ae=t.useMemo(()=>Ia({edgeColorBy:v,colorBy:p,colorScale:J,nodeStyleFn:se,edgeOpacity:j,baseStyle:{stroke:"none",strokeWidth:0}}),[v,p,J,se,j]),le=t.useMemo(()=>Ur(ae,{stroke:I,strokeWidth:D,opacity:H}),[ae,I,D,H]),ce=t.useMemo(()=>{if(!z)return;const e=w||f;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[z,w,f]),ue=Object.assign(Object.assign({},s.marginDefaults),"number"==typeof c?{top:c,bottom:c,left:c,right:c}:c),{customHoverBehavior:de,customClickBehavior:he}=Er({selection:P,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:M,onClick:C,chartType:"SankeyDiagram",chartId:_}),ge=is({componentName:"SankeyDiagram",edges:l,edgesRequired:!0});return ge?e.jsx(Kr,{componentName:"SankeyDiagram",message:ge,width:N,height:F}):U||K||e.jsx(ws,{componentName:"SankeyDiagram",width:N,height:F,children:e.jsx(Zi,Object.assign({ref:r,chartType:"sankey"},Z.length>0&&{nodes:Z},null!=l&&{edges:Q},{size:[N,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ue,nodeIDAccessor:f,sourceAccessor:d,targetAccessor:h,valueAccessor:g,orientation:m,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:se,edgeStyle:le,colorBy:p,colorScheme:ie,edgeColorBy:v,edgeOpacity:j,edgeSort:A,nodeLabel:ce,showLabels:z,enableHover:E,tooltipContent:!1===S?()=>null:nr(S)||void 0,customHoverBehavior:L||M||C?de:void 0,customClickBehavior:M||C?he:void 0},B&&"none"!==B&&{legendHoverBehavior:te.onLegendHover,legendClickBehavior:te.onLegendClick,legendHighlightedCategory:te.highlightedCategory,legendIsolatedCategories:te.isolatedCategories},{className:u,title:G,description:q,summary:X,accessibleTable:V},null!=o.animate&&{animate:o.animate},O))})});function Na(o){var n;const i=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:r,margin:s,className:a,layout:l="tree",orientation:c="vertical",childrenAccessor:u="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:f,colorByDepth:p=!1,edgeStyle:y="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,onClick:w,chartId:j,selection:A,linkedHover:S,loading:O,legendInteraction:M,stroke:C,strokeWidth:_,opacity:P}=o,L=i.width,T=i.height,R=i.enableHover,B=null===(n=i.showLabels)||void 0===n||n,I=i.title,D=i.description,H=i.summary,N=i.accessibleTable,F=Os(O,L,T),z=t.useMemo(()=>Ta(null!=r?r:null,u),[r,u]),G=Wr(z,p?void 0:g,f),q=t.useMemo(()=>{if(!g||p)return[];const e=new Set;for(const t of z){const o="function"==typeof g?g(t):t[g];null!=o&&e.add(o+"")}return Array.from(e)},[z,g,p]),X=Gr(M,p?void 0:g,q),V=Nr(),U=t.useMemo(()=>new Map,[]),K=t.useMemo(()=>{if(Array.isArray(f))return f;if(V&&V.length>0)return V;const e=$[f];return Array.isArray(e)?e:W},[f,V]),Q=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?E[(e.depth||0)%E.length]:g?Y(e.data||e,g,G):$r(void 0,V,f,void 0,U),t},[g,p,G,V,f,U]),Z=t.useMemo(()=>Ur(Q,{stroke:C,strokeWidth:_,opacity:P}),[Q,C,_,P]),J=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),ee=t.useMemo(()=>Ur(J,{stroke:C,strokeWidth:_,opacity:P}),[J,C,_,P]),te=t.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return Ba(d)},[l,d]),oe=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof s?{top:s,bottom:s,left:s,right:s}:s),{customHoverBehavior:ne,customClickBehavior:ie}=Er({selection:A,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:k,onClick:w,chartType:"TreeDiagram",chartId:j}),re=ns({componentName:"TreeDiagram",data:r});return re?e.jsx(Kr,{componentName:"TreeDiagram",message:re,width:L,height:T}):F||e.jsx(ws,{componentName:"TreeDiagram",width:L,height:T,children:e.jsx(Zi,Object.assign({chartType:l},null!=r&&{data:r},{size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:oe,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:te,treeOrientation:c,edgeType:y,nodeStyle:Z,edgeStyle:ee,colorBy:g,colorScheme:K,colorByDepth:p,nodeSize:m,nodeLabel:B?v||h:void 0,showLabels:B,enableHover:R,tooltipContent:!1===b?()=>null:nr(b)||void 0,customHoverBehavior:S||k||w?ne:void 0,customClickBehavior:k||w?ie:void 0},M&&"none"!==M&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:a,title:I,description:D,summary:H,accessibleTable:N},null!=o.animate&&{animate:o.animate},x))})}function $a(o){var n;const i=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover},{width:600,height:600}),{data:r,margin:s,className:a,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h,colorByDepth:g=!1,labelMode:f="leaf",nodeLabel:p,padding:y=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,chartId:A,loading:S,legendInteraction:O,stroke:M,strokeWidth:C,opacity:_}=o,P=i.width,L=i.height,T=i.enableHover,R=null===(n=i.showLabels)||void 0===n||n,B=i.title,I=i.description,D=i.summary,H=i.accessibleTable,N=Os(S,P,L),{activeSelectionHook:F,customHoverBehavior:z,customClickBehavior:G}=Er({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,onClick:j,chartType:"Treemap",chartId:A}),q=Cs(x),X=t.useCallback(e=>{if(!e)return z(null);const t=e.data||e;z({data:(null==t?void 0:t.data)||t})},[z]),V=t.useMemo(()=>Ta(null!=r?r:null,l),[r,l]),U=Wr(V,g?void 0:d,h),K=t.useMemo(()=>{if(!d||g)return[];const e=new Set;for(const t of V){const o="function"==typeof d?d(t):t[d];null!=o&&e.add(o+"")}return Array.from(e)},[V,d,g]),Q=Gr(O,g?void 0:d,K),Z=Nr(),J=t.useMemo(()=>new Map,[]),ee=t.useMemo(()=>{if(Array.isArray(h))return h;if(Z&&Z.length>0)return Z;const e=$[h];return Array.isArray(e)?e:W},[h,Z]),te=t.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=g?E[(e.depth||0)%E.length]:d?Y(e.data||e,d,U):$r(void 0,Z,h,void 0,J),t},[d,g,U,Z,h,J]),oe=t.useMemo(()=>Ur(te,{stroke:M,strokeWidth:C,opacity:_}),[te,M,C,_]),ne=t.useMemo(()=>F?e=>{var t;const o=Object.assign({},oe(e));if(F.isActive)if(F.predicate(e.data||e))(null==q?void 0:q.selectedStyle)&&Object.assign(o,q.selectedStyle);else{const e=null!==(t=null==q?void 0:q.unselectedOpacity)&&void 0!==t?t:.5;o.opacity=e,o.fillOpacity=e,o.strokeOpacity=e,(null==q?void 0:q.unselectedStyle)&&Object.assign(o,q.unselectedStyle)}return o}:oe,[oe,F,q]),ie=t.useMemo(()=>Ba(c),[c]),re=void 0!==v?v:!R||"parent"!==f&&"all"!==f?void 0:18,se=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof s?{top:s,bottom:s,left:s,right:s}:s),ae=ns({componentName:"Treemap",data:r});return ae?e.jsx(Kr,{componentName:"Treemap",message:ae,width:P,height:L}):N||e.jsx(ws,{componentName:"Treemap",width:P,height:L,children:e.jsx(Zi,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[P,L],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:se,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:ie,padding:y,paddingTop:re,nodeStyle:ne,colorBy:d,colorScheme:ee,colorByDepth:g,nodeLabel:R?p||u:void 0,showLabels:R,labelMode:f,enableHover:T,tooltipContent:!1===m?()=>null:nr(m)||void 0},(k||w||j)&&{customHoverBehavior:X},(w||j)&&{customClickBehavior:G},O&&"none"!==O&&{legendHoverBehavior:Q.onLegendHover,legendClickBehavior:Q.onLegendClick,legendHighlightedCategory:Q.highlightedCategory,legendIsolatedCategories:Q.isolatedCategories},{className:a,title:B,description:I,summary:D,accessibleTable:H},null!=o.animate&&{animate:o.animate},b))})}function Wa(o){var n;const i=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:r,margin:s,className:a,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h,colorByDepth:g=!1,nodeLabel:f,circleOpacity:p=.7,padding:y=4,tooltip:v,frameProps:m={},onObservation:b,onClick:x,chartId:k,selection:w,linkedHover:j,loading:A,legendInteraction:S,stroke:O,strokeWidth:M,opacity:C}=o,_=i.width,P=i.height,L=i.enableHover,T=null===(n=i.showLabels)||void 0===n||n,R=i.title,B=i.description,I=i.summary,D=i.accessibleTable,H=Os(A,_,P),N=t.useMemo(()=>Ta(null!=r?r:null,l),[r,l]),F=Wr(N,g?void 0:d,h),z=t.useMemo(()=>{if(!d||g)return[];const e=new Set;for(const t of N){const o="function"==typeof d?d(t):t[d];null!=o&&e.add(o+"")}return Array.from(e)},[N,d,g]),G=Gr(S,g?void 0:d,z),q=Nr(),X=t.useMemo(()=>new Map,[]),V=t.useMemo(()=>{if(Array.isArray(h))return h;if(q&&q.length>0)return q;const e=$[h];return Array.isArray(e)?e:W},[h,q]),U=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:p};return t.fill=g?E[(e.depth||0)%E.length]:d?Y(e.data||e,d,F):$r(void 0,q,h,void 0,X),t},[d,g,F,p,q,h,X]),K=t.useMemo(()=>Ur(U,{stroke:O,strokeWidth:M,opacity:C}),[U,O,M,C]),Q=t.useMemo(()=>Ba(c),[c]),Z=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof s?{top:s,bottom:s,left:s,right:s}:s),{customHoverBehavior:J,customClickBehavior:ee}=Er({selection:w,linkedHover:j,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),te=ns({componentName:"CirclePack",data:r});return te?e.jsx(Kr,{componentName:"CirclePack",message:te,width:_,height:P}):H||e.jsx(ws,{componentName:"CirclePack",width:_,height:P,children:e.jsx(Zi,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[_,P],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:Q,padding:y,nodeStyle:K,colorBy:d,colorScheme:V,colorByDepth:g,nodeLabel:T?f||u:void 0,showLabels:T,enableHover:L,tooltipContent:!1===v?()=>null:nr(v)||void 0,customHoverBehavior:j||b||x?J:void 0,customClickBehavior:b||x?ee:void 0},S&&"none"!==S&&{legendHoverBehavior:G.onLegendHover,legendClickBehavior:G.onLegendClick,legendHighlightedCategory:G.highlightedCategory,legendIsolatedCategories:G.isolatedCategories},{className:a,title:R,description:B,summary:I,accessibleTable:D},null!=o.animate&&{animate:o.animate},m))})}Ha.displayName="SankeyDiagram",Na.displayName="TreeDiagram",$a.displayName="Treemap",Wa.displayName="CirclePack";const Fa=E;function Ea(o){const n=Xr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:g=2.95,speed:f=.25,revolution:p,revolutionStyle:y,eccentricity:v=1,showRings:m=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:j,annotations:A,frameProps:S={},onObservation:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,stroke:T,strokeWidth:R,opacity:B}=o,I=n.width,D=n.height,H=n.enableHover,N=n.title,F=n.description,E=n.summary,z=n.accessibleTable,G=Os(L,I,D),q=Wr(t.useMemo(()=>Ta(i,a),[i,a]),d?void 0:c,u),X=Nr(),V=t.useMemo(()=>new Map,[]),U=t.useMemo(()=>{if(Array.isArray(u))return u;if(X&&X.length>0)return X;const e=$[u];return Array.isArray(e)?e:W},[u,X]),K=t.useMemo(()=>{if(Array.isArray(u))return u;const e=$[u];return Array.isArray(e)?e:W},[u]),Q=t.useMemo(()=>e=>{var t;const o={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return o.fill=d?n?K[0]:Fa[(e.depth||0)%Fa.length]:c?Y(e.data||e,c,q):$r(void 0,X,u,void 0,V),o.opacity=n?1:.85,o},[c,d,q,K,X,u,V]),Z=t.useMemo(()=>Ur(Q,{stroke:T,strokeWidth:R,opacity:B}),[Q,T,R,B]),J=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),ee=Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof r?{top:r,bottom:r,left:r,right:r}:r),{customHoverBehavior:te,customClickBehavior:oe}=Er({selection:_,linkedHover:P,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:O,onClick:M,chartType:"OrbitDiagram",chartId:C}),ne=t.useMemo(()=>{if(te)return e=>{te(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[te]),ie=t.useMemo(()=>{if(oe)return e=>{oe(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[oe]),re=ns({componentName:"OrbitDiagram",data:i});return re?e.jsx(Kr,{componentName:"OrbitDiagram",message:re,width:I,height:D}):G||e.jsx(ws,{componentName:"OrbitDiagram",width:I,height:D,children:e.jsx(Zi,Object.assign({chartType:"orbit"},null!=i&&{data:i},{size:[I,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ee,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:Z,edgeStyle:J,colorBy:c,colorScheme:U,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&H,tooltipContent:k?void 0:!1===w?()=>null:nr(w)||void 0,customHoverBehavior:P||O||M?ne:void 0,customClickBehavior:O||M?ie:void 0,foregroundGraphics:j,annotations:A,className:s,title:N,description:F,summary:E,orbitMode:h,orbitSize:g,orbitSpeed:f,orbitRevolution:p,orbitRevolutionStyle:y,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k,accessibleTable:z},null!=o.animate&&{animate:o.animate},S))})}Ea.displayName="OrbitDiagram";const za=t.forwardRef(function(o,n){var i,r,s,a;const l=Xr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,timeExtent:m,valueExtent:b,extentPadding:x,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:j,opacity:A,background:S,tooltipContent:O,tooltip:M,onHover:C,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,transition:D,linkedHover:H,selection:N,onObservation:$,chartId:W,loading:F,emptyContent:E,emphasis:z,legendPosition:Y}=o,G=l.showAxes,q=l.enableHover,X=null!=u?u:l.marginDefaults,V=null!=c?c:[l.width,l.height],U=null!=O?O:M,K=t.useRef(null),{customHoverBehavior:Q}=Er({selection:N,linkedHover:H,unwrapData:!0,onObservation:$,chartType:"RealtimeLineChart",chartId:W}),Z=t.useCallback(e=>{C&&C(e),Q(e)},[C,Q]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=K.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=K.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=K.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const J=Os(F,V[0],V[1]),ee=J?null:Ss(p,V[0],V[1],E),te={stroke:k,strokeWidth:w,strokeDasharray:j};return null!=A&&(te.opacity=A),J||ee||e.jsx(Lo,{ref:K,chartType:"line",runtimeMode:"streaming",size:V,margin:X,className:z?`${d||""} semiotic-emphasis-${z}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,xExtent:m,yExtent:b,extentPadding:x,lineStyle:te,showAxes:G,background:S,hoverAnnotation:q,tooltipContent:U,customHoverBehavior:Z,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,transition:D,pointIdAccessor:o.pointIdAccessor,legendPosition:Y})});za.displayName="RealtimeLineChart";const Ya=t.forwardRef(function(o,n){var i,r,s,a;const l=Xr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,showAxes:o.showAxes,enableHover:null!=o.enableHover?!!o.enableHover:void 0,linkedHover:o.linkedHover}),{binSize:c,size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p=200,data:y,timeAccessor:v,valueAccessor:m,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:j,fill:A,stroke:S,strokeWidth:O,opacity:M,gap:C,background:_,tooltipContent:P,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,linkedHover:H,selection:N,decay:$,pulse:W,staleness:F,transition:E,onObservation:z,chartId:Y,loading:G,emptyContent:q,emphasis:X,legendPosition:V,brush:U,onBrush:K,linkedBrush:Q}=o,Z=l.showAxes,J=l.enableHover,ee=null!=d?d:l.marginDefaults,te=null!=u?u:[l.width,l.height],oe=null!=P?P:L,ne=t.useRef(null),{customHoverBehavior:ie}=Er({selection:N,linkedHover:H,unwrapData:!0,onObservation:z,chartType:"RealtimeTemporalHistogram",chartId:Y}),re=t.useCallback(e=>{T&&T(e),ie(e)},[T,ie]),se=!0===U?{dimension:"x",snap:"bin"}:"x"===U?{dimension:"x"}:"object"==typeof U?U:void 0,ae=_r(Q),le=wr(Object.assign({name:(null==ae?void 0:ae.name)||"__unused_hist_brush__",xField:(null==ae?void 0:ae.xField)||("string"==typeof v?v:"time")},(null==ae?void 0:ae.yField)?{yField:ae.yField}:{})),ce=t.useRef(le.brushInteraction);ce.current=le.brushInteraction;const ue=t.useCallback(e=>{if(K&&K(e),z&&z(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}),ae){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[K,z,Y,ae]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=ne.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=ne.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const de=Os(G,te[0],te[1]),he=de?null:Ss(y,te[0],te[1],q),ge={};return null!=A&&(ge.fill=A),null!=S&&(ge.stroke=S),null!=O&&(ge.strokeWidth=O),null!=M&&(ge.opacity=M),null!=C&&(ge.gap=C),de||he||e.jsx(Lo,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:te,margin:ee,className:X?`${h||""} semiotic-emphasis-${X}`.trim():h,arrowOfTime:g,windowMode:f,windowSize:p,data:y,timeAccessor:v,valueAccessor:m,xExtent:b,yExtent:x,extentPadding:k,binSize:c,categoryAccessor:w,barColors:j,barStyle:ge,showAxes:Z,background:_,hoverAnnotation:J,tooltipContent:oe,customHoverBehavior:re,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,decay:$,pulse:W,staleness:F,transition:E,pointIdAccessor:o.pointIdAccessor,legendPosition:V,brush:se||(Q?{dimension:"x"}:void 0),onBrush:se||Q?ue:void 0})});Ya.displayName="RealtimeTemporalHistogram";const Ga=Ya,qa=t.forwardRef(function(o,n){var i,r,s,a;const l=Xr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,timeExtent:m,valueExtent:b,extentPadding:x,categoryAccessor:k,colors:w,radius:j,fill:A,opacity:S,stroke:O,strokeWidth:M,background:C,tooltipContent:_,tooltip:P,onHover:L,annotations:T,svgAnnotationRules:R,tickFormatTime:B,tickFormatValue:I,linkedHover:D,selection:H,onObservation:N,chartId:$,loading:W,emptyContent:F,emphasis:E,legendPosition:z}=o,Y=l.showAxes,G=l.enableHover,q=null!=u?u:l.marginDefaults,X=null!=c?c:[l.width,l.height],V=null!=_?_:P,U=t.useRef(null),{customHoverBehavior:K}=Er({selection:H,linkedHover:D,unwrapData:!0,onObservation:N,chartType:"RealtimeSwarmChart",chartId:$}),Q=t.useCallback(e=>{L&&L(e),K(e)},[L,K]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=U.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Z=Os(W,X[0],X[1]),J=Z?null:Ss(p,X[0],X[1],F),ee={};return null!=j&&(ee.radius=j),null!=A&&(ee.fill=A),null!=S&&(ee.opacity=S),null!=O&&(ee.stroke=O),null!=M&&(ee.strokeWidth=M),Z||J||e.jsx(Lo,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:X,margin:q,className:E?`${d||""} semiotic-emphasis-${E}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,xExtent:m,yExtent:b,extentPadding:x,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:Y,background:C,hoverAnnotation:G,tooltipContent:V,customHoverBehavior:Q,annotations:T,svgAnnotationRules:R,tickFormatTime:B,tickFormatValue:I,legendPosition:z,pointIdAccessor:o.pointIdAccessor})});qa.displayName="RealtimeSwarmChart";const Xa=t.forwardRef(function(o,n){var i,r,s,a;const l=Xr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,timeExtent:m,valueExtent:b,extentPadding:x,positiveColor:k,negativeColor:w,connectorStroke:j,connectorWidth:A,gap:S,stroke:O,strokeWidth:M,opacity:C,background:_,tooltipContent:P,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,linkedHover:H,selection:N,onObservation:$,chartId:W,loading:F,emptyContent:E,emphasis:z,legendPosition:Y}=o,G=l.showAxes,q=l.enableHover,X=null!=u?u:l.marginDefaults,V=null!=c?c:[l.width,l.height],U=null!=P?P:L,K=t.useRef(null),{customHoverBehavior:Q}=Er({selection:N,linkedHover:H,unwrapData:!0,onObservation:$,chartType:"RealtimeWaterfallChart",chartId:W}),Z=t.useCallback(e=>{T&&T(e),Q(e)},[T,Q]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=K.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=K.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=K.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const J=Os(F,V[0],V[1]),ee=J?null:Ss(p,V[0],V[1],E),te={};return null!=k&&(te.positiveColor=k),null!=w&&(te.negativeColor=w),null!=j&&(te.connectorStroke=j),null!=A&&(te.connectorWidth=A),null!=S&&(te.gap=S),null!=O&&(te.stroke=O),null!=M&&(te.strokeWidth=M),null!=C&&(te.opacity=C),J||ee||e.jsx(Lo,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:X,className:z?`${d||""} semiotic-emphasis-${z}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,xExtent:m,yExtent:b,extentPadding:x,waterfallStyle:te,showAxes:G,background:_,hoverAnnotation:q,tooltipContent:U,customHoverBehavior:Z,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,legendPosition:Y,pointIdAccessor:o.pointIdAccessor})});Xa.displayName="RealtimeWaterfallChart";const Va=t.forwardRef(function(o,n){var i,r,s,a;const l=Xr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,categoryAccessor:m,timeExtent:b,valueExtent:x,extentPadding:k,heatmapXBins:w=20,heatmapYBins:j=20,aggregation:A="count",background:S,tooltipContent:O,tooltip:M,onHover:C,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,linkedHover:D,selection:H,onObservation:N,chartId:$,loading:W,emptyContent:F,emphasis:E,legendPosition:z}=o,Y=l.showAxes,G=l.enableHover,q=null!=u?u:l.marginDefaults,X=null!=c?c:[l.width,l.height],V=null!=O?O:M,U=t.useRef(null),{customHoverBehavior:K}=Er({selection:H,linkedHover:D,unwrapData:!0,onObservation:N,chartType:"RealtimeHeatmap",chartId:$}),Q=t.useCallback(e=>{C&&C(e),K(e)},[C,K]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=U.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Z=Os(W,X[0],X[1]),J=Z?null:Ss(p,X[0],X[1],F);return Z||J||e.jsx(Lo,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:q,className:E?`${d||""} semiotic-emphasis-${E}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,categoryAccessor:m,xExtent:b,yExtent:x,extentPadding:k,heatmapXBins:w,heatmapYBins:j,heatmapAggregation:A,showAxes:Y,background:S,hoverAnnotation:G,tooltipContent:V,customHoverBehavior:Q,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,legendPosition:z,pointIdAccessor:o.pointIdAccessor})});Va.displayName="RealtimeHeatmap";const Ua=864e5;function Ka(e){return 10>e?"0"+e:e+""}const Qa=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Za(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)*(1-t)),i=Math.round(parseInt(o[2],16)*(1-t)),r=Math.round(parseInt(o[3],16)*(1-t));return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function Ja(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*t),i=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*t),r=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*t);return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function el(e,t){return Rs(this,void 0,void 0,function*(){const{format:o="png",filename:n="chart",scale:i=2,background:r="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const a=s.cloneNode(!0),l=s.getBoundingClientRect();if(a.getAttribute("width")||a.setAttribute("width",l.width+""),a.getAttribute("height")||a.setAttribute("height",l.height+""),a.getAttribute("xmlns")||a.setAttribute("xmlns","http://www.w3.org/2000/svg"),tl(s,a),"svg"===o){const e=(new XMLSerializer).serializeToString(a);ol(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const t=l.width*i,o=l.height*i,s=document.createElement("canvas");s.width=t,s.height=o;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,o),c.scale(i,i);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(a),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),s.toBlob(o=>{o?(ol(o,n+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function tl(e,t){var o;const n=e.children,i=t.children,r=window.getComputedStyle(e),s=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of s){const n=r.getPropertyValue(e);n&&"none"!==n&&""!==n&&(null===(o=t.style)||void 0===o||o.setProperty(e,n))}for(let e=0;Math.min(n.length,i.length)>e;e++)tl(n[e],i[e])}function ol(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}const nl=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),il=new Set(["data","nodes","edges"]),rl="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function sl(e){return Rs(this,arguments,void 0,function*(e,t="json"){const o="jsx"===t?al(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(o)})}function al(e){const{component:t,props:o}=e,n=["<"+t];for(const[e,t]of Object.entries(o))if("string"==typeof t)n.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)n.push(" "+e);else if("boolean"==typeof t&&!1===t)n.push(` ${e}={false}`);else if("number"==typeof t)n.push(` ${e}={${t}}`);else{const o=JSON.stringify(t);n.push(80>o.length?` ${e}={${o}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return n.push("/>"),n.join("\n")}function ll(e){return"nominal"===e||"ordinal"===e}function cl(e){return"quantitative"===e||"temporal"===e}const ul={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},dl={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},hl={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function gl(e,t,o,n,i){var r,s;(null==e?void 0:e.field)&&(o.xAccessor=n?"value":e.field),(null==t?void 0:t.field)&&(o.yAccessor=i?"value":t.field),(null===(r=null==e?void 0:e.axis)||void 0===r?void 0:r.title)&&(o.xLabel=e.axis.title),(null===(s=null==t?void 0:t.axis)||void 0===s?void 0:s.title)&&(o.yLabel=t.axis.title)}function fl(e,t,o){const n={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(o.length>0){n.warnings=o;for(const e of o)console.warn("[semiotic/fromVegaLite] "+e)}return n}function pl(){const t=function(){const e=y.useContext(kt);return e?()=>e.setVisible(e=>!e):null}();return t?e.jsx("button",{className:"semiotic-chart-action",onClick:t,title:"Data summary","aria-label":"Toggle data summary",style:xl,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}const yl={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function vl({height:t}){return e.jsx("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:t,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function ml({error:t}){return e.jsx("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:e.jsx("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:t})})}const bl=y.forwardRef(function({title:t,subtitle:o,children:n,width:i="100%",height:r=400,actions:s,chartConfig:a,controls:l,loading:c=!1,error:u,errorBoundary:d=!1,status:h,detailsPanel:g,className:f,style:p},v){const m=y.useRef(null),b=y.useRef(null),[x,k]=y.useState(!1),w=!1!==(null==s?void 0:s.export)&&void 0!==(null==s?void 0:s.export),j=!1!==(null==s?void 0:s.fullscreen)&&void 0!==(null==s?void 0:s.fullscreen),A=!1!==(null==s?void 0:s.copyConfig)&&void 0!==(null==s?void 0:s.copyConfig)&&a,S=!0===(null==s?void 0:s.dataSummary),O="object"==typeof(null==s?void 0:s.export)?s.export:{},M="object"==typeof(null==s?void 0:s.copyConfig)?s.copyConfig.format:"json",C=y.useCallback(e=>Rs(this,void 0,void 0,function*(){b.current&&(yield el(b.current,Object.assign(Object.assign({},O),e)))}),[O]),_=y.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),P=y.useCallback(e=>Rs(this,void 0,void 0,function*(){a&&(yield sl(a,e||M||"json"))}),[a,M]);y.useEffect(()=>{const e=()=>{k(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),y.useImperativeHandle(v,()=>({export:C,toggleFullscreen:_,copyConfig:P,element:m.current}),[C,_,P]);const L=t||o||l||w||j||A||S||h,T=c?e.jsx(vl,{height:r}):u?e.jsx(ml,{error:u}):d?e.jsx(Qr,{children:n}):n;return R=e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),e.jsxs("div",{ref:m,className:"semiotic-chart-container"+(f?" "+f:""),style:Object.assign(Object.assign({width:i,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative"},x?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),p),children:[L&&e.jsxs("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[e.jsxs("div",{className:"semiotic-chart-title-area",children:[t&&e.jsx("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:t}),o&&e.jsx("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0},children:o})]}),e.jsxs("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4},children:[l,w&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>C(),title:"Export chart","aria-label":"Export chart",style:xl,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),e.jsx("path",{d:"M2 12h10"})]})}),S&&e.jsx(pl,{}),j&&e.jsx("button",{className:"semiotic-chart-action",onClick:_,title:x?"Exit fullscreen":"Fullscreen","aria-label":x?"Exit fullscreen":"Enter fullscreen",style:xl,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsxs(e.Fragment,x?{children:[e.jsx("path",{d:"M9 1v4h4"}),e.jsx("path",{d:"M5 13V9H1"}),e.jsx("path",{d:"M13 5H9V1"}),e.jsx("path",{d:"M1 9h4v4"})]}:{children:[e.jsx("path",{d:"M1 5V1h4"}),e.jsx("path",{d:"M13 9v4H9"}),e.jsx("path",{d:"M9 1h4v4"}),e.jsx("path",{d:"M5 13H1V9"})]})})}),A&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>P(),title:"Copy config","aria-label":"Copy chart configuration",style:xl,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),e.jsx("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),h&&e.jsx("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:yl[h].bg,color:yl[h].color,lineHeight:"18px"},children:h})]})]}),e.jsxs("div",{className:"semiotic-chart-body",ref:b,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},x?{flex:1}:{height:r}),children:[T,g]})]})]}),S?e.jsx(wt,{children:R}):R;var R}),xl={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function kl({children:t,columns:o="auto",minCellWidth:n=300,gap:i=16,className:r,style:s}){const a="number"==typeof o?o:void 0;return e.jsx("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===o?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${o}, 1fr)`,gap:i,width:"100%"},s),children:y.Children.map(t,t=>y.isValidElement(t)?"primary"!==t.props.emphasis||void 0!==a&&2>a?t:e.jsx("div",{style:{gridColumn:"span 2"},children:t}):t)})}function wl({children:t,context:o,position:n="right",contextSize:i=250,gap:r=12,className:s,style:a}){const l="left"===n||"right"===n,c="left"===n||"top"===n,u=Object.assign({display:"flex",flexDirection:l?c?"row-reverse":"row":c?"column-reverse":"column",gap:r,width:"100%"},a),d=l?{flex:`0 0 ${i}px`,width:i,minHeight:0}:{flex:`0 0 ${i}px`,height:i,minWidth:0};return e.jsxs("div",{className:"semiotic-context-layout"+(s?" "+s:""),style:u,children:[e.jsx("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:t}),e.jsx("div",{style:d,children:o})]})}kl.displayName="ChartGrid",wl.displayName="ContextLayout";function jl({children:o,position:n="right",size:i=300,trigger:r="click",chartId:s,observation:a,dismissOnEmpty:l=!0,showClose:c=!0,onToggle:u,className:d,style:h}){const[g,f]=t.useState(null),[p,y]=t.useState(null),[v,m]=t.useState(!1),[b,x]=t.useState(!1),k=t.useRef(null),w=t.useRef(void 0),j="click"===r?["click","click-end"]:["hover","hover-end"],{latest:A}=jr({types:j,chartId:s,limit:1}),S=void 0!==a?a:A;t.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;f(e.datum),y(e),v||(m(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!l||"click-end"!==S.type&&"hover-end"!==S.type||O()},[S]),t.useEffect(()=>{null==u||u(v)},[v,u]);const O=t.useCallback(()=>{x(!0),m(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),f(null),y(null)},200)},[]);if(t.useEffect(()=>()=>clearTimeout(w.current),[]),!g&&!b)return null;const M=g&&p?o(g,p):null;if(null===M&&!b)return null;const C=function(e,t,o,n){const i={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:n?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},i),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:o?"translateX(0)":`translateX(${t}px)`,opacity:o?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:o?"translateY(0)":`translateY(${t}px)`,opacity:o?1:0}:{top:"50%",left:"50%",transform:o?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:o?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,i,v,b);return e.jsxs("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${d?" "+d:""}`,style:Object.assign(Object.assign({},C),h),children:[c&&e.jsx("button",{className:"semiotic-details-close",onClick:O,"aria-label":"Close details",style:Al,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:M})]})}const Al={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};jl.displayName="DetailsPanel";const Sl="__forecastSegment";function Ol(e,t){return"function"==typeof t?t(e):!!e[t]}const Ml=Object.freeze({__proto__:null,SEGMENT_FIELD:Sl,buildAnomalyAnnotations:function(e){var t,o,n;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(o=e.bandOpacity)&&void 0!==o?o:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(n=e.anomalyRadius)&&void 0!==n?n:6,label:e.label}]},buildForecast:function(e,t,o,n,i){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,o,n,i){var r,s,a,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:v=6,label:m}=n,b=e.map(e=>{let t="observed";return u&&Ol(e,u)?t="forecast":c&&Ol(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Sl]:t})}),x=n._groupBy,k=[];if(x){const e=new Map;for(const t of b){const o=null!==(r=t[x])&&void 0!==r?r:"__default";e.has(o)||e.set(o,[]),e.get(o).push(t)}const t=[];for(const[,o]of e)for(let e=0;o.length-1>e;e++)o[e][Sl]!==o[e+1][Sl]&&(t.push(Object.assign(Object.assign({},o[e+1]),{[Sl]:o[e][Sl]})),t.push(Object.assign(Object.assign({},o[e]),{[Sl]:o[e+1][Sl]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Sl]!==b[e+1][Sl]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Sl]:b[e][Sl]})),k.push(Object.assign(Object.assign({},b[e]),{[Sl]:b[e+1][Sl]})));if(n.trainUnderline){const e=[];for(const t of k)"training"===t[Sl]&&e.push(Object.assign(Object.assign({},t),{[Sl]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const o of k)"function"==typeof h&&(o[e]=h(o)),"function"==typeof g&&(o[t]=g(o));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:m})}if(d){const e=n.anomalyStyle,t={type:"highlight",filter:e=>Ol(e,d)};e?(t.style=e,t.r=v):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=v):(t.color=y,t.r=v,t.style={stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}),w.push(t)}return i&&w.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(a=i.bandOpacity)&&void 0!==a?a:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:k,annotations:w}}(e,0,0,n,i):function(e,t,o,n,i){var r,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=n;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const o of e)o[t]>l?p.push(Object.assign(Object.assign({},o),{[Sl]:"observed"})):f.push(Object.assign(Object.assign({},o),{[Sl]:"training"}));const y=f.map(e=>[e[t],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),v=[],m=[];if(y.length>=3){const n=y.length;let i=0,r=0,s=0,a=0;for(const[e,t]of y)i+=e,r+=t,s+=e*e,a+=e*t;const l=n*s-i*i;if(Math.abs(l)>1e-12){const s=(n*a-i*r)/l,f=(r-s*i)/n,p=e=>f+s*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(n-2,1)),k=y.reduce((e,t)=>e+t[0],0)/n,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),j=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,A=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...A),O=y.length>1?(y[n-1][0]-y[0][0])/(n-1):1;for(let e=1;c>=e;e++){const i=S+e*O,r=p(i),s=x*Math.sqrt(1+1/n+(w>0?Math.pow(i-k,2)/w:0))*j;m.push({[t]:i,[o]:r,[Sl]:"forecast",__forecastUpper:r+s,__forecastLower:r-s})}v.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}v.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&v.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(s=i.bandOpacity)&&void 0!==s?s:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(a=i.anomalyRadius)&&void 0!==a?a:6,label:i.label});const b=[];if(b.push(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Sl]:"observed"})),b.push(...p),m.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Sl]:"forecast"})),b.push(...m)}return{processedData:b,annotations:v}}(e,t,o,n,i);var r},createSegmentLineStyle:function(e,t){var o,n;const i=null!==(o=t.trainDasharray)&&void 0!==o?o:"8,4",r=null!==(n=t.forecastDasharray)&&void 0!==n?n:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const o=e(t),n=t[Sl];if("training"===n){let e=o.stroke;return"darken"===c?e=Za(o.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:i}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===n){let e=o.stroke||"#666";return"lighten"===d&&(e=Ja(e,.4)),Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:void 0})}return"forecast"===n?Object.assign(Object.assign(Object.assign({},o),{stroke:s,strokeDasharray:r}),null!=l&&{strokeOpacity:l}):o}},darkenColor:Za,lightenColor:Ja});exports.AreaChart=Ns,exports.BarChart=sa,exports.BoxPlot=xa,exports.BubbleChart=Es,exports.CARBON_ALERT={danger:"#da1e28",warning:"#f1c21b",success:"#24a148",info:"#0043ce"},exports.CARBON_CATEGORICAL_14=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"],exports.COLOR_BLIND_SAFE_CATEGORICAL=O,exports.CandlestickChart=ra,exports.CategoryColorProvider=dr,exports.ChartContainer=bl,exports.ChartErrorBoundary=Qr,exports.ChartGrid=kl,exports.ChordDiagram=Da,exports.CirclePack=Wa,exports.ConnectedScatterplot=Ts,exports.ContextLayout=wl,exports.DARK_THEME=C,exports.DetailsPanel=jl,exports.DonutChart=Ma,exports.DotPlot=Sa,exports.ForceDirectedGraph=La,exports.FunnelChart=Aa,exports.GaugeChart=Ca,exports.GroupedBarChart=_a,exports.HIGH_CONTRAST_THEME=_,exports.Heatmap=Fs,exports.Histogram=ka,exports.IncrementalExtent=R,exports.LIGHT_THEME=M,exports.LikertChart=ya,exports.LineChart=Hs,exports.LinkedCharts=Mr,exports.MinimapChart=Zs,exports.MultiAxisLineChart=ia,exports.MultiLineTooltip=function(t={}){const{fields:o=[],title:n,format:i,style:r={},className:s="",showLabels:a=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(n){const e=er(t,n);c.push({value:tr(e,i)})}o&&Array.isArray(o)&&o.length>0?o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=tr(er(t,n),r);c.push({label:a?o:void 0,value:s})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:a?e:void 0,value:tr(t[e],i)})});const u=Object.assign(Object.assign({},Ji),r);return Array.isArray(c)&&0!==c.length?e.jsx("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+s).trim(),style:u,children:c.map((t,o)=>e.jsxs("div",{style:{marginBottom:c.length-1>o?"4px":0},children:[t.label&&e.jsxs("strong",{children:[t.label,l]}),t.value]},o))}):null}},exports.OrbitDiagram=Ea,exports.PieChart=Oa,exports.QuadrantChart=Js,exports.RealtimeHeatmap=Va,exports.RealtimeHistogram=Ga,exports.RealtimeLineChart=za,exports.RealtimeSwarmChart=qa,exports.RealtimeTemporalHistogram=Ya,exports.RealtimeWaterfallChart=Xa,exports.RidgelinePlot=ja,exports.RingBuffer=T,exports.SankeyDiagram=Ha,exports.Scatterplot=Ps,exports.ScatterplotMatrix=Ks,exports.StackedAreaChart=Ws,exports.StackedBarChart=la,exports.StreamNetworkFrame=Zi,exports.StreamOrdinalFrame=dn,exports.StreamXYFrame=Lo,exports.SwarmPlot=ma,exports.SwimlaneChart=Pa,exports.THEME_PRESETS=Lr,exports.ThemeProvider=function({theme:t,children:o}){const n="string"==typeof t&&Tr(t)?t:void 0;return e.jsx(P,{children:e.jsxs(Rr.Provider,{value:n,children:[e.jsx(Br,{theme:t}),e.jsx(Ir,{children:o})]})})},exports.Tooltip=or,exports.TreeDiagram=Na,exports.Treemap=$a,exports.ViolinPlot=wa,exports.adaptiveTimeTicks=function(e){let t,o=e;return(n,i,r)=>{const s=n instanceof Date?n:new Date(n);e||!r||2>r.length||r===t||(t=r,o=function(e){if(2>e.length)return"days";const t=[];for(let o=1;e.length>o;o++)t.push(e[o]-e[o-1]);t.sort((e,t)=>e-t);const o=t[Math.floor(t.length/2)];return 12e4>o?"seconds":72e5>o?"minutes":2*Ua>o?"hours":60*Ua>o?"days":400*Ua>o?"months":"years"}(r));const a=o||"days";return null!=i&&0!==i&&r&&0!==r.length?function(e,t,o){const n=e.getUTCFullYear()!==t.getUTCFullYear(),i=n||e.getUTCMonth()!==t.getUTCMonth(),r=i||e.getUTCDate()!==t.getUTCDate(),s=r||e.getUTCHours()!==t.getUTCHours(),a=s||e.getUTCMinutes()!==t.getUTCMinutes(),l=Qa[e.getUTCMonth()],c=e.getUTCDate(),u=e.getUTCFullYear(),d=Ka(e.getUTCHours()),h=Ka(e.getUTCMinutes()),g=Ka(e.getUTCSeconds());switch(o){case"seconds":return n?`${l} ${c}, ${u} ${d}:${h}:${g}`:r?`${l} ${c} ${d}:${h}:${g}`:s?`${d}:${h}:${g}`:a?`${h}:${g}`:":"+g;case"minutes":return n?`${l} ${c}, ${u} ${d}:${h}`:r?`${l} ${c} ${d}:${h}`:s?`${d}:${h}`:":"+h;case"hours":return n?`${l} ${c}, ${u} ${d}:00`:i?`${l} ${c} ${d}:${h}`:r?`${l} ${c} ${d}:00`:d+":00";case"days":return n?`${l} ${c}, ${u}`:i?`${l} ${c}`:""+c;case"months":return n?`${l} ${u}`:""+l;case"years":return""+u}}(s,new Date(r[i-1]),a):function(e,t){const o=Qa[e.getUTCMonth()],n=e.getUTCDate(),i=e.getUTCFullYear(),r=Ka(e.getUTCHours()),s=Ka(e.getUTCMinutes()),a=Ka(e.getUTCSeconds());switch(t){case"seconds":return`${o} ${n}, ${i} ${r}:${s}:${a}`;case"minutes":case"hours":return`${o} ${n}, ${i} ${r}:${s}`;case"days":return`${o} ${n}, ${i}`;case"months":return`${o} ${i}`;case"years":return""+i}}(s,a)}},exports.configToJSX=al,exports.copyConfig=sl,exports.createHatchPattern=Jo,exports.darkenColor=Za,exports.deserializeSelections=function(e){const t=new Map;for(const[o,n]of Object.entries(e)){const e=new Map;for(const t of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:new Set(n.values)}:{type:"interval",range:n.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:o})}t.set(o,{name:n.name,resolution:n.resolution,clauses:e})}return t},exports.exportChart=el,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!us[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:rl(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const o=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(escape(atob(o)));return JSON.parse(n)},exports.fromVegaLite=function(e){var t,o,n,i,r,s,a,l,c,u,d,h,g,f;const p=[],{type:y,markProps:v}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}(e,["type"])}}(e.mark),m=e.encoding||{},b=m.x,x=m.y,k=m.color,w=m.size,j=m.theta,A=m.opacity;let S;(null===(t=e.data)||void 0===t?void 0:t.values)?S=e.data.values:(null===(o=e.data)||void 0===o?void 0:o.url)&&p.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&p.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&p.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&p.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&p.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&p.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&p.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const O={};e.width&&(O.width=e.width),e.height&&(O.height=e.height);const M=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(M&&(O.title=M),(null==k?void 0:k.field)&&(O.colorBy=k.field,null===(n=k.scale)||void 0===n?void 0:n.scheme)){const e=ul[k.scale.scheme];e&&(O.colorScheme=e)}void 0!==(null==A?void 0:A.value)&&(O.pointOpacity=A.value);const C=null==b?void 0:b.aggregate,_=null==x?void 0:x.aggregate;if(S&&(C||_)){const e=_?x:b,t=_?b:x,o=hl[e.aggregate];if(o&&(null==t?void 0:t.field)&&e.field)S=function(e,t){const{groupBy:o,value:n,agg:i="sum"}=t,r=new Map;for(const t of e){const e=t[o]+"";r.has(e)||r.set(e,[]),r.get(e).push(Number(t[n]))}const s=[];for(const[e,t]of r){let n;switch(i){case"count":n=t.length;break;case"mean":n=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":n=Math.min(...t);break;case"max":n=Math.max(...t);break;default:n=t.reduce((e,t)=>e+t,0)}s.push({[o]:e,value:n})}return s}(S,{groupBy:t.field,value:e.field,agg:o});else if(("count"===o||"count"===e.aggregate)&&(null==t?void 0:t.field)&&S){const e=new Map;for(const o of S){const n=o[t.field]+"";e.set(n,(e.get(n)||0)+1)}S=Array.from(e,([e,o])=>({[t.field]:e,value:o}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";S&&(O.data=S),(null==b?void 0:b.bin)?(O.valueAccessor=b.field,(null==x?void 0:x.field)&&(O.categoryAccessor=x.field),(null===(i=b.axis)||void 0===i?void 0:i.title)&&(O.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(O.valueAccessor=x.field,(null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null===(r=x.axis)||void 0===r?void 0:r.title)&&(O.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(s=null==b?void 0:b.bin)||void 0===s?void 0:s.maxbins)||(null===(a=null==x?void 0:x.bin)||void 0===a?void 0:a.maxbins):void 0;return t&&(O.bins=t),fl(e,O,p)}let P;switch(y){case"bar":P=function(e,t,o,n,i,r,s){var a,l,c,u,d,h;let g;return(null==o?void 0:o.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",n.stackBy=o.field):g="BarChart",ll(null==e?void 0:e.type)&&cl(null==t?void 0:t.type)?(n.categoryAccessor=e.field,n.valueAccessor=s?"value":t.field,(null===(a=null==e?void 0:e.axis)||void 0===a?void 0:a.title)&&(n.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(n.valueLabel=t.axis.title)):cl(null==e?void 0:e.type)&&ll(null==t?void 0:t.type)?(n.categoryAccessor=t.field,n.valueAccessor=r?"value":e.field,n.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(n.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(n.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(n.categoryAccessor=e.field),(null==t?void 0:t.field)&&(n.valueAccessor=s?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(n.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(n.valueLabel=t.axis.title)),i&&(n.data=i),g}(b,x,k,O,S,C,_);break;case"line":if(P="LineChart",gl(b,x,O,C,_),(null==k?void 0:k.field)&&(O.lineBy=k.field),v.interpolate){const e=dl[v.interpolate];e&&(O.curve=e)}!0===v.point&&(O.showPoints=!0),S&&(O.data=S);break;case"area":if((null==k?void 0:k.field)?(P="StackedAreaChart",O.areaBy=k.field):P="AreaChart",gl(b,x,O,C,_),v.interpolate){const e=dl[v.interpolate];e&&(O.curve=e)}void 0!==v.opacity&&(O.areaOpacity=v.opacity),S&&(O.data=S);break;case"point":case"circle":case"square":(null==w?void 0:w.field)?(P="BubbleChart",O.sizeBy=w.field,(null===(l=w.scale)||void 0===l?void 0:l.range)&&(O.sizeRange=w.scale.range)):P="Scatterplot",gl(b,x,O,C,_),S&&(O.data=S);break;case"rect":P="Heatmap",(null==b?void 0:b.field)&&(O.xAccessor=b.field),(null==x?void 0:x.field)&&(O.yAccessor=x.field),(null==k?void 0:k.field)&&(O.valueAccessor=k.field,delete O.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(O.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(O.yLabel=x.axis.title),S&&(O.data=S);break;case"arc":v.innerRadius&&v.innerRadius>0?(P="DonutChart",O.innerRadius=v.innerRadius):P="PieChart",(null==j?void 0:j.field)?O.valueAccessor=j.field:(null==x?void 0:x.field)&&(O.valueAccessor=_?"value":x.field),(null==k?void 0:k.field)&&(O.categoryAccessor=k.field),(null==b?void 0:b.field)&&!(null==j?void 0:j.field)&&(O.categoryAccessor=b.field),S&&(O.data=S);break;case"tick":P="DotPlot",ll(null==b?void 0:b.type)?(O.categoryAccessor=b.field,(null==x?void 0:x.field)&&(O.valueAccessor=_?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(O.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(O.valueLabel=x.axis.title)):ll(null==x?void 0:x.type)?(O.categoryAccessor=x.field,(null==b?void 0:b.field)&&(O.valueAccessor=C?"value":b.field),O.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(O.categoryLabel=x.axis.title),(null===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(O.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null==x?void 0:x.field)&&(O.valueAccessor=_?"value":x.field)),S&&(O.data=S);break;default:p.push(`Unsupported mark type "${y}". Defaulting to Scatterplot.`),P="Scatterplot",gl(b,x,O,C,_),S&&(O.data=S)}return fl(P,O,p)},exports.lightenColor=Ja,exports.normalizeTooltip=nr,exports.resolveThemePreset=Tr,exports.serializeSelections=function(e){const t={};for(const[o,n]of e){const e=[];for(const[,t]of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:Array.from(n.values)}:{type:"interval",range:n.range};e.push({clientId:t.clientId,type:t.type,fields:o})}t[o]={name:n.name,resolution:n.resolution,clauses:e}}return t},exports.smartTickFormat=function(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),o=Math.abs(t);return 1e9>o?1e6>o?1e4>o?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"},exports.themeToCSS=function(e,t=":root"){var o,n,i,r,s;const a=[];return a.push(` --semiotic-bg: ${e.colors.background};`),a.push(` --semiotic-text: ${e.colors.text};`),a.push(` --semiotic-text-secondary: ${e.colors.textSecondary};`),a.push(` --semiotic-grid: ${e.colors.grid};`),a.push(` --semiotic-border: ${e.colors.border};`),a.push(` --semiotic-primary: ${e.colors.primary};`),a.push(` --semiotic-font-family: ${e.typography.fontFamily};`),e.colors.focus&&a.push(` --semiotic-focus: ${e.colors.focus};`),e.colors.selection&&a.push(` --semiotic-selection-color: ${e.colors.selection};`),null!=e.colors.selectionOpacity&&a.push(` --semiotic-selection-opacity: ${e.colors.selectionOpacity};`),e.colors.diverging&&a.push(` --semiotic-diverging: ${e.colors.diverging};`),(null===(o=e.tooltip)||void 0===o?void 0:o.background)&&a.push(` --semiotic-tooltip-bg: ${e.tooltip.background};`),(null===(n=e.tooltip)||void 0===n?void 0:n.text)&&a.push(` --semiotic-tooltip-text: ${e.tooltip.text};`),(null===(i=e.tooltip)||void 0===i?void 0:i.borderRadius)&&a.push(` --semiotic-tooltip-radius: ${e.tooltip.borderRadius};`),(null===(r=e.tooltip)||void 0===r?void 0:r.fontSize)&&a.push(` --semiotic-tooltip-font-size: ${e.tooltip.fontSize};`),(null===(s=e.tooltip)||void 0===s?void 0:s.shadow)&&a.push(` --semiotic-tooltip-shadow: ${e.tooltip.shadow};`),e.borderRadius&&a.push(` --semiotic-border-radius: ${e.borderRadius};`),e.colors.annotation&&a.push(` --semiotic-annotation-color: ${e.colors.annotation};`),null!=e.typography.legendSize&&a.push(` --semiotic-legend-font-size: ${e.typography.legendSize}px;`),null!=e.typography.titleFontSize&&a.push(` --semiotic-title-font-size: ${e.typography.titleFontSize}px;`),null!=e.typography.tickFontFamily&&a.push(` --semiotic-tick-font-family: ${e.typography.tickFontFamily};`),a.push(` --semiotic-secondary: ${e.colors.secondary||e.colors.primary};`),a.push(` --semiotic-surface: ${e.colors.surface||e.colors.background};`),e.colors.success&&a.push(` --semiotic-success: ${e.colors.success};`),e.colors.danger&&a.push(` --semiotic-danger: ${e.colors.danger};`),e.colors.warning&&a.push(` --semiotic-warning: ${e.colors.warning};`),e.colors.error&&a.push(` --semiotic-error: ${e.colors.error};`),e.colors.info&&a.push(` --semiotic-info: ${e.colors.info};`),`${t} {\n${a.join("\n")}\n}`},exports.themeToTokens=function(e){var t,o,n,i,r,s;return{semiotic:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({bg:{$value:e.colors.background,$type:"color"},text:{$value:e.colors.text,$type:"color"},"text-secondary":{$value:e.colors.textSecondary,$type:"color"},grid:{$value:e.colors.grid,$type:"color"},border:{$value:e.colors.border,$type:"color"},primary:{$value:e.colors.primary,$type:"color"},focus:{$value:e.colors.focus||e.colors.primary,$type:"color"},"font-family":{$value:e.typography.fontFamily,$type:"fontFamily"},"border-radius":{$value:e.borderRadius||"8px",$type:"dimension"},tooltip:{bg:{$value:(null===(t=e.tooltip)||void 0===t?void 0:t.background)||e.colors.background,$type:"color"},text:{$value:(null===(o=e.tooltip)||void 0===o?void 0:o.text)||e.colors.text,$type:"color"},radius:{$value:(null===(n=e.tooltip)||void 0===n?void 0:n.borderRadius)||"6px",$type:"dimension"},"font-size":{$value:(null===(i=e.tooltip)||void 0===i?void 0:i.fontSize)||"14px",$type:"dimension"},shadow:{$value:(null===(r=e.tooltip)||void 0===r?void 0:r.shadow)||"0 2px 8px rgba(0,0,0,0.15)",$type:"shadow"}},selection:{color:{$value:e.colors.selection||e.colors.primary,$type:"color"},opacity:{$value:null!==(s=e.colors.selectionOpacity)&&void 0!==s?s:.2,$type:"number"}},categorical:{$value:e.colors.categorical,$type:"color",$description:"Categorical color palette"},sequential:{$value:e.colors.sequential,$type:"string",$description:"d3-scale-chromatic sequential scheme name"}},e.colors.diverging?{diverging:{$value:e.colors.diverging,$type:"string",$description:"d3-scale-chromatic diverging scheme name"}}:{}),e.colors.annotation?{"annotation-color":{$value:e.colors.annotation,$type:"color"}}:{}),null!=e.typography.legendSize?{"legend-font-size":{$value:e.typography.legendSize+"px",$type:"dimension"}}:{}),null!=e.typography.titleFontSize?{"title-font-size":{$value:e.typography.titleFontSize+"px",$type:"dimension"}}:{}),null!=e.typography.tickFontFamily?{"tick-font-family":{$value:e.typography.tickFontFamily,$type:"fontFamily"}}:{}),{secondary:{$value:e.colors.secondary||e.colors.primary,$type:"color"},surface:{$value:e.colors.surface||e.colors.background,$type:"color"}}),e.colors.success?{success:{$value:e.colors.success,$type:"color"}}:{}),e.colors.danger?{danger:{$value:e.colors.danger,$type:"color"}}:{}),e.colors.warning?{warning:{$value:e.colors.warning,$type:"color"}}:{}),e.colors.error?{error:{$value:e.colors.error,$type:"color"}}:{}),e.colors.info?{info:{$value:e.colors.info,$type:"color"}}:{})}},exports.toConfig=function(e,t,o){if(!us[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(us).join(", ")}`);const n=!1!==(null==o?void 0:o.includeData),i={};for(const[e,o]of Object.entries(t))null!=o&&(nl.has(e)||!n&&il.has(e)||"function"!=typeof o&&((null==o?void 0:o.$$typeof)||(i[e]=rl(o))));return Object.assign({component:e,props:i,version:"1",createdAt:(new Date).toISOString()},(null==o?void 0:o.selections)?{selections:o.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=wr,exports.useCategoryColors=hr,exports.useChartObserver=jr,exports.useFilteredData=function(e,o,n){const i=vr(e=>e.selections.get(o));return t.useMemo(()=>{if(!i||0===i.clauses.size)return e;const t=fr(i,n);return e.filter(t)},[e,i,n])},exports.useLinkedHover=kr,exports.useSelection=xr,exports.useTheme=Dr;
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react"),o=require("d3-selection"),n=require("d3-brush"),i=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-scale-chromatic"),a=require("d3-array"),l=require("d3-hierarchy"),c=require("d3-shape"),u=require("regression"),d=require("d3-interpolate"),h=require("d3-force"),g=require("d3-chord");function f(e){return e&&e.__esModule?e:{default:e}}function p(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}const y=p(t),v=f(u);function m(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n+1>>1;t[i]>e?n=i-1:o=i}return t[o]}function b(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n>>1;e>t[i]?o=i+1:n=i}return t[o]}function x({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,dimension:c,scales:u,onBrush:d,binSize:h,snap:g,binBoundaries:f,snapDuring:p,streaming:y}){const v=t.useRef(null),x=t.useRef(null),k=t.useRef(d);k.current=d;const w=t.useRef(u);w.current=u;const j=t.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),A=t.useRef(j);A.current=j;const S=t.useRef(!1),O=t.useRef(null);return t.useEffect(()=>{if(!v.current)return;const e=o.select(v.current).select(".brush-g"),t="x"===c?n.brushX():"y"===c?n.brushY():n.brush();return t.extent([[0,0],[i,r]]),t.on("brush end",o=>{if(S.current)return;const n=w.current;if(!n)return;if(!o.selection)return O.current=null,void k.current(null);let s,a;if("x"===c){const[e,t]=o.selection;s=[n.x.invert(e),n.x.invert(t)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===c){const[e,t]=o.selection;s=[n.x.invert(0),n.x.invert(i)],a=[n.y.invert(t),n.y.invert(e)]}else{const[[e,t],[i,r]]=o.selection;s=[n.x.invert(e),n.x.invert(i)],a=[n.y.invert(r),n.y.invert(t)]}if("bin"===g&&"y"!==c&&("end"===o.type||"brush"===o.type&&p)){const i=A.current;i&&i.length>0?s=function(e,t){return 0===t.length?e:[m(e[0],t),b(e[1],t)]}(s,i):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===c)e.call(t.move,[r,a]);else if("xy"===c){const n=o.selection;e.call(t.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const l={x:s,y:a};O.current=l,k.current(l)}),e.call(t),x.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),x.current=null}},[i,r,c,g,h,p]),t.useEffect(()=>{if(!(y&&u&&x.current&&O.current))return;if(!v.current)return;if("y"===c)return;const e=O.current,t=u.x.domain()[0],n=o.select(v.current).select(".brush-g");if(t>=e.x[1])return S.current=!0,n.call(x.current.move,null),S.current=!1,O.current=null,void k.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===g){const e=A.current;e&&e.length>0?i=b(t,e):h&&h>0&&(i=Math.ceil(t/h)*h)}if(i>=e.x[1])return S.current=!0,n.call(x.current.move,null),S.current=!1,O.current=null,void k.current(null);r=!0}const s=u.x(i),a=u.x(e.x[1]);if(S.current=!0,"x"===c)n.call(x.current.move,[s,a]);else{const t=u.y(e.y[1]),o=u.y(e.y[0]);n.call(x.current.move,[[s,t],[a,o]])}if(S.current=!1,r){const t={x:[i,e.x[1]],y:e.y};O.current=t,k.current(t)}},[u,y,c,g,h]),e.jsx("svg",{ref:v,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`})})}class k{constructor(e,t){var o,n;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(o=null==t?void 0:t.chunkThreshold)&&void 0!==o?o:5e3,this.chunkSize=null!==(n=null==t?void 0:t.chunkSize)&&void 0!==n?n:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}setReplacementData(e){if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){this.pushBuffer.push(e),this.scheduleFlush()}pushMany(e){if(0!==e.length){for(let t=0;e.length>t;t++)this.pushBuffer.push(e[t]);this.scheduleFlush()}}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function w(o){const n=t.createContext(null),i=j(o);return[function({children:i}){const r=t.useMemo(()=>j(o),[]);return e.jsx(n.Provider,{value:r,children:i})},e=>{var o;const r=null!==(o=t.useContext(n))&&void 0!==o?o:i,s=t.useRef(e);s.current=e;const a=t.useCallback(()=>s.current(r.getState()),[r]),l=t.useCallback(()=>s.current(r.getState()),[r]);return t.useSyncExternalStore(r.subscribe,a,l)}]}function j(e){const t=new EventTarget;let o=e(function(e){o=Object.assign(Object.assign({},o),e(o)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>o,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}function A(e){if(!(null==e?void 0:e.colors))return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function S(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:O})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}const O=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],M={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}},C={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}},_={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:O,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"},[P,L]=w(e=>({theme:M,setTheme(t){e(e=>{if("light"===t)return{theme:M};if("dark"===t)return{theme:C};if("high-contrast"===t)return{theme:_};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?C:M;return{theme:S(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||{})}))}}return{theme:S(Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})}))}})}}));class T{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const o of e){const e=this.push(o);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e(this.buffer[(t+o)%this._capacity],o)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e[o]=this.buffer[(t+o)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),o=[];for(;t.length>e;)o.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return o}update(e,t){const o=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(n+i)%this._capacity,s=this.buffer[r];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),o.push(e),this.buffer[r]=t(s)}}return o}remove(e){const t=[],o=[];if(this.forEach(n=>{e(n)?o.push(n):t.push(n)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return o}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 R{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const o of e){const e=t?t(o):o;Number.isNaN(e)||(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}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 B(e,t,o,n,i){const r=new Map;for(const s of e){const e=t(s),a=o(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/n)*n;let c=r.get(l);if(c||(c={start:l,end:l+n,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const e=i(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return r}function I(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function D(e,t){if("function"==typeof e)return t=>+e(t);const o=e||t;return e=>+e[o]}function H(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function N(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}const $={category10:s.schemeCategory10,tableau10:s.schemeTableau10,set3:s.schemeSet3,blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,oranges:s.interpolateOranges,purples:s.interpolatePurples,viridis:s.interpolateViridis,plasma:s.interpolatePlasma},W=s.schemeCategory10,F=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],E=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],z=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 Y(e,t,o){if("function"==typeof t){const n=t(e);return o&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||z.has(t)}(n)?o(n):n}const n=null==e?void 0:e[t];return o?o(n):W[Math.abs(function(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return Math.abs(t)}(n+""))%W.length]}function G(e,t,o="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),r=n.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(o))return i.scaleOrdinal().domain(n).range(o).unknown("#999");const s=$[o]||$.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of n){const o=Number(t);o>e&&(e=o)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:W;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function q(e,t,o=[3,20],n){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!n)return i;const[r,s]=n,[a,l]=o;return s===r?(a+l)/2:a+(i-r)/(s-r)*(l-a)}function X(e,t,o){var n,i,r;if(1>=o)return 1;const s=null!==(n=e.minOpacity)&&void 0!==n?n:.1,a=o-1-t;switch(e.type){case"linear":return s+(1-a/(o-1))*(1-s);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:o/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*o)>a?1:s;default:return 1}}function V(e,t,o){var n;const i=null!==(n=e.duration)&&void 0!==n?n:500,r=o-t;return i>r?1-r/i:0}function U(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function K(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Q(e,t,o){return e+(t-e)*o}function Z(){return"undefined"!=typeof performance?performance.now():Date.now()}function J(e,t,o){var n,i,r,s;if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const o=e.getX(t.datum),n=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${o}:${n}`;if(null!=o&&null!=n)return`p:${o}:${n}`}return"p:"+o;case"rect":return`r:${t.group||""}:${null!==(s=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:o}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+o:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function ee(e,t,o,n,i,r){const s=[];for(const i of e){const e=o(i),r=n(i);null==e||null==r||Number.isNaN(e)||Number.isNaN(r)||s.push({px:t.x(e),py:t.y(r),rawY:r,d:i})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:i,datum:c,group:r}}function te(e,t,o,n,i,r,s,a){const l=[];for(const r of e){const e=o(r),s=n(r);if(null==e||null==s||Number.isNaN(e)||Number.isNaN(s))continue;const c=t.x(e),u=a?a(r):i;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:r,datum:e,group:s}}function oe(e,t,o,n,i,r,s){const a=o(e),l=n(e);if(null==a||null==l||Number.isNaN(a)||Number.isNaN(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:i,style:r,datum:e};return void 0!==s&&(c.pointId=s),c}function ne(e,t,o,n,i,r,s){return{type:"rect",x:e,y:t,w:o,h:n,style:i,datum:r,group:s}}function ie(e,t,o,n,i,r,s){const a={type:"heatcell",x:e,y:t,w:o,h:n,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 re(e,t,o){if(!e.getBounds||!e.scales)return null;const n=[],i=[];for(const o of t){const t=e.getX(o),r=e.getY(o);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const s=e.getBounds(o),a=e.scales.x(t);if(s&&0!==s)n.push([a,e.scales.y(r+s)]),i.push([a,e.scales.y(r-s)]);else{const t=e.scales.y(r);n.push([a,t]),i.push([a,t])}}return 2>n.length?null:{type:"area",topPath:n,bottomPath:i,style:e.resolveBoundsStyle(o,t[0]),datum:t,group:o,interactive:!1}}function se(e,t,o,n){var i;if(!e.config.pointStyle)return;const r=null!=n?n:e.getY;for(const n of t){const t=e.resolveGroupColor(n.key);for(const s of n.data){let n=e.config.pointStyle(s);!n.fill&&t&&(n=Object.assign(Object.assign({},n),{fill:t}));const a=null!==(i=n.r)&&void 0!==i?i:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=oe(s,e.scales,e.getX,r,a,n,l);c&&o.push(c)}}}const ae={blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo},le=new Map;class ce{constructor(e){if(this.xExtent=new R,this.yExtent=new R,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.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=e,this.buffer=new T(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=D(e.timeAccessor||e.xAccessor,"time"),this.getY=D(e.valueAccessor||e.yAccessor,"value")):(this.getX=D(e.xAccessor,"x"),this.getY=D(e.yAccessor,"y")),this.getGroup=N(e.groupAccessor),this.getCategory=N(e.categoryAccessor),this.getSize=e.sizeAccessor?D(e.sizeAccessor,"size"):void 0,this.getColor=N(e.colorAccessor),this.getBounds=e.boundsAccessor?D(e.boundsAccessor,"bounds"):void 0,this.getY0=e.y0Accessor?D(e.y0Accessor,"y0"):void 0,this.getPointId=N(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,o=null!=e.closeAccessor;this.getOpen=t?D(e.openAccessor,"open"):void 0,this.getHigh=D(e.highAccessor,"high"),this.getLow=D(e.lowAccessor,"low"),this.getClose=o?D(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!o}e.pulse&&(this.timestampBuffer=new T(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){if(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?D(this.config.timeAccessor||this.config.xAccessor,"time"):D(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],o=this.config.xAccessor,n="function"==typeof o?o(t):t[o||"x"],i=n instanceof Date,r="string"==typeof n&&n.length>=10&&!isNaN(new Date(n).getTime())&&isNaN(Number(n));if(this.xIsDate=i||r,r){const e="string"==typeof o?o:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(o(e)instanceof Date?o(e):new Date(o(e)))}}const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o))):(this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o)))}else for(const o of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o))):(this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o))),null!=e&&(this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):this.yExtent.evict(this.getY(e)))}return!0}computeScene(e){var t,o,n,r,s,a,l;const{config:c,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(t=this.config.scalePadding)&&void 0!==t?t:0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===c.chartType&&this.getHigh&&this.getLow){this.yExtent.clear();for(const e of u)this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))}else this.yExtent.recalculate(u,this.getY);const d=this.getBufferArray(),h=this.xExtent.extent,g=this.yExtent.extent;let f=c.xExtent?[null!==(o=c.xExtent[0])&&void 0!==o?o:h[0],null!==(n=c.xExtent[1])&&void 0!==n?n:h[1]]:h,p=c.yExtent?[null!==(r=c.yExtent[0])&&void 0!==r?r:g[0],null!==(s=c.yExtent[1])&&void 0!==s?s:g[1]]:g;const y=c.yExtent&&null!=c.yExtent[0]&&null!=c.yExtent[1];if("stackedarea"===c.chartType&&!y&&u.size>0)if(c.normalize)p=[0,1+c.extentPadding];else{const e=`${u.size}:${this._ingestVersion}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)p=this._stackExtentCache.yDomain;else{const t=this.groupData(d),o=new Map;let n=0;for(const e of t)for(const t of e.data){const e=this.getX(t),i=this.getY(t);if(null==e||null==i||Number.isNaN(e)||Number.isNaN(i))continue;const r=(o.get(e)||0)+i;o.set(e,r),r>n&&(n=r)}p=[0,n+(n>0?n*c.extentPadding:1)],this._stackExtentCache={key:e,yDomain:p}}}else if("bar"===c.chartType&&c.binSize&&!y&&u.size>0){const[,e]=function(e,t,o,n,i){const r=B(e,t,o,n,i);if(0===r.size)return[0,0];let s=0;for(const e of r.values())e.total>s&&(s=e.total);return[0,s]}(u,this.getX,this.getY,c.binSize,this.getCategory);p=[0,e+e*c.extentPadding]}else if("waterfall"===c.chartType&&!y&&u.size>0){const[e,t]=function(e,t){let o=0,n=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,o>i&&(o=i),i>n&&(n=i))}return[o,n]}(u,this.getY),o=t-e,n=o>0?o*c.extentPadding:1;p=[Math.min(0,e-Math.abs(n)),Math.max(0,t+Math.abs(n))]}else if(!y&&p[0]!==1/0){if(this.getBounds)for(const e of d){const t=this.getY(e),o=this.getBounds(e);null!=t&&!Number.isNaN(t)&&o&&(t+o>p[1]&&(p[1]=t+o),p[0]>t-o&&(p[0]=t-o))}const e=p[1]-p[0],t=e>0?e*c.extentPadding:1,o=null===(a=c.yExtent)||void 0===a?void 0:a[0],n=null===(l=c.yExtent)||void 0===l?void 0:l[1];p=[null!=o?p[0]:p[0]-t,null!=n?p[1]:p[1]+t],"log"===c.yScaleType&&0>=p[0]&&g[0]>0&&(p[0]=null!=o?p[0]:g[0]/(1+c.extentPadding))}if(f[0]===1/0||f[1]===-1/0)if("time"===c.xScaleType){const e=Date.now();f=[e-864e5,e]}else f=[0,1];p[0]!==1/0&&p[1]!==-1/0||(p=[0,1]);const v="streaming"===c.runtimeMode,m=Math.max(0,Math.min(c.scalePadding||0,Math.min(e.width,e.height)/2-1));if(v)if("x"==("up"===(b=c.arrowOfTime)||"down"===b?"y":"x")){const t="right"===c.arrowOfTime?[m,e.width-m]:[e.width-m,m];this.scales={x:i.scaleLinear().domain(f).range(t),y:i.scaleLinear().domain(p).range([e.height-m,m])}}else{const t="down"===c.arrowOfTime?[m,e.height-m]:[e.height-m,m];this.scales={x:i.scaleLinear().domain(p).range([m,e.width-m]),y:i.scaleLinear().domain(f).range(t)}}else{const t=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)};this.scales={x:t(c.xScaleType,f,[m,e.width-m]),y:t(c.yScaleType,p,[e.height-m,m])}}var b;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,d),this.config.decay&&this.applyDecay(this.scene,d),this.config.pulse&&this.applyPulse(this.scene,d),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:e.width,height:e.height},this.version++}rebuildQuadtree(){const e=this.config.chartType;if("scatter"!==e&&"bubble"!==e)return this._quadtree=null,void(this._maxPointRadius=0);let t=0,o=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>o&&(o=e.r));if(this._maxPointRadius=o,ce.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const n=Array(t);let i=0;for(const e of this.scene)"point"===e.type&&(n[i++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,o=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const n of e.path)n[0]*=t,n[1]*=o;break;case"area":for(const n of e.topPath)n[0]*=t,n[1]*=o;for(const n of e.bottomPath)n[0]*=t,n[1]*=o;break;case"point":e.x*=t,e.y*=o;break;case"rect":case"heatcell":e.x*=t,e.y*=o,e.w*=t,e.h*=o;break;case"candlestick":e.x*=t,e.openY*=o,e.closeY*=o,e.highY*=o,e.lowY*=o}const n=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,n,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,r,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var o;const{config:n,scales:i}=this;if(!i||0===t.length)return[];const r={scales:i,config:n,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:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){var o;const n=e.groupData(t),i=[],r=null===(o=e.config.annotations)||void 0===o?void 0:o.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.getBounds)for(const t of n){const o=re(e,t.data,t.key);o&&i.push(o)}for(const t of n){const o=e.resolveLineStyle(t.key,t.data[0]),n=ee(t.data,e.scales,e.getX,e.getY,o,t.key);r&&r.length>0&&(n.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),i.push(n)}return se(e,n,i),i}(r,t);case"area":return function(e,t){const o=e.groupData(t),n=[],i=e.scales.y.domain()[0],r=e.getY0?t=>{const o=e.getY0(t);return null==o?i:o}:void 0;for(const t of o){const o=e.resolveAreaStyle(t.key,t.data[0]),s=te(t.data,e.scales,e.getX,e.getY,i,o,t.key,r);e.config.gradientFill&&(s.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),n.push(s)}return se(e,o,n),n}(r,t);case"mixed":return function(e,t){const o=e.groupData(t),n=[],i=e.config.areaGroups||new Set,r=e.scales.y.domain()[0],s=e.getY0?t=>{const o=e.getY0(t);return null==o?r:o}:void 0;for(const t of o)if(i.has(t.key)){const o=e.resolveAreaStyle(t.key,t.data[0]),i=te(t.data,e.scales,e.getX,e.getY,r,o,t.key,s);e.config.gradientFill&&(i.fillGradient=e.config.gradientFill),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}else{const o=e.resolveLineStyle(t.key,t.data[0]),i=ee(t.data,e.scales,e.getX,e.getY,o,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}return se(e,o,n),n}(r,t);case"stackedarea":return function(e,t){const o=e.groupData(t);o.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);const n=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,{nodes:i,stackedTops:r}=function(e,t,o,n,i,r,s){var a;const l=new Set;for(const t of e)for(const e of t.data){const t=o(e);null==t||Number.isNaN(t)||l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=o(i),r=n(i);null==t||null==r||Number.isNaN(t)||Number.isNaN(r)||e.set(t,(e.get(t)||0)+r)}u.set(t.key,e)}let d;if(r){d=new Map;for(const t of c){let o=0;for(const n of e)o+=(null===(a=u.get(n.key))||void 0===a?void 0:a.get(t))||0;d.set(t,o||1)}}const h=[],g=new Map,f=new Map;for(const e of c)f.set(e,0);for(const o of e){const e=u.get(o.key),n=[],a=[],l=new Map;for(const o of c){let i=e.get(o)||0;const s=f.get(o);r&&(i/=d.get(o));const c=s+i,u=t.x(o);a.push([u,t.y(s)]),n.push([u,t.y(c)]),f.set(o,c),l.set(o,c)}g.set(o.key,l);const p={type:"area",topPath:n,bottomPath:a,style:i(o.key,o.data[0]),datum:o.data,group:o.key};s&&(p.curve=s),h.push(p)}return{nodes:h,stackedTops:g}}(o,e.scales,e.getX,e.getY,(t,o)=>e.resolveAreaStyle(t,o),e.config.normalize,n),s=i;if(e.config.pointStyle){const t=new WeakMap;for(const n of o){const o=r.get(n.key);if(o)for(const i of n.data){const n=e.getX(i),r=e.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||t.set(i,o.get(n))}}const n=o=>{var n;return null!==(n=t.get(o))&&void 0!==n?n:e.getY(o)};se(e,o,s,n)}return s}(r,t);case"scatter":case"bubble":return function(e,t){var o;const n=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let s=null;if(e.getSize&&!e.config.pointStyle){const o=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(o.length>0){let e=1/0,t=-1/0;for(const n of o)e>n&&(e=n),n>t&&(t=n);s=o=>e===t?(r[0]+r[1])/2:r[0]+(o-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,l=(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7";for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:l,opacity:.8},r=t.r||i;if(s&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(r=s(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(o);n&&a.has(n)&&(t=Object.assign(Object.assign({},t),{fill:a.get(n)}))}const c=e.getPointId?e.getPointId(o)+"":void 0,u=oe(o,e.scales,e.getX,e.getY,r,t,c);u&&n.push(u)}return n}(r,t);case"heatmap":return function(e,t,o){if(e.config.heatmapAggregation)return function(e,t,o){var n,i,r;const s=Math.max(1,Math.floor(null!==(n=e.config.heatmapXBins)&&void 0!==n?n:20)),a=Math.max(1,Math.floor(null!==(i=e.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=e.config.heatmapAggregation)&&void 0!==r?r:"count",c=D(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,g]=e.scales.y.domain(),f=(d-u||1)/s,p=(g-h||1)/a,y=s*a;if(y>1e6)return[];const v=new Int32Array(y),m=new Float64Array(y);for(let o=0;t.length>o;o++){const n=t[o],i=e.getX(n),r=e.getY(n);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/f),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;v[g]++;const y=c(n);m[g]+=isFinite(y)?y:0}let b=1/0,x=-1/0;for(let e=0;y>e;e++){if(0===v[e])continue;let t;switch(l){case"sum":t=m[e];break;case"mean":t=m[e]/v[e];break;default:t=v[e]}b>t&&(b=t),t>x&&(x=t)}if(!isFinite(b))return[];const k=x-b||1,w=o.width/s,j=o.height/a,A=e.config.showValues,S=e.config.heatmapValueFormat,O=[];for(let e=0;a>e;e++){const t=e*s;for(let o=0;s>o;o++){const n=t+o;if(0===v[n])continue;let i;switch(l){case"sum":i=m[n];break;case"mean":i=m[n]/v[n];break;default:i=v[n]}const r=(i-b)/k;O.push(ie(o*w,(a-1-e)*j,w,j,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:o,yi:e,value:i,count:v[n],sum:m[n]},A?{value:i,showValues:!0,valueFormat:S}:void 0))}}return O}(e,t,o);if(0===t.length)return[];const n=D(e.config.valueAccessor,"value"),i=H(e.config.xAccessor,"x"),r=H(e.config.yAccessor,"y"),a=new Map,l=new Map,c=Array(t.length),u=Array(t.length);for(let e=0;t.length>e;e++){const o=t[e],n=i(o),s=r(o);c[e]=n,u[e]=s,a.has(n)||a.set(n,a.size),l.has(s)||l.set(s,l.size)}const d=a.size,h=l.size;if(0===d||0===h)return[];const g=Array.from(a.keys()),f=Array.from(l.keys()),p=g.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}if(y){f.sort((e,t)=>e-t),l.clear();for(let e=0;f.length>e;e++)l.set(f[e],e)}const v=new Float64Array(t.length),m=new Float64Array(t.length),b=Array(t.length),x=new Map;let k=0;for(let e=0;t.length>e;e++){const o=t[e],i=a.get(c[e]),r=l.get(u[e]);if(void 0===i||void 0===r)continue;const s=n(o),h=r*d+i,g=x.get(h);let f;void 0!==g?f=g:(f=k++,x.set(h,f)),v[f]=h,m[f]=s,b[f]=o}let w=1/0,j=-1/0;for(let e=0;k>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>j&&(j=t))}if(!isFinite(w)||!isFinite(j))return[];const A=function(e){const t=e in ae?e:"blues";let o=le.get(t);if(o)return o;o=Array(256);const n=ae[t]||s.interpolateBlues;for(let e=0;256>e;e++)o[e]=n(e/255);return le.set(t,o),o}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(j-w||1),O=o.width/d,M=o.height/h,C=e.config.showValues,_=e.config.heatmapValueFormat,P=[];for(let e=0;k>e;e++){const t=m[e];if(!isFinite(t))continue;const o=v[e],n=o%d;P.push(ie(n*O,(h-1-(o-n)/d)*M,O,M,A[Math.min((t-w)*S+.5|0,255)],b[e],C?{value:t,showValues:!0,valueFormat:_}:void 0))}return P}(r,t,e);case"bar":{const e=function(e,t){var o,n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=B(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of i.values())for(const o of e.categories.keys())t.add(o);const o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),s=Array.from(t).filter(e=>!n.has(e)).sort(),a=o.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const s=[],a=e.scales,[l,c]=a.x.domain(),u=e.config.barStyle,d=null===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary,h=null==u?void 0:u.gap,g="number"!=typeof h||0>h?1:h,f={};(null==u?void 0:u.stroke)&&(f.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(f.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(f.opacity=u.opacity);for(const t of i.values()){const o=Math.max(t.start,l),i=Math.min(t.end,c);if(o>=i)continue;const h=a.x(o),p=a.x(i),y=Math.abs(p-h),v=y>g+1?g:0,m=Math.min(h,p)+v/2,b=Math.max(y-v,1);if(b>0)if(r&&t.categories.size>0){let o=0;for(const i of r){const r=t.categories.get(i)||0;if(0===r)continue;const l=a.y(o),c=a.y(o+r),h=(null===(n=e.config.barColors)||void 0===n?void 0:n[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(ne(m,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},f),{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:r},i)),o+=r}}else{const e=a.y(0),o=a.y(t.total);s.push(ne(m,Math.min(e,o),b,Math.abs(e-o),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},f),{binStart:t.start,binEnd:t.end,total:t.total}))}}const p=new Set;for(const e of i.values())p.add(e.start),p.add(e.end);return{nodes:s,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=null!==(o=r.barCategoryCache)&&void 0!==o?o:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var o,n,i,r,s,a;const l=[],c=e.config.swarmStyle||{},u=null!==(o=c.radius)&&void 0!==o?o:3,d=null!==(r=null!==(n=c.fill)&&void 0!==n?n:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,g=c.stroke,f=c.strokeWidth;for(const o of t){const t=e.getX(o),n=e.getY(o);if(null==n||Number.isNaN(n))continue;const i=e.scales.x(t),r=e.scales.y(n);let s=d;if(e.getCategory){const t=e.getCategory(o);s=(null===(a=e.config.barColors)||void 0===a?void 0:a[t])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:g,strokeWidth:f},datum:o};e.getPointId&&(c.pointId=e.getPointId(o)+""),l.push(c)}return l}(r,t);case"waterfall":return function(e,t,o){var n,i,r,s,a,l,c;const u=[],d=e.scales,h=e.config.waterfallStyle,g=t.filter(t=>{const o=e.getY(t),n=e.getX(t);return null!=o&&!Number.isNaN(o)&&null!=n&&isFinite(n)});if(0===g.length)return u;const f=null!==(r=null!==(n=null==h?void 0:h.positiveColor)&&void 0!==n?n:null===(i=e.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=e.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,v=null==h?void 0:h.stroke,m=null==h?void 0:h.strokeWidth,b=null==h?void 0:h.opacity;let x=0;for(let t=0;g.length>t;t++){const n=g[t],i=e.getX(n),r=e.getY(n),s=x+r;let a;a=g.length-1>t?e.getX(g[t+1])-i:t>0?i-e.getX(g[t-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+o.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const j=d.y(x),A=d.y(s),S=Math.min(j,A),O=Math.abs(j-A),M={fill:0>r?p:f,stroke:v,strokeWidth:m};null!=b&&(M.opacity=b),u.push(ne(k,S,w,O,M,Object.assign(Object.assign({},n),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(r,t,e);case"candlestick":return function(e,t){var o,n;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(o=e.config.candlestickRangeMode)&&void 0!==o&&o;if(!(i||e.getOpen&&e.getClose))return[];const r=[],s=e.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=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let g=null!==(n=s.bodyWidth)&&void 0!==n?n:0;if(null==s.bodyWidth)if(h.length>1){let t=1/0;for(let o=1;h.length>o;o++){const n=Math.abs(e.scales.x(h[o])-e.scales.x(h[o-1]));n>0&&t>n&&(t=n)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else g=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const n=e.getHigh(o),s=e.getLow(o);if(null==n||Number.isNaN(n)||null==s||Number.isNaN(s))continue;const a=i?n:e.getOpen(o),h=i?s:e.getClose(o);if(!i&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const f=h>=a,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(n),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:o};i&&(p.isRange=!0),r.push(p)}return r}(r,t);default:return[]}}resolveBoundsStyle(e,t){var o;const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||(null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?X(o,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,o){var n,i;const r=o.length;if(1>=r)return;const s=new Map;for(let e=0;o.length>e;e++)s.set(o[e],e);for(const o of t){if("line"===o.type){const t=Array.isArray(o.datum)?o.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let o=0;t.length>o;o++){const a=s.get(t[o]);null!=a?(n[o]=X(e,a,r),1>n[o]&&(i=!0)):n[o]=1}i&&(o._decayOpacities=n);continue}if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[],n=o.topPath?o.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let a=!1;for(let o=0;t.length>o;o++){const n=s.get(t[o]);null!=n?(i[o]=X(e,n,r),1>i[o]&&(a=!0)):i[o]=1}a&&(o._decayOpacities=i)}else{let i=1;for(const o of t){const t=s.get(o);if(null!=t){const o=X(e,t,r);i>o&&(i=o)}}if(1>i){const e=Array(n);e.fill(i),o._decayOpacities=e}}continue}const t=s.get(o.datum);if(null==t)continue;const a=X(e,t,r);if("heatcell"===o.type)o.style={opacity:a};else if("candlestick"===o.type)o._decayOpacity=a;else{const e=null!==(i=null===(n=o.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;o.style=Object.assign(Object.assign({},o.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,o,n){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=e.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=e.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;o.length>e;e++)c.set(o[e],e);for(const o of t){if("line"===o.type)continue;if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[o.datum];let i=0;for(const o of t){const t=c.get(o);if(null==t)continue;const r=n.get(t);if(null==r)continue;const a=V(e,r,s);a>i&&(i=a)}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const t=c.get(o.datum);if(null==t)continue;const i=n.get(t);if(null==i)continue;const r=V(e,i,s);r>0&&(o._pulseIntensity=r,o._pulseColor=a,o._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var o;if(!t||0===t.size)return!1;const n="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(o=e.duration)&&void 0!==o?o:500,r=t.peek();return null!=r&&i>n-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,o,n){var i,r,s,a;o.clear(),n.clear();for(let l=0;t.length>l;l++){const c=t[l],u=J(e,c,l);u&&("point"===c.type?o.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?o.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?o.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?o.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?n.set(u,{path:c.path.map(e=>[e[0],e[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&n.set(u,{topPath:c.topPath.map(e=>[e[0],e[1]]),bottomPath:c.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var e,t,o;this.prevPositionMap.clear(),this.prevPathMap.clear();const n=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.y(0))&&void 0!==t?t:0;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],i=J(this.transitionContext,t,e);i&&("point"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,r:0,opacity:0}):"rect"===t.type?this.prevPositionMap.set(i,{x:t.x,y:n,w:t.w,h:0,opacity:null!==(o=t.style.opacity)&&void 0!==o?o:1}):"heatcell"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,w:t.w,h:t.h,opacity:0}):"line"===t.type?(t._introClipFraction=0,this.prevPathMap.set(i,{path:t.path.map(e=>[e[0],e[1]]),opacity:t.style.opacity})):"area"===t.type&&(t._introClipFraction=0,this.prevPathMap.set(i,{topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),opacity:t.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,o,n,i){var r,s,a,l,c,u,d,h,g,f,p,y,v,m,b,x,k,w,j,A,S,O,M,C,_,P,L,T,R,B,I,D,H,N,$,W,F,E,z,Y,G;if(0===n.size&&0===i.size)return o;const q=null!==(r=t.duration)&&void 0!==r?r:300;if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}let X=!1;const V=new Set,U=new Set;for(let t=0;o.scene.length>t;t++){const r=o.scene[t],P=J(e,r,t);if(!P)continue;if(r._transitionKey=P,"line"===r.type||"area"===r.type){const e=i.get(P);if(e){if(U.add(P),"line"===r.type&&e.path&&e.path.length===r.path.length){r._targetPath=r.path.map(e=>[e[0],e[1]]),r._prevPath=e.path;for(let t=0;r.path.length>t;t++)r.path[t]=[e.path[t][0],e.path[t][1]];X=!0}else if("area"===r.type&&e.topPath&&e.bottomPath&&e.topPath.length===r.topPath.length&&e.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(e=>[e[0],e[1]]),r._targetBottomPath=r.bottomPath.map(e=>[e[0],e[1]]),r._prevTopPath=e.topPath,r._prevBottomPath=e.bottomPath;for(let t=0;r.topPath.length>t;t++)r.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;r.bottomPath.length>t;t++)r.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];X=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=e.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 L=n.get(P);if("point"===r.type)if(L){V.add(P);const e={x:r.x,y:r.y,r:r.r};r._targetOpacity=null!==(u=r.style.opacity)&&void 0!==u?u:1,L.x===e.x&&L.y===e.y&&L.r===e.r||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=L.x,r.y=L.y,r.r=null!==(d=L.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(L){V.add(P);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(g=r.style.opacity)&&void 0!==g?g:1,L.x===e.x&&L.y===e.y&&L.w===e.w&&L.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=L.x,r.y=L.y,r.w=null!==(f=L.w)&&void 0!==f?f:r.w,r.h=null!==(p=L.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(L){V.add(P);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(m=null===(v=r.style)||void 0===v?void 0:v.opacity)&&void 0!==m?m:1,L.x===e.x&&L.y===e.y&&L.w===e.w&&L.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=L.x,r.y=L.y,r.w=null!==(b=L.w)&&void 0!==b?b:r.w,r.h=null!==(x=L.h)&&void 0!==x?x:r.h,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(L&&null!=L.openY){V.add(P);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(A=null===(j=r.style)||void 0===j?void 0:j.opacity)&&void 0!==A?A:1,(L.x!==e.x||L.openY!==e.openY||L.closeY!==e.closeY||L.highY!==e.highY||L.lowY!==e.lowY)&&(r._targetX=e.x,r._targetOpenY=e.openY,r._targetCloseY=e.closeY,r._targetHighY=e.highY,r._targetLowY=e.lowY,r.x=L.x,r.openY=L.openY,r.closeY=null!==(S=L.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(O=L.highY)&&void 0!==O?O:r.highY,r.lowY=null!==(M=L.lowY)&&void 0!==M?M:r.lowY,X=!0)}else r._targetOpacity=null!==(_=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==_?_:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0}for(const[e,t]of i)if(!U.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(P=t.opacity)&&void 0!==P?P:1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(n),X=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(L=t.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(n),X=!0}for(const[e,t]of n)if(!V.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(T=t.r)&&void 0!==T?T:3,style:{opacity:null!==(R=t.opacity)&&void 0!==R?R:1},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(B=t.w)&&void 0!==B?B:0,h:null!==(I=t.h)&&void 0!==I?I:0,style:{opacity:null!==(D=t.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(H=t.w)&&void 0!==H?H:0,h:null!==(N=t.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==($=t.opacity)&&void 0!==$?$:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("c:")){const n=null!==(W=t.openY)&&void 0!==W?W:t.y,i={type:"candlestick",x:t.x,openY:n,closeY:null!==(F=t.closeY)&&void 0!==F?F:n,highY:null!==(E=t.highY)&&void 0!==E?E:n,lowY:null!==(z=t.lowY)&&void 0!==z?z:n,bodyWidth:null!==(Y=t.w)&&void 0!==Y?Y:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(G=t.opacity)&&void 0!==G?G:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(i)}X=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),X&&(o.activeTransition={startTime:Z(),duration:q}),o}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},o=function(e,t,o,n){var i,r,s,a,l,c;if(!o.activeTransition)return!1;const u=K(e,o.activeTransition),d=U(u,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of o.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style.opacity=Q(r,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),e.y=Q(o.y,e._targetY,d),void 0!==e._targetR&&void 0!==o.r&&(e.r=Q(o.r,e._targetR,d))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(r=o.opacity)&&void 0!==r?r:1:0;e.style.opacity=Q(i,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),e.y=Q(o.y,e._targetY,d),void 0!==o.w&&(e.w=Q(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Q(o.h,e._targetH,d))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(s=o.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Q(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),e.y=Q(o.y,e._targetY,d),void 0!==o.w&&(e.w=Q(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Q(o.h,e._targetH,d))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(a=o.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Q(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,d),void 0!==o.openY&&(e.openY=Q(o.openY,e._targetOpenY,d)),void 0!==o.closeY&&(e.closeY=Q(o.closeY,e._targetCloseY,d)),void 0!==o.highY&&(e.highY=Q(o.highY,e._targetHighY,d)),void 0!==o.lowY&&(e.lowY=Q(o.lowY,e._targetLowY,d))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Q(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevPath,o=e._targetPath;if(t&&o&&t.length===e.path.length)for(let n=0;e.path.length>n;n++)e.path[n][0]=Q(t[n][0],o[n][0],d),e.path[n][1]=Q(t[n][1],o[n][1],d)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(c=e._startOpacity)&&void 0!==c?c:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Q(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevTopPath,o=e._prevBottomPath,n=e._targetTopPath,i=e._targetBottomPath;if(t&&n&&t.length===e.topPath.length)for(let o=0;e.topPath.length>o;o++)e.topPath[o][0]=Q(t[o][0],n[o][0],d),e.topPath[o][1]=Q(t[o][1],n[o][1],d);if(o&&i&&o.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Q(o[t][0],i[t][0],d),e.bottomPath[t][1]=Q(o[t][1],i[t][1],d)}}if(u>=1){for(const e of o.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let o=0;e.path.length>o;o++)e.path[o]=t[o];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,o=e._targetBottomPath;if(t)for(let o=0;e.topPath.length>o;o++)e.topPath[o]=t[o];if(o)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=o[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}return o.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,o}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const o of e){const e=this.getGroup(o);t.has(e)||t.set(e,[]),t.get(e).push(o)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const t=new Set;for(const o of e){const e=this.getColor(o);e&&t.add(e)}const o=Array.from(t).sort(),n=o.join("\0");if(this._colorMapCache&&this._colorMapCache.key===n)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||F,r=new Map;for(let e=0;o.length>e;e++)r.set(o[e],i[e%i.length]);return this._colorMapCache={key:n,map:r,version:this._ingestVersion},r}resolveLineStyle(e,t){var o;const n=this.config.lineStyle;if("function"==typeof n){const o=n(t||{},e);if(o&&!o.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{stroke:t})}return o}const i=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;return n&&"object"==typeof n?{stroke:n.stroke||i||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var o,n;if(this.config.areaStyle){const o=this.config.areaStyle(t||{});if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const i=this.config.lineStyle;if("function"==typeof i){const o=i(t||{},e);if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const r=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const o=(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)||F;if(0===o.length)return null;const n=o[this._groupColorCounter%o.length];if(this._groupColorCounter++,this._groupColorMap.set(e,n),this._groupColorMap.size>ce.GROUP_COLOR_MAP_CAP){const e=this._groupColorMap.keys().next().value;void 0!==e&&this._groupColorMap.delete(e)}return n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const o=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(e)),t);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),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.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(e){var t,o,n,i;const r=Object.assign({},this.config);("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let s=!1;Object.assign(this.config,e);const a="chartType"in e&&e.chartType!==r.chartType||"runtimeMode"in e&&e.runtimeMode!==r.runtimeMode;if(a||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const l=a||!I(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(o=r.xAccessor)&&void 0!==o?o:r.timeAccessor),c=a||!I(null!==(n=e.yAccessor)&&void 0!==n?n:e.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(l||c)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=D(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=D(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=D(this.config.xAccessor,"x"),this.getY=D(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in e&&!I(e.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?N(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!I(e.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?N(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!I(e.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?D(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!I(e.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?N(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!I(e.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?D(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in e&&!I(e.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?N(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in e&&!I(e.openAccessor,r.openAccessor)||"closeAccessor"in e&&!I(e.closeAccessor,r.closeAccessor)||"highAccessor"in e&&!I(e.highAccessor,r.highAccessor)||"lowAccessor"in e&&!I(e.lowAccessor,r.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?D(this.config.openAccessor,"open"):void 0,this.getHigh=D(this.config.highAccessor,"high"),this.getLow=D(this.config.lowAccessor,"low"),this.getClose=t?D(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0}if(!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of t)if(e[o]!==r[o]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function ue(e,t,o){return o.x>e||e>o.x+o.w||o.y>t||t>o.y+o.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:o.x+o.w/2,cy:o.y+o.h/2}}function de(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function he(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ge(e,t){const o=he(e);if(!o)return!1;const n=he(t);return!n||o.getFullYear()!==n.getFullYear()||o.getMonth()!==n.getMonth()}function fe(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function pe(e,t,o,n,i){const r=Math.max(n,i+5,12),s=t-r,a=t+r,l=o-r,c=o+r;let u=null,d=1/0;return e.visit((e,i,r,h,g)=>{if(i>a||s>h||r>c||l>g)return!0;if(!e.length){let i=e;do{const e=i.data,r=e.x-t,s=e.y-o,a=Math.sqrt(r*r+s*s);de(e.r,n)>=a&&d>a&&(u=e,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}function ye(e,t,o,n=30,i,r=0){let s=null;if(i){const e=pe(i,t,o,n,r);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const r of e){let e=null;switch(r.type){case"point":if(i)break;e=me(r,t,o,n);break;case"line":e=be(r,t,o,n);break;case"rect":e=ke(r,t,o);break;case"heatcell":e=we(r,t,o);break;case"area":if(!1===r.interactive)break;e=Ae(r,t,o);break;case"candlestick":e=je(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function ve(e,t,o){if(0===e.length)return null;const n=Se(e,t);if(0>n)return null;if(Math.abs(e[n][0]-t)>o)return null;let i=n,r=n;n>0&&e[n][0]>=t?(i=n-1,r=n):e.length-1>n&&(i=n,r=n+1);const[s,a]=e[i],[l,c]=e[r];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function me(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>de(e.r,n)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function be(e,t,o,n=30){var i,r,s,a;if(0===e.path.length)return null;const l=Se(e.path,t);if(0>l)return null;const[c,u]=e.path[l];let d;if(e.path.length>1){let n=1/0;const i=Math.max(0,l-1),r=Math.min(e.path.length-2,l);for(let s=i;r>=s;s++){const[i,r]=e.path[s],[a,l]=e.path[s+1],c=xe(t,o,i,r,a,l);n>c&&(n=c)}d=n}else{const e=t-c,n=o-u;d=Math.sqrt(e*e+n*n)}const h=null!==(a=null!==(r=null===(i=e.style)||void 0===i?void 0:i.strokeWidth)&&void 0!==r?r:null===(s=e.style)||void 0===s?void 0:s.lineWidth)&&void 0!==a?a:1;return d>Math.max(5,h/2+2,n)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:c,y:u,distance:d}}function xe(e,t,o,n,i,r){const s=i-o,a=r-n,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-o,2)+Math.pow(t-n,2));let c=((e-o)*s+(t-n)*a)/l;c=Math.max(0,Math.min(1,c));const u=n+c*a;return Math.sqrt(Math.pow(e-(o+c*s),2)+Math.pow(t-u,2))}function ke(e,t,o){const n=ue(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function we(e,t,o){const n=ue(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function je(e,t,o){const n=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-n-3>t||t>e.x+n+3||e.highY-3>o||o>e.lowY+3)){const n=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,s=o-n;return{node:e,datum:e.datum,x:e.x,y:n,distance:Math.sqrt(r*r+s*s)}}return null}function Ae(e,t,o){if(0===e.topPath.length)return null;const n=Se(e.topPath,t);if(0>n)return null;const[i,r]=e.topPath[n],s=t-i,a=o-r,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[n]?e.datum[n]:e.datum,x:i,y:r,distance:l}}function Se(e,t){if(0===e.length)return-1;let o=0,n=e.length-1;for(;n>o;){const i=o+n>>1;t>e[i][0]?o=i+1:n=i}return o>0&&Math.abs(e[o][0]-t)>=Math.abs(e[o-1][0]-t)?o-1:o}function Oe(e){var t,o;const n=new Map;for(const o of e){const e=null!==(t=o.group)&&void 0!==t?t:"_default";let i=n.get(e);i||(i=[],n.set(e,i)),i.push(o)}for(const e of n.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const i=Array.from(n.keys()).sort((e,t)=>{const o=n.get(e),i=n.get(t);return(o.length>0?o[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(n.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=null===(o=r[e].datum)||void 0===o?void 0:o.id;null!=t&&s.set(t+"",e)}return{flat:r,groups:i,byGroup:n,idToIdx:s}}function Me(e,t){var o,n;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[i];return{flatIndex:i,group:null!==(o=r.group)&&void 0!==o?o:"_default",indexInGroup:null!==(n=r._groupIndex)&&void 0!==n?n:0}}function Ce(e,t,o){const{group:n,indexInGroup:i}=t,r=o.byGroup.get(n);switch(e){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=o.groups.indexOf(n);return o.groups.length-1>e?_e(o,o.groups[e+1],r[i]):t.flatIndex}case"ArrowUp":{const e=o.groups.indexOf(n);return e>0?_e(o,o.groups[e-1],r[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*o.flat.length)),o.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*o.flat.length)),0);case"Home":return 0;case"End":return o.flat.length-1;case"Escape":return-1;default:return null}}function _e(e,t,o){const n=e.byGroup.get(t);let i=0,r=Math.abs(n[0].x-o.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-o.x);r>t&&(r=t,i=e)}return n[i]._flatIndex}function Pe(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function Le(e){const t=e.datum||{};return Object.assign(Object.assign({},"object"!=typeof t||null===t||Array.isArray(t)?{}:t),{data:t,x:e.x,y:e.y,time:e.x,value:e.y})}function Te(e,o,n,i,r,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=o.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-a.lastIngestTime>c;u!==r&&(s(u),n.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}ce.GROUP_COLOR_MAP_CAP=1e3,ce.QUADTREE_THRESHOLD=500;const Re={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function Be(e,t,o,n){let i;return i="function"==typeof o?o(e):(0,Re[o])(n(e,t)),i}function Ie(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function De(e,t,o){return o&&o.size>0?o.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const He=(t,o,n,i,r,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:g}=t,f=[];let p=0;const y=!(!o&&!n),v="isolate"===u||void 0===u&&null!=r;return g.forEach((t,u)=>{const m=Be(t,u,d,h),b=De(t,i,r),x=r&&r.size>0&&r.has(t.label);f.push(e.jsxs("g",{transform:`translate(0,${p})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:y?l===s&&u===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&v?x||!1:void 0,"aria-current":y&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:y?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:y?e=>{c(l,u),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),m,x&&e.jsx(Ie,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),p+=22}),f};function Ne({config:t,orientation:o="vertical",width:n=100}){const{colorFn:i,domain:r,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+y.useId();if("horizontal"===o){const t=12,o=Math.min(n,200),a=Math.max(0,(n-o)/2),u=[];for(let t=0;64>=t;t++){const o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[0]+o*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&e.jsx("text",{x:a+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:o,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),e.jsx("text",{x:a+o,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let t=0;64>=t;t++){const o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[1]-o*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function $e(t){const{legendGroups:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,g]=y.useState(0),[f,p]=y.useState(0),v=y.useCallback((e,t)=>{g(e),p(t)},[]),m="vertical"===d?(({legendGroups:t,width:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,g)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:o,y2:d},"legend-top-line legend-symbol-"+g)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+g)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:He(t,n,i,r,s,a,l,g,c,u)},"legend-group-"+g)),d+=22*t.items.length+8}),h})({legendGroups:o||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:v,legendInteraction:a}):(({legendGroups:t,height:o,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const g=[];t.forEach((t,o)=>{let f=0;t.label&&(f+=16);const p=((t,o,n,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:g,items:f}=t,p=[];let y=0,v=0;const m=!(!o&&!n),b="isolate"===u||void 0===u&&null!=r;f.forEach((t,u)=>{const x=Be(t,u,h,g),k=De(t,i,r),w=r&&r.size>0&&r.has(t.label),j=26+7*t.label.length;d&&d>0&&y>0&&y+j>d&&(v++,y=0),p.push(e.jsxs("g",{transform:`translate(${y},${22*v})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?l===s&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&b?w||!1:void 0,"aria-current":m&&!b&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:m?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+f.length)%f.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:m?e=>{c(l,u),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,w&&e.jsx(Ie,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=j});let x=0,k=0;for(const e of f){const t=26+7*e.label.length;d&&d>0&&k>0&&k+t>d?(x=Math.max(x,k),k=t):k+=t}x=Math.max(x,k);const w=v+1;return{items:p,offset:x,totalRows:w,totalHeight:22*w}})(t,i,r,s,a,l,c,o,u,d,n);f+=p.offset+5,g.push(Object.assign(Object.assign({label:t.label},p),{offset:f,totalRows:p.totalRows,totalHeight:p.totalHeight})),h+=f+12});let f=h>n?0:Math.max(0,(n-h)/2);const p=[];return g.forEach((n,i)=>{const r=t[i];r.label&&(p.push(e.jsx("text",{transform:`translate(${f},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)),f+=16),p.push(e.jsx("g",{className:"legend-item",transform:`translate(${f},0)`,children:n.items},"legend-group-"+i)),f+=n.offset+5,t[i+1]&&p.push(e.jsx("line",{stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+i)),f+=12}),e.jsx("g",{children:p})})({legendGroups:o||[],title:l,height:u,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:v,legendInteraction:a}),b=!(!n&&!i);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"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&&e.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}),m]})}function We(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function Fe(e){return"object"==typeof e&&null!==e&&"gradient"in e}function Ee(t){const{legend:o,totalWidth:n,totalHeight:i,margin:r,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!o)return null;const g="top"===s||"bottom"===s;let f,p;return"left"===s?(f=4,p=r.top):"top"===s?(f=0,p=a?32:8):"bottom"===s?(f=0,p=i-r.bottom+50):(f=n-r.right+10,p=r.top),e.jsx("g",{transform:`translate(${f}, ${p})`,children:Fe(o)?e.jsx(Ne,{config:o.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):We(o)?e.jsx($e,{legendGroups:o.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):o})}function ze(e){return"string"==typeof e?{type:e}:e}function Ye({orient:o,config:n,values:i,scale:r,size:s,length:l}){const c=function(e){var t,o,n,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(o=e.fill)&&void 0!==o?o:"#4e79a7",fillOpacity:null!==(n=e.fillOpacity)&&void 0!==n?n:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),u="top"===o||"bottom"===o,d=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=s-8;if("boxplot"===c.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),o=t.length;if(0===o)return null;const n=t[Math.floor(.25*o)],i=t[Math.floor(.5*o)],r=t[Math.floor(.75*o)],s=r-n;return{q1:n,median:i,q3:r,whiskerLow:Math.max(t[0],n-1.5*s),whiskerHigh:Math.min(t[o-1],r+1.5*s)}}(i);if(!t)return null;const{q1:s,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=t,g=Math.min(.5*n,20),f=(n-g)/2+4;if(u){const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="top"===o?-1:1,v=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:u,y1:v+y*(f+g/2),x2:p,y2:v+y*(f+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:v+y*f,x2:u,y2:v+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:p,y1:v+y*f,x2:p,y2:v+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,n),y:"top"===o?v-f-g:v+f,width:Math.abs(n-t),height:g,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:i,y1:"top"===o?v-f-g:v+f,x2:i,y2:"top"===o?v-f:v+f+g,stroke:c.fill,strokeWidth:2})]})}{const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="left"===o?-1:1,v=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:v+y*(f+g/2),y1:u,x2:v+y*(f+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:v+y*f,y1:u,x2:v+y*(f+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:v+y*f,y1:p,x2:v+y*(f+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===o?v-f-g:v+f,y:Math.min(t,n),width:g,height:Math.abs(n-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===o?v-f-g:v+f,y1:i,x2:"left"===o?v-f:v+f+g,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=a.bin().domain(t).thresholds(c.bins)(i);if(0===d.length)return null;const h=Math.max(...d.map(e=>e.length));if(0===h)return null;if("histogram"===c.type)return e.jsx("g",{"data-testid":"marginal-histogram-"+o,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const s=t.length/h*n;if(u){const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:n,y:"top"===o?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:"left"===o?-4-s:4,y:Math.min(n,n+a),width:s,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const t=n/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(n/2),a=r((e.x0+e.x1)/2);i.push(u?`${a},${"top"===o?-(t-s):t-s}`:`${"left"===o?-(t-s):t-s},${a}`)}for(let e=d.length-1;e>=0;e--){const s=d[e];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(n/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===o?-(t+a):t+a}`:`${"left"===o?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+o,children:e.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 t=[];if(u){const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${i},${e}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*n,s=r((e.x0+e.x1)/2);t.push(`L${s},${"top"===o?-i-4:i+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${s},${e}`),t.push("Z")}else{const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${e},${i}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*n,s=r((e.x0+e.x1)/2);t.push(`L${"left"===o?-i-4:i+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${e},${s}`),t.push("Z")}return e.jsx("g",{"data-testid":"marginal-ridgeline-"+o,children:e.jsx("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,r,c,s,l,o,u,4]);return d?e.jsx("g",{className:"marginal-"+o,"data-testid":"marginal-"+o,children:d}):null}function Ge(e,t=120,o=8){if(!e)return[];const n=Math.max(1,Math.floor(t/o)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>n?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function qe(e,t,o,n){return"curly"===e?n?`M0,0 C${.6*o},0 ${.4*o},${t/2} ${o},${t/2} C${.4*o},${t/2} ${.6*o},${t} 0,${t}`:`M0,0 C0,${.6*o} ${t/2},${.4*o} ${t/2},${o} C${t/2},${.4*o} ${t},${.6*o} ${t},0`:n?`M0,0 L${o},0 L${o},${t} L0,${t}`:`M0,0 L0,${o} L${t},${o} L${t},0`}function Xe(t,o,n,i){if(!t)return e.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=t;if(!r&&!s)return e.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(o)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>o?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>o?"end":"start";const f=16,p=s?u?[s]:Ge(s,c):[],y=r?u?[r]:Ge(r,c):[],v="leftRight"===d?"end"===g?-4:4:0;let m=0;const b=[],x=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";p.length>0&&(b.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold",children:p.map((t,o)=>e.jsx("tspan",{x:v,dy:0===o?0:f,children:t},o))},"annotation-note-title")),m=p.length*f),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:g,y:m,children:y.map((t,o)=>e.jsx("tspan",{x:v,dy:0===o?0:f,children:t},o))},"annotation-note-label"));let k=null;if((s||r)&&(0!==o||0!==n))if("topBottom"===d){const t=Math.min(c,120);let o=0,n=t;"end"===g?(o=-t,n=0):"middle"===g&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:o,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let o=0,n=t;"bottom"===h?(o=-t,n=0):"middle"===h&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:o,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let j=0;return"topBottom"===d?j=0>n?-(w+2):18:"leftRight"===d&&(j="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(w+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${o},${n})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==j?`translate(0,${j})`:void 0,children:b}),k]})}function Ve(t,o,n,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==o?void 0:o.radius)||0)+((null==o?void 0:o.radiusPadding)||0);t>0&&a.push(e.jsx("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==o?void 0:o.width)||0,i=(null==o?void 0:o.height)||0;(t>0||i>0)&&a.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==o?void 0:o.custom)&&a.push(...Array.isArray(o.custom)?o.custom:[o.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==o?void 0:o.x)){const i=(o.x||0)-t;a.push(e.jsx("line",{x1:i,y1:(o.y1||0)-s,x2:i,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==o?void 0:o.y)){const i=(o.y||0)-s;a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:i,x2:(o.x2||0)-t,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==o?void 0:o.x1)||void 0!==(null==o?void 0:o.x2)?a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:0,x2:(o.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==o?void 0:o.y1)&&void 0===(null==o?void 0:o.y2)||a.push(e.jsx("line",{x1:0,y1:(o.y1||0)-s,x2:0,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==o?void 0:o.width)&&void 0!==s?s:null==o?void 0:o.height;void 0!==t&&a.push(e.jsx("path",{d:qe((null==o?void 0:o.type)||"curly",t,(null==o?void 0:o.depth)||30,void 0===(null==o?void 0:o.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function Ue(t,o,n,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 e=s.width||0,n=s.height||0;if(e>0||n>0){const i=e/2,r=n/2,s=t-i,a=o-r;if(0!==s||0!==a){const t=Math.abs(s),o=Math.abs(a),u=e/2,d=n/2,h=t*d>o*u?u/t:d/o;l=i+s*h,c=r+a*h}}}else if("bracket"===r&&s){const e=s.width,t=s.height,o=s.depth||30;void 0!==e?(l=e/2,c=o):void 0!==t&&(l=o,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==o)){const n=Math.atan2(o,t);l=Math.cos(n)*e,c=Math.sin(n)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(o-c,2))>.5&&(a.push(e.jsx("line",{x1:l,y1:c,x2:t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,s=Math.atan2(o-c,t-l);a.push(e.jsx("path",{d:`M${l},${c}L${l+n*Math.cos(s+r)},${c+n*Math.sin(s+r)}L${l+n*Math.cos(s-r)},${c+n*Math.sin(s-r)}Z`,fill:i||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return e.jsx("g",{className:"annotation-connector",children:a})}function Ke(t){const{x:o=0,y:n=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:f,events:p={},"data-testid":y}=t,v=new Set(Array.isArray(f)?f:[]);let m=i||0,b=r||0;null!=s&&(m=s-o),null!=a&&(b=a-n);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===m&&0===b)if(void 0!==u.width){m=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;m=e+(0>e?-5:5),b=u.height/2}return e.jsxs("g",Object.assign({className:("annotation "+(g||"")).trim(),transform:`translate(${o},${n})`,"data-testid":y},p,{children:[!v.has("connector")&&Ue(m,b,c,h,x,u),!v.has("subject")&&Ve(x,u,h,o,n),!v.has("note")&&Xe(l,m,b,h)]}))}function Qe(t){var o,n;const{noteData:i}=t,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(o=i.dx)&&void 0!==o?o:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((o,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:o[0],y:o[1],nx:t,ny:a});return e.jsx(Ke,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+n)});return e.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return e.jsx(Ke,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Ze(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.x)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.time;return r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function Je(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==n?n:null===(i=t.scales)||void 0===i?void 0:i.value;return r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function et(e,t,o){var n,i,r,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let i=o.pointNodes.length-1;i>=0;i--){const r=o.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(n=o.stickyPositionCache)||void 0===n||n.set(t,e),e}}const r=function(e){var t,o,n,i,r,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(o=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==o?o:null===(n=e.scales)||void 0===n?void 0:n.time,u=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(o);return r&&(null===(i=o.stickyPositionCache)||void 0===i||i.set(t,r)),r}let l=null,c=null;if(null!=e.pointId&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Ze(e,o),c=Je(e,o)),null!=l&&null!=c)return null===(r=o.stickyPositionCache)||void 0===r||r.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=o.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function tt(e,t,o,n=50){return!(-n>e||e>(o.width||0)+n||-n>t||t>(o.height||0)+n)}const ot={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};function nt(t){return function(t,o,n){var i,r,s,a,u,d,h,g,f,p,y,m,b,x,k,w,j,A,S,O,M,C,_,P,L,T,R,B,I,D,H,N,$,W,F,E,z,Y,G,q,X,V,U,K,Q,Z,J,ee;switch(t.type){case"label":{const i=et(t,o,n);if(!i)return null;const{x:r,y:s}=i;return tt(r,s,n)?e.jsx(Qe,{noteData:{x:r,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}},"ann-"+o):null}case"callout":{const i=et(t,o,n);if(!i)return null;const{x:r,y:s}=i;return tt(r,s,n)?e.jsx(Qe,{noteData:{x:r,y:s,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}},"ann-"+o):null}case"x-threshold":{const i=Ze(t,n);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(n.height||0)-4:"center"===s?(n.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:i,y1:0,x2:i,y2:n.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:i+4,y:a,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+o)}case"y-threshold":{const i=Je(t,n);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(n.width||0)/2,l="middle"):(a=(n.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:i,x2:n.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+o)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Ze(Object.assign(Object.assign({},e),{type:"point"}),n),y:Je(Object.assign(Object.assign({},e),{type:"point"}),n),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=l.packEnclose(i),s=t.padding||10;return e.jsxs("g",{children:[e.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+o)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Ze(Object.assign(Object.assign({},e),{type:"point"}),n),y:Je(Object.assign(Object.assign({},e),{type:"point"}),n)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,s=i.map(e=>e.x),a=i.map(e=>e.y),l=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...a)-r,d=Math.max(...a)+r;return e.jsxs("g",{children:[e.jsx("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+o)}case"highlight":{const i=n.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],s={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.jsx("g",{children:r.map((o,i)=>{const r=Ze(o,n),a=Je(o,n);if(null==r||null==a)return null;const l="function"==typeof t.r?t.r(o):t.r||6,c="function"==typeof t.style?t.style(o):t.style||s;return e.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+o)}case"bracket":{const i=Ze(t,n),r=Je(t,n);return e.jsx(Qe,{noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+o)}case"trend":{const l=n.data||[];if(2>l.length)return null;const c=n.xAccessor||"x",g=n.yAccessor||"y",f=l.map(e=>[e[c],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const p=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(s=n.scales)||void 0===s?void 0:s.time,y=null!==(u=null===(a=n.scales)||void 0===a?void 0:a.y)&&void 0!==u?u:null===(d=n.scales)||void 0===d?void 0:d.value;if(!p||!y)return null;const m=t.method||"linear";let b;b="loess"===m?function(e,t=.3){const o=e.length;if(2>o)return e.slice();const n=e.slice().sort((e,t)=>e[0]-t[0]),i=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.max(2,Math.ceil(t*o)),a=[];for(let e=0;o>e;e++){const t=i[e],n=i.map(e=>Math.abs(e-t)),l=n.slice().sort((e,t)=>e-t)[Math.min(s-1,o-1)]||1,c=[];for(let e=0;o>e;e++){const t=0===l?0:n[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,g=0,f=0;for(let e=0;o>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],g+=t*i[e]*i[e],f+=t*i[e]*r[e])}if(0===u){a.push([t,r[e]]);continue}const p=u*g-d*d;if(1e-12>Math.abs(p))a.push([t,h/u]);else{const e=(u*f-d*h)/p;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===m?v.default.polynomial(f,{order:t.order||2}):v.default.linear(f)).points;const x=b.map(([e,t])=>`${p(e)},${y(t)}`).join(" "),k=t.color||"#6366f1";return e.jsxs("g",{children:[e.jsx("polyline",{points:x,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:p(b[b.length-1][0])+4,y:y(b[b.length-1][1])-4,fill:k,fontSize:11,children:t.label})]},"ann-"+o)}case"band":{const i=null!==(f=null===(g=n.scales)||void 0===g?void 0:g.y)&&void 0!==f?f:null===(p=n.scales)||void 0===p?void 0:p.value,r=null!==(y=null==i?void 0:i(t.y0))&&void 0!==y?y:0,s=null!==(m=null==i?void 0:i(t.y1))&&void 0!==m?m:n.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,s),width:n.width||0,height:Math.abs(s-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+o)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",s=null!==(x=null===(b=n.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(k=n.scales)||void 0===k?void 0:k.time,a=null!==(j=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==j?j:null===(A=n.scales)||void 0===A?void 0:A.value;if(!s||!a)return null;const l=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=i.filter(e=>null!=e[l]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=ot[n.curve||"linear"]||c.curveLinear,f=c.area().x(e=>s(e[r])).y0(e=>a(e[u])).y1(e=>a(e[l])).curve(g)(h);if(!f)return null;const p=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:f,fill:p,fillOpacity:null!==(S=t.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:s(h[h.length-1][r])+4,y:a(h[h.length-1][l])-4,fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",s=null!==(M=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==M?M:null===(C=n.scales)||void 0===C?void 0:C.time,a=null!==(P=null===(_=n.scales)||void 0===_?void 0:_.y)&&void 0!==P?P:null===(L=n.scales)||void 0===L?void 0:L.value;if(!s||!a)return null;const l=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),h=null!==(T=t.threshold)&&void 0!==T?T:2,g=c-h*d,f=!1!==t.showBand,p=t.fill||"#6366f1",y=null!==(R=t.fillOpacity)&&void 0!==R?R:.1,v=t.anomalyColor||"#ef4444",m=null!==(B=t.anomalyRadius)&&void 0!==B?B:6,b=a(c+h*d),x=a(g),k=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>h*d});return e.jsxs("g",{children:[f&&e.jsx("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((t,o)=>{const i=Ze(t,n),r=Je(t,n);return null==i||null==r?null:e.jsx("circle",{cx:i,cy:r,r:m,fill:v,fillOpacity:.7,stroke:v,strokeWidth:1.5},"anomaly-"+o)}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",s=n.yAccessor||"y",a=null!==(D=null===(I=n.scales)||void 0===I?void 0:I.x)&&void 0!==D?D:null===(H=n.scales)||void 0===H?void 0:H.time,l=null!==($=null===(N=n.scales)||void 0===N?void 0:N.y)&&void 0!==$?$:null===(W=n.scales)||void 0===W?void 0:W.value;if(!a||!l)return null;const c=i.map(e=>[e[r],e[s]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear")){const e=v.default.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,o,n)=>e+o*Math.pow(t,n),0)}else{const e=c.length;let t=0,o=0,n=0,i=0;for(const[e,r]of c)t+=e,o+=r,n+=e*e,i+=e*r;const r=e*n-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*o)/r,a=(o-s*t)/e;u=e=>a+s*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),g=Math.sqrt(h/Math.max(d-2,1)),f=c.reduce((e,t)=>e+t[0],0)/d,p=c.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),y=null!==(F=t.confidence)&&void 0!==F?F:.95,m=.99>y?.95>y?.9>y?1:1.645:1.96:2.576,b=null!==(E=t.steps)&&void 0!==E?E:5,x=c[d-1][0],k=(x-c[0][0])/Math.max(d-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*k);const j=[];for(const e of w){const t=u(e),o=g*Math.sqrt(1+1/d+(p>0?Math.pow(e-f,2)/p:0))*m;j.push({x:e,yCenter:t,yUpper:t+o,yLower:t-o})}const A=`M${j.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${j.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=j.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),O=`${a(x)},${l(u(x))}`,M=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(z=t.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),e.jsx("polyline",{points:`${O} ${S}`,fill:"none",stroke:M,strokeWidth:null!==(Y=t.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&j.length>0&&e.jsx("text",{x:a(j[j.length-1].x)+4,y:l(j[j.length-1].yCenter)-4,fill:M,fontSize:11,children:t.label})]},"ann-"+o)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=et(t,o,n);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!tt(i,r,n))return null;const s=null!==(q=t.dx)&&void 0!==q?q:0,a=null!==(X=t.dy)&&void 0!==X?X:0,l=null!==(V=t.width)&&void 0!==V?V:32,c=null!==(U=t.height)&&void 0!==U?U:32,u=null!==(K=t.content)&&void 0!==K?K:e.jsx("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return e.jsx("foreignObject",{x:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:e.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const i=et(t,o,n);if(!i)return null;const{x:r,y:s}=i;return e.jsx("text",{x:r+(t.dx||0),y:s+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label},"ann-text-"+o)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=null===(Q=n.scales)||void 0===Q?void 0:Q.o,s=null===(Z=n.scales)||void 0===Z?void 0:Z.x,a=null===(J=n.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=t.color||"var(--semiotic-primary, #4589ff)",h=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,g=t.label;return e.jsxs("g",(n.projection?"vertical"===n.projection:l===s)?{children:[e.jsx("rect",{x:c,y:0,width:u,height:n.height||0,fill:d,fillOpacity:h}),g&&e.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:g})]}:{children:[e.jsx("rect",{x:0,y:c,width:n.width||0,height:u,fill:d,fillOpacity:h}),g&&e.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+o)}default:return null}}}let it={positions:new Map};const rt=new Set;function st(){for(const e of rt)e()}function at(e,t){const o=it.positions.get(e);if(null==o?void 0:o.locked)return;if(!o||o.sourceId!==t)return;const n=new Map(it.positions);n.delete(e),it={positions:n},st()}function lt(e,t){const o=it.positions.get(e);if(!(null==o?void 0:o.locked))return;if(t&&o.sourceId!==t)return;const n=new Map(it.positions);n.delete(e),it={positions:n},st()}function ct(){return it}function ut(e){return rt.add(e),()=>rt.delete(e)}const dt={positions:new Map};function ht(){return()=>{}}function gt(){return dt}function ft(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function pt(e,t,o){if("left"===e||"right"===e){const n="left"===e?o:0,i="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+n;for(let e=0;r>e;e++){const o=8*(e+1);s+=`L${Math.min(8*e+4,t)},${n+4*i}`,s+=`L${Math.min(o,t)},${n}`}return s}{const n="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(o/8);let s=`M${n},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${n+4*i},${Math.min(8*e+4,o)}`,s+=`L${n},${Math.min(t,o)}`}return s}}function yt(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:g}=o,f=t.useMemo(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||h||vt,i=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,r=l.x.ticks(Math.min(i,Math.max(2,Math.floor(n/70)))),s=r.map(e=>e.valueOf()),a=r.map((e,t)=>({value:e,pixel:l.x(e),label:o(e,t,s)})),c=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return mt(a,Math.max(55,c+8))},[l,u,h,n]),p=t.useMemo(()=>{var e;if(!l)return[];const t=null==u?void 0:u.find(e=>"left"===e.orient),o=(null==t?void 0:t.tickFormat)||g||vt,n=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return mt(l.y.ticks(Math.min(n,Math.max(2,Math.floor(i/30)))).map(e=>({value:e,pixel:l.y(e),label:o(e)})),22)},[l,u,g,i]),y=d&&l,v=c&&l;if(!y&&!v)return null;const m=null==u?void 0:u.find(e=>"bottom"===e.orient),b=null==u?void 0:u.find(e=>"left"===e.orient),x=v&&(!m||!1!==m.baseline),k=v&&(!b||!1!==b.baseline),w=(null==m?void 0:m.jaggedBase)||!1,j=(null==b?void 0:b.jaggedBase)||!1,A="var(--semiotic-border, #ccc)";return e.jsx("svg",{width:r,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[y&&(()=>{var t,o;const r=ft(null===(t=null==u?void 0:u.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),s=ft(null===(o=null==u?void 0:u.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[f.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+o)),p.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+o))]})})(),x&&!w&&e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:A,strokeWidth:1}),w&&e.jsx("path",{d:pt("bottom",n,i),fill:"none",stroke:A,strokeWidth:1}),k&&!j&&e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:A,strokeWidth:1}),j&&e.jsx("path",{d:pt("left",n,i),fill:"none",stroke:A,strokeWidth:1})]})})}function vt(e,t,o){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function mt(e,t){if(2>=e.length)return e;const o=[e[0]];for(let n=1;e.length-1>n;n++)t>Math.abs(e[n].pixel-o[o.length-1].pixel)||o.push(e[n]);const n=e[e.length-1];return t>Math.abs(n.pixel-o[o.length-1].pixel)?o[o.length-1]=n:o.push(n),o}function bt(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,axes:h,xLabel:g,yLabel:f,yLabelRight:p,xFormat:y,yFormat:v,showGrid:m,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:j,legendIsolatedCategories:A,legendPosition:S="right",foregroundGraphics:O,marginalGraphics:M,xValues:C,yValues:_,annotations:P,svgAnnotationRules:L,xAccessor:T,yAccessor:R,annotationData:B,pointNodes:I,curve:D,underlayRendered:H,linkedCrosshairName:N,linkedCrosshairSourceId:$,children:W}=o,F=t.useMemo(()=>{var e;if(!d||!u)return[];const t=null==h?void 0:h.find(e=>"bottom"===e.orient),o=(null==t?void 0:t.tickFormat)||y||vt,n=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=u.x.ticks(Math.min(n,Math.max(2,Math.floor(r/70)))),s=i.map(e=>e.valueOf()),a=i.map((e,t)=>({value:e,pixel:u.x(e),label:o(e,t,s)})),l=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let g=mt(a,c);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),(null==t?void 0:t.includeMax)&&g.length>0){const e=u.x.domain()[1],t=u.x(e),n=g[g.length-1].pixel;if(Math.abs(t-n)>1){const i=o(e,g.length,s);c>t-n&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:i})}}return g},[d,u,h,y,r]),E=t.useMemo(()=>{var e;if(!d||!u)return[];const t=null==h?void 0:h.find(e=>"left"===e.orient),o=(null==t?void 0:t.tickFormat)||v||vt,n=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let i=mt(u.y.ticks(Math.min(n,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:u.y(e),label:o(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),(null==t?void 0:t.includeMax)&&i.length>0){const e=u.y.domain()[1],t=u.y(e),n=i[i.length-1].pixel;if(Math.abs(t-n)>1){const r=o(e);22>Math.abs(t-n)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:t,label:r})}}return i},[d,u,h,v,s]),z=t.useMemo(()=>{var e;if(!d||!u)return[];const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t)return[];const o=t.tickFormat||v||vt,n=null!==(e=t.ticks)&&void 0!==e?e:5;return mt(u.y.ticks(Math.min(n,Math.max(2,Math.floor(s/30)))).map(e=>({value:e,pixel:u.y(e),label:o(e)})),22)},[d,u,h,v,s]),Y=t.useRef(new Map),G=t.useRef(null!==(n=null==P?void 0:P.length)&&void 0!==n?n:0),q=null!==(i=null==P?void 0:P.length)&&void 0!==i?i:0;G.current!==q&&(G.current=q,Y.current=new Map);const X=t.useMemo(()=>{if(!P||0===P.length)return null;const e=nt(),t={scales:u?{x:u.x,y:u.y,time:u.x,value:u.y}:null,timeAxis:"x",xAccessor:T,yAccessor:R,width:r,height:s,data:B,frameType:"xy",pointNodes:I,curve:D,stickyPositionCache:Y.current};return P.map((o,n)=>{if(L){const i=L(o,n,t);return null!=i?i:e(o,n,t)}return e(o,n,t)}).filter(Boolean)},[P,L,r,s,T,R,B,u,I,D]),V=function(e){var o;const n=t.useSyncExternalStore(e?ut:ht,e?ct:gt,e?ct:gt);return e&&null!==(o=n.positions.get(e))&&void 0!==o?o:null}(N);return t.useEffect(()=>{if(!(null==V?void 0:V.locked)||!N)return;const e=e=>{"Escape"===e.key&<(N)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==V?void 0:V.locked,N]),d||b||x||O||M||X&&X.length>0||m||W||V?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof b?b:"XY Chart"}),e.jsx("desc",{children:"string"==typeof b?b+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[m&&u&&!H&&(()=>{var t,o;const n=ft(null===(t=null==h?void 0:h.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=ft(null===(o=null==h?void 0:h.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[F.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"xgrid-"+o)),E.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+o))]})})(),d&&u&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),o=null==h?void 0:h.find(e=>"bottom"===e.orient),n=!t||!1!==t.baseline,i=!o||!1!==o.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==o?void 0:o.jaggedBase)||!1,u=null==o?void 0:o.landmarkTicks,d=null==t?void 0:t.landmarkTicks,y="var(--semiotic-border, #ccc)",v="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",b=!!(null==o?void 0:o.autoRotate)&&F.length>1&&(()=>{const e=r/Math.max(F.length-1,1);return F.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!H&&i&&!l&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:y,strokeWidth:1}),!H&&l&&e.jsx("path",{d:pt("bottom",r,s),fill:"none",stroke:y,strokeWidth:1}),F.map((t,o)=>{const n=!!u&&("function"==typeof u?u(t.value,o):ge(t.value,o>0?F[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:v,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0,children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"xtick-"+o)}),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:m,style:{userSelect:"none"},children:g}),!H&&n&&!a&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:y,strokeWidth:1}),!H&&a&&e.jsx("path",{d:pt("left",r,s),fill:"none",stroke:y,strokeWidth:1}),E.map((t,o)=>{const n=!!d&&("function"==typeof d?d(t.value,o):ge(t.value,o>0?E[o-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n?11:10,fontWeight:n?600:400,fill:v,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-"+o)}),(()=>{const o=(null==t?void 0:t.label)||f;return o?e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fontSize:12,fill:m,transform:`rotate(-90, ${15-c.left}, ${s/2})`,style:{userSelect:"none"},children:o}):null})(),(()=>{const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t||0===z.length)return null;const o=t.landmarkTicks,n=t.label||p;return e.jsxs(e.Fragment,{children:[!1!==t.baseline&&e.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:y,strokeWidth:1}),z.map((t,n)=>{const i=!!o&&("function"==typeof o?o(t.value,n):ge(t.value,n>0?z[n-1].value:void 0));return e.jsxs("g",{transform:`translate(${r},${t.pixel})`,children:[e.jsx("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:v,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-r-"+n)}),n&&e.jsx("text",{x:r+c.right-15,y:s/2,textAnchor:"middle",fontSize:12,fill:m,transform:`rotate(90, ${r+c.right-15}, ${s/2})`,style:{userSelect:"none"},children:n})]})})()]})})(),X,M&&u&&C&&_&&e.jsxs(e.Fragment,{children:[M.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(Ye,{orient:"top",config:ze(M.top),values:C,scale:u.x,size:c.top,length:r})}),M.bottom&&e.jsx("g",{transform:`translate(0, ${s})`,children:e.jsx(Ye,{orient:"bottom",config:ze(M.bottom),values:C,scale:u.x,size:c.bottom,length:r})}),M.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(Ye,{orient:"left",config:ze(M.left),values:_,scale:u.y,size:c.left,length:s})}),M.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx(Ye,{orient:"right",config:ze(M.right),values:_,scale:u.y,size:c.right,length:s})})]}),O,V&&V.sourceId!==$&&(null==u?void 0:u.x)&&(()=>{const t=u.x(V.xValue);if(null==t||0>t||t>r)return null;const o=V.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),W]}),b&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof b?b:null}),Ee({legend:x,totalWidth:a,totalHeight:l,margin:c,legendPosition:S,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:j,legendIsolatedCategories:A})]}):null}function xt(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const kt="undefined"==typeof window||"undefined"==typeof document,wt=y.createContext(null);function jt({children:t}){const[o,n]=y.useState(!1),i=y.useMemo(()=>({visible:o,setVisible:n}),[o]);return e.jsx(wt.Provider,{value:i,children:t})}function At(){return y.useContext(wt)}const St={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ot(e,t){if(!e||0===e.length)return t+", empty";const o={};for(const t of e)o[t.type]=(o[t.type]||0)+1;const n=[],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(o).sort((e,t)=>{const o=r.indexOf(e),n=r.indexOf(t);return(-1===o?999:o)-(-1===n?999:n)});for(const e of s)n.push(`${o[e]} ${i[e]||e}`);return`${t}, ${n.join(", ")}`}function Mt(e,t,o){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?o+", empty":`${o}, ${n.join(", ")}`}const Ct=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},_t={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"},Pt={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Lt={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)"},Tt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Rt={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)"},Bt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},It={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Dt({scene:t,chartType:o,tableId:n,chartTitle:i}){var r;const[s,a]=y.useState(!1),l=At(),c=null!==(r=null==l?void 0:l.visible)&&void 0!==r&&r,u=s||c,d=y.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${o} ${n}`:"Data summary for "+o,g=y.useCallback(()=>{s||c||a(!0)},[s,c]),f=y.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[c]);if(!t||0===t.length)return n?e.jsx("span",{id:n,tabIndex:-1,style:St}):null;if(!u)return e.jsx("div",{id:n,tabIndex:-1,onFocus:g,style:St,role:"region","aria-label":h,children:e.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",t.length," elements)"]})});const p=function(e){var t,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,v,m,b,x,k,w,j,A,S;const O=[];if(!Array.isArray(e))return O;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":O.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&O.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&O.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},r=null!==(o=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==o?o:"",s=null!==(i=null!==(n=e.value)&&void 0!==n?n:e.__aggregateValue)&&void 0!==i?i:e.total;O.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":O.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":O.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=M.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=M.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":O.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=M.cx)&&void 0!==g?g:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":O.push({label:"Arc",values:{id:null!==(y=null===(p=M.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(v=M.cx)&&void 0!==v?v:M.x,y:null!==(m=M.cy)&&void 0!==m?m:M.y}});break;case"candlestick":O.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":O.push({label:"Region",values:{name:null!==(j=null!==(k=null===(x=null===(b=M.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=M.datum)||void 0===w?void 0:w.name)&&void 0!==j?j:"",value:null!==(S=null===(A=M.datum)||void 0===A?void 0:A.value)&&void 0!==S?S:""}})}}catch(e){}return O}(t),v=function(e){if(!e||0===e.length)return[];const t=new Set;for(const o of e)if(o&&o.values)for(const e of Object.keys(o.values))t.add(e);const o=[];for(const n of t){const t=[],i=new Set;for(const o of e){if(!o||!o.values)continue;const e=o.values[n];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],r=0;for(const o of t)e>o&&(e=o),o>i&&(i=o),r+=o;o.push({name:n,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);o.push({name:n,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return o}(p),m=function(e,t){const o=[e+" data points."];for(const e of t)if(e.numeric)o.push(`${e.name}: ${Ct(e.min)} to ${Ct(e.max)}, mean ${Ct(e.mean)}.`);else{const t=e.uniqueValues,n=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");o.push(`${e.name}: ${n}.`)}return o.join(" ")}(p.length,v),b=p.slice(0,5),x=new Set;for(const e of b)for(const t of Object.keys(e.values))x.add(t);const k=Array.from(x);return e.jsxs("div",{ref:d,id:n,tabIndex:-1,onBlur:f,style:_t,role:"region","aria-label":h,children:[e.jsx("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Lt,children:"×"}),e.jsx("div",{role:"note",style:Pt,children:m}),e.jsxs("table",{role:"table","aria-label":"Sample data for "+o,style:Tt,children:[e.jsxs("caption",{style:It,children:["First ",b.length," of ",p.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Rt,children:"type"}),k.map(t=>e.jsx("th",{style:Rt,children:t},t))]})}),e.jsx("tbody",{children:b.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:Bt,children:t.label}),k.map(o=>{return e.jsx("td",{style:Bt,children:(n=t.values[o],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Ct(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},o);var n})]},o))})]})]})}function Ht({nodes:t,edges:o,chartType:n,tableId:i,chartTitle:r}){var s,a,l,c,u,d,h,g,f,p,v,m,b,x;const[k,w]=y.useState(!1),j=At(),A=null!==(s=null==j?void 0:j.visible)&&void 0!==s&&s,S=k||A,O=r?"Data summary for "+r:i?`Data summary for ${n} ${i}`:"Data summary for "+n,M=y.useRef(null),C=y.useCallback(()=>{k||A||w(!0)},[k,A]),_=y.useCallback(e=>{var t;A||(null===(t=M.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[A]);if(!t||0===t.length)return i?e.jsx("span",{id:i,tabIndex:-1,style:St}):null;if(!S)return e.jsx("div",{id:i,tabIndex:-1,onFocus:C,style:St,role:"region","aria-label":O,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",o.length," edges)"]})});const P=Array.isArray(t)?t:[],L=Array.isArray(o)?o:[],T=new Map,R=new Map,B=new Map,I=new Map;for(const e of L){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,o="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=o&&""!==o){const e=o+"";R.set(e,(null!==(u=R.get(e))&&void 0!==u?u:0)+1),I.set(e,(null!==(d=I.get(e))&&void 0!==d?d:0)+i)}if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(h=T.get(e))&&void 0!==h?h:0)+1),B.set(e,(null!==(g=B.get(e))&&void 0!==g?g:0)+i)}}const D=[];for(let e=0;P.length>e;e++){const t=P[e];if(!t||"object"!=typeof t)continue;const o=null!==(p=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==p?p:t.id,n=null!=o?o+"":"node-"+e,i=null!==(v=T.get(n))&&void 0!==v?v:0,r=null!==(m=R.get(n))&&void 0!==m?m:0,s=null!==(b=B.get(n))&&void 0!==b?b:0,a=null!==(x=I.get(n))&&void 0!==x?x:0;D.push({id:n,degree:i+r,inDeg:i,outDeg:r,wDegree:s+a,wInDeg:s,wOutDeg:a})}D.sort((e,t)=>t.degree-e.degree);let H=0,N=0;if(D.length>0){let e=0;for(const t of D)e+=t.degree,t.degree>N&&(N=t.degree);H=e/D.length}const $=L.some(e=>{var t;const o=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==o?void 0:o.value)&&Number.isFinite(o.value)}),W=[`${D.length} nodes, ${L.length} edges.`];D.length>0&&W.push(`Mean degree: ${Ct(H)}, max degree: ${N}.`);const F=D.slice(0,5);return e.jsxs("div",{ref:M,id:i,tabIndex:-1,onBlur:_,style:_t,role:"region","aria-label":O,children:[e.jsx("button",{type:"button",onClick:()=>{A&&j&&j.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:Lt,children:"×"}),e.jsx("div",{role:"note",style:Pt,children:W.join(" ")}),e.jsxs("table",{role:"table","aria-label":"Node degree summary for "+n,style:Tt,children:[e.jsxs("caption",{style:It,children:["Top ",F.length," of ",D.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Rt,children:"id"}),e.jsx("th",{style:Rt,children:"degree"}),e.jsx("th",{style:Rt,children:"in"}),e.jsx("th",{style:Rt,children:"out"}),$&&e.jsx("th",{style:Rt,children:"w. degree"}),$&&e.jsx("th",{style:Rt,children:"w. in"}),$&&e.jsx("th",{style:Rt,children:"w. out"})]})}),e.jsx("tbody",{children:F.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:Bt,children:t.id}),e.jsx("td",{style:Bt,children:t.degree}),e.jsx("td",{style:Bt,children:t.inDeg}),e.jsx("td",{style:Bt,children:t.outDeg}),$&&e.jsx("td",{style:Bt,children:Ct(t.wDegree)}),$&&e.jsx("td",{style:Bt,children:Ct(t.wInDeg)}),$&&e.jsx("td",{style:Bt,children:Ct(t.wOutDeg)})]},o))})]})]})}function Nt({summary:t}){return t?e.jsx("div",{role:"note",style:St,children:t}):null}function $t({tableId:t}){return e.jsx("a",{href:"#"+t,style:St,onClick:e=>{e.preventDefault();const o=document.getElementById(t);o&&requestAnimationFrame(()=>o.focus())},onFocus:e=>{Object.assign(e.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:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,St)},children:"Skip to data table"})}function Wt({hoverPoint:t}){let o="";if(t){const e=t.data||t;o="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:St,children:o})}const Ft="var(--semiotic-focus, #005fcc)";function Et({active:t,hoverPoint:o,margin:n,size:i,shape:r="circle",width:s,height:a}){if(!t||!o)return null;const l=o.x+n.left,c=o.y+n.top;let u;if("rect"===r&&null!=s&&null!=a){const t=Math.max(s,4),o=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-o/2-3,width:t+6,height:o+6,rx:3,fill:"none",stroke:Ft,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Ft,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Ft,strokeWidth:2,strokeDasharray:"4,2"});return e.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 zt({x:t,y:o,containerWidth:n,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=y.useRef(null),[u,d]=y.useState(null);y.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,n,i]);let h;return h=u?`translate(${u.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-o?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>o?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:c,className:a,style:{position:"absolute",left:r.left+t,top:r.top+o,transform:h,pointerEvents:"none",zIndex:l,width:"max-content"},children:s})}function Yt(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}function Gt(e,o,n){const i=t.useRef(null),[r,s]=t.useState(null);return t.useEffect(()=>{if(!o&&!n)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:o}=t.contentRect;s(t=>t&&t.w===e&&t.h===o?t:{w:e,h:o})}});return t.observe(e),()=>t.disconnect()},[o,n]),[i,[o&&r?r.w:e[0],n&&r?r.h:e[1]]]}const qt=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Xt=new WeakMap;let Vt=0,Ut=!1,Kt=null,Qt=null,Zt=null;function Jt(e,t){var o,n;if(!t)return t;const i=qt.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(o=i[2])||void 0===o?void 0:o.trim())||t;!function(){if(Ut)return;if("undefined"==typeof window||"undefined"==typeof document)return;Ut=!0;const e=()=>{Vt++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(Kt=new MutationObserver(e),Kt.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Qt=window.matchMedia("(prefers-color-scheme: dark)"),Zt=e,"function"==typeof Qt.addEventListener?Qt.addEventListener("change",Zt):"function"==typeof Qt.addListener&&Qt.addListener(Zt)}catch(e){}}();let s=Xt.get(r);s&&s.version===Vt||(s={version:Vt,map:new Map},Xt.set(r,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(n=i[2])||void 0===n?void 0:n.trim())||t;return s.map.set(t,l),l}function eo(e,t,o){return"function"==typeof e?e({size:t,margin:o}):e}function to(e){const o=function(){const[e,o]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return o(e.matches),Yt(e,e=>o(e.matches))},[]),e}(),n=t.useRef(o);n.current=o;const[i,r]=Gt(e.sizeProp,e.responsiveWidth,e.responsiveHeight),s=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),a=r[0]-s.left-s.right,l=r[1]-s.top-s.bottom,c=eo(e.foregroundGraphics,r,s),u=eo(e.backgroundGraphics,r,s),d=L(e=>e.theme),{transition:h,introEnabled:g}=function(e,t){var o,n;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(o=window.matchMedia)||void 0===o?void 0:o.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(n=e.duration)&&void 0!==n?n:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+y.useId(),p=t.useRef(0),v=t.useRef(()=>{}),m=t.useCallback(()=>{p.current||(p.current=requestAnimationFrame(()=>v.current()))},[]);t.useEffect(()=>()=>{p.current&&(cancelAnimationFrame(p.current),p.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),k=t.useRef(null),w=t.useRef(0),j=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),A=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(j))},[j]),S=t.useCallback(()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0),x.current()},[]);t.useEffect(()=>()=>{k.current=null,0!==w.current&&(cancelAnimationFrame(w.current),w.current=0)},[]);const O=e.themeDirtyRef;return t.useEffect(()=>{O&&(Vt++,O.current=!0,m())},[d,m,O]),{reducedMotion:o,reducedMotionRef:n,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:g,tableId:f,rafRef:p,renderFnRef:v,scheduleRender:m,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:A,onPointerLeave:S}}function oo(e,t,o,n){const i=e.getContext("2d");if(!i)return null;const r=t[0]*n,s=t[1]*n,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===r&&e.height===s||(e.width=r,e.height=s),i.setTransform(n,0,0,n,0,0),i.translate(o.left,o.top),i}function no(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function io(e){switch(e){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 ro(e,t,o){let n=o;for(const o of t)"lesser"===o.thresholdType?o.value>e&&(n=o.color):e>o.value&&(n=o.color);return n}function so(e,t,o,n,i,r){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const o=t[e][0]-t[e-1][0],n=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(o*o+n*n))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=o,e.lineWidth=n,e.lineCap=r;for(let o=0;t.length-1>o;o++){const n=(s[o]+s[o+1])/2;let r=i;l>n&&(r*=n/l),l>a-n&&(r*=(a-n)/l),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[o][0],t[o][1]),e.lineTo(t[o+1][0],t[o+1][1]),e.stroke()}}const ao=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"line"===e.type);for(const a of s){if(2>a.path.length)continue;const l=a._introClipFraction;void 0!==l&&1>l&&(e.save(),e.beginPath(),e.rect(0,0,n.width*l,n.height),e.clip());const u=a.style.stroke||"#007bff",d=Jt(e,u)||u,h=a.style.strokeWidth||2,g=a.colorThresholds,f=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=h,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const m=null!==(i=a.style.opacity)&&void 0!==i?i:1;so(e,a.path,d,h,m,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const p=io(a.curve),y=g&&g.length>0&&f&&f.length===a.path.length,v=a._decayOpacities;if(v&&v.length===a.path.length&&!y){e.strokeStyle=d;const b=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let x=0;a.path.length-1>x;x++)e.globalAlpha=.5*(v[x]+v[x+1])*b,e.beginPath(),e.moveTo(a.path[x][0],a.path[x][1]),e.lineTo(a.path[x+1][0],a.path[x+1][1]),e.stroke()}else if(y){let k=null,w=null,j=null,A=null,S=!1;function O(t,o,n){e.beginPath(),e.strokeStyle=t,e.moveTo(o,n),S=!0}function M(){S&&(e.stroke(),S=!1)}for(let C=0;a.path.length>C;C++){const[_,P]=a.path[C],L=f[C],T=ro(L,g,d);if(null!==k&&null!==A&&null!==j){if(T===A)e.lineTo(_,P);else{const R=[];for(const B of g){const I=B.value;(j>I||I>L)&&(I>j||L>I)||j===I||L===I||R.push({t:(I-j)/(L-j)})}R.sort((e,t)=>e.t-t.t);for(const D of R){const H=k+(_-k)*D.t,N=w+(P-w)*D.t,$=ro(j+(L-j)*Math.min(D.t+1e-4,1),g,d);e.lineTo(H,N),M(),O($,H,N)}e.lineTo(_,P)}k=_,w=P,j=L,A=T}else O(T,_,P),k=_,w=P,j=L,A=T}M()}else{if(e.beginPath(),!a.strokeGradient||2>a.strokeGradient.colorStops.length||2>a.path.length)e.strokeStyle=d;else{const W=e.createLinearGradient(a.path[0][0],0,a.path[a.path.length-1][0],0);for(const F of a.strokeGradient.colorStops)W.addColorStop(Math.max(0,Math.min(1,F.offset)),F.color);e.strokeStyle=W}if(p)c.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(a.path);else{const[E,z]=a.path[0];e.moveTo(E,z);for(let Y=1;a.path.length>Y;Y++)e.lineTo(a.path[Y][0],a.path[Y][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=("string"==typeof a.style.fill?Jt(e,a.style.fill):a.style.fill)||a.style.fill,p&&!y)c.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(a.path);else{const[q,X]=a.path[0];e.moveTo(q,X);for(let V=1;a.path.length>V;V++)e.lineTo(a.path[V][0],a.path[V][1])}const G=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],n.height),e.lineTo(G,n.height),e.closePath(),e.fill()}void 0!==l&&1>l&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function lo(e,t){const o=e.fillStyle,n="#010203";try{e.fillStyle=n,e.fillStyle=t}catch(t){return e.fillStyle=o,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=o,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===n&&t.trim().toLowerCase()!==n)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]}function co(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function uo(e,t,o=.3){co(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function ho(e,t,o=.6){var n,i,r,s,a;if(!co(t))return;const l=null!==(n=t._pulseGlowRadius)&&void 0!==n?n:4,c=t.r+l*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*o,e.stroke()}function go(e,t,o,n=.35){co(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function fo(e){switch(e){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 po(e,t){const o=fo(t.curve);if(!o||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);for(let o=t.bottomPath.length-1;o>=0;o--)e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]);e.closePath()}else{const n=c.area().x(e=>e[0]).y0((e,o)=>t.bottomPath[o][1]).y1(e=>e[1]).curve(o).context(e);e.beginPath(),n(t.topPath)}}const yo=(e,t,o,n)=>{var i,r,s;const a=t.filter(e=>"area"===e.type);for(const t of a){if(2>t.topPath.length)continue;const o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,n.width*o,n.height),e.clip());const a=t.style.fill||"#4e79a7",l=t._decayOpacities;if(l&&l.length===t.topPath.length){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=a;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(l[n]+l[n+1])*o,e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.lineTo(t.bottomPath[n+1][0],t.bottomPath[n+1][1]),e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(l[o]+l[o+1]),e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.stroke()}e.globalAlpha=1;continue}const u=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(po(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let o=1/0;for(const e of t.topPath)o>e[1]&&(o=e[1]);let n=-1/0;for(const e of t.bottomPath)e[1]>n&&(n=e[1]);const i=e.createLinearGradient(0,o,0,n);if("colorStops"in t.fillGradient)for(const e of t.fillGradient.colorStops){const t=Math.max(0,Math.min(1,e.offset));isNaN(t)||i.addColorStop(t,e.color)}else if("topOpacity"in t.fillGradient){const[o,n,r]=lo(e,"string"==typeof a?a:"#4e79a7");i.addColorStop(0,`rgba(${o},${n},${r},${t.fillGradient.topOpacity})`),i.addColorStop(1,`rgba(${o},${n},${r},${t.fillGradient.bottomOpacity})`)}e.fillStyle=i,e.globalAlpha=u}else{const o=null!==(s=t.style.fillOpacity)&&void 0!==s?s:.7;e.globalAlpha=o*u,e.fillStyle=a}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(po(e,t),go(e,t)),t.style.stroke&&"none"!==t.style.stroke){if(e.globalAlpha=u,!t.strokeGradient||2>t.strokeGradient.colorStops.length||2>t.topPath.length)e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke;else{const o=e.createLinearGradient(t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);for(const e of t.strokeGradient.colorStops)o.addColorStop(Math.max(0,Math.min(1,e.offset)),e.color);e.strokeStyle=o}e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=fo(t.curve);if(e.beginPath(),o)c.line().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1])}e.stroke()}void 0!==o&&1>o&&e.restore(),e.globalAlpha=1}},vo=(e,t,o,n)=>{var i;const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const o=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=("string"==typeof t.style.fill?Jt(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?Jt(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),ho(e,t),e.globalAlpha=1}}finally{e.restore()}}};function mo(e,t,o){const n=t.fillGradient;if(!n)return null;const i=t.roundedEdge;let r=t.x,s=t.y,a=t.x,l=t.y+t.h;if("bottom"===i?(s=t.y+t.h,l=t.y):"right"===i?(r=t.x+t.w,s=t.y,a=t.x,l=t.y):"left"===i&&(r=t.x,s=t.y,a=t.x+t.w,l=t.y),"colorStops"in n){const t=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>t.length)return null;const o=e.createLinearGradient(r,s,a,l);for(const e of t)o.addColorStop(e.offset,e.color);return o}const c=e.createLinearGradient(r,s,a,l),[u,d,h]=lo(e,o);return c.addColorStop(0,`rgba(${u},${d},${h},${n.topOpacity})`),c.addColorStop(1,`rgba(${u},${d},${h},${n.bottomOpacity})`),c}const bo=(e,t,o,n)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)xo(e,t);else if(t.roundedTop&&t.roundedTop>0){const o=("string"==typeof t.style.fill?Jt(e,t.style.fill):t.style.fill)||Jt(e,"var(--semiotic-primary, #007bff)"),n="string"==typeof o?mo(e,t,o):null;e.fillStyle=n||o;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:r,y:s,w:a,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(r,s),e.lineTo(r+a-i,s),e.arcTo(r+a,s,r+a,s+i,i),e.lineTo(r+a,s+l-i),e.arcTo(r+a,s+l,r+a-i,s+l,i),e.lineTo(r,s+l);break;case"left":e.moveTo(r+a,s),e.lineTo(r+i,s),e.arcTo(r,s,r,s+i,i),e.lineTo(r,s+l-i),e.arcTo(r,s+l,r+i,s+l,i),e.lineTo(r+a,s+l);break;case"bottom":e.moveTo(r,s),e.lineTo(r+a,s),e.lineTo(r+a,s+l-i),e.arcTo(r+a,s+l,r+a-i,s+l,i),e.lineTo(r+i,s+l),e.arcTo(r,s+l,r,s+l-i,i);break;default:e.moveTo(r,s+l),e.lineTo(r,s+i),e.arcTo(r,s,r+i,s,i),e.lineTo(r+a-i,s),e.arcTo(r+a,s,r+a,s+i,i),e.lineTo(r+a,s+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const o=("string"==typeof t.style.fill?Jt(e,t.style.fill):t.style.fill)||Jt(e,"var(--semiotic-primary, #007bff)"),n="string"==typeof o?mo(e,t,o):null;e.fillStyle=n||o,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}uo(e,t),e.globalAlpha=1}};function xo(e,t){const o=t.style.icon,n=t.style.iconPadding||2,i=Math.min(t.w,t.h)-n;if(0>=i)return;const r=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),r){const r=i+n,s=t.x+(t.w-i)/2;for(let n=t.y+t.h-i;n>=t.y-i;n-=r)e.drawImage(o,s,n,i,i)}else{const r=i+n,s=t.y+(t.h-i)/2;for(let n=t.x;t.x+t.w>n;n+=r)e.drawImage(o,n,s,i,i)}e.restore()}function ko(e,t,o,n){return Object.assign(Object.assign(Object.assign({},function(e){return"object"!=typeof e||null===e||Array.isArray(e)?{}:e}(e)),{data:e,x:t,y:o,time:t,value:o}),n)}function wo(e){const[t,o,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*o+.114*n>128?"#000":"#fff"}function jo(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ao=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function So(e){const t=e[1]-e[0],o=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:o>t?e=>{const t=new Date(e);return`${Ao[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*o>t?e=>{const t=new Date(e);return`${Ao[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Oo={line:[yo,ao,vo],area:[yo,vo],stackedarea:[yo,vo],scatter:[vo],bubble:[vo],heatmap:[(e,t,o,n)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const o=t.style;if(null!=(null==o?void 0:o.opacity)&&(e.globalAlpha=o.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Jt(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),uo(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const o=t.valueFormat?t.valueFormat(t.value):jo(t.value),n=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,r=t.y+t.h/2;e.fillStyle=wo(t.fill),e.font=n+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(o,i,r)}}}finally{e.restore()}}],bar:[bo],swarm:[vo],waterfall:[(e,t,o,n)=>{var i,r,s;bo(e,t);const a=t.filter(e=>"rect"===e.type);if(2>a.length)return;const l=a[0].datum,c=null==l?void 0:l._connectorStroke;if(c){e.save(),e.strokeStyle=Jt(e,c)||c,e.lineWidth=null!==(i=null==l?void 0:l._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;a.length-1>t;t++){const n=a[t],i=a[t+1];if(!(null===(r=n.datum)||void 0===r?void 0:r.cumEnd)||!(null===(s=i.datum)||void 0===s?void 0:s.baseline))continue;const l=o.y(n.datum.cumEnd),c=n.x+n.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[(e,t,o,n)=>{var i,r,s;for(const o of t){if("candlestick"!==o.type)continue;const t=o;e.save();const a=(null!==(i=t._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(e.globalAlpha=a);const l=Jt(e,t.wickColor)||t.wickColor,c=60>n.height,u=c?Math.max(t.wickWidth,2):t.wickWidth,d=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=l,e.lineWidth=u,e.stroke()};if(c||d(),t.isRange){const o=Math.max(2,Math.min(t.bodyWidth/2,.12*n.height));e.fillStyle=l,e.beginPath(),e.arc(t.x,t.highY,o,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,o,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const o=Math.min(t.openY,t.closeY),n=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,r=Jt(e,i)||i;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1))}c&&d(),e.restore()}}],mixed:[yo,ao,vo]},Mo={top:20,right:20,bottom:30,left:40},Co={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 _o(e,t){const o=e.trim();if(/^#[0-9a-f]{3}$/i.test(o)){const e=o[1],n=o[2],i=o[3];return`#${e}${e}${n}${n}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(o))return`${o}${t}`;const n=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return n?`rgba(${n[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:o}const Po={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 Lo({hover:t}){const o=e=>Number.isInteger(e)?e+"":e.toFixed(2);return e.jsxs("div",{className:"semiotic-tooltip",style:Po,children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:o(t.value)}),e.jsx("div",{style:{opacity:.7,fontSize:11},children:o(t.time)})]})}const To=t.forwardRef(function(o,n){var i,r,s,a,l,c,u,d,h,g,f;const{chartType:p,runtimeMode:v,data:m,chunkThreshold:b,chunkSize:w,xAccessor:j,yAccessor:S,colorAccessor:O,sizeAccessor:M,groupAccessor:C,lineDataAccessor:_,curve:P,normalize:L,binSize:T,valueAccessor:R,arrowOfTime:B="right",windowMode:I="sliding",windowSize:D=200,timeAccessor:H,xExtent:N,yExtent:$,extentPadding:W=.1,scalePadding:F,sizeRange:E,size:z=[500,300],responsiveWidth:Y,responsiveHeight:G,margin:q,className:X,background:V,lineStyle:U,pointStyle:K,areaStyle:Q,barStyle:Z,waterfallStyle:J,swarmStyle:ee,barColors:te,colorScheme:oe,boundsAccessor:ne,boundsStyle:ie,y0Accessor:re,gradientFill:se,lineGradient:ae,areaGroups:le,openAccessor:ue,highAccessor:de,lowAccessor:he,closeAccessor:ge,candlestickStyle:fe,showAxes:pe=!0,axes:me,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:we,yFormat:je,tickFormatTime:Ae,tickFormatValue:_e,hoverAnnotation:Pe,tooltipContent:Re,customHoverBehavior:Be,customClickBehavior:Ie,enableHover:De,hoverRadius:He=30,tooltipMode:Ne,annotations:$e,svgAnnotationRules:We,showGrid:Fe,legend:Ee,legendHoverBehavior:ze,legendClickBehavior:Ye,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Xe,backgroundGraphics:Ve,foregroundGraphics:Ue,canvasPreRenderers:Ke,svgPreRenderers:Qe,title:Ze,categoryAccessor:Je,brush:et,onBrush:tt,decay:ot,pulse:nt,transition:it,animate:rt,staleness:st,heatmapAggregation:at,heatmapXBins:lt,heatmapYBins:ct,showValues:ut,heatmapValueFormat:dt,marginalGraphics:ht,pointIdAccessor:gt,xScaleType:ft,yScaleType:pt,accessibleTable:vt=!0,description:mt,summary:wt,linkedCrosshairName:jt,linkedCrosshairSourceId:At}=o,St=t.useRef(!1),Mt=to({sizeProp:z,responsiveWidth:Y,responsiveHeight:G,userMargin:q,marginDefault:Mo,animate:rt,transitionProp:it,themeDirtyRef:St}),{reducedMotionRef:Ct,responsiveRef:_t,size:Pt,currentTheme:Lt,transition:Tt,introEnabled:Rt,tableId:Bt,rafRef:It,renderFnRef:Ht,scheduleRender:Ft}=Mt;let Yt=Mt.margin;if(ht){const e=60,t=Object.assign({},Mt.margin);ht.top&&e>t.top&&(t.top=e),ht.bottom&&e>t.bottom&&(t.bottom=e),ht.left&&e>t.left&&(t.left=e),ht.right&&e>t.right&&(t.right=e),Yt=t}const Gt="function"==typeof Ue?Ue({size:Pt,margin:Yt}):Ue,qt="function"==typeof Ve?Ve({size:Pt,margin:Yt}):Ve,Xt=Pt[0]-Yt.left-Yt.right,Vt=Pt[1]-Yt.top-Yt.bottom,Ut=null!=Pe?Pe:De,Kt=t.useRef(null),Qt=t.useRef(null),[Zt,Jt]=t.useState(0),[eo,io]=t.useState(null),ro=t.useRef(null),so=t.useRef(null),[ao,lo]=t.useState(null),co=t.useRef(Co.primary),[uo,ho]=t.useState(!1),[go,fo]=t.useState([]),[po,yo]=t.useState([]),vo="streaming"===v||["bar","swarm","waterfall"].includes(p),mo=t.useMemo(()=>{var e,t,o;return{chartType:p,runtimeMode:vo?"streaming":"bounded",windowSize:D,windowMode:I,arrowOfTime:vo?B:"right",extentPadding:W,scalePadding:F,xAccessor:vo?void 0:j,yAccessor:vo?void 0:S,timeAccessor:vo?H:void 0,valueAccessor:R,colorAccessor:O,sizeAccessor:M,groupAccessor:C||(_?"_lineGroup":void 0),categoryAccessor:Je,lineDataAccessor:_,xScaleType:ft,yScaleType:pt,xExtent:N,yExtent:$,sizeRange:E,binSize:T,normalize:L,boundsAccessor:ne,boundsStyle:ie,y0Accessor:re,gradientFill:!0===se?{topOpacity:.8,bottomOpacity:.05}:!1===se?void 0:se,areaGroups:le?new Set(le):void 0,lineGradient:ae,openAccessor:ue,highAccessor:de,lowAccessor:he,closeAccessor:ge,candlestickStyle:fe,lineStyle:U,pointStyle:K,areaStyle:Q,swarmStyle:ee,waterfallStyle:J,colorScheme:oe,barColors:te,barStyle:Z,annotations:$e,decay:ot,pulse:nt,transition:Tt,introAnimation:Rt,staleness:st,heatmapAggregation:at,heatmapXBins:lt,heatmapYBins:ct,showValues:ut,heatmapValueFormat:dt,pointIdAccessor:gt,curve:P,themeCategorical:null===(e=null==Lt?void 0:Lt.colors)||void 0===e?void 0:e.categorical,themeSemantic:A(Lt),themeSequential:null===(t=null==Lt?void 0:Lt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==Lt?void 0:Lt.colors)||void 0===o?void 0:o.diverging}},[p,D,I,B,W,F,j,S,H,R,ft,pt,O,M,C,Je,_,N,$,E,T,L,ne,ie,re,se,ae,le,ue,de,he,ge,fe,U,K,Q,ee,J,Z,oe,te,$e,ot,nt,null==Tt?void 0:Tt.duration,null==Tt?void 0:Tt.easing,Rt,st,at,lt,ct,ut,dt,vo,gt,P,Lt]),bo=t.useRef(null);bo.current||(bo.current=new ce(mo)),t.useEffect(()=>{var e;null===(e=bo.current)||void 0===e||e.updateConfig(mo),St.current=!0,Ft()},[mo,Ft]);const xo=t.useRef(null);xo.current||(xo.current=new k(e=>{const t=bo.current;t&&t.ingest(e)&&(St.current=!0,Ft())},{chunkThreshold:b,chunkSize:w})),t.useEffect(()=>{var e;null===(e=xo.current)||void 0===e||e.updateChunkOptions({chunkThreshold:b,chunkSize:w})},[b,w]);const wo=t.useCallback(e=>{var t;null===(t=xo.current)||void 0===t||t.push(e)},[]),jo=t.useCallback(e=>{var t;null===(t=xo.current)||void 0===t||t.pushMany(e)},[]),Ao=t.useCallback(()=>{var e,t;null===(e=xo.current)||void 0===e||e.clear(),null===(t=bo.current)||void 0===t||t.clear(),St.current=!0,Ft()},[Ft]);t.useImperativeHandle(n,()=>({push:wo,pushMany:jo,remove:e=>{var t,o,n;null===(t=xo.current)||void 0===t||t.flush();const i=null!==(n=null===(o=bo.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];return i.length>0&&(ro.current&&i.some(e=>{var t;return e===(null===(t=ro.current)||void 0===t?void 0:t.data)})&&(ro.current=null,lo(null)),St.current=!0,Ft()),i},update:(e,t)=>{var o,n,i;null===(o=xo.current)||void 0===o||o.flush();const r=null!==(i=null===(n=bo.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(St.current=!0,Ft()),r},clear:Ao,getData:()=>{var e,t,o;return null===(e=xo.current)||void 0===e||e.flush(),null!==(o=null===(t=bo.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=bo.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=bo.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[wo,jo,Ao,Ft]),t.useEffect(()=>{var e,t;if(m){if(_&&m.length>0&&"object"==typeof m[0]&&null!==m[0]){const t="string"==typeof _?_:"coordinates";if(Array.isArray(m[0][t])){const o=[];for(const e of m){const n=e[t];if(Array.isArray(n)){const t=e.label||e.id||e.key;if(null!=t)for(const e of n)o.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of n)o.push(e)}}return void(null===(e=xo.current)||void 0===e||e.setBoundedData(o))}}null===(t=xo.current)||void 0===t||t.setBoundedData(m)}},[m,_]);const{hoverHandlerRef:Po,hoverLeaveRef:To,onPointerMove:Ro,onPointerLeave:Bo}=Mt;Po.current=e=>{if(!Ut)return;const t=Kt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-Yt.left,i=e.clientY-o.top-Yt.top;if(0>n||n>Xt||0>i||i>Vt)return void(ro.current&&(ro.current=null,so.current=null,lo(null),Be&&(Be(null),St.current=!0),Ft()));const r=bo.current;if(!r||0===r.scene.length)return;const s=ye(r.scene,n,i,He,r.quadtree,r.maxPointRadius);if(!s)return void(ro.current&&(ro.current=null,so.current=null,lo(null),Be&&Be(null),Ft()));const a=ko(s.datum||{},s.x,s.y);if("multi"===Ne&&r.scene.length>0&&r.scales){const e=function(e,t,o=30){const n=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const r=ve(e.path,t,o);if(null===r)continue;const s=Se(e.path,t);n.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:r,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const r=ve(e.topPath,t,o);if(null===r)continue;const s=Se(e.topPath,t);n.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.topPath[s][0],y:r,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return n}(r.scene,s.x,He),t=r.scales.y.invert,o=r.scales.x.invert;if(e.length>0){const n=o?o(s.x):s.x;a.xValue=n,a.xPx=s.x;const i=co.current;a.allSeries=e.map(e=>({group:e.group||"",value:t?t(e.y):e.y,valuePx:e.y,color:e.color||i,datum:e.datum}))}}ro.current=a,so.current=s.node,lo(a),Be&&(Be(a),St.current=!0),Ft()},To.current=()=>{ro.current&&(ro.current=null,so.current=null,lo(null),Be&&(Be(null),St.current=!0),Ft())};const Io=t.useRef(()=>{});Io.current=e=>{if(!Ie)return;const t=Kt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-Yt.left,i=e.clientY-o.top-Yt.top;if(0>n||n>Xt||0>i||i>Vt)return void Ie(null);const r=bo.current;if(!r||0===r.scene.length)return void Ie(null);const s=ye(r.scene,n,i,He,r.quadtree,r.maxPointRadius);Ie(s?ko(s.datum||{},s.x,s.y):null)};const Do=t.useCallback(e=>Io.current(e),[]),Ho=t.useRef(-1),No=t.useRef(null),$o=t.useRef(null),Wo=t.useCallback(e=>{const t=bo.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if($o.current&&$o.current.version===o)n=$o.current.graph;else{const e=function(e){var t,o,n;const i=[];for(const r of e)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const e=r,o=Array.isArray(e.datum)?e.datum:[],n=null!==(t=e.group)&&void 0!==t?t:"_default";for(let t=0;e.path.length>t&&o.length>t;t++)i.push({x:e.path[t][0],y:e.path[t][1],datum:o[t],shape:"circle",group:n});break}case"area":{const e=r,t=Array.isArray(e.datum)?e.datum:[],n=null!==(o=e.group)&&void 0!==o?o:"_default";for(let o=0;e.topPath.length>o&&t.length>o;o++)i.push({x:e.topPath[o][0],y:e.topPath[o][1],datum:t[o],shape:"circle",group:n});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!==(n=r.group)&&void 0!==n?n:"_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((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;n=Oe(e),$o.current={version:o,graph:n}}const i=Ho.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Ho.current=0;const t=n.flat[0];No.current={shape:t.shape,w:t.w,h:t.h};const o=Le(t);return ro.current=o,lo(o),Be&&Be(o),void Ft()}const r=Me(n,i),s=Ce(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return Ho.current=-1,No.current=null,ro.current=null,so.current=null,lo(null),Be&&Be(null),void Ft();Ho.current=s;const a=n.flat[s];No.current={shape:a.shape,w:a.w,h:a.h};const l=Le(a);ro.current=l,lo(l),Be&&Be(l),Ft()},[Be,Ft]),Fo=t.useCallback(e=>{Ho.current=-1,No.current=null,Ro(e)},[Ro]);Ht.current=()=>{var e,t;It.current=0;const o=Kt.current,n=Qt.current;if(!o||!n)return;const i=bo.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(Ct.current?r+1e6:r),a=!Ct.current&&s,l=St.current||s;l&&!a&&i.computeScene({width:Xt,height:Vt});const c=no(),u=function(e){if(!e)return Co;const t=getComputedStyle(e),o=t.getPropertyValue("--semiotic-border").trim(),n=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=t.getPropertyValue("--semiotic-primary").trim(),s=n||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=o||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||o||r?{axisStroke:l||Co.axisStroke,tickText:s||Co.tickText,crosshair:s?_o(s,"66"):Co.crosshair,hoverFill:c?_o(c,"4D"):Co.hoverFill,hoverStroke:s?_o(s,"99"):Co.hoverStroke,pointRing:c||Co.pointRing,primary:r||Co.primary}:Co}(o);co.current=u.primary;const d=null!==(e=null==st?void 0:st.threshold)&&void 0!==e?e:5e3,h=st&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const e=oo(o,Pt,Yt,c);if(e){if(e.clearRect(-Yt.left,-Yt.top,Pt[0],Pt[1]),h&&(e.globalAlpha=null!==(t=null==st?void 0:st.dimOpacity)&&void 0!==t?t:.5),"transparent"!==V&&!Ve){const t=getComputedStyle(o).getPropertyValue("--semiotic-bg").trim(),n=V||(t&&"transparent"!==t?t:null);n&&(e.fillStyle=n,e.fillRect(-Yt.left,-Yt.top,Pt[0],Pt[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Xt,Vt),e.clip()),Ke&&i.scales)for(const t of Ke)e.save(),t(e,i.scene,i.scales,{width:Xt,height:Vt}),e.restore();const n=Oo[p];if(n&&i.scales)for(const t of n)t(e,i.scene,i.scales,{width:Xt,height:Vt});e.restore(),h&&(e.globalAlpha=1)}}{const e=oo(n,Pt,Yt,c);if(e&&(e.clearRect(-Yt.left,-Yt.top,Pt[0],Pt[1]),Ut&&ro.current&&i.scales&&function(e,t,o,n,i,r,s){var a;if(!1===i.crosshair)return;const l=t.allSeries,c=l&&l.length>0,u=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(e.strokeStyle=d.stroke||s.crosshair,e.lineWidth=d.strokeWidth||1,e.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?u:t.x,0),e.lineTo(c?u:t.x,n),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(o,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of l)null!=t.valuePx&&(e.beginPath(),e.arc(u,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const o=i.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const o="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||o||null:o||t.stroke||null}(r)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=o,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,ro.current,Xt,Vt,"object"==typeof Ut?Ut:{},so.current,u),so.current&&Array.isArray(Pe))){const t=Pe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,o,n,i){var r;if(!o)return;const s=o.group;if(void 0!==s)for(const o of t){if("line"!==o.type)continue;if(o.group!==s)continue;if(2>o.path.length)continue;const t="function"==typeof n.style?o.datum?n.style(o.datum):{}:n.style||{};e.save(),e.beginPath(),e.moveTo(o.path[0][0],o.path[0][1]);for(let t=1;o.path.length>t;t++)e.lineTo(o.path[t][0],o.path[t][1]);e.strokeStyle=t.stroke||o.style.stroke||i.primary,e.lineWidth=t.strokeWidth||(o.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,i.scene,so.current,t,u)}}l&&o&&o.setAttribute("aria-label",Ot(i.scene,p+" chart"));const g=St.current;if(St.current=!1,g&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!eo||e(eo.x.domain()[0])!==e(i.scales.x.domain()[0])||e(eo.x.domain()[1])!==e(i.scales.x.domain()[1])||e(eo.y.domain()[0])!==e(i.scales.y.domain()[0])||e(eo.y.domain()[1])!==e(i.scales.y.domain()[1])||eo.x.range()[0]!==i.scales.x.range()[0]||eo.x.range()[1]!==i.scales.x.range()[1]||eo.y.range()[0]!==i.scales.y.range()[0]||eo.y.range()[1]!==i.scales.y.range()[1])&&io(i.scales),ht){const e=i.getData(),t="function"==typeof j?j:e=>e[j||"x"],o="function"==typeof S?S:e=>e[S||"y"];fo(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),yo(e.map(e=>o(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&$e&&$e.length>0&&Jt(e=>e+1),(null==st?void 0:st.showBadge)&&ho(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(It.current=requestAnimationFrame(()=>Ht.current()))},t.useEffect(()=>(Ft(),()=>{var e;null===(e=xo.current)||void 0===e||e.clear()}),[Ft]),t.useEffect(()=>{St.current=!0,Ft()},[p,Xt,Vt,pe,V,U,Ke,Ft]),Te(st,bo,St,Ft,uo,ho);const Eo=t.useMemo(()=>{if(we||Ae)return;const e=bo.current;return(null==e?void 0:e.xIsDate)&&eo?So(eo.x.domain()):void 0},[we,Ae,eo]),zo=we||Ae||Eo,Yo=Ut&&ao?Re?Re(ao):e.jsx(Lo,{hover:ao}):null,Go=Yo?e.jsx(zt,{x:ao.x,y:ao.y,containerWidth:Xt,containerHeight:Vt,margin:Yt,className:"stream-frame-tooltip",children:Yo}):null,qo=No.current,Xo=e.jsx(Et,{active:Ho.current>=0,hoverPoint:ao,margin:Yt,size:Pt,shape:null==qo?void 0:qo.shape,width:null==qo?void 0:qo.w,height:null==qo?void 0:qo.h}),Vo=(e,t,o,n)=>"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:{key:void 0,fn:null},Uo=Vo(j,H,"__semiotic_resolvedX","__semiotic_resolvedTime"),Ko=Vo(S,R,"__semiotic_resolvedY","__semiotic_resolvedValue"),Qo=Uo.key,Zo=Ko.key,Jo=$e&&$e.length>0,en=e=>{if(!e||!Jo||!Uo.fn&&!Ko.fn)return e;let t=!1;const o=e.map(e=>{const o=Uo.fn&&Uo.key&&!(Uo.key in e),n=Ko.fn&&Ko.key&&!(Ko.key in e);if(!o&&!n)return e;t=!0;const i=Object.assign({},e);return o&&(i[Uo.key]=Uo.fn(e)),n&&(i[Ko.key]=Ko.fn(e)),i});return t?o:e};if(kt){const t=bo.current;t&&m&&(t.ingest({inserts:m,bounded:!0}),t.computeScene({width:Xt,height:Vt}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,s=zo||(()=>{if((null==t?void 0:t.xIsDate)&&n)return So(n.x.domain())})();return e.jsxs("div",{className:"stream-xy-frame"+(X?" "+X:""),role:"img","aria-label":mt||("string"==typeof Ze?Ze:"XY chart"),style:{position:"relative",width:Pt[0],height:Pt[1]},children:[e.jsx(Nt,{summary:wt}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Pt[0],height:Pt[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Yt.left},${Yt.top})`,children:qt}),e.jsxs("g",{transform:`translate(${Yt.left},${Yt.top})`,children:[V&&e.jsx("rect",{x:0,y:0,width:Xt,height:Vt,fill:V}),Qe&&n&&Qe.map((t,i)=>e.jsx(y.Fragment,{children:t(o,n,{width:Xt,height:Vt})},"svgpre-"+i)),o.map((t,o)=>function(t,o){var n,i,r;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+o)}case"area":{const r=t;if(0===r.topPath.length)return null;const s=r.topPath.map(([e,t])=>`${e},${t}`).join("L"),a=[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:`M${s}L${a}Z`,fill:xt(r.style.fill),fillOpacity:null!==(i=null!==(n=r.style.fillOpacity)&&void 0!==n?n:r.style.opacity)&&void 0!==i?i:.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth},"area-"+o)}case"point":{const n=t;return e.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:xt(n.style.fill),opacity:null!==(r=n.style.opacity)&&void 0!==r?r:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:xt(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+o)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[i,r,s]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return e.jsxs("g",{children:[e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),e.jsx("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:t})]},"heatcell-"+o)}return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+o)}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),s=n.isUp?n.upColor:n.downColor;return e.jsxs("g",{children:[e.jsx("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),e.jsx("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+o)}default:return null}}(t,o)).filter(Boolean)]})]}),e.jsx(bt,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,scales:n,showAxes:pe,axes:me,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:s,yFormat:je||_e,showGrid:Fe,title:Ze,legend:Ee,legendHoverBehavior:ze,legendClickBehavior:Ye,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Xe,foregroundGraphics:Gt,marginalGraphics:ht,xValues:[],yValues:[],annotations:$e,svgAnnotationRules:We,annotationFrame:0,xAccessor:Qo,yAccessor:Zo,annotationData:en(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,linkedCrosshairName:jt,linkedCrosshairSourceId:At})]})}return e.jsxs("div",{ref:_t,className:"stream-xy-frame"+(X?" "+X:""),role:"group","aria-label":mt||("string"==typeof Ze?Ze:"XY chart"),tabIndex:0,style:{position:"relative",width:Y?"100%":Pt[0],height:G?"100%":Pt[1],overflow:"visible"},onKeyDown:Wo,children:[vt&&e.jsx($t,{tableId:Bt}),vt&&e.jsx(Dt,{scene:null!==(a=null===(s=bo.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:p+" chart",tableId:Bt,chartTitle:"string"==typeof Ze?Ze:void 0}),e.jsx(Nt,{summary:wt}),e.jsxs("div",{role:"img","aria-label":mt||("string"==typeof Ze?Ze:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ut?Fo:void 0,onMouseLeave:Ut?Bo:void 0,onClick:Ie?Do:void 0,children:[qt&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Pt[0],height:Pt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Yt.left},${Yt.top})`,children:qt})}),e.jsx(yt,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,scales:eo,showAxes:pe,axes:me,showGrid:Fe,xFormat:zo,yFormat:je||_e}),e.jsx("canvas",{ref:Kt,"aria-label":Ot(null!==(c=null===(l=bo.current)||void 0===l?void 0:l.scene)&&void 0!==c?c:[],p+" chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:Qt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(Wt,{hoverPoint:ao}),e.jsx(bt,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,scales:eo,showAxes:pe,axes:me,xLabel:be,yLabel:xe,yLabelRight:ke,xFormat:zo,yFormat:je||_e,showGrid:Fe,title:Ze,legend:Ee,legendHoverBehavior:ze,legendClickBehavior:Ye,legendHighlightedCategory:Ge,legendIsolatedCategories:qe,legendPosition:Xe,foregroundGraphics:Gt,marginalGraphics:ht,xValues:go,yValues:po,annotations:$e,svgAnnotationRules:We,annotationFrame:Zt,xAccessor:Qo,yAccessor:Zo,annotationData:en(null===(u=bo.current)||void 0===u?void 0:u.getData()),pointNodes:null===(d=bo.current)||void 0===d?void 0:d.scene.filter(e=>"point"===e.type),curve:"string"==typeof P?P:void 0,underlayRendered:!0,linkedCrosshairName:jt,linkedCrosshairSourceId:At}),(et||tt)&&e.jsx(x,{width:Xt,height:Vt,totalWidth:Pt[0],totalHeight:Pt[1],margin:Yt,dimension:null!==(h=null==et?void 0:et.dimension)&&void 0!==h?h:"xy",scales:eo,onBrush:null!=tt?tt:()=>{},binSize:T,snap:null==et?void 0:et.snap,binBoundaries:null!==(g=null==et?void 0:et.binBoundaries)&&void 0!==g?g:"bar"===p?null===(f=bo.current)||void 0===f?void 0:f.getBinBoundaries():void 0,snapDuring:null==et?void 0:et.snapDuring,streaming:"streaming"===v}),(null==st?void 0:st.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===st.badgePosition?{top:4,left:4}:"bottom-left"===st.badgePosition?{bottom:4,left:4}:"bottom-right"===st.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:uo?"#dc3545":"#28a745",color:"white"}),children:uo?"STALE":"LIVE"}),Xo,Go]})]})});function Ro(e,t){const{columns:o,config:n,resolvePieceStyle:i}=e,r=[],s=Math.min(t.width,t.height)/2-4,a="donut"===n.chartType?n.innerRadius||60:0,l=-Math.PI/2+(n.startAngle||0)*Math.PI/180,c=null!=n.sweepAngle?n.sweepAngle*Math.PI/180:2*Math.PI;for(const e of Object.values(o)){const t=l+e.pctStart*c,o=l+(e.pctStart+e.pct)*c,u=i(e.pieceData[0],e.name);r.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:t,endAngle:o},n.cornerRadius&&{cornerRadius:n.cornerRadius}),{style:u,datum:e.pieceData,category:e.name}))}return r}function Bo(e){var t,o,n;const i=e.length,r=e[0],s=e[i-1];return{n:i,min:r,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:r,median:null!==(o=a.quantile(e,.5))&&void 0!==o?o:(r+s)/2,q3:null!==(n=a.quantile(e,.75))&&void 0!==n?n:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}To.displayName="StreamXYFrame";const Io={bar:function(e,t){var o,n,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p="horizontal"===h,y=a.normalize,v=[];if(c){const e=new Set;for(const t of Object.values(s))for(const o of t.pieceData){const t=c(o);e.has(t)||(e.add(t),v.push(t))}}else v.push("_default");for(const e of Object.values(s)){const t=new Map;for(const o of e.pieceData){const e=c?c(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=l(o),n.pieces.push(o)}let o=0;if(y)for(const e of t.values())o+=Math.abs(e.total);let n=0,i=0;for(const r of v){const s=t.get(r);if(!s)continue;let a=s.total;y&&o>0&&(a/=o);const l=u(s.pieces[0],c?r:e.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:e.name});if(f){const t=d(0>a?i:n+a),o=0>a?d(i+a)-d(i):d(n)-d(n+a);g.push(ne(e.x,t,e.width,Math.abs(o),l,h,r)),0>a?i+=a:n+=a}else if(p){const t=d(0>a?i+a:n),o=0>a?d(i)-d(i+a):d(n+a)-d(n);g.push(ne(t,e.x,Math.abs(o),e.width,l,h,r)),0>a?i+=a:n+=a}}}const m="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const e of g){if("rect"!==e.type)continue;const t=null!==(n=null===(o=e.datum)||void 0===o?void 0:o.__aggregateValue)&&void 0!==n?n:0;e.roundedEdge=m?0>t?"bottom":"top":0>t?"left":"right",a.gradientFill&&(e.fillGradient=a.gradientFill)}if(b>0){const e=new Map;for(const t of g){if("rect"!==t.type)continue;const o=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>{var t,o;return(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)>=0}),o=t.filter(e=>{var t,o;return 0>(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)});e.length>0&&(e.reduce(m?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=b),o.length>0&&(o.reduce(m?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=b)}}return g},clusterbar:function(e,t){const{scales:o,columns:n,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h=[],g=new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=s?s(t):"_default";g.has(e)||(g.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(n)){const t=e.width/f,o=.2*t,n=t-o,i=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";i.has(e)||i.set(e,[]),i.get(e).push(t)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),g=a(i,h[s]);if(d){const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push(ne(r,Math.min(a,d),n,Math.abs(a-d),g,i,h[s]))}else{const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push(ne(Math.min(a,d),r,Math.abs(d-a),n,g,i,h[s]))}}}}const p=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum);p>0&&(e.roundedTop=p),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",i.gradientFill&&(e.fillGradient=i.gradientFill)}return u},point:function(e,t){var o,n;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=i,d=[],h="vertical"===u,g="radial"===u,f=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const i=null!==(o=t.__rIndex)&&void 0!==o?o:0,r=null!==(n=t.__rValue)&&void 0!==n?n:s(t),u=f&&a[i]||c,v=l(t,e.name),m=v.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*p,o=u(r);b=Math.cos(t)*o,x=Math.sin(t)*o}else h?(b=e.middle,x=u(r)):(b=u(r),x=e.middle);d.push({type:"point",x:b,y:x,r:m,style:v,datum:t})}return d},swarm:function(e,t){const{scales:o,columns:n,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="vertical"===a;for(const e of Object.values(n)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const n=e.pieceData[o],a=i(n),u=r(n,e.name),d=u.r||4,h=(7919*o%100/100-.5)*t*.8,g=c?e.middle+h:s(a),f=c?s(a):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:n})}}return l},pie:Ro,donut:Ro,boxplot:function(e,t){var o,n,i,r,s,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:g}=e,{r:f,projection:p}=c,y=[],v="vertical"===p,m=!1!==d.showOutliers;for(const t of Object.values(u)){const c=t.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===c.length)continue;const u=c[0],d=c[c.length-1],p=null!==(o=a.quantile(c,.25))&&void 0!==o?o:u,b=null!==(n=a.quantile(c,.5))&&void 0!==n?n:(u+d)/2,x=null!==(i=a.quantile(c,.75))&&void 0!==i?i:d,k=x-p,w=p-1.5*k,j=x+1.5*k,A=null!==(r=c.find(e=>e>=w))&&void 0!==r?r:u,S=null!==(s=[...c].reverse().find(e=>j>=e))&&void 0!==s?s:d,O=g(t.pieceData[0],t.name),M=[];if(m)for(const e of t.pieceData){const o=h(e);if(w>o||o>j){const n=v?t.middle:f(o),i=v?f(o):t.middle;M.push({px:n,py:i,value:o,datum:e})}}if(y.push({type:"boxplot",x:v?t.middle:0,y:v?0:t.middle,projection:v?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(A),q1Pos:f(p),medianPos:f(b),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:A,q1:p,median:b,q3:x,max:S,mean:c.reduce((e,t)=>e+t,0)/c.length},style:O,datum:t.pieceData,category:t.name,outliers:M}),m)for(const t of M)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:O.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:t.datum})}return y},violin:function(e,t){var o,n,i;const{scales:r,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],s=t[t.length-1],l=(s-r)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-r)/l),p-1)]++;const v=Math.max(...h,1),m=e.width/2*.9;let b="";if(f){b=`M ${e.middle} ${d(r)}`;for(let t=0;p>t;t++){const o=d(r+(t+.5)*l);b+=` L ${e.middle+h[t]/v*m} ${o}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const o=d(r+(t+.5)*l);b+=` L ${e.middle-h[t]/v*m} ${o}`}b+=" Z"}else{b=`M ${d(r)} ${e.middle}`;for(let t=0;p>t;t++)b+=` L ${d(r+(t+.5)*l)} ${e.middle-h[t]/v*m}`;b+=` L ${d(s)} ${e.middle}`;for(let t=p-1;t>=0;t--)b+=` L ${d(r+(t+.5)*l)} ${e.middle+h[t]/v*m}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(o=a.quantile(t,.25))&&void 0!==o?o:r,c=null!==(n=a.quantile(t,.5))&&void 0!==n?n:(r+s)/2,u=null!==(i=a.quantile(t,.75))&&void 0!==i?i:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(r)),width:e.width,height:Math.abs(d(s)-d(r))}:{x:Math.min(d(r),d(s)),y:e.x,width:Math.abs(d(s)-d(r)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Bo(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l}=n,c=[],u=r.bins||25,d=r.normalize,h=null===(o=l.domain)||void 0===o?void 0:o.call(l),g=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const o=null!=g&&isFinite(g)?g:Math.min(...t),n=null!=f&&isFinite(f)?f:Math.max(...t),i=(n-o)/u||1,r=Array(u).fill(0);for(const e of t)o>e||e>n||r[Math.min(Math.floor((e-o)/i),u-1)]++;const h=t.length,p=Math.max(...r,1),y=a(e.pieceData[0],e.name);for(let t=0;u>t;t++){if(0===r[t])continue;const n=(d?r[t]/h:r[t]/p)*e.width*.9,s=l(o+t*i),a=l(o+(t+1)*i);c.push(ne(Math.min(s,a),e.x+e.width-n,Math.abs(a-s),n,y,{bin:t,count:r[t],range:[o+t*i,o+(t+1)*i],category:e.name},e.name))}}return c},ridgeline:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=n,u=[],d=r.bins||20,h="horizontal"===c,g=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*g;let v="";if(h){const t=e.x+e.width;v=`M ${l(n)} ${t}`;for(let e=0;d>e;e++)v+=` L ${l(n+(e+.5)*r)} ${t-c[e]/f*y}`;v+=` L ${l(i)} ${t} Z`}else{const t=e.x;v=`M ${t} ${l(n)}`;for(let e=0;d>e;e++){const o=l(n+(e+.5)*r);v+=` L ${t+c[e]/f*y} ${o}`}v+=` L ${t} ${l(i)} Z`}const m=h?{x:Math.min(l(n),l(i)),y:e.x,width:Math.abs(l(i)-l(n)),height:e.width}:{x:e.x,y:Math.min(l(i),l(n)),width:e.width,height:Math.abs(l(i)-l(n))};u.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:m,stats:Bo(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(o=p.fillOpacity)&&void 0!==o?o:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:o,columns:n,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const o=i(t);if(!o)continue;const[n,a]=o,u=r(t,e.name);if(c){const o=s(Math.min(n,a)),i=s(Math.max(n,a));l.push(ne(o,e.x,i-o,e.width,u,t,e.name))}else{const o=s(Math.max(n,a)),i=s(Math.min(n,a));l.push(ne(e.x,o,e.width,i-o,u,t,e.name))}}return l},funnel:function(e,t){var o,n,r,s,a,l,c,u;const{columns:d,getR:h,getStack:g,resolvePieceStyle:f}=e,p=[],y=t.width/2,v=!1!==e.config.showLabels,m=e.scales.o.domain().map(e=>d[e]).filter(Boolean);if(0===m.length)return p;const b=[],x=new Set;for(const e of m)for(const t of e.pieceData){const e=g?g(t):"_default";x.has(e)||(x.add(e),b.push(e))}const k=b.length>1&&"_default"!==b[0],w=[];let j=0;for(const e of m){const t=new Map;let o=0;for(const n of e.pieceData){const e=g?g(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=h(n);i.total+=r,i.pieces.push(n),o+=r}w.push({col:e,groups:t,stepTotal:o}),k||o>j&&(j=o)}if(k)for(const e of w){let t=0,o=0;for(let n=0;b.length>n;n++){const i=e.groups.get(b[n]);i&&(n%2==0?t+=i.total:o+=i.total)}const n=Math.max(t,o);n>j&&(j=n)}if(0===j)return p;const A=new Map;for(const e of b){const t=w[0].groups.get(e);A.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const S=w[0].stepTotal,O=k?.95*y:.9*t.width,M=i.scaleLinear().domain([0,j]).range([0,O]),C=null!==(n=e.config.connectorOpacity)&&void 0!==n?n:.3;let _=new Map;for(let t=0;w.length>t;t++){const o=w[t],n=o.col,i=0===t,d=n.width,h=.55*d,g=n.x+(d-h)/2,m=new Map;if(k){let e=0;for(const t of b){const n=o.groups.get(t);n&&(e+=M(n.total))}let t=y,r=y;for(let s=0;b.length>s;s++){const l=b[s],c=o.groups.get(l);if(!c)continue;const u=M(c.total),d=s%2==0,x=d?t:r-u;d?t+=u:r-=u;const k=f(c.pieces[0],l),w=null!==(a=A.get(l))&&void 0!==a?a:c.total,j=w>0?c.total/w*100:0,S=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:j,__funnelStep:n.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});v&&(0===s&&(S.__funnelStepLabel=n.name,S.__funnelStepLabelX=y,S.__funnelStepLabelY=g,S.__funnelRowWidth=e),S.__funnelValueLabelX=x+u/2,S.__funnelValueLabelY=g,S.__funnelBarW=u),p.push(ne(x,g,u,h,k,S,l)),m.set(l,{x:x,y:g,w:u,h:h})}}else{const e=o.stepTotal,t=M(e),a=y-t/2,l=b[0],c="_default"!==l,u=null!==(s=null===(r=o.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:n.pieceData[0],d=c?l:n.name,x=f(u,d),k=S>0?e/S*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:e,__funnelPercent:k,__funnelStep:n.name,__funnelIsFirstStep:i,category:c?l:n.name});v&&(w.__funnelStepLabel=n.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=g,w.__funnelRowWidth=t,w.__funnelValueLabelX=y,w.__funnelValueLabelY=g,w.__funnelBarW=t),p.push(ne(a,g,t,h,x,w,d)),m.set(l,{x:a,y:g,w:t,h:h})}if(t>0&&_.size>0){const t=k?b:[b[0]];for(const i of t){const t=_.get(i),r=m.get(i);if(!t||!r)continue;const s=(()=>{const e=o.groups.get(i);return f(e?e.pieces[0]:n.pieceData[0],"_default"===i?n.name:i)})(),a={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:C},datum:null!==(u=null===(c=o.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:n.pieceData[0],category:"_default"===i?n.name:i};p.push(a)}}_=m}return p},"bar-funnel":function(e,t){var o,n,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=e,d=[],h=u.o.domain().map(e=>s[e]).filter(Boolean);if(0===h.length)return d;const g=[],f=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";f.has(e)||(f.add(e),g.push(e))}const p=g.length>1&&"_default"!==g[0],y=[];for(const e of h){const t=new Map;let o=0;for(const n of e.pieceData){const e=l?l(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=a(n);i.total+=r,i.pieces.push(n),o+=r}y.push({col:e,groups:t,stepTotal:o})}const v=new Map;for(const e of g){const t=null===(o=y[0])||void 0===o?void 0:o.groups.get(e);v.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const m=u.r,b=p?g.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],o=t.col,n=0===e,s=e>0?y[e-1]:null,a=o.width/b,l=a*x,u=a-l;for(let e=0;g.length>e;e++){const h=g[e],f=t.groups.get(h);if(!f)continue;const y=f.total,b=null!==(i=v.get(h))&&void 0!==i?i:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,j=n?0:Math.max(0,w-y),A=o.x+e*a+l/2,S=m(y),O=m(0)-S,M=c(f.pieces[0],p?h:o.name),C=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:j,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name,__barFunnelLabelX:A+u/2,__barFunnelLabelY:m(y+j)});if(d.push(ne(A,S,u,O,M,C,p?h:o.name)),j>0){const e=m(y+j),t=S-e,n=Object.assign({},M),i=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:j,__barFunnelPercent:b>0?j/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name});d.push(ne(A,e,u,t,n,i,p?h:o.name))}}}return d},swimlane:function(e,t){const{scales:o,columns:n,getR:i,getStack:r,resolvePieceStyle:s}=e,{r:a,projection:l}=o,c=[],u="horizontal"===l;for(const e of Object.values(n)){let t=0;for(const o of e.pieceData){const n=Math.abs(i(o));if(0===n)continue;const l=r?r(o):e.name,d=s(o,l);if(u){const i=a(t),r=a(t+n);c.push(ne(i,e.x,r-i,e.width,d,o,l))}else{const i=a(t+n),r=a(t);c.push(ne(e.x,i,e.width,r-i,d,o,l))}t+=n}}return c}};class Do{constructor(e){this.rExtent=new R,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.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new T(e.windowSize),this.getO=N(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>D(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new R)):(this.getR=D(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=N(e.stackBy),this.getGroup=N(e.groupBy),this.getColor=N(e.colorAccessor),this.getConnector=N(e.connectorAccessor),this.getDataId=N(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new T(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=o.toArray(),r=t.projection||"vertical",s=t.oExtent||this.resolveCategories(n),a=this.computeValueDomain(n,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===r?e.width:e.height):.1));let d,h;if(c){d=i.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,n=t.innerRadius||0;h=i.scaleLinear().domain(a).range([n,o])}else l?(d=i.scaleBand().domain(s).range([0,e.height]).padding(u),h=i.scaleLinear().domain(a).range([0,e.width])):(d=i.scaleBand().domain(s).range([0,e.width]).padding(u),h=i.scaleLinear().domain(a).range([e.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((n,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(o,n);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=t.extentPadding)&&void 0!==s?s:.05,h=u-c,g=h>0?h*d:1;return c-=g,u+=g,c>0&&(c=0),l?i.scaleLinear().domain([c,u]).range([0,e.width]):i.scaleLinear().domain([c,u]).range([e.height,0])}):[];let g=n;this.rAccessors.length>1&&(g=n.flatMap(e=>this.rAccessors.map((t,o)=>Object.assign(Object.assign({},e),{__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(g,s,d,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,e),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),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(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,n="auto"===t?void 0:t;let i=null;if(o){i=new Set;for(const t of e)i.add(this.getO(t))}const r=i?Array.from(this.categories).filter(e=>i.has(e)):Array.from(this.categories);if(o&&void 0===n){const e=Math.max(50,3*i.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===n)return r;if("function"==typeof n)return r.sort(n);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===n?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){var o,n,i,r,s;const a=this.config.chartType,l=null!==(o=this.config.extentPadding)&&void 0!==o?o:.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 t=new Map,o=new Map;for(const n of e){const e=this.getO(n),i=this.getR(n);0>i?o.set(e,(o.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>u&&(u=e);for(const e of o.values())c>e&&(c=e)}else if("bar"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=this.getR(o);t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e),c>e&&(c=e)}else if("swimlane"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=Math.abs(this.getR(o));t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e)}else if("clusterbar"===a||"bar-funnel"===a)for(const t of e){const e=this.getR(t);e>u&&(u=e),c>e&&(c=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(c=e),t!==-1/0&&(u=t)}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===(n=this.config.rExtent)||void 0===n?void 0:n[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){const e=u-c,t=e>0?e*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=t),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=t)}return[c,u]}buildColumns(e,t,o,n,i){var r;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===n)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==n){u=new Map;let e=0;for(const o of t){const t=a.get(o)||[];let n;n="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(o,n),e+=n}const r=("horizontal"===n?i.height:i.width)-o.padding()*o.step()*t.length;if(e>0)for(const[t,o]of u)u.set(t,o/e*r)}let d=0,h=0;for(const e of t){const t=a.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?n/l:0;let c,g;u?(c=h,g=u.get(e)||o.bandwidth(),h+=g+o.padding()*o.step()):(c=null!==(r=o(e))&&void 0!==r?r:0,g=o.bandwidth()),s[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:o.padding()*o.step(),pieceData:t,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:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];const o=this.getSceneContext(),n=Io[this.config.chartType];let i=n?n(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){var o,n;const{scales:i,config:r,getConnector:s,getO:a}=e;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let n,i;"point"===e.type?(n=e.x,i=e.y):(n=e.x+e.w/2,i=e.y+("vertical"===c?0:e.h/2)),u.has(o)||u.set(o,[]),u.get(o).push({x:n,y:i,datum:t,category:a(t)})}const d=i.o.domain(),h=r.connectorStyle;for(const[t,i]of u)if(i.length>=2){i.sort((e,t)=>d.indexOf(e.category)-d.indexOf(t.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===(o=e.config.themeSemantic)||void 0===o?void 0:o.border)||(null===(n=e.config.themeSemantic)||void 0===n?void 0:n.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:t})}}return l}(o,i);i=[...e,...i]}return i}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const o=this.config.pieceStyle(e,t);return o&&!o.fill&&t?Object.assign(Object.assign({},o),{fill:this.getColorFromScheme(t)}):o}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||F,n=o[this._colorSchemeIndex%o.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,n),n}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?X(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=new Map;for(let o=0;e.length>o;o++)t.set(e[o],o);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=this.config.categoryAccessor||this.config.oAccessor,o="function"==typeof t,n=o?null:t||"category",i=new Map;for(let r=0;e.length>r;r++){const s=e[r],a=o?t(s):s[n];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 e=0,t=0;for(const o of this.scene)"point"===o.type&&(e++,o.r>t&&(t=o.r));if(this._maxPointRadius=t,Do.QUADTREE_THRESHOLD>=e)return void(this._pointQuadtree=null);const o=Array(e);let n=0;for(const e of this.scene)"point"===e.type&&(o[n++]=e);this._pointQuadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(o)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){var o,n;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const r=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,i),a=null!==(n=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==n?n:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*s})}}applyPulse(e,t){var o,n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=this.config.pulse.duration)&&void 0!==o?o:500,a=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(t);let u=null;for(const o of e){if("connector"===o.type||"violin"===o.type||"boxplot"===o.type)continue;if("wedge"===o.type){const e=o.category;if(!e)continue;u||(u=this.getCategoryIndexMap(t));const n=u.get(e);if(!n)continue;let i=0;for(let e=0;n.length>e;e++){const t=this.timestampBuffer.get(n[e]);if(null==t)continue;const o=r-t;if(s>o){const e=1-o/s;e>i&&(i=e)}}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const e=c.get(o.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const i=r-n;s>i&&(o._pulseIntensity=1-i/s,o._pulseColor=a,o._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,n=this.timestampBuffer.peek();return null!=n&&o>t-n}synthesizeIntroPositions(){var e,t,o,n,i;this.prevPositionMap.clear();const r=new Map,s=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.r(0))&&void 0!==t?t:0,a="horizontal"!==(null===(o=this.scales)||void 0===o?void 0:o.projection);let l;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],o=this.getNodeKey(t,r);o&&("rect"===t.type?this.prevPositionMap.set(o,a?{x:t.x,y:s,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}:{x:s,y:t.y,w:0,h:t.h,opacity:null!==(i=t.style.opacity)&&void 0!==i?i:1}):"point"===t.type?this.prevPositionMap.set(o,{x:t.x,y:t.y,r:0,opacity:0}):"wedge"===t.type&&(void 0===l&&(l=t.startAngle),this.prevPositionMap.set(o,{x:t.cx,y:t.cy,startAngle:l,endAngle:l,innerRadius:t.innerRadius,outerRadius:t.outerRadius,opacity:0})))}}getNodeKey(e,t){var o,n,i;if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,n=t.get(o)||0;return t.set(o,n+1),`${o}:${n}`}return"rect"===e.type?`r:${e.group||""}:${null!==(n=null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==n?n:""}`:"wedge"===e.type?"w:"+(null!==(i=e.category)&&void 0!==i?i:""):null}snapshotPositions(){var e;this.prevPositionMap.clear();const t=new Map;for(let o=0;this.scene.length>o;o++){const n=this.scene[o],i=this.getNodeKey(n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:null!==(e=n.style.opacity)&&void 0!==e?e:1}))}}startTransition(){var e,t,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,v,m,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let w=!1;const j=new Set,A=new Map;for(let e=0;this.scene.length>e;e++){const c=this.scene[e],u=this.getNodeKey(c,A);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(j.add(u),c._targetOpacity=null!==(t=c.style.opacity)&&void 0!==t?t: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!==(o=c.style.opacity)&&void 0!==o?o: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?(j.add(u),c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n: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)j.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 e=c.startAngle;c.startAngle=e,c.endAngle=e,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:e,endAngle:e,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)if(!j.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(c=t.r)&&void 0!==c?c:3,style:{opacity:null!==(u=t.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(d=t.w)&&void 0!==d?d:0,h:null!==(h=t.h)&&void 0!==h?h:0,style:{opacity:null!==(g=t.opacity)&&void 0!==g?g:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const o=((null!==(f=t.startAngle)&&void 0!==f?f:0)+(null!==(p=t.endAngle)&&void 0!==p?p:0))/2,n={type:"wedge",cx:t.x,cy:t.y,innerRadius:null!==(y=t.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(v=t.outerRadius)&&void 0!==v?v:100,startAngle:null!==(m=t.startAngle)&&void 0!==m?m:0,endAngle:null!==(b=t.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=t.opacity)&&void 0!==x?x:1},datum:null,category:e.slice(2),_targetStartAngle:o,_targetEndAngle:o,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:Z(),duration:k})}advanceTransition(e){var t,o,n,i;if(!this.activeTransition)return!1;const r=K(e,this.activeTransition),s=U(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=Q(i,e._targetOpacity,s)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=Q(n.x,e._targetX,s),e.y=Q(n.y,e._targetY,s)),void 0!==e._targetR&&void 0!==(null==n?void 0:n.r)&&(e.r=Q(n.r,e._targetR,s))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=Q(i,e._targetOpacity,s)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Q(o.x,e._targetX,s),e.y=Q(o.y,e._targetY,s),void 0!==o.w&&(e.w=Q(o.w,e._targetW,s),e.h=Q(o.h,e._targetH,s))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),n=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Q(n,e._targetOpacity,s)})}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Q(o.startAngle,e._targetStartAngle,s),e.endAngle=Q(o.endAngle,e._targetEndAngle,s))}}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);if(0===i.length)return i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,i}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=new Set(Array.isArray(e)?e:[e]),n=this.getDataId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(e)),t);if(0===r.length)return r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),i.has(t)&&this.pushValueExtent(e)}),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(e){const t=Object.assign({},this.config);if(("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!I(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!I(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!I(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),("categoryAccessor"in e||"oAccessor"in e)&&(I(e.categoryAccessor||e.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=N(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in e||"rAccessor"in e){const o=e.valueAccessor||e.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(o)?o:[o],r=Array.isArray(n)?n:[n];if(i.length!==r.length||i.some((e,t)=>!I(e,r[t]))){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>D(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new R)):(this.getR=D(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!I(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?N(this.config.stackBy):void 0),"groupBy"in e&&!I(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?N(this.config.groupBy):void 0),"colorAccessor"in e&&!I(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?N(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!I(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?N(this.config.connectorAccessor):void 0)}}function Ho(e,t,o){const n=ue(t,o,e);return n.hit?{datum:e.datum,x:n.cx,y:e.y,distance:0,category:e.group}:null}function No(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>de(e.r,n)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function $o(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;const s=fe(Math.atan2(i,n)),a=fe(e.startAngle),l=fe(e.endAngle);if(!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function Wo(e,t,o){const n=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-n>t||t>e.x+n||Math.min(e.minPos,e.maxPos)>o||o>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const i=e.y-n,r=e.y+n;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>o||o>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function Fo(e,t,o){if(!e.bounds)return null;const{x:n,y:i,width:r,height:s}=e.bounds;return n>t||t>n+r||i>o||o>i+s?null:{datum:e.datum,x:n+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}function Eo(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,showGrid:u,rFormat:d}=o,{rTickValues:h}=o,g="radial"===(null==l?void 0:l.projection),f="horizontal"===(null==l?void 0:l.projection),p=t.useMemo(()=>!l||g?[]:(h||l.r.ticks(5)).map(e=>({value:e,pixel:l.r(e),label:(d||zo)(e)})),[l,d,g,h]),y=u&&l&&!g,v=c&&l&&!g;return y||v?e.jsx("svg",{width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[y&&e.jsx("g",{className:"ordinal-grid",children:p.map((t,o)=>e.jsx("line",{x1:f?t.pixel:0,y1:f?0:t.pixel,x2:f?t.pixel:n,y2:f?i:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),v&&e.jsx(e.Fragment,{children:e.jsxs(e.Fragment,f?{children:[e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function zo(e){return Math.round(100*e)/100+""}function Yo(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,showCategoryTicks:h,oLabel:g,rLabel:f,oFormat:p,rFormat:y,showGrid:v,title:m,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:j,legendPosition:A="right",foregroundGraphics:S,annotations:O,svgAnnotationRules:M,xAccessor:C,yAccessor:_,annotationData:P,underlayRendered:L,children:T}=o,R="radial"===(null==u?void 0:u.projection),B="horizontal"===(null==u?void 0:u.projection),I=!1!==h,D=t.useMemo(()=>d&&I&&u&&!R?u.o.domain().map((e,t)=>{var o;return{value:e,pixel:(null!==(o=u.o(e))&&void 0!==o?o:0)+u.o.bandwidth()/2,label:p?p(e,t):e}}):[],[d,I,u,p,R]),H=o.rTickValues,N=o.tickLabelEdgeAlign,$=t.useMemo(()=>d&&u&&!R?(H||u.r.ticks(5)).map(e=>({value:e,pixel:u.r(e),label:(y||zo)(e)})):[],[d,u,y,R,H]),W=t.useRef(new Map),F=t.useRef(null!==(n=null==O?void 0:O.length)&&void 0!==n?n:0),E=null!==(i=null==O?void 0:O.length)&&void 0!==i?i:0;F.current!==E&&(F.current=E,W.current=new Map);const z=t.useMemo(()=>{if(!O||0===O.length)return null;const e=nt(),t="horizontal"===(null==u?void 0:u.projection),o=(null==u?void 0:u.o)?e=>{var t;return(null!==(t=u.o(e))&&void 0!==t?t:0)+u.o.bandwidth()/2}:null,n={scales:u?{x:t?u.r:o||u.r,y:t&&o||u.r,time:u.r,value:u.r,o:u.o}:null,timeAxis:"x",xAccessor:C,yAccessor:_,width:r,height:s,data:P,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return O.map((t,o)=>{if(M){const i=M(t,o,n);return null!=i?i:e(t,o,n)}return e(t,o,n)}).filter(Boolean)},[O,M,r,s,u,C,_,P]);return d||m||b||S||z&&z.length>0||v||T?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof m?m:"Ordinal Chart"}),e.jsx("desc",{children:"string"==typeof m?m+" — ordinal data visualization":"Ordinal data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[v&&u&&!R&&!L&&e.jsx("g",{className:"ordinal-grid",children:$.map((t,o)=>e.jsx("line",{x1:B?t.pixel:0,y1:B?0:t.pixel,x2:B?t.pixel:r,y2:B?s:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),d&&u&&!R&&e.jsx("g",{className:"ordinal-axes",children:e.jsxs(e.Fragment,B?{children:[!L&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),D.map((t,o)=>e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"cat-"+o)),g&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,style:{userSelect:"none"},children:g}),!L&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!L&&(null==u?void 0:u.r)&&(()=>{const t=u.r(0);return t>1&&r-1>t?e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),$.map((t,o)=>{const n=N?0===o?"start":o===$.length-1?"end":"middle":"middle";return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{y:18,textAnchor:n,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label})]},"val-"+o)}),f&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:f})]}:{children:[!L&&(()=>{const t=(null==u?void 0:u.r)?u.r(0):s,o=0>t||t>s?s:t;return e.jsx("line",{x1:0,y1:o,x2:r,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),D.map((t,o)=>e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:18,textAnchor:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"cat-"+o)),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:g}),!L&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),$.map((t,o)=>e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label})]},"val-"+o)),f&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,style:{userSelect:"none"},children:f})]})}),z,S,T]}),m&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof m?m:null}),Ee({legend:b,totalWidth:a,totalHeight:l,margin:c,legendPosition:A,title:m,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:j})]}):null}function Go({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,scales:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(u);g.current=u;const f=t.useRef(c);f.current=c;const p=t.useRef(!1),y=t.useRef(null),v="horizontal"===(null==c?void 0:c.projection),m=t.useRef(v);return m.current=v,t.useEffect(()=>{if(!d.current)return;const e=o.select(d.current).select(".brush-g"),t=v?n.brushX():n.brushY();return t.extent([[0,0],[i,r]]),t.on("brush end",e=>{if(p.current)return;const t=f.current;if(!t)return;if(!e.selection)return y.current=null,void g.current(null);const[o,n]=e.selection;let i;i=m.current?[t.r.invert(o),t.r.invert(n)]:[t.r.invert(n),t.r.invert(o)];const r={r:i};y.current=r,g.current(r)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),h.current=null}},[i,r,v]),t.useEffect(()=>{if(!c||!h.current||!y.current)return;if(!d.current)return;const e=y.current,t=o.select(d.current).select(".brush-g"),n=c.r(e.r[0]),i=c.r(e.r[1]);v?(p.current=!0,t.call(h.current.move,[n,i]),p.current=!1):(p.current=!0,t.call(h.current.move,[i,n]),p.current=!1)},[c,v]),e.jsx("svg",{ref:d,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`,style:{pointerEvents:"all"}})})}function qo(e,t){e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath()}function Xo(e,t){const o=c.arc().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle+Math.PI/2).endAngle(t.endAngle+Math.PI/2).cornerRadius(t.cornerRadius)({});if(!o)return;e.save(),e.translate(t.cx,t.cy);const n=new Path2D(o);e.fill(n),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(n),e.restore()}Do.QUADTREE_THRESHOLD=500;const Vo=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"wedge"===e.type);for(const t of s){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:1,n=null!==(r=t.style.opacity)&&void 0!==r?r:1;e.globalAlpha=o*n,e.fillStyle=("string"==typeof t.style.fill?Jt(e,t.style.fill):t.style.fill)||"#007bff",t.cornerRadius?(t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),Xo(e,t)):(qo(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())),t._pulseIntensity&&t._pulseIntensity>0&&(qo(e,t),go(e,t)),e.globalAlpha=1}},Uo=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const o=new Path2D(t.pathString);if(e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6,e.fillStyle=("string"==typeof t.style.fill?Jt(e,t.style.fill):t.style.fill)||"#007bff",e.fill(o),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(o)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const o=t.iqrLine.centerPos,n=!1!==t.iqrLine.isVertical;e.beginPath(),n?(e.moveTo(o,t.iqrLine.q1Pos),e.lineTo(o,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,o),e.lineTo(t.iqrLine.q3Pos,o)),e.stroke(),e.beginPath(),n?e.arc(o,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,o,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},Ko=(e,t,o,n)=>{var i,r,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const o=t[0].style;if(o.fill&&"none"!==o.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const o of t)e.lineTo(o.x2,o.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=o.fillOpacity)&&void 0!==i?i:o.opacity)&&void 0!==r?r:.3,e.fillStyle=o.fill,e.fill(),e.globalAlpha=1}for(const o of t)e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.strokeStyle=Jt(e,o.style.stroke)||("string"==typeof o.style.fill?Jt(e,o.style.fill):o.style.fill)||Jt(e,"var(--semiotic-border, #999)"),e.lineWidth=o.style.strokeWidth||1,e.globalAlpha=null!==(s=o.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}};function Qo(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Zo(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Jo=null;function en(e={},t){const{background:o="transparent",stroke:n="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*r));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Jo||(Jo=document.createElement("canvas")),Jo.width=e,Jo.height=e,Jo)}(a)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;o&&"transparent"!==o?(c.fillStyle=o,c.fillRect(0,0,a,a)):c.clearRect(0,0,a,a),c.strokeStyle=n,c.lineWidth=i,c.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=r)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*a,a),c.stroke()}else{c.save(),c.translate(a/2,a/2),c.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=r)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}const tn=new Map;function on(e,t){const o=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,n=tn.get(o);if(void 0!==n)return n;const i=en({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return tn.set(o,i),i}function nn(e,t,o,n,i,r){e.moveTo(t+r,o),e.lineTo(t+n-r,o),e.quadraticCurveTo(t+n,o,t+n,o+r),e.lineTo(t+n,o+i-r),e.quadraticCurveTo(t+n,o+i,t+n-r,o+i),e.lineTo(t+r,o+i),e.quadraticCurveTo(t,o+i,t,o+i-r),e.lineTo(t,o+r),e.quadraticCurveTo(t,o,t+r,o),e.closePath()}function rn(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function sn(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const an=e=>[Ko,...e],ln={bar:an([bo]),clusterbar:an([bo]),point:an([vo]),swarm:an([vo]),pie:[Vo],donut:[Vo],boxplot:an([(e,t,o,n)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const o=t.columnWidth/2,n="vertical"===t.projection,s=Jt(e,"var(--semiotic-primary, #007bff)"),a=Jt(e,"var(--semiotic-text, #333)"),l=t.style.fill,c="string"==typeof l?Jt(e,l)||l:null!=l?l:s,u=t.style.stroke,d="string"==typeof u?Jt(e,u)||u:a,h=t.style.strokeWidth||1,g=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6;if(e.save(),e.strokeStyle=d,e.lineWidth=h,e.beginPath(),n?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),n?(e.moveTo(t.x-.4*o,t.minPos),e.lineTo(t.x+.4*o,t.minPos),e.moveTo(t.x-.4*o,t.maxPos),e.lineTo(t.x+.4*o,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*o),e.lineTo(t.minPos,t.y+.4*o),e.moveTo(t.maxPos,t.y-.4*o),e.lineTo(t.maxPos,t.y+.4*o)),e.stroke(),e.globalAlpha=g,e.fillStyle=c,n){const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-o,n,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-o,n,t.columnWidth,i)}else{const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(n,t.y-o,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(n,t.y-o,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),n?(e.moveTo(t.x-o,t.medianPos),e.lineTo(t.x+o,t.medianPos)):(e.moveTo(t.medianPos,t.y-o),e.lineTo(t.medianPos,t.y+o)),e.stroke(),e.restore()}},vo]),violin:an([Uo]),histogram:an([bo]),ridgeline:an([Uo]),timeline:an([bo]),funnel:[bo,(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const o=t.points;if(o.length>=4){e.globalAlpha=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1,e.beginPath(),e.moveTo(o[0][0],o[0][1]);for(let t=1;o.length>t;t++)e.lineTo(o[t][0],o[t][1]);e.closePath(),e.fillStyle=(null===(s=t.style)||void 0===s?void 0:s.fill)||"#999",e.fill(),(null===(a=t.style)||void 0===a?void 0:a.stroke)&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}},(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==l.length&&l.some(e=>{var t,o;return null!=(null===(t=e.datum)||void 0===t?void 0:t.__funnelStepLabel)||null!=(null===(o=e.datum)||void 0===o?void 0:o.__funnelValueLabelX)})){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const o=t.datum;if(!o)continue;if(!o.__funnelStepLabel)continue;const n=o.__funnelStepLabel;if(e.measureText(n).width+16>(null!==(r=null!==(i=o.__funnelRowWidth)&&void 0!==i?i:o.__funnelBarW)&&void 0!==r?r:0))continue;const s=o.__funnelStepLabelX,a=o.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(n,s,a),e.fillStyle="#fff",e.fillText(n,s,a)}e.font="bold 13px sans-serif";for(const t of l){const o=t.datum;if(!o)continue;if(null==o.__funnelValueLabelX)continue;const n=null!==(s=o.__funnelBarW)&&void 0!==s?s:0;if(60>n)continue;const i=o.__funnelValue;if(null==i||0===i)continue;const r=o.__funnelPercent,l=!0===o.__funnelIsFirstStep;let c;if(c=l?Qo(i):null!=r?`${Qo(i)} (${Zo(r)})`:Qo(i),e.measureText(c).width+16>n){if(l||null==r)continue;if(c=Qo(i),e.measureText(c).width+16>n)continue}const u=o.__funnelValueLabelX,d=(null!==(a=o.__funnelValueLabelY)&&void 0!==a?a:t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(c,u,d),e.fillStyle="#fff",e.fillText(c,u,d)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[bo,(e,t,o,n)=>{var i,r;const s=t.filter(e=>{var t;return"rect"===e.type&&!0===(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)});for(const t of s){const o=("string"==typeof t.style.fill?t.style.fill:null)||Jt(e,"var(--semiotic-border, #999)"),n=on(o,e);e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),n?e.fillStyle=n:(e.fillStyle=o,e.globalAlpha=.4*(null!==(r=t.style.opacity)&&void 0!==r?r:1)),e.fill(),e.globalAlpha=1}},(e,t,o,n)=>{const i=t.filter(e=>{var t,o;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(o=e.datum)||void 0===o?void 0:o.__barFunnelLabelX)});if(0===i.length)return;const r=Jt(e,"var(--semiotic-text, #333)"),s=Jt(e,"var(--semiotic-text-secondary, #666)");for(const t of i){const o=t.datum;if(!o)continue;const n=o.__barFunnelValue;if(null==n)continue;if(25>t.w)continue;const i=o.__barFunnelPercent,a=!(!0===o.__barFunnelIsFirstStep)&&null!=i,l=a?sn(i):"",c=rn(n);e.font="bold 13px sans-serif";const u=a?e.measureText(l).width:0;e.font="11px sans-serif";const d=e.measureText(c).width,h=Math.max(u,d)+12,g=a?32:17,f=o.__barFunnelLabelX,p=f-h/2,y=o.__barFunnelLabelY-g-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle="rgba(255,255,255,0.95)",e.beginPath(),nn(e,p,y,h,g,4),e.fill(),e.restore(),e.strokeStyle="rgba(0,0,0,0.12)",e.lineWidth=.5,e.beginPath(),nn(e,p,y,h,g,4),e.stroke(),e.textAlign="center",e.textBaseline="top",a?(e.font="bold 13px sans-serif",e.fillStyle=r,e.fillText(l,f,y+3),e.font="11px sans-serif",e.fillStyle=s,e.fillText(c,f,y+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=r,e.fillText(c,f,y+3))}e.lineWidth=1}],swimlane:an([bo])},cn={top:50,right:40,bottom:60,left:70},un={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function dn({hover:t}){var o,n,i,r,s,a;const l=t.data||{},c=t.stats,u=t.category;if(Array.isArray(l)){const t=u||(null===(o=l[0])||void 0===o?void 0:o.category)||"";if(c)return e.jsxs("div",{className:"semiotic-tooltip",style:un,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:["n = ",c.n]}),e.jsxs("div",{children:["Min: ",c.min.toLocaleString()]}),e.jsxs("div",{children:["Q1: ",c.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",c.median.toLocaleString()]}),e.jsxs("div",{children:["Q3: ",c.q3.toLocaleString()]}),e.jsxs("div",{children:["Max: ",c.max.toLocaleString()]}),e.jsxs("div",{style:{opacity:.8},children:["Mean: ",c.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const n=l.length;return e.jsxs("div",{className:"semiotic-tooltip",style:un,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:[n," items"]})]})}if(null!=l.bin&&null!=l.count){const t=l.range||[];return e.jsxs("div",{className:"semiotic-tooltip",style:un,children:[l.category&&e.jsx("div",{style:{fontWeight:"bold"},children:l.category+""}),e.jsxs("div",{children:["Count: ",l.count]}),2===t.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)]})]})}const d=t.__oAccessor,h=t.__rAccessor,g=t.__chartType;if("swarm"===g||"point"===g){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:un,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}const f=(d&&null!=l[d]?l[d]:null)||l.category||l.name||l.group||l.__rName||"",p=null!==(a=null!==(s=null!==(r=null!==(i=null!==(n=l.__aggregateValue)&&void 0!==n?n:h&&null!=l[h]?l[h]:null)&&void 0!==i?i:l.value)&&void 0!==r?r:l.__rValue)&&void 0!==s?s:l.pct)&&void 0!==a?a:"";if(!f&&""===p){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:un,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}return e.jsxs("div",{className:"semiotic-tooltip",style:un,children:[f&&e.jsx("div",{style:{fontWeight:"bold"},children:f+""}),""!==p&&e.jsx("div",{children:"number"==typeof p?p.toLocaleString():p+""})]})}const hn=t.forwardRef(function(o,n){var i,r,s,a,l,u,d,h,g,f;const{chartType:p,runtimeMode:v,data:m,oAccessor:b="category",rAccessor:x="value",colorAccessor:w,stackBy:j,groupBy:S,multiAxis:O,timeAccessor:M,valueAccessor:C,categoryAccessor:_,projection:P="vertical",size:L=[600,400],responsiveWidth:T,responsiveHeight:R,margin:B,barPadding:I,roundedTop:D,gradientFill:H,baselinePadding:N,innerRadius:$,cornerRadius:W,normalize:F,startAngle:E,sweepAngle:z,dynamicColumnWidth:Y,bins:G,showOutliers:q,showIQR:X,amplitude:V,connectorOpacity:U,showLabels:K,connectorAccessor:Q,connectorStyle:Z,dataIdAccessor:J,rExtent:ee,oExtent:te,extentPadding:oe=.05,oSort:ne,windowMode:ie="sliding",windowSize:re=200,pieceStyle:se,summaryStyle:ae,colorScheme:le,barColors:ce,showAxes:ue=!0,showCategoryTicks:de,categoryLabel:he,valueLabel:ge,categoryFormat:fe,valueFormat:ye,oLabel:ve,rLabel:me,oFormat:be,rFormat:xe,rTickValues:ke,tickLabelEdgeAlign:we,enableHover:je=!0,hoverAnnotation:Ae,tooltipContent:Se,customHoverBehavior:_e,annotations:Pe,svgAnnotationRules:Re,showGrid:Be=!1,legend:Ie,legendHoverBehavior:De,legendClickBehavior:He,legendHighlightedCategory:Ne,legendIsolatedCategories:$e,legendPosition:We,backgroundGraphics:Fe,foregroundGraphics:Ee,title:ze,className:Ye,background:Ge,centerContent:qe,decay:Xe,pulse:Ve,transition:Ue,animate:Ke,staleness:Qe,brush:Ze,onBrush:Je,accessibleTable:et=!0,description:tt,summary:ot}=o,nt=t.useRef(!0),it=to({sizeProp:L,responsiveWidth:T,responsiveHeight:R,userMargin:B,marginDefault:cn,foregroundGraphics:Ee,backgroundGraphics:Fe,animate:Ke,transitionProp:Ue,themeDirtyRef:nt}),{reducedMotionRef:rt,responsiveRef:st,size:at,margin:lt,adjustedWidth:ct,adjustedHeight:ut,resolvedForeground:dt,resolvedBackground:ht,currentTheme:gt,transition:ft,introEnabled:pt,tableId:yt,rafRef:vt,renderFnRef:mt,scheduleRender:bt}=it,wt=null!=he?he:ve,jt=null!=ge?ge:me,At=null!=fe?fe:be,St=null!=ye?ye:xe,Mt=t.useRef(null),Ct=t.useRef(null),[_t,Pt]=t.useState(null),[Lt,Tt]=t.useState(null),[Rt,Bt]=t.useState(0),[It,Ht]=t.useState(!1),Ft=je||Ae,Yt="streaming"===v,Gt=t.useMemo(()=>{var e,t,o;return{chartType:p,runtimeMode:Yt?"streaming":"bounded",windowSize:re,windowMode:ie,extentPadding:oe,projection:P,oAccessor:Yt?void 0:b,rAccessor:Yt?void 0:x,colorAccessor:w,stackBy:j,groupBy:S,multiAxis:O,timeAccessor:Yt?M:void 0,valueAccessor:Yt?C||("string"==typeof x||"function"==typeof x?x:void 0):void 0,categoryAccessor:Yt?_||b:void 0,rExtent:ee,oExtent:te,barPadding:I,roundedTop:D,gradientFill:H,baselinePadding:N,innerRadius:$,cornerRadius:W,normalize:F,startAngle:E,sweepAngle:z,dynamicColumnWidth:Y,bins:G,showOutliers:q,showIQR:X,amplitude:V,connectorOpacity:U,showLabels:K,connectorAccessor:Q,connectorStyle:Z,dataIdAccessor:J,oSort:ne,pieceStyle:se,summaryStyle:ae,colorScheme:le,themeCategorical:null===(e=null==gt?void 0:gt.colors)||void 0===e?void 0:e.categorical,themeSemantic:A(gt),themeSequential:null===(t=null==gt?void 0:gt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==gt?void 0:gt.colors)||void 0===o?void 0:o.diverging,barColors:ce,decay:Xe,pulse:Ve,transition:ft,introAnimation:pt,staleness:Qe}},[p,re,ie,oe,P,b,x,w,j,S,O,M,C,_,ee,te,I,D,H,N,$,W,F,E,z,Y,G,q,X,V,U,K,Q,Z,J,ne,se,ae,le,ce,Xe,Ve,null==ft?void 0:ft.duration,null==ft?void 0:ft.easing,pt,Qe,Yt,gt]),qt=t.useRef(null);qt.current||(qt.current=new Do(Gt)),t.useEffect(()=>{var e;null===(e=qt.current)||void 0===e||e.updateConfig(Gt),nt.current=!0,bt()},[Gt,bt]);const Xt=t.useRef(null);Xt.current||(Xt.current=new k(e=>{const t=qt.current;t&&t.ingest(e)&&(nt.current=!0,bt())}));const Vt=t.useCallback(e=>{var t;null===(t=Xt.current)||void 0===t||t.push(e)},[]),Ut=t.useCallback(e=>{var t;null===(t=Xt.current)||void 0===t||t.pushMany(e)},[]),Kt=t.useCallback(()=>{var e,t;null===(e=Xt.current)||void 0===e||e.clear(),null===(t=qt.current)||void 0===t||t.clear(),nt.current=!0,bt()},[bt]),Qt=t.useCallback(e=>{var t,o;null===(t=Xt.current)||void 0===t||t.clearLastData(),null===(o=Xt.current)||void 0===o||o.setReplacementData(e)},[]);t.useImperativeHandle(n,()=>({push:Vt,pushMany:Ut,replace:Qt,remove:e=>{var t,o,n,i;null===(t=Xt.current)||void 0===t||t.flush();const r=null!==(n=null===(o=qt.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];if(r.length>0){const e=null===(i=Ct.current)||void 0===i?void 0:i.data;!!Ct.current&&r.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(Ct.current=null,Pt(null)),nt.current=!0,bt()}return r},update:(e,t)=>{var o,n,i;null===(o=Xt.current)||void 0===o||o.flush();const r=null!==(i=null===(n=qt.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(nt.current=!0,bt()),r},clear:Kt,getData:()=>{var e,t,o;return null===(e=Xt.current)||void 0===e||e.flush(),null!==(o=null===(t=qt.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=qt.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[Vt,Ut,Qt,Kt,bt]),t.useEffect(()=>{var e;m&&(null===(e=Xt.current)||void 0===e||e.setBoundedData(m))},[m]);const{hoverHandlerRef:Zt,hoverLeaveRef:Jt,onPointerMove:eo,onPointerLeave:oo}=it;Zt.current=e=>{if(!Ft)return;const t=Mt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-lt.left,i=e.clientY-o.top-lt.top;if(0>n||n>ct||0>i||i>ut)return void(Ct.current&&(Ct.current=null,Pt(null),_e&&_e(null),bt()));const r=qt.current;if(!r||0===r.scene.length)return;const s="radial"===P,a=function(e,t,o,n=30,i,r=0){let s=null;if(i){const e=pe(i,t,o,n,r);e&&(s={datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const r of e){let e=null;switch(r.type){case"rect":e=Ho(r,t,o);break;case"point":if(i)break;e=No(r,t,o,n);break;case"wedge":e=$o(r,t,o);break;case"boxplot":e=Wo(r,t,o);break;case"violin":e=Fo(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(r.scene,s?n-ct/2:n,s?i-ut/2:i,30,r.pointQuadtree,r.maxPointRadius);if(!a)return void(Ct.current&&(Ct.current=null,Pt(null),_e&&_e(null),bt()));const l=ko(a.datum||{},a.x,a.y,Object.assign(Object.assign(Object.assign({},a.stats&&{stats:a.stats}),a.category&&{category:a.category}),{__oAccessor:"string"==typeof b?b:void 0,__rAccessor:"string"==typeof x?x:void 0,__chartType:p}));Ct.current=l,Pt(l),_e&&(_e(l),nt.current=!0),bt()},Jt.current=()=>{Ct.current&&(Ct.current=null,Pt(null),_e&&(_e(null),nt.current=!0),bt())};const io=t.useRef(-1),ro=t.useRef(null),so=t.useRef(null),ao=t.useCallback(e=>{const t=qt.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if(so.current&&so.current.version===o)n=so.current.graph;else{const e=function(e){var t,o,n;const i=[];for(const r of e)if("rect"===r.type&&null!=r.x){const e=null!==(o=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==o?o:"";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!==(n=r.group)&&void 0!==n?n:e})}else if("point"===r.type)i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});else if("wedge"===r.type&&null!=r.cx){const e=((r.startAngle||0)+(r.endAngle||0))/2,t=((r.innerRadius||0)+(r.outerRadius||50))/2;i.push({x:r.cx+Math.cos(e)*t,y:r.cy+Math.sin(e)*t,datum:r.datum,shape:"wedge",group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;n=Oe(e),so.current={version:o,graph:n}}const i=io.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),io.current=0;const t=n.flat[0];ro.current={shape:t.shape,w:t.w,h:t.h};const o=Object.assign(Object.assign({},Le(t)),{__oAccessor:"string"==typeof b?b:void 0,__rAccessor:"string"==typeof x?x:void 0,__chartType:p});return Ct.current=o,Pt(o),_e&&_e(o),void bt()}const r=Me(n,i),s=Ce(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return io.current=-1,ro.current=null,Ct.current=null,Pt(null),_e&&_e(null),void bt();io.current=s;const a=n.flat[s];ro.current={shape:a.shape,w:a.w,h:a.h};const l=Object.assign(Object.assign({},Le(a)),{__oAccessor:"string"==typeof b?b:void 0,__rAccessor:"string"==typeof x?x:void 0,__chartType:p});Ct.current=l,Pt(l),_e&&_e(l),bt()},[_e,bt]),lo=t.useCallback(e=>{io.current=-1,ro.current=null,eo(e)},[eo]);mt.current=()=>{var e,t;vt.current=0;const o=Mt.current;if(!o)return;const n=o.getContext("2d");if(!n)return;const i=qt.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(rt.current?r+1e6:r),a=!rt.current&&s,l=nt.current;l&&!s&&(i.computeScene({width:ct,height:ut}),nt.current=!1),(l||a)&&o.setAttribute("aria-label",Ot(i.scene,p+" chart"));const c=no(),u=at[0]*c,d=at[1]*c;o.width===u&&o.height===d||(o.width=u,o.height=d,o.style.width=at[0]+"px",o.style.height=at[1]+"px"),n.setTransform(c,0,0,c,0,0),n.clearRect(0,0,at[0],at[1]);const h=null!==(e=null==Qe?void 0:Qe.threshold)&&void 0!==e?e:5e3,g=Qe&&i.lastIngestTime>0&&r-i.lastIngestTime>h;if(g&&(n.globalAlpha=null!==(t=null==Qe?void 0:Qe.dimOpacity)&&void 0!==t?t:.5),"transparent"!==Ge&&!Fe){const e=o?getComputedStyle(o).getPropertyValue("--semiotic-bg").trim():"",t=Ge||(e&&"transparent"!==e?e:null);t&&(n.fillStyle=t,n.fillRect(0,0,at[0],at[1]))}const f="radial"===P;n.save(),n.beginPath(),n.rect(lt.left,lt.top,ct,ut),n.clip(),f?(n.save(),n.translate(lt.left+ct/2,lt.top+ut/2)):n.translate(lt.left,lt.top);const y=ln[p]||[],v={width:ct,height:ut};for(const e of y)e(n,i.scene,i.scales,v);f&&n.restore(),n.restore(),g&&(n.globalAlpha=1),l&&i.scales&&(Tt(i.scales),Bt(e=>e+1)),(null==Qe?void 0:Qe.showBadge)&&Ht(!!g),(a||null!=i.activeTransition||i.hasActivePulses)&&(vt.current=requestAnimationFrame(()=>mt.current()))},t.useEffect(()=>(bt(),()=>{var e;null===(e=Xt.current)||void 0===e||e.clear()}),[bt]),t.useEffect(()=>{nt.current=!0,bt()},[p,ct,ut,ue,Ge,bt]),Te(Qe,qt,nt,bt,It,Ht);const co=Ft&&_t?Se?Se(_t):e.jsx(dn,{hover:_t}):null,uo="radial"===P,ho=co?e.jsx(zt,{x:_t?uo?_t.x+ct/2:_t.x:0,y:_t?uo?_t.y+ut/2:_t.y:0,containerWidth:ct,containerHeight:ut,margin:lt,className:"stream-ordinal-tooltip",children:co}):null;if(kt){const t=qt.current;t&&m&&(t.ingest({inserts:m,bounded:!0}),t.computeScene({width:ct,height:ut}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,s="radial"===P,a=s?lt.left+ct/2:lt.left,l=s?lt.top+ut/2:lt.top;return e.jsxs("div",{className:"stream-ordinal-frame"+(Ye?" "+Ye:""),role:"img","aria-label":tt||("string"==typeof ze?ze:"Ordinal chart"),style:{position:"relative",width:at[0],height:at[1]},children:[e.jsx(Nt,{summary:ot}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:at[0],height:at[1],style:{position:"absolute",left:0,top:0},children:[ht&&e.jsx("g",{transform:`translate(${lt.left},${lt.top})`,children:ht}),e.jsxs("g",{transform:`translate(${a},${l})`,children:[Ge&&e.jsx("rect",{x:0,y:0,width:ct,height:ut,fill:Ge}),o.map((t,o)=>function(t,o){var n,i,r,s,a;const l=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",u=e=>`ord-${t.type}-${l}-${o}-${e}`,d=`ord-${t.type}-${l}-${o}`;switch(t.type){case"rect":{const o=t,n=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(d)+"-grad",i=function(t,o){const n=t.fillGradient;if(!n)return null;let i=t.x,r=t.y,s=t.x,a=t.y+t.h;"bottom"===t.roundedEdge?(r=t.y+t.h,a=t.y):"right"===t.roundedEdge?(i=t.x+t.w,r=t.y,s=t.x,a=t.y):"left"===t.roundedEdge&&(i=t.x,r=t.y,s=t.x+t.w,a=t.y);const l=[];if("colorStops"in n){const t=n.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>t.length)return null;for(let o=0;t.length>o;o++)l.push(e.jsx("stop",{offset:t[o].offset,stopColor:t[o].color},o))}else{const o=xt(t.style.fill);l.push(e.jsx("stop",{offset:0,stopColor:o,stopOpacity:n.topOpacity},"0")),l.push(e.jsx("stop",{offset:1,stopColor:o,stopOpacity:n.bottomOpacity},"1"))}return e.jsx("linearGradient",{id:o,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(o,n),r=i?`url(#${n})`:xt(o.style.fill);if(o.roundedTop&&o.roundedTop>0){const t=Math.min(o.roundedTop,o.w/2,o.h/2),{x:n,y:s,w:a,h:l}=o;let c;switch(o.roundedEdge){case"right":c=`M${n},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n},${s+l} Z`;break;case"left":c=`M${n+a},${s} L${n+t},${s} A${t},${t} 0 0 0 ${n},${s+t} L${n},${s+l-t} A${t},${t} 0 0 0 ${n+t},${s+l} L${n+a},${s+l} Z`;break;case"bottom":c=`M${n},${s} L${n+a},${s} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n+t},${s+l} A${t},${t} 0 0 1 ${n},${s+l-t} Z`;break;default:c=`M${n},${s+l} L${n},${s+t} A${t},${t} 0 0 1 ${n+t},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l} Z`}return e.jsxs(y.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:c,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}return e.jsxs(y.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:xt(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},d)}case"wedge":{const o=t,n=c.arc().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&n.cornerRadius(o.cornerRadius);const i=n({})||"";return e.jsx("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:xt(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},d)}case"boxplot":{const o=t,n=o.columnWidth/2;return e.jsxs("g","vertical"===o.projection?{children:[e.jsx("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:o.x-n,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:xt(o.style.fill),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-n,y1:o.medianPos,x2:o.x+n,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.x-.5*n,y1:o.minPos,x2:o.x+.5*n,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-.5*n,y1:o.maxPos,x2:o.x+.5*n,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[e.jsx("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-n,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:xt(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.medianPos,y1:o.y-n,x2:o.medianPos,y2:o.y+n,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.minPos,y1:o.y-.5*n,x2:o.minPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.maxPos,y1:o.y-.5*n,x2:o.maxPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1})]},d)}case"violin":{const o=t,n=[e.jsx("path",{d:o.pathString,transform:o.translateX||o.translateY?`translate(${o.translateX},${o.translateY})`:void 0,fill:xt(o.style.fill),fillOpacity:null!==(s=o.style.fillOpacity)&&void 0!==s?s:.6,stroke:o.style.stroke||"#333",strokeWidth:o.style.strokeWidth||1},u("path"))];if(o.iqrLine&&o.bounds){const t=o.bounds,i=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?n.push(e.jsx("line",{x1:i,y1:o.iqrLine.q1Pos,x2:i,y2:o.iqrLine.q3Pos,stroke:o.style.stroke||"#333",strokeWidth:2},u("iqr")),e.jsx("circle",{cx:i,cy:o.iqrLine.medianPos,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},u("med"))):n.push(e.jsx("line",{x1:o.iqrLine.q1Pos,y1:r,x2:o.iqrLine.q3Pos,y2:r,stroke:o.style.stroke||"#333",strokeWidth:2},u("iqr")),e.jsx("circle",{cx:o.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},u("med")))}return e.jsx("g",{children:n},d)}case"connector":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(a=t.style.opacity)&&void 0!==a?a:.5},d);case"trapezoid":{const o=t,n=o.points.map(e=>`${e[0]},${e[1]}`).join(" ");return e.jsx("polygon",{points:n,fill:xt(o.style.fill,"#999"),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},d)}default:return null}}(t,o)).filter(Boolean)]})]}),e.jsx(Yo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:n,showAxes:ue,showCategoryTicks:de,oLabel:wt,rLabel:jt,oFormat:At,rFormat:St,rTickValues:ke,tickLabelEdgeAlign:we,showGrid:Be,title:ze,legend:Ie,legendHoverBehavior:De,legendClickBehavior:He,legendHighlightedCategory:Ne,legendIsolatedCategories:$e,legendPosition:We,foregroundGraphics:dt,annotations:Pe,svgAnnotationRules:Re,annotationFrame:0,xAccessor:"string"==typeof b?b:void 0,yAccessor:"string"==typeof x?x:void 0,annotationData:null==t?void 0:t.getData()}),qe&&"radial"===P&&e.jsx("div",{style:{position:"absolute",left:lt.left+ct/2,top:lt.top+ut/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:qe})]})}return e.jsxs("div",{ref:st,className:"stream-ordinal-frame"+(Ye?" "+Ye:""),role:"group","aria-label":tt||("string"==typeof ze?ze:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:T?"100%":at[0],height:R?"100%":at[1],overflow:"visible"},onKeyDown:ao,children:[et&&e.jsx($t,{tableId:yt}),et&&e.jsx(Dt,{scene:null!==(a=null===(s=qt.current)||void 0===s?void 0:s.scene)&&void 0!==a?a:[],chartType:p+" chart",tableId:yt,chartTitle:"string"==typeof ze?ze:void 0}),e.jsx(Nt,{summary:ot}),e.jsxs("div",{role:"img","aria-label":tt||("string"==typeof ze?ze:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Ft?lo:void 0,onMouseLeave:Ft?oo:void 0,children:[ht&&e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:at[0],height:at[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${lt.left},${lt.top})`,children:ht})}),e.jsx(Eo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:Lt,showAxes:ue,showGrid:Be,rFormat:St,rTickValues:ke}),e.jsx("canvas",{ref:Mt,"aria-label":Ot(null!==(u=null===(l=qt.current)||void 0===l?void 0:l.scene)&&void 0!==u?u:[],p+" chart"),style:{position:"absolute",top:0,left:0,width:at[0],height:at[1]}}),e.jsx(Wt,{hoverPoint:_t}),e.jsx(Yo,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:Lt,showAxes:ue,showCategoryTicks:de,oLabel:wt,rLabel:jt,oFormat:At,rFormat:St,showGrid:Be,title:ze,legend:Ie,legendHoverBehavior:De,legendClickBehavior:He,legendHighlightedCategory:Ne,legendIsolatedCategories:$e,legendPosition:We,foregroundGraphics:dt,annotations:Pe,svgAnnotationRules:Re,annotationFrame:Rt,xAccessor:"string"==typeof b?b:void 0,yAccessor:"string"==typeof x?x:void 0,annotationData:null===(d=qt.current)||void 0===d?void 0:d.getData(),underlayRendered:!0}),(Ze||Je)&&"radial"!==P&&e.jsx(Go,{width:ct,height:ut,totalWidth:at[0],totalHeight:at[1],margin:lt,scales:Lt,onBrush:Je||(()=>{})}),qe&&"radial"===P&&e.jsx("div",{style:{position:"absolute",left:lt.left+ct/2,top:lt.top+ut/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:qe}),(null==Qe?void 0:Qe.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Qe.badgePosition?{top:4,left:4}:"bottom-left"===Qe.badgePosition?{bottom:4,left:4}:"bottom-right"===Qe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:It?"#dc3545":"#28a745",color:"white"}),children:It?"STALE":"LIVE"}),e.jsx(Et,{active:io.current>=0,hoverPoint:_t,margin:lt,size:at,shape:null===(h=ro.current)||void 0===h?void 0:h.shape,width:null===(g=ro.current)||void 0===g?void 0:g.w,height:null===(f=ro.current)||void 0===f?void 0:f.h}),ho]})]})});hn.displayName="StreamOrdinalFrame";const gn={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},fn={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class pn{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const o=this.particles[t];return o.active=!0,o.t=0,o.offset=Math.random()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,o,n){var i;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const a=o[s.edgeIndex];if(!a||!a.bezier){s.active=!1,this._freeIndices.push(r);continue}const l=n&&null!==(i=n[s.edgeIndex])&&void 0!==i?i:1;s.t+=e*t*l*(a.bezier.circular?.3:1),1>s.t?yn(a.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let o=0;e>o;o++)t.length>o?this.particles[o]=t[o]:(this.particles[o]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(o));this.capacity=e}}function yn(e,t,o,n){if(e.circular&&e.segments)return void function(e,t,o,n,i){const r=e.length,s=t*r,a=Math.min(Math.floor(s),r-1),l=s-a,[c,u,d,h]=e[a];vn(c,u,d,h,l,i);const g=h.x-c.x,f=h.y-c.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;i.x+=-f/p*o*n*2,i.y+=e*o*n*2}}(e.segments,t,o,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[i,r,s,a]=e.points;vn(i,r,s,a,t,n);const l=a.x-i.x,c=a.y-i.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;n.x+=-c/u*o*e.halfWidth*2,n.y+=t*o*e.halfWidth*2}}function vn(e,t,o,n,i,r){const s=1-i,a=s*s,l=a*s,c=i*i,u=c*i;r.x=l*e.x+3*a*i*t.x+3*s*c*o.x+u*n.x,r.y=l*e.y+3*a*i*t.y+3*s*c*o.y+u*n.y}function mn(e,t){var o=e.get(t);if(!o)throw Error("missing: "+t);return o}function bn(e,t){var o,n=[],i=[],r=[],s={},a=[];function l(e){r[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],r[t]&&l(t)})}function c(e){var t,n,d=!1;for(i.push(e),r[e]=!0,t=0;a[e].length>t;t++)(n=a[e][t])===o?(u(o,i),d=!0):r[n]||(d=c(n));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[n=a[e][t]];h||(s[n]=h={}),h[n]=!0}return i.pop(),d}function u(e,t){var o=[].concat(t).concat(e);n.push(o)}function d(t){!function(t){for(var o=0;e.length>o;o++)o>=t&&e[o]||(e[o]=[]),e[o]=e[o].filter(function(e){return e>=t})}(t);for(var o,n=function(e){for(var t=e.length,o=Array(t),n=Array(t),i=Array(t),r=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)o[l]=-1,n[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(o[t]=n[t]=u,i[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>r[t]){for(var f=r[t];g.length>f;++f){var p=g[f];if(0>o[p]){o[p]=n[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(n[t]=0|Math.min(n[t],n[p])),0>s[p]||a[t].push(s[p])}r[t]=f}else{if(n[t]===o[t]){var y=[],v=[],m=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(i[b]=!1,y.push(b),v.push(a[b]),m+=a[b].length,s[b]=d.length,b===t){l.length=f;break}}d.push(y);var x=Array(m);for(f=0;v.length>f;f++)for(var k=0;v[f].length>k;k++)x[--m]=v[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>o[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),i=n.components.filter(function(e){return e.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],o=s);var l=i[o];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:r,adjList:c}}o=0;for(var h=e.length;h>o;){var g=d(o);if(o=g.leastVertex,a=g.adjList){for(var f=0;a.length>f;f++)for(var p=0;a[f].length>p;p++){var y=a[f][p];r[+y]=!1,s[y]={}}c(o),o+=1}else o=h}return n}function xn(e){return e.y0-e.y1>0?"up":"down"}function kn(e,t){return t(e.source)==t(e.target)}function wn(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var o=0;return e.target.targetLinks.forEach(function(e){o=e.circular?o+1:o}),1>=t&&1>=o}function jn(e){return e.target.x0-e.source.x1}function An(e,t){var o=On(e),n=jn(t)/Math.tan(o);return"up"==xn(e)?e.y1-n:e.y1+n}function Sn(e,t){var o=On(e),n=jn(t)/Math.tan(o);return"up"==xn(e)?e.y1+n:e.y1-n}function On(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Mn(e,t){return t(e)}function Cn(e){return Pn(e.source)}function _n(e){return Pn(e.target)}function Pn(e){return(e.y0+e.y1)/2}function Ln(e){return e.virtual?0:e.value}function Tn(e,t){var o=0;e.sourceLinks.forEach(function(e){o=e.circular&&!kn(e,t)?o+1:o});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!kn(e,t)?n+1:n}),o+n}function Rn(e){return e.target.depth}function Bn(e,t){return e.sourceLinks.length?e.depth:t-1}function In(e,t){return e.y0-t.y0}function Dn(e,t){return t.y0-e.y0}function Hn(e,t){return e.y1-t.y1}function Nn(e,t){return t.y1-e.y1}function $n(e,t){return Fn(e.source,t.source)||e.index-t.index}function Wn(e,t){return Fn(e.target,t.target)||e.index-t.index}function Fn(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function En(e,t){return zn(e)==zn(t)?"bottom"==e.circularLinkType?Dn(e,t):In(e,t):zn(t)-zn(e)}function zn(e){return e.target.column-e.source.column}function Yn(e,t){return Gn(e)==Gn(t)}function Gn(e){return e.y0-e.y1>0?"up":"down"}function qn(e,t,o,n,i){let r=e;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(r.links,function(e){return e.source.y0});r.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=r.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Xn(r.links.filter(function(e){return"top"==e.circularLinkType}),t,o),Xn(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,o),r.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,kn(e,t)&&wn(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,a=e.circularLinkType,c=r.links.filter(function(e){return e.source.column==s&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?Dn:In);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=r.links.filter(function(e){return e.target.column==s&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?Nn:Hn),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(r.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,o=e.y0,n=e.target.x0,i=e.y1,r=(t+n)/2;return"M"+t+","+o+"C"+r+","+o+" "+r+","+i+" "+n+","+i}(e)}),r}function Xn(e,t,o){e.sort(En);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var r=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(kn(e,t)&&wn(e))e.circularPathData.verticalBuffer=r+e._circularWidth/2;else{for(var s=0;n.length>s;s++){var a=n[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Vn(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+o;r=l>r?l:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function Vn(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Un(e){return function(){return e}}function Kn(e){return e.index}function Qn(e){return e.nodes}function Zn(e){return e.links}function Jn(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(i,r){var s=i.length;if(t)i.sort(t);else if(r>0){var a=new Map;i.forEach(function(e,t){var o,n,i,r=(n=0,i=0,(o=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Pn(e.source)*t,n+=t}}),o.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Pn(e.target)*t,n+=t}}),n>0?i/n:NaN);a.set(e,{bc:r,idx:t})}),i.sort(function(e,t){var o=a.get(e),n=a.get(t),i=o.bc,r=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?o.idx-n.idx:1:-1:i-r})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Tn(t,o)-Tn(e,o):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==n.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Tn(t,o)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+i,t.y1=t.y0+t.value*e.ky)})})}function ei(e,t,o,n,i,r){var s=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=r;c>0;--c)u(l*=.99,o),d();function u(t,o){var n=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Tn(i,o)>0){var c=a.mean(i.sourceLinks,_n),u=a.mean(i.targetLinks,Cn),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Pn(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==n-1&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.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 g=a.mean(i.sourceLinks,_n),f=a.mean(i.targetLinks,Cn),p=((g&&f?(g+f)/2:g||f)-Pn(i))*t;i.y0+=p,i.y1+=p}})})}function d(){s.forEach(function(o){var r,s,a,l=e.y0,c=o.length;for(o.sort(t||Fn),a=0;c>a;++a)(s=l-(r=o[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+n;if((s=l-n-e.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=o[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function ti(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Wn),e.targetLinks.sort($n)}),e.nodes.forEach(function(e){var t=e.y0,o=t,n=e.y1,i=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=o+e.width/2,o+=e.width)})})}function oi(){var e=0,t=0,o=1,n=1,i=24,r=8,s=null,l=Kn,c=Bn,u=void 0,d=32,h=2,g=Qn,f=Zn;function p(){var p={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=o,g.y1=n,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var o=function(e,t){var o=new Map;return a.group(e,t).forEach(function(e,t){o.set(t,e[0])}),o}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,i=e.target;"object"!=typeof n&&(n=e.source=mn(o,n)),"object"!=typeof i&&(i=e.target=mn(o,i)),n.sourceLinks.push(e),i.targetLinks.push(e)})}(g,l),function(e,t){var o=0;if(null==t){for(var n=[],i=0;e.links.length>i;i++){var r=e.links[i],s=r.source.index,a=r.target.index;n[s]||(n[s]=[]),n[a]||(n[a]=[]),-1===n[s].indexOf(a)&&n[s].push(a)}var l=bn(n);l.sort(function(e,t){return e.length-t.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}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=o++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=o++)})}(g,u),function(e,t){var o=0,n=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:n>o?"top":"bottom","top"==i.circularLinkType?o++:n++,e.nodes.forEach(function(e){Mn(e,t)!=Mn(i.source,t)&&Mn(e,t)!=Mn(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),kn(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Ln),a.sum(e.targetLinks,Ln)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,o){var n,i,r;if(null!=t){e.nodes.sort(function(e,o){return t(e)<t(o)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.height=r,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?o(e,r):e.column})}(g,u,c);var f=r;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(n-t)*s/(y-1)))}(function(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=a.min(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var r=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(r>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-o)/r),t.x1=t.x0+o}:function(t){t.x0=e.x0,t.x1=t.x0+o})})(g,f,i),Jn(g,u,l),ei(g,u,l,f,f,d),ti(g),qn(g,l,h,10,8),Jn(g,u,l),ei(g,u,l,f,f,d),ti(g),qn(g,l,h,10,8),function(e,t){let o=e;o.nodes.forEach(function(e){e.y+(e.y1-e.y0)>o.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-o.y1));var n=o.links.filter(function(o){return Mn(o.source,t)==Mn(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Yn(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var o=An(t,e);return e.y1-o}if(t.target.column>e.target.column)return An(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y0=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y0=e.y1-s-t.width/2}})})}(g,l),function(e,t){let o=e;o.nodes.forEach(function(e){var n=o.links.filter(function(o){return Mn(o.target,t)==Mn(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Yn(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var o=Sn(t,e);return e.y0-o}if(t.source.column>e.source.column)return Sn(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y1=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y1=e.y1-s-t.width/2}})})}(g,l),function(e){var t=e.nodes,o=e.links,n=!1,i=!1;if(o.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==n||0==i){var r=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-r);function c(t){return(t-r)/(s-r)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),o.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,o=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+o}),e.targetLinks.forEach(function(e){e.y1=e.y1+o})})}}(g),qn(g,l,h,10,8)}(p),p}return p.update=function(e){return ti(e),qn(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(i=+e,p):i},p.nodePadding=function(e){return arguments.length?(r=+e,p):r},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:Un(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Un(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Un(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Un(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],o=+i[1][0],n=+i[1][1],p):[[e,t],[o,n]]},p.size=function(i){return arguments.length?(e=t=0,o=+i[0],n=+i[1],p):[o-e,n-t]},p}const ni=e=>{let t,o,n,i,r,s,a,l,c;return"down"===e.direction?(t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,r=e.source.x1,s=e.target.x0,a=d.interpolateNumber(r,s),l=a(.5),c=a(.5),`M${t},${r}C${t},${l} ${o},${c} ${o},${s}L${n},${s}C${n},${c} ${i},${l} ${i},${r}Z`):(t=e.source.x1,o=e.target.x0,a=d.interpolateNumber(t,o),n=a(.5),i=a(.5),r=e.y0-e.sankeyWidth/2,s=e.y1-e.sankeyWidth/2,l=e.y1+e.sankeyWidth/2,c=e.y0+e.sankeyWidth/2,`M${t},${r}C${n},${r} ${i},${s} ${o},${s}L${o},${l}C${i},${l} ${n},${c} ${t},${c}Z`)};function ii(e){var t;const o=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const t=i.sourceX,n=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${t},${n-o}L${t+a},${n-o}L${t+a},${n+o}L${t},${n+o}ZM${r},${s-o}L${r-l},${s-o}L${r-l},${s+o}L${r},${s+o}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"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(n,15));return`M${r},${s-h*o}L${c},${s-h*o}L${c+n},${s-h*o+h*g}L${c+n},${d+h*n-h*g}L${c+n-g},${d+h*n}L${u-n+g},${d+h*n}L${u-n},${d+h*n-h*g}L${u-n},${l-h*o+h*g}L${u-n+g},${l-h*o}L${a},${l-h*o}L${a},${l+h*o}L${u+n},${l+h*o}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${s+h*o}L${r},${s+h*o}Z`}const ri=new Set,si=new WeakMap;function ai(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let o=si.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,si.set(e,o);const n=new Proxy(e,{get(e,o,n){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;ri.has(e)||(ri.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,o,n)}});return o.set(t,n),n}const li={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Rn))-1:0},justify:Bn};function ci(e){return"string"==typeof e?e:e.id}const ui={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r,s,a,l,c,u;if(0===e.length)return;const d="vertical"===o.orientation?"down":"right",h=o.nodeAlign||"justify",g=null!==(i=o.nodeWidth)&&void 0!==i?i:15,f=null!==(r=o.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=o.iterations)&&void 0!==s?s:100,y=e.map(e=>Object.assign({},e)),v=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let m;m="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=oi().extent(m).links(v).nodes(y).nodeAlign(li[h]||Bn).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,o=1/0,i=-1/0;for(const n of y)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),o>n.y0&&(o=n.y0),n.y1>i&&(i=n.y1);for(const n of v){if(!n.circular||!n.circularPathData)continue;const r=n.circularPathData,s=(null!==(l=null!==(a=n._circularWidth)&&void 0!==a?a:n.width)&&void 0!==l?l:0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),o>r.verticalFullExtent-s&&(o=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=t-e,s=i-o,u=n[0],d=n[1];if(r>0&&s>0&&(0>e||0>o||t>u||i>d)){const t=Math.min(u/r,d/s),n=-e*t+(u-r*t)/2,i=-o*t+(d-s*t)/2;for(const e of y)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of v)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const o=e.circularPathData;o.sourceX=o.sourceX*t+n,o.targetX=o.targetX*t+n,o.sourceY=o.sourceY*t+i,o.targetY=o.targetY*t+i,o.rightFullExtent=o.rightFullExtent*t+n,o.leftFullExtent=o.leftFullExtent*t+n,o.verticalFullExtent=o.verticalFullExtent*t+i,o.rightInnerExtent=o.rightInnerExtent*t+n,o.leftInnerExtent=o.leftInnerExtent*t+n,o.verticalRightInnerExtent=o.verticalRightInnerExtent*t+i,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*t+i,o.rightSmallArcRadius*=t,o.rightLargeArcRadius*=t,o.leftSmallArcRadius*=t,o.leftLargeArcRadius*=t,o.sourceWidth*=t,o.rightNodeBuffer*=t,o.leftNodeBuffer*=t,o.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of v){const t=ci(e.source),o=ci(e.target),n=k.get(e._edgeKey?e._edgeKey:`${t}\0${o}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=d;const i=x.get(t),r=x.get(o);i&&(n.source=i),r&&(n.target=r)}}},buildScene(e,t,o,n){var i,r,a,l,c,u;const d="vertical"===o.orientation?"down":"right",h=o.nodeStyle,g=o.edgeStyle,f=null!==(i=o.edgeOpacity)&&void 0!==i?i:.5,p=o.edgeColorBy||"source",y=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:s.schemeCategory10,v=new Map;e.forEach((e,t)=>{v.set(e.id,y[t%y.length])});const m=[],b=[],x=[],k=new Map;for(const t of e){const e=t.x1-t.x0,o=t.y1-t.y0;if(0>=e||0>=o)continue;const n=h?h(ai(t,"nodeStyle")):{},i={fill:n.fill||v.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};k.set(t.id,("string"==typeof i.fill?i.fill:null)||v.get(t.id)||"#4d430c"),m.push("down"===d?{type:"rect",x:t.y0,y:t.x0,w:o,h:e,style:i,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:o,style:i,datum:t,id:t.id,label:t.id})}const w=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of w){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(a=o.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";i="function"==typeof p?p(e)||i:"target"===p?k.get(n.id)||v.get(n.id)||i:k.get(t.id)||v.get(t.id)||i;const s=g?g(ai(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,o=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),r=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=s.fill||i;b.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-o}L${t.sourceX+n},${t.sourceY-o}L${t.sourceX+n},${t.sourceY+o}L${t.sourceX},${t.sourceY+o}Z`,style:{fill:a,fillOpacity:null!==(l=s.fillOpacity)&&void 0!==l?l:f,stroke:"none",opacity:s.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),b.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-o}L${t.targetX-r},${t.targetY-o}L${t.targetX-r},${t.targetY+o}L${t.targetX},${t.targetY+o}Z`,style:{fill:a,fillOpacity:null!==(c=s.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:s.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-r,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?ii(e):ni(e),!d)continue;const h={fill:s.fill||i,fillOpacity:null!==(u=s.fillOpacity)&&void 0!==u?u:f,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity};b.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:h,datum:e})}if(!1!==o.showLabels){const t=(j=o.nodeLabel)?"function"==typeof j?j:e=>e[j]||e.id:null;for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const r=t?t(o):o.id;if(!r)continue;let s,a,l;"down"===d?(s=o.y0+(o.y1-o.y0)/2,a=o.x1+14,l="start"):(n[0]/2>o.x0+e/2?(s=o.x0-6,l="end"):(s=o.x1+6,l="start"),a=o.y0+i/2),x.push({x:s,y:a,text:r+"",anchor:"down"===d?"middle":l,baseline:"middle",fontSize:11})}}var j;return{sceneNodes:m,sceneEdges:b,labels:x}}},di={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r;if(0===e.length)return;const s=null!==(i=o.forceStrength)&&void 0!==i?i:.1,a=n[0]/2,l=n[1]/2,c=o.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=null==c?void 0:c.get(t.id);e?u++:o?(t.x=o.x,t.y=o.y,u++):d.push(t)}const g=u>0&&.3>=(e.length>0?d.length/e.length:1);if(g){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of d){const n=hi(e.id,t,o);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const i=gi(e.id),r=i%360*(Math.PI/180),s=10+i%20;e.x=t/n.length+s*Math.cos(r),e.y=o/n.length+s*Math.sin(r)}else{const t=gi(e.id),o=t%360*(Math.PI/180),n=15+t%30;e.x=a+n*Math.cos(o),e.y=l+n*Math.sin(o)}}}else{const t=2.399963229728653;for(let o=0;e.length>o;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5),i=o*t;n.x=a+e*Math.cos(i),n.y=l+e*Math.sin(i)}}}const f=null!==(r=o.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===o.iterations?0:g?40:f,y=fi(o.nodeSize,o.nodeSizeRange,e),v=e=>y(e);if(p>0){const o=h.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),n=h.forceSimulation().force("charge",h.forceManyBody().strength(e=>-25*v(e))).force("center",h.forceCenter(a,l).strength(.8)).force("x",h.forceX(a).strength(.15)).force("y",h.forceY(l).strength(.15));if(n.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));n.force("link",o),n.force("link").links(e)}g?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;p>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=v(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=m.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=m.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,n){var i,r,a,l,c,u,d;const h=o.nodeStyle,g=o.edgeStyle,f=fi(o.nodeSize,o.nodeSizeRange,e),p=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:s.schemeCategory10,y=new Map;e.forEach((e,t)=>{y.set(e.id,p[t%p.length])});const v=[],m=[],b=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(ai(t,"nodeSize")),n=h?h(ai(t,"nodeStyle")):{},s={fill:n.fill||y.get(t.id)||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:2,opacity:n.opacity};v.push({type:"circle",cx:t.x,cy:t.y,r:e,style:s,datum:t,id:t.id,label:t.id})}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:x.get(e.source),n="object"==typeof e.target?e.target:x.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const i=g?g(ai(e,"edgeStyle")):{},r={stroke:i.stroke||(null===(l=o.themeSemantic)||void 0===l?void 0:l.border)||(null===(c=o.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(u=i.strokeWidth)&&void 0!==u?u:1,opacity:null!==(d=i.opacity)&&void 0!==d?d:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==o.showLabels){const t=(k=o.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=f(ai(o,"nodeSize"));b.push({x:o.x,y:o.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:v,sceneEdges:m,labels:b}}};function hi(e,t,o){const n=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(t===e?s=r:r===e&&(s=t),s){const e=o.get(s);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function gi(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function fi(e,t,o){var n,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=o.map(t=>{var o;return null===(o=t.data)||void 0===o?void 0:o[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(n=a.min(l))&&void 0!==n?n:0,u=null!==(r=a.max(l))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var o;const n=null===(o=t.data)||void 0===o?void 0:o[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const pi=s.schemeCategory10,yi={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:s}=o,a=Math.min(n[0],n[1])/2,l=a-r,u=n[0]/2,d=n[1]/2,h=(f=o.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const y=e.length,v=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=p.get("string"==typeof e.source?e.source:e.source.id),n=p.get(t);if(void 0===o||void 0===n)continue;const i=h(e);v[o][n]=i}const m=g.chord().padAngle(i);s&&m.sortGroups(s);const b=m(v),x=b.groups,k=c.arc().innerRadius(l).outerRadius(a);for(const t of x){const o=e[t.index],n=k.centroid(t);o.x=n[0]+u,o.y=n[1]+d,o.arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);o&&(e.source=o),n&&(e.target=n)}const j=new Map;for(const e of t)j.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const o=e[t.source.index].id,n=e[t.target.index].id,i=j.get(`${o}\0${n}`)||j.get(`${n}\0${o}`);i&&(i.chordData=t)}},buildScene(e,t,o,n){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=o,u=Math.min(n[0],n[1])/2,d=u-l,h=n[0]/2,f=n[1]/2,p=o.nodeStyle,y=o.edgeStyle,v=o.edgeColorBy||"source",m=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:pi,b=new Map;e.forEach((e,t)=>{b.set(e.id,m[t%m.length])});const x=g.ribbon().radius(d),k=[],w=[],j=[];for(let t=0;e.length>t;t++){const o=e[t],n=o.arcData;if(!n)continue;let r;r=p?p(ai(o,"nodeStyle")).fill||b.get(o.id)||m[t%m.length]:b.get(o.id)||m[t%m.length];const s=p?p(ai(o,"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:h,cy:f,innerR:d,outerR:u,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:o,id:o.id,label:o.id})}for(const e of t){const t=e.chordData;if(!t)continue;const n=x(t);if(!n)continue;const i=vi(n,h,f);let l=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=o.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)l=y(ai(e,"edgeStyle")).fill||l;else{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;"target"===v&&o?l=b.get(o.id)||l:t&&(l=b.get(t.id)||l)}const u=y?y(ai(e,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:e})}if(!1!==o.showLabels){const t=(A=o.nodeLabel)?"function"==typeof A?A:e=>e[A]||e.id:null,n=u+12;for(const o of e){const e=o.arcData;if(!e)continue;const i=t?t(o):o.id;if(!i)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;j.push({x:h+Math.cos(s)*n,y:f+Math.sin(s)*n,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var A;return{sceneNodes:k,sceneEdges:w,labels:j}}};function vi(e,t,o){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const i=[];let r=0;for(;n.length>r;){const e=n[r];if("M"===e||"L"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("C"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;3>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("Q"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;2>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("A"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&(i.push(Number(n[r])+t+""),r++),n.length>r&&(i.push(Number(n[r])+o+""),r++);else"Z"===e||"z"===e?(i.push(e),r++):(i.push(n[r]),r++)}return i.join(" ")}const mi=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function bi(e){const[t,o,n]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*o+.114*n>150?"#222":"#fff"}function xi(e,t,o){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+o}function ki(e){return e?"function"==typeof e?e:t=>{var o;return(null===(o=t.data)||void 0===o?void 0:o[e])||t[e]||t.id}:null}function wi(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:mi}function ji(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ai(e,t,o,n,i){if("horizontal"===i){const i=(e+o)/2;return`M ${e},${t} C ${i},${t} ${i},${n} ${o},${n}`}if("radial"===i){const i=(e+o)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+n)/2} T ${o},${n}`}{const i=(t+n)/2;return`M ${e},${t} C ${e},${i} ${o},${i} ${o},${n}`}}const Si={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,o,n){var i;const r=o.__hierarchyRoot;if(!r)return;const s=o.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(o.childrenAccessor),c=o.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>{var t;return null!==(t=e[c])&&void 0!==t?t:0}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:0},d=l.hierarchy(r,a);d.sum(u),d.sort((e,t)=>{var o,n;return(null!==(o=t.value)&&void 0!==o?o:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,g]=n;switch(s){case"tree":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.tree();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"cluster":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.cluster();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"treemap":!function(e,t,o,n){var i,r;const s=null!==(i=t.padding)&&void 0!==i?i:4,a=null!==(r=t.paddingTop)&&void 0!==r?r:0,c=l.treemap().size([o,n]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(e)}(d,o,h,g);break;case"circlepack":!function(e,t,o,n){var i;const r=null!==(i=t.padding)&&void 0!==i?i:4;l.pack().size([o,n]).padding(r)(e)}(d,o,h,g);break;case"partition":!function(e,t,o,n){var i;l.partition().size([o,n]).padding(null!==(i=t.padding)&&void 0!==i?i:1)(e)}(d,o,h,g)}const f=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;f.length>t;t++){const n=f[t],r={id:xi(n,o,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=n.value)&&void 0!==i?i:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?Oi(r,n,o):"treemap"===s||"partition"===s?Mi(r,n):"circlepack"===s&&Ci(r,n),r.__hierarchyNode=n,e.push(r),p.set(n,r)}if("tree"===s||"cluster"===s)for(const e of f)if(e.parent){const o=p.get(e.parent),n=p.get(e);o&&n&&t.push({source:o,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,o,n){const i=o.nodeStyle||(()=>({})),r=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(e,t,o,n,i,r){var s,a,l,c,u,d,h,g;const f=[],p=[],y=[],v=o.treeOrientation||"vertical",m="radial"===v,b=n[0]/2,x=n[1]/2,k="number"==typeof(w=o.nodeSize)?w:5;var w;for(const t of e){let e=t.x,n=t.y;m&&(e+=b,n+=x);const r=i(ai(t,"nodeStyle"));let l=r.fill||ji(o);if(o.colorByDepth&&void 0!==t.depth){const e=wi(o);l=e[t.depth%e.length]}const c={fill:l,stroke:r.stroke||(null===(s=o.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};f.push({type:"circle",cx:e,cy:n,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const j=null!==(l=o.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=t.x,s=t.y,a=n.x,l=n.y;m&&(i+=b,s+=x,a+=b,l+=x);const g=Ai(i,s,a,l,v),f=r(ai(e,"edgeStyle")),y={fill:"none",stroke:f.stroke||(null===(c=o.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=o.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=f.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=f.opacity)&&void 0!==h?h:j};p.push({type:"curved",pathD:g,style:y,datum:e})}if(!1!==o.showLabels){const t=ki(o.nodeLabel);for(const o of e){const e=t?t(o):o.id;if(!e)continue;let n,i,r,s=o.x,a=o.y;if(m&&(s+=b,a+=x),m){const e=s-b,t=a-x,o=Math.sqrt(e*e+t*t);o>0?(n=s+e/o*10,i=a+t/o*10,r=0>e?"end":"start"):(n=s,i=a-12,r="middle")}else"horizontal"===v?((null===(g=o.data)||void 0===g?void 0:g.children)&&0!==o.data.children.length?(n=s-k-6,r="end"):(n=s+k+6,r="start"),i=a):(n=s,i=a+k+14,r="middle");y.push({x:n,y:i,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:f,sceneEdges:p,labels:y}}(e,t,o,n,i,r);case"treemap":case"partition":return function(e,t,o,n){var i,r,s,a,l;const c=[],u=[];for(const o of e){const e=o.x1-o.x0,s=o.y1-o.y0;if(0>=e||0>=s)continue;const a=n(ai(o,"nodeStyle"));let l=a.fill||ji(t);if(t.colorByDepth&&void 0!==o.depth){const e=wi(t);l=e[o.depth%e.length]}const u={fill:l,stroke:a.stroke||(null===(i=t.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:o.x0,y:o.y0,w:e,h:s,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=ki(t.nodeLabel),i=t.labelMode||"leaf",r="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,d=c.y1-c.y0;if(0>=e||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 g=o?o(c):c.id;if(!g)continue;if((h?30:40)>e||(h?16:14)>d)continue;let f=n(ai(c,"nodeStyle")).fill||ji(t);if(t.colorByDepth&&void 0!==c.depth){const e=wi(t);f=e[c.depth%e.length]}const p="string"==typeof f?bi(f):null!==(l=null===(a=t.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+e/2,y:c.y0+d/2,text:g+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/6)),fill:p}:{x:c.x0+4,y:c.y0+12,text:g+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,o,0,i);case"circlepack":return function(e,t,o,n){var i,r,s,a,l,c,u,d,h,g;const f=[],p=[];for(const o of e){const e=null!==(i=o.__radius)&&void 0!==i?i:5;if(0>=e)continue;const l=n(ai(o,"nodeStyle"));let c=l.fill||ji(t);if(t.colorByDepth&&void 0!==o.depth){const e=wi(t);c=e[o.depth%e.length]}const u={fill:c,stroke:l.stroke||(null===(r=t.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};f.push({type:"circle",cx:o.x,cy:o.y,r:e,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=ki(t.nodeLabel);for(const i of e){const e=null!==(l=i.__radius)&&void 0!==l?l:5,r=o?o(i):i.id;if(!r)continue;if(15>e)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=n(ai(i,"nodeStyle")).fill||ji(t);if(t.colorByDepth&&void 0!==i.depth){const e=wi(t);a=e[i.depth%e.length]}if(s){const o="string"==typeof a?bi(a):null!==(d=null===(u=t.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,e/3)),fill:o})}else p.push({x:i.x,y:i.y-e+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(g=t.themeSemantic)||void 0===g?void 0:g.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:f,sceneEdges:[],labels:p}}(e,o,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Oi(e,t,o){const n=o.treeOrientation||"vertical";if("radial"===n){const o=t.x,n=t.y;e.x=n*Math.cos(o-Math.PI/2),e.y=n*Math.sin(o-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Mi(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Ci(e,t){var o;const n=null!==(o=t.r)&&void 0!==o?o:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function _i(e){const t=e;return t.__orbitState||(t.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),t.__orbitState}const Pi={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,o,n){const i=o.__hierarchyRoot;i&&function(e,t,o,n,i){var r,s;const a=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(o.childrenAccessor),l=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var o;return(null!==(o=e[t])&&void 0!==o?o:"")+""}}(o.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),d=null!==(r=o.orbitSize)&&void 0!==r?r:2.95,h=null!==(s=o.orbitEccentricity)&&void 0!==s?s:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=_i(o);p.metaMap.clear(),n.length=0,i.length=0;const y=new Map;function v(e){var t;const o=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,o+1),0===o?e:`${e}__${o}`}const m=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=v(l(e));n.push({id:k,x:m,y:b,x0:m,x1:m,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,o,r,s,d,h,y){const m=a(t);if(!(null==m?void 0:m.length))return;const b=m.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let j=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=m.slice(j,j+k);if(!w.length)break;const A=(b+1)/x,S={id:o,depth:h,data:t,parentId:o},O=y?d/g(S)*A:d*A,M=c.pie().value(e=>{var t;return(null===(t=a(e))||void 0===t?void 0:t.length)?4:1}).sort(null),C=M(w),_=f(S);for(let t=0;w.length>t;t++){const a=(C[t].startAngle+C[t].endAngle)/2,c=w[t],u=v(l(c)),d=r+O*Math.sin(a),g=s+O*Math.cos(a)*_;n.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:c}),p.metaMap.set(u,{ring:O,angle:a,depth:h,parentId:o,eccentricity:_}),i.push({source:o,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:u}}),e(c,u,d,g,O,h+1,!0)}j+=k}}(e,k,m,b,x,1,!1)}(i,n,o,e,t)},buildScene(e,t,o,n){var i,r,s,a,l,c,u;const d=o.nodeStyle,h=o.nodeSize,g="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,f=[],p=[],y=[];if(!1!==o.orbitShowRings){const t=_i(o),n=new Map;for(const t of e)n.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const o=`${e.parentId}:${e.ring}`;i.has(o)||i.set(o,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:o,ecc:n}]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:e+o*Math.sin(a),y1:t+o*Math.cos(a)*n,x2:e+o*Math.sin(l),y2:t+o*Math.cos(l)*n,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=g(ai(t,"nodeSize")),n=d?d(ai(t,"nodeStyle")):{},c={fill:n.fill||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:v.get(e.source),o="object"==typeof e.target?e.target:v.get(e.target);t&&o&&(null!=t.x&&null!=o.x&&p.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(o.showLabels){const t=o.nodeLabel;for(const o of e){const e=g(ai(o,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(o):t&&null!==(u=null===(c=o.data)||void 0===c?void 0:c[t])&&void 0!==u?u:o.id;y.push({x:o.x,y:o.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:p,labels:y}},tick:(e,t,o,n,i)=>!1!==o.orbitAnimated&&(function(e,t){var o,n;const i=_i(t),r=null!==(o=t.orbitSpeed)&&void 0!==o?o:.25,s=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const o=null!==(t=e.depth)&&void 0!==t?t:0;return(o%2==0?1:-1)/(o+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=c.get(e.parentId);if(!o)continue;const n=e.angle+a*l*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(n),t.y=o.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,o),!0)},Li={sankey:ui,force:di,chord:yi,tree:Si,cluster:Si,treemap:Si,circlepack:Si,partition:Si,orbit:Pi};function Ti(e){return Li[e]}class Ri{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},gn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&(this.particlePool=new pn(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},gn),e.tensionConfig),"sankey"===e.chartType&&e.showParticles&&!this.particlePool&&(this.particlePool=new pn(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,o){const{nodeIDAccessor:n="id",sourceAccessor:i="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,a="function"==typeof n?n:e=>e[n],l="function"==typeof i?i:e=>e[i],c="function"==typeof r?r:e=>e[r],u="function"==typeof s?s:e=>{var t;return null!==(t=e[s])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},Bi(e)),{data:t}))}for(let e=0;t.length>e;e++){const o=t[e],n=l(o)+"",i=c(o)+"",r=Number(u(o))||1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},Bi(n)),{data:o})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Bi(i)),{data:o}));const s=`${n}\0${i}\0${e}`;this.edges.set(s,{source:n,target:i,value:r,y0:0,y1:0,sankeyWidth:0,data:o,_edgeKey:s})}this.runLayout(o)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:o,value:n}=e,i=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,Bi(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(o)||(this.nodes.set(o,Bi(o)),this.nodeTimestamps.set(o,s),this.tension+=this.tensionConfig.newNode,r=!0);const a=this.edgeKey(t,o),l=this.edges.get(a);let c=!1;return l?(l.value+=n,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:o,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,r=!0),i||r||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,o,n,i,r,s,a,l;const c=Ti(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const a of u)if(void 0!==a._prevX0){const l=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(o=a._prevX0)&&void 0!==o?o:0),c=(null!==(n=a._prevY1)&&void 0!==n?n:0)-(null!==(i=a._prevY0)&&void 0!==i?i:0);e.set(a.id,{x:(null!==(r=a._prevX0)&&void 0!==r?r:0)+l/2,y:(null!==(s=a._prevY0)&&void 0!==s?s:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,o]of this._lastPositionSnapshot)e.has(t)||e.set(t,o);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],o=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=o,this.edges.set(o,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const o=e.get(t.id);o&&(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const g=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),f=null!==(l=null===(a=this.config.transition)||void 0===a?void 0:a.duration)&&void 0!==l?l:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&f>0){const t=e[0]/2,o=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=o,e._prevY1=o;for(const e of this.edges.values())e._prevY0=o,e._prevY1=o,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f}}else g&&f>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f});this._hasRenderedOnce=!0;const p=new Set(this.nodes.keys()),y=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const e of p)this.previousNodeIds.has(e)||this.addedNodes.add(e);for(const e of this.previousNodeIds)p.has(e)||this.removedNodes.add(e);for(const e of y)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)y.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=p,this.previousEdgeKeys=y,this.layoutVersion++}buildScene(e){const t=Ti(this.config.chartType);if(!t)return;const o=Array.from(this.nodes.values()),n=Array.from(this.edges.values()),{sceneNodes:i,sceneEdges:r,labels:s}=t.buildScene(o,n,this.config,e);this.sceneNodes=i,this.sceneEdges=r,this.labels=s}get isAnimating(){const e=Ti(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const o=Ti(this.config.chartType);if(!(null==o?void 0:o.tick))return!1;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return o.tick(n,i,this.config,e,t)}advanceTransition(e){if(!this.transition)return!1;const t=K(e,this.transition),o=U(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Q(e._prevX0,e._targetX0,o),e.x1=Q(e._prevX1,e._targetX1,o),e.y0=Q(e._prevY0,e._targetY0,o),e.y1=Q(e._prevY1,e._targetY1,o));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Q(e._prevY0,e._targetY0,o),e.y1=Q(e._prevY1,e._targetY1,o),e.sankeyWidth=Q(e._prevSankeyWidth,e._targetSankeyWidth,o));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const o=null==e?void 0:e.get(t.id);o&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const o=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(o){e._prevY0=o.y0,e._prevY1=o.y1,e._prevSankeyWidth=o.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,o="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&o&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,o))}buildStandardBezier(e,t,o){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,r=o.x0,s=d.interpolateNumber(i,r);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:r}],halfWidth:n}}const i=t.x1,r=o.x0,s=d.interpolateNumber(i,r);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:r,y:e.y1}],halfWidth:n}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,o=e.circularPathData;if(!o)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(o.rightFullExtent-o.sourceX))),n=Math.max(15,Math.min(40,.33*(o.targetX-o.leftFullExtent)));return{circular:!0,segments:[[{x:o.sourceX,y:o.sourceY},{x:o.sourceX+.33*e,y:o.sourceY},{x:o.sourceX+.66*e,y:o.sourceY},{x:o.sourceX+e,y:o.sourceY}],[{x:o.targetX-n,y:o.targetY},{x:o.targetX-.66*n,y:o.targetY},{x:o.targetX-.33*n,y:o.targetY},{x:o.targetX,y:o.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:o.sourceY,y:o.sourceX},{x:o.sourceY,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.leftFullExtent},{x:o.targetY,y:o.leftFullExtent},{x:o.targetY,y:o.targetX}]:[{x:o.sourceX,y:o.sourceY},{x:o.rightFullExtent,y:o.sourceY},{x:o.rightFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.targetY},{x:o.targetX,y:o.targetY}];const i=[];for(let e=0;n.length-1>e;e++){const t=n[e],o=n[e+1],r=o.x-t.x,s=o.y-t.y;i.push([t,{x:t.x+r/3,y:t.y+s/3},{x:t.x+2*r/3,y:t.y+2*s/3},o])}return{circular:!0,segments:i,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,o,n,i,r;const s=this.config.pulse;if(!s)return;const a=null!==(t=s.duration)&&void 0!==t?t:500,l=null!==(o=s.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=s.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const n=this.nodeTimestamps.get(o);if(!n)continue;const i=e-n;a>i&&(t._pulseIntensity=1-i/a,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const o=t.datum;if(!o)continue;const n="object"==typeof o.source?null===(i=o.source)||void 0===i?void 0:i.id:o.source,s="object"==typeof o.target?null===(r=o.target)||void 0===r?void 0:r.id:o.target;if(!n||!s)continue;const c=this.edgeTimestamps.get(`${n}\0${s}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=l)}}applyDecay(){var e,t;const o=this.config.decay;if(!o)return;const n=this.nodeTimestamps.size;if(1>=n)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const i=this._decaySortedNodes,r=new Map;for(let e=0;i.length>e;e++)r.set(i[e][0],e);for(const i of this.sceneNodes){const s=i.id;if(!s)continue;const a=r.get(s);if(void 0===a)continue;const l=X(o,a,n),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const o=e-this.lastTopologyChangeTime;if(o>=2e3)return;const n=1-o/2e3;for(const e of this.sceneNodes){const o=e.id;o&&this.addedNodes.has(o)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,o;const n=this.config.thresholds;if(!n)return;const i=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",r=null!==(o=n.criticalColor)&&void 0!==o?o:"#ef4444",s=!1!==n.pulse;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const a=this.nodes.get(o);if(!a)continue;const l=n.metric(a);let c=null;void 0===n.critical||n.critical>l?void 0===n.warning||n.warning>l||(c=i):c=r,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),s&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const o=e.metric(t);if(void 0!==e.warning&&o>=e.warning||void 0!==e.critical&&o>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const o="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>o-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var o;const n=this.nodes.get(e);if(!n)return null;const i=n.data?Object.assign({},n.data):{};return n.data=t(null!==(o=n.data)&&void 0!==o?o:{}),this.layoutVersion++,i}updateEdge(e,t,o){var n;const i=this.config.valueAccessor,r="function"==typeof i?i:i?e=>e[i]:e=>e.value,s=[];for(const[,i]of this.edges)if(("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t){s.push(i.data?Object.assign({},i.data):{}),i.data=o(null!==(n=i.data)&&void 0!==n?n:{});const e=r(i.data);null!=e&&(i.value=Number(e))}return s.length>0&&this.layoutVersion++,s}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)!==e&&("string"==typeof o.target?o.target:o.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const o=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,i]of this.edges)i.data&&n(i.data)===e&&o.push(t)}else for(const[n,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&o.push(n);for(const e of o)this.edges.delete(e),this.edgeTimestamps.delete(e);return o.length>0&&this.layoutVersion++,o.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function Bi(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Ii(e,t,o,n,i=30){let r=null,s=i,a=1/0;for(const t of e){const e=Di(t,o,n,i);if(e)if("rect"===t.type){const o=t.w*t.h;a>o&&(r=e,a=o)}else s>e.distance&&(r=e,s=e.distance)}if(r)return r;for(const e of t){const t=Fi(e,o,n);t&&s>t.distance&&(r=t,s=t.distance)}return r}function Di(e,t,o,n=30){switch(e.type){case"circle":return function(e,t,o,n=30){const i=t-e.cx,r=o-e.cy,s=Math.sqrt(i*i+r*r);return s>de(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,o,n);case"rect":return function(e,t,o){const n=ue(t,o,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,o);case"arc":return function(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerR-2>r||r>e.outerR+2)return null;const s=fe(Math.atan2(i,n)),a=fe(e.startAngle),l=fe(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const t=(e.startAngle+e.endAngle)/2,o=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+o*Math.cos(t),y:e.cy+o*Math.sin(t),distance:0}}return null}(e,t,o);default:return null}}let Hi=null,Ni=null;function $i(){return Ni||(Hi=document.createElement("canvas"),Hi.width=1,Hi.height=1,Ni=Hi.getContext("2d")),Ni}function Wi(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function Fi(e,t,o){switch(e.type){case"bezier":return function(e,t,o){var n,i;if(!e.pathD)return null;const r=Wi(e),s=$i();if(!r||!s)return null;try{if(s.isPointInPath(r,t,o)){const r="object"==typeof(null===(n=e.datum)||void 0===n?void 0:n.source)?e.datum.source:null,s="object"==typeof(null===(i=e.datum)||void 0===i?void 0:i.target)?e.datum.target:null;return{type:"edge",datum:e.datum,x:r&&s?(r.x1+s.x0)/2:t,y:e.datum?(e.datum.y0+e.datum.y1)/2:o,distance:0}}const a=s.lineWidth;s.lineWidth=10;const l=s.isPointInStroke(r,t,o);if(s.lineWidth=a,l)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);case"line":return function(e,t,o){const n=e.x2-e.x1,i=e.y2-e.y1,r=n*n+i*i;if(0===r)return null;let s=((t-e.x1)*n+(o-e.y1)*i)/r;s=Math.max(0,Math.min(1,s));const a=e.x1+s*n,l=e.y1+s*i,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(o-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,o);case"ribbon":case"curved":return function(e,t,o){if(!e.pathD)return null;const n=Wi(e),i=$i();if(!n||!i)return null;try{if(i.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(n,t,o);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);default:return null}}function Ei(t){const{width:o,height:n,totalWidth:i,totalHeight:r,margin:s,labels:a,title:l,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g,legendPosition:f="right",foregroundGraphics:p,sceneNodes:v,annotations:m,svgAnnotationRules:b}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof l?l:"Network Chart"}),e.jsx("desc",{children:"string"==typeof l?l+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[a.map((t,o)=>e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+o)),m&&m.filter(e=>"widget"!==e.type).map((t,i)=>{if(b){const r=b(t,i,{width:o,height:n,sceneNodes:v});if(r)return e.jsx(y.Fragment,{children:r},"annotation-"+i)}return null}),p]}),l&&"string"==typeof l?e.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"currentColor",children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:i,height:s.top,children:l}):null,Ee({legend:c,totalWidth:i,totalHeight:r,margin:s,legendPosition:f,title:l,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g})]}),null==m?void 0:m.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,o)=>{var n,i,r,a,l,c,u,d,h;const g=v.find(e=>{var o,n,i,r,s;return e.id===t.nodeId||(null===(o=e.datum)||void 0===o?void 0:o.id)===t.nodeId||(null===(i=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===i?void 0:i.id)===t.nodeId||(null===(s=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===t.nodeId});if(!g)return null;const f=s.left+(null!==(n=g.cx)&&void 0!==n?n:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(i=g.x)&&void 0!==i?i:0),p=s.top+(null!==(r=g.cy)&&void 0!==r?r:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(a=g.y)&&void 0!==a?a:0),y=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(c=t.dy)&&void 0!==c?c:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:f+y-b/2,top:p+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+o)})]})}function zi(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Yi(e,t){var o,n,i,r,s,a;if(!t.pathD)return;e.save();const l=zi(t);if(t.style.fill&&"none"!==t.style.fill){const s=t._gradient;if(s){const i=e.createLinearGradient(s.x0,0,s.x1,0),r=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,a="string"==typeof t.style.fill?t.style.fill:"#999",l=Jt(e,a)||a;i.addColorStop(0,1===s.from?l:"transparent"),i.addColorStop(1,1===s.to?l:"transparent"),e.fillStyle=i,e.globalAlpha=r}else e.fillStyle="string"==typeof t.style.fill&&Jt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(s=t.style.strokeWidth)&&void 0!==s?s:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function Gi(e,t){var o,n;e.save();const i=t.style.stroke||"#999";e.strokeStyle=Jt(e,i)||i,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function qi(e,t){var o,n,i,r;if(!t.pathD)return;e.save();const s=zi(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Jt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,e.fill(s)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.3*(null!==(r=t.style.opacity)&&void 0!==r?r:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(s)),e.restore()}function Xi(e,t){var o,n;if(!t.pathD)return;e.save();const i=zi(t),r=t.style.stroke||"#999";e.strokeStyle=Jt(e,r)||r,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(i),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Jt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(i)),e.restore()}Ei.displayName="NetworkSVGOverlay";const Vi={top:20,right:80,bottom:20,left:80},Ui={top:40,right:40,bottom:40,left:40},Ki=new Set(["chord","force","circlepack","orbit"]),Qi=[800,600],Zi={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 Ji({data:t}){var o,n,i,r,s,a;if("edge"===t.nodeOrEdge){const o=t.data;return o?e.jsxs("div",{className:"semiotic-tooltip",style:Zi,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof o.source?o.source.id:o.source," → ","object"==typeof o.target?o.target.id:o.target]}),null!=o.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof o.value?o.value.toLocaleString():o.value+""]})]}):null}const l=t.data;if(!l)return null;const c=l.__hierarchyNode;if(c){const t=[];let s=c;for(;s;){const e=null!==(r=null!==(n=null===(o=s.data)||void 0===o?void 0:o.name)&&void 0!==n?n:null===(i=s.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=e&&t.unshift(e+""),s=s.parent}t.length>1&&t.shift();const a=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:Zi,children:[e.jsx("div",{children:t.map((t,o)=>e.jsxs("span",{children:[o>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),o===a?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},o))}),null!=l.value&&l.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof l.value?l.value.toLocaleString():l.value+""})]})}const u=((null===(s=l.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:Zi,children:[e.jsx("div",{style:{fontWeight:600},children:l.id}),null!=l.value&&l.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}const er=t.forwardRef(function(o,n){var i,r,s,a,l,u,d,h,g,f,p,y,v,m,b,x,k;const{chartType:w,nodes:j,edges:S,data:O,initialEdges:M,nodeIDAccessor:C="id",sourceAccessor:_="source",targetAccessor:P="target",valueAccessor:L="value",edgeIdAccessor:T,childrenAccessor:R,hierarchySum:B,orientation:I="horizontal",nodeAlign:D="justify",nodePaddingRatio:H=.05,nodeWidth:N=15,iterations:$=300,forceStrength:F=.1,padAngle:E=.01,groupWidth:z=20,sortGroups:Y,edgeSort:G,treeOrientation:q="vertical",edgeType:X="curve",padding:V,paddingTop:U,tensionConfig:K,showParticles:Q=!1,particleStyle:Z,nodeStyle:J,edgeStyle:ee,colorBy:te,colorScheme:oe="category10",edgeColorBy:ne="source",edgeOpacity:ie=.5,colorByDepth:re=!1,nodeSize:se=8,nodeSizeRange:ae=[5,20],nodeLabel:le,showLabels:ce=!0,labelMode:ue,size:de=Qi,responsiveWidth:he,responsiveHeight:ge,margin:fe,className:pe,background:ye,enableHover:ve=!0,tooltipContent:me,customHoverBehavior:be,customClickBehavior:xe,onObservation:ke,chartId:we,onTopologyChange:je,annotations:Ae,svgAnnotationRules:Se,legend:_e,legendPosition:Le,legendHoverBehavior:Re,legendClickBehavior:Be,legendHighlightedCategory:Ie,legendIsolatedCategories:De,title:He,foregroundGraphics:Ne,backgroundGraphics:$e,decay:We,pulse:Fe,transition:Ee,animate:ze,staleness:Ye,thresholds:Ge,accessibleTable:qe=!0,description:Xe,summary:Ve,orbitMode:Ue,orbitSize:Ke,orbitSpeed:Qe,orbitRevolution:Ze,orbitRevolutionStyle:Je,orbitEccentricity:et,orbitShowRings:tt,orbitAnimated:ot}=o,nt=Ki.has(w)?Ui:Vi,it=t.useRef(!0),rt=to({sizeProp:de,responsiveWidth:he,responsiveHeight:ge,userMargin:fe,marginDefault:nt,foregroundGraphics:Ne,backgroundGraphics:$e,animate:ze,transitionProp:Ee,themeDirtyRef:it}),{reducedMotionRef:st,responsiveRef:at,size:lt,margin:ct,adjustedWidth:ut,adjustedHeight:dt,resolvedForeground:ht,resolvedBackground:gt,transition:ft,introEnabled:pt,tableId:yt,rafRef:vt,renderFnRef:mt,scheduleRender:bt,currentTheme:wt}=rt,jt=t.useMemo(()=>Object.assign(Object.assign({},gn),K),[K]),At=t.useMemo(()=>Object.assign(Object.assign({},fn),Z),[Z]),St=t.useMemo(()=>{var e;return{chartType:w,nodeIDAccessor:C,sourceAccessor:_,targetAccessor:P,valueAccessor:L,edgeIdAccessor:T,childrenAccessor:R,hierarchySum:B,orientation:I,nodeAlign:D,nodePaddingRatio:H,nodeWidth:N,iterations:$,forceStrength:F,padAngle:E,groupWidth:z,sortGroups:Y,edgeSort:G,treeOrientation:q,edgeType:X,padding:V,paddingTop:U,tensionConfig:jt,showParticles:Q,particleStyle:At,nodeStyle:J,edgeStyle:ee,nodeLabel:le,showLabels:ce,labelMode:ue,colorBy:te,colorScheme:oe,themeCategorical:null===(e=null==wt?void 0:wt.colors)||void 0===e?void 0:e.categorical,themeSemantic:A(wt),edgeColorBy:ne,edgeOpacity:ie,colorByDepth:re,nodeSize:se,nodeSizeRange:ae,decay:We,pulse:Fe,transition:ft,introAnimation:pt,staleness:Ye,thresholds:Ge,orbitMode:Ue,orbitSize:Ke,orbitSpeed:Qe,orbitRevolution:Ze,orbitRevolutionStyle:Je,orbitEccentricity:et,orbitShowRings:tt,orbitAnimated:ot}},[w,C,_,P,L,R,B,I,D,H,N,$,F,E,z,Y,G,q,X,V,U,jt,Q,At,J,ee,le,ce,ue,te,oe,ne,ie,re,se,ae,We,Fe,null==ft?void 0:ft.duration,null==ft?void 0:ft.easing,pt,Ye,Ge,Ue,Ke,Qe,Ze,Je,et,tt,ot,wt]),Ot=t.useRef(null),Ct=t.useRef(0),_t=t.useRef(null);_t.current||(_t.current=new Ri(St));const[Pt,Lt]=t.useState(null),[Tt,Rt]=t.useState(0),[Bt,It]=t.useState(0),[Dt,Ft]=t.useState(!1),Yt=t.useRef(null),Gt=t.useRef(new Map),qt=t.useRef(0),Xt=t.useCallback(e=>{if("function"==typeof te)return te(e)+"";if("string"==typeof te&&e.data){const t=e.data[te];if(void 0!==t){if(!Gt.current.has(t+"")){const e=Array.isArray(oe)?oe:W;Gt.current.set(t+"",e[qt.current++%e.length])}return Gt.current.get(t+"")}}if(Gt.current.has(e.id))return Gt.current.get(e.id);const t=Array.isArray(oe)?oe:W,o=te?t[qt.current++%t.length]:t[0];return Gt.current.set(e.id,o),o},[te,oe]),Vt=(null===(i=null==wt?void 0:wt.colors)||void 0===i?void 0:i.border)||(null===(r=null==wt?void 0:wt.colors)||void 0===r?void 0:r.secondary)||(null===(s=null==wt?void 0:wt.colors)||void 0===s?void 0:s.primary)||"#999",Ut=t.useCallback(e=>{if("function"==typeof ne)return ne(e);const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;return"target"===ne&&o?Xt(o):t?Xt(t):Vt},[ne,Xt,Vt]),Kt=t.useCallback(e=>{if(!(null==Z?void 0:Z.colorBy))return Ut(e);const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;return"target"===At.colorBy&&o?Xt(o):t?Xt(t):Vt},[null==Z?void 0:Z.colorBy,At.colorBy,Xt,Ut,Vt]),Qt="sankey"===w&&Q||!!Fe||null!==(l=null===(a=_t.current)||void 0===a?void 0:a.isAnimating)&&void 0!==l&&l;t.useEffect(()=>{var e;null===(e=_t.current)||void 0===e||e.updateConfig(St),it.current=!0,bt()},[St,bt]),t.useEffect(()=>{var e;const t=_t.current;if(t){t.buildScene([ut,dt]);for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Gt.current.set(o.id,o.style.fill);it.current=!0,bt()}},[wt,ut,dt,bt]);const Zt=t.useCallback(()=>{var e;const t=_t.current;if(!t)return;t.runLayout([ut,dt]),t.buildScene([ut,dt]),it.current=!0;for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Gt.current.set(o.id,o.style.fill);const o=Array.isArray(oe)?oe:W,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Gt.current.has(t.id)||Gt.current.set(t.id,o[e%o.length])}if(qt.current=n.length,Rt(t.layoutVersion),je){const{nodes:e,edges:o}=t.getLayoutData();je(e,o)}},[ut,dt,je,oe]),eo=t.useCallback(e=>{const t=_t.current;t&&(t.ingestEdge(e)&&Zt(),bt())},[Zt,bt]),io=t.useCallback(e=>{const t=_t.current;if(!t)return;let o=!1;for(const n of e)t.ingestEdge(n)&&(o=!0);o&&Zt(),bt()},[Zt,bt]),ro=t.useCallback(()=>{var e;null===(e=_t.current)||void 0===e||e.clear(),Gt.current.clear(),qt.current=0,Rt(0),Lt(null),Yt.current=null,it.current=!0,bt()},[bt]),so=t.useCallback(()=>{const e=_t.current;e&&(e.tension+=999,Zt(),bt())},[Zt,bt]);t.useImperativeHandle(n,()=>({push:eo,pushMany:io,removeNode:e=>{var t,o,n;const i=null!==(o=null===(t=_t.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==o&&o;if(i){const t=(null===(n=Yt.current)||void 0===n?void 0:n.data)?"function"==typeof C?C(Yt.current.data):Yt.current.data[C]:void 0;Yt.current&&"node"===Yt.current.nodeOrEdge&&t===e&&(Yt.current=null,Lt(null)),Gt.current.delete(e),Zt(),it.current=!0,bt()}return i},removeEdge:(e,t)=>{var o,n;const i=null!==(n=null===(o=_t.current)||void 0===o?void 0:o.removeEdge(e,t))&&void 0!==n&&n;if(i){if(Yt.current&&"edge"===Yt.current.nodeOrEdge){const o=Yt.current.data;let n;n=void 0!==t?("object"==typeof(null==o?void 0:o.source)?o.source.id:null==o?void 0:o.source)===e&&("object"==typeof(null==o?void 0:o.target)?o.target.id:null==o?void 0:o.target)===t:!T||!o||("function"==typeof T?T:e=>null==e?void 0:e[T])(o)===e,n&&(Yt.current=null,Lt(null))}Zt(),it.current=!0,bt()}return i},updateNode:(e,t)=>{var o,n;const i=null!==(n=null===(o=_t.current)||void 0===o?void 0:o.updateNode(e,t))&&void 0!==n?n:null;return i&&(it.current=!0,bt()),i},updateEdge:(e,t,o)=>{var n,i;const r=null!==(i=null===(n=_t.current)||void 0===n?void 0:n.updateEdge(e,t,o))&&void 0!==i?i:[];return r.length>0&&(Zt(),it.current=!0,bt()),r},clear:ro,getTopology:()=>{var e,t;return null!==(t=null===(e=_t.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=_t.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:so,getTension:()=>{var e,t;return null!==(t=null===(e=_t.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[eo,io,ro,so,Zt,bt]);const ao=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),lo=ao?O||(Array.isArray(S)?void 0:S):void 0;t.useEffect(()=>{var e;const t=_t.current;if(t)if(ao&&lo)t.ingestHierarchy(lo,[ut,dt]),t.buildScene([ut,dt]),it.current=!0,bt();else{const o=j||[],n=Array.isArray(S)?S:[];if(0===o.length&&0===n.length)return;t.ingestBounded(o,n,[ut,dt]),t.buildScene([ut,dt]);for(const o of t.sceneNodes)o.id&&(null===(e=o.style)||void 0===e?void 0:e.fill)&&Gt.current.set(o.id,o.style.fill+"");const i=Array.isArray(oe)?oe:W,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Gt.current.has(t.id)||Gt.current.set(t.id,i[e%i.length])}qt.current=r.length,it.current=!0,bt()}},[j,S,O,lo,ao,ut,dt,St,bt,oe]),t.useEffect(()=>{M&&M.length>0&&io(M)},[]);const co=t.useCallback(e=>{if(be&&be(e),ke){const t=Date.now();ke(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[be,ke,we]),go=t.useCallback(e=>{if(xe&&xe(e),ke){const t=Date.now();ke(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:we}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:we})}},[xe,ke,we]),{hoverHandlerRef:fo,hoverLeaveRef:po,onPointerMove:yo,onPointerLeave:vo}=rt;fo.current=e=>{if(!ve)return;const t=Ot.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ct.left,i=e.clientY-o.top-ct.top;if(0>n||n>ut||0>i||i>dt)return void(Yt.current&&(Yt.current=null,Lt(null),co&&(co(null),it.current=!0),bt()));const r=_t.current;if(!r)return;const s=Ii(r.sceneNodes,r.sceneEdges,n,i);if(!s)return void(Yt.current&&(Yt.current=null,Lt(null),co&&(co(null),it.current=!0),bt()));const a=ko(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});Yt.current=a,Lt(a),co&&(co(a),it.current=!0),bt()},po.current=()=>{Yt.current&&(Yt.current=null,Lt(null),co&&(co(null),it.current=!0),bt())};const mo=t.useRef(()=>{});mo.current=e=>{if(!xe&&!ke)return;const t=Ot.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ct.left,i=e.clientY-o.top-ct.top;if(0>n||n>ut||0>i||i>dt)return;const r=_t.current;if(!r)return;const s=Ii(r.sceneNodes,r.sceneEdges,n,i);go(s?ko(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const bo=t.useCallback(e=>mo.current(e),[]),xo=t.useRef(-1),wo=t.useRef(null),jo=t.useRef(-1),Ao=t.useCallback(e=>{var t;const o=_t.current;if(!o)return;const n=function(e){var t,o,n,i,r,s;const a=[];for(const l of e)"circle"===l.type&&null!=l.cx?a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(o=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==o?o:"_default"}):"rect"===l.type&&null!=l.x?a.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(i=null===(n=l.datum)||void 0===n?void 0:n.id)&&void 0!==i?i:"_default"}):"arc"===l.type&&null!=l.cx&&a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(s=null===(r=l.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(o.sceneNodes);if(0===n.length)return;const i=Oe(n),r=xo.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),xo.current=0,jo.current=-1;const t=i.flat[0];wo.current={shape:t.shape,w:t.w,h:t.h};const o=ko(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Yt.current=o,Lt(o),co&&(co(o),it.current=!0),void bt()}const s=Me(i,r),a=function(e,t,o,n,i){var r,s,a;const l=o.flat[t.flatIndex];if(!l)return Ce(e,t,o);const c=null===(r=l.datum)||void 0===r?void 0:r.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(s=function(e,t,o){let n=null,i=1/0;for(let r=0;e.flat.length>r;r++){const s=e.flat[r];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(o){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;i>u&&(i=u,n=r)}return n}(o,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==s?s:t.flatIndex;return n!==t.flatIndex&&(i.current=-1),n}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var o;const n=e+"",i=[];for(const e of t){const t=null!==(o=e.datum)&&void 0!==o?o:e,r=Pe(t.source),s=Pe(t.target),a=null!=r,l=null!=s;a&&r+""===n&&l?i.push(s+""):l&&s+""===n&&a&&i.push(r+"")}return i}(c,n);if(0===e.length)return t.flatIndex;const r=null!==(a=o.idToIdx.get(e[(i.current+1)%e.length]))&&void 0!==a?a:-1;return 0>r?t.flatIndex:(i.current=-1,r)}default:{const n=Ce(e,t,o);return null!==n&&n!==t.flatIndex&&(i.current=-1),n}}}(e.key,s,i,null!==(t=o.sceneEdges)&&void 0!==t?t:[],jo);if(null===a)return;if(e.preventDefault(),0>a)return xo.current=-1,wo.current=null,jo.current=-1,Yt.current=null,Lt(null),co&&(co(null),it.current=!0),void bt();xo.current=a;const l=i.flat[a];wo.current={shape:l.shape,w:l.w,h:l.h};const c=l.datum||{},u=Object.assign(Object.assign({},"object"!=typeof c||null===c||Array.isArray(c)?{}:c),{data:c,x:l.x,y:l.y,time:l.x,value:l.y,nodeOrEdge:"node"});Yt.current=u,Lt(u),co&&(co(u),it.current=!0),bt()},[co,bt]),So=t.useCallback(e=>{xo.current=-1,wo.current=null,yo(e)},[yo]);mt.current=()=>{var e,t,o,n,i,r,s;vt.current=0;const a=Ot.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=_t.current;if(!c)return;const u=performance.now(),d=Ct.current?Math.min((u-Ct.current)/1e3,.1):.016;Ct.current=u;const h=c.advanceTransition(st.current?u+1e6:u),g=!st.current&&h,f=!st.current&&c.tickAnimation([ut,dt],d);(h||it.current||f)&&c.buildScene([ut,dt]);const p=no();if(!oo(a,lt,ct,p))return;l.clearRect(-ct.left,-ct.top,lt[0],lt[1]),ye&&(l.fillStyle=ye,l.fillRect(0,0,ut,dt)),We&&c.applyDecay(),Fe&&c.applyPulse(u),Ge&&c.applyThresholds(u),c.applyTopologyDiff(u);const y=null!==(e=null==Ye?void 0:Ye.threshold)&&void 0!==e?e:5e3,v=Ye&&c.lastIngestTime>0&&u-c.lastIngestTime>y;if(v&&(l.globalAlpha=null!==(t=null==Ye?void 0:Ye.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const o of t)switch(o.type){case"bezier":Yi(e,o);break;case"line":Gi(e,o);break;case"ribbon":qi(e,o);break;case"curved":Xi(e,o)}}(l,c.sceneEdges),function(e,t){var o,n,i;for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Jt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.strokeRect(t.x,t.y,t.w,t.h)),uo(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("circle"!==r.type)continue;const t=r;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Jt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),ho(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("arc"!==r.type)continue;const t=r;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&Jt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Jt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),e.restore()}}(l,c.sceneNodes),Q&&c.particlePool&&!v){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,o,n){var i,r;const s=null!==(i=n.spawnRate)&&void 0!==i?i:fn.spawnRate,a=null!==(r=n.maxPerEdge)&&void 0!==r?r:fn.maxPerEdge;for(let n=0;t.length>n;n++){const i=t[n];if(!i.bezier)continue;if(e.countForEdge(n)>=a)continue;const r=i.value*s*o*(i.bezier.circular?.3:1),l=Math.floor(r),c=r-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<a;t++)e.spawn(n)}}(c.particlePool,e,d,At);const t=.5*(null!==(o=At.speedMultiplier)&&void 0!==o?o:1);let n;if(At.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,n),function(e,t,o,n,i){var r,s;const a=null!==(r=n.radius)&&void 0!==r?r:fn.radius,l=null!==(s=n.opacity)&&void 0!==s?s:fn.opacity;e.globalAlpha=l;for(let r=0;t.particles.length>r;r++){const s=t.particles[r];if(!s.active)continue;const l=o[s.edgeIndex];if(l){if("function"==typeof n.color){const t="object"==typeof l.source?l.source:null;e.fillStyle=t?n.color(l,t):Jt(e,"var(--semiotic-secondary, #666)")}else e.fillStyle=n.color&&"inherit"!==n.color?n.color:i(l);e.beginPath(),e.arc(s.x,s.y,a,0,2*Math.PI),e.fill()}}e.globalAlpha=1}(l,c.particlePool,e,At,Kt)}}v&&(l.globalAlpha=1);const m=it.current;if(it.current=!1,m||g||f){const e=Ot.current;e&&e.setAttribute("aria-label",Mt(null!==(i=null===(n=c.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==i?i:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}(m||g||f)&&It(e=>e+1),(Qt||g||null!=c.transition||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff)&&(vt.current=requestAnimationFrame(()=>mt.current()))},t.useEffect(()=>(bt(),()=>{}),[bt]),t.useEffect(()=>{it.current=!0,bt()},[w,ut,dt,ye,bt]),Te(Ye,_t,it,bt,Dt,Ft);const Oo=ve&&Pt?e.jsx(zt,{x:Pt.x,y:Pt.y,containerWidth:ut,containerHeight:dt,margin:ct,className:"stream-network-tooltip",zIndex:2,children:me?me(Pt):e.jsx(Ji,{data:Pt})}):null;if(kt){const t=_t.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(w),o=e?O||(Array.isArray(S)?void 0:S):void 0;if(e&&o)t.ingestHierarchy(o,[ut,dt]),t.buildScene([ut,dt]);else{const e=j||[],o=Array.isArray(S)?S:[];(e.length>0||o.length>0)&&(t.ingestBounded(e,o,[ut,dt]),t.buildScene([ut,dt]))}}const o=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],n=null!==(d=null==t?void 0:t.sceneEdges)&&void 0!==d?d:[],i=null!==(h=null==t?void 0:t.labels)&&void 0!==h?h:[];return e.jsxs("div",{className:"stream-network-frame"+(pe?" "+pe:""),role:"img","aria-label":Xe||("string"==typeof He?He:"Network chart"),style:{position:"relative",width:lt[0],height:lt[1]},children:[e.jsx(Nt,{summary:Ve}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:lt[0],height:lt[1],style:{position:"absolute",left:0,top:0},children:[gt&&e.jsx("g",{transform:`translate(${ct.left},${ct.top})`,children:gt}),e.jsxs("g",{transform:`translate(${ct.left},${ct.top})`,children:[ye&&e.jsx("rect",{x:0,y:0,width:ut,height:dt,fill:ye}),n.map((t,o)=>function(t,o){switch(t.type){case"line":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+o);case"bezier":{const n=t;return e.jsx("path",{d:n.pathD,fill:xt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"ribbon":{const n=t;return e.jsx("path",{d:n.pathD,fill:xt(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"curved":{const n=t;return e.jsx("path",{d:n.pathD,fill:xt(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+o)}default:return null}}(t,o)).filter(Boolean),o.map((t,o)=>function(t,o){switch(t.type){case"circle":{const n=t;return e.jsx("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:xt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:xt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+o)}case"arc":{const n=t,i=c.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)({})||"";return e.jsx("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:xt(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+o)}default:return null}}(t,o)).filter(Boolean),i.map((t,o)=>function(t,o){return e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+o)}(t,o)).filter(Boolean)]})]}),e.jsx(Ei,{width:ut,height:dt,totalWidth:lt[0],totalHeight:lt[1],margin:ct,labels:i,sceneNodes:o,title:He,legend:_e,legendPosition:Le,legendHoverBehavior:Re,legendClickBehavior:Be,legendHighlightedCategory:Ie,legendIsolatedCategories:De,foregroundGraphics:ht,annotations:Ae,svgAnnotationRules:Se,annotationFrame:0})]})}const Mo=_t.current;return e.jsxs("div",{ref:at,className:"stream-network-frame"+(pe?" "+pe:""),role:"group","aria-label":Xe||("string"==typeof He?He:"Network chart"),tabIndex:0,style:{position:"relative",width:he?"100%":lt[0],height:ge?"100%":lt[1],overflow:"visible"},onKeyDown:Ao,children:[qe&&e.jsx($t,{tableId:yt}),qe&&e.jsx(Ht,{nodes:null!==(g=null==Mo?void 0:Mo.sceneNodes)&&void 0!==g?g:[],edges:null!==(f=null==Mo?void 0:Mo.sceneEdges)&&void 0!==f?f:[],chartType:"Network chart",tableId:yt,chartTitle:"string"==typeof He?He:void 0}),e.jsx(Nt,{summary:Ve}),e.jsxs("div",{role:"img","aria-label":Xe||("string"==typeof He?He:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:ve?So:void 0,onMouseLeave:ve?vo:void 0,onClick:xe||ke?bo:void 0,children:[gt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:lt[0],height:lt[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${ct.left},${ct.top})`,children:gt})}),e.jsx("canvas",{ref:Ot,"aria-label":Mt(null!==(y=null===(p=null==Mo?void 0:Mo.sceneNodes)||void 0===p?void 0:p.length)&&void 0!==y?y:0,null!==(m=null===(v=null==Mo?void 0:Mo.sceneEdges)||void 0===v?void 0:v.length)&&void 0!==m?m:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(Wt,{hoverPoint:Pt}),e.jsx(Ei,{width:ut,height:dt,totalWidth:lt[0],totalHeight:lt[1],margin:ct,labels:(null==Mo?void 0:Mo.labels)||[],sceneNodes:null==Mo?void 0:Mo.sceneNodes,title:He,legend:_e,legendPosition:Le,legendHoverBehavior:Re,legendClickBehavior:Be,legendHighlightedCategory:Ie,legendIsolatedCategories:De,foregroundGraphics:ht,annotations:Ae,svgAnnotationRules:Se,annotationFrame:Bt}),e.jsx(Et,{active:xo.current>=0,hoverPoint:Pt,margin:ct,size:lt,shape:null===(b=wo.current)||void 0===b?void 0:b.shape,width:null===(x=wo.current)||void 0===x?void 0:x.w,height:null===(k=wo.current)||void 0===k?void 0:k.h}),Oo,(null==Ye?void 0:Ye.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Ye.badgePosition?{top:4,left:4}:"bottom-left"===Ye.badgePosition?{bottom:4,left:4}:"bottom-right"===Ye.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Dt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Dt?"STALE":"LIVE"})]})]})});er.displayName="StreamNetworkFrame";const tr={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 or(e,t){return"function"==typeof t?t(e):e[t]}function nr(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function ir(t={}){const{fields:o,title:n,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(n){const e=or(t,n);a=nr(e,i)}if(o&&o.length>0)o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=or(t,n);l.push({label:o,value:nr(s,r)})});else if(!n){const e=["value","y","name","id","label"];for(const o of e)if(void 0!==t[o]){a=nr(t[o],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=nr(t[e[0]],i))}}const c=Object.assign(Object.assign({},tr),r);return e.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((t,o)=>e.jsxs("div",{style:{marginTop:0===o&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},o))]})}}function rr(t){if(!0===t)return ir();if("function"==typeof t){const o=t;return t=>{const n=o(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==n?null:e.jsx("div",{className:"semiotic-tooltip",style:tr,children:n})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?ir(t):ir())}function sr(e){return"string"==typeof e?e:"value"}function ar(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function lr(e,t){if(!t)return ar(e);try{const o=t(e);return null==o?ar(e):o}catch(t){return ar(e)}}function cr(e,t){return"function"==typeof t?t(e):e[t]}function ur(t){const o=t.find(e=>"title"===e.role),n=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=o?lr(cr(i,o.accessor),o.format):null;return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[null!=r&&e.jsx("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((t,o)=>{const n=lr(cr(i,t.accessor),t.format);return e.jsxs("div",{style:o>0?{marginTop:2}:void 0,children:[e.jsxs("span",{style:{opacity:.7},children:[t.label,": "]}),e.jsx("span",{children:n})]},o)})]})}}function dr({categoryAccessor:t,valueAccessor:o,groupAccessor:n,groupLabel:i,pieData:r=!1,valueFormat:s}){return a=>{var l;const c=r?(null===(l=a.data)||void 0===l?void 0:l[0])||a.data||a:a.data||a,u=cr(c,t),d=cr(c,o),h=n?cr(c,n):void 0;return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[e.jsx("div",{style:{fontWeight:"bold"},children:ar(u)}),e.jsx("div",{style:{marginTop:4},children:lr(d,s)}),null!=h&&e.jsxs("div",{style:{marginTop:2,opacity:.8},children:[i||sr(n),": ",ar(h)]})]})}}const hr=t.createContext(null);function gr({colors:o,categories:n,colorScheme:i="category10",children:r}){const s=t.useMemo(()=>{if(o)return o;if(n){const e=Array.isArray(i)?i:$[i]||W,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[o,n,i]);return e.jsx(hr.Provider,{value:s,children:r})}function fr(){return t.useContext(hr)}function pr(e){const t=[];for(const[o,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[o]));else{const[e,i]=n.range;t.push(t=>{const n=t[o];return n>=e&&i>=n})}return e=>t.every(t=>t(e))}function yr(e,t){const o=[];for(const[n,i]of e.clauses)"crossfilter"===e.resolution&&n===t||o.push(pr(i));return 0===o.length?()=>!0:"intersect"===e.resolution?e=>o.every(t=>t(e)):e=>o.some(t=>t(e))}function vr(e,t){let o=e.get(t);return o||(o={name:t,resolution:"union",clauses:new Map},e.set(t,o)),o}gr.displayName="CategoryColorProvider";const[mr,br]=w(e=>({selections:new Map,setClause(t,o){e(e=>{const n=new Map(e.selections),i=vr(n,t),r=new Map(i.clauses);return r.set(o.clientId,o),n.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:n}})},clearClause(t,o){e(e=>{const n=e.selections.get(t);if(!n)return{};const i=new Map(e.selections),r=new Map(n.clauses);return r.delete(o),i.set(t,Object.assign(Object.assign({},n),{clauses:r})),{selections:i}})},setResolution(t,o){e(e=>{const n=new Map(e.selections),i=vr(n,t);return n.set(t,Object.assign(Object.assign({},i),{resolution:o})),{selections:n}})},clearSelection(t){e(e=>{const o=new Map(e.selections),n=o.get(t);return n&&o.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[xr,kr]=w(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const o=e.observations;return o.push(t),o.length>e.maxObservations&&o.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function wr(e){const o=t.useId(),n=e.clientId||o,{name:i}=e,r=br(e=>e.selections.get(i)),s=br(e=>e.setClause),a=br(e=>e.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?yr(r,n):()=>!0,[r,n]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"point",values:new Set(n)};s(i,{clientId:n,type:"point",fields:t})},[n,i,s]),selectInterval:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"interval",range:n};s(i,{clientId:n,type:"interval",fields:t})},[n,i,s]),clear:t.useCallback(()=>{a(i,n)},[a,i,n]),clientId:n}}function jr(e){const o=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:s,clear:a}=wr({name:o});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,a,o]),predicate:i,isActive:r}}function Ar(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Sr(e){const{name:o,xField:n,yField:i}=e,{predicate:r,isActive:s,selectInterval:a,clear:l}=wr({name:o}),c=n&&i?"xyBrush":n?"xBrush":"yBrush",u=t.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Ar(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Ar(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,n,i,a,l]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:l}}function Or(e={}){const{limit:o=50,types:n,chartId:i}=e,r=kr(e=>e.version),s=kr(e=>e.observations),a=kr(e=>e.clearObservations),l=t.useMemo(()=>{let e=s;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return i&&(e=e.filter(e=>e.chartId===i)),e.length>o&&(e=e.slice(e.length-o)),e},[s,n,i,o,r]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:a}}const Mr=t.createContext(!1);function Cr({selections:e}){const o=br(e=>e.setResolution);return t.useEffect(()=>{for(const[t,n]of Object.entries(e))n.resolution&&o(t,n.resolution)},[e,o]),null}function _r({categoryColors:o,interaction:n,selectionName:i,field:r}){const s=Object.entries(o);if(0===s.length)return null;const a=s.map(([e])=>e),l=[{styleFn:e=>({fill:e.color||"#333",stroke:e.color||"#333"}),type:"fill",items:s.map(([e,t])=>({label:e,color:t})),label:""}],c=jr({name:i,fields:[r]}),u=wr({name:i,clientId:"__linked-legend-isolate__"}),[d,h]=t.useState(new Set),[g,f]=t.useState(null),p=t.useRef(u.selectPoints);p.current=u.selectPoints;const y=t.useRef(u.clear);y.current=u.clear,t.useEffect(()=>{"isolate"===n&&(d.size>0?p.current({[r]:Array.from(d)}):y.current())},[n,d,r]);const v=t.useCallback(e=>{"highlight"===n&&(e?(f(e.label),c.onHover({[r]:e.label})):(f(null),c.onHover(null)))},[n,r,c]),m=t.useCallback(e=>{"isolate"===n&&h(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===a.length?new Set:o})},[n,a.length]),[b,[x]]=Gt([0,0],!0,!1),k=t.useMemo(()=>function(e,t){if(!t||0===e.length)return 1;let o=0,n=1;for(const i of e){const e=26+7*i.length;o>0&&o+e>t&&(n++,o=0),o+=e}return n}(s.map(([e])=>e),x),[s,x]);return e.jsx("div",{ref:b,style:{width:"100%",display:"block"},children:e.jsx("svg",{width:"100%",height:Math.max(30,22*k+8),style:{display:"block",overflow:"visible"},children:e.jsx($e,{legendGroups:l,title:!1,orientation:"horizontal",width:x,height:20,customHoverBehavior:"highlight"===n?v:void 0,customClickBehavior:"isolate"===n?m:void 0,highlightedCategory:g,isolatedCategories:d})})})}function Pr({children:t,selections:o,showLegend:n,legendPosition:i="top",legendInteraction:r="none",legendSelectionName:s="legend",legendField:a="category"}){const l=fr(),c=void 0!==n?n:!(!l||0>=Object.keys(l).length);return e.jsx(mr,{children:e.jsxs(xr,{children:[o&&e.jsx(Cr,{selections:o}),e.jsxs(Mr.Provider,{value:c,children:[c&&"top"===i&&l&&e.jsx(_r,{categoryColors:l,interaction:r,selectionName:s,field:a}),t,c&&"bottom"===i&&l&&e.jsx(_r,{categoryColors:l,interaction:r,selectionName:s,field:a})]})]})})}function Lr({data:e,colorBy:t,colorScale:o,getColor:n,strokeColor:i,strokeWidth:r,categories:s}){const a=(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((i,r)=>{const s=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),a=s?n(s,t,o):o?o(i):F[r%F.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",o={fill:t,stroke:t};return void 0!==i&&(o.stroke=i),void 0!==r&&(o.strokeWidth=r),o},type:"fill",items:a,label:""}]}}function Tr(e){return e?"string"==typeof e?{name:e}:e:null}function Rr(e,t,o){return t?n=>{var i;const r=Object.assign({},e(n));if(t.isActive)if(t.predicate(n))(null==o?void 0:o.selectedStyle)&&Object.assign(r,o.selectedStyle);else{const e=null!==(i=null==o?void 0:o.unselectedOpacity)&&void 0!==i?i:.5;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==o?void 0:o.unselectedStyle)&&Object.assign(r,o.unselectedStyle)}return r}:e}const Br={light:M,dark:C,"high-contrast":_,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 Ir(e){return Br[e]}const Dr=y.createContext(void 0);function Hr({theme:e}){const t=L(e=>e.setTheme),o=L(e=>e.theme),n=y.useRef(o);n.current=o;const i=y.useRef(null);return y.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(forced-colors: active)");return o.matches&&(i.current=n.current,t(_)),Yt(o,e=>{var o;e.matches?(i.current=n.current,t(_)):(t(null!==(o=i.current)&&void 0!==o?o:M),i.current=null)})},[e,t]),y.useEffect(()=>{if(void 0!==e)if("string"==typeof e){const o=Ir(e);t(o||e)}else t(e)},[e,t]),null}function Nr({children:t}){var o,n,i,r,s;const a=L(e=>e.theme),l=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({position:"relative","--semiotic-bg":a.colors.background,"--semiotic-text":a.colors.text,"--semiotic-text-secondary":a.colors.textSecondary,"--semiotic-grid":a.colors.grid,"--semiotic-border":a.colors.border,"--semiotic-primary":a.colors.primary,"--semiotic-font-family":a.typography.fontFamily},a.colors.focus?{"--semiotic-focus":a.colors.focus}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(n=a.tooltip)||void 0===n?void 0:n.text)?{"--semiotic-tooltip-text":a.tooltip.text}:{}),(null===(i=a.tooltip)||void 0===i?void 0:i.borderRadius)?{"--semiotic-tooltip-radius":a.tooltip.borderRadius}:{}),(null===(r=a.tooltip)||void 0===r?void 0:r.fontSize)?{"--semiotic-tooltip-font-size":a.tooltip.fontSize}:{}),(null===(s=a.tooltip)||void 0===s?void 0:s.shadow)?{"--semiotic-tooltip-shadow":a.tooltip.shadow}:{}),a.borderRadius?{"--semiotic-border-radius":a.borderRadius}:{}),a.colors.selection?{"--semiotic-selection-color":a.colors.selection}:{}),null!=a.colors.selectionOpacity?{"--semiotic-selection-opacity":a.colors.selectionOpacity+""}:{}),a.colors.diverging?{"--semiotic-diverging":a.colors.diverging}:{}),a.colors.annotation?{"--semiotic-annotation-color":a.colors.annotation}:{}),null!=a.typography.legendSize?{"--semiotic-legend-font-size":a.typography.legendSize+"px"}:{}),null!=a.typography.titleFontSize?{"--semiotic-title-font-size":a.typography.titleFontSize+"px"}:{}),null!=a.typography.tickFontFamily?{"--semiotic-tick-font-family":a.typography.tickFontFamily}:{}),{"--semiotic-secondary":a.colors.secondary||a.colors.primary,"--semiotic-surface":a.colors.surface||a.colors.background}),a.colors.success?{"--semiotic-success":a.colors.success}:{}),a.colors.danger?{"--semiotic-danger":a.colors.danger}:{}),a.colors.warning?{"--semiotic-warning":a.colors.warning}:{}),a.colors.error?{"--semiotic-error":a.colors.error}:{}),a.colors.info?{"--semiotic-info":a.colors.info}:{}),c=y.useContext(Dr),u={};return c&&(u["data-semiotic-theme"]=c),e.jsx("div",Object.assign({style:l},u,{children:t}))}function $r(){return L(e=>e.theme)}const Wr="#007bff";function Fr(){var e;const t=$r(),o=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return o&&o.length>0?o:void 0}function Er(e,t,o,n,i){if(e)return e;let r;if(Array.isArray(o))r=o;else if(t&&t.length>0)r=t;else if("string"==typeof o){const e=$[o];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=n?(i.has(n)||i.set(n,i.size),r[i.get(n)%r.length]):r[0]:Wr}function zr(e,o,n){const i=fr(),r=Fr();return t.useMemo(()=>{var t;if(!o)return;const s=null!==(t=null!=n?n:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof o){const t=Array.from(new Set(e.map(e=>o(e)+"")));if(i&&Object.keys(i).length>0){const e=G(t.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return G(t.map(e=>({_cat:e})),"_cat",s)}if(i&&Object.keys(i).length>0){const t=G(e,o,s);return e=>i[e]||t(e)}return G(e,o,s)}if(i&&Object.keys(i).length>0){const e=G([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,o,n,i,r])}function Yr(e,o,n){return t.useMemo(()=>{if(!o||"auto"===o||"function"==typeof o)return e;const t=[...e],i="function"==typeof(r=n)?r:e=>e[r];var r;return t.sort("asc"===o?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,o,n])}function Gr({selection:e,linkedHover:o,fallbackFields:n=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}(o,n),g=wr({name:(null==e?void 0:e.name)||"__unused__"}),f=jr({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),p=kr(e=>e.pushObservation),y=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,m]=t.useState(null),b=u||n[0],x=t.useMemo(()=>{if(!c||null==v||!b)return null;const e=v,t=b;return{isActive:!0,predicate:o=>{var n;return("string"==typeof o[t]?o[t]:(null!==(n=o[t])&&void 0!==n?n:"")+"")===e}}},[c,v,b]),k=t.useCallback(e=>{var t,n;if(o)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,o){const n=it.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===o||(it={positions:new Map(it.positions).set(e,{xValue:t,sourceId:o})},st())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&at(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const o=null==t?void 0:t[b];m(null!=o?o+"":null)}else m(null);if(r||p){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const s=Object.assign(Object.assign({},o),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});r&&r(e),p&&p(e)}}},[o,f,h,d,r,s,a,p,c,b]),w=t.useCallback(e=>{var t,o,n,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const o=null==t?void 0:t[h.xField];null!=o&&Number.isFinite(Number(o))&&function(e,t,o){const n=it.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(it.positions);return t.delete(e),it={positions:t},st(),!1}it={positions:new Map(it.positions).set(e,{xValue:t,sourceId:o,locked:!0})},st()}(h.name||"hover",Number(o),d)}if(e&&l){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),l(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0})}if(r||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:o||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),p&&p(e)}}},[l,r,p,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{lt(e,d),at(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:k,customClickBehavior:w,crosshairSourceId:d}}function qr(e,t){const o="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==o?void 0:o.mode))return{linkedCrosshairName:o.name||"hover",linkedCrosshairSourceId:t}}function Xr({data:e,colorBy:o,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(Mr),u=void 0!==i?i:!c&&!!o,d=t.useMemo(()=>{if(!u||!o)return;const t=Lr({data:e,colorBy:o,colorScale:n,getColor:Y,categories:l});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[u,o,e,n,l]),h=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=Object.assign(Object.assign({},a),e);return d&&("right"===r&&110>t.right?t.right=110:"left"===r&&110>t.left?t.left=110:"top"===r&&50>t.top?t.top=50:"bottom"===r&&80>t.bottom&&(t.bottom=80)),t},[a,s,d,r]);return{legend:d,margin:h,legendPosition:r}}function Vr(e,o,n){const[i,r]=t.useState(null),[s,a]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&r(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&a(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=t.useMemo(()=>{if(!e||"none"===e||!o)return null;const t="string"==typeof o?o:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof o?o(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const n=t?e[t]:"function"==typeof o?o(e):null;return s.has(n)}}:null},[e,o,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const Ur={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 Kr(e,t,o){var n,i,r,s,a,l,c;const u=Ur[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==o?void 0:o.width)?u.width:o.width,height:null!==(i=t.height)&&void 0!==i?i:e&&"primary"!==e||!(null==o?void 0:o.height)?u.height:o.height,showAxes:null!==(r=t.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Qr(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function Qr(e,t,o){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===o?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function Zr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>{const n=e(...t)||{};return Object.assign(Object.assign({},n),o)}:(...e)=>Object.assign({},o)}function Jr({componentName:t,message:o,diagnosticHint:n,width:i,height:r}){return e.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:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:o}),n&&e.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:n})]})})}class es extends y.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var o,n;null===(n=(o=this.props).onError)||void 0===n||n.call(o,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,o=this.state.error;return"function"==typeof t?t(o):void 0!==t?t:e.jsx(Jr,{componentName:"ChartErrorBoundary",message:o.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function ts(e,t){const o=e.length,n=t.length,i=Array(n+1);for(let e=0;n>=e;e++)i[e]=e;for(let r=1;o>=r;r++){let o=i[0];i[0]=r;for(let s=1;n>=s;s++){const n=i[s];i[s]=e[r-1]===t[s-1]?o:1+Math.min(o,i[s],i[s-1]),o=n}}return i[n]}function os(e,t,o=3){let n,i=o+1;for(const o of t){const t=ts(e.toLowerCase(),o.toLowerCase());i>t&&(i=t,n=o)}return i>o?void 0:n}function ns(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function is(e,t){var o;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(o=os(e,t,3))&&void 0!==o?o:null)}function rs({componentName:e,data:t,accessors:o,requiredProps:n}){if(n)for(const[t,o]of Object.entries(n))if(null==o)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(o){const n=ns(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[i,r]of Object.entries(o))if(r&&"string"==typeof r&&!(r in n)){const o=is(r,t),n=o?` Try ${i}="${o}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}function ss({componentName:e,data:t,dataLabel:o="data"}){return null==t?`${e}: No ${o} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${o} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function as({componentName:e,nodes:t,edges:o,nodesRequired:n=!1,edgesRequired:i=!0,accessors:r}){if(null==t&&null==o)return null;if(i&&(!o||!Array.isArray(o)||0===o.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(r&&t&&t.length>0){const o=ns(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[n,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in o)){const o=is(i,t),r=o?` Try ${n}="${o}".`:"";return`${e}: ${n} "${i}" not found in node data. Available fields: ${t.join(", ")}.${r}`}}}return null}const ls={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},cs={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},us={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},ds=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],hs=["vertical","horizontal"],gs={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ds},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ds},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ds},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},CandlestickChart:{required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},highAccessor:{type:["string","function"]},lowAccessor:{type:["string","function"]},openAccessor:{type:["string","function"]},closeAccessor:{type:["string","function"]},candlestickStyle:{type:"object"},mode:{type:"string",enum:["primary","context","sparkline"]},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),cs),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:hs},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:hs},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},ls),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},ls),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ls),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},ls),us),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ls),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ls),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:hs},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},ls),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ls),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ls),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ls),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},ls),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},ls),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},ls),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},ls),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},ls),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},ls),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},ls),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function fs(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const ps=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),ys=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),vs=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),ms=new Set(["LineChart","AreaChart","StackedAreaChart"]),bs=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function xs(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[o,n,i]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],r=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*r(o)+.7152*r(n)+.0722*r(i)}function ks(e,t){const o=xs(e),n=xs(t);return null===o||null===n?null:(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}const ws=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];var js;const As="undefined"!=typeof process&&"production"!==(null===(js=process.env)||void 0===js?void 0:js.NODE_ENV);function Ss({componentName:t,width:o,height:n,chartProps:i,children:r}){return e.jsx(es,{fallback:r=>{let s="";if(As&&i)try{const e=function(e,t){const o=[],n=function(e,t){const o=[],n=gs[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(gs).join(", ")}`]};for(const i of n.required)null==t[i]&&o.push(`"${i}" is required for ${e}.`);for(const[e,i]of Object.entries(t)){if(null==i)continue;const t=n.props[e];if(t){if(!fs(i,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;o.push(`"${e}" should be ${n}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&o.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const i=Object.keys(n.props),r=new Set(i);for(const n of Object.keys(t))if(void 0!==t[n]&&!r.has(n)){const t=os(n,i),r=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${i.join(", ")}.`;o.push(r)}if("array"===n.dataShape){const i=t.data,r={};for(const e of n.dataAccessors){const o=t[e];"string"==typeof o&&(r[e]=o)}const s=rs({componentName:e,data:i,accessors:Object.keys(r).length>0?r:void 0});s&&o.push(s)}else if("object"===n.dataShape){const n=ss({componentName:e,data:t.data});n&&o.push(n)}else if("network"===n.dataShape){const i=as({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});i&&o.push(i)}return{valid:0===o.length,errors:o}}(e,t);for(const e of n.errors)o.push({severity:"error",code:"VALIDATION",message:e,fix:""});return gs[e]?(function(e,t,o){const n=gs[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&o.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&o.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,o),function(e,t,o){const n=t.width,i=t.height;if(void 0===n||"number"==typeof n&&n>0||o.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===i||"number"==typeof i&&i>0||o.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(i)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&o.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,o),function(e,t,o){const n=gs[e];if(!n||"array"!==n.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=Object.keys(r);for(const e of n.dataAccessors){const n=t[e];"string"==typeof n&&(n in r||o.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,o),function(e,t,o){ps.has(e)&&Array.isArray(t.data)&&o.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,o),function(e,t,o){ys.has(e)&&(t.edges||t.data||o.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,o),function(e,t,o){const n=gs[e];if(!n||"array"!==n.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=t.xAccessor;"string"==typeof s&&r[s]instanceof Date&&!t.xFormat&&o.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,o),function(e,t,o){t.linkedHover&&!t.selection&&o.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,o),function(e,t,o){var n;if(!vs.has(e))return;const i=t.rExtent||t.yExtent;i&&Array.isArray(i)&&i.length>=1&&null!=i[0]&&0!==i[0]&&o.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${i[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(n=i[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,o),function(e,t,o){if(!ms.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=t.yAccessor||"y";"string"==typeof i&&n.some(e=>{const t=e[i];return null==t||Number.isNaN(t)})&&o.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${i}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,o),function(e,t,o){var n,i;const r=null!==(n=t.width)&&void 0!==n?n:600,s=null!==(i=t.height)&&void 0!==i?i:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);r>l||o.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||o.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,o),function(e,t,o){var n;const i=gs[e];if(!i||"array"!==i.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(r.length,5);for(const e of s){let t=!0;for(let o=0;a>o;o++){const i=null===(n=r[o])||void 0===n?void 0:n[e.name];if("number"==typeof i&&Number.isFinite(i)){t=!1;break}}t&&o.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,o),function(e,t,o){if(!bs.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&o.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,o),function(e,t,o){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const i=n.bottom;"number"==typeof i&&70>i&&o.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${i}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,o),function(e,t,o){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const i=t.margin;if(!i||"object"!=typeof i)return;const r=i.right;"number"==typeof r&&100>r&&o.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${r}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,o),function(e,t,o){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=n[0];if(i&&"object"==typeof i)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const r=i[n];"string"==typeof r&&o.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" resolves to string values (e.g. "${r}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;const r=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ks(e,i);null!==t&&3>t&&r.push(`${e} (${t.toFixed(1)}:1)`)}r.length>0&&o.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${r.length} color(s) in colorScheme have < 3:1 contrast against background "${i}": ${r.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const i=n.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>i.length)return;const r=[];for(let e=0;i.length-1>e;e++){const t=ks(i[e],i[e+1]);null!==t&&1.5>t&&r.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}r.length>0&&o.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${r.length} adjacent color pair(s) in colorScheme have very similar luminance: ${r.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,o),function(e,t,o){const n="string"==typeof t.title&&t.title.trim().length>0,i="string"==typeof t.description&&t.description.trim().length>0,r="string"==typeof t.summary&&t.summary.trim().length>0;n||i||r||o.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,o),function(e,t,o){const n=[];for(const e of ws)"function"==typeof t[e]&&n.push(e);n.length>0&&o.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,o),{ok:o.every(e=>"warning"===e.severity),diagnoses:o}):{ok:0===o.length,diagnoses:o}}(t,i);e.ok||(s=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.jsx(Jr,{componentName:t,message:r.message,diagnosticHint:s,width:o,height:n})},children:r})}const Os={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"},Ms={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Cs(t,o,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},Os),{width:o,height:n}),children:i||"No data available"}):null}function _s(t,o,n){if(!t)return null;const i=Math.min(5,Math.floor(n/40)),r=Math.max(8,Math.floor(n/(3*i))),s=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(r+s)-s))/2);return e.jsx("div",{style:{width:o,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,n)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ms),{position:"absolute",top:a+n*(r+s),left:Math.floor(.1*o),width:30+(37*n+13)%50+"%",height:r,opacity:.5+n%2*.2})},n))})}function Ps(e,t,o,n){if(!As)return;if(!t||0===t.length)return;if("string"!=typeof n)return;const i=t[0];if(!i||"object"!=typeof i)return;if(n in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${o} "${n}" not found in data. Available keys: ${r}`)}function Ls(e){const o=L(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,n;if(void 0!==e||void 0!==o)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(n=null==e?void 0:e.unselectedOpacity)&&void 0!==n?n:o})},[e,o])}function Ts(e){const{data:o,rawData:n,colorBy:i,colorScheme:r,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:g,chartId:f,showLegend:p,userMargin:y,marginDefaults:v,onClick:m,hoverHighlight:b,loading:x,emptyContent:k,width:w,height:j}=e,A="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:S,hoverSelectionHook:O,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:_}=Gr({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:m,hoverHighlight:b,colorByField:A}),P=qr(c,_),L=zr(o,i,r),T=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of o){const o="function"==typeof i?i(t):t[i];null!=o&&e.add(o+"")}return Array.from(e)},[o,i]),R=Vr(s,i,T),B=t.useMemo(()=>O||(R.legendSelectionHook?R.legendSelectionHook:S),[O,R.legendSelectionHook,S]),I=Ls(l),{legend:D,margin:H,legendPosition:N}=Xr({data:o,colorBy:i,colorScale:L,showLegend:p,legendPosition:a,userMargin:y,defaults:v}),$=t.useMemo(()=>{const e={};return D&&(e.legend=D,e.legendPosition=N),s&&"none"!==s&&(e.legendHoverBehavior=R.onLegendHover,e.legendClickBehavior=R.onLegendClick,e.legendHighlightedCategory=R.highlightedCategory,e.legendIsolatedCategories=R.isolatedCategories),e},[D,N,s,R.onLegendHover,R.onLegendClick,R.highlightedCategory,R.isolatedCategories]),W=_s(x,w,j),F=W?null:Cs(n,w,j,k);return{colorScale:L,allCategories:T,legendState:R,effectiveSelectionHook:B,activeSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,legend:D,margin:H,legendPosition:N,earlyReturn:W||F||null,legendBehaviorProps:$,crosshairProps:P,resolvedSelection:I}}const Rs=t.forwardRef(function(o,n){const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",colorBy:g,colorScheme:f,sizeBy:p,sizeRange:v=[3,15],pointRadius:m=5,pointOpacity:b=.8,tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:j,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,emptyContent:R,legendInteraction:B,legendPosition:I,color:D,stroke:H,strokeWidth:N,opacity:$}=o,W=r.width,F=r.height,E=r.enableHover,z=r.showGrid,G=r.title,X=r.description,V=r.summary,U=r.accessibleTable,K=r.xLabel,Q=r.yLabel,Z=s||[],J=Ts({data:Z,rawData:s,colorBy:g,colorScheme:f,legendInteraction:B,legendPosition:I,selection:S,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!1,onObservation:C,onClick:_,hoverHighlight:P,chartType:"Scatterplot",chartId:L,showLegend:r.showLegend,userMargin:a,marginDefaults:r.marginDefaults,loading:T,emptyContent:R,width:W,height:F}),ee=Tr(M),te=Sr({name:(null==ee?void 0:ee.name)||"__unused_brush__",xField:(null==ee?void 0:ee.xField)||("string"==typeof d?d:void 0),yField:(null==ee?void 0:ee.yField)||("string"==typeof h?h:void 0)}),oe=ee?"xyBrush"===te.brushInteraction.brush?"xy":"xBrush"===te.brushInteraction.brush?"x":"y":void 0,ne=y.useRef(te.brushInteraction);ne.current=te.brushInteraction;const ie=t.useCallback(e=>{const t=ne.current;t.end(e?"xyBrush"===t.brush?[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:"xBrush"===t.brush?e.x:e.y:null)},[]);if(J.earlyReturn)return J.earlyReturn;Ps("Scatterplot",Z,"xAccessor",d),Ps("Scatterplot",Z,"yAccessor",h);const re=t.useMemo(()=>{if(!p||0===Z.length)return;const e=Z.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[Z,p]),se=t.useMemo(()=>e=>{const t={fillOpacity:b};return g?J.colorScale&&(t.fill=Y(e,g,J.colorScale)):t.fill=D||Wr,t.r=p?q(e,p,v,re):m,t},[g,J.colorScale,p,v,re,m,b,D]),ae=t.useMemo(()=>Zr(se,{stroke:H,strokeWidth:N,opacity:$}),[se,H,N,$]),le=t.useMemo(()=>Rr(ae,J.effectiveSelectionHook,J.resolvedSelection),[ae,J.effectiveSelectionHook,J.resolvedSelection]),ce=t.useMemo(()=>ur([{label:K||sr(d),accessor:d,role:"x",format:c},{label:Q||sr(h),accessor:h,role:"y",format:u},...g?[{label:sr(g),accessor:g,role:"color"}]:[],...p?[{label:sr(p),accessor:p,role:"size"}]:[]]),[d,h,K,Q,g,p,c,u]),ue=rs({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(ue)return e.jsx(Jr,{componentName:"Scatterplot",message:ue,width:W,height:F});const de=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:Z}),{xAccessor:d,yAccessor:h,colorAccessor:g||void 0,sizeAccessor:p||void 0,sizeRange:v,pointStyle:le,colorScheme:f,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J.margin,showAxes:r.showAxes,xLabel:K,yLabel:Q,xFormat:c,yFormat:u,enableHover:E,showGrid:z}),J.legendBehaviorProps),G&&{title:G}),X&&{description:X}),V&&{summary:V}),void 0!==U&&{accessibleTable:U}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:rr(x)||ce}),(O||C||_||P)&&{customHoverBehavior:J.customHoverBehavior}),(C||_||O)&&{customClickBehavior:J.customClickBehavior}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),j&&j.length>0&&{annotations:j}),ee&&{brush:{dimension:oe},onBrush:ie}),J.crosshairProps),A);return e.jsx(Ss,{componentName:"Scatterplot",width:W,height:F,children:e.jsx(To,Object.assign({ref:i},de))})});function Bs(e,t){return s.interpolateViridis(1===t?.5:e/(t-1))}Rs.displayName="Scatterplot";const Is=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const s=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",orderAccessor:g,orderLabel:f,pointRadius:p=4,tooltip:y,pointIdAccessor:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,stroke:_,strokeWidth:P,opacity:L}=o,T=s.width,R=s.height,B=s.enableHover,I=s.showGrid,D=s.title,H=s.description,N=s.summary,$=s.accessibleTable,W=s.xLabel,F=s.yLabel,E=a||[],{safeData:z,orderMap:Y}=t.useMemo(()=>{const e="function"==typeof d?d:e=>e[d],t="function"==typeof h?h:e=>e[h];let o=E;if(g&&E.length>0){const e="function"==typeof g?g:e=>e[g];o=[...E].sort((t,o)=>{const n=e(t),i=e(o);return(n instanceof Date?n.getTime():+n)-(i instanceof Date?i.getTime():+i)})}const n=new WeakMap;let i=0;for(const n of o){const o=e(n),r=t(n);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&i++}let r=0;for(const s of o){const o=e(s),a=t(s);null!=o&&null!=a&&isFinite(o)&&isFinite(a)&&n.set(s,{idx:r++,total:i})}return{safeData:o,orderMap:n}},[E,g,d,h]);Ps("ConnectedScatterplot",z,"xAccessor",d),Ps("ConnectedScatterplot",z,"yAccessor",h);const{activeSelectionHook:G,hoverSelectionHook:q,customHoverBehavior:X,customClickBehavior:V,crosshairSourceId:U}=Gr({selection:x,linkedHover:k,fallbackFields:[],onObservation:w,onClick:j,chartType:"ConnectedScatterplot",chartId:S,hoverHighlight:A,colorByField:void 0}),K=Ls(x),Q=qr(k,U),Z=Vr(C,void 0,[]),J=t.useMemo(()=>q||(Z.legendSelectionHook?Z.legendSelectionHook:G),[q,Z.legendSelectionHook,G]),ee=null!==(i=null==K?void 0:K.unselectedOpacity)&&void 0!==i?i:.5,te=t.useMemo(()=>(e,t)=>{var o,n;const i=t.filter(e=>"point"===e.type);if(2>i.length)return;const r=null==J?void 0:J.isActive,s=null==J?void 0:J.predicate,a=100>i.length,l=i.length;e.lineCap="round";for(let t=0;l-1>t;t++){const c=i[t],u=i[t+1],d=Bs(t,l),h=!r||!s||s(null!==(o=c.datum)&&void 0!==o?o:c)||s(null!==(n=u.datum)&&void 0!==n?n:u),g=r?h?1:ee:1;a&&(e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle="white",e.lineWidth=p+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(c.x,c.y),e.lineTo(u.x,u.y),e.strokeStyle=d,e.lineWidth=p,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[p,J,ee]),oe=t.useMemo(()=>[te],[te]),ne=t.useMemo(()=>(t,o,n)=>{var i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return null;const a=s.length,l=100>a,c=[];for(let t=0;a-1>t;t++){const o=s[t],n=s[t+1],u=Bs(t,a),d="number"==typeof(null===(i=o.style)||void 0===i?void 0:i.opacity)?o.style.opacity:1,h="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(d,h);l&&c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:p+2,strokeLinecap:"round",opacity:.5*g},"halo-"+t)),c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:u,strokeWidth:p,strokeLinecap:"round",opacity:g},"seg-"+t))}return e.jsx(e.Fragment,{children:c})},[p]),ie=t.useMemo(()=>[ne],[ne]),re=t.useMemo(()=>e=>{var t,o;const n=Y.get(e),i=null!==(t=null==n?void 0:n.idx)&&void 0!==t?t:0,r=null!==(o=null==n?void 0:n.total)&&void 0!==o?o:1;return{fill:r>0?Bs(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:p,fillOpacity:1}},[p,Y]),se=t.useMemo(()=>Zr(re,{stroke:_,strokeWidth:P,opacity:L}),[re,_,P,L]),ae=t.useMemo(()=>Rr(se,J,K),[se,J,K]),le=Object.assign({top:50,right:40,bottom:60,left:70},"number"==typeof o.margin?{top:o.margin,bottom:o.margin,left:o.margin,right:o.margin}:o.margin),ce=f||("string"==typeof g?g:"Order"),ue=t.useMemo(()=>ur([{label:W||sr(d),accessor:d,role:"x",format:c},{label:F||sr(h),accessor:h,role:"y",format:u},...g?[{label:ce,accessor:g,role:"group"}]:[]]),[d,h,W,F,g,ce,c,u]),de=rs({componentName:"ConnectedScatterplot",data:a,accessors:{xAccessor:d,yAccessor:h}}),he=_s(O,T,R),ge=he?null:Cs(a,T,R,M),fe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=a&&{data:z}),{xAccessor:d,yAccessor:h,pointStyle:ae,size:[T,R],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:le,showAxes:s.showAxes,xLabel:W,yLabel:F,xFormat:c,yFormat:u,enableHover:B,showGrid:I}),D&&{title:D}),H&&{description:H}),N&&{summary:N}),void 0!==$&&{accessibleTable:$}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===y?()=>null:rr(y)||ue}),(k||w||j||A)&&{customHoverBehavior:X}),(w||j||k)&&{customClickBehavior:V}),v&&{pointIdAccessor:v}),{canvasPreRenderers:oe,svgPreRenderers:ie}),m&&m.length>0&&{annotations:m}),Q),b);return he||ge||(de?e.jsx(Jr,{componentName:"ConnectedScatterplot",message:de,width:T,height:R}):e.jsx(Ss,{componentName:"ConnectedScatterplot",width:T,height:R,children:e.jsx(To,Object.assign({ref:r},fe))}))});function Ds(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){e.done?i(e.value):function(e){return e instanceof o?e:new o(function(t){t(e)})}(e.value).then(s,a)}l((n=n.apply(e,t||[])).next())})}Is.displayName="ConnectedScatterplot","function"==typeof SuppressedError&&SuppressedError;const Hs="__forecastSegment";let Ns=null;function $s(){return Ds(this,void 0,void 0,function*(){return Ns||(Ns=yield Promise.resolve().then(function(){return Pl})),Ns})}const Ws=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=s.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const a=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,xAccessor:g="x",yAccessor:f="y",lineBy:p,lineDataAccessor:y="coordinates",colorBy:v,colorScheme:m,curve:b="linear",showPoints:x=!1,pointRadius:k=3,fillArea:w=!1,areaOpacity:j=.3,lineWidth:A=2,lineGradient:S,tooltip:O,pointIdAccessor:M,annotations:C,directLabel:_,gapStrategy:P="break",anomaly:L,forecast:T,frameProps:R={},selection:B,linkedHover:I,onObservation:D,onClick:H,hoverHighlight:N,hoverRadius:$,chartId:W,loading:F,emptyContent:E,legendInteraction:z,legendPosition:G,xScaleType:q,yScaleType:X,color:V,stroke:U,strokeWidth:K,opacity:Q}=o,Z=a.width,J=a.height,ee=a.enableHover,te=a.showGrid,oe=a.showLegend,ne=a.title,ie=a.description,re=a.summary,se=a.accessibleTable,ae=a.xLabel,le=a.yLabel,ce=_s(F,Z,J),ue=ce?null:Cs(l,Z,J,E),de=l||[];Ps("LineChart",de,"xAccessor",g),Ps("LineChart",de,"yAccessor",f);const he="string"==typeof g?g:"__semiotic_resolvedX",ge="string"==typeof f?f:"__semiotic_resolvedY",[fe,pe]=t.useState(null),[ye,ve]=t.useState([]),me=t.useMemo(()=>{if(!T&&!L)return de;const e="function"==typeof g,t="function"==typeof f;return e||t?de.map(o=>{const n=Object.assign({},o);return e&&(n.__semiotic_resolvedX=g(o)),t&&(n.__semiotic_resolvedY=f(o)),n}):de},[de,T,L,g,f]),be=t.useRef(T),xe=t.useRef(L);t.useEffect(()=>{if(!T&&!L)return void((be.current||xe.current)&&(pe(null),ve([]),be.current=T,xe.current=L));let e=!1;const t=T!==be.current||L!==xe.current;if(be.current=T,xe.current=L,t&&(pe(null),ve([])),T){const t=p&&"string"==typeof p&&"object"==typeof T?Object.assign(Object.assign({},T),{_groupBy:p}):T;(function(...e){return Ds(this,void 0,void 0,function*(){return(yield $s()).buildForecast(...e)})})(me,he,ge,t,L).then(t=>{e||(pe(t),ve(t.annotations))}).catch(()=>{e||(pe(null),ve([]))})}else L&&function(...e){return Ds(this,void 0,void 0,function*(){return(yield $s()).buildAnomalyAnnotations(...e)})}(L).then(t=>{e||(pe(null),ve(t))}).catch(()=>{e||ve([])});return()=>{e=!0}},[me,T,L,he,ge]);const ke=fe?fe.processedData:de,we="__compoundGroup",je=!(!T||!p),Ae=je?we:T?Hs:p,Se=t.useMemo(()=>{if(!je)return ke;const e="function"==typeof p?p:e=>e[p];return ke.map(t=>{const o=Object.assign({},t);return o[we]=`${e(t)}__${t[Hs]||"observed"}`,o})},[ke,je,p]),Oe=je?Se:ke,Me=t.useMemo(()=>{if(!T)return;const e=T.upperBounds,t=T.lowerBounds;if(!e&&!t)return;const o="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,n="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let i=1/0,r=-1/0;const s=fe?fe.processedData:de;for(const e of s){const t="function"==typeof f?f(e):+e[f];if(isFinite(t)&&(i>t&&(i=t),t>r&&(r=t)),o){const t=o(e);null!=t&&isFinite(t)&&(t>r&&(r=t),i>t&&(i=t))}if(n){const t=n(e);null!=t&&isFinite(t)&&(i>t&&(i=t),t>r&&(r=t))}}return isFinite(i)&&isFinite(r)?[i,r]:void 0},[T,fe,de,f]),{activeSelectionHook:Ce,hoverSelectionHook:_e,customHoverBehavior:Pe,customClickBehavior:Le,crosshairSourceId:Te}=Gr({selection:B,linkedHover:I,fallbackFields:v?["string"==typeof v?v:""]:[],onObservation:D,onClick:H,chartType:"LineChart",chartId:W,hoverHighlight:N,colorByField:"string"==typeof v?v:void 0}),Re=Ls(B),Be=qr(I,Te),Ie=t.useCallback(e=>{const t="function"==typeof g?g(e):e[g],o="function"==typeof f?f(e):e[f];return null==t||null==o||Number.isNaN(t)||Number.isNaN(o)},[g,f]),De=void 0!==(null===(i=Oe[0])||void 0===i?void 0:i[y]),He=t.useMemo(()=>{if(De)return Oe;if(Ae){const e=Oe.reduce((e,t)=>{const o="function"==typeof Ae?Ae(t):t[Ae];if(!e[o]){const n={[y]:[]};"string"==typeof Ae&&(n[Ae]=o),je&&(n[Hs]=t[Hs],"string"==typeof p&&(n[p]=t[p])),e[o]=n}return e[o][y].push(t),e},{});return Object.values(e)}return[{[y]:Oe}]},[Oe,Ae,y,De]),{gapProcessedLineData:Ne,hasGaps:$e}=t.useMemo(()=>{if("interpolate"===P){let e=!1;const t=[];for(const o of He){const n=(o[y]||[]).filter(t=>!Ie(t)||(e=!0,!1));n.length>0&&t.push(Object.assign(Object.assign({},o),{[y]:n}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===P){let e=!1;const t=[];for(const o of He){const n=o[y]||[];let i=[],r=0;const s=Ae&&"string"==typeof Ae?o[Ae]:void 0;for(const a of n)if(Ie(a))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},o),{[y]:i})),i=[],r++);else{const e=null!=s?`${s}__seg${r}`:"__seg"+r;i.push(Object.assign(Object.assign({},a),{_gapSegment:e}))}i.length>0&&t.push(Object.assign(Object.assign({},o),{[y]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===P){let e=!1;const t="string"==typeof f?f:"y",o=[];for(const n of He){const i=n[y]||[],r=[];for(const o of i)Ie(o)?(e=!0,r.push(Object.assign(Object.assign({},o),{[t]:0}))):r.push(o);o.push(Object.assign(Object.assign({},n),{[y]:r}))}return{gapProcessedLineData:o,hasGaps:e}}return{gapProcessedLineData:He,hasGaps:!1}},[He,P,y,Ie,Ae,f]),We=zr(ke,v,m),Fe=t.useMemo(()=>{if(!v)return[];const e=new Set;for(const t of ke){const o="function"==typeof v?v(t):t[v];null!=o&&e.add(o+"")}return Array.from(e)},[ke,v]),Ee=Vr(z,v,Fe),ze=t.useMemo(()=>_e||(Ee.legendSelectionHook?Ee.legendSelectionHook:Ce),[_e,Ee.legendSelectionHook,Ce]),Ye=t.useMemo(()=>(e,t)=>{const o={strokeWidth:A},n=!0===w||Array.isArray(w)&&null!=t&&w.includes(t);return v?We&&(o.stroke=Y(e,v,We),n&&(o.fill=o.stroke,o.fillOpacity=j)):(o.stroke=V||Wr,n&&(o.fill=V||Wr,o.fillOpacity=j)),o},[v,We,A,w,j,V]),[Ge,qe]=t.useState(null);t.useEffect(()=>{if(!T)return void qe(null);let e=!1;return function(...e){return Ds(this,void 0,void 0,function*(){return(yield $s()).createSegmentLineStyle(...e)})}(Ye,T).then(t=>{e||qe(()=>t)}).catch(()=>{e||qe(null)}),()=>{e=!0}},[Ye,T]);const Xe=Ge||Ye,Ve=t.useMemo(()=>Zr(Xe,{stroke:U,strokeWidth:K,opacity:Q}),[Xe,U,K,Q]),Ue=t.useMemo(()=>Rr(Ve,ze,Re),[Ve,ze,Re]),Ke=t.useMemo(()=>{if(x)return e=>{const t={r:k,fillOpacity:1};return v?We&&(t.fill=Y(e.parentLine||e,v,We)):t.fill=V||Wr,t}},[x,k,v,We,V]),Qe=Array.isArray(w)?"mixed":w?"area":"line",Ze="object"==typeof _?_:{},Je=Ze.position||"end",et=Ze.fontSize||11,tt=t.useMemo(()=>{var e,t;if(!_||!v)return[];const o="function"==typeof g?g:e=>e[g],n="function"==typeof f?f:e=>e[f],i="function"==typeof v?v:e=>e[v],r=new Map;for(const o of Ne){const n=o[y]||[];if(0===n.length)continue;const s="end"===Je?n[n.length-1]:n[0],a=null!==(t=null!==(e=i(s))&&void 0!==e?e:i(o))&&void 0!==t?t:"";a&&!r.has(a+"")&&r.set(a+"",s)}const s=Array.from(r.entries()).map(([e,t])=>({type:"text",label:e,["string"==typeof g?g:"x"]:o(t),["string"==typeof f?f:"y"]:n(t),dx:"end"===Je?6:-6,dy:0,color:We?We(e):Wr,fontSize:et}));s.sort((e,t)=>{const o="string"==typeof f?f:"y";return e[o]-t[o]});for(let e=1;s.length>e;e++){const t="string"==typeof f?f:"y",o=s[e-1],n=s[e];et+2>Math.abs(n[t]+n.dy-(o[t]+o.dy))&&(n.dy+=et+2)}return s},[_,v,We,Ne,y,g,f,Je,et]),ot=(!_||void 0!==oe)&&oe,nt=t.useMemo(()=>{if(!_)return a.marginDefaults;const e=tt.reduce((e,t)=>{var o;const n=((null===(o=t.label)||void 0===o?void 0:o.length)||0)*(.6*et);return Math.max(e,n)},0),t=e+10,o="end"===Je?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[o]:Math.max(a.marginDefaults[o]||0,t)})},[_,tt,et,Je,a.marginDefaults]),{legend:it,margin:rt,legendPosition:st}=Xr({data:Ne,colorBy:v,colorScale:We,showLegend:ot,legendPosition:G,userMargin:c,defaults:nt}),at=p||v,lt=t.useMemo(()=>ur([{label:ae||sr(g),accessor:g,role:"x",format:d},{label:le||sr(f),accessor:f,role:"y",format:h},...at?[{label:sr(at),accessor:at,role:"group"}]:[]]),[g,f,ae,le,at,d,h]),ct=rs({componentName:"LineChart",data:De?(null===(r=ke[0])||void 0===r?void 0:r[y])||[]:l,accessors:{xAccessor:g,yAccessor:f}}),ut=t.useMemo(()=>De||Ae||$e?Ne.flatMap(e=>{const t=e[y]||[];return Ae&&"string"==typeof Ae?t.map(t=>Object.assign(Object.assign({},t),{[Ae]:e[Ae]})):t}):Oe,[Ne,y,De,Ae,Oe,$e]),dt=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(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:Qe},Array.isArray(w)&&{areaGroups:w}),S&&{lineGradient:S}),null!=$&&{hoverRadius:$}),null!=l&&{data:ut}),{xAccessor:g,yAccessor:f,xScaleType:q,yScaleType:X}),Me&&{yExtent:Me}),{groupAccessor:"break"===P&&$e?"_gapSegment":Ae||void 0,curve:b,lineStyle:Ue}),x&&{pointStyle:Ke}),{size:[Z,J],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:rt,showAxes:a.showAxes,xLabel:ae,yLabel:le,xFormat:d,yFormat:h,enableHover:ee,showGrid:te}),it&&{legend:it,legendPosition:st}),z&&"none"!==z&&{legendHoverBehavior:Ee.onLegendHover,legendClickBehavior:Ee.onLegendClick,legendHighlightedCategory:Ee.highlightedCategory,legendIsolatedCategories:Ee.isolatedCategories}),ne&&{title:ne}),ie&&{description:ie}),re&&{summary:re}),void 0!==se&&{accessibleTable:se}),u&&{className:u}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===O?()=>null:"multi"===O?t=>{var o,n,i,r,s,a,l,c,u,d;const h=t.allSeries;if(!h||0===h.length){const a=null!==(s=null!==(r=null!==(n=null===(o=t.data)||void 0===o?void 0:o.value)&&void 0!==n?n:null===(i=t.data)||void 0===i?void 0:i.y)&&void 0!==r?r:t.value)&&void 0!==s?s:t.y;return e.jsx("div",{className:"semiotic-tooltip",style:tr,children:e.jsx("div",{children:nr(a)})})}const g=null!==(d=null!==(c=null!==(a=t.xValue)&&void 0!==a?a:null===(l=t.data)||void 0===l?void 0:l.time)&&void 0!==c?c:null===(u=t.data)||void 0===u?void 0:u.x)&&void 0!==d?d:t.time;return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[null!=g&&e.jsx("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:nr(g)}),h.map((t,o)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:t.color,flexShrink:0}}),e.jsx("span",{style:{flex:1,fontSize:"0.85em"},children:t.group}),e.jsx("span",{style:{fontWeight:500,fontSize:"0.85em"},children:nr(t.value)})]},o))]})}:rr(O)||lt}),"multi"===O&&{tooltipMode:"multi"}),(I||D||H||N)&&{customHoverBehavior:Pe}),(D||H||I)&&{customClickBehavior:Le}),M&&{pointIdAccessor:M}),((null==C?void 0:C.length)||ye.length||tt.length)&&{annotations:[...C||[],...ye,...tt]}),Be),R);return ce||ue||(ct?e.jsx(Jr,{componentName:"LineChart",message:ct,width:Z,height:J}):e.jsx(Ss,{componentName:"LineChart",width:Z,height:J,children:e.jsx(To,Object.assign({ref:s},dt))}))});Ws.displayName="LineChart";const Fs=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const s=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",areaBy:f,y0Accessor:p,gradientFill:y=!1,lineDataAccessor:v="coordinates",colorBy:m,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:j=!0,lineWidth:A=2,showPoints:S=!1,pointRadius:O=3,tooltip:M,annotations:C,frameProps:_={},selection:P,linkedHover:L,onObservation:T,onClick:R,hoverHighlight:B,chartId:I,loading:D,emptyContent:H,legendInteraction:N,legendPosition:$,color:W,stroke:F,strokeWidth:E,opacity:z}=o,G=s.width,q=s.height,X=s.enableHover,V=s.showGrid,U=s.showLegend,K=s.title,Q=s.description,Z=s.summary,J=s.accessibleTable,ee=s.xLabel,te=s.yLabel,oe=_s(D,G,q),ne=oe?null:Cs(a,G,q,H),ie=a||[];Ps("AreaChart",ie,"xAccessor",h),Ps("AreaChart",ie,"yAccessor",g);const{activeSelectionHook:re,hoverSelectionHook:se,customHoverBehavior:ae,customClickBehavior:le,crosshairSourceId:ce}=Gr({selection:P,linkedHover:L,fallbackFields:m?["string"==typeof m?m:""]:[],onObservation:T,onClick:R,chartType:"AreaChart",chartId:I,hoverHighlight:B,colorByField:"string"==typeof m?m:void 0}),ue=Ls(P),de=qr(L,ce),he=void 0!==(null===(i=ie[0])||void 0===i?void 0:i[v]),ge=t.useMemo(()=>{if(he)return ie;if(f){const e=ie.reduce((e,t)=>{const o="function"==typeof f?f(t):t[f];if(!e[o]){const t={[v]:[]};"string"==typeof f&&(t[f]=o),e[o]=t}return e[o][v].push(t),e},{});return Object.values(e)}return[{[v]:ie}]},[ie,f,v,he]),fe=zr(ie,m,b),pe=t.useMemo(()=>{if(!m)return[];const e=new Set;for(const t of ie){const o="function"==typeof m?m(t):t[m];null!=o&&e.add(o+"")}return Array.from(e)},[ie,m]),ye=Vr(N,m,pe),ve=t.useMemo(()=>se||(ye.legendSelectionHook?ye.legendSelectionHook:re),[se,ye.legendSelectionHook,re]),me=t.useMemo(()=>e=>{const t={};if(m){if(fe){const o=Y(e,m,fe);t.fill=o,j?(t.stroke=o,t.strokeWidth=A):t.stroke="none"}}else{const e=W||Wr;t.fill=e,j?(t.stroke=e,t.strokeWidth=A):t.stroke="none"}return t.fillOpacity=k,t},[m,fe,W,k,j,A]),be=t.useMemo(()=>Zr(me,{stroke:F,strokeWidth:E,opacity:z}),[me,F,E,z]),xe=t.useMemo(()=>Rr(be,ve,ue),[be,ve,ue]),ke=t.useMemo(()=>{if(S)return e=>{const t={r:O,fillOpacity:1};return m?fe&&(t.fill=Y(e.parentLine||e,m,fe)):t.fill=Wr,t}},[S,O,m,fe]),{legend:we,margin:je,legendPosition:Ae}=Xr({data:ge,colorBy:m,colorScale:fe,showLegend:U,legendPosition:$,userMargin:l,defaults:s.marginDefaults}),Se=f||m,Oe=t.useMemo(()=>ur([{label:ee||sr(h),accessor:h,role:"x",format:u},{label:te||sr(g),accessor:g,role:"y",format:d},...Se?[{label:sr(Se),accessor:Se,role:"group"}]:[]]),[h,g,ee,te,Se,u,d]),Me=rs({componentName:"AreaChart",data:a,accessors:{xAccessor:h,yAccessor:g}}),Ce=t.useMemo(()=>he||f?ge.flatMap(e=>{const t=e[v]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):ie,[ge,v,he,f,ie]),_e=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"area"},null!=a&&{data:Ce}),{xAccessor:h,yAccessor:g,groupAccessor:f||void 0}),p&&{y0Accessor:p}),y&&{gradientFill:y}),w&&{lineGradient:w}),{curve:x,lineStyle:xe}),S&&ke&&{pointStyle:ke}),{size:[G,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:je,showAxes:s.showAxes,xLabel:ee,yLabel:te,xFormat:u,yFormat:d,enableHover:X}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:V}),we&&{legend:we,legendPosition:Ae}),N&&"none"!==N&&{legendHoverBehavior:ye.onLegendHover,legendClickBehavior:ye.onLegendClick,legendHighlightedCategory:ye.highlightedCategory,legendIsolatedCategories:ye.isolatedCategories}),K&&{title:K}),Q&&{description:Q}),Z&&{summary:Z}),void 0!==J&&{accessibleTable:J}),c&&{className:c}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===M?()=>null:rr(M)||Oe}),(L||T||R||B)&&{customHoverBehavior:ae}),(T||R||L)&&{customClickBehavior:le}),C&&C.length>0&&{annotations:C}),de),_);return oe||ne||(Me?e.jsx(Jr,{componentName:"AreaChart",message:Me,width:G,height:q}):e.jsx(Ss,{componentName:"AreaChart",width:G,height:q,children:e.jsx(To,Object.assign({ref:r},_e))}))});function Es({isPushMode:e,colorBy:o,colorScheme:n,showLegend:i,legendPosition:r="right"}){const s=t.useRef(new Set),a=t.useRef([]),[l,c]=t.useState(0),u=t.useCallback(e=>{if(!o)return null;const t="function"==typeof o?o(e):e[o];return null!=t?t+"":null},[o]),d=t.useCallback(t=>{if(!e||!o)return;let n=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=u(e);null==t||s.current.has(t)||(s.current.add(t),a.current.push(t),n=!0)}n&&c(e=>e+1)},[e,o,u]),h=t.useCallback(e=>t=>{d([t]),e(t)},[d]),g=t.useCallback(e=>t=>{d(t),e(t)},[d]),f=t.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]),p=t.useMemo(()=>{if(!e||!o||!1===i)return;const t=a.current;if(0===t.length)return;const r=Array.isArray(n)?n:F,s=new Map;for(let e=0;t.length>e;e++)s.set(t[e],r[e%r.length]);const l="string"==typeof o?o:"__streamCat";return Lr({data:t.map(e=>({[l]:e})),colorBy:l,colorScale:e=>s.get(e)||"#999",getColor:Y})},[e,o,i,n,l]),y=t.useMemo(()=>{if(p)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[p,r]);return{wrapPush:h,wrapPushMany:g,resetCategories:f,streamingLegend:p,streamingMarginAdjust:y}}Fs.displayName="AreaChart";const zs=t.forwardRef(function(o,n){var i;const r=t.useRef(null),s=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:a,margin:l,className:c,xFormat:u,yFormat:d,xAccessor:h="x",yAccessor:g="y",areaBy:f,lineDataAccessor:p="coordinates",colorBy:y,colorScheme:v,curve:m="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:j=3,normalize:A=!1,tooltip:S,annotations:O,frameProps:M={},selection:C,linkedHover:_,onObservation:P,onClick:L,hoverHighlight:T,chartId:R,loading:B,emptyContent:I,legendInteraction:D,legendPosition:H,color:N,stroke:$,strokeWidth:W,opacity:F}=o,E=s.width,z=s.height,G=s.enableHover,q=s.showGrid,X=s.showLegend,V=s.title,U=s.description,K=s.summary,Q=s.accessibleTable,Z=s.xLabel,J=s.yLabel,ee=_s(B,E,z),te=ee?null:Cs(a,E,z,I),oe=a||[],ne=Es({isPushMode:void 0===a,colorBy:y||f,colorScheme:v,showLegend:X,legendPosition:H}),ie=t.useCallback(ne.wrapPush(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)}),[ne.wrapPush]),re=t.useCallback(ne.wrapPushMany(e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)}),[ne.wrapPushMany]);t.useImperativeHandle(n,()=>({push:ie,pushMany:re,remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;ne.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[ie,re,ne.resetCategories]);const{activeSelectionHook:se,hoverSelectionHook:ae,customHoverBehavior:le,customClickBehavior:ce,crosshairSourceId:ue}=Gr({selection:C,linkedHover:_,fallbackFields:y?["string"==typeof y?y:""]:[],onObservation:P,onClick:L,chartType:"StackedAreaChart",chartId:R,hoverHighlight:T,colorByField:"string"==typeof y?y:void 0}),de=Ls(C),he=qr(_,ue),ge=void 0!==(null===(i=oe[0])||void 0===i?void 0:i[p]),fe=t.useMemo(()=>{if(ge)return oe;if(f){const e=oe.reduce((e,t)=>{const o="function"==typeof f?f(t):t[f];if(!e[o]){const t={[p]:[]};"string"==typeof f&&(t[f]=o),e[o]=t}return e[o][p].push(t),e},{});return Object.values(e)}return[{[p]:oe}]},[oe,f,p,ge]),pe=zr(oe,y,v),ye=t.useMemo(()=>{if(!y)return[];const e=new Set;for(const t of oe){const o="function"==typeof y?y(t):t[y];null!=o&&e.add(o+"")}return Array.from(e)},[oe,y]),ve=Vr(D,y,ye),me=t.useMemo(()=>ae||(ve.legendSelectionHook?ve.legendSelectionHook:se),[ae,ve.legendSelectionHook,se]),be=t.useMemo(()=>e=>{const t={};if(y&&pe){const o=Y(e,y,pe);t.fill=o,x?(t.stroke=o,t.strokeWidth=k):t.stroke="none"}else if(!y){const e=N||Wr;t.fill=e,t.stroke=x?e:"none",x&&(t.strokeWidth=k)}return t.fillOpacity=b,t},[y,pe,b,x,k,N]),xe=t.useMemo(()=>Zr(be,{stroke:$,strokeWidth:W,opacity:F}),[be,$,W,F]),ke=t.useMemo(()=>Rr(xe,me,de),[xe,me,de]),we=t.useMemo(()=>{if(w)return e=>{const t={r:j,fillOpacity:1};return y?pe&&(t.fill=Y(e.parentLine||e,y,pe)):t.fill=N||Wr,t}},[w,j,y,pe,N]),{legend:je,margin:Ae,legendPosition:Se}=Xr({data:fe,colorBy:y,colorScale:pe,showLegend:X,legendPosition:H,userMargin:l,defaults:s.marginDefaults}),Oe=ne.streamingLegend||je,Me=H||Se,Ce=t.useMemo(()=>{if(ne.streamingMarginAdjust){const e=Object.assign({},Ae);for(const[t,o]of Object.entries(ne.streamingMarginAdjust))o>e[t]&&(e[t]=o);return e}return Ae},[Ae,ne.streamingMarginAdjust]),_e=f||y,Pe=t.useMemo(()=>ur([{label:Z||sr(h),accessor:h,role:"x",format:u},{label:J||sr(g),accessor:g,role:"y",format:d},..._e?[{label:sr(_e),accessor:_e,role:"group"}]:[]]),[h,g,Z,J,_e,u,d]),Le=rs({componentName:"StackedAreaChart",data:a,accessors:{xAccessor:h,yAccessor:g}}),Te=t.useMemo(()=>ge||f?fe.flatMap(e=>{const t=e[p]||[];return f&&"string"==typeof f?t.map(t=>Object.assign(Object.assign({},t),{[f]:e[f]})):t}):oe,[fe,p,ge,f,oe]),Re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"stackedarea"},null!=a&&{data:Te}),{xAccessor:h,yAccessor:g,groupAccessor:f||void 0,curve:m,normalize:A,lineStyle:ke}),w&&we&&{pointStyle:we}),{size:[E,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Ce,showAxes:s.showAxes,xLabel:Z,yLabel:J,xFormat:u,yFormat:d,enableHover:G}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:q}),Oe&&{legend:Oe,legendPosition:Me}),D&&"none"!==D&&{legendHoverBehavior:ve.onLegendHover,legendClickBehavior:ve.onLegendClick,legendHighlightedCategory:ve.highlightedCategory,legendIsolatedCategories:ve.isolatedCategories}),V&&{title:V}),U&&{description:U}),K&&{summary:K}),void 0!==Q&&{accessibleTable:Q}),c&&{className:c}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===S?()=>null:rr(S)||Pe}),(_||P||L||T)&&{customHoverBehavior:le}),(P||L||_)&&{customClickBehavior:ce}),O&&O.length>0&&{annotations:O}),he),M);return ee||te||(Le?e.jsx(Jr,{componentName:"StackedAreaChart",message:Le,width:E,height:z}):e.jsx(Ss,{componentName:"StackedAreaChart",width:E,height:z,children:e.jsx(To,Object.assign({ref:r},Re))}))});zs.displayName="StackedAreaChart";const Ys=t.forwardRef(function(o,n){var r;const a=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=a.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=a.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=a.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=a.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const l=Kr(o.mode,{width:o.width,height:o.height,showGrid:void 0,enableHover:o.enableHover,showLegend:void 0,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:c,margin:u,className:d,xAccessor:h="x",yAccessor:g="y",valueAccessor:f="value",xFormat:p,yFormat:y,colorScheme:v,customColorScale:m,showValues:b=!1,valueFormat:x,tooltip:k,annotations:w,frameProps:j={},selection:A,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,emptyContent:L,showLegend:T,legendPosition:R,legendInteraction:B}=o,I=l.width,D=l.height,H=l.enableHover,N=l.title,$=l.description,W=l.summary,F=l.accessibleTable,E=l.xLabel,z=l.yLabel,Y=_s(P,I,D),G=Y?null:Cs(c,I,D,L),q=c||[],X=function(){var e;const t=$r();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),V=null!==(r=null!=v?v:X)&&void 0!==r?r:"blues",U=null!=T&&T,K=null!=R?R:"right",{margin:Q}=Xr({data:q,colorBy:U?"value":void 0,colorScale:void 0,showLegend:U,legendPosition:K,userMargin:u,defaults:l.marginDefaults}),{customHoverBehavior:Z,customClickBehavior:J,crosshairSourceId:ee}=Gr({selection:A,linkedHover:S,fallbackFields:[],onObservation:O,onClick:M,chartType:"Heatmap",chartId:_,hoverHighlight:C,colorByField:void 0});Ls(A);const te=qr(S,ee);Vr(B,void 0,[]);const oe=t.useMemo(()=>"function"==typeof f?e=>f(e):e=>e[f],[f]),ne=t.useMemo(()=>{const e=q.map(oe);return[Math.min(...e),Math.max(...e)]},[q,oe]),ie=t.useMemo(()=>"custom"===V&&m?m:i.scaleSequential({blues:s.interpolateBlues,reds:s.interpolateReds,greens:s.interpolateGreens,viridis:s.interpolateViridis,oranges:s.interpolateOranges,purples:s.interpolatePurples,greys:s.interpolateGreys,plasma:s.interpolatePlasma,inferno:s.interpolateInferno,magma:s.interpolateMagma,cividis:s.interpolateCividis,turbo:s.interpolateTurbo}[V]||s.interpolateBlues).domain(ne),[V,m,ne]),re=t.useMemo(()=>ur([{label:E||sr(h),accessor:h,role:"x",format:p},{label:z||sr(g),accessor:g,role:"y",format:y},{label:sr(f),accessor:f,role:"value",format:x}]),[h,g,E,z,f,p,y,x]),se=rs({componentName:"Heatmap",data:c,accessors:{xAccessor:h,yAccessor:g,valueAccessor:f}}),ae=t.useMemo(()=>{if(U)return{gradient:{colorFn:e=>ie(e),domain:ne,label:"string"==typeof f?f:"value",format:x}}},[U,ie,ne,f,x]),le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"heatmap"},null!=c&&{data:q}),{xAccessor:h,yAccessor:g,valueAccessor:f,colorScheme:"custom"!==V?V:void 0,showValues:b,heatmapValueFormat:x,size:[I,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Q,showAxes:l.showAxes,xLabel:E,yLabel:z,xFormat:p,yFormat:y,enableHover:H}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),ae&&{legend:ae,legendPosition:K}),N&&{title:N}),$&&{description:$}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),d&&{className:d}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===k?()=>null:rr(k)||re}),(S||O||M||C)&&{customHoverBehavior:Z}),(O||M||S)&&{customClickBehavior:J}),w&&w.length>0&&{annotations:w}),te),j);return Y||G||(se?e.jsx(Jr,{componentName:"Heatmap",message:se,width:I,height:D}):e.jsx(Ss,{componentName:"Heatmap",width:I,height:D,children:e.jsx(To,Object.assign({ref:a},le))}))});Ys.displayName="Heatmap";const Gs=t.forwardRef(function(o,n){const i=t.useRef(null),r=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:v=.6,bubbleStrokeWidth:m=1,bubbleStrokeColor:b="white",tooltip:x,marginalGraphics:k,pointIdAccessor:w,annotations:j,frameProps:A={},selection:S,linkedHover:O,linkedBrush:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,emptyContent:R,legendInteraction:B,legendPosition:I,color:D,stroke:H,strokeWidth:N,opacity:$}=o,W=r.width,F=r.height,E=r.enableHover,z=r.showGrid,G=r.showLegend,X=r.title,V=r.description,U=r.summary,K=r.accessibleTable,Q=r.xLabel,Z=r.yLabel,J=_s(T,W,F),ee=J?null:Cs(s,W,F,R),te=s||[],oe=void 0===s,ne=t.useRef(null),[ie,re]=t.useState(0),se=t.useCallback(e=>{if(!oe)return;let t=!1;for(const o of e){const e="function"==typeof g?g(o):o[g];null!=e&&isFinite(e)&&(ne.current?(ne.current[0]>e&&(ne.current[0]=e,t=!0),e>ne.current[1]&&(ne.current[1]=e,t=!0)):(ne.current=[e,e],t=!0))}t&&re(e=>e+1)},[oe,g]),ae=Es({isPushMode:oe,colorBy:p,colorScheme:y,showLegend:G,legendPosition:I}),le=t.useCallback(ae.wrapPush(e=>{var t;se([e]),null===(t=i.current)||void 0===t||t.push(e)}),[ae.wrapPush,se]),ce=t.useCallback(ae.wrapPushMany(e=>{var t;se(e),null===(t=i.current)||void 0===t||t.pushMany(e)}),[ae.wrapPushMany,se]);t.useImperativeHandle(n,()=>({push:le,pushMany:ce,remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;ae.resetCategories(),ne.current=null,re(e=>e+1),null===(e=i.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[le,ce,ae.resetCategories]);const{activeSelectionHook:ue,hoverSelectionHook:de,customHoverBehavior:he,customClickBehavior:ge,crosshairSourceId:fe}=Gr({selection:S,linkedHover:O,fallbackFields:p?["string"==typeof p?p:""]:[],onObservation:C,onClick:_,chartType:"BubbleChart",chartId:L,hoverHighlight:P,colorByField:"string"==typeof p?p:void 0}),pe=Ls(S),ye=qr(O,fe),ve=Tr(M);Sr({name:(null==ve?void 0:ve.name)||"__unused_brush__",xField:(null==ve?void 0:ve.xField)||("string"==typeof d?d:void 0),yField:(null==ve?void 0:ve.yField)||("string"==typeof h?h:void 0)});const me=zr(te,p,y),be=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of te){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[te,p]),xe=Vr(B,p,be),ke=t.useMemo(()=>de||(xe.legendSelectionHook?xe.legendSelectionHook:ue),[de,xe.legendSelectionHook,ue]),we=t.useMemo(()=>{if(oe)return ne.current||[0,1];const e=te.map(e=>"function"==typeof g?g(e):e[g]);return[Math.min(...e),Math.max(...e)]},[te,g,oe,ie]),je=t.useMemo(()=>e=>{const t={fillOpacity:v,strokeWidth:m,stroke:b};return p?me&&(t.fill=Y(e,p,me)):t.fill=D||Wr,t.r=q(e,g,f,we),t},[p,me,g,f,we,v,m,b,D]),Ae=t.useMemo(()=>Zr(je,{stroke:H,strokeWidth:N,opacity:$}),[je,H,N,$]),Se=t.useMemo(()=>Rr(Ae,ke,pe),[Ae,ke,pe]),{legend:Oe,margin:Me,legendPosition:Ce}=Xr({data:te,colorBy:p,colorScale:me,showLegend:G,legendPosition:I,userMargin:a,defaults:r.marginDefaults}),_e=ae.streamingLegend||Oe,Pe=I||Ce,Le=t.useMemo(()=>{if(ae.streamingMarginAdjust){const e=Object.assign({},Me);for(const[t,o]of Object.entries(ae.streamingMarginAdjust))o>e[t]&&(e[t]=o);return e}return Me},[Me,ae.streamingMarginAdjust]),Te=t.useMemo(()=>ur([{label:Q||sr(d),accessor:d,role:"x",format:c},{label:Z||sr(h),accessor:h,role:"y",format:u},{label:sr(g),accessor:g,role:"size"},...p?[{label:sr(p),accessor:p,role:"color"}]:[]]),[d,h,Q,Z,g,p,c,u]),Re=rs({componentName:"BubbleChart",data:s,accessors:{xAccessor:d,yAccessor:h},requiredProps:{sizeBy:g}});if(Re)return e.jsx(Jr,{componentName:"BubbleChart",message:Re,width:W,height:F});const Be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bubble"},null!=s&&{data:te}),{xAccessor:d,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:Se,colorScheme:y,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Le,showAxes:r.showAxes,xLabel:Q,yLabel:Z,xFormat:c,yFormat:u,enableHover:E,showGrid:z}),_e&&{legend:_e,legendPosition:Pe}),B&&"none"!==B&&{legendHoverBehavior:xe.onLegendHover,legendClickBehavior:xe.onLegendClick,legendHighlightedCategory:xe.highlightedCategory,legendIsolatedCategories:xe.isolatedCategories}),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:rr(x)||Te}),(O||C||_||P)&&{customHoverBehavior:he}),(C||_||O)&&{customClickBehavior:ge}),k&&{marginalGraphics:k}),w&&{pointIdAccessor:w}),j&&j.length>0&&{annotations:j}),ye),A);return J||ee||e.jsx(Ss,{componentName:"BubbleChart",width:W,height:F,children:e.jsx(To,Object.assign({ref:i},Be))})});Gs.displayName="BubbleChart";const qs="__splomIdx",Xs={top:4,bottom:4,left:4,right:4};function Vs({frameRef:i,cellSize:r,onBrush:s}){const a=t.useRef(null),l=r-Xs.left-Xs.right,c=r-Xs.top-Xs.bottom;return t.useEffect(()=>{if(!a.current)return;const e=o.select(a.current).select(".brush-g"),t=n.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const o=null===(t=i.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void s(null);const[[n,r],[a,l]]=e.selection,c=[[o.x.invert(n),o.y.invert(r)],[o.x.invert(a),o.y.invert(l)]];s(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[l,c,i,s]),e.jsx("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0},children:e.jsx("g",{className:"brush-g",transform:`translate(${Xs.left},${Xs.top})`})})}function Us({data:o,xField:n,yField:i,cellSize:r,pointRadius:s,pointOpacity:a,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:h,mode:g,onPointHover:f}){const p=t.useRef(null),y=wr({name:u,clientId:`splom-${n}-${i}`}),v=Sr({name:u,xField:n,yField:i}),m=wr({name:d,clientId:"splom-hover-source"}),b=m.selectPoints,x=t.useCallback(e=>{e?v.brushInteraction.during(e):v.brushInteraction.end(null)},[v.brushInteraction]),k=t.useCallback(e=>{if(!e)return void(null==f||f(null));const t=e.data,o=null==t?void 0:t[qs];void 0!==o&&(b({[qs]:[o]}),null==f||f(t,e.x+Xs.left,e.y+Xs.top))},[b,f]),w=t.useCallback(e=>{const t={opacity:a,r:s};return t.fill=l?Y(e,l,c):Wr,"hover"===g?m.isActive&&m.predicate(e)?(t.opacity=1,t.r=2.5*s,t.stroke="#333",t.strokeWidth=1.5):m.isActive&&(t.opacity=.6*a):y.isActive&&!y.predicate(e)&&(t.opacity=h),t},[l,c,a,s,g,y.isActive,y.predicate,m.isActive,m.predicate,h]);return e.jsxs("div",{style:{position:"relative",width:r,height:r},children:[e.jsx(To,{ref:p,chartType:"scatter",data:o,size:[r,r],xAccessor:n,yAccessor:i,pointStyle:w,margin:Xs,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&e.jsx(Vs,{frameRef:p,cellSize:r,xField:n,yField:i,onBrush:x})]})}function Ks({data:o,field:n,label:i,cellSize:r,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=wr({name:c,clientId:"splom-diag-"+n}),g=wr({name:u,clientId:`splom-diag-${n}-hover`}),f="hover"===d?g:h,p=f.isActive,y=f.predicate,v=t.useMemo(()=>{const e=o.map(e=>e[n]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const t=Math.min(...e),i=(Math.max(...e)-t)/s||1,l="string"==typeof a?a:null,c=l?[...new Set(o.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(s).fill(0),h=Array(s).fill(0),g=Array.from({length:s},()=>Array(c.length).fill(0)),f=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of o){const o=e[n];if(null==o||isNaN(o))continue;const r=Math.min(Math.floor((o-t)/i),s-1);if(d[r]++,p&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(g[r][t]++,p&&!y(e)||f[r][t]++)}}const v=Math.max(...d,1),m=g.map((e,t)=>{let o=0;return e.map((e,n)=>{const i=e/v*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=i,a})}),b=f.map((e,t)=>{let o=0;return e.map((e,n)=>{const i=e/v*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=i,a})});return{bars:d.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/v*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/v*(r-24),count:e})),categoryBars:m,selectedCategoryBars:b,max:v,categories:c}},[o,n,s,r,p,y,a]);return e.jsxs("svg",{width:r,height:r,style:{overflow:"hidden"},children:[e.jsx("text",{x:r/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:i}),v.categories.length>0?v.categoryBars.map((t,o)=>t.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Wr,opacity:p?.3:.6},`bg-${o}-${n}`))):v.bars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Wr,opacity:p?.3:.6},"bg-"+o)),p&&(v.categories.length>0?v.selectedCategoryBars.map((t,o)=>t.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):Wr,opacity:.7},`sel-${o}-${n}`))):v.selectedBars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Wr,opacity:.7},"sel-"+o)))]})}function Qs({label:t,cellSize:o}){return e.jsx("svg",{width:o,height:o,children:e.jsx("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:t})})}function Zs(o){const{data:n,fields:i,fieldLabels:r={},colorBy:s,colorScheme:a,cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:d=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:p=!0,unselectedOpacity:v=.1,showGrid:m=!1,tooltip:b,showLegend:x,idAccessor:k,className:w,onObservation:j,chartId:A}=o,S="splom",O="splom-hover",M=p?"hover":f?"brush":"hover",C=br(e=>e.clearSelection),[_,P]=t.useState(null),L=t.useCallback(()=>{C(O),P(null)},[C,O]),T=t.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[qs]?e:Object.assign(Object.assign({},e),{[qs]:t})),[n]),R=zr(T,s,a),B=void 0!==x?x:!!s,I=t.useMemo(()=>{if(!B||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(T.map(t=>t[e]))].map(e=>({label:e+"",color:R?R(e+""):Wr})):null},[B,s,T,R]),D=t.useMemo(()=>({display:"grid",gridTemplateColumns:"40px "+i.map(()=>l+"px").join(" "),gridTemplateRows:i.map(()=>l+"px").join(" ")+" 40px",gap:c+"px",width:"fit-content"}),[i,l,c,40]);return e.jsxs("div",{className:w,style:{position:"relative"},children:[I&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:I.map(t=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,borderRadius:"50%",backgroundColor:t.color}}),e.jsx("span",{style:{fontSize:11},children:t.label})]},t.label))}),e.jsxs("div",{style:D,onMouseLeave:"hover"===M?L:void 0,children:[i.map((t,o)=>e.jsxs(y.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",writingMode:"vertical-rl",transform:"rotate(180deg)",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t}),i.map((n,i)=>o===i?"label"===h?e.jsx(Qs,{label:r[t]||t,cellSize:l},"diag-"+t):e.jsx(Ks,{data:T,field:t,label:r[t]||t,cellSize:l,bins:g,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:v,mode:M},"diag-"+t):e.jsx(Us,{data:T,xField:n,yField:t,fieldLabels:r,cellSize:l,pointRadius:u,pointOpacity:d,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:v,showGrid:m,tooltip:b,mode:M,onPointHover:"hover"===M?(e,r,s)=>{e?(P({datum:e,xField:n,yField:t,colIndex:i,rowIndex:o,px:null!=r?r:0,py:null!=s?s:0}),j&&j({type:"hover",datum:e,x:null!=r?r:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A})):(P(null),j&&j({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:A}))}:void 0},`cell-${t}-${n}`))]},"row-"+t)),e.jsx("div",{})," ",i.map(t=>e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t},"col-label-"+t))]}),_&&"hover"===M&&(()=>{const t=_.datum,o=r[_.xField]||_.xField,n=r[_.yField]||_.yField,i=s?"function"==typeof s?s(t):t[s]:null,a=k?"function"==typeof k?k(t):t[k]:"Row "+t[qs];return e.jsxs("div",{style:{position:"absolute",left:40+_.colIndex*(l+c)+_.px,top:_.rowIndex*(l+c)+_.py-8,transform:"translate(-50%, -100%)",color:"#333",background:"rgba(255,255,255,0.95)",border:"1px solid #ddd",borderRadius:3,padding:"4px 8px",fontSize:11,lineHeight:1.4,whiteSpace:"nowrap",pointerEvents:"none",zIndex:10},children:[e.jsx("div",{style:{fontWeight:"bold",marginBottom:2},children:a+""}),e.jsxs("div",{children:[o,": ",null!=t[_.xField]?Number(t[_.xField]).toFixed(1):"–"]}),e.jsxs("div",{children:[n,": ",null!=t[_.yField]?Number(t[_.yField]).toFixed(1):"–"]}),null!=i&&e.jsxs("div",{style:{opacity:.8},children:["string"==typeof s?s:"group",": ",i+""]})]})})()]})}function Js(t){const{brushMode:o="crossfilter",hoverMode:n=!0}=t,i={};return!n&&o&&(i.splom={resolution:o}),n&&(i["splom-hover"]={resolution:"union"}),e.jsx(Pr,{selections:i,children:e.jsx(Zs,Object.assign({},t))})}function ea({width:i,height:r,margin:s,scales:a,brushDirection:l,extent:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(!1),f=i+s.left+s.right,p=r+s.top+s.bottom;return t.useEffect(()=>{if(!d.current||!a)return;const e=o.select(d.current).select(".brush-group"),t="x"===l?n.brushX().extent([[0,0],[i,r]]):n.brushY().extent([[0,0],[i,r]]);return t.on("brush end",e=>{if(g.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void u(null);const o=("x"===l?a.x:a.y).invert;if(!o)return;const n=[o(t[0]),o(t[1])];u(n)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,i,r,l,u]),t.useEffect(()=>{if(!h.current||!a||!d.current)return;const e=o.select(d.current).select(".brush-group"),t="x"===l?a.x:a.y;if(g.current=!0,c){const o=[t(c[0]),t(c[1])];e.call(h.current.move,o)}else e.call(h.current.move,null);g.current=!1},[c,a,l]),e.jsx("svg",{ref:d,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`})})}function ta(o){var n,i;const{data:r,width:s=600,height:a=400,margin:l,className:c,title:u,description:d,summary:h,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:v="x",yAccessor:m="y",lineBy:b,lineDataAccessor:x="coordinates",colorBy:k,colorScheme:w,curve:j="linear",lineWidth:A=2,fillArea:S=!1,areaOpacity:O=.3,showPoints:M=!1,pointRadius:C=3,enableHover:_=!0,showGrid:P=!1,showLegend:L,legendPosition:T,tooltip:R,minimap:B={},renderBefore:I=!1,onBrush:D,brushExtent:H,frameProps:N={},loading:$,emptyContent:W}=o,F=_s($,s,a),E=F?null:Cs(r,s,a,W),z=r||[],[G,q]=t.useState(null),X=null!=H?H:G,V=t.useCallback(e=>{H||q(e),null==D||D(e)},[H,D]),U=t.useRef(null),[K,Q]=t.useState(null);t.useEffect(()=>{let e=0,t=!1;const o=()=>{var n,i;if(t)return;const r=null===(i=null===(n=U.current)||void 0===n?void 0:n.getScales)||void 0===i?void 0:i.call(n);r?Q(r):e=requestAnimationFrame(o)};return e=requestAnimationFrame(o),()=>{t=!0,e&&cancelAnimationFrame(e)}},[r]);const Z=void 0!==(null===(n=z[0])||void 0===n?void 0:n[x]),J=t.useMemo(()=>{if(Z)return z;if(b){const e=z.reduce((e,t)=>{const o="function"==typeof b?b(t):t[b];if(!e[o]){const t={[x]:[]};"string"==typeof b&&(t[b]=o),e[o]=t}return e[o][x].push(t),e},{});return Object.values(e)}return[{[x]:z}]},[z,b,x,Z]),ee=t.useMemo(()=>Z||b?J.flatMap(e=>{const t=e[x]||[];return b&&"string"==typeof b?t.map(t=>Object.assign(Object.assign({},t),{[b]:e[b]})):t}):z,[J,x,Z,b,z]),te=zr(z,k,w),oe=t.useMemo(()=>e=>{const t={strokeWidth:A};return t.stroke=k?Y(e,k,te):Wr,S&&(t.fill=t.stroke,t.fillOpacity=O),t},[k,te,A,S,O]),ne=t.useMemo(()=>B.lineStyle?B.lineStyle:e=>{const t={strokeWidth:1};return t.stroke=k?Y(e,k,te):Wr,t},[k,te,B.lineStyle]),ie=t.useMemo(()=>{if(M)return e=>{const t={r:C,fillOpacity:1};return t.fill=k?Y(e.parentLine||e,k,te):Wr,t}},[M,C,k,te]),{legend:re,margin:se,legendPosition:ae}=Xr({data:J,colorBy:k,colorScale:te,showLegend:L,legendPosition:T,userMargin:l}),le=B.height||60,ce=t.useMemo(()=>{var e,t,o,n,i,r,s,a;return{top:null!==(t=null===(e=B.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(n=null===(o=B.margin)||void 0===o?void 0:o.bottom)&&void 0!==n?n:20,left:null!==(r=null===(i=B.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:se.left,right:null!==(a=null===(s=B.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:se.right}},[B.margin,se]),ue=B.brushDirection||"x",de=rs({componentName:"MinimapChart",data:r,accessors:{xAccessor:v,yAccessor:m}});if(de)return e.jsx(Jr,{componentName:"MinimapChart",message:de,width:s,height:a});const he=S?"area":"line",ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:he,data:ee,xAccessor:v,yAccessor:m,groupAccessor:b||void 0,curve:j,lineStyle:oe},M&&{pointStyle:ie}),{size:[s,a],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:se,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:_,showGrid:P}),re&&{legend:re,legendPosition:ae}),u&&{title:u}),d&&{description:d}),h&&{summary:h}),R&&{tooltipContent:rr(R)||void 0}),X&&{xExtent:X}),N),fe={chartType:he,data:ee,xAccessor:v,yAccessor:m,groupAccessor:b||void 0,curve:j,lineStyle:ne,size:[s,le+ce.top+ce.bottom],margin:ce,showAxes:null!==(i=B.showAxes)&&void 0!==i&&i,background:B.background,enableHover:!1},pe=e.jsxs("div",{style:{position:"relative",width:s,overflow:"hidden"},children:[e.jsx(To,Object.assign({ref:U},fe)),e.jsx(ea,{width:s-ce.left-ce.right,height:le,margin:ce,scales:K,brushDirection:ue,extent:X,onBrush:V})]},"minimap"),ye=e.jsx("div",{style:{overflow:"hidden"},children:e.jsx(To,Object.assign({},ge))},"main");return F||E||e.jsx(Ss,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[I?pe:ye,I?ye:pe]})})}Js.displayName="ScatterplotMatrix",ta.displayName="MinimapChart";const oa=t.forwardRef(function(o,n){const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:v=!0,quadrantLabelSize:m=12,colorBy:b,colorScheme:x,sizeBy:k,sizeRange:w=[3,15],pointRadius:j=5,pointOpacity:A=.8,tooltip:S,pointIdAccessor:O,annotations:M,frameProps:C={},selection:_,linkedHover:P,onObservation:L,onClick:T,hoverHighlight:R,chartId:B,loading:I,emptyContent:D,legendInteraction:H,legendPosition:N,color:$,stroke:W,strokeWidth:F,opacity:E}=o,z=r.width,G=r.height,X=r.enableHover,V=r.showGrid,U=r.showLegend,K=r.title,Q=r.description,Z=r.summary,J=r.accessibleTable,ee=r.xLabel,te=r.yLabel,oe=_s(I,z,G),ne=oe?null:Cs(s,z,G,D),ie=s||[];Ps("QuadrantChart",ie,"xAccessor",d),Ps("QuadrantChart",ie,"yAccessor",h);const{activeSelectionHook:re,hoverSelectionHook:se,customHoverBehavior:ae,customClickBehavior:le,crosshairSourceId:ce}=Gr({selection:_,linkedHover:P,fallbackFields:"string"==typeof b?[b]:[],onObservation:L,onClick:T,chartType:"QuadrantChart",chartId:B,hoverHighlight:R,colorByField:"string"==typeof b?b:void 0}),ue=Ls(_),de=qr(P,ce),he=zr(ie,b,x),ge=t.useMemo(()=>{if(!b)return[];const e=new Set;for(const t of ie){const o="function"==typeof b?b(t):t[b];null!=o&&e.add(o+"")}return Array.from(e)},[ie,b]),fe=Vr(H,b,ge),pe=t.useMemo(()=>se||(fe.legendSelectionHook?fe.legendSelectionHook:re),[se,fe.legendSelectionHook,re]),ye=t.useMemo(()=>{if(!ie.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let o=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of ie){const a=e(s),l=t(s);isFinite(a)&&(o>a&&(o=a),a>n&&(n=a)),isFinite(l)&&(i>l&&(i=l),l>r&&(r=l))}if(null!=g&&isFinite(g)&&(o>g&&(o=g),g>n&&(n=g)),null!=f&&isFinite(f)&&(i>f&&(i=f),f>r&&(r=f)),o===1/0)return;const s=.1*(n-o)||1,a=.1*(r-i)||1;return{xExtent:[o-s,n+s],yExtent:[i-a,r+a]}},[ie,d,h,g,f]),ve=t.useMemo(()=>{if(!k||0===ie.length)return;const e=ie.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[ie,k]),me=t.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),be=t.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),xe=t.useMemo(()=>e=>{const t={fillOpacity:A};if(b)he&&(t.fill=Y(e,b,he));else{const o=me(e),n=be(e),i=null!=g?o>=g:void 0,r=null!=f?n>=f:void 0;t.fill=void 0===r||void 0===i?$||Wr:r&&i?p.topRight.color:r&&!i?p.topLeft.color:!r&&i?p.bottomRight.color:p.bottomLeft.color}return t.r=k?q(e,k,w,ve):j,t},[b,he,k,w,ve,j,A,me,be,g,f,p,$]),ke=t.useMemo(()=>Zr(xe,{stroke:W,strokeWidth:F,opacity:E}),[xe,W,F,E]),we=t.useMemo(()=>Rr(ke,pe,ue),[ke,pe,ue]),{legend:je,margin:Ae,legendPosition:Se}=Xr({data:ie,colorBy:b,colorScale:he,showLegend:U,legendPosition:N,userMargin:a,defaults:r.marginDefaults}),Oe=t.useMemo(()=>{if(!ie.length)return;const e=new Set;"string"==typeof d&&e.add(d),"string"==typeof h&&e.add(h),"string"==typeof b&&e.add(b),"string"==typeof k&&e.add(k);const t=ie[0];for(const o of Object.keys(t))if(!o.startsWith("_")&&!e.has(o)&&"string"==typeof t[o])return o},[ie,d,h,b,k]),Me=t.useMemo(()=>ur([...Oe?[{label:Oe,accessor:Oe,role:"title"}]:[],{label:ee||sr(d),accessor:d,role:"x",format:c},{label:te||sr(h),accessor:h,role:"y",format:u},...b?[{label:sr(b),accessor:b,role:"color"}]:[],...k?[{label:sr(k),accessor:k,role:"size"}]:[]]),[Oe,d,h,ee,te,b,k,c,u]),Ce=rs({componentName:"QuadrantChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),_e=t.useMemo(()=>{var e;const t={stroke:y.stroke||"#999",strokeWidth:null!==(e=y.strokeWidth)&&void 0!==e?e:1,dashArray:y.strokeDasharray||[]};return[(e,o,n,i)=>{var r;if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const s=i.width,a=i.height,l=null!=g?n.x(g):s/2,c=null!=f?n.y(f):a/2;if(null!=g&&!isFinite(l))return;if(null!=f&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:p.topLeft,x:0,y:0,w:u,h:d},{config:p.topRight,x:u,y:0,w:s-u,h:d},{config:p.bottomLeft,x:0,y:d,w:u,h:a-d},{config:p.bottomRight,x:u,y:d,w:s-u,h:a-d}];for(const t of h)t.w>0&&t.h>0&&(e.fillStyle=t.config.color,e.globalAlpha=null!==(r=t.config.opacity)&&void 0!==r?r:.08,e.fillRect(t.x,t.y,t.w,t.h));e.globalAlpha=1,e.strokeStyle=t.stroke,e.lineWidth=t.strokeWidth,t.dashArray.length>0&&e.setLineDash(t.dashArray),e.beginPath(),e.moveTo(u,0),e.lineTo(u,a),e.stroke(),e.beginPath(),e.moveTo(0,d),e.lineTo(s,d),e.stroke(),e.setLineDash([])}]},[g,f,p,y]),Pe=t.useMemo(()=>v?[..._e,(e,t,o,n)=>{if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const i=n.width,r=n.height,s=null!=g?o.x(g):i/2,a=null!=f?o.y(f):r/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${m}px sans-serif`,e.globalAlpha=.5,e.fillStyle=p.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(p.topLeft.label,8,8),e.fillStyle=p.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(p.topRight.label,i-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,r-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:_e,[_e,v,m,p,g,f]),Le=t.useMemo(()=>{const e=C.canvasPreRenderers||[];return[...Pe,...e]},[Pe,C.canvasPreRenderers]),Te=t.useMemo(()=>{var t;const o={stroke:y.stroke||"#999",strokeWidth:null!==(t=y.strokeWidth)&&void 0!==t?t:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(t,n,i)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=i.width,s=i.height,a=null!=g?n.x(g):r/2,l=null!=f?n.y(f):s/2;if(null!=g&&!isFinite(a))return null;if(null!=f&&!isFinite(l))return null;const c=Math.max(0,Math.min(r,a)),u=Math.max(0,Math.min(s,l));return e.jsxs(e.Fragment,{children:[[{config:p.topLeft,x:0,y:0,w:c,h:u},{config:p.topRight,x:c,y:0,w:r-c,h:u},{config:p.bottomLeft,x:0,y:u,w:c,h:s-u},{config:p.bottomRight,x:c,y:u,w:r-c,h:s-u}].map((t,o)=>{var n;return t.w>0&&t.h>0?e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.config.color,opacity:null!==(n=t.config.opacity)&&void 0!==n?n:.08},"qf-"+o):null}),e.jsx("line",{x1:c,y1:0,x2:c,y2:s,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),e.jsx("line",{x1:0,y1:u,x2:r,y2:u,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),v&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:8,y:8+m,fill:p.topLeft.color,fontWeight:600,fontSize:m,opacity:.5,children:p.topLeft.label}),e.jsx("text",{x:r-8,y:8+m,fill:p.topRight.color,fontWeight:600,fontSize:m,opacity:.5,textAnchor:"end",children:p.topRight.label}),e.jsx("text",{x:8,y:s-8,fill:p.bottomLeft.color,fontWeight:600,fontSize:m,opacity:.5,children:p.bottomLeft.label}),e.jsx("text",{x:r-8,y:s-8,fill:p.bottomRight.color,fontWeight:600,fontSize:m,opacity:.5,textAnchor:"end",children:p.bottomRight.label})]})]})}]},[g,f,p,y,v,m]),Re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"scatter"},null!=s&&{data:ie}),{xAccessor:d,yAccessor:h,colorAccessor:b||void 0,sizeAccessor:k||void 0,sizeRange:w,pointStyle:we,colorScheme:x,size:[z,G],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Ae,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),ye&&{xExtent:ye.xExtent,yExtent:ye.yExtent}),je&&{legend:je,legendPosition:Se}),H&&"none"!==H&&{legendHoverBehavior:fe.onLegendHover,legendClickBehavior:fe.onLegendClick,legendHighlightedCategory:fe.highlightedCategory,legendIsolatedCategories:fe.isolatedCategories}),K&&{title:K}),Q&&{description:Q}),Z&&{summary:Z}),void 0!==J&&{accessibleTable:J}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===S?()=>null:!0===S||void 0===S?Me:rr(S)||Me}),(P||L||T||R)&&{customHoverBehavior:ae}),(L||T||P)&&{customClickBehavior:le}),O&&{pointIdAccessor:O}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:Le}),de),C),Le.length>0&&{canvasPreRenderers:Le}),{svgPreRenderers:Te});return oe||ne||(Ce?e.jsx(Jr,{componentName:"QuadrantChart",message:Ce,width:z,height:G}):e.jsx(Ss,{componentName:"QuadrantChart",width:z,height:G,children:e.jsx(To,Object.assign({ref:i},Re))}))});oa.displayName="QuadrantChart";const na="__ma_unitized",ia="__ma_series";function ra(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function sa(e,t){return t[0]+e*(t[1]-t[0])}const aa=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null),a=t.useRef([]);t.useImperativeHandle(n,()=>({push:e=>{if(!s.current)return;const t=e;for(let e=0;o.series.length>e&&2>e;e++){const n=o.series[e],i=n.extent||a.current[e];if(!i)continue;const r=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(t);null!=r&&isFinite(r)&&s.current.push(Object.assign(Object.assign({},t),{[na]:ra(r,i),[ia]:n.label||"Series "+(e+1)}))}},pushMany:e=>{if(!s.current)return;const t=[];for(const n of e)for(let e=0;o.series.length>e&&2>e;e++){const i=o.series[e],r=i.extent||a.current[e];if(!r)continue;const s=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(n);null!=s&&isFinite(s)&&t.push(Object.assign(Object.assign({},n),{[na]:ra(s,r),[ia]:i.label||"Series "+(e+1)}))}s.current.pushMany(t)},remove:e=>{var t,o;return null!==(o=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=s.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const l=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,accessibleTable:o.accessibleTable},{width:800,height:400}),{data:c,margin:u,className:d,xFormat:h,xAccessor:g="x",series:f,colorScheme:p,curve:v="monotoneX",lineWidth:m=2,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:j,onObservation:A,onClick:S,hoverHighlight:O,chartId:M,loading:C,emptyContent:_,legendInteraction:P,legendPosition:L,stroke:T,strokeWidth:R,opacity:B}=o,I=l.width,D=l.height,H=l.enableHover,N=l.showGrid,F=null===(i=l.showLegend)||void 0===i||i,E=l.title,z=l.description,Y=l.summary,G=l.accessibleTable,q=l.xLabel,X=2===f.length;"undefined"==typeof process||"production"===(null===(r=process.env)||void 0===r?void 0:r.NODE_ENV)||X||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${f.length}. Rendering as a standard multi-line chart.`);const V=_s(C,I,D),U=V?null:Cs(c,I,D,_),K=c||[],Q=Fr(),Z=t.useMemo(()=>{let e;if(Array.isArray(p))e=p;else if(Q&&Q.length>0)e=Q;else{const t=$[p];e=Array.isArray(t)?t:W}return f.map((t,o)=>t.color||e[o%e.length])},[f,p,Q]),J=t.useMemo(()=>f.map((e,t)=>e.label||"Series "+(t+1)),[f]),{unitizedData:ee,extents:te}=t.useMemo(()=>{if(0===K.length){const e=f.map(e=>e.extent||null).filter(Boolean);return e.length===f.length&&(a.current=e),{unitizedData:[],extents:e.length===f.length?e:[]}}const e=f.map(e=>e.extent||function(e,t){let o=1/0,n=-1/0;const i="function"==typeof t?t:e=>e[t];for(const t of e){const e=i(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>n&&(n=e))}if(!isFinite(o)||!isFinite(n))return[0,1];if(o===n){const e=0===o?1:.1*Math.abs(o);return[o-e,n+e]}return[o,n]}(K,e.yAccessor));if(a.current=e,!X){const t=[];for(const e of K)for(let o=0;f.length>o;o++){const n=f[o],i=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(e);null!=i&&t.push(Object.assign(Object.assign({},e),{[na]:i,[ia]:J[o]}))}return{unitizedData:t,extents:e}}const t=[];for(const o of K)for(let n=0;2>n;n++){const i=f[n],r=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(o);null!=r&&t.push(Object.assign(Object.assign({},o),{[na]:ra(r,e[n]),[ia]:J[n]}))}return{unitizedData:t,extents:e}},[K,f,X,J]),oe=t.useMemo(()=>{if(X&&te.length>=2)return[{orient:"left",label:J[0],tickFormat:f[0].format||(e=>{const t=sa(e,te[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:J[1],tickFormat:f[1].format||(e=>{const t=sa(e,te[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[X,te,f,J]),ne=Ts({data:t.useMemo(()=>ee.length>0?ee:J.map(e=>({[ia]:e})),[ee,J]),rawData:c,colorBy:ia,colorScheme:Z,legendInteraction:P,legendPosition:L,selection:w,linkedHover:j,fallbackFields:[ia],unwrapData:!1,onObservation:A,onClick:S,hoverHighlight:O,chartType:"MultiAxisLineChart",chartId:M,showLegend:F,userMargin:u,marginDefaults:X?Object.assign(Object.assign({},l.marginDefaults),{left:70,right:70}):l.marginDefaults,loading:C,emptyContent:_,width:I,height:D});if(ne.earlyReturn)return ne.earlyReturn;const ie=t.useMemo(()=>{const e=new Map;return J.forEach((t,o)=>e.set(t,Z[o])),t=>({stroke:e.get(t[ia])||Z[0],strokeWidth:m,fill:"none"})},[J,Z,m]),re=t.useMemo(()=>Zr(ie,{stroke:T,strokeWidth:R,opacity:B}),[ie,T,R,B]),se=t.useMemo(()=>Rr(re,ne.effectiveSelectionHook,ne.resolvedSelection),[re,ne.effectiveSelectionHook,ne.resolvedSelection]),ae=t.useMemo(()=>{if(!1===b)return()=>null;return rr(b)||(e=>{var t;const o=e.data||e,n=o[ia],i=J.indexOf(n),r=o[na],s=X&&i>=0&&te[i]?sa(r,te[i]):r,a=i>=0&&(null===(t=f[i])||void 0===t?void 0:t.format)?f[i].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(o):o[g];return y.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},y.createElement("div",{style:{fontWeight:600,marginBottom:4,color:Z[i]||"inherit"}},n),y.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),y.createElement("div",null,`${n}: ${a(s)}`))})},[b,J,Z,te,X,f,g]),le=rs({componentName:"MultiAxisLineChart",data:c,accessors:{xAccessor:g}}),ce=X?[0,1]:void 0,ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=c&&{data:ee}),{xAccessor:g,yAccessor:na,groupAccessor:ia,lineStyle:se,colorScheme:Z,size:[I,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne.margin,showAxes:l.showAxes}),oe&&{axes:oe}),{xLabel:q}),X?{}:{yLabel:J[0]}),{xFormat:h}),X&&ce&&{yExtent:ce}),{enableHover:H}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:N,curve:v}),ne.legendBehaviorProps),E&&{title:E}),z&&{description:z}),Y&&{summary:Y}),void 0!==G&&{accessibleTable:G}),d&&{className:d}),null!=o.animate&&{animate:o.animate}),{tooltipContent:ae}),x&&{annotations:x}),(j||A||S||O)&&{customHoverBehavior:ne.customHoverBehavior}),(A||S||j)&&{customClickBehavior:ne.customClickBehavior}),ne.crosshairProps),k);return V||U||(le?e.jsx(Jr,{componentName:"MultiAxisLineChart",message:le,width:I,height:D}):e.jsx(Ss,{componentName:"MultiAxisLineChart",width:I,height:D,children:e.jsx(To,Object.assign({ref:s},ue))}))});aa.displayName="MultiAxisLineChart";const la=t.forwardRef(function(o,n){const i=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=i.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=i.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=i.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=i.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const r=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",highAccessor:h="high",lowAccessor:g="low",openAccessor:f,closeAccessor:p,candlestickStyle:y,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,chartId:A,loading:S,emptyContent:O}=o,M=r.width,C=r.height,_=r.enableHover,P=r.showGrid,L=r.title,T=r.description,R=r.summary,B=r.accessibleTable,I=r.xLabel,D=r.yLabel,H=_s(S,M,C),N=H?null:Cs(s,M,C,O),$=s||[],W=null==f||null==p;Ps("CandlestickChart",$,"xAccessor",d),Ps("CandlestickChart",$,"highAccessor",h),Ps("CandlestickChart",$,"lowAccessor",g),W||(Ps("CandlestickChart",$,"openAccessor",f),Ps("CandlestickChart",$,"closeAccessor",p));const{customHoverBehavior:F,customClickBehavior:E,crosshairSourceId:z}=Gr({selection:x,linkedHover:k,onObservation:w,onClick:j,chartType:"CandlestickChart",chartId:A}),Y=qr(k,z),G=t.useMemo(()=>{const e=r.marginDefaults,t="sparkline"===o.mode?Object.assign(Object.assign({},e),{top:0,bottom:0}):e;return null==a?t:"number"==typeof a?{top:a,bottom:a,left:a,right:a}:Object.assign(Object.assign({},t),a)},[a,r.marginDefaults,o.mode]),q=t.useMemo(()=>{const e=[{label:I||sr(d),accessor:d,role:"x",format:c}];return W?(e.push({label:"High",accessor:h,role:"y",format:u}),e.push({label:"Low",accessor:g,format:u})):(e.push({label:"Open",accessor:f,format:u}),e.push({label:"High",accessor:h,format:u}),e.push({label:"Low",accessor:g,format:u}),e.push({label:"Close",accessor:p,format:u})),ur(e)},[d,I,c,u,h,g,f,p,W]),X=rs({componentName:"CandlestickChart",data:s,accessors:Object.assign({xAccessor:d,highAccessor:h,lowAccessor:g},!W&&{openAccessor:f,closeAccessor:p})}),V=Math.max(2,Math.min(12,Math.round(M/40))),U=M>200?.1:.02,K=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"candlestick"},null!=s&&{data:$}),{xAccessor:d,yAccessor:h,highAccessor:h,lowAccessor:g}),!W&&{openAccessor:f,closeAccessor:p}),y&&{candlestickStyle:y}),{scalePadding:V,extentPadding:U,size:[M,C],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:G,showAxes:r.showAxes,xLabel:I,yLabel:D,xFormat:c,yFormat:u,enableHover:_,showGrid:P}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),L&&{title:L}),T&&{description:T}),R&&{summary:R}),void 0!==B&&{accessibleTable:B}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:rr(v)||q}),(k||w||j)&&{customHoverBehavior:F}),(w||j||k)&&{customClickBehavior:E}),m&&m.length>0&&{annotations:m}),Y),b);return H||N||(X?e.jsx(Jr,{componentName:"CandlestickChart",message:X,width:M,height:C}):e.jsx(Ss,{componentName:"CandlestickChart",width:M,height:C,children:e.jsx(To,Object.assign({ref:i},K))}))});la.displayName="CandlestickChart";const ca=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sort:p=!1,barPadding:y=40,roundedTop:v,gradientFill:m=!1,baselinePadding:b=!1,tooltip:x,annotations:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,showCategoryTicks:H,categoryFormat:N,dataIdAccessor:$}=o,W=i.width,F=i.height,E=i.enableHover,z=i.showGrid,G=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.categoryLabel,K=i.valueLabel,Q=s||[],Z=Ts({data:Q,rawData:s,colorBy:g,colorScheme:f,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"BarChart",chartId:C,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:W,height:F});if(Z.earlyReturn)return Z.earlyReturn;Ps("BarChart",Q,"categoryAccessor",c),Ps("BarChart",Q,"valueAccessor",u);const J=Yr(Q,p,u),ee=Fr(),te=t.useMemo(()=>new Map,[Q]),oe=t.useMemo(()=>(e,t)=>{const o={};return o.fill=g?Y(e,g,Z.colorScale):Er(R,ee,f,void 0,te),o},[g,Z.colorScale,R,ee,f,te]),ne=t.useMemo(()=>{const e=null==w?void 0:w.pieceStyle;return Zr(e&&"function"==typeof e?(t,o)=>Object.assign(Object.assign({},oe(t,o)),e(t,o)||{}):oe,{stroke:B,strokeWidth:I,opacity:D})},[oe,w,B,I,D]),ie=t.useMemo(()=>Rr(ne,Z.effectiveSelectionHook,Z.resolvedSelection),[ne,Z.effectiveSelectionHook,Z.resolvedSelection]),re=t.useMemo(()=>dr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",valueFormat:h}),[c,u,g,h]),se=rs({componentName:"BarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(se)return e.jsx(Jr,{componentName:"BarChart",message:se,width:W,height:F});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=s&&{data:J}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ie,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z.margin,barPadding:y}),null!=v&&{roundedTop:v}),m&&{gradientFill:!0===m?{topOpacity:.8,bottomOpacity:.05}:m}),$&&{dataIdAccessor:$}),{baselinePadding:b,enableHover:E,showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:h}),N&&{oFormat:N}),{showGrid:z,showCategoryTicks:H,oSort:p}),Z.legendBehaviorProps),G&&{title:G}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:rr(x)||re}),(A||S||O||M)&&{customHoverBehavior:Z.customHoverBehavior}),(S||O||A)&&{customClickBehavior:Z.customClickBehavior}),k&&k.length>0&&{annotations:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"BarChart",width:W,height:F,children:e.jsx(hn,Object.assign({ref:r},ae))})});function ua({ref:e,frameRef:o,isPushMode:n,colorBy:i,colorScheme:r,showLegend:s,legendPosition:a,setup:l}){const c=Es({isPushMode:n,colorBy:i,colorScheme:r,showLegend:s,legendPosition:a}),u=t.useCallback(c.wrapPush(e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.push(e)}),[c.wrapPush]),d=t.useCallback(c.wrapPushMany(e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushMany(e)}),[c.wrapPushMany]);return t.useImperativeHandle(e,()=>({push:u,pushMany:d,remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,i;return null!==(i=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[]},clear:()=>{var e;c.resetCategories(),null===(e=o.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}),[u,d,c.resetCategories]),{effectiveLegendProps:t.useMemo(()=>c.streamingLegend?Object.assign(Object.assign({},l.legendBehaviorProps),{legend:c.streamingLegend,legendPosition:a||l.legendPosition}):l.legendBehaviorProps,[l.legendBehaviorProps,l.legendPosition,c.streamingLegend,a]),effectiveMargin:t.useMemo(()=>{if(c.streamingMarginAdjust){const e=Object.assign({},l.margin);for(const[t,o]of Object.entries(c.streamingMarginAdjust))o>e[t]&&(e[t]=o);return e}return l.margin},[l.margin,c.streamingMarginAdjust])}}ca.displayName="BarChart";const da=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",stackBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,normalize:y=!1,sort:v=!1,barPadding:m=40,roundedTop:b,baselinePadding:x=!1,tooltip:k,annotations:w,frameProps:j={},selection:A,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,emptyContent:L,legendInteraction:T,legendPosition:R,color:B,stroke:I,strokeWidth:D,opacity:H,categoryFormat:N}=o,$=i.width,W=i.height,F=i.enableHover,E=i.showGrid,z=i.showLegend,G=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.categoryLabel,K=i.valueLabel,Q=s||[],Z=f||u,J=void 0===s,ee=Ts({data:Q,rawData:s,colorBy:Z,colorScheme:p,legendInteraction:T,legendPosition:R,selection:A,linkedHover:S,fallbackFields:Z?["string"==typeof Z?Z:""]:[],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:C,chartType:"StackedBarChart",chartId:_,showLegend:z,userMargin:a,marginDefaults:i.marginDefaults,loading:P,emptyContent:L,width:$,height:W});if(ee.earlyReturn)return ee.earlyReturn;const te=Fr(),oe=t.useMemo(()=>new Map,[Q]),ne=t.useMemo(()=>(e,t)=>Z?ee.colorScale?{fill:Y(e,Z,ee.colorScale)}:{}:{fill:Er(B,te,p,t,oe)},[Z,ee.colorScale,B,te,p,oe]),ie=t.useMemo(()=>{const e=null==j?void 0:j.pieceStyle;return Zr(e&&"function"==typeof e?(t,o)=>{const n=ne(t,o),i=e(t,o)||{};return Object.assign(Object.assign({},n),i)}:ne,{stroke:I,strokeWidth:D,opacity:H})},[ne,j,I,D,H]),re=t.useMemo(()=>Rr(ie,ee.effectiveSelectionHook,ee.resolvedSelection),[ie,ee.effectiveSelectionHook,ee.resolvedSelection]),se=t.useMemo(()=>dr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),ae=rs({componentName:"StackedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{stackBy:u}}),{effectiveLegendProps:le,effectiveMargin:ce}=ua({ref:n,frameRef:r,isPushMode:J,colorBy:Z,colorScheme:p,showLegend:z,legendPosition:R,setup:ee}),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=s&&{data:Q}),{oAccessor:c,rAccessor:d,stackBy:u,normalize:y,oSort:v,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:re,size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ce,barPadding:m}),null!=b&&{roundedTop:b}),{baselinePadding:x,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:g}),N&&{oFormat:N}),{showGrid:E}),le),G&&{title:G}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===k?()=>null:rr(k)||se}),(S||O||M||C)&&{customHoverBehavior:ee.customHoverBehavior}),(O||M||S)&&{customClickBehavior:ee.customClickBehavior}),w&&w.length>0&&{annotations:w}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return ae?e.jsx(Jr,{componentName:"StackedBarChart",message:ae,width:$,height:W}):e.jsx(Ss,{componentName:"StackedBarChart",width:$,height:W,children:e.jsx(hn,Object.assign({ref:r},ue))})});da.displayName="StackedBarChart";const ha={RdBu:s.interpolateRdBu,PiYG:s.interpolatePiYG,PRGn:s.interpolatePRGn,BrBG:s.interpolateBrBG,RdYlBu:s.interpolateRdYlBu,RdYlGn:s.interpolateRdYlGn,Spectral:s.interpolateSpectral},ga="__likert_neutral_neg",fa="__likert_neutral_pos";function pa(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function ya(e,t,o,n,i,r){const s=new Map,a=new Set(t);for(const l of e){const e=o(l);s.has(e)||s.set(e,new Map);const c=s.get(e);if(n){const e=n(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const i=t[o];c.set(i,(c.get(i)||0)+1)}else if(i&&r){const e=i(l),t=r(l);if(!a.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,o]of s){let n=0;for(const e of t)n+=o.get(e)||0;if(0!==n)for(let i=0;t.length>i;i++){const r=t[i],s=o.get(r)||0;l.push({__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/n*100,__likertLevelIndex:i})}}return l}function va(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(n&&e===i){const e=t.__likertPct/2;r.push(Object.assign(Object.assign({},t),{__likertLevel:ga,__likertPct:-e})),r.push(Object.assign(Object.assign({},t),{__likertLevel:fa,__likertPct:e}))}else r.push(i>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return r}function ma(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=new Map;for(const t of e){const e=r.get(t.__likertCategory)||[];e.push(t),r.set(t.__likertCategory,e)}const s=[];for(const[,e]of r){const t=new Map;let r,a;for(const o of e)o.__likertLevel===ga?r=o:o.__likertLevel===fa?a=o:t.set(o.__likertLevelIndex,o);n&&r&&s.push(r);for(let e=i-1;e>=0;e--){const o=t.get(e);o&&s.push(o)}n&&a&&s.push(a);for(let e=n?i+1:i;o>e;e++){const o=t.get(e);o&&s.push(o)}}return s}const ba=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="question",valueAccessor:u,levelAccessor:d,countAccessor:h="count",levels:g,orientation:f="horizontal",colorScheme:p,barPadding:v=20,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:j,onClick:A,hoverHighlight:S,chartId:O,valueFormat:M,loading:C,emptyContent:_,legendInteraction:P,legendPosition:L,categoryFormat:T,stroke:R,strokeWidth:B,opacity:I}=o,D=i.width,H=i.height,N=i.enableHover,$=i.showGrid,W=i.showLegend,F=i.title,E=i.description,z=i.summary,Y=i.accessibleTable,G=i.categoryLabel,q=i.valueLabel,X="horizontal"===f,V=void 0===s,U=!d,K=function(){var e;const t=$r();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.diverging)||void 0}(),Q=t.useMemo(()=>p&&Array.isArray(p)&&p.length>=g.length?p:function(e,t){if(0>=e)return[];if(t){const o=ha[t];if(o){if(1===e)return[o(.5)];const t=[];for(let n=0;e>n;n++)t.push(o(n/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],i="#a8a8a8";if(1===e)return[i];const r=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);r&&a.push(i);for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);return a}(g.length,K),[p,g.length,K]),Z=t.useMemo(()=>{const e=new Map;for(let t=0;g.length>t;t++)e.set(g[t],Q[t]||"#888");return e},[g,Q]),{processedData:J,reAggregate:ee,accumulatorRef:te}=function({data:e,levels:o,categoryAccessor:n,valueAccessor:i,levelAccessor:r,countAccessor:s,isDiverging:a,frameRef:l}){const c=!r,u=t.useMemo(()=>pa(n,"question"),[n]),d=t.useMemo(()=>c?pa(i,"score"):null,[c,i]),h=t.useMemo(()=>c?null:pa(r,"level"),[c,r]),g=t.useMemo(()=>c?null:pa(s,"count"),[c,s]),f=e||[],p=t.useRef([]),y=t.useMemo(()=>{if(0===f.length)return[];let e=ya(f,o,u,d,h,g);return a&&(e=va(e,o),e=ma(e,o)),e},[f,o,u,d,h,g,a]),v=t.useCallback(e=>{var t;let n=ya(e,o,u,d,h,g);a&&(n=va(n,o),n=ma(n,o)),null===(t=l.current)||void 0===t||t.replace(n)},[o,u,d,h,g,a,l]);return{processedData:y,reAggregate:v,accumulatorRef:p}}({data:s,levels:g,categoryAccessor:c,valueAccessor:u,levelAccessor:d,countAccessor:h,isDiverging:X,frameRef:r}),oe="__likertLevelLabel",ne=Es({isPushMode:V,colorBy:oe,colorScheme:Q,showLegend:W,legendPosition:L}),ie=t.useCallback(ne.wrapPush(e=>{te.current.push(e),ee(te.current)}),[ne.wrapPush,ee,te]),re=t.useCallback(ne.wrapPushMany(e=>{te.current.push(...e),ee(te.current)}),[ne.wrapPushMany,ee,te]);t.useImperativeHandle(n,()=>({push:ie,pushMany:re,remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;te.current=[],ne.resetCategories(),null===(e=r.current)||void 0===e||e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[ie,re,ne.resetCategories,te]);const se=Ts({data:J,rawData:s,colorBy:oe,colorScheme:Q,legendInteraction:P,legendPosition:L,selection:k,linkedHover:w,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:j,onClick:A,hoverHighlight:S,chartType:"LikertChart",chartId:O,showLegend:W,userMargin:a,marginDefaults:i.marginDefaults,loading:C,emptyContent:_,width:D,height:H});if(se.earlyReturn)return se.earlyReturn;const ae=t.useMemo(()=>{const e=g.length;return e%2!=0&&Z.get(g[Math.floor(e/2)])||"#888"},[g,Z]),le=x.pieceStyle,ce=t.useMemo(()=>(e,t)=>{var o,n;const i=e.__likertLevelLabel||(null===(o=e.data)||void 0===o?void 0:o.__likertLevelLabel),r=e.__likertLevel||(null===(n=e.data)||void 0===n?void 0:n.__likertLevel);let s;if(r===ga||r===fa)s={fill:ae};else{const e=i||r;s=e&&Z.has(e)?{fill:Z.get(e)}:{fill:"#888"}}if(le){const o=le(e,t);o.stroke&&(s.stroke=o.stroke),null!=o.strokeWidth&&(s.strokeWidth=o.strokeWidth),null!=o.strokeOpacity&&(s.strokeOpacity=o.strokeOpacity)}return s},[Z,ae,le]),ue=t.useMemo(()=>Zr(ce,{stroke:R,strokeWidth:B,opacity:I}),[ce,R,B,I]),de=t.useMemo(()=>Rr(ue,se.effectiveSelectionHook,se.resolvedSelection),[ue,se.effectiveSelectionHook,se.resolvedSelection]),he=t.useMemo(()=>{const e=g.length;return e%2!=0?g[Math.floor(e/2)]:""},[g]),ge=t.useMemo(()=>e=>{const t=e.data||e,o=t.__likertLevel||"Unknown",n=o===ga||o===fa?he:o,i=t.__likertCategory||"",r=Math.abs(t.__likertPct||0),s=o===ga||o===fa?2*r:r,a=t.__likertCount||0;return y.createElement("div",{className:"semiotic-tooltip",style:tr},y.createElement("div",{style:{fontWeight:"bold"}},i),y.createElement("div",{style:{marginTop:4}},`${n}: ${s.toFixed(1)}% (n=${a})`))},[he]),fe=t.useMemo(()=>{if(!g||2>g.length)return"LikertChart requires `levels` with at least 2 entries.";if(u&&d)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(d&&!h)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==s&&0===s.length)return null;const e={categoryAccessor:c};return U?u&&(e.valueAccessor=u):(d&&(e.levelAccessor=d),h&&(e.countAccessor=h)),rs({componentName:"LikertChart",data:s,accessors:e,requiredProps:{levels:g}})},[s,c,u,d,h,g,U]),pe=t.useMemo(()=>[{styleFn:e=>({fill:Z.get(e.label)||"#888"}),items:g.map(e=>({label:e})),label:""}],[g,Z]),ye=t.useMemo(()=>!1!==W?Object.assign(Object.assign({},se.legendBehaviorProps),{legend:{legendGroups:pe},legendPosition:L||se.legendPosition||"bottom"}):se.legendBehaviorProps,[se.legendBehaviorProps,se.legendPosition,L,W,pe]),ve=t.useMemo(()=>{const e=Object.assign({},se.margin);if(V&&!1!==W){const t=L||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(ne.streamingMarginAdjust)for(const[t,o]of Object.entries(ne.streamingMarginAdjust))o>e[t]&&(e[t]=o);return X&&100>e.left&&(e.left=100),e},[se.margin,ne.streamingMarginAdjust,X,V,W,L]),me=t.useMemo(()=>M||(X?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[X,M]),be=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"bar"},null!=s&&{data:J}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:X?"horizontal":"vertical",pieceStyle:de,size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ve,barPadding:v,enableHover:N}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:G,rLabel:q||(X?void 0:"Percentage"),rFormat:me}),T&&{oFormat:T}),{showGrid:$}),ye),F&&{title:F}),E&&{description:E}),z&&{summary:z}),void 0!==Y&&{accessibleTable:Y}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:!0===m?ge:rr(m)||ge}),(w||j||A||S)&&{customHoverBehavior:se.customHoverBehavior}),(j||A||w)&&{customClickBehavior:se.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return fe?e.jsx(Jr,{componentName:"LikertChart",message:fe,width:D,height:H}):e.jsx(Ss,{componentName:"LikertChart",width:D,height:H,children:e.jsx(hn,Object.assign({ref:r},be))})});function xa({brushProp:e,onBrushProp:o,linkedBrush:n,valueAccessor:i}){const r=Tr("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),s=Sr({name:(null==r?void 0:r.name)||"__unused_ordinal_brush__",xField:(null==r?void 0:r.xField)||("string"==typeof i?i:"value")}),a=t.useRef(s.brushInteraction);a.current=s.brushInteraction;const l=t.useCallback(e=>{if(r){a.current.end(e?e.r:null)}null==o||o(e)},[o,r]),c=!!(e||n||o);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}ba.displayName="LikertChart";const ka=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,8],pointRadius:v=4,pointOpacity:m=.7,categoryPadding:b=20,tooltip:x,annotations:k,brush:w,onBrush:j,linkedBrush:A,frameProps:S={},selection:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,emptyContent:R,legendInteraction:B,legendPosition:I,color:D,stroke:H,strokeWidth:N,opacity:$,showCategoryTicks:W,categoryFormat:F}=o,E=i.width,z=i.height,G=i.enableHover,X=i.showGrid,V=i.title,U=i.description,K=i.summary,Q=i.accessibleTable,Z=i.categoryLabel,J=i.valueLabel,ee=s||[],te=Ts({data:ee,rawData:s,colorBy:g,colorScheme:f,legendInteraction:B,legendPosition:I,selection:O,linkedHover:M,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:C,onClick:_,hoverHighlight:P,chartType:"SwarmPlot",chartId:L,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:T,emptyContent:R,width:E,height:z}),oe=xa({brushProp:w,onBrushProp:j,linkedBrush:A,valueAccessor:u});if(te.earlyReturn)return te.earlyReturn;const ne=t.useMemo(()=>{if(!p)return;const e=ee.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[ee,p]),ie=Fr(),re=t.useMemo(()=>new Map,[ee]),se=S.pieceStyle,ae=t.useMemo(()=>(e,t)=>{const o={fillOpacity:m};if(o.fill=g?Y(e,g,te.colorScale):Er(D,ie,f,void 0,re),o.r=p?q(e,p,y,ne):v,se){const n=se(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[g,te.colorScale,p,y,ne,v,m,D,ie,f,re,se]),le=t.useMemo(()=>Zr(ae,{stroke:H,strokeWidth:N,opacity:$}),[ae,H,N,$]),ce=t.useMemo(()=>Rr(le,te.effectiveSelectionHook,te.resolvedSelection),[le,te.effectiveSelectionHook,te.resolvedSelection]),ue=t.useMemo(()=>dr({categoryAccessor:c,valueAccessor:u,groupAccessor:g||void 0,valueFormat:h}),[c,u,g,h]),de=rs({componentName:"SwarmPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(de)return e.jsx(Jr,{componentName:"SwarmPlot",message:de,width:E,height:z});const he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swarm"},null!=s&&{data:ee}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:ce,size:[E,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:te.margin,barPadding:b,enableHover:G}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Z,rLabel:J,rFormat:h}),F&&{oFormat:F}),{showGrid:X,showCategoryTicks:W}),te.legendBehaviorProps),V&&{title:V}),U&&{description:U}),K&&{summary:K}),void 0!==Q&&{accessibleTable:Q}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:rr(x)||ue}),(M||C||_||P)&&{customHoverBehavior:te.customHoverBehavior}),(C||_||M)&&{customClickBehavior:te.customClickBehavior}),k&&k.length>0&&{annotations:k}),oe.brushStreamProps),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"SwarmPlot",width:E,height:z,children:e.jsx(hn,Object.assign({ref:r},he))})});function wa(t){return o=>{var n;const i=o.category||o.data&&(null===(n=o.data[0])||void 0===n?void 0:n.category)||"",r=o.stats||(o.data||o).stats;if(r&&null!=r.median)return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),null!=r.n&&e.jsxs("div",{children:["n = ",r.n]}),null!=r.min&&e.jsxs("div",{children:["Min: ",r.min.toLocaleString()]}),null!=r.q1&&e.jsxs("div",{children:["Q1: ",r.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",r.median.toLocaleString()]}),null!=r.q3&&e.jsxs("div",{children:["Q3: ",r.q3.toLocaleString()]}),null!=r.max&&e.jsxs("div",{children:["Max: ",r.max.toLocaleString()]}),null!=r.mean&&e.jsxs("div",{style:{opacity:.8},children:["Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});if(null==t?void 0:t.valueAccessor){const n=t.valueAccessor,r=(Array.isArray(o.data)?o.data:[]).map(e=>Number("function"==typeof n?n(e):e[n])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),s=r.length,a=s>0?s%2!=0?r[Math.floor(s/2)]:(r[s/2-1]+r[s/2])/2:null;return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),s>0&&e.jsxs("div",{children:["n = ",s]}),null!=a&&e.jsxs("div",{children:["Median: ",a.toLocaleString()]})]})}return e.jsx("div",{className:"semiotic-tooltip",style:tr,children:e.jsx("div",{style:{fontWeight:"bold"},children:i+""})})}}ka.displayName="SwarmPlot";const ja=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,showOutliers:p=!0,categoryPadding:y=20,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R,showCategoryTicks:B,categoryFormat:I}=o,D=i.width,H=i.height,N=i.enableHover,$=i.showGrid,W=i.title,F=i.description,E=i.summary,z=i.accessibleTable,G=i.categoryLabel,q=i.valueLabel,X=s||[],V=Ts({data:X,rawData:s,colorBy:g,colorScheme:f,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"BoxPlot",chartId:S,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:O,emptyContent:M,width:D,height:H});if(V.earlyReturn)return V.earlyReturn;const U=Fr(),K=t.useMemo(()=>new Map,[X]),Q=t.useMemo(()=>e=>{const t=g?Y(e,g,V.colorScale):Er(P,U,f,void 0,K);return{fill:t,stroke:t,fillOpacity:.8}},[g,V.colorScale,P,U,f,K]),Z=t.useMemo(()=>Zr(Q,{stroke:L,strokeWidth:T,opacity:R}),[Q,L,T,R]),J=t.useMemo(()=>Rr(Z,V.effectiveSelectionHook,V.resolvedSelection),[Z,V.effectiveSelectionHook,V.resolvedSelection]),ee=t.useMemo(()=>wa(),[]),te=rs({componentName:"BoxPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(te)return e.jsx(Jr,{componentName:"BoxPlot",message:te,width:D,height:H});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot"},null!=s&&{data:X}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:J,showOutliers:p,size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:V.margin,barPadding:y,enableHover:N}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:G,rLabel:q,rFormat:h}),I&&{oFormat:I}),{showGrid:$,showCategoryTicks:B}),V.legendBehaviorProps),W&&{title:W}),F&&{description:F}),E&&{summary:E}),void 0!==z&&{accessibleTable:z}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:rr(v)||ee}),(k||w||j||A)&&{customHoverBehavior:V.customHoverBehavior}),(w||j||k)&&{customClickBehavior:V.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"BoxPlot",width:D,height:H,children:e.jsx(hn,Object.assign({ref:r},oe))})});ja.displayName="BoxPlot";const Aa=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:"horizontal"}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",bins:d=25,relative:h=!1,valueFormat:g,colorBy:f,colorScheme:p,categoryPadding:y=20,tooltip:v,annotations:m,brush:b,onBrush:x,linkedBrush:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,showCategoryTicks:H,categoryFormat:N}=o,$=i.width,W=i.height,F=i.enableHover,E=i.showGrid,z=i.title,G=i.description,q=i.summary,X=i.accessibleTable,V=i.categoryLabel,U=i.valueLabel,K=s||[],Q=Ts({data:K,rawData:s,colorBy:f,colorScheme:p,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"Histogram",chartId:C,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:$,height:W}),Z=xa({brushProp:b,onBrushProp:x,linkedBrush:k,valueAccessor:u});if(Q.earlyReturn)return Q.earlyReturn;const J=t.useMemo(()=>{if(0===K.length)return;const e="function"==typeof u?u:e=>e[u];let t=1/0,o=-1/0;for(const n of K){const i=e(n);null!=i&&isFinite(i)&&(t>i&&(t=i),i>o&&(o=i))}return t>o?void 0:[t,o]},[K,u]),ee=Fr(),te=t.useMemo(()=>new Map,[K]),oe=t.useMemo(()=>e=>{const t=f?Y(e,f,Q.colorScale):Er(R,ee,p,void 0,te);return{fill:t,stroke:t,fillOpacity:.8}},[f,Q.colorScale,R,ee,p,te]),ne=t.useMemo(()=>Zr(oe,{stroke:B,strokeWidth:I,opacity:D}),[oe,B,I,D]),ie=t.useMemo(()=>Rr(ne,Q.effectiveSelectionHook,Q.resolvedSelection),[ne,Q.effectiveSelectionHook,Q.resolvedSelection]),re=t.useMemo(()=>t=>{const o=t.data||t,n=o.category||t.category||"",i=o.count,r=o.range;return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[n&&e.jsx("div",{style:{fontWeight:"bold"},children:n+""}),null!=i&&e.jsxs("div",{children:["Count: ",i]}),r&&2===r.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]),se=rs({componentName:"Histogram",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(se)return e.jsx(Jr,{componentName:"Histogram",message:se,width:$,height:W});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"histogram"},null!=s&&{data:K}),{oAccessor:c,rAccessor:u,projection:"horizontal",summaryStyle:ie,bins:d,normalize:h}),J&&{rExtent:J}),{size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Q.margin,barPadding:y,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:U,rFormat:g}),N&&{oFormat:N}),{showGrid:E,showCategoryTicks:H}),Q.legendBehaviorProps),z&&{title:z}),G&&{description:G}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:rr(v)||re}),(A||S||O||M)&&{customHoverBehavior:Q.customHoverBehavior}),(S||O||A)&&{customClickBehavior:Q.customClickBehavior}),m&&m.length>0&&{annotations:m}),Z.brushStreamProps),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"Histogram",width:$,height:W,children:e.jsx(hn,Object.assign({ref:r},ae))})});Aa.displayName="Histogram";const Sa=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",bins:h=25,showIQR:g=!0,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:v=20,tooltip:m,annotations:b,brush:x,onBrush:k,linkedBrush:w,frameProps:j={},selection:A,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,emptyContent:L,legendInteraction:T,legendPosition:R,color:B,stroke:I,strokeWidth:D,opacity:H,showCategoryTicks:N,categoryFormat:$}=o,W=i.width,F=i.height,E=i.enableHover,z=i.showGrid,G=i.title,q=i.description,X=i.summary,V=i.accessibleTable,U=i.categoryLabel,K=i.valueLabel,Q=s||[],Z=Ts({data:Q,rawData:s,colorBy:p,colorScheme:y,legendInteraction:T,legendPosition:R,selection:A,linkedHover:S,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:C,chartType:"ViolinPlot",chartId:_,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:P,emptyContent:L,width:W,height:F}),J=xa({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:u});if(Z.earlyReturn)return Z.earlyReturn;const ee=Fr(),te=t.useMemo(()=>new Map,[Q]),oe=t.useMemo(()=>e=>{const t=p?Y(e,p,Z.colorScale):Er(B,ee,y,void 0,te);return{fill:t,stroke:t,fillOpacity:.6}},[p,Z.colorScale,B,ee,y,te]),ne=t.useMemo(()=>Zr(oe,{stroke:I,strokeWidth:D,opacity:H}),[oe,I,D,H]),ie=t.useMemo(()=>Rr(ne,Z.effectiveSelectionHook,Z.resolvedSelection),[ne,Z.effectiveSelectionHook,Z.resolvedSelection]),re=t.useMemo(()=>wa({valueAccessor:u}),[u]),se=rs({componentName:"ViolinPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(se)return e.jsx(Jr,{componentName:"ViolinPlot",message:se,width:W,height:F});const ae=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"violin"},null!=s&&{data:Q}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ie,bins:h,showIQR:g,size:[W,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z.margin,barPadding:v,enableHover:E}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:f}),$&&{oFormat:$}),{showGrid:z,showCategoryTicks:N}),Z.legendBehaviorProps),G&&{title:G}),q&&{description:q}),X&&{summary:X}),void 0!==V&&{accessibleTable:V}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:rr(m)||re}),(S||O||M||C)&&{customHoverBehavior:Z.customHoverBehavior}),(O||M||S)&&{customClickBehavior:Z.customClickBehavior}),b&&b.length>0&&{annotations:b}),J.brushStreamProps),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"ViolinPlot",width:W,height:F,children:e.jsx(hn,Object.assign({ref:r},ae))})});Sa.displayName="ViolinPlot";const Oa=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",bins:h=20,amplitude:g=1.5,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:v=5,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:j,onClick:A,hoverHighlight:S,chartId:O,loading:M,emptyContent:C,legendInteraction:_,legendPosition:P,color:L,stroke:T,strokeWidth:R,opacity:B,showCategoryTicks:I,categoryFormat:D}=o,H=i.width,N=i.height,$=i.enableHover,W=i.showGrid,F=i.title,E=i.description,z=i.summary,G=i.accessibleTable,q=i.categoryLabel,X=i.valueLabel,V=s||[],U=Ts({data:V,rawData:s,colorBy:p,colorScheme:y,legendInteraction:_,legendPosition:P,selection:k,linkedHover:w,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:j,onClick:A,hoverHighlight:S,chartType:"RidgelinePlot",chartId:O,showLegend:i.showLegend,userMargin:a,marginDefaults:i.marginDefaults,loading:M,emptyContent:C,width:H,height:N});if(U.earlyReturn)return U.earlyReturn;const K=Fr(),Q=t.useMemo(()=>new Map,[V]),Z=t.useMemo(()=>e=>{const t=p?Y(e,p,U.colorScale):Er(L,K,y,void 0,Q);return{fill:t,stroke:t,fillOpacity:.5}},[p,U.colorScale,L,K,y,Q]),J=t.useMemo(()=>Zr(Z,{stroke:T,strokeWidth:R,opacity:B}),[Z,T,R,B]),ee=t.useMemo(()=>Rr(J,U.effectiveSelectionHook,U.resolvedSelection),[J,U.effectiveSelectionHook,U.resolvedSelection]),te=t.useMemo(()=>wa(),[]),oe=rs({componentName:"RidgelinePlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(oe)return e.jsx(Jr,{componentName:"RidgelinePlot",message:oe,width:H,height:N});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"ridgeline"},null!=s&&{data:V}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ee,bins:h,size:[H,N],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:U.margin,barPadding:v,enableHover:$}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:q,rLabel:X,rFormat:f}),D&&{oFormat:D}),{showGrid:W,showCategoryTicks:I,oSort:!1,amplitude:g}),U.legendBehaviorProps),F&&{title:F}),E&&{description:E}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:rr(m)||te}),(w||j||A||S)&&{customHoverBehavior:U.customHoverBehavior}),(j||A||w)&&{customClickBehavior:U.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"RidgelinePlot",width:H,height:N,children:e.jsx(hn,Object.assign({ref:r},ne))})});Oa.displayName="RidgelinePlot";const Ma=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:!1,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:!1}),r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:s,margin:a,className:l,stepAccessor:c="step",valueAccessor:u="value",categoryAccessor:d,colorBy:h,colorScheme:g,orientation:f="horizontal",connectorOpacity:p=.3,showLabels:y=!0,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R,categoryFormat:B}=o,I="vertical"===f,D=i.width,H=i.height,N=i.enableHover,$=i.title,W=i.description,F=i.summary,E=i.accessibleTable,z=s||[],G=h||d,q=!G,X=Ts({data:z,rawData:s,colorBy:G,colorScheme:g,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:G?["string"==typeof G?G:""]:[],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"FunnelChart",chartId:S,showLegend:i.showLegend,userMargin:a,marginDefaults:I?{top:$?60:40,right:20,bottom:60,left:60}:{top:$?40:10,right:10,bottom:10,left:10},loading:O,emptyContent:M,width:D,height:H});if(X.earlyReturn)return X.earlyReturn;Ps("FunnelChart",z,"stepAccessor",c),Ps("FunnelChart",z,"valueAccessor",u);const V=Fr(),U=t.useMemo(()=>new Map,[z]),K=t.useMemo(()=>{if(q)return P||((null==V?void 0:V[0])?V[0]:Array.isArray(g)&&g[0]?g[0]:"#4e79a7")},[q,P,V,g]),Q=b.pieceStyle,Z=t.useMemo(()=>(e,t)=>{const o={};if(o.fill=K||(G?Y(e,G,X.colorScale):Er(P,V,g,t,U)),Q){const n=Q(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[K,G,X.colorScale,P,V,g,U,Q]),J=t.useMemo(()=>Zr(Z,{stroke:L,strokeWidth:T,opacity:R}),[Z,L,T,R]),ee=t.useMemo(()=>Rr(J,X.effectiveSelectionHook,X.resolvedSelection),[J,X.effectiveSelectionHook,X.resolvedSelection]),te=t.useMemo(()=>t=>{var o,n,i,r,s,a;const l=(null==t?void 0:t.data)||t,c=(null==l?void 0:l.__funnelStep)||(null==l?void 0:l.__barFunnelStep)||(null==l?void 0:l.step)||"",u=null!==(i=null!==(n=null!==(o=null==l?void 0:l.__funnelValue)&&void 0!==o?o:null==l?void 0:l.__barFunnelValue)&&void 0!==n?n:null==l?void 0:l.value)&&void 0!==i?i:"",d=null!==(r=null==l?void 0:l.__funnelPercent)&&void 0!==r?r:null==l?void 0:l.__barFunnelPercent,h=null!==(s=null==l?void 0:l.__funnelIsFirstStep)&&void 0!==s?s:null==l?void 0:l.__barFunnelIsFirstStep,g=null==l?void 0:l.__barFunnelIsDropoff,f=null!==(a=null==l?void 0:l.__barFunnelCategory)&&void 0!==a?a:null==l?void 0:l.category,p=null==d||h?"":` (${.05>Math.abs(d-Math.round(d))?Math.round(d)+"%":d.toFixed(1)+"%"})`;return e.jsxs("div",{className:"semiotic-tooltip",style:tr,children:[c&&e.jsx("div",{style:{fontWeight:"bold"},children:c+""}),f&&f!==c&&e.jsx("div",{style:{marginTop:2,opacity:.8},children:f+""}),g&&e.jsx("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),e.jsxs("div",{style:{marginTop:4},children:[u+"",p]})]})},[]),oe=rs({componentName:"FunnelChart",data:s,accessors:{stepAccessor:c,valueAccessor:u}});if(oe)return e.jsx(Jr,{componentName:"FunnelChart",message:oe,width:D,height:H});const ne=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:I?"bar-funnel":"funnel"},null!=s&&{data:z}),{oAccessor:c,rAccessor:u}),d&&{stackBy:d}),{projection:I?"vertical":"horizontal",barPadding:I?40:0,pieceStyle:ee,size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:X.margin,enableHover:N}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:I,showCategoryTicks:I}),B&&{oFormat:B}),{showGrid:I}),!I&&{connectorOpacity:p}),{showLabels:y}),X.legendBehaviorProps),$&&{title:$}),W&&{description:W}),F&&{summary:F}),void 0!==E&&{accessibleTable:E}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:!0===v||null==v?te:rr(v)||te}),(k||w||j||A)&&{customHoverBehavior:X.customHoverBehavior}),(w||j||k)&&{customClickBehavior:X.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"FunnelChart",width:D,height:H,children:e.jsx(hn,Object.assign({ref:r},ne))})});Ma.displayName="FunnelChart";const Ca=t.forwardRef(function(o,n){var i;const r=Kr(o.mode,{width:o.width,height:o.height,showGrid:null===(i=o.showGrid)||void 0===i||i,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),s=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=s.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=s.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=s.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=s.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=s.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const{data:a,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,sort:y="auto",dotRadius:v=5,categoryPadding:m=10,tooltip:b,annotations:x,frameProps:k={},selection:w,linkedHover:j,onObservation:A,onClick:S,hoverHighlight:O,chartId:M,loading:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:I,categoryFormat:D}=o,H=r.width,N=r.height,$=r.enableHover,W=r.showGrid,F=r.title,E=r.description,z=r.summary,G=r.accessibleTable,q=r.categoryLabel,X=r.valueLabel,V=a||[],U=Ts({data:V,rawData:a,colorBy:f,colorScheme:p,legendInteraction:P,legendPosition:L,selection:w,linkedHover:j,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof u?u:""],unwrapData:!0,onObservation:A,onClick:S,hoverHighlight:O,chartType:"DotPlot",chartId:M,showLegend:r.showLegend,userMargin:l,marginDefaults:r.marginDefaults,loading:C,emptyContent:_,width:H,height:N});if(U.earlyReturn)return U.earlyReturn;const K=Yr(V,y,d),Q=Fr(),Z=t.useMemo(()=>new Map,[V]),J=k.pieceStyle,ee=t.useMemo(()=>(e,t)=>{const o={r:v,fillOpacity:.8};if(o.fill=f?Y(e,f,U.colorScale):Er(T,Q,p,void 0,Z),J){const n=J(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[f,U.colorScale,v,T,Q,p,Z,J]),te=t.useMemo(()=>Zr(ee,{stroke:R,strokeWidth:B,opacity:I}),[ee,R,B,I]),oe=t.useMemo(()=>Rr(te,U.effectiveSelectionHook,U.resolvedSelection),[te,U.effectiveSelectionHook,U.resolvedSelection]),ne=t.useMemo(()=>dr({categoryAccessor:u,valueAccessor:d,valueFormat:g}),[u,d,g]),ie=rs({componentName:"DotPlot",data:a,accessors:{categoryAccessor:u,valueAccessor:d}});if(ie)return e.jsx(Jr,{componentName:"DotPlot",message:ie,width:H,height:N});const re=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"point"},null!=a&&{data:K}),{oAccessor:u,rAccessor:d,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:oe,size:[H,N],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:U.margin,barPadding:m,enableHover:$}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:r.showAxes,oLabel:q,rLabel:X,rFormat:g}),D&&{oFormat:D}),{showGrid:W,oSort:y}),U.legendBehaviorProps),F&&{title:F}),E&&{description:E}),z&&{summary:z}),void 0!==G&&{accessibleTable:G}),c&&{className:c}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===b?()=>null:rr(b)||ne}),(j||A||S||O)&&{customHoverBehavior:U.customHoverBehavior}),(A||S||j)&&{customClickBehavior:U.customClickBehavior}),x&&x.length>0&&{annotations:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Ss,{componentName:"DotPlot",width:H,height:N,children:e.jsx(hn,Object.assign({ref:s},re))})});Ca.displayName="DotPlot";const _a=t.forwardRef(function(o,n){var i,r;const s=Kr(o.mode,{width:null!==(i=o.width)&&void 0!==i?i:400,height:null!==(r=o.height)&&void 0!==r?r:400,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:o.showCategoryTicks}),a=t.useRef(null),{data:l,margin:c,className:u,categoryAccessor:d="category",valueAccessor:h="value",colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R}=o,B=s.width,I=s.height,D=s.enableHover,H=s.showLegend,N=s.title,$=s.description,W=s.summary,F=s.accessibleTable,E=l||[],z=g||d,G=void 0===l,q=Ts({data:E,rawData:l,colorBy:z,colorScheme:f,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"PieChart",chartId:S,showLegend:H,userMargin:c,marginDefaults:s.marginDefaults,loading:O,emptyContent:M,width:B,height:I});if(q.earlyReturn)return q.earlyReturn;const X=Fr(),V=t.useMemo(()=>new Map,[E]),U=t.useMemo(()=>(e,t)=>z?q.colorScale?{fill:Y(e,z,q.colorScale)}:{}:{fill:Er(P,X,f,t,V)},[z,q.colorScale,P,X,f,V]),K=t.useMemo(()=>{const e=null==b?void 0:b.pieceStyle;return Zr(e&&"function"==typeof e?(t,o)=>Object.assign(Object.assign({},U(t,o)),e(t,o)||{}):U,{stroke:L,strokeWidth:T,opacity:R})},[U,b,L,T,R]),Q=t.useMemo(()=>Rr(K,q.effectiveSelectionHook,q.resolvedSelection),[K,q.effectiveSelectionHook,q.resolvedSelection]),Z=t.useMemo(()=>dr({categoryAccessor:d,valueAccessor:h,groupAccessor:g&&g!==d?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[d,h,g]),J=rs({componentName:"PieChart",data:l,accessors:{categoryAccessor:d,valueAccessor:h}}),{effectiveLegendProps:ee,effectiveMargin:te}=ua({ref:n,frameRef:a,isPushMode:G,colorBy:z,colorScheme:f,showLegend:H,legendPosition:_,setup:q}),oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie"},null!=l&&{data:E}),{oAccessor:d,rAccessor:h,projection:"radial",pieceStyle:Q,startAngle:p}),null!=y&&{cornerRadius:y}),{size:[B,I],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:te,enableHover:D}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),ee),N&&{title:N}),$&&{description:$}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),u&&{className:u}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:rr(v)||Z}),(k||w||j||A)&&{customHoverBehavior:q.customHoverBehavior}),(w||j||k)&&{customClickBehavior:q.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return J?e.jsx(Jr,{componentName:"PieChart",message:J,width:B,height:I}):e.jsx(Ss,{componentName:"PieChart",width:B,height:I,children:e.jsx(hn,Object.assign({ref:a},oe))})});_a.displayName="PieChart";const Pa=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover,showCategoryTicks:o.showCategoryTicks},{width:400,height:400}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:d,centerContent:h,colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:v,annotations:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,hoverHighlight:A,chartId:S,loading:O,emptyContent:M,legendInteraction:C,legendPosition:_,color:P,stroke:L,strokeWidth:T,opacity:R}=o,B=i.width,I=i.height,D=i.enableHover,H=i.showLegend,N=i.title,$=i.description,W=i.summary,F=i.accessibleTable,E=s||[],z=g||c,G=void 0===s,q=Ts({data:E,rawData:s,colorBy:z,colorScheme:f,legendInteraction:C,legendPosition:_,selection:x,linkedHover:k,fallbackFields:z?["string"==typeof z?z:""]:[],unwrapData:!0,onObservation:w,onClick:j,hoverHighlight:A,chartType:"DonutChart",chartId:S,showLegend:H,userMargin:a,marginDefaults:i.marginDefaults,loading:O,emptyContent:M,width:B,height:I});if(q.earlyReturn)return q.earlyReturn;const X=null!=d?d:Math.max(2,.15*Math.min(B,I)),V=Fr(),U=t.useMemo(()=>new Map,[E]),K=b.pieceStyle,Q=t.useMemo(()=>(e,t)=>{let o;if(o=z?q.colorScale?{fill:Y(e,z,q.colorScale)}:{}:{fill:Er(P,V,f,t,U)},K){const n=K(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[z,q.colorScale,P,V,f,U,K]),Z=t.useMemo(()=>Zr(Q,{stroke:L,strokeWidth:T,opacity:R}),[Q,L,T,R]),J=t.useMemo(()=>Rr(Z,q.effectiveSelectionHook,q.resolvedSelection),[Z,q.effectiveSelectionHook,q.resolvedSelection]),ee=t.useMemo(()=>dr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,u,g]),te=rs({componentName:"DonutChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}}),{effectiveLegendProps:oe,effectiveMargin:ne}=ua({ref:n,frameRef:r,isPushMode:G,colorBy:z,colorScheme:f,showLegend:H,legendPosition:_,setup:q}),ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut"},null!=s&&{data:E}),{oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:J,innerRadius:X,startAngle:p}),null!=y&&{cornerRadius:y}),{centerContent:h,size:[B,I],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne,enableHover:D}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),oe),N&&{title:N}),$&&{description:$}),W&&{summary:W}),void 0!==F&&{accessibleTable:F}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:rr(v)||ee}),(k||w||j||A)&&{customHoverBehavior:q.customHoverBehavior}),(w||j||k)&&{customClickBehavior:q.customClickBehavior}),m&&m.length>0&&{annotations:m}),Object.fromEntries(Object.entries(b).filter(([e])=>"pieceStyle"!==e)));return te?e.jsx(Jr,{componentName:"DonutChart",message:te,width:B,height:I}):e.jsx(Ss,{componentName:"DonutChart",width:B,height:I,children:e.jsx(hn,Object.assign({ref:r},ie))})});Pa.displayName="DonutChart";const La=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:!1,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:300,height:250}),r=t.useRef(null),s="context"===o.mode,{compactMode:a}=i,{value:l,min:c=0,max:u=100,thresholds:d,color:h,backgroundColor:g="var(--semiotic-grid, #e0e0e0)",arcWidth:f=.3,showNeedle:p=!0,needleColor:y="var(--semiotic-text, #333)",centerContent:v,valueFormat:m,showScaleLabels:b=!a,sweep:x=240,fillZones:k=!0,tooltip:w,annotations:j,frameProps:A={},className:S,stroke:O,strokeWidth:M,opacity:C}=o,_=i.width,P=i.height,L=i.title,T=i.description,R=i.summary,B=i.accessibleTable,I=Math.max(c,Math.min(u,l)),D=u-c||1,H=(I-c)/D,{gaugeData:N,pieceStyle:$,gaugeAnnotations:W}=t.useMemo(()=>{const e=[],t=new Map,o=[];let n=d&&d.length>0?[...d].sort((e,t)=>e.value-t.value):[{value:u,color:h||"var(--semiotic-primary, #007bff)"}];n=n.map(e=>Object.assign(Object.assign({},e),{value:Math.max(c,Math.min(u,e.value))})),u>n[n.length-1].value&&n.push({value:u,color:n[n.length-1].color});let i=c;for(let o=0;n.length>o;o++){const r=n[o],s=(r.value-i)/D;if(k){const n=(i-c)/D,a=Math.max(0,Math.min(H,(r.value-c)/D)-n),l=s-a;if(a>0){const n="fill-"+o;e.push({category:n,value:a,_zone:r.label||"Zone "+(o+1),_isFill:!0}),t.set(n,{fill:r.color})}if(l>0){const n="bg-"+o;e.push({category:n,value:l,_zone:r.label||"Zone "+(o+1),_isFill:!1}),t.set(n,{fill:g,opacity:.4})}}else{const n="zone-"+o;e.push({category:n,value:s,_zone:r.label||"Zone "+(o+1),_isFill:!0}),t.set(n,{fill:r.color})}i=r.value}if(b&&d&&d.length>0)for(const e of d)e.value>c&&u>e.value&&o.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:e,pieceStyle:(e,o)=>t.get(o||e.category)||{fill:g},gaugeAnnotations:o}},[l,c,u,d,h,g,H,D,b,k]),F=t.useMemo(()=>Zr($,{stroke:O,strokeWidth:M,opacity:C}),[$,O,M,C]),E=x*Math.PI/180,z=180+(360-x)/2,Y=Math.min(10,Math.max(1,Math.min(_,P)/12)),G=-Math.PI/2+z*Math.PI/180,q=[[Math.cos(G),Math.sin(G)],[Math.cos(G+E),Math.sin(G+E)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-G)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>E+.001||q.push([Math.cos(e),Math.sin(e)]);const X=Math.min(...q.map(e=>e[0])),V=Math.max(...q.map(e=>e[0])),U=Math.min(...q.map(e=>e[1])),K=Math.max(...q.map(e=>e[1])),Q=(U+K)/2,Z=(X+V)/2,J=Math.max(4,Math.min((_-2*Y)/(V-X),(P-2*Y)/(K-U))-2),ee=Math.max(0,Math.min(J-1.5,J*(1-f))),te=_/2-Z*J,oe=P/2-Q*J,ne=2*(J+4),ie=t.useMemo(()=>{if(a&&null==v)return null;if(null!=v)return"function"==typeof v?v(I,c,u):v;const t=m?m(I):Math.round(I)+"";return e.jsxs("div",{style:{textAlign:"center",lineHeight:1.2},children:[e.jsx("div",{style:{fontSize:Math.max(16,.3*J),fontWeight:700,color:"var(--semiotic-text, #333)"},children:t}),b&&e.jsxs("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[c," – ",u]})]})},[v,I,c,u,m,b,J,a]),re=t.useMemo(()=>s&&null==v?{type:"gauge-value",text:m?m(I):Math.round(I)+""}:null,[s,v,I,m]),se=t.useMemo(()=>{if(!p)return null;const e=-Math.PI/2+z*Math.PI/180+H*E,t=ee>20?ee-8:J-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:y}},[p,H,z,E,ee,y]),ae=t.useMemo(()=>(t,o,n)=>{if("gauge-needle"===t.type){const i=(n.width||_)/2,r=(n.height||P)/2,s=Math.max(1,J-ee),a=Math.max(1,Math.min(2.5,.4*s)),l=Math.max(1,Math.min(5,.6*s));return e.jsxs("g",{transform:`translate(${i},${r})`,children:[e.jsx("line",{x1:0,y1:0,x2:t.tipX,y2:t.tipY,stroke:t.color,strokeWidth:a,strokeLinecap:"round"}),e.jsx("circle",{cx:0,cy:0,r:l,fill:t.color})]},"gauge-needle-"+o)}if("gauge-label"===t.type){const i=-Math.PI/2+z*Math.PI/180+(t.value-c)/D*E,r=ee-14,s=(n.height||P)/2;return e.jsx("text",{x:(n.width||_)/2+Math.cos(i)*r,y:s+Math.sin(i)*r,textAnchor:"middle",dominantBaseline:"middle",fontSize:9,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label},"gauge-label-"+o)}return"gauge-value"===t.type?e.jsx("text",{x:(n.width||_)/2,y:(n.height||P)/2-.2*ee,textAnchor:"middle",dominantBaseline:"middle",fontSize:Math.max(12,Math.min(22,.28*J)),fontWeight:700,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:t.text},"gauge-value-"+o):null},[_,P,c,D,z,E,ee,J]),le=t.useMemo(()=>{const e=[...W,...j||[]];return se&&e.push(se),re&&e.push(re),e},[W,j,se,re]),ce=t.useMemo(()=>t=>{var o;const n=(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o[0])||(null==t?void 0:t.data)||t,i=null==n?void 0:n._isFill;return e.jsxs("div",{className:"semiotic-tooltip",style:{padding:"6px 10px",background:"var(--semiotic-tooltip-bg, white)",borderRadius:"var(--semiotic-tooltip-radius, 6px)",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0,0,0,0.15))"},children:[e.jsx("div",{style:{fontWeight:600},children:(null==n?void 0:n._zone)||""}),e.jsx("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:i?"Current: "+Math.round(I):"Remaining"})]})},[I]);if(0===N.length)return e.jsx(Jr,{componentName:"GaugeChart",message:"No data to display",width:_,height:P});const ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:N,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:F,innerRadius:ee,startAngle:z,sweepAngle:x,centerContent:ie,size:[_,P],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:{top:oe-ne/2,bottom:P-oe-ne/2,left:te-ne/2,right:_-te-ne/2},enableHover:i.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===w?()=>null:rr(w)||ce,svgAnnotationRules:ae},le.length>0&&{annotations:le}),L&&{title:L}),T&&{description:T}),R&&{summary:R}),void 0!==B&&{accessibleTable:B}),S&&{className:S}),null!=o.animate&&{animate:o.animate}),A);return e.jsx(Ss,{componentName:"GaugeChart",width:_,height:P,children:e.jsx(hn,Object.assign({ref:r},ue))})});La.displayName="GaugeChart";const Ta=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",groupBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,sort:y=!1,barPadding:v=60,roundedTop:m,baselinePadding:b=!1,tooltip:x,annotations:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,categoryFormat:H}=o,N=i.width,$=i.height,W=i.enableHover,F=i.showGrid,E=i.showLegend,z=i.title,G=i.description,q=i.summary,X=i.accessibleTable,V=i.categoryLabel,U=i.valueLabel,K=s||[],Q=f||u,Z=void 0===s,J=Ts({data:K,rawData:s,colorBy:Q,colorScheme:p,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:Q?["string"==typeof Q?Q:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"GroupedBarChart",chartId:C,showLegend:E,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:N,height:$});if(J.earlyReturn)return J.earlyReturn;const ee=Fr(),te=t.useMemo(()=>new Map,[K]),oe=w.pieceStyle,ne=t.useMemo(()=>(e,t)=>{const o=Q?J.colorScale?{fill:Y(e,Q,J.colorScale)}:{}:{fill:Er(R,ee,p,t,te)};if(oe){const n=oe(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[Q,J.colorScale,R,ee,p,te,oe]),ie=t.useMemo(()=>Zr(ne,{stroke:B,strokeWidth:I,opacity:D}),[ne,B,I,D]),re=t.useMemo(()=>Rr(ie,J.effectiveSelectionHook,J.resolvedSelection),[ie,J.effectiveSelectionHook,J.resolvedSelection]),se=t.useMemo(()=>dr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),ae=rs({componentName:"GroupedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{groupBy:u}}),{effectiveLegendProps:le,effectiveMargin:ce}=ua({ref:n,frameRef:r,isPushMode:Z,colorBy:Q,colorScheme:p,showLegend:E,legendPosition:T,setup:J}),ue=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"clusterbar"},null!=s&&{data:K}),{oAccessor:c,rAccessor:d,groupBy:u,oSort:y,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:re,size:[N,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ce,barPadding:v}),null!=m&&{roundedTop:m}),{baselinePadding:b,enableHover:W}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:U,rFormat:g}),H&&{oFormat:H}),{showGrid:F}),le),z&&{title:z}),G&&{description:G}),q&&{summary:q}),void 0!==X&&{accessibleTable:X}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===x?()=>null:rr(x)||se}),(A||S||O||M)&&{customHoverBehavior:J.customHoverBehavior}),(S||O||A)&&{customClickBehavior:J.customClickBehavior}),k&&k.length>0&&{annotations:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return ae?e.jsx(Jr,{componentName:"GroupedBarChart",message:ae,width:N,height:$}):e.jsx(Ss,{componentName:"GroupedBarChart",width:N,height:$,children:e.jsx(hn,Object.assign({ref:r},ue))})});Ta.displayName="GroupedBarChart";const Ra=t.forwardRef(function(o,n){const i=Kr(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",subcategoryAccessor:u,valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,barPadding:y,tooltip:v,annotations:m,brush:b,onBrush:x,linkedBrush:k,frameProps:w={},selection:j,linkedHover:A,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:I,opacity:D,categoryFormat:H,rTickValues:N,tickLabelEdgeAlign:$,showCategoryTicks:W}=o,F=i.width,E=i.height,z=i.enableHover,G=i.showGrid,q=i.showLegend,X=i.title,V=i.description,U=i.summary,K=i.accessibleTable,Q=i.categoryLabel,Z=i.valueLabel,J=s||[],ee=f||u,te=void 0===s,oe=t.useMemo(()=>{if(null!=y)return y;if("sparkline"!==o.mode)return 40;const e=new Set(J.map(e=>"function"==typeof c?c(e):e[c])),t=Math.max(1,e.size);return t>1?Math.max(0,Math.min(1,(("horizontal"===h?E:F)-2*t)/(t-1))):1},[y,o.mode,J,c,h,F,E]),ne=Ts({data:J,rawData:s,colorBy:ee,colorScheme:p,legendInteraction:L,legendPosition:T,selection:j,linkedHover:A,fallbackFields:ee?["string"==typeof ee?ee:""]:[],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"SwimlaneChart",chartId:C,showLegend:q,userMargin:a,marginDefaults:i.marginDefaults,loading:_,emptyContent:P,width:F,height:E}),ie=xa({brushProp:b,onBrushProp:x,linkedBrush:k,valueAccessor:d});if(ne.earlyReturn)return ne.earlyReturn;const re=Fr(),se=t.useMemo(()=>new Map,[J]),ae=w.pieceStyle,le=t.useMemo(()=>(e,t)=>{const o=ee?ne.colorScale?{fill:Y(e,ee,ne.colorScale)}:{}:{fill:Er(R,re,p,t,se)};if(ae){const n=ae(e,t);n.stroke&&(o.stroke=n.stroke),null!=n.strokeWidth&&(o.strokeWidth=n.strokeWidth),null!=n.strokeOpacity&&(o.strokeOpacity=n.strokeOpacity)}return o},[ee,ne.colorScale,R,re,p,se,ae]),ce=t.useMemo(()=>Zr(le,{stroke:B,strokeWidth:I,opacity:D}),[le,B,I,D]),ue=t.useMemo(()=>Rr(ce,ne.effectiveSelectionHook,ne.resolvedSelection),[ce,ne.effectiveSelectionHook,ne.resolvedSelection]),de=t.useMemo(()=>dr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),he=rs({componentName:"SwimlaneChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d,subcategoryAccessor:u},requiredProps:{subcategoryAccessor:u}}),{effectiveLegendProps:ge,effectiveMargin:fe}=ua({ref:n,frameRef:r,isPushMode:te,colorBy:ee,colorScheme:p,showLegend:q,legendPosition:T,setup:ne}),pe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"swimlane"},null!=s&&{data:J}),{oAccessor:c,rAccessor:d,stackBy:u,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ue,size:[F,E],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:fe,barPadding:oe,enableHover:z}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:!1===W?void 0:Q,rLabel:Z,rFormat:g}),N&&{rTickValues:N}),null!=$&&{tickLabelEdgeAlign:$}),H&&{oFormat:H}),void 0!==W&&{showCategoryTicks:W}),{showGrid:G}),ge),X&&{title:X}),V&&{description:V}),U&&{summary:U}),void 0!==K&&{accessibleTable:K}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===v?()=>null:rr(v)||de}),(A||S||O||M)&&{customHoverBehavior:ne.customHoverBehavior}),(S||O||A)&&{customClickBehavior:ne.customClickBehavior}),m&&m.length>0&&{annotations:m}),ie.brushStreamProps),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return he?e.jsx(Jr,{componentName:"SwimlaneChart",message:he,width:F,height:E}):e.jsx(Ss,{componentName:"SwimlaneChart",width:F,height:E,children:e.jsx(hn,Object.assign({ref:r},pe))})});Ra.displayName="SwimlaneChart";const Ba=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o,n,i,s;const a=Array.isArray(e)?e:[e],l=null!==(n=null===(o=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==n?n:[],c=[];for(const e of a){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(s=r.current)||void 0===s||s.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var o;const n=null===(o=r.current)||void 0===o?void 0:o.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}));const s=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,nodeIDAccessor:d="id",sourceAccessor:h="source",targetAccessor:g="target",nodeLabel:f,colorBy:p,colorScheme:y,nodeSize:v=8,nodeSizeRange:m=[5,20],edgeWidth:b=1,edgeColor:x="#999",edgeOpacity:k=.6,iterations:w=300,forceStrength:j=.1,tooltip:A,frameProps:S={},onObservation:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,emptyContent:T,legendInteraction:R,legendPosition:B,stroke:I,strokeWidth:D,opacity:H}=o,N=s.width,F=s.height,E=s.enableHover,z=s.showLegend,G=null!==(i=s.showLabels)&&void 0!==i&&i,q=s.title,X=s.description,V=s.summary,U=s.accessibleTable,K=_s(L,N,F),Q=K?null:Cs(a,N,F,T),Z=a||[],J=l||[],ee=zr(Z,p,y),te=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Z){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[Z,p]),oe=Vr(R,p,te),ne=Fr(),ie=t.useMemo(()=>new Map,[]),re=t.useMemo(()=>{if(Array.isArray(y))return y;if(ne&&ne.length>0)return ne;const e=$[y];return Array.isArray(e)?e:W},[y,ne]),se=t.useMemo(()=>e=>{const t={};return t.fill=p?Y(e.data||e,p,ee):Er(void 0,ne,y,void 0,ie),"number"==typeof v&&(t.r=v),t},[p,ee,v,ne,y,ie]),ae=t.useMemo(()=>Zr(se,{stroke:I,strokeWidth:D,opacity:H}),[se,I,D,H]),le=t.useMemo(()=>e=>({stroke:x,strokeWidth:"number"==typeof b?b:"function"==typeof b?b(e):e[b]||1,opacity:k}),[b,x,k]),ce=t.useMemo(()=>Zr(le,{stroke:I,strokeWidth:D,opacity:H}),[le,I,D,H]),ue=t.useMemo(()=>{if(G&&f)return"function"==typeof f?f:e=>{var t,o,n;return null!==(n=null!==(o=null===(t=e.data)||void 0===t?void 0:t[f])&&void 0!==o?o:e[f])&&void 0!==n?n:e.id}},[G,f]),{legend:de,margin:he,legendPosition:ge}=Xr({data:Z,colorBy:p,colorScale:ee,showLegend:z,legendPosition:B,userMargin:c,defaults:s.marginDefaults}),{customHoverBehavior:fe,customClickBehavior:pe}=Gr({selection:_,linkedHover:P,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:O,onClick:M,chartType:"ForceDirectedGraph",chartId:C}),ye=as({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:d}});return ye?e.jsx(Jr,{componentName:"ForceDirectedGraph",message:ye,width:N,height:F}):K||Q||e.jsx(Ss,{componentName:"ForceDirectedGraph",width:N,height:F,children:e.jsx(er,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:Z},null!=l&&{edges:J},{size:[N,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:he,nodeIDAccessor:d,sourceAccessor:h,targetAccessor:g,iterations:w,forceStrength:j,nodeStyle:ae,edgeStyle:ce,colorBy:p,colorScheme:re,nodeSize:v,nodeSizeRange:m,nodeLabel:ue,showLabels:G,enableHover:E,tooltipContent:!1===A?()=>null:rr(A)||void 0,customHoverBehavior:P||O||M?fe:void 0,customClickBehavior:O||M?pe:void 0,legend:de,legendPosition:ge},R&&"none"!==R&&{legendHoverBehavior:oe.onLegendHover,legendClickBehavior:oe.onLegendClick,legendHighlightedCategory:oe.highlightedCategory,legendIsolatedCategories:oe.isolatedCategories},{className:u,title:q,description:X,summary:V,accessibleTable:U},null!=o.animate&&{animate:o.animate},S))})});function Ia(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function Da(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function Ha(e){return"function"==typeof e?e:t=>t[e]||1}function Na({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a=Object.assign({fillOpacity:i},r);if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=Y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=Y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}Ba.displayName="ForceDirectedGraph";const $a=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o,n,i,s;const a=Array.isArray(e)?e:[e],l=null!==(n=null===(o=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==n?n:[],c=[];for(const e of a){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(s=r.current)||void 0===s||s.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var o;const n=null===(o=r.current)||void 0===o?void 0:o.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}));const s=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:g="value",nodeIdAccessor:f="id",colorBy:p,colorScheme:y,edgeColorBy:v="source",padAngle:m=.01,groupWidth:b=20,sortGroups:x,nodeLabel:k,edgeOpacity:w=.5,tooltip:j,frameProps:A={},onObservation:S,onClick:O,chartId:M,selection:C,linkedHover:_,loading:P,emptyContent:L,legendInteraction:T,stroke:R,strokeWidth:B,opacity:I}=o,D=s.width,H=s.height,N=s.enableHover,F=null===(i=s.showLabels)||void 0===i||i,E=s.title,z=s.description,G=s.summary,q=s.accessibleTable,X=_s(P,D,H),V=X?null:Cs(l,D,H,L),U=l||[],K=t.useMemo(()=>Da(a,U,d,h),[a,U,d,h]),Q=zr(K,p,y),Z=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of K){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[K,p]),J=Vr(T,p,Z),ee=Fr(),te=t.useMemo(()=>new Map,[]),oe=t.useMemo(()=>{if(Array.isArray(y))return y;if(ee&&ee.length>0)return ee;const e=$[y];return Array.isArray(e)?e:W},[y,ee]),ne=K.length>0,ie=t.useMemo(()=>{if(ne)return(e,t)=>{var o,n;const i={stroke:"black",strokeWidth:1};if(p)i.fill=Y(e.data||e,p,Q);else{const r=Array.isArray(y)?y:$[y]||W,s=Array.isArray(r)?r:W,a=null!==(n=null!==(o=e.index)&&void 0!==o?o:t)&&void 0!==n?n:0;i.fill=s[a%s.length]}return i}},[ne,p,Q,y]),re=t.useMemo(()=>ie?Zr(ie,{stroke:R,strokeWidth:B,opacity:I}):void 0,[ie,R,B,I]),se=t.useMemo(()=>{if(ne)return Na({edgeColorBy:v,colorBy:p,colorScale:Q,nodeStyleFn:re||(e=>({fill:Er(void 0,ee,y,void 0,te)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[ne,v,p,Q,re,w,ee,y,te]),ae=t.useMemo(()=>se?Zr(se,{stroke:R,strokeWidth:B,opacity:I}):void 0,[se,R,B,I]),le=t.useMemo(()=>{if(!F)return;const e=k||f;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[F,k,f]),ce=Object.assign(Object.assign({},s.marginDefaults),"number"==typeof c?{top:c,bottom:c,left:c,right:c}:c),{customHoverBehavior:ue,customClickBehavior:de}=Gr({selection:C,linkedHover:_,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:S,onClick:O,chartType:"ChordDiagram",chartId:M}),he=as({componentName:"ChordDiagram",edges:l,edgesRequired:!0});return he?e.jsx(Jr,{componentName:"ChordDiagram",message:he,width:D,height:H}):X||V||e.jsx(Ss,{componentName:"ChordDiagram",width:D,height:H,children:e.jsx(er,Object.assign({ref:r,chartType:"chord"},K.length>0&&{nodes:K},null!=l&&{edges:U},{size:[D,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ce,nodeIDAccessor:f,sourceAccessor:d,targetAccessor:h,valueAccessor:g,padAngle:m,groupWidth:b,sortGroups:x,nodeStyle:re,edgeStyle:ae,colorBy:p,colorScheme:oe,edgeColorBy:v,edgeOpacity:w,nodeLabel:le,showLabels:F,enableHover:N,tooltipContent:!1===j?()=>null:rr(j)||void 0,customHoverBehavior:_||S||O?ue:void 0,customClickBehavior:S||O?de:void 0},T&&"none"!==T&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories},{className:u,title:E,description:z,summary:G,accessibleTable:q},null!=o.animate&&{animate:o.animate},A))})});$a.displayName="ChordDiagram";const Wa=t.forwardRef(function(o,n){var i;const r=t.useRef(null);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o,n,i,s;const a=Array.isArray(e)?e:[e],l=null!==(n=null===(o=null===(t=r.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==n?n:[],c=[];for(const e of a){const t=l.find(t=>t.id===e);t&&c.push(Object.assign(Object.assign({},null!==(i=t.data)&&void 0!==i?i:{}),{id:e})),null===(s=r.current)||void 0===s||s.removeNode(e)}return c},update:(e,t)=>(Array.isArray(e)?e:[e]).flatMap(e=>{var o;const n=null===(o=r.current)||void 0===o?void 0:o.updateNode(e,t);return n?[Object.assign(Object.assign({},n),{id:e})]:[]}),clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=r.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}));const s=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:800,height:600}),{nodes:a,edges:l,margin:c,className:u,sourceAccessor:d="source",targetAccessor:h="target",valueAccessor:g="value",nodeIdAccessor:f="id",colorBy:p,colorScheme:y,edgeColorBy:v="source",orientation:m="horizontal",nodeAlign:b="justify",nodePaddingRatio:x=.05,nodeWidth:k=15,nodeLabel:w,edgeOpacity:j=.5,edgeSort:A,tooltip:S,frameProps:O={},onObservation:M,onClick:C,chartId:_,selection:P,linkedHover:L,loading:T,emptyContent:R,legendInteraction:B,stroke:I,strokeWidth:D,opacity:H}=o,N=s.width,F=s.height,E=s.enableHover,z=null===(i=s.showLabels)||void 0===i||i,G=s.title,q=s.description,X=s.summary,V=s.accessibleTable,U=_s(T,N,F),K=U?null:Cs(l,N,F,R),Q=l||[],Z=t.useMemo(()=>Da(a,Q,d,h),[a,Q,d,h]),J=zr(Z,p,y),ee=t.useMemo(()=>{if(!p)return[];const e=new Set;for(const t of Z){const o="function"==typeof p?p(t):t[p];null!=o&&e.add(o+"")}return Array.from(e)},[Z,p]),te=Vr(B,p,ee),oe=Fr(),ne=t.useMemo(()=>new Map,[]),ie=t.useMemo(()=>{if(Array.isArray(y))return y;if(oe&&oe.length>0)return oe;const e=$[y];return Array.isArray(e)?e:W},[y,oe]),re=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?Y(e.data||e,p,J):Er(void 0,oe,y,void 0,ne),t},[p,J,oe,y,ne]),se=t.useMemo(()=>Zr(re,{stroke:I,strokeWidth:D,opacity:H}),[re,I,D,H]),ae=t.useMemo(()=>Na({edgeColorBy:v,colorBy:p,colorScale:J,nodeStyleFn:se,edgeOpacity:j,baseStyle:{stroke:"none",strokeWidth:0}}),[v,p,J,se,j]),le=t.useMemo(()=>Zr(ae,{stroke:I,strokeWidth:D,opacity:H}),[ae,I,D,H]),ce=t.useMemo(()=>{if(!z)return;const e=w||f;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[z,w,f]),ue=Object.assign(Object.assign({},s.marginDefaults),"number"==typeof c?{top:c,bottom:c,left:c,right:c}:c),{customHoverBehavior:de,customClickBehavior:he}=Gr({selection:P,linkedHover:L,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!0,onObservation:M,onClick:C,chartType:"SankeyDiagram",chartId:_}),ge=as({componentName:"SankeyDiagram",edges:l,edgesRequired:!0});return ge?e.jsx(Jr,{componentName:"SankeyDiagram",message:ge,width:N,height:F}):U||K||e.jsx(Ss,{componentName:"SankeyDiagram",width:N,height:F,children:e.jsx(er,Object.assign({ref:r,chartType:"sankey"},Z.length>0&&{nodes:Z},null!=l&&{edges:Q},{size:[N,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ue,nodeIDAccessor:f,sourceAccessor:d,targetAccessor:h,valueAccessor:g,orientation:m,nodeAlign:b,nodePaddingRatio:x,nodeWidth:k,nodeStyle:se,edgeStyle:le,colorBy:p,colorScheme:ie,edgeColorBy:v,edgeOpacity:j,edgeSort:A,nodeLabel:ce,showLabels:z,enableHover:E,tooltipContent:!1===S?()=>null:rr(S)||void 0,customHoverBehavior:L||M||C?de:void 0,customClickBehavior:M||C?he:void 0},B&&"none"!==B&&{legendHoverBehavior:te.onLegendHover,legendClickBehavior:te.onLegendClick,legendHighlightedCategory:te.highlightedCategory,legendIsolatedCategories:te.isolatedCategories},{className:u,title:G,description:q,summary:X,accessibleTable:V},null!=o.animate&&{animate:o.animate},O))})});function Fa(o){var n;const i=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:r,margin:s,className:a,layout:l="tree",orientation:c="vertical",childrenAccessor:u="children",valueAccessor:d="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:f,colorByDepth:p=!1,edgeStyle:y="curve",nodeLabel:v,nodeSize:m=5,tooltip:b,frameProps:x={},onObservation:k,onClick:w,chartId:j,selection:A,linkedHover:S,loading:O,legendInteraction:M,stroke:C,strokeWidth:_,opacity:P}=o,L=i.width,T=i.height,R=i.enableHover,B=null===(n=i.showLabels)||void 0===n||n,I=i.title,D=i.description,H=i.summary,N=i.accessibleTable,F=_s(O,L,T),z=t.useMemo(()=>Ia(null!=r?r:null,u),[r,u]),G=zr(z,p?void 0:g,f),q=t.useMemo(()=>{if(!g||p)return[];const e=new Set;for(const t of z){const o="function"==typeof g?g(t):t[g];null!=o&&e.add(o+"")}return Array.from(e)},[z,g,p]),X=Vr(M,p?void 0:g,q),V=Fr(),U=t.useMemo(()=>new Map,[]),K=t.useMemo(()=>{if(Array.isArray(f))return f;if(V&&V.length>0)return V;const e=$[f];return Array.isArray(e)?e:W},[f,V]),Q=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=p?E[(e.depth||0)%E.length]:g?Y(e.data||e,g,G):Er(void 0,V,f,void 0,U),t},[g,p,G,V,f,U]),Z=t.useMemo(()=>Zr(Q,{stroke:C,strokeWidth:_,opacity:P}),[Q,C,_,P]),J=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),ee=t.useMemo(()=>Zr(J,{stroke:C,strokeWidth:_,opacity:P}),[J,C,_,P]),te=t.useMemo(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return Ha(d)},[l,d]),oe=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof s?{top:s,bottom:s,left:s,right:s}:s),{customHoverBehavior:ne,customClickBehavior:ie}=Gr({selection:A,linkedHover:S,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:k,onClick:w,chartType:"TreeDiagram",chartId:j}),re=ss({componentName:"TreeDiagram",data:r});return re?e.jsx(Jr,{componentName:"TreeDiagram",message:re,width:L,height:T}):F||e.jsx(Ss,{componentName:"TreeDiagram",width:L,height:T,children:e.jsx(er,Object.assign({chartType:l},null!=r&&{data:r},{size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:oe,nodeIDAccessor:h,childrenAccessor:u,hierarchySum:te,treeOrientation:c,edgeType:y,nodeStyle:Z,edgeStyle:ee,colorBy:g,colorScheme:K,colorByDepth:p,nodeSize:m,nodeLabel:B?v||h:void 0,showLabels:B,enableHover:R,tooltipContent:!1===b?()=>null:rr(b)||void 0,customHoverBehavior:S||k||w?ne:void 0,customClickBehavior:k||w?ie:void 0},M&&"none"!==M&&{legendHoverBehavior:X.onLegendHover,legendClickBehavior:X.onLegendClick,legendHighlightedCategory:X.highlightedCategory,legendIsolatedCategories:X.isolatedCategories},{className:a,title:I,description:D,summary:H,accessibleTable:N},null!=o.animate&&{animate:o.animate},x))})}function Ea(o){var n;const i=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover},{width:600,height:600}),{data:r,margin:s,className:a,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h,colorByDepth:g=!1,labelMode:f="leaf",nodeLabel:p,padding:y=4,paddingTop:v,tooltip:m,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:j,chartId:A,loading:S,legendInteraction:O,stroke:M,strokeWidth:C,opacity:_}=o,P=i.width,L=i.height,T=i.enableHover,R=null===(n=i.showLabels)||void 0===n||n,B=i.title,I=i.description,D=i.summary,H=i.accessibleTable,N=_s(S,P,L),{activeSelectionHook:F,customHoverBehavior:z,customClickBehavior:G}=Gr({selection:x,linkedHover:k,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:w,onClick:j,chartType:"Treemap",chartId:A}),q=Ls(x),X=t.useCallback(e=>{if(!e)return z(null);const t=e.data||e;z({data:(null==t?void 0:t.data)||t})},[z]),V=t.useMemo(()=>Ia(null!=r?r:null,l),[r,l]),U=zr(V,g?void 0:d,h),K=t.useMemo(()=>{if(!d||g)return[];const e=new Set;for(const t of V){const o="function"==typeof d?d(t):t[d];null!=o&&e.add(o+"")}return Array.from(e)},[V,d,g]),Q=Vr(O,g?void 0:d,K),Z=Fr(),J=t.useMemo(()=>new Map,[]),ee=t.useMemo(()=>{if(Array.isArray(h))return h;if(Z&&Z.length>0)return Z;const e=$[h];return Array.isArray(e)?e:W},[h,Z]),te=t.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=g?E[(e.depth||0)%E.length]:d?Y(e.data||e,d,U):Er(void 0,Z,h,void 0,J),t},[d,g,U,Z,h,J]),oe=t.useMemo(()=>Zr(te,{stroke:M,strokeWidth:C,opacity:_}),[te,M,C,_]),ne=t.useMemo(()=>F?e=>{var t;const o=Object.assign({},oe(e));if(F.isActive)if(F.predicate(e.data||e))(null==q?void 0:q.selectedStyle)&&Object.assign(o,q.selectedStyle);else{const e=null!==(t=null==q?void 0:q.unselectedOpacity)&&void 0!==t?t:.5;o.opacity=e,o.fillOpacity=e,o.strokeOpacity=e,(null==q?void 0:q.unselectedStyle)&&Object.assign(o,q.unselectedStyle)}return o}:oe,[oe,F,q]),ie=t.useMemo(()=>Ha(c),[c]),re=void 0!==v?v:!R||"parent"!==f&&"all"!==f?void 0:18,se=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof s?{top:s,bottom:s,left:s,right:s}:s),ae=ss({componentName:"Treemap",data:r});return ae?e.jsx(Jr,{componentName:"Treemap",message:ae,width:P,height:L}):N||e.jsx(Ss,{componentName:"Treemap",width:P,height:L,children:e.jsx(er,Object.assign({chartType:"treemap"},null!=r&&{data:r},{size:[P,L],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:se,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:ie,padding:y,paddingTop:re,nodeStyle:ne,colorBy:d,colorScheme:ee,colorByDepth:g,nodeLabel:R?p||u:void 0,showLabels:R,labelMode:f,enableHover:T,tooltipContent:!1===m?()=>null:rr(m)||void 0},(k||w||j)&&{customHoverBehavior:X},(w||j)&&{customClickBehavior:G},O&&"none"!==O&&{legendHoverBehavior:Q.onLegendHover,legendClickBehavior:Q.onLegendClick,legendHighlightedCategory:Q.highlightedCategory,legendIsolatedCategories:Q.isolatedCategories},{className:a,title:B,description:I,summary:D,accessibleTable:H},null!=o.animate&&{animate:o.animate},b))})}function za(o){var n;const i=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:r,margin:s,className:a,childrenAccessor:l="children",valueAccessor:c="value",nodeIdAccessor:u="name",colorBy:d,colorScheme:h,colorByDepth:g=!1,nodeLabel:f,circleOpacity:p=.7,padding:y=4,tooltip:v,frameProps:m={},onObservation:b,onClick:x,chartId:k,selection:w,linkedHover:j,loading:A,legendInteraction:S,stroke:O,strokeWidth:M,opacity:C}=o,_=i.width,P=i.height,L=i.enableHover,T=null===(n=i.showLabels)||void 0===n||n,R=i.title,B=i.description,I=i.summary,D=i.accessibleTable,H=_s(A,_,P),N=t.useMemo(()=>Ia(null!=r?r:null,l),[r,l]),F=zr(N,g?void 0:d,h),z=t.useMemo(()=>{if(!d||g)return[];const e=new Set;for(const t of N){const o="function"==typeof d?d(t):t[d];null!=o&&e.add(o+"")}return Array.from(e)},[N,d,g]),G=Vr(S,g?void 0:d,z),q=Fr(),X=t.useMemo(()=>new Map,[]),V=t.useMemo(()=>{if(Array.isArray(h))return h;if(q&&q.length>0)return q;const e=$[h];return Array.isArray(e)?e:W},[h,q]),U=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:p};return t.fill=g?E[(e.depth||0)%E.length]:d?Y(e.data||e,d,F):Er(void 0,q,h,void 0,X),t},[d,g,F,p,q,h,X]),K=t.useMemo(()=>Zr(U,{stroke:O,strokeWidth:M,opacity:C}),[U,O,M,C]),Q=t.useMemo(()=>Ha(c),[c]),Z=Object.assign(Object.assign({},i.marginDefaults),"number"==typeof s?{top:s,bottom:s,left:s,right:s}:s),{customHoverBehavior:J,customClickBehavior:ee}=Gr({selection:w,linkedHover:j,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!0,onObservation:b,onClick:x,chartType:"CirclePack",chartId:k}),te=ss({componentName:"CirclePack",data:r});return te?e.jsx(Jr,{componentName:"CirclePack",message:te,width:_,height:P}):H||e.jsx(Ss,{componentName:"CirclePack",width:_,height:P,children:e.jsx(er,Object.assign({chartType:"circlepack"},null!=r&&{data:r},{size:[_,P],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z,nodeIDAccessor:u,childrenAccessor:l,hierarchySum:Q,padding:y,nodeStyle:K,colorBy:d,colorScheme:V,colorByDepth:g,nodeLabel:T?f||u:void 0,showLabels:T,enableHover:L,tooltipContent:!1===v?()=>null:rr(v)||void 0,customHoverBehavior:j||b||x?J:void 0,customClickBehavior:b||x?ee:void 0},S&&"none"!==S&&{legendHoverBehavior:G.onLegendHover,legendClickBehavior:G.onLegendClick,legendHighlightedCategory:G.highlightedCategory,legendIsolatedCategories:G.isolatedCategories},{className:a,title:R,description:B,summary:I,accessibleTable:D},null!=o.animate&&{animate:o.animate},m))})}Wa.displayName="SankeyDiagram",Fa.displayName="TreeDiagram",Ea.displayName="Treemap",za.displayName="CirclePack";const Ya=E;function Ga(o){const n=Kr(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:g=2.95,speed:f=.25,revolution:p,revolutionStyle:y,eccentricity:v=1,showRings:m=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:j,annotations:A,frameProps:S={},onObservation:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,stroke:T,strokeWidth:R,opacity:B}=o,I=n.width,D=n.height,H=n.enableHover,N=n.title,F=n.description,E=n.summary,z=n.accessibleTable,G=_s(L,I,D),q=zr(t.useMemo(()=>Ia(i,a),[i,a]),d?void 0:c,u),X=Fr(),V=t.useMemo(()=>new Map,[]),U=t.useMemo(()=>{if(Array.isArray(u))return u;if(X&&X.length>0)return X;const e=$[u];return Array.isArray(e)?e:W},[u,X]),K=t.useMemo(()=>{if(Array.isArray(u))return u;const e=$[u];return Array.isArray(e)?e:W},[u]),Q=t.useMemo(()=>e=>{var t;const o={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return o.fill=d?n?K[0]:Ya[(e.depth||0)%Ya.length]:c?Y(e.data||e,c,q):Er(void 0,X,u,void 0,V),o.opacity=n?1:.85,o},[c,d,q,K,X,u,V]),Z=t.useMemo(()=>Zr(Q,{stroke:T,strokeWidth:R,opacity:B}),[Q,T,R,B]),J=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),ee=Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof r?{top:r,bottom:r,left:r,right:r}:r),{customHoverBehavior:te,customClickBehavior:oe}=Gr({selection:_,linkedHover:P,fallbackFields:c?["string"==typeof c?c:""]:[],unwrapData:!0,onObservation:O,onClick:M,chartType:"OrbitDiagram",chartId:C}),ne=t.useMemo(()=>{if(te)return e=>{te(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[te]),ie=t.useMemo(()=>{if(oe)return e=>{oe(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[oe]),re=ss({componentName:"OrbitDiagram",data:i});return re?e.jsx(Jr,{componentName:"OrbitDiagram",message:re,width:I,height:D}):G||e.jsx(Ss,{componentName:"OrbitDiagram",width:I,height:D,children:e.jsx(er,Object.assign({chartType:"orbit"},null!=i&&{data:i},{size:[I,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ee,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:Z,edgeStyle:J,colorBy:c,colorScheme:U,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&H,tooltipContent:k?void 0:!1===w?()=>null:rr(w)||void 0,customHoverBehavior:P||O||M?ne:void 0,customClickBehavior:O||M?ie:void 0,foregroundGraphics:j,annotations:A,className:s,title:N,description:F,summary:E,orbitMode:h,orbitSize:g,orbitSpeed:f,orbitRevolution:p,orbitRevolutionStyle:y,orbitEccentricity:v,orbitShowRings:m,orbitAnimated:k,accessibleTable:z},null!=o.animate&&{animate:o.animate},S))})}Ga.displayName="OrbitDiagram";const qa=t.forwardRef(function(o,n){var i,r,s,a;const l=Kr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,timeExtent:m,valueExtent:b,extentPadding:x,stroke:k="#007bff",strokeWidth:w=2,strokeDasharray:j,opacity:A,background:S,tooltipContent:O,tooltip:M,onHover:C,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,transition:D,linkedHover:H,selection:N,onObservation:$,chartId:W,loading:F,emptyContent:E,emphasis:z,legendPosition:Y}=o,G=l.showAxes,q=l.enableHover,X=null!=u?u:l.marginDefaults,V=null!=c?c:[l.width,l.height],U=null!=O?O:M,K=t.useRef(null),{customHoverBehavior:Q}=Gr({selection:N,linkedHover:H,unwrapData:!0,onObservation:$,chartType:"RealtimeLineChart",chartId:W}),Z=t.useCallback(e=>{C&&C(e),Q(e)},[C,Q]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=K.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=K.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=K.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const J=_s(F,V[0],V[1]),ee=J?null:Cs(p,V[0],V[1],E),te={stroke:k,strokeWidth:w,strokeDasharray:j};return null!=A&&(te.opacity=A),J||ee||e.jsx(To,{ref:K,chartType:"line",runtimeMode:"streaming",size:V,margin:X,className:z?`${d||""} semiotic-emphasis-${z}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,xExtent:m,yExtent:b,extentPadding:x,lineStyle:te,showAxes:G,background:S,hoverAnnotation:q,tooltipContent:U,customHoverBehavior:Z,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,transition:D,pointIdAccessor:o.pointIdAccessor,legendPosition:Y})});qa.displayName="RealtimeLineChart";const Xa=t.forwardRef(function(o,n){var i,r,s,a;const l=Kr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,showAxes:o.showAxes,enableHover:null!=o.enableHover?!!o.enableHover:void 0,linkedHover:o.linkedHover}),{binSize:c,size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p=200,data:y,timeAccessor:v,valueAccessor:m,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:j,fill:A,stroke:S,strokeWidth:O,opacity:M,gap:C,background:_,tooltipContent:P,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,linkedHover:H,selection:N,decay:$,pulse:W,staleness:F,transition:E,onObservation:z,chartId:Y,loading:G,emptyContent:q,emphasis:X,legendPosition:V,brush:U,onBrush:K,linkedBrush:Q}=o,Z=l.showAxes,J=l.enableHover,ee=null!=d?d:l.marginDefaults,te=null!=u?u:[l.width,l.height],oe=null!=P?P:L,ne=t.useRef(null),{customHoverBehavior:ie}=Gr({selection:N,linkedHover:H,unwrapData:!0,onObservation:z,chartType:"RealtimeTemporalHistogram",chartId:Y}),re=t.useCallback(e=>{T&&T(e),ie(e)},[T,ie]),se=!0===U?{dimension:"x",snap:"bin"}:"x"===U?{dimension:"x"}:"object"==typeof U?U:void 0,ae=Tr(Q),le=Sr(Object.assign({name:(null==ae?void 0:ae.name)||"__unused_hist_brush__",xField:(null==ae?void 0:ae.xField)||("string"==typeof v?v:"time")},(null==ae?void 0:ae.yField)?{yField:ae.yField}:{})),ce=t.useRef(le.brushInteraction);ce.current=le.brushInteraction;const ue=t.useCallback(e=>{if(K&&K(e),z&&z(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeTemporalHistogram",chartId:Y}),ae){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[K,z,Y,ae]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ne.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=ne.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=ne.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=ne.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=ne.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const de=_s(G,te[0],te[1]),he=de?null:Cs(y,te[0],te[1],q),ge={};return null!=A&&(ge.fill=A),null!=S&&(ge.stroke=S),null!=O&&(ge.strokeWidth=O),null!=M&&(ge.opacity=M),null!=C&&(ge.gap=C),de||he||e.jsx(To,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:te,margin:ee,className:X?`${h||""} semiotic-emphasis-${X}`.trim():h,arrowOfTime:g,windowMode:f,windowSize:p,data:y,timeAccessor:v,valueAccessor:m,xExtent:b,yExtent:x,extentPadding:k,binSize:c,categoryAccessor:w,barColors:j,barStyle:ge,showAxes:Z,background:_,hoverAnnotation:J,tooltipContent:oe,customHoverBehavior:re,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,decay:$,pulse:W,staleness:F,transition:E,pointIdAccessor:o.pointIdAccessor,legendPosition:V,brush:se||(Q?{dimension:"x"}:void 0),onBrush:se||Q?ue:void 0})});Xa.displayName="RealtimeTemporalHistogram";const Va=Xa,Ua=t.forwardRef(function(o,n){var i,r,s,a;const l=Kr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,timeExtent:m,valueExtent:b,extentPadding:x,categoryAccessor:k,colors:w,radius:j,fill:A,opacity:S,stroke:O,strokeWidth:M,background:C,tooltipContent:_,tooltip:P,onHover:L,annotations:T,svgAnnotationRules:R,tickFormatTime:B,tickFormatValue:I,linkedHover:D,selection:H,onObservation:N,chartId:$,loading:W,emptyContent:F,emphasis:E,legendPosition:z}=o,Y=l.showAxes,G=l.enableHover,q=null!=u?u:l.marginDefaults,X=null!=c?c:[l.width,l.height],V=null!=_?_:P,U=t.useRef(null),{customHoverBehavior:K}=Gr({selection:H,linkedHover:D,unwrapData:!0,onObservation:N,chartType:"RealtimeSwarmChart",chartId:$}),Q=t.useCallback(e=>{L&&L(e),K(e)},[L,K]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=U.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Z=_s(W,X[0],X[1]),J=Z?null:Cs(p,X[0],X[1],F),ee={};return null!=j&&(ee.radius=j),null!=A&&(ee.fill=A),null!=S&&(ee.opacity=S),null!=O&&(ee.stroke=O),null!=M&&(ee.strokeWidth=M),Z||J||e.jsx(To,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:X,margin:q,className:E?`${d||""} semiotic-emphasis-${E}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,xExtent:m,yExtent:b,extentPadding:x,categoryAccessor:k,barColors:w,swarmStyle:ee,showAxes:Y,background:C,hoverAnnotation:G,tooltipContent:V,customHoverBehavior:Q,annotations:T,svgAnnotationRules:R,tickFormatTime:B,tickFormatValue:I,legendPosition:z,pointIdAccessor:o.pointIdAccessor})});Ua.displayName="RealtimeSwarmChart";const Ka=t.forwardRef(function(o,n){var i,r,s,a;const l=Kr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,timeExtent:m,valueExtent:b,extentPadding:x,positiveColor:k,negativeColor:w,connectorStroke:j,connectorWidth:A,gap:S,stroke:O,strokeWidth:M,opacity:C,background:_,tooltipContent:P,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,linkedHover:H,selection:N,onObservation:$,chartId:W,loading:F,emptyContent:E,emphasis:z,legendPosition:Y}=o,G=l.showAxes,q=l.enableHover,X=null!=u?u:l.marginDefaults,V=null!=c?c:[l.width,l.height],U=null!=P?P:L,K=t.useRef(null),{customHoverBehavior:Q}=Gr({selection:N,linkedHover:H,unwrapData:!0,onObservation:$,chartType:"RealtimeWaterfallChart",chartId:W}),Z=t.useCallback(e=>{T&&T(e),Q(e)},[T,Q]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=K.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=K.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=K.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=K.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=K.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const J=_s(F,V[0],V[1]),ee=J?null:Cs(p,V[0],V[1],E),te={};return null!=k&&(te.positiveColor=k),null!=w&&(te.negativeColor=w),null!=j&&(te.connectorStroke=j),null!=A&&(te.connectorWidth=A),null!=S&&(te.gap=S),null!=O&&(te.stroke=O),null!=M&&(te.strokeWidth=M),null!=C&&(te.opacity=C),J||ee||e.jsx(To,{ref:K,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:X,className:z?`${d||""} semiotic-emphasis-${z}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,xExtent:m,yExtent:b,extentPadding:x,waterfallStyle:te,showAxes:G,background:_,hoverAnnotation:q,tooltipContent:U,customHoverBehavior:Z,annotations:R,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:D,legendPosition:Y,pointIdAccessor:o.pointIdAccessor})});Ka.displayName="RealtimeWaterfallChart";const Qa=t.forwardRef(function(o,n){var i,r,s,a;const l=Kr(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:c,margin:u,className:d,arrowOfTime:h="right",windowMode:g="sliding",windowSize:f=200,data:p,timeAccessor:y,valueAccessor:v,categoryAccessor:m,timeExtent:b,valueExtent:x,extentPadding:k,heatmapXBins:w=20,heatmapYBins:j=20,aggregation:A="count",background:S,tooltipContent:O,tooltip:M,onHover:C,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,linkedHover:D,selection:H,onObservation:N,chartId:$,loading:W,emptyContent:F,emphasis:E,legendPosition:z}=o,Y=l.showAxes,G=l.enableHover,q=null!=u?u:l.marginDefaults,X=null!=c?c:[l.width,l.height],V=null!=O?O:M,U=t.useRef(null),{customHoverBehavior:K}=Gr({selection:H,linkedHover:D,unwrapData:!0,onObservation:N,chartType:"RealtimeHeatmap",chartId:$}),Q=t.useCallback(e=>{C&&C(e),K(e)},[C,K]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=U.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=U.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=U.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=U.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=U.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}));const Z=_s(W,X[0],X[1]),J=Z?null:Cs(p,X[0],X[1],F);return Z||J||e.jsx(To,{ref:U,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:q,className:E?`${d||""} semiotic-emphasis-${E}`.trim():d,arrowOfTime:h,windowMode:g,windowSize:f,data:p,timeAccessor:y,valueAccessor:v,categoryAccessor:m,xExtent:b,yExtent:x,extentPadding:k,heatmapXBins:w,heatmapYBins:j,heatmapAggregation:A,showAxes:Y,background:S,hoverAnnotation:G,tooltipContent:V,customHoverBehavior:Q,annotations:_,svgAnnotationRules:P,tickFormatTime:L,tickFormatValue:T,decay:R,pulse:B,staleness:I,legendPosition:z,pointIdAccessor:o.pointIdAccessor})});Qa.displayName="RealtimeHeatmap";const Za=864e5;function Ja(e){return 10>e?"0"+e:e+""}const el=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function tl(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)*(1-t)),i=Math.round(parseInt(o[2],16)*(1-t)),r=Math.round(parseInt(o[3],16)*(1-t));return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function ol(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*t),i=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*t),r=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*t);return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function nl(e,t){return Ds(this,void 0,void 0,function*(){const{format:o="png",filename:n="chart",scale:i=2,background:r="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const a=s.cloneNode(!0),l=s.getBoundingClientRect();if(a.getAttribute("width")||a.setAttribute("width",l.width+""),a.getAttribute("height")||a.setAttribute("height",l.height+""),a.getAttribute("xmlns")||a.setAttribute("xmlns","http://www.w3.org/2000/svg"),il(s,a),"svg"===o){const e=(new XMLSerializer).serializeToString(a);rl(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const t=l.width*i,o=l.height*i,s=document.createElement("canvas");s.width=t,s.height=o;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,o),c.scale(i,i);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(a),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),s.toBlob(o=>{o?(rl(o,n+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function il(e,t){var o;const n=e.children,i=t.children,r=window.getComputedStyle(e),s=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of s){const n=r.getPropertyValue(e);n&&"none"!==n&&""!==n&&(null===(o=t.style)||void 0===o||o.setProperty(e,n))}for(let e=0;Math.min(n.length,i.length)>e;e++)il(n[e],i[e])}function rl(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}const sl=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),al=new Set(["data","nodes","edges"]),ll="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function cl(e){return Ds(this,arguments,void 0,function*(e,t="json"){const o="jsx"===t?ul(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(o)})}function ul(e){const{component:t,props:o}=e,n=["<"+t];for(const[e,t]of Object.entries(o))if("string"==typeof t)n.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)n.push(" "+e);else if("boolean"==typeof t&&!1===t)n.push(` ${e}={false}`);else if("number"==typeof t)n.push(` ${e}={${t}}`);else{const o=JSON.stringify(t);n.push(80>o.length?` ${e}={${o}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return n.push("/>"),n.join("\n")}function dl(e){return"nominal"===e||"ordinal"===e}function hl(e){return"quantitative"===e||"temporal"===e}const gl={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},fl={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},pl={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function yl(e,t,o,n,i){var r,s;(null==e?void 0:e.field)&&(o.xAccessor=n?"value":e.field),(null==t?void 0:t.field)&&(o.yAccessor=i?"value":t.field),(null===(r=null==e?void 0:e.axis)||void 0===r?void 0:r.title)&&(o.xLabel=e.axis.title),(null===(s=null==t?void 0:t.axis)||void 0===s?void 0:s.title)&&(o.yLabel=t.axis.title)}function vl(e,t,o){const n={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(o.length>0){n.warnings=o;for(const e of o)console.warn("[semiotic/fromVegaLite] "+e)}return n}function ml(){const t=function(){const e=y.useContext(wt);return e?()=>e.setVisible(e=>!e):null}();return t?e.jsx("button",{className:"semiotic-chart-action",onClick:t,title:"Data summary","aria-label":"Toggle data summary",style:jl,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}const bl={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function xl({height:t}){return e.jsx("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:t,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function kl({error:t}){return e.jsx("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:e.jsx("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:t})})}const wl=y.forwardRef(function({title:t,subtitle:o,children:n,width:i="100%",height:r=400,actions:s,chartConfig:a,controls:l,loading:c=!1,error:u,errorBoundary:d=!1,status:h,detailsPanel:g,className:f,style:p},v){const m=y.useRef(null),b=y.useRef(null),[x,k]=y.useState(!1),w=!1!==(null==s?void 0:s.export)&&void 0!==(null==s?void 0:s.export),j=!1!==(null==s?void 0:s.fullscreen)&&void 0!==(null==s?void 0:s.fullscreen),A=!1!==(null==s?void 0:s.copyConfig)&&void 0!==(null==s?void 0:s.copyConfig)&&a,S=!0===(null==s?void 0:s.dataSummary),O="object"==typeof(null==s?void 0:s.export)?s.export:{},M="object"==typeof(null==s?void 0:s.copyConfig)?s.copyConfig.format:"json",C=y.useCallback(e=>Ds(this,void 0,void 0,function*(){b.current&&(yield nl(b.current,Object.assign(Object.assign({},O),e)))}),[O]),_=y.useCallback(()=>{m.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):m.current.requestFullscreen().catch(()=>{}))},[]),P=y.useCallback(e=>Ds(this,void 0,void 0,function*(){a&&(yield cl(a,e||M||"json"))}),[a,M]);y.useEffect(()=>{const e=()=>{k(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),y.useImperativeHandle(v,()=>({export:C,toggleFullscreen:_,copyConfig:P,element:m.current}),[C,_,P]);const L=t||o||l||w||j||A||S||h,T=c?e.jsx(xl,{height:r}):u?e.jsx(kl,{error:u}):d?e.jsx(es,{children:n}):n;return R=e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),e.jsxs("div",{ref:m,className:"semiotic-chart-container"+(f?" "+f:""),style:Object.assign(Object.assign({width:i,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative"},x?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),p),children:[L&&e.jsxs("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[e.jsxs("div",{className:"semiotic-chart-title-area",children:[t&&e.jsx("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:t}),o&&e.jsx("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0},children:o})]}),e.jsxs("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4},children:[l,w&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>C(),title:"Export chart","aria-label":"Export chart",style:jl,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),e.jsx("path",{d:"M2 12h10"})]})}),S&&e.jsx(ml,{}),j&&e.jsx("button",{className:"semiotic-chart-action",onClick:_,title:x?"Exit fullscreen":"Fullscreen","aria-label":x?"Exit fullscreen":"Enter fullscreen",style:jl,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsxs(e.Fragment,x?{children:[e.jsx("path",{d:"M9 1v4h4"}),e.jsx("path",{d:"M5 13V9H1"}),e.jsx("path",{d:"M13 5H9V1"}),e.jsx("path",{d:"M1 9h4v4"})]}:{children:[e.jsx("path",{d:"M1 5V1h4"}),e.jsx("path",{d:"M13 9v4H9"}),e.jsx("path",{d:"M9 1h4v4"}),e.jsx("path",{d:"M5 13H1V9"})]})})}),A&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>P(),title:"Copy config","aria-label":"Copy chart configuration",style:jl,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),e.jsx("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),h&&e.jsx("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:bl[h].bg,color:bl[h].color,lineHeight:"18px"},children:h})]})]}),e.jsxs("div",{className:"semiotic-chart-body",ref:b,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},x?{flex:1}:{height:r}),children:[T,g]})]})]}),S?e.jsx(jt,{children:R}):R;var R}),jl={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Al({children:t,columns:o="auto",minCellWidth:n=300,gap:i=16,className:r,style:s}){const a="number"==typeof o?o:void 0;return e.jsx("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===o?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${o}, 1fr)`,gap:i,width:"100%"},s),children:y.Children.map(t,t=>y.isValidElement(t)?"primary"!==t.props.emphasis||void 0!==a&&2>a?t:e.jsx("div",{style:{gridColumn:"span 2"},children:t}):t)})}function Sl({children:t,context:o,position:n="right",contextSize:i=250,gap:r=12,className:s,style:a}){const l="left"===n||"right"===n,c="left"===n||"top"===n,u=Object.assign({display:"flex",flexDirection:l?c?"row-reverse":"row":c?"column-reverse":"column",gap:r,width:"100%"},a),d=l?{flex:`0 0 ${i}px`,width:i,minHeight:0}:{flex:`0 0 ${i}px`,height:i,minWidth:0};return e.jsxs("div",{className:"semiotic-context-layout"+(s?" "+s:""),style:u,children:[e.jsx("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:t}),e.jsx("div",{style:d,children:o})]})}Al.displayName="ChartGrid",Sl.displayName="ContextLayout";function Ol({children:o,position:n="right",size:i=300,trigger:r="click",chartId:s,observation:a,dismissOnEmpty:l=!0,showClose:c=!0,onToggle:u,className:d,style:h}){const[g,f]=t.useState(null),[p,y]=t.useState(null),[v,m]=t.useState(!1),[b,x]=t.useState(!1),k=t.useRef(null),w=t.useRef(void 0),j="click"===r?["click","click-end"]:["hover","hover-end"],{latest:A}=Or({types:j,chartId:s,limit:1}),S=void 0!==a?a:A;t.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;f(e.datum),y(e),v||(m(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!l||"click-end"!==S.type&&"hover-end"!==S.type||O()},[S]),t.useEffect(()=>{null==u||u(v)},[v,u]);const O=t.useCallback(()=>{x(!0),m(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),f(null),y(null)},200)},[]);if(t.useEffect(()=>()=>clearTimeout(w.current),[]),!g&&!b)return null;const M=g&&p?o(g,p):null;if(null===M&&!b)return null;const C=function(e,t,o,n){const i={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:n?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},i),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:o?"translateX(0)":`translateX(${t}px)`,opacity:o?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:o?"translateY(0)":`translateY(${t}px)`,opacity:o?1:0}:{top:"50%",left:"50%",transform:o?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:o?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,i,v,b);return e.jsxs("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${d?" "+d:""}`,style:Object.assign(Object.assign({},C),h),children:[c&&e.jsx("button",{className:"semiotic-details-close",onClick:O,"aria-label":"Close details",style:Ml,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:M})]})}const Ml={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};Ol.displayName="DetailsPanel";const Cl="__forecastSegment";function _l(e,t){return"function"==typeof t?t(e):!!e[t]}const Pl=Object.freeze({__proto__:null,SEGMENT_FIELD:Cl,buildAnomalyAnnotations:function(e){var t,o,n;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(o=e.bandOpacity)&&void 0!==o?o:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(n=e.anomalyRadius)&&void 0!==n?n:6,label:e.label}]},buildForecast:function(e,t,o,n,i){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,o,n,i){var r,s,a,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:g,color:f="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:v=6,label:m}=n,b=e.map(e=>{let t="observed";return u&&_l(e,u)?t="forecast":c&&_l(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Cl]:t})}),x=n._groupBy,k=[];if(x){const e=new Map;for(const t of b){const o=null!==(r=t[x])&&void 0!==r?r:"__default";e.has(o)||e.set(o,[]),e.get(o).push(t)}const t=[];for(const[,o]of e)for(let e=0;o.length-1>e;e++)o[e][Cl]!==o[e+1][Cl]&&(t.push(Object.assign(Object.assign({},o[e+1]),{[Cl]:o[e][Cl]})),t.push(Object.assign(Object.assign({},o[e]),{[Cl]:o[e+1][Cl]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Cl]!==b[e+1][Cl]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Cl]:b[e][Cl]})),k.push(Object.assign(Object.assign({},b[e]),{[Cl]:b[e+1][Cl]})));if(n.trainUnderline){const e=[];for(const t of k)"training"===t[Cl]&&e.push(Object.assign(Object.assign({},t),{[Cl]:"training-base"}));k.unshift(...e)}const w=[];if(h&&g){const e="string"==typeof h?h:"__envUpper",t="string"==typeof g?g:"__envLower";if("function"==typeof h||"function"==typeof g)for(const o of k)"function"==typeof h&&(o[e]=h(o)),"function"==typeof g&&(o[t]=g(o));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:m})}if(d){const e=n.anomalyStyle,t={type:"highlight",filter:e=>_l(e,d)};e?(t.style=e,t.r=v):"function"==typeof y?(t.style=e=>{const t=y(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=v):(t.color=y,t.r=v,t.style={stroke:y,strokeWidth:1.5,fill:y,fillOpacity:.7}),w.push(t)}return i&&w.push({type:"anomaly-band",threshold:null!==(s=i.threshold)&&void 0!==s?s:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(a=i.bandOpacity)&&void 0!==a?a:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(l=i.anomalyRadius)&&void 0!==l?l:6,label:i.label}),{processedData:k,annotations:w}}(e,0,0,n,i):function(e,t,o,n,i){var r,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=n;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const o of e)o[t]>l?p.push(Object.assign(Object.assign({},o),{[Cl]:"observed"})):f.push(Object.assign(Object.assign({},o),{[Cl]:"training"}));const y=f.map(e=>[e[t],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),v=[],m=[];if(y.length>=3){const n=y.length;let i=0,r=0,s=0,a=0;for(const[e,t]of y)i+=e,r+=t,s+=e*e,a+=e*t;const l=n*s-i*i;if(Math.abs(l)>1e-12){const s=(n*a-i*r)/l,f=(r-s*i)/n,p=e=>f+s*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(n-2,1)),k=y.reduce((e,t)=>e+t[0],0)/n,w=y.reduce((e,t)=>e+Math.pow(t[0]-k,2),0),j=.99>u?.95>u?.9>u?1:1.645:1.96:2.576,A=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...A),O=y.length>1?(y[n-1][0]-y[0][0])/(n-1):1;for(let e=1;c>=e;e++){const i=S+e*O,r=p(i),s=x*Math.sqrt(1+1/n+(w>0?Math.pow(i-k,2)/w:0))*j;m.push({[t]:i,[o]:r,[Cl]:"forecast",__forecastUpper:r+s,__forecastLower:r-s})}v.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:g})}}v.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),i&&v.push({type:"anomaly-band",threshold:null!==(r=i.threshold)&&void 0!==r?r:2,showBand:!1!==i.showBand,fill:i.bandColor||"#6366f1",fillOpacity:null!==(s=i.bandOpacity)&&void 0!==s?s:.1,anomalyColor:i.anomalyColor||"#ef4444",anomalyRadius:null!==(a=i.anomalyRadius)&&void 0!==a?a:6,label:i.label});const b=[];if(b.push(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Cl]:"observed"})),b.push(...p),m.length>0){const e=p.length>0?p[p.length-1]:f[f.length-1];e&&b.push(Object.assign(Object.assign({},e),{[Cl]:"forecast"})),b.push(...m)}return{processedData:b,annotations:v}}(e,t,o,n,i);var r},createSegmentLineStyle:function(e,t){var o,n;const i=null!==(o=t.trainDasharray)&&void 0!==o?o:"8,4",r=null!==(n=t.forecastDasharray)&&void 0!==n?n:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const o=e(t),n=t[Cl];if("training"===n){let e=o.stroke;return"darken"===c?e=tl(o.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:i}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===n){let e=o.stroke||"#666";return"lighten"===d&&(e=ol(e,.4)),Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:void 0})}return"forecast"===n?Object.assign(Object.assign(Object.assign({},o),{stroke:s,strokeDasharray:r}),null!=l&&{strokeOpacity:l}):o}},darkenColor:tl,lightenColor:ol});exports.AreaChart=Fs,exports.BarChart=ca,exports.BoxPlot=ja,exports.BubbleChart=Gs,exports.CARBON_ALERT={danger:"#da1e28",warning:"#f1c21b",success:"#24a148",info:"#0043ce"},exports.CARBON_CATEGORICAL_14=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"],exports.COLOR_BLIND_SAFE_CATEGORICAL=O,exports.CandlestickChart=la,exports.CategoryColorProvider=gr,exports.ChartContainer=wl,exports.ChartErrorBoundary=es,exports.ChartGrid=Al,exports.ChordDiagram=$a,exports.CirclePack=za,exports.ConnectedScatterplot=Is,exports.ContextLayout=Sl,exports.DARK_THEME=C,exports.DetailsPanel=Ol,exports.DonutChart=Pa,exports.DotPlot=Ca,exports.ForceDirectedGraph=Ba,exports.FunnelChart=Ma,exports.GaugeChart=La,exports.GroupedBarChart=Ta,exports.HIGH_CONTRAST_THEME=_,exports.Heatmap=Ys,exports.Histogram=Aa,exports.IncrementalExtent=R,exports.LIGHT_THEME=M,exports.LikertChart=ba,exports.LineChart=Ws,exports.LinkedCharts=Pr,exports.MinimapChart=ta,exports.MultiAxisLineChart=aa,exports.MultiLineTooltip=function(t={}){const{fields:o=[],title:n,format:i,style:r={},className:s="",showLabels:a=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(n){const e=or(t,n);c.push({value:nr(e,i)})}o&&Array.isArray(o)&&o.length>0?o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=nr(or(t,n),r);c.push({label:a?o:void 0,value:s})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:a?e:void 0,value:nr(t[e],i)})});const u=Object.assign(Object.assign({},tr),r);return Array.isArray(c)&&0!==c.length?e.jsx("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+s).trim(),style:u,children:c.map((t,o)=>e.jsxs("div",{style:{marginBottom:c.length-1>o?"4px":0},children:[t.label&&e.jsxs("strong",{children:[t.label,l]}),t.value]},o))}):null}},exports.OrbitDiagram=Ga,exports.PieChart=_a,exports.QuadrantChart=oa,exports.RealtimeHeatmap=Qa,exports.RealtimeHistogram=Va,exports.RealtimeLineChart=qa,exports.RealtimeSwarmChart=Ua,exports.RealtimeTemporalHistogram=Xa,exports.RealtimeWaterfallChart=Ka,exports.RidgelinePlot=Oa,exports.RingBuffer=T,exports.SankeyDiagram=Wa,exports.Scatterplot=Rs,exports.ScatterplotMatrix=Js,exports.StackedAreaChart=zs,exports.StackedBarChart=da,exports.StreamNetworkFrame=er,exports.StreamOrdinalFrame=hn,exports.StreamXYFrame=To,exports.SwarmPlot=ka,exports.SwimlaneChart=Ra,exports.THEME_PRESETS=Br,exports.ThemeProvider=function({theme:t,children:o}){const n="string"==typeof t&&Ir(t)?t:void 0;return e.jsx(P,{children:e.jsxs(Dr.Provider,{value:n,children:[e.jsx(Hr,{theme:t}),e.jsx(Nr,{children:o})]})})},exports.Tooltip=ir,exports.TreeDiagram=Fa,exports.Treemap=Ea,exports.ViolinPlot=Sa,exports.adaptiveTimeTicks=function(e){let t,o=e;return(n,i,r)=>{const s=n instanceof Date?n:new Date(n);e||!r||2>r.length||r===t||(t=r,o=function(e){if(2>e.length)return"days";const t=[];for(let o=1;e.length>o;o++)t.push(e[o]-e[o-1]);t.sort((e,t)=>e-t);const o=t[Math.floor(t.length/2)];return 12e4>o?"seconds":72e5>o?"minutes":2*Za>o?"hours":60*Za>o?"days":400*Za>o?"months":"years"}(r));const a=o||"days";return null!=i&&0!==i&&r&&0!==r.length?function(e,t,o){const n=e.getUTCFullYear()!==t.getUTCFullYear(),i=n||e.getUTCMonth()!==t.getUTCMonth(),r=i||e.getUTCDate()!==t.getUTCDate(),s=r||e.getUTCHours()!==t.getUTCHours(),a=s||e.getUTCMinutes()!==t.getUTCMinutes(),l=el[e.getUTCMonth()],c=e.getUTCDate(),u=e.getUTCFullYear(),d=Ja(e.getUTCHours()),h=Ja(e.getUTCMinutes()),g=Ja(e.getUTCSeconds());switch(o){case"seconds":return n?`${l} ${c}, ${u} ${d}:${h}:${g}`:r?`${l} ${c} ${d}:${h}:${g}`:s?`${d}:${h}:${g}`:a?`${h}:${g}`:":"+g;case"minutes":return n?`${l} ${c}, ${u} ${d}:${h}`:r?`${l} ${c} ${d}:${h}`:s?`${d}:${h}`:":"+h;case"hours":return n?`${l} ${c}, ${u} ${d}:00`:i?`${l} ${c} ${d}:${h}`:r?`${l} ${c} ${d}:00`:d+":00";case"days":return n?`${l} ${c}, ${u}`:i?`${l} ${c}`:""+c;case"months":return n?`${l} ${u}`:""+l;case"years":return""+u}}(s,new Date(r[i-1]),a):function(e,t){const o=el[e.getUTCMonth()],n=e.getUTCDate(),i=e.getUTCFullYear(),r=Ja(e.getUTCHours()),s=Ja(e.getUTCMinutes()),a=Ja(e.getUTCSeconds());switch(t){case"seconds":return`${o} ${n}, ${i} ${r}:${s}:${a}`;case"minutes":case"hours":return`${o} ${n}, ${i} ${r}:${s}`;case"days":return`${o} ${n}, ${i}`;case"months":return`${o} ${i}`;case"years":return""+i}}(s,a)}},exports.configToJSX=ul,exports.copyConfig=cl,exports.createHatchPattern=en,exports.darkenColor=tl,exports.deserializeSelections=function(e){const t=new Map;for(const[o,n]of Object.entries(e)){const e=new Map;for(const t of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:new Set(n.values)}:{type:"interval",range:n.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:o})}t.set(o,{name:n.name,resolution:n.resolution,clauses:e})}return t},exports.exportChart=nl,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!gs[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:ll(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const o=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(escape(atob(o)));return JSON.parse(n)},exports.fromVegaLite=function(e){var t,o,n,i,r,s,a,l,c,u,d,h,g,f;const p=[],{type:y,markProps:v}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}(e,["type"])}}(e.mark),m=e.encoding||{},b=m.x,x=m.y,k=m.color,w=m.size,j=m.theta,A=m.opacity;let S;(null===(t=e.data)||void 0===t?void 0:t.values)?S=e.data.values:(null===(o=e.data)||void 0===o?void 0:o.url)&&p.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&p.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&p.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&p.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||e.encoding&&e.encoding.facet||e.encoding&&(e.encoding.row||e.encoding.column))&&p.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&p.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&p.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const O={};e.width&&(O.width=e.width),e.height&&(O.height=e.height);const M=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(M&&(O.title=M),(null==k?void 0:k.field)&&(O.colorBy=k.field,null===(n=k.scale)||void 0===n?void 0:n.scheme)){const e=gl[k.scale.scheme];e&&(O.colorScheme=e)}void 0!==(null==A?void 0:A.value)&&(O.pointOpacity=A.value);const C=null==b?void 0:b.aggregate,_=null==x?void 0:x.aggregate;if(S&&(C||_)){const e=_?x:b,t=_?b:x,o=pl[e.aggregate];if(o&&(null==t?void 0:t.field)&&e.field)S=function(e,t){const{groupBy:o,value:n,agg:i="sum"}=t,r=new Map;for(const t of e){const e=t[o]+"";r.has(e)||r.set(e,[]),r.get(e).push(Number(t[n]))}const s=[];for(const[e,t]of r){let n;switch(i){case"count":n=t.length;break;case"mean":n=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":n=Math.min(...t);break;case"max":n=Math.max(...t);break;default:n=t.reduce((e,t)=>e+t,0)}s.push({[o]:e,value:n})}return s}(S,{groupBy:t.field,value:e.field,agg:o});else if(("count"===o||"count"===e.aggregate)&&(null==t?void 0:t.field)&&S){const e=new Map;for(const o of S){const n=o[t.field]+"";e.set(n,(e.get(n)||0)+1)}S=Array.from(e,([e,o])=>({[t.field]:e,value:o}))}}if((null==b?void 0:b.bin)||(null==x?void 0:x.bin)){const e="Histogram";S&&(O.data=S),(null==b?void 0:b.bin)?(O.valueAccessor=b.field,(null==x?void 0:x.field)&&(O.categoryAccessor=x.field),(null===(i=b.axis)||void 0===i?void 0:i.title)&&(O.valueLabel=b.axis.title)):(null==x?void 0:x.bin)&&(O.valueAccessor=x.field,(null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null===(r=x.axis)||void 0===r?void 0:r.title)&&(O.valueLabel=x.axis.title));const t="object"==typeof((null==b?void 0:b.bin)||(null==x?void 0:x.bin))?(null===(s=null==b?void 0:b.bin)||void 0===s?void 0:s.maxbins)||(null===(a=null==x?void 0:x.bin)||void 0===a?void 0:a.maxbins):void 0;return t&&(O.bins=t),vl(e,O,p)}let P;switch(y){case"bar":P=function(e,t,o,n,i,r,s){var a,l,c,u,d,h;let g;return(null==o?void 0:o.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",n.stackBy=o.field):g="BarChart",dl(null==e?void 0:e.type)&&hl(null==t?void 0:t.type)?(n.categoryAccessor=e.field,n.valueAccessor=s?"value":t.field,(null===(a=null==e?void 0:e.axis)||void 0===a?void 0:a.title)&&(n.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(n.valueLabel=t.axis.title)):hl(null==e?void 0:e.type)&&dl(null==t?void 0:t.type)?(n.categoryAccessor=t.field,n.valueAccessor=r?"value":e.field,n.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(n.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(n.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(n.categoryAccessor=e.field),(null==t?void 0:t.field)&&(n.valueAccessor=s?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(n.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(n.valueLabel=t.axis.title)),i&&(n.data=i),g}(b,x,k,O,S,C,_);break;case"line":if(P="LineChart",yl(b,x,O,C,_),(null==k?void 0:k.field)&&(O.lineBy=k.field),v.interpolate){const e=fl[v.interpolate];e&&(O.curve=e)}!0===v.point&&(O.showPoints=!0),S&&(O.data=S);break;case"area":if((null==k?void 0:k.field)?(P="StackedAreaChart",O.areaBy=k.field):P="AreaChart",yl(b,x,O,C,_),v.interpolate){const e=fl[v.interpolate];e&&(O.curve=e)}void 0!==v.opacity&&(O.areaOpacity=v.opacity),S&&(O.data=S);break;case"point":case"circle":case"square":(null==w?void 0:w.field)?(P="BubbleChart",O.sizeBy=w.field,(null===(l=w.scale)||void 0===l?void 0:l.range)&&(O.sizeRange=w.scale.range)):P="Scatterplot",yl(b,x,O,C,_),S&&(O.data=S);break;case"rect":P="Heatmap",(null==b?void 0:b.field)&&(O.xAccessor=b.field),(null==x?void 0:x.field)&&(O.yAccessor=x.field),(null==k?void 0:k.field)&&(O.valueAccessor=k.field,delete O.colorBy),(null===(c=null==b?void 0:b.axis)||void 0===c?void 0:c.title)&&(O.xLabel=b.axis.title),(null===(u=null==x?void 0:x.axis)||void 0===u?void 0:u.title)&&(O.yLabel=x.axis.title),S&&(O.data=S);break;case"arc":v.innerRadius&&v.innerRadius>0?(P="DonutChart",O.innerRadius=v.innerRadius):P="PieChart",(null==j?void 0:j.field)?O.valueAccessor=j.field:(null==x?void 0:x.field)&&(O.valueAccessor=_?"value":x.field),(null==k?void 0:k.field)&&(O.categoryAccessor=k.field),(null==b?void 0:b.field)&&!(null==j?void 0:j.field)&&(O.categoryAccessor=b.field),S&&(O.data=S);break;case"tick":P="DotPlot",dl(null==b?void 0:b.type)?(O.categoryAccessor=b.field,(null==x?void 0:x.field)&&(O.valueAccessor=_?"value":x.field),(null===(d=null==b?void 0:b.axis)||void 0===d?void 0:d.title)&&(O.categoryLabel=b.axis.title),(null===(h=null==x?void 0:x.axis)||void 0===h?void 0:h.title)&&(O.valueLabel=x.axis.title)):dl(null==x?void 0:x.type)?(O.categoryAccessor=x.field,(null==b?void 0:b.field)&&(O.valueAccessor=C?"value":b.field),O.orientation="horizontal",(null===(g=null==x?void 0:x.axis)||void 0===g?void 0:g.title)&&(O.categoryLabel=x.axis.title),(null===(f=null==b?void 0:b.axis)||void 0===f?void 0:f.title)&&(O.valueLabel=b.axis.title)):((null==b?void 0:b.field)&&(O.categoryAccessor=b.field),(null==x?void 0:x.field)&&(O.valueAccessor=_?"value":x.field)),S&&(O.data=S);break;default:p.push(`Unsupported mark type "${y}". Defaulting to Scatterplot.`),P="Scatterplot",yl(b,x,O,C,_),S&&(O.data=S)}return vl(P,O,p)},exports.lightenColor=ol,exports.normalizeTooltip=rr,exports.resolveThemePreset=Ir,exports.serializeSelections=function(e){const t={};for(const[o,n]of e){const e=[];for(const[,t]of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:Array.from(n.values)}:{type:"interval",range:n.range};e.push({clientId:t.clientId,type:t.type,fields:o})}t[o]={name:n.name,resolution:n.resolution,clauses:e}}return t},exports.smartTickFormat=function(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),o=Math.abs(t);return 1e9>o?1e6>o?1e4>o?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"},exports.themeToCSS=function(e,t=":root"){var o,n,i,r,s;const a=[];return a.push(` --semiotic-bg: ${e.colors.background};`),a.push(` --semiotic-text: ${e.colors.text};`),a.push(` --semiotic-text-secondary: ${e.colors.textSecondary};`),a.push(` --semiotic-grid: ${e.colors.grid};`),a.push(` --semiotic-border: ${e.colors.border};`),a.push(` --semiotic-primary: ${e.colors.primary};`),a.push(` --semiotic-font-family: ${e.typography.fontFamily};`),e.colors.focus&&a.push(` --semiotic-focus: ${e.colors.focus};`),e.colors.selection&&a.push(` --semiotic-selection-color: ${e.colors.selection};`),null!=e.colors.selectionOpacity&&a.push(` --semiotic-selection-opacity: ${e.colors.selectionOpacity};`),e.colors.diverging&&a.push(` --semiotic-diverging: ${e.colors.diverging};`),(null===(o=e.tooltip)||void 0===o?void 0:o.background)&&a.push(` --semiotic-tooltip-bg: ${e.tooltip.background};`),(null===(n=e.tooltip)||void 0===n?void 0:n.text)&&a.push(` --semiotic-tooltip-text: ${e.tooltip.text};`),(null===(i=e.tooltip)||void 0===i?void 0:i.borderRadius)&&a.push(` --semiotic-tooltip-radius: ${e.tooltip.borderRadius};`),(null===(r=e.tooltip)||void 0===r?void 0:r.fontSize)&&a.push(` --semiotic-tooltip-font-size: ${e.tooltip.fontSize};`),(null===(s=e.tooltip)||void 0===s?void 0:s.shadow)&&a.push(` --semiotic-tooltip-shadow: ${e.tooltip.shadow};`),e.borderRadius&&a.push(` --semiotic-border-radius: ${e.borderRadius};`),e.colors.annotation&&a.push(` --semiotic-annotation-color: ${e.colors.annotation};`),null!=e.typography.legendSize&&a.push(` --semiotic-legend-font-size: ${e.typography.legendSize}px;`),null!=e.typography.titleFontSize&&a.push(` --semiotic-title-font-size: ${e.typography.titleFontSize}px;`),null!=e.typography.tickFontFamily&&a.push(` --semiotic-tick-font-family: ${e.typography.tickFontFamily};`),a.push(` --semiotic-secondary: ${e.colors.secondary||e.colors.primary};`),a.push(` --semiotic-surface: ${e.colors.surface||e.colors.background};`),e.colors.success&&a.push(` --semiotic-success: ${e.colors.success};`),e.colors.danger&&a.push(` --semiotic-danger: ${e.colors.danger};`),e.colors.warning&&a.push(` --semiotic-warning: ${e.colors.warning};`),e.colors.error&&a.push(` --semiotic-error: ${e.colors.error};`),e.colors.info&&a.push(` --semiotic-info: ${e.colors.info};`),`${t} {\n${a.join("\n")}\n}`},exports.themeToTokens=function(e){var t,o,n,i,r,s;return{semiotic:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({bg:{$value:e.colors.background,$type:"color"},text:{$value:e.colors.text,$type:"color"},"text-secondary":{$value:e.colors.textSecondary,$type:"color"},grid:{$value:e.colors.grid,$type:"color"},border:{$value:e.colors.border,$type:"color"},primary:{$value:e.colors.primary,$type:"color"},focus:{$value:e.colors.focus||e.colors.primary,$type:"color"},"font-family":{$value:e.typography.fontFamily,$type:"fontFamily"},"border-radius":{$value:e.borderRadius||"8px",$type:"dimension"},tooltip:{bg:{$value:(null===(t=e.tooltip)||void 0===t?void 0:t.background)||e.colors.background,$type:"color"},text:{$value:(null===(o=e.tooltip)||void 0===o?void 0:o.text)||e.colors.text,$type:"color"},radius:{$value:(null===(n=e.tooltip)||void 0===n?void 0:n.borderRadius)||"6px",$type:"dimension"},"font-size":{$value:(null===(i=e.tooltip)||void 0===i?void 0:i.fontSize)||"14px",$type:"dimension"},shadow:{$value:(null===(r=e.tooltip)||void 0===r?void 0:r.shadow)||"0 2px 8px rgba(0,0,0,0.15)",$type:"shadow"}},selection:{color:{$value:e.colors.selection||e.colors.primary,$type:"color"},opacity:{$value:null!==(s=e.colors.selectionOpacity)&&void 0!==s?s:.2,$type:"number"}},categorical:{$value:e.colors.categorical,$type:"color",$description:"Categorical color palette"},sequential:{$value:e.colors.sequential,$type:"string",$description:"d3-scale-chromatic sequential scheme name"}},e.colors.diverging?{diverging:{$value:e.colors.diverging,$type:"string",$description:"d3-scale-chromatic diverging scheme name"}}:{}),e.colors.annotation?{"annotation-color":{$value:e.colors.annotation,$type:"color"}}:{}),null!=e.typography.legendSize?{"legend-font-size":{$value:e.typography.legendSize+"px",$type:"dimension"}}:{}),null!=e.typography.titleFontSize?{"title-font-size":{$value:e.typography.titleFontSize+"px",$type:"dimension"}}:{}),null!=e.typography.tickFontFamily?{"tick-font-family":{$value:e.typography.tickFontFamily,$type:"fontFamily"}}:{}),{secondary:{$value:e.colors.secondary||e.colors.primary,$type:"color"},surface:{$value:e.colors.surface||e.colors.background,$type:"color"}}),e.colors.success?{success:{$value:e.colors.success,$type:"color"}}:{}),e.colors.danger?{danger:{$value:e.colors.danger,$type:"color"}}:{}),e.colors.warning?{warning:{$value:e.colors.warning,$type:"color"}}:{}),e.colors.error?{error:{$value:e.colors.error,$type:"color"}}:{}),e.colors.info?{info:{$value:e.colors.info,$type:"color"}}:{})}},exports.toConfig=function(e,t,o){if(!gs[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(gs).join(", ")}`);const n=!1!==(null==o?void 0:o.includeData),i={};for(const[e,o]of Object.entries(t))null!=o&&(sl.has(e)||!n&&al.has(e)||"function"!=typeof o&&((null==o?void 0:o.$$typeof)||(i[e]=ll(o))));return Object.assign({component:e,props:i,version:"1",createdAt:(new Date).toISOString()},(null==o?void 0:o.selections)?{selections:o.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=Sr,exports.useCategoryColors=fr,exports.useChartObserver=Or,exports.useFilteredData=function(e,o,n){const i=br(e=>e.selections.get(o));return t.useMemo(()=>{if(!i||0===i.clauses.size)return e;const t=yr(i,n);return e.filter(t)},[e,i,n])},exports.useLinkedHover=jr,exports.useSelection=wr,exports.useTheme=$r;
|