semiotic 3.10.2 → 3.10.3
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/README.md +23 -27
- package/ai/artifact-surface-inventory.json +1 -1
- package/ai/behaviorContracts.cjs +1 -1
- package/ai/dist/mcp-server.js +1 -1
- package/ai/reference.md +4 -4
- package/ai/schema.json +1 -1
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/ai/task-packets/compare-category-totals.json +4 -4
- package/ai/task-packets/compare-category-totals.md +2 -2
- package/ai/task-packets/correct-published-chart.json +4 -4
- package/ai/task-packets/correct-published-chart.md +2 -2
- package/ai/task-packets/index.json +6 -6
- package/ai/task-packets/update-live-chart.json +4 -4
- package/ai/task-packets/update-live-chart.md +2 -2
- package/dist/{c-AKLBQMQF.min.js → c-43XNOQNQ.min.js} +50 -50
- package/dist/{c-PZ3NEGNG.min.js → c-5PIKBUMF.min.js} +1 -1
- package/dist/{c-FDUQDCBC.min.js → c-CO4NDAD6.min.js} +23 -23
- package/dist/c-FHNY57SO.min.js +209 -0
- package/dist/c-FMCUQ6JX.min.js +1 -0
- package/dist/{c-C4KIXUWU.min.js → c-GK263BF4.min.js} +1 -1
- package/dist/{c-TTKWXGAI.min.js → c-HNHKIMIV.min.js} +3 -3
- package/dist/c-IJCZGUG6.min.js +31 -0
- package/dist/{c-7LY46QUI.min.js → c-ISA6IJ6V.min.js} +7 -7
- package/dist/{c-4MD53L2J.min.js → c-JC76YAHB.min.js} +28 -28
- package/dist/{c-VXIYF7V2.min.js → c-JOPGDP6N.min.js} +1 -1
- package/dist/c-KXH7LFIL.min.js +26 -0
- package/dist/c-M43PK7K4.min.js +1 -0
- package/dist/{c-7ASK4WBF.min.js → c-PITYSOPK.min.js} +1 -1
- package/dist/{c-2TW5H5PD.min.js → c-QPO24R7Q.min.js} +1 -1
- package/dist/{c-KGROWFT2.min.js → c-SAP5KY6R.min.js} +2 -2
- package/dist/c-UMGHCBH5.min.js +114 -0
- package/dist/{c-6ZU3QVLB.min.js → c-VEMCBQZZ.min.js} +33 -33
- package/dist/{c-IPYGNVN6.min.js → c-WD2RL76M.min.js} +45 -45
- package/dist/{c-PQOZPM4G.min.js → c-YL7HJL5J.min.js} +1 -1
- package/dist/c-Z6GRGS53.min.js +1 -0
- package/dist/{c-SG2Y7EBY.min.js → c-ZVOFLE2P.min.js} +6 -6
- package/dist/components/CategoryColors.d.ts +7 -0
- package/dist/components/LinkedCharts.d.ts +2 -1
- package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -1
- package/dist/components/data/transforms.d.ts +1 -0
- package/dist/geo.min.js +3 -3
- package/dist/geo.module.min.js +10 -10
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +7 -7
- package/dist/semiotic-artifact.min.js +1 -1
- package/dist/semiotic-artifact.module.min.js +1 -1
- package/dist/semiotic-atlas-selection.module.min.js +1 -1
- package/dist/semiotic-client-cjs-shared.min.js +903 -902
- package/dist/semiotic-data.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental-auxiliary.module.min.js +2 -2
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +2 -2
- package/dist/semiotic-line.module.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-server-edge-node.module.min.js +65 -65
- package/dist/semiotic-server-edge.min.js +64 -64
- package/dist/semiotic-server-edge.module.min.js +80 -80
- package/dist/semiotic-server-node.min.js +64 -64
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic.module.min.js +10 -10
- package/dist/server.min.js +64 -64
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +5 -5
- package/dist/c-72CBVNYX.min.js +0 -209
- package/dist/c-F2GGJB2S.min.js +0 -31
- package/dist/c-G53AVC42.min.js +0 -113
- package/dist/c-HQ27AHMC.min.js +0 -1
- package/dist/c-IHWZ2C6D.min.js +0 -26
- package/dist/c-MOP2NGLH.min.js +0 -1
- package/dist/c-PKY4JFY5.min.js +0 -1
package/dist/server.min.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
async function e(e,t,i,n){const{format:o="png",scale:r=1}=n;let s;try{const e="sharp",t=await(import(e));s=t.default??t}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const a=s(void 0!==globalThis.Buffer?globalThis.Buffer.from(e):(new TextEncoder).encode(e),{density:72*r}).resize(Math.round(t*r),Math.round(i*r));return"jpeg"===o?a.jpeg({quality:90}).toBuffer():a.png().toBuffer()}async function t(e,t,i,n={}){const{fps:o=12,loop:r=!0,scale:s=1}=n,a=Math.round(t*s),c=Math.round(i*s);let l,u,d,h;try{const e="sharp",t=await(import(e));l=t.default??t}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const e="gifenc",t=await(import(e)),i=[t,t.default].find(e=>"function"==typeof e?.GIFEncoder&&"function"==typeof e.quantize&&"function"==typeof e.applyPalette);if(!i)throw Error("gifenc did not expose its encoder functions");u=i.GIFEncoder,d=i.quantize,h=i.applyPalette}catch(e){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:e})}const p=Math.round(1e3/o),f=u();for(let t=0;e.length>t;t++){const i=e[t],n=await l(Buffer.from(i),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),u=d(o,256),y=h(o,u);f.writeFrame(y,a,c,{palette:u,delay:p,repeat:r?0:-1})}return f.finish(),Buffer.from(f.bytes())}function i(e){const t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),n=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:n,rightAxis:o,xAxis:t??i,yAxis:n??o,xOrient:t||!i?"bottom":"top",yOrient:n||!o?"left":"right"}}function n(e){let t=6;for(let i=1;e.length>i;i++){const n=Math.abs(e[i]-e[i-1]);n>0&&Number.isFinite(n)&&(t=Math.max(t,Math.ceil(Math.log10(Math.max(Math.abs(e[i]),Math.abs(e[i-1]))/n))+1))}const i=Math.min(17,t);return e=>Number.isInteger(e)?e+"":Number(e.toPrecision(i))+""}function o(...e){let t;for(const i of e)i&&(t=r(t)&&r(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function s(e){return"object"==typeof e&&null!==e&&"gradient"in e}function a(e){return"string"==typeof e&&e.length>0}function c(e,t,i=!1){const n=i?t?rw:ow:t?nw:0;return n>e.top?{...e,top:n}:e}function l(e,t){return c(e,a(t))}function u(e,t,i,n,o=8){const r=n,s="left"===n?"right":"right"===n?"left":"top"===n?"bottom":"top",a=Math.max(t[r],Math.max(0,("left"===n||"right"===n?i[0]:i[1])-o)-e[s]);e[r]>a&&(e[r]=a)}function d(e){return Math.ceil(7*e.length)}function h(e,t){if(r(e)){const i=A(t);let n=dw;for(const t of e.legendGroups){t.label&&(n=Math.max(n,d(t.label)));for(const e of t.items)n=Math.max(n,i.swatchSize+i.labelGap+d(e.label))}return n}if(s(e)){const{gradient:t}=e,i=t.format||n(t.domain),o=Math.max(d(i(t.domain[0])),d(i(t.domain[1]))),r=t.label?d(t.label):0;return Math.max(dw,19+o,r)}return dw}function p(e){return(r(e)||s(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):hw}function f(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?kw:ww:0}function y(e){return Math.max(0,e?.edgeGutter??pw)}function g(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?vw:bw:xw:0}function m(e){const{bottomAxis:t,topAxis:n,leftAxis:o,rightAxis:r}=i(e.axes),s=!(n&&!t||!1===t?.visible),a=!!n&&!t&&!1!==n.visible,c=!(r&&!o||!1===o?.visible),l=!!r&&!1!==r.visible,u=!1!==e.showAxes;return{hasAxis:u&&s,hasAxisLabel:u&&s&&!!(t?.label??e.xLabel),rotatedTicks:u&&s&&(e.rotatedTicks??!!t?.autoRotate),topAxis:a?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??e.xLabel),rotatedTicks:u&&(e.rotatedTicks??!!n?.autoRotate)}:void 0,leftAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??e.yLabel)}:void 0,rightAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??e.yLabelRight??e.yLabel)}:void 0}}function x(e){const t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}function b(e,t,i){if(s(e))return e.gradient.label?gw:mw;if(!r(e))return 20;const n=A(i),o=Math.max(1,i?.maxWidth??t);let a=n.rowHeight;for(const t of e.legendGroups){let e=0,i=0;for(const r of t.items){const t=n.swatchSize+n.labelGap+d(r.label),s=0===i?t:i+n.itemGap+t;i>0&&s>o?(e+=1,i=t):i=s}t.items.length>0&&(e+=1),a=Math.max(a,e*n.rowHeight,t.label?d(t.label):0)}return a+(e.legendGroups.length>1?16:0)}function v(e,t,i){return h(e,t)+p(e)+f(t,i)+y(t)}function w(e,t){const{legend:i}=t;if(!i)return;const n=t.position??"right",o=b(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+p(i)+g("bottom"===n?t.axisChrome:"top"===n?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===n&&t.hasTitle?24:0),r=Math.max(t.minimumMargin??0,"top"===n?t.hasTitle?rw:ow:0);"right"===n?e.right=Math.max(e.right,r,v(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===n?e.left=Math.max(e.left,r,v(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===n?e.top=Math.max(e.top,r,o):e.bottom=Math.max(e.bottom,r,o)}function k(e,t){const i=t.position??"right",n="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),r=Math.max(1,n?t.legendLayout?.maxWidth??o:t.reservedWidth??h(e,t.legendLayout)),s=p(e),a=f(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),c=y(t.legendLayout),l=b(e,o,t.legendLayout),u=g(t.axisChrome,t.legendLayout),d=g(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(c,t.margin.left-a-r-s),y:t.margin.top,width:r,height:l};if("top"===i)return{x:t.margin.left,y:t.margin.top-d-s-l,width:r,height:l};if("bottom"===i){const e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+s,Math.min(e+u+s,t.totalHeight-l)),width:r,height:l}}return{x:Math.min(t.totalWidth-r-c,t.totalWidth-t.margin.right+a+s),y:t.margin.top,width:r,height:l}}function A(e){const t=Math.max(1,e?.swatchSize??aw),i=Math.max(t,e?.rowHeight??uw);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??cw),itemGap:Math.max(0,e?.itemGap??lw),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function S(e,t){let i=24;return e.map(({hasLabel:e,itemCount:n})=>{i+=5;const o=i;let r;i+=8,e&&(i+=16,r=i,i+=8);const s=i;return i+=n*t+8,{lineY:o,labelY:r,itemsY:s,endY:i}})}function M(e,t,i=!1){const n={...e};for(const e of t??[])!1!==e.visible||"top"===e.orient&&i||(n[e.orient]=0);return n}function _(e){let t=0;for(;e.length>t;){const i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);const n=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(n){const i=e.indexOf(n,t+2);if(0>i)return;t=i+n.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",n=0,o=t+9;for(;e.length>o;o+=1){const t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){const t=e.indexOf("--\x3e",o+4);if(0>t)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)n+=1;else if("]"===t)n-=1;else if(">"===t&&0===n)break}if(o===e.length)return;t=o+1;continue}break}const i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;const n=i[2].endsWith("/"),o=n?i[2].slice(0,-1):i[2];return o.replace(Aw,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:n}}function $(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function P(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];const i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&1114111>=i?String.fromCodePoint(i):e})}function j(e,t){for(const i of e.attributes.matchAll(Aw))if(i[1]===t)return P(i[2]??i[3])}function I(e,t){const i=_(e)?.start??0;return e.slice(0,i)+e.slice(i).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,i)=>i?e.replace(Aw,(e,i,n,o)=>{const r=t(i,P(n??o));return void 0===r?e:` ${i}="${$(r)}"`}):e)}function L(e,t){const i=_(e);if(!i)return e;const n=new Map(Object.entries(t));let o=i.attributes.replace(Aw,(e,t)=>{const i=n.get(t);return void 0===i?e:(n.delete(t),` ${t}="${$(i)}"`)});for(const[e,t]of n)o+=` ${e}="${$(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function R(e,t){const i=_(e);if(!i)return t;const n=e=>{const n=j(i,e),o=n&&/^[0-9]+(?:\.[0-9]+)?$/.test(n)?Number(n):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:n("width"),height:n("height")}}function C(e,t){const i=_(e);return i?L(e,{width:"100%",height:"100%",...void 0===j(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===j(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function T(e){return null==e?"null":Array.isArray(e)?`[${e.map(T).join(",")}]`:e instanceof Date?JSON.stringify(e):"object"==typeof e?`{${Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>t>e?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${T(t)}`).join(",")}}`:JSON.stringify(e)}function O(e){const t=[..._w],i=Array.from((new TextEncoder).encode(e)),n=8*i.length;for(i.push(128);i.length%64!=56;)i.push(0);const o=Math.floor(n/4294967296),r=n>>>0;i.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o,r>>>24&255,r>>>16&255,r>>>8&255,255&r);const s=[];for(let e=0;i.length>e;e+=4)s.push((i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0);for(let e=0;s.length>e;e+=16){const i=[...s.slice(e,e+16)];for(let e=16;64>e;e+=1){const t=Sw(i[e-15],7)^Sw(i[e-15],18)^i[e-15]>>>3,n=Sw(i[e-2],17)^Sw(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+n>>>0}let[n,o,r,a,c,l,u,d]=t;for(let e=0;64>e;e+=1){const t=d+(Sw(c,6)^Sw(c,11)^Sw(c,25))+(c&l^~c&u)+$w[e]+i[e]>>>0,s=n&o^n&r^o&r;d=u,u=l,l=c,c=a+t>>>0,a=r,r=o,o=n,n=t+((Sw(n,2)^Sw(n,13)^Sw(n,22))+s>>>0)>>>0}const h=[n,o,r,a,c,l,u,d];for(let e=0;8>e;e+=1)t[e]=t[e]+h[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function E(e,t){return`${e}[Symbol(${t.description??""})]`}function F(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function N(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function z(e){return e.sort((e,t)=>{const i=JSON.stringify(e),n=JSON.stringify(t);return n>i?-1:i>n?1:0})}function D(e,t,i){if(null===e)return null;if(e instanceof Date){const n=e.getTime();return Number.isFinite(n)?{$type:"date",value:e.toISOString()}:void i.excluded.push(t)}switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isNaN(e)?{$type:"number",value:"NaN"}:e===1/0?{$type:"number",value:"Infinity"}:e===-1/0?{$type:"number",value:"-Infinity"}:Object.is(e,-0)?{$type:"number",value:"-0"}:e;case"bigint":return{$type:"bigint",value:""+e};case"undefined":case"function":case"symbol":return void i.excluded.push(t);case"object":{const n=e;if(i.ancestors.has(n))return void i.excluded.push(t);i.ancestors.add(n);try{if(Array.isArray(e)){for(const n of Reflect.ownKeys(e))"length"===n||"string"==typeof n&&F(n,e.length)||i.excluded.push("symbol"==typeof n?E(t,n):N(t,n));return Array.from({length:e.length},(n,o)=>{const r=N(t,o),s=Object.getOwnPropertyDescriptor(e,o+"");if(!s||!("value"in s)||!s.enumerable)return i.excluded.push(r),null;const a=D(s.value,r,i);return void 0===a?null:a})}const n={},o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return void i.excluded.push(t);const r=[];for(const n of Reflect.ownKeys(e)){if("symbol"==typeof n){i.excluded.push(E(t,n));continue}const o=Object.getOwnPropertyDescriptor(e,n);o&&"value"in o&&o.enumerable?r.push(n):i.excluded.push(N(t,n))}for(const o of r.sort()){const r=Object.getOwnPropertyDescriptor(e,o),s=D(r&&"value"in r?r.value:void 0,N(t,o),i);void 0!==s&&Object.defineProperty(n,o,{value:s,enumerable:!0,configurable:!0,writable:!0})}return n}finally{i.ancestors.delete(n)}}default:return void i.excluded.push(t)}}function B(e,t=/* @__PURE__ */new Set){if(null===e)return["null"];if(e instanceof Date)return Number.isFinite(e.getTime())?["date",e.toISOString()]:["excluded"];switch(typeof e){case"string":return["string",e];case"boolean":return["boolean",e];case"number":return["number",Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Object.is(e,-0)?"-0":e+""];case"bigint":return["bigint",""+e];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(t.has(e))return["excluded"];t.add(e);try{const i=i=>{const n="symbol"==typeof i?["symbol-key",i.description??""]:["string-key",i],o=Object.getOwnPropertyDescriptor(e,i);return o?"value"in o?[n,"data",!!o.enumerable,B(o.value,t)]:[n,"accessor",!!o.enumerable,!!o.get,!!o.set]:[n,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,n)=>{const o=n+"";return Object.prototype.hasOwnProperty.call(e,o)?i(o):["hole"]}),z(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&F(t,e.length))).map(i))];const n=Object.getPrototypeOf(e);return[n!==Object.prototype&&null!==n?"non-json-object":"object",z(Reflect.ownKeys(e).map(i))]}finally{t.delete(e)}default:return["excluded"]}}function W(e){const t={excluded:[],ancestors:/* @__PURE__ */new Set},i=D(e,"$",t)??null;return{value:i,text:JSON.stringify(i),excludedPaths:t.excluded}}function Y(e){const t=W(e),i=O(JSON.stringify(["semiotic-value-fingerprint","v2",B(e)]));return{...t,algorithm:"sha256",digest:i,fingerprint:"sha256:"+i}}function q(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function X(e,t){return`${e}[Symbol(${t.description??""})]`}function G(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function V(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function H(e,t,i,n){const o=V(e,t);return o&&"value"in o&&o.enumerable?U(o.value,i,n):[i]}function U(e,t="$",i=/* @__PURE__ */new Set){if(null===e||"string"==typeof e||"boolean"==typeof e)return[];if("number"==typeof e)return Number.isFinite(e)&&!Object.is(e,-0)?[]:[t];if("object"!=typeof e)return[t];if(i.has(e))return[t];let n,o,r;try{r=Array.isArray(e),n=Object.getPrototypeOf(e),o=Reflect.ownKeys(e)}catch{return[t]}if(n!==(r?Array.prototype:Object.prototype)&&null!==n)return[t];i.add(e);const s=[];try{if(r){const n=V(e,"length")?.value;if(!Number.isSafeInteger(n)||0>n)return[q(t,"length")];for(const e of o)"length"===e||"string"==typeof e&&G(e,n)||s.push("symbol"==typeof e?X(t,e):q(t,e));for(let o=0;n>o;o+=1)s.push(...H(e,o+"",q(t,o),i))}else for(const n of o)"symbol"!=typeof n?s.push(...H(e,n,q(t,n),i)):s.push(X(t,n));return s}catch{return[t]}finally{i.delete(e)}}function K(e,t,i,n){ne(e,Object.keys(t),i,n);for(const[o,r]of Object.entries(t))r.values?(r.required||void 0!==e[o])&&re(e,o,i,r.values,n):r.required?oe(e,o,i,n):ue(e,o,i,n)}function Z(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Q(e,t,i,n){void 0===e[t]||"number"==typeof e[t]&&Number.isFinite(e[t])||n.push({path:`${i}.${t}`,message:"Expected a finite number."})}function J(e,t,i,n){void 0!==e[t]&&"boolean"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a boolean."})}function ee(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(ee):Z(e)&&Object.values(e).every(ee))}function te(e,t,i,n){void 0===e[t]||Z(e[t])&&ee(e[t])||n.push({path:`${i}.${t}`,message:"Expected a JSON object."})}function ie(e){return e.every(ee)}function ne(e,t,i,n){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||n.push({path:`${i}.${t}`,message:"Unexpected property."})}function oe(e,t,i,n){"string"==typeof e[t]&&e[t]||n.push({path:`${i}.${t}`,message:"Expected a non-empty string."})}function re(e,t,i,n,o){"string"==typeof e[t]&&n.includes(e[t])||o.push({path:`${i}.${t}`,message:`Expected one of: ${n.join(", ")}.`})}function se(e,t,i,n){const o=e[t];if(void 0!==o){if(Z(o))return o;n.push({path:`${i}.${t}`,message:"Expected an object."})}}function ae(e,t,i,n){const o=e[t];if(void 0!==o){if(Array.isArray(o))return o;n.push({path:`${i}.${t}`,message:"Expected an array."})}}function ce(e,t,i){e?.some(e=>"string"!=typeof e||!e)&&i.push({path:t,message:"Expected non-empty string values."})}function le(e,t,i,n,o){void 0!==e[t]&&re(e,t,i,n,o)}function ue(e,t,i,n){void 0!==e[t]&&"string"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a string."})}function de(e,t,i){Z(e)?(ne(e,["id","name","kind"],t,i),oe(e,"kind",t,i),ue(e,"id",t,i),ue(e,"name",t,i)):i.push({path:t,message:"Expected an actor object."})}function he(e,t){const i=se(e,"reception","$",t);if(!i)return;ne(i,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);const n=ae(i,"channels","$.reception",t);n||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),n?.forEach((e,i)=>{const n=`$.reception.channels[${i}]`;Z(e)?(ne(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],n,t),re(e,"channel",n,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),le(e,"disclosure",n,["summary","standard","detailed"],t),le(e,"rawData",n,["deny","bounded","allow"],t),J(e,"navigation",n,t),J(e,"interactionInstructions",n,t),Q(e,"tokenBudget",n,t),ce(ae(e,"privacyNotes",n,t),n+".privacyNotes",t)):t.push({path:n,message:"Expected a channel object."})});for(const e of["strengths","risks","scaffolds","manualChecks"])ce(ae(i,e,"$.reception",t),"$.reception."+e,t);ue(i,"audience","$.reception",t),ue(i,"description","$.reception",t),J(i,"dataFallback","$.reception",t)}function pe(e,t){const i=se(e,"form","$",t);i&&(ne(i,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),ue(i,"chartFamily","$.form",t),ue(i,"whyThisForm","$.form",t),ce(ae(i,"risks","$.form",t),"$.form.risks",t),ce(ae(i,"misuse","$.form",t),"$.form.misuse",t),ae(i,"rejectedAlternatives","$.form",t)?.forEach((e,i)=>{const n=`$.form.rejectedAlternatives[${i}]`;Z(e)?(ne(e,["representation","reason"],n,t),oe(e,"representation",n,t),oe(e,"reason",n,t)):t.push({path:n,message:"Expected an alternative object."})}))}function fe(e,t){const i=se(e,"contestability","$",t);i&&(ne(i,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),J(i,"sourceRequestsAllowed","$.contestability",t),ae(i,"challenges","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.challenges[${i}]`;if(Z(e)){ne(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],n,t),oe(e,"id",n,t),oe(e,"claimId",n,t),oe(e,"reason",n,t),re(e,"status",n,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&de(e.raisedBy,n+".raisedBy",t);for(const i of["raisedAt","counterclaimId","resolution"])ue(e,i,n,t)}else t.push({path:n,message:"Expected a challenge object."})}),ae(i,"corrections","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.corrections[${i}]`;if(!Z(e))return void t.push({path:n,message:"Expected a correction object."});ne(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],n,t),oe(e,"id",n,t),oe(e,"reason",n,t);const o=ae(e,"affectedClaimIds",n,t);o||t.push({path:n+".affectedClaimIds",message:"Expected an affected-claim array."}),ce(o,n+".affectedClaimIds",t),ce(ae(e,"replacementClaimIds",n,t),n+".replacementClaimIds",t),ue(e,"createdAt",n,t),void 0!==e.createdBy&&de(e.createdBy,n+".createdBy",t)}),ae(i,"alternativeViews","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.alternativeViews[${i}]`;Z(e)?(ne(e,["id","label","rationale"],n,t),oe(e,"id",n,t),oe(e,"label",n,t),ue(e,"rationale",n,t)):t.push({path:n,message:"Expected an alternative-view object."})}),ae(i,"editorialExceptions","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.editorialExceptions[${i}]`;Z(e)?(ne(e,["ruleId","rationale","owner","reviewAt"],n,t),oe(e,"ruleId",n,t),oe(e,"rationale",n,t),ue(e,"owner",n,t),ue(e,"reviewAt",n,t)):t.push({path:n,message:"Expected an editorial-exception object."})}))}function ye(e,t){const i=se(e,"accountability","$",t);i&&(ne(i,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),ae(i,"authors","$.accountability",t)?.forEach((e,i)=>de(e,`$.accountability.authors[${i}]`,t)),ce(ae(i,"dataSources","$.accountability",t),"$.accountability.dataSources",t),ue(i,"generatedBy","$.accountability",t),ue(i,"codeRef","$.accountability",t),ae(i,"reviews","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.reviews[${i}]`;if(Z(e)){ne(e,["id","status","reviewer","reviewedAt","rationale","policyId"],n,t),oe(e,"id",n,t),re(e,"status",n,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&de(e.reviewer,n+".reviewer",t);for(const i of["reviewedAt","rationale","policyId"])ue(e,i,n,t)}else t.push({path:n,message:"Expected a review object."})}),ae(i,"actions","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.actions[${i}]`;if(!Z(e))return void t.push({path:n,message:"Expected an action object."});ne(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],n,t),oe(e,"id",n,t),oe(e,"action",n,t);const o=ae(e,"claimIds",n,t);o||t.push({path:n+".claimIds",message:"Expected a claim identifier array."}),ce(o,n+".claimIds",t),void 0!==e.actor&&de(e.actor,n+".actor",t);for(const i of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])ue(e,i,n,t);le(e,"status",n,["proposed","taken","reversed","invalidated"],t)}))}function ge(e,t){const i=se(e,"inheritance","$",t);if(i){ne(i,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(const e of["requiredPaths","prohibitedExports","sourceArtifactIds"])ce(ae(i,e,"$.inheritance",t),"$.inheritance."+e,t);le(i,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),le(i,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),le(i,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function me(e,t){he(e,t),pe(e,t),fe(e,t),ye(e,t),ge(e,t)}function xe(e){for(const t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function be(e,t){if(void 0===e||Z(e)){if(Z(e))for(const[i,n]of Object.entries(e)){const e="$.fieldStatus."+i;if(!Z(n)||"string"!=typeof n.status){t.push({path:e,message:"Expected a field state with a status."});continue}ne(n,["status","reason","suppliedBy","derived","reviewedBy"],e,t),["known","unknown","manual","not-applicable"].includes(n.status)||t.push({path:e+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0===n.suppliedBy||"string"==typeof n.suppliedBy&&["author","system","model-proposal","import"].includes(n.suppliedBy)||t.push({path:e+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),ue(n,"reason",e,t),ue(n,"reviewedBy",e,t),J(n,"derived",e,t);const o=Object.prototype.hasOwnProperty.call(jw,i)?jw[i]:void 0,r="model-proposal"===n.suppliedBy,s=r&&!0===o?.modelMayPropose&&"known"!==n.status;o&&"known"===n.status&&"string"!=typeof n.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${i}" must identify an allowed supplier.`}),!o||"string"!=typeof n.suppliedBy||s||o.suppliedBy.includes(n.suppliedBy)||t.push({path:e+".suppliedBy",message:`Field "${i}" cannot be supplied by ${n.suppliedBy}.`}),o&&!0===n.derived&&!o.derivable&&t.push({path:e+".derived",message:`Field "${i}" cannot be marked as derived.`}),!o||!r||o.modelMayPropose&&"known"!==n.status||t.push({path:e+".suppliedBy",message:"known"===n.status?`A model proposal cannot finalize field "${i}" as known.`:`Field "${i}" does not accept model proposals.`}),"required"!==o?.humanReview||"known"!==n.status||"string"==typeof n.reviewedBy&&n.reviewedBy.trim()||t.push({path:e+".reviewedBy",message:`Known field "${i}" requires an attributable human review.`})}}else t.push({path:"$.fieldStatus",message:"Expected a field-state object."})}function ve(e,t){const i="$.time";ne(e,[...Rw,...Object.keys(Cw),"sources"],i,t);for(const n of Rw)ue(e,n,i,t);for(const[n,o]of Object.entries(Cw)){const r=se(e,n,i,t);r&&K(r,o,`${i}.${n}`,t)}ae(e,"sources",i,t)?.forEach((e,n)=>{const o=`${i}.sources[${n}]`;Z(e)?K(e,Tw,o,t):t.push({path:o,message:"Expected a source object."})})}function we(e){try{return ke(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function ke(e){const t=[],i=[];if(!Z(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:i};const n=U(e);if(n.length>0)return{valid:!1,errors:n.map(e=>({path:e,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:i};if(ne(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),e.contractVersion!==Pw&&t.push({path:"$.contractVersion",message:`Expected contract version ${Pw}.`}),Z(e.artifact)){ne(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),oe(e.artifact,"id","$.artifact",t),re(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(const i of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])ue(e.artifact,i,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(Z(e.purpose))if(Array.isArray(e.purpose.intents)){ne(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,i)=>{Z(e)&&"string"==typeof e.id&&e.id||t.push({path:`$.purpose.intents[${i}].id`,message:"Expected a non-empty intent identifier."}),Z(e)&&ne(e,["id","strength","source","rationale"],`$.purpose.intents[${i}]`,t),Z(e)&&void 0!==e.strength&&re(e,"strength",`$.purpose.intents[${i}]`,["primary","secondary"],t),Z(e)&&(le(e,"source",`$.purpose.intents[${i}]`,["author","derived","model-proposal","import"],t),ue(e,"rationale",`$.purpose.intents[${i}]`,t))});for(const i of["allowedUses","prohibitedUses"])ce(ae(e.purpose,i,"$.purpose",t),"$.purpose."+i,t);le(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),ue(e.purpose,"communicativeAct","$.purpose",t),ue(e.purpose,"decisionContext","$.purpose",t)}else t.push({path:"$.purpose.intents",message:"Expected an intent array."});else t.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(e.claims)?e.claims.forEach((e,i)=>{if(!Z(e))return void t.push({path:`$.claims[${i}]`,message:"Expected a claim object."});ne(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${i}]`,t),oe(e,"id",`$.claims[${i}]`,t),re(e,"kind",`$.claims[${i}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),re(e,"status",`$.claims[${i}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],t),Array.isArray(e.evidenceIds)?e.evidenceIds.some(e=>"string"!=typeof e||!e)&&t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected an evidence identifier array."}),ce(ae(e,"supersedes",`$.claims[${i}]`,t),`$.claims[${i}].supersedes`,t),ue(e,"text",`$.claims[${i}]`,t),ue(e,"asOf",`$.claims[${i}]`,t),te(e,"scope",`$.claims[${i}]`,t),ce(ae(e,"tags",`$.claims[${i}]`,t),`$.claims[${i}].tags`,t),void 0!==e.authoredBy&&de(e.authoredBy,`$.claims[${i}].authoredBy`,t);const n=se(e,"review",`$.claims[${i}]`,t);n&&(ne(n,["status","reviewer","reviewedAt","rationale"],`$.claims[${i}].review`,t),re(n,"status",`$.claims[${i}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==n.reviewer&&de(n.reviewer,`$.claims[${i}].review.reviewer`,t),ue(n,"reviewedAt",`$.claims[${i}].review`,t),ue(n,"rationale",`$.claims[${i}].review`,t));const o=se(e,"uncertainty",`$.claims[${i}]`,t);if(o){ne(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${i}].uncertainty`,t),re(o,"kind",`$.claims[${i}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(const e of["lower","upper","confidence"])Q(o,e,`$.claims[${i}].uncertainty`,t);ue(o,"unit",`$.claims[${i}].uncertainty`,t),ue(o,"description",`$.claims[${i}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,i)=>{if(!Z(e))return void t.push({path:`$.evidence[${i}]`,message:"Expected an evidence object."});ne(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${i}]`,t),oe(e,"id",`$.evidence[${i}]`,t),re(e,"role",`$.evidence[${i}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(const n of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])ue(e,n,`$.evidence[${i}]`,t);te(e,"scope",`$.evidence[${i}]`,t);const n=se(e,"source",`$.evidence[${i}]`,t);if(n){ne(n,["name","uri","version","retrievedAt","publisher"],`$.evidence[${i}].source`,t);for(const e of["name","uri","version","retrievedAt","publisher"])ue(n,e,`$.evidence[${i}].source`,t)}const o=se(e,"transformation",`$.evidence[${i}]`,t);if(o){ne(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${i}].transformation`,t),oe(o,"id",`$.evidence[${i}].transformation`,t),re(o,"kind",`$.evidence[${i}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);const e=ae(o,"inputEvidenceIds",`$.evidence[${i}].transformation`,t);e?ce(e,`$.evidence[${i}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${i}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),ce(ae(o,"assumptions",`$.evidence[${i}].transformation`,t),`$.evidence[${i}].transformation.assumptions`,t),ue(o,"description",`$.evidence[${i}].transformation`,t),ue(o,"implementation",`$.evidence[${i}].transformation`,t),ue(o,"performedAt",`$.evidence[${i}].transformation`,t),te(o,"parameters",`$.evidence[${i}].transformation`,t),void 0!==o.performedBy&&de(o.performedBy,`$.evidence[${i}].transformation.performedBy`,t)}const r=se(e,"sample",`$.evidence[${i}]`,t);if(r){ne(r,["rowCount","fields","values","truncated"],`$.evidence[${i}].sample`,t),ce(ae(r,"fields",`$.evidence[${i}].sample`,t),`$.evidence[${i}].sample.fields`,t);const e=ae(r,"values",`$.evidence[${i}].sample`,t);e&&!ie(e)&&t.push({path:`$.evidence[${i}].sample.values`,message:"Expected JSON values."}),Q(r,"rowCount",`$.evidence[${i}].sample`,t),J(r,"truncated",`$.evidence[${i}].sample`,t)}le(e,"relationship",`$.evidence[${i}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),be(e.fieldStatus,t);const o=se(e,"time","$",t);return o&&ve(o,t),me(e,t),te(e,"extensions","$",t),Array.isArray(e.claims)&&0===e.claims.length&&i.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(e.evidence)&&0===e.evidence.length&&i.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===t.length,errors:t,warnings:i}}function Ae(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Se(e,t){if(!t||!Ae(e)||!Array.isArray(e.evidence))return[];const i=[];return e.evidence.forEach((e,t)=>{Ae(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,i.push(`$.evidence[${t}].sample`))}),i}function Me(e,t={}){try{return _e(e,t)}catch{const t=U(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function _e(e,t){if(!Ae(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const i=W(e),n=[.../* @__PURE__ */new Set([...i.excludedPaths,...U(e)])].sort(),o=i.value,r=Se(o,t.excludeEvidenceSamples),s=r.length?["Bounded evidence samples were excluded by the transfer policy."]:[],a=o?.contractVersion;if("string"!=typeof a||!a)return{contract:o,transfer:{status:"invalid",omittedPaths:[...n,...r],warnings:["Artifact contract is missing a string contractVersion.",...s]}};if(a!==Pw)return{contract:o,transfer:{status:n.length>0?"invalid":"unsupported-version",omittedPaths:[...n,...r],warnings:[`Contract version ${a} is not interpreted by this runtime.`,...n.length>0?[`Non-JSON values could not be preserved at: ${n.join(", ")}.`]:[],...s]}};const c=we(o),l=[...c.errors.map(({path:e,message:t})=>`${e}: ${t}`),...c.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...n.length?[`Non-JSON values could not be preserved at: ${n.join(", ")}.`]:[],...s];return{contract:o,transfer:{status:!c.valid||n.length>0?"invalid":r.length>0?"excluded":"preserved",omittedPaths:[...n,...r],warnings:l}}}function $e(e,t){return Ow.has(e)&&!("reading"===e&&"string"==typeof t)}function Pe(e){const t=Object.entries(e).filter(([e,t])=>$e(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function je(e,t=[]){if(void 0===e)return;const i=t.filter(e=>!!e.transformation).map(({id:e,transformation:t})=>({evidenceId:e,transformation:t})).sort(({evidenceId:e},{evidenceId:t})=>t>e?-1:e>t?1:0);return Y(i.length>0?{data:e,transformations:i}:e).fingerprint}function Ie(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!$e(e,t)&&"recipeId"!==e))}function Le(e,t,i,n=Pe(t)){const o=Ie(t),r=0===U(o).length?Y(o).fingerprint:void 0,s=void 0!==n&&0===U(n).length?je(n,e.evidence):void 0,a="ChartRecipe"===i&&"string"==typeof t.recipeId?t.recipeId:i,c=[],l=[];return void 0!==a&&(void 0===e.artifact.component?l.push("artifact.component"):e.artifact.component!==a&&c.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===r?l.push("artifact.configFingerprint"):e.artifact.configFingerprint!==r&&c.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&s?e.artifact.dataFingerprint!==s&&c.push("artifact.dataFingerprint"):l.push("artifact.dataFingerprint"),{status:c.length>0?"mismatch":l.length>0?"unknown":"match",mismatchPaths:c,unknownPaths:l}}function Re(e,t){return O(T({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories}))}function Ce(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Te(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function Oe(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function Ee(e,t){const{when:i}=e,n=t.width,o=t.height,r=Oe(t),s=Te(t);return!("number"==typeof i.minWidth&&i.minWidth>n||"number"==typeof i.maxWidth&&n>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||i.minHeight>o)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof r||i.minAspectRatio>r)||"number"==typeof i.maxAspectRatio&&("number"!=typeof r||r>i.maxAspectRatio)||i.orientation&&s!==i.orientation)}function Fe(e,t){const i={...e,...t};for(const n of["margin","frameProps","mobileSemantics","style"])Ce(e[n])&&Ce(t[n])&&(i[n]={...e[n],...t[n]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}function Ne(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};const n=i.map((e,t)=>({rule:e,index:t})).filter(e=>Ee(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:n.reduce((e,t)=>Fe(e,t.rule.transform),e),matches:n}}function ze(e,t={}){const i=t.mobileSemantics?.interaction,n="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,r=!!i||void 0!==n,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!r)return Nw;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??n??Ew,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??Ew,standardControls:a.standardControls??!1}}function De(e,t,i){const n=zw[e||"primary"],o=e&&"primary"!==e||!i?.width?n.width:i.width,r=e&&"primary"!==e||!i?.height?n.height:i.height,s=Ne({...t,mode:e},{width:t.width??o,height:t.height??r}).props,a=s.mode||e||"primary",c=zw[a],l="context"===a||"sparkline"===a,u="primary"===a&&i?.width?i.width:c.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&i?.height?i.height:c.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:Be(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:ze(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function Be(e,t,i){if(!1!==t)return e;const n={...e};return"horizontal"===i?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function We(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Ye(e,t,i,n){const o=e??t;return"function"==typeof o?o(i,n):i[o+""]}function qe(e){const t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,n)=>{if(!Number.isFinite(Number(Ye(e.yAccessor,"y",i,n))))return;const o=We(Ye(e.xAccessor,"x",i,n)),r=t.get(o)??/* @__PURE__ */new Set;r.add(Ye(e.lineBy,"series",i,n)+""),t.set(o,r)});const i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];const n=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[n]:(i[n-1]+i[n])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},r=2>o.max;return r||2>o.contestedColumns||2>o.median?[{code:r?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:r?"error":"warning",message:r?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]:[]}function Xe(e){return Yw.has(e)}function Ge(e){return Yw.get(e)}function Ve(e){return Xe(e)?Ge(e):"BumpChart"===e?Dw:void 0}function He(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function Ue(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;const n=Ve(t);if(!n)return;let o;try{const t="function"==typeof n?n(i,e):qe(i);o=Array.from(t).filter(He)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=o,e.semanticStatus=o.some(e=>"error"===e.severity)?"degenerate":o.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(const t of o)e.warnings.includes(t.code)||e.warnings.push(t.code)}function Ke(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}function Ze(e){return`${e.getUTCFullYear()}-${Qe(e.getUTCMonth()+1)}-${Qe(e.getUTCDate())}`}function Qe(e){return 10>e?"0"+e:e+""}function Je(e,t){if(!t)return!0;const i=Array.isArray(t)?t:[t],n=e;for(const e of i)if(null!=e.value&&n[e.field]+""!=e.value+"")return!1;return!0}function et(e,t={}){const i=t.baseOpacity??1;return t.highlight||t.predicate?!Je(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function tt(e){if(0===e.length)return 0;let t=0;for(const i of e)t+=i;return t/e.length}function it(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,Kw.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function nt(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>st(t(e))}function ot(e,t){const i=nt(e),n=nt(t);return(e,t)=>{const o=n(e);return{value:o,x:i(e),y:o,category:t}}}function rt(e,t){const i=nt(t??"value"),n=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=n?n(e):void 0;return{value:i(e),category:null==t?void 0:t+""}}}function st(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function at(e,t,i){const n=null!=e.axis?i[e.axis]:null!=e.field?t[e.field]:i.value;if(void 0!==e.eq&&n!==e.eq)return!1;if(void 0!==e.ne&&n===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(n))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=st(n);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,i]=e.within;if(t>o||o>i)return!1}if(void 0!==e.outside){const[t,i]=e.outside;if(o>=t&&i>=o)return!1}return!0}function ct(e,t,i){const n=e.when;return void 0===n||!0===n||!1!==n&&("function"==typeof n?n(t,i):at(n,t,i))}function lt(e,t,i){if(!t||0===t.length)return{};let n={};for(const o of t){if(!ct(o,e,i))continue;const t="function"==typeof o.style?o.style(e,i):o.style;t&&(n={...n,...t})}return n}function ut(e,t,i,n=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,r)=>{const s=n(e),a={...o(e,r)};return Object.assign(a,lt(s,t,i(s,r))),a}:o}function dt(e,t,i,n){if(!e||0===e.length)return n;const o=rt(t,i);return(t,i)=>{const r=t&&t.data||t,s=lt(r,e,o(r)),a=n?n(t,i):void 0;return a?{...s,...a}:s}}function ht(e){const[t,i]=e,n=160>t||116>i,o=n?Math.min(12,Math.max(2,.08*t)):32,r=n?Math.min(8,Math.max(2,.12*i)):24,s=n?r:34;return{width:t,height:i,plot:{x:o,y:r,width:Math.max(1,t-2*o),height:Math.max(1,i-r-s)}}}function pt(e){const t=(e??"")+"";if(!t)return"#4e79a7";const i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let n=0;for(let e=0;t.length>e;e+=1)n=31*n+t.charCodeAt(e)>>>0;return i[n%i.length]}function ft(e,t="#4e79a7",i){const n=i?.styleRules,o=!!n&&n.length>0,r=o?nt(i?.valueAccessor):void 0;return i=>{const s=i.datum,a=s&&e?"function"==typeof e?e(s,0):s[e]:void 0,c={fill:null==a?t:pt(a),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&s&&Object.assign(c,lt(s,n,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function yt(e,t,i,n){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:i},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...n}}}function gt(e,t,i){return"function"==typeof i?i(e,t):e[i]}function mt(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function xt(e,t,i){return Math.max(t,Math.min(i,e))}function bt(e,t){const i=mt(e);return null!=i&&i>0?i:t}function vt(e){if(!e)return;const t=mt(e[0]),i=mt(e[1]);return null!=t&&null!=i?t>i?[i,t]:[t,i]:void 0}function wt(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function kt(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function At(e){const t=Math.max(2,Math.round(e.bins)),i=Math.max(1,Math.round(e.pegRows??t-1)),n=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=xt(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),r=kt(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:n},(e,t)=>{let n=0;for(let e=0;i>e;e+=1)r()<o&&(n+=1);const a=i/2;return{id:`${s}-${t}`,value:n,mechanical:!0,pegRows:i,branchProbability:o,pathRights:n,side:a>n?"left":n>a?"right":"center"}})}function St(e,t,i=0){const n=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),o=/* @__PURE__ */new Map;for(const r of e){let e=null==r.id?`${t}-${i++}`:r.id+"";for(;null==r.id&&n.has(e);)e=`${t}-${i++}`;n.add(e),o.set(e,null==r.id?{...r,id:e}:r)}return{seed:e,rows:Array.from(o.values()),nextId:i}}function Mt(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function _t(e){const t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function $t(e){if(!e)return;const t=Number.isFinite(e.x)?e.x:void 0,i=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==i?void 0:{x:t,y:i}}function Pt(e,t,i){const n="x"===i?"y":"x",o=Math.abs(t[i]-e[i]),r=t[n]-e[n],s=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;let a;if("circle"===e.shape.type&&"circle"===t.shape.type){const i=e.shape.radius+t.shape.radius;a=Math.sqrt(Math.max(0,i*i-o*o))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)a=s(e,n)+s(t,n);else{const r="aabb"===e.shape.type?e:t,c=s("circle"===e.shape.type?e:t,i),l=Math.max(0,o-s(r,i));a=s(r,n)+Math.sqrt(Math.max(0,c*c-l*l))}const c=0>r?-1:1;return{nx:"x"===n?c:0,ny:"y"===n?c:0,penetration:Math.max(0,a-Math.abs(r))}}function jt(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function It(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Lt(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,...e.fixedPosition?{fixedPosition:$t(e.fixedPosition)}:{},shape:jt(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Rt(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Ct(e){return{id:e.id,shape:It(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Rt(e.bodyFilter),index:e.index}}function Tt(e,t,i){return Math.max(t,Math.min(i,e))}function Ot(e,t,i){return Math.min(e??i,t??i)}function Et(e,t,i){return Tt(Math.max(e??i,t??i),0,1)}function Ft(e){return 0>e?-1:1}function Nt(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,i=e.shape.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}function zt(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,i=t.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}const i=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-i,minY:Math.min(t.y1,t.y2)-i,maxX:Math.max(t.x1,t.x2)+i,maxY:Math.max(t.y1,t.y2)+i}}function Dt(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Bt(e,t,i,n,o,r){const s=n-e,a=o-t,c=i+r,l=s*s+a*a;if(l>=c*c)return null;if(sk>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}function Wt(e,t,i,n,o,r,s,a){const c=o-e,l=(i+s)/2-Math.abs(c);if(0>=l)return null;const u=r-t,d=(n+a)/2-Math.abs(u);return d>0?d>l?{nx:Ft(c),ny:0,penetration:l}:{nx:0,ny:Ft(u),penetration:d}:null}function Yt(e,t,i,n,o,r,s){const a=r/2,c=s/2,l=e-Tt(e,n-a,n+a),u=t-Tt(t,o-c,o+c),d=l*l+u*u;if(d>i*i)return null;if(sk>=d){const r=Math.abs(e-(n-a)),s=Math.abs(e-(n+a)),l=Math.abs(t-(o-c)),u=Math.abs(t-(o+c)),d=Math.min(r,s,l,u);return d===r?{nx:-1,ny:0,penetration:i+r}:d===s?{nx:1,ny:0,penetration:i+s}:d===l?{nx:0,ny:-1,penetration:i+l}:{nx:0,ny:1,penetration:i+u}}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:i-h}}function qt(e,t,i,n,o,r,s,a=0){const c=r-n,l=s-o,u=c*c+l*l,d=u>sk?Tt(((e-n)*c+(t-o)*l)/u,0,1):0,h=i+a/2,p=e-(n+c*d),f=t-(o+l*d),y=p*p+f*f;if(y>=h*h)return null;if(sk>=y){const e=Math.sqrt(u);return e>sk?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:p/g,ny:f/g,penetration:h-g}}function Xt(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return Bt(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Wt(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const i=Yt(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Yt(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Gt(e,t){const i=t.shape;return"aabb"===i.type?"circle"===e.shape.type?Yt(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):Wt(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height):qt(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Vt(e,t){return`${e}\0${t}`}function Ht(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Ut(e,t){if(!t)return;let i=e;for(const e of t.split(".")){if(null==i||"object"!=typeof i)return;if(!Object.prototype.hasOwnProperty.call(i,e))return;i=i[e]}return i}function Kt(e,t){return!!t?.some(t=>Object.is(e,t))}function Zt(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const i=Ut(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!Kt(i,t.oneOf)||t.notOneOf&&Kt(i,t.notOneOf))}function Qt(e,t){return Zt(t,e.bodyFilter)}function Jt(e={}){return new lk(e)}function ei(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):Jt(t)}function ti(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const i=t-e.mean;e.mean+=i/e.count,e.m2+=i*(t-e.mean)}function ii(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function ni(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function oi(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function ri(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?oi(t,e):void 0}function si(e,t,i){if("number"==typeof e)return e;const n="function"==typeof e?e(t,i):"string"==typeof e?oi(t,e):1,o="number"==typeof n?n:Number(n);return Number.isFinite(o)?o:1}function ai(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function ci(e){for(const t of uk){const i=ai(oi(e,t));if(i)return i}return"sediment"}function li(e){const t=ii(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:ii(e.x),y:ii(e.y),value:t}}function ui(e,t={}){const{baselineY:i=0,binWidth:n=24,gap:o=2,maxHeight:r=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*r),u=a?.(e,t)??t*(n+o);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:i-l,width:n,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function di(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}function hi(e,t,i){if(!1===i)return;const n=di(i?.warnAt);return null!=n?n:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}function pi(e){const t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),n=t+i,o=di(e.bodyLimit),r=di(e.engineMaxBodiesHint),s=hi(o,r,e.options),a=null==o?0:Math.max(0,t-o),c=a>0?"overflow":null==s||s>n?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:o,engineMaxBodiesHint:r,liveBodies:t,overflow:a,projectedBodies:n,queuedBodies:i,state:c,warnAt:s}}function fi(e={},t=pk){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function yi(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function gi(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function mi(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function xi(e,t,i){return"function"==typeof i?gi(i(e,t)):"string"==typeof i?gi(mi(e,i)):gi(e.spawnAt)??gi(mi(e,"arrivalTime"))??gi(mi(e,"timestamp"))??gi(mi(e,"time"))??gi(mi(e,"eventTime"))}function bi(e,t={}){const i=gi(t.startAt)??0,n=t.pacing??"immediate";if("arrival"===n){const n=e.map((e,i)=>xi(e,i,t.timeAccessor)),o=n.filter(e=>null!=e),r=o.length>0?Math.min(...o):0,s=gi(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const o=n[t],s=null==o?0:Math.max(0,o-r);return{...yi(e),spawnAt:i+s/a}})}if("object"==typeof n){const t=gi(n.ratePerSec);if(t&&t>0)return e.map((e,n)=>({...yi(e),spawnAt:i+n/t}))}return e.map(e=>({...yi(e),spawnAt:i}))}function vi(e){return{...yi(e),sequence:e.sequence,spawnAt:e.spawnAt}}function wi(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function ki(e){return!1!==e&&{...e}}function Ai(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Si(e){return{...e,gravity:{...e.gravity}}}function Mi(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}function _i(e,t,i,n){if("circle"===e.shape.type){const o=e.x-t,r=e.y-i,s=e.shape.radius+n,a=o*o+r*r;return a>s*s?null:a}const o=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),r=Math.max(Math.abs(i-e.y)-e.shape.height/2,0),s=o*o+r*r;return s>n*n?null:s}function $i(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Pi(e,t={}){const{idPrefix:i="plot",includeFloor:n=!0,includeCeiling:o=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return n&&l.push({id:i+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),o&&l.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),r&&l.push({id:i+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:i+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function ji(e){const{idPrefix:t="bin",count:i,domainStart:n,domainStep:o,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:p=Math.max(2,c)}=e,f=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?i:i-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&i>e)continue;const s=r(n+e*o);f.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;i>e;e+=1){const i=n+e*o,s=i+o;if(s>=d)continue;const a=r(i),l=r(s);f.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:p}})}return f}function Ii(e,t){const i={...e};for(const e of t)i[fk[e]]++;return i}function Li(e,t,i){const n=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:n,revisions:Ii(i,n)}}function Ri(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=Mk[n]??_k;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Ci(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&$k.every(i=>e[i]===t[i])}function Ti(e,t){return Object.keys(e).filter(i=>"kernel"===i?!Ci(e.kernel,t.kernel):e[i]!==t[i])}function Oi(e,t,i){if(0===t.length)return;const n=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=n.get(e.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}function Ei(e,t,i){const n=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===n.size&&0===t.size)return n;const o=new Map(e.readState().map(e=>[e.id,e])),r=(e,t)=>{const{sensorId:n,bodyId:r}=$i(t),s=i.observation.sensors[n],a=o.get(r);i.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:n,binId:s?.binId??n})};for(const e of Array.from(n).sort())t.has(e)||r("enter",e);for(const e of Array.from(t).sort())n.has(e)||r("exit",e);return n}function Fi(e,t){for(const i of e)t.has($i(i).bodyId)&&e.delete(i)}function Ni(e,t,i,n){return e||!t?"paused":i||!n?"running":"settled"}function zi(e,t,i){i.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||i.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:t,previousSimulationState:e})}function Di(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt})}function Bi(e,t,i){if("sleeping-first"!==t)return i.slice();const n=new Map(e.readState().map(e=>[e.id,e.sleeping])),o=[],r=[];for(const e of i)n.get(e)?o.push(e):r.push(e);return[...o,...r]}function Wi(e,t,i,n){const o=new Map(e.readState().map(e=>[e.id,e])),r=[];for(const e of i){const i=o.get(e);if(!i)continue;const s=t.add(i);s&&(r.push(e),n.emit({type:"physics-sediment",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e,datum:i.datum,x:i.x,y:i.y,binId:s.id,count:s.count,total:s.total}))}return r}function Yi(e,t,i,n,o,r){const s={evicted:[],sedimented:[],liveBodyOrder:o};if(!1===i)return s;const a=Math.max(0,Math.floor(n));if(!Number.isFinite(a))return s;const c=o.length-a;if(0>=c)return s;const l=Bi(e,i,o).slice(0,c);if(0===l.length)return s;const u=Wi(e,t,l,r);e.remove(l);const d=new Set(l);return{evicted:l,sedimented:u,liveBodyOrder:o.filter(e=>!d.has(e))}}function qi(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}function Xi(e,t){if(!e)return;const i=["spawned","evicted","sedimented","events","observations"],n={spawned:0,evicted:0,sedimented:0,events:0,observations:0},o=o=>{const r=t(o),s={...r,spawned:r.spawned.slice(n.spawned),evicted:r.evicted.slice(n.evicted),sedimented:r.sedimented.slice(n.sedimented),events:r.events.slice(n.events),observations:r.observations.slice(n.observations)};for(const e of i)n[e]=r[e].length;e.onStep(s)};return o(0),()=>o(1)}function Gi(e,t,i,n={}){let o,r=0;for(;t>r&&!n.shouldStop?.()&&(!1===n.stopAtRest||e.queueSize()>0||!e.atRest()||n.continueWhile?.());){e.step(e.fixedDt),e.advanceTime(e.fixedDt);const t=e.drainEvents();i.events&&(i.events.push(...t),e.observeKernelEvents(t,i.observations),e.observeSensorTransitions(i.observations));const s=[];if(e.spawnDue(s,i.observations),s.length>0){i.spawned.push(...s),o=e.observeBodyBudget(i.observations);const t=e.evictOverflow(i.observations);i.evicted?.push(...t.evicted),i.sedimented?.push(...t.sedimented)}r+=1,e.refreshQuiescence(e.fixedDt,s.length),n.afterStep?.()}return{steps:r,budget:o}}function Vi(e){const{data:t,valueAccessor:i,bins:n,ballRadius:o,seed:r,size:s,valueExtent:a}=e,{rows:c}=St(t,"galton"),l=ht(s),u=c.map((e,t)=>mt(gt(e,t,i))).filter(e=>null!=e),d=vt(a),h=d?.[0]??(u.length?Math.min(...u):0),p=d?.[1]??(u.length?Math.max(...u):1),f=p===h?1:p-h,y=(0,ok.scaleLinear)().domain([0,n]).range([l.plot.x,l.plot.x+l.plot.width]),g=Array.from({length:n},()=>0),m=[];c.forEach((e,t)=>{const r=mt(gt(e,t,i));if(null==r)return;const s=Math.max(0,Math.min(n-1,Math.floor((r-h)/f*n)));g[s]+=1,m.push({id:(e.id??"galton-"+t)+"",x:y(s+.5),y:l.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:r,bin:s}})});const x=l.plot.y+l.plot.height;return{config:yt(r,[...Pi({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...ji({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:y,yTop:l.plot.y-400,yBottom:x,wallThickness:6})],"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:g.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:n,plot:l.plot,valueExtent:[h,p]}}}function Hi(e){const{windowSize:t,watermark:i,watermarkAtArrivalAccessor:n}=e;if(!Number.isFinite(t)||0>=t)throw new RangeError("EventDrop windows.size must be a finite positive number");const{rows:o}=St(e.data,"event"),r=o.flatMap((t,i)=>{const n=mt(gt(t,i,e.timeAccessor));return null==n?[]:[{datum:t,index:i,eventTime:n,arrivalTime:mt(gt(t,i,e.arrivalAccessor))??n,watermarkAtArrival:0,late:!1}]}),s="function"==typeof i?null:mt(i?.value),a="function"==typeof i?t:mt(i?.delay)??t;let c=-1/0,l=-1/0;for(const e of r.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){c=Math.max(c,e.eventTime);const o="function"==typeof i?mt(i(c)):c-a;l=s??Math.max(l,o??c-t);const r=n?mt(gt(e.datum,e.index,n)):null;e.watermarkAtArrival=r??l,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:r,watermarkValue:r.length?l:s??-a}}function Ui(e,t){const i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}function Ki(e,t){const i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];const n=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,r=(0,Ik.scaleLinear)().domain([n,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=r(e.windowStart+i*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;i>t;t+=1){const i=e.windowStart+t*e.windowSize,n=i+e.windowSize,o=r(i),s=r(n);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:l(o),x2:s,y2:l(s)})}return u}function Zi(e){const{count:t,idPrefix:i,wallThickness:n,xScale:o,yBottom:r,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(r-1,a?.(t)??s),l=Math.max(1,r-c);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:c+l/2,width:n,height:l}}})}function Qi(e){const{data:t,timeAccessor:i,arrivalAccessor:n,windows:o,watermark:r,watermarkAtArrivalAccessor:s,ballRadius:a,seed:c,size:l,timeExtent:u,timeScale:d=1}=e,{events:h,watermarkValue:p}=Hi({data:t,timeAccessor:i,arrivalAccessor:n,watermark:r,watermarkAtArrivalAccessor:s,windowSize:o.size}),f=ht(l),y=h.map(e=>e.eventTime),g=h.length?Math.min(...h.map(e=>e.arrivalTime)):0,m=mt(u?.[0]),x=mt(u?.[1]),b=y.length?Math.min(...y):0,v=y.length?Math.max(...y):b+o.size,w=Math.min(m??b,b),k=Math.max(x??v,v),A=Math.floor(w/o.size)*o.size,S=Math.max(1,Math.ceil((k-A+o.size)/o.size)),M=Math.max(0,Math.min(S,Array.from({length:S},(e,t)=>t).reduce((e,t)=>A+(t+1)*o.size>p?e:e+1,0))),_=Ui(f,a),$=A+S*o.size,P=(0,Ik.scaleLinear)().domain([A,$]).range([_.windowPlot.x,_.windowPlot.x+_.windowPlot.width]),j=Array.from({length:S},()=>({value:0,secondary:0})),I=[];h.forEach(({datum:e,index:t,eventTime:i,arrivalTime:n,watermarkAtArrival:r,late:s})=>{const c=Math.max(0,Math.min(S-1,Math.floor((i-A)/o.size)));j[c].value+=s?0:1,j[c].secondary+=s?1:0,I.push({id:(e.id??"event-"+t)+"",x:en(i,c,s,{windowStart:A,windowSize:o.size,gutter:_.gutter,closedWindowCount:M,windowPlot:_.windowPlot,windowCount:S},a),y:f.plot.y+a+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:n,shape:{type:"circle",radius:a},datum:{...e,eventTime:i,arrivalTime:n,windowIndex:c,watermarkAtArrival:r,late:s}})});const L=f.plot.y+f.plot.height,R={closedWindowCount:M,gutter:_.gutter,plot:f.plot,windowCount:S,windowPlot:_.windowPlot,windowSize:o.size,windowStart:A},C=Ki(R,f.plot.y+.28*f.plot.height);for(const e of I){const t=e.datum;e.y=Ji({...R,lidSegments:C},t.windowIndex,t.late,a)}const T=e=>{if(0>e||e>M)return null;const t=0===e?C[0]?.y1:C[e-1]?.y2??C[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null},O=Zi({idPrefix:"eventdrop-window",count:S,xScale:e=>P(A+e*o.size),yTop:_.wallTop,yTopForIndex:e=>{const t=T(e);return null==t?_.wallTop:t+1.25*a},yBottom:L,wallThickness:6});return{config:yt(c,[...Pi({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...O,...C.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*a)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:I,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{const t=e.datum,i=M>t.windowIndex;return i&&!t.late||!i&&t.late?g:t.arrivalTime},timeScale:d},projectionRows:j.map((e,t)=>({label:`${A+t*o.size}-${A+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:M,gutter:_.gutter,lidSegments:C,lateCount:j.reduce((e,t)=>e+t.secondary,0),plot:f.plot,windowPlot:_.windowPlot,windowWalls:O.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:p,windowCount:S,windowSize:o.size,windowStart:A}}}function Ji(e,t,i,n){const{windowPlot:o,lidSegments:r}=e,s=r[t];return i&&!s?Math.min(o.y+o.height-n,o.y+.48*o.height+2*n+4):!i&&s?Math.min(o.y+o.height-n,Math.max(s.y1,s.y2)+2*n+4):o.y+n+2}function en(e,t,i,n,o){const{windowPlot:r,windowCount:s,windowStart:a,windowSize:c}=n;if(i&&t>=n.closedWindowCount)return n.gutter.x+n.gutter.width/2;const l=r.width/s,u=i?r.x:r.x+t*l,d=i?r.x+r.width:u+l,h=Math.min((d-u)/2,o+(i?0:3));return Math.max(u+h,Math.min(d-h,r.x+(e-a)/c*l))}function tn(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),i=t.length?t:["Intake"],n=Math.max(i.length,Math.round(e.count??Math.max(48,12*i.length))),o=bt(e.unitValue,1),r=kt(e.seed??1),s=e.idPrefix??"mechanical-pile",a=i.map(()=>.65+.9*r()),c=a.reduce((e,t)=>e+t,0)||1,l=n-i.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=n-d.reduce((e,t)=>e+t,0);const p=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%p.length)d[p[e].index]+=1,h-=1;return i.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*o,mechanical:!0,unitCount:d[t],unitValue:o,share:d[t]/n}))}function nn(e,t){const i=e/t,n=Math.round(i);return Math.ceil(n>0&&Number.EPSILON*i*4>=Math.abs(i-n)?n:i)}function on(e,t,i){const n=e.width/Math.max(1,t),o=Math.max(2,2*i),r=Math.min(.7*n,Math.max(3.2*o,o+8)),s=Math.max(1,Math.floor(r/o));return{laneWidth:n,tubeWidth:r,ballDiameter:o,perRow:s,centerX:t=>e.x+(t+.5)*n,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*o}}function rn(e){function t(e){let t=p.get(e);return null==t&&(t=h.length,h.push(e),p.set(e,t)),t}const{data:i,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:s,seed:a,size:c}=e,l=bt(r,1),{rows:u}=St(i,"pile"),d=ht(c),h=[],p=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map,y=[];u.forEach((e,i)=>{t((gt(e,i,n)??"unknown")+"")});const g=Math.max(1,h.length),m=on(d.plot,g,s),x=Math.max(0,m.tubeWidth/2-s-1),b=h.map(()=>[]);u.forEach((e,i)=>{const r=(gt(e,i,n)??"unknown")+"",a=t(r),c=o?mt(gt(e,i,o)):1,u=Math.max(0,c??0);f.set(r,(f.get(r)??0)+u);const h=nn(u,l),p=m.centerX(a);for(let t=0;h>t;t+=1){const n=b[a].length,o=t===h-1?u-t*l:l,c=Math.min(1,o/l);b[a].push({id:`${(e.id??"pile-"+i)+""}-${t}`,x:p+(m.perRow>1?((m.perRow>1?n%m.perRow:0)/(m.perRow-1)*2-1)*x:0),y:d.plot.y+s+2,vx:(t%3-1)*s/2,vy:0,mass:1,shape:{type:"circle",radius:s*Math.sqrt(c)},datum:{...e,category:r,unitIndex:t,unitValue:l,representedValue:o,unitFraction:c}})}});const v=b.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(const t of b)t.length>e&&y.push(t[e]);const w=d.plot.y+d.plot.height,k=[...Pi({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let e=0;g>e;e+=1){const t=m.centerX(e);for(const i of[-1,1])k.push({id:`pile-tube-${e}-${0>i?"l":"r"}`,shape:{type:"aabb",x:t+i*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:yt(a,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:f.get(e)??0}))}}function sn(e,t,i,n){const o=(t+i)/2,r=[];for(const s of e){const a=r.filter(e=>s.radius+e.radius+.5>Math.abs(s.x-e.x)),c=[o];for(const e of a){const t=Math.sqrt((s.radius+e.radius+.5)**2-(s.x-e.x)**2);c.push(e.y-t,e.y+t)}const l=.5>n()?-1:1;c.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||l*(e-t));const u=c.find(e=>e-s.radius>=t&&i>=e+s.radius&&a.every(t=>(s.x-t.x)**2+(e-t.y)**2>=(s.radius+t.radius+.5)**2-1e-6));if(null==u){const n=Math.max(...e.map(e=>e.radius)),r=Math.max(0,i-t-2*n);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*r),overlapping:!0,entryOffset:0}}r.push({...s,y:u})}return{positions:r.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,Math.min(36,...r.map(e=>e.y-e.radius-t)))}}function an(e){function t(e){let t=m.get(e);return null==t&&(t=g.length,g.push(e),m.set(e,t)),t}const{data:i,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:s,seed:a,size:c,xExtent:l,collisionIterations:u,settle:d}=e,{rows:h}=St(i,"collision-swarm"),p=ht(c),f=kt(a),y=[],g=[],m=/* @__PURE__ */new Map;h.forEach((e,i)=>{const a=mt(gt(e,i,n));if(null==a)return;const c=o?(gt(e,i,o)??"All")+"":"All",l=r?mt(gt(e,i,r)):null,u=xt(null!=l&&l>0?l:s,2,18);t(c),y.push({datum:e,index:i,value:a,group:c,radius:u})});const x=y.map(e=>e.value),b=l?mt(l[0]):null,v=l?mt(l[1]):null,w=x.length?Math.min(...x):0,k=x.length?Math.max(...x):1;let A=b??w,S=v??k;if(A===S&&(A-=.5,S+=.5),A>S){const e=S;S=A,A=e}const M=Math.max(s,...y.map(e=>e.radius)),_=p.plot.x+M+8,$=p.plot.x+p.plot.width-M-8,P=(0,Lk.scaleLinear)().domain([A,S]).range([_,$]),j=p.plot.height/Math.max(1,g.length),I=Math.min(6,.05*j),L=e=>p.plot.y+((m.get(e)??0)+.5)*j,R=/* @__PURE__ */new Map,C=/* @__PURE__ */new Set,T=/* @__PURE__ */new Map;for(const e of g){const t=y.filter(t=>t.group===e),i=L(e),n=t.map(e=>({x:P(e.value),radius:e.radius})),o=sn(n,i-j/2+I,i+j/2-I,f);R.set(e,t.length),o.overlapping&&C.add(e),t.forEach((e,t)=>T.set(e.index,{x:n[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}const O=y.map((e,t)=>{const i=T.get(e.index),n=i.x,o=i.y,r=C.has(e.group);return{id:(e.datum.id??"collision-swarm-"+t)+"",x:n,y:o-(d?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:n},bodyCollisions:!r,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:o,overlapping:r},springs:[{target:{type:"point",x:n,y:o},restLength:0,stiffness:34,damping:12}]}});return{config:yt(a,Pi({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*M),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:O,projectionRows:g.map(e=>({label:e,value:R.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[A,S],xRange:[_,$],groups:g.map(e=>({label:e,y:L(e),count:R.get(e)??0,overlapping:C.has(e)})),plot:p.plot}}}function cn(e){if(Array.isArray(e)&&e.length>=2){const t=mt(e[0]),i=mt(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){const t=e,i=mt(t.x),n=mt(t.y);return null!=i&&null!=n?{x:i,y:n}:null}return null}function ln(e){return Array.isArray(e)?e.map(cn).filter(e=>null!=e):[]}function un(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:xt(e.x,t.plot.x,t.plot.x+t.plot.width),y:xt(e.y,t.plot.y,t.plot.y+t.plot.height)}}function dn(e){let t=0;for(let i=1;e.length>i;i+=1)t+=Math.hypot(e[i].x-e[i-1].x,e[i].y-e[i-1].y);return t}function hn(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const i=xt(t,0,1)*dn(e);let n=0;for(let t=1;e.length>t;t+=1){const o=e[t-1],r=e[t],s=Math.hypot(r.x-o.x,r.y-o.y);if(s>0){if(n+s>=i){const e=(i-n)/s;return{x:o.x+(r.x-o.x)*e,y:o.y+(r.y-o.y)*e}}n+=s}}return{...e[e.length-1]}}function pn(e,t){const i=hn(e,Math.max(0,t-.02)),n=hn(e,Math.min(1,t+.02)),o=n.x-i.x,r=n.y-i.y,s=Math.hypot(o,r)||1;return{x:o/s,y:r/s}}function fn(e){function t(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof s){const e=s(t,0);if(null!=e)return e+""}if("string"==typeof s&&null!=t[s])return t[s]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}const{coordinateMode:i,flowSpeed:n,links:o,maxParticles:r,nodeIdAccessor:s,nodeXAccessor:a,nodeYAccessor:c,nodes:l,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:p="path",reducedMotion:f,seed:y,size:g,sourceAccessor:m,targetAccessor:x,throughputAccessor:b}=e,v=ht(g),w=kt(y),k=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=[];l.forEach((e,t)=>{const i=(gt(e,t,s)??e.id??t)+"",n=mt(gt(e,t,a)),o=mt(gt(e,t,c));if(null!=n&&null!=o){const e={x:n,y:o};k.set(i,e),S.push(e)}A.set(i,(e.label??e.name??i)+"")});const M=[];o.forEach((e,i)=>{const n=t(gt(e,i,m)),o=t(gt(e,i,x)),r=Math.max(0,mt(gt(e,i,b))??0),s=ln(h?gt(e,i,h):void 0),a=s.length?s:ln(e.path??e.points??e.route);a.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${o}-${i}`)+"",link:e,index:i,source:n,target:o,throughput:r,rawPath:a})});const _=(P=S,"normalized"===($=i)||"pixels"===$?$:P.length>0&&P.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var $,P;const j=/* @__PURE__ */new Map;for(const[e,t]of k)j.set(e,un(t,v,_));const I=[];for(const e of M){let t=e.rawPath.map(e=>un(e,v,_));if(2>t.length){const i=j.get(e.source),n=j.get(e.target);i&&n&&(t=[i,n])}else j.has(e.source)||j.set(e.source,t[0]),j.has(e.target)||j.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(A.has(e.source)||A.set(e.source,e.source),A.has(e.target)||A.set(e.target,e.target),I.push({...e,path:t,packetCount:0}))}const L=bt(d,.12),R=Math.max(1,Math.round(r)),C=I.map(e=>Math.max(1,Math.round(e.throughput*L))),T=C.reduce((e,t)=>e+t,0),O=T>R?R/T:1;I.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(C[t]*O))});let E=I.reduce((e,t)=>e+t.packetCount,0);for(;E>R;){const e=I.reduce((e,t,i)=>t.packetCount>1&&(-1===e||t.packetCount>I[e].packetCount)?i:e,-1);if(-1===e)break;I[e].packetCount-=1,E-=1}const F=/* @__PURE__ */new Map,N=/* @__PURE__ */new Map,z=[],D=bt(n,90),B=bt(u,4);I.forEach((e,t)=>{F.set(e.target,(F.get(e.target)??0)+e.throughput),N.set(e.source,(N.get(e.source)??0)+e.throughput);const i=dn(e.path);for(let n=0;e.packetCount>n;n+=1){const o=(n+.5)/e.packetCount,r=f?o:xt(.12+.84*o+.04*(w()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*w())),a=hn(e.path,s),c=hn(e.path,r),l=pn(e.path,s),u={x:-l.y,y:l.x},d=(w()-.5)*B*1.5;z.push({id:`${e.id}-packet-${n}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*D+10*(w()-.5),vy:f?0:l.y*D+10*(w()-.5),mass:.8,spawnAt:f?0:.04*t+n/32,shape:{type:"circle",radius:B},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:n,packetCount:e.packetCount,routeProgress:r,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:D,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target},springs:"none"!==p&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*B,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*B),Y=Array.from(j,([e,t])=>({nodeId:e,label:A.get(e)??e,sensorId:"physical-flow-node-"+wt(e),point:t})),q=Y.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),X=Object.fromEntries(Y.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=yt(y,[...Pi({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*B),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=R,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(j,([e,t])=>({id:e,label:A.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+wt(e),incoming:F.get(e)??0,outgoing:N.get(e)??0})),H=I.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:z,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:z.length,totalThroughput:I.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:H}}}function yn(e,t){const i=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],n=t.filter(e=>!i.has(e)),o=t.length-n.length,r=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s&&Object.prototype.hasOwnProperty.call(i=s,n=e)?i[n]:void 0;var i,n;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(i.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:r,complete:t.length>0&&("anyAbsorbed"===r?o>0:"threshold"===r?l>=(d??c):0===n.length),absorbed:o,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:n}})}function gn(e,t,i){return Math.max(t,Math.min(i,e))}function mn(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function xn(e,t,i,n,o,r={}){return{id:e,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:t,y1:i,x2:n,y2:o,thickness:r.thickness??8}}}function bn(e){const t=e.shape??"lane",i=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height)),o=e.padX??46,r=e.padY??72,s=o,a=i-o,c=r,l=n-Math.max(24,Math.round(.45*r)),u=(c+l)/2,d=Math.max(1,l-c),h=gn(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,y=gn(d*h+f,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,A=e.stages;if(!A.length)throw Error("processStageLayout requires at least one stage");const S=gn(e.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=mn(A),_=a-s;let $=s;const P=A.map((e,t)=>{const i=$,n=t===A.length-1?a:$+(e.share??1)/M*_;return $=n,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:i,x1:n,x:(i+n)/2,width:n-i,y:u,height:d}}),j=P[S],I=j.x0,L=j.x1,R=(e,i)=>{if("lane"===t)return"top"===i?c:l;if("funnel"===t){const t=gn((e-s)/Math.max(1,a-s),0,1);return"top"===i?c+(m-c)*t:l+(x-l)*t}if(I>=e){const t=gn((e-s)/Math.max(1,I-s),0,1);return"top"===i?c+(m-c)*t:l+(x-l)*t}if(L>=e)return"top"===i?m:x;const n=gn((e-L)/Math.max(1,a-L),0,1);return"top"===i?m+(c-m)*n:x+(l-x)*n},C=P.map(e=>{const t=Math.min(R(e.x0,"top"),R(e.x1,"top")),i=Math.max(R(e.x0,"bottom"),R(e.x1,"bottom"));return{...e,y:(t+i)/2,height:Math.max(1,i-t)}}),T={thickness:k,friction:v,restitution:w},O=[];"lane"===t?O.push(xn(b+"-top",s,c,a,c,T),xn(b+"-bottom",s,l,a,l,T),xn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),xn(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)})):"funnel"===t?O.push(xn(b+"-top",s,c,a,m,T),xn(b+"-bottom",s,l,a,x,T),xn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),xn(b+"-right",a,m,a,x,{...T,thickness:Math.max(6,k)})):O.push(xn(b+"-left-top",s,c,I,m,T),xn(b+"-left-bottom",s,l,I,x,T),xn(b+"-center-top",I,m,L,m,T),xn(b+"-center-bottom",I,x,L,x,T),xn(b+"-right-top",L,m,a,c,T),xn(b+"-right-bottom",L,x,a,l,T),xn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),xn(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)}));const E=e.membraneDampingScale??.5,F=s,N=Math.max(1,("bowtie"===t?I:a)-F),z=(e.membranes??[]).map(e=>{const t=F+gn(e.offset,0,1)*N,i=e.width??18+18*e.cost,n=d-16,o=u+.25*(e.wobble??0);return{...e,x:t,y:o,width:i,height:n}}),D=!1===e.includeMembraneRegions?[]:z.map(e=>wn({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??E,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:i,height:n,padX:o,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:I,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:C,membranes:z,colliders:O,regionEffects:D,boundaryY:R}}function vn(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,i=e.y,n=e.width,o=e.height,{type:"aabb",x:t,y:i,width:n,height:o}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,i,n,o}function wn(e){const t=e.dampingScale??.5,i=e.energyScale??1,n=gn(e.cost,0,2);return{...vn({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:n,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n*t,energyDelta:-n*i}}function kn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...vn({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function An(e){const t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,n=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...vn({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i+t*n,energyDelta:o?-t*o:void 0,force:e.force}}function Sn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...vn({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function Mn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...vn({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function _n(e){return{...vn({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function $n(e){const t=e.x??e.anchor?.x??0,i=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:i,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:i},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function Pn(e){const t=e.idPrefix??"lane",i={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},n=[xn(t+"-top",e.left,e.top,e.right,e.top,i),xn(t+"-bottom",e.left,e.bottom,e.right,e.bottom,i)];return e.openEnds||n.push(xn(t+"-left",e.left,e.top,e.left,e.bottom,i),xn(t+"-right",e.right,e.top,e.right,e.bottom,i)),n}function jn(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function In(e,t){const i={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return Mn({...i,kind:e.kind??"sink",force:jn(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return n={...i,kind:e.kind??"force-field",force:jn(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...vn({...n,kind:n.kind??"force-field",attributes:{primitive:"portal",targetStage:n.targetStage,..."object"==typeof n.attributes&&n.attributes?n.attributes:{}}}),force:n.force,impulseOnEnter:n.impulseOnEnter,damping:n.damping??.08}}var n;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return Sn({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:jn(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return An({...i,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:jn(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?kn({...i,kind:e.kind??"force-field",force:jn(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):_n({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}function Ln(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=e.size,n=ht(i),o=xt(e.ballRadius??6,2,18),r=e.seed??1,s=kt(r),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,p=e.groupCompletion??(l?"allAbsorbed":"none"),f=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=bn({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,n.plot.x),padY:Math.max(36,n.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],A=new Set(t.filter(e=>e.absorb).map(e=>e.id)),S=t.map(e=>{const t=v.get(e.id)??k;return In(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(kn({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=/* @__PURE__ */new Map;for(const e of x.stages)M.set(e.id,0);const _=[];e.data.forEach((e,t)=>{const i=(a?gt(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",n=(gt(e,t,c)??w)+"",r=b.has(n)?n:w;M.set(r,(M.get(r)??0)+1);const s=l?(gt(e,t,l)??"")+"":void 0,p=s&&u?(gt(e,t,u)??s)+"":s,f=d?mt(gt(e,t,d))??1:1,y=h?mt(gt(e,t,h)):null,g=xt(null!=y&&y>0?y:o,2,18);_.push({datum:e,id:i,stageId:r,groupId:s||void 0,groupLabel:p||void 0,work:f,radius:g,index:t})});const $=/* @__PURE__ */new Map,P=/* @__PURE__ */new Map;for(const e of _){if(!e.groupId)continue;const t=$.get(e.groupId)??[];t.push(e.id),$.set(e.groupId,t),e.groupLabel&&P.set(e.groupId,e.groupLabel)}const j=xt(e.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*j,L=Array.from($.keys()),R=L.map((e,i)=>{const n=$.get(e)??[],o=L.length>1?x.topY+28+i/Math.max(1,L.length-1)*(x.bottomY-x.topY-56):x.midY;return $n({id:e,label:P.get(e)??e,bodyIds:n,anchor:{x:I,y:o},x:I,y:o,completion:"allAbsorbed"===p?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),C=yn(R,_.filter(e=>A.has(e.stageId)).map(e=>e.id)),T=new Map(R.map(e=>[e.id,e])),O=_.map((e,t)=>{const i=v.get(e.stageId)??k,n=i.x+(s()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(n,"top")+e.radius+10,r=x.boundaryY(n,"bottom")-e.radius-10,a=r>o?o+s()*Math.max(1,r-o):x.midY,c=g?n:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:n,y:a},restLength:.45*e.radius,stiffness:f,damping:y}];if(e.groupId){const t=T.get(e.groupId);t?.anchor&&!A.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),E={kernel:{seed:r,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},F=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),N=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:E,initialSpawns:O,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:F,metadata:{kind:"process-flow",plot:n.plot,volume:x,stages:N,groups:R,groupCompletion:C,regionEffects:S}}}function Rn(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function Cn(e,t,i){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(i)}`}function Tn(e){const t=e.map(Rn),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){const[e,i,n]=t[0];return Cn(e,i,n)}if(e>=1){const[e,n,o]=t[i];return Cn(e,n,o)}const n=e*i,o=Math.floor(n),r=n-o,[s,a,c]=t[o],[l,u,d]=t[o+1];return Cn(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(d-c)*r))}}function On(e){return e&&Object.prototype.hasOwnProperty.call(Vk,e)?Vk[e]:Ok}function En(e,t,i=iA){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Object.prototype.hasOwnProperty.call(tA,e)?tA[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function Fn(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||sA.has(t)}function Nn(e,t,i){if("function"==typeof t){const n=t(e);return i&&n&&"string"==typeof n&&!Fn(n)?i(n):n}const n=e?.[t]+"";return i?i(n):iA[Math.abs(Bn(n))%iA.length]}function zn(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function Dn(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const e=i;return t=>zn(e,t)??"#999"}const n=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=n.every(e=>!isNaN(Number(e)));if(Array.isArray(i))return(0,Ck.scaleOrdinal)().domain(n).range(i).unknown("#999");const r=Object.prototype.hasOwnProperty.call(tA,i)?tA[i]:tA.category10;if(o&&"function"==typeof r){let e=-1/0;for(const t of n){const i=Number(t);i>e&&(e=i)}return t=>r(0===e?0:Number(t)/e)}{const e=Array.isArray(r)?r:iA;return(0,Ck.scaleOrdinal)().domain(n).range(e).unknown("#999")}}function Bn(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}function Wn(e,t,i=[3,20],n){let o;if(o="function"==typeof t?t(e):e?.[t],!n)return o;const[r,s]=n,[a,c]=i;if(s===r)return(a+c)/2;let l=(o-r)/(s-r);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function Yn(e,t,i){return En(e,t,i)}function qn(e,t){const i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&zn(i,e)||"#4e79a7":t=>{if(i){const e=zn(i,t);if(e)return e}let n=0;for(let e=0;t.length>e;e++)n=31*n+t.charCodeAt(e)|0;return e[Math.abs(n)%e.length]??"#4e79a7"}}function Xn(e,t,i){const n=e?.observation;return{...e,observation:{...n,chartId:t??n?.chartId??"physics-custom",chartType:n?.chartType??"PhysicsCustomChart",onObservation:i??n?.onObservation}}}function Gn(e,t){const i=t.config??{},n=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...n],r=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...r.length>0&&{colliders:r}}}function Vn(e,t){if(!t?.length)return e;const i=/* @__PURE__ */new Map;for(const e of t){const{bodyId:t,...n}=e,o=i.get(t)??[];o.push(n),i.set(t,o)}return e.map(e=>{const t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}function Hn(e){const t=Xn(e.config,e.chartId,e.onObservation),i=Yn(e.colorScheme,e.themeCategorical,Tk),n=ht(e.size),o={data:e.data,scales:{x:(0,Rk.scaleLinear)().domain(e.xExtent??[0,1]).range([n.plot.x,n.plot.x+n.plot.width]),y:(0,Rk.scaleLinear)().domain(e.yExtent??[0,1]).range([n.plot.y+n.plot.height,n.plot.y])},dimensions:n,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:qn(i,e.colorScheme),config:e.layoutConfig??{},world:new jk(t)},r=e.skipLayout?{}:e.layout(o)??{},s=Vn([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Gn(t,r),context:o,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}function Un(e){const t=eo(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function Kn(e,t,i,n){return i?"function"==typeof i?i(e,t):e[i]??n:n}function Zn(e){return`gauntlet:${e}:core`}function Qn(e,t){return`gauntlet:${e}:positive:${t}`}function Jn(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function eo(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return aA;const i=Math.max(1,Math.min(e.width,t)),n=Math.max(2,.04*e.width);return{left:n,top:Math.max(2,.08*t),rightInset:n,thickness:Math.max(1,Math.min(4,.04*i))}}function to(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function io(e,t,i,n){const o=eo(n),r=Math.max(2,i+2),s=o.top+o.thickness/2+r,a=n.floorY-r,c=(e,t,i)=>t>i?(t+i)/2:Math.max(t,Math.min(i,e));return{x:c(e,o.left+o.thickness/2+r,n.width-o.rightInset-o.thickness/2-r),y:c(t,s,a)}}function no(e,t,i){const[n,o]=e,r=220>n||160>o,s=Math.round(.48*o),a=r?o-Math.max(3,Math.min(12,.1*o)):o-36,c=(t??[]).filter(e=>!1!==e.enabled),l=Math.max(1,c.length),u=.22*n,d=l>1?(.78*n-u)/(l-1):0,h=r?Math.max(Math.round(.12*n),.08*n+6):Math.max(Math.round(.14*n),110);return{crashY:a-(r?Math.min(i,Math.max(3,.22*o)):i),floorY:a,gates:c.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(r?8:54,Math.round(.07*n))})),graveyardX:Math.round(n*(r?.72:.84)),graveyardY:a-4,height:o,routeY:s,socketX:Math.round(n*(r?.82:.92)),startX:h,width:n}}function oo(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function ro(e,t,i,n){const o=oo(i),r=n?.(e,t,i)??{};return{...o,...r,startY:r.startY??r.routeY??o.startY,socketY:r.socketY??r.routeY??o.socketY,graveyardY:r.graveyardY??o.graveyardY}}function so(e,t,i=1){const n=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,n.indexOf(t));return{angle:.82*-Math.PI+(n.length>1?o/(n.length-1):.5)*Math.PI*.64,index:o,radius:(48+o%2*6)*i}}function ao(e,t,i){const n=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,r=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*n-8*r-1.2*e.delay-5*o))}function co(e,t,i,n,o){const r=Kn(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=n.map(e=>e.id),a=[...Kn(e,t,i.positiveAccessor,s)],c=[...Kn(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Kn(e,t,i.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Kn(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Kn(e,t,i.initialViability,100)}}function lo(e,t,i,n,o,r,s){const a=to(i),c=Math.max(3,28*a),l=n.startX,u=n.startY+(n.startY===i.routeY?38*t*a:0),d=s?.(e,t,i,n)??{},h=d.x??l,p=d.y??u,f={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:Zn(e.id),x:h,y:p,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??e.startedAt,datum:f}],g=io(h,p,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,i);y[0].x=g.x,y[0].y=g.y;for(const t of e.activePositiveIds){const n=o.get(t);if(!n)continue;const r=so(e.activePositiveIds,t,a),s=n.radius??Math.max(2,10*a),c=io(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,i);y.push({id:Qn(e.id,t),x:c.x,y:c.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:n.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:n,sourceDatum:e.datum},springs:!1===n.spring?[]:[{target:{type:"body",bodyId:Zn(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+r.index%2*4)*a),...n.spring??{}}]})}return e.negativeIds.forEach((t,n)=>{const o=r.get(t);o&&y.push(ho(e,o,n,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}function uo(e){const t=no(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],n=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),r={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=co(t,s,r,i,o);return{...a,viability:e.viability?.(a,{negativeProperties:o,positiveProperties:n})??ao(a,n,o)}}),a=s.flatMap((i,r)=>{const s=ro(i,r,t,e.projectPlacement);return lo(i,r,t,s,n,o,e.coreBody)});return{layout:t,states:s,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Un(t)}}}function ho(e,t,i,n,o,r,s){const a=to(r),c=t.radius??Math.max(2,7.2*a),l=io(n+(i%4*12-12)*a,o+(54+12*Math.floor(i/4))*a,c,r);return{id:Jn(e.id,t.id,i),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Zn(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*a),...t.spring??{}}]}}function po(e=[]){const t=/* @__PURE__ */Object.create(null);for(const[i,n]of e)t[i]=n;return t}function fo(...e){const t=po();for(const i of e)for(const[e,n]of Object.entries(i??{}))t[e]=n;return t}function yo(e){return fo(e)}function go(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function mo(e){const t=po(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:yo(t.initialMetrics),metrics:yo(t.metrics),productIds:[...t.productIds],history:go(t.history)}])),i=po(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:yo(t.metrics),sourceIds:[...t.sourceIds],history:go(t.history)}])),n=po(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?yo(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:n,input:{amount:e.input.amount,metrics:yo(e.input.metrics)},metrics:yo(e.metrics),loss:{amount:e.loss.amount,metrics:yo(e.loss.metrics)},history:go(e.history)}}function xo(e,t){return t>e?-1:e>t?1:0}function bo(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function vo(e){const t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const n of e)t.has(n)&&i.add(n),t.add(n);return[...i].sort(xo)}function wo(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[bo("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function ko(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function Ao(e){const t=po();for(const i of e)ko(t,i.metrics);return t}function So(e,t,i="selector"){const n=[],o=Object.values(e.components),r=new Set(o.map(e=>e.id)),s=(t.ids??[]).filter(e=>!r.has(e));if(s.length&&n.push(bo("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,i+".ids",s)),void 0===t.count||Number.isInteger(t.count)&&t.count>=0||n.push(bo("error","invalid-selector-count","Selector count must be a non-negative integer.",i+".count")),n.some(e=>"error"===e.severity))return{ids:[],diagnostics:n};const a=t.ids?new Set(t.ids):null,c=t.categories?new Set(t.categories):null,l=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null;let d=o.filter(e=>!a||a.has(e.id)).filter(e=>!c||c.has(e.category)).filter(e=>!l||l.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(xo);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||n.push(bo("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:n}}function Mo(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function _o(e,t){const i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function $o(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(bo("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function Po(e,t,i){const n=vo(t);t.length||e.diagnostics.push(bo("error","empty-source-list","A product requires at least one source component.",i)),n.length&&e.diagnostics.push(bo("error","duplicate-source",`Source ids may appear only once: ${n.join(", ")}.`,i,n));const o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(bo("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));const r=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);r.length&&e.diagnostics.push(bo("error","source-already-assigned",`Source component${1===r.length?" is":"s are"} already assigned: ${r.join(", ")}.`,i,r));const s=t.filter(t=>"consumed"===e.state.components[t]?.status&&!r.includes(t));return s.length&&e.diagnostics.push(bo("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,i,s)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function jo(e,t,i){const n=vo(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(bo("error","insufficient-relation-sources","A relation requires at least two source components.",i)),n.length&&e.diagnostics.push(bo("error","duplicate-source",`Relation source ids must be unique: ${n.join(", ")}.`,i,n)),o.length&&e.diagnostics.push(bo("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function Io(e,t,i,n,o){const r=n?.amount??0;(!Number.isFinite(r)||0>r||r>t+cA)&&e.diagnostics.push(bo("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...wo(n?.metrics,o+".metrics"));for(const[t,r]of Object.entries(n?.metrics??{}))(0>r||r>Number(i[t]??0)+cA)&&e.diagnostics.push(bo("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function Lo(e,t,i,n){if(!t?.length)return[];const o=vo(t),r=t.filter(t=>!e.state.relations[t]),s=t.filter(t=>"resolved"===e.state.relations[t]?.status),a=new Set(i),c=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!a.has(e)));return o.length&&e.diagnostics.push(bo("error","duplicate-relation","Basis relations must be unique.",n,o)),r.length&&e.diagnostics.push(bo("error","unknown-relation",`Unknown basis relation: ${r.join(", ")}.`,n,r)),s.length&&e.diagnostics.push(bo("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,n,s)),c.length&&e.diagnostics.push(bo("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,n,c)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}function Ro(e,t){if(t.length){for(const i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;_o(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}function Co(e,t,i){e.state.loss.amount+=i?.amount??0;for(const[n,o]of Object.entries(i?.metrics??{}))t[n]=Number(t[n]??0)-o,e.state.loss.metrics[n]=Number(e.state.loss.metrics[n]??0)+o}function To(e,t,i,n,o,r,s){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:r&&void 0!==e.amount?e.amount:i,metrics:r&&e.metrics?fo(n,e.metrics):yo(n),status:r?"complete":"forming",sourceIds:[...t],outletId:r?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:r?o.event.id:void 0,completedAt:r?o.context.appliedAt:void 0,history:[s]}}function Oo(e,t,i,n){void 0!==t.amount&&Math.abs(t.amount-i)>cA&&e.diagnostics.push(bo("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,n,[t.id]))}function Eo(e,t,i,n,o,r){const s=e.productDefinitions.get(t.id),a=i??s?.outletId??(e.outletIds.has("product")?"product":void 0);if(!$o(e,a,r+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(bo("error","product-already-complete",`Product "${t.id}" is already complete.`,r,[t.id]));s&&(Oo(e,s,t.amount,r+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics=fo(t.metrics,s.metrics))),t.status="complete",t.outletId=a,t.reason=n,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;const c=Mo(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),_o(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0})}function Fo(e,t,i){const n=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(bo("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,n+".state")),e.diagnostics.push(...wo(t.metricsDelta,n+".metricsDelta")),$o(e,t.outletId,n+".outletId");const i=So(o,t.select,n+".select");e.diagnostics.push(...i.diagnostics);const r=i.ids.filter(e=>o.components[e].productIds.length);if(r.length&&e.diagnostics.push(bo("error","source-already-assigned",`Assigned source components cannot be retargeted: ${r.join(", ")}.`,n+".select",r)),e.diagnostics.some(e=>"error"===e.severity))return;const s=Mo(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(const e of i.ids){const i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&ko(i.metrics,t.metricsDelta),i.history.push(s)}return o.history.push(s),void(i.ids.length&&_o(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){const{relation:i}=t;i.id&&!o.relations[i.id]||e.diagnostics.push(bo("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,n+".relation.id",[i.id]));const r=jo(e,i.sourceIds,n+".relation.sourceIds");if(e.diagnostics.push(...wo(i.metrics,n+".relation.metrics")),!r||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?yo(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=Mo(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(s),void _o(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){const i=vo(t.relationIds),r=t.relationIds.filter(e=>!o.relations[e]),s=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(bo("error","duplicate-relation","Relation ids must be unique.",n+".relationIds",i)),r.length&&e.diagnostics.push(bo("error","unknown-relation",`Unknown relation: ${r.join(", ")}.`,n+".relationIds",r)),s.length&&e.diagnostics.push(bo("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,n+".relationIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const i of t.relationIds){const n=o.relations[i];n.status="resolved",n.resolution=t.resolution,n.resolvedByEventId=e.event.id,n.resolvedAt=e.context.appliedAt,n.reason=t.reason}const a=Mo(e,t,{relationIds:[...t.relationIds]});return o.history.push(a),void _o(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){const i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(bo("error","unknown-product",`Product "${t.productId}" has no declared mold.`,n+".productId",[t.productId]));const r=o.products[t.productId];"combine"===t.type&&r&&e.diagnostics.push(bo("error","duplicate-product",`Product "${t.productId}" has already been formed.`,n+".productId",[t.productId])),"contribute"!==t.type||r&&"forming"===r.status||e.diagnostics.push(bo("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,n+".productId",[t.productId]));const s=Po(e,t.sourceIds,n+".sourceIds"),a="contribute"===t.type&&r?[...r.sourceIds,...t.sourceIds]:t.sourceIds,c=Lo(e,t.basisRelationIds,a,n+".basisRelationIds");if(!s||!c||!i||e.diagnostics.some(e=>"error"===e.severity))return;const l=s.reduce((e,t)=>e+t.amount,0),u=Ao(s);if(!Io(e,l,u,t.loss,n+".loss"))return;const d=l-(t.loss?.amount??0);Co(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,p=Mo(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let f;if("combine"===t.type){if(h&&Oo(e,i,d,n+".productId"),f=To(i,t.sourceIds,d,u,e,h,p),h&&!$o(e,f.outletId,n+".productId"))return;o.products[t.productId]=f}else f=r,f.sourceIds.push(...t.sourceIds),f.amount+=d,ko(f.metrics,u),f.history.push(p);for(const e of s)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),Ro(e,c),_o(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:f.outletId?[f.outletId]:void 0}),void(h&&_o(e,{type:"complete-product",sourceIds:[...f.sourceIds],productIds:[f.id],outletIds:f.outletId?[f.outletId]:void 0}))}if("complete-product"===t.type){const i=o.products[t.productId];return i?void Eo(e,i,t.outletId,t.reason,t,n):void e.diagnostics.push(bo("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,n+".productId",[t.productId]))}if("split"===t.type){const i=Po(e,[t.sourceId],n+".sourceId");t.products.length||e.diagnostics.push(bo("error","empty-split","A split requires at least one product allocation.",n+".products"));const r=t.products.map(e=>e.productId),s=vo(r);s.length&&e.diagnostics.push(bo("error","duplicate-product","Split product ids must be unique.",n+".products",s));const a=r.map(t=>e.productDefinitions.get(t)),c=r.filter((e,t)=>!a[t]),l=r.filter(e=>o.products[e]);c.length&&e.diagnostics.push(bo("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,n+".products",c)),l.length&&e.diagnostics.push(bo("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,n+".products",l));for(const[i,o]of t.products.entries())void 0===o.amount||Number.isFinite(o.amount)&&o.amount>=0||e.diagnostics.push(bo("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${n}.products.${i}.amount`)),e.diagnostics.push(...wo(o.metrics,`${n}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=i[0];if(!Io(e,u.amount,u.metrics,t.loss,n+".loss"))return;const d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??a[t]?.amount),p=h.filter(e=>void 0!==e).length;if(0!==p&&p!==h.length)return void e.diagnostics.push(bo("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",n+".products"));const f=p?h:t.products.map(()=>d/t.products.length),y=f.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>cA)return void e.diagnostics.push(bo("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,n+".products"));const g=yo(u.metrics);for(const[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;const m=Mo(e,t,{sourceIds:[u.id],productIds:r});if(t.products.forEach((i,r)=>{const s=a[r],c=d>cA?f[r]/d:1/t.products.length,l=po(Object.entries(g).map(([e,t])=>[e,t*c])),h=i.metrics??s.metrics??l,p=To({...s,amount:f[r],metrics:h},[u.id],f[r],yo(h),e,!0,m);$o(e,p.outletId,`${n}.products.${r}.productId`)&&(o.products[p.id]=p)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=r,u.status="consumed",u.outletId=void 0,u.history.push(m),o.loss.amount+=t.loss?.amount??0;for(const[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(m),_o(e,{type:"split-source",sourceIds:[u.id],productIds:r});for(const t of r)_o(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){$o(e,t.outletId,n+".outletId");const i=So(o,t.select,n+".select");e.diagnostics.push(...i.diagnostics);const r=i.ids.filter(e=>o.components[e].productIds.length);if(r.length&&e.diagnostics.push(bo("error","source-already-assigned",`Assigned source components cannot be ejected: ${r.join(", ")}.`,n+".select",r)),e.diagnostics.some(e=>"error"===e.severity))return;const s=Mo(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(const e of i.ids){const i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(s)}return o.history.push(s),void(i.ids.length&&_o(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...wo(t.metricsDelta,n+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,r;if("run"===t.target)ko(o.metrics,t.metricsDelta);else if("components"in t.target){const r=So(o,t.target.components,n+".target.components");if(e.diagnostics.push(...r.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=r.ids;for(const e of r.ids)ko(o.components[e].metrics,t.metricsDelta)}else{r=[...t.target.productIds];const i=vo(r),s=r.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(bo("error","duplicate-product","Metric target product ids must be unique.",n+".target.productIds",i)),s.length&&e.diagnostics.push(bo("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,n+".target.productIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const e of r)ko(o.products[e].metrics,t.metricsDelta)}return void o.history.push(Mo(e,t,{sourceIds:i,productIds:r}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(Mo(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(bo("error","invalid-outcome","Outcome must be a non-empty string.",n+".outcome"))}function No(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[bo("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const n=mo(e),o={state:n,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(const[i,n]of t.effects.entries())if(Fo(o,n,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return n.elapsed=Math.max(n.elapsed,i.appliedAt),n.phaseId=i.phaseId,n.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:n,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function zo(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function Do(e,t={}){const i=t.groupBy??"outlet",n=/* @__PURE__ */new Map,o=e=>{const t=zo({...e,status:e.status??"active"},i),o=n.get(t);if(o)return o.count+=1,o.amount+=e.amount,void ko(o.metrics,e.metrics);n.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:yo(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(const t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(const t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});const r=new Map((t.order??[]).map((e,t)=>[e,t]));return[...n.values()].sort((e,t)=>(r.get(e.key)??Number.MAX_SAFE_INTEGER)-(r.get(t.key)??Number.MAX_SAFE_INTEGER)||xo(e.key,t.key))}function Bo(e,t){return t>e?-1:e>t?1:0}function Wo(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function Yo(e){const t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const n of e)t.has(n)&&i.add(n),t.add(n);return[...i].sort(Bo)}function qo(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Xo(e,t,i,n,o,r){if(!i)return n;try{return("function"==typeof i?i(e,t):e[i])??n}catch(e){return o.push(Wo("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,r)),n}}function Go(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Wo("error","invalid-metrics","Metrics must be a numeric object.",i)),po();const n=po();for(const[o,r]of Object.entries(e)){const e=qo(r);null!=e?n[o]=e:t.push(Wo("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return n}function Vo(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function Ho(e){const t=[],i=po(),n=[];let o=0;const r=po();e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((Xo(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(Wo("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));n.push(l);const u=qo(Xo(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Wo("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=Go(Xo(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),p=Xo(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),f=dA.has(p)?p:"active";dA.has(p)||t.push(Wo("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${a}.status`,[l]));const y=Xo(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",g=Xo(s,a,e.categoryAccessor,"component",t,`data.${a}.category`)+"";Object.hasOwn(i,l)||(i[l]={id:l,label:y,category:g,datum:s,status:f,initialAmount:d,amount:d,initialMetrics:fo(h),metrics:fo(h),productIds:[],history:[]},o+=d,Vo(r,h))});const s=Yo(n);s.length&&t.push(Wo("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=Go(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:po(),relations:po(),input:{amount:o,metrics:r},metrics:a,loss:{amount:0,metrics:po()},history:[]},diagnostics:t}}function Uo(e){const t=[];e.length||t.push(Wo("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const i=Yo(e.map(e=>e.id));i.length&&t.push(Wo("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let n=0;return{phases:e.map((e,i)=>{const o=qo(e.duration),r=null!=o&&o>0?o:0;e.id.trim()||t.push(Wo("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),null!=o&&o>0||t.push(Wo("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0===e.intensity||Number.isFinite(e.intensity)||t.push(Wo("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));const s={...e,duration:r,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:n,end:n+r};return n=s.end,s}),diagnostics:t}}function Ko(e,t,i){const n=e.find(e=>hA>=Math.abs(e.start-i));if(n)return{phase:n,boundaryRank:1};const o=e.find(e=>i>=e.start&&e.end>i);return o?{phase:o,boundaryRank:0}:hA>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function Zo(e,t,i){const n=[],o=Yo(e.map(e=>e.id));o.length&&n.push(Wo("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));const r=[];return e.forEach((e,o)=>{let s,a,c;if(e.id.trim()||n.push(Wo("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){const r=qo(e.at.time);if(null==r||0>r||r>i+hA)return void n.push(Wo("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));s=Math.max(0,Math.min(i,r));const l=Ko(t,i,s);a=l.phase,c=l.boundaryRank}else{if(a=t.find(t=>t.id===e.at.phaseId),!a)return void n.push(Wo("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));const i=e.at.progress??0;if(!Number.isFinite(i)||0>i||i>1)return void n.push(Wo("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));s=a.start+a.duration*i,c=0===i?1:0}a?r.push({...e,index:o,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):n.push(Wo("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),r.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:r,diagnostics:n}}function Qo(e,t){const i=[],n=new Set(t.map(e=>e.id)),o=Yo(t.map(e=>e.id)),r=Yo(e.map(e=>e.id));return o.length&&i.push(Wo("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),r.length&&i.push(Wo("error","duplicate-product-id",`Product ids must be unique: ${r.join(", ")}.`,"products",r)),t.forEach((e,t)=>{e.id.trim()||i.push(Wo("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||i.push(Wo("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Wo("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0===e.amount||Number.isFinite(e.amount)&&e.amount>=0||i.push(Wo("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0===e.outletId||n.has(e.outletId)||i.push(Wo("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Go(e.metrics??{},i,`products.${t}.metrics`)}),i}function Jo(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function er(e=lA,t=uA){const i=Math.max(1,qo(e[0])??900),n=Math.max(1,qo(e[1])??520),o=360>i||260>n,r=o?Math.max(4,.035*Math.min(i,n)):20,s=o?Math.max(10,.075*n):34,a={x:r,y:r,width:Math.max(1,i-2*r),height:s},c=o?Math.max(16,.14*n):Math.min(78,.16*n),l={x:r,y:n-r-c,width:Math.max(1,i-2*r),height:c},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=a.y+a.height+(o?12:38),h=l.y-(o?10:34),p={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},f=Math.max(18,Math.min(.32*p.width,o?84:180)),y={x:p.x+(p.width-f)/2,y:p.y-(o?10:24),width:f,height:o?12:28},g=Jo(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{const n=Math.max(8,u-1.5*r),s=p.height/Math.max(1,t.length);t.forEach((t,a)=>{x.push({...t,side:e,x:"left"===e?r:i-r-n,y:p.y+a*s,width:n,height:Math.max(8,s-(o?2:8))})})};b("left",m.left),b("right",m.right);const v=p.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:p.x+t*v,y:p.y+p.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,l.y-p.y-p.height-(o?4:12))})}),x.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:i,height:n,phaseRail:a,chamber:p,mouth:y,projection:l,outlets:x}}function tr(e,t,i){const n=i.map(([i,n])=>[Math.max(e,Math.min(i,n)),Math.min(t,Math.max(i,n))]).filter(([e,t])=>t>e+hA).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[];let r=e;for(const[e,t]of n)e>r+hA&&o.push([r,e]),r=Math.max(r,t);return t>r+hA&&o.push([r,t]),o}function ir(e){const{id:t,orientation:i,fixed:n,start:o,end:r,openings:s,thickness:a,friction:c,restitution:l}=e,u=tr(o,r,s);return u.map(([e,o],r)=>({id:1===u.length?t:`${t}:${r}`,friction:c,restitution:l,shape:"horizontal"===i?{type:"segment",x1:e,y1:n,x2:o,y2:n,thickness:a}:{type:"segment",x1:n,y1:e,x2:n,y2:o,thickness:a}}))}function nr(e){const{chamber:t,mouth:i}=e,n=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),r=Math.min(t.x+t.width,i.x+i.width),s={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:n}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:r,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:n}}];a.push(...ir({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:s.left.map(e=>[e.y,e.y+e.height]),thickness:n,friction:.46,restitution:.12}),...ir({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:s.right.map(e=>[e.y,e.y+e.height]),thickness:n,friction:.46,restitution:.12}),...ir({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:s.bottom.map(e=>[e.x,e.x+e.width]),thickness:n,friction:.5,restitution:.08}));for(const t of e.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return a}function or(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t>>>0}function rr(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?or(e):1}function sr(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function ar(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:rr(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function cr(e){return"crucible:component:"+encodeURIComponent(e)}function lr(e,t,i,n){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;const o=Math.min(...t,e),r=Math.max(...t,e);return r-o>hA?n[0]+(n[1]-n[0])*Math.sqrt(Math.max(0,e-o)/(r-o)):(n[0]+n[1])/2}function ur(e,t){const i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),n=e?.[0]??7*i,o=e?.[1]??18*i,r=Math.max(1,Math.min(n,o));return[r,Math.max(r,Math.max(n,o))]}function dr(e,t,i={}){const n=Object.values(e.components).sort((e,t)=>Bo(e.id,t.id)),o=n.map(e=>e.amount),r=ur(i.radiusRange,t),s=sr(rr(i.seed)),a=t.mouth.x+t.mouth.width/2,c=t.chamber.y+Math.max(18,.18*t.chamber.height),l=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return n.map((e,t)=>{const d=t/Math.max(1,n.length)*Math.PI*2+.18*(s()-.5),h=lr(e.amount,o,i.bodyRadius,r),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:cr(e.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:p}})}function hr(e,t){if(!e)return[];const i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),n=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+t.width/i*(o%i+.5),y:t.y+(Math.floor(o/i)+.5)*(t.height/n)}))}function pr(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function fr(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function yr(e,t){const i=/* @__PURE__ */new Map;for(const t of e){const e=t.outletId??"__chamber__",n=i.get(e)??[];n.push(t),i.set(e,n)}const n=/* @__PURE__ */new Map;for(const[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||Bo(e.id,t.id));const i=hr(o.length,fr(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>n.set(e.id,i[t]))}return n}function gr(e,t,i={}){const n=Object.values(e.products).sort((e,t)=>Bo(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>Bo(e.id,t.id)),r=[...o.map(e=>e.amount),...n.map(e=>e.amount)],s=ur(i.radiusRange,t),a=yr(n,t),c=n.map(e=>{const n=a.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*lr(e.amount,r,i.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(l=e.id,"crucible:product:"+encodeURIComponent(l)),x:n.x,y:n.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:c};var l}),l=/* @__PURE__ */new Map;for(const e of o.filter(e=>!e.productIds.length)){const t=pr(e)??"__chamber__",i=l.get(t)??[];i.push(e),l.set(t,i)}const u=/* @__PURE__ */new Map;for(const[e,i]of l){const n=hr(i.length,fr(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,n[t]))}return[...o.map(e=>{let n=u.get(e.id);if(e.productIds.length){const i=e.productIds.map(e=>a.get(e)).filter(e=>!!e);if(i.length){n={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};const o=or(e.id)/4294967295*Math.PI*2,r=Math.min(20,Math.max(4,.012*t.width));n={x:n.x+Math.cos(o)*r,y:n.y+Math.sin(o)*r}}}n??(n={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});const o=lr(e.amount,r,i.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:cr(e.id),x:n.x,y:n.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:c}}),...c]}function mr(e){return Array.isArray(e)?e.map(mr):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>Bo(e,t)).map(([e,t])=>[e,mr(t)])):e}function xr(e,t){const i=qo(t)??0,n=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:n,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const o=n>=e.duration-hA,r=o?e.phases[e.phases.length-1]:e.phases.find(e=>n>=e.start&&e.end>n)??e.phases[0];return{elapsed:n,phaseId:r.id,phaseIndex:r.index,phaseElapsed:o?r.duration:Math.max(0,n-r.start),complete:o}}function br(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,qo(t)??0));const i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;const n=Math.max(0,Math.min(1,qo(t.progress??0)??0));return i.start+i.duration*n}function vr(e,t=e.duration){const i=xr(e,t);let n=mo(e.initialState);const o=[],r=[],s=[];for(const t of e.events){if(t.authoredAt>i.elapsed+hA)break;const a=No(n,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...a.diagnostics),r.push(...a.materializations),s.push(...a.observations),a.applied&&(n=a.state)}return n.elapsed=i.elapsed,n.phaseId=i.phaseId,n.phaseIndex=i.phaseIndex,n.phaseElapsed=i.phaseElapsed,n.complete=i.complete,i.complete&&"in_process"===n.outcome&&(n.outcome="complete"),n.playing=!1,{state:n,diagnostics:o,materializations:r,observations:s}}function wr(e){const t=Uo(e.phases),i=t.phases.at(-1)?.end??0,n=Jo(e.outlets??uA),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?fo(e.metrics):void 0})),r=Zo(e.events??[],t.phases,i),s=Ho(e),a=er(e.size??lA,n),c=nr(a),l=Qo(o,n),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>Bo(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:n,intensity:o,motion:r,color:s,metrics:a})=>({id:e,duration:t,label:i,description:n,intensity:o,motion:r,color:s,metrics:a})),products:o,outlets:n,events:r.events.map(({id:e,label:t,description:i,summary:n,authoredAt:o,phaseId:r,boundaryRank:s,effects:a})=>({id:e,label:t,description:i,summary:n,authoredAt:o,phaseId:r,boundaryRank:s,effects:a}))},JSON.stringify(mr(d)));var d;const h=dr(s.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),p=[...t.diagnostics,...r.diagnostics,...s.diagnostics,...l],f={phases:t.phases,events:r.events,products:o,outlets:n,duration:i,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:ar(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:p},y=vr(f),g=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Wo("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return f.terminalState=y.state,f.terminalSpawns=pA(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...p,...y.diagnostics,...m],f}function kr(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Ar(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Sr(e,t){let i=2166136261;const n=Ar(t);for(let e=0;n.length>e;e++)i^=n.charCodeAt(e),i=Math.imul(i,16777619);return`${e}-hatch-${(i>>>0).toString(36)}`}function Mr(e,t){const{background:i="transparent",stroke:n="#000",lineWidth:o=1.5,spacing:r=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*r));/* @__PURE__ */ /* @__PURE__ */
|
|
1
|
+
async function e(e,t,i,n){const{format:o="png",scale:r=1}=n;let s;try{const e="sharp",t=await(import(e));s=t.default??t}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const a=s(void 0!==globalThis.Buffer?globalThis.Buffer.from(e):(new TextEncoder).encode(e),{density:72*r}).resize(Math.round(t*r),Math.round(i*r));return"jpeg"===o?a.jpeg({quality:90}).toBuffer():a.png().toBuffer()}async function t(e,t,i,n={}){const{fps:o=12,loop:r=!0,scale:s=1}=n,a=Math.round(t*s),c=Math.round(i*s);let l,u,d,h;try{const e="sharp",t=await(import(e));l=t.default??t}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const e="gifenc",t=await(import(e)),i=[t,t.default].find(e=>"function"==typeof e?.GIFEncoder&&"function"==typeof e.quantize&&"function"==typeof e.applyPalette);if(!i)throw Error("gifenc did not expose its encoder functions");u=i.GIFEncoder,d=i.quantize,h=i.applyPalette}catch(e){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:e})}const p=Math.round(1e3/o),f=u();for(let t=0;e.length>t;t++){const i=e[t],n=await l(Buffer.from(i),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),o=new Uint8Array(n),u=d(o,256),y=h(o,u);f.writeFrame(y,a,c,{palette:u,delay:p,repeat:r?0:-1})}return f.finish(),Buffer.from(f.bytes())}function i(e){const t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),n=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:n,rightAxis:o,xAxis:t??i,yAxis:n??o,xOrient:t||!i?"bottom":"top",yOrient:n||!o?"left":"right"}}function n(e){let t=6;for(let i=1;e.length>i;i++){const n=Math.abs(e[i]-e[i-1]);n>0&&Number.isFinite(n)&&(t=Math.max(t,Math.ceil(Math.log10(Math.max(Math.abs(e[i]),Math.abs(e[i-1]))/n))+1))}const i=Math.min(17,t);return e=>Number.isInteger(e)?e+"":Number(e.toPrecision(i))+""}function o(...e){let t;for(const i of e)i&&(t=r(t)&&r(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function s(e){return"object"==typeof e&&null!==e&&"gradient"in e}function a(e){return"string"==typeof e&&e.length>0}function c(e,t,i=!1){const n=i?t?rw:ow:t?nw:0;return n>e.top?{...e,top:n}:e}function l(e,t){return c(e,a(t))}function u(e,t,i,n,o=8){const r=n,s="left"===n?"right":"right"===n?"left":"top"===n?"bottom":"top",a=Math.max(t[r],Math.max(0,("left"===n||"right"===n?i[0]:i[1])-o)-e[s]);e[r]>a&&(e[r]=a)}function d(e){return Math.ceil(7*e.length)}function h(e,t){if(r(e)){const i=A(t);let n=dw;for(const t of e.legendGroups){t.label&&(n=Math.max(n,d(t.label)));for(const e of t.items)n=Math.max(n,i.swatchSize+i.labelGap+d(e.label))}return n}if(s(e)){const{gradient:t}=e,i=t.format||n(t.domain),o=Math.max(d(i(t.domain[0])),d(i(t.domain[1]))),r=t.label?d(t.label):0;return Math.max(dw,19+o,r)}return dw}function p(e){return(r(e)||s(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):hw}function f(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?kw:ww:0}function y(e){return Math.max(0,e?.edgeGutter??pw)}function g(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?vw:bw:xw:0}function m(e){const{bottomAxis:t,topAxis:n,leftAxis:o,rightAxis:r}=i(e.axes),s=!(n&&!t||!1===t?.visible),a=!!n&&!t&&!1!==n.visible,c=!(r&&!o||!1===o?.visible),l=!!r&&!1!==r.visible,u=!1!==e.showAxes;return{hasAxis:u&&s,hasAxisLabel:u&&s&&!!(t?.label??e.xLabel),rotatedTicks:u&&s&&(e.rotatedTicks??!!t?.autoRotate),topAxis:a?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??e.xLabel),rotatedTicks:u&&(e.rotatedTicks??!!n?.autoRotate)}:void 0,leftAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??e.yLabel)}:void 0,rightAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??e.yLabelRight??e.yLabel)}:void 0}}function x(e){const t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}function b(e,t,i){if(s(e))return e.gradient.label?gw:mw;if(!r(e))return 20;const n=A(i),o=Math.max(1,i?.maxWidth??t);let a=n.rowHeight;for(const t of e.legendGroups){let e=0,i=0;for(const r of t.items){const t=n.swatchSize+n.labelGap+d(r.label),s=0===i?t:i+n.itemGap+t;i>0&&s>o?(e+=1,i=t):i=s}t.items.length>0&&(e+=1),a=Math.max(a,e*n.rowHeight,t.label?d(t.label):0)}return a+(e.legendGroups.length>1?16:0)}function v(e,t,i){return h(e,t)+p(e)+f(t,i)+y(t)}function w(e,t){const{legend:i}=t;if(!i)return;const n=t.position??"right",o=b(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+p(i)+g("bottom"===n?t.axisChrome:"top"===n?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===n&&t.hasTitle?24:0),r=Math.max(t.minimumMargin??0,"top"===n?t.hasTitle?rw:ow:0);"right"===n?e.right=Math.max(e.right,r,v(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===n?e.left=Math.max(e.left,r,v(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===n?e.top=Math.max(e.top,r,o):e.bottom=Math.max(e.bottom,r,o)}function k(e,t){const i=t.position??"right",n="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),r=Math.max(1,n?t.legendLayout?.maxWidth??o:t.reservedWidth??h(e,t.legendLayout)),s=p(e),a=f(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),c=y(t.legendLayout),l=b(e,o,t.legendLayout),u=g(t.axisChrome,t.legendLayout),d=g(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(c,t.margin.left-a-r-s),y:t.margin.top,width:r,height:l};if("top"===i)return{x:t.margin.left,y:t.margin.top-d-s-l,width:r,height:l};if("bottom"===i){const e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+s,Math.min(e+u+s,t.totalHeight-l)),width:r,height:l}}return{x:Math.min(t.totalWidth-r-c,t.totalWidth-t.margin.right+a+s),y:t.margin.top,width:r,height:l}}function A(e){const t=Math.max(1,e?.swatchSize??aw),i=Math.max(t,e?.rowHeight??uw);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??cw),itemGap:Math.max(0,e?.itemGap??lw),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function S(e,t){let i=24;return e.map(({hasLabel:e,itemCount:n})=>{i+=5;const o=i;let r;i+=8,e&&(i+=16,r=i,i+=8);const s=i;return i+=n*t+8,{lineY:o,labelY:r,itemsY:s,endY:i}})}function M(e,t,i=!1){const n={...e};for(const e of t??[])!1!==e.visible||"top"===e.orient&&i||(n[e.orient]=0);return n}function _(e){let t=0;for(;e.length>t;){const i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);const n=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(n){const i=e.indexOf(n,t+2);if(0>i)return;t=i+n.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",n=0,o=t+9;for(;e.length>o;o+=1){const t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){const t=e.indexOf("--\x3e",o+4);if(0>t)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)n+=1;else if("]"===t)n-=1;else if(">"===t&&0===n)break}if(o===e.length)return;t=o+1;continue}break}const i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;const n=i[2].endsWith("/"),o=n?i[2].slice(0,-1):i[2];return o.replace(Aw,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:n}}function $(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function P(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];const i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&1114111>=i?String.fromCodePoint(i):e})}function j(e,t){for(const i of e.attributes.matchAll(Aw))if(i[1]===t)return P(i[2]??i[3])}function I(e,t){const i=_(e)?.start??0;return e.slice(0,i)+e.slice(i).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,i)=>i?e.replace(Aw,(e,i,n,o)=>{const r=t(i,P(n??o));return void 0===r?e:` ${i}="${$(r)}"`}):e)}function L(e,t){const i=_(e);if(!i)return e;const n=new Map(Object.entries(t));let o=i.attributes.replace(Aw,(e,t)=>{const i=n.get(t);return void 0===i?e:(n.delete(t),` ${t}="${$(i)}"`)});for(const[e,t]of n)o+=` ${e}="${$(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function R(e,t){const i=_(e);if(!i)return t;const n=e=>{const n=j(i,e),o=n&&/^[0-9]+(?:\.[0-9]+)?$/.test(n)?Number(n):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:n("width"),height:n("height")}}function C(e,t){const i=_(e);return i?L(e,{width:"100%",height:"100%",...void 0===j(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===j(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function T(e){return null==e?"null":Array.isArray(e)?`[${e.map(T).join(",")}]`:e instanceof Date?JSON.stringify(e):"object"==typeof e?`{${Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>t>e?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${T(t)}`).join(",")}}`:JSON.stringify(e)}function O(e){const t=[..._w],i=Array.from((new TextEncoder).encode(e)),n=8*i.length;for(i.push(128);i.length%64!=56;)i.push(0);const o=Math.floor(n/4294967296),r=n>>>0;i.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o,r>>>24&255,r>>>16&255,r>>>8&255,255&r);const s=[];for(let e=0;i.length>e;e+=4)s.push((i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0);for(let e=0;s.length>e;e+=16){const i=[...s.slice(e,e+16)];for(let e=16;64>e;e+=1){const t=Sw(i[e-15],7)^Sw(i[e-15],18)^i[e-15]>>>3,n=Sw(i[e-2],17)^Sw(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+n>>>0}let[n,o,r,a,c,l,u,d]=t;for(let e=0;64>e;e+=1){const t=d+(Sw(c,6)^Sw(c,11)^Sw(c,25))+(c&l^~c&u)+$w[e]+i[e]>>>0,s=n&o^n&r^o&r;d=u,u=l,l=c,c=a+t>>>0,a=r,r=o,o=n,n=t+((Sw(n,2)^Sw(n,13)^Sw(n,22))+s>>>0)>>>0}const h=[n,o,r,a,c,l,u,d];for(let e=0;8>e;e+=1)t[e]=t[e]+h[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function E(e,t){return`${e}[Symbol(${t.description??""})]`}function F(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function N(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function z(e){return e.sort((e,t)=>{const i=JSON.stringify(e),n=JSON.stringify(t);return n>i?-1:i>n?1:0})}function D(e,t,i){if(null===e)return null;if(e instanceof Date){const n=e.getTime();return Number.isFinite(n)?{$type:"date",value:e.toISOString()}:void i.excluded.push(t)}switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isNaN(e)?{$type:"number",value:"NaN"}:e===1/0?{$type:"number",value:"Infinity"}:e===-1/0?{$type:"number",value:"-Infinity"}:Object.is(e,-0)?{$type:"number",value:"-0"}:e;case"bigint":return{$type:"bigint",value:""+e};case"undefined":case"function":case"symbol":return void i.excluded.push(t);case"object":{const n=e;if(i.ancestors.has(n))return void i.excluded.push(t);i.ancestors.add(n);try{if(Array.isArray(e)){for(const n of Reflect.ownKeys(e))"length"===n||"string"==typeof n&&F(n,e.length)||i.excluded.push("symbol"==typeof n?E(t,n):N(t,n));return Array.from({length:e.length},(n,o)=>{const r=N(t,o),s=Object.getOwnPropertyDescriptor(e,o+"");if(!s||!("value"in s)||!s.enumerable)return i.excluded.push(r),null;const a=D(s.value,r,i);return void 0===a?null:a})}const n={},o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return void i.excluded.push(t);const r=[];for(const n of Reflect.ownKeys(e)){if("symbol"==typeof n){i.excluded.push(E(t,n));continue}const o=Object.getOwnPropertyDescriptor(e,n);o&&"value"in o&&o.enumerable?r.push(n):i.excluded.push(N(t,n))}for(const o of r.sort()){const r=Object.getOwnPropertyDescriptor(e,o),s=D(r&&"value"in r?r.value:void 0,N(t,o),i);void 0!==s&&Object.defineProperty(n,o,{value:s,enumerable:!0,configurable:!0,writable:!0})}return n}finally{i.ancestors.delete(n)}}default:return void i.excluded.push(t)}}function B(e,t=/* @__PURE__ */new Set){if(null===e)return["null"];if(e instanceof Date)return Number.isFinite(e.getTime())?["date",e.toISOString()]:["excluded"];switch(typeof e){case"string":return["string",e];case"boolean":return["boolean",e];case"number":return["number",Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Object.is(e,-0)?"-0":e+""];case"bigint":return["bigint",""+e];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(t.has(e))return["excluded"];t.add(e);try{const i=i=>{const n="symbol"==typeof i?["symbol-key",i.description??""]:["string-key",i],o=Object.getOwnPropertyDescriptor(e,i);return o?"value"in o?[n,"data",!!o.enumerable,B(o.value,t)]:[n,"accessor",!!o.enumerable,!!o.get,!!o.set]:[n,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,n)=>{const o=n+"";return Object.prototype.hasOwnProperty.call(e,o)?i(o):["hole"]}),z(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&F(t,e.length))).map(i))];const n=Object.getPrototypeOf(e);return[n!==Object.prototype&&null!==n?"non-json-object":"object",z(Reflect.ownKeys(e).map(i))]}finally{t.delete(e)}default:return["excluded"]}}function W(e){const t={excluded:[],ancestors:/* @__PURE__ */new Set},i=D(e,"$",t)??null;return{value:i,text:JSON.stringify(i),excludedPaths:t.excluded}}function Y(e){const t=W(e),i=O(JSON.stringify(["semiotic-value-fingerprint","v2",B(e)]));return{...t,algorithm:"sha256",digest:i,fingerprint:"sha256:"+i}}function q(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function X(e,t){return`${e}[Symbol(${t.description??""})]`}function G(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;const i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function V(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function H(e,t,i,n){const o=V(e,t);return o&&"value"in o&&o.enumerable?U(o.value,i,n):[i]}function U(e,t="$",i=/* @__PURE__ */new Set){if(null===e||"string"==typeof e||"boolean"==typeof e)return[];if("number"==typeof e)return Number.isFinite(e)&&!Object.is(e,-0)?[]:[t];if("object"!=typeof e)return[t];if(i.has(e))return[t];let n,o,r;try{r=Array.isArray(e),n=Object.getPrototypeOf(e),o=Reflect.ownKeys(e)}catch{return[t]}if(n!==(r?Array.prototype:Object.prototype)&&null!==n)return[t];i.add(e);const s=[];try{if(r){const n=V(e,"length")?.value;if(!Number.isSafeInteger(n)||0>n)return[q(t,"length")];for(const e of o)"length"===e||"string"==typeof e&&G(e,n)||s.push("symbol"==typeof e?X(t,e):q(t,e));for(let o=0;n>o;o+=1)s.push(...H(e,o+"",q(t,o),i))}else for(const n of o)"symbol"!=typeof n?s.push(...H(e,n,q(t,n),i)):s.push(X(t,n));return s}catch{return[t]}finally{i.delete(e)}}function K(e,t,i,n){ne(e,Object.keys(t),i,n);for(const[o,r]of Object.entries(t))r.values?(r.required||void 0!==e[o])&&re(e,o,i,r.values,n):r.required?oe(e,o,i,n):ue(e,o,i,n)}function Z(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Q(e,t,i,n){void 0===e[t]||"number"==typeof e[t]&&Number.isFinite(e[t])||n.push({path:`${i}.${t}`,message:"Expected a finite number."})}function J(e,t,i,n){void 0!==e[t]&&"boolean"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a boolean."})}function ee(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(ee):Z(e)&&Object.values(e).every(ee))}function te(e,t,i,n){void 0===e[t]||Z(e[t])&&ee(e[t])||n.push({path:`${i}.${t}`,message:"Expected a JSON object."})}function ie(e){return e.every(ee)}function ne(e,t,i,n){const o=new Set(t);for(const t of Object.keys(e))o.has(t)||n.push({path:`${i}.${t}`,message:"Unexpected property."})}function oe(e,t,i,n){"string"==typeof e[t]&&e[t]||n.push({path:`${i}.${t}`,message:"Expected a non-empty string."})}function re(e,t,i,n,o){"string"==typeof e[t]&&n.includes(e[t])||o.push({path:`${i}.${t}`,message:`Expected one of: ${n.join(", ")}.`})}function se(e,t,i,n){const o=e[t];if(void 0!==o){if(Z(o))return o;n.push({path:`${i}.${t}`,message:"Expected an object."})}}function ae(e,t,i,n){const o=e[t];if(void 0!==o){if(Array.isArray(o))return o;n.push({path:`${i}.${t}`,message:"Expected an array."})}}function ce(e,t,i){e?.some(e=>"string"!=typeof e||!e)&&i.push({path:t,message:"Expected non-empty string values."})}function le(e,t,i,n,o){void 0!==e[t]&&re(e,t,i,n,o)}function ue(e,t,i,n){void 0!==e[t]&&"string"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a string."})}function de(e,t,i){Z(e)?(ne(e,["id","name","kind"],t,i),oe(e,"kind",t,i),ue(e,"id",t,i),ue(e,"name",t,i)):i.push({path:t,message:"Expected an actor object."})}function he(e,t){const i=se(e,"reception","$",t);if(!i)return;ne(i,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);const n=ae(i,"channels","$.reception",t);n||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),n?.forEach((e,i)=>{const n=`$.reception.channels[${i}]`;Z(e)?(ne(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],n,t),re(e,"channel",n,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),le(e,"disclosure",n,["summary","standard","detailed"],t),le(e,"rawData",n,["deny","bounded","allow"],t),J(e,"navigation",n,t),J(e,"interactionInstructions",n,t),Q(e,"tokenBudget",n,t),ce(ae(e,"privacyNotes",n,t),n+".privacyNotes",t)):t.push({path:n,message:"Expected a channel object."})});for(const e of["strengths","risks","scaffolds","manualChecks"])ce(ae(i,e,"$.reception",t),"$.reception."+e,t);ue(i,"audience","$.reception",t),ue(i,"description","$.reception",t),J(i,"dataFallback","$.reception",t)}function pe(e,t){const i=se(e,"form","$",t);i&&(ne(i,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),ue(i,"chartFamily","$.form",t),ue(i,"whyThisForm","$.form",t),ce(ae(i,"risks","$.form",t),"$.form.risks",t),ce(ae(i,"misuse","$.form",t),"$.form.misuse",t),ae(i,"rejectedAlternatives","$.form",t)?.forEach((e,i)=>{const n=`$.form.rejectedAlternatives[${i}]`;Z(e)?(ne(e,["representation","reason"],n,t),oe(e,"representation",n,t),oe(e,"reason",n,t)):t.push({path:n,message:"Expected an alternative object."})}))}function fe(e,t){const i=se(e,"contestability","$",t);i&&(ne(i,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),J(i,"sourceRequestsAllowed","$.contestability",t),ae(i,"challenges","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.challenges[${i}]`;if(Z(e)){ne(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],n,t),oe(e,"id",n,t),oe(e,"claimId",n,t),oe(e,"reason",n,t),re(e,"status",n,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&de(e.raisedBy,n+".raisedBy",t);for(const i of["raisedAt","counterclaimId","resolution"])ue(e,i,n,t)}else t.push({path:n,message:"Expected a challenge object."})}),ae(i,"corrections","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.corrections[${i}]`;if(!Z(e))return void t.push({path:n,message:"Expected a correction object."});ne(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],n,t),oe(e,"id",n,t),oe(e,"reason",n,t);const o=ae(e,"affectedClaimIds",n,t);o||t.push({path:n+".affectedClaimIds",message:"Expected an affected-claim array."}),ce(o,n+".affectedClaimIds",t),ce(ae(e,"replacementClaimIds",n,t),n+".replacementClaimIds",t),ue(e,"createdAt",n,t),void 0!==e.createdBy&&de(e.createdBy,n+".createdBy",t)}),ae(i,"alternativeViews","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.alternativeViews[${i}]`;Z(e)?(ne(e,["id","label","rationale"],n,t),oe(e,"id",n,t),oe(e,"label",n,t),ue(e,"rationale",n,t)):t.push({path:n,message:"Expected an alternative-view object."})}),ae(i,"editorialExceptions","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.editorialExceptions[${i}]`;Z(e)?(ne(e,["ruleId","rationale","owner","reviewAt"],n,t),oe(e,"ruleId",n,t),oe(e,"rationale",n,t),ue(e,"owner",n,t),ue(e,"reviewAt",n,t)):t.push({path:n,message:"Expected an editorial-exception object."})}))}function ye(e,t){const i=se(e,"accountability","$",t);i&&(ne(i,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),ae(i,"authors","$.accountability",t)?.forEach((e,i)=>de(e,`$.accountability.authors[${i}]`,t)),ce(ae(i,"dataSources","$.accountability",t),"$.accountability.dataSources",t),ue(i,"generatedBy","$.accountability",t),ue(i,"codeRef","$.accountability",t),ae(i,"reviews","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.reviews[${i}]`;if(Z(e)){ne(e,["id","status","reviewer","reviewedAt","rationale","policyId"],n,t),oe(e,"id",n,t),re(e,"status",n,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&de(e.reviewer,n+".reviewer",t);for(const i of["reviewedAt","rationale","policyId"])ue(e,i,n,t)}else t.push({path:n,message:"Expected a review object."})}),ae(i,"actions","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.actions[${i}]`;if(!Z(e))return void t.push({path:n,message:"Expected an action object."});ne(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],n,t),oe(e,"id",n,t),oe(e,"action",n,t);const o=ae(e,"claimIds",n,t);o||t.push({path:n+".claimIds",message:"Expected a claim identifier array."}),ce(o,n+".claimIds",t),void 0!==e.actor&&de(e.actor,n+".actor",t);for(const i of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])ue(e,i,n,t);le(e,"status",n,["proposed","taken","reversed","invalidated"],t)}))}function ge(e,t){const i=se(e,"inheritance","$",t);if(i){ne(i,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(const e of["requiredPaths","prohibitedExports","sourceArtifactIds"])ce(ae(i,e,"$.inheritance",t),"$.inheritance."+e,t);le(i,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),le(i,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),le(i,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function me(e,t){he(e,t),pe(e,t),fe(e,t),ye(e,t),ge(e,t)}function xe(e){for(const t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function be(e,t){if(void 0===e||Z(e)){if(Z(e))for(const[i,n]of Object.entries(e)){const e="$.fieldStatus."+i;if(!Z(n)||"string"!=typeof n.status){t.push({path:e,message:"Expected a field state with a status."});continue}ne(n,["status","reason","suppliedBy","derived","reviewedBy"],e,t),["known","unknown","manual","not-applicable"].includes(n.status)||t.push({path:e+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0===n.suppliedBy||"string"==typeof n.suppliedBy&&["author","system","model-proposal","import"].includes(n.suppliedBy)||t.push({path:e+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),ue(n,"reason",e,t),ue(n,"reviewedBy",e,t),J(n,"derived",e,t);const o=Object.prototype.hasOwnProperty.call(jw,i)?jw[i]:void 0,r="model-proposal"===n.suppliedBy,s=r&&!0===o?.modelMayPropose&&"known"!==n.status;o&&"known"===n.status&&"string"!=typeof n.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${i}" must identify an allowed supplier.`}),!o||"string"!=typeof n.suppliedBy||s||o.suppliedBy.includes(n.suppliedBy)||t.push({path:e+".suppliedBy",message:`Field "${i}" cannot be supplied by ${n.suppliedBy}.`}),o&&!0===n.derived&&!o.derivable&&t.push({path:e+".derived",message:`Field "${i}" cannot be marked as derived.`}),!o||!r||o.modelMayPropose&&"known"!==n.status||t.push({path:e+".suppliedBy",message:"known"===n.status?`A model proposal cannot finalize field "${i}" as known.`:`Field "${i}" does not accept model proposals.`}),"required"!==o?.humanReview||"known"!==n.status||"string"==typeof n.reviewedBy&&n.reviewedBy.trim()||t.push({path:e+".reviewedBy",message:`Known field "${i}" requires an attributable human review.`})}}else t.push({path:"$.fieldStatus",message:"Expected a field-state object."})}function ve(e,t){const i="$.time";ne(e,[...Rw,...Object.keys(Cw),"sources"],i,t);for(const n of Rw)ue(e,n,i,t);for(const[n,o]of Object.entries(Cw)){const r=se(e,n,i,t);r&&K(r,o,`${i}.${n}`,t)}ae(e,"sources",i,t)?.forEach((e,n)=>{const o=`${i}.sources[${n}]`;Z(e)?K(e,Tw,o,t):t.push({path:o,message:"Expected a source object."})})}function we(e){try{return ke(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function ke(e){const t=[],i=[];if(!Z(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:i};const n=U(e);if(n.length>0)return{valid:!1,errors:n.map(e=>({path:e,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:i};if(ne(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),e.contractVersion!==Pw&&t.push({path:"$.contractVersion",message:`Expected contract version ${Pw}.`}),Z(e.artifact)){ne(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),oe(e.artifact,"id","$.artifact",t),re(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(const i of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])ue(e.artifact,i,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(Z(e.purpose))if(Array.isArray(e.purpose.intents)){ne(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,i)=>{Z(e)&&"string"==typeof e.id&&e.id||t.push({path:`$.purpose.intents[${i}].id`,message:"Expected a non-empty intent identifier."}),Z(e)&&ne(e,["id","strength","source","rationale"],`$.purpose.intents[${i}]`,t),Z(e)&&void 0!==e.strength&&re(e,"strength",`$.purpose.intents[${i}]`,["primary","secondary"],t),Z(e)&&(le(e,"source",`$.purpose.intents[${i}]`,["author","derived","model-proposal","import"],t),ue(e,"rationale",`$.purpose.intents[${i}]`,t))});for(const i of["allowedUses","prohibitedUses"])ce(ae(e.purpose,i,"$.purpose",t),"$.purpose."+i,t);le(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),ue(e.purpose,"communicativeAct","$.purpose",t),ue(e.purpose,"decisionContext","$.purpose",t)}else t.push({path:"$.purpose.intents",message:"Expected an intent array."});else t.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(e.claims)?e.claims.forEach((e,i)=>{if(!Z(e))return void t.push({path:`$.claims[${i}]`,message:"Expected a claim object."});ne(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${i}]`,t),oe(e,"id",`$.claims[${i}]`,t),re(e,"kind",`$.claims[${i}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),re(e,"status",`$.claims[${i}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],t),Array.isArray(e.evidenceIds)?e.evidenceIds.some(e=>"string"!=typeof e||!e)&&t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected an evidence identifier array."}),ce(ae(e,"supersedes",`$.claims[${i}]`,t),`$.claims[${i}].supersedes`,t),ue(e,"text",`$.claims[${i}]`,t),ue(e,"asOf",`$.claims[${i}]`,t),te(e,"scope",`$.claims[${i}]`,t),ce(ae(e,"tags",`$.claims[${i}]`,t),`$.claims[${i}].tags`,t),void 0!==e.authoredBy&&de(e.authoredBy,`$.claims[${i}].authoredBy`,t);const n=se(e,"review",`$.claims[${i}]`,t);n&&(ne(n,["status","reviewer","reviewedAt","rationale"],`$.claims[${i}].review`,t),re(n,"status",`$.claims[${i}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==n.reviewer&&de(n.reviewer,`$.claims[${i}].review.reviewer`,t),ue(n,"reviewedAt",`$.claims[${i}].review`,t),ue(n,"rationale",`$.claims[${i}].review`,t));const o=se(e,"uncertainty",`$.claims[${i}]`,t);if(o){ne(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${i}].uncertainty`,t),re(o,"kind",`$.claims[${i}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(const e of["lower","upper","confidence"])Q(o,e,`$.claims[${i}].uncertainty`,t);ue(o,"unit",`$.claims[${i}].uncertainty`,t),ue(o,"description",`$.claims[${i}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,i)=>{if(!Z(e))return void t.push({path:`$.evidence[${i}]`,message:"Expected an evidence object."});ne(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${i}]`,t),oe(e,"id",`$.evidence[${i}]`,t),re(e,"role",`$.evidence[${i}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(const n of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])ue(e,n,`$.evidence[${i}]`,t);te(e,"scope",`$.evidence[${i}]`,t);const n=se(e,"source",`$.evidence[${i}]`,t);if(n){ne(n,["name","uri","version","retrievedAt","publisher"],`$.evidence[${i}].source`,t);for(const e of["name","uri","version","retrievedAt","publisher"])ue(n,e,`$.evidence[${i}].source`,t)}const o=se(e,"transformation",`$.evidence[${i}]`,t);if(o){ne(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${i}].transformation`,t),oe(o,"id",`$.evidence[${i}].transformation`,t),re(o,"kind",`$.evidence[${i}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);const e=ae(o,"inputEvidenceIds",`$.evidence[${i}].transformation`,t);e?ce(e,`$.evidence[${i}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${i}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),ce(ae(o,"assumptions",`$.evidence[${i}].transformation`,t),`$.evidence[${i}].transformation.assumptions`,t),ue(o,"description",`$.evidence[${i}].transformation`,t),ue(o,"implementation",`$.evidence[${i}].transformation`,t),ue(o,"performedAt",`$.evidence[${i}].transformation`,t),te(o,"parameters",`$.evidence[${i}].transformation`,t),void 0!==o.performedBy&&de(o.performedBy,`$.evidence[${i}].transformation.performedBy`,t)}const r=se(e,"sample",`$.evidence[${i}]`,t);if(r){ne(r,["rowCount","fields","values","truncated"],`$.evidence[${i}].sample`,t),ce(ae(r,"fields",`$.evidence[${i}].sample`,t),`$.evidence[${i}].sample.fields`,t);const e=ae(r,"values",`$.evidence[${i}].sample`,t);e&&!ie(e)&&t.push({path:`$.evidence[${i}].sample.values`,message:"Expected JSON values."}),Q(r,"rowCount",`$.evidence[${i}].sample`,t),J(r,"truncated",`$.evidence[${i}].sample`,t)}le(e,"relationship",`$.evidence[${i}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),be(e.fieldStatus,t);const o=se(e,"time","$",t);return o&&ve(o,t),me(e,t),te(e,"extensions","$",t),Array.isArray(e.claims)&&0===e.claims.length&&i.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(e.evidence)&&0===e.evidence.length&&i.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===t.length,errors:t,warnings:i}}function Ae(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Se(e,t){if(!t||!Ae(e)||!Array.isArray(e.evidence))return[];const i=[];return e.evidence.forEach((e,t)=>{Ae(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,i.push(`$.evidence[${t}].sample`))}),i}function Me(e,t={}){try{return _e(e,t)}catch{const t=U(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function _e(e,t){if(!Ae(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const i=W(e),n=[.../* @__PURE__ */new Set([...i.excludedPaths,...U(e)])].sort(),o=i.value,r=Se(o,t.excludeEvidenceSamples),s=r.length?["Bounded evidence samples were excluded by the transfer policy."]:[],a=o?.contractVersion;if("string"!=typeof a||!a)return{contract:o,transfer:{status:"invalid",omittedPaths:[...n,...r],warnings:["Artifact contract is missing a string contractVersion.",...s]}};if(a!==Pw)return{contract:o,transfer:{status:n.length>0?"invalid":"unsupported-version",omittedPaths:[...n,...r],warnings:[`Contract version ${a} is not interpreted by this runtime.`,...n.length>0?[`Non-JSON values could not be preserved at: ${n.join(", ")}.`]:[],...s]}};const c=we(o),l=[...c.errors.map(({path:e,message:t})=>`${e}: ${t}`),...c.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...n.length?[`Non-JSON values could not be preserved at: ${n.join(", ")}.`]:[],...s];return{contract:o,transfer:{status:!c.valid||n.length>0?"invalid":r.length>0?"excluded":"preserved",omittedPaths:[...n,...r],warnings:l}}}function $e(e,t){return Ow.has(e)&&!("reading"===e&&"string"==typeof t)}function Pe(e){const t=Object.entries(e).filter(([e,t])=>$e(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function je(e,t=[]){if(void 0===e)return;const i=t.filter(e=>!!e.transformation).map(({id:e,transformation:t})=>({evidenceId:e,transformation:t})).sort(({evidenceId:e},{evidenceId:t})=>t>e?-1:e>t?1:0);return Y(i.length>0?{data:e,transformations:i}:e).fingerprint}function Ie(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!$e(e,t)&&"recipeId"!==e))}function Le(e,t,i,n=Pe(t)){const o=Ie(t),r=0===U(o).length?Y(o).fingerprint:void 0,s=void 0!==n&&0===U(n).length?je(n,e.evidence):void 0,a="ChartRecipe"===i&&"string"==typeof t.recipeId?t.recipeId:i,c=[],l=[];return void 0!==a&&(void 0===e.artifact.component?l.push("artifact.component"):e.artifact.component!==a&&c.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===r?l.push("artifact.configFingerprint"):e.artifact.configFingerprint!==r&&c.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&s?e.artifact.dataFingerprint!==s&&c.push("artifact.dataFingerprint"):l.push("artifact.dataFingerprint"),{status:c.length>0?"mismatch":l.length>0?"unknown":"match",mismatchPaths:c,unknownPaths:l}}function Re(e,t){return O(T({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories}))}function Ce(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Te(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function Oe(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function Ee(e,t){const{when:i}=e,n=t.width,o=t.height,r=Oe(t),s=Te(t);return!("number"==typeof i.minWidth&&i.minWidth>n||"number"==typeof i.maxWidth&&n>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||i.minHeight>o)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof r||i.minAspectRatio>r)||"number"==typeof i.maxAspectRatio&&("number"!=typeof r||r>i.maxAspectRatio)||i.orientation&&s!==i.orientation)}function Fe(e,t){const i={...e,...t};for(const n of["margin","frameProps","mobileSemantics","style"])Ce(e[n])&&Ce(t[n])&&(i[n]={...e[n],...t[n]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}function Ne(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};const n=i.map((e,t)=>({rule:e,index:t})).filter(e=>Ee(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:n.reduce((e,t)=>Fe(e,t.rule.transform),e),matches:n}}function ze(e,t={}){const i=t.mobileSemantics?.interaction,n="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,r=!!i||void 0!==n,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!r)return Nw;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??n??Ew,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??Ew,standardControls:a.standardControls??!1}}function De(e,t,i){const n=zw[e||"primary"],o=e&&"primary"!==e||!i?.width?n.width:i.width,r=e&&"primary"!==e||!i?.height?n.height:i.height,s=Ne({...t,mode:e},{width:t.width??o,height:t.height??r}).props,a=s.mode||e||"primary",c=zw[a],l="context"===a||"sparkline"===a,u="primary"===a&&i?.width?i.width:c.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&i?.height?i.height:c.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:Be(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:ze(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function Be(e,t,i){if(!1!==t)return e;const n={...e};return"horizontal"===i?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function We(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Ye(e,t,i,n){const o=e??t;return"function"==typeof o?o(i,n):i[o+""]}function qe(e){const t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,n)=>{if(!Number.isFinite(Number(Ye(e.yAccessor,"y",i,n))))return;const o=We(Ye(e.xAccessor,"x",i,n)),r=t.get(o)??/* @__PURE__ */new Set;r.add(Ye(e.lineBy,"series",i,n)+""),t.set(o,r)});const i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];const n=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[n]:(i[n-1]+i[n])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},r=2>o.max;return r||2>o.contestedColumns||2>o.median?[{code:r?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:r?"error":"warning",message:r?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]:[]}function Xe(e){return Yw.has(e)}function Ge(e){return Yw.get(e)}function Ve(e){return Xe(e)?Ge(e):"BumpChart"===e?Dw:void 0}function He(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function Ue(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;const n=Ve(t);if(!n)return;let o;try{const t="function"==typeof n?n(i,e):qe(i);o=Array.from(t).filter(He)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=o,e.semanticStatus=o.some(e=>"error"===e.severity)?"degenerate":o.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(const t of o)e.warnings.includes(t.code)||e.warnings.push(t.code)}function Ke(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}function Ze(e){return`${e.getUTCFullYear()}-${Qe(e.getUTCMonth()+1)}-${Qe(e.getUTCDate())}`}function Qe(e){return 10>e?"0"+e:e+""}function Je(e,t){if(!t)return!0;const i=Array.isArray(t)?t:[t],n=e;for(const e of i)if(null!=e.value&&n[e.field]+""!=e.value+"")return!1;return!0}function et(e,t={}){const i=t.baseOpacity??1;return t.highlight||t.predicate?!Je(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function tt(e){if(0===e.length)return 0;let t=0;for(const i of e)t+=i;return t/e.length}function it(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,Kw.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function nt(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>st(t(e))}function ot(e,t){const i=nt(e),n=nt(t);return(e,t)=>{const o=n(e);return{value:o,x:i(e),y:o,category:t}}}function rt(e,t){const i=nt(t??"value"),n=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=n?n(e):void 0;return{value:i(e),category:null==t?void 0:t+""}}}function st(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function at(e,t,i){const n=null!=e.axis?i[e.axis]:null!=e.field?t[e.field]:i.value;if(void 0!==e.eq&&n!==e.eq)return!1;if(void 0!==e.ne&&n===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(n))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=st(n);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,i]=e.within;if(t>o||o>i)return!1}if(void 0!==e.outside){const[t,i]=e.outside;if(o>=t&&i>=o)return!1}return!0}function ct(e,t,i){const n=e.when;return void 0===n||!0===n||!1!==n&&("function"==typeof n?n(t,i):at(n,t,i))}function lt(e,t,i){if(!t||0===t.length)return{};let n={};for(const o of t){if(!ct(o,e,i))continue;const t="function"==typeof o.style?o.style(e,i):o.style;t&&(n={...n,...t})}return n}function ut(e,t,i,n=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,r)=>{const s=n(e),a={...o(e,r)};return Object.assign(a,lt(s,t,i(s,r))),a}:o}function dt(e,t,i,n){if(!e||0===e.length)return n;const o=rt(t,i);return(t,i)=>{const r=t&&t.data||t,s=lt(r,e,o(r)),a=n?n(t,i):void 0;return a?{...s,...a}:s}}function ht(e){const[t,i]=e,n=160>t||116>i,o=n?Math.min(12,Math.max(2,.08*t)):32,r=n?Math.min(8,Math.max(2,.12*i)):24,s=n?r:34;return{width:t,height:i,plot:{x:o,y:r,width:Math.max(1,t-2*o),height:Math.max(1,i-r-s)}}}function pt(e){const t=(e??"")+"";if(!t)return"#4e79a7";const i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let n=0;for(let e=0;t.length>e;e+=1)n=31*n+t.charCodeAt(e)>>>0;return i[n%i.length]}function ft(e,t="#4e79a7",i){const n=i?.styleRules,o=!!n&&n.length>0,r=o?nt(i?.valueAccessor):void 0;return i=>{const s=i.datum,a=s&&e?"function"==typeof e?e(s,0):s[e]:void 0,c={fill:null==a?t:pt(a),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&s&&Object.assign(c,lt(s,n,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function yt(e,t,i,n){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:i},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...n}}}function gt(e,t,i){return"function"==typeof i?i(e,t):e[i]}function mt(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function xt(e,t,i){return Math.max(t,Math.min(i,e))}function bt(e,t){const i=mt(e);return null!=i&&i>0?i:t}function vt(e){if(!e)return;const t=mt(e[0]),i=mt(e[1]);return null!=t&&null!=i?t>i?[i,t]:[t,i]:void 0}function wt(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function kt(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function At(e){const t=Math.max(2,Math.round(e.bins)),i=Math.max(1,Math.round(e.pegRows??t-1)),n=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=xt(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),r=kt(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:n},(e,t)=>{let n=0;for(let e=0;i>e;e+=1)r()<o&&(n+=1);const a=i/2;return{id:`${s}-${t}`,value:n,mechanical:!0,pegRows:i,branchProbability:o,pathRights:n,side:a>n?"left":n>a?"right":"center"}})}function St(e,t,i=0){const n=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),o=/* @__PURE__ */new Map;for(const r of e){let e=null==r.id?`${t}-${i++}`:r.id+"";for(;null==r.id&&n.has(e);)e=`${t}-${i++}`;n.add(e),o.set(e,null==r.id?{...r,id:e}:r)}return{seed:e,rows:Array.from(o.values()),nextId:i}}function Mt(e){let t=1/0,i=-1/0;for(const n of e)t>n&&(t=n),n>i&&(i=n);return[t,i]}function _t(e,t=1/0){let i=t;for(const t of e)i>t&&(i=t);return i}function $t(e,t=-1/0){let i=t;for(const t of e)t>i&&(i=t);return i}function Pt(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}function jt(e){const t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function It(e){if(!e)return;const t=Number.isFinite(e.x)?e.x:void 0,i=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==i?void 0:{x:t,y:i}}function Lt(e,t,i){const n="x"===i?"y":"x",o=Math.abs(t[i]-e[i]),r=t[n]-e[n],s=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;let a;if("circle"===e.shape.type&&"circle"===t.shape.type){const i=e.shape.radius+t.shape.radius;a=Math.sqrt(Math.max(0,i*i-o*o))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)a=s(e,n)+s(t,n);else{const r="aabb"===e.shape.type?e:t,c=s("circle"===e.shape.type?e:t,i),l=Math.max(0,o-s(r,i));a=s(r,n)+Math.sqrt(Math.max(0,c*c-l*l))}const c=0>r?-1:1;return{nx:"x"===n?c:0,ny:"y"===n?c:0,penetration:Math.max(0,a-Math.abs(r))}}function Rt(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Ct(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Tt(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,...e.fixedPosition?{fixedPosition:It(e.fixedPosition)}:{},shape:Rt(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Ot(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Et(e){return{id:e.id,shape:Ct(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Ot(e.bodyFilter),index:e.index}}function Ft(e,t,i){return Math.max(t,Math.min(i,e))}function Nt(e,t,i){return Math.min(e??i,t??i)}function zt(e,t,i){return Ft(Math.max(e??i,t??i),0,1)}function Dt(e){return 0>e?-1:1}function Bt(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,i=e.shape.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}function Wt(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,i=t.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}const i=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-i,minY:Math.min(t.y1,t.y2)-i,maxX:Math.max(t.x1,t.x2)+i,maxY:Math.max(t.y1,t.y2)+i}}function Yt(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function qt(e,t,i,n,o,r){const s=n-e,a=o-t,c=i+r,l=s*s+a*a;if(l>=c*c)return null;if(sk>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}function Xt(e,t,i,n,o,r,s,a){const c=o-e,l=(i+s)/2-Math.abs(c);if(0>=l)return null;const u=r-t,d=(n+a)/2-Math.abs(u);return d>0?d>l?{nx:Dt(c),ny:0,penetration:l}:{nx:0,ny:Dt(u),penetration:d}:null}function Gt(e,t,i,n,o,r,s){const a=r/2,c=s/2,l=e-Ft(e,n-a,n+a),u=t-Ft(t,o-c,o+c),d=l*l+u*u;if(d>i*i)return null;if(sk>=d){const r=Math.abs(e-(n-a)),s=Math.abs(e-(n+a)),l=Math.abs(t-(o-c)),u=Math.abs(t-(o+c)),d=Math.min(r,s,l,u);return d===r?{nx:-1,ny:0,penetration:i+r}:d===s?{nx:1,ny:0,penetration:i+s}:d===l?{nx:0,ny:-1,penetration:i+l}:{nx:0,ny:1,penetration:i+u}}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:i-h}}function Vt(e,t,i,n,o,r,s,a=0){const c=r-n,l=s-o,u=c*c+l*l,d=u>sk?Ft(((e-n)*c+(t-o)*l)/u,0,1):0,h=i+a/2,p=e-(n+c*d),f=t-(o+l*d),y=p*p+f*f;if(y>=h*h)return null;if(sk>=y){const e=Math.sqrt(u);return e>sk?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:p/g,ny:f/g,penetration:h-g}}function Ht(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return qt(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Xt(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const i=Gt(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Gt(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Ut(e,t){const i=t.shape;return"aabb"===i.type?"circle"===e.shape.type?Gt(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):Xt(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height):Vt(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Kt(e,t){return`${e}\0${t}`}function Zt(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Qt(e,t){if(!t)return;let i=e;for(const e of t.split(".")){if(null==i||"object"!=typeof i)return;if(!Object.prototype.hasOwnProperty.call(i,e))return;i=i[e]}return i}function Jt(e,t){return!!t?.some(t=>Object.is(e,t))}function ei(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const i=Qt(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!Jt(i,t.oneOf)||t.notOneOf&&Jt(i,t.notOneOf))}function ti(e,t){return ei(t,e.bodyFilter)}function ii(e={}){return new lk(e)}function ni(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):ii(t)}function oi(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const i=t-e.mean;e.mean+=i/e.count,e.m2+=i*(t-e.mean)}function ri(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function si(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function ai(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function ci(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?ai(t,e):void 0}function li(e,t,i){if("number"==typeof e)return e;const n="function"==typeof e?e(t,i):"string"==typeof e?ai(t,e):1,o="number"==typeof n?n:Number(n);return Number.isFinite(o)?o:1}function ui(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function di(e){for(const t of uk){const i=ui(ai(e,t));if(i)return i}return"sediment"}function hi(e){const t=ri(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:ri(e.x),y:ri(e.y),value:t}}function pi(e,t={}){const{baselineY:i=0,binWidth:n=24,gap:o=2,maxHeight:r=80,value:s="count",x:a}=t,c=e.reduce((e,t)=>Math.max(e,t[s]),1);return e.map((e,t)=>{const l=Math.max(0,e[s]/c*r),u=a?.(e,t)??t*(n+o);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:i-l,width:n,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function fi(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}function yi(e,t,i){if(!1===i)return;const n=fi(i?.warnAt);return null!=n?n:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}function gi(e){const t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),n=t+i,o=fi(e.bodyLimit),r=fi(e.engineMaxBodiesHint),s=yi(o,r,e.options),a=null==o?0:Math.max(0,t-o),c=a>0?"overflow":null==s||s>n?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:o,engineMaxBodiesHint:r,liveBodies:t,overflow:a,projectedBodies:n,queuedBodies:i,state:c,warnAt:s}}function mi(e={},t=pk){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function xi(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function bi(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function vi(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function wi(e,t,i){return"function"==typeof i?bi(i(e,t)):"string"==typeof i?bi(vi(e,i)):bi(e.spawnAt)??bi(vi(e,"arrivalTime"))??bi(vi(e,"timestamp"))??bi(vi(e,"time"))??bi(vi(e,"eventTime"))}function ki(e,t={}){const i=bi(t.startAt)??0,n=t.pacing??"immediate";if("arrival"===n){let n=1/0;const o=e.map((e,i)=>{const o=wi(e,i,t.timeAccessor);return null!=o&&(n=Math.min(n,o)),o}),r=bi(t.timeScale)??1,s=r>0?r:1;return e.map((e,t)=>{const r=o[t],a=null==r?0:Math.max(0,r-n);return{...xi(e),spawnAt:i+a/s}})}if("object"==typeof n){const t=bi(n.ratePerSec);if(t&&t>0)return e.map((e,n)=>({...xi(e),spawnAt:i+n/t}))}return e.map(e=>({...xi(e),spawnAt:i}))}function Ai(e){return{...xi(e),sequence:e.sequence,spawnAt:e.spawnAt}}function Si(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function Mi(e){return!1!==e&&{...e}}function _i(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function $i(e){return{...e,gravity:{...e.gravity}}}function Pi(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}function ji(e,t,i,n){if("circle"===e.shape.type){const o=e.x-t,r=e.y-i,s=e.shape.radius+n,a=o*o+r*r;return a>s*s?null:a}const o=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),r=Math.max(Math.abs(i-e.y)-e.shape.height/2,0),s=o*o+r*r;return s>n*n?null:s}function Ii(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Li(e,t={}){const{idPrefix:i="plot",includeFloor:n=!0,includeCeiling:o=!1,includeLeftWall:r=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return n&&l.push({id:i+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),o&&l.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),r&&l.push({id:i+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:i+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function Ri(e){const{idPrefix:t="bin",count:i,domainStart:n,domainStep:o,xScale:r,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:p=Math.max(2,c)}=e,f=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?i:i-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&i>e)continue;const s=r(n+e*o);f.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;i>e;e+=1){const i=n+e*o,s=i+o;if(s>=d)continue;const a=r(i),l=r(s);f.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:p}})}return f}function Ci(e,t){const i={...e};for(const e of t)i[fk[e]]++;return i}function Ti(e,t,i){const n=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:n,revisions:Ci(i,n)}}function Oi(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=Mk[n]??_k;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Ei(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&$k.every(i=>e[i]===t[i])}function Fi(e,t){return Object.keys(e).filter(i=>"kernel"===i?!Ei(e.kernel,t.kernel):e[i]!==t[i])}function Ni(e,t,i){if(0===t.length)return;const n=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=n.get(e.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}function zi(e,t,i){const n=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===n.size&&0===t.size)return n;const o=new Map(e.readState().map(e=>[e.id,e])),r=(e,t)=>{const{sensorId:n,bodyId:r}=Ii(t),s=i.observation.sensors[n],a=o.get(r);i.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:r,datum:a?.datum,x:a?.x,y:a?.y,sensorId:n,binId:s?.binId??n})};for(const e of Array.from(n).sort())t.has(e)||r("enter",e);for(const e of Array.from(t).sort())n.has(e)||r("exit",e);return n}function Di(e,t){for(const i of e)t.has(Ii(i).bodyId)&&e.delete(i)}function Bi(e,t,i,n){return e||!t?"paused":i||!n?"running":"settled"}function Wi(e,t,i){i.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||i.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:t,previousSimulationState:e})}function Yi(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt})}function qi(e,t,i){if("sleeping-first"!==t)return i.slice();const n=new Map(e.readState().map(e=>[e.id,e.sleeping])),o=[],r=[];for(const e of i)n.get(e)?o.push(e):r.push(e);return[...o,...r]}function Xi(e,t,i,n){const o=new Map(e.readState().map(e=>[e.id,e])),r=[];for(const e of i){const i=o.get(e);if(!i)continue;const s=t.add(i);s&&(r.push(e),n.emit({type:"physics-sediment",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e,datum:i.datum,x:i.x,y:i.y,binId:s.id,count:s.count,total:s.total}))}return r}function Gi(e,t,i,n,o,r){const s={evicted:[],sedimented:[],liveBodyOrder:o};if(!1===i)return s;const a=Math.max(0,Math.floor(n));if(!Number.isFinite(a))return s;const c=o.length-a;if(0>=c)return s;const l=qi(e,i,o).slice(0,c);if(0===l.length)return s;const u=Xi(e,t,l,r);e.remove(l);const d=new Set(l);return{evicted:l,sedimented:u,liveBodyOrder:o.filter(e=>!d.has(e))}}function Vi(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}function Hi(e,t){if(!e)return;const i=["spawned","evicted","sedimented","events","observations"],n={spawned:0,evicted:0,sedimented:0,events:0,observations:0},o=o=>{const r=t(o),s={...r,spawned:r.spawned.slice(n.spawned),evicted:r.evicted.slice(n.evicted),sedimented:r.sedimented.slice(n.sedimented),events:r.events.slice(n.events),observations:r.observations.slice(n.observations)};for(const e of i)n[e]=r[e].length;e.onStep(s)};return o(0),()=>o(1)}function Ui(e,t,i,n={}){let o,r=0;for(;t>r&&!n.shouldStop?.()&&(!1===n.stopAtRest||e.queueSize()>0||!e.atRest()||n.continueWhile?.());){e.step(e.fixedDt),e.advanceTime(e.fixedDt);const t=e.drainEvents();i.events&&(i.events.push(...t),e.observeKernelEvents(t,i.observations),e.observeSensorTransitions(i.observations));const s=[];if(e.spawnDue(s,i.observations),s.length>0){i.spawned.push(...s),o=e.observeBodyBudget(i.observations);const t=e.evictOverflow(i.observations);i.evicted?.push(...t.evicted),i.sedimented?.push(...t.sedimented)}r+=1,e.refreshQuiescence(e.fixedDt,s.length),n.afterStep?.()}return{steps:r,budget:o}}function Ki(e){const{data:t,valueAccessor:i,bins:n,ballRadius:o,seed:r,size:s,valueExtent:a}=e,{rows:c}=St(t,"galton"),l=ht(s),u=c.map((e,t)=>mt(gt(e,t,i))).filter(e=>null!=e),d=vt(a),[h,p]=d??(u.length?Mt(u):[0,1]),f=p===h?1:p-h,y=(0,ok.scaleLinear)().domain([0,n]).range([l.plot.x,l.plot.x+l.plot.width]),g=Array.from({length:n},()=>0),m=[];c.forEach((e,t)=>{const r=mt(gt(e,t,i));if(null==r)return;const s=Math.max(0,Math.min(n-1,Math.floor((r-h)/f*n)));g[s]+=1,m.push({id:(e.id??"galton-"+t)+"",x:y(s+.5),y:l.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:r,bin:s}})});const x=l.plot.y+l.plot.height;return{config:yt(r,[...Li({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Ri({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:y,yTop:l.plot.y-400,yBottom:x,wallThickness:6})],"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:g.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:n,plot:l.plot,valueExtent:[h,p]}}}function Zi(e){const{windowSize:t,watermark:i,watermarkAtArrivalAccessor:n}=e;if(!Number.isFinite(t)||0>=t)throw new RangeError("EventDrop windows.size must be a finite positive number");const{rows:o}=St(e.data,"event"),r=o.flatMap((t,i)=>{const n=mt(gt(t,i,e.timeAccessor));return null==n?[]:[{datum:t,index:i,eventTime:n,arrivalTime:mt(gt(t,i,e.arrivalAccessor))??n,watermarkAtArrival:0,late:!1}]}),s="function"==typeof i?null:mt(i?.value),a="function"==typeof i?t:mt(i?.delay)??t;let c=-1/0,l=-1/0;for(const e of r.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){c=Math.max(c,e.eventTime);const o="function"==typeof i?mt(i(c)):c-a;l=s??Math.max(l,o??c-t);const r=n?mt(gt(e.datum,e.index,n)):null;e.watermarkAtArrival=r??l,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:r,watermarkValue:r.length?l:s??-a}}function Qi(e,t){const i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}function Ji(e,t){const i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];const n=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,r=(0,Ik.scaleLinear)().domain([n,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=r(e.windowStart+i*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;i>t;t+=1){const i=e.windowStart+t*e.windowSize,n=i+e.windowSize,o=r(i),s=r(n);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:l(o),x2:s,y2:l(s)})}return u}function en(e){const{count:t,idPrefix:i,wallThickness:n,xScale:o,yBottom:r,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(r-1,a?.(t)??s),l=Math.max(1,r-c);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:c+l/2,width:n,height:l}}})}function tn(e){const{data:t,timeAccessor:i,arrivalAccessor:n,windows:o,watermark:r,watermarkAtArrivalAccessor:s,ballRadius:a,seed:c,size:l,timeExtent:u,timeScale:d=1}=e,{events:h,watermarkValue:p}=Zi({data:t,timeAccessor:i,arrivalAccessor:n,watermark:r,watermarkAtArrivalAccessor:s,windowSize:o.size}),f=ht(l);let y=h.length?1/0:0,g=h.length?1/0:0,m=h.length?-1/0:o.size;for(const e of h)y=Math.min(y,e.arrivalTime),g=Math.min(g,e.eventTime),m=Math.max(m,e.eventTime);const x=mt(u?.[0]),b=mt(u?.[1]),v=Math.min(x??g,g),w=Math.max(b??m,m),k=Math.floor(v/o.size)*o.size,A=Math.max(1,Math.ceil((w-k+o.size)/o.size)),S=Qi(f,a),M=k+A*o.size,_=(0,Ik.scaleLinear)().domain([k,M]).range([S.windowPlot.x,S.windowPlot.x+S.windowPlot.width]);let $=0;const P=Array.from({length:A},(e,t)=>(k+(t+1)*o.size>p||$++,{value:0,secondary:0})),j=[];h.forEach(({datum:e,index:t,eventTime:i,arrivalTime:n,watermarkAtArrival:r,late:s})=>{const c=Math.max(0,Math.min(A-1,Math.floor((i-k)/o.size)));P[c].value+=s?0:1,P[c].secondary+=s?1:0,j.push({id:(e.id??"event-"+t)+"",x:on(i,c,s,{windowStart:k,windowSize:o.size,gutter:S.gutter,closedWindowCount:$,windowPlot:S.windowPlot,windowCount:A},a),y:f.plot.y+a+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:n,shape:{type:"circle",radius:a},datum:{...e,eventTime:i,arrivalTime:n,windowIndex:c,watermarkAtArrival:r,late:s}})});const I=f.plot.y+f.plot.height,L={closedWindowCount:$,gutter:S.gutter,plot:f.plot,windowCount:A,windowPlot:S.windowPlot,windowSize:o.size,windowStart:k},R=Ji(L,f.plot.y+.28*f.plot.height);for(const e of j){const t=e.datum;e.y=nn({...L,lidSegments:R},t.windowIndex,t.late,a)}const C=e=>{if(0>e||e>$)return null;const t=0===e?R[0]?.y1:R[e-1]?.y2??R[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null},T=en({idPrefix:"eventdrop-window",count:A,xScale:e=>_(k+e*o.size),yTop:S.wallTop,yTopForIndex:e=>{const t=C(e);return null==t?S.wallTop:t+1.25*a},yBottom:I,wallThickness:6});return{config:yt(c,[...Li({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...T,...R.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*a)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:j,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{const t=e.datum,i=$>t.windowIndex;return i&&!t.late||!i&&t.late?y:t.arrivalTime},timeScale:d},projectionRows:P.map((e,t)=>({label:`${k+t*o.size}-${k+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:$,gutter:S.gutter,lidSegments:R,lateCount:P.reduce((e,t)=>e+t.secondary,0),plot:f.plot,windowPlot:S.windowPlot,windowWalls:T.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:p,windowCount:A,windowSize:o.size,windowStart:k}}}function nn(e,t,i,n){const{windowPlot:o,lidSegments:r}=e,s=r[t];return i&&!s?Math.min(o.y+o.height-n,o.y+.48*o.height+2*n+4):!i&&s?Math.min(o.y+o.height-n,Math.max(s.y1,s.y2)+2*n+4):o.y+n+2}function on(e,t,i,n,o){const{windowPlot:r,windowCount:s,windowStart:a,windowSize:c}=n;if(i&&t>=n.closedWindowCount)return n.gutter.x+n.gutter.width/2;const l=r.width/s,u=i?r.x:r.x+t*l,d=i?r.x+r.width:u+l,h=Math.min((d-u)/2,o+(i?0:3));return Math.max(u+h,Math.min(d-h,r.x+(e-a)/c*l))}function rn(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),i=t.length?t:["Intake"],n=Math.max(i.length,Math.round(e.count??Math.max(48,12*i.length))),o=bt(e.unitValue,1),r=kt(e.seed??1),s=e.idPrefix??"mechanical-pile",a=i.map(()=>.65+.9*r()),c=a.reduce((e,t)=>e+t,0)||1,l=n-i.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=n-d.reduce((e,t)=>e+t,0);const p=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%p.length)d[p[e].index]+=1,h-=1;return i.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*o,mechanical:!0,unitCount:d[t],unitValue:o,share:d[t]/n}))}function sn(e,t){const i=e/t,n=Math.round(i);return Math.ceil(n>0&&Number.EPSILON*i*4>=Math.abs(i-n)?n:i)}function an(e,t,i){const n=e.width/Math.max(1,t),o=Math.max(2,2*i),r=Math.min(.7*n,Math.max(3.2*o,o+8)),s=Math.max(1,Math.floor(r/o));return{laneWidth:n,tubeWidth:r,ballDiameter:o,perRow:s,centerX:t=>e.x+(t+.5)*n,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*o}}function cn(e){function t(e){let t=p.get(e);return null==t&&(t=h.length,h.push(e),p.set(e,t)),t}const{data:i,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:s,seed:a,size:c}=e,l=bt(r,1),{rows:u}=St(i,"pile"),d=ht(c),h=[],p=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map,y=[];u.forEach((e,i)=>{t((gt(e,i,n)??"unknown")+"")});const g=Math.max(1,h.length),m=an(d.plot,g,s),x=Math.max(0,m.tubeWidth/2-s-1),b=h.map(()=>[]);u.forEach((e,i)=>{const r=(gt(e,i,n)??"unknown")+"",a=t(r),c=o?mt(gt(e,i,o)):1,u=Math.max(0,c??0);f.set(r,(f.get(r)??0)+u);const h=sn(u,l),p=m.centerX(a);for(let t=0;h>t;t+=1){const n=b[a].length,o=t===h-1?u-t*l:l,c=Math.min(1,o/l);b[a].push({id:`${(e.id??"pile-"+i)+""}-${t}`,x:p+(m.perRow>1?((m.perRow>1?n%m.perRow:0)/(m.perRow-1)*2-1)*x:0),y:d.plot.y+s+2,vx:(t%3-1)*s/2,vy:0,mass:1,shape:{type:"circle",radius:s*Math.sqrt(c)},datum:{...e,category:r,unitIndex:t,unitValue:l,representedValue:o,unitFraction:c}})}});const v=b.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(const t of b)t.length>e&&y.push(t[e]);const w=d.plot.y+d.plot.height,k=[...Li({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let e=0;g>e;e+=1){const t=m.centerX(e);for(const i of[-1,1])k.push({id:`pile-tube-${e}-${0>i?"l":"r"}`,shape:{type:"aabb",x:t+i*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:yt(a,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:f.get(e)??0}))}}function ln(e,t,i,n){const o=(t+i)/2,r=[];for(const s of e){const a=r.filter(e=>s.radius+e.radius+.5>Math.abs(s.x-e.x)),c=[o];for(const e of a){const t=Math.sqrt((s.radius+e.radius+.5)**2-(s.x-e.x)**2);c.push(e.y-t,e.y+t)}const l=.5>n()?-1:1;c.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||l*(e-t));const u=c.find(e=>e-s.radius>=t&&i>=e+s.radius&&a.every(t=>(s.x-t.x)**2+(e-t.y)**2>=(s.radius+t.radius+.5)**2-1e-6));if(null==u){const n=e.reduce((e,t)=>Math.max(e,t.radius),-1/0),r=Math.max(0,i-t-2*n);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*r),overlapping:!0,entryOffset:0}}r.push({...s,y:u})}return{positions:r.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,r.reduce((e,i)=>Math.min(e,i.y-i.radius-t),36))}}function un(e){function t(e){let t=m.get(e);return null==t&&(t=g.length,g.push(e),m.set(e,t)),t}const{data:i,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:s,seed:a,size:c,xExtent:l,collisionIterations:u,settle:d}=e,{rows:h}=St(i,"collision-swarm"),p=ht(c),f=kt(a),y=[],g=[],m=/* @__PURE__ */new Map;h.forEach((e,i)=>{const a=mt(gt(e,i,n));if(null==a)return;const c=o?(gt(e,i,o)??"All")+"":"All",l=r?mt(gt(e,i,r)):null,u=xt(null!=l&&l>0?l:s,2,18);t(c),y.push({datum:e,index:i,value:a,group:c,radius:u})});const x=l?mt(l[0]):null,b=l?mt(l[1]):null,v=y.reduce((e,t)=>Math.min(e,t.value),y.length?1/0:0),w=y.reduce((e,t)=>Math.max(e,t.value),y.length?-1/0:1);let k=x??v,A=b??w;if(k===A&&(k-=.5,A+=.5),k>A){const e=A;A=k,k=e}const S=y.reduce((e,t)=>Math.max(e,t.radius),s),M=p.plot.x+S+8,_=p.plot.x+p.plot.width-S-8,$=(0,Lk.scaleLinear)().domain([k,A]).range([M,_]),P=p.plot.height/Math.max(1,g.length),j=Math.min(6,.05*P),I=e=>p.plot.y+((m.get(e)??0)+.5)*P,L=/* @__PURE__ */new Map,R=/* @__PURE__ */new Set,C=/* @__PURE__ */new Map;for(const e of g){const t=y.filter(t=>t.group===e),i=I(e),n=t.map(e=>({x:$(e.value),radius:e.radius})),o=ln(n,i-P/2+j,i+P/2-j,f);L.set(e,t.length),o.overlapping&&R.add(e),t.forEach((e,t)=>C.set(e.index,{x:n[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}const T=y.map((e,t)=>{const i=C.get(e.index),n=i.x,o=i.y,r=R.has(e.group);return{id:(e.datum.id??"collision-swarm-"+t)+"",x:n,y:o-(d?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:n},bodyCollisions:!r,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:o,overlapping:r},springs:[{target:{type:"point",x:n,y:o},restLength:0,stiffness:34,damping:12}]}});return{config:yt(a,Li({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:T,projectionRows:g.map(e=>({label:e,value:L.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[k,A],xRange:[M,_],groups:g.map(e=>({label:e,y:I(e),count:L.get(e)??0,overlapping:R.has(e)})),plot:p.plot}}}function dn(e){if(Array.isArray(e)&&e.length>=2){const t=mt(e[0]),i=mt(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){const t=e,i=mt(t.x),n=mt(t.y);return null!=i&&null!=n?{x:i,y:n}:null}return null}function hn(e){return Array.isArray(e)?e.map(dn).filter(e=>null!=e):[]}function pn(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:xt(e.x,t.plot.x,t.plot.x+t.plot.width),y:xt(e.y,t.plot.y,t.plot.y+t.plot.height)}}function fn(e){let t=0;for(let i=1;e.length>i;i+=1)t+=Math.hypot(e[i].x-e[i-1].x,e[i].y-e[i-1].y);return t}function yn(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const i=xt(t,0,1)*fn(e);let n=0;for(let t=1;e.length>t;t+=1){const o=e[t-1],r=e[t],s=Math.hypot(r.x-o.x,r.y-o.y);if(s>0){if(n+s>=i){const e=(i-n)/s;return{x:o.x+(r.x-o.x)*e,y:o.y+(r.y-o.y)*e}}n+=s}}return{...e[e.length-1]}}function gn(e,t){const i=yn(e,Math.max(0,t-.02)),n=yn(e,Math.min(1,t+.02)),o=n.x-i.x,r=n.y-i.y,s=Math.hypot(o,r)||1;return{x:o/s,y:r/s}}function mn(e){function t(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof s){const e=s(t,0);if(null!=e)return e+""}if("string"==typeof s&&null!=t[s])return t[s]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}const{coordinateMode:i,flowSpeed:n,links:o,maxParticles:r,nodeIdAccessor:s,nodeXAccessor:a,nodeYAccessor:c,nodes:l,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:p="path",reducedMotion:f,seed:y,size:g,sourceAccessor:m,targetAccessor:x,throughputAccessor:b}=e,v=ht(g),w=kt(y),k=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=[];l.forEach((e,t)=>{const i=(gt(e,t,s)??e.id??t)+"",n=mt(gt(e,t,a)),o=mt(gt(e,t,c));if(null!=n&&null!=o){const e={x:n,y:o};k.set(i,e),S.push(e)}A.set(i,(e.label??e.name??i)+"")});const M=[];o.forEach((e,i)=>{const n=t(gt(e,i,m)),o=t(gt(e,i,x)),r=Math.max(0,mt(gt(e,i,b))??0),s=hn(h?gt(e,i,h):void 0),a=s.length?s:hn(e.path??e.points??e.route);a.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${o}-${i}`)+"",link:e,index:i,source:n,target:o,throughput:r,rawPath:a})});const _=(P=S,"normalized"===($=i)||"pixels"===$?$:P.length>0&&P.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var $,P;const j=/* @__PURE__ */new Map;for(const[e,t]of k)j.set(e,pn(t,v,_));const I=[];for(const e of M){let t=e.rawPath.map(e=>pn(e,v,_));if(2>t.length){const i=j.get(e.source),n=j.get(e.target);i&&n&&(t=[i,n])}else j.has(e.source)||j.set(e.source,t[0]),j.has(e.target)||j.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(A.has(e.source)||A.set(e.source,e.source),A.has(e.target)||A.set(e.target,e.target),I.push({...e,path:t,packetCount:0}))}const L=bt(d,.12),R=Math.max(1,Math.round(r)),C=I.map(e=>Math.max(1,Math.round(e.throughput*L))),T=C.reduce((e,t)=>e+t,0),O=T>R?R/T:1;I.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(C[t]*O))});let E=I.reduce((e,t)=>e+t.packetCount,0);for(;E>R;){const e=I.reduce((e,t,i)=>t.packetCount>1&&(-1===e||t.packetCount>I[e].packetCount)?i:e,-1);if(-1===e)break;I[e].packetCount-=1,E-=1}const F=/* @__PURE__ */new Map,N=/* @__PURE__ */new Map,z=[],D=bt(n,90),B=bt(u,4);I.forEach((e,t)=>{F.set(e.target,(F.get(e.target)??0)+e.throughput),N.set(e.source,(N.get(e.source)??0)+e.throughput);const i=fn(e.path);for(let n=0;e.packetCount>n;n+=1){const o=(n+.5)/e.packetCount,r=f?o:xt(.12+.84*o+.04*(w()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*w())),a=yn(e.path,s),c=yn(e.path,r),l=gn(e.path,s),u={x:-l.y,y:l.x},d=(w()-.5)*B*1.5;z.push({id:`${e.id}-packet-${n}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*D+10*(w()-.5),vy:f?0:l.y*D+10*(w()-.5),mass:.8,spawnAt:f?0:.04*t+n/32,shape:{type:"circle",radius:B},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:n,packetCount:e.packetCount,routeProgress:r,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:D,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target},springs:"none"!==p&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*B,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*B),Y=Array.from(j,([e,t])=>({nodeId:e,label:A.get(e)??e,sensorId:"physical-flow-node-"+wt(e),point:t})),q=Y.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),X=Object.fromEntries(Y.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=yt(y,[...Li({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*B),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=R,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(j,([e,t])=>({id:e,label:A.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+wt(e),incoming:F.get(e)??0,outgoing:N.get(e)??0})),H=I.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:z,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:z.length,totalThroughput:I.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:H}}}function xn(e,t){const i=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],n=t.filter(e=>!i.has(e)),o=t.length-n.length,r=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s&&Object.prototype.hasOwnProperty.call(i=s,n=e)?i[n]:void 0;var i,n;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(i.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===r?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:r,complete:t.length>0&&("anyAbsorbed"===r?o>0:"threshold"===r?l>=(d??c):0===n.length),absorbed:o,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:n}})}function bn(e,t,i){return Math.max(t,Math.min(i,e))}function vn(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function wn(e,t,i,n,o,r={}){return{id:e,friction:r.friction,restitution:r.restitution,bodyFilter:r.bodyFilter,shape:{type:"segment",x1:t,y1:i,x2:n,y2:o,thickness:r.thickness??8}}}function kn(e){const t=e.shape??"lane",i=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height)),o=e.padX??46,r=e.padY??72,s=o,a=i-o,c=r,l=n-Math.max(24,Math.round(.45*r)),u=(c+l)/2,d=Math.max(1,l-c),h=bn(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,y=bn(d*h+f,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,A=e.stages;if(!A.length)throw Error("processStageLayout requires at least one stage");const S=bn(e.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=vn(A),_=a-s;let $=s;const P=A.map((e,t)=>{const i=$,n=t===A.length-1?a:$+(e.share??1)/M*_;return $=n,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:i,x1:n,x:(i+n)/2,width:n-i,y:u,height:d}}),j=P[S],I=j.x0,L=j.x1,R=(e,i)=>{if("lane"===t)return"top"===i?c:l;if("funnel"===t){const t=bn((e-s)/Math.max(1,a-s),0,1);return"top"===i?c+(m-c)*t:l+(x-l)*t}if(I>=e){const t=bn((e-s)/Math.max(1,I-s),0,1);return"top"===i?c+(m-c)*t:l+(x-l)*t}if(L>=e)return"top"===i?m:x;const n=bn((e-L)/Math.max(1,a-L),0,1);return"top"===i?m+(c-m)*n:x+(l-x)*n},C=P.map(e=>{const t=Math.min(R(e.x0,"top"),R(e.x1,"top")),i=Math.max(R(e.x0,"bottom"),R(e.x1,"bottom"));return{...e,y:(t+i)/2,height:Math.max(1,i-t)}}),T={thickness:k,friction:v,restitution:w},O=[];"lane"===t?O.push(wn(b+"-top",s,c,a,c,T),wn(b+"-bottom",s,l,a,l,T),wn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),wn(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)})):"funnel"===t?O.push(wn(b+"-top",s,c,a,m,T),wn(b+"-bottom",s,l,a,x,T),wn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),wn(b+"-right",a,m,a,x,{...T,thickness:Math.max(6,k)})):O.push(wn(b+"-left-top",s,c,I,m,T),wn(b+"-left-bottom",s,l,I,x,T),wn(b+"-center-top",I,m,L,m,T),wn(b+"-center-bottom",I,x,L,x,T),wn(b+"-right-top",L,m,a,c,T),wn(b+"-right-bottom",L,x,a,l,T),wn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),wn(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)}));const E=e.membraneDampingScale??.5,F=s,N=Math.max(1,("bowtie"===t?I:a)-F),z=(e.membranes??[]).map(e=>{const t=F+bn(e.offset,0,1)*N,i=e.width??18+18*e.cost,n=d-16,o=u+.25*(e.wobble??0);return{...e,x:t,y:o,width:i,height:n}}),D=!1===e.includeMembraneRegions?[]:z.map(e=>Sn({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??E,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:i,height:n,padX:o,padY:r,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:I,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:C,membranes:z,colliders:O,regionEffects:D,boundaryY:R}}function An(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,i=e.y,n=e.width,o=e.height,{type:"aabb",x:t,y:i,width:n,height:o}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,i,n,o}function Sn(e){const t=e.dampingScale??.5,i=e.energyScale??1,n=bn(e.cost,0,2);return{...An({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:n,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n*t,energyDelta:-n*i}}function Mn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...An({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function _n(e){const t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,n=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...An({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i+t*n,energyDelta:o?-t*o:void 0,force:e.force}}function $n(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...An({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function Pn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...An({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function jn(e){return{...An({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function In(e){const t=e.x??e.anchor?.x??0,i=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:i,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:i},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function Ln(e){const t=e.idPrefix??"lane",i={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},n=[wn(t+"-top",e.left,e.top,e.right,e.top,i),wn(t+"-bottom",e.left,e.bottom,e.right,e.bottom,i)];return e.openEnds||n.push(wn(t+"-left",e.left,e.top,e.left,e.bottom,i),wn(t+"-right",e.right,e.top,e.right,e.bottom,i)),n}function Rn(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function Cn(e,t){const i={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return Pn({...i,kind:e.kind??"sink",force:Rn(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return n={...i,kind:e.kind??"force-field",force:Rn(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...An({...n,kind:n.kind??"force-field",attributes:{primitive:"portal",targetStage:n.targetStage,..."object"==typeof n.attributes&&n.attributes?n.attributes:{}}}),force:n.force,impulseOnEnter:n.impulseOnEnter,damping:n.damping??.08}}var n;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return $n({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Rn(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return _n({...i,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:Rn(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Mn({...i,kind:e.kind??"force-field",force:Rn(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):jn({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}function Tn(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=e.size,n=ht(i),o=xt(e.ballRadius??6,2,18),r=e.seed??1,s=kt(r),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,p=e.groupCompletion??(l?"allAbsorbed":"none"),f=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=kn({width:i[0],height:i[1],shape:"lane",padX:Math.max(28,n.plot.x),padY:Math.max(36,n.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],A=new Set(t.filter(e=>e.absorb).map(e=>e.id)),S=t.map(e=>{const t=v.get(e.id)??k;return Cn(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(Mn({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=/* @__PURE__ */new Map;for(const e of x.stages)M.set(e.id,0);const _=[];e.data.forEach((e,t)=>{const i=(a?gt(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",n=(gt(e,t,c)??w)+"",r=b.has(n)?n:w;M.set(r,(M.get(r)??0)+1);const s=l?(gt(e,t,l)??"")+"":void 0,p=s&&u?(gt(e,t,u)??s)+"":s,f=d?mt(gt(e,t,d))??1:1,y=h?mt(gt(e,t,h)):null,g=xt(null!=y&&y>0?y:o,2,18);_.push({datum:e,id:i,stageId:r,groupId:s||void 0,groupLabel:p||void 0,work:f,radius:g,index:t})});const $=/* @__PURE__ */new Map,P=/* @__PURE__ */new Map;for(const e of _){if(!e.groupId)continue;const t=$.get(e.groupId)??[];t.push(e.id),$.set(e.groupId,t),e.groupLabel&&P.set(e.groupId,e.groupLabel)}const j=xt(e.groupAnchorAlong??.55,.15,.9),I=x.left+(x.right-x.left)*j,L=Array.from($.keys()),R=L.map((e,i)=>{const n=$.get(e)??[],o=L.length>1?x.topY+28+i/Math.max(1,L.length-1)*(x.bottomY-x.topY-56):x.midY;return In({id:e,label:P.get(e)??e,bodyIds:n,anchor:{x:I,y:o},x:I,y:o,completion:"allAbsorbed"===p?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),C=xn(R,_.filter(e=>A.has(e.stageId)).map(e=>e.id)),T=new Map(R.map(e=>[e.id,e])),O=_.map((e,t)=>{const i=v.get(e.stageId)??k,n=i.x+(s()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(n,"top")+e.radius+10,r=x.boundaryY(n,"bottom")-e.radius-10,a=r>o?o+s()*Math.max(1,r-o):x.midY,c=g?n:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:n,y:a},restLength:.45*e.radius,stiffness:f,damping:y}];if(e.groupId){const t=T.get(e.groupId);t?.anchor&&!A.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),E={kernel:{seed:r,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},F=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),N=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:E,initialSpawns:O,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:F,metadata:{kind:"process-flow",plot:n.plot,volume:x,stages:N,groups:R,groupCompletion:C,regionEffects:S}}}function On(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function En(e,t,i){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(i)}`}function Fn(e){const t=e.map(On),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){const[e,i,n]=t[0];return En(e,i,n)}if(e>=1){const[e,n,o]=t[i];return En(e,n,o)}const n=e*i,o=Math.floor(n),r=n-o,[s,a,c]=t[o],[l,u,d]=t[o+1];return En(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(d-c)*r))}}function Nn(e){return e&&Object.prototype.hasOwnProperty.call(Vk,e)?Vk[e]:Ok}function zn(e,t,i=iA){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Object.prototype.hasOwnProperty.call(tA,e)?tA[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function Dn(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||sA.has(t)}function Bn(e,t,i){if("function"==typeof t){const n=t(e);return i&&n&&"string"==typeof n&&!Dn(n)?i(n):n}const n=e?.[t]+"";return i?i(n):iA[Math.abs(qn(n))%iA.length]}function Wn(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function Yn(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const e=i;return t=>Wn(e,t)??"#999"}const n=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=n.every(e=>!isNaN(Number(e)));if(Array.isArray(i))return(0,Ck.scaleOrdinal)().domain(n).range(i).unknown("#999");const r=Object.prototype.hasOwnProperty.call(tA,i)?tA[i]:tA.category10;if(o&&"function"==typeof r){let e=-1/0;for(const t of n){const i=Number(t);i>e&&(e=i)}return t=>r(0===e?0:Number(t)/e)}{const e=Array.isArray(r)?r:iA;return(0,Ck.scaleOrdinal)().domain(n).range(e).unknown("#999")}}function qn(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}function Xn(e,t,i=[3,20],n){let o;if(o="function"==typeof t?t(e):e?.[t],!n)return o;const[r,s]=n,[a,c]=i;if(s===r)return(a+c)/2;let l=(o-r)/(s-r);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function Gn(e,t,i){return zn(e,t,i)}function Vn(e,t){const i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Wn(i,e)||"#4e79a7":t=>{if(i){const e=Wn(i,t);if(e)return e}let n=0;for(let e=0;t.length>e;e++)n=31*n+t.charCodeAt(e)|0;return e[Math.abs(n)%e.length]??"#4e79a7"}}function Hn(e,t,i){const n=e?.observation;return{...e,observation:{...n,chartId:t??n?.chartId??"physics-custom",chartType:n?.chartType??"PhysicsCustomChart",onObservation:i??n?.onObservation}}}function Un(e,t){const i=t.config??{},n=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...n],r=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...r.length>0&&{colliders:r}}}function Kn(e,t){if(!t?.length)return e;const i=/* @__PURE__ */new Map;for(const e of t){const{bodyId:t,...n}=e,o=i.get(t)??[];o.push(n),i.set(t,o)}return e.map(e=>{const t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}function Zn(e){const t=Hn(e.config,e.chartId,e.onObservation),i=Gn(e.colorScheme,e.themeCategorical,Tk),n=ht(e.size),o={data:e.data,scales:{x:(0,Rk.scaleLinear)().domain(e.xExtent??[0,1]).range([n.plot.x,n.plot.x+n.plot.width]),y:(0,Rk.scaleLinear)().domain(e.yExtent??[0,1]).range([n.plot.y+n.plot.height,n.plot.y])},dimensions:n,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:Vn(i,e.colorScheme),config:e.layoutConfig??{},world:new jk(t)},r=e.skipLayout?{}:e.layout(o)??{},s=Kn([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Un(t,r),context:o,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}function Qn(e){const t=no(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function Jn(e,t,i,n){return i?"function"==typeof i?i(e,t):e[i]??n:n}function eo(e){return`gauntlet:${e}:core`}function to(e,t){return`gauntlet:${e}:positive:${t}`}function io(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function no(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return aA;const i=Math.max(1,Math.min(e.width,t)),n=Math.max(2,.04*e.width);return{left:n,top:Math.max(2,.08*t),rightInset:n,thickness:Math.max(1,Math.min(4,.04*i))}}function oo(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function ro(e,t,i,n){const o=no(n),r=Math.max(2,i+2),s=o.top+o.thickness/2+r,a=n.floorY-r,c=(e,t,i)=>t>i?(t+i)/2:Math.max(t,Math.min(i,e));return{x:c(e,o.left+o.thickness/2+r,n.width-o.rightInset-o.thickness/2-r),y:c(t,s,a)}}function so(e,t,i){const[n,o]=e,r=220>n||160>o,s=Math.round(.48*o),a=r?o-Math.max(3,Math.min(12,.1*o)):o-36,c=(t??[]).filter(e=>!1!==e.enabled),l=Math.max(1,c.length),u=.22*n,d=l>1?(.78*n-u)/(l-1):0,h=r?Math.max(Math.round(.12*n),.08*n+6):Math.max(Math.round(.14*n),110);return{crashY:a-(r?Math.min(i,Math.max(3,.22*o)):i),floorY:a,gates:c.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(r?8:54,Math.round(.07*n))})),graveyardX:Math.round(n*(r?.72:.84)),graveyardY:a-4,height:o,routeY:s,socketX:Math.round(n*(r?.82:.92)),startX:h,width:n}}function ao(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}function co(e,t,i,n){const o=ao(i),r=n?.(e,t,i)??{};return{...o,...r,startY:r.startY??r.routeY??o.startY,socketY:r.socketY??r.routeY??o.socketY,graveyardY:r.graveyardY??o.graveyardY}}function lo(e,t,i=1){const n=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,n.indexOf(t));return{angle:.82*-Math.PI+(n.length>1?o/(n.length-1):.5)*Math.PI*.64,index:o,radius:(48+o%2*6)*i}}function uo(e,t,i){const n=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,r=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*n-8*r-1.2*e.delay-5*o))}function ho(e,t,i,n,o){const r=Jn(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=n.map(e=>e.id),a=[...Jn(e,t,i.positiveAccessor,s)],c=[...Jn(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Jn(e,t,i.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Jn(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Jn(e,t,i.initialViability,100)}}function po(e,t,i,n,o,r,s){const a=oo(i),c=Math.max(3,28*a),l=n.startX,u=n.startY+(n.startY===i.routeY?38*t*a:0),d=s?.(e,t,i,n)??{},h=d.x??l,p=d.y??u,f={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:eo(e.id),x:h,y:p,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??e.startedAt,datum:f}],g=ro(h,p,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,i);y[0].x=g.x,y[0].y=g.y;for(const t of e.activePositiveIds){const n=o.get(t);if(!n)continue;const r=lo(e.activePositiveIds,t,a),s=n.radius??Math.max(2,10*a),c=ro(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,i);y.push({id:to(e.id,t),x:c.x,y:c.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:n.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:n,sourceDatum:e.datum},springs:!1===n.spring?[]:[{target:{type:"body",bodyId:eo(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+r.index%2*4)*a),...n.spring??{}}]})}return e.negativeIds.forEach((t,n)=>{const o=r.get(t);o&&y.push(yo(e,o,n,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}function fo(e){const t=so(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],n=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),r={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=ho(t,s,r,i,o);return{...a,viability:e.viability?.(a,{negativeProperties:o,positiveProperties:n})??uo(a,n,o)}}),a=s.flatMap((i,r)=>{const s=co(i,r,t,e.projectPlacement);return po(i,r,t,s,n,o,e.coreBody)});return{layout:t,states:s,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Qn(t)}}}function yo(e,t,i,n,o,r,s){const a=oo(r),c=t.radius??Math.max(2,7.2*a),l=ro(n+(i%4*12-12)*a,o+(54+12*Math.floor(i/4))*a,c,r);return{id:io(e.id,t.id,i),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:eo(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*a),...t.spring??{}}]}}function go(e=[]){const t=/* @__PURE__ */Object.create(null);for(const[i,n]of e)t[i]=n;return t}function mo(...e){const t=go();for(const i of e)for(const[e,n]of Object.entries(i??{}))t[e]=n;return t}function xo(e){return mo(e)}function bo(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function vo(e){const t=go(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:xo(t.initialMetrics),metrics:xo(t.metrics),productIds:[...t.productIds],history:bo(t.history)}])),i=go(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:xo(t.metrics),sourceIds:[...t.sourceIds],history:bo(t.history)}])),n=go(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?xo(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:n,input:{amount:e.input.amount,metrics:xo(e.input.metrics)},metrics:xo(e.metrics),loss:{amount:e.loss.amount,metrics:xo(e.loss.metrics)},history:bo(e.history)}}function wo(e,t){return t>e?-1:e>t?1:0}function ko(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function Ao(e){const t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const n of e)t.has(n)&&i.add(n),t.add(n);return[...i].sort(wo)}function So(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[ko("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function Mo(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function _o(e){const t=go();for(const i of e)Mo(t,i.metrics);return t}function $o(e,t,i="selector"){const n=[],o=Object.values(e.components),r=new Set(o.map(e=>e.id)),s=(t.ids??[]).filter(e=>!r.has(e));if(s.length&&n.push(ko("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,i+".ids",s)),void 0===t.count||Number.isInteger(t.count)&&t.count>=0||n.push(ko("error","invalid-selector-count","Selector count must be a non-negative integer.",i+".count")),n.some(e=>"error"===e.severity))return{ids:[],diagnostics:n};const a=t.ids?new Set(t.ids):null,c=t.categories?new Set(t.categories):null,l=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null;let d=o.filter(e=>!a||a.has(e.id)).filter(e=>!c||c.has(e.category)).filter(e=>!l||l.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(wo);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||n.push(ko("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:n}}function Po(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function jo(e,t){const i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function Io(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(ko("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function Lo(e,t,i){const n=Ao(t);t.length||e.diagnostics.push(ko("error","empty-source-list","A product requires at least one source component.",i)),n.length&&e.diagnostics.push(ko("error","duplicate-source",`Source ids may appear only once: ${n.join(", ")}.`,i,n));const o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(ko("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));const r=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);r.length&&e.diagnostics.push(ko("error","source-already-assigned",`Source component${1===r.length?" is":"s are"} already assigned: ${r.join(", ")}.`,i,r));const s=t.filter(t=>"consumed"===e.state.components[t]?.status&&!r.includes(t));return s.length&&e.diagnostics.push(ko("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,i,s)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function Ro(e,t,i){const n=Ao(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(ko("error","insufficient-relation-sources","A relation requires at least two source components.",i)),n.length&&e.diagnostics.push(ko("error","duplicate-source",`Relation source ids must be unique: ${n.join(", ")}.`,i,n)),o.length&&e.diagnostics.push(ko("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function Co(e,t,i,n,o){const r=n?.amount??0;(!Number.isFinite(r)||0>r||r>t+cA)&&e.diagnostics.push(ko("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...So(n?.metrics,o+".metrics"));for(const[t,r]of Object.entries(n?.metrics??{}))(0>r||r>Number(i[t]??0)+cA)&&e.diagnostics.push(ko("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function To(e,t,i,n){if(!t?.length)return[];const o=Ao(t),r=t.filter(t=>!e.state.relations[t]),s=t.filter(t=>"resolved"===e.state.relations[t]?.status),a=new Set(i),c=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!a.has(e)));return o.length&&e.diagnostics.push(ko("error","duplicate-relation","Basis relations must be unique.",n,o)),r.length&&e.diagnostics.push(ko("error","unknown-relation",`Unknown basis relation: ${r.join(", ")}.`,n,r)),s.length&&e.diagnostics.push(ko("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,n,s)),c.length&&e.diagnostics.push(ko("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,n,c)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}function Oo(e,t){if(t.length){for(const i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;jo(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}function Eo(e,t,i){e.state.loss.amount+=i?.amount??0;for(const[n,o]of Object.entries(i?.metrics??{}))t[n]=Number(t[n]??0)-o,e.state.loss.metrics[n]=Number(e.state.loss.metrics[n]??0)+o}function Fo(e,t,i,n,o,r,s){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:r&&void 0!==e.amount?e.amount:i,metrics:r&&e.metrics?mo(n,e.metrics):xo(n),status:r?"complete":"forming",sourceIds:[...t],outletId:r?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:r?o.event.id:void 0,completedAt:r?o.context.appliedAt:void 0,history:[s]}}function No(e,t,i,n){void 0!==t.amount&&Math.abs(t.amount-i)>cA&&e.diagnostics.push(ko("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,n,[t.id]))}function zo(e,t,i,n,o,r){const s=e.productDefinitions.get(t.id),a=i??s?.outletId??(e.outletIds.has("product")?"product":void 0);if(!Io(e,a,r+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(ko("error","product-already-complete",`Product "${t.id}" is already complete.`,r,[t.id]));s&&(No(e,s,t.amount,r+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics=mo(t.metrics,s.metrics))),t.status="complete",t.outletId=a,t.reason=n,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;const c=Po(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),jo(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0})}function Do(e,t,i){const n=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(ko("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,n+".state")),e.diagnostics.push(...So(t.metricsDelta,n+".metricsDelta")),Io(e,t.outletId,n+".outletId");const i=$o(o,t.select,n+".select");e.diagnostics.push(...i.diagnostics);const r=i.ids.filter(e=>o.components[e].productIds.length);if(r.length&&e.diagnostics.push(ko("error","source-already-assigned",`Assigned source components cannot be retargeted: ${r.join(", ")}.`,n+".select",r)),e.diagnostics.some(e=>"error"===e.severity))return;const s=Po(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(const e of i.ids){const i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&Mo(i.metrics,t.metricsDelta),i.history.push(s)}return o.history.push(s),void(i.ids.length&&jo(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){const{relation:i}=t;i.id&&!o.relations[i.id]||e.diagnostics.push(ko("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,n+".relation.id",[i.id]));const r=Ro(e,i.sourceIds,n+".relation.sourceIds");if(e.diagnostics.push(...So(i.metrics,n+".relation.metrics")),!r||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?xo(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=Po(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(s),void jo(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){const i=Ao(t.relationIds),r=t.relationIds.filter(e=>!o.relations[e]),s=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(ko("error","duplicate-relation","Relation ids must be unique.",n+".relationIds",i)),r.length&&e.diagnostics.push(ko("error","unknown-relation",`Unknown relation: ${r.join(", ")}.`,n+".relationIds",r)),s.length&&e.diagnostics.push(ko("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,n+".relationIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const i of t.relationIds){const n=o.relations[i];n.status="resolved",n.resolution=t.resolution,n.resolvedByEventId=e.event.id,n.resolvedAt=e.context.appliedAt,n.reason=t.reason}const a=Po(e,t,{relationIds:[...t.relationIds]});return o.history.push(a),void jo(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){const i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(ko("error","unknown-product",`Product "${t.productId}" has no declared mold.`,n+".productId",[t.productId]));const r=o.products[t.productId];"combine"===t.type&&r&&e.diagnostics.push(ko("error","duplicate-product",`Product "${t.productId}" has already been formed.`,n+".productId",[t.productId])),"contribute"!==t.type||r&&"forming"===r.status||e.diagnostics.push(ko("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,n+".productId",[t.productId]));const s=Lo(e,t.sourceIds,n+".sourceIds"),a="contribute"===t.type&&r?[...r.sourceIds,...t.sourceIds]:t.sourceIds,c=To(e,t.basisRelationIds,a,n+".basisRelationIds");if(!s||!c||!i||e.diagnostics.some(e=>"error"===e.severity))return;const l=s.reduce((e,t)=>e+t.amount,0),u=_o(s);if(!Co(e,l,u,t.loss,n+".loss"))return;const d=l-(t.loss?.amount??0);Eo(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,p=Po(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let f;if("combine"===t.type){if(h&&No(e,i,d,n+".productId"),f=Fo(i,t.sourceIds,d,u,e,h,p),h&&!Io(e,f.outletId,n+".productId"))return;o.products[t.productId]=f}else f=r,f.sourceIds.push(...t.sourceIds),f.amount+=d,Mo(f.metrics,u),f.history.push(p);for(const e of s)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),Oo(e,c),jo(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:f.outletId?[f.outletId]:void 0}),void(h&&jo(e,{type:"complete-product",sourceIds:[...f.sourceIds],productIds:[f.id],outletIds:f.outletId?[f.outletId]:void 0}))}if("complete-product"===t.type){const i=o.products[t.productId];return i?void zo(e,i,t.outletId,t.reason,t,n):void e.diagnostics.push(ko("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,n+".productId",[t.productId]))}if("split"===t.type){const i=Lo(e,[t.sourceId],n+".sourceId");t.products.length||e.diagnostics.push(ko("error","empty-split","A split requires at least one product allocation.",n+".products"));const r=t.products.map(e=>e.productId),s=Ao(r);s.length&&e.diagnostics.push(ko("error","duplicate-product","Split product ids must be unique.",n+".products",s));const a=r.map(t=>e.productDefinitions.get(t)),c=r.filter((e,t)=>!a[t]),l=r.filter(e=>o.products[e]);c.length&&e.diagnostics.push(ko("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,n+".products",c)),l.length&&e.diagnostics.push(ko("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,n+".products",l));for(const[i,o]of t.products.entries())void 0===o.amount||Number.isFinite(o.amount)&&o.amount>=0||e.diagnostics.push(ko("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${n}.products.${i}.amount`)),e.diagnostics.push(...So(o.metrics,`${n}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=i[0];if(!Co(e,u.amount,u.metrics,t.loss,n+".loss"))return;const d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??a[t]?.amount),p=h.filter(e=>void 0!==e).length;if(0!==p&&p!==h.length)return void e.diagnostics.push(ko("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",n+".products"));const f=p?h:t.products.map(()=>d/t.products.length),y=f.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>cA)return void e.diagnostics.push(ko("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,n+".products"));const g=xo(u.metrics);for(const[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;const m=Po(e,t,{sourceIds:[u.id],productIds:r});if(t.products.forEach((i,r)=>{const s=a[r],c=d>cA?f[r]/d:1/t.products.length,l=go(Object.entries(g).map(([e,t])=>[e,t*c])),h=i.metrics??s.metrics??l,p=Fo({...s,amount:f[r],metrics:h},[u.id],f[r],xo(h),e,!0,m);Io(e,p.outletId,`${n}.products.${r}.productId`)&&(o.products[p.id]=p)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=r,u.status="consumed",u.outletId=void 0,u.history.push(m),o.loss.amount+=t.loss?.amount??0;for(const[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(m),jo(e,{type:"split-source",sourceIds:[u.id],productIds:r});for(const t of r)jo(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){Io(e,t.outletId,n+".outletId");const i=$o(o,t.select,n+".select");e.diagnostics.push(...i.diagnostics);const r=i.ids.filter(e=>o.components[e].productIds.length);if(r.length&&e.diagnostics.push(ko("error","source-already-assigned",`Assigned source components cannot be ejected: ${r.join(", ")}.`,n+".select",r)),e.diagnostics.some(e=>"error"===e.severity))return;const s=Po(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(const e of i.ids){const i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(s)}return o.history.push(s),void(i.ids.length&&jo(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...So(t.metricsDelta,n+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,r;if("run"===t.target)Mo(o.metrics,t.metricsDelta);else if("components"in t.target){const r=$o(o,t.target.components,n+".target.components");if(e.diagnostics.push(...r.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=r.ids;for(const e of r.ids)Mo(o.components[e].metrics,t.metricsDelta)}else{r=[...t.target.productIds];const i=Ao(r),s=r.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(ko("error","duplicate-product","Metric target product ids must be unique.",n+".target.productIds",i)),s.length&&e.diagnostics.push(ko("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,n+".target.productIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const e of r)Mo(o.products[e].metrics,t.metricsDelta)}return void o.history.push(Po(e,t,{sourceIds:i,productIds:r}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(Po(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(ko("error","invalid-outcome","Outcome must be a non-empty string.",n+".outcome"))}function Bo(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[ko("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const n=vo(e),o={state:n,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(const[i,n]of t.effects.entries())if(Do(o,n,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return n.elapsed=Math.max(n.elapsed,i.appliedAt),n.phaseId=i.phaseId,n.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:n,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function Wo(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function Yo(e,t={}){const i=t.groupBy??"outlet",n=/* @__PURE__ */new Map,o=e=>{const t=Wo({...e,status:e.status??"active"},i),o=n.get(t);if(o)return o.count+=1,o.amount+=e.amount,void Mo(o.metrics,e.metrics);n.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:xo(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(const t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(const t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});const r=new Map((t.order??[]).map((e,t)=>[e,t]));return[...n.values()].sort((e,t)=>(r.get(e.key)??Number.MAX_SAFE_INTEGER)-(r.get(t.key)??Number.MAX_SAFE_INTEGER)||wo(e.key,t.key))}function qo(e,t){return t>e?-1:e>t?1:0}function Xo(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function Go(e){const t=/* @__PURE__ */new Set,i=/* @__PURE__ */new Set;for(const n of e)t.has(n)&&i.add(n),t.add(n);return[...i].sort(qo)}function Vo(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Ho(e,t,i,n,o,r){if(!i)return n;try{return("function"==typeof i?i(e,t):e[i])??n}catch(e){return o.push(Xo("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,r)),n}}function Uo(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Xo("error","invalid-metrics","Metrics must be a numeric object.",i)),go();const n=go();for(const[o,r]of Object.entries(e)){const e=Vo(r);null!=e?n[o]=e:t.push(Xo("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return n}function Ko(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function Zo(e){const t=[],i=go(),n=[];let o=0;const r=go();e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((Ho(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(Xo("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));n.push(l);const u=Vo(Ho(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Xo("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=Uo(Ho(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),p=Ho(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),f=dA.has(p)?p:"active";dA.has(p)||t.push(Xo("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${a}.status`,[l]));const y=Ho(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",g=Ho(s,a,e.categoryAccessor,"component",t,`data.${a}.category`)+"";Object.hasOwn(i,l)||(i[l]={id:l,label:y,category:g,datum:s,status:f,initialAmount:d,amount:d,initialMetrics:mo(h),metrics:mo(h),productIds:[],history:[]},o+=d,Ko(r,h))});const s=Go(n);s.length&&t.push(Xo("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=Uo(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:go(),relations:go(),input:{amount:o,metrics:r},metrics:a,loss:{amount:0,metrics:go()},history:[]},diagnostics:t}}function Qo(e){const t=[];e.length||t.push(Xo("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const i=Go(e.map(e=>e.id));i.length&&t.push(Xo("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let n=0;return{phases:e.map((e,i)=>{const o=Vo(e.duration),r=null!=o&&o>0?o:0;e.id.trim()||t.push(Xo("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),null!=o&&o>0||t.push(Xo("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0===e.intensity||Number.isFinite(e.intensity)||t.push(Xo("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));const s={...e,duration:r,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:n,end:n+r};return n=s.end,s}),diagnostics:t}}function Jo(e,t,i){const n=e.find(e=>hA>=Math.abs(e.start-i));if(n)return{phase:n,boundaryRank:1};const o=e.find(e=>i>=e.start&&e.end>i);return o?{phase:o,boundaryRank:0}:hA>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function er(e,t,i){const n=[],o=Go(e.map(e=>e.id));o.length&&n.push(Xo("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));const r=[];return e.forEach((e,o)=>{let s,a,c;if(e.id.trim()||n.push(Xo("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){const r=Vo(e.at.time);if(null==r||0>r||r>i+hA)return void n.push(Xo("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));s=Math.max(0,Math.min(i,r));const l=Jo(t,i,s);a=l.phase,c=l.boundaryRank}else{if(a=t.find(t=>t.id===e.at.phaseId),!a)return void n.push(Xo("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));const i=e.at.progress??0;if(!Number.isFinite(i)||0>i||i>1)return void n.push(Xo("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));s=a.start+a.duration*i,c=0===i?1:0}a?r.push({...e,index:o,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):n.push(Xo("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),r.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:r,diagnostics:n}}function tr(e,t){const i=[],n=new Set(t.map(e=>e.id)),o=Go(t.map(e=>e.id)),r=Go(e.map(e=>e.id));return o.length&&i.push(Xo("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),r.length&&i.push(Xo("error","duplicate-product-id",`Product ids must be unique: ${r.join(", ")}.`,"products",r)),t.forEach((e,t)=>{e.id.trim()||i.push(Xo("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||i.push(Xo("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Xo("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0===e.amount||Number.isFinite(e.amount)&&e.amount>=0||i.push(Xo("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0===e.outletId||n.has(e.outletId)||i.push(Xo("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Uo(e.metrics??{},i,`products.${t}.metrics`)}),i}function ir(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function nr(e=lA,t=uA){const i=Math.max(1,Vo(e[0])??900),n=Math.max(1,Vo(e[1])??520),o=360>i||260>n,r=o?Math.max(4,.035*Math.min(i,n)):20,s=o?Math.max(10,.075*n):34,a={x:r,y:r,width:Math.max(1,i-2*r),height:s},c=o?Math.max(16,.14*n):Math.min(78,.16*n),l={x:r,y:n-r-c,width:Math.max(1,i-2*r),height:c},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=a.y+a.height+(o?12:38),h=l.y-(o?10:34),p={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},f=Math.max(18,Math.min(.32*p.width,o?84:180)),y={x:p.x+(p.width-f)/2,y:p.y-(o?10:24),width:f,height:o?12:28},g=ir(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{const n=Math.max(8,u-1.5*r),s=p.height/Math.max(1,t.length);t.forEach((t,a)=>{x.push({...t,side:e,x:"left"===e?r:i-r-n,y:p.y+a*s,width:n,height:Math.max(8,s-(o?2:8))})})};b("left",m.left),b("right",m.right);const v=p.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:p.x+t*v,y:p.y+p.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,l.y-p.y-p.height-(o?4:12))})}),x.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:i,height:n,phaseRail:a,chamber:p,mouth:y,projection:l,outlets:x}}function or(e,t,i){const n=i.map(([i,n])=>[Math.max(e,Math.min(i,n)),Math.min(t,Math.max(i,n))]).filter(([e,t])=>t>e+hA).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[];let r=e;for(const[e,t]of n)e>r+hA&&o.push([r,e]),r=Math.max(r,t);return t>r+hA&&o.push([r,t]),o}function rr(e){const{id:t,orientation:i,fixed:n,start:o,end:r,openings:s,thickness:a,friction:c,restitution:l}=e,u=or(o,r,s);return u.map(([e,o],r)=>({id:1===u.length?t:`${t}:${r}`,friction:c,restitution:l,shape:"horizontal"===i?{type:"segment",x1:e,y1:n,x2:o,y2:n,thickness:a}:{type:"segment",x1:n,y1:e,x2:n,y2:o,thickness:a}}))}function sr(e){const{chamber:t,mouth:i}=e,n=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),r=Math.min(t.x+t.width,i.x+i.width),s={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:n}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:r,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:n}}];a.push(...rr({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:s.left.map(e=>[e.y,e.y+e.height]),thickness:n,friction:.46,restitution:.12}),...rr({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:s.right.map(e=>[e.y,e.y+e.height]),thickness:n,friction:.46,restitution:.12}),...rr({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:s.bottom.map(e=>[e.x,e.x+e.width]),thickness:n,friction:.5,restitution:.08}));for(const t of e.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return a}function ar(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t>>>0}function cr(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?ar(e):1}function lr(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function ur(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:cr(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function dr(e){return"crucible:component:"+encodeURIComponent(e)}function hr(e,t,i,n){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;const[o,r]=t;return r-o>hA?n[0]+(n[1]-n[0])*Math.sqrt(Math.max(0,e-o)/(r-o)):(n[0]+n[1])/2}function pr(e,t){const i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),n=e?.[0]??7*i,o=e?.[1]??18*i,r=Math.max(1,Math.min(n,o));return[r,Math.max(r,Math.max(n,o))]}function fr(e,t,i={}){const n=Object.values(e.components).sort((e,t)=>qo(e.id,t.id)),o=Mt(n.map(e=>e.amount)),r=pr(i.radiusRange,t),s=lr(cr(i.seed)),a=t.mouth.x+t.mouth.width/2,c=t.chamber.y+Math.max(18,.18*t.chamber.height),l=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return n.map((e,t)=>{const d=t/Math.max(1,n.length)*Math.PI*2+.18*(s()-.5),h=hr(e.amount,o,i.bodyRadius,r),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:dr(e.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:p}})}function yr(e,t){if(!e)return[];const i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),n=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+t.width/i*(o%i+.5),y:t.y+(Math.floor(o/i)+.5)*(t.height/n)}))}function gr(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function mr(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function xr(e,t){const i=/* @__PURE__ */new Map;for(const t of e){const e=t.outletId??"__chamber__",n=i.get(e)??[];n.push(t),i.set(e,n)}const n=/* @__PURE__ */new Map;for(const[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||qo(e.id,t.id));const i=yr(o.length,mr(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>n.set(e.id,i[t]))}return n}function br(e,t,i={}){const n=Object.values(e.products).sort((e,t)=>qo(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>qo(e.id,t.id)),r=Mt([...o.map(e=>e.amount),...n.map(e=>e.amount)]),s=pr(i.radiusRange,t),a=xr(n,t),c=n.map(e=>{const n=a.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*hr(e.amount,r,i.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(l=e.id,"crucible:product:"+encodeURIComponent(l)),x:n.x,y:n.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:c};var l}),l=/* @__PURE__ */new Map;for(const e of o.filter(e=>!e.productIds.length)){const t=gr(e)??"__chamber__",i=l.get(t)??[];i.push(e),l.set(t,i)}const u=/* @__PURE__ */new Map;for(const[e,i]of l){const n=yr(i.length,mr(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,n[t]))}return[...o.map(e=>{let n=u.get(e.id);if(e.productIds.length){const i=e.productIds.map(e=>a.get(e)).filter(e=>!!e);if(i.length){n={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};const o=ar(e.id)/4294967295*Math.PI*2,r=Math.min(20,Math.max(4,.012*t.width));n={x:n.x+Math.cos(o)*r,y:n.y+Math.sin(o)*r}}}n??(n={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});const o=hr(e.amount,r,i.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:dr(e.id),x:n.x,y:n.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:c}}),...c]}function vr(e){return Array.isArray(e)?e.map(vr):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>qo(e,t)).map(([e,t])=>[e,vr(t)])):e}function wr(e,t){const i=Vo(t)??0,n=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:n,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const o=n>=e.duration-hA,r=o?e.phases[e.phases.length-1]:e.phases.find(e=>n>=e.start&&e.end>n)??e.phases[0];return{elapsed:n,phaseId:r.id,phaseIndex:r.index,phaseElapsed:o?r.duration:Math.max(0,n-r.start),complete:o}}function kr(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Vo(t)??0));const i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;const n=Math.max(0,Math.min(1,Vo(t.progress??0)??0));return i.start+i.duration*n}function Ar(e,t=e.duration){const i=wr(e,t);let n=vo(e.initialState);const o=[],r=[],s=[];for(const t of e.events){if(t.authoredAt>i.elapsed+hA)break;const a=Bo(n,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...a.diagnostics),r.push(...a.materializations),s.push(...a.observations),a.applied&&(n=a.state)}return n.elapsed=i.elapsed,n.phaseId=i.phaseId,n.phaseIndex=i.phaseIndex,n.phaseElapsed=i.phaseElapsed,n.complete=i.complete,i.complete&&"in_process"===n.outcome&&(n.outcome="complete"),n.playing=!1,{state:n,diagnostics:o,materializations:r,observations:s}}function Sr(e){const t=Qo(e.phases),i=t.phases.at(-1)?.end??0,n=ir(e.outlets??uA),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?mo(e.metrics):void 0})),r=er(e.events??[],t.phases,i),s=Zo(e),a=nr(e.size??lA,n),c=sr(a),l=tr(o,n),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>qo(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:n,intensity:o,motion:r,color:s,metrics:a})=>({id:e,duration:t,label:i,description:n,intensity:o,motion:r,color:s,metrics:a})),products:o,outlets:n,events:r.events.map(({id:e,label:t,description:i,summary:n,authoredAt:o,phaseId:r,boundaryRank:s,effects:a})=>({id:e,label:t,description:i,summary:n,authoredAt:o,phaseId:r,boundaryRank:s,effects:a}))},JSON.stringify(vr(d)));var d;const h=fr(s.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),p=[...t.diagnostics,...r.diagnostics,...s.diagnostics,...l],f={phases:t.phases,events:r.events,products:o,outlets:n,duration:i,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:ur(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:p},y=Ar(f),g=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Xo("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return f.terminalState=y.state,f.terminalSpawns=pA(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...p,...y.diagnostics,...m],f}function Mr(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function _r(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function $r(e,t){let i=2166136261;const n=_r(t);for(let e=0;n.length>e;e++)i^=n.charCodeAt(e),i=Math.imul(i,16777619);return`${e}-hatch-${(i>>>0).toString(36)}`}function Pr(e,t){const{background:i="transparent",stroke:n="#000",lineWidth:o=1.5,spacing:r=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*r));/* @__PURE__ */ /* @__PURE__ */
|
|
2
2
|
return(0,yA.jsxs)("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&/* @__PURE__ */ /* @__PURE__ */(0,yA.jsx)("rect",{width:c,height:c,fill:i}),
|
|
3
3
|
/* @__PURE__ */
|
|
4
4
|
/* @__PURE__ */(0,yA.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:n,strokeWidth:o,strokeOpacity:a}),
|
|
5
5
|
/* @__PURE__ */
|
|
6
|
-
/* @__PURE__ */(0,yA.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:n,strokeWidth:o,strokeOpacity:a})]},t)}function
|
|
6
|
+
/* @__PURE__ */(0,yA.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:n,strokeWidth:o,strokeOpacity:a})]},t)}function jr(e,t,i="#4e79a7"){if(Mr(e)){const i=$r(t,e);return{fill:`url(#${i})`,def:Pr(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}function Ir(e,t,i,n){if(!e||"object"!=typeof e)return;const o=e;if(!Array.isArray(o.stops))return;const r=o.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];const{offset:t,color:i,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof i&&i?i:n,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);if(!r.length)return;const s="horizontal"===o.direction?"horizontal":"vertical"===o.direction?"vertical":i,a=t+"-gradient";return{fill:`url(#${a})`,def:/* @__PURE__ */ /* @__PURE__ */(0,yA.jsx)("linearGradient",{id:a,x1:0,y1:0,x2:"horizontal"===s?"100%":0,y2:"vertical"===s?"100%":0,children:r.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,yA.jsx)("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},a)}}function Lr(e){switch(e){case"monotoneX":return gA.curveMonotoneX;case"monotoneY":return gA.curveMonotoneY;case"cardinal":return gA.curveCardinal;case"catmullRom":return gA.curveCatmullRom;case"step":return gA.curveStep;case"stepBefore":return gA.curveStepBefore;case"stepAfter":return gA.curveStepAfter;case"basis":return gA.curveBasis;case"natural":return gA.curveNatural;default:return null}}function Rr(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function Cr(e,t,i,n){const o=e.datum;if(!o?.__crucible)return;const r="circle"===e.shape.type?e.shape.radius:8,s="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",a="string"==typeof t.stroke?t.stroke:"#26323a",c="number"==typeof t.strokeWidth?t.strokeWidth:1.25,l="number"==typeof t.opacity?t.opacity:.96,u=n?`${n}-crucible-body-${i}`:"crucible-body-"+i;if("product"===o.kind){const t=Array.from({length:6},(t,i)=>{const n=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(n)*r},${e.y+Math.sin(n)*r}`}).join(" "),i=u+"-glow";/* @__PURE__ */ /* @__PURE__ */
|
|
7
7
|
return(0,mA.jsxs)(fA.Fragment,{children:[
|
|
8
8
|
/* @__PURE__ */
|
|
9
9
|
/* @__PURE__ */(0,mA.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,mA.jsx)("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:/* @__PURE__ */ /* @__PURE__ */(0,mA.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:s,floodOpacity:"0.8"})})}),
|
|
@@ -15,7 +15,7 @@ return(0,mA.jsxs)(fA.Fragment,{children:[
|
|
|
15
15
|
/* @__PURE__ */
|
|
16
16
|
/* @__PURE__ */(0,mA.jsx)("circle",{cx:e.x,cy:e.y,r:r,fill:s,stroke:a,strokeWidth:c,opacity:l}),
|
|
17
17
|
/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */(0,mA.jsx)("circle",{cx:e.x-.25*r,cy:e.y-.28*r,r:Math.max(1,.18*r),fill:"rgba(255,255,255,0.34)"})]},u)}function
|
|
18
|
+
/* @__PURE__ */(0,mA.jsx)("circle",{cx:e.x-.25*r,cy:e.y-.28*r,r:Math.max(1,.18*r),fill:"rgba(255,255,255,0.34)"})]},u)}function Tr(e){const{x:t,y:i,width:n,height:o}=e.chamber,r=Math.min(.14*n,48),s=i+o;return[`M ${t} ${i}`,`L ${t+r} ${s-.16*o}`,`Q ${t+n/2} ${s+.1*o} ${t+n-r} ${s-.16*o}`,`L ${t+n} ${i}`].join(" ")}function Or({layout:e,phases:t,state:i,compact:n=!1}){const o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));/* @__PURE__ */ /* @__PURE__ */
|
|
19
19
|
return(0,xA.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[
|
|
20
20
|
/* @__PURE__ */
|
|
21
21
|
/* @__PURE__ */(0,xA.jsxs)("defs",{children:[
|
|
@@ -32,14 +32,14 @@ return(0,xA.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",vi
|
|
|
32
32
|
/* @__PURE__ */
|
|
33
33
|
/* @__PURE__ */(0,xA.jsx)("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:bA,strokeOpacity:"0.52",strokeWidth:n?1:2.2}),
|
|
34
34
|
/* @__PURE__ */
|
|
35
|
-
/* @__PURE__ */(0,xA.jsx)("path",{d:
|
|
35
|
+
/* @__PURE__ */(0,xA.jsx)("path",{d:Tr(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),
|
|
36
36
|
/* @__PURE__ */
|
|
37
37
|
/* @__PURE__ */(0,xA.jsx)("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:bA,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:n?2:5}),n?null:/* @__PURE__ */ /* @__PURE__ */(0,xA.jsx)("g",{"data-testid":"crucible-phase-rail",children:t.map((n,r)=>{const s=t.slice(0,r).reduce((e,t)=>e+Math.max(0,t.duration),0),a=e.phaseRail.x+s/o*e.phaseRail.width,c=Math.max(0,n.duration)/o*e.phaseRail.width,l=n.id===i.phaseId,u=i.phaseIndex>r||i.complete;/* @__PURE__ */ /* @__PURE__ */
|
|
38
38
|
return(0,xA.jsxs)("g",{children:[
|
|
39
39
|
/* @__PURE__ */
|
|
40
40
|
/* @__PURE__ */(0,xA.jsx)("rect",{x:a,y:e.phaseRail.y,width:Math.max(1,c-2),height:e.phaseRail.height,rx:2,fill:l?n.color??wA:u?AA:bA,fillOpacity:l?.68:u?.28:.09}),46>c?null:/* @__PURE__ */ /* @__PURE__ */(0,xA.jsx)("text",{x:a+c/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:l?bA:vA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:l?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(n.label??n.id).toUpperCase()})]},n.id)})}),e.outlets.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,xA.jsxs)("g",{children:[
|
|
41
41
|
/* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */(0,xA.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?kA:AA),fillOpacity:"0.1",stroke:e.color??("left"===e.side?kA:AA),strokeDasharray:"3 3",strokeOpacity:"0.62"}),n?null:/* @__PURE__ */ /* @__PURE__ */(0,xA.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:vA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function
|
|
42
|
+
/* @__PURE__ */(0,xA.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?kA:AA),fillOpacity:"0.1",stroke:e.color??("left"===e.side?kA:AA),strokeDasharray:"3 3",strokeOpacity:"0.62"}),n?null:/* @__PURE__ */ /* @__PURE__ */(0,xA.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:vA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function Er(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function Fr({rows:e,layout:t,projection:i,amountLabel:n}){if(!e.length)return null;const o=i.measure??"count",r=e.map(e=>Math.max(0,Er(e,o))),s=r.reduce((e,t)=>Math.max(e,t),1),a=t.projection.width/Math.max(1,e.length),c=t.projection.height>48?21:4,l=Math.max(5,t.projection.height-c-5);/* @__PURE__ */ /* @__PURE__ */
|
|
43
43
|
return(0,xA.jsx)("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{const u=r[i],d=Math.max(u>0?2:0,u/s*l),h=t.projection.x+i*a+.18*a;/* @__PURE__ */ /* @__PURE__ */
|
|
44
44
|
return(0,xA.jsxs)("g",{children:[
|
|
45
45
|
/* @__PURE__ */
|
|
@@ -47,7 +47,7 @@ return(0,xA.jsxs)("g",{children:[
|
|
|
47
47
|
/* @__PURE__ */
|
|
48
48
|
/* @__PURE__ */(0,xA.jsx)("text",{x:h+.32*a,y:t.projection.y+l+10,fill:vA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),
|
|
49
49
|
/* @__PURE__ */
|
|
50
|
-
/* @__PURE__ */(0,xA.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:bA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[
|
|
50
|
+
/* @__PURE__ */(0,xA.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:bA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[Rr(u),"amount"===o&&n?" "+n:""]})]}):null]},e.key)})})}function Nr(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function zr(e,t={}){const i=t.bodies??[],n=Math.max(0,t.recentBodyLimit??6),o=/* @__PURE__ */new Map;for(const e of i){const i=t.getContainerId?.(e);if(!i)continue;const n=o.get(i);n?n.push(e):o.set(i,[e])}const r=e.map(e=>{const i=o.get(e.id)??[],r=Math.max(0,Math.floor(e.count??i.length)),s=i.slice(Math.max(0,i.length-n)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??Nr(e),datum:e.datum}));return{id:e.id,label:e.label,count:r,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:s,metadata:e.metadata}}),s=r.reduce((e,t)=>e+t.count,0);return r.map(e=>({...e,share:s>0?e.count/s:0}))}function Dr(e){if(!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 Br(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:SA}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}function Wr(e){if(!e)return MA;if("string"==typeof e)return"light"===e?MA:"dark"===e?_A:"high-contrast"===e?$A:(Object.prototype.hasOwnProperty.call(PA,t=e)?PA[t]:void 0)||MA;var t;const i="dark"===e.mode?_A:MA;return Br({...i,...e,colors:{...i.colors,...e.colors||{}},typography:{...i.typography,...e.typography||{}},tooltip:{...i.tooltip,...e.tooltip||{}}})}function Yr(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function qr(e,t,i,n,o){const r=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==r.length)return({size:o})=>{const s=[Number(o[0])||700,Number(o[1])||420],a=ht(s),c=Math.max(2,Math.round(t)),l=a.plot.width/c,u=a.plot.y+a.plot.height,d=e.reduce((e,t)=>Math.max(e,t.value),1),h=!1!==i,[p,f]=n?.valueExtent??[0,c],y=f===p?1:f-p,g=e.map((e,t)=>{const i=u-e.value/d*a.plot.height*.9;return`${0===t?"M":"L"} ${(a.plot.x+(t+.5)*l).toFixed(1)} ${i.toFixed(1)}`}).join(" ");/* @__PURE__ */ /* @__PURE__ */
|
|
51
51
|
return(0,jA.jsxs)("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:s[0],height:s[1],viewBox:`0 0 ${s[0]} ${s[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?/* @__PURE__ */ /* @__PURE__ */(0,jA.jsxs)(jA.Fragment,{children:[Array.from({length:c+1},(e,t)=>{const i=a.plot.x+t*l;/* @__PURE__ */ /* @__PURE__ */
|
|
52
52
|
return(0,jA.jsx)("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:a.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),
|
|
53
53
|
/* @__PURE__ */
|
|
@@ -56,7 +56,7 @@ return(0,jA.jsx)("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:a.pl
|
|
|
56
56
|
/* @__PURE__ */(0,jA.jsx)("path",{d:g,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?/* @__PURE__ */ /* @__PURE__ */(0,jA.jsx)("text",{x:a.plot.x+(t+.5)*l,y:Math.max(a.plot.y+10,u-e.value/d*a.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`):null)]}):null,r.map((e,t)=>{const i=Number(e.value);if(!Number.isFinite(i))return null;const n=a.plot.x+Math.max(0,Math.min(1,(i-p)/y))*a.plot.width,o=e.color??"var(--semiotic-warning, #f28e2b)",r="bottom"===e.labelPosition?Math.min(s[1]-8,u+16):a.plot.y+16;/* @__PURE__ */ /* @__PURE__ */
|
|
57
57
|
return(0,jA.jsxs)("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[
|
|
58
58
|
/* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */(0,jA.jsx)("line",{x1:n,x2:n,y1:a.plot.y+8,y2:u-4,stroke:o,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:/* @__PURE__ */ /* @__PURE__ */(0,jA.jsx)("text",{x:Math.min(a.plot.x+a.plot.width-4,n+6),y:r,fill:o,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function
|
|
59
|
+
/* @__PURE__ */(0,jA.jsx)("line",{x1:n,x2:n,y1:a.plot.y+8,y2:u-4,stroke:o,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:/* @__PURE__ */ /* @__PURE__ */(0,jA.jsx)("text",{x:Math.min(a.plot.x+a.plot.width-4,n+6),y:r,fill:o,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function Xr(e,t,i){if(!1!==i&&t)return({size:i})=>{const n=[Number(i[0])||760,Number(i[1])||360],o=ht(n),r=Math.max(1,t.windowCount),s=t.plot??o.plot,a=t.gutter??{x:s.x,y:s.y,width:0,height:s.height},c=t.windowPlot??s,l=c.width/r,u=s.y+s.height,d=s.y+.48*s.height,h=t.lidSegments[0]?.y1??d,p=t.windowStart,f=t.windowStart+r*t.windowSize,y=c.x+Math.max(0,Math.min(1,f===p?0:(t.watermarkValue-p)/(f-p)))*c.width;/* @__PURE__ */ /* @__PURE__ */
|
|
60
60
|
return(0,jA.jsxs)("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
61
61
|
/* @__PURE__ */
|
|
62
62
|
/* @__PURE__ */(0,jA.jsx)("rect",{x:s.x,y:s.y,width:s.width,height:s.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),a.width>0?/* @__PURE__ */ /* @__PURE__ */(0,jA.jsxs)("g",{children:[
|
|
@@ -76,7 +76,7 @@ return(0,jA.jsxs)("g",{children:[
|
|
|
76
76
|
/* @__PURE__ */
|
|
77
77
|
/* @__PURE__ */(0,jA.jsx)("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:s.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),
|
|
78
78
|
/* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */(0,jA.jsxs)("text",{x:Math.min(s.x+s.width-4,y+6),y:s.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function
|
|
79
|
+
/* @__PURE__ */(0,jA.jsxs)("text",{x:Math.min(s.x+s.width-4,y+6),y:s.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function Gr(e,t,i,n=1){if(!1!==i&&0!==e.length)return({size:i})=>{const o=[Number(i[0])||700,Number(i[1])||380],r=ht(o),s=an(r.plot,e.length,t),a=r.plot.y+r.plot.height;/* @__PURE__ */ /* @__PURE__ */
|
|
80
80
|
return(0,jA.jsxs)("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
81
81
|
/* @__PURE__ */
|
|
82
82
|
/* @__PURE__ */(0,jA.jsx)("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:a,y2:a,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{const i=Math.min(r.plot.height,s.pileHeight(e.value/n)),c=s.tubeWidth,l=s.centerX(t),u=a-i;/* @__PURE__ */ /* @__PURE__ */
|
|
@@ -88,7 +88,7 @@ return(0,jA.jsxs)("g",{children:[
|
|
|
88
88
|
/* @__PURE__ */
|
|
89
89
|
/* @__PURE__ */(0,jA.jsx)("text",{x:l,y:Math.min(o[1]-8,a+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),
|
|
90
90
|
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */(0,jA.jsx)("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${n}; partial circles scaled by area`})]})}}function
|
|
91
|
+
/* @__PURE__ */(0,jA.jsx)("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${n}; partial circles scaled by area`})]})}}function Vr(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function Hr(e,t){if(!1!==t&&e)return({size:t})=>{const i=[Number(t[0])||700,Number(t[1])||360],n=ht(i),o=n.plot.y+n.plot.height,[r,s]=e.xExtent,a=r+(s-r)/2,c=[{label:Vr(r),x:e.xRange[0]},{label:Vr(a),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Vr(s),x:e.xRange[1]}];/* @__PURE__ */ /* @__PURE__ */
|
|
92
92
|
return(0,jA.jsxs)("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?/* @__PURE__ */ /* @__PURE__ */(0,jA.jsx)("text",{"data-testid":"collision-swarm-overlap-warning",x:n.plot.x,y:Math.max(10,n.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:360>i[0]?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,jA.jsxs)("g",{children:[
|
|
93
93
|
/* @__PURE__ */
|
|
94
94
|
/* @__PURE__ */(0,jA.jsx)("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),
|
|
@@ -101,7 +101,7 @@ return(0,jA.jsxs)("svg",{"aria-hidden":"true","data-testid":"collision-swarm-pro
|
|
|
101
101
|
/* @__PURE__ */
|
|
102
102
|
/* @__PURE__ */(0,jA.jsx)("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),
|
|
103
103
|
/* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */(0,jA.jsx)("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}function
|
|
104
|
+
/* @__PURE__ */(0,jA.jsx)("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}function Ur(e,t,i){return Math.max(t,Math.min(i,e))}function Kr(e){return 6.2*e.length}function Zr(e,t){const i=e.trim();if(t>=i.length)return i;if(1>=t)return i.slice(0,1);const n=i.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return n.length>1&&t>=n.length?n:t>3?i.slice(0,Math.max(1,t-2))+"..":i.slice(0,t).toUpperCase()}function Qr(e,t,i="auto"){const n=Math.max(1,Math.floor(t/6.2)),o="compact"===i?Zr(e,n):"full"===i?e:Kr(e)>t?Zr(e,n):e;return{text:o,textLength:Kr(o)>t?Math.max(4,t):void 0}}function Jr(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function es(e){if(null!=e.capacity){const t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function ts(e,t={}){const{showFlowSpine:i=!0,showStageCounts:n=!0,showCapacityBadges:o=!0,showGroupSockets:r=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:p,bottomY:f,midY:y,stages:g,groups:m=[]}=e,x=f-p;/* @__PURE__ */ /* @__PURE__ */
|
|
105
105
|
return(0,IA.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[
|
|
106
106
|
/* @__PURE__ */
|
|
107
107
|
/* @__PURE__ */(0,IA.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,IA.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
|
|
@@ -112,7 +112,7 @@ return(0,IA.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stag
|
|
|
112
112
|
/* @__PURE__ */
|
|
113
113
|
/* @__PURE__ */(0,IA.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),
|
|
114
114
|
/* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */(0,IA.jsx)("rect",{x:d-6,y:p-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),i?/* @__PURE__ */ /* @__PURE__ */(0,IA.jsx)("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const i=
|
|
115
|
+
/* @__PURE__ */(0,IA.jsx)("rect",{x:d-6,y:p-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),i?/* @__PURE__ */ /* @__PURE__ */(0,IA.jsx)("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const i=Jr(e),r=LA[i],c=Math.max(12,e.width-8),l=Ur(c-8,22,88),d=Qr(e.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,m=es(e),b=Qr(m,Math.max(16,c-10),"auto"),v=o&&!1!==e.showBadge&&c>=32,w=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",k=Qr(w,Math.max(16,c-8),"auto"),A=Math.max(30,p-15),S=A-13;/* @__PURE__ */ /* @__PURE__ */
|
|
116
116
|
return(0,IA.jsxs)("g",{"data-stage":e.id,"data-role":i,children:[
|
|
117
117
|
/* @__PURE__ */
|
|
118
118
|
/* @__PURE__ */(0,IA.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:c,height:x-12,rx:10,fill:a?"none":r.fill,stroke:r.stroke,strokeWidth:a?1.85:"flow"===i?1:1.6}),g.length-1>t?/* @__PURE__ */ /* @__PURE__ */(0,IA.jsx)("polygon",{points:`${e.x1-2},${y-7} ${e.x1+8},${y} ${e.x1-2},${y+7}`,fill:r.accent,opacity:.85}):null,h?/* @__PURE__ */ /* @__PURE__ */(0,IA.jsxs)(IA.Fragment,{children:[
|
|
@@ -125,7 +125,7 @@ return(0,IA.jsxs)("g",{"data-stage":e.id,"data-role":i,children:[
|
|
|
125
125
|
/* @__PURE__ */
|
|
126
126
|
/* @__PURE__ */(0,IA.jsx)("title",{children:m}),b.text]}):null,n&&null!=e.count?/* @__PURE__ */ /* @__PURE__ */(0,IA.jsxs)("text",{x:e.x,y:Math.min(u-8,f+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[
|
|
127
127
|
/* @__PURE__ */
|
|
128
|
-
/* @__PURE__ */(0,IA.jsx)("title",{children:w}),k.text]}):null]},e.id)}),r?m.map((e,t)=>{const i=e.total??0,n=e.absorbed??0,o=e.complete??(i>0&&n>=i),r=!o&&i>0&&n/i>=.75,s=o?"rgba(52, 211, 153, 0.35)":r?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=o?"#34d399":r?"#fbbf24":"var(--semiotic-border, #64748b)",c=i>0?`${n}/${i}${o?" shipped":r?" almost":""}`:"feature "+(t+1),l=
|
|
128
|
+
/* @__PURE__ */(0,IA.jsx)("title",{children:w}),k.text]}):null]},e.id)}),r?m.map((e,t)=>{const i=e.total??0,n=e.absorbed??0,o=e.complete??(i>0&&n>=i),r=!o&&i>0&&n/i>=.75,s=o?"rgba(52, 211, 153, 0.35)":r?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=o?"#34d399":r?"#fbbf24":"var(--semiotic-border, #64748b)",c=i>0?`${n}/${i}${o?" shipped":r?" almost":""}`:"feature "+(t+1),l=Ur(Math.max(54,Kr(e.label)+18,Kr(c)+16),54,104),u=Qr(e.label,l-12,"auto"),d=Qr(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
|
|
129
129
|
return(0,IA.jsxs)("g",{"data-group":e.id,children:[
|
|
130
130
|
/* @__PURE__ */
|
|
131
131
|
/* @__PURE__ */(0,IA.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),
|
|
@@ -136,18 +136,18 @@ return(0,IA.jsxs)("g",{"data-group":e.id,children:[
|
|
|
136
136
|
/* @__PURE__ */
|
|
137
137
|
/* @__PURE__ */(0,IA.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[
|
|
138
138
|
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */(0,IA.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function
|
|
139
|
+
/* @__PURE__ */(0,IA.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function is(e,t,i={},n){if(!1===t||!e)return;const{volume:o,stages:r,groups:s,groupCompletion:a}=e,c=new Map(o.stages.map(e=>[e.id,e])),l=new Map(a.map(e=>[e.id,e]));return({size:e})=>{const t=Number(e[0])||o.width,a=Number(e[1])||o.height,u=r.map(e=>{const t=c.get(e.id),n=i["process-stage-"+e.id];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:n?.queueDepth,processed:n?.processedCount}}),d=s.map(e=>{const t=l.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return ts({width:t,height:a,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...n})}}function ns(e,t,i){if(!1===i||!t||0===e.length)return;const n=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{const o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],r=ht(o),s=e.reduce((e,t)=>Math.max(e,t.value),1),a=Math.min(48,.18*r.plot.height),c=r.plot.y+6;/* @__PURE__ */ /* @__PURE__ */
|
|
140
140
|
return(0,RA.jsx)("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{const o=e[i];if(!o)return null;const r=n.get(t.id);if(!r)return null;const l=Math.max(2,o.value/s*a),u=Math.max(8,.35*r.width);/* @__PURE__ */ /* @__PURE__ */
|
|
141
|
-
return(0,RA.jsx)("rect",{x:r.x-u/2,y:c,width:u,height:l,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function
|
|
141
|
+
return(0,RA.jsx)("rect",{x:r.x-u/2,y:c,width:u,height:l,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function os(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function rs(e,t){const{showNodeLabels:i,showSensors:n,showStaticFlow:o}=t;if(e&&(o||n||i))return({size:t})=>{const r=[Number(t[0])||760,Number(t[1])||420],s=e.links.reduce((e,t)=>Math.max(e,t.throughput),1),a=new Set(e.nodes.map(e=>e.sensorId));/* @__PURE__ */ /* @__PURE__ */
|
|
142
142
|
return(0,CA.jsxs)("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{const t=3+e.throughput/s*16,i=e.path[Math.floor(e.path.length/2)];/* @__PURE__ */ /* @__PURE__ */
|
|
143
143
|
return(0,CA.jsxs)("g",{children:[
|
|
144
144
|
/* @__PURE__ */
|
|
145
|
-
/* @__PURE__ */(0,CA.jsx)("path",{d:
|
|
145
|
+
/* @__PURE__ */(0,CA.jsx)("path",{d:os(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),
|
|
146
146
|
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */(0,CA.jsx)("path",{d:
|
|
147
|
+
/* @__PURE__ */(0,CA.jsx)("path",{d:os(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?/* @__PURE__ */ /* @__PURE__ */(0,CA.jsx)("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:(n=e.throughput,n.toLocaleString(void 0,1e3>Math.abs(n)?{maximumFractionDigits:1}:{maximumFractionDigits:0}))}):null]},e.id);var n}):null,e.nodes.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,CA.jsxs)("g",{children:[n&&a.has(e.sensorId)?/* @__PURE__ */ /* @__PURE__ */(0,CA.jsx)("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?/* @__PURE__ */ /* @__PURE__ */(0,CA.jsx)("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?/* @__PURE__ */ /* @__PURE__ */(0,CA.jsx)("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}function ss({layout:e,compact:t,showLabels:i}){const n=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);/* @__PURE__ */ /* @__PURE__ */
|
|
148
148
|
return(0,TA.jsx)(TA.Fragment,{children:e.gates.map(r=>/* @__PURE__ */ /* @__PURE__ */(0,TA.jsxs)("g",{children:[
|
|
149
149
|
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */(0,TA.jsx)("rect",{x:r.x-r.width/2,y:n,width:r.width,height:o,rx:t?2:12,fill:r.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:r.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?/* @__PURE__ */ /* @__PURE__ */(0,TA.jsx)("text",{x:r.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:r.label??r.id}):null]},r.id))})}function
|
|
150
|
+
/* @__PURE__ */(0,TA.jsx)("rect",{x:r.x-r.width/2,y:n,width:r.width,height:o,rx:t?2:12,fill:r.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:r.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?/* @__PURE__ */ /* @__PURE__ */(0,TA.jsx)("text",{x:r.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:r.label??r.id}):null]},r.id))})}function as({layout:e,states:t,compact:i=!1}){return i?/* @__PURE__ */ /* @__PURE__ */(0,TA.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,TA.jsx)(ss,{layout:e,compact:!0,showLabels:!1})}):/* @__PURE__ */ /* @__PURE__ */(0,TA.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
151
151
|
/* @__PURE__ */
|
|
152
152
|
/* @__PURE__ */(0,TA.jsx)("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),
|
|
153
153
|
/* @__PURE__ */
|
|
@@ -155,7 +155,7 @@ return(0,TA.jsx)(TA.Fragment,{children:e.gates.map(r=>/* @__PURE__ */ /* @__PURE
|
|
|
155
155
|
/* @__PURE__ */
|
|
156
156
|
/* @__PURE__ */(0,TA.jsx)("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),
|
|
157
157
|
/* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */(0,TA.jsx)(
|
|
158
|
+
/* @__PURE__ */(0,TA.jsx)(ss,{layout:e,compact:!1,showLabels:!0}),
|
|
159
159
|
/* @__PURE__ */
|
|
160
160
|
/* @__PURE__ */(0,TA.jsxs)("g",{children:[
|
|
161
161
|
/* @__PURE__ */
|
|
@@ -169,7 +169,7 @@ return(0,TA.jsx)(TA.Fragment,{children:e.gates.map(r=>/* @__PURE__ */ /* @__PURE
|
|
|
169
169
|
/* @__PURE__ */
|
|
170
170
|
/* @__PURE__ */(0,TA.jsx)("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),
|
|
171
171
|
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */(0,TA.jsx)("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function
|
|
172
|
+
/* @__PURE__ */(0,TA.jsx)("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function cs(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}function ls({states:e,layout:t}){const i=cs(e);if(!i.length)return null;const n=i.reduce((e,t)=>Math.max(e,t.value),1),o=Math.max(40,(t.width-80)/i.length);/* @__PURE__ */ /* @__PURE__ */
|
|
173
173
|
return(0,TA.jsxs)("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
|
|
174
174
|
/* @__PURE__ */
|
|
175
175
|
/* @__PURE__ */(0,TA.jsx)("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{const i=40+t*o,r=Math.max(2,e.value/n*28),s=/kill|crash|block|grave/i.test(e.outcome);/* @__PURE__ */ /* @__PURE__ */
|
|
@@ -177,15 +177,15 @@ return(0,TA.jsxs)("g",{children:[
|
|
|
177
177
|
/* @__PURE__ */
|
|
178
178
|
/* @__PURE__ */(0,TA.jsx)("rect",{x:i+.18*o,y:28-r+22,width:Math.max(10,.45*o),height:r,rx:2,fill:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:s?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),
|
|
179
179
|
/* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */(0,TA.jsx)("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function as(e){return e.map(e=>({...e,spawnAt:void 0}))}function cs(e,t){return e?t?i=>nk.createElement(nk.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function ls(e,t,i){const n=t[i];return"boolean"==typeof n?n:!0!==e.__compactMode}function us(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return EA[(t>>>0)%EA.length]}function ds(e,t,i,n){const o=e.datum,r={stroke:n.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:n.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:n.opacity??.96};if(!o?.__crucible)return{...r,fill:n.color??"#b8792d"};if("product"===o.kind){const e=t.products[o.semanticId];return{...r,fill:n.color??e?.color??us(e?.id??o.semanticId)}}const s=t.components[o.semanticId];if(!s)return{...r,fill:n.color??"#356b63"};let a;return a="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:"function"==typeof i?(i(s.datum)??"unassigned")+"":(s.datum[i+""]??"unassigned")+"",{...r,fill:n.color??us(a)}}function hs(e,t){const i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}function ps(e){return e?{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}:e}function fs(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function ys(e,t={}){const i=new Set(t.templates??["repeated-state-episode"]),n=e.filter(e=>i.has(e.template)).map(e=>({id:"capsule:"+e.id,matchId:e.id,template:e.template,entryState:"string"==typeof e.roles.state?e.roles.state:e.nodePath[0],exitState:e.nodePath[e.nodePath.length-1],entityCount:e.entityCount,occurrenceIds:fs(e),selected:!1})).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),o=/* @__PURE__ */new Set;for(const e of n)if(!e.occurrenceIds.some(e=>o.has(e))){e.selected=!0;for(const t of e.occurrenceIds)o.add(t)}return n}function gs(e,t=[],i){const n=void 0===i?void 0:new Set("string"==typeof i?[i]:i),o=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&n?.has(e.partition)),r=new Set(o.map(e=>e.id)),s=new Set(o.map(e=>e.entityId)),a=/* @__PURE__ */new Map;let c=0;for(const t of e){if(void 0!==i&&"string"==typeof t.roles.occurrence&&!r.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===i&&(c+=t.entityCount);for(const[t,n]of e)(void 0===i||s.has(t))&&a.set(t,n)}return[...a.values()].reduce((e,t)=>e+t,c)}function ms(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function xs(e,t,i){return e.entries.find(e=>e.measureId===t&&e.subjectId===i)}function bs(e){const t=e.spec.comparison;if(!t)return;const i=t.partitions.map(i=>{const n=xs(e.ledger,t.denominatorMeasureId,i)?.value??0,o={};return o["repeated-state-episode"]=gs(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,i),{partition:i,assigned:n,motifUsers:o,outcomes:{purchases:xs(e.ledger,"purchases",i)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:i}}function vs(e,t){const i=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return xs(e.ledger,i,t)?.value}function ws(e,t,i){return 0===i||1e4*e%i!=0?Math.round((t-e)/Math.max(i,1)*1e4):1e4*(t-e)/i}function ks(e,t={}){const i=t.templates??["repeated-state-episode"],n="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],o=void 0!==t.partition?vs(e,t.partition)??0:e.spec.comparison?e.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:e.ledger.entries.find(t=>"global"===t.subjectKind&&t.measureId===e.spec.motifs.denominatorRef)?.value??0,r=i=>gs(i,e.source.occurrences,t.partition??e.spec.comparison?.partitions),s=[],a=e.motifs.incompleteCandidates.length>0;for(const c of i)for(const i of n){const n=e.motifs.matches.filter(e=>e.template===c),l=r(n.filter(e=>e.completionSectionId===i)),u=r(n.filter(e=>e.intersectSectionIds.includes(i)));s.push({template:c,sectionId:i,partition:t.partition,completionCount:l,intersectionCount:u,denominator:o,status:a?"incomplete":"exact"})}return{templates:i,sections:n,cells:s}}function As(e){return e.entityCount??1}function Ss(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:As(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:ms(e.nodePath,e.nodePath.length-1)}}function Ms(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:ks(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const i=(e.source.occurrences??[]).map(Ss).filter(e=>!!e),n=/* @__PURE__ */new Map;for(const e of i){const i=t.order.indexOf(e.signature),o=n.get(e.signature),r=-1===i?t.order.length:i;(null==o||o>r)&&n.set(e.signature,r)}const o=[...new Set(i.map(e=>e.signature))].sort((e,t)=>{const i=(n.get(e)??0)-(n.get(t)??0);return 0!==i?i:e.localeCompare(t)}),r=[];for(const e of i)for(let t=0;e.nodePath.length-1>t;t++){const i=ms(e.nodePath,t),n=ms(e.nodePath,t+1);r.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:i,toPrefixId:n,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const s=ys(e.motifs.matches),a=e.comparison??bs(e),c=[];if(a&&a.partitions.length>=2){const e=a.rows[0],t=a.rows[1],i=Math.min(e.assigned,t.assigned)||e.assigned,n=e.motifUsers["repeated-state-episode"]??0,o=t.motifUsers["repeated-state-episode"]??0;c.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:n,rightCount:o,deltaCount:o-n,deltaBps:ws(n,o,i),denominator:i}),c.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:ws(e.outcomes.purchases??0,t.outcomes.purchases??0,i),denominator:i})}const l={nodes:i.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:r.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:i,signatureOrder:o,ribbons:r,capsules:s,profile:ks(e),differences:c,prefixForest:t,sceneSeeds:l}}function _s(e){let t=1/0,i=-1/0;for(const n of e)t>n&&(t=n),n>i&&(i=n);return[t,i]}function $s(e,t=1/0){let i=t;for(const t of e)i>t&&(i=t);return i}function Ps(e,t=-1/0){let i=t;for(const t of e)t>i&&(i=t);return i}function js(e,t){if(0===t||2>e.length)return e.map(e=>({...e}));const i=(e,t)=>{const i=t.x-e.x,n=t.y-e.y,o=Math.hypot(i,n)||1;return{x:-n/o,y:i/o}};return e.map((n,o)=>{const r=o>0?i(e[o-1],n):null,s=e.length-1>o?i(n,e[o+1]):null;if(!r||!s){const e=s??r??{x:0,y:0};return{x:n.x+e.x*t,y:n.y+e.y*t}}let a=r.x+s.x,c=r.y+s.y;const l=Math.hypot(a,c);if(.001>l)return{x:n.x+s.x*t,y:n.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(.001>Math.abs(u))return{x:n.x+s.x*t,y:n.y+s.y*t};const d=4*Math.abs(t),h=Math.max(-d,Math.min(d,t/u));return{x:n.x+a*h,y:n.y+c*h}})}function Is(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const i=Math.max(0,t);let n=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){const o=e[t-1],r=e[t],s=e[t+1],a=Math.hypot(r.x-o.x,r.y-o.y),c=Math.hypot(s.x-r.x,s.y-r.y),l=Math.min(i,a/2,c/2);if(.001>=l){n+=` L${r.x},${r.y}`;continue}const u={x:r.x+(o.x-r.x)/a*l,y:r.y+(o.y-r.y)/a*l},d={x:r.x+(s.x-r.x)/c*l,y:r.y+(s.y-r.y)/c*l};n+=` L${u.x},${u.y} Q${r.x},${r.y} ${d.x},${d.y}`}const o=e[e.length-1];return`${n} L${o.x},${o.y}`}function Ls(e){const t=[e[0]];for(let i=1;e.length-1>i;i++){const n=e[i-1],o=e[i],r=e[i+1],s=VA(n,o),a=VA(o,r),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=GA(o,n,c/s),u=GA(o,r,c/a);t.push(l);for(let e=1;12>=e;e++){const i=e/12;t.push(GA(GA(l,o,i),GA(o,u,i),i))}}return t.push(e[e.length-1]),t.filter((e,i)=>0===i||VA(t[i-1],e)>1e-8)}function Rs(e,t,i){if(2>e.length)return"";const n=Ls(e);if(2>n.length)return"";const o=[0];for(let e=1;n.length>e;e++)o.push(o[e-1]+VA(n[e-1],n[e]));const r=o[o.length-1],s=js(n,1),a=[1,-1].map(e=>n.map((n,a)=>GA(n,s[a],e*(t+(i-t)*o[a]/r)/2)));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function Cs(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const i=t+e/2;return t+=e+3,i})}function Ts(e){let t="";return e.split(">").map((e,i)=>t=i?`${t}>${e}`:e)}function Os(e){const t=/* @__PURE__ */new Map;for(const i of e){const e=Ts(i.signature);i.nodePath.forEach((n,o)=>{const r=e[o];let s=t.get(r);s||(s={id:r,state:n,depth:o+1,signatures:/* @__PURE__ */new Set},t.set(r,s)),s.signatures.add(i.signature)})}return[...t.values()]}function Es(e,t){const i=/* @__PURE__ */new Set,n=[t];for(;n.length;){const t=n.pop();if(i.has(t))continue;i.add(t);const o=e.children[t];Array.isArray(o)&&n.push(...o)}return i}function Fs(e,t){const i=[],n=e.requiredChildren[t],o=Array.isArray(n)?[...n]:[];for(;o.length;){const t=o.pop();i.push(t),o.push(...e.requiredChildren[t])}return i.sort()}function Ns(e,t,i){if(!Number.isFinite(t)||!Number.isFinite(i)||360>t||300>i)throw Error("Circuit geometry needs at least 360 × 300 pixels");const n=[...e.atlas.sections.sectionIds];e.atlas.source.nodes.some(e=>!e.sectionId)&&n.push("Unsectioned");const o=bn({width:t,height:i-110,padX:22,padY:70,stages:n.map(e=>({id:e})),shape:"lane"}),r=new Map(e.atlas.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),s=o.stages.flatMap(t=>{const n=e.order.filter(e=>r.get(e)===t.id),o=(i-235)/Math.max(1,n.length);if(n.length&&78>o)throw Error("Increase circuit height to keep every module readable");return n.map((i,n)=>{const r=e.modules.find(e=>e.nodeId===i),s=Math.max(68,Math.min(142,t.width-56)),a=Math.min(68,o-10),c=t.x-s/2,l=95+(n+.5)*o-a/2;return{module:r,x:c,y:l,width:s,height:a,queue:{x:c+8,y:l+a-8,width:s-16,height:4},sensor:{x:c+s-5,y:l+a/2-4,width:8,height:8}}})}),a=new Map(s.map(e=>[e.module.nodeId,e])),c=new Set(e.residualEdgeIds);let l=0;const u=e.atlas.source.edges.map(e=>{const t=a.get(e.source),i=a.get(e.target),o=i.x>t.x,s=i.x===t.x,u=(t,i)=>{const n=t.module.ports.filter(e=>e.direction===i),o=n.findIndex(t=>t.edgeId===e.id);return t.y+10+(o+.5)*(t.height-20)/n.length},d={x:t.x+(o||s?t.width:0),y:u(t,"out")},h={x:i.x+(o?0:i.width),y:u(i,"in")};let p;if(s){const i=d.x+18+5*l++;p=e.source===e.target?[d,{x:i,y:d.y},{x:i,y:t.y-15},{x:h.x-8,y:t.y-15},{x:h.x-8,y:t.y}]:[d,{x:i,y:d.y},{x:i,y:h.y},h]}else if(!o||Math.abs(n.indexOf(r.get(e.source))-n.indexOf(r.get(e.target)))>1){const e=o?1:-1,t=62+7*l++;p=[d,{x:d.x+16*e,y:d.y},{x:d.x+16*e,y:t},{x:h.x-16*e,y:t},{x:h.x-16*e,y:h.y},h]}else{const e=(d.x+h.x)/2;p=[d,{x:e,y:d.y},{x:e,y:h.y},h]}return{edgeId:e.id,source:e.source,target:e.target,residual:c.has(e.id),points:p,pathD:ts(p)}});return{width:t,height:i,modules:s,routes:u,sections:o.stages.map(e=>({id:e.id,x:e.x})),history:{x:42,y:i-88,width:t-84,height:46}}}function zs(e,t){const i=e.slice(1).map((t,i)=>Math.hypot(t.x-e[i].x,t.y-e[i].y)),n=i.reduce((e,t)=>e+t,0);let o=Math.max(0,Math.min(1,t))*n;for(let t=0;i.length>t;t++){if(i[t]>=o){const n=i[t]?o/i[t]:0;return{x:e[t].x+(e[t+1].x-e[t].x)*n,y:e[t].y+(e[t+1].y-e[t].y)*n}}o-=i[t]}return e[e.length-1]}function Ds(e,t={}){return{observed:t.observed??e.info??e.primary??"#387e98",modeled:t.modeled??e.secondary??"#946344",residual:t.residual??e.warning??"#a56537",muted:t.muted??e.textSecondary??iS.muted,alarm:t.alarm??e.danger??iS.alarm}}function Bs(e,t,i,n,o,r=iS,s){const a=Object.values(t.entry.nodes).map(e=>e.queued??0),c=Math.max(1,...a);return e.modules.map(e=>{const{module:a,x:l,y:u,width:d,height:h,queue:p}=e,f=t.entry.nodes[a.nodeId],y=o===a.nodeId?i:(f.queued??0)>0?r.alarm:r.muted,g=l+d/2,m="records"===a.semantics.unit?"rec":"attempts"===a.semantics.unit?"att":"roots",x=null!==f.capacity?`${nS(f.completions)} / ${nS(f.capacity)} ${m}/s`:null!==f.completions?`${nS(f.completions)} ${m}/s complete`:`${nS(f.arrivals)} ${m}/s offered`;return tS("g",{key:a.id,"data-circuit-module":a.nodeId,"data-module-kind":a.kind,opacity:s?.(a.nodeId),"data-queued":f.queued??"unmeasured"},tS("rect",{x:l,y:u,width:d,height:h,fill:"none",stroke:y,strokeWidth:o===a.nodeId?2.5:1}),tS("path",{d:oS[a.kind],transform:`translate(${l+10},${u+12})`,stroke:y,fill:"none",strokeWidth:1.4}),tS("text",{x:g+5,y:u+16,textAnchor:"middle",fontSize:110>d?9:11,fontWeight:600,fill:n},a.semantics.label),tS("text",{x:g,y:u+28,textAnchor:"middle",fontSize:8,fill:n},rS[a.kind]),tS("text",{x:g,y:u+41,textAnchor:"middle",fontSize:110>d?7:9,fill:n},x),tS("text",{x:g,y:u+h-13,textAnchor:"middle",fontSize:8,fill:n},"Queue "+nS(f.queued)),null!==f.queued?tS("rect",{...p,width:p.width*f.queued/c,fill:y,"data-circuit-gauge":"queue"}):null,tS("rect",{...e.sensor,fill:i,"data-circuit-sensor":a.nodeId}),a.semantics.dependencyNodeIds?.length?tS("text",{x:g,y:u-8,fontSize:8,textAnchor:"middle",fill:n,"data-circuit-dependency":a.nodeId},"Requires "+a.semantics.dependencyNodeIds.join(", ")):null)})}function Ws(e,t,i,n,o,r){const{history:s}=e,a=e.modules.find(e=>e.module.nodeId===r)?.module,c="records"===t.unit?"queued":"attempts",l=t.entries.map(e=>a?e.nodes[a.nodeId]["records"===t.unit?"queued":"arrivals"]:e.totals[c]),u=Math.max(1,...l.map(e=>e??0)),d=t.entries[0].at,h=t.entries[t.entries.length-1].at,p=e=>s.x+(e-d)/Math.max(1,h-d)*s.width;let f="",y=!1;for(const[e,i]of t.entries.entries()){if(null===l[e]){y=!1;continue}const t=s.y+s.height-l[e]/u*s.height;f+=`${y?" H":"M"}${p(i.at)}${y?" V"+t:","+t}`,y=!0}return tS("g",{"data-circuit-history":c,"data-history-module":a?.nodeId},tS("text",{x:s.x,y:s.y-9,fill:o,fontSize:10},a?`${a.semantics.label} · ${"queued"===c?"queued "+a.semantics.unit:`offered ${a.semantics.unit}/s`} · aggregate observations`:"queued"===c?"Queued records · aggregate observations":"Offered attempts/s · aggregate observations"),tS("path",{d:f,fill:"none",stroke:n,strokeWidth:2}),tS("line",{x1:p(i.observedAt),x2:p(i.observedAt),y1:s.y,y2:s.y+s.height,stroke:o,strokeDasharray:"3 3","data-circuit-cursor":i.observedAt}),...t.entries.map(e=>tS("text",{key:e.id,x:p(e.at),y:s.y+s.height+14,textAnchor:"middle",fontSize:9,fill:o},e.at+"s")))}function Ys(e,t,i,n){return{id:n.nodeId,nodeId:n.nodeId,kind:"circuit-module",moduleKind:n.kind,label:n.semantics.label,unit:n.semantics.unit,sourceRevision:t.sourceRevision,analysisRevision:e.atlas.analysisRevision,relationScopeId:"directed-admitted",editionId:t.id,editionKind:t.kind,synthetic:t.synthetic,mode:i.mode,observedAt:i.observedAt,...i.entry.nodes[n.nodeId]}}function qs(e,t,i,n){return[...t.modules.map(t=>{const o=Ys(e,i,n,t.module);return{id:o.id,bodyId:o.id,datum:o,x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height,shape:"rect",label:`${o.label}: ${o.moduleKind}`,description:`${o.label}. ${i.kind} at ${n.observedAt}s. Arrivals ${sS(o.arrivals)} ${o.unit}/s; completions ${sS(o.completions)} ${o.unit}/s; installed capacity ${sS(o.capacity)} ${o.unit}/s; queue ${sS(o.queued)} ${o.unit}. Measurement status: ${o.status}. Individual timings unavailable.`,group:"circuit modules"}}),...t.routes.map(t=>{const o=n.entry.flows.find(e=>e.edgeId===t.edgeId),r=t.points[Math.floor(t.points.length/2)];return{id:"pipe:"+t.edgeId,x:r.x,y:r.y,shape:"path",pathData:t.pathD,label:`${t.source} → ${t.target}: ${sS(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${n.observedAt}s; transferred volume ${sS(o.perSecond)} ${o.unit}/s.`,group:"original pipes",datum:{id:t.edgeId,kind:"circuit-pipe",source:t.source,target:t.target,analysisRevision:e.atlas.analysisRevision,sourceRevision:i.sourceRevision,relationScopeId:"directed-admitted",editionId:i.id,editionKind:i.kind,observedAt:n.observedAt,...o}}})]}function Xs(e,t,i,n){return{frameType:e.frameType,layout:{...e.layout,primarySize:{width:i[0],height:i[1]},...n&&{margin:n}},buildProps:(i,n,o,r,s)=>{const[a,c]=r.size,l=t({...s,...r,width:a,height:c,colorScheme:o});return e.buildProps(l.data,n,o,{...r,title:l.title,description:l.description,summary:l.summary,accessibleTable:l.accessibleTable},{...s,...l})}}}function Gs(e,t,i){const n="function"==typeof t?t(e):e[(t??i)+""];if(null==n||"string"==typeof n&&""===n.trim())return null;const o=Number(n);return Number.isFinite(o)?o:null}function Vs({data:e,safeData:t,areaBy:i,lineDataAccessor:n}){if(null==e)return[];const o=void 0!==t[0]?.[n];if(!o&&!i)return t;let r;if(o)r=t;else{const e=t.reduce((e,t)=>{const o="function"==typeof i?i(t):t[i],r=o+"";if(!e[r]){const t={[n]:[]};"string"==typeof i&&(t[i]=o),e[r]=t}return e[r][n].push(t),e},{});r=Object.values(e)}return r.flatMap(e=>{const t=Array.isArray(e[n])?e[n]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}function Hs(e){if(!e)return fS;let t=!1;for(let i=0;e.length>i;i++){const n=e[i];if(null==n||"object"!=typeof n){t=!0;break}}if(!t)return e;const i=[];for(const t of e)null!=t&&"object"==typeof t&&i.push(t);return i}function Us(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Ks(e,t){if(!Us(t))return e??((...e)=>({}));const i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function Zs(e){const{lineWidth:t=2,colorBy:i,colorScale:n,color:o,resolveStroke:r,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,u)=>{const d={strokeWidth:t},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let p;return r?p=r(e,u):i?n&&(p=Nn(e,i,n)):p=o||nA,void 0!==p&&(d.stroke=p,h&&(d.fill=p,d.fillOpacity=a)),c?.length&&Object.assign(d,lt(e,c,l?l(e,u):{value:void 0,category:u})),d}}function Qs(e,t,i,n){if(!e.length)return[];const o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),r=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>r.push(e),p=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;o.length>e;e++){const r=o[e],f=t(r),y=i(r),g=n(r);if(!Number.isFinite(f)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const i=y-c.a-(g-c.b);if(0!==i){const n=Math.max(0,Math.min(1,(c.b-c.a)/i));e=c.x+n*(f-c.x),t=c.a+n*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)p(l[e],a)}else for(const e of l)p(e,a);l=[],h({__x:f,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:f,a:y,b:g,w:m}}else{a=m;for(const e of l)p(e,a);l=[],h({__x:f,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:f,a:y,b:g,w:m}}else l.push({x:f,y:y,datum:r})}for(const e of l)p(e,a??"A");return r}function Js(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;const t=(e.__diffSegment??"")+"";return"line-A"===t||t.endsWith("-A")?"A":"B"}function ea(e,t){return ut(e,t,e=>{const t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:Js(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function ta(e){const{seriesAColor:t,seriesBColor:i,areaOpacity:n,styleRules:o}=e;return ea(e=>({fill:"A"===Js(e)?t:i,stroke:"none",fillOpacity:n}),o)}function ia(e){const{seriesAColor:t,seriesBColor:i,lineWidth:n,styleRules:o}=e;return ea(e=>({stroke:"A"===Js(e)?t:i,strokeWidth:n,fill:"none"}),o)}function na(e,t=yS){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function oa(e){return e?na(e):void 0}function ra(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}function sa(e){const t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;const i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}function aa(e){if(!e)return;const t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}function ca(e,t,i){return"function"==typeof e?e(i):i[e||t]}function la(e){return e instanceof Date?e.getTime():Number(e)}function ua(e,t){return Bk(1===t?.5:e/(t-1))}function da(e){const t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function ha(e,t){const i=aa(t),n=Array.isArray(e)?e:void 0;return i?[i,...n??[]]:n}function pa(e,t){if(!Array.isArray(e))return{data:e,orderMap:/* @__PURE__ */new WeakMap};const i=t.xAccessor||"x",n=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:la(ca(t.orderAccessor,"order",e))-la(ca(t.orderAccessor,"order",i))):e,r=/* @__PURE__ */new WeakMap;let s=0;for(const e of o){if(null==e||"object"!=typeof e)continue;const t=la(ca(i,"x",e)),o=la(ca(n,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&s++}let a=0;for(const e of o){if(null==e||"object"!=typeof e)continue;const t=la(ca(i,"x",e)),o=la(ca(n,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&r.set(e,{idx:a++,total:s})}return{data:o,orderMap:r}}function fa(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function ya(e,t,i,n=!1){const o=m({axes:t,showAxes:i});return{...M(e,t,n),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function ga(e,t,i="x",n="y"){const o="function"==typeof i?i:e=>e[i],r="function"==typeof n?n:e=>e[n],s="function"==typeof t.colorBy?t.colorBy:e=>e[t.colorBy],a=/* @__PURE__ */new Map;for(const i of e){const e=s(i)??(i.parentLine&&s(i.parentLine));if(null==e||e+""=="")continue;const n=e+"",r=a.get(n);r&&!("end"===t.position?Number(o(i))>Number(o(r)):Number(o(i))<Number(o(r)))||a.set(n,i)}return[...a].map(([e,s])=>({type:"text",label:e,["string"==typeof i?i:"x"]:o(s),["string"==typeof n?n:"y"]:r(s),x:o(s),y:r(s),_directLabel:{id:e,position:t.position},color:t.color(e),fontSize:t.fontSize}))}function ma(e=[]){const t=e.filter(e=>e._directLabel);return t.length?` Series endpoints: ${t.map(e=>`${e.label}: x ${e.x+""}, y ${e.y+""}`).join("; ")}.`:""}function xa(e,t=.5){const i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;const n=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),r=Math.round(parseInt(i[3],16)*(1-t));return`#${n.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function ba(e,t=.5){const i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;const n=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),r=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${n.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function va(e){const t=10**gS;return Math.round(e*t)/t}function wa(e,t){const i=e,n=e.length-1,o=[t];for(let e=0;n>e;e++){let t=e;for(let o=e+1;n>o;o++)Math.abs(i[e][o])>Math.abs(i[e][t])&&(t=o);for(let o=e;n+1>o;o++){const n=i[o][e];i[o][e]=i[o][t],i[o][t]=n}for(let t=e+1;n>t;t++)for(let o=n;o>=e;o--)i[o][t]-=i[o][e]*i[e][t]/i[e][e]}for(let e=n-1;e>=0;e--){let t=0;for(let r=e+1;n>r;r++)t+=i[r][e]*o[r];o[e]=(i[n][e]-t)/i[e][e]}return o}function ka(e){const t=[0,0,0,0];let i=0;for(const[n,o]of e)null!==o&&(i++,t[0]+=n,t[1]+=o,t[2]+=n*n,t[3]+=n*o);const n=i*t[2]-t[0]*t[0],o=0===n?0:va((i*t[3]-t[0]*t[1])/n),r=va(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[va(e),va(o*e+r)]),equation:[o,r]}}function Aa(e,t=2){const i=[],n=[],o=t+1;for(let t=0;o>t;t++){let r=0;for(const[i,n]of e)null!==n&&(r+=i**t*n);i.push(r);const s=[];for(let i=0;o>i;i++){let n=0;for(const[o,r]of e)null!==r&&(n+=o**(t+i));s.push(n)}n.push(s)}n.push(i);const r=wa(n,o).map(va);return{points:e.map(([e])=>[va(e),va(r.reduce((t,i,n)=>t+i*e**n,0))]),equation:[...r].reverse()}}function Sa(e){const t=e.length;let i=0,n=0,o=0,r=0;for(const[t,s]of e)i+=t,n+=s,o+=t*t,r+=t*s;const s=t*o-i*i;if(1e-12>Math.abs(s))return null;const a=(t*r-i*n)/s,c=(n-a*i)/t;return e=>c+a*e}function Ma(e,t){const i=e.length,n=e.map(([e,i])=>i-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(n/Math.max(i-2,1)),r=e.reduce((e,t)=>e+t[0],0)/i,s=e.reduce((e,t)=>e+(t[0]-r)**2,0);return{se:o,meanX:r,ssX:s}}function _a(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function $a(e,t,i,n){const o=t.uncertaintyOpacity,r=t.confidenceAccessor;if(!o&&!r)return;const s="object"==typeof o?o:{},a=s.min??.15,c=s.max??1;if(r){const t="function"==typeof r?r:e=>e[r];for(const i of e){const e=t(i);null!=e&&Number.isFinite(e)&&(i[xS]=a+Math.max(0,Math.min(1,e))*(c-a))}return}const l=e.map(e=>{const t=i(e),o=n(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=l.filter(e=>Number.isFinite(e));if(0===u.length)return;const[d,h]=_s(u),p=h-d;e.forEach((e,t)=>{const i=l[t];Number.isFinite(i)&&(e[xS]=c-(p>0?(i-d)/p:0)*(c-a))})}function Pa(e,t){return"function"==typeof t?t(e):!!e[t]}function ja(e,t,i,n,o){const{isTraining:r,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:p=6,label:f}=n,y=e.map(e=>{let t="observed";return s&&Pa(e,s)?t="forecast":r&&Pa(e,r)&&(t="training"),{...e,[mS]:t}}),g=n._groupBy,m=[];if(g){const e=/* @__PURE__ */new Map;for(const t of y){const i=t[g]??"__default";e.has(i)||e.set(i,[]),e.get(i).push(t)}const t=[];for(const[,i]of e)for(let e=0;i.length-1>e;e++)i[e][mS]!==i[e+1][mS]&&(t.push({...i[e+1],[mS]:i[e][mS]}),t.push({...i[e],[mS]:i[e+1][mS]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][mS]!==y[e+1][mS]&&(m.push({...y[e+1],[mS]:y[e][mS]}),m.push({...y[e],[mS]:y[e+1][mS]}));if(n.trainUnderline){const e=[];for(const t of m)"training"===t[mS]&&e.push({...t,[mS]:"training-base"});m.unshift(...e)}const x=[];if(c&&l){const e="string"==typeof c?c:"__envUpper",t="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const i of m)"function"==typeof c&&(i[e]=c(i)),"function"==typeof l&&(i[t]=l(i));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:f})}if(n.uncertaintyOpacity||n.confidenceAccessor){const e=c?"function"==typeof c?c:e=>e[c]:()=>{},t=l?"function"==typeof l?l:e=>e[l]:()=>{};$a(m.filter(e=>"forecast"===e[mS]),n,e,t)}if(a){const e=n.anomalyStyle,t={type:"highlight",filter:e=>Pa(e,a)};e?(t.style=e,t.r=p):"function"==typeof h?(t.style=e=>{const t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=p):(t.color=h,t.r=p,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(t)}return o&&x.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label}),{processedData:m,annotations:x}}function Ia(e,t,i,n,o){const{trainEnd:r,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=n;if(null==r)return{processedData:e,annotations:[]};const d=[],h=[];for(const i of e)i[t]>r?h.push({...i,[mS]:"observed"}):d.push({...i,[mS]:"training"});const p=d.map(e=>[e[t],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),f=[],y=[];if(p.length>=3){const o=p.length,r=Sa(p);if(r){const{se:d,meanX:h,ssX:g}=Ma(p,r),m=_a(a),x=Ps(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),b=p.length>1?(p[o-1][0]-p[0][0])/(o-1):1;for(let e=1;s>=e;e++){const n=x+e*b,s=r(n),a=d*Math.sqrt(1+1/o+(g>0?(n-h)**2/g:0))*m;y.push({[t]:n,[i]:s,[mS]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}$a(y,n,e=>e.__forecastUpper,e=>e.__forecastLower),f.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}f.push({type:"x-threshold",x:r,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&f.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label});const g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[mS]:"observed"}),g.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[mS]:"forecast"}),g.push(...y)}return{processedData:g,annotations:f}}function La(e,t,i,n,o){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?ja(e,0,0,n,o):Ia(e,t,i,n,o);var r}function Ra(e,t){const i=t.trainDasharray??"8,4",n=t.forecastDasharray??"4,4",o=t.color||"#6366f1",r=t.trainOpacity,s=t.forecastOpacity,a=t.trainStroke,c=t.trainLinecap,l=t.trainUnderline;return t=>{const u=e(t),d=t[mS];if("training"===d){let e=u.stroke;return"darken"===a?e=xa(u.stroke||"#666",.5):a&&(e=a),{...u,stroke:e,strokeDasharray:i,...c&&{strokeLinecap:c},...null!=r&&{strokeOpacity:r}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===l&&(e=ba(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[xS],i=null!=e?e:s;return{...u,stroke:o,strokeDasharray:n,...null!=i&&{strokeOpacity:i}}}return u}}function Ca(e,t,i){const n="function"==typeof t,o="function"==typeof i,r=n?bS:t,s=o?vS:i;return n||o?{xKey:r,yKey:s,rows:e.map(e=>{const r={...e};return n&&(r[bS]=t(e)),o&&(r[vS]=i(e)),r})}:{rows:e,xKey:r,yKey:s}}function Ta(e,t,i){const n=e[t],o=e[i];return null==n||null==o||Number.isNaN(n)||Number.isNaN(o)}function Oa(e,t,i,n,o){const r=/* @__PURE__ */new Map;for(const t of e){const e=o?(t[o]??"")+"":"__single";r.has(e)||r.set(e,[]),r.get(e).push(t)}if("interpolate"===t){const e=[];for(const[,t]of r)for(const o of t)Ta(o,i,n)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){const e=[];for(const[,t]of r)for(const o of t)Ta(o,i,n)?e.push({...o,[n]:0}):e.push(o);return{rows:e,groupKey:o}}const s=[],a="_gapSegment";for(const[e,t]of r){let o=0,r=[];const c=()=>{if(0===r.length)return;const t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(const e of r)s.push({...e,[a]:t});r=[],o++};for(const e of t)Ta(e,i,n)?c():r.push(e);c()}return{rows:s,groupKey:a}}function Ea(e,t,i){const n=i.upperBounds,o=i.lowerBounds;if(!n&&!o)return;const r="function"==typeof n?n:"string"==typeof n?e=>e[n]:null,s="function"==typeof o?o:"string"==typeof o?e=>e[o]:null;let a=1/0,c=-1/0;for(const i of e){const e=Number(i[t]);if(Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e)),r){const e=r(i);null!=e&&Number.isFinite(e)&&(e>c&&(c=e),a>e&&(a=e))}if(s){const e=s(i);null!=e&&Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}function Fa(e,t,i,n,o,r,s,a){if(!t||!i)return{annotations:[]};const c="object"==typeof t?t:{},l=c.position||"end",u=c.fontSize||11,d="function"==typeof i?i:e=>e[i],h=Dn(e.map(e=>({__lbl:(d(e)??"")+""})),"__lbl",r??s),p=ga(e,{position:l,fontSize:u,colorBy:i,color:e=>h?h(e):a||nA},n,o),f=p.reduce((e,t)=>Math.max(e,Array.from(t.label+"").length*(.65*u)),0)+10;return{annotations:p,marginExtra:"end"===l?{right:f}:{left:f}}}function Na(e){const t=e.xAccessor||"x",i=e.yAccessor||"y",n=e.lineBy,o=e.colorBy||n;let r=Array.isArray(e.data)?Hs(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=Ca(r,t,i);r=s.rows;const a=s.xKey,c=s.yKey,l=Array.isArray(e.annotations)?[...e.annotations]:[];let u,d="string"==typeof n||"function"==typeof n?n:void 0,h=e.baseLineStyle;if(e.forecast){const t=La(r,a,c,n&&"string"==typeof n&&"object"==typeof e.forecast?{...e.forecast,_groupBy:n}:e.forecast,e.anomaly);if(r=t.processedData,l.push(...t.annotations),u=Ea(r,c,e.forecast),n&&"string"==typeof n?(r=r.map(e=>({...e,[wS]:`${e[n]}__${e[mS]||"observed"}`})),d=wS):d=mS,e.baseLineStyle){const t=Ra(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&l.push(...(p=e.anomaly,[{type:"anomaly-band",threshold:p.threshold??2,showBand:!1!==p.showBand,fill:p.bandColor||"#6366f1",fillOpacity:p.bandOpacity??.1,anomalyColor:p.anomalyColor||"#ef4444",anomalyRadius:p.anomalyRadius??6,label:p.label}]));var p;if(e.gapStrategy){if("function"==typeof d){const e=d;r=r.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}const t=Oa(r,e.gapStrategy,a,c,"string"==typeof d?d:void 0);r=t.rows,t.groupKey&&(d=t.groupKey)}let f;if(e.directLabel){const t=Fa(r,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,a,c,e.colorScheme,e.themeCategorical,e.color);l.push(...t.annotations),f=t.marginExtra}return{data:r,xAccessor:"function"==typeof t?a:t,yAccessor:"function"==typeof i?c:i,groupAccessor:d,colorAccessor:o,annotations:l,lineStyle:h,yExtent:u,marginExtra:f}}function za(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=zr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrScatterColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrScatterColorBy:t(e)})):r,u=t?Dn(l,c,a):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],p=d?r.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],f=p.length?_s(p):void 0,y=ot(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?Nn(e,t,u):"string"==typeof o.color?o.color:nA,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Wn(e,d,h,f):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,lt(e,g,y(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function Da(e,t){if(!t)return[];const i=/* @__PURE__ */new Set,n=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e=("function"==typeof t?t(o):o[t])+"";i.has(e)||(i.add(e),n.push(e))}return n}function Ba(e,t,i,n){if(!i.categoryAccessor)return;const o=Da(e,i.categoryAccessor),r=i.colors,s="explicit-then-alpha"===n?[...Object.keys(r??{}).filter(e=>o.includes(e)),...o.filter(e=>!Object.hasOwn(r??{},e)).sort()]:o,a=zr(t.theme).colors.categorical,c=a?.length?a:oA;return Object.fromEntries(s.map((e,t)=>[e,r&&zn(r,e)||i.fill||c[t%c.length]]))}function Wa(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=zr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrBubbleColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrBubbleColorBy:t(e)})):r,u=t?Dn(l,c,a):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],p=d?r.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],f=p.length?_s(p):void 0,y=ot(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?Nn(e,t,u):"string"==typeof o.color?o.color:nA,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Wn(e,d,h,f):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,lt(e,g,y(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function Ya(e,t){return t?.length?(Object.defineProperty(e,SS,{configurable:!0,enumerable:!1,value:t}),e):e}function qa(e){return e?.[SS]}function Xa(e){return e.parentLine?Ya({...e.parentLine,...e},qa(e)):e}function Ga(e){return Ya({...e[0]},e.map(Xa))}function Va(e){return!!e&&qa(e)?.[0]===e}function Ha(e){const t={"--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background};e.colors.categorical.forEach((e,i)=>{t["--semiotic-category-"+(i+1)]=e}),e.colors.focus&&(t["--semiotic-focus"]=e.colors.focus),e.colors.selection&&(t["--semiotic-selection-color"]=e.colors.selection),null!=e.colors.selectionOpacity&&(t["--semiotic-selection-opacity"]=e.colors.selectionOpacity+""),e.colors.diverging&&(t["--semiotic-diverging"]=e.colors.diverging),e.colors.annotation&&(t["--semiotic-annotation-color"]=e.colors.annotation),e.colors.success&&(t["--semiotic-success"]=e.colors.success),e.colors.danger&&(t["--semiotic-danger"]=e.colors.danger),e.colors.warning&&(t["--semiotic-warning"]=e.colors.warning),e.colors.error&&(t["--semiotic-error"]=e.colors.error),e.colors.info&&(t["--semiotic-info"]=e.colors.info),e.tooltip?.background&&(t["--semiotic-tooltip-bg"]=e.tooltip.background),e.tooltip?.text&&(t["--semiotic-tooltip-text"]=e.tooltip.text),e.tooltip?.borderRadius&&(t["--semiotic-tooltip-radius"]=e.tooltip.borderRadius),e.tooltip?.fontSize&&(t["--semiotic-tooltip-font-size"]=e.tooltip.fontSize),e.tooltip?.shadow&&(t["--semiotic-tooltip-shadow"]=e.tooltip.shadow),e.borderRadius&&(t["--semiotic-border-radius"]=e.borderRadius);const i=e.typography.legendSize??e.typography.labelSize;null!=i&&(t["--semiotic-legend-font-size"]=i+"px"),null!=e.typography.legendFontFamily&&(t["--semiotic-legend-font-family"]=e.typography.legendFontFamily),null!=e.typography.legendFontWeight&&(t["--semiotic-legend-font-weight"]=e.typography.legendFontWeight+"");const n=e.typography.titleFontSize??e.typography.titleSize;return null!=n&&(t["--semiotic-title-font-size"]=n+"px"),null!=e.typography.titleFontFamily&&(t["--semiotic-title-font-family"]=e.typography.titleFontFamily),null!=e.typography.titleFontWeight&&(t["--semiotic-title-font-weight"]=e.typography.titleFontWeight+""),null!=e.typography.tickFontFamily&&(t["--semiotic-tick-font-family"]=e.typography.tickFontFamily),null!=e.typography.tickSize&&(t["--semiotic-tick-font-size"]=e.typography.tickSize+"px"),null!=e.typography.labelSize&&(t["--semiotic-axis-label-font-size"]=e.typography.labelSize+"px"),t}function Ua(e,t,i,n,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){const e=zn(i,n);if(e)return e}let r;if(Array.isArray(i))r=i;else if(t&&t.length>0)r=t;else if("string"==typeof i){const e=tA[i];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=n?(o.has(n)||o.set(n,o.size),r[o.get(n)%r.length]):r[0]:nA}function Ka(e,t,i){return"function"==typeof e?e(t,i):t[e]}function Za(e,t){if(!e?.length)return;const i=new Map(t.map((e,t)=>[We(e),t]));return e.map(e=>{const t={...e},n=n=>{if(!(n in e))return;const o=i.get(We(e[n]));void 0!==o&&(t[n]=o)};return n("x"),n("x0"),n("x1"),"string"!=typeof e.type||"x-threshold"!==e.type&&"x"!==e.type||n("value"),t})}function Qa(e){const{seriesOrder:t,overallOrder:i,highlightTop:n,color:o,colorScheme:r,neutralColor:s,themeCategorical:a,themeNeutral:c}=e;if(null==n&&null==o)return r;const l=new Set(i.slice(0,null==n?i.length:Math.max(0,Math.floor(n)))),u=/* @__PURE__ */new Map,d={};for(const e of t)Object.defineProperty(d,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(l.has(e)?Ua(void 0,a,r,e,u):s??c??"#b8bec8")});return d}function Ja(e,t={}){const i=t.xAccessor??"x",n=t.yAccessor??"y",o=t.lineBy??"series",r=t.rankDirection??"descending",s=[],a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,l=[],u=/* @__PURE__ */new Map;let d=1/0,h=-1/0;e.forEach((e,t)=>{const r=Ka(i,e,t),p=We(r);let f=a.get(p);null==f&&(f=s.length,a.set(p,f),s.push(r),c.set(f,[]));const y=Ka(o,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(Ka(n,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),c.get(f)?.push({datum:e,inputIndex:t,series:y,value:g}))});const p=[],f=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map;for(let e=0;s.length>e;e++){const t=c.get(e)??[];t.sort((e,t)=>("descending"===r?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{const n=i+1;p.push({datum:t.datum,xIndex:e,xValue:s[e],series:t.series,value:t.value,rank:n}),f.set(t.series,(f.get(t.series)??0)+n),y.set(t.series,(y.get(t.series)??0)+1)})}const g=l.length+1,m=[...l].sort((e,t)=>{const i=y.get(e)??0,n=y.get(t)??0;return((f.get(e)??0)+(s.length-i)*g)/Math.max(1,s.length)-((f.get(t)??0)+(s.length-n)*g)/Math.max(1,s.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:p.map(e=>{const t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:s,seriesOrder:l,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}function ec(){const e=(iw??(iw=MS.createContext(null)),iw);return MS.useContext(e)??_S}function tc(e,t,i,n,o){const r=1-o;return r*r*r*e+3*r*r*o*t+3*r*o*o*i+o*o*o*n}function ic(e,t,i,n,o){const r=1-o;return 3*r*r*(t-e)+6*r*o*(i-t)+3*o*o*(n-i)}function nc(e,t,i,n,o){const r=[],s=(e.x+t.x)/2;for(let a=0;o>=a;a++){const c=a/o;let l,u,d,h;"linear"===n?(l=e.x+(t.x-e.x)*c,u=e.y+(t.y-e.y)*c,d=t.x-e.x,h=t.y-e.y):(l=tc(e.x,s,s,t.x,c),u=tc(e.y,e.y,t.y,t.y,c),d=ic(e.x,s,s,t.x,c),h=ic(e.y,e.y,t.y,t.y,c)),r.push({x:l,y:u,dx:d,dy:h,radius:e.radius+(t.radius-e.radius)*c,datumIndex:.5>c?i:i+1})}return r}function oc(e,t={}){const i=[],n=[],o=[];if(2>e.length)return{topPath:i,bottomPath:n,datumIndices:o};const r=t.curve??"smooth",s=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){const a=nc(e[t],e[t+1],t,r,s);for(let e=0===t?0:1;a.length>e;e++){const t=a[e],r=Math.hypot(t.dx,t.dy)||1,s=-t.dy/r,c=t.dx/r,l=Math.max(0,t.radius);i.push([t.x+s*l,t.y+c*l]),n.push([t.x-s*l,t.y-c*l]),o.push(t.datumIndex)}}return{topPath:i,bottomPath:n,datumIndices:o}}function rc(e,t,i,n){const o=Math.max(1,Math.floor(t/18)),r="auto"===i?Number.isFinite(n)&&(n??0)>=0?Math.min(o,Math.floor(n)):o:1/0,s=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>(t.candidate.priority??0)-(e.candidate.priority??0)||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index),a=[];for(const{candidate:e}of s){if(a.length>=r)break;a.some(t=>t.side===e.side&&14>Math.abs(t.y-e.y))||a.push(e)}return new Set(a.map(e=>e.id))}function sc({datum:e,x:t,y:i,side:n,color:o,highlighted:r,labelStyle:s}){const a=ec(),c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;/* @__PURE__ */ /* @__PURE__ */
|
|
181
|
-
return(0,$S.jsx)("text",{className:"semiotic-bump-label",x:t+("end"===n?8:-8),y:i,dy:"0.35em",textAnchor:"end"===n?"start":"end",fill:o,fillOpacity:c?.16:1,fontWeight:r?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...l},children:e.__bumpSeries})}function ac(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function cc(e,t,i){const[n,o]=t,[r,s]=i;return o===n?(r+s)/2:r+(s-r)*Math.max(0,Math.min(1,(e-n)/(o-n)))}function lc(e){const t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function uc(e){const t=e.config,i=/* @__PURE__ */new Map;for(const t of e.data){const e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}const n=t.seriesOrder.filter(e=>i.has(e)).sort((e,n)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(n)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(n)),o=[],r=[],s=[];for(const r of n){const n=(i.get(r)??[]).sort((e,t)=>e.x-t.x);if(2>n.length)continue;const a=n[0].__bumpHighlighted,c=(t.colorMap&&
|
|
180
|
+
/* @__PURE__ */(0,TA.jsx)("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function us(e){return e.map(e=>({...e,spawnAt:void 0}))}function ds(e,t){return e?t?i=>nk.createElement(nk.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function hs(e,t,i){const n=t[i];return"boolean"==typeof n?n:!0!==e.__compactMode}function ps(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return EA[(t>>>0)%EA.length]}function fs(e,t,i,n){const o=e.datum,r={stroke:n.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:n.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:n.opacity??.96};if(!o?.__crucible)return{...r,fill:n.color??"#b8792d"};if("product"===o.kind){const e=t.products[o.semanticId];return{...r,fill:n.color??e?.color??ps(e?.id??o.semanticId)}}const s=t.components[o.semanticId];if(!s)return{...r,fill:n.color??"#356b63"};let a;return a="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:"function"==typeof i?(i(s.datum)??"unassigned")+"":(s.datum[i+""]??"unassigned")+"",{...r,fill:n.color??ps(a)}}function ys(e,t){const i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}function gs(e){return e?{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}:e}function ms(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function xs(e,t={}){const i=new Set(t.templates??["repeated-state-episode"]),n=e.filter(e=>i.has(e.template)).map(e=>({id:"capsule:"+e.id,matchId:e.id,template:e.template,entryState:"string"==typeof e.roles.state?e.roles.state:e.nodePath[0],exitState:e.nodePath[e.nodePath.length-1],entityCount:e.entityCount,occurrenceIds:ms(e),selected:!1})).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),o=/* @__PURE__ */new Set;for(const e of n)if(!e.occurrenceIds.some(e=>o.has(e))){e.selected=!0;for(const t of e.occurrenceIds)o.add(t)}return n}function bs(e,t=[],i){const n=void 0===i?void 0:new Set("string"==typeof i?[i]:i),o=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&n?.has(e.partition)),r=new Set(o.map(e=>e.id)),s=new Set(o.map(e=>e.entityId)),a=/* @__PURE__ */new Map;let c=0;for(const t of e){if(void 0!==i&&"string"==typeof t.roles.occurrence&&!r.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===i&&(c+=t.entityCount);for(const[t,n]of e)(void 0===i||s.has(t))&&a.set(t,n)}return[...a.values()].reduce((e,t)=>e+t,c)}function vs(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function ws(e,t,i){return e.entries.find(e=>e.measureId===t&&e.subjectId===i)}function ks(e){const t=e.spec.comparison;if(!t)return;const i=t.partitions.map(i=>{const n=ws(e.ledger,t.denominatorMeasureId,i)?.value??0,o={};return o["repeated-state-episode"]=bs(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,i),{partition:i,assigned:n,motifUsers:o,outcomes:{purchases:ws(e.ledger,"purchases",i)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:i}}function As(e,t){const i=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return ws(e.ledger,i,t)?.value}function Ss(e,t,i){return 0===i||1e4*e%i!=0?Math.round((t-e)/Math.max(i,1)*1e4):1e4*(t-e)/i}function Ms(e,t={}){const i=t.templates??["repeated-state-episode"],n="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],o=void 0!==t.partition?As(e,t.partition)??0:e.spec.comparison?e.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:e.ledger.entries.find(t=>"global"===t.subjectKind&&t.measureId===e.spec.motifs.denominatorRef)?.value??0,r=i=>bs(i,e.source.occurrences,t.partition??e.spec.comparison?.partitions),s=[],a=e.motifs.incompleteCandidates.length>0;for(const c of i)for(const i of n){const n=e.motifs.matches.filter(e=>e.template===c),l=r(n.filter(e=>e.completionSectionId===i)),u=r(n.filter(e=>e.intersectSectionIds.includes(i)));s.push({template:c,sectionId:i,partition:t.partition,completionCount:l,intersectionCount:u,denominator:o,status:a?"incomplete":"exact"})}return{templates:i,sections:n,cells:s}}function _s(e){return e.entityCount??1}function $s(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:_s(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:vs(e.nodePath,e.nodePath.length-1)}}function Ps(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:Ms(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const i=(e.source.occurrences??[]).map($s).filter(e=>!!e),n=/* @__PURE__ */new Map;for(const e of i){const i=t.order.indexOf(e.signature),o=n.get(e.signature),r=-1===i?t.order.length:i;(null==o||o>r)&&n.set(e.signature,r)}const o=[...new Set(i.map(e=>e.signature))].sort((e,t)=>{const i=(n.get(e)??0)-(n.get(t)??0);return 0!==i?i:e.localeCompare(t)}),r=[];for(const e of i)for(let t=0;e.nodePath.length-1>t;t++){const i=vs(e.nodePath,t),n=vs(e.nodePath,t+1);r.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:i,toPrefixId:n,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const s=xs(e.motifs.matches),a=e.comparison??ks(e),c=[];if(a&&a.partitions.length>=2){const e=a.rows[0],t=a.rows[1],i=Math.min(e.assigned,t.assigned)||e.assigned,n=e.motifUsers["repeated-state-episode"]??0,o=t.motifUsers["repeated-state-episode"]??0;c.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:n,rightCount:o,deltaCount:o-n,deltaBps:Ss(n,o,i),denominator:i}),c.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:Ss(e.outcomes.purchases??0,t.outcomes.purchases??0,i),denominator:i})}const l={nodes:i.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:r.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:i,signatureOrder:o,ribbons:r,capsules:s,profile:Ms(e),differences:c,prefixForest:t,sceneSeeds:l}}function js(e,t){if(0===t||2>e.length)return e.map(e=>({...e}));const i=(e,t)=>{const i=t.x-e.x,n=t.y-e.y,o=Math.hypot(i,n)||1;return{x:-n/o,y:i/o}};return e.map((n,o)=>{const r=o>0?i(e[o-1],n):null,s=e.length-1>o?i(n,e[o+1]):null;if(!r||!s){const e=s??r??{x:0,y:0};return{x:n.x+e.x*t,y:n.y+e.y*t}}let a=r.x+s.x,c=r.y+s.y;const l=Math.hypot(a,c);if(.001>l)return{x:n.x+s.x*t,y:n.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(.001>Math.abs(u))return{x:n.x+s.x*t,y:n.y+s.y*t};const d=4*Math.abs(t),h=Math.max(-d,Math.min(d,t/u));return{x:n.x+a*h,y:n.y+c*h}})}function Is(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const i=Math.max(0,t);let n=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){const o=e[t-1],r=e[t],s=e[t+1],a=Math.hypot(r.x-o.x,r.y-o.y),c=Math.hypot(s.x-r.x,s.y-r.y),l=Math.min(i,a/2,c/2);if(.001>=l){n+=` L${r.x},${r.y}`;continue}const u={x:r.x+(o.x-r.x)/a*l,y:r.y+(o.y-r.y)/a*l},d={x:r.x+(s.x-r.x)/c*l,y:r.y+(s.y-r.y)/c*l};n+=` L${u.x},${u.y} Q${r.x},${r.y} ${d.x},${d.y}`}const o=e[e.length-1];return`${n} L${o.x},${o.y}`}function Ls(e){const t=[e[0]];for(let i=1;e.length-1>i;i++){const n=e[i-1],o=e[i],r=e[i+1],s=VA(n,o),a=VA(o,r),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=GA(o,n,c/s),u=GA(o,r,c/a);t.push(l);for(let e=1;12>=e;e++){const i=e/12;t.push(GA(GA(l,o,i),GA(o,u,i),i))}}return t.push(e[e.length-1]),t.filter((e,i)=>0===i||VA(t[i-1],e)>1e-8)}function Rs(e,t,i){if(2>e.length)return"";const n=Ls(e);if(2>n.length)return"";const o=[0];for(let e=1;n.length>e;e++)o.push(o[e-1]+VA(n[e-1],n[e]));const r=o[o.length-1],s=js(n,1),a=[1,-1].map(e=>n.map((n,a)=>GA(n,s[a],e*(t+(i-t)*o[a]/r)/2)));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function Cs(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const i=t+e/2;return t+=e+3,i})}function Ts(e){let t="";return e.split(">").map((e,i)=>t=i?`${t}>${e}`:e)}function Os(e){const t=/* @__PURE__ */new Map;for(const i of e){const e=Ts(i.signature);i.nodePath.forEach((n,o)=>{const r=e[o];let s=t.get(r);s||(s={id:r,state:n,depth:o+1,signatures:/* @__PURE__ */new Set},t.set(r,s)),s.signatures.add(i.signature)})}return[...t.values()]}function Es(e,t){const i=/* @__PURE__ */new Set,n=[t];for(;n.length;){const t=n.pop();if(i.has(t))continue;i.add(t);const o=e.children[t];Array.isArray(o)&&n.push(...o)}return i}function Fs(e,t){const i=[],n=e.requiredChildren[t],o=Array.isArray(n)?[...n]:[];for(;o.length;){const t=o.pop();i.push(t),o.push(...e.requiredChildren[t])}return i.sort()}function Ns(e,t,i){if(!Number.isFinite(t)||!Number.isFinite(i)||360>t||300>i)throw Error("Circuit geometry needs at least 360 × 300 pixels");const n=[...e.atlas.sections.sectionIds];e.atlas.source.nodes.some(e=>!e.sectionId)&&n.push("Unsectioned");const o=kn({width:t,height:i-110,padX:22,padY:70,stages:n.map(e=>({id:e})),shape:"lane"}),r=new Map(e.atlas.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),s=o.stages.flatMap(t=>{const n=e.order.filter(e=>r.get(e)===t.id),o=(i-235)/Math.max(1,n.length);if(n.length&&78>o)throw Error("Increase circuit height to keep every module readable");return n.map((i,n)=>{const r=e.modules.find(e=>e.nodeId===i),s=Math.max(68,Math.min(142,t.width-56)),a=Math.min(68,o-10),c=t.x-s/2,l=95+(n+.5)*o-a/2;return{module:r,x:c,y:l,width:s,height:a,queue:{x:c+8,y:l+a-8,width:s-16,height:4},sensor:{x:c+s-5,y:l+a/2-4,width:8,height:8}}})}),a=new Map(s.map(e=>[e.module.nodeId,e])),c=new Set(e.residualEdgeIds);let l=0;const u=e.atlas.source.edges.map(e=>{const t=a.get(e.source),i=a.get(e.target),o=i.x>t.x,s=i.x===t.x,u=(t,i)=>{const n=t.module.ports.filter(e=>e.direction===i),o=n.findIndex(t=>t.edgeId===e.id);return t.y+10+(o+.5)*(t.height-20)/n.length},d={x:t.x+(o||s?t.width:0),y:u(t,"out")},h={x:i.x+(o?0:i.width),y:u(i,"in")};let p;if(s){const i=d.x+18+5*l++;p=e.source===e.target?[d,{x:i,y:d.y},{x:i,y:t.y-15},{x:h.x-8,y:t.y-15},{x:h.x-8,y:t.y}]:[d,{x:i,y:d.y},{x:i,y:h.y},h]}else if(!o||Math.abs(n.indexOf(r.get(e.source))-n.indexOf(r.get(e.target)))>1){const e=o?1:-1,t=62+7*l++;p=[d,{x:d.x+16*e,y:d.y},{x:d.x+16*e,y:t},{x:h.x-16*e,y:t},{x:h.x-16*e,y:h.y},h]}else{const e=(d.x+h.x)/2;p=[d,{x:e,y:d.y},{x:e,y:h.y},h]}return{edgeId:e.id,source:e.source,target:e.target,residual:c.has(e.id),points:p,pathD:os(p)}});return{width:t,height:i,modules:s,routes:u,sections:o.stages.map(e=>({id:e.id,x:e.x})),history:{x:42,y:i-88,width:t-84,height:46}}}function zs(e,t){const i=e.slice(1).map((t,i)=>Math.hypot(t.x-e[i].x,t.y-e[i].y)),n=i.reduce((e,t)=>e+t,0);let o=Math.max(0,Math.min(1,t))*n;for(let t=0;i.length>t;t++){if(i[t]>=o){const n=i[t]?o/i[t]:0;return{x:e[t].x+(e[t+1].x-e[t].x)*n,y:e[t].y+(e[t+1].y-e[t].y)*n}}o-=i[t]}return e[e.length-1]}function Ds(e,t={}){return{observed:t.observed??e.info??e.primary??"#387e98",modeled:t.modeled??e.secondary??"#946344",residual:t.residual??e.warning??"#a56537",muted:t.muted??e.textSecondary??iS.muted,alarm:t.alarm??e.danger??iS.alarm}}function Bs(e,t,i,n,o,r=iS,s){const a=Object.values(t.entry.nodes).map(e=>e.queued??0),c=Math.max(1,...a);return e.modules.map(e=>{const{module:a,x:l,y:u,width:d,height:h,queue:p}=e,f=t.entry.nodes[a.nodeId],y=o===a.nodeId?i:(f.queued??0)>0?r.alarm:r.muted,g=l+d/2,m="records"===a.semantics.unit?"rec":"attempts"===a.semantics.unit?"att":"roots",x=null!==f.capacity?`${nS(f.completions)} / ${nS(f.capacity)} ${m}/s`:null!==f.completions?`${nS(f.completions)} ${m}/s complete`:`${nS(f.arrivals)} ${m}/s offered`;return tS("g",{key:a.id,"data-circuit-module":a.nodeId,"data-module-kind":a.kind,opacity:s?.(a.nodeId),"data-queued":f.queued??"unmeasured"},tS("rect",{x:l,y:u,width:d,height:h,fill:"none",stroke:y,strokeWidth:o===a.nodeId?2.5:1}),tS("path",{d:oS[a.kind],transform:`translate(${l+10},${u+12})`,stroke:y,fill:"none",strokeWidth:1.4}),tS("text",{x:g+5,y:u+16,textAnchor:"middle",fontSize:110>d?9:11,fontWeight:600,fill:n},a.semantics.label),tS("text",{x:g,y:u+28,textAnchor:"middle",fontSize:8,fill:n},rS[a.kind]),tS("text",{x:g,y:u+41,textAnchor:"middle",fontSize:110>d?7:9,fill:n},x),tS("text",{x:g,y:u+h-13,textAnchor:"middle",fontSize:8,fill:n},"Queue "+nS(f.queued)),null!==f.queued?tS("rect",{...p,width:p.width*f.queued/c,fill:y,"data-circuit-gauge":"queue"}):null,tS("rect",{...e.sensor,fill:i,"data-circuit-sensor":a.nodeId}),a.semantics.dependencyNodeIds?.length?tS("text",{x:g,y:u-8,fontSize:8,textAnchor:"middle",fill:n,"data-circuit-dependency":a.nodeId},"Requires "+a.semantics.dependencyNodeIds.join(", ")):null)})}function Ws(e,t,i,n,o,r){const{history:s}=e,a=e.modules.find(e=>e.module.nodeId===r)?.module,c="records"===t.unit?"queued":"attempts",l=t.entries.map(e=>a?e.nodes[a.nodeId]["records"===t.unit?"queued":"arrivals"]:e.totals[c]),u=Math.max(1,...l.map(e=>e??0)),d=t.entries[0].at,h=t.entries[t.entries.length-1].at,p=e=>s.x+(e-d)/Math.max(1,h-d)*s.width;let f="",y=!1;for(const[e,i]of t.entries.entries()){if(null===l[e]){y=!1;continue}const t=s.y+s.height-l[e]/u*s.height;f+=`${y?" H":"M"}${p(i.at)}${y?" V"+t:","+t}`,y=!0}return tS("g",{"data-circuit-history":c,"data-history-module":a?.nodeId},tS("text",{x:s.x,y:s.y-9,fill:o,fontSize:10},a?`${a.semantics.label} · ${"queued"===c?"queued "+a.semantics.unit:`offered ${a.semantics.unit}/s`} · aggregate observations`:"queued"===c?"Queued records · aggregate observations":"Offered attempts/s · aggregate observations"),tS("path",{d:f,fill:"none",stroke:n,strokeWidth:2}),tS("line",{x1:p(i.observedAt),x2:p(i.observedAt),y1:s.y,y2:s.y+s.height,stroke:o,strokeDasharray:"3 3","data-circuit-cursor":i.observedAt}),...t.entries.map(e=>tS("text",{key:e.id,x:p(e.at),y:s.y+s.height+14,textAnchor:"middle",fontSize:9,fill:o},e.at+"s")))}function Ys(e,t,i,n){return{id:n.nodeId,nodeId:n.nodeId,kind:"circuit-module",moduleKind:n.kind,label:n.semantics.label,unit:n.semantics.unit,sourceRevision:t.sourceRevision,analysisRevision:e.atlas.analysisRevision,relationScopeId:"directed-admitted",editionId:t.id,editionKind:t.kind,synthetic:t.synthetic,mode:i.mode,observedAt:i.observedAt,...i.entry.nodes[n.nodeId]}}function qs(e,t,i,n){return[...t.modules.map(t=>{const o=Ys(e,i,n,t.module);return{id:o.id,bodyId:o.id,datum:o,x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height,shape:"rect",label:`${o.label}: ${o.moduleKind}`,description:`${o.label}. ${i.kind} at ${n.observedAt}s. Arrivals ${sS(o.arrivals)} ${o.unit}/s; completions ${sS(o.completions)} ${o.unit}/s; installed capacity ${sS(o.capacity)} ${o.unit}/s; queue ${sS(o.queued)} ${o.unit}. Measurement status: ${o.status}. Individual timings unavailable.`,group:"circuit modules"}}),...t.routes.map(t=>{const o=n.entry.flows.find(e=>e.edgeId===t.edgeId),r=t.points[Math.floor(t.points.length/2)];return{id:"pipe:"+t.edgeId,x:r.x,y:r.y,shape:"path",pathData:t.pathD,label:`${t.source} → ${t.target}: ${sS(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${n.observedAt}s; transferred volume ${sS(o.perSecond)} ${o.unit}/s.`,group:"original pipes",datum:{id:t.edgeId,kind:"circuit-pipe",source:t.source,target:t.target,analysisRevision:e.atlas.analysisRevision,sourceRevision:i.sourceRevision,relationScopeId:"directed-admitted",editionId:i.id,editionKind:i.kind,observedAt:n.observedAt,...o}}})]}function Xs(e,t,i,n){return{frameType:e.frameType,layout:{...e.layout,primarySize:{width:i[0],height:i[1]},...n&&{margin:n}},buildProps:(i,n,o,r,s)=>{const[a,c]=r.size,l=t({...s,...r,width:a,height:c,colorScheme:o});return e.buildProps(l.data,n,o,{...r,title:l.title,description:l.description,summary:l.summary,accessibleTable:l.accessibleTable},{...s,...l})}}}function Gs(e,t,i){const n="function"==typeof t?t(e):e[(t??i)+""];if(null==n||"string"==typeof n&&""===n.trim())return null;const o=Number(n);return Number.isFinite(o)?o:null}function Vs({data:e,safeData:t,areaBy:i,lineDataAccessor:n}){if(null==e)return[];const o=void 0!==t[0]?.[n];if(!o&&!i)return t;let r;if(o)r=t;else{const e=t.reduce((e,t)=>{const o="function"==typeof i?i(t):t[i],r=o+"";if(!e[r]){const t={[n]:[]};"string"==typeof i&&(t[i]=o),e[r]=t}return e[r][n].push(t),e},{});r=Object.values(e)}return r.flatMap(e=>{const t=Array.isArray(e[n])?e[n]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}function Hs(e){if(!e)return fS;let t=!1;for(let i=0;e.length>i;i++){const n=e[i];if(null==n||"object"!=typeof n){t=!0;break}}if(!t)return e;const i=[];for(const t of e)null!=t&&"object"==typeof t&&i.push(t);return i}function Us(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Ks(e,t){if(!Us(t))return e??((...e)=>({}));const i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function Zs(e){const{lineWidth:t=2,colorBy:i,colorScale:n,color:o,resolveStroke:r,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,u)=>{const d={strokeWidth:t},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let p;return r?p=r(e,u):i?n&&(p=Bn(e,i,n)):p=o||nA,void 0!==p&&(d.stroke=p,h&&(d.fill=p,d.fillOpacity=a)),c?.length&&Object.assign(d,lt(e,c,l?l(e,u):{value:void 0,category:u})),d}}function Qs(e,t,i,n){if(!e.length)return[];const o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),r=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>r.push(e),p=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;o.length>e;e++){const r=o[e],f=t(r),y=i(r),g=n(r);if(!Number.isFinite(f)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const i=y-c.a-(g-c.b);if(0!==i){const n=Math.max(0,Math.min(1,(c.b-c.a)/i));e=c.x+n*(f-c.x),t=c.a+n*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)p(l[e],a)}else for(const e of l)p(e,a);l=[],h({__x:f,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:f,a:y,b:g,w:m}}else{a=m;for(const e of l)p(e,a);l=[],h({__x:f,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:r}),c={x:f,a:y,b:g,w:m}}else l.push({x:f,y:y,datum:r})}for(const e of l)p(e,a??"A");return r}function Js(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;const t=(e.__diffSegment??"")+"";return"line-A"===t||t.endsWith("-A")?"A":"B"}function ea(e,t){return ut(e,t,e=>{const t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:Js(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function ta(e){const{seriesAColor:t,seriesBColor:i,areaOpacity:n,styleRules:o}=e;return ea(e=>({fill:"A"===Js(e)?t:i,stroke:"none",fillOpacity:n}),o)}function ia(e){const{seriesAColor:t,seriesBColor:i,lineWidth:n,styleRules:o}=e;return ea(e=>({stroke:"A"===Js(e)?t:i,strokeWidth:n,fill:"none"}),o)}function na(e,t=yS){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function oa(e){return e?na(e):void 0}function ra(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}function sa(e){const t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;const i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}function aa(e){if(!e)return;const t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}function ca(e,t,i){return"function"==typeof e?e(i):i[e||t]}function la(e){return e instanceof Date?e.getTime():Number(e)}function ua(e,t){return Bk(1===t?.5:e/(t-1))}function da(e){const t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function ha(e,t){const i=aa(t),n=Array.isArray(e)?e:void 0;return i?[i,...n??[]]:n}function pa(e,t){if(!Array.isArray(e))return{data:e,orderMap:/* @__PURE__ */new WeakMap};const i=t.xAccessor||"x",n=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:la(ca(t.orderAccessor,"order",e))-la(ca(t.orderAccessor,"order",i))):e,r=/* @__PURE__ */new WeakMap;let s=0;for(const e of o){if(null==e||"object"!=typeof e)continue;const t=la(ca(i,"x",e)),o=la(ca(n,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&s++}let a=0;for(const e of o){if(null==e||"object"!=typeof e)continue;const t=la(ca(i,"x",e)),o=la(ca(n,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&r.set(e,{idx:a++,total:s})}return{data:o,orderMap:r}}function fa(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function ya(e,t,i,n=!1){const o=m({axes:t,showAxes:i});return{...M(e,t,n),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function ga(e,t,i="x",n="y"){const o="function"==typeof i?i:e=>e[i],r="function"==typeof n?n:e=>e[n],s="function"==typeof t.colorBy?t.colorBy:e=>e[t.colorBy],a=/* @__PURE__ */new Map;for(const i of e){const e=s(i)??(i.parentLine&&s(i.parentLine));if(null==e||e+""=="")continue;const n=e+"",r=a.get(n);r&&!("end"===t.position?Number(o(i))>Number(o(r)):Number(o(i))<Number(o(r)))||a.set(n,i)}return[...a].map(([e,s])=>({type:"text",label:e,["string"==typeof i?i:"x"]:o(s),["string"==typeof n?n:"y"]:r(s),x:o(s),y:r(s),_directLabel:{id:e,position:t.position},color:t.color(e),fontSize:t.fontSize}))}function ma(e=[]){const t=e.filter(e=>e._directLabel);return t.length?` Series endpoints: ${t.map(e=>`${e.label}: x ${e.x+""}, y ${e.y+""}`).join("; ")}.`:""}function xa(e,t=.5){const i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;const n=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),r=Math.round(parseInt(i[3],16)*(1-t));return`#${n.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function ba(e,t=.5){const i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;const n=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),r=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${n.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function va(e){const t=10**gS;return Math.round(e*t)/t}function wa(e,t){const i=e,n=e.length-1,o=[t];for(let e=0;n>e;e++){let t=e;for(let o=e+1;n>o;o++)Math.abs(i[e][o])>Math.abs(i[e][t])&&(t=o);for(let o=e;n+1>o;o++){const n=i[o][e];i[o][e]=i[o][t],i[o][t]=n}for(let t=e+1;n>t;t++)for(let o=n;o>=e;o--)i[o][t]-=i[o][e]*i[e][t]/i[e][e]}for(let e=n-1;e>=0;e--){let t=0;for(let r=e+1;n>r;r++)t+=i[r][e]*o[r];o[e]=(i[n][e]-t)/i[e][e]}return o}function ka(e){const t=[0,0,0,0];let i=0;for(const[n,o]of e)null!==o&&(i++,t[0]+=n,t[1]+=o,t[2]+=n*n,t[3]+=n*o);const n=i*t[2]-t[0]*t[0],o=0===n?0:va((i*t[3]-t[0]*t[1])/n),r=va(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[va(e),va(o*e+r)]),equation:[o,r]}}function Aa(e,t=2){const i=[],n=[],o=t+1;for(let t=0;o>t;t++){let r=0;for(const[i,n]of e)null!==n&&(r+=i**t*n);i.push(r);const s=[];for(let i=0;o>i;i++){let n=0;for(const[o,r]of e)null!==r&&(n+=o**(t+i));s.push(n)}n.push(s)}n.push(i);const r=wa(n,o).map(va);return{points:e.map(([e])=>[va(e),va(r.reduce((t,i,n)=>t+i*e**n,0))]),equation:[...r].reverse()}}function Sa(e){const t=e.length;let i=0,n=0,o=0,r=0;for(const[t,s]of e)i+=t,n+=s,o+=t*t,r+=t*s;const s=t*o-i*i;if(1e-12>Math.abs(s))return null;const a=(t*r-i*n)/s,c=(n-a*i)/t;return e=>c+a*e}function Ma(e,t){const i=e.length,n=e.map(([e,i])=>i-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(n/Math.max(i-2,1)),r=e.reduce((e,t)=>e+t[0],0)/i,s=e.reduce((e,t)=>e+(t[0]-r)**2,0);return{se:o,meanX:r,ssX:s}}function _a(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function $a(e,t,i,n){const o=t.uncertaintyOpacity,r=t.confidenceAccessor;if(!o&&!r)return;const s="object"==typeof o?o:{},a=s.min??.15,c=s.max??1;if(r){const t="function"==typeof r?r:e=>e[r];for(const i of e){const e=t(i);null!=e&&Number.isFinite(e)&&(i[xS]=a+Math.max(0,Math.min(1,e))*(c-a))}return}const l=e.map(e=>{const t=i(e),o=n(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=l.filter(e=>Number.isFinite(e));if(0===u.length)return;const[d,h]=Mt(u),p=h-d;e.forEach((e,t)=>{const i=l[t];Number.isFinite(i)&&(e[xS]=c-(p>0?(i-d)/p:0)*(c-a))})}function Pa(e,t){return"function"==typeof t?t(e):!!e[t]}function ja(e,t,i,n,o){const{isTraining:r,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:p=6,label:f}=n,y=e.map(e=>{let t="observed";return s&&Pa(e,s)?t="forecast":r&&Pa(e,r)&&(t="training"),{...e,[mS]:t}}),g=n._groupBy,m=[];if(g){const e=/* @__PURE__ */new Map;for(const t of y){const i=t[g]??"__default";e.has(i)||e.set(i,[]),e.get(i).push(t)}const t=[];for(const[,i]of e)for(let e=0;i.length-1>e;e++)i[e][mS]!==i[e+1][mS]&&(t.push({...i[e+1],[mS]:i[e][mS]}),t.push({...i[e],[mS]:i[e+1][mS]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][mS]!==y[e+1][mS]&&(m.push({...y[e+1],[mS]:y[e][mS]}),m.push({...y[e],[mS]:y[e+1][mS]}));if(n.trainUnderline){const e=[];for(const t of m)"training"===t[mS]&&e.push({...t,[mS]:"training-base"});m.unshift(...e)}const x=[];if(c&&l){const e="string"==typeof c?c:"__envUpper",t="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const i of m)"function"==typeof c&&(i[e]=c(i)),"function"==typeof l&&(i[t]=l(i));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:f})}if(n.uncertaintyOpacity||n.confidenceAccessor){const e=c?"function"==typeof c?c:e=>e[c]:()=>{},t=l?"function"==typeof l?l:e=>e[l]:()=>{};$a(m.filter(e=>"forecast"===e[mS]),n,e,t)}if(a){const e=n.anomalyStyle,t={type:"highlight",filter:e=>Pa(e,a)};e?(t.style=e,t.r=p):"function"==typeof h?(t.style=e=>{const t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=p):(t.color=h,t.r=p,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(t)}return o&&x.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label}),{processedData:m,annotations:x}}function Ia(e,t,i,n,o){const{trainEnd:r,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=n;if(null==r)return{processedData:e,annotations:[]};const d=[],h=[];for(const i of e)i[t]>r?h.push({...i,[mS]:"observed"}):d.push({...i,[mS]:"training"});const p=d.map(e=>[e[t],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),f=[],y=[];if(p.length>=3){const o=p.length,r=Sa(p);if(r){const{se:d,meanX:h,ssX:g}=Ma(p,r),m=_a(a),x=$t(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),b=p.length>1?(p[o-1][0]-p[0][0])/(o-1):1;for(let e=1;s>=e;e++){const n=x+e*b,s=r(n),a=d*Math.sqrt(1+1/o+(g>0?(n-h)**2/g:0))*m;y.push({[t]:n,[i]:s,[mS]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}$a(y,n,e=>e.__forecastUpper,e=>e.__forecastLower),f.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}f.push({type:"x-threshold",x:r,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&f.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label});const g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[mS]:"observed"}),g.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[mS]:"forecast"}),g.push(...y)}return{processedData:g,annotations:f}}function La(e,t,i,n,o){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?ja(e,0,0,n,o):Ia(e,t,i,n,o);var r}function Ra(e,t){const i=t.trainDasharray??"8,4",n=t.forecastDasharray??"4,4",o=t.color||"#6366f1",r=t.trainOpacity,s=t.forecastOpacity,a=t.trainStroke,c=t.trainLinecap,l=t.trainUnderline;return t=>{const u=e(t),d=t[mS];if("training"===d){let e=u.stroke;return"darken"===a?e=xa(u.stroke||"#666",.5):a&&(e=a),{...u,stroke:e,strokeDasharray:i,...c&&{strokeLinecap:c},...null!=r&&{strokeOpacity:r}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===l&&(e=ba(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[xS],i=null!=e?e:s;return{...u,stroke:o,strokeDasharray:n,...null!=i&&{strokeOpacity:i}}}return u}}function Ca(e,t,i){const n="function"==typeof t,o="function"==typeof i,r=n?bS:t,s=o?vS:i;return n||o?{xKey:r,yKey:s,rows:e.map(e=>{const r={...e};return n&&(r[bS]=t(e)),o&&(r[vS]=i(e)),r})}:{rows:e,xKey:r,yKey:s}}function Ta(e,t,i){const n=e[t],o=e[i];return null==n||null==o||Number.isNaN(n)||Number.isNaN(o)}function Oa(e,t,i,n,o){const r=/* @__PURE__ */new Map;for(const t of e){const e=o?(t[o]??"")+"":"__single";r.has(e)||r.set(e,[]),r.get(e).push(t)}if("interpolate"===t){const e=[];for(const[,t]of r)for(const o of t)Ta(o,i,n)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){const e=[];for(const[,t]of r)for(const o of t)Ta(o,i,n)?e.push({...o,[n]:0}):e.push(o);return{rows:e,groupKey:o}}const s=[],a="_gapSegment";for(const[e,t]of r){let o=0,r=[];const c=()=>{if(0===r.length)return;const t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(const e of r)s.push({...e,[a]:t});r=[],o++};for(const e of t)Ta(e,i,n)?c():r.push(e);c()}return{rows:s,groupKey:a}}function Ea(e,t,i){const n=i.upperBounds,o=i.lowerBounds;if(!n&&!o)return;const r="function"==typeof n?n:"string"==typeof n?e=>e[n]:null,s="function"==typeof o?o:"string"==typeof o?e=>e[o]:null;let a=1/0,c=-1/0;for(const i of e){const e=Number(i[t]);if(Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e)),r){const e=r(i);null!=e&&Number.isFinite(e)&&(e>c&&(c=e),a>e&&(a=e))}if(s){const e=s(i);null!=e&&Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}function Fa(e,t,i,n,o,r,s,a){if(!t||!i)return{annotations:[]};const c="object"==typeof t?t:{},l=c.position||"end",u=c.fontSize||11,d="function"==typeof i?i:e=>e[i],h=Yn(e.map(e=>({__lbl:(d(e)??"")+""})),"__lbl",r??s),p=ga(e,{position:l,fontSize:u,colorBy:i,color:e=>h?h(e):a||nA},n,o),f=p.reduce((e,t)=>Math.max(e,Array.from(t.label+"").length*(.65*u)),0)+10;return{annotations:p,marginExtra:"end"===l?{right:f}:{left:f}}}function Na(e){const t=e.xAccessor||"x",i=e.yAccessor||"y",n=e.lineBy,o=e.colorBy||n;let r=Array.isArray(e.data)?Hs(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=Ca(r,t,i);r=s.rows;const a=s.xKey,c=s.yKey,l=Array.isArray(e.annotations)?[...e.annotations]:[];let u,d="string"==typeof n||"function"==typeof n?n:void 0,h=e.baseLineStyle;if(e.forecast){const t=La(r,a,c,n&&"string"==typeof n&&"object"==typeof e.forecast?{...e.forecast,_groupBy:n}:e.forecast,e.anomaly);if(r=t.processedData,l.push(...t.annotations),u=Ea(r,c,e.forecast),n&&"string"==typeof n?(r=r.map(e=>({...e,[wS]:`${e[n]}__${e[mS]||"observed"}`})),d=wS):d=mS,e.baseLineStyle){const t=Ra(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&l.push(...(p=e.anomaly,[{type:"anomaly-band",threshold:p.threshold??2,showBand:!1!==p.showBand,fill:p.bandColor||"#6366f1",fillOpacity:p.bandOpacity??.1,anomalyColor:p.anomalyColor||"#ef4444",anomalyRadius:p.anomalyRadius??6,label:p.label}]));var p;if(e.gapStrategy){if("function"==typeof d){const e=d;r=r.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}const t=Oa(r,e.gapStrategy,a,c,"string"==typeof d?d:void 0);r=t.rows,t.groupKey&&(d=t.groupKey)}let f;if(e.directLabel){const t=Fa(r,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,a,c,e.colorScheme,e.themeCategorical,e.color);l.push(...t.annotations),f=t.marginExtra}return{data:r,xAccessor:"function"==typeof t?a:t,yAccessor:"function"==typeof i?c:i,groupAccessor:d,colorAccessor:o,annotations:l,lineStyle:h,yExtent:u,marginExtra:f}}function za(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Wr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrScatterColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrScatterColorBy:t(e)})):r,u=t?Yn(l,c,a):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],p=d?r.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],f=p.length?Mt(p):void 0,y=ot(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?Bn(e,t,u):"string"==typeof o.color?o.color:nA,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Xn(e,d,h,f):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,lt(e,g,y(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function Da(e,t){if(!t)return[];const i=/* @__PURE__ */new Set,n=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e=("function"==typeof t?t(o):o[t])+"";i.has(e)||(i.add(e),n.push(e))}return n}function Ba(e,t,i,n){if(!i.categoryAccessor)return;const o=Da(e,i.categoryAccessor),r=i.colors,s="explicit-then-alpha"===n?[...Object.keys(r??{}).filter(e=>o.includes(e)),...o.filter(e=>!Object.hasOwn(r??{},e)).sort()]:o,a=Wr(t.theme).colors.categorical,c=a?.length?a:oA;return Object.fromEntries(s.map((e,t)=>[e,r&&Wn(r,e)||i.fill||c[t%c.length]]))}function Wa(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Wr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrBubbleColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrBubbleColorBy:t(e)})):r,u=t?Yn(l,c,a):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],p=d?r.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],f=p.length?Mt(p):void 0,y=ot(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?Bn(e,t,u):"string"==typeof o.color?o.color:nA,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Xn(e,d,h,f):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,lt(e,g,y(e))),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function Ya(e,t){return t?.length?(Object.defineProperty(e,SS,{configurable:!0,enumerable:!1,value:t}),e):e}function qa(e){return e?.[SS]}function Xa(e){return e.parentLine?Ya({...e.parentLine,...e},qa(e)):e}function Ga(e){return Ya({...e[0]},e.map(Xa))}function Va(e){return!!e&&qa(e)?.[0]===e}function Ha(e){const t={"--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background};e.colors.categorical.forEach((e,i)=>{t["--semiotic-category-"+(i+1)]=e}),e.colors.focus&&(t["--semiotic-focus"]=e.colors.focus),e.colors.selection&&(t["--semiotic-selection-color"]=e.colors.selection),null!=e.colors.selectionOpacity&&(t["--semiotic-selection-opacity"]=e.colors.selectionOpacity+""),e.colors.diverging&&(t["--semiotic-diverging"]=e.colors.diverging),e.colors.annotation&&(t["--semiotic-annotation-color"]=e.colors.annotation),e.colors.success&&(t["--semiotic-success"]=e.colors.success),e.colors.danger&&(t["--semiotic-danger"]=e.colors.danger),e.colors.warning&&(t["--semiotic-warning"]=e.colors.warning),e.colors.error&&(t["--semiotic-error"]=e.colors.error),e.colors.info&&(t["--semiotic-info"]=e.colors.info),e.tooltip?.background&&(t["--semiotic-tooltip-bg"]=e.tooltip.background),e.tooltip?.text&&(t["--semiotic-tooltip-text"]=e.tooltip.text),e.tooltip?.borderRadius&&(t["--semiotic-tooltip-radius"]=e.tooltip.borderRadius),e.tooltip?.fontSize&&(t["--semiotic-tooltip-font-size"]=e.tooltip.fontSize),e.tooltip?.shadow&&(t["--semiotic-tooltip-shadow"]=e.tooltip.shadow),e.borderRadius&&(t["--semiotic-border-radius"]=e.borderRadius);const i=e.typography.legendSize??e.typography.labelSize;null!=i&&(t["--semiotic-legend-font-size"]=i+"px"),null!=e.typography.legendFontFamily&&(t["--semiotic-legend-font-family"]=e.typography.legendFontFamily),null!=e.typography.legendFontWeight&&(t["--semiotic-legend-font-weight"]=e.typography.legendFontWeight+"");const n=e.typography.titleFontSize??e.typography.titleSize;return null!=n&&(t["--semiotic-title-font-size"]=n+"px"),null!=e.typography.titleFontFamily&&(t["--semiotic-title-font-family"]=e.typography.titleFontFamily),null!=e.typography.titleFontWeight&&(t["--semiotic-title-font-weight"]=e.typography.titleFontWeight+""),null!=e.typography.tickFontFamily&&(t["--semiotic-tick-font-family"]=e.typography.tickFontFamily),null!=e.typography.tickSize&&(t["--semiotic-tick-font-size"]=e.typography.tickSize+"px"),null!=e.typography.labelSize&&(t["--semiotic-axis-label-font-size"]=e.typography.labelSize+"px"),t}function Ua(e,t,i,n,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){const e=Wn(i,n);if(e)return e}let r;if(Array.isArray(i))r=i;else if(t&&t.length>0)r=t;else if("string"==typeof i){const e=tA[i];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=n?(o.has(n)||o.set(n,o.size),r[o.get(n)%r.length]):r[0]:nA}function Ka(e,t,i){return"function"==typeof e?e(t,i):t[e]}function Za(e,t){if(!e?.length)return;const i=new Map(t.map((e,t)=>[We(e),t]));return e.map(e=>{const t={...e},n=n=>{if(!(n in e))return;const o=i.get(We(e[n]));void 0!==o&&(t[n]=o)};return n("x"),n("x0"),n("x1"),"string"!=typeof e.type||"x-threshold"!==e.type&&"x"!==e.type||n("value"),t})}function Qa(e){const{seriesOrder:t,overallOrder:i,highlightTop:n,color:o,colorScheme:r,neutralColor:s,themeCategorical:a,themeNeutral:c}=e;if(null==n&&null==o)return r;const l=new Set(i.slice(0,null==n?i.length:Math.max(0,Math.floor(n)))),u=/* @__PURE__ */new Map,d={};for(const e of t)Object.defineProperty(d,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(l.has(e)?Ua(void 0,a,r,e,u):s??c??"#b8bec8")});return d}function Ja(e,t={}){const i=t.xAccessor??"x",n=t.yAccessor??"y",o=t.lineBy??"series",r=t.rankDirection??"descending",s=[],a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map,l=[],u=/* @__PURE__ */new Map;let d=1/0,h=-1/0;e.forEach((e,t)=>{const r=Ka(i,e,t),p=We(r);let f=a.get(p);null==f&&(f=s.length,a.set(p,f),s.push(r),c.set(f,[]));const y=Ka(o,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(Ka(n,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),c.get(f)?.push({datum:e,inputIndex:t,series:y,value:g}))});const p=[],f=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map;for(let e=0;s.length>e;e++){const t=c.get(e)??[];t.sort((e,t)=>("descending"===r?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{const n=i+1;p.push({datum:t.datum,xIndex:e,xValue:s[e],series:t.series,value:t.value,rank:n}),f.set(t.series,(f.get(t.series)??0)+n),y.set(t.series,(y.get(t.series)??0)+1)})}const g=l.length+1,m=[...l].sort((e,t)=>{const i=y.get(e)??0,n=y.get(t)??0;return((f.get(e)??0)+(s.length-i)*g)/Math.max(1,s.length)-((f.get(t)??0)+(s.length-n)*g)/Math.max(1,s.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:p.map(e=>{const t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:s,seriesOrder:l,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}function ec(){const e=(iw??(iw=MS.createContext(null)),iw);return MS.useContext(e)??_S}function tc(e,t,i,n,o){const r=1-o;return r*r*r*e+3*r*r*o*t+3*r*o*o*i+o*o*o*n}function ic(e,t,i,n,o){const r=1-o;return 3*r*r*(t-e)+6*r*o*(i-t)+3*o*o*(n-i)}function nc(e,t,i,n,o){const r=[],s=(e.x+t.x)/2;for(let a=0;o>=a;a++){const c=a/o;let l,u,d,h;"linear"===n?(l=e.x+(t.x-e.x)*c,u=e.y+(t.y-e.y)*c,d=t.x-e.x,h=t.y-e.y):(l=tc(e.x,s,s,t.x,c),u=tc(e.y,e.y,t.y,t.y,c),d=ic(e.x,s,s,t.x,c),h=ic(e.y,e.y,t.y,t.y,c)),r.push({x:l,y:u,dx:d,dy:h,radius:e.radius+(t.radius-e.radius)*c,datumIndex:.5>c?i:i+1})}return r}function oc(e,t={}){const i=[],n=[],o=[];if(2>e.length)return{topPath:i,bottomPath:n,datumIndices:o};const r=t.curve??"smooth",s=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){const a=nc(e[t],e[t+1],t,r,s);for(let e=0===t?0:1;a.length>e;e++){const t=a[e],r=Math.hypot(t.dx,t.dy)||1,s=-t.dy/r,c=t.dx/r,l=Math.max(0,t.radius);i.push([t.x+s*l,t.y+c*l]),n.push([t.x-s*l,t.y-c*l]),o.push(t.datumIndex)}}return{topPath:i,bottomPath:n,datumIndices:o}}function rc(e,t,i,n){const o=Math.max(1,Math.floor(t/18)),r="auto"===i?Number.isFinite(n)&&(n??0)>=0?Math.min(o,Math.floor(n)):o:1/0,s=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>(t.candidate.priority??0)-(e.candidate.priority??0)||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index),a=[];for(const{candidate:e}of s){if(a.length>=r)break;a.some(t=>t.side===e.side&&14>Math.abs(t.y-e.y))||a.push(e)}return new Set(a.map(e=>e.id))}function sc({datum:e,x:t,y:i,side:n,color:o,highlighted:r,labelStyle:s}){const a=ec(),c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;/* @__PURE__ */ /* @__PURE__ */
|
|
181
|
+
return(0,$S.jsx)("text",{className:"semiotic-bump-label",x:t+("end"===n?8:-8),y:i,dy:"0.35em",textAnchor:"end"===n?"start":"end",fill:o,fillOpacity:c?.16:1,fontWeight:r?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...l},children:e.__bumpSeries})}function ac(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function cc(e,t,i){const[n,o]=t,[r,s]=i;return o===n?(r+s)/2:r+(s-r)*Math.max(0,Math.min(1,(e-n)/(o-n)))}function lc(e){const t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function uc(e){const t=e.config,i=/* @__PURE__ */new Map;for(const t of e.data){const e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}const n=t.seriesOrder.filter(e=>i.has(e)).sort((e,n)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(n)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(n)),o=[],r=[],s=[];for(const r of n){const n=(i.get(r)??[]).sort((e,t)=>e.x-t.x);if(2>n.length)continue;const a=n[0].__bumpHighlighted,c=(t.colorMap&&Wn(t.colorMap,r))??e.resolveColor(n[0].__bumpSeries,n[0]),l=t.color??(a?c:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??c),u=n.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?cc(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=oc(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:l,fillOpacity:1,opacity:a?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,lt(n[0].__bumpRaw,t.styleRules,lc(n[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(n[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(e=>n[e]),accessibleDatum:n.map(e=>e.__bumpRaw),accessibility:{label:r+" ranking trajectory",tableFields:n.map(e=>e.__bumpRaw)},group:r,interactive:!0}),t.showPoints&&n.forEach((e,i)=>{const n={fill:l,stroke:"none",opacity:a?1:.75};t.styleRules?.length&&Object.assign(n,lt(e.__bumpRaw,t.styleRules,lc(e))),t.pointStyle&&Object.assign(n,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:n.r??t.pointRadius,style:n,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${r}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${r}:${e.x}`})});const p=!0===t.showLabels?"end":t.showLabels,f=(e,i,n)=>{const o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);s.push({id:`${r}\0${n}`,datum:e,x:u[i].x,y:u[i].y,side:n,rank:e.__bumpRank,highlighted:a,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:l})};"start"!==p&&"both"!==p||f(n[0],0,"start"),"end"!==p&&"both"!==p&&"auto"!==p||f(n.at(-1),n.length-1,"end")}const a=rc(s,e.dimensions.plot.height,"auto"!==(!0===t.showLabels?"end":t.showLabels)||"auto",t.maxLabels);for(const e of s)a.has(e.id)&&r.push(
|
|
182
182
|
/* @__PURE__ */
|
|
183
|
-
/* @__PURE__ */(0,$S.jsx)(sc,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle},e.id));return{nodes:o,overlays:r.length?/* @__PURE__ */ /* @__PURE__ */(0,$S.jsx)("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(e,t)=>{const i=ac(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function dc(e,t,i){const n=
|
|
183
|
+
/* @__PURE__ */(0,$S.jsx)(sc,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle},e.id));return{nodes:o,overlays:r.length?/* @__PURE__ */ /* @__PURE__ */(0,$S.jsx)("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(e,t)=>{const i=ac(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function dc(e,t,i){const n=zn(t,i,iA),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;const i=e.label||"Series "+(t+1),r=o?.[i];return"string"==typeof r&&r.length>0?r:n[t%n.length]})}function hc(e,t){const i=nt(e),n=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:nt(e.yAccessor)}));return(e,t)=>{const o=(e[IS]??t??"")+"",r=n.find(e=>e.label===o)??n[0],s=r?.readY(e);return{value:s,x:i(e),y:s,category:o||void 0}}}function pc(e,t){const i="function"==typeof t?t:e=>Number(e[t||"y"]);let n=1/0,o=-1/0;for(const t of e){const e=i(t);"number"==typeof e&&Number.isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!Number.isFinite(n)||!Number.isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}function fc(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Wr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrLineColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrLineColorBy:t(e)})):r,u=t?Yn(l,c,a):void 0,d=ot(o.xAccessor,o.yAccessor);return Ks(Zs({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof o.color?o.color:void 0,fillArea:o.fillArea,areaOpacity:"number"==typeof o.areaOpacity?o.areaOpacity:.3,styleRules:o.styleRules,ruleContext:d}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0})}function yc(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Wr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrAreaColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrAreaColorBy:t(e)})):r,u=t?Yn(l,c,a):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,p="number"==typeof o.areaOpacity?o.areaOpacity:.7,f=nt(o.yAccessor),y=o.styleRules;return(e,i)=>{const n=t&&u?Bn(e,t,u):"string"==typeof o.color?o.color:nA,r={fill:n,fillOpacity:p,stroke:d?n:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(r,lt(e,y,{value:f(e),category:i})),void 0!==o.stroke&&(r.stroke=o.stroke),void 0!==o.strokeWidth&&(r.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(r.opacity=o.opacity),r}}function gc(e,t,i,n,o){if(!o.showPoints)return;const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Wr(n.theme).colors.categorical,a=i??n.colorScheme??s,c="string"==typeof t?t:"__ssrPointColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrPointColorBy:t(e)})):r,u=t?Yn(l,c,a):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{const i=t&&u?Bn(e,t,u):"string"==typeof o.color?o.color:nA;return{r:d,fill:i,stroke:"none"}}}function mc(e){let t=2166136261;for(let i=0;e.length>i;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2146121005),t^=t>>>15,t=Math.imul(t,2221713035),t^=t>>>16,t>>>0}function xc(e){return"p"+(Math.round(1e3*e)/10+"").replace(".","_")}function bc(e,t,i){let n=e.length;for(e.push(t);n>0;){const o=n-1>>>1;if(0>=i(e[o],t))break;e[n]=e[o],n=o}e[n]=t}function vc(e,t){const i=e[0],n=e.pop();if(e.length>0){let i=0;for(;e.length>2*i+1;){let o=2*i+1;if(e.length>o+1&&0>t(e[o+1],e[o])&&o++,0>=t(n,e[o]))break;e[i]=e[o],i=o}e[i]=n}return i}function wc(e,t){switch(t){case"distinct":return e.distinct??0;case"p50":case"p95":case"p99":return e.percentiles?.[t]??NaN;default:return e[t]??e.mean}}function kc(e,t,i,n=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=wc(e,i),r=e.stddev*n;return[o-r,o+r]}function Ac(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;HS.lastIndex=0;let i,n=0,o=0;for(;null!==(i=HS.exec(t));){const e=parseFloat(i[1]),t=VS[i[2]];if(null==t||!Number.isFinite(e))return null;n+=e*t,o+=i[0].length}return o!==t.length?null:n>0?n:null}function Sc(e){const t=e.window??"tumbling",i=Ac("session"===t?e.gap??e.size:e.size);if(null==i)return null;const n=null!=e.hop?Ac(e.hop):void 0,o=null!=e.gap?Ac(e.gap):void 0;return new GS({window:t,size:i,hop:n??void 0,gap:o??void 0,retain:e.retain,percentiles:e.percentiles,distinct:e.distinct})}function Mc(e,t){const i=t.stat??"mean",n=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[US]:(e.start+e.end)/2,[KS]:wc(e,i),[eM]:e.count,[JS]:e.partial,[tM]:e.start,[iM]:e.end},r=kc(e,n,i,o);return r&&(t[ZS]=r[0],t[QS]=r[1]),t})}function _c(e,t,i){const n=e??i;return null!=n?n:Math.max(t?.length??0,200)}function $c(e,t,i){const n=nt(e),o=nt(t),r=nt(i);return e=>{const t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?Pc(e.value):r(e),x:t?Pc(e.xCenter):n(e),y:t?Pc(e.yCenter):o(e)}}}function Pc(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function jc(e,t){const i=Array.isArray(e)?Hs(e):[],n=t.aggregate;if(!n)return i;const o=new oM(n,t.seriesAccessor);for(const e of i)o.push(e,t.timeAccessor,t.valueAccessor);return o.emit(n)}function Ic(e){const t=e.timeAccessor||"time",i=e.valueAccessor||"value";return{timeAccessor:e=>Gs(e,t,"time")??NaN,valueAccessor:e=>Gs(e,i,"value")??NaN}}function Lc(e,t,i){return{runtimeMode:"streaming",windowMode:i.windowMode??i.capacityMode??"sliding",windowSize:_c(i.windowSize,e,i.capacity),arrowOfTime:i.arrowOfTime??"right",...Ic(i),xExtent:i.timeExtent??t.xExtent,yExtent:i.valueExtent??t.yExtent,extentPadding:i.extentPadding??t.extentPadding,tickFormatTime:i.tickFormatTime,tickFormatValue:i.tickFormatValue}}function Rc(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function Cc(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(dM,t)){const i=dM[t];if(1===e)return[i(.5)];const n=[];for(let t=0;e>t;t++)n.push(i(t/(e-1)));return n}const i=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];const r=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(i[Math.min(Math.floor(e*i.length/s),i.length-1)]);r&&a.push(o);for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);return a}function Tc(e,t,i,n,o,r,s={}){const a=/* @__PURE__ */new Map,c=new Set(t);for(const s of e){const e=i(s);a.has(e)||a.set(e,/* @__PURE__ */new Map);const l=a.get(e);if(n){const e=n(s);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 i=e-1;if(0>i||i>=t.length)continue;const o=t[i];l.set(o,(l.get(o)||0)+1)}else if(o&&r){const e=o(s),t=r(s);if(!c.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,i]of a){let n=0;for(const e of t)n+=i.get(e)||0;if(0!==n)for(let o=0;t.length>o;o++){const r=t[o],a=i.get(r)||0,c={};s.category&&(c[s.category]=e),s.level&&(c[s.level]=r),s.count&&(c[s.count]=a),s.score&&(c[s.score]=o+1),l.push({...c,__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:a,__likertPct:a/n*100,__likertLevelIndex:o})}}return l}function Oc(e,t){const i=t.length,n=i%2!=0,o=Math.floor(i/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(n&&e===o){const e=t.__likertPct/2;r.push({...t,__likertLevel:hM,__likertPct:-e}),r.push({...t,__likertLevel:pM,__likertPct:e})}else r.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return r}function Ec(e,t){const i=t.length,n=i%2!=0,o=Math.floor(i/2),r=/* @__PURE__ */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=/* @__PURE__ */new Map;let r,a;for(const i of e)i.__likertLevel===hM?r=i:i.__likertLevel===pM?a=i:t.set(i.__likertLevelIndex,i);n&&r&&s.push(r);for(let e=o-1;e>=0;e--){const i=t.get(e);i&&s.push(i)}n&&a&&s.push(a);for(let e=n?o+1:o;i>e;e++){const i=t.get(e);i&&s.push(i)}}return s}function Fc({value:e,min:t,max:i,radius:n,showScaleLabels:o}){const r=Math.max(16,.3*n);/* @__PURE__ */ /* @__PURE__ */
|
|
184
184
|
return(0,yM.jsxs)("g",{textAnchor:"middle",children:[
|
|
185
185
|
/* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */(0,yM.jsx)("text",{y:0,dominantBaseline:"central",fontSize:r,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&/* @__PURE__ */ /* @__PURE__ */(0,yM.jsxs)("text",{y:.7*r+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}function Nc(e){return Math.max(0,Math.min(1,e))}function zc(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){const e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function Dc(e,t,i){const n=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(i)}`}function Bc(e,t,i){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Nc(e.offset),color:e.color??i,opacity:null==e.opacity?1:Nc(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";const o=e=>{if(1===e.opacity)return e.color;const t=zc(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===n.length)return o(n[0]);const r=Nc(t);if(n[0].offset>=r)return o(n[0]);if(r>=n[n.length-1].offset)return o(n[n.length-1]);for(let e=0;n.length-1>e;e++){const t=n[e],i=n[e+1];if(t.offset>r||r>i.offset)continue;const s=i.offset-t.offset,a=s>0?(r-t.offset)/s:0,c=zc(t.color),l=zc(i.color);if(!c||!l)return o(.5>a?t:i);const[u,d,h]=c,[p,f,y]=l,g=u+(p-u)*a,m=d+(f-d)*a,x=h+(y-h)*a,b=t.opacity+(i.opacity-t.opacity)*a;return 1===b?Dc(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return o(n[n.length-1])}function Wc(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Yc(e){const{min:t,max:i,value:n,thresholds:o,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=i-t||1,h=(Math.max(t,Math.min(i,n))-t)/d;let p=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:r||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),i>p[p.length-1].value&&p.push({value:i,color:p[p.length-1].color});const f=!!l&&l.stops.length>=2,y=[],g=/* @__PURE__ */new Map,m=[];if(f){const e=a?h:1,t=Wc("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),n=[];for(let t=0;i>t;t++)n.push(Bc(l.stops,e*(t+.5)/i,r||p[0]?.color||"#007bff"));const o=Wc("fill",0);y.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:n}}),g.set(o,{fill:n[0]||s})}}else{let e=t;for(let i=0;p.length>i;i++){const n=p[i],o=(n.value-e)/d,r=(e-t)/d,c=(n.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-r),u=a?Math.max(0,o-l):0;if(l>0){const e=Wc("fill",i);y.push({category:e,value:l,_zone:n.label||"Zone "+(i+1),_isFill:!0}),g.set(e,{fill:n.color})}if(u>0){const e=Wc("bg",i);y.push({category:e,value:u,_zone:n.label||"Zone "+(i+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=n.value}}if(c&&o&&o.length>0)for(const e of o)e.value>t&&i>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}function qc(e=240){const t=360-e,i=180+t/2,n=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:n,offsetRad:-Math.PI/2+n}}function Xc(e=240){const{sweepRad:t,offsetRad:i}=qc(e),n=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||n.push([Math.cos(e),Math.sin(e)]);const o=n.map(e=>e[0]),r=n.map(e=>e[1]),[s,a]=
|
|
187
|
-
/* @__PURE__ */new Map),p=r??nt(o.valueAccessor??"value"),f=o.styleRules,y=n.pieceStyle;return(e,i)=>{const n={fill:t&&d?
|
|
188
|
-
return Object.create(null)}function hl(e,t){return t>e?-1:e>t?1:0}function pl(e){return e.occupants.map(e=>e.id).sort(hl).join("\0")}function fl(e,t,i=0){return e.slice(0,-1).map((n,o)=>null!=n.group&&n.group===e[o+1].group?i:t)}function yl(e,t){return e.map(e=>{const i=/* @__PURE__ */new Map;for(const n of e.occupants){const e=t[n.id];if(e)for(const t of e.samples){const e=i.get(t.t)??{before:0,after:0},n=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-n),after:Math.max(e.after,t.botMass+n)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function gl(e,t,i){return sl(yl([e,t],i)).adjacentClearance[0]??0}function ml(e,t,i){if(0===e.length)return[];const{padding:n,plotH:o,valueScale:r}=i,s=i.stackValueScale??r,a=fl(e,n,i.groupPadding??0),c=[n+e[0].peak.topPeak*s];for(let i=1;e.length>i;i++)c.push(c[i-1]+t[i-1]*s+a[i-1]);const l=c[c.length-1]+e[e.length-1].peak.botPeak*s+n;if(l>o&&l>0){const e=o/l;for(let t=0;c.length>t;t++)c[t]*=e}return c}function xl(e,t){const i=(e.boundaryOffset??0)*t,n=e.value*t;if("out"===e.kind){const o=e.sideMassBefore*t;return i+("top"===e.side?n/2-o:o-n/2)}const o=e.sideMassAfter*t;return i+("top"===e.side?n/2-o:o-n/2)}function bl(e,t,i,n,o,r,s){const a=e.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=fl(e,c,s.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),p=c+e[0].peak.topPeak*u,f=l-c-e[a-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=f-p)return ml(e,o,s);let y=1===a?[(p+f)/2]:[...r];for(let e=0;12>e;e++){const e=Array(a).fill(0),o=Array(a).fill(0);for(const r of i){const i=t[r.source],s=t[r.target];if(null==i||null==s||i===s)continue;const a=n[r.source]?.localAttachments.get(r.id),c=n[r.target]?.localAttachments.get(r.id);if(!a||!c)continue;const l=r.value>0&&Number.isFinite(r.value)?r.value:1,d=xl(a,u),h=xl(c,u);e[i]+=(y[s]+h-d)*l,o[i]+=l,e[s]+=(y[i]+d-h)*l,o[s]+=l}const r=ol({desired:y.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),minGaps:h,weights:o.map(e=>Math.max(1,e)),min:p,max:f});let s=0;for(let e=0;a>e;e++)s=Math.max(s,Math.abs(r[e]-y[e]));if(y=r,.01>s)break}return y}function vl(e,t,i,n,o,r){const s=r.adjacentClearance?[...r.adjacentClearance]:sl(yl(n,i)).adjacentClearance,a=ml(n,s,r);let c="hug"===r.lanePlacement?bl(n,o,t,i,s,a,r):[...a];if("hug"===r.lanePlacement){const i=t=>{const i=dl();for(const n of e)i[n.id]=t[o[n.id]];return i};wl(i(c),t)>wl(i(a),t)+1e-6&&(c=[...a])}const l=dl();for(const t of e)l[t.id]=c[o[t.id]];let u=1/0,d=-1/0;for(const t of e){const e=l[t.id],n=i[t.id];Number.isFinite(e)&&n&&(u=Math.min(u,e-n.topPeak*r.valueScale),d=Math.max(d,e+n.botPeak*r.valueScale))}return{adjacentClearance:s,centerlines:l,slotCenter:c,stackCenter:a,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&r.plotH>0?Math.max(0,Math.min(1,(d-u)/r.plotH)):0}}function wl(e,t){let i=0;for(const n of t){const t=e[n.source],o=e[n.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(n.value>0?n.value:1))}return i}function kl(e,t){const i=e?.samples;if(!i||0===i.length||i[0].t>t)return{top:0,bot:0};let n=0,o=i.length-1,r=0;for(;o>=n;){const e=n+o>>>1;i[e].t>t?o=e-1:(r=e,n=e+1)}const s=i[r].boundaryOffset??0;return{top:i[r].topMass-s,bot:i[r].botMass+s}}function Al(e,t,i,n,o){const r=1-o;return r*r*r*e+3*r*r*o*t+3*r*o*o*i+o*o*o*n}function Sl(e,t){let i=0,n=1;for(let o=0;28>o;o++){const o=(i+n)/2;e>Al(0,t,t,1,o)?i=o:n=o}return(i+n)/2}function Ml(e,t,i){const n=t+xl(e,i),o=e.value*i/2;return[n-o,n+o]}function _l(e,t,i,n){return Math.max(0,Math.min(t,n)-Math.max(e,i))/Math.max(1e-9,t-e)}function $l(e,t,i,n,o,r,s){const{valueScale:a,domain:c,mode:l="quality"}=s,u="source"===s.ribbonLane?.85:"target"===s.ribbonLane?.15:.5;let d=0;for(const s of e){const e=n[s.source],h=n[s.target];if(null==e||null==h||2>Math.abs(e-h))continue;const p=t[s.source]?.localAttachments.get(s.id),f=t[s.target]?.localAttachments.get(s.id);if(!p||!f)continue;const y=Math.max(s.startTime,c?.[0]??-1/0),g=Math.min(s.endTime,c?.[1]??1/0);if(y>=g)continue;const[m,x]=Ml(p,o[s.source],a),[b,v]=Ml(f,o[s.target],a),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){const n=i[e];if(!n)continue;const c=[y,g];if("quality"===l)for(const e of n.occupants)for(const i of t[e.id]?.samples??[])i.t>y&&g>i.t&&c.push(i.t);const h=e=>{const i=Sl((e-y)/(g-y),u),c=Al(m,m,b,b,i),l=Al(x,x,v,v,i);let d=0;for(const i of n.occupants){if(i.id===s.source||i.id===s.target)continue;const n=r[i.id];if(null!=n?.start&&n.start>e)continue;if(null!=n?.end&&e>n.end)continue;const u=kl(t[i.id],e),h=o[i.id];d=Math.max(d,_l(c,l,h-u.top*a,h+u.bot*a))}return d},p=[...new Set(c)].sort((e,t)=>e-t);let f=0;for(let e=0;p.length-1>e;e++){const t=p[e],i=p[e+1]-t;f+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=f/(g-y)*(s.value>0?s.value:1)}}return d}function Pl(e,t,i,n,o,r,s,a,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:wl(s,i),transitOcclusion:$l(i,n,o,r,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function jl(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Il(e,t){return e.map(e=>({t:jl(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Ll(e,t,i){const n=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){const t=e.sideMassBefore*i;if("top"===e.side){const e=n-t;return[e,e+o]}const r=n+t;return[r-o,r]}const r=e.sideMassAfter*i;if("top"===e.side){const e=n-r;return[e,e+o]}const s=n+r;return[s-o,s]}function Rl(e,t,i,n,o){if(0===e.length)return null;const r=Il(e,o),s=e=>t+(r[e].boundaryOffset??0)*i,a=e=>s(e)-r[e].topMass*i,c=e=>s(e)+r[e].botMass*i;let l=`M${n(r[0].t)},${a(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${a(e)}`;l+=` L${n(r[r.length-1].t)},${c(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${c(e)}`;return l+" Z"}function Cl(e,t,i,n,o,r){const s=i.nodeData[e];if(!s||0===s.samples.length)return[];const a=i.valueScale,c=i.centerlines[e],l=Il(s.samples,o),u=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],h=n(u.t),p=n(d.t),f=e=>n(jl(e,o)),y=[],g=(e,t,i,n)=>`M${e},${t} L${i},${t} L${i},${n} L${e},${n} Z`;for(const i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){const e=s.localAttachments.get(i.id),t=r?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&t>i.systemInTime){const n=f(i.systemInTime),r=f(t),s=null!=o&&o[0]>i.systemInTime,l=s?n:n-20,u=s?Math.min(r,n+20):n,d=Math.max(h,l);if(r>d){const[t,i]=Ll(e,c,a);y.push({pathD:g(d,t,r,i),x0:l,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){const e=s.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){const t=f(i.systemOutTime),n=f(i.endTime),o=t+20,r=Math.min(p,o);if(r>n){const[i,s]=Ll(e,c,a);y.push({pathD:g(n,i,r,s),x0:t,x1:o,from:1,to:0})}}}}return y}function Tl(e,t){const i=dl(),n=dl();for(const t of e)i[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:n}}function Ol(e,t,i,n="temporal"){const o="temporal"===n?(e,t)=>e.endTime-t.endTime||hl(e.id,t.id):(e,t)=>t.value-e.value||hl(e.id,t.id),r="temporal"===n?(e,t)=>e.startTime-t.startTime||hl(e.id,t.id):(e,t)=>t.value-e.value||hl(e.id,t.id),s=/* @__PURE__ */new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const i=/* @__PURE__ */new Map;for(const n of e){const e=n[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=i.get(e);o.edges.push(n),o.total+=n.value,o.earliestStart=Math.min(o.earliestStart,n.startTime),o.latestEnd=Math.max(o.latestEnd,n.endTime)}const s=[...i.values()];s.sort("temporal"===n?(e,i)=>"target"===t?e.earliestStart-i.earliestStart||hl(e.partner,i.partner):e.latestEnd-i.latestEnd||hl(e.partner,i.partner):(e,t)=>t.total-e.total||hl(e.partner,t.partner));for(const e of s)e.edges.sort("target"===t?r:o);return s};for(const t of e){const e=i.outgoing[t.id],n=i.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const i=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=i});else if(0===e.length)a(n,"source").forEach((e,t)=>{const i=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=i});else{const t=a(n,"source"),i=a(e,"target"),o=Math.max(t.length,i.length);for(let e=0;o>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const i of t[e].edges)s.get(i.id).targetSide=n;if(i[e])for(const t of i[e].edges)s.get(t.id).sourceSide=n}}}return s}function El(e,t,i,n,o="temporal"){const r=t.incoming[e.id],s=t.outgoing[e.id],a=[];for(const e of r)a.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(const e of s)a.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});const c={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=(e,t)=>{if(!n||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const i=n.get(e.edge.id)?.target,o=n.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const i=n.get(e.edge.id)?.source,o=n.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0},u=()=>{a.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(c[e.kind]??99)-(c[t.kind]??99)||l(e,t)||hl(e.edge?.id??"",t.edge?.id??"")||hl(e.side,t.side)||e.delta-t.delta)},d=a.length?$s(a.map(e=>e.time)):null,h=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,p=null!=h?h-1:null!=d&&Number.isFinite(d)?d-1:null;u();let f=null,y=0;for(const e of a)e.time!==f&&(f=e.time,y=0),e.sequence=y++;const g=e=>({time:e.time,phase:0,sequence:e.sequence??0}),m=[];let x=0,b=0;for(const e of a)if("out"===e.kind){const t=Math.abs(e.delta);let i=t-("top"===e.side?x:b);if(i>0){const t="top"===e.side?"bot":"top",n=Math.min(i,"top"===t?x:b);if(n>0){const o=g(e);m.push({...o,delta:-n,kind:"transfer-out",side:t}),m.push({...o,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?x-=n:b-=n,"top"===e.side?x+=n:b+=n,i-=n}i>0&&null!==p&&(m.push({time:p,delta:+i,kind:"create",side:e.side}),"top"===e.side?x+=i:b+=i)}"top"===e.side?x-=t:b-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?x+=t:b+=t}a.push(...m),u();let v=0,w=0,k=0,A=0,S=0,M=0;const _=[],$=/* @__PURE__ */new Map,P=e=>{_.push({t:e,topMass:v,botMass:w,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},j=()=>{A=Math.max(A,v+w),S=Math.max(S,v-k),M=Math.max(M,w+k)};for(const e of a){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&P(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:w;$.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:w+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,j(),P(e.time)):"transfer-out"!==e.kind&&(j(),"out"!==e.kind||v+w>1e-12||(k=0),P(e.time))}const I=[];let L=0;for(;_.length>L;){let e=L;for(;_.length>e+1&&_[e+1].t===_[L].t;)e++;I.push(_[L]);for(let t=L+1;e>=t;t++){const e=I[I.length-1];_[t].topMass===e.topMass&&_[t].botMass===e.botMass&&(_[t].boundaryOffset??0)===(e.boundaryOffset??0)||I.push(_[t])}L=e+1}const R=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let C=null;for(const e of s)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let T=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===T||e.systemOutTime>T)&&(T=e.systemOutTime);if(I.length>0){const e=I[I.length-1],t=Math.max(null!=R?R:-1/0,null!=T?T:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const i=I[0],n=I.find(e=>e.topMass+e.botMass>0);let o,r=1/0;null!=h&&Number.isFinite(h)&&i.t>h&&i.topMass+i.botMass>0&&(r=h,o=i),n&&null!=C&&Number.isFinite(C)&&n.t>C&&r>C&&(r=C,o=n),o&&Number.isFinite(r)&&I.unshift({t:r,topMass:o.topMass,botMass:o.botMass,...null!=o.boundaryOffset&&{boundaryOffset:o.boundaryOffset}})}let O=I;if("max"===o&&null!=h&&null!=R&&R>h){let e,t=0;for(const i of I){const n=i.topMass+i.botMass;n>t&&(t=n,e=i)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};O=[...I.filter(e=>h>e.t),{t:h,...t},{t:R,...t},...I.filter(e=>e.t>R)]}}return{samples:O,peak:A,topPeak:S,botPeak:M,localAttachments:$}}function Fl(e,t,i,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=t[r.source]?.localAttachments.get(r.id),s=t[r.target]?.localAttachments.get(r.id),a=i[r.source],c=i[r.target];if(!(e&&s&&Number.isFinite(a)&&Number.isFinite(c)))continue;const l=Ll(e,a,n),u=Ll(s,c,n);o.set(r.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return o}function Nl(e,t){const i=(e,i)=>{for(const n of e){const e=/* @__PURE__ */new Map;for(const o of n){const n=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,r="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,s=e.get(n);if(null!=s&&s!==r)return!0;e.set(n,r)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}function zl(e,t,i){const n=/* @__PURE__ */new Map,o=[];for(const t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||hl(e.edge.id,t.edge.id));const r=e=>{let t=n.get(e);return t||(t={top:0,bot:0},n.set(e,t)),t},s=(e,t,i)=>{const n="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;const r=i-o;r>0&&(e[n]=Math.max(0,e[n]-r))};for(const e of o){const{edge:n}=e;if("in"===e.kind){const e=t.get(n.id)?.targetSide??"bot";r(n.target)[e]+=n.value;continue}const o=r(n.source),a=t.get(n.id);let c=a.sourceSide??"bot";if(i[n.source]===i[n.target]){const e=o.top>=n.value,t=o.bot>=n.value;e!==t?c=e?"top":"bot":e||t||o.top===o.bot||(c=o.top>o.bot?"top":"bot"),a.sourceSide=c,a.targetSide=c}s(o,c,n.value)}}function Dl(e,t,i,n){for(const o of e){const e=t.incoming[o.id],r=t.outgoing[o.id];if(0===e.length||0===r.length)continue;const s=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===i.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of r)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},a=(e,t)=>{const o=s(),a="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,c="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=a||0>=c)return!1;const l=Math.min(a,c),u=r.filter(t=>!n.has(t.id)&&i.get(t.id).sourceSide===e&&l>=t.value).sort((e,t)=>t.value-e.value||hl(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)};let c=r.length+1;for(;c-- >0&&(a("top","bot")||a("bot","top")););}}function Bl(e){const t=dl();return e.forEach((e,i)=>{for(const n of e.occupants)t[n.id]=i}),t}function Wl(e,t,i){e.splice(0,e.length,...i);const n=Bl(i);for(const e of Object.keys(t))delete t[e];Object.assign(t,n)}function Yl(e){const t=/* @__PURE__ */new Map,i=[];e.forEach((e,n)=>{if(!e.group)return void i.push({anchor:n,stableId:pl(e),slots:[e]});const o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(n),o.slots.push(e),t.set(e.group,o)});for(const[e,n]of t)i.push({anchor:n.indexes.reduce((e,t)=>e+t,0)/n.indexes.length,stableId:`${e}\0${n.slots.map(pl).join("\0")}`,slots:n.slots});return i.sort((e,t)=>e.anchor-t.anchor||hl(e.stableId,t.stableId))}function ql(e){return e.some(e=>e.group)?Yl(e).flatMap(e=>e.slots):[...e]}function Xl(e){const t=/* @__PURE__ */new Set;for(const i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}function Gl(e){return e.flatMap(e=>e.slots)}function Vl(e,t){const i=/* @__PURE__ */new Map;for(const t of e)for(const e of t.slots)i.set(e,t);const n=/* @__PURE__ */new Map;for(const e of t){const t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;const r=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,s=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,a=n.get(s);a?a.weight=(a.weight??0)+r:n.set(s,{source:t,target:o,weight:r})}return[...n.values()]}function Hl(e,t,i){const n=/* @__PURE__ */new Map;return e.forEach((e,t)=>{for(const i of e.slots)n.set(i,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;const r=/* @__PURE__ */new Map;for(const t of e.slots)r.set(t,0);for(const e of t){const t=n.get(e.source),i=n.get(e.target);if(null==t||null==i)continue;const s=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){const t=i>o?1:-1;r.set(e.source,(r.get(e.source)??0)+s*t)}else if(i===o&&t!==o){const i=t>o?1:-1;r.set(e.target,(r.get(e.target)??0)+s*i)}}const s=[...e.slots].sort((e,t)=>(r.get(e)??0)-(r.get(t)??0)||i(e,t));return{...e,slots:s}})}function Ul(e,t){e.some(e=>e.group)&&Wl(e,t,ql(e))}function Kl(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost}function Zl({order:e,after:t,nodes:i,edges:n,outgoingPartners:o,incomingPartners:r,slotForNode:s,averageGap:a,evaluate:c}){const l=(i,o)=>{const r=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),s=e.indexOf(i),l=r[0],u=r[r.length-1];if(3>r.length||!r.includes(s)||u-l+1!==r.length||1>=Math.abs(2*s-l-u))return;const d=[...e];d.splice(s,1),d.splice(l+u>>1,0,i);const h=ql(d),p=c(h),f=new Set(i.occupants.map(e=>e.id)),y=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),g=n.reduce((e,t)=>f.has(t.source)&&y.has(t.target)||f.has(t.target)&&y.has(t.source)?e+(t.value>0?t.value:1):e,0);Kl(p,t,Math.abs(2*s-l-u)*a*Math.max(1,g))&&(e=h,t=p)};for(const[e,t]of o)r.has(e)||3>t.size||l(s.get(e),[...t].map(e=>s.get(e)));for(const e of i){const t=s.get(e.id);e.group||!t.group||3>(r.get(e.id)?.size??0)||l(t,[...r.get(e.id)??[]].map(e=>s.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}function Ql(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function Jl(e,t){return ul(t,t=>[e[t.source],e[t.target]],Ql)}function eu(e,t){let i=0;for(const n of t){const t=e[n.source],o=e[n.target];null!=t&&null!=o&&(i+=Math.abs(t-o)*(n.value>0?n.value:1))}return i}function tu(e,t,i){const[n,o]=i.get(e.first),[r,s]=i.get(e.second);return 0>(t.get(n)-t.get(r))*(t.get(o)-t.get(s))?1:0}function iu(e,t,i,n,o,r,s){const a=[...o],c=new Map(o.map(e=>[e,pl(e)])),l=/* @__PURE__ */new Map;for(const e of o)for(const t of e.occupants)l.set(t.id,e);const u=/* @__PURE__ */new Map,d=[];for(const e of t){const t=l.get(e.source),i=l.get(e.target);t&&i&&(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}const h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let i=e+1;t.length>i;i++){if(!u.has(t[i])||!Ql(t[e],t[i]))continue;const n=/* @__PURE__ */new Set([...u.get(t[e]),...u.get(t[i])]);h.push({index:h.length,first:t[e],second:t[i],involvedSlots:n})}const p=/* @__PURE__ */new Map;for(const e of o)p.set(e,[]);for(const e of h)for(const t of e.involvedSlots)p.get(t)?.push(e);const f=new Uint32Array(h.length);let y=0;const g=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=s.plotH/Math.max(1,o.length),x=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),b=Math.max(1,g)*(Math.max(1,s.plotH)+m*Math.max(x,o.length)+1e-6*Math.max(1,o.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=/* @__PURE__ */new Map,A=(e,t)=>{let n=k.get(e);n||(n=/* @__PURE__ */new Map,k.set(e,n));const o=n.get(t);if(null!=o)return o;const r=gl(e,t,i);return n.set(t,r),r},S=new Map(o.map((e,t)=>[e,t])),M=t.flatMap(e=>{const t=u.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),_=/* @__PURE__ */new Map;for(const e of t){const t=u.get(e);t&&_.set(e,{source:S.get(t[0]),target:S.get(t[1])})}const $=/* @__PURE__ */new Map,P=/* @__PURE__ */new Map,j=/* @__PURE__ */new Map,I=(e,t,i)=>{e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(i)};for(const e of t)I($,e.source,e.target),I(P,e.target,e.source),I(j,e.source,e.target),I(j,e.target,e.source);const L=e=>1===$.get(e.source)?.size&&$.get(e.source).has(e.target)||1===j.get(e.source)?.size||1===j.get(e.target)?.size,R=t.flatMap(e=>{if(!L(e))return[];const t=_.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),C=e=>{let t=0;for(const i of R)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*v},T=e=>{const t=new Int16Array(o.length);for(let i=0;e.length>i;i++)t[S.get(e[i])]=i;return C(t)},O=h.map(e=>{const t=_.get(e.first),i=_.get(e.second);return[t.source,t.target,i.source,i.target]}),E=new Int16Array(o.length),F=new Float64Array(o.length),N=new Float64Array(o.length+1),z=e=>{for(let t=0;e.length>t;t++)E[S.get(e[t])]=t;let t=0;for(const[e,i,n,o]of O)0>(E[e]-E[n])*(E[i]-E[o])&&t++;if(e.length>0){const t=S.get(e[0]);F[t]=s.padding+e[0].peak.topPeak*s.valueScale;for(let t=1;e.length>t;t++){const i=S.get(e[t-1]),n=S.get(e[t]);F[n]=F[i]+A(e[t-1],e[t])*s.valueScale+s.padding}const i=S.get(e[e.length-1]),n=F[i]+e[e.length-1].peak.botPeak*s.valueScale+s.padding;if(n>s.plotH&&n>0){const e=s.plotH/n;for(let t=0;F.length>t;t++)F[t]*=e}}N[0]=0;for(let t=0;e.length>t;t++)N[t+1]=N[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,n=0,o=0;for(const e of M){const t=E[e.source],r=E[e.target];if(i+=Math.abs(t-r)*e.weight,n+=Math.abs(F[e.source]-F[e.target])*e.weight,Math.abs(t-r)>=2){const i=Math.min(t,r)+1;o+=(N[Math.max(t,r)]-N[i])*e.weight}}return t*b+n+o*m+C(E)+1e-6*i},D=(e,i)=>{const n=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)n[t+1]=n[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(const e of t){const t=i[e.source],r=i[e.target];if(null==t||null==r||2>Math.abs(t-r))continue;const s=Math.min(t,r)+1;o+=(n[Math.max(t,r)]-n[s])*(e.value>0?e.value:1)}return o},B=n=>{const o=Bl(n),r=n.slice(0,-1).map((e,t)=>A(e,n[t+1])),a=vl(e,t,i,n,o,{plotH:s.plotH,padding:s.padding,valueScale:s.valueScale,lanePlacement:s.lanePlacement??"stack",groupPadding:s.groupPadding,adjacentClearance:r});return{map:o,geometry:a,weightedLength:eu(o,t),pixelLength:wl(a.centerlines,t),transitOcclusion:D(n,o)}},W=(e,t,i)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*b+t.pixelLength+t.transitOcclusion*m+T(i)+1e-6*t.weightedLength}),Y=(e,t)=>{let i=t;if(null==i){const t=new Map(e.map((e,t)=>[e,t]));i=h.reduce((e,i)=>e+tu(i,t,u),0),w.fullCrossing++}return W(i,B(e),e)},q=(e,o,r="quality")=>{let a=o;if(null==a){const t=new Map(e.map((e,t)=>[e,t]));a=h.reduce((e,i)=>e+tu(i,t,u),0),w.fullCrossing++}const c=B(e);return W(a,{...c,transitOcclusion:$l(t,i,e,c.map,c.geometry.centerlines,n,{valueScale:s.valueScale,ribbonLane:s.ribbonLane,domain:s.domain,mode:r})},e)};let X=[...a];const G=(e,t)=>hl(c.get(e),c.get(t)),V=Xl(X),H=e=>{const t=al(e,d,e=>Y(e).cost,{passes:6,compare:G,maxEvaluations:FM});let i=Y(t),n=FM;for(let e=0;6>e&&n>0;e++){let o=!1;const r=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&r.reverse();for(const e of r){if(0>=n--)break;const r=t[e],s=t[e+1],a=new Map(t.map((e,t)=>[e,t]));let c=0;const l=[];y++;for(const e of[...p.get(r)??[],...p.get(s)??[]])f[e.index]!==y&&(f[e.index]=y,l.push(e),c+=tu(e,a,u));[t[e],t[e+1]]=[s,r];const d=new Map(a);d.set(r,e+1),d.set(s,e);let h=0;for(const e of l)h+=tu(e,d,u);w.localCrossing+=l.length;const g=Y(t,i.crossings-c+h);i.cost>g.cost?(i=g,o=!0):[t[e],t[e+1]]=[r,s]}if(!o)break}return t},U=e=>{const t=H(e);if((e.length>8?1/0:OM(e.length)*(e.length+M.length+O.length))>EM)return t;const i=ll(e,z,{maxItems:8,maxEvaluations:5e4}),n=q(i),o=q(t);return n.crossings!==o.crossings&&o.crossings>n.crossings?i:t},K="geometry-refine"===s.mode;if(K||"crossing-min"!==s.laneOrder&&"crossing-min+inside-out"!==s.laneOrder){if(!K&&"inside-out"===s.laneOrder)if(V){const e=Yl(X),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),i=[...e].sort((e,i)=>t(i)-t(e)||hl(e.stableId,i.stableId)),n=Array(i.length);let o=Math.floor((i.length-1)/2)-1,r=Math.floor((i.length-1)/2)+1;i.length>0&&(n[Math.floor((i.length-1)/2)]=i[0]);for(let e=1;i.length>e;e++)e%2==1&&i.length>r||0>o?n[r++]=i[e]:n[o--]=i[e];X=Gl(n)}else{const e=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||G(e,t)),t=Array(e.length);let i=Math.floor((e.length-1)/2)-1,n=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>n||0>i?t[n++]=e[o]:t[i--]=e[o];X=t}}else X=V?(e=>{let t=Yl(e);if(1>=t.length)return Gl(t);const i=e=>Y(Gl(e)).cost;t=Yl(U(e)),t=Hl(t,d,G),t=al(t,Vl(t,d),i,{passes:6,compare:(e,t)=>hl(e.stableId,t.stableId),maxEvaluations:FM}),t=cl(t,i,{passes:8,maxEvaluations:FM});const n=t.length>8?1/0:OM(t.length)*(t.length+M.length+O.length);if(EM>=n){const e=ll(t,e=>z(Gl(e)),{maxItems:8,maxEvaluations:5e4}),i=Gl(e),n=Gl(t),o=q(i),r=q(n);o.crossings!==r.crossings?t=r.crossings>o.crossings?e:t:r.cost>o.cost&&(t=e)}return t=Hl(t,d,G),Gl(t)})(X):U(X);if(!K&&"crossing-min+inside-out"===s.laneOrder&&X.length>1)if(V){const e=Yl(X);let t=Y(Gl(e)),i=Gl(e),n=t;const o=Math.floor((e.length-1)/2),r=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),s=[...e].sort((e,t)=>r(t)-r(e)||hl(e.stableId,t.stableId));for(const r of s){const s=e.indexOf(r);if(s===o)continue;e.splice(s,1),e.splice(o,0,r);const a=Gl(e),c=Y(a);c.cost>t.cost?(e.splice(o,1),e.splice(s,0,r)):(t=c,n.cost>c.cost&&(i=a,n=c))}X=i}else{let e=Y(X),t=[...X],i=e;const n=Math.floor((X.length-1)/2),o=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||G(e,t));for(const r of o){const o=X.indexOf(r);if(o===n)continue;X.splice(o,1),X.splice(n,0,r);const s=Y(X);s.cost>e.cost?(X.splice(n,1),X.splice(o,0,r)):(e=s,i.cost>s.cost&&(t=[...X],i=s))}X=t}if((K||"crossing-min"===s.laneOrder||"crossing-min+inside-out"===s.laneOrder)&&X.length>1)if(V){let e=Yl(X),t=q(Gl(e),void 0,"score");for(let i=0;6>i&&e.length>1;i++){let i=!1;for(let n=0;e.length-1>n;n++){[e[n],e[n+1]]=[e[n+1],e[n]];const o=Gl(e),r=q(o,void 0,"score");t.cost>r.cost?(X=o,t=r,i=!0):[e[n],e[n+1]]=[e[n+1],e[n]]}if(!i)break}e=Hl(Yl(X),d,G),X=Gl(e)}else{let e=q(X,void 0,"score");for(let t=0;X.length-1>t;t++){const i=X[t],n=X[t+1],o=new Map(X.map((e,t)=>[e,t]));let r=0;const s=[];y++;for(const e of[...p.get(i)??[],...p.get(n)??[]])f[e.index]!==y&&(f[e.index]=y,s.push(e),r+=tu(e,o,u));[X[t],X[t+1]]=[n,i];const a=new Map(o);a.set(i,t+1),a.set(n,t);let c=0;for(const e of s)c+=tu(e,a,u);w.localCrossing+=s.length;const l=q(X,e.crossings-r+c,"score");e.cost>l.cost?e=l:[X[t],X[t+1]]=[i,n]}}const Z=ql(a);X=ql(X);let Q=q(X);const J=q(Z);if(K){const e=T(Z),t=T(X);(Q.crossings>J.crossings||Q.crossings===J.crossings&&t>e+1e-9||Q.cost>J.cost)&&(X=Z,Q=J)}else Q.cost>J.cost&&(X=Z,Q=J);const ee=Zl({order:X,after:Q,nodes:e,edges:t,outgoingPartners:$,incomingPartners:P,slotForNode:l,averageGap:m,evaluate:q});return X=ee.order,Q=ee.after,Wl(o,r,X),{before:J,after:Q,initialOrder:a.map(e=>c.get(e)),evaluations:w}}function nu(e,t,i){const n=new Map(i.map((e,t)=>[e,t]));Wl(e,t,[...e].sort((e,t)=>(n.get(pl(e))??1/0)-(n.get(pl(t))??1/0)||hl(pl(e),pl(t))))}function ou(e,t,i){const n=e.map(e=>{const n=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end}));let o=0,r=0;for(const e of n){const i=t[e.id];o=Math.max(o,i?.topPeak||0),r=Math.max(r,i?.botPeak||0)}return{occupants:n,peak:{topPeak:o,botPeak:r},...null!=e.group?{group:e.group}:{}}}),o=dl();return n.forEach((e,t)=>{for(const i of e.occupants)o[i.id]=t}),{slots:n,slotByNode:o}}function ru(e,t,i,n){return`${e.map(e=>{const t=i[e.id],o=n[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}function su(e,t){for(NM.has(e)&&NM.delete(e),NM.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(dl(),t.slotByNode)});NM.size>12;){const e=NM.keys().next().value;if(null==e)break;NM.delete(e)}}function au(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function cu(e,t){return hl(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function lu(e){const t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const n of e)i.has(n.source)||i.set(n.source,/* @__PURE__ */new Set),t.has(n.target)||t.set(n.target,/* @__PURE__ */new Set),i.get(n.source).add(n.target),t.get(n.target).add(n.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function uu(e){const t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,n=(e,t,i,n)=>{let o=e.get(t);o||(o=/* @__PURE__ */new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+n)};for(const o of e){const e=o.value>0&&Number.isFinite(o.value)?o.value:1;n(t,o.source,o.target,e),n(i,o.target,o.source,e)}const o=/* @__PURE__ */new Map,r=e=>{if(o.has(e))return;const n=t.get(e),r=i.get(e),s=/* @__PURE__ */new Map;for(const[e,t]of n??[])s.set(e,(s.get(e)??0)+t);for(const[e,t]of r??[])s.set(e,(s.get(e)??0)+t);if(1===s.size){const[t,i]=[...s][0];o.set(e,{partner:t,weight:i})}};for(const t of e)r(t.source),r(t.target);return o}function du(e,t,i){const n=i.get(e),o=i.get(t);return!n||!o||n.partner===o.partner||n.partner===t||o.partner===e}function hu(e,t,i){return!!i.has(e)&&t.some(t=>!du(e,t,i))}function pu(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function fu(e,t,i,n,o,r){const s=/* @__PURE__ */new Set,a=new Map(e.map(e=>[e,/* @__PURE__ */new Set])),c=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of n)s.add(cu(e.source,e.target)),a.get(e.target)?.add(e.source),c.get(e.source)?.add(e.target);const l=/* @__PURE__ */new Map,u=/* @__PURE__ */new Set,d=(e,t)=>{for(let i=0;e.length>i;i++)for(let n=i+1;e.length>n;n++){const o=cu(e[i],e[n]);t instanceof Map?t.set(o,[e[i],e[n]]):t.add(o)}};for(const e of c.values())d([...e],l);for(const e of a.values())d([...e],u);const h=/* @__PURE__ */new Set;for(const[e,[n,o]]of l)u.has(e)&&(au(t[n],t[o])||au(i[n],i[o])&&(h.add(n),h.add(o)));return{conflicts:(e,i)=>{const n=o.get(e),a=o.get(i);return null!=n&&null!=a&&n!==a||!(null!=n==(null!=a)||s.has(cu(e,i))||r.has(e)&&r.has(i)&&du(e,i,r))||!!au(t[e],t[i])||!(!h.has(e)&&!h.has(i))&&!s.has(cu(e,i))}}}function yu(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||hl(e.id,i.id)).map(e=>e.id)}function gu(e,t,i=/* @__PURE__ */new Map){const n=[],o=[];for(const r of e){let e=n.findIndex(e=>e.every(e=>!t.conflicts(r,e))&&!hu(r,e,i));-1!==e||i.has(r)||(e=n.findIndex(e=>e.every(e=>!t.conflicts(r,e)))),-1===e&&(e=n.length,n.push([])),n[e].push(r),o.push(e)}return{assignment:o,slotCount:n.length}}function mu(e,t,i,n){if(12>=e.length||1>=n.slotCount)return n.assignment;const o=new Map(e.map((e,t)=>[e,t])),r=Array.from({length:e.length},()=>/* @__PURE__ */new Map),s=lu(i);for(const e of i){const t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;const n=pu(e,s);r[t].set(i,(r[t].get(i)??0)+n),r[i].set(t,(r[i].get(t)??0)+n)}const a=uu(i),c=e.map(e=>a.get(e)?.weight??0),l=Array.from({length:e.length},()=>/* @__PURE__ */new Map);let u=0;for(let i=0;e.length-1>i&&5e4>u;i++)if(a.has(e[i]))for(let n=i+1;e.length>n;n++){if(!a.has(e[n]))continue;if(t.conflicts(e[i],e[n]))continue;u++;const o=Math.min(c[i],c[n])||Math.max(c[i],c[n]),r=du(e[i],e[n],a)?o:-o;if(Math.abs(r)>DM&&(l[i].set(n,r),l[n].set(i,r),u>=5e4))break}const d=[...n.assignment],h=Array.from({length:n.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));const p=(e,t,i)=>{const n=d[t],o=d[i];let r=0;const s=/* @__PURE__ */new Set;for(const a of[t,i])for(const[c,l]of e[a]){const e=c>a?`${a}:${c}`:`${c}:${a}`;if(s.has(e))continue;s.add(e);const u=(a===t?o:n)===(c===t?o:c===i?n:d[c]);d[a]===d[c]!==u&&(r+=u?l:-l)}return r},f=(e,t,i)=>{let n=0;for(const[o,r]of e[t]){const e=i===d[o];d[t]===d[o]!==e&&(n+=e?r:-r)}return n},y=(e,t)=>e>DM||DM>=Math.abs(e)&&t>DM,g=(e,t,i,n)=>e>i+DM||DM>=Math.abs(e-i)&&t>n+DM;let m=0;for(let i=0;32>i&&zM>m;i++){let i=null,n=-1,o=-1,s=-1,a=-1/0,c=-1/0;for(let u=0;e.length>u;u++){for(let p=0;h.length>p&&m++<zM;p++){if(p===d[u])continue;if(!h[p].every(i=>!t.conflicts(e[u],e[i])))continue;const m=f(r,u,p),x=f(l,u,p);y(m,x)&&g(m,x,a,c)&&(i="move",n=u,o=-1,s=p,a=m,c=x)}if(m>=zM)break}for(let u=0;e.length-1>u;u++){for(let f=u+1;e.length>f&&m++<zM;f++){const m=d[u],x=d[f];if(m===x)continue;if(!h[x].every(i=>i===f||!t.conflicts(e[u],e[i])))continue;if(!h[m].every(i=>i===u||!t.conflicts(e[f],e[i])))continue;const b=p(r,u,f),v=p(l,u,f);y(b,v)&&g(b,v,a,c)&&(i="swap",n=u,o=f,s=-1,a=b,c=v)}if(m>=zM)break}if(null==i||-1===n)break;if("move"===i){const e=d[n];h[e].splice(h[e].indexOf(n),1),h[s].push(n),d[n]=s;continue}const u=d[n],x=d[o];h[u].splice(h[u].indexOf(n),1,o),h[x].splice(h[x].indexOf(o),1,n),d[n]=x,d[o]=u}return d}function xu(e,t){for(let i=0;Math.min(e.length,t.length)>i;i++)if(e[i]!==t[i])return t[i]>e[i];return t.length>e.length}function bu(e,t,i,n){if(0===e.length||e.length>12||1>=n.slotCount)return n.assignment;const o=new Map(e.map((e,t)=>[e,t])),r=Array.from({length:e.length},()=>new Float64Array(e.length)),s=Array.from({length:e.length},()=>/* @__PURE__ */new Map),a=Array.from({length:e.length},()=>/* @__PURE__ */new Map),c=lu(i);for(const e of i){const t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;const n=pu(e,c);r[t][i]+=n,r[i][t]+=n,a[t].set(i,(a[t].get(i)??0)+n),s[i].set(t,(s[i].get(t)??0)+n)}const l=uu(i),u=e.map(e=>l.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let i=t+1;e.length>i;i++){for(const[e,n]of s[t])d[t][i]+=Math.min(n,s[i].get(e)??0);for(const[e,n]of a[t])d[t][i]+=Math.min(n,a[i].get(e)??0);if(l.has(e[t])&&l.has(e[i])){const n=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=du(e[t],e[i],l)?n:-n}d[i][t]=d[t][i]}let h=[...n.assignment],p=(t=>{let i=0,n=0;for(let o=0;e.length>o;o++)for(let s=o+1;e.length>s;s++)t[o]===t[s]&&(i+=r[o][s],n+=d[o][s]);return{flow:i,affinity:n}})(h),f=0;const y=Array(e.length).fill(-1),g=Array.from({length:n.slotCount},()=>[]),m=(i,o,s,a)=>{if(f>=75e3)return;if(i===e.length)return f++,void((s>p.flow||s===p.flow&&a>p.affinity||s===p.flow&&a===p.affinity&&xu(y,h))&&(h=[...y],p={flow:s,affinity:a}));const c=Math.min(o+1,n.slotCount-1);for(let n=0;c>=n;n++){if(g[n].some(n=>t.conflicts(e[i],e[n])))continue;let c=0,l=0;for(const e of g[n])c+=r[i][e],l+=d[i][e];if(y[i]=n,g[n].push(i),m(i+1,Math.max(o,n),s+c,a+l),g[n].pop(),y[i]=-1,f>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}function vu(e,t){let i=1/0,n=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>1e-9&&(i=Math.min(i,t.t),n=Math.max(n,t.t));return Number.isFinite(i)&&Number.isFinite(n)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(n=Math.min(n,t.end)),i>n?{start:null,end:null}:{start:i,end:n}):{start:null,end:null}}function wu(e,t,i,n){const o=ru(e,t,i,n),r=NM.get(o);if(r)return ou(r.slots,i,n);const s=dl();for(const t of e)s[t.id]=vu(i[t.id],n[t.id]);const a=yu(e,s),c=new Map(e.map(e=>[e.id,e])),l=new Map(e.map(e=>[e.id,e.group||void 0])),u=uu(t),d=fu(a,s,n,t,l,u),h=gu(a,d,u),p=bu(a,d,t,{...h,assignment:mu(a,d,t,h)}),f=/* @__PURE__ */new Map,y=p.map(e=>(f.has(e)||f.set(e,f.size),f.get(e))),g=Array.from({length:f.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=dl();a.forEach((e,t)=>{const i=y[t],n=g[i];n.occupants.push({id:e,end:s[e].end??-1/0});const o=c.get(e)?.group;o&&(n.group=o),m[e]=i});for(const t of[...e].sort((e,t)=>hl(e.id,t.id)))null==m[t.id]&&(g[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(const e of g){e.occupants.sort((e,t)=>(s[e.id].start??1/0)-(s[t.id].start??1/0)||hl(e.id,t.id));for(const t of e.occupants){const n=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,n?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,n?.botPeak||0)}}const x={slots:g,slotByNode:m};return su(o,x),x}function ku(e){return e.topMass+e.botMass}function Au(e){const t=/* @__PURE__ */new Map;for(const i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,n=-1/0;return o=>{n>o&&(i=0),n=o;const r=t.get(o);if(r){const e=r.reduce((e,t)=>ku(t)<ku(e)?e:t,r[0]);return{exact:r,sample:e}}for(;e.samples.length>i&&o>=e.samples[i].t;)i++;return{exact:r,sample:e.samples[i-1]??null}}}function Su(e,t,i,n,o,r,s=0){const a=/* @__PURE__ */new Map;for(const i of e){if(!i.group||!t[i.id])continue;const e=a.get(i.group)??[];e.push(i),a.set(i.group,e)}if(0===a.size||0>=r)return t;const c=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,l]of a){const a=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===a.length)continue;const u=a[0].slot,d=a.at(-1).slot,h=o[u.occupants[0]?.id],p=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(p))continue;const f=(h-u.peak.topPeak*r+(p+d.peak.botPeak*r))/2,y=[...new Set(l.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),g=/* @__PURE__ */new Map;for(const e of l)g.set(e.id,/* @__PURE__ */new Map);const m=new Map(l.map(e=>[e.id,Au(t[e.id])]));for(const e of y){const t=/* @__PURE__ */new Map;for(const i of l){const{sample:o}=m.get(i.id)(e);if(!o||1e-9>=ku(o))continue;const r=n[i.id];if(null==r)continue;const s=t.get(r)??[];s.push({node:i,sample:o}),t.set(r,s)}const i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>ku(e)))}));if(0===i.length)continue;let a=f-(i.reduce((e,t)=>e+t.mass,0)*r+Math.max(0,s)*Math.max(0,i.length-1))/2;for(const t of i){for(const{node:i,sample:n}of t.active){const t=(a-o[i.id])/r+n.topMass-(n.boundaryOffset??0);g.get(i.id).set(e,t)}a+=t.mass*r+Math.max(0,s)}}for(const e of l){const i=t[e.id],n=c[e.id],o=g.get(e.id),r=m.get(e.id),s=[];for(const e of y){const t=o.get(e),{exact:i,sample:n}=r(e);i?s.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null!=t&&n&&ku(n)>1e-9&&s.push({...n,t:e,boundaryOffset:(n.boundaryOffset??0)+t})}n.samples=s,n.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{const i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return c}function Mu(e,t,i,n,o){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:p="both",domain:f}=o,y=dl(),g=dl();for(const t of e)y[t.id]=i[t.id].topPeak||0,g[t.id]=i[t.id].botPeak||0;const m="half"===u,x=dl();for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,r=null!=i&&Number.isFinite(i)?i:-1/0;for(const e of n.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=m?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(r)?r:null}}let b=dl(),v=[],w=[];if(o.frozenSlots){const e=ou(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(pl)}else if("reuse"===c){const n=wu(e,t,i,x);v=n.slots,b=n.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:y[e.id],botPeak:g[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});Ul(v,b),0===w.length&&(w=v.map(pl));let k=null;o.frozenSlots||(o.fixedSlotOrder?nu(v,b,o.fixedSlotOrder):o.runOrdering&&l&&"insertion"!==l&&(k=iu(e,t,i,x,v,b,{plotH:r,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:p,domain:f}))),Ul(v,b);const A=vl(e,t,i,v,b,{plotH:r,padding:s,valueScale:a,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,$=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(pl),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:$,lengthAfter:P}}function _u(e,t,i){const{plotH:n,pairing:o="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half",maxValueScale:c,lanePlacement:l="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:p}=i,f=Number.isFinite(d)?Math.max(0,d):0,y=Tl(e,t),g=Ol(e,t,y,o);let m=dl();for(const t of e)m[t.id]=El(t,y,g,void 0,u);const x=Mu(e,t,m,y,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,runOrdering:!0,lanePlacement:"stack",groupPadding:f,ribbonLane:h,domain:p}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=/* @__PURE__ */new Set;for(const e of t){const t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;const n=g.get(e.id);t!==i?t>i?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(v.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=y.outgoing[t.id],i=y.incoming[t.id],n=new Set(e.map(e=>g.get(e.id).sourceSide)),o=new Set(i.map(e=>g.get(e.id).targetSide));if(1===n.size&&i.length>0){const e=[...n][0];for(const t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(g.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(g.get(i.id).sourceSide=t)}}zl(t,g,x.slotByNode),Dl(e,y,g,v),m=dl();for(const t of e)m[t.id]=El(t,y,g,void 0,u);const w=Mu(e,t,m,y,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:"stack",groupPadding:f,ribbonLane:h,domain:p}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*n-A*f)/S),_=2*M+fl(w.slots,M,f).reduce((e,t)=>e+t,0),$=k>0?Math.max(0,(n-_)/k):1,P=Number.isFinite(c)&&c>0?Math.min($,c):$;let j=Mu(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$});const I=Number.isFinite(c)&&c>0&&$>c+1e-12;if("insertion"!==s&&("hug"===l||I)&&j.slots.length>1&&(iu(e,t,m,j.laneLifetime,j.slots,j.slotByNode,{plotH:n,padding:M,valueScale:P,groupPadding:f,laneOrder:s,ribbonLane:h,domain:p,lanePlacement:l,mode:"geometry-refine"}),j=Mu(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(pl),lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$})),Nl(y,g)){const i=Fl(t,m,j.centerlines,P);m=dl();for(const t of e)m[t.id]=El(t,y,g,i,u);j=Mu(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(pl),lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$})}const L=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),R=[...j.slots].sort((e,t)=>(L.get(pl(e))??1/0)-(L.get(pl(t))??1/0)||hl(pl(e),pl(t))),C=dl();R.forEach((e,t)=>{for(const i of e.occupants)C[i.id]=t});const T=vl(e,t,m,R,C,{plotH:n,padding:M,valueScale:P,stackValueScale:$,lanePlacement:"stack",groupPadding:f}),O=Su(e,m,R,C,T.centerlines,P,f),E=Pl(Jl(C,t),eu(C,t),t,O,R,C,T.centerlines,j.laneLifetime,P,T.verticalUtilization,h,p);m=Su(e,m,j.slots,j.slotByNode,j.centerlines,P,f);const F=Pl(Jl(j.slotByNode,t),eu(j.slotByNode,t),t,m,j.slots,j.slotByNode,j.centerlines,j.laneLifetime,P,j.verticalUtilization,h,p);return{nodeData:m,sides:g,valueScale:P,padding:M,compressedPadding:12>M,centerlines:j.centerlines,laneLifetime:j.laneLifetime,slots:j.slots,slotByNode:j.slotByNode,crossingsBefore:"insertion"===s?null:E.crossings,crossingsAfter:"insertion"===s?null:F.crossings,lengthBefore:"insertion"===s?null:E.weightedLength,lengthAfter:"insertion"===s?null:F.weightedLength,layoutQualityBefore:E,layoutQuality:F}}function $u(e){const{sx:t,sTop:i,sBot:n,tx:o,tTop:r,tBot:s,cp1X:a,cp2X:c}=e,l=(i+n)/2,u=(r+s)/2;return{pathD:[`M${t},${i}`,`C${a},${i} ${c},${r} ${o},${r}`,`L${o},${s}`,`C${c},${s} ${a},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(n-i)/2}}}function Pu(e,t,i,n,o,r,s,a,c={}){const l=o,u=e=>a?Math.max(a[0],Math.min(a[1],e)):e;let d=r(u(e.time));const h=r(u(i.time)),p=e.value*l,f=i.value*l,y=t+(e.boundaryOffset??0)*l,g=n+(i.boundaryOffset??0)*l,m=e.sideMassBefore*l,x=i.sideMassAfter*l;let b,v,w,k;"top"===e.side?(b=y-m,v=b+p):(v=y+m,b=v-p),"top"===i.side?(w=g-x,k=w+f):(k=g+x,w=k-f);const A=c.sourceRunwayStart,S=c.minRun,M=Math.abs((w+k)/2-(b+v)/2),_=h-d,$="number"==typeof A&&Number.isFinite(A),P="number"==typeof S&&Number.isFinite(S)&&S>0;if($&&M>1e-9&&_>0&&("auto"===S||P)){const t="source"===s?.85:"target"===s?.15:.5,i="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(i>_){const t=r(u(Math.min(A,e.time)));Number.isFinite(t)&&(d=Math.min(d,Math.max(Math.min(d,t),h-i)))}}const j="source"===s?d+.85*(h-d):"target"===s?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:b,sBot:v,tx:h,tTop:w,tBot:k,cp1X:j,cp2X:j}}function ju(e,t,i,n,o,r){const s=new Map(t),a=/* @__PURE__ */new Map;for(const t of e){const e=r?.get(t.source),i=null==e?"node:"+t.source:"group:"+e,n=a.get(i)??/* @__PURE__ */new Map,o=n.get(t.startTime)??[];o.push(t),n.set(t.startTime,o),a.set(i,n)}for(const e of a.values())for(const[r,a]of e){if(!a.some(e=>i.has(e.id)))continue;const e=a.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const c=n(r),l=Math.min(...e.map(e=>e.sx));if(l>=c-1e-9)continue;const u=Math.max(...a.map(e=>{const t=i.get(e.id);return null==t?c:Math.min(c,n(t))})),d=Math.min(c,Math.max(l,u));for(const e of a){const i=t.get(e.id),n=d+(i.tx-d)*("source"===o?.85:"target"===o?.15:.5);s.set(e.id,{...i,sx:d,cp1X:n,cp2X:n})}}return s}function Iu(e,t,i){const n=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),r=/* @__PURE__ */new Map;for(const e of t){if(n.has(e.source))continue;const t=r.get(e.source)??[];t.push(e),r.set(e.source,t)}const s=/* @__PURE__ */new Map;for(const t of e){if(!t.group)continue;const e=s.get(t.group)??[];e.push(t),s.set(t.group,e)}const a=/* @__PURE__ */new Set;for(const[e,t]of s){const i=t.flatMap(e=>r.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{const t=e.xExtent?.[0],o=i[0].startTime;return!n.has(e.id)&&(r.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&a.add(e)}const c=/* @__PURE__ */new Map;for(const[e,t]of r){const n=o.get(e);if(n?.group&&!a.has(n.group))continue;const r=n?.xExtent?.[0],s=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),l=s[0]?.startTime-1;let u=null;for(let e=0;s.length>e;){const t=s[e].startTime;let n=e+1;for(;s.length>n&&s[n].startTime===t;)n++;for(let t=e;n>t;t++){const e=s[t],n=Number.isFinite(r)&&e.startTime>r,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!n&&!o)continue;let a=i[0];n&&(a=Math.max(a,r)),o&&(a=Math.max(a,e.systemInTime)),!n&&o&&Number.isFinite(l)&&(a=Math.max(a,l)),null!=u&&(a=Math.max(a,u)),e.startTime>a&&c.set(e.id,a)}u=t,e=n}}for(const[e,t]of s){if(!a.has(e))continue;const i=t.flatMap(e=>r.get(e.id)??[]);if(!i.every(e=>c.has(e.id))){for(const e of i)c.delete(e.id);continue}const n=Math.max(...i.map(e=>c.get(e.id)));for(const e of i)c.set(e.id,n)}return c}function Lu(e,t,i,n,o){const r=/* @__PURE__ */new Map;for(const s of e){if(!i.has(s.id))continue;const e=t.get(s.id);if(!e||e.sx>=n(s.startTime)-1e-9)continue;const a=o(e.sx);Number.isFinite(a)&&s.startTime>a&&r.set(s.id,a)}return r}function Ru(e,t,i){const n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(const[e,t]of i??[]){const i=o.get(t)??[];i.push(e),o.set(t,i)}for(const r of e){const e=t.get(r.id);if(null==e||!Number.isFinite(e)||e>=r.startTime)continue;const s=i?.get(r.source),a=null==s?[r.source]:o.get(s)??[r.source];for(const t of a){const i=n.get(t)??/* @__PURE__ */new Map,o=i.get(r.startTime);i.set(r.startTime,null==o?e:Math.min(o,e)),n.set(t,i)}}return n}function Cu(e){return Math.max(18,11*e.length*.58)}function Tu(e){const t=1.22*Cu(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Ou(e,t){const i=e.labelX-Cu(e.labelText),n=t.labelX-Cu(t.labelText);return t.labelX+3>=i&&e.labelX+3>=n}function Eu(e,t){const i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;i.length>e;e+=1){let t=8;for(let n=0;e>n;n+=1)Ou(i[e],i[n])&&(t=Math.max(t,i[n].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let n=t-8;for(let t=e+1;i.length>t;t+=1)Ou(i[e],i[t])&&(n=Math.min(n,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,n)}}}function Fu(e,t,i){const n=e.map(e=>({...e})),o=/* @__PURE__ */new Map;for(const e of n){const i=t[e.id];if(null==i)continue;const n=o.get(i)??[];n.push(e),o.set(i,n)}const r=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-n)))})};for(const e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(const n of e){const e=n.labelX-Cu(n.labelText);t.length>0&&e>i+3&&(r(t),t=[],i=-1/0),t.push(n),i=Math.max(i,n.labelX)}r(t)}return Eu(n,i),n}function Nu(e,t,i){const n=e.map(e=>({...e}));for(const e of n){const i=1.22*Cu(e.labelText)+4;e.labelX=t-4>i?Math.max(i/2+2,Math.min(t-i/2-2,e.labelX)):t/2}const o=[],r=[...n].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of r){const t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(const e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],n=/* @__PURE__ */new Map;for(const i of e){const[e,o]=Tu(i);let r=t.findIndex(t=>e>t+8);-1===r&&(r=t.length),t[r]=o,n.set(i,r)}const o=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=14*t.length+8>o;for(const t of e){const e=n.get(t)??0;t.labelY=r?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return n}function zu(e,t,i,n,o={}){if(!1===n)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===n)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let r=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*i)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(r=Math.min(r,Math.floor(o.maxLabels)));const s=e.map((e,t)=>{const i=o.priorityById?.get(e.id),n=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+Cu(e.labelText):Cu(e.labelText)+.01*n}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),a=new Set(s.slice(0,r).map(e=>e.band.id));return e.map(e=>a.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}function Du(e){return e.replace(BM,(e,t,i)=>`${i},${t}`)}function Bu(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Wu(e){return{...e,pathD:Du(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Yu(e,t){return"horizontal"===t?e:{...e,pathD:Du(e.pathD),gradientStubs:e.gradientStubs?.map(Wu),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function qu(e,t){return"horizontal"===t?e:{...e,pathD:Du(e.pathD),bezier:Bu(e.bezier)}}function Xu(e){const{nodes:t,edges:i,domain:n,plotW:o,plotH:r,ribbonLane:s,ribbonMinRun:a=0,edgeOpacity:c,colorOf:l,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:p,maxLabels:f,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?r:o,w="vertical"===d?o:r,k=tl(t,i,n,{usageMode:b}),{fatal:A,warnings:S}=el(k),M=il(i,k,b),_=(0,RM.scaleTime)().domain(n).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:_};const $=_u(t,M,{plotH:w,...u,ribbonLane:s,domain:n}),{centerlines:P,nodeData:j,valueScale:I}=$,L=rt(m,x),R=[],C=[],T=0===a?/* @__PURE__ */new Map:Iu(t,M,n),O=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),E=/* @__PURE__ */new Map;for(const e of M){const t=j[e.source]?.localAttachments.get(e.id),i=j[e.target]?.localAttachments.get(e.id);t&&i&&E.set(e.id,Pu(t,P[e.source],i,P[e.target],I,_,s,n,{minRun:a,sourceRunwayStart:T.get(e.id)}))}const F=ju(M,E,T,_,s,O),N=Lu(M,F,T,_,e=>n[0]+e/v*(n[1]-n[0])),z=Ru(M,N,O);t.forEach((e,t)=>{const i=j[e.id];if(!i||0===i.samples.length)return;const o=(r=i.samples,(s=z.get(e.id))&&0!==s.size?r.map(e=>{const t=s.get(e.t);return null==t?e:{...e,t:t}}):r);var r,s;const a=Rl(o,P[e.id],I,_,n);if(!a)return;const c=Il(o,n),u=c.find(e=>e.topMass+e.botMass>0)||c[0],h=P[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*I/2;let p,f,y=l(e.id,t),m=y,x=.5;const b=e.__raw??e;if(g&&g.length>0){const e=lt(b,g,L(b));"string"==typeof e.fill?y=e.fill:null!=e.fill&&kr(e.fill)&&(f=e.fill,y=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:y),"string"==typeof e.stroke&&(m=e.stroke),"number"==typeof e.strokeWidth&&(x=e.strokeWidth),"number"==typeof e.fillOpacity&&(p=e.fillOpacity),"number"==typeof e.opacity&&null==p&&(p=e.opacity)}const v=Cl(e.id,M,$,_,n,N);R.push({id:e.id,pathD:a,fill:y,stroke:m,strokeWidth:x,...null!=p&&{fillOpacity:p},...f&&{hatchFill:f},...v.length>0&&{gradientStubs:v},rawDatum:b,labelX:_("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:h,labelText:e.label??e.id})});const D=/* @__PURE__ */new Map;t.forEach((e,t)=>D.set(e.id,t)),M.forEach(e=>{const t=F.get(e.id);if(!t)return;const i=D.get(e.source)??0,n=l(e.source,i),{pathD:o,bezier:r}=$u(t),s=e.__raw??e,a="function"==typeof c?Number(c(s)):c,u=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.35;C.push({id:e.id,pathD:o,fill:n,opacity:u,rawDatum:s,bezier:r})});const B=Fu(R,$.slotByNode,w).map(e=>Yu(e,d)),W="vertical"===d?Nu(B,o,r):B,Y=/* @__PURE__ */new Map;if(null!=p)for(const e of t){const t=e.__raw??e,i="function"==typeof p?p(t):Number(t[p]);Number.isFinite(i)&&Y.set(e.id,i)}const q=zu(W,o,r,h,{...Y.size>0&&{priorityById:Y},...null!=f&&{maxLabels:f}});return{layout:$,layoutConfig:{bands:q,ribbons:C.map(e=>qu(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function Gu(e,t,i,n="horizontal"){return"vertical"===n?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}function Vu(e){const t=e.layout,i=e.nodes,n=e.orientation,o=e.plotW,r=e.plotH,s=e.timelineExtent,a=e.axisTicks,c=e.showQualityReadout??!1,l=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,p=e.toTime,f=e.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t;let S=null,M=null;for(const e of i){const t=g[e.id];if(!t||null===t.start||null===t.end)continue;const i=f(t.start),n=f(t.end);(null===S||S>i)&&(S=i),(null===M||n>M)&&(M=n)}const _=e=>Math.max(0,Math.min(s,e)),$=_(S??0),P=Math.max($,_(M??s)),j=a.map((e,t)=>({tick:e,index:t,coordinate:f(p(e.date))})).filter(({coordinate:e})=>e>=$-.5&&P+.5>=e),I=null!==(w??null)&&null!=k&&null!=A,L=c&&(I||u.length>0)?/* @__PURE__ */ /* @__PURE__ */(0,WM.jsxs)("g",{fill:XM,fontSize:10,textAnchor:"end",children:[I&&/* @__PURE__ */ /* @__PURE__ */(0,WM.jsxs)(WM.Fragment,{children:[
|
|
186
|
+
/* @__PURE__ */(0,yM.jsx)("text",{y:0,dominantBaseline:"central",fontSize:r,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&/* @__PURE__ */ /* @__PURE__ */(0,yM.jsxs)("text",{y:.7*r+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}function Nc(e){return Math.max(0,Math.min(1,e))}function zc(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){const e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function Dc(e,t,i){const n=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(i)}`}function Bc(e,t,i){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Nc(e.offset),color:e.color??i,opacity:null==e.opacity?1:Nc(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";const o=e=>{if(1===e.opacity)return e.color;const t=zc(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===n.length)return o(n[0]);const r=Nc(t);if(n[0].offset>=r)return o(n[0]);if(r>=n[n.length-1].offset)return o(n[n.length-1]);for(let e=0;n.length-1>e;e++){const t=n[e],i=n[e+1];if(t.offset>r||r>i.offset)continue;const s=i.offset-t.offset,a=s>0?(r-t.offset)/s:0,c=zc(t.color),l=zc(i.color);if(!c||!l)return o(.5>a?t:i);const[u,d,h]=c,[p,f,y]=l,g=u+(p-u)*a,m=d+(f-d)*a,x=h+(y-h)*a,b=t.opacity+(i.opacity-t.opacity)*a;return 1===b?Dc(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return o(n[n.length-1])}function Wc(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Yc(e){const{min:t,max:i,value:n,thresholds:o,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=i-t||1,h=(Math.max(t,Math.min(i,n))-t)/d;let p=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:r||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),i>p[p.length-1].value&&p.push({value:i,color:p[p.length-1].color});const f=!!l&&l.stops.length>=2,y=[],g=/* @__PURE__ */new Map,m=[];if(f){const e=a?h:1,t=Wc("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),n=[];for(let t=0;i>t;t++)n.push(Bc(l.stops,e*(t+.5)/i,r||p[0]?.color||"#007bff"));const o=Wc("fill",0);y.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:n}}),g.set(o,{fill:n[0]||s})}}else{let e=t;for(let i=0;p.length>i;i++){const n=p[i],o=(n.value-e)/d,r=(e-t)/d,c=(n.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-r),u=a?Math.max(0,o-l):0;if(l>0){const e=Wc("fill",i);y.push({category:e,value:l,_zone:n.label||"Zone "+(i+1),_isFill:!0}),g.set(e,{fill:n.color})}if(u>0){const e=Wc("bg",i);y.push({category:e,value:u,_zone:n.label||"Zone "+(i+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=n.value}}if(c&&o&&o.length>0)for(const e of o)e.value>t&&i>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}function qc(e=240){const t=360-e,i=180+t/2,n=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:n,offsetRad:-Math.PI/2+n}}function Xc(e=240){const{sweepRad:t,offsetRad:i}=qc(e),n=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||n.push([Math.cos(e),Math.sin(e)]);const o=n.map(e=>e[0]),r=n.map(e=>e[1]),[s,a]=Mt(o),[c,l]=Mt(r);return{minX:s,maxX:a,minY:c,maxY:l,width:a-s,height:l-c,cx:(s+a)/2,cy:(c+l)/2}}function Gc(e){return na(e)}function Vc(e,t,i,n,o,r){const s=Wr(n.theme).colors.categorical,a=i??n.colorScheme,c=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],l="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?c.map(e=>({...e,__ssrColorBy:t(e)})):c,d=t?Yn(u,l,a??s):void 0,h=Ua("string"==typeof o.color?o.color:void 0,s,a,void 0,
|
|
187
|
+
/* @__PURE__ */new Map),p=r??nt(o.valueAccessor??"value"),f=o.styleRules,y=n.pieceStyle;return(e,i)=>{const n={fill:t&&d?Bn(e,t,d):h};return f?.length&&Object.assign(n,lt(e,f,{value:p(e,i),category:i})),"function"==typeof y?Object.assign(n,y(e,i)||{}):y&&"object"==typeof y&&Object.assign(n,y),void 0!==o.stroke&&(n.stroke=o.stroke),void 0!==o.strokeWidth&&(n.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(n.opacity=o.opacity),n}}function Hc(e,t,i,n,o,r="median",s=.8){const a=nt(o.valueAccessor??"value"),c=Vc(e,t,i,n,o,e=>"number"==typeof e[r]?e[r]:a(e));return(e,t)=>{const i=c(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=s),void 0===i.stroke&&(i.stroke=i.fill),i}}function Uc(e,t,i,n,o){return Hc(e,t,i,n,o,"median",.6)}function Kc(e,t,i,n,o){const r=Vc(e,t,i,n,o),s="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:s,fillOpacity:.8,...r(e,t)})}function Zc(e,t,i,n,o){const r=Vc(e,t,i,n,o),s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.sizeBy,c=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],l=a?s.map(e=>"function"==typeof a?a(e):Number(e[a])).filter(Number.isFinite):[],u=l.length?Mt(l):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:a?Xn(e,a,c,u):d,fillOpacity:h,...r(e,t)})}function Qc(e="static"){return CM[e]??CM.static}function Jc(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:TM.has(e.kind)?"fatal":"warn"}function el(e){const t=[],i=[];for(const n of e)"fatal"===Jc(n)?t.push(n):i.push(n);return{fatal:t,warnings:i}}function tl(e,t,i,n={}){const o=Qc(n.usageMode??"static"),r=[],s=/* @__PURE__ */new Set;for(const t of e)s.has(t.id)&&r.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),s.add(t.id);const a=/* @__PURE__ */new Set,c=Array.isArray(i)&&2===i.length,l=c&&Number.isFinite(i[0])&&Number.isFinite(i[1]);c&&l&&l&&i[1]>=i[0]||r.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)a.has(e.id)&&r.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),a.add(e.id),s.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),s.has(e.target)||r.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&r.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),Number.isFinite(e.value)&&e.value>0||r.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&r.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}function il(e,t,i="static"){if("strip"!==Qc(i).invalidSystemTime)return e;const n=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===n.size?e:e.map(e=>{if(!n.has(e.id))return e;const t={...e};return null==t.systemInTime||Number.isFinite(t.systemInTime)||delete t.systemInTime,null==t.systemOutTime||Number.isFinite(t.systemOutTime)||delete t.systemOutTime,t})}function nl(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function ol(e){const{desired:t,minGaps:i,weights:n}=e,o=t.length;if(0===o)return[];if(i.length!==Math.max(0,o-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const r=Array(o).fill(0);for(let e=1;o>e;e++)r[e]=r[e-1]+Math.max(0,Number.isFinite(i[e-1])?i[e-1]:0);const s=[];for(let e=0;o>e;e++){const i=Math.max(Number.EPSILON,Number.isFinite(n?.[e])?n[e]:1),o=(Number.isFinite(t[e])?t[e]:0)-r[e];for(s.push({start:e,end:e,weight:i,mean:o});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(e.mean>=t.mean)break;const i=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:i,mean:(t.mean*t.weight+e.mean*e.weight)/i})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-r[o-1]:1/0,l=a>c?a:c,u=Array(o);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let i=e.start;e.end>=i;i++)u[i]=t+r[i]}return u}function rl(e,t){let i=0,n=e.length-1,o=-1;for(;n>=i;){const r=i+n>>>1;e[r].at>t?n=r-1:(o=r,i=r+1)}return 0>o?{at:t,before:0,after:0}:e[o]}function sl(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const i=[],n=[0];for(let o=0;e.length-1>o;o++){const r=e[o],s=e[o+1],a=[.../* @__PURE__ */new Set([...r.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=rl(r,e),i=rl(s,e);c=Math.max(c,t.after+i.before)}i.push(c),n.push(n[n.length-1]+c+t)}return{adjacentClearance:i,positions:n}}function al(e,t,i,n={}){let o=[...e];if(1>=o.length)return o;let r=[...o],s=i(o),a=1;const c=Math.max(0,n.passes??6),l=Math.max(1,n.maxEvaluations??1/0);for(let e=0;c>e&&l>a;e++){const e=new Map(o.map((e,t)=>[e,t])),c=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(const i of t){const t=e.get(i.source),n=e.get(i.target);if(null==t||null==n)continue;const o=Number.isFinite(i.weight)&&i.weight>0?i.weight:1;c.set(i.source,(c.get(i.source)??0)+n*o),l.set(i.source,(l.get(i.source)??0)+o),c.set(i.target,(c.get(i.target)??0)+t*o),l.set(i.target,(l.get(i.target)??0)+o)}o=o.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(n.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=i(o);if(a++,s>u)s=u,r=[...o];else if(u===s)break}return r}function cl(e,t,i={}){const n=[...e];if(1>=n.length)return n;let o=t(n),r=1;const s=Math.max(0,i.passes??6),a=Math.max(1,i.maxEvaluations??1/0);for(let e=0;s>e&&a>r;e++){let e=!1;for(let i=0;n.length-1>i&&a>r;i++){[n[i],n[i+1]]=[n[i+1],n[i]];const s=t(n);r++,o>s?(o=s,e=!0):[n[i],n[i+1]]=[n[i+1],n[i]]}if(!e)break}return n}function ll(e,t,i={}){const n=[...e],o=n.length;if(1>=o||o>(i.maxItems??8))return n;const r=Math.max(1,i.maxEvaluations??1/0);let s=0,a=[...n],c=1/0;const l=()=>{if(s>=r)return;const e=t(n);s++,c>e&&(c=e,a=[...n])};l();const u=Array(o).fill(0);let d=0;for(;o>d&&r>s;)if(d>u[d]){const e=d%2==0?0:u[d];[n[e],n[d]]=[n[d],n[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function ul(e,t,i=()=>!0){let n=0;for(let o=0;e.length>o;o++){const[r,s]=t(e[o]);for(let a=o+1;e.length>a;a++){if(!i(e[o],e[a]))continue;const[c,l]=t(e[a]);0>(r-c)*(s-l)&&n++}}return n}function dl(){/* @__PURE__ */
|
|
188
|
+
return Object.create(null)}function hl(e,t){return t>e?-1:e>t?1:0}function pl(e){return e.occupants.map(e=>e.id).sort(hl).join("\0")}function fl(e,t,i=0){return e.slice(0,-1).map((n,o)=>null!=n.group&&n.group===e[o+1].group?i:t)}function yl(e,t){return e.map(e=>{const i=/* @__PURE__ */new Map;for(const n of e.occupants){const e=t[n.id];if(e)for(const t of e.samples){const e=i.get(t.t)??{before:0,after:0},n=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-n),after:Math.max(e.after,t.botMass+n)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function gl(e,t,i){return sl(yl([e,t],i)).adjacentClearance[0]??0}function ml(e,t,i){if(0===e.length)return[];const{padding:n,plotH:o,valueScale:r}=i,s=i.stackValueScale??r,a=fl(e,n,i.groupPadding??0),c=[n+e[0].peak.topPeak*s];for(let i=1;e.length>i;i++)c.push(c[i-1]+t[i-1]*s+a[i-1]);const l=c[c.length-1]+e[e.length-1].peak.botPeak*s+n;if(l>o&&l>0){const e=o/l;for(let t=0;c.length>t;t++)c[t]*=e}return c}function xl(e,t){const i=(e.boundaryOffset??0)*t,n=e.value*t;if("out"===e.kind){const o=e.sideMassBefore*t;return i+("top"===e.side?n/2-o:o-n/2)}const o=e.sideMassAfter*t;return i+("top"===e.side?n/2-o:o-n/2)}function bl(e,t,i,n,o,r,s){const a=e.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=fl(e,c,s.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),p=c+e[0].peak.topPeak*u,f=l-c-e[a-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=f-p)return ml(e,o,s);let y=1===a?[(p+f)/2]:[...r];for(let e=0;12>e;e++){const e=Array(a).fill(0),o=Array(a).fill(0);for(const r of i){const i=t[r.source],s=t[r.target];if(null==i||null==s||i===s)continue;const a=n[r.source]?.localAttachments.get(r.id),c=n[r.target]?.localAttachments.get(r.id);if(!a||!c)continue;const l=r.value>0&&Number.isFinite(r.value)?r.value:1,d=xl(a,u),h=xl(c,u);e[i]+=(y[s]+h-d)*l,o[i]+=l,e[s]+=(y[i]+d-h)*l,o[s]+=l}const r=ol({desired:y.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),minGaps:h,weights:o.map(e=>Math.max(1,e)),min:p,max:f});let s=0;for(let e=0;a>e;e++)s=Math.max(s,Math.abs(r[e]-y[e]));if(y=r,.01>s)break}return y}function vl(e,t,i,n,o,r){const s=r.adjacentClearance?[...r.adjacentClearance]:sl(yl(n,i)).adjacentClearance,a=ml(n,s,r);let c="hug"===r.lanePlacement?bl(n,o,t,i,s,a,r):[...a];if("hug"===r.lanePlacement){const i=t=>{const i=dl();for(const n of e)i[n.id]=t[o[n.id]];return i};wl(i(c),t)>wl(i(a),t)+1e-6&&(c=[...a])}const l=dl();for(const t of e)l[t.id]=c[o[t.id]];let u=1/0,d=-1/0;for(const t of e){const e=l[t.id],n=i[t.id];Number.isFinite(e)&&n&&(u=Math.min(u,e-n.topPeak*r.valueScale),d=Math.max(d,e+n.botPeak*r.valueScale))}return{adjacentClearance:s,centerlines:l,slotCenter:c,stackCenter:a,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&r.plotH>0?Math.max(0,Math.min(1,(d-u)/r.plotH)):0}}function wl(e,t){let i=0;for(const n of t){const t=e[n.source],o=e[n.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(n.value>0?n.value:1))}return i}function kl(e,t){const i=e?.samples;if(!i||0===i.length||i[0].t>t)return{top:0,bot:0};let n=0,o=i.length-1,r=0;for(;o>=n;){const e=n+o>>>1;i[e].t>t?o=e-1:(r=e,n=e+1)}const s=i[r].boundaryOffset??0;return{top:i[r].topMass-s,bot:i[r].botMass+s}}function Al(e,t,i,n,o){const r=1-o;return r*r*r*e+3*r*r*o*t+3*r*o*o*i+o*o*o*n}function Sl(e,t){let i=0,n=1;for(let o=0;28>o;o++){const o=(i+n)/2;e>Al(0,t,t,1,o)?i=o:n=o}return(i+n)/2}function Ml(e,t,i){const n=t+xl(e,i),o=e.value*i/2;return[n-o,n+o]}function _l(e,t,i,n){return Math.max(0,Math.min(t,n)-Math.max(e,i))/Math.max(1e-9,t-e)}function $l(e,t,i,n,o,r,s){const{valueScale:a,domain:c,mode:l="quality"}=s,u="source"===s.ribbonLane?.85:"target"===s.ribbonLane?.15:.5;let d=0;for(const s of e){const e=n[s.source],h=n[s.target];if(null==e||null==h||2>Math.abs(e-h))continue;const p=t[s.source]?.localAttachments.get(s.id),f=t[s.target]?.localAttachments.get(s.id);if(!p||!f)continue;const y=Math.max(s.startTime,c?.[0]??-1/0),g=Math.min(s.endTime,c?.[1]??1/0);if(y>=g)continue;const[m,x]=Ml(p,o[s.source],a),[b,v]=Ml(f,o[s.target],a),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){const n=i[e];if(!n)continue;const c=[y,g];if("quality"===l)for(const e of n.occupants)for(const i of t[e.id]?.samples??[])i.t>y&&g>i.t&&c.push(i.t);const h=e=>{const i=Sl((e-y)/(g-y),u),c=Al(m,m,b,b,i),l=Al(x,x,v,v,i);let d=0;for(const i of n.occupants){if(i.id===s.source||i.id===s.target)continue;const n=r[i.id];if(null!=n?.start&&n.start>e)continue;if(null!=n?.end&&e>n.end)continue;const u=kl(t[i.id],e),h=o[i.id];d=Math.max(d,_l(c,l,h-u.top*a,h+u.bot*a))}return d},p=[...new Set(c)].sort((e,t)=>e-t);let f=0;for(let e=0;p.length-1>e;e++){const t=p[e],i=p[e+1]-t;f+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=f/(g-y)*(s.value>0?s.value:1)}}return d}function Pl(e,t,i,n,o,r,s,a,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:wl(s,i),transitOcclusion:$l(i,n,o,r,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function jl(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Il(e,t){return e.map(e=>({t:jl(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Ll(e,t,i){const n=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){const t=e.sideMassBefore*i;if("top"===e.side){const e=n-t;return[e,e+o]}const r=n+t;return[r-o,r]}const r=e.sideMassAfter*i;if("top"===e.side){const e=n-r;return[e,e+o]}const s=n+r;return[s-o,s]}function Rl(e,t,i,n,o){if(0===e.length)return null;const r=Il(e,o),s=e=>t+(r[e].boundaryOffset??0)*i,a=e=>s(e)-r[e].topMass*i,c=e=>s(e)+r[e].botMass*i;let l=`M${n(r[0].t)},${a(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${a(e)}`;l+=` L${n(r[r.length-1].t)},${c(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${c(e)}`;return l+" Z"}function Cl(e,t,i,n,o,r){const s=i.nodeData[e];if(!s||0===s.samples.length)return[];const a=i.valueScale,c=i.centerlines[e],l=Il(s.samples,o),u=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],h=n(u.t),p=n(d.t),f=e=>n(jl(e,o)),y=[],g=(e,t,i,n)=>`M${e},${t} L${i},${t} L${i},${n} L${e},${n} Z`;for(const i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){const e=s.localAttachments.get(i.id),t=r?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&t>i.systemInTime){const n=f(i.systemInTime),r=f(t),s=null!=o&&o[0]>i.systemInTime,l=s?n:n-20,u=s?Math.min(r,n+20):n,d=Math.max(h,l);if(r>d){const[t,i]=Ll(e,c,a);y.push({pathD:g(d,t,r,i),x0:l,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){const e=s.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){const t=f(i.systemOutTime),n=f(i.endTime),o=t+20,r=Math.min(p,o);if(r>n){const[i,s]=Ll(e,c,a);y.push({pathD:g(n,i,r,s),x0:t,x1:o,from:1,to:0})}}}}return y}function Tl(e,t){const i=dl(),n=dl();for(const t of e)i[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:n}}function Ol(e,t,i,n="temporal"){const o="temporal"===n?(e,t)=>e.endTime-t.endTime||hl(e.id,t.id):(e,t)=>t.value-e.value||hl(e.id,t.id),r="temporal"===n?(e,t)=>e.startTime-t.startTime||hl(e.id,t.id):(e,t)=>t.value-e.value||hl(e.id,t.id),s=/* @__PURE__ */new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const i=/* @__PURE__ */new Map;for(const n of e){const e=n[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=i.get(e);o.edges.push(n),o.total+=n.value,o.earliestStart=Math.min(o.earliestStart,n.startTime),o.latestEnd=Math.max(o.latestEnd,n.endTime)}const s=[...i.values()];s.sort("temporal"===n?(e,i)=>"target"===t?e.earliestStart-i.earliestStart||hl(e.partner,i.partner):e.latestEnd-i.latestEnd||hl(e.partner,i.partner):(e,t)=>t.total-e.total||hl(e.partner,t.partner));for(const e of s)e.edges.sort("target"===t?r:o);return s};for(const t of e){const e=i.outgoing[t.id],n=i.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const i=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=i});else if(0===e.length)a(n,"source").forEach((e,t)=>{const i=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=i});else{const t=a(n,"source"),i=a(e,"target"),o=Math.max(t.length,i.length);for(let e=0;o>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const i of t[e].edges)s.get(i.id).targetSide=n;if(i[e])for(const t of i[e].edges)s.get(t.id).sourceSide=n}}}return s}function El(e,t,i,n,o="temporal"){const r=t.incoming[e.id],s=t.outgoing[e.id],a=[];for(const e of r)a.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(const e of s)a.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});const c={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},l=(e,t)=>{if(!n||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;const i=n.get(e.edge.id)?.target,o=n.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;const i=n.get(e.edge.id)?.source,o=n.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0},u=()=>{a.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(c[e.kind]??99)-(c[t.kind]??99)||l(e,t)||hl(e.edge?.id??"",t.edge?.id??"")||hl(e.side,t.side)||e.delta-t.delta)},d=a.length?_t(a.map(e=>e.time)):null,h=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,p=null!=h?h-1:null!=d&&Number.isFinite(d)?d-1:null;u();let f=null,y=0;for(const e of a)e.time!==f&&(f=e.time,y=0),e.sequence=y++;const g=e=>({time:e.time,phase:0,sequence:e.sequence??0}),m=[];let x=0,b=0;for(const e of a)if("out"===e.kind){const t=Math.abs(e.delta);let i=t-("top"===e.side?x:b);if(i>0){const t="top"===e.side?"bot":"top",n=Math.min(i,"top"===t?x:b);if(n>0){const o=g(e);m.push({...o,delta:-n,kind:"transfer-out",side:t}),m.push({...o,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?x-=n:b-=n,"top"===e.side?x+=n:b+=n,i-=n}i>0&&null!==p&&(m.push({time:p,delta:+i,kind:"create",side:e.side}),"top"===e.side?x+=i:b+=i)}"top"===e.side?x-=t:b-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?x+=t:b+=t}a.push(...m),u();let v=0,w=0,k=0,A=0,S=0,M=0;const _=[],$=/* @__PURE__ */new Map,P=e=>{_.push({t:e,topMass:v,botMass:w,...Math.abs(k)>1e-12&&{boundaryOffset:k}})},j=()=>{A=Math.max(A,v+w),S=Math.max(S,v-k),M=Math.max(M,w+k)};for(const e of a){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&P(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?v:w;$.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(k)>1e-12&&{boundaryOffset:k}})}"top"===e.side?v+=e.delta:w+=e.delta,"transfer-in"===e.kind?(k+="top"===e.side?e.delta:-e.delta,j(),P(e.time)):"transfer-out"!==e.kind&&(j(),"out"!==e.kind||v+w>1e-12||(k=0),P(e.time))}const I=[];let L=0;for(;_.length>L;){let e=L;for(;_.length>e+1&&_[e+1].t===_[L].t;)e++;I.push(_[L]);for(let t=L+1;e>=t;t++){const e=I[I.length-1];_[t].topMass===e.topMass&&_[t].botMass===e.botMass&&(_[t].boundaryOffset??0)===(e.boundaryOffset??0)||I.push(_[t])}L=e+1}const R=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let C=null;for(const e of s)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let T=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===T||e.systemOutTime>T)&&(T=e.systemOutTime);if(I.length>0){const e=I[I.length-1],t=Math.max(null!=R?R:-1/0,null!=T?T:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});const i=I[0],n=I.find(e=>e.topMass+e.botMass>0);let o,r=1/0;null!=h&&Number.isFinite(h)&&i.t>h&&i.topMass+i.botMass>0&&(r=h,o=i),n&&null!=C&&Number.isFinite(C)&&n.t>C&&r>C&&(r=C,o=n),o&&Number.isFinite(r)&&I.unshift({t:r,topMass:o.topMass,botMass:o.botMass,...null!=o.boundaryOffset&&{boundaryOffset:o.boundaryOffset}})}let O=I;if("max"===o&&null!=h&&null!=R&&R>h){let e,t=0;for(const i of I){const n=i.topMass+i.botMass;n>t&&(t=n,e=i)}if(e){const t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};O=[...I.filter(e=>h>e.t),{t:h,...t},{t:R,...t},...I.filter(e=>e.t>R)]}}return{samples:O,peak:A,topPeak:S,botPeak:M,localAttachments:$}}function Fl(e,t,i,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=t[r.source]?.localAttachments.get(r.id),s=t[r.target]?.localAttachments.get(r.id),a=i[r.source],c=i[r.target];if(!(e&&s&&Number.isFinite(a)&&Number.isFinite(c)))continue;const l=Ll(e,a,n),u=Ll(s,c,n);o.set(r.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return o}function Nl(e,t){const i=(e,i)=>{for(const n of e){const e=/* @__PURE__ */new Map;for(const o of n){const n=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,r="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,s=e.get(n);if(null!=s&&s!==r)return!0;e.set(n,r)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}function zl(e,t,i){const n=/* @__PURE__ */new Map,o=[];for(const t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||hl(e.edge.id,t.edge.id));const r=e=>{let t=n.get(e);return t||(t={top:0,bot:0},n.set(e,t)),t},s=(e,t,i)=>{const n="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;const r=i-o;r>0&&(e[n]=Math.max(0,e[n]-r))};for(const e of o){const{edge:n}=e;if("in"===e.kind){const e=t.get(n.id)?.targetSide??"bot";r(n.target)[e]+=n.value;continue}const o=r(n.source),a=t.get(n.id);let c=a.sourceSide??"bot";if(i[n.source]===i[n.target]){const e=o.top>=n.value,t=o.bot>=n.value;e!==t?c=e?"top":"bot":e||t||o.top===o.bot||(c=o.top>o.bot?"top":"bot"),a.sourceSide=c,a.targetSide=c}s(o,c,n.value)}}function Dl(e,t,i,n){for(const o of e){const e=t.incoming[o.id],r=t.outgoing[o.id];if(0===e.length||0===r.length)continue;const s=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===i.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of r)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},a=(e,t)=>{const o=s(),a="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,c="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=a||0>=c)return!1;const l=Math.min(a,c),u=r.filter(t=>!n.has(t.id)&&i.get(t.id).sourceSide===e&&l>=t.value).sort((e,t)=>t.value-e.value||hl(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)};let c=r.length+1;for(;c-- >0&&(a("top","bot")||a("bot","top")););}}function Bl(e){const t=dl();return e.forEach((e,i)=>{for(const n of e.occupants)t[n.id]=i}),t}function Wl(e,t,i){e.splice(0,e.length,...i);const n=Bl(i);for(const e of Object.keys(t))delete t[e];Object.assign(t,n)}function Yl(e){const t=/* @__PURE__ */new Map,i=[];e.forEach((e,n)=>{if(!e.group)return void i.push({anchor:n,stableId:pl(e),slots:[e]});const o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(n),o.slots.push(e),t.set(e.group,o)});for(const[e,n]of t)i.push({anchor:n.indexes.reduce((e,t)=>e+t,0)/n.indexes.length,stableId:`${e}\0${n.slots.map(pl).join("\0")}`,slots:n.slots});return i.sort((e,t)=>e.anchor-t.anchor||hl(e.stableId,t.stableId))}function ql(e){return e.some(e=>e.group)?Yl(e).flatMap(e=>e.slots):[...e]}function Xl(e){const t=/* @__PURE__ */new Set;for(const i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}function Gl(e){return e.flatMap(e=>e.slots)}function Vl(e,t){const i=/* @__PURE__ */new Map;for(const t of e)for(const e of t.slots)i.set(e,t);const n=/* @__PURE__ */new Map;for(const e of t){const t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;const r=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,s=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,a=n.get(s);a?a.weight=(a.weight??0)+r:n.set(s,{source:t,target:o,weight:r})}return[...n.values()]}function Hl(e,t,i){const n=/* @__PURE__ */new Map;return e.forEach((e,t)=>{for(const i of e.slots)n.set(i,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;const r=/* @__PURE__ */new Map;for(const t of e.slots)r.set(t,0);for(const e of t){const t=n.get(e.source),i=n.get(e.target);if(null==t||null==i)continue;const s=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){const t=i>o?1:-1;r.set(e.source,(r.get(e.source)??0)+s*t)}else if(i===o&&t!==o){const i=t>o?1:-1;r.set(e.target,(r.get(e.target)??0)+s*i)}}const s=[...e.slots].sort((e,t)=>(r.get(e)??0)-(r.get(t)??0)||i(e,t));return{...e,slots:s}})}function Ul(e,t){e.some(e=>e.group)&&Wl(e,t,ql(e))}function Kl(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost}function Zl({order:e,after:t,nodes:i,edges:n,outgoingPartners:o,incomingPartners:r,slotForNode:s,averageGap:a,evaluate:c}){const l=(i,o)=>{const r=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),s=e.indexOf(i),l=r[0],u=r[r.length-1];if(3>r.length||!r.includes(s)||u-l+1!==r.length||1>=Math.abs(2*s-l-u))return;const d=[...e];d.splice(s,1),d.splice(l+u>>1,0,i);const h=ql(d),p=c(h),f=new Set(i.occupants.map(e=>e.id)),y=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),g=n.reduce((e,t)=>f.has(t.source)&&y.has(t.target)||f.has(t.target)&&y.has(t.source)?e+(t.value>0?t.value:1):e,0);Kl(p,t,Math.abs(2*s-l-u)*a*Math.max(1,g))&&(e=h,t=p)};for(const[e,t]of o)r.has(e)||3>t.size||l(s.get(e),[...t].map(e=>s.get(e)));for(const e of i){const t=s.get(e.id);e.group||!t.group||3>(r.get(e.id)?.size??0)||l(t,[...r.get(e.id)??[]].map(e=>s.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}function Ql(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function Jl(e,t){return ul(t,t=>[e[t.source],e[t.target]],Ql)}function eu(e,t){let i=0;for(const n of t){const t=e[n.source],o=e[n.target];null!=t&&null!=o&&(i+=Math.abs(t-o)*(n.value>0?n.value:1))}return i}function tu(e,t,i){const[n,o]=i.get(e.first),[r,s]=i.get(e.second);return 0>(t.get(n)-t.get(r))*(t.get(o)-t.get(s))?1:0}function iu(e,t,i,n,o,r,s){const a=[...o],c=new Map(o.map(e=>[e,pl(e)])),l=/* @__PURE__ */new Map;for(const e of o)for(const t of e.occupants)l.set(t.id,e);const u=/* @__PURE__ */new Map,d=[];for(const e of t){const t=l.get(e.source),i=l.get(e.target);t&&i&&(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}const h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let i=e+1;t.length>i;i++){if(!u.has(t[i])||!Ql(t[e],t[i]))continue;const n=/* @__PURE__ */new Set([...u.get(t[e]),...u.get(t[i])]);h.push({index:h.length,first:t[e],second:t[i],involvedSlots:n})}const p=/* @__PURE__ */new Map;for(const e of o)p.set(e,[]);for(const e of h)for(const t of e.involvedSlots)p.get(t)?.push(e);const f=new Uint32Array(h.length);let y=0;const g=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=s.plotH/Math.max(1,o.length),x=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),b=Math.max(1,g)*(Math.max(1,s.plotH)+m*Math.max(x,o.length)+1e-6*Math.max(1,o.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=/* @__PURE__ */new Map,A=(e,t)=>{let n=k.get(e);n||(n=/* @__PURE__ */new Map,k.set(e,n));const o=n.get(t);if(null!=o)return o;const r=gl(e,t,i);return n.set(t,r),r},S=new Map(o.map((e,t)=>[e,t])),M=t.flatMap(e=>{const t=u.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),_=/* @__PURE__ */new Map;for(const e of t){const t=u.get(e);t&&_.set(e,{source:S.get(t[0]),target:S.get(t[1])})}const $=/* @__PURE__ */new Map,P=/* @__PURE__ */new Map,j=/* @__PURE__ */new Map,I=(e,t,i)=>{e.has(t)||e.set(t,/* @__PURE__ */new Set),e.get(t).add(i)};for(const e of t)I($,e.source,e.target),I(P,e.target,e.source),I(j,e.source,e.target),I(j,e.target,e.source);const L=e=>1===$.get(e.source)?.size&&$.get(e.source).has(e.target)||1===j.get(e.source)?.size||1===j.get(e.target)?.size,R=t.flatMap(e=>{if(!L(e))return[];const t=_.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),C=e=>{let t=0;for(const i of R)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*v},T=e=>{const t=new Int16Array(o.length);for(let i=0;e.length>i;i++)t[S.get(e[i])]=i;return C(t)},O=h.map(e=>{const t=_.get(e.first),i=_.get(e.second);return[t.source,t.target,i.source,i.target]}),E=new Int16Array(o.length),F=new Float64Array(o.length),N=new Float64Array(o.length+1),z=e=>{for(let t=0;e.length>t;t++)E[S.get(e[t])]=t;let t=0;for(const[e,i,n,o]of O)0>(E[e]-E[n])*(E[i]-E[o])&&t++;if(e.length>0){const t=S.get(e[0]);F[t]=s.padding+e[0].peak.topPeak*s.valueScale;for(let t=1;e.length>t;t++){const i=S.get(e[t-1]),n=S.get(e[t]);F[n]=F[i]+A(e[t-1],e[t])*s.valueScale+s.padding}const i=S.get(e[e.length-1]),n=F[i]+e[e.length-1].peak.botPeak*s.valueScale+s.padding;if(n>s.plotH&&n>0){const e=s.plotH/n;for(let t=0;F.length>t;t++)F[t]*=e}}N[0]=0;for(let t=0;e.length>t;t++)N[t+1]=N[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,n=0,o=0;for(const e of M){const t=E[e.source],r=E[e.target];if(i+=Math.abs(t-r)*e.weight,n+=Math.abs(F[e.source]-F[e.target])*e.weight,Math.abs(t-r)>=2){const i=Math.min(t,r)+1;o+=(N[Math.max(t,r)]-N[i])*e.weight}}return t*b+n+o*m+C(E)+1e-6*i},D=(e,i)=>{const n=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)n[t+1]=n[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(const e of t){const t=i[e.source],r=i[e.target];if(null==t||null==r||2>Math.abs(t-r))continue;const s=Math.min(t,r)+1;o+=(n[Math.max(t,r)]-n[s])*(e.value>0?e.value:1)}return o},B=n=>{const o=Bl(n),r=n.slice(0,-1).map((e,t)=>A(e,n[t+1])),a=vl(e,t,i,n,o,{plotH:s.plotH,padding:s.padding,valueScale:s.valueScale,lanePlacement:s.lanePlacement??"stack",groupPadding:s.groupPadding,adjacentClearance:r});return{map:o,geometry:a,weightedLength:eu(o,t),pixelLength:wl(a.centerlines,t),transitOcclusion:D(n,o)}},W=(e,t,i)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*b+t.pixelLength+t.transitOcclusion*m+T(i)+1e-6*t.weightedLength}),Y=(e,t)=>{let i=t;if(null==i){const t=new Map(e.map((e,t)=>[e,t]));i=h.reduce((e,i)=>e+tu(i,t,u),0),w.fullCrossing++}return W(i,B(e),e)},q=(e,o,r="quality")=>{let a=o;if(null==a){const t=new Map(e.map((e,t)=>[e,t]));a=h.reduce((e,i)=>e+tu(i,t,u),0),w.fullCrossing++}const c=B(e);return W(a,{...c,transitOcclusion:$l(t,i,e,c.map,c.geometry.centerlines,n,{valueScale:s.valueScale,ribbonLane:s.ribbonLane,domain:s.domain,mode:r})},e)};let X=[...a];const G=(e,t)=>hl(c.get(e),c.get(t)),V=Xl(X),H=e=>{const t=al(e,d,e=>Y(e).cost,{passes:6,compare:G,maxEvaluations:FM});let i=Y(t),n=FM;for(let e=0;6>e&&n>0;e++){let o=!1;const r=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&r.reverse();for(const e of r){if(0>=n--)break;const r=t[e],s=t[e+1],a=new Map(t.map((e,t)=>[e,t]));let c=0;const l=[];y++;for(const e of[...p.get(r)??[],...p.get(s)??[]])f[e.index]!==y&&(f[e.index]=y,l.push(e),c+=tu(e,a,u));[t[e],t[e+1]]=[s,r];const d=new Map(a);d.set(r,e+1),d.set(s,e);let h=0;for(const e of l)h+=tu(e,d,u);w.localCrossing+=l.length;const g=Y(t,i.crossings-c+h);i.cost>g.cost?(i=g,o=!0):[t[e],t[e+1]]=[r,s]}if(!o)break}return t},U=e=>{const t=H(e);if((e.length>8?1/0:OM(e.length)*(e.length+M.length+O.length))>EM)return t;const i=ll(e,z,{maxItems:8,maxEvaluations:5e4}),n=q(i),o=q(t);return n.crossings!==o.crossings&&o.crossings>n.crossings?i:t},K="geometry-refine"===s.mode;if(K||"crossing-min"!==s.laneOrder&&"crossing-min+inside-out"!==s.laneOrder){if(!K&&"inside-out"===s.laneOrder)if(V){const e=Yl(X),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),i=[...e].sort((e,i)=>t(i)-t(e)||hl(e.stableId,i.stableId)),n=Array(i.length);let o=Math.floor((i.length-1)/2)-1,r=Math.floor((i.length-1)/2)+1;i.length>0&&(n[Math.floor((i.length-1)/2)]=i[0]);for(let e=1;i.length>e;e++)e%2==1&&i.length>r||0>o?n[r++]=i[e]:n[o--]=i[e];X=Gl(n)}else{const e=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||G(e,t)),t=Array(e.length);let i=Math.floor((e.length-1)/2)-1,n=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>n||0>i?t[n++]=e[o]:t[i--]=e[o];X=t}}else X=V?(e=>{let t=Yl(e);if(1>=t.length)return Gl(t);const i=e=>Y(Gl(e)).cost;t=Yl(U(e)),t=Hl(t,d,G),t=al(t,Vl(t,d),i,{passes:6,compare:(e,t)=>hl(e.stableId,t.stableId),maxEvaluations:FM}),t=cl(t,i,{passes:8,maxEvaluations:FM});const n=t.length>8?1/0:OM(t.length)*(t.length+M.length+O.length);if(EM>=n){const e=ll(t,e=>z(Gl(e)),{maxItems:8,maxEvaluations:5e4}),i=Gl(e),n=Gl(t),o=q(i),r=q(n);o.crossings!==r.crossings?t=r.crossings>o.crossings?e:t:r.cost>o.cost&&(t=e)}return t=Hl(t,d,G),Gl(t)})(X):U(X);if(!K&&"crossing-min+inside-out"===s.laneOrder&&X.length>1)if(V){const e=Yl(X);let t=Y(Gl(e)),i=Gl(e),n=t;const o=Math.floor((e.length-1)/2),r=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),s=[...e].sort((e,t)=>r(t)-r(e)||hl(e.stableId,t.stableId));for(const r of s){const s=e.indexOf(r);if(s===o)continue;e.splice(s,1),e.splice(o,0,r);const a=Gl(e),c=Y(a);c.cost>t.cost?(e.splice(o,1),e.splice(s,0,r)):(t=c,n.cost>c.cost&&(i=a,n=c))}X=i}else{let e=Y(X),t=[...X],i=e;const n=Math.floor((X.length-1)/2),o=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||G(e,t));for(const r of o){const o=X.indexOf(r);if(o===n)continue;X.splice(o,1),X.splice(n,0,r);const s=Y(X);s.cost>e.cost?(X.splice(n,1),X.splice(o,0,r)):(e=s,i.cost>s.cost&&(t=[...X],i=s))}X=t}if((K||"crossing-min"===s.laneOrder||"crossing-min+inside-out"===s.laneOrder)&&X.length>1)if(V){let e=Yl(X),t=q(Gl(e),void 0,"score");for(let i=0;6>i&&e.length>1;i++){let i=!1;for(let n=0;e.length-1>n;n++){[e[n],e[n+1]]=[e[n+1],e[n]];const o=Gl(e),r=q(o,void 0,"score");t.cost>r.cost?(X=o,t=r,i=!0):[e[n],e[n+1]]=[e[n+1],e[n]]}if(!i)break}e=Hl(Yl(X),d,G),X=Gl(e)}else{let e=q(X,void 0,"score");for(let t=0;X.length-1>t;t++){const i=X[t],n=X[t+1],o=new Map(X.map((e,t)=>[e,t]));let r=0;const s=[];y++;for(const e of[...p.get(i)??[],...p.get(n)??[]])f[e.index]!==y&&(f[e.index]=y,s.push(e),r+=tu(e,o,u));[X[t],X[t+1]]=[n,i];const a=new Map(o);a.set(i,t+1),a.set(n,t);let c=0;for(const e of s)c+=tu(e,a,u);w.localCrossing+=s.length;const l=q(X,e.crossings-r+c,"score");e.cost>l.cost?e=l:[X[t],X[t+1]]=[i,n]}}const Z=ql(a);X=ql(X);let Q=q(X);const J=q(Z);if(K){const e=T(Z),t=T(X);(Q.crossings>J.crossings||Q.crossings===J.crossings&&t>e+1e-9||Q.cost>J.cost)&&(X=Z,Q=J)}else Q.cost>J.cost&&(X=Z,Q=J);const ee=Zl({order:X,after:Q,nodes:e,edges:t,outgoingPartners:$,incomingPartners:P,slotForNode:l,averageGap:m,evaluate:q});return X=ee.order,Q=ee.after,Wl(o,r,X),{before:J,after:Q,initialOrder:a.map(e=>c.get(e)),evaluations:w}}function nu(e,t,i){const n=new Map(i.map((e,t)=>[e,t]));Wl(e,t,[...e].sort((e,t)=>(n.get(pl(e))??1/0)-(n.get(pl(t))??1/0)||hl(pl(e),pl(t))))}function ou(e,t,i){const n=e.map(e=>{const n=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end}));let o=0,r=0;for(const e of n){const i=t[e.id];o=Math.max(o,i?.topPeak||0),r=Math.max(r,i?.botPeak||0)}return{occupants:n,peak:{topPeak:o,botPeak:r},...null!=e.group?{group:e.group}:{}}}),o=dl();return n.forEach((e,t)=>{for(const i of e.occupants)o[i.id]=t}),{slots:n,slotByNode:o}}function ru(e,t,i,n){return`${e.map(e=>{const t=i[e.id],o=n[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}function su(e,t){for(NM.has(e)&&NM.delete(e),NM.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(dl(),t.slotByNode)});NM.size>12;){const e=NM.keys().next().value;if(null==e)break;NM.delete(e)}}function au(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function cu(e,t){return hl(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function lu(e){const t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const n of e)i.has(n.source)||i.set(n.source,/* @__PURE__ */new Set),t.has(n.target)||t.set(n.target,/* @__PURE__ */new Set),i.get(n.source).add(n.target),t.get(n.target).add(n.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function uu(e){const t=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map,n=(e,t,i,n)=>{let o=e.get(t);o||(o=/* @__PURE__ */new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+n)};for(const o of e){const e=o.value>0&&Number.isFinite(o.value)?o.value:1;n(t,o.source,o.target,e),n(i,o.target,o.source,e)}const o=/* @__PURE__ */new Map,r=e=>{if(o.has(e))return;const n=t.get(e),r=i.get(e),s=/* @__PURE__ */new Map;for(const[e,t]of n??[])s.set(e,(s.get(e)??0)+t);for(const[e,t]of r??[])s.set(e,(s.get(e)??0)+t);if(1===s.size){const[t,i]=[...s][0];o.set(e,{partner:t,weight:i})}};for(const t of e)r(t.source),r(t.target);return o}function du(e,t,i){const n=i.get(e),o=i.get(t);return!n||!o||n.partner===o.partner||n.partner===t||o.partner===e}function hu(e,t,i){return!!i.has(e)&&t.some(t=>!du(e,t,i))}function pu(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function fu(e,t,i,n,o,r){const s=/* @__PURE__ */new Set,a=new Map(e.map(e=>[e,/* @__PURE__ */new Set])),c=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of n)s.add(cu(e.source,e.target)),a.get(e.target)?.add(e.source),c.get(e.source)?.add(e.target);const l=/* @__PURE__ */new Map,u=/* @__PURE__ */new Set,d=(e,t)=>{for(let i=0;e.length>i;i++)for(let n=i+1;e.length>n;n++){const o=cu(e[i],e[n]);t instanceof Map?t.set(o,[e[i],e[n]]):t.add(o)}};for(const e of c.values())d([...e],l);for(const e of a.values())d([...e],u);const h=/* @__PURE__ */new Set;for(const[e,[n,o]]of l)u.has(e)&&(au(t[n],t[o])||au(i[n],i[o])&&(h.add(n),h.add(o)));return{conflicts:(e,i)=>{const n=o.get(e),a=o.get(i);return null!=n&&null!=a&&n!==a||!(null!=n==(null!=a)||s.has(cu(e,i))||r.has(e)&&r.has(i)&&du(e,i,r))||!!au(t[e],t[i])||!(!h.has(e)&&!h.has(i))&&!s.has(cu(e,i))}}}function yu(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||hl(e.id,i.id)).map(e=>e.id)}function gu(e,t,i=/* @__PURE__ */new Map){const n=[],o=[];for(const r of e){let e=n.findIndex(e=>e.every(e=>!t.conflicts(r,e))&&!hu(r,e,i));-1!==e||i.has(r)||(e=n.findIndex(e=>e.every(e=>!t.conflicts(r,e)))),-1===e&&(e=n.length,n.push([])),n[e].push(r),o.push(e)}return{assignment:o,slotCount:n.length}}function mu(e,t,i,n){if(12>=e.length||1>=n.slotCount)return n.assignment;const o=new Map(e.map((e,t)=>[e,t])),r=Array.from({length:e.length},()=>/* @__PURE__ */new Map),s=lu(i);for(const e of i){const t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;const n=pu(e,s);r[t].set(i,(r[t].get(i)??0)+n),r[i].set(t,(r[i].get(t)??0)+n)}const a=uu(i),c=e.map(e=>a.get(e)?.weight??0),l=Array.from({length:e.length},()=>/* @__PURE__ */new Map);let u=0;for(let i=0;e.length-1>i&&5e4>u;i++)if(a.has(e[i]))for(let n=i+1;e.length>n;n++){if(!a.has(e[n]))continue;if(t.conflicts(e[i],e[n]))continue;u++;const o=Math.min(c[i],c[n])||Math.max(c[i],c[n]),r=du(e[i],e[n],a)?o:-o;if(Math.abs(r)>DM&&(l[i].set(n,r),l[n].set(i,r),u>=5e4))break}const d=[...n.assignment],h=Array.from({length:n.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));const p=(e,t,i)=>{const n=d[t],o=d[i];let r=0;const s=/* @__PURE__ */new Set;for(const a of[t,i])for(const[c,l]of e[a]){const e=c>a?`${a}:${c}`:`${c}:${a}`;if(s.has(e))continue;s.add(e);const u=(a===t?o:n)===(c===t?o:c===i?n:d[c]);d[a]===d[c]!==u&&(r+=u?l:-l)}return r},f=(e,t,i)=>{let n=0;for(const[o,r]of e[t]){const e=i===d[o];d[t]===d[o]!==e&&(n+=e?r:-r)}return n},y=(e,t)=>e>DM||DM>=Math.abs(e)&&t>DM,g=(e,t,i,n)=>e>i+DM||DM>=Math.abs(e-i)&&t>n+DM;let m=0;for(let i=0;32>i&&zM>m;i++){let i=null,n=-1,o=-1,s=-1,a=-1/0,c=-1/0;for(let u=0;e.length>u;u++){for(let p=0;h.length>p&&m++<zM;p++){if(p===d[u])continue;if(!h[p].every(i=>!t.conflicts(e[u],e[i])))continue;const m=f(r,u,p),x=f(l,u,p);y(m,x)&&g(m,x,a,c)&&(i="move",n=u,o=-1,s=p,a=m,c=x)}if(m>=zM)break}for(let u=0;e.length-1>u;u++){for(let f=u+1;e.length>f&&m++<zM;f++){const m=d[u],x=d[f];if(m===x)continue;if(!h[x].every(i=>i===f||!t.conflicts(e[u],e[i])))continue;if(!h[m].every(i=>i===u||!t.conflicts(e[f],e[i])))continue;const b=p(r,u,f),v=p(l,u,f);y(b,v)&&g(b,v,a,c)&&(i="swap",n=u,o=f,s=-1,a=b,c=v)}if(m>=zM)break}if(null==i||-1===n)break;if("move"===i){const e=d[n];h[e].splice(h[e].indexOf(n),1),h[s].push(n),d[n]=s;continue}const u=d[n],x=d[o];h[u].splice(h[u].indexOf(n),1,o),h[x].splice(h[x].indexOf(o),1,n),d[n]=x,d[o]=u}return d}function xu(e,t){for(let i=0;Math.min(e.length,t.length)>i;i++)if(e[i]!==t[i])return t[i]>e[i];return t.length>e.length}function bu(e,t,i,n){if(0===e.length||e.length>12||1>=n.slotCount)return n.assignment;const o=new Map(e.map((e,t)=>[e,t])),r=Array.from({length:e.length},()=>new Float64Array(e.length)),s=Array.from({length:e.length},()=>/* @__PURE__ */new Map),a=Array.from({length:e.length},()=>/* @__PURE__ */new Map),c=lu(i);for(const e of i){const t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;const n=pu(e,c);r[t][i]+=n,r[i][t]+=n,a[t].set(i,(a[t].get(i)??0)+n),s[i].set(t,(s[i].get(t)??0)+n)}const l=uu(i),u=e.map(e=>l.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let i=t+1;e.length>i;i++){for(const[e,n]of s[t])d[t][i]+=Math.min(n,s[i].get(e)??0);for(const[e,n]of a[t])d[t][i]+=Math.min(n,a[i].get(e)??0);if(l.has(e[t])&&l.has(e[i])){const n=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=du(e[t],e[i],l)?n:-n}d[i][t]=d[t][i]}let h=[...n.assignment],p=(t=>{let i=0,n=0;for(let o=0;e.length>o;o++)for(let s=o+1;e.length>s;s++)t[o]===t[s]&&(i+=r[o][s],n+=d[o][s]);return{flow:i,affinity:n}})(h),f=0;const y=Array(e.length).fill(-1),g=Array.from({length:n.slotCount},()=>[]),m=(i,o,s,a)=>{if(f>=75e3)return;if(i===e.length)return f++,void((s>p.flow||s===p.flow&&a>p.affinity||s===p.flow&&a===p.affinity&&xu(y,h))&&(h=[...y],p={flow:s,affinity:a}));const c=Math.min(o+1,n.slotCount-1);for(let n=0;c>=n;n++){if(g[n].some(n=>t.conflicts(e[i],e[n])))continue;let c=0,l=0;for(const e of g[n])c+=r[i][e],l+=d[i][e];if(y[i]=n,g[n].push(i),m(i+1,Math.max(o,n),s+c,a+l),g[n].pop(),y[i]=-1,f>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}function vu(e,t){let i=1/0,n=-1/0;for(const t of e?.samples??[])t.topMass+t.botMass>1e-9&&(i=Math.min(i,t.t),n=Math.max(n,t.t));return Number.isFinite(i)&&Number.isFinite(n)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(n=Math.min(n,t.end)),i>n?{start:null,end:null}:{start:i,end:n}):{start:null,end:null}}function wu(e,t,i,n){const o=ru(e,t,i,n),r=NM.get(o);if(r)return ou(r.slots,i,n);const s=dl();for(const t of e)s[t.id]=vu(i[t.id],n[t.id]);const a=yu(e,s),c=new Map(e.map(e=>[e.id,e])),l=new Map(e.map(e=>[e.id,e.group||void 0])),u=uu(t),d=fu(a,s,n,t,l,u),h=gu(a,d,u),p=bu(a,d,t,{...h,assignment:mu(a,d,t,h)}),f=/* @__PURE__ */new Map,y=p.map(e=>(f.has(e)||f.set(e,f.size),f.get(e))),g=Array.from({length:f.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=dl();a.forEach((e,t)=>{const i=y[t],n=g[i];n.occupants.push({id:e,end:s[e].end??-1/0});const o=c.get(e)?.group;o&&(n.group=o),m[e]=i});for(const t of[...e].sort((e,t)=>hl(e.id,t.id)))null==m[t.id]&&(g[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(const e of g){e.occupants.sort((e,t)=>(s[e.id].start??1/0)-(s[t.id].start??1/0)||hl(e.id,t.id));for(const t of e.occupants){const n=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,n?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,n?.botPeak||0)}}const x={slots:g,slotByNode:m};return su(o,x),x}function ku(e){return e.topMass+e.botMass}function Au(e){const t=/* @__PURE__ */new Map;for(const i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,n=-1/0;return o=>{n>o&&(i=0),n=o;const r=t.get(o);if(r){const e=r.reduce((e,t)=>ku(t)<ku(e)?e:t,r[0]);return{exact:r,sample:e}}for(;e.samples.length>i&&o>=e.samples[i].t;)i++;return{exact:r,sample:e.samples[i-1]??null}}}function Su(e,t,i,n,o,r,s=0){const a=/* @__PURE__ */new Map;for(const i of e){if(!i.group||!t[i.id])continue;const e=a.get(i.group)??[];e.push(i),a.set(i.group,e)}if(0===a.size||0>=r)return t;const c=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(const[e,l]of a){const a=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===a.length)continue;const u=a[0].slot,d=a.at(-1).slot,h=o[u.occupants[0]?.id],p=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(p))continue;const f=(h-u.peak.topPeak*r+(p+d.peak.botPeak*r))/2,y=[...new Set(l.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),g=/* @__PURE__ */new Map;for(const e of l)g.set(e.id,/* @__PURE__ */new Map);const m=new Map(l.map(e=>[e.id,Au(t[e.id])]));for(const e of y){const t=/* @__PURE__ */new Map;for(const i of l){const{sample:o}=m.get(i.id)(e);if(!o||1e-9>=ku(o))continue;const r=n[i.id];if(null==r)continue;const s=t.get(r)??[];s.push({node:i,sample:o}),t.set(r,s)}const i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>ku(e)))}));if(0===i.length)continue;let a=f-(i.reduce((e,t)=>e+t.mass,0)*r+Math.max(0,s)*Math.max(0,i.length-1))/2;for(const t of i){for(const{node:i,sample:n}of t.active){const t=(a-o[i.id])/r+n.topMass-(n.boundaryOffset??0);g.get(i.id).set(e,t)}a+=t.mass*r+Math.max(0,s)}}for(const e of l){const i=t[e.id],n=c[e.id],o=g.get(e.id),r=m.get(e.id),s=[];for(const e of y){const t=o.get(e),{exact:i,sample:n}=r(e);i?s.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null!=t&&n&&ku(n)>1e-9&&s.push({...n,t:e,boundaryOffset:(n.boundaryOffset??0)+t})}n.samples=s,n.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{const i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return c}function Mu(e,t,i,n,o){const{plotH:r,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:p="both",domain:f}=o,y=dl(),g=dl();for(const t of e)y[t.id]=i[t.id].topPeak||0,g[t.id]=i[t.id].botPeak||0;const m="half"===u,x=dl();for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,r=null!=i&&Number.isFinite(i)?i:-1/0;for(const e of n.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=m?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(r)?r:null}}let b=dl(),v=[],w=[];if(o.frozenSlots){const e=ou(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(pl)}else if("reuse"===c){const n=wu(e,t,i,x);v=n.slots,b=n.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:y[e.id],botPeak:g[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});Ul(v,b),0===w.length&&(w=v.map(pl));let k=null;o.frozenSlots||(o.fixedSlotOrder?nu(v,b,o.fixedSlotOrder):o.runOrdering&&l&&"insertion"!==l&&(k=iu(e,t,i,x,v,b,{plotH:r,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:p,domain:f}))),Ul(v,b);const A=vl(e,t,i,v,b,{plotH:r,padding:s,valueScale:a,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,$=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(pl),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:$,lengthAfter:P}}function _u(e,t,i){const{plotH:n,pairing:o="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half",maxValueScale:c,lanePlacement:l="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:p}=i,f=Number.isFinite(d)?Math.max(0,d):0,y=Tl(e,t),g=Ol(e,t,y,o);let m=dl();for(const t of e)m[t.id]=El(t,y,g,void 0,u);const x=Mu(e,t,m,y,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,runOrdering:!0,lanePlacement:"stack",groupPadding:f,ribbonLane:h,domain:p}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=/* @__PURE__ */new Set;for(const e of t){const t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;const n=g.get(e.id);t!==i?t>i?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(v.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=y.outgoing[t.id],i=y.incoming[t.id],n=new Set(e.map(e=>g.get(e.id).sourceSide)),o=new Set(i.map(e=>g.get(e.id).targetSide));if(1===n.size&&i.length>0){const e=[...n][0];for(const t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(g.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(g.get(i.id).sourceSide=t)}}zl(t,g,x.slotByNode),Dl(e,y,g,v),m=dl();for(const t of e)m[t.id]=El(t,y,g,void 0,u);const w=Mu(e,t,m,y,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:"stack",groupPadding:f,ribbonLane:h,domain:p}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*n-A*f)/S),_=2*M+fl(w.slots,M,f).reduce((e,t)=>e+t,0),$=k>0?Math.max(0,(n-_)/k):1,P=Number.isFinite(c)&&c>0?Math.min($,c):$;let j=Mu(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:b,lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$});const I=Number.isFinite(c)&&c>0&&$>c+1e-12;if("insertion"!==s&&("hug"===l||I)&&j.slots.length>1&&(iu(e,t,m,j.laneLifetime,j.slots,j.slotByNode,{plotH:n,padding:M,valueScale:P,groupPadding:f,laneOrder:s,ribbonLane:h,domain:p,lanePlacement:l,mode:"geometry-refine"}),j=Mu(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(pl),lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$})),Nl(y,g)){const i=Fl(t,m,j.centerlines,P);m=dl();for(const t of e)m[t.id]=El(t,y,g,i,u);j=Mu(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(pl),lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$})}const L=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),R=[...j.slots].sort((e,t)=>(L.get(pl(e))??1/0)-(L.get(pl(t))??1/0)||hl(pl(e),pl(t))),C=dl();R.forEach((e,t)=>{for(const i of e.occupants)C[i.id]=t});const T=vl(e,t,m,R,C,{plotH:n,padding:M,valueScale:P,stackValueScale:$,lanePlacement:"stack",groupPadding:f}),O=Su(e,m,R,C,T.centerlines,P,f),E=Pl(Jl(C,t),eu(C,t),t,O,R,C,T.centerlines,j.laneLifetime,P,T.verticalUtilization,h,p);m=Su(e,m,j.slots,j.slotByNode,j.centerlines,P,f);const F=Pl(Jl(j.slotByNode,t),eu(j.slotByNode,t),t,m,j.slots,j.slotByNode,j.centerlines,j.laneLifetime,P,j.verticalUtilization,h,p);return{nodeData:m,sides:g,valueScale:P,padding:M,compressedPadding:12>M,centerlines:j.centerlines,laneLifetime:j.laneLifetime,slots:j.slots,slotByNode:j.slotByNode,crossingsBefore:"insertion"===s?null:E.crossings,crossingsAfter:"insertion"===s?null:F.crossings,lengthBefore:"insertion"===s?null:E.weightedLength,lengthAfter:"insertion"===s?null:F.weightedLength,layoutQualityBefore:E,layoutQuality:F}}function $u(e){const{sx:t,sTop:i,sBot:n,tx:o,tTop:r,tBot:s,cp1X:a,cp2X:c}=e,l=(i+n)/2,u=(r+s)/2;return{pathD:[`M${t},${i}`,`C${a},${i} ${c},${r} ${o},${r}`,`L${o},${s}`,`C${c},${s} ${a},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(n-i)/2}}}function Pu(e,t,i,n,o,r,s,a,c={}){const l=o,u=e=>a?Math.max(a[0],Math.min(a[1],e)):e;let d=r(u(e.time));const h=r(u(i.time)),p=e.value*l,f=i.value*l,y=t+(e.boundaryOffset??0)*l,g=n+(i.boundaryOffset??0)*l,m=e.sideMassBefore*l,x=i.sideMassAfter*l;let b,v,w,k;"top"===e.side?(b=y-m,v=b+p):(v=y+m,b=v-p),"top"===i.side?(w=g-x,k=w+f):(k=g+x,w=k-f);const A=c.sourceRunwayStart,S=c.minRun,M=Math.abs((w+k)/2-(b+v)/2),_=h-d,$="number"==typeof A&&Number.isFinite(A),P="number"==typeof S&&Number.isFinite(S)&&S>0;if($&&M>1e-9&&_>0&&("auto"===S||P)){const t="source"===s?.85:"target"===s?.15:.5,i="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(i>_){const t=r(u(Math.min(A,e.time)));Number.isFinite(t)&&(d=Math.min(d,Math.max(Math.min(d,t),h-i)))}}const j="source"===s?d+.85*(h-d):"target"===s?d+.15*(h-d):(d+h)/2;return{sx:d,sTop:b,sBot:v,tx:h,tTop:w,tBot:k,cp1X:j,cp2X:j}}function ju(e,t,i,n,o,r){const s=new Map(t),a=/* @__PURE__ */new Map;for(const t of e){const e=r?.get(t.source),i=null==e?"node:"+t.source:"group:"+e,n=a.get(i)??/* @__PURE__ */new Map,o=n.get(t.startTime)??[];o.push(t),n.set(t.startTime,o),a.set(i,n)}for(const e of a.values())for(const[r,a]of e){if(!a.some(e=>i.has(e.id)))continue;const e=a.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;const c=n(r),l=Math.min(...e.map(e=>e.sx));if(l>=c-1e-9)continue;const u=Math.max(...a.map(e=>{const t=i.get(e.id);return null==t?c:Math.min(c,n(t))})),d=Math.min(c,Math.max(l,u));for(const e of a){const i=t.get(e.id),n=d+(i.tx-d)*("source"===o?.85:"target"===o?.15:.5);s.set(e.id,{...i,sx:d,cp1X:n,cp2X:n})}}return s}function Iu(e,t,i){const n=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),r=/* @__PURE__ */new Map;for(const e of t){if(n.has(e.source))continue;const t=r.get(e.source)??[];t.push(e),r.set(e.source,t)}const s=/* @__PURE__ */new Map;for(const t of e){if(!t.group)continue;const e=s.get(t.group)??[];e.push(t),s.set(t.group,e)}const a=/* @__PURE__ */new Set;for(const[e,t]of s){const i=t.flatMap(e=>r.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{const t=e.xExtent?.[0],o=i[0].startTime;return!n.has(e.id)&&(r.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&a.add(e)}const c=/* @__PURE__ */new Map;for(const[e,t]of r){const n=o.get(e);if(n?.group&&!a.has(n.group))continue;const r=n?.xExtent?.[0],s=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),l=s[0]?.startTime-1;let u=null;for(let e=0;s.length>e;){const t=s[e].startTime;let n=e+1;for(;s.length>n&&s[n].startTime===t;)n++;for(let t=e;n>t;t++){const e=s[t],n=Number.isFinite(r)&&e.startTime>r,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!n&&!o)continue;let a=i[0];n&&(a=Math.max(a,r)),o&&(a=Math.max(a,e.systemInTime)),!n&&o&&Number.isFinite(l)&&(a=Math.max(a,l)),null!=u&&(a=Math.max(a,u)),e.startTime>a&&c.set(e.id,a)}u=t,e=n}}for(const[e,t]of s){if(!a.has(e))continue;const i=t.flatMap(e=>r.get(e.id)??[]);if(!i.every(e=>c.has(e.id))){for(const e of i)c.delete(e.id);continue}const n=Math.max(...i.map(e=>c.get(e.id)));for(const e of i)c.set(e.id,n)}return c}function Lu(e,t,i,n,o){const r=/* @__PURE__ */new Map;for(const s of e){if(!i.has(s.id))continue;const e=t.get(s.id);if(!e||e.sx>=n(s.startTime)-1e-9)continue;const a=o(e.sx);Number.isFinite(a)&&s.startTime>a&&r.set(s.id,a)}return r}function Ru(e,t,i){const n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map;for(const[e,t]of i??[]){const i=o.get(t)??[];i.push(e),o.set(t,i)}for(const r of e){const e=t.get(r.id);if(null==e||!Number.isFinite(e)||e>=r.startTime)continue;const s=i?.get(r.source),a=null==s?[r.source]:o.get(s)??[r.source];for(const t of a){const i=n.get(t)??/* @__PURE__ */new Map,o=i.get(r.startTime);i.set(r.startTime,null==o?e:Math.min(o,e)),n.set(t,i)}}return n}function Cu(e){return Math.max(18,11*e.length*.58)}function Tu(e){const t=1.22*Cu(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Ou(e,t){const i=e.labelX-Cu(e.labelText),n=t.labelX-Cu(t.labelText);return t.labelX+3>=i&&e.labelX+3>=n}function Eu(e,t){const i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;i.length>e;e+=1){let t=8;for(let n=0;e>n;n+=1)Ou(i[e],i[n])&&(t=Math.max(t,i[n].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let n=t-8;for(let t=e+1;i.length>t;t+=1)Ou(i[e],i[t])&&(n=Math.min(n,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,n)}}}function Fu(e,t,i){const n=e.map(e=>({...e})),o=/* @__PURE__ */new Map;for(const e of n){const i=t[e.id];if(null==i)continue;const n=o.get(i)??[];n.push(e),o.set(i,n)}const r=e=>{if(2>e.length)return;const t=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-n)))})};for(const e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(const n of e){const e=n.labelX-Cu(n.labelText);t.length>0&&e>i+3&&(r(t),t=[],i=-1/0),t.push(n),i=Math.max(i,n.labelX)}r(t)}return Eu(n,i),n}function Nu(e,t,i){const n=e.map(e=>({...e}));for(const e of n){const i=1.22*Cu(e.labelText)+4;e.labelX=t-4>i?Math.max(i/2+2,Math.min(t-i/2-2,e.labelX)):t/2}const o=[],r=[...n].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(const e of r){const t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(const e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));const t=[],n=/* @__PURE__ */new Map;for(const i of e){const[e,o]=Tu(i);let r=t.findIndex(t=>e>t+8);-1===r&&(r=t.length),t[r]=o,n.set(i,r)}const o=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=14*t.length+8>o;for(const t of e){const e=n.get(t)??0;t.labelY=r?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return n}function zu(e,t,i,n,o={}){if(!1===n)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===n)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let r=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*i)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(r=Math.min(r,Math.floor(o.maxLabels)));const s=e.map((e,t)=>{const i=o.priorityById?.get(e.id),n=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+Cu(e.labelText):Cu(e.labelText)+.01*n}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),a=new Set(s.slice(0,r).map(e=>e.band.id));return e.map(e=>a.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}function Du(e){return e.replace(BM,(e,t,i)=>`${i},${t}`)}function Bu(e){if(!e)return;const t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Wu(e){return{...e,pathD:Du(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Yu(e,t){return"horizontal"===t?e:{...e,pathD:Du(e.pathD),gradientStubs:e.gradientStubs?.map(Wu),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function qu(e,t){return"horizontal"===t?e:{...e,pathD:Du(e.pathD),bezier:Bu(e.bezier)}}function Xu(e){const{nodes:t,edges:i,domain:n,plotW:o,plotH:r,ribbonLane:s,ribbonMinRun:a=0,edgeOpacity:c,colorOf:l,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:p,maxLabels:f,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?r:o,w="vertical"===d?o:r,k=tl(t,i,n,{usageMode:b}),{fatal:A,warnings:S}=el(k),M=il(i,k,b),_=(0,RM.scaleTime)().domain(n).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:_};const $=_u(t,M,{plotH:w,...u,ribbonLane:s,domain:n}),{centerlines:P,nodeData:j,valueScale:I}=$,L=rt(m,x),R=[],C=[],T=0===a?/* @__PURE__ */new Map:Iu(t,M,n),O=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),E=/* @__PURE__ */new Map;for(const e of M){const t=j[e.source]?.localAttachments.get(e.id),i=j[e.target]?.localAttachments.get(e.id);t&&i&&E.set(e.id,Pu(t,P[e.source],i,P[e.target],I,_,s,n,{minRun:a,sourceRunwayStart:T.get(e.id)}))}const F=ju(M,E,T,_,s,O),N=Lu(M,F,T,_,e=>n[0]+e/v*(n[1]-n[0])),z=Ru(M,N,O);t.forEach((e,t)=>{const i=j[e.id];if(!i||0===i.samples.length)return;const o=(r=i.samples,(s=z.get(e.id))&&0!==s.size?r.map(e=>{const t=s.get(e.t);return null==t?e:{...e,t:t}}):r);var r,s;const a=Rl(o,P[e.id],I,_,n);if(!a)return;const c=Il(o,n),u=c.find(e=>e.topMass+e.botMass>0)||c[0],h=P[e.id]+(u.botMass-u.topMass+2*(u.boundaryOffset??0))*I/2;let p,f,y=l(e.id,t),m=y,x=.5;const b=e.__raw??e;if(g&&g.length>0){const e=lt(b,g,L(b));"string"==typeof e.fill?y=e.fill:null!=e.fill&&Mr(e.fill)&&(f=e.fill,y=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:y),"string"==typeof e.stroke&&(m=e.stroke),"number"==typeof e.strokeWidth&&(x=e.strokeWidth),"number"==typeof e.fillOpacity&&(p=e.fillOpacity),"number"==typeof e.opacity&&null==p&&(p=e.opacity)}const v=Cl(e.id,M,$,_,n,N);R.push({id:e.id,pathD:a,fill:y,stroke:m,strokeWidth:x,...null!=p&&{fillOpacity:p},...f&&{hatchFill:f},...v.length>0&&{gradientStubs:v},rawDatum:b,labelX:_("vertical"===d&&e.xExtent?e.xExtent[0]:u.t)-4,labelY:h,labelText:e.label??e.id})});const D=/* @__PURE__ */new Map;t.forEach((e,t)=>D.set(e.id,t)),M.forEach(e=>{const t=F.get(e.id);if(!t)return;const i=D.get(e.source)??0,n=l(e.source,i),{pathD:o,bezier:r}=$u(t),s=e.__raw??e,a="function"==typeof c?Number(c(s)):c,u=Number.isFinite(a)?Math.max(0,Math.min(1,a)):.35;C.push({id:e.id,pathD:o,fill:n,opacity:u,rawDatum:s,bezier:r})});const B=Fu(R,$.slotByNode,w).map(e=>Yu(e,d)),W="vertical"===d?Nu(B,o,r):B,Y=/* @__PURE__ */new Map;if(null!=p)for(const e of t){const t=e.__raw??e,i="function"==typeof p?p(t):Number(t[p]);Number.isFinite(i)&&Y.set(e.id,i)}const q=zu(W,o,r,h,{...Y.size>0&&{priorityById:Y},...null!=f&&{maxLabels:f}});return{layout:$,layoutConfig:{bands:q,ribbons:C.map(e=>qu(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function Gu(e,t,i,n="horizontal"){return"vertical"===n?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}function Vu(e){const t=e.layout,i=e.nodes,n=e.orientation,o=e.plotW,r=e.plotH,s=e.timelineExtent,a=e.axisTicks,c=e.showQualityReadout??!1,l=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,p=e.toTime,f=e.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t;let S=null,M=null;for(const e of i){const t=g[e.id];if(!t||null===t.start||null===t.end)continue;const i=f(t.start),n=f(t.end);(null===S||S>i)&&(S=i),(null===M||n>M)&&(M=n)}const _=e=>Math.max(0,Math.min(s,e)),$=_(S??0),P=Math.max($,_(M??s)),j=a.map((e,t)=>({tick:e,index:t,coordinate:f(p(e.date))})).filter(({coordinate:e})=>e>=$-.5&&P+.5>=e),I=null!==(w??null)&&null!=k&&null!=A,L=c&&(I||u.length>0)?/* @__PURE__ */ /* @__PURE__ */(0,WM.jsxs)("g",{fill:XM,fontSize:10,textAnchor:"end",children:[I&&/* @__PURE__ */ /* @__PURE__ */(0,WM.jsxs)(WM.Fragment,{children:[
|
|
189
189
|
/* @__PURE__ */
|
|
190
190
|
/* @__PURE__ */(0,WM.jsxs)("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),
|
|
191
191
|
/* @__PURE__ */
|
|
@@ -218,14 +218,14 @@ return(0,WM.jsxs)("g",{transform:`translate(${i},${r+4})`,children:[
|
|
|
218
218
|
/* @__PURE__ */
|
|
219
219
|
/* @__PURE__ */(0,WM.jsx)("line",{y2:6,stroke:YM}),
|
|
220
220
|
/* @__PURE__ */
|
|
221
|
-
/* @__PURE__ */(0,WM.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:qM,children:o})]},t)})]})}function Hu(e,t){return"scene"===t?e:e.data}function Uu(e,t,i){return!t?.isActive||t.predicate(Hu(e,i))}function Ku(e,t){if(!e)return[];const i=[],n=e=>{i.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),i}function Zu(e,t,i,n){if(e&&e.length>0)return e;const o=/* @__PURE__ */new Set;return t.forEach(e=>{const t="function"==typeof i?i(e):e[i],r="function"==typeof n?n(e):e[n];o.add(t),o.add(r)}),Array.from(o).map(e=>({id:e}))}function Qu({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:n,edgeOpacity:o,baseStyle:r={}}){return s=>{const a={fillOpacity:o,...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=Nn(e.data||e,t,i):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=Nn(e.data||e,t,i):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*o);return a}}function Ju(e,t,i={}){return Ks(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function ed(e){if(void 0!==e.edgeStyle)return e.edgeStyle;const{edgeWidth:t,edgeColor:i,edgeOpacity:n}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==n||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?r=>{const s=r?.data||r;let a=o;if("number"==typeof t)a=t;else if("function"==typeof t)a=t(s);else if("string"==typeof t){const e=s?.[t],i="number"==typeof e?e:Number(e);a=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:a,opacity:n??e.opacity??.6}}:void 0}function td(e,t,i){const[n,o]=i;if(!t)return n;const[r,s]=t,a=s>r?s-r:0,c=Number(e),l=Number.isFinite(c)?c:r;return n+Math.max(0,Math.min(1,a>0?(l-r)/a:0))*(o-n)}function id(e){const{valueAccessor:t,valueDomain:i,edgeWidthRange:n,resolveStroke:o,edgeOpacity:r,edgeLinecap:s,styleRules:a}=e,c=nt(t);return ut(e=>({stroke:o(e),strokeWidth:td(e[t],i,n),strokeLinecap:s,opacity:r,fillOpacity:0}),a,e=>({value:c(e)}))}function nd(e,t,i,n){const o=Array.isArray(e)?e:[];let r,s;if(t){const e="string"==typeof t?t:"__geoColorBy",n="string"==typeof t?o:o.map(e=>({...e,__geoColorBy:t(e)}));r=Dn(n,e,i)}if(n.sizeBy){const e=o.map("function"==typeof n.sizeBy?n.sizeBy:e=>e?.[n.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(s=_s(e))}return e=>({fill:t&&r?Nn(e,t,r):nA,fillOpacity:n.fillOpacity,stroke:"#fff",strokeWidth:n.strokeWidth,r:n.sizeBy?Wn(e,n.sizeBy,n.sizeRange,s):n.pointRadius??6})}function od(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function rd(e,t,i){if(!Array.isArray(e))return;const n=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let o=1/0,r=-1/0;for(const t of e){const e=n(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>r&&(r=e))}const s=[Number.isFinite(o)?o:0,Number.isFinite(r)?r:1],a=(0,n_.scaleSequential)(On(i)).domain(s);return{domain:s,colorScale:e=>a(e),valueAccessor:n}}function sd(e,t){if(e)return i=>{const n=e.valueAccessor(i);return{fill:null!=n&&isFinite(n)?e.colorScale(n):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}function ad(e,t){return e===t}function cd(e,t){if("function"==typeof e)return t=>+e(t);const i=e||t;return e=>+e[i]}function ld(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function ud(e,t){return"function"==typeof e?t=>e(t)+"":e?t=>t[e]+"":t?e=>e[t]+"":void 0}function dd(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function hd(e){return"string"==typeof e?e:e.id}function pd(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const i=p_.test(t)?t+"-01":t;if(i===t&&10>t.length)return NaN;const n=Date.parse(i);return Number.isFinite(n)?n:NaN}function fd(e){return e instanceof Date?e.getTime():"string"==typeof e?pd(e):+e}function yd(e){return new Set(Array.isArray(e)?e:[e])}function gd(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function md(e,t){return Math.min((e-t.startTime)/t.duration,1)}function xd(e,t,i){return e+(t-e)*i}function bd(){return"undefined"!=typeof performance?performance.now():Date.now()}function vd(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function wd(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const i=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>i?1:t;if("exponential"===e.type){const n=e.halfLife??e.extent/2;return t+Math.pow(.5,i/(n>0?n:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}function kd(e,t,i){if(1>=i)return 1;const n=i-1;return wd({age:n-t,extent:n,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function Ad(e){const t=/* @__PURE__ */new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function Sd(e,t,i,n=Ad(i)){const o=i.length;if(o>1)for(const i of t){if("line"===i.type){const t=Array.isArray(i.datum)?i.datum:[];if(2>t.length)continue;const r=Array(t.length);let s=!1;for(let i=0;t.length>i;i++){const a=n.get(t[i]);null!=a?(r[i]=kd(e,a,o),1>r[i]&&(s=!0)):r[i]=1}s&&(i._decayOpacities=r);continue}if("area"===i.type){const t=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:t.length;if(2>r)continue;if(t.length===r){const s=Array(r);let a=!1;for(let i=0;t.length>i;i++){const r=n.get(t[i]);null!=r?(s[i]=kd(e,r,o),1>s[i]&&(a=!0)):s[i]=1}a&&(i._decayOpacities=s)}else{let s=1;for(const i of t){const t=n.get(i);if(null!=t){const i=kd(e,t,o);s>i&&(s=i)}}if(1>s){const e=Array(r);e.fill(s),i._decayOpacities=e}}continue}const t=n.get(i.datum);if(null==t)continue;const r=kd(e,t,o);"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}function Md(e,t,i){const n=e.duration??500,o=i-t;return n>o?1-o/n:0}function _d(e,t,i,n,o,r=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=o??(()=>{const e=/* @__PURE__ */new Map;for(let t=0;i.length>t;t++)e.set(i[t],t);return e})();for(const i of t){if("line"===i.type)continue;if("area"===i.type){const t=Array.isArray(i.datum)?i.datum:[i.datum];let o=0,a=!1;for(const i of t){const t=l.get(i);if(null==t)continue;a=!0;const s=n.get(t);if(null==s)continue;const c=Md(e,s,r);c>o&&(o=c)}a&&(c=$d(i,o,s)||c);continue}const t=l.get(i.datum);if(null==t)continue;const o=n.get(t);c=$d(i,null==o?0:Md(e,o,r),s,a)||c}return c}function $d(e,t,i,n){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,o=!0),e._pulseGlowRadius!==n&&(e._pulseGlowRadius=n,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function Pd(e,t,i=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const n=e.duration??500,o=t.peek();return null!=o&&n>i-o}function jd(e){return[e[0],e[1]]}function Id(e,t,i,n){const o=/* @__PURE__ */new Map;for(let i=0;t.length>i;i++)o.set(t[i],e[i]);let r;for(const e of n){const t=o.get(e);if(t){r=t;break}}const s=Array(i.length),a=Array(i.length);let c;for(let e=0;i.length>e;e++){a[e]=jd(i[e]);const t=o.get(n[e]);t?(s[e]=jd(t),c=t):s[e]=jd(c??r??i[e])}return{prev:s,target:a}}function Ld(e,t,i){if(Array.isArray(t)&&t.length===i&&0!==i){if(e.getPointId){const i=t.map(t=>e.getPointId(t)+"");if(i.every(e=>e.length>0))return i}if("streaming"===e.runtimeMode){const i=t.map(t=>"x:"+e.getX(t));if(new Set(i).size===i.length)return i}}}function Rd(e,t,i){return t.pathIds&&t.pathIds.length===i?t.pathIds:Ld(e,t.datum,i)}function Cd(e,t){if(e.length!==t.length)return!0;for(let i=0;e.length>i;i++)if(e[i][0]!==t[i][0]||e[i][1]!==t[i][1])return!0;return!1}function Td(e,t,i,n){n.set(i,"line"!==t.type?{topPath:t.topPath.map(jd),bottomPath:t.bottomPath.map(jd),pathIds:Rd(e,t,t.topPath.length),opacity:t.style?.opacity}:{path:t.path.map(jd),pathIds:Rd(e,t,t.path.length),opacity:t.style?.opacity})}function Od(e,t,i){if(!i.path)return!1;const n=Rd(e,t,t.path.length),o=i.pathIds;if(o&&n&&o.length===i.path.length&&n.length===t.path.length){const e=Id(i.path,o,t.path,n);return!(!Cd(e.prev,e.target)&&void 0===t._introClipFraction||(t._targetPath=e.target,t._prevPath=e.prev,t.path=e.prev.map(jd),0))}if(i.path.length===t.path.length){t._targetPath=t.path.map(jd),t._prevPath=i.path;for(let e=0;t.path.length>e;e++)t.path[e]=jd(i.path[e]);return!0}return!1}function Ed(e,t,i){if(!i.topPath||!i.bottomPath)return!1;const n=Rd(e,t,t.topPath.length),o=i.pathIds;if(o&&n&&o.length===i.topPath.length&&n.length===t.topPath.length&&i.bottomPath.length===i.topPath.length&&t.bottomPath.length===t.topPath.length){const e=Id(i.topPath,o,t.topPath,n),r=Id(i.bottomPath,o,t.bottomPath,n);return!(!Cd(e.prev,e.target)&&!Cd(r.prev,r.target)&&void 0===t._introClipFraction||(t._targetTopPath=e.target,t._targetBottomPath=r.target,t._prevTopPath=e.prev,t._prevBottomPath=r.prev,t.topPath=e.prev.map(jd),t.bottomPath=r.prev.map(jd),0))}if(i.topPath.length===t.topPath.length&&i.bottomPath.length===t.bottomPath.length){t._targetTopPath=t.topPath.map(jd),t._targetBottomPath=t.bottomPath.map(jd),t._prevTopPath=i.topPath,t._prevBottomPath=i.bottomPath;for(let e=0;t.topPath.length>e;e++)t.topPath[e]=jd(i.topPath[e]);for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=jd(i.bottomPath[e]);return!0}return!1}function Fd(e,t,i,n,o){if(!i)return t._targetOpacity=t.style.opacity??1,t._startOpacity=0,t.style={...t.style,opacity:0},!0;n.add(o);const r="line"===t.type?Od(e,t,i):Ed(e,t,i);return t._targetOpacity=t.style.opacity??1,t._startOpacity=i.opacity??t.style.opacity??1,r}function Nd(e,t){const i=[];for(const[n,o]of e)if(!t.has(n))if(n.startsWith("l:")&&o.path){const e={type:"line",path:o.path.map(jd),group:n.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:o.opacity??1},_targetOpacity:0,_transitionKey:n,datum:null};i.push(e)}else if(n.startsWith("a:")&&o.topPath&&o.bottomPath){const e={type:"area",topPath:o.topPath.map(jd),bottomPath:o.bottomPath.map(jd),group:n.slice(2),style:{fill:"#999",opacity:o.opacity??1},_targetOpacity:0,_transitionKey:n,datum:null};i.push(e)}return i}function zd(e,t){if(void 0!==e._targetOpacity&&(e.style={...e.style,opacity:xd(e._startOpacity??0,e._targetOpacity,t)}),void 0!==e._introClipFraction&&(e._introClipFraction=t),"line"===e.type){const i=e._prevPath,n=e._targetPath;if(i&&n&&i.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=xd(i[o][0],n[o][0],t),e.path[o][1]=xd(i[o][1],n[o][1],t);return}const i=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(i&&o&&i.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=xd(i[n][0],o[n][0],t),e.topPath[n][1]=xd(i[n][1],o[n][1],t);if(n&&r&&n.length===e.bottomPath.length)for(let i=0;e.bottomPath.length>i;i++)e.bottomPath[i][0]=xd(n[i][0],r[i][0],t),e.bottomPath[i][1]=xd(n[i][1],r[i][1],t)}function Dd(e){if("line"===e.type){const t=e._targetPath;if(t)for(let i=0;e.path.length>i;i++)e.path[i]=t[i];return e._prevPath=void 0,e._targetPath=void 0,void(e._introClipFraction=void 0)}const t=e._targetTopPath,i=e._targetBottomPath;if(t)for(let i=0;e.topPath.length>i;i++)e.topPath[i]=t[i];if(i)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=i[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}function Bd(e,t,i){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 i=e.getX(t.datum),n=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${i}:${n}`;if(null!=i&&null!=n)return`p:${i}:${n}`}return"p:"+i;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+i;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??i}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+i:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Wd(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Yd(e,t,i,n){i.clear(),n.clear();for(let o=0;t.length>o;o++){const r=t[o],s=Bd(e,r,o);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:Wd(r.style)}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:Wd(r.style),glyph:r.glyph}):"rect"===r.type||"heatcell"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:Wd(r.style)}):"candlestick"===r.type?i.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:Wd(r.style)}):"line"!==r.type&&"area"!==r.type||Td(e,r,s,n))}}function qd(e,t,i,n,o,r=bd()){if(0===n.size&&0===o.size)return i;const s=t.duration??300;if(i.exitNodes.length>0){const e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}let a=!1;const c=/* @__PURE__ */new Set,l=/* @__PURE__ */new Set;for(let t=0;i.scene.length>t;t++){const r=i.scene[t],s=Bd(e,r,t);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){Fd(e,r,o.get(s),l,s)&&(a=!0);continue}const u=n.get(s);if("point"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,r:r.r};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.r===e.r||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=u.x,r.y=u.y,r.r=u.r??r.r,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style,opacity:0},a=!0;else if("glyph"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,size:r.size};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.r===e.size||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.size,r.x=u.x,r.y=u.y,r.size=u.r??r.size,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style,opacity:0},a=!0;else if("rect"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style,opacity:0},a=!0;else if("heatcell"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style||{},opacity:0},a=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){c.add(s);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=Wd(r.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.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=u.x,r.openY=u.openY,r.closeY=u.closeY??r.closeY,r.highY=u.highY??r.highY,r.lowY=u.lowY??r.lowY,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style||{},opacity:0},a=!0}const u=Nd(o,l);u.length&&(i.exitNodes.push(...u),a=!0);for(const[e,t]of n)if(!c.has(e)){if(e.startsWith("p:"))i.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)i.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))i.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const n=t.openY??t.y;i.exitNodes.push({type:"candlestick",x:t.x,openY:n,closeY:t.closeY??n,highY:t.highY??n,lowY:t.lowY??n,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:r,duration:s}),i}function Xd(e,t,i,n,o){if(!i.activeTransition)return!1;const r=md(e,i.activeTransition),s=gd(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of i.scene){const t=e._transitionKey;if("line"!==e.type&&"area"!==e.type){if("point"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style.opacity=xd(i?i.opacity??1:0,e._targetOpacity,s)}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.r=xd(i.r,e._targetR,s))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style.opacity=xd(i?i.opacity??1:0,e._targetOpacity,s)}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.size=xd(i.r,e._targetR,s))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style.opacity=xd(i?i.opacity??1:0,e._targetOpacity,s)}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==i.w&&(e.w=xd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=xd(i.h,e._targetH,s))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style={...e.style||{},opacity:xd(i?i.opacity??1:0,e._targetOpacity,s)}}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==i.w&&(e.w=xd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=xd(i.h,e._targetH,s))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style={...e.style||{},opacity:xd(i?i.opacity??1:0,e._targetOpacity,s)}}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),void 0!==i.openY&&(e.openY=xd(i.openY,e._targetOpenY,s)),void 0!==i.closeY&&(e.closeY=xd(i.closeY,e._targetCloseY,s)),void 0!==i.highY&&(e.highY=xd(i.highY,e._targetHighY,s)),void 0!==i.lowY&&(e.lowY=xd(i.lowY,e._targetLowY,s))}}else zd(e,s)}if(r>=1){for(const e of i.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("line"!==e.type&&"area"!==e.type){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("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=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 Dd(e)}if(i.exitNodes.length>0){const e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}function Gd(e){f_[e.chartType]=e}function Vd(e){return f_[e]}function Hd(e){Vd(e)||y_&&(g_.has(e)||(g_.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}function Ud(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:i,overlays:n,warned:o}=e;Kd(n)&&0===i.length&&Zd(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(e=>null==e.datum)&&Zd(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Kd(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Kd))}function Zd(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Qd(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}function Jd(e,t,i,n){const o=Qd(t),r="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:r,message:`Semiotic ${e} ${r} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:n}}function eh(e){try{return{kind:"success",result:e.run()}}catch(t){const i=e.hasPreviousResult,n=Jd(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:n,preservedLastGoodScene:i}}}function th(e,t){const i="function"==typeof e?e:i=>i[e||t];return e=>{const t=i(e);return null==t?NaN:+t}}function ih(e){const t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,n=th(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){const i=cd(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const i=Array.isArray(e.band)?e.band:[e.band];for(const e of i)t.push({kind:"band",getTop:th(e.y1Accessor,"y1"),getBottom:th(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function nh(e,t,i,n,o,r=!1){const s=/* @__PURE__ */new Map;for(const a of e){const e=t(a),c=i(a);if(null==e||null==c||Number.isNaN(e)||Number.isNaN(c))continue;const l=Math.floor(e/n)*n;let u=s.get(l);if(u||(u={start:l,end:l+n,total:0,categories:/* @__PURE__ */new Map,...r?{rows:[],categoryRows:/* @__PURE__ */new Map}:{}},s.set(l,u)),u.total+=c,u.rows?.push(a),o){const e=o(a);if(u.categories.set(e,(u.categories.get(e)||0)+c),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(a)}}}return s}function oh(e,t,i,n,o){const r=nh(e,t,i,n,o);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]}function rh(e,t){let i=0,n=0,o=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(o+=e,i>o&&(i=o),o>n&&(n=o))}return[i,n]}function sh(e,t,i,n,o,r){const s=[];for(const r of e){const e=i(r),a=n(r),c=o?o(r):0;if(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(c))continue;const l=t.x(e),u=t.y(a),d=o?t.y(c):0;Number.isFinite(l)&&Number.isFinite(u)&&Number.isFinite(d)&&s.push({x:l,y:u,bottom:d,raw:a,datum:r})}s.sort((e,t)=>e.x-t.x);const a=Array(s.length),c=o?Array(s.length):[],l=Array(s.length),u=Array(s.length),d=r?Array(s.length):void 0;for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.x,t.y],o&&(c[e]=[t.x,t.bottom]),l[e]=t.raw,u[e]=t.datum,d&&r&&(d[e]=r(t.datum)+"")}return d?{topPath:a,bottomPath:c,rawValues:l,datum:u,pathIds:d}:{topPath:a,bottomPath:c,rawValues:l,datum:u}}function ah(e,t,i,n,o,r,s){const{topPath:a,rawValues:c,datum:l,pathIds:u}=sh(e,t,i,n,void 0,s),d={type:"line",path:a,rawValues:c,style:o,datum:l,group:r};return u&&(d.pathIds=u),d}function ch(e,t,i,n,o,r,s,a,c){return{type:"area",...sh(e,t,i,n,a??(()=>o),c),style:r,group:s}}function lh(e,t,i,n){const o=/* @__PURE__ */new Map;if("silhouette"===n)for(const n of e){let e=0;for(const o of t)e+=i(o,n)||0;o.set(n,-e/2)}else if("wiggle"===n){e.length>0&&o.set(e[0],0);for(let n=1;e.length>n;n++){const r=e[n-1],s=e[n];let a=0,c=0,l=0;for(const e of t){const t=i(e,s)||0;a+=(2*l+t)*(t-(i(e,r)||0)),c+=t,l+=t}const u=o.get(r)??0;o.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let n=0;for(const r of e){let e=0;for(const n of t)e+=i(n,r)||0;n+=(o.get(r)??0)+e/2}const r=n/e.length;for(const t of e)o.set(t,(o.get(t)??0)-r)}}else for(const t of e)o.set(t,0);return o}function uh(e,t,i){let n=0,o=0;for(const r of e){let e=0,s=0;for(const n of t){const t=i(n,r)||0;0>t?s+=t:e+=t}n>s&&(n=s),e>o&&(o=e)}return[n,o]}function dh(e,t,i,n,o,r,s,a="zero",c){const l=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const t of e){const e=/* @__PURE__ */new Map;for(const o of t.data){const t=i(o),r=n(o);if(!Number.isFinite(t))continue;if(l.add(t),!Number.isFinite(r))continue;const s=e.get(t);s?(s.value+=r,s.sources?s.sources.push(o):s.sources=[s.datum,o]):e.set(t,{value:r,datum:o})}u.set(t.key,e)}const d=Array.from(l).sort((e,t)=>e-t);let h;if(r){h=/* @__PURE__ */new Map;for(const t of d){let i=0;for(const n of e)i+=u.get(n.key)?.get(t)?.value||0;h.set(t,i||1)}}const p=lh(d,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)?.value||0,a),f="diverging"===a&&!r,y=[],g=/* @__PURE__ */new Map,m=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(const e of d)m.set(e,p.get(e)??0),x.set(e,0),b.set(e,0);for(const i of e){const e=u.get(i.key),n=/* @__PURE__ */new Map;let a=[],l=[],p=[],v=[],w=[],k=c?[]:void 0,A=!1;const S=()=>{if(0!==a.length){if(a.length>=2){const e=A?a.map((e,t)=>t).sort((e,t)=>a[e][0]-a[t][0]):void 0,t=e?e.map(e=>v[e]):v,n={type:"area",topPath:e?e.map(e=>a[e]):a,bottomPath:e?e.map(e=>l[e]):l,rawValues:e?e.map(e=>p[e]):p,style:o(i.key,Ga(i.data)),datum:t,accessibleDatum:e?e.map(e=>w[e]):w,group:i.key};k&&(n.pathIds=e?e.map(e=>k[e]):k),s&&(n.curve=s),y.push(n)}a=[],l=[],p=[],v=[],w=[],k=c?[]:void 0,A=!1}};for(const o of d){const s=e.get(o),c=void 0!==s;let u,d,y=s?.value??0;if(r&&c&&(y/=h.get(o)),!c||!Number.isFinite(y)||0===y){S();continue}f?y>0?(u=x.get(o),d=u+y,x.set(o,d)):(u=b.get(o),d=u+y,b.set(o,d)):(u=m.get(o),d=u+y,m.set(o,d));const g=t.x(o),M=t.y(u),_=t.y(d);if(!Number.isFinite(g)||!Number.isFinite(M)||!Number.isFinite(_)){S();continue}const $=s.sources,P=s.value,j=$?{...$[0],__aggregateValue:P,__aggregateCount:$.length,__aggregateRows:$}:s.datum;a.length>0&&a[a.length-1][0]>g&&(A=!0),a.push([g,_]),l.push([g,M]),v.push(j),p.push(P),k&&k.push("x:"+o),w.push($?{x:o,value:P,group:i.key,observations:$.length}:j),n.set(o,d)}S(),g.set(i.key,n)}return{nodes:y,stackedTops:g}}function hh(e,t,i,n,o,r,s){const a=i(e),c=n(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:o,style:r,datum:e};return void 0!==s&&(l.pointId=s),l}function ph(e,t,i,n,o,r,s,a){const c=i(e),l=n(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:o,symbolType:r,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function fh(e,t,i,n,o,r,s){return{type:"rect",x:e,y:t,w:i,h:n,style:o,datum:r,group:s}}function yh(e,t,i,n,o,r,s){const a={type:"heatcell",x:e,y:t,w:i,h:n,fill:o,datum:r};return void 0!==s?.value&&(a.value=s.value),s?.showValues&&(a.showValues=!0,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function gh(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function mh(e){const{config:t,groups:i,getX:n,getY:o}=e,r="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){const i=[0,r?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set;let l=0;const u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(const e of i){const t=/* @__PURE__ */new Map;let i=0;for(const r of e.data){const e=n(r),s=o(r);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),i+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,i)}const h=t.stackOrder??"key",p=(e,t)=>t>e?-1:e>t?1:0;let f,y;if("input"===h)f=i.map(e=>e.key);else if("insideOut"===h){const e=[...i].map(e=>e.key).sort((e,t)=>{const i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:p(e,t)}),t=[],n=[];let o=0,r=0;for(const i of e)r>o?(t.push(i),o+=d.get(i)??0):(n.push(i),r+=d.get(i)??0);f=[...n.reverse(),...t]}else f="asc"===h?i.map(e=>e.key).sort((e,t)=>{const i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:p(e,t)}):"desc"===h?i.map(e=>e.key).sort((e,t)=>{const i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:p(e,t)}):i.map(e=>e.key).sort(p);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),i=lh(e,f,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let n=1/0,o=-1/0;for(const t of e){const e=i.get(t)??0,r=u.get(t)??0;n>e&&(n=e),e+r>o&&(o=e+r)}Number.isFinite(n)&&Number.isFinite(o)||(n=0,o=0);const s=o-n,l=r?0:s>0?s*t.extentPadding:1;y=[n-l,o+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[i,n]=uh(e,f,(e,t)=>a.get(e)?.get(t)||0),o=n-i,s=r?0:o>0?o*t.extentPadding:1;y=[i-s,n+s]}else y=[0,l+(r?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}function xh(e,t,i,n,o,r,s){const[,a]=oh(e,t,i,n,o);return[0,s?a:a+a*r]}function bh(e,t,i,n){const[o,r]=rh(e,t),s=r-o,a=n?0:s>0?s*i:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,r+Math.abs(a))]}function vh(e,t,i,n,o){const r=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(2>r.length)return gh(i,n);const s=r[0],a=r[1],c=r[r.length-1],l=r[r.length-2];return gh("log"===o&&s>0?[s/Math.sqrt(a/s),c*Math.sqrt(c/l)]:[s-(a-s)/2,c+(c-l)/2],n)}function wh(e,t,i){if(!i.length)return e;let[n,o]=e;for(const e of t)for(const t of i){const i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&(n>i&&(n=i),i>o&&(o=i)),Number.isFinite(r)&&(n>r&&(n=r),r>o&&(o=r))}return[n,o]}function kh(e,t){const i=e[1]-e[0],n=t.exactMode?0:i>0?i*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-n,null!=t.userMax?e[1]:e[1]+n];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}function Ah(e,t,i){if(!t||i)return e;const n=t[0],o=t[1];return null==n&&null==o?e:[null!=n?n:e[0],null!=o?o:e[1]]}function Sh(e,t,i){let n=e,o=t;if(n[0]===1/0||n[1]===-1/0)if("time"===i){const e=Date.now();n=[e-864e5,e]}else n=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:n,yDomain:o}}function Mh(e,t,i){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,m_.scaleLog)().domain(e).range(i).clamp(!0)}return"symlog"===e?(0,m_.scaleSymlog)().domain(t).range(i):"time"===e?(0,m_.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(i):(0,m_.scaleLinear)().domain(t).range(i)}function _h(e){const{config:t,layout:i,xDomain:n}=e,o=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,r="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(i.width,i.height)/2-1));if(r){const e="left"===t.arrowOfTime?[i.width-s,s]:[s,i.width-s];return{x:(0,m_.scaleLinear)().domain(n).range(e),y:Mh(t.yScaleType,o,[i.height-s,s])}}return{x:Mh(t.xScaleType,n,[s,i.width-s]),y:Mh(t.yScaleType,o,[i.height-s,s])}}function $h(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?zn(e,t):void 0}function Ph(e,t,i,n){if(n&&n.version===i&&n.group===t&&n.data===e)return{result:n.result,cache:n};let o;if(t){const i=/* @__PURE__ */new Map;for(const n of e){const e=t(n);i.has(e)||i.set(e,[]),i.get(e).push(n)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}function jh(e,t,i,n,o){if(o&&o.version===n)return{map:o.map,cache:o};const r=/* @__PURE__ */new Set;if(t)for(const i of e){const e=t(i);e&&r.add(e)}const s=Array.from(r).sort(),a=s.join("\0");if(o&&o.key===a){const e={...o,version:n};return{map:e.map,cache:e}}const c=En(i.colorScheme,i.themeCategorical,oA),l=/* @__PURE__ */new Map;for(let e=0;s.length>e;e++)l.set(s[e],$h(i.colorScheme,s[e])??c[e%c.length]);return{map:l,cache:{key:a,map:l,version:n}}}function Ih(e){const{group:t,colorMapCache:i,groupColorMap:n,groupColorMapCap:o,config:r}=e;let{groupColorCounter:s}=e;const a=$h(r.colorScheme,t);if(a)return{color:a,groupColorCounter:s};if(i){const e=i.map.get(t);if(e)return{color:e,groupColorCounter:s}}const c=n.get(t);if(c)return{color:c,groupColorCounter:s};const l=En(r.colorScheme,r.themeCategorical,oA);if(0===l.length)return{color:null,groupColorCounter:s};const u=l[s%l.length];if(s++,n.set(t,u),n.size>o){const e=n.keys().next().value;void 0!==e&&n.delete(e)}return{color:u,groupColorCounter:s}}function Lh(e,t,i,n){const o=e.lineStyle;if("function"==typeof o){const e=o(i||{},t);if(e&&!e.stroke&&t){const i=n(t);if(i)return{...e,stroke:i}}return e}const r=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:n(t)||r||"#007bff",strokeWidth:2}}function Rh(e,t,i,n){if(e.areaStyle){const o=e.areaStyle(i||{});if(o&&!o.fill&&t){const e=n(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(i||{},t);if(e&&!e.fill&&t){const i=n(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}const r=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};const s=n(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}function Ch(e,t,i,n){const o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;const r=n(t,i);return{fill:r.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=r.opacity&&{opacity:r.opacity},stroke:"none",cursor:r.cursor}}function Th(e,t,i){t>e.capacity&&(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Oh(e,t){const i=new d_(e.capacity);return e.forEach(()=>i.push(t)),i}function Eh(e,t,i,n){const o=e.push(t);return i&&i.push(n),o}function Fh(e,t,i){if(!t||0===t.size)return;const n=/* @__PURE__ */new Set;if(e.forEach((e,t)=>{i(e)&&n.add(t)}),0===n.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)n.has(e)||t.push(o[e])}function Nh(){return this.updateResults.last}function zh(){return this.updateResults.last}function Dh(e){return this.updateResults.subscribe(e)}function Bh(e){this.config.layoutSelection=e}function Wh(){x_.set(this,!0)}function Yh(){const e=!0===x_.get(this);return x_.delete(this),e}function qh(e){Object.assign(e.prototype,{getLastUpdateResult:Nh,getUpdateSnapshot:zh,subscribeUpdateResult:Dh,setLayoutSelection:Bh,markStylePaintPending:Wh,consumeStylePaintPending:Yh})}function Xh(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=j_[n]??I_;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Gh(e){for(const t of e){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0);else if("candlestick"===t.type)void 0!==t._targetX&&(t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0);else if("line"===t.type||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}function Vh(e){for(const t of e){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?void 0!==t._targetX?(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}function Hh(e,t,i,n){return"function"==typeof t.style?t.style(n||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,n)}function Uh(e,t,i,n){if(!e.scales)return null;const{topPath:o,bottomPath:r,datum:s,pathIds:a}=sh(t,e.scales,e.getX,n.getTop,n.getBottom,e.getPointId);return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,...a&&{pathIds:a},...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:Hh(e,n,i,Ga(t)),datum:s,group:i,interactive:n.interactive}}function Kh(e){const t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(const n of e)n.perSeries?t.push(n):i.push(n);return{perSeries:t,aggregate:i}}function Zh(e,t,i){const n=[];for(const o of i){const i=Uh(e,t,"__ribbon_aggregate",o);i&&n.push(i)}return n}function Qh(e,t,i,n){const o=[];for(const r of n){const n=Uh(e,t,i,r);n&&o.push(n)}return o}function Jh(e,t,i,n){if(!e.config.pointStyle)return;const o=n??e.getY;for(const n of t){const t=e.resolveGroupColor(n.key);for(const r of n.data){let n=e.config.pointStyle(r);!n.fill&&t&&(n={...n,fill:t});const s=n.r??3,a=e.getPointId?e.getPointId(r)+"":void 0,c=hh(r,e.scales,e.getX,o,s,n,a);c&&i.push(c)}}}function ep(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function tp(e){return na(e)}function ip(e,t,i){if(i)return i;const n=e??"circle";if("chevron"===n)return rp(t);const o=Object.prototype.hasOwnProperty.call(F_,n)?F_[n]:E_.symbolCircle;return(0,E_.symbol)(o,Math.max(1,t))()??""}function np(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function op(e,t){const i=/* @__PURE__ */new Map;let n=0;return o=>{const r=e(o)+"",s=t&&Object.prototype.hasOwnProperty.call(t,r)?t[r]:void 0;if(s&&N_.has(s))return s;let a=i.get(r);return a||(a=z_[n%z_.length],n++,i.set(r,a)),a}}function rp(e){const t=1.5*np(e),i=.92*t;return`M0,${-t}L${i},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-i},${(.78*t).toFixed(3)}Z`}function sp(e,t){const i=[],n="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let r=null;if(e.getSize&&!e.config.pointStyle){const i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(const n of i)e>n&&(e=n),n>t&&(t=n);r=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=c?op(c,e.config.symbolMap):null;for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},c=t.r||n;if(r&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(c=r(t))}if(s&&e.getColor&&!t.fill){const i=e.getColor(o);i&&s.has(i)&&(t={...t,fill:s.get(i)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(l){const n=l(o),r=ph(o,e.scales,e.getX,e.getY,Math.PI*c*c,n,t,u);r&&i.push(r)}else{const n=hh(o,e.scales,e.getX,e.getY,c,t,u);n&&i.push(n)}}return i}function ap(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function cp(e){const t=Object.prototype.hasOwnProperty.call(Vk,e)?e:"blues";let i=B_.get(t);if(i)return i;i=Array(D_);const n=On(t);for(let e=0;D_>e;e++)i[e]=n(e/255);return B_.set(t,i),i}function lp(e,t,i){const n=i.config.areaStyle?.(t);return n&&("string"==typeof n.fill&&(e.fill=n.fill),e.style=n),e}function up(e,t,i){const n=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),r=e.config.heatmapAggregation??"count",s=cd(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/n,h=(u-l||1)/o,p=n*o;if(p>1e6)return[];const f=new Int32Array(p),y=new Float64Array(p),g=e.config.trackHoverRows||Va(e.config.areaStyle)?/* @__PURE__ */new Map:void 0;for(let i=0;t.length>i;i++){const r=t[i],c=e.getX(r),u=e.getY(r);if(!isFinite(c)||!isFinite(u))continue;const p=Math.min(Math.floor((c-a)/d),n-1),m=Math.min(Math.floor((u-l)/h),o-1);if(0>p||0>m)continue;const x=m*n+p;f[x]++;const b=s(r);if(y[x]+=isFinite(b)?b:0,g){let e=g.get(x);e||(e=[],g.set(x,e)),e.push(r)}}let m=1/0,x=-1/0;for(let e=0;p>e;e++){if(0===f[e])continue;let t;switch(r){case"sum":t=y[e];break;case"mean":t=y[e]/f[e];break;default:t=f[e]}m>t&&(m=t),t>x&&(x=t)}if(!isFinite(m))return[];const b=e.config.heatmapColorScale,v=b?void 0:cp("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),w=i.width/n,k=i.height/o,A=e.config.showValues,S=e.config.heatmapValueFormat,M=[];for(let t=0;o>t;t++){const i=t*n;for(let s=0;n>s;s++){const n=i+s;if(0===f[n])continue;let c;switch(r){case"sum":c=y[n];break;case"mean":c=y[n]/f[n];break;default:c=f[n]}const u=ap(c,m,x),p=b?b(c):v[u],_=A?{value:c,showValues:!0,valueFormat:S}:{value:c},$=Ya({xi:s,yi:t,value:c,count:f[n],sum:y[n],xCenter:a+(s+.5)*d,yCenter:l+(t+.5)*h,agg:r},g?.get(n));M.push(lp(yh(s*w,(o-1-t)*k,w,k,p,$,_),$,e))}}return M}function dp(){for(const e of Object.keys(W_))Vd(e)||Gd({chartType:e,buildScene:W_[e],canvasRenderers:[]})}function hp(e){const t=e.parts.filter(e=>null!=e),i={};for(const e of t)for(const[t,n]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+n;for(const[t,n]of Object.entries(e.additionalMarkCountByType??{}))n>0&&(i[t]=(i[t]??0)+n);const n=Object.values(i).reduce((e,t)=>e+t,0),o=0===n,r=Array.from(
|
|
222
|
-
/* @__PURE__ */new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),s="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${n} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:n,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:s,warnings:r,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function pp(e){const t={};for(const i of e){const e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}function fp(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function yp(e){if(!e||2>e.length)return;const t=fp(e[0]),i=fp(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function gp(e){const{count:t,byType:i}=pp(e.marks),n=0===t,o=[...e.extraWarnings??[]];n&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");const r=Array.isArray(e.annotations)?e.annotations.length:0,s="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,a=e.margin,c=a?{x:a.left,y:a.top,width:e.width-a.left-a.right,height:e.height-a.top-a.bottom}:void 0;return{component:"",frameType:e.frameType,status:n?"empty":"ok",empty:n,markCount:t,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:e.annotationRender?.renderedCount??r,...e.annotationRender?.layout?{layout:e.annotationRender.layout}:{},...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:s,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...a?{margin:a}:{},...c?{plot:c}:{}}}function mp(e,t,i){let n=i;for(const i of t)"lesser"===i.thresholdType?i.value>e&&(n=i.color):e>i.value&&(n=i.color);return n}function xp(e,t,i,n){if(2>e.length||t.length!==e.length||0===i.length)return[];const o=[],r=(e,t,i)=>{const n=o[o.length-1];n?.color===e?n.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;e.length>o;o++){const[s,a]=e[o-1],[c,l]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;h.length>e;e++){const t=h[e-1],o=h[e];r(mp(u+d*((t+o)/2),i,n),[s+(c-s)*t,a+(l-a)*t],[s+(c-s)*o,a+(l-a)*o])}}return o}function bp(e,t){const[i,n]=e.viewBox??G_,[o,r]=e.anchor??V_,s=n>0?n:1,a=Math.max(0,t)/s,c=(i>0?i:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-o*c,offsetY:-r*l}}function vp(e,t,i,n){if("none"!==e)return"color"===e||null==e?t??n:"accent"===e?i:e}function wp(e,t,i=0,n="horizontal"){const[o,r]=e.viewBox??G_,s=Math.min(1,Math.max(0,i)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===n?{x:0,y:r*(1-a),width:o,height:r*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}function kp(e,t){const i=bp(e,t);return{centerDx:i.offsetX+i.width/2,centerDy:i.offsetY+i.height/2,halfWidth:i.width/2,halfHeight:i.height/2,radius:Math.hypot(i.width,i.height)/2}}function Ap(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const i=Math.min(e.w,e.h)/2,n=e=>Math.max(0,Math.min(e??0,i));return{tl:n(t.tl),tr:n(t.tr),br:n(t.br),bl:n(t.bl)}}function Sp(e,t="#4e79a7"){return
|
|
221
|
+
/* @__PURE__ */(0,WM.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:qM,children:o})]},t)})]})}function Hu(e,t){return"scene"===t?e:e.data}function Uu(e,t,i){return!t?.isActive||t.predicate(Hu(e,i))}function Ku(e,t){if(!e)return[];const i=[],n=e=>{i.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(n)};return n(e),i}function Zu(e,t,i,n){if(e&&e.length>0)return e;const o=/* @__PURE__ */new Set;return t.forEach(e=>{const t="function"==typeof i?i(e):e[i],r="function"==typeof n?n(e):e[n];o.add(t),o.add(r)}),Array.from(o).map(e=>({id:e}))}function Qu({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:n,edgeOpacity:o,baseStyle:r={}}){return s=>{const a={fillOpacity:o,...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=Bn(e.data||e,t,i):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=Bn(e.data||e,t,i):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*o);return a}}function Ju(e,t,i={}){return Ks(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function ed(e){if(void 0!==e.edgeStyle)return e.edgeStyle;const{edgeWidth:t,edgeColor:i,edgeOpacity:n}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==n||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?r=>{const s=r?.data||r;let a=o;if("number"==typeof t)a=t;else if("function"==typeof t)a=t(s);else if("string"==typeof t){const e=s?.[t],i="number"==typeof e?e:Number(e);a=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:a,opacity:n??e.opacity??.6}}:void 0}function td(e,t,i){const[n,o]=i;if(!t)return n;const[r,s]=t,a=s>r?s-r:0,c=Number(e),l=Number.isFinite(c)?c:r;return n+Math.max(0,Math.min(1,a>0?(l-r)/a:0))*(o-n)}function id(e){const{valueAccessor:t,valueDomain:i,edgeWidthRange:n,resolveStroke:o,edgeOpacity:r,edgeLinecap:s,styleRules:a}=e,c=nt(t);return ut(e=>({stroke:o(e),strokeWidth:td(e[t],i,n),strokeLinecap:s,opacity:r,fillOpacity:0}),a,e=>({value:c(e)}))}function nd(e,t,i,n){const o=Array.isArray(e)?e:[];let r,s;if(t){const e="string"==typeof t?t:"__geoColorBy",n="string"==typeof t?o:o.map(e=>({...e,__geoColorBy:t(e)}));r=Yn(n,e,i)}if(n.sizeBy){const e=o.map("function"==typeof n.sizeBy?n.sizeBy:e=>e?.[n.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(s=Mt(e))}return e=>({fill:t&&r?Bn(e,t,r):nA,fillOpacity:n.fillOpacity,stroke:"#fff",strokeWidth:n.strokeWidth,r:n.sizeBy?Xn(e,n.sizeBy,n.sizeRange,s):n.pointRadius??6})}function od(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function rd(e,t,i){if(!Array.isArray(e))return;const n=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let o=1/0,r=-1/0;for(const t of e){const e=n(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>r&&(r=e))}const s=[Number.isFinite(o)?o:0,Number.isFinite(r)?r:1],a=(0,n_.scaleSequential)(Nn(i)).domain(s);return{domain:s,colorScale:e=>a(e),valueAccessor:n}}function sd(e,t){if(e)return i=>{const n=e.valueAccessor(i);return{fill:null!=n&&isFinite(n)?e.colorScale(n):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}function ad(e,t){return e===t}function cd(e,t){if("function"==typeof e)return t=>+e(t);const i=e||t;return e=>+e[i]}function ld(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function ud(e,t){return"function"==typeof e?t=>e(t)+"":e?t=>t[e]+"":t?e=>e[t]+"":void 0}function dd(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function hd(e){return"string"==typeof e?e:e.id}function pd(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const i=p_.test(t)?t+"-01":t;if(i===t&&10>t.length)return NaN;const n=Date.parse(i);return Number.isFinite(n)?n:NaN}function fd(e){return e instanceof Date?e.getTime():"string"==typeof e?pd(e):+e}function yd(e){return new Set(Array.isArray(e)?e:[e])}function gd(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function md(e,t){return Math.min((e-t.startTime)/t.duration,1)}function xd(e,t,i){return e+(t-e)*i}function bd(){return"undefined"!=typeof performance?performance.now():Date.now()}function vd(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function wd(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const i=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>i?1:t;if("exponential"===e.type){const n=e.halfLife??e.extent/2;return t+Math.pow(.5,i/(n>0?n:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}function kd(e,t,i){if(1>=i)return 1;const n=i-1;return wd({age:n-t,extent:n,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function Ad(e){const t=/* @__PURE__ */new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function Sd(e,t,i,n=Ad(i)){const o=i.length;if(o>1)for(const i of t){if("line"===i.type){const t=Array.isArray(i.datum)?i.datum:[];if(2>t.length)continue;const r=Array(t.length);let s=!1;for(let i=0;t.length>i;i++){const a=n.get(t[i]);null!=a?(r[i]=kd(e,a,o),1>r[i]&&(s=!0)):r[i]=1}s&&(i._decayOpacities=r);continue}if("area"===i.type){const t=Array.isArray(i.datum)?i.datum:[],r=i.topPath?i.topPath.length:t.length;if(2>r)continue;if(t.length===r){const s=Array(r);let a=!1;for(let i=0;t.length>i;i++){const r=n.get(t[i]);null!=r?(s[i]=kd(e,r,o),1>s[i]&&(a=!0)):s[i]=1}a&&(i._decayOpacities=s)}else{let s=1;for(const i of t){const t=n.get(i);if(null!=t){const i=kd(e,t,o);s>i&&(s=i)}}if(1>s){const e=Array(r);e.fill(s),i._decayOpacities=e}}continue}const t=n.get(i.datum);if(null==t)continue;const r=kd(e,t,o);"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}function Md(e,t,i){const n=e.duration??500,o=i-t;return n>o?1-o/n:0}function _d(e,t,i,n,o,r=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=o??(()=>{const e=/* @__PURE__ */new Map;for(let t=0;i.length>t;t++)e.set(i[t],t);return e})();for(const i of t){if("line"===i.type)continue;if("area"===i.type){const t=Array.isArray(i.datum)?i.datum:[i.datum];let o=0,a=!1;for(const i of t){const t=l.get(i);if(null==t)continue;a=!0;const s=n.get(t);if(null==s)continue;const c=Md(e,s,r);c>o&&(o=c)}a&&(c=$d(i,o,s)||c);continue}const t=l.get(i.datum);if(null==t)continue;const o=n.get(t);c=$d(i,null==o?0:Md(e,o,r),s,a)||c}return c}function $d(e,t,i,n){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,o=!0),e._pulseGlowRadius!==n&&(e._pulseGlowRadius=n,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function Pd(e,t,i=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const n=e.duration??500,o=t.peek();return null!=o&&n>i-o}function jd(e){return[e[0],e[1]]}function Id(e,t,i,n){const o=/* @__PURE__ */new Map;for(let i=0;t.length>i;i++)o.set(t[i],e[i]);let r;for(const e of n){const t=o.get(e);if(t){r=t;break}}const s=Array(i.length),a=Array(i.length);let c;for(let e=0;i.length>e;e++){a[e]=jd(i[e]);const t=o.get(n[e]);t?(s[e]=jd(t),c=t):s[e]=jd(c??r??i[e])}return{prev:s,target:a}}function Ld(e,t,i){if(Array.isArray(t)&&t.length===i&&0!==i){if(e.getPointId){const i=t.map(t=>e.getPointId(t)+"");if(i.every(e=>e.length>0))return i}if("streaming"===e.runtimeMode){const i=t.map(t=>"x:"+e.getX(t));if(new Set(i).size===i.length)return i}}}function Rd(e,t,i){return t.pathIds&&t.pathIds.length===i?t.pathIds:Ld(e,t.datum,i)}function Cd(e,t){if(e.length!==t.length)return!0;for(let i=0;e.length>i;i++)if(e[i][0]!==t[i][0]||e[i][1]!==t[i][1])return!0;return!1}function Td(e,t,i,n){n.set(i,"line"!==t.type?{topPath:t.topPath.map(jd),bottomPath:t.bottomPath.map(jd),pathIds:Rd(e,t,t.topPath.length),opacity:t.style?.opacity}:{path:t.path.map(jd),pathIds:Rd(e,t,t.path.length),opacity:t.style?.opacity})}function Od(e,t,i){if(!i.path)return!1;const n=Rd(e,t,t.path.length),o=i.pathIds;if(o&&n&&o.length===i.path.length&&n.length===t.path.length){const e=Id(i.path,o,t.path,n);return!(!Cd(e.prev,e.target)&&void 0===t._introClipFraction||(t._targetPath=e.target,t._prevPath=e.prev,t.path=e.prev.map(jd),0))}if(i.path.length===t.path.length){t._targetPath=t.path.map(jd),t._prevPath=i.path;for(let e=0;t.path.length>e;e++)t.path[e]=jd(i.path[e]);return!0}return!1}function Ed(e,t,i){if(!i.topPath||!i.bottomPath)return!1;const n=Rd(e,t,t.topPath.length),o=i.pathIds;if(o&&n&&o.length===i.topPath.length&&n.length===t.topPath.length&&i.bottomPath.length===i.topPath.length&&t.bottomPath.length===t.topPath.length){const e=Id(i.topPath,o,t.topPath,n),r=Id(i.bottomPath,o,t.bottomPath,n);return!(!Cd(e.prev,e.target)&&!Cd(r.prev,r.target)&&void 0===t._introClipFraction||(t._targetTopPath=e.target,t._targetBottomPath=r.target,t._prevTopPath=e.prev,t._prevBottomPath=r.prev,t.topPath=e.prev.map(jd),t.bottomPath=r.prev.map(jd),0))}if(i.topPath.length===t.topPath.length&&i.bottomPath.length===t.bottomPath.length){t._targetTopPath=t.topPath.map(jd),t._targetBottomPath=t.bottomPath.map(jd),t._prevTopPath=i.topPath,t._prevBottomPath=i.bottomPath;for(let e=0;t.topPath.length>e;e++)t.topPath[e]=jd(i.topPath[e]);for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=jd(i.bottomPath[e]);return!0}return!1}function Fd(e,t,i,n,o){if(!i)return t._targetOpacity=t.style.opacity??1,t._startOpacity=0,t.style={...t.style,opacity:0},!0;n.add(o);const r="line"===t.type?Od(e,t,i):Ed(e,t,i);return t._targetOpacity=t.style.opacity??1,t._startOpacity=i.opacity??t.style.opacity??1,r}function Nd(e,t){const i=[];for(const[n,o]of e)if(!t.has(n))if(n.startsWith("l:")&&o.path){const e={type:"line",path:o.path.map(jd),group:n.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:o.opacity??1},_targetOpacity:0,_transitionKey:n,datum:null};i.push(e)}else if(n.startsWith("a:")&&o.topPath&&o.bottomPath){const e={type:"area",topPath:o.topPath.map(jd),bottomPath:o.bottomPath.map(jd),group:n.slice(2),style:{fill:"#999",opacity:o.opacity??1},_targetOpacity:0,_transitionKey:n,datum:null};i.push(e)}return i}function zd(e,t){if(void 0!==e._targetOpacity&&(e.style={...e.style,opacity:xd(e._startOpacity??0,e._targetOpacity,t)}),void 0!==e._introClipFraction&&(e._introClipFraction=t),"line"===e.type){const i=e._prevPath,n=e._targetPath;if(i&&n&&i.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=xd(i[o][0],n[o][0],t),e.path[o][1]=xd(i[o][1],n[o][1],t);return}const i=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(i&&o&&i.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=xd(i[n][0],o[n][0],t),e.topPath[n][1]=xd(i[n][1],o[n][1],t);if(n&&r&&n.length===e.bottomPath.length)for(let i=0;e.bottomPath.length>i;i++)e.bottomPath[i][0]=xd(n[i][0],r[i][0],t),e.bottomPath[i][1]=xd(n[i][1],r[i][1],t)}function Dd(e){if("line"===e.type){const t=e._targetPath;if(t)for(let i=0;e.path.length>i;i++)e.path[i]=t[i];return e._prevPath=void 0,e._targetPath=void 0,void(e._introClipFraction=void 0)}const t=e._targetTopPath,i=e._targetBottomPath;if(t)for(let i=0;e.topPath.length>i;i++)e.topPath[i]=t[i];if(i)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=i[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}function Bd(e,t,i){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 i=e.getX(t.datum),n=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${i}:${n}`;if(null!=i&&null!=n)return`p:${i}:${n}`}return"p:"+i;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+i;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??i}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+i:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Wd(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Yd(e,t,i,n){i.clear(),n.clear();for(let o=0;t.length>o;o++){const r=t[o],s=Bd(e,r,o);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:Wd(r.style)}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:Wd(r.style),glyph:r.glyph}):"rect"===r.type||"heatcell"===r.type?i.set(s,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:Wd(r.style)}):"candlestick"===r.type?i.set(s,{x:r.x,y:r.openY,w:r.bodyWidth,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY,opacity:Wd(r.style)}):"line"!==r.type&&"area"!==r.type||Td(e,r,s,n))}}function qd(e,t,i,n,o,r=bd()){if(0===n.size&&0===o.size)return i;const s=t.duration??300;if(i.exitNodes.length>0){const e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}let a=!1;const c=/* @__PURE__ */new Set,l=/* @__PURE__ */new Set;for(let t=0;i.scene.length>t;t++){const r=i.scene[t],s=Bd(e,r,t);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){Fd(e,r,o.get(s),l,s)&&(a=!0);continue}const u=n.get(s);if("point"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,r:r.r};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.r===e.r||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.r,r.x=u.x,r.y=u.y,r.r=u.r??r.r,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style,opacity:0},a=!0;else if("glyph"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,size:r.size};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.r===e.size||(r._targetX=e.x,r._targetY=e.y,r._targetR=e.size,r.x=u.x,r.y=u.y,r.size=u.r??r.size,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style,opacity:0},a=!0;else if("rect"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style,opacity:0},a=!0;else if("heatcell"===r.type)if(u){c.add(s);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=Wd(r.style),u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(r._targetX=e.x,r._targetY=e.y,r._targetW=e.w,r._targetH=e.h,r.x=u.x,r.y=u.y,r.w=u.w??r.w,r.h=u.h??r.h,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style||{},opacity:0},a=!0;else if("candlestick"===r.type)if(u&&null!=u.openY){c.add(s);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=Wd(r.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.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=u.x,r.openY=u.openY,r.closeY=u.closeY??r.closeY,r.highY=u.highY??r.highY,r.lowY=u.lowY??r.lowY,a=!0)}else r._targetOpacity=Wd(r.style),r.style={...r.style||{},opacity:0},a=!0}const u=Nd(o,l);u.length&&(i.exitNodes.push(...u),a=!0);for(const[e,t]of n)if(!c.has(e)){if(e.startsWith("p:"))i.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)i.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))i.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const n=t.openY??t.y;i.exitNodes.push({type:"candlestick",x:t.x,openY:n,closeY:t.closeY??n,highY:t.highY??n,lowY:t.lowY??n,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:r,duration:s}),i}function Xd(e,t,i,n,o){if(!i.activeTransition)return!1;const r=md(e,i.activeTransition),s=gd(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of i.scene){const t=e._transitionKey;if("line"!==e.type&&"area"!==e.type){if("point"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style.opacity=xd(i?i.opacity??1:0,e._targetOpacity,s)}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.r=xd(i.r,e._targetR,s))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style.opacity=xd(i?i.opacity??1:0,e._targetOpacity,s)}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.size=xd(i.r,e._targetR,s))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style.opacity=xd(i?i.opacity??1:0,e._targetOpacity,s)}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==i.w&&(e.w=xd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=xd(i.h,e._targetH,s))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style={...e.style||{},opacity:xd(i?i.opacity??1:0,e._targetOpacity,s)}}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),e.y=xd(i.y,e._targetY,s),void 0!==i.w&&(e.w=xd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=xd(i.h,e._targetH,s))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const i=t?n.get(t):void 0;e.style={...e.style||{},opacity:xd(i?i.opacity??1:0,e._targetOpacity,s)}}if(void 0===e._targetX)continue;if(!t)continue;const i=n.get(t);if(!i)continue;e.x=xd(i.x,e._targetX,s),void 0!==i.openY&&(e.openY=xd(i.openY,e._targetOpenY,s)),void 0!==i.closeY&&(e.closeY=xd(i.closeY,e._targetCloseY,s)),void 0!==i.highY&&(e.highY=xd(i.highY,e._targetHighY,s)),void 0!==i.lowY&&(e.lowY=xd(i.lowY,e._targetLowY,s))}}else zd(e,s)}if(r>=1){for(const e of i.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style={...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("line"!==e.type&&"area"!==e.type){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("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=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 Dd(e)}if(i.exitNodes.length>0){const e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}function Gd(e){f_[e.chartType]=e}function Vd(e){return f_[e]}function Hd(e){Vd(e)||y_&&(g_.has(e)||(g_.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}function Ud(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:i,overlays:n,warned:o}=e;Kd(n)&&0===i.length&&Zd(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(e=>null==e.datum)&&Zd(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Kd(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Kd))}function Zd(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Qd(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}function Jd(e,t,i,n){const o=Qd(t),r="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:r,message:`Semiotic ${e} ${r} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:n}}function eh(e){try{return{kind:"success",result:e.run()}}catch(t){const i=e.hasPreviousResult,n=Jd(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:n,preservedLastGoodScene:i}}}function th(e,t){const i="function"==typeof e?e:i=>i[e||t];return e=>{const t=i(e);return null==t?NaN:+t}}function ih(e){const t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,n=th(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){const i=cd(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const i=Array.isArray(e.band)?e.band:[e.band];for(const e of i)t.push({kind:"band",getTop:th(e.y1Accessor,"y1"),getBottom:th(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function nh(e,t,i,n,o,r=!1){const s=/* @__PURE__ */new Map;for(const a of e){const e=t(a),c=i(a);if(null==e||null==c||Number.isNaN(e)||Number.isNaN(c))continue;const l=Math.floor(e/n)*n;let u=s.get(l);if(u||(u={start:l,end:l+n,total:0,categories:/* @__PURE__ */new Map,...r?{rows:[],categoryRows:/* @__PURE__ */new Map}:{}},s.set(l,u)),u.total+=c,u.rows?.push(a),o){const e=o(a);if(u.categories.set(e,(u.categories.get(e)||0)+c),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(a)}}}return s}function oh(e,t,i,n,o){const r=nh(e,t,i,n,o);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]}function rh(e,t){let i=0,n=0,o=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(o+=e,i>o&&(i=o),o>n&&(n=o))}return[i,n]}function sh(e,t,i,n,o,r){const s=[];for(const r of e){const e=i(r),a=n(r),c=o?o(r):0;if(!Number.isFinite(e)||!Number.isFinite(a)||!Number.isFinite(c))continue;const l=t.x(e),u=t.y(a),d=o?t.y(c):0;Number.isFinite(l)&&Number.isFinite(u)&&Number.isFinite(d)&&s.push({x:l,y:u,bottom:d,raw:a,datum:r})}s.sort((e,t)=>e.x-t.x);const a=Array(s.length),c=o?Array(s.length):[],l=Array(s.length),u=Array(s.length),d=r?Array(s.length):void 0;for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.x,t.y],o&&(c[e]=[t.x,t.bottom]),l[e]=t.raw,u[e]=t.datum,d&&r&&(d[e]=r(t.datum)+"")}return d?{topPath:a,bottomPath:c,rawValues:l,datum:u,pathIds:d}:{topPath:a,bottomPath:c,rawValues:l,datum:u}}function ah(e,t,i,n,o,r,s){const{topPath:a,rawValues:c,datum:l,pathIds:u}=sh(e,t,i,n,void 0,s),d={type:"line",path:a,rawValues:c,style:o,datum:l,group:r};return u&&(d.pathIds=u),d}function ch(e,t,i,n,o,r,s,a,c){return{type:"area",...sh(e,t,i,n,a??(()=>o),c),style:r,group:s}}function lh(e,t,i,n){const o=/* @__PURE__ */new Map;if("silhouette"===n)for(const n of e){let e=0;for(const o of t)e+=i(o,n)||0;o.set(n,-e/2)}else if("wiggle"===n){e.length>0&&o.set(e[0],0);for(let n=1;e.length>n;n++){const r=e[n-1],s=e[n];let a=0,c=0,l=0;for(const e of t){const t=i(e,s)||0;a+=(2*l+t)*(t-(i(e,r)||0)),c+=t,l+=t}const u=o.get(r)??0;o.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let n=0;for(const r of e){let e=0;for(const n of t)e+=i(n,r)||0;n+=(o.get(r)??0)+e/2}const r=n/e.length;for(const t of e)o.set(t,(o.get(t)??0)-r)}}else for(const t of e)o.set(t,0);return o}function uh(e,t,i){let n=0,o=0;for(const r of e){let e=0,s=0;for(const n of t){const t=i(n,r)||0;0>t?s+=t:e+=t}n>s&&(n=s),e>o&&(o=e)}return[n,o]}function dh(e,t,i,n,o,r,s,a="zero",c){const l=/* @__PURE__ */new Set,u=/* @__PURE__ */new Map;for(const t of e){const e=/* @__PURE__ */new Map;for(const o of t.data){const t=i(o),r=n(o);if(!Number.isFinite(t))continue;if(l.add(t),!Number.isFinite(r))continue;const s=e.get(t);s?(s.value+=r,s.sources?s.sources.push(o):s.sources=[s.datum,o]):e.set(t,{value:r,datum:o})}u.set(t.key,e)}const d=Array.from(l).sort((e,t)=>e-t);let h;if(r){h=/* @__PURE__ */new Map;for(const t of d){let i=0;for(const n of e)i+=u.get(n.key)?.get(t)?.value||0;h.set(t,i||1)}}const p=lh(d,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)?.value||0,a),f="diverging"===a&&!r,y=[],g=/* @__PURE__ */new Map,m=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=/* @__PURE__ */new Map;for(const e of d)m.set(e,p.get(e)??0),x.set(e,0),b.set(e,0);for(const i of e){const e=u.get(i.key),n=/* @__PURE__ */new Map;let a=[],l=[],p=[],v=[],w=[],k=c?[]:void 0,A=!1;const S=()=>{if(0!==a.length){if(a.length>=2){const e=A?a.map((e,t)=>t).sort((e,t)=>a[e][0]-a[t][0]):void 0,t=e?e.map(e=>v[e]):v,n={type:"area",topPath:e?e.map(e=>a[e]):a,bottomPath:e?e.map(e=>l[e]):l,rawValues:e?e.map(e=>p[e]):p,style:o(i.key,Ga(i.data)),datum:t,accessibleDatum:e?e.map(e=>w[e]):w,group:i.key};k&&(n.pathIds=e?e.map(e=>k[e]):k),s&&(n.curve=s),y.push(n)}a=[],l=[],p=[],v=[],w=[],k=c?[]:void 0,A=!1}};for(const o of d){const s=e.get(o),c=void 0!==s;let u,d,y=s?.value??0;if(r&&c&&(y/=h.get(o)),!c||!Number.isFinite(y)||0===y){S();continue}f?y>0?(u=x.get(o),d=u+y,x.set(o,d)):(u=b.get(o),d=u+y,b.set(o,d)):(u=m.get(o),d=u+y,m.set(o,d));const g=t.x(o),M=t.y(u),_=t.y(d);if(!Number.isFinite(g)||!Number.isFinite(M)||!Number.isFinite(_)){S();continue}const $=s.sources,P=s.value,j=$?{...$[0],__aggregateValue:P,__aggregateCount:$.length,__aggregateRows:$}:s.datum;a.length>0&&a[a.length-1][0]>g&&(A=!0),a.push([g,_]),l.push([g,M]),v.push(j),p.push(P),k&&k.push("x:"+o),w.push($?{x:o,value:P,group:i.key,observations:$.length}:j),n.set(o,d)}S(),g.set(i.key,n)}return{nodes:y,stackedTops:g}}function hh(e,t,i,n,o,r,s){const a=i(e),c=n(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:o,style:r,datum:e};return void 0!==s&&(l.pointId=s),l}function ph(e,t,i,n,o,r,s,a){const c=i(e),l=n(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:o,symbolType:r,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function fh(e,t,i,n,o,r,s){return{type:"rect",x:e,y:t,w:i,h:n,style:o,datum:r,group:s}}function yh(e,t,i,n,o,r,s){const a={type:"heatcell",x:e,y:t,w:i,h:n,fill:o,datum:r};return void 0!==s?.value&&(a.value=s.value),s?.showValues&&(a.showValues=!0,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function gh(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function mh(e){const{config:t,groups:i,getX:n,getY:o}=e,r="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){const i=[0,r?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Set;let l=0;const u=/* @__PURE__ */new Map,d=/* @__PURE__ */new Map;for(const e of i){const t=/* @__PURE__ */new Map;let i=0;for(const r of e.data){const e=n(r),s=o(r);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),i+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,i)}const h=t.stackOrder??"key",p=(e,t)=>t>e?-1:e>t?1:0;let f,y;if("input"===h)f=i.map(e=>e.key);else if("insideOut"===h){const e=[...i].map(e=>e.key).sort((e,t)=>{const i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:p(e,t)}),t=[],n=[];let o=0,r=0;for(const i of e)r>o?(t.push(i),o+=d.get(i)??0):(n.push(i),r+=d.get(i)??0);f=[...n.reverse(),...t]}else f="asc"===h?i.map(e=>e.key).sort((e,t)=>{const i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:p(e,t)}):"desc"===h?i.map(e=>e.key).sort((e,t)=>{const i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:p(e,t)}):i.map(e=>e.key).sort(p);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),i=lh(e,f,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let n=1/0,o=-1/0;for(const t of e){const e=i.get(t)??0,r=u.get(t)??0;n>e&&(n=e),e+r>o&&(o=e+r)}Number.isFinite(n)&&Number.isFinite(o)||(n=0,o=0);const s=o-n,l=r?0:s>0?s*t.extentPadding:1;y=[n-l,o+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[i,n]=uh(e,f,(e,t)=>a.get(e)?.get(t)||0),o=n-i,s=r?0:o>0?o*t.extentPadding:1;y=[i-s,n+s]}else y=[0,l+(r?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}function xh(e,t,i,n,o,r,s){const[,a]=oh(e,t,i,n,o);return[0,s?a:a+a*r]}function bh(e,t,i,n){const[o,r]=rh(e,t),s=r-o,a=n?0:s>0?s*i:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,r+Math.abs(a))]}function vh(e,t,i,n,o){const r=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(2>r.length)return gh(i,n);const s=r[0],a=r[1],c=r[r.length-1],l=r[r.length-2];return gh("log"===o&&s>0?[s/Math.sqrt(a/s),c*Math.sqrt(c/l)]:[s-(a-s)/2,c+(c-l)/2],n)}function wh(e,t,i){if(!i.length)return e;let[n,o]=e;for(const e of t)for(const t of i){const i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&(n>i&&(n=i),i>o&&(o=i)),Number.isFinite(r)&&(n>r&&(n=r),r>o&&(o=r))}return[n,o]}function kh(e,t){const i=e[1]-e[0],n=t.exactMode?0:i>0?i*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-n,null!=t.userMax?e[1]:e[1]+n];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}function Ah(e,t,i){if(!t||i)return e;const n=t[0],o=t[1];return null==n&&null==o?e:[null!=n?n:e[0],null!=o?o:e[1]]}function Sh(e,t,i){let n=e,o=t;if(n[0]===1/0||n[1]===-1/0)if("time"===i){const e=Date.now();n=[e-864e5,e]}else n=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:n,yDomain:o}}function Mh(e,t,i){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,m_.scaleLog)().domain(e).range(i).clamp(!0)}return"symlog"===e?(0,m_.scaleSymlog)().domain(t).range(i):"time"===e?(0,m_.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(i):(0,m_.scaleLinear)().domain(t).range(i)}function _h(e){const{config:t,layout:i,xDomain:n}=e,o=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,r="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(i.width,i.height)/2-1));if(r){const e="left"===t.arrowOfTime?[i.width-s,s]:[s,i.width-s];return{x:(0,m_.scaleLinear)().domain(n).range(e),y:Mh(t.yScaleType,o,[i.height-s,s])}}return{x:Mh(t.xScaleType,n,[s,i.width-s]),y:Mh(t.yScaleType,o,[i.height-s,s])}}function $h(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Wn(e,t):void 0}function Ph(e,t,i,n){if(n&&n.version===i&&n.group===t&&n.data===e)return{result:n.result,cache:n};let o;if(t){const i=/* @__PURE__ */new Map;for(const n of e){const e=t(n);i.has(e)||i.set(e,[]),i.get(e).push(n)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}function jh(e,t,i,n,o){if(o&&o.version===n)return{map:o.map,cache:o};const r=/* @__PURE__ */new Set;if(t)for(const i of e){const e=t(i);e&&r.add(e)}const s=Array.from(r).sort(),a=s.join("\0");if(o&&o.key===a){const e={...o,version:n};return{map:e.map,cache:e}}const c=zn(i.colorScheme,i.themeCategorical,oA),l=/* @__PURE__ */new Map;for(let e=0;s.length>e;e++)l.set(s[e],$h(i.colorScheme,s[e])??c[e%c.length]);return{map:l,cache:{key:a,map:l,version:n}}}function Ih(e){const{group:t,colorMapCache:i,groupColorMap:n,groupColorMapCap:o,config:r}=e;let{groupColorCounter:s}=e;const a=$h(r.colorScheme,t);if(a)return{color:a,groupColorCounter:s};if(i){const e=i.map.get(t);if(e)return{color:e,groupColorCounter:s}}const c=n.get(t);if(c)return{color:c,groupColorCounter:s};const l=zn(r.colorScheme,r.themeCategorical,oA);if(0===l.length)return{color:null,groupColorCounter:s};const u=l[s%l.length];if(s++,n.set(t,u),n.size>o){const e=n.keys().next().value;void 0!==e&&n.delete(e)}return{color:u,groupColorCounter:s}}function Lh(e,t,i,n){const o=e.lineStyle;if("function"==typeof o){const e=o(i||{},t);if(e&&!e.stroke&&t){const i=n(t);if(i)return{...e,stroke:i}}return e}const r=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:n(t)||r||"#007bff",strokeWidth:2}}function Rh(e,t,i,n){if(e.areaStyle){const o=e.areaStyle(i||{});if(o&&!o.fill&&t){const e=n(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(i||{},t);if(e&&!e.fill&&t){const i=n(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}const r=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||r||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||r||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};const s=n(t)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}function Ch(e,t,i,n){const o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;const r=n(t,i);return{fill:r.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=r.opacity&&{opacity:r.opacity},stroke:"none",cursor:r.cursor}}function Th(e,t,i){t>e.capacity&&(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Oh(e,t){const i=new d_(e.capacity);return e.forEach(()=>i.push(t)),i}function Eh(e,t,i,n){const o=e.push(t);return i&&i.push(n),o}function Fh(e,t,i){if(!t||0===t.size)return;const n=/* @__PURE__ */new Set;if(e.forEach((e,t)=>{i(e)&&n.add(t)}),0===n.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)n.has(e)||t.push(o[e])}function Nh(){return this.updateResults.last}function zh(){return this.updateResults.last}function Dh(e){return this.updateResults.subscribe(e)}function Bh(e){this.config.layoutSelection=e}function Wh(){x_.set(this,!0)}function Yh(){const e=!0===x_.get(this);return x_.delete(this),e}function qh(e){Object.assign(e.prototype,{getLastUpdateResult:Nh,getUpdateSnapshot:zh,subscribeUpdateResult:Dh,setLayoutSelection:Bh,markStylePaintPending:Wh,consumeStylePaintPending:Yh})}function Xh(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=j_[n]??I_;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Gh(e){for(const t of e){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("glyph"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0);else if("rect"===t.type||"heatcell"===t.type)void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0);else if("candlestick"===t.type)void 0!==t._targetX&&(t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0);else if("line"===t.type||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}function Vh(e){for(const t of e){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?void 0!==t._targetX?(t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}function Hh(e,t,i,n){return"function"==typeof t.style?t.style(n||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,n)}function Uh(e,t,i,n){if(!e.scales)return null;const{topPath:o,bottomPath:r,datum:s,pathIds:a}=sh(t,e.scales,e.getX,n.getTop,n.getBottom,e.getPointId);return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,...a&&{pathIds:a},...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:Hh(e,n,i,Ga(t)),datum:s,group:i,interactive:n.interactive}}function Kh(e){const t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(const n of e)n.perSeries?t.push(n):i.push(n);return{perSeries:t,aggregate:i}}function Zh(e,t,i){const n=[];for(const o of i){const i=Uh(e,t,"__ribbon_aggregate",o);i&&n.push(i)}return n}function Qh(e,t,i,n){const o=[];for(const r of n){const n=Uh(e,t,i,r);n&&o.push(n)}return o}function Jh(e,t,i,n){if(!e.config.pointStyle)return;const o=n??e.getY;for(const n of t){const t=e.resolveGroupColor(n.key);for(const r of n.data){let n=e.config.pointStyle(r);!n.fill&&t&&(n={...n,fill:t});const s=n.r??3,a=e.getPointId?e.getPointId(r)+"":void 0,c=hh(r,e.scales,e.getX,o,s,n,a);c&&i.push(c)}}}function ep(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function tp(e){return na(e)}function ip(e,t,i){if(i)return i;const n=e??"circle";if("chevron"===n)return rp(t);const o=Object.prototype.hasOwnProperty.call(F_,n)?F_[n]:E_.symbolCircle;return(0,E_.symbol)(o,Math.max(1,t))()??""}function np(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function op(e,t){const i=/* @__PURE__ */new Map;let n=0;return o=>{const r=e(o)+"",s=t&&Object.prototype.hasOwnProperty.call(t,r)?t[r]:void 0;if(s&&N_.has(s))return s;let a=i.get(r);return a||(a=z_[n%z_.length],n++,i.set(r,a)),a}}function rp(e){const t=1.5*np(e),i=.92*t;return`M0,${-t}L${i},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-i},${(.78*t).toFixed(3)}Z`}function sp(e,t){const i=[],n="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let r=null;if(e.getSize&&!e.config.pointStyle){const i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(const n of i)e>n&&(e=n),n>t&&(t=n);r=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=c?op(c,e.config.symbolMap):null;for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},c=t.r||n;if(r&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(c=r(t))}if(s&&e.getColor&&!t.fill){const i=e.getColor(o);i&&s.has(i)&&(t={...t,fill:s.get(i)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(l){const n=l(o),r=ph(o,e.scales,e.getX,e.getY,Math.PI*c*c,n,t,u);r&&i.push(r)}else{const n=hh(o,e.scales,e.getX,e.getY,c,t,u);n&&i.push(n)}}return i}function ap(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function cp(e){const t=Object.prototype.hasOwnProperty.call(Vk,e)?e:"blues";let i=B_.get(t);if(i)return i;i=Array(D_);const n=Nn(t);for(let e=0;D_>e;e++)i[e]=n(e/255);return B_.set(t,i),i}function lp(e,t,i){const n=i.config.areaStyle?.(t);return n&&("string"==typeof n.fill&&(e.fill=n.fill),e.style=n),e}function up(e,t,i){const n=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),r=e.config.heatmapAggregation??"count",s=cd(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/n,h=(u-l||1)/o,p=n*o;if(p>1e6)return[];const f=new Int32Array(p),y=new Float64Array(p),g=e.config.trackHoverRows||Va(e.config.areaStyle)?/* @__PURE__ */new Map:void 0;for(let i=0;t.length>i;i++){const r=t[i],c=e.getX(r),u=e.getY(r);if(!isFinite(c)||!isFinite(u))continue;const p=Math.min(Math.floor((c-a)/d),n-1),m=Math.min(Math.floor((u-l)/h),o-1);if(0>p||0>m)continue;const x=m*n+p;f[x]++;const b=s(r);if(y[x]+=isFinite(b)?b:0,g){let e=g.get(x);e||(e=[],g.set(x,e)),e.push(r)}}let m=1/0,x=-1/0;for(let e=0;p>e;e++){if(0===f[e])continue;let t;switch(r){case"sum":t=y[e];break;case"mean":t=y[e]/f[e];break;default:t=f[e]}m>t&&(m=t),t>x&&(x=t)}if(!isFinite(m))return[];const b=e.config.heatmapColorScale,v=b?void 0:cp("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),w=i.width/n,k=i.height/o,A=e.config.showValues,S=e.config.heatmapValueFormat,M=[];for(let t=0;o>t;t++){const i=t*n;for(let s=0;n>s;s++){const n=i+s;if(0===f[n])continue;let c;switch(r){case"sum":c=y[n];break;case"mean":c=y[n]/f[n];break;default:c=f[n]}const u=ap(c,m,x),p=b?b(c):v[u],_=A?{value:c,showValues:!0,valueFormat:S}:{value:c},$=Ya({xi:s,yi:t,value:c,count:f[n],sum:y[n],xCenter:a+(s+.5)*d,yCenter:l+(t+.5)*h,agg:r},g?.get(n));M.push(lp(yh(s*w,(o-1-t)*k,w,k,p,$,_),$,e))}}return M}function dp(){for(const e of Object.keys(W_))Vd(e)||Gd({chartType:e,buildScene:W_[e],canvasRenderers:[]})}function hp(e){const t=e.parts.filter(e=>null!=e),i={};for(const e of t)for(const[t,n]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+n;for(const[t,n]of Object.entries(e.additionalMarkCountByType??{}))n>0&&(i[t]=(i[t]??0)+n);const n=Object.values(i).reduce((e,t)=>e+t,0),o=0===n,r=Array.from(
|
|
222
|
+
/* @__PURE__ */new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),s="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${n} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:n,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:s,warnings:r,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function pp(e){const t={};for(const i of e){const e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}function fp(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function yp(e){if(!e||2>e.length)return;const t=fp(e[0]),i=fp(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function gp(e){const{count:t,byType:i}=pp(e.marks),n=0===t,o=[...e.extraWarnings??[]];n&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");const r=Array.isArray(e.annotations)?e.annotations.length:0,s="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,a=e.margin,c=a?{x:a.left,y:a.top,width:e.width-a.left-a.right,height:e.height-a.top-a.bottom}:void 0;return{component:"",frameType:e.frameType,status:n?"empty":"ok",empty:n,markCount:t,markCountByType:i,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:e.annotationRender?.renderedCount??r,...e.annotationRender?.layout?{layout:e.annotationRender.layout}:{},...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:s,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...a?{margin:a}:{},...c?{plot:c}:{}}}function mp(e,t,i){let n=i;for(const i of t)"lesser"===i.thresholdType?i.value>e&&(n=i.color):e>i.value&&(n=i.color);return n}function xp(e,t,i,n){if(2>e.length||t.length!==e.length||0===i.length)return[];const o=[],r=(e,t,i)=>{const n=o[o.length-1];n?.color===e?n.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;e.length>o;o++){const[s,a]=e[o-1],[c,l]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;h.length>e;e++){const t=h[e-1],o=h[e];r(mp(u+d*((t+o)/2),i,n),[s+(c-s)*t,a+(l-a)*t],[s+(c-s)*o,a+(l-a)*o])}}return o}function bp(e,t){const[i,n]=e.viewBox??G_,[o,r]=e.anchor??V_,s=n>0?n:1,a=Math.max(0,t)/s,c=(i>0?i:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-o*c,offsetY:-r*l}}function vp(e,t,i,n){if("none"!==e)return"color"===e||null==e?t??n:"accent"===e?i:e}function wp(e,t,i=0,n="horizontal"){const[o,r]=e.viewBox??G_,s=Math.min(1,Math.max(0,i)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===n?{x:0,y:r*(1-a),width:o,height:r*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:r}:null:{x:0,y:0,width:0,height:0}}function kp(e,t){const i=bp(e,t);return{centerDx:i.offsetX+i.width/2,centerDy:i.offsetY+i.height/2,halfWidth:i.width/2,halfHeight:i.height/2,radius:Math.hypot(i.width,i.height)/2}}function Ap(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const i=Math.min(e.w,e.h)/2,n=e=>Math.max(0,Math.min(e??0,i));return{tl:n(t.tl),tr:n(t.tr),br:n(t.br),bl:n(t.bl)}}function Sp(e,t="#4e79a7"){return Mr(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Mp(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function _p(e,t,i,n){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const r=bp(o,e.size);if(0>=r.scale)return null;const s=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${r.offsetX},${r.offsetY}) scale(${r.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=wp(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?Mp(n+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,n)=>{const o=t?"none"===i.fill?void 0:t:vp(i.fill,a,e.accent),r=t?i.stroke&&"none"!==i.stroke?t:void 0:vp(i.stroke??"none",a,e.accent);return o||r?/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("path",{d:i.d,fill:o??"none",stroke:r,strokeWidth:r?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},n):null});/* @__PURE__ */ /* @__PURE__ */
|
|
223
223
|
return(0,H_.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("clipPath",{id:l,children:/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},n)}function $p(e,t){const i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>i.length?null:i.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function Pp(e,t){const i=e.fillGradient;if(!i||"object"!=typeof i)return null;let n=e.x,o=e.y,r=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,s=e.y):"right"===e.roundedEdge?(n=e.x+e.w,o=e.y,r=e.x,s=e.y):"left"===e.roundedEdge&&(n=e.x,o=e.y,r=e.x+e.w,s=e.y);const a=$p(i.stops,Sp(e.style.fill));return a?/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:n,y1:o,x2:r,y2:s,children:a}):null}function jp(e){const{x:t,y:i,w:n,h:o}=e,{tl:r,tr:s,br:a,bl:c}=Ap(e);let l=`M${t+r},${i}`;return l+=` L${t+n-s},${i}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+n},${i+s}`),l+=` L${t+n},${i+o-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+n-a},${i+o}`),l+=` L${t+c},${i+o}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${i+o-c}`),l+=` L${t},${i+r}`,r>0&&(l+=` A${r},${r} 0 0 1 ${t+r},${i}`),l+=" Z",l}function Ip(e,t,i){const n=ip(e.symbolType,e.size,e.path);/* @__PURE__ */ /* @__PURE__ */
|
|
224
|
-
return(0,H_.jsx)("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Sp(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function Lp(e,t,i){const n="point"===e.type,o=n?"circle":"rect",r=n?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},s=`${i?i+"-":""}${n?"point":"xyrect"}-${t}-hatch`,a=
|
|
225
|
-
return(0,H_.jsxs)(X_.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("defs",{children:a}),X_.createElement(o,{...r,fill:a?`url(#${s})`:Sp(e.style.fill),opacity:n?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}function Rp(e){if(!1!==e?.interactive)return e?.style?.cursor}function Cp(e,t,i){const n=Rp(t);return n&&null!=e&&!1!==e?/* @__PURE__ */ /* @__PURE__ */(0,K_.jsx)("g",{style:{cursor:n},"data-semiotic-mark-cursor":n,children:e},i):e}function Tp(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]}function Op(e,t){const i=e.fillGradient;if(!i||"object"!=typeof i)return null;let n=1/0;for(const[,t]of e.topPath)n=Math.min(n,t);let o=-1/0;for(const[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(n)||!Number.isFinite(o))return null;const r=$p(i.stops,Sp(e.style.fill));return r?/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:n,x2:0,y2:o,children:r}):null}function Ep(e,t,i,n){if(!e||2>t.length)return null;const o=$p(e.stops,n);return o?/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Fp(e,t,i,n=30){const o=Np(e,t,i,n);return"area"===e.type?o:Cp(o,e,"xy-cursor-"+t)}function Np(e,t,i,n=30){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o=
|
|
224
|
+
return(0,H_.jsx)("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Sp(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function Lp(e,t,i){const n="point"===e.type,o=n?"circle":"rect",r=n?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},s=`${i?i+"-":""}${n?"point":"xyrect"}-${t}-hatch`,a=Mr(e.style.fill)?Pr(e.style.fill,s):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
225
|
+
return(0,H_.jsxs)(X_.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,H_.jsx)("defs",{children:a}),X_.createElement(o,{...r,fill:a?`url(#${s})`:Sp(e.style.fill),opacity:n?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}function Rp(e){if(!1!==e?.interactive)return e?.style?.cursor}function Cp(e,t,i){const n=Rp(t);return n&&null!=e&&!1!==e?/* @__PURE__ */ /* @__PURE__ */(0,K_.jsx)("g",{style:{cursor:n},"data-semiotic-mark-cursor":n,children:e},i):e}function Tp(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]}function Op(e,t){const i=e.fillGradient;if(!i||"object"!=typeof i)return null;let n=1/0;for(const[,t]of e.topPath)n=Math.min(n,t);let o=-1/0;for(const[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(n)||!Number.isFinite(o))return null;const r=$p(i.stops,Sp(e.style.fill));return r?/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:n,x2:0,y2:o,children:r}):null}function Ep(e,t,i,n){if(!e||2>t.length)return null;const o=$p(e.stops,n);return o?/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Fp(e,t,i,n=30){const o=Np(e,t,i,n);return"area"===e.type?o:Cp(o,e,"xy-cursor-"+t)}function Np(e,t,i,n=30){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o=Lr(n.curve),r=o?(0,q_.line)().x(([e])=>e).y(([,e])=>e).curve(o)(n.path)??"":"M"+n.path.map(([e,t])=>`${e},${t}`).join("L"),s=Mp(`${i?i+"-":""}line-${t}-stroke-gradient`),a=Ep(n.strokeGradient,n.path,s,n.style.stroke||"#4e79a7");/* @__PURE__ */ /* @__PURE__ */
|
|
226
226
|
return(0,Z_.jsxs)(Y_.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("defs",{children:a}),
|
|
227
227
|
/* @__PURE__ */
|
|
228
|
-
/* @__PURE__ */(0,Z_.jsx)("path",{d:r,fill:"none",stroke:a?`url(#${s})`:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth??2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})]},"line-"+t)}case"area":{const o=e;if(0===o.topPath.length)return null;const r=
|
|
228
|
+
/* @__PURE__ */(0,Z_.jsx)("path",{d:r,fill:"none",stroke:a?`url(#${s})`:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth??2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity})]},"line-"+t)}case"area":{const o=e;if(0===o.topPath.length)return null;const r=Lr(o.curve),s=!r||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:(0,q_.area)().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(r)(o.topPath)??"",a=`${i?i+"-":""}area-${t}-hatch`,c=Mr(o.style.fill)?Pr(o.style.fill,a):void 0,l=Mp(`${i?i+"-":""}area-${t}-gradient`),u=Op(o,l),d=u?`url(#${l})`:c?`url(#${a})`:Sp(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,p=r?(0,q_.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=Rp(o),y=f&&n>=0?/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*n),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:f},"data-semiotic-mark-cursor":f,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,g=Mp(`${i?i+"-":""}area-${t}-stroke-gradient`),m=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),x=!!o.strokeColorBands?.length,b=m||x?null:Ep(o.strokeGradient,o.topPath,g,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2;let w=1/0,k=-1/0;for(const[e]of o.topPath)w>e&&(w=e),e>k&&(k=e);const A=x?o.strokeColorBands.map((e,n)=>Mp(`${i?i+"-":""}area-${t}-stroke-band-${n}`)):[],S=x?o.strokeColorBands.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("clipPath",{id:A[t],children:/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?x?o.strokeColorBands.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("path",{d:p,fill:"none",stroke:e.color??Sp(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?xp(o.topPath,o.rawValues,o.colorThresholds,Sp(o.style.stroke)).map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("path",{d:p,fill:"none",stroke:b?`url(#${g})`:Sp(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){const e=`${i?i+"-":""}area-clip-${t}`;/* @__PURE__ */ /* @__PURE__ */
|
|
229
229
|
return(0,Z_.jsxs)("g",{children:[
|
|
230
230
|
/* @__PURE__ */
|
|
231
231
|
/* @__PURE__ */(0,Z_.jsxs)("defs",{children:[u,!u&&c,b,S,
|
|
@@ -243,7 +243,7 @@ return(0,Z_.jsxs)("g",{children:[
|
|
|
243
243
|
/* @__PURE__ */(0,Z_.jsx)("rect",{...n}),
|
|
244
244
|
/* @__PURE__ */
|
|
245
245
|
/* @__PURE__ */(0,Z_.jsx)("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},"heatcell-"+t)}/* @__PURE__ */ /* @__PURE__ */
|
|
246
|
-
return(0,Z_.jsx)("rect",{...n},"heatcell-"+t)}case"candlestick":{const n=e,o=`${i?i+"-":""}candle-${t}-hatch`,r=
|
|
246
|
+
return(0,Z_.jsx)("rect",{...n},"heatcell-"+t)}case"candlestick":{const n=e,o=`${i?i+"-":""}candle-${t}-hatch`,r=Mr(n.style?.fill)?Pr(n.style.fill,o):void 0,s=r?`url(#${o})`:void 0,{fill:a,...c}=n.style??{};if(n.isRange){const e=n.dotRadius??Math.max(2,n.bodyWidth/2),i=s??n.wickColor;/* @__PURE__ */ /* @__PURE__ */
|
|
247
247
|
return(0,Z_.jsxs)(Y_.Fragment,{children:[r&&/* @__PURE__ */ /* @__PURE__ */(0,Z_.jsx)("defs",{children:r}),
|
|
248
248
|
/* @__PURE__ */
|
|
249
249
|
/* @__PURE__ */(0,Z_.jsxs)("g",{style:c,children:[
|
|
@@ -259,7 +259,7 @@ return(0,Z_.jsxs)(Y_.Fragment,{children:[r&&/* @__PURE__ */ /* @__PURE__ */(0,Z_
|
|
|
259
259
|
/* @__PURE__ */
|
|
260
260
|
/* @__PURE__ */(0,Z_.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth,opacity:n.style?.opacity}),
|
|
261
261
|
/* @__PURE__ */
|
|
262
|
-
/* @__PURE__ */(0,Z_.jsx)("rect",{x:n.x-n.bodyWidth/2,y:l,width:n.bodyWidth,height:u,fill:h,stroke:s?n.wickColor:d,strokeWidth:1,opacity:n.style?.opacity})]})]},"candle-"+t)}default:return null}}function zp(e,t){const i="function"==typeof e?e(t.datum??null,t):e;return(n=i)&&"object"==typeof n&&"string"==typeof n.id&&"function"==typeof n.cacheKey&&"function"==typeof n.drawCanvas&&"function"==typeof n.renderStaticSVG?i:void 0;var n}function Dp(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${e}:${t}`;Q_.has(i)||(Q_.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Bp(e){const{node:t,index:i,renderMode:n,fallback:o}=e,r=zp(n,t);if(!r)return{element:o(),renderedByBackend:!1};const s=r.renderStaticSVG({node:t,style:t.style??{},key:`${r.id}-${i}`});return null!=s?{element:Cp(s,t,`${r.id}-${i}-cursor`),renderedByBackend:!0}:(Dp(r.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Wp(e){const t=[];return e.nodes.forEach((i,n)=>{const o=Bp({node:i,index:n,renderMode:e.renderMode,fallback:()=>e.fallback(i,n)});null!=o.element&&!1!==o.element&&t.push({node:i,index:n,...o})}),t}function Yp(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>
|
|
262
|
+
/* @__PURE__ */(0,Z_.jsx)("rect",{x:n.x-n.bodyWidth/2,y:l,width:n.bodyWidth,height:u,fill:h,stroke:s?n.wickColor:d,strokeWidth:1,opacity:n.style?.opacity})]})]},"candle-"+t)}default:return null}}function zp(e,t){const i="function"==typeof e?e(t.datum??null,t):e;return(n=i)&&"object"==typeof n&&"string"==typeof n.id&&"function"==typeof n.cacheKey&&"function"==typeof n.drawCanvas&&"function"==typeof n.renderStaticSVG?i:void 0;var n}function Dp(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${e}:${t}`;Q_.has(i)||(Q_.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Bp(e){const{node:t,index:i,renderMode:n,fallback:o}=e,r=zp(n,t);if(!r)return{element:o(),renderedByBackend:!1};const s=r.renderStaticSVG({node:t,style:t.style??{},key:`${r.id}-${i}`});return null!=s?{element:Cp(s,t,`${r.id}-${i}-cursor`),renderedByBackend:!0}:(Dp(r.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Wp(e){const t=[];return e.nodes.forEach((i,n)=>{const o=Bp({node:i,index:n,renderMode:e.renderMode,fallback:()=>e.fallback(i,n)});null!=o.element&&!1!==o.element&&t.push({node:i,index:n,...o})}),t}function Yp(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>Wn(e,t)??"#999"}const n=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:Tk;return(0,J_.scaleOrdinal)().domain(e).range(n)}function qp(e,t,i){if(0===e.length)return;const n=Yp(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:n(e.label)})}]}}function Xp(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Gp(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Vp(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Hp(e){return e.typography.legendFontWeight}function Up(e,t,i,n){const o=Gp(n);return t+i+Math.ceil(e.length*o*.58)}function Kp(e){const{categories:t,theme:i,position:n="right",totalWidth:o,margin:r,legendLayout:s}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=A(s),d=a+c,h="top"===n||"bottom"===n,p=Math.max(a,o-r.left-r.right),f=t.map(e=>Up(e,a,c,i));if(h){const e=Math.max(a,s?.maxWidth??p),i=[];let n=0,o=0;f.forEach((t,r)=>{const s=0===o?t:o+l+t;o>0&&s>e?(i.push({start:n,end:r,width:o}),n=r,o=t):o=s}),t.length>0&&i.push({start:n,end:t.length,width:o});const r=Xp(s?.align),c=[];return i.forEach((i,n)=>{let o="center"===r?Math.max(0,(e-i.width)/2):"end"===r?Math.max(0,e-i.width):0;for(let e=i.start;i.end>e;e++)c.push({category:t[e],width:f[e],x:o,y:n*u}),o+=f[e]+l}),{items:c,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}const y=f.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:f[t],x:0,y:t*u})),width:y,height:t.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}function Zp(e){const{legendGroups:t,theme:i,position:n="right",totalWidth:o,margin:r,legendLayout:s}=e,{swatchSize:a,labelGap:c,rowHeight:l}=A(s),u=a+c,d=Math.max(12,Gp(i)),h="top"===n||"bottom"===n,p=Math.max(a,o-r.left-r.right);if(h){const n=Math.max(a,s?.maxWidth??p),o=Xp(s?.align);let r=0,c=0;const l=[];for(const o of t){const t=o.items.map(e=>e.label),u=Kp({...e,categories:t,legendLayout:{...s,maxWidth:Math.max(a,n-d-8),align:"start"}}),h=o.label?d:0,p=o.label?Up(o.label,0,0,i):0,f=h>0?h+8:0,y=f+u.width,g=Math.max(u.height,p);l.push({group:o,x:r,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),r+=y+12,c=Math.max(c,g)}const h=l.length>0?r-12:0,f=h>n?0:"center"===o?Math.max(0,(n-h)/2):"end"===o?Math.max(0,n-h):0;return{groups:l.map(e=>({...e,x:e.x+f})),width:h,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const f=S(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),l);let y=0;return{groups:t.map((e,t)=>{const n=e.items.map(e=>Up(e.label,a,c,i)),o=Math.max(0,...n,e.label?Up(e.label,0,0,i):0);return y=Math.max(y,o),{group:e,x:0,y:f[t].itemsY,itemOffsetX:0,itemOffsetY:0,width:o,height:e.items.length*l,items:e.items.map((e,t)=>({category:e.label,width:n[t],x:0,y:t*l}))}}),width:y,height:f.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function Qp(e){const t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?gw:mw,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?yw+108:108,swatchSize:14}}function Jp(e){const{categories:t,colorScheme:i,theme:n,position:o="right",totalWidth:r,totalHeight:s,margin:a}=e;if(!t||0===t.length)return null;const c=Yp(t,i,n),l="top"===o||"bottom"===o,u=Kp(e),d={...qp(t,i,n),legendDistance:e.legendDistance},p=e.reservedWidth??h(d,e.legendLayout),{x:f,y:y}=k(d,{totalWidth:r,totalHeight:s,margin:a,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:p});if(l){const e=u.items.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,e$.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[
|
|
263
263
|
/* @__PURE__ */
|
|
264
264
|
/* @__PURE__ */(0,e$.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(e.category),rx:u.swatchRadius}),
|
|
265
265
|
/* @__PURE__ */
|
|
@@ -331,10 +331,10 @@ return(0,h$.jsx)(xf,{"data-testid":"semiotic-annotation",events:o,...t,type:n},s
|
|
|
331
331
|
/* @__PURE__ */
|
|
332
332
|
/* @__PURE__ */(0,p$.jsx)("style",{children:k$},"annotation-disclosure-style")),r&&a.unshift(
|
|
333
333
|
/* @__PURE__ */
|
|
334
|
-
/* @__PURE__ */(0,p$.jsx)("style",{children:A$},"annotation-cohesion-style")),a}function Mf(e,t,i,n){const o=[];return e.forEach((e,r)=>{let s;if(i){const o=i(e,r,n);s=null!=o?o:t(e,r,n)}else s=t(e,r,n);s&&o.push({node:s,annotation:e})}),{nodes:Sf(o),renderedAnnotations:o.map(e=>e.annotation)}}function _f(e,t){const i=t.scales?.x??t.scales?.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function $f(e,t){const i=t.scales?.y??t.scales?.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Pf(e){const t=e.data;if(!t||0===t.length)return null;const i=t[t.length-1],n=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!n||!o)return null;const r=i[e.xAccessor||"x"],s=i[e.yAccessor||"y"];return null==r||null==s?null:{x:n(r),y:o(s)}}function jf(e){return null==e?null:e+""}function If(e){return jf(e.provenance?.stableId??e.stableId)}function Lf(e){return jf(e.stableId??e.id??e.provenance?.stableId)}function Rf(e,t,i){return t.stickyPositionCache?.set(e,i),i}function Cf(e,t,i){const n=If(e);if(!n)return null;const o=i.pointNodes?.find(e=>jf(e.pointId)===n);if(o)return Rf(t,i,{x:o.x,y:o.y});const r=i.data?.find(e=>Lf(e)===n);if(!r)return null;const s=_f(r,i),a=$f(r,i);return null==s||null==a?null:Rf(t,i,{x:s,y:a})}function Tf(e,t,i){const n=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===n){if(null!=e.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let n=i.pointNodes.length-1;n>=0;n--){const o=i.pointNodes[n];if(o.pointId===e.pointId)return Rf(t,i,{x:o.x,y:o.y})}const n=Pf(i);return n?Rf(t,i,n):null}if("semantic"===n){const n=Cf(e,t,i);if(n)return n}let o=null,r=null;if(null!=e.pointId&&i.pointNodes){const t=i.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,r=t.y)}if(null!=o&&null!=r||(o=_f(e,i),r=$f(e,i)),null!=o&&null!=r)return Rf(t,i,{x:o,y:r});if("sticky"===n){const e=i.stickyPositionCache?.get(t);if(e)return e}return null}function Of(e,t,i,n=50){return!(-n>e||e>(i.width||0)+n||-n>t||t>(i.height||0)+n)}function Ef(e){return"string"==typeof e?.type?e.type:""}function Ff(e){return!!e&&"object"==typeof e&&S$.has(Ef(e))}function Nf(e){return"primary"===e?.emphasis||!0===e?.defensive}function zf(e,t,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:M$))):1/0}function Df(e){let t;const i=e?.emphasis;t="primary"===i?100:"secondary"===i?10:50;const n=e?.provenance?.confidence;switch("number"==typeof n&&Number.isFinite(n)&&(t+=15*Math.max(0,Math.min(1,n))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function Bf(e){const{annotations:t,width:i,height:n}=e,o=Math.max(0,e.minVisible??_$),r=zf(i,n,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(i=e,Ff(i))};var i}),a=s.filter(e=>e.note);if(0===a.length||r>=a.length)return{visible:t.slice(),deferred:[],budget:r};const c=a.filter(e=>Nf(e.annotation)),l=a.filter(e=>!Nf(e.annotation)).sort((e,t)=>Df(t.annotation)-Df(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,r-c.length),Math.max(0,o-c.length))),d=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],p=[];for(const{annotation:e,index:t,note:i}of s)!i||d.has(t)?h.push(e):p.push(e);return{visible:h,deferred:p,budget:r}}function Wf(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:R$,dy:C$}}function Yf(e){const t=e?.familiarity;if(!t)return E$;const i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?E$:i.reduce((e,t)=>e+t,0)/i.length}function qf(e){if(!e)return 1;const t=Yf(e);return t>2?4>t?1:.6:1.5}function Xf(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(F$,t.source)?F$[t.source]:t.source:null,n="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!i&&!n)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[i,n].filter(Boolean).join(" · "),r="string"==typeof e.label?e.label:"";return r.includes(`(${o})`)?e:{...e,label:r?`${r} (${o})`:`(${o})`}}function Gf(e,t){let i=!1;const n=e.map(e=>Uf(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(i=!0,{...e,cohesion:t}):e);return i?n:e}function Vf(e){if(!Uf(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Hf(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<T$?e:{...e,_redundantConnector:!0}}function Uf(e){return Ff(e)}function Kf(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t=hf(e);if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const i="number"==typeof e.wrap?e.wrap:120,n=[...pf("string"==typeof e.title?e.title:void 0,i,7),...pf("string"==typeof e.label?e.label:void 0,i,7)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(i,7*o)+10),height:Math.max(18,16*n.length+6)}}function Zf(e,t,i,n,o){const r=e+i,s=t+n;return Math.abs(i)>Math.abs(n)?{x:0>i?r-o.width-4:r+4,y:0>n?s-o.height:s,width:o.width,height:o.height}:{x:0>i?r-o.width:r,y:0>n?s-o.height-4:s+4,width:o.width,height:o.height}}function Qf(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Jf(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function ey(e,t,i,n){const o=Math.max(0,n-e.x),r=Math.max(0,n-e.y);return(o+Math.max(0,e.x+e.width-(t-n)))*e.height+(r+Math.max(0,e.y+e.height-(i-n)))*e.width}function ty(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function iy(e,t){return(e.pointNodes||[]).map(e=>{const i=Math.max(1,e.r||1)+t;return{x:e.x-i,y:e.y-i,width:2*i,height:2*i}})}function ny(e,t,i,n,o,r,s,a){const c=Qf(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*ey(c,o,r,a);for(const e of i)l+=12*Jf(c,e);for(const e of n)l+=4*Jf(c,e);return l}function oy(e,t,i){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const n=e.pointId??e.nodeId;if(null!=n&&i.pointNodes){const e=i.pointNodes.find(e=>e.pointId===n);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,r=i.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&r){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const i=r([e,t]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof e.x||"number"!=typeof e.y?Tf(e,t,i):{x:e.x,y:e.y}}function ry(e){const{annotations:t,context:i,defaultOffset:n=$$,notePadding:o=P$,markPadding:r=j$,edgePadding:s=I$,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=L$,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:p,mobile:f,cohesion:y,audience:g}=e,m=i.width||0,x=i.height||0,b="object"==typeof f?f:{},v=b.breakpoint??O$,w=!!f&&v>=m,k=w&&!1!==b.preferShortText?t.map(Vf):t,A=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,S=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!p?b.responsive??{minWidth:v}:p,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const $=[],P=iy(i,r);let j=!1;const I=k.map((e,t)=>{if(!Uf(e))return e;const r=oy(e,t,i);if(!r)return e;const u=Kf(!0===e.defensive?Xf(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=Wf(e);return $.push(Qf(Zf(r.x,r.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,p=1/0;for(const e of ty(n)){const t=ny(Zf(r.x,r.y,e.dx,e.dy,u),e,$,P,m,x,o,s);p>t&&(h=e,p=t)}if(!h)return e;const f=Qf(Zf(r.x,r.y,h.dx,h.dy,u),o);$.push(f);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=j?I:k.slice();let R=L;if(h){let e=!1;const t=L.map(t=>{const i=Hf(t);return i!==t&&(e=!0),i});R=e?t:L}{let e=!1;const t=R.map(t=>{if(!0!==t?.defensive)return t;const i=Xf(t);return i!==t&&(e=!0),i});R=e?t:R}const C=/* @__PURE__ */new Set;if(A){const e="object"==typeof A?A:{},t=qf(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??zf(m,x,e))*t))},{deferred:n}=Bf({annotations:R,width:m,height:x,...i});for(const e of n)C.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:O$)>=m)for(const e of R)Uf(e)&&"secondary"===e.emphasis&&C.add(e);if(C.size>0)for(const e of R)!0===e?.defensive&&C.delete(e);let T;return T=0===C.size?R:S?R.map(e=>C.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!C.has(e)),_?Gf(T,_):T}function sy(e,t,i,n){const o=_r(e.fill??e.color,t,n);return $r(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:n)??o}function ay(e,t={}){const i=!0===t.showRetractedAnnotations,n=!0===t.showSupersededAnnotations,o=/* @__PURE__ */new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!i)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!n)})}function cy(e,t,i){const n=e.position,o="string"==typeof n&&N$.has(n)?n:"bottom-left",r=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",s=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",a="top"===s?0:"bottom"===s?i:i/2;return{x:("left"===r?0:"right"===r?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:a+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===r?"start":"right"===r?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===s?"hanging":"bottom"===s?"auto":"middle"}}function ly(e,t,i,n){return{...cy(e,t,i),fill:e.fill??e.color??n.fill,fontSize:e.fontSize??n.fontSize,fontFamily:e.fontFamily??n.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}function uy({annotation:e,width:t,height:i,defaults:n=D$}){const o=e.label??e.text;return null==o?null:/* @__PURE__ */ /* @__PURE__ */(0,z$.jsx)("text",{...ly(e,t,i,n),children:o})}function dy(e){const t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}function hy(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function py(e,t={}){const i=dy(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(n){const o=hy(n);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function fy(e,t=.3){const i=e.length;if(2>i)return e.slice();const n=e.slice().sort((e,t)=>e[0]-t[0]),o=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.min(i,Math.max(2,Math.ceil(t*i))),a=Number.isFinite(s)&&o.every(Number.isFinite);let c=0,l=s-1;const u=[];for(let e=0;i>e;e++){const t=o[e];let n,d=0,h=i-1;if(a){for(;i-1>l&&Math.abs(o[c]-t)>=Math.abs(o[l+1]-t);)c++,l++;const e=Math.max(Math.abs(o[c]-t),Math.abs(o[l]-t));n=e||1,e>0&&(d=c,h=l)}else n=o.map(e=>Math.abs(e-t)).sort((e,t)=>e-t)[s-1]||1;let p=0,f=0,y=0,g=0,m=0;for(let e=d;h>=e;e++){const i=Math.abs(o[e]-t)/n,s=1>i?Math.pow(1-Math.pow(i,3),3):0;0!==s&&(p+=s,f+=s*o[e],y+=s*r[e],g+=s*o[e]*o[e],m+=s*o[e]*r[e])}if(0===p){u.push([t,r[e]]);continue}const x=p*g-f*f;if(1e-12>Math.abs(x))u.push([t,y/p]);else{const e=(p*m-f*y)/x;u.push([t,(y-e*f)/p+e*t])}}return u}function yy(e,t,i){switch(e.type){case"enclose":{const n=(e.coordinates||[]).map(e=>({x:_f({...e,type:"point"},i),y:$f({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const o=(0,B$.packEnclose)(n),r=e.padding||10;/* @__PURE__ */ /* @__PURE__ */
|
|
334
|
+
/* @__PURE__ */(0,p$.jsx)("style",{children:A$},"annotation-cohesion-style")),a}function Mf(e,t,i,n){const o=[];return e.forEach((e,r)=>{let s;if(i){const o=i(e,r,n);s=null!=o?o:t(e,r,n)}else s=t(e,r,n);s&&o.push({node:s,annotation:e})}),{nodes:Sf(o),renderedAnnotations:o.map(e=>e.annotation)}}function _f(e,t){const i=t.scales?.x??t.scales?.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function $f(e,t){const i=t.scales?.y??t.scales?.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Pf(e){const t=e.data;if(!t||0===t.length)return null;const i=t[t.length-1],n=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!n||!o)return null;const r=i[e.xAccessor||"x"],s=i[e.yAccessor||"y"];return null==r||null==s?null:{x:n(r),y:o(s)}}function jf(e){return null==e?null:e+""}function If(e){return jf(e.provenance?.stableId??e.stableId)}function Lf(e){return jf(e.stableId??e.id??e.provenance?.stableId)}function Rf(e,t,i){return t.stickyPositionCache?.set(e,i),i}function Cf(e,t,i){const n=If(e);if(!n)return null;const o=i.pointNodes?.find(e=>jf(e.pointId)===n);if(o)return Rf(t,i,{x:o.x,y:o.y});const r=i.data?.find(e=>Lf(e)===n);if(!r)return null;const s=_f(r,i),a=$f(r,i);return null==s||null==a?null:Rf(t,i,{x:s,y:a})}function Tf(e,t,i){const n=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===n){if(null!=e.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let n=i.pointNodes.length-1;n>=0;n--){const o=i.pointNodes[n];if(o.pointId===e.pointId)return Rf(t,i,{x:o.x,y:o.y})}const n=Pf(i);return n?Rf(t,i,n):null}if("semantic"===n){const n=Cf(e,t,i);if(n)return n}let o=null,r=null;if(null!=e.pointId&&i.pointNodes){const t=i.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,r=t.y)}if(null!=o&&null!=r||(o=_f(e,i),r=$f(e,i)),null!=o&&null!=r)return Rf(t,i,{x:o,y:r});if("sticky"===n){const e=i.stickyPositionCache?.get(t);if(e)return e}return null}function Of(e,t,i,n=50){return!(-n>e||e>(i.width||0)+n||-n>t||t>(i.height||0)+n)}function Ef(e){return"string"==typeof e?.type?e.type:""}function Ff(e){return!!e&&"object"==typeof e&&S$.has(Ef(e))}function Nf(e){return"primary"===e?.emphasis||!0===e?.defensive}function zf(e,t,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:M$))):1/0}function Df(e){let t;const i=e?.emphasis;t="primary"===i?100:"secondary"===i?10:50;const n=e?.provenance?.confidence;switch("number"==typeof n&&Number.isFinite(n)&&(t+=15*Math.max(0,Math.min(1,n))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function Bf(e){const{annotations:t,width:i,height:n}=e,o=Math.max(0,e.minVisible??_$),r=zf(i,n,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(i=e,Ff(i))};var i}),a=s.filter(e=>e.note);if(0===a.length||r>=a.length)return{visible:t.slice(),deferred:[],budget:r};const c=a.filter(e=>Nf(e.annotation)),l=a.filter(e=>!Nf(e.annotation)).sort((e,t)=>Df(t.annotation)-Df(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,r-c.length),Math.max(0,o-c.length))),d=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],p=[];for(const{annotation:e,index:t,note:i}of s)!i||d.has(t)?h.push(e):p.push(e);return{visible:h,deferred:p,budget:r}}function Wf(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:R$,dy:C$}}function Yf(e){const t=e?.familiarity;if(!t)return E$;const i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?E$:i.reduce((e,t)=>e+t,0)/i.length}function qf(e){if(!e)return 1;const t=Yf(e);return t>2?4>t?1:.6:1.5}function Xf(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(F$,t.source)?F$[t.source]:t.source:null,n="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!i&&!n)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[i,n].filter(Boolean).join(" · "),r="string"==typeof e.label?e.label:"";return r.includes(`(${o})`)?e:{...e,label:r?`${r} (${o})`:`(${o})`}}function Gf(e,t){let i=!1;const n=e.map(e=>Uf(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(i=!0,{...e,cohesion:t}):e);return i?n:e}function Vf(e){if(!Uf(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Hf(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<T$?e:{...e,_redundantConnector:!0}}function Uf(e){return Ff(e)}function Kf(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t=hf(e);if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const i="number"==typeof e.wrap?e.wrap:120,n=[...pf("string"==typeof e.title?e.title:void 0,i,7),...pf("string"==typeof e.label?e.label:void 0,i,7)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(i,7*o)+10),height:Math.max(18,16*n.length+6)}}function Zf(e,t,i,n,o){const r=e+i,s=t+n;return Math.abs(i)>Math.abs(n)?{x:0>i?r-o.width-4:r+4,y:0>n?s-o.height:s,width:o.width,height:o.height}:{x:0>i?r-o.width:r,y:0>n?s-o.height-4:s+4,width:o.width,height:o.height}}function Qf(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Jf(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function ey(e,t,i,n){const o=Math.max(0,n-e.x),r=Math.max(0,n-e.y);return(o+Math.max(0,e.x+e.width-(t-n)))*e.height+(r+Math.max(0,e.y+e.height-(i-n)))*e.width}function ty(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function iy(e,t){return(e.pointNodes||[]).map(e=>{const i=Math.max(1,e.r||1)+t;return{x:e.x-i,y:e.y-i,width:2*i,height:2*i}})}function ny(e,t,i,n,o,r,s,a){const c=Qf(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*ey(c,o,r,a);for(const e of i)l+=12*Jf(c,e);for(const e of n)l+=4*Jf(c,e);return l}function oy(e,t,i){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const n=e.pointId??e.nodeId;if(null!=n&&i.pointNodes){const e=i.pointNodes.find(e=>e.pointId===n);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,r=i.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&r){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const i=r([e,t]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof e.x||"number"!=typeof e.y?Tf(e,t,i):{x:e.x,y:e.y}}function ry(e){const{annotations:t,context:i,defaultOffset:n=$$,notePadding:o=P$,markPadding:r=j$,edgePadding:s=I$,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=L$,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:p,mobile:f,cohesion:y,audience:g}=e,m=i.width||0,x=i.height||0,b="object"==typeof f?f:{},v=b.breakpoint??O$,w=!!f&&v>=m,k=w&&!1!==b.preferShortText?t.map(Vf):t,A=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,S=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!p?b.responsive??{minWidth:v}:p,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const $=[],P=iy(i,r);let j=!1;const I=k.map((e,t)=>{if(!Uf(e))return e;const r=oy(e,t,i);if(!r)return e;const u=Kf(!0===e.defensive?Xf(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=Wf(e);return $.push(Qf(Zf(r.x,r.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,p=1/0;for(const e of ty(n)){const t=ny(Zf(r.x,r.y,e.dx,e.dy,u),e,$,P,m,x,o,s);p>t&&(h=e,p=t)}if(!h)return e;const f=Qf(Zf(r.x,r.y,h.dx,h.dy,u),o);$.push(f);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=j?I:k.slice();let R=L;if(h){let e=!1;const t=L.map(t=>{const i=Hf(t);return i!==t&&(e=!0),i});R=e?t:L}{let e=!1;const t=R.map(t=>{if(!0!==t?.defensive)return t;const i=Xf(t);return i!==t&&(e=!0),i});R=e?t:R}const C=/* @__PURE__ */new Set;if(A){const e="object"==typeof A?A:{},t=qf(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??zf(m,x,e))*t))},{deferred:n}=Bf({annotations:R,width:m,height:x,...i});for(const e of n)C.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:O$)>=m)for(const e of R)Uf(e)&&"secondary"===e.emphasis&&C.add(e);if(C.size>0)for(const e of R)!0===e?.defensive&&C.delete(e);let T;return T=0===C.size?R:S?R.map(e=>C.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!C.has(e)),_?Gf(T,_):T}function sy(e,t,i,n){const o=jr(e.fill??e.color,t,n);return Ir(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:n)??o}function ay(e,t={}){const i=!0===t.showRetractedAnnotations,n=!0===t.showSupersededAnnotations,o=/* @__PURE__ */new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!i)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!n)})}function cy(e,t,i){const n=e.position,o="string"==typeof n&&N$.has(n)?n:"bottom-left",r=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",s=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",a="top"===s?0:"bottom"===s?i:i/2;return{x:("left"===r?0:"right"===r?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:a+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===r?"start":"right"===r?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===s?"hanging":"bottom"===s?"auto":"middle"}}function ly(e,t,i,n){return{...cy(e,t,i),fill:e.fill??e.color??n.fill,fontSize:e.fontSize??n.fontSize,fontFamily:e.fontFamily??n.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}function uy({annotation:e,width:t,height:i,defaults:n=D$}){const o=e.label??e.text;return null==o?null:/* @__PURE__ */ /* @__PURE__ */(0,z$.jsx)("text",{...ly(e,t,i,n),children:o})}function dy(e){const t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}function hy(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function py(e,t={}){const i=dy(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(n){const o=hy(n);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function fy(e,t=.3){const i=e.length;if(2>i)return e.slice();const n=e.slice().sort((e,t)=>e[0]-t[0]),o=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.min(i,Math.max(2,Math.ceil(t*i))),a=Number.isFinite(s)&&o.every(Number.isFinite);let c=0,l=s-1;const u=[];for(let e=0;i>e;e++){const t=o[e];let n,d=0,h=i-1;if(a){for(;i-1>l&&Math.abs(o[c]-t)>=Math.abs(o[l+1]-t);)c++,l++;const e=Math.max(Math.abs(o[c]-t),Math.abs(o[l]-t));n=e||1,e>0&&(d=c,h=l)}else n=o.map(e=>Math.abs(e-t)).sort((e,t)=>e-t)[s-1]||1;let p=0,f=0,y=0,g=0,m=0;for(let e=d;h>=e;e++){const i=Math.abs(o[e]-t)/n,s=1>i?Math.pow(1-Math.pow(i,3),3):0;0!==s&&(p+=s,f+=s*o[e],y+=s*r[e],g+=s*o[e]*o[e],m+=s*o[e]*r[e])}if(0===p){u.push([t,r[e]]);continue}const x=p*g-f*f;if(1e-12>Math.abs(x))u.push([t,y/p]);else{const e=(p*m-f*y)/x;u.push([t,(y-e*f)/p+e*t])}}return u}function yy(e,t,i){switch(e.type){case"enclose":{const n=(e.coordinates||[]).map(e=>({x:_f({...e,type:"point"},i),y:$f({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const o=(0,B$.packEnclose)(n),r=e.padding||10;/* @__PURE__ */ /* @__PURE__ */
|
|
335
335
|
return(0,Y$.jsxs)("g",{children:[
|
|
336
336
|
/* @__PURE__ */
|
|
337
|
-
/* @__PURE__ */(0,Y$.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,Y$.jsx)(cf,{x:o.x,y:o.y-o.r-r-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"rect-enclose":{const n=(e.coordinates||[]).map(e=>({x:_f({...e,type:"point"},i),y:$f({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const o=e.padding||10,[r,s]=
|
|
337
|
+
/* @__PURE__ */(0,Y$.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+r,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,Y$.jsx)(cf,{x:o.x,y:o.y-o.r-r-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"rect-enclose":{const n=(e.coordinates||[]).map(e=>({x:_f({...e,type:"point"},i),y:$f({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const o=e.padding||10,[r,s]=Mt(n.map(e=>e.x)),[a,c]=Mt(n.map(e=>e.y)),l=r-o,u=s+o,d=a-o;/* @__PURE__ */ /* @__PURE__ */
|
|
338
338
|
return(0,Y$.jsxs)("g",{children:[
|
|
339
339
|
/* @__PURE__ */
|
|
340
340
|
/* @__PURE__ */(0,Y$.jsx)("rect",{x:l,y:d,width:u-l,height:c+o-d,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,Y$.jsx)(cf,{x:(l+u)/2,y:d-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"highlight":{const n=i.data||[],o="function"==typeof e.filter?n.filter(e.filter):e.field&&null!=e.value?n.filter(t=>t[e.field]===e.value):[],r={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};/* @__PURE__ */ /* @__PURE__ */
|
|
@@ -372,30 +372,30 @@ return(0,X$.jsxs)("g","horizontal"===i.projection?{children:[
|
|
|
372
372
|
return(0,X$.jsx)(bf,{noteData:{x:l,y:u,dx:h,dy:p,note:df(e),type:i,...n?{subject:n}:{},connector:e.connector||{end:"arrow"},color:f,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}/* @__PURE__ */ /* @__PURE__ */
|
|
373
373
|
return(0,X$.jsx)("g",{children:/* @__PURE__ */ /* @__PURE__ */(0,X$.jsx)("text",{x:l+h,y:u+p,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||s.typography.labelSize,fill:f,fontFamily:s.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}function Ay(e,t,i,n="right",o,r){if(null==e||!1===e)return null;const{x:s,y:a}=k(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:n,legendLayout:o,axisChrome:r});/* @__PURE__ */ /* @__PURE__ */
|
|
374
374
|
return(0,V$.jsx)("g",{transform:`translate(${s}, ${a})`,children:e})}function Sy(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:"c"+t,n=i+"-semiotic-title",o=i+"-semiotic-desc";return{titleId:n,descId:o,labelledBy:`${n} ${o}`}}function My(e,t){if(0===t.categories.length)return;const i=t.position||"right";w(e,{legend:qp(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function _y(e,t){w(e,{legend:t.legend,position:t.position||"right",size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function $y(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function Py(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function jy(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(const n of e)t>n.pixel&&(t=n.pixel),n.pixel>i&&(i=n.pixel);return{min:t,max:i}}function Iy(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ly(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:Iy(e)}}}function Ry(e,t,i){if("left"===e||"right"===e){const n="left"===e?i:0,o="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+n;for(let e=0;r>e;e++){const i=8*(e+1);s+=`L${Math.min(8*e+4,t)},${n+4*o}`,s+=`L${Math.min(i,t)},${n}`}return s}const n="bottom"===e?0:t,o="bottom"===e?1:-1,r=Math.ceil(i/8);let s=`M${n},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${n+4*o},${Math.min(8*e+4,i)}`,s+=`L${n},${Math.min(t,i)}`}return s}function Cy(e,t){const i=e.domain(),n=i[0],o=i[i.length-1],r=n instanceof Date,s=n instanceof Date?n.getTime():n,a=o instanceof Date?o.getTime():o;if(2>t||s===a)return r?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const i=e===t-1?a:s+e*c;l[e]=r?new Date(i):i}return l}function Ty(e,t,i){return"exact"===i?Cy(e,t):e.ticks(t)}function Oy(e){return"string"==typeof e||"number"==typeof e}function Ey(e){const{label:t,x:i,y:n,textAlign:o,fontSize:r,fontFamily:s,color:a}=e;/* @__PURE__ */ /* @__PURE__ */
|
|
375
|
-
return(0,U$.jsx)("foreignObject",{x:i,y:n,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */ /* @__PURE__ */(0,U$.jsx)("div",{style:{color:a,fontFamily:s,fontSize:r,textAlign:o,userSelect:"none"},children:t})})}function Fy(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ny(e,t){const i=Fy(e);if(!i)return!1;const n=Fy(t);return!n||i.getFullYear()!==n.getFullYear()||i.getMonth()!==n.getMonth()}function zy(e,t,i,n){return!!e&&("function"==typeof e?e(t.value,i):Ny(t.value,i>0?n[i-1].value:void 0))}function Dy(e,t){return e?.ticks??e?.tickCount??t}function By(e,t){if(2>=e.length)return e;const i=[e[0]];for(let n=1;e.length-1>n;n++)t>Math.abs(e[n].pixel-i[i.length-1].pixel)||i.push(e[n]);const n=e[e.length-1];return t>Math.abs(n.pixel-i[i.length-1].pixel)?i[i.length-1]=n:i.push(n),i}function Wy(e){const t=new Date(e instanceof Date?e.valueOf():e);return`${K$[t.getUTCMonth()]} ${t.getUTCDate()}`}function Yy(e){const t=Math.abs(e[1]-e[0]);return Z$>t?e=>{const i=new Date(e instanceof Date?e.valueOf():e);let n=`${(i.getUTCHours()+"").padStart(2,"0")}:${(i.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>t&&(n+=":"+(i.getUTCSeconds()+"").padStart(2,"0")),1e4>t&&(n+="."+(i.getUTCMilliseconds()+"").padStart(3,"0")),n}:Q$>t?Wy:5*Q$>t?e=>{const t=new Date(e instanceof Date?e.valueOf():e);return`${K$[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function qy(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function Xy(e){for(let t=1;e.length>t;t++){const i=e[t-1],n=e[t];if(Math.abs(n.pixel-i.pixel)<(qy(i.label)+qy(n.label))/2+8)return!0}return!1}function Gy(e){const{scale:t,axis:i,size:o,horizontal:r=!1,axisExtent:s}=e,a=i?.extent??s,c=t.domain(),l=Dy(i,5),u=Math.max(2,Math.floor(o/(r?70:30))),d="exact"===a?Math.max(2,l):Math.min(l,u),h=i?.tickValues??Ty(t,d,a),p=h.map(e=>e.valueOf()),f=i?.tickFormat||e.format||(c[0]instanceof Date||h[0]instanceof Date?Yy([c[0].valueOf(),c[c.length-1].valueOf()]):n(p)),y=(e,t)=>r?f(e,t,p):f(e),g=h.map((e,i)=>({value:e,pixel:t(e),label:y(e,i)}));let m=22;if(r){const e=g.reduce((e,t)=>Math.max(e,qy(t.label)),0);m=i?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=By(g,m);if(x.length>1&&(x=x.filter((e,t)=>{return 0===t||(n=x[t-1].label,!!("string"!=typeof(i=e.label)&&"number"!=typeof i||"string"!=typeof n&&"number"!=typeof n||i+""!=n+""));var i,n})),i?.includeMax&&x.length>0&&"exact"!==a&&!i.tickValues){const e=c[c.length-1];if(null!=e){const i=t(e),n=Math.abs(i-x[x.length-1].pixel);if(n>1){const t=y(e,x.length);m>n&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:i,label:t}]}}}return x}function Vy(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Hy(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let n=0;for(let e=0;i.length>e;e++)n=31*n+i.charCodeAt(e)|0;return"c"+(n>>>0).toString(36)}function Uy(e,t,i){return o(e.showLegend&&!e.__legendIncludesAutomatic?qp(t,e.colorScheme,i):void 0,e.legend)}function Ky(e,t){if(e.__autoLegendMargin)return eP[t]}function Zy(e,t){const i={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix,reservedWidth:t.reservedWidth,axisChrome:t.axisChrome,legendDistance:r(e)||s(e)?e.legendDistance:void 0};return r(e)?ef({...i,legendGroups:e.legendGroups}):s(e)?tf({...i,gradient:e.gradient}):null}function Qy(e,t){const{props:i,categories:n,theme:o,size:r,hasTitle:s}=t,a=i.legendPosition||"right",c={...e},l={theme:o,position:a,size:r,hasTitle:s,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:Ky(i,a)};if(null!=i.legend){const t=Uy(i,n,o);null!=t&&!1!==t&&_y(e,{...l,legend:t})}else i.showLegend&&n.length>0&&My(e,{...l,categories:n,colorScheme:i.colorScheme});return u(e,c,r,a),a}function Jy(e){const{props:t,categories:i,theme:n,size:o,margin:a,hasTitle:c}=e,l=t.legendPosition||"right",u={theme:n,position:l,size:o,margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){const e=Uy(t,i,n);return H$.isValidElement(e)?Ay(e,o,a,l,t.legendLayout,t.axisChrome):Zy(e,u)||(r(e)||s(e)?null:Ay(e??null,o,a,l,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?Jp({categories:i,colorScheme:t.colorScheme,theme:n,position:l,totalWidth:o[0],totalHeight:o[1],margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function eg(e,t,i,n,o,r){const s=e.scales;if(!s||"radial"===s.projection)return null;const{grid:a}=
|
|
375
|
+
return(0,U$.jsx)("foreignObject",{x:i,y:n,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */ /* @__PURE__ */(0,U$.jsx)("div",{style:{color:a,fontFamily:s,fontSize:r,textAlign:o,userSelect:"none"},children:t})})}function Fy(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ny(e,t){const i=Fy(e);if(!i)return!1;const n=Fy(t);return!n||i.getFullYear()!==n.getFullYear()||i.getMonth()!==n.getMonth()}function zy(e,t,i,n){return!!e&&("function"==typeof e?e(t.value,i):Ny(t.value,i>0?n[i-1].value:void 0))}function Dy(e,t){return e?.ticks??e?.tickCount??t}function By(e,t){if(2>=e.length)return e;const i=[e[0]];for(let n=1;e.length-1>n;n++)t>Math.abs(e[n].pixel-i[i.length-1].pixel)||i.push(e[n]);const n=e[e.length-1];return t>Math.abs(n.pixel-i[i.length-1].pixel)?i[i.length-1]=n:i.push(n),i}function Wy(e){const t=new Date(e instanceof Date?e.valueOf():e);return`${K$[t.getUTCMonth()]} ${t.getUTCDate()}`}function Yy(e){const t=Math.abs(e[1]-e[0]);return Z$>t?e=>{const i=new Date(e instanceof Date?e.valueOf():e);let n=`${(i.getUTCHours()+"").padStart(2,"0")}:${(i.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>t&&(n+=":"+(i.getUTCSeconds()+"").padStart(2,"0")),1e4>t&&(n+="."+(i.getUTCMilliseconds()+"").padStart(3,"0")),n}:Q$>t?Wy:5*Q$>t?e=>{const t=new Date(e instanceof Date?e.valueOf():e);return`${K$[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function qy(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function Xy(e){for(let t=1;e.length>t;t++){const i=e[t-1],n=e[t];if(Math.abs(n.pixel-i.pixel)<(qy(i.label)+qy(n.label))/2+8)return!0}return!1}function Gy(e){const{scale:t,axis:i,size:o,horizontal:r=!1,axisExtent:s}=e,a=i?.extent??s,c=t.domain(),l=Dy(i,5),u=Math.max(2,Math.floor(o/(r?70:30))),d="exact"===a?Math.max(2,l):Math.min(l,u),h=i?.tickValues??Ty(t,d,a),p=h.map(e=>e.valueOf()),f=i?.tickFormat||e.format||(c[0]instanceof Date||h[0]instanceof Date?Yy([c[0].valueOf(),c[c.length-1].valueOf()]):n(p)),y=(e,t)=>r?f(e,t,p):f(e),g=h.map((e,i)=>({value:e,pixel:t(e),label:y(e,i)}));let m=22;if(r){const e=g.reduce((e,t)=>Math.max(e,qy(t.label)),0);m=i?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=By(g,m);if(x.length>1&&(x=x.filter((e,t)=>{return 0===t||(n=x[t-1].label,!!("string"!=typeof(i=e.label)&&"number"!=typeof i||"string"!=typeof n&&"number"!=typeof n||i+""!=n+""));var i,n})),i?.includeMax&&x.length>0&&"exact"!==a&&!i.tickValues){const e=c[c.length-1];if(null!=e){const i=t(e),n=Math.abs(i-x[x.length-1].pixel);if(n>1){const t=y(e,x.length);m>n&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:i,label:t}]}}}return x}function Vy(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Hy(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let n=0;for(let e=0;i.length>e;e++)n=31*n+i.charCodeAt(e)|0;return"c"+(n>>>0).toString(36)}function Uy(e,t,i){return o(e.showLegend&&!e.__legendIncludesAutomatic?qp(t,e.colorScheme,i):void 0,e.legend)}function Ky(e,t){if(e.__autoLegendMargin)return eP[t]}function Zy(e,t){const i={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix,reservedWidth:t.reservedWidth,axisChrome:t.axisChrome,legendDistance:r(e)||s(e)?e.legendDistance:void 0};return r(e)?ef({...i,legendGroups:e.legendGroups}):s(e)?tf({...i,gradient:e.gradient}):null}function Qy(e,t){const{props:i,categories:n,theme:o,size:r,hasTitle:s}=t,a=i.legendPosition||"right",c={...e},l={theme:o,position:a,size:r,hasTitle:s,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:Ky(i,a)};if(null!=i.legend){const t=Uy(i,n,o);null!=t&&!1!==t&&_y(e,{...l,legend:t})}else i.showLegend&&n.length>0&&My(e,{...l,categories:n,colorScheme:i.colorScheme});return u(e,c,r,a),a}function Jy(e){const{props:t,categories:i,theme:n,size:o,margin:a,hasTitle:c}=e,l=t.legendPosition||"right",u={theme:n,position:l,size:o,margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){const e=Uy(t,i,n);return H$.isValidElement(e)?Ay(e,o,a,l,t.legendLayout,t.axisChrome):Zy(e,u)||(r(e)||s(e)?null:Ay(e??null,o,a,l,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?Jp({categories:i,colorScheme:t.colorScheme,theme:n,position:l,totalWidth:o[0],totalHeight:o[1],margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function eg(e,t,i,n,o,r){const s=e.scales;if(!s||"radial"===s.projection)return null;const{grid:a}=Yr(i),c=n?n+"-":"",l="vertical"===s.projection,u=r??Ty(s.r,5,o);/* @__PURE__ */ /* @__PURE__ */
|
|
376
376
|
return(0,J$.jsx)("g",l?{id:c+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{const n=s.r(e);/* @__PURE__ */ /* @__PURE__ */
|
|
377
377
|
return(0,J$.jsx)("line",{x1:0,y1:n,x2:t.width,y2:n,stroke:a,strokeWidth:.5},"gr-"+i)})}:{id:c+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{const n=s.r(e);/* @__PURE__ */ /* @__PURE__ */
|
|
378
|
-
return(0,J$.jsx)("line",{x1:n,y1:0,x2:n,y2:t.height,stroke:a,strokeWidth:.5},"gr-"+i)})})}function tg(e,t){const i=
|
|
378
|
+
return(0,J$.jsx)("line",{x1:n,y1:0,x2:n,y2:t.height,stroke:a,strokeWidth:.5},"gr-"+i)})})}function tg(e,t){const i=Yr(t.theme),n=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,s=t.idPrefix?Sy(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},a=r?s.titleId:void 0,c=t.description?s.descId:void 0,l=[a,c].filter(Boolean).join(" ")||void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
379
379
|
return(0,J$.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":l,style:{fontFamily:i.fontFamily},children:[r&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("title",{id:a,children:r}),t.description&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("desc",{id:c,children:t.description}),t.defs&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("defs",{children:t.defs}),n&&"transparent"!==n&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:n}),
|
|
380
380
|
/* @__PURE__ */
|
|
381
|
-
/* @__PURE__ */(0,J$.jsx)("g",{id:o+"data-area",transform:t.innerTransform,children:e}),r&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{id:o+"chart-title",x:t.width/2,y:sw,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:r}),t.legend&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function ig(e,t,n,o,r,s,a,c=!1){const l=
|
|
381
|
+
/* @__PURE__ */(0,J$.jsx)("g",{id:o+"data-area",transform:t.innerTransform,children:e}),r&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{id:o+"chart-title",x:t.width/2,y:sw,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:r}),t.legend&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function ig(e,t,n,o,r,s,a,c=!1){const l=Yr(o),u=n.legendPosition??"right",d=f(n.legendLayout,a?.leftAxis),h=f(n.legendLayout,a?.rightAxis),p=c&&"left"===u&&d>0?d:s?.left??n.margin?.left??40,y=c&&"right"===u&&h>0?h:s?.right??n.margin?.right??40,{xAxis:g,yAxis:m,xOrient:x,yOrient:b}=i(n.axes),v="top"===x?0:t.height,w="right"===b?t.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=Gy({scale:e.x,axis:g,size:t.width,horizontal:!0,format:n.xFormat||n.tickFormatTime,axisExtent:n.axisExtent}),M=Gy({scale:e.y,axis:m,size:t.height,format:n.yFormat||n.tickFormatValue,axisExtent:n.axisExtent}),_=!(!g?.autoRotate||!Xy(S)),$=jy(S),P=jy(M),j=g?.label??n.xLabel,I=m?.label??("right"===b?n.yLabelRight??n.yLabel:n.yLabel),L=Ly(g?.axisStyle,{stroke:l.border,strokeWidth:1}),R=Ly(m?.axisStyle,{stroke:l.border,strokeWidth:1}),C="right"===b?t.width+y-15:15-p;/* @__PURE__ */ /* @__PURE__ */
|
|
382
382
|
return(0,J$.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[!1!==g?.visible&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsxs)("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==g?.baseline&&!g?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("line",{x1:0,y1:v,x2:t.width,y2:v,...L}),g?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("path",{d:Ry(x,t.width,t.height),fill:"none",...L}),S.map((e,t)=>{const i=zy(g?.landmarkTicks,e,t,S);/* @__PURE__ */ /* @__PURE__ */
|
|
383
383
|
return(0,J$.jsxs)("g",{transform:`translate(${e.pixel},${v})`,children:[
|
|
384
384
|
/* @__PURE__ */
|
|
385
385
|
/* @__PURE__ */(0,J$.jsx)("line",{y2:5*k,...L}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{y:k*(_?12:18),textAnchor:_?"end":$y(g?.tickAnchor,e.pixel===$.min,e.pixel===$.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,transform:_?"top"===x?"rotate(45)":"rotate(-45)":void 0,children:e.label}):Ey({label:e.label,x:-30,y:"top"===x?-30:6,textAlign:"center",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"xtick-"+t)}),j&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{x:t.width/2,y:"top"===x?-(_?58:40):t.height+(_?58:40),textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:j})]}),!1!==m?.visible&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsxs)("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==m?.baseline&&!m?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("line",{x1:w,y1:0,x2:w,y2:t.height,...R}),m?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("path",{d:Ry(b,t.width,t.height),fill:"none",...R}),M.map((e,t)=>{const i=zy(m?.landmarkTicks,e,t,M);/* @__PURE__ */ /* @__PURE__ */
|
|
386
386
|
return(0,J$.jsxs)("g",{transform:`translate(${w},${e.pixel})`,children:[
|
|
387
387
|
/* @__PURE__ */
|
|
388
|
-
/* @__PURE__ */(0,J$.jsx)("line",{x2:5*A,...R}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:Py(m?.tickAnchor,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:e.label}):Ey({label:e.label,x:"right"===b?8:-68,y:-12,textAlign:"right"===b?"left":"right",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"ytick-"+t)}),I&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{x:C,y:t.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${C}, ${t.height/2})`,children:I})]})]})}function ng(e,t,i,n,o,r,s){const{grid:a}=
|
|
389
|
-
return(0,tP.jsxs)("g",{id:c+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,tP.jsx)("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},"gx-"+i)),x&&g.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,tP.jsx)("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}function og(e,t){if(!t||0===e.length)return e;if(!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;const i=[];for(const n of e){if(null==n||"object"!=typeof n)continue;const e=n[t];if(!Array.isArray(e))continue;const o=n.label??n.id??n.key;for(const t of e)null!=t&&"object"==typeof t&&i.push(null==o?t:{...t,_lineGroup:o})}return i}function rg(e,t,i,n){return"function"==typeof e?e({size:t,margin:i,scales:n}):e}function sg(e){return rP.has(e)?oP:nP}function ag(e){const{scales:t,layout:i,props:n,theme:o,leftAxis:r,rightAxis:s,margin:a,axisChrome:c,hasRenderedLegend:l}=e;if(!r||!s||!1===s.visible)return null;const u=
|
|
388
|
+
/* @__PURE__ */(0,J$.jsx)("line",{x2:5*A,...R}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:Py(m?.tickAnchor,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fontSize:i?l.tickSize+1:l.tickSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:e.label}):Ey({label:e.label,x:"right"===b?8:-68,y:-12,textAlign:"right"===b?"left":"right",fontSize:l.tickSize,fontFamily:l.fontFamily,color:l.textSecondary})]},"ytick-"+t)}),I&&/* @__PURE__ */ /* @__PURE__ */(0,J$.jsx)("text",{x:C,y:t.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${C}, ${t.height/2})`,children:I})]})]})}function ng(e,t,i,n,o,r,s){const{grid:a}=Yr(i),c=n?n+"-":"",l=r?.find(e=>"bottom"===e.orient),u=r?.find(e=>"top"===e.orient),d=r?.find(e=>"left"===e.orient),h=r?.find(e=>"right"===e.orient),p=l??u,f=d??h,y=Gy({scale:e.x,axis:p,size:t.width,horizontal:!0,format:s?.xFormat||s?.tickFormatTime,axisExtent:o}),g=Gy({scale:e.y,axis:f,size:t.height,format:s?.yFormat||s?.tickFormatValue,axisExtent:o}),m=!1!==p?.grid,x=!1!==f?.grid,b=Iy(p?.gridStyle),v=Iy(f?.gridStyle),w=Ly(p?.gridStyle,{stroke:a,strokeWidth:.5}),k=Ly(f?.gridStyle,{stroke:a,strokeWidth:.5});/* @__PURE__ */ /* @__PURE__ */
|
|
389
|
+
return(0,tP.jsxs)("g",{id:c+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,tP.jsx)("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},"gx-"+i)),x&&g.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,tP.jsx)("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}function og(e,t){if(!t||0===e.length)return e;if(!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;const i=[];for(const n of e){if(null==n||"object"!=typeof n)continue;const e=n[t];if(!Array.isArray(e))continue;const o=n.label??n.id??n.key;for(const t of e)null!=t&&"object"==typeof t&&i.push(null==o?t:{...t,_lineGroup:o})}return i}function rg(e,t,i,n){return"function"==typeof e?e({size:t,margin:i,scales:n}):e}function sg(e){return rP.has(e)?oP:nP}function ag(e){const{scales:t,layout:i,props:n,theme:o,leftAxis:r,rightAxis:s,margin:a,axisChrome:c,hasRenderedLegend:l}=e;if(!r||!s||!1===s.visible)return null;const u=Yr(o),d=Gy({scale:t.y,axis:s,size:i.height,format:n.yFormat||n.tickFormatValue,axisExtent:n.axisExtent}),h=jy(d),p=s.label??n.yLabelRight,y=Ly(s.axisStyle,{stroke:u.border,strokeWidth:1}),g=n.legendPosition??"right",m=f(n.legendLayout,c?.rightAxis),x=i.width+(l&&"right"===g&&m>0?m:a.right)-15;/* @__PURE__ */ /* @__PURE__ */
|
|
390
390
|
return(0,sP.jsxs)("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==s.baseline&&!s.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,sP.jsx)("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...y}),s.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,sP.jsx)("path",{d:Ry("right",i.width,i.height),fill:"none",...y}),d.map((e,t)=>{const n=zy(s.landmarkTicks,e,t,d);/* @__PURE__ */ /* @__PURE__ */
|
|
391
391
|
return(0,sP.jsxs)("g",{transform:`translate(${i.width},${e.pixel})`,children:[
|
|
392
392
|
/* @__PURE__ */
|
|
393
|
-
/* @__PURE__ */(0,sP.jsx)("line",{x2:5,...y}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,sP.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Py(s.tickAnchor,e.pixel===h.min,e.pixel===h.max),fontWeight:n?600:400,fontSize:n?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ey({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),p&&/* @__PURE__ */ /* @__PURE__ */(0,sP.jsx)("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:p})]})}function cg(e,t){const i=
|
|
393
|
+
/* @__PURE__ */(0,sP.jsx)("line",{x2:5,...y}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,sP.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Py(s.tickAnchor,e.pixel===h.min,e.pixel===h.max),fontWeight:n?600:400,fontSize:n?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ey({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),p&&/* @__PURE__ */ /* @__PURE__ */(0,sP.jsx)("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:p})]})}function cg(e,t){const i=Wr(e.theme),n=e.size||[500,300],o=l({...iP,...e.margin},e.title),r=a(e.title),s=og(Hs(e.data),e.lineDataAccessor),c=e.showLegend?nf(s,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],u=m({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});Qy(o,{props:{...e,axisChrome:u},categories:c,theme:i,size:n,hasTitle:r});const d=Jy({props:{...e,axisChrome:u},categories:c,theme:i,size:n,margin:o,hasTitle:r}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),y=e.colorScheme||i.colors.categorical,g=(e.axes?.find(e=>"left"===e.orient)??e.axes?.find(e=>"right"===e.orient))?.extent??e.axisExtent,x={chartType:e.chartType,runtimeMode:f?"streaming":"bounded",windowSize:e.windowSize??e.capacity??200,windowMode:e.windowMode??e.capacityMode??"sliding",arrowOfTime:f?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:e.xAccessor,yAccessor:e.yAccessor,timeAccessor:f?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor||(e.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,invertY:e.invertY,axisExtent:e.axisExtent,yAxisExtent:g,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:na(e.gradientFill),lineGradient:oa(e.lineGradient),semanticLineStops:e.semanticLineStops,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:y,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:Dr(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat,heatmapColorScale:e.heatmapColorScale,heatmapAggregation:e.heatmapAggregation,heatmapXBins:e.heatmapXBins,heatmapYBins:e.heatmapYBins,pointIdAccessor:e.pointIdAccessor,onLayoutError:e.onLayoutError},b=new O_(x);e.data&&b.ingest({inserts:s,bounded:!0}),b.computeScene({width:h,height:p});const v=rg(e.backgroundGraphics,n,o,b.scales),w=rg(e.foregroundGraphics,n,o,b.scales),k=ma(e.annotations),A=k?`${e.description||e.title||"Line chart."}${k}`:e.description;if(!b.scales){let r;const a=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:h,height:p},theme:i,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=gp({frameType:"xy",width:n[0],height:n[1],marks:[],title:e.title,description:A,annotations:e.annotations,annotationRender:r,extraWarnings:b.scales?[]:["NO_SCALES"],margin:o})),u_.renderToStaticMarkup(tg(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,aP.jsxs)(aP.Fragment,{children:[v,a,w]}):null,{width:n[0],height:n[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:A,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}const S=e._idPrefix,M=Wp({nodes:b.scene,renderMode:e.renderMode,fallback:(t,i)=>Fp(t,i,S,e.hoverRadius??30)}),_=!b.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:Yy(b.scales.x.domain().map(e=>e.valueOf()))},$=e.showGrid?ng(b.scales,{width:h,height:p},i,S,e.axisExtent,e.axes,_):null,P=M.map(e=>e.element),j=Hy(e)+"-plot-clip",I=!1!==e.showAxes,L=I?ig(b.scales,{width:h,height:p},_,i,S,o,u,!!d):null,R=I?ag({scales:b.scales,layout:{width:h,height:p},props:e,theme:i,leftAxis:e.axes?.find(e=>"left"===e.orient),rightAxis:e.axes?.find(e=>"right"===e.orient),margin:o,axisChrome:u,hasRenderedLegend:!!d}):null;let C;const T=e.annotations?wy({annotations:e.annotations,margin:o,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{x:b.scales.x,y:b.scales.y},layout:{width:h,height:p},theme:i,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:S,onRender:e=>{C=e}}):null;t&&(t.evidence=gp({frameType:"xy",width:n[0],height:n[1],marks:M.map(e=>e.node),title:e.title,description:A,annotations:e.annotations,annotationRender:C,xDomain:yp(b.scales.x?.domain?.()),yDomain:yp(b.scales.y?.domain?.()),legendItems:c.length>0?c.length:void 0,margin:o}));const O=e.svgPreRenderers&&b.scales?e.svgPreRenderers.map((e,t)=>{try{/* @__PURE__ */ /* @__PURE__ */
|
|
394
394
|
return(0,aP.jsx)(l_.Fragment,{children:e(b.scene,b.scales,{width:h,height:p})},"pre-"+t)}catch{return null}}).filter(Boolean):null;return u_.renderToStaticMarkup(tg(/* @__PURE__ */ /* @__PURE__ */(0,aP.jsxs)(aP.Fragment,{children:[v,O,$,
|
|
395
395
|
/* @__PURE__ */
|
|
396
396
|
/* @__PURE__ */(0,aP.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,aP.jsx)("clipPath",{id:j,children:/* @__PURE__ */ /* @__PURE__ */(0,aP.jsx)("rect",{x:0,y:0,width:h,height:p})})}),
|
|
397
397
|
/* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */(0,aP.jsx)("g",{clipPath:`url(#${j})`,children:P}),L,R,T,w,b.customLayoutOverlays]}),{width:n[0],height:n[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:A,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function lg(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}function ug({machine:e,layout:t,runtime:i,downstreamSet:n,selectedSet:o,width:r,height:s,seed:a,reduced:c,onSelectTask:l}){const u=t.tasks.length?
|
|
398
|
+
/* @__PURE__ */(0,aP.jsx)("g",{clipPath:`url(#${j})`,children:P}),L,R,T,w,b.customLayoutOverlays]}),{width:n[0],height:n[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:A,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function lg(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}function ug({machine:e,layout:t,runtime:i,downstreamSet:n,selectedSet:o,width:r,height:s,seed:a,reduced:c,onSelectTask:l}){const u=t.tasks.length?t.tasks.reduce((e,t)=>Math.min(e,t.y-t.height/2),1/0):60,d=Math.max(20,u-12),h=Math.max(26,u-6);/* @__PURE__ */ /* @__PURE__ */
|
|
399
399
|
return(0,lP.jsxs)("svg",{"aria-hidden":"true",width:r,height:s,viewBox:`0 0 ${r} ${s}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[
|
|
400
400
|
/* @__PURE__ */
|
|
401
401
|
/* @__PURE__ */(0,lP.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,lP.jsx)("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:/* @__PURE__ */ /* @__PURE__ */(0,lP.jsx)("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{const n=t.tasks.filter(e=>e.laneIndex===i),o=n[0]?.x??0;/* @__PURE__ */ /* @__PURE__ */
|
|
@@ -426,7 +426,7 @@ return(0,lP.jsxs)("g",{children:[
|
|
|
426
426
|
/* @__PURE__ */
|
|
427
427
|
/* @__PURE__ */(0,lP.jsx)("text",{x:r.x,y:r.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),
|
|
428
428
|
/* @__PURE__ */
|
|
429
|
-
/* @__PURE__ */(0,lP.jsxs)("text",{x:r.x,y:r.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",s?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function dg(e,t=0){if(e instanceof Date)return e.getTime();const i=Number(e);return Number.isFinite(i)?i:t}function hg(e){if(null==e.completionTime)return null;const t=dg(e.completionTime,NaN);return Number.isFinite(t)?t:null}function pg(e,t,i,n){const o=/* @__PURE__ */new Set;for(const r of e.nodes){const s=e.incoming.get(r.id)??[];(n.has(r.id)||!i.has(r.id)&&s.every(e=>t.has(e.id)))&&o.add(r.id)}return o}function fg(e,t,i,n){const o=e.nodes.map(hg).filter(e=>null!=e),r=o.length?Math.min(
|
|
429
|
+
/* @__PURE__ */(0,lP.jsxs)("text",{x:r.x,y:r.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",s?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function dg(e,t=0){if(e instanceof Date)return e.getTime();const i=Number(e);return Number.isFinite(i)?i:t}function hg(e){if(null==e.completionTime)return null;const t=dg(e.completionTime,NaN);return Number.isFinite(t)?t:null}function pg(e,t,i,n){const o=/* @__PURE__ */new Set;for(const r of e.nodes){const s=e.incoming.get(r.id)??[];(n.has(r.id)||!i.has(r.id)&&s.every(e=>t.has(e.id)))&&o.add(r.id)}return o}function fg(e,t,i,n){const o=e.nodes.map(hg).filter(e=>null!=e),r=o.length?o.reduce((e,t)=>Math.min(e,t),1/0)-1:0,s="replay"!==t||n?i:r,a=/* @__PURE__ */new Set,c=/* @__PURE__ */new Map;for(const i of e.nodes){const e=hg(i);(null!=e&&s>=e||"done"===i.status&&"replay"!==t)&&a.add(i.id),i.blockerReason&&!a.has(i.id)&&c.set(i.id,i.blockerReason)}const l=/* @__PURE__ */new Set;if("replay"!==t||n)for(const t of e.edges)a.has(t.sourceID)&&l.add(t.id);return{currentTime:s,playing:!1,completed:a,delivered:l,inFlight:/* @__PURE__ */new Set,armed:pg(e,l,c,a),blockers:c,previewTaskID:null}}function yg(e,t){const i=/* @__PURE__ */new Map;for(const t of e)i.set(t.id,/* @__PURE__ */new Set);for(const e of t)i.has(e.source)||i.set(e.source,/* @__PURE__ */new Set),i.has(e.target)||i.set(e.target,/* @__PURE__ */new Set),i.get(e.source).add(e.target);return i}function gg(e,t,i={}){const n=/* @__PURE__ */new Set,o=[...e.get(t)??[]];for(let t=0;o.length>t;t++){const i=o[t];n.has(i)||(n.add(i),o.push(...e.get(i)??[]))}return i.includeStart&&n.add(t),n}function mg(e,t,i){return vd(i,e,t)}function xg(e,t){return t>e?-1:e>t?1:0}function bg(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function vg(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function wg(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function kg(e){const t=[],i=/* @__PURE__ */new Map,n=[],o=/* @__PURE__ */new Set;e.data.forEach((r,s)=>{const a=(mg(r,s,e.taskIDAccessor)??"")+"";if(!a)return void t.push({code:"duplicate-task-id",message:`Task row ${s} has an empty id.`,taskIDs:[]});if(i.has(a))return void t.push({code:"duplicate-task-id",message:`Task id "${a}" occurs more than once.`,taskIDs:[a]});const c=(mg(r,s,e.laneAccessor)??"Unassigned")+"";o.has(c)||(o.add(c),n.push(c));const l=mg(r,s,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(l,e=>e+""))).sort(xg),d=mg(r,s,e.blockerAccessor),h=mg(r,s,e.statusAccessor)??(d?"blocked":"waiting");i.set(a,{id:a,label:(mg(r,s,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:s,datum:r,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:mg(r,s,e.startAccessor),end:mg(r,s,e.endAccessor),progress:wg(mg(r,s,e.progressAccessor)),status:h,completionTime:mg(r,s,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!mg(r,s,e.milestoneAccessor)})});const r=e.laneOrder?[...e.laneOrder,...n.filter(t=>!e.laneOrder?.includes(t))]:n,s=new Map(r.map((e,t)=>[e,t]));for(const e of i.values())e.laneIndex=s.get(e.lane)??0;const a=/* @__PURE__ */new Map,c=/* @__PURE__ */new Map;for(const e of i.keys())a.set(e,[]),c.set(e,[]);const l=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(const e of u)e.dependencyIDs.forEach((n,o)=>{const r=i.get(n);if(!r)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${n}".`,taskIDs:[e.id,n]});const s={id:bg(n,e.id),sourceID:n,targetID:e.id,sourceIndex:r.index,targetIndex:e.index,socketID:vg(e.id,o),socketIndex:o};l.push(s),a.get(e.id)?.push(s),c.get(n)?.push(s),e.incomingEdgeIDs.push(s.id),e.socketIDs.push(s.socketID),r.outgoingEdgeIDs.push(s.id)});for(const e of a.values())e.sort((e,t)=>xg(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=vg(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>xg(e.targetID,t.targetID));for(const e of i.values()){const t=a.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(c.get(e.id)??[]).map(e=>e.id)}const d=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(const e of i.keys())d.set(e,a.get(e)?.length??0),h.set(e,0);const p=[...i.keys()].filter(e=>0===d.get(e)).sort(xg);let f=0;for(;p.length;){const e=p.shift();f+=1;for(const t of c.get(e)??[]){const i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);const n=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,n),0===n){const e=p.findIndex(e=>e>t.targetID);0>e?p.push(t.targetID):p.splice(e,0,t.targetID)}}}if(f!==i.size){const e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(xg);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let y=0;const g=[...i.values()].sort((e,t)=>e.index-t.index);for(const e of g)e.level=h.get(e.id)??0,y=Math.max(y,e.level);return{nodes:g,edges:l,byID:i,incoming:a,outgoing:c,lanes:r,maxLevel:y,diagnostics:t,valid:0===t.length}}function Ag(e,t,i={}){const n=Math.max(240,t.width),o=Math.max(220,t.height),r=t.paddingX??48,s=t.paddingTop??48,a=t.paddingBottom??44,c=Math.max(70,(n-2*r)/Math.max(1,e.lanes.length)),l=Math.max(76,(o-s-a)/Math.max(1,e.maxLevel+1)),u=Math.min(i.taskWidth??112,Math.max(58,.78*c)),d=Math.min(i.taskHeight??58,.64*l),h=i.socketRadius??5,p=Math.max(1,Math.round(i.gutterCount??3)),f=/* @__PURE__ */new Map;for(const t of e.nodes){const e=`${t.laneIndex}:${t.level}`,i=f.get(e)??[];i.push(t),f.set(e,i)}for(const e of f.values())e.sort((e,t)=>xg(e.id,t.id));const y=.86*l,g=e.nodes.map(e=>{const t=f.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,n=(o=t.length)>1?Math.max(22,Math.min(d,(y-4*(o-1))/o)):d;var o;return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:r+c*(e.laneIndex+.5),y:s+l*(e.level+.5)+i*(n+4),width:u,height:n}}),m=new Map(g.map(e=>[e.taskID,e])),x=[],b=[];e.edges.forEach((t,i)=>{const n=m.get(t.sourceID),o=m.get(t.targetID);if(!n||!o)return;const r=e.incoming.get(t.targetID)??[],s=Math.min(.72*o.width,14*Math.max(1,r.length-1)),a=r.length>1?o.x-s/2+s*t.socketIndex/(r.length-1):o.x,c=o.y-o.height/2-h-2;x.push({id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:a,y:c,radius:h});const l={x:n.x,y:n.y+n.height/2+3},u=Math.min(c-10,l.y+.48*Math.max(18,c-l.y)+7*(i%p-(p-1)/2));var d;b.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(d=[l,{x:l.x,y:u},{x:a,y:u},{x:a,y:c}],d.filter((e,t)=>{const i=d[t-1];return!i||i.x!==e.x||i.y!==e.y}))})});const v=new Map(x.map(e=>[e.id,e])),w=new Map(b.map(e=>[e.edgeID,e]));return{tasks:g,sockets:x,routes:b,taskByID:m,socketByID:v,routeByEdgeID:w}}function Sg(e,t,i={}){const n=new Set(i.completedTaskIDs??[]),o=[...gg(yg(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):n.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),r=Array.from(new Set(o.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:o.length,affectedLaneCount:r.length,downstreamTaskIDs:o.map(e=>e.id),affectedLanes:r}}function Mg(e){return e.__composite}function _g(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function $g(e,t,i){const n="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{const n=Sg(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${n.downstreamTaskCount} unfinished tasks across ${n.affectedLaneCount} lanes.`}).join(" ");return o?`${n} ${o}`:n+" No explicit blockers are active."}function Pg(e,t,i,n,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:n,rest:o}}}function jg(e){return e.__composite}function Ig(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function Lg(e,t){return Math.max(1,Math.floor(Ig(e,t)))}function Rg(e,t,i,n){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${n}"`)}function Cg(e,t){for(const i of e){const e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}function Tg(e,t){return("function"==typeof t?t(e):e[t])+""}function Og(e,t,i,n){if(!t)return{categories:[],color:()=>nA};const o=Array.from(new Set(e.map(e=>Tg(e,t)))),r="string"==typeof t?t:"__semioticSplomColor",s=Yn("function"==typeof t?e.map(e=>({...e,[r]:Tg(e,t)})):e,r,i??n.colors.categorical);return{categories:o,color:e=>Bn(e,t,s)}}function Eg(e){const{data:t,field:i,label:n,cellSize:o,bins:r,diagonal:s,colorBy:a,color:c,x:l,y:u}=e;if("label"===s)return{visibleBars:0,svg:c_.renderToStaticMarkup(
|
|
430
430
|
/* @__PURE__ */
|
|
431
431
|
/* @__PURE__ */(0,dP.jsx)("svg",{x:l,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:n})}))};const d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,p=((d.length?Math.max(...d):0)-h)/r||1,f=Array.from({length:r},()=>/* @__PURE__ */new Map);for(const e of t){const t=Number(e[i]);if(!Number.isFinite(t))continue;const n=Math.max(0,Math.min(r-1,Math.floor((t-h)/p))),o=a?Tg(e,a):"__all",s=f[n];s.set(o,[...s.get(o)??[],e])}const y=f.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),g=Math.max(1,...y);let m=0;const x=f.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,n])=>{if(0===n.length)return[];m+=1;const s=n.length/g*(o-24),l=i;return i+=s,/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("rect",{x:t/r*o,y:o-l-s,width:Math.max(o/r-1,1),height:s,fill:a?c(n[0]):nA,opacity:.6},`${t}-${e}`)})});return{visibleBars:m,svg:c_.renderToStaticMarkup(
|
|
432
432
|
/* @__PURE__ */
|
|
@@ -437,7 +437,7 @@ return(0,gP.jsx)("g",{className:"semiotic-radial-center-content",transform:`tran
|
|
|
437
437
|
/* @__PURE__ */
|
|
438
438
|
/* @__PURE__ */(0,WP.jsx)("text",{x:r,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-step"));const c=Number(i.__funnelValue),l=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&d>=60){const e=Number(i.__funnelPercent);let o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${em(c)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:em(c);7.8*o.length+16>d&&(o=em(c)),7.8*o.length+16>d||n.push(
|
|
439
439
|
/* @__PURE__ */
|
|
440
|
-
/* @__PURE__ */(0,WP.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return n.length?/* @__PURE__ */ /* @__PURE__ */(0,WP.jsx)("g",{children:n},t+"-funnel-labels"):null}function im(e,t,i){return Cp(nm(e,t,i),e,"ordinal-cursor-"+t)}function nm(e,t,i){const n=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${n}-${t}-${i}`,r=`ord-${e.type}-${n}-${t}`;switch(e.type){case"rect":{const t=e,i=Mp(r)+"-grad",n=Pp(t,i);let o,a;if(n)a=`url(#${i})`;else if(
|
|
440
|
+
/* @__PURE__ */(0,WP.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return n.length?/* @__PURE__ */ /* @__PURE__ */(0,WP.jsx)("g",{children:n},t+"-funnel-labels"):null}function im(e,t,i){return Cp(nm(e,t,i),e,"ordinal-cursor-"+t)}function nm(e,t,i){const n=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${n}-${t}-${i}`,r=`ord-${e.type}-${n}-${t}`;switch(e.type){case"rect":{const t=e,i=Mp(r)+"-grad",n=Pp(t,i);let o,a;if(n)a=`url(#${i})`;else if(Mr(t.style.fill)){const e=Mp(r)+"-hatch";o=Pr(t.style.fill,e),a=`url(#${e})`}else a=Sp(t.style.fill);const c=n||o?/* @__PURE__ */ /* @__PURE__ */(0,WP.jsxs)("defs",{children:[n,o]}):null;if(t.cornerRadii&&(((s=t.cornerRadii).tl??0)>0||(s.tr??0)>0||(s.br??0)>0||(s.bl??0)>0)){const e=jp(t);/* @__PURE__ */ /* @__PURE__ */
|
|
441
441
|
return(0,WP.jsxs)(zP.Fragment,{children:[c,
|
|
442
442
|
/* @__PURE__ */
|
|
443
443
|
/* @__PURE__ */(0,WP.jsx)("path",{d:e,fill:a,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},r)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:i,y:n,w:o,h:s}=t;let l;switch(t.roundedEdge){case"right":l=`M${i},${n} L${i+o-e},${n} A${e},${e} 0 0 1 ${i+o},${n+e} L${i+o},${n+s-e} A${e},${e} 0 0 1 ${i+o-e},${n+s} L${i},${n+s} Z`;break;case"left":l=`M${i+o},${n} L${i+e},${n} A${e},${e} 0 0 0 ${i},${n+e} L${i},${n+s-e} A${e},${e} 0 0 0 ${i+e},${n+s} L${i+o},${n+s} Z`;break;case"bottom":l=`M${i},${n} L${i+o},${n} L${i+o},${n+s-e} A${e},${e} 0 0 1 ${i+o-e},${n+s} L${i+e},${n+s} A${e},${e} 0 0 1 ${i},${n+s-e} Z`;break;default:l=`M${i},${n+s} L${i},${n+e} A${e},${e} 0 0 1 ${i+e},${n} L${i+o-e},${n} A${e},${e} 0 0 1 ${i+o},${n+e} L${i+o},${n+s} Z`}/* @__PURE__ */ /* @__PURE__ */
|
|
@@ -489,14 +489,14 @@ return(0,WP.jsxs)("g","vertical"===t.projection?{children:[
|
|
|
489
489
|
/* @__PURE__ */(0,WP.jsx)("circle",{cx:t.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}/* @__PURE__ */ /* @__PURE__ */
|
|
490
490
|
return(0,WP.jsx)("g",{children:i},r)}case"connector":{const t=e,i=t.style.fill&&"none"!==t.style.fill?Sp(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";/* @__PURE__ */ /* @__PURE__ */
|
|
491
491
|
return(0,WP.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},r)}case"trapezoid":{const t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");/* @__PURE__ */ /* @__PURE__ */
|
|
492
|
-
return(0,WP.jsx)("polygon",{points:i,fill:Sp(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},r)}default:return null}var s}function om(e){return"connector"===e.node.type}function rm(e,t,i,n){if(2>e.length)return null;const o=e[0].node,r=o.style.fill;if(!r||"none"===r)return null;const s=Mp(`${t?t+"-":""}connector-${i}-${n}-hatch`),a=
|
|
492
|
+
return(0,WP.jsx)("polygon",{points:i,fill:Sp(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},r)}default:return null}var s}function om(e){return"connector"===e.node.type}function rm(e,t,i,n){if(2>e.length)return null;const o=e[0].node,r=o.style.fill;if(!r||"none"===r)return null;const s=Mp(`${t?t+"-":""}connector-${i}-${n}-hatch`),a=Mr(r)?Pr(r,s):null,c=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return Cp(/* @__PURE__ */ /* @__PURE__ */(0,YP.jsxs)(NP.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,YP.jsx)("defs",{children:a}),
|
|
493
493
|
/* @__PURE__ */
|
|
494
494
|
/* @__PURE__ */(0,YP.jsx)("polygon",{points:c,fill:a?`url(#${s})`:Sp(r,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${n}`)}function sm(e,t,i){const n=/* @__PURE__ */new Map;for(const t of e){if(!om(t))continue;const e=t.node.group||"_default",i=n.get(e);i?i.push(t):n.set(e,[t])}if(0===n.size)return;const o=Array.from(n.values()).map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,YP.jsxs)("g",{children:[rm(e,t,i,n),e.map(e=>e.element)]},`ordinal-connectors-${i}-${n}`)),r=e[0],s=om(r)?null:r.element;for(const e of n.values())for(const t of e)t.element=null;r.element=/* @__PURE__ */ /* @__PURE__ */(0,YP.jsxs)(NP.Fragment,{children:[o,s]},"ordinal-connector-run-"+i)}function am(e){const t=Wp({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>im(t,i,e.idPrefix)});let i=0;for(let n=0;t.length>n;){if(t[n].renderedByBackend){n++;continue}let o=n+1;for(;t.length>o&&!t[o].renderedByBackend;)o++;sm(t.slice(n,o),e.idPrefix,i++),n=o}return t}function cm(e){const{id:t,background:i="transparent",stroke:n="#000",lineWidth:o=1.5,spacing:r=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*r));/* @__PURE__ */ /* @__PURE__ */
|
|
495
495
|
return(0,qP.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&/* @__PURE__ */ /* @__PURE__ */(0,qP.jsx)("rect",{width:a,height:a,fill:i}),
|
|
496
496
|
/* @__PURE__ */
|
|
497
497
|
/* @__PURE__ */(0,qP.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:n,strokeWidth:o}),
|
|
498
498
|
/* @__PURE__ */
|
|
499
|
-
/* @__PURE__ */(0,qP.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:n,strokeWidth:o})]},t)}function lm(e,t,i,o,r,s,a,c=!1){const l=e.scales;if(!l)return null;if("radial"===l.projection)return null;const u=
|
|
499
|
+
/* @__PURE__ */(0,qP.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:n,strokeWidth:o})]},t)}function lm(e,t,i,o,r,s,a,c=!1){const l=e.scales;if(!l)return null;if("radial"===l.projection)return null;const u=Yr(o),d="vertical"===l.projection,h=e.columns,p=i.categoryFormat||i.oFormat,y=i.valueFormat||i.rFormat,g=i.categoryLabel||i.oLabel,m=i.valueLabel||i.rLabel,x=i.legendPosition??"right",b=f(i.legendLayout,a?.leftAxis),v=c&&"left"===x&&b>0?b:s?.left??i.margin?.left??40,w=Object.values(h).map((e,t)=>({pixel:e.middle,label:p?p(e.name,t):e.name})),k=i.rTickValues??Ty(l.r,5,i.axisExtent),A=y||n(k),S=k.map(e=>({pixel:l.r(e),label:A(e)}));/* @__PURE__ */ /* @__PURE__ */
|
|
500
500
|
return(0,XP.jsxs)("g",d?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[
|
|
501
501
|
/* @__PURE__ */
|
|
502
502
|
/* @__PURE__ */(0,XP.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:u.border,strokeWidth:1}),w.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[
|
|
@@ -517,29 +517,29 @@ return(0,XP.jsxs)("g",d?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",childre
|
|
|
517
517
|
/* @__PURE__ */
|
|
518
518
|
/* @__PURE__ */(0,XP.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[
|
|
519
519
|
/* @__PURE__ */
|
|
520
|
-
/* @__PURE__ */(0,XP.jsx)("line",{x2:-5,stroke:u.border,strokeWidth:1}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ey({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("text",{x:15-v,y:t.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${t.height/2})`,children:g})]})}function um(e,t){const i=zr(e.theme),n=e.size||[500,400],o=l({...iP,...e.margin},e.title),r=a(e.title),s=Hs(e.data),c=e.showLegend?nf(s,e.colorAccessor||e.stackBy||e.groupBy):[],u=x({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Qy(o,{props:{...e,axisChrome:u},categories:c,theme:i,size:n,hasTitle:r});const d=Jy({props:{...e,axisChrome:u},categories:c,theme:i,size:n,margin:o,hasTitle:r}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f=e.projection||"vertical",y="radial"===f,g=e.colorScheme||i.colors.categorical,m={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:f,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:na(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:g,themeCategorical:i.colors.categorical,themeSemantic:Fr(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors},b=new FP(m);e.data&&b.ingest({inserts:s,bounded:!0}),b.computeScene({width:h,height:p});const v=rg(e.backgroundGraphics,n,o,b.scales),w=rg(e.foregroundGraphics,n,o,b.scales);if(!b.scales){let r;const a=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:h,height:p},theme:i,projection:f,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=gp({frameType:"ordinal",width:n[0],height:n[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:r,extraWarnings:b.scales?[]:["NO_SCALES"],margin:o})),xP.renderToStaticMarkup(tg(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)(XP.Fragment,{children:[v,a,w,b.customLayoutOverlays]}):null,{width:n[0],height:n[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}const k=e._idPrefix,A=e.showGrid?eg(b,{width:h,height:p},i,k,e.axisExtent,e.rTickValues):null;let S=null;if(b.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=Hy(e),n=/* @__PURE__ */new Set;for(const e of b.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&n.add("string"==typeof e.style.fill?e.style.fill:"#666");S=Array.from(n).map((e,n)=>cm({id:`funnel-hatch-${t}-${n}`,background:e,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));const o=/* @__PURE__ */new Map;Array.from(n).forEach((e,i)=>o.set(e,`funnel-hatch-${t}-${i}`));for(const e of b.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const M=am({nodes:b.scene,renderMode:e.renderMode,idPrefix:k}),_=M.map(e=>e.element),$=!1!==e.showAxes?lm(b,{width:h,height:p},e,i,k,o,u,!!d):null;let P;const j=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{o:b.scales.o,r:b.scales.r,y:"vertical"===b.scales.projection?b.scales.r:void 0},layout:{width:h,height:p},theme:i,projection:f,xAccessor:"string"==typeof e.oAccessor?e.oAccessor:void 0,yAccessor:"string"==typeof e.rAccessor?e.rAccessor:void 0,idPrefix:k,onRender:e=>{P=e}}):null;if(t){const i=b.scales.o?.domain?.();t.evidence=gp({frameType:"ordinal",width:n[0],height:n[1],marks:M.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:P,yDomain:yp(b.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:o})}const I=y&&e.centerContent?Fg(e.centerContent,o.left+h/2,o.top+p/2):null,L=y&&e.centerContent?I??/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("foreignObject",{x:o.left,y:o.top,width:h,height:p,pointerEvents:"none",children:/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,R=/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)(XP.Fragment,{children:[A,_,$,j,w,b.customLayoutOverlays]});return xP.renderToStaticMarkup(tg(/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)(XP.Fragment,y?{children:[v?/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("g",{transform:`translate(${-h/2},${-p/2})`,children:v}):null,R]}:{children:[v,R]}),{width:n[0],height:n[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:y?`translate(${o.left+h/2},${o.top+p/2})`:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,defs:S,outerElements:L,idPrefix:e._idPrefix}))}function dm({nodes:e,edges:t,restyle:i,restyleEdge:n,baseStyles:o,selection:r}){const s=!(!i&&!n);if(i)for(const t of e){const e=o.get(t)??t.style,n=i(t,r);t.style=n?{...e,...n}:e}if(n)for(const e of t){const t=o.get(e)??e.style,i=n(e,r);e.style=i?{...t,...i}:t}return s}function hm(e,t){VP[e]=t}function pm(e){return VP[e]}function fm(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function ym(e){function t(t){var i=[t],l=[t];for(n[t]=o[t]=d,r[t]=!0,d+=1;l.length>0;){var u=e[t=l[l.length-1]];if(u.length>s[t]){for(var f=s[t];u.length>f;++f){var y=u[f];if(0>n[y]){n[y]=o[y]=d,r[y]=!0,d+=1,i.push(y),l.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||c[t].push(a[y])}s[t]=f}else{if(o[t]===n[t]){var g=[],m=[],x=0;for(f=i.length-1;f>=0;--f){var b=i[f];if(r[b]=!1,g.push(b),m.push(c[b]),x+=c[b].length,a[b]=h.length,b===t){i.length=f;break}}h.push(g);var v=Array(x);for(f=0;m.length>f;f++)for(var w=0;m[f].length>w;w++)v[--x]=m[f][w];p.push(v)}l.pop()}}}for(var i=e.length,n=Array(i),o=Array(i),r=Array(i),s=Array(i),a=Array(i),c=Array(i),l=0;i>l;++l)n[l]=-1,o[l]=0,r[l]=!1,s[l]=0,a[l]=-1,c[l]=[];var u,d=0,h=[],p=[];for(l=0;i>l;++l)0>n[l]&&t(l);for(l=0;p.length>l;l++){var f=p[l];if(0!==f.length){f.sort(function(e,t){return e-t}),u=[f[0]];for(var y=1;f.length>y;y++)f[y]!==f[y-1]&&u.push(f[y]);p[l]=u}}return{components:h,adjacencyList:p}}function gm(e,t){function i(e){u[e]=!1,d.hasOwnProperty(e)&&Object.keys(d[e]).forEach(function(t){delete d[e][t],u[t]&&i(t)})}function n(e){var t,r,s=!1;for(l.push(e),u[e]=!0,t=0;h[e].length>t;t++)(r=h[e][t])===a?(o(a,l),s=!0):u[r]||(s=n(r));if(s)i(e);else for(t=0;h[e].length>t;t++){var c=d[r=h[e][t]];c||(d[r]=c={}),c[r]=!0}return l.pop(),s}function o(e,i){var n=[].concat(i).concat(e);t?t(n):c.push(n)}function r(t){for(var i=0;e.length>i;i++)i>=t&&e[i]||(e[i]=[]),e[i]=e[i].filter(function(e){return e>=t})}function s(t){r(t);for(var i,n=ym(e).components.filter(function(e){return e.length>1}),o=1/0,s=0;n.length>s;s++)for(var a=0;n[s].length>a;a++)o>n[s][a]&&(o=n[s][a],i=s);var c=n[i];return!!c&&{leastVertex:o,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}var a,c=[],l=[],u=[],d={},h=[];a=0;for(var p=e.length;p>a;){var f=s(a);if(a=f.leastVertex,h=f.adjList){for(var y=0;h.length>y;y++)for(var g=0;h[y].length>g;g++){var m=h[y][g];u[+m]=!1,d[m]={}}n(a),a+=1}else a=p}return t?void 0:c}function mm(e){return e.y0-e.y1>0?"up":"down"}function xm(e,t){return t(e.source)==t(e.target)}function bm(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var i=0;return e.target.targetLinks.forEach(function(e){i=e.circular?i+1:i}),1>=t&&1>=i}function vm(e){return e.target.x0-e.source.x1}function wm(e,t){var i=Am(e),n=vm(t)/Math.tan(i);return"up"==mm(e)?e.y1-n:e.y1+n}function km(e,t){var i=Am(e),n=vm(t)/Math.tan(i);return"up"==mm(e)?e.y1+n:e.y1-n}function Am(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Sm(e,t){return t(e)}function Mm(e){return $m(e.source)}function _m(e){return $m(e.target)}function $m(e){return(e.y0+e.y1)/2}function Pm(e){return e.virtual?0:e.value}function jm(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!xm(e,t)?i+1:i});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!xm(e,t)?n+1:n}),i+n}function Im(e){return e.target.depth}function Lm(e,t){return e.sourceLinks.length?e.depth:t-1}function Rm(e,t){return e.y0-t.y0}function Cm(e,t){return t.y0-e.y0}function Tm(e,t){return e.y1-t.y1}function Om(e,t){return t.y1-e.y1}function Em(e,t){return Nm(e.source,t.source)||e.index-t.index}function Fm(e,t){return Nm(e.target,t.target)||e.index-t.index}function Nm(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function zm(e,t){return Dm(e)==Dm(t)?"bottom"==e.circularLinkType?Cm(e,t):Rm(e,t):Dm(t)-Dm(e)}function Dm(e){return e.target.column-e.source.column}function Bm(e,t){let i=e;return i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var n=i.links.filter(function(i){return Sm(i.source,t)==Sm(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ym(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=wm(t,e);return e.y1-i}if(t.target.column>e.target.column)return wm(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,i){if("bottom"==t.circularLinkType){for(var r=i+1,s=0;o>r;r++)s+=n[r].width;t.y0=e.y1-s-t.width/2}})}),i}function Wm(e,t){let i=e;return i.nodes.forEach(function(e){var n=i.links.filter(function(i){return Sm(i.target,t)==Sm(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ym(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=km(t,e);return e.y0-i}if(t.source.column>e.source.column)return km(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,i){if("bottom"==t.circularLinkType){for(var r=i+1,s=0;o>r;r++)s+=n[r].width;t.y1=e.y1-s-t.width/2}})}),i}function Ym(e,t){return qm(e)==qm(t)}function qm(e){return e.y0-e.y1>0?"up":"down"}function Xm(e){var t=e.source.x1,i=e.y0,n=e.target.x0,o=e.y1,r=(t+n)/2;return"M"+t+","+i+"C"+r+","+i+" "+r+","+o+" "+n+","+o}function Gm(e,t,i,n,o){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 a=(0,HP.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}),Vm(r.links.filter(function(e){return"top"==e.circularLinkType}),t,i),Vm(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,i),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,xm(e,t)&&bm(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+o+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-o-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,c=e.circularLinkType,l=r.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?Cm:Rm);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=r.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Om:Tm),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(r.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-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?Um(e):Xm(e)}),r}function Vm(e,t,i){e.sort(zm);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var r=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xm(e,t)&&bm(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&&Hm(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;r=c>r?c:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function Hm(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Um(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}function Km(e){return function(){return e}}function Zm(e){return e.index}function Qm(e){return e.nodes}function Jm(e){return e.links}function ex(e,t){var i=/* @__PURE__ */new Map;return(0,UP.group)(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function tx(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=ex(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=fm(i,n)),"object"!=typeof o&&(o=e.target=fm(i,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}function ix(e,t){var i=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var r=e.links[o],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 c=gm(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=i++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=i++)})}function nx(e,t){var i=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>i?"top":"bottom","top"==o.circularLinkType?i++:n++,e.nodes.forEach(function(e){Sm(e,t)!=Sm(o.source,t)&&Sm(e,t)!=Sm(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xm(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function ox(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,UP.sum)(e.sourceLinks,Pm),(0,UP.sum)(e.targetLinks,Pm)),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)})})}function rx(e,t,i){var n,o,r;if(null!=t){e.nodes.sort(function(e,i){return t(e)<t(i)?-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,o=[],r=0;n.length;++r,n=o,o=[])n.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],r=0;n.length;++r,n=o,o=[])n.forEach(function(e){e.height=r,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?i(e,r):e.column})}function sx(e,t,i){var n=(0,UP.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 o=(0,UP.min)(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,UP.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var r=(0,UP.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-i)/r),t.x1=t.x0+i}:function(t){t.x0=e.x0,t.x1=t.x0+i})}function ax(e,t,i){var n=(0,UP.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(o,r){var s=o.length;if(t)o.sort(t);else if(r>0){var a=/* @__PURE__ */new Map;o.forEach(function(e,t){var i,n,o,r=(n=0,o=0,(i=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=$m(e.source)*t,n+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=$m(e.target)*t,n+=t}}),n>0?o/n:NaN);a.set(e,{bc:r,idx:t})}),o.sort(function(e,t){var i=a.get(e),n=a.get(t),o=i.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(o)||isNaN(r)?isNaN(o)?isNaN(r)?i.idx-n.idx:1:-1:o-r})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?jm(t,i)-jm(e,i):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){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==jm(t,i)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function cx(e,t,i,n,o,r){function s(t,i){var n=c.length;c.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&jm(o,i)>0){var c=(0,UP.mean)(o.sourceLinks,_m),l=(0,UP.mean)(o.targetLinks,Mm),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-$m(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==r)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==n-1&&1==r)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=(0,UP.mean)(o.sourceLinks,_m),p=(0,UP.mean)(o.targetLinks,Mm),f=((h&&p?(h+p)/2:h||p)-$m(o))*t;o.y0+=f,o.y1+=f}})})}function a(){c.forEach(function(i){var r,s,a,c=e.y0,l=i.length;for(i.sort(t||Nm),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+n;if((s=c-n-e.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+o-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}var c=(0,UP.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});a();for(var l=1,u=r;u>0;--u)s(l*=.99,i),a()}function lx(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Fm),e.targetLinks.sort(Em)}),e.nodes.forEach(function(e){var t=e.y0,i=t,n=e.y1,o=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=o-e.width/2,o-=e.width):(e.y1=i+e.width/2,i+=e.width)})})}function ux(e){var t=e.nodes,i=e.links,n=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){let n=function(t){return(t-r)/(s-r)*(e.y1-e.y0)+e.y0};var r=(0,UP.min)(t,function(e){return e.y0}),s=(0,UP.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-r);1>a?(t.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1)}),i.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,i=n(e.y0)-e.y0;e.y0=n(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}function dx(){function e(){var e={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return t(e),e}function t(e){e.x0=i,e.y0=n,e.x1=o,e.y1=r,e.py=0,tx(e,l),ix(e,d),nx(e,l),ox(e),rx(e,d,u);var t=a;if(null!==c){var f=(0,UP.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,UP.max)(f,function(e){return e.length});y>1&&(t=Math.max(1,(r-n)*c/(y-1)))}sx(e,t,s),ax(e,d,l),cx(e,d,l,t,t,h),lx(e),Gm(e,l,p,10,8),ax(e,d,l),cx(e,d,l,t,t,h),lx(e),Gm(e,l,p,10,8),Bm(e,l),Wm(e,l),ux(e),Gm(e,l,p,10,8)}var i=0,n=0,o=1,r=1,s=24,a=8,c=null,l=Zm,u=Lm,d=void 0,h=32,p=2,f=Qm,y=Jm;return e.update=function(e){return lx(e),Gm(e,l,p,10,8),e},e.nodeWidth=function(t){return arguments.length?(s=+t,e):s},e.nodePadding=function(t){return arguments.length?(a=+t,e):a},e.nodePaddingRatio=function(t){return arguments.length?(c=+t,e):c},e.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Km(t),e):f},e.links=function(t){return arguments.length?(y="function"==typeof t?t:Km(t),e):y},e.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Km(t),e):l},e.nodeAlign=function(t){return arguments.length?(u="function"==typeof t?t:Km(t),e):u},e.nodeSort=function(t){return arguments.length?(d=t,e):d},e.iterations=function(t){return arguments.length?(h=+t,e):h},e.circularLinkGap=function(t){return arguments.length?(p=+t,e):p},e.extent=function(t){return arguments.length?(i=+t[0][0],n=+t[0][1],o=+t[1][0],r=+t[1][1],e):[[i,n],[o,r]]},e.size=function(t){return arguments.length?(i=n=0,o=+t[0],r=+t[1],e):[o-i,r-n]},e}function hx(e){const t=e.sankeyWidth/2,i=(e._circularWidth??e.sankeyWidth)/2,n=e.circularPathData;if(!n)return null;if("down"===e.direction)return null;if(e._circularStub){const i=n.sourceX,o=n.sourceY,r=n.targetX,s=n.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*(n.rightFullExtent-i))),c=Math.max(15,Math.min(40,.33*(r-n.leftFullExtent)));return`M${i},${o-t}L${i+a},${o-t}L${i+a},${o+t}L${i},${o+t}ZM${r},${s-t}L${r-c},${s-t}L${r-c},${s+t}L${r},${s+t}Z`}const o=n.sourceX,r=n.sourceY,s=n.targetX,a=n.targetY,c=n.rightFullExtent,l=n.leftFullExtent,u=n.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(i,15));return`M${o},${r-d*t}L${c},${r-d*t}L${c+i},${r-d*t+d*h}L${c+i},${u+d*i-d*h}L${c+i-h},${u+d*i}L${l-i+h},${u+d*i}L${l-i},${u+d*i-d*h}L${l-i},${a-d*t+d*h}L${l-i+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+i},${a+d*t}L${l+i},${u-d*i}L${c-i},${u-d*i}L${c-i},${r+d*t}L${o},${r+d*t}Z`}function px(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let i=ej.get(e);if(i){const e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,ej.set(e,i);const n=new Proxy(e,{get(e,i,n){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){const e=`${t}:${i}`;JP.has(e)||(JP.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,i,n)}});return i.set(t,n),n}function fx(e,t,i){if(i.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],o=[];for(const t of i){const i=t.data?.[e];"number"==typeof i&&o.push(i)}if(0===o.length)return()=>n[0];const[r,s]=_s(o);if(r===s)return()=>(n[0]+n[1])/2;const a=(0,oj.scaleLinear)().domain([r,s]).range(n).clamp(!0);return t=>{const i=t.data?.[e];return null==i||"number"!=typeof i?n[0]:a(i)}}function yx(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function gx(e,t,i){const n=[];for(const o of t){const t=hd(o.source),r=hd(o.target);let s=null;if(t===e?s=r:r===e&&(s=t),s){const e=i.get(s);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function mx(e,t,i=2,n=.6){let o=[];const r=r=>{const s=n*Math.max(r,.2);for(const n of o){const o=n.x??e[0]/2,r=n.y??e[1]/2,a=n.vx??0,c=n.vy??0,l=t(n)+i,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),h=Math.min(e[1]/2,l),p=Math.max(e[1]/2,e[1]-l),f=o+a,y=r+c;u>f?n.vx=a+(u-f)*s:f>d&&(n.vx=a+(d-f)*s),h>y?n.vy=c+(h-y)*s:y>p&&(n.vy=c+(p-y)*s)}};return r.initialize=e=>{o=e},r}function xx(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}function bx(e,t,i){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let r=0;for(;n.length>r;){const e=n[r];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)o.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(o.push(Number(n[r])+i+""),r++);else if("A"===e)for(o.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&(o.push(Number(n[r])+t+""),r++),n.length>r&&(o.push(Number(n[r])+i+""),r++);else"Z"===e||"z"===e?(o.push(e),r++):(o.push(n[r]),r++)}return o.join(" ")}function vx(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]}function wx(e){const[t,i,n]=vx(e);return.299*t+.587*i+.114*n>150?"#222":"#fff"}function kx(e){if(e)return"function"==typeof e?e:t=>t[e]}function Ax(e,t,i){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-"+i}function Sx(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Mx(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:dj}function _x(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function $x(e,t,i,n,o,r){const s=[],a=[],c=[],l=i.treeOrientation||"vertical",u="radial"===l,d=n[0]/2,h=n[1]/2,p="number"==typeof(f=i.nodeSize)?f:5;var f;for(const t of e){let e=t.x,n=t.y;u&&(e+=d,n+=h);const r=o(px(t,"nodeStyle"));let a=r.fill||_x(i);if(i.colorByDepth&&void 0!==t.depth){const e=Mx(i);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:n,r:p,style:{fill:a,stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity,cursor:r.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=i.edgeOpacity??.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 o=t.x,s=t.y,c=n.x,p=n.y;u&&(o+=d,s+=h,c+=d,p+=h);const f=Ix(o,s,c,p,l),g=r(px(e,"edgeStyle"));a.push({type:"curved",pathD:f,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y,cursor:g.cursor},datum:e})}if(!1!==i.showLabels){const t=Sx(i.nodeLabel);for(const i of e){const e=t?t(i):i.id;if(!e)continue;let n,o,r,s=i.x,a=i.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,i=Math.sqrt(e*e+t*t);i>0?(n=s+e/i*10,o=a+t/i*10,r=0>e?"end":"start"):(n=s,o=a-12,r="middle")}else"horizontal"===l?(i.data?.children&&0!==i.data.children.length?(n=s-p-6,r="end"):(n=s+p+6,r="start"),o=a):(n=s,o=a+p+14,r="middle");c.push({x:n,y:o,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}function Px(e,t,i,n){const o=[],r=[];for(const i of e){const e=i.x1-i.x0,r=i.y1-i.y0;if(0>=e||0>=r)continue;const s=n(px(i,"nodeStyle"));let a=s.fill||_x(t);if(t.colorByDepth&&void 0!==i.depth){const e=Mx(t);a=e[i.depth%e.length]}o.push({type:"rect",x:i.x0,y:i.y0,w:e,h:r,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity,fillOpacity:s.fillOpacity,strokeOpacity:s.strokeOpacity,cursor:s.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){const i=Sx(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=i?i(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=n(px(a,"nodeStyle")).fill||_x(t);if(t.colorByDepth&&void 0!==a.depth){const e=Mx(t);d=e[a.depth%e.length]}const h="string"==typeof d?wx(d):t.themeSemantic?.text??"#000";r.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:r}}function jx(e,t,i,n){const o=[],r=[];for(const i of e){const e=i.__radius??5;if(0>=e)continue;const r=n(px(i,"nodeStyle"));let s=r.fill||_x(t);if(t.colorByDepth&&void 0!==i.depth){const e=Mx(t);s=e[i.depth%e.length]}o.push({type:"circle",cx:i.x,cy:i.y,r:e,style:{fill:s,stroke:r.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7,cursor:r.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){const i=Sx(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=i?i(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let c=n(px(o,"nodeStyle")).fill||_x(t);if(t.colorByDepth&&void 0!==o.depth){const e=Mx(t);c=e[o.depth%e.length]}if(a){const i="string"==typeof c?wx(c):t.themeSemantic?.text??"#000";r.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else r.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:r}}function Ix(e,t,i,n,o){if("horizontal"===o){const o=(e+i)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${i},${n}`}if("radial"===o){const o=(e+i)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${i},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${i},${o} ${i},${n}`}}function Lx(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,uj.tree)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Rx(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,uj.cluster)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Cx(e,t,i,n){const o=t.padding??4,r=t.paddingTop??0,s=(0,uj.treemap)().size([i,n]).tile(uj.treemapBinary).padding(o);r>0&&s.paddingTop(r),s(e)}function Tx(e,t,i,n){const o=t.padding??4;(0,uj.pack)().size([i,n]).padding(o)(e)}function Ox(e,t,i,n){(0,uj.partition)().size([i,n]).padding(t.padding??1)(e)}function Ex(e,t,i){const n=i.treeOrientation||"vertical";if("radial"===n){const i=t.x,n=t.y;e.x=n*Math.cos(i-Math.PI/2),e.y=n*Math.sin(i-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 Fx(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 Nx(e,t){const i=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-i,e.x1=t.x+i,e.y0=t.y-i,e.y1=t.y+i,e.width=2*i,e.height=2*i,e.__radius=i}function zx(e){let t=e.__orbitState;return t||(t={metaMap:/* @__PURE__ */new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function Dx(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function Bx(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}function Wx(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}function Yx(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}function qx(e,t,i,n,o){function r(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const s=Bx(i.childrenAccessor),a=Wx(i.nodeIDAccessor),c=Dx(i.orbitMode),l=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof l?()=>l:l,h="number"==typeof u?()=>u:u,p=zx(i);p.metaMap.clear(),n.length=0,o.length=0;const f=/* @__PURE__ */new Map,y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=r(a(e));n.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,l,u,f,y,g){const m=s(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=c[Math.min(w,c.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=c[Math.min(x,c.length-1)],w=m.slice(k,k+v);if(!w.length)break;const A=(x+1)/b,S={id:i,depth:y,data:t,parentId:i},M=g?f/d(S)*A:f*A,_=(0,pj.pie)().value(e=>{const t=s(e)?.length;return t?4:1}).sort(null)(w),$=h(S);for(let t=0;w.length>t;t++){const s=(_[t].startAngle+_[t].endAngle)/2,c=w[t],d=r(a(c)),h=l+M*Math.sin(s),f=u+M*Math.cos(s)*$;n.push({id:d,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:c}),p.metaMap.set(d,{ring:M,angle:s,depth:y,parentId:i,eccentricity:$}),o.push({source:i,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:d}}),e(c,d,h,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}function Xx(e,t,i,n){const o=zx(t),r=t.orbitSpeed??.25,s=t.orbitRevolution??Yx(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=r*(Math.PI/6),l=/* @__PURE__ */new Map;for(const t of e)l.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const i=l.get(e.parentId);if(!i)continue;const n=e.angle+a*c*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=i.x+e.ring*Math.sin(n),t.y=i.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}function Gx(e,t){return Cp(Vx(e,t),e,"network-node-cursor-"+t)}function Vx(e,t){switch(e.type){case"circle":{const i=e,n=kr(i.style.fill)?Mr(i.style.fill,`net-circle-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
520
|
+
/* @__PURE__ */(0,XP.jsx)("line",{x2:-5,stroke:u.border,strokeWidth:1}),Oy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ey({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("text",{x:15-v,y:t.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${t.height/2})`,children:g})]})}function um(e,t){const i=Wr(e.theme),n=e.size||[500,400],o=l({...iP,...e.margin},e.title),r=a(e.title),s=Hs(e.data),c=e.showLegend?nf(s,e.colorAccessor||e.stackBy||e.groupBy):[],u=x({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Qy(o,{props:{...e,axisChrome:u},categories:c,theme:i,size:n,hasTitle:r});const d=Jy({props:{...e,axisChrome:u},categories:c,theme:i,size:n,margin:o,hasTitle:r}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f=e.projection||"vertical",y="radial"===f,g=e.colorScheme||i.colors.categorical,m={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:f,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:na(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:g,themeCategorical:i.colors.categorical,themeSemantic:Dr(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors},b=new FP(m);e.data&&b.ingest({inserts:s,bounded:!0}),b.computeScene({width:h,height:p});const v=rg(e.backgroundGraphics,n,o,b.scales),w=rg(e.foregroundGraphics,n,o,b.scales);if(!b.scales){let r;const a=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{},layout:{width:h,height:p},theme:i,projection:f,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=gp({frameType:"ordinal",width:n[0],height:n[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:r,extraWarnings:b.scales?[]:["NO_SCALES"],margin:o})),xP.renderToStaticMarkup(tg(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)(XP.Fragment,{children:[v,a,w,b.customLayoutOverlays]}):null,{width:n[0],height:n[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}const k=e._idPrefix,A=e.showGrid?eg(b,{width:h,height:p},i,k,e.axisExtent,e.rTickValues):null;let S=null;if(b.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=Hy(e),n=/* @__PURE__ */new Set;for(const e of b.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&n.add("string"==typeof e.style.fill?e.style.fill:"#666");S=Array.from(n).map((e,n)=>cm({id:`funnel-hatch-${t}-${n}`,background:e,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));const o=/* @__PURE__ */new Map;Array.from(n).forEach((e,i)=>o.set(e,`funnel-hatch-${t}-${i}`));for(const e of b.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const M=am({nodes:b.scene,renderMode:e.renderMode,idPrefix:k}),_=M.map(e=>e.element),$=!1!==e.showAxes?lm(b,{width:h,height:p},e,i,k,o,u,!!d):null;let P;const j=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{o:b.scales.o,r:b.scales.r,y:"vertical"===b.scales.projection?b.scales.r:void 0},layout:{width:h,height:p},theme:i,projection:f,xAccessor:"string"==typeof e.oAccessor?e.oAccessor:void 0,yAccessor:"string"==typeof e.rAccessor?e.rAccessor:void 0,idPrefix:k,onRender:e=>{P=e}}):null;if(t){const i=b.scales.o?.domain?.();t.evidence=gp({frameType:"ordinal",width:n[0],height:n[1],marks:M.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:P,yDomain:yp(b.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:o})}const I=y&&e.centerContent?Fg(e.centerContent,o.left+h/2,o.top+p/2):null,L=y&&e.centerContent?I??/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("foreignObject",{x:o.left,y:o.top,width:h,height:p,pointerEvents:"none",children:/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,R=/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)(XP.Fragment,{children:[A,_,$,j,w,b.customLayoutOverlays]});return xP.renderToStaticMarkup(tg(/* @__PURE__ */ /* @__PURE__ */(0,XP.jsxs)(XP.Fragment,y?{children:[v?/* @__PURE__ */ /* @__PURE__ */(0,XP.jsx)("g",{transform:`translate(${-h/2},${-p/2})`,children:v}):null,R]}:{children:[v,R]}),{width:n[0],height:n[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:y?`translate(${o.left+h/2},${o.top+p/2})`:`translate(${o.left},${o.top})`,innerWidth:h,innerHeight:p,legend:d,defs:S,outerElements:L,idPrefix:e._idPrefix}))}function dm({nodes:e,edges:t,restyle:i,restyleEdge:n,baseStyles:o,selection:r}){const s=!(!i&&!n);if(i)for(const t of e){const e=o.get(t)??t.style,n=i(t,r);t.style=n?{...e,...n}:e}if(n)for(const e of t){const t=o.get(e)??e.style,i=n(e,r);e.style=i?{...t,...i}:t}return s}function hm(e,t){VP[e]=t}function pm(e){return VP[e]}function fm(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function ym(e){function t(t){var i=[t],l=[t];for(n[t]=o[t]=d,r[t]=!0,d+=1;l.length>0;){var u=e[t=l[l.length-1]];if(u.length>s[t]){for(var f=s[t];u.length>f;++f){var y=u[f];if(0>n[y]){n[y]=o[y]=d,r[y]=!0,d+=1,i.push(y),l.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>a[y]||c[t].push(a[y])}s[t]=f}else{if(o[t]===n[t]){var g=[],m=[],x=0;for(f=i.length-1;f>=0;--f){var b=i[f];if(r[b]=!1,g.push(b),m.push(c[b]),x+=c[b].length,a[b]=h.length,b===t){i.length=f;break}}h.push(g);var v=Array(x);for(f=0;m.length>f;f++)for(var w=0;m[f].length>w;w++)v[--x]=m[f][w];p.push(v)}l.pop()}}}for(var i=e.length,n=Array(i),o=Array(i),r=Array(i),s=Array(i),a=Array(i),c=Array(i),l=0;i>l;++l)n[l]=-1,o[l]=0,r[l]=!1,s[l]=0,a[l]=-1,c[l]=[];var u,d=0,h=[],p=[];for(l=0;i>l;++l)0>n[l]&&t(l);for(l=0;p.length>l;l++){var f=p[l];if(0!==f.length){f.sort(function(e,t){return e-t}),u=[f[0]];for(var y=1;f.length>y;y++)f[y]!==f[y-1]&&u.push(f[y]);p[l]=u}}return{components:h,adjacencyList:p}}function gm(e,t){function i(e){u[e]=!1,d.hasOwnProperty(e)&&Object.keys(d[e]).forEach(function(t){delete d[e][t],u[t]&&i(t)})}function n(e){var t,r,s=!1;for(l.push(e),u[e]=!0,t=0;h[e].length>t;t++)(r=h[e][t])===a?(o(a,l),s=!0):u[r]||(s=n(r));if(s)i(e);else for(t=0;h[e].length>t;t++){var c=d[r=h[e][t]];c||(d[r]=c={}),c[r]=!0}return l.pop(),s}function o(e,i){var n=[].concat(i).concat(e);t?t(n):c.push(n)}function r(t){for(var i=0;e.length>i;i++)i>=t&&e[i]||(e[i]=[]),e[i]=e[i].filter(function(e){return e>=t})}function s(t){r(t);for(var i,n=ym(e).components.filter(function(e){return e.length>1}),o=1/0,s=0;n.length>s;s++)for(var a=0;n[s].length>a;a++)o>n[s][a]&&(o=n[s][a],i=s);var c=n[i];return!!c&&{leastVertex:o,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}var a,c=[],l=[],u=[],d={},h=[];a=0;for(var p=e.length;p>a;){var f=s(a);if(a=f.leastVertex,h=f.adjList){for(var y=0;h.length>y;y++)for(var g=0;h[y].length>g;g++){var m=h[y][g];u[+m]=!1,d[m]={}}n(a),a+=1}else a=p}return t?void 0:c}function mm(e){return e.y0-e.y1>0?"up":"down"}function xm(e,t){return t(e.source)==t(e.target)}function bm(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var i=0;return e.target.targetLinks.forEach(function(e){i=e.circular?i+1:i}),1>=t&&1>=i}function vm(e){return e.target.x0-e.source.x1}function wm(e,t){var i=Am(e),n=vm(t)/Math.tan(i);return"up"==mm(e)?e.y1-n:e.y1+n}function km(e,t){var i=Am(e),n=vm(t)/Math.tan(i);return"up"==mm(e)?e.y1+n:e.y1-n}function Am(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Sm(e,t){return t(e)}function Mm(e){return $m(e.source)}function _m(e){return $m(e.target)}function $m(e){return(e.y0+e.y1)/2}function Pm(e){return e.virtual?0:e.value}function jm(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!xm(e,t)?i+1:i});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!xm(e,t)?n+1:n}),i+n}function Im(e){return e.target.depth}function Lm(e,t){return e.sourceLinks.length?e.depth:t-1}function Rm(e,t){return e.y0-t.y0}function Cm(e,t){return t.y0-e.y0}function Tm(e,t){return e.y1-t.y1}function Om(e,t){return t.y1-e.y1}function Em(e,t){return Nm(e.source,t.source)||e.index-t.index}function Fm(e,t){return Nm(e.target,t.target)||e.index-t.index}function Nm(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function zm(e,t){return Dm(e)==Dm(t)?"bottom"==e.circularLinkType?Cm(e,t):Rm(e,t):Dm(t)-Dm(e)}function Dm(e){return e.target.column-e.source.column}function Bm(e,t){let i=e;return i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var n=i.links.filter(function(i){return Sm(i.source,t)==Sm(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Ym(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=wm(t,e);return e.y1-i}if(t.target.column>e.target.column)return wm(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,i){if("bottom"==t.circularLinkType){for(var r=i+1,s=0;o>r;r++)s+=n[r].width;t.y0=e.y1-s-t.width/2}})}),i}function Wm(e,t){let i=e;return i.nodes.forEach(function(e){var n=i.links.filter(function(i){return Sm(i.target,t)==Sm(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Ym(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=km(t,e);return e.y0-i}if(t.source.column>e.source.column)return km(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,i){if("bottom"==t.circularLinkType){for(var r=i+1,s=0;o>r;r++)s+=n[r].width;t.y1=e.y1-s-t.width/2}})}),i}function Ym(e,t){return qm(e)==qm(t)}function qm(e){return e.y0-e.y1>0?"up":"down"}function Xm(e){var t=e.source.x1,i=e.y0,n=e.target.x0,o=e.y1,r=(t+n)/2;return"M"+t+","+i+"C"+r+","+i+" "+r+","+o+" "+n+","+o}function Gm(e,t,i,n,o){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 a=(0,HP.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}),Vm(r.links.filter(function(e){return"top"==e.circularLinkType}),t,i),Vm(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,i),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,xm(e,t)&&bm(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+o+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-o-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,c=e.circularLinkType,l=r.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?Cm:Rm);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=r.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Om:Tm),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*i+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(r.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-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?Um(e):Xm(e)}),r}function Vm(e,t,i){e.sort(zm);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var r=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xm(e,t)&&bm(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&&Hm(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;r=c>r?c:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function Hm(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Um(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}function Km(e){return function(){return e}}function Zm(e){return e.index}function Qm(e){return e.nodes}function Jm(e){return e.links}function ex(e,t){var i=/* @__PURE__ */new Map;return(0,UP.group)(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function tx(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=ex(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=fm(i,n)),"object"!=typeof o&&(o=e.target=fm(i,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}function ix(e,t){var i=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var r=e.links[o],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 c=gm(n);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=i++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=i++)})}function nx(e,t){var i=0,n=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:n>i?"top":"bottom","top"==o.circularLinkType?i++:n++,e.nodes.forEach(function(e){Sm(e,t)!=Sm(o.source,t)&&Sm(e,t)!=Sm(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xm(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function ox(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,UP.sum)(e.sourceLinks,Pm),(0,UP.sum)(e.targetLinks,Pm)),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)})})}function rx(e,t,i){var n,o,r;if(null!=t){e.nodes.sort(function(e,i){return t(e)<t(i)?-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,o=[],r=0;n.length;++r,n=o,o=[])n.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],r=0;n.length;++r,n=o,o=[])n.forEach(function(e){e.height=r,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?i(e,r):e.column})}function sx(e,t,i){var n=(0,UP.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 o=(0,UP.min)(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,UP.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var r=(0,UP.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-i)/r),t.x1=t.x0+i}:function(t){t.x0=e.x0,t.x1=t.x0+i})}function ax(e,t,i){var n=(0,UP.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(o,r){var s=o.length;if(t)o.sort(t);else if(r>0){var a=/* @__PURE__ */new Map;o.forEach(function(e,t){var i,n,o,r=(n=0,o=0,(i=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=$m(e.source)*t,n+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=$m(e.target)*t,n+=t}}),n>0?o/n:NaN);a.set(e,{bc:r,idx:t})}),o.sort(function(e,t){var i=a.get(e),n=a.get(t),o=i.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(o)||isNaN(r)?isNaN(o)?isNaN(r)?i.idx-n.idx:1:-1:o-r})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?jm(t,i)-jm(e,i):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){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==jm(t,i)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function cx(e,t,i,n,o,r){function s(t,i){var n=c.length;c.forEach(function(o){var r=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&jm(o,i)>0){var c=(0,UP.mean)(o.sourceLinks,_m),l=(0,UP.mean)(o.targetLinks,Mm),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-$m(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==r)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==n-1&&1==r)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=(0,UP.mean)(o.sourceLinks,_m),p=(0,UP.mean)(o.targetLinks,Mm),f=((h&&p?(h+p)/2:h||p)-$m(o))*t;o.y0+=f,o.y1+=f}})})}function a(){c.forEach(function(i){var r,s,a,c=e.y0,l=i.length;for(i.sort(t||Nm),a=0;l>a;++a)(s=c-(r=i[a]).y0)>0&&(r.y0+=s,r.y1+=s),c=r.y1+n;if((s=c-n-e.y1)>0)for(c=r.y0-=s,r.y1-=s,a=l-2;a>=0;--a)(s=(r=i[a]).y1+o-c)>0&&(r.y0-=s,r.y1-=s),c=r.y0})}var c=(0,UP.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});a();for(var l=1,u=r;u>0;--u)s(l*=.99,i),a()}function lx(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Fm),e.targetLinks.sort(Em)}),e.nodes.forEach(function(e){var t=e.y0,i=t,n=e.y1,o=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=o-e.width/2,o-=e.width):(e.y1=i+e.width/2,i+=e.width)})})}function ux(e){var t=e.nodes,i=e.links,n=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){let n=function(t){return(t-r)/(s-r)*(e.y1-e.y0)+e.y0};var r=(0,UP.min)(t,function(e){return e.y0}),s=(0,UP.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-r);1>a?(t.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1)}),i.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,i=n(e.y0)-e.y0;e.y0=n(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}function dx(){function e(){var e={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return t(e),e}function t(e){e.x0=i,e.y0=n,e.x1=o,e.y1=r,e.py=0,tx(e,l),ix(e,d),nx(e,l),ox(e),rx(e,d,u);var t=a;if(null!==c){var f=(0,UP.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,UP.max)(f,function(e){return e.length});y>1&&(t=Math.max(1,(r-n)*c/(y-1)))}sx(e,t,s),ax(e,d,l),cx(e,d,l,t,t,h),lx(e),Gm(e,l,p,10,8),ax(e,d,l),cx(e,d,l,t,t,h),lx(e),Gm(e,l,p,10,8),Bm(e,l),Wm(e,l),ux(e),Gm(e,l,p,10,8)}var i=0,n=0,o=1,r=1,s=24,a=8,c=null,l=Zm,u=Lm,d=void 0,h=32,p=2,f=Qm,y=Jm;return e.update=function(e){return lx(e),Gm(e,l,p,10,8),e},e.nodeWidth=function(t){return arguments.length?(s=+t,e):s},e.nodePadding=function(t){return arguments.length?(a=+t,e):a},e.nodePaddingRatio=function(t){return arguments.length?(c=+t,e):c},e.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Km(t),e):f},e.links=function(t){return arguments.length?(y="function"==typeof t?t:Km(t),e):y},e.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Km(t),e):l},e.nodeAlign=function(t){return arguments.length?(u="function"==typeof t?t:Km(t),e):u},e.nodeSort=function(t){return arguments.length?(d=t,e):d},e.iterations=function(t){return arguments.length?(h=+t,e):h},e.circularLinkGap=function(t){return arguments.length?(p=+t,e):p},e.extent=function(t){return arguments.length?(i=+t[0][0],n=+t[0][1],o=+t[1][0],r=+t[1][1],e):[[i,n],[o,r]]},e.size=function(t){return arguments.length?(i=n=0,o=+t[0],r=+t[1],e):[o-i,r-n]},e}function hx(e){const t=e.sankeyWidth/2,i=(e._circularWidth??e.sankeyWidth)/2,n=e.circularPathData;if(!n)return null;if("down"===e.direction)return null;if(e._circularStub){const i=n.sourceX,o=n.sourceY,r=n.targetX,s=n.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*(n.rightFullExtent-i))),c=Math.max(15,Math.min(40,.33*(r-n.leftFullExtent)));return`M${i},${o-t}L${i+a},${o-t}L${i+a},${o+t}L${i},${o+t}ZM${r},${s-t}L${r-c},${s-t}L${r-c},${s+t}L${r},${s+t}Z`}const o=n.sourceX,r=n.sourceY,s=n.targetX,a=n.targetY,c=n.rightFullExtent,l=n.leftFullExtent,u=n.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(i,15));return`M${o},${r-d*t}L${c},${r-d*t}L${c+i},${r-d*t+d*h}L${c+i},${u+d*i-d*h}L${c+i-h},${u+d*i}L${l-i+h},${u+d*i}L${l-i},${u+d*i-d*h}L${l-i},${a-d*t+d*h}L${l-i+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+i},${a+d*t}L${l+i},${u-d*i}L${c-i},${u-d*i}L${c-i},${r+d*t}L${o},${r+d*t}Z`}function px(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let i=ej.get(e);if(i){const e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,ej.set(e,i);const n=new Proxy(e,{get(e,i,n){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){const e=`${t}:${i}`;JP.has(e)||(JP.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,i,n)}});return i.set(t,n),n}function fx(e,t,i){if(i.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const n=t||[5,20],o=[];for(const t of i){const i=t.data?.[e];"number"==typeof i&&o.push(i)}if(0===o.length)return()=>n[0];const[r,s]=Mt(o);if(r===s)return()=>(n[0]+n[1])/2;const a=(0,oj.scaleLinear)().domain([r,s]).range(n).clamp(!0);return t=>{const i=t.data?.[e];return null==i||"number"!=typeof i?n[0]:a(i)}}function yx(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function gx(e,t,i){const n=[];for(const o of t){const t=hd(o.source),r=hd(o.target);let s=null;if(t===e?s=r:r===e&&(s=t),s){const e=i.get(s);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function mx(e,t,i=2,n=.6){let o=[];const r=r=>{const s=n*Math.max(r,.2);for(const n of o){const o=n.x??e[0]/2,r=n.y??e[1]/2,a=n.vx??0,c=n.vy??0,l=t(n)+i,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),h=Math.min(e[1]/2,l),p=Math.max(e[1]/2,e[1]-l),f=o+a,y=r+c;u>f?n.vx=a+(u-f)*s:f>d&&(n.vx=a+(d-f)*s),h>y?n.vy=c+(h-y)*s:y>p&&(n.vy=c+(p-y)*s)}};return r.initialize=e=>{o=e},r}function xx(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}function bx(e,t,i){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let r=0;for(;n.length>r;){const e=n[r];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)o.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(o.push(Number(n[r])+i+""),r++);else if("A"===e)for(o.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&o.push(n[r++]),n.length>r&&(o.push(Number(n[r])+t+""),r++),n.length>r&&(o.push(Number(n[r])+i+""),r++);else"Z"===e||"z"===e?(o.push(e),r++):(o.push(n[r]),r++)}return o.join(" ")}function vx(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]}function wx(e){const[t,i,n]=vx(e);return.299*t+.587*i+.114*n>150?"#222":"#fff"}function kx(e){if(e)return"function"==typeof e?e:t=>t[e]}function Ax(e,t,i){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-"+i}function Sx(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Mx(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:dj}function _x(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function $x(e,t,i,n,o,r){const s=[],a=[],c=[],l=i.treeOrientation||"vertical",u="radial"===l,d=n[0]/2,h=n[1]/2,p="number"==typeof(f=i.nodeSize)?f:5;var f;for(const t of e){let e=t.x,n=t.y;u&&(e+=d,n+=h);const r=o(px(t,"nodeStyle"));let a=r.fill||_x(i);if(i.colorByDepth&&void 0!==t.depth){const e=Mx(i);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:n,r:p,style:{fill:a,stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity,cursor:r.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=i.edgeOpacity??.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 o=t.x,s=t.y,c=n.x,p=n.y;u&&(o+=d,s+=h,c+=d,p+=h);const f=Ix(o,s,c,p,l),g=r(px(e,"edgeStyle"));a.push({type:"curved",pathD:f,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y,cursor:g.cursor},datum:e})}if(!1!==i.showLabels){const t=Sx(i.nodeLabel);for(const i of e){const e=t?t(i):i.id;if(!e)continue;let n,o,r,s=i.x,a=i.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,i=Math.sqrt(e*e+t*t);i>0?(n=s+e/i*10,o=a+t/i*10,r=0>e?"end":"start"):(n=s,o=a-12,r="middle")}else"horizontal"===l?(i.data?.children&&0!==i.data.children.length?(n=s-p-6,r="end"):(n=s+p+6,r="start"),o=a):(n=s,o=a+p+14,r="middle");c.push({x:n,y:o,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}function Px(e,t,i,n){const o=[],r=[];for(const i of e){const e=i.x1-i.x0,r=i.y1-i.y0;if(0>=e||0>=r)continue;const s=n(px(i,"nodeStyle"));let a=s.fill||_x(t);if(t.colorByDepth&&void 0!==i.depth){const e=Mx(t);a=e[i.depth%e.length]}o.push({type:"rect",x:i.x0,y:i.y0,w:e,h:r,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity,fillOpacity:s.fillOpacity,strokeOpacity:s.strokeOpacity,cursor:s.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){const i=Sx(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=i?i(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=n(px(a,"nodeStyle")).fill||_x(t);if(t.colorByDepth&&void 0!==a.depth){const e=Mx(t);d=e[a.depth%e.length]}const h="string"==typeof d?wx(d):t.themeSemantic?.text??"#000";r.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:r}}function jx(e,t,i,n){const o=[],r=[];for(const i of e){const e=i.__radius??5;if(0>=e)continue;const r=n(px(i,"nodeStyle"));let s=r.fill||_x(t);if(t.colorByDepth&&void 0!==i.depth){const e=Mx(t);s=e[i.depth%e.length]}o.push({type:"circle",cx:i.x,cy:i.y,r:e,style:{fill:s,stroke:r.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.7,cursor:r.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){const i=Sx(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=i?i(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let c=n(px(o,"nodeStyle")).fill||_x(t);if(t.colorByDepth&&void 0!==o.depth){const e=Mx(t);c=e[o.depth%e.length]}if(a){const i="string"==typeof c?wx(c):t.themeSemantic?.text??"#000";r.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else r.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:r}}function Ix(e,t,i,n,o){if("horizontal"===o){const o=(e+i)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${i},${n}`}if("radial"===o){const o=(e+i)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${i},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${i},${o} ${i},${n}`}}function Lx(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,uj.tree)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Rx(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,uj.cluster)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Cx(e,t,i,n){const o=t.padding??4,r=t.paddingTop??0,s=(0,uj.treemap)().size([i,n]).tile(uj.treemapBinary).padding(o);r>0&&s.paddingTop(r),s(e)}function Tx(e,t,i,n){const o=t.padding??4;(0,uj.pack)().size([i,n]).padding(o)(e)}function Ox(e,t,i,n){(0,uj.partition)().size([i,n]).padding(t.padding??1)(e)}function Ex(e,t,i){const n=i.treeOrientation||"vertical";if("radial"===n){const i=t.x,n=t.y;e.x=n*Math.cos(i-Math.PI/2),e.y=n*Math.sin(i-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 Fx(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 Nx(e,t){const i=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-i,e.x1=t.x+i,e.y0=t.y-i,e.y1=t.y+i,e.width=2*i,e.height=2*i,e.__radius=i}function zx(e){let t=e.__orbitState;return t||(t={metaMap:/* @__PURE__ */new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function Dx(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function Bx(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}function Wx(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}function Yx(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}function qx(e,t,i,n,o){function r(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const s=Bx(i.childrenAccessor),a=Wx(i.nodeIDAccessor),c=Dx(i.orbitMode),l=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof l?()=>l:l,h="number"==typeof u?()=>u:u,p=zx(i);p.metaMap.clear(),n.length=0,o.length=0;const f=/* @__PURE__ */new Map,y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=r(a(e));n.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,l,u,f,y,g){const m=s(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=c[Math.min(w,c.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=c[Math.min(x,c.length-1)],w=m.slice(k,k+v);if(!w.length)break;const A=(x+1)/b,S={id:i,depth:y,data:t,parentId:i},M=g?f/d(S)*A:f*A,_=(0,pj.pie)().value(e=>{const t=s(e)?.length;return t?4:1}).sort(null)(w),$=h(S);for(let t=0;w.length>t;t++){const s=(_[t].startAngle+_[t].endAngle)/2,c=w[t],d=r(a(c)),h=l+M*Math.sin(s),f=u+M*Math.cos(s)*$;n.push({id:d,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:c}),p.metaMap.set(d,{ring:M,angle:s,depth:y,parentId:i,eccentricity:$}),o.push({source:i,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:d}}),e(c,d,h,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}function Xx(e,t,i,n){const o=zx(t),r=t.orbitSpeed??.25,s=t.orbitRevolution??Yx(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-o.startTime)/1e3,c=r*(Math.PI/6),l=/* @__PURE__ */new Map;for(const t of e)l.set(t.id,t);for(const t of e){const e=o.metaMap.get(t.id);if(!e||!e.parentId)continue;const i=l.get(e.parentId);if(!i)continue;const n=e.angle+a*c*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=i.x+e.ring*Math.sin(n),t.y=i.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}function Gx(e,t){return Cp(Vx(e,t),e,"network-node-cursor-"+t)}function Vx(e,t){switch(e.type){case"circle":{const i=e,n=Mr(i.style.fill)?Pr(i.style.fill,`net-circle-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
521
521
|
return(0,mj.jsxs)(yj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,mj.jsx)("defs",{children:n}),
|
|
522
522
|
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */(0,mj.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:n?`url(#net-circle-${t}-hatch)`:Sp(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-circle-"+t)}case"rect":{const i=e,n=
|
|
523
|
+
/* @__PURE__ */(0,mj.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:n?`url(#net-circle-${t}-hatch)`:Sp(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-circle-"+t)}case"rect":{const i=e,n=Mr(i.style.fill)?Pr(i.style.fill,`net-rect-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
524
524
|
return(0,mj.jsxs)(yj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,mj.jsx)("defs",{children:n}),
|
|
525
525
|
/* @__PURE__ */
|
|
526
|
-
/* @__PURE__ */(0,mj.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n?`url(#net-rect-${t}-hatch)`:Sp(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-rect-"+t)}case"arc":{const i=e,n=(0,gj.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(U_)||"",o=
|
|
526
|
+
/* @__PURE__ */(0,mj.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n?`url(#net-rect-${t}-hatch)`:Sp(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-rect-"+t)}case"arc":{const i=e,n=(0,gj.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(U_)||"",o=Mr(i.style.fill)?Pr(i.style.fill,`net-arc-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
527
527
|
return(0,mj.jsxs)(yj.Fragment,{children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,mj.jsx)("defs",{children:o}),
|
|
528
528
|
/* @__PURE__ */
|
|
529
529
|
/* @__PURE__ */(0,mj.jsx)("path",{d:n,transform:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:Sp(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-arc-"+t)}case"symbol":{const i=e,n=ip(i.symbolType,i.size,i.path);/* @__PURE__ */ /* @__PURE__ */
|
|
530
530
|
return(0,mj.jsx)("path",{d:n,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?Sp(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},"net-symbol-"+t)}case"glyph":return _p(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}function Hx(e,t){return Cp(Ux(e,t),e,"network-edge-cursor-"+t)}function Ux(e,t){switch(e.type){case"line":/* @__PURE__ */ /* @__PURE__ */
|
|
531
|
-
return(0,mj.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth??1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const i=e,n=`net-bezier-${t}-hatch`,o=
|
|
531
|
+
return(0,mj.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth??1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const i=e,n=`net-bezier-${t}-hatch`,o=Mr(i.style.fill)?Pr(i.style.fill,n):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
532
532
|
return(0,mj.jsxs)(yj.Fragment,{children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,mj.jsx)("defs",{children:o}),
|
|
533
533
|
/* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */(0,mj.jsx)("path",{d:i.pathD,fill:o?`url(#${n})`:Sp(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"ribbon":{const i=e,n=`net-ribbon-${t}-hatch`,o=
|
|
534
|
+
/* @__PURE__ */(0,mj.jsx)("path",{d:i.pathD,fill:o?`url(#${n})`:Sp(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"ribbon":{const i=e,n=`net-ribbon-${t}-hatch`,o=Mr(i.style.fill)?Pr(i.style.fill,n):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
535
535
|
return(0,mj.jsxs)(yj.Fragment,{children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,mj.jsx)("defs",{children:o}),
|
|
536
536
|
/* @__PURE__ */
|
|
537
537
|
/* @__PURE__ */(0,mj.jsx)("path",{d:i.pathD,fill:o?`url(#${n})`:Sp(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"curved":{const i=e;/* @__PURE__ */ /* @__PURE__ */
|
|
538
538
|
return(0,mj.jsx)("path",{d:i.pathD,fill:Sp(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth??1,opacity:i.style.opacity},"net-edge-"+t)}default:return null}}function Kx(e,t){/* @__PURE__ */ /* @__PURE__ */
|
|
539
|
-
return(0,mj.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}function Zx(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Qx(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;const n=kp(e.glyph,e.size);return{x:t+n.centerDx,y:i+n.centerDy,r:Math.max(1,n.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,np(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Jx(e){if(!e)return;const t=[];for(const i of e){const e=Qx(i);e&&t.push({pointId:Zx(i),...e})}return t}function eb(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function tb(e,t){const i=eb(t.nodeIDAccessor,"id");return e.map(e=>({id:i(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}function ib(e,t){const i=eb(t.sourceAccessor,"source"),n=eb(t.targetAccessor,"target"),o=eb(t.valueAccessor,"value");return e.map((e,t)=>{const r=Number(o(e)),s=i(e)+"",a=n(e)+"";return{source:s,target:a,value:Number.isFinite(r)?r:1,y0:0,y1:0,sankeyWidth:0,data:e,_edgeKey:`${s}\0${a}\0${t}`}})}function nb(e){return e.map(e=>{const t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,n="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:n,y:o}})}function ob(e,t){const i=zr(e.theme),n=e.chartType||"force",o=t=>gp({frameType:"network",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:s}),r=e.size||[500,500],s=l({...sg(n),...e.margin},e.title),c=a(e.title),u=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const o=Hs(e.nodes||[]);if(o.length>0)return nf(o,t);if(bj.has(n)&&e.data)return nf(Ku(e.data,e.childrenAccessor||"children"),t);const r=Array.isArray(e.edges)?Hs(e.edges):[];if(0===r.length)return[];const s=eb(e.sourceAccessor,"source"),a=eb(e.targetAccessor,"target");return nf(Array.from(new Set(r.flatMap(e=>[s(e),a(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Qy(s,{props:e,categories:u,theme:i,size:r,hasTitle:c});const d=Jy({props:e,categories:u,theme:i,size:r,margin:s,hasTitle:c}),h=r[0]-s.left-s.right,p=r[1]-s.top-s.bottom,f=rg(e.backgroundGraphics,r,s,null),y=rg(e.foregroundGraphics,r,s,null),g=()=>{let n;const a=e=>Number(e),c=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:a,y:a},layout:{width:h,height:p},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{n=e}}):null;return t&&(t.evidence=o(n)),GP.renderToStaticMarkup(tg(f||y||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,xj.jsxs)(xj.Fragment,{children:[f,c,y]}):null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))},m=pm(n);if(!m&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${n}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);const x={chartType:n,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let b,v;if(bj.has(n)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g();x.__hierarchyRoot=t,b=[],v=[]}else{const t=Hs(e.nodes||[]),i=Array.isArray(e.edges)?Hs(e.edges):[];if(0===t.length&&0===i.length)return g();if(v=ib(i,x),0===t.length&&v.length>0){const e=/* @__PURE__ */new Set;for(const t of v){const i=Vy(t.source),n=Vy(t.target);i&&e.add(i),n&&e.add(n)}b=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else b=tb(t,x)}let w=[],k=[],A=[],S=null,M=null;if(x.customNetworkLayout){const t=x.colorScheme,n=Yn(t,i.colors.categorical,Tk),o=qn(n,t),r={nodes:b,edges:v,dimensions:{width:h,height:p,plot:{x:0,y:0,width:h,height:p}},theme:{semantic:i.colors,categorical:[...n]},resolveColor:o,config:x.layoutConfig??{},selection:e.layoutSelection??null},s=x.customNetworkLayout(r);w=s.sceneNodes??[],k=s.sceneEdges??[],dm({nodes:w,edges:k,restyle:s.restyle,restyleEdge:s.restyleEdge,selection:e.layoutSelection??null,baseStyles:/* @__PURE__ */new WeakMap}),A=s.labels??[],S=s.backgrounds??null,M=s.overlays??null}else if(m){m.computeLayout(b,v,x,[h,p]);const e=m.buildScene(b,v,x,[h,p]);w=e.sceneNodes,k=e.sceneEdges,A=e.labels}const _=Dr(i);for(const e of A)e.fill||(e.fill=_.text);const $=Wp({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>Hx(e,t)}),P=Wp({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>Gx(e,t)}),j=$.map(e=>e.element),I=P.map(e=>e.element),L=A.map((e,t)=>Kx(e,t)).filter(Boolean);let R;const C=e=>Number(e),T=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:C,y:C},layout:{width:h,height:p},theme:i,frameType:"network",annotationData:nb(w),pointNodes:Jx(w),idPrefix:e._idPrefix,onRender:e=>{R=e}}):null;return t&&(t.evidence=gp({frameType:"network",width:r[0],height:r[1],marks:[...P.map(({node:e})=>({type:"node:"+(e.type??"node")})),...$.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:R,nodeCount:P.length,edgeCount:$.length,margin:s})),GP.renderToStaticMarkup(tg(/* @__PURE__ */ /* @__PURE__ */(0,xj.jsxs)(xj.Fragment,{children:[f,S,j,I,L,T,y,M]}),{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function rb(e){if(!e)return(0,Aj.geoEqualEarth)();if("string"==typeof e){const t=Sj[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Aj.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Sj[e.type],i=t?t():(0,Aj.geoEqualEarth)();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function sb(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function ab(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function cb(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function lb(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function ub(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function db(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function hb(e,t){if(2>e.length)return[e];const i=.4*t,n=[];let o=[e[0]];for(let t=1;e.length>t;t++){const r=e[t];Math.abs(r[0]-e[t-1][0])>i?(2>o.length||n.push(o),o=[r]):o.push(r)}return 2>o.length||n.push(o),n}function pb(e,t,i=24){const n=t[0]-e[0],o=t[1]-e[1],r=Math.sqrt(n*n+o*o);if(0===r)return[e,t];const s=-o/r,a=n/r,c=Math.min(.3*r,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let n=0;i>=n;n++){const o=n/i,r=1-o;d.push([r*r*e[0]+2*r*o*l+o*o*t[0],r*r*e[1]+2*r*o*u+o*o*t[1]])}return d}function fb(e,t){if(2>e.length)return e;const i=t/2+1,n=[];for(let t=0;e.length>t;t++){const o=e[t];let r,s;0===t?(r=e[1][0]-o[0],s=e[1][1]-o[1]):t===e.length-1?(r=o[0]-e[t-1][0],s=o[1]-e[t-1][1]):(r=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(r*r+s*s)||1;n.push([o[0]+s/a*i,o[1]+-r/a*i])}return n}function yb(e,t,i,n,o){const r=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(r*r+s*s);if(0===a)return[e,t];const c=s/a,l=-r/a,u=o/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}function gb(e,t,i,n){const o=e.filter(e=>"point"===e.type);if(2>o.length)return null;const r=t.strength??1,s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,a="strip"===t.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const d=Ps(o.map(e=>e.datum?Number(l(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);n>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}const h="strip"===a?xb(o,u,l,d,i):mb(o,u,l,d,s,i),p=e.filter(e=>"line"===e.type);if(p.length>0){const e=/* @__PURE__ */new Map;for(const t of o)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(const i of p){const n=i.datum?.source,o=i.datum?.target;if(null!=n&&null!=o){const r=e.get(n+""),s=e.get(o+"");if(r&&s)if("fractional"===t.lineMode&&i.path.length>2){const e=i.path[0],t=i.path[i.path.length-1],n=[r[0]-e[0],r[1]-e[1]],o=[s[0]-t[0],s[1]-t[1]],a=[0];for(let e=1;i.path.length>e;e++)a.push(a[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));const c=a[a.length-1];i.path=i.path.map((e,t)=>{const r=c>0?a[t]/c:t/(i.path.length-1);return[e[0]+n[0]*(1-r)+o[0]*r,e[1]+n[1]*(1-r)+o[1]*r]})}else i.path=[r,s]}}}return h}function mb(e,t,i,n,o,r){const s=t.x,a=t.y,c=r.width/2,l=r.height/2,u=Math.min(r.width,r.height)/2,d=(0,Mj.scaleLinear)().domain([0,n]).range([0,u]);for(const r of e){if(r===t)continue;if(!r.datum)continue;const e=r.x,u=r.y,h=Math.atan2(u-a,e-s),p=Math.hypot(e-s,u-a),f=Number(i(r.datum)),y=isFinite(f)&&f>=0?n>0?d(f):0:p,g=c+Math.cos(h)*y,m=l+Math.sin(h)*y;r.x=e+(g-e)*o,r.y=u+(m-u)*o}return t.x=s+(c-s)*o,t.y=a+(l-a)*o,{cx:t.x,cy:t.y,maxCost:n,availableRadius:u,layout:"radial"}}function xb(e,t,i,n,o){const r=Math.max(3,Math.min(8,.35*o.height)),s=Math.max(1,o.width-2*r),a=o.height/2,c=(0,Mj.scaleLinear)().domain([0,n]).range([0,s]);t.x=r,t.y=a;const l=[];for(const o of e){if(o===t)continue;if(!o.datum){o.x=r,o.y=a;continue}const e=Number(i(o.datum)),s=r+(isFinite(e)&&e>=0&&n>0?c(e):0);o.x=s,o.y=a,l.push({node:o,x:s})}l.sort((e,t)=>e.x-t.x);const u=Math.max(0,Math.min(o.height/2-1,6));let d=0;for(;l.length>d;){let e=d+1;for(;l.length>e&&3>Math.abs(l[e].x-l[d].x);)e++;const t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)l[d+e].node.y=a+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:r,cy:a,maxCost:n,availableRadius:s,layout:"strip"}}function bb(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=Oj[n]??Ej;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function vb({config:e,projection:t,path:i,areas:n,points:o,lines:r,layout:s}){const a=sb(e.xAccessor,"lon"),c=sb(e.yAccessor,"lat"),l=[],u=lb(e),d=db(e),h=ub(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,n=(0,Nj.geoGraticule)();t.step&&n.step(t.step);const o=i(n())||"";o&&l.push({type:"geoarea",pathData:o,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of n){const n=i(t);if(!n)continue;const o=i.centroid(t),r=i.bounds(t),s=i.area(t);l.push({type:"geoarea",pathData:n,centroid:o,bounds:r,screenArea:s,style:cb(e.areaStyle,t,u),datum:t,interactive:!0})}const p=ab(e.lineDataAccessor);for(const i of r){const n=p(i);if(!n||2>n.length)continue;let o=[];if("geo"===e.lineType){const e=Array(n.length);for(let t=0;n.length>t;t++)e[t]=[a(n[t]),c(n[t])];for(let i=0;e.length-1>i;i++){const n=e[i],r=e[i+1],s=(0,Nj.geoDistance)(n,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,Nj.geoInterpolate)(n,r);for(let e=0;a>=e;e++){if(i>0&&0===e)continue;const n=t(c(e/a));null!=n&&o.push(n)}}}else for(let e=0;n.length>e;e++){const i=n[e],r=t([a(i),c(i)]);null!=r&&o.push(r)}if(2>o.length)continue;const r=cb(e.lineStyle,i,d),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==n.length||2>o.length||"arc"!==e.flowStyle?2!==n.length||2>o.length||"offset"!==e.flowStyle||(o="geo"===e.lineType?fb(o,u):yb(o[0],o[o.length-1],0,0,u)):o=pb(o[0],o[o.length-1]);const h=hb(o,s.width);if(h.length>1)for(const e of h)2>e.length||l.push({type:"line",path:e,style:{...r,_edgeFade:!0},datum:i});else l.push({type:"line",path:2>o.length&&h[0]||o,style:r,datum:i})}const f=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,y=t.clipAngle?t.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const i of o){const n=a(i),o=c(i);if(null!=g&&(0,Nj.geoDistance)([n,o],b)>g)continue;const r=t([n,o]);if(!r)continue;const s=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:i,pointId:f?f(i)+"":void 0};l.push(u)}return l}function wb(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}function kb(e){return{...e,fitPadding:wb(e.fitPadding)}}function Ab(e){return"fitPadding"in e?{...e,fitPadding:wb(e.fitPadding)}:e}function Sb(e,t){return Cp(Mb(e,t),e,"geo-cursor-"+t)}function Mb(e,t){switch(e.type){case"geoarea":{const i=e;if(!i.pathData)return null;const n=kr(i.style.fill)?Mr(i.style.fill,`geoarea-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
539
|
+
return(0,mj.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}function Zx(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Qx(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;const n=kp(e.glyph,e.size);return{x:t+n.centerDx,y:i+n.centerDy,r:Math.max(1,n.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,np(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Jx(e){if(!e)return;const t=[];for(const i of e){const e=Qx(i);e&&t.push({pointId:Zx(i),...e})}return t}function eb(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function tb(e,t){const i=eb(t.nodeIDAccessor,"id");return e.map(e=>({id:i(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}function ib(e,t){const i=eb(t.sourceAccessor,"source"),n=eb(t.targetAccessor,"target"),o=eb(t.valueAccessor,"value");return e.map((e,t)=>{const r=Number(o(e)),s=i(e)+"",a=n(e)+"";return{source:s,target:a,value:Number.isFinite(r)?r:1,y0:0,y1:0,sankeyWidth:0,data:e,_edgeKey:`${s}\0${a}\0${t}`}})}function nb(e){return e.map(e=>{const t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,n="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:n,y:o}})}function ob(e,t){const i=Wr(e.theme),n=e.chartType||"force",o=t=>gp({frameType:"network",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:s}),r=e.size||[500,500],s=l({...sg(n),...e.margin},e.title),c=a(e.title),u=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const o=Hs(e.nodes||[]);if(o.length>0)return nf(o,t);if(bj.has(n)&&e.data)return nf(Ku(e.data,e.childrenAccessor||"children"),t);const r=Array.isArray(e.edges)?Hs(e.edges):[];if(0===r.length)return[];const s=eb(e.sourceAccessor,"source"),a=eb(e.targetAccessor,"target");return nf(Array.from(new Set(r.flatMap(e=>[s(e),a(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Qy(s,{props:e,categories:u,theme:i,size:r,hasTitle:c});const d=Jy({props:e,categories:u,theme:i,size:r,margin:s,hasTitle:c}),h=r[0]-s.left-s.right,p=r[1]-s.top-s.bottom,f=rg(e.backgroundGraphics,r,s,null),y=rg(e.foregroundGraphics,r,s,null),g=()=>{let n;const a=e=>Number(e),c=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:a,y:a},layout:{width:h,height:p},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{n=e}}):null;return t&&(t.evidence=o(n)),GP.renderToStaticMarkup(tg(f||y||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,xj.jsxs)(xj.Fragment,{children:[f,c,y]}):null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))},m=pm(n);if(!m&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${n}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);const x={chartType:n,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let b,v;if(bj.has(n)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g();x.__hierarchyRoot=t,b=[],v=[]}else{const t=Hs(e.nodes||[]),i=Array.isArray(e.edges)?Hs(e.edges):[];if(0===t.length&&0===i.length)return g();if(v=ib(i,x),0===t.length&&v.length>0){const e=/* @__PURE__ */new Set;for(const t of v){const i=Vy(t.source),n=Vy(t.target);i&&e.add(i),n&&e.add(n)}b=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else b=tb(t,x)}let w=[],k=[],A=[],S=null,M=null;if(x.customNetworkLayout){const t=x.colorScheme,n=Gn(t,i.colors.categorical,Tk),o=Vn(n,t),r={nodes:b,edges:v,dimensions:{width:h,height:p,plot:{x:0,y:0,width:h,height:p}},theme:{semantic:i.colors,categorical:[...n]},resolveColor:o,config:x.layoutConfig??{},selection:e.layoutSelection??null},s=x.customNetworkLayout(r);w=s.sceneNodes??[],k=s.sceneEdges??[],dm({nodes:w,edges:k,restyle:s.restyle,restyleEdge:s.restyleEdge,selection:e.layoutSelection??null,baseStyles:/* @__PURE__ */new WeakMap}),A=s.labels??[],S=s.backgrounds??null,M=s.overlays??null}else if(m){m.computeLayout(b,v,x,[h,p]);const e=m.buildScene(b,v,x,[h,p]);w=e.sceneNodes,k=e.sceneEdges,A=e.labels}const _=Yr(i);for(const e of A)e.fill||(e.fill=_.text);const $=Wp({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>Hx(e,t)}),P=Wp({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>Gx(e,t)}),j=$.map(e=>e.element),I=P.map(e=>e.element),L=A.map((e,t)=>Kx(e,t)).filter(Boolean);let R;const C=e=>Number(e),T=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:C,y:C},layout:{width:h,height:p},theme:i,frameType:"network",annotationData:nb(w),pointNodes:Jx(w),idPrefix:e._idPrefix,onRender:e=>{R=e}}):null;return t&&(t.evidence=gp({frameType:"network",width:r[0],height:r[1],marks:[...P.map(({node:e})=>({type:"node:"+(e.type??"node")})),...$.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:R,nodeCount:P.length,edgeCount:$.length,margin:s})),GP.renderToStaticMarkup(tg(/* @__PURE__ */ /* @__PURE__ */(0,xj.jsxs)(xj.Fragment,{children:[f,S,j,I,L,T,y,M]}),{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function rb(e){if(!e)return(0,Aj.geoEqualEarth)();if("string"==typeof e){const t=Sj[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Aj.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Sj[e.type],i=t?t():(0,Aj.geoEqualEarth)();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function sb(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function ab(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function cb(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function lb(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function ub(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function db(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function hb(e,t){if(2>e.length)return[e];const i=.4*t,n=[];let o=[e[0]];for(let t=1;e.length>t;t++){const r=e[t];Math.abs(r[0]-e[t-1][0])>i?(2>o.length||n.push(o),o=[r]):o.push(r)}return 2>o.length||n.push(o),n}function pb(e,t,i=24){const n=t[0]-e[0],o=t[1]-e[1],r=Math.sqrt(n*n+o*o);if(0===r)return[e,t];const s=-o/r,a=n/r,c=Math.min(.3*r,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let n=0;i>=n;n++){const o=n/i,r=1-o;d.push([r*r*e[0]+2*r*o*l+o*o*t[0],r*r*e[1]+2*r*o*u+o*o*t[1]])}return d}function fb(e,t){if(2>e.length)return e;const i=t/2+1,n=[];for(let t=0;e.length>t;t++){const o=e[t];let r,s;0===t?(r=e[1][0]-o[0],s=e[1][1]-o[1]):t===e.length-1?(r=o[0]-e[t-1][0],s=o[1]-e[t-1][1]):(r=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(r*r+s*s)||1;n.push([o[0]+s/a*i,o[1]+-r/a*i])}return n}function yb(e,t,i,n,o){const r=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(r*r+s*s);if(0===a)return[e,t];const c=s/a,l=-r/a,u=o/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}function gb(e,t,i,n){const o=e.filter(e=>"point"===e.type);if(2>o.length)return null;const r=t.strength??1,s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,a="strip"===t.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const d=$t(o.map(e=>e.datum?Number(l(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);n>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}const h="strip"===a?xb(o,u,l,d,i):mb(o,u,l,d,s,i),p=e.filter(e=>"line"===e.type);if(p.length>0){const e=/* @__PURE__ */new Map;for(const t of o)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(const i of p){const n=i.datum?.source,o=i.datum?.target;if(null!=n&&null!=o){const r=e.get(n+""),s=e.get(o+"");if(r&&s)if("fractional"===t.lineMode&&i.path.length>2){const e=i.path[0],t=i.path[i.path.length-1],n=[r[0]-e[0],r[1]-e[1]],o=[s[0]-t[0],s[1]-t[1]],a=[0];for(let e=1;i.path.length>e;e++)a.push(a[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));const c=a[a.length-1];i.path=i.path.map((e,t)=>{const r=c>0?a[t]/c:t/(i.path.length-1);return[e[0]+n[0]*(1-r)+o[0]*r,e[1]+n[1]*(1-r)+o[1]*r]})}else i.path=[r,s]}}}return h}function mb(e,t,i,n,o,r){const s=t.x,a=t.y,c=r.width/2,l=r.height/2,u=Math.min(r.width,r.height)/2,d=(0,Mj.scaleLinear)().domain([0,n]).range([0,u]);for(const r of e){if(r===t)continue;if(!r.datum)continue;const e=r.x,u=r.y,h=Math.atan2(u-a,e-s),p=Math.hypot(e-s,u-a),f=Number(i(r.datum)),y=isFinite(f)&&f>=0?n>0?d(f):0:p,g=c+Math.cos(h)*y,m=l+Math.sin(h)*y;r.x=e+(g-e)*o,r.y=u+(m-u)*o}return t.x=s+(c-s)*o,t.y=a+(l-a)*o,{cx:t.x,cy:t.y,maxCost:n,availableRadius:u,layout:"radial"}}function xb(e,t,i,n,o){const r=Math.max(3,Math.min(8,.35*o.height)),s=Math.max(1,o.width-2*r),a=o.height/2,c=(0,Mj.scaleLinear)().domain([0,n]).range([0,s]);t.x=r,t.y=a;const l=[];for(const o of e){if(o===t)continue;if(!o.datum){o.x=r,o.y=a;continue}const e=Number(i(o.datum)),s=r+(isFinite(e)&&e>=0&&n>0?c(e):0);o.x=s,o.y=a,l.push({node:o,x:s})}l.sort((e,t)=>e.x-t.x);const u=Math.max(0,Math.min(o.height/2-1,6));let d=0;for(;l.length>d;){let e=d+1;for(;l.length>e&&3>Math.abs(l[e].x-l[d].x);)e++;const t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)l[d+e].node.y=a+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:r,cy:a,maxCost:n,availableRadius:s,layout:"strip"}}function bb(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=Oj[n]??Ej;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function vb({config:e,projection:t,path:i,areas:n,points:o,lines:r,layout:s}){const a=sb(e.xAccessor,"lon"),c=sb(e.yAccessor,"lat"),l=[],u=lb(e),d=db(e),h=ub(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,n=(0,Nj.geoGraticule)();t.step&&n.step(t.step);const o=i(n())||"";o&&l.push({type:"geoarea",pathData:o,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of n){const n=i(t);if(!n)continue;const o=i.centroid(t),r=i.bounds(t),s=i.area(t);l.push({type:"geoarea",pathData:n,centroid:o,bounds:r,screenArea:s,style:cb(e.areaStyle,t,u),datum:t,interactive:!0})}const p=ab(e.lineDataAccessor);for(const i of r){const n=p(i);if(!n||2>n.length)continue;let o=[];if("geo"===e.lineType){const e=Array(n.length);for(let t=0;n.length>t;t++)e[t]=[a(n[t]),c(n[t])];for(let i=0;e.length-1>i;i++){const n=e[i],r=e[i+1],s=(0,Nj.geoDistance)(n,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,Nj.geoInterpolate)(n,r);for(let e=0;a>=e;e++){if(i>0&&0===e)continue;const n=t(c(e/a));null!=n&&o.push(n)}}}else for(let e=0;n.length>e;e++){const i=n[e],r=t([a(i),c(i)]);null!=r&&o.push(r)}if(2>o.length)continue;const r=cb(e.lineStyle,i,d),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==n.length||2>o.length||"arc"!==e.flowStyle?2!==n.length||2>o.length||"offset"!==e.flowStyle||(o="geo"===e.lineType?fb(o,u):yb(o[0],o[o.length-1],0,0,u)):o=pb(o[0],o[o.length-1]);const h=hb(o,s.width);if(h.length>1)for(const e of h)2>e.length||l.push({type:"line",path:e,style:{...r,_edgeFade:!0},datum:i});else l.push({type:"line",path:2>o.length&&h[0]||o,style:r,datum:i})}const f=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,y=t.clipAngle?t.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const i of o){const n=a(i),o=c(i);if(null!=g&&(0,Nj.geoDistance)([n,o],b)>g)continue;const r=t([n,o]);if(!r)continue;const s=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:i,pointId:f?f(i)+"":void 0};l.push(u)}return l}function wb(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}function kb(e){return{...e,fitPadding:wb(e.fitPadding)}}function Ab(e){return"fitPadding"in e?{...e,fitPadding:wb(e.fitPadding)}:e}function Sb(e,t){return Cp(Mb(e,t),e,"geo-cursor-"+t)}function Mb(e,t){switch(e.type){case"geoarea":{const i=e;if(!i.pathData)return null;const n=Mr(i.style.fill)?Pr(i.style.fill,`geoarea-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
540
540
|
return(0,Wj.jsxs)(Bj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,Wj.jsx)("defs",{children:n}),
|
|
541
541
|
/* @__PURE__ */
|
|
542
|
-
/* @__PURE__ */(0,Wj.jsx)("path",{d:i.pathData,fill:n?`url(#geoarea-${t}-hatch)`:Sp(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth??.5,strokeDasharray:i.style.strokeDasharray,opacity:(i.style.opacity??1)*(i._decayOpacity??1)})]},"geoarea-"+t)}case"point":{const i=e,n=
|
|
542
|
+
/* @__PURE__ */(0,Wj.jsx)("path",{d:i.pathData,fill:n?`url(#geoarea-${t}-hatch)`:Sp(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth??.5,strokeDasharray:i.style.strokeDasharray,opacity:(i.style.opacity??1)*(i._decayOpacity??1)})]},"geoarea-"+t)}case"point":{const i=e,n=Mr(i.style.fill)?Pr(i.style.fill,`geopoint-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
|
|
543
543
|
return(0,Wj.jsxs)(Bj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,Wj.jsx)("defs",{children:n}),
|
|
544
544
|
/* @__PURE__ */
|
|
545
545
|
/* @__PURE__ */(0,Wj.jsx)("circle",{cx:i.x,cy:i.y,r:i.r,fill:n?`url(#geopoint-${t}-hatch)`:Sp(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+t)}case"line":{const i=e;if(2>i.path.length)return null;const n="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");/* @__PURE__ */ /* @__PURE__ */
|
|
@@ -566,7 +566,7 @@ return(0,Yj.jsxs)("g",{children:[
|
|
|
566
566
|
/* @__PURE__ */
|
|
567
567
|
/* @__PURE__ */(0,Yj.jsx)("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),
|
|
568
568
|
/* @__PURE__ */
|
|
569
|
-
/* @__PURE__ */(0,Yj.jsx)("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function Pb(e,t){const i=
|
|
569
|
+
/* @__PURE__ */(0,Yj.jsx)("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function Pb(e,t){const i=Wr(e.theme),n=e.size||[e.width||600,e.height||400],o=l({top:10,right:10,bottom:10,left:10,...e.margin},e.title),r=a(e.title),s=Array.isArray(e.areas)?Hs(e.areas):e.areas,c=Hs(e.points),u=Hs(e.lines),d=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;return nf(c.length>0?c:Array.isArray(s)&&s.length>0?"string"==typeof t?s.map(e=>({...e.properties||{},...e})):s:[],t)})():[];Qy(o,{props:e,categories:d,theme:i,size:n,hasTitle:r});const h=Jy({props:e,categories:d,theme:i,size:n,margin:o,hasTitle:r}),p=n[0]-(o.left??0)-(o.right??0),f=n[1]-(o.top??0)-(o.bottom??0),y={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutSelection:e.layoutSelection,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:Dr(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},g=new Dj(y);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);g.setAreas(s)}e.points&&g.setPoints(c),e.lines&&g.setLines(u),g.computeScene({width:p,height:f});const m=rg(e.backgroundGraphics,n,o,g.scales),x=rg(e.foregroundGraphics,n,o,g.scales),b=Wp({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>Sb(e,t)});if(0===b.length){let r;const s=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:p,height:f},theme:i,pointNodes:_b(g.scene),idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=gp({frameType:"geo",width:n[0],height:n[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:r,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),vj.renderToStaticMarkup(tg(m||x||e.annotations||g.customLayoutOverlays?/* @__PURE__ */ /* @__PURE__ */(0,qj.jsxs)(qj.Fragment,{children:[m,s,x,g.customLayoutOverlays]}):null,{width:n[0],height:n[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:p,innerHeight:f,legend:h,idPrefix:e._idPrefix}))}const v=b.map(e=>e.element),w=e.cartogramChrome,k=g.cartogramLayout&&w?/* @__PURE__ */ /* @__PURE__ */(0,qj.jsx)($b,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:jb(g.cartogramLayout.maxCost,w.showRings),showRings:w.showRings??!0,showNorth:w.showNorth??!0,showRingLabels:w.showRingLabels??!0,costLabel:"string"==typeof w.costLabel?w.costLabel:void 0}):null;let A;const S=e.annotations?wy({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:p,height:f},theme:i,pointNodes:_b(g.scene),idPrefix:e._idPrefix,onRender:e=>{A=e}}):null;return t&&(t.evidence=gp({frameType:"geo",width:n[0],height:n[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:A,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),vj.renderToStaticMarkup(tg(/* @__PURE__ */ /* @__PURE__ */(0,qj.jsxs)(qj.Fragment,{children:[m,v,S,k,x,g.customLayoutOverlays]}),{width:n[0],height:n[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:p,innerHeight:f,legend:h,idPrefix:e._idPrefix}))}function jb(e,t){if(!1===t||0>=e)return[];if(Array.isArray(t))return t.filter(t=>t>0&&e>=t);const i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),n=e/i,o=[];for(let e=1;i>=e;e++)o.push(Math.round(n*e*10)/10);return o}function Ib(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}function Lb(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}function Rb(e,t,i,n){const o=e-(t+i+n);return{charge:e,live:t,queued:i,sedimented:n,unaccounted:o,balanced:0===o}}function Cb(e,t={}){const i=t.bodies??Ib(e),n=i.filter(e=>e.sleeping).length,o=e.queue.length,r=e.sediment.reduce((e,t)=>e+t.count,0),s="settled"===e.simulationState&&0===o&&n===i.length,a=[];s||a.push("PHYSICS_NOT_SETTLED"),o>0&&a.push("PHYSICS_QUEUE_UNDRAINED");const c=null!=t.charge&&Number.isFinite(t.charge)?Rb(t.charge,i.length,o,r):void 0;return c&&!c.balanced&&a.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:n,settled:s,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Lb(t.projectionRows),queuedCount:o,sedimentedCount:r,...c?{ledger:c}:{},warnings:a}}function Tb(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function Ob(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Eb(e,t,i){const n="function"==typeof t?t(e,i):t;return{...Gj,...n??{}}}function Fb(e,t={},i={index:0,simulationState:"settled"}){const n=Tb(e),o={label:t.getBodyLabel?.(e)??Ob(e)},r={style:Eb(e,t.bodyStyle,i),datum:n,accessibleDatum:n,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}function Nb(e,t={},i="settled"){return e.map((e,n)=>Fb(e,t,{index:n,simulationState:i}))}function zb(e,t={}){const i=e.settle(t.maxSteps),n=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:n,sceneNodes:Nb(n,t,o.simulationState),evidence:Cb(o,{bodies:n,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge}),stepsRun:i}}function Db(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}function Bb(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function Wb(e,t={}){const{width:i=640,height:n=360,title:o,description:r,background:s,backgroundGraphics:a,backgroundGraphicsBackdrop:c,className:l,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:p,renderBodySVG:f,renderChrome:y,...g}=t,m=zb(e,g),x={...Hj,...h},b=[i,n],v=Bb(a,b,x),w=Bb(u,b,x),k=Db(d),A=o?k+"-title":void 0,S=r?k+"-desc":void 0,M=[A,S].filter(Boolean).join(" ")||void 0,_=x.left||x.top?`translate(${x.left},${x.top})`:void 0,$=Math.max(1,i-x.left-x.right),P=Math.max(1,n-x.top-x.bottom),j=k+"-plot-clip",I=_&&null!=v?/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("g",{transform:_,children:v}):v;return{element:/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:l??"stream-physics-frame",width:i,height:n,viewBox:`0 0 ${i} ${n}`,role:"img","aria-labelledby":M,style:p,children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("title",{id:A,children:o}),r&&/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("desc",{id:S,children:r}),
|
|
570
570
|
/* @__PURE__ */
|
|
571
571
|
/* @__PURE__ */(0,Vj.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("clipPath",{id:j,children:/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("rect",{width:$,height:P})})}),c&&"transparent"!==c?/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:n,fill:c}):null,!a&&s&&"transparent"!==s?/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)("rect",{x:0,y:0,width:i,height:n,fill:s}):null,I,
|
|
572
572
|
/* @__PURE__ */
|
|
@@ -574,19 +574,19 @@ return(0,Yj.jsxs)("g",{children:[
|
|
|
574
574
|
/* @__PURE__ */
|
|
575
575
|
/* @__PURE__ */(0,Zj.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:p}),
|
|
576
576
|
/* @__PURE__ */
|
|
577
|
-
/* @__PURE__ */(0,Zj.jsx)(Kb,{title:t.title,totalWidth:i[0],marginTop:Math.max(n.top,28)}),f]})}}function tv(e,t){const i=e.size??[e.width??600,e.height??400],n=
|
|
577
|
+
/* @__PURE__ */(0,Zj.jsx)(Kb,{title:t.title,totalWidth:i[0],marginTop:Math.max(n.top,28)}),f]})}}function tv(e,t){const i=e.size??[e.width??600,e.height??400],n=Wr(e.theme),o=void 0===e.theme?{}:Ha(n),r=e.bodyStyle,s=!1,a=e.legendPosition??"right",l=c({...Qj,...e.margin},s,!!e.legend&&"top"===a);if(e.legend){const t={...l};w(l,{legend:e.legend,position:a,size:i,hasTitle:s,legendLayout:e.legendLayout}),u(l,t,i,a)}let d;const h=Ub({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-l.left-l.right),Math.max(1,i[1]-l.top-l.bottom)]}),p=new jk(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&p.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const f=Yb(p,{...e,width:i[0],height:i[1],background:e.background??n.colors.background,bodyStyle:(e,t)=>({fill:n.colors.primary,stroke:n.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof r?r(e,t):r}),style:{...o,fontFamily:n.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:l,renderChrome:t=>{const o=ev(t,e,i,l,n);return d=o.annotationRender,o.node}});return t&&(t.evidence=gp({frameType:"physics",width:i[0],height:i[1],marks:f.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:d,extraWarnings:[...0===f.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...f.scene.evidence.warnings]})),f.svg}function iv(e,t={}){if("function"==typeof e)return e;const i=t.locale??"en-US";if("currency"===e){const e=t.precision??2,n=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>n.format(e)}if("percent"===e){const e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){const e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>nv(e);const n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>n.format(e)}function nv(e){if(!Number.isFinite(e))return e+"";const t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;const n=i/1e3;if(60>n)return`${t}${o=n,Math.round(100*o)/100+""}s`;var o;const r=n/60;if(60>r){const e=Math.floor(r),i=Math.round(n-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}const s=r/60;if(24>s){const e=Math.floor(s),i=Math.round(r-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}const a=Math.floor(s/24),c=Math.round(s-24*a);return 0===c?`${t}${a}d`:`${t}${a}d ${c}h`}function ov(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function rv(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let n=null;for(const t of i){if(t.at>e)break;n=t}return n}function sv(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function av(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}function cv(e,t,i){const n=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=n&&"number"==typeof n.value&&Number.isFinite(n.value)?n.value:void 0,r=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0!==r)return`${ov(r,i)}${n&&"string"==typeof n.label?" "+n.label:""}`}function lv(e,t,i){const n=e.target&&"object"==typeof e.target?e.target:void 0;if(!n||"number"!=typeof n.value||!Number.isFinite(n.value))return;const o="string"==typeof n.label?" "+n.label:"";return 0===n.value?`target ${i(n.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/n.value)} of ${i(n.value)}${o}`}function uv(e,t,i){return iI[e](t,i)}function dv(e,t,i){const{title:n,subtitle:o,theme:r,width:s=1200,height:a,layout:c={},background:l}=t,u=Yr(Wr(r)),d=c.columns||2,h=c.gap??16;let p=0;n&&(p+=30),o&&(p+=20),p>0&&(p+=10);const f=Math.floor((s-h-h*(d-1))/d),y=[];let g=0,m=p+h,x=0;for(const t of e){const e=Math.min(t.colSpan||1,d),n=f*e+h*(e-1),o=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0);const s=h/2+g*(f+h),a={...t.props,width:n,height:o,theme:r,_idPrefix:"chart-"+y.length},c=t.component?i.chart(t.component,a):t.frameType?i.frame(t.frameType,a):`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${o}"></svg>`,l=R(c,{width:n,height:o}),u=Math.max(o,l.height);y.push({x:s,y:m,width:n,height:u,svg:c,svgDimensions:l}),x=Math.max(x,u),g+=e}const b=a||m+x+h,v=y.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("g",{transform:`translate(${e.x},${e.y})`,children:/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("foreignObject",{width:e.width,height:e.height,children:/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:C(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return nI.renderToStaticMarkup(
|
|
578
578
|
/* @__PURE__ */
|
|
579
|
-
/* @__PURE__ */(0,oI.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":n||"Dashboard",style:{fontFamily:u.fontFamily},children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("title",{children:n}),l&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("rect",{x:0,y:0,width:s,height:b,fill:l}),n&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("text",{x:s/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:n}),o&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("text",{x:s/2,y:n?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}function hv(e,t){switch(e){case"xy":return cg(t);case"ordinal":return um(t);case"network":return ob(t);case"geo":return Pb(t);case"physics":return tv(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function pv(e){return cg(e)}function fv(e){return um(e)}function yv(e){return ob(e)}function gv(e){return Pb(e)}function mv(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function xv(e,t){const i=Number(e);if(!Number.isFinite(i))return e;const n=10**t,o=Math.round((i+Number.EPSILON)*n)/n;return Object.is(o,-0)?"0":o+""}function bv(e,t){const i=RegExp(aI.source,aI.flags);let n,o="",r=0,s=!1;for(;n=i.exec(e);){const i=e.slice(r,n.index);o+=s&&0===i.length?" ":i,o+=xv(n[0],t),r=n.index+n[0].length,s=!0}return o+e.slice(r)}function vv(e,t){const i=mv(t);return void 0===i?e:I(e,(e,t)=>{if(sI.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return bv(t,i)})}function wv(e,t){const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i}function kv(e,t,i){return Sv(e,t,i).svg}function Av(e,t,i){const n={},{svg:o,frameType:r}=Sv(e,t,i,n),s=n.evidence??gp({frameType:r,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});if(s.component=e,s.sceneHashVersion=2,s.sceneHash=Re(o,s),Ue(s,e,t),i?.artifactContract){const n=Me(i.artifactContract,{excludeEvidenceSamples:!0});n.contract&&(s.artifactContract=n.contract),s.artifactTransfer=n.transfer,s.artifactBinding=n.contract?.contractVersion===Pw&&"invalid"!==n.transfer.status?Le(n.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:s}}function Sv(e,t,i,n){if(Object.prototype.hasOwnProperty.call(iI,e))return{svg:vv(uv(e,t,n),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(fP,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);const o=fP[e];var r;const s=De(o.layout?.mode??("string"==typeof(r=t.mode)&&Object.prototype.hasOwnProperty.call(zw,r)?t.mode:void 0),{...o.layout?.modeDefaults,...wv(t,lI)},o.layout?.primarySize),{data:a,theme:c,background:l,className:u,annotations:d,margin:h,colorScheme:p,colorBy:f,legendPosition:y,...g}=t,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=o.layout?.margin,k="function"==typeof w?w(t,s):w??s.marginDefaults,A="xy"===o.frameType?M(k,g.axes??v.axes,!!s.title):k,S=void 0!==h?h:v.margin,_=Ke(S),$="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...A,..._},P=wv(g,cI),j=e=>v[e]??s[e],I={...v,...P,theme:c,title:s.title,description:s.description,showAxes:j("showAxes"),showLegend:j("showLegend"),showLabels:j("showLabels"),showGrid:j("showGrid"),xLabel:j("xLabel"),yLabel:j("yLabel"),categoryLabel:j("categoryLabel"),valueLabel:j("valueLabel"),background:l,className:u,annotations:d,size:b,margin:$,__compactMode:s.compactMode,__autoLegendMargin:!0,...void 0!==p&&{colorScheme:p},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=o.buildProps(a,f,p,I,g);let R;if(o.renderStatic)R=o.renderStatic(L,n);else switch(o.frameType){case"xy":R=cg(L,n);break;case"ordinal":R=um(L,n);break;case"network":R=ob(L,n);break;case"geo":R=Pb(L,n);break;case"physics":R=tv(L,n)}const C=o.renderOverlay?.(L,{theme:
|
|
579
|
+
/* @__PURE__ */(0,oI.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":n||"Dashboard",style:{fontFamily:u.fontFamily},children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("title",{children:n}),l&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("rect",{x:0,y:0,width:s,height:b,fill:l}),n&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("text",{x:s/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:n}),o&&/* @__PURE__ */ /* @__PURE__ */(0,oI.jsx)("text",{x:s/2,y:n?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}function hv(e,t){switch(e){case"xy":return cg(t);case"ordinal":return um(t);case"network":return ob(t);case"geo":return Pb(t);case"physics":return tv(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function pv(e){return cg(e)}function fv(e){return um(e)}function yv(e){return ob(e)}function gv(e){return Pb(e)}function mv(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function xv(e,t){const i=Number(e);if(!Number.isFinite(i))return e;const n=10**t,o=Math.round((i+Number.EPSILON)*n)/n;return Object.is(o,-0)?"0":o+""}function bv(e,t){const i=RegExp(aI.source,aI.flags);let n,o="",r=0,s=!1;for(;n=i.exec(e);){const i=e.slice(r,n.index);o+=s&&0===i.length?" ":i,o+=xv(n[0],t),r=n.index+n[0].length,s=!0}return o+e.slice(r)}function vv(e,t){const i=mv(t);return void 0===i?e:I(e,(e,t)=>{if(sI.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return bv(t,i)})}function wv(e,t){const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i}function kv(e,t,i){return Sv(e,t,i).svg}function Av(e,t,i){const n={},{svg:o,frameType:r}=Sv(e,t,i,n),s=n.evidence??gp({frameType:r,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});if(s.component=e,s.sceneHashVersion=2,s.sceneHash=Re(o,s),Ue(s,e,t),i?.artifactContract){const n=Me(i.artifactContract,{excludeEvidenceSamples:!0});n.contract&&(s.artifactContract=n.contract),s.artifactTransfer=n.transfer,s.artifactBinding=n.contract?.contractVersion===Pw&&"invalid"!==n.transfer.status?Le(n.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:s}}function Sv(e,t,i,n){if(Object.prototype.hasOwnProperty.call(iI,e))return{svg:vv(uv(e,t,n),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(fP,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);const o=fP[e];var r;const s=De(o.layout?.mode??("string"==typeof(r=t.mode)&&Object.prototype.hasOwnProperty.call(zw,r)?t.mode:void 0),{...o.layout?.modeDefaults,...wv(t,lI)},o.layout?.primarySize),{data:a,theme:c,background:l,className:u,annotations:d,margin:h,colorScheme:p,colorBy:f,legendPosition:y,...g}=t,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=o.layout?.margin,k="function"==typeof w?w(t,s):w??s.marginDefaults,A="xy"===o.frameType?M(k,g.axes??v.axes,!!s.title):k,S=void 0!==h?h:v.margin,_=Ke(S),$="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...A,..._},P=wv(g,cI),j=e=>v[e]??s[e],I={...v,...P,theme:c,title:s.title,description:s.description,showAxes:j("showAxes"),showLegend:j("showLegend"),showLabels:j("showLabels"),showGrid:j("showGrid"),xLabel:j("xLabel"),yLabel:j("yLabel"),categoryLabel:j("categoryLabel"),valueLabel:j("valueLabel"),background:l,className:u,annotations:d,size:b,margin:$,__compactMode:s.compactMode,__autoLegendMargin:!0,...void 0!==p&&{colorScheme:p},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=o.buildProps(a,f,p,I,g);let R;if(o.renderStatic)R=o.renderStatic(L,n);else switch(o.frameType){case"xy":R=cg(L,n);break;case"ordinal":R=um(L,n);break;case"network":R=ob(L,n);break;case"geo":R=Pb(L,n);break;case"physics":R=tv(L,n)}const C=o.renderOverlay?.(L,{theme:Wr(c)});if(null!=C){const e=qw.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,rI.jsx)(rI.Fragment,{children:C})),t=R.lastIndexOf("</svg>");R=0>t?`${R}${e}`:`${R.slice(0,t)}${e}${R.slice(t)}`}return{svg:vv(R,i?.precision),frameType:o.frameType}}async function Mv(e,t,i={}){const{background:n}=i;let o;if(o=["xy","ordinal","network","geo","physics"].includes(e)?hv(e,t):kv(e,t),n){const e=_(o),t=e?j(e,"style"):void 0;o=L(o,{style:`${t?t+";":""}background:${n}`})}const r={width:t.width||t.size?.[0]||600,height:t.height||t.size?.[1]||400},{width:s,height:a}=R(o,r),{rasterizeSVG:c}=await Promise.resolve().then(()=>(Zv(),Kv));return c(o,s,a,i)}function _v(e,t={}){return dv(e,t,{chart:kv,frame:hv})}function $v(e,t,i,n={}){const{stepSize:o,windowSize:r,frameCount:s,xExtent:a,yExtent:c,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:p}=n,f=i.width||600,y=i.height||400,g=Wr(i.theme),m={...i,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const x=o||Math.max(1,Math.ceil(t.length/(s||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=x;t.length>=e;e+=x)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);const v=/* @__PURE__ */new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=l({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=f-w.left-w.right,A=y-w.top-w.bottom,S=[];if(v)for(let n=0;b.length>n;n++){const o=b[n],s=t.slice(r?Math.max(0,o-r):0,o),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||g.colors.categorical,...p&&{decay:p}},c=new FP(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&S.push(Ev(c.scene,f,y,g,m,S.length))}else for(let n=0;b.length>n;n++){const o=b[n],s=t.slice(r?Math.max(0,o-r):0,o),l={chartType:e,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||g.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...p&&{decay:p},...u>0&&{transition:{duration:u*(1e3/d),easing:h}}},x=new O_(l);if(x.ingest({inserts:s,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;const v=x.scales?{y:x.scales.y}:void 0;if(S.push(Ov(x.scene,f,y,g,m,v,S.length)),u>0&&n>0&&x.activeTransition){const e=u*(1e3/d);for(let t=1;u>=t;t++)x.advanceTransition(x.activeTransition.startTime+t/u*e),S.push(Ov(x.scene,f,y,g,m,v,S.length))}}return S}function Pv(e,t,i={}){return t.map(t=>{try{return kv(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function jv(e,t,i,n){const o=Sy(`${e}-${t}`),r="string"==typeof i&&i.length>0?i:void 0,s="string"==typeof n&&n.length>0?n:void 0,a=r?o.titleId:void 0,c=s?o.descId:void 0;return{titleText:r,descText:s,titleId:a,descId:c,labelledBy:[a,c].filter(Boolean).join(" ")||void 0}}function Iv(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:Hy(e)||t}function Lv(e,t,i){const n=t.size??[t.width??600,t.height??400],o=Wr(t.theme),r=Yr(o),s=t.background||o.colors.background,a=t.idPrefix??"physics-gif",c=jv(a,i,t.title,t.description),{titleId:l,descId:u,labelledBy:d}=c,h=Nb(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),p=/* @__PURE__ */ /* @__PURE__ */(0,dI.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:r.fontFamily},children:[t.title&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("title",{id:l,children:t.title}),t.description&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("desc",{id:u,children:t.description}),s&&"transparent"!==s?/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("rect",{x:0,y:0,width:n[0],height:n[1],fill:s}):null,
|
|
580
580
|
/* @__PURE__ */
|
|
581
|
-
/* @__PURE__ */(0,dI.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((e,t)=>Fp(e,t,`${a}-${i}`))})]});return uI.renderToStaticMarkup(p)}function Rv(e,t={}){const{fps:i=12,frameCount:n,durationSeconds:o=2,includeInitialFrame:r=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,i)/l)),d=n??Math.max(1,Math.ceil(o*Math.max(1,i))),h=c?{...e,background:c}:e,p=new jk(e.config);e.initialSpawns?.length&&p.enqueue(e.initialSpawns,e.initialSpawnPacing);const f=[];for(r&&(p.tick(0),f.push(Lv(p,h,0)));d>f.length;){for(let e=0;u>e;e+=1)p.tick(l);f.push(Lv(p,h,f.length))}return f}function Cv(e,t){const i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Tv(e,t,i,n,o,r){if(!e||0===e.length)return null;const s=
|
|
581
|
+
/* @__PURE__ */(0,dI.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((e,t)=>Fp(e,t,`${a}-${i}`))})]});return uI.renderToStaticMarkup(p)}function Rv(e,t={}){const{fps:i=12,frameCount:n,durationSeconds:o=2,includeInitialFrame:r=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,i)/l)),d=n??Math.max(1,Math.ceil(o*Math.max(1,i))),h=c?{...e,background:c}:e,p=new jk(e.config);e.initialSpawns?.length&&p.enqueue(e.initialSpawns,e.initialSpawnPacing);const f=[];for(r&&(p.tick(0),f.push(Lv(p,h,0)));d>f.length;){for(let e=0;u>e;e+=1)p.tick(l);f.push(Lv(p,h,f.length))}return f}function Cv(e,t){const i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Tv(e,t,i,n,o,r){if(!e||0===e.length)return null;const s=Yr(n),a=[];for(let n=0;e.length>n;n++){const c=e[n];if("y-threshold"===c.type&&null!=c.value){let e=null;if(r)e=r(c.value);else if(o){const[t,n]=o,r=n-t;if(0===r)continue;e=i-(c.value-t)/r*i}if(null==e)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push(
|
|
582
582
|
/* @__PURE__ */
|
|
583
583
|
/* @__PURE__ */(0,dI.jsxs)("g",{children:[
|
|
584
584
|
/* @__PURE__ */
|
|
585
|
-
/* @__PURE__ */(0,dI.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(i-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+n))}}return a.length>0?/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)(dI.Fragment,{children:a}):null}function Ov(e,t,i,n,o,r,s=0){const a=
|
|
585
|
+
/* @__PURE__ */(0,dI.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(i-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+n))}}return a.length>0?/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)(dI.Fragment,{children:a}):null}function Ov(e,t,i,n,o,r,s=0){const a=Yr(n),c=l({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-c.left-c.right,d=i-c.top-c.bottom,h=Cv(o,n),p=o.renderMode,f=e.map((e,t)=>Bp({node:e,index:t,renderMode:p,fallback:()=>Fp(e,t)}).element).filter(Boolean),y=Tv(o.annotations,u,d,n,o.yExtent,r?.y),{titleText:g,descText:m,titleId:x,descId:b,labelledBy:v}=jv(Iv(o,"xy-gif"),s,o.title,o.description);return uI.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,dI.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:a.fontFamily},children:[g&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("title",{id:x,children:g}),m&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("desc",{id:b,children:m}),h&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("rect",{x:0,y:0,width:t,height:i,fill:h}),
|
|
586
586
|
/* @__PURE__ */
|
|
587
|
-
/* @__PURE__ */(0,dI.jsxs)("g",{transform:`translate(${c.left},${c.top})`,children:[y,f]}),g&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("text",{x:t/2,y:sw,textAnchor:"middle",fontSize:a.titleFontSize,fontWeight:a.titleFontWeight,fill:a.text,fontFamily:a.titleFontFamily,children:g})]}))}function Ev(e,t,i,n,o,r=0){const s=
|
|
587
|
+
/* @__PURE__ */(0,dI.jsxs)("g",{transform:`translate(${c.left},${c.top})`,children:[y,f]}),g&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("text",{x:t/2,y:sw,textAnchor:"middle",fontSize:a.titleFontSize,fontWeight:a.titleFontWeight,fill:a.text,fontFamily:a.titleFontFamily,children:g})]}))}function Ev(e,t,i,n,o,r=0){const s=Yr(n),a=l({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c="radial"===o.projection,u=c?a.left+(t-a.left-a.right)/2:a.left,d=c?a.top+(i-a.top-a.bottom)/2:a.top,h=Cv(o,n),p=am({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:f,descText:y,titleId:g,descId:m,labelledBy:x}=jv(Iv(o,"ordinal-gif"),r,o.title,o.description);return uI.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,dI.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[f&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("title",{id:g,children:f}),y&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("desc",{id:m,children:y}),h&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("rect",{x:0,y:0,width:t,height:i,fill:h}),
|
|
588
588
|
/* @__PURE__ */
|
|
589
|
-
/* @__PURE__ */(0,dI.jsx)("g",{transform:`translate(${u},${d})`,children:p}),f&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("text",{x:t/2,y:sw,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:f})]}))}async function Fv(e,t,i,n={}){const{fps:o=12,loop:r=!0,scale:s=1,background:a}=n,c=i.width||600,l=i.height||400,u=$v(e,t,a?{...i,background:a}:i,n);if(0===u.length)throw Error("No frames generated — check that data is not empty");return zv(u,c,l,{fps:o,loop:r,scale:s})}async function Nv(e,t={}){const{fps:i=12,loop:n=!0,scale:o=1}=t,r=e.size??[e.width??600,e.height??400],s=Rv(e,t);if(0===s.length)throw Error("No physics frames generated");return zv(s,r[0],r[1],{fps:i,loop:n,scale:o})}async function zv(...e){return(await Promise.resolve().then(()=>(ew(),Qv))).encodeSvgFramesToGif(...e)}var Dv=Object.create,Bv=Object.defineProperty,Wv=Object.getOwnPropertyDescriptor,Yv=Object.getOwnPropertyNames,qv=Object.getPrototypeOf,Xv=Object.prototype.hasOwnProperty,Gv=(e,t,i)=>function(){if(i)throw i[0];try{return e&&(t=(0,e[Yv(e)[0]])(e=0)),t}catch(e){throw i=[e],e}},Vv=(e,t)=>{for(var i in t)Bv(e,i,{get:t[i],enumerable:!0})},Hv=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of Yv(t))Xv.call(e,o)||o===i||Bv(e,o,{get:()=>t[o],enumerable:!(n=Wv(t,o))||n.enumerable});return e},Uv=(e,t,i)=>(i=null!=e?Dv(qv(e)):{},Hv(!t&&e&&e.__esModule?i:Bv(i,"default",{value:e,enumerable:!0}),e)),Kv={};Vv(Kv,{rasterizeSVG:()=>e});var Zv=Gv({"src/components/server/rasterizeSVG.ts"(){}}),Qv={};Vv(Qv,{encodeSvgFramesToGif:()=>t});var Jv,ew=Gv({"src/components/server/encodeSvgFramesToGif.ts"(){}}),tw={};Vv(tw,{generateFrameSVGs:()=>$v,generateFrameSequence:()=>Pv,generatePhysicsFrameSVGs:()=>Rv,renderChart:()=>kv,renderChartWithEvidence:()=>Av,renderDashboard:()=>_v,renderGeoToStaticSVG:()=>gv,renderNetworkToStaticSVG:()=>yv,renderOrdinalToStaticSVG:()=>fv,renderPhysicsToAnimatedGif:()=>Nv,renderToAnimatedGif:()=>Fv,renderToImage:()=>Mv,renderToStaticSVG:()=>hv,renderXYToStaticSVG:()=>pv,resolveTheme:()=>zr,serializeSvgPrecision:()=>vv,themeStyles:()=>Dr}),module.exports=(Jv=tw,Hv(Bv({},"__esModule",{value:!0}),Jv));var iw,nw=36,ow=34,rw=58,sw=22,aw=16,cw=6,lw=10,uw=22,dw=100,hw=10,pw=3,fw=12,yw=18,gw=46,mw=26,xw=22,bw=46,vw=64,ww=34,kw=70,Aw=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Sw=(e,t)=>(e>>>t|e<<32-t)>>>0,Mw=e=>Math.floor(4294967296*(e-Math.floor(e)))>>>0,[_w,$w]=/* @__PURE__ */(()=>{const e=[],t=[];for(let i=2;64>t.length;i+=1){let n=!0;for(let e=2;i>=e*e;e+=1)if(i%e===0){n=!1;break}n&&(8>e.length&&e.push(Mw(Math.sqrt(i))),t.push(Mw(Math.cbrt(i))))}return[e,t]})(),Pw="0.1",jw=/* @__PURE__ */xe({"artifact.id":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.createdAt":{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"never"},"artifact.configFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.dataFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"purpose.intents":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.communicativeAct":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.stakes":{suppliedBy:["author","import"],derivable:!1,modelMayPropose:!0,humanReview:"required"},claims:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"claims.status":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},evidence:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.source":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.fingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},time:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"time.completeness":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},reception:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},form:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},contestability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"required"},accountability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"policy-dependent"},inheritance:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"}}),Iw=["fresh","stale","unknown"],Lw=["partial","provisional","settled","unknown"],Rw=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],Cw={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:Iw},checkedAt:{},heartbeatAt:{},expiresAt:{},basis:{}},watermark:{value:{required:!0},policy:{},allowedLateness:{}},window:{start:{required:!0},end:{required:!0},status:{required:!0,values:["open","provisional","settled","reopened","corrected"]}},completeness:{status:{required:!0,values:Lw},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},Tw={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:Iw},completeness:{values:Lw}},Ow=/* @__PURE__ */new Set(["data","nodes","edges","points","areas","lines","flows","atlas","forest","circuit","edition","reading"]),Ew=44,Fw={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Ew,snap:"nearestDatum",brushHandleSize:Ew,standardControls:!1},Nw={...Fw,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},zw={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}},Dw={kind:"rank-competition"},Bw=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),Ww=globalThis,Yw=Ww[Bw]??(Ww[Bw]=/* @__PURE__ */new Map),qw=Uv(require("react-dom/server")),Xw=require("d3-interpolate"),Gw=864e5,Vw=e=>{const t=e.config,{plot:i}=e.dimensions;if(0>=i.width||0>=i.height)return{nodes:[]};const n=e=>{const i="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return i instanceof Date?i:new Date(i)},o=e=>{const i="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(i)},r=/* @__PURE__ */new Map;let s=null;for(const t of e.data){const e=n(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const i=Ze(e),a=o(t);r.set(i,(r.get(i)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??/* @__PURE__ */(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of r.values())c>e&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Xw.interpolateRgb)(u,d)(t)},p=t.gutter??2,f=t.labelInset??0,y=Math.min((i.width-f-53*p)/54,(i.height-6*p)/7);if(0>=y)return{nodes:[]};const g=new Date(Date.UTC(a,0,1)),m=g.getUTCDay(),x=new Date(g.getTime()-m*Gw),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const n=new Date(x.getTime()+(7*e+t)*Gw);if(n.getUTCFullYear()!==a)continue;const o=Ze(n),s=r.get(o),c=null==s?u:h(s);b.push({type:"rect",x:i.x+f+e*(y+p),y:i.y+t*(y+p),w:y,h:y,style:{fill:c,stroke:"none"},datum:{date:n,value:s??0}})}return{nodes:b}},Hw=Uv(require("react")),Uw=require("d3-scale"),Kw=(require("d3-interpolate"),require("react/jsx-runtime")),Zw=e=>{const t=e.config,{plot:i}=e.dimensions,n=t.fields??[];if(2>n.length||0>=i.width||0>=i.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const o=/* @__PURE__ */Object.create(null);for(const i of n){const n=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,i)?t.domains[i]:void 0;if(Array.isArray(n)&&n.length>=2&&"number"==typeof n[0]&&Number.isFinite(n[0])&&"number"==typeof n[1]&&Number.isFinite(n[1])){o[i]=[n[0],n[1]];continue}let r=1/0,s=-1/0;for(const t of e.data){const e=Number(t[i]);Number.isFinite(e)&&(r>e&&(r=e),e>s&&(s=e))}if(Number.isFinite(r)&&Number.isFinite(s))if(r===s){const e=Math.max(.01*Math.abs(r),.5);o[i]=[r-e,s+e]}else o[i]=[r,s];else o[i]=[0,1]}const r=!1!==t.showAxes,s=r?t.axisLabelPadding??24:8,a=r?18:8,c=n.map(e=>(0,Uw.scaleLinear)().domain(o[e]).range([i.y+i.height-a,i.y+s])),l=n.map((e,t)=>1===n.length?i.x+i.width/2:i.x+t/(n.length-1)*i.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,p=e.theme.semantic.primary??"#3b6cb1",f=t.dimmedOpacity??.08,y=t.highlightFn,g=[],m=[];for(const i of e.data){const o=u?e.resolveColor(u(i)+""):p,r=!y||y(i),s=et(i,{predicate:y,baseOpacity:d,dimOpacity:f,brighten:.4}),a=r?m:g;for(let e=0;n.length-1>e;e++){const t=Number(i[n[e]]),u=Number(i[n[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:o,strokeWidth:y&&r?h+.75:h,opacity:s,fill:"none"},datum:i};a.push(d)}if(t.showPoints)for(let e=0;n.length>e;e++){const t=Number(i[n[e]]);if(!Number.isFinite(t))continue;const r={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:o,stroke:"none",opacity:Math.min(1,s+.3)},datum:i};a.push(r)}}let x=null;if(r){const r=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=i.y+s,p=i.y+i.height-a,f=[];for(let e=0;n.length>e;e++){const a=n[e],y=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,m="function"==typeof g?g:e=>e.toLocaleString();f.push(Hw.createElement("line",{key:"pc-axis-line-"+e,x1:y,x2:y,y1:h,y2:p,stroke:r,strokeWidth:1})),f.push(it({keyId:"pc-axis-label-"+e,text:a,x:y,y:i.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=o[a],v=5;for(let t=0;v>t;t++){const i=x+(b-x)*t/(v-1),n=c[e](i);f.push(Hw.createElement("line",{key:`pc-tick-${e}-${t}`,x1:y-3,x2:y+3,y1:n,y2:n,stroke:r,strokeWidth:1}),it({keyId:`pc-ticktext-${e}-${t}`,text:m(i),x:y+6,y:n+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Hw.createElement(Hw.Fragment,null,...f)}return{nodes:g.concat(m),overlays:x}},Qw={frameType:"xy",buildProps:(e,t,i,n,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...n,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:n.showLegend??!!t})},Jw={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...n,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},ek={frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,n,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...n})},tk={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({...Jw.buildProps(e,t,i,n,o),customLayout:Zw,showAxes:!1})},ik={frameType:"xy",buildProps:(e,t,i,n,o)=>({...Qw.buildProps(e,t,i,n,o),customLayout:Vw,showAxes:!1})},nk=Uv(require("react")),ok=require("d3-scale"),rk={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},sk=1e-9,ak=.005,ck=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=/* @__PURE__ */new Map,this.colliders=/* @__PURE__ */new Map,this.springs=/* @__PURE__ */new Map,this.activeSensors=/* @__PURE__ */new Set,this.supportedThisStep=/* @__PURE__ */new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...rk,...e},this.random=Mt(this.options.seed)}init(e={}){this.options={...rk,...e},this.random=Mt(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(sk,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:$t(e.fixedPosition)}:{},shape:jt(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};_t(t),this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Ht(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:It(t.shape),bodyFilter:Rt(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,i){const n=this.bodies.get(e);n&&(n.vx+=t/n.mass,n.vy+=i/n.mass,_t(n),this.wake(n))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const i=this.sortedBodies();for(const e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const n=this.options.maxVelocity;for(const e of i)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,_t(e),n>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>n){const i=n/t;e.vx*=i,e.vy*=i}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const o=this.bodyPairKeys(i),r=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(i,o,0===e),this.resolveColliders(i,r,0===e);this.updateSensors(i),this.updateSleeping(i,t)}settle(e=1200,t=this.options.fixedDt){let i=0;for(;e>i&&!this.allSleeping();)this.step(t),i+=1;return i}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,...t.fixedPosition?{fixedPosition:$t(t.fixedPosition)}:{},shape:jt(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Ht)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Lt),colliders:this.sortedColliders().map(Ct),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=Mt(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Lt(t);_t(e),this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Ct(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const i=this.bodies.get(t.bodyId);if(!i||i.sleeping)continue;const n="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!n)continue;const o=n.x-i.x,r=n.y-i.y,s=Math.sqrt(o*o+r*r);if(sk>=s)continue;const a=o/s,c=r/s,l=(s-t.restLength)*t.stiffness+((("vx"in n?n.vx:0)-i.vx)*a+(("vy"in n?n.vy:0)-i.vy)*c)*t.damping;i.vx+=l*a*e/i.mass,i.vy+=l*c*e/i.mass}}resolveBodyPairs(e,t,i){for(const n of t){const[t,o]=n.split(":").map(Number),r=e[t],s=e[o];if(!r||!s)continue;const a=Xt(r,s);a&&(this.resolveDynamicCollision(r,s,a),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),i=/* @__PURE__ */new Map;for(let n=0;e.length>n;n+=1){if(!1===e[n].bodyCollisions)continue;const o=Nt(e[n]),r=Math.floor(o.minX/t),s=Math.floor(o.maxX/t),a=Math.floor(o.minY/t),c=Math.floor(o.maxY/t);for(let e=r;s>=e;e+=1)for(let t=a;c>=t;t+=1){const o=`${e}:${t}`,r=i.get(o);r?r.push(n):i.set(o,[n])}}const n=/* @__PURE__ */new Set;for(const t of Array.from(i.keys()).sort()){const o=i.get(t)??[];o.sort((e,t)=>e-t);for(let t=0;o.length>t;t+=1)for(let i=t+1;o.length>i;i+=1){const r=o[t],s=o[i];!1!==e[r].bodyCollisions&&!1!==e[s].bodyCollisions&&Dt(Nt(e[r]),Nt(e[s]))&&n.add(`${r}:${s}`)}}return Array.from(n).sort((e,t)=>{const[i,n]=e.split(":").map(Number),[o,r]=t.split(":").map(Number);return i===o?n-r:i-o})}resolveDynamicCollision(e,t,i){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?!e.sleeping&&null==e.fixedPosition?.y||!t.sleeping&&null==t.fixedPosition?.y||(i=Pt(e,t,"y")):i=Pt(e,t,"x")),e.sleeping&&this.contactOpposesGravity(i.nx,i.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-i.nx,-i.ny)&&this.supportedThisStep.add(e.id);const n=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,r=null==e.fixedPosition?.x?n:0,s=null==e.fixedPosition?.y?n:0,a=null==t.fixedPosition?.x?o:0,c=null==t.fixedPosition?.y?o:0,l=e.fixedPosition||t.fixedPosition?i.nx**2*(r+a)+i.ny**2*(s+c):n+o;if(sk>=l)return;const u=Math.max(0,i.penetration-ak)/l;e.x-=i.nx*u*r,e.y-=i.ny*u*s,t.x+=i.nx*u*a,t.y+=i.ny*u*c;const d=(t.vx-e.vx)*i.nx+(t.vy-e.vy)*i.ny;if(d>0)return;const h=Math.abs(d),p=-(1+Ot(e.restitution,t.restitution,this.options.restitution))*d/l,f=p*i.nx,y=p*i.ny;e.vx-=f*r,e.vy-=y*s,t.vx+=f*a,t.vy+=y*c,this.applyFriction(e,t,i,p,n,o),h>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,i,n,o,r){const s=-i.ny,a=i.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=null==e.fixedPosition?.x?o:0,u=null==e.fixedPosition?.y?o:0,d=null==t.fixedPosition?.x?r:0,h=null==t.fixedPosition?.y?r:0,p=e.fixedPosition||t.fixedPosition?s**2*(l+d)+a**2*(u+h):o+r;if(sk>=Math.abs(c)||sk>=p)return;const f=Et(e.friction,t.friction,this.options.friction),y=Tt(-c/p,-n*f,n*f),g=y*s,m=y*a;e.vx-=g*l,e.vy-=m*u,t.vx+=g*d,t.vy+=m*h}resolveColliders(e,t,i){for(const n of e)for(const e of t){if(!Qt(e,n))continue;if(!Dt(Nt(n),zt(e)))continue;const t=Gt(n,e);t&&(this.resolveStaticCollision(n,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(n.id),i&&this.lastEvents.push({type:"contact",bodyId:n.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,i){e.x+=i.nx*Math.max(0,i.penetration-ak),e.y+=i.ny*Math.max(0,i.penetration-ak);const n=e.vx*i.nx+e.vy*i.ny;if(0>n){const o=Ot(e.restitution,t.restitution,this.options.restitution);e.vx-=(1+o)*n*i.nx,e.vy-=(1+o)*n*i.ny;const r=-i.ny,s=i.nx,a=e.vx*r+e.vy*s,c=Et(e.friction,t.friction,this.options.friction);e.vx-=a*r*c,e.vy-=a*s*c}_t(e)}updateSensors(e){const t=/* @__PURE__ */new Set,i=this.sortedColliders().filter(e=>e.sensor);for(const n of e){const e=Nt(n);for(const o of i){if(!Qt(o,n))continue;if(!Dt(e,zt(o)))continue;if(!Gt(n,o))continue;const i=Vt(o.id,n.id);t.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:n.id,sensorId:o.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:i,bodyId:n}=Ht(e);this.lastEvents.push({type:"sensor-exit",bodyId:n,sensorId:i})}this.activeSensors=t}updateSleeping(e,t){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const n of e)Math.sqrt(n.vx*n.vx+n.vy*n.vy)>=this.options.sleepSpeed||Math.sqrt((n.x-n.prevX)*(n.x-n.prevX)+(n.y-n.prevY)*(n.y-n.prevY))>=this.options.sleepSpeed*t||i&&!this.supportedThisStep.has(n.id)?n.sleeping?this.wake(n):n.sleepTime=0:(n.sleepTime+=t,n.sleeping||this.options.sleepAfter>n.sleepTime||(n.sleeping=!0,n.vx=0,n.vy=0,this.lastEvents.push({type:"sleep",bodyId:n.id})))}contactOpposesGravity(e,t){const{x:i,y:n}=this.options.gravity,o=Math.hypot(i,n);return 1e-9>=o||-.2>(e*i+t*n)/o}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},lk=class{constructor(e={}){this.id="builtin",this.capabilities={...(new ck).capabilities,engine:"builtin"},this.world=new ck(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}},uk=["binId","targetBin","category","windowIndex","lane","group"],dk=class{constructor(e=!1){this.bins=/* @__PURE__ */new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const i=ai(ri(this.config.binAccessor,e,t))??ci(e),n=ai(ri(this.config.labelAccessor,e,t))??i,o=si(this.config.valueAccessor,e,t),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(i);return s||(s={id:i,label:n,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,s)),s.label=n,s.lastBodyId=e.id,s.lastDatum=e.datum,ti(s.x,e.x),ti(s.y,e.y),ti(s.value,o),r>0&&(s.bodyIds.push(e.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),li(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(li)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:ni(t.x),y:ni(t.y),value:ni(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}},hk={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},pk={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},fk={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},yk=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Li({kind:"initialize"},[],this.revisions),this.listeners=/* @__PURE__ */new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const i=Li(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(const e of[...this.listeners])e();return i}},gk=require("d3-quadtree"),mk=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,i,n,o,r=0,s){const a=this.ensure(e,t);if(!a)return null;let c=null,l=1/0;const u=Math.max(0,s?.searchRadius??Math.max(0,r)+this.maxSearchRadius),d=n-u,h=n+u,p=o-u,f=o+u;return a.visit((e,t,a,u,y)=>{if(d>u||t>h||p>y||a>f)return!0;if(e.length)return!1;let g=e;for(;g;){const e=g.data;if(e&&(!s?.include||s.include(e))){const t=s?.distanceSquared?s.distanceSquared(e,n,o):_i(e,n,o,Math.max(0,r));null!=t&&(l>t||t===l&&i.indexOf(e.id)>i.indexOf(c?.id??""))&&(c=e,l=t)}g=g.next}return!1}),c}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const i=e.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=i.reduce((e,t)=>Math.max(e,Mi(t)),0),this.tree=(0,gk.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},xk=["data","scene-geometry","data-paint","accessibility","evidence"],bk=["scene-geometry","data-paint","accessibility","evidence"],vk=["overlay","accessibility","evidence"],wk=(e,t)=>({retainedData:e,invalidations:t}),kk=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ak=["scene-geometry","data-paint","accessibility","evidence"],Sk=[],Mk={engine:wk("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:wk("preserve",Ak),colliders:wk("preserve",Ak),sediment:wk("preserve",Ak),bodyBudget:wk("preserve",kk),bodyLimit:wk("preserve",kk),eviction:wk("preserve",kk),fixedDt:wk("preserve",Sk),maxDeltaSeconds:wk("preserve",Sk),maxSubsteps:wk("preserve",Sk),settleStepLimit:wk("preserve",Sk),timeScale:wk("preserve",Sk),observation:wk("preserve",Sk)},_k=wk("preserve",kk),$k=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],Pk=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=qi(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,i){if(i>0)return void(this.seconds=0);const n=e.readState(this.scratch),o=this.speed*this.speed;let r=!0;for(const e of n)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=o){r=!1;break}this.seconds=r?this.seconds+Math.max(0,t):0}},jk=class{constructor(e={}){this.activeSensorPairs=/* @__PURE__ */new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new mk,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new yk,this.simulationState="settled",this.visible=!0,this.quiescence=new Pk;const{bodyBudget:t,colliders:i,engine:n,kernel:o,observation:r,sediment:s,...a}=e;this.config={...hk,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=n,this.observation=fi(r),this.sediment=new dk(s??!1),this.world=ei(n,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),i&&this.world.setColliders(wi(i))}updateConfig(e){const t=Ti(e,this.configInput),{colliders:i,bodyBudget:n,engine:o,kernel:r,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==n&&(this.bodyBudget=n,!1===n&&(this.bodyBudgetObservationKey="ok")),o&&o!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=o,this.world=ei(o,e.options),this.world.restore(e),this.revision+=1}if(r&&!Ci(r,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...r,gravity:{...e.options.gravity,...r.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}s&&(this.observation=fi(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(wi(i)),this.revision+=1),this.configInput={...this.configInput,...e};const l=Ri(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(wi(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Ri(["colliders"]).invalidations)}enqueue(e,t){const i=Array.isArray(e)?e:[e],n=t?bi(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(const e of n)this.queue.push({...yi(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Ai),n.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:n.length},n.length?xk:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(yi(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},xk)}materializeDueSpawns(){const e=this.revision,t=[],i=[];return this.spawnDue(t,i),0===t.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?xk:[])),t}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},xk)}tick(e,t){const i=this.revision,n=[],o=[],r=[],s=[],a=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,s,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const c=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(n,a);const l=this.observeBodyBudget(a),u=this.evictOverflow(a);o.push(...u.evicted),r.push(...u.sedimented),this.syncSimulationState(a),n.length>0&&this.quiescence.reset(),this.accumulator+=c;const d=this.stepObserver(t,{spawned:n,evicted:o,sedimented:r,events:s,observations:a}),h=c>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:p,budget:f}=Gi(this.settleHost(),Math.min(h,this.config.maxSubsteps),{spawned:n,evicted:o,sedimented:r,events:s,observations:a},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:d});this.accumulator=Math.max(0,this.accumulator-p*this.config.fixedDt),p===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(p>0||n.length>0||o.length>0||r.length>0||s.length>0)&&(this.revision+=1);const y=this.result(p,n,o,r,s,a,void 0,f??l);return this.updateResults.record({kind:"tick",count:p},this.revision!==i?n.length||o.length||r.length?xk:bk:[]),y}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit,t){return this.runSettle(e,!0,t)}stepObserver(e,t){return Xi(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,i){const n=this.revision,o=[],r=[],s=[],a=[],c=t?[]:void 0;if(t&&(this.paused||!this.visible)){const e=this.result(0,o,r,s,a,c??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,c);const l=this.observeBodyBudget(c),u=this.evictOverflow(c);r.push(...u.evicted),s.push(...u.sedimented),this.syncSimulationState(c),o.length>0&&this.quiescence.reset();const d=t?{spawned:o,evicted:r,sedimented:s,events:a,observations:c}:{spawned:o},h=this.stepObserver(i,{spawned:o,evicted:r,sedimented:s,events:a,observations:c??[]}),{steps:p,budget:f}=Gi(this.settleHost(),e,d,{afterStep:h,continueWhile:i?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0}),y=o.length+r.length+s.length>0;(p>0||y||a.length>0)&&(this.revision+=1);const g=this.result(p,o,r,s,a,c??[],void 0,f??l);return this.updateResults.record({kind:"settle",count:p},this.revision===n?[]:y?xk:bk),g}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return ui(this.readSediment(),e)}hitTest(e,t,i=0,n){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,i,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:i,chartId:n,...o}=e,r={...o,timestamp:t??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:n??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?vk:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?vk:[])}remove(e){const t=new Set(e),i=new Set(this.liveBodyOrder),n=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const o=e.filter(e=>i.has(e)||n.has(e));return o.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:o,count:o.length},o.length?xk:[]),o}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},bk),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},bk)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},bk)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,i,n)=>e.applyImpulse(t,i,n),clear:()=>e.clear(),hitTest:(t,i,n)=>e.hitTest(t,i,n),pause:()=>e.setPaused(!0),push:(t,i)=>e.enqueue(t,i),pushMany:(t,i)=>e.enqueue(t,i),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:ki(this.bodyBudget),config:{...this.config,kernel:Si(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(vi),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){const t=this.simulationState;this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:ki(e.bodyBudget??{}),kernel:Si(e.world.options)},this.bodyBudget=ki(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(vi).sort(Ai),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Ni(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},xk),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds+1e-9*this.config.fixedDt>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,t),e.push(i.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(/* @__PURE__ */new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const i=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:i?.datum??e.datum,x:i?.x??e.x,y:i?.y??e.y},t)}result(e,t,i,n,o,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:o,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:c,sedimented:n,spawned:t,steps:e}}observeKernelEvents(e,t){Oi(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=Ei(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){Fi(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return pi({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const i=`${t.state}:${t.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,Di(t,this.observationContext(e))),t}syncSimulationState(e){const t=Ni(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const i=this.simulationState;this.simulationState=t,zi(i,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:i,liveBodyOrder:n}=Yi(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=n,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:i}}},Ik=require("d3-scale"),Lk=require("d3-scale"),Rk=require("d3-scale"),Ck=require("d3-scale"),Tk=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Ok=Tn(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Ek=Tn(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Fk=Tn(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Nk=Tn(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),zk=Tn(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Dk=Tn(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Bk=Tn(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Wk=Tn(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Yk=Tn(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),qk=Tn(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Xk=Tn(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Gk=Tn(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Vk={blues:Ok,reds:Ek,greens:Fk,viridis:Bk,oranges:Nk,purples:zk,greys:Dk,plasma:Wk,inferno:Yk,magma:qk,cividis:Xk,turbo:Gk},Hk=Tn(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Uk=Tn(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Kk=Tn(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Zk=Tn(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Qk=Tn(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Jk=Tn(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),eA=Tn(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),tA={category10:Tk,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Vk},iA=Tk,nA="#007bff",oA=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],rA=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],sA=/* @__PURE__ */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"]),aA={left:28,top:76,rightInset:30,thickness:8},cA=1e-9,lA=[900,520],uA=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],dA=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),hA=1e-9,pA=gr,fA=Uv(require("react")),yA=require("react/jsx-runtime"),gA=require("d3-shape"),mA=require("react/jsx-runtime"),xA=require("react/jsx-runtime"),bA="var(--semiotic-text, #26323a)",vA="var(--semiotic-text-secondary, #6c7377)",wA="var(--semiotic-primary, #b8792d)",kA="var(--semiotic-danger, #9f3d35)",AA="var(--semiotic-success, #356b63)",SA=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],MA={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:12}},_A={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:12}},$A={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:SA,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"},PA={light:MA,dark:_A,"high-contrast":$A,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},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:12},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:"#64717f",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:12},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:12},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:12},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:12},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:12,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:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},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:"#c63b3b",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:12,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:12},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:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},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:12},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:12},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:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}},jA=require("react/jsx-runtime"),IA=require("react/jsx-runtime"),LA={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},RA=require("react/jsx-runtime"),CA=require("react/jsx-runtime"),TA=require("react/jsx-runtime"),OA={margin:(e,t)=>t.compactMode?"sparkline"===e.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}},EA=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],FA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s=o.bins??21,a=o.seed??1,c=Math.max(1,Math.round(o.pegRows??s-1)),l="mechanical"===(o.simulationMode??o.mode),u=Vi({data:l?At({bins:s,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],valueAccessor:o.valueAccessor||"value",bins:s,ballRadius:o.ballRadius??("sparkline"===o.mode?1.5:"context"===o.mode?4:6),seed:a,size:r,valueExtent:l?[0,c]:o.valueExtent});return{...n,config:u.config,initialSpawns:as(u.initialSpawns),projectionRows:u.projectionRows,foregroundGraphics:cs(Br(u.projectionRows,s,ls(n,o,"showProjection"),u.metadata,o.referenceLines),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},NA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s=Qi({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:r,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...n,config:s.config,initialSpawns:as(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:cs(Wr(s.projectionRows,s.metadata,ls(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},zA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s="mechanical"===(o.simulationMode??o.mode),a=rn({data:s?tn({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(s?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:r});return{...n,config:a.config,initialSpawns:as(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:cs(Yr(a.projectionRows,o.ballRadius??8,ls(n,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},DA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,360],s=an({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:r,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...n,config:s.config,initialSpawns:as(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:cs(Xr(s.metadata,ls(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},BA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,420],s=Array.isArray(o.stages)?o.stages:[],a=Ln({data:Array.isArray(e)?e:[],stages:s,size:r,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),c=a.metadata;return{...n,config:a.config,initialSpawns:as(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,backgroundGraphics:cs(Jr(a.metadata,ls(n,o,"showChrome"),{},o.chromeOptions),n.backgroundGraphics),foregroundGraphics:cs(es(a.projectionRows,a.metadata,ls(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},WA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=uo({data:Array.isArray(e)?e:[],size:r,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...n,config:s.config,initialSpawns:as(s.initialSpawns),projectionRows:[],backgroundGraphics:cs(ls(n,o,"showChrome")?nk.createElement(os,{layout:s.layout,states:s.states,compact:!0===n.__compactMode}):void 0,n.backgroundGraphics),foregroundGraphics:cs(ls(n,o,"showProjection")?nk.createElement(ss,{layout:s.layout,states:s.states}):void 0,n.foregroundGraphics),bodyStyle:ft(t||o.colorBy)}}},YA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=wr({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:r,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),a=vr(s,"snapshot"===o.playback?br(s,o.snapshotAt):s.duration).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},l=Do(a,c),u=c.measure??"count",d=Er(l.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===u||"amount"===u?e.amount:Number(e.metrics[u]??0),secondaryLabel:"count"===u||"amount"===u?o.amountLabel??"amount":u,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),h={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},p=t??o.colorBy??"category",f=!1===o.showChrome?null:nk.createElement(Rr,{layout:s.layout,phases:s.phases,state:a,compact:520>r[0]||360>r[1]}),y=!1===o.showProjection?null:nk.createElement(Tr,{rows:l,layout:s.layout,projection:c,amountLabel:o.amountLabel});return{...n,config:s.config,initialSpawns:as(gr(a,s.layout,h)),projectionRows:d,bodyStyle:e=>ds(e,a,p,o),getBodyLabel:e=>hs(e,a),renderBodySVG:Ir,backgroundGraphics:cs(f,n.backgroundGraphics),foregroundGraphics:cs(y,n.foregroundGraphics)}}},qA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[760,420],s=fn({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:r});return{...n,config:s.config,initialSpawns:as(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:cs(is(s.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||"source")}}},XA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[700,380],s=zr(n.theme),a=Hn({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Fr(s)??{},size:r,themeCategorical:s.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...n,config:a.config,initialSpawns:as(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??ft(t||o.colorBy),backgroundGraphics:cs(n.backgroundGraphics,a.result.backgroundOverlays),foregroundGraphics:cs(n.foregroundGraphics,a.result.overlays)}}},GA=(e,t,i)=>({x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}),VA=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),HA={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},UA=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,KA=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),ZA=e=>{const t=e.config.braid,i=e.dimensions.plot,n=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],o=t.groups.filter(e=>n.includes(e.partition)&&e.nodePath.length>0),r=[],s=[],a=[];if(0===o.length)return{sceneNodes:s,sceneEdges:r,labels:a};const c=new Set(o.map(e=>e.signature)),l=[...t.signatureOrder.filter(e=>c.delete(e)),...c],u=new Map(l.map((e,t)=>[e,t])),d=[...o].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=n.map(e=>d.filter(t=>t.partition===e)),p=Os(d),f=Ps(p.map(e=>e.depth)),y=o.map(e=>Ps(e.stepEntityCounts??[e.entityCount])),g=Ps(y),m=e=>e>0?Math.max(1,10*e/g):0,x=new Map(o.map((e,t)=>[e.id,m(y[t])])),b=i.height/n.length,{semantic:v}=e.theme,w=(e,t,i,n={})=>a.push({x:e,y:t,text:i,fill:v.text??"#333",fontSize:10,anchor:"middle",...n}),k={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},A=new Map(p.map(e=>{const t=h.map(t=>t.reduce((t,i)=>t+(e.signatures.has(i.signature)?x.get(i.id)+3:0),5));return[e.id,Ps(t,24)]})),S=Ps([...A.values()],24),M=Math.min(i.width/4,S/2+16),_=(i.width-2*M)/Math.max(f-1,1),$=e=>i.x+M+(e-1)*_,P=48+S/2,j=22+S/2,I=(e,t)=>e+P+(u.get(t)+.5)*Math.max(0,b-P-j)/l.length,L=(t,i,n,o,s)=>{const a=UA(i,o),c=UA(i,s),l=m(a),u=m(c);if(0===l&&0===u)return;const d=l!==u,h=e.resolveColor(i.signature);r.push({type:"curved",id:n,pathD:d?Rs(t,l,u):Is(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:l},datum:{...k,id:n,kind:"braid-track",nodeId:i.nodePath[s],fromNodeId:i.nodePath[o],groupId:i.id,signature:i.signature,partition:i.partition,entityCount:i.entityCount,fromStep:o,toStep:s,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:i.nodePath.join(" → "),partition:i.partition??"all",fromStep:o+1,toStep:s+1,fromCount:a,toCount:c}})};return n.forEach((e,t)=>{const n=i.y+t*b,o=h[t];if(e&&w(i.x+8,n+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===o.length)return;for(let e=1;f>=e;e++)w($(e),n+34,"Step "+e);const r=/* @__PURE__ */new Map;for(const t of p){const i=o.filter(e=>t.signatures.has(e.signature));if(0===i.length)continue;const a=$(t.depth),c=tt([...t.signatures].map(e=>I(n,e))),l=Cs(i.map(e=>x.get(e.id)));r.set(t.id,new Map(i.map((e,t)=>[e.id,{x:a,y:c+l[t],offset:l[t]}])));const u=A.get(t.id),d={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;s.push({type:"glyph",id:h,cx:a,cy:c,size:u,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:HA,accent:v.border??"#888",style:{fill:v.surface??"#fff"},datum:{...k,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),w(a,c+u/2+12,t.state)}for(const t of o){const i=Ts(t.signature);for(let n=1;i.length>n;n++){const o=r.get(i[n-1]).get(t.id),s=r.get(i[n]).get(t.id),a=(o.x+s.x)/2-Math.sign(s.y-o.y)*s.offset;L(1e-8>Math.abs(o.y-s.y)?[o,s]:[o,{x:a,y:o.y},{x:a,y:s.y},s],t,`step:${e??"all"}:${i[n]}:${t.id}`,n-1,n)}}}),{sceneNodes:s,sceneEdges:r,labels:a,restyle:KA,restyleEdge:KA}},QA=Uv(require("react")),JA=e=>{const{forest:t,selection:i,reading:n="organize"}=e.config,{atlas:o}=t,r=e.dimensions.plot,s=e.theme.semantic.text??"#273442",a=e.config.colors?.backbone??e.theme.semantic.textSecondary??"#8995a3",c=e.config.colors?.residual??e.theme.semantic.warning??"#b66631",l=e.config.colors?.required??e.theme.semantic.primary??"#3983a5",u=i?.analysisRevision===o.analysisRevision&&"directed-admitted"===i.relationScopeId&&o.source.nodes.some(e=>e.id===i.nodeId)?i.nodeId:void 0,d=/* @__PURE__ */new Map;for(const i of t.order)if(e.config.collapsedNodeIds?.includes(i)&&!d.has(i))for(const e of Es(t,i))e!==i&&d.set(e,i);const h=t.order.filter(e=>!d.has(e)),p=new Map(o.source.nodes.map(e=>[e.id,e])),f=/* @__PURE__ */new Map;for(const e of d.values())f.set(e,(f.get(e)??0)+1);const y=/* @__PURE__ */new Map;for(const e of o.source.edges){const t=d.get(e.source)??e.source;if(t===(d.get(e.target)??e.target)&&(e.source!==t||e.target!==t)){const i=y.get(t);i?i.push(e.id):y.set(t,[e.id])}}const g=[...o.sections.sectionIds];o.source.nodes.some(e=>!e.sectionId)&&g.push("Unsectioned");const m=new Map(o.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),x=g.map(e=>h.filter(t=>m.get(t)===e)),b=/* @__PURE__ */new Map,v=[],w=[],k=[],A=[],S=(e,t,i,n=11)=>v.push({x:e,y:t,text:i,fill:s,anchor:"middle",fontSize:n}),M=Math.max(16,Math.min(94,r.width/Math.max(1,g.length)-20));x.forEach((e,t)=>{const i=r.x+r.width*(t+.5)/g.length;S(i,r.y+18,g[t],12),e.forEach((t,n)=>{b.set(t,{x:i,y:r.y+58+(n+.5)*Math.max(40,r.height-110)/Math.max(1,e.length)})})});for(const t of h){const i=b.get(t),n=p.get(t),r=f.get(t)??0,s=y.get(t)??[],d=o.requiredPaths?.unreachableNodeIds.includes(t),h=n.completeness&&"known"!==n.completeness,g=h?"Unknown upstream":d?"Unreachable from roots":void 0;w.push({type:"glyph",id:t,cx:i.x,cy:i.y,size:34,glyph:{viewBox:[M,34],parts:[{d:`M6,0 H${M-6} Q${M},0 ${M},6 V28 Q${M},34 ${M-6},34 H6 Q0,34 0,28 V6 Q0,0 6,0 Z`,stroke:"accent"}]},accent:u===t?l:h?c:a,style:{fill:e.theme.semantic.surface??"#fff",strokeWidth:u===t?2.5:1},label:t,datum:{...n,nodeId:t,kind:"dependency-node",sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",hiddenCount:r,internalEdgeIds:s},accessibleDatum:{node:t,section:m.get(t),status:g??"Admitted",hiddenCount:r,internalEdges:s.join(", ")}}),S(i.x,i.y+4,r?`${t} +${r}`:t,12),g?S(i.x,i.y+30,g,9):r&&S(i.x,i.y+30,s.length+" internal links",9)}const _=new Set(t.forest.backboneEdgeIds),$=new Set(e.config.highlightedEdgeIds),P=/* @__PURE__ */new Map;for(const e of o.source.edges){const t=d.get(e.source)??e.source,i=d.get(e.target)??e.target;if(t===i&&(e.source!==t||e.target!==i))continue;const n=b.get(t),s=b.get(i),u=JSON.stringify([t,i]),h=12*(P.get(u)??0);P.set(u,(P.get(u)??0)+1);const p=_.has(e.id),f=$.has(e.id)?l:p?a:c,y=s.x>n.x,m=n.x+(y?M/2:-M/2),x=s.x+(y?-M/2:M/2),v=[...b.values()].filter(e=>e.x>Math.min(n.x,s.x)&&Math.max(n.x,s.x)>e.x);let w,S;if(t===i)w=`M${n.x-14},${n.y-17} C${n.x-35-h},${n.y-64-h} ${n.x+35+h},${n.y-64-h} ${n.x+14},${n.y-17}`,S=1;else if(n.x===s.x){const e=s.y>n.y?1:-1,t=n.x+e*M/2,i=t+e*(32+h);w=`M${t},${n.y} C${i},${n.y} ${i},${s.y} ${t},${s.y}`,S=1===e?2:0}else if(v.length){const e=Math.min(n.y,s.y,...v.map(e=>e.y))-17-26-h,t=(r.width/g.length-M)/2*(y?1:-1);w=`M${m},${n.y} C${m+t},${n.y} ${m},${e} ${m+t},${e} H${x-t} C${x},${e} ${x-t},${s.y} ${x},${s.y}`,S=y?0:2}else if(y){const e=(m+x)/2;w=`M${m},${n.y} C${e},${n.y-h} ${e},${s.y-h} ${x},${s.y}`,S=0}else{const e=Math.min(n.y,s.y)-48-h;w=`M${m},${n.y} C${m-25},${e} ${x+25},${e} ${x},${s.y}`,S=2}k.push({type:"curved",id:e.id,pathD:w,style:{stroke:f,strokeWidth:$.has(e.id)?3:p?1.3:2,fill:"none"},datum:{...e,sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",kind:"dependency-edge",edgeClass:p?"backbone":"residual"},accessibleDatum:{edge:e.id,source:e.source,target:e.target,display:p?"backbone":"residual cross-link"}}),A.push(QA.createElement("path",{key:"arrow:"+e.id,"data-dependency-edge":e.id,"data-source":e.source,"data-target":e.target,d:"M-6,-3 L0,0 L-6,3",fill:"none",stroke:f,transform:`translate(${t===i?n.x+14:n.x===s.x?n.x+(s.y>n.y?M/2:-M/2):x},${t===i?n.y-17:s.y}) rotate(${90*S})`}))}if("required-paths"===n&&u){const e=Fs(t,u),i=[...new Set(e.map(e=>d.get(e)??e))].filter(e=>e!==u&&b.has(e));if(i.length){const e=i.map(e=>b.get(e)),t=Math.max(...e.map(e=>e.x))+M/2+8,n=Math.min(...e.map(e=>e.y))-23,o=Math.max(...e.map(e=>e.y))+23;A.push(QA.createElement("path",{key:"required-bracket",d:`M${t-7},${n} H${t} V${o} H${t-7}`,fill:"none",stroke:l,strokeWidth:2,"data-kind":"dominator-bracket"}))}S(r.x+r.width/2,r.y+r.height-16,e.length?`${u} lies on all admitted paths to ${e.join(", ")}${"incomplete"===o.requiredPaths?.status?" · incomplete scope":""}`:o.requiredPaths?u+": no other required targets in the admitted graph":"Required paths have not been prepared")}const j=new Map(w.map(e=>[e.id,e.datum]));return{sceneNodes:w,sceneEdges:k,labels:v,restyle:(e,t)=>({opacity:t?.isActive&&!t.predicate(e.datum)?.2:1}),restyleEdge:(e,t)=>({opacity:t?.isActive&&![e.datum,j.get(e.datum?.source+""),j.get(e.datum?.target+"")].some(e=>e&&t.predicate(e))?.2:1}),overlays:QA.createElement("g",{"aria-hidden":!0},A)}},eS=Uv(require("react")),tS=Uv(require("react")).createElement,iS={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"},nS=e=>null===e?"unmeasured":1e6>e?1e3>e?e+"":Number((e/1e3).toFixed(1))+"k":Number((e/1e6).toFixed(2))+"m",oS={stage:"M-5,0 H5",distributor:"M-5,0 H0 M0,0 L6,-5 M0,0 H6 M0,0 L6,5",queue:"M-6,-5 V5 H6 V-5 M-3,2 H3",retry:"M-5,2 A5,5 0 1,1 4,3 M4,-1 V4 H0","join-all":"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M2,-5 V5",selector:"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M1,-4 L5,0 L1,4",dependency:"M-5,-5 H5 V5 H-5 Z M-2,-2 L2,2 M-2,2 L2,-2",junction:"M0,-6 L6,0 L0,6 L-6,0 Z"},rS={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"},sS=e=>null===e?"unmeasured":e+"",aS=eS.createElement,cS=e=>{const{circuit:t,edition:i,reading:n,selection:o}=e.config;if(n.editionId!==i.id||i.analysisRevision!==t.atlas.analysisRevision)throw Error("Circuit render inputs must share an edition and analysis revision");const r=Ns(t,e.dimensions.width,e.dimensions.height),s=e.theme.semantic.text??"#273442",a=e.theme.semantic.surface??"#fff",c=Ds(e.theme.semantic,e.config.colors),l="modeled"===i.kind?c.modeled:c.observed,u={width:r.width,height:r.height,viewBox:`0 0 ${r.width} ${r.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":!0},d=o?.analysisRevision===t.atlas.analysisRevision&&"directed-admitted"===o.relationScopeId?o.nodeId:void 0,h=Math.max(1,...n.entry.flows.map(e=>e.perSecond??0)),p=new Map(n.entry.flows.map(e=>[e.edgeId,e])),f=new Map(t.modules.map(e=>[e.nodeId,Ys(t,i,n,e)])),y=t=>e.config.layoutSelection?.isActive&&!e.config.layoutSelection.predicate(f.get(t))?.2:1,g=Math.max(0,Math.min(200,Math.floor(e.config.particleBudget??24))),m=kt(e.config.placementSeed??1),x=r.routes.filter(e=>(p.get(e.edgeId)?.perSecond??0)>0),b=e.config.reducedMotion?[]:Array.from({length:x.length?g:0},(e,t)=>{const i=x[t%x.length],o=zs(i.points,(m()+n.requestedTime/10)%1);return aS("circle",{key:"cue:"+t,cx:o.x,cy:o.y,r:2.3,fill:s,opacity:Math.max(y(i.source),y(i.target)),"data-circuit-particle":i.edgeId})}),v=r.modules.map(e=>({id:e.module.nodeId,x:e.x+e.width/2,y:e.y+e.height/2,fixedPosition:{x:e.x+e.width/2,y:e.y+e.height/2},shape:{type:"aabb",width:e.width,height:e.height},bodyCollisions:!1,datum:Ys(t,i,n,e.module)}));return{bodies:v,config:{kernel:{gravity:{x:0,y:0},seed:e.config.placementSeed??1,sleepAfter:.01},bodyBudget:!1,bodyLimit:v.length,eviction:!1,sediment:!1,settleStepLimit:4},bodyStyle:e=>({fill:a,stroke:c.muted,strokeWidth:1,opacity:y(e.id)}),colliders:r.modules.flatMap(e=>Pn({idPrefix:"queue:"+e.module.nodeId,left:e.queue.x,right:e.queue.x+e.queue.width,top:e.queue.y,bottom:e.queue.y+e.queue.height,thickness:1,openEnds:!0})),sensors:r.modules.map(e=>({id:"sensor:"+e.module.nodeId,shape:{type:"aabb",x:e.sensor.x+e.sensor.width/2,y:e.sensor.y+e.sensor.height/2,width:e.sensor.width,height:e.sensor.height}})),semanticItems:qs(t,r,i,n),backgroundOverlays:aS("svg",u,...r.routes.map(t=>{const i=p.get(t.edgeId),n=t.points[t.points.length-1],o=t.points[t.points.length-2],a=r.modules.find(e=>e.module.nodeId===t.source),u=r.modules.find(e=>e.module.nodeId===t.target),d=a.module.ports.filter(e=>"out"===e.direction).length<u.module.ports.filter(e=>"in"===e.direction).length,f=d?t.points[0]:n,g=d?f.x>=a.x+a.width:f.x>u.x,m=180*Math.atan2(n.y-o.y,n.x-o.x)/Math.PI,x=e.config.highlightedEdgeIds?.includes(t.edgeId),b=x?s:t.residual?c.residual:l,v="records"===i.unit?"rec":"attempts"===i.unit?"att":"roots";return aS("g",{key:t.edgeId,"data-circuit-edge":t.edgeId,opacity:Math.max(y(t.source),y(t.target)),"data-source":t.source,"data-target":t.target,"data-flow":i.perSecond??"unmeasured","data-highlighted":x||void 0,"data-unit":i.unit+"/s"},aS("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),aS("path",{d:t.pathD,stroke:b,strokeWidth:null===i.perSecond?1.5:1+i.perSecond/h*7,strokeDasharray:null===i.perSecond?"4 3":void 0,strokeLinejoin:"round",fill:"none",opacity:0===i.perSecond?.35:.75}),aS("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${n.x},${n.y}) rotate(${m})`,fill:"none",stroke:b}),aS("text",{x:f.x+(g?5:-5),y:f.y-7,textAnchor:g?"start":"end",fontSize:8,fill:s},`${null===i.perSecond?"?":nS(i.perSecond)} ${v}/s`))})),overlays:aS("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":n.observedAt},...r.sections.map(e=>aS("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:s},e.id)),...Bs(r,n,l,s,d,c,y),...b,Ws(r,i,n,l,s,d),aS("text",{x:r.width/2,y:r.height-8,textAnchor:"middle",fontSize:9,fill:s},`${"modeled"===i.kind?"Modeled":"Observed"} · ${n.observedAt}s · pipe width = transferred volume/s · individual timings unavailable`))}},lS=()=>null,uS=Xs(ek,function({atlas:e,linkedHover:t,...i},n=Ms(e)){return{...i,linkedHover:ps(t),title:i.title??e.spec.dataRevision,description:i.description??"Motif Braid. Labeled squares show successive journey steps; parallel strands split at diverging prefixes and taper with per-step traffic.",summary:i.summary??`${n.groups.length} supported journey groups. Counts use ${e.spec.motifs.countUnit}; overlapping motifs do not partition the population. Source revision: ${e.provenance.sourceRevision}.`,accessibleTable:i.accessibleTable??!0,nodes:n.sceneSeeds.nodes,edges:n.sceneSeeds.edges,layout:ZA,layoutConfig:{braid:n}}},[600,400]),dS=Xs(ek,function({width:e=920,height:t=440,title:i="Dependency X-Ray",description:n,summary:o,accessibleTable:r=!0,chartId:s,className:a,onObservation:c,linkedHover:l,linkedSelection:u,annotations:d,frameProps:h,onSelectNode:p,...f}){return{nodes:f.forest.sceneSeeds.nodes,edges:f.forest.sceneSeeds.edges,layout:JA,layoutConfig:f,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:s,className:a,onObservation:c,linkedHover:ps(l),selection:u,annotations:d,frameProps:h,animate:!1,margin:{top:12,right:24,bottom:12,left:12},description:n??`Sections organize the admitted directed graph. Backbone links organize the drawing; residual links retain other original edges. Brackets describe required paths, separately from transport. Roots: ${f.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Completeness: ${f.forest.atlas.requiredPaths?.status??"not prepared"}.`,summary:o??`Roots: ${f.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Required-path completeness: ${f.forest.atlas.requiredPaths?.status??"not prepared"}. ${f.forest.residual.originalEdgeIds.length} original edges retained.`,accessibleTable:r}},[920,440],{top:12,right:24,bottom:12,left:12}),hS=Xs(XA,function({width:e=980,height:t=860,title:i,description:n,summary:o,accessibleTable:r=!0,chartId:s,className:a,onObservation:c,linkedHover:l,annotations:u,frameProps:d,linkedSelection:h,onSelectNode:p,...f}){return{key:JSON.stringify([f.circuit.atlas.analysisRevision,f.circuit.order,f.circuit.backboneEdgeIds,e,t]),data:f.circuit.modules.map(e=>Ys(f.circuit,f.edition,f.reading,e)),layout:cS,layoutConfig:f,width:e,height:t,chartId:s,className:a,onObservation:c,linkedHover:ps(l),annotations:u,frameProps:d,paused:!0,title:i??f.edition.label,description:n??`${f.edition.label}. ${f.edition.kind} aggregate interval tape at ${f.reading.observedAt} seconds. Pipe widths encode transferred volume per second in their labeled units; module readouts separate completions, capacity and queue stock. Individual timings are unavailable.`,summary:o??f.edition.assumptions.join(" "),accessibleTable:r,tooltip:!!(s||l||c)&&lS}},[980,860]),pS=Uv(require("react")),fS=Object.freeze([]),yS={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},gS=2,mS="__forecastSegment",xS="__forecastOpacity",bS="__semiotic_resolvedX",vS="__semiotic_resolvedY",wS="__compoundGroup",kS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Na({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:zr(n.theme).colors.categorical}),s=ha(r.annotations,o.regression);return{chartType:"scatter",data:r.data,xAccessor:r.xAccessor,yAccessor:r.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...n,...s&&s.length>0&&{annotations:s},...r.yExtent&&!n.yExtent&&{yExtent:r.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:n.pointStyle||za(e,t,i,n,o),showLegend:n.showLegend??!!t}}},AS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=ha(n.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...n,...r&&{annotations:r},pointStyle:n.pointStyle||Wa(e,t,i,n,o),showLegend:n.showLegend??!!t}}},SS=(require("react"),"__semioticSelectionData"),MS=Uv(require("react")),_S=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),$S=require("react/jsx-runtime"),PS={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,i,n,o)=>{const r=Ja(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineBy:o.lineBy,rankDirection:o.rankDirection,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0}),s=Math.max(1,r.seriesOrder.length),a=zr(n.theme),c=Qa({seriesOrder:r.seriesOrder,overallOrder:r.overallOrder,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0,color:"string"==typeof o.color?o.color:void 0,colorScheme:i,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,themeCategorical:a.colors.categorical,themeNeutral:a.colors.textSecondary}),l={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:r.valueExtent,seriesOrder:r.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,color:"string"==typeof o.color?o.color:void 0,colorMap:c&&"object"==typeof c&&!Array.isArray(c)?c:void 0,stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0,styleRules:o.styleRules,areaStyle:n.areaStyle,pointStyle:n.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0},u=n.xFormat,d=(e,t)=>{if(0===r.xValues.length)return"";const i=r.xValues[Math.max(0,Math.min(r.xValues.length-1,Math.round(Number(e))))];return u?u(i,t):(i instanceof Date?i.toLocaleDateString():i)+""},h=r.xValues.map((e,t)=>t),p=Array.from({length:s},(e,t)=>t+1),f=n.axes??[{orient:"left",tickValues:p,tickFormat:e=>e+"",label:n.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:n.xLabel,tickAnchor:"edges"}];return{...n,chartType:"custom",data:r.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,r.xValues.length-1)],yExtent:[s+.5,.5],customLayout:uc,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:f,axisExtent:"exact",showAxes:n.showAxes??!0,showLegend:n.showLegend??!1,annotations:Za(n.annotations,r.xValues)}}},jS="__ma_unitized",IS="__ma_series",LS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Array.isArray(o.series)?o.series:[],a=dc(s,i,zr(n.theme).colors.categorical),c=2===s.length,l=s.map(e=>e.extent||pc(r,e.yAccessor)),u=[];for(const e of r)s.forEach((t,i)=>{const n=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==n||!Number.isFinite(Number(n)))return;const o=Number(n),r=l[i],s=r[1]-r[0]||1;u.push({...e,[jS]:c?(o-r[0])/s:o,[IS]:t.label||"Series "+(i+1)})});const d=(e,t)=>i=>{const n=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(n):Number.isInteger(n)?n+"":n.toFixed(1)},h=c?[{orient:"left",label:s[0].label,tickFormat:d(l[0],s[0].format)},{orient:"right",label:s[1].label,tickFormat:d(l[1],s[1].format)},{orient:"bottom"}]:void 0,p=/* @__PURE__ */new Map;s.forEach((e,t)=>{p.set(e.label||"Series "+(t+1),a[t])});const f=Ks(Zs({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>p.get((e[IS]??"")+"")||a[0],styleRules:o.styleRules,ruleContext:hc(o.xAccessor,s)}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:jS,groupAccessor:IS,colorAccessor:IS,...h&&{axes:h},...c&&{yExtent:[0,1]},...n,curve:o.curve||n.curve||"monotoneX",showLegend:n.showLegend??!0,colorScheme:a,lineStyle:f}}},RS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.xAccessor||"x",a="function"==typeof s?s:e=>e[s],c=r.some(e=>{const t=a(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),l=c?r.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:(a(e)??t)+""})):r,u=o.styleRules?ut(void 0,o.styleRules,ot(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{const t=u(e),i="function"==typeof n.areaStyle?n.areaStyle(e):n.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:l,xAccessor:c?"__waterfallX":s,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...n,...d&&{areaStyle:d},...c&&{axes:n.axes??[{orient:"bottom",tickValues:l.map((e,t)=>t)}],xFormat:e=>{const t=r[Number(e)]?a(r[Number(e)]):e,i=o.xFormat??n.xFormat;return"function"==typeof i?i(t):(t??e)+""}}}}},CS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.lineBy,s=o.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",c=zr(n.theme).colors.categorical,l=fc(e,r,i,n,o),u=Na({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:r,colorScheme:i,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:n.annotations,themeCategorical:c,baseLineStyle:l}),d=n.pointStyle||gc(u.data,u.colorAccessor,i,n,o);let h=n.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const p=(!o.directLabel||void 0!==n.showLegend)&&(n.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||l,...Array.isArray(s)&&{areaGroups:s},...s&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...n,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!n.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:p}}},TS={frameType:"xy",layout:{margin:(e,t)=>ya(t.marginDefaults,fa(e),t.showAxes,!!t.title)},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[],s=o.timeAccessor||"time",a=o.valueAccessor||"value",c=o.categoryAccessor,l=Ba(r,n,o,"explicit-then-alpha"),u=o.valueExtent||n.yExtent,d={...da(o),...void 0!==o.cursor&&{cursor:o.cursor}},h={...d,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap}},p=ut(void 0,o.styleRules,e=>{const t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,n=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(n)&&Number.isFinite(o)?(n+o)/2:void 0,y:i,category:null==e.category?void 0:e.category+""}});return{chartType:"bar",data:r,...n,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,r.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>Gs(e,s,"time")??NaN,valueAccessor:e=>Gs(e,a,"value")??NaN,xExtent:o.timeExtent||n.xExtent,yExtent:u,invertY:"down"===o.direction,axes:fa({...o,axes:n.axes??o.axes}),extentPadding:o.extentPadding??n.extentPadding,binSize:o.binSize,categoryAccessor:c,barColors:l||n.barColors,colorScheme:l||n.colorScheme,barStyle:n.barStyle||h,areaStyle:n.areaStyle||(e=>({...p(e),...!c&&void 0!==o.fill&&{fill:o.fill},...d})),showLegend:n.showLegend??!!c}}},OS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s=Na({data:Array.isArray(e)?Hs(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:zr(n.theme).colors.categorical}),a=Vs({data:e,safeData:s.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),c=ra(o.semanticGradient),l=c?.stops.length?{stops:c.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:na(n.gradientFill),u=!1!==o.semanticLine?sa(c):void 0,d=n.pointStyle||gc(a,r,i,n,o);return{chartType:"area",data:a,xAccessor:s.xAccessor,yAccessor:s.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:r,colorScheme:i,...n,...s.annotations.length>0&&{annotations:s.annotations},...s.yExtent&&!n.yExtent&&{yExtent:s.yExtent},...void 0!==l&&{gradientFill:l},...u&&{semanticLineStops:u},lineStyle:n.lineStyle||yc(a,r,i,n,o),...d&&{pointStyle:d}}}},ES={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.xAccessor||"x",s=o.seriesAAccessor||"a",a=o.seriesBAccessor||"b",c=e=>la(ca(r,"x",e)),l=e=>la(ca(s,"a",e)),u=e=>la(ca(a,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",p=o.areaOpacity??.6,f=o.lineWidth??1.5,y=!1!==o.showLines,g=!1!==n.showLegend,m=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=n.legendPosition||"right",v=Qs(Array.isArray(e)?e:[],c,l,u),w=[];if(y&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),i=l(e),n=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(n)&&w.push({__x:t,__y:n,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:ta({seriesAColor:d,seriesBColor:h,areaOpacity:p,styleRules:o.styleRules}),lineStyle:ia({seriesAColor:d,seriesBColor:h,lineWidth:f,styleRules:o.styleRules}),curve:o.curve||"linear",...n,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},FS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s="string"==typeof r&&Array.isArray(e)?Dn(e,r,i):void 0,a="number"==typeof o.areaOpacity?o.areaOpacity:.7,c=n.lineStyle||(e=>{const t=null==r?void 0:Nn(e,r,s),i=o.showLine??!0,n={fill:o.color??t,stroke:i?o.stroke??t:"none",...i?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:a,...null==o.opacity?{}:{opacity:o.opacity}},c=o.styleRules;if(c?.length){const t=nt(o.yAccessor),i=r?"function"==typeof r?(r(e)??"")+"":(e[r]??"")+"":void 0;Object.assign(n,lt(e,c,{value:t(e),category:i}))}return n}),l=o.normalize?"zero":o.baseline??"zero",u=n.pointStyle||gc(e,r,i,n,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:r,colorScheme:i,normalize:o.normalize,baseline:l,stackOrder:o.stackOrder,lineStyle:c,...n,...u&&{pointStyle:u},curve:n.curve??o.curve??"monotoneX",showLegend:n.showLegend??!!r}}},NS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const[r]=n.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...n,...!n.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:ut(void 0,o.styleRules,ot(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:n.scalePadding??Math.max(2,Math.min(12,Math.round(r/40))),extentPadding:n.extentPadding??(r>200?.1:.02)}}},zS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.xCenter,s=o.yCenter,a=o.quadrants,c=o.centerlineStyle||{},l=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=c.stroke||"#999",h=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,f=pS.createElement,y=a?[(e,t,i)=>{if(!t?.x||!t?.y)return null;const n=i.width,o=i.height,c=null!=r?t.x(r):n/2,y=null!=s?t.y(s):o/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(n,c)),m=Math.max(0,Math.min(o,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:n-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:o-m},{c:a.bottomRight,x:g,y:m,w:n-g,h:o-m}],b=l?[f("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),f("text",{key:"ltr",x:n-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),f("text",{key:"lbl",x:8,y:o-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),f("text",{key:"lbr",x:n-8,y:o-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return f(pS.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?f("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),f("line",{key:"vc",x1:g,y1:0,x2:g,y2:o,stroke:d,strokeWidth:h,strokeDasharray:p}),f("line",{key:"hc",x1:0,y1:m,x2:n,y2:m,stroke:d,strokeWidth:h,strokeDasharray:p}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:i,pointStyle:n.pointStyle||o.pointStyle||za(e,t,i,n,o),...n,showLegend:n.showLegend??!!t,...y&&{svgPreRenderers:y}}}},DS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=pa(e,o),s=Na({data:r.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:zr(n.theme).colors.categorical}),a=ha(s.annotations,o.regression),c=o.pointRadius??4,l=ot(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{const t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;const i=[];for(let e=0;t.length-1>e;e++){const n=t[e],o=t[e+1],r=ua(e,t.length);100>t.length&&i.push(pS.createElement("line",{key:"halo-"+e,x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:c+2,strokeLinecap:"round",opacity:.5})),i.push(pS.createElement("line",{key:"segment-"+e,x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:r,strokeWidth:c,strokeLinecap:"round"}))}return pS.createElement(pS.Fragment,null,...i)}];return{chartType:"scatter",data:s.data,xAccessor:s.xAccessor,yAccessor:s.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Ks(e=>{const t=r.orderMap.get(e),i=t?.idx??0,n=t?.total??1,o={fill:n>0?ua(i,n):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1};return u?.length&&Object.assign(o,lt(e,u,l(e))),o},da(o)),...n,...a&&a.length>0&&{annotations:a},...s.yExtent&&!n.yExtent&&{yExtent:s.yExtent},svgPreRenderers:d}}},BS=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,i=e._mean-this._mean;this._mean+=i*e._count/t,this._m2+=e._m2+i*i*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t.merge(this),t}get count(){return this._count}get mean(){return this._mean}get sum(){return this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},WS=class e{constructor(e=10){const t=Math.max(4,Math.min(16,Math.floor(e)));this.p=t,this.m=1<<t,this.registers=new Uint8Array(this.m),this.alpha=.7213/(1+1.079/this.m),this.harmonicSum=this.m,this.zeros=this.m}add(e){const t=mc(e+""),i=t>>>32-this.p,n=Math.min(Math.clz32(t<<this.p),32-this.p)+1;this.updateRegister(i,n)}updateRegister(e,t){const i=this.registers[e];t>i&&(this.registers[e]=t,this.harmonicSum+=2**-t-2**-i,0===i&&this.zeros--)}merge(e){if(e.m===this.m)for(let t=0;this.m>t;t++)this.updateRegister(t,e.registers[t])}clone(){const t=new e(this.p);return t.registers.set(this.registers),t.harmonicSum=this.harmonicSum,t.zeros=this.zeros,t}count(){const e=this.alpha*this.m*this.m/this.harmonicSum;return Math.round(2.5*this.m>=e&&this.zeros>0?this.m*Math.log(this.m/this.zeros):e)}},YS=class e{constructor(e=100){this.centroids=[],this.total=0,this.pending=0,this.compression=Math.max(20,e)}push(e){Number.isFinite(e)&&(this.centroids.push({mean:e,weight:1}),this.total+=1,this.pending++,2*this.compression>this.pending||this.compress())}merge(e){if(0===e.total)return;const t=0===this.total,i=e.centroids.length;for(let t=0;i>t;t++)this.centroids.push({...e.centroids[t]});this.total+=e.total,this.pending=t&&this.compression===e.compression?e.pending:this.pending+i,t||this.compress()}clone(){const t=new e(this.compression);return t.merge(this),t}quantile(e){if(0===this.total||Number.isNaN(e))return NaN;const t=Math.min(1,Math.max(0,e));this.compress();const i=t*this.total;let n=this.centroids[0].weight/2;if(n>=i)return this.centroids[0].mean;for(let e=1;this.centroids.length>e;e++){const t=this.centroids[e-1],o=this.centroids[e],r=(t.weight+o.weight)/2,s=n+r;if(s>=i)return t.mean+(i-n)/r*(o.mean-t.mean);n=s}return this.centroids[this.centroids.length-1].mean}get count(){return this.total}compress(){if(0===this.pending)return;if(this.pending=0,1>=this.centroids.length)return;this.centroids.sort((e,t)=>e.mean-t.mean);let e=0,t=0;const i=this.total,n=this.compression;for(let o=1;this.centroids.length>o;o++){const r=this.centroids[e],s=this.centroids[o],a=(t+r.weight/2)/i;if(r.weight+s.weight>Math.max(1,4*i*a*(1-a)/n))t+=r.weight,this.centroids[++e]=s;else{const e=r.weight+s.weight;r.mean=(r.mean*r.weight+s.mean*s.weight)/e,r.weight=e}}this.centroids.length=e+1}},qS=(e,t)=>e-t,XS=class{constructor(e,t){this.stats=new BS,this.digest=e?new YS:null,this.hll=t?new WS:null}push(e,t){this.stats.push(e),this.digest?.push(e),this.hll&&this.hll.add(t??e)}merge(e){this.stats.merge(e.stats),this.digest?.merge(e.digest),this.hll?.merge(e.hll)}},GS=class{constructor(e){this.windows=/* @__PURE__ */new Map,this.starts=[],this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0,this.percentiles=e.percentiles??[],this.wantDistinct=!0===e.distinct}newBucket(){return new XS(this.percentiles.length>0,this.wantDistinct)}push(e,t,i){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t,i):this.pushFixed(e,t,i),this.prune())}pushFixed(e,t,i){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t,i);const n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t,i)}bump(e,t,i){let n=this.windows.get(e);if(!n){if(this.windows.size>=this.retain&&this.starts[0]>e)return;n=this.newBucket(),this.windows.set(e,n),this.retain!==1/0&&bc(this.starts,e,qS)}n.push(t,i)}pushSession(e,t,i){const n=e-this.gap,o=e+this.gap;let r=0,s=this.sessions.length;const a=this.sessions[s-1];if(a&&a.end>e)for(;s>r;){const e=r+s>>>1;n>this.sessions[e].end?r=e+1:s=e}else r=s,!a||n>a.end||a.start>o||r--;const c=this.sessions[r];if(!c||c.start>o){const n=this.newBucket();return n.push(t,i),void this.sessions.splice(r,0,{start:e,end:e,bucket:n})}c.bucket.push(t,i),c.start=Math.min(c.start,e),c.end=Math.max(c.end,e);let l=r+1;for(;this.sessions.length>l&&o>=this.sessions[l].start;){const e=this.sessions[l++];c.bucket.merge(e.bucket),c.end=Math.max(c.end,e.end)}l>r+1&&this.sessions.splice(r+1,l-r-1)}prune(){if(this.retain!==1/0)if("session"!==this.type)for(;this.windows.size>this.retain;)this.windows.delete(vc(this.starts,qS));else this.sessions.length>this.retain&&this.sessions.splice(0,this.sessions.length-this.retain)}emit(){if("session"===this.type)return this.sessions.map(e=>this.row(e.start,e.end,e.bucket,this.gap>this.latest-e.end));const e=[];for(const[t,i]of this.windows){const n=t+this.size;e.push(this.row(t,n,i,n>this.latest))}return e.sort((e,t)=>e.start-t.start),e}row(e,t,i,n){const o=i.stats,r={start:e,end:t,count:o.count,mean:o.mean,sum:o.sum,min:o.min,max:o.max,stddev:o.stddev,partial:n};if(i.digest){const e={};for(const t of this.percentiles)e[xc(t)]=i.digest.quantile(t);r.percentiles=e}return i.hll&&(r.distinct=i.hll.count()),r}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.starts=[],this.sessions=[],this.latest=-1/0}},VS={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},HS=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,US="time",KS="value",ZS="__aggLower",QS="__aggUpper",JS="__aggPartial",eM="count",tM="__aggStart",iM="__aggEnd",nM="__aggSeries",oM=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){const n=Gs(e,t,"time"),o=Gs(e,i,"value");if(null==n||null==o)return;const r=null==this.seriesAccessor?"":("function"==typeof this.seriesAccessor?this.seriesAccessor(e):e[this.seriesAccessor])+"";let s=this.groups.get(r);if(!s){if(s=Sc(this.config),!s)return;this.groups.set(r,s)}s.push(n,o)}emit(e){const t=[];for(const[i,n]of this.groups)for(const o of Mc(n,e))t.push(null==this.seriesAccessor?o:{...o,[nM]:i});return t}clear(){this.groups.clear()}},rM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,s=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,a=ut(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:s}),o.styleRules,$c(o.xAccessor,o.yAccessor,o.valueAccessor)),c=("string"==typeof r?.colorScheme?r.colorScheme:void 0)??i,l=null!=r&&Object.hasOwn(r,"heatmapColorScale"),u=r?.heatmapColorScale,d=l?"function"==typeof u?u:void 0:"custom"===c&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:a,...n,...void 0!==c&&{colorScheme:c},...d&&{heatmapColorScale:d}}}},sM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=jc(e,o),s=o.aggregate,a=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:Ic(o),c=ut(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,ot(a.timeAccessor,a.valueAccessor));return{chartType:"line",data:r,...n,...Lc(r,n,o),...a,groupAccessor:s&&null!=o.seriesAccessor?nM:o.seriesAccessor,...s&&{windowMode:"growing",windowSize:Math.max(1,s.retain??Math.max(r.length,600)),band:(l=s,"none"!==(l.band??"none")?{y0Accessor:ZS,y1Accessor:QS,perSeries:null!=o.seriesAccessor}:void 0)},lineStyle:n.lineStyle||(e=>({...c(e),...da(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))};var l}},aM={...TS,buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[];return{...TS.buildProps(r,t,i,n,o),...Lc(r,n,o)}}},cM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[];return{...rM.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...Lc(r,n,o),categoryAccessor:o.categoryAccessor}}},lM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[],s=Ba(r,n,o,"discovery"),a=ut(void 0,o.styleRules,ot(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:r,...n,...Lc(r,n,o),categoryAccessor:o.categoryAccessor,colorScheme:s||i||n.colorScheme,barColors:s,yScaleType:o.yScaleType,swarmStyle:{...da(o),fill:o.fill,radius:o.radius,cursor:o.cursor},pointStyle:e=>({...a(e),..."function"==typeof o.pointStyle?o.pointStyle(e):{},..."function"==typeof n.pointStyle?n.pointStyle(e):n.pointStyle})}}},uM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[],s=RS.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...s,...Lc(r,n,o),waterfallStyle:{...s.waterfallStyle,cursor:o.cursor}}}},dM=(require("react"),{RdBu:Hk,PiYG:Uk,PRGn:Kk,BrBG:Zk,RdYlBu:Qk,RdYlGn:Jk,Spectral:eA}),hM="__likert_neutral_neg",pM="__likert_neutral_pos",fM={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,i,n,r)=>{const s=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],a="vertical"!==r.orientation;let c=Tc(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s,Rc(r.categoryAccessor,"question"),r.levelAccessor?null:Rc(r.valueAccessor,"score"),r.levelAccessor?Rc(r.levelAccessor,"level"):null,r.levelAccessor?Rc(r.countAccessor,"count"):null,{category:"string"==typeof r.categoryAccessor?r.categoryAccessor:void 0,level:"string"==typeof r.levelAccessor?r.levelAccessor:void 0,count:"string"==typeof r.countAccessor?r.countAccessor:void 0,score:r.levelAccessor||"string"!=typeof r.valueAccessor?void 0:r.valueAccessor});a&&(c=Ec(Oc(c,s),s));const l=zr(n.theme).colors.diverging,u=Array.isArray(i)&&i.length>=s.length?i:Cc(s.length,l),d=new Map(s.map((e,t)=>[e,u[t]||"#888"])),h=s.length%2&&d.get(s[Math.floor(s.length/2)])||"#888",p="function"==typeof r.valueFormat?r.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",f=o(!1===n.showLegend?void 0:{legendGroups:[{label:"",items:s.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},n.legend),y=r.styleRules,g=n.pieceStyle;return{chartType:"bar",data:c,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:r.barPadding,showGrid:n.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(a?void 0:"Percentage"),rFormat:p,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...n,pieceStyle:Ks((e,t)=>{const i=e.__likertLevel||e.data?.__likertLevel,n=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,r={fill:i===hM||i===pM?h:d.get((n||i)+"")||"#888"};return y?.length&&Object.assign(r,lt(e,y,{value:"number"==typeof o?o:void 0,category:t??(null==n?void 0:n+"")})),"function"==typeof g?Object.assign(r,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(r,g),r},da(r)),showLegend:n.showLegend??!0,legendPosition:n.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},yM=require("react/jsx-runtime"),gM=require("react/jsx-runtime"),mM={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const i=e.__gauge;if(!i)return null;const n=(i.startAngleDeg+(i.gMax===i.gMin?0:(Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin))-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,o=i.needleColor||t.colors.text,r=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&i.gMax>e.value):[];/* @__PURE__ */ /* @__PURE__ */
|
|
589
|
+
/* @__PURE__ */(0,dI.jsx)("g",{transform:`translate(${u},${d})`,children:p}),f&&/* @__PURE__ */ /* @__PURE__ */(0,dI.jsx)("text",{x:t/2,y:sw,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:f})]}))}async function Fv(e,t,i,n={}){const{fps:o=12,loop:r=!0,scale:s=1,background:a}=n,c=i.width||600,l=i.height||400,u=$v(e,t,a?{...i,background:a}:i,n);if(0===u.length)throw Error("No frames generated — check that data is not empty");return zv(u,c,l,{fps:o,loop:r,scale:s})}async function Nv(e,t={}){const{fps:i=12,loop:n=!0,scale:o=1}=t,r=e.size??[e.width??600,e.height??400],s=Rv(e,t);if(0===s.length)throw Error("No physics frames generated");return zv(s,r[0],r[1],{fps:i,loop:n,scale:o})}async function zv(...e){return(await Promise.resolve().then(()=>(ew(),Qv))).encodeSvgFramesToGif(...e)}var Dv=Object.create,Bv=Object.defineProperty,Wv=Object.getOwnPropertyDescriptor,Yv=Object.getOwnPropertyNames,qv=Object.getPrototypeOf,Xv=Object.prototype.hasOwnProperty,Gv=(e,t,i)=>function(){if(i)throw i[0];try{return e&&(t=(0,e[Yv(e)[0]])(e=0)),t}catch(e){throw i=[e],e}},Vv=(e,t)=>{for(var i in t)Bv(e,i,{get:t[i],enumerable:!0})},Hv=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of Yv(t))Xv.call(e,o)||o===i||Bv(e,o,{get:()=>t[o],enumerable:!(n=Wv(t,o))||n.enumerable});return e},Uv=(e,t,i)=>(i=null!=e?Dv(qv(e)):{},Hv(!t&&e&&e.__esModule?i:Bv(i,"default",{value:e,enumerable:!0}),e)),Kv={};Vv(Kv,{rasterizeSVG:()=>e});var Zv=Gv({"src/components/server/rasterizeSVG.ts"(){}}),Qv={};Vv(Qv,{encodeSvgFramesToGif:()=>t});var Jv,ew=Gv({"src/components/server/encodeSvgFramesToGif.ts"(){}}),tw={};Vv(tw,{generateFrameSVGs:()=>$v,generateFrameSequence:()=>Pv,generatePhysicsFrameSVGs:()=>Rv,renderChart:()=>kv,renderChartWithEvidence:()=>Av,renderDashboard:()=>_v,renderGeoToStaticSVG:()=>gv,renderNetworkToStaticSVG:()=>yv,renderOrdinalToStaticSVG:()=>fv,renderPhysicsToAnimatedGif:()=>Nv,renderToAnimatedGif:()=>Fv,renderToImage:()=>Mv,renderToStaticSVG:()=>hv,renderXYToStaticSVG:()=>pv,resolveTheme:()=>Wr,serializeSvgPrecision:()=>vv,themeStyles:()=>Yr}),module.exports=(Jv=tw,Hv(Bv({},"__esModule",{value:!0}),Jv));var iw,nw=36,ow=34,rw=58,sw=22,aw=16,cw=6,lw=10,uw=22,dw=100,hw=10,pw=3,fw=12,yw=18,gw=46,mw=26,xw=22,bw=46,vw=64,ww=34,kw=70,Aw=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Sw=(e,t)=>(e>>>t|e<<32-t)>>>0,Mw=e=>Math.floor(4294967296*(e-Math.floor(e)))>>>0,[_w,$w]=/* @__PURE__ */(()=>{const e=[],t=[];for(let i=2;64>t.length;i+=1){let n=!0;for(let e=2;i>=e*e;e+=1)if(i%e===0){n=!1;break}n&&(8>e.length&&e.push(Mw(Math.sqrt(i))),t.push(Mw(Math.cbrt(i))))}return[e,t]})(),Pw="0.1",jw=/* @__PURE__ */xe({"artifact.id":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.createdAt":{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"never"},"artifact.configFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.dataFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"purpose.intents":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.communicativeAct":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.stakes":{suppliedBy:["author","import"],derivable:!1,modelMayPropose:!0,humanReview:"required"},claims:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"claims.status":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},evidence:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.source":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.fingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},time:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"time.completeness":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},reception:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},form:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},contestability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"required"},accountability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"policy-dependent"},inheritance:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"}}),Iw=["fresh","stale","unknown"],Lw=["partial","provisional","settled","unknown"],Rw=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],Cw={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:Iw},checkedAt:{},heartbeatAt:{},expiresAt:{},basis:{}},watermark:{value:{required:!0},policy:{},allowedLateness:{}},window:{start:{required:!0},end:{required:!0},status:{required:!0,values:["open","provisional","settled","reopened","corrected"]}},completeness:{status:{required:!0,values:Lw},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},Tw={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:Iw},completeness:{values:Lw}},Ow=/* @__PURE__ */new Set(["data","nodes","edges","points","areas","lines","flows","atlas","forest","circuit","edition","reading"]),Ew=44,Fw={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Ew,snap:"nearestDatum",brushHandleSize:Ew,standardControls:!1},Nw={...Fw,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},zw={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}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}},Dw={kind:"rank-competition"},Bw=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),Ww=globalThis,Yw=Ww[Bw]??(Ww[Bw]=/* @__PURE__ */new Map),qw=Uv(require("react-dom/server")),Xw=require("d3-interpolate"),Gw=864e5,Vw=e=>{const t=e.config,{plot:i}=e.dimensions;if(0>=i.width||0>=i.height)return{nodes:[]};const n=e=>{const i="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return i instanceof Date?i:new Date(i)},o=e=>{const i="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(i)},r=/* @__PURE__ */new Map;let s=null;for(const t of e.data){const e=n(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const i=Ze(e),a=o(t);r.set(i,(r.get(i)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??/* @__PURE__ */(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of r.values())c>e&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Xw.interpolateRgb)(u,d)(t)},p=t.gutter??2,f=t.labelInset??0,y=Math.min((i.width-f-53*p)/54,(i.height-6*p)/7);if(0>=y)return{nodes:[]};const g=new Date(Date.UTC(a,0,1)),m=g.getUTCDay(),x=new Date(g.getTime()-m*Gw),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const n=new Date(x.getTime()+(7*e+t)*Gw);if(n.getUTCFullYear()!==a)continue;const o=Ze(n),s=r.get(o),c=null==s?u:h(s);b.push({type:"rect",x:i.x+f+e*(y+p),y:i.y+t*(y+p),w:y,h:y,style:{fill:c,stroke:"none"},datum:{date:n,value:s??0}})}return{nodes:b}},Hw=Uv(require("react")),Uw=require("d3-scale"),Kw=(require("d3-interpolate"),require("react/jsx-runtime")),Zw=e=>{const t=e.config,{plot:i}=e.dimensions,n=t.fields??[];if(2>n.length||0>=i.width||0>=i.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const o=/* @__PURE__ */Object.create(null);for(const i of n){const n=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,i)?t.domains[i]:void 0;if(Array.isArray(n)&&n.length>=2&&"number"==typeof n[0]&&Number.isFinite(n[0])&&"number"==typeof n[1]&&Number.isFinite(n[1])){o[i]=[n[0],n[1]];continue}let r=1/0,s=-1/0;for(const t of e.data){const e=Number(t[i]);Number.isFinite(e)&&(r>e&&(r=e),e>s&&(s=e))}if(Number.isFinite(r)&&Number.isFinite(s))if(r===s){const e=Math.max(.01*Math.abs(r),.5);o[i]=[r-e,s+e]}else o[i]=[r,s];else o[i]=[0,1]}const r=!1!==t.showAxes,s=r?t.axisLabelPadding??24:8,a=r?18:8,c=n.map(e=>(0,Uw.scaleLinear)().domain(o[e]).range([i.y+i.height-a,i.y+s])),l=n.map((e,t)=>1===n.length?i.x+i.width/2:i.x+t/(n.length-1)*i.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,p=e.theme.semantic.primary??"#3b6cb1",f=t.dimmedOpacity??.08,y=t.highlightFn,g=[],m=[];for(const i of e.data){const o=u?e.resolveColor(u(i)+""):p,r=!y||y(i),s=et(i,{predicate:y,baseOpacity:d,dimOpacity:f,brighten:.4}),a=r?m:g;for(let e=0;n.length-1>e;e++){const t=Number(i[n[e]]),u=Number(i[n[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:o,strokeWidth:y&&r?h+.75:h,opacity:s,fill:"none"},datum:i};a.push(d)}if(t.showPoints)for(let e=0;n.length>e;e++){const t=Number(i[n[e]]);if(!Number.isFinite(t))continue;const r={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:o,stroke:"none",opacity:Math.min(1,s+.3)},datum:i};a.push(r)}}let x=null;if(r){const r=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=i.y+s,p=i.y+i.height-a,f=[];for(let e=0;n.length>e;e++){const a=n[e],y=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,m="function"==typeof g?g:e=>e.toLocaleString();f.push(Hw.createElement("line",{key:"pc-axis-line-"+e,x1:y,x2:y,y1:h,y2:p,stroke:r,strokeWidth:1})),f.push(it({keyId:"pc-axis-label-"+e,text:a,x:y,y:i.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=o[a],v=5;for(let t=0;v>t;t++){const i=x+(b-x)*t/(v-1),n=c[e](i);f.push(Hw.createElement("line",{key:`pc-tick-${e}-${t}`,x1:y-3,x2:y+3,y1:n,y2:n,stroke:r,strokeWidth:1}),it({keyId:`pc-ticktext-${e}-${t}`,text:m(i),x:y+6,y:n+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Hw.createElement(Hw.Fragment,null,...f)}return{nodes:g.concat(m),overlays:x}},Qw={frameType:"xy",buildProps:(e,t,i,n,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...n,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:n.showLegend??!!t})},Jw={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...n,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},ek={frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,n,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...n})},tk={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({...Jw.buildProps(e,t,i,n,o),customLayout:Zw,showAxes:!1})},ik={frameType:"xy",buildProps:(e,t,i,n,o)=>({...Qw.buildProps(e,t,i,n,o),customLayout:Vw,showAxes:!1})},nk=Uv(require("react")),ok=require("d3-scale"),rk={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},sk=1e-9,ak=.005,ck=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=/* @__PURE__ */new Map,this.colliders=/* @__PURE__ */new Map,this.springs=/* @__PURE__ */new Map,this.activeSensors=/* @__PURE__ */new Set,this.supportedThisStep=/* @__PURE__ */new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...rk,...e},this.random=Pt(this.options.seed)}init(e={}){this.options={...rk,...e},this.random=Pt(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(sk,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:It(e.fixedPosition)}:{},shape:Rt(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};jt(t),this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Zt(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:Ct(t.shape),bodyFilter:Ot(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,i){const n=this.bodies.get(e);n&&(n.vx+=t/n.mass,n.vy+=i/n.mass,jt(n),this.wake(n))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const i=this.sortedBodies();for(const e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const n=this.options.maxVelocity;for(const e of i)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,jt(e),n>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>n){const i=n/t;e.vx*=i,e.vy*=i}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const o=this.bodyPairKeys(i),r=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(i,o,0===e),this.resolveColliders(i,r,0===e);this.updateSensors(i),this.updateSleeping(i,t)}settle(e=1200,t=this.options.fixedDt){let i=0;for(;e>i&&!this.allSleeping();)this.step(t),i+=1;return i}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,...t.fixedPosition?{fixedPosition:It(t.fixedPosition)}:{},shape:Rt(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Zt)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Tt),colliders:this.sortedColliders().map(Et),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=Pt(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Tt(t);jt(e),this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Et(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const i=this.bodies.get(t.bodyId);if(!i||i.sleeping)continue;const n="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!n)continue;const o=n.x-i.x,r=n.y-i.y,s=Math.sqrt(o*o+r*r);if(sk>=s)continue;const a=o/s,c=r/s,l=(s-t.restLength)*t.stiffness+((("vx"in n?n.vx:0)-i.vx)*a+(("vy"in n?n.vy:0)-i.vy)*c)*t.damping;i.vx+=l*a*e/i.mass,i.vy+=l*c*e/i.mass}}resolveBodyPairs(e,t,i){for(const n of t){const[t,o]=n.split(":").map(Number),r=e[t],s=e[o];if(!r||!s)continue;const a=Ht(r,s);a&&(this.resolveDynamicCollision(r,s,a),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),i=/* @__PURE__ */new Map;for(let n=0;e.length>n;n+=1){if(!1===e[n].bodyCollisions)continue;const o=Bt(e[n]),r=Math.floor(o.minX/t),s=Math.floor(o.maxX/t),a=Math.floor(o.minY/t),c=Math.floor(o.maxY/t);for(let e=r;s>=e;e+=1)for(let t=a;c>=t;t+=1){const o=`${e}:${t}`,r=i.get(o);r?r.push(n):i.set(o,[n])}}const n=/* @__PURE__ */new Set;for(const t of Array.from(i.keys()).sort()){const o=i.get(t)??[];o.sort((e,t)=>e-t);for(let t=0;o.length>t;t+=1)for(let i=t+1;o.length>i;i+=1){const r=o[t],s=o[i];!1!==e[r].bodyCollisions&&!1!==e[s].bodyCollisions&&Yt(Bt(e[r]),Bt(e[s]))&&n.add(`${r}:${s}`)}}return Array.from(n).sort((e,t)=>{const[i,n]=e.split(":").map(Number),[o,r]=t.split(":").map(Number);return i===o?n-r:i-o})}resolveDynamicCollision(e,t,i){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?!e.sleeping&&null==e.fixedPosition?.y||!t.sleeping&&null==t.fixedPosition?.y||(i=Lt(e,t,"y")):i=Lt(e,t,"x")),e.sleeping&&this.contactOpposesGravity(i.nx,i.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-i.nx,-i.ny)&&this.supportedThisStep.add(e.id);const n=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,r=null==e.fixedPosition?.x?n:0,s=null==e.fixedPosition?.y?n:0,a=null==t.fixedPosition?.x?o:0,c=null==t.fixedPosition?.y?o:0,l=e.fixedPosition||t.fixedPosition?i.nx**2*(r+a)+i.ny**2*(s+c):n+o;if(sk>=l)return;const u=Math.max(0,i.penetration-ak)/l;e.x-=i.nx*u*r,e.y-=i.ny*u*s,t.x+=i.nx*u*a,t.y+=i.ny*u*c;const d=(t.vx-e.vx)*i.nx+(t.vy-e.vy)*i.ny;if(d>0)return;const h=Math.abs(d),p=-(1+Nt(e.restitution,t.restitution,this.options.restitution))*d/l,f=p*i.nx,y=p*i.ny;e.vx-=f*r,e.vy-=y*s,t.vx+=f*a,t.vy+=y*c,this.applyFriction(e,t,i,p,n,o),h>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,i,n,o,r){const s=-i.ny,a=i.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=null==e.fixedPosition?.x?o:0,u=null==e.fixedPosition?.y?o:0,d=null==t.fixedPosition?.x?r:0,h=null==t.fixedPosition?.y?r:0,p=e.fixedPosition||t.fixedPosition?s**2*(l+d)+a**2*(u+h):o+r;if(sk>=Math.abs(c)||sk>=p)return;const f=zt(e.friction,t.friction,this.options.friction),y=Ft(-c/p,-n*f,n*f),g=y*s,m=y*a;e.vx-=g*l,e.vy-=m*u,t.vx+=g*d,t.vy+=m*h}resolveColliders(e,t,i){for(const n of e)for(const e of t){if(!ti(e,n))continue;if(!Yt(Bt(n),Wt(e)))continue;const t=Ut(n,e);t&&(this.resolveStaticCollision(n,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(n.id),i&&this.lastEvents.push({type:"contact",bodyId:n.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,i){e.x+=i.nx*Math.max(0,i.penetration-ak),e.y+=i.ny*Math.max(0,i.penetration-ak);const n=e.vx*i.nx+e.vy*i.ny;if(0>n){const o=Nt(e.restitution,t.restitution,this.options.restitution);e.vx-=(1+o)*n*i.nx,e.vy-=(1+o)*n*i.ny;const r=-i.ny,s=i.nx,a=e.vx*r+e.vy*s,c=zt(e.friction,t.friction,this.options.friction);e.vx-=a*r*c,e.vy-=a*s*c}jt(e)}updateSensors(e){const t=/* @__PURE__ */new Set,i=this.sortedColliders().filter(e=>e.sensor);for(const n of e){const e=Bt(n);for(const o of i){if(!ti(o,n))continue;if(!Yt(e,Wt(o)))continue;if(!Ut(n,o))continue;const i=Kt(o.id,n.id);t.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:n.id,sensorId:o.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:i,bodyId:n}=Zt(e);this.lastEvents.push({type:"sensor-exit",bodyId:n,sensorId:i})}this.activeSensors=t}updateSleeping(e,t){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const n of e)Math.sqrt(n.vx*n.vx+n.vy*n.vy)>=this.options.sleepSpeed||Math.sqrt((n.x-n.prevX)*(n.x-n.prevX)+(n.y-n.prevY)*(n.y-n.prevY))>=this.options.sleepSpeed*t||i&&!this.supportedThisStep.has(n.id)?n.sleeping?this.wake(n):n.sleepTime=0:(n.sleepTime+=t,n.sleeping||this.options.sleepAfter>n.sleepTime||(n.sleeping=!0,n.vx=0,n.vy=0,this.lastEvents.push({type:"sleep",bodyId:n.id})))}contactOpposesGravity(e,t){const{x:i,y:n}=this.options.gravity,o=Math.hypot(i,n);return 1e-9>=o||-.2>(e*i+t*n)/o}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},lk=class{constructor(e={}){this.id="builtin",this.capabilities={...(new ck).capabilities,engine:"builtin"},this.world=new ck(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}},uk=["binId","targetBin","category","windowIndex","lane","group"],dk=class{constructor(e=!1){this.bins=/* @__PURE__ */new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const i=ui(ci(this.config.binAccessor,e,t))??di(e),n=ui(ci(this.config.labelAccessor,e,t))??i,o=li(this.config.valueAccessor,e,t),r=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(i);return s||(s={id:i,label:n,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,s)),s.label=n,s.lastBodyId=e.id,s.lastDatum=e.datum,oi(s.x,e.x),oi(s.y,e.y),oi(s.value,o),r>0&&(s.bodyIds.push(e.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),hi(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(hi)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:si(t.x),y:si(t.y),value:si(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}},hk={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},pk={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},fk={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},yk=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Ti({kind:"initialize"},[],this.revisions),this.listeners=/* @__PURE__ */new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const i=Ti(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(const e of[...this.listeners])e();return i}},gk=require("d3-quadtree"),mk=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,i,n,o,r=0,s){const a=this.ensure(e,t);if(!a)return null;let c=null,l=1/0;const u=Math.max(0,s?.searchRadius??Math.max(0,r)+this.maxSearchRadius),d=n-u,h=n+u,p=o-u,f=o+u;return a.visit((e,t,a,u,y)=>{if(d>u||t>h||p>y||a>f)return!0;if(e.length)return!1;let g=e;for(;g;){const e=g.data;if(e&&(!s?.include||s.include(e))){const t=s?.distanceSquared?s.distanceSquared(e,n,o):ji(e,n,o,Math.max(0,r));null!=t&&(l>t||t===l&&i.indexOf(e.id)>i.indexOf(c?.id??""))&&(c=e,l=t)}g=g.next}return!1}),c}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const i=e.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=i.reduce((e,t)=>Math.max(e,Pi(t)),0),this.tree=(0,gk.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},xk=["data","scene-geometry","data-paint","accessibility","evidence"],bk=["scene-geometry","data-paint","accessibility","evidence"],vk=["overlay","accessibility","evidence"],wk=(e,t)=>({retainedData:e,invalidations:t}),kk=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ak=["scene-geometry","data-paint","accessibility","evidence"],Sk=[],Mk={engine:wk("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:wk("preserve",Ak),colliders:wk("preserve",Ak),sediment:wk("preserve",Ak),bodyBudget:wk("preserve",kk),bodyLimit:wk("preserve",kk),eviction:wk("preserve",kk),fixedDt:wk("preserve",Sk),maxDeltaSeconds:wk("preserve",Sk),maxSubsteps:wk("preserve",Sk),settleStepLimit:wk("preserve",Sk),timeScale:wk("preserve",Sk),observation:wk("preserve",Sk)},_k=wk("preserve",kk),$k=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],Pk=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=Vi(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,i){if(i>0)return void(this.seconds=0);const n=e.readState(this.scratch),o=this.speed*this.speed;let r=!0;for(const e of n)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=o){r=!1;break}this.seconds=r?this.seconds+Math.max(0,t):0}},jk=class{constructor(e={}){this.activeSensorPairs=/* @__PURE__ */new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new mk,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new yk,this.simulationState="settled",this.visible=!0,this.quiescence=new Pk;const{bodyBudget:t,colliders:i,engine:n,kernel:o,observation:r,sediment:s,...a}=e;this.config={...hk,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=n,this.observation=mi(r),this.sediment=new dk(s??!1),this.world=ni(n,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),i&&this.world.setColliders(Si(i))}updateConfig(e){const t=Fi(e,this.configInput),{colliders:i,bodyBudget:n,engine:o,kernel:r,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==n&&(this.bodyBudget=n,!1===n&&(this.bodyBudgetObservationKey="ok")),o&&o!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=o,this.world=ni(o,e.options),this.world.restore(e),this.revision+=1}if(r&&!Ei(r,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...r,gravity:{...e.options.gravity,...r.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}s&&(this.observation=mi(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(Si(i)),this.revision+=1),this.configInput={...this.configInput,...e};const l=Oi(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(Si(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Oi(["colliders"]).invalidations)}enqueue(e,t){const i=Array.isArray(e)?e:[e],n=t?ki(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(const e of n)this.queue.push({...xi(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(_i),n.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:n.length},n.length?xk:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(xi(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},xk)}materializeDueSpawns(){const e=this.revision,t=[],i=[];return this.spawnDue(t,i),0===t.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?xk:[])),t}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},xk)}tick(e,t){const i=this.revision,n=[],o=[],r=[],s=[],a=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,s,a,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const c=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(n,a);const l=this.observeBodyBudget(a),u=this.evictOverflow(a);o.push(...u.evicted),r.push(...u.sedimented),this.syncSimulationState(a),n.length>0&&this.quiescence.reset(),this.accumulator+=c;const d=this.stepObserver(t,{spawned:n,evicted:o,sedimented:r,events:s,observations:a}),h=c>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:p,budget:f}=Ui(this.settleHost(),Math.min(h,this.config.maxSubsteps),{spawned:n,evicted:o,sedimented:r,events:s,observations:a},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:d});this.accumulator=Math.max(0,this.accumulator-p*this.config.fixedDt),p===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(p>0||n.length>0||o.length>0||r.length>0||s.length>0)&&(this.revision+=1);const y=this.result(p,n,o,r,s,a,void 0,f??l);return this.updateResults.record({kind:"tick",count:p},this.revision!==i?n.length||o.length||r.length?xk:bk:[]),y}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit,t){return this.runSettle(e,!0,t)}stepObserver(e,t){return Hi(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,i){const n=this.revision,o=[],r=[],s=[],a=[],c=t?[]:void 0;if(t&&(this.paused||!this.visible)){const e=this.result(0,o,r,s,a,c??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,c);const l=this.observeBodyBudget(c),u=this.evictOverflow(c);r.push(...u.evicted),s.push(...u.sedimented),this.syncSimulationState(c),o.length>0&&this.quiescence.reset();const d=t?{spawned:o,evicted:r,sedimented:s,events:a,observations:c}:{spawned:o},h=this.stepObserver(i,{spawned:o,evicted:r,sedimented:s,events:a,observations:c??[]}),{steps:p,budget:f}=Ui(this.settleHost(),e,d,{afterStep:h,continueWhile:i?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0}),y=o.length+r.length+s.length>0;(p>0||y||a.length>0)&&(this.revision+=1);const g=this.result(p,o,r,s,a,c??[],void 0,f??l);return this.updateResults.record({kind:"settle",count:p},this.revision===n?[]:y?xk:bk),g}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return pi(this.readSediment(),e)}hitTest(e,t,i=0,n){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,i,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:i,chartId:n,...o}=e,r={...o,timestamp:t??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:n??this.observation.chartId};return this.emitObservation(r),this.updateResults.record({kind:"update",count:1},["evidence"]),r}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?vk:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?vk:[])}remove(e){const t=new Set(e),i=new Set(this.liveBodyOrder),n=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const o=e.filter(e=>i.has(e)||n.has(e));return o.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:o,count:o.length},o.length?xk:[]),o}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},bk),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},bk)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},bk)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,i,n)=>e.applyImpulse(t,i,n),clear:()=>e.clear(),hitTest:(t,i,n)=>e.hitTest(t,i,n),pause:()=>e.setPaused(!0),push:(t,i)=>e.enqueue(t,i),pushMany:(t,i)=>e.enqueue(t,i),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Mi(this.bodyBudget),config:{...this.config,kernel:$i(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(Ai),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){const t=this.simulationState;this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:Mi(e.bodyBudget??{}),kernel:$i(e.world.options)},this.bodyBudget=Mi(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(Ai).sort(_i),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Bi(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},xk),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds+1e-9*this.config.fixedDt>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,t),e.push(i.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(/* @__PURE__ */new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const i=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:i?.datum??e.datum,x:i?.x??e.x,y:i?.y??e.y},t)}result(e,t,i,n,o,r,s,a=this.evaluateBodyBudget()){this.syncSimulationState(r);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:o,observations:r,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:c,sedimented:n,spawned:t,steps:e}}observeKernelEvents(e,t){Ni(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=zi(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){Di(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return gi({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const i=`${t.state}:${t.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,Yi(t,this.observationContext(e))),t}syncSimulationState(e){const t=Bi(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const i=this.simulationState;this.simulationState=t,Wi(i,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:i,liveBodyOrder:n}=Gi(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=n,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:i}}},Ik=require("d3-scale"),Lk=require("d3-scale"),Rk=require("d3-scale"),Ck=require("d3-scale"),Tk=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Ok=Fn(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Ek=Fn(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Fk=Fn(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Nk=Fn(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),zk=Fn(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Dk=Fn(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Bk=Fn(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Wk=Fn(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Yk=Fn(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),qk=Fn(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Xk=Fn(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Gk=Fn(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Vk={blues:Ok,reds:Ek,greens:Fk,viridis:Bk,oranges:Nk,purples:zk,greys:Dk,plasma:Wk,inferno:Yk,magma:qk,cividis:Xk,turbo:Gk},Hk=Fn(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Uk=Fn(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Kk=Fn(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Zk=Fn(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Qk=Fn(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Jk=Fn(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),eA=Fn(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),tA={category10:Tk,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Vk},iA=Tk,nA="#007bff",oA=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],rA=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],sA=/* @__PURE__ */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"]),aA={left:28,top:76,rightInset:30,thickness:8},cA=1e-9,lA=[900,520],uA=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],dA=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),hA=1e-9,pA=br,fA=Uv(require("react")),yA=require("react/jsx-runtime"),gA=require("d3-shape"),mA=require("react/jsx-runtime"),xA=require("react/jsx-runtime"),bA="var(--semiotic-text, #26323a)",vA="var(--semiotic-text-secondary, #6c7377)",wA="var(--semiotic-primary, #b8792d)",kA="var(--semiotic-danger, #9f3d35)",AA="var(--semiotic-success, #356b63)",SA=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],MA={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:12}},_A={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:12}},$A={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:SA,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"},PA={light:MA,dark:_A,"high-contrast":$A,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},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:12},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:"#64717f",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:12},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:12},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:12},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:12},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:12,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:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},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:"#c63b3b",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:12,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:12},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:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},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:12},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:12},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:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}},jA=require("react/jsx-runtime"),IA=require("react/jsx-runtime"),LA={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},RA=require("react/jsx-runtime"),CA=require("react/jsx-runtime"),TA=require("react/jsx-runtime"),OA={margin:(e,t)=>t.compactMode?"sparkline"===e.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}},EA=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],FA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s=o.bins??21,a=o.seed??1,c=Math.max(1,Math.round(o.pegRows??s-1)),l="mechanical"===(o.simulationMode??o.mode),u=Ki({data:l?At({bins:s,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],valueAccessor:o.valueAccessor||"value",bins:s,ballRadius:o.ballRadius??("sparkline"===o.mode?1.5:"context"===o.mode?4:6),seed:a,size:r,valueExtent:l?[0,c]:o.valueExtent});return{...n,config:u.config,initialSpawns:us(u.initialSpawns),projectionRows:u.projectionRows,foregroundGraphics:ds(qr(u.projectionRows,s,hs(n,o,"showProjection"),u.metadata,o.referenceLines),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},NA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s=tn({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:r,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...n,config:s.config,initialSpawns:us(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ds(Xr(s.projectionRows,s.metadata,hs(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},zA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s="mechanical"===(o.simulationMode??o.mode),a=cn({data:s?rn({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(s?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:r});return{...n,config:a.config,initialSpawns:us(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:ds(Gr(a.projectionRows,o.ballRadius??8,hs(n,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},DA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,360],s=un({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:r,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...n,config:s.config,initialSpawns:us(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ds(Hr(s.metadata,hs(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},BA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,420],s=Array.isArray(o.stages)?o.stages:[],a=Tn({data:Array.isArray(e)?e:[],stages:s,size:r,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),c=a.metadata;return{...n,config:a.config,initialSpawns:us(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,backgroundGraphics:ds(is(a.metadata,hs(n,o,"showChrome"),{},o.chromeOptions),n.backgroundGraphics),foregroundGraphics:ds(ns(a.projectionRows,a.metadata,hs(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},WA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=fo({data:Array.isArray(e)?e:[],size:r,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...n,config:s.config,initialSpawns:us(s.initialSpawns),projectionRows:[],backgroundGraphics:ds(hs(n,o,"showChrome")?nk.createElement(as,{layout:s.layout,states:s.states,compact:!0===n.__compactMode}):void 0,n.backgroundGraphics),foregroundGraphics:ds(hs(n,o,"showProjection")?nk.createElement(ls,{layout:s.layout,states:s.states}):void 0,n.foregroundGraphics),bodyStyle:ft(t||o.colorBy)}}},YA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=Sr({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:r,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),a=Ar(s,"snapshot"===o.playback?kr(s,o.snapshotAt):s.duration).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},l=Yo(a,c),u=c.measure??"count",d=zr(l.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===u||"amount"===u?e.amount:Number(e.metrics[u]??0),secondaryLabel:"count"===u||"amount"===u?o.amountLabel??"amount":u,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),h={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},p=t??o.colorBy??"category",f=!1===o.showChrome?null:nk.createElement(Or,{layout:s.layout,phases:s.phases,state:a,compact:520>r[0]||360>r[1]}),y=!1===o.showProjection?null:nk.createElement(Fr,{rows:l,layout:s.layout,projection:c,amountLabel:o.amountLabel});return{...n,config:s.config,initialSpawns:us(br(a,s.layout,h)),projectionRows:d,bodyStyle:e=>fs(e,a,p,o),getBodyLabel:e=>ys(e,a),renderBodySVG:Cr,backgroundGraphics:ds(f,n.backgroundGraphics),foregroundGraphics:ds(y,n.foregroundGraphics)}}},qA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[760,420],s=mn({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:r});return{...n,config:s.config,initialSpawns:us(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ds(rs(s.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),n.foregroundGraphics),bodyStyle:ft(t||o.colorBy||"source")}}},XA={frameType:"physics",layout:OA,buildProps:(e,t,i,n,o)=>{const r=n.size??[700,380],s=Wr(n.theme),a=Zn({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Dr(s)??{},size:r,themeCategorical:s.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...n,config:a.config,initialSpawns:us(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??ft(t||o.colorBy),backgroundGraphics:ds(n.backgroundGraphics,a.result.backgroundOverlays),foregroundGraphics:ds(n.foregroundGraphics,a.result.overlays)}}},GA=(e,t,i)=>({x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}),VA=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),HA={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},UA=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,KA=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),ZA=e=>{const t=e.config.braid,i=e.dimensions.plot,n=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],o=t.groups.filter(e=>n.includes(e.partition)&&e.nodePath.length>0),r=[],s=[],a=[];if(0===o.length)return{sceneNodes:s,sceneEdges:r,labels:a};const c=new Set(o.map(e=>e.signature)),l=[...t.signatureOrder.filter(e=>c.delete(e)),...c],u=new Map(l.map((e,t)=>[e,t])),d=[...o].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=n.map(e=>d.filter(t=>t.partition===e)),p=Os(d),f=$t(p.map(e=>e.depth)),y=o.map(e=>$t(e.stepEntityCounts??[e.entityCount])),g=$t(y),m=e=>e>0?Math.max(1,10*e/g):0,x=new Map(o.map((e,t)=>[e.id,m(y[t])])),b=i.height/n.length,{semantic:v}=e.theme,w=(e,t,i,n={})=>a.push({x:e,y:t,text:i,fill:v.text??"#333",fontSize:10,anchor:"middle",...n}),k={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},A=new Map(p.map(e=>{const t=h.map(t=>t.reduce((t,i)=>t+(e.signatures.has(i.signature)?x.get(i.id)+3:0),5));return[e.id,$t(t,24)]})),S=$t([...A.values()],24),M=Math.min(i.width/4,S/2+16),_=(i.width-2*M)/Math.max(f-1,1),$=e=>i.x+M+(e-1)*_,P=48+S/2,j=22+S/2,I=(e,t)=>e+P+(u.get(t)+.5)*Math.max(0,b-P-j)/l.length,L=(t,i,n,o,s)=>{const a=UA(i,o),c=UA(i,s),l=m(a),u=m(c);if(0===l&&0===u)return;const d=l!==u,h=e.resolveColor(i.signature);r.push({type:"curved",id:n,pathD:d?Rs(t,l,u):Is(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:l},datum:{...k,id:n,kind:"braid-track",nodeId:i.nodePath[s],fromNodeId:i.nodePath[o],groupId:i.id,signature:i.signature,partition:i.partition,entityCount:i.entityCount,fromStep:o,toStep:s,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:i.nodePath.join(" → "),partition:i.partition??"all",fromStep:o+1,toStep:s+1,fromCount:a,toCount:c}})};return n.forEach((e,t)=>{const n=i.y+t*b,o=h[t];if(e&&w(i.x+8,n+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===o.length)return;for(let e=1;f>=e;e++)w($(e),n+34,"Step "+e);const r=/* @__PURE__ */new Map;for(const t of p){const i=o.filter(e=>t.signatures.has(e.signature));if(0===i.length)continue;const a=$(t.depth),c=tt([...t.signatures].map(e=>I(n,e))),l=Cs(i.map(e=>x.get(e.id)));r.set(t.id,new Map(i.map((e,t)=>[e.id,{x:a,y:c+l[t],offset:l[t]}])));const u=A.get(t.id),d={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;s.push({type:"glyph",id:h,cx:a,cy:c,size:u,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:HA,accent:v.border??"#888",style:{fill:v.surface??"#fff"},datum:{...k,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),w(a,c+u/2+12,t.state)}for(const t of o){const i=Ts(t.signature);for(let n=1;i.length>n;n++){const o=r.get(i[n-1]).get(t.id),s=r.get(i[n]).get(t.id),a=(o.x+s.x)/2-Math.sign(s.y-o.y)*s.offset;L(1e-8>Math.abs(o.y-s.y)?[o,s]:[o,{x:a,y:o.y},{x:a,y:s.y},s],t,`step:${e??"all"}:${i[n]}:${t.id}`,n-1,n)}}}),{sceneNodes:s,sceneEdges:r,labels:a,restyle:KA,restyleEdge:KA}},QA=Uv(require("react")),JA=e=>{const{forest:t,selection:i,reading:n="organize"}=e.config,{atlas:o}=t,r=e.dimensions.plot,s=e.theme.semantic.text??"#273442",a=e.config.colors?.backbone??e.theme.semantic.textSecondary??"#8995a3",c=e.config.colors?.residual??e.theme.semantic.warning??"#b66631",l=e.config.colors?.required??e.theme.semantic.primary??"#3983a5",u=i?.analysisRevision===o.analysisRevision&&"directed-admitted"===i.relationScopeId&&o.source.nodes.some(e=>e.id===i.nodeId)?i.nodeId:void 0,d=/* @__PURE__ */new Map;for(const i of t.order)if(e.config.collapsedNodeIds?.includes(i)&&!d.has(i))for(const e of Es(t,i))e!==i&&d.set(e,i);const h=t.order.filter(e=>!d.has(e)),p=new Map(o.source.nodes.map(e=>[e.id,e])),f=/* @__PURE__ */new Map;for(const e of d.values())f.set(e,(f.get(e)??0)+1);const y=/* @__PURE__ */new Map;for(const e of o.source.edges){const t=d.get(e.source)??e.source;if(t===(d.get(e.target)??e.target)&&(e.source!==t||e.target!==t)){const i=y.get(t);i?i.push(e.id):y.set(t,[e.id])}}const g=[...o.sections.sectionIds];o.source.nodes.some(e=>!e.sectionId)&&g.push("Unsectioned");const m=new Map(o.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),x=g.map(e=>h.filter(t=>m.get(t)===e)),b=/* @__PURE__ */new Map,v=[],w=[],k=[],A=[],S=(e,t,i,n=11)=>v.push({x:e,y:t,text:i,fill:s,anchor:"middle",fontSize:n}),M=Math.max(16,Math.min(94,r.width/Math.max(1,g.length)-20));x.forEach((e,t)=>{const i=r.x+r.width*(t+.5)/g.length;S(i,r.y+18,g[t],12),e.forEach((t,n)=>{b.set(t,{x:i,y:r.y+58+(n+.5)*Math.max(40,r.height-110)/Math.max(1,e.length)})})});for(const t of h){const i=b.get(t),n=p.get(t),r=f.get(t)??0,s=y.get(t)??[],d=o.requiredPaths?.unreachableNodeIds.includes(t),h=n.completeness&&"known"!==n.completeness,g=h?"Unknown upstream":d?"Unreachable from roots":void 0;w.push({type:"glyph",id:t,cx:i.x,cy:i.y,size:34,glyph:{viewBox:[M,34],parts:[{d:`M6,0 H${M-6} Q${M},0 ${M},6 V28 Q${M},34 ${M-6},34 H6 Q0,34 0,28 V6 Q0,0 6,0 Z`,stroke:"accent"}]},accent:u===t?l:h?c:a,style:{fill:e.theme.semantic.surface??"#fff",strokeWidth:u===t?2.5:1},label:t,datum:{...n,nodeId:t,kind:"dependency-node",sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",hiddenCount:r,internalEdgeIds:s},accessibleDatum:{node:t,section:m.get(t),status:g??"Admitted",hiddenCount:r,internalEdges:s.join(", ")}}),S(i.x,i.y+4,r?`${t} +${r}`:t,12),g?S(i.x,i.y+30,g,9):r&&S(i.x,i.y+30,s.length+" internal links",9)}const _=new Set(t.forest.backboneEdgeIds),$=new Set(e.config.highlightedEdgeIds),P=/* @__PURE__ */new Map;for(const e of o.source.edges){const t=d.get(e.source)??e.source,i=d.get(e.target)??e.target;if(t===i&&(e.source!==t||e.target!==i))continue;const n=b.get(t),s=b.get(i),u=JSON.stringify([t,i]),h=12*(P.get(u)??0);P.set(u,(P.get(u)??0)+1);const p=_.has(e.id),f=$.has(e.id)?l:p?a:c,y=s.x>n.x,m=n.x+(y?M/2:-M/2),x=s.x+(y?-M/2:M/2),v=[...b.values()].filter(e=>e.x>Math.min(n.x,s.x)&&Math.max(n.x,s.x)>e.x);let w,S;if(t===i)w=`M${n.x-14},${n.y-17} C${n.x-35-h},${n.y-64-h} ${n.x+35+h},${n.y-64-h} ${n.x+14},${n.y-17}`,S=1;else if(n.x===s.x){const e=s.y>n.y?1:-1,t=n.x+e*M/2,i=t+e*(32+h);w=`M${t},${n.y} C${i},${n.y} ${i},${s.y} ${t},${s.y}`,S=1===e?2:0}else if(v.length){const e=Math.min(n.y,s.y,...v.map(e=>e.y))-17-26-h,t=(r.width/g.length-M)/2*(y?1:-1);w=`M${m},${n.y} C${m+t},${n.y} ${m},${e} ${m+t},${e} H${x-t} C${x},${e} ${x-t},${s.y} ${x},${s.y}`,S=y?0:2}else if(y){const e=(m+x)/2;w=`M${m},${n.y} C${e},${n.y-h} ${e},${s.y-h} ${x},${s.y}`,S=0}else{const e=Math.min(n.y,s.y)-48-h;w=`M${m},${n.y} C${m-25},${e} ${x+25},${e} ${x},${s.y}`,S=2}k.push({type:"curved",id:e.id,pathD:w,style:{stroke:f,strokeWidth:$.has(e.id)?3:p?1.3:2,fill:"none"},datum:{...e,sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",kind:"dependency-edge",edgeClass:p?"backbone":"residual"},accessibleDatum:{edge:e.id,source:e.source,target:e.target,display:p?"backbone":"residual cross-link"}}),A.push(QA.createElement("path",{key:"arrow:"+e.id,"data-dependency-edge":e.id,"data-source":e.source,"data-target":e.target,d:"M-6,-3 L0,0 L-6,3",fill:"none",stroke:f,transform:`translate(${t===i?n.x+14:n.x===s.x?n.x+(s.y>n.y?M/2:-M/2):x},${t===i?n.y-17:s.y}) rotate(${90*S})`}))}if("required-paths"===n&&u){const e=Fs(t,u),i=[...new Set(e.map(e=>d.get(e)??e))].filter(e=>e!==u&&b.has(e));if(i.length){const e=i.map(e=>b.get(e)),t=Math.max(...e.map(e=>e.x))+M/2+8,n=Math.min(...e.map(e=>e.y))-23,o=Math.max(...e.map(e=>e.y))+23;A.push(QA.createElement("path",{key:"required-bracket",d:`M${t-7},${n} H${t} V${o} H${t-7}`,fill:"none",stroke:l,strokeWidth:2,"data-kind":"dominator-bracket"}))}S(r.x+r.width/2,r.y+r.height-16,e.length?`${u} lies on all admitted paths to ${e.join(", ")}${"incomplete"===o.requiredPaths?.status?" · incomplete scope":""}`:o.requiredPaths?u+": no other required targets in the admitted graph":"Required paths have not been prepared")}const j=new Map(w.map(e=>[e.id,e.datum]));return{sceneNodes:w,sceneEdges:k,labels:v,restyle:(e,t)=>({opacity:t?.isActive&&!t.predicate(e.datum)?.2:1}),restyleEdge:(e,t)=>({opacity:t?.isActive&&![e.datum,j.get(e.datum?.source+""),j.get(e.datum?.target+"")].some(e=>e&&t.predicate(e))?.2:1}),overlays:QA.createElement("g",{"aria-hidden":!0},A)}},eS=Uv(require("react")),tS=Uv(require("react")).createElement,iS={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"},nS=e=>null===e?"unmeasured":1e6>e?1e3>e?e+"":Number((e/1e3).toFixed(1))+"k":Number((e/1e6).toFixed(2))+"m",oS={stage:"M-5,0 H5",distributor:"M-5,0 H0 M0,0 L6,-5 M0,0 H6 M0,0 L6,5",queue:"M-6,-5 V5 H6 V-5 M-3,2 H3",retry:"M-5,2 A5,5 0 1,1 4,3 M4,-1 V4 H0","join-all":"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M2,-5 V5",selector:"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M1,-4 L5,0 L1,4",dependency:"M-5,-5 H5 V5 H-5 Z M-2,-2 L2,2 M-2,2 L2,-2",junction:"M0,-6 L6,0 L0,6 L-6,0 Z"},rS={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"},sS=e=>null===e?"unmeasured":e+"",aS=eS.createElement,cS=e=>{const{circuit:t,edition:i,reading:n,selection:o}=e.config;if(n.editionId!==i.id||i.analysisRevision!==t.atlas.analysisRevision)throw Error("Circuit render inputs must share an edition and analysis revision");const r=Ns(t,e.dimensions.width,e.dimensions.height),s=e.theme.semantic.text??"#273442",a=e.theme.semantic.surface??"#fff",c=Ds(e.theme.semantic,e.config.colors),l="modeled"===i.kind?c.modeled:c.observed,u={width:r.width,height:r.height,viewBox:`0 0 ${r.width} ${r.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":!0},d=o?.analysisRevision===t.atlas.analysisRevision&&"directed-admitted"===o.relationScopeId?o.nodeId:void 0,h=Math.max(1,...n.entry.flows.map(e=>e.perSecond??0)),p=new Map(n.entry.flows.map(e=>[e.edgeId,e])),f=new Map(t.modules.map(e=>[e.nodeId,Ys(t,i,n,e)])),y=t=>e.config.layoutSelection?.isActive&&!e.config.layoutSelection.predicate(f.get(t))?.2:1,g=Math.max(0,Math.min(200,Math.floor(e.config.particleBudget??24))),m=kt(e.config.placementSeed??1),x=r.routes.filter(e=>(p.get(e.edgeId)?.perSecond??0)>0),b=e.config.reducedMotion?[]:Array.from({length:x.length?g:0},(e,t)=>{const i=x[t%x.length],o=zs(i.points,(m()+n.requestedTime/10)%1);return aS("circle",{key:"cue:"+t,cx:o.x,cy:o.y,r:2.3,fill:s,opacity:Math.max(y(i.source),y(i.target)),"data-circuit-particle":i.edgeId})}),v=r.modules.map(e=>({id:e.module.nodeId,x:e.x+e.width/2,y:e.y+e.height/2,fixedPosition:{x:e.x+e.width/2,y:e.y+e.height/2},shape:{type:"aabb",width:e.width,height:e.height},bodyCollisions:!1,datum:Ys(t,i,n,e.module)}));return{bodies:v,config:{kernel:{gravity:{x:0,y:0},seed:e.config.placementSeed??1,sleepAfter:.01},bodyBudget:!1,bodyLimit:v.length,eviction:!1,sediment:!1,settleStepLimit:4},bodyStyle:e=>({fill:a,stroke:c.muted,strokeWidth:1,opacity:y(e.id)}),colliders:r.modules.flatMap(e=>Ln({idPrefix:"queue:"+e.module.nodeId,left:e.queue.x,right:e.queue.x+e.queue.width,top:e.queue.y,bottom:e.queue.y+e.queue.height,thickness:1,openEnds:!0})),sensors:r.modules.map(e=>({id:"sensor:"+e.module.nodeId,shape:{type:"aabb",x:e.sensor.x+e.sensor.width/2,y:e.sensor.y+e.sensor.height/2,width:e.sensor.width,height:e.sensor.height}})),semanticItems:qs(t,r,i,n),backgroundOverlays:aS("svg",u,...r.routes.map(t=>{const i=p.get(t.edgeId),n=t.points[t.points.length-1],o=t.points[t.points.length-2],a=r.modules.find(e=>e.module.nodeId===t.source),u=r.modules.find(e=>e.module.nodeId===t.target),d=a.module.ports.filter(e=>"out"===e.direction).length<u.module.ports.filter(e=>"in"===e.direction).length,f=d?t.points[0]:n,g=d?f.x>=a.x+a.width:f.x>u.x,m=180*Math.atan2(n.y-o.y,n.x-o.x)/Math.PI,x=e.config.highlightedEdgeIds?.includes(t.edgeId),b=x?s:t.residual?c.residual:l,v="records"===i.unit?"rec":"attempts"===i.unit?"att":"roots";return aS("g",{key:t.edgeId,"data-circuit-edge":t.edgeId,opacity:Math.max(y(t.source),y(t.target)),"data-source":t.source,"data-target":t.target,"data-flow":i.perSecond??"unmeasured","data-highlighted":x||void 0,"data-unit":i.unit+"/s"},aS("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),aS("path",{d:t.pathD,stroke:b,strokeWidth:null===i.perSecond?1.5:1+i.perSecond/h*7,strokeDasharray:null===i.perSecond?"4 3":void 0,strokeLinejoin:"round",fill:"none",opacity:0===i.perSecond?.35:.75}),aS("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${n.x},${n.y}) rotate(${m})`,fill:"none",stroke:b}),aS("text",{x:f.x+(g?5:-5),y:f.y-7,textAnchor:g?"start":"end",fontSize:8,fill:s},`${null===i.perSecond?"?":nS(i.perSecond)} ${v}/s`))})),overlays:aS("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":n.observedAt},...r.sections.map(e=>aS("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:s},e.id)),...Bs(r,n,l,s,d,c,y),...b,Ws(r,i,n,l,s,d),aS("text",{x:r.width/2,y:r.height-8,textAnchor:"middle",fontSize:9,fill:s},`${"modeled"===i.kind?"Modeled":"Observed"} · ${n.observedAt}s · pipe width = transferred volume/s · individual timings unavailable`))}},lS=()=>null,uS=Xs(ek,function({atlas:e,linkedHover:t,...i},n=Ps(e)){return{...i,linkedHover:gs(t),title:i.title??e.spec.dataRevision,description:i.description??"Motif Braid. Labeled squares show successive journey steps; parallel strands split at diverging prefixes and taper with per-step traffic.",summary:i.summary??`${n.groups.length} supported journey groups. Counts use ${e.spec.motifs.countUnit}; overlapping motifs do not partition the population. Source revision: ${e.provenance.sourceRevision}.`,accessibleTable:i.accessibleTable??!0,nodes:n.sceneSeeds.nodes,edges:n.sceneSeeds.edges,layout:ZA,layoutConfig:{braid:n}}},[600,400]),dS=Xs(ek,function({width:e=920,height:t=440,title:i="Dependency X-Ray",description:n,summary:o,accessibleTable:r=!0,chartId:s,className:a,onObservation:c,linkedHover:l,linkedSelection:u,annotations:d,frameProps:h,onSelectNode:p,...f}){return{nodes:f.forest.sceneSeeds.nodes,edges:f.forest.sceneSeeds.edges,layout:JA,layoutConfig:f,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:s,className:a,onObservation:c,linkedHover:gs(l),selection:u,annotations:d,frameProps:h,animate:!1,margin:{top:12,right:24,bottom:12,left:12},description:n??`Sections organize the admitted directed graph. Backbone links organize the drawing; residual links retain other original edges. Brackets describe required paths, separately from transport. Roots: ${f.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Completeness: ${f.forest.atlas.requiredPaths?.status??"not prepared"}.`,summary:o??`Roots: ${f.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Required-path completeness: ${f.forest.atlas.requiredPaths?.status??"not prepared"}. ${f.forest.residual.originalEdgeIds.length} original edges retained.`,accessibleTable:r}},[920,440],{top:12,right:24,bottom:12,left:12}),hS=Xs(XA,function({width:e=980,height:t=860,title:i,description:n,summary:o,accessibleTable:r=!0,chartId:s,className:a,onObservation:c,linkedHover:l,annotations:u,frameProps:d,linkedSelection:h,onSelectNode:p,...f}){return{key:JSON.stringify([f.circuit.atlas.analysisRevision,f.circuit.order,f.circuit.backboneEdgeIds,e,t]),data:f.circuit.modules.map(e=>Ys(f.circuit,f.edition,f.reading,e)),layout:cS,layoutConfig:f,width:e,height:t,chartId:s,className:a,onObservation:c,linkedHover:gs(l),annotations:u,frameProps:d,paused:!0,title:i??f.edition.label,description:n??`${f.edition.label}. ${f.edition.kind} aggregate interval tape at ${f.reading.observedAt} seconds. Pipe widths encode transferred volume per second in their labeled units; module readouts separate completions, capacity and queue stock. Individual timings are unavailable.`,summary:o??f.edition.assumptions.join(" "),accessibleTable:r,tooltip:!!(s||l||c)&&lS}},[980,860]),pS=Uv(require("react")),fS=Object.freeze([]),yS={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},gS=2,mS="__forecastSegment",xS="__forecastOpacity",bS="__semiotic_resolvedX",vS="__semiotic_resolvedY",wS="__compoundGroup",kS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Na({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Wr(n.theme).colors.categorical}),s=ha(r.annotations,o.regression);return{chartType:"scatter",data:r.data,xAccessor:r.xAccessor,yAccessor:r.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...n,...s&&s.length>0&&{annotations:s},...r.yExtent&&!n.yExtent&&{yExtent:r.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:n.pointStyle||za(e,t,i,n,o),showLegend:n.showLegend??!!t}}},AS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=ha(n.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...n,...r&&{annotations:r},pointStyle:n.pointStyle||Wa(e,t,i,n,o),showLegend:n.showLegend??!!t}}},SS=(require("react"),"__semioticSelectionData"),MS=Uv(require("react")),_S=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),$S=require("react/jsx-runtime"),PS={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,i,n,o)=>{const r=Ja(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineBy:o.lineBy,rankDirection:o.rankDirection,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0}),s=Math.max(1,r.seriesOrder.length),a=Wr(n.theme),c=Qa({seriesOrder:r.seriesOrder,overallOrder:r.overallOrder,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0,color:"string"==typeof o.color?o.color:void 0,colorScheme:i,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,themeCategorical:a.colors.categorical,themeNeutral:a.colors.textSecondary}),l={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:r.valueExtent,seriesOrder:r.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,color:"string"==typeof o.color?o.color:void 0,colorMap:c&&"object"==typeof c&&!Array.isArray(c)?c:void 0,stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0,styleRules:o.styleRules,areaStyle:n.areaStyle,pointStyle:n.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0},u=n.xFormat,d=(e,t)=>{if(0===r.xValues.length)return"";const i=r.xValues[Math.max(0,Math.min(r.xValues.length-1,Math.round(Number(e))))];return u?u(i,t):(i instanceof Date?i.toLocaleDateString():i)+""},h=r.xValues.map((e,t)=>t),p=Array.from({length:s},(e,t)=>t+1),f=n.axes??[{orient:"left",tickValues:p,tickFormat:e=>e+"",label:n.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:n.xLabel,tickAnchor:"edges"}];return{...n,chartType:"custom",data:r.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,r.xValues.length-1)],yExtent:[s+.5,.5],customLayout:uc,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:f,axisExtent:"exact",showAxes:n.showAxes??!0,showLegend:n.showLegend??!1,annotations:Za(n.annotations,r.xValues)}}},jS="__ma_unitized",IS="__ma_series",LS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Array.isArray(o.series)?o.series:[],a=dc(s,i,Wr(n.theme).colors.categorical),c=2===s.length,l=s.map(e=>e.extent||pc(r,e.yAccessor)),u=[];for(const e of r)s.forEach((t,i)=>{const n=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==n||!Number.isFinite(Number(n)))return;const o=Number(n),r=l[i],s=r[1]-r[0]||1;u.push({...e,[jS]:c?(o-r[0])/s:o,[IS]:t.label||"Series "+(i+1)})});const d=(e,t)=>i=>{const n=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(n):Number.isInteger(n)?n+"":n.toFixed(1)},h=c?[{orient:"left",label:s[0].label,tickFormat:d(l[0],s[0].format)},{orient:"right",label:s[1].label,tickFormat:d(l[1],s[1].format)},{orient:"bottom"}]:void 0,p=/* @__PURE__ */new Map;s.forEach((e,t)=>{p.set(e.label||"Series "+(t+1),a[t])});const f=Ks(Zs({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>p.get((e[IS]??"")+"")||a[0],styleRules:o.styleRules,ruleContext:hc(o.xAccessor,s)}),{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:jS,groupAccessor:IS,colorAccessor:IS,...h&&{axes:h},...c&&{yExtent:[0,1]},...n,curve:o.curve||n.curve||"monotoneX",showLegend:n.showLegend??!0,colorScheme:a,lineStyle:f}}},RS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.xAccessor||"x",a="function"==typeof s?s:e=>e[s],c=r.some(e=>{const t=a(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),l=c?r.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:(a(e)??t)+""})):r,u=o.styleRules?ut(void 0,o.styleRules,ot(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{const t=u(e),i="function"==typeof n.areaStyle?n.areaStyle(e):n.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:l,xAccessor:c?"__waterfallX":s,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...n,...d&&{areaStyle:d},...c&&{axes:n.axes??[{orient:"bottom",tickValues:l.map((e,t)=>t)}],xFormat:e=>{const t=r[Number(e)]?a(r[Number(e)]):e,i=o.xFormat??n.xFormat;return"function"==typeof i?i(t):(t??e)+""}}}}},CS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.lineBy,s=o.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",c=Wr(n.theme).colors.categorical,l=fc(e,r,i,n,o),u=Na({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:r,colorScheme:i,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:n.annotations,themeCategorical:c,baseLineStyle:l}),d=n.pointStyle||gc(u.data,u.colorAccessor,i,n,o);let h=n.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const p=(!o.directLabel||void 0!==n.showLegend)&&(n.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||l,...Array.isArray(s)&&{areaGroups:s},...s&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...n,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!n.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:p}}},TS={frameType:"xy",layout:{margin:(e,t)=>ya(t.marginDefaults,fa(e),t.showAxes,!!t.title)},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[],s=o.timeAccessor||"time",a=o.valueAccessor||"value",c=o.categoryAccessor,l=Ba(r,n,o,"explicit-then-alpha"),u=o.valueExtent||n.yExtent,d={...da(o),...void 0!==o.cursor&&{cursor:o.cursor}},h={...d,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap}},p=ut(void 0,o.styleRules,e=>{const t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,n=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(n)&&Number.isFinite(o)?(n+o)/2:void 0,y:i,category:null==e.category?void 0:e.category+""}});return{chartType:"bar",data:r,...n,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,r.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>Gs(e,s,"time")??NaN,valueAccessor:e=>Gs(e,a,"value")??NaN,xExtent:o.timeExtent||n.xExtent,yExtent:u,invertY:"down"===o.direction,axes:fa({...o,axes:n.axes??o.axes}),extentPadding:o.extentPadding??n.extentPadding,binSize:o.binSize,categoryAccessor:c,barColors:l||n.barColors,colorScheme:l||n.colorScheme,barStyle:n.barStyle||h,areaStyle:n.areaStyle||(e=>({...p(e),...!c&&void 0!==o.fill&&{fill:o.fill},...d})),showLegend:n.showLegend??!!c}}},OS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s=Na({data:Array.isArray(e)?Hs(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Wr(n.theme).colors.categorical}),a=Vs({data:e,safeData:s.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),c=ra(o.semanticGradient),l=c?.stops.length?{stops:c.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:na(n.gradientFill),u=!1!==o.semanticLine?sa(c):void 0,d=n.pointStyle||gc(a,r,i,n,o);return{chartType:"area",data:a,xAccessor:s.xAccessor,yAccessor:s.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:r,colorScheme:i,...n,...s.annotations.length>0&&{annotations:s.annotations},...s.yExtent&&!n.yExtent&&{yExtent:s.yExtent},...void 0!==l&&{gradientFill:l},...u&&{semanticLineStops:u},lineStyle:n.lineStyle||yc(a,r,i,n,o),...d&&{pointStyle:d}}}},ES={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.xAccessor||"x",s=o.seriesAAccessor||"a",a=o.seriesBAccessor||"b",c=e=>la(ca(r,"x",e)),l=e=>la(ca(s,"a",e)),u=e=>la(ca(a,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",p=o.areaOpacity??.6,f=o.lineWidth??1.5,y=!1!==o.showLines,g=!1!==n.showLegend,m=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=n.legendPosition||"right",v=Qs(Array.isArray(e)?e:[],c,l,u),w=[];if(y&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),i=l(e),n=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(n)&&w.push({__x:t,__y:n,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}return{chartType:"mixed",data:[...v,...w],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:ta({seriesAColor:d,seriesBColor:h,areaOpacity:p,styleRules:o.styleRules}),lineStyle:ia({seriesAColor:d,seriesBColor:h,lineWidth:f,styleRules:o.styleRules}),curve:o.curve||"linear",...n,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},FS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s="string"==typeof r&&Array.isArray(e)?Yn(e,r,i):void 0,a="number"==typeof o.areaOpacity?o.areaOpacity:.7,c=n.lineStyle||(e=>{const t=null==r?void 0:Bn(e,r,s),i=o.showLine??!0,n={fill:o.color??t,stroke:i?o.stroke??t:"none",...i?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:a,...null==o.opacity?{}:{opacity:o.opacity}},c=o.styleRules;if(c?.length){const t=nt(o.yAccessor),i=r?"function"==typeof r?(r(e)??"")+"":(e[r]??"")+"":void 0;Object.assign(n,lt(e,c,{value:t(e),category:i}))}return n}),l=o.normalize?"zero":o.baseline??"zero",u=n.pointStyle||gc(e,r,i,n,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:r,colorScheme:i,normalize:o.normalize,baseline:l,stackOrder:o.stackOrder,lineStyle:c,...n,...u&&{pointStyle:u},curve:n.curve??o.curve??"monotoneX",showLegend:n.showLegend??!!r}}},NS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const[r]=n.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...n,...!n.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:ut(void 0,o.styleRules,ot(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:n.scalePadding??Math.max(2,Math.min(12,Math.round(r/40))),extentPadding:n.extentPadding??(r>200?.1:.02)}}},zS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.xCenter,s=o.yCenter,a=o.quadrants,c=o.centerlineStyle||{},l=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=c.stroke||"#999",h=c.strokeWidth??1,p=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,f=pS.createElement,y=a?[(e,t,i)=>{if(!t?.x||!t?.y)return null;const n=i.width,o=i.height,c=null!=r?t.x(r):n/2,y=null!=s?t.y(s):o/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(n,c)),m=Math.max(0,Math.min(o,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:n-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:o-m},{c:a.bottomRight,x:g,y:m,w:n-g,h:o-m}],b=l?[f("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),f("text",{key:"ltr",x:n-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),f("text",{key:"lbl",x:8,y:o-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),f("text",{key:"lbr",x:n-8,y:o-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return f(pS.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?f("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),f("line",{key:"vc",x1:g,y1:0,x2:g,y2:o,stroke:d,strokeWidth:h,strokeDasharray:p}),f("line",{key:"hc",x1:0,y1:m,x2:n,y2:m,stroke:d,strokeWidth:h,strokeDasharray:p}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:i,pointStyle:n.pointStyle||o.pointStyle||za(e,t,i,n,o),...n,showLegend:n.showLegend??!!t,...y&&{svgPreRenderers:y}}}},DS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=pa(e,o),s=Na({data:r.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Wr(n.theme).colors.categorical}),a=ha(s.annotations,o.regression),c=o.pointRadius??4,l=ot(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{const t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;const i=[];for(let e=0;t.length-1>e;e++){const n=t[e],o=t[e+1],r=ua(e,t.length);100>t.length&&i.push(pS.createElement("line",{key:"halo-"+e,x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:c+2,strokeLinecap:"round",opacity:.5})),i.push(pS.createElement("line",{key:"segment-"+e,x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:r,strokeWidth:c,strokeLinecap:"round"}))}return pS.createElement(pS.Fragment,null,...i)}];return{chartType:"scatter",data:s.data,xAccessor:s.xAccessor,yAccessor:s.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Ks(e=>{const t=r.orderMap.get(e),i=t?.idx??0,n=t?.total??1,o={fill:n>0?ua(i,n):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1};return u?.length&&Object.assign(o,lt(e,u,l(e))),o},da(o)),...n,...a&&a.length>0&&{annotations:a},...s.yExtent&&!n.yExtent&&{yExtent:s.yExtent},svgPreRenderers:d}}},BS=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,i=e._mean-this._mean;this._mean+=i*e._count/t,this._m2+=e._m2+i*i*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t.merge(this),t}get count(){return this._count}get mean(){return this._mean}get sum(){return this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},WS=class e{constructor(e=10){const t=Math.max(4,Math.min(16,Math.floor(e)));this.p=t,this.m=1<<t,this.registers=new Uint8Array(this.m),this.alpha=.7213/(1+1.079/this.m),this.harmonicSum=this.m,this.zeros=this.m}add(e){const t=mc(e+""),i=t>>>32-this.p,n=Math.min(Math.clz32(t<<this.p),32-this.p)+1;this.updateRegister(i,n)}updateRegister(e,t){const i=this.registers[e];t>i&&(this.registers[e]=t,this.harmonicSum+=2**-t-2**-i,0===i&&this.zeros--)}merge(e){if(e.m===this.m)for(let t=0;this.m>t;t++)this.updateRegister(t,e.registers[t])}clone(){const t=new e(this.p);return t.registers.set(this.registers),t.harmonicSum=this.harmonicSum,t.zeros=this.zeros,t}count(){const e=this.alpha*this.m*this.m/this.harmonicSum;return Math.round(2.5*this.m>=e&&this.zeros>0?this.m*Math.log(this.m/this.zeros):e)}},YS=class e{constructor(e=100){this.centroids=[],this.total=0,this.pending=0,this.compression=Math.max(20,e)}push(e){Number.isFinite(e)&&(this.centroids.push({mean:e,weight:1}),this.total+=1,this.pending++,2*this.compression>this.pending||this.compress())}merge(e){if(0===e.total)return;const t=0===this.total,i=e.centroids.length;for(let t=0;i>t;t++)this.centroids.push({...e.centroids[t]});this.total+=e.total,this.pending=t&&this.compression===e.compression?e.pending:this.pending+i,t||this.compress()}clone(){const t=new e(this.compression);return t.merge(this),t}quantile(e){if(0===this.total||Number.isNaN(e))return NaN;const t=Math.min(1,Math.max(0,e));this.compress();const i=t*this.total;let n=this.centroids[0].weight/2;if(n>=i)return this.centroids[0].mean;for(let e=1;this.centroids.length>e;e++){const t=this.centroids[e-1],o=this.centroids[e],r=(t.weight+o.weight)/2,s=n+r;if(s>=i)return t.mean+(i-n)/r*(o.mean-t.mean);n=s}return this.centroids[this.centroids.length-1].mean}get count(){return this.total}compress(){if(0===this.pending)return;if(this.pending=0,1>=this.centroids.length)return;this.centroids.sort((e,t)=>e.mean-t.mean);let e=0,t=0;const i=this.total,n=this.compression;for(let o=1;this.centroids.length>o;o++){const r=this.centroids[e],s=this.centroids[o],a=(t+r.weight/2)/i;if(r.weight+s.weight>Math.max(1,4*i*a*(1-a)/n))t+=r.weight,this.centroids[++e]=s;else{const e=r.weight+s.weight;r.mean=(r.mean*r.weight+s.mean*s.weight)/e,r.weight=e}}this.centroids.length=e+1}},qS=(e,t)=>e-t,XS=class{constructor(e,t){this.stats=new BS,this.digest=e?new YS:null,this.hll=t?new WS:null}push(e,t){this.stats.push(e),this.digest?.push(e),this.hll&&this.hll.add(t??e)}merge(e){this.stats.merge(e.stats),this.digest?.merge(e.digest),this.hll?.merge(e.hll)}},GS=class{constructor(e){this.windows=/* @__PURE__ */new Map,this.starts=[],this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0,this.percentiles=e.percentiles??[],this.wantDistinct=!0===e.distinct}newBucket(){return new XS(this.percentiles.length>0,this.wantDistinct)}push(e,t,i){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t,i):this.pushFixed(e,t,i),this.prune())}pushFixed(e,t,i){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t,i);const n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t,i)}bump(e,t,i){let n=this.windows.get(e);if(!n){if(this.windows.size>=this.retain&&this.starts[0]>e)return;n=this.newBucket(),this.windows.set(e,n),this.retain!==1/0&&bc(this.starts,e,qS)}n.push(t,i)}pushSession(e,t,i){const n=e-this.gap,o=e+this.gap;let r=0,s=this.sessions.length;const a=this.sessions[s-1];if(a&&a.end>e)for(;s>r;){const e=r+s>>>1;n>this.sessions[e].end?r=e+1:s=e}else r=s,!a||n>a.end||a.start>o||r--;const c=this.sessions[r];if(!c||c.start>o){const n=this.newBucket();return n.push(t,i),void this.sessions.splice(r,0,{start:e,end:e,bucket:n})}c.bucket.push(t,i),c.start=Math.min(c.start,e),c.end=Math.max(c.end,e);let l=r+1;for(;this.sessions.length>l&&o>=this.sessions[l].start;){const e=this.sessions[l++];c.bucket.merge(e.bucket),c.end=Math.max(c.end,e.end)}l>r+1&&this.sessions.splice(r+1,l-r-1)}prune(){if(this.retain!==1/0)if("session"!==this.type)for(;this.windows.size>this.retain;)this.windows.delete(vc(this.starts,qS));else this.sessions.length>this.retain&&this.sessions.splice(0,this.sessions.length-this.retain)}emit(){if("session"===this.type)return this.sessions.map(e=>this.row(e.start,e.end,e.bucket,this.gap>this.latest-e.end));const e=[];for(const[t,i]of this.windows){const n=t+this.size;e.push(this.row(t,n,i,n>this.latest))}return e.sort((e,t)=>e.start-t.start),e}row(e,t,i,n){const o=i.stats,r={start:e,end:t,count:o.count,mean:o.mean,sum:o.sum,min:o.min,max:o.max,stddev:o.stddev,partial:n};if(i.digest){const e={};for(const t of this.percentiles)e[xc(t)]=i.digest.quantile(t);r.percentiles=e}return i.hll&&(r.distinct=i.hll.count()),r}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.starts=[],this.sessions=[],this.latest=-1/0}},VS={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},HS=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,US="time",KS="value",ZS="__aggLower",QS="__aggUpper",JS="__aggPartial",eM="count",tM="__aggStart",iM="__aggEnd",nM="__aggSeries",oM=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){const n=Gs(e,t,"time"),o=Gs(e,i,"value");if(null==n||null==o)return;const r=null==this.seriesAccessor?"":("function"==typeof this.seriesAccessor?this.seriesAccessor(e):e[this.seriesAccessor])+"";let s=this.groups.get(r);if(!s){if(s=Sc(this.config),!s)return;this.groups.set(r,s)}s.push(n,o)}emit(e){const t=[];for(const[i,n]of this.groups)for(const o of Mc(n,e))t.push(null==this.seriesAccessor?o:{...o,[nM]:i});return t}clear(){this.groups.clear()}},rM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,s=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,a=ut(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:s}),o.styleRules,$c(o.xAccessor,o.yAccessor,o.valueAccessor)),c=("string"==typeof r?.colorScheme?r.colorScheme:void 0)??i,l=null!=r&&Object.hasOwn(r,"heatmapColorScale"),u=r?.heatmapColorScale,d=l?"function"==typeof u?u:void 0:"custom"===c&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:a,...n,...void 0!==c&&{colorScheme:c},...d&&{heatmapColorScale:d}}}},sM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=jc(e,o),s=o.aggregate,a=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:Ic(o),c=ut(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,ot(a.timeAccessor,a.valueAccessor));return{chartType:"line",data:r,...n,...Lc(r,n,o),...a,groupAccessor:s&&null!=o.seriesAccessor?nM:o.seriesAccessor,...s&&{windowMode:"growing",windowSize:Math.max(1,s.retain??Math.max(r.length,600)),band:(l=s,"none"!==(l.band??"none")?{y0Accessor:ZS,y1Accessor:QS,perSeries:null!=o.seriesAccessor}:void 0)},lineStyle:n.lineStyle||(e=>({...c(e),...da(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))};var l}},aM={...TS,buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[];return{...TS.buildProps(r,t,i,n,o),...Lc(r,n,o)}}},cM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[];return{...rM.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...Lc(r,n,o),categoryAccessor:o.categoryAccessor}}},lM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[],s=Ba(r,n,o,"discovery"),a=ut(void 0,o.styleRules,ot(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:r,...n,...Lc(r,n,o),categoryAccessor:o.categoryAccessor,colorScheme:s||i||n.colorScheme,barColors:s,yScaleType:o.yScaleType,swarmStyle:{...da(o),fill:o.fill,radius:o.radius,cursor:o.cursor},pointStyle:e=>({...a(e),..."function"==typeof o.pointStyle?o.pointStyle(e):{},..."function"==typeof n.pointStyle?n.pointStyle(e):n.pointStyle})}}},uM={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Hs(e):[],s=RS.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...s,...Lc(r,n,o),waterfallStyle:{...s.waterfallStyle,cursor:o.cursor}}}},dM=(require("react"),{RdBu:Hk,PiYG:Uk,PRGn:Kk,BrBG:Zk,RdYlBu:Qk,RdYlGn:Jk,Spectral:eA}),hM="__likert_neutral_neg",pM="__likert_neutral_pos",fM={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,i,n,r)=>{const s=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],a="vertical"!==r.orientation;let c=Tc(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s,Rc(r.categoryAccessor,"question"),r.levelAccessor?null:Rc(r.valueAccessor,"score"),r.levelAccessor?Rc(r.levelAccessor,"level"):null,r.levelAccessor?Rc(r.countAccessor,"count"):null,{category:"string"==typeof r.categoryAccessor?r.categoryAccessor:void 0,level:"string"==typeof r.levelAccessor?r.levelAccessor:void 0,count:"string"==typeof r.countAccessor?r.countAccessor:void 0,score:r.levelAccessor||"string"!=typeof r.valueAccessor?void 0:r.valueAccessor});a&&(c=Ec(Oc(c,s),s));const l=Wr(n.theme).colors.diverging,u=Array.isArray(i)&&i.length>=s.length?i:Cc(s.length,l),d=new Map(s.map((e,t)=>[e,u[t]||"#888"])),h=s.length%2&&d.get(s[Math.floor(s.length/2)])||"#888",p="function"==typeof r.valueFormat?r.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",f=o(!1===n.showLegend?void 0:{legendGroups:[{label:"",items:s.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},n.legend),y=r.styleRules,g=n.pieceStyle;return{chartType:"bar",data:c,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:r.barPadding,showGrid:n.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(a?void 0:"Percentage"),rFormat:p,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...n,pieceStyle:Ks((e,t)=>{const i=e.__likertLevel||e.data?.__likertLevel,n=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,r={fill:i===hM||i===pM?h:d.get((n||i)+"")||"#888"};return y?.length&&Object.assign(r,lt(e,y,{value:"number"==typeof o?o:void 0,category:t??(null==n?void 0:n+"")})),"function"==typeof g?Object.assign(r,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(r,g),r},da(r)),showLegend:n.showLegend??!0,legendPosition:n.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},yM=require("react/jsx-runtime"),gM=require("react/jsx-runtime"),mM={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const i=e.__gauge;if(!i)return null;const n=(i.startAngleDeg+(i.gMax===i.gMin?0:(Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin))-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,o=i.needleColor||t.colors.text,r=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&i.gMax>e.value):[];/* @__PURE__ */ /* @__PURE__ */
|
|
590
590
|
return(0,gM.jsxs)(gM.Fragment,{children:[i.showNeedle&&/* @__PURE__ */ /* @__PURE__ */(0,gM.jsxs)(gM.Fragment,{children:[
|
|
591
591
|
/* @__PURE__ */
|
|
592
592
|
/* @__PURE__ */(0,gM.jsx)("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(n),y2:i.centerY+i.needleLength*Math.sin(n),stroke:o,strokeWidth:2.5,strokeLinecap:"round"}),
|
|
@@ -596,13 +596,13 @@ return(0,gM.jsxs)("g",{children:[
|
|
|
596
596
|
/* @__PURE__ */
|
|
597
597
|
/* @__PURE__ */(0,gM.jsx)("line",{x1:i.centerX+Math.cos(o)*r,y1:i.centerY+Math.sin(o)*r,x2:i.centerX+Math.cos(o)*s,y2:i.centerY+Math.sin(o)*s,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),
|
|
598
598
|
/* @__PURE__ */
|
|
599
|
-
/* @__PURE__ */(0,gM.jsx)("text",{x:i.centerX+Math.cos(o)*a,y:i.centerY+Math.sin(o)*a,textAnchor:l,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+n)})]})},buildProps:(e,t,i,n,o)=>{const r=o.min??0,s=o.max??100,a=o.sweep??240,c=o.arcWidth??.3,l=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=qc(a),h=o.thresholds,p=oa(n.gradientFill),f=Yc({min:r,max:s,value:o.value,thresholds:h,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==o.showScaleLabels,gradientFill:p}),y=o.styleRules,[g,m]=n.size||[300,250],x=Xc(a),b=Math.min(10,Math.max(1,Math.min(g,m)/12)),v=Math.max(4,Math.min((g-2*b)/x.width,(m-2*b)/x.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-c))),k=g/2-x.cx*v,A=m/2-x.cy*v,S=2*(v+4),M=Math.max(r,Math.min(s,o.value??r)),_="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",$=o.centerContent??n.centerContent,P=null!=$?"function"==typeof $?$(M,r,s):$:"sparkline"===o.mode||"context"===o.mode?void 0:Fc({value:_,min:r,max:s,radius:v,showScaleLabels:!1!==o.showScaleLabels});return{chartType:"donut",data:f.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:Ks((e,t)=>{const i={...f.pieceStyle(e,t)};return y?.length&&Object.assign(i,lt(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},da(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...n,size:[g,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:g-k-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(n.annotations)?n.annotations:[],...f.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:l,needleColor:o.needleColor,..."context"===o.mode&&null==$&&{contextValue:_,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},xM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=ha(n.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,...r&&{annotations:r},gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,t,i,n,o)}}},bM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:r,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},vM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:r,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},wM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=nt(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:r,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...n,pieceStyle:Vc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)}),showLegend:n.showLegend??!!r}}},kM={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=nt(o.valueAccessor??"value");return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:n.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:r,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...n,pieceStyle:Vc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)})}}},AM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.valueAccessor||"value",a=r.map(e=>Number("function"==typeof s?s(e):e[s])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:s,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:c?{rExtent:c}:{},...n,summaryStyle:Hc(e,t,i,n,o,"count")}}},SM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...n,summaryStyle:Hc(e,t,i,n,o)})},MM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:i,...n,summaryStyle:Uc(e,t,i,n,o),showLegend:n.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},_M={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...n,sizeRange:o.sizeRange||[3,8],pieceStyle:Zc(e,t,i,n,o),showLegend:n.showLegend??!!t})},$M={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,n,o)=>{const r=ha(n.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...n,...r&&{annotations:r},pieceStyle:Kc(e,t,i,n,o),showGrid:n.showGrid??!0,showLegend:n.showLegend??!!t}}},PM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=o.seriesAccessor||t||"__radar",s=t||("__radar"===r?void 0:r),a=Kc(e,s,i,n,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:s,colorScheme:i,connectorAccessor:r,connectorStyle:e=>{const t=a(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:a,rExtent:o.valueExtent||[0],oLabel:"",...n,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:n.showLegend??!!s}}},jM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:r,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,r,i,n,o),showLegend:n.showLegend??!!r,barPadding:o.barPadding??40}}},IM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...n,summaryStyle:Hc(e,t,i,n,o,"median",.5),showLegend:n.showLegend??!!t})},LM={frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r="vertical"===o.orientation,s=t||o.categoryAccessor;return{chartType:r?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:s,categoryAccessor:o.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!r&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:r?40:0,colorScheme:i,...n,showAxes:r&&!1!==n.showAxes,showGrid:r,pieceStyle:Vc(e,s,i,n,o),showLabels:o.showLabels??!0}}},RM=require("d3-scale"),CM={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},TM=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),OM=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},EM=828*OM(8),FM=3e3,NM=/* @__PURE__ */new Map,zM=1e5,DM=1e-9,BM=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,WM=require("react/jsx-runtime"),YM="var(--semiotic-grid, #94a3b8)",qM="var(--semiotic-text-secondary, #475569)",XM="var(--semiotic-text-secondary, #94a3b8)",GM=.22,VM=e=>{const{bands:t=[],ribbons:i=[],showLabels:n=!0,selectionDatum:o="raw"}=e.config,r=e.selection??null,s=[];for(const e of i){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!Uu(t,r,o);s.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,GM):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!Uu({__kind:"band",data:e.rawDatum,id:e.id},r,o);for(let i=0;e.gradientStubs.length>i;i++){const n=e.gradientStubs[i];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?GM:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,...null!=n.y0&&{y0:n.y0},...null!=n.y1&&{y1:n.y1},from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),i={__kind:"band",data:e.rawDatum,id:e.id},n=!Uu(i,r,o);s.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:n?GM:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...n&&t?{opacity:GM}:{}},datum:i})}const a=n?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,n=t&&r?.isActive&&Uu({__kind:"band",data:e.rawDatum,id:e.id},r,o),s=i?e.labelText:n?e.labelFullText:"";return s.trim()?[{x:e.labelX,y:e.labelY,text:s,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:a}},HM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||n.nodeStyle||o.nodeStyle||Us(da(o))))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,...n,showLegend:(n.showLegend??!!t)&&!!t};const r=Array.isArray(o.edges)?o.edges:[],s=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:Zu([],r,o.sourceAccessor||"source",o.targetAccessor||"target"),a=zr(n.theme).colors.categorical,c=En(i,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,d=t?Dn(u,l,i??n.colorScheme??a):void 0,h=/* @__PURE__ */new Map,p=o.nodeIdAccessor||o.nodeIDAccessor||"id",f=(e,i)=>{const n=e?.data||e;let r;if(t)r=Nn(n,t,d);else{const t=(e.id??n?.[p]??"")+"";h.has(t)||h.set(t,h.size);const o=e.index??i??h.get(t);r=c[o%c.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=dt(o.styleRules,t,o.valueAccessor);return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,nodeStyle:Ks(o.nodeStyle||(y?(e,t)=>({...f(e,t),...y(e,t)}):f),da(o)),...n,showLegend:(n.showLegend??!!t)&&!!t}}},UM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=ed(o),s=zr(n.theme).colors.categorical,a=/* @__PURE__ */new Map,c=o.nodeStyle??(e=>({fill:t?Nn(e?.data||e,t,void 0):Ua(void 0,s,i,void 0,a),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),l=dt(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=Ks(l?(e,t)=>({...c(e),...l(e,t)}):c,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:u,edgeStyle:r,...n,showLegend:(n.showLegend??!!t)&&!!t}}},KM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=zr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Ku(e??null,o.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrCirclePackColorBy:c(e)})):a,u=c?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,d=t&&u?Dn(l,u,i??n.colorScheme??r):void 0,h=o.showLabels??n.showLabels,p=n.nodeStyle||o.nodeStyle,f=ut(e=>{const n=e?.data||e;return{fill:o.colorByDepth?rA[Number(e?.depth||0)%rA.length]:t?c?Nn({__ssrCirclePackColorBy:c(n)},"__ssrCirclePackColorBy",d??void 0):Nn(n,t,d??void 0):Ua(void 0,r,i,void 0,s),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,rt(t,o.valueAccessor),e=>e?.data||e);return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:i,...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:Ju(f,p,da(o))}}},ZM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=e??o.data,s=o.childrenAccessor||"children",a=o.nodeIdAccessor||o.nodeIDAccessor||"name",c=zr(n.theme).colors.categorical,l=i??n.colorScheme??c,u=En(l,c),d=Ku(r,s),h="__ssrOrbitColorBy",p="function"==typeof t?t:null,f=t?Dn(p?d.map(e=>({[h]:p(e)})):d,p?h:t,l):void 0,y=ut(e=>{const i=e.data||e,n=Number(e.depth??0);return{fill:o.colorByDepth?0===n?u[0]:rA[n%rA.length]:t?p?Nn({[h]:p(i)},h,f):Nn(i,t,f):u[0],stroke:"#fff",strokeWidth:1,opacity:0===n?1:.85}},o.styleRules,rt(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:r,childrenAccessor:s,nodeIDAccessor:a,colorBy:t,colorScheme:l,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?a:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:Ks(y,da(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},QM={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,i,n,r)=>{const s=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),a=r.sourceAccessor||"source",c=r.targetAccessor||"target",l=r.valueAccessor||"value",u=r.nodeIdAccessor||"id",d=r.startTimeAccessor||"startTime",h=r.endTimeAccessor||"endTime",p=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,y=r.xExtentAccessor||"xExtent",g=r.groupBy,m=r.edgeIdAccessor||"id",x=(e,t)=>"function"==typeof e?e(t):t[e],b=Array.isArray(r.edges)?r.edges:[],v=Array.isArray(r.nodes)?r.nodes:[],w=v.length>0?v:Zu([],b,a,c),k=[s(r.domain?.[0]),s(r.domain?.[1])],A=w.map(e=>{const t=x(u,e)+"",i=x(y,e),n=r.nodeLabel?x(r.nodeLabel,e):t,o={id:t,label:null==n?t:n+"",__raw:e},a=g?x(g,e):null;if(null!=a&&a+""!=""&&(o.group=a+""),Array.isArray(i)&&2===i.length){const e=s(i[0]),t=s(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),S=b.map((e,t)=>{const i=x(m,e),n={id:null!=i?i+"":`${x(a,e)}-${x(c,e)}-${t}`,source:x(a,e)+"",target:x(c,e)+"",value:Number(x(l,e)),startTime:s(x(d,e)),endTime:s(x(h,e)),__raw:e};if(p){const t=s(x(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(f){const t=s(x(f,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),[M,_]=n.size??[600,400],$=n.margin,P="vertical"===r.orientation?"vertical":"horizontal",j={...Gu(!!n.title,!!r.showQualityReadout,Array.isArray(r.axisTicks)&&r.axisTicks.length>0,P),...$},I=(n.showLegend??!!t)&&!!t,L=n.legendPosition??"right";I&&("right"===L?j.right=Math.max(j.right,140):"left"===L?j.left=Math.max(j.left,140):"top"===L?j.top=Math.max(j.top,50):"bottom"===L&&(j.bottom=Math.max(j.bottom,80)));const R=j,C=M-R.left-R.right,T=_-R.top-R.bottom,O=En(i,zr(n.theme).colors.categorical,Tk),E="function"==typeof t?t:null,F=E?w.map(e=>({_cat:E(e)})):w,N=E?"_cat":"string"==typeof t?t:void 0,z=i??[...O],D=N?Dn(F,N,z):null,B=/* @__PURE__ */new Map;for(const e of A)B.set(e.id,e.__raw);const W=(e,i)=>{if(t&&B.has(e)){const i=B.get(e);return E?Nn({_cat:E(i)},"_cat",D??void 0):Nn(i,"string"==typeof t?t:"id",D??void 0)}return O[i%O.length]},Y=o(I&&t?(()=>{const e=/* @__PURE__ */new Map;w.forEach((i,n)=>{const o=x(t,i),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:W(x(u,i)+"",n)})});const i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,n.legend),q=!1!==r.showLabels&&("auto"!==r.showLabels||"auto"),{layout:X,layoutConfig:G,issues:V,xScale:H}=Xu({nodes:A,edges:S,domain:k,plotW:C,plotH:T,orientation:P,ribbonLane:r.ribbonLane||"both",ribbonMinRun:"auto"===r.ribbonMinRun||"number"==typeof r.ribbonMinRun?r.ribbonMinRun:0,edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:W,showLabels:q,styleRules:r.styleRules,colorBy:t,valueAccessor:l,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half",maxValueScale:"number"==typeof r.maxValueScale?r.maxValueScale:void 0,lanePlacement:r.lanePlacement||"stack",nodeSizing:r.nodeSizing||"temporal",groupPadding:"number"==typeof r.groupPadding?r.groupPadding:0}});if(V.length>0){const e=V.map(nl).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const U=X?Vu({layout:X,nodes:A,orientation:P,plotW:C,plotH:T,timelineExtent:"vertical"===P?T:C,axisTicks:Array.isArray(r.axisTicks)?r.axisTicks.map(e=>({date:e.date,label:e.label})):[],showQualityReadout:!!r.showQualityReadout,showLaneRails:!!r.showLaneRails,timeFormat:"function"==typeof r.timeFormat?e=>r.timeFormat(e):void 0,colorOf:W,toTime:e=>s(e),xScale:e=>Number(H(e))}):void 0;return{chartType:"force",nodes:w,edges:b,customNetworkLayout:VM,layoutConfig:G,sourceAccessor:a,targetAccessor:c,valueAccessor:l,nodeIDAccessor:u,colorBy:t,colorScheme:i,...U&&{backgroundGraphics:U},...n,showLegend:I,...Y&&{legend:Y,legendPosition:L},__legendIncludesAutomatic:!0,margin:R}}},JM={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(o.nodes)?o.nodes:Zu([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),s=zr(n.theme).colors.categorical,a=/* @__PURE__ */new Map,c="string"==typeof t?t:"__ssrSankeyColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrSankeyColorBy:t(e)})):r,u=t?Dn(l,c,i??n.colorScheme??s):void 0,d=e=>({fill:t?Nn(e?.data||e,t,u):Ua(void 0,s,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=dt(o.styleRules,t,o.valueAccessor),p=h?(e,t)=>({...d(e),...h(e,t)}):d,f=Qu({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:p,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:Ks(o.nodeStyle||p,da(o)),edgeStyle:Ks(o.edgeStyle||f,da(o)),colorScheme:i,...n,showLegend:(n.showLegend??!!t)&&!!t}}},e_={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=zr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Ku(e??null,o.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrTreeColorBy:c(e)})):a,u=c?"__ssrTreeColorBy":"string"==typeof t?t:void 0,d=t&&u?Dn(l,u,i??n.colorScheme??r):void 0,h=!1!==o.showLabels,p=n.nodeStyle||o.nodeStyle,f=ut(e=>{const n=e?.data||e;return{fill:o.colorByDepth?rA[Number(e?.depth||0)%rA.length]:t?c?Nn({__ssrTreeColorBy:c(n)},"__ssrTreeColorBy",d??void 0):Nn(n,t,d??void 0):Ua(void 0,r,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,rt(t,o.valueAccessor),e=>e?.data||e);return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:i,...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:Ju(f,p,da(o))}}},t_={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=zr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Ku(e??null,o.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrTreemapColorBy:c(e)})):a,u=c?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,d=t&&u?Dn(l,u,i??n.colorScheme??r):void 0,h=o.showLabels??n.showLabels,p=o.labelMode,f=void 0!==o.paddingTop?o.paddingTop:n.paddingTop,y=void 0!==f?f:!h||"parent"!==p&&"all"!==p?void 0:18,g=n.nodeStyle||o.nodeStyle,m=ut(e=>{const n=e?.data||e;return{fill:o.colorByDepth?rA[Number(e?.depth||0)%rA.length]:t?c?Nn({__ssrTreemapColorBy:c(n)},"__ssrTreemapColorBy",d??void 0):Nn(n,t,d??void 0):Ua(void 0,r,i,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,rt(t,o.valueAccessor),e=>e?.data||e);return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:p,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=y&&{paddingTop:y},colorScheme:i,...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:Ju(m,g,da(o))}}},i_={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},n_=require("d3-scale"),o_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r="string"==typeof i?i:"blues",s=rd(o.areas,o.valueAccessor,r),a=o.areaStyle??sd(s,o.areaOpacity??1),c=o.styleRules?ut(a,o.styleRules,e=>{return{value:(t=e,"function"==typeof o.valueAccessor?o.valueAccessor(t):null!=o.valueAccessor?t?.properties?.[o.valueAccessor]??t?.[o.valueAccessor]:void 0)};var t},od):a,l=!1!==n.showLegend&&s?{gradient:{colorFn:s.colorScale,domain:s.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:c,valueAccessor:o.valueAccessor,colorScheme:r,graticule:o.graticule,fitPadding:o.fitPadding,...n,...void 0===n.legend&&l?{legend:l}:{}}}},r_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r=e||o.points,s=o.pointStyle??nd(r,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=o.styleRules?ut(s,o.styleRules,rt(t,o.sizeBy)):s;return{points:r,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||i_,pointStyle:a,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...n}}},s_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r=e||o.points,s=o.pointStyle??nd(r,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:5,fillOpacity:.85,strokeWidth:1}),a=o.nodeIdAccessor||"id",c=o.cartogramLayout||("sparkline"===o.mode?"strip":"radial"),l="sparkline"===o.mode,u="strip"===c,d=o.styleRules?ut(s,o.styleRules,rt(t)):s;return{points:r,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{const t="function"==typeof d?d(e):d,i="function"==typeof a?a(e):e[a],n=null!=i&&i+""==o.center+"",r="number"==typeof t.r?t.r:5;return{...t,fillOpacity:n?1:t.fillOpacity??.8,stroke:n?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:n?1.25:t.strokeWidth??1,r:n?1.35*r:r}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:a,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:c},...n,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!u&&!l),showRingLabels:o.showRingLabels??!u,costLabel:o.costLabel}}}},a_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r=(Array.isArray(e)?e:null)||o.flows||[],s=o.nodeIdAccessor||"id",a=o.valueAccessor||"value",c=o.xAccessor||"lon",l=o.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(o.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),p=/* @__PURE__ */new Map;for(const e of h)p.set(e[s]+"",e);const f=o.edgeColorBy??t,y="function"==typeof f,g=r.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=p.get(e.source+""),i=p.get(e.target+"");return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=f?y?Dn(g.map(e=>({[m]:f(e)})),m,i||"category10"):Dn(g,f,i||"category10"):null,b=g.map(e=>Number(e[a]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?_s(b):void 0,[w,k]=o.edgeWidthRange??[1,8];return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||i_,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:id({valueAccessor:a,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>f&&x?Nn(e,f,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...n}}},c_=Uv(require("react-dom/server")),l_=Uv(require("react")),u_=Uv(require("react-dom/server")),d_=class{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 i of e){const e=this.push(i);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 i=0;this._size>i;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let i=0,n=[];t.length>e&&(i=t.length-e,n=t.slice(0,i)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=i;t.length>e;e++)this.push(t[e]);return n}update(e,t){const i=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(n+o)%this._capacity,s=this.buffer[r];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},i.push(e),this.buffer[r]=t(s)}}return i}remove(e){const t=[],i=[];if(this.forEach(n=>{e(n)?i.push(n):t.push(n)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},h_=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(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 i of e){const e=t?t(i):i;Number.isFinite(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}},p_=/^\d{4}-\d{1,2}$/,f_=/* @__PURE__ */Object.create(null),y_="undefined"==typeof window||"undefined"==typeof document,g_=/* @__PURE__ */new Set,m_=require("d3-scale"),x_=/* @__PURE__ */new WeakMap,b_=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],v_=["scene-style","data-paint","accessibility","evidence"],w_=(e,t)=>({retainedData:e,invalidations:t}),k_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],A_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],S_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],M_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],__=["scene-geometry","data-paint","accessibility","evidence"],$_=["scene-style","data-paint","accessibility","evidence"],P_=[],j_={chartType:w_("rebuild",k_),runtimeMode:w_("rebuild",k_),xAccessor:w_("rebuild",k_),yAccessor:w_("rebuild",k_),timeAccessor:w_("rebuild",k_),valueAccessor:w_("rebuild",k_),y0Accessor:w_("rebuild",k_),boundsAccessor:w_("rebuild",k_),band:w_("rebuild",k_),openAccessor:w_("rebuild",k_),highAccessor:w_("rebuild",k_),lowAccessor:w_("rebuild",k_),closeAccessor:w_("rebuild",k_),candlestickRangeMode:w_("rebuild",k_),accessorRevision:w_("rebuild",k_),groupAccessor:w_("rebuild",A_),categoryAccessor:w_("rebuild",A_),lineDataAccessor:w_("rebuild",A_),colorAccessor:w_("rebuild",$_),sizeAccessor:w_("rebuild",__),symbolAccessor:w_("rebuild",__),pointIdAccessor:w_("rebuild",__),xScaleType:w_("preserve",S_),yScaleType:w_("preserve",S_),xExtent:w_("preserve",S_),invertY:w_("preserve",S_),yExtent:w_("preserve",S_),extentPadding:w_("preserve",S_),scalePadding:w_("preserve",S_),axisExtent:w_("preserve",S_),yAxisExtent:w_("preserve",S_),binSize:w_("preserve",S_),normalize:w_("preserve",S_),heatmapAggregation:w_("preserve",S_),heatmapXBins:w_("preserve",S_),heatmapYBins:w_("preserve",S_),arrowOfTime:w_("preserve",M_),baseline:w_("preserve",M_),stackOrder:w_("preserve",M_),sizeRange:w_("preserve",M_),curve:w_("preserve",M_),areaGroups:w_("preserve",M_),customLayout:w_("preserve",M_),layoutConfig:w_("preserve",M_),layoutMargin:w_("preserve",M_),symbolMap:w_("preserve",__),showValues:w_("preserve",__),heatmapValueFormat:w_("preserve",__),trackHoverRows:w_("preserve",__),lineStyle:w_("preserve",$_),pointStyle:w_("preserve",$_),areaStyle:w_("preserve",$_),barStyle:w_("preserve",$_),swarmStyle:w_("preserve",$_),waterfallStyle:w_("preserve",$_),candlestickStyle:w_("preserve",$_),boundsStyle:w_("preserve",$_),gradientFill:w_("preserve",$_),lineGradient:w_("preserve",$_),semanticLineStops:w_("preserve",$_),colorScheme:w_("preserve",$_),themeCategorical:w_("preserve",$_),themeSemantic:w_("preserve",$_),themeSequential:w_("preserve",$_),themeDiverging:w_("preserve",$_),barColors:w_("preserve",$_),decay:w_("preserve",$_),pulse:w_("preserve",$_),staleness:w_("preserve",$_),layoutSelection:w_("preserve",$_),annotations:w_("preserve",["overlay","accessibility","evidence"]),windowSize:w_("preserve",P_),windowMode:w_("preserve",P_),maxCapacity:w_("preserve",P_),clock:w_("preserve",P_),transition:w_("preserve",P_),introAnimation:w_("preserve",P_),onLayoutError:w_("preserve",P_)},I_=w_("preserve",M_),L_=class{constructor(){this.tracker=new yk}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},b_)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},v_):this.recordNoop("restyle")}recordConfig(e,t=!1){const i=Xh(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...__]):i.invalidations)}},R_=require("d3-quadtree"),C_=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let i=0,n=0;for(const e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>n&&(n=e.r));if(this.maxRadius=n,500>=i)return void(this.tree=null);const o=Array(i);let r=0;for(const e of t)"point"===e.type&&!1!==e.interactive&&(o[r++]=e);this.tree=(0,R_.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}},T_=class e{constructor(e){if(this.xExtent=new h_,this.yExtent=new h_,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=/* @__PURE__ */new Map,this.prevPathMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new L_,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.xIsDate=!1,this.spatialIndex=new C_,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&_d(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new d_(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=cd(e.timeAccessor||e.xAccessor,"time"),this.getY=cd(e.valueAccessor||e.yAccessor,"value")):(this.getX=cd(e.xAccessor,"x"),this.getY=cd(e.yAccessor,"y")),this.getGroup=ud(e.groupAccessor),this.getCategory=ud(e.categoryAccessor),this.getSize=e.sizeAccessor?cd(e.sizeAccessor,"size"):void 0,this.getColor=ud(e.colorAccessor),this.getSymbol=ud(e.symbolAccessor),this.getY0=e.y0Accessor?cd(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=ih(e),this.getPointId=ud(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?cd(e.openAccessor,"open"):void 0,this.getHigh=cd(e.highAccessor,"high"),this.getLow=cd(e.lowAccessor,"low"),this.getClose=i?cd(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new d_(e.windowSize))}currentTime(){return this.config.clock?.()??bd()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Oh(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(n)&&this.yExtent.push(n)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(n)&&this.yExtent.evict(n)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?cd(this.config.timeAccessor||this.config.xAccessor,"time"):cd(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],i=this.config.xAccessor,n="function"==typeof i?i(t):t[i||"x"],o=n instanceof Date,r="string"==typeof n&&Number.isFinite(pd(n));if(this.xIsDate=o||r,r){const e="string"==typeof i?i:void 0;this.getX=e?t=>fd(t[e]):e=>fd(i(e))}}Th(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Eh(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Eh(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:i}=this,n=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.xExtent.extent,a=this.yExtent.extent;let c="waterfall"===t.chartType&&i.size>0?vh(r,this.getX,s,t.xExtent,t.xScaleType):gh(s,t.xExtent),l=gh(a,t.yExtent);const u=!(!(d=t.yExtent)||null==d[0]||null==d[1]);var d;const h="exact"===(t.yAxisExtent??t.axisExtent);if("stackedarea"===t.chartType&&!u&&i.size>0){const e=mh({config:t,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?l=xh(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!u&&i.size>0?l=bh(i,this.getY,t.extentPadding,h):u||l[0]===1/0||(l=wh(l,r,this.resolvedRibbons),l=kh(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:a}));l=Ah(l,t.yExtent,!!u),({xDomain:c,yDomain:l}=Sh(c,l,t.xScaleType)),this.scales=_h({config:t,layout:e,xDomain:c,yDomain:l}),this._customLayoutFailedThisBuild=!1;const p=this.buildSceneNodes(e,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=n,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=p,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r,this.currentTime()),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.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,i=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]*=i;break;case"area":for(const n of e.topPath)n[0]*=t,n[1]*=i;for(const n of e.bottomPath)n[0]*=t,n[1]*=i;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*i,width:e.clipRect.width*t,height:e.clipRect.height*i}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*i,height:e.height*i})));break;case"point":case"glyph":e.x*=t,e.y*=i;break;case"rect":case"heatcell":e.x*=t,e.y*=i,e.w*=t,e.h*=i;break;case"candlestick":e.x*=t,e.openY*=i,e.closeY*=i,e.highY*=i,e.lowY*=i}const n=this.scales.x.domain(),o=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=Mh,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,n,r[0]>r[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,o,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:i,scales:n}=this;if(!n)return[];if(i.customLayout){const o={data:t,scales:n,dimensions:{width:e.width,height:e.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??oA},resolveColor:(e,t)=>{const n=this.resolveGroupColor(e);if(n)return n;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},r=eh({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(o)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);const s=r.result;this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null;const a=s.nodes??[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(const e of a)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(a,i.layoutSelection??null)}return Ud({label:"customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const o={scales:n,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(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},r=(s=i.chartType,f_[s]?.buildScene);var s;if(!r)return Hd(i.chartType),[];const a=(c=r(o,t,e),Array.isArray(c)?{nodes:c,binBoundaries:[]}:{nodes:c.nodes,binBoundaries:c.binBoundaries});var c;return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=a.binBoundaries),a.nodes}resolveBoundsStyle(e,t){return Ch(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?kd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Ad(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&Sd(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Pd(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory,getPointId:this.getPointId}}snapshotPositions(){Yd(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const i=this.scene[t],n=Bd(this.transitionContext,i,t);n&&("point"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(n,{x:i.x,y:e,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(n,{path:i.path.map(e=>[e[0],e[1]]),pathIds:i.pathIds?.slice(),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(n,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),pathIds:i.pathIds?.slice(),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=qd(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());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},i=Xd(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,Gh(this.scene),this.exitNodes=[]}groupData(e){const{result:t,cache:i}=Ph(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){const{map:t,cache:i}=jh(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return Lh(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return Rh(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:i,groupColorCounter:n}=Ih({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=n,i}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=yd(e),i=this.getPointId,n=e=>t.has(i(e));Fh(this.buffer,this.timestampBuffer,n);const o=this.buffer.remove(n);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=yd(e),n=this.getPointId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(n(e))&&o.add(t)});const r=this.buffer.update(e=>i.has(n(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const i=this._customRestyle;if(i)for(const n of e){const e=this._baseStyles.get(n)??n.style??{},o=i(n,t);n.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=/* @__PURE__ */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||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let n=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const r="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(r||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=r||!ad(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=r||!ad(i,s);(a||c)&&(e?(this.getX=cd(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=cd(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=cd(this.config.xAccessor,"x"),this.getY=cd(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=ih(this.config)),n=!0,o=!0)}if("groupAccessor"in e&&!ad(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?ud(this.config.groupAccessor):void 0,n=!0),"categoryAccessor"in e&&!ad(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?ud(this.config.categoryAccessor):void 0,n=!0),"sizeAccessor"in e&&!ad(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?cd(this.config.sizeAccessor,"size"):void 0,n=!0),"symbolAccessor"in e&&!ad(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ud(this.config.symbolAccessor):void 0,n=!0),"colorAccessor"in e&&!ad(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ud(this.config.colorAccessor):void 0,n=!0),"y0Accessor"in e&&!ad(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?cd(this.config.y0Accessor,"y0"):void 0,n=!0,o=!0),("boundsAccessor"in e&&!ad(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=ih(this.config),n=!0,o=!0),"pointIdAccessor"in e&&!ad(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?ud(this.config.pointIdAccessor):void 0,n=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in e&&!ad(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!ad(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!ad(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!ad(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?cd(this.config.openAccessor,"open"):void 0,this.getHigh=cd(this.config.highAccessor,"high"),this.getLow=cd(this.config.lowAccessor,"low"),this.getClose=t?cd(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,n=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(n=!0,o=!0),!n){const i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of i)if(e[o]!==t[o]){n=!0;break}}n&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&Va(t.areaStyle)!==Va(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};T_.GROUP_COLOR_MAP_CAP=1e3;var O_=T_;qh(O_);var E_=require("d3-shape"),F_={circle:E_.symbolCircle,square:E_.symbolSquare,triangle:E_.symbolTriangle,diamond:E_.symbolDiamond,star:E_.symbolStar,cross:E_.symbolCross,wye:E_.symbolWye},N_=/* @__PURE__ */new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),z_=["circle","triangle","diamond","star","square","chevron","cross","wye"],D_=256,B_=/* @__PURE__ */new Map,W_={line:function(e,t){const i=e.groupData(t),n=[],o=e.config.annotations?.filter(ep).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Kh(e.ribbons);if(r.length>0&&n.push(...Zh(e,t,r)),o.length>0)for(const t of i)n.push(...Qh(e,t.data,t.key,o))}for(const t of i){const i=e.resolveLineStyle(t.key,Ga(t.data)),r=ah(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);o&&o.length>0&&(r.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),n.push(r)}return Jh(e,i,n),n},area:function(e,t){const i=e.groupData(t),n=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Kh(e.ribbons);if(r.length>0&&n.push(...Zh(e,t,r)),o.length>0)for(const t of i)n.push(...Qh(e,t.data,t.key,o))}const o=e.scales.y.domain(),r=o[0],s=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),a=s&&s.length>0?(()=>{const t=s.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;t.length>e;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:n,opacity:o})=>{const r=e.scales.y(t),s=e.scales.y(i);return{y:Math.min(r,s),height:Math.abs(s-r),color:n,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,c=e.getY0?t=>{const i=e.getY0(t);return null==i?r:i}:void 0;for(const t of i){const i=e.resolveAreaStyle(t.key,Ga(t.data)),o=ch(t.data,e.scales,e.getX,e.getY,r,i,t.key,c,e.getPointId),l=tp(e.config.gradientFill);l&&(o.fillGradient=l),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),s&&s.length>0&&(o.colorThresholds=s,o.strokeColorBands=a),n.push(o)}return Jh(e,i,n),n},stackedarea:function(e,t){const i=e.groupData(t),n=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===n);else if("key"===n)o();else if("asc"===n||"desc"===n||"insideOut"===n){const t=/* @__PURE__ */new Map;for(const n of i){let i=0;for(const t of n.data){const n=e.getX(t),o=e.getY(t);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}t.set(n.key,i)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===n)i.sort((e,i)=>{const n=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==n?n:o(e.key,i.key)});else if("desc"===n)i.sort((e,i)=>{const n=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==n?n:o(e.key,i.key)});else{const e=[...i].sort((e,i)=>{const n=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==n?n:o(e.key,i.key)}),n=[],r=[];let s=0,a=0;for(const i of e)a>s?(n.push(i),s+=t.get(i.key)??0):(r.push(i),a+=t.get(i.key)??0);i.length=0,i.push(...r.reverse(),...n)}}else o();const r=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=dh(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,r,s,e.getPointId),l=a;if(e.config.pointStyle){const t=/* @__PURE__ */new WeakMap;for(const n of i){const i=c.get(n.key);if(i)for(const o of n.data){const n=e.getX(o),r=e.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||t.set(o,i.get(n))}}const n=i=>t.get(i)??e.getY(i);Jh(e,i,l,n)}return l},mixed:function(e,t){const i=e.groupData(t),n=[],o=e.config.areaGroups||/* @__PURE__ */new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Kh(e.ribbons);if(r.length>0&&n.push(...Zh(e,t,r)),o.length>0)for(const t of i)n.push(...Qh(e,t.data,t.key,o))}const r=e.scales.y.domain()[0],s=e.getY0?t=>{const i=e.getY0(t);return null==i?r:i}:void 0;for(const t of i)if(o.has(t.key)){const i=e.resolveAreaStyle(t.key,Ga(t.data)),o=ch(t.data,e.scales,e.getX,e.getY,r,i,t.key,s,e.getPointId),a=tp(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),n.push(o)}else{const i=e.resolveLineStyle(t.key,Ga(t.data)),o=ah(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),n.push(o)}return Jh(e,i,n),n},scatter:sp,bubble:sp,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return up(e,t,i);if(0===t.length)return[];const n=cd(e.config.valueAccessor,"value"),o=ld(e.config.xAccessor,"x"),r=ld(e.config.yAccessor,"y"),s=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const i=t[e],n=o(i),u=r(i);c[e]=n,l[e]=u,s.has(n)||s.set(n,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),p=Array.from(a.keys()),f=h.every(e=>"number"==typeof e&&!isNaN(e)),y=p.every(e=>"number"==typeof e&&!isNaN(e)),g=4096;if(f&&y&&u*d>g&&t.length>g){const n=/* @__PURE__ */new Set;for(let o=0;t.length>o;o++){const r=s.get(c[o]),d=a.get(l[o]);if(void 0!==r&&void 0!==d&&(n.add(d*u+r),n.size>g))return up({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(f){h.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){p.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;p.length>e;e++)a.set(p[e],e)}const m=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=/* @__PURE__ */new Map;let w=0;for(let e=0;t.length>e;e++){const i=t[e],o=s.get(c[e]),r=a.get(l[e]);if(void 0===o||void 0===r)continue;const d=n(i),h=r*u+o,p=v.get(h);let f;void 0!==p?f=p:(f=w++,v.set(h,f)),m[f]=h,x[f]=d,b[f]=i}let k=1/0,A=-1/0;for(let e=0;w>e;e++){const t=x[e];isFinite(t)&&(k>t&&(k=t),t>A&&(A=t))}if(!isFinite(k)||!isFinite(A))return[];const S=e.config.heatmapColorScale,M=S?void 0:cp("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),_=i.width/u,$=i.height/d,P=e.config.showValues,j=e.config.heatmapValueFormat,I=[];for(let t=0;w>t;t++){const i=x[t];if(!isFinite(i))continue;const n=m[t],o=n%u,r=(n-o)/u,s=ap(i,k,A),a=S?S(i):M[s],c=b[t];I.push(lp(yh(o*_,(d-1-r)*$,_,$,a,c,P?{value:i,showValues:!0,valueFormat:j}:{value:i}),c,e))}return I},bar:function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=nh(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||Va(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let n=null;if(e.getCategory){const t=/* @__PURE__ */new Set;for(const e of i.values())for(const i of e.categories.keys())t.add(i);const o=e.config.barColors?Object.keys(e.config.barColors):[],r=new Set(o),s=Array.from(t).filter(e=>!r.has(e)).sort(),a=o.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?n=e.barCategoryCache.order:(n=[...a,...s],e.barCategoryCache={key:c,order:n})}const o=[],r=e.scales,[s,a]=r.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity),c?.cursor&&(h.cursor=c.cursor);for(const t of i.values()){const i=Math.max(t.start,s),u=Math.min(t.end,a);if(i>=u)continue;const p=r.x(i),f=r.x(u),y=Math.abs(f-p),g=y>d+1?d:0,m=Math.min(p,f)+g/2,x=Math.max(y-g,1);if(x>0)if(n&&t.categories.size>0){let i=0;for(const s of n){const n=t.categories.get(s)||0;if(0===n)continue;const a=r.y(i),u=r.y(i+n),d=Math.min(a,u),p=Math.abs(a-u),f=(e.config.barColors?zn(e.config.barColors,s):void 0)??c?.fill??l??"#4e79a7",y=Ya({binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:n},t.categoryRows?.get(s)),g=e.config.areaStyle?.(y)??{};o.push(fh(m,d,x,p,{fill:f,...h,...g},y,s)),i+=n}}else{const i=r.y(0),n=r.y(t.total),s=Math.min(i,n),a=Math.abs(i-n),u=c?.fill||l||"#007bff",d=Ya({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{};o.push(fh(m,s,x,a,{fill:u,...h,...p},d))}}const p=/* @__PURE__ */new Set;for(const e of i.values())p.add(e.start),p.add(e.end);return{nodes:o,binBoundaries:Array.from(p).sort((e,t)=>e-t)}},swarm:function(e,t){const i=[],n=e.config.swarmStyle||{},o=n.radius??3,r=n.fill??e.config.themeSemantic?.primary??"#007bff",s=n.opacity??.7,a=n.stroke,c=n.strokeWidth,l=n.cursor;for(const n of t){const t=e.getX(n),u=e.getY(n);if(null==u||Number.isNaN(u))continue;const d=e.scales.x(t),h=e.scales.y(u);let p=r;if(e.getCategory){const t=e.getCategory(n)+"";p=(e.config.barColors?zn(e.config.barColors,t):void 0)??p}const{r:f,...y}=e.config.pointStyle?.(n)??{},g={type:"point",x:d,y:h,r:f??o,style:{fill:p,opacity:s,stroke:a,strokeWidth:c,cursor:l,...y},datum:n};e.getPointId&&(g.pointId=e.getPointId(n)+""),i.push(g)}return i},waterfall:function(e,t,i){const n=[],o=e.scales,r=e.config.waterfallStyle,s=t.filter(t=>{const i=e.getY(t),n=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=n&&isFinite(n)});if(0===s.length)return n;const a=r?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,d=r?.strokeWidth,h=r?.opacity;let p=0;for(let t=0;s.length>t;t++){const f=s[t],y=e.getX(f),g=e.getY(f),m=p+g,x=o.x(y),b=t>0?o.x(e.getX(s[t-1])):void 0,v=s.length-1>t?o.x(e.getX(s[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+l/2,S=Math.max(w,k)-l/2-A;if(0>=S){p=m;continue}const M=o.y(p),_=o.y(m),$=Math.min(M,_),P=Math.abs(M-_),j=0>g?c:a,I={...f,baseline:p,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth},L={fill:j,stroke:u,strokeWidth:d,opacity:h,cursor:r?.cursor,...e.config.areaStyle?.(I)};n.push(fh(A,$,S,P,L,I)),p=m}return n},candlestick:function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const o=[],r=e.config.candlestickStyle||{},s=r.rangeColor||"#6366f1",a=n?s:r.upColor||"#28a745",c=n?s:r.downColor||"#dc3545",l=n?s:r.wickColor||"#333",u=r.wickWidth||(n?2:1);let d=r.bodyWidth??0;if(null==r.bodyWidth){const i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,n=e.scales.x(i[0]);for(let o=1;i.length>o;o++){const r=e.scales.x(i[o]),s=Math.abs(r-n);s>0&&t>s&&(t=s),n=r}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(const s of t){const t=e.getX(s);if(null==t||Number.isNaN(t))continue;const h=e.getHigh(s),p=e.getLow(s);if(null==h||Number.isNaN(h)||null==p||Number.isNaN(p))continue;const f=n?h:e.getOpen(s),y=n?p:e.getClose(s);if(!n&&(null==f||Number.isNaN(f)||null==y||Number.isNaN(y)))continue;const g=y>=f,m=e.config.pointStyle?.(s)??{},x="string"==typeof m.fill?m.fill:void 0,b="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(f),closeY:e.scales.y(y),highY:e.scales.y(h),lowY:e.scales.y(p),bodyWidth:d,upColor:x&&g?x:a,downColor:x&&!g?x:c,wickColor:b??(n&&x?x:l),wickWidth:v??u,isUp:g,style:{cursor:r.cursor,...m,...void 0!==w&&{opacity:w}},datum:s};n&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o},custom:()=>[]},Y_=Uv(require("react")),q_=require("d3-shape"),X_=Uv(require("react")),G_=[40,40],V_=[.5,.5],H_=require("react/jsx-runtime"),U_={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0},K_=(Uv(require("react")),require("react/jsx-runtime")),Z_=require("react/jsx-runtime"),Q_=/* @__PURE__ */new Set,J_=require("d3-scale"),e$=require("react/jsx-runtime"),t$=uw,i$=Uv(require("react")),n$=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),o$={INVALID_PROJECTION:"Check endpoint values and the scale domain, especially log-scale values.",INSUFFICIENT_SPACE:"Increase chart height or the label-side margin, or reduce the label font size.",TIED_ENDPOINTS:"Use connectors or a legend to distinguish series sharing an endpoint.",LABEL_OMITTED:"Consult the accessible series list; increase the label rail space to restore visible labels.",ESTIMATED_METRICS:"Load the intended font and remeasure before asserting collision-free text.",RENDER_FAILURE:"Inspect the annotation renderer; the placed label did not produce a node.",UNSUPPORTED_GEOMETRY:"Inspect custom-rendered text; its geometry has not been measured by the label solver.",LABEL_COLLISION:"Increase spacing or shorten the affected labels.",LABEL_OVERFLOW:"Increase the allocated bounds or shorten the affected labels."},r$=require("react/jsx-runtime"),s$=require("react/jsx-runtime"),a$="var(--semiotic-bg, #ffffff)",c$=.85,l$=require("react/jsx-runtime"),u$=16,d$=require("react/jsx-runtime"),h$=require("react/jsx-runtime"),p$=require("react/jsx-runtime"),f$={secondary:0,primary:3},y$=1,g$=2,m$=.6,x$="0.88em",b$=.95,v$=.72,w$=.06,k$=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}",A$=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}",S$=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),M$=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),_$=1,$$=32,P$=6,j$=4,I$=8,L$=72,R$=30,C$=-30,T$=8,O$=480,E$=3,F$={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},N$=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]),z$=require("react/jsx-runtime"),D$={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"},B$=require("d3-hierarchy"),W$=require("d3-shape"),Y$=(Uv(require("react")),require("react/jsx-runtime")),q$={linear:W$.curveLinear,monotoneX:W$.curveMonotoneX,monotoneY:W$.curveMonotoneY,step:W$.curveStep,stepAfter:W$.curveStepAfter,stepBefore:W$.curveStepBefore,basis:W$.curveBasis,cardinal:W$.curveCardinal,catmullRom:W$.curveCatmullRom},X$=require("react/jsx-runtime"),G$=16,V$=require("react/jsx-runtime"),H$=Uv(require("react")),U$=require("react/jsx-runtime"),K$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z$=864e5,Q$=3156e7,J$=require("react/jsx-runtime"),eP={right:110,left:110,top:50,bottom:80},tP=require("react/jsx-runtime"),iP={top:50,right:40,bottom:60,left:70},nP={top:20,right:80,bottom:20,left:80},oP={top:40,right:40,bottom:40,left:40},rP=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]),sP=require("react/jsx-runtime"),aP=require("react/jsx-runtime");dp();var cP=Uv(require("react-dom/server")),lP=require("react/jsx-runtime"),uP=require("react/jsx-runtime"),dP=require("react/jsx-runtime"),hP={top:4,bottom:4,left:4,right:4},pP={frameType:"xy",buildProps:Pg,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=jg(e),[a,c]=r.size??[600,400],l=s.minimap&&"object"==typeof s.minimap?s.minimap:{},u=Ig(l.height,60),d=r.margin,h=l.margin&&"object"==typeof l.margin?l.margin:{},p={top:Ig(h.top,0),right:Ig(h.right,Ig(d?.right,20)),bottom:Ig(h.bottom,20),left:Ig(h.left,Ig(d?.left,40))},f=u+p.top+p.bottom,y=s.frameProps&&"object"==typeof s.frameProps?s.frameProps:{},g={...s,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y"},m={...r,size:[a,c],xExtent:y.xExtent??s.brushExtent??r.xExtent,yExtent:y.yExtent??s.yExtent??r.yExtent,_idPrefix:(r._idPrefix??"minimap")+"-detail"},x=CS.buildProps(i,n,o,m,g);Object.assign(x,y);const b={...r,size:[a,f],margin:p,title:void 0,description:(r.description??r.title??"Chart")+" overview minimap",showAxes:l.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:l.background,xExtent:void 0,yExtent:s.yExtent??r.yExtent,_idPrefix:(r._idPrefix??"minimap")+"-overview"};delete b.lineStyle,delete b.pointStyle;const v={...g,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=CS.buildProps(i,n,o,b,v);w.chartType=s.fillArea?"area":"line","function"==typeof l.lineStyle&&(w.lineStyle=l.lineStyle);const k={},A={},S=cg(x,k),M=cg(w,A),_=!0===s.renderBefore,$=_?0:c,P=""+Rg(S,0,_?f:0,"detail")+Rg(M,0,$,"overview"),j=c+f,I=Dr(zr(r.theme)),L="string"==typeof r.title?r.title:void 0,R="string"==typeof r.description?r.description:L||"Chart with overview minimap",C=Hy(r),T=L?C+"-title":void 0,O=C+"-description",E="y"===l.brushDirection?"y":"x",F=Array.isArray(s.brushExtent)&&s.brushExtent.length>=2?[Number(s.brushExtent[0]),Number(s.brushExtent[1])]:null,N=A.evidence;let z=null;if(F&&F.every(Number.isFinite)&&N){const e="x"===E?N.xDomain:N.yDomain;if(e&&e[0]!==e[1]){const t=Math.max(0,a-p.left-p.right),i=u,n=t=>(t-e[0])/(e[1]-e[0]);if("x"===E){const e=n(Math.min(...F))*t,o=n(Math.max(...F))*t;z=/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("rect",{className:"selection",x:p.left+e,y:$+p.top,width:o-e,height:i,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{const e=(1-n(Math.max(...F)))*i,o=(1-n(Math.min(...F)))*i;z=/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("rect",{className:"selection",x:p.left,y:$+p.top+e,width:t,height:o-e,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}const D=c_.renderToStaticMarkup(
|
|
599
|
+
/* @__PURE__ */(0,gM.jsx)("text",{x:i.centerX+Math.cos(o)*a,y:i.centerY+Math.sin(o)*a,textAnchor:l,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+n)})]})},buildProps:(e,t,i,n,o)=>{const r=o.min??0,s=o.max??100,a=o.sweep??240,c=o.arcWidth??.3,l=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=qc(a),h=o.thresholds,p=oa(n.gradientFill),f=Yc({min:r,max:s,value:o.value,thresholds:h,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==o.showScaleLabels,gradientFill:p}),y=o.styleRules,[g,m]=n.size||[300,250],x=Xc(a),b=Math.min(10,Math.max(1,Math.min(g,m)/12)),v=Math.max(4,Math.min((g-2*b)/x.width,(m-2*b)/x.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-c))),k=g/2-x.cx*v,A=m/2-x.cy*v,S=2*(v+4),M=Math.max(r,Math.min(s,o.value??r)),_="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",$=o.centerContent??n.centerContent,P=null!=$?"function"==typeof $?$(M,r,s):$:"sparkline"===o.mode||"context"===o.mode?void 0:Fc({value:_,min:r,max:s,radius:v,showScaleLabels:!1!==o.showScaleLabels});return{chartType:"donut",data:f.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:Ks((e,t)=>{const i={...f.pieceStyle(e,t)};return y?.length&&Object.assign(i,lt(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},da(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...n,size:[g,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:g-k-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(n.annotations)?n.annotations:[],...f.gaugeAnnotations],__gauge:{gMin:r,gMax:s,sweep:a,arcWidth:c,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:l,needleColor:o.needleColor,..."context"===o.mode&&null==$&&{contextValue:_,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},xM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=ha(n.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,...r&&{annotations:r},gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,t,i,n,o)}}},bM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:r,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},vM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:r,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},wM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=nt(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:r,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...n,pieceStyle:Vc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)}),showLegend:n.showLegend??!!r}}},kM={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=nt(o.valueAccessor??"value");return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:n.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:r,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...n,pieceStyle:Vc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)})}}},AM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.valueAccessor||"value",a=r.map(e=>Number("function"==typeof s?s(e):e[s])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:s,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:c?{rExtent:c}:{},...n,summaryStyle:Hc(e,t,i,n,o,"count")}}},SM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...n,summaryStyle:Hc(e,t,i,n,o)})},MM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:i,...n,summaryStyle:Uc(e,t,i,n,o),showLegend:n.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},_M={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...n,sizeRange:o.sizeRange||[3,8],pieceStyle:Zc(e,t,i,n,o),showLegend:n.showLegend??!!t})},$M={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,n,o)=>{const r=ha(n.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...n,...r&&{annotations:r},pieceStyle:Kc(e,t,i,n,o),showGrid:n.showGrid??!0,showLegend:n.showLegend??!!t}}},PM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=o.seriesAccessor||t||"__radar",s=t||("__radar"===r?void 0:r),a=Kc(e,s,i,n,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:s,colorScheme:i,connectorAccessor:r,connectorStyle:e=>{const t=a(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:a,rExtent:o.valueExtent||[0],oLabel:"",...n,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:n.showLegend??!!s}}},jM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:r,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...n,gradientFill:Gc(n.gradientFill),pieceStyle:Vc(e,r,i,n,o),showLegend:n.showLegend??!!r,barPadding:o.barPadding??40}}},IM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...n,summaryStyle:Hc(e,t,i,n,o,"median",.5),showLegend:n.showLegend??!!t})},LM={frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r="vertical"===o.orientation,s=t||o.categoryAccessor;return{chartType:r?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:s,categoryAccessor:o.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!r&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:r?40:0,colorScheme:i,...n,showAxes:r&&!1!==n.showAxes,showGrid:r,pieceStyle:Vc(e,s,i,n,o),showLabels:o.showLabels??!0}}},RM=require("d3-scale"),CM={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},TM=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),OM=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},EM=828*OM(8),FM=3e3,NM=/* @__PURE__ */new Map,zM=1e5,DM=1e-9,BM=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,WM=require("react/jsx-runtime"),YM="var(--semiotic-grid, #94a3b8)",qM="var(--semiotic-text-secondary, #475569)",XM="var(--semiotic-text-secondary, #94a3b8)",GM=.22,VM=e=>{const{bands:t=[],ribbons:i=[],showLabels:n=!0,selectionDatum:o="raw"}=e.config,r=e.selection??null,s=[];for(const e of i){const t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!Uu(t,r,o);s.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,GM):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!Uu({__kind:"band",data:e.rawDatum,id:e.id},r,o);for(let i=0;e.gradientStubs.length>i;i++){const n=e.gradientStubs[i];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?GM:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,...null!=n.y0&&{y0:n.y0},...null!=n.y1&&{y1:n.y1},from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(const e of t){const t=!(!e.gradientStubs||0>=e.gradientStubs.length),i={__kind:"band",data:e.rawDatum,id:e.id},n=!Uu(i,r,o);s.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:n?GM:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...n&&t?{opacity:GM}:{}},datum:i})}const a=n?t.flatMap(e=>{const t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,n=t&&r?.isActive&&Uu({__kind:"band",data:e.rawDatum,id:e.id},r,o),s=i?e.labelText:n?e.labelFullText:"";return s.trim()?[{x:e.labelX,y:e.labelY,text:s,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"middle",fontSize:11,fontWeight:600}]:[]}):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:a}},HM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||n.nodeStyle||o.nodeStyle||Us(da(o))))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,...n,showLegend:(n.showLegend??!!t)&&!!t};const r=Array.isArray(o.edges)?o.edges:[],s=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:Zu([],r,o.sourceAccessor||"source",o.targetAccessor||"target"),a=Wr(n.theme).colors.categorical,c=zn(i,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,d=t?Yn(u,l,i??n.colorScheme??a):void 0,h=/* @__PURE__ */new Map,p=o.nodeIdAccessor||o.nodeIDAccessor||"id",f=(e,i)=>{const n=e?.data||e;let r;if(t)r=Bn(n,t,d);else{const t=(e.id??n?.[p]??"")+"";h.has(t)||h.set(t,h.size);const o=e.index??i??h.get(t);r=c[o%c.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=dt(o.styleRules,t,o.valueAccessor);return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:i,nodeStyle:Ks(o.nodeStyle||(y?(e,t)=>({...f(e,t),...y(e,t)}):f),da(o)),...n,showLegend:(n.showLegend??!!t)&&!!t}}},UM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=ed(o),s=Wr(n.theme).colors.categorical,a=/* @__PURE__ */new Map,c=o.nodeStyle??(e=>({fill:t?Bn(e?.data||e,t,void 0):Ua(void 0,s,i,void 0,a),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),l=dt(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=Ks(l?(e,t)=>({...c(e),...l(e,t)}):c,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:u,edgeStyle:r,...n,showLegend:(n.showLegend??!!t)&&!!t}}},KM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Wr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Ku(e??null,o.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrCirclePackColorBy:c(e)})):a,u=c?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,d=t&&u?Yn(l,u,i??n.colorScheme??r):void 0,h=o.showLabels??n.showLabels,p=n.nodeStyle||o.nodeStyle,f=ut(e=>{const n=e?.data||e;return{fill:o.colorByDepth?rA[Number(e?.depth||0)%rA.length]:t?c?Bn({__ssrCirclePackColorBy:c(n)},"__ssrCirclePackColorBy",d??void 0):Bn(n,t,d??void 0):Ua(void 0,r,i,void 0,s),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,rt(t,o.valueAccessor),e=>e?.data||e);return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:i,...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:Ju(f,p,da(o))}}},ZM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=e??o.data,s=o.childrenAccessor||"children",a=o.nodeIdAccessor||o.nodeIDAccessor||"name",c=Wr(n.theme).colors.categorical,l=i??n.colorScheme??c,u=zn(l,c),d=Ku(r,s),h="__ssrOrbitColorBy",p="function"==typeof t?t:null,f=t?Yn(p?d.map(e=>({[h]:p(e)})):d,p?h:t,l):void 0,y=ut(e=>{const i=e.data||e,n=Number(e.depth??0);return{fill:o.colorByDepth?0===n?u[0]:rA[n%rA.length]:t?p?Bn({[h]:p(i)},h,f):Bn(i,t,f):u[0],stroke:"#fff",strokeWidth:1,opacity:0===n?1:.85}},o.styleRules,rt(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:r,childrenAccessor:s,nodeIDAccessor:a,colorBy:t,colorScheme:l,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?a:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:Ks(y,da(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},QM={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,i,n,r)=>{const s=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),a=r.sourceAccessor||"source",c=r.targetAccessor||"target",l=r.valueAccessor||"value",u=r.nodeIdAccessor||"id",d=r.startTimeAccessor||"startTime",h=r.endTimeAccessor||"endTime",p=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,y=r.xExtentAccessor||"xExtent",g=r.groupBy,m=r.edgeIdAccessor||"id",x=(e,t)=>"function"==typeof e?e(t):t[e],b=Array.isArray(r.edges)?r.edges:[],v=Array.isArray(r.nodes)?r.nodes:[],w=v.length>0?v:Zu([],b,a,c),k=[s(r.domain?.[0]),s(r.domain?.[1])],A=w.map(e=>{const t=x(u,e)+"",i=x(y,e),n=r.nodeLabel?x(r.nodeLabel,e):t,o={id:t,label:null==n?t:n+"",__raw:e},a=g?x(g,e):null;if(null!=a&&a+""!=""&&(o.group=a+""),Array.isArray(i)&&2===i.length){const e=s(i[0]),t=s(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),S=b.map((e,t)=>{const i=x(m,e),n={id:null!=i?i+"":`${x(a,e)}-${x(c,e)}-${t}`,source:x(a,e)+"",target:x(c,e)+"",value:Number(x(l,e)),startTime:s(x(d,e)),endTime:s(x(h,e)),__raw:e};if(p){const t=s(x(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(f){const t=s(x(f,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),[M,_]=n.size??[600,400],$=n.margin,P="vertical"===r.orientation?"vertical":"horizontal",j={...Gu(!!n.title,!!r.showQualityReadout,Array.isArray(r.axisTicks)&&r.axisTicks.length>0,P),...$},I=(n.showLegend??!!t)&&!!t,L=n.legendPosition??"right";I&&("right"===L?j.right=Math.max(j.right,140):"left"===L?j.left=Math.max(j.left,140):"top"===L?j.top=Math.max(j.top,50):"bottom"===L&&(j.bottom=Math.max(j.bottom,80)));const R=j,C=M-R.left-R.right,T=_-R.top-R.bottom,O=zn(i,Wr(n.theme).colors.categorical,Tk),E="function"==typeof t?t:null,F=E?w.map(e=>({_cat:E(e)})):w,N=E?"_cat":"string"==typeof t?t:void 0,z=i??[...O],D=N?Yn(F,N,z):null,B=/* @__PURE__ */new Map;for(const e of A)B.set(e.id,e.__raw);const W=(e,i)=>{if(t&&B.has(e)){const i=B.get(e);return E?Bn({_cat:E(i)},"_cat",D??void 0):Bn(i,"string"==typeof t?t:"id",D??void 0)}return O[i%O.length]},Y=o(I&&t?(()=>{const e=/* @__PURE__ */new Map;w.forEach((i,n)=>{const o=x(t,i),r=null==o?"":o+"";r&&!e.has(r)&&e.set(r,{label:r,color:W(x(u,i)+"",n)})});const i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,n.legend),q=!1!==r.showLabels&&("auto"!==r.showLabels||"auto"),{layout:X,layoutConfig:G,issues:V,xScale:H}=Xu({nodes:A,edges:S,domain:k,plotW:C,plotH:T,orientation:P,ribbonLane:r.ribbonLane||"both",ribbonMinRun:"auto"===r.ribbonMinRun||"number"==typeof r.ribbonMinRun?r.ribbonMinRun:0,edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:W,showLabels:q,styleRules:r.styleRules,colorBy:t,valueAccessor:l,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half",maxValueScale:"number"==typeof r.maxValueScale?r.maxValueScale:void 0,lanePlacement:r.lanePlacement||"stack",nodeSizing:r.nodeSizing||"temporal",groupPadding:"number"==typeof r.groupPadding?r.groupPadding:0}});if(V.length>0){const e=V.map(nl).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const U=X?Vu({layout:X,nodes:A,orientation:P,plotW:C,plotH:T,timelineExtent:"vertical"===P?T:C,axisTicks:Array.isArray(r.axisTicks)?r.axisTicks.map(e=>({date:e.date,label:e.label})):[],showQualityReadout:!!r.showQualityReadout,showLaneRails:!!r.showLaneRails,timeFormat:"function"==typeof r.timeFormat?e=>r.timeFormat(e):void 0,colorOf:W,toTime:e=>s(e),xScale:e=>Number(H(e))}):void 0;return{chartType:"force",nodes:w,edges:b,customNetworkLayout:VM,layoutConfig:G,sourceAccessor:a,targetAccessor:c,valueAccessor:l,nodeIDAccessor:u,colorBy:t,colorScheme:i,...U&&{backgroundGraphics:U},...n,showLegend:I,...Y&&{legend:Y,legendPosition:L},__legendIncludesAutomatic:!0,margin:R}}},JM={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(o.nodes)?o.nodes:Zu([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),s=Wr(n.theme).colors.categorical,a=/* @__PURE__ */new Map,c="string"==typeof t?t:"__ssrSankeyColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrSankeyColorBy:t(e)})):r,u=t?Yn(l,c,i??n.colorScheme??s):void 0,d=e=>({fill:t?Bn(e?.data||e,t,u):Ua(void 0,s,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=dt(o.styleRules,t,o.valueAccessor),p=h?(e,t)=>({...d(e),...h(e,t)}):d,f=Qu({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:p,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:Ks(o.nodeStyle||p,da(o)),edgeStyle:Ks(o.edgeStyle||f,da(o)),colorScheme:i,...n,showLegend:(n.showLegend??!!t)&&!!t}}},e_={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Wr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Ku(e??null,o.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrTreeColorBy:c(e)})):a,u=c?"__ssrTreeColorBy":"string"==typeof t?t:void 0,d=t&&u?Yn(l,u,i??n.colorScheme??r):void 0,h=!1!==o.showLabels,p=n.nodeStyle||o.nodeStyle,f=ut(e=>{const n=e?.data||e;return{fill:o.colorByDepth?rA[Number(e?.depth||0)%rA.length]:t?c?Bn({__ssrTreeColorBy:c(n)},"__ssrTreeColorBy",d??void 0):Bn(n,t,d??void 0):Ua(void 0,r,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,rt(t,o.valueAccessor),e=>e?.data||e);return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:i,...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:Ju(f,p,da(o))}}},t_={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Wr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Ku(e??null,o.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrTreemapColorBy:c(e)})):a,u=c?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,d=t&&u?Yn(l,u,i??n.colorScheme??r):void 0,h=o.showLabels??n.showLabels,p=o.labelMode,f=void 0!==o.paddingTop?o.paddingTop:n.paddingTop,y=void 0!==f?f:!h||"parent"!==p&&"all"!==p?void 0:18,g=n.nodeStyle||o.nodeStyle,m=ut(e=>{const n=e?.data||e;return{fill:o.colorByDepth?rA[Number(e?.depth||0)%rA.length]:t?c?Bn({__ssrTreemapColorBy:c(n)},"__ssrTreemapColorBy",d??void 0):Bn(n,t,d??void 0):Ua(void 0,r,i,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,rt(t,o.valueAccessor),e=>e?.data||e);return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:p,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=y&&{paddingTop:y},colorScheme:i,...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:Ju(m,g,da(o))}}},i_={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},n_=require("d3-scale"),o_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r="string"==typeof i?i:"blues",s=rd(o.areas,o.valueAccessor,r),a=o.areaStyle??sd(s,o.areaOpacity??1),c=o.styleRules?ut(a,o.styleRules,e=>{return{value:(t=e,"function"==typeof o.valueAccessor?o.valueAccessor(t):null!=o.valueAccessor?t?.properties?.[o.valueAccessor]??t?.[o.valueAccessor]:void 0)};var t},od):a,l=!1!==n.showLegend&&s?{gradient:{colorFn:s.colorScale,domain:s.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:c,valueAccessor:o.valueAccessor,colorScheme:r,graticule:o.graticule,fitPadding:o.fitPadding,...n,...void 0===n.legend&&l?{legend:l}:{}}}},r_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r=e||o.points,s=o.pointStyle??nd(r,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=o.styleRules?ut(s,o.styleRules,rt(t,o.sizeBy)):s;return{points:r,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||i_,pointStyle:a,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...n}}},s_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r=e||o.points,s=o.pointStyle??nd(r,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:5,fillOpacity:.85,strokeWidth:1}),a=o.nodeIdAccessor||"id",c=o.cartogramLayout||("sparkline"===o.mode?"strip":"radial"),l="sparkline"===o.mode,u="strip"===c,d=o.styleRules?ut(s,o.styleRules,rt(t)):s;return{points:r,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{const t="function"==typeof d?d(e):d,i="function"==typeof a?a(e):e[a],n=null!=i&&i+""==o.center+"",r="number"==typeof t.r?t.r:5;return{...t,fillOpacity:n?1:t.fillOpacity??.8,stroke:n?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:n?1.25:t.strokeWidth??1,r:n?1.35*r:r}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:a,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:c},...n,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!u&&!l),showRingLabels:o.showRingLabels??!u,costLabel:o.costLabel}}}},a_={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,n,o)=>{const r=(Array.isArray(e)?e:null)||o.flows||[],s=o.nodeIdAccessor||"id",a=o.valueAccessor||"value",c=o.xAccessor||"lon",l=o.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(o.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),p=/* @__PURE__ */new Map;for(const e of h)p.set(e[s]+"",e);const f=o.edgeColorBy??t,y="function"==typeof f,g=r.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=p.get(e.source+""),i=p.get(e.target+"");return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=f?y?Yn(g.map(e=>({[m]:f(e)})),m,i||"category10"):Yn(g,f,i||"category10"):null,b=g.map(e=>Number(e[a]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?Mt(b):void 0,[w,k]=o.edgeWidthRange??[1,8];return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||i_,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:id({valueAccessor:a,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>f&&x?Bn(e,f,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...n}}},c_=Uv(require("react-dom/server")),l_=Uv(require("react")),u_=Uv(require("react-dom/server")),d_=class{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 i of e){const e=this.push(i);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 i=0;this._size>i;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let i=0,n=[];t.length>e&&(i=t.length-e,n=t.slice(0,i)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=i;t.length>e;e++)this.push(t[e]);return n}update(e,t){const i=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const r=(n+o)%this._capacity,s=this.buffer[r];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},i.push(e),this.buffer[r]=t(s)}}return i}remove(e){const t=[],i=[];if(this.forEach(n=>{e(n)?i.push(n):t.push(n)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},h_=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(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 i of e){const e=t?t(i):i;Number.isFinite(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}},p_=/^\d{4}-\d{1,2}$/,f_=/* @__PURE__ */Object.create(null),y_="undefined"==typeof window||"undefined"==typeof document,g_=/* @__PURE__ */new Set,m_=require("d3-scale"),x_=/* @__PURE__ */new WeakMap,b_=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],v_=["scene-style","data-paint","accessibility","evidence"],w_=(e,t)=>({retainedData:e,invalidations:t}),k_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],A_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],S_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],M_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],__=["scene-geometry","data-paint","accessibility","evidence"],$_=["scene-style","data-paint","accessibility","evidence"],P_=[],j_={chartType:w_("rebuild",k_),runtimeMode:w_("rebuild",k_),xAccessor:w_("rebuild",k_),yAccessor:w_("rebuild",k_),timeAccessor:w_("rebuild",k_),valueAccessor:w_("rebuild",k_),y0Accessor:w_("rebuild",k_),boundsAccessor:w_("rebuild",k_),band:w_("rebuild",k_),openAccessor:w_("rebuild",k_),highAccessor:w_("rebuild",k_),lowAccessor:w_("rebuild",k_),closeAccessor:w_("rebuild",k_),candlestickRangeMode:w_("rebuild",k_),accessorRevision:w_("rebuild",k_),groupAccessor:w_("rebuild",A_),categoryAccessor:w_("rebuild",A_),lineDataAccessor:w_("rebuild",A_),colorAccessor:w_("rebuild",$_),sizeAccessor:w_("rebuild",__),symbolAccessor:w_("rebuild",__),pointIdAccessor:w_("rebuild",__),xScaleType:w_("preserve",S_),yScaleType:w_("preserve",S_),xExtent:w_("preserve",S_),invertY:w_("preserve",S_),yExtent:w_("preserve",S_),extentPadding:w_("preserve",S_),scalePadding:w_("preserve",S_),axisExtent:w_("preserve",S_),yAxisExtent:w_("preserve",S_),binSize:w_("preserve",S_),normalize:w_("preserve",S_),heatmapAggregation:w_("preserve",S_),heatmapXBins:w_("preserve",S_),heatmapYBins:w_("preserve",S_),arrowOfTime:w_("preserve",M_),baseline:w_("preserve",M_),stackOrder:w_("preserve",M_),sizeRange:w_("preserve",M_),curve:w_("preserve",M_),areaGroups:w_("preserve",M_),customLayout:w_("preserve",M_),layoutConfig:w_("preserve",M_),layoutMargin:w_("preserve",M_),symbolMap:w_("preserve",__),showValues:w_("preserve",__),heatmapValueFormat:w_("preserve",__),trackHoverRows:w_("preserve",__),lineStyle:w_("preserve",$_),pointStyle:w_("preserve",$_),areaStyle:w_("preserve",$_),barStyle:w_("preserve",$_),swarmStyle:w_("preserve",$_),waterfallStyle:w_("preserve",$_),candlestickStyle:w_("preserve",$_),boundsStyle:w_("preserve",$_),gradientFill:w_("preserve",$_),lineGradient:w_("preserve",$_),semanticLineStops:w_("preserve",$_),colorScheme:w_("preserve",$_),themeCategorical:w_("preserve",$_),themeSemantic:w_("preserve",$_),themeSequential:w_("preserve",$_),themeDiverging:w_("preserve",$_),barColors:w_("preserve",$_),decay:w_("preserve",$_),pulse:w_("preserve",$_),staleness:w_("preserve",$_),layoutSelection:w_("preserve",$_),annotations:w_("preserve",["overlay","accessibility","evidence"]),windowSize:w_("preserve",P_),windowMode:w_("preserve",P_),maxCapacity:w_("preserve",P_),clock:w_("preserve",P_),transition:w_("preserve",P_),introAnimation:w_("preserve",P_),onLayoutError:w_("preserve",P_)},I_=w_("preserve",M_),L_=class{constructor(){this.tracker=new yk}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},b_)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},v_):this.recordNoop("restyle")}recordConfig(e,t=!1){const i=Xh(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...__]):i.invalidations)}},R_=require("d3-quadtree"),C_=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let i=0,n=0;for(const e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>n&&(n=e.r));if(this.maxRadius=n,500>=i)return void(this.tree=null);const o=Array(i);let r=0;for(const e of t)"point"===e.type&&!1!==e.interactive&&(o[r++]=e);this.tree=(0,R_.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}},T_=class e{constructor(e){if(this.xExtent=new h_,this.yExtent=new h_,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=/* @__PURE__ */new Map,this.prevPathMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new L_,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.xIsDate=!1,this.spatialIndex=new C_,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&_d(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new d_(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=cd(e.timeAccessor||e.xAccessor,"time"),this.getY=cd(e.valueAccessor||e.yAccessor,"value")):(this.getX=cd(e.xAccessor,"x"),this.getY=cd(e.yAccessor,"y")),this.getGroup=ud(e.groupAccessor),this.getCategory=ud(e.categoryAccessor),this.getSize=e.sizeAccessor?cd(e.sizeAccessor,"size"):void 0,this.getColor=ud(e.colorAccessor),this.getSymbol=ud(e.symbolAccessor),this.getY0=e.y0Accessor?cd(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=ih(e),this.getPointId=ud(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?cd(e.openAccessor,"open"):void 0,this.getHigh=cd(e.highAccessor,"high"),this.getLow=cd(e.lowAccessor,"low"),this.getClose=i?cd(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new d_(e.windowSize))}currentTime(){return this.config.clock?.()??bd()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Oh(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(n)&&this.yExtent.push(n)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(n)&&this.yExtent.evict(n)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?cd(this.config.timeAccessor||this.config.xAccessor,"time"):cd(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],i=this.config.xAccessor,n="function"==typeof i?i(t):t[i||"x"],o=n instanceof Date,r="string"==typeof n&&Number.isFinite(pd(n));if(this.xIsDate=o||r,r){const e="string"==typeof i?i:void 0;this.getX=e?t=>fd(t[e]):e=>fd(i(e))}}Th(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Eh(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Eh(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:i}=this,n=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const r=this.getBufferArray(),s=this.xExtent.extent,a=this.yExtent.extent;let c="waterfall"===t.chartType&&i.size>0?vh(r,this.getX,s,t.xExtent,t.xScaleType):gh(s,t.xExtent),l=gh(a,t.yExtent);const u=!(!(d=t.yExtent)||null==d[0]||null==d[1]);var d;const h="exact"===(t.yAxisExtent??t.axisExtent);if("stackedarea"===t.chartType&&!u&&i.size>0){const e=mh({config:t,groups:this.groupData(r),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?l=xh(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!u&&i.size>0?l=bh(i,this.getY,t.extentPadding,h):u||l[0]===1/0||(l=wh(l,r,this.resolvedRibbons),l=kh(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:a}));l=Ah(l,t.yExtent,!!u),({xDomain:c,yDomain:l}=Sh(c,l,t.xScaleType)),this.scales=_h({config:t,layout:e,xDomain:c,yDomain:l}),this._customLayoutFailedThisBuild=!1;const p=this.buildSceneNodes(e,r);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=n,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=p,this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r,this.currentTime()),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.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,i=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]*=i;break;case"area":for(const n of e.topPath)n[0]*=t,n[1]*=i;for(const n of e.bottomPath)n[0]*=t,n[1]*=i;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*i,width:e.clipRect.width*t,height:e.clipRect.height*i}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*i,height:e.height*i})));break;case"point":case"glyph":e.x*=t,e.y*=i;break;case"rect":case"heatcell":e.x*=t,e.y*=i,e.w*=t,e.h*=i;break;case"candlestick":e.x*=t,e.openY*=i,e.closeY*=i,e.highY*=i,e.lowY*=i}const n=this.scales.x.domain(),o=this.scales.y.domain(),r=this.scales.x.range(),s=this.scales.y.range(),a=Mh,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,n,r[0]>r[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,o,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:i,scales:n}=this;if(!n)return[];if(i.customLayout){const o={data:t,scales:n,dimensions:{width:e.width,height:e.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??oA},resolveColor:(e,t)=>{const n=this.resolveGroupColor(e);if(n)return n;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},r=eh({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(o)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);const s=r.result;this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null;const a=s.nodes??[];if(this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(const e of a)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(a,i.layoutSelection??null)}return Ud({label:"customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const o={scales:n,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(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},r=(s=i.chartType,f_[s]?.buildScene);var s;if(!r)return Hd(i.chartType),[];const a=(c=r(o,t,e),Array.isArray(c)?{nodes:c,binBoundaries:[]}:{nodes:c.nodes,binBoundaries:c.binBoundaries});var c;return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=a.binBoundaries),a.nodes}resolveBoundsStyle(e,t){return Ch(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?kd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Ad(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&Sd(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Pd(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory,getPointId:this.getPointId}}snapshotPositions(){Yd(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const i=this.scene[t],n=Bd(this.transitionContext,i,t);n&&("point"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(n,{x:i.x,y:e,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(n,{path:i.path.map(e=>[e[0],e[1]]),pathIds:i.pathIds?.slice(),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(n,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),pathIds:i.pathIds?.slice(),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=qd(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());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},i=Xd(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,Gh(this.scene),this.exitNodes=[]}groupData(e){const{result:t,cache:i}=Ph(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){const{map:t,cache:i}=jh(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return Lh(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return Rh(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:i,groupColorCounter:n}=Ih({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=n,i}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=yd(e),i=this.getPointId,n=e=>t.has(i(e));Fh(this.buffer,this.timestampBuffer,n);const o=this.buffer.remove(n);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=yd(e),n=this.getPointId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(n(e))&&o.add(t)});const r=this.buffer.update(e=>i.has(n(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=/* @__PURE__ */new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const i=this._customRestyle;if(i)for(const n of e){const e=this._baseStyles.get(n)??n.style??{},o=i(n,t);n.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=/* @__PURE__ */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||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let n=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const r="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(r||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=r||!ad(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=r||!ad(i,s);(a||c)&&(e?(this.getX=cd(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=cd(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=cd(this.config.xAccessor,"x"),this.getY=cd(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=ih(this.config)),n=!0,o=!0)}if("groupAccessor"in e&&!ad(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?ud(this.config.groupAccessor):void 0,n=!0),"categoryAccessor"in e&&!ad(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?ud(this.config.categoryAccessor):void 0,n=!0),"sizeAccessor"in e&&!ad(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?cd(this.config.sizeAccessor,"size"):void 0,n=!0),"symbolAccessor"in e&&!ad(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ud(this.config.symbolAccessor):void 0,n=!0),"colorAccessor"in e&&!ad(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ud(this.config.colorAccessor):void 0,n=!0),"y0Accessor"in e&&!ad(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?cd(this.config.y0Accessor,"y0"):void 0,n=!0,o=!0),("boundsAccessor"in e&&!ad(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=ih(this.config),n=!0,o=!0),"pointIdAccessor"in e&&!ad(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?ud(this.config.pointIdAccessor):void 0,n=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in e&&!ad(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!ad(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!ad(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!ad(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?cd(this.config.openAccessor,"open"):void 0,this.getHigh=cd(this.config.highAccessor,"high"),this.getLow=cd(this.config.lowAccessor,"low"),this.getClose=t?cd(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,n=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(n=!0,o=!0),!n){const i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of i)if(e[o]!==t[o]){n=!0;break}}n&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&Va(t.areaStyle)!==Va(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};T_.GROUP_COLOR_MAP_CAP=1e3;var O_=T_;qh(O_);var E_=require("d3-shape"),F_={circle:E_.symbolCircle,square:E_.symbolSquare,triangle:E_.symbolTriangle,diamond:E_.symbolDiamond,star:E_.symbolStar,cross:E_.symbolCross,wye:E_.symbolWye},N_=/* @__PURE__ */new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),z_=["circle","triangle","diamond","star","square","chevron","cross","wye"],D_=256,B_=/* @__PURE__ */new Map,W_={line:function(e,t){const i=e.groupData(t),n=[],o=e.config.annotations?.filter(ep).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Kh(e.ribbons);if(r.length>0&&n.push(...Zh(e,t,r)),o.length>0)for(const t of i)n.push(...Qh(e,t.data,t.key,o))}for(const t of i){const i=e.resolveLineStyle(t.key,Ga(t.data)),r=ah(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);o&&o.length>0&&(r.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),n.push(r)}return Jh(e,i,n),n},area:function(e,t){const i=e.groupData(t),n=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Kh(e.ribbons);if(r.length>0&&n.push(...Zh(e,t,r)),o.length>0)for(const t of i)n.push(...Qh(e,t.data,t.key,o))}const o=e.scales.y.domain(),r=o[0],s=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),a=s&&s.length>0?(()=>{const t=s.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;t.length>e;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:n,opacity:o})=>{const r=e.scales.y(t),s=e.scales.y(i);return{y:Math.min(r,s),height:Math.abs(s-r),color:n,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,c=e.getY0?t=>{const i=e.getY0(t);return null==i?r:i}:void 0;for(const t of i){const i=e.resolveAreaStyle(t.key,Ga(t.data)),o=ch(t.data,e.scales,e.getX,e.getY,r,i,t.key,c,e.getPointId),l=tp(e.config.gradientFill);l&&(o.fillGradient=l),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),s&&s.length>0&&(o.colorThresholds=s,o.strokeColorBands=a),n.push(o)}return Jh(e,i,n),n},stackedarea:function(e,t){const i=e.groupData(t),n=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===n);else if("key"===n)o();else if("asc"===n||"desc"===n||"insideOut"===n){const t=/* @__PURE__ */new Map;for(const n of i){let i=0;for(const t of n.data){const n=e.getX(t),o=e.getY(t);Number.isFinite(n)&&Number.isFinite(o)&&(i+=o)}t.set(n.key,i)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===n)i.sort((e,i)=>{const n=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==n?n:o(e.key,i.key)});else if("desc"===n)i.sort((e,i)=>{const n=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==n?n:o(e.key,i.key)});else{const e=[...i].sort((e,i)=>{const n=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==n?n:o(e.key,i.key)}),n=[],r=[];let s=0,a=0;for(const i of e)a>s?(n.push(i),s+=t.get(i.key)??0):(r.push(i),a+=t.get(i.key)??0);i.length=0,i.push(...r.reverse(),...n)}}else o();const r=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=dh(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,r,s,e.getPointId),l=a;if(e.config.pointStyle){const t=/* @__PURE__ */new WeakMap;for(const n of i){const i=c.get(n.key);if(i)for(const o of n.data){const n=e.getX(o),r=e.getY(o);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!i.has(n)||t.set(o,i.get(n))}}const n=i=>t.get(i)??e.getY(i);Jh(e,i,l,n)}return l},mixed:function(e,t){const i=e.groupData(t),n=[],o=e.config.areaGroups||/* @__PURE__ */new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Kh(e.ribbons);if(r.length>0&&n.push(...Zh(e,t,r)),o.length>0)for(const t of i)n.push(...Qh(e,t.data,t.key,o))}const r=e.scales.y.domain()[0],s=e.getY0?t=>{const i=e.getY0(t);return null==i?r:i}:void 0;for(const t of i)if(o.has(t.key)){const i=e.resolveAreaStyle(t.key,Ga(t.data)),o=ch(t.data,e.scales,e.getX,e.getY,r,i,t.key,s,e.getPointId),a=tp(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),n.push(o)}else{const i=e.resolveLineStyle(t.key,Ga(t.data)),o=ah(t.data,e.scales,e.getX,e.getY,i,t.key,e.getPointId);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),n.push(o)}return Jh(e,i,n),n},scatter:sp,bubble:sp,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return up(e,t,i);if(0===t.length)return[];const n=cd(e.config.valueAccessor,"value"),o=ld(e.config.xAccessor,"x"),r=ld(e.config.yAccessor,"y"),s=/* @__PURE__ */new Map,a=/* @__PURE__ */new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const i=t[e],n=o(i),u=r(i);c[e]=n,l[e]=u,s.has(n)||s.set(n,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),p=Array.from(a.keys()),f=h.every(e=>"number"==typeof e&&!isNaN(e)),y=p.every(e=>"number"==typeof e&&!isNaN(e)),g=4096;if(f&&y&&u*d>g&&t.length>g){const n=/* @__PURE__ */new Set;for(let o=0;t.length>o;o++){const r=s.get(c[o]),d=a.get(l[o]);if(void 0!==r&&void 0!==d&&(n.add(d*u+r),n.size>g))return up({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(f){h.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){p.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;p.length>e;e++)a.set(p[e],e)}const m=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=/* @__PURE__ */new Map;let w=0;for(let e=0;t.length>e;e++){const i=t[e],o=s.get(c[e]),r=a.get(l[e]);if(void 0===o||void 0===r)continue;const d=n(i),h=r*u+o,p=v.get(h);let f;void 0!==p?f=p:(f=w++,v.set(h,f)),m[f]=h,x[f]=d,b[f]=i}let k=1/0,A=-1/0;for(let e=0;w>e;e++){const t=x[e];isFinite(t)&&(k>t&&(k=t),t>A&&(A=t))}if(!isFinite(k)||!isFinite(A))return[];const S=e.config.heatmapColorScale,M=S?void 0:cp("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),_=i.width/u,$=i.height/d,P=e.config.showValues,j=e.config.heatmapValueFormat,I=[];for(let t=0;w>t;t++){const i=x[t];if(!isFinite(i))continue;const n=m[t],o=n%u,r=(n-o)/u,s=ap(i,k,A),a=S?S(i):M[s],c=b[t];I.push(lp(yh(o*_,(d-1-r)*$,_,$,a,c,P?{value:i,showValues:!0,valueFormat:j}:{value:i}),c,e))}return I},bar:function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=nh(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||Va(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let n=null;if(e.getCategory){const t=/* @__PURE__ */new Set;for(const e of i.values())for(const i of e.categories.keys())t.add(i);const o=e.config.barColors?Object.keys(e.config.barColors):[],r=new Set(o),s=Array.from(t).filter(e=>!r.has(e)).sort(),a=o.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?n=e.barCategoryCache.order:(n=[...a,...s],e.barCategoryCache={key:c,order:n})}const o=[],r=e.scales,[s,a]=r.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity),c?.cursor&&(h.cursor=c.cursor);for(const t of i.values()){const i=Math.max(t.start,s),u=Math.min(t.end,a);if(i>=u)continue;const p=r.x(i),f=r.x(u),y=Math.abs(f-p),g=y>d+1?d:0,m=Math.min(p,f)+g/2,x=Math.max(y-g,1);if(x>0)if(n&&t.categories.size>0){let i=0;for(const s of n){const n=t.categories.get(s)||0;if(0===n)continue;const a=r.y(i),u=r.y(i+n),d=Math.min(a,u),p=Math.abs(a-u),f=(e.config.barColors?Wn(e.config.barColors,s):void 0)??c?.fill??l??"#4e79a7",y=Ya({binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:n},t.categoryRows?.get(s)),g=e.config.areaStyle?.(y)??{};o.push(fh(m,d,x,p,{fill:f,...h,...g},y,s)),i+=n}}else{const i=r.y(0),n=r.y(t.total),s=Math.min(i,n),a=Math.abs(i-n),u=c?.fill||l||"#007bff",d=Ya({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{};o.push(fh(m,s,x,a,{fill:u,...h,...p},d))}}const p=/* @__PURE__ */new Set;for(const e of i.values())p.add(e.start),p.add(e.end);return{nodes:o,binBoundaries:Array.from(p).sort((e,t)=>e-t)}},swarm:function(e,t){const i=[],n=e.config.swarmStyle||{},o=n.radius??3,r=n.fill??e.config.themeSemantic?.primary??"#007bff",s=n.opacity??.7,a=n.stroke,c=n.strokeWidth,l=n.cursor;for(const n of t){const t=e.getX(n),u=e.getY(n);if(null==u||Number.isNaN(u))continue;const d=e.scales.x(t),h=e.scales.y(u);let p=r;if(e.getCategory){const t=e.getCategory(n)+"";p=(e.config.barColors?Wn(e.config.barColors,t):void 0)??p}const{r:f,...y}=e.config.pointStyle?.(n)??{},g={type:"point",x:d,y:h,r:f??o,style:{fill:p,opacity:s,stroke:a,strokeWidth:c,cursor:l,...y},datum:n};e.getPointId&&(g.pointId=e.getPointId(n)+""),i.push(g)}return i},waterfall:function(e,t,i){const n=[],o=e.scales,r=e.config.waterfallStyle,s=t.filter(t=>{const i=e.getY(t),n=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=n&&isFinite(n)});if(0===s.length)return n;const a=r?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=r?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=r?.gap??1,u=r?.stroke,d=r?.strokeWidth,h=r?.opacity;let p=0;for(let t=0;s.length>t;t++){const f=s[t],y=e.getX(f),g=e.getY(f),m=p+g,x=o.x(y),b=t>0?o.x(e.getX(s[t-1])):void 0,v=s.length-1>t?o.x(e.getX(s[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+l/2,S=Math.max(w,k)-l/2-A;if(0>=S){p=m;continue}const M=o.y(p),_=o.y(m),$=Math.min(M,_),P=Math.abs(M-_),j=0>g?c:a,I={...f,baseline:p,cumEnd:m,delta:g,_connectorStroke:r?.connectorStroke,_connectorWidth:r?.connectorWidth},L={fill:j,stroke:u,strokeWidth:d,opacity:h,cursor:r?.cursor,...e.config.areaStyle?.(I)};n.push(fh(A,$,S,P,L,I)),p=m}return n},candlestick:function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const o=[],r=e.config.candlestickStyle||{},s=r.rangeColor||"#6366f1",a=n?s:r.upColor||"#28a745",c=n?s:r.downColor||"#dc3545",l=n?s:r.wickColor||"#333",u=r.wickWidth||(n?2:1);let d=r.bodyWidth??0;if(null==r.bodyWidth){const i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,n=e.scales.x(i[0]);for(let o=1;i.length>o;o++){const r=e.scales.x(i[o]),s=Math.abs(r-n);s>0&&t>s&&(t=s),n=r}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(const s of t){const t=e.getX(s);if(null==t||Number.isNaN(t))continue;const h=e.getHigh(s),p=e.getLow(s);if(null==h||Number.isNaN(h)||null==p||Number.isNaN(p))continue;const f=n?h:e.getOpen(s),y=n?p:e.getClose(s);if(!n&&(null==f||Number.isNaN(f)||null==y||Number.isNaN(y)))continue;const g=y>=f,m=e.config.pointStyle?.(s)??{},x="string"==typeof m.fill?m.fill:void 0,b="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(f),closeY:e.scales.y(y),highY:e.scales.y(h),lowY:e.scales.y(p),bodyWidth:d,upColor:x&&g?x:a,downColor:x&&!g?x:c,wickColor:b??(n&&x?x:l),wickWidth:v??u,isUp:g,style:{cursor:r.cursor,...m,...void 0!==w&&{opacity:w}},datum:s};n&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o},custom:()=>[]},Y_=Uv(require("react")),q_=require("d3-shape"),X_=Uv(require("react")),G_=[40,40],V_=[.5,.5],H_=require("react/jsx-runtime"),U_={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0},K_=(Uv(require("react")),require("react/jsx-runtime")),Z_=require("react/jsx-runtime"),Q_=/* @__PURE__ */new Set,J_=require("d3-scale"),e$=require("react/jsx-runtime"),t$=uw,i$=Uv(require("react")),n$=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),o$={INVALID_PROJECTION:"Check endpoint values and the scale domain, especially log-scale values.",INSUFFICIENT_SPACE:"Increase chart height or the label-side margin, or reduce the label font size.",TIED_ENDPOINTS:"Use connectors or a legend to distinguish series sharing an endpoint.",LABEL_OMITTED:"Consult the accessible series list; increase the label rail space to restore visible labels.",ESTIMATED_METRICS:"Load the intended font and remeasure before asserting collision-free text.",RENDER_FAILURE:"Inspect the annotation renderer; the placed label did not produce a node.",UNSUPPORTED_GEOMETRY:"Inspect custom-rendered text; its geometry has not been measured by the label solver.",LABEL_COLLISION:"Increase spacing or shorten the affected labels.",LABEL_OVERFLOW:"Increase the allocated bounds or shorten the affected labels."},r$=require("react/jsx-runtime"),s$=require("react/jsx-runtime"),a$="var(--semiotic-bg, #ffffff)",c$=.85,l$=require("react/jsx-runtime"),u$=16,d$=require("react/jsx-runtime"),h$=require("react/jsx-runtime"),p$=require("react/jsx-runtime"),f$={secondary:0,primary:3},y$=1,g$=2,m$=.6,x$="0.88em",b$=.95,v$=.72,w$=.06,k$=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}",A$=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}",S$=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),M$=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),_$=1,$$=32,P$=6,j$=4,I$=8,L$=72,R$=30,C$=-30,T$=8,O$=480,E$=3,F$={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},N$=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]),z$=require("react/jsx-runtime"),D$={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"},B$=require("d3-hierarchy"),W$=require("d3-shape"),Y$=(Uv(require("react")),require("react/jsx-runtime")),q$={linear:W$.curveLinear,monotoneX:W$.curveMonotoneX,monotoneY:W$.curveMonotoneY,step:W$.curveStep,stepAfter:W$.curveStepAfter,stepBefore:W$.curveStepBefore,basis:W$.curveBasis,cardinal:W$.curveCardinal,catmullRom:W$.curveCatmullRom},X$=require("react/jsx-runtime"),G$=16,V$=require("react/jsx-runtime"),H$=Uv(require("react")),U$=require("react/jsx-runtime"),K$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Z$=864e5,Q$=3156e7,J$=require("react/jsx-runtime"),eP={right:110,left:110,top:50,bottom:80},tP=require("react/jsx-runtime"),iP={top:50,right:40,bottom:60,left:70},nP={top:20,right:80,bottom:20,left:80},oP={top:40,right:40,bottom:40,left:40},rP=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]),sP=require("react/jsx-runtime"),aP=require("react/jsx-runtime");dp();var cP=Uv(require("react-dom/server")),lP=require("react/jsx-runtime"),uP=require("react/jsx-runtime"),dP=require("react/jsx-runtime"),hP={top:4,bottom:4,left:4,right:4},pP={frameType:"xy",buildProps:Pg,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=jg(e),[a,c]=r.size??[600,400],l=s.minimap&&"object"==typeof s.minimap?s.minimap:{},u=Ig(l.height,60),d=r.margin,h=l.margin&&"object"==typeof l.margin?l.margin:{},p={top:Ig(h.top,0),right:Ig(h.right,Ig(d?.right,20)),bottom:Ig(h.bottom,20),left:Ig(h.left,Ig(d?.left,40))},f=u+p.top+p.bottom,y=s.frameProps&&"object"==typeof s.frameProps?s.frameProps:{},g={...s,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y"},m={...r,size:[a,c],xExtent:y.xExtent??s.brushExtent??r.xExtent,yExtent:y.yExtent??s.yExtent??r.yExtent,_idPrefix:(r._idPrefix??"minimap")+"-detail"},x=CS.buildProps(i,n,o,m,g);Object.assign(x,y);const b={...r,size:[a,f],margin:p,title:void 0,description:(r.description??r.title??"Chart")+" overview minimap",showAxes:l.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:l.background,xExtent:void 0,yExtent:s.yExtent??r.yExtent,_idPrefix:(r._idPrefix??"minimap")+"-overview"};delete b.lineStyle,delete b.pointStyle;const v={...g,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=CS.buildProps(i,n,o,b,v);w.chartType=s.fillArea?"area":"line","function"==typeof l.lineStyle&&(w.lineStyle=l.lineStyle);const k={},A={},S=cg(x,k),M=cg(w,A),_=!0===s.renderBefore,$=_?0:c,P=""+Rg(S,0,_?f:0,"detail")+Rg(M,0,$,"overview"),j=c+f,I=Yr(Wr(r.theme)),L="string"==typeof r.title?r.title:void 0,R="string"==typeof r.description?r.description:L||"Chart with overview minimap",C=Hy(r),T=L?C+"-title":void 0,O=C+"-description",E="y"===l.brushDirection?"y":"x",F=Array.isArray(s.brushExtent)&&s.brushExtent.length>=2?[Number(s.brushExtent[0]),Number(s.brushExtent[1])]:null,N=A.evidence;let z=null;if(F&&F.every(Number.isFinite)&&N){const e="x"===E?N.xDomain:N.yDomain;if(e&&e[0]!==e[1]){const t=Math.max(0,a-p.left-p.right),i=u,n=t=>(t-e[0])/(e[1]-e[0]);if("x"===E){const e=n(Math.min(...F))*t,o=n(Math.max(...F))*t;z=/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("rect",{className:"selection",x:p.left+e,y:$+p.top,width:o-e,height:i,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{const e=(1-n(Math.max(...F)))*i,o=(1-n(Math.min(...F)))*i;z=/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("rect",{className:"selection",x:p.left,y:$+p.top+e,width:t,height:o-e,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}const D=c_.renderToStaticMarkup(
|
|
600
600
|
/* @__PURE__ */
|
|
601
601
|
/* @__PURE__ */(0,dP.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:a,height:j,role:"img","aria-labelledby":[T,O].filter(Boolean).join(" "),style:{fontFamily:I.fontFamily},children:[L&&/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("title",{id:T,children:L}),
|
|
602
602
|
/* @__PURE__ */
|
|
603
603
|
/* @__PURE__ */(0,dP.jsx)("desc",{id:O,children:R}),
|
|
604
604
|
/* @__PURE__ */
|
|
605
|
-
/* @__PURE__ */(0,dP.jsx)("g",{dangerouslySetInnerHTML:{__html:P}}),z]}));if(t){const e=[k.evidence,A.evidence];t.evidence=hp({frameType:"xy",width:a,height:j,parts:e,title:L,description:R,xDomain:Cg(e,"xDomain"),yDomain:Cg(e,"yDomain")})}return D}},fP={MotifBraidChart:uS,DependencyForestChart:dS,FlowCircuitChart:hS,Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,n,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...n,showAxes:!1,margin:n.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:PS,LineChart:CS,AreaChart:OS,DifferenceChart:ES,StackedAreaChart:FS,Scatterplot:kS,CandlestickChart:NS,BubbleChart:AS,ConnectedScatterplot:DS,QuadrantChart:zS,Heatmap:rM,WaterfallChart:RS,MultiAxisLineChart:LS,MinimapChart:pP,ScatterplotMatrix:{frameType:"xy",buildProps:Pg,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=jg(e),a=Array.isArray(c=i)?c.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[];var c;const l=Array.isArray(s.fields)?s.fields.filter(e=>"string"==typeof e):[],u=s.fieldLabels&&"object"==typeof s.fieldLabels?s.fieldLabels:{},d=Lg(s.cellSize,150),h=Math.max(0,Ig(s.cellGap,4)),p=Math.max(0,Ig(s.pointRadius,2)),f=Math.max(0,Math.min(1,Ig(s.pointOpacity,.5))),y=Lg(s.histogramBins,20),g="string"==typeof s.diagonal?s.diagonal:"histogram",m=40+l.length*d+l.length*h,x=l.length*d+40+l.length*h,b=
|
|
605
|
+
/* @__PURE__ */(0,dP.jsx)("g",{dangerouslySetInnerHTML:{__html:P}}),z]}));if(t){const e=[k.evidence,A.evidence];t.evidence=hp({frameType:"xy",width:a,height:j,parts:e,title:L,description:R,xDomain:Cg(e,"xDomain"),yDomain:Cg(e,"yDomain")})}return D}},fP={MotifBraidChart:uS,DependencyForestChart:dS,FlowCircuitChart:hS,Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,n,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...n,showAxes:!1,margin:n.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:PS,LineChart:CS,AreaChart:OS,DifferenceChart:ES,StackedAreaChart:FS,Scatterplot:kS,CandlestickChart:NS,BubbleChart:AS,ConnectedScatterplot:DS,QuadrantChart:zS,Heatmap:rM,WaterfallChart:RS,MultiAxisLineChart:LS,MinimapChart:pP,ScatterplotMatrix:{frameType:"xy",buildProps:Pg,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=jg(e),a=Array.isArray(c=i)?c.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[];var c;const l=Array.isArray(s.fields)?s.fields.filter(e=>"string"==typeof e):[],u=s.fieldLabels&&"object"==typeof s.fieldLabels?s.fieldLabels:{},d=Lg(s.cellSize,150),h=Math.max(0,Ig(s.cellGap,4)),p=Math.max(0,Ig(s.pointRadius,2)),f=Math.max(0,Math.min(1,Ig(s.pointOpacity,.5))),y=Lg(s.histogramBins,20),g="string"==typeof s.diagonal?s.diagonal:"histogram",m=40+l.length*d+l.length*h,x=l.length*d+40+l.length*h,b=Wr(r.theme),v=Yr(b),w=Og(a,n,o,b),k="string"==typeof r.title?r.title:void 0,A="string"==typeof r.description?r.description:`Scatterplot matrix comparing ${l.length} fields`,S=k?28:0,M=s.showLegend??!!n?w.categories:[],_=e=>Math.max(72,30+7*e.length);let $=0,P=0;const j=M.map(e=>{const t=_(e);$>0&&$+t>m&&(P+=1,$=0);const i={label:e,x:$,y:24*P};return $+=t,i}),I=S+(M.length?24*(P+1)+4:0),L=I+x,R=[],C=[];let T=0;l.forEach((e,t)=>{l.forEach((i,o)=>{const c=40+h+o*(d+h),l=I+t*(d+h);if(t===o){const t=Eg({data:a,field:e,label:Wn(u,e)??e,cellSize:d,bins:y,diagonal:g,colorBy:n,color:w.color,x:c,y:l});return T+=t.visibleBars,void C.push(t.svg)}const m={},x=cg({chartType:"scatter",data:a,size:[d,d],xAccessor:i,yAccessor:e,pointStyle:ut(e=>({r:p,opacity:f,fill:w.color(e)}),s.styleRules,ot(i,e)),margin:hP,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Wn(u,i)??i} versus ${Wn(u,e)??e} scatterplot`,theme:r.theme,_idPrefix:`${(r._idPrefix??"splom")+""}-${t}-${o}`},m);R.push(m.evidence),C.push(Rg(x,c,l,`cell-${e}-${i}`))})});const O=Hy(r),E=k?O+"-title":void 0,F=O+"-description",N=c_.renderToStaticMarkup(
|
|
606
606
|
/* @__PURE__ */
|
|
607
607
|
/* @__PURE__ */(0,dP.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:m,height:L,role:"img","aria-labelledby":[E,F].filter(Boolean).join(" "),style:{fontFamily:v.fontFamily},children:[k&&/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("title",{id:E,children:k}),
|
|
608
608
|
/* @__PURE__ */
|
|
@@ -614,9 +614,9 @@ return(0,dP.jsxs)("g",{transform:`translate(${e.x},${S+e.y})`,children:[
|
|
|
614
614
|
/* @__PURE__ */(0,dP.jsx)("circle",{cx:5,cy:8,r:5,fill:i}),
|
|
615
615
|
/* @__PURE__ */
|
|
616
616
|
/* @__PURE__ */(0,dP.jsx)("text",{x:14,y:12,fontSize:11,fill:v.text,children:e.label})]},e.label)}),l.map((e,t)=>{const i=I+t*(d+h)+d/2;/* @__PURE__ */ /* @__PURE__ */
|
|
617
|
-
return(0,dP.jsx)("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:
|
|
617
|
+
return(0,dP.jsx)("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:Wn(u,e)??e},"row-"+e)}),l.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,dP.jsx)("text",{x:40+h+t*(d+h)+d/2,y:I+l.length*(d+h)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:Wn(u,e)??e},"column-"+e)),
|
|
618
618
|
/* @__PURE__ */
|
|
619
|
-
/* @__PURE__ */(0,dP.jsx)("g",{dangerouslySetInnerHTML:{__html:C.join("")}})]}));return t&&(t.evidence=hp({frameType:"xy",width:m,height:L,parts:R,additionalMarkCountByType:T>0?{histogram:T}:void 0,title:k,description:A,categories:w.categories.length?w.categories:void 0,legendItems:M.length||void 0})),N}},TemporalHistogram:TS,RealtimeLineChart:sM,RealtimeHistogram:aM,RealtimeHeatmap:cM,RealtimeSwarmChart:lM,RealtimeWaterfallChart:uM,XYCustomChart:Qw,BarChart:xM,StackedBarChart:bM,GroupedBarChart:vM,PieChart:wM,DonutChart:kM,Histogram:AM,BoxPlot:SM,ViolinPlot:MM,SwarmPlot:_M,DotPlot:$M,SwimlaneChart:jM,RidgelinePlot:IM,LikertChart:fM,FunnelChart:LM,RadarChart:PM,GaugeChart:mM,OrdinalCustomChart:Jw,ParallelCoordinatesRecipe:tk,CalendarHeatmapRecipe:ik,ForceDirectedGraph:UM,NetworkCustomChart:ek,SankeyDiagram:JM,ProcessSankey:QM,ChordDiagram:HM,TreeDiagram:e_,Treemap:t_,CirclePack:KM,OrbitDiagram:ZM,ChoroplethMap:o_,ProportionalSymbolMap:r_,FlowMap:a_,DistanceCartogram:s_,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,n,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...n})},GaltonBoardChart:FA,EventDropChart:NA,UnitPileChart:zA,CollisionSwarmChart:DA,ProcessFlowChart:BA,GauntletChart:WA,CrucibleChart:YA,PacketFlowChart:qA,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:Pg,renderStatic:function(e,t){const{data:i,common:n,rest:o}=Mg(e),r=Array.isArray(s=i)?s.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[];var s;const[a,c]=n.size??[920,620],l="string"==typeof n.title?n.title:"Dependency chain reaction",u=kg({data:r,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),d=
|
|
619
|
+
/* @__PURE__ */(0,dP.jsx)("g",{dangerouslySetInnerHTML:{__html:C.join("")}})]}));return t&&(t.evidence=hp({frameType:"xy",width:m,height:L,parts:R,additionalMarkCountByType:T>0?{histogram:T}:void 0,title:k,description:A,categories:w.categories.length?w.categories:void 0,legendItems:M.length||void 0})),N}},TemporalHistogram:TS,RealtimeLineChart:sM,RealtimeHistogram:aM,RealtimeHeatmap:cM,RealtimeSwarmChart:lM,RealtimeWaterfallChart:uM,XYCustomChart:Qw,BarChart:xM,StackedBarChart:bM,GroupedBarChart:vM,PieChart:wM,DonutChart:kM,Histogram:AM,BoxPlot:SM,ViolinPlot:MM,SwarmPlot:_M,DotPlot:$M,SwimlaneChart:jM,RidgelinePlot:IM,LikertChart:fM,FunnelChart:LM,RadarChart:PM,GaugeChart:mM,OrdinalCustomChart:Jw,ParallelCoordinatesRecipe:tk,CalendarHeatmapRecipe:ik,ForceDirectedGraph:UM,NetworkCustomChart:ek,SankeyDiagram:JM,ProcessSankey:QM,ChordDiagram:HM,TreeDiagram:e_,Treemap:t_,CirclePack:KM,OrbitDiagram:ZM,ChoroplethMap:o_,ProportionalSymbolMap:r_,FlowMap:a_,DistanceCartogram:s_,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,n,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...n})},GaltonBoardChart:FA,EventDropChart:NA,UnitPileChart:zA,CollisionSwarmChart:DA,ProcessFlowChart:BA,GauntletChart:WA,CrucibleChart:YA,PacketFlowChart:qA,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:Pg,renderStatic:function(e,t){const{data:i,common:n,rest:o}=Mg(e),r=Array.isArray(s=i)?s.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[];var s;const[a,c]=n.size??[920,620],l="string"==typeof n.title?n.title:"Dependency chain reaction",u=kg({data:r,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),d=Wr(n.theme),h=Yr(d),p=Hy(n),f=p+"-title",y=p+"-description";if(!u.valid){const e=u.diagnostics.map(e=>e.message).join(" "),i=cP.renderToStaticMarkup(
|
|
620
620
|
/* @__PURE__ */
|
|
621
621
|
/* @__PURE__ */(0,uP.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:c,role:"img","aria-labelledby":`${f} ${y}`,style:{fontFamily:h.fontFamily},children:[
|
|
622
622
|
/* @__PURE__ */
|
|
@@ -640,7 +640,7 @@ return(0,dP.jsx)("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"mi
|
|
|
640
640
|
/* @__PURE__ */
|
|
641
641
|
/* @__PURE__ */(0,uP.jsx)("text",{x:a/2,y:22,textAnchor:"middle",fontSize:h.titleFontSize,fontFamily:h.titleFontFamily,fontWeight:h.titleFontWeight,fill:h.text,children:l}),
|
|
642
642
|
/* @__PURE__ */
|
|
643
|
-
/* @__PURE__ */(0,uP.jsx)("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=hp({frameType:"physics",width:a,height:c,parts:[],additionalMarkCountByType:{task:u.nodes.length,dependency:u.edges.length},title:l,description:S,categories:u.lanes,nodeCount:u.nodes.length,edgeCount:u.edges.length})),$}},PhysicsCustomChart:XA},yP=Uv(require("react")),gP=require("react/jsx-runtime"),mP=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]),xP=Uv(require("react-dom/server")),bP=require("d3-scale"),vP=class{constructor(){this.colorSchemeMap=/* @__PURE__ */new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){const n=e.pieceStyle(t,i);return n&&!n.fill&&i?{...n,fill:this.getColorFromScheme(e,i)}:n}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:zn(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const i=this.colorSchemeMap.get(t);if(i)return i;const n=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||oA,o=n[this.colorSchemeIndex%n.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}},wP=require("d3-array"),kP=require("d3-scale"),AP={bar:function(e,t){const{scales:i,columns:n,config:o,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=i,u=[],d="vertical"===l,h="horizontal"===l,p=o.normalize,f=[];if(s){const e=/* @__PURE__ */new Set;for(const t of Object.values(n))for(const i of t.pieceData){const t=s(i);e.has(t)||(e.add(t),f.push(t))}}else f.push("_default");for(const e of Object.values(n)){const t=/* @__PURE__ */new Map;for(const i of e.pieceData){const e=s?s(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=r(i),n.pieces.push(i)}let i=0;if(p)for(const e of t.values())i+=Math.abs(e.total);let n=0,o=0;for(const r of f){const l=t.get(r);if(!l)continue;let f=l.total;p&&i>0&&(f/=i);const y=a(l.pieces[0],s?r:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>f?o:n+f),i=0>f?c(o+f)-c(o):c(n)-c(n+f);u.push(fh(e.x,t,e.width,Math.abs(i),y,g,r)),0>f?o+=f:n+=f}else if(h){const t=c(0>f?o+f:n),i=0>f?c(o)-c(o+f):c(n+f)-c(n);u.push(fh(t,e.x,Math.abs(i),e.width,y,g,r)),0>f?o+=f:n+=f}}}const y="vertical"===l;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){const e=/* @__PURE__ */new Map;for(const t of u){if("rect"!==t.type)continue;const i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>0>(e.datum?.__aggregateValue??0));if(e.length>0){const t=e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t),i=Dg(o.roundedTop,t,y);i>0&&(t.roundedTop=i)}if(i.length>0){const e=i.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t),t=Dg(o.roundedTop,e,y);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){const{scales:i,columns:n,config:o,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=i,u=[],d="vertical"===l,h=[],p=/* @__PURE__ */new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=s?s(t):"_default";p.has(e)||(p.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(n)){const t=e.width/f,i=.2*t,n=t-i,o=/* @__PURE__ */new Map;for(const t of e.pieceData){const e=s?s(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let s=0;h.length>s;s++){const l=o.get(h[s])||[];for(const o of l){const l=r(o),p=a(o,h[s]);if(d){const r=e.x+s*t+i/2,a=c(0),d=c(l);u.push(fh(r,Math.min(a,d),n,Math.abs(a-d),p,o,h[s]))}else{const r=e.x+s*t+i/2,a=c(0),d=c(l);u.push(fh(Math.min(a,d),r,Math.abs(d-a),n,p,o,h[s]))}}}}for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum),i=Dg(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){const{scales:i,columns:n,getR:o,multiScales:r,resolvePieceStyle:s}=e,{r:a,projection:c}=i,l=[],u="vertical"===c,d="radial"===c,h=r.length>0,p=Bg(e),f=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(n))for(const t of e.pieceData){const i=t.__rIndex??0,n=t.__rValue??o(t),c=h&&r[i]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*f,i=c(n);x=Math.cos(t)*i,b=Math.sin(t)*i}else u?(x=e.middle,b=c(n)):(x=c(n),b=e.middle);Wg(l,p,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:i,columns:n,getR:o,resolvePieceStyle:r}=e,{r:s,projection:a}=i,c=[],l="vertical"===a,u=Bg(e);for(const e of Object.values(n)){const t=e.width/2;for(let i=0;e.pieceData.length>i;i++){const n=e.pieceData[i],a=o(n),d=r(n,e.name),h=d.r||4,p=(7919*i%100/100-.5)*t*.8;Wg(c,u,n,l?e.middle+p:s(a),l?s(a):e.middle+p,h,d)}}return c},pie:Yg,donut:Yg,boxplot:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a,projection:c}=i,l=[],u="vertical"===c,d=!1!==o.showOutliers;for(const t of Object.values(n)){const i=t.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;const n=Xg(i),{min:o,max:c,q1:h,median:p,q3:f}=n,y=f-h,g=h-1.5*y,m=f+1.5*y,x=i.find(e=>e>=g)??o;let b=c;for(let e=i.length-1;e>=0;e--)if(m>=i[e]){b=i[e];break}n.min=x,n.max=b;const v=s(qg(t.pieceData,t.name,n),t.name),w=[];if(d)for(const e of t.pieceData){const i=r(e);if(g>i||i>m){const n=u?t.middle:a(i),o=u?a(i):t.middle;w.push({px:n,py:o,value:i,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(x),q1Pos:a(h),medianPos:a(p),q3Pos:a(f),maxPos:a(b),stats:n,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(const t of w)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return l},violin:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a,projection:c}=i,l=[],u="vertical"===c,d=o.bins||20,h=!1!==o.showIQR;for(const e of Object.values(n)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],n=t[t.length-1],o=(n-i)/d||1,c=Gg(t,i,n,o,d),p=Ps(c,1),f=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(i)}`;for(let t=0;d>t;t++){const n=a(i+(t+.5)*o);y+=` L ${e.middle+c[t]/p*f} ${n}`}y+=` L ${e.middle} ${a(n)}`;for(let t=d-1;t>=0;t--){const n=a(i+(t+.5)*o);y+=` L ${e.middle-c[t]/p*f} ${n}`}y+=" Z"}else{y=`M ${a(i)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(i+(t+.5)*o)} ${e.middle-c[t]/p*f}`;y+=` L ${a(n)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(i+(t+.5)*o)} ${e.middle+c[t]/p*f}`;y+=" Z"}const g=Xg(t),m=s(qg(e.pieceData,e.name,g),e.name);let x;h&&t.length>=4&&(x={q1Pos:a(g.q1),medianPos:a(g.median),q3Pos:a(g.q3),centerPos:e.middle,isVertical:u});const b=u?{x:e.x,y:Math.min(a(n),a(i)),width:e.width,height:Math.abs(a(n)-a(i))}:{x:Math.min(a(i),a(n)),y:e.x,width:Math.abs(a(n)-a(i)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:b,iqrLine:x,stats:g,style:m,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a}=i,c=[],l=o.bins||25,u=o.normalize,d=a.domain?.(),h=d?+d[0]:void 0,p=d?+d[1]:void 0;for(const e of Object.values(n)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[i,n]=_s(t),o=null!=h&&isFinite(h)?h:i,d=null!=p&&isFinite(p)?p:n,f=(d-o)/l||1,y=Gg(t,o,d,f,l),g=t.length,m=Ps(y,1);for(let t=0;l>t;t++){if(0===y[t])continue;const i=(u?y[t]/g:y[t]/m)*e.width*.9,n=a(o+t*f),r=a(o+(t+1)*f),l=Math.min(n,r),d=Math.abs(r-n),h=e.x+e.width-i,p={...e.pieceData[0],bin:t,count:y[t],range:[o+t*f,o+(t+1)*f],category:e.name,data:e.pieceData},x=s(p,e.name);c.push(fh(l,h,d,i,x,p,e.name))}}return c},ridgeline:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a,projection:c}=i,l=[],u=o.bins||20,d="horizontal"===c,h=o.amplitude||1.5;for(const e of Object.values(n)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],n=t[t.length-1],o=(n-i)/u||1,c=Gg(t,i,n,o,u),p=Ps(c,1),f=Xg(t),y=s(qg(e.pieceData,e.name,f),e.name),g=e.width*h;let m;if(d){const t=e.x+e.width;m=`M ${a(i)} ${t}`;for(let e=0;u>e;e++)m+=` L ${a(i+(e+.5)*o)} ${t-c[e]/p*g}`;m+=` L ${a(n)} ${t} Z`}else{const t=e.x;m=`M ${t} ${a(i)}`;for(let e=0;u>e;e++){const n=a(i+(e+.5)*o);m+=` L ${t+c[e]/p*g} ${n}`}m+=` L ${t} ${a(n)} Z`}const x=d?{x:Math.min(a(i),a(n)),y:e.x,width:Math.abs(a(n)-a(i)),height:e.width}:{x:e.x,y:Math.min(a(n),a(i)),width:e.width,height:Math.abs(a(n)-a(i))};l.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:f,style:{...y,fillOpacity:y.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:i,columns:n,getRawRange:o,resolvePieceStyle:r}=e,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const i=o(t);if(!i)continue;const[n,a]=i,u=r(t,e.name);if(l){const i=s(Math.min(n,a)),o=s(Math.max(n,a));c.push(fh(i,e.x,o-i,e.width,u,t,e.name))}else{const i=s(Math.max(n,a)),o=s(Math.min(n,a));c.push(fh(e.x,i,e.width,o-i,u,t,e.name))}}return c},funnel:function(e,t){const{columns:i,getR:n,getStack:o,resolvePieceStyle:r}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=/* @__PURE__ */new Set;for(const e of l)for(const t of e.pieceData){const e=o?o(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],p=[];let f=0;for(const e of l){const t=/* @__PURE__ */new Map;let i=0;for(const r of e.pieceData){const e=o?o(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=n(r);s.total+=a,s.pieces.push(r),i+=a}p.push({col:e,groups:t,stepTotal:i}),h||i>f&&(f=i)}if(h)for(const e of p){let t=0,i=0;for(let n=0;u.length>n;n++){const o=e.groups.get(u[n]);o&&(n%2==0?t+=o.total:i+=o.total)}const n=Math.max(t,i);n>f&&(f=n)}if(0===f)return s;const y=/* @__PURE__ */new Map;for(const e of u){const t=p[0].groups.get(e);y.set(e,t?.total??0)}const g=p[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,kP.scaleLinear)().domain([0,f]).range([0,m]),b=e.config.connectorOpacity??.3;let v=/* @__PURE__ */new Map;for(let t=0;p.length>t;t++){const i=p[t],n=i.col,o=0===t,l=n.width,d=.55*l,f=n.x+(l-d)/2,m=/* @__PURE__ */new Map;if(h){let e=0;for(const t of u){const n=i.groups.get(t);n&&(e+=x(n.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const p=u[h],g=i.groups.get(p);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=r(g.pieces[0],p),A=y.get(p)??g.total,S={...g.pieces[0],__funnelValue:g.total,__funnelPercent:A>0?g.total/A*100:0,__funnelStep:n.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:p};c&&(0===h&&(S.__funnelStepLabel=n.name,S.__funnelStepLabelX=a,S.__funnelStepLabelY=f,S.__funnelRowWidth=e),S.__funnelValueLabelX=w+b/2,S.__funnelValueLabelY=f,S.__funnelBarW=b),s.push(fh(w,f,b,d,k,S,p)),m.set(p,{x:w,y:f,w:b,h:d})}}else{const e=i.stepTotal,t=x(e),l=a-t/2,h=u[0],p="_default"!==h,y=i.groups.get(h)?.pieces[0]??n.pieceData[0],b=p?h:n.name,v=r(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:n.name,__funnelIsFirstStep:o,category:p?h:n.name};c&&(k.__funnelStepLabel=n.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=f,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=f,k.__funnelBarW=t),s.push(fh(l,f,t,d,v,k,b)),m.set(h,{x:l,y:f,w:t,h:d})}if(t>0&&v.size>0){const t=h?u:[u[0]];for(const o of t){const t=v.get(o),a=m.get(o);if(!t||!a)continue;const c=(()=>{const e=i.groups.get(o);return r(e?e.pieces[0]:n.pieceData[0],"_default"===o?n.name:o)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b,cursor:c.cursor},datum:i.groups.get(o)?.pieces[0]??n.pieceData[0],category:"_default"===o?n.name:o};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:i,getR:n,getStack:o,resolvePieceStyle:r,scales:s}=e,a=[],c=s.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return a;const l=[],u=/* @__PURE__ */new Set;for(const e of c)for(const t of e.pieceData){const e=o?o(t):"_default";u.has(e)||(u.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=/* @__PURE__ */new Map;let i=0;for(const r of e.pieceData){const e=o?o(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=n(r);s.total+=a,s.pieces.push(r),i+=a}h.push({col:e,groups:t,stepTotal:i})}const p=/* @__PURE__ */new Map;for(const e of l){const t=h[0]?.groups.get(e);p.set(e,t?.total??0)}const f=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],i=t.col,n=0===e,o=e>0?h[e-1]:null,s=i.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=p.get(h)??g,x=m>0?g/m*100:0,b=o?.groups.get(h),v=n?0:Math.max(0,(b?.total??g)-g),w=i.x+e*s+c/2,k=f(g),A=f(0)-k,S=r(y.pieces[0],d?h:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:f(g+v)};if(a.push(fh(w,k,u,A,S,M,d?h:i.name)),v>0){const e=f(g+v),t=k-e,n={...S},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name};a.push(fh(w,e,u,t,n,o,d?h:i.name))}}}return a},swimlane:function(e,t){const{scales:i,columns:n,getR:o,getStack:r,resolvePieceStyle:s}=e,{r:a,projection:c}=i,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",p=/* @__PURE__ */new Map,f=t=>{const i=p.get(t);if(void 0!==i)return i;const n="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof n&&Number.isFinite(n)?Math.max(0,n):0;return p.set(t,o),o},y=e.config.trackFill;if(y){const e="string"==typeof y?y:y.color,t="string"==typeof y?1:y.opacity??1,[i,o]=a.range(),r=Math.min(i,o),s=Math.abs(o-i);for(const i of Object.values(n)){const n={fill:e,opacity:t},o=u?fh(r,i.x,s,i.width,n,null,"__track__"):fh(i.x,r,i.width,s,n,null,"__track__"),a=f(i);a>0&&(o.cornerRadii={tl:a,tr:a,br:a,bl:a}),l.push(o)}}for(const e of Object.values(n)){let t=0;const i=l.length,n=f(e);for(const i of e.pieceData){const n=Math.abs(o(i));if(0===n)continue;const c=r?r(i):e.name,p=s(i,c);let f;if(u){const o=a(t),r=a(t+n);f=fh(o,e.x,r-o,e.width,p,i,c)}else{const o=a(t+n),r=a(t);f=fh(e.x,o,e.width,r-o,p,i,c)}d&&(f.fillGradient=d,f.roundedEdge=h),l.push(f),t+=n}if(n>0&&l.length>i){const e=l.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:n,tr:n,br:n,bl:n}:u?(t.cornerRadii={tl:n,bl:n},o.cornerRadii={tr:n,br:n}):(t.cornerRadii={bl:n,br:n},o.cornerRadii={tl:n,tr:n})}}return l}},SP=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],MP=["scene-style","data-paint","accessibility","evidence"],_P=(e,t)=>({retainedData:e,invalidations:t}),$P=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],PP=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jP=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],IP=["scene-geometry","data-paint","accessibility","evidence"],LP=["scene-style","data-paint","accessibility","evidence"],RP=[],CP={chartType:_P("rebuild",$P),runtimeMode:_P("rebuild",$P),categoryAccessor:_P("rebuild",$P),valueAccessor:_P("rebuild",$P),oAccessor:_P("rebuild",$P),rAccessor:_P("rebuild",$P),stackBy:_P("rebuild",$P),groupBy:_P("rebuild",$P),timeAccessor:_P("rebuild",$P),accessorRevision:_P("rebuild",$P),colorAccessor:_P("rebuild",LP),symbolAccessor:_P("rebuild",IP),connectorAccessor:_P("rebuild",IP),dataIdAccessor:_P("rebuild",IP),projection:_P("preserve",PP),extentPadding:_P("preserve",PP),axisExtent:_P("preserve",PP),rExtent:_P("preserve",PP),oExtent:_P("preserve",PP),multiAxis:_P("preserve",PP),normalize:_P("preserve",PP),bins:_P("preserve",PP),oSort:_P("preserve",jP),barPadding:_P("preserve",jP),roundedTop:_P("preserve",jP),baselinePadding:_P("preserve",jP),innerRadius:_P("preserve",jP),cornerRadius:_P("preserve",jP),startAngle:_P("preserve",jP),sweepAngle:_P("preserve",jP),trackFill:_P("preserve",jP),showOutliers:_P("preserve",jP),showIQR:_P("preserve",jP),amplitude:_P("preserve",jP),connectorOpacity:_P("preserve",jP),showLabels:_P("preserve",jP),dynamicColumnWidth:_P("rebuild",jP),customLayout:_P("preserve",jP),layoutConfig:_P("preserve",jP),layoutMargin:_P("preserve",jP),symbolMap:_P("preserve",IP),pieceStyle:_P("preserve",LP),summaryStyle:_P("preserve",LP),connectorStyle:_P("preserve",LP),gradientFill:_P("preserve",LP),colorScheme:_P("preserve",LP),themeCategorical:_P("preserve",LP),themeSemantic:_P("preserve",LP),themeSequential:_P("preserve",LP),themeDiverging:_P("preserve",LP),barColors:_P("preserve",LP),decay:_P("preserve",LP),pulse:_P("preserve",LP),staleness:_P("preserve",LP),layoutSelection:_P("preserve",LP),windowSize:_P("preserve",RP),windowMode:_P("preserve",RP),clock:_P("preserve",RP),transition:_P("preserve",RP),introAnimation:_P("preserve",RP),onLayoutError:_P("preserve",RP)},TP=_P("preserve",jP),OP=class{constructor(){this.tracker=new yk}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},SP)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},MP):this.recordNoop("restyle")}recordConfig(e){const t=Kg(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},EP=require("d3-quadtree"),FP=class{constructor(e){this.rExtent=new h_,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new OP,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new vP,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new d_(e.windowSize),this.getO=ud(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>cd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new h_)):(this.getR=cd(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=ud(e.stackBy),this.getGroup=ud(e.groupBy),this.getColor=ud(e.colorAccessor),this.getSymbol=ud(e.symbolAccessor),this.getConnector=ud(e.connectorAccessor),this.getDataId=ud(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new d_(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,n;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,n=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:Oh(t,n):null)}currentTime(){return this.config.clock?.()??bd()}ingest(e){const t=this.currentTime();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(),Th(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Eh(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of e.inserts){const e=Eh(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}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 i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){const{config:t,buffer:i}=this,n=this.scales,o=this.multiScales,r=this.columns;if(0===i.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let p,f;if(d){p=(0,bP.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(e.width,e.height)/2,n=t.innerRadius||0;f=(0,bP.scaleLinear)().domain(l).range([n,i])}else u?(p=(0,bP.scaleBand)().domain(c).range([0,e.height]).padding(h),f=(0,bP.scaleLinear)().domain(l).range([0,e.width])):(p=(0,bP.scaleBand)().domain(c).range([0,e.width]).padding(h),f=(0,bP.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:p,r:f,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((n,o)=>{const r=this.rExtents[o];r.dirty&&r.recalculate(i,n);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,bP.scaleLinear)().domain([s,a]).range([0,e.width]):(0,bP.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,c,p,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=n,this.multiScales=o,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),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,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:"value"+e}resolveCategories(e){const t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,n="auto"===t?void 0:t;let o=null;if(i){o=/* @__PURE__ */new Set;for(const t of e)o.add(this.getO(t))}const r=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===n){const e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===n)return r;if("function"==typeof n)return r.sort(n);const s=/* @__PURE__ */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){return Vg({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,i,n,o){return Hg({data:e,oExtent:t,oScale:i,projection:n,layout:o,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(e,t),n=eh({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);const o=n.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const r=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return Ud({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const i=this.getSceneContext(),n=AP[this.config.chartType];let o=n?n(i,t):[];return this.getConnector&&this.scales&&(o=[...zg(i,o),...o]),o}buildLayoutContext(e,t){const i=this.config,n=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Yn(i.colorScheme,i.themeCategorical,oA),r=this.scales;return{data:e,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:t.width,height:t.height,margin:n,plot:"radial"===r.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:[...o]},resolveColor:qn(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?kd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=Ad(e);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=Ug(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=Zg(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const i=t.length;if(1>=i)return;const n=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=n.get(t.datum);if(null==e)continue;const o=this.computeDecayOpacity(e,i);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&Ng(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Pd(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=/* @__PURE__ */new Map,t=this.scales?.r(0)??0,i="horizontal"!==this.scales?.projection;let n;for(let o=0;this.scene.length>o;o++){const r=this.scene[o],s=this.getNodeKey(r,e);s&&("rect"===r.type?this.prevPositionMap.set(s,i?{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}:{x:t,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===n&&(n=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:n,endAngle:n,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,n=t.get(i)||0;return t.set(i,n+1),`${i}:${n}`}if("rect"===e.type){const i=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",n=`r:${e.group||""}:${i}`,o=t.get(n)||0;return t.set(n,o+1),0===o?n:`${n}:${o}`}return"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=/* @__PURE__ */new Map;for(let t=0;this.scene.length>t;t++){const i=this.scene[t],n=this.getNodeKey(i,e);n&&("point"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(n,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const i=/* @__PURE__ */new Set,n=/* @__PURE__ */new Map;for(let e=0;this.scene.length>e;e++){const o=this.scene[e],r=this.getNodeKey(o,n);if(!r)continue;o._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===o.type)s?(i.add(r),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(s.x!==o.x||s.y!==o.y||void 0!==s.r&&s.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=s.x,o.y=s.y,void 0!==s.r&&(o.r=s.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)s?(i.add(r),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,s.x===o.x&&s.y===o.y&&s.w===o.w&&s.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=s.x,o.y=s.y,o.w=s.w??o.w,o.h=s.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(s)i.add(r),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,s.startAngle===o.startAngle&&s.endAngle===o.endAngle||(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=s.startAngle,o.endAngle=s.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;const e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,n]of this.prevPositionMap)if(!i.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:n.x,y:n.y,r:n.r??3,style:{opacity:n.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:n.x,y:n.y,w:n.w??0,h:n.h??0,style:{opacity:n.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((n.startAngle??0)+(n.endAngle??0))/2,i={type:"wedge",cx:n.x,cy:n.y,innerRadius:n.innerRadius??0,outerRadius:n.outerRadius??100,startAngle:n.startAngle??0,endAngle:n.endAngle??0,style:{opacity:n.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(i)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=md(e,this.activeTransition),i=gd(t,"linear"===this.config.transition?.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);e.style.opacity=xd(n?n.opacity??1:0,e._targetOpacity,i)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=xd(n.x,e._targetX,i),e.y=xd(n.y,e._targetY,i)),void 0!==e._targetR&&void 0!==n?.r&&(e.r=xd(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t);e.style.opacity=xd(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=xd(n.x,e._targetX,i),e.y=xd(n.y,e._targetY,i),void 0!==n.w&&(e.w=xd(n.w,e._targetW,i),e.h=xd(n.h,e._targetH,i))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t);e.style={...e.style,opacity:xd(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const n=this.prevPositionMap.get(t);n&&void 0!==n.startAngle&&(e.startAngle=xd(n.startAngle,e._targetStartAngle,i),e.endAngle=xd(n.endAngle,e._targetEndAngle,i))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...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}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null,Vh(this.scene),this.exitNodes=[]}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}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=yd(e),i=this.getDataId,n=e=>t.has(i(e));Fh(this.buffer,this.timestampBuffer,n);const o=this.buffer.remove(n);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=yd(e),n=this.getDataId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(n(e))&&o.add(t)});const r=this.buffer.update(e=>i.has(n(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),o.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),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.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const i=this._customRestyle;if(i)for(const n of e){const e=this._baseStyles.get(n)??n.style??{},o=i(n,t);n.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!ad(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!ad(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!ad(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let n=!1;("categoryAccessor"in e||"oAccessor"in e)&&(ad(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=ud(this.config.categoryAccessor||this.config.oAccessor,"category"),n=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,n=Array.isArray(e)?e:[e],r=Array.isArray(i)?i:[i];if(o=n.length!==r.length||n.some((e,t)=>!ad(e,r[t])),o){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>cd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new h_)):(this.getR=cd(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!ad(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?ud(this.config.stackBy):void 0),"groupBy"in e&&!ad(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?ud(this.config.groupBy):void 0),"colorAccessor"in e&&!ad(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ud(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!ad(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ud(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!ad(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?ud(this.config.connectorAccessor):void 0),(n||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};qh(FP);var NP=Uv(require("react")),zP=Uv(require("react")),DP=require("d3-shape"),BP=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)}),WP=require("react/jsx-runtime"),YP=require("react/jsx-runtime"),qP=require("react/jsx-runtime"),XP=require("react/jsx-runtime"),GP=Uv(require("react-dom/server")),VP=/* @__PURE__ */Object.create(null),HP=require("d3-array"),UP=require("d3-array"),KP=require("d3-interpolate"),ZP=(require("d3-shape"),.5),QP=e=>{let t,i,n,o,r,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,i=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,r=e.source.x1,s=e.target.x0,a=(0,KP.interpolateNumber)(r,s),c=a(ZP),l=a(.5),`M${t},${r}C${t},${c} ${i},${l} ${i},${s}L${n},${s}C${n},${l} ${o},${c} ${o},${r}Z`;const u=e.sankeyWidth/2,d=(0,KP.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=$u({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(ZP),cp2X:d(.5)});return h},JP=/* @__PURE__ */new Set,ej=/* @__PURE__ */new WeakMap,tj={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(Im))-1:0},justify:Lm},ij={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,n){if(0===e.length)return;const o="vertical"===i.orientation?"down":"right",r=i.nodeAlign||"justify",s=i.nodeWidth??15,a=i.nodePaddingRatio??.05,c=i.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:hd(e.source),target:hd(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const h=dx().extent(d).links(u).nodes(l).nodeAlign(tj[r]||Lm).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,i=1/0,o=-1/0;for(const n of l)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),i>n.y0&&(i=n.y0),n.y1>o&&(o=n.y1);for(const n of u){if(!n.circular||!n.circularPathData)continue;const r=n.circularPathData,s=(n._circularWidth??n.width??0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),i>r.verticalFullExtent-s&&(i=r.verticalFullExtent-s),r.verticalFullExtent+s>o&&(o=r.verticalFullExtent+s)}const r=t-e,s=o-i,a=n[0],c=n[1];if(r>0&&s>0&&(0>e||0>i||t>a||o>c)){const t=Math.min(a/r,c/s),n=-e*t+(a-r*t)/2,o=-i*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const i=e.circularPathData;i.sourceX=i.sourceX*t+n,i.targetX=i.targetX*t+n,i.sourceY=i.sourceY*t+o,i.targetY=i.targetY*t+o,i.rightFullExtent=i.rightFullExtent*t+n,i.leftFullExtent=i.leftFullExtent*t+n,i.verticalFullExtent=i.verticalFullExtent*t+o,i.rightInnerExtent=i.rightInnerExtent*t+n,i.leftInnerExtent=i.leftInnerExtent*t+n,i.verticalRightInnerExtent=i.verticalRightInnerExtent*t+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*t+o,i.rightSmallArcRadius*=t,i.rightLargeArcRadius*=t,i.leftSmallArcRadius*=t,i.leftLargeArcRadius*=t,i.sourceWidth*=t,i.rightNodeBuffer*=t,i.leftNodeBuffer*=t,i.arcRadius*=t}}}const p=/* @__PURE__ */new Map;for(const t of e)p.set(t.id,t);for(const e of l){const t=p.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 f=/* @__PURE__ */new Map;for(const e of t)if(e._edgeKey)f.set(e._edgeKey,e);else{const t=hd(e.source),i=hd(e.target);f.set(`${t}\0${i}`,e)}for(const e of u){const t=hd(e.source),i=hd(e.target),n=f.get(e._edgeKey?e._edgeKey:`${t}\0${i}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=e.width??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=o;const r=p.get(t),s=p.get(i);r&&(n.source=r),s&&(n.target=s)}}},buildScene(e,t,i,n){const o="vertical"===i.orientation?"down":"right",r=i.nodeStyle,s=i.edgeStyle,a=i.edgeOpacity??.5,c=i.edgeColorBy||"source",l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Tk,u=/* @__PURE__ */new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],p=[],f=/* @__PURE__ */new Map;for(const t of e){const e=t.x1-t.x0,i=t.y1-t.y0;if(0>=e||0>=i)continue;const n=r?r(px(t,"nodeStyle")):{},s={fill:n.fill||u.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity,cursor:n.cursor};f.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){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 o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?f.get(n.id)||u.get(n.id)||o:f.get(t.id)||u.get(t.id)||o;const r=s?s(px(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,i=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-i}L${t.sourceX+n},${t.sourceY-i}L${t.sourceX+n},${t.sourceY+i}L${t.sourceX},${t.sourceY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-i}L${t.targetX-s},${t.targetY-i}L${t.targetX-s},${t.targetY+i}L${t.targetX},${t.targetY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;l=e.circular&&e.circularPathData?hx(e):QP(e),l&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:r.fill||o,fillOpacity:r.fillOpacity??a,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor},datum:e})}if(!1!==i.showLabels){const t=dd(i.nodeLabel);for(const i of e){const e=i.x1-i.x0,r=i.y1-i.y0;if(0>=e||0>=r)continue;const s=t?t(i):i.id;if(!s)continue;let a,c,l;"down"===o?(a=i.y0+(i.y1-i.y0)/2,c=i.x1+14,l="start"):(n[0]/2>i.x0+e/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),c=i.y0+r/2),p.push({x:a,y:c,text:s+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:p}}};hm("sankey",ij);var nj=require("d3-force"),oj=require("d3-scale"),rj={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,n){if(0===e.length)return;const o=i.forceStrength??.1,r=n[0]/2,s=n[1]/2,a=Math.max(.1,Math.min(1,Math.min(n[0],n[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=i.__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),i=l?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const i=/* @__PURE__ */new Map;for(const t of e)i.set(t.id,t);for(const e of d){const n=gx(e.id,t,i);if(n.length>0){let t=0,i=0;for(const e of n)t+=e.x,i+=e.y;const o=xx(e.id),r=o%360*(Math.PI/180),s=(10+o%20)*a;e.x=t/n.length+s*Math.cos(r),e.y=i/n.length+s*Math.sin(r)}else{const t=xx(e.id),i=t%360*(Math.PI/180),n=(15+t%30)*a;e.x=r+n*Math.cos(i),e.y=s+n*Math.sin(i)}}}else{const t=2.399963229728653;for(let i=0;e.length>i;i++){const n=e[i];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(i+.5)*a,o=i*t;n.x=r+e*Math.cos(o),n.y=s+e*Math.sin(o)}}}const p=i.__skipForceSimulation||0===i.iterations?0:h?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=fx(i.nodeSize,i.nodeSizeRange,e),y=e=>f(e);if(p>0){const l=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t=hd(e.source),i=hd(e.target);l.set(t,(l.get(t)??0)+1),l.set(i,(l.get(i)??0)+1)}const d=(0,nj.forceLink)().strength(e=>{const t=e.weight,i=hd(e.source),n=hd(e.target),r=Math.max(1,Math.min(l.get(i)??1,l.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*r))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,n=(t?y(t):0)+(i?y(i):0)+Math.max(6,12*a);return Math.max(16,40*a,n)}).id(e=>e.id),f=(0,nj.forceSimulation)();if(void 0===i.random&&void 0===i.seed||f.randomSource(i.random??yx(i.seed)),f.force("charge",(0,nj.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,nj.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,nj.forceCenter)(r,s).strength(.8)).force("x",(0,nj.forceX)(r).strength(c)).force("y",(0,nj.forceY)(s).strength(c)).force("bounds",mx(n,y)),f.nodes(e),t.length>0){const e=t.map(e=>({...e,source:hd(e.source),target:hd(e.target)}));d.links(e),f.force("link",d)}h?f.alpha(.3):.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;p>e;++e)f.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),i=p>0?2:0,o=Math.min(n[0]/2,e+i),r=Math.min(n[1]/2,e+i);t.x=Math.max(o,Math.min(n[0]-o,t.x)),t.y=Math.max(r,Math.min(n[1]-r,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const g=/* @__PURE__ */new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,n){const o=i.nodeStyle,r=i.edgeStyle,s=fx(i.nodeSize,i.nodeSizeRange,e),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Tk,c=/* @__PURE__ */new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(px(t,"nodeSize")),n=o?o(px(t,"nodeStyle")):{},r={fill:n.fill||c.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity,cursor:n.cursor};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id})}const h=/* @__PURE__ */new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),n="object"==typeof e.target?e.target:h.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=r?r(px(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor},datum:e})}if(!1!==i.showLabels){const t=dd(i.nodeLabel);for(const i of e){if(null==i.x||null==i.y)continue;const e=t?t(i):i.id;if(!e)continue;const n=s(px(i,"nodeSize"));d.push({x:i.x,y:i.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:l,sceneEdges:u,labels:d}}};hm("force",rj);var sj=require("d3-chord"),aj=require("d3-shape"),cj=Tk,lj={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=i,a=Math.min(n[0],n[1])/2,c=a-r,l=n[0]/2,u=n[1]/2,d=(h=i.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const p=/* @__PURE__ */new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const f=e.length,y=Array.from({length:f},()=>Array(f).fill(0));for(const e of t){const t=hd(e.source),i=hd(e.target),n=p.get(t),o=p.get(i);if(void 0===n||void 0===o)continue;const r=d(e);y[n][o]=r}const g=(0,sj.chord)().padAngle(o);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,aj.arc)().innerRadius(c).outerRadius(a);for(const t of x){const i=e[t.index],n=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});i.x=n[0]+l,i.y=n[1]+u,i.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=/* @__PURE__ */new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t=hd(e.source),i=hd(e.target),n=v.get(t),o=v.get(i);n&&(e.source=n),o&&(e.target=o)}const w=/* @__PURE__ */new Map;for(const e of t){const t=hd(e.source),i=hd(e.target);w.set(`${t}\0${i}`,e)}for(const t of m){const i=e[t.source.index].id,n=e[t.target.index].id,o=w.get(`${i}\0${n}`)||w.get(`${n}\0${i}`);o&&(o.__chordData=t)}},buildScene(e,t,i,n){const{groupWidth:o=20,edgeOpacity:r=.5}=i,s=Math.min(n[0],n[1])/2,a=s-o,c=n[0]/2,l=n[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:cj,f=/* @__PURE__ */new Map;e.forEach((e,t)=>{f.set(e.id,p[t%p.length])});const y=(0,sj.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const i=e[t],n=i.__arcData;if(!n)continue;const o=u?u(px(i,"nodeStyle")):{},r=("string"==typeof o.fill?o.fill:void 0)||f.get(i.id)||p[t%p.length];g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:r,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor},datum:i,id:i.id,label:i.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=y(t);if(!n)continue;const o=bx(n,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";const a=d?d(px(e,"edgeStyle")):{};if(d)s=("string"==typeof a.fill?a.fill:void 0)||s;else{const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?s=f.get(i.id)||s:t&&(s=f.get(t.id)||s)}m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity,cursor:a.cursor},datum:e})}if(!1!==i.showLabels){const t=dd(i.nodeLabel),n=s+12;for(const i of e){const e=i.__arcData;if(!e)continue;const o=t?t(i):i.id;if(!o)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*n,y:l+Math.sin(s)*n,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:x}}};hm("chord",lj);var uj=require("d3-hierarchy"),dj=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],hj={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;if(!o)return;const r=i.chartType,s=kx(i.childrenAccessor),a=i.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,uj.hierarchy)(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(r){case"tree":Lx(l,i,u,d);break;case"cluster":Rx(l,i,u,d);break;case"treemap":Cx(l,i,u,d);break;case"circlepack":Tx(l,i,u,d);break;case"partition":Ox(l,i,u,d)}const h=l.descendants();e.length=0,t.length=0;const p=/* @__PURE__ */new Map;for(let t=0;h.length>t;t++){const n=h[t],o={id:Ax(n,i,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:n.value??0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===r||"cluster"===r?Ex(o,n,i):"treemap"===r||"partition"===r?Fx(o,n):"circlepack"===r&&Nx(o,n),o.__hierarchyNode=n,e.push(o),p.set(n,o)}if("tree"===r||"cluster"===r)for(const e of h)if(e.parent){const i=p.get(e.parent),n=p.get(e);i&&n&&t.push({source:i,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,n){const o=i.nodeStyle||(()=>({})),r=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return $x(e,t,i,n,o,r);case"treemap":case"partition":return Px(e,i,0,o);case"circlepack":return jx(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};hm("tree",hj),hm("cluster",hj),hm("treemap",hj),hm("circlepack",hj),hm("partition",hj);var pj=require("d3-shape"),fj={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;o&&qx(o,n,i,e,t)},buildScene(e,t,i,n){const o=i.nodeStyle,r=i.edgeStyle,s=i.nodeSize,a="number"==typeof s?()=>s:"function"==typeof s?s:()=>6,c=[],l=[],u=[];if(!1!==i.orbitShowRings){const t=zx(i),n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,t);const o=/* @__PURE__ */new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{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:i,ecc:n}]of o)for(let o=0;r>o;o++){const a=o/r*Math.PI*2,c=(o+1)/r*Math.PI*2;l.push({type:"line",x1:e+i*Math.sin(a),y1:t+i*Math.cos(a)*n,x2:e+i*Math.sin(c),y2:t+i*Math.cos(c)*n,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(px(t,"nodeSize")),n=o?o(px(t,"nodeStyle")):{};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:n.fill||i.themeSemantic?.primary||"#6366f1",stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??(0===(t.depth??0)?1:.85),cursor:n.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}const d=/* @__PURE__ */new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i)continue;if(null==t.x||null==i.x)continue;const n=r?r(px(e,"edgeStyle")):{};l.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:n.stroke||"rgba(128,128,128,0.35)",strokeWidth:n.strokeWidth??.5,opacity:n.opacity??1,cursor:n.cursor},datum:e})}if(i.showLabels){const t=i.nodeLabel;for(const i of e){const e=a(px(i,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(e,t,i,n,o)=>!1!==i.orbitAnimated&&(Xx(e,i),!0)};hm("orbit",fj);var yj=Uv(require("react")),gj=require("d3-shape"),mj=require("react/jsx-runtime"),xj=require("react/jsx-runtime");hm("sankey",ij),hm("force",rj),hm("chord",lj),hm("tree",hj),hm("cluster",hj),hm("treemap",hj),hm("circlepack",hj),hm("partition",hj),hm("orbit",fj);var bj=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]),vj=Uv(require("react-dom/server")),wj=require("d3-geo"),kj=require("d3-quadtree"),Aj=require("d3-geo"),Sj={mercator:Aj.geoMercator,equalEarth:Aj.geoEqualEarth,albersUsa:Aj.geoAlbersUsa,orthographic:Aj.geoOrthographic,naturalEarth:Aj.geoNaturalEarth1,equirectangular:Aj.geoEquirectangular},Mj=require("d3-scale"),_j=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$j=["scene-style","data-paint","accessibility","evidence"],Pj=(e,t)=>({retainedData:e,invalidations:t}),jj=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ij=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lj=["scene-geometry","data-paint","accessibility","evidence"],Rj=["scene-style","data-paint","accessibility","evidence"],Cj=["overlay","accessibility","evidence"],Tj=[],Oj={xAccessor:Pj("rebuild",jj),yAccessor:Pj("rebuild",jj),lineDataAccessor:Pj("rebuild",jj),pointIdAccessor:Pj("rebuild",Lj),lineIdAccessor:Pj("rebuild",Lj),windowSize:Pj("rebuild",jj),projection:Pj("preserve",Ij),projectionExtent:Pj("preserve",Ij),fitPadding:Pj("preserve",Ij),lineType:Pj("preserve",Ij),flowStyle:Pj("preserve",Ij),graticule:Pj("preserve",Ij),projectionTransform:Pj("preserve",Ij),customLayout:Pj("preserve",Ij),layoutConfig:Pj("preserve",Ij),layoutMargin:Pj("preserve",Ij),areaStyle:Pj("preserve",Rj),pointStyle:Pj("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Pj("preserve",Rj),colorScheme:Pj("preserve",Rj),themeCategorical:Pj("preserve",Rj),themeDiverging:Pj("preserve",Rj),themeSemantic:Pj("preserve",Rj),themeSequential:Pj("preserve",Rj),decay:Pj("preserve",Rj),pulse:Pj("preserve",Rj),layoutSelection:Pj("preserve",Rj),annotations:Pj("preserve",Cj),autoPlaceAnnotations:Pj("preserve",Cj),clock:Pj("preserve",Tj),transition:Pj("preserve",Tj),introAnimation:Pj("preserve",Tj),onLayoutError:Pj("preserve",Tj)},Ej=Pj("preserve",Ij),Fj=class{constructor(){this.tracker=new yk}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},_j)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},$j):this.recordNoop("restyle")}recordConfig(e,t={}){const i=bb(e),n=new Set(i.invalidations);return t.retainedDataChanged&&n.add("data"),this.tracker.record({kind:"config",keys:e},n)}},Nj=require("d3-geo"),zj=class e{constructor(e){this.updateResults=new Fj,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=kb(e)}currentTime(){return this.config.clock?.()??bd()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],n=t.slice(-e),o=i.slice(-n.length),r=this.currentTime();this.pointBuffer=new d_(e),this.timestampBuffer=new d_(e),n.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=Ab(e),i=this.config,n=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);this.config={...this.config,...t};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==n;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,n=this.timestampBuffer?.toArray()??[],o=i.slice(-t),r=n.slice(-o.length),s=this.currentTime();this.pointBuffer=new d_(t),this.timestampBuffer=new d_(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??s)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();Eh(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const i of e)Eh(this.pointBuffer,i,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const i="function"==typeof t?t:e=>e[t],n=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!n.has(i(e)+"")||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof t?t:e=>e[t],n=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>n.has(i(e)+"");Fh(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!n.has(i(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const i of this.scene){const n=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...n,...o}:n}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,i=this.projection,n=this.geoPath,o=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=rb(t.projection),this.geoPath=(0,wj.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,wj.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=n,this.scales=o,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,i=e.height/2,n=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));n.length>0&&this.startTransition(n)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,i=this.config,n=[...this.areas],o=sb(i.xAccessor,"lon"),r=sb(i.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[o(e),r(e)]);n.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=ab(i.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[o(e),r(e)]);n.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==n.length){if(i.projectionExtent){const[[n,o],[r,s]]=i.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[n,o],[n,s],[r,s],[r,o],[n,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const n=i.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*n),t.translate([e.width/2,e.height/2])}else{const o=i.fitPadding??0,r=e.width*o,s=e.height*o;t.fitExtent([[r,s],[e.width-r,e.height-s]],{type:"FeatureCollection",features:n})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const i=this.projection;if(!i)return;const n=this.geoPath,o=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,wj.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=n,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const i=this.projection;if(!i)return;const n=this.geoPath,o=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,wj.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=n,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const i=this.projection;if(!i||!i.rotate)return;const n=this.geoPath,o=this.scales,r=[...i.rotate()];i.rotate(e),this.geoPath=(0,wj.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(r),this.geoPath=n,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,i=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(i++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);const n=Array(i);let o=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(n[o++]=e);this._quadtree=(0,kj.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,i=this.projection,n=this.geoPath;if(t.customLayout&&this.scales){const i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Yn(t.colorScheme,t.themeCategorical,oA),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...n]},resolveColor:qn(n,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},r=eh({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);const s=r.result,a=s.nodes??[];if(this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null,this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this._baseStyles=/* @__PURE__ */new WeakMap,this.hasCustomRestyle)for(const e of a){this._baseStyles.set(e,e.style);const i=s.restyle?.(e,t.layoutSelection??null);i&&(e.style={...e.style,...i})}return Ud({label:"geo customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,vb({config:t,projection:i,path:n,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const i=gb(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const i=this.scene.filter(e=>"point"===e.type);for(let n=0;i.length>n;n++){const o=kd(e,n,t);i[n]._decayOpacity=o,i[n].style={...i[n].style,opacity:o}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const i=this.scene.filter(e=>"point"===e.type),n=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",r=t.glowRadius??4;let s=!1;for(let a=0;i.length>a&&n.length>a;a++){const c=Md(t,n[a],e);s=$d(i[a],c,o,r)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Pd(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const i=/* @__PURE__ */new Map;for(const t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);const n=this.scene.filter(e=>"point"===e.type);let o=!1;for(const e of n)if(e.pointId){const t=i.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(o=!0))}for(const e of n)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(const e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;const t=md(e,this.activeTransition),i=gd(t),n=this.scene.filter(e=>"point"===e.type);for(const e of n){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=xd(e.x,e._targetX,i),e.y=xd(t,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(const e of n)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};zj.QUADTREE_THRESHOLD=500;var Dj=zj;qh(Dj);var Bj=Uv(require("react")),Wj=require("react/jsx-runtime"),Yj=require("react/jsx-runtime"),qj=require("react/jsx-runtime"),Xj=Uv(require("react-dom/server")),Gj={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85},Vj=require("react/jsx-runtime"),Hj={top:0,right:0,bottom:0,left:0},Uj=require("react/jsx-runtime"),Kj=require("d3-scale"),Zj=require("react/jsx-runtime"),Qj={top:0,right:0,bottom:0,left:0},Jj=Uv(require("react-dom/server")),eI=require("react/jsx-runtime"),tI={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},iI={BigNumber:function(e,t){const i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",n=tI[i],o=sv(e.width,n.width),r=sv(e.height,n.height),s="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):n.padding,a="center"===e.align||"end"===e.align||"start"===e.align?e.align:n.align,c="center"===a?"middle":"end"===a?"end":"start",l="center"===a?o/2:"end"===a?o-s:s,u=zr(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=iv("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),p=void 0===d?"No value":(f=h(d),`${("string"==typeof e.prefix?e.prefix:void 0)??""}${f}${("string"==typeof e.suffix?e.suffix:void 0)??""}`);var f;const y=void 0===d?void 0:rv(d,e.thresholds),g="string"==typeof e.color?e.color:av(y?.level??"neutral",y?.color,u),m="string"==typeof e.label?e.label:void 0,x="string"==typeof e.caption?e.caption:void 0,b="string"==typeof e.unit?e.unit:void 0,v=[void 0===d?void 0:cv(e,d,h),void 0===d?void 0:lv(e,d,h),y?.label].filter(Boolean).join(" · "),w="string"==typeof e.description&&e.description||[m,p,b,v].filter(Boolean).join(", "),k="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,A="string"==typeof e.borderColor?e.borderColor:u.colors.border,S=s+n.labelSize,M=S+n.captionSize+4,_="presentation"===i?r/2+.32*n.valueSize:"thumbnail"===i?r/2+.34*n.valueSize:Math.min(r-s-(v?26:4),(n.showHeader&&(m||x)?x?M+10:S+14:s)+n.valueSize),$=l+("start"===c?Math.max(n.valueSize,p.length*n.valueSize*.55):0),P=Jj.renderToStaticMarkup(
|
|
643
|
+
/* @__PURE__ */(0,uP.jsx)("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=hp({frameType:"physics",width:a,height:c,parts:[],additionalMarkCountByType:{task:u.nodes.length,dependency:u.edges.length},title:l,description:S,categories:u.lanes,nodeCount:u.nodes.length,edgeCount:u.edges.length})),$}},PhysicsCustomChart:XA},yP=Uv(require("react")),gP=require("react/jsx-runtime"),mP=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]),xP=Uv(require("react-dom/server")),bP=require("d3-scale"),vP=class{constructor(){this.colorSchemeMap=/* @__PURE__ */new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){const n=e.pieceStyle(t,i);return n&&!n.fill&&i?{...n,fill:this.getColorFromScheme(e,i)}:n}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:Wn(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const i=this.colorSchemeMap.get(t);if(i)return i;const n=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||oA,o=n[this.colorSchemeIndex%n.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}},wP=require("d3-array"),kP=require("d3-scale"),AP={bar:function(e,t){const{scales:i,columns:n,config:o,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=i,u=[],d="vertical"===l,h="horizontal"===l,p=o.normalize,f=[];if(s){const e=/* @__PURE__ */new Set;for(const t of Object.values(n))for(const i of t.pieceData){const t=s(i);e.has(t)||(e.add(t),f.push(t))}}else f.push("_default");for(const e of Object.values(n)){const t=/* @__PURE__ */new Map;for(const i of e.pieceData){const e=s?s(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=r(i),n.pieces.push(i)}let i=0;if(p)for(const e of t.values())i+=Math.abs(e.total);let n=0,o=0;for(const r of f){const l=t.get(r);if(!l)continue;let f=l.total;p&&i>0&&(f/=i);const y=a(l.pieces[0],s?r:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>f?o:n+f),i=0>f?c(o+f)-c(o):c(n)-c(n+f);u.push(fh(e.x,t,e.width,Math.abs(i),y,g,r)),0>f?o+=f:n+=f}else if(h){const t=c(0>f?o+f:n),i=0>f?c(o)-c(o+f):c(n+f)-c(n);u.push(fh(t,e.x,Math.abs(i),e.width,y,g,r)),0>f?o+=f:n+=f}}}const y="vertical"===l;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){const e=/* @__PURE__ */new Map;for(const t of u){if("rect"!==t.type)continue;const i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>0>(e.datum?.__aggregateValue??0));if(e.length>0){const t=e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t),i=Dg(o.roundedTop,t,y);i>0&&(t.roundedTop=i)}if(i.length>0){const e=i.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t),t=Dg(o.roundedTop,e,y);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){const{scales:i,columns:n,config:o,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=i,u=[],d="vertical"===l,h=[],p=/* @__PURE__ */new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=s?s(t):"_default";p.has(e)||(p.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(n)){const t=e.width/f,i=.2*t,n=t-i,o=/* @__PURE__ */new Map;for(const t of e.pieceData){const e=s?s(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let s=0;h.length>s;s++){const l=o.get(h[s])||[];for(const o of l){const l=r(o),p=a(o,h[s]);if(d){const r=e.x+s*t+i/2,a=c(0),d=c(l);u.push(fh(r,Math.min(a,d),n,Math.abs(a-d),p,o,h[s]))}else{const r=e.x+s*t+i/2,a=c(0),d=c(l);u.push(fh(Math.min(a,d),r,Math.abs(d-a),n,p,o,h[s]))}}}}for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum),i=Dg(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){const{scales:i,columns:n,getR:o,multiScales:r,resolvePieceStyle:s}=e,{r:a,projection:c}=i,l=[],u="vertical"===c,d="radial"===c,h=r.length>0,p=Bg(e),f=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(n))for(const t of e.pieceData){const i=t.__rIndex??0,n=t.__rValue??o(t),c=h&&r[i]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*f,i=c(n);x=Math.cos(t)*i,b=Math.sin(t)*i}else u?(x=e.middle,b=c(n)):(x=c(n),b=e.middle);Wg(l,p,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:i,columns:n,getR:o,resolvePieceStyle:r}=e,{r:s,projection:a}=i,c=[],l="vertical"===a,u=Bg(e);for(const e of Object.values(n)){const t=e.width/2;for(let i=0;e.pieceData.length>i;i++){const n=e.pieceData[i],a=o(n),d=r(n,e.name),h=d.r||4,p=(7919*i%100/100-.5)*t*.8;Wg(c,u,n,l?e.middle+p:s(a),l?s(a):e.middle+p,h,d)}}return c},pie:Yg,donut:Yg,boxplot:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a,projection:c}=i,l=[],u="vertical"===c,d=!1!==o.showOutliers;for(const t of Object.values(n)){const i=t.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;const n=Xg(i),{min:o,max:c,q1:h,median:p,q3:f}=n,y=f-h,g=h-1.5*y,m=f+1.5*y,x=i.find(e=>e>=g)??o;let b=c;for(let e=i.length-1;e>=0;e--)if(m>=i[e]){b=i[e];break}n.min=x,n.max=b;const v=s(qg(t.pieceData,t.name,n),t.name),w=[];if(d)for(const e of t.pieceData){const i=r(e);if(g>i||i>m){const n=u?t.middle:a(i),o=u?a(i):t.middle;w.push({px:n,py:o,value:i,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(x),q1Pos:a(h),medianPos:a(p),q3Pos:a(f),maxPos:a(b),stats:n,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(const t of w)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return l},violin:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a,projection:c}=i,l=[],u="vertical"===c,d=o.bins||20,h=!1!==o.showIQR;for(const e of Object.values(n)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],n=t[t.length-1],o=(n-i)/d||1,c=Gg(t,i,n,o,d),p=$t(c,1),f=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(i)}`;for(let t=0;d>t;t++){const n=a(i+(t+.5)*o);y+=` L ${e.middle+c[t]/p*f} ${n}`}y+=` L ${e.middle} ${a(n)}`;for(let t=d-1;t>=0;t--){const n=a(i+(t+.5)*o);y+=` L ${e.middle-c[t]/p*f} ${n}`}y+=" Z"}else{y=`M ${a(i)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(i+(t+.5)*o)} ${e.middle-c[t]/p*f}`;y+=` L ${a(n)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(i+(t+.5)*o)} ${e.middle+c[t]/p*f}`;y+=" Z"}const g=Xg(t),m=s(qg(e.pieceData,e.name,g),e.name);let x;h&&t.length>=4&&(x={q1Pos:a(g.q1),medianPos:a(g.median),q3Pos:a(g.q3),centerPos:e.middle,isVertical:u});const b=u?{x:e.x,y:Math.min(a(n),a(i)),width:e.width,height:Math.abs(a(n)-a(i))}:{x:Math.min(a(i),a(n)),y:e.x,width:Math.abs(a(n)-a(i)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:b,iqrLine:x,stats:g,style:m,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a}=i,c=[],l=o.bins||25,u=o.normalize,d=a.domain?.(),h=d?+d[0]:void 0,p=d?+d[1]:void 0;for(const e of Object.values(n)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[i,n]=Mt(t),o=null!=h&&isFinite(h)?h:i,d=null!=p&&isFinite(p)?p:n,f=(d-o)/l||1,y=Gg(t,o,d,f,l),g=t.length,m=$t(y,1);for(let t=0;l>t;t++){if(0===y[t])continue;const i=(u?y[t]/g:y[t]/m)*e.width*.9,n=a(o+t*f),r=a(o+(t+1)*f),l=Math.min(n,r),d=Math.abs(r-n),h=e.x+e.width-i,p={...e.pieceData[0],bin:t,count:y[t],range:[o+t*f,o+(t+1)*f],category:e.name,data:e.pieceData},x=s(p,e.name);c.push(fh(l,h,d,i,x,p,e.name))}}return c},ridgeline:function(e,t){const{scales:i,columns:n,config:o,getR:r,resolveSummaryStyle:s}=e,{r:a,projection:c}=i,l=[],u=o.bins||20,d="horizontal"===c,h=o.amplitude||1.5;for(const e of Object.values(n)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const i=t[0],n=t[t.length-1],o=(n-i)/u||1,c=Gg(t,i,n,o,u),p=$t(c,1),f=Xg(t),y=s(qg(e.pieceData,e.name,f),e.name),g=e.width*h;let m;if(d){const t=e.x+e.width;m=`M ${a(i)} ${t}`;for(let e=0;u>e;e++)m+=` L ${a(i+(e+.5)*o)} ${t-c[e]/p*g}`;m+=` L ${a(n)} ${t} Z`}else{const t=e.x;m=`M ${t} ${a(i)}`;for(let e=0;u>e;e++){const n=a(i+(e+.5)*o);m+=` L ${t+c[e]/p*g} ${n}`}m+=` L ${t} ${a(n)} Z`}const x=d?{x:Math.min(a(i),a(n)),y:e.x,width:Math.abs(a(n)-a(i)),height:e.width}:{x:e.x,y:Math.min(a(n),a(i)),width:e.width,height:Math.abs(a(n)-a(i))};l.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:f,style:{...y,fillOpacity:y.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:i,columns:n,getRawRange:o,resolvePieceStyle:r}=e,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const i=o(t);if(!i)continue;const[n,a]=i,u=r(t,e.name);if(l){const i=s(Math.min(n,a)),o=s(Math.max(n,a));c.push(fh(i,e.x,o-i,e.width,u,t,e.name))}else{const i=s(Math.max(n,a)),o=s(Math.min(n,a));c.push(fh(e.x,i,e.width,o-i,u,t,e.name))}}return c},funnel:function(e,t){const{columns:i,getR:n,getStack:o,resolvePieceStyle:r}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=/* @__PURE__ */new Set;for(const e of l)for(const t of e.pieceData){const e=o?o(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],p=[];let f=0;for(const e of l){const t=/* @__PURE__ */new Map;let i=0;for(const r of e.pieceData){const e=o?o(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=n(r);s.total+=a,s.pieces.push(r),i+=a}p.push({col:e,groups:t,stepTotal:i}),h||i>f&&(f=i)}if(h)for(const e of p){let t=0,i=0;for(let n=0;u.length>n;n++){const o=e.groups.get(u[n]);o&&(n%2==0?t+=o.total:i+=o.total)}const n=Math.max(t,i);n>f&&(f=n)}if(0===f)return s;const y=/* @__PURE__ */new Map;for(const e of u){const t=p[0].groups.get(e);y.set(e,t?.total??0)}const g=p[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,kP.scaleLinear)().domain([0,f]).range([0,m]),b=e.config.connectorOpacity??.3;let v=/* @__PURE__ */new Map;for(let t=0;p.length>t;t++){const i=p[t],n=i.col,o=0===t,l=n.width,d=.55*l,f=n.x+(l-d)/2,m=/* @__PURE__ */new Map;if(h){let e=0;for(const t of u){const n=i.groups.get(t);n&&(e+=x(n.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const p=u[h],g=i.groups.get(p);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=r(g.pieces[0],p),A=y.get(p)??g.total,S={...g.pieces[0],__funnelValue:g.total,__funnelPercent:A>0?g.total/A*100:0,__funnelStep:n.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:p};c&&(0===h&&(S.__funnelStepLabel=n.name,S.__funnelStepLabelX=a,S.__funnelStepLabelY=f,S.__funnelRowWidth=e),S.__funnelValueLabelX=w+b/2,S.__funnelValueLabelY=f,S.__funnelBarW=b),s.push(fh(w,f,b,d,k,S,p)),m.set(p,{x:w,y:f,w:b,h:d})}}else{const e=i.stepTotal,t=x(e),l=a-t/2,h=u[0],p="_default"!==h,y=i.groups.get(h)?.pieces[0]??n.pieceData[0],b=p?h:n.name,v=r(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:n.name,__funnelIsFirstStep:o,category:p?h:n.name};c&&(k.__funnelStepLabel=n.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=f,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=f,k.__funnelBarW=t),s.push(fh(l,f,t,d,v,k,b)),m.set(h,{x:l,y:f,w:t,h:d})}if(t>0&&v.size>0){const t=h?u:[u[0]];for(const o of t){const t=v.get(o),a=m.get(o);if(!t||!a)continue;const c=(()=>{const e=i.groups.get(o);return r(e?e.pieces[0]:n.pieceData[0],"_default"===o?n.name:o)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b,cursor:c.cursor},datum:i.groups.get(o)?.pieces[0]??n.pieceData[0],category:"_default"===o?n.name:o};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:i,getR:n,getStack:o,resolvePieceStyle:r,scales:s}=e,a=[],c=s.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return a;const l=[],u=/* @__PURE__ */new Set;for(const e of c)for(const t of e.pieceData){const e=o?o(t):"_default";u.has(e)||(u.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=/* @__PURE__ */new Map;let i=0;for(const r of e.pieceData){const e=o?o(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=n(r);s.total+=a,s.pieces.push(r),i+=a}h.push({col:e,groups:t,stepTotal:i})}const p=/* @__PURE__ */new Map;for(const e of l){const t=h[0]?.groups.get(e);p.set(e,t?.total??0)}const f=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],i=t.col,n=0===e,o=e>0?h[e-1]:null,s=i.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=p.get(h)??g,x=m>0?g/m*100:0,b=o?.groups.get(h),v=n?0:Math.max(0,(b?.total??g)-g),w=i.x+e*s+c/2,k=f(g),A=f(0)-k,S=r(y.pieces[0],d?h:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:f(g+v)};if(a.push(fh(w,k,u,A,S,M,d?h:i.name)),v>0){const e=f(g+v),t=k-e,n={...S},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name};a.push(fh(w,e,u,t,n,o,d?h:i.name))}}}return a},swimlane:function(e,t){const{scales:i,columns:n,getR:o,getStack:r,resolvePieceStyle:s}=e,{r:a,projection:c}=i,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",p=/* @__PURE__ */new Map,f=t=>{const i=p.get(t);if(void 0!==i)return i;const n="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof n&&Number.isFinite(n)?Math.max(0,n):0;return p.set(t,o),o},y=e.config.trackFill;if(y){const e="string"==typeof y?y:y.color,t="string"==typeof y?1:y.opacity??1,[i,o]=a.range(),r=Math.min(i,o),s=Math.abs(o-i);for(const i of Object.values(n)){const n={fill:e,opacity:t},o=u?fh(r,i.x,s,i.width,n,null,"__track__"):fh(i.x,r,i.width,s,n,null,"__track__"),a=f(i);a>0&&(o.cornerRadii={tl:a,tr:a,br:a,bl:a}),l.push(o)}}for(const e of Object.values(n)){let t=0;const i=l.length,n=f(e);for(const i of e.pieceData){const n=Math.abs(o(i));if(0===n)continue;const c=r?r(i):e.name,p=s(i,c);let f;if(u){const o=a(t),r=a(t+n);f=fh(o,e.x,r-o,e.width,p,i,c)}else{const o=a(t+n),r=a(t);f=fh(e.x,o,e.width,r-o,p,i,c)}d&&(f.fillGradient=d,f.roundedEdge=h),l.push(f),t+=n}if(n>0&&l.length>i){const e=l.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:n,tr:n,br:n,bl:n}:u?(t.cornerRadii={tl:n,bl:n},o.cornerRadii={tr:n,br:n}):(t.cornerRadii={bl:n,br:n},o.cornerRadii={tl:n,tr:n})}}return l}},SP=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],MP=["scene-style","data-paint","accessibility","evidence"],_P=(e,t)=>({retainedData:e,invalidations:t}),$P=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],PP=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jP=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],IP=["scene-geometry","data-paint","accessibility","evidence"],LP=["scene-style","data-paint","accessibility","evidence"],RP=[],CP={chartType:_P("rebuild",$P),runtimeMode:_P("rebuild",$P),categoryAccessor:_P("rebuild",$P),valueAccessor:_P("rebuild",$P),oAccessor:_P("rebuild",$P),rAccessor:_P("rebuild",$P),stackBy:_P("rebuild",$P),groupBy:_P("rebuild",$P),timeAccessor:_P("rebuild",$P),accessorRevision:_P("rebuild",$P),colorAccessor:_P("rebuild",LP),symbolAccessor:_P("rebuild",IP),connectorAccessor:_P("rebuild",IP),dataIdAccessor:_P("rebuild",IP),projection:_P("preserve",PP),extentPadding:_P("preserve",PP),axisExtent:_P("preserve",PP),rExtent:_P("preserve",PP),oExtent:_P("preserve",PP),multiAxis:_P("preserve",PP),normalize:_P("preserve",PP),bins:_P("preserve",PP),oSort:_P("preserve",jP),barPadding:_P("preserve",jP),roundedTop:_P("preserve",jP),baselinePadding:_P("preserve",jP),innerRadius:_P("preserve",jP),cornerRadius:_P("preserve",jP),startAngle:_P("preserve",jP),sweepAngle:_P("preserve",jP),trackFill:_P("preserve",jP),showOutliers:_P("preserve",jP),showIQR:_P("preserve",jP),amplitude:_P("preserve",jP),connectorOpacity:_P("preserve",jP),showLabels:_P("preserve",jP),dynamicColumnWidth:_P("rebuild",jP),customLayout:_P("preserve",jP),layoutConfig:_P("preserve",jP),layoutMargin:_P("preserve",jP),symbolMap:_P("preserve",IP),pieceStyle:_P("preserve",LP),summaryStyle:_P("preserve",LP),connectorStyle:_P("preserve",LP),gradientFill:_P("preserve",LP),colorScheme:_P("preserve",LP),themeCategorical:_P("preserve",LP),themeSemantic:_P("preserve",LP),themeSequential:_P("preserve",LP),themeDiverging:_P("preserve",LP),barColors:_P("preserve",LP),decay:_P("preserve",LP),pulse:_P("preserve",LP),staleness:_P("preserve",LP),layoutSelection:_P("preserve",LP),windowSize:_P("preserve",RP),windowMode:_P("preserve",RP),clock:_P("preserve",RP),transition:_P("preserve",RP),introAnimation:_P("preserve",RP),onLayoutError:_P("preserve",RP)},TP=_P("preserve",jP),OP=class{constructor(){this.tracker=new yk}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},SP)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},MP):this.recordNoop("restyle")}recordConfig(e){const t=Kg(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},EP=require("d3-quadtree"),FP=class{constructor(e){this.rExtent=new h_,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new OP,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new vP,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=/* @__PURE__ */new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new d_(e.windowSize),this.getO=ud(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>cd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new h_)):(this.getR=cd(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=ud(e.stackBy),this.getGroup=ud(e.groupBy),this.getColor=ud(e.colorAccessor),this.getSymbol=ud(e.symbolAccessor),this.getConnector=ud(e.connectorAccessor),this.getDataId=ud(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new d_(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,n;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,n=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:Oh(t,n):null)}currentTime(){return this.config.clock?.()??bd()}ingest(e){const t=this.currentTime();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(),Th(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Eh(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of e.inserts){const e=Eh(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}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 i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){const{config:t,buffer:i}=this,n=this.scales,o=this.multiScales,r=this.columns;if(0===i.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let p,f;if(d){p=(0,bP.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(e.width,e.height)/2,n=t.innerRadius||0;f=(0,bP.scaleLinear)().domain(l).range([n,i])}else u?(p=(0,bP.scaleBand)().domain(c).range([0,e.height]).padding(h),f=(0,bP.scaleLinear)().domain(l).range([0,e.width])):(p=(0,bP.scaleBand)().domain(c).range([0,e.width]).padding(h),f=(0,bP.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:p,r:f,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((n,o)=>{const r=this.rExtents[o];r.dirty&&r.recalculate(i,n);let[s,a]=r.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,bP.scaleLinear)().domain([s,a]).range([0,e.width]):(0,bP.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,c,p,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=n,this.multiScales=o,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),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,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:"value"+e}resolveCategories(e){const t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,n="auto"===t?void 0:t;let o=null;if(i){o=/* @__PURE__ */new Set;for(const t of e)o.add(this.getO(t))}const r=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===n){const e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===n)return r;if("function"==typeof n)return r.sort(n);const s=/* @__PURE__ */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){return Vg({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,i,n,o){return Hg({data:e,oExtent:t,oScale:i,projection:n,layout:o,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(e,t),n=eh({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);const o=n.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const r=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=/* @__PURE__ */new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return Ud({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const i=this.getSceneContext(),n=AP[this.config.chartType];let o=n?n(i,t):[];return this.getConnector&&this.scales&&(o=[...zg(i,o),...o]),o}buildLayoutContext(e,t){const i=this.config,n=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Gn(i.colorScheme,i.themeCategorical,oA),r=this.scales;return{data:e,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:t.width,height:t.height,margin:n,plot:"radial"===r.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:[...o]},resolveColor:Vn(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?kd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=Ad(e);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=Ug(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=Zg(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const i=t.length;if(1>=i)return;const n=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=n.get(t.datum);if(null==e)continue;const o=this.computeDecayOpacity(e,i);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&Ng(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Pd(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=/* @__PURE__ */new Map,t=this.scales?.r(0)??0,i="horizontal"!==this.scales?.projection;let n;for(let o=0;this.scene.length>o;o++){const r=this.scene[o],s=this.getNodeKey(r,e);s&&("rect"===r.type?this.prevPositionMap.set(s,i?{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}:{x:t,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(s,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===n&&(n=r.startAngle),this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:n,endAngle:n,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,n=t.get(i)||0;return t.set(i,n+1),`${i}:${n}`}if("rect"===e.type){const i=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",n=`r:${e.group||""}:${i}`,o=t.get(n)||0;return t.set(n,o+1),0===o?n:`${n}:${o}`}return"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=/* @__PURE__ */new Map;for(let t=0;this.scene.length>t;t++){const i=this.scene[t],n=this.getNodeKey(i,e);n&&("point"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(n,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(n,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const i=/* @__PURE__ */new Set,n=/* @__PURE__ */new Map;for(let e=0;this.scene.length>e;e++){const o=this.scene[e],r=this.getNodeKey(o,n);if(!r)continue;o._transitionKey=r;const s=this.prevPositionMap.get(r);if("point"===o.type)s?(i.add(r),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(s.x!==o.x||s.y!==o.y||void 0!==s.r&&s.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=s.x,o.y=s.y,void 0!==s.r&&(o.r=s.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)s?(i.add(r),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,s.x===o.x&&s.y===o.y&&s.w===o.w&&s.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=s.x,o.y=s.y,o.w=s.w??o.w,o.h=s.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(s)i.add(r),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,s.startAngle===o.startAngle&&s.endAngle===o.endAngle||(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=s.startAngle,o.endAngle=s.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;const e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,n]of this.prevPositionMap)if(!i.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:n.x,y:n.y,r:n.r??3,style:{opacity:n.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:n.x,y:n.y,w:n.w??0,h:n.h??0,style:{opacity:n.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((n.startAngle??0)+(n.endAngle??0))/2,i={type:"wedge",cx:n.x,cy:n.y,innerRadius:n.innerRadius??0,outerRadius:n.outerRadius??100,startAngle:n.startAngle??0,endAngle:n.endAngle??0,style:{opacity:n.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(i)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=md(e,this.activeTransition),i=gd(t,"linear"===this.config.transition?.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);e.style.opacity=xd(n?n.opacity??1:0,e._targetOpacity,i)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=xd(n.x,e._targetX,i),e.y=xd(n.y,e._targetY,i)),void 0!==e._targetR&&void 0!==n?.r&&(e.r=xd(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t);e.style.opacity=xd(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=xd(n.x,e._targetX,i),e.y=xd(n.y,e._targetY,i),void 0!==n.w&&(e.w=xd(n.w,e._targetW,i),e.h=xd(n.h,e._targetH,i))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t);e.style={...e.style,opacity:xd(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const n=this.prevPositionMap.get(t);n&&void 0!==n.startAngle&&(e.startAngle=xd(n.startAngle,e._targetStartAngle,i),e.endAngle=xd(n.endAngle,e._targetEndAngle,i))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...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}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null,Vh(this.scene),this.exitNodes=[]}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}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=yd(e),i=this.getDataId,n=e=>t.has(i(e));Fh(this.buffer,this.timestampBuffer,n);const o=this.buffer.remove(n);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=yd(e),n=this.getDataId,o=/* @__PURE__ */new Set;this.buffer.forEach((e,t)=>{i.has(n(e))&&o.add(t)});const r=this.buffer.update(e=>i.has(n(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),o.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),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.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const i=this._customRestyle;if(i)for(const n of e){const e=this._baseStyles.get(n)??n.style??{},o=i(n,t);n.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!ad(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!ad(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!ad(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let n=!1;("categoryAccessor"in e||"oAccessor"in e)&&(ad(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=ud(this.config.categoryAccessor||this.config.oAccessor,"category"),n=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,n=Array.isArray(e)?e:[e],r=Array.isArray(i)?i:[i];if(o=n.length!==r.length||n.some((e,t)=>!ad(e,r[t])),o){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>cd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new h_)):(this.getR=cd(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!ad(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?ud(this.config.stackBy):void 0),"groupBy"in e&&!ad(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?ud(this.config.groupBy):void 0),"colorAccessor"in e&&!ad(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?ud(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!ad(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?ud(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!ad(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?ud(this.config.connectorAccessor):void 0),(n||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};qh(FP);var NP=Uv(require("react")),zP=Uv(require("react")),DP=require("d3-shape"),BP=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)}),WP=require("react/jsx-runtime"),YP=require("react/jsx-runtime"),qP=require("react/jsx-runtime"),XP=require("react/jsx-runtime"),GP=Uv(require("react-dom/server")),VP=/* @__PURE__ */Object.create(null),HP=require("d3-array"),UP=require("d3-array"),KP=require("d3-interpolate"),ZP=(require("d3-shape"),.5),QP=e=>{let t,i,n,o,r,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,i=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,r=e.source.x1,s=e.target.x0,a=(0,KP.interpolateNumber)(r,s),c=a(ZP),l=a(.5),`M${t},${r}C${t},${c} ${i},${l} ${i},${s}L${n},${s}C${n},${l} ${o},${c} ${o},${r}Z`;const u=e.sankeyWidth/2,d=(0,KP.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=$u({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(ZP),cp2X:d(.5)});return h},JP=/* @__PURE__ */new Set,ej=/* @__PURE__ */new WeakMap,tj={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(Im))-1:0},justify:Lm},ij={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,n){if(0===e.length)return;const o="vertical"===i.orientation?"down":"right",r=i.nodeAlign||"justify",s=i.nodeWidth??15,a=i.nodePaddingRatio??.05,c=i.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:hd(e.source),target:hd(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const h=dx().extent(d).links(u).nodes(l).nodeAlign(tj[r]||Lm).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,i=1/0,o=-1/0;for(const n of l)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),i>n.y0&&(i=n.y0),n.y1>o&&(o=n.y1);for(const n of u){if(!n.circular||!n.circularPathData)continue;const r=n.circularPathData,s=(n._circularWidth??n.width??0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),i>r.verticalFullExtent-s&&(i=r.verticalFullExtent-s),r.verticalFullExtent+s>o&&(o=r.verticalFullExtent+s)}const r=t-e,s=o-i,a=n[0],c=n[1];if(r>0&&s>0&&(0>e||0>i||t>a||o>c)){const t=Math.min(a/r,c/s),n=-e*t+(a-r*t)/2,o=-i*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const i=e.circularPathData;i.sourceX=i.sourceX*t+n,i.targetX=i.targetX*t+n,i.sourceY=i.sourceY*t+o,i.targetY=i.targetY*t+o,i.rightFullExtent=i.rightFullExtent*t+n,i.leftFullExtent=i.leftFullExtent*t+n,i.verticalFullExtent=i.verticalFullExtent*t+o,i.rightInnerExtent=i.rightInnerExtent*t+n,i.leftInnerExtent=i.leftInnerExtent*t+n,i.verticalRightInnerExtent=i.verticalRightInnerExtent*t+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*t+o,i.rightSmallArcRadius*=t,i.rightLargeArcRadius*=t,i.leftSmallArcRadius*=t,i.leftLargeArcRadius*=t,i.sourceWidth*=t,i.rightNodeBuffer*=t,i.leftNodeBuffer*=t,i.arcRadius*=t}}}const p=/* @__PURE__ */new Map;for(const t of e)p.set(t.id,t);for(const e of l){const t=p.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 f=/* @__PURE__ */new Map;for(const e of t)if(e._edgeKey)f.set(e._edgeKey,e);else{const t=hd(e.source),i=hd(e.target);f.set(`${t}\0${i}`,e)}for(const e of u){const t=hd(e.source),i=hd(e.target),n=f.get(e._edgeKey?e._edgeKey:`${t}\0${i}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=e.width??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=o;const r=p.get(t),s=p.get(i);r&&(n.source=r),s&&(n.target=s)}}},buildScene(e,t,i,n){const o="vertical"===i.orientation?"down":"right",r=i.nodeStyle,s=i.edgeStyle,a=i.edgeOpacity??.5,c=i.edgeColorBy||"source",l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Tk,u=/* @__PURE__ */new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],p=[],f=/* @__PURE__ */new Map;for(const t of e){const e=t.x1-t.x0,i=t.y1-t.y0;if(0>=e||0>=i)continue;const n=r?r(px(t,"nodeStyle")):{},s={fill:n.fill||u.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity,cursor:n.cursor};f.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){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 o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?f.get(n.id)||u.get(n.id)||o:f.get(t.id)||u.get(t.id)||o;const r=s?s(px(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,i=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=r.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-i}L${t.sourceX+n},${t.sourceY-i}L${t.sourceX+n},${t.sourceY+i}L${t.sourceX},${t.sourceY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-i}L${t.targetX-s},${t.targetY-i}L${t.targetX-s},${t.targetY+i}L${t.targetX},${t.targetY+i}Z`,style:{fill:c,fillOpacity:r.fillOpacity??a,stroke:"none",opacity:r.opacity,cursor:r.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;l=e.circular&&e.circularPathData?hx(e):QP(e),l&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:r.fill||o,fillOpacity:r.fillOpacity??a,stroke:r.stroke||"none",strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor},datum:e})}if(!1!==i.showLabels){const t=dd(i.nodeLabel);for(const i of e){const e=i.x1-i.x0,r=i.y1-i.y0;if(0>=e||0>=r)continue;const s=t?t(i):i.id;if(!s)continue;let a,c,l;"down"===o?(a=i.y0+(i.y1-i.y0)/2,c=i.x1+14,l="start"):(n[0]/2>i.x0+e/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),c=i.y0+r/2),p.push({x:a,y:c,text:s+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}return{sceneNodes:d,sceneEdges:h,labels:p}}};hm("sankey",ij);var nj=require("d3-force"),oj=require("d3-scale"),rj={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,n){if(0===e.length)return;const o=i.forceStrength??.1,r=n[0]/2,s=n[1]/2,a=Math.max(.1,Math.min(1,Math.min(n[0],n[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=i.__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),i=l?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const i=/* @__PURE__ */new Map;for(const t of e)i.set(t.id,t);for(const e of d){const n=gx(e.id,t,i);if(n.length>0){let t=0,i=0;for(const e of n)t+=e.x,i+=e.y;const o=xx(e.id),r=o%360*(Math.PI/180),s=(10+o%20)*a;e.x=t/n.length+s*Math.cos(r),e.y=i/n.length+s*Math.sin(r)}else{const t=xx(e.id),i=t%360*(Math.PI/180),n=(15+t%30)*a;e.x=r+n*Math.cos(i),e.y=s+n*Math.sin(i)}}}else{const t=2.399963229728653;for(let i=0;e.length>i;i++){const n=e[i];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(i+.5)*a,o=i*t;n.x=r+e*Math.cos(o),n.y=s+e*Math.sin(o)}}}const p=i.__skipForceSimulation||0===i.iterations?0:h?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=fx(i.nodeSize,i.nodeSizeRange,e),y=e=>f(e);if(p>0){const l=/* @__PURE__ */new Map,u=/* @__PURE__ */new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t=hd(e.source),i=hd(e.target);l.set(t,(l.get(t)??0)+1),l.set(i,(l.get(i)??0)+1)}const d=(0,nj.forceLink)().strength(e=>{const t=e.weight,i=hd(e.source),n=hd(e.target),r=Math.max(1,Math.min(l.get(i)??1,l.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*r))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,n=(t?y(t):0)+(i?y(i):0)+Math.max(6,12*a);return Math.max(16,40*a,n)}).id(e=>e.id),f=(0,nj.forceSimulation)();if(void 0===i.random&&void 0===i.seed||f.randomSource(i.random??yx(i.seed)),f.force("charge",(0,nj.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,nj.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,nj.forceCenter)(r,s).strength(.8)).force("x",(0,nj.forceX)(r).strength(c)).force("y",(0,nj.forceY)(s).strength(c)).force("bounds",mx(n,y)),f.nodes(e),t.length>0){const e=t.map(e=>({...e,source:hd(e.source),target:hd(e.target)}));d.links(e),f.force("link",d)}h?f.alpha(.3):.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;p>e;++e)f.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),i=p>0?2:0,o=Math.min(n[0]/2,e+i),r=Math.min(n[1]/2,e+i);t.x=Math.max(o,Math.min(n[0]-o,t.x)),t.y=Math.max(r,Math.min(n[1]-r,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const g=/* @__PURE__ */new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,n){const o=i.nodeStyle,r=i.edgeStyle,s=fx(i.nodeSize,i.nodeSizeRange,e),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Tk,c=/* @__PURE__ */new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(px(t,"nodeSize")),n=o?o(px(t,"nodeStyle")):{},r={fill:n.fill||c.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity,cursor:n.cursor};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:r,datum:t,id:t.id,label:t.id})}const h=/* @__PURE__ */new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),n="object"==typeof e.target?e.target:h.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=r?r(px(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor},datum:e})}if(!1!==i.showLabels){const t=dd(i.nodeLabel);for(const i of e){if(null==i.x||null==i.y)continue;const e=t?t(i):i.id;if(!e)continue;const n=s(px(i,"nodeSize"));d.push({x:i.x,y:i.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:l,sceneEdges:u,labels:d}}};hm("force",rj);var sj=require("d3-chord"),aj=require("d3-shape"),cj=Tk,lj={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:r=20,sortGroups:s}=i,a=Math.min(n[0],n[1])/2,c=a-r,l=n[0]/2,u=n[1]/2,d=(h=i.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const p=/* @__PURE__ */new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const f=e.length,y=Array.from({length:f},()=>Array(f).fill(0));for(const e of t){const t=hd(e.source),i=hd(e.target),n=p.get(t),o=p.get(i);if(void 0===n||void 0===o)continue;const r=d(e);y[n][o]=r}const g=(0,sj.chord)().padAngle(o);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,aj.arc)().innerRadius(c).outerRadius(a);for(const t of x){const i=e[t.index],n=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});i.x=n[0]+l,i.y=n[1]+u,i.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=/* @__PURE__ */new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t=hd(e.source),i=hd(e.target),n=v.get(t),o=v.get(i);n&&(e.source=n),o&&(e.target=o)}const w=/* @__PURE__ */new Map;for(const e of t){const t=hd(e.source),i=hd(e.target);w.set(`${t}\0${i}`,e)}for(const t of m){const i=e[t.source.index].id,n=e[t.target.index].id,o=w.get(`${i}\0${n}`)||w.get(`${n}\0${i}`);o&&(o.__chordData=t)}},buildScene(e,t,i,n){const{groupWidth:o=20,edgeOpacity:r=.5}=i,s=Math.min(n[0],n[1])/2,a=s-o,c=n[0]/2,l=n[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:cj,f=/* @__PURE__ */new Map;e.forEach((e,t)=>{f.set(e.id,p[t%p.length])});const y=(0,sj.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const i=e[t],n=i.__arcData;if(!n)continue;const o=u?u(px(i,"nodeStyle")):{},r=("string"==typeof o.fill?o.fill:void 0)||f.get(i.id)||p[t%p.length];g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:r,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor},datum:i,id:i.id,label:i.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=y(t);if(!n)continue;const o=bx(n,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";const a=d?d(px(e,"edgeStyle")):{};if(d)s=("string"==typeof a.fill?a.fill:void 0)||s;else{const t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?s=f.get(i.id)||s:t&&(s=f.get(t.id)||s)}m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??r,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity,cursor:a.cursor},datum:e})}if(!1!==i.showLabels){const t=dd(i.nodeLabel),n=s+12;for(const i of e){const e=i.__arcData;if(!e)continue;const o=t?t(i):i.id;if(!o)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;x.push({x:c+Math.cos(s)*n,y:l+Math.sin(s)*n,text:o+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:x}}};hm("chord",lj);var uj=require("d3-hierarchy"),dj=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],hj={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;if(!o)return;const r=i.chartType,s=kx(i.childrenAccessor),a=i.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,uj.hierarchy)(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(r){case"tree":Lx(l,i,u,d);break;case"cluster":Rx(l,i,u,d);break;case"treemap":Cx(l,i,u,d);break;case"circlepack":Tx(l,i,u,d);break;case"partition":Ox(l,i,u,d)}const h=l.descendants();e.length=0,t.length=0;const p=/* @__PURE__ */new Map;for(let t=0;h.length>t;t++){const n=h[t],o={id:Ax(n,i,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:n.value??0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===r||"cluster"===r?Ex(o,n,i):"treemap"===r||"partition"===r?Fx(o,n):"circlepack"===r&&Nx(o,n),o.__hierarchyNode=n,e.push(o),p.set(n,o)}if("tree"===r||"cluster"===r)for(const e of h)if(e.parent){const i=p.get(e.parent),n=p.get(e);i&&n&&t.push({source:i,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,n){const o=i.nodeStyle||(()=>({})),r=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return $x(e,t,i,n,o,r);case"treemap":case"partition":return Px(e,i,0,o);case"circlepack":return jx(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};hm("tree",hj),hm("cluster",hj),hm("treemap",hj),hm("circlepack",hj),hm("partition",hj);var pj=require("d3-shape"),fj={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;o&&qx(o,n,i,e,t)},buildScene(e,t,i,n){const o=i.nodeStyle,r=i.edgeStyle,s=i.nodeSize,a="number"==typeof s?()=>s:"function"==typeof s?s:()=>6,c=[],l=[],u=[];if(!1!==i.orbitShowRings){const t=zx(i),n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,t);const o=/* @__PURE__ */new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{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:i,ecc:n}]of o)for(let o=0;r>o;o++){const a=o/r*Math.PI*2,c=(o+1)/r*Math.PI*2;l.push({type:"line",x1:e+i*Math.sin(a),y1:t+i*Math.cos(a)*n,x2:e+i*Math.sin(c),y2:t+i*Math.cos(c)*n,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(px(t,"nodeSize")),n=o?o(px(t,"nodeStyle")):{};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:n.fill||i.themeSemantic?.primary||"#6366f1",stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??(0===(t.depth??0)?1:.85),cursor:n.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}const d=/* @__PURE__ */new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i)continue;if(null==t.x||null==i.x)continue;const n=r?r(px(e,"edgeStyle")):{};l.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:n.stroke||"rgba(128,128,128,0.35)",strokeWidth:n.strokeWidth??.5,opacity:n.opacity??1,cursor:n.cursor},datum:e})}if(i.showLabels){const t=i.nodeLabel;for(const i of e){const e=a(px(i,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(e,t,i,n,o)=>!1!==i.orbitAnimated&&(Xx(e,i),!0)};hm("orbit",fj);var yj=Uv(require("react")),gj=require("d3-shape"),mj=require("react/jsx-runtime"),xj=require("react/jsx-runtime");hm("sankey",ij),hm("force",rj),hm("chord",lj),hm("tree",hj),hm("cluster",hj),hm("treemap",hj),hm("circlepack",hj),hm("partition",hj),hm("orbit",fj);var bj=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]),vj=Uv(require("react-dom/server")),wj=require("d3-geo"),kj=require("d3-quadtree"),Aj=require("d3-geo"),Sj={mercator:Aj.geoMercator,equalEarth:Aj.geoEqualEarth,albersUsa:Aj.geoAlbersUsa,orthographic:Aj.geoOrthographic,naturalEarth:Aj.geoNaturalEarth1,equirectangular:Aj.geoEquirectangular},Mj=require("d3-scale"),_j=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$j=["scene-style","data-paint","accessibility","evidence"],Pj=(e,t)=>({retainedData:e,invalidations:t}),jj=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ij=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lj=["scene-geometry","data-paint","accessibility","evidence"],Rj=["scene-style","data-paint","accessibility","evidence"],Cj=["overlay","accessibility","evidence"],Tj=[],Oj={xAccessor:Pj("rebuild",jj),yAccessor:Pj("rebuild",jj),lineDataAccessor:Pj("rebuild",jj),pointIdAccessor:Pj("rebuild",Lj),lineIdAccessor:Pj("rebuild",Lj),windowSize:Pj("rebuild",jj),projection:Pj("preserve",Ij),projectionExtent:Pj("preserve",Ij),fitPadding:Pj("preserve",Ij),lineType:Pj("preserve",Ij),flowStyle:Pj("preserve",Ij),graticule:Pj("preserve",Ij),projectionTransform:Pj("preserve",Ij),customLayout:Pj("preserve",Ij),layoutConfig:Pj("preserve",Ij),layoutMargin:Pj("preserve",Ij),areaStyle:Pj("preserve",Rj),pointStyle:Pj("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Pj("preserve",Rj),colorScheme:Pj("preserve",Rj),themeCategorical:Pj("preserve",Rj),themeDiverging:Pj("preserve",Rj),themeSemantic:Pj("preserve",Rj),themeSequential:Pj("preserve",Rj),decay:Pj("preserve",Rj),pulse:Pj("preserve",Rj),layoutSelection:Pj("preserve",Rj),annotations:Pj("preserve",Cj),autoPlaceAnnotations:Pj("preserve",Cj),clock:Pj("preserve",Tj),transition:Pj("preserve",Tj),introAnimation:Pj("preserve",Tj),onLayoutError:Pj("preserve",Tj)},Ej=Pj("preserve",Ij),Fj=class{constructor(){this.tracker=new yk}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},_j)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},$j):this.recordNoop("restyle")}recordConfig(e,t={}){const i=bb(e),n=new Set(i.invalidations);return t.retainedDataChanged&&n.add("data"),this.tracker.record({kind:"config",keys:e},n)}},Nj=require("d3-geo"),zj=class e{constructor(e){this.updateResults=new Fj,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=/* @__PURE__ */new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=kb(e)}currentTime(){return this.config.clock?.()??bd()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],n=t.slice(-e),o=i.slice(-n.length),r=this.currentTime();this.pointBuffer=new d_(e),this.timestampBuffer=new d_(e),n.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=Ab(e),i=this.config,n=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);this.config={...this.config,...t};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==n;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,n=this.timestampBuffer?.toArray()??[],o=i.slice(-t),r=n.slice(-o.length),s=this.currentTime();this.pointBuffer=new d_(t),this.timestampBuffer=new d_(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??s)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();Eh(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const i of e)Eh(this.pointBuffer,i,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const i="function"==typeof t?t:e=>e[t],n=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!n.has(i(e)+"")||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof t?t:e=>e[t],n=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>n.has(i(e)+"");Fh(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!n.has(i(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const i of this.scene){const n=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...n,...o}:n}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,i=this.projection,n=this.geoPath,o=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=rb(t.projection),this.geoPath=(0,wj.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,wj.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=n,this.scales=o,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,i=e.height/2,n=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));n.length>0&&this.startTransition(n)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,i=this.config,n=[...this.areas],o=sb(i.xAccessor,"lon"),r=sb(i.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[o(e),r(e)]);n.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=ab(i.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[o(e),r(e)]);n.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==n.length){if(i.projectionExtent){const[[n,o],[r,s]]=i.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[n,o],[n,s],[r,s],[r,o],[n,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const n=i.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*n),t.translate([e.width/2,e.height/2])}else{const o=i.fitPadding??0,r=e.width*o,s=e.height*o;t.fitExtent([[r,s],[e.width-r,e.height-s]],{type:"FeatureCollection",features:n})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const i=this.projection;if(!i)return;const n=this.geoPath,o=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,wj.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=n,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const i=this.projection;if(!i)return;const n=this.geoPath,o=this.scales,r=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,wj.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(r),i.translate(s),this.currentZoom=a,this.geoPath=n,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const i=this.projection;if(!i||!i.rotate)return;const n=this.geoPath,o=this.scales,r=[...i.rotate()];i.rotate(e),this.geoPath=(0,wj.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(r),this.geoPath=n,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,i=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(i++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);const n=Array(i);let o=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(n[o++]=e);this._quadtree=(0,kj.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,i=this.projection,n=this.geoPath;if(t.customLayout&&this.scales){const i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},n=Gn(t.colorScheme,t.themeCategorical,oA),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...n]},resolveColor:Vn(n,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},r=eh({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,[]);const s=r.result,a=s.nodes??[];if(this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null,this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this._baseStyles=/* @__PURE__ */new WeakMap,this.hasCustomRestyle)for(const e of a){this._baseStyles.set(e,e.style);const i=s.restyle?.(e,t.layoutSelection??null);i&&(e.style={...e.style,...i})}return Ud({label:"geo customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=/* @__PURE__ */new WeakMap,vb({config:t,projection:i,path:n,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const i=gb(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const i=this.scene.filter(e=>"point"===e.type);for(let n=0;i.length>n;n++){const o=kd(e,n,t);i[n]._decayOpacity=o,i[n].style={...i[n].style,opacity:o}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const i=this.scene.filter(e=>"point"===e.type),n=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",r=t.glowRadius??4;let s=!1;for(let a=0;i.length>a&&n.length>a;a++){const c=Md(t,n[a],e);s=$d(i[a],c,o,r)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Pd(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const i=/* @__PURE__ */new Map;for(const t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);const n=this.scene.filter(e=>"point"===e.type);let o=!1;for(const e of n)if(e.pointId){const t=i.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(o=!0))}for(const e of n)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(const e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;const t=md(e,this.activeTransition),i=gd(t),n=this.scene.filter(e=>"point"===e.type);for(const e of n){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=xd(e.x,e._targetX,i),e.y=xd(t,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(const e of n)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};zj.QUADTREE_THRESHOLD=500;var Dj=zj;qh(Dj);var Bj=Uv(require("react")),Wj=require("react/jsx-runtime"),Yj=require("react/jsx-runtime"),qj=require("react/jsx-runtime"),Xj=Uv(require("react-dom/server")),Gj={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85},Vj=require("react/jsx-runtime"),Hj={top:0,right:0,bottom:0,left:0},Uj=require("react/jsx-runtime"),Kj=require("d3-scale"),Zj=require("react/jsx-runtime"),Qj={top:0,right:0,bottom:0,left:0},Jj=Uv(require("react-dom/server")),eI=require("react/jsx-runtime"),tI={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},iI={BigNumber:function(e,t){const i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",n=tI[i],o=sv(e.width,n.width),r=sv(e.height,n.height),s="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):n.padding,a="center"===e.align||"end"===e.align||"start"===e.align?e.align:n.align,c="center"===a?"middle":"end"===a?"end":"start",l="center"===a?o/2:"end"===a?o-s:s,u=Wr(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=iv("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),p=void 0===d?"No value":(f=h(d),`${("string"==typeof e.prefix?e.prefix:void 0)??""}${f}${("string"==typeof e.suffix?e.suffix:void 0)??""}`);var f;const y=void 0===d?void 0:rv(d,e.thresholds),g="string"==typeof e.color?e.color:av(y?.level??"neutral",y?.color,u),m="string"==typeof e.label?e.label:void 0,x="string"==typeof e.caption?e.caption:void 0,b="string"==typeof e.unit?e.unit:void 0,v=[void 0===d?void 0:cv(e,d,h),void 0===d?void 0:lv(e,d,h),y?.label].filter(Boolean).join(" · "),w="string"==typeof e.description&&e.description||[m,p,b,v].filter(Boolean).join(", "),k="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,A="string"==typeof e.borderColor?e.borderColor:u.colors.border,S=s+n.labelSize,M=S+n.captionSize+4,_="presentation"===i?r/2+.32*n.valueSize:"thumbnail"===i?r/2+.34*n.valueSize:Math.min(r-s-(v?26:4),(n.showHeader&&(m||x)?x?M+10:S+14:s)+n.valueSize),$=l+("start"===c?Math.max(n.valueSize,p.length*n.valueSize*.55):0),P=Jj.renderToStaticMarkup(
|
|
644
644
|
/* @__PURE__ */
|
|
645
645
|
/* @__PURE__ */(0,eI.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:r,viewBox:`0 0 ${o} ${r}`,role:"img","aria-label":w,"data-semiotic-component":"BigNumber",children:[
|
|
646
646
|
/* @__PURE__ */
|