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.
Files changed (80) hide show
  1. package/README.md +23 -27
  2. package/ai/artifact-surface-inventory.json +1 -1
  3. package/ai/behaviorContracts.cjs +1 -1
  4. package/ai/dist/mcp-server.js +1 -1
  5. package/ai/reference.md +4 -4
  6. package/ai/schema.json +1 -1
  7. package/ai/surface-manifest.json +1 -1
  8. package/ai/system-prompt.md +1 -1
  9. package/ai/task-packets/compare-category-totals.json +4 -4
  10. package/ai/task-packets/compare-category-totals.md +2 -2
  11. package/ai/task-packets/correct-published-chart.json +4 -4
  12. package/ai/task-packets/correct-published-chart.md +2 -2
  13. package/ai/task-packets/index.json +6 -6
  14. package/ai/task-packets/update-live-chart.json +4 -4
  15. package/ai/task-packets/update-live-chart.md +2 -2
  16. package/dist/{c-AKLBQMQF.min.js → c-43XNOQNQ.min.js} +50 -50
  17. package/dist/{c-PZ3NEGNG.min.js → c-5PIKBUMF.min.js} +1 -1
  18. package/dist/{c-FDUQDCBC.min.js → c-CO4NDAD6.min.js} +23 -23
  19. package/dist/c-FHNY57SO.min.js +209 -0
  20. package/dist/c-FMCUQ6JX.min.js +1 -0
  21. package/dist/{c-C4KIXUWU.min.js → c-GK263BF4.min.js} +1 -1
  22. package/dist/{c-TTKWXGAI.min.js → c-HNHKIMIV.min.js} +3 -3
  23. package/dist/c-IJCZGUG6.min.js +31 -0
  24. package/dist/{c-7LY46QUI.min.js → c-ISA6IJ6V.min.js} +7 -7
  25. package/dist/{c-4MD53L2J.min.js → c-JC76YAHB.min.js} +28 -28
  26. package/dist/{c-VXIYF7V2.min.js → c-JOPGDP6N.min.js} +1 -1
  27. package/dist/c-KXH7LFIL.min.js +26 -0
  28. package/dist/c-M43PK7K4.min.js +1 -0
  29. package/dist/{c-7ASK4WBF.min.js → c-PITYSOPK.min.js} +1 -1
  30. package/dist/{c-2TW5H5PD.min.js → c-QPO24R7Q.min.js} +1 -1
  31. package/dist/{c-KGROWFT2.min.js → c-SAP5KY6R.min.js} +2 -2
  32. package/dist/c-UMGHCBH5.min.js +114 -0
  33. package/dist/{c-6ZU3QVLB.min.js → c-VEMCBQZZ.min.js} +33 -33
  34. package/dist/{c-IPYGNVN6.min.js → c-WD2RL76M.min.js} +45 -45
  35. package/dist/{c-PQOZPM4G.min.js → c-YL7HJL5J.min.js} +1 -1
  36. package/dist/c-Z6GRGS53.min.js +1 -0
  37. package/dist/{c-SG2Y7EBY.min.js → c-ZVOFLE2P.min.js} +6 -6
  38. package/dist/components/CategoryColors.d.ts +7 -0
  39. package/dist/components/LinkedCharts.d.ts +2 -1
  40. package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
  41. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -1
  42. package/dist/components/data/transforms.d.ts +1 -0
  43. package/dist/geo.min.js +3 -3
  44. package/dist/geo.module.min.js +10 -10
  45. package/dist/network.module.min.js +1 -1
  46. package/dist/ordinal.module.min.js +1 -1
  47. package/dist/physics.module.min.js +1 -1
  48. package/dist/physicsWorker.js +1 -1
  49. package/dist/semiotic-ai-core.min.js +1 -1
  50. package/dist/semiotic-ai-core.module.min.js +1 -1
  51. package/dist/semiotic-ai.module.min.js +7 -7
  52. package/dist/semiotic-artifact.min.js +1 -1
  53. package/dist/semiotic-artifact.module.min.js +1 -1
  54. package/dist/semiotic-atlas-selection.module.min.js +1 -1
  55. package/dist/semiotic-client-cjs-shared.min.js +903 -902
  56. package/dist/semiotic-data.min.js +1 -1
  57. package/dist/semiotic-data.module.min.js +1 -1
  58. package/dist/semiotic-experimental-auxiliary.module.min.js +2 -2
  59. package/dist/semiotic-experimental-node-auxiliary.module.min.js +2 -2
  60. package/dist/semiotic-line.module.min.js +1 -1
  61. package/dist/semiotic-realtime-core.module.min.js +1 -1
  62. package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
  63. package/dist/semiotic-recipes-core.module.min.js +1 -1
  64. package/dist/semiotic-server-edge-node.module.min.js +65 -65
  65. package/dist/semiotic-server-edge.min.js +64 -64
  66. package/dist/semiotic-server-edge.module.min.js +80 -80
  67. package/dist/semiotic-server-node.min.js +64 -64
  68. package/dist/semiotic-server-node.module.min.js +1 -1
  69. package/dist/semiotic.module.min.js +10 -10
  70. package/dist/server.min.js +64 -64
  71. package/dist/server.module.min.js +1 -1
  72. package/dist/xy.module.min.js +1 -1
  73. package/package.json +5 -5
  74. package/dist/c-72CBVNYX.min.js +0 -209
  75. package/dist/c-F2GGJB2S.min.js +0 -31
  76. package/dist/c-G53AVC42.min.js +0 -113
  77. package/dist/c-HQ27AHMC.min.js +0 -1
  78. package/dist/c-IHWZ2C6D.min.js +0 -26
  79. package/dist/c-MOP2NGLH.min.js +0 -1
  80. package/dist/c-PKY4JFY5.min.js +0 -1
@@ -1,9 +1,9 @@
1
- function e(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 t(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 i(...e){let t;for(const i of e)i&&(t=n(t)&&n(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function n(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function o(e){return"object"==typeof e&&null!==e&&"gradient"in e}function r(e){return"string"==typeof e&&e.length>0}function s(e,t,i=!1){const n=i?t?Vv:Gv:t?Xv:0;return n>e.top?{...e,top:n}:e}function a(e,t){return s(e,r(t))}function c(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 l(e){return Math.ceil(7*e.length)}function u(e,i){if(n(e)){const t=w(i);let n=Jv;for(const i of e.legendGroups){i.label&&(n=Math.max(n,l(i.label)));for(const e of i.items)n=Math.max(n,t.swatchSize+t.labelGap+l(e.label))}return n}if(o(e)){const{gradient:i}=e,n=i.format||t(i.domain),o=Math.max(l(n(i.domain[0])),l(n(i.domain[1]))),r=i.label?l(i.label):0;return Math.max(Jv,19+o,r)}return Jv}function d(e){return(n(e)||o(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):ew}function h(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?uw:lw:0}function p(e){return Math.max(0,e?.edgeGutter??tw)}function f(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?cw:aw:sw:0}function y(t){const{bottomAxis:i,topAxis:n,leftAxis:o,rightAxis:r}=e(t.axes),s=!(n&&!i||!1===i?.visible),a=!!n&&!i&&!1!==n.visible,c=!(r&&!o||!1===o?.visible),l=!!r&&!1!==r.visible,u=!1!==t.showAxes;return{hasAxis:u&&s,hasAxisLabel:u&&s&&!!(i?.label??t.xLabel),rotatedTicks:u&&s&&(t.rotatedTicks??!!i?.autoRotate),topAxis:a?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??t.xLabel),rotatedTicks:u&&(t.rotatedTicks??!!n?.autoRotate)}:void 0,leftAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??t.yLabel)}:void 0,rightAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??t.yLabelRight??t.yLabel)}:void 0}}function g(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 m(e,t,i){if(o(e))return e.gradient.label?ow:rw;if(!n(e))return 20;const r=w(i),s=Math.max(1,i?.maxWidth??t);let a=r.rowHeight;for(const t of e.legendGroups){let e=0,i=0;for(const n of t.items){const t=r.swatchSize+r.labelGap+l(n.label),o=0===i?t:i+r.itemGap+t;i>0&&o>s?(e+=1,i=t):i=o}t.items.length>0&&(e+=1),a=Math.max(a,e*r.rowHeight,t.label?l(t.label):0)}return a+(e.legendGroups.length>1?16:0)}function x(e,t,i){return u(e,t)+d(e)+h(t,i)+p(t)}function b(e,t){const{legend:i}=t;if(!i)return;const n=t.position??"right",o=m(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+d(i)+f("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?Vv:Gv:0);"right"===n?e.right=Math.max(e.right,r,x(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===n?e.left=Math.max(e.left,r,x(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 v(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??u(e,t.legendLayout)),s=d(e),a=h(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),c=p(t.legendLayout),l=m(e,o,t.legendLayout),y=f(t.axisChrome,t.legendLayout),g=f(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-g-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+y+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 w(e){const t=Math.max(1,e?.swatchSize??Uv),i=Math.max(t,e?.rowHeight??Qv);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??Kv),itemGap:Math.max(0,e?.itemGap??Zv),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function k(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 A(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 S(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(dw,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:n}}function M(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;")}function _(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 $(e,t){for(const i of e.attributes.matchAll(dw))if(i[1]===t)return _(i[2]??i[3])}function P(e,t){const i=S(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(dw,(e,i,n,o)=>{const r=t(i,_(n??o));return void 0===r?e:` ${i}="${M(r)}"`}):e)}function j(e,t){const i=S(e);if(!i)return e;const n=new Map(Object.entries(t));let o=i.attributes.replace(dw,(e,t)=>{const i=n.get(t);return void 0===i?e:(n.delete(t),` ${t}="${M(i)}"`)});for(const[e,t]of n)o+=` ${e}="${M(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function I(e,t){const i=S(e);if(!i)return t;const n=e=>{const n=$(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 L(e,t){const i=S(e);return i?j(e,{width:"100%",height:"100%",...void 0===$(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===$(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function R(e){return null==e?"null":Array.isArray(e)?`[${e.map(R).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)}:${R(t)}`).join(",")}}`:JSON.stringify(e)}function C(e){const t=[...fw],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=hw(i[e-15],7)^hw(i[e-15],18)^i[e-15]>>>3,n=hw(i[e-2],17)^hw(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+(hw(c,6)^hw(c,11)^hw(c,25))+(c&l^~c&u)+yw[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+((hw(n,2)^hw(n,13)^hw(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 T(e,t){return`${e}[Symbol(${t.description??""})]`}function O(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 E(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function F(e){return e.sort((e,t)=>{const i=JSON.stringify(e),n=JSON.stringify(t);return n>i?-1:i>n?1:0})}function N(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&&O(n,e.length)||i.excluded.push("symbol"==typeof n?T(t,n):E(t,n));return Array.from({length:e.length},(n,o)=>{const r=E(t,o),s=Object.getOwnPropertyDescriptor(e,o+"");if(!s||!("value"in s)||!s.enumerable)return i.excluded.push(r),null;const a=N(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(T(t,n));continue}const o=Object.getOwnPropertyDescriptor(e,n);o&&"value"in o&&o.enumerable?r.push(n):i.excluded.push(E(t,n))}for(const o of r.sort()){const r=Object.getOwnPropertyDescriptor(e,o),s=N(r&&"value"in r?r.value:void 0,E(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 z(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,z(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"]}),F(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&O(t,e.length))).map(i))];const n=Object.getPrototypeOf(e);return[n!==Object.prototype&&null!==n?"non-json-object":"object",F(Reflect.ownKeys(e).map(i))]}finally{t.delete(e)}default:return["excluded"]}}function D(e){const t={excluded:[],ancestors:/* @__PURE__ */new Set},i=N(e,"$",t)??null;return{value:i,text:JSON.stringify(i),excludedPaths:t.excluded}}function B(e){const t=D(e),i=C(JSON.stringify(["semiotic-value-fingerprint","v2",z(e)]));return{...t,algorithm:"sha256",digest:i,fingerprint:"sha256:"+i}}function W(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function Y(e,t){return`${e}[Symbol(${t.description??""})]`}function q(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 X(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function G(e,t,i,n){const o=X(e,t);return o&&"value"in o&&o.enumerable?V(o.value,i,n):[i]}function V(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=X(e,"length")?.value;if(!Number.isSafeInteger(n)||0>n)return[W(t,"length")];for(const e of o)"length"===e||"string"==typeof e&&q(e,n)||s.push("symbol"==typeof e?Y(t,e):W(t,e));for(let o=0;n>o;o+=1)s.push(...G(e,o+"",W(t,o),i))}else for(const n of o)"symbol"!=typeof n?s.push(...G(e,n,W(t,n),i)):s.push(Y(t,n));return s}catch{return[t]}finally{i.delete(e)}}function H(e,t,i,n){te(e,Object.keys(t),i,n);for(const[o,r]of Object.entries(t))r.values?(r.required||void 0!==e[o])&&ne(e,o,i,r.values,n):r.required?ie(e,o,i,n):ce(e,o,i,n)}function U(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function K(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 Z(e,t,i,n){void 0!==e[t]&&"boolean"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a boolean."})}function Q(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(Q):U(e)&&Object.values(e).every(Q))}function J(e,t,i,n){void 0===e[t]||U(e[t])&&Q(e[t])||n.push({path:`${i}.${t}`,message:"Expected a JSON object."})}function ee(e){return e.every(Q)}function te(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 ie(e,t,i,n){"string"==typeof e[t]&&e[t]||n.push({path:`${i}.${t}`,message:"Expected a non-empty string."})}function ne(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 oe(e,t,i,n){const o=e[t];if(void 0!==o){if(U(o))return o;n.push({path:`${i}.${t}`,message:"Expected an object."})}}function re(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 se(e,t,i){e?.some(e=>"string"!=typeof e||!e)&&i.push({path:t,message:"Expected non-empty string values."})}function ae(e,t,i,n,o){void 0!==e[t]&&ne(e,t,i,n,o)}function ce(e,t,i,n){void 0!==e[t]&&"string"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a string."})}function le(e,t,i){U(e)?(te(e,["id","name","kind"],t,i),ie(e,"kind",t,i),ce(e,"id",t,i),ce(e,"name",t,i)):i.push({path:t,message:"Expected an actor object."})}function ue(e,t){const i=oe(e,"reception","$",t);if(!i)return;te(i,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);const n=re(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}]`;U(e)?(te(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],n,t),ne(e,"channel",n,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),ae(e,"disclosure",n,["summary","standard","detailed"],t),ae(e,"rawData",n,["deny","bounded","allow"],t),Z(e,"navigation",n,t),Z(e,"interactionInstructions",n,t),K(e,"tokenBudget",n,t),se(re(e,"privacyNotes",n,t),n+".privacyNotes",t)):t.push({path:n,message:"Expected a channel object."})});for(const e of["strengths","risks","scaffolds","manualChecks"])se(re(i,e,"$.reception",t),"$.reception."+e,t);ce(i,"audience","$.reception",t),ce(i,"description","$.reception",t),Z(i,"dataFallback","$.reception",t)}function de(e,t){const i=oe(e,"form","$",t);i&&(te(i,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),ce(i,"chartFamily","$.form",t),ce(i,"whyThisForm","$.form",t),se(re(i,"risks","$.form",t),"$.form.risks",t),se(re(i,"misuse","$.form",t),"$.form.misuse",t),re(i,"rejectedAlternatives","$.form",t)?.forEach((e,i)=>{const n=`$.form.rejectedAlternatives[${i}]`;U(e)?(te(e,["representation","reason"],n,t),ie(e,"representation",n,t),ie(e,"reason",n,t)):t.push({path:n,message:"Expected an alternative object."})}))}function he(e,t){const i=oe(e,"contestability","$",t);i&&(te(i,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),Z(i,"sourceRequestsAllowed","$.contestability",t),re(i,"challenges","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.challenges[${i}]`;if(U(e)){te(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],n,t),ie(e,"id",n,t),ie(e,"claimId",n,t),ie(e,"reason",n,t),ne(e,"status",n,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&le(e.raisedBy,n+".raisedBy",t);for(const i of["raisedAt","counterclaimId","resolution"])ce(e,i,n,t)}else t.push({path:n,message:"Expected a challenge object."})}),re(i,"corrections","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.corrections[${i}]`;if(!U(e))return void t.push({path:n,message:"Expected a correction object."});te(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],n,t),ie(e,"id",n,t),ie(e,"reason",n,t);const o=re(e,"affectedClaimIds",n,t);o||t.push({path:n+".affectedClaimIds",message:"Expected an affected-claim array."}),se(o,n+".affectedClaimIds",t),se(re(e,"replacementClaimIds",n,t),n+".replacementClaimIds",t),ce(e,"createdAt",n,t),void 0!==e.createdBy&&le(e.createdBy,n+".createdBy",t)}),re(i,"alternativeViews","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.alternativeViews[${i}]`;U(e)?(te(e,["id","label","rationale"],n,t),ie(e,"id",n,t),ie(e,"label",n,t),ce(e,"rationale",n,t)):t.push({path:n,message:"Expected an alternative-view object."})}),re(i,"editorialExceptions","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.editorialExceptions[${i}]`;U(e)?(te(e,["ruleId","rationale","owner","reviewAt"],n,t),ie(e,"ruleId",n,t),ie(e,"rationale",n,t),ce(e,"owner",n,t),ce(e,"reviewAt",n,t)):t.push({path:n,message:"Expected an editorial-exception object."})}))}function pe(e,t){const i=oe(e,"accountability","$",t);i&&(te(i,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),re(i,"authors","$.accountability",t)?.forEach((e,i)=>le(e,`$.accountability.authors[${i}]`,t)),se(re(i,"dataSources","$.accountability",t),"$.accountability.dataSources",t),ce(i,"generatedBy","$.accountability",t),ce(i,"codeRef","$.accountability",t),re(i,"reviews","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.reviews[${i}]`;if(U(e)){te(e,["id","status","reviewer","reviewedAt","rationale","policyId"],n,t),ie(e,"id",n,t),ne(e,"status",n,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&le(e.reviewer,n+".reviewer",t);for(const i of["reviewedAt","rationale","policyId"])ce(e,i,n,t)}else t.push({path:n,message:"Expected a review object."})}),re(i,"actions","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.actions[${i}]`;if(!U(e))return void t.push({path:n,message:"Expected an action object."});te(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],n,t),ie(e,"id",n,t),ie(e,"action",n,t);const o=re(e,"claimIds",n,t);o||t.push({path:n+".claimIds",message:"Expected a claim identifier array."}),se(o,n+".claimIds",t),void 0!==e.actor&&le(e.actor,n+".actor",t);for(const i of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])ce(e,i,n,t);ae(e,"status",n,["proposed","taken","reversed","invalidated"],t)}))}function fe(e,t){const i=oe(e,"inheritance","$",t);if(i){te(i,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(const e of["requiredPaths","prohibitedExports","sourceArtifactIds"])se(re(i,e,"$.inheritance",t),"$.inheritance."+e,t);ae(i,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),ae(i,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),ae(i,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function ye(e,t){ue(e,t),de(e,t),he(e,t),pe(e,t),fe(e,t)}function ge(e){for(const t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function me(e,t){if(void 0===e||U(e)){if(U(e))for(const[i,n]of Object.entries(e)){const e="$.fieldStatus."+i;if(!U(n)||"string"!=typeof n.status){t.push({path:e,message:"Expected a field state with a status."});continue}te(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."}),ce(n,"reason",e,t),ce(n,"reviewedBy",e,t),Z(n,"derived",e,t);const o=Object.prototype.hasOwnProperty.call(mw,i)?mw[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 xe(e,t){const i="$.time";te(e,[...vw,...Object.keys(ww),"sources"],i,t);for(const n of vw)ce(e,n,i,t);for(const[n,o]of Object.entries(ww)){const r=oe(e,n,i,t);r&&H(r,o,`${i}.${n}`,t)}re(e,"sources",i,t)?.forEach((e,n)=>{const o=`${i}.sources[${n}]`;U(e)?H(e,kw,o,t):t.push({path:o,message:"Expected a source object."})})}function be(e){try{return ve(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function ve(e){const t=[],i=[];if(!U(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:i};const n=V(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(te(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),e.contractVersion!==gw&&t.push({path:"$.contractVersion",message:`Expected contract version ${gw}.`}),U(e.artifact)){te(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),ie(e.artifact,"id","$.artifact",t),ne(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(const i of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])ce(e.artifact,i,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(U(e.purpose))if(Array.isArray(e.purpose.intents)){te(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,i)=>{U(e)&&"string"==typeof e.id&&e.id||t.push({path:`$.purpose.intents[${i}].id`,message:"Expected a non-empty intent identifier."}),U(e)&&te(e,["id","strength","source","rationale"],`$.purpose.intents[${i}]`,t),U(e)&&void 0!==e.strength&&ne(e,"strength",`$.purpose.intents[${i}]`,["primary","secondary"],t),U(e)&&(ae(e,"source",`$.purpose.intents[${i}]`,["author","derived","model-proposal","import"],t),ce(e,"rationale",`$.purpose.intents[${i}]`,t))});for(const i of["allowedUses","prohibitedUses"])se(re(e.purpose,i,"$.purpose",t),"$.purpose."+i,t);ae(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),ce(e.purpose,"communicativeAct","$.purpose",t),ce(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(!U(e))return void t.push({path:`$.claims[${i}]`,message:"Expected a claim object."});te(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${i}]`,t),ie(e,"id",`$.claims[${i}]`,t),ne(e,"kind",`$.claims[${i}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),ne(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."}),se(re(e,"supersedes",`$.claims[${i}]`,t),`$.claims[${i}].supersedes`,t),ce(e,"text",`$.claims[${i}]`,t),ce(e,"asOf",`$.claims[${i}]`,t),J(e,"scope",`$.claims[${i}]`,t),se(re(e,"tags",`$.claims[${i}]`,t),`$.claims[${i}].tags`,t),void 0!==e.authoredBy&&le(e.authoredBy,`$.claims[${i}].authoredBy`,t);const n=oe(e,"review",`$.claims[${i}]`,t);n&&(te(n,["status","reviewer","reviewedAt","rationale"],`$.claims[${i}].review`,t),ne(n,"status",`$.claims[${i}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==n.reviewer&&le(n.reviewer,`$.claims[${i}].review.reviewer`,t),ce(n,"reviewedAt",`$.claims[${i}].review`,t),ce(n,"rationale",`$.claims[${i}].review`,t));const o=oe(e,"uncertainty",`$.claims[${i}]`,t);if(o){te(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${i}].uncertainty`,t),ne(o,"kind",`$.claims[${i}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(const e of["lower","upper","confidence"])K(o,e,`$.claims[${i}].uncertainty`,t);ce(o,"unit",`$.claims[${i}].uncertainty`,t),ce(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(!U(e))return void t.push({path:`$.evidence[${i}]`,message:"Expected an evidence object."});te(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${i}]`,t),ie(e,"id",`$.evidence[${i}]`,t),ne(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"])ce(e,n,`$.evidence[${i}]`,t);J(e,"scope",`$.evidence[${i}]`,t);const n=oe(e,"source",`$.evidence[${i}]`,t);if(n){te(n,["name","uri","version","retrievedAt","publisher"],`$.evidence[${i}].source`,t);for(const e of["name","uri","version","retrievedAt","publisher"])ce(n,e,`$.evidence[${i}].source`,t)}const o=oe(e,"transformation",`$.evidence[${i}]`,t);if(o){te(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${i}].transformation`,t),ie(o,"id",`$.evidence[${i}].transformation`,t),ne(o,"kind",`$.evidence[${i}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);const e=re(o,"inputEvidenceIds",`$.evidence[${i}].transformation`,t);e?se(e,`$.evidence[${i}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${i}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),se(re(o,"assumptions",`$.evidence[${i}].transformation`,t),`$.evidence[${i}].transformation.assumptions`,t),ce(o,"description",`$.evidence[${i}].transformation`,t),ce(o,"implementation",`$.evidence[${i}].transformation`,t),ce(o,"performedAt",`$.evidence[${i}].transformation`,t),J(o,"parameters",`$.evidence[${i}].transformation`,t),void 0!==o.performedBy&&le(o.performedBy,`$.evidence[${i}].transformation.performedBy`,t)}const r=oe(e,"sample",`$.evidence[${i}]`,t);if(r){te(r,["rowCount","fields","values","truncated"],`$.evidence[${i}].sample`,t),se(re(r,"fields",`$.evidence[${i}].sample`,t),`$.evidence[${i}].sample.fields`,t);const e=re(r,"values",`$.evidence[${i}].sample`,t);e&&!ee(e)&&t.push({path:`$.evidence[${i}].sample.values`,message:"Expected JSON values."}),K(r,"rowCount",`$.evidence[${i}].sample`,t),Z(r,"truncated",`$.evidence[${i}].sample`,t)}ae(e,"relationship",`$.evidence[${i}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),me(e.fieldStatus,t);const o=oe(e,"time","$",t);return o&&xe(o,t),ye(e,t),J(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 we(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ke(e,t){if(!t||!we(e)||!Array.isArray(e.evidence))return[];const i=[];return e.evidence.forEach((e,t)=>{we(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,i.push(`$.evidence[${t}].sample`))}),i}function Ae(e,t={}){try{return Se(e,t)}catch{const t=V(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function Se(e,t){if(!we(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const i=D(e),n=[.../* @__PURE__ */new Set([...i.excludedPaths,...V(e)])].sort(),o=i.value,r=ke(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!==gw)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=be(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 Me(e,t){return Aw.has(e)&&!("reading"===e&&"string"==typeof t)}function _e(e){const t=Object.entries(e).filter(([e,t])=>Me(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function $e(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 B(i.length>0?{data:e,transformations:i}:e).fingerprint}function Pe(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!Me(e,t)&&"recipeId"!==e))}function je(e,t,i,n=_e(t)){const o=Pe(t),r=0===V(o).length?B(o).fingerprint:void 0,s=void 0!==n&&0===V(n).length?$e(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 Ie(e,t){return C(R({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 Le(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Re(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function Ce(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function Te(e,t){const{when:i}=e,n=t.width,o=t.height,r=Ce(t),s=Re(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 Oe(e,t){const i={...e,...t};for(const n of["margin","frameProps","mobileSemantics","style"])Le(e[n])&&Le(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 Ee(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=>Te(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)=>Oe(e,t.rule.transform),e),matches:n}}function Fe(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 _w;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??n??Sw,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??Sw,standardControls:a.standardControls??!1}}function Ne(e,t,i){const n=$w[e||"primary"],o=e&&"primary"!==e||!i?.width?n.width:i.width,r=e&&"primary"!==e||!i?.height?n.height:i.height,s=Ee({...t,mode:e},{width:t.width??o,height:t.height??r}).props,a=s.mode||e||"primary",c=$w[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:ze(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:Fe(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function ze(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 De(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Be(e,t,i,n){const o=e??t;return"function"==typeof o?o(i,n):i[o+""]}function We(e){const t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,n)=>{if(!Number.isFinite(Number(Be(e.yAccessor,"y",i,n))))return;const o=De(Be(e.xAccessor,"x",i,n)),r=t.get(o)??/* @__PURE__ */new Set;r.add(Be(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 Ye(e){return Lw.has(e)}function qe(e){return Lw.get(e)}function Xe(e){return Ye(e)?qe(e):"BumpChart"===e?Pw:void 0}function Ge(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 Ve(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;const n=Xe(t);if(!n)return;let o;try{const t="function"==typeof n?n(i,e):We(i);o=Array.from(t).filter(Ge)}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 He(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 Ue(e){return`${e.getUTCFullYear()}-${Ke(e.getUTCMonth()+1)}-${Ke(e.getUTCDate())}`}function Ke(e){return 10>e?"0"+e:e+""}function Ze(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 Qe(e,t={}){const i=t.baseOpacity??1;return t.highlight||t.predicate?!Ze(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function Je(e){if(0===e.length)return 0;let t=0;for(const i of e)t+=i;return t/e.length}function et(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,Nw.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 tt(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>ot(t(e))}function it(e,t){const i=tt(e),n=tt(t);return(e,t)=>{const o=n(e);return{value:o,x:i(e),y:o,category:t}}}function nt(e,t){const i=tt(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 ot(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 rt(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=ot(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 st(e,t,i){const n=e.when;return void 0===n||!0===n||!1!==n&&("function"==typeof n?n(t,i):rt(n,t,i))}function at(e,t,i){if(!t||0===t.length)return{};let n={};for(const o of t){if(!st(o,e,i))continue;const t="function"==typeof o.style?o.style(e,i):o.style;t&&(n={...n,...t})}return n}function ct(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,at(s,t,i(s,r))),a}:o}function lt(e,t,i,n){if(!e||0===e.length)return n;const o=nt(t,i);return(t,i)=>{const r=t&&t.data||t,s=at(r,e,o(r)),a=n?n(t,i):void 0;return a?{...s,...a}:s}}function ut(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 dt(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 ht(e,t="#4e79a7",i){const n=i?.styleRules,o=!!n&&n.length>0,r=o?tt(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:dt(a),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&s&&Object.assign(c,at(s,n,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function pt(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 ft(e,t,i){return"function"==typeof i?i(e,t):e[i]}function yt(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 gt(e,t,i){return Math.max(t,Math.min(i,e))}function mt(e,t){const i=yt(e);return null!=i&&i>0?i:t}function xt(e){if(!e)return;const t=yt(e[0]),i=yt(e[1]);return null!=t&&null!=i?t>i?[i,t]:[t,i]:void 0}function bt(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function vt(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 wt(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=gt(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),r=vt(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 kt(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 At(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 St(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 Mt(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 _t(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 $t(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Pt(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 jt(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:Mt(e.fixedPosition)}:{},shape:$t(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function It(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 Lt(e){return{id:e.id,shape:Pt(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:It(e.bodyFilter),index:e.index}}function Rt(e,t,i){return Math.max(t,Math.min(i,e))}function Ct(e,t,i){return Math.min(e??i,t??i)}function Tt(e,t,i){return Rt(Math.max(e??i,t??i),0,1)}function Ot(e){return 0>e?-1:1}function Et(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 Ft(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 Nt(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function zt(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(Hw>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}function Dt(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:Ot(c),ny:0,penetration:l}:{nx:0,ny:Ot(u),penetration:d}:null}function Bt(e,t,i,n,o,r,s){const a=r/2,c=s/2,l=e-Rt(e,n-a,n+a),u=t-Rt(t,o-c,o+c),d=l*l+u*u;if(d>i*i)return null;if(Hw>=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 Wt(e,t,i,n,o,r,s,a=0){const c=r-n,l=s-o,u=c*c+l*l,d=u>Hw?Rt(((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(Hw>=y){const e=Math.sqrt(u);return e>Hw?{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 Yt(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return zt(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Dt(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=Bt(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?Bt(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function qt(e,t){const i=t.shape;return"aabb"===i.type?"circle"===e.shape.type?Bt(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):Dt(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height):Wt(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 Xt(e,t){return`${e}\0${t}`}function Gt(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Vt(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 Ht(e,t){return!!t?.some(t=>Object.is(e,t))}function Ut(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const i=Vt(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!Ht(i,t.oneOf)||t.notOneOf&&Ht(i,t.notOneOf))}function Kt(e,t){return Ut(t,e.bodyFilter)}function Zt(e={}){return new Zw(e)}function Qt(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):Zt(t)}function Jt(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 ei(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 ti(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 ii(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function ni(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?ii(t,e):void 0}function oi(e,t,i){if("number"==typeof e)return e;const n="function"==typeof e?e(t,i):"string"==typeof e?ii(t,e):1,o="number"==typeof n?n:Number(n);return Number.isFinite(o)?o:1}function ri(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function si(e){for(const t of Qw){const i=ri(ii(e,t));if(i)return i}return"sediment"}function ai(e){const t=ei(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:ei(e.x),y:ei(e.y),value:t}}function ci(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 li(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}function ui(e,t,i){if(!1===i)return;const n=li(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 di(e){const t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),n=t+i,o=li(e.bodyLimit),r=li(e.engineMaxBodiesHint),s=ui(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 hi(e={},t=tk){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 pi(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function fi(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 yi(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function gi(e,t,i){return"function"==typeof i?fi(i(e,t)):"string"==typeof i?fi(yi(e,i)):fi(e.spawnAt)??fi(yi(e,"arrivalTime"))??fi(yi(e,"timestamp"))??fi(yi(e,"time"))??fi(yi(e,"eventTime"))}function mi(e,t={}){const i=fi(t.startAt)??0,n=t.pacing??"immediate";if("arrival"===n){const n=e.map((e,i)=>gi(e,i,t.timeAccessor)),o=n.filter(e=>null!=e),r=o.length>0?Math.min(...o):0,s=fi(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{...pi(e),spawnAt:i+s/a}})}if("object"==typeof n){const t=fi(n.ratePerSec);if(t&&t>0)return e.map((e,n)=>({...pi(e),spawnAt:i+n/t}))}return e.map(e=>({...pi(e),spawnAt:i}))}function xi(e){return{...pi(e),sequence:e.sequence,spawnAt:e.spawnAt}}function bi(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 vi(e){return!1!==e&&{...e}}function wi(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function ki(e){return{...e,gravity:{...e.gravity}}}function Ai(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}function Si(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 Mi(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function _i(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 $i(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 Pi(e,t){const i={...e};for(const e of t)i[ik[e]]++;return i}function ji(e,t,i){const n=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:n,revisions:Pi(i,n)}}function Ii(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=pk[n]??fk;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Li(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&yk.every(i=>e[i]===t[i])}function Ri(e,t){return Object.keys(e).filter(i=>"kernel"===i?!Li(e.kernel,t.kernel):e[i]!==t[i])}function Ci(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 Ti(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}=Mi(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 Oi(e,t){for(const i of e)t.has(Mi(i).bodyId)&&e.delete(i)}function Ei(e,t,i,n){return e||!t?"paused":i||!n?"running":"settled"}function Fi(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 Ni(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 zi(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 Di(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 Bi(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=zi(e,i,o).slice(0,c);if(0===l.length)return s;const u=Di(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 Wi(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}function Yi(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 qi(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 Xi(e){const{data:t,valueAccessor:i,bins:n,ballRadius:o,seed:r,size:s,valueExtent:a}=e,{rows:c}=kt(t,"galton"),l=ut(s),u=c.map((e,t)=>yt(ft(e,t,i))).filter(e=>null!=e),d=xt(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,Gw.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=yt(ft(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:pt(r,[..._i({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...$i({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 Gi(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}=kt(e.data,"event"),r=o.flatMap((t,i)=>{const n=yt(ft(t,i,e.timeAccessor));return null==n?[]:[{datum:t,index:i,eventTime:n,arrivalTime:yt(ft(t,i,e.arrivalAccessor))??n,watermarkAtArrival:0,late:!1}]}),s="function"==typeof i?null:yt(i?.value),a="function"==typeof i?t:yt(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?yt(i(c)):c-a;l=s??Math.max(l,o??c-t);const r=n?yt(ft(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 Vi(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 Hi(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,xk.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 Ui(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 Ki(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}=Gi({data:t,timeAccessor:i,arrivalAccessor:n,watermark:r,watermarkAtArrivalAccessor:s,windowSize:o.size}),f=ut(l),y=h.map(e=>e.eventTime),g=h.length?Math.min(...h.map(e=>e.arrivalTime)):0,m=yt(u?.[0]),x=yt(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))),_=Vi(f,a),$=A+S*o.size,P=(0,xk.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:Qi(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=Hi(R,f.plot.y+.28*f.plot.height);for(const e of I){const t=e.datum;e.y=Zi({...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=Ui({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:pt(c,[..._i({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 Zi(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 Qi(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 Ji(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=mt(e.unitValue,1),r=vt(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 en(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 tn(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 nn(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=mt(r,1),{rows:u}=kt(i,"pile"),d=ut(c),h=[],p=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map,y=[];u.forEach((e,i)=>{t((ft(e,i,n)??"unknown")+"")});const g=Math.max(1,h.length),m=tn(d.plot,g,s),x=Math.max(0,m.tubeWidth/2-s-1),b=h.map(()=>[]);u.forEach((e,i)=>{const r=(ft(e,i,n)??"unknown")+"",a=t(r),c=o?yt(ft(e,i,o)):1,u=Math.max(0,c??0);f.set(r,(f.get(r)??0)+u);const h=en(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=[..._i({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:pt(a,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:f.get(e)??0}))}}function on(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 rn(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}=kt(i,"collision-swarm"),p=ut(c),f=vt(a),y=[],g=[],m=/* @__PURE__ */new Map;h.forEach((e,i)=>{const a=yt(ft(e,i,n));if(null==a)return;const c=o?(ft(e,i,o)??"All")+"":"All",l=r?yt(ft(e,i,r)):null,u=gt(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?yt(l[0]):null,v=l?yt(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,bk.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=on(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:pt(a,_i({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 sn(e){if(Array.isArray(e)&&e.length>=2){const t=yt(e[0]),i=yt(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){const t=e,i=yt(t.x),n=yt(t.y);return null!=i&&null!=n?{x:i,y:n}:null}return null}function an(e){return Array.isArray(e)?e.map(sn).filter(e=>null!=e):[]}function cn(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:gt(e.x,t.plot.x,t.plot.x+t.plot.width),y:gt(e.y,t.plot.y,t.plot.y+t.plot.height)}}function ln(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 un(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const i=gt(t,0,1)*ln(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 dn(e,t){const i=un(e,Math.max(0,t-.02)),n=un(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 hn(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=ut(g),w=vt(y),k=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=[];l.forEach((e,t)=>{const i=(ft(e,t,s)??e.id??t)+"",n=yt(ft(e,t,a)),o=yt(ft(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(ft(e,i,m)),o=t(ft(e,i,x)),r=Math.max(0,yt(ft(e,i,b))??0),s=an(h?ft(e,i,h):void 0),a=s.length?s:an(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,cn(t,v,_));const I=[];for(const e of M){let t=e.rawPath.map(e=>cn(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=mt(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=mt(n,90),B=mt(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=ln(e.path);for(let n=0;e.packetCount>n;n+=1){const o=(n+.5)/e.packetCount,r=f?o:gt(.12+.84*o+.04*(w()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*w())),a=un(e.path,s),c=un(e.path,r),l=dn(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-"+bt(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=pt(y,[..._i({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-"+bt(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 pn(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 fn(e,t,i){return Math.max(t,Math.min(i,e))}function yn(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function gn(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 mn(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=fn(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,y=fn(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=fn(e.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=yn(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=fn((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=fn((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=fn((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(gn(b+"-top",s,c,a,c,T),gn(b+"-bottom",s,l,a,l,T),gn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),gn(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)})):"funnel"===t?O.push(gn(b+"-top",s,c,a,m,T),gn(b+"-bottom",s,l,a,x,T),gn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),gn(b+"-right",a,m,a,x,{...T,thickness:Math.max(6,k)})):O.push(gn(b+"-left-top",s,c,I,m,T),gn(b+"-left-bottom",s,l,I,x,T),gn(b+"-center-top",I,m,L,m,T),gn(b+"-center-bottom",I,x,L,x,T),gn(b+"-right-top",L,m,a,c,T),gn(b+"-right-bottom",L,x,a,l,T),gn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),gn(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+fn(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=>bn({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 xn(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 bn(e){const t=e.dampingScale??.5,i=e.energyScale??1,n=fn(e.cost,0,2);return{...xn({...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 vn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...xn({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function wn(e){const t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,n=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...xn({...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 kn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...xn({...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 An(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...xn({...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 Sn(e){return{...xn({...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 Mn(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 _n(e){const t=e.idPrefix??"lane",i={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},n=[gn(t+"-top",e.left,e.top,e.right,e.top,i),gn(t+"-bottom",e.left,e.bottom,e.right,e.bottom,i)];return e.openEnds||n.push(gn(t+"-left",e.left,e.top,e.left,e.bottom,i),gn(t+"-right",e.right,e.top,e.right,e.bottom,i)),n}function $n(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 Pn(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 An({...i,kind:e.kind??"sink",force:$n(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:$n(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...xn({...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 kn({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:$n(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 wn({...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:$n(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?vn({...i,kind:e.kind??"force-field",force:$n(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):Sn({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}function jn(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=e.size,n=ut(i),o=gt(e.ballRadius??6,2,18),r=e.seed??1,s=vt(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=mn({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 Pn(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(vn({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?ft(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",n=(ft(e,t,c)??w)+"",r=b.has(n)?n:w;M.set(r,(M.get(r)??0)+1);const s=l?(ft(e,t,l)??"")+"":void 0,p=s&&u?(ft(e,t,u)??s)+"":s,f=d?yt(ft(e,t,d))??1:1,y=h?yt(ft(e,t,h)):null,g=gt(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=gt(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 Mn({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=pn(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 In(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function Ln(e,t,i){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(i)}`}function Rn(e){const t=e.map(In),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){const[e,i,n]=t[0];return Ln(e,i,n)}if(e>=1){const[e,n,o]=t[i];return Ln(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 Ln(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(d-c)*r))}}function Cn(e){return e&&Object.prototype.hasOwnProperty.call(Ok,e)?Ok[e]:Ak}function Tn(e,t,i=qk){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(Yk,e)?Yk[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function On(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Hk.has(t)}function En(e,t,i){if("function"==typeof t){const n=t(e);return i&&n&&"string"==typeof n&&!On(n)?i(n):n}const n=e?.[t]+"";return i?i(n):qk[Math.abs(zn(n))%qk.length]}function Fn(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 Nn(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const e=i;return t=>Fn(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,wk.scaleOrdinal)().domain(n).range(i).unknown("#999");const r=Object.prototype.hasOwnProperty.call(Yk,i)?Yk[i]:Yk.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:qk;return(0,wk.scaleOrdinal)().domain(n).range(e).unknown("#999")}}function zn(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 Dn(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 Bn(e,t,i){return Tn(e,t,i)}function Wn(e,t){const i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Fn(i,e)||"#4e79a7":t=>{if(i){const e=Fn(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 Yn(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 qn(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 Xn(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 Gn(e){const t=Yn(e.config,e.chartId,e.onObservation),i=Bn(e.colorScheme,e.themeCategorical,kk),n=ut(e.size),o={data:e.data,scales:{x:(0,vk.scaleLinear)().domain(e.xExtent??[0,1]).range([n.plot.x,n.plot.x+n.plot.width]),y:(0,vk.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:Wn(i,e.colorScheme),config:e.layoutConfig??{},world:new mk(t)},r=e.skipLayout?{}:e.layout(o)??{},s=Xn([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:qn(t,r),context:o,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}function Vn(e){const t=Qn(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 Hn(e,t,i,n){return i?"function"==typeof i?i(e,t):e[i]??n:n}function Un(e){return`gauntlet:${e}:core`}function Kn(e,t){return`gauntlet:${e}:positive:${t}`}function Zn(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function Qn(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return Uk;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 Jn(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function eo(e,t,i,n){const o=Qn(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 to(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 io(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 no(e,t,i,n){const o=io(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 oo(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 ro(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 so(e,t,i,n,o){const r=Hn(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=n.map(e=>e.id),a=[...Hn(e,t,i.positiveAccessor,s)],c=[...Hn(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Hn(e,t,i.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Hn(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Hn(e,t,i.initialViability,100)}}function ao(e,t,i,n,o,r,s){const a=Jn(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:Un(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=eo(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=oo(e.activePositiveIds,t,a),s=n.radius??Math.max(2,10*a),c=eo(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,i);y.push({id:Kn(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:Un(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(lo(e,o,n,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}function co(e){const t=to(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=so(t,s,r,i,o);return{...a,viability:e.viability?.(a,{negativeProperties:o,positiveProperties:n})??ro(a,n,o)}}),a=s.flatMap((i,r)=>{const s=no(i,r,t,e.projectPlacement);return ao(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:Vn(t)}}}function lo(e,t,i,n,o,r,s){const a=Jn(r),c=t.radius??Math.max(2,7.2*a),l=eo(n+(i%4*12-12)*a,o+(54+12*Math.floor(i/4))*a,c,r);return{id:Zn(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:Un(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*a),...t.spring??{}}]}}function uo(e=[]){const t=/* @__PURE__ */Object.create(null);for(const[i,n]of e)t[i]=n;return t}function ho(...e){const t=uo();for(const i of e)for(const[e,n]of Object.entries(i??{}))t[e]=n;return t}function po(e){return ho(e)}function fo(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 yo(e){const t=uo(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:po(t.initialMetrics),metrics:po(t.metrics),productIds:[...t.productIds],history:fo(t.history)}])),i=uo(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:po(t.metrics),sourceIds:[...t.sourceIds],history:fo(t.history)}])),n=uo(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?po(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:n,input:{amount:e.input.amount,metrics:po(e.input.metrics)},metrics:po(e.metrics),loss:{amount:e.loss.amount,metrics:po(e.loss.metrics)},history:fo(e.history)}}function go(e,t){return t>e?-1:e>t?1:0}function mo(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function xo(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(go)}function bo(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[mo("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function vo(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function wo(e){const t=uo();for(const i of e)vo(t,i.metrics);return t}function ko(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(mo("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(mo("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(go);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||n.push(mo("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:n}}function Ao(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 So(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 Mo(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(mo("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function _o(e,t,i){const n=xo(t);t.length||e.diagnostics.push(mo("error","empty-source-list","A product requires at least one source component.",i)),n.length&&e.diagnostics.push(mo("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(mo("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(mo("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(mo("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 $o(e,t,i){const n=xo(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(mo("error","insufficient-relation-sources","A relation requires at least two source components.",i)),n.length&&e.diagnostics.push(mo("error","duplicate-source",`Relation source ids must be unique: ${n.join(", ")}.`,i,n)),o.length&&e.diagnostics.push(mo("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 Po(e,t,i,n,o){const r=n?.amount??0;(!Number.isFinite(r)||0>r||r>t+Kk)&&e.diagnostics.push(mo("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...bo(n?.metrics,o+".metrics"));for(const[t,r]of Object.entries(n?.metrics??{}))(0>r||r>Number(i[t]??0)+Kk)&&e.diagnostics.push(mo("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 jo(e,t,i,n){if(!t?.length)return[];const o=xo(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(mo("error","duplicate-relation","Basis relations must be unique.",n,o)),r.length&&e.diagnostics.push(mo("error","unknown-relation",`Unknown basis relation: ${r.join(", ")}.`,n,r)),s.length&&e.diagnostics.push(mo("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,n,s)),c.length&&e.diagnostics.push(mo("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 Io(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;So(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}function Lo(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 Ro(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?ho(n,e.metrics):po(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 Co(e,t,i,n){void 0!==t.amount&&Math.abs(t.amount-i)>Kk&&e.diagnostics.push(mo("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,n,[t.id]))}function To(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(!Mo(e,a,r+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(mo("error","product-already-complete",`Product "${t.id}" is already complete.`,r,[t.id]));s&&(Co(e,s,t.amount,r+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics=ho(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=Ao(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),So(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0})}function Oo(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(mo("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,n+".state")),e.diagnostics.push(...bo(t.metricsDelta,n+".metricsDelta")),Mo(e,t.outletId,n+".outletId");const i=ko(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(mo("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=Ao(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&&vo(i.metrics,t.metricsDelta),i.history.push(s)}return o.history.push(s),void(i.ids.length&&So(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(mo("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,n+".relation.id",[i.id]));const r=$o(e,i.sourceIds,n+".relation.sourceIds");if(e.diagnostics.push(...bo(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?po(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=Ao(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(s),void So(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){const i=xo(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(mo("error","duplicate-relation","Relation ids must be unique.",n+".relationIds",i)),r.length&&e.diagnostics.push(mo("error","unknown-relation",`Unknown relation: ${r.join(", ")}.`,n+".relationIds",r)),s.length&&e.diagnostics.push(mo("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=Ao(e,t,{relationIds:[...t.relationIds]});return o.history.push(a),void So(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(mo("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(mo("error","duplicate-product",`Product "${t.productId}" has already been formed.`,n+".productId",[t.productId])),"contribute"!==t.type||r&&"forming"===r.status||e.diagnostics.push(mo("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,n+".productId",[t.productId]));const s=_o(e,t.sourceIds,n+".sourceIds"),a="contribute"===t.type&&r?[...r.sourceIds,...t.sourceIds]:t.sourceIds,c=jo(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=wo(s);if(!Po(e,l,u,t.loss,n+".loss"))return;const d=l-(t.loss?.amount??0);Lo(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,p=Ao(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let f;if("combine"===t.type){if(h&&Co(e,i,d,n+".productId"),f=Ro(i,t.sourceIds,d,u,e,h,p),h&&!Mo(e,f.outletId,n+".productId"))return;o.products[t.productId]=f}else f=r,f.sourceIds.push(...t.sourceIds),f.amount+=d,vo(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),Io(e,c),So(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&&So(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 To(e,i,t.outletId,t.reason,t,n):void e.diagnostics.push(mo("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,n+".productId",[t.productId]))}if("split"===t.type){const i=_o(e,[t.sourceId],n+".sourceId");t.products.length||e.diagnostics.push(mo("error","empty-split","A split requires at least one product allocation.",n+".products"));const r=t.products.map(e=>e.productId),s=xo(r);s.length&&e.diagnostics.push(mo("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(mo("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,n+".products",c)),l.length&&e.diagnostics.push(mo("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(mo("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${n}.products.${i}.amount`)),e.diagnostics.push(...bo(o.metrics,`${n}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=i[0];if(!Po(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(mo("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)>Kk)return void e.diagnostics.push(mo("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,n+".products"));const g=po(u.metrics);for(const[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;const m=Ao(e,t,{sourceIds:[u.id],productIds:r});if(t.products.forEach((i,r)=>{const s=a[r],c=d>Kk?f[r]/d:1/t.products.length,l=uo(Object.entries(g).map(([e,t])=>[e,t*c])),h=i.metrics??s.metrics??l,p=Ro({...s,amount:f[r],metrics:h},[u.id],f[r],po(h),e,!0,m);Mo(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),So(e,{type:"split-source",sourceIds:[u.id],productIds:r});for(const t of r)So(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){Mo(e,t.outletId,n+".outletId");const i=ko(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(mo("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=Ao(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&&So(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...bo(t.metricsDelta,n+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,r;if("run"===t.target)vo(o.metrics,t.metricsDelta);else if("components"in t.target){const r=ko(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)vo(o.components[e].metrics,t.metricsDelta)}else{r=[...t.target.productIds];const i=xo(r),s=r.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(mo("error","duplicate-product","Metric target product ids must be unique.",n+".target.productIds",i)),s.length&&e.diagnostics.push(mo("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)vo(o.products[e].metrics,t.metricsDelta)}return void o.history.push(Ao(e,t,{sourceIds:i,productIds:r}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(Ao(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(mo("error","invalid-outcome","Outcome must be a non-empty string.",n+".outcome"))}function Eo(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[mo("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const n=yo(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(Oo(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 Fo(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function No(e,t={}){const i=t.groupBy??"outlet",n=/* @__PURE__ */new Map,o=e=>{const t=Fo({...e,status:e.status??"active"},i),o=n.get(t);if(o)return o.count+=1,o.amount+=e.amount,void vo(o.metrics,e.metrics);n.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:po(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)||go(e.key,t.key))}function zo(e,t){return t>e?-1:e>t?1:0}function Do(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function Bo(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(zo)}function Wo(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Yo(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(Do("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,r)),n}}function qo(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Do("error","invalid-metrics","Metrics must be a numeric object.",i)),uo();const n=uo();for(const[o,r]of Object.entries(e)){const e=Wo(r);null!=e?n[o]=e:t.push(Do("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return n}function Xo(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function Go(e){const t=[],i=uo(),n=[];let o=0;const r=uo();e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((Yo(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(Do("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));n.push(l);const u=Wo(Yo(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Do("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=qo(Yo(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),p=Yo(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),f=Jk.has(p)?p:"active";Jk.has(p)||t.push(Do("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${a}.status`,[l]));const y=Yo(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",g=Yo(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:ho(h),metrics:ho(h),productIds:[],history:[]},o+=d,Xo(r,h))});const s=Bo(n);s.length&&t.push(Do("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=qo(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:uo(),relations:uo(),input:{amount:o,metrics:r},metrics:a,loss:{amount:0,metrics:uo()},history:[]},diagnostics:t}}function Vo(e){const t=[];e.length||t.push(Do("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const i=Bo(e.map(e=>e.id));i.length&&t.push(Do("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let n=0;return{phases:e.map((e,i)=>{const o=Wo(e.duration),r=null!=o&&o>0?o:0;e.id.trim()||t.push(Do("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),null!=o&&o>0||t.push(Do("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(Do("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 Ho(e,t,i){const n=e.find(e=>eA>=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}:eA>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function Uo(e,t,i){const n=[],o=Bo(e.map(e=>e.id));o.length&&n.push(Do("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(Do("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){const r=Wo(e.at.time);if(null==r||0>r||r>i+eA)return void n.push(Do("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=Ho(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(Do("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(Do("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(Do("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 Ko(e,t){const i=[],n=new Set(t.map(e=>e.id)),o=Bo(t.map(e=>e.id)),r=Bo(e.map(e=>e.id));return o.length&&i.push(Do("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),r.length&&i.push(Do("error","duplicate-product-id",`Product ids must be unique: ${r.join(", ")}.`,"products",r)),t.forEach((e,t)=>{e.id.trim()||i.push(Do("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||i.push(Do("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Do("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(Do("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(Do("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),qo(e.metrics??{},i,`products.${t}.metrics`)}),i}function Zo(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 Qo(e=Zk,t=Qk){const i=Math.max(1,Wo(e[0])??900),n=Math.max(1,Wo(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=Zo(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 Jo(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+eA).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[];let r=e;for(const[e,t]of n)e>r+eA&&o.push([r,e]),r=Math.max(r,t);return t>r+eA&&o.push([r,t]),o}function er(e){const{id:t,orientation:i,fixed:n,start:o,end:r,openings:s,thickness:a,friction:c,restitution:l}=e,u=Jo(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 tr(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(...er({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}),...er({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}),...er({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 ir(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 nr(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?ir(e):1}function or(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 rr(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:nr(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function sr(e){return"crucible:component:"+encodeURIComponent(e)}function ar(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>eA?n[0]+(n[1]-n[0])*Math.sqrt(Math.max(0,e-o)/(r-o)):(n[0]+n[1])/2}function cr(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 lr(e,t,i={}){const n=Object.values(e.components).sort((e,t)=>zo(e.id,t.id)),o=n.map(e=>e.amount),r=cr(i.radiusRange,t),s=or(nr(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=ar(e.amount,o,i.bodyRadius,r),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:sr(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 ur(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 dr(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 hr(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 pr(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)||zo(e.id,t.id));const i=ur(o.length,hr(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>n.set(e.id,i[t]))}return n}function fr(e,t,i={}){const n=Object.values(e.products).sort((e,t)=>zo(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>zo(e.id,t.id)),r=[...o.map(e=>e.amount),...n.map(e=>e.amount)],s=cr(i.radiusRange,t),a=pr(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*ar(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=dr(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=ur(i.length,hr(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=ir(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=ar(e.amount,r,i.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:sr(e.id),x:n.x,y:n.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:c}}),...c]}function yr(e){return Array.isArray(e)?e.map(yr):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>zo(e,t)).map(([e,t])=>[e,yr(t)])):e}function gr(e,t){const i=Wo(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-eA,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 mr(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Wo(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,Wo(t.progress??0)??0));return i.start+i.duration*n}function xr(e,t=e.duration){const i=gr(e,t);let n=yo(e.initialState);const o=[],r=[],s=[];for(const t of e.events){if(t.authoredAt>i.elapsed+eA)break;const a=Eo(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 br(e){const t=Vo(e.phases),i=t.phases.at(-1)?.end??0,n=Zo(e.outlets??Qk),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?ho(e.metrics):void 0})),r=Uo(e.events??[],t.phases,i),s=Go(e),a=Qo(e.size??Zk,n),c=tr(a),l=Ko(o,n),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>zo(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(yr(d)));var d;const h=lr(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:rr(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:p},y=xr(f),g=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Do("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=tA(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...p,...y.diagnostics,...m],f}function vr(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function wr(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function kr(e,t){let i=2166136261;const n=wr(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 Ar(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
+ function e(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 t(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 i(...e){let t;for(const i of e)i&&(t=n(t)&&n(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function n(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function o(e){return"object"==typeof e&&null!==e&&"gradient"in e}function r(e){return"string"==typeof e&&e.length>0}function s(e,t,i=!1){const n=i?t?Vv:Gv:t?Xv:0;return n>e.top?{...e,top:n}:e}function a(e,t){return s(e,r(t))}function c(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 l(e){return Math.ceil(7*e.length)}function u(e,i){if(n(e)){const t=w(i);let n=Jv;for(const i of e.legendGroups){i.label&&(n=Math.max(n,l(i.label)));for(const e of i.items)n=Math.max(n,t.swatchSize+t.labelGap+l(e.label))}return n}if(o(e)){const{gradient:i}=e,n=i.format||t(i.domain),o=Math.max(l(n(i.domain[0])),l(n(i.domain[1]))),r=i.label?l(i.label):0;return Math.max(Jv,19+o,r)}return Jv}function d(e){return(n(e)||o(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):ew}function h(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?uw:lw:0}function p(e){return Math.max(0,e?.edgeGutter??tw)}function f(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?cw:aw:sw:0}function y(t){const{bottomAxis:i,topAxis:n,leftAxis:o,rightAxis:r}=e(t.axes),s=!(n&&!i||!1===i?.visible),a=!!n&&!i&&!1!==n.visible,c=!(r&&!o||!1===o?.visible),l=!!r&&!1!==r.visible,u=!1!==t.showAxes;return{hasAxis:u&&s,hasAxisLabel:u&&s&&!!(i?.label??t.xLabel),rotatedTicks:u&&s&&(t.rotatedTicks??!!i?.autoRotate),topAxis:a?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??t.xLabel),rotatedTicks:u&&(t.rotatedTicks??!!n?.autoRotate)}:void 0,leftAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??t.yLabel)}:void 0,rightAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??t.yLabelRight??t.yLabel)}:void 0}}function g(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 m(e,t,i){if(o(e))return e.gradient.label?ow:rw;if(!n(e))return 20;const r=w(i),s=Math.max(1,i?.maxWidth??t);let a=r.rowHeight;for(const t of e.legendGroups){let e=0,i=0;for(const n of t.items){const t=r.swatchSize+r.labelGap+l(n.label),o=0===i?t:i+r.itemGap+t;i>0&&o>s?(e+=1,i=t):i=o}t.items.length>0&&(e+=1),a=Math.max(a,e*r.rowHeight,t.label?l(t.label):0)}return a+(e.legendGroups.length>1?16:0)}function x(e,t,i){return u(e,t)+d(e)+h(t,i)+p(t)}function b(e,t){const{legend:i}=t;if(!i)return;const n=t.position??"right",o=m(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+d(i)+f("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?Vv:Gv:0);"right"===n?e.right=Math.max(e.right,r,x(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===n?e.left=Math.max(e.left,r,x(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 v(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??u(e,t.legendLayout)),s=d(e),a=h(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),c=p(t.legendLayout),l=m(e,o,t.legendLayout),y=f(t.axisChrome,t.legendLayout),g=f(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-g-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+y+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 w(e){const t=Math.max(1,e?.swatchSize??Uv),i=Math.max(t,e?.rowHeight??Qv);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??Kv),itemGap:Math.max(0,e?.itemGap??Zv),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function k(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 A(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 S(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(dw,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:n}}function M(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\t/g,"&#9;").replace(/\n/g,"&#10;").replace(/\r/g,"&#13;")}function _(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 $(e,t){for(const i of e.attributes.matchAll(dw))if(i[1]===t)return _(i[2]??i[3])}function P(e,t){const i=S(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(dw,(e,i,n,o)=>{const r=t(i,_(n??o));return void 0===r?e:` ${i}="${M(r)}"`}):e)}function j(e,t){const i=S(e);if(!i)return e;const n=new Map(Object.entries(t));let o=i.attributes.replace(dw,(e,t)=>{const i=n.get(t);return void 0===i?e:(n.delete(t),` ${t}="${M(i)}"`)});for(const[e,t]of n)o+=` ${e}="${M(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}function I(e,t){const i=S(e);if(!i)return t;const n=e=>{const n=$(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 L(e,t){const i=S(e);return i?j(e,{width:"100%",height:"100%",...void 0===$(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===$(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function R(e){return null==e?"null":Array.isArray(e)?`[${e.map(R).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)}:${R(t)}`).join(",")}}`:JSON.stringify(e)}function C(e){const t=[...fw],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=hw(i[e-15],7)^hw(i[e-15],18)^i[e-15]>>>3,n=hw(i[e-2],17)^hw(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+(hw(c,6)^hw(c,11)^hw(c,25))+(c&l^~c&u)+yw[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+((hw(n,2)^hw(n,13)^hw(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 T(e,t){return`${e}[Symbol(${t.description??""})]`}function O(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 E(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function F(e){return e.sort((e,t)=>{const i=JSON.stringify(e),n=JSON.stringify(t);return n>i?-1:i>n?1:0})}function N(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&&O(n,e.length)||i.excluded.push("symbol"==typeof n?T(t,n):E(t,n));return Array.from({length:e.length},(n,o)=>{const r=E(t,o),s=Object.getOwnPropertyDescriptor(e,o+"");if(!s||!("value"in s)||!s.enumerable)return i.excluded.push(r),null;const a=N(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(T(t,n));continue}const o=Object.getOwnPropertyDescriptor(e,n);o&&"value"in o&&o.enumerable?r.push(n):i.excluded.push(E(t,n))}for(const o of r.sort()){const r=Object.getOwnPropertyDescriptor(e,o),s=N(r&&"value"in r?r.value:void 0,E(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 z(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,z(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"]}),F(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&O(t,e.length))).map(i))];const n=Object.getPrototypeOf(e);return[n!==Object.prototype&&null!==n?"non-json-object":"object",F(Reflect.ownKeys(e).map(i))]}finally{t.delete(e)}default:return["excluded"]}}function D(e){const t={excluded:[],ancestors:/* @__PURE__ */new Set},i=N(e,"$",t)??null;return{value:i,text:JSON.stringify(i),excludedPaths:t.excluded}}function B(e){const t=D(e),i=C(JSON.stringify(["semiotic-value-fingerprint","v2",z(e)]));return{...t,algorithm:"sha256",digest:i,fingerprint:"sha256:"+i}}function W(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function Y(e,t){return`${e}[Symbol(${t.description??""})]`}function q(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 X(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function G(e,t,i,n){const o=X(e,t);return o&&"value"in o&&o.enumerable?V(o.value,i,n):[i]}function V(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=X(e,"length")?.value;if(!Number.isSafeInteger(n)||0>n)return[W(t,"length")];for(const e of o)"length"===e||"string"==typeof e&&q(e,n)||s.push("symbol"==typeof e?Y(t,e):W(t,e));for(let o=0;n>o;o+=1)s.push(...G(e,o+"",W(t,o),i))}else for(const n of o)"symbol"!=typeof n?s.push(...G(e,n,W(t,n),i)):s.push(Y(t,n));return s}catch{return[t]}finally{i.delete(e)}}function H(e,t,i,n){te(e,Object.keys(t),i,n);for(const[o,r]of Object.entries(t))r.values?(r.required||void 0!==e[o])&&ne(e,o,i,r.values,n):r.required?ie(e,o,i,n):ce(e,o,i,n)}function U(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function K(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 Z(e,t,i,n){void 0!==e[t]&&"boolean"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a boolean."})}function Q(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(Q):U(e)&&Object.values(e).every(Q))}function J(e,t,i,n){void 0===e[t]||U(e[t])&&Q(e[t])||n.push({path:`${i}.${t}`,message:"Expected a JSON object."})}function ee(e){return e.every(Q)}function te(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 ie(e,t,i,n){"string"==typeof e[t]&&e[t]||n.push({path:`${i}.${t}`,message:"Expected a non-empty string."})}function ne(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 oe(e,t,i,n){const o=e[t];if(void 0!==o){if(U(o))return o;n.push({path:`${i}.${t}`,message:"Expected an object."})}}function re(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 se(e,t,i){e?.some(e=>"string"!=typeof e||!e)&&i.push({path:t,message:"Expected non-empty string values."})}function ae(e,t,i,n,o){void 0!==e[t]&&ne(e,t,i,n,o)}function ce(e,t,i,n){void 0!==e[t]&&"string"!=typeof e[t]&&n.push({path:`${i}.${t}`,message:"Expected a string."})}function le(e,t,i){U(e)?(te(e,["id","name","kind"],t,i),ie(e,"kind",t,i),ce(e,"id",t,i),ce(e,"name",t,i)):i.push({path:t,message:"Expected an actor object."})}function ue(e,t){const i=oe(e,"reception","$",t);if(!i)return;te(i,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);const n=re(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}]`;U(e)?(te(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],n,t),ne(e,"channel",n,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),ae(e,"disclosure",n,["summary","standard","detailed"],t),ae(e,"rawData",n,["deny","bounded","allow"],t),Z(e,"navigation",n,t),Z(e,"interactionInstructions",n,t),K(e,"tokenBudget",n,t),se(re(e,"privacyNotes",n,t),n+".privacyNotes",t)):t.push({path:n,message:"Expected a channel object."})});for(const e of["strengths","risks","scaffolds","manualChecks"])se(re(i,e,"$.reception",t),"$.reception."+e,t);ce(i,"audience","$.reception",t),ce(i,"description","$.reception",t),Z(i,"dataFallback","$.reception",t)}function de(e,t){const i=oe(e,"form","$",t);i&&(te(i,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),ce(i,"chartFamily","$.form",t),ce(i,"whyThisForm","$.form",t),se(re(i,"risks","$.form",t),"$.form.risks",t),se(re(i,"misuse","$.form",t),"$.form.misuse",t),re(i,"rejectedAlternatives","$.form",t)?.forEach((e,i)=>{const n=`$.form.rejectedAlternatives[${i}]`;U(e)?(te(e,["representation","reason"],n,t),ie(e,"representation",n,t),ie(e,"reason",n,t)):t.push({path:n,message:"Expected an alternative object."})}))}function he(e,t){const i=oe(e,"contestability","$",t);i&&(te(i,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),Z(i,"sourceRequestsAllowed","$.contestability",t),re(i,"challenges","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.challenges[${i}]`;if(U(e)){te(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],n,t),ie(e,"id",n,t),ie(e,"claimId",n,t),ie(e,"reason",n,t),ne(e,"status",n,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&le(e.raisedBy,n+".raisedBy",t);for(const i of["raisedAt","counterclaimId","resolution"])ce(e,i,n,t)}else t.push({path:n,message:"Expected a challenge object."})}),re(i,"corrections","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.corrections[${i}]`;if(!U(e))return void t.push({path:n,message:"Expected a correction object."});te(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],n,t),ie(e,"id",n,t),ie(e,"reason",n,t);const o=re(e,"affectedClaimIds",n,t);o||t.push({path:n+".affectedClaimIds",message:"Expected an affected-claim array."}),se(o,n+".affectedClaimIds",t),se(re(e,"replacementClaimIds",n,t),n+".replacementClaimIds",t),ce(e,"createdAt",n,t),void 0!==e.createdBy&&le(e.createdBy,n+".createdBy",t)}),re(i,"alternativeViews","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.alternativeViews[${i}]`;U(e)?(te(e,["id","label","rationale"],n,t),ie(e,"id",n,t),ie(e,"label",n,t),ce(e,"rationale",n,t)):t.push({path:n,message:"Expected an alternative-view object."})}),re(i,"editorialExceptions","$.contestability",t)?.forEach((e,i)=>{const n=`$.contestability.editorialExceptions[${i}]`;U(e)?(te(e,["ruleId","rationale","owner","reviewAt"],n,t),ie(e,"ruleId",n,t),ie(e,"rationale",n,t),ce(e,"owner",n,t),ce(e,"reviewAt",n,t)):t.push({path:n,message:"Expected an editorial-exception object."})}))}function pe(e,t){const i=oe(e,"accountability","$",t);i&&(te(i,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),re(i,"authors","$.accountability",t)?.forEach((e,i)=>le(e,`$.accountability.authors[${i}]`,t)),se(re(i,"dataSources","$.accountability",t),"$.accountability.dataSources",t),ce(i,"generatedBy","$.accountability",t),ce(i,"codeRef","$.accountability",t),re(i,"reviews","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.reviews[${i}]`;if(U(e)){te(e,["id","status","reviewer","reviewedAt","rationale","policyId"],n,t),ie(e,"id",n,t),ne(e,"status",n,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&le(e.reviewer,n+".reviewer",t);for(const i of["reviewedAt","rationale","policyId"])ce(e,i,n,t)}else t.push({path:n,message:"Expected a review object."})}),re(i,"actions","$.accountability",t)?.forEach((e,i)=>{const n=`$.accountability.actions[${i}]`;if(!U(e))return void t.push({path:n,message:"Expected an action object."});te(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],n,t),ie(e,"id",n,t),ie(e,"action",n,t);const o=re(e,"claimIds",n,t);o||t.push({path:n+".claimIds",message:"Expected a claim identifier array."}),se(o,n+".claimIds",t),void 0!==e.actor&&le(e.actor,n+".actor",t);for(const i of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])ce(e,i,n,t);ae(e,"status",n,["proposed","taken","reversed","invalidated"],t)}))}function fe(e,t){const i=oe(e,"inheritance","$",t);if(i){te(i,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(const e of["requiredPaths","prohibitedExports","sourceArtifactIds"])se(re(i,e,"$.inheritance",t),"$.inheritance."+e,t);ae(i,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),ae(i,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),ae(i,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}function ye(e,t){ue(e,t),de(e,t),he(e,t),pe(e,t),fe(e,t)}function ge(e){for(const t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function me(e,t){if(void 0===e||U(e)){if(U(e))for(const[i,n]of Object.entries(e)){const e="$.fieldStatus."+i;if(!U(n)||"string"!=typeof n.status){t.push({path:e,message:"Expected a field state with a status."});continue}te(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."}),ce(n,"reason",e,t),ce(n,"reviewedBy",e,t),Z(n,"derived",e,t);const o=Object.prototype.hasOwnProperty.call(mw,i)?mw[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 xe(e,t){const i="$.time";te(e,[...vw,...Object.keys(ww),"sources"],i,t);for(const n of vw)ce(e,n,i,t);for(const[n,o]of Object.entries(ww)){const r=oe(e,n,i,t);r&&H(r,o,`${i}.${n}`,t)}re(e,"sources",i,t)?.forEach((e,n)=>{const o=`${i}.sources[${n}]`;U(e)?H(e,kw,o,t):t.push({path:o,message:"Expected a source object."})})}function be(e){try{return ve(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function ve(e){const t=[],i=[];if(!U(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:i};const n=V(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(te(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),e.contractVersion!==gw&&t.push({path:"$.contractVersion",message:`Expected contract version ${gw}.`}),U(e.artifact)){te(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),ie(e.artifact,"id","$.artifact",t),ne(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(const i of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])ce(e.artifact,i,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(U(e.purpose))if(Array.isArray(e.purpose.intents)){te(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,i)=>{U(e)&&"string"==typeof e.id&&e.id||t.push({path:`$.purpose.intents[${i}].id`,message:"Expected a non-empty intent identifier."}),U(e)&&te(e,["id","strength","source","rationale"],`$.purpose.intents[${i}]`,t),U(e)&&void 0!==e.strength&&ne(e,"strength",`$.purpose.intents[${i}]`,["primary","secondary"],t),U(e)&&(ae(e,"source",`$.purpose.intents[${i}]`,["author","derived","model-proposal","import"],t),ce(e,"rationale",`$.purpose.intents[${i}]`,t))});for(const i of["allowedUses","prohibitedUses"])se(re(e.purpose,i,"$.purpose",t),"$.purpose."+i,t);ae(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),ce(e.purpose,"communicativeAct","$.purpose",t),ce(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(!U(e))return void t.push({path:`$.claims[${i}]`,message:"Expected a claim object."});te(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${i}]`,t),ie(e,"id",`$.claims[${i}]`,t),ne(e,"kind",`$.claims[${i}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),ne(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."}),se(re(e,"supersedes",`$.claims[${i}]`,t),`$.claims[${i}].supersedes`,t),ce(e,"text",`$.claims[${i}]`,t),ce(e,"asOf",`$.claims[${i}]`,t),J(e,"scope",`$.claims[${i}]`,t),se(re(e,"tags",`$.claims[${i}]`,t),`$.claims[${i}].tags`,t),void 0!==e.authoredBy&&le(e.authoredBy,`$.claims[${i}].authoredBy`,t);const n=oe(e,"review",`$.claims[${i}]`,t);n&&(te(n,["status","reviewer","reviewedAt","rationale"],`$.claims[${i}].review`,t),ne(n,"status",`$.claims[${i}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==n.reviewer&&le(n.reviewer,`$.claims[${i}].review.reviewer`,t),ce(n,"reviewedAt",`$.claims[${i}].review`,t),ce(n,"rationale",`$.claims[${i}].review`,t));const o=oe(e,"uncertainty",`$.claims[${i}]`,t);if(o){te(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${i}].uncertainty`,t),ne(o,"kind",`$.claims[${i}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(const e of["lower","upper","confidence"])K(o,e,`$.claims[${i}].uncertainty`,t);ce(o,"unit",`$.claims[${i}].uncertainty`,t),ce(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(!U(e))return void t.push({path:`$.evidence[${i}]`,message:"Expected an evidence object."});te(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${i}]`,t),ie(e,"id",`$.evidence[${i}]`,t),ne(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"])ce(e,n,`$.evidence[${i}]`,t);J(e,"scope",`$.evidence[${i}]`,t);const n=oe(e,"source",`$.evidence[${i}]`,t);if(n){te(n,["name","uri","version","retrievedAt","publisher"],`$.evidence[${i}].source`,t);for(const e of["name","uri","version","retrievedAt","publisher"])ce(n,e,`$.evidence[${i}].source`,t)}const o=oe(e,"transformation",`$.evidence[${i}]`,t);if(o){te(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${i}].transformation`,t),ie(o,"id",`$.evidence[${i}].transformation`,t),ne(o,"kind",`$.evidence[${i}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);const e=re(o,"inputEvidenceIds",`$.evidence[${i}].transformation`,t);e?se(e,`$.evidence[${i}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${i}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),se(re(o,"assumptions",`$.evidence[${i}].transformation`,t),`$.evidence[${i}].transformation.assumptions`,t),ce(o,"description",`$.evidence[${i}].transformation`,t),ce(o,"implementation",`$.evidence[${i}].transformation`,t),ce(o,"performedAt",`$.evidence[${i}].transformation`,t),J(o,"parameters",`$.evidence[${i}].transformation`,t),void 0!==o.performedBy&&le(o.performedBy,`$.evidence[${i}].transformation.performedBy`,t)}const r=oe(e,"sample",`$.evidence[${i}]`,t);if(r){te(r,["rowCount","fields","values","truncated"],`$.evidence[${i}].sample`,t),se(re(r,"fields",`$.evidence[${i}].sample`,t),`$.evidence[${i}].sample.fields`,t);const e=re(r,"values",`$.evidence[${i}].sample`,t);e&&!ee(e)&&t.push({path:`$.evidence[${i}].sample.values`,message:"Expected JSON values."}),K(r,"rowCount",`$.evidence[${i}].sample`,t),Z(r,"truncated",`$.evidence[${i}].sample`,t)}ae(e,"relationship",`$.evidence[${i}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),me(e.fieldStatus,t);const o=oe(e,"time","$",t);return o&&xe(o,t),ye(e,t),J(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 we(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ke(e,t){if(!t||!we(e)||!Array.isArray(e.evidence))return[];const i=[];return e.evidence.forEach((e,t)=>{we(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,i.push(`$.evidence[${t}].sample`))}),i}function Ae(e,t={}){try{return Se(e,t)}catch{const t=V(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}function Se(e,t){if(!we(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};const i=D(e),n=[.../* @__PURE__ */new Set([...i.excludedPaths,...V(e)])].sort(),o=i.value,r=ke(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!==gw)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=be(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 Me(e,t){return Aw.has(e)&&!("reading"===e&&"string"==typeof t)}function _e(e){const t=Object.entries(e).filter(([e,t])=>Me(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}function $e(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 B(i.length>0?{data:e,transformations:i}:e).fingerprint}function Pe(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!Me(e,t)&&"recipeId"!==e))}function je(e,t,i,n=_e(t)){const o=Pe(t),r=0===V(o).length?B(o).fingerprint:void 0,s=void 0!==n&&0===V(n).length?$e(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 Ie(e,t){return C(R({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 Le(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Re(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}function Ce(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}function Te(e,t){const{when:i}=e,n=t.width,o=t.height,r=Ce(t),s=Re(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 Oe(e,t){const i={...e,...t};for(const n of["margin","frameProps","mobileSemantics","style"])Le(e[n])&&Le(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 Ee(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=>Te(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)=>Oe(e,t.rule.transform),e),matches:n}}function Fe(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 _w;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??n??Sw,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??Sw,standardControls:a.standardControls??!1}}function Ne(e,t,i){const n=$w[e||"primary"],o=e&&"primary"!==e||!i?.width?n.width:i.width,r=e&&"primary"!==e||!i?.height?n.height:i.height,s=Ee({...t,mode:e},{width:t.width??o,height:t.height??r}).props,a=s.mode||e||"primary",c=$w[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:ze(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:Fe(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function ze(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 De(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Be(e,t,i,n){const o=e??t;return"function"==typeof o?o(i,n):i[o+""]}function We(e){const t=/* @__PURE__ */new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,n)=>{if(!Number.isFinite(Number(Be(e.yAccessor,"y",i,n))))return;const o=De(Be(e.xAccessor,"x",i,n)),r=t.get(o)??/* @__PURE__ */new Set;r.add(Be(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 Ye(e){return Lw.has(e)}function qe(e){return Lw.get(e)}function Xe(e){return Ye(e)?qe(e):"BumpChart"===e?Pw:void 0}function Ge(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 Ve(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;const n=Xe(t);if(!n)return;let o;try{const t="function"==typeof n?n(i,e):We(i);o=Array.from(t).filter(Ge)}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 He(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 Ue(e){return`${e.getUTCFullYear()}-${Ke(e.getUTCMonth()+1)}-${Ke(e.getUTCDate())}`}function Ke(e){return 10>e?"0"+e:e+""}function Ze(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 Qe(e,t={}){const i=t.baseOpacity??1;return t.highlight||t.predicate?!Ze(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function Je(e){if(0===e.length)return 0;let t=0;for(const i of e)t+=i;return t/e.length}function et(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,Nw.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 tt(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>ot(t(e))}function it(e,t){const i=tt(e),n=tt(t);return(e,t)=>{const o=n(e);return{value:o,x:i(e),y:o,category:t}}}function nt(e,t){const i=tt(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 ot(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 rt(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=ot(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 st(e,t,i){const n=e.when;return void 0===n||!0===n||!1!==n&&("function"==typeof n?n(t,i):rt(n,t,i))}function at(e,t,i){if(!t||0===t.length)return{};let n={};for(const o of t){if(!st(o,e,i))continue;const t="function"==typeof o.style?o.style(e,i):o.style;t&&(n={...n,...t})}return n}function ct(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,at(s,t,i(s,r))),a}:o}function lt(e,t,i,n){if(!e||0===e.length)return n;const o=nt(t,i);return(t,i)=>{const r=t&&t.data||t,s=at(r,e,o(r)),a=n?n(t,i):void 0;return a?{...s,...a}:s}}function ut(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 dt(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 ht(e,t="#4e79a7",i){const n=i?.styleRules,o=!!n&&n.length>0,r=o?tt(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:dt(a),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&s&&Object.assign(c,at(s,n,{value:r?r(s):void 0,category:null==a?void 0:a+""})),c}}function pt(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 ft(e,t,i){return"function"==typeof i?i(e,t):e[i]}function yt(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 gt(e,t,i){return Math.max(t,Math.min(i,e))}function mt(e,t){const i=yt(e);return null!=i&&i>0?i:t}function xt(e){if(!e)return;const t=yt(e[0]),i=yt(e[1]);return null!=t&&null!=i?t>i?[i,t]:[t,i]:void 0}function bt(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function vt(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 wt(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=gt(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),r=vt(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 kt(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 At(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 St(e,t=1/0){let i=t;for(const t of e)i>t&&(i=t);return i}function Mt(e,t=-1/0){let i=t;for(const t of e)t>i&&(i=t);return i}function _t(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 Pt(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 jt(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 It(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Lt(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 Rt(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:Pt(e.fixedPosition)}:{},shape:It(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Ct(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 Tt(e){return{id:e.id,shape:Lt(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Ct(e.bodyFilter),index:e.index}}function Ot(e,t,i){return Math.max(t,Math.min(i,e))}function Et(e,t,i){return Math.min(e??i,t??i)}function Ft(e,t,i){return Ot(Math.max(e??i,t??i),0,1)}function Nt(e){return 0>e?-1:1}function zt(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 Dt(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 Bt(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Wt(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(Hw>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}function Yt(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:Nt(c),ny:0,penetration:l}:{nx:0,ny:Nt(u),penetration:d}:null}function qt(e,t,i,n,o,r,s){const a=r/2,c=s/2,l=e-Ot(e,n-a,n+a),u=t-Ot(t,o-c,o+c),d=l*l+u*u;if(d>i*i)return null;if(Hw>=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 Xt(e,t,i,n,o,r,s,a=0){const c=r-n,l=s-o,u=c*c+l*l,d=u>Hw?Ot(((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(Hw>=y){const e=Math.sqrt(u);return e>Hw?{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 Gt(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return Wt(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Yt(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=qt(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?qt(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Vt(e,t){const i=t.shape;return"aabb"===i.type?"circle"===e.shape.type?qt(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):Yt(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height):Xt(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 Ht(e,t){return`${e}\0${t}`}function Ut(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Kt(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 Zt(e,t){return!!t?.some(t=>Object.is(e,t))}function Qt(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const i=Kt(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!Zt(i,t.oneOf)||t.notOneOf&&Zt(i,t.notOneOf))}function Jt(e,t){return Qt(t,e.bodyFilter)}function ei(e={}){return new Zw(e)}function ti(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):ei(t)}function ii(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 ni(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 oi(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 ri(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function si(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?ri(t,e):void 0}function ai(e,t,i){if("number"==typeof e)return e;const n="function"==typeof e?e(t,i):"string"==typeof e?ri(t,e):1,o="number"==typeof n?n:Number(n);return Number.isFinite(o)?o:1}function ci(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function li(e){for(const t of Qw){const i=ci(ri(e,t));if(i)return i}return"sediment"}function ui(e){const t=ni(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:ni(e.x),y:ni(e.y),value:t}}function di(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 hi(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}function pi(e,t,i){if(!1===i)return;const n=hi(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 fi(e){const t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),n=t+i,o=hi(e.bodyLimit),r=hi(e.engineMaxBodiesHint),s=pi(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 yi(e={},t=tk){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 gi(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function mi(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 xi(e,t){if(null!=e[t])return e[t];const i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function bi(e,t,i){return"function"==typeof i?mi(i(e,t)):"string"==typeof i?mi(xi(e,i)):mi(e.spawnAt)??mi(xi(e,"arrivalTime"))??mi(xi(e,"timestamp"))??mi(xi(e,"time"))??mi(xi(e,"eventTime"))}function vi(e,t={}){const i=mi(t.startAt)??0,n=t.pacing??"immediate";if("arrival"===n){let n=1/0;const o=e.map((e,i)=>{const o=bi(e,i,t.timeAccessor);return null!=o&&(n=Math.min(n,o)),o}),r=mi(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{...gi(e),spawnAt:i+a/s}})}if("object"==typeof n){const t=mi(n.ratePerSec);if(t&&t>0)return e.map((e,n)=>({...gi(e),spawnAt:i+n/t}))}return e.map(e=>({...gi(e),spawnAt:i}))}function wi(e){return{...gi(e),sequence:e.sequence,spawnAt:e.spawnAt}}function ki(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 Ai(e){return!1!==e&&{...e}}function Si(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Mi(e){return{...e,gravity:{...e.gravity}}}function _i(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 Pi(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function ji(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 Ii(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 Li(e,t){const i={...e};for(const e of t)i[ik[e]]++;return i}function Ri(e,t,i){const n=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:n,revisions:Li(i,n)}}function Ci(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=pk[n]??fk;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Ti(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&yk.every(i=>e[i]===t[i])}function Oi(e,t){return Object.keys(e).filter(i=>"kernel"===i?!Ti(e.kernel,t.kernel):e[i]!==t[i])}function Ei(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 Fi(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}=Pi(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 Ni(e,t){for(const i of e)t.has(Pi(i).bodyId)&&e.delete(i)}function zi(e,t,i,n){return e||!t?"paused":i||!n?"running":"settled"}function Di(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 Bi(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 Wi(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 Yi(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 qi(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=Wi(e,i,o).slice(0,c);if(0===l.length)return s;const u=Yi(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 Xi(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}function Gi(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 Vi(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 Hi(e){const{data:t,valueAccessor:i,bins:n,ballRadius:o,seed:r,size:s,valueExtent:a}=e,{rows:c}=kt(t,"galton"),l=ut(s),u=c.map((e,t)=>yt(ft(e,t,i))).filter(e=>null!=e),d=xt(a),[h,p]=d??(u.length?At(u):[0,1]),f=p===h?1:p-h,y=(0,Gw.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=yt(ft(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:pt(r,[...ji({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Ii({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 Ui(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}=kt(e.data,"event"),r=o.flatMap((t,i)=>{const n=yt(ft(t,i,e.timeAccessor));return null==n?[]:[{datum:t,index:i,eventTime:n,arrivalTime:yt(ft(t,i,e.arrivalAccessor))??n,watermarkAtArrival:0,late:!1}]}),s="function"==typeof i?null:yt(i?.value),a="function"==typeof i?t:yt(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?yt(i(c)):c-a;l=s??Math.max(l,o??c-t);const r=n?yt(ft(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 Ki(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 Zi(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,xk.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 Qi(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 Ji(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}=Ui({data:t,timeAccessor:i,arrivalAccessor:n,watermark:r,watermarkAtArrivalAccessor:s,windowSize:o.size}),f=ut(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=yt(u?.[0]),b=yt(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=Ki(f,a),M=k+A*o.size,_=(0,xk.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:tn(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=Zi(L,f.plot.y+.28*f.plot.height);for(const e of j){const t=e.datum;e.y=en({...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=Qi({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:pt(c,[...ji({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 en(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 tn(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 nn(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=mt(e.unitValue,1),r=vt(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 on(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 rn(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 sn(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=mt(r,1),{rows:u}=kt(i,"pile"),d=ut(c),h=[],p=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map,y=[];u.forEach((e,i)=>{t((ft(e,i,n)??"unknown")+"")});const g=Math.max(1,h.length),m=rn(d.plot,g,s),x=Math.max(0,m.tubeWidth/2-s-1),b=h.map(()=>[]);u.forEach((e,i)=>{const r=(ft(e,i,n)??"unknown")+"",a=t(r),c=o?yt(ft(e,i,o)):1,u=Math.max(0,c??0);f.set(r,(f.get(r)??0)+u);const h=on(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=[...ji({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:pt(a,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:f.get(e)??0}))}}function an(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 cn(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}=kt(i,"collision-swarm"),p=ut(c),f=vt(a),y=[],g=[],m=/* @__PURE__ */new Map;h.forEach((e,i)=>{const a=yt(ft(e,i,n));if(null==a)return;const c=o?(ft(e,i,o)??"All")+"":"All",l=r?yt(ft(e,i,r)):null,u=gt(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?yt(l[0]):null,b=l?yt(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,bk.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=an(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:pt(a,ji({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 ln(e){if(Array.isArray(e)&&e.length>=2){const t=yt(e[0]),i=yt(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){const t=e,i=yt(t.x),n=yt(t.y);return null!=i&&null!=n?{x:i,y:n}:null}return null}function un(e){return Array.isArray(e)?e.map(ln).filter(e=>null!=e):[]}function dn(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:gt(e.x,t.plot.x,t.plot.x+t.plot.width),y:gt(e.y,t.plot.y,t.plot.y+t.plot.height)}}function hn(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 pn(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const i=gt(t,0,1)*hn(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 fn(e,t){const i=pn(e,Math.max(0,t-.02)),n=pn(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 yn(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=ut(g),w=vt(y),k=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=[];l.forEach((e,t)=>{const i=(ft(e,t,s)??e.id??t)+"",n=yt(ft(e,t,a)),o=yt(ft(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(ft(e,i,m)),o=t(ft(e,i,x)),r=Math.max(0,yt(ft(e,i,b))??0),s=un(h?ft(e,i,h):void 0),a=s.length?s:un(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,dn(t,v,_));const I=[];for(const e of M){let t=e.rawPath.map(e=>dn(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=mt(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=mt(n,90),B=mt(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=hn(e.path);for(let n=0;e.packetCount>n;n+=1){const o=(n+.5)/e.packetCount,r=f?o:gt(.12+.84*o+.04*(w()-.5),.04,.98),s=f?r:Math.max(0,r-(.18+.12*w())),a=pn(e.path,s),c=pn(e.path,r),l=fn(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-"+bt(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=pt(y,[...ji({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-"+bt(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 gn(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 mn(e,t,i){return Math.max(t,Math.min(i,e))}function xn(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function bn(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 vn(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=mn(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,y=mn(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=mn(e.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=xn(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=mn((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=mn((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=mn((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(bn(b+"-top",s,c,a,c,T),bn(b+"-bottom",s,l,a,l,T),bn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),bn(b+"-right",a,c,a,l,{...T,thickness:Math.max(6,k)})):"funnel"===t?O.push(bn(b+"-top",s,c,a,m,T),bn(b+"-bottom",s,l,a,x,T),bn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),bn(b+"-right",a,m,a,x,{...T,thickness:Math.max(6,k)})):O.push(bn(b+"-left-top",s,c,I,m,T),bn(b+"-left-bottom",s,l,I,x,T),bn(b+"-center-top",I,m,L,m,T),bn(b+"-center-bottom",I,x,L,x,T),bn(b+"-right-top",L,m,a,c,T),bn(b+"-right-bottom",L,x,a,l,T),bn(b+"-left",s,c,s,l,{...T,thickness:Math.max(6,k-2)}),bn(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+mn(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=>kn({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 wn(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 kn(e){const t=e.dampingScale??.5,i=e.energyScale??1,n=mn(e.cost,0,2);return{...wn({...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 An(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...wn({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Sn(e){const t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,n=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...wn({...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 Mn(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...wn({...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 _n(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...wn({...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{...wn({...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 Pn(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 jn(e){const t=e.idPrefix??"lane",i={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},n=[bn(t+"-top",e.left,e.top,e.right,e.top,i),bn(t+"-bottom",e.left,e.bottom,e.right,e.bottom,i)];return e.openEnds||n.push(bn(t+"-left",e.left,e.top,e.left,e.bottom,i),bn(t+"-right",e.right,e.top,e.right,e.bottom,i)),n}function In(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 Ln(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 _n({...i,kind:e.kind??"sink",force:In(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:In(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...wn({...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 Mn({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:In(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 Sn({...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:In(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?An({...i,kind:e.kind??"force-field",force:In(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 Rn(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=e.size,n=ut(i),o=gt(e.ballRadius??6,2,18),r=e.seed??1,s=vt(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=vn({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 Ln(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(An({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?ft(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",n=(ft(e,t,c)??w)+"",r=b.has(n)?n:w;M.set(r,(M.get(r)??0)+1);const s=l?(ft(e,t,l)??"")+"":void 0,p=s&&u?(ft(e,t,u)??s)+"":s,f=d?yt(ft(e,t,d))??1:1,y=h?yt(ft(e,t,h)):null,g=gt(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=gt(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 Pn({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=gn(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 Cn(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function Tn(e,t,i){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(i)}`}function On(e){const t=e.map(Cn),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){const[e,i,n]=t[0];return Tn(e,i,n)}if(e>=1){const[e,n,o]=t[i];return Tn(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 Tn(Math.round(s+(l-s)*r),Math.round(a+(u-a)*r),Math.round(c+(d-c)*r))}}function En(e){return e&&Object.prototype.hasOwnProperty.call(Ok,e)?Ok[e]:Ak}function Fn(e,t,i=qk){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(Yk,e)?Yk[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function Nn(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Hk.has(t)}function zn(e,t,i){if("function"==typeof t){const n=t(e);return i&&n&&"string"==typeof n&&!Nn(n)?i(n):n}const n=e?.[t]+"";return i?i(n):qk[Math.abs(Wn(n))%qk.length]}function Dn(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 Bn(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const e=i;return t=>Dn(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,wk.scaleOrdinal)().domain(n).range(i).unknown("#999");const r=Object.prototype.hasOwnProperty.call(Yk,i)?Yk[i]:Yk.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:qk;return(0,wk.scaleOrdinal)().domain(n).range(e).unknown("#999")}}function Wn(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 Yn(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 qn(e,t,i){return Fn(e,t,i)}function Xn(e,t){const i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Dn(i,e)||"#4e79a7":t=>{if(i){const e=Dn(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 Gn(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 Vn(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 Hn(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 Un(e){const t=Gn(e.config,e.chartId,e.onObservation),i=qn(e.colorScheme,e.themeCategorical,kk),n=ut(e.size),o={data:e.data,scales:{x:(0,vk.scaleLinear)().domain(e.xExtent??[0,1]).range([n.plot.x,n.plot.x+n.plot.width]),y:(0,vk.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:Xn(i,e.colorScheme),config:e.layoutConfig??{},world:new mk(t)},r=e.skipLayout?{}:e.layout(o)??{},s=Hn([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:Vn(t,r),context:o,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}function Kn(e){const t=to(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 Zn(e,t,i,n){return i?"function"==typeof i?i(e,t):e[i]??n:n}function Qn(e){return`gauntlet:${e}:core`}function Jn(e,t){return`gauntlet:${e}:positive:${t}`}function eo(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function to(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return Uk;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 io(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function no(e,t,i,n){const o=to(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 oo(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 ro(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 so(e,t,i,n){const o=ro(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 ao(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 co(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 lo(e,t,i,n,o){const r=Zn(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=n.map(e=>e.id),a=[...Zn(e,t,i.positiveAccessor,s)],c=[...Zn(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Zn(e,t,i.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Zn(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Zn(e,t,i.initialViability,100)}}function uo(e,t,i,n,o,r,s){const a=io(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:Qn(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=no(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=ao(e.activePositiveIds,t,a),s=n.radius??Math.max(2,10*a),c=no(g.x+Math.cos(r.angle)*r.radius,g.y+Math.sin(r.angle)*r.radius,s,i);y.push({id:Jn(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:Qn(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(po(e,o,n,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}function ho(e){const t=oo(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=lo(t,s,r,i,o);return{...a,viability:e.viability?.(a,{negativeProperties:o,positiveProperties:n})??co(a,n,o)}}),a=s.flatMap((i,r)=>{const s=so(i,r,t,e.projectPlacement);return uo(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:Kn(t)}}}function po(e,t,i,n,o,r,s){const a=io(r),c=t.radius??Math.max(2,7.2*a),l=no(n+(i%4*12-12)*a,o+(54+12*Math.floor(i/4))*a,c,r);return{id:eo(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:Qn(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*a),...t.spring??{}}]}}function fo(e=[]){const t=/* @__PURE__ */Object.create(null);for(const[i,n]of e)t[i]=n;return t}function yo(...e){const t=fo();for(const i of e)for(const[e,n]of Object.entries(i??{}))t[e]=n;return t}function go(e){return yo(e)}function mo(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 xo(e){const t=fo(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:go(t.initialMetrics),metrics:go(t.metrics),productIds:[...t.productIds],history:mo(t.history)}])),i=fo(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:go(t.metrics),sourceIds:[...t.sourceIds],history:mo(t.history)}])),n=fo(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?go(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:n,input:{amount:e.input.amount,metrics:go(e.input.metrics)},metrics:go(e.metrics),loss:{amount:e.loss.amount,metrics:go(e.loss.metrics)},history:mo(e.history)}}function bo(e,t){return t>e?-1:e>t?1:0}function vo(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function wo(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 ko(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[vo("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function Ao(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function So(e){const t=fo();for(const i of e)Ao(t,i.metrics);return t}function Mo(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(vo("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(vo("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(bo);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||n.push(vo("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:n}}function _o(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 Po(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(vo("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function jo(e,t,i){const n=wo(t);t.length||e.diagnostics.push(vo("error","empty-source-list","A product requires at least one source component.",i)),n.length&&e.diagnostics.push(vo("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(vo("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(vo("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(vo("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 Io(e,t,i){const n=wo(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(vo("error","insufficient-relation-sources","A relation requires at least two source components.",i)),n.length&&e.diagnostics.push(vo("error","duplicate-source",`Relation source ids must be unique: ${n.join(", ")}.`,i,n)),o.length&&e.diagnostics.push(vo("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 Lo(e,t,i,n,o){const r=n?.amount??0;(!Number.isFinite(r)||0>r||r>t+Kk)&&e.diagnostics.push(vo("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...ko(n?.metrics,o+".metrics"));for(const[t,r]of Object.entries(n?.metrics??{}))(0>r||r>Number(i[t]??0)+Kk)&&e.diagnostics.push(vo("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 Ro(e,t,i,n){if(!t?.length)return[];const o=wo(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(vo("error","duplicate-relation","Basis relations must be unique.",n,o)),r.length&&e.diagnostics.push(vo("error","unknown-relation",`Unknown basis relation: ${r.join(", ")}.`,n,r)),s.length&&e.diagnostics.push(vo("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,n,s)),c.length&&e.diagnostics.push(vo("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 Co(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 To(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 Oo(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?yo(n,e.metrics):go(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 Eo(e,t,i,n){void 0!==t.amount&&Math.abs(t.amount-i)>Kk&&e.diagnostics.push(vo("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,n,[t.id]))}function Fo(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(!Po(e,a,r+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(vo("error","product-already-complete",`Product "${t.id}" is already complete.`,r,[t.id]));s&&(Eo(e,s,t.amount,r+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics=yo(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=_o(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 No(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(vo("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,n+".state")),e.diagnostics.push(...ko(t.metricsDelta,n+".metricsDelta")),Po(e,t.outletId,n+".outletId");const i=Mo(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(vo("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=_o(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&&Ao(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(vo("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,n+".relation.id",[i.id]));const r=Io(e,i.sourceIds,n+".relation.sourceIds");if(e.diagnostics.push(...ko(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?go(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=_o(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=wo(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(vo("error","duplicate-relation","Relation ids must be unique.",n+".relationIds",i)),r.length&&e.diagnostics.push(vo("error","unknown-relation",`Unknown relation: ${r.join(", ")}.`,n+".relationIds",r)),s.length&&e.diagnostics.push(vo("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=_o(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(vo("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(vo("error","duplicate-product",`Product "${t.productId}" has already been formed.`,n+".productId",[t.productId])),"contribute"!==t.type||r&&"forming"===r.status||e.diagnostics.push(vo("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,n+".productId",[t.productId]));const s=jo(e,t.sourceIds,n+".sourceIds"),a="contribute"===t.type&&r?[...r.sourceIds,...t.sourceIds]:t.sourceIds,c=Ro(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=So(s);if(!Lo(e,l,u,t.loss,n+".loss"))return;const d=l-(t.loss?.amount??0);To(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,p=_o(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let f;if("combine"===t.type){if(h&&Eo(e,i,d,n+".productId"),f=Oo(i,t.sourceIds,d,u,e,h,p),h&&!Po(e,f.outletId,n+".productId"))return;o.products[t.productId]=f}else f=r,f.sourceIds.push(...t.sourceIds),f.amount+=d,Ao(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),Co(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 Fo(e,i,t.outletId,t.reason,t,n):void e.diagnostics.push(vo("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,n+".productId",[t.productId]))}if("split"===t.type){const i=jo(e,[t.sourceId],n+".sourceId");t.products.length||e.diagnostics.push(vo("error","empty-split","A split requires at least one product allocation.",n+".products"));const r=t.products.map(e=>e.productId),s=wo(r);s.length&&e.diagnostics.push(vo("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(vo("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,n+".products",c)),l.length&&e.diagnostics.push(vo("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(vo("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${n}.products.${i}.amount`)),e.diagnostics.push(...ko(o.metrics,`${n}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=i[0];if(!Lo(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(vo("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)>Kk)return void e.diagnostics.push(vo("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,n+".products"));const g=go(u.metrics);for(const[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;const m=_o(e,t,{sourceIds:[u.id],productIds:r});if(t.products.forEach((i,r)=>{const s=a[r],c=d>Kk?f[r]/d:1/t.products.length,l=fo(Object.entries(g).map(([e,t])=>[e,t*c])),h=i.metrics??s.metrics??l,p=Oo({...s,amount:f[r],metrics:h},[u.id],f[r],go(h),e,!0,m);Po(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){Po(e,t.outletId,n+".outletId");const i=Mo(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(vo("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=_o(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(...ko(t.metricsDelta,n+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,r;if("run"===t.target)Ao(o.metrics,t.metricsDelta);else if("components"in t.target){const r=Mo(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)Ao(o.components[e].metrics,t.metricsDelta)}else{r=[...t.target.productIds];const i=wo(r),s=r.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(vo("error","duplicate-product","Metric target product ids must be unique.",n+".target.productIds",i)),s.length&&e.diagnostics.push(vo("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)Ao(o.products[e].metrics,t.metricsDelta)}return void o.history.push(_o(e,t,{sourceIds:i,productIds:r}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(_o(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(vo("error","invalid-outcome","Outcome must be a non-empty string.",n+".outcome"))}function zo(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[vo("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const n=xo(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(No(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 Do(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}function Bo(e,t={}){const i=t.groupBy??"outlet",n=/* @__PURE__ */new Map,o=e=>{const t=Do({...e,status:e.status??"active"},i),o=n.get(t);if(o)return o.count+=1,o.amount+=e.amount,void Ao(o.metrics,e.metrics);n.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:go(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)||bo(e.key,t.key))}function Wo(e,t){return t>e?-1:e>t?1:0}function Yo(e,t,i,n,o){return{severity:e,code:t,message:i,path:n,ids:o?[...o]:void 0}}function qo(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 Xo(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Go(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(Yo("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,r)),n}}function Vo(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Yo("error","invalid-metrics","Metrics must be a numeric object.",i)),fo();const n=fo();for(const[o,r]of Object.entries(e)){const e=Xo(r);null!=e?n[o]=e:t.push(Yo("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return n}function Ho(e,t){for(const[i,n]of Object.entries(t))e[i]=Number(e[i]??0)+n}function Uo(e){const t=[],i=fo(),n=[];let o=0;const r=fo();e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((Go(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(Yo("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));n.push(l);const u=Xo(Go(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Yo("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=Vo(Go(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),p=Go(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),f=Jk.has(p)?p:"active";Jk.has(p)||t.push(Yo("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${a}.status`,[l]));const y=Go(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",g=Go(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:yo(h),metrics:yo(h),productIds:[],history:[]},o+=d,Ho(r,h))});const s=qo(n);s.length&&t.push(Yo("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=Vo(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:fo(),relations:fo(),input:{amount:o,metrics:r},metrics:a,loss:{amount:0,metrics:fo()},history:[]},diagnostics:t}}function Ko(e){const t=[];e.length||t.push(Yo("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const i=qo(e.map(e=>e.id));i.length&&t.push(Yo("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let n=0;return{phases:e.map((e,i)=>{const o=Xo(e.duration),r=null!=o&&o>0?o:0;e.id.trim()||t.push(Yo("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),null!=o&&o>0||t.push(Yo("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(Yo("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 Zo(e,t,i){const n=e.find(e=>eA>=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}:eA>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}function Qo(e,t,i){const n=[],o=qo(e.map(e=>e.id));o.length&&n.push(Yo("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(Yo("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){const r=Xo(e.at.time);if(null==r||0>r||r>i+eA)return void n.push(Yo("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=Zo(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(Yo("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(Yo("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(Yo("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 Jo(e,t){const i=[],n=new Set(t.map(e=>e.id)),o=qo(t.map(e=>e.id)),r=qo(e.map(e=>e.id));return o.length&&i.push(Yo("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),r.length&&i.push(Yo("error","duplicate-product-id",`Product ids must be unique: ${r.join(", ")}.`,"products",r)),t.forEach((e,t)=>{e.id.trim()||i.push(Yo("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||i.push(Yo("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Yo("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(Yo("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(Yo("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Vo(e.metrics??{},i,`products.${t}.metrics`)}),i}function er(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 tr(e=Zk,t=Qk){const i=Math.max(1,Xo(e[0])??900),n=Math.max(1,Xo(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=er(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 ir(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+eA).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[];let r=e;for(const[e,t]of n)e>r+eA&&o.push([r,e]),r=Math.max(r,t);return t>r+eA&&o.push([r,t]),o}function nr(e){const{id:t,orientation:i,fixed:n,start:o,end:r,openings:s,thickness:a,friction:c,restitution:l}=e,u=ir(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 or(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(...nr({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}),...nr({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}),...nr({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 rr(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 sr(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?rr(e):1}function ar(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 cr(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:sr(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function lr(e){return"crucible:component:"+encodeURIComponent(e)}function ur(e,t,i,n){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;const[o,r]=t;return r-o>eA?n[0]+(n[1]-n[0])*Math.sqrt(Math.max(0,e-o)/(r-o)):(n[0]+n[1])/2}function dr(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 hr(e,t,i={}){const n=Object.values(e.components).sort((e,t)=>Wo(e.id,t.id)),o=At(n.map(e=>e.amount)),r=dr(i.radiusRange,t),s=ar(sr(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=ur(e.amount,o,i.bodyRadius,r),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:lr(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 pr(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 fr(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 yr(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 gr(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)||Wo(e.id,t.id));const i=pr(o.length,yr(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>n.set(e.id,i[t]))}return n}function mr(e,t,i={}){const n=Object.values(e.products).sort((e,t)=>Wo(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>Wo(e.id,t.id)),r=At([...o.map(e=>e.amount),...n.map(e=>e.amount)]),s=dr(i.radiusRange,t),a=gr(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*ur(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=fr(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=pr(i.length,yr(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=rr(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=ur(e.amount,r,i.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:lr(e.id),x:n.x,y:n.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:c}}),...c]}function xr(e){return Array.isArray(e)?e.map(xr):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>Wo(e,t)).map(([e,t])=>[e,xr(t)])):e}function br(e,t){const i=Xo(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-eA,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 vr(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Xo(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,Xo(t.progress??0)??0));return i.start+i.duration*n}function wr(e,t=e.duration){const i=br(e,t);let n=xo(e.initialState);const o=[],r=[],s=[];for(const t of e.events){if(t.authoredAt>i.elapsed+eA)break;const a=zo(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 kr(e){const t=Ko(e.phases),i=t.phases.at(-1)?.end??0,n=er(e.outlets??Qk),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?yo(e.metrics):void 0})),r=Qo(e.events??[],t.phases,i),s=Uo(e),a=tr(e.size??Zk,n),c=or(a),l=Jo(o,n),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>Wo(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(xr(d)));var d;const h=hr(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:cr(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:p},y=wr(f),g=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Yo("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=tA(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...p,...y.diagnostics,...m],f}function Ar(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Sr(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Mr(e,t){let i=2166136261;const n=Sr(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 _r(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,nA.jsxs)("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&/* @__PURE__ */ /* @__PURE__ */(0,nA.jsx)("rect",{width:c,height:c,fill:i}),
3
3
  /* @__PURE__ */
4
4
  /* @__PURE__ */(0,nA.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:n,strokeWidth:o,strokeOpacity:a}),
5
5
  /* @__PURE__ */
6
- /* @__PURE__ */(0,nA.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:n,strokeWidth:o,strokeOpacity:a})]},t)}function Sr(e,t,i="#4e79a7"){if(vr(e)){const i=kr(t,e);return{fill:`url(#${i})`,def:Ar(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}function Mr(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,nA.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,nA.jsx)("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},a)}}function _r(e){switch(e){case"monotoneX":return oA.curveMonotoneX;case"monotoneY":return oA.curveMonotoneY;case"cardinal":return oA.curveCardinal;case"catmullRom":return oA.curveCatmullRom;case"step":return oA.curveStep;case"stepBefore":return oA.curveStepBefore;case"stepAfter":return oA.curveStepAfter;case"basis":return oA.curveBasis;case"natural":return oA.curveNatural;default:return null}}function $r(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 Pr(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__ */
6
+ /* @__PURE__ */(0,nA.jsx)("line",{x1:r,y1:0,x2:r,y2:c,stroke:n,strokeWidth:o,strokeOpacity:a})]},t)}function $r(e,t,i="#4e79a7"){if(Ar(e)){const i=Mr(t,e);return{fill:`url(#${i})`,def:_r(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}function Pr(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,nA.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,nA.jsx)("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},a)}}function jr(e){switch(e){case"monotoneX":return oA.curveMonotoneX;case"monotoneY":return oA.curveMonotoneY;case"cardinal":return oA.curveCardinal;case"catmullRom":return oA.curveCatmullRom;case"step":return oA.curveStep;case"stepBefore":return oA.curveStepBefore;case"stepAfter":return oA.curveStepAfter;case"basis":return oA.curveBasis;case"natural":return oA.curveNatural;default:return null}}function Ir(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 Lr(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,rA.jsxs)(iA.Fragment,{children:[
8
8
  /* @__PURE__ */
9
9
  /* @__PURE__ */(0,rA.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,rA.jsx)("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:/* @__PURE__ */ /* @__PURE__ */(0,rA.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:s,floodOpacity:"0.8"})})}),
@@ -15,7 +15,7 @@ return(0,rA.jsxs)(iA.Fragment,{children:[
15
15
  /* @__PURE__ */
16
16
  /* @__PURE__ */(0,rA.jsx)("circle",{cx:e.x,cy:e.y,r:r,fill:s,stroke:a,strokeWidth:c,opacity:l}),
17
17
  /* @__PURE__ */
18
- /* @__PURE__ */(0,rA.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 jr(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 Ir({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__ */
18
+ /* @__PURE__ */(0,rA.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 Rr(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 Cr({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,sA.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,sA.jsxs)("defs",{children:[
@@ -32,14 +32,14 @@ return(0,sA.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",vi
32
32
  /* @__PURE__ */
33
33
  /* @__PURE__ */(0,sA.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:aA,strokeOpacity:"0.52",strokeWidth:n?1:2.2}),
34
34
  /* @__PURE__ */
35
- /* @__PURE__ */(0,sA.jsx)("path",{d:jr(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),
35
+ /* @__PURE__ */(0,sA.jsx)("path",{d:Rr(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),
36
36
  /* @__PURE__ */
37
37
  /* @__PURE__ */(0,sA.jsx)("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:aA,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:n?2:5}),n?null:/* @__PURE__ */ /* @__PURE__ */(0,sA.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,sA.jsxs)("g",{children:[
39
39
  /* @__PURE__ */
40
40
  /* @__PURE__ */(0,sA.jsx)("rect",{x:a,y:e.phaseRail.y,width:Math.max(1,c-2),height:e.phaseRail.height,rx:2,fill:l?n.color??lA:u?dA:aA,fillOpacity:l?.68:u?.28:.09}),46>c?null:/* @__PURE__ */ /* @__PURE__ */(0,sA.jsx)("text",{x:a+c/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:l?aA:cA,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,sA.jsxs)("g",{children:[
41
41
  /* @__PURE__ */
42
- /* @__PURE__ */(0,sA.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?uA:dA),fillOpacity:"0.1",stroke:e.color??("left"===e.side?uA:dA),strokeDasharray:"3 3",strokeOpacity:"0.62"}),n?null:/* @__PURE__ */ /* @__PURE__ */(0,sA.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:cA,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 Lr(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function Rr({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,Lr(e,o))),s=Math.max(1,...r),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__ */
42
+ /* @__PURE__ */(0,sA.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?uA:dA),fillOpacity:"0.1",stroke:e.color??("left"===e.side?uA:dA),strokeDasharray:"3 3",strokeOpacity:"0.62"}),n?null:/* @__PURE__ */ /* @__PURE__ */(0,sA.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:cA,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 Tr(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}function Or({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,Tr(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,sA.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,sA.jsxs)("g",{children:[
45
45
  /* @__PURE__ */
@@ -47,7 +47,7 @@ return(0,sA.jsxs)("g",{children:[
47
47
  /* @__PURE__ */
48
48
  /* @__PURE__ */(0,sA.jsx)("text",{x:h+.32*a,y:t.projection.y+l+10,fill:cA,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,sA.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:aA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[$r(u),"amount"===o&&n?" "+n:""]})]}):null]},e.key)})})}function Cr(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 Tr(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)??Cr(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 Or(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 Er(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:hA}}),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 Fr(e){if(!e)return pA;if("string"==typeof e)return"light"===e?pA:"dark"===e?fA:"high-contrast"===e?yA:(Object.prototype.hasOwnProperty.call(gA,t=e)?gA[t]:void 0)||pA;var t;const i="dark"===e.mode?fA:pA;return Er({...i,...e,colors:{...i.colors,...e.colors||{}},typography:{...i.typography,...e.typography||{}},tooltip:{...i.tooltip,...e.tooltip||{}}})}function Nr(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 zr(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=ut(s),c=Math.max(2,Math.round(t)),l=a.plot.width/c,u=a.plot.y+a.plot.height,d=Math.max(1,...e.map(e=>e.value)),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__ */
50
+ /* @__PURE__ */(0,sA.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:aA,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[Ir(u),"amount"===o&&n?" "+n:""]})]}):null]},e.key)})})}function Er(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 Fr(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)??Er(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 Nr(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 zr(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:hA}}),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 Dr(e){if(!e)return pA;if("string"==typeof e)return"light"===e?pA:"dark"===e?fA:"high-contrast"===e?yA:(Object.prototype.hasOwnProperty.call(gA,t=e)?gA[t]:void 0)||pA;var t;const i="dark"===e.mode?fA:pA;return zr({...i,...e,colors:{...i.colors,...e.colors||{}},typography:{...i.typography,...e.typography||{}},tooltip:{...i.tooltip,...e.tooltip||{}}})}function Br(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 Wr(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=ut(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,mA.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,mA.jsxs)(mA.Fragment,{children:[Array.from({length:c+1},(e,t)=>{const i=a.plot.x+t*l;/* @__PURE__ */ /* @__PURE__ */
52
52
  return(0,mA.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,mA.jsx)("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:a.pl
56
56
  /* @__PURE__ */(0,mA.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,mA.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,mA.jsxs)("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[
58
58
  /* @__PURE__ */
59
- /* @__PURE__ */(0,mA.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,mA.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 Dr(e,t,i){if(!1!==i&&t)return({size:i})=>{const n=[Number(i[0])||760,Number(i[1])||360],o=ut(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__ */
59
+ /* @__PURE__ */(0,mA.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,mA.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 Yr(e,t,i){if(!1!==i&&t)return({size:i})=>{const n=[Number(i[0])||760,Number(i[1])||360],o=ut(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,mA.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,mA.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,mA.jsxs)("g",{children:[
@@ -76,7 +76,7 @@ return(0,mA.jsxs)("g",{children:[
76
76
  /* @__PURE__ */
77
77
  /* @__PURE__ */(0,mA.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,mA.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 Br(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=ut(o),s=tn(r.plot,e.length,t),a=r.plot.y+r.plot.height;/* @__PURE__ */ /* @__PURE__ */
79
+ /* @__PURE__ */(0,mA.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 qr(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=ut(o),s=rn(r.plot,e.length,t),a=r.plot.y+r.plot.height;/* @__PURE__ */ /* @__PURE__ */
80
80
  return(0,mA.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,mA.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,mA.jsxs)("g",{children:[
88
88
  /* @__PURE__ */
89
89
  /* @__PURE__ */(0,mA.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,mA.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 Wr(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function Yr(e,t){if(!1!==t&&e)return({size:t})=>{const i=[Number(t[0])||700,Number(t[1])||360],n=ut(i),o=n.plot.y+n.plot.height,[r,s]=e.xExtent,a=r+(s-r)/2,c=[{label:Wr(r),x:e.xRange[0]},{label:Wr(a),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Wr(s),x:e.xRange[1]}];/* @__PURE__ */ /* @__PURE__ */
91
+ /* @__PURE__ */(0,mA.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 Xr(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function Gr(e,t){if(!1!==t&&e)return({size:t})=>{const i=[Number(t[0])||700,Number(t[1])||360],n=ut(i),o=n.plot.y+n.plot.height,[r,s]=e.xExtent,a=r+(s-r)/2,c=[{label:Xr(r),x:e.xRange[0]},{label:Xr(a),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Xr(s),x:e.xRange[1]}];/* @__PURE__ */ /* @__PURE__ */
92
92
  return(0,mA.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,mA.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,mA.jsxs)("g",{children:[
93
93
  /* @__PURE__ */
94
94
  /* @__PURE__ */(0,mA.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,mA.jsxs)("svg",{"aria-hidden":"true","data-testid":"collision-swarm-pro
101
101
  /* @__PURE__ */
102
102
  /* @__PURE__ */(0,mA.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,mA.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 qr(e,t,i){return Math.max(t,Math.min(i,e))}function Xr(e){return 6.2*e.length}function Gr(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 Vr(e,t,i="auto"){const n=Math.max(1,Math.floor(t/6.2)),o="compact"===i?Gr(e,n):"full"===i?e:Xr(e)>t?Gr(e,n):e;return{text:o,textLength:Xr(o)>t?Math.max(4,t):void 0}}function Hr(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function Ur(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 Kr(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__ */
104
+ /* @__PURE__ */(0,mA.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 Vr(e,t,i){return Math.max(t,Math.min(i,e))}function Hr(e){return 6.2*e.length}function Ur(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 Kr(e,t,i="auto"){const n=Math.max(1,Math.floor(t/6.2)),o="compact"===i?Ur(e,n):"full"===i?e:Hr(e)>t?Ur(e,n):e;return{text:o,textLength:Hr(o)>t?Math.max(4,t):void 0}}function Zr(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function Qr(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 Jr(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,xA.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,xA.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,xA.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
@@ -112,7 +112,7 @@ return(0,xA.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stag
112
112
  /* @__PURE__ */
113
113
  /* @__PURE__ */(0,xA.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),
114
114
  /* @__PURE__ */
115
- /* @__PURE__ */(0,xA.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,xA.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=Hr(e),r=bA[i],c=Math.max(12,e.width-8),l=qr(c-8,22,88),d=Vr(e.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,m=Ur(e),b=Vr(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=Vr(w,Math.max(16,c-8),"auto"),A=Math.max(30,p-15),S=A-13;/* @__PURE__ */ /* @__PURE__ */
115
+ /* @__PURE__ */(0,xA.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,xA.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=Zr(e),r=bA[i],c=Math.max(12,e.width-8),l=Vr(c-8,22,88),d=Kr(e.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,m=Qr(e),b=Kr(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=Kr(w,Math.max(16,c-8),"auto"),A=Math.max(30,p-15),S=A-13;/* @__PURE__ */ /* @__PURE__ */
116
116
  return(0,xA.jsxs)("g",{"data-stage":e.id,"data-role":i,children:[
117
117
  /* @__PURE__ */
118
118
  /* @__PURE__ */(0,xA.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,xA.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,xA.jsxs)(xA.Fragment,{children:[
@@ -125,7 +125,7 @@ return(0,xA.jsxs)("g",{"data-stage":e.id,"data-role":i,children:[
125
125
  /* @__PURE__ */
126
126
  /* @__PURE__ */(0,xA.jsx)("title",{children:m}),b.text]}):null,n&&null!=e.count?/* @__PURE__ */ /* @__PURE__ */(0,xA.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,xA.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=qr(Math.max(54,Xr(e.label)+18,Xr(c)+16),54,104),u=Vr(e.label,l-12,"auto"),d=Vr(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
128
+ /* @__PURE__ */(0,xA.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=Vr(Math.max(54,Hr(e.label)+18,Hr(c)+16),54,104),u=Kr(e.label,l-12,"auto"),d=Kr(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
129
129
  return(0,xA.jsxs)("g",{"data-group":e.id,children:[
130
130
  /* @__PURE__ */
131
131
  /* @__PURE__ */(0,xA.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,xA.jsxs)("g",{"data-group":e.id,children:[
136
136
  /* @__PURE__ */
137
137
  /* @__PURE__ */(0,xA.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,xA.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function Zr(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 Kr({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 Qr(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=ut(o),s=Math.max(1,...e.map(e=>e.value)),a=Math.min(48,.18*r.plot.height),c=r.plot.y+6;/* @__PURE__ */ /* @__PURE__ */
139
+ /* @__PURE__ */(0,xA.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function es(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 Jr({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 ts(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=ut(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,vA.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,vA.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 Jr(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function es(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=Math.max(1,...e.links.map(e=>e.throughput)),a=new Set(e.nodes.map(e=>e.sensorId));/* @__PURE__ */ /* @__PURE__ */
141
+ return(0,vA.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 is(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function ns(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,wA.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,wA.jsxs)("g",{children:[
144
144
  /* @__PURE__ */
145
- /* @__PURE__ */(0,wA.jsx)("path",{d:Jr(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),
145
+ /* @__PURE__ */(0,wA.jsx)("path",{d:is(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),
146
146
  /* @__PURE__ */
147
- /* @__PURE__ */(0,wA.jsx)("path",{d:Jr(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?/* @__PURE__ */ /* @__PURE__ */(0,wA.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,wA.jsxs)("g",{children:[n&&a.has(e.sensorId)?/* @__PURE__ */ /* @__PURE__ */(0,wA.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,wA.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,wA.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 ts({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__ */
147
+ /* @__PURE__ */(0,wA.jsx)("path",{d:is(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?/* @__PURE__ */ /* @__PURE__ */(0,wA.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,wA.jsxs)("g",{children:[n&&a.has(e.sensorId)?/* @__PURE__ */ /* @__PURE__ */(0,wA.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,wA.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,wA.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 os({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,kA.jsx)(kA.Fragment,{children:e.gates.map(r=>/* @__PURE__ */ /* @__PURE__ */(0,kA.jsxs)("g",{children:[
149
149
  /* @__PURE__ */
150
- /* @__PURE__ */(0,kA.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,kA.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 is({layout:e,states:t,compact:i=!1}){return i?/* @__PURE__ */ /* @__PURE__ */(0,kA.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,kA.jsx)(ts,{layout:e,compact:!0,showLabels:!1})}):/* @__PURE__ */ /* @__PURE__ */(0,kA.jsxs)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[
150
+ /* @__PURE__ */(0,kA.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,kA.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 rs({layout:e,states:t,compact:i=!1}){return i?/* @__PURE__ */ /* @__PURE__ */(0,kA.jsx)("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,kA.jsx)(os,{layout:e,compact:!0,showLabels:!1})}):/* @__PURE__ */ /* @__PURE__ */(0,kA.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,kA.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,kA.jsx)(kA.Fragment,{children:e.gates.map(r=>/* @__PURE__ */ /* @__PURE
155
155
  /* @__PURE__ */
156
156
  /* @__PURE__ */(0,kA.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,kA.jsx)(ts,{layout:e,compact:!1,showLabels:!0}),
158
+ /* @__PURE__ */(0,kA.jsx)(os,{layout:e,compact:!1,showLabels:!0}),
159
159
  /* @__PURE__ */
160
160
  /* @__PURE__ */(0,kA.jsxs)("g",{children:[
161
161
  /* @__PURE__ */
@@ -169,7 +169,7 @@ return(0,kA.jsx)(kA.Fragment,{children:e.gates.map(r=>/* @__PURE__ */ /* @__PURE
169
169
  /* @__PURE__ */
170
170
  /* @__PURE__ */(0,kA.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,kA.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 ns(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}function os({states:e,layout:t}){const i=ns(e);if(!i.length)return null;const n=Math.max(1,...i.map(e=>e.value)),o=Math.max(40,(t.width-80)/i.length);/* @__PURE__ */ /* @__PURE__ */
172
+ /* @__PURE__ */(0,kA.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 ss(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}function as({states:e,layout:t}){const i=ss(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,kA.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,kA.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,kA.jsxs)("g",{children:[
177
177
  /* @__PURE__ */
178
178
  /* @__PURE__ */(0,kA.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,kA.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 rs(e){return e.map(e=>({...e,spawnAt:void 0}))}function ss(e,t){return e?t?i=>Xw.createElement(Xw.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function as(e,t,i){const n=t[i];return"boolean"==typeof n?n:!0!==e.__compactMode}function cs(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return SA[(t>>>0)%SA.length]}function ls(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??cs(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??cs(a)}}function us(e,t){const i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}function ds(e){return e?{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}:e}function hs(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function ps(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:hs(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 fs(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 ys(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function gs(e,t,i){return e.entries.find(e=>e.measureId===t&&e.subjectId===i)}function ms(e){const t=e.spec.comparison;if(!t)return;const i=t.partitions.map(i=>{const n=gs(e.ledger,t.denominatorMeasureId,i)?.value??0,o={};return o["repeated-state-episode"]=fs(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,i),{partition:i,assigned:n,motifUsers:o,outcomes:{purchases:gs(e.ledger,"purchases",i)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:i}}function xs(e,t){const i=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return gs(e.ledger,i,t)?.value}function bs(e,t,i){return 0===i||1e4*e%i!=0?Math.round((t-e)/Math.max(i,1)*1e4):1e4*(t-e)/i}function vs(e,t={}){const i=t.templates??["repeated-state-episode"],n="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],o=void 0!==t.partition?xs(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=>fs(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 ws(e){return e.entityCount??1}function ks(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:ws(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:ys(e.nodePath,e.nodePath.length-1)}}function As(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:vs(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const i=(e.source.occurrences??[]).map(ks).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=ys(e.nodePath,t),n=ys(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=ps(e.motifs.matches),a=e.comparison??ms(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:bs(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:bs(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:vs(e),differences:c,prefixForest:t,sceneSeeds:l}}function Ss(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 Ms(e,t=1/0){let i=t;for(const t of e)i>t&&(i=t);return i}function _s(e,t=-1/0){let i=t;for(const t of e)t>i&&(i=t);return i}function $s(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 Ps(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 js(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=OA(n,o),a=OA(o,r),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=TA(o,n,c/s),u=TA(o,r,c/a);t.push(l);for(let e=1;12>=e;e++){const i=e/12;t.push(TA(TA(l,o,i),TA(o,u,i),i))}}return t.push(e[e.length-1]),t.filter((e,i)=>0===i||OA(t[i-1],e)>1e-8)}function Is(e,t,i){if(2>e.length)return"";const n=js(e);if(2>n.length)return"";const o=[0];for(let e=1;n.length>e;e++)o.push(o[e-1]+OA(n[e-1],n[e]));const r=o[o.length-1],s=$s(n,1),a=[1,-1].map(e=>n.map((n,a)=>TA(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 Ls(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 Rs(e){let t="";return e.split(">").map((e,i)=>t=i?`${t}>${e}`:e)}function Cs(e){const t=/* @__PURE__ */new Map;for(const i of e){const e=Rs(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 Ts(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 Os(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 Es(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=mn({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:Jr(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 Fs(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 Ns(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??qA.muted,alarm:t.alarm??e.danger??qA.alarm}}function zs(e,t,i,n,o,r=qA,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?`${XA(f.completions)} / ${XA(f.capacity)} ${m}/s`:null!==f.completions?`${XA(f.completions)} ${m}/s complete`:`${XA(f.arrivals)} ${m}/s offered`;return YA("g",{key:a.id,"data-circuit-module":a.nodeId,"data-module-kind":a.kind,opacity:s?.(a.nodeId),"data-queued":f.queued??"unmeasured"},YA("rect",{x:l,y:u,width:d,height:h,fill:"none",stroke:y,strokeWidth:o===a.nodeId?2.5:1}),YA("path",{d:GA[a.kind],transform:`translate(${l+10},${u+12})`,stroke:y,fill:"none",strokeWidth:1.4}),YA("text",{x:g+5,y:u+16,textAnchor:"middle",fontSize:110>d?9:11,fontWeight:600,fill:n},a.semantics.label),YA("text",{x:g,y:u+28,textAnchor:"middle",fontSize:8,fill:n},VA[a.kind]),YA("text",{x:g,y:u+41,textAnchor:"middle",fontSize:110>d?7:9,fill:n},x),YA("text",{x:g,y:u+h-13,textAnchor:"middle",fontSize:8,fill:n},"Queue "+XA(f.queued)),null!==f.queued?YA("rect",{...p,width:p.width*f.queued/c,fill:y,"data-circuit-gauge":"queue"}):null,YA("rect",{...e.sensor,fill:i,"data-circuit-sensor":a.nodeId}),a.semantics.dependencyNodeIds?.length?YA("text",{x:g,y:u-8,fontSize:8,textAnchor:"middle",fill:n,"data-circuit-dependency":a.nodeId},"Requires "+a.semantics.dependencyNodeIds.join(", ")):null)})}function Ds(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 YA("g",{"data-circuit-history":c,"data-history-module":a?.nodeId},YA("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"),YA("path",{d:f,fill:"none",stroke:n,strokeWidth:2}),YA("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=>YA("text",{key:e.id,x:p(e.at),y:s.y+s.height+14,textAnchor:"middle",fontSize:9,fill:o},e.at+"s")))}function Bs(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 Ws(e,t,i,n){return[...t.modules.map(t=>{const o=Bs(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 ${HA(o.arrivals)} ${o.unit}/s; completions ${HA(o.completions)} ${o.unit}/s; installed capacity ${HA(o.capacity)} ${o.unit}/s; queue ${HA(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}: ${HA(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${n.observedAt}s; transferred volume ${HA(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 Ys(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 qs(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 Xs({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 Gs(e){if(!e)return iS;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 Vs(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Hs(e,t){if(!Vs(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 Us(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=En(e,i,n)):p=o||Xk,void 0!==p&&(d.stroke=p,h&&(d.fill=p,d.fillOpacity=a)),c?.length&&Object.assign(d,at(e,c,l?l(e,u):{value:void 0,category:u})),d}}function Ks(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 Zs(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 Qs(e,t){return ct(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:Zs(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function Js(e){const{seriesAColor:t,seriesBColor:i,areaOpacity:n,styleRules:o}=e;return Qs(e=>({fill:"A"===Zs(e)?t:i,stroke:"none",fillOpacity:n}),o)}function ea(e){const{seriesAColor:t,seriesBColor:i,lineWidth:n,styleRules:o}=e;return Qs(e=>({stroke:"A"===Zs(e)?t:i,strokeWidth:n,fill:"none"}),o)}function ta(e,t=nS){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 ia(e){return e?ta(e):void 0}function na(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 oa(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 ra(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 sa(e,t,i){return"function"==typeof e?e(i):i[e||t]}function aa(e){return e instanceof Date?e.getTime():Number(e)}function ca(e,t){return jk(1===t?.5:e/(t-1))}function la(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 ua(e,t){const i=ra(t),n=Array.isArray(e)?e:void 0;return i?[i,...n??[]]:n}function da(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:aa(sa(t.orderAccessor,"order",e))-aa(sa(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=aa(sa(i,"x",e)),o=aa(sa(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=aa(sa(i,"x",e)),o=aa(sa(n,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&r.set(e,{idx:a++,total:s})}return{data:o,orderMap:r}}function ha(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function pa(e,t,i,n=!1){const o=y({axes:t,showAxes:i});return{...A(e,t,n),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function fa(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 ya(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 ga(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 ma(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 xa(e){const t=10**oS;return Math.round(e*t)/t}function ba(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 va(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:xa((i*t[3]-t[0]*t[1])/n),r=xa(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[xa(e),xa(o*e+r)]),equation:[o,r]}}function wa(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=ba(n,o).map(xa);return{points:e.map(([e])=>[xa(e),xa(r.reduce((t,i,n)=>t+i*e**n,0))]),equation:[...r].reverse()}}function ka(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 Aa(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 Sa(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function Ma(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[sS]=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]=Ss(u),p=h-d;e.forEach((e,t)=>{const i=l[t];Number.isFinite(i)&&(e[sS]=c-(p>0?(i-d)/p:0)*(c-a))})}function _a(e,t){return"function"==typeof t?t(e):!!e[t]}function $a(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&&_a(e,s)?t="forecast":r&&_a(e,r)&&(t="training"),{...e,[rS]: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][rS]!==i[e+1][rS]&&(t.push({...i[e+1],[rS]:i[e][rS]}),t.push({...i[e],[rS]:i[e+1][rS]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][rS]!==y[e+1][rS]&&(m.push({...y[e+1],[rS]:y[e][rS]}),m.push({...y[e],[rS]:y[e+1][rS]}));if(n.trainUnderline){const e=[];for(const t of m)"training"===t[rS]&&e.push({...t,[rS]:"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]:()=>{};Ma(m.filter(e=>"forecast"===e[rS]),n,e,t)}if(a){const e=n.anomalyStyle,t={type:"highlight",filter:e=>_a(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 Pa(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,[rS]:"observed"}):d.push({...i,[rS]:"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=ka(p);if(r){const{se:d,meanX:h,ssX:g}=Aa(p,r),m=Sa(a),x=_s(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,[rS]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}Ma(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],[rS]:"observed"}),g.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[rS]:"forecast"}),g.push(...y)}return{processedData:g,annotations:f}}function ja(e,t,i,n,o){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?$a(e,0,0,n,o):Pa(e,t,i,n,o);var r}function Ia(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[rS];if("training"===d){let e=u.stroke;return"darken"===a?e=ga(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=ma(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[sS],i=null!=e?e:s;return{...u,stroke:o,strokeDasharray:n,...null!=i&&{strokeOpacity:i}}}return u}}function La(e,t,i){const n="function"==typeof t,o="function"==typeof i,r=n?aS:t,s=o?cS:i;return n||o?{xKey:r,yKey:s,rows:e.map(e=>{const r={...e};return n&&(r[aS]=t(e)),o&&(r[cS]=i(e)),r})}:{rows:e,xKey:r,yKey:s}}function Ra(e,t,i){const n=e[t],o=e[i];return null==n||null==o||Number.isNaN(n)||Number.isNaN(o)}function Ca(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)Ra(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)Ra(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)Ra(e,i,n)?c():r.push(e);c()}return{rows:s,groupKey:a}}function Ta(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 Oa(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=Nn(e.map(e=>({__lbl:(d(e)??"")+""})),"__lbl",r??s),p=fa(e,{position:l,fontSize:u,colorBy:i,color:e=>h?h(e):a||Xk},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 Ea(e){const t=e.xAccessor||"x",i=e.yAccessor||"y",n=e.lineBy,o=e.colorBy||n;let r=Array.isArray(e.data)?Gs(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=La(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=ja(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=Ta(r,c,e.forecast),n&&"string"==typeof n?(r=r.map(e=>({...e,[lS]:`${e[n]}__${e[rS]||"observed"}`})),d=lS):d=rS,e.baseLineStyle){const t=Ia(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=Ca(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=Oa(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 Fa(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Fr(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?Nn(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?Ss(p):void 0,y=it(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?En(e,t,u):"string"==typeof o.color?o.color:Xk,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Dn(e,d,h,f):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,at(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 Na(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 za(e,t,i,n){if(!i.categoryAccessor)return;const o=Na(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=Fr(t.theme).colors.categorical,c=a?.length?a:Gk;return Object.fromEntries(s.map((e,t)=>[e,r&&Fn(r,e)||i.fill||c[t%c.length]]))}function Da(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Fr(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?Nn(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?Ss(p):void 0,y=it(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?En(e,t,u):"string"==typeof o.color?o.color:Xk,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Dn(e,d,h,f):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,at(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 Ba(e,t){return t?.length?(Object.defineProperty(e,hS,{configurable:!0,enumerable:!1,value:t}),e):e}function Wa(e){return e?.[hS]}function Ya(e){return e.parentLine?Ba({...e.parentLine,...e},Wa(e)):e}function qa(e){return Ba({...e[0]},e.map(Ya))}function Xa(e){return!!e&&Wa(e)?.[0]===e}function Ga(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 Va(e,t,i,n,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){const e=Fn(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=Yk[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]:Xk}function Ha(e,t,i){return"function"==typeof e?e(t,i):t[e]}function Ua(e,t){if(!e?.length)return;const i=new Map(t.map((e,t)=>[De(e),t]));return e.map(e=>{const t={...e},n=n=>{if(!(n in e))return;const o=i.get(De(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 Ka(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)?Va(void 0,a,r,e,u):s??c??"#b8bec8")});return d}function Za(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=Ha(i,e,t),p=De(r);let f=a.get(p);null==f&&(f=s.length,a.set(p,f),s.push(r),c.set(f,[]));const y=Ha(o,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(Ha(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 Qa(){const e=(qv??(qv=pS.createContext(null)),qv);return pS.useContext(e)??fS}function Ja(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 ec(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 tc(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=Ja(e.x,s,s,t.x,c),u=Ja(e.y,e.y,t.y,t.y,c),d=ec(e.x,s,s,t.x,c),h=ec(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 ic(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=tc(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 nc(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 oc({datum:e,x:t,y:i,side:n,color:o,highlighted:r,labelStyle:s}){const a=Qa(),c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;/* @__PURE__ */ /* @__PURE__ */
181
- return(0,yS.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 rc(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function sc(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 ac(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 cc(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&&Fn(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?sc(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=ic(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,at(n[0].__bumpRaw,t.styleRules,ac(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,at(e.__bumpRaw,t.styleRules,ac(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=nc(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(
180
+ /* @__PURE__ */(0,kA.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 cs(e){return e.map(e=>({...e,spawnAt:void 0}))}function ls(e,t){return e?t?i=>Xw.createElement(Xw.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function us(e,t,i){const n=t[i];return"boolean"==typeof n?n:!0!==e.__compactMode}function ds(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return SA[(t>>>0)%SA.length]}function hs(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??ds(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??ds(a)}}function ps(e,t){const i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}function fs(e){return e?{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}:e}function ys(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function gs(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:ys(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 ms(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 xs(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function bs(e,t,i){return e.entries.find(e=>e.measureId===t&&e.subjectId===i)}function vs(e){const t=e.spec.comparison;if(!t)return;const i=t.partitions.map(i=>{const n=bs(e.ledger,t.denominatorMeasureId,i)?.value??0,o={};return o["repeated-state-episode"]=ms(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,i),{partition:i,assigned:n,motifUsers:o,outcomes:{purchases:bs(e.ledger,"purchases",i)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:i}}function ws(e,t){const i=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return bs(e.ledger,i,t)?.value}function ks(e,t,i){return 0===i||1e4*e%i!=0?Math.round((t-e)/Math.max(i,1)*1e4):1e4*(t-e)/i}function As(e,t={}){const i=t.templates??["repeated-state-episode"],n="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],o=void 0!==t.partition?ws(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=>ms(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 Ss(e){return e.entityCount??1}function Ms(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:Ss(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:xs(e.nodePath,e.nodePath.length-1)}}function _s(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:As(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const i=(e.source.occurrences??[]).map(Ms).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=xs(e.nodePath,t),n=xs(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=gs(e.motifs.matches),a=e.comparison??vs(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:ks(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:ks(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:As(e),differences:c,prefixForest:t,sceneSeeds:l}}function $s(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 Ps(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 js(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=OA(n,o),a=OA(o,r),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=TA(o,n,c/s),u=TA(o,r,c/a);t.push(l);for(let e=1;12>=e;e++){const i=e/12;t.push(TA(TA(l,o,i),TA(o,u,i),i))}}return t.push(e[e.length-1]),t.filter((e,i)=>0===i||OA(t[i-1],e)>1e-8)}function Is(e,t,i){if(2>e.length)return"";const n=js(e);if(2>n.length)return"";const o=[0];for(let e=1;n.length>e;e++)o.push(o[e-1]+OA(n[e-1],n[e]));const r=o[o.length-1],s=$s(n,1),a=[1,-1].map(e=>n.map((n,a)=>TA(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 Ls(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 Rs(e){let t="";return e.split(">").map((e,i)=>t=i?`${t}>${e}`:e)}function Cs(e){const t=/* @__PURE__ */new Map;for(const i of e){const e=Rs(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 Ts(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 Os(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 Es(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=vn({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:is(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 Fs(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 Ns(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??qA.muted,alarm:t.alarm??e.danger??qA.alarm}}function zs(e,t,i,n,o,r=qA,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?`${XA(f.completions)} / ${XA(f.capacity)} ${m}/s`:null!==f.completions?`${XA(f.completions)} ${m}/s complete`:`${XA(f.arrivals)} ${m}/s offered`;return YA("g",{key:a.id,"data-circuit-module":a.nodeId,"data-module-kind":a.kind,opacity:s?.(a.nodeId),"data-queued":f.queued??"unmeasured"},YA("rect",{x:l,y:u,width:d,height:h,fill:"none",stroke:y,strokeWidth:o===a.nodeId?2.5:1}),YA("path",{d:GA[a.kind],transform:`translate(${l+10},${u+12})`,stroke:y,fill:"none",strokeWidth:1.4}),YA("text",{x:g+5,y:u+16,textAnchor:"middle",fontSize:110>d?9:11,fontWeight:600,fill:n},a.semantics.label),YA("text",{x:g,y:u+28,textAnchor:"middle",fontSize:8,fill:n},VA[a.kind]),YA("text",{x:g,y:u+41,textAnchor:"middle",fontSize:110>d?7:9,fill:n},x),YA("text",{x:g,y:u+h-13,textAnchor:"middle",fontSize:8,fill:n},"Queue "+XA(f.queued)),null!==f.queued?YA("rect",{...p,width:p.width*f.queued/c,fill:y,"data-circuit-gauge":"queue"}):null,YA("rect",{...e.sensor,fill:i,"data-circuit-sensor":a.nodeId}),a.semantics.dependencyNodeIds?.length?YA("text",{x:g,y:u-8,fontSize:8,textAnchor:"middle",fill:n,"data-circuit-dependency":a.nodeId},"Requires "+a.semantics.dependencyNodeIds.join(", ")):null)})}function Ds(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 YA("g",{"data-circuit-history":c,"data-history-module":a?.nodeId},YA("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"),YA("path",{d:f,fill:"none",stroke:n,strokeWidth:2}),YA("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=>YA("text",{key:e.id,x:p(e.at),y:s.y+s.height+14,textAnchor:"middle",fontSize:9,fill:o},e.at+"s")))}function Bs(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 Ws(e,t,i,n){return[...t.modules.map(t=>{const o=Bs(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 ${HA(o.arrivals)} ${o.unit}/s; completions ${HA(o.completions)} ${o.unit}/s; installed capacity ${HA(o.capacity)} ${o.unit}/s; queue ${HA(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}: ${HA(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${n.observedAt}s; transferred volume ${HA(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 Ys(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 qs(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 Xs({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 Gs(e){if(!e)return iS;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 Vs(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Hs(e,t){if(!Vs(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 Us(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=zn(e,i,n)):p=o||Xk,void 0!==p&&(d.stroke=p,h&&(d.fill=p,d.fillOpacity=a)),c?.length&&Object.assign(d,at(e,c,l?l(e,u):{value:void 0,category:u})),d}}function Ks(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 Zs(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 Qs(e,t){return ct(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:Zs(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function Js(e){const{seriesAColor:t,seriesBColor:i,areaOpacity:n,styleRules:o}=e;return Qs(e=>({fill:"A"===Zs(e)?t:i,stroke:"none",fillOpacity:n}),o)}function ea(e){const{seriesAColor:t,seriesBColor:i,lineWidth:n,styleRules:o}=e;return Qs(e=>({stroke:"A"===Zs(e)?t:i,strokeWidth:n,fill:"none"}),o)}function ta(e,t=nS){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 ia(e){return e?ta(e):void 0}function na(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 oa(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 ra(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 sa(e,t,i){return"function"==typeof e?e(i):i[e||t]}function aa(e){return e instanceof Date?e.getTime():Number(e)}function ca(e,t){return jk(1===t?.5:e/(t-1))}function la(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 ua(e,t){const i=ra(t),n=Array.isArray(e)?e:void 0;return i?[i,...n??[]]:n}function da(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:aa(sa(t.orderAccessor,"order",e))-aa(sa(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=aa(sa(i,"x",e)),o=aa(sa(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=aa(sa(i,"x",e)),o=aa(sa(n,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&r.set(e,{idx:a++,total:s})}return{data:o,orderMap:r}}function ha(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function pa(e,t,i,n=!1){const o=y({axes:t,showAxes:i});return{...A(e,t,n),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}function fa(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 ya(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 ga(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 ma(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 xa(e){const t=10**oS;return Math.round(e*t)/t}function ba(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 va(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:xa((i*t[3]-t[0]*t[1])/n),r=xa(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[xa(e),xa(o*e+r)]),equation:[o,r]}}function wa(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=ba(n,o).map(xa);return{points:e.map(([e])=>[xa(e),xa(r.reduce((t,i,n)=>t+i*e**n,0))]),equation:[...r].reverse()}}function ka(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 Aa(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 Sa(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function Ma(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[sS]=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]=At(u),p=h-d;e.forEach((e,t)=>{const i=l[t];Number.isFinite(i)&&(e[sS]=c-(p>0?(i-d)/p:0)*(c-a))})}function _a(e,t){return"function"==typeof t?t(e):!!e[t]}function $a(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&&_a(e,s)?t="forecast":r&&_a(e,r)&&(t="training"),{...e,[rS]: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][rS]!==i[e+1][rS]&&(t.push({...i[e+1],[rS]:i[e][rS]}),t.push({...i[e],[rS]:i[e+1][rS]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][rS]!==y[e+1][rS]&&(m.push({...y[e+1],[rS]:y[e][rS]}),m.push({...y[e],[rS]:y[e+1][rS]}));if(n.trainUnderline){const e=[];for(const t of m)"training"===t[rS]&&e.push({...t,[rS]:"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]:()=>{};Ma(m.filter(e=>"forecast"===e[rS]),n,e,t)}if(a){const e=n.anomalyStyle,t={type:"highlight",filter:e=>_a(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 Pa(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,[rS]:"observed"}):d.push({...i,[rS]:"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=ka(p);if(r){const{se:d,meanX:h,ssX:g}=Aa(p,r),m=Sa(a),x=Mt(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,[rS]:"forecast",__forecastUpper:s+a,__forecastLower:s-a})}Ma(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],[rS]:"observed"}),g.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[rS]:"forecast"}),g.push(...y)}return{processedData:g,annotations:f}}function ja(e,t,i,n,o){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?$a(e,0,0,n,o):Pa(e,t,i,n,o);var r}function Ia(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[rS];if("training"===d){let e=u.stroke;return"darken"===a?e=ga(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=ma(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[sS],i=null!=e?e:s;return{...u,stroke:o,strokeDasharray:n,...null!=i&&{strokeOpacity:i}}}return u}}function La(e,t,i){const n="function"==typeof t,o="function"==typeof i,r=n?aS:t,s=o?cS:i;return n||o?{xKey:r,yKey:s,rows:e.map(e=>{const r={...e};return n&&(r[aS]=t(e)),o&&(r[cS]=i(e)),r})}:{rows:e,xKey:r,yKey:s}}function Ra(e,t,i){const n=e[t],o=e[i];return null==n||null==o||Number.isNaN(n)||Number.isNaN(o)}function Ca(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)Ra(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)Ra(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)Ra(e,i,n)?c():r.push(e);c()}return{rows:s,groupKey:a}}function Ta(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 Oa(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=Bn(e.map(e=>({__lbl:(d(e)??"")+""})),"__lbl",r??s),p=fa(e,{position:l,fontSize:u,colorBy:i,color:e=>h?h(e):a||Xk},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 Ea(e){const t=e.xAccessor||"x",i=e.yAccessor||"y",n=e.lineBy,o=e.colorBy||n;let r=Array.isArray(e.data)?Gs(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=La(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=ja(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=Ta(r,c,e.forecast),n&&"string"==typeof n?(r=r.map(e=>({...e,[lS]:`${e[n]}__${e[rS]||"observed"}`})),d=lS):d=rS,e.baseLineStyle){const t=Ia(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=Ca(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=Oa(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 Fa(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Dr(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?Bn(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?At(p):void 0,y=it(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?zn(e,t,u):"string"==typeof o.color?o.color:Xk,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?Yn(e,d,h,f):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,at(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 Na(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 za(e,t,i,n){if(!i.categoryAccessor)return;const o=Na(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=Dr(t.theme).colors.categorical,c=a?.length?a:Gk;return Object.fromEntries(s.map((e,t)=>[e,r&&Dn(r,e)||i.fill||c[t%c.length]]))}function Da(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Dr(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?Bn(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?At(p):void 0,y=it(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{const i={fill:t&&u?zn(e,t,u):"string"==typeof o.color?o.color:Xk,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?Yn(e,d,h,f):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,at(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 Ba(e,t){return t?.length?(Object.defineProperty(e,hS,{configurable:!0,enumerable:!1,value:t}),e):e}function Wa(e){return e?.[hS]}function Ya(e){return e.parentLine?Ba({...e.parentLine,...e},Wa(e)):e}function qa(e){return Ba({...e[0]},e.map(Ya))}function Xa(e){return!!e&&Wa(e)?.[0]===e}function Ga(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 Va(e,t,i,n,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){const e=Dn(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=Yk[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]:Xk}function Ha(e,t,i){return"function"==typeof e?e(t,i):t[e]}function Ua(e,t){if(!e?.length)return;const i=new Map(t.map((e,t)=>[De(e),t]));return e.map(e=>{const t={...e},n=n=>{if(!(n in e))return;const o=i.get(De(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 Ka(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)?Va(void 0,a,r,e,u):s??c??"#b8bec8")});return d}function Za(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=Ha(i,e,t),p=De(r);let f=a.get(p);null==f&&(f=s.length,a.set(p,f),s.push(r),c.set(f,[]));const y=Ha(o,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(Ha(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 Qa(){const e=(qv??(qv=pS.createContext(null)),qv);return pS.useContext(e)??fS}function Ja(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 ec(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 tc(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=Ja(e.x,s,s,t.x,c),u=Ja(e.y,e.y,t.y,t.y,c),d=ec(e.x,s,s,t.x,c),h=ec(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 ic(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=tc(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 nc(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 oc({datum:e,x:t,y:i,side:n,color:o,highlighted:r,labelStyle:s}){const a=Qa(),c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;/* @__PURE__ */ /* @__PURE__ */
181
+ return(0,yS.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 rc(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}function sc(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 ac(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 cc(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&&Dn(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?sc(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=ic(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,at(n[0].__bumpRaw,t.styleRules,ac(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,at(e.__bumpRaw,t.styleRules,ac(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=nc(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,yS.jsx)(oc,{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,yS.jsx)("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(e,t)=>{const i=rc(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function lc(e,t,i){const n=Tn(t,i,qk),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 uc(e,t){const i=tt(e),n=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:tt(e.yAccessor)}));return(e,t)=>{const o=(e[xS]??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 dc(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 hc(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Fr(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?Nn(l,c,a):void 0,d=it(o.xAccessor,o.yAccessor);return Hs(Us({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 pc(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Fr(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?Nn(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=tt(o.yAccessor),y=o.styleRules;return(e,i)=>{const n=t&&u?En(e,t,u):"string"==typeof o.color?o.color:Xk,r={fill:n,fillOpacity:p,stroke:d?n:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(r,at(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 fc(e,t,i,n,o){if(!o.showPoints)return;const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Fr(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?Nn(l,c,a):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{const i=t&&u?En(e,t,u):"string"==typeof o.color?o.color:Xk;return{r:d,fill:i,stroke:"none"}}}function yc(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 gc(e){return"p"+(Math.round(1e3*e)/10+"").replace(".","_")}function mc(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 xc(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 bc(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 vc(e,t,i,n=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=bc(e,i),r=e.stddev*n;return[o-r,o+r]}function wc(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;ES.lastIndex=0;let i,n=0,o=0;for(;null!==(i=ES.exec(t));){const e=parseFloat(i[1]),t=OS[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 kc(e){const t=e.window??"tumbling",i=wc("session"===t?e.gap??e.size:e.size);if(null==i)return null;const n=null!=e.hop?wc(e.hop):void 0,o=null!=e.gap?wc(e.gap):void 0;return new TS({window:t,size:i,hop:n??void 0,gap:o??void 0,retain:e.retain,percentiles:e.percentiles,distinct:e.distinct})}function Ac(e,t){const i=t.stat??"mean",n=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[FS]:(e.start+e.end)/2,[NS]:bc(e,i),[WS]:e.count,[BS]:e.partial,[YS]:e.start,[qS]:e.end},r=vc(e,n,i,o);return r&&(t[zS]=r[0],t[DS]=r[1]),t})}function Sc(e,t,i){const n=e??i;return null!=n?n:Math.max(t?.length??0,200)}function Mc(e,t,i){const n=tt(e),o=tt(t),r=tt(i);return e=>{const t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?_c(e.value):r(e),x:t?_c(e.xCenter):n(e),y:t?_c(e.yCenter):o(e)}}}function _c(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function $c(e,t){const i=Array.isArray(e)?Gs(e):[],n=t.aggregate;if(!n)return i;const o=new GS(n,t.seriesAccessor);for(const e of i)o.push(e,t.timeAccessor,t.valueAccessor);return o.emit(n)}function Pc(e){const t=e.timeAccessor||"time",i=e.valueAccessor||"value";return{timeAccessor:e=>qs(e,t,"time")??NaN,valueAccessor:e=>qs(e,i,"value")??NaN}}function jc(e,t,i){return{runtimeMode:"streaming",windowMode:i.windowMode??i.capacityMode??"sliding",windowSize:Sc(i.windowSize,e,i.capacity),arrowOfTime:i.arrowOfTime??"right",...Pc(i),xExtent:i.timeExtent??t.xExtent,yExtent:i.valueExtent??t.yExtent,extentPadding:i.extentPadding??t.extentPadding,tickFormatTime:i.tickFormatTime,tickFormatValue:i.tickFormatValue}}function Ic(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function Lc(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(JS,t)){const i=JS[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 Rc(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 Cc(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:eM,__likertPct:-e}),r.push({...t,__likertLevel:tM,__likertPct:e})}else r.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return r}function Tc(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===eM?r=i:i.__likertLevel===tM?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 Oc({value:e,min:t,max:i,radius:n,showScaleLabels:o}){const r=Math.max(16,.3*n);/* @__PURE__ */ /* @__PURE__ */
183
+ /* @__PURE__ */(0,yS.jsx)(oc,{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,yS.jsx)("g",{className:"semiotic-bump-labels",children:r}):void 0,restyle:(e,t)=>{const i=rc(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function lc(e,t,i){const n=Fn(t,i,qk),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 uc(e,t){const i=tt(e),n=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:tt(e.yAccessor)}));return(e,t)=>{const o=(e[xS]??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 dc(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 hc(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Dr(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?Bn(l,c,a):void 0,d=it(o.xAccessor,o.yAccessor);return Hs(Us({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 pc(e,t,i,n,o){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Dr(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?Bn(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=tt(o.yAccessor),y=o.styleRules;return(e,i)=>{const n=t&&u?zn(e,t,u):"string"==typeof o.color?o.color:Xk,r={fill:n,fillOpacity:p,stroke:d?n:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(r,at(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 fc(e,t,i,n,o){if(!o.showPoints)return;const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Dr(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?Bn(l,c,a):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{const i=t&&u?zn(e,t,u):"string"==typeof o.color?o.color:Xk;return{r:d,fill:i,stroke:"none"}}}function yc(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 gc(e){return"p"+(Math.round(1e3*e)/10+"").replace(".","_")}function mc(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 xc(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 bc(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 vc(e,t,i,n=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=bc(e,i),r=e.stddev*n;return[o-r,o+r]}function wc(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;ES.lastIndex=0;let i,n=0,o=0;for(;null!==(i=ES.exec(t));){const e=parseFloat(i[1]),t=OS[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 kc(e){const t=e.window??"tumbling",i=wc("session"===t?e.gap??e.size:e.size);if(null==i)return null;const n=null!=e.hop?wc(e.hop):void 0,o=null!=e.gap?wc(e.gap):void 0;return new TS({window:t,size:i,hop:n??void 0,gap:o??void 0,retain:e.retain,percentiles:e.percentiles,distinct:e.distinct})}function Ac(e,t){const i=t.stat??"mean",n=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[FS]:(e.start+e.end)/2,[NS]:bc(e,i),[WS]:e.count,[BS]:e.partial,[YS]:e.start,[qS]:e.end},r=vc(e,n,i,o);return r&&(t[zS]=r[0],t[DS]=r[1]),t})}function Sc(e,t,i){const n=e??i;return null!=n?n:Math.max(t?.length??0,200)}function Mc(e,t,i){const n=tt(e),o=tt(t),r=tt(i);return e=>{const t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?_c(e.value):r(e),x:t?_c(e.xCenter):n(e),y:t?_c(e.yCenter):o(e)}}}function _c(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function $c(e,t){const i=Array.isArray(e)?Gs(e):[],n=t.aggregate;if(!n)return i;const o=new GS(n,t.seriesAccessor);for(const e of i)o.push(e,t.timeAccessor,t.valueAccessor);return o.emit(n)}function Pc(e){const t=e.timeAccessor||"time",i=e.valueAccessor||"value";return{timeAccessor:e=>qs(e,t,"time")??NaN,valueAccessor:e=>qs(e,i,"value")??NaN}}function jc(e,t,i){return{runtimeMode:"streaming",windowMode:i.windowMode??i.capacityMode??"sliding",windowSize:Sc(i.windowSize,e,i.capacity),arrowOfTime:i.arrowOfTime??"right",...Pc(i),xExtent:i.timeExtent??t.xExtent,yExtent:i.valueExtent??t.yExtent,extentPadding:i.extentPadding??t.extentPadding,tickFormatTime:i.tickFormatTime,tickFormatValue:i.tickFormatValue}}function Ic(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function Lc(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(JS,t)){const i=JS[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 Rc(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 Cc(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:eM,__likertPct:-e}),r.push({...t,__likertLevel:tM,__likertPct:e})}else r.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return r}function Tc(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===eM?r=i:i.__likertLevel===tM?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 Oc({value:e,min:t,max:i,radius:n,showScaleLabels:o}){const r=Math.max(16,.3*n);/* @__PURE__ */ /* @__PURE__ */
184
184
  return(0,nM.jsxs)("g",{textAnchor:"middle",children:[
185
185
  /* @__PURE__ */
186
- /* @__PURE__ */(0,nM.jsx)("text",{y:0,dominantBaseline:"central",fontSize:r,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&/* @__PURE__ */ /* @__PURE__ */(0,nM.jsxs)("text",{y:.7*r+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}function Ec(e){return Math.max(0,Math.min(1,e))}function Fc(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 Nc(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 zc(e,t,i){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ec(e.offset),color:e.color??i,opacity:null==e.opacity?1:Ec(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=Fc(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=Ec(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=Fc(t.color),l=Fc(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?Nc(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return o(n[n.length-1])}function Dc(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Bc(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=Dc("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(zc(l.stops,e*(t+.5)/i,r||p[0]?.color||"#007bff"));const o=Dc("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=Dc("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=Dc("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 Wc(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 Yc(e=240){const{sweepRad:t,offsetRad:i}=Wc(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]=Ss(o),[c,l]=Ss(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 qc(e){return ta(e)}function Xc(e,t,i,n,o,r){const s=Fr(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?Nn(u,l,a??s):void 0,h=Va("string"==typeof o.color?o.color:void 0,s,a,void 0,
187
- /* @__PURE__ */new Map),p=r??tt(o.valueAccessor??"value"),f=o.styleRules,y=n.pieceStyle;return(e,i)=>{const n={fill:t&&d?En(e,t,d):h};return f?.length&&Object.assign(n,at(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 Gc(e,t,i,n,o,r="median",s=.8){const a=tt(o.valueAccessor??"value"),c=Xc(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 Vc(e,t,i,n,o){return Gc(e,t,i,n,o,"median",.6)}function Hc(e,t,i,n,o){const r=Xc(e,t,i,n,o),s="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:s,fillOpacity:.8,...r(e,t)})}function Uc(e,t,i,n,o){const r=Xc(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?Ss(l):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:a?Dn(e,a,c,u):d,fillOpacity:h,...r(e,t)})}function Kc(e="static"){return wM[e]??wM.static}function Zc(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:kM.has(e.kind)?"fatal":"warn"}function Qc(e){const t=[],i=[];for(const n of e)"fatal"===Zc(n)?t.push(n):i.push(n);return{fatal:t,warnings:i}}function Jc(e,t,i,n={}){const o=Kc(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 el(e,t,i="static"){if("strip"!==Kc(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 tl(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 il(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 nl(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 ol(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=nl(r,e),i=nl(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 rl(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 sl(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 al(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 cl(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 ll(){/* @__PURE__ */
188
- return Object.create(null)}function ul(e,t){return t>e?-1:e>t?1:0}function dl(e){return e.occupants.map(e=>e.id).sort(ul).join("\0")}function hl(e,t,i=0){return e.slice(0,-1).map((n,o)=>null!=n.group&&n.group===e[o+1].group?i:t)}function pl(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 fl(e,t,i){return ol(pl([e,t],i)).adjacentClearance[0]??0}function yl(e,t,i){if(0===e.length)return[];const{padding:n,plotH:o,valueScale:r}=i,s=i.stackValueScale??r,a=hl(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 gl(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 ml(e,t,i,n,o,r,s){const a=e.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=hl(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 yl(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=gl(a,u),h=gl(c,u);e[i]+=(y[s]+h-d)*l,o[i]+=l,e[s]+=(y[i]+d-h)*l,o[s]+=l}const r=il({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 xl(e,t,i,n,o,r){const s=r.adjacentClearance?[...r.adjacentClearance]:ol(pl(n,i)).adjacentClearance,a=yl(n,s,r);let c="hug"===r.lanePlacement?ml(n,o,t,i,s,a,r):[...a];if("hug"===r.lanePlacement){const i=t=>{const i=ll();for(const n of e)i[n.id]=t[o[n.id]];return i};bl(i(c),t)>bl(i(a),t)+1e-6&&(c=[...a])}const l=ll();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 bl(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 vl(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 wl(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 kl(e,t){let i=0,n=1;for(let o=0;28>o;o++){const o=(i+n)/2;e>wl(0,t,t,1,o)?i=o:n=o}return(i+n)/2}function Al(e,t,i){const n=t+gl(e,i),o=e.value*i/2;return[n-o,n+o]}function Sl(e,t,i,n){return Math.max(0,Math.min(t,n)-Math.max(e,i))/Math.max(1e-9,t-e)}function Ml(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]=Al(p,o[s.source],a),[b,v]=Al(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=kl((e-y)/(g-y),u),c=wl(m,m,b,b,i),l=wl(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=vl(t[i.id],e),h=o[i.id];d=Math.max(d,Sl(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 _l(e,t,i,n,o,r,s,a,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:bl(s,i),transitOcclusion:Ml(i,n,o,r,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function $l(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Pl(e,t){return e.map(e=>({t:$l(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function jl(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 Il(e,t,i,n,o){if(0===e.length)return null;const r=Pl(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 Ll(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=Pl(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($l(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]=jl(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]=jl(e,c,a);y.push({pathD:g(n,i,r,s),x0:t,x1:o,from:1,to:0})}}}}return y}function Rl(e,t){const i=ll(),n=ll();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 Cl(e,t,i,n="temporal"){const o="temporal"===n?(e,t)=>e.endTime-t.endTime||ul(e.id,t.id):(e,t)=>t.value-e.value||ul(e.id,t.id),r="temporal"===n?(e,t)=>e.startTime-t.startTime||ul(e.id,t.id):(e,t)=>t.value-e.value||ul(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||ul(e.partner,i.partner):e.latestEnd-i.latestEnd||ul(e.partner,i.partner):(e,t)=>t.total-e.total||ul(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 Tl(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)||ul(e.edge?.id??"",t.edge?.id??"")||ul(e.side,t.side)||e.delta-t.delta)},d=a.length?Ms(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 Ol(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=jl(e,a,n),u=jl(s,c,n);o.set(r.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return o}function El(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 Fl(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)||ul(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 Nl(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||ul(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 zl(e){const t=ll();return e.forEach((e,i)=>{for(const n of e.occupants)t[n.id]=i}),t}function Dl(e,t,i){e.splice(0,e.length,...i);const n=zl(i);for(const e of Object.keys(t))delete t[e];Object.assign(t,n)}function Bl(e){const t=/* @__PURE__ */new Map,i=[];e.forEach((e,n)=>{if(!e.group)return void i.push({anchor:n,stableId:dl(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(dl).join("\0")}`,slots:n.slots});return i.sort((e,t)=>e.anchor-t.anchor||ul(e.stableId,t.stableId))}function Wl(e){return e.some(e=>e.group)?Bl(e).flatMap(e=>e.slots):[...e]}function Yl(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 ql(e){return e.flatMap(e=>e.slots)}function Xl(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 Gl(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 Vl(e,t){e.some(e=>e.group)&&Dl(e,t,Wl(e))}function Hl(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost}function Ul({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=Wl(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);Hl(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 Kl(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 Zl(e,t){return cl(t,t=>[e[t.source],e[t.target]],Kl)}function Ql(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 Jl(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 eu(e,t,i,n,o,r,s){const a=[...o],c=new Map(o.map(e=>[e,dl(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])||!Kl(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=fl(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=zl(n),r=n.slice(0,-1).map((e,t)=>A(e,n[t+1])),a=xl(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:Ql(o,t),pixelLength:bl(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+Jl(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+Jl(i,t,u),0),w.fullCrossing++}const c=B(e);return W(a,{...c,transitOcclusion:Ml(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)=>ul(c.get(e),c.get(t)),V=Yl(X),H=e=>{const t=rl(e,d,e=>Y(e).cost,{passes:6,compare:G,maxEvaluations:MM});let i=Y(t),n=MM;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+=Jl(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+=Jl(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:AM(e.length)*(e.length+M.length+O.length))>SM)return t;const i=al(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=Bl(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)||ul(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=ql(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=Bl(e);if(1>=t.length)return ql(t);const i=e=>Y(ql(e)).cost;t=Bl(U(e)),t=Gl(t,d,G),t=rl(t,Xl(t,d),i,{passes:6,compare:(e,t)=>ul(e.stableId,t.stableId),maxEvaluations:MM}),t=sl(t,i,{passes:8,maxEvaluations:MM});const n=t.length>8?1/0:AM(t.length)*(t.length+M.length+O.length);if(SM>=n){const e=al(t,e=>z(ql(e)),{maxItems:8,maxEvaluations:5e4}),i=ql(e),n=ql(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=Gl(t,d,G),ql(t)})(X):U(X);if(!K&&"crossing-min+inside-out"===s.laneOrder&&X.length>1)if(V){const e=Bl(X);let t=Y(ql(e)),i=ql(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)||ul(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=ql(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=Bl(X),t=q(ql(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=ql(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=Gl(Bl(X),d,G),X=ql(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+=Jl(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+=Jl(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=Wl(a);X=Wl(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=Ul({order:X,after:Q,nodes:e,edges:t,outgoingPartners:$,incomingPartners:P,slotForNode:l,averageGap:m,evaluate:q});return X=ee.order,Q=ee.after,Dl(o,r,X),{before:J,after:Q,initialOrder:a.map(e=>c.get(e)),evaluations:w}}function tu(e,t,i){const n=new Map(i.map((e,t)=>[e,t]));Dl(e,t,[...e].sort((e,t)=>(n.get(dl(e))??1/0)-(n.get(dl(t))??1/0)||ul(dl(e),dl(t))))}function iu(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=ll();return n.forEach((e,t)=>{for(const i of e.occupants)o[i.id]=t}),{slots:n,slotByNode:o}}function nu(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 ou(e,t){for(_M.has(e)&&_M.delete(e),_M.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(ll(),t.slotByNode)});_M.size>12;){const e=_M.keys().next().value;if(null==e)break;_M.delete(e)}}function ru(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function su(e,t){return ul(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function au(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 cu(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 lu(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 uu(e,t,i){return!!i.has(e)&&t.some(t=>!lu(e,t,i))}function du(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 hu(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(su(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=su(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)&&(ru(t[n],t[o])||ru(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(su(e,i))||r.has(e)&&r.has(i)&&lu(e,i,r))||!!ru(t[e],t[i])||!(!h.has(e)&&!h.has(i))&&!s.has(su(e,i))}}}function pu(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||ul(e.id,i.id)).map(e=>e.id)}function fu(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))&&!uu(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 yu(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=au(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=du(e,s);r[t].set(i,(r[t].get(i)??0)+n),r[i].set(t,(r[i].get(t)??0)+n)}const a=cu(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=lu(e[i],e[n],a)?o:-o;if(Math.abs(r)>PM&&(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>PM||PM>=Math.abs(e)&&t>PM,g=(e,t,i,n)=>e>i+PM||PM>=Math.abs(e-i)&&t>n+PM;let m=0;for(let i=0;32>i&&$M>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++<$M;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>=$M)break}for(let u=0;e.length-1>u;u++){for(let f=u+1;e.length>f&&m++<$M;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>=$M)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 gu(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 mu(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=au(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=du(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=cu(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]+=lu(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&&gu(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 xu(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 bu(e,t,i,n){const o=nu(e,t,i,n),r=_M.get(o);if(r)return iu(r.slots,i,n);const s=ll();for(const t of e)s[t.id]=xu(i[t.id],n[t.id]);const a=pu(e,s),c=new Map(e.map(e=>[e.id,e])),l=new Map(e.map(e=>[e.id,e.group||void 0])),u=cu(t),d=hu(a,s,n,t,l,u),h=fu(a,d,u),p=mu(a,d,t,{...h,assignment:yu(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=ll();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)=>ul(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)||ul(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 ou(o,x),x}function vu(e){return e.topMass+e.botMass}function wu(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)=>vu(t)<vu(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 ku(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,wu(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>=vu(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})=>vu(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&&vu(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 Au(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=ll(),g=ll();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=ll();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=ll(),v=[],w=[];if(o.frozenSlots){const e=iu(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(dl)}else if("reuse"===c){const n=bu(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});Vl(v,b),0===w.length&&(w=v.map(dl));let k=null;o.frozenSlots||(o.fixedSlotOrder?tu(v,b,o.fixedSlotOrder):o.runOrdering&&l&&"insertion"!==l&&(k=eu(e,t,i,x,v,b,{plotH:r,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:p,domain:f}))),Vl(v,b);const A=xl(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(dl),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:$,lengthAfter:P}}function Su(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=Rl(e,t),g=Cl(e,t,y,o);let m=ll();for(const t of e)m[t.id]=Tl(t,y,g,void 0,u);const x=Au(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)}}Fl(t,g,x.slotByNode),Nl(e,y,g,v),m=ll();for(const t of e)m[t.id]=Tl(t,y,g,void 0,u);const w=Au(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+hl(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=Au(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&&(eu(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=Au(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(dl),lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$})),El(y,g)){const i=Ol(t,m,j.centerlines,P);m=ll();for(const t of e)m[t.id]=Tl(t,y,g,i,u);j=Au(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(dl),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(dl(e))??1/0)-(L.get(dl(t))??1/0)||ul(dl(e),dl(t))),C=ll();R.forEach((e,t)=>{for(const i of e.occupants)C[i.id]=t});const T=xl(e,t,m,R,C,{plotH:n,padding:M,valueScale:P,stackValueScale:$,lanePlacement:"stack",groupPadding:f}),O=ku(e,m,R,C,T.centerlines,P,f),E=_l(Zl(C,t),Ql(C,t),t,O,R,C,T.centerlines,j.laneLifetime,P,T.verticalUtilization,h,p);m=ku(e,m,j.slots,j.slotByNode,j.centerlines,P,f);const F=_l(Zl(j.slotByNode,t),Ql(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 Mu(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 _u(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 $u(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 Pu(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 ju(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 Iu(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 Lu(e){return Math.max(18,11*e.length*.58)}function Ru(e){const t=1.22*Lu(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 Cu(e,t){const i=e.labelX-Lu(e.labelText),n=t.labelX-Lu(t.labelText);return t.labelX+3>=i&&e.labelX+3>=n}function Tu(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)Cu(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)Cu(i[e],i[t])&&(n=Math.min(n,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,n)}}}function Ou(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-Lu(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 Tu(n,i),n}function Eu(e,t,i){const n=e.map(e=>({...e}));for(const e of n){const i=1.22*Lu(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]=Ru(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 Fu(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+Lu(e.labelText):Lu(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 Nu(e){return e.replace(jM,(e,t,i)=>`${i},${t}`)}function zu(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 Du(e){return{...e,pathD:Nu(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Bu(e,t){return"horizontal"===t?e:{...e,pathD:Nu(e.pathD),gradientStubs:e.gradientStubs?.map(Du),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function Wu(e,t){return"horizontal"===t?e:{...e,pathD:Nu(e.pathD),bezier:zu(e.bezier)}}function Yu(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=Jc(t,i,n,{usageMode:b}),{fatal:A,warnings:S}=Qc(k),M=el(i,k,b),_=(0,vM.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 $=Su(t,M,{plotH:w,...u,ribbonLane:s,domain:n}),{centerlines:P,nodeData:j,valueScale:I}=$,L=nt(m,x),R=[],C=[],T=0===a?/* @__PURE__ */new Map:Pu(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,_u(t,P[e.source],i,P[e.target],I,_,s,n,{minRun:a,sourceRunwayStart:T.get(e.id)}))}const F=$u(M,E,T,_,s,O),N=ju(M,F,T,_,e=>n[0]+e/v*(n[1]-n[0])),z=Iu(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=Il(o,P[e.id],I,_,n);if(!a)return;const c=Pl(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=at(b,g,L(b));"string"==typeof e.fill?y=e.fill:null!=e.fill&&vr(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=Ll(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}=Mu(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=Ou(R,$.slotByNode,w).map(e=>Bu(e,d)),W="vertical"===d?Eu(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=Fu(W,o,r,h,{...Y.size>0&&{priorityById:Y},...null!=f&&{maxLabels:f}});return{layout:$,layoutConfig:{bands:q,ribbons:C.map(e=>Wu(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function qu(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 Xu(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,IM.jsxs)("g",{fill:CM,fontSize:10,textAnchor:"end",children:[I&&/* @__PURE__ */ /* @__PURE__ */(0,IM.jsxs)(IM.Fragment,{children:[
186
+ /* @__PURE__ */(0,nM.jsx)("text",{y:0,dominantBaseline:"central",fontSize:r,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&/* @__PURE__ */ /* @__PURE__ */(0,nM.jsxs)("text",{y:.7*r+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}function Ec(e){return Math.max(0,Math.min(1,e))}function Fc(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 Nc(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 zc(e,t,i){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ec(e.offset),color:e.color??i,opacity:null==e.opacity?1:Ec(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=Fc(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=Ec(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=Fc(t.color),l=Fc(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?Nc(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return o(n[n.length-1])}function Dc(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Bc(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=Dc("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(zc(l.stops,e*(t+.5)/i,r||p[0]?.color||"#007bff"));const o=Dc("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=Dc("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=Dc("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 Wc(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 Yc(e=240){const{sweepRad:t,offsetRad:i}=Wc(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]=At(o),[c,l]=At(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 qc(e){return ta(e)}function Xc(e,t,i,n,o,r){const s=Dr(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?Bn(u,l,a??s):void 0,h=Va("string"==typeof o.color?o.color:void 0,s,a,void 0,
187
+ /* @__PURE__ */new Map),p=r??tt(o.valueAccessor??"value"),f=o.styleRules,y=n.pieceStyle;return(e,i)=>{const n={fill:t&&d?zn(e,t,d):h};return f?.length&&Object.assign(n,at(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 Gc(e,t,i,n,o,r="median",s=.8){const a=tt(o.valueAccessor??"value"),c=Xc(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 Vc(e,t,i,n,o){return Gc(e,t,i,n,o,"median",.6)}function Hc(e,t,i,n,o){const r=Xc(e,t,i,n,o),s="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:s,fillOpacity:.8,...r(e,t)})}function Uc(e,t,i,n,o){const r=Xc(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?At(l):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:a?Yn(e,a,c,u):d,fillOpacity:h,...r(e,t)})}function Kc(e="static"){return wM[e]??wM.static}function Zc(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:kM.has(e.kind)?"fatal":"warn"}function Qc(e){const t=[],i=[];for(const n of e)"fatal"===Zc(n)?t.push(n):i.push(n);return{fatal:t,warnings:i}}function Jc(e,t,i,n={}){const o=Kc(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 el(e,t,i="static"){if("strip"!==Kc(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 tl(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 il(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 nl(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 ol(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=nl(r,e),i=nl(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 rl(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 sl(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 al(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 cl(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 ll(){/* @__PURE__ */
188
+ return Object.create(null)}function ul(e,t){return t>e?-1:e>t?1:0}function dl(e){return e.occupants.map(e=>e.id).sort(ul).join("\0")}function hl(e,t,i=0){return e.slice(0,-1).map((n,o)=>null!=n.group&&n.group===e[o+1].group?i:t)}function pl(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 fl(e,t,i){return ol(pl([e,t],i)).adjacentClearance[0]??0}function yl(e,t,i){if(0===e.length)return[];const{padding:n,plotH:o,valueScale:r}=i,s=i.stackValueScale??r,a=hl(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 gl(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 ml(e,t,i,n,o,r,s){const a=e.length;if(0===a)return[];const{padding:c,plotH:l,valueScale:u}=s,d=hl(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 yl(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=gl(a,u),h=gl(c,u);e[i]+=(y[s]+h-d)*l,o[i]+=l,e[s]+=(y[i]+d-h)*l,o[s]+=l}const r=il({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 xl(e,t,i,n,o,r){const s=r.adjacentClearance?[...r.adjacentClearance]:ol(pl(n,i)).adjacentClearance,a=yl(n,s,r);let c="hug"===r.lanePlacement?ml(n,o,t,i,s,a,r):[...a];if("hug"===r.lanePlacement){const i=t=>{const i=ll();for(const n of e)i[n.id]=t[o[n.id]];return i};bl(i(c),t)>bl(i(a),t)+1e-6&&(c=[...a])}const l=ll();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 bl(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 vl(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 wl(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 kl(e,t){let i=0,n=1;for(let o=0;28>o;o++){const o=(i+n)/2;e>wl(0,t,t,1,o)?i=o:n=o}return(i+n)/2}function Al(e,t,i){const n=t+gl(e,i),o=e.value*i/2;return[n-o,n+o]}function Sl(e,t,i,n){return Math.max(0,Math.min(t,n)-Math.max(e,i))/Math.max(1e-9,t-e)}function Ml(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]=Al(p,o[s.source],a),[b,v]=Al(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=kl((e-y)/(g-y),u),c=wl(m,m,b,b,i),l=wl(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=vl(t[i.id],e),h=o[i.id];d=Math.max(d,Sl(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 _l(e,t,i,n,o,r,s,a,c,l,u="both",d){return{crossings:e,weightedLength:t,pixelLength:bl(s,i),transitOcclusion:Ml(i,n,o,r,s,a,{valueScale:c,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:l}}function $l(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Pl(e,t){return e.map(e=>({t:$l(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function jl(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 Il(e,t,i,n,o){if(0===e.length)return null;const r=Pl(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 Ll(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=Pl(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($l(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]=jl(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]=jl(e,c,a);y.push({pathD:g(n,i,r,s),x0:t,x1:o,from:1,to:0})}}}}return y}function Rl(e,t){const i=ll(),n=ll();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 Cl(e,t,i,n="temporal"){const o="temporal"===n?(e,t)=>e.endTime-t.endTime||ul(e.id,t.id):(e,t)=>t.value-e.value||ul(e.id,t.id),r="temporal"===n?(e,t)=>e.startTime-t.startTime||ul(e.id,t.id):(e,t)=>t.value-e.value||ul(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||ul(e.partner,i.partner):e.latestEnd-i.latestEnd||ul(e.partner,i.partner):(e,t)=>t.total-e.total||ul(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 Tl(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)||ul(e.edge?.id??"",t.edge?.id??"")||ul(e.side,t.side)||e.delta-t.delta)},d=a.length?St(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 Ol(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=jl(e,a,n),u=jl(s,c,n);o.set(r.id,{source:(l[0]+l[1])/2,target:(u[0]+u[1])/2})}return o}function El(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 Fl(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)||ul(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 Nl(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||ul(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 zl(e){const t=ll();return e.forEach((e,i)=>{for(const n of e.occupants)t[n.id]=i}),t}function Dl(e,t,i){e.splice(0,e.length,...i);const n=zl(i);for(const e of Object.keys(t))delete t[e];Object.assign(t,n)}function Bl(e){const t=/* @__PURE__ */new Map,i=[];e.forEach((e,n)=>{if(!e.group)return void i.push({anchor:n,stableId:dl(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(dl).join("\0")}`,slots:n.slots});return i.sort((e,t)=>e.anchor-t.anchor||ul(e.stableId,t.stableId))}function Wl(e){return e.some(e=>e.group)?Bl(e).flatMap(e=>e.slots):[...e]}function Yl(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 ql(e){return e.flatMap(e=>e.slots)}function Xl(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 Gl(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 Vl(e,t){e.some(e=>e.group)&&Dl(e,t,Wl(e))}function Hl(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost}function Ul({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=Wl(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);Hl(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 Kl(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 Zl(e,t){return cl(t,t=>[e[t.source],e[t.target]],Kl)}function Ql(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 Jl(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 eu(e,t,i,n,o,r,s){const a=[...o],c=new Map(o.map(e=>[e,dl(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])||!Kl(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=fl(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=zl(n),r=n.slice(0,-1).map((e,t)=>A(e,n[t+1])),a=xl(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:Ql(o,t),pixelLength:bl(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+Jl(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+Jl(i,t,u),0),w.fullCrossing++}const c=B(e);return W(a,{...c,transitOcclusion:Ml(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)=>ul(c.get(e),c.get(t)),V=Yl(X),H=e=>{const t=rl(e,d,e=>Y(e).cost,{passes:6,compare:G,maxEvaluations:MM});let i=Y(t),n=MM;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+=Jl(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+=Jl(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:AM(e.length)*(e.length+M.length+O.length))>SM)return t;const i=al(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=Bl(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)||ul(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=ql(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=Bl(e);if(1>=t.length)return ql(t);const i=e=>Y(ql(e)).cost;t=Bl(U(e)),t=Gl(t,d,G),t=rl(t,Xl(t,d),i,{passes:6,compare:(e,t)=>ul(e.stableId,t.stableId),maxEvaluations:MM}),t=sl(t,i,{passes:8,maxEvaluations:MM});const n=t.length>8?1/0:AM(t.length)*(t.length+M.length+O.length);if(SM>=n){const e=al(t,e=>z(ql(e)),{maxItems:8,maxEvaluations:5e4}),i=ql(e),n=ql(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=Gl(t,d,G),ql(t)})(X):U(X);if(!K&&"crossing-min+inside-out"===s.laneOrder&&X.length>1)if(V){const e=Bl(X);let t=Y(ql(e)),i=ql(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)||ul(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=ql(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=Bl(X),t=q(ql(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=ql(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=Gl(Bl(X),d,G),X=ql(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+=Jl(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+=Jl(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=Wl(a);X=Wl(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=Ul({order:X,after:Q,nodes:e,edges:t,outgoingPartners:$,incomingPartners:P,slotForNode:l,averageGap:m,evaluate:q});return X=ee.order,Q=ee.after,Dl(o,r,X),{before:J,after:Q,initialOrder:a.map(e=>c.get(e)),evaluations:w}}function tu(e,t,i){const n=new Map(i.map((e,t)=>[e,t]));Dl(e,t,[...e].sort((e,t)=>(n.get(dl(e))??1/0)-(n.get(dl(t))??1/0)||ul(dl(e),dl(t))))}function iu(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=ll();return n.forEach((e,t)=>{for(const i of e.occupants)o[i.id]=t}),{slots:n,slotByNode:o}}function nu(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 ou(e,t){for(_M.has(e)&&_M.delete(e),_M.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(ll(),t.slotByNode)});_M.size>12;){const e=_M.keys().next().value;if(null==e)break;_M.delete(e)}}function ru(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function su(e,t){return ul(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function au(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 cu(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 lu(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 uu(e,t,i){return!!i.has(e)&&t.some(t=>!lu(e,t,i))}function du(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 hu(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(su(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=su(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)&&(ru(t[n],t[o])||ru(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(su(e,i))||r.has(e)&&r.has(i)&&lu(e,i,r))||!!ru(t[e],t[i])||!(!h.has(e)&&!h.has(i))&&!s.has(su(e,i))}}}function pu(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||ul(e.id,i.id)).map(e=>e.id)}function fu(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))&&!uu(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 yu(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=au(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=du(e,s);r[t].set(i,(r[t].get(i)??0)+n),r[i].set(t,(r[i].get(t)??0)+n)}const a=cu(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=lu(e[i],e[n],a)?o:-o;if(Math.abs(r)>PM&&(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>PM||PM>=Math.abs(e)&&t>PM,g=(e,t,i,n)=>e>i+PM||PM>=Math.abs(e-i)&&t>n+PM;let m=0;for(let i=0;32>i&&$M>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++<$M;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>=$M)break}for(let u=0;e.length-1>u;u++){for(let f=u+1;e.length>f&&m++<$M;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>=$M)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 gu(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 mu(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=au(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=du(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=cu(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]+=lu(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&&gu(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 xu(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 bu(e,t,i,n){const o=nu(e,t,i,n),r=_M.get(o);if(r)return iu(r.slots,i,n);const s=ll();for(const t of e)s[t.id]=xu(i[t.id],n[t.id]);const a=pu(e,s),c=new Map(e.map(e=>[e.id,e])),l=new Map(e.map(e=>[e.id,e.group||void 0])),u=cu(t),d=hu(a,s,n,t,l,u),h=fu(a,d,u),p=mu(a,d,t,{...h,assignment:yu(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=ll();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)=>ul(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)||ul(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 ou(o,x),x}function vu(e){return e.topMass+e.botMass}function wu(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)=>vu(t)<vu(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 ku(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,wu(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>=vu(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})=>vu(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&&vu(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 Au(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=ll(),g=ll();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=ll();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=ll(),v=[],w=[];if(o.frozenSlots){const e=iu(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(dl)}else if("reuse"===c){const n=bu(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});Vl(v,b),0===w.length&&(w=v.map(dl));let k=null;o.frozenSlots||(o.fixedSlotOrder?tu(v,b,o.fixedSlotOrder):o.runOrdering&&l&&"insertion"!==l&&(k=eu(e,t,i,x,v,b,{plotH:r,padding:s,valueScale:a,groupPadding:h,laneOrder:l,ribbonLane:p,domain:f}))),Vl(v,b);const A=xl(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(dl),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:$,lengthAfter:P}}function Su(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=Rl(e,t),g=Cl(e,t,y,o);let m=ll();for(const t of e)m[t.id]=Tl(t,y,g,void 0,u);const x=Au(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)}}Fl(t,g,x.slotByNode),Nl(e,y,g,v),m=ll();for(const t of e)m[t.id]=Tl(t,y,g,void 0,u);const w=Au(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+hl(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=Au(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&&(eu(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=Au(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(dl),lanePlacement:l,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:$})),El(y,g)){const i=Ol(t,m,j.centerlines,P);m=ll();for(const t of e)m[t.id]=Tl(t,y,g,i,u);j=Au(e,t,m,y,{plotH:n,padding:M,valueScale:P,packing:r,laneOrder:s,lifetimeMode:a,frozenSlots:j.slots,fixedSlotOrder:j.slots.map(dl),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(dl(e))??1/0)-(L.get(dl(t))??1/0)||ul(dl(e),dl(t))),C=ll();R.forEach((e,t)=>{for(const i of e.occupants)C[i.id]=t});const T=xl(e,t,m,R,C,{plotH:n,padding:M,valueScale:P,stackValueScale:$,lanePlacement:"stack",groupPadding:f}),O=ku(e,m,R,C,T.centerlines,P,f),E=_l(Zl(C,t),Ql(C,t),t,O,R,C,T.centerlines,j.laneLifetime,P,T.verticalUtilization,h,p);m=ku(e,m,j.slots,j.slotByNode,j.centerlines,P,f);const F=_l(Zl(j.slotByNode,t),Ql(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 Mu(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 _u(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 $u(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 Pu(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 ju(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 Iu(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 Lu(e){return Math.max(18,11*e.length*.58)}function Ru(e){const t=1.22*Lu(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 Cu(e,t){const i=e.labelX-Lu(e.labelText),n=t.labelX-Lu(t.labelText);return t.labelX+3>=i&&e.labelX+3>=n}function Tu(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)Cu(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)Cu(i[e],i[t])&&(n=Math.min(n,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,n)}}}function Ou(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-Lu(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 Tu(n,i),n}function Eu(e,t,i){const n=e.map(e=>({...e}));for(const e of n){const i=1.22*Lu(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]=Ru(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 Fu(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+Lu(e.labelText):Lu(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 Nu(e){return e.replace(jM,(e,t,i)=>`${i},${t}`)}function zu(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 Du(e){return{...e,pathD:Nu(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Bu(e,t){return"horizontal"===t?e:{...e,pathD:Nu(e.pathD),gradientStubs:e.gradientStubs?.map(Du),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}function Wu(e,t){return"horizontal"===t?e:{...e,pathD:Nu(e.pathD),bezier:zu(e.bezier)}}function Yu(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=Jc(t,i,n,{usageMode:b}),{fatal:A,warnings:S}=Qc(k),M=el(i,k,b),_=(0,vM.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 $=Su(t,M,{plotH:w,...u,ribbonLane:s,domain:n}),{centerlines:P,nodeData:j,valueScale:I}=$,L=nt(m,x),R=[],C=[],T=0===a?/* @__PURE__ */new Map:Pu(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,_u(t,P[e.source],i,P[e.target],I,_,s,n,{minRun:a,sourceRunwayStart:T.get(e.id)}))}const F=$u(M,E,T,_,s,O),N=ju(M,F,T,_,e=>n[0]+e/v*(n[1]-n[0])),z=Iu(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=Il(o,P[e.id],I,_,n);if(!a)return;const c=Pl(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=at(b,g,L(b));"string"==typeof e.fill?y=e.fill:null!=e.fill&&Ar(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=Ll(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}=Mu(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=Ou(R,$.slotByNode,w).map(e=>Bu(e,d)),W="vertical"===d?Eu(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=Fu(W,o,r,h,{...Y.size>0&&{priorityById:Y},...null!=f&&{maxLabels:f}});return{layout:$,layoutConfig:{bands:q,ribbons:C.map(e=>Wu(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function qu(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 Xu(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,IM.jsxs)("g",{fill:CM,fontSize:10,textAnchor:"end",children:[I&&/* @__PURE__ */ /* @__PURE__ */(0,IM.jsxs)(IM.Fragment,{children:[
189
189
  /* @__PURE__ */
190
190
  /* @__PURE__ */(0,IM.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,IM.jsxs)("g",{transform:`translate(${i},${r+4})`,children:[
218
218
  /* @__PURE__ */
219
219
  /* @__PURE__ */(0,IM.jsx)("line",{y2:6,stroke:LM}),
220
220
  /* @__PURE__ */
221
- /* @__PURE__ */(0,IM.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:RM,children:o})]},t)})]})}function Gu(e,t){return"scene"===t?e:e.data}function Vu(e,t,i){return!t?.isActive||t.predicate(Gu(e,i))}function Hu(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 Uu(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 Ku({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=En(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=En(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 Zu(e,t,i={}){return Hs(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function Qu(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 Ju(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 ed(e){const{valueAccessor:t,valueDomain:i,edgeWidthRange:n,resolveStroke:o,edgeOpacity:r,edgeLinecap:s,styleRules:a}=e,c=tt(t);return ct(e=>({stroke:o(e),strokeWidth:Ju(e[t],i,n),strokeLinecap:s,opacity:r,fillOpacity:0}),a,e=>({value:c(e)}))}function td(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=Nn(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=Ss(e))}return e=>({fill:t&&r?En(e,t,r):Xk,fillOpacity:n.fillOpacity,stroke:"#fff",strokeWidth:n.strokeWidth,r:n.sizeBy?Dn(e,n.sizeBy,n.sizeRange,s):n.pointRadius??6})}function id(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function nd(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,XM.scaleSequential)(Cn(i)).domain(s);return{domain:s,colorScale:e=>a(e),valueAccessor:n}}function od(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 rd(e,t){return e===t}function sd(e,t){if("function"==typeof e)return t=>+e(t);const i=e||t;return e=>+e[i]}function ad(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function cd(e,t){return"function"==typeof e?t=>e(t)+"":e?t=>t[e]+"":t?e=>e[t]+"":void 0}function ld(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function ud(e){return"string"==typeof e?e:e.id}function dd(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const i=t_.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 hd(e){return e instanceof Date?e.getTime():"string"==typeof e?dd(e):+e}function pd(e){return new Set(Array.isArray(e)?e:[e])}function fd(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function yd(e,t){return Math.min((e-t.startTime)/t.duration,1)}function gd(e,t,i){return e+(t-e)*i}function md(){return"undefined"!=typeof performance?performance.now():Date.now()}function xd(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 bd(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 vd(e,t,i){if(1>=i)return 1;const n=i-1;return bd({age:n-t,extent:n,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function wd(e){const t=/* @__PURE__ */new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function kd(e,t,i,n=wd(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]=vd(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]=vd(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=vd(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=vd(e,t,o);"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}function Ad(e,t,i){const n=e.duration??500,o=i-t;return n>o?1-o/n:0}function Sd(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=Ad(e,s,r);c>o&&(o=c)}a&&(c=Md(i,o,s)||c);continue}const t=l.get(i.datum);if(null==t)continue;const o=n.get(t);c=Md(i,null==o?0:Ad(e,o,r),s,a)||c}return c}function Md(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 _d(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 $d(e){return[e[0],e[1]]}function Pd(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]=$d(i[e]);const t=o.get(n[e]);t?(s[e]=$d(t),c=t):s[e]=$d(c??r??i[e])}return{prev:s,target:a}}function jd(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 Id(e,t,i){return t.pathIds&&t.pathIds.length===i?t.pathIds:jd(e,t.datum,i)}function Ld(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 Rd(e,t,i,n){n.set(i,"line"!==t.type?{topPath:t.topPath.map($d),bottomPath:t.bottomPath.map($d),pathIds:Id(e,t,t.topPath.length),opacity:t.style?.opacity}:{path:t.path.map($d),pathIds:Id(e,t,t.path.length),opacity:t.style?.opacity})}function Cd(e,t,i){if(!i.path)return!1;const n=Id(e,t,t.path.length),o=i.pathIds;if(o&&n&&o.length===i.path.length&&n.length===t.path.length){const e=Pd(i.path,o,t.path,n);return!(!Ld(e.prev,e.target)&&void 0===t._introClipFraction||(t._targetPath=e.target,t._prevPath=e.prev,t.path=e.prev.map($d),0))}if(i.path.length===t.path.length){t._targetPath=t.path.map($d),t._prevPath=i.path;for(let e=0;t.path.length>e;e++)t.path[e]=$d(i.path[e]);return!0}return!1}function Td(e,t,i){if(!i.topPath||!i.bottomPath)return!1;const n=Id(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=Pd(i.topPath,o,t.topPath,n),r=Pd(i.bottomPath,o,t.bottomPath,n);return!(!Ld(e.prev,e.target)&&!Ld(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($d),t.bottomPath=r.prev.map($d),0))}if(i.topPath.length===t.topPath.length&&i.bottomPath.length===t.bottomPath.length){t._targetTopPath=t.topPath.map($d),t._targetBottomPath=t.bottomPath.map($d),t._prevTopPath=i.topPath,t._prevBottomPath=i.bottomPath;for(let e=0;t.topPath.length>e;e++)t.topPath[e]=$d(i.topPath[e]);for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=$d(i.bottomPath[e]);return!0}return!1}function Od(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?Cd(e,t,i):Td(e,t,i);return t._targetOpacity=t.style.opacity??1,t._startOpacity=i.opacity??t.style.opacity??1,r}function Ed(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($d),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($d),bottomPath:o.bottomPath.map($d),group:n.slice(2),style:{fill:"#999",opacity:o.opacity??1},_targetOpacity:0,_transitionKey:n,datum:null};i.push(e)}return i}function Fd(e,t){if(void 0!==e._targetOpacity&&(e.style={...e.style,opacity:gd(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]=gd(i[o][0],n[o][0],t),e.path[o][1]=gd(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]=gd(i[n][0],o[n][0],t),e.topPath[n][1]=gd(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]=gd(n[i][0],r[i][0],t),e.bottomPath[i][1]=gd(n[i][1],r[i][1],t)}function Nd(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 zd(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 Dd(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Bd(e,t,i,n){i.clear(),n.clear();for(let o=0;t.length>o;o++){const r=t[o],s=zd(e,r,o);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:Dd(r.style)}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:Dd(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:Dd(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:Dd(r.style)}):"line"!==r.type&&"area"!==r.type||Rd(e,r,s,n))}}function Wd(e,t,i,n,o,r=md()){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=zd(e,r,t);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){Od(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(r.style),r.style={...r.style||{},opacity:0},a=!0}const u=Ed(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 Yd(e,t,i,n,o){if(!i.activeTransition)return!1;const r=yd(e,i.activeTransition),s=fd(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=gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.r=gd(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=gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.size=gd(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=gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==i.w&&(e.w=gd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=gd(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:gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==i.w&&(e.w=gd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=gd(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:gd(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=gd(i.x,e._targetX,s),void 0!==i.openY&&(e.openY=gd(i.openY,e._targetOpenY,s)),void 0!==i.closeY&&(e.closeY=gd(i.closeY,e._targetCloseY,s)),void 0!==i.highY&&(e.highY=gd(i.highY,e._targetHighY,s)),void 0!==i.lowY&&(e.lowY=gd(i.lowY,e._targetLowY,s))}}else Fd(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 Nd(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 qd(e){i_[e.chartType]=e}function Xd(e){return i_[e]}function Gd(e){Xd(e)||n_&&(o_.has(e)||(o_.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 Vd(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:i,overlays:n,warned:o}=e;Hd(n)&&0===i.length&&Ud(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)&&Ud(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 Hd(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Hd))}function Ud(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Kd(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 Zd(e,t,i,n){const o=Kd(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 Qd(e){try{return{kind:"success",result:e.run()}}catch(t){const i=e.hasPreviousResult,n=Zd(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 Jd(e,t){const i="function"==typeof e?e:i=>i[e||t];return e=>{const t=i(e);return null==t?NaN:+t}}function eh(e){const t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,n=Jd(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){const i=sd(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:Jd(e.y1Accessor,"y1"),getBottom:Jd(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function th(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 ih(e,t,i,n,o){const r=th(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 nh(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 oh(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 rh(e,t,i,n,o,r,s){const{topPath:a,rawValues:c,datum:l,pathIds:u}=oh(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 sh(e,t,i,n,o,r,s,a,c){return{type:"area",...oh(e,t,i,n,a??(()=>o),c),style:r,group:s}}function ah(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 ch(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 lh(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=ah(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,qa(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 uh(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 dh(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 hh(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 ph(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 fh(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function yh(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=ah(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]=ch(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 gh(e,t,i,n,o,r,s){const[,a]=ih(e,t,i,n,o);return[0,s?a:a+a*r]}function mh(e,t,i,n){const[o,r]=nh(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 xh(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 fh(i,n);const s=r[0],a=r[1],c=r[r.length-1],l=r[r.length-2];return fh("log"===o&&s>0?[s/Math.sqrt(a/s),c*Math.sqrt(c/l)]:[s-(a-s)/2,c+(c-l)/2],n)}function bh(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 vh(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 wh(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 kh(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 Ah(e,t,i){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,r_.scaleLog)().domain(e).range(i).clamp(!0)}return"symlog"===e?(0,r_.scaleSymlog)().domain(t).range(i):"time"===e?(0,r_.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(i):(0,r_.scaleLinear)().domain(t).range(i)}function Sh(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,r_.scaleLinear)().domain(n).range(e),y:Ah(t.yScaleType,o,[i.height-s,s])}}return{x:Ah(t.xScaleType,n,[s,i.width-s]),y:Ah(t.yScaleType,o,[i.height-s,s])}}function Mh(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Fn(e,t):void 0}function _h(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 $h(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=Tn(i.colorScheme,i.themeCategorical,Gk),l=/* @__PURE__ */new Map;for(let e=0;s.length>e;e++)l.set(s[e],Mh(i.colorScheme,s[e])??c[e%c.length]);return{map:l,cache:{key:a,map:l,version:n}}}function Ph(e){const{group:t,colorMapCache:i,groupColorMap:n,groupColorMapCap:o,config:r}=e;let{groupColorCounter:s}=e;const a=Mh(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=Tn(r.colorScheme,r.themeCategorical,Gk);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 jh(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 Ih(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 Lh(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 Rh(e,t,i){t>e.capacity&&(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Ch(e,t){const i=new JM(e.capacity);return e.forEach(()=>i.push(t)),i}function Th(e,t,i,n){const o=e.push(t);return i&&i.push(n),o}function Oh(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 Eh(){return this.updateResults.last}function Fh(){return this.updateResults.last}function Nh(e){return this.updateResults.subscribe(e)}function zh(e){this.config.layoutSelection=e}function Dh(){s_.set(this,!0)}function Bh(){const e=!0===s_.get(this);return s_.delete(this),e}function Wh(e){Object.assign(e.prototype,{getLastUpdateResult:Eh,getUpdateSnapshot:Fh,subscribeUpdateResult:Nh,setLayoutSelection:zh,markStylePaintPending:Dh,consumeStylePaintPending:Bh})}function Yh(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=m_[n]??x_;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function qh(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 Xh(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 Gh(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 Vh(e,t,i,n){if(!e.scales)return null;const{topPath:o,bottomPath:r,datum:s,pathIds:a}=oh(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:Gh(e,n,i,qa(t)),datum:s,group:i,interactive:n.interactive}}function Hh(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 Uh(e,t,i){const n=[];for(const o of i){const i=Vh(e,t,"__ribbon_aggregate",o);i&&n.push(i)}return n}function Kh(e,t,i,n){const o=[];for(const r of n){const n=Vh(e,t,i,r);n&&o.push(n)}return o}function Zh(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=uh(r,e.scales,e.getX,o,s,n,a);c&&i.push(c)}}}function Qh(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function Jh(e){return ta(e)}function ep(e,t,i){if(i)return i;const n=e??"circle";if("chevron"===n)return np(t);const o=Object.prototype.hasOwnProperty.call(M_,n)?M_[n]:S_.symbolCircle;return(0,S_.symbol)(o,Math.max(1,t))()??""}function tp(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function ip(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&&__.has(s))return s;let a=i.get(r);return a||(a=$_[n%$_.length],n++,i.set(r,a)),a}}function np(e){const t=1.5*tp(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 op(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?ip(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=dh(o,e.scales,e.getX,e.getY,Math.PI*c*c,n,t,u);r&&i.push(r)}else{const n=uh(o,e.scales,e.getX,e.getY,c,t,u);n&&i.push(n)}}return i}function rp(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function sp(e){const t=Object.prototype.hasOwnProperty.call(Ok,e)?e:"blues";let i=j_.get(t);if(i)return i;i=Array(P_);const n=Cn(t);for(let e=0;P_>e;e++)i[e]=n(e/255);return j_.set(t,i),i}function ap(e,t,i){const n=i.config.areaStyle?.(t);return n&&("string"==typeof n.fill&&(e.fill=n.fill),e.style=n),e}function cp(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=sd(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||Xa(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:sp("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=rp(c,m,x),p=b?b(c):v[u],_=A?{value:c,showValues:!0,valueFormat:S}:{value:c},$=Ba({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(ap(ph(s*w,(o-1-t)*k,w,k,p,$,_),$,e))}}return M}function lp(){for(const e of Object.keys(I_))Xd(e)||qd({chartType:e,buildScene:I_[e],canvasRenderers:[]})}function up(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 dp(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 hp(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function pp(e){if(!e||2>e.length)return;const t=hp(e[0]),i=hp(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function fp(e){const{count:t,byType:i}=dp(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 yp(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 gp(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(yp(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 mp(e,t){const[i,n]=e.viewBox??T_,[o,r]=e.anchor??O_,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 xp(e,t,i,n){if("none"!==e)return"color"===e||null==e?t??n:"accent"===e?i:e}function bp(e,t,i=0,n="horizontal"){const[o,r]=e.viewBox??T_,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 vp(e,t){const i=mp(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 wp(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 kp(e,t="#4e79a7"){return vr(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Ap(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Sp(e,t,i,n){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const r=mp(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=bp(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?Ap(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:xp(i.fill,a,e.accent),r=t?i.stroke&&"none"!==i.stroke?t:void 0:xp(i.stroke??"none",a,e.accent);return o||r?/* @__PURE__ */ /* @__PURE__ */(0,E_.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__ */
221
+ /* @__PURE__ */(0,IM.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:RM,children:o})]},t)})]})}function Gu(e,t){return"scene"===t?e:e.data}function Vu(e,t,i){return!t?.isActive||t.predicate(Gu(e,i))}function Hu(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 Uu(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 Ku({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=zn(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=zn(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 Zu(e,t,i={}){return Hs(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function Qu(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 Ju(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 ed(e){const{valueAccessor:t,valueDomain:i,edgeWidthRange:n,resolveStroke:o,edgeOpacity:r,edgeLinecap:s,styleRules:a}=e,c=tt(t);return ct(e=>({stroke:o(e),strokeWidth:Ju(e[t],i,n),strokeLinecap:s,opacity:r,fillOpacity:0}),a,e=>({value:c(e)}))}function td(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=Bn(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=At(e))}return e=>({fill:t&&r?zn(e,t,r):Xk,fillOpacity:n.fillOpacity,stroke:"#fff",strokeWidth:n.strokeWidth,r:n.sizeBy?Yn(e,n.sizeBy,n.sizeRange,s):n.pointRadius??6})}function id(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function nd(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,XM.scaleSequential)(En(i)).domain(s);return{domain:s,colorScale:e=>a(e),valueAccessor:n}}function od(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 rd(e,t){return e===t}function sd(e,t){if("function"==typeof e)return t=>+e(t);const i=e||t;return e=>+e[i]}function ad(e,t){if("function"==typeof e)return e;const i=e||t;return e=>e[i]}function cd(e,t){return"function"==typeof e?t=>e(t)+"":e?t=>t[e]+"":t?e=>e[t]+"":void 0}function ld(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function ud(e){return"string"==typeof e?e:e.id}function dd(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const i=t_.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 hd(e){return e instanceof Date?e.getTime():"string"==typeof e?dd(e):+e}function pd(e){return new Set(Array.isArray(e)?e:[e])}function fd(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function yd(e,t){return Math.min((e-t.startTime)/t.duration,1)}function gd(e,t,i){return e+(t-e)*i}function md(){return"undefined"!=typeof performance?performance.now():Date.now()}function xd(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 bd(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 vd(e,t,i){if(1>=i)return 1;const n=i-1;return bd({age:n-t,extent:n,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function wd(e){const t=/* @__PURE__ */new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function kd(e,t,i,n=wd(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]=vd(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]=vd(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=vd(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=vd(e,t,o);"candlestick"===i.type?i._decayOpacity=r:i.style={...i.style,opacity:(i.style?.opacity??1)*r}}}function Ad(e,t,i){const n=e.duration??500,o=i-t;return n>o?1-o/n:0}function Sd(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=Ad(e,s,r);c>o&&(o=c)}a&&(c=Md(i,o,s)||c);continue}const t=l.get(i.datum);if(null==t)continue;const o=n.get(t);c=Md(i,null==o?0:Ad(e,o,r),s,a)||c}return c}function Md(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 _d(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 $d(e){return[e[0],e[1]]}function Pd(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]=$d(i[e]);const t=o.get(n[e]);t?(s[e]=$d(t),c=t):s[e]=$d(c??r??i[e])}return{prev:s,target:a}}function jd(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 Id(e,t,i){return t.pathIds&&t.pathIds.length===i?t.pathIds:jd(e,t.datum,i)}function Ld(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 Rd(e,t,i,n){n.set(i,"line"!==t.type?{topPath:t.topPath.map($d),bottomPath:t.bottomPath.map($d),pathIds:Id(e,t,t.topPath.length),opacity:t.style?.opacity}:{path:t.path.map($d),pathIds:Id(e,t,t.path.length),opacity:t.style?.opacity})}function Cd(e,t,i){if(!i.path)return!1;const n=Id(e,t,t.path.length),o=i.pathIds;if(o&&n&&o.length===i.path.length&&n.length===t.path.length){const e=Pd(i.path,o,t.path,n);return!(!Ld(e.prev,e.target)&&void 0===t._introClipFraction||(t._targetPath=e.target,t._prevPath=e.prev,t.path=e.prev.map($d),0))}if(i.path.length===t.path.length){t._targetPath=t.path.map($d),t._prevPath=i.path;for(let e=0;t.path.length>e;e++)t.path[e]=$d(i.path[e]);return!0}return!1}function Td(e,t,i){if(!i.topPath||!i.bottomPath)return!1;const n=Id(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=Pd(i.topPath,o,t.topPath,n),r=Pd(i.bottomPath,o,t.bottomPath,n);return!(!Ld(e.prev,e.target)&&!Ld(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($d),t.bottomPath=r.prev.map($d),0))}if(i.topPath.length===t.topPath.length&&i.bottomPath.length===t.bottomPath.length){t._targetTopPath=t.topPath.map($d),t._targetBottomPath=t.bottomPath.map($d),t._prevTopPath=i.topPath,t._prevBottomPath=i.bottomPath;for(let e=0;t.topPath.length>e;e++)t.topPath[e]=$d(i.topPath[e]);for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=$d(i.bottomPath[e]);return!0}return!1}function Od(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?Cd(e,t,i):Td(e,t,i);return t._targetOpacity=t.style.opacity??1,t._startOpacity=i.opacity??t.style.opacity??1,r}function Ed(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($d),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($d),bottomPath:o.bottomPath.map($d),group:n.slice(2),style:{fill:"#999",opacity:o.opacity??1},_targetOpacity:0,_transitionKey:n,datum:null};i.push(e)}return i}function Fd(e,t){if(void 0!==e._targetOpacity&&(e.style={...e.style,opacity:gd(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]=gd(i[o][0],n[o][0],t),e.path[o][1]=gd(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]=gd(i[n][0],o[n][0],t),e.topPath[n][1]=gd(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]=gd(n[i][0],r[i][0],t),e.bottomPath[i][1]=gd(n[i][1],r[i][1],t)}function Nd(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 zd(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 Dd(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Bd(e,t,i,n){i.clear(),n.clear();for(let o=0;t.length>o;o++){const r=t[o],s=zd(e,r,o);s&&("point"===r.type?i.set(s,{x:r.x,y:r.y,r:r.r,opacity:Dd(r.style)}):"glyph"===r.type?i.set(s,{x:r.x,y:r.y,r:r.size,opacity:Dd(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:Dd(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:Dd(r.style)}):"line"!==r.type&&"area"!==r.type||Rd(e,r,s,n))}}function Wd(e,t,i,n,o,r=md()){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=zd(e,r,t);if(!s)continue;if(r._transitionKey=s,"line"===r.type||"area"===r.type){Od(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(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=Dd(r.style),r.style={...r.style||{},opacity:0},a=!0}const u=Ed(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 Yd(e,t,i,n,o){if(!i.activeTransition)return!1;const r=yd(e,i.activeTransition),s=fd(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=gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.r=gd(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=gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==e._targetR&&void 0!==i.r&&(e.size=gd(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=gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==i.w&&(e.w=gd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=gd(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:gd(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=gd(i.x,e._targetX,s),e.y=gd(i.y,e._targetY,s),void 0!==i.w&&(e.w=gd(i.w,e._targetW,s)),void 0!==i.h&&(e.h=gd(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:gd(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=gd(i.x,e._targetX,s),void 0!==i.openY&&(e.openY=gd(i.openY,e._targetOpenY,s)),void 0!==i.closeY&&(e.closeY=gd(i.closeY,e._targetCloseY,s)),void 0!==i.highY&&(e.highY=gd(i.highY,e._targetHighY,s)),void 0!==i.lowY&&(e.lowY=gd(i.lowY,e._targetLowY,s))}}else Fd(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 Nd(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 qd(e){i_[e.chartType]=e}function Xd(e){return i_[e]}function Gd(e){Xd(e)||n_&&(o_.has(e)||(o_.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 Vd(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:i,overlays:n,warned:o}=e;Hd(n)&&0===i.length&&Ud(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)&&Ud(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 Hd(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Hd))}function Ud(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Kd(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 Zd(e,t,i,n){const o=Kd(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 Qd(e){try{return{kind:"success",result:e.run()}}catch(t){const i=e.hasPreviousResult,n=Zd(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 Jd(e,t){const i="function"==typeof e?e:i=>i[e||t];return e=>{const t=i(e);return null==t?NaN:+t}}function eh(e){const t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,n=Jd(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){const i=sd(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:Jd(e.y1Accessor,"y1"),getBottom:Jd(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function th(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 ih(e,t,i,n,o){const r=th(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 nh(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 oh(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 rh(e,t,i,n,o,r,s){const{topPath:a,rawValues:c,datum:l,pathIds:u}=oh(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 sh(e,t,i,n,o,r,s,a,c){return{type:"area",...oh(e,t,i,n,a??(()=>o),c),style:r,group:s}}function ah(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 ch(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 lh(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=ah(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,qa(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 uh(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 dh(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 hh(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 ph(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 fh(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function yh(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=ah(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]=ch(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 gh(e,t,i,n,o,r,s){const[,a]=ih(e,t,i,n,o);return[0,s?a:a+a*r]}function mh(e,t,i,n){const[o,r]=nh(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 xh(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 fh(i,n);const s=r[0],a=r[1],c=r[r.length-1],l=r[r.length-2];return fh("log"===o&&s>0?[s/Math.sqrt(a/s),c*Math.sqrt(c/l)]:[s-(a-s)/2,c+(c-l)/2],n)}function bh(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 vh(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 wh(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 kh(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 Ah(e,t,i){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,r_.scaleLog)().domain(e).range(i).clamp(!0)}return"symlog"===e?(0,r_.scaleSymlog)().domain(t).range(i):"time"===e?(0,r_.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(i):(0,r_.scaleLinear)().domain(t).range(i)}function Sh(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,r_.scaleLinear)().domain(n).range(e),y:Ah(t.yScaleType,o,[i.height-s,s])}}return{x:Ah(t.xScaleType,n,[s,i.width-s]),y:Ah(t.yScaleType,o,[i.height-s,s])}}function Mh(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Dn(e,t):void 0}function _h(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 $h(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=Fn(i.colorScheme,i.themeCategorical,Gk),l=/* @__PURE__ */new Map;for(let e=0;s.length>e;e++)l.set(s[e],Mh(i.colorScheme,s[e])??c[e%c.length]);return{map:l,cache:{key:a,map:l,version:n}}}function Ph(e){const{group:t,colorMapCache:i,groupColorMap:n,groupColorMapCap:o,config:r}=e;let{groupColorCounter:s}=e;const a=Mh(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=Fn(r.colorScheme,r.themeCategorical,Gk);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 jh(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 Ih(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 Lh(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 Rh(e,t,i){t>e.capacity&&(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Ch(e,t){const i=new JM(e.capacity);return e.forEach(()=>i.push(t)),i}function Th(e,t,i,n){const o=e.push(t);return i&&i.push(n),o}function Oh(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 Eh(){return this.updateResults.last}function Fh(){return this.updateResults.last}function Nh(e){return this.updateResults.subscribe(e)}function zh(e){this.config.layoutSelection=e}function Dh(){s_.set(this,!0)}function Bh(){const e=!0===s_.get(this);return s_.delete(this),e}function Wh(e){Object.assign(e.prototype,{getLastUpdateResult:Eh,getUpdateSnapshot:Fh,subscribeUpdateResult:Nh,setLayoutSelection:zh,markStylePaintPending:Dh,consumeStylePaintPending:Bh})}function Yh(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=m_[n]??x_;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function qh(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 Xh(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 Gh(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 Vh(e,t,i,n){if(!e.scales)return null;const{topPath:o,bottomPath:r,datum:s,pathIds:a}=oh(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:Gh(e,n,i,qa(t)),datum:s,group:i,interactive:n.interactive}}function Hh(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 Uh(e,t,i){const n=[];for(const o of i){const i=Vh(e,t,"__ribbon_aggregate",o);i&&n.push(i)}return n}function Kh(e,t,i,n){const o=[];for(const r of n){const n=Vh(e,t,i,r);n&&o.push(n)}return o}function Zh(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=uh(r,e.scales,e.getX,o,s,n,a);c&&i.push(c)}}}function Qh(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function Jh(e){return ta(e)}function ep(e,t,i){if(i)return i;const n=e??"circle";if("chevron"===n)return np(t);const o=Object.prototype.hasOwnProperty.call(M_,n)?M_[n]:S_.symbolCircle;return(0,S_.symbol)(o,Math.max(1,t))()??""}function tp(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function ip(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&&__.has(s))return s;let a=i.get(r);return a||(a=$_[n%$_.length],n++,i.set(r,a)),a}}function np(e){const t=1.5*tp(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 op(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?ip(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=dh(o,e.scales,e.getX,e.getY,Math.PI*c*c,n,t,u);r&&i.push(r)}else{const n=uh(o,e.scales,e.getX,e.getY,c,t,u);n&&i.push(n)}}return i}function rp(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function sp(e){const t=Object.prototype.hasOwnProperty.call(Ok,e)?e:"blues";let i=j_.get(t);if(i)return i;i=Array(P_);const n=En(t);for(let e=0;P_>e;e++)i[e]=n(e/255);return j_.set(t,i),i}function ap(e,t,i){const n=i.config.areaStyle?.(t);return n&&("string"==typeof n.fill&&(e.fill=n.fill),e.style=n),e}function cp(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=sd(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||Xa(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:sp("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=rp(c,m,x),p=b?b(c):v[u],_=A?{value:c,showValues:!0,valueFormat:S}:{value:c},$=Ba({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(ap(ph(s*w,(o-1-t)*k,w,k,p,$,_),$,e))}}return M}function lp(){for(const e of Object.keys(I_))Xd(e)||qd({chartType:e,buildScene:I_[e],canvasRenderers:[]})}function up(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 dp(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 hp(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function pp(e){if(!e||2>e.length)return;const t=hp(e[0]),i=hp(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function fp(e){const{count:t,byType:i}=dp(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 yp(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 gp(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(yp(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 mp(e,t){const[i,n]=e.viewBox??T_,[o,r]=e.anchor??O_,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 xp(e,t,i,n){if("none"!==e)return"color"===e||null==e?t??n:"accent"===e?i:e}function bp(e,t,i=0,n="horizontal"){const[o,r]=e.viewBox??T_,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 vp(e,t){const i=mp(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 wp(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 kp(e,t="#4e79a7"){return Ar(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Ap(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Sp(e,t,i,n){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const r=mp(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=bp(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?Ap(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:xp(i.fill,a,e.accent),r=t?i.stroke&&"none"!==i.stroke?t:void 0:xp(i.stroke??"none",a,e.accent);return o||r?/* @__PURE__ */ /* @__PURE__ */(0,E_.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,E_.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("clipPath",{id:l,children:/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},n)}function Mp(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,E_.jsx)("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function _p(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=Mp(i.stops,kp(e.style.fill));return a?/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:n,y1:o,x2:r,y2:s,children:a}):null}function $p(e){const{x:t,y:i,w:n,h:o}=e,{tl:r,tr:s,br:a,bl:c}=wp(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 Pp(e,t,i){const n=ep(e.symbolType,e.size,e.path);/* @__PURE__ */ /* @__PURE__ */
224
- return(0,E_.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?kp(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function jp(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=vr(e.style.fill)?Ar(e.style.fill,s):void 0;/* @__PURE__ */ /* @__PURE__ */
225
- return(0,E_.jsxs)(C_.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("defs",{children:a}),C_.createElement(o,{...r,fill:a?`url(#${s})`:kp(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 Ip(e){if(!1!==e?.interactive)return e?.style?.cursor}function Lp(e,t,i){const n=Ip(t);return n&&null!=e&&!1!==e?/* @__PURE__ */ /* @__PURE__ */(0,N_.jsx)("g",{style:{cursor:n},"data-semiotic-mark-cursor":n,children:e},i):e}function Rp(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 Cp(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=Mp(i.stops,kp(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 Tp(e,t,i,n){if(!e||2>t.length)return null;const o=Mp(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 Op(e,t,i,n=30){const o=Ep(e,t,i,n);return"area"===e.type?o:Lp(o,e,"xy-cursor-"+t)}function Ep(e,t,i,n=30){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o=_r(n.curve),r=o?(0,R_.line)().x(([e])=>e).y(([,e])=>e).curve(o)(n.path)??"":"M"+n.path.map(([e,t])=>`${e},${t}`).join("L"),s=Ap(`${i?i+"-":""}line-${t}-stroke-gradient`),a=Tp(n.strokeGradient,n.path,s,n.style.stroke||"#4e79a7");/* @__PURE__ */ /* @__PURE__ */
224
+ return(0,E_.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?kp(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function jp(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=Ar(e.style.fill)?_r(e.style.fill,s):void 0;/* @__PURE__ */ /* @__PURE__ */
225
+ return(0,E_.jsxs)(C_.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,E_.jsx)("defs",{children:a}),C_.createElement(o,{...r,fill:a?`url(#${s})`:kp(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 Ip(e){if(!1!==e?.interactive)return e?.style?.cursor}function Lp(e,t,i){const n=Ip(t);return n&&null!=e&&!1!==e?/* @__PURE__ */ /* @__PURE__ */(0,N_.jsx)("g",{style:{cursor:n},"data-semiotic-mark-cursor":n,children:e},i):e}function Rp(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 Cp(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=Mp(i.stops,kp(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 Tp(e,t,i,n){if(!e||2>t.length)return null;const o=Mp(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 Op(e,t,i,n=30){const o=Ep(e,t,i,n);return"area"===e.type?o:Lp(o,e,"xy-cursor-"+t)}function Ep(e,t,i,n=30){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const o=jr(n.curve),r=o?(0,R_.line)().x(([e])=>e).y(([,e])=>e).curve(o)(n.path)??"":"M"+n.path.map(([e,t])=>`${e},${t}`).join("L"),s=Ap(`${i?i+"-":""}line-${t}-stroke-gradient`),a=Tp(n.strokeGradient,n.path,s,n.style.stroke||"#4e79a7");/* @__PURE__ */ /* @__PURE__ */
226
226
  return(0,z_.jsxs)(L_.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=_r(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,R_.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=vr(o.style.fill)?Ar(o.style.fill,a):void 0,l=Ap(`${i?i+"-":""}area-${t}-gradient`),u=Cp(o,l),d=u?`url(#${l})`:c?`url(#${a})`:kp(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,p=r?(0,R_.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=Ip(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=Ap(`${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:Tp(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)=>Ap(`${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??kp(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?gp(o.topPath,o.rawValues,o.colorThresholds,kp(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})`:kp(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){const e=`${i?i+"-":""}area-clip-${t}`;/* @__PURE__ */ /* @__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=jr(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,R_.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=Ar(o.style.fill)?_r(o.style.fill,a):void 0,l=Ap(`${i?i+"-":""}area-${t}-gradient`),u=Cp(o,l),d=u?`url(#${l})`:c?`url(#${a})`:kp(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,p=r?(0,R_.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=Ip(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=Ap(`${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:Tp(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)=>Ap(`${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??kp(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?gp(o.topPath,o.rawValues,o.colorThresholds,kp(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})`:kp(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=vr(n.style?.fill)?Ar(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__ */
246
+ return(0,z_.jsx)("rect",{...n},"heatcell-"+t)}case"candlestick":{const n=e,o=`${i?i+"-":""}candle-${t}-hatch`,r=Ar(n.style?.fill)?_r(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)(L_.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)(L_.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 Fp(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 Np(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${e}:${t}`;D_.has(i)||(D_.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function zp(e){const{node:t,index:i,renderMode:n,fallback:o}=e,r=Fp(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:Lp(s,t,`${r.id}-${i}-cursor`),renderedByBackend:!0}:(Np(r.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Dp(e){const t=[];return e.nodes.forEach((i,n)=>{const o=zp({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 Bp(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>Fn(e,t)??"#999"}const n=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:kk;return(0,B_.scaleOrdinal)().domain(e).range(n)}function Wp(e,t,i){if(0===e.length)return;const n=Bp(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:n(e.label)})}]}}function Yp(e){return"left"===e?"start":"right"===e?"end":e??"start"}function qp(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Xp(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Gp(e){return e.typography.legendFontWeight}function Vp(e,t,i,n){const o=qp(n);return t+i+Math.ceil(e.length*o*.58)}function Hp(e){const{categories:t,theme:i,position:n="right",totalWidth:o,margin:r,legendLayout:s}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=w(s),d=a+c,h="top"===n||"bottom"===n,p=Math.max(a,o-r.left-r.right),f=t.map(e=>Vp(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=Yp(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 Up(e){const{legendGroups:t,theme:i,position:n="right",totalWidth:o,margin:r,legendLayout:s}=e,{swatchSize:a,labelGap:c,rowHeight:l}=w(s),u=a+c,d=Math.max(12,qp(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=Yp(s?.align);let r=0,c=0;const l=[];for(const o of t){const t=o.items.map(e=>e.label),u=Hp({...e,categories:t,legendLayout:{...s,maxWidth:Math.max(a,n-d-8),align:"start"}}),h=o.label?d:0,p=o.label?Vp(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=k(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=>Vp(e.label,a,c,i)),o=Math.max(0,...n,e.label?Vp(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 Kp(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?ow:rw,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?nw+108:108,swatchSize:14}}function Zp(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=Bp(t,i,n),l="top"===o||"bottom"===o,d=Hp(e),h={...Wp(t,i,n),legendDistance:e.legendDistance},p=e.reservedWidth??u(h,e.legendLayout),{x:f,y:y}=v(h,{totalWidth:r,totalHeight:s,margin:a,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:p});if(l){const e=d.items.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,W_.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[
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 Fp(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 Np(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${e}:${t}`;D_.has(i)||(D_.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function zp(e){const{node:t,index:i,renderMode:n,fallback:o}=e,r=Fp(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:Lp(s,t,`${r.id}-${i}-cursor`),renderedByBackend:!0}:(Np(r.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function Dp(e){const t=[];return e.nodes.forEach((i,n)=>{const o=zp({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 Bp(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>Dn(e,t)??"#999"}const n=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:kk;return(0,B_.scaleOrdinal)().domain(e).range(n)}function Wp(e,t,i){if(0===e.length)return;const n=Bp(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:n(e.label)})}]}}function Yp(e){return"left"===e?"start":"right"===e?"end":e??"start"}function qp(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Xp(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Gp(e){return e.typography.legendFontWeight}function Vp(e,t,i,n){const o=qp(n);return t+i+Math.ceil(e.length*o*.58)}function Hp(e){const{categories:t,theme:i,position:n="right",totalWidth:o,margin:r,legendLayout:s}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=w(s),d=a+c,h="top"===n||"bottom"===n,p=Math.max(a,o-r.left-r.right),f=t.map(e=>Vp(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=Yp(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 Up(e){const{legendGroups:t,theme:i,position:n="right",totalWidth:o,margin:r,legendLayout:s}=e,{swatchSize:a,labelGap:c,rowHeight:l}=w(s),u=a+c,d=Math.max(12,qp(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=Yp(s?.align);let r=0,c=0;const l=[];for(const o of t){const t=o.items.map(e=>e.label),u=Hp({...e,categories:t,legendLayout:{...s,maxWidth:Math.max(a,n-d-8),align:"start"}}),h=o.label?d:0,p=o.label?Vp(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=k(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=>Vp(e.label,a,c,i)),o=Math.max(0,...n,e.label?Vp(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 Kp(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?ow:rw,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?nw+108:108,swatchSize:14}}function Zp(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=Bp(t,i,n),l="top"===o||"bottom"===o,d=Hp(e),h={...Wp(t,i,n),legendDistance:e.legendDistance},p=e.reservedWidth??u(h,e.legendLayout),{x:f,y:y}=v(h,{totalWidth:r,totalHeight:s,margin:a,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:p});if(l){const e=d.items.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,W_.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[
263
263
  /* @__PURE__ */
264
264
  /* @__PURE__ */(0,W_.jsx)("rect",{width:d.swatchSize,height:d.swatchSize,fill:c(e.category),rx:d.swatchRadius}),
265
265
  /* @__PURE__ */
@@ -331,10 +331,10 @@ return(0,e$.jsx)(gf,{"data-testid":"semiotic-annotation",events:o,...t,type:n},s
331
331
  /* @__PURE__ */
332
332
  /* @__PURE__ */(0,t$.jsx)("style",{children:u$},"annotation-disclosure-style")),r&&a.unshift(
333
333
  /* @__PURE__ */
334
- /* @__PURE__ */(0,t$.jsx)("style",{children:d$},"annotation-cohesion-style")),a}function Af(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:kf(o),renderedAnnotations:o.map(e=>e.annotation)}}function Sf(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 Mf(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 _f(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 $f(e){return null==e?null:e+""}function Pf(e){return $f(e.provenance?.stableId??e.stableId)}function jf(e){return $f(e.stableId??e.id??e.provenance?.stableId)}function If(e,t,i){return t.stickyPositionCache?.set(e,i),i}function Lf(e,t,i){const n=Pf(e);if(!n)return null;const o=i.pointNodes?.find(e=>$f(e.pointId)===n);if(o)return If(t,i,{x:o.x,y:o.y});const r=i.data?.find(e=>jf(e)===n);if(!r)return null;const s=Sf(r,i),a=Mf(r,i);return null==s||null==a?null:If(t,i,{x:s,y:a})}function Rf(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 If(t,i,{x:o.x,y:o.y})}const n=_f(i);return n?If(t,i,n):null}if("semantic"===n){const n=Lf(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=Sf(e,i),r=Mf(e,i)),null!=o&&null!=r)return If(t,i,{x:o,y:r});if("sticky"===n){const e=i.stickyPositionCache?.get(t);if(e)return e}return null}function Cf(e,t,i,n=50){return!(-n>e||e>(i.width||0)+n||-n>t||t>(i.height||0)+n)}function Tf(e){return"string"==typeof e?.type?e.type:""}function Of(e){return!!e&&"object"==typeof e&&h$.has(Tf(e))}function Ef(e){return"primary"===e?.emphasis||!0===e?.defensive}function Ff(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:p$))):1/0}function Nf(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 zf(e){const{annotations:t,width:i,height:n}=e,o=Math.max(0,e.minVisible??f$),r=Ff(i,n,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(i=e,Of(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=>Ef(e.annotation)),l=a.filter(e=>!Ef(e.annotation)).sort((e,t)=>Nf(t.annotation)-Nf(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 Df(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:v$,dy:w$}}function Bf(e){const t=e?.familiarity;if(!t)return S$;const i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?S$:i.reduce((e,t)=>e+t,0)/i.length}function Wf(e){if(!e)return 1;const t=Bf(e);return t>2?4>t?1:.6:1.5}function Yf(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(M$,t.source)?M$[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 qf(e,t){let i=!1;const n=e.map(e=>Vf(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(i=!0,{...e,cohesion:t}):e);return i?n:e}function Xf(e){if(!Vf(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 Gf(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)<k$?e:{...e,_redundantConnector:!0}}function Vf(e){return Of(e)}function Hf(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t=uf(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=[...df("string"==typeof e.title?e.title:void 0,i,7),...df("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 Uf(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 Kf(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Zf(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 Qf(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 Jf(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 ey(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 ty(e,t,i,n,o,r,s,a){const c=Kf(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*Qf(c,o,r,a);for(const e of i)l+=12*Zf(c,e);for(const e of n)l+=4*Zf(c,e);return l}function iy(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?Rf(e,t,i):{x:e.x,y:e.y}}function ny(e){const{annotations:t,context:i,defaultOffset:n=y$,notePadding:o=g$,markPadding:r=m$,edgePadding:s=x$,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=b$,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??A$,w=!!f&&v>=m,k=w&&!1!==b.preferShortText?t.map(Xf):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=ey(i,r);let j=!1;const I=k.map((e,t)=>{if(!Vf(e))return e;const r=iy(e,t,i);if(!r)return e;const u=Hf(!0===e.defensive?Yf(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=Df(e);return $.push(Kf(Uf(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 Jf(n)){const t=ty(Uf(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=Kf(Uf(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=Gf(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=Yf(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=Wf(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Ff(m,x,e))*t))},{deferred:n}=zf({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:A$)>=m)for(const e of R)Vf(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)),_?qf(T,_):T}function oy(e,t,i,n){const o=Sr(e.fill??e.color,t,n);return Mr(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:n)??o}function ry(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 sy(e,t,i){const n=e.position,o="string"==typeof 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 ay(e,t,i,n){return{...sy(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 cy({annotation:e,width:t,height:i,defaults:n=P$}){const o=e.label??e.text;return null==o?null:/* @__PURE__ */ /* @__PURE__ */(0,$$.jsx)("text",{...ay(e,t,i,n),children:o})}function ly(e){const t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}function uy(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function dy(e,t={}){const i=ly(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(n){const o=uy(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 hy(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 py(e,t,i){switch(e.type){case"enclose":{const n=(e.coordinates||[]).map(e=>({x:Sf({...e,type:"point"},i),y:Mf({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const o=(0,j$.packEnclose)(n),r=e.padding||10;/* @__PURE__ */ /* @__PURE__ */
334
+ /* @__PURE__ */(0,t$.jsx)("style",{children:d$},"annotation-cohesion-style")),a}function Af(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:kf(o),renderedAnnotations:o.map(e=>e.annotation)}}function Sf(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 Mf(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 _f(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 $f(e){return null==e?null:e+""}function Pf(e){return $f(e.provenance?.stableId??e.stableId)}function jf(e){return $f(e.stableId??e.id??e.provenance?.stableId)}function If(e,t,i){return t.stickyPositionCache?.set(e,i),i}function Lf(e,t,i){const n=Pf(e);if(!n)return null;const o=i.pointNodes?.find(e=>$f(e.pointId)===n);if(o)return If(t,i,{x:o.x,y:o.y});const r=i.data?.find(e=>jf(e)===n);if(!r)return null;const s=Sf(r,i),a=Mf(r,i);return null==s||null==a?null:If(t,i,{x:s,y:a})}function Rf(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 If(t,i,{x:o.x,y:o.y})}const n=_f(i);return n?If(t,i,n):null}if("semantic"===n){const n=Lf(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=Sf(e,i),r=Mf(e,i)),null!=o&&null!=r)return If(t,i,{x:o,y:r});if("sticky"===n){const e=i.stickyPositionCache?.get(t);if(e)return e}return null}function Cf(e,t,i,n=50){return!(-n>e||e>(i.width||0)+n||-n>t||t>(i.height||0)+n)}function Tf(e){return"string"==typeof e?.type?e.type:""}function Of(e){return!!e&&"object"==typeof e&&h$.has(Tf(e))}function Ef(e){return"primary"===e?.emphasis||!0===e?.defensive}function Ff(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:p$))):1/0}function Nf(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 zf(e){const{annotations:t,width:i,height:n}=e,o=Math.max(0,e.minVisible??f$),r=Ff(i,n,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(i=e,Of(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=>Ef(e.annotation)),l=a.filter(e=>!Ef(e.annotation)).sort((e,t)=>Nf(t.annotation)-Nf(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 Df(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:v$,dy:w$}}function Bf(e){const t=e?.familiarity;if(!t)return S$;const i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?S$:i.reduce((e,t)=>e+t,0)/i.length}function Wf(e){if(!e)return 1;const t=Bf(e);return t>2?4>t?1:.6:1.5}function Yf(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(M$,t.source)?M$[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 qf(e,t){let i=!1;const n=e.map(e=>Vf(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(i=!0,{...e,cohesion:t}):e);return i?n:e}function Xf(e){if(!Vf(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 Gf(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)<k$?e:{...e,_redundantConnector:!0}}function Vf(e){return Of(e)}function Hf(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t=uf(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=[...df("string"==typeof e.title?e.title:void 0,i,7),...df("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 Uf(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 Kf(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Zf(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 Qf(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 Jf(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 ey(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 ty(e,t,i,n,o,r,s,a){const c=Kf(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*Qf(c,o,r,a);for(const e of i)l+=12*Zf(c,e);for(const e of n)l+=4*Zf(c,e);return l}function iy(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?Rf(e,t,i):{x:e.x,y:e.y}}function ny(e){const{annotations:t,context:i,defaultOffset:n=y$,notePadding:o=g$,markPadding:r=m$,edgePadding:s=x$,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=b$,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??A$,w=!!f&&v>=m,k=w&&!1!==b.preferShortText?t.map(Xf):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=ey(i,r);let j=!1;const I=k.map((e,t)=>{if(!Vf(e))return e;const r=iy(e,t,i);if(!r)return e;const u=Hf(!0===e.defensive?Yf(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=Df(e);return $.push(Kf(Uf(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 Jf(n)){const t=ty(Uf(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=Kf(Uf(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=Gf(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=Yf(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=Wf(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Ff(m,x,e))*t))},{deferred:n}=zf({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:A$)>=m)for(const e of R)Vf(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)),_?qf(T,_):T}function oy(e,t,i,n){const o=$r(e.fill??e.color,t,n);return Pr(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:n)??o}function ry(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 sy(e,t,i){const n=e.position,o="string"==typeof 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 ay(e,t,i,n){return{...sy(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 cy({annotation:e,width:t,height:i,defaults:n=P$}){const o=e.label??e.text;return null==o?null:/* @__PURE__ */ /* @__PURE__ */(0,$$.jsx)("text",{...ay(e,t,i,n),children:o})}function ly(e){const t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}function uy(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}function dy(e,t={}){const i=ly(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(n){const o=uy(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 hy(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 py(e,t,i){switch(e.type){case"enclose":{const n=(e.coordinates||[]).map(e=>({x:Sf({...e,type:"point"},i),y:Mf({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>n.length)return null;const o=(0,j$.packEnclose)(n),r=e.padding||10;/* @__PURE__ */ /* @__PURE__ */
335
335
  return(0,L$.jsxs)("g",{children:[
336
336
  /* @__PURE__ */
337
- /* @__PURE__ */(0,L$.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,L$.jsx)(sf,{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:Sf({...e,type:"point"},i),y:Mf({...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]=Ss(n.map(e=>e.x)),[a,c]=Ss(n.map(e=>e.y)),l=r-o,u=s+o,d=a-o;/* @__PURE__ */ /* @__PURE__ */
337
+ /* @__PURE__ */(0,L$.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,L$.jsx)(sf,{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:Sf({...e,type:"point"},i),y:Mf({...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]=At(n.map(e=>e.x)),[a,c]=At(n.map(e=>e.y)),l=r-o,u=s+o,d=a-o;/* @__PURE__ */ /* @__PURE__ */
338
338
  return(0,L$.jsxs)("g",{children:[
339
339
  /* @__PURE__ */
340
340
  /* @__PURE__ */(0,L$.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,L$.jsx)(sf,{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,C$.jsxs)("g","horizontal"===i.projection?{children:[
372
372
  return(0,C$.jsx)(mf,{noteData:{x:l,y:u,dx:h,dy:p,note:lf(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,C$.jsx)("g",{children:/* @__PURE__ */ /* @__PURE__ */(0,C$.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 wy(e,t,i,n="right",o,r){if(null==e||!1===e)return null;const{x:s,y:a}=v(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:n,legendLayout:o,axisChrome:r});/* @__PURE__ */ /* @__PURE__ */
374
374
  return(0,O$.jsx)("g",{transform:`translate(${s}, ${a})`,children:e})}function ky(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 Ay(e,t){if(0===t.categories.length)return;const i=t.position||"right";b(e,{legend:Wp(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function Sy(e,t){b(e,{legend:t.legend,position:t.position||"right",size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}function My(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function _y(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function $y(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 Py(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function jy(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:Py(e)}}}function Iy(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 Ly(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 Ry(e,t,i){return"exact"===i?Ly(e,t):e.ticks(t)}function Cy(e){return"string"==typeof e||"number"==typeof e}function Ty(e){const{label:t,x:i,y:n,textAlign:o,fontSize:r,fontFamily:s,color:a}=e;/* @__PURE__ */ /* @__PURE__ */
375
- return(0,F$.jsx)("foreignObject",{x:i,y:n,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */ /* @__PURE__ */(0,F$.jsx)("div",{style:{color:a,fontFamily:s,fontSize:r,textAlign:o,userSelect:"none"},children:t})})}function Oy(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ey(e,t){const i=Oy(e);if(!i)return!1;const n=Oy(t);return!n||i.getFullYear()!==n.getFullYear()||i.getMonth()!==n.getMonth()}function Fy(e,t,i,n){return!!e&&("function"==typeof e?e(t.value,i):Ey(t.value,i>0?n[i-1].value:void 0))}function Ny(e,t){return e?.ticks??e?.tickCount??t}function zy(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 Dy(e){const t=new Date(e instanceof Date?e.valueOf():e);return`${N$[t.getUTCMonth()]} ${t.getUTCDate()}`}function By(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}:D$>t?Dy:5*D$>t?e=>{const t=new Date(e instanceof Date?e.valueOf():e);return`${N$[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function Wy(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function Yy(e){for(let t=1;e.length>t;t++){const i=e[t-1],n=e[t];if(Math.abs(n.pixel-i.pixel)<(Wy(i.label)+Wy(n.label))/2+8)return!0}return!1}function qy(e){const{scale:i,axis:n,size:o,horizontal:r=!1,axisExtent:s}=e,a=n?.extent??s,c=i.domain(),l=Ny(n,5),u=Math.max(2,Math.floor(o/(r?70:30))),d="exact"===a?Math.max(2,l):Math.min(l,u),h=n?.tickValues??Ry(i,d,a),p=h.map(e=>e.valueOf()),f=n?.tickFormat||e.format||(c[0]instanceof Date||h[0]instanceof Date?By([c[0].valueOf(),c[c.length-1].valueOf()]):t(p)),y=(e,t)=>r?f(e,t,p):f(e),g=h.map((e,t)=>({value:e,pixel:i(e),label:y(e,t)}));let m=22;if(r){const e=g.reduce((e,t)=>Math.max(e,Wy(t.label)),0);m=n?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=zy(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})),n?.includeMax&&x.length>0&&"exact"!==a&&!n.tickValues){const e=c[c.length-1];if(null!=e){const t=i(e),n=Math.abs(t-x[x.length-1].pixel);if(n>1){const i=y(e,x.length);m>n&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:t,label:i}]}}}return x}function Xy(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Gy(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 Vy(e,t,n){return i(e.showLegend&&!e.__legendIncludesAutomatic?Wp(t,e.colorScheme,n):void 0,e.legend)}function Hy(e,t){if(e.__autoLegendMargin)return W$[t]}function Uy(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:n(e)||o(e)?e.legendDistance:void 0};return n(e)?Qp({...i,legendGroups:e.legendGroups}):o(e)?Jp({...i,gradient:e.gradient}):null}function Ky(e,t){const{props:i,categories:n,theme:o,size:r,hasTitle:s}=t,a=i.legendPosition||"right",l={...e},u={theme:o,position:a,size:r,hasTitle:s,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:Hy(i,a)};if(null!=i.legend){const t=Vy(i,n,o);null!=t&&!1!==t&&Sy(e,{...u,legend:t})}else i.showLegend&&n.length>0&&Ay(e,{...u,categories:n,colorScheme:i.colorScheme});return c(e,l,r,a),a}function Zy(e){const{props:t,categories:i,theme:r,size:s,margin:a,hasTitle:c}=e,l=t.legendPosition||"right",u={theme:r,position:l,size:s,margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){const e=Vy(t,i,r);return E$.isValidElement(e)?wy(e,s,a,l,t.legendLayout,t.axisChrome):Uy(e,u)||(n(e)||o(e)?null:wy(e??null,s,a,l,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?Zp({categories:i,colorScheme:t.colorScheme,theme:r,position:l,totalWidth:s[0],totalHeight:s[1],margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function Qy(e,t,i,n,o,r){const s=e.scales;if(!s||"radial"===s.projection)return null;const{grid:a}=Nr(i),c=n?n+"-":"",l="vertical"===s.projection,u=r??Ry(s.r,5,o);/* @__PURE__ */ /* @__PURE__ */
375
+ return(0,F$.jsx)("foreignObject",{x:i,y:n,width:60,height:24,style:{overflow:"visible"},children:/* @__PURE__ */ /* @__PURE__ */(0,F$.jsx)("div",{style:{color:a,fontFamily:s,fontSize:r,textAlign:o,userSelect:"none"},children:t})})}function Oy(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ey(e,t){const i=Oy(e);if(!i)return!1;const n=Oy(t);return!n||i.getFullYear()!==n.getFullYear()||i.getMonth()!==n.getMonth()}function Fy(e,t,i,n){return!!e&&("function"==typeof e?e(t.value,i):Ey(t.value,i>0?n[i-1].value:void 0))}function Ny(e,t){return e?.ticks??e?.tickCount??t}function zy(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 Dy(e){const t=new Date(e instanceof Date?e.valueOf():e);return`${N$[t.getUTCMonth()]} ${t.getUTCDate()}`}function By(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}:D$>t?Dy:5*D$>t?e=>{const t=new Date(e instanceof Date?e.valueOf():e);return`${N$[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function Wy(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function Yy(e){for(let t=1;e.length>t;t++){const i=e[t-1],n=e[t];if(Math.abs(n.pixel-i.pixel)<(Wy(i.label)+Wy(n.label))/2+8)return!0}return!1}function qy(e){const{scale:i,axis:n,size:o,horizontal:r=!1,axisExtent:s}=e,a=n?.extent??s,c=i.domain(),l=Ny(n,5),u=Math.max(2,Math.floor(o/(r?70:30))),d="exact"===a?Math.max(2,l):Math.min(l,u),h=n?.tickValues??Ry(i,d,a),p=h.map(e=>e.valueOf()),f=n?.tickFormat||e.format||(c[0]instanceof Date||h[0]instanceof Date?By([c[0].valueOf(),c[c.length-1].valueOf()]):t(p)),y=(e,t)=>r?f(e,t,p):f(e),g=h.map((e,t)=>({value:e,pixel:i(e),label:y(e,t)}));let m=22;if(r){const e=g.reduce((e,t)=>Math.max(e,Wy(t.label)),0);m=n?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=zy(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})),n?.includeMax&&x.length>0&&"exact"!==a&&!n.tickValues){const e=c[c.length-1];if(null!=e){const t=i(e),n=Math.abs(t-x[x.length-1].pixel);if(n>1){const i=y(e,x.length);m>n&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:t,label:i}]}}}return x}function Xy(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Gy(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 Vy(e,t,n){return i(e.showLegend&&!e.__legendIncludesAutomatic?Wp(t,e.colorScheme,n):void 0,e.legend)}function Hy(e,t){if(e.__autoLegendMargin)return W$[t]}function Uy(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:n(e)||o(e)?e.legendDistance:void 0};return n(e)?Qp({...i,legendGroups:e.legendGroups}):o(e)?Jp({...i,gradient:e.gradient}):null}function Ky(e,t){const{props:i,categories:n,theme:o,size:r,hasTitle:s}=t,a=i.legendPosition||"right",l={...e},u={theme:o,position:a,size:r,hasTitle:s,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:Hy(i,a)};if(null!=i.legend){const t=Vy(i,n,o);null!=t&&!1!==t&&Sy(e,{...u,legend:t})}else i.showLegend&&n.length>0&&Ay(e,{...u,categories:n,colorScheme:i.colorScheme});return c(e,l,r,a),a}function Zy(e){const{props:t,categories:i,theme:r,size:s,margin:a,hasTitle:c}=e,l=t.legendPosition||"right",u={theme:r,position:l,size:s,margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){const e=Vy(t,i,r);return E$.isValidElement(e)?wy(e,s,a,l,t.legendLayout,t.axisChrome):Uy(e,u)||(n(e)||o(e)?null:wy(e??null,s,a,l,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?Zp({categories:i,colorScheme:t.colorScheme,theme:r,position:l,totalWidth:s[0],totalHeight:s[1],margin:a,hasTitle:c,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function Qy(e,t,i,n,o,r){const s=e.scales;if(!s||"radial"===s.projection)return null;const{grid:a}=Br(i),c=n?n+"-":"",l="vertical"===s.projection,u=r??Ry(s.r,5,o);/* @__PURE__ */ /* @__PURE__ */
376
376
  return(0,B$.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,B$.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,B$.jsx)("line",{x1:n,y1:0,x2:n,y2:t.height,stroke:a,strokeWidth:.5},"gr-"+i)})})}function Jy(e,t){const i=Nr(t.theme),n=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,s=t.idPrefix?ky(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__ */
378
+ return(0,B$.jsx)("line",{x1:n,y1:0,x2:n,y2:t.height,stroke:a,strokeWidth:.5},"gr-"+i)})})}function Jy(e,t){const i=Br(t.theme),n=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,s=t.idPrefix?ky(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,B$.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,B$.jsx)("title",{id:a,children:r}),t.description&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("desc",{id:c,children:t.description}),t.defs&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("defs",{children:t.defs}),n&&"transparent"!==n&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:n}),
380
380
  /* @__PURE__ */
381
- /* @__PURE__ */(0,B$.jsx)("g",{id:o+"data-area",transform:t.innerTransform,children:e}),r&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("text",{id:o+"chart-title",x:t.width/2,y:Hv,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:r}),t.legend&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function eg(t,i,n,o,r,s,a,c=!1){const l=Nr(o),u=n.legendPosition??"right",d=h(n.legendLayout,a?.leftAxis),p=h(n.legendLayout,a?.rightAxis),f=c&&"left"===u&&d>0?d:s?.left??n.margin?.left??40,y=c&&"right"===u&&p>0?p:s?.right??n.margin?.right??40,{xAxis:g,yAxis:m,xOrient:x,yOrient:b}=e(n.axes),v="top"===x?0:i.height,w="right"===b?i.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=qy({scale:t.x,axis:g,size:i.width,horizontal:!0,format:n.xFormat||n.tickFormatTime,axisExtent:n.axisExtent}),M=qy({scale:t.y,axis:m,size:i.height,format:n.yFormat||n.tickFormatValue,axisExtent:n.axisExtent}),_=!(!g?.autoRotate||!Yy(S)),$=$y(S),P=$y(M),j=g?.label??n.xLabel,I=m?.label??("right"===b?n.yLabelRight??n.yLabel:n.yLabel),L=jy(g?.axisStyle,{stroke:l.border,strokeWidth:1}),R=jy(m?.axisStyle,{stroke:l.border,strokeWidth:1}),C="right"===b?i.width+y-15:15-f;/* @__PURE__ */ /* @__PURE__ */
381
+ /* @__PURE__ */(0,B$.jsx)("g",{id:o+"data-area",transform:t.innerTransform,children:e}),r&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("text",{id:o+"chart-title",x:t.width/2,y:Hv,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:r}),t.legend&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function eg(t,i,n,o,r,s,a,c=!1){const l=Br(o),u=n.legendPosition??"right",d=h(n.legendLayout,a?.leftAxis),p=h(n.legendLayout,a?.rightAxis),f=c&&"left"===u&&d>0?d:s?.left??n.margin?.left??40,y=c&&"right"===u&&p>0?p:s?.right??n.margin?.right??40,{xAxis:g,yAxis:m,xOrient:x,yOrient:b}=e(n.axes),v="top"===x?0:i.height,w="right"===b?i.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=qy({scale:t.x,axis:g,size:i.width,horizontal:!0,format:n.xFormat||n.tickFormatTime,axisExtent:n.axisExtent}),M=qy({scale:t.y,axis:m,size:i.height,format:n.yFormat||n.tickFormatValue,axisExtent:n.axisExtent}),_=!(!g?.autoRotate||!Yy(S)),$=$y(S),P=$y(M),j=g?.label??n.xLabel,I=m?.label??("right"===b?n.yLabelRight??n.yLabel:n.yLabel),L=jy(g?.axisStyle,{stroke:l.border,strokeWidth:1}),R=jy(m?.axisStyle,{stroke:l.border,strokeWidth:1}),C="right"===b?i.width+y-15:15-f;/* @__PURE__ */ /* @__PURE__ */
382
382
  return(0,B$.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[!1!==g?.visible&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsxs)("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==g?.baseline&&!g?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("line",{x1:0,y1:v,x2:i.width,y2:v,...L}),g?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("path",{d:Iy(x,i.width,i.height),fill:"none",...L}),S.map((e,t)=>{const i=Fy(g?.landmarkTicks,e,t,S);/* @__PURE__ */ /* @__PURE__ */
383
383
  return(0,B$.jsxs)("g",{transform:`translate(${e.pixel},${v})`,children:[
384
384
  /* @__PURE__ */
385
385
  /* @__PURE__ */(0,B$.jsx)("line",{y2:5*k,...L}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("text",{y:k*(_?12:18),textAnchor:_?"end":My(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}):Ty({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,B$.jsx)("text",{x:i.width/2,y:"top"===x?-(_?58:40):i.height+(_?58:40),textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,children:j})]}),!1!==m?.visible&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsxs)("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==m?.baseline&&!m?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("line",{x1:w,y1:0,x2:w,y2:i.height,...R}),m?.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("path",{d:Iy(b,i.width,i.height),fill:"none",...R}),M.map((e,t)=>{const i=Fy(m?.landmarkTicks,e,t,M);/* @__PURE__ */ /* @__PURE__ */
386
386
  return(0,B$.jsxs)("g",{transform:`translate(${w},${e.pixel})`,children:[
387
387
  /* @__PURE__ */
388
- /* @__PURE__ */(0,B$.jsx)("line",{x2:5*A,...R}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:_y(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}):Ty({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,B$.jsx)("text",{x:C,y:i.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${C}, ${i.height/2})`,children:I})]})]})}function tg(e,t,i,n,o,r,s){const{grid:a}=Nr(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=qy({scale:e.x,axis:p,size:t.width,horizontal:!0,format:s?.xFormat||s?.tickFormatTime,axisExtent:o}),g=qy({scale:e.y,axis:f,size:t.height,format:s?.yFormat||s?.tickFormatValue,axisExtent:o}),m=!1!==p?.grid,x=!1!==f?.grid,b=Py(p?.gridStyle),v=Py(f?.gridStyle),w=jy(p?.gridStyle,{stroke:a,strokeWidth:.5}),k=jy(f?.gridStyle,{stroke:a,strokeWidth:.5});/* @__PURE__ */ /* @__PURE__ */
389
- return(0,Y$.jsxs)("g",{id:c+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,Y$.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,Y$.jsx)("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}function ig(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 ng(e,t,i,n){return"function"==typeof e?e({size:t,margin:i,scales:n}):e}function og(e){return V$.has(e)?G$:X$}function rg(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=Nr(o),d=qy({scale:t.y,axis:s,size:i.height,format:n.yFormat||n.tickFormatValue,axisExtent:n.axisExtent}),p=$y(d),f=s.label??n.yLabelRight,y=jy(s.axisStyle,{stroke:u.border,strokeWidth:1}),g=n.legendPosition??"right",m=h(n.legendLayout,c?.rightAxis),x=i.width+(l&&"right"===g&&m>0?m:a.right)-15;/* @__PURE__ */ /* @__PURE__ */
388
+ /* @__PURE__ */(0,B$.jsx)("line",{x2:5*A,...R}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,B$.jsx)("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:_y(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}):Ty({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,B$.jsx)("text",{x:C,y:i.height/2,textAnchor:"middle",fontSize:l.labelSize,fill:l.text,fontFamily:l.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${C}, ${i.height/2})`,children:I})]})]})}function tg(e,t,i,n,o,r,s){const{grid:a}=Br(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=qy({scale:e.x,axis:p,size:t.width,horizontal:!0,format:s?.xFormat||s?.tickFormatTime,axisExtent:o}),g=qy({scale:e.y,axis:f,size:t.height,format:s?.yFormat||s?.tickFormatValue,axisExtent:o}),m=!1!==p?.grid,x=!1!==f?.grid,b=Py(p?.gridStyle),v=Py(f?.gridStyle),w=jy(p?.gridStyle,{stroke:a,strokeWidth:.5}),k=jy(f?.gridStyle,{stroke:a,strokeWidth:.5});/* @__PURE__ */ /* @__PURE__ */
389
+ return(0,Y$.jsxs)("g",{id:c+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>/* @__PURE__ */ /* @__PURE__ */(0,Y$.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,Y$.jsx)("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}function ig(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 ng(e,t,i,n){return"function"==typeof e?e({size:t,margin:i,scales:n}):e}function og(e){return V$.has(e)?G$:X$}function rg(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=Br(o),d=qy({scale:t.y,axis:s,size:i.height,format:n.yFormat||n.tickFormatValue,axisExtent:n.axisExtent}),p=$y(d),f=s.label??n.yLabelRight,y=jy(s.axisStyle,{stroke:u.border,strokeWidth:1}),g=n.legendPosition??"right",m=h(n.legendLayout,c?.rightAxis),x=i.width+(l&&"right"===g&&m>0?m:a.right)-15;/* @__PURE__ */ /* @__PURE__ */
390
390
  return(0,H$.jsxs)("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==s.baseline&&!s.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,H$.jsx)("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...y}),s.jaggedBase&&/* @__PURE__ */ /* @__PURE__ */(0,H$.jsx)("path",{d:Iy("right",i.width,i.height),fill:"none",...y}),d.map((e,t)=>{const n=Fy(s.landmarkTicks,e,t,d);/* @__PURE__ */ /* @__PURE__ */
391
391
  return(0,H$.jsxs)("g",{transform:`translate(${i.width},${e.pixel})`,children:[
392
392
  /* @__PURE__ */
393
- /* @__PURE__ */(0,H$.jsx)("line",{x2:5,...y}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,H$.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:_y(s.tickAnchor,e.pixel===p.min,e.pixel===p.max),fontWeight:n?600:400,fontSize:n?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ty({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),f&&/* @__PURE__ */ /* @__PURE__ */(0,H$.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:f})]})}function sg(e,t){const i=Fr(e.theme),n=e.size||[500,300],o=a({...q$,...e.margin},e.title),s=r(e.title),c=ig(Gs(e.data),e.lineDataAccessor),l=e.showLegend?ef(c,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],u=y({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});Ky(o,{props:{...e,axisChrome:u},categories:l,theme:i,size:n,hasTitle:s});const d=Zy({props:{...e,axisChrome:u},categories:l,theme:i,size:n,margin:o,hasTitle:s}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),g=e.colorScheme||i.colors.categorical,m=(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:m,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:ta(e.gradientFill),lineGradient:ia(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:g,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:Or(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 A_(x);e.data&&b.ingest({inserts:c,bounded:!0}),b.computeScene({width:h,height:p});const v=ng(e.backgroundGraphics,n,o,b.scales),w=ng(e.foregroundGraphics,n,o,b.scales),k=ya(e.annotations),A=k?`${e.description||e.title||"Line chart."}${k}`:e.description;if(!b.scales){let r;const s=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:h,height:p},theme:i,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=fp({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})),QM.renderToStaticMarkup(Jy(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,U$.jsxs)(U$.Fragment,{children:[v,s,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=Dp({nodes:b.scene,renderMode:e.renderMode,fallback:(t,i)=>Op(t,i,S,e.hoverRadius??30)}),_=!b.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:By(b.scales.x.domain().map(e=>e.valueOf()))},$=e.showGrid?tg(b.scales,{width:h,height:p},i,S,e.axisExtent,e.axes,_):null,P=M.map(e=>e.element),j=Gy(e)+"-plot-clip",I=!1!==e.showAxes,L=I?eg(b.scales,{width:h,height:p},_,i,S,o,u,!!d):null,R=I?rg({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?by({annotations:e.annotations,margin:o,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,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=fp({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:pp(b.scales.x?.domain?.()),yDomain:pp(b.scales.y?.domain?.()),legendItems:l.length>0?l.length:void 0,margin:o}));const O=e.svgPreRenderers&&b.scales?e.svgPreRenderers.map((e,t)=>{try{/* @__PURE__ */ /* @__PURE__ */
393
+ /* @__PURE__ */(0,H$.jsx)("line",{x2:5,...y}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,H$.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:_y(s.tickAnchor,e.pixel===p.min,e.pixel===p.max),fontWeight:n?600:400,fontSize:n?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ty({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),f&&/* @__PURE__ */ /* @__PURE__ */(0,H$.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:f})]})}function sg(e,t){const i=Dr(e.theme),n=e.size||[500,300],o=a({...q$,...e.margin},e.title),s=r(e.title),c=ig(Gs(e.data),e.lineDataAccessor),l=e.showLegend?ef(c,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],u=y({showAxes:e.showAxes,xLabel:e.xLabel,yLabel:e.yLabel,yLabelRight:e.yLabelRight,axes:e.axes});Ky(o,{props:{...e,axisChrome:u},categories:l,theme:i,size:n,hasTitle:s});const d=Zy({props:{...e,axisChrome:u},categories:l,theme:i,size:n,margin:o,hasTitle:s}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),g=e.colorScheme||i.colors.categorical,m=(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:m,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:ta(e.gradientFill),lineGradient:ia(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:g,themeCategorical:i.colors.categorical,themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging,themeSemantic:Nr(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 A_(x);e.data&&b.ingest({inserts:c,bounded:!0}),b.computeScene({width:h,height:p});const v=ng(e.backgroundGraphics,n,o,b.scales),w=ng(e.foregroundGraphics,n,o,b.scales),k=ya(e.annotations),A=k?`${e.description||e.title||"Line chart."}${k}`:e.description;if(!b.scales){let r;const s=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:h,height:p},theme:i,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=fp({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})),QM.renderToStaticMarkup(Jy(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,U$.jsxs)(U$.Fragment,{children:[v,s,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=Dp({nodes:b.scene,renderMode:e.renderMode,fallback:(t,i)=>Op(t,i,S,e.hoverRadius??30)}),_=!b.xIsDate||e.xFormat||e.tickFormatTime?e:{...e,xFormat:By(b.scales.x.domain().map(e=>e.valueOf()))},$=e.showGrid?tg(b.scales,{width:h,height:p},i,S,e.axisExtent,e.axes,_):null,P=M.map(e=>e.element),j=Gy(e)+"-plot-clip",I=!1!==e.showAxes,L=I?eg(b.scales,{width:h,height:p},_,i,S,o,u,!!d):null,R=I?rg({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?by({annotations:e.annotations,margin:o,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,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=fp({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:pp(b.scales.x?.domain?.()),yDomain:pp(b.scales.y?.domain?.()),legendItems:l.length>0?l.length:void 0,margin:o}));const O=e.svgPreRenderers&&b.scales?e.svgPreRenderers.map((e,t)=>{try{/* @__PURE__ */ /* @__PURE__ */
394
394
  return(0,U$.jsx)(ZM.Fragment,{children:e(b.scene,b.scales,{width:h,height:p})},"pre-"+t)}catch{return null}}).filter(Boolean):null;return QM.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,U$.jsxs)(U$.Fragment,{children:[v,O,$,
395
395
  /* @__PURE__ */
396
396
  /* @__PURE__ */(0,U$.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,U$.jsx)("clipPath",{id:j,children:/* @__PURE__ */ /* @__PURE__ */(0,U$.jsx)("rect",{x:0,y:0,width:h,height:p})})}),
397
397
  /* @__PURE__ */
398
- /* @__PURE__ */(0,U$.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 ag(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 cg({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?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);/* @__PURE__ */ /* @__PURE__ */
398
+ /* @__PURE__ */(0,U$.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 ag(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 cg({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,Z$.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,Z$.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,Z$.jsx)("filter",{id:"chain-shadow-"+a,x:"-20%",y:"-20%",width:"140%",height:"150%",children:/* @__PURE__ */ /* @__PURE__ */(0,Z$.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,Z$.jsxs)("g",{children:[
426
426
  /* @__PURE__ */
427
427
  /* @__PURE__ */(0,Z$.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,Z$.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 lg(e,t=0){if(e instanceof Date)return e.getTime();const i=Number(e);return Number.isFinite(i)?i:t}function ug(e){if(null==e.completionTime)return null;const t=lg(e.completionTime,NaN);return Number.isFinite(t)?t:null}function dg(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 hg(e,t,i,n){const o=e.nodes.map(ug).filter(e=>null!=e),r=o.length?Math.min(...o)-1:0,s="replay"!==t||n?i:r,a=/* @__PURE__ */new Set,c=/* @__PURE__ */new Map;for(const i of e.nodes){const e=ug(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:dg(e,l,c,a),blockers:c,previewTaskID:null}}function pg(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 fg(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 yg(e,t,i){return xd(i,e,t)}function gg(e,t){return t>e?-1:e>t?1:0}function mg(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function xg(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function bg(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function vg(e){const t=[],i=/* @__PURE__ */new Map,n=[],o=/* @__PURE__ */new Set;e.data.forEach((r,s)=>{const a=(yg(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=(yg(r,s,e.laneAccessor)??"Unassigned")+"";o.has(c)||(o.add(c),n.push(c));const l=yg(r,s,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(l,e=>e+""))).sort(gg),d=yg(r,s,e.blockerAccessor),h=yg(r,s,e.statusAccessor)??(d?"blocked":"waiting");i.set(a,{id:a,label:(yg(r,s,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:s,datum:r,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:yg(r,s,e.startAccessor),end:yg(r,s,e.endAccessor),progress:bg(yg(r,s,e.progressAccessor)),status:h,completionTime:yg(r,s,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!yg(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:mg(n,e.id),sourceID:n,targetID:e.id,sourceIndex:r.index,targetIndex:e.index,socketID:xg(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)=>gg(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=xg(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>gg(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(gg);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(gg);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 wg(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)=>gg(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 kg(e,t,i={}){const n=new Set(i.completedTaskIDs??[]),o=[...fg(pg(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 Ag(e){return e.__composite}function Sg(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function Mg(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=kg(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 _g(e,t,i,n,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:n,rest:o}}}function $g(e){return e.__composite}function Pg(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function jg(e,t){return Math.max(1,Math.floor(Pg(e,t)))}function Ig(e,t,i,n){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${n}"`)}function Lg(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 Rg(e,t){return("function"==typeof t?t(e):e[t])+""}function Cg(e,t,i,n){if(!t)return{categories:[],color:()=>Xk};const o=Array.from(new Set(e.map(e=>Rg(e,t)))),r="string"==typeof t?t:"__semioticSplomColor",s=Nn("function"==typeof t?e.map(e=>({...e,[r]:Rg(e,t)})):e,r,i??n.colors.categorical);return{categories:o,color:e=>En(e,t,s)}}function Tg(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:KM.renderToStaticMarkup(
429
+ /* @__PURE__ */(0,Z$.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 lg(e,t=0){if(e instanceof Date)return e.getTime();const i=Number(e);return Number.isFinite(i)?i:t}function ug(e){if(null==e.completionTime)return null;const t=lg(e.completionTime,NaN);return Number.isFinite(t)?t:null}function dg(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 hg(e,t,i,n){const o=e.nodes.map(ug).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=ug(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:dg(e,l,c,a),blockers:c,previewTaskID:null}}function pg(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 fg(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 yg(e,t,i){return xd(i,e,t)}function gg(e,t){return t>e?-1:e>t?1:0}function mg(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function xg(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function bg(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function vg(e){const t=[],i=/* @__PURE__ */new Map,n=[],o=/* @__PURE__ */new Set;e.data.forEach((r,s)=>{const a=(yg(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=(yg(r,s,e.laneAccessor)??"Unassigned")+"";o.has(c)||(o.add(c),n.push(c));const l=yg(r,s,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(l,e=>e+""))).sort(gg),d=yg(r,s,e.blockerAccessor),h=yg(r,s,e.statusAccessor)??(d?"blocked":"waiting");i.set(a,{id:a,label:(yg(r,s,e.labelAccessor)??a)+"",lane:c,laneIndex:0,level:0,index:s,datum:r,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:yg(r,s,e.startAccessor),end:yg(r,s,e.endAccessor),progress:bg(yg(r,s,e.progressAccessor)),status:h,completionTime:yg(r,s,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!yg(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:mg(n,e.id),sourceID:n,targetID:e.id,sourceIndex:r.index,targetIndex:e.index,socketID:xg(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)=>gg(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=xg(e.targetID,t)});for(const e of c.values())e.sort((e,t)=>gg(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(gg);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(gg);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 wg(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)=>gg(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 kg(e,t,i={}){const n=new Set(i.completedTaskIDs??[]),o=[...fg(pg(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 Ag(e){return e.__composite}function Sg(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function Mg(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=kg(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 _g(e,t,i,n,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:n,rest:o}}}function $g(e){return e.__composite}function Pg(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function jg(e,t){return Math.max(1,Math.floor(Pg(e,t)))}function Ig(e,t,i,n){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${n}"`)}function Lg(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 Rg(e,t){return("function"==typeof t?t(e):e[t])+""}function Cg(e,t,i,n){if(!t)return{categories:[],color:()=>Xk};const o=Array.from(new Set(e.map(e=>Rg(e,t)))),r="string"==typeof t?t:"__semioticSplomColor",s=Bn("function"==typeof t?e.map(e=>({...e,[r]:Rg(e,t)})):e,r,i??n.colors.categorical);return{categories:o,color:e=>zn(e,t,s)}}function Tg(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:KM.renderToStaticMarkup(
430
430
  /* @__PURE__ */
431
431
  /* @__PURE__ */(0,J$.jsx)("svg",{x:l,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:/* @__PURE__ */ /* @__PURE__ */(0,J$.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?Rg(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,J$.jsx)("rect",{x:t/r*o,y:o-l-s,width:Math.max(o/r-1,1),height:s,fill:a?c(n[0]):Xk,opacity:.6},`${t}-${e}`)})});return{visibleBars:m,svg:KM.renderToStaticMarkup(
432
432
  /* @__PURE__ */
@@ -437,7 +437,7 @@ return(0,oP.jsx)("g",{className:"semiotic-radial-center-content",transform:`tran
437
437
  /* @__PURE__ */
438
438
  /* @__PURE__ */(0,IP.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)?`${Qg(c)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:Qg(c);7.8*o.length+16>d&&(o=Qg(c)),7.8*o.length+16>d||n.push(
439
439
  /* @__PURE__ */
440
- /* @__PURE__ */(0,IP.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,IP.jsx)("g",{children:n},t+"-funnel-labels"):null}function em(e,t,i){return Lp(tm(e,t,i),e,"ordinal-cursor-"+t)}function tm(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=Ap(r)+"-grad",n=_p(t,i);let o,a;if(n)a=`url(#${i})`;else if(vr(t.style.fill)){const e=Ap(r)+"-hatch";o=Ar(t.style.fill,e),a=`url(#${e})`}else a=kp(t.style.fill);const c=n||o?/* @__PURE__ */ /* @__PURE__ */(0,IP.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=$p(t);/* @__PURE__ */ /* @__PURE__ */
440
+ /* @__PURE__ */(0,IP.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,IP.jsx)("g",{children:n},t+"-funnel-labels"):null}function em(e,t,i){return Lp(tm(e,t,i),e,"ordinal-cursor-"+t)}function tm(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=Ap(r)+"-grad",n=_p(t,i);let o,a;if(n)a=`url(#${i})`;else if(Ar(t.style.fill)){const e=Ap(r)+"-hatch";o=_r(t.style.fill,e),a=`url(#${e})`}else a=kp(t.style.fill);const c=n||o?/* @__PURE__ */ /* @__PURE__ */(0,IP.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=$p(t);/* @__PURE__ */ /* @__PURE__ */
441
441
  return(0,IP.jsxs)($P.Fragment,{children:[c,
442
442
  /* @__PURE__ */
443
443
  /* @__PURE__ */(0,IP.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,IP.jsxs)("g","vertical"===t.projection?{children:[
489
489
  /* @__PURE__ */(0,IP.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,IP.jsx)("g",{children:i},r)}case"connector":{const t=e,i=t.style.fill&&"none"!==t.style.fill?kp(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";/* @__PURE__ */ /* @__PURE__ */
491
491
  return(0,IP.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,IP.jsx)("polygon",{points:i,fill:kp(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},r)}default:return null}var s}function im(e){return"connector"===e.node.type}function nm(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=Ap(`${t?t+"-":""}connector-${i}-${n}-hatch`),a=vr(r)?Ar(r,s):null,c=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return Lp(/* @__PURE__ */ /* @__PURE__ */(0,LP.jsxs)(_P.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,LP.jsx)("defs",{children:a}),
492
+ return(0,IP.jsx)("polygon",{points:i,fill:kp(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},r)}default:return null}var s}function im(e){return"connector"===e.node.type}function nm(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=Ap(`${t?t+"-":""}connector-${i}-${n}-hatch`),a=Ar(r)?_r(r,s):null,c=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return Lp(/* @__PURE__ */ /* @__PURE__ */(0,LP.jsxs)(_P.Fragment,{children:[a&&/* @__PURE__ */ /* @__PURE__ */(0,LP.jsx)("defs",{children:a}),
493
493
  /* @__PURE__ */
494
494
  /* @__PURE__ */(0,LP.jsx)("polygon",{points:c,fill:a?`url(#${s})`:kp(r,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${n}`)}function om(e,t,i){const n=/* @__PURE__ */new Map;for(const t of e){if(!im(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,LP.jsxs)("g",{children:[nm(e,t,i,n),e.map(e=>e.element)]},`ordinal-connectors-${i}-${n}`)),r=e[0],s=im(r)?null:r.element;for(const e of n.values())for(const t of e)t.element=null;r.element=/* @__PURE__ */ /* @__PURE__ */(0,LP.jsxs)(_P.Fragment,{children:[o,s]},"ordinal-connector-run-"+i)}function rm(e){const t=Dp({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>em(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++;om(t.slice(n,o),e.idPrefix,i++),n=o}return t}function sm(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,RP.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&/* @__PURE__ */ /* @__PURE__ */(0,RP.jsx)("rect",{width:a,height:a,fill:i}),
496
496
  /* @__PURE__ */
497
497
  /* @__PURE__ */(0,RP.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:n,strokeWidth:o}),
498
498
  /* @__PURE__ */
499
- /* @__PURE__ */(0,RP.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:n,strokeWidth:o})]},t)}function am(e,i,n,o,r,s,a,c=!1){const l=e.scales;if(!l)return null;if("radial"===l.projection)return null;const u=Nr(o),d="vertical"===l.projection,p=e.columns,f=n.categoryFormat||n.oFormat,y=n.valueFormat||n.rFormat,g=n.categoryLabel||n.oLabel,m=n.valueLabel||n.rLabel,x=n.legendPosition??"right",b=h(n.legendLayout,a?.leftAxis),v=c&&"left"===x&&b>0?b:s?.left??n.margin?.left??40,w=Object.values(p).map((e,t)=>({pixel:e.middle,label:f?f(e.name,t):e.name})),k=n.rTickValues??Ry(l.r,5,n.axisExtent),A=y||t(k),S=k.map(e=>({pixel:l.r(e),label:A(e)}));/* @__PURE__ */ /* @__PURE__ */
499
+ /* @__PURE__ */(0,RP.jsx)("line",{x1:r,y1:0,x2:r,y2:a,stroke:n,strokeWidth:o})]},t)}function am(e,i,n,o,r,s,a,c=!1){const l=e.scales;if(!l)return null;if("radial"===l.projection)return null;const u=Br(o),d="vertical"===l.projection,p=e.columns,f=n.categoryFormat||n.oFormat,y=n.valueFormat||n.rFormat,g=n.categoryLabel||n.oLabel,m=n.valueLabel||n.rLabel,x=n.legendPosition??"right",b=h(n.legendLayout,a?.leftAxis),v=c&&"left"===x&&b>0?b:s?.left??n.margin?.left??40,w=Object.values(p).map((e,t)=>({pixel:e.middle,label:f?f(e.name,t):e.name})),k=n.rTickValues??Ry(l.r,5,n.axisExtent),A=y||t(k),S=k.map(e=>({pixel:l.r(e),label:A(e)}));/* @__PURE__ */ /* @__PURE__ */
500
500
  return(0,CP.jsxs)("g",d?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[
501
501
  /* @__PURE__ */
502
502
  /* @__PURE__ */(0,CP.jsx)("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)("g",{transform:`translate(${e.pixel},${i.height})`,children:[
@@ -517,29 +517,29 @@ return(0,CP.jsxs)("g",d?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",childre
517
517
  /* @__PURE__ */
518
518
  /* @__PURE__ */(0,CP.jsx)("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[
519
519
  /* @__PURE__ */
520
- /* @__PURE__ */(0,CP.jsx)("line",{x2:-5,stroke:u.border,strokeWidth:1}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ty({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:g})]})}function cm(e,t){const i=Fr(e.theme),n=e.size||[500,400],o=a({...q$,...e.margin},e.title),s=r(e.title),c=Gs(e.data),l=e.showLegend?ef(c,e.colorAccessor||e.stackBy||e.groupBy):[],u=g({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Ky(o,{props:{...e,axisChrome:u},categories:l,theme:i,size:n,hasTitle:s});const d=Zy({props:{...e,axisChrome:u},categories:l,theme:i,size:n,margin:o,hasTitle:s}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f=e.projection||"vertical",y="radial"===f,m=e.colorScheme||i.colors.categorical,x={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:ta(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:m,themeCategorical:i.colors.categorical,themeSemantic:Or(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors},b=new MP(x);e.data&&b.ingest({inserts:c,bounded:!0}),b.computeScene({width:h,height:p});const v=ng(e.backgroundGraphics,n,o,b.scales),w=ng(e.foregroundGraphics,n,o,b.scales);if(!b.scales){let r;const s=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:h,height:p},theme:i,projection:f,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=fp({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})),sP.renderToStaticMarkup(Jy(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)(CP.Fragment,{children:[v,s,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?Qy(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=Gy(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)=>sm({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=rm({nodes:b.scene,renderMode:e.renderMode,idPrefix:k}),_=M.map(e=>e.element),$=!1!==e.showAxes?am(b,{width:h,height:p},e,i,k,o,u,!!d):null;let P;const j=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,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=fp({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:pp(b.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:o})}const I=y&&e.centerContent?Og(e.centerContent,o.left+h/2,o.top+p/2):null,L=y&&e.centerContent?I??/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("foreignObject",{x:o.left,y:o.top,width:h,height:p,pointerEvents:"none",children:/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,R=/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)(CP.Fragment,{children:[A,_,$,j,w,b.customLayoutOverlays]});return sP.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)(CP.Fragment,y?{children:[v?/* @__PURE__ */ /* @__PURE__ */(0,CP.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 lm({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 um(e,t){OP[e]=t}function dm(e){return OP[e]}function hm(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function pm(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 fm(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=pm(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 ym(e){return e.y0-e.y1>0?"up":"down"}function gm(e,t){return t(e.source)==t(e.target)}function mm(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 xm(e){return e.target.x0-e.source.x1}function bm(e,t){var i=wm(e),n=xm(t)/Math.tan(i);return"up"==ym(e)?e.y1-n:e.y1+n}function vm(e,t){var i=wm(e),n=xm(t)/Math.tan(i);return"up"==ym(e)?e.y1+n:e.y1-n}function wm(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function km(e,t){return t(e)}function Am(e){return Mm(e.source)}function Sm(e){return Mm(e.target)}function Mm(e){return(e.y0+e.y1)/2}function _m(e){return e.virtual?0:e.value}function $m(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!gm(e,t)?i+1:i});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!gm(e,t)?n+1:n}),i+n}function Pm(e){return e.target.depth}function jm(e,t){return e.sourceLinks.length?e.depth:t-1}function Im(e,t){return e.y0-t.y0}function Lm(e,t){return t.y0-e.y0}function Rm(e,t){return e.y1-t.y1}function Cm(e,t){return t.y1-e.y1}function Tm(e,t){return Em(e.source,t.source)||e.index-t.index}function Om(e,t){return Em(e.target,t.target)||e.index-t.index}function Em(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Fm(e,t){return Nm(e)==Nm(t)?"bottom"==e.circularLinkType?Lm(e,t):Im(e,t):Nm(t)-Nm(e)}function Nm(e){return e.target.column-e.source.column}function zm(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 km(i.source,t)==km(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(!Bm(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=bm(t,e);return e.y1-i}if(t.target.column>e.target.column)return bm(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 Dm(e,t){let i=e;return i.nodes.forEach(function(e){var n=i.links.filter(function(i){return km(i.target,t)==km(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(!Bm(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=vm(t,e);return e.y0-i}if(t.source.column>e.source.column)return vm(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 Bm(e,t){return Wm(e)==Wm(t)}function Wm(e){return e.y0-e.y1>0?"up":"down"}function Ym(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 qm(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,EP.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}),Xm(r.links.filter(function(e){return"top"==e.circularLinkType}),t,i),Xm(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,gm(e,t)&&mm(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?Lm:Im);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?Cm:Rm),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?Vm(e):Ym(e)}),r}function Xm(e,t,i){e.sort(Fm);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(gm(e,t)&&mm(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&&Gm(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 Gm(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Vm(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 Hm(e){return function(){return e}}function Um(e){return e.index}function Km(e){return e.nodes}function Zm(e){return e.links}function Qm(e,t){var i=/* @__PURE__ */new Map;return(0,FP.group)(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function Jm(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=Qm(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=hm(i,n)),"object"!=typeof o&&(o=e.target=hm(i,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}function ex(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=fm(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 tx(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){km(e,t)!=km(o.source,t)&&km(e,t)!=km(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),gm(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function ix(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,FP.sum)(e.sourceLinks,_m),(0,FP.sum)(e.targetLinks,_m)),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 nx(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 ox(e,t,i){var n=(0,FP.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,FP.min)(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,FP.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var r=(0,FP.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 rx(e,t,i){var n=(0,FP.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+=Mm(e.source)*t,n+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Mm(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?$m(t,i)-$m(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==$m(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 sx(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&&$m(o,i)>0){var c=(0,FP.mean)(o.sourceLinks,Sm),l=(0,FP.mean)(o.targetLinks,Am),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-Mm(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,FP.mean)(o.sourceLinks,Sm),p=(0,FP.mean)(o.targetLinks,Am),f=((h&&p?(h+p)/2:h||p)-Mm(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||Em),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,FP.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 ax(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Om),e.targetLinks.sort(Tm)}),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 cx(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,FP.min)(t,function(e){return e.y0}),s=(0,FP.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 lx(){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,Jm(e,l),ex(e,d),tx(e,l),ix(e),nx(e,d,u);var t=a;if(null!==c){var f=(0,FP.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,FP.max)(f,function(e){return e.length});y>1&&(t=Math.max(1,(r-n)*c/(y-1)))}ox(e,t,s),rx(e,d,l),sx(e,d,l,t,t,h),ax(e),qm(e,l,p,10,8),rx(e,d,l),sx(e,d,l,t,t,h),ax(e),qm(e,l,p,10,8),zm(e,l),Dm(e,l),cx(e),qm(e,l,p,10,8)}var i=0,n=0,o=1,r=1,s=24,a=8,c=null,l=Um,u=jm,d=void 0,h=32,p=2,f=Km,y=Zm;return e.update=function(e){return ax(e),qm(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:Hm(t),e):f},e.links=function(t){return arguments.length?(y="function"==typeof t?t:Hm(t),e):y},e.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Hm(t),e):l},e.nodeAlign=function(t){return arguments.length?(u="function"==typeof t?t:Hm(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 ux(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 dx(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let i=WP.get(e);if(i){const e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,WP.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}`;BP.has(e)||(BP.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 hx(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]=Ss(o);if(r===s)return()=>(n[0]+n[1])/2;const a=(0,GP.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 px(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 fx(e,t,i){const n=[];for(const o of t){const t=ud(o.source),r=ud(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 yx(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 gx(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 mx(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 xx(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 bx(e){const[t,i,n]=xx(e);return.299*t+.587*i+.114*n>150?"#222":"#fff"}function vx(e){if(e)return"function"==typeof e?e:t=>t[e]}function wx(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 kx(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 Ax(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:JP}function Sx(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 Mx(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(dx(t,"nodeStyle"));let a=r.fill||Sx(i);if(i.colorByDepth&&void 0!==t.depth){const e=Ax(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=Px(o,s,c,p,l),g=r(dx(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=kx(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 _x(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(dx(i,"nodeStyle"));let a=s.fill||Sx(t);if(t.colorByDepth&&void 0!==i.depth){const e=Ax(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=kx(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(dx(a,"nodeStyle")).fill||Sx(t);if(t.colorByDepth&&void 0!==a.depth){const e=Ax(t);d=e[a.depth%e.length]}const h="string"==typeof d?bx(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 $x(e,t,i,n){const o=[],r=[];for(const i of e){const e=i.__radius??5;if(0>=e)continue;const r=n(dx(i,"nodeStyle"));let s=r.fill||Sx(t);if(t.colorByDepth&&void 0!==i.depth){const e=Ax(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=kx(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(dx(o,"nodeStyle")).fill||Sx(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ax(t);c=e[o.depth%e.length]}if(a){const i="string"==typeof c?bx(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 Px(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 jx(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,QP.tree)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Ix(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,QP.cluster)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Lx(e,t,i,n){const o=t.padding??4,r=t.paddingTop??0,s=(0,QP.treemap)().size([i,n]).tile(QP.treemapBinary).padding(o);r>0&&s.paddingTop(r),s(e)}function Rx(e,t,i,n){const o=t.padding??4;(0,QP.pack)().size([i,n]).padding(o)(e)}function Cx(e,t,i,n){(0,QP.partition)().size([i,n]).padding(t.padding??1)(e)}function Tx(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 Ox(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 Ex(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 Fx(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 Nx(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function zx(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}function Dx(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}function Bx(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 Wx(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=zx(i.childrenAccessor),a=Dx(i.nodeIDAccessor),c=Nx(i.orbitMode),l=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof l?()=>l:l,h="number"==typeof u?()=>u:u,p=Fx(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,tj.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 Yx(e,t,i,n){const o=Fx(t),r=t.orbitSpeed??.25,s=t.orbitRevolution??Bx(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 qx(e,t){return Lp(Xx(e,t),e,"network-node-cursor-"+t)}function Xx(e,t){switch(e.type){case"circle":{const i=e,n=vr(i.style.fill)?Ar(i.style.fill,`net-circle-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
520
+ /* @__PURE__ */(0,CP.jsx)("line",{x2:-5,stroke:u.border,strokeWidth:1}),Cy(e.label)?/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Ty({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:g})]})}function cm(e,t){const i=Dr(e.theme),n=e.size||[500,400],o=a({...q$,...e.margin},e.title),s=r(e.title),c=Gs(e.data),l=e.showLegend?ef(c,e.colorAccessor||e.stackBy||e.groupBy):[],u=g({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Ky(o,{props:{...e,axisChrome:u},categories:l,theme:i,size:n,hasTitle:s});const d=Zy({props:{...e,axisChrome:u},categories:l,theme:i,size:n,margin:o,hasTitle:s}),h=n[0]-o.left-o.right,p=n[1]-o.top-o.bottom,f=e.projection||"vertical",y="radial"===f,m=e.colorScheme||i.colors.categorical,x={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:ta(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:m,themeCategorical:i.colors.categorical,themeSemantic:Nr(i),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors},b=new MP(x);e.data&&b.ingest({inserts:c,bounded:!0}),b.computeScene({width:h,height:p});const v=ng(e.backgroundGraphics,n,o,b.scales),w=ng(e.foregroundGraphics,n,o,b.scales);if(!b.scales){let r;const s=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:h,height:p},theme:i,projection:f,idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=fp({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})),sP.renderToStaticMarkup(Jy(v||w||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)(CP.Fragment,{children:[v,s,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?Qy(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=Gy(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)=>sm({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=rm({nodes:b.scene,renderMode:e.renderMode,idPrefix:k}),_=M.map(e=>e.element),$=!1!==e.showAxes?am(b,{width:h,height:p},e,i,k,o,u,!!d):null;let P;const j=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,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=fp({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:pp(b.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0,margin:o})}const I=y&&e.centerContent?Og(e.centerContent,o.left+h/2,o.top+p/2):null,L=y&&e.centerContent?I??/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("foreignObject",{x:o.left,y:o.top,width:h,height:p,pointerEvents:"none",children:/* @__PURE__ */ /* @__PURE__ */(0,CP.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,R=/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)(CP.Fragment,{children:[A,_,$,j,w,b.customLayoutOverlays]});return sP.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,CP.jsxs)(CP.Fragment,y?{children:[v?/* @__PURE__ */ /* @__PURE__ */(0,CP.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 lm({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 um(e,t){OP[e]=t}function dm(e){return OP[e]}function hm(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function pm(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 fm(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=pm(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 ym(e){return e.y0-e.y1>0?"up":"down"}function gm(e,t){return t(e.source)==t(e.target)}function mm(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 xm(e){return e.target.x0-e.source.x1}function bm(e,t){var i=wm(e),n=xm(t)/Math.tan(i);return"up"==ym(e)?e.y1-n:e.y1+n}function vm(e,t){var i=wm(e),n=xm(t)/Math.tan(i);return"up"==ym(e)?e.y1+n:e.y1-n}function wm(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function km(e,t){return t(e)}function Am(e){return Mm(e.source)}function Sm(e){return Mm(e.target)}function Mm(e){return(e.y0+e.y1)/2}function _m(e){return e.virtual?0:e.value}function $m(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!gm(e,t)?i+1:i});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!gm(e,t)?n+1:n}),i+n}function Pm(e){return e.target.depth}function jm(e,t){return e.sourceLinks.length?e.depth:t-1}function Im(e,t){return e.y0-t.y0}function Lm(e,t){return t.y0-e.y0}function Rm(e,t){return e.y1-t.y1}function Cm(e,t){return t.y1-e.y1}function Tm(e,t){return Em(e.source,t.source)||e.index-t.index}function Om(e,t){return Em(e.target,t.target)||e.index-t.index}function Em(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Fm(e,t){return Nm(e)==Nm(t)?"bottom"==e.circularLinkType?Lm(e,t):Im(e,t):Nm(t)-Nm(e)}function Nm(e){return e.target.column-e.source.column}function zm(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 km(i.source,t)==km(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(!Bm(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=bm(t,e);return e.y1-i}if(t.target.column>e.target.column)return bm(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 Dm(e,t){let i=e;return i.nodes.forEach(function(e){var n=i.links.filter(function(i){return km(i.target,t)==km(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(!Bm(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=vm(t,e);return e.y0-i}if(t.source.column>e.source.column)return vm(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 Bm(e,t){return Wm(e)==Wm(t)}function Wm(e){return e.y0-e.y1>0?"up":"down"}function Ym(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 qm(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,EP.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}),Xm(r.links.filter(function(e){return"top"==e.circularLinkType}),t,i),Xm(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,gm(e,t)&&mm(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?Lm:Im);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?Cm:Rm),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?Vm(e):Ym(e)}),r}function Xm(e,t,i){e.sort(Fm);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(gm(e,t)&&mm(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&&Gm(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 Gm(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Vm(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 Hm(e){return function(){return e}}function Um(e){return e.index}function Km(e){return e.nodes}function Zm(e){return e.links}function Qm(e,t){var i=/* @__PURE__ */new Map;return(0,FP.group)(e,t).forEach(function(e,t){i.set(t,e[0])}),i}function Jm(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=Qm(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=hm(i,n)),"object"!=typeof o&&(o=e.target=hm(i,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}function ex(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=fm(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 tx(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){km(e,t)!=km(o.source,t)&&km(e,t)!=km(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),gm(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}function ix(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,FP.sum)(e.sourceLinks,_m),(0,FP.sum)(e.targetLinks,_m)),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 nx(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 ox(e,t,i){var n=(0,FP.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,FP.min)(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,FP.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var r=(0,FP.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 rx(e,t,i){var n=(0,FP.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+=Mm(e.source)*t,n+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Mm(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?$m(t,i)-$m(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==$m(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 sx(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&&$m(o,i)>0){var c=(0,FP.mean)(o.sourceLinks,Sm),l=(0,FP.mean)(o.targetLinks,Am),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-Mm(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,FP.mean)(o.sourceLinks,Sm),p=(0,FP.mean)(o.targetLinks,Am),f=((h&&p?(h+p)/2:h||p)-Mm(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||Em),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,FP.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 ax(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Om),e.targetLinks.sort(Tm)}),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 cx(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,FP.min)(t,function(e){return e.y0}),s=(0,FP.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 lx(){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,Jm(e,l),ex(e,d),tx(e,l),ix(e),nx(e,d,u);var t=a;if(null!==c){var f=(0,FP.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,FP.max)(f,function(e){return e.length});y>1&&(t=Math.max(1,(r-n)*c/(y-1)))}ox(e,t,s),rx(e,d,l),sx(e,d,l,t,t,h),ax(e),qm(e,l,p,10,8),rx(e,d,l),sx(e,d,l,t,t,h),ax(e),qm(e,l,p,10,8),zm(e,l),Dm(e,l),cx(e),qm(e,l,p,10,8)}var i=0,n=0,o=1,r=1,s=24,a=8,c=null,l=Um,u=jm,d=void 0,h=32,p=2,f=Km,y=Zm;return e.update=function(e){return ax(e),qm(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:Hm(t),e):f},e.links=function(t){return arguments.length?(y="function"==typeof t?t:Hm(t),e):y},e.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Hm(t),e):l},e.nodeAlign=function(t){return arguments.length?(u="function"==typeof t?t:Hm(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 ux(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 dx(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let i=WP.get(e);if(i){const e=i.get(t);if(e)return e}else i=/* @__PURE__ */new Map,WP.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}`;BP.has(e)||(BP.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 hx(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]=At(o);if(r===s)return()=>(n[0]+n[1])/2;const a=(0,GP.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 px(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 fx(e,t,i){const n=[];for(const o of t){const t=ud(o.source),r=ud(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 yx(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 gx(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 mx(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 xx(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 bx(e){const[t,i,n]=xx(e);return.299*t+.587*i+.114*n>150?"#222":"#fff"}function vx(e){if(e)return"function"==typeof e?e:t=>t[e]}function wx(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 kx(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 Ax(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:JP}function Sx(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 Mx(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(dx(t,"nodeStyle"));let a=r.fill||Sx(i);if(i.colorByDepth&&void 0!==t.depth){const e=Ax(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=Px(o,s,c,p,l),g=r(dx(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=kx(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 _x(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(dx(i,"nodeStyle"));let a=s.fill||Sx(t);if(t.colorByDepth&&void 0!==i.depth){const e=Ax(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=kx(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(dx(a,"nodeStyle")).fill||Sx(t);if(t.colorByDepth&&void 0!==a.depth){const e=Ax(t);d=e[a.depth%e.length]}const h="string"==typeof d?bx(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 $x(e,t,i,n){const o=[],r=[];for(const i of e){const e=i.__radius??5;if(0>=e)continue;const r=n(dx(i,"nodeStyle"));let s=r.fill||Sx(t);if(t.colorByDepth&&void 0!==i.depth){const e=Ax(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=kx(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(dx(o,"nodeStyle")).fill||Sx(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ax(t);c=e[o.depth%e.length]}if(a){const i="string"==typeof c?bx(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 Px(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 jx(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,QP.tree)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Ix(e,t,i,n){const o=t.treeOrientation||"vertical",r=(0,QP.cluster)();r.size("horizontal"===o?[n,i]:"radial"===o?[2*Math.PI,Math.min(i,n)/2*.8]:[i,n]),r(e)}function Lx(e,t,i,n){const o=t.padding??4,r=t.paddingTop??0,s=(0,QP.treemap)().size([i,n]).tile(QP.treemapBinary).padding(o);r>0&&s.paddingTop(r),s(e)}function Rx(e,t,i,n){const o=t.padding??4;(0,QP.pack)().size([i,n]).padding(o)(e)}function Cx(e,t,i,n){(0,QP.partition)().size([i,n]).padding(t.padding??1)(e)}function Tx(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 Ox(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 Ex(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 Fx(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 Nx(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}function zx(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}function Dx(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}function Bx(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 Wx(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=zx(i.childrenAccessor),a=Dx(i.nodeIDAccessor),c=Nx(i.orbitMode),l=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof l?()=>l:l,h="number"==typeof u?()=>u:u,p=Fx(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,tj.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 Yx(e,t,i,n){const o=Fx(t),r=t.orbitSpeed??.25,s=t.orbitRevolution??Bx(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 qx(e,t){return Lp(Xx(e,t),e,"network-node-cursor-"+t)}function Xx(e,t){switch(e.type){case"circle":{const i=e,n=Ar(i.style.fill)?_r(i.style.fill,`net-circle-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
521
521
  return(0,rj.jsxs)(nj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,rj.jsx)("defs",{children:n}),
522
522
  /* @__PURE__ */
523
- /* @__PURE__ */(0,rj.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:n?`url(#net-circle-${t}-hatch)`:kp(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=vr(i.style.fill)?Ar(i.style.fill,`net-rect-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
523
+ /* @__PURE__ */(0,rj.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:n?`url(#net-circle-${t}-hatch)`:kp(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=Ar(i.style.fill)?_r(i.style.fill,`net-rect-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
524
524
  return(0,rj.jsxs)(nj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,rj.jsx)("defs",{children:n}),
525
525
  /* @__PURE__ */
526
- /* @__PURE__ */(0,rj.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n?`url(#net-rect-${t}-hatch)`:kp(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,oj.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(F_)||"",o=vr(i.style.fill)?Ar(i.style.fill,`net-arc-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
526
+ /* @__PURE__ */(0,rj.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n?`url(#net-rect-${t}-hatch)`:kp(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,oj.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(F_)||"",o=Ar(i.style.fill)?_r(i.style.fill,`net-arc-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
527
527
  return(0,rj.jsxs)(nj.Fragment,{children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,rj.jsx)("defs",{children:o}),
528
528
  /* @__PURE__ */
529
529
  /* @__PURE__ */(0,rj.jsx)("path",{d:n,transform:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:kp(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=ep(i.symbolType,i.size,i.path);/* @__PURE__ */ /* @__PURE__ */
530
530
  return(0,rj.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?kp(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 Sp(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}function Gx(e,t){return Lp(Vx(e,t),e,"network-edge-cursor-"+t)}function Vx(e,t){switch(e.type){case"line":/* @__PURE__ */ /* @__PURE__ */
531
- return(0,rj.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=vr(i.style.fill)?Ar(i.style.fill,n):void 0;/* @__PURE__ */ /* @__PURE__ */
531
+ return(0,rj.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=Ar(i.style.fill)?_r(i.style.fill,n):void 0;/* @__PURE__ */ /* @__PURE__ */
532
532
  return(0,rj.jsxs)(nj.Fragment,{children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,rj.jsx)("defs",{children:o}),
533
533
  /* @__PURE__ */
534
- /* @__PURE__ */(0,rj.jsx)("path",{d:i.pathD,fill:o?`url(#${n})`:kp(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=vr(i.style.fill)?Ar(i.style.fill,n):void 0;/* @__PURE__ */ /* @__PURE__ */
534
+ /* @__PURE__ */(0,rj.jsx)("path",{d:i.pathD,fill:o?`url(#${n})`:kp(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=Ar(i.style.fill)?_r(i.style.fill,n):void 0;/* @__PURE__ */ /* @__PURE__ */
535
535
  return(0,rj.jsxs)(nj.Fragment,{children:[o&&/* @__PURE__ */ /* @__PURE__ */(0,rj.jsx)("defs",{children:o}),
536
536
  /* @__PURE__ */
537
537
  /* @__PURE__ */(0,rj.jsx)("path",{d:i.pathD,fill:o?`url(#${n})`:kp(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,rj.jsx)("path",{d:i.pathD,fill:kp(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 Hx(e,t){/* @__PURE__ */ /* @__PURE__ */
539
- return(0,rj.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 Ux(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Kx(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=vp(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,tp(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Zx(e){if(!e)return;const t=[];for(const i of e){const e=Kx(i);e&&t.push({pointId:Ux(i),...e})}return t}function Qx(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Jx(e,t){const i=Qx(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 eb(e,t){const i=Qx(t.sourceAccessor,"source"),n=Qx(t.targetAccessor,"target"),o=Qx(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 tb(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 ib(e,t){const i=Fr(e.theme),n=e.chartType||"force",o=t=>fp({frameType:"network",width:s[0],height:s[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:c}),s=e.size||[500,500],c=a({...og(n),...e.margin},e.title),l=r(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=Gs(e.nodes||[]);if(o.length>0)return ef(o,t);if(aj.has(n)&&e.data)return ef(Hu(e.data,e.childrenAccessor||"children"),t);const r=Array.isArray(e.edges)?Gs(e.edges):[];if(0===r.length)return[];const s=Qx(e.sourceAccessor,"source"),a=Qx(e.targetAccessor,"target");return ef(Array.from(new Set(r.flatMap(e=>[s(e),a(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Ky(c,{props:e,categories:u,theme:i,size:s,hasTitle:l});const d=Zy({props:e,categories:u,theme:i,size:s,margin:c,hasTitle:l}),h=s[0]-c.left-c.right,p=s[1]-c.top-c.bottom,f=ng(e.backgroundGraphics,s,c,null),y=ng(e.foregroundGraphics,s,c,null),g=()=>{let n;const r=e=>Number(e),a=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:r,y:r},layout:{width:h,height:p},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{n=e}}):null;return t&&(t.evidence=o(n)),TP.renderToStaticMarkup(Jy(f||y||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,sj.jsxs)(sj.Fragment,{children:[f,a,y]}):null,{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${c.left},${c.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))},m=dm(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(aj.has(n)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g();x.__hierarchyRoot=t,b=[],v=[]}else{const t=Gs(e.nodes||[]),i=Array.isArray(e.edges)?Gs(e.edges):[];if(0===t.length&&0===i.length)return g();if(v=eb(i,x),0===t.length&&v.length>0){const e=/* @__PURE__ */new Set;for(const t of v){const i=Xy(t.source),n=Xy(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=Jx(t,x)}let w=[],k=[],A=[],S=null,M=null;if(x.customNetworkLayout){const t=x.colorScheme,n=Bn(t,i.colors.categorical,kk),o=Wn(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??[],lm({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 _=Nr(i);for(const e of A)e.fill||(e.fill=_.text);const $=Dp({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>Gx(e,t)}),P=Dp({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>qx(e,t)}),j=$.map(e=>e.element),I=P.map(e=>e.element),L=A.map((e,t)=>Hx(e,t)).filter(Boolean);let R;const C=e=>Number(e),T=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:C,y:C},layout:{width:h,height:p},theme:i,frameType:"network",annotationData:tb(w),pointNodes:Zx(w),idPrefix:e._idPrefix,onRender:e=>{R=e}}):null;return t&&(t.evidence=fp({frameType:"network",width:s[0],height:s[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:c})),TP.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,sj.jsxs)(sj.Fragment,{children:[f,S,j,I,L,T,y,M]}),{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${c.left},${c.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function nb(e){if(!e)return(0,dj.geoEqualEarth)();if("string"==typeof e){const t=hj[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,dj.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=hj[e.type],i=t?t():(0,dj.geoEqualEarth)();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function ob(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function rb(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function sb(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function ab(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function cb(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function lb(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function ub(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 db(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 hb(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 pb(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 fb(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=_s(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?gb(o,u,l,d,i):yb(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 yb(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,pj.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 gb(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,pj.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 mb(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=Aj[n]??Sj;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function xb({config:e,projection:t,path:i,areas:n,points:o,lines:r,layout:s}){const a=ob(e.xAccessor,"lon"),c=ob(e.yAccessor,"lat"),l=[],u=ab(e),d=lb(e),h=cb(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,n=(0,_j.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:sb(e.areaStyle,t,u),datum:t,interactive:!0})}const p=rb(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,_j.geoDistance)(n,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,_j.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=sb(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?hb(o,u):pb(o[0],o[o.length-1],0,0,u)):o=db(o[0],o[o.length-1]);const h=ub(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,_j.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 bb(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 vb(e){return{...e,fitPadding:bb(e.fitPadding)}}function wb(e){return"fitPadding"in e?{...e,fitPadding:bb(e.fitPadding)}:e}function kb(e,t){return Lp(Ab(e,t),e,"geo-cursor-"+t)}function Ab(e,t){switch(e.type){case"geoarea":{const i=e;if(!i.pathData)return null;const n=vr(i.style.fill)?Ar(i.style.fill,`geoarea-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
539
+ return(0,rj.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 Ux(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Kx(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=vp(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,tp(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Zx(e){if(!e)return;const t=[];for(const i of e){const e=Kx(i);e&&t.push({pointId:Ux(i),...e})}return t}function Qx(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Jx(e,t){const i=Qx(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 eb(e,t){const i=Qx(t.sourceAccessor,"source"),n=Qx(t.targetAccessor,"target"),o=Qx(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 tb(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 ib(e,t){const i=Dr(e.theme),n=e.chartType||"force",o=t=>fp({frameType:"network",width:s[0],height:s[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:c}),s=e.size||[500,500],c=a({...og(n),...e.margin},e.title),l=r(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=Gs(e.nodes||[]);if(o.length>0)return ef(o,t);if(aj.has(n)&&e.data)return ef(Hu(e.data,e.childrenAccessor||"children"),t);const r=Array.isArray(e.edges)?Gs(e.edges):[];if(0===r.length)return[];const s=Qx(e.sourceAccessor,"source"),a=Qx(e.targetAccessor,"target");return ef(Array.from(new Set(r.flatMap(e=>[s(e),a(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Ky(c,{props:e,categories:u,theme:i,size:s,hasTitle:l});const d=Zy({props:e,categories:u,theme:i,size:s,margin:c,hasTitle:l}),h=s[0]-c.left-c.right,p=s[1]-c.top-c.bottom,f=ng(e.backgroundGraphics,s,c,null),y=ng(e.foregroundGraphics,s,c,null),g=()=>{let n;const r=e=>Number(e),a=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:r,y:r},layout:{width:h,height:p},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{n=e}}):null;return t&&(t.evidence=o(n)),TP.renderToStaticMarkup(Jy(f||y||e.annotations?/* @__PURE__ */ /* @__PURE__ */(0,sj.jsxs)(sj.Fragment,{children:[f,a,y]}):null,{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${c.left},${c.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))},m=dm(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(aj.has(n)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g();x.__hierarchyRoot=t,b=[],v=[]}else{const t=Gs(e.nodes||[]),i=Array.isArray(e.edges)?Gs(e.edges):[];if(0===t.length&&0===i.length)return g();if(v=eb(i,x),0===t.length&&v.length>0){const e=/* @__PURE__ */new Set;for(const t of v){const i=Xy(t.source),n=Xy(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=Jx(t,x)}let w=[],k=[],A=[],S=null,M=null;if(x.customNetworkLayout){const t=x.colorScheme,n=qn(t,i.colors.categorical,kk),o=Xn(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??[],lm({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 _=Br(i);for(const e of A)e.fill||(e.fill=_.text);const $=Dp({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>Gx(e,t)}),P=Dp({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>qx(e,t)}),j=$.map(e=>e.element),I=P.map(e=>e.element),L=A.map((e,t)=>Hx(e,t)).filter(Boolean);let R;const C=e=>Number(e),T=e.annotations?by({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:C,y:C},layout:{width:h,height:p},theme:i,frameType:"network",annotationData:tb(w),pointNodes:Zx(w),idPrefix:e._idPrefix,onRender:e=>{R=e}}):null;return t&&(t.evidence=fp({frameType:"network",width:s[0],height:s[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:c})),TP.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,sj.jsxs)(sj.Fragment,{children:[f,S,j,I,L,T,y,M]}),{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${c.left},${c.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function nb(e){if(!e)return(0,dj.geoEqualEarth)();if("string"==typeof e){const t=hj[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,dj.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=hj[e.type],i=t?t():(0,dj.geoEqualEarth)();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}function ob(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function rb(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function sb(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function ab(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}function cb(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}function lb(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}function ub(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 db(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 hb(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 pb(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 fb(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=Mt(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?gb(o,u,l,d,i):yb(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 yb(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,pj.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 gb(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,pj.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 mb(e){let t="preserve";const i=/* @__PURE__ */new Set;for(const n of e){const e=Aj[n]??Sj;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function xb({config:e,projection:t,path:i,areas:n,points:o,lines:r,layout:s}){const a=ob(e.xAccessor,"lon"),c=ob(e.yAccessor,"lat"),l=[],u=ab(e),d=lb(e),h=cb(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,n=(0,_j.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:sb(e.areaStyle,t,u),datum:t,interactive:!0})}const p=rb(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,_j.geoDistance)(n,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,_j.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=sb(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?hb(o,u):pb(o[0],o[o.length-1],0,0,u)):o=db(o[0],o[o.length-1]);const h=ub(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,_j.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 bb(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 vb(e){return{...e,fitPadding:bb(e.fitPadding)}}function wb(e){return"fitPadding"in e?{...e,fitPadding:bb(e.fitPadding)}:e}function kb(e,t){return Lp(Ab(e,t),e,"geo-cursor-"+t)}function Ab(e,t){switch(e.type){case"geoarea":{const i=e;if(!i.pathData)return null;const n=Ar(i.style.fill)?_r(i.style.fill,`geoarea-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
540
540
  return(0,Ij.jsxs)(jj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,Ij.jsx)("defs",{children:n}),
541
541
  /* @__PURE__ */
542
- /* @__PURE__ */(0,Ij.jsx)("path",{d:i.pathData,fill:n?`url(#geoarea-${t}-hatch)`:kp(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=vr(i.style.fill)?Ar(i.style.fill,`geopoint-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
542
+ /* @__PURE__ */(0,Ij.jsx)("path",{d:i.pathData,fill:n?`url(#geoarea-${t}-hatch)`:kp(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=Ar(i.style.fill)?_r(i.style.fill,`geopoint-${t}-hatch`):void 0;/* @__PURE__ */ /* @__PURE__ */
543
543
  return(0,Ij.jsxs)(jj.Fragment,{children:[n&&/* @__PURE__ */ /* @__PURE__ */(0,Ij.jsx)("defs",{children:n}),
544
544
  /* @__PURE__ */
545
545
  /* @__PURE__ */(0,Ij.jsx)("circle",{cx:i.x,cy:i.y,r:i.r,fill:n?`url(#geopoint-${t}-hatch)`:kp(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,Lj.jsxs)("g",{children:[
566
566
  /* @__PURE__ */
567
567
  /* @__PURE__ */(0,Lj.jsx)("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),
568
568
  /* @__PURE__ */
569
- /* @__PURE__ */(0,Lj.jsx)("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function _b(e,t){const i=Fr(e.theme),n=e.size||[e.width||600,e.height||400],o=a({top:10,right:10,bottom:10,left:10,...e.margin},e.title),s=r(e.title),c=Array.isArray(e.areas)?Gs(e.areas):e.areas,l=Gs(e.points),u=Gs(e.lines),d=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;return ef(l.length>0?l:Array.isArray(c)&&c.length>0?"string"==typeof t?c.map(e=>({...e.properties||{},...e})):c:[],t)})():[];Ky(o,{props:e,categories:d,theme:i,size:n,hasTitle:s});const h=Zy({props:e,categories:d,theme:i,size:n,margin:o,hasTitle:s}),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:Or(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},g=new Pj(y);if(c){if("string"==typeof c)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${c}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${c}')\` before calling renderGeoToStaticSVG.`);g.setAreas(c)}e.points&&g.setPoints(l),e.lines&&g.setLines(u),g.computeScene({width:p,height:f});const m=ng(e.backgroundGraphics,n,o,g.scales),x=ng(e.foregroundGraphics,n,o,g.scales),b=Dp({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>kb(e,t)});if(0===b.length){let r;const s=e.annotations?by({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:Sb(g.scene),idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=fp({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})),cj.renderToStaticMarkup(Jy(m||x||e.annotations||g.customLayoutOverlays?/* @__PURE__ */ /* @__PURE__ */(0,Rj.jsxs)(Rj.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,Rj.jsx)(Mb,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:$b(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?by({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:Sb(g.scene),idPrefix:e._idPrefix,onRender:e=>{A=e}}):null;return t&&(t.evidence=fp({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})),cj.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,Rj.jsxs)(Rj.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 $b(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 Pb(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 jb(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 Ib(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 Lb(e,t={}){const i=t.bodies??Pb(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)?Ib(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:jb(t.projectionRows),queuedCount:o,sedimentedCount:r,...c?{ledger:c}:{},warnings:a}}function Rb(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function Cb(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 Tb(e,t,i){const n="function"==typeof t?t(e,i):t;return{...Tj,...n??{}}}function Ob(e,t={},i={index:0,simulationState:"settled"}){const n=Rb(e),o={label:t.getBodyLabel?.(e)??Cb(e)},r={style:Tb(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 Eb(e,t={},i="settled"){return e.map((e,n)=>Ob(e,t,{index:n,simulationState:i}))}function Fb(e,t={}){const i=e.settle(t.maxSteps),n=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:n,sceneNodes:Eb(n,t,o.simulationState),evidence:Lb(o,{bodies:n,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge}),stepsRun:i}}function Nb(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}function zb(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function Db(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=Fb(e,g),x={...Ej,...h},b=[i,n],v=zb(a,b,x),w=zb(u,b,x),k=Nb(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,Oj.jsx)("g",{transform:_,children:v}):v;return{element:/* @__PURE__ */ /* @__PURE__ */(0,Oj.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,Oj.jsx)("title",{id:A,children:o}),r&&/* @__PURE__ */ /* @__PURE__ */(0,Oj.jsx)("desc",{id:S,children:r}),
569
+ /* @__PURE__ */(0,Lj.jsx)("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function _b(e,t){const i=Dr(e.theme),n=e.size||[e.width||600,e.height||400],o=a({top:10,right:10,bottom:10,left:10,...e.margin},e.title),s=r(e.title),c=Array.isArray(e.areas)?Gs(e.areas):e.areas,l=Gs(e.points),u=Gs(e.lines),d=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;return ef(l.length>0?l:Array.isArray(c)&&c.length>0?"string"==typeof t?c.map(e=>({...e.properties||{},...e})):c:[],t)})():[];Ky(o,{props:e,categories:d,theme:i,size:n,hasTitle:s});const h=Zy({props:e,categories:d,theme:i,size:n,margin:o,hasTitle:s}),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:Nr(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},g=new Pj(y);if(c){if("string"==typeof c)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${c}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${c}')\` before calling renderGeoToStaticSVG.`);g.setAreas(c)}e.points&&g.setPoints(l),e.lines&&g.setLines(u),g.computeScene({width:p,height:f});const m=ng(e.backgroundGraphics,n,o,g.scales),x=ng(e.foregroundGraphics,n,o,g.scales),b=Dp({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>kb(e,t)});if(0===b.length){let r;const s=e.annotations?by({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:Sb(g.scene),idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=fp({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})),cj.renderToStaticMarkup(Jy(m||x||e.annotations||g.customLayoutOverlays?/* @__PURE__ */ /* @__PURE__ */(0,Rj.jsxs)(Rj.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,Rj.jsx)(Mb,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:$b(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?by({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:Sb(g.scene),idPrefix:e._idPrefix,onRender:e=>{A=e}}):null;return t&&(t.evidence=fp({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})),cj.renderToStaticMarkup(Jy(/* @__PURE__ */ /* @__PURE__ */(0,Rj.jsxs)(Rj.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 $b(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 Pb(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 jb(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 Ib(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 Lb(e,t={}){const i=t.bodies??Pb(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)?Ib(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:jb(t.projectionRows),queuedCount:o,sedimentedCount:r,...c?{ledger:c}:{},warnings:a}}function Rb(e){return e.datum&&"object"==typeof e.datum?e.datum:null}function Cb(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 Tb(e,t,i){const n="function"==typeof t?t(e,i):t;return{...Tj,...n??{}}}function Ob(e,t={},i={index:0,simulationState:"settled"}){const n=Rb(e),o={label:t.getBodyLabel?.(e)??Cb(e)},r={style:Tb(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 Eb(e,t={},i="settled"){return e.map((e,n)=>Ob(e,t,{index:n,simulationState:i}))}function Fb(e,t={}){const i=e.settle(t.maxSteps),n=e.readBodies(),o=e.snapshot();return{snapshot:o,bodies:n,sceneNodes:Eb(n,t,o.simulationState),evidence:Lb(o,{bodies:n,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge}),stepsRun:i}}function Nb(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}function zb(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function Db(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=Fb(e,g),x={...Ej,...h},b=[i,n],v=zb(a,b,x),w=zb(u,b,x),k=Nb(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,Oj.jsx)("g",{transform:_,children:v}):v;return{element:/* @__PURE__ */ /* @__PURE__ */(0,Oj.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,Oj.jsx)("title",{id:A,children:o}),r&&/* @__PURE__ */ /* @__PURE__ */(0,Oj.jsx)("desc",{id:S,children:r}),
570
570
  /* @__PURE__ */
571
571
  /* @__PURE__ */(0,Oj.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,Oj.jsx)("clipPath",{id:j,children:/* @__PURE__ */ /* @__PURE__ */(0,Oj.jsx)("rect",{width:$,height:P})})}),c&&"transparent"!==c?/* @__PURE__ */ /* @__PURE__ */(0,Oj.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,Oj.jsx)("rect",{x:0,y:0,width:i,height:n,fill:s}):null,I,
572
572
  /* @__PURE__ */
@@ -574,19 +574,19 @@ return(0,Lj.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)(Hb,{title:t.title,totalWidth:i[0],marginTop:Math.max(n.top,28)}),f]})}}function Jb(e,t){const i=e.size??[e.width??600,e.height??400],n=Fr(e.theme),o=void 0===e.theme?{}:Ga(n),r=e.bodyStyle,a=!1,l=e.legendPosition??"right",u=s({...Dj,...e.margin},a,!!e.legend&&"top"===l);if(e.legend){const t={...u};b(u,{legend:e.legend,position:l,size:i,hasTitle:a,legendLayout:e.legendLayout}),c(u,t,i,l)}let d;const h=Vb({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-u.left-u.right),Math.max(1,i[1]-u.top-u.bottom)]}),p=new mk(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&p.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const f=Bb(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:u,renderChrome:t=>{const o=Qb(t,e,i,u,n);return d=o.annotationRender,o.node}});return t&&(t.evidence=fp({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 ev(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=>tv(e);const n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>n.format(e)}function tv(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 iv(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function nv(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 ov(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function rv(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 sv(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`${iv(r,i)}${n&&"string"==typeof n.label?" "+n.label:""}`}function av(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 cv(e,t,i){return qj[e](t,i)}function lv(e,t,i){const{title:n,subtitle:o,theme:r,width:s=1200,height:a,layout:c={},background:l}=t,u=Nr(Fr(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=I(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,Gj.jsx)("g",{transform:`translate(${e.x},${e.y})`,children:/* @__PURE__ */ /* @__PURE__ */(0,Gj.jsx)("foreignObject",{width:e.width,height:e.height,children:/* @__PURE__ */ /* @__PURE__ */(0,Gj.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:L(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return Xj.renderToStaticMarkup(
577
+ /* @__PURE__ */(0,zj.jsx)(Hb,{title:t.title,totalWidth:i[0],marginTop:Math.max(n.top,28)}),f]})}}function Jb(e,t){const i=e.size??[e.width??600,e.height??400],n=Dr(e.theme),o=void 0===e.theme?{}:Ga(n),r=e.bodyStyle,a=!1,l=e.legendPosition??"right",u=s({...Dj,...e.margin},a,!!e.legend&&"top"===l);if(e.legend){const t={...u};b(u,{legend:e.legend,position:l,size:i,hasTitle:a,legendLayout:e.legendLayout}),c(u,t,i,l)}let d;const h=Vb({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-u.left-u.right),Math.max(1,i[1]-u.top-u.bottom)]}),p=new mk(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&p.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const f=Bb(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:u,renderChrome:t=>{const o=Qb(t,e,i,u,n);return d=o.annotationRender,o.node}});return t&&(t.evidence=fp({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 ev(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=>tv(e);const n=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>n.format(e)}function tv(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 iv(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}function nv(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 ov(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function rv(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 sv(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`${iv(r,i)}${n&&"string"==typeof n.label?" "+n.label:""}`}function av(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 cv(e,t,i){return qj[e](t,i)}function lv(e,t,i){const{title:n,subtitle:o,theme:r,width:s=1200,height:a,layout:c={},background:l}=t,u=Br(Dr(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=I(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,Gj.jsx)("g",{transform:`translate(${e.x},${e.y})`,children:/* @__PURE__ */ /* @__PURE__ */(0,Gj.jsx)("foreignObject",{width:e.width,height:e.height,children:/* @__PURE__ */ /* @__PURE__ */(0,Gj.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:L(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return Xj.renderToStaticMarkup(
578
578
  /* @__PURE__ */
579
- /* @__PURE__ */(0,Gj.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,Gj.jsx)("title",{children:n}),l&&/* @__PURE__ */ /* @__PURE__ */(0,Gj.jsx)("rect",{x:0,y:0,width:s,height:b,fill:l}),n&&/* @__PURE__ */ /* @__PURE__ */(0,Gj.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,Gj.jsx)("text",{x:s/2,y:n?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}function uv(e,t){switch(e){case"xy":return sg(t);case"ordinal":return cm(t);case"network":return ib(t);case"geo":return _b(t);case"physics":return Jb(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function dv(e){return sg(e)}function hv(e){return cm(e)}function pv(e){return ib(e)}function fv(e){return _b(e)}function yv(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function gv(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 mv(e,t){const i=RegExp(Uj.source,Uj.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+=gv(n[0],t),r=n.index+n[0].length,s=!0}return o+e.slice(r)}function xv(e,t){const i=yv(t);return void 0===i?e:P(e,(e,t)=>{if(Hj.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return mv(t,i)})}function bv(e,t){const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i}function vv(e,t,i){return kv(e,t,i).svg}function wv(e,t,i){const n={},{svg:o,frameType:r}=kv(e,t,i,n),s=n.evidence??fp({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=Ie(o,s),Ve(s,e,t),i?.artifactContract){const n=Ae(i.artifactContract,{excludeEvidenceSamples:!0});n.contract&&(s.artifactContract=n.contract),s.artifactTransfer=n.transfer,s.artifactBinding=n.contract?.contractVersion===gw&&"invalid"!==n.transfer.status?je(n.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:s}}function kv(e,t,i,n){if(Object.prototype.hasOwnProperty.call(qj,e))return{svg:xv(cv(e,t,n),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(iP,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);const o=iP[e];var r;const s=Ne(o.layout?.mode??("string"==typeof(r=t.mode)&&Object.prototype.hasOwnProperty.call($w,r)?t.mode:void 0),{...o.layout?.modeDefaults,...bv(t,Zj)},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,S="xy"===o.frameType?A(k,g.axes??v.axes,!!s.title):k,M=void 0!==h?h:v.margin,_=He(M),$="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,..._},P=bv(g,Kj),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=sg(L,n);break;case"ordinal":R=cm(L,n);break;case"network":R=ib(L,n);break;case"geo":R=_b(L,n);break;case"physics":R=Jb(L,n)}const C=o.renderOverlay?.(L,{theme:Fr(c)});if(null!=C){const e=Rw.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)(Vj.Fragment,{children:C})),t=R.lastIndexOf("</svg>");R=0>t?`${R}${e}`:`${R.slice(0,t)}${e}${R.slice(t)}`}return{svg:xv(R,i?.precision),frameType:o.frameType}}function Av(e,t={}){return lv(e,t,{chart:vv,frame:uv})}function Sv(e,t,i,n={}){const{stepSize:o,windowSize:r,frameCount:s,xExtent:c,yExtent:l,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:p}=n,f=i.width||600,y=i.height||400,g=Fr(i.theme),m={...i,...c&&{xExtent:c},...l&&{yExtent:l}};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=a({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 MP(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&S.push(Cv(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),a={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:c,yExtent:l,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 A_(a);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(Rv(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(Rv(x.scene,f,y,g,m,v,S.length))}}return S}function Mv(e,t,i={}){return t.map(t=>{try{return vv(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 _v(e,t,i,n){const o=ky(`${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 $v(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:Gy(e)||t}function Pv(e,t,i){const n=t.size??[t.width??600,t.height??400],o=Fr(t.theme),r=Nr(o),s=t.background||o.colors.background,a=t.idPrefix??"physics-gif",c=_v(a,i,t.title,t.description),{titleId:l,descId:u,labelledBy:d}=c,h=Eb(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),p=/* @__PURE__ */ /* @__PURE__ */(0,Jj.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,Jj.jsx)("title",{id:l,children:t.title}),t.description&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("desc",{id:u,children:t.description}),s&&"transparent"!==s?/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("rect",{x:0,y:0,width:n[0],height:n[1],fill:s}):null,
579
+ /* @__PURE__ */(0,Gj.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,Gj.jsx)("title",{children:n}),l&&/* @__PURE__ */ /* @__PURE__ */(0,Gj.jsx)("rect",{x:0,y:0,width:s,height:b,fill:l}),n&&/* @__PURE__ */ /* @__PURE__ */(0,Gj.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,Gj.jsx)("text",{x:s/2,y:n?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}function uv(e,t){switch(e){case"xy":return sg(t);case"ordinal":return cm(t);case"network":return ib(t);case"geo":return _b(t);case"physics":return Jb(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function dv(e){return sg(e)}function hv(e){return cm(e)}function pv(e){return ib(e)}function fv(e){return _b(e)}function yv(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}function gv(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 mv(e,t){const i=RegExp(Uj.source,Uj.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+=gv(n[0],t),r=n.index+n[0].length,s=!0}return o+e.slice(r)}function xv(e,t){const i=yv(t);return void 0===i?e:P(e,(e,t)=>{if(Hj.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return mv(t,i)})}function bv(e,t){const i={};for(const n of t)void 0!==e[n]&&(i[n]=e[n]);return i}function vv(e,t,i){return kv(e,t,i).svg}function wv(e,t,i){const n={},{svg:o,frameType:r}=kv(e,t,i,n),s=n.evidence??fp({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=Ie(o,s),Ve(s,e,t),i?.artifactContract){const n=Ae(i.artifactContract,{excludeEvidenceSamples:!0});n.contract&&(s.artifactContract=n.contract),s.artifactTransfer=n.transfer,s.artifactBinding=n.contract?.contractVersion===gw&&"invalid"!==n.transfer.status?je(n.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:s}}function kv(e,t,i,n){if(Object.prototype.hasOwnProperty.call(qj,e))return{svg:xv(cv(e,t,n),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(iP,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);const o=iP[e];var r;const s=Ne(o.layout?.mode??("string"==typeof(r=t.mode)&&Object.prototype.hasOwnProperty.call($w,r)?t.mode:void 0),{...o.layout?.modeDefaults,...bv(t,Zj)},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,S="xy"===o.frameType?A(k,g.axes??v.axes,!!s.title):k,M=void 0!==h?h:v.margin,_=He(M),$="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,..._},P=bv(g,Kj),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=sg(L,n);break;case"ordinal":R=cm(L,n);break;case"network":R=ib(L,n);break;case"geo":R=_b(L,n);break;case"physics":R=Jb(L,n)}const C=o.renderOverlay?.(L,{theme:Dr(c)});if(null!=C){const e=Rw.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,Vj.jsx)(Vj.Fragment,{children:C})),t=R.lastIndexOf("</svg>");R=0>t?`${R}${e}`:`${R.slice(0,t)}${e}${R.slice(t)}`}return{svg:xv(R,i?.precision),frameType:o.frameType}}function Av(e,t={}){return lv(e,t,{chart:vv,frame:uv})}function Sv(e,t,i,n={}){const{stepSize:o,windowSize:r,frameCount:s,xExtent:c,yExtent:l,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:p}=n,f=i.width||600,y=i.height||400,g=Dr(i.theme),m={...i,...c&&{xExtent:c},...l&&{yExtent:l}};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=a({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 MP(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&S.push(Cv(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),a={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:c,yExtent:l,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 A_(a);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(Rv(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(Rv(x.scene,f,y,g,m,v,S.length))}}return S}function Mv(e,t,i={}){return t.map(t=>{try{return vv(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 _v(e,t,i,n){const o=ky(`${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 $v(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:Gy(e)||t}function Pv(e,t,i){const n=t.size??[t.width??600,t.height??400],o=Dr(t.theme),r=Br(o),s=t.background||o.colors.background,a=t.idPrefix??"physics-gif",c=_v(a,i,t.title,t.description),{titleId:l,descId:u,labelledBy:d}=c,h=Eb(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),p=/* @__PURE__ */ /* @__PURE__ */(0,Jj.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,Jj.jsx)("title",{id:l,children:t.title}),t.description&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("desc",{id:u,children:t.description}),s&&"transparent"!==s?/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("rect",{x:0,y:0,width:n[0],height:n[1],fill:s}):null,
580
580
  /* @__PURE__ */
581
- /* @__PURE__ */(0,Jj.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((e,t)=>Op(e,t,`${a}-${i}`))})]});return Qj.renderToStaticMarkup(p)}function jv(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 mk(e.config);e.initialSpawns?.length&&p.enqueue(e.initialSpawns,e.initialSpawnPacing);const f=[];for(r&&(p.tick(0),f.push(Pv(p,h,0)));d>f.length;){for(let e=0;u>e;e+=1)p.tick(l);f.push(Pv(p,h,f.length))}return f}function Iv(e,t){const i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Lv(e,t,i,n,o,r){if(!e||0===e.length)return null;const s=Nr(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(
581
+ /* @__PURE__ */(0,Jj.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((e,t)=>Op(e,t,`${a}-${i}`))})]});return Qj.renderToStaticMarkup(p)}function jv(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 mk(e.config);e.initialSpawns?.length&&p.enqueue(e.initialSpawns,e.initialSpawnPacing);const f=[];for(r&&(p.tick(0),f.push(Pv(p,h,0)));d>f.length;){for(let e=0;u>e;e+=1)p.tick(l);f.push(Pv(p,h,f.length))}return f}function Iv(e,t){const i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Lv(e,t,i,n,o,r){if(!e||0===e.length)return null;const s=Br(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,Jj.jsxs)("g",{children:[
584
584
  /* @__PURE__ */
585
- /* @__PURE__ */(0,Jj.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,Jj.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,Jj.jsx)(Jj.Fragment,{children:a}):null}function Rv(e,t,i,n,o,r,s=0){const c=Nr(n),l=a({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-l.left-l.right,d=i-l.top-l.bottom,h=Iv(o,n),p=o.renderMode,f=e.map((e,t)=>zp({node:e,index:t,renderMode:p,fallback:()=>Op(e,t)}).element).filter(Boolean),y=Lv(o.annotations,u,d,n,o.yExtent,r?.y),{titleText:g,descText:m,titleId:x,descId:b,labelledBy:v}=_v($v(o,"xy-gif"),s,o.title,o.description);return Qj.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:c.fontFamily},children:[g&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("title",{id:x,children:g}),m&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("desc",{id:b,children:m}),h&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("rect",{x:0,y:0,width:t,height:i,fill:h}),
585
+ /* @__PURE__ */(0,Jj.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,Jj.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,Jj.jsx)(Jj.Fragment,{children:a}):null}function Rv(e,t,i,n,o,r,s=0){const c=Br(n),l=a({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-l.left-l.right,d=i-l.top-l.bottom,h=Iv(o,n),p=o.renderMode,f=e.map((e,t)=>zp({node:e,index:t,renderMode:p,fallback:()=>Op(e,t)}).element).filter(Boolean),y=Lv(o.annotations,u,d,n,o.yExtent,r?.y),{titleText:g,descText:m,titleId:x,descId:b,labelledBy:v}=_v($v(o,"xy-gif"),s,o.title,o.description);return Qj.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:c.fontFamily},children:[g&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("title",{id:x,children:g}),m&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("desc",{id:b,children:m}),h&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("rect",{x:0,y:0,width:t,height:i,fill:h}),
586
586
  /* @__PURE__ */
587
- /* @__PURE__ */(0,Jj.jsxs)("g",{transform:`translate(${l.left},${l.top})`,children:[y,f]}),g&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("text",{x:t/2,y:Hv,textAnchor:"middle",fontSize:c.titleFontSize,fontWeight:c.titleFontWeight,fill:c.text,fontFamily:c.titleFontFamily,children:g})]}))}function Cv(e,t,i,n,o,r=0){const s=Nr(n),c=a({top:20,right:20,bottom:30,left:40,...o.margin},o.title),l="radial"===o.projection,u=l?c.left+(t-c.left-c.right)/2:c.left,d=l?c.top+(i-c.top-c.bottom)/2:c.top,h=Iv(o,n),p=rm({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:f,descText:y,titleId:g,descId:m,labelledBy:x}=_v($v(o,"ordinal-gif"),r,o.title,o.description);return Qj.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,Jj.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,Jj.jsx)("title",{id:g,children:f}),y&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("desc",{id:m,children:y}),h&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("rect",{x:0,y:0,width:t,height:i,fill:h}),
587
+ /* @__PURE__ */(0,Jj.jsxs)("g",{transform:`translate(${l.left},${l.top})`,children:[y,f]}),g&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("text",{x:t/2,y:Hv,textAnchor:"middle",fontSize:c.titleFontSize,fontWeight:c.titleFontWeight,fill:c.text,fontFamily:c.titleFontFamily,children:g})]}))}function Cv(e,t,i,n,o,r=0){const s=Br(n),c=a({top:20,right:20,bottom:30,left:40,...o.margin},o.title),l="radial"===o.projection,u=l?c.left+(t-c.left-c.right)/2:c.left,d=l?c.top+(i-c.top-c.bottom)/2:c.top,h=Iv(o,n),p=rm({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:f,descText:y,titleId:g,descId:m,labelledBy:x}=_v($v(o,"ordinal-gif"),r,o.title,o.description);return Qj.renderToStaticMarkup(/* @__PURE__ */ /* @__PURE__ */(0,Jj.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,Jj.jsx)("title",{id:g,children:f}),y&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("desc",{id:m,children:y}),h&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("rect",{x:0,y:0,width:t,height:i,fill:h}),
588
588
  /* @__PURE__ */
589
- /* @__PURE__ */(0,Jj.jsx)("g",{transform:`translate(${u},${d})`,children:p}),f&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("text",{x:t/2,y:Hv,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:f})]}))}var Tv,Ov=Object.create,Ev=Object.defineProperty,Fv=Object.getOwnPropertyDescriptor,Nv=Object.getOwnPropertyNames,zv=Object.getPrototypeOf,Dv=Object.prototype.hasOwnProperty,Bv=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of Nv(t))Dv.call(e,o)||o===i||Ev(e,o,{get:()=>t[o],enumerable:!(n=Fv(t,o))||n.enumerable});return e},Wv=(e,t,i)=>(i=null!=e?Ov(zv(e)):{},Bv(!t&&e&&e.__esModule?i:Ev(i,"default",{value:e,enumerable:!0}),e)),Yv={};((e,t)=>{for(var i in t)Ev(e,i,{get:t[i],enumerable:!0})})(Yv,{generateFrameSVGs:()=>Sv,generateFrameSequence:()=>Mv,generatePhysicsFrameSVGs:()=>jv,renderChart:()=>vv,renderChartWithEvidence:()=>wv,renderDashboard:()=>Av,renderGeoToStaticSVG:()=>fv,renderNetworkToStaticSVG:()=>pv,renderOrdinalToStaticSVG:()=>hv,renderToStaticSVG:()=>uv,renderXYToStaticSVG:()=>dv,resolveTheme:()=>Fr,serializeSvgPrecision:()=>xv,themeStyles:()=>Nr}),module.exports=(Tv=Yv,Bv(Ev({},"__esModule",{value:!0}),Tv));var qv,Xv=36,Gv=34,Vv=58,Hv=22,Uv=16,Kv=6,Zv=10,Qv=22,Jv=100,ew=10,tw=3,iw=12,nw=18,ow=46,rw=26,sw=22,aw=46,cw=64,lw=34,uw=70,dw=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,hw=(e,t)=>(e>>>t|e<<32-t)>>>0,pw=e=>Math.floor(4294967296*(e-Math.floor(e)))>>>0,[fw,yw]=/* @__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(pw(Math.sqrt(i))),t.push(pw(Math.cbrt(i))))}return[e,t]})(),gw="0.1",mw=/* @__PURE__ */ge({"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"}}),xw=["fresh","stale","unknown"],bw=["partial","provisional","settled","unknown"],vw=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],ww={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:xw},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:bw},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},kw={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:xw},completeness:{values:bw}},Aw=/* @__PURE__ */new Set(["data","nodes","edges","points","areas","lines","flows","atlas","forest","circuit","edition","reading"]),Sw=44,Mw={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Sw,snap:"nearestDatum",brushHandleSize:Sw,standardControls:!1},_w={...Mw,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},$w={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}}},Pw={kind:"rank-competition"},jw=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),Iw=globalThis,Lw=Iw[jw]??(Iw[jw]=/* @__PURE__ */new Map),Rw=Wv(require("react-dom/server")),Cw=require("d3-interpolate"),Tw=864e5,Ow=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=Ue(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,Cw.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*Tw),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const n=new Date(x.getTime()+(7*e+t)*Tw);if(n.getUTCFullYear()!==a)continue;const o=Ue(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}},Ew=Wv(require("react")),Fw=require("d3-scale"),Nw=(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,Fw.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=Qe(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(Ew.createElement("line",{key:"pc-axis-line-"+e,x1:y,x2:y,y1:h,y2:p,stroke:r,strokeWidth:1})),f.push(et({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(Ew.createElement("line",{key:`pc-tick-${e}-${t}`,x1:y-3,x2:y+3,y1:n,y2:n,stroke:r,strokeWidth:1}),et({keyId:`pc-ticktext-${e}-${t}`,text:m(i),x:y+6,y:n+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Ew.createElement(Ew.Fragment,null,...f)}return{nodes:g.concat(m),overlays:x}},Dw={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})},Bw={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})},Ww={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})},Yw={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({...Bw.buildProps(e,t,i,n,o),customLayout:zw,showAxes:!1})},qw={frameType:"xy",buildProps:(e,t,i,n,o)=>({...Dw.buildProps(e,t,i,n,o),customLayout:Ow,showAxes:!1})},Xw=Wv(require("react")),Gw=require("d3-scale"),Vw={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},Hw=1e-9,Uw=.005,Kw=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={...Vw,...e},this.random=At(this.options.seed)}init(e={}){this.options={...Vw,...e},this.random=At(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(Hw,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:Mt(e.fixedPosition)}:{},shape:$t(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};St(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))Gt(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:Pt(t.shape),bodyFilter:It(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,St(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,St(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:Mt(t.fixedPosition)}:{},shape:$t(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Gt)}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(jt),colliders:this.sortedColliders().map(Lt),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=At(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=jt(t);St(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=Lt(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(Hw>=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=Yt(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=Et(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&&Nt(Et(e[r]),Et(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=_t(e,t,"y")):i=_t(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(Hw>=l)return;const u=Math.max(0,i.penetration-Uw)/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+Ct(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(Hw>=Math.abs(c)||Hw>=p)return;const f=Tt(e.friction,t.friction,this.options.friction),y=Rt(-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(!Kt(e,n))continue;if(!Nt(Et(n),Ft(e)))continue;const t=qt(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-Uw),e.y+=i.ny*Math.max(0,i.penetration-Uw);const n=e.vx*i.nx+e.vy*i.ny;if(0>n){const o=Ct(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=Tt(e.friction,t.friction,this.options.friction);e.vx-=a*r*c,e.vy-=a*s*c}St(e)}updateSensors(e){const t=/* @__PURE__ */new Set,i=this.sortedColliders().filter(e=>e.sensor);for(const n of e){const e=Et(n);for(const o of i){if(!Kt(o,n))continue;if(!Nt(e,Ft(o)))continue;if(!qt(n,o))continue;const i=Xt(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}=Gt(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()}},Zw=class{constructor(e={}){this.id="builtin",this.capabilities={...(new Kw).capabilities,engine:"builtin"},this.world=new Kw(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()}},Qw=["binId","targetBin","category","windowIndex","lane","group"],Jw=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=ri(ni(this.config.binAccessor,e,t))??si(e),n=ri(ni(this.config.labelAccessor,e,t))??i,o=oi(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,Jt(s.x,e.x),Jt(s.y,e.y),Jt(s.value,o),r>0&&(s.bodyIds.push(e.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),ai(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(ai)}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:ti(t.x),y:ti(t.y),value:ti(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)}}},ek={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},tk={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},ik={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},nk=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=ji({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=ji(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(const e of[...this.listeners])e();return i}},ok=require("d3-quadtree"),rk=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):Si(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,Ai(t)),0),this.tree=(0,ok.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},sk=["data","scene-geometry","data-paint","accessibility","evidence"],ak=["scene-geometry","data-paint","accessibility","evidence"],ck=["overlay","accessibility","evidence"],lk=(e,t)=>({retainedData:e,invalidations:t}),uk=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dk=["scene-geometry","data-paint","accessibility","evidence"],hk=[],pk={engine:lk("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:lk("preserve",dk),colliders:lk("preserve",dk),sediment:lk("preserve",dk),bodyBudget:lk("preserve",uk),bodyLimit:lk("preserve",uk),eviction:lk("preserve",uk),fixedDt:lk("preserve",hk),maxDeltaSeconds:lk("preserve",hk),maxSubsteps:lk("preserve",hk),settleStepLimit:lk("preserve",hk),timeScale:lk("preserve",hk),observation:lk("preserve",hk)},fk=lk("preserve",uk),yk=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],gk=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=Wi(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}},mk=class{constructor(e={}){this.activeSensorPairs=/* @__PURE__ */new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new rk,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new nk,this.simulationState="settled",this.visible=!0,this.quiescence=new gk;const{bodyBudget:t,colliders:i,engine:n,kernel:o,observation:r,sediment:s,...a}=e;this.config={...ek,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=n,this.observation=hi(r),this.sediment=new Jw(s??!1),this.world=Qt(n,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),i&&this.world.setColliders(bi(i))}updateConfig(e){const t=Ri(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=Qt(o,e.options),this.world.restore(e),this.revision+=1}if(r&&!Li(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=hi(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(bi(i)),this.revision+=1),this.configInput={...this.configInput,...e};const l=Ii(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(bi(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Ii(["colliders"]).invalidations)}enqueue(e,t){const i=Array.isArray(e)?e:[e],n=t?mi(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(const e of n)this.queue.push({...pi(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(wi),n.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:n.length},n.length?sk:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(pi(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},sk)}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?sk:[])),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"},sk)}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}=qi(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?sk:ak:[]),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 Yi(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}=qi(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?sk:ak),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 ci(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?ck:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?ck:[])}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?sk:[]),o}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},ak),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},ak)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},ak)}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:vi(this.bodyBudget),config:{...this.config,kernel:ki(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(xi),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:vi(e.bodyBudget??{}),kernel:ki(e.world.options)},this.bodyBudget=vi(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(xi).sort(wi),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Ei(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"},sk),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){Ci(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=Ti(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){Oi(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 di({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,Ni(t,this.observationContext(e))),t}syncSimulationState(e){const t=Ei(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const i=this.simulationState;this.simulationState=t,Fi(i,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:i,liveBodyOrder:n}=Bi(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}}},xk=require("d3-scale"),bk=require("d3-scale"),vk=require("d3-scale"),wk=require("d3-scale"),kk=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Ak=Rn(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Sk=Rn(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Mk=Rn(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),_k=Rn(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),$k=Rn(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Pk=Rn(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),jk=Rn(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Ik=Rn(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Lk=Rn(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Rk=Rn(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Ck=Rn(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Tk=Rn(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Ok={blues:Ak,reds:Sk,greens:Mk,viridis:jk,oranges:_k,purples:$k,greys:Pk,plasma:Ik,inferno:Lk,magma:Rk,cividis:Ck,turbo:Tk},Ek=Rn(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Fk=Rn(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Nk=Rn(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),zk=Rn(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Dk=Rn(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Bk=Rn(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Wk=Rn(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Yk={category10:kk,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Ok},qk=kk,Xk="#007bff",Gk=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Vk=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Hk=/* @__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"]),Uk={left:28,top:76,rightInset:30,thickness:8},Kk=1e-9,Zk=[900,520],Qk=[{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}],Jk=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),eA=1e-9,tA=fr,iA=Wv(require("react")),nA=require("react/jsx-runtime"),oA=require("d3-shape"),rA=require("react/jsx-runtime"),sA=require("react/jsx-runtime"),aA="var(--semiotic-text, #26323a)",cA="var(--semiotic-text-secondary, #6c7377)",lA="var(--semiotic-primary, #b8792d)",uA="var(--semiotic-danger, #9f3d35)",dA="var(--semiotic-success, #356b63)",hA=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],pA={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}},fA={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}},yA={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:hA,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"},gA={light:pA,dark:fA,"high-contrast":yA,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"}},mA=require("react/jsx-runtime"),xA=require("react/jsx-runtime"),bA={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"}},vA=require("react/jsx-runtime"),wA=require("react/jsx-runtime"),kA=require("react/jsx-runtime"),AA={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}},SA=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],MA={frameType:"physics",layout:AA,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=Xi({data:l?wt({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:rs(u.initialSpawns),projectionRows:u.projectionRows,foregroundGraphics:ss(zr(u.projectionRows,s,as(n,o,"showProjection"),u.metadata,o.referenceLines),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},_A={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s=Ki({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:rs(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ss(Dr(s.projectionRows,s.metadata,as(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},$A={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s="mechanical"===(o.simulationMode??o.mode),a=nn({data:s?Ji({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:rs(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:ss(Br(a.projectionRows,o.ballRadius??8,as(n,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},PA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,360],s=rn({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:rs(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ss(Yr(s.metadata,as(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},jA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,420],s=Array.isArray(o.stages)?o.stages:[],a=jn({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:rs(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,backgroundGraphics:ss(Zr(a.metadata,as(n,o,"showChrome"),{},o.chromeOptions),n.backgroundGraphics),foregroundGraphics:ss(Qr(a.projectionRows,a.metadata,as(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},IA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=co({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:rs(s.initialSpawns),projectionRows:[],backgroundGraphics:ss(as(n,o,"showChrome")?Xw.createElement(is,{layout:s.layout,states:s.states,compact:!0===n.__compactMode}):void 0,n.backgroundGraphics),foregroundGraphics:ss(as(n,o,"showProjection")?Xw.createElement(os,{layout:s.layout,states:s.states}):void 0,n.foregroundGraphics),bodyStyle:ht(t||o.colorBy)}}},LA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=br({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=xr(s,"snapshot"===o.playback?mr(s,o.snapshotAt):s.duration).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},l=No(a,c),u=c.measure??"count",d=Tr(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:Xw.createElement(Ir,{layout:s.layout,phases:s.phases,state:a,compact:520>r[0]||360>r[1]}),y=!1===o.showProjection?null:Xw.createElement(Rr,{rows:l,layout:s.layout,projection:c,amountLabel:o.amountLabel});return{...n,config:s.config,initialSpawns:rs(fr(a,s.layout,h)),projectionRows:d,bodyStyle:e=>ls(e,a,p,o),getBodyLabel:e=>us(e,a),renderBodySVG:Pr,backgroundGraphics:ss(f,n.backgroundGraphics),foregroundGraphics:ss(y,n.foregroundGraphics)}}},RA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[760,420],s=hn({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:rs(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ss(es(s.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||"source")}}},CA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[700,380],s=Fr(n.theme),a=Gn({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Or(s)??{},size:r,themeCategorical:s.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...n,config:a.config,initialSpawns:rs(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??ht(t||o.colorBy),backgroundGraphics:ss(n.backgroundGraphics,a.result.backgroundOverlays),foregroundGraphics:ss(n.foregroundGraphics,a.result.overlays)}}},TA=(e,t,i)=>({x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}),OA=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),EA={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"}]},FA=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,NA=({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=Cs(d),f=_s(p.map(e=>e.depth)),y=o.map(e=>_s(e.stepEntityCounts??[e.entityCount])),g=_s(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,_s(t,24)]})),S=_s([...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=FA(i,o),c=FA(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?Is(t,l,u):Ps(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=Je([...t.signatures].map(e=>I(n,e))),l=Ls(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:EA,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=Rs(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:NA,restyleEdge:NA}},DA=Wv(require("react")),BA=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 Ts(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(DA.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=Os(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(DA.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:DA.createElement("g",{"aria-hidden":!0},A)}},WA=Wv(require("react")),YA=Wv(require("react")).createElement,qA={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"},XA=e=>null===e?"unmeasured":1e6>e?1e3>e?e+"":Number((e/1e3).toFixed(1))+"k":Number((e/1e6).toFixed(2))+"m",GA={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"},VA={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"},HA=e=>null===e?"unmeasured":e+"",UA=WA.createElement,KA=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=Es(t,e.dimensions.width,e.dimensions.height),s=e.theme.semantic.text??"#273442",a=e.theme.semantic.surface??"#fff",c=Ns(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,Bs(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=vt(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=Fs(i.points,(m()+n.requestedTime/10)%1);return UA("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:Bs(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=>_n({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:Ws(t,r,i,n),backgroundOverlays:UA("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 UA("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"},UA("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),UA("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}),UA("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${n.x},${n.y}) rotate(${m})`,fill:"none",stroke:b}),UA("text",{x:f.x+(g?5:-5),y:f.y-7,textAnchor:g?"start":"end",fontSize:8,fill:s},`${null===i.perSecond?"?":XA(i.perSecond)} ${v}/s`))})),overlays:UA("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":n.observedAt},...r.sections.map(e=>UA("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:s},e.id)),...zs(r,n,l,s,d,c,y),...b,Ds(r,i,n,l,s,d),UA("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`))}},ZA=()=>null,QA=Ys(Ww,function({atlas:e,linkedHover:t,...i},n=As(e)){return{...i,linkedHover:ds(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]),JA=Ys(Ww,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:BA,layoutConfig:f,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:s,className:a,onObservation:c,linkedHover:ds(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}),eS=Ys(CA,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=>Bs(f.circuit,f.edition,f.reading,e)),layout:KA,layoutConfig:f,width:e,height:t,chartId:s,className:a,onObservation:c,linkedHover:ds(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)&&ZA}},[980,860]),tS=Wv(require("react")),iS=Object.freeze([]),nS={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},oS=2,rS="__forecastSegment",sS="__forecastOpacity",aS="__semiotic_resolvedX",cS="__semiotic_resolvedY",lS="__compoundGroup",uS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Ea({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Fr(n.theme).colors.categorical}),s=ua(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||Fa(e,t,i,n,o),showLegend:n.showLegend??!!t}}},dS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=ua(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||Da(e,t,i,n,o),showLegend:n.showLegend??!!t}}},hS=(require("react"),"__semioticSelectionData"),pS=Wv(require("react")),fS=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),yS=require("react/jsx-runtime"),gS={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=Za(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=Fr(n.theme),c=Ka({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:cc,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:f,axisExtent:"exact",showAxes:n.showAxes??!0,showLegend:n.showLegend??!1,annotations:Ua(n.annotations,r.xValues)}}},mS="__ma_unitized",xS="__ma_series",bS={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=lc(s,i,Fr(n.theme).colors.categorical),c=2===s.length,l=s.map(e=>e.extent||dc(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,[mS]:c?(o-r[0])/s:o,[xS]: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=Hs(Us({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>p.get((e[xS]??"")+"")||a[0],styleRules:o.styleRules,ruleContext:uc(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:mS,groupAccessor:xS,colorAccessor:xS,...h&&{axes:h},...c&&{yExtent:[0,1]},...n,curve:o.curve||n.curve||"monotoneX",showLegend:n.showLegend??!0,colorScheme:a,lineStyle:f}}},vS={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?ct(void 0,o.styleRules,it(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)+""}}}}},wS={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=Fr(n.theme).colors.categorical,l=hc(e,r,i,n,o),u=Ea({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||fc(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}}},kS={frameType:"xy",layout:{margin:(e,t)=>pa(t.marginDefaults,ha(e),t.showAxes,!!t.title)},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[],s=o.timeAccessor||"time",a=o.valueAccessor||"value",c=o.categoryAccessor,l=za(r,n,o,"explicit-then-alpha"),u=o.valueExtent||n.yExtent,d={...la(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=ct(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=>qs(e,s,"time")??NaN,valueAccessor:e=>qs(e,a,"value")??NaN,xExtent:o.timeExtent||n.xExtent,yExtent:u,invertY:"down"===o.direction,axes:ha({...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}}},AS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s=Ea({data:Array.isArray(e)?Gs(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Fr(n.theme).colors.categorical}),a=Xs({data:e,safeData:s.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),c=na(o.semanticGradient),l=c?.stops.length?{stops:c.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:ta(n.gradientFill),u=!1!==o.semanticLine?oa(c):void 0,d=n.pointStyle||fc(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||pc(a,r,i,n,o),...d&&{pointStyle:d}}}},SS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.xAccessor||"x",s=o.seriesAAccessor||"a",a=o.seriesBAccessor||"b",c=e=>aa(sa(r,"x",e)),l=e=>aa(sa(s,"a",e)),u=e=>aa(sa(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=Ks(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:Js({seriesAColor:d,seriesBColor:h,areaOpacity:p,styleRules:o.styleRules}),lineStyle:ea({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}}}},MS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s="string"==typeof r&&Array.isArray(e)?Nn(e,r,i):void 0,a="number"==typeof o.areaOpacity?o.areaOpacity:.7,c=n.lineStyle||(e=>{const t=null==r?void 0:En(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=tt(o.yAccessor),i=r?"function"==typeof r?(r(e)??"")+"":(e[r]??"")+"":void 0;Object.assign(n,at(e,c,{value:t(e),category:i}))}return n}),l=o.normalize?"zero":o.baseline??"zero",u=n.pointStyle||fc(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}}},_S={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:ct(void 0,o.styleRules,it(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)}}},$S={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=tS.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(tS.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||Fa(e,t,i,n,o),...n,showLegend:n.showLegend??!!t,...y&&{svgPreRenderers:y}}}},PS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=da(e,o),s=Ea({data:r.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Fr(n.theme).colors.categorical}),a=ua(s.annotations,o.regression),c=o.pointRadius??4,l=it(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=ca(e,t.length);100>t.length&&i.push(tS.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(tS.createElement("line",{key:"segment-"+e,x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:r,strokeWidth:c,strokeLinecap:"round"}))}return tS.createElement(tS.Fragment,null,...i)}];return{chartType:"scatter",data:s.data,xAccessor:s.xAccessor,yAccessor:s.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Hs(e=>{const t=r.orderMap.get(e),i=t?.idx??0,n=t?.total??1,o={fill:n>0?ca(i,n):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1};return u?.length&&Object.assign(o,at(e,u,l(e))),o},la(o)),...n,...a&&a.length>0&&{annotations:a},...s.yExtent&&!n.yExtent&&{yExtent:s.yExtent},svgPreRenderers:d}}},jS=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}},IS=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=yc(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)}},LS=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}},RS=(e,t)=>e-t,CS=class{constructor(e,t){this.stats=new jS,this.digest=e?new LS:null,this.hll=t?new IS: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)}},TS=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 CS(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&&mc(this.starts,e,RS)}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(xc(this.starts,RS));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[gc(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}},OS={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},ES=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,FS="time",NS="value",zS="__aggLower",DS="__aggUpper",BS="__aggPartial",WS="count",YS="__aggStart",qS="__aggEnd",XS="__aggSeries",GS=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){const n=qs(e,t,"time"),o=qs(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=kc(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 Ac(n,e))t.push(null==this.seriesAccessor?o:{...o,[XS]:i});return t}clear(){this.groups.clear()}},VS={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=ct(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:s}),o.styleRules,Mc(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}}}},HS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=$c(e,o),s=o.aggregate,a=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:Pc(o),c=ct(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,it(a.timeAccessor,a.valueAccessor));return{chartType:"line",data:r,...n,...jc(r,n,o),...a,groupAccessor:s&&null!=o.seriesAccessor?XS: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:DS,perSeries:null!=o.seriesAccessor}:void 0)},lineStyle:n.lineStyle||(e=>({...c(e),...la(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))};var l}},US={...kS,buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[];return{...kS.buildProps(r,t,i,n,o),...jc(r,n,o)}}},KS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[];return{...VS.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...jc(r,n,o),categoryAccessor:o.categoryAccessor}}},ZS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[],s=za(r,n,o,"discovery"),a=ct(void 0,o.styleRules,it(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:r,...n,...jc(r,n,o),categoryAccessor:o.categoryAccessor,colorScheme:s||i||n.colorScheme,barColors:s,yScaleType:o.yScaleType,swarmStyle:{...la(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})}}},QS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[],s=vS.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...s,...jc(r,n,o),waterfallStyle:{...s.waterfallStyle,cursor:o.cursor}}}},JS=(require("react"),{RdBu:Ek,PiYG:Fk,PRGn:Nk,BrBG:zk,RdYlBu:Dk,RdYlGn:Bk,Spectral:Wk}),eM="__likert_neutral_neg",tM="__likert_neutral_pos",iM={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,n,o,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=Rc(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s,Ic(r.categoryAccessor,"question"),r.levelAccessor?null:Ic(r.valueAccessor,"score"),r.levelAccessor?Ic(r.levelAccessor,"level"):null,r.levelAccessor?Ic(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=Tc(Cc(c,s),s));const l=Fr(o.theme).colors.diverging,u=Array.isArray(n)&&n.length>=s.length?n:Lc(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=i(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:s.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},o.legend),y=r.styleRules,g=o.pieceStyle;return{chartType:"bar",data:c,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:r.barPadding,showGrid:o.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(a?void 0:"Percentage"),rFormat:p,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...o,pieceStyle:Hs((e,t)=>{const i=e.__likertLevel||e.data?.__likertLevel,n=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,r={fill:i===eM||i===tM?h:d.get((n||i)+"")||"#888"};return y?.length&&Object.assign(r,at(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},la(r)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},nM=require("react/jsx-runtime"),oM=require("react/jsx-runtime"),rM={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,Jj.jsx)("g",{transform:`translate(${u},${d})`,children:p}),f&&/* @__PURE__ */ /* @__PURE__ */(0,Jj.jsx)("text",{x:t/2,y:Hv,textAnchor:"middle",fontSize:s.titleFontSize,fontWeight:s.titleFontWeight,fill:s.text,fontFamily:s.titleFontFamily,children:f})]}))}var Tv,Ov=Object.create,Ev=Object.defineProperty,Fv=Object.getOwnPropertyDescriptor,Nv=Object.getOwnPropertyNames,zv=Object.getPrototypeOf,Dv=Object.prototype.hasOwnProperty,Bv=(e,t,i,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of Nv(t))Dv.call(e,o)||o===i||Ev(e,o,{get:()=>t[o],enumerable:!(n=Fv(t,o))||n.enumerable});return e},Wv=(e,t,i)=>(i=null!=e?Ov(zv(e)):{},Bv(!t&&e&&e.__esModule?i:Ev(i,"default",{value:e,enumerable:!0}),e)),Yv={};((e,t)=>{for(var i in t)Ev(e,i,{get:t[i],enumerable:!0})})(Yv,{generateFrameSVGs:()=>Sv,generateFrameSequence:()=>Mv,generatePhysicsFrameSVGs:()=>jv,renderChart:()=>vv,renderChartWithEvidence:()=>wv,renderDashboard:()=>Av,renderGeoToStaticSVG:()=>fv,renderNetworkToStaticSVG:()=>pv,renderOrdinalToStaticSVG:()=>hv,renderToStaticSVG:()=>uv,renderXYToStaticSVG:()=>dv,resolveTheme:()=>Dr,serializeSvgPrecision:()=>xv,themeStyles:()=>Br}),module.exports=(Tv=Yv,Bv(Ev({},"__esModule",{value:!0}),Tv));var qv,Xv=36,Gv=34,Vv=58,Hv=22,Uv=16,Kv=6,Zv=10,Qv=22,Jv=100,ew=10,tw=3,iw=12,nw=18,ow=46,rw=26,sw=22,aw=46,cw=64,lw=34,uw=70,dw=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,hw=(e,t)=>(e>>>t|e<<32-t)>>>0,pw=e=>Math.floor(4294967296*(e-Math.floor(e)))>>>0,[fw,yw]=/* @__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(pw(Math.sqrt(i))),t.push(pw(Math.cbrt(i))))}return[e,t]})(),gw="0.1",mw=/* @__PURE__ */ge({"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"}}),xw=["fresh","stale","unknown"],bw=["partial","provisional","settled","unknown"],vw=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],ww={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:xw},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:bw},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},kw={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:xw},completeness:{values:bw}},Aw=/* @__PURE__ */new Set(["data","nodes","edges","points","areas","lines","flows","atlas","forest","circuit","edition","reading"]),Sw=44,Mw={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:Sw,snap:"nearestDatum",brushHandleSize:Sw,standardControls:!1},_w={...Mw,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},$w={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}}},Pw={kind:"rank-competition"},jw=/* @__PURE__ */Symbol.for("semiotic.semantic-viability"),Iw=globalThis,Lw=Iw[jw]??(Iw[jw]=/* @__PURE__ */new Map),Rw=Wv(require("react-dom/server")),Cw=require("d3-interpolate"),Tw=864e5,Ow=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=Ue(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,Cw.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*Tw),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const n=new Date(x.getTime()+(7*e+t)*Tw);if(n.getUTCFullYear()!==a)continue;const o=Ue(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}},Ew=Wv(require("react")),Fw=require("d3-scale"),Nw=(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,Fw.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=Qe(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(Ew.createElement("line",{key:"pc-axis-line-"+e,x1:y,x2:y,y1:h,y2:p,stroke:r,strokeWidth:1})),f.push(et({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(Ew.createElement("line",{key:`pc-tick-${e}-${t}`,x1:y-3,x2:y+3,y1:n,y2:n,stroke:r,strokeWidth:1}),et({keyId:`pc-ticktext-${e}-${t}`,text:m(i),x:y+6,y:n+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Ew.createElement(Ew.Fragment,null,...f)}return{nodes:g.concat(m),overlays:x}},Dw={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})},Bw={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})},Ww={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})},Yw={frameType:"ordinal",buildProps:(e,t,i,n,o)=>({...Bw.buildProps(e,t,i,n,o),customLayout:zw,showAxes:!1})},qw={frameType:"xy",buildProps:(e,t,i,n,o)=>({...Dw.buildProps(e,t,i,n,o),customLayout:Ow,showAxes:!1})},Xw=Wv(require("react")),Gw=require("d3-scale"),Vw={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},Hw=1e-9,Uw=.005,Kw=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={...Vw,...e},this.random=_t(this.options.seed)}init(e={}){this.options={...Vw,...e},this.random=_t(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(Hw,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:Pt(e.fixedPosition)}:{},shape:It(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))Ut(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:Lt(t.shape),bodyFilter:Ct(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:Pt(t.fixedPosition)}:{},shape:It(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Ut)}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(Rt),colliders:this.sortedColliders().map(Tt),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=_t(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=Rt(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=Tt(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(Hw>=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=Gt(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=zt(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&&Bt(zt(e[r]),zt(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=jt(e,t,"y")):i=jt(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(Hw>=l)return;const u=Math.max(0,i.penetration-Uw)/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+Et(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(Hw>=Math.abs(c)||Hw>=p)return;const f=Ft(e.friction,t.friction,this.options.friction),y=Ot(-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(!Jt(e,n))continue;if(!Bt(zt(n),Dt(e)))continue;const t=Vt(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-Uw),e.y+=i.ny*Math.max(0,i.penetration-Uw);const n=e.vx*i.nx+e.vy*i.ny;if(0>n){const o=Et(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=Ft(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=zt(n);for(const o of i){if(!Jt(o,n))continue;if(!Bt(e,Dt(o)))continue;if(!Vt(n,o))continue;const i=Ht(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}=Ut(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()}},Zw=class{constructor(e={}){this.id="builtin",this.capabilities={...(new Kw).capabilities,engine:"builtin"},this.world=new Kw(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()}},Qw=["binId","targetBin","category","windowIndex","lane","group"],Jw=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=ci(si(this.config.binAccessor,e,t))??li(e),n=ci(si(this.config.labelAccessor,e,t))??i,o=ai(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,ii(s.x,e.x),ii(s.y,e.y),ii(s.value,o),r>0&&(s.bodyIds.push(e.id),s.bodyIds.length>r&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-r))),ui(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(ui)}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:oi(t.x),y:oi(t.y),value:oi(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)}}},ek={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},tk={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},ik={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},nk=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=Ri({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=Ri(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(const e of[...this.listeners])e();return i}},ok=require("d3-quadtree"),rk=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,_i(t)),0),this.tree=(0,ok.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},sk=["data","scene-geometry","data-paint","accessibility","evidence"],ak=["scene-geometry","data-paint","accessibility","evidence"],ck=["overlay","accessibility","evidence"],lk=(e,t)=>({retainedData:e,invalidations:t}),uk=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dk=["scene-geometry","data-paint","accessibility","evidence"],hk=[],pk={engine:lk("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:lk("preserve",dk),colliders:lk("preserve",dk),sediment:lk("preserve",dk),bodyBudget:lk("preserve",uk),bodyLimit:lk("preserve",uk),eviction:lk("preserve",uk),fixedDt:lk("preserve",hk),maxDeltaSeconds:lk("preserve",hk),maxSubsteps:lk("preserve",hk),settleStepLimit:lk("preserve",hk),timeScale:lk("preserve",hk),observation:lk("preserve",hk)},fk=lk("preserve",uk),yk=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],gk=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=Xi(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}},mk=class{constructor(e={}){this.activeSensorPairs=/* @__PURE__ */new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new rk,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new nk,this.simulationState="settled",this.visible=!0,this.quiescence=new gk;const{bodyBudget:t,colliders:i,engine:n,kernel:o,observation:r,sediment:s,...a}=e;this.config={...ek,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=n,this.observation=yi(r),this.sediment=new Jw(s??!1),this.world=ti(n,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),i&&this.world.setColliders(ki(i))}updateConfig(e){const t=Oi(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=ti(o,e.options),this.world.restore(e),this.revision+=1}if(r&&!Ti(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=yi(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(ki(i)),this.revision+=1),this.configInput={...this.configInput,...e};const l=Ci(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(ki(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Ci(["colliders"]).invalidations)}enqueue(e,t){const i=Array.isArray(e)?e:[e],n=t?vi(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(const e of n)this.queue.push({...gi(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Si),n.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:n.length},n.length?sk:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(gi(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},sk)}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?sk:[])),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"},sk)}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}=Vi(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?sk:ak:[]),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 Gi(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}=Vi(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?sk:ak),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 di(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?ck:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?ck:[])}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?sk:[]),o}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},ak),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},ak)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},ak)}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:Ai(this.bodyBudget),config:{...this.config,kernel:Mi(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(wi),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:Ai(e.bodyBudget??{}),kernel:Mi(e.world.options)},this.bodyBudget=Ai(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(wi).sort(Si),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??zi(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"},sk),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){Ei(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=Fi(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){Ni(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 fi({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,Bi(t,this.observationContext(e))),t}syncSimulationState(e){const t=zi(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const i=this.simulationState;this.simulationState=t,Di(i,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:i,liveBodyOrder:n}=qi(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}}},xk=require("d3-scale"),bk=require("d3-scale"),vk=require("d3-scale"),wk=require("d3-scale"),kk=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Ak=On(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Sk=On(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Mk=On(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),_k=On(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),$k=On(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Pk=On(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),jk=On(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Ik=On(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Lk=On(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Rk=On(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Ck=On(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Tk=On(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Ok={blues:Ak,reds:Sk,greens:Mk,viridis:jk,oranges:_k,purples:$k,greys:Pk,plasma:Ik,inferno:Lk,magma:Rk,cividis:Ck,turbo:Tk},Ek=On(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Fk=On(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Nk=On(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),zk=On(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Dk=On(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Bk=On(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Wk=On(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Yk={category10:kk,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Ok},qk=kk,Xk="#007bff",Gk=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Vk=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Hk=/* @__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"]),Uk={left:28,top:76,rightInset:30,thickness:8},Kk=1e-9,Zk=[900,520],Qk=[{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}],Jk=/* @__PURE__ */new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),eA=1e-9,tA=mr,iA=Wv(require("react")),nA=require("react/jsx-runtime"),oA=require("d3-shape"),rA=require("react/jsx-runtime"),sA=require("react/jsx-runtime"),aA="var(--semiotic-text, #26323a)",cA="var(--semiotic-text-secondary, #6c7377)",lA="var(--semiotic-primary, #b8792d)",uA="var(--semiotic-danger, #9f3d35)",dA="var(--semiotic-success, #356b63)",hA=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],pA={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}},fA={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}},yA={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:hA,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"},gA={light:pA,dark:fA,"high-contrast":yA,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"}},mA=require("react/jsx-runtime"),xA=require("react/jsx-runtime"),bA={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"}},vA=require("react/jsx-runtime"),wA=require("react/jsx-runtime"),kA=require("react/jsx-runtime"),AA={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}},SA=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],MA={frameType:"physics",layout:AA,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=Hi({data:l?wt({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:cs(u.initialSpawns),projectionRows:u.projectionRows,foregroundGraphics:ls(Wr(u.projectionRows,s,us(n,o,"showProjection"),u.metadata,o.referenceLines),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},_A={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s=Ji({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:cs(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ls(Yr(s.projectionRows,s.metadata,us(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},$A={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,400],s="mechanical"===(o.simulationMode??o.mode),a=sn({data:s?nn({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:cs(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:ls(qr(a.projectionRows,o.ballRadius??8,us(n,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},PA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[600,360],s=cn({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:cs(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ls(Gr(s.metadata,us(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},jA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,420],s=Array.isArray(o.stages)?o.stages:[],a=Rn({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:cs(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,backgroundGraphics:ls(es(a.metadata,us(n,o,"showChrome"),{},o.chromeOptions),n.backgroundGraphics),foregroundGraphics:ls(ts(a.projectionRows,a.metadata,us(n,o,"showProjection")),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},IA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=ho({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:cs(s.initialSpawns),projectionRows:[],backgroundGraphics:ls(us(n,o,"showChrome")?Xw.createElement(rs,{layout:s.layout,states:s.states,compact:!0===n.__compactMode}):void 0,n.backgroundGraphics),foregroundGraphics:ls(us(n,o,"showProjection")?Xw.createElement(as,{layout:s.layout,states:s.states}):void 0,n.foregroundGraphics),bodyStyle:ht(t||o.colorBy)}}},LA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[900,520],s=kr({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=wr(s,"snapshot"===o.playback?vr(s,o.snapshotAt):s.duration).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},l=Bo(a,c),u=c.measure??"count",d=Fr(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:Xw.createElement(Cr,{layout:s.layout,phases:s.phases,state:a,compact:520>r[0]||360>r[1]}),y=!1===o.showProjection?null:Xw.createElement(Or,{rows:l,layout:s.layout,projection:c,amountLabel:o.amountLabel});return{...n,config:s.config,initialSpawns:cs(mr(a,s.layout,h)),projectionRows:d,bodyStyle:e=>hs(e,a,p,o),getBodyLabel:e=>ps(e,a),renderBodySVG:Lr,backgroundGraphics:ls(f,n.backgroundGraphics),foregroundGraphics:ls(y,n.foregroundGraphics)}}},RA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[760,420],s=yn({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:cs(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:ls(ns(s.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),n.foregroundGraphics),bodyStyle:ht(t||o.colorBy||"source")}}},CA={frameType:"physics",layout:AA,buildProps:(e,t,i,n,o)=>{const r=n.size??[700,380],s=Dr(n.theme),a=Un({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Nr(s)??{},size:r,themeCategorical:s.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...n,config:a.config,initialSpawns:cs(a.initialSpawns),projectionRows:[],bodyStyle:a.result.bodyStyle??ht(t||o.colorBy),backgroundGraphics:ls(n.backgroundGraphics,a.result.backgroundOverlays),foregroundGraphics:ls(n.foregroundGraphics,a.result.overlays)}}},TA=(e,t,i)=>({x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}),OA=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),EA={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"}]},FA=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,NA=({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=Cs(d),f=Mt(p.map(e=>e.depth)),y=o.map(e=>Mt(e.stepEntityCounts??[e.entityCount])),g=Mt(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,Mt(t,24)]})),S=Mt([...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=FA(i,o),c=FA(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?Is(t,l,u):Ps(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=Je([...t.signatures].map(e=>I(n,e))),l=Ls(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:EA,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=Rs(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:NA,restyleEdge:NA}},DA=Wv(require("react")),BA=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 Ts(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(DA.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=Os(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(DA.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:DA.createElement("g",{"aria-hidden":!0},A)}},WA=Wv(require("react")),YA=Wv(require("react")).createElement,qA={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"},XA=e=>null===e?"unmeasured":1e6>e?1e3>e?e+"":Number((e/1e3).toFixed(1))+"k":Number((e/1e6).toFixed(2))+"m",GA={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"},VA={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"},HA=e=>null===e?"unmeasured":e+"",UA=WA.createElement,KA=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=Es(t,e.dimensions.width,e.dimensions.height),s=e.theme.semantic.text??"#273442",a=e.theme.semantic.surface??"#fff",c=Ns(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,Bs(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=vt(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=Fs(i.points,(m()+n.requestedTime/10)%1);return UA("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:Bs(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=>jn({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:Ws(t,r,i,n),backgroundOverlays:UA("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 UA("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"},UA("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),UA("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}),UA("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${n.x},${n.y}) rotate(${m})`,fill:"none",stroke:b}),UA("text",{x:f.x+(g?5:-5),y:f.y-7,textAnchor:g?"start":"end",fontSize:8,fill:s},`${null===i.perSecond?"?":XA(i.perSecond)} ${v}/s`))})),overlays:UA("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":n.observedAt},...r.sections.map(e=>UA("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:s},e.id)),...zs(r,n,l,s,d,c,y),...b,Ds(r,i,n,l,s,d),UA("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`))}},ZA=()=>null,QA=Ys(Ww,function({atlas:e,linkedHover:t,...i},n=_s(e)){return{...i,linkedHover:fs(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]),JA=Ys(Ww,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:BA,layoutConfig:f,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:s,className:a,onObservation:c,linkedHover:fs(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}),eS=Ys(CA,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=>Bs(f.circuit,f.edition,f.reading,e)),layout:KA,layoutConfig:f,width:e,height:t,chartId:s,className:a,onObservation:c,linkedHover:fs(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)&&ZA}},[980,860]),tS=Wv(require("react")),iS=Object.freeze([]),nS={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},oS=2,rS="__forecastSegment",sS="__forecastOpacity",aS="__semiotic_resolvedX",cS="__semiotic_resolvedY",lS="__compoundGroup",uS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Ea({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Dr(n.theme).colors.categorical}),s=ua(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||Fa(e,t,i,n,o),showLegend:n.showLegend??!!t}}},dS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=ua(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||Da(e,t,i,n,o),showLegend:n.showLegend??!!t}}},hS=(require("react"),"__semioticSelectionData"),pS=Wv(require("react")),fS=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),yS=require("react/jsx-runtime"),gS={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=Za(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=Dr(n.theme),c=Ka({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:cc,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:f,axisExtent:"exact",showAxes:n.showAxes??!0,showLegend:n.showLegend??!1,annotations:Ua(n.annotations,r.xValues)}}},mS="__ma_unitized",xS="__ma_series",bS={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=lc(s,i,Dr(n.theme).colors.categorical),c=2===s.length,l=s.map(e=>e.extent||dc(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,[mS]:c?(o-r[0])/s:o,[xS]: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=Hs(Us({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>p.get((e[xS]??"")+"")||a[0],styleRules:o.styleRules,ruleContext:uc(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:mS,groupAccessor:xS,colorAccessor:xS,...h&&{axes:h},...c&&{yExtent:[0,1]},...n,curve:o.curve||n.curve||"monotoneX",showLegend:n.showLegend??!0,colorScheme:a,lineStyle:f}}},vS={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?ct(void 0,o.styleRules,it(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)+""}}}}},wS={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=Dr(n.theme).colors.categorical,l=hc(e,r,i,n,o),u=Ea({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||fc(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}}},kS={frameType:"xy",layout:{margin:(e,t)=>pa(t.marginDefaults,ha(e),t.showAxes,!!t.title)},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[],s=o.timeAccessor||"time",a=o.valueAccessor||"value",c=o.categoryAccessor,l=za(r,n,o,"explicit-then-alpha"),u=o.valueExtent||n.yExtent,d={...la(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=ct(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=>qs(e,s,"time")??NaN,valueAccessor:e=>qs(e,a,"value")??NaN,xExtent:o.timeExtent||n.xExtent,yExtent:u,invertY:"down"===o.direction,axes:ha({...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}}},AS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s=Ea({data:Array.isArray(e)?Gs(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Dr(n.theme).colors.categorical}),a=Xs({data:e,safeData:s.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),c=na(o.semanticGradient),l=c?.stops.length?{stops:c.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:ta(n.gradientFill),u=!1!==o.semanticLine?oa(c):void 0,d=n.pointStyle||fc(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||pc(a,r,i,n,o),...d&&{pointStyle:d}}}},SS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=o.xAccessor||"x",s=o.seriesAAccessor||"a",a=o.seriesBAccessor||"b",c=e=>aa(sa(r,"x",e)),l=e=>aa(sa(s,"a",e)),u=e=>aa(sa(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=Ks(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:Js({seriesAColor:d,seriesBColor:h,areaOpacity:p,styleRules:o.styleRules}),lineStyle:ea({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}}}},MS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=t||o.areaBy,s="string"==typeof r&&Array.isArray(e)?Bn(e,r,i):void 0,a="number"==typeof o.areaOpacity?o.areaOpacity:.7,c=n.lineStyle||(e=>{const t=null==r?void 0:zn(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=tt(o.yAccessor),i=r?"function"==typeof r?(r(e)??"")+"":(e[r]??"")+"":void 0;Object.assign(n,at(e,c,{value:t(e),category:i}))}return n}),l=o.normalize?"zero":o.baseline??"zero",u=n.pointStyle||fc(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}}},_S={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:ct(void 0,o.styleRules,it(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)}}},$S={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=tS.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(tS.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||Fa(e,t,i,n,o),...n,showLegend:n.showLegend??!!t,...y&&{svgPreRenderers:y}}}},PS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=da(e,o),s=Ea({data:r.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:n.annotations,themeCategorical:Dr(n.theme).colors.categorical}),a=ua(s.annotations,o.regression),c=o.pointRadius??4,l=it(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=ca(e,t.length);100>t.length&&i.push(tS.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(tS.createElement("line",{key:"segment-"+e,x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:r,strokeWidth:c,strokeLinecap:"round"}))}return tS.createElement(tS.Fragment,null,...i)}];return{chartType:"scatter",data:s.data,xAccessor:s.xAccessor,yAccessor:s.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Hs(e=>{const t=r.orderMap.get(e),i=t?.idx??0,n=t?.total??1,o={fill:n>0?ca(i,n):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1};return u?.length&&Object.assign(o,at(e,u,l(e))),o},la(o)),...n,...a&&a.length>0&&{annotations:a},...s.yExtent&&!n.yExtent&&{yExtent:s.yExtent},svgPreRenderers:d}}},jS=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}},IS=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=yc(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)}},LS=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}},RS=(e,t)=>e-t,CS=class{constructor(e,t){this.stats=new jS,this.digest=e?new LS:null,this.hll=t?new IS: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)}},TS=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 CS(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&&mc(this.starts,e,RS)}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(xc(this.starts,RS));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[gc(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}},OS={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},ES=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g,FS="time",NS="value",zS="__aggLower",DS="__aggUpper",BS="__aggPartial",WS="count",YS="__aggStart",qS="__aggEnd",XS="__aggSeries",GS=class{constructor(e,t){this.config=e,this.seriesAccessor=t,this.groups=/* @__PURE__ */new Map}push(e,t,i){const n=qs(e,t,"time"),o=qs(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=kc(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 Ac(n,e))t.push(null==this.seriesAccessor?o:{...o,[XS]:i});return t}clear(){this.groups.clear()}},VS={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=ct(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:s}),o.styleRules,Mc(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}}}},HS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=$c(e,o),s=o.aggregate,a=o.aggregate?{timeAccessor:"time",valueAccessor:"value"}:Pc(o),c=ct(()=>({stroke:"#007bff",strokeWidth:2}),o.styleRules,it(a.timeAccessor,a.valueAccessor));return{chartType:"line",data:r,...n,...jc(r,n,o),...a,groupAccessor:s&&null!=o.seriesAccessor?XS: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:DS,perSeries:null!=o.seriesAccessor}:void 0)},lineStyle:n.lineStyle||(e=>({...c(e),...la(o),...null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray},...null!=o.cursor&&{cursor:o.cursor}}))};var l}},US={...kS,buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[];return{...kS.buildProps(r,t,i,n,o),...jc(r,n,o)}}},KS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[];return{...VS.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value",heatmapAggregation:o.aggregation??"count",cellBorderWidth:0}),...jc(r,n,o),categoryAccessor:o.categoryAccessor}}},ZS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[],s=za(r,n,o,"discovery"),a=ct(void 0,o.styleRules,it(o.timeAccessor??"time",o.valueAccessor??"value"));return{chartType:"swarm",data:r,...n,...jc(r,n,o),categoryAccessor:o.categoryAccessor,colorScheme:s||i||n.colorScheme,barColors:s,yScaleType:o.yScaleType,swarmStyle:{...la(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})}}},QS={frameType:"xy",buildProps:(e,t,i,n,o)=>{const r=Array.isArray(e)?Gs(e):[],s=vS.buildProps(r,t,i,n,{...o,xAccessor:o.timeAccessor||o.xAccessor||"time",yAccessor:o.valueAccessor||o.yAccessor||"value"});return{...s,...jc(r,n,o),waterfallStyle:{...s.waterfallStyle,cursor:o.cursor}}}},JS=(require("react"),{RdBu:Ek,PiYG:Fk,PRGn:Nk,BrBG:zk,RdYlBu:Dk,RdYlGn:Bk,Spectral:Wk}),eM="__likert_neutral_neg",tM="__likert_neutral_pos",iM={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,n,o,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=Rc(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s,Ic(r.categoryAccessor,"question"),r.levelAccessor?null:Ic(r.valueAccessor,"score"),r.levelAccessor?Ic(r.levelAccessor,"level"):null,r.levelAccessor?Ic(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=Tc(Cc(c,s),s));const l=Dr(o.theme).colors.diverging,u=Array.isArray(n)&&n.length>=s.length?n:Lc(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=i(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:s.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},o.legend),y=r.styleRules,g=o.pieceStyle;return{chartType:"bar",data:c,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:a?"horizontal":"vertical",barPadding:r.barPadding,showGrid:o.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(a?void 0:"Percentage"),rFormat:p,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...o,pieceStyle:Hs((e,t)=>{const i=e.__likertLevel||e.data?.__likertLevel,n=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,r={fill:i===eM||i===tM?h:d.get((n||i)+"")||"#888"};return y?.length&&Object.assign(r,at(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},la(r)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},nM=require("react/jsx-runtime"),oM=require("react/jsx-runtime"),rM={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,oM.jsxs)(oM.Fragment,{children:[i.showNeedle&&/* @__PURE__ */ /* @__PURE__ */(0,oM.jsxs)(oM.Fragment,{children:[
591
591
  /* @__PURE__ */
592
592
  /* @__PURE__ */(0,oM.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,oM.jsxs)("g",{children:[
596
596
  /* @__PURE__ */
597
597
  /* @__PURE__ */(0,oM.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,oM.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}=Wc(a),h=o.thresholds,p=ia(n.gradientFill),f=Bc({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=Yc(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:Oc({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:Hs((e,t)=>{const i={...f.pieceStyle(e,t)};return y?.length&&Object.assign(i,at(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},la(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))}}}}},sM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=ua(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:qc(n.gradientFill),pieceStyle:Xc(e,t,i,n,o)}}},aM={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:qc(n.gradientFill),pieceStyle:Xc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},cM={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:qc(n.gradientFill),pieceStyle:Xc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},lM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=tt(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:Xc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)}),showLegend:n.showLegend??!!r}}},uM={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=tt(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:Xc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)})}}},dM={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:Gc(e,t,i,n,o,"count")}}},hM={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:Gc(e,t,i,n,o)})},pM={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:Vc(e,t,i,n,o),showLegend:n.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},fM={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:Uc(e,t,i,n,o),showLegend:n.showLegend??!!t})},yM={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,n,o)=>{const r=ua(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:Hc(e,t,i,n,o),showGrid:n.showGrid??!0,showLegend:n.showLegend??!!t}}},gM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=o.seriesAccessor||t||"__radar",s=t||("__radar"===r?void 0:r),a=Hc(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}}},mM={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:qc(n.gradientFill),pieceStyle:Xc(e,r,i,n,o),showLegend:n.showLegend??!!r,barPadding:o.barPadding??40}}},xM={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:Gc(e,t,i,n,o,"median",.5),showLegend:n.showLegend??!!t})},bM={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:Xc(e,s,i,n,o),showLabels:o.showLabels??!0}}},vM=require("d3-scale"),wM={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},kM=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),AM=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},SM=828*AM(8),MM=3e3,_M=/* @__PURE__ */new Map,$M=1e5,PM=1e-9,jM=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,IM=require("react/jsx-runtime"),LM="var(--semiotic-grid, #94a3b8)",RM="var(--semiotic-text-secondary, #475569)",CM="var(--semiotic-text-secondary, #94a3b8)",TM=.22,OM=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=!Vu(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,TM):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!Vu({__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?TM: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=!Vu(i,r,o);s.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:n?TM:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...n&&t?{opacity:TM}:{}},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&&Vu({__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}},EM={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||Vs(la(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:Uu([],r,o.sourceAccessor||"source",o.targetAccessor||"target"),a=Fr(n.theme).colors.categorical,c=Tn(i,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,d=t?Nn(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=En(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=lt(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:Hs(o.nodeStyle||(y?(e,t)=>({...f(e,t),...y(e,t)}):f),la(o)),...n,showLegend:(n.showLegend??!!t)&&!!t}}},FM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Qu(o),s=Fr(n.theme).colors.categorical,a=/* @__PURE__ */new Map,c=o.nodeStyle??(e=>({fill:t?En(e?.data||e,t,void 0):Va(void 0,s,i,void 0,a),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),l=lt(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=Hs(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}}},NM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Fr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Hu(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?Nn(l,u,i??n.colorScheme??r):void 0,h=o.showLabels??n.showLabels,p=n.nodeStyle||o.nodeStyle,f=ct(e=>{const n=e?.data||e;return{fill:o.colorByDepth?Vk[Number(e?.depth||0)%Vk.length]:t?c?En({__ssrCirclePackColorBy:c(n)},"__ssrCirclePackColorBy",d??void 0):En(n,t,d??void 0):Va(void 0,r,i,void 0,s),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,nt(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:Zu(f,p,la(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=Fr(n.theme).colors.categorical,l=i??n.colorScheme??c,u=Tn(l,c),d=Hu(r,s),h="__ssrOrbitColorBy",p="function"==typeof t?t:null,f=t?Nn(p?d.map(e=>({[h]:p(e)})):d,p?h:t,l):void 0,y=ct(e=>{const i=e.data||e,n=Number(e.depth??0);return{fill:o.colorByDepth?0===n?u[0]:Vk[n%Vk.length]:t?p?En({[h]:p(i)},h,f):En(i,t,f):u[0],stroke:"#fff",strokeWidth:1,opacity:0===n?1:.85}},o.styleRules,nt(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:Hs(y,la(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},DM={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,n,o,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:Uu([],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,_]=o.size??[600,400],$=o.margin,P="vertical"===r.orientation?"vertical":"horizontal",j={...qu(!!o.title,!!r.showQualityReadout,Array.isArray(r.axisTicks)&&r.axisTicks.length>0,P),...$},I=(o.showLegend??!!t)&&!!t,L=o.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=Tn(n,Fr(o.theme).colors.categorical,kk),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=n??[...O],D=N?Nn(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?En({_cat:E(i)},"_cat",D??void 0):En(i,"string"==typeof t?t:"id",D??void 0)}return O[i%O.length]},Y=i(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,o.legend),q=!1!==r.showLabels&&("auto"!==r.showLabels||"auto"),{layout:X,layoutConfig:G,issues:V,xScale:H}=Yu({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(tl).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const U=X?Xu({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:OM,layoutConfig:G,sourceAccessor:a,targetAccessor:c,valueAccessor:l,nodeIDAccessor:u,colorBy:t,colorScheme:n,...U&&{backgroundGraphics:U},...o,showLegend:I,...Y&&{legend:Y,legendPosition:L},__legendIncludesAutomatic:!0,margin:R}}},BM={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(o.nodes)?o.nodes:Uu([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),s=Fr(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?Nn(l,c,i??n.colorScheme??s):void 0,d=e=>({fill:t?En(e?.data||e,t,u):Va(void 0,s,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=lt(o.styleRules,t,o.valueAccessor),p=h?(e,t)=>({...d(e),...h(e,t)}):d,f=Ku({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:Hs(o.nodeStyle||p,la(o)),edgeStyle:Hs(o.edgeStyle||f,la(o)),colorScheme:i,...n,showLegend:(n.showLegend??!!t)&&!!t}}},WM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Fr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Hu(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?Nn(l,u,i??n.colorScheme??r):void 0,h=!1!==o.showLabels,p=n.nodeStyle||o.nodeStyle,f=ct(e=>{const n=e?.data||e;return{fill:o.colorByDepth?Vk[Number(e?.depth||0)%Vk.length]:t?c?En({__ssrTreeColorBy:c(n)},"__ssrTreeColorBy",d??void 0):En(n,t,d??void 0):Va(void 0,r,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,nt(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:Zu(f,p,la(o))}}},YM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Fr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Hu(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?Nn(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=ct(e=>{const n=e?.data||e;return{fill:o.colorByDepth?Vk[Number(e?.depth||0)%Vk.length]:t?c?En({__ssrTreemapColorBy:c(n)},"__ssrTreemapColorBy",d??void 0):En(n,t,d??void 0):Va(void 0,r,i,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,nt(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:Zu(m,g,la(o))}}},qM={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},XM=require("d3-scale"),GM={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=nd(o.areas,o.valueAccessor,r),a=o.areaStyle??od(s,o.areaOpacity??1),c=o.styleRules?ct(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},id):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}:{}}}},VM={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??td(r,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=o.styleRules?ct(s,o.styleRules,nt(t,o.sizeBy)):s;return{points:r,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||qM,pointStyle:a,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...n}}},HM={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??td(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?ct(s,o.styleRules,nt(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}}}},UM={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?Nn(g.map(e=>({[m]:f(e)})),m,i||"category10"):Nn(g,f,i||"category10"):null,b=g.map(e=>Number(e[a]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?Ss(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||qM,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:ed({valueAccessor:a,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>f&&x?En(e,f,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...n}}},KM=Wv(require("react-dom/server")),ZM=Wv(require("react")),QM=Wv(require("react-dom/server")),JM=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}},e_=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}},t_=/^\d{4}-\d{1,2}$/,i_=/* @__PURE__ */Object.create(null),n_="undefined"==typeof window||"undefined"==typeof document,o_=/* @__PURE__ */new Set,r_=require("d3-scale"),s_=/* @__PURE__ */new WeakMap,a_=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],c_=["scene-style","data-paint","accessibility","evidence"],l_=(e,t)=>({retainedData:e,invalidations:t}),u_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],d_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],h_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],p_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],f_=["scene-geometry","data-paint","accessibility","evidence"],y_=["scene-style","data-paint","accessibility","evidence"],g_=[],m_={chartType:l_("rebuild",u_),runtimeMode:l_("rebuild",u_),xAccessor:l_("rebuild",u_),yAccessor:l_("rebuild",u_),timeAccessor:l_("rebuild",u_),valueAccessor:l_("rebuild",u_),y0Accessor:l_("rebuild",u_),boundsAccessor:l_("rebuild",u_),band:l_("rebuild",u_),openAccessor:l_("rebuild",u_),highAccessor:l_("rebuild",u_),lowAccessor:l_("rebuild",u_),closeAccessor:l_("rebuild",u_),candlestickRangeMode:l_("rebuild",u_),accessorRevision:l_("rebuild",u_),groupAccessor:l_("rebuild",d_),categoryAccessor:l_("rebuild",d_),lineDataAccessor:l_("rebuild",d_),colorAccessor:l_("rebuild",y_),sizeAccessor:l_("rebuild",f_),symbolAccessor:l_("rebuild",f_),pointIdAccessor:l_("rebuild",f_),xScaleType:l_("preserve",h_),yScaleType:l_("preserve",h_),xExtent:l_("preserve",h_),invertY:l_("preserve",h_),yExtent:l_("preserve",h_),extentPadding:l_("preserve",h_),scalePadding:l_("preserve",h_),axisExtent:l_("preserve",h_),yAxisExtent:l_("preserve",h_),binSize:l_("preserve",h_),normalize:l_("preserve",h_),heatmapAggregation:l_("preserve",h_),heatmapXBins:l_("preserve",h_),heatmapYBins:l_("preserve",h_),arrowOfTime:l_("preserve",p_),baseline:l_("preserve",p_),stackOrder:l_("preserve",p_),sizeRange:l_("preserve",p_),curve:l_("preserve",p_),areaGroups:l_("preserve",p_),customLayout:l_("preserve",p_),layoutConfig:l_("preserve",p_),layoutMargin:l_("preserve",p_),symbolMap:l_("preserve",f_),showValues:l_("preserve",f_),heatmapValueFormat:l_("preserve",f_),trackHoverRows:l_("preserve",f_),lineStyle:l_("preserve",y_),pointStyle:l_("preserve",y_),areaStyle:l_("preserve",y_),barStyle:l_("preserve",y_),swarmStyle:l_("preserve",y_),waterfallStyle:l_("preserve",y_),candlestickStyle:l_("preserve",y_),boundsStyle:l_("preserve",y_),gradientFill:l_("preserve",y_),lineGradient:l_("preserve",y_),semanticLineStops:l_("preserve",y_),colorScheme:l_("preserve",y_),themeCategorical:l_("preserve",y_),themeSemantic:l_("preserve",y_),themeSequential:l_("preserve",y_),themeDiverging:l_("preserve",y_),barColors:l_("preserve",y_),decay:l_("preserve",y_),pulse:l_("preserve",y_),staleness:l_("preserve",y_),layoutSelection:l_("preserve",y_),annotations:l_("preserve",["overlay","accessibility","evidence"]),windowSize:l_("preserve",g_),windowMode:l_("preserve",g_),maxCapacity:l_("preserve",g_),clock:l_("preserve",g_),transition:l_("preserve",g_),introAnimation:l_("preserve",g_),onLayoutError:l_("preserve",g_)},x_=l_("preserve",p_),b_=class{constructor(){this.tracker=new nk}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}},a_)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},c_):this.recordNoop("restyle")}recordConfig(e,t=!1){const i=Yh(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...f_]):i.invalidations)}},v_=require("d3-quadtree"),w_=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,v_.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}},k_=class e{constructor(e){if(this.xExtent=new e_,this.yExtent=new e_,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 b_,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 w_,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&Sd(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new JM(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=sd(e.timeAccessor||e.xAccessor,"time"),this.getY=sd(e.valueAccessor||e.yAccessor,"value")):(this.getX=sd(e.xAccessor,"x"),this.getY=sd(e.yAccessor,"y")),this.getGroup=cd(e.groupAccessor),this.getCategory=cd(e.categoryAccessor),this.getSize=e.sizeAccessor?sd(e.sizeAccessor,"size"):void 0,this.getColor=cd(e.colorAccessor),this.getSymbol=cd(e.symbolAccessor),this.getY0=e.y0Accessor?sd(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=eh(e),this.getPointId=cd(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?sd(e.openAccessor,"open"):void 0,this.getHigh=sd(e.highAccessor,"high"),this.getLow=sd(e.lowAccessor,"low"),this.getClose=i?sd(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new JM(e.windowSize))}currentTime(){return this.config.clock?.()??md()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ch(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?sd(this.config.timeAccessor||this.config.xAccessor,"time"):sd(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(dd(n));if(this.xIsDate=o||r,r){const e="string"==typeof i?i:void 0;this.getX=e?t=>hd(t[e]):e=>hd(i(e))}}Rh(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Th(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=Th(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?xh(r,this.getX,s,t.xExtent,t.xScaleType):fh(s,t.xExtent),l=fh(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=yh({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=gh(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!u&&i.size>0?l=mh(i,this.getY,t.extentPadding,h):u||l[0]===1/0||(l=bh(l,r,this.resolvedRibbons),l=vh(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:a}));l=wh(l,t.yExtent,!!u),({xDomain:c,yDomain:l}=kh(c,l,t.xScaleType)),this.scales=Sh({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=Ah,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??Gk},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=Qd({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 Vd({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,i_[s]?.buildScene);var s;if(!r)return Gd(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 Lh(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?vd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=wd(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&kd(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&&_d(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(){Bd(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=zd(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=Wd(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=Yd(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,qh(this.scene),this.exitNodes=[]}groupData(e){const{result:t,cache:i}=_h(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){const{map:t,cache:i}=$h(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return jh(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return Ih(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:i,groupColorCounter:n}=Ph({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=pd(e),i=this.getPointId,n=e=>t.has(i(e));Oh(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=pd(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||!rd(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=r||!rd(i,s);(a||c)&&(e?(this.getX=sd(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=sd(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=sd(this.config.xAccessor,"x"),this.getY=sd(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=eh(this.config)),n=!0,o=!0)}if("groupAccessor"in e&&!rd(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?cd(this.config.groupAccessor):void 0,n=!0),"categoryAccessor"in e&&!rd(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?cd(this.config.categoryAccessor):void 0,n=!0),"sizeAccessor"in e&&!rd(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?sd(this.config.sizeAccessor,"size"):void 0,n=!0),"symbolAccessor"in e&&!rd(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?cd(this.config.symbolAccessor):void 0,n=!0),"colorAccessor"in e&&!rd(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?cd(this.config.colorAccessor):void 0,n=!0),"y0Accessor"in e&&!rd(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?sd(this.config.y0Accessor,"y0"):void 0,n=!0,o=!0),("boundsAccessor"in e&&!rd(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=eh(this.config),n=!0,o=!0),"pointIdAccessor"in e&&!rd(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?cd(this.config.pointIdAccessor):void 0,n=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in e&&!rd(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!rd(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!rd(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!rd(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?sd(this.config.openAccessor,"open"):void 0,this.getHigh=sd(this.config.highAccessor,"high"),this.getLow=sd(this.config.lowAccessor,"low"),this.getClose=t?sd(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&&Xa(t.areaStyle)!==Xa(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};k_.GROUP_COLOR_MAP_CAP=1e3;var A_=k_;Wh(A_);var S_=require("d3-shape"),M_={circle:S_.symbolCircle,square:S_.symbolSquare,triangle:S_.symbolTriangle,diamond:S_.symbolDiamond,star:S_.symbolStar,cross:S_.symbolCross,wye:S_.symbolWye},__=/* @__PURE__ */new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),$_=["circle","triangle","diamond","star","square","chevron","cross","wye"],P_=256,j_=/* @__PURE__ */new Map,I_={line:function(e,t){const i=e.groupData(t),n=[],o=e.config.annotations?.filter(Qh).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Hh(e.ribbons);if(r.length>0&&n.push(...Uh(e,t,r)),o.length>0)for(const t of i)n.push(...Kh(e,t.data,t.key,o))}for(const t of i){const i=e.resolveLineStyle(t.key,qa(t.data)),r=rh(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 Zh(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}=Hh(e.ribbons);if(r.length>0&&n.push(...Uh(e,t,r)),o.length>0)for(const t of i)n.push(...Kh(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,qa(t.data)),o=sh(t.data,e.scales,e.getX,e.getY,r,i,t.key,c,e.getPointId),l=Jh(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 Zh(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}=lh(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);Zh(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}=Hh(e.ribbons);if(r.length>0&&n.push(...Uh(e,t,r)),o.length>0)for(const t of i)n.push(...Kh(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,qa(t.data)),o=sh(t.data,e.scales,e.getX,e.getY,r,i,t.key,s,e.getPointId),a=Jh(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,qa(t.data)),o=rh(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 Zh(e,i,n),n},scatter:op,bubble:op,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return cp(e,t,i);if(0===t.length)return[];const n=sd(e.config.valueAccessor,"value"),o=ad(e.config.xAccessor,"x"),r=ad(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 cp({...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:sp("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=rp(i,k,A),a=S?S(i):M[s],c=b[t];I.push(ap(ph(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=th(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||Xa(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?Fn(e.config.barColors,s):void 0)??c?.fill??l??"#4e79a7",y=Ba({binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:n},t.categoryRows?.get(s)),g=e.config.areaStyle?.(y)??{};o.push(hh(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=Ba({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{};o.push(hh(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?Fn(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(hh(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:()=>[]},L_=Wv(require("react")),R_=require("d3-shape"),C_=Wv(require("react")),T_=[40,40],O_=[.5,.5],E_=require("react/jsx-runtime"),F_={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0},N_=(Wv(require("react")),require("react/jsx-runtime")),z_=require("react/jsx-runtime"),D_=/* @__PURE__ */new Set,B_=require("d3-scale"),W_=require("react/jsx-runtime"),Y_=Qv,q_=Wv(require("react")),X_=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),G_={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."},V_=require("react/jsx-runtime"),H_=require("react/jsx-runtime"),U_="var(--semiotic-bg, #ffffff)",K_=.85,Z_=require("react/jsx-runtime"),Q_=16,J_=require("react/jsx-runtime"),e$=require("react/jsx-runtime"),t$=require("react/jsx-runtime"),i$={secondary:0,primary:3},n$=1,o$=2,r$=.6,s$="0.88em",a$=.95,c$=.72,l$=.06,u$=".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}}",d$=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}",h$=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),p$=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),f$=1,y$=32,g$=6,m$=4,x$=8,b$=72,v$=30,w$=-30,k$=8,A$=480,S$=3,M$={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},_$=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]),$$=require("react/jsx-runtime"),P$={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"},j$=require("d3-hierarchy"),I$=require("d3-shape"),L$=(Wv(require("react")),require("react/jsx-runtime")),R$={linear:I$.curveLinear,monotoneX:I$.curveMonotoneX,monotoneY:I$.curveMonotoneY,step:I$.curveStep,stepAfter:I$.curveStepAfter,stepBefore:I$.curveStepBefore,basis:I$.curveBasis,cardinal:I$.curveCardinal,catmullRom:I$.curveCatmullRom},C$=require("react/jsx-runtime"),T$=16,O$=require("react/jsx-runtime"),E$=Wv(require("react")),F$=require("react/jsx-runtime"),N$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z$=864e5,D$=3156e7,B$=require("react/jsx-runtime"),W$={right:110,left:110,top:50,bottom:80},Y$=require("react/jsx-runtime"),q$={top:50,right:40,bottom:60,left:70},X$={top:20,right:80,bottom:20,left:80},G$={top:40,right:40,bottom:40,left:40},V$=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]),H$=require("react/jsx-runtime"),U$=require("react/jsx-runtime");lp();var K$=Wv(require("react-dom/server")),Z$=require("react/jsx-runtime"),Q$=require("react/jsx-runtime"),J$=require("react/jsx-runtime"),eP={top:4,bottom:4,left:4,right:4},tP={frameType:"xy",buildProps:_g,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=$g(e),[a,c]=r.size??[600,400],l=s.minimap&&"object"==typeof s.minimap?s.minimap:{},u=Pg(l.height,60),d=r.margin,h=l.margin&&"object"==typeof l.margin?l.margin:{},p={top:Pg(h.top,0),right:Pg(h.right,Pg(d?.right,20)),bottom:Pg(h.bottom,20),left:Pg(h.left,Pg(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=wS.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=wS.buildProps(i,n,o,b,v);w.chartType=s.fillArea?"area":"line","function"==typeof l.lineStyle&&(w.lineStyle=l.lineStyle);const k={},A={},S=sg(x,k),M=sg(w,A),_=!0===s.renderBefore,$=_?0:c,P=""+Ig(S,0,_?f:0,"detail")+Ig(M,0,$,"overview"),j=c+f,I=Nr(Fr(r.theme)),L="string"==typeof r.title?r.title:void 0,R="string"==typeof r.description?r.description:L||"Chart with overview minimap",C=Gy(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,J$.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,J$.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=KM.renderToStaticMarkup(
599
+ /* @__PURE__ */(0,oM.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}=Wc(a),h=o.thresholds,p=ia(n.gradientFill),f=Bc({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=Yc(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:Oc({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:Hs((e,t)=>{const i={...f.pieceStyle(e,t)};return y?.length&&Object.assign(i,at(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},la(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))}}}}},sM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=ua(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:qc(n.gradientFill),pieceStyle:Xc(e,t,i,n,o)}}},aM={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:qc(n.gradientFill),pieceStyle:Xc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},cM={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:qc(n.gradientFill),pieceStyle:Xc(e,r,i,n,o),showLegend:n.showLegend??!!r}}},lM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=tt(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:Xc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)}),showLegend:n.showLegend??!!r}}},uM={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,n,o)=>{const r=t||o.categoryAccessor,s=tt(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:Xc(e,r,i,n,o,e=>{const t=s(e);return null==t?void 0:Math.abs(t)})}}},dM={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:Gc(e,t,i,n,o,"count")}}},hM={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:Gc(e,t,i,n,o)})},pM={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:Vc(e,t,i,n,o),showLegend:n.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},fM={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:Uc(e,t,i,n,o),showLegend:n.showLegend??!!t})},yM={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,n,o)=>{const r=ua(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:Hc(e,t,i,n,o),showGrid:n.showGrid??!0,showLegend:n.showLegend??!!t}}},gM={frameType:"ordinal",buildProps:(e,t,i,n,o)=>{const r=o.seriesAccessor||t||"__radar",s=t||("__radar"===r?void 0:r),a=Hc(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}}},mM={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:qc(n.gradientFill),pieceStyle:Xc(e,r,i,n,o),showLegend:n.showLegend??!!r,barPadding:o.barPadding??40}}},xM={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:Gc(e,t,i,n,o,"median",.5),showLegend:n.showLegend??!!t})},bM={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:Xc(e,s,i,n,o),showLabels:o.showLabels??!0}}},vM=require("d3-scale"),wM={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},kM=/* @__PURE__ */new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),AM=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},SM=828*AM(8),MM=3e3,_M=/* @__PURE__ */new Map,$M=1e5,PM=1e-9,jM=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,IM=require("react/jsx-runtime"),LM="var(--semiotic-grid, #94a3b8)",RM="var(--semiotic-text-secondary, #475569)",CM="var(--semiotic-text-secondary, #94a3b8)",TM=.22,OM=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=!Vu(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,TM):e.opacity,stroke:"none"},datum:t})}for(const e of t){if(!e.gradientStubs)continue;const t=!Vu({__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?TM: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=!Vu(i,r,o);s.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:n?TM:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...n&&t?{opacity:TM}:{}},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&&Vu({__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}},EM={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||Vs(la(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:Uu([],r,o.sourceAccessor||"source",o.targetAccessor||"target"),a=Dr(n.theme).colors.categorical,c=Fn(i,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,d=t?Bn(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=zn(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=lt(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:Hs(o.nodeStyle||(y?(e,t)=>({...f(e,t),...y(e,t)}):f),la(o)),...n,showLegend:(n.showLegend??!!t)&&!!t}}},FM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Qu(o),s=Dr(n.theme).colors.categorical,a=/* @__PURE__ */new Map,c=o.nodeStyle??(e=>({fill:t?zn(e?.data||e,t,void 0):Va(void 0,s,i,void 0,a),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),l=lt(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=Hs(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}}},NM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Dr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Hu(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?Bn(l,u,i??n.colorScheme??r):void 0,h=o.showLabels??n.showLabels,p=n.nodeStyle||o.nodeStyle,f=ct(e=>{const n=e?.data||e;return{fill:o.colorByDepth?Vk[Number(e?.depth||0)%Vk.length]:t?c?zn({__ssrCirclePackColorBy:c(n)},"__ssrCirclePackColorBy",d??void 0):zn(n,t,d??void 0):Va(void 0,r,i,void 0,s),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,nt(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:Zu(f,p,la(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=Dr(n.theme).colors.categorical,l=i??n.colorScheme??c,u=Fn(l,c),d=Hu(r,s),h="__ssrOrbitColorBy",p="function"==typeof t?t:null,f=t?Bn(p?d.map(e=>({[h]:p(e)})):d,p?h:t,l):void 0,y=ct(e=>{const i=e.data||e,n=Number(e.depth??0);return{fill:o.colorByDepth?0===n?u[0]:Vk[n%Vk.length]:t?p?zn({[h]:p(i)},h,f):zn(i,t,f):u[0],stroke:"#fff",strokeWidth:1,opacity:0===n?1:.85}},o.styleRules,nt(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:Hs(y,la(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...n,showLegend:(n.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},DM={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,n,o,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:Uu([],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,_]=o.size??[600,400],$=o.margin,P="vertical"===r.orientation?"vertical":"horizontal",j={...qu(!!o.title,!!r.showQualityReadout,Array.isArray(r.axisTicks)&&r.axisTicks.length>0,P),...$},I=(o.showLegend??!!t)&&!!t,L=o.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=Fn(n,Dr(o.theme).colors.categorical,kk),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=n??[...O],D=N?Bn(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?zn({_cat:E(i)},"_cat",D??void 0):zn(i,"string"==typeof t?t:"id",D??void 0)}return O[i%O.length]},Y=i(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,o.legend),q=!1!==r.showLabels&&("auto"!==r.showLabels||"auto"),{layout:X,layoutConfig:G,issues:V,xScale:H}=Yu({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(tl).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const U=X?Xu({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:OM,layoutConfig:G,sourceAccessor:a,targetAccessor:c,valueAccessor:l,nodeIDAccessor:u,colorBy:t,colorScheme:n,...U&&{backgroundGraphics:U},...o,showLegend:I,...Y&&{legend:Y,legendPosition:L},__legendIncludesAutomatic:!0,margin:R}}},BM={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,n,o)=>{const r=Array.isArray(o.nodes)?o.nodes:Uu([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),s=Dr(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?Bn(l,c,i??n.colorScheme??s):void 0,d=e=>({fill:t?zn(e?.data||e,t,u):Va(void 0,s,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=lt(o.styleRules,t,o.valueAccessor),p=h?(e,t)=>({...d(e),...h(e,t)}):d,f=Ku({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:Hs(o.nodeStyle||p,la(o)),edgeStyle:Hs(o.edgeStyle||f,la(o)),colorScheme:i,...n,showLegend:(n.showLegend??!!t)&&!!t}}},WM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Dr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Hu(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?Bn(l,u,i??n.colorScheme??r):void 0,h=!1!==o.showLabels,p=n.nodeStyle||o.nodeStyle,f=ct(e=>{const n=e?.data||e;return{fill:o.colorByDepth?Vk[Number(e?.depth||0)%Vk.length]:t?c?zn({__ssrTreeColorBy:c(n)},"__ssrTreeColorBy",d??void 0):zn(n,t,d??void 0):Va(void 0,r,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,nt(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:Zu(f,p,la(o))}}},YM={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,n,o)=>{const r=Dr(n.theme).colors.categorical,s=/* @__PURE__ */new Map,a=Hu(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?Bn(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=ct(e=>{const n=e?.data||e;return{fill:o.colorByDepth?Vk[Number(e?.depth||0)%Vk.length]:t?c?zn({__ssrTreemapColorBy:c(n)},"__ssrTreemapColorBy",d??void 0):zn(n,t,d??void 0):Va(void 0,r,i,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,nt(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:Zu(m,g,la(o))}}},qM={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},XM=require("d3-scale"),GM={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=nd(o.areas,o.valueAccessor,r),a=o.areaStyle??od(s,o.areaOpacity??1),c=o.styleRules?ct(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},id):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}:{}}}},VM={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??td(r,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=o.styleRules?ct(s,o.styleRules,nt(t,o.sizeBy)):s;return{points:r,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||qM,pointStyle:a,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...n}}},HM={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??td(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?ct(s,o.styleRules,nt(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}}}},UM={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?Bn(g.map(e=>({[m]:f(e)})),m,i||"category10"):Bn(g,f,i||"category10"):null,b=g.map(e=>Number(e[a]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?At(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||qM,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:ed({valueAccessor:a,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>f&&x?zn(e,f,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...n}}},KM=Wv(require("react-dom/server")),ZM=Wv(require("react")),QM=Wv(require("react-dom/server")),JM=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}},e_=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}},t_=/^\d{4}-\d{1,2}$/,i_=/* @__PURE__ */Object.create(null),n_="undefined"==typeof window||"undefined"==typeof document,o_=/* @__PURE__ */new Set,r_=require("d3-scale"),s_=/* @__PURE__ */new WeakMap,a_=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],c_=["scene-style","data-paint","accessibility","evidence"],l_=(e,t)=>({retainedData:e,invalidations:t}),u_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],d_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],h_=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],p_=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],f_=["scene-geometry","data-paint","accessibility","evidence"],y_=["scene-style","data-paint","accessibility","evidence"],g_=[],m_={chartType:l_("rebuild",u_),runtimeMode:l_("rebuild",u_),xAccessor:l_("rebuild",u_),yAccessor:l_("rebuild",u_),timeAccessor:l_("rebuild",u_),valueAccessor:l_("rebuild",u_),y0Accessor:l_("rebuild",u_),boundsAccessor:l_("rebuild",u_),band:l_("rebuild",u_),openAccessor:l_("rebuild",u_),highAccessor:l_("rebuild",u_),lowAccessor:l_("rebuild",u_),closeAccessor:l_("rebuild",u_),candlestickRangeMode:l_("rebuild",u_),accessorRevision:l_("rebuild",u_),groupAccessor:l_("rebuild",d_),categoryAccessor:l_("rebuild",d_),lineDataAccessor:l_("rebuild",d_),colorAccessor:l_("rebuild",y_),sizeAccessor:l_("rebuild",f_),symbolAccessor:l_("rebuild",f_),pointIdAccessor:l_("rebuild",f_),xScaleType:l_("preserve",h_),yScaleType:l_("preserve",h_),xExtent:l_("preserve",h_),invertY:l_("preserve",h_),yExtent:l_("preserve",h_),extentPadding:l_("preserve",h_),scalePadding:l_("preserve",h_),axisExtent:l_("preserve",h_),yAxisExtent:l_("preserve",h_),binSize:l_("preserve",h_),normalize:l_("preserve",h_),heatmapAggregation:l_("preserve",h_),heatmapXBins:l_("preserve",h_),heatmapYBins:l_("preserve",h_),arrowOfTime:l_("preserve",p_),baseline:l_("preserve",p_),stackOrder:l_("preserve",p_),sizeRange:l_("preserve",p_),curve:l_("preserve",p_),areaGroups:l_("preserve",p_),customLayout:l_("preserve",p_),layoutConfig:l_("preserve",p_),layoutMargin:l_("preserve",p_),symbolMap:l_("preserve",f_),showValues:l_("preserve",f_),heatmapValueFormat:l_("preserve",f_),trackHoverRows:l_("preserve",f_),lineStyle:l_("preserve",y_),pointStyle:l_("preserve",y_),areaStyle:l_("preserve",y_),barStyle:l_("preserve",y_),swarmStyle:l_("preserve",y_),waterfallStyle:l_("preserve",y_),candlestickStyle:l_("preserve",y_),boundsStyle:l_("preserve",y_),gradientFill:l_("preserve",y_),lineGradient:l_("preserve",y_),semanticLineStops:l_("preserve",y_),colorScheme:l_("preserve",y_),themeCategorical:l_("preserve",y_),themeSemantic:l_("preserve",y_),themeSequential:l_("preserve",y_),themeDiverging:l_("preserve",y_),barColors:l_("preserve",y_),decay:l_("preserve",y_),pulse:l_("preserve",y_),staleness:l_("preserve",y_),layoutSelection:l_("preserve",y_),annotations:l_("preserve",["overlay","accessibility","evidence"]),windowSize:l_("preserve",g_),windowMode:l_("preserve",g_),maxCapacity:l_("preserve",g_),clock:l_("preserve",g_),transition:l_("preserve",g_),introAnimation:l_("preserve",g_),onLayoutError:l_("preserve",g_)},x_=l_("preserve",p_),b_=class{constructor(){this.tracker=new nk}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}},a_)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},c_):this.recordNoop("restyle")}recordConfig(e,t=!1){const i=Yh(e);return this.tracker.record({kind:"config",keys:e},t?/* @__PURE__ */new Set([...i.invalidations,...f_]):i.invalidations)}},v_=require("d3-quadtree"),w_=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,v_.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}},k_=class e{constructor(e){if(this.xExtent=new e_,this.yExtent=new e_,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 b_,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 w_,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&Sd(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new JM(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=sd(e.timeAccessor||e.xAccessor,"time"),this.getY=sd(e.valueAccessor||e.yAccessor,"value")):(this.getX=sd(e.xAccessor,"x"),this.getY=sd(e.yAccessor,"y")),this.getGroup=cd(e.groupAccessor),this.getCategory=cd(e.categoryAccessor),this.getSize=e.sizeAccessor?sd(e.sizeAccessor,"size"):void 0,this.getColor=cd(e.colorAccessor),this.getSymbol=cd(e.symbolAccessor),this.getY0=e.y0Accessor?sd(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=eh(e),this.getPointId=cd(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?sd(e.openAccessor,"open"):void 0,this.getHigh=sd(e.highAccessor,"high"),this.getLow=sd(e.lowAccessor,"low"),this.getClose=i?sd(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new JM(e.windowSize))}currentTime(){return this.config.clock?.()??md()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ch(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?sd(this.config.timeAccessor||this.config.xAccessor,"time"):sd(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(dd(n));if(this.xIsDate=o||r,r){const e="string"==typeof i?i:void 0;this.getX=e?t=>hd(t[e]):e=>hd(i(e))}}Rh(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Th(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=Th(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?xh(r,this.getX,s,t.xExtent,t.xScaleType):fh(s,t.xExtent),l=fh(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=yh({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=gh(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!u&&i.size>0?l=mh(i,this.getY,t.extentPadding,h):u||l[0]===1/0||(l=bh(l,r,this.resolvedRibbons),l=vh(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:a}));l=wh(l,t.yExtent,!!u),({xDomain:c,yDomain:l}=kh(c,l,t.xScaleType)),this.scales=Sh({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=Ah,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??Gk},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=Qd({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 Vd({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,i_[s]?.buildScene);var s;if(!r)return Gd(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 Lh(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?vd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=wd(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&kd(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&&_d(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(){Bd(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=zd(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=Wd(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=Yd(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,qh(this.scene),this.exitNodes=[]}groupData(e){const{result:t,cache:i}=_h(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){const{map:t,cache:i}=$h(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return jh(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return Ih(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:i,groupColorCounter:n}=Ph({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=pd(e),i=this.getPointId,n=e=>t.has(i(e));Oh(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=pd(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||!rd(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=r||!rd(i,s);(a||c)&&(e?(this.getX=sd(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=sd(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=sd(this.config.xAccessor,"x"),this.getY=sd(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=eh(this.config)),n=!0,o=!0)}if("groupAccessor"in e&&!rd(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?cd(this.config.groupAccessor):void 0,n=!0),"categoryAccessor"in e&&!rd(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?cd(this.config.categoryAccessor):void 0,n=!0),"sizeAccessor"in e&&!rd(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?sd(this.config.sizeAccessor,"size"):void 0,n=!0),"symbolAccessor"in e&&!rd(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?cd(this.config.symbolAccessor):void 0,n=!0),"colorAccessor"in e&&!rd(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?cd(this.config.colorAccessor):void 0,n=!0),"y0Accessor"in e&&!rd(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?sd(this.config.y0Accessor,"y0"):void 0,n=!0,o=!0),("boundsAccessor"in e&&!rd(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=eh(this.config),n=!0,o=!0),"pointIdAccessor"in e&&!rd(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?cd(this.config.pointIdAccessor):void 0,n=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in e&&!rd(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!rd(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!rd(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!rd(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?sd(this.config.openAccessor,"open"):void 0,this.getHigh=sd(this.config.highAccessor,"high"),this.getLow=sd(this.config.lowAccessor,"low"),this.getClose=t?sd(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&&Xa(t.areaStyle)!==Xa(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};k_.GROUP_COLOR_MAP_CAP=1e3;var A_=k_;Wh(A_);var S_=require("d3-shape"),M_={circle:S_.symbolCircle,square:S_.symbolSquare,triangle:S_.symbolTriangle,diamond:S_.symbolDiamond,star:S_.symbolStar,cross:S_.symbolCross,wye:S_.symbolWye},__=/* @__PURE__ */new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),$_=["circle","triangle","diamond","star","square","chevron","cross","wye"],P_=256,j_=/* @__PURE__ */new Map,I_={line:function(e,t){const i=e.groupData(t),n=[],o=e.config.annotations?.filter(Qh).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Hh(e.ribbons);if(r.length>0&&n.push(...Uh(e,t,r)),o.length>0)for(const t of i)n.push(...Kh(e,t.data,t.key,o))}for(const t of i){const i=e.resolveLineStyle(t.key,qa(t.data)),r=rh(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 Zh(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}=Hh(e.ribbons);if(r.length>0&&n.push(...Uh(e,t,r)),o.length>0)for(const t of i)n.push(...Kh(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,qa(t.data)),o=sh(t.data,e.scales,e.getX,e.getY,r,i,t.key,c,e.getPointId),l=Jh(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 Zh(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}=lh(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);Zh(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}=Hh(e.ribbons);if(r.length>0&&n.push(...Uh(e,t,r)),o.length>0)for(const t of i)n.push(...Kh(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,qa(t.data)),o=sh(t.data,e.scales,e.getX,e.getY,r,i,t.key,s,e.getPointId),a=Jh(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,qa(t.data)),o=rh(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 Zh(e,i,n),n},scatter:op,bubble:op,heatmap:function(e,t,i){if(e.config.heatmapAggregation)return cp(e,t,i);if(0===t.length)return[];const n=sd(e.config.valueAccessor,"value"),o=ad(e.config.xAccessor,"x"),r=ad(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 cp({...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:sp("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=rp(i,k,A),a=S?S(i):M[s],c=b[t];I.push(ap(ph(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=th(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||Xa(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?Dn(e.config.barColors,s):void 0)??c?.fill??l??"#4e79a7",y=Ba({binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:n},t.categoryRows?.get(s)),g=e.config.areaStyle?.(y)??{};o.push(hh(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=Ba({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{};o.push(hh(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?Dn(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(hh(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:()=>[]},L_=Wv(require("react")),R_=require("d3-shape"),C_=Wv(require("react")),T_=[40,40],O_=[.5,.5],E_=require("react/jsx-runtime"),F_={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0},N_=(Wv(require("react")),require("react/jsx-runtime")),z_=require("react/jsx-runtime"),D_=/* @__PURE__ */new Set,B_=require("d3-scale"),W_=require("react/jsx-runtime"),Y_=Qv,q_=Wv(require("react")),X_=(e,t)=>({width:Array.from(e).length*t.size*.65,height:1.2*t.size,ascent:.9*t.size,source:"estimated"}),G_={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."},V_=require("react/jsx-runtime"),H_=require("react/jsx-runtime"),U_="var(--semiotic-bg, #ffffff)",K_=.85,Z_=require("react/jsx-runtime"),Q_=16,J_=require("react/jsx-runtime"),e$=require("react/jsx-runtime"),t$=require("react/jsx-runtime"),i$={secondary:0,primary:3},n$=1,o$=2,r$=.6,s$="0.88em",a$=.95,c$=.72,l$=.06,u$=".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}}",d$=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}",h$=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),p$=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),f$=1,y$=32,g$=6,m$=4,x$=8,b$=72,v$=30,w$=-30,k$=8,A$=480,S$=3,M$={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},_$=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]),$$=require("react/jsx-runtime"),P$={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"},j$=require("d3-hierarchy"),I$=require("d3-shape"),L$=(Wv(require("react")),require("react/jsx-runtime")),R$={linear:I$.curveLinear,monotoneX:I$.curveMonotoneX,monotoneY:I$.curveMonotoneY,step:I$.curveStep,stepAfter:I$.curveStepAfter,stepBefore:I$.curveStepBefore,basis:I$.curveBasis,cardinal:I$.curveCardinal,catmullRom:I$.curveCatmullRom},C$=require("react/jsx-runtime"),T$=16,O$=require("react/jsx-runtime"),E$=Wv(require("react")),F$=require("react/jsx-runtime"),N$=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],z$=864e5,D$=3156e7,B$=require("react/jsx-runtime"),W$={right:110,left:110,top:50,bottom:80},Y$=require("react/jsx-runtime"),q$={top:50,right:40,bottom:60,left:70},X$={top:20,right:80,bottom:20,left:80},G$={top:40,right:40,bottom:40,left:40},V$=/* @__PURE__ */new Set(["chord","force","circlepack","orbit"]),H$=require("react/jsx-runtime"),U$=require("react/jsx-runtime");lp();var K$=Wv(require("react-dom/server")),Z$=require("react/jsx-runtime"),Q$=require("react/jsx-runtime"),J$=require("react/jsx-runtime"),eP={top:4,bottom:4,left:4,right:4},tP={frameType:"xy",buildProps:_g,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=$g(e),[a,c]=r.size??[600,400],l=s.minimap&&"object"==typeof s.minimap?s.minimap:{},u=Pg(l.height,60),d=r.margin,h=l.margin&&"object"==typeof l.margin?l.margin:{},p={top:Pg(h.top,0),right:Pg(h.right,Pg(d?.right,20)),bottom:Pg(h.bottom,20),left:Pg(h.left,Pg(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=wS.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=wS.buildProps(i,n,o,b,v);w.chartType=s.fillArea?"area":"line","function"==typeof l.lineStyle&&(w.lineStyle=l.lineStyle);const k={},A={},S=sg(x,k),M=sg(w,A),_=!0===s.renderBefore,$=_?0:c,P=""+Ig(S,0,_?f:0,"detail")+Ig(M,0,$,"overview"),j=c+f,I=Br(Dr(r.theme)),L="string"==typeof r.title?r.title:void 0,R="string"==typeof r.description?r.description:L||"Chart with overview minimap",C=Gy(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,J$.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,J$.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=KM.renderToStaticMarkup(
600
600
  /* @__PURE__ */
601
601
  /* @__PURE__ */(0,J$.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,J$.jsx)("title",{id:T,children:L}),
602
602
  /* @__PURE__ */
603
603
  /* @__PURE__ */(0,J$.jsx)("desc",{id:O,children:R}),
604
604
  /* @__PURE__ */
605
- /* @__PURE__ */(0,J$.jsx)("g",{dangerouslySetInnerHTML:{__html:P}}),z]}));if(t){const e=[k.evidence,A.evidence];t.evidence=up({frameType:"xy",width:a,height:j,parts:e,title:L,description:R,xDomain:Lg(e,"xDomain"),yDomain:Lg(e,"yDomain")})}return D}},iP={MotifBraidChart:QA,DependencyForestChart:JA,FlowCircuitChart:eS,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:gS,LineChart:wS,AreaChart:AS,DifferenceChart:SS,StackedAreaChart:MS,Scatterplot:uS,CandlestickChart:_S,BubbleChart:dS,ConnectedScatterplot:PS,QuadrantChart:$S,Heatmap:VS,WaterfallChart:vS,MultiAxisLineChart:bS,MinimapChart:tP,ScatterplotMatrix:{frameType:"xy",buildProps:_g,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=$g(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=jg(s.cellSize,150),h=Math.max(0,Pg(s.cellGap,4)),p=Math.max(0,Pg(s.pointRadius,2)),f=Math.max(0,Math.min(1,Pg(s.pointOpacity,.5))),y=jg(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=Fr(r.theme),v=Nr(b),w=Cg(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=Tg({data:a,field:e,label:Fn(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=sg({chartType:"scatter",data:a,size:[d,d],xAccessor:i,yAccessor:e,pointStyle:ct(e=>({r:p,opacity:f,fill:w.color(e)}),s.styleRules,it(i,e)),margin:eP,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Fn(u,i)??i} versus ${Fn(u,e)??e} scatterplot`,theme:r.theme,_idPrefix:`${(r._idPrefix??"splom")+""}-${t}-${o}`},m);R.push(m.evidence),C.push(Ig(x,c,l,`cell-${e}-${i}`))})});const O=Gy(r),E=k?O+"-title":void 0,F=O+"-description",N=KM.renderToStaticMarkup(
605
+ /* @__PURE__ */(0,J$.jsx)("g",{dangerouslySetInnerHTML:{__html:P}}),z]}));if(t){const e=[k.evidence,A.evidence];t.evidence=up({frameType:"xy",width:a,height:j,parts:e,title:L,description:R,xDomain:Lg(e,"xDomain"),yDomain:Lg(e,"yDomain")})}return D}},iP={MotifBraidChart:QA,DependencyForestChart:JA,FlowCircuitChart:eS,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:gS,LineChart:wS,AreaChart:AS,DifferenceChart:SS,StackedAreaChart:MS,Scatterplot:uS,CandlestickChart:_S,BubbleChart:dS,ConnectedScatterplot:PS,QuadrantChart:$S,Heatmap:VS,WaterfallChart:vS,MultiAxisLineChart:bS,MinimapChart:tP,ScatterplotMatrix:{frameType:"xy",buildProps:_g,renderStatic:function(e,t){const{data:i,colorBy:n,colorScheme:o,common:r,rest:s}=$g(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=jg(s.cellSize,150),h=Math.max(0,Pg(s.cellGap,4)),p=Math.max(0,Pg(s.pointRadius,2)),f=Math.max(0,Math.min(1,Pg(s.pointOpacity,.5))),y=jg(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=Dr(r.theme),v=Br(b),w=Cg(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=Tg({data:a,field:e,label:Dn(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=sg({chartType:"scatter",data:a,size:[d,d],xAccessor:i,yAccessor:e,pointStyle:ct(e=>({r:p,opacity:f,fill:w.color(e)}),s.styleRules,it(i,e)),margin:eP,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Dn(u,i)??i} versus ${Dn(u,e)??e} scatterplot`,theme:r.theme,_idPrefix:`${(r._idPrefix??"splom")+""}-${t}-${o}`},m);R.push(m.evidence),C.push(Ig(x,c,l,`cell-${e}-${i}`))})});const O=Gy(r),E=k?O+"-title":void 0,F=O+"-description",N=KM.renderToStaticMarkup(
606
606
  /* @__PURE__ */
607
607
  /* @__PURE__ */(0,J$.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,J$.jsx)("title",{id:E,children:k}),
608
608
  /* @__PURE__ */
@@ -614,9 +614,9 @@ return(0,J$.jsxs)("g",{transform:`translate(${e.x},${S+e.y})`,children:[
614
614
  /* @__PURE__ */(0,J$.jsx)("circle",{cx:5,cy:8,r:5,fill:i}),
615
615
  /* @__PURE__ */
616
616
  /* @__PURE__ */(0,J$.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,J$.jsx)("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:Fn(u,e)??e},"row-"+e)}),l.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,J$.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:Fn(u,e)??e},"column-"+e)),
617
+ return(0,J$.jsx)("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:v.text,children:Dn(u,e)??e},"row-"+e)}),l.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,J$.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:Dn(u,e)??e},"column-"+e)),
618
618
  /* @__PURE__ */
619
- /* @__PURE__ */(0,J$.jsx)("g",{dangerouslySetInnerHTML:{__html:C.join("")}})]}));return t&&(t.evidence=up({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:kS,RealtimeLineChart:HS,RealtimeHistogram:US,RealtimeHeatmap:KS,RealtimeSwarmChart:ZS,RealtimeWaterfallChart:QS,XYCustomChart:Dw,BarChart:sM,StackedBarChart:aM,GroupedBarChart:cM,PieChart:lM,DonutChart:uM,Histogram:dM,BoxPlot:hM,ViolinPlot:pM,SwarmPlot:fM,DotPlot:yM,SwimlaneChart:mM,RidgelinePlot:xM,LikertChart:iM,FunnelChart:bM,RadarChart:gM,GaugeChart:rM,OrdinalCustomChart:Bw,ParallelCoordinatesRecipe:Yw,CalendarHeatmapRecipe:qw,ForceDirectedGraph:FM,NetworkCustomChart:Ww,SankeyDiagram:BM,ProcessSankey:DM,ChordDiagram:EM,TreeDiagram:WM,Treemap:YM,CirclePack:NM,OrbitDiagram:zM,ChoroplethMap:GM,ProportionalSymbolMap:VM,FlowMap:UM,DistanceCartogram:HM,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:MA,EventDropChart:_A,UnitPileChart:$A,CollisionSwarmChart:PA,ProcessFlowChart:jA,GauntletChart:IA,CrucibleChart:LA,PacketFlowChart:RA,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:_g,renderStatic:function(e,t){const{data:i,common:n,rest:o}=Ag(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=vg({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=Fr(n.theme),h=Nr(d),p=Gy(n),f=p+"-title",y=p+"-description";if(!u.valid){const e=u.diagnostics.map(e=>e.message).join(" "),i=K$.renderToStaticMarkup(
619
+ /* @__PURE__ */(0,J$.jsx)("g",{dangerouslySetInnerHTML:{__html:C.join("")}})]}));return t&&(t.evidence=up({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:kS,RealtimeLineChart:HS,RealtimeHistogram:US,RealtimeHeatmap:KS,RealtimeSwarmChart:ZS,RealtimeWaterfallChart:QS,XYCustomChart:Dw,BarChart:sM,StackedBarChart:aM,GroupedBarChart:cM,PieChart:lM,DonutChart:uM,Histogram:dM,BoxPlot:hM,ViolinPlot:pM,SwarmPlot:fM,DotPlot:yM,SwimlaneChart:mM,RidgelinePlot:xM,LikertChart:iM,FunnelChart:bM,RadarChart:gM,GaugeChart:rM,OrdinalCustomChart:Bw,ParallelCoordinatesRecipe:Yw,CalendarHeatmapRecipe:qw,ForceDirectedGraph:FM,NetworkCustomChart:Ww,SankeyDiagram:BM,ProcessSankey:DM,ChordDiagram:EM,TreeDiagram:WM,Treemap:YM,CirclePack:NM,OrbitDiagram:zM,ChoroplethMap:GM,ProportionalSymbolMap:VM,FlowMap:UM,DistanceCartogram:HM,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:MA,EventDropChart:_A,UnitPileChart:$A,CollisionSwarmChart:PA,ProcessFlowChart:jA,GauntletChart:IA,CrucibleChart:LA,PacketFlowChart:RA,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:_g,renderStatic:function(e,t){const{data:i,common:n,rest:o}=Ag(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=vg({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=Dr(n.theme),h=Br(d),p=Gy(n),f=p+"-title",y=p+"-description";if(!u.valid){const e=u.diagnostics.map(e=>e.message).join(" "),i=K$.renderToStaticMarkup(
620
620
  /* @__PURE__ */
621
621
  /* @__PURE__ */(0,Q$.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,J$.jsx)("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"mi
640
640
  /* @__PURE__ */
641
641
  /* @__PURE__ */(0,Q$.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,Q$.jsx)("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=up({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:CA},nP=Wv(require("react")),oP=require("react/jsx-runtime"),rP=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]),sP=Wv(require("react-dom/server")),aP=require("d3-scale"),cP=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:Fn(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||Gk,o=n[this.colorSchemeIndex%n.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}},lP=require("d3-array"),uP=require("d3-scale"),dP={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(hh(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(hh(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=Ng(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=Ng(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(hh(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(hh(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=Ng(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=zg(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);Dg(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=zg(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;Dg(c,u,n,l?e.middle+p:s(a),l?s(a):e.middle+p,h,d)}}return c},pie:Bg,donut:Bg,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=Yg(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(Wg(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=qg(t,i,n,o,d),p=_s(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=Yg(t),m=s(Wg(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]=Ss(t),o=null!=h&&isFinite(h)?h:i,d=null!=p&&isFinite(p)?p:n,f=(d-o)/l||1,y=qg(t,o,d,f,l),g=t.length,m=_s(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(hh(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=qg(t,i,n,o,u),p=_s(c,1),f=Yg(t),y=s(Wg(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(hh(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(hh(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,uP.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(hh(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(hh(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(hh(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(hh(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?hh(r,i.x,s,i.width,n,null,"__track__"):hh(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=hh(o,e.x,r-o,e.width,p,i,c)}else{const o=a(t+n),r=a(t);f=hh(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}},hP=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pP=["scene-style","data-paint","accessibility","evidence"],fP=(e,t)=>({retainedData:e,invalidations:t}),yP=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gP=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mP=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xP=["scene-geometry","data-paint","accessibility","evidence"],bP=["scene-style","data-paint","accessibility","evidence"],vP=[],wP={chartType:fP("rebuild",yP),runtimeMode:fP("rebuild",yP),categoryAccessor:fP("rebuild",yP),valueAccessor:fP("rebuild",yP),oAccessor:fP("rebuild",yP),rAccessor:fP("rebuild",yP),stackBy:fP("rebuild",yP),groupBy:fP("rebuild",yP),timeAccessor:fP("rebuild",yP),accessorRevision:fP("rebuild",yP),colorAccessor:fP("rebuild",bP),symbolAccessor:fP("rebuild",xP),connectorAccessor:fP("rebuild",xP),dataIdAccessor:fP("rebuild",xP),projection:fP("preserve",gP),extentPadding:fP("preserve",gP),axisExtent:fP("preserve",gP),rExtent:fP("preserve",gP),oExtent:fP("preserve",gP),multiAxis:fP("preserve",gP),normalize:fP("preserve",gP),bins:fP("preserve",gP),oSort:fP("preserve",mP),barPadding:fP("preserve",mP),roundedTop:fP("preserve",mP),baselinePadding:fP("preserve",mP),innerRadius:fP("preserve",mP),cornerRadius:fP("preserve",mP),startAngle:fP("preserve",mP),sweepAngle:fP("preserve",mP),trackFill:fP("preserve",mP),showOutliers:fP("preserve",mP),showIQR:fP("preserve",mP),amplitude:fP("preserve",mP),connectorOpacity:fP("preserve",mP),showLabels:fP("preserve",mP),dynamicColumnWidth:fP("rebuild",mP),customLayout:fP("preserve",mP),layoutConfig:fP("preserve",mP),layoutMargin:fP("preserve",mP),symbolMap:fP("preserve",xP),pieceStyle:fP("preserve",bP),summaryStyle:fP("preserve",bP),connectorStyle:fP("preserve",bP),gradientFill:fP("preserve",bP),colorScheme:fP("preserve",bP),themeCategorical:fP("preserve",bP),themeSemantic:fP("preserve",bP),themeSequential:fP("preserve",bP),themeDiverging:fP("preserve",bP),barColors:fP("preserve",bP),decay:fP("preserve",bP),pulse:fP("preserve",bP),staleness:fP("preserve",bP),layoutSelection:fP("preserve",bP),windowSize:fP("preserve",vP),windowMode:fP("preserve",vP),clock:fP("preserve",vP),transition:fP("preserve",vP),introAnimation:fP("preserve",vP),onLayoutError:fP("preserve",vP)},kP=fP("preserve",mP),AP=class{constructor(){this.tracker=new nk}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}},hP)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},pP):this.recordNoop("restyle")}recordConfig(e){const t=Hg(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},SP=require("d3-quadtree"),MP=class{constructor(e){this.rExtent=new e_,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new AP,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new cP,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 JM(e.windowSize),this.getO=cd(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>sd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new e_)):(this.getR=sd(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=cd(e.stackBy),this.getGroup=cd(e.groupBy),this.getColor=cd(e.colorAccessor),this.getSymbol=cd(e.symbolAccessor),this.getConnector=cd(e.connectorAccessor),this.getDataId=cd(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new JM(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:Ch(t,n):null)}currentTime(){return this.config.clock?.()??md()}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(),Rh(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Th(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=Th(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,aP.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(e.width,e.height)/2,n=t.innerRadius||0;f=(0,aP.scaleLinear)().domain(l).range([n,i])}else u?(p=(0,aP.scaleBand)().domain(c).range([0,e.height]).padding(h),f=(0,aP.scaleLinear)().domain(l).range([0,e.width])):(p=(0,aP.scaleBand)().domain(c).range([0,e.width]).padding(h),f=(0,aP.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,aP.scaleLinear)().domain([s,a]).range([0,e.width]):(0,aP.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 Xg({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 Gg({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=Qd({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 Vd({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=dP[this.config.chartType];let o=n?n(i,t):[];return this.getConnector&&this.scales&&(o=[...Fg(i,o),...o]),o}buildLayoutContext(e,t){const i=this.config,n=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Bn(i.colorScheme,i.themeCategorical,Gk),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:Wn(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?vd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=wd(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=Vg(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=Ug(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)&&Eg(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&&_d(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=yd(e,this.activeTransition),i=fd(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=gd(n?n.opacity??1:0,e._targetOpacity,i)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=gd(n.x,e._targetX,i),e.y=gd(n.y,e._targetY,i)),void 0!==e._targetR&&void 0!==n?.r&&(e.r=gd(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t);e.style.opacity=gd(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=gd(n.x,e._targetX,i),e.y=gd(n.y,e._targetY,i),void 0!==n.w&&(e.w=gd(n.w,e._targetW,i),e.h=gd(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:gd(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=gd(n.startAngle,e._targetStartAngle,i),e.endAngle=gd(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,Xh(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=pd(e),i=this.getDataId,n=e=>t.has(i(e));Oh(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=pd(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&&!rd(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!rd(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!rd(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)&&(rd(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=cd(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)=>!rd(e,r[t])),o){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>sd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new e_)):(this.getR=sd(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!rd(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?cd(this.config.stackBy):void 0),"groupBy"in e&&!rd(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?cd(this.config.groupBy):void 0),"colorAccessor"in e&&!rd(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?cd(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!rd(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?cd(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!rd(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?cd(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}};Wh(MP);var _P=Wv(require("react")),$P=Wv(require("react")),PP=require("d3-shape"),jP=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)}),IP=require("react/jsx-runtime"),LP=require("react/jsx-runtime"),RP=require("react/jsx-runtime"),CP=require("react/jsx-runtime"),TP=Wv(require("react-dom/server")),OP=/* @__PURE__ */Object.create(null),EP=require("d3-array"),FP=require("d3-array"),NP=require("d3-interpolate"),zP=(require("d3-shape"),.5),DP=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,NP.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,NP.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=Mu({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},BP=/* @__PURE__ */new Set,WP=/* @__PURE__ */new WeakMap,YP={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(Pm))-1:0},justify:jm},qP={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:ud(e.source),target:ud(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=lx().extent(d).links(u).nodes(l).nodeAlign(YP[r]||jm).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=ud(e.source),i=ud(e.target);f.set(`${t}\0${i}`,e)}for(const e of u){const t=ud(e.source),i=ud(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:kk,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(dx(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(dx(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?ux(e):DP(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=ld(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}}};um("sankey",qP);var XP=require("d3-force"),GP=require("d3-scale"),VP={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=fx(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=gx(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=gx(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=hx(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=ud(e.source),i=ud(e.target);l.set(t,(l.get(t)??0)+1),l.set(i,(l.get(i)??0)+1)}const d=(0,XP.forceLink)().strength(e=>{const t=e.weight,i=ud(e.source),n=ud(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,XP.forceSimulation)();if(void 0===i.random&&void 0===i.seed||f.randomSource(i.random??px(i.seed)),f.force("charge",(0,XP.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,XP.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,XP.forceCenter)(r,s).strength(.8)).force("x",(0,XP.forceX)(r).strength(c)).force("y",(0,XP.forceY)(s).strength(c)).force("bounds",yx(n,y)),f.nodes(e),t.length>0){const e=t.map(e=>({...e,source:ud(e.source),target:ud(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=hx(i.nodeSize,i.nodeSizeRange,e),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:kk,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(dx(t,"nodeSize")),n=o?o(dx(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(dx(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=ld(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(dx(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}}};um("force",VP);var HP=require("d3-chord"),UP=require("d3-shape"),KP=kk,ZP={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=ud(e.source),i=ud(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,HP.chord)().padAngle(o);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,UP.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=ud(e.source),i=ud(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=ud(e.source),i=ud(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:KP,f=/* @__PURE__ */new Map;e.forEach((e,t)=>{f.set(e.id,p[t%p.length])});const y=(0,HP.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(dx(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=mx(n,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";const a=d?d(dx(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=ld(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}}};um("chord",ZP);var QP=require("d3-hierarchy"),JP=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],ej={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;if(!o)return;const r=i.chartType,s=vx(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,QP.hierarchy)(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(r){case"tree":jx(l,i,u,d);break;case"cluster":Ix(l,i,u,d);break;case"treemap":Lx(l,i,u,d);break;case"circlepack":Rx(l,i,u,d);break;case"partition":Cx(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:wx(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?Tx(o,n,i):"treemap"===r||"partition"===r?Ox(o,n):"circlepack"===r&&Ex(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 Mx(e,t,i,n,o,r);case"treemap":case"partition":return _x(e,i,0,o);case"circlepack":return $x(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};um("tree",ej),um("cluster",ej),um("treemap",ej),um("circlepack",ej),um("partition",ej);var tj=require("d3-shape"),ij={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;o&&Wx(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=Fx(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(dx(t,"nodeSize")),n=o?o(dx(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(dx(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(dx(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&&(Yx(e,i),!0)};um("orbit",ij);var nj=Wv(require("react")),oj=require("d3-shape"),rj=require("react/jsx-runtime"),sj=require("react/jsx-runtime");um("sankey",qP),um("force",VP),um("chord",ZP),um("tree",ej),um("cluster",ej),um("treemap",ej),um("circlepack",ej),um("partition",ej),um("orbit",ij);var aj=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]),cj=Wv(require("react-dom/server")),lj=require("d3-geo"),uj=require("d3-quadtree"),dj=require("d3-geo"),hj={mercator:dj.geoMercator,equalEarth:dj.geoEqualEarth,albersUsa:dj.geoAlbersUsa,orthographic:dj.geoOrthographic,naturalEarth:dj.geoNaturalEarth1,equirectangular:dj.geoEquirectangular},pj=require("d3-scale"),fj=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yj=["scene-style","data-paint","accessibility","evidence"],gj=(e,t)=>({retainedData:e,invalidations:t}),mj=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xj=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bj=["scene-geometry","data-paint","accessibility","evidence"],vj=["scene-style","data-paint","accessibility","evidence"],wj=["overlay","accessibility","evidence"],kj=[],Aj={xAccessor:gj("rebuild",mj),yAccessor:gj("rebuild",mj),lineDataAccessor:gj("rebuild",mj),pointIdAccessor:gj("rebuild",bj),lineIdAccessor:gj("rebuild",bj),windowSize:gj("rebuild",mj),projection:gj("preserve",xj),projectionExtent:gj("preserve",xj),fitPadding:gj("preserve",xj),lineType:gj("preserve",xj),flowStyle:gj("preserve",xj),graticule:gj("preserve",xj),projectionTransform:gj("preserve",xj),customLayout:gj("preserve",xj),layoutConfig:gj("preserve",xj),layoutMargin:gj("preserve",xj),areaStyle:gj("preserve",vj),pointStyle:gj("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:gj("preserve",vj),colorScheme:gj("preserve",vj),themeCategorical:gj("preserve",vj),themeDiverging:gj("preserve",vj),themeSemantic:gj("preserve",vj),themeSequential:gj("preserve",vj),decay:gj("preserve",vj),pulse:gj("preserve",vj),layoutSelection:gj("preserve",vj),annotations:gj("preserve",wj),autoPlaceAnnotations:gj("preserve",wj),clock:gj("preserve",kj),transition:gj("preserve",kj),introAnimation:gj("preserve",kj),onLayoutError:gj("preserve",kj)},Sj=gj("preserve",xj),Mj=class{constructor(){this.tracker=new nk}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}},fj)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},yj):this.recordNoop("restyle")}recordConfig(e,t={}){const i=mb(e),n=new Set(i.invalidations);return t.retainedDataChanged&&n.add("data"),this.tracker.record({kind:"config",keys:e},n)}},_j=require("d3-geo"),$j=class e{constructor(e){this.updateResults=new Mj,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=vb(e)}currentTime(){return this.config.clock?.()??md()}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 JM(e),this.timestampBuffer=new JM(e),n.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=wb(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 JM(t),this.timestampBuffer=new JM(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();Th(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)Th(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)+"");Oh(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=nb(t.projection),this.geoPath=(0,lj.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,lj.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=ob(i.xAccessor,"lon"),r=ob(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=rb(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,lj.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,lj.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,lj.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,uj.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=Bn(t.colorScheme,t.themeCategorical,Gk),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:Wn(n,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},r=Qd({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 Vd({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,xb({config:t,projection:i,path:n,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const i=fb(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=vd(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=Ad(t,n[a],e);s=Md(i[a],c,o,r)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&_d(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=yd(e,this.activeTransition),i=fd(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=gd(e.x,e._targetX,i),e.y=gd(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}};$j.QUADTREE_THRESHOLD=500;var Pj=$j;Wh(Pj);var jj=Wv(require("react")),Ij=require("react/jsx-runtime"),Lj=require("react/jsx-runtime"),Rj=require("react/jsx-runtime"),Cj=Wv(require("react-dom/server")),Tj={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85},Oj=require("react/jsx-runtime"),Ej={top:0,right:0,bottom:0,left:0},Fj=require("react/jsx-runtime"),Nj=require("d3-scale"),zj=require("react/jsx-runtime"),Dj={top:0,right:0,bottom:0,left:0},Bj=Wv(require("react-dom/server")),Wj=require("react/jsx-runtime"),Yj={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}},qj={BigNumber:function(e,t){const i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",n=Yj[i],o=ov(e.width,n.width),r=ov(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=Fr(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=ev("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:nv(d,e.thresholds),g="string"==typeof e.color?e.color:rv(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:sv(e,d,h),void 0===d?void 0:av(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=Bj.renderToStaticMarkup(
643
+ /* @__PURE__ */(0,Q$.jsx)("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=up({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:CA},nP=Wv(require("react")),oP=require("react/jsx-runtime"),rP=/* @__PURE__ */new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]),sP=Wv(require("react-dom/server")),aP=require("d3-scale"),cP=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:Dn(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||Gk,o=n[this.colorSchemeIndex%n.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}},lP=require("d3-array"),uP=require("d3-scale"),dP={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(hh(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(hh(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=Ng(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=Ng(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(hh(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(hh(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=Ng(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=zg(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);Dg(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=zg(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;Dg(c,u,n,l?e.middle+p:s(a),l?s(a):e.middle+p,h,d)}}return c},pie:Bg,donut:Bg,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=Yg(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(Wg(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=qg(t,i,n,o,d),p=Mt(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=Yg(t),m=s(Wg(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]=At(t),o=null!=h&&isFinite(h)?h:i,d=null!=p&&isFinite(p)?p:n,f=(d-o)/l||1,y=qg(t,o,d,f,l),g=t.length,m=Mt(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(hh(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=qg(t,i,n,o,u),p=Mt(c,1),f=Yg(t),y=s(Wg(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(hh(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(hh(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,uP.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(hh(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(hh(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(hh(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(hh(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?hh(r,i.x,s,i.width,n,null,"__track__"):hh(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=hh(o,e.x,r-o,e.width,p,i,c)}else{const o=a(t+n),r=a(t);f=hh(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}},hP=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pP=["scene-style","data-paint","accessibility","evidence"],fP=(e,t)=>({retainedData:e,invalidations:t}),yP=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gP=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mP=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xP=["scene-geometry","data-paint","accessibility","evidence"],bP=["scene-style","data-paint","accessibility","evidence"],vP=[],wP={chartType:fP("rebuild",yP),runtimeMode:fP("rebuild",yP),categoryAccessor:fP("rebuild",yP),valueAccessor:fP("rebuild",yP),oAccessor:fP("rebuild",yP),rAccessor:fP("rebuild",yP),stackBy:fP("rebuild",yP),groupBy:fP("rebuild",yP),timeAccessor:fP("rebuild",yP),accessorRevision:fP("rebuild",yP),colorAccessor:fP("rebuild",bP),symbolAccessor:fP("rebuild",xP),connectorAccessor:fP("rebuild",xP),dataIdAccessor:fP("rebuild",xP),projection:fP("preserve",gP),extentPadding:fP("preserve",gP),axisExtent:fP("preserve",gP),rExtent:fP("preserve",gP),oExtent:fP("preserve",gP),multiAxis:fP("preserve",gP),normalize:fP("preserve",gP),bins:fP("preserve",gP),oSort:fP("preserve",mP),barPadding:fP("preserve",mP),roundedTop:fP("preserve",mP),baselinePadding:fP("preserve",mP),innerRadius:fP("preserve",mP),cornerRadius:fP("preserve",mP),startAngle:fP("preserve",mP),sweepAngle:fP("preserve",mP),trackFill:fP("preserve",mP),showOutliers:fP("preserve",mP),showIQR:fP("preserve",mP),amplitude:fP("preserve",mP),connectorOpacity:fP("preserve",mP),showLabels:fP("preserve",mP),dynamicColumnWidth:fP("rebuild",mP),customLayout:fP("preserve",mP),layoutConfig:fP("preserve",mP),layoutMargin:fP("preserve",mP),symbolMap:fP("preserve",xP),pieceStyle:fP("preserve",bP),summaryStyle:fP("preserve",bP),connectorStyle:fP("preserve",bP),gradientFill:fP("preserve",bP),colorScheme:fP("preserve",bP),themeCategorical:fP("preserve",bP),themeSemantic:fP("preserve",bP),themeSequential:fP("preserve",bP),themeDiverging:fP("preserve",bP),barColors:fP("preserve",bP),decay:fP("preserve",bP),pulse:fP("preserve",bP),staleness:fP("preserve",bP),layoutSelection:fP("preserve",bP),windowSize:fP("preserve",vP),windowMode:fP("preserve",vP),clock:fP("preserve",vP),transition:fP("preserve",vP),introAnimation:fP("preserve",vP),onLayoutError:fP("preserve",vP)},kP=fP("preserve",mP),AP=class{constructor(){this.tracker=new nk}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}},hP)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},pP):this.recordNoop("restyle")}recordConfig(e){const t=Hg(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},SP=require("d3-quadtree"),MP=class{constructor(e){this.rExtent=new e_,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new AP,this.rAccessors=[],this.categories=/* @__PURE__ */new Set,this._hasStreamingData=!1,this.styleResolver=new cP,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 JM(e.windowSize),this.getO=cd(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>sd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new e_)):(this.getR=sd(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=cd(e.stackBy),this.getGroup=cd(e.groupBy),this.getColor=cd(e.colorAccessor),this.getSymbol=cd(e.symbolAccessor),this.getConnector=cd(e.connectorAccessor),this.getDataId=cd(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new JM(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:Ch(t,n):null)}currentTime(){return this.config.clock?.()??md()}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(),Rh(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const i of e.inserts)Th(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=Th(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,aP.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(e.width,e.height)/2,n=t.innerRadius||0;f=(0,aP.scaleLinear)().domain(l).range([n,i])}else u?(p=(0,aP.scaleBand)().domain(c).range([0,e.height]).padding(h),f=(0,aP.scaleLinear)().domain(l).range([0,e.width])):(p=(0,aP.scaleBand)().domain(c).range([0,e.width]).padding(h),f=(0,aP.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,aP.scaleLinear)().domain([s,a]).range([0,e.width]):(0,aP.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 Xg({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 Gg({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=Qd({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 Vd({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=dP[this.config.chartType];let o=n?n(i,t):[];return this.getConnector&&this.scales&&(o=[...Fg(i,o),...o]),o}buildLayoutContext(e,t){const i=this.config,n=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=qn(i.colorScheme,i.themeCategorical,Gk),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:Xn(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){const i=this.config.decay;return i&&t>1?vd(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=wd(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=Vg(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=Ug(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)&&Eg(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&&_d(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=yd(e,this.activeTransition),i=fd(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=gd(n?n.opacity??1:0,e._targetOpacity,i)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=gd(n.x,e._targetX,i),e.y=gd(n.y,e._targetY,i)),void 0!==e._targetR&&void 0!==n?.r&&(e.r=gd(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t);e.style.opacity=gd(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=gd(n.x,e._targetX,i),e.y=gd(n.y,e._targetY,i),void 0!==n.w&&(e.w=gd(n.w,e._targetW,i),e.h=gd(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:gd(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=gd(n.startAngle,e._targetStartAngle,i),e.endAngle=gd(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,Xh(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=pd(e),i=this.getDataId,n=e=>t.has(i(e));Oh(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=pd(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&&!rd(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!rd(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!rd(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)&&(rd(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=cd(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)=>!rd(e,r[t])),o){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>sd(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new e_)):(this.getR=sd(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!rd(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?cd(this.config.stackBy):void 0),"groupBy"in e&&!rd(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?cd(this.config.groupBy):void 0),"colorAccessor"in e&&!rd(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?cd(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!rd(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?cd(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!rd(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?cd(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}};Wh(MP);var _P=Wv(require("react")),$P=Wv(require("react")),PP=require("d3-shape"),jP=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)}),IP=require("react/jsx-runtime"),LP=require("react/jsx-runtime"),RP=require("react/jsx-runtime"),CP=require("react/jsx-runtime"),TP=Wv(require("react-dom/server")),OP=/* @__PURE__ */Object.create(null),EP=require("d3-array"),FP=require("d3-array"),NP=require("d3-interpolate"),zP=(require("d3-shape"),.5),DP=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,NP.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,NP.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=Mu({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},BP=/* @__PURE__ */new Set,WP=/* @__PURE__ */new WeakMap,YP={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(Pm))-1:0},justify:jm},qP={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:ud(e.source),target:ud(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=lx().extent(d).links(u).nodes(l).nodeAlign(YP[r]||jm).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=ud(e.source),i=ud(e.target);f.set(`${t}\0${i}`,e)}for(const e of u){const t=ud(e.source),i=ud(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:kk,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(dx(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(dx(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?ux(e):DP(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=ld(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}}};um("sankey",qP);var XP=require("d3-force"),GP=require("d3-scale"),VP={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=fx(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=gx(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=gx(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=hx(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=ud(e.source),i=ud(e.target);l.set(t,(l.get(t)??0)+1),l.set(i,(l.get(i)??0)+1)}const d=(0,XP.forceLink)().strength(e=>{const t=e.weight,i=ud(e.source),n=ud(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,XP.forceSimulation)();if(void 0===i.random&&void 0===i.seed||f.randomSource(i.random??px(i.seed)),f.force("charge",(0,XP.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,XP.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,XP.forceCenter)(r,s).strength(.8)).force("x",(0,XP.forceX)(r).strength(c)).force("y",(0,XP.forceY)(s).strength(c)).force("bounds",yx(n,y)),f.nodes(e),t.length>0){const e=t.map(e=>({...e,source:ud(e.source),target:ud(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=hx(i.nodeSize,i.nodeSizeRange,e),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:kk,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(dx(t,"nodeSize")),n=o?o(dx(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(dx(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=ld(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(dx(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}}};um("force",VP);var HP=require("d3-chord"),UP=require("d3-shape"),KP=kk,ZP={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=ud(e.source),i=ud(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,HP.chord)().padAngle(o);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,UP.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=ud(e.source),i=ud(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=ud(e.source),i=ud(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:KP,f=/* @__PURE__ */new Map;e.forEach((e,t)=>{f.set(e.id,p[t%p.length])});const y=(0,HP.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(dx(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=mx(n,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";const a=d?d(dx(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=ld(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}}};um("chord",ZP);var QP=require("d3-hierarchy"),JP=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],ej={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;if(!o)return;const r=i.chartType,s=vx(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,QP.hierarchy)(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(r){case"tree":jx(l,i,u,d);break;case"cluster":Ix(l,i,u,d);break;case"treemap":Lx(l,i,u,d);break;case"circlepack":Rx(l,i,u,d);break;case"partition":Cx(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:wx(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?Tx(o,n,i):"treemap"===r||"partition"===r?Ox(o,n):"circlepack"===r&&Ex(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 Mx(e,t,i,n,o,r);case"treemap":case"partition":return _x(e,i,0,o);case"circlepack":return $x(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};um("tree",ej),um("cluster",ej),um("treemap",ej),um("circlepack",ej),um("partition",ej);var tj=require("d3-shape"),ij={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,n){const o=i.__hierarchyRoot;o&&Wx(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=Fx(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(dx(t,"nodeSize")),n=o?o(dx(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(dx(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(dx(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&&(Yx(e,i),!0)};um("orbit",ij);var nj=Wv(require("react")),oj=require("d3-shape"),rj=require("react/jsx-runtime"),sj=require("react/jsx-runtime");um("sankey",qP),um("force",VP),um("chord",ZP),um("tree",ej),um("cluster",ej),um("treemap",ej),um("circlepack",ej),um("partition",ej),um("orbit",ij);var aj=/* @__PURE__ */new Set(["tree","cluster","treemap","circlepack","partition","orbit"]),cj=Wv(require("react-dom/server")),lj=require("d3-geo"),uj=require("d3-quadtree"),dj=require("d3-geo"),hj={mercator:dj.geoMercator,equalEarth:dj.geoEqualEarth,albersUsa:dj.geoAlbersUsa,orthographic:dj.geoOrthographic,naturalEarth:dj.geoNaturalEarth1,equirectangular:dj.geoEquirectangular},pj=require("d3-scale"),fj=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yj=["scene-style","data-paint","accessibility","evidence"],gj=(e,t)=>({retainedData:e,invalidations:t}),mj=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xj=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bj=["scene-geometry","data-paint","accessibility","evidence"],vj=["scene-style","data-paint","accessibility","evidence"],wj=["overlay","accessibility","evidence"],kj=[],Aj={xAccessor:gj("rebuild",mj),yAccessor:gj("rebuild",mj),lineDataAccessor:gj("rebuild",mj),pointIdAccessor:gj("rebuild",bj),lineIdAccessor:gj("rebuild",bj),windowSize:gj("rebuild",mj),projection:gj("preserve",xj),projectionExtent:gj("preserve",xj),fitPadding:gj("preserve",xj),lineType:gj("preserve",xj),flowStyle:gj("preserve",xj),graticule:gj("preserve",xj),projectionTransform:gj("preserve",xj),customLayout:gj("preserve",xj),layoutConfig:gj("preserve",xj),layoutMargin:gj("preserve",xj),areaStyle:gj("preserve",vj),pointStyle:gj("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:gj("preserve",vj),colorScheme:gj("preserve",vj),themeCategorical:gj("preserve",vj),themeDiverging:gj("preserve",vj),themeSemantic:gj("preserve",vj),themeSequential:gj("preserve",vj),decay:gj("preserve",vj),pulse:gj("preserve",vj),layoutSelection:gj("preserve",vj),annotations:gj("preserve",wj),autoPlaceAnnotations:gj("preserve",wj),clock:gj("preserve",kj),transition:gj("preserve",kj),introAnimation:gj("preserve",kj),onLayoutError:gj("preserve",kj)},Sj=gj("preserve",xj),Mj=class{constructor(){this.tracker=new nk}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}},fj)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},yj):this.recordNoop("restyle")}recordConfig(e,t={}){const i=mb(e),n=new Set(i.invalidations);return t.retainedDataChanged&&n.add("data"),this.tracker.record({kind:"config",keys:e},n)}},_j=require("d3-geo"),$j=class e{constructor(e){this.updateResults=new Mj,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=vb(e)}currentTime(){return this.config.clock?.()??md()}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 JM(e),this.timestampBuffer=new JM(e),n.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=wb(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 JM(t),this.timestampBuffer=new JM(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();Th(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)Th(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)+"");Oh(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=nb(t.projection),this.geoPath=(0,lj.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,lj.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=ob(i.xAccessor,"lon"),r=ob(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=rb(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,lj.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,lj.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,lj.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,uj.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=qn(t.colorScheme,t.themeCategorical,Gk),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:Xn(n,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},r=Qd({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 Vd({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,xb({config:t,projection:i,path:n,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const i=fb(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=vd(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=Ad(t,n[a],e);s=Md(i[a],c,o,r)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&_d(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=yd(e,this.activeTransition),i=fd(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=gd(e.x,e._targetX,i),e.y=gd(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}};$j.QUADTREE_THRESHOLD=500;var Pj=$j;Wh(Pj);var jj=Wv(require("react")),Ij=require("react/jsx-runtime"),Lj=require("react/jsx-runtime"),Rj=require("react/jsx-runtime"),Cj=Wv(require("react-dom/server")),Tj={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85},Oj=require("react/jsx-runtime"),Ej={top:0,right:0,bottom:0,left:0},Fj=require("react/jsx-runtime"),Nj=require("d3-scale"),zj=require("react/jsx-runtime"),Dj={top:0,right:0,bottom:0,left:0},Bj=Wv(require("react-dom/server")),Wj=require("react/jsx-runtime"),Yj={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}},qj={BigNumber:function(e,t){const i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",n=Yj[i],o=ov(e.width,n.width),r=ov(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=Dr(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=ev("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:nv(d,e.thresholds),g="string"==typeof e.color?e.color:rv(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:sv(e,d,h),void 0===d?void 0:av(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=Bj.renderToStaticMarkup(
644
644
  /* @__PURE__ */
645
645
  /* @__PURE__ */(0,Wj.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__ */