semiotic 3.10.0 → 3.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -59
- package/ai/artifact-surface-inventory.json +1 -1
- package/ai/componentMetadata.cjs +3 -1
- package/ai/dist/mcp-server.js +45 -45
- package/ai/examples.md +67 -0
- package/ai/reference.md +75 -1
- package/ai/schema.json +5199 -1
- package/ai/surface-manifest.json +24 -3
- package/ai/task-packets/compare-category-totals.json +6 -6
- package/ai/task-packets/compare-category-totals.md +3 -3
- package/ai/task-packets/correct-published-chart.json +6 -6
- package/ai/task-packets/correct-published-chart.md +3 -3
- package/ai/task-packets/index.json +6 -6
- package/ai/task-packets/update-live-chart.json +6 -6
- package/ai/task-packets/update-live-chart.md +3 -3
- package/dist/c-2RL2QPZJ.min.js +1 -0
- package/dist/c-45CQWZZ6.min.js +1 -0
- package/dist/{c-PP6VY3QU.min.js → c-4BRHKVKV.min.js} +1 -1
- package/dist/c-7DVPSB5C.min.js +1 -0
- package/dist/{c-XDQKXPX4.min.js → c-A7OGOFSL.min.js} +1 -1
- package/dist/{c-AZKPVBOC.min.js → c-AH5HWZWS.min.js} +1 -1
- package/dist/c-B7GW7IHJ.min.js +1 -0
- package/dist/{c-ROEHCIGV.min.js → c-C3TZLTZK.min.js} +1 -1
- package/dist/c-CGQAQWBV.min.js +1 -0
- package/dist/c-DIPEYUOW.min.js +1 -0
- package/dist/{c-WNGH47HF.min.js → c-E72OTUZU.min.js} +1 -1
- package/dist/{c-DY2676CR.min.js → c-EUMPMDCS.min.js} +1 -1
- package/dist/c-EZZT2WAE.min.js +1 -0
- package/dist/c-FHBVFCQB.min.js +1 -0
- package/dist/{c-E32M6XW5.min.js → c-G4HCO2IQ.min.js} +1 -1
- package/dist/{c-ZYPXQF7B.min.js → c-G5VIJEOK.min.js} +1 -1
- package/dist/c-GHVOXAYH.min.js +1 -0
- package/dist/{c-EBOQ7ER7.min.js → c-HP4ZFM47.min.js} +1 -1
- package/dist/{c-IDJV3CZK.min.js → c-HYDTS5OP.min.js} +1 -1
- package/dist/c-IK33LNZ6.min.js +1 -0
- package/dist/c-IK3PZHRY.min.js +1 -0
- package/dist/{c-JO2UGTCP.min.js → c-J6DVC236.min.js} +1 -1
- package/dist/{c-MXCP7GNZ.min.js → c-JIMJF6F6.min.js} +1 -1
- package/dist/{c-4FN7Q6VQ.min.js → c-KKPMHAZC.min.js} +1 -1
- package/dist/c-L6WNDBHV.min.js +1 -0
- package/dist/c-LDEX5OFW.min.js +1 -0
- package/dist/{c-CPSPZH6A.min.js → c-LESEUVC5.min.js} +1 -1
- package/dist/c-MB6CV5NC.min.js +1 -0
- package/dist/{c-OO5QLMJC.min.js → c-MOKJOIPE.min.js} +1 -1
- package/dist/{c-BNG5ECK5.min.js → c-N3FXLRNT.min.js} +1 -1
- package/dist/c-N5NPTJVJ.min.js +1 -0
- package/dist/{c-DE5Q3U2X.min.js → c-NHBL4J67.min.js} +1 -1
- package/dist/{c-LMGSSD2E.min.js → c-ODG6TFSY.min.js} +1 -1
- package/dist/{c-HXDKPIKR.min.js → c-PSKKFZNP.min.js} +1 -1
- package/dist/{c-NYZ2QNAM.min.js → c-R2P4RR7Q.min.js} +1 -1
- package/dist/{c-KCRJGUHP.min.js → c-RFC7UAG7.min.js} +1 -1
- package/dist/c-SGAURYHG.min.js +1 -0
- package/dist/{c-DK662R77.min.js → c-SJMWU6UX.min.js} +1 -1
- package/dist/c-STIIGQOD.min.js +1 -0
- package/dist/c-T2ASIJVZ.min.js +1 -0
- package/dist/c-TX3THUTO.min.js +1 -0
- package/dist/{c-55BAJ333.min.js → c-TX7XJM3Z.min.js} +1 -1
- package/dist/c-UMXSJIOV.min.js +1 -0
- package/dist/{c-JLGRHXGZ.min.js → c-VRSXMLYF.min.js} +1 -1
- package/dist/c-VSLWSAN2.min.js +1 -0
- package/dist/{c-33QOXEUG.min.js → c-WCBRPILW.min.js} +1 -1
- package/dist/{c-WH2O53VI.min.js → c-WGHT7OCY.min.js} +1 -1
- package/dist/c-WWCW3APR.min.js +1 -0
- package/dist/c-Y6PYUMFU.min.js +1 -0
- package/dist/c-ZIVPFTOC.min.js +1 -0
- package/dist/components/charts/shared/chartDataProps.d.ts +3 -0
- package/dist/components/charts/shared/chartSpecAtlasSchemas.d.ts +5 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecsAtlas.d.ts +2 -0
- package/dist/components/charts/shared/hooks.d.ts +3 -1
- package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
- package/dist/components/recipes/atlas/DependencyForestChart.d.ts +20 -0
- package/dist/components/recipes/atlas/DependencyMatrix.d.ts +7 -0
- package/dist/components/recipes/atlas/FlowCircuitChart.d.ts +20 -0
- package/dist/components/recipes/atlas/MotifBraidChart.d.ts +17 -0
- package/dist/components/recipes/atlas/atlasChartOptions.d.ts +11 -0
- package/dist/components/recipes/atlas/braid.d.ts +62 -0
- package/dist/components/recipes/atlas/capsules.d.ts +18 -0
- package/dist/components/recipes/atlas/compare.d.ts +4 -0
- package/dist/components/recipes/atlas/completeness.d.ts +2 -0
- package/dist/components/recipes/atlas/dependencyForest.d.ts +32 -0
- package/dist/components/recipes/atlas/dependencyForestChartProps.d.ts +58 -0
- package/dist/components/recipes/atlas/dependencyForestLayout.d.ts +17 -0
- package/dist/components/recipes/atlas/dependencyQueries.d.ts +20 -0
- package/dist/components/recipes/atlas/dependencyTypes.d.ts +21 -0
- package/dist/components/recipes/atlas/directedGraph.d.ts +9 -0
- package/dist/components/recipes/atlas/entityCounts.d.ts +3 -0
- package/dist/components/recipes/atlas/flowCircuit.d.ts +32 -0
- package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +72 -0
- package/dist/components/recipes/atlas/flowCircuitChrome.d.ts +18 -0
- package/dist/components/recipes/atlas/flowCircuitGeometry.d.ts +11 -0
- package/dist/components/recipes/atlas/flowCircuitLayout.d.ts +20 -0
- package/dist/components/recipes/atlas/flowCircuitSemantics.d.ts +26 -0
- package/dist/components/recipes/atlas/flowCircuitTape.d.ts +22 -0
- package/dist/components/recipes/atlas/flowCircuitTypes.d.ts +144 -0
- package/dist/components/recipes/atlas/forests.d.ts +11 -0
- package/dist/components/recipes/atlas/ids.d.ts +6 -0
- package/dist/components/recipes/atlas/index.d.ts +26 -0
- package/dist/components/recipes/atlas/ledger.d.ts +7 -0
- package/dist/components/recipes/atlas/motifBraidChartProps.d.ts +51 -0
- package/dist/components/recipes/atlas/motifBraidGeometry.d.ts +5 -0
- package/dist/components/recipes/atlas/motifBraidLayout.d.ts +11 -0
- package/dist/components/recipes/atlas/motifs.d.ts +3 -0
- package/dist/components/recipes/atlas/prefixForest.d.ts +9 -0
- package/dist/components/recipes/atlas/prepare.d.ts +14 -0
- package/dist/components/recipes/atlas/prepareAsync.d.ts +7 -0
- package/dist/components/recipes/atlas/profile.d.ts +19 -0
- package/dist/components/recipes/atlas/publish.d.ts +10 -0
- package/dist/components/recipes/atlas/queries.d.ts +34 -0
- package/dist/components/recipes/atlas/requiredPaths.d.ts +9 -0
- package/dist/components/recipes/atlas/rootedForest.d.ts +4 -0
- package/dist/components/recipes/atlas/sections.d.ts +3 -0
- package/dist/components/recipes/atlas/support.d.ts +7 -0
- package/dist/components/recipes/atlas/types.d.ts +278 -0
- package/dist/components/recipes/atlas/validate.d.ts +12 -0
- package/dist/components/semiotic-atlas-core.d.ts +20 -0
- package/dist/components/semiotic-atlas.d.ts +8 -0
- package/dist/components/semiotic-recipes-core.d.ts +9 -0
- package/dist/components/server/serverChartConfigs.d.ts +3 -0
- package/dist/components/server/serverChartConfigsAtlas.d.ts +4 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +1 -0
- package/dist/components/stream/canvasSetup.d.ts +1 -2
- package/dist/components/stream/fontLoading.d.ts +4 -0
- package/dist/components/stream/networkCustomLayout.d.ts +8 -0
- package/dist/components/stream/networkCustomLayoutCache.d.ts +12 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +0 -7
- package/dist/components/stream/physics/physicsSemanticUI.d.ts +2 -0
- package/dist/components/stream/physics/usePhysicsCanvasPointer.d.ts +3 -1
- package/dist/components/stream/physics/usePhysicsSemanticNavigation.d.ts +2 -0
- package/dist/components/stream/shallowEqual.d.ts +2 -0
- package/dist/components/stream/useEnsureCustomXYRenderers.d.ts +4 -2
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/rough.module.min.js +1 -1
- package/dist/semiotic-access.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-artifact.min.js +1 -1
- package/dist/semiotic-artifact.module.min.js +1 -1
- package/dist/semiotic-atlas-core.d.ts +20 -0
- package/dist/semiotic-atlas-core.min.js +1 -0
- package/dist/semiotic-atlas-core.module.min.js +1 -0
- package/dist/semiotic-atlas-selection.module.min.js +2 -0
- package/dist/semiotic-atlas.d.ts +8 -0
- package/dist/semiotic-atlas.min.js +2 -0
- package/dist/semiotic-atlas.module.min.js +2 -0
- package/dist/semiotic-client-cjs-shared.min.js +1 -1
- package/dist/semiotic-evidence.min.js +1 -1
- package/dist/semiotic-evidence.module.min.js +1 -1
- package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
- package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.min.js +1 -1
- package/dist/semiotic-experimental-vacp.module.min.js +1 -1
- package/dist/semiotic-line.module.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +9 -0
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-server-edge-node.module.min.js +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-text.min.js +1 -1
- package/dist/semiotic-text.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +16 -1
- package/dist/c-447VIMRO.min.js +0 -1
- package/dist/c-553QUDKA.min.js +0 -1
- package/dist/c-7HP7MB2I.min.js +0 -1
- package/dist/c-7NBU5ZKS.min.js +0 -1
- package/dist/c-CCTGN5CK.min.js +0 -1
- package/dist/c-GSZRZRD6.min.js +0 -1
- package/dist/c-GWX7JGMF.min.js +0 -1
- package/dist/c-ITKX3RC5.min.js +0 -1
- package/dist/c-JG2JCQLP.min.js +0 -1
- package/dist/c-LYVKDBQJ.min.js +0 -1
- package/dist/c-NG7BLZTR.min.js +0 -1
- package/dist/c-PYNW54D2.min.js +0 -1
- package/dist/c-TIXX5CAU.min.js +0 -1
- /package/dist/{c-OOVX2JPQ.min.js → c-UC7SIU2W.min.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return"function"==typeof e?e:t=>t[e]}function t(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function n(e){return null==e?null:e.data??e.datum??e}function o(e,t){const n=new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function r(e){const t=Object.create(null);return e((e,n)=>{t[e]=n}),t}function i(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&o[e.field]+""!=e.value+"")return!1;return!0}function a(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!i(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function s(e){return e.join("|")}function c(e,t=.72){const n=(0,ca.interpolateLab)(e,"#ffffff"),o=(0,ca.interpolateLab)(e,"#000000"),r=(0,ca.interpolateLab)(e,e)(0);return e=>{const i=0>e?0:e>1?1:e;return.5===i?r:.5>i?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function l(e,t,n=.72){return c(e,n)(t)}function u(e){return r(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function d(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function h(e,t,n){return Math.max(t,Math.min(n,e))}function f(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function m(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function p(e,t){const n=h(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}function g(e,t,n){const o=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,r=e=>Number.isFinite(e)?Math.max(0,e):0,i=e.reduce((e,t)=>e+(r(t.weight)>0?1:0),0),a=i>0?Math.min(Math.max(0,Math.floor(n?.minPerCategory??0)),Math.floor(o/i)):0,s=e.reduce((e,t)=>e+r(t.weight),0);if(0>=o||0>=s)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const c=e.map(e=>{const t=r(e.weight),n=t/s*o;return{...e,exact:n,cells:t>0?Math.max(a,Math.floor(n)):0,remainder:n-Math.floor(n)}});let l=c.reduce((e,t)=>e+t.cells,0);for(;l>o;){const e=c.filter(e=>e.cells>a).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,l--}const u=c.filter(e=>r(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||r(t.weight)-r(e.weight)||e.key.localeCompare(t.key));for(let e=0;o>l;e++)u[e%u.length].cells++,l++;return c}function y(e,t,n,o){const r=new Set;return e.map((e,i)=>{const a=t(e,i)+"",s=Number(n(e,i));if(!a)throw Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(a))throw Error(`${o} snapshot contains duplicate id "${a}".`);if(!Number.isFinite(s)||0>s)throw Error(`${o} snapshot value for "${a}" must be a finite non-negative number.`);return r.add(a),{id:a,value:s}})}function x(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null==n.epsilon||0>n.epsilon?1e-9:n.epsilon,a=y(e,n.beforeId,n.beforeValue,"Before"),s=y(t,o,r,"After"),c=new Map(a.map(e=>[e.id,e.value])),l=new Map(s.map(e=>[e.id,e.value])),u=a.reduce((e,t)=>e+t.value,0),d=s.reduce((e,t)=>e+t.value,0),h=i>=Math.abs(u-d);if(!h&&!n.allowImbalance)throw Error(`Snapshot totals must match (before ${u}, after ${d}). Pass allowImbalance to inspect residuals.`);const f=[],m=[...a.map(e=>e.id),...s.map(e=>e.id).filter(e=>!c.has(e))];for(const e of m){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&f.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const p=a.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=s.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let x=0,b=0;for(;p.length>x&&g.length>b;){const e=p[x],t=g[b],n=Math.min(e.value,t.value);n>i&&f.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value>i||(x+=1),t.value>i||(b+=1)}return{flows:f,beforeTotal:u,afterTotal:d,balanced:h,unmatchedBefore:p.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(b).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function b(e){return Number.isFinite(e)?Math.max(0,e):0}function w(e,t){const n=Number(t.unit),o=b(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const a=Math.ceil(o/n-da),s=Math.min(r,a),c=a>r,l=[];for(let e=0;s>e;e+=1){const t=e*n;let r=Math.min(1,Math.max(0,(Math.min(o,t+n)-t)/n));da>1-r&&(r=1),l.push({index:e,fraction:r,start:t,end:t+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((e,t)=>e+t.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function M(e,t,n){const o=w(e,n),r=Math.max(b(t),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=w(r,{unit:n.unit,maxUnits:n.maxUnits}),a=i.unit>0?o.total/i.unit:0,s=Math.floor(a+da);let c=Math.min(1,Math.max(0,a-s));da>c&&(c=0);const l=[];for(const e of i.units)s>e.index||(e.index===s&&c>0?e.fraction-c>da&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function v(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 k(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=v(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const m=fa/2,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=new Set(e.map(e=>e.id)),y=t.filter(e=>g.has(e.source)&&g.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=(0,ha.forceSimulation)(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",(0,ha.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",(0,ha.forceCollide)(e=>(e=>"function"==typeof l?l(e.data):l)(e)+u).strength(.9).iterations(2)).force("center",(0,ha.forceCenter)(m,m).strength(.8)).force("x",(0,ha.forceX)(m).strength(s)).force("y",(0,ha.forceY)(m).strength(s));y.length>0&&e.force("link",(0,ha.forceLink)(y).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/n})),e.stop();for(let t=0;o>t;t+=1)e.tick()}let x=1/0,b=1/0,w=-1/0,M=-1/0;for(const e of p){const t=e.x??m,n=e.y??m;x>t&&(x=t),b>n&&(b=n),t>w&&(w=t),n>M&&(M=n)}const k=w-x,$=M-b,A={};for(const e of p)Object.defineProperty(A,e.id,{value:{x:0===k?.5:d+((e.x??m)-x)/k*(1-2*d),y:0===$?.5:d+((e.y??m)-b)/$*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return A}function $(e){return e?e.map(Number).filter(Number.isFinite):[]}function A(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function S(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function I(e){if(e.samples)return $(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function C(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function j(e,t){const n=S(t),o=function(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:$(e),data:e}:e}(e);let r,i,a,s,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?w(f(o.value),e):M(f(o.value),f(o.rangeValue),e);r=t.units.map(e=>C(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue&&(l=t.rangeTotal,u=t.rangeUnits.map(e=>C(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){s=Math.floor(f(o.denominator??n.denominator)),a=f(o.numerator??n.numerator??o.value);const e=Math.min(s,Math.max(0,Math.round(a)));r=Array.from({length:s},(t,o)=>C(n,o,1,{highlighted:e>o,start:o,end:o+1})),i=s,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=I(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),a=e.length>0?Math.min(t,A(n)):0;r=Array.from({length:a},(t,o)=>{const r=(o+.5)/a,i=function(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=o-r;return e[r]*(1-i)+e[Math.ceil(o)]*i}(e,r);return C(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=I(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),a=Math.min(t,A(n));r=("random-sample"===n.countStrategy?function(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=v(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}(e.length,n.seed).slice(0,a):Array.from({length:a},(t,n)=>Math.floor(n/Math.max(1,a-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return C(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>C(n,t,1,{datum:e})),i=e.length;else{const e=w(f(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>C(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=function(e,t){const n=A(t);return e.length>n?{tokens:e.slice(0,n),overflow:!0}:{tokens:e,overflow:!1}}(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:a,denominator:s,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:F(n,{visibleTokens:r.length+(u?.length??0)})}}function N(e,t={}){const n=Array.isArray(e)?e:e.tokens,o=n.length;if(0===o)return[];const r=t.flow??"row",i=t.cellWidth??16,a=t.cellHeight??i,s=t.gutter??2,c=t.anchor??[.5,.5],l=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?o/t.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(t.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=t.x??0,m=t.y??0;return n.map((e,n)=>{let o,p;return"column"===r?(p=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),p=n%l),"left"===t.columnDirection&&(p=h-1-p),"up"===t.rowDirection&&(o=d-1-o),{...e,row:o,column:p,x:f+p*(i+s)+c[0]*i,y:m+o*(a+s)+c[1]*a}})}function F(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||f(e.denominator)>pa?ma:pa);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function E(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function z(e){const t=E(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function L(e){const t=E(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:F(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:F(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:F(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:F(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function O(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return function(e){const t=1.5*T(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t);const r=Object.prototype.hasOwnProperty.call(ya,o)?ya[o]:ga.symbolCircle;return(0,ga.symbol)(r,Math.max(1,t))()??""}function T(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function P(e,t,n){if(!n&&"circle"===(e??"circle"))return T(t);const o=n?"p:"+n:`s:${e??"circle"}:${t}`,r=ba.get(o);if(null!=r)return r;const i=O(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let a=0;if(i)for(let e=0;i.length>e+1;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>a&&(a=o)}return a>0?(ba.size>512&&ba.clear(),ba.set(o,a),a):T(t)}function R(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function W(e,t,n){return"function"==typeof e?e(t)??n:e??n}function q(e,t){return"function"==typeof e?e(t):e}function D(e){return e.sample??e.value??e.index}function B(e,t){return void 0!==t.datum?W(t.datum,e,null):e.datum??null}function Y(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?W(t.rangeColor,e,Ea):W(t.color,e,Na):W(t.inactiveColor,e,Fa),stroke:"none",...q(t.style,e)??{}}}function G(e,t){const n=q(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:B(e,t),accessibleDatum:q(t.accessibleDatum,e),accessibility:q(t.accessibility,e),pointId:n,_transitionKey:n}}function V({input:e,encoding:t,options:n={}}){if(!R(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=R(e)?{...e,encoding:S(e.encoding)}:j(e,t),r=function(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return function(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,a=Math.max(1,Math.floor(t.rows??1)),s=e.map(D),c=Math.min(...s),l=Math.max(...s)-c||1;return e.map((s,u)=>{const d=D(s),h=u%a,f=t.valueToX?t.valueToX(d,s):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,s):o+h*(r+i);return{...s,x:f,y:m,row:h,column:u}})}(n,t);if("dotplot"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,a=t.cellWidth??r+i,s=t.cellHeight??r+i,c=e.map(D),l=Math.min(...c),u=Math.max(...c)-l||1,d=new Map;return e.map(r=>{const i=D(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*a),h=Math.round((c-n)/Math.max(1,a)),f=d.get(h)??0;d.set(h,f+1);const m=t.valueToY?t.valueToY(i,r):o+f*s;return{...r,x:n+h*a,y:m,row:f,column:h}})}(n,t);if("bar-segment"===o){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const a=Number.isFinite(e.start)?e.start:D(e),s=(a+(Number.isFinite(e.end)?e.end:a+e.value))/2,c=t.valueToY?t.valueToY(s,e):n+r[1]*o;return{...e,x:t.valueToX(s,e),y:c,row:0,column:i}})}(n,t)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,a=t.cellHeight??r??i,s="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:function(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}(n,t,i);return N(n,{...t,columns:s,cellWidth:i,cellHeight:a})}(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>function(e,t,n){if("dot"===n.tokenType)return function(e,t){const n=W(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:W(t.radius,e,n/2),style:Y(e,t),...G(e,t)}}(e,t);const o=q(t.glyph,e)??function(e){if(e)return ja[e]}(n.icon);if(o)return function(e,t,n){const o=Y(e,n),r=W(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:(o.fill??Na)+"",accent:W(n.accent,e,za),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:W(n.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?q(n.ghostColor,e)??Fa:void 0,rotation:q(n.rotation,e),style:o,...G(e,n)}}(e,o,t);const r=(i=n.icon)&&La.has(i)?i:void 0;var i;return function(e,t){const n=W(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:W(t.symbolType,e,"circle"),path:q(t.symbolPath,e),rotation:q(t.rotation,e),style:Y(e,t),...G(e,t)}}(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}(e,n,o.encoding))}}function H(e){return`${e.getUTCFullYear()}-${_(e.getUTCMonth()+1)}-${_(e.getUTCDate())}`}function _(e){return 10>e?"0"+e:e+""}function X(){const e=(sa??(sa=Ra.createContext(null)),sa);return Ra.useContext(e)??Wa}function U(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function K(e,t){const n=U(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Q(e,t){if(Va.has(t))return K(e,t)}function Z(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function J(e,t,n){return[111.32*(e-n.lon)*Math.cos((t+n.lat)/2*(Math.PI/180)),110.574*(t-n.lat)]}function ee(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function te(e){return Va.has(e)?e:"monument"}function ne(e,t){const n=ee(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),a=Z(t.idAccessor,"id"),s=Z(t.nameAccessor,"name"),c=Z(t.longitudeAccessor,"lon"),l=Z(t.latitudeAccessor,"lat"),u=Z(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?Z(t.candidatePriorityAccessor,"priority"):()=>0,h=new Map;let f=null;for(const m of e){const e=Number(c(m)),p=Number(l(m));if(!Number.isFinite(e)||!Number.isFinite(p))continue;const g=(a(m)??`${e},${p}`)+"",y=(s(m)??g)+"",x=te(u(m)),[b,w]=J(e,p,t.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,A={...m,id:g,name:y,kind:x,lon:e,lat:p,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(m))||0};(null!=t.centerId&&g===t.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=A);const S=`${v}:${M}`,I=h.get(S)??[];I.push(A),h.set(S,I)}const m=new Map;f&&m.set("city",1);const p=[];for(let e=0;n>e;e++)for(let t=0;n>t;t++){const n=`tile-${e}-${t}`,a=(t+.5)*r-o,s=o-(e+.5)*r;let c,l;if(e===i&&t===i&&f){c=f;const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id).sort((e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||e.name.localeCompare(t.name));l=[f,...n]}else{const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{const n=e.candidatePriority-t.candidatePriority;if(0!==n)return n;const o=m.get(e.kind)??0,i=m.get(t.kind)??0,a=r*r*.35;return e.cellDistanceSq+o*a-(t.cellDistanceSq+i*a)||e.name.localeCompare(t.name)}),c=n[0]??null,l=n}c&&m.set(c.kind,(m.get(c.kind)??0)+1),p.push({id:n,row:e,column:t,centerXKm:a,centerYKm:s,terrainIndex:Math.abs((17*e+31*t)%Ba.length),landmark:c,landmarks:l})}return p}function oe({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:a}){const s=X(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);return(0,qa.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const a=e.landmark,c="city"===a.kind?i:r,l=e.y+n/2,u=s.isActive&&!s.predicate(a)?.28:1;return(0,qa.jsxs)("g",{opacity:u,children:[(0,qa.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),(0,qa.jsx)(ie,{kind:a.kind,href:Q(o,a.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&(0,qa.jsx)(re,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},a.id)}),a&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);return(0,qa.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[(0,qa.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),(0,qa.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},e.landmark.id+"-label")})]})}function re({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,a=Math.max(r,i.length*r*.58);return(0,qa.jsxs)("g",{transform:`translate(${e},${t})`,children:[(0,qa.jsx)("rect",{x:-a/2,y:-r/2,width:a,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),(0,qa.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function ie({kind:e,href:t,x:n,y:o,size:r}){if(t)return(0,qa.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=Ua[e];return(0,qa.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:Xa[e].flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:(0,qa.jsx)("rect",{x:n,y:t,width:1,height:1,fill:i[e]},`${t}-${n}`)))})}function ae(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function se(e,t,n){return Math.max(t,Math.min(n,e))}function ce(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(t>o&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function le(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function ue(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=se(Number.isFinite(t.occupancy)?Number(t.occupancy):Qa,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):Za;let i=ae(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),a=ae(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));n.length>i*a&&(null!=t.columns&&null==t.rows?a=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/a):a=Math.ceil(n.length/i));const s=ce(n.map(e=>e.x)),c=ce(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:le(e.x,s)*Math.max(0,i-1),desiredRow:le(e.y,c)*Math.max(0,a-1)})),u=(i-1)/2,d=(a-1)/2;l.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-d)**2-((e.desiredColumn-u)**2+(e.desiredRow-d)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const h=new Set;for(let e=0;a>e;e+=1)for(let t=0;i>t;t+=1)h.add(e*i+t);const f=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=(o%i-e.desiredColumn)**2+(Math.floor(o/i)-e.desiredRow)**2;(n>r||r===n&&t>o)&&(t=o,n=r)}0>t||(h.delete(t),f.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return f.sort((e,t)=>e.index-t.index),f.map(({index:e,...t})=>t)}function de(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function he(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function fe({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=X();return(0,Ka.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const a=!i.isActive||i.predicate(e.datum);return(0,Ka.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:a?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function me(){throw Error("geographicDotGrid requires the geo recipe bundle")}function pe(e,t,n){return Math.max(t,Math.min(n,e))}function ge(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function ye(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function xe(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function be(e,t){const n=xe(e);return(e.id??n.id??n.name??"feature-"+t)+""}function we(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function Me(e){if(!e)return 0;const t=is.get(e);if(t)return t;const n=as;return as+=1,is.set(e,n),n}function ve(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(n=e[0],o=t[0][0],r=t[1][0],o>r?o>n&&n>r:o>n||n>r));var n,o,r}function ke(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&ve(t,n.bounds))try{if(me())return{feature:e,index:o}}catch{}}return null}function $e(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=function(e,t){if(0===e.length)return null;const n=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(n[0][0])&&Number.isFinite(n[0][1])&&Number.isFinite(n[1][0])&&Number.isFinite(n[1][1])?n:null}(r,t.geoPath);if(!i)return{dots:[],cellSize:ts,features:r};const a=Math.max(0,o.layoutPadding??0),s=[[pe(i[0][0],a,Math.max(a,n.width-a)),pe(i[0][1],a,Math.max(a,n.height-a))],[pe(i[1][0],a,Math.max(a,n.width-a)),pe(i[1][1],a,Math.max(a,n.height-a))]],c=Math.max(0,s[1][0]-s[0][0]),l=Math.max(0,s[1][1]-s[0][1]);if(0===c||0===l)return{dots:[],cellSize:ts,features:r};const u=ge(o.columns);let d=Math.max(2,u?c/u:ge(o.cellSize)??ts);const h=Math.max(100,Math.round(ge(o.maxSamples)??ns)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const m=o.gridOrigin?.[0]??0,p=o.gridOrigin?.[1]??0,[g,y]=we(s[0][0],s[1][0],m,d),[x,b]=we(s[0][1],s[1][1],p,d),w=[],M=function(e){return e.map((e,t)=>{if(rs.has(e))return{feature:e,index:t,bounds:rs.get(e)??null};try{const n=function(){throw Error("geographicDotGrid requires the geo recipe bundle")}();return rs.set(e,n),{feature:e,index:t,bounds:n}}catch{return rs.set(e,null),{feature:e,index:t,bounds:null}}})}(r);for(let e=x;b>=e;e+=1){const n=p+(e+.5)*d;for(let r=g;y>=r;r+=1){const i=t.invertedPoint(m+(r+.5)*d,n);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;const a=ke(M,i);if(!a)continue;const s={...xe(a.feature),featureId:be(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:r,longitude:i[0],latitude:i[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(s,w.length)||w.push(s)}}return{dots:w,cellSize:d,features:r}}function Ae(e){return Math.round(1e4*e)/1e4}function Se(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${Ae(Number(e[0]))},${Ae(Number(e[1]))}`:"null"}function Ie(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function Ce(e){return"number"==typeof e&&Number.isFinite(e)?Ae(e)+"":null===e?"null":"unavailable"}function je(e){const t=e.scales.projection;return[Ce(Ie(t,"scale")),Se(Ie(t,"translate")),Se(Ie(t,"center")),(n=Ie(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>Ae(Number(e))).join(","):"unavailable"),Ce(Ie(t,"clipAngle")),Ce(Ie(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>Se(e.scales.projectedPoint(t,n)))].join("|");var n}function Ne(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function Fe(e,t){const n="function"==typeof t?t(e):e[t];return ds(n)?n:void 0}function Ee(e){return[...e].sort((e,t)=>e.localeCompare(t))}function ze(e,t,n){const o=new Map([[e,0]]),r=[e];for(;r.length>0;){const e=r.shift(),i=o.get(e);for(const a of Ee(n.get(e)??[]))t.has(a)&&!o.has(a)&&(o.set(a,i+1),r.push(a))}return o}function Le(e,t,n){return[...ze(e,t,n).entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))[0][0]}function Oe(e,t,n){const o=new Set(e),r=e.filter(e=>1>=(t.get(e)?.size??0))[0]??e[0],i=ze(n&&o.has(n)?n:Le(Le(r,o,t),o,t),o,t),a=Math.max(0,...i.values()),s=Array.from({length:a+1},()=>[]);for(const t of e)s[i.get(t)??0].push(t);s.forEach(e=>e.sort((e,t)=>e.localeCompare(t)));const c=(e,n)=>{const o=new Map(s[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?1/0:n.reduce((e,t)=>e+t,0)/n.length};s[e].sort((e,t)=>r(e)-r(t)||e.localeCompare(t))};for(let e=0;4>e;e+=1){for(let e=1;s.length>e;e+=1)c(e,e-1);for(let e=s.length-2;e>=0;e-=1)c(e,e+1)}return s}function Te(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),a=o.xAccessor??"x",s=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:Fe(e.data,a),authoredY:Fe(e.data,s)})),l=c.length>0&&c.every(e=>ds(e.authoredX)&&ds(e.authoredY)),u="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,d=[];if(u&&!l&&d.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!u||!l){l||"automatic"===o.layoutMode||d.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const a=function(e,t,n,o,r,i){const a=function(e,t){const n=new Map(e.map(e=>[e,new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}(e.map(e=>e.id),t),s=function(e){const t=new Set(e.keys()),n=[];for(;t.size>0;){const o=Ee(t)[0],r=[o],i=[];for(t.delete(o);r.length>0;){const n=r.shift();i.push(n);for(const o of Ee(e.get(n)??[]))t.has(o)&&(t.delete(o),r.push(o))}n.push(i.sort((e,t)=>e.localeCompare(t)))}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}(a),c=new Map(e.map(e=>[e.id,e.data])),l=new Map,u=Math.max(0,n.width),d=Math.max(0,n.height),h=Math.min(o,u/2),f=Math.min(o,d/2),m=Math.max(0,d-2*f),p=s.length>1?Math.min(r,m/s.length):0,g=Math.max(0,m-p*Math.max(0,s.length-1)),y=s.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=f;for(const e of s){const t=g*(Math.sqrt(e.length)/y),n=Oe(e,a,i),o=Math.max(0,u-2*h);n.forEach((e,r)=>{const i=1===n.length?u/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{l.set(n,{id:n,x:i,y:1===e.length?x+t/2:x+o/(e.length-1)*t,data:c.get(n)})})}),x+=t+p}return l}(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of a.values())e.x=n.width-e.x;return{positions:a,mode:"automatic",warnings:d,projectAuthoredPoint:e=>e}}const h=c.map(e=>e.authoredX),f=c.map(e=>e.authoredY),m=Math.min(...h),p=Math.max(...h),g=Math.min(...f),y=Math.max(...f),x=Math.max(1,n.width-2*r),b=Math.max(1,n.height-2*r),w=e=>({x:p===m?n.width/2:r+(e.x-m)/(p-m)*x,y:y===g?n.height/2:r+(e.y-g)/(y-g)*b}),M=new Map;for(const e of c){const t=w({x:e.authoredX,y:e.authoredY});M.set(e.id,{id:e.id,...t,data:e.data})}return{positions:M,mode:"authored",warnings:d,projectAuthoredPoint:w}}function Pe(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(.001>r||.001>i||.001>Math.abs(r-i))return[e,t];const a=Math.sign(n),s=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+a*n,y:e.y},{x:t.x-a*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+s*c},{x:t.x,y:t.y-s*c},t]}function Re(e,t){if(0===t||2>e.length)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,a=e.length-1>r?n(o,e[r+1]):null;if(!i||!a){const e=a??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let s=i.x+a.x,c=i.y+a.y;const l=Math.hypot(s,c);if(.001>l)return{x:o.x+a.x*t,y:o.y+a.y*t};s/=l,c/=l;const u=s*a.x+c*a.y;if(.001>Math.abs(u))return{x:o.x+a.x*t,y:o.y+a.y*t};const d=4*Math.abs(t),h=Math.max(-d,Math.min(d,t/u));return{x:o.x+s*h,y:o.y+c*h}})}function We(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){const r=e[t-1],i=e[t],a=e[t+1],s=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(a.x-i.x,a.y-i.y),l=Math.min(n,s/2,c/2);if(.001>=l){o+=` L${i.x},${i.y}`;continue}const u={x:i.x+(r.x-i.x)/s*l,y:i.y+(r.y-i.y)/s*l},d={x:i.x+(a.x-i.x)/c*l,y:i.y+(a.y-i.y)/c*l};o+=` L${u.x},${u.y} Q${i.x},${i.y} ${d.x},${d.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function qe(e){return n(e)??e}function De(e){return"string"==typeof e?e:e.id}function Be(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,function(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:e.id+""}:{id:e+""});return t.length>0?t:[{id:"network"}]}(o)}function Ye(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function Ge(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,a="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof a?a:o(e.id)}function Ve(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??1/0)-(n.get(t)??1/0)||e.localeCompare(t))}function He(e,t){const n=new Map((e.authoredOrder??t.lineOrder??[]).map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(n.get(e.descriptor.id)??1/0)-(n.get(t.descriptor.id)??1/0)||e.descriptor.id.localeCompare(t.descriptor.id))}function _e(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>"number"==typeof e.x&&"number"==typeof e.y?t.projectAuthoredPoint({x:e.x,y:e.y}):null).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function Xe(e,t){return r(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function Ue(e,n,o,r,i,a){if(!1===a.showLabels)return[];const s=a.labelFontSize??11,c=[],l=[],u=[...e].sort((e,t)=>(o.get(t.id)?.size??0)-(o.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(const e of u){const o=n.get(e.id);if(!o)continue;const u=("function"==typeof a.labelAccessor?a.labelAccessor(e.data):t(e.data,a.labelAccessor??"label",e.id)+"")||e.id,d=Math.max(2*s,u.length*s*.58),h=1.25*s,f=Math.max(a.interchangeRadius??7,r.get(e.id)??a.stationRadius??4)+5,m=[{x:o.x+f,y:o.y,anchor:"start",left:o.x+f},{x:o.x-f,y:o.y,anchor:"end",left:o.x-f-d},{x:o.x,y:o.y-f,anchor:"middle",left:o.x-d/2},{x:o.x,y:o.y+f,anchor:"middle",left:o.x-d/2}].map((e,t)=>{const n={left:e.left,right:e.left+d,top:e.y-h/2,bottom:e.y+h/2},o=c.filter(e=>{return(o=e).right>(t=n).left&&t.right>o.left&&o.bottom>t.top&&t.bottom>o.top;var t,o}).length;return{candidate:e,box:n,score:1e4*o+10*(Math.max(0,-n.left)+Math.max(0,n.right-i.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-i.height))+t}}).sort((e,t)=>e.score-t.score)[0];c.push(m.box),l.push({x:m.candidate.x,y:m.candidate.y,text:u,anchor:m.candidate.anchor,baseline:"middle",fontSize:s,fill:a.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return l}function Ke(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function Qe(e){return(1e-12>Math.abs(e)?0:e)+""}function Ze(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}function Je(e,t){return Number.isFinite(e)?h(e,0,1):t}function et(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}function tt(e,t,n,o,r,i,a,s){const c=t-o/2,l=n-r/2,u={fill:i,stroke:a,strokeWidth:s};switch(e){case"diamond":return(0,xs.jsx)("polygon",{points:`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`,...u});case"circle":return(0,xs.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return(0,xs.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16);return(0,xs.jsx)("polygon",{points:`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;return(0,xs.jsxs)("g",{children:[(0,xs.jsx)("path",{d:`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,...u}),(0,xs.jsx)("path",{d:t,fill:"none",stroke:a,strokeWidth:s})]})}case"subroutine":{const e=Math.min(8,.08*o);return(0,xs.jsxs)("g",{children:[(0,xs.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),(0,xs.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:a,strokeWidth:s}),(0,xs.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:a,strokeWidth:s})]})}default:return(0,xs.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}function nt(e){return(0,Ms.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function ot(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;n>t.x-e&&(n=t.x-e),t.x+e>r&&(r=t.x+e),o>t.y-e&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function rt(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);r>t.x&&(r=t.x),i>t.y&&(i=t.y),t.x+e>a&&(a=t.x+e),t.y+n>s&&(s=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:a-r+2*n,height:s-i+2*o}:null}function it(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:(0,Ms.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 at(e){const t=e.spacing??8;return{def:(0,Ms.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:(0,Ms.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:e.color??"currentColor",strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function st(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,a=e.labelGap??4,s=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>e+""),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,m)=>{const p=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*a;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===m?"start":e.edgeAnchor&&m===h?"end":"middle":"left"===t?"end":"start";const w=n?"top"===t?"auto":"hanging":"middle",M=n?{x:p,y:x}:{x:x,y:p};return(0,Ms.jsxs)("g",{children:[(r>0||i>0)&&(0,Ms.jsx)("line",{...n?{x1:p,x2:p,y1:g,y2:y}:{x1:g,x2:y,y1:p,y2:p},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),(0,Ms.jsx)("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:s,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${m}`)});return(0,Ms.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function ct(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,a=Math.hypot(r,i)||1,s=e.markX+r/a*o,c=e.markY+i/a*o;let l;return l="elbow"===e.connector?`M${s},${c} L${s},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${s},${c} Q${(s+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${s},${c} L${e.labelX},${e.labelY}`,(0,Ms.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&(0,Ms.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),(0,Ms.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),(0,Ms.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function lt(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{outAdj:a,inAdj:s,undirected:c}=pt(r,t),l=gt(r,a,s,c,o).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:mt(e)})),u=new Map;for(const e of l){const t=u.get(e.motif);t?t.count+=1:u.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:l,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:l.filter(e=>e.directed).length,branchingCount:l.filter(e=>!e.directed).length}}function ut(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function dt(e){return"string"==typeof e?e:e?.id}function ht(e,t,n,o,r){const i=new Set(e);let a=new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);a.set(o,`${e}:${r}`)}for(let o=0;r>o;o+=1){const o=new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(a.get(n));const s=[];for(const e of n.get(r)??[])i.has(e)&&s.push(a.get(e));e.sort(),s.sort(),o.set(r,ut(`${a.get(r)}>${e.join(",")}<${s.join(",")}`))}a=o}const s=e.map(e=>a.get(e)).sort();return ut(`${e.length}#${o}#${s.join(";")}`)}function ft(e,t,n,o,r,i,a){function s(e){let t=0,n=0;for(const o of r.get(e)??[]){const e=g.get(o);y.has(o)&&e&&(t+=e.x,n+=1)}return n>0?t/n:i.x+m/2}const{layer:c,layerCount:l}=function(e,t){const n=new Set(e),o=new Map,r=new Set,i=e=>{const a=o.get(e);if(void 0!==a)return a;if(r.has(e))return 0;r.add(e);let s=0;for(const o of t.get(e)??[])n.has(o)&&(s=Math.max(s,1+i(o)));return r.delete(e),o.set(e,s),s};let a=0;for(const t of e)a=Math.max(a,i(t));const s=new Map;for(const t of e)s.set(t,a-o.get(t));return{layer:s,layerCount:a+1}}(e.ids,o),d=Array.from({length:l},()=>[]);for(const t of e.ids)d[c.get(t)].push(t);const f=.14*Math.min(i.width,i.height),m=Math.max(1,i.width-2*f),p=Math.max(1,i.height-2*f),g=new Map,y=new Set(e.ids);for(let e=0;l>e;e+=1){let t=d[e];e>0&&(t=[...t].sort((e,t)=>s(e)-s(t)));const n=t.length,o=i.y+f+(1===l?.5:e/(l-1))*p;t.forEach((e,t)=>{g.set(e,{x:i.x+f+(1===n?.5:t/(n-1))*m,y:o})})}const x=d.reduce((e,t)=>Math.max(e,t.length),1),b=h(Math.min(a,m/(2.4*x),p/(2.4*l)),1.4,a),w=e.ids.map(e=>{const o=g.get(e);return{id:e,cx:o.x,cy:o.y,r:b,datum:t.get(e)??u({id:e}),category:n.get(e)??""}}),M=[];for(const t of e.ids){const e=g.get(t);for(const n of o.get(t)??[]){if(!y.has(n))continue;const t=g.get(n);M.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:w,edges:M}}function mt(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?"chain of "+t:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+o}function pt(e,t){const n=new Set(e),o=new Map,r=new Map,i=new Map;for(const t of e)o.set(t,new Set),r.set(t,new Set),i.set(t,new Set);for(const e of t){const t=e.source,a=e.target;n.has(t)&&n.has(a)&&t!==a&&(o.get(t).has(a)||(o.get(t).add(a),r.get(a).add(t),i.get(t).add(a),i.get(a).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function gt(e,t,n,o,r){const i=new Set,a=[];for(const s of e){if(i.has(s))continue;const e=[s];i.add(s);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}const l=new Set(c);let u=0,d=0,h=0;for(const e of c){let o=0,r=0;for(const n of t.get(e)??[])l.has(n)&&(o+=1);for(const t of n.get(e)??[])l.has(t)&&(r+=1);h+=o,0===o&&(u+=1),0===r&&(d+=1)}a.push({ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:ht(c,t,n,h,r)})}return a}function yt(e,t,n){return e?ft(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,n,3):null}function xt(e){return n(e)??e}function bt(e){return"string"==typeof e?e:e.id}function wt(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function Mt(e){return Math.round(100*e)/100+""}function vt(e,t){if(2>e.length)return"";let n=`M${Mt(e[0][0])},${Mt(e[0][1])}`;for(let o=1;e.length-1>o;o+=1){const r=e[o-1],i=e[o],a=e[o+1],s=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(a[0]-i[0],a[1]-i[1]),l=Math.min(t,s/2,c/2);if(0>=l){n+=`L${Mt(i[0])},${Mt(i[1])}`;continue}const u=[(i[0]-r[0])/s,(i[1]-r[1])/s],d=[(a[0]-i[0])/c,(a[1]-i[1])/c],h=[i[0]-u[0]*l,i[1]-u[1]*l],f=[i[0]+d[0]*l,i[1]+d[1]*l];n+=`L${Mt(h[0])},${Mt(h[1])}Q${Mt(i[0])},${Mt(i[1])} ${Mt(f[0])},${Mt(f[1])}`}const o=e[e.length-1];return`${n}L${Mt(o[0])},${Mt(o[1])}`}function kt(e,t,n,o,r=.92*o){const i=Math.cos(n),a=Math.sin(n),s=-a,c=[e+i*o*.56,t+a*o*.56],l=e-i*o*.44,u=t-a*o*.44,d=[l+s*r*.5,u+i*r*.5],h=[l-s*r*.5,u-i*r*.5];return`M${Mt(c[0])},${Mt(c[1])}L${Mt(d[0])},${Mt(d[1])}L${Mt(h[0])},${Mt(h[1])}Z`}function $t(e,t){return`${t}\0${e}`}function At(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function St(e,t,n){if(1>=e)return 0;const o=Math.max(0,n.flowGap??.75),r=At(t,n);return Math.min(o,Math.max(0,(r-Math.min(.1,r))/(e-1)))}function It(e,n,o){const r="function"==typeof n?n(e):t(e,n,o);return null==r||""===r?o:r+""}function Ct(e,n){const o="function"==typeof n?n(e):t(e,n,void 0);if(null!=o){if("object"==typeof o){const e=o.id;return null==e?void 0:e+""}return o+""}}function jt(e,n){const o="function"==typeof n?n(e):t(e,n,1);return Number(o)}function Nt(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function Ft(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",a=n.sourceAccessor??"source",s=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),u=n.includeInternalFlows??!0,d=[],h=new Map,f=new Map;for(const t of e){const e=It(t,o,d.length+"");if(h.has(e))continue;const n=It(t,i,e),a=It(t,r,e),s={id:e,label:n,group:a,datum:t};d.push(s),h.set(e,s);const c=f.get(a);c?c.push(s):f.set(a,[s])}const m=new Set(d.map(e=>e.id)),p=[],g=new Map,y=new Map,x=[];for(const[e,t]of f){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=Nt(`${n.groupIdPrefix??"group:"}${e}`,m),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};p.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};p.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=new Map;let M=0;for(const e of t){const t=Ct(e,a),n=Ct(e,s),o=jt(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!(r&&i&&Number.isFinite(o)&&o>0)){M+=1;continue}const l=h.get(t)?.group,u=h.get(n)?.group;if(l&&u&&l===u){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(u){const e=b.get(u);e&&(e.incomingValue+=o)}}let d=w.get(r);d||(d=new Map,w.set(r,d));const f=d.get(i);f?(f.value+=o,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:p,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function Et(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=e+"",n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function zt(e,t,n){return t>e?t:e>n?n:e}function Lt(e){let t=2166136261;const n=e=>{for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(const o of e)n(o.id),n(o.col),n(o.row),t^=Math.round(8*o.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Ot(e,t,n){const o=new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function Tt(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function Pt(e,t){return function(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}(Tt(e,t),e.bottomRadius,t)}function Rt(e,t){const n=(e.topRadius+e.bottomRadius)/2,o=Math.PI*n*n;let r=t/o,i=t-Pt(e,r),a=0;for(;100>a&&Math.abs(i)>1e-4;)r+=i/o,i=t-Pt(e,r),a++;return r}function Wt(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function qt(e,t){if(t>e||2*t>e)return[{x:0,y:0}];const n=[],o=e=>{let r=Math.floor(2*Math.PI*e/(2*t));1>r&&(r=1);const i=0*e,a=Math.hypot(1*e-e*Math.cos(2*Math.PI/r),i-e*Math.sin(2*Math.PI/r));2*t>a&&r>1&&r--;for(let t=0;r>t;t++)n.push({x:e*Math.cos(2*t*Math.PI/r),y:e*Math.sin(2*t*Math.PI/r)});const s=e-2*t;t>s?e>2*t&&n.push({x:0,y:0}):o(s)};return o(e-t),n}function Dt(e,t,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=t*(1+2*i),a=qt(Tt(e,n),t),s=a.length-r,c=s>1?a.slice(Math.floor(s/2),Math.floor(s/2)+r):a,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Wt(97*i+t,.15),z:l+Wt(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function Bt(e,t,n,o){if(0>=o)return[];const r=function(e,t,n){let o=n,r=0;for(;o>0&&60>r;){const n=Tt(e,t+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/Ws)),r++}return r}(e,t,o),i=Math.max(t,n-r*Ws)+.875,a=[];let s=0;for(let t=0;r>t&&o>s;t++){const n=i+Ws*t,r=Tt(e,n),c=Math.max(1,Math.floor(2*r/Ws)),l=(2*r-c*Ws)/(c+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;c>e&&o>s;e++)a.push({cx:u+(l+Ws)*e+.875,cy:d+.875,rotation:Wt(53*t+e,10)}),s++}return a}function Yt(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Gt(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Vt(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Ht(e){return null==e?null:e+""}function _t(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Xt(e){return!!e&&"object"==typeof e&&Bs.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Ut(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function Kt(e){return"primary"===e?.emphasis||!0===e?.defensive}function Qt(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:Ys))):1/0}function Zt(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),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 Jt(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??Gs),i=Qt(n,o,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Xt(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const c=s.filter(e=>Kt(e.annotation)),l=s.filter(e=>!Kt(e.annotation)).sort((e,t)=>Zt(t.annotation)-Zt(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}function en(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(tc,t.source)?tc[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function tn(e){if(!nn(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 nn(e){return Xt(e)}function on(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function rn(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function an(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 sn(e,t,n,o,r,i,a,s){const c=rn(e,a);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,s);for(const e of n)l+=12*an(c,e);for(const e of o)l+=4*an(c,e);return l}function cn(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?function(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return _t(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:o(i),y:r(a)}}(n);return o?_t(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return Ht(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>Ht(e.pointId)===o);if(r)return _t(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return Ht(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const a=Gt(i,n),s=Vt(i,n);return null==a||null==s?null:_t(t,n,{x:a,y:s})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=Gt(e,n),i=Vt(e,n)),null!=r&&null!=i)return _t(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function ln(e){const{annotations:t,context:n,defaultOffset:o=Vs,notePadding:r=Hs,markPadding:i=_s,edgePadding:a=Xs,preserveManualOffsets:s=!0,routeLongConnectors:c=!0,connectorThreshold:l=Us,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:m,cohesion:p,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof m?m:{},w=b.breakpoint??Js,M=!!m&&w>=y,v=M&&!1!==b.preferShortText?t.map(tn):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),A=M&&!f?b.responsive??{minWidth:w}:f,S=M&&!p?b.cohesion:p;if(0===v.length||0>=y||0>=x)return v.slice();const I=[],C=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let j=!1;const N=v.map((e,t)=>{if(!nn(e))return e;const i=cn(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...Ut("string"==typeof e.title?e.title:void 0,o,7),...Ut("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}(!0===e.defensive?en(e):e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:Ks,dy:Qs}}(e);return I.push(rn(on(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(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}]}(o)){const t=sn(on(i.x,i.y,e.dx,e.dy,u),e,I,C,y,x,r,a);f>t&&(h=e,f=t)}if(!h)return e;const m=rn(on(i.x,i.y,h.dx,h.dy,u),r);I.push(m);const p=Math.hypot(h.dx,h.dy),g=c&&p>=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}:{}}}),F=j?N:v.slice();let E=F;if(h){let e=!1;const t=F.map(t=>{const n=function(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)<Zs?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});E=e?t:F}{let e=!1;const t=E.map(t=>{if(!0!==t?.defensive)return t;const n=en(t);return n!==t&&(e=!0),n});E=e?t:E}const z=new Set;if(k){const e="object"==typeof k?k:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return ec;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?ec:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Qt(y,x,e))*t))},{deferred:o}=Jt({annotations:E,width:y,height:x,...n});for(const e of o)z.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:Js)>=y)for(const e of E)nn(e)&&"secondary"===e.emphasis&&z.add(e);if(z.size>0)for(const e of E)!0===e?.defensive&&z.delete(e);let L;return L=0===z.size?E:$?E.map(e=>z.has(e)?{...e,_annotationDeferred:!0}:e):E.filter(e=>!z.has(e)),S?function(e,t){let n=!1;const o=e.map(e=>nn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(L,S):L}function un(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function dn(e,t={}){const n=t.fuels??nc,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=un(t.fuels?.[e]);(o||n>0)&&r.push({t:t.t,fuel:e,fuelLabel:oc[e],mw:n,ba:t.ba})}return r}function hn(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=un(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function fn(e){const t=un(e.demand);if(0>=t)return 0;const n=un(e.capacityOrNetGen),o=un(e.interchange);return(n+(0>o?-o:0)-t)/t*100}function mn(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=un(e.demandMw),n=un(e.netGenMw),o=fn({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t,demandMw:t,netGenMw:n}})}function pn(e={},t={}){const{watch:n,comfortable:o}={...rc,...e},r=t.field,i=r?{field:r}:{},a=t.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:a,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function gn(e={}){const{tight:t,watch:n,comfortable:o}={...rc,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function yn(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>t>=e.t);o=e.length?e[e.length-1]:n[0]}const r=un(o.demandMw),i=un(o.netGenMw),a="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,s=fn({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of nc){const t=un(o.fuels?.[e]);t>0&&(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:a,forecastErrorMw:null==a?null:r-a,netGenMw:i,reserveMarginPct:s,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function xn(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const t=(e.start+e.end)/2,i=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:t,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:e.id,dataVersion:e.start+""},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function bn(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function wn(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function Mn(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function vn(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function kn(e,t={}){const n=vn(t.start,"start"),o=vn(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new ac;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function $n(e,t){const n=vn(t.start,"start"),o=vn(t.end,"end"),[r,i]=t.domain,a=t.step??1,s="half-open"===t.bounds;if(r>i)return[];const c=(i-r)/a>Math.log2(e.length+1),l=[],u=[];if(c){for(const t of e){const e=n(t),r=o(t);e>r||(l.push(e),u.push(r))}l.sort((e,t)=>e-t),u.sort((e,t)=>e-t)}let d=0,h=0;const f=[];for(let t=r;i>=t;t+=a){let r=0;if(c){for(;l.length>d&&t>=l[d];)d++;for(;u.length>h&&(s?t>=u[h]:t>u[h]);)h++;r=d-h}else for(const i of e){const e=n(i),a=o(i);e>t||(s?t>=a:t>a)||r++}f.push({value:t,count:r})}return f}function An(e){return"function"==typeof e?e:t=>t[e]}function Sn(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,a=(e,t)=>(e+t)/2;if("vertical"===o){if(i>Math.abs(t.y-e.y)){const n=e.x>t.x?-1:1,o=a(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${a(e.y,t.y)} ${t.x},${t.y}`}const n=a(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){const n=e.y>t.y?-1:1,o=a(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${a(e.x,t.x)},${o} ${t.x},${t.y}`}const s=a(e.x,t.x)+r;return`M${e.x},${e.y} C${s},${e.y} ${s},${t.y} ${t.x},${t.y}`}function In(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function Cn(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function jn(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function Nn(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,a=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+a*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+a*e.p3.y}}function Fn(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function En(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function zn(e,t){const n=t?.axis??"x",o=t?.padding??0,r=t?.strength??.5,i="x"===n?"y":"x",a="x"===n?"width":"height",s="x"===n?"height":"width",c=new Map;for(const t of e)c.set(t.id,0);for(let t=0;e.length>t;t++)for(let l=t+1;e.length>l;l++){const u=e[t],d=e[l];if(Math.abs(u[i]-d[i])>(u[s]+d[s])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[a]+d[a])/2+o-Math.abs(h);if(0>=f)continue;const m=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-m),c.set(d.id,(c.get(d.id)??0)+m)}return c}function Ln(e,n){if("function"==typeof e)return e;const o=e??n;return e=>t(e,o,void 0)}function On(e,t,o,r){const i=r.fixedAxis??"y",a=e=>Ln(r.sourceAccessor,"source")(e)+"",s=e=>Ln(r.targetAccessor,"target")(e)+"",c=r.size??(()=>cc),l=r.iterations??180,u=r.attraction??.012,d=r.anchorStrength??.003,h=r.collisionStrength??.12,f=r.collisionPadding??15,m=r.edgePadding??42,p=r.fixedPadding??16,g=r.damping??.72,y=r.spread??1,[x,b]=r.fixedDomain,w=b-x||1,M=("y"===i?o.y:o.x)+p,v=("y"===i?o.y+o.height:o.x+o.width)-p,k=("y"===i?o.x:o.y)+m,$=("y"===i?o.x+o.width:o.y+o.height)-m,A=Math.max(1,$-k),S=e.map(e=>{const t=n(e)??e,o=(i=e,Ln(r.idAccessor,"id")(i)+"");var i;const{width:a,height:s}=c(t),l=(e=>Number(Ln(r.fixedAccessor,"fixed")(e)))(e),u=k+function(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}(o)*A;return{data:t,id:o,width:a,height:s,fixedValue:l,fixed:(d=l,M+(d-x)/w*(v-M)),free:u,anchor:u};var d}),I=new Map(S.map(e=>[e.id,e])),C=e=>"y"===i?e.width:e.height;for(let e=0;l>e;e++){const e=new Map;for(const t of S)e.set(t.id,0);for(const n of t){const t=I.get(a(n)),o=I.get(s(n));if(!t||!o)continue;const r=(o.free-t.free)*u;e.set(t.id,(e.get(t.id)??0)+r),e.set(o.id,(e.get(o.id)??0)-r)}for(const t of S)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*d);const n=zn(S.map(e=>({id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===i?"x":"y",padding:f,strength:h});for(const t of S)e.set(t.id,(e.get(t.id)??0)+(n.get(t.id)??0));for(const t of S){t.free+=(e.get(t.id)??0)*g;const n=C(t)/2;t.free=Math.max(k+n,Math.min($-n,t.free))}}if(1!==y){const e=(k+$)/2;for(const t of S){const n=C(t)/2;t.free=Math.max(k+n,Math.min($-n,e+(t.free-e)*y))}}const j=S.map(e=>({data:e.data,id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:j,byId:new Map(j.map(e=>[e.id,e]))}}function Tn(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=o>r?-1:1,a=Math.abs(r-o),s=Number(e.currentSegment),c=Number.isFinite(s)?h((s-o)*i,0,a):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?h(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),f=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return f;const n=(t-o)*i;if(n>c)return f;if(0===c)return d;const r=h(n/c,0,1);return u+(d-u)*r}}}function Pn(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function Rn(e){let t=0;for(const n of e)t+=hc[n]??.6;return t}function Wn(e,t){return Math.max(8,Rn(e)*t*1.05+1)}function qn(e,t,n){for(const o of t)if((e.w+o.w)/2+n>Math.abs(e.x-o.x)&&(e.h+o.h)/2+n>Math.abs(e.y-o.y))return!0;return!1}function Dn(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;e.tickCount>o;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));return(0,uc.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[(0,uc.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);return(0,uc.jsxs)("g",{children:[(0,uc.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),(0,uc.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+n)}),e.label&&(0,uc.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function Bn(e){return null==e?void 0:e+""}function Yn(e){const t=Bn(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??pc,style:{...mc,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function Gn(e){return Yn(e)}function Vn(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...mc,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function Hn(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...mc,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:Bn(e.id)}}function _n(e){const t=Bn(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...mc,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??pc,style:{...mc,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function Xn(e){const t={style:{...mc,cursor:e.cursor},datum:e.datum,id:Bn(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?{type:e.type??"curved",pathD:e.pathD,...t}:{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function Un(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:a=!1}=n,s=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null==n||c(n)-c(t)>r?c(t)+r:c(n):t+1,s.push(e)};let u=null;for(let n=0;e.length>n;n++){const s=t(e[n],n);if(a&&!s){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,s)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:s,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),s}function Kn(e,t,n=0){return t>0?((e-n)%t+t)%t+n:e}function Qn(e,t,n){if(0>=n)return t-e;let o=(t-e)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function Zn(e,t,n){return t>n?e>=t||n>=e:e>=t&&n>=e}function Jn(e,t,n,o){return n>o?[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]:e.filter(e=>Zn(t(e),n,o))}function eo(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(r).fill(0);for(let e=1;r>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const a=[];for(let e=0;r>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(a.push({start:e,end:e,weight:n,mean:r});a.length>1;){const e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const s=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=s>c?s:c,u=Array(r);for(const e of a){const t=Math.max(s,Math.min(l,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function to(e,t){let n=0,o=e.length-1,r=-1;for(;o>=n;){const i=n+o>>>1;e[i].at>t?o=i-1:(r=i,n=i+1)}return 0>r?{at:t,before:0,after:0}:e[r]}function no(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;e.length-1>r;r++){const i=e[r],a=e[r+1],s=[...new Set([...i.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of s){const t=to(i,e),n=to(a,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function oo(e,t,n,o={}){let r=[...e];if(1>=r.length)return r;let i=[...r],a=n(r),s=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;c>e&&l>s;e++){const e=new Map(r.map((e,t)=>[e,t])),c=new Map,l=new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(s++,a>u)a=u,i=[...r];else if(u===a)break}return i}function ro(e,t,n={}){const o=[...e];if(1>=o.length)return o;let r=t(o),i=1;const a=Math.max(0,n.passes??6),s=Math.max(1,n.maxEvaluations??1/0);for(let e=0;a>e&&s>i;e++){let e=!1;for(let n=0;o.length-1>n&&s>i;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const a=t(o);i++,r>a?(r=a,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function io(e,t,n={}){const o=[...e],r=o.length;if(1>=r||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let a=0,s=[...o],c=1/0;const l=()=>{if(a>=i)return;const e=t(o);a++,c>e&&(c=e,s=[...o])};l();const u=Array(r).fill(0);let d=0;for(;r>d&&i>a;)if(d>u[d]){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return s}function ao(e,t,n=()=>!0){let o=0;for(let r=0;e.length>r;r++){const[i,a]=t(e[r]);for(let s=r+1;e.length>s;s++){if(!n(e[r],e[s]))continue;const[c,l]=t(e[s]);0>(i-c)*(a-l)&&o++}}return o}function so(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,a=e.length>1?Math.max(0,n-i-(t.paddingRight??r))/(e.length-1):0,s=new Map;return e.forEach((e,t)=>{s.set(e.id,{id:e.id,x:i+a*t,y:o,index:t})}),s}function co(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,a=t.paddingRight??r,s=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>lo(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+s*Math.max(0,e.length-1),h=Math.max(0,n-i-a),f=c&&e.length>1?Math.max(0,h-d)/(e.length-1):0,m=new Map;let p=i;return c||1!==e.length||(p=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];m.set(e.id,{id:e.id,x:p+n/2,y:o,index:t,width:n}),p+=n+s+f}),m}function lo(e,t=38,n=7.4,o=20){return Math.max(t,((e??"")+"").length*n+o)}function uo(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new ac,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function ho(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function fo(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function mo(e,t,n){return e-n.arcLift-t*n.levelStep}function po(e,t=go){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function go(e){return null==e||"object"!=typeof e?e+"":null!=e.id?e.id+"":`${(e.sourceTokenId??e.source)+""}|${(e.targetTokenId??e.target)+""}|${(e.relation??e.label??"")+""}`}function yo(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function xo(e,t,n){return(Math.atan2(e-(n?.center?.x??0),-(t-(n?.center?.y??0)))+yc)%yc}function bo(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,a=t?.endAngle??yc;return e=>i+(e-n)/r*(a-i)}function wo(e,t){const[n,o]=e,[r,i]=t,a=o-n||1;return e=>r+(e-n)/a*(i-r)}function Mo(e,t,n,o,r){const i=r?.center,a=(e,t)=>{const{x:n,y:o}=yo(e,t,{center:i});return`${vo(n)},${vo(o)}`},s=Math.max(0,n),c=Math.max(s,o),l=Math.abs(t-e),u=e>t?0:1;if(l>=yc-1e-6){const e=i?.x??0,t=i?.y??0,n=`${vo(e)},${vo(t-c)}`,o=`${vo(e)},${vo(t+c)}`;let r=`M${n} A${vo(c)},${vo(c)} 0 1 1 ${o} A${vo(c)},${vo(c)} 0 1 1 ${n} Z`;if(s>0){const n=`${vo(e)},${vo(t-s)}`,o=`${vo(e)},${vo(t+s)}`;r+=` M${n} A${vo(s)},${vo(s)} 0 1 0 ${o} A${vo(s)},${vo(s)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=a(e,c),f=a(t,c);if(0>=s){const e=i?.x??0,t=i?.y??0;return`M${vo(e)},${vo(t)} L${h} A${vo(c)},${vo(c)} 0 ${d} ${u} ${f} Z`}const m=a(t,s),p=a(e,s);return`M${h} A${vo(c)},${vo(c)} 0 ${d} ${u} ${f} L${m} A${vo(s)},${vo(s)} 0 ${d} ${1===u?0:1} ${p} Z`}function vo(e){return Math.round(1e3*e)/1e3}function ko(e,t){return{x:e.x+t.x,y:e.y+t.y}}function $o(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ao(e,t){return{x:e.x*t,y:e.y*t}}function So(e){return Math.hypot(e.x,e.y)}function Io(e){const t=So(e)||1;return{x:e.x/t,y:e.y/t}}function Co(e,t){const[n,o]=e.viewBox??xc,[r,i]=e.anchor??bc,a=o>0?o:1,s=Math.max(0,t)/a,c=(n>0?n:a)*s,l=a*s;return{width:c,height:l,scale:s,offsetX:-r*c,offsetY:-i*l}}function jo(e,t){const n=Co(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function No(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??xc,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===o?{x:0,y:i*(1-s),width:r,height:i*(s-a)}:{x:r*a,y:0,width:r*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function Fo(e,t){const n=P(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function Eo(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t}));t.push({type:o,label:e.colorLabel??"",items:r,styleFn:"line"===o?e=>({stroke:e.color??Mc,strokeWidth:2,fill:"none"}):e=>({fill:e.color??Mc,stroke:e.color??Mc})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??Mc,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;return(0,wc.jsx)("path",{d:O(t,Fo(t,vc-1)),transform:`translate(${vc},${vc})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>e+""),r=e.sizeColor??Mc,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>(0,wc.jsx)("circle",{cx:vc,cy:vc,r:e.r,fill:e.color??r})})}return t}function zo(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,a=e.color??"var(--semiotic-text-secondary, #888)",s=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{l.push((0,wc.jsxs)("g",{transform:`translate(${"vertical"===t?0:c},${"vertical"===t?c:0})`,children:[Lo(e,n,e.color??e.line??a,a),(0,wc.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:a,children:e.label})]},"legend-"+u)),c+="vertical"===t?s:n+r+e.label.length*i*.58+o+8}),(0,wc.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function Lo(e,t,n,o){if(e.shape){const o=Fo(e.shape,t/2-1);return(0,wc.jsx)("path",{d:O(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;return(0,wc.jsxs)("g",{children:[(0,wc.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>(0,wc.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),(0,wc.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return(0,wc.jsx)("rect",e.line?{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}:{width:t,height:t,rx:2,fill:n})}function Oo(e){const t=e,n=[Wo(t,["datum","data"]),Wo(t,["datum"]),Wo(t,["data","data"]),Wo(t,["data"]),Wo(t,["node","datum","data"]),Wo(t,["node","datum"]),e];for(const e of n){if(!qo(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function To(e,t={}){const n=Oo(e);if(!n)return[];const o=new Set(kc);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:Ro(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):Po(i)}),r.length>=(t.maxEntries??8)))break;return r}function Po(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?e+"":e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return e.length+" items";if("object"==typeof e)try{return JSON.stringify(e)}catch{return e+""}return e+""}function Ro(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function Wo(e,t){let n=e;for(const e of t){if(!qo(n))return;n=n[e]}return n}function qo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Do(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Bo(e,t){return Do(e,t)?e[t]:void 0}function Yo(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Go(){return Object.create(null)}function Vo(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function Ho(e,t){const n={};for(const t of e)Yo(n,t.id,0);for(const e of t)Yo(n,e.source,(Bo(n,e.source)??0)+1),Yo(n,e.target,(Bo(n,e.target)??0)+1);return n}function _o(e,t){const n={};Yo(n,t,0);const o=[t];let r=0;for(;o.length>r;){const t=o[r];r+=1;for(const r of e.get(t)||[])Do(n,r)||(Yo(n,r,n[t]+1),o.push(r))}return n}function Xo(e,t,n,o){if(n===o)return n?[n]:[];const r=Vo(e,t),i=Go();i[n]=null;const a=[n];let s=0;for(;a.length>s;){const e=a[s];if(s+=1,e===o)break;for(const t of r.get(e)||[])Do(i,t)||(i[t]=e,a.push(t))}if(!Do(i,o))return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function Uo(e,t,n,o=1){const r=Vo(e,t);if(!r.has(n))return new Set;const i=_o(r,n),a=new Set;for(const e of Object.keys(i))i[e]>o||a.add(e);return a}function Ko(e,t){const n=Vo(e,t),o={};for(const t of e)Yo(o,t.id,0);for(const t of e.map(e=>e.id)){const r=[],i=Go(),a=Go(),s=Go();for(const t of e)i[t.id]=[],a[t.id]=0,s[t.id]=-1;a[t]=1,s[t]=0;const c=[t];let l=0;for(;c.length>l;){const e=c[l];l+=1,r.push(e);for(const t of n.get(e)||[])0>s[t]&&(s[t]=s[e]+1,c.push(t)),s[t]===s[e]+1&&(a[t]+=a[e],i[t].push(e))}const u=Go();for(const t of e)u[t.id]=0;for(;r.length;){const e=r.pop();for(const t of i[e])u[t]+=a[t]/a[e]*(1+u[e]);e!==t&&Yo(o,e,(Bo(o,e)??0)+u[e])}}for(const e of Object.keys(o))Yo(o,e,o[e]/2);return o}function Qo(e,t){const n=Vo(e,t),o={};for(const t of e){const e=_o(n,t.id);let r=0,i=0;for(const t of Object.keys(e))r+=e[t],i+=1;Yo(o,t.id,r>0?(i-1)/r:0)}return o}function Zo(e,t){const n=Vo(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(2>r){Yo(o,t.id,0);continue}let i=0;for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);Yo(o,t.id,2*i/(r*(r-1)))}return o}function Jo(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const o of Object.keys(e))Yo(n,o,t>0?e[o]/t:0);return n}function er(e,t,n,o={}){const r=Vo(e,t),i=Go();for(const t of e)i[t.id]=_o(r,t.id);let a=o.minHops??4,s=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1){const r=e[t].id,c=e[o].id,u=Bo(n,r),d=Bo(n,c);if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=a&&s>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(s+=.02,s>c&&(s=o.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:l,threshold:s,minHops:a}}function tr(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function nr(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function or(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}async function rr(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:a,...s}=n,c=s.iterations??260,l=or()&&function(e,t,n,o,r=Ac){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(o,e.length,t.length,c,i);if(!l)return k(e,t,{...s,nodeRadius:a});const u={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:s,nodeRadii:"function"==typeof a?Object.fromEntries(e.map(e=>[e.id,a(e)])):null==a?void 0:Object.fromEntries(e.map(e=>[e.id,a]))};try{const e=await function(e,t){return or()?Cc.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(u,r);return e.positions}catch(n){if("AbortError"===n?.name)throw n;return k(e,t,{...s,nodeRadius:a})}}function ir(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function ar(e,t){return!!t?.some(t=>Object.is(e,t))}function sr(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=ir(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!ar(n,t.oneOf)||t.notOneOf&&ar(n,t.notOneOf))}function cr(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function lr(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function ur(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=cr(e,n),r=lr(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function dr(e,t){return(t??Object.keys(e)).map(t=>cr(e,t)).filter(lr).map(e=>({label:e.label??e.id,value:e.count}))}function hr(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",a=e.completion?.valueByBodyId,s=e=>{const t=a?cr(a,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+s(t),0),l=t.reduce((e,t)=>e+(n.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function fr(e,t,n){return Math.max(t,Math.min(n,e))}function mr(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function pr(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,a=r,s=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=fr(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,p=fr(d*h+m,.06*d,.5*d),g=p/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=fr(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),A=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(k),S=s-a;let I=a;const C=k.map((e,t)=>{const n=I,o=t===k.length-1?s:I+(e.share??1)/A*S;return I=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),j=C[$],N=j.x0,F=j.x1,E=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=fr((e-a)/Math.max(1,s-a),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(N>=e){const t=fr((e-a)/Math.max(1,N-a),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(F>=e)return"top"===n?y:x;const o=fr((e-F)/Math.max(1,s-F),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},z=C.map(e=>{const t=Math.min(E(e.x0,"top"),E(e.x1,"top")),n=Math.max(E(e.x0,"bottom"),E(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),L={thickness:v,friction:w,restitution:M},O=[];"lane"===t?O.push(mr(b+"-top",a,c,s,c,L),mr(b+"-bottom",a,l,s,l,L),mr(b+"-left",a,c,a,l,{...L,thickness:Math.max(6,v-2)}),mr(b+"-right",s,c,s,l,{...L,thickness:Math.max(6,v)})):"funnel"===t?O.push(mr(b+"-top",a,c,s,y,L),mr(b+"-bottom",a,l,s,x,L),mr(b+"-left",a,c,a,l,{...L,thickness:Math.max(6,v-2)}),mr(b+"-right",s,y,s,x,{...L,thickness:Math.max(6,v)})):O.push(mr(b+"-left-top",a,c,N,y,L),mr(b+"-left-bottom",a,l,N,x,L),mr(b+"-center-top",N,y,F,y,L),mr(b+"-center-bottom",N,x,F,x,L),mr(b+"-right-top",F,y,s,c,L),mr(b+"-right-bottom",F,x,s,l,L),mr(b+"-left",a,c,a,l,{...L,thickness:Math.max(6,v-2)}),mr(b+"-right",s,c,s,l,{...L,thickness:Math.max(6,v)}));const T=e.membraneDampingScale??.5,P=a,R=Math.max(1,("bowtie"===t?N:s)-P),W=(e.membranes??[]).map(e=>{const t=P+fr(e.offset,0,1)*R,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),q=!1===e.includeMembraneRegions?[]:W.map(e=>xr({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??T,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:a,right:s,topY:c,bottomY:l,midY:u,centerLeft:N,centerRight:F,pinchHeight:p,pinchTop:y,pinchBottom:x,stages:z,membranes:W,colliders:O,regionEffects:q,boundaryY:E}}function gr(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),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,n,o,r}function yr(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...gr({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function xr(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=fr(e.cost,0,2);return{...gr({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}function br(e){return{...gr({...e,kind:e.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function wr(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...gr({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Mr(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...gr({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function vr(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...gr({...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 kr(e){return{...gr({...e,kind:e.kind??"force-field",attributes:{primitive:"portal",targetStage:e.targetStage,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function $r(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...gr({...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 Ar(e){return{...gr({...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 Sr(e){const t=e.x??e.anchor?.x??0,n=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:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function Ir(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[mr(t+"-top",e.left,e.top,e.right,e.top,n),mr(t+"-bottom",e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(mr(t+"-left",e.left,e.top,e.left,e.bottom,n),mr(t+"-right",e.right,e.top,e.right,e.bottom,n)),o}function Cr(e,t,n){return Math.max(t,Math.min(n,e))}function jr(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=Cr(n.along??.5,.05,.95),a=n.jitterX??0,s=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*a,l=Math.min(1,r.width/2),u=Cr(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+s,h=e.boundaryY(u,"bottom")-s;return{x:u,y:h>d?d+o()*Math.max(1,h-d):e.midY}}function Nr(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function Fr(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Er(e,t,n,o,r){return"function"==typeof o?o(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}(e,o??r)}function zr(e){const t=Number(e.toFixed(Fc));return Object.is(t,-0)?0:t}function Lr(e,t,n,o){const r=e.flatMap((e,r)=>{const i=Fr(Er(e,r,t,n,"time")),a=Fr(Er(e,r,t,o,"value"));return null==i||null==a?[]:[{time:zr(i),value:a,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function Or(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(r.time>t)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const a=function(e,t){let n=0,o=e.length;for(;o>n;){const r=n+o>>>1;t>e[r].time?n=r+1:o=r}return n}(e,t),s=e[a];if(s?.time===t)return s.value;const c=e[Math.max(0,a-1)];return"step"!==n&&s&&s.time!==c.time?c.value+(t-c.time)/(s.time-c.time)*(s.value-c.value):c.value}function Tr(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);return o===r?e[o]:e[o]+(e[r]-e[o])*(n-o)}function Pr(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=function(e){const t=(e??jc).map(e=>{const t=Fr(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return zr(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),r=function(e){if(Array.isArray(e)){if(e.length>Nc)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Nc} points`);return Array.from(new Set(e.map(Fr).filter(e=>null!=e).map(zr))).sort((e,t)=>e-t)}const t=e,n=Fr(t.start),o=Fr(t.end),r=Fr(t.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>Nc)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Nc} points`);const a=[],s=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;i>e;e+=1){const t=n+e*r;if(t>o+s)break;a.push(zr(Math.min(t,o)))}if(a.length&&s>=Math.abs(a[a.length-1]-o)||a.push(zr(o)),a.length>Nc)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Nc} points`);return Array.from(new Set(a)).sort((e,t)=>e-t)}(e.sampleAt),i=e.runs.map(t=>Lr(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>Or(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),a={};for(const e of o)a[e]=r.length?Tr(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?Tr(r,.5):null,quantiles:a}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Rr(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function Wr(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=Fr(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const o=zr(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function qr(e,t,n){return t>e?"below":e>n?"above":"inside"}function Dr(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,a=t.value-t.upper,s=[0,1];for(const[e,t]of[[o,r],[i,a]])(0>e&&t>0||e>0&&0>t)&&s.push(-e/(t-e));s.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;s.length-1>o;o+=1){const r=s[o],i=s[o+1];if(r>=i)continue;const a=(r+i)/2,d=(i-r)*n,h=qr(e.value+(t.value-e.value)*a,e.lower+(t.lower-e.lower)*a,e.upper+(t.upper-e.upper)*a);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function Br(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=Lr(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),a=n.lower??Rr(t,"lower"),s=n.upper??Rr(t,"upper"),c=t.points.map(e=>{const t=Or(i,e.time,o,r),n=Wr(e,a),c=Wr(e,s);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":qr(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,m=0,p=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>m&&(m=n,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=Dr(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function Yr(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Gr(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Vr(e){return!!Gr(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&Gr(e.visitsByStage)&&Gr(e.firstEnteredAt)&&Gr(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function Hr(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function _r(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,Hr(e)]))}}function Xr(e,t,n={}){if("region-enter"!==t.type)return e;const o=function(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}(t,n),r=e.stages.findIndex(e=>e.id===o);if(0>r)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const a=Yr(e.entities,i),s=Vr(a)?a:Hr(i),c=s.currentStageId?e.stages.findIndex(e=>e.id===s.currentStageId):-1,l=!s.visitedStageIds.includes(o),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=Yr(s.visitsByStage,o),f="number"==typeof h&&Number.isFinite(h)?h:0,m={...s,currentStageId:o,furthestStageId:r>s.furthestStageIndex?o:s.furthestStageId,furthestStageIndex:Math.max(s.furthestStageIndex,r),visitedStageIds:l?[...s.visitedStageIds,o]:s.visitedStageIds,visitsByStage:{...s.visitsByStage,[o]:f+1},firstEnteredAt:l?{...s.firstEnteredAt,[o]:d}:s.firstEnteredAt,lastEnteredAt:{...s.lastEnteredAt,[o]:d},regressionCount:c>=0&&c>r?s.regressionCount+1:s.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:m}}}function Ur(e){const t=e.bodyIds.map(t=>{const n=Yr(e.entities,t);return Vr(n)?n:Hr(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,a=t.filter(t=>t.visitedStageIds.includes(e.id)).length,s=t.reduce((t,n)=>{const o=Yr(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:a,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:s,repeatVisits:Math.max(0,s-a)};return o=i,c})}function Kr(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function Qr(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=ir(e.datum,t),o=ir(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Zr(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function Jr(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(l)}function n(){G+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:l,work:e.total,queuedAt:e.queuedAt}}function r(t,r,i,a){const s={bodyId:t.id,jobId:r.jobId,visitId:r.visitId,visit:r.visit,remaining:r.work,total:r.work,queuedAt:r.queuedAt,sequence:a};return x.set(r.jobId,s),$.delete(t.id),k.set(t.id,r.jobId),L+=1,O+=r.work,n(),function(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:l,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:x.size})}(t,s,i),s}function i(e){if(x.size>=m||0===b.size)return;const t=Array.from(b.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(x.size>=m)break;const t=v.get(n.jobId);t&&w.has(n.jobId)?(b.delete(n.jobId),$.delete(n.bodyId),r(t,n,e,n.sequence)):b.delete(n.jobId)}}function a(){let e=0;for(const t of x.values())e+=t.remaining;return e}function s(){D=Math.max(D,x.size),B=Math.max(B,a())}function c(){const e=F-p,t=Math.max(0,Math.min(p,F-(E??F)));let n=0,o=0,r=0,i=0,a=0;for(const t of A){if(e>t.end)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const s=t.end-t.start;a+=s>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/s):t.processedWork}const s=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:a,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&u>0?Math.max(0,Math.min(1,a/(u*t))):0,pressure:u>0?s/u:0}}const l=e.regionId,u=Math.max(0,e.unitsPerSecond),d=e.queueLayout??"lane",h=e.queueSlotSpacing??14,f=e.queueStiffness??.35,m=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,p=Math.max(.25,e.metricWindowSeconds??30),g=Math.max(1/60,e.snapshotIntervalSeconds??.25),y=e.releaseImpulse??{x:90,y:0},x=new Map,b=new Map,w=new Map,M=new Map,v=new Map,k=new Map,$=new Map,A=[];let S=0,I=new Map,C=new Map,j=0,N=0,F=0,E=null,z=0,L=0,O=0,T=0,P=0,R=0,W=0,q=0,D=0,B=0,Y=0,G=0,V=-1,H=!1;return{id:e.id??"capacity-queue:"+l,continuous:!1!==e.continuous,tick:a=>{const c=a.controls.readBodies(),d=new Map,h=new Map;for(const n of c){if(d.set(n.id,n),!t(n.id,a.getRegionState))continue;if(!sr(n,e.bodyFilter))continue;const o=Qr(n,e.jobKey),r=h.get(o)??[];r.push(n),h.set(o,r)}const f=Number.isFinite(a.dt)?Math.max(0,a.dt):0;if(!H){const e=Number.isFinite(a.elapsed)?Math.max(0,a.elapsed):f;F=Math.max(0,e-f),H=!0}const L=F,O=L+f;F=O,E=null==E?L:Math.min(E,L);const D={start:L,end:O,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},B=new Map;for(const[e,t]of h){const n=w.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];B.set(e,o),v.set(e,o)}for(const[t,r]of w){if(B.has(t))continue;const i=x.get(t),s=d.get(r.bodyId)??v.get(t);if(i){x.delete(t),k.delete(i.bodyId),W+=1,q+=i.remaining,n();const c={...o(i),abandonedAt:F,remainingWork:i.remaining,queueSeconds:Math.max(0,F-i.queuedAt)};s&&e.onAbandoned?.(s,c),a.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:s?.datum,x:s?.x,y:s?.y,regionId:l,work:i.total,remainingWork:i.remaining,jobId:t,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,abandonedAt:F,queueSeconds:c.queueSeconds,queueDepth:x.size})}b.delete(t),$.delete(r.bodyId),w.delete(t),v.delete(t)}for(const[t,o]of B){if(w.has(t))continue;const i=(M.get(t)??0)+1;M.set(t,i);const s=Kr(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${l}:${t}:${i}`,visit:i,regionId:l,work:s,queuedAt:F};w.set(t,c),z+=1,D.arrivals+=1,D.arrivalWork+=s;const u=S++;if(m>x.size)r(o,c,a,u);else{const r={...c,blockedAt:F,sequence:u};b.set(t,r),$.set(o.id,t),R+=1,n(),e.onBlocked?.(o,r),a.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:l,work:s,jobId:t,visitId:c.visitId,visit:i,queuedAt:F,blockedAt:F,queueDepth:x.size,blockedDepth:b.size})}}i(a),s();const G=Array.from(x.values()).sort((e,t)=>e.sequence-t.sequence);let _=u*f;for(const t of G){if(0>=_)break;const r=Math.min(t.remaining,_);if(t.remaining-=r,_-=r,T+=r,D.processedWork+=r,t.remaining>1e-6)continue;x.delete(t.jobId),k.delete(t.bodyId),N+=1,P+=t.total,D.completions+=1,D.completedWork+=t.total;const i=Math.max(0,F-t.queuedAt);Y+=i,n();const s=d.get(t.bodyId);if(!s)continue;a.controls.applyImpulse(t.bodyId,y.x??0,y.y??0);const c={...o(t),completedAt:F,queueSeconds:i};e.onProcessed?.(s,c),a.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:s.datum,x:s.x,y:s.y,regionId:l,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:F,queueSeconds:i,queueDepth:x.size})}i(a),s(),function(){const e=Array.from(x.values()).sort((e,t)=>e.sequence-t.sequence);I=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(b.values()).sort((e,t)=>e.sequence-t.sequence);C=new Map(t.map((e,t)=>[e.bodyId,t])),j=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&A.push(e);const t=F-p;for(;A.length>0&&t>A[0].end;)A.shift()}(D);const X=Math.floor(F/g);X!==V&&(V=X,n())},getSnapshot:()=>{const e=a(),t=function(){let e=0;for(const t of b.values())e+=t.work;return e}(),n=x.size,o=Array.from(x.values()).map(e=>Math.max(0,F-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:l,queueDepth:n,processedCount:N,unitsPerSecond:u,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:b.size,blockedWork:t,arrivalCount:z,admittedCount:L,admittedWork:O,processedWork:T,completedWork:P,blockedCount:R,abandonedCount:W,abandonedWork:q,peakQueueDepth:D,peakRemainingWork:B,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:Zr(o,.5),p95Seconds:Zr(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:N>0?Y/N:0,window:c(),simulatedAt:F,metricRevision:G}},bodyForce:e=>{if("none"===d)return null;const t=k.get(e.body.id),n=$.get(e.body.id),o=t?x.get(t):void 0,r=n?b.get(n):void 0;if(!o&&!r)return null;const i=o?I.get(e.body.id):C.get(e.body.id);if(null==i)return null;let a;const s=e.regions;if(s)for(let e=0;s.length>e;e+=1)if(s[e].id===l){const t=s[e].shape;t&&"aabb"===t.type&&(a=t);break}return a?{x:((r?a.x-.44*a.width:a.x-.22*a.width-i*(.15*h))-e.body.x)*f,y:(a.y-(i-((r?b.size:j)-1)/2)*h/Math.max(1,Math.sqrt(r?b.size:j))-e.body.y)*f*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function ei(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function ti(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=ei(n,o.bodyForce(e)));return n}}}function ni(e){const t=new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),a=r?.activeRegionIds.includes(e.fromRegionId);a?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function oi(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=new Map,r=new Map,i=e.assignmentForce??.45,a=e.returnForce??.35,s=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const a={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,a),r.set(i.id,a),d+=1,a},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,s=n?i:a;return{x:((o?o.x+(c.x??0):t.home.x)-e.body.x)*s,y:((o?o.y+(c.y??0):t.home.y)-e.body.y)*s}}const u=o.get(e.body.id);if(!u||0>=s)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*s,y:(d.y-e.body.y)*s}:null}}}function ri(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):ir(e.datum,t.deadlineAccessor)??ir(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function ii(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const a of i.controls.readBodies()){if(!sr(a,e.bodyFilter))continue;if(!o.has(a.id)){const n=ri(a,e);t({bodyId:a.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const s=o.get(a.id);s&&null==s.completedAt&&(e.completionRegionId&&i.getRegionState(a.id)?.activeRegionIds.includes(e.completionRegionId)?n(a.id):"waiting"!==s.state||s.deadlineAt>r||t({...s,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function ai(e){const t=new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:a=>{n=Math.max(n,a.elapsed);const s=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=a.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=a.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&sr(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!s){for(const n of t){const t=u.get(n);t&&(a.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const a=e.holdForce??.4;return{x:(r.x-n.body.x)*a-.45*n.body.vx,y:(r.y-n.body.y)*a-.45*n.body.vy}}}}function si(e,t,n){return Math.max(t,Math.min(n,e))}function ci(e){return e.length*Lc}function li(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function ui(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Lc)),r="compact"===n?li(e,o):"full"===n?e:ci(e)>t?li(e,o):e;return{text:r,textLength:ci(r)>t?Math.max(4,t):void 0}}function di(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:m,midY:p,stages:g,groups:y=[]}=e,x=m-f;return(0,Ec.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":s?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,Ec.jsx)("defs",{children:(0,Ec.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Ec.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,Ec.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,Ec.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,Ec.jsx)("rect",{x:d-6,y:f-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}),n?(0,Ec.jsx)("line",{x1:d+8,x2:h-8,y1:p,y2:p,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=zc[n],c=Math.max(12,e.width-8),l=si(c-8,22,88),d=ui(e.label,Math.max(8,l-10),a),h="none"!==a&&c-8>=22,y=function(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"}(e),b=ui(y,Math.max(16,c-10),"auto"),w=r&&!1!==e.showBadge&&c>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",v=ui(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return(0,Ec.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,Ec.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===n?1:1.6}),g.length-1>t?(0,Ec.jsx)("polygon",{points:`${e.x1-2},${p-7} ${e.x1+8},${p} ${e.x1-2},${p+7}`,fill:i.accent,opacity:.85}):null,h?(0,Ec.jsxs)(Ec.Fragment,{children:[(0,Ec.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),(0,Ec.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Ec.jsx)("title",{children:e.label}),d.text]})]}):null,w?(0,Ec.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,Ec.jsx)("title",{children:y}),b.text]}):null,o&&null!=e.count?(0,Ec.jsxs)("text",{x:e.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[(0,Ec.jsx)("title",{children:M}),v.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,a=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=si(Math.max(54,ci(e.label)+18,ci(c)+16),54,104),u=ui(e.label,l-12,"auto"),d=ui(c,l-12,"auto");return(0,Ec.jsxs)("g",{"data-group":e.id,children:[(0,Ec.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),(0,Ec.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,Ec.jsx)("title",{children:e.label}),u.text]}),(0,Ec.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Ec.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function hi(e){const[t,n]=e.size,o=e.flow??Oc.flow,r=function(e){if(null==e){const e=Oc.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??Oc.channelRatio)),a={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},s="down"===o?a.height:a.width,c=s*Math.max(0,e.chargeExtent??Oc.chargeExtent),l=s*Math.max(0,e.projectionExtent??Oc.projectionExtent),u=s*Math.max(0,e.destinationExtent??Oc.destinationExtent),d=Math.max(0,s-c-u-l),h=function(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}(e.destinations),f=("down"===o?a.width:a.height)/h.length,m="down"===o?(e,t)=>({x:a.x,y:a.y+e,width:a.width,height:t}):(e,t)=>({x:a.x+e,y:a.y,width:t,height:a.height}),p=m(0,c),g=m(c,d),y=c+d,x=m(y,u),b=m(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,s=(f-r)/2;return"down"===o?{id:e.id,label:e.label,order:t,x:a.x+n+s,y:x.y,width:r,height:x.height,centerX:a.x+(t+.5)*f,centerY:x.y+x.height/2}:{id:e.id,label:e.label,order:t,x:x.x,y:a.y+n+s,width:x.width,height:r,centerX:x.x+x.width/2,centerY:a.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:p,apparatus:g,destinations:w,projection:b}}function fi(e,t){return e.destinations.find(e=>e.id===t)}function mi(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),a=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*a,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*a}}function pi(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:a,height:s}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:o+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;r.length>e;e+=1){const a=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:a,y1:t.y,x2:a,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:o+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;r.length>e;e+=1){const a=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:a,x2:i,y2:a,thickness:n}})}}}return!1!==t.walls&&c.push({id:o+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:s,thickness:n}},{id:o+"-wall-right",shape:{type:"segment",x1:a-1,y1:0,x2:a-1,y2:s,thickness:n}}),c}function gi(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function yi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function xi(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function bi(e,t,n){return yi(e[t])??n}function wi(e,t){return"number"==typeof e?e:e?.[t]??0}function Mi(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:s=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let e=i?0:1;l>=e;e+=1){if(!a&&e>0&&c.length-1>e)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:s,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:s}})}return u}function vi(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:a}=e,s=[];if(!1!==o&&s.push(...function(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:c=s}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*s,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*s,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*c}}),a&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*c}}),l}(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...a}=r;s.push(...function(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:a,yBottom:s,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:f=Math.max(2,c)}=e,m=[],p=a+(s-a)/2,g=Math.abs(s-a),y=l?n:n-1;if(u||l)for(let e=l?0:1;y>=e;e+=1){if(!u&&e>0&&n>e)continue;const a=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:p,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,a=n+r;if(a>=d)continue;const s=i(n),l=i(a);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,l)+c/2,y1:h,x2:Math.max(s,l)-c/2,y2:h,thickness:f}})}return m}({...a,idPrefix:e??n+"-xbin",yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&s.push(...Mi({band:i,idPrefix:i.idPrefix??n+"-xband",plot:t,projection:"x"})),a&&s.push(...Mi({band:a,idPrefix:a.idPrefix??n+"-yband",plot:t,projection:"y"})),s}function ki(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:a=t.y+.18*t.height,yEnd:s=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(s-a)/(d-1):0,m=t.width/h,p=[];for(let e=0;d>e;e+=1){const n=c&&e%2==1?m/2:0;for(let o=0;h>o;o+=1){const s=t.x+m*(o+.5)+n;t.x+r>s||s>t.x+t.width-r||p.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:s,y:a+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function $i(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:a,vy:s,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=v(l),f=wi(u,"x"),m=wi(u,"y");return e.map((e,l)=>{const u=xi(t.x,e,l,bi(e,"x",0)),p=xi(t.y,e,l,bi(e,"y",0)),g=xi(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:xi(a,e,l,0),vy:xi(s,e,l,0),mass:xi(i,e,l,1),spawnAt:xi(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Ai(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:a=.2,...s}=t,c=function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:a="count",x:s}=t,c=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{const l=Math.max(0,e[a]/c*i),u=s?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(e,s),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:a})):[];return{columns:c,colliders:l}}function Si(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:a=!0}=t,s=e.map((e,t)=>({spawn:e,time:function(e,t,n){return yi("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=s.length?Math.min(...s.map(e=>e.time)):0;return{initialSpawns:s.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function Ii(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Ci(e,t,n="group"){const o=Ho(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return i>n?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function ji(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{Ii(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function Ni(e,t,n=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*n} ${t.x},${t.y}`}function Fi(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,a={},s=e.length;return e.forEach((e,t)=>{const c=i+t/s*Math.PI*2-Math.PI/2;Ii(a,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),a}function Ei(e,t,n={}){const o=(n.order??Ci(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.target>e.source?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const a=[];let s=0;for(const[e,t]of i){const[n,o]=e.split("\0"),i=r.get(n),c=r.get(o);t>s&&(s=t),a.push({row:i,col:c,source:n,target:o,value:t}),a.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:a,size:o.length,maxValue:s}}function zi(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Li(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function Oi(e,t){const n=zi(e.note)?e.note:void 0;return t?Li(e.mobileText)||Li(e.shortText)||Li(e.label)||Li(n?.mobileText)||Li(n?.shortText)||Li(n?.label)||Li(n?.title):Li(e.label)||Li(e.mobileText)||Li(e.shortText)||Li(n?.label)||Li(n?.title)}function Ti(e,t,n){const o=function(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=((e.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const a=zi(e.provenance)?e.provenance:void 0;"number"==typeof a?.confidence&&(r+=100*a.confidence);const s=zi(e.lifecycle)?e.lifecycle:void 0,c=((s?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function Pi(e,t){if(!t)return e;const n=Oi(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function Ri(e,t={}){const n=Array.isArray(e)?e.filter(zi):[],o=t.active??(null==t.width||(t.breakpoint??480)>=t.width),r=t.strategy??"hybrid",i=!1!==t.preferShortText,a=!1!==t.preservePrimary,s=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(e=>Pi(e,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((e,n)=>({annotation:e,index:n,priority:Ti(e,n,t)})).filter(e=>!!Xt(e.annotation)||(l.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),d=a?u.filter(e=>"primary"===((e.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(e=>e.index)),f=u.filter(e=>!h.has(e.index)),m=[...d,...f].slice(0,Math.max(s,c)),p=new Set(m.map(e=>e.index)),g=u.filter(e=>!p.has(e.index)),y=[...l,...m.sort((e,t)=>e.index-t.index).map(e=>Pi(e.annotation,i))],x=g.sort((e,t)=>e.index-t.index).map(e=>e.annotation),b=Math.max(0,t.maxCalloutItems??6),w=g.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>function(e,t,n,o){const r=Oi(e,o);if(!r)return null;const i=Li(e.id)||Li(e.key)||Li(e.pointId)||"annotation-"+(t+1),a=zi(e.provenance)?Li(e.provenance.source)||Li(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:Li(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:a,priority:n,annotation:e}}(e.annotation,e.index,e.priority,i)).filter(e=>!!e).slice(0,b),M=new Set(w.map(e=>e.annotation)),v=x.filter(e=>!M.has(e));return{active:o,strategy:r,budget:s,visible:y,deferred:x,calloutList:w,hidden:v}}function Wi(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function qi(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function Di(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:qi(e,t),...o},a=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),s=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=function(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}(e,t),l=function(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}(t);return{family:e,props:a,responsiveRules:[{id:e+"-mobile",description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...s,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function Bi(e={}){const t=Wi(e);return Di("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Yi(e={}){const t=Wi(e);return Di("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Gi(e={}){return Di("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Vi(e={}){const t=Wi(e);return Di("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Hi(e={}){const t=Wi(e);return Di("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function _i(e={}){return Di("geo",e,{showLegend:e.showLegend??!1})}function Xi(e={}){return Di("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Ui(e,t={}){switch(e){case"line":return Bi(t);case"area":return Yi(t);case"ordinal":return Gi(t);case"scatter":return Vi(t);case"network":return Hi(t);case"geo":return _i(t);case"small-multiple":return Xi(t)}}function Ki(e={}){const t=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:e.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:t,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:t}}var Qi,Zi=Object.create,Ji=Object.defineProperty,ea=Object.getOwnPropertyDescriptor,ta=Object.getOwnPropertyNames,na=Object.getPrototypeOf,oa=Object.prototype.hasOwnProperty,ra=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of ta(t))oa.call(e,r)||r===n||Ji(e,r,{get:()=>t[r],enumerable:!(o=ea(t,r))||o.enumerable});return e},ia=(e,t,n)=>(n=null!=e?Zi(na(e)):{},ra(!t&&e&&e.__esModule?n:Ji(n,"default",{value:e,enumerable:!0}),e)),aa={};((e,t)=>{for(var n in t)Ji(e,n,{get:t[n],enumerable:!0})})(aa,{DEFAULT_AREA_PER_ANNOTATION:()=>Ys,DEFAULT_GLYPH_ANCHOR:()=>bc,DEFAULT_GLYPH_VIEWBOX:()=>xc,DEFAULT_HIT_RADIUS:()=>pc,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>Da,GRID_FUEL_KEYS:()=>nc,GRID_FUEL_LABELS:()=>oc,LayoutCache:()=>la,SYMBOL_SEQUENCE:()=>xa,TAU:()=>yc,absorbRegion:()=>$r,activeCountOverDomain:()=>$n,addPoints:()=>ko,adjacencyFlowLayout:()=>Ss,adjacencyMatrix:()=>Ei,aggregateAdjacencyFlow:()=>Ft,aggregateRegionCounts:()=>ur,allocateCells:()=>g,analyzeNetEnsemble:()=>lt,angleScale:()=>bo,annotationBudget:()=>Qt,annotationDensity:()=>Jt,annotationLayout:()=>ln,arcLayout:()=>ji,arcPath:()=>Ni,arrivalReplay:()=>Si,axisFixedForceLayout:()=>lc,axisFixedForcePositions:()=>On,balanceSnapshotsToFlows:()=>x,bandLabel:()=>it,betweenness:()=>Ko,bfsDistances:()=>_o,bobaLayout:()=>Ds,bodyGroupSpec:()=>Sr,boundsOf:()=>ot,boxEdgeAnchors:()=>Cn,buildAdjacency:()=>Vo,buildTooltipEntries:()=>To,bulletLayout:()=>Ls,calendarLayout:()=>Pa,capacitatedRegion:()=>vr,chargeGateRegion:()=>br,circularLayout:()=>Fi,clamp:()=>h,closeness:()=>Qo,clustering:()=>Zo,collidersFromScales:()=>vi,comparePhysicsTrace:()=>Br,composePhysicsControllers:()=>ti,computeTransitDiagramPositions:()=>Te,countPairwiseCrossings:()=>ao,createCapacityQueueController:()=>Jr,createDependencyGateController:()=>ai,createPortalController:()=>ni,createProcessJourneyLedger:()=>_r,createServiceLevelController:()=>ii,createServiceResourcePoolController:()=>oi,cubicPath:()=>En,cubicPoint:()=>Nn,cubicTangent:()=>Fn,curvedEdgePath:()=>Sn,cyclicRangeContains:()=>Zn,dagreLayout:()=>ls,degree:()=>Ho,demandForecastRows:()=>hn,describePhysicsStageGeography:()=>gi,diagnoseTokenEncoding:()=>F,dimFor:()=>a,egoNetwork:()=>Uo,estimateLabelWidth:()=>lo,extractTooltipDatum:()=>Oo,fanOutBend:()=>jn,flextreeLayout:()=>cs,forceFieldRegion:()=>Ar,forceLayout:()=>k,forceLayoutAsync:()=>rr,formatMw:()=>wn,formatReservePct:()=>Mn,formatTooltipValue:()=>Po,galtonPegs:()=>ki,generateTokens:()=>j,geoAreaHitTarget:()=>Vn,geoHitTarget:()=>Gn,geographicDotGridLayout:()=>ss,geographicGridLayout:()=>Ja,glyphExtent:()=>jo,glyphFractionClipRect:()=>No,glyphPlacement:()=>Co,gridEventAnnotations:()=>xn,gridifyGeographicPoints:()=>ue,groupBy:()=>o,groupCompletionRows:()=>hr,hatchFill:()=>at,hitTargetPoint:()=>Yn,hitTargetRect:()=>Hn,hullFromBoxes:()=>rt,intervalLanesLayout:()=>sc,isometricLandmarkLayout:()=>_a,isotypeBoltGlyph:()=>Aa,isotypeBusGlyph:()=>Sa,isotypeChipGlyph:()=>$a,isotypeGhost:()=>va,isotypeInk:()=>wa,isotypeNetworkGlyphs:()=>ja,isotypePaper:()=>Ma,isotypePersonGlyph:()=>Ca,isotypePersonPath:()=>Ia,isotypeServerGlyph:()=>ka,layoutChipStrip:()=>co,layoutSequence:()=>so,layoutTokenGrid:()=>N,legendGroupsFrom:()=>Eo,legendSwatches:()=>zo,lineageDagLayout:()=>ys,linearAxis:()=>st,makeShade:()=>c,marimekkoLayout:()=>Es,markCallout:()=>ct,matchesHighlight:()=>i,mean:()=>m,membraneRegion:()=>xr,mermaidDagLayout:()=>ws,mobileAnnotationStrategy:()=>Ri,mobileAreaChartRecipe:()=>Yi,mobileBrushAlternatives:()=>Ki,mobileChartFamilyRecipe:()=>Ui,mobileGeoChartRecipe:()=>_i,mobileLineChartRecipe:()=>Bi,mobileNetworkChartRecipe:()=>Hi,mobileOrdinalChartRecipe:()=>Gi,mobileScatterplotRecipe:()=>Vi,mobileSmallMultipleRecipe:()=>Xi,mulberry32:()=>v,netEnsembleLayout:()=>$s,networkEdgeHitTarget:()=>Xn,networkHitTarget:()=>_n,nonNegativeFinite:()=>f,normalizePoint:()=>Io,normalizeScores:()=>Jo,normalizeTokenEncoding:()=>S,octilinearRoute:()=>Pe,offsetTransitPath:()=>Re,orderByBarycenter:()=>oo,orderByGroupDegree:()=>Ci,orderExactSmall:()=>io,orthogonalEdgePath:()=>In,packBandsBySilhouette:()=>no,packIntervals:()=>kn,packSpanLevels:()=>uo,packedClusterMatrix:()=>js,parallelCoordinatesLayout:()=>Ps,partitionSharedEdges:()=>po,physicsChargePoint:()=>mi,physicsDestination:()=>fi,physicsReferenceEnvelope:()=>Pr,physicsStageColliders:()=>pi,physicsStageGeography:()=>hi,placeWithMinGap:()=>eo,pointMagnitude:()=>So,polarToXY:()=>yo,portalRegion:()=>kr,pressureFieldRegion:()=>Mr,processChrome:()=>di,processJourneyRows:()=>Ur,processLaneWalls:()=>Ir,processStageLayout:()=>pr,processStageRegions:()=>yr,processVolumePolygons:()=>Nr,proximityProblem:()=>er,radiusScale:()=>wo,readField:()=>t,rectCollide:()=>zn,refineByAdjacentSwaps:()=>ro,regionCountsToProjectionRows:()=>dr,reserveAnnotationBands:()=>gn,reserveMarginPct:()=>fn,reserveSeries:()=>mn,ringArcPath:()=>Mo,roundedEnclosure:()=>nt,roundedTransitPath:()=>We,routeSurfaceRegion:()=>wr,runLengthEncode:()=>gc,runs:()=>Un,sampleGeographicDotGrid:()=>$e,scaleArcBand:()=>ho,scalePoint:()=>Ao,sedimentBake:()=>Ai,selectCyclicRange:()=>Jn,selectIsometricLandmarks:()=>ne,shade:()=>l,shortestArcDelta:()=>Qn,shortestPath:()=>Xo,signatureKey:()=>s,spanArcPath:()=>fo,spanArcPeakY:()=>mo,spawnFromTokens:()=>$i,stackFuelSeries:()=>dn,stageTargetInVolume:()=>jr,subtractPoints:()=>$o,suggestTokenEncoding:()=>L,summarizeOperatingPoint:()=>yn,symbolExtent:()=>P,symbolPathString:()=>O,symbolRadius:()=>T,thresholdBandsForReserve:()=>pn,tightestHours:()=>bn,tokenLayer:()=>V,tokenTaskIntentToCapabilityIntents:()=>z,transitDiagramLayout:()=>hs,unitize:()=>w,unitizeRange:()=>M,unwrapDatum:()=>n,updateProcessJourney:()=>Xr,waffleLayout:()=>ua,withAlpha:()=>p,wordTrailsLayout:()=>fc,wordTrailsProgressiveReveal:()=>Tn,wrapValue:()=>Kn,xyToAngle:()=>xo}),module.exports=(Qi=aa,ra(Ji({},"__esModule",{value:!0}),Qi));var sa,ca=require("d3-interpolate"),la=class{constructor(e=12){this.maxSize=e,this.store=new Map}get(e){return this.store.get(e)}set(e,t){this.maxSize>this.store.size||this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},ua=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,i=t.gutter??2,a=n*o;if(0>=n||0>=o||0>=a)return{nodes:[]};const{plot:s}=e.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};const c=(s.width-i*(o-1))/o,l=(s.height-i*(n-1))/n;if(0>=c||0>=l)return{nodes:[]};const u=(null==(d=t.categoryAccessor)?null:"function"==typeof d?d:e=>e[d])??(()=>"_default");var d;const h=function(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}(t.valueAccessor)??(()=>1),f=new Map,m=[];for(const t of e.data){const e=u(t)+"",n=Number(h(t)),o=Number.isFinite(n)?Math.max(0,n):0;f.has(e)||m.push(e),f.set(e,(f.get(e)??0)+o)}const p=Array.from(f.values()).reduce((e,t)=>e+t,0);if(0>=p)return{nodes:[]};let g;if(t.categoryOrder&&t.categoryOrder.length>0){const e=new Set,n=[];for(const o of t.categoryOrder)f.has(o)&&!e.has(o)&&(e.add(o),n.push(o));g=[...n,...m.filter(t=>!e.has(t))]}else g=m;if(0===g.length)return{nodes:[]};const y=g.map(e=>({cat:e,exact:(f.get(e)??0)/p*a})).map(e=>({...e,count:Math.floor(e.exact)})),x=y.reduce((e,t)=>e+t.count,0),b=y.map((e,t)=>({i:t,rem:e.exact-e.count})).sort((e,t)=>t.rem-e.rem);for(let e=0;a-x>e;e++)y[b[e%b.length].i].count+=1;const w="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",M="string"==typeof t.valueAccessor?t.valueAccessor:"value",v=(e,t,n)=>r(o=>{o("category",e),o("value",f.get(e)??0),o("share",(f.get(e)??0)/p),"category"!==w&&o(w,e),"value"!==M&&o(M,f.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),k=[];let $=0;for(const t of y){const r=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)k.push({type:"rect",x:s.x+$%o*(c+i),y:s.y+(n-1-Math.floor($/o))*(l+i),w:c,h:l,style:{fill:r,stroke:"none"},datum:v(t.cat,$,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),$++}return{nodes:k}},da=1e-6,ha=require("d3-force"),fa=1e3,ma=80,pa=100,ga=require("d3-shape"),ya={circle:ga.symbolCircle,square:ga.symbolSquare,triangle:ga.symbolTriangle,diamond:ga.symbolDiamond,star:ga.symbolStar,cross:ga.symbolCross,wye:ga.symbolWye},xa=["circle","triangle","diamond","star","square","chevron","cross","wye"],ba=new Map,wa="#334155",Ma="#f8fafc",va="#cbd5e1",ka={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},$a={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Aa={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},Sa={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},Ia="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",Ca={viewBox:[18,40],anchor:[.5,1],parts:[{d:Ia,fill:"color",stroke:"color",strokeWidth:1.4}]},ja={server:ka,chip:$a,bolt:Aa,bus:Sa,person:Ca},Na="var(--semiotic-primary, #4e79a7)",Fa="var(--semiotic-border, #d1d5db)",Ea="var(--semiotic-secondary, #9ca3af)",za="var(--semiotic-bg, #ffffff)",La=new Set(xa),Oa=require("d3-interpolate"),Ta=864e5,Pa=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=new Map;let a=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==a&&(a=e.getUTCFullYear());const n=H(e),s=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(s)?s:0))}const s=t.year??a??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.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,Oa.interpolateRgb)(u,d)(t)},f=t.gutter??2,m=t.labelInset??0,p=Math.min((n.width-m-53*f)/54,(n.height-6*f)/7);if(0>=p)return{nodes:[]};const g=new Date(Date.UTC(s,0,1)),y=g.getUTCDay(),x=new Date(g.getTime()-y*Ta),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const o=new Date(x.getTime()+(7*e+t)*Ta);if(o.getUTCFullYear()!==s)continue;const r=H(o),a=i.get(r),c=null==a?u:h(a);b.push({type:"rect",x:n.x+m+e*(p+f),y:n.y+t*(p+f),w:p,h:p,style:{fill:c,stroke:"none"},datum:{date:o,value:a??0}})}return{nodes:b}},Ra=ia(require("react")),Wa=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),qa=require("react/jsx-runtime"),Da={resource:32,city:64},Ba=["#739b58","#83a964","#668d52","#8baa68"],Ya={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},Ga={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},Va=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),Ha=new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),_a=e=>{const t=ee(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:Ba,i=e.dimensions.width/2,a=(e.dimensions.height-t*o)/2+o/2,s=ne(e.points,e.config).map(e=>({...e,x:i+n/2*(e.column-e.row),y:a+(e.column+e.row)*(o/2)}));return{nodes:s.map(t=>{const i=function(e,t){const n=U(e,t),o=function(e){return Ha.has(e)?e:void 0}("string"==typeof n?n:U(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=U(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,a=K(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...a?{fill:a}:{}}}(e.config.terrainByCell,t.id),a="city"===t.landmark?.kind?"urban":i?.kind??"land",s=i?.fill??K(e.config.terrainPalette,a)??K(Ya,a)??Ya.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:a,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=a,K(Ga,l)??Ga.land),kind:"terrain",terrainKind:a,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,u,d,h,f;return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===a?s:r[t.terrainIndex%r.length],stroke:"ocean"===a?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??a,interactive:!0}}),overlays:(0,qa.jsx)(oe,{tiles:s,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??Da.resource,citySize:e.config.citySpriteSize??Da.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},Xa={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},Ua={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},Ka=require("react/jsx-runtime"),Qa=.72,Za=1.8,Ja=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=o?function(e){return e.areas.map((t,n)=>{const o=function(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??"area-"+t;return{...n,id:o+""}}(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}(e):e.points.map((e,t)=>({datum:e,x:t,y:t})),i=r.filter((e,n)=>!t.filter||t.filter(e.datum,n)),a=function(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(de(e,t.columnAccessor)),y:Number(de(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}(i.map(e=>e.datum),t),s=o?i:function(e){return e.points.map(t=>{const n=Number(de(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(de(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}({...e,points:i.map(e=>e.datum)}),c=a??ue(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===c.length)return{nodes:[]};const l=ce(c.map(e=>e.row)),u=ce(c.map(e=>e.column)),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(1,Math.round(u[1]-u[0])+1),f=Math.max(0,t.layoutPadding??8),m=Math.max(1,e.dimensions.width-2*f)/h,p=Math.max(1,e.dimensions.height-2*f)/d,g=(e.dimensions.width-m*h)/2,y=(e.dimensions.height-p*d)/2,x=se(t.cellPadding??.12,0,.8),b=Math.max(1,.5*Math.min(m,p)*(1-x)),w=t.sizeAccessor?c.map(e=>Number(de(e.datum,t.sizeAccessor))):[],M=t.sizeDomain??ce(w),v=t.sizeRange??[.36,1],k=se(Math.min(v[0],v[1]),.05,1),$=se(Math.max(v[0],v[1]),k,1),A=c.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=(de(r,t.idAccessor,["id","key","name"])??"grid-"+o)+"",a=(de(r,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",s=Math.max(1,t.maxLabelLength??4),c=a.length>s?a.slice(0,s):a,d=de(r,t.categoryAccessor),h=null==d?void 0:d+"",f=de(r,t.fillAccessor),x=null!=f?f+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",w=t.sizeAccessor?Number(de(r,t.sizeAccessor)):NaN,v=t.sizeAccessor&&Number.isFinite(w)?Math.sqrt(se(le(w,M),0,1)):1,A=b*(k+v*($-k)),S="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:c,category:h,row:n.row,column:n.column,x:g+(n.column-u[0]+.5)*m,y:y+(n.row-l[0]+.5)*p,radius:A,style:{fill:x,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...S}}}),S=t.shape??"circle";return{nodes:A.map(e=>{return"circle"===S?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===S?function(e,t,n){const o=[];for(let r=0;6>r;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return he(o)}(e.x,e.y,e.radius):he([[(t=e.x)-(o=e.radius),(n=e.y)-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===S?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:(0,Ka.jsx)(fe,{marks:A,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??se(.23*Math.min(m,p),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},es=require("react/jsx-runtime"),ts=10,ns=25e3,os=new WeakMap,rs=new WeakMap,is=new WeakMap,as=1,ss=e=>{const t=function(e){let t=os.get(e.areas);t||(t=new Map,os.set(e.areas,t));const n=function(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",Me(t.featureFilter),Me(t.dotFilter),je(e)].join("::")}(e),o=t.get(n);if(o)return o;const r=$e(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,ge(n.dotRadius)??t.cellSize*pe(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,a=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((s,c)=>{const l=i+(s.gridColumn+.5)*t.cellSize,u=a+(s.gridRow+.5)*t.cellSize,d=ye(s,n.categoryAccessor),h=ye(s,n.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(s,c):n.markStyle},m=`dot-${s.gridRow}-${s.gridColumn}`;if("circle"===o)return{type:"point",x:l,y:u,r:r,style:f,datum:s,interactive:!1,pointId:m,_transitionKey:m};const p="hexagon"===o?function(e,t,n){return Ne(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}(l,u,r):function(e,t,n){return Ne([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}(l,u,r);return{type:"geoarea",pathData:p,centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:s,group:s.featureId,interactive:!1}}),overlays:n.showOutline?(0,es.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?(0,es.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},be(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},cs=e=>{const n=e.config,o=n.nodeWidth??80,r=n.nodeHeight??30,i=n.orientation??"vertical",a=n.edgeCurve??"curved",s=!1!==n.showLabels,c=n.labelAccessor??"id",l="function"==typeof c?c:e=>t(e,c,e.id??"")+"",u=new Map,d=[],h=[],f=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??o,h:("number"==typeof t.height?t.height:e.height)??r}};for(const t of e.nodes){const{x:o,y:r,w:i,h:a}=f(t);null!=o&&null!=r&&(u.set(t.id,{x:o,y:r,w:i,h:a}),d.push({type:"rect",x:o-i/2,y:r-a/2,w:i,h:a,style:{fill:n.nodeFill??e.resolveColor(t.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:t,id:t.id,label:l(t)+""}),s&&h.push({x:o,y:r,text:l(t)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const m=[];for(const t of e.edges){const n="string"==typeof t.target?t.target:t.target.id,o=u.get("string"==typeof t.source?t.source:t.source.id),r=u.get(n);if(!o||!r)continue;const s="vertical"===i?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===i?{x:r.x,y:r.y-r.h/2}:{x:r.x-r.w/2,y:r.y};if("line"===a)m.push({type:"line",x1:s.x,y1:s.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{const n=(s.y+c.y)/2,o=(s.x+c.x)/2;m.push({type:"curved",pathD:"vertical"===i?`M${s.x},${s.y} C${s.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${s.x},${s.y} C${o},${s.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:d,sceneEdges:m,labels:h}},ls=e=>{const n=e.config,o=n.nodeWidth??100,r=n.nodeHeight??36,i=n.edgeStyle??"polyline",a=!1!==n.showLabels,s=n.labelAccessor??"label",c="function"==typeof s?s:e=>t(e,s,e.id??"")+"",l=new Map,u=[],d=[],h=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??o,h:("number"==typeof t.height?t.height:e.height)??r}};for(const t of e.nodes){const{x:o,y:r,w:i,h:s}=h(t);null!=o&&null!=r&&(l.set(t.id,{x:o,y:r,w:i,h:s}),u.push({type:"rect",x:o-i/2,y:r-s/2,w:i,h:s,style:{fill:n.nodeFill??e.resolveColor(t.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:t,id:t.id,label:c(t)+""}),a&&d.push({x:o,y:r,text:c(t)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=n.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,m=[];for(const t of e.edges){const e="string"==typeof t.target?t.target:t.target.id,n=l.get("string"==typeof t.source?t.source:t.source.id),o=l.get(e);if(!n||!o)continue;const r=t.data??{},a=Array.isArray(r.points)?r.points:t.points;if(a&&a.length>=2)if("smooth"!==i||3>a.length){const e="M"+a.map(e=>`${e.x},${e.y}`).join(" L ");m.push({type:"curved",pathD:e,style:{stroke:f,strokeWidth:1,fill:"none"},datum:t})}else{let e=`M${a[0].x},${a[0].y}`;for(let t=1;a.length-1>t;t++)e+=` Q${a[t].x},${a[t].y} ${(a[t].x+a[t+1].x)/2},${(a[t].y+a[t+1].y)/2}`;const n=a[a.length-1];e+=` T${n.x},${n.y}`,m.push({type:"curved",pathD:e,style:{stroke:f,strokeWidth:1,fill:"none"},datum:t})}else m.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:f,strokeWidth:1},datum:t})}return{sceneNodes:u,sceneEdges:m,labels:d}},us=require("react"),ds=e=>"number"==typeof e&&Number.isFinite(e),hs=e=>{const n=e.config??{},o=n.mode??"primary",i=n.dimOpacity??.14,a=t=>e.selection?.isActive&&!e.selection.predicate(t)?i:1,s=e.nodes.map(e=>({id:e.id,data:qe(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),c=e.edges.map(e=>({source:De(e.source),target:De(e.target),data:qe(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),l=Te(s,c,e.dimensions.plot,n),u="source-rooted"===n.lineMode?function(e,n,o,r){const i=new Set(e.map(e=>e.id)),a=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of n)i.has(e.source)&&i.has(e.target)&&(a.set(e.target,(a.get(e.target)??0)+1),s.get(e.source)?.push(e));for(const e of s.values())e.sort((e,t)=>e.target.localeCompare(t.target)||e.source.localeCompare(t.source));const c=e.filter(e=>0===(a.get(e.id)??0)).sort((e,t)=>e.id.localeCompare(t.id)),l=new Map,u=new Map(e.map(e=>[e.id,new Map]));for(const e of c){const n="function"==typeof o.labelAccessor?o.labelAccessor(e.data):t(e.data,o.labelAccessor??"label",e.id),i={id:e.id,label:n+"",color:Ye(e,o,r)},a=new Set,c=[e.id];for(;c.length>0;){const e=c.shift();if(!a.has(e)){a.add(e),u.get(e)?.set(i.id,i);for(const t of s.get(e)??[]){let e=l.get(t);e||(e=new Map,l.set(t,e)),e.set(i.id,i),a.has(t.target)||c.push(t.target)}}}}const d=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(n.map(e=>[e,d(l.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,d(u.get(e.id)?.values()??[])]))}}(s,c,n,e.resolveColor):void 0,d=function(e,t,n){const o=new Map;for(const r of e){const e=r.target>r.source?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:new Map},o.set(e,i));const a=r.data.lineOrder;Array.isArray(a)&&(i.authoredOrder=a.map(String));const s=n?.byEdge.get(r)??Be(r,t);for(const e of s)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>e.key.localeCompare(t.key))}(c,n,u),h=new Map(s.map(e=>[e.id,new Set])),f=new Map;if(u)for(const[e,t]of u.byNode)for(const n of t)h.get(e)?.add(n.id),n.color&&f.set(n.id,n.color);const m=Math.max(1,n.lineWidth??("primary"===o?6:"compact"===o?3.5:2)),p=Math.max(0,n.lineGap??("primary"===o?2:"compact"===o?1:.5)),g=new Map,y=[];for(const t of d){const o=l.positions.get(t.source),r=l.positions.get(t.target);if(!o||!r)continue;const i=He(t,n),s=(i.length-1)/2*(m+p)+m/2;for(const e of[t.source,t.target])g.set(e,Math.max(g.get(e)??0,s));i.forEach((s,c)=>{h.get(t.source)?.add(s.descriptor.id),h.get(t.target)?.add(s.descriptor.id);const u=_e(s.edge,l,n,s.edge.source!==t.source),d=Re(u?[o,...u,r]:Pe(o,r),(c-(i.length-1)/2)*(m+p)),g=Xe(s.edge,s.descriptor),x=Ge(s.descriptor,s.edge,n,e.resolveColor);f.has(s.descriptor.id)||f.set(s.descriptor.id,x),y.push({type:"curved",id:`${t.key}:${s.descriptor.id}`,label:`${s.descriptor.label??s.descriptor.id}: ${s.edge.source} to ${s.edge.target}`,pathD:We(d,n.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:m,strokeLinecap:"round",opacity:a(g)},datum:g,accessibleDatum:g,accessibility:{label:`${s.descriptor.label??s.descriptor.id}, ${s.edge.source} to ${s.edge.target}`,tableFields:{line:s.descriptor.label??s.descriptor.id,source:s.edge.source,target:s.edge.target}}})})}const x=new Map,b=[],w=[],M=e=>(("function"==typeof n.labelAccessor?n.labelAccessor(e.data):t(e.data,n.labelAccessor??"label",e.id))||e.id)+"";if("minimap"===o){const t=new Map;for(const e of s){const n=l.positions.get(e.id);if(!n)continue;const o=`${n.x}\0${n.y}`;let r=t.get(o);r||(r={x:n.x,y:n.y,nodes:[],lineIds:new Set,bundleRadius:0},t.set(o,r)),r.nodes.push(e);for(const t of h.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,g.get(e.id)??0)}const o=[...t.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(const t of o){const o=Ve(t.lineIds,n),i=o.length>1||t.nodes.length>1||t.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?n.interchangeRadius??Math.max(5,t.bundleRadius):n.stationRadius??Math.max(3.5,t.bundleRadius);for(const e of t.nodes)x.set(e.id,s);const c=t.nodes.map(M).join(" / "),l=t.nodes.map(e=>e.id).join("--"),u=1===t.nodes.length?t.nodes[0].data:r(e=>{e("id",l),e("label",c),e("stationIds",t.nodes.map(e=>e.id)),e("stations",t.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),d={label:`${c}${i?", interchange":""}`,tableFields:{station:c,lines:o.join(", ")}};o.length>1?(o.forEach((n,r)=>{const i={type:"arc",cx:t.x,cy:t.y,innerR:0,outerR:s,startAngle:-Math.PI/2+r/o.length*Math.PI*2,endAngle:-Math.PI/2+(r+1)/o.length*Math.PI*2,style:{fill:f.get(n)??e.resolveColor(n),stroke:"none",opacity:a(u)},datum:null,id:`${l}:${n}`};b.push(i)}),b.push({type:"circle",cx:t.x,cy:t.y,r:s,style:{fill:"transparent",stroke:n.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:a(u)},datum:u,accessibleDatum:u,accessibility:d,id:l,label:c})):b.push({type:"circle",cx:t.x,cy:t.y,r:s,style:{fill:(o[0]&&f.get(o[0]))??n.stationFill??"var(--semiotic-bg, white)",stroke:n.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:a(u)},datum:u,accessibleDatum:u,accessibility:d,id:l,label:c})}}else for(const e of s){const t=l.positions.get(e.id);if(!t)continue;const r=Ve(h.get(e.id)??[],n),i=r.length>1||!0===e.data.interchange||!0===e.data.transfer,s=i?n.interchangeRadius??Math.max("primary"===o?7:5,g.get(e.id)??0):n.stationRadius??("primary"===o?4:2.75);x.set(e.id,s);const c=M(e);if(b.push({type:"circle",cx:t.x,cy:t.y,r:s,style:null!=n.renderStation?{fill:"transparent",stroke:"transparent"}:{fill:n.stationFill??"var(--semiotic-bg, white)",stroke:n.stationStroke??"var(--semiotic-text, #222)",strokeWidth:i?"primary"===o?3:2:1.5,opacity:a(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${c}${i?", interchange":""}`,tableFields:{station:c,lines:r.join(", ")}},id:e.id,label:c}),n.renderStation){const c=n.renderStation({station:e.data,x:t.x,y:t.y,radius:s,lineIds:r,interchange:i,mode:o});null!=c&&w.push((0,us.createElement)("g",{key:e.id,opacity:a(e.data),style:{pointerEvents:"none"}},c))}}const v=w.length>0?(0,us.createElement)("g",{className:"transit-diagram-stations"},...w):void 0,k={sceneEdges:y,sceneNodes:b,overlays:v,labels:Ue(s,l.positions,h,x,e.dimensions.plot,"primary"===o?n:{...n,showLabels:!1})};return w.length>0||"minimap"===o?k:{...k,restyle:(e,t)=>t?.isActive&&!t.predicate(e.datum)?{opacity:i}:{opacity:1},restyleEdge:(e,t)=>t?.isActive&&!t.predicate(e.datum)?{opacity:i}:{opacity:1}}},fs=require("react/jsx-runtime"),ms=require("react/jsx-runtime"),ps={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},gs={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},ys=e=>{const n=e.config||{},o=e.dimensions.plot,r=n.layerAccessor??"x",i=n.rowAccessor??"y",a=n.partitionAccessor??"partition",s=n.semanticAccessor??"semantic",c=n.labelAccessor??"label",l=n.storesAccessor??"stores",u=n.backEdgeAccessor??"isBackEdge",d=n.edgeTypeAccessor??"edgeType",h={...ps,...n.partitionColors},m={...gs,...n.edgeColors},p=n.accentColor??"var(--semiotic-focus, #ffcc33)",g=n.borderColor??"var(--semiotic-border, #555)",y=n.dimOpacity??.14,x=n.edgeOpacity??.5,b=n.edgeWidth??1.25,w=n.backEdgeWidth??n.edgeWidth??1.5,M=!1!==n.showStoreChips,v=n.storeChipColor??"var(--semiotic-info, #6a8caf)",k=n.hullGroupAccessor;let $=n.layerCount,A=n.maxLayerSize;if(null==$||null==A){let n=0;const o=new Map;for(const i of e.nodes){const e=Math.round(Number(t(i,r,0)));n=Math.max(n,e),o.set(e,(o.get(e)??0)+1)}$=$??n+1,A=A??Math.max(1,...o.values())}const S=o.width/Math.max(1,$),I=o.height/Math.max(1,A);let C=Math.min(n.nodeWidth??172,Math.max(8,S-(n.minGapX??26))),j=Math.min(n.nodeHeight??54,Math.max(8,I-(n.minGapY??18)));const N=n.lod&&"auto"!==n.lod?n.lod:16>C?"dot":48>C?"icon":108>C?"compact":"full";if("dot"===N){const e=Math.min(C,j,11);C=e,j=e}const F=Math.max(1,o.width-C),E=Math.max(1,o.height-j),z=Math.max(1,A-1),L=e=>o.x+C/2+($>1?e/($-1):.5)*F,O=e=>o.y+j/2+(e+z/2)/z*E,T=n.reachableIds?new Set(n.reachableIds):null,P=n.selectedId??null,R=e.selection,W=new Map,q=new Map,D=[],B=null==k?null:new Map,Y=[];for(const n of e.nodes){const e=n.id,o=Number(t(n,r,0)),u=Number(t(n,i,0)),d=t(n,a,"processor")+"",f=t(n,s,"processor")+"",m=t(n,c,e)+"",x=Ze(t(n,l,[])),b=n.data??n,w=L(o),M=O(u);W.set(e,{cx:w,cy:M});const v=T?T.has(e):null,$=R?.isActive?R.predicate(b):null,A=null!==v?!v:null!==$&&!$;q.set(e,A);const S=null!=P&&e===P,I=A&&!S?y:1,F=Object.prototype.hasOwnProperty.call(h,d)?h[d]:h.unknown;if("dot"===N?D.push({type:"circle",cx:w,cy:M,r:C/2,style:{fill:F,opacity:I,stroke:S?p:"transparent",strokeWidth:S?2:0},datum:n,id:e,label:m}):(D.push({type:"rect",x:w-C/2,y:M-j/2,w:C,h:j,style:{fill:F,opacity:I,stroke:S?p:g,strokeWidth:S?3:1},datum:n,id:e,label:m}),Y.push({id:e,cx:w,cy:M,partition:d,semantic:f,label:m,stores:x,opacity:I,selected:S,node:b})),B&&null!=k){const o=t(n,k,null);if(null!=o){const t=o+"",n=B.get(t)??[];n.push({id:e,x:w-C/2,y:M-j/2,w:C,h:j}),B.set(t,n)}}}const G=[];for(const n of e.edges){const e="string"==typeof n.source?n.source:n.source.id,o="string"==typeof n.target?n.target:n.target.id,r=W.get(e),i=W.get(o);if(!r||!i)continue;const a=!!t(n,u,!1),s=t(n,d,"internal")+"",c=q.get(e)||q.get(o)?Math.min(x,1.4*y):x,l=a?m.back:Object.prototype.hasOwnProperty.call(m,s)?m[s]:m.internal;let h;if(a){const e=r.cx,t=r.cy+j/2,n=i.cx,o=i.cy+j/2,a=Math.max(48,.28*Math.abs(e-n))+j;h=`M${e},${t} C${e},${t+a} ${n},${o+a} ${n},${o}`}else{const e=r.cx+C/2,t=r.cy,n=i.cx-C/2,o=i.cy,a=(e+n)/2;h=`M${e},${t} C${a},${t} ${a},${o} ${n},${o}`}const f={type:"curved",pathD:h,style:{stroke:l,strokeWidth:a?w:b,fill:"none",opacity:c,...a?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:n};G.push(f)}const V=0===Y.length?null:(0,ms.jsx)("g",{className:"lineage-dag-glyphs",children:Y.map(e=>function(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),a=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",s="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:a,node:e.node}):function(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";return(0,ms.jsxs)("g",{children:[(0,ms.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),(0,ms.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(e.semantic,e.partition,i),l="full"===r,u="icon"!==r,d="full"===r&&t.showChips&&e.stores.length>0;return(0,ms.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[(0,ms.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),u&&(0,ms.jsx)("foreignObject",{x:s,y:l?o/2-12:o/2-9,width:Math.max(8,n-s-8),height:18,style:{pointerEvents:"none"},children:(0,ms.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&(0,ms.jsx)("text",{x:s,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),d&&e.stores.map((e,n)=>(0,ms.jsx)("rect",{x:s+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:(0,ms.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}(e,{w:C,h:j,lod:N,partColors:h,chipColor:v,showChips:M,renderIcon:n.renderIcon,typeLabel:n.typeLabel}))}),H=B&&B.size>0?function(e,t){const n=Array.from(e.entries()).sort(([e],[t])=>t>e?-1:e>t?1:0);return(0,fs.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:n.map(([e,n])=>{const o=function(e,t){if(0===t||3>e.length)return e;const n=0>e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)?-1:1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],a=e[(r+1)%e.length],s=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(a.x-o.x,a.y-o.y)||1,l=n>0?{x:(o.y-i.y)/s,y:-(o.x-i.x)/s}:{x:-(o.y-i.y)/s,y:(o.x-i.x)/s},u=n>0?{x:(a.y-o.y)/c,y:-(a.x-o.x)/c}:{x:-(a.y-o.y)/c,y:(a.x-o.x)/c},d={x:l.x+u.x,y:l.y+u.y},h=Math.hypot(d.x,d.y);if(1e-9>h)return{x:o.x+u.x*t,y:o.y+u.y*t};const f=d.x/h,m=d.y/h,p=t/Math.max(1e-6,f*u.x+m*u.y);return{x:o.x+f*p,y:o.y+m*p}})}(function(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(2>=t.length)return t;const n=[];for(const e of t){for(;n.length>=2&&0>=Ke(n[n.length-2],n[n.length-1],e);)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&0>=Ke(o[o.length-2],o[o.length-1],n);)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}(n.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding),r=function(e,t){if(0===e.length)return"";if(3>e.length||0===t)return e.map((e,t)=>`${0===t?"M":"L"}${Qe(e.x)},${Qe(e.y)}`).join(" ")+" Z";const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],a=Math.hypot(r.x-n.x,r.y-n.y)||1,s=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,a/2,s/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/a*c,y:n.y+(r.y-n.y)/a*c},outgoing:{x:n.x+(i.x-n.x)/s*c,y:n.y+(i.y-n.y)/s*c}}}),o=n[0].outgoing;let r=`M${Qe(o.x)},${Qe(o.y)}`;for(let e=1;n.length>e;e++){const t=n[e];r+=` L${Qe(t.incoming.x)},${Qe(t.incoming.y)}`,r+=` Q${Qe(t.point.x)},${Qe(t.point.y)} ${Qe(t.outgoing.x)},${Qe(t.outgoing.y)}`}const i=n[0];return r+=` L${Qe(i.incoming.x)},${Qe(i.incoming.y)}`,r+=` Q${Qe(i.point.x)},${Qe(i.point.y)} ${Qe(i.outgoing.x)},${Qe(i.outgoing.y)} Z`,r}(o,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),a=n.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),s=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=t.label?.(e);return(0,fs.jsxs)("g",{"data-lineage-hull":e,opacity:a?t.dimOpacity:void 0,children:[(0,fs.jsx)("path",{className:"lineage-dag-hull",d:r,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}}),l?(0,fs.jsx)("text",{className:"lineage-dag-hull-label",x:s+8,y:c+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:l}):null]},e)})})}(B,{colors:n.hullColors,padding:null==n.hullPadding?16:f(n.hullPadding),radius:null==n.hullRadius?12:f(n.hullRadius),fillOpacity:Je(n.hullFillOpacity,.08),strokeOpacity:Je(n.hullStrokeOpacity,.4),label:n.hullLabel,resolveColor:e.resolveColor,dimById:q,selectedId:P,dimOpacity:y}):null;return H?{sceneNodes:D,sceneEdges:G,backgrounds:H,overlays:V}:{sceneNodes:D,sceneEdges:G,overlays:V}},xs=require("react/jsx-runtime"),bs={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},ws=e=>{const n=e.config||{},o=e.dimensions.plot,r=n.direction??"TD",i="LR"===r||"RL"===r,a="BT"===r||"RL"===r,s=n.layerAccessor??"layer",c=n.rowAccessor??"row",l=n.labelAccessor??"label",u=n.shapeAccessor??"shape",d=n.edgeLabelAccessor??"label",h=n.nodeFill??"var(--semiotic-surface, #20242d)",f=n.nodeStroke??"var(--semiotic-border, #5a6573)",m=n.textColor??"var(--semiotic-text, #e6e6e6)",p=n.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",g=n.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const y=new Map;let x=0;for(const n of e.nodes){const e=Math.round(Number(t(n,s,0)));x=Math.max(x,e);const o=y.get(e)||[];o.push(n),y.set(e,o)}const b=x+1;let w=1;for(const e of y.values())e.sort((e,n)=>Number(t(e,c,0))-Number(t(n,c,0))),w=Math.max(w,e.length);const M=i?o.width:o.height,v=i?o.height:o.width,k=M/b,$=v/(w+1),A=Math.max(44,Math.min(n.nodeWidth??150,i?k-36:.92*$)),S=Math.max(26,Math.min(n.nodeHeight??46,i?.7*$:.5*k)),I=(i?A:S)/2+6,C=Math.max(1,M-2*I),j=e=>(i?o.x:o.y)+I+(b>1?(a?b-1-e:e)/(b-1)*C:C/2),N=new Map,F=[],E=[];for(const[e,n]of y)n.forEach((r,a)=>{const s=j(e),c=(i?o.y:o.x)+(a+1)/(n.length+1)*v,d=i?s:c,p=i?c:s,y=t(r,u,"rect")+"",x=t(r,l,r.id)+"";N.set(r.id,{cx:d,cy:p,shape:y}),F.push({type:"rect",x:d-A/2,y:p-S/2,w:A,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:r.id,name:x,type:bs[y]??"process",shape:y},id:r.id,label:x}),E.push((0,xs.jsxs)("g",{children:[tt(y,d,p,A,S,h,"diamond"===y?g:f,1.5),(0,xs.jsx)("text",{x:d,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:m,style:{pointerEvents:"none"},children:et(x,Math.max(4,Math.floor((A-12)/7)))})]},"n-"+r.id))});const z=[];return e.edges.forEach((e,n)=>{const o="string"==typeof e.target?e.target:e.target.id,r=N.get("string"==typeof e.source?e.source:e.source.id),a=N.get(o);if(!r||!a)return;const s=i?r.cx+A/2:r.cx,c=i?r.cy:r.cy+S/2,l=i?a.cx-A/2:a.cx,u=i?a.cy:a.cy-S/2,h=i?`M${s},${c} C${(s+l)/2},${c} ${(s+l)/2},${u} ${l},${u}`:`M${s},${c} C${s},${(c+u)/2} ${l},${(c+u)/2} ${l},${u}`,g=Math.atan2(u-c,l-s),y=l-9*Math.cos(g),x=u-9*Math.sin(g),b=4.5*-Math.sin(g),w=4.5*Math.cos(g),M=`${l},${u} ${y+b},${x+w} ${y-b},${x-w}`,v=t(e,d,void 0),k=(s+l)/2,$=(c+u)/2;z.push((0,xs.jsxs)("g",{children:[(0,xs.jsx)("path",{d:h,fill:"none",stroke:p,strokeWidth:1.4}),(0,xs.jsx)("polygon",{points:M,fill:p}),"string"==typeof v&&v.length>0&&(0,xs.jsxs)("g",{children:[(0,xs.jsx)("rect",{x:k-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:f,strokeWidth:.75}),(0,xs.jsx)("text",{x:k,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:m,style:{pointerEvents:"none"},children:v})]})]},"e-"+n))}),{sceneNodes:F,overlays:(0,xs.jsxs)("g",{className:"mermaid-dag",children:[z,E]})}},Ms=require("react/jsx-runtime"),vs=require("react/jsx-runtime"),ks=new la(8),$s=e=>{const n=e.config||{},o=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};const r=n.sourceAccessor??"source",i=n.targetAccessor??"target",c=n.labelAccessor??"label",l=n.categoryAccessor??"category",d=n.nodeRadius??4,h=n.cellGap??16,f=n.bandGap??22,m=n.headerHeight??34,p=n.minCellForFull??38,g=n.maxCellSize??120,y=n.minCellSize??12,x=n.fingerprintRounds??3,b=!1!==n.groupByMotif,w=n.sort??"frequency",M=new Map,v=new Map,k=[];for(const n of e.nodes){const e=n.id;null==e||M.has(e)||(k.push(e),M.set(e,n.data??n),v.set(e,t(n,l,"")+""))}const $=[];for(const n of e.edges){const e=dt(n.source??t(n,r,void 0)),o=dt(n.target??t(n,i,void 0));null!=e&&null!=o&&$.push({source:e,target:o})}const{outAdj:A,inAdj:S,undirected:I}=pt(k,$),C=gt(k,A,S,I,x),j=new Map;if(b)for(const e of C){const t=j.get(e.motif);t?t.push(e):j.set(e.motif,[e])}else j.set("all",[...C].sort((e,t)=>t.nodeCount-e.nodeCount));const N=[...j.entries()];N.sort((e,t)=>"size"===w?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===w?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const F=ut(k.join(",")+"|"+[...A.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),E=s([Math.round(o.x),Math.round(o.y),Math.round(o.width),Math.round(o.height),h,f,m,p,g,y,x,b,w,d,N.map(([e,t])=>e+":"+t.length).join(","),F]),z=ks.getOrCompute(E,()=>function(e,t){const{plot:n}=t,o=Math.max(40,n.width),{cell:r,cols:i}=(()=>{for(let r=t.maxCellSize;r>=t.minCellSize;r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let a=0;for(const[,n]of e)a+=t.headerHeight+Math.ceil(n.length/i)*(r+t.cellGap)+t.bandGap;if(n.height>=a)return{cell:r,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((o+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),a=[],s=[];let c=n.y;for(const[l,u]of e){const e=Math.ceil(u.length/i),d=c,h=d+t.headerHeight,f=r>=t.minCellForFull;u.forEach((e,o)=>{const s=n.x+o%i*(r+t.cellGap),c=h+Math.floor(o/i)*(r+t.cellGap);if(f){const n=ft(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:s,y:c,width:r,height:r},t.nodeRadius);a.push({component:e,lod:"full",cx:s+r/2,cy:c+r/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:s+r/2,cy:c+r/2,glyphR:Math.max(2.5,.36*r),nodes:[],edges:[]})});const m=yt(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});s.push({motif:l,descriptor:mt(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(r+t.cellGap),exemplar:m}),c=h+e*(r+t.cellGap)+t.bandGap}return{cells:a,bands:s}}(N,{plot:o,cellGap:h,bandGap:f,headerHeight:m,minCellForFull:p,maxCellSize:g,minCellSize:y,nodeRadius:d,nodeDatum:M,nodeCategory:v,outAdj:A,inAdj:S})),L=e.theme.semantic||{},O=n.convergeColor??L.info??"#4c78a8",T=n.branchColor??L.warning??"#e8853a",P=n.edgeColor??L.border??"#9aa0aa",R=n.colorMode??"directedness",W={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:n.highlight??null,dimOpacity:.14},q=t=>"motif"===R?e.resolveColor(t.motif):"category"===R||t.directed?O:T,D=[],B=[];for(const n of z.cells){const o=n.component,r=q(o);if("full"===n.lod){for(const e of n.edges)B.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:P,strokeWidth:1,opacity:.5},datum:null});for(const o of n.nodes){const n="category"===R&&o.category?e.resolveColor(o.category):r,i={type:"symbol",cx:o.cx,cy:o.cy,size:Math.PI*o.r*o.r,symbolType:"circle",style:{fill:n,opacity:a(o.datum,W)},datum:o.datum,id:o.id,label:t(o.datum,c,o.id)+""};D.push(i)}}else{const e=u({id:`motif-${o.motif}-${n.cx.toFixed(0)}-${n.cy.toFixed(0)}`,motif:o.motif,shape:mt(o),nodes:o.nodeCount,edges:o.edgeCount,sinks:o.sinkCount,sources:o.sourceCount,directedness:o.directed?"converging":"branching"}),t={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.glyphR*n.glyphR,symbolType:o.directed?"circle":"diamond",style:{fill:r,opacity:a(e,W),stroke:P,strokeWidth:.75},datum:e,id:e.id+"",label:mt(o)};D.push(t)}}return{sceneNodes:D,sceneEdges:B,overlays:function(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor;if(n.push(nt({keyId:"band-"+o.motif,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&o.exemplar){const r=o.exemplar;n.push((0,vs.jsxs)("g",{style:{pointerEvents:"none"},children:[r.edges.map((e,n)=>(0,vs.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+n)),r.nodes.map(t=>(0,vs.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+o.motif))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);n.push((0,vs.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},"bl-"+o.motif)),n.push((0,vs.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+o.motif))}}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push((0,vs.jsxs)("g",{style:{pointerEvents:"none"},children:[(0,vs.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),(0,vs.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),(0,vs.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),(0,vs.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;return(0,vs.jsx)("g",{className:"net-ensemble-overlays",children:n})}(z.bands,{convergeColor:O,branchColor:T,edgeColor:P,plot:o,showBandLabels:!1!==n.showBandLabels,showExemplars:!1!==n.showExemplars,showLegend:!1!==n.showLegend&&"directedness"===R,textColor:L.text??"var(--semiotic-text, #1a1a1a)",subText:L.textSecondary??"var(--semiotic-text-secondary, #888)"})}},As=ia(require("react")),Ss=e=>{const n=e.config??{},o=e.dimensions.plot,i=e.nodes.map((e,t)=>({id:e.id,datum:xt(e),inputIndex:t})),a=new Map(i.map(e=>[e.id,e.inputIndex])),s=new Map((n.order??[]).map((e,t)=>[e+"",t]));if(i.sort((e,t)=>{const n=s.get(e.id),o=s.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(a.get(e.id)??0)-(a.get(t.id)??0)}),0===i.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const c=Math.max(0,n.padding??18),l=Math.max(1,Math.min(o.width,o.height)-2*c),u=Math.min(Math.max(1,n.maxCellSize??120),l/i.length),d=u*i.length,h=o.x+(o.width-d)/2,f=o.y+(o.height-d)/2,m=Math.max(4,Math.min(.76*u,n.nodeSize??.56*u)),p=m/2,g=i.map((e,o)=>{const r="function"==typeof n.labelAccessor?n.labelAccessor(e.datum):t(e.datum,n.labelAccessor??"label",e.id)+"";return{id:e.id,label:r,datum:e.datum,index:o,cx:h+(o+.5)*u,cy:f+(o+.5)*u}}),y=new Map(g.map(e=>[e.id,e])),x=new Map(g.map(e=>[e.id,e.index])),b=function(e,n,o){const i=new Map;for(const r of e){const e=bt(r.source),a=bt(r.target),s=n.get(e),c=n.get(a);if(null==s||null==c)continue;const l=xt(r),u=wt("function"==typeof o.valueAccessor?o.valueAccessor(l):t(l,o.valueAccessor??"value",r.value??1),0);if(0>=u)continue;let d=i.get(e);d||(d=new Map,i.set(e,d));const h=d.get(a);h?(h.value+=u,h.edgeCount+=1,h.memberEdges.push(l)):d.set(a,{key:`${s}-${c}`,source:e,target:a,sourceIndex:s,targetIndex:c,value:u,edgeCount:1,memberEdges:[l],datum:l,width:1,color:""})}const a=[...i.values()].flatMap(e=>[...e.values()]);for(const e of a)e.datum=r(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return a}(e.edges,x,n),w=function(e,t,n){const o=new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r($t(t.source,t.sourceIndex>t.targetIndex?"out-left":"out-right"),t),r($t(t.target,t.targetIndex>t.sourceIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=At(t,n);let a=null==n.flowScale?1/0:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=St(e.length,t,n);o>0&&(a=Math.min(a,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}Number.isFinite(a)||(a=1)}const s=Math.max(0,n.minFlowWidth??1.25),c=Math.max(s,n.maxFlowWidth??1/0);for(const t of e)t.width=Math.min(c,Math.max(s,t.value*a));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=St(e.length,t,n);o>0&&(l=Math.min(l,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}if(1>l)for(const t of e)t.width*=l;return o}(b,m,n),M=function(e,t,n,o){const r=new Map;for(const[i,a]of e){const e=i.slice(i.indexOf("\0")+1),s=t.get(e);if(!s)continue;const c=i.startsWith("out-")?s.cy:s.cx,l=St(a.length,n,o);let u=c-(a.reduce((e,t)=>e+t.width,0)+l*Math.max(0,a.length-1))/2;for(const e of a){const t=u+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),u+=e.width+l}}return r}(w,y,m,n),v=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),k=e.theme.semantic.text??"var(--semiotic-text, currentColor)",$=e.theme.semantic.surface??"var(--semiotic-bg, white)",A=e.theme.semantic.border??"var(--semiotic-border, currentColor)",S=e.theme.semantic.grid??A,I=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),C=n.valueFormat??(e=>Math.round(100*e)/100+""),j=Math.max(0,Math.min(n.cornerRadius??10,.22*u)),N=new Map(g.map(e=>[e.id,0])),F=new Map(g.map(e=>[e.id,0])),E=[],z=[],L=[];for(const t of b){const o=y.get(t.source),r=y.get(t.target);if(!o||!r)continue;N.set(o.id,(N.get(o.id)??0)+t.value),F.set(r.id,(F.get(r.id)??0)+t.value);const i=n.colorMode??"single",a="function"==typeof n.edgeColor?n.edgeColor(t.datum):void 0;t.color=a??("string"==typeof n.edgeColor?n.edgeColor:void 0)??("source"===i?e.resolveColor(t.source):"target"===i?e.resolveColor(t.target):"edge"===i?e.resolveColor(`${t.source}→${t.target}`):v);const s=M.get(t.key+":source")??o.cy,c=M.get(t.key+":target")??r.cx;let l,d,m,g,x,b,w;if(t.targetIndex>t.sourceIndex){const e=[o.cx+p,s],n=[c,r.cy-p];l=[e,[n[0],e[1]],n],d=n[0],m=e[1]+.68*(n[1]-e[1]),g=Math.PI/2,x=n[0]-j-4,b=e[1]-t.width/2-3,w="end"}else if(t.sourceIndex>t.targetIndex){const e=[o.cx-p,s],i=[c,r.cy+p];l=[e,[i[0],e[1]],i],d=i[0],m=e[1]+.68*(i[1]-e[1]),g=-Math.PI/2,x=i[0]+j+4,b=e[1]+t.width/2+(n.valueFontSize??10),w="start"}else{const e=h+(o.index+1)*u,n=f+(o.index+1)*u,i=Math.max(2,Math.min(6,.07*u)),a=Math.max(o.cx+p+2,e-i),y=Math.max(o.cy+p+2,n-i),M=[o.cx+p,s],v=[c,r.cy+p];l=[M,[a,M[1]],[a,y],[v[0],y],v],d=(a+v[0])/2,m=y,g=Math.PI,x=a-3,b=y-t.width/2-3,w="end"}const A=vt(l,j);if(L.push({type:"curved",id:"adjacency-flow-"+t.key,label:`${o.label} to ${r.label}: ${C(t.value,t.datum)}`,pathD:A,style:{fill:"none",stroke:t.color,strokeWidth:t.width,opacity:.82,cursor:"pointer"},datum:t.datum,accessibleDatum:t.datum,accessibility:{label:`${o.label} to ${r.label}, ${C(t.value,t.datum)}`,tableFields:{source:o.label,target:r.label,value:t.value,edges:t.edgeCount}}}),(n.showValues??!0)&&z.push({x:x,y:b,text:C(t.value,t.datum),anchor:w,fontSize:n.valueFontSize??Math.max(7,Math.min(10,.14*u)),fontWeight:650,fill:k,stroke:$,strokeWidth:3,paintOrder:"stroke"}),n.showArrows??!0){const e=Math.min(Math.max(0,n.arrowSize??14),Math.max(0,t.width-2));if(2>=e)continue;E.push(As.createElement("path",{key:"arrow-"+t.key,className:"semiotic-adjacency-flow-arrow",d:kt(d,m,g,Math.max(3,1.08*e),e),fill:n.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":t.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const O=g.map(t=>{const o=("function"==typeof n.nodeColor?n.nodeColor(t.datum,t.index):void 0)??("string"==typeof n.nodeColor?n.nodeColor:"source"===(n.colorMode??"single")?e.resolveColor(t.id):I);return{type:"rect",id:t.id,label:t.label,x:t.cx-p,y:t.cy-p,w:m,h:m,style:{fill:o,stroke:n.nodeStroke??A,strokeWidth:1.25,cursor:"pointer"},datum:t.datum,accessibleDatum:t.datum,accessibility:{label:`${t.label}, step ${t.index+1}`,tableFields:{step:t.index+1,node:t.label,incoming:F.get(t.id)??0,outgoing:N.get(t.id)??0}}}}),T=Math.max(2,n.maxLabelLength??14),P=g.map(e=>{return{x:e.cx,y:e.cy,text:(t=e.label,o=T,t.length>o?t.slice(0,Math.max(1,o-1))+"…":t),anchor:"middle",baseline:"middle",fontSize:n.labelFontSize??Math.max(6,Math.min(15,.34*m,m/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:n.nodeTextColor??$};var t,o});let R=null;if(n.showGrid??!0){const e=[];for(let t=0;g.length>=t;t+=1){const n=h+t*u,o=f+t*u;e.push(As.createElement("line",{key:"grid-v-"+t,x1:n,y1:f,x2:n,y2:f+d,stroke:S,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),As.createElement("line",{key:"grid-h-"+t,x1:h,y1:o,x2:h+d,y2:o,stroke:S,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}R=As.createElement(As.Fragment,null,...e)}return{sceneEdges:L,sceneNodes:O,labels:[...z,...P],backgrounds:R,overlays:As.createElement(As.Fragment,null,...E)}},Is=require("react/jsx-runtime"),Cs=new la(12),js=e=>{const n=e.config||{},r=e.dimensions.plot,i=n.columnAccessor??"column",l=n.rowAccessor??"row",u=n.sizeAccessor,d=n.colorAccessor,h=n.symbolAccessor,f=n.shadeAccessor,m=n.markerAccessor,p=n.iconAccessor,g=n.defaultSymbol??"circle",[y,x]=n.sizeRange??[2,8],b=n.shadeStrength??.72,w=n.shadeReverse??!1,M=n.rowMode??"banded",v=n.cellSizing??"proportional",k=n.proportionExponent??1,$=n.columnGap??16,A=n.rowGap??12,S=n.packPadding??1,I=n.iterations??12,C=!1!==n.showEnclosures,j=!1!==n.showColumnHeaders,N=!1!==n.showRowLabels,F=j?n.headerHeight??26:0,E=N?n.labelWidth??66:0,z=n.callouts&&n.callouts.length>0?n.footerHeight??30:0,L=r.x+E,T=r.y+F,R=Math.max(1,r.width-E),W=Math.max(1,r.height-F-z),q=[];for(const n of e.nodes){const e=n.data??n;q.push({id:n.id,col:t(n,i,"—")+"",row:t(n,l,"—")+"",sizeVal:u?Number(t(n,u,1)):1,colorKey:d?t(n,d,"")+"":"",symVal:h?t(n,h,"")+"":"",shadeVal:f?Et(t(n,f,null)):NaN,marker:!!m&&!!t(n,m,!1),iconVal:p?t(n,p,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===q.length)return{sceneNodes:[]};let D=1/0,B=-1/0;if(u)for(const e of q)Number.isFinite(e.sizeVal)&&(D>e.sizeVal&&(D=e.sizeVal),e.sizeVal>B&&(B=e.sizeVal));n.sizeDomain&&([D,B]=n.sizeDomain),Number.isFinite(D)&&Number.isFinite(B)||(D=0,B=1);const Y=e=>{if(D>=B)return(y+x)/2;const t=Math.sqrt(zt((e-D)/(B-D),0,1));return y+t*(x-y)};let G=1/0,V=-1/0;if(f)for(const e of q)Number.isFinite(e.shadeVal)&&(G>e.shadeVal&&(G=e.shadeVal),e.shadeVal>V&&(V=e.shadeVal));n.shadeDomain&&([G,V]=n.shadeDomain);const H=e=>{if(!f||!Number.isFinite(e)||G>=V)return.5;const t=zt((e-G)/(V-G),0,1);return w?1-t:t},_=n.colorMap,X=new Map,U=(t,n)=>{let o=X.get(t);return o||(o=c(_&&Object.prototype.hasOwnProperty.call(_,t)&&"string"==typeof _[t]&&_[t]?_[t]:e.resolveColor(t),b),X.set(t,o)),o(n)},K=new Map;if(n.symbolMap)for(const[e,t]of Object.entries(n.symbolMap))K.set(e,t);let Q=0;const Z=n.iconMap,J=e=>p&&Z&&Object.prototype.hasOwnProperty.call(Z,e)?Z[e]??null:null,ee=e=>p?"circle":(e=>{if(!h)return g;let t=K.get(e);return t||(t=xa[Q%xa.length],Q++,K.set(e,t)),t})(e.symVal),te=n.maxAreaFraction??.4;let ne=0;const oe=Array(q.length),re=Array(q.length);for(let e=0;q.length>e;e++){const t=q[e],n=Y(t.sizeVal);oe[e]=n,t.baseShape=ee(t),t.iconShape=J(t.iconVal);const o=P(t.baseShape,Math.PI*n*n);re[e]=o,ne+=Math.PI*o*o}const ie=te*R*W,ae=ne>ie?Math.sqrt(ie/ne):1;for(let e=0;q.length>e;e++){const t=q[e],n=oe[e]*ae;t.size=Math.PI*n*n,t.packR=re[e]*ae}const se=new Map,ce=new Map;for(const e of q)se.set(e.col,(se.get(e.col)??0)+1),ce.set(e.row,(ce.get(e.row)??0)+1);const le=n.columnOrder?.filter(e=>se.has(e))??[...se.keys()].sort((e,t)=>(se.get(t)??0)-(se.get(e)??0)),ue=n.rowOrder?.filter(e=>ce.has(e))??[...ce.keys()].sort((e,t)=>(ce.get(t)??0)-(ce.get(e)??0)),de=s([Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height),F,E,z,M,v,k,$,A,S,I,y,x,D,B,te,le.join(","),ue.join(","),q.length,Lt(q)]),he=Cs.getOrCompute(de,()=>function(e,t){const n=new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const r=t.columnOrder.filter(e=>n.has(e)),i=Math.max(1,t.innerW-t.columnGap*Math.max(0,r.length-1)),a=t.proportionExponent,s=r.map(e=>Math.pow(n.get(e).length,a)),c=s.reduce((e,t)=>e+t,0)||1,l=e=>"uniform"===t.cellSizing?i/r.length:s[e]/c*i,u=new Map,d=[];let h=t.innerX;for(let e=0;r.length>e;e++)d.push({col:r[e],x:h,w:l(e)}),h+=l(e)+t.columnGap;let f=1;const m=new Map,p=[],g=(e,t,n,o)=>{let r=m.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},m.set(e,r)),r.minX>t-o&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,a)=>{const s=e.map(e=>({id:e.id,r:e.packR})),c=function(e,t,n,o,r,i,a,s){const c=t+o/2,l=n+r/2,u=new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=function(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}(s),f=new Float64Array(d);let m=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);const p=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/p,b=r/Math.ceil(d/p);for(let e=0;d>e;e++){const o=e%p,r=Math.floor(e/p);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;w>e;e++){v.clear();for(let e=0;d>e;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;d>e;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;1>=t;t++)for(let n=-1;1>=n;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;i.length>t;t++){const n=i[t];if(e>=n)continue;let o=g[n]-g[e],r=y[n]-y[e];const a=f[e]+f[n],s=o*o+r*r;if(a*a>s)if(s>1e-9){const t=Math.sqrt(s),i=(a-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;d>e;e++){const i=f[e],a=t+i,s=t+o-i,u=n+i,d=n+r-i;g[e]=s>a?zt(g[e],a,s):c,y[e]=d>u?zt(y[e],u,d):l}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}(s,n,o,r,i,t.packPadding,t.iterations,f++);let l=1/0,d=1/0,h=-1/0,m=-1/0;for(const e of s){const t=c.get(e.id);u.set(e.id,{px:t.px,py:t.py}),g(a,t.px,t.py,e.r),l>t.px-e.r&&(l=t.px-e.r),t.px+e.r>h&&(h=t.px+e.r),d>t.py-e.r&&(d=t.py-e.r),t.py+e.r>m&&(m=t.py+e.r)}return Number.isFinite(l)?{x:l-Ns,y:d-Ns,w:h-l+2*Ns,h:m-d+2*Ns}:null};if("banded"===t.rowMode){const i=new Map;for(const t of e)i.set(t.row,(i.get(t.row)??0)+1);const s=t.rowOrder.filter(e=>i.has(e)),c=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),l=s.map(e=>Math.pow(i.get(e),a)),h=l.reduce((e,t)=>e+t,0)||1,f=new Map;let p=t.innerY+t.innerH;for(let e=0;s.length>e;e++){const n="uniform"===t.cellSizing?c/s.length:l[e]/h*c,o=p-n;f.set(s[e],{y:o,h:n}),p=o-t.rowGap}r.forEach((e,t)=>{const r=o(n.get(e),e=>e.row);for(const e of s){const n=r.get(e),o=f.get(e);n&&o&&y(n,d[t].x,o.y,d[t].w,o.h,e)}});const g=[],x=new Map;for(const e of s){const t=f.get(e);x.set(e,t.y+t.h/2);const n=m.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-Ns,y:n.minY-Ns,w:n.maxX-n.minX+2*Ns,h:n.maxY-n.minY+2*Ns})}return{positions:u,enclosures:g,colBands:d,rowLabelY:x}}const x=new Map;r.forEach((e,r)=>{const i=o(n.get(e),e=>e.row),s=t.rowOrder.filter(e=>i.has(e)),c=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),l=s.map(e=>Math.pow(i.get(e).length,a)),u=l.reduce((e,t)=>e+t,0)||1;let h=t.innerY+t.innerH;s.forEach((e,n)=>{const o="uniform"===t.cellSizing?c/s.length:l[n]/u*c,a=h-o,f=y(i.get(e),d[r].x,a,d[r].w,o,e);if(f){p.push(f);const t=x.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,x.set(e,t)}h=a-t.rowGap})});const b=new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:u,enclosures:p,colBands:d,rowLabelY:b}}(q,{columnOrder:le,rowOrder:ue,innerX:L,innerY:T,innerW:R,innerH:W,rowMode:M,cellSizing:v,proportionExponent:k,columnGap:$,rowGap:A,packPadding:S,iterations:I})),fe=e.selection,me=fe?.isActive?fe.predicate:null,pe=n.highlight??null,ge=n.dimOpacity??.16,ye=n.markStroke,xe=n.markStrokeWidth??0,be=n.markerColor??"#ffffff",we=n.iconColor??"rgba(255,255,255,0.92)",Me=n.iconStrokeWidth??1,ve=n.iconScale??.72,ke=[],$e=[],Ae=[];for(const e of q){const t=he.positions.get(e.id);if(!t)continue;const n=a(e.datum,{highlight:pe,predicate:me,dimOpacity:ge}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:U(e.colorKey,H(e.shadeVal)),opacity:n,...ye?{stroke:ye,strokeWidth:xe}:{}},datum:e.datum,id:e.id,label:e.id+""};if(ke.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ve,r=P(e.iconShape,100);Ae.push({x:t.px,y:t.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:e.iconShape,opacity:n})}e.marker&&n>ge+.001&&$e.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Se=[];if(n.callouts&&n.callouts.length>0){const e=n.calloutColor??"var(--semiotic-text, #f4f4f8)",t=r.y+r.height-(z>0?.45*z:9),o=[];for(let e=0;n.callouts.length>e;e++){const t=n.callouts[e],r=q.find(e=>e.datum[t.field]+""==t.value+"");if(!r)continue;const i=he.positions.get(r.id);i&&o.push({c:t,ci:e,px:i.px,py:i.py,markR:Math.sqrt(r.size/Math.PI)})}const i=o.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),a=new Map;i.forEach((e,t)=>{a.set(e.ci,L+(t+.5)/i.length*R)});for(const n of o){const o=n.c;let i=a.get(n.ci)??n.px,s=t;const c=o.connector??(a.has(n.ci)?"elbow":"straight");"object"==typeof o.at&&o.at?(i=o.at.x,s=o.at.y):"number"==typeof o.at&&(s=r.y+o.at*r.height),Se.push({keyId:"callout-"+n.ci,markX:n.px,markY:n.py,labelX:i,labelY:s,label:o.label,connector:c,markRadius:Math.max(n.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const Ie=function(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e);return(0,Is.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,n)=>nt({keyId:"enc-"+n,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity})),t.iconMarks.length>0&&(0,Is.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>(0,Is.jsx)("path",{d:O(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+n))}),t.markerDots.length>0&&(0,Is.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>(0,Is.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+n))}),t.showColumnHeaders&&e.colBands.map((e,o)=>it({keyId:"col-"+o,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor})),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>it({keyId:"row-"+e,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>ct(e))]})}(he,{markerDots:$e,markerColor:be,iconMarks:Ae,iconColor:we,iconStrokeWidth:Me,callouts:Se,plot:r,showEnclosures:C,showColumnHeaders:j,showRowLabels:N,enclosureColor:n.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:n.enclosureRadius??9,enclosureOpacity:n.enclosureOpacity??.5,enclosureWidth:n.enclosureWidth??1.5,headerColor:n.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:n.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:n.headerFontSize??13,labelFontSize:n.labelFontSize??11,headerY:r.y+.62*F,labelX:r.x+E-10,columnLabel:n.columnLabel,rowLabel:n.rowLabel});return{sceneNodes:ke,overlays:Ie}},Ns=4,Fs=ia(require("react")),Es=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const i=e(n.categoryAccessor),a=e(n.stackBy),s=e=>{const t="function"==typeof n.valueAccessor?n.valueAccessor(e):e[n.valueAccessor],o=Number(t);return Number.isFinite(o)&&o>0?o:0},c=n.gutter??2,l="string"==typeof n.categoryAccessor?n.categoryAccessor:"category",u="string"==typeof n.stackBy?n.stackBy:"stack",d="string"==typeof n.valueAccessor?n.valueAccessor:"value",h=(e,t,n)=>r(o=>{o("category",e),o("stack",t),o("value",n),"category"!==l&&o(l,e),"stack"!==u&&o(u,t),"value"!==d&&o(d,n)}),f=!1!==n.showCategoryLabels,m=Math.max(0,o.height-(n.labelPadding??(f?22:0))),p=[],g=new Map,y=[],x=new Set,b=new Map;for(const e of t.data){const t=i(e)+"",n=a(e)+"",o=s(e);g.has(t)||(p.push(t),g.set(t,0),b.set(t,new Map)),x.has(n)||(x.add(n),y.push(n)),g.set(t,(g.get(t)??0)+o);const r=b.get(t);r.set(n,(r.get(n)??0)+o)}const w=n.categoryOrder?Ot(n.categoryOrder,p,e=>g.has(e)):p,M=n.stackOrder?Ot(n.stackOrder,y,()=>!0):y,v=w.reduce((e,t)=>e+(g.get(t)??0),0);if(0>=v)return{nodes:[]};const k=Math.max(0,o.width-c*Math.max(0,w.length-1)),$=[],A=[];let S=o.x;for(const e of w){const n=g.get(e)??0,r=n/v*k;if(0>=r)continue;A.push({cat:e,x:S,w:r});const i=b.get(e);let a=o.y;for(const o of M){const s=i.get(o)??0;if(0>=s)continue;const c=s/n*m;$.push({type:"rect",x:S,y:a,w:r,h:c,style:{fill:t.resolveColor(o),stroke:"none"},datum:h(e,o,s),group:o}),a+=c}S+=r+c}return{nodes:$,overlays:f&&A.length>0?function(e,t,n){const o=e.map((e,o)=>it({keyId:"marimekko-label-"+o,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return Fs.createElement(Fs.Fragment,null,...o)}(A,o.y+m+4,`var(--semiotic-text, ${t.theme.semantic.text??"currentColor"})`):null}},zs=ia(require("react")),Ls=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height||0===t.data.length)return{nodes:[]};const i=n.rowHeight??28,a=n.rowGap??12,s=!1!==n.showLabels,c=s?n.labelWidth??120:0,l=!1!==n.showTicks,u=l?14:0,d=n.tickFormat??(e=>e.toLocaleString()),h=o.x+c,f=Math.max(0,o.width-c);if(0>=f)return{nodes:[]};const m=e(n.categoryAccessor),p=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},g=e=>p("function"==typeof n.valueAccessor?n.valueAccessor(e):e[n.valueAccessor]),y=e=>p("function"==typeof n.targetAccessor?n.targetAccessor(e):e[n.targetAccessor]),x=e=>{const t="function"==typeof n.rangesAccessor?n.rangesAccessor(e):e[n.rangesAccessor];return Array.isArray(t)?t.map(p).sort((e,t)=>e-t):[]},b="string"==typeof n.categoryAccessor?n.categoryAccessor:"metric",w="string"==typeof n.valueAccessor?n.valueAccessor:"value",M="string"==typeof n.targetAccessor?n.targetAccessor:"target",v=n.actualColor??t.theme.semantic.primary??"#3b6cb1",k=t.theme.semantic.text??"currentColor",$=n.targetColor??`var(--semiotic-text, ${k})`,A=[`var(--semiotic-surface, ${t.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${t.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${t.theme.semantic.border??"#a3a8af"})`],S=`var(--semiotic-text, ${k})`,I=`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,C=[],j=[];for(let e=0;t.data.length>e;e++){const n=t.data[e],s=x(n),c=g(n),l=y(n),d=Math.max(c,l,...s.length?s:[0]);if(0>=d)continue;const p=o.y+e*(i+a+u);if(p+i+u>o.y+o.height)break;j.push({yTop:p,label:m(n),actual:c,target:l,maxVal:d});const k=e=>h+e/d*f,S=m(n),I=e=>r(t=>{t("metric",S),"metric"!==b&&t(b,S),e(t)});let N=h;for(let e=0;s.length>e;e++){const t=k(s[e]),n=t-N;n>0&&C.push({type:"rect",x:N,y:p,w:n,h:i,style:{fill:A[Math.min(e,A.length-1)],stroke:"none"},datum:I(t=>{t("range",e),t("rangeValue",s[e]),t("kind","range")}),group:"range-"+e}),N=t}const F=Math.max(6,Math.floor(.45*i));C.push({type:"rect",x:h,y:p+(i-F)/2,w:k(c)-h,h:F,style:{fill:v,stroke:"none"},datum:I(e=>{e("value",c),e("kind","actual"),"value"!==w&&e(w,c)}),group:"actual"});const E=3,z=Math.floor(.8*i);C.push({type:"rect",x:k(l)-E/2,y:p+(i-z)/2,w:E,h:z,style:{fill:$,stroke:"none"},datum:I(e=>{e("target",l),e("kind","target"),"target"!==M&&e(M,l)}),group:"target"})}const N=[];for(let e=0;j.length>e;e++){const t=j[e];if(s&&N.push(it({keyId:"bullet-label-"+e,text:t.label,x:o.x+c-8,y:t.yTop+i/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:S})),l){const n=5,o=t.yTop+i+2;for(let r=0;n>r;r++){const i=t.maxVal*r/(n-1),a=h+i/t.maxVal*f;N.push(zs.createElement("line",{key:`bullet-tick-${e}-${r}`,x1:a,x2:a,y1:o,y2:o+3,stroke:I,strokeWidth:1}),it({keyId:`bullet-ticktext-${e}-${r}`,text:d(i),x:a,y:o+12,anchor:0===r?"start":r===n-1?"end":"middle",baseline:"auto",fontSize:10,color:I}))}}}return{nodes:C,overlays:N.length>0?zs.createElement(zs.Fragment,null,...N):null}},Os=ia(require("react")),Ts=require("d3-scale"),Ps=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,a=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(i>e&&(i=e),e>a&&(a=e))}if(Number.isFinite(i)&&Number.isFinite(a))if(i===a){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,a+e]}else r[n]=[i,a];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,c=i?18:8,l=o.map(e=>(0,Ts.scaleLinear)().domain(r[e]).range([n.y+n.height-c,n.y+s])),u=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),d=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,h=t.opacity??.45,f=t.strokeWidth??1.25,m=e.theme.semantic.primary??"#3b6cb1",p=t.dimmedOpacity??.08,g=t.highlightFn,y=[],x=[];for(const n of e.data){const r=d?e.resolveColor(d(n)+""):m,i=!g||g(n),s=a(n,{predicate:g,baseOpacity:h,dimOpacity:p,brighten:.4}),c=i?x:y;for(let e=0;o.length-1>e;e++){const t=Number(n[o[e]]),a=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(a))continue;const d={type:"connector",x1:u[e],y1:l[e](t),x2:u[e+1],y2:l[e+1](a),style:{stroke:r,strokeWidth:g&&i?f+.75:f,opacity:s,fill:"none"},datum:n};c.push(d)}if(t.showPoints)for(let e=0;o.length>e;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:u[e],y:l[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};c.push(i)}}let b=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,a=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+s,f=n.y+n.height-c,m=[];for(let e=0;o.length>e;e++){const c=o[e],p=u[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,c)?t.tickFormat[c]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();m.push(Os.createElement("line",{key:"pc-axis-line-"+e,x1:p,x2:p,y1:h,y2:f,stroke:i,strokeWidth:1})),m.push(it({keyId:"pc-axis-label-"+e,text:c,x:p,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:a}));const[x,b]=r[c],w=5;for(let t=0;w>t;t++){const n=x+(b-x)*t/(w-1),o=l[e](n);m.push(Os.createElement("line",{key:`pc-tick-${e}-${t}`,x1:p-3,x2:p+3,y1:o,y2:o,stroke:i,strokeWidth:1}),it({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:p+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}b=Os.createElement(Os.Fragment,null,...m)}return{nodes:y.concat(x),overlays:b}},Rs=require("react/jsx-runtime"),Ws=1.75,qs="#222222",Ds=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height)return{nodes:[]};const r=e(n.categoryAccessor??"name"),i=e(n.teaVolumeAccessor??"teaVolume"),a=e(n.bobaVolumeAccessor??"bobaVolume"),s=e(n.iceVolumeAccessor??"iceVolume"),c=e(n.cupHeightAccessor??"cupHeight"),l=e(n.cupTopRadiusAccessor??"cupTopRadius"),h=e(n.cupBottomRadiusAccessor??"cupBottomRadius"),f=e(n.bobaRadiusAccessor??"bobaRadius"),m=n.cupWidthRatio??.82,p=t.scales.o,g=p.bandwidth(),y=Math.max(1,o.height-26-8),x=o.y+8,b=[],w=[];for(const e of t.data){const n=r(e)+"",o=p(n);if(null==o)continue;const M={height:Yt(c(e),15.5),topRadius:Yt(l(e),4.75),bottomRadius:Yt(h(e),3.75)},v=Yt(f(e),.6),k=Math.max(0,Yt(i(e),450)),$=Math.max(0,Yt(a(e),110)),A=Math.max(0,Yt(s(e),135)),S=Math.PI*v*v,I=Math.floor($/S),C=I*S,j=Math.floor(A/5.359375),N=j*Ws*Ws*Ws,F=k+C+N,E=Rt(M,F),z=Math.min(M.height,Math.max(0,E)),L=Tt(M,z),{pearls:O,layers:T}=Dt(M,v,I),P=z,R=Bt(M,T*v*2,P,j),W=M.height-20.32,q=Math.min(0,W),D=Math.min(g*m/(2*(M.topRadius+1)),y/(M.height-q)),B=o+g/2,Y=e=>B+e*D,G=e=>x+(e-q)*D,V=Y(-(M.topRadius+1)),H=Y(M.topRadius+1),_=G(q),X=G(M.height),U=u({name:n,teaVolume:k,bobaVolume:Math.round(C),iceVolume:Math.round(N),totalVolume:Math.round(F),numBobas:I,numIce:j,kind:"boba cup"});b.push({type:"rect",x:V,y:_,w:Math.max(1,H-V),h:Math.max(1,X-_),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:U,group:n,_transitionKey:"boba-"+d(n)});const K=M.height-P,Q=d(n),Z=t.resolveColor(n);w.push((0,Rs.jsxs)("g",{children:[k>0?(0,Rs.jsx)("path",{d:`M${Y(-L)},${G(K)} L${Y(-M.bottomRadius)},${G(M.height)} L${Y(M.bottomRadius)},${G(M.height)} L${Y(L)},${G(K)} z`,fill:"#D2B799"}):null,O.map((e,t)=>(0,Rs.jsx)("circle",{cx:Y(e.x),cy:G(e.z),r:v*D,fill:"#222222",opacity:.5},"p-"+t)),R.map((e,t)=>(0,Rs.jsx)("rect",{x:Y(e.cx)-.95*Ws*D/2,y:G(e.cy)-.95*Ws*D/2,width:.95*Ws*D,height:.95*Ws*D,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${Y(e.cx)} ${G(e.cy)})`},"i-"+t)),(0,Rs.jsx)("path",{d:`M${Y(-M.topRadius)},${G(0)} L${Y(-M.bottomRadius)},${G(M.height)} L${Y(M.bottomRadius)},${G(M.height)} L${Y(M.topRadius)},${G(0)}`,fill:"none",stroke:qs,strokeWidth:2.5}),(0,Rs.jsx)("line",{x1:Y(-(M.topRadius+1)),y1:G(0),x2:Y(M.topRadius+1),y2:G(0),stroke:qs,strokeWidth:3,strokeLinecap:"round"}),k>0?(0,Rs.jsx)("path",{d:`M${Y(-.635)},${G(W)} L${Y(-.635)},${G(M.height-.4)} L${Y(.635)},${G(M.height-1.27-.4)} L${Y(.635)},${G(W)} z`,fill:"#4F91CB",stroke:qs,strokeWidth:1,opacity:.78}):null,(0,Rs.jsx)("text",{x:B,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),(0,Rs.jsx)("text",{x:B,y:X+30,textAnchor:"middle",fontSize:10,fill:Z,children:`${I} pearls · ${Math.round(F)} cm³`})]},"boba-"+Q))}return{nodes:b,overlays:(0,Rs.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:w})}},Bs=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Ys=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),Gs=1,Vs=32,Hs=6,_s=4,Xs=8,Us=72,Ks=30,Qs=-30,Zs=8,Js=480,ec=3,tc={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},nc=["naturalGas","coal","nuclear","hydro","wind","solar","other"],oc={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},rc={tight:5,watch:12,comfortable:20},ic=ia(require("react")),ac=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]>e)n=this.count++,n===this.capacity&&this.grow();else{let t=1;for(;this.capacity>t;)t*=2,this.tree[t]>e&&t++;n=t-this.capacity}let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return n>=t||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},sc=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length||!t?.domain)return{nodes:[]};const o=An(t.laneAccessor),r=An(t.startAccessor),i=An(t.endAccessor),a=t.idAccessor?An(t.idAccessor):null,s=t.unit??0,c=t.barGap??1.5,l=Math.max(0,t.minBarWidth??2),u=t.minBarHeight??3.5,d=t.maxBarHeight??10,h=t.lanePadding??7,f=t.cornerRadius??2,m=t.bottomInset??0,p=t.color??((t,n)=>e.resolveColor(n)),[g,y]=t.domain,x=y-g||1,b=e=>n.x+(e-g)/x*n.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(o))]),v=Math.max(0,n.height-m)/Math.max(1,M.length),k=e=>b(r(e)),$=e=>Math.max(k(e)+l,b(i(e)+s)),A=[];M.forEach((t,r)=>{const i=n.y+r*v,s=e.data.filter(e=>o(e)===t);if(0===s.length)return;const{packed:l,trackCount:m}=kn(s,{start:k,end:$}),g=new Map,y=new Map;for(const{item:e,track:t}of l){const n=y.get(t);n?n.push(e):y.set(t,[e])}for(const e of y.values()){e.sort((e,t)=>k(e)-k(t));for(let t=0;e.length-1>t;t++)g.set(e[t],k(e[t+1]))}const x=(v-2*h)/m,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:e,track:n}of l){const o=k(e),r=g.get(e),s=$(e)-o;A.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+s>r-1?Math.max(1,r-1-o):s,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:p(e,t),stroke:"none"},datum:e,group:t,_transitionKey:a?a(e)+"":void 0})}});const S=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,I=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,C=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,j=[];(t.periods??[]).forEach((e,t)=>{const o=b(e.start),r=Math.max(1,b(e.end+s)-o);j.push(ic.createElement("rect",{key:"period-"+t,x:o,y:n.y,width:r,height:n.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&j.push(it({keyId:"period-label-"+t,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:I}))});const N=!1!==t.showLaneLabels,F=t.laneLabelGap??12;if(M.forEach((e,t)=>{const o=n.y+t*v;j.push(ic.createElement("line",{key:"lane-sep-"+t,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:C,opacity:.45})),N&&j.push(it({keyId:"lane-label-"+t,text:e,x:n.x-F,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==t.showAxis){const e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));j.push(st({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:I}))}return{nodes:A,overlays:ic.createElement(ic.Fragment,null,...j)}},cc={width:60,height:34},lc=e=>{const{plot:o}=e.dimensions;if(0>=o.width||0>=o.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const r=e.config.fixedAxis??"y",{positioned:i,byId:a}=On(e.nodes,e.edges,o,e.config),s=i.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),c=[];e.edges.forEach((o,i)=>{const s=a.get((l=o,("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(l):t(l,e.config.sourceAccessor??"source",void 0))+""));var l;const u=a.get((n=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(n):t(n,e.config.targetAccessor??"target",void 0))+"")(o));if(!s||!u)return;const{from:d,to:h}=Cn({cx:s.x,cy:s.y,width:s.width,height:s.height},{cx:u.x,cy:u.y,width:u.width,height:u.height},{orientation:"y"===r?"vertical":"horizontal"});c.push({type:"curved",pathD:Sn(d,h,{orientation:"y"===r?"vertical":"horizontal",bend:jn(i,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:n(o)??o})});const l=i.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:s,sceneEdges:c,labels:l}},uc=require("react/jsx-runtime"),dc=1.15,hc={a:.556,b:.556,c:.5,d:.556,e:.556,f:.278,g:.556,h:.556,i:.222,j:.222,k:.5,l:.222,m:.833,n:.556,o:.556,p:.556,q:.556,r:.333,s:.5,t:.278,u:.556,v:.5,w:.722,x:.5,y:.5,z:.5,"'":.191,"-":.333,".":.278," ":.278},fc=t=>{const n=t.config,{plot:o}=t.dimensions;if(0>=o.width||0>=o.height||0===t.data.length)return{nodes:[]};const i=e(n.textAccessor),a=t=>{const o=Number(e(n.weightAccessor)(t));return Number.isFinite(o)&&o>0?o:0},s=e(n.columnAccessor),c=t=>Number(e(n.segmentAccessor)(t)),l=n.minFontSize??11,u=n.maxFontSize??42,d=n.columnGutter??18,f=n.collisionPadding??2,m=!1!==n.showColumnLabels,p=!1!==n.showSegmentAxis,g=n.segmentTickCount??6,y=n.segmentTickFormat??(e=>Math.round(e)+""),x=n.rotate??0,b=!0===n.repeatWords,w=!1!==n.scaleToFit,M=n.packingDensity??.6,v="string"==typeof n.textAccessor?n.textAccessor:"word",k="string"==typeof n.weightAccessor?n.weightAccessor:"weight",$="string"==typeof n.columnAccessor?n.columnAccessor:"column",A="string"==typeof n.segmentAccessor?n.segmentAccessor:"segment",S=[],I=new Map;let C=1/0,j=-1/0;for(let e=0;t.data.length>e;e++){const n=t.data[e],o=s(n)+"",r=i(n)+"",l=a(n),u=c(n);r&&Number.isFinite(u)&&(I.has(o)||(S.push(o),I.set(o,[])),I.get(o).push({col:o,text:r,weight:l,segment:u,datum:n,dataIndex:e}),C>u&&(C=u),u>j&&(j=u))}if(0===S.length)return{nodes:[]};if(!b)for(const[e,t]of I){const n=new Map;for(const e of t){const t=n.get(e.text);t&&t.weight>=e.weight||n.set(e.text,e)}I.set(e,[...n.values()])}let N=1/0,F=-1/0;for(const e of I.values())for(const t of e)N>t.weight&&(N=t.weight),t.weight>F&&(F=t.weight);if(!Number.isFinite(N))return{nodes:[]};const E=n.columnOrder?[...n.columnOrder.filter(e=>I.has(e)),...S.filter(e=>!n.columnOrder.includes(e))]:S,z=new Map(E.map(e=>[e,n.columnColor?.(e)||t.resolveColor(e)])),[L,O]=n.segmentDomain??[C,j],T=O-L||1,P=F-N||1,R=m?22:0,W=p?52:0,q=o.x+W,D=o.y+R,B=Math.max(0,o.width-W),Y=Math.max(0,o.height-R),G=E.length,V=G>0?Math.max(0,B-d*Math.max(0,G-1))/G:0,H=D+14,_=D+Y-14,X=e=>H+(e-L)/T*(_-H),U=V*Y;let K=1/0,Q=1/0;const Z=E.map((e,t)=>{const o=z.get(e),r=(I.get(e)??[]).map(e=>{const r={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:t,resolvedColumnColor:o},i=n.wordOpacity?Number(n.wordOpacity(r)):1,a=n.wordColor?.(r);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:(s=e.weight,l+Math.sqrt((s-N)/P)*(u-l)),opacity:Number.isFinite(i)?h(i,0,1):0,color:a||o,info:r};var s});if(0===r.length)return null;let i=0;for(const e of r){const t=1.05*Rn(e.text);i+=t*dc*e.baseFont*e.baseFont,Q=Math.min(Q,(V-8-1)/(t*e.baseFont))}return i>0&&(K=Math.min(K,Math.sqrt(M*U/i))),{col:e,colLeft:q+t*(V+d),center:q+t*(V+d)+V/2,rows:r}}).filter(e=>null!==e),J=e=>{const t=[];let n=0;for(const o of Z){if(0>=V)continue;const i=o.colLeft+4,a=o.colLeft+V-4,s=o.rows.map((t,n)=>{const r=Math.max(5,e*t.baseFont),i=`${o.col}::${t.text}::${n}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:r,w:Wn(t.text,r),h:r*dc+2,anchorY:X(t.segment),seed:(Pn(i)-.5)*Math.min(.5*V,80),opacity:t.opacity,color:t.color,info:t.info}}).sort((e,t)=>t.font-e.font||(t.id>e.id?-1:1)),c=[];for(const e of s){const s=e.w/2,l=e.h/2,u=h(o.center+e.seed,i+s,a-s),d=e.anchorY;let m=u,p=h(d,H+l,_-l),g=!1;for(let t=0;2600>t;t++){const n=3.2*Math.sqrt(t),o=2.399963229728653*t,r={x:h(u+n*Math.cos(o),i+s,a-s),y:h(d+n*Math.sin(o),H+l,_-l),w:e.w,h:e.h};if(!qn(r,c,f)){m=r.x,p=r.y,g=!0;break}}g||n++,c.push({x:m,y:p,w:e.w,h:e.h});const y=Math.sqrt((e.weight-N)/P),b=x>0?2*(Pn(e.id+"r")-.5)*x:0;t.push({id:e.id,text:e.text,x:m,y:p,fontSize:e.font,rotation:b,color:e.color,opacity:e.opacity,datum:r(t=>{for(const n of Object.keys(e.info.datum))t(n,e.info.datum[n]);t("word",e.text),t("weight",e.weight),t("column",o.col),t("segment",e.segment),"word"!==v&&t(v,e.text),"weight"!==k&&t(k,e.weight),"column"!==$&&t($,o.col),"segment"!==A&&t(A,e.segment),t("__strength",.5+.5*y)})})}}return{placed:t,unplaced:n}};let ee=w?Math.min(1,K,Q):Math.min(1,Q),te=J(ee);if(w)for(let e=0;6>e&&te.unplaced>0&&ee>.1;e++)ee*=.88,te=J(ee);const ne=te.placed.filter(e=>e.opacity>0);return{nodes:ne.map(e=>{const t=Wn(e.text,e.fontSize)/2,n=e.fontSize*dc/2;return{type:"rect",x:e.x-t,y:e.y-n,w:2*t,h:2*n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:(0,uc.jsxs)("g",{className:"semiotic-word-trails",children:[p&&Dn({x:o.x+W-10,yTop:H,yBot:_,segLo:L,segHi:O,segToY:X,tickCount:g,tickFormat:y,color:`var(--semiotic-text-secondary, ${t.theme.semantic.textSecondary??"#888"})`,label:n.segmentAxisLabel,labelX:o.x}),m&&E.map((e,t)=>V>0?(0,uc.jsx)("text",{x:q+t*(V+d)+V/2,y:o.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:z.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ne.map(e=>(0,uc.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===n.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},"wt-"+e.id))]})}},mc={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},pc=8,gc=Un,yc=2*Math.PI,xc=[40,40],bc=[.5,.5],wc=require("react/jsx-runtime"),Mc="var(--semiotic-text, currentColor)",vc=8,kc=new Set(["rows"]),$c=class{constructor(e){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(e.data),n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(tr(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{const e=1===this.pending.size;this.pending.delete(n),t?.removeEventListener("abort",i),r(tr(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Ac=4e4,Sc={},Ic=class{constructor(e=function(){const e="string"==typeof Sc.url&&Sc.url?new URL("./forceLayoutWorker.js",Sc.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new $c({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=function(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}(t);return o?{requestId:n,ok:!1,error:nr(o)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},Cc=function(){let e=null;return{get:()=>(e&&!e.isDead||(e=new Ic),e),resetForTest:()=>{if(e){try{e.terminate()}catch{}e=null}}}}(),jc=[.1,.5,.9],Nc=1e6,Fc=12,Ec=require("react/jsx-runtime"),zc={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"}},Lc=6.2,Oc={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1};
|
|
1
|
+
function e(e,t=[],n){const o=void 0===n?void 0:new Set("string"==typeof n?[n]:n),r=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&o?.has(e.partition)),i=new Set(r.map(e=>e.id)),s=new Set(r.map(e=>e.entityId)),a=new Map;let c=0;for(const t of e){if(void 0!==n&&"string"==typeof t.roles.occurrence&&!i.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===n&&(c+=t.entityCount);for(const[t,o]of e)(void 0===n||s.has(t))&&a.set(t,o)}return[...a.values()].reduce((e,t)=>e+t,c)}function t(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function n(){return Object.create(null)}function o(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function r(e,t,n){return t.has(e)?"node":(function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(o=n.nodeIdsBySection,r=e)?o[r]:void 0)?"section":"global";var o,r}function i(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function s(t){const n=t.spec.comparison;if(!n)return;const o=n.partitions.map(o=>{const r=i(t.ledger,n.denominatorMeasureId,o)?.value??0,s={};return s["repeated-state-episode"]=e(t.motifs.matches.filter(e=>"repeated-state-episode"===e.template),t.source.occurrences,o),{partition:o,assigned:r,motifUsers:s,outcomes:{purchases:i(t.ledger,"purchases",o)?.value??0}}});return{partitions:[...n.partitions],denominatorMeasureId:n.denominatorMeasureId,referencePartition:n.referencePartition,rows:o}}function a(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return i(e.ledger,n,t)?.value}function c(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function l(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return!(!o?.sectionId||!t.coordinate.sectionIds.includes(o.sectionId))}function u(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function d(e,t){return e.sectionByNode.get(t)}function h(e,t){const n=new Set,o=[];for(const r of t){const t=d(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function f(e,t,n){return e.pairs.get(t)?.get(n)??[]}function p(e){return e.entityCount??1}function m(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=p(r));return{entityIds:n,entityCount:o}}function g(e,t,o,r,i,s){if(2>o.length)return;const{kept:a,truncation:c}=function(e,t){return null!=t&&e.length>t?{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}:{kept:e}}(o,s),l=[t,...a],u=[];for(const n of a){const o="fan-out"===e?f(i,t,n):f(i,n,t);u.push(...o)}const d=h(i,[t,...o]),p=m(r.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:a}:{destination:t,sources:a},nodePath:l,edgeIds:u,startSectionId:d[0],completionSectionId:d[d.length-1],intersectSectionIds:d,entityIds:p.entityIds,entityWeights:n(),entityCount:p.entityCount,flags:{occurrence:p.entityIds.length>0,temporal:!1,trajectorySupported:p.entityIds.length>0,enriched:!1},truncation:c}}function y(e,t,n){return 1===t.length&&1===n.length}function x(e){return e.entityCount??1}function b(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function w(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=function(e,t){const n=new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),u=new Map([[r,r]]),d=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=u.get(e):t=u.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>u.has(e)).reduce(d);u.get(e)!==t&&(u.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>u.has(t)?[[e,u.get(t)===r?null:n[u.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>u.has(t)),unreachableNodeIds:n.filter((e,t)=>!u.has(t))}}function M(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function v(e,i,a={}){const c=function(e,o){const r=[];e.schemaVersion!==Ps&&M(r,"schema-version","expected schemaVersion "+Ps),e.relations.directed&&!0===e.relations.edgeIdRequired||M(r,"relations","Phase 1 requires directed edges with ids"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&M(r,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&M(r,"coordinate","Phase 1 kernel uses ordinal sections");const i=n();for(const n of o.nodes)n.id?(i[n.id]&&M(r,"duplicate-node","duplicate node id",n.id),t(i,n.id,!0),"ordinal"===e.coordinate.kind&&n.sectionId&&!e.coordinate.sectionIds.includes(n.sectionId)&&M(r,"section-membership",`node section ${n.sectionId} is not in the coordinate`,n.id)):M(r,"node-id","node is missing id");const s=n();for(const e of o.edges)e.id?(s[e.id]&&M(r,"duplicate-edge","duplicate edge id",e.id),t(s,e.id,!0),i[e.source]||M(r,"dangling-source","edge source is not a node",e.id),i[e.target]||M(r,"dangling-target","edge target is not a node",e.id)):M(r,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])i[t]||M(r,"missing-root","display root is not a node",t);const a=e.forest.requiredPaths;if(a)if("directed-admitted"!==a.relationScopeId&&M(r,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(a.roots)&&0!==a.roots.length)for(const e of a.roots)i[e]||M(r,"required-path-roots","required-path root is not a node",e);else M(r,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&M(r,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(2>e.comparison.partitions.length&&M(r,"comparison","comparison requires at least two partitions"),e.measures[e.comparison.denominatorMeasureId]||M(r,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(c=e.measures)||"object"!=typeof c||Array.isArray(c))M(r,"measures","measures must be an object");else for(const[t,n]of Object.entries(e.measures))"rate"!==n.unitKind||n.timeDenominator||M(r,"rate-denominator","rate measures require a timeDenominator",t);var c;for(const t of o.measureValues)e.measures[t.measureId]?Number.isFinite(t.value)||M(r,"non-finite-measure","measure value is not finite",t.measureId):M(r,"unknown-measure","measureValue refers to an undeclared measure",t.measureId);for(const e of o.occurrences??[])if(e.id&&e.entityId){void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||0>e)||M(r,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)i[t]||M(r,"occurrence-node","occurrence path references a missing node",e.id)}else M(r,"occurrence","occurrence needs id and entityId");return{ok:r.every(e=>"fatal"!==e.severity),issues:r}}(e,i);if(!c.ok)return{ok:!1,issues:c.issues};const v=a.generation??1,k=function(e,o){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:n()};const r=n();for(const n of e.coordinate.sectionIds)t(r,n,[]);for(const e of o.nodes){if(!e.sectionId)continue;const t=r[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:r}}(e,i),$=function(e,o){const r=e.motifs.matchBudget,i=function(e){const t=new Map(e.nodes.map(e=>[e.id,new Set])),n=new Map(e.nodes.map(e=>[e.id,new Set])),o=new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}(o),s=[];for(const e of o.nodes){const t=g("fan-out",e.id,i.outgoing.get(e.id)??[],o,i,r);t&&s.push(t);const n=g("fan-in",e.id,i.incoming.get(e.id)??[],o,i,r);n&&s.push(n)}s.push(...function(e,t){const o=t.incoming,r=t.outgoing,i=[];for(const s of e.nodes){const a=o.get(s.id)??[],c=r.get(s.id)??[];if(1!==c.length)continue;const l=1===a.length&&y(0,o.get(a[0])??[],r.get(a[0])??[]);if(y(0,a,c)&&l)continue;const u=[s.id];let d=s.id;const p=new Set([d]);for(;;){const e=(r.get(d)??[])[0];if(!e||p.has(e))break;if(u.push(e),p.add(e),!y(0,o.get(e)??[],r.get(e)??[]))break;d=e}if(2>u.length)continue;const g=[];for(let e=0;u.length-1>e;e++)g.push(...f(t,u[e],u[e+1]));const x=h(t,u),b=m(e.occurrences??[],u[0]);i.push({id:"serial-chain:"+u.join(">"),template:"serial-chain",roles:{nodes:u,start:u[0],end:u[u.length-1]},nodePath:u,edgeIds:g,startSectionId:x[0],completionSectionId:x[x.length-1],intersectSectionIds:x,entityIds:b.entityIds,entityWeights:n(),entityCount:b.entityCount,flags:{occurrence:b.entityIds.length>0,temporal:!1,trajectorySupported:b.entityIds.length>0,enriched:!1}})}return i}(o,i)),s.push(...function(e,o){const r=[];for(const i of e.occurrences??[]){if(i.missingPrehistory)continue;const e=new Map,s=new Set;for(const[a,c]of i.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,a);continue}if(s.has(c))continue;s.add(c);const u=i.nodePath.slice(l,a+1),f=h(o,u),m=n();t(m,i.entityId,p(i)),r.push({id:`repeated-state-episode:${i.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:i.id},nodePath:u,edgeIds:[],startSectionId:d(o,u[0]),completionSectionId:d(o,u[u.length-1]),intersectSectionIds:f,entityIds:[i.entityId],entityWeights:m,entityCount:p(i),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return r}(o,i)),function(e,o){const r=o.occurrences??[];if(0!==r.length)for(const o of e){if("repeated-state-episode"===o.template)continue;const e=o.nodePath,i=n();for(const n of r)n.missingPrehistory||e.some(e=>n.nodePath.includes(e))&&t(i,n.entityId,p(n));const s=Object.keys(i);o.entityIds=s,o.entityWeights=i,o.entityCount=s.reduce((e,t)=>e+(i[t]??0),0),o.flags={...o.flags,occurrence:s.length>0,trajectorySupported:s.length>0}}}(s,o);const a=[];for(const e of o.occurrences??[])e.missingPrehistory&&(a.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),a.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const c=Fs.filter(e=>!Os.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:s,incompleteCandidates:a,unsupportedTemplates:c}}(e,i),S=function(e,o){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return function(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=function(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),u=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!u.has(e.id)).map(e=>e.id)}}}(o,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const r=o.edges.map(e=>e.id),i=e.forest.display.rankingPolicyId??"main-transport",{mode:s,order:a}=function(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}(i),c=t=>l(o,e,t.source)&&l(o,e,t.target),d=new Map;for(const e of o.nodes)d.set(e.id,[]);for(const e of o.edges)d.has(e.target)||d.set(e.target,[]),d.get(e.target).push(e);const h=n(),f=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:o.nodes[0]?[o.nodes[0].id]:[],p=new Set(f);for(const e of o.nodes){if(p.has(e.id))continue;const n=u(d.get(e.id)??[],a),o=n.find(e=>c(e))??n[0];o&&t(h,e.id,o.id)}let m;m="tree-only"===s?Object.values(h):o.edges.filter(e=>c(e)).map(e=>e.id);const g=new Set(m),y=r.filter(e=>!g.has(e));return{forest:{kind:"rooted-backbone",roots:[...f],rankingPolicyId:i,backboneEdgeIds:m,primaryParentEdgeIdByNode:h},residual:{residualEdgeIds:y,originalEdgeIds:r}}}(e,i);!function(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw Error("original edge IDs != backbone ⊎ residual")}(S.residual,S.forest);const I=function(e,o,i){const s=[],a=new Set(o.nodes.map(e=>e.id)),c=new Set;for(const t of o.measureValues){const n=e.measures[t.measureId];if(!n)continue;const o=r(t.subjectId,a,i);s.push({measureId:t.measureId,subjectId:t.subjectId,subjectKind:o,value:t.value,status:t.status,unitKind:n.unitKind,countUnit:n.countUnit,timeDenominator:n.timeDenominator}),"section"===o&&c.add(`${t.measureId}\0${t.subjectId}`)}const l=n();for(const e of o.nodes)t(l,e.id,e);const u=n(),d=n();for(const e of s){if("node"!==e.subjectKind)continue;const t=l[e.subjectId];if(!t?.sectionId)continue;const n=`${e.measureId}\0${t.sectionId}`;c.has(n)||(u[n]=(u[n]??0)+e.value,"exact"!==e.status?d[n]=e.status:d[n]||(d[n]="exact"))}for(const[t,n]of Object.entries(u)){const o=t.split("\0"),r=o[0],i=e.measures[r];i&&s.push({measureId:r,subjectId:o[1],subjectKind:"section",value:n,status:d[t]??"exact",unitKind:i.unitKind,countUnit:i.countUnit,timeDenominator:i.timeDenominator})}return{entries:s}}(e,i,k),A=function(e,o){const r=n();for(const n of e.nodes)t(r,n.id,n.completeness??"known");const i=n();for(const e of o.unsupportedTemplates)t(i,e,"unsupported-template");if(o.incompleteCandidates.length>0){const e=new Set(o.incompleteCandidates.map(e=>e.template));for(const n of e)t(i,n,"incomplete")}const s=o.matches.find(e=>e.truncation),a={nodes:r,motifs:i,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return s?.truncation&&(a.truncation={disclosed:!0,template:s.template,omitted:s.truncation.omitted}),a}(i,$),C=function(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;e.length-1>o;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}(i),j=function(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}(e,i,v),N="observed-prefix"===e.forest.display.kind||(i.occurrences?.length??0)>0?function(e,r={}){function i(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const s={id:"",stateId:"",prefix:[],children:new Map,occurrenceIds:[],entityCount:0,partitionCounts:new Map};for(const t of e){if(t.missingPrehistory)continue;const e=x(t);let n=s;n.occurrenceIds.push(t.id),n.entityCount+=e,b(n,t.partition,e);for(const r of t.nodePath){const i=[...n.prefix,r],s=o(i,i.length-1);let a=n.children.get(r);a||(a={id:s,stateId:r,prefix:i,children:new Map,occurrenceIds:[],entityCount:0,partitionCounts:new Map},n.children.set(r,a)),a.occurrenceIds.push(t.id),a.entityCount+=e,b(a,t.partition,e),n=a}}const a=[],c=[],l=r.referencePartition;return function e(o,r){if(o.id){const e=n();for(const[n,r]of o.partitionCounts)t(e,n,r);a.push({id:o.id,stateId:o.stateId,prefix:o.prefix,parentId:r,childIds:i(o).map(e=>o.children.get(e).id),entityCount:o.entityCount,occurrenceIds:[...o.occurrenceIds],partitionCounts:e}),c.push(o.id)}for(const t of i(o))e(o.children.get(t),o.id||null)}(s,null),{kind:"observed-prefix",rootIds:i(s).map(e=>s.children.get(e).id),nodes:a,order:c,referencePartition:l}}(i.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,E={sourceGraphRef:i.graphRef,analysisRevision:j,spec:e,source:i,sections:k,motifs:$,forest:S.forest,residualEdges:S.residual,ports:C,ledger:I,completeness:A,provenance:{sourceRevision:i.revision,analysisRevision:j,generation:v,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?"ordinal:"+e.coordinate.sectionIds.join(","):"numeric:"+e.coordinate.field,forestRoots:[...e.forest.display.roots??S.forest.roots],rankingPolicyId:S.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:N,...e.forest.requiredPaths&&{requiredPaths:w(i,e.forest.requiredPaths)}};return E.comparison=s(E),{ok:!0,atlas:E,issues:c.issues}}function k(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function $(t,n={}){const o=n.templates??["repeated-state-episode"],r="ordinal"===t.spec.coordinate.kind?t.spec.coordinate.sectionIds:[],i=void 0!==n.partition?a(t,n.partition)??0:t.spec.comparison?t.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:t.ledger.entries.find(e=>"global"===e.subjectKind&&e.measureId===t.spec.motifs.denominatorRef)?.value??0,s=o=>e(o,t.source.occurrences,n.partition??t.spec.comparison?.partitions),c=[],l=t.motifs.incompleteCandidates.length>0;for(const e of o)for(const o of r){const r=t.motifs.matches.filter(t=>t.template===e),a=s(r.filter(e=>e.completionSectionId===o)),u=s(r.filter(e=>e.intersectSectionIds.includes(o)));c.push({template:e,sectionId:o,partition:n.partition,completionCount:a,intersectionCount:u,denominator:i,status:l?"incomplete":"exact"})}return{templates:o,sections:r,cells:c}}function S(e){return e.entityCount??1}function I(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:S(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:o(e.nodePath,e.nodePath.length-1)}}function A(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:$(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(I).filter(e=>!!e),r=new Map;for(const e of n){const n=t.order.indexOf(e.signature),o=r.get(e.signature),i=-1===n?t.order.length:n;(null==o||o>i)&&r.set(e.signature,i)}const i=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(r.get(e)??0)-(r.get(t)??0);return 0!==n?n:e.localeCompare(t)}),a=[];for(const e of n)for(let t=0;e.nodePath.length-1>t;t++){const n=o(e.nodePath,t),r=o(e.nodePath,t+1);a.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:r,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const l=function(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.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:k(e),selected:!1})).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}(e.motifs.matches),u=e.comparison??s(e),d=[];if(u&&u.partitions.length>=2){const e=u.rows[0],t=u.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;d.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:c(o,r,n),denominator:n}),d.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:c(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const h={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:a.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:i,ribbons:a,capsules:l,profile:$(e),differences:d,prefixForest:t,sceneSeeds:h}}function C(e,t){return e.groups.some(e=>function(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}(e.nodePath,t))}function j(e){return"function"==typeof e?e:t=>t[e]}function N(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function E(e){return null==e?null:e.data??e.datum??e}function P(e,t){const n=new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function F(e){const t=Object.create(null);return e((e,n)=>{t[e]=n}),t}function z(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&o[e.field]+""!=e.value+"")return!1;return!0}function O(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!z(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function L(e){return e.join("|")}function R(e,t=.72){const n=(0,ga.interpolateLab)(e,"#ffffff"),o=(0,ga.interpolateLab)(e,"#000000"),r=(0,ga.interpolateLab)(e,e)(0);return e=>{const i=0>e?0:e>1?1:e;return.5===i?r:.5>i?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function T(e,t,n=.72){return R(e,n)(t)}function W(e){return F(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function q(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function D(e,t,n){return Math.max(t,Math.min(n,e))}function B(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function V(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function G(e,t){const n=D(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}function Y(e,t,n){const o=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,r=e=>Number.isFinite(e)?Math.max(0,e):0,i=e.reduce((e,t)=>e+(r(t.weight)>0?1:0),0),s=i>0?Math.min(Math.max(0,Math.floor(n?.minPerCategory??0)),Math.floor(o/i)):0,a=e.reduce((e,t)=>e+r(t.weight),0);if(0>=o||0>=a)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const c=e.map(e=>{const t=r(e.weight),n=t/a*o;return{...e,exact:n,cells:t>0?Math.max(s,Math.floor(n)):0,remainder:n-Math.floor(n)}});let l=c.reduce((e,t)=>e+t.cells,0);for(;l>o;){const e=c.filter(e=>e.cells>s).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,l--}const u=c.filter(e=>r(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||r(t.weight)-r(e.weight)||e.key.localeCompare(t.key));for(let e=0;o>l;e++)u[e%u.length].cells++,l++;return c}function H(e,t,n,o){const r=new Set;return e.map((e,i)=>{const s=t(e,i)+"",a=Number(n(e,i));if(!s)throw Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||0>a)throw Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function _(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null==n.epsilon||0>n.epsilon?1e-9:n.epsilon,s=H(e,n.beforeId,n.beforeValue,"Before"),a=H(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),u=s.reduce((e,t)=>e+t.value,0),d=a.reduce((e,t)=>e+t.value,0),h=i>=Math.abs(u-d);if(!h&&!n.allowImbalance)throw Error(`Snapshot totals must match (before ${u}, after ${d}). Pass allowImbalance to inspect residuals.`);const f=[],p=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of p){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&f.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const m=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;m.length>y&&g.length>x;){const e=m[y],t=g[x],n=Math.min(e.value,t.value);n>i&&f.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value>i||(y+=1),t.value>i||(x+=1)}return{flows:f,beforeTotal:u,afterTotal:d,balanced:h,unmatchedBefore:m.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function X(e){return Number.isFinite(e)?Math.max(0,e):0}function U(e,t){const n=Number(t.unit),o=X(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=Math.ceil(o/n-ba),a=Math.min(r,s),c=s>r,l=[];for(let e=0;a>e;e+=1){const t=e*n;let r=Math.min(1,Math.max(0,(Math.min(o,t+n)-t)/n));ba>1-r&&(r=1),l.push({index:e,fraction:r,start:t,end:t+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((e,t)=>e+t.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function K(e,t,n){const o=U(e,n),r=Math.max(X(t),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=U(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+ba);let c=Math.min(1,Math.max(0,s-a));ba>c&&(c=0);const l=[];for(const e of i.units)a>e.index||(e.index===a&&c>0?e.fraction-c>ba&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function Q(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 Z(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,s=n.linkStrength??.045,a=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=Q(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const p=Ma/2,m=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=new Set(e.map(e=>e.id)),y=t.filter(e=>g.has(e.source)&&g.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=(0,wa.forceSimulation)(m).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",(0,wa.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",(0,wa.forceCollide)(e=>(e=>"function"==typeof l?l(e.data):l)(e)+u).strength(.9).iterations(2)).force("center",(0,wa.forceCenter)(p,p).strength(.8)).force("x",(0,wa.forceX)(p).strength(a)).force("y",(0,wa.forceY)(p).strength(a));y.length>0&&e.force("link",(0,wa.forceLink)(y).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return s/.045/n})),e.stop();for(let t=0;o>t;t+=1)e.tick()}let x=1/0,b=1/0,w=-1/0,M=-1/0;for(const e of m){const t=e.x??p,n=e.y??p;x>t&&(x=t),b>n&&(b=n),t>w&&(w=t),n>M&&(M=n)}const v=w-x,k=M-b,$={};for(const e of m)Object.defineProperty($,e.id,{value:{x:0===v?.5:d+((e.x??p)-x)/v*(1-2*d),y:0===k?.5:d+((e.y??p)-b)/k*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return $}function J(e){return e?e.map(Number).filter(Number.isFinite):[]}function ee(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function te(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function ne(e){if(e.samples)return J(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function oe(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function re(e,t){const n=te(t),o=function(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:J(e),data:e}:e}(e);let r,i,s,a,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?U(B(o.value),e):K(B(o.value),B(o.rangeValue),e);r=t.units.map(e=>oe(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue&&(l=t.rangeTotal,u=t.rangeUnits.map(e=>oe(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){a=Math.floor(B(o.denominator??n.denominator)),s=B(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>oe(n,o,1,{highlighted:e>o,start:o,end:o+1})),i=a,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=ne(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,ee(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=function(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=o-r;return e[r]*(1-i)+e[Math.ceil(o)]*i}(e,r);return oe(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=ne(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,ee(n));r=("random-sample"===n.countStrategy?function(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=Q(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return oe(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>oe(n,t,1,{datum:e})),i=e.length;else{const e=U(B(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>oe(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=function(e,t){const n=ee(t);return e.length>n?{tokens:e.slice(0,n),overflow:!0}:{tokens:e,overflow:!1}}(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:se(n,{visibleTokens:r.length+(u?.length??0)})}}function ie(e,t={}){const n=Array.isArray(e)?e:e.tokens,o=n.length;if(0===o)return[];const r=t.flow??"row",i=t.cellWidth??16,s=t.cellHeight??i,a=t.gutter??2,c=t.anchor??[.5,.5],l=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?o/t.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(t.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=t.x??0,p=t.y??0;return n.map((e,n)=>{let o,m;return"column"===r?(m=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),m=n%l),"left"===t.columnDirection&&(m=h-1-m),"up"===t.rowDirection&&(o=d-1-o),{...e,row:o,column:m,x:f+m*(i+a)+c[0]*i,y:p+o*(s+a)+c[1]*s}})}function se(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||B(e.denominator)>ka?va:ka);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function ae(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function ce(e){const t=ae(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function le(e){const t=ae(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:se(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:se(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:se(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:se(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function ue(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return function(e){const t=1.5*de(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t);const r=Object.prototype.hasOwnProperty.call(Sa,o)?Sa[o]:$a.symbolCircle;return(0,$a.symbol)(r,Math.max(1,t))()??""}function de(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function he(e,t,n){if(!n&&"circle"===(e??"circle"))return de(t);const o=n?"p:"+n:`s:${e??"circle"}:${t}`,r=Aa.get(o);if(null!=r)return r;const i=ue(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;i.length>e+1;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Aa.size>512&&Aa.clear(),Aa.set(o,s),s):de(t)}function fe(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function pe(e,t,n){return"function"==typeof e?e(t)??n:e??n}function me(e,t){return"function"==typeof e?e(t):e}function ge(e){return e.sample??e.value??e.index}function ye(e,t){return void 0!==t.datum?pe(t.datum,e,null):e.datum??null}function xe(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?pe(t.rangeColor,e,qa):pe(t.color,e,Ta):pe(t.inactiveColor,e,Wa),stroke:"none",...me(t.style,e)??{}}}function be(e,t){const n=me(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:ye(e,t),accessibleDatum:me(t.accessibleDatum,e),accessibility:me(t.accessibility,e),pointId:n,_transitionKey:n}}function we({input:e,encoding:t,options:n={}}){if(!fe(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=fe(e)?{...e,encoding:te(e.encoding)}:re(e,t),r=function(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return function(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,s=Math.max(1,Math.floor(t.rows??1)),a=e.map(ge),c=Math.min(...a),l=Math.max(...a)-c||1;return e.map((a,u)=>{const d=ge(a),h=u%s,f=t.valueToX?t.valueToX(d,a):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),p=t.valueToY?t.valueToY(d,a):o+h*(r+i);return{...a,x:f,y:p,row:h,column:u}})}(n,t);if("dotplot"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,s=t.cellWidth??r+i,a=t.cellHeight??r+i,c=e.map(ge),l=Math.min(...c),u=Math.max(...c)-l||1,d=new Map;return e.map(r=>{const i=ge(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*s),h=Math.round((c-n)/Math.max(1,s)),f=d.get(h)??0;d.set(h,f+1);const p=t.valueToY?t.valueToY(i,r):o+f*a;return{...r,x:n+h*s,y:p,row:f,column:h}})}(n,t);if("bar-segment"===o){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:ge(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}(n,t)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:function(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}(n,t,i);return ie(n,{...t,columns:a,cellWidth:i,cellHeight:s})}(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>function(e,t,n){if("dot"===n.tokenType)return function(e,t){const n=pe(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:pe(t.radius,e,n/2),style:xe(e,t),...be(e,t)}}(e,t);const o=me(t.glyph,e)??function(e){if(e)return Ra[e]}(n.icon);if(o)return function(e,t,n){const o=xe(e,n),r=pe(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:(o.fill??Ta)+"",accent:pe(n.accent,e,Da),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:pe(n.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?me(n.ghostColor,e)??Wa:void 0,rotation:me(n.rotation,e),style:o,...be(e,n)}}(e,o,t);const r=(i=n.icon)&&Ba.has(i)?i:void 0;var i;return function(e,t){const n=pe(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:pe(t.symbolType,e,"circle"),path:me(t.symbolPath,e),rotation:me(t.rotation,e),style:xe(e,t),...be(e,t)}}(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}(e,n,o.encoding))}}function Me(e){return`${e.getUTCFullYear()}-${ve(e.getUTCMonth()+1)}-${ve(e.getUTCDate())}`}function ve(e){return 10>e?"0"+e:e+""}function ke(){const e=(ma??(ma=Ha.createContext(null)),ma);return Ha.useContext(e)??_a}function $e(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Se(e,t){const n=$e(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Ie(e,t){if(Ja.has(t))return Se(e,t)}function Ae(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Ce(e,t,n){return[111.32*(e-n.lon)*Math.cos((t+n.lat)/2*(Math.PI/180)),110.574*(t-n.lat)]}function je(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function Ne(e){return Ja.has(e)?e:"monument"}function Ee(e,t){const n=je(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=Ae(t.idAccessor,"id"),a=Ae(t.nameAccessor,"name"),c=Ae(t.longitudeAccessor,"lon"),l=Ae(t.latitudeAccessor,"lat"),u=Ae(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?Ae(t.candidatePriorityAccessor,"priority"):()=>0,h=new Map;let f=null;for(const p of e){const e=Number(c(p)),m=Number(l(p));if(!Number.isFinite(e)||!Number.isFinite(m))continue;const g=(s(p)??`${e},${m}`)+"",y=(a(p)??g)+"",x=Ne(u(p)),[b,w]=Ce(e,m,t.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,S={...p,id:g,name:y,kind:x,lon:e,lat:m,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(p))||0};(null!=t.centerId&&g===t.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=S);const I=`${v}:${M}`,A=h.get(I)??[];A.push(S),h.set(I,A)}const p=new Map;f&&p.set("city",1);const m=[];for(let e=0;n>e;e++)for(let t=0;n>t;t++){const n=`tile-${e}-${t}`,s=(t+.5)*r-o,a=o-(e+.5)*r;let c,l;if(e===i&&t===i&&f){c=f;const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id).sort((e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||e.name.localeCompare(t.name));l=[f,...n]}else{const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{const n=e.candidatePriority-t.candidatePriority;if(0!==n)return n;const o=p.get(e.kind)??0,i=p.get(t.kind)??0,s=r*r*.35;return e.cellDistanceSq+o*s-(t.cellDistanceSq+i*s)||e.name.localeCompare(t.name)}),c=n[0]??null,l=n}c&&p.set(c.kind,(p.get(c.kind)??0)+1),m.push({id:n,row:e,column:t,centerXKm:s,centerYKm:a,terrainIndex:Math.abs((17*e+31*t)%Ka.length),landmark:c,landmarks:l})}return m}function Pe({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=ke(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);return(0,Xa.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const s=e.landmark,c="city"===s.kind?i:r,l=e.y+n/2,u=a.isActive&&!a.predicate(s)?.28:1;return(0,Xa.jsxs)("g",{opacity:u,children:[(0,Xa.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),(0,Xa.jsx)(ze,{kind:s.kind,href:Ie(o,s.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&(0,Xa.jsx)(Fe,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},s.id)}),s&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);return(0,Xa.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[(0,Xa.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),(0,Xa.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},e.landmark.id+"-label")})]})}function Fe({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,s=Math.max(r,i.length*r*.58);return(0,Xa.jsxs)("g",{transform:`translate(${e},${t})`,children:[(0,Xa.jsx)("rect",{x:-s/2,y:-r/2,width:s,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),(0,Xa.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function ze({kind:e,href:t,x:n,y:o,size:r}){if(t)return(0,Xa.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=oc[e];return(0,Xa.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:nc[e].flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:(0,Xa.jsx)("rect",{x:n,y:t,width:1,height:1,fill:i[e]},`${t}-${n}`)))})}function Oe(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Le(e,t,n){return Math.max(t,Math.min(n,e))}function Re(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(t>o&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function Te(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function We(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=Le(Number.isFinite(t.occupancy)?Number(t.occupancy):ic,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):sc;let i=Oe(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),s=Oe(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));n.length>i*s&&(null!=t.columns&&null==t.rows?s=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/s):s=Math.ceil(n.length/i));const a=Re(n.map(e=>e.x)),c=Re(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:Te(e.x,a)*Math.max(0,i-1),desiredRow:Te(e.y,c)*Math.max(0,s-1)})),u=(i-1)/2,d=(s-1)/2;l.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-d)**2-((e.desiredColumn-u)**2+(e.desiredRow-d)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const h=new Set;for(let e=0;s>e;e+=1)for(let t=0;i>t;t+=1)h.add(e*i+t);const f=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=(o%i-e.desiredColumn)**2+(Math.floor(o/i)-e.desiredRow)**2;(n>r||r===n&&t>o)&&(t=o,n=r)}0>t||(h.delete(t),f.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return f.sort((e,t)=>e.index-t.index),f.map(({index:e,...t})=>t)}function qe(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function De(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function Be({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=ke();return(0,rc.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const s=!i.isActive||i.predicate(e.datum);return(0,rc.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function Ve(){throw Error("geographicDotGrid requires the geo recipe bundle")}function Ge(e,t,n){return Math.max(t,Math.min(n,e))}function Ye(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function He(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function _e(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function Xe(e,t){const n=_e(e);return(e.id??n.id??n.name??"feature-"+t)+""}function Ue(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function Ke(e){if(!e)return 0;const t=fc.get(e);if(t)return t;const n=pc;return pc+=1,fc.set(e,n),n}function Qe(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(n=e[0],o=t[0][0],r=t[1][0],o>r?o>n&&n>r:o>n||n>r));var n,o,r}function Ze(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&Qe(t,n.bounds))try{if(Ve())return{feature:e,index:o}}catch{}}return null}function Je(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=function(e,t){if(0===e.length)return null;const n=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(n[0][0])&&Number.isFinite(n[0][1])&&Number.isFinite(n[1][0])&&Number.isFinite(n[1][1])?n:null}(r,t.geoPath);if(!i)return{dots:[],cellSize:lc,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[Ge(i[0][0],s,Math.max(s,n.width-s)),Ge(i[0][1],s,Math.max(s,n.height-s))],[Ge(i[1][0],s,Math.max(s,n.width-s)),Ge(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:lc,features:r};const u=Ye(o.columns);let d=Math.max(2,u?c/u:Ye(o.cellSize)??lc);const h=Math.max(100,Math.round(Ye(o.maxSamples)??uc)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const p=o.gridOrigin?.[0]??0,m=o.gridOrigin?.[1]??0,[g,y]=Ue(a[0][0],a[1][0],p,d),[x,b]=Ue(a[0][1],a[1][1],m,d),w=[],M=function(e){return e.map((e,t)=>{if(hc.has(e))return{feature:e,index:t,bounds:hc.get(e)??null};try{const n=function(){throw Error("geographicDotGrid requires the geo recipe bundle")}();return hc.set(e,n),{feature:e,index:t,bounds:n}}catch{return hc.set(e,null),{feature:e,index:t,bounds:null}}})}(r);for(let e=x;b>=e;e+=1){const n=m+(e+.5)*d;for(let r=g;y>=r;r+=1){const i=t.invertedPoint(p+(r+.5)*d,n);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;const s=Ze(M,i);if(!s)continue;const a={..._e(s.feature),featureId:Xe(s.feature,s.index),featureIndex:s.index,gridRow:e,gridColumn:r,longitude:i[0],latitude:i[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(a,w.length)||w.push(a)}}return{dots:w,cellSize:d,features:r}}function et(e){return Math.round(1e4*e)/1e4}function tt(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${et(Number(e[0]))},${et(Number(e[1]))}`:"null"}function nt(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function ot(e){return"number"==typeof e&&Number.isFinite(e)?et(e)+"":null===e?"null":"unavailable"}function rt(e){const t=e.scales.projection;return[ot(nt(t,"scale")),tt(nt(t,"translate")),tt(nt(t,"center")),(n=nt(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>et(Number(e))).join(","):"unavailable"),ot(nt(t,"clipAngle")),ot(nt(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>tt(e.scales.projectedPoint(t,n)))].join("|");var n}function it(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}function st(e,t){const n="function"==typeof t?t(e):e[t];return bc(n)?n:void 0}function at(e){return[...e].sort((e,t)=>e.localeCompare(t))}function ct(e,t,n){const o=new Map([[e,0]]),r=[e];for(;r.length>0;){const e=r.shift(),i=o.get(e);for(const s of at(n.get(e)??[]))t.has(s)&&!o.has(s)&&(o.set(s,i+1),r.push(s))}return o}function lt(e,t,n){return[...ct(e,t,n).entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))[0][0]}function ut(e,t,n){const o=new Set(e),r=e.filter(e=>1>=(t.get(e)?.size??0))[0]??e[0],i=ct(n&&o.has(n)?n:lt(lt(r,o,t),o,t),o,t),s=Math.max(0,...i.values()),a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>e.localeCompare(t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?1/0:n.reduce((e,t)=>e+t,0)/n.length};a[e].sort((e,t)=>r(e)-r(t)||e.localeCompare(t))};for(let e=0;4>e;e+=1){for(let e=1;a.length>e;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function dt(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:st(e.data,s),authoredY:st(e.data,a)})),l=c.length>0&&c.every(e=>bc(e.authoredX)&&bc(e.authoredY)),u="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,d=[];if(u&&!l&&d.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!u||!l){l||"automatic"===o.layoutMode||d.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=function(e,t,n,o,r,i){const s=function(e,t){const n=new Map(e.map(e=>[e,new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}(e.map(e=>e.id),t),a=function(e){const t=new Set(e.keys()),n=[];for(;t.size>0;){const o=at(t)[0],r=[o],i=[];for(t.delete(o);r.length>0;){const n=r.shift();i.push(n);for(const o of at(e.get(n)??[]))t.has(o)&&(t.delete(o),r.push(o))}n.push(i.sort((e,t)=>e.localeCompare(t)))}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}(s),c=new Map(e.map(e=>[e.id,e.data])),l=new Map,u=Math.max(0,n.width),d=Math.max(0,n.height),h=Math.min(o,u/2),f=Math.min(o,d/2),p=Math.max(0,d-2*f),m=a.length>1?Math.min(r,p/a.length):0,g=Math.max(0,p-m*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=f;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=ut(e,s,i),o=Math.max(0,u-2*h);n.forEach((e,r)=>{const i=1===n.length?u/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{l.set(n,{id:n,x:i,y:1===e.length?x+t/2:x+o/(e.length-1)*t,data:c.get(n)})})}),x+=t+m}return l}(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:d,projectAuthoredPoint:e=>e}}const h=c.map(e=>e.authoredX),f=c.map(e=>e.authoredY),p=Math.min(...h),m=Math.max(...h),g=Math.min(...f),y=Math.max(...f),x=Math.max(1,n.width-2*r),b=Math.max(1,n.height-2*r),w=e=>({x:m===p?n.width/2:r+(e.x-p)/(m-p)*x,y:y===g?n.height/2:r+(e.y-g)/(y-g)*b}),M=new Map;for(const e of c){const t=w({x:e.authoredX,y:e.authoredY});M.set(e.id,{id:e.id,...t,data:e.data})}return{positions:M,mode:"authored",warnings:d,projectAuthoredPoint:w}}function ht(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(.001>r||.001>i||.001>Math.abs(r-i))return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function ft(e,t){if(0===t||2>e.length)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=e.length-1>r?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(.001>l)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(.001>Math.abs(u))return{x:o.x+s.x*t,y:o.y+s.y*t};const d=4*Math.abs(t),h=Math.max(-d,Math.min(d,t/u));return{x:o.x+a*h,y:o.y+c*h}})}function pt(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(.001>=l){o+=` L${i.x},${i.y}`;continue}const u={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},d={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${u.x},${u.y} Q${i.x},${i.y} ${d.x},${d.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function mt(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):N(e.data,t.labelAccessor??"label",e.id)}function gt(e){return"string"==typeof e?e:e.id}function yt(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,function(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:e.id+""}:{id:e+""});return t.length>0?t:[{id:"network"}]}(o)}function xt(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function bt(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function wt(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??1/0)-(n.get(t)??1/0)||e.localeCompare(t))}function Mt(e,t){const n=new Map((e.authoredOrder??t.lineOrder??[]).map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(n.get(e.descriptor.id)??1/0)-(n.get(t.descriptor.id)??1/0)||e.descriptor.id.localeCompare(t.descriptor.id))}function vt(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>"number"==typeof e.x&&"number"==typeof e.y?t.projectAuthoredPoint({x:e.x,y:e.y}):null).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function kt(e,t){return F(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function $t(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):N(e.data,i.labelAccessor??"label",e.id)+"")||e.id,u=Math.max(2*s,l.length*s*.58),d=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,f=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-u},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-u/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-u/2}].map((e,t)=>{const n={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},o=a.filter(e=>{return(o=e).right>(t=n).left&&t.right>o.left&&o.bottom>t.top&&t.bottom>o.top;var t,o}).length;return{candidate:e,box:n,score:1e4*o+10*(Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height))+t}}).sort((e,t)=>e.score-t.score)[0];a.push(f.box),c.push({x:f.candidate.x,y:f.candidate.y,text:l,anchor:f.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function St(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function It(e){return(1e-12>Math.abs(e)?0:e)+""}function At(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}function Ct(e,t){return Number.isFinite(e)?D(e,0,1):t}async function jt(e,t,n={}){const{prepareNetworkAtlas:o}=await Promise.resolve().then(()=>(ca(),aa));return o(e,t,n)}async function Nt(e){const{prepareMotifBraid:t}=await Promise.resolve().then(()=>(fa(),da));return t(e)}function Et(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function Pt(e,t,n){if(2>e.length)return"";const o=function(e){const t=[e[0]];for(let n=1;e.length-1>n;n++){const o=e[n-1],r=e[n],i=e[n+1],s=Ac(o,r),a=Ac(r,i),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=Ic(r,o,c/s),u=Ic(r,i,c/a);t.push(l);for(let e=1;12>=e;e++){const n=e/12;t.push(Ic(Ic(l,r,n),Ic(r,u,n),n))}}return t.push(e[e.length-1]),t.filter((e,n)=>0===n||Ac(t[n-1],e)>1e-8)}(e);if(2>o.length)return"";const r=[0];for(let e=1;o.length>e;e++)r.push(r[e-1]+Ac(o[e-1],o[e]));const i=r[r.length-1],s=ft(o,1),a=[1,-1].map(e=>o.map((o,a)=>Ic(o,s[a],e*(t+(n-t)*r[a]/i)/2)));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function Ft(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const n=t+e/2;return t+=e+3,n})}function zt(e){let t="";return e.split(">").map((e,n)=>t=n?`${t}>${e}`:e)}function Ot(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}function Lt(e,t,n,o,r,i,s,a){const c=t-o/2,l=n-r/2,u={fill:i,stroke:s,strokeWidth:a};switch(e){case"diamond":return(0,Pc.jsx)("polygon",{points:`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`,...u});case"circle":return(0,Pc.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return(0,Pc.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16);return(0,Pc.jsx)("polygon",{points:`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;return(0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("path",{d:`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,...u}),(0,Pc.jsx)("path",{d:t,fill:"none",stroke:s,strokeWidth:a})]})}case"subroutine":{const e=Math.min(8,.08*o);return(0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),(0,Pc.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:s,strokeWidth:a}),(0,Pc.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:s,strokeWidth:a})]})}default:return(0,Pc.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}function Rt(e){return(0,Oc.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Tt(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;n>t.x-e&&(n=t.x-e),t.x+e>r&&(r=t.x+e),o>t.y-e&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function Wt(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);r>t.x&&(r=t.x),i>t.y&&(i=t.y),t.x+e>s&&(s=t.x+e),t.y+n>a&&(a=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:s-r+2*n,height:a-i+2*o}:null}function qt(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:(0,Oc.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 Dt(e){const t=e.spacing??8;return{def:(0,Oc.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:(0,Oc.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:e.color??"currentColor",strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function Bt(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,s=e.labelGap??4,a=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>e+""),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,p)=>{const m=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*s;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===p?"start":e.edgeAnchor&&p===h?"end":"middle":"left"===t?"end":"start";const w=n?"top"===t?"auto":"hanging":"middle",M=n?{x:m,y:x}:{x:x,y:m};return(0,Oc.jsxs)("g",{children:[(r>0||i>0)&&(0,Oc.jsx)("line",{...n?{x1:m,x2:m,y1:g,y2:y}:{x1:g,x2:y,y1:m,y2:m},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),(0,Oc.jsx)("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:a,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${p}`)});return(0,Oc.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function Vt(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,s=Math.hypot(r,i)||1,a=e.markX+r/s*o,c=e.markY+i/s*o;let l;return l="elbow"===e.connector?`M${a},${c} L${a},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${a},${c} Q${(a+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${a},${c} L${e.labelX},${e.labelY}`,(0,Oc.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&(0,Oc.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),(0,Oc.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),(0,Oc.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function Gt(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{outAdj:s,inAdj:a,undirected:c}=Kt(r,t),l=Qt(r,s,a,c,o).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Ut(e)})),u=new Map;for(const e of l){const t=u.get(e.motif);t?t.count+=1:u.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:l,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:l.filter(e=>e.directed).length,branchingCount:l.filter(e=>!e.directed).length}}function Yt(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Ht(e){return"string"==typeof e?e:e?.id}function _t(e,t,n,o,r){const i=new Set(e);let s=new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;r>o;o+=1){const o=new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,Yt(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return Yt(`${e.length}#${o}#${a.join(";")}`)}function Xt(e,t,n,o,r,i,s){function a(e){let t=0,n=0;for(const o of r.get(e)??[]){const e=p.get(o);m.has(o)&&e&&(t+=e.x,n+=1)}return n>0?t/n:i.x+h/2}const{layer:c,layerCount:l}=function(e,t){const n=new Set(e),o=new Map,r=new Set,i=e=>{const s=o.get(e);if(void 0!==s)return s;if(r.has(e))return 0;r.add(e);let a=0;for(const o of t.get(e)??[])n.has(o)&&(a=Math.max(a,1+i(o)));return r.delete(e),o.set(e,a),a};let s=0;for(const t of e)s=Math.max(s,i(t));const a=new Map;for(const t of e)a.set(t,s-o.get(t));return{layer:a,layerCount:s+1}}(e.ids,o),u=Array.from({length:l},()=>[]);for(const t of e.ids)u[c.get(t)].push(t);const d=.14*Math.min(i.width,i.height),h=Math.max(1,i.width-2*d),f=Math.max(1,i.height-2*d),p=new Map,m=new Set(e.ids);for(let e=0;l>e;e+=1){let t=u[e];e>0&&(t=[...t].sort((e,t)=>a(e)-a(t)));const n=t.length,o=i.y+d+(1===l?.5:e/(l-1))*f;t.forEach((e,t)=>{p.set(e,{x:i.x+d+(1===n?.5:t/(n-1))*h,y:o})})}const g=u.reduce((e,t)=>Math.max(e,t.length),1),y=D(Math.min(s,h/(2.4*g),f/(2.4*l)),1.4,s),x=e.ids.map(e=>{const o=p.get(e);return{id:e,cx:o.x,cy:o.y,r:y,datum:t.get(e)??W({id:e}),category:n.get(e)??""}}),b=[];for(const t of e.ids){const e=p.get(t);for(const n of o.get(t)??[]){if(!m.has(n))continue;const t=p.get(n);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function Ut(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?"chain of "+t:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+o}function Kt(e,t){const n=new Set(e),o=new Map,r=new Map,i=new Map;for(const t of e)o.set(t,new Set),r.set(t,new Set),i.set(t,new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function Qt(e,t,n,o,r){const i=new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}const l=new Set(c);let u=0,d=0,h=0;for(const e of c){let o=0,r=0;for(const n of t.get(e)??[])l.has(n)&&(o+=1);for(const t of n.get(e)??[])l.has(t)&&(r+=1);h+=o,0===o&&(u+=1),0===r&&(d+=1)}s.push({ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:_t(c,t,n,h,r)})}return s}function Zt(e,t,n){return e?Xt(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,n,3):null}function Jt(e){return E(e)??e}function en(e){return"string"==typeof e?e:e.id}function tn(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function nn(e){return Math.round(100*e)/100+""}function on(e,t){if(2>e.length)return"";let n=`M${nn(e[0][0])},${nn(e[0][1])}`;for(let o=1;e.length-1>o;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(0>=l){n+=`L${nn(i[0])},${nn(i[1])}`;continue}const u=[(i[0]-r[0])/a,(i[1]-r[1])/a],d=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-u[0]*l,i[1]-u[1]*l],f=[i[0]+d[0]*l,i[1]+d[1]*l];n+=`L${nn(h[0])},${nn(h[1])}Q${nn(i[0])},${nn(i[1])} ${nn(f[0])},${nn(f[1])}`}const o=e[e.length-1];return`${n}L${nn(o[0])},${nn(o[1])}`}function rn(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,u=t-s*o*.44,d=[l+a*r*.5,u+i*r*.5],h=[l-a*r*.5,u-i*r*.5];return`M${nn(c[0])},${nn(c[1])}L${nn(d[0])},${nn(d[1])}L${nn(h[0])},${nn(h[1])}Z`}function sn(e,t){return`${t}\0${e}`}function an(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function cn(e,t,n){if(1>=e)return 0;const o=Math.max(0,n.flowGap??.75),r=an(t,n);return Math.min(o,Math.max(0,(r-Math.min(.1,r))/(e-1)))}function ln(e,t,n){const o="function"==typeof t?t(e):N(e,t,n);return null==o||""===o?n:o+""}function un(e,t){const n="function"==typeof t?t(e):N(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:e+""}return n+""}}function dn(e,t){const n="function"==typeof t?t(e):N(e,t,1);return Number(n)}function hn(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function fn(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),u=n.includeInternalFlows??!0,d=[],h=new Map,f=new Map;for(const t of e){const e=ln(t,o,d.length+"");if(h.has(e))continue;const n=ln(t,i,e),s=ln(t,r,e),a={id:e,label:n,group:s,datum:t};d.push(a),h.set(e,a);const c=f.get(s);c?c.push(a):f.set(s,[a])}const p=new Set(d.map(e=>e.id)),m=[],g=new Map,y=new Map,x=[];for(const[e,t]of f){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=hn(`${n.groupIdPrefix??"group:"}${e}`,p),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};m.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};m.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=new Map;let M=0;for(const e of t){const t=un(e,s),n=un(e,a),o=dn(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!(r&&i&&Number.isFinite(o)&&o>0)){M+=1;continue}const l=h.get(t)?.group,u=h.get(n)?.group;if(l&&u&&l===u){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(u){const e=b.get(u);e&&(e.incomingValue+=o)}}let d=w.get(r);d||(d=new Map,w.set(r,d));const f=d.get(i);f?(f.value+=o,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:m,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function pn(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=e+"",n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function mn(e,t,n){return t>e?t:e>n?n:e}function gn(e){let t=2166136261;const n=e=>{for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(const o of e)n(o.id),n(o.col),n(o.row),t^=Math.round(8*o.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function yn(e,t,n){const o=new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function xn(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function bn(e,t){return function(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}(xn(e,t),e.bottomRadius,t)}function wn(e,t){const n=(e.topRadius+e.bottomRadius)/2,o=Math.PI*n*n;let r=t/o,i=t-bn(e,r),s=0;for(;100>s&&Math.abs(i)>1e-4;)r+=i/o,i=t-bn(e,r),s++;return r}function Mn(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function vn(e,t){if(t>e||2*t>e)return[{x:0,y:0}];const n=[],o=e=>{let r=Math.floor(2*Math.PI*e/(2*t));1>r&&(r=1);const i=0*e,s=Math.hypot(1*e-e*Math.cos(2*Math.PI/r),i-e*Math.sin(2*Math.PI/r));2*t>s&&r>1&&r--;for(let t=0;r>t;t++)n.push({x:e*Math.cos(2*t*Math.PI/r),y:e*Math.sin(2*t*Math.PI/r)});const a=e-2*t;t>a?e>2*t&&n.push({x:0,y:0}):o(a)};return o(e-t),n}function kn(e,t,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=t*(1+2*i),s=vn(xn(e,n),t),a=s.length-r,c=a>1?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Mn(97*i+t,.15),z:l+Mn(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function $n(e,t,n,o){if(0>=o)return[];const r=function(e,t,n){let o=n,r=0;for(;o>0&&60>r;){const n=xn(e,t+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/Jc)),r++}return r}(e,t,o),i=Math.max(t,n-r*Jc)+.875,s=[];let a=0;for(let t=0;r>t&&o>a;t++){const n=i+Jc*t,r=xn(e,n),c=Math.max(1,Math.floor(2*r/Jc)),l=(2*r-c*Jc)/(c+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;c>e&&o>a;e++)s.push({cx:u+(l+Jc)*e+.875,cy:d+.875,rotation:Mn(53*t+e,10)}),a++}return s}function Sn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function In(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function An(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Cn(e){return null==e?null:e+""}function jn(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Nn(e){return!!e&&"object"==typeof e&&nl.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function En(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function Pn(e){return"primary"===e?.emphasis||!0===e?.defensive}function Fn(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:ol))):1/0}function zn(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),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 On(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??rl),i=Fn(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Nn(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Pn(e.annotation)),l=a.filter(e=>!Pn(e.annotation)).sort((e,t)=>zn(t.annotation)-zn(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}function Ln(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(ml,t.source)?ml[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function Rn(e){if(!Tn(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 Tn(e){return Nn(e)}function Wn(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function qn(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Dn(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 Bn(e,t,n,o,r,i,s,a){const c=qn(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,a);for(const e of n)l+=12*Dn(c,e);for(const e of o)l+=4*Dn(c,e);return l}function Vn(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?function(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return jn(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:o(i),y:r(s)}}(n);return o?jn(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return Cn(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>Cn(e.pointId)===o);if(r)return jn(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return Cn(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const s=In(i,n),a=An(i,n);return null==s||null==a?null:jn(t,n,{x:s,y:a})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=In(e,n),i=An(e,n)),null!=r&&null!=i)return jn(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function Gn(e){const{annotations:t,context:n,defaultOffset:o=il,notePadding:r=sl,markPadding:i=al,edgePadding:s=cl,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ll,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:m,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof p?p:{},w=b.breakpoint??fl,M=!!p&&w>=y,v=M&&!1!==b.preferShortText?t.map(Rn):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!f?b.responsive??{minWidth:w}:f,I=M&&!m?b.cohesion:m;if(0===v.length||0>=y||0>=x)return v.slice();const A=[],C=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let j=!1;const N=v.map((e,t)=>{if(!Tn(e))return e;const i=Vn(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...En("string"==typeof e.title?e.title:void 0,o,7),...En("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}(!0===e.defensive?Ln(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:ul,dy:dl}}(e);return A.push(qn(Wn(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(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}]}(o)){const t=Bn(Wn(i.x,i.y,e.dx,e.dy,u),e,A,C,y,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=qn(Wn(i.x,i.y,h.dx,h.dy,u),r);A.push(p);const m=Math.hypot(h.dx,h.dy),g=c&&m>=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}:{}}}),E=j?N:v.slice();let P=E;if(h){let e=!1;const t=E.map(t=>{const n=function(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)<hl?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});P=e?t:E}{let e=!1;const t=P.map(t=>{if(!0!==t?.defensive)return t;const n=Ln(t);return n!==t&&(e=!0),n});P=e?t:P}const F=new Set;if(k){const e="object"==typeof k?k:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return pl;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?pl:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Fn(y,x,e))*t))},{deferred:o}=On({annotations:P,width:y,height:x,...n});for(const e of o)F.add(e)}if(S&&("object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:fl)>=y)for(const e of P)Tn(e)&&"secondary"===e.emphasis&&F.add(e);if(F.size>0)for(const e of P)!0===e?.defensive&&F.delete(e);let z;return z=0===F.size?P:$?P.map(e=>F.has(e)?{...e,_annotationDeferred:!0}:e):P.filter(e=>!F.has(e)),I?function(e,t){let n=!1;const o=e.map(e=>Tn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(z,I):z}function Yn(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function Hn(e,t={}){const n=t.fuels??gl,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=Yn(t.fuels?.[e]);(o||n>0)&&r.push({t:t.t,fuel:e,fuelLabel:yl[e],mw:n,ba:t.ba})}return r}function _n(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=Yn(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function Xn(e){const t=Yn(e.demand);if(0>=t)return 0;const n=Yn(e.capacityOrNetGen),o=Yn(e.interchange);return(n+(0>o?-o:0)-t)/t*100}function Un(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=Yn(e.demandMw),n=Yn(e.netGenMw),o=Xn({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t,demandMw:t,netGenMw:n}})}function Kn(e={},t={}){const{watch:n,comfortable:o}={...xl,...e},r=t.field,i=r?{field:r}:{},s=t.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:s,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function Qn(e={}){const{tight:t,watch:n,comfortable:o}={...xl,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function Zn(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>t>=e.t);o=e.length?e[e.length-1]:n[0]}const r=Yn(o.demandMw),i=Yn(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=Xn({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of gl){const t=Yn(o.fuels?.[e]);t>0&&(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function Jn(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const t=(e.start+e.end)/2,i=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:t,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:e.id,dataVersion:e.start+""},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function eo(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function to(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function no(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function oo(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function ro(e,t={}){const n=oo(t.start,"start"),o=oo(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new wl;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function io(e,t){const n=oo(t.start,"start"),o=oo(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(r>i)return[];const c=(i-r)/s>Math.log2(e.length+1),l=[],u=[];if(c){for(const t of e){const e=n(t),r=o(t);e>r||(l.push(e),u.push(r))}l.sort((e,t)=>e-t),u.sort((e,t)=>e-t)}let d=0,h=0;const f=[];for(let t=r;i>=t;t+=s){let r=0;if(c){for(;l.length>d&&t>=l[d];)d++;for(;u.length>h&&(a?t>=u[h]:t>u[h]);)h++;r=d-h}else for(const i of e){const e=n(i),s=o(i);e>t||(a?t>=s:t>s)||r++}f.push({value:t,count:r})}return f}function so(e){return"function"==typeof e?e:t=>t[e]}function ao(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(i>Math.abs(t.y-e.y)){const n=e.x>t.x?-1:1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){const n=e.y>t.y?-1:1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function co(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function lo(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function uo(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function ho(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function fo(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function po(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function mo(e,t){const n=t?.axis??"x",o=t?.padding??0,r=t?.strength??.5,i="x"===n?"y":"x",s="x"===n?"width":"height",a="x"===n?"height":"width",c=new Map;for(const t of e)c.set(t.id,0);for(let t=0;e.length>t;t++)for(let l=t+1;e.length>l;l++){const u=e[t],d=e[l];if(Math.abs(u[i]-d[i])>(u[a]+d[a])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[s]+d[s])/2+o-Math.abs(h);if(0>=f)continue;const p=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-p),c.set(d.id,(c.get(d.id)??0)+p)}return c}function go(e,t){if("function"==typeof e)return e;const n=e??t;return e=>N(e,n,void 0)}function yo(e,t,n,o){const r=o.fixedAxis??"y",i=e=>go(o.sourceAccessor,"source")(e)+"",s=e=>go(o.targetAccessor,"target")(e)+"",a=o.size??(()=>vl),c=o.iterations??180,l=o.attraction??.012,u=o.anchorStrength??.003,d=o.collisionStrength??.12,h=o.collisionPadding??15,f=o.edgePadding??42,p=o.fixedPadding??16,m=o.damping??.72,g=o.spread??1,[y,x]=o.fixedDomain,b=x-y||1,w=("y"===r?n.y:n.x)+p,M=("y"===r?n.y+n.height:n.x+n.width)-p,v=("y"===r?n.x:n.y)+f,k=("y"===r?n.x+n.width:n.y+n.height)-f,$=Math.max(1,k-v),S=e.map(e=>{const t=E(e)??e,n=(r=e,go(o.idAccessor,"id")(r)+"");var r;const{width:i,height:s}=a(t),c=(e=>Number(go(o.fixedAccessor,"fixed")(e)))(e),l=v+function(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}(n)*$;return{data:t,id:n,width:i,height:s,fixedValue:c,fixed:(u=c,w+(u-y)/b*(M-w)),free:l,anchor:l};var u}),I=new Map(S.map(e=>[e.id,e])),A=e=>"y"===r?e.width:e.height;for(let e=0;c>e;e++){const e=new Map;for(const t of S)e.set(t.id,0);for(const n of t){const t=I.get(i(n)),o=I.get(s(n));if(!t||!o)continue;const r=(o.free-t.free)*l;e.set(t.id,(e.get(t.id)??0)+r),e.set(o.id,(e.get(o.id)??0)-r)}for(const t of S)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*u);const n=mo(S.map(e=>({id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===r?"x":"y",padding:h,strength:d});for(const t of S)e.set(t.id,(e.get(t.id)??0)+(n.get(t.id)??0));for(const t of S){t.free+=(e.get(t.id)??0)*m;const n=A(t)/2;t.free=Math.max(v+n,Math.min(k-n,t.free))}}if(1!==g){const e=(v+k)/2;for(const t of S){const n=A(t)/2;t.free=Math.max(v+n,Math.min(k-n,e+(t.free-e)*g))}}const C=S.map(e=>({data:e.data,id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:C,byId:new Map(C.map(e=>[e.id,e]))}}function xo(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=o>r?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?D((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?D(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=D(n/c,0,1);return u+(d-u)*r}}}function bo(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function wo(e){let t=0;for(const n of e)t+=Il[n]??.6;return t}function Mo(e,t){return Math.max(8,wo(e)*t*1.05+1)}function vo(e,t,n){for(const o of t)if((e.w+o.w)/2+n>Math.abs(e.x-o.x)&&(e.h+o.h)/2+n>Math.abs(e.y-o.y))return!0;return!1}function ko(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;e.tickCount>o;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));return(0,$l.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[(0,$l.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);return(0,$l.jsxs)("g",{children:[(0,$l.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),(0,$l.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+n)}),e.label&&(0,$l.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function $o(e){return null==e?void 0:e+""}function So(e){const t=$o(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??jl,style:{...Cl,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function Io(e){return So(e)}function Ao(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...Cl,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function Co(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Cl,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:$o(e.id)}}function jo(e){const t=$o(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Cl,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??jl,style:{...Cl,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function No(e){const t={style:{...Cl,cursor:e.cursor},datum:e.datum,id:$o(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?{type:e.type??"curved",pathD:e.pathD,...t}:{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function Eo(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null==n||c(n)-c(t)>r?c(t)+r:c(n):t+1,a.push(e)};let u=null;for(let n=0;e.length>n;n++){const a=t(e[n],n);if(s&&!a){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,a)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),a}function Po(e,t,n=0){return t>0?((e-n)%t+t)%t+n:e}function Fo(e,t,n){if(0>=n)return t-e;let o=(t-e)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function zo(e,t,n){return t>n?e>=t||n>=e:e>=t&&n>=e}function Oo(e,t,n,o){return n>o?[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]:e.filter(e=>zo(t(e),n,o))}function Lo(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=Array(r).fill(0);for(let e=1;r>e;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;r>e;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(e.mean>=t.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=a>c?a:c,u=Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;e.end>=n;n++)u[n]=t+i[n]}return u}function Ro(e,t){let n=0,o=e.length-1,r=-1;for(;o>=n;){const i=n+o>>>1;e[i].at>t?o=i-1:(r=i,n=i+1)}return 0>r?{at:t,before:0,after:0}:e[r]}function To(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;e.length-1>r;r++){const i=e[r],s=e[r+1],a=[...new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=Ro(i,e),n=Ro(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function Wo(e,t,n,o={}){let r=[...e];if(1>=r.length)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;c>e&&l>a;e++){const e=new Map(r.map((e,t)=>[e,t])),c=new Map,l=new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(a++,s>u)s=u,i=[...r];else if(u===s)break}return i}function qo(e,t,n={}){const o=[...e];if(1>=o.length)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;s>e&&a>i;e++){let e=!1;for(let n=0;o.length-1>n&&a>i;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,r>s?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function Do(e,t,n={}){const o=[...e],r=o.length;if(1>=r||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,c>e&&(c=e,a=[...o])};l();const u=Array(r).fill(0);let d=0;for(;r>d&&i>s;)if(d>u[d]){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function Bo(e,t,n=()=>!0){let o=0;for(let r=0;e.length>r;r++){const[i,s]=t(e[r]);for(let a=r+1;e.length>a;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);0>(i-c)*(s-l)&&o++}}return o}function Vo(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=e.length>1?Math.max(0,n-i-(t.paddingRight??r))/(e.length-1):0,a=new Map;return e.forEach((e,t)=>{a.set(e.id,{id:e.id,x:i+s*t,y:o,index:t})}),a}function Go(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>Yo(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),f=c&&e.length>1?Math.max(0,h-d)/(e.length-1):0,p=new Map;let m=i;return c||1!==e.length||(m=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];p.set(e.id,{id:e.id,x:m+n/2,y:o,index:t,width:n}),m+=n+a+f}),p}function Yo(e,t=38,n=7.4,o=20){return Math.max(t,((e??"")+"").length*n+o)}function Ho(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new wl,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function _o(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function Xo(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Uo(e,t,n){return e-n.arcLift-t*n.levelStep}function Ko(e,t=Qo){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Qo(e){return null==e||"object"!=typeof e?e+"":null!=e.id?e.id+"":`${(e.sourceTokenId??e.source)+""}|${(e.targetTokenId??e.target)+""}|${(e.relation??e.label??"")+""}`}function Zo(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Jo(e,t,n){return(Math.atan2(e-(n?.center?.x??0),-(t-(n?.center?.y??0)))+El)%El}function er(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??El;return e=>i+(e-n)/r*(s-i)}function tr(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function nr(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=Zo(e,t,{center:i});return`${or(n)},${or(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),u=e>t?0:1;if(l>=El-1e-6){const e=i?.x??0,t=i?.y??0,n=`${or(e)},${or(t-c)}`,o=`${or(e)},${or(t+c)}`;let r=`M${n} A${or(c)},${or(c)} 0 1 1 ${o} A${or(c)},${or(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${or(e)},${or(t-a)}`,o=`${or(e)},${or(t+a)}`;r+=` M${n} A${or(a)},${or(a)} 0 1 0 ${o} A${or(a)},${or(a)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=s(e,c),f=s(t,c);if(0>=a){const e=i?.x??0,t=i?.y??0;return`M${or(e)},${or(t)} L${h} A${or(c)},${or(c)} 0 ${d} ${u} ${f} Z`}const p=s(t,a),m=s(e,a);return`M${h} A${or(c)},${or(c)} 0 ${d} ${u} ${f} L${p} A${or(a)},${or(a)} 0 ${d} ${1===u?0:1} ${m} Z`}function or(e){return Math.round(1e3*e)/1e3}function rr(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ir(e,t){return{x:e.x-t.x,y:e.y-t.y}}function sr(e,t){return{x:e.x*t,y:e.y*t}}function ar(e){return Math.hypot(e.x,e.y)}function cr(e){const t=ar(e)||1;return{x:e.x/t,y:e.y/t}}function lr(e,t){const[n,o]=e.viewBox??Pl,[r,i]=e.anchor??Fl,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function ur(e,t){const n=lr(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function dr(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??Pl,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function hr(e,t){const n=he(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function fr(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t}));t.push({type:o,label:e.colorLabel??"",items:r,styleFn:"line"===o?e=>({stroke:e.color??Ol,strokeWidth:2,fill:"none"}):e=>({fill:e.color??Ol,stroke:e.color??Ol})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??Ol,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;return(0,zl.jsx)("path",{d:ue(t,hr(t,Ll-1)),transform:`translate(${Ll},${Ll})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>e+""),r=e.sizeColor??Ol,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>(0,zl.jsx)("circle",{cx:Ll,cy:Ll,r:e.r,fill:e.color??r})})}return t}function pr(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,s=e.color??"var(--semiotic-text-secondary, #888)",a=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{l.push((0,zl.jsxs)("g",{transform:`translate(${"vertical"===t?0:c},${"vertical"===t?c:0})`,children:[mr(e,n,e.color??e.line??s,s),(0,zl.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:s,children:e.label})]},"legend-"+u)),c+="vertical"===t?a:n+r+e.label.length*i*.58+o+8}),(0,zl.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function mr(e,t,n,o){if(e.shape){const o=hr(e.shape,t/2-1);return(0,zl.jsx)("path",{d:ue(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;return(0,zl.jsxs)("g",{children:[(0,zl.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>(0,zl.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),(0,zl.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return(0,zl.jsx)("rect",e.line?{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}:{width:t,height:t,rx:2,fill:n})}function gr(e){const t=e,n=[wr(t,["datum","data"]),wr(t,["datum"]),wr(t,["data","data"]),wr(t,["data"]),wr(t,["node","datum","data"]),wr(t,["node","datum"]),e];for(const e of n){if(!Mr(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function yr(e,t={}){const n=gr(e);if(!n)return[];const o=new Set(Rl);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:br(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):xr(i)}),r.length>=(t.maxEntries??8)))break;return r}function xr(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?e+"":e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return e.length+" items";if("object"==typeof e)try{return JSON.stringify(e)}catch{return e+""}return e+""}function br(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function wr(e,t){let n=e;for(const e of t){if(!Mr(n))return;n=n[e]}return n}function Mr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function vr(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function kr(e,t){return vr(e,t)?e[t]:void 0}function $r(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Sr(){return Object.create(null)}function Ir(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function Ar(e,t){const n={};for(const t of e)$r(n,t.id,0);for(const e of t)$r(n,e.source,(kr(n,e.source)??0)+1),$r(n,e.target,(kr(n,e.target)??0)+1);return n}function Cr(e,t){const n={};$r(n,t,0);const o=[t];let r=0;for(;o.length>r;){const t=o[r];r+=1;for(const r of e.get(t)||[])vr(n,r)||($r(n,r,n[t]+1),o.push(r))}return n}function jr(e,t,n,o){if(n===o)return n?[n]:[];const r=Ir(e,t),i=Sr();i[n]=null;const s=[n];let a=0;for(;s.length>a;){const e=s[a];if(a+=1,e===o)break;for(const t of r.get(e)||[])vr(i,t)||(i[t]=e,s.push(t))}if(!vr(i,o))return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function Nr(e,t,n,o=1){const r=Ir(e,t);if(!r.has(n))return new Set;const i=Cr(r,n),s=new Set;for(const e of Object.keys(i))i[e]>o||s.add(e);return s}function Er(e,t){const n=Ir(e,t),o={};for(const t of e)$r(o,t.id,0);for(const t of e.map(e=>e.id)){const r=[],i=Sr(),s=Sr(),a=Sr();for(const t of e)i[t.id]=[],s[t.id]=0,a[t.id]=-1;s[t]=1,a[t]=0;const c=[t];let l=0;for(;c.length>l;){const e=c[l];l+=1,r.push(e);for(const t of n.get(e)||[])0>a[t]&&(a[t]=a[e]+1,c.push(t)),a[t]===a[e]+1&&(s[t]+=s[e],i[t].push(e))}const u=Sr();for(const t of e)u[t.id]=0;for(;r.length;){const e=r.pop();for(const t of i[e])u[t]+=s[t]/s[e]*(1+u[e]);e!==t&&$r(o,e,(kr(o,e)??0)+u[e])}}for(const e of Object.keys(o))$r(o,e,o[e]/2);return o}function Pr(e,t){const n=Ir(e,t),o={};for(const t of e){const e=Cr(n,t.id);let r=0,i=0;for(const t of Object.keys(e))r+=e[t],i+=1;$r(o,t.id,r>0?(i-1)/r:0)}return o}function Fr(e,t){const n=Ir(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(2>r){$r(o,t.id,0);continue}let i=0;for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);$r(o,t.id,2*i/(r*(r-1)))}return o}function zr(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const o of Object.keys(e))$r(n,o,t>0?e[o]/t:0);return n}function Or(e,t,n,o={}){const r=Ir(e,t),i=Sr();for(const t of e)i[t.id]=Cr(r,t.id);let s=o.minHops??4,a=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1){const r=e[t].id,c=e[o].id,u=kr(n,r),d=kr(n,c);if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=s&&a>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(a+=.02,a>c&&(a=o.startThreshold??.08,s=Math.max(2,s-1))),u+=1}return{problemIds:l,threshold:a,minHops:s}}function Lr(e){if("undefined"!=typeof DOMException)return new DOMException(e+" aborted","AbortError");const t=Error(e+" aborted");return t.name="AbortError",t}function Rr(e){const t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function Tr(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}async function Wr(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260,l=Tr()&&function(e,t,n,o,r=Wl){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(o,e.length,t.length,c,i);if(!l)return Z(e,t,{...a,nodeRadius:s});const u={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{const e=await function(e,t){return Tr()?Bl.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(u,r);return e.positions}catch(n){if("AbortError"===n?.name)throw n;return Z(e,t,{...a,nodeRadius:s})}}function qr(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function Dr(e,t){return!!t?.some(t=>Object.is(e,t))}function Br(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=qr(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!Dr(n,t.oneOf)||t.notOneOf&&Dr(n,t.notOneOf))}function Vr(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Gr(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function Yr(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=Vr(e,n),r=Gr(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function Hr(e,t){return(t??Object.keys(e)).map(t=>Vr(e,t)).filter(Gr).map(e=>({label:e.label??e.id,value:e.count}))}function _r(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?Vr(s,e):void 0;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+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function Xr(e,t,n){return Math.max(t,Math.min(n,e))}function Ur(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Kr(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=Xr(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,m=Xr(d*h+p,.06*d,.5*d),g=m/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=Xr(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),S=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(k),I=a-s;let A=s;const C=k.map((e,t)=>{const n=A,o=t===k.length-1?a:A+(e.share??1)/S*I;return A=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),j=C[$],N=j.x0,E=j.x1,P=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Xr((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(N>=e){const t=Xr((e-s)/Math.max(1,N-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(E>=e)return"top"===n?y:x;const o=Xr((e-E)/Math.max(1,a-E),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},F=C.map(e=>{const t=Math.min(P(e.x0,"top"),P(e.x1,"top")),n=Math.max(P(e.x0,"bottom"),P(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),z={thickness:v,friction:w,restitution:M},O=[];"lane"===t?O.push(Ur(b+"-top",s,c,a,c,z),Ur(b+"-bottom",s,l,a,l,z),Ur(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Ur(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,v)})):"funnel"===t?O.push(Ur(b+"-top",s,c,a,y,z),Ur(b+"-bottom",s,l,a,x,z),Ur(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Ur(b+"-right",a,y,a,x,{...z,thickness:Math.max(6,v)})):O.push(Ur(b+"-left-top",s,c,N,y,z),Ur(b+"-left-bottom",s,l,N,x,z),Ur(b+"-center-top",N,y,E,y,z),Ur(b+"-center-bottom",N,x,E,x,z),Ur(b+"-right-top",E,y,a,c,z),Ur(b+"-right-bottom",E,x,a,l,z),Ur(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Ur(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,v)}));const L=e.membraneDampingScale??.5,R=s,T=Math.max(1,("bowtie"===t?N:a)-R),W=(e.membranes??[]).map(e=>{const t=R+Xr(e.offset,0,1)*T,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),q=!1===e.includeMembraneRegions?[]:W.map(e=>Jr({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??L,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:N,centerRight:E,pinchHeight:m,pinchTop:y,pinchBottom:x,stages:F,membranes:W,colliders:O,regionEffects:q,boundaryY:P}}function Qr(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),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,n,o,r}function Zr(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...Qr({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Jr(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=Xr(e.cost,0,2);return{...Qr({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}function ei(e){return{...Qr({...e,kind:e.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function ti(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Qr({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function ni(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Qr({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function oi(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Qr({...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 ri(e){return{...Qr({...e,kind:e.kind??"force-field",attributes:{primitive:"portal",targetStage:e.targetStage,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function ii(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Qr({...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 si(e){return{...Qr({...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 ai(e){const t=e.x??e.anchor?.x??0,n=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:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function ci(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Ur(t+"-top",e.left,e.top,e.right,e.top,n),Ur(t+"-bottom",e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Ur(t+"-left",e.left,e.top,e.left,e.bottom,n),Ur(t+"-right",e.right,e.top,e.right,e.bottom,n)),o}function li(e,t,n){return Math.max(t,Math.min(n,e))}function ui(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=li(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),u=li(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+a,h=e.boundaryY(u,"bottom")-a;return{x:u,y:h>d?d+o()*Math.max(1,h-d):e.midY}}function di(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function hi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function fi(e,t,n,o,r){return"function"==typeof o?o(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}(e,o??r)}function pi(e){const t=Number(e.toFixed(Yl));return Object.is(t,-0)?0:t}function mi(e,t,n,o){const r=e.flatMap((e,r)=>{const i=hi(fi(e,r,t,n,"time")),s=hi(fi(e,r,t,o,"value"));return null==i||null==s?[]:[{time:pi(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function gi(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(r.time>t)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=function(e,t){let n=0,o=e.length;for(;o>n;){const r=n+o>>>1;t>e[r].time?n=r+1:o=r}return n}(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];return"step"!==n&&a&&a.time!==c.time?c.value+(t-c.time)/(a.time-c.time)*(a.value-c.value):c.value}function yi(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);return o===r?e[o]:e[o]+(e[r]-e[o])*(n-o)}function xi(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=function(e){const t=(e??Vl).map(e=>{const t=hi(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return pi(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),r=function(e){if(Array.isArray(e)){if(e.length>Gl)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Gl} points`);return Array.from(new Set(e.map(hi).filter(e=>null!=e).map(pi))).sort((e,t)=>e-t)}const t=e,n=hi(t.start),o=hi(t.end),r=hi(t.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>Gl)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Gl} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;i>e;e+=1){const t=n+e*r;if(t>o+a)break;s.push(pi(Math.min(t,o)))}if(s.length&&a>=Math.abs(s[s.length-1]-o)||s.push(pi(o)),s.length>Gl)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Gl} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}(e.sampleAt),i=e.runs.map(t=>mi(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>gi(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?yi(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?yi(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function bi(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function wi(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=hi(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const o=pi(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function Mi(e,t,n){return t>e?"below":e>n?"above":"inside"}function vi(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(0>e&&t>0||e>0&&0>t)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;a.length-1>o;o+=1){const r=a[o],i=a[o+1];if(r>=i)continue;const s=(r+i)/2,d=(i-r)*n,h=Mi(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function ki(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=mi(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??bi(t,"lower"),a=n.upper??bi(t,"upper"),c=t.points.map(e=>{const t=gi(i,e.time,o,r),n=wi(e,s),c=wi(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Mi(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,p=0,m=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>p&&(p=n,m=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=vi(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:p,peakDeficitAt:m}}function $i(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Si(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Ii(e){return!!Si(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&Si(e.visitsByStage)&&Si(e.firstEnteredAt)&&Si(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function Ai(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function Ci(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,Ai(e)]))}}function ji(e,t,n={}){if("region-enter"!==t.type)return e;const o=function(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}(t,n),r=e.stages.findIndex(e=>e.id===o);if(0>r)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=$i(e.entities,i),a=Ii(s)?s:Ai(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=$i(a.visitsByStage,o),f="number"==typeof h&&Number.isFinite(h)?h:0,p={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:f+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:d}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:d},regressionCount:c>=0&&c>r?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:p}}}function Ni(e){const t=e.bodyIds.map(t=>{const n=$i(e.entities,t);return Ii(n)?n:Ai(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=$i(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function Ei(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function Pi(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=qr(e.datum,t),o=qr(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Fi(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function zi(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(l)}function n(){G+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:l,work:e.total,queuedAt:e.queuedAt}}function r(t,r,i,s){const a={bodyId:t.id,jobId:r.jobId,visitId:r.visitId,visit:r.visit,remaining:r.work,total:r.work,queuedAt:r.queuedAt,sequence:s};return x.set(r.jobId,a),$.delete(t.id),k.set(t.id,r.jobId),z+=1,O+=r.work,n(),function(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:l,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:x.size})}(t,a,i),a}function i(e){if(x.size>=p||0===b.size)return;const t=Array.from(b.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(x.size>=p)break;const t=v.get(n.jobId);t&&w.has(n.jobId)?(b.delete(n.jobId),$.delete(n.bodyId),r(t,n,e,n.sequence)):b.delete(n.jobId)}}function s(){let e=0;for(const t of x.values())e+=t.remaining;return e}function a(){D=Math.max(D,x.size),B=Math.max(B,s())}function c(){const e=E-m,t=Math.max(0,Math.min(m,E-(P??E)));let n=0,o=0,r=0,i=0,s=0;for(const t of S){if(e>t.end)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;s+=a>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/a):t.processedWork}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&u>0?Math.max(0,Math.min(1,s/(u*t))):0,pressure:u>0?a/u:0}}const l=e.regionId,u=Math.max(0,e.unitsPerSecond),d=e.queueLayout??"lane",h=e.queueSlotSpacing??14,f=e.queueStiffness??.35,p=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,m=Math.max(.25,e.metricWindowSeconds??30),g=Math.max(1/60,e.snapshotIntervalSeconds??.25),y=e.releaseImpulse??{x:90,y:0},x=new Map,b=new Map,w=new Map,M=new Map,v=new Map,k=new Map,$=new Map,S=[];let I=0,A=new Map,C=new Map,j=0,N=0,E=0,P=null,F=0,z=0,O=0,L=0,R=0,T=0,W=0,q=0,D=0,B=0,V=0,G=0,Y=-1,H=!1;return{id:e.id??"capacity-queue:"+l,continuous:!1!==e.continuous,tick:s=>{const c=s.controls.readBodies(),d=new Map,h=new Map;for(const n of c){if(d.set(n.id,n),!t(n.id,s.getRegionState))continue;if(!Br(n,e.bodyFilter))continue;const o=Pi(n,e.jobKey),r=h.get(o)??[];r.push(n),h.set(o,r)}const f=Number.isFinite(s.dt)?Math.max(0,s.dt):0;if(!H){const e=Number.isFinite(s.elapsed)?Math.max(0,s.elapsed):f;E=Math.max(0,e-f),H=!0}const z=E,O=z+f;E=O,P=null==P?z:Math.min(P,z);const D={start:z,end:O,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},B=new Map;for(const[e,t]of h){const n=w.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];B.set(e,o),v.set(e,o)}for(const[t,r]of w){if(B.has(t))continue;const i=x.get(t),a=d.get(r.bodyId)??v.get(t);if(i){x.delete(t),k.delete(i.bodyId),W+=1,q+=i.remaining,n();const c={...o(i),abandonedAt:E,remainingWork:i.remaining,queueSeconds:Math.max(0,E-i.queuedAt)};a&&e.onAbandoned?.(a,c),s.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:l,work:i.total,remainingWork:i.remaining,jobId:t,visitId:i.visitId,visit:i.visit,queuedAt:i.queuedAt,abandonedAt:E,queueSeconds:c.queueSeconds,queueDepth:x.size})}b.delete(t),$.delete(r.bodyId),w.delete(t),v.delete(t)}for(const[t,o]of B){if(w.has(t))continue;const i=(M.get(t)??0)+1;M.set(t,i);const a=Ei(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${l}:${t}:${i}`,visit:i,regionId:l,work:a,queuedAt:E};w.set(t,c),F+=1,D.arrivals+=1,D.arrivalWork+=a;const u=I++;if(p>x.size)r(o,c,s,u);else{const r={...c,blockedAt:E,sequence:u};b.set(t,r),$.set(o.id,t),T+=1,n(),e.onBlocked?.(o,r),s.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:l,work:a,jobId:t,visitId:c.visitId,visit:i,queuedAt:E,blockedAt:E,queueDepth:x.size,blockedDepth:b.size})}}i(s),a();const G=Array.from(x.values()).sort((e,t)=>e.sequence-t.sequence);let _=u*f;for(const t of G){if(0>=_)break;const r=Math.min(t.remaining,_);if(t.remaining-=r,_-=r,L+=r,D.processedWork+=r,t.remaining>1e-6)continue;x.delete(t.jobId),k.delete(t.bodyId),N+=1,R+=t.total,D.completions+=1,D.completedWork+=t.total;const i=Math.max(0,E-t.queuedAt);V+=i,n();const a=d.get(t.bodyId);if(!a)continue;s.controls.applyImpulse(t.bodyId,y.x??0,y.y??0);const c={...o(t),completedAt:E,queueSeconds:i};e.onProcessed?.(a,c),s.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:l,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:E,queueSeconds:i,queueDepth:x.size})}i(s),a(),function(){const e=Array.from(x.values()).sort((e,t)=>e.sequence-t.sequence);A=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(b.values()).sort((e,t)=>e.sequence-t.sequence);C=new Map(t.map((e,t)=>[e.bodyId,t])),j=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&S.push(e);const t=E-m;for(;S.length>0&&t>S[0].end;)S.shift()}(D);const X=Math.floor(E/g);X!==Y&&(Y=X,n())},getSnapshot:()=>{const e=s(),t=function(){let e=0;for(const t of b.values())e+=t.work;return e}(),n=x.size,o=Array.from(x.values()).map(e=>Math.max(0,E-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:l,queueDepth:n,processedCount:N,unitsPerSecond:u,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:b.size,blockedWork:t,arrivalCount:F,admittedCount:z,admittedWork:O,processedWork:L,completedWork:R,blockedCount:T,abandonedCount:W,abandonedWork:q,peakQueueDepth:D,peakRemainingWork:B,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:Fi(o,.5),p95Seconds:Fi(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:N>0?V/N:0,window:c(),simulatedAt:E,metricRevision:G}},bodyForce:e=>{if("none"===d)return null;const t=k.get(e.body.id),n=$.get(e.body.id),o=t?x.get(t):void 0,r=n?b.get(n):void 0;if(!o&&!r)return null;const i=o?A.get(e.body.id):C.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;a.length>e;e+=1)if(a[e].id===l){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}return s?{x:((r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*h))-e.body.x)*f,y:(s.y-(i-((r?b.size:j)-1)/2)*h/Math.max(1,Math.sqrt(r?b.size:j))-e.body.y)*f*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Oi(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Li(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=Oi(n,o.bodyForce(e)));return n}}}function Ri(e){const t=new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function Ti(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=new Map,r=new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,s),r.set(i.id,s),d+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=n?i:s;return{x:((o?o.x+(c.x??0):t.home.x)-e.body.x)*a,y:((o?o.y+(c.y??0):t.home.y)-e.body.y)*a}}const u=o.get(e.body.id);if(!u||0>=a)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*a,y:(d.y-e.body.y)*a}:null}}}function Wi(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):qr(e.datum,t.deadlineAccessor)??qr(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function qi(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!Br(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=Wi(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"!==a.state||a.deadlineAt>r||t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function Di(e){const t=new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&Br(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=u.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function Bi(e,t,n){return Math.max(t,Math.min(n,e))}function Vi(e){return e.length*Xl}function Gi(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function Yi(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Xl)),r="compact"===n?Gi(e,o):"full"===n?e:Vi(e)>t?Gi(e,o):e;return{text:r,textLength:Vi(r)>t?Math.max(4,t):void 0}}function Hi(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:p,midY:m,stages:g,groups:y=[]}=e,x=p-f;return(0,Hl.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:[(0,Hl.jsx)("defs",{children:(0,Hl.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Hl.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,Hl.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,Hl.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,Hl.jsx)("rect",{x:d-6,y:f-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}),n?(0,Hl.jsx)("line",{x1:d+8,x2:h-8,y1:m,y2:m,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=_l[n],c=Math.max(12,e.width-8),l=Bi(c-8,22,88),d=Yi(e.label,Math.max(8,l-10),s),h="none"!==s&&c-8>=22,y=function(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"}(e),b=Yi(y,Math.max(16,c-10),"auto"),w=r&&!1!==e.showBadge&&c>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",v=Yi(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return(0,Hl.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,Hl.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),g.length-1>t?(0,Hl.jsx)("polygon",{points:`${e.x1-2},${m-7} ${e.x1+8},${m} ${e.x1-2},${m+7}`,fill:i.accent,opacity:.85}):null,h?(0,Hl.jsxs)(Hl.Fragment,{children:[(0,Hl.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),(0,Hl.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:e.label}),d.text]})]}):null,w?(0,Hl.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:y}),b.text]}):null,o&&null!=e.count?(0,Hl.jsxs)("text",{x:e.x,y:Math.min(u-8,p+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:M}),v.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=Bi(Math.max(54,Vi(e.label)+18,Vi(c)+16),54,104),u=Yi(e.label,l-12,"auto"),d=Yi(c,l-12,"auto");return(0,Hl.jsxs)("g",{"data-group":e.id,children:[(0,Hl.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),(0,Hl.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,Hl.jsx)("title",{children:e.label}),u.text]}),(0,Hl.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:[(0,Hl.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function _i(e){const[t,n]=e.size,o=e.flow??Ul.flow,r=function(e){if(null==e){const e=Ul.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??Ul.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??Ul.chargeExtent),l=a*Math.max(0,e.projectionExtent??Ul.projectionExtent),u=a*Math.max(0,e.destinationExtent??Ul.destinationExtent),d=Math.max(0,a-c-u-l),h=function(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}(e.destinations),f=("down"===o?s.width:s.height)/h.length,p="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),m=p(0,c),g=p(c,d),y=c+d,x=p(y,u),b=p(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,a=(f-r)/2;return"down"===o?{id:e.id,label:e.label,order:t,x:s.x+n+a,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*f,centerY:x.y+x.height/2}:{id:e.id,label:e.label,order:t,x:x.x,y:s.y+n+a,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:m,apparatus:g,destinations:w,projection:b}}function Xi(e,t){return e.destinations.find(e=>e.id===t)}function Ui(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function Ki(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:o+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;r.length>e;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:o+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;r.length>e;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:o+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:o+"-wall-right",shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function Qi(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Zi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ji(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function es(e,t,n){return Zi(e[t])??n}function ts(e,t){return"number"==typeof e?e:e?.[t]??0}function ns(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let e=i?0:1;l>=e;e+=1){if(!s&&e>0&&c.length-1>e)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return u}function os(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...function(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!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 o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...function(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],m=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(u||l)for(let e=l?0:1;y>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=i(o+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:m,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);p.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:f}})}return p}({...s,idPrefix:e??n+"-xbin",yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...ns({band:i,idPrefix:i.idPrefix??n+"-xband",plot:t,projection:"x"})),s&&a.push(...ns({band:s,idPrefix:s.idPrefix??n+"-yband",plot:t,projection:"y"})),a}function rs(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(a-s)/(d-1):0,p=t.width/h,m=[];for(let e=0;d>e;e+=1){const n=c&&e%2==1?p/2:0;for(let o=0;h>o;o+=1){const a=t.x+p*(o+.5)+n;t.x+r>a||a>t.x+t.width-r||m.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return m}function is(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=Q(l),f=ts(u,"x"),p=ts(u,"y");return e.map((e,l)=>{const u=Ji(t.x,e,l,es(e,"x",0)),m=Ji(t.y,e,l,es(e,"y",0)),g=Ji(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:m+(h()-.5)*p,vx:Ji(s,e,l,0),vy:Ji(a,e,l,0),mass:Ji(i,e,l,1),spawnAt:Ji(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function ss(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=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*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function as(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:function(e,t,n){return Zi("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function cs(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function ls(e,t,n="group"){const o=Ar(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return i>n?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function us(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{cs(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function ds(e,t,n=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*n} ${t.x},${t.y}`}function hs(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;cs(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function fs(e,t,n={}){const o=(n.order??ls(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.target>e.source?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split("\0"),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function ps(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ms(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function gs(e,t){const n=ps(e.note)?e.note:void 0;return t?ms(e.mobileText)||ms(e.shortText)||ms(e.label)||ms(n?.mobileText)||ms(n?.shortText)||ms(n?.label)||ms(n?.title):ms(e.label)||ms(e.mobileText)||ms(e.shortText)||ms(n?.label)||ms(n?.title)}function ys(e,t,n){const o=function(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=((e.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=ps(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=ps(e.lifecycle)?e.lifecycle:void 0,c=((a?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function xs(e,t){if(!t)return e;const n=gs(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function bs(e,t={}){const n=Array.isArray(e)?e.filter(ps):[],o=t.active??(null==t.width||(t.breakpoint??480)>=t.width),r=t.strategy??"hybrid",i=!1!==t.preferShortText,s=!1!==t.preservePrimary,a=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(e=>xs(e,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((e,n)=>({annotation:e,index:n,priority:ys(e,n,t)})).filter(e=>!!Nn(e.annotation)||(l.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),d=s?u.filter(e=>"primary"===((e.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(e=>e.index)),f=u.filter(e=>!h.has(e.index)),p=[...d,...f].slice(0,Math.max(a,c)),m=new Set(p.map(e=>e.index)),g=u.filter(e=>!m.has(e.index)),y=[...l,...p.sort((e,t)=>e.index-t.index).map(e=>xs(e.annotation,i))],x=g.sort((e,t)=>e.index-t.index).map(e=>e.annotation),b=Math.max(0,t.maxCalloutItems??6),w=g.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>function(e,t,n,o){const r=gs(e,o);if(!r)return null;const i=ms(e.id)||ms(e.key)||ms(e.pointId)||"annotation-"+(t+1),s=ps(e.provenance)?ms(e.provenance.source)||ms(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:ms(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}(e.annotation,e.index,e.priority,i)).filter(e=>!!e).slice(0,b),M=new Set(w.map(e=>e.annotation)),v=x.filter(e=>!M.has(e));return{active:o,strategy:r,budget:a,visible:y,deferred:x,calloutList:w,hidden:v}}function ws(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function Ms(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function vs(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:Ms(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=function(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}(e,t),l=function(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}(t);return{family:e,props:s,responsiveRules:[{id:e+"-mobile",description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function ks(e={}){const t=ws(e);return vs("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function $s(e={}){const t=ws(e);return vs("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Ss(e={}){return vs("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Is(e={}){const t=ws(e);return vs("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function As(e={}){const t=ws(e);return vs("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function Cs(e={}){return vs("geo",e,{showLegend:e.showLegend??!1})}function js(e={}){return vs("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Ns(e,t={}){switch(e){case"line":return ks(t);case"area":return $s(t);case"ordinal":return Ss(t);case"scatter":return Is(t);case"network":return As(t);case"geo":return Cs(t);case"small-multiple":return js(t)}}function Es(e={}){const t=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:e.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:t,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:t}}var Ps,Fs,zs,Os,Ls=Object.create,Rs=Object.defineProperty,Ts=Object.getOwnPropertyDescriptor,Ws=Object.getOwnPropertyNames,qs=Object.getPrototypeOf,Ds=Object.prototype.hasOwnProperty,Bs=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[Ws(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},Vs=(e,t)=>{for(var n in t)Rs(e,n,{get:t[n],enumerable:!0})},Gs=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Ws(t))Ds.call(e,r)||r===n||Rs(e,r,{get:()=>t[r],enumerable:!(o=Ts(t,r))||o.enumerable});return e},Ys=(e,t,n)=>(n=null!=e?Ls(qs(e)):{},Gs(!t&&e&&e.__esModule?n:Rs(n,"default",{value:e,enumerable:!0}),e)),Hs=Bs({"src/components/recipes/atlas/entityCounts.ts"(){}}),_s=Bs({"src/components/recipes/atlas/ids.ts"(){}}),Xs=Bs({"src/components/recipes/atlas/ledger.ts"(){_s()}}),Us=Bs({"src/components/recipes/atlas/compare.ts"(){Hs(),Xs()}}),Ks=Bs({"src/components/recipes/atlas/completeness.ts"(){_s()}}),Qs=Bs({"src/components/recipes/atlas/directedGraph.ts"(){}}),Zs=Bs({"src/components/recipes/atlas/rootedForest.ts"(){Qs()}}),Js=Bs({"src/components/recipes/atlas/forests.ts"(){_s(),Zs()}}),ea=Bs({"src/components/recipes/atlas/types.ts"(){Ps="0.2",Fs=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],zs=["serial-chain","fan-out","fan-in"],Os=[...zs,"repeated-state-episode"]}}),ta=Bs({"src/components/recipes/atlas/motifs.ts"(){_s(),ea()}}),na=Bs({"src/components/recipes/atlas/prefixForest.ts"(){_s()}}),oa=Bs({"src/components/recipes/atlas/sections.ts"(){_s()}}),ra=Bs({"src/components/recipes/atlas/support.ts"(){}}),ia=Bs({"src/components/recipes/atlas/requiredPaths.ts"(){Qs()}}),sa=Bs({"src/components/recipes/atlas/validate.ts"(){_s(),ea()}}),aa={};Vs(aa,{prepareNetworkAtlas:()=>v});var ca=Bs({"src/components/recipes/atlas/prepare.ts"(){Us(),Ks(),Js(),Xs(),ta(),na(),oa(),ra(),ia(),sa()}}),la=Bs({"src/components/recipes/atlas/capsules.ts"(){}}),ua=Bs({"src/components/recipes/atlas/profile.ts"(){Hs(),Us()}}),da={};Vs(da,{assignedDenominator:()=>a,prepareMotifBraid:()=>A,ribbonSupportsRoute:()=>C});var ha,fa=Bs({"src/components/recipes/atlas/braid.ts"(){la(),Us(),ra(),_s(),ua()}}),pa={};Vs(pa,{DEFAULT_AREA_PER_ANNOTATION:()=>ol,DEFAULT_GLYPH_ANCHOR:()=>Fl,DEFAULT_GLYPH_VIEWBOX:()=>Pl,DEFAULT_HIT_RADIUS:()=>jl,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>Ua,GRID_FUEL_KEYS:()=>gl,GRID_FUEL_LABELS:()=>yl,LayoutCache:()=>ya,SYMBOL_SEQUENCE:()=>Ia,TAU:()=>El,absorbRegion:()=>ii,activeCountOverDomain:()=>io,addPoints:()=>rr,adjacencyFlowLayout:()=>qc,adjacencyMatrix:()=>fs,aggregateAdjacencyFlow:()=>fn,aggregateRegionCounts:()=>Yr,allocateCells:()=>Y,analyzeNetEnsemble:()=>Gt,angleScale:()=>er,annotationBudget:()=>Fn,annotationDensity:()=>On,annotationLayout:()=>Gn,arcLayout:()=>us,arcPath:()=>ds,arrivalReplay:()=>as,axisFixedForceLayout:()=>kl,axisFixedForcePositions:()=>yo,balanceSnapshotsToFlows:()=>_,bandLabel:()=>qt,betweenness:()=>Er,bfsDistances:()=>Cr,bobaLayout:()=>tl,bodyGroupSpec:()=>ai,boundsOf:()=>Tt,boxEdgeAnchors:()=>lo,buildAdjacency:()=>Ir,buildTooltipEntries:()=>yr,bulletLayout:()=>Xc,calendarLayout:()=>Ya,capacitatedRegion:()=>oi,chargeGateRegion:()=>ei,circularLayout:()=>hs,clamp:()=>D,closeness:()=>Pr,clustering:()=>Fr,collidersFromScales:()=>os,comparePhysicsTrace:()=>ki,composePhysicsControllers:()=>Li,computeTransitDiagramPositions:()=>dt,countPairwiseCrossings:()=>Bo,createCapacityQueueController:()=>zi,createDependencyGateController:()=>Di,createPortalController:()=>Ri,createProcessJourneyLedger:()=>Ci,createServiceLevelController:()=>qi,createServiceResourcePoolController:()=>Ti,cubicPath:()=>po,cubicPoint:()=>ho,cubicTangent:()=>fo,curvedEdgePath:()=>ao,cyclicRangeContains:()=>zo,dagreLayout:()=>yc,degree:()=>Ar,demandForecastRows:()=>_n,describePhysicsStageGeography:()=>Qi,diagnoseTokenEncoding:()=>se,dimFor:()=>O,egoNetwork:()=>Nr,estimateLabelWidth:()=>Yo,extractTooltipDatum:()=>gr,fanOutBend:()=>uo,flextreeLayout:()=>gc,forceFieldRegion:()=>si,forceLayout:()=>Z,forceLayoutAsync:()=>Wr,formatMw:()=>to,formatReservePct:()=>no,formatTooltipValue:()=>xr,galtonPegs:()=>rs,generateTokens:()=>re,geoAreaHitTarget:()=>Ao,geoHitTarget:()=>Io,geographicDotGridLayout:()=>mc,geographicGridLayout:()=>ac,glyphExtent:()=>ur,glyphFractionClipRect:()=>dr,glyphPlacement:()=>lr,gridEventAnnotations:()=>Jn,gridifyGeographicPoints:()=>We,groupBy:()=>P,groupCompletionRows:()=>_r,hatchFill:()=>Dt,hitTargetPoint:()=>So,hitTargetRect:()=>Co,hullFromBoxes:()=>Wt,intervalLanesLayout:()=>Ml,isometricLandmarkLayout:()=>tc,isotypeBoltGlyph:()=>Fa,isotypeBusGlyph:()=>za,isotypeChipGlyph:()=>Pa,isotypeGhost:()=>Na,isotypeInk:()=>Ca,isotypeNetworkGlyphs:()=>Ra,isotypePaper:()=>ja,isotypePersonGlyph:()=>La,isotypePersonPath:()=>Oa,isotypeServerGlyph:()=>Ea,layoutChipStrip:()=>Go,layoutSequence:()=>Vo,layoutTokenGrid:()=>ie,legendGroupsFrom:()=>fr,legendSwatches:()=>pr,lineageDagLayout:()=>Sc,linearAxis:()=>Bt,makeShade:()=>R,marimekkoLayout:()=>Hc,markCallout:()=>Vt,matchesHighlight:()=>z,mean:()=>V,membraneRegion:()=>Jr,mermaidDagLayout:()=>zc,mobileAnnotationStrategy:()=>bs,mobileAreaChartRecipe:()=>$s,mobileBrushAlternatives:()=>Es,mobileChartFamilyRecipe:()=>Ns,mobileGeoChartRecipe:()=>Cs,mobileLineChartRecipe:()=>ks,mobileNetworkChartRecipe:()=>As,mobileOrdinalChartRecipe:()=>Ss,mobileScatterplotRecipe:()=>Is,mobileSmallMultipleRecipe:()=>js,motifBraidLayout:()=>Ec,mulberry32:()=>Q,netEnsembleLayout:()=>Tc,networkEdgeHitTarget:()=>No,networkHitTarget:()=>jo,nonNegativeFinite:()=>B,normalizePoint:()=>cr,normalizeScores:()=>zr,normalizeTokenEncoding:()=>te,octilinearRoute:()=>ht,offsetTransitPath:()=>ft,orderByBarycenter:()=>Wo,orderByGroupDegree:()=>ls,orderExactSmall:()=>Do,orthogonalEdgePath:()=>co,packBandsBySilhouette:()=>To,packIntervals:()=>ro,packSpanLevels:()=>Ho,packedClusterMatrix:()=>Vc,parallelCoordinatesLayout:()=>Qc,partitionSharedEdges:()=>Ko,physicsChargePoint:()=>Ui,physicsDestination:()=>Xi,physicsReferenceEnvelope:()=>xi,physicsStageColliders:()=>Ki,physicsStageGeography:()=>_i,placeWithMinGap:()=>Lo,pointMagnitude:()=>ar,polarToXY:()=>Zo,portalRegion:()=>ri,prepareMotifBraid:()=>Nt,prepareNetworkAtlasAsync:()=>jt,pressureFieldRegion:()=>ni,processChrome:()=>Hi,processJourneyRows:()=>Ni,processLaneWalls:()=>ci,processStageLayout:()=>Kr,processStageRegions:()=>Zr,processVolumePolygons:()=>di,proximityProblem:()=>Or,radiusScale:()=>tr,readField:()=>N,rectCollide:()=>mo,refineByAdjacentSwaps:()=>qo,regionCountsToProjectionRows:()=>Hr,reserveAnnotationBands:()=>Qn,reserveMarginPct:()=>Xn,reserveSeries:()=>Un,ringArcPath:()=>nr,roundedEnclosure:()=>Rt,roundedTransitPath:()=>pt,routeSurfaceRegion:()=>ti,runLengthEncode:()=>Nl,runs:()=>Eo,sampleGeographicDotGrid:()=>Je,scaleArcBand:()=>_o,scalePoint:()=>sr,sedimentBake:()=>ss,selectCyclicRange:()=>Oo,selectIsometricLandmarks:()=>Ee,shade:()=>T,shortestArcDelta:()=>Fo,shortestPath:()=>jr,signatureKey:()=>L,spanArcPath:()=>Xo,spanArcPeakY:()=>Uo,spawnFromTokens:()=>is,stackFuelSeries:()=>Hn,stageTargetInVolume:()=>ui,subtractPoints:()=>ir,suggestTokenEncoding:()=>le,summarizeOperatingPoint:()=>Zn,symbolExtent:()=>he,symbolPathString:()=>ue,symbolRadius:()=>de,thresholdBandsForReserve:()=>Kn,tightestHours:()=>eo,tokenLayer:()=>we,tokenTaskIntentToCapabilityIntents:()=>ce,transitDiagramLayout:()=>wc,unitize:()=>U,unitizeRange:()=>K,unwrapDatum:()=>E,updateProcessJourney:()=>ji,waffleLayout:()=>xa,withAlpha:()=>G,wordTrailsLayout:()=>Al,wordTrailsProgressiveReveal:()=>xo,wrapValue:()=>Po,xyToAngle:()=>Jo}),module.exports=(ha=pa,Gs(Rs({},"__esModule",{value:!0}),ha));var ma,ga=require("d3-interpolate"),ya=class{constructor(e=12){this.maxSize=e,this.store=new Map}get(e){return this.store.get(e)}set(e,t){this.maxSize>this.store.size||this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},xa=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,i=n*o;if(0>=n||0>=o||0>=i)return{nodes:[]};const{plot:s}=e.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};const a=(s.width-r*(o-1))/o,c=(s.height-r*(n-1))/n;if(0>=a||0>=c)return{nodes:[]};const l=(null==(u=t.categoryAccessor)?null:"function"==typeof u?u:e=>e[u])??(()=>"_default");var u;const d=function(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}(t.valueAccessor)??(()=>1),h=new Map,f=[];for(const t of e.data){const e=l(t)+"",n=Number(d(t)),o=Number.isFinite(n)?Math.max(0,n):0;h.has(e)||f.push(e),h.set(e,(h.get(e)??0)+o)}const p=Array.from(h.values()).reduce((e,t)=>e+t,0);if(0>=p)return{nodes:[]};let m;if(t.categoryOrder&&t.categoryOrder.length>0){const e=new Set,n=[];for(const o of t.categoryOrder)h.has(o)&&!e.has(o)&&(e.add(o),n.push(o));m=[...n,...f.filter(t=>!e.has(t))]}else m=f;if(0===m.length)return{nodes:[]};const g=m.map(e=>({cat:e,exact:(h.get(e)??0)/p*i})).map(e=>({...e,count:Math.floor(e.exact)})),y=g.reduce((e,t)=>e+t.count,0),x=g.map((e,t)=>({i:t,rem:e.exact-e.count})).sort((e,t)=>t.rem-e.rem);for(let e=0;i-y>e;e++)g[x[e%x.length].i].count+=1;const b="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",w="string"==typeof t.valueAccessor?t.valueAccessor:"value",M=(e,t,n)=>F(o=>{o("category",e),o("value",h.get(e)??0),o("share",(h.get(e)??0)/p),"category"!==b&&o(b,e),"value"!==w&&o(w,h.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),v=[];let k=0;for(const t of g){const i=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)v.push({type:"rect",x:s.x+k%o*(a+r),y:s.y+(n-1-Math.floor(k/o))*(c+r),w:a,h:c,style:{fill:i,stroke:"none"},datum:M(t.cat,k,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),k++}return{nodes:v}},ba=1e-6,wa=require("d3-force"),Ma=1e3,va=80,ka=100,$a=require("d3-shape"),Sa={circle:$a.symbolCircle,square:$a.symbolSquare,triangle:$a.symbolTriangle,diamond:$a.symbolDiamond,star:$a.symbolStar,cross:$a.symbolCross,wye:$a.symbolWye},Ia=["circle","triangle","diamond","star","square","chevron","cross","wye"],Aa=new Map,Ca="#334155",ja="#f8fafc",Na="#cbd5e1",Ea={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},Pa={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Fa={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},za={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},Oa="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",La={viewBox:[18,40],anchor:[.5,1],parts:[{d:Oa,fill:"color",stroke:"color",strokeWidth:1.4}]},Ra={server:Ea,chip:Pa,bolt:Fa,bus:za,person:La},Ta="var(--semiotic-primary, #4e79a7)",Wa="var(--semiotic-border, #d1d5db)",qa="var(--semiotic-secondary, #9ca3af)",Da="var(--semiotic-bg, #ffffff)",Ba=new Set(Ia),Va=require("d3-interpolate"),Ga=864e5,Ya=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=new Map;let s=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const n=Me(e),a=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.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,Va.interpolateRgb)(u,d)(t)},f=t.gutter??2,p=t.labelInset??0,m=Math.min((n.width-p-53*f)/54,(n.height-6*f)/7);if(0>=m)return{nodes:[]};const g=new Date(Date.UTC(a,0,1)),y=g.getUTCDay(),x=new Date(g.getTime()-y*Ga),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const o=new Date(x.getTime()+(7*e+t)*Ga);if(o.getUTCFullYear()!==a)continue;const r=Me(o),s=i.get(r),c=null==s?u:h(s);b.push({type:"rect",x:n.x+p+e*(m+f),y:n.y+t*(m+f),w:m,h:m,style:{fill:c,stroke:"none"},datum:{date:o,value:s??0}})}return{nodes:b}},Ha=Ys(require("react")),_a=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),Xa=require("react/jsx-runtime"),Ua={resource:32,city:64},Ka=["#739b58","#83a964","#668d52","#8baa68"],Qa={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},Za={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},Ja=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),ec=new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),tc=e=>{const t=je(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:Ka,i=e.dimensions.width/2,s=(e.dimensions.height-t*o)/2+o/2,a=Ee(e.points,e.config).map(e=>({...e,x:i+n/2*(e.column-e.row),y:s+(e.column+e.row)*(o/2)}));return{nodes:a.map(t=>{const i=function(e,t){const n=$e(e,t),o=function(e){return ec.has(e)?e:void 0}("string"==typeof n?n:$e(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=$e(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=Se(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??Se(e.config.terrainPalette,s)??Se(Qa,s)??Qa.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,Se(Za,l)??Za.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,u,d,h,f;return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:(0,Xa.jsx)(Pe,{tiles:a,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??Ua.resource,citySize:e.config.citySpriteSize??Ua.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},nc={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},oc={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},rc=require("react/jsx-runtime"),ic=.72,sc=1.8,ac=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=o?function(e){return e.areas.map((t,n)=>{const o=function(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??"area-"+t;return{...n,id:o+""}}(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}(e):e.points.map((e,t)=>({datum:e,x:t,y:t})),i=r.filter((e,n)=>!t.filter||t.filter(e.datum,n)),s=function(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(qe(e,t.columnAccessor)),y:Number(qe(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}(i.map(e=>e.datum),t),a=o?i:function(e){return e.points.map(t=>{const n=Number(qe(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(qe(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}({...e,points:i.map(e=>e.datum)}),c=s??We(a,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===c.length)return{nodes:[]};const l=Re(c.map(e=>e.row)),u=Re(c.map(e=>e.column)),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(1,Math.round(u[1]-u[0])+1),f=Math.max(0,t.layoutPadding??8),p=Math.max(1,e.dimensions.width-2*f)/h,m=Math.max(1,e.dimensions.height-2*f)/d,g=(e.dimensions.width-p*h)/2,y=(e.dimensions.height-m*d)/2,x=Le(t.cellPadding??.12,0,.8),b=Math.max(1,.5*Math.min(p,m)*(1-x)),w=t.sizeAccessor?c.map(e=>Number(qe(e.datum,t.sizeAccessor))):[],M=t.sizeDomain??Re(w),v=t.sizeRange??[.36,1],k=Le(Math.min(v[0],v[1]),.05,1),$=Le(Math.max(v[0],v[1]),k,1),S=c.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=(qe(r,t.idAccessor,["id","key","name"])??"grid-"+o)+"",s=(qe(r,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",a=Math.max(1,t.maxLabelLength??4),c=s.length>a?s.slice(0,a):s,d=qe(r,t.categoryAccessor),h=null==d?void 0:d+"",f=qe(r,t.fillAccessor),x=null!=f?f+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",w=t.sizeAccessor?Number(qe(r,t.sizeAccessor)):NaN,v=t.sizeAccessor&&Number.isFinite(w)?Math.sqrt(Le(Te(w,M),0,1)):1,S=b*(k+v*($-k)),I="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:c,category:h,row:n.row,column:n.column,x:g+(n.column-u[0]+.5)*p,y:y+(n.row-l[0]+.5)*m,radius:S,style:{fill:x,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...I}}}),I=t.shape??"circle";return{nodes:S.map(e=>{return"circle"===I?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===I?function(e,t,n){const o=[];for(let r=0;6>r;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return De(o)}(e.x,e.y,e.radius):De([[(t=e.x)-(o=e.radius),(n=e.y)-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===I?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:(0,rc.jsx)(Be,{marks:S,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??Le(.23*Math.min(p,m),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},cc=require("react/jsx-runtime"),lc=10,uc=25e3,dc=new WeakMap,hc=new WeakMap,fc=new WeakMap,pc=1,mc=e=>{const t=function(e){let t=dc.get(e.areas);t||(t=new Map,dc.set(e.areas,t));const n=function(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",Ke(t.featureFilter),Ke(t.dotFilter),rt(e)].join("::")}(e),o=t.get(n);if(o)return o;const r=Je(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,Ye(n.dotRadius)??t.cellSize*Ge(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,u=s+(a.gridRow+.5)*t.cellSize,d=He(a,n.categoryAccessor),h=He(a,n.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},p=`dot-${a.gridRow}-${a.gridColumn}`;if("circle"===o)return{type:"point",x:l,y:u,r:r,style:f,datum:a,interactive:!1,pointId:p,_transitionKey:p};const m="hexagon"===o?function(e,t,n){return it(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}(l,u,r):function(e,t,n){return it([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}(l,u,r);return{type:"geoarea",pathData:m,centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?(0,cc.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?(0,cc.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},Xe(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},gc=e=>{const t=e.config,n=t.nodeWidth??80,o=t.nodeHeight??30,r=t.orientation??"vertical",i=t.edgeCurve??"curved",s=!1!==t.showLabels,a=t.labelAccessor??"id",c="function"==typeof a?a:e=>N(e,a,e.id??"")+"",l=new Map,u=[],d=[],h=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:i,h:a}=h(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:a}),u.push({type:"rect",x:o-i/2,y:r-a/2,w:i,h:a,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),s&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=[];for(const t of e.edges){const n="string"==typeof t.target?t.target:t.target.id,o=l.get("string"==typeof t.source?t.source:t.source.id),s=l.get(n);if(!o||!s)continue;const a="vertical"===r?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===r?{x:s.x,y:s.y-s.h/2}:{x:s.x-s.w/2,y:s.y};if("line"===i)f.push({type:"line",x1:a.x,y1:a.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{const n=(a.y+c.y)/2,o=(a.x+c.x)/2;f.push({type:"curved",pathD:"vertical"===r?`M${a.x},${a.y} C${a.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${a.x},${a.y} C${o},${a.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:f,labels:d}},yc=e=>{const t=e.config,n=t.nodeWidth??100,o=t.nodeHeight??36,r=t.edgeStyle??"polyline",i=!1!==t.showLabels,s=t.labelAccessor??"label",a="function"==typeof s?s:e=>N(e,s,e.id??"")+"",c=new Map,l=[],u=[],d=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:s,h:h}=d(n);null!=o&&null!=r&&(c.set(n.id,{x:o,y:r,w:s,h:h}),l.push({type:"rect",x:o-s/2,y:r-h/2,w:s,h:h,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:a(n)+""}),i&&u.push({x:o,y:r,text:a(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const h=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,f=[];for(const t of e.edges){const e="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),o=c.get(e);if(!n||!o)continue;const i=t.data??{},s=Array.isArray(i.points)?i.points:t.points;if(s&&s.length>=2)if("smooth"!==r||3>s.length){const e="M"+s.map(e=>`${e.x},${e.y}`).join(" L ");f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else{let e=`M${s[0].x},${s[0].y}`;for(let t=1;s.length-1>t;t++)e+=` Q${s[t].x},${s[t].y} ${(s[t].x+s[t+1].x)/2},${(s[t].y+s[t+1].y)/2}`;const n=s[s.length-1];e+=` T${n.x},${n.y}`,f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else f.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:h,strokeWidth:1},datum:t})}return{sceneNodes:l,sceneEdges:f,labels:u}},xc=require("react"),bc=e=>"number"==typeof e&&Number.isFinite(e),wc=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:E(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),s=e.edges.map(e=>({source:gt(e.source),target:gt(e.target),data:E(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=dt(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?function(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=new Map,l=new Map(e.map(e=>[e.id,new Map]));for(const e of a){const t={id:e.id,label:mt(e,n)+"",color:xt(e,n,o)},r=new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const u=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(t.map(e=>[e,u(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(l.get(e.id)?.values()??[])]))}}(i,s,t,e.resolveColor):void 0,l=function(e,t,n){const o=new Map;for(const r of e){const e=r.target>r.source?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??yt(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>e.key.localeCompare(t.key))}(s,t,c),u=new Map(i.map(e=>[e.id,new Set])),d=new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)u.get(e)?.add(n.id),n.color&&d.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),f=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),p=new Map,m=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=Mt(n,t),c=(s.length-1)/2*(h+f)+h/2;for(const e of[n.source,n.target])p.set(e,Math.max(p.get(e)??0,c));s.forEach((c,l)=>{u.get(n.source)?.add(c.descriptor.id),u.get(n.target)?.add(c.descriptor.id);const p=vt(c.edge,a,t,c.edge.source!==n.source),g=ft(p?[o,...p,i]:ht(o,i),(l-(s.length-1)/2)*(h+f)),y=kt(c.edge,c.descriptor),x=bt(c.descriptor,c.edge,t,e.resolveColor);d.has(c.descriptor.id)||d.set(c.descriptor.id,x),m.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:pt(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=new Map,y=[],x=[],b=e=>(mt(e,t)||e.id)+"";if("minimap"===n){const n=new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of u.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,p.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(const n of o){const o=wt(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(b).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:F(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),u={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length>1?(o.forEach((t,i)=>{const a={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:-Math.PI/2+i/o.length*Math.PI*2,endAngle:-Math.PI/2+(i+1)/o.length*Math.PI*2,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(a)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a})):y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&d.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a})}}else for(const e of i){const o=a.positions.get(e.id);if(!o)continue;const i=wt(u.get(e.id)??[],t),s=i.length>1||!0===e.data.interchange||!0===e.data.transfer,c=s?t.interchangeRadius??Math.max("primary"===n?7:5,p.get(e.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(e.id,c);const l=b(e);if(y.push({type:"circle",cx:o.x,cy:o.y,r:c,style:null!=t.renderStation?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:s?"primary"===n?3:2:1.5,opacity:r(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${l}${s?", interchange":""}`,tableFields:{station:l,lines:i.join(", ")}},id:e.id,label:l}),t.renderStation){const a=t.renderStation({station:e.data,x:o.x,y:o.y,radius:c,lineIds:i,interchange:s,mode:n});null!=a&&x.push((0,xc.createElement)("g",{key:e.id,opacity:r(e.data),style:{pointerEvents:"none"}},a))}}const w=x.length>0?(0,xc.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,M={sceneEdges:m,sceneNodes:y,overlays:w,labels:$t(i,a.positions,u,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return M;const v=(e,t)=>({opacity:r(e.datum,t)});return{...M,restyle:v,restyleEdge:v}},Mc=require("react/jsx-runtime"),vc=require("react/jsx-runtime"),kc={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},$c={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Sc=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.layerAccessor??"x",r=t.rowAccessor??"y",i=t.partitionAccessor??"partition",s=t.semanticAccessor??"semantic",a=t.labelAccessor??"label",c=t.storesAccessor??"stores",l=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...kc,...t.partitionColors},h={...$c,...t.edgeColors},f=t.accentColor??"var(--semiotic-focus, #ffcc33)",p=t.borderColor??"var(--semiotic-border, #555)",m=t.dimOpacity??.14,g=t.edgeOpacity??.5,y=t.edgeWidth??1.25,x=t.backEdgeWidth??t.edgeWidth??1.5,b=!1!==t.showStoreChips,w=t.storeChipColor??"var(--semiotic-info, #6a8caf)",M=t.hullGroupAccessor;let v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0;const n=new Map;for(const r of e.nodes){const e=Math.round(Number(N(r,o,0)));t=Math.max(t,e),n.set(e,(n.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...n.values())}const $=n.width/Math.max(1,v),S=n.height/Math.max(1,k);let I=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),A=Math.min(t.nodeHeight??54,Math.max(8,S-(t.minGapY??18)));const C=t.lod&&"auto"!==t.lod?t.lod:16>I?"dot":48>I?"icon":108>I?"compact":"full";if("dot"===C){const e=Math.min(I,A,11);I=e,A=e}const j=Math.max(1,n.width-I),E=Math.max(1,n.height-A),P=Math.max(1,k-1),F=e=>n.x+I/2+(v>1?e/(v-1):.5)*j,z=e=>n.y+A/2+(e+P/2)/P*E,O=t.reachableIds?new Set(t.reachableIds):null,L=t.selectedId??null,R=e.selection,T=new Map,W=new Map,q=[],D=null==M?null:new Map,V=[];for(const t of e.nodes){const e=t.id,n=Number(N(t,o,0)),l=Number(N(t,r,0)),u=N(t,i,"processor")+"",h=N(t,s,"processor")+"",g=N(t,a,e)+"",y=At(N(t,c,[])),x=t.data??t,b=F(n),w=z(l);T.set(e,{cx:b,cy:w});const v=O?O.has(e):null,k=R?.isActive?R.predicate(x):null,$=null!==v?!v:null!==k&&!k;W.set(e,$);const S=null!=L&&e===L,j=$&&!S?m:1,E=Object.prototype.hasOwnProperty.call(d,u)?d[u]:d.unknown;if("dot"===C?q.push({type:"circle",cx:b,cy:w,r:I/2,style:{fill:E,opacity:j,stroke:S?f:"transparent",strokeWidth:S?2:0},datum:t,id:e,label:g}):(q.push({type:"rect",x:b-I/2,y:w-A/2,w:I,h:A,style:{fill:E,opacity:j,stroke:S?f:p,strokeWidth:S?3:1},datum:t,id:e,label:g}),V.push({id:e,cx:b,cy:w,partition:u,semantic:h,label:g,stores:y,opacity:j,selected:S,node:x})),D&&null!=M){const n=N(t,M,null);if(null!=n){const t=n+"",o=D.get(t)??[];o.push({id:e,x:b-I/2,y:w-A/2,w:I,h:A}),D.set(t,o)}}}const G=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,o=T.get(e),r=T.get(n);if(!o||!r)continue;const i=!!N(t,l,!1),s=N(t,u,"internal")+"",a=W.get(e)||W.get(n)?Math.min(g,1.4*m):g,c=i?h.back:Object.prototype.hasOwnProperty.call(h,s)?h[s]:h.internal;let d;if(i){const e=o.cx,t=o.cy+A/2,n=r.cx,i=r.cy+A/2,s=Math.max(48,.28*Math.abs(e-n))+A;d=`M${e},${t} C${e},${t+s} ${n},${i+s} ${n},${i}`}else{const e=o.cx+I/2,t=o.cy,n=r.cx-I/2,i=r.cy,s=(e+n)/2;d=`M${e},${t} C${s},${t} ${s},${i} ${n},${i}`}const f={type:"curved",pathD:d,style:{stroke:c,strokeWidth:i?x:y,fill:"none",opacity:a,...i?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};G.push(f)}const Y=0===V.length?null:(0,vc.jsx)("g",{className:"lineage-dag-glyphs",children:V.map(e=>function(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),s=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",a="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:s,node:e.node}):function(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";return(0,vc.jsxs)("g",{children:[(0,vc.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),(0,vc.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(e.semantic,e.partition,i),l="full"===r,u="icon"!==r,d="full"===r&&t.showChips&&e.stores.length>0;return(0,vc.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[(0,vc.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),u&&(0,vc.jsx)("foreignObject",{x:a,y:l?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:(0,vc.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&(0,vc.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),d&&e.stores.map((e,n)=>(0,vc.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:(0,vc.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}(e,{w:I,h:A,lod:C,partColors:d,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))}),H=D&&D.size>0?function(e,t){const n=Array.from(e.entries()).sort(([e],[t])=>t>e?-1:e>t?1:0);return(0,Mc.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:n.map(([e,n])=>{const o=function(e,t){if(0===t||3>e.length)return e;const n=0>e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)?-1:1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},u=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},d={x:l.x+u.x,y:l.y+u.y},h=Math.hypot(d.x,d.y);if(1e-9>h)return{x:o.x+u.x*t,y:o.y+u.y*t};const f=d.x/h,p=d.y/h,m=t/Math.max(1e-6,f*u.x+p*u.y);return{x:o.x+f*m,y:o.y+p*m}})}(function(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(2>=t.length)return t;const n=[];for(const e of t){for(;n.length>=2&&0>=St(n[n.length-2],n[n.length-1],e);)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&0>=St(o[o.length-2],o[o.length-1],n);)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}(n.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding),r=function(e,t){if(0===e.length)return"";if(3>e.length||0===t)return e.map((e,t)=>`${0===t?"M":"L"}${It(e.x)},${It(e.y)}`).join(" ")+" Z";const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${It(o.x)},${It(o.y)}`;for(let e=1;n.length>e;e++){const t=n[e];r+=` L${It(t.incoming.x)},${It(t.incoming.y)}`,r+=` Q${It(t.point.x)},${It(t.point.y)} ${It(t.outgoing.x)},${It(t.outgoing.y)}`}const i=n[0];return r+=` L${It(i.incoming.x)},${It(i.incoming.y)}`,r+=` Q${It(i.point.x)},${It(i.point.y)} ${It(i.outgoing.x)},${It(i.outgoing.y)} Z`,r}(o,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),s=n.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),a=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=t.label?.(e);return(0,Mc.jsxs)("g",{"data-lineage-hull":e,opacity:s?t.dimOpacity:void 0,children:[(0,Mc.jsx)("path",{className:"lineage-dag-hull",d:r,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}}),l?(0,Mc.jsx)("text",{className:"lineage-dag-hull-label",x:a+8,y:c+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:l}):null]},e)})})}(D,{colors:t.hullColors,padding:null==t.hullPadding?16:B(t.hullPadding),radius:null==t.hullRadius?12:B(t.hullRadius),fillOpacity:Ct(t.hullFillOpacity,.08),strokeOpacity:Ct(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:W,selectedId:L,dimOpacity:m}):null;return H?{sceneNodes:q,sceneEdges:G,backgrounds:H,overlays:Y}:{sceneNodes:q,sceneEdges:G,overlays:Y}},Ic=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Ac=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),Cc={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"}]},jc=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,Nc=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),Ec=e=>{const t=e.config.braid,n=e.dimensions.plot,o=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],r=t.groups.filter(e=>o.includes(e.partition)&&e.nodePath.length>0),i=[],s=[],a=[];if(0===r.length)return{sceneNodes:s,sceneEdges:i,labels:a};const c=new Set(r.map(e=>e.signature)),l=[...t.signatureOrder.filter(e=>c.delete(e)),...c],u=new Map(l.map((e,t)=>[e,t])),d=[...r].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=o.map(e=>d.filter(t=>t.partition===e)),f=function(e){const t=new Map;for(const n of e){const e=zt(n.signature);n.nodePath.forEach((o,r)=>{const i=e[r];let s=t.get(i);s||(s={id:i,state:o,depth:r+1,signatures:new Set},t.set(i,s)),s.signatures.add(n.signature)})}return[...t.values()]}(d),p=Et(f.map(e=>e.depth)),m=r.map(e=>Et(e.stepEntityCounts??[e.entityCount])),g=Et(m),y=e=>e>0?Math.max(1,10*e/g):0,x=new Map(r.map((e,t)=>[e.id,y(m[t])])),b=n.height/o.length,{semantic:w}=e.theme,M=(e,t,n,o={})=>a.push({x:e,y:t,text:n,fill:w.text??"#333",fontSize:10,anchor:"middle",...o}),v={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},k=new Map(f.map(e=>{const t=h.map(t=>t.reduce((t,n)=>t+(e.signatures.has(n.signature)?x.get(n.id)+3:0),5));return[e.id,Et(t,24)]})),$=Et([...k.values()],24),S=Math.min(n.width/4,$/2+16),I=(n.width-2*S)/Math.max(p-1,1),A=e=>n.x+S+(e-1)*I,C=48+$/2,j=22+$/2,N=(e,t)=>e+C+(u.get(t)+.5)*Math.max(0,b-C-j)/l.length,E=(t,n,o,r,s)=>{const a=jc(n,r),c=jc(n,s),l=y(a),u=y(c);if(0===l&&0===u)return;const d=l!==u,h=e.resolveColor(n.signature);i.push({type:"curved",id:o,pathD:d?Pt(t,l,u):pt(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:l},datum:{...v,id:o,kind:"braid-track",nodeId:n.nodePath[s],fromNodeId:n.nodePath[r],groupId:n.id,signature:n.signature,partition:n.partition,entityCount:n.entityCount,fromStep:r,toStep:s,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:n.nodePath.join(" → "),partition:n.partition??"all",fromStep:r+1,toStep:s+1,fromCount:a,toCount:c}})};return o.forEach((e,t)=>{const o=n.y+t*b,r=h[t];if(e&&M(n.x+8,o+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===r.length)return;for(let e=1;p>=e;e++)M(A(e),o+34,"Step "+e);const i=new Map;for(const t of f){const n=r.filter(e=>t.signatures.has(e.signature));if(0===n.length)continue;const a=A(t.depth),c=V([...t.signatures].map(e=>N(o,e))),l=Ft(n.map(e=>x.get(e.id)));i.set(t.id,new Map(n.map((e,t)=>[e.id,{x:a,y:c+l[t],offset:l[t]}])));const u=k.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:Cc,accent:w.border??"#888",style:{fill:w.surface??"#fff"},datum:{...v,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),M(a,c+u/2+12,t.state)}for(const t of r){const n=zt(t.signature);for(let o=1;n.length>o;o++){const r=i.get(n[o-1]).get(t.id),s=i.get(n[o]).get(t.id),a=(r.x+s.x)/2-Math.sign(s.y-r.y)*s.offset;E(1e-8>Math.abs(r.y-s.y)?[r,s]:[r,{x:a,y:r.y},{x:a,y:s.y},s],t,`step:${e??"all"}:${n[o]}:${t.id}`,o-1,o)}}}),{sceneNodes:s,sceneEdges:i,labels:a,restyle:Nc,restyleEdge:Nc}},Pc=require("react/jsx-runtime"),Fc={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},zc=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,s=t.layerAccessor??"layer",a=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",u=t.edgeLabelAccessor??"label",d=t.nodeFill??"var(--semiotic-surface, #20242d)",h=t.nodeStroke??"var(--semiotic-border, #5a6573)",f=t.textColor??"var(--semiotic-text, #e6e6e6)",p=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",m=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const g=new Map;let y=0;for(const t of e.nodes){const e=Math.round(Number(N(t,s,0)));y=Math.max(y,e);const n=g.get(e)||[];n.push(t),g.set(e,n)}const x=y+1;let b=1;for(const e of g.values())e.sort((e,t)=>Number(N(e,a,0))-Number(N(t,a,0))),b=Math.max(b,e.length);const w=r?n.width:n.height,M=r?n.height:n.width,v=w/x,k=M/(b+1),$=Math.max(44,Math.min(t.nodeWidth??150,r?v-36:.92*k)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*k:.5*v)),I=(r?$:S)/2+6,A=Math.max(1,w-2*I),C=e=>(r?n.x:n.y)+I+(x>1?(i?x-1-e:e)/(x-1)*A:A/2),j=new Map,E=[],P=[];for(const[e,t]of g)t.forEach((o,i)=>{const s=C(e),a=(r?n.y:n.x)+(i+1)/(t.length+1)*M,u=r?s:a,p=r?a:s,g=N(o,l,"rect")+"",y=N(o,c,o.id)+"";j.set(o.id,{cx:u,cy:p,shape:g}),E.push({type:"rect",x:u-$/2,y:p-S/2,w:$,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:o.id,name:y,type:Fc[g]??"process",shape:g},id:o.id,label:y}),P.push((0,Pc.jsxs)("g",{children:[Lt(g,u,p,$,S,d,"diamond"===g?m:h,1.5),(0,Pc.jsx)("text",{x:u,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:f,style:{pointerEvents:"none"},children:Ot(y,Math.max(4,Math.floor(($-12)/7)))})]},"n-"+o.id))});const F=[];return e.edges.forEach((e,t)=>{const n="string"==typeof e.target?e.target:e.target.id,o=j.get("string"==typeof e.source?e.source:e.source.id),i=j.get(n);if(!o||!i)return;const s=r?o.cx+$/2:o.cx,a=r?o.cy:o.cy+S/2,c=r?i.cx-$/2:i.cx,l=r?i.cy:i.cy-S/2,d=r?`M${s},${a} C${(s+c)/2},${a} ${(s+c)/2},${l} ${c},${l}`:`M${s},${a} C${s},${(a+l)/2} ${c},${(a+l)/2} ${c},${l}`,m=Math.atan2(l-a,c-s),g=c-9*Math.cos(m),y=l-9*Math.sin(m),x=4.5*-Math.sin(m),b=4.5*Math.cos(m),w=`${c},${l} ${g+x},${y+b} ${g-x},${y-b}`,M=N(e,u,void 0),v=(s+c)/2,k=(a+l)/2;F.push((0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("path",{d:d,fill:"none",stroke:p,strokeWidth:1.4}),(0,Pc.jsx)("polygon",{points:w,fill:p}),"string"==typeof M&&M.length>0&&(0,Pc.jsxs)("g",{children:[(0,Pc.jsx)("rect",{x:v-6.5*M.length/2-4,y:k-9,width:6.5*M.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),(0,Pc.jsx)("text",{x:v,y:k,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:M})]})]},"e-"+t))}),{sceneNodes:E,overlays:(0,Pc.jsxs)("g",{className:"mermaid-dag",children:[F,P]})}},Oc=require("react/jsx-runtime"),Lc=require("react/jsx-runtime"),Rc=new ya(8),Tc=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,p=t.fingerprintRounds??3,m=!1!==t.groupByMotif,g=t.sort??"frequency",y=new Map,x=new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,N(t,s,"")+""))}const w=[];for(const t of e.edges){const e=Ht(t.source??N(t,o,void 0)),n=Ht(t.target??N(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,undirected:k}=Kt(b,w),$=Qt(b,M,v,k,p),S=new Map;if(m)for(const e of $){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...$].sort((e,t)=>t.nodeCount-e.nodeCount));const I=[...S.entries()];I.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const A=Yt(b.join(",")+"|"+[...M.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),C=L([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),c,l,u,d,h,f,p,m,g,a,I.map(([e,t])=>e+":"+t.length).join(","),A]),j=Rc.getOrCompute(C,()=>function(e,t){const{plot:n}=t,o=Math.max(40,n.width),{cell:r,cols:i}=(()=>{for(let r=t.maxCellSize;r>=t.minCellSize;r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e)s+=t.headerHeight+Math.ceil(n.length/i)*(r+t.cellGap)+t.bandGap;if(n.height>=s)return{cell:r,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((o+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),s=[],a=[];let c=n.y;for(const[l,u]of e){const e=Math.ceil(u.length/i),d=c,h=d+t.headerHeight,f=r>=t.minCellForFull;u.forEach((e,o)=>{const a=n.x+o%i*(r+t.cellGap),c=h+Math.floor(o/i)*(r+t.cellGap);if(f){const n=Xt(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:a,y:c,width:r,height:r},t.nodeRadius);s.push({component:e,lod:"full",cx:a+r/2,cy:c+r/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else s.push({component:e,lod:"glyph",cx:a+r/2,cy:c+r/2,glyphR:Math.max(2.5,.36*r),nodes:[],edges:[]})});const p=Zt(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});a.push({motif:l,descriptor:Ut(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(r+t.cellGap),exemplar:p}),c=h+e*(r+t.cellGap)+t.bandGap}return{cells:s,bands:a}}(I,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:a,nodeDatum:y,nodeCategory:x,outAdj:M,inAdj:v})),E=e.theme.semantic||{},P=t.convergeColor??E.info??"#4c78a8",F=t.branchColor??E.warning??"#e8853a",z=t.edgeColor??E.border??"#9aa0aa",R=t.colorMode??"directedness",T={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},q=t=>"motif"===R?e.resolveColor(t.motif):"category"===R||t.directed?P:F,D=[],B=[];for(const t of j.cells){const n=t.component,o=q(n);if("full"===t.lod){for(const e of t.edges)B.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:z,strokeWidth:1,opacity:.5},datum:null});for(const n of t.nodes){const t="category"===R&&n.category?e.resolveColor(n.category):o,r={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:t,opacity:O(n.datum,T)},datum:n.datum,id:n.id,label:N(n.datum,i,n.id)+""};D.push(r)}}else{const e=W({id:`motif-${n.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:n.motif,shape:Ut(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:O(e,T),stroke:z,strokeWidth:.75},datum:e,id:e.id+"",label:Ut(n)};D.push(r)}}return{sceneNodes:D,sceneEdges:B,overlays:function(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor;if(n.push(Rt({keyId:"band-"+o.motif,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&o.exemplar){const r=o.exemplar;n.push((0,Lc.jsxs)("g",{style:{pointerEvents:"none"},children:[r.edges.map((e,n)=>(0,Lc.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+n)),r.nodes.map(t=>(0,Lc.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+o.motif))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);n.push((0,Lc.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},"bl-"+o.motif)),n.push((0,Lc.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+o.motif))}}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push((0,Lc.jsxs)("g",{style:{pointerEvents:"none"},children:[(0,Lc.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),(0,Lc.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),(0,Lc.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),(0,Lc.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;return(0,Lc.jsx)("g",{className:"net-ensemble-overlays",children:n})}(j.bands,{convergeColor:P,branchColor:F,edgeColor:z,plot:n,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===R,textColor:E.text??"var(--semiotic-text, #1a1a1a)",subText:E.textSecondary??"var(--semiotic-text-secondary, #888)"})}},Wc=Ys(require("react")),qc=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:Jt(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[e+"",t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,u=n.x+(n.width-l)/2,d=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),f=h/2,p=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):N(e.datum,t.labelAccessor??"label",e.id)+"";return{id:e.id,label:o,datum:e.datum,index:n,cx:u+(n+.5)*c,cy:d+(n+.5)*c}}),m=new Map(p.map(e=>[e.id,e])),g=new Map(p.map(e=>[e.id,e.index])),y=function(e,t,n){const o=new Map;for(const r of e){const e=en(r.source),i=en(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=Jt(r),l=tn("function"==typeof n.valueAccessor?n.valueAccessor(c):N(c,n.valueAccessor??"value",r.value??1),0);if(0>=l)continue;let u=o.get(e);u||(u=new Map,o.set(e,u));const d=u.get(i);d?(d.value+=l,d.edgeCount+=1,d.memberEdges.push(c)):u.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=F(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}(e.edges,g,t),x=function(e,t,n){const o=new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(sn(t.source,t.sourceIndex>t.targetIndex?"out-left":"out-right"),t),r(sn(t.target,t.targetIndex>t.sourceIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=an(t,n);let s=null==n.flowScale?1/0:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=cn(e.length,t,n);o>0&&(s=Math.min(s,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??1/0);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=cn(e.length,t,n);o>0&&(l=Math.min(l,Math.max(.1,i-r*Math.max(0,e.length-1))/o))}if(1>l)for(const t of e)t.width*=l;return o}(y,h,t),b=function(e,t,n,o){const r=new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=cn(s.length,n,o);let u=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=u+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),u+=e.width+l}}return r}(x,m,h,t),w=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),M=e.theme.semantic.text??"var(--semiotic-text, currentColor)",v=e.theme.semantic.surface??"var(--semiotic-bg, white)",k=e.theme.semantic.border??"var(--semiotic-border, currentColor)",$=e.theme.semantic.grid??k,S=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),I=t.valueFormat??(e=>Math.round(100*e)/100+""),A=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),C=new Map(p.map(e=>[e.id,0])),j=new Map(p.map(e=>[e.id,0])),E=[],P=[],z=[];for(const n of y){const o=m.get(n.source),r=m.get(n.target);if(!o||!r)continue;C.set(o.id,(C.get(o.id)??0)+n.value),j.set(r.id,(j.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):w);const a=b.get(n.key+":source")??o.cy,l=b.get(n.key+":target")??r.cx;let h,p,g,y,x,k,$;if(n.targetIndex>n.sourceIndex){const e=[o.cx+f,a],t=[l,r.cy-f];h=[e,[t[0],e[1]],t],p=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,x=t[0]-A-4,k=e[1]-n.width/2-3,$="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-f,a],i=[l,r.cy+f];h=[e,[i[0],e[1]],i],p=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,x=i[0]+A+4,k=e[1]+n.width/2+(t.valueFontSize??10),$="start"}else{const e=u+(o.index+1)*c,t=d+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+f+2,e-i),m=Math.max(o.cy+f+2,t-i),b=[o.cx+f,a],w=[l,r.cy+f];h=[b,[s,b[1]],[s,m],[w[0],m],w],p=(s+w[0])/2,g=m,y=Math.PI,x=s-3,k=m-n.width/2-3,$="end"}const S=on(h,A);if(z.push({type:"curved",id:"adjacency-flow-"+n.key,label:`${o.label} to ${r.label}: ${I(n.value,n.datum)}`,pathD:S,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${I(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&P.push({x:x,y:k,text:I(n.value,n.datum),anchor:$,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:M,stroke:v,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(2>=e)continue;E.push(Wc.createElement("path",{key:"arrow-"+n.key,className:"semiotic-adjacency-flow-arrow",d:rn(p,g,y,Math.max(3,1.08*e),e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const O=p.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):S);return{type:"rect",id:n.id,label:n.label,x:n.cx-f,y:n.cy-f,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??k,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:j.get(n.id)??0,outgoing:C.get(n.id)??0}}}}),L=Math.max(2,t.maxLabelLength??14),R=p.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=L,n.length>o?n.slice(0,Math.max(1,o-1))+"…":n),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??v};var n,o});let T=null;if(t.showGrid??!0){const e=[];for(let t=0;p.length>=t;t+=1){const n=u+t*c,o=d+t*c;e.push(Wc.createElement("line",{key:"grid-v-"+t,x1:n,y1:d,x2:n,y2:d+l,stroke:$,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),Wc.createElement("line",{key:"grid-h-"+t,x1:u,y1:o,x2:u+l,y2:o,stroke:$,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}T=Wc.createElement(Wc.Fragment,null,...e)}return{sceneEdges:z,sceneNodes:O,labels:[...P,...R],backgrounds:T,overlays:Wc.createElement(Wc.Fragment,null,...E)}},Dc=require("react/jsx-runtime"),Bc=new ya(12),Vc=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],p=t.shadeStrength??.72,m=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,k=!1!==t.showEnclosures,$=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,I=$?t.headerHeight??26:0,A=S?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,j=n.x+A,E=n.y+I,F=Math.max(1,n.width-A),z=Math.max(1,n.height-I-C),T=[];for(const t of e.nodes){const e=t.data??t;T.push({id:t.id,col:N(t,o,"—")+"",row:N(t,r,"—")+"",sizeVal:i?Number(N(t,i,1)):1,colorKey:s?N(t,s,"")+"":"",symVal:a?N(t,a,"")+"":"",shadeVal:c?pn(N(t,c,null)):NaN,marker:!!l&&!!N(t,l,!1),iconVal:u?N(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===T.length)return{sceneNodes:[]};let W=1/0,q=-1/0;if(i)for(const e of T)Number.isFinite(e.sizeVal)&&(W>e.sizeVal&&(W=e.sizeVal),e.sizeVal>q&&(q=e.sizeVal));t.sizeDomain&&([W,q]=t.sizeDomain),Number.isFinite(W)&&Number.isFinite(q)||(W=0,q=1);const D=e=>{if(W>=q)return(h+f)/2;const t=Math.sqrt(mn((e-W)/(q-W),0,1));return h+t*(f-h)};let B=1/0,V=-1/0;if(c)for(const e of T)Number.isFinite(e.shadeVal)&&(B>e.shadeVal&&(B=e.shadeVal),e.shadeVal>V&&(V=e.shadeVal));t.shadeDomain&&([B,V]=t.shadeDomain);const G=e=>{if(!c||!Number.isFinite(e)||B>=V)return.5;const t=mn((e-B)/(V-B),0,1);return m?1-t:t},Y=t.colorMap,H=new Map,_=(t,n)=>{let o=H.get(t);return o||(o=R(Y&&Object.prototype.hasOwnProperty.call(Y,t)&&"string"==typeof Y[t]&&Y[t]?Y[t]:e.resolveColor(t),p),H.set(t,o)),o(n)},X=new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))X.set(e,n);let U=0;const K=t.iconMap,Q=e=>u&&K&&Object.prototype.hasOwnProperty.call(K,e)?K[e]??null:null,Z=e=>u?"circle":(e=>{if(!a)return d;let t=X.get(e);return t||(t=Ia[U%Ia.length],U++,X.set(e,t)),t})(e.symVal),J=t.maxAreaFraction??.4;let ee=0;const te=Array(T.length),ne=Array(T.length);for(let e=0;T.length>e;e++){const t=T[e],n=D(t.sizeVal);te[e]=n,t.baseShape=Z(t),t.iconShape=Q(t.iconVal);const o=he(t.baseShape,Math.PI*n*n);ne[e]=o,ee+=Math.PI*o*o}const oe=J*F*z,re=ee>oe?Math.sqrt(oe/ee):1;for(let e=0;T.length>e;e++){const t=T[e],n=te[e]*re;t.size=Math.PI*n*n,t.packR=ne[e]*re}const ie=new Map,se=new Map;for(const e of T)ie.set(e.col,(ie.get(e.col)??0)+1),se.set(e.row,(se.get(e.row)??0)+1);const ae=t.columnOrder?.filter(e=>ie.has(e))??[...ie.keys()].sort((e,t)=>(ie.get(t)??0)-(ie.get(e)??0)),ce=t.rowOrder?.filter(e=>se.has(e))??[...se.keys()].sort((e,t)=>(se.get(t)??0)-(se.get(e)??0)),le=L([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),I,A,C,g,y,x,b,w,M,v,h,f,W,q,J,ae.join(","),ce.join(","),T.length,gn(T)]),de=Bc.getOrCompute(le,()=>function(e,t){const n=new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=Math.max(1,t.innerW-t.columnGap*Math.max(0,o.length-1)),i=t.proportionExponent,s=o.map(e=>Math.pow(n.get(e).length,i)),a=s.reduce((e,t)=>e+t,0)||1,c=e=>"uniform"===t.cellSizing?r/o.length:s[e]/a*r,l=new Map,u=[];let d=t.innerX;for(let e=0;o.length>e;e++)u.push({col:o[e],x:d,w:c(e)}),d+=c(e)+t.columnGap;let h=1;const f=new Map,p=[],m=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),r.minX>t-o&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},g=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=function(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,u=new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=function(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}(a),f=new Float64Array(d);let p=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>p&&(p=f[t]);const m=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/m,b=r/Math.ceil(d/m);for(let e=0;d>e;e++){const o=e%m,r=Math.floor(e/m);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*p),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;w>e;e++){v.clear();for(let e=0;d>e;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;d>e;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;1>=t;t++)for(let n=-1;1>=n;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;i.length>t;t++){const n=i[t];if(e>=n)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=f[e]+f[n],a=o*o+r*r;if(s*s>a)if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;d>e;e++){const i=f[e],s=t+i,a=t+o-i,u=n+i,d=n+r-i;g[e]=a>s?mn(g[e],s,a):c,y[e]=d>u?mn(y[e],u,d):l}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}(a,n,o,r,i,t.packPadding,t.iterations,h++);let u=1/0,d=1/0,f=-1/0,p=-1/0;for(const e of a){const t=c.get(e.id);l.set(e.id,{px:t.px,py:t.py}),m(s,t.px,t.py,e.r),u>t.px-e.r&&(u=t.px-e.r),t.px+e.r>f&&(f=t.px+e.r),d>t.py-e.r&&(d=t.py-e.r),t.py+e.r>p&&(p=t.py+e.r)}return Number.isFinite(u)?{x:u-Gc,y:d-Gc,w:f-u+2*Gc,h:p-d+2*Gc}:null};if("banded"===t.rowMode){const r=new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const s=t.rowOrder.filter(e=>r.has(e)),a=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),c=s.map(e=>Math.pow(r.get(e),i)),d=c.reduce((e,t)=>e+t,0)||1,h=new Map;let p=t.innerY+t.innerH;for(let e=0;s.length>e;e++){const n="uniform"===t.cellSizing?a/s.length:c[e]/d*a,o=p-n;h.set(s[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=P(n.get(e),e=>e.row);for(const e of s){const n=o.get(e),r=h.get(e);n&&r&&g(n,u[t].x,r.y,u[t].w,r.h,e)}});const m=[],y=new Map;for(const e of s){const t=h.get(e);y.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&m.push({x:n.minX-Gc,y:n.minY-Gc,w:n.maxX-n.minX+2*Gc,h:n.maxY-n.minY+2*Gc})}return{positions:l,enclosures:m,colBands:u,rowLabelY:y}}const y=new Map;o.forEach((e,o)=>{const r=P(n.get(e),e=>e.row),s=t.rowOrder.filter(e=>r.has(e)),a=Math.max(1,t.innerH-t.rowGap*Math.max(0,s.length-1)),c=s.map(e=>Math.pow(r.get(e).length,i)),l=c.reduce((e,t)=>e+t,0)||1;let d=t.innerY+t.innerH;s.forEach((e,n)=>{const i="uniform"===t.cellSizing?a/s.length:c[n]/l*a,h=d-i,f=g(r.get(e),u[o].x,h,u[o].w,i,e);if(f){p.push(f);const t=y.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,y.set(e,t)}d=h-t.rowGap})});const x=new Map;for(const[e,t]of y)x.set(e,t.sum/t.n);return{positions:l,enclosures:p,colBands:u,rowLabelY:x}}(T,{columnOrder:ae,rowOrder:ce,innerX:j,innerY:E,innerW:F,innerH:z,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),fe=e.selection,pe=fe?.isActive?fe.predicate:null,me=t.highlight??null,ge=t.dimOpacity??.16,ye=t.markStroke,xe=t.markStrokeWidth??0,be=t.markerColor??"#ffffff",we=t.iconColor??"rgba(255,255,255,0.92)",Me=t.iconStrokeWidth??1,ve=t.iconScale??.72,ke=[],$e=[],Se=[];for(const e of T){const t=de.positions.get(e.id);if(!t)continue;const n=O(e.datum,{highlight:me,predicate:pe,dimOpacity:ge}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:_(e.colorKey,G(e.shadeVal)),opacity:n,...ye?{stroke:ye,strokeWidth:xe}:{}},datum:e.datum,id:e.id,label:e.id+""};if(ke.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ve,r=he(e.iconShape,100);Se.push({x:t.px,y:t.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:e.iconShape,opacity:n})}e.marker&&n>ge+.001&&$e.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Ie=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(C>0?.45*C:9),r=[];for(let e=0;t.callouts.length>e;e++){const n=t.callouts[e],o=T.find(e=>e.datum[n.field]+""==n.value+"");if(!o)continue;const i=de.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=new Map;i.forEach((e,t)=>{s.set(e.ci,j+(t+.5)/i.length*F)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),Ie.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const Ae=function(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e);return(0,Dc.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,n)=>Rt({keyId:"enc-"+n,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity})),t.iconMarks.length>0&&(0,Dc.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>(0,Dc.jsx)("path",{d:ue(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+n))}),t.markerDots.length>0&&(0,Dc.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>(0,Dc.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+n))}),t.showColumnHeaders&&e.colBands.map((e,o)=>qt({keyId:"col-"+o,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor})),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>qt({keyId:"row-"+e,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>Vt(e))]})}(de,{markerDots:$e,markerColor:be,iconMarks:Se,iconColor:we,iconStrokeWidth:Me,callouts:Ie,plot:n,showEnclosures:k,showColumnHeaders:$,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*I,labelX:n.x+A-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel});return{sceneNodes:ke,overlays:Ae}},Gc=4,Yc=Ys(require("react")),Hc=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=j(t.categoryAccessor),r=j(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>F(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),d=!1!==t.showCategoryLabels,h=Math.max(0,n.height-(t.labelPadding??(d?22:0))),f=[],p=new Map,m=[],g=new Set,y=new Map;for(const t of e.data){const e=o(t)+"",n=r(t)+"",s=i(t);p.has(e)||(f.push(e),p.set(e,0),y.set(e,new Map)),g.has(n)||(g.add(n),m.push(n)),p.set(e,(p.get(e)??0)+s);const a=y.get(e);a.set(n,(a.get(n)??0)+s)}const x=t.categoryOrder?yn(t.categoryOrder,f,e=>p.has(e)):f,b=t.stackOrder?yn(t.stackOrder,m,()=>!0):m,w=x.reduce((e,t)=>e+(p.get(t)??0),0);if(0>=w)return{nodes:[]};const M=Math.max(0,n.width-s*Math.max(0,x.length-1)),v=[],k=[];let $=n.x;for(const t of x){const o=p.get(t)??0,r=o/w*M;if(0>=r)continue;k.push({cat:t,x:$,w:r});const i=y.get(t);let a=n.y;for(const n of b){const s=i.get(n)??0;if(0>=s)continue;const c=s/o*h;v.push({type:"rect",x:$,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,s),group:n}),a+=c}$+=r+s}return{nodes:v,overlays:d&&k.length>0?function(e,t,n){const o=e.map((e,o)=>qt({keyId:"marimekko-label-"+o,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return Yc.createElement(Yc.Fragment,null,...o)}(k,n.y+h+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}},_c=Ys(require("react")),Xc=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=t.rowHeight??28,r=t.rowGap??12,i=!1!==t.showLabels,s=i?t.labelWidth??120:0,a=!1!==t.showTicks,c=a?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+s,d=Math.max(0,n.width-s);if(0>=d)return{nodes:[]};const h=j(t.categoryAccessor),f=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},p=e=>f("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),m=e=>f("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),g=e=>{const n="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(n)?n.map(f).sort((e,t)=>e-t):[]},y="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",x="string"==typeof t.valueAccessor?t.valueAccessor:"value",b="string"==typeof t.targetAccessor?t.targetAccessor:"target",w=t.actualColor??e.theme.semantic.primary??"#3b6cb1",M=e.theme.semantic.text??"currentColor",v=t.targetColor??`var(--semiotic-text, ${M})`,k=[`var(--semiotic-surface, ${e.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${e.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${e.theme.semantic.border??"#a3a8af"})`],$=`var(--semiotic-text, ${M})`,S=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,I=[],A=[];for(let t=0;e.data.length>t;t++){const i=e.data[t],s=g(i),a=p(i),l=m(i),f=Math.max(a,l,...s.length?s:[0]);if(0>=f)continue;const M=n.y+t*(o+r+c);if(M+o+c>n.y+n.height)break;A.push({yTop:M,label:h(i),actual:a,target:l,maxVal:f});const $=e=>u+e/f*d,S=h(i),C=e=>F(t=>{t("metric",S),"metric"!==y&&t(y,S),e(t)});let j=u;for(let e=0;s.length>e;e++){const t=$(s[e]),n=t-j;n>0&&I.push({type:"rect",x:j,y:M,w:n,h:o,style:{fill:k[Math.min(e,k.length-1)],stroke:"none"},datum:C(t=>{t("range",e),t("rangeValue",s[e]),t("kind","range")}),group:"range-"+e}),j=t}const N=Math.max(6,Math.floor(.45*o));I.push({type:"rect",x:u,y:M+(o-N)/2,w:$(a)-u,h:N,style:{fill:w,stroke:"none"},datum:C(e=>{e("value",a),e("kind","actual"),"value"!==x&&e(x,a)}),group:"actual"});const E=3,P=Math.floor(.8*o);I.push({type:"rect",x:$(l)-E/2,y:M+(o-P)/2,w:E,h:P,style:{fill:v,stroke:"none"},datum:C(e=>{e("target",l),e("kind","target"),"target"!==b&&e(b,l)}),group:"target"})}const C=[];for(let e=0;A.length>e;e++){const t=A[e];if(i&&C.push(qt({keyId:"bullet-label-"+e,text:t.label,x:n.x+s-8,y:t.yTop+o/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:$})),a){const n=5,r=t.yTop+o+2;for(let o=0;n>o;o++){const i=t.maxVal*o/(n-1),s=u+i/t.maxVal*d;C.push(_c.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:s,x2:s,y1:r,y2:r+3,stroke:S,strokeWidth:1}),qt({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:s,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:S}))}}}return{nodes:I,overlays:C.length>0?_c.createElement(_c.Fragment,null,...C):null}},Uc=Ys(require("react")),Kc=require("d3-scale"),Qc=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(i>e&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,Kc.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",p=t.dimmedOpacity??.08,m=t.highlightFn,g=[],y=[];for(const n of e.data){const r=u?e.resolveColor(u(n)+""):f,i=!m||m(n),s=O(n,{predicate:m,baseOpacity:d,dimOpacity:p,brighten:.4}),a=i?y:g;for(let e=0;o.length-1>e;e++){const t=Number(n[o[e]]),u=Number(n[o[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:r,strokeWidth:m&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(d)}if(t.showPoints)for(let e=0;o.length>e;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`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=n.y+s,f=n.y+n.height-a,p=[];for(let e=0;o.length>e;e++){const a=o[e],m=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();p.push(Uc.createElement("line",{key:"pc-axis-line-"+e,x1:m,x2:m,y1:h,y2:f,stroke:i,strokeWidth:1})),p.push(qt({keyId:"pc-axis-label-"+e,text:a,x:m,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=r[a],w=5;for(let t=0;w>t;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);p.push(Uc.createElement("line",{key:`pc-tick-${e}-${t}`,x1:m-3,x2:m+3,y1:o,y2:o,stroke:i,strokeWidth:1}),qt({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:m+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Uc.createElement(Uc.Fragment,null,...p)}return{nodes:g.concat(y),overlays:x}},Zc=require("react/jsx-runtime"),Jc=1.75,el="#222222",tl=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=j(t.categoryAccessor??"name"),r=j(t.teaVolumeAccessor??"teaVolume"),i=j(t.bobaVolumeAccessor??"bobaVolume"),s=j(t.iceVolumeAccessor??"iceVolume"),a=j(t.cupHeightAccessor??"cupHeight"),c=j(t.cupTopRadiusAccessor??"cupTopRadius"),l=j(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=j(t.bobaRadiusAccessor??"bobaRadius"),d=t.cupWidthRatio??.82,h=e.scales.o,f=h.bandwidth(),p=Math.max(1,n.height-26-8),m=n.y+8,g=[],y=[];for(const t of e.data){const n=o(t)+"",x=h(n);if(null==x)continue;const b={height:Sn(a(t),15.5),topRadius:Sn(c(t),4.75),bottomRadius:Sn(l(t),3.75)},w=Sn(u(t),.6),M=Math.max(0,Sn(r(t),450)),v=Math.max(0,Sn(i(t),110)),k=Math.max(0,Sn(s(t),135)),$=Math.PI*w*w,S=Math.floor(v/$),I=S*$,A=Math.floor(k/5.359375),C=A*Jc*Jc*Jc,j=M+I+C,N=wn(b,j),E=Math.min(b.height,Math.max(0,N)),P=xn(b,E),{pearls:F,layers:z}=kn(b,w,S),O=E,L=$n(b,z*w*2,O,A),R=b.height-20.32,T=Math.min(0,R),D=Math.min(f*d/(2*(b.topRadius+1)),p/(b.height-T)),B=x+f/2,V=e=>B+e*D,G=e=>m+(e-T)*D,Y=V(-(b.topRadius+1)),H=V(b.topRadius+1),_=G(T),X=G(b.height),U=W({name:n,teaVolume:M,bobaVolume:Math.round(I),iceVolume:Math.round(C),totalVolume:Math.round(j),numBobas:S,numIce:A,kind:"boba cup"});g.push({type:"rect",x:Y,y:_,w:Math.max(1,H-Y),h:Math.max(1,X-_),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:U,group:n,_transitionKey:"boba-"+q(n)});const K=b.height-O,Q=q(n),Z=e.resolveColor(n);y.push((0,Zc.jsxs)("g",{children:[M>0?(0,Zc.jsx)("path",{d:`M${V(-P)},${G(K)} L${V(-b.bottomRadius)},${G(b.height)} L${V(b.bottomRadius)},${G(b.height)} L${V(P)},${G(K)} z`,fill:"#D2B799"}):null,F.map((e,t)=>(0,Zc.jsx)("circle",{cx:V(e.x),cy:G(e.z),r:w*D,fill:"#222222",opacity:.5},"p-"+t)),L.map((e,t)=>(0,Zc.jsx)("rect",{x:V(e.cx)-.95*Jc*D/2,y:G(e.cy)-.95*Jc*D/2,width:.95*Jc*D,height:.95*Jc*D,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${V(e.cx)} ${G(e.cy)})`},"i-"+t)),(0,Zc.jsx)("path",{d:`M${V(-b.topRadius)},${G(0)} L${V(-b.bottomRadius)},${G(b.height)} L${V(b.bottomRadius)},${G(b.height)} L${V(b.topRadius)},${G(0)}`,fill:"none",stroke:el,strokeWidth:2.5}),(0,Zc.jsx)("line",{x1:V(-(b.topRadius+1)),y1:G(0),x2:V(b.topRadius+1),y2:G(0),stroke:el,strokeWidth:3,strokeLinecap:"round"}),M>0?(0,Zc.jsx)("path",{d:`M${V(-.635)},${G(R)} L${V(-.635)},${G(b.height-.4)} L${V(.635)},${G(b.height-1.27-.4)} L${V(.635)},${G(R)} z`,fill:"#4F91CB",stroke:el,strokeWidth:1,opacity:.78}):null,(0,Zc.jsx)("text",{x:B,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),(0,Zc.jsx)("text",{x:B,y:X+30,textAnchor:"middle",fontSize:10,fill:Z,children:`${S} pearls · ${Math.round(j)} cm³`})]},"boba-"+Q))}return{nodes:g,overlays:(0,Zc.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},nl=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),ol=(new Set(["label","callout","callout-circle","callout-rect"]),2e4),rl=1,il=32,sl=6,al=4,cl=8,ll=72,ul=30,dl=-30,hl=8,fl=480,pl=3,ml={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},gl=["naturalGas","coal","nuclear","hydro","wind","solar","other"],yl={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},xl={tight:5,watch:12,comfortable:20},bl=Ys(require("react")),wl=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]>e)n=this.count++,n===this.capacity&&this.grow();else{let t=1;for(;this.capacity>t;)t*=2,this.tree[t]>e&&t++;n=t-this.capacity}let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return n>=t||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},Ml=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length||!t?.domain)return{nodes:[]};const o=so(t.laneAccessor),r=so(t.startAccessor),i=so(t.endAccessor),s=t.idAccessor?so(t.idAccessor):null,a=t.unit??0,c=t.barGap??1.5,l=Math.max(0,t.minBarWidth??2),u=t.minBarHeight??3.5,d=t.maxBarHeight??10,h=t.lanePadding??7,f=t.cornerRadius??2,p=t.bottomInset??0,m=t.color??((t,n)=>e.resolveColor(n)),[g,y]=t.domain,x=y-g||1,b=e=>n.x+(e-g)/x*n.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(o))]),v=Math.max(0,n.height-p)/Math.max(1,M.length),k=e=>b(r(e)),$=e=>Math.max(k(e)+l,b(i(e)+a)),S=[];M.forEach((t,r)=>{const i=n.y+r*v,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:p}=ro(a,{start:k,end:$}),g=new Map,y=new Map;for(const{item:e,track:t}of l){const n=y.get(t);n?n.push(e):y.set(t,[e])}for(const e of y.values()){e.sort((e,t)=>k(e)-k(t));for(let t=0;e.length-1>t;t++)g.set(e[t],k(e[t+1]))}const x=(v-2*h)/p,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:e,track:n}of l){const o=k(e),r=g.get(e),a=$(e)-o;S.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:m(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?s(e)+"":void 0})}});const I=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,C=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,j=[];(t.periods??[]).forEach((e,t)=>{const o=b(e.start),r=Math.max(1,b(e.end+a)-o);j.push(bl.createElement("rect",{key:"period-"+t,x:o,y:n.y,width:r,height:n.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&j.push(qt({keyId:"period-label-"+t,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:A}))});const N=!1!==t.showLaneLabels,E=t.laneLabelGap??12;if(M.forEach((e,t)=>{const o=n.y+t*v;j.push(bl.createElement("line",{key:"lane-sep-"+t,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:C,opacity:.45})),N&&j.push(qt({keyId:"lane-label-"+t,text:e,x:n.x-E,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:I}))}),!1!==t.showAxis){const e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));j.push(Bt({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:A}))}return{nodes:S,overlays:bl.createElement(bl.Fragment,null,...j)}},vl={width:60,height:34},kl=e=>{const{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=yo(e.nodes,e.edges,t,e.config),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[];e.edges.forEach((t,o)=>{const i=r.get((a=t,("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(a):N(a,e.config.sourceAccessor??"source",void 0))+""));var a;const c=r.get((t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):N(t,e.config.targetAccessor??"target",void 0))+"")(t));if(!i||!c)return;const{from:l,to:u}=lo({cx:i.x,cy:i.y,width:i.width,height:i.height},{cx:c.x,cy:c.y,width:c.width,height:c.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:ao(l,u,{orientation:"y"===n?"vertical":"horizontal",bend:uo(o,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:E(t)??t})});const a=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:a}},$l=require("react/jsx-runtime"),Sl=1.15,Il={a:.556,b:.556,c:.5,d:.556,e:.556,f:.278,g:.556,h:.556,i:.222,j:.222,k:.5,l:.222,m:.833,n:.556,o:.556,p:.556,q:.556,r:.333,s:.5,t:.278,u:.556,v:.5,w:.722,x:.5,y:.5,z:.5,"'":.191,"-":.333,".":.278," ":.278},Al=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=j(t.textAccessor),r=e=>{const n=Number(j(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},i=j(t.columnAccessor),s=e=>Number(j(t.segmentAccessor)(e)),a=t.minFontSize??11,c=t.maxFontSize??42,l=t.columnGutter??18,u=t.collisionPadding??2,d=!1!==t.showColumnLabels,h=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,p=t.segmentTickFormat??(e=>Math.round(e)+""),m=t.rotate??0,g=!0===t.repeatWords,y=!1!==t.scaleToFit,x=t.packingDensity??.6,b="string"==typeof t.textAccessor?t.textAccessor:"word",w="string"==typeof t.weightAccessor?t.weightAccessor:"weight",M="string"==typeof t.columnAccessor?t.columnAccessor:"column",v="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",k=[],$=new Map;let S=1/0,I=-1/0;for(let t=0;e.data.length>t;t++){const n=e.data[t],a=i(n)+"",c=o(n)+"",l=r(n),u=s(n);c&&Number.isFinite(u)&&($.has(a)||(k.push(a),$.set(a,[])),$.get(a).push({col:a,text:c,weight:l,segment:u,datum:n,dataIndex:t}),S>u&&(S=u),u>I&&(I=u))}if(0===k.length)return{nodes:[]};if(!g)for(const[e,t]of $){const n=new Map;for(const e of t){const t=n.get(e.text);t&&t.weight>=e.weight||n.set(e.text,e)}$.set(e,[...n.values()])}let A=1/0,C=-1/0;for(const e of $.values())for(const t of e)A>t.weight&&(A=t.weight),t.weight>C&&(C=t.weight);if(!Number.isFinite(A))return{nodes:[]};const N=t.columnOrder?[...t.columnOrder.filter(e=>$.has(e)),...k.filter(e=>!t.columnOrder.includes(e))]:k,E=new Map(N.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[P,z]=t.segmentDomain??[S,I],O=z-P||1,L=C-A||1,R=d?22:0,T=h?52:0,W=n.x+T,q=n.y+R,B=Math.max(0,n.width-T),V=Math.max(0,n.height-R),G=N.length,Y=G>0?Math.max(0,B-l*Math.max(0,G-1))/G:0,H=q+14,_=q+V-14,X=e=>H+(e-P)/O*(_-H),U=Y*V;let K=1/0,Q=1/0;const Z=N.map((e,n)=>{const o=E.get(e),r=($.get(e)??[]).map(e=>{const r={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:n,resolvedColumnColor:o},i=t.wordOpacity?Number(t.wordOpacity(r)):1,s=t.wordColor?.(r);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:(l=e.weight,a+Math.sqrt((l-A)/L)*(c-a)),opacity:Number.isFinite(i)?D(i,0,1):0,color:s||o,info:r};var l});if(0===r.length)return null;let i=0;for(const e of r){const t=1.05*wo(e.text);i+=t*Sl*e.baseFont*e.baseFont,Q=Math.min(Q,(Y-8-1)/(t*e.baseFont))}return i>0&&(K=Math.min(K,Math.sqrt(x*U/i))),{col:e,colLeft:W+n*(Y+l),center:W+n*(Y+l)+Y/2,rows:r}}).filter(e=>null!==e),J=e=>{const t=[];let n=0;for(const o of Z){if(0>=Y)continue;const r=o.colLeft+4,i=o.colLeft+Y-4,s=o.rows.map((t,n)=>{const r=Math.max(5,e*t.baseFont),i=`${o.col}::${t.text}::${n}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:r,w:Mo(t.text,r),h:r*Sl+2,anchorY:X(t.segment),seed:(bo(i)-.5)*Math.min(.5*Y,80),opacity:t.opacity,color:t.color,info:t.info}}).sort((e,t)=>t.font-e.font||(t.id>e.id?-1:1)),a=[];for(const e of s){const s=e.w/2,c=e.h/2,l=D(o.center+e.seed,r+s,i-s),d=e.anchorY;let h=l,f=D(d,H+c,_-c),p=!1;for(let t=0;2600>t;t++){const n=3.2*Math.sqrt(t),o=2.399963229728653*t,m={x:D(l+n*Math.cos(o),r+s,i-s),y:D(d+n*Math.sin(o),H+c,_-c),w:e.w,h:e.h};if(!vo(m,a,u)){h=m.x,f=m.y,p=!0;break}}p||n++,a.push({x:h,y:f,w:e.w,h:e.h});const g=Math.sqrt((e.weight-A)/L),y=m>0?2*(bo(e.id+"r")-.5)*m:0;t.push({id:e.id,text:e.text,x:h,y:f,fontSize:e.font,rotation:y,color:e.color,opacity:e.opacity,datum:F(t=>{for(const n of Object.keys(e.info.datum))t(n,e.info.datum[n]);t("word",e.text),t("weight",e.weight),t("column",o.col),t("segment",e.segment),"word"!==b&&t(b,e.text),"weight"!==w&&t(w,e.weight),"column"!==M&&t(M,o.col),"segment"!==v&&t(v,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:n}};let ee=y?Math.min(1,K,Q):Math.min(1,Q),te=J(ee);if(y)for(let e=0;6>e&&te.unplaced>0&&ee>.1;e++)ee*=.88,te=J(ee);const ne=te.placed.filter(e=>e.opacity>0);return{nodes:ne.map(e=>{const t=Mo(e.text,e.fontSize)/2,n=e.fontSize*Sl/2;return{type:"rect",x:e.x-t,y:e.y-n,w:2*t,h:2*n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:(0,$l.jsxs)("g",{className:"semiotic-word-trails",children:[h&&ko({x:n.x+T-10,yTop:H,yBot:_,segLo:P,segHi:z,segToY:X,tickCount:f,tickFormat:p,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),d&&N.map((e,t)=>Y>0?(0,$l.jsx)("text",{x:W+t*(Y+l)+Y/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:E.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ne.map(e=>(0,$l.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},"wt-"+e.id))]})}},Cl={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},jl=8,Nl=Eo,El=2*Math.PI,Pl=[40,40],Fl=[.5,.5],zl=require("react/jsx-runtime"),Ol="var(--semiotic-text, currentColor)",Ll=8,Rl=new Set(["rows"]),Tl=class{constructor(e){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{const t=this.options.parseMessage(e.data),n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||this.options.name+" worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error(this.options.name+" worker session is closed"));if(t?.aborted)return Promise.reject(Lr(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{const e=1===this.pending.size;this.pending.delete(n),t?.removeEventListener("abort",i),r(Lr(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error(this.options.name+" worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Wl=4e4,ql={},Dl=class{constructor(e=function(){const e="string"==typeof ql.url&&ql.url?new URL("./forceLayoutWorker.js",ql.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.session=new Tl({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=function(e){return e&&"object"==typeof e?{requestId:e.requestId,error:e.error}:{}}(t);return o?{requestId:n,ok:!1,error:Rr(o)}:{requestId:n,ok:!0,payload:{positions:t.positions??{}}}}})}get isDead(){return this.session.isDead}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},Bl=function(){let e=null;return{get:()=>(e&&!e.isDead||(e=new Dl),e),resetForTest:()=>{if(e){try{e.terminate()}catch{}e=null}}}}(),Vl=[.1,.5,.9],Gl=1e6,Yl=12,Hl=require("react/jsx-runtime"),_l={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"}},Xl=6.2,Ul={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1};
|