semiotic 3.10.3 → 3.10.4
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 +17 -18
- package/ai/artifact-surface-inventory.json +1 -1
- package/ai/behaviorContracts.cjs +14 -4
- package/ai/behaviorContracts.d.cts +3 -0
- package/ai/cli.js +17 -166
- package/ai/componentMetadata.cjs +68 -15
- package/ai/componentMetadata.d.cts +3 -0
- package/ai/dist/diagnose-operation.js +3 -0
- package/ai/dist/mcp-server.js +59 -59
- package/ai/reference.md +3 -3
- package/ai/schema.json +1 -1
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/ai/task-packets/compare-category-totals.json +7 -7
- package/ai/task-packets/compare-category-totals.md +3 -3
- package/ai/task-packets/correct-published-chart.json +7 -7
- 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 +7 -7
- package/ai/task-packets/update-live-chart.md +3 -3
- package/dist/{c-FHNY57SO.min.js → c-2MHSD3TN.min.js} +46 -46
- package/dist/{c-5PIKBUMF.min.js → c-6XGGN5OS.min.js} +1 -1
- package/dist/c-EK6XI2U7.min.js +26 -0
- package/dist/{c-4XLHPQTP.min.js → c-JBWPJNTJ.min.js} +1 -1
- package/dist/c-KWP4QTCM.min.js +4 -0
- package/dist/c-LRV7PO45.min.js +393 -0
- package/dist/c-LVHJJUOF.min.js +1 -0
- package/dist/c-NUBZ63VU.min.js +1 -0
- package/dist/{c-ZVOFLE2P.min.js → c-RWHLEUX6.min.js} +6 -6
- package/dist/{c-4JKDJUYD.min.js → c-S746GRV4.min.js} +1 -1
- package/dist/{c-ISA6IJ6V.min.js → c-UQBWSYKI.min.js} +5 -5
- package/dist/components/ai/chartClinic.d.ts +1 -1
- package/dist/components/ai/chartClinicMetadata.generated.d.ts +2 -2
- package/dist/components/charts/shared/{chartDefinitionPilot.d.ts → chartDefinition.d.ts} +30 -34
- package/dist/components/charts/shared/chartDefinitions.d.ts +10 -0
- package/dist/components/charts/shared/chartDefinitionsNetwork.d.ts +17 -0
- package/dist/components/charts/shared/chartDefinitionsOrdinal.d.ts +23 -0
- package/dist/components/charts/shared/chartDefinitionsPhysics.d.ts +17 -0
- package/dist/components/charts/shared/chartDefinitionsRealtime.d.ts +12 -0
- package/dist/components/charts/shared/chartDefinitionsXY.d.ts +26 -0
- package/dist/components/server/serverChartConfigs.d.ts +36 -36
- package/dist/components/server/serverChartConfigsNetwork.generated.d.ts +17 -0
- package/dist/components/server/serverChartConfigsOrdinal.generated.d.ts +23 -0
- package/dist/components/server/serverChartConfigsPhysics.generated.d.ts +17 -0
- package/dist/components/server/serverChartConfigsRealtime.generated.d.ts +13 -0
- package/dist/components/server/serverChartConfigsXY.generated.d.ts +22 -0
- package/dist/components/stream/physics/PhysicsOptionalEngineAdapters.d.ts +5 -0
- package/dist/network.module.min.js +1 -1
- package/dist/physics-matter.min.js +4 -1
- package/dist/physics-matter.module.min.js +1 -1
- package/dist/physics-rapier.min.js +4 -1
- package/dist/physics-rapier.module.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +3 -3
- package/dist/semiotic-ai-core.module.min.js +3 -3
- package/dist/semiotic-ai.module.min.js +2 -2
- package/dist/semiotic-artifact.min.js +1 -1
- package/dist/semiotic-artifact.module.min.js +1 -1
- package/dist/semiotic-client-cjs-shared.min.js +4 -4
- 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-vacp.module.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +13 -13
- package/dist/semiotic-server-edge-node.module.min.js +393 -391
- package/dist/semiotic-server-edge.min.js +393 -391
- package/dist/semiotic-server-edge.module.min.js +374 -372
- package/dist/semiotic-server-node.min.js +393 -391
- package/dist/semiotic-server-node.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 +9 -9
- package/dist/server.min.js +393 -391
- package/dist/server.module.min.js +1 -1
- package/package.json +8 -4
- package/dist/c-3OFVBWQY.min.js +0 -1
- package/dist/c-43XNOQNQ.min.js +0 -391
- package/dist/c-6IVBV5NO.min.js +0 -1
- package/dist/c-KXH7LFIL.min.js +0 -26
- package/dist/c-UBHICVSC.min.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function e(e,t,r){let n=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,o=e=>Number.isFinite(e)?Math.max(0,e):0,i=e.reduce((e,t)=>e+(o(t.weight)>0?1:0),0),a=i>0?Math.min(Math.max(0,Math.floor(r?.minPerCategory??0)),Math.floor(n/i)):0,l=e.reduce((e,t)=>e+o(t.weight),0);if(0>=n||0>=l)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));let s=e.map(e=>{let t=o(e.weight),r=t/l*n;return{...e,exact:r,cells:t>0?Math.max(a,Math.floor(r)):0,remainder:r-Math.floor(r)}}),c=s.reduce((e,t)=>e+t.cells,0);for(;c>n;){let e=s.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--,c--}let u=s.filter(e=>o(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||o(t.weight)-o(e.weight)||e.key.localeCompare(t.key));for(let e=0;n>c;e++)u[e%u.length].cells++,c++;return s}function t(e){return null==e?null:"function"==typeof e?e:t=>t[e]}function r(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}function n(e,t,r,n){let o=/* @__PURE__ */new Set;return e.map((e,i)=>{let a=t(e,i)+"",l=Number(r(e,i));if(!a)throw Error(`${n} snapshot contains an empty id at index ${i}.`);if(o.has(a))throw Error(`${n} snapshot contains duplicate id "${a}".`);if(!Number.isFinite(l)||0>l)throw Error(`${n} snapshot value for "${a}" must be a finite non-negative number.`);return o.add(a),{id:a,value:l}})}function o(e,t,r){let o=r.afterId??r.beforeId,i=r.afterValue??r.beforeValue,a=null==r.epsilon||0>r.epsilon?1e-9:r.epsilon,l=n(e,r.beforeId,r.beforeValue,"Before"),s=n(t,o,i,"After"),c=new Map(l.map(e=>[e.id,e.value])),u=new Map(s.map(e=>[e.id,e.value])),d=l.reduce((e,t)=>e+t.value,0),h=s.reduce((e,t)=>e+t.value,0),f=a>=Math.abs(d-h);if(!f&&!r.allowImbalance)throw Error(`Snapshot totals must match (before ${d}, after ${h}). Pass allowImbalance to inspect residuals.`);let m=[],p=[...l.map(e=>e.id),...s.map(e=>e.id).filter(e=>!c.has(e))];for(let e of p){let t=Math.min(c.get(e)??0,u.get(e)??0);t>a&&m.push({sourceId:e,targetId:e,value:t,kind:"stay"})}let g=l.map(e=>({id:e.id,value:e.value-(u.get(e.id)??0)})).filter(e=>e.value>a),y=s.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>a),x=0,b=0;for(;g.length>x&&y.length>b;){let e=g[x],t=y[b],r=Math.min(e.value,t.value);r>a&&m.push({sourceId:e.id,targetId:t.id,value:r,kind:"move"}),e.value-=r,t.value-=r,a>=e.value&&(x+=1),a>=t.value&&(b+=1)}return{flows:m,beforeTotal:d,afterTotal:h,balanced:f,unmatchedBefore:g.slice(x).filter(e=>e.value>a).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:y.slice(b).filter(e=>e.value>a).map(({id:e,value:t})=>({id:e,value:t}))}}function i(e){return Number.isFinite(e)?Math.max(0,e):0}function a(e,t){let r=Number(t.unit),n=i(e),o=t.maxUnits??1/0,a=t.minFraction??0;if(0>=r||0>=o||0>=n)return{units:[],unit:r>0?r:0,total:n,shown:0,overflow:n>0&&!(o>0)};let l=Math.ceil(n/r-1e-6),s=Math.min(o,l),c=l>o,u=[];for(let e=0;s>e;e+=1){let t=e*r,o=Math.min(1,Math.max(0,(Math.min(n,t+r)-t)/r));1e-6>1-o&&(o=1),u.push({index:e,fraction:o,start:t,end:t+o*r,value:o*r})}let d=u[u.length-1];d&&a>d.fraction&&1>d.fraction&&u.pop();let h=u.reduce((e,t)=>e+t.value,0);return{units:u,unit:r,total:n,shown:h,overflow:c}}function l(e,t,r){let n=a(e,r),o=Math.max(i(t),n.total);if(n.total>=o)return{...n,rangeUnits:[],rangeTotal:n.total};let l=a(o,{unit:r.unit,maxUnits:r.maxUnits}),s=l.unit>0?n.total/l.unit:0,c=Math.floor(s+1e-6),u=Math.min(1,Math.max(0,s-c));1e-6>u&&(u=0);let d=[];for(let e of l.units)if(e.index>=c){if(e.index===c&&u>0){e.fraction-u>1e-6&&d.push({...e,startFraction:u,start:e.index*l.unit+u*l.unit,value:(e.fraction-u)*l.unit});continue}d.push({...e,startFraction:0})}return{...n,overflow:n.overflow||l.overflow,rangeUnits:d,rangeTotal:o}}function s(e,t,r={}){let n=r.iterations??260,o=r.repulsion??5200,i=r.linkDistance??165,a=r.linkStrength??.045,l=r.centerStrength??.018,s=r.damping??.84,c=r.nodeRadius??12,u=r.nodePadding??3,d=r.inset??.06,h=Wi(r.seed??1),f=/* @__PURE__ */new Map;for(let t of e)f.set(t.id,0);for(let e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);let m=500,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=e=>"function"==typeof c?c(e.data):c,y=new Set(e.map(e=>e.id)),x=t.filter(e=>y.has(e.source)&&y.has(e.target)).map(e=>({source:e.source,target:e.target}));if(n>0){let e=cl(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/n)).velocityDecay(Math.max(0,Math.min(1,1-s))).force("charge",sl().strength(e=>{let t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",al(e=>g(e)+u).strength(.9).iterations(2)).force("center",il(m,m).strength(.8)).force("x",ul(m).strength(l)).force("y",dl(m).strength(l));x.length>0&&e.force("link",ll(x).id(e=>e.id).distance(i).strength(e=>{let t="string"==typeof e.target?e.target:e.target.id,r=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/r})),e.stop();for(let t=0;n>t;t+=1)e.tick()}let b=1/0,w=1/0,M=-1/0,v=-1/0;for(let e of p){let t=e.x??m,r=e.y??m;b>t&&(b=t),w>r&&(w=r),t>M&&(M=t),r>v&&(v=r)}let k=M-b,$=v-w,A={};for(let e of p)Object.defineProperty(A,e.id,{value:{x:0===k?.5:d+((e.x??m)-b)/k*(1-2*d),y:0===$?.5:d+((e.y??m)-w)/$*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return A}function c(e){return Array.isArray(e)}function u(e){return e?e.map(Number).filter(Number.isFinite):[]}function d(e){if("fixed-denominator"===e.countStrategy)return 1/0;let t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function h(e,t){let r=d(t);return e.length>r?{tokens:e.slice(0,r),overflow:!0}:{tokens:e,overflow:!1}}function f(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:u(e),data:e}:e}function m(e){let t=e.unitValue??e.unit,r=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=r&&{icon:r}}}function p(e){if(e.samples)return u(e.samples);if(!e.data||!e.valueAccessor)return[];let t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function g(e,t){let r=e.length;if(0===r)return 0;if(1===r)return e[0];let n=(r-1)*Math.min(1,Math.max(0,t)),o=Math.floor(n),i=n-o;return e[o]*(1-i)+e[Math.ceil(n)]*i}function y(e,t=1){let r=Array.from({length:e},(e,t)=>t),n=Wi(Math.floor(t)||1);for(let e=r.length-1;e>0;e-=1){let t=Math.floor(n()*(e+1)),o=r[e];r[e]=r[t],r[t]=o}return r}function x(e,t,r,n={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:r,start:t,end:t+r,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...n}}function b(e,t){let r,n,o,i,s,c,u,b=m(t),w=f(e),v=0,k=!1;if("unitized"===b.countStrategy){s=b.unitValue??1;let e={unit:s,maxUnits:b.maxTokens,minFraction:b.minFraction},t=null==w.rangeValue?a(Ga(w.value),e):l(Ga(w.value),Ga(w.rangeValue),e);r=t.units.map(e=>x(b,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),n=t.total,v=t.shown,k=t.overflow,null!=w.rangeValue&&(c=t.rangeTotal,u=t.rangeUnits.map(e=>x(b,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"===b.countStrategy){i=Math.floor(Ga(w.denominator??b.denominator)),o=Ga(w.numerator??b.numerator??w.value);let e=Math.min(i,Math.max(0,Math.round(o)));r=Array.from({length:i},(t,r)=>x(b,r,1,{highlighted:e>r,start:r,end:r+1})),n=i,v=r.length,k=!1}else if("quantile"===b.countStrategy){let e=p(w).sort((e,t)=>e-t),t=Math.max(0,Math.floor(b.tokenCount??50)),o=e.length>0?Math.min(t,d(b)):0;r=Array.from({length:o},(t,r)=>{let n=(r+.5)/o,i=g(e,n);return x(b,r,i,{sample:i,quantile:n,start:i,end:i})}),n=e.length,v=r.length,k=e.length>0&&t>r.length}else if("sample"===b.countStrategy||"posterior-sample"===b.countStrategy||"random-sample"===b.countStrategy){let e=p(w),t=Math.min(e.length,Math.max(0,Math.floor(b.tokenCount??e.length))),o=Math.min(t,d(b));r=("random-sample"===b.countStrategy?y(e.length,b.seed).slice(0,o):Array.from({length:o},(t,r)=>Math.floor(r/Math.max(1,o-1)*(e.length-1)))).map((t,r)=>{let n=e[t];return x(b,r,n,{sample:n,start:n,end:n})}),n=e.length,v=r.length,k=t>r.length}else{let e=w.data;if(e&&null==w.value)r=e.map((e,t)=>x(b,t,1,{datum:e})),n=e.length;else{let e=a(Ga(w.value),{unit:1,maxUnits:b.maxTokens,minFraction:b.minFraction});r=e.units.map(e=>x(b,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),n=e.total,v=e.shown,k=e.overflow}if(e&&null==w.value){let e=h(r,b);r=e.tokens,v=r.length,k=e.overflow}}return{tokens:r,encoding:b,total:n,shown:v,overflow:k,numerator:o,denominator:i,unitValue:s,rangeTotal:c,rangeTokens:u,diagnostics:M(b,{visibleTokens:r.length+(u?.length??0)})}}function w(e,t={}){let r=c(e)?e:e.tokens,n=r.length;if(0===n)return[];let o=t.flow??"row",i=t.cellWidth??16,a=t.cellHeight??i,l=t.gutter??2,s=t.anchor??[.5,.5],u=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?n/t.rows:Math.sqrt(n)))),d=Math.max(1,Math.floor(t.rows??Math.ceil(n/u))),h="row"===o?Math.max(d,Math.ceil(n/u)):d,f="column"===o?Math.max(u,Math.ceil(n/d)):u,m=t.x??0,p=t.y??0;return r.map((e,r)=>{let n,c;return"column"===o?(c=Math.floor(r/d),n=r%d):(n=Math.floor(r/u),c=r%u),"left"===t.columnDirection&&(c=f-1-c),"up"===t.rowDirection&&(n=h-1-n),{...e,row:n,column:c,x:m+c*(i+l)+s[0]*i,y:p+n*(a+l)+s[1]*a}})}function M(e,t={}){let r=[],n=e.tokenSemantics,o=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==o||Ga(e.denominator)>100?80:100);return n||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),o||r.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)&&r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&r.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"===n&&("icon"===e.tokenType||"glyph"===e.tokenType)&&r.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===n&&o&&"unitized"!==o&&r.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"===n&&o&&"fixed-denominator"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),("possible-outcome"===n||"posterior-sample"===n||"hypothetical-case"===n)&&o&&"quantile"!==o&&"sample"!==o&&"posterior-sample"!==o&&"random-sample"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===n&&"unitized"===o&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"===n&&"unitized"===o&&!e.unitMeaning&&r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function v(e){return"small"===e?25:"large"===e?100:50}function k(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 $(e){let t=k(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 A(e){let t=k(e.taskIntent),r=v(e.availableSpace);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){let e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:r,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:M(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){let 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:M(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){let 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:M(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){let 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:r,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:M(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 S(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function I(e,t,r){return"function"==typeof e?e(t)??r:e??r}function C(e,t){return"function"==typeof e?e(t):e}function N(e){return e.sample??e.value??e.index}function F(e,t,r){if(t.columns)return t.columns;if(t.width&&r>0){let e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(r+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function E(e,t){let r=t.positionToken;return r?e.map((t,n)=>{let o=r(t,n,e);return{...t,x:o.x,y:o.y,row:o.row??n,column:o.column??0}}):[]}function z(e,t){if(0===e.length)return[];let r=t.x??0,n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,a=Math.max(1,Math.floor(t.rows??1)),l=e.map(N),s=Math.min(...l),c=Math.max(...l)-s||1;return e.map((l,u)=>{let d=N(l),h=u%a,f=t.valueToX?t.valueToX(d,l):r+(d-s)/c*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,l):n+h*(o+i);return{...l,x:f,y:m,row:h,column:u}})}function R(e,t){if(0===e.length)return[];let r=t.x??0,n=t.y??0,o="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,a=t.cellWidth??o+i,l=t.cellHeight??o+i,s=e.map(N),c=Math.min(...s),u=Math.max(...s)-c||1,d=/* @__PURE__ */new Map;return e.map(o=>{let i=N(o),s=t.valueToX?t.valueToX(i,o):r+(i-c)/u*(t.width??Math.max(1,e.length-1)*a),h=Math.round((s-r)/Math.max(1,a)),f=d.get(h)??0;d.set(h,f+1);let m=t.valueToY?t.valueToY(i,o):n+f*l;return{...o,x:r+h*a,y:m,row:f,column:h}})}function L(e,t){if(!t.valueToX)return[];let r=t.y??0,n=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),o=t.anchor??[.5,.5];return e.map((e,i)=>{let a=Number.isFinite(e.start)?e.start:N(e),l=(a+(Number.isFinite(e.end)?e.end:a+e.value))/2,s=t.valueToY?t.valueToY(l,e):r+o[1]*n;return{...e,x:t.valueToX(l,e),y:s,row:0,column:i}})}function T(e,t){let r=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return E(r,t);let n=t.layout??e.encoding.layout??"grid";if("quantile-strip"===n)return z(r,t);if("dotplot"===n)return R(r,t);if("bar-segment"===n){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return L(r,t)}if("beeswarm"===n||"small-multiple"===n)throw Error(`tokenLayer layout "${n}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);let o="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??o??12,a=t.cellHeight??o??i,l="row"===n?Math.max(1,r.length):"column"===n||"stack"===n?1:"waffle"===n&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:F(r,t,i);return w(r,{...t,columns:l,cellWidth:i,cellHeight:a})}function P(e){if(e)return Ml[e]}function j(e){return e&&$l.has(e)?e:void 0}function O(e,t){return void 0!==t.datum?I(t.datum,e,null):e.datum??null}function W(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?I(t.rangeColor,e,"var(--semiotic-secondary, #9ca3af)"):I(t.color,e,vl):I(t.inactiveColor,e,kl),stroke:"none",...C(t.style,e)??{}}}function D(e,t){let r=C(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:O(e,t),accessibleDatum:C(t.accessibleDatum,e),accessibility:C(t.accessibility,e),pointId:r,_transitionKey:r}}function q(e,t){let r=I(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:I(t.radius,e,r/2),style:W(e,t),...D(e,t)}}function B(e,t){let r=I(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,r/2)**2,symbolType:I(t.symbolType,e,"circle"),path:C(t.symbolPath,e),rotation:C(t.rotation,e),style:W(e,t),...D(e,t)}}function V(e,t,r){let n=W(e,r),o=I(r.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:o,glyph:t,color:(n.fill??vl)+"",accent:I(r.accent,e,"var(--semiotic-bg, #ffffff)"),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:I(r.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?C(r.ghostColor,e)??kl:void 0,rotation:C(r.rotation,e),style:n,...D(e,r)}}function G(e,t,r){if("dot"===r.tokenType)return q(e,t);let n=C(t.glyph,e)??P(r.icon);if(n)return V(e,n,t);let o=j(r.icon);return B(e,o&&null==t.symbolType?{...t,symbolType:o}:t)}function H({input:e,encoding:t,options:r={}}){if(!S(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");let n=S(e)?{...e,encoding:m(e.encoding)}:b(e,t),o=T(n,r).filter(e=>!r.include||r.include(e));return{tokenSet:n,positionedTokens:o,nodes:o.map(e=>G(e,r,n.encoding))}}function Y(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function _(e,t){let r=Y(e,t);return"string"==typeof r&&r.length>0?r:void 0}function X(e){return zl.has(e)?e:void 0}function K(e,t){let r=Y(e,t),n=X("string"==typeof r?r:Y(r,"kind"));if(!n)return;if("string"==typeof r)return{kind:n};let o=Y(r,"coverage"),i="number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0,a=_(r,"fill");return{kind:n,...null==i?{}:{coverage:i},...a?{fill:a}:{}}}function U(e){return _(Nl,e)??Nl.land}function Q(e){return _(Fl,e)??Fl.land}function Z(e,t){if(El.has(t))return _(e,t)}function J(e,t){if("function"==typeof e)return e;let r=e??t;return e=>e[r]}function ee(e,t,r){return[111.32*(e-r.lon)*Math.cos((t+r.lat)/2*(Math.PI/180)),110.574*(t-r.lat)]}function te(e){let t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function re(e){return El.has(e)?e:"monument"}function ne(e,t){let r=te(t.gridSize),n=Math.max(1,t.gridRadiusKm??75),o=2*n/r,i=Math.floor(r/2),a=J(t.idAccessor,"id"),l=J(t.nameAccessor,"name"),s=J(t.longitudeAccessor,"lon"),c=J(t.latitudeAccessor,"lat"),u=J(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?J(t.candidatePriorityAccessor,"priority"):()=>0,h=/* @__PURE__ */new Map,f=null;for(let m of e){let e=Number(s(m)),p=Number(c(m));if(!Number.isFinite(e)||!Number.isFinite(p))continue;let g=(a(m)??`${e},${p}`)+"",y=(l(m)??g)+"",x=re(u(m)),[b,w]=ee(e,p,t.center);if(Math.abs(b)>n||Math.abs(w)>n)continue;let M=Math.min(r-1,Math.max(0,Math.floor((b+n)/o))),v=Math.min(r-1,Math.max(0,Math.floor((n-w)/o))),k=(M+.5)*o-n,$=n-(v+.5)*o,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);let S=`${v}:${M}`,I=h.get(S)??[];I.push(A),h.set(S,I)}let m=/* @__PURE__ */new Map;f&&m.set("city",1);let p=[];for(let e=0;r>e;e++)for(let t=0;r>t;t++){let r,a,l=`tile-${e}-${t}`,s=(t+.5)*o-n,c=n-(e+.5)*o;if(e===i&&t===i&&f){r=f;let 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));a=[f,...n]}else{let n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{let r=e.candidatePriority-t.candidatePriority;if(0!==r)return r;let n=m.get(e.kind)??0,i=m.get(t.kind)??0,a=o*o*.35;return e.cellDistanceSq+n*a-(t.cellDistanceSq+i*a)||e.name.localeCompare(t.name)}),r=n[0]??null,a=n}r&&m.set(r.kind,(m.get(r.kind)??0)+1),p.push({id:l,row:e,column:t,centerXKm:s,centerYKm:c,terrainIndex:Math.abs((17*e+31*t)%Cl.length),landmark:r,landmarks:a})}return p}function oe(e,t,r,n){return`M${e},${t-n/2}L${e+r/2},${t}L${e},${t+n/2}L${e-r/2},${t}Z`}function ie({tiles:e,tileWidth:t,tileHeight:r,sprites:n,resourceSize:o,citySize:i,showCityLabel:a}){let l=xa(),s=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */
|
|
1
|
+
function e(e,t,r){let n=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,o=e=>Number.isFinite(e)?Math.max(0,e):0,i=e.reduce((e,t)=>e+(o(t.weight)>0?1:0),0),a=i>0?Math.min(Math.max(0,Math.floor(r?.minPerCategory??0)),Math.floor(n/i)):0,l=e.reduce((e,t)=>e+o(t.weight),0);if(0>=n||0>=l)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));let s=e.map(e=>{let t=o(e.weight),r=t/l*n;return{...e,exact:r,cells:t>0?Math.max(a,Math.floor(r)):0,remainder:r-Math.floor(r)}}),c=s.reduce((e,t)=>e+t.cells,0);for(;c>n;){let e=s.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--,c--}let u=s.filter(e=>o(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||o(t.weight)-o(e.weight)||e.key.localeCompare(t.key));for(let e=0;n>c;e++)u[e%u.length].cells++,c++;return s}function t(e){return null==e?null:"function"==typeof e?e:t=>t[e]}function r(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}function n(e,t,r,n){let o=/* @__PURE__ */new Set;return e.map((e,i)=>{let a=t(e,i)+"",l=Number(r(e,i));if(!a)throw Error(`${n} snapshot contains an empty id at index ${i}.`);if(o.has(a))throw Error(`${n} snapshot contains duplicate id "${a}".`);if(!Number.isFinite(l)||0>l)throw Error(`${n} snapshot value for "${a}" must be a finite non-negative number.`);return o.add(a),{id:a,value:l}})}function o(e,t,r){let o=r.afterId??r.beforeId,i=r.afterValue??r.beforeValue,a=null==r.epsilon||0>r.epsilon?1e-9:r.epsilon,l=n(e,r.beforeId,r.beforeValue,"Before"),s=n(t,o,i,"After"),c=new Map(l.map(e=>[e.id,e.value])),u=new Map(s.map(e=>[e.id,e.value])),d=l.reduce((e,t)=>e+t.value,0),h=s.reduce((e,t)=>e+t.value,0),f=a>=Math.abs(d-h);if(!f&&!r.allowImbalance)throw Error(`Snapshot totals must match (before ${d}, after ${h}). Pass allowImbalance to inspect residuals.`);let m=[],p=[...l.map(e=>e.id),...s.map(e=>e.id).filter(e=>!c.has(e))];for(let e of p){let t=Math.min(c.get(e)??0,u.get(e)??0);t>a&&m.push({sourceId:e,targetId:e,value:t,kind:"stay"})}let g=l.map(e=>({id:e.id,value:e.value-(u.get(e.id)??0)})).filter(e=>e.value>a),y=s.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>a),x=0,b=0;for(;g.length>x&&y.length>b;){let e=g[x],t=y[b],r=Math.min(e.value,t.value);r>a&&m.push({sourceId:e.id,targetId:t.id,value:r,kind:"move"}),e.value-=r,t.value-=r,a>=e.value&&(x+=1),a>=t.value&&(b+=1)}return{flows:m,beforeTotal:d,afterTotal:h,balanced:f,unmatchedBefore:g.slice(x).filter(e=>e.value>a).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:y.slice(b).filter(e=>e.value>a).map(({id:e,value:t})=>({id:e,value:t}))}}function i(e){return Number.isFinite(e)?Math.max(0,e):0}function a(e,t){let r=Number(t.unit),n=i(e),o=t.maxUnits??1/0,a=t.minFraction??0;if(0>=r||0>=o||0>=n)return{units:[],unit:r>0?r:0,total:n,shown:0,overflow:n>0&&!(o>0)};let l=Math.ceil(n/r-1e-6),s=Math.min(o,l),c=l>o,u=[];for(let e=0;s>e;e+=1){let t=e*r,o=Math.min(1,Math.max(0,(Math.min(n,t+r)-t)/r));1e-6>1-o&&(o=1),u.push({index:e,fraction:o,start:t,end:t+o*r,value:o*r})}let d=u[u.length-1];d&&a>d.fraction&&1>d.fraction&&u.pop();let h=u.reduce((e,t)=>e+t.value,0);return{units:u,unit:r,total:n,shown:h,overflow:c}}function l(e,t,r){let n=a(e,r),o=Math.max(i(t),n.total);if(n.total>=o)return{...n,rangeUnits:[],rangeTotal:n.total};let l=a(o,{unit:r.unit,maxUnits:r.maxUnits}),s=l.unit>0?n.total/l.unit:0,c=Math.floor(s+1e-6),u=Math.min(1,Math.max(0,s-c));1e-6>u&&(u=0);let d=[];for(let e of l.units)if(e.index>=c){if(e.index===c&&u>0){e.fraction-u>1e-6&&d.push({...e,startFraction:u,start:e.index*l.unit+u*l.unit,value:(e.fraction-u)*l.unit});continue}d.push({...e,startFraction:0})}return{...n,overflow:n.overflow||l.overflow,rangeUnits:d,rangeTotal:o}}function s(e,t,r={}){let n=r.iterations??260,o=r.repulsion??5200,i=r.linkDistance??165,a=r.linkStrength??.045,l=r.centerStrength??.018,s=r.damping??.84,c=r.nodeRadius??12,u=r.nodePadding??3,d=r.inset??.06,h=wa(r.seed??1),f=/* @__PURE__ */new Map;for(let t of e)f.set(t.id,0);for(let e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);let m=500,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=e=>"function"==typeof c?c(e.data):c,y=new Set(e.map(e=>e.id)),x=t.filter(e=>y.has(e.source)&&y.has(e.target)).map(e=>({source:e.source,target:e.target}));if(n>0){let e=cl(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/n)).velocityDecay(Math.max(0,Math.min(1,1-s))).force("charge",sl().strength(e=>{let t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",al(e=>g(e)+u).strength(.9).iterations(2)).force("center",il(m,m).strength(.8)).force("x",ul(m).strength(l)).force("y",dl(m).strength(l));x.length>0&&e.force("link",ll(x).id(e=>e.id).distance(i).strength(e=>{let t="string"==typeof e.target?e.target:e.target.id,r=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/r})),e.stop();for(let t=0;n>t;t+=1)e.tick()}let b=1/0,w=1/0,M=-1/0,v=-1/0;for(let e of p){let t=e.x??m,r=e.y??m;b>t&&(b=t),w>r&&(w=r),t>M&&(M=t),r>v&&(v=r)}let k=M-b,$=v-w,A={};for(let e of p)Object.defineProperty(A,e.id,{value:{x:0===k?.5:d+((e.x??m)-b)/k*(1-2*d),y:0===$?.5:d+((e.y??m)-w)/$*(1-2*d)},enumerable:!0,configurable:!0,writable:!0});return A}function c(e){return Array.isArray(e)}function u(e){return e?e.map(Number).filter(Number.isFinite):[]}function d(e){if("fixed-denominator"===e.countStrategy)return 1/0;let t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function h(e,t){let r=d(t);return e.length>r?{tokens:e.slice(0,r),overflow:!0}:{tokens:e,overflow:!1}}function f(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:u(e),data:e}:e}function m(e){let t=e.unitValue??e.unit,r=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=r&&{icon:r}}}function p(e){if(e.samples)return u(e.samples);if(!e.data||!e.valueAccessor)return[];let t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function g(e,t){let r=e.length;if(0===r)return 0;if(1===r)return e[0];let n=(r-1)*Math.min(1,Math.max(0,t)),o=Math.floor(n),i=n-o;return e[o]*(1-i)+e[Math.ceil(n)]*i}function y(e,t=1){let r=Array.from({length:e},(e,t)=>t),n=wa(Math.floor(t)||1);for(let e=r.length-1;e>0;e-=1){let t=Math.floor(n()*(e+1)),o=r[e];r[e]=r[t],r[t]=o}return r}function x(e,t,r,n={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:r,start:t,end:t+r,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...n}}function b(e,t){let r,n,o,i,s,c,u,b=m(t),w=f(e),v=0,k=!1;if("unitized"===b.countStrategy){s=b.unitValue??1;let e={unit:s,maxUnits:b.maxTokens,minFraction:b.minFraction},t=null==w.rangeValue?a(ca(w.value),e):l(ca(w.value),ca(w.rangeValue),e);r=t.units.map(e=>x(b,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),n=t.total,v=t.shown,k=t.overflow,null!=w.rangeValue&&(c=t.rangeTotal,u=t.rangeUnits.map(e=>x(b,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"===b.countStrategy){i=Math.floor(ca(w.denominator??b.denominator)),o=ca(w.numerator??b.numerator??w.value);let e=Math.min(i,Math.max(0,Math.round(o)));r=Array.from({length:i},(t,r)=>x(b,r,1,{highlighted:e>r,start:r,end:r+1})),n=i,v=r.length,k=!1}else if("quantile"===b.countStrategy){let e=p(w).sort((e,t)=>e-t),t=Math.max(0,Math.floor(b.tokenCount??50)),o=e.length>0?Math.min(t,d(b)):0;r=Array.from({length:o},(t,r)=>{let n=(r+.5)/o,i=g(e,n);return x(b,r,i,{sample:i,quantile:n,start:i,end:i})}),n=e.length,v=r.length,k=e.length>0&&t>r.length}else if("sample"===b.countStrategy||"posterior-sample"===b.countStrategy||"random-sample"===b.countStrategy){let e=p(w),t=Math.min(e.length,Math.max(0,Math.floor(b.tokenCount??e.length))),o=Math.min(t,d(b));r=("random-sample"===b.countStrategy?y(e.length,b.seed).slice(0,o):Array.from({length:o},(t,r)=>Math.floor(r/Math.max(1,o-1)*(e.length-1)))).map((t,r)=>{let n=e[t];return x(b,r,n,{sample:n,start:n,end:n})}),n=e.length,v=r.length,k=t>r.length}else{let e=w.data;if(e&&null==w.value)r=e.map((e,t)=>x(b,t,1,{datum:e})),n=e.length;else{let e=a(ca(w.value),{unit:1,maxUnits:b.maxTokens,minFraction:b.minFraction});r=e.units.map(e=>x(b,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),n=e.total,v=e.shown,k=e.overflow}if(e&&null==w.value){let e=h(r,b);r=e.tokens,v=r.length,k=e.overflow}}return{tokens:r,encoding:b,total:n,shown:v,overflow:k,numerator:o,denominator:i,unitValue:s,rangeTotal:c,rangeTokens:u,diagnostics:M(b,{visibleTokens:r.length+(u?.length??0)})}}function w(e,t={}){let r=c(e)?e:e.tokens,n=r.length;if(0===n)return[];let o=t.flow??"row",i=t.cellWidth??16,a=t.cellHeight??i,l=t.gutter??2,s=t.anchor??[.5,.5],u=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?n/t.rows:Math.sqrt(n)))),d=Math.max(1,Math.floor(t.rows??Math.ceil(n/u))),h="row"===o?Math.max(d,Math.ceil(n/u)):d,f="column"===o?Math.max(u,Math.ceil(n/d)):u,m=t.x??0,p=t.y??0;return r.map((e,r)=>{let n,c;return"column"===o?(c=Math.floor(r/d),n=r%d):(n=Math.floor(r/u),c=r%u),"left"===t.columnDirection&&(c=f-1-c),"up"===t.rowDirection&&(n=h-1-n),{...e,row:n,column:c,x:m+c*(i+l)+s[0]*i,y:p+n*(a+l)+s[1]*a}})}function M(e,t={}){let r=[],n=e.tokenSemantics,o=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==o||ca(e.denominator)>100?80:100);return n||r.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),o||r.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)&&r.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&r.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"===n&&("icon"===e.tokenType||"glyph"===e.tokenType)&&r.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===n&&o&&"unitized"!==o&&r.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"===n&&o&&"fixed-denominator"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),("possible-outcome"===n||"posterior-sample"===n||"hypothetical-case"===n)&&o&&"quantile"!==o&&"sample"!==o&&"posterior-sample"!==o&&"random-sample"!==o&&r.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===n&&"unitized"===o&&null==e.unitValue&&null==e.unit&&r.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"===n&&"unitized"===o&&!e.unitMeaning&&r.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),r}function v(e){return"small"===e?25:"large"===e?100:50}function k(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 $(e){let t=k(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 A(e){let t=k(e.taskIntent),r=v(e.availableSpace);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){let e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:r,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:M(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){let 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:M(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){let 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:M(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){let 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:r,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:M(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 S(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function I(e,t,r){return"function"==typeof e?e(t)??r:e??r}function C(e,t){return"function"==typeof e?e(t):e}function N(e){return e.sample??e.value??e.index}function F(e,t,r){if(t.columns)return t.columns;if(t.width&&r>0){let e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(r+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function E(e,t){let r=t.positionToken;return r?e.map((t,n)=>{let o=r(t,n,e);return{...t,x:o.x,y:o.y,row:o.row??n,column:o.column??0}}):[]}function z(e,t){if(0===e.length)return[];let r=t.x??0,n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,a=Math.max(1,Math.floor(t.rows??1)),l=e.map(N),s=Math.min(...l),c=Math.max(...l)-s||1;return e.map((l,u)=>{let d=N(l),h=u%a,f=t.valueToX?t.valueToX(d,l):r+(d-s)/c*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,l):n+h*(o+i);return{...l,x:f,y:m,row:h,column:u}})}function R(e,t){if(0===e.length)return[];let r=t.x??0,n=t.y??0,o="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,a=t.cellWidth??o+i,l=t.cellHeight??o+i,s=e.map(N),c=Math.min(...s),u=Math.max(...s)-c||1,d=/* @__PURE__ */new Map;return e.map(o=>{let i=N(o),s=t.valueToX?t.valueToX(i,o):r+(i-c)/u*(t.width??Math.max(1,e.length-1)*a),h=Math.round((s-r)/Math.max(1,a)),f=d.get(h)??0;d.set(h,f+1);let m=t.valueToY?t.valueToY(i,o):n+f*l;return{...o,x:r+h*a,y:m,row:f,column:h}})}function L(e,t){if(!t.valueToX)return[];let r=t.y??0,n=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),o=t.anchor??[.5,.5];return e.map((e,i)=>{let a=Number.isFinite(e.start)?e.start:N(e),l=(a+(Number.isFinite(e.end)?e.end:a+e.value))/2,s=t.valueToY?t.valueToY(l,e):r+o[1]*n;return{...e,x:t.valueToX(l,e),y:s,row:0,column:i}})}function T(e,t){let r=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return E(r,t);let n=t.layout??e.encoding.layout??"grid";if("quantile-strip"===n)return z(r,t);if("dotplot"===n)return R(r,t);if("bar-segment"===n){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return L(r,t)}if("beeswarm"===n||"small-multiple"===n)throw Error(`tokenLayer layout "${n}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);let o="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??o??12,a=t.cellHeight??o??i,l="row"===n?Math.max(1,r.length):"column"===n||"stack"===n?1:"waffle"===n&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:F(r,t,i);return w(r,{...t,columns:l,cellWidth:i,cellHeight:a})}function P(e){if(e)return Ml[e]}function j(e){return e&&$l.has(e)?e:void 0}function O(e,t){return void 0!==t.datum?I(t.datum,e,null):e.datum??null}function W(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?I(t.rangeColor,e,"var(--semiotic-secondary, #9ca3af)"):I(t.color,e,vl):I(t.inactiveColor,e,kl),stroke:"none",...C(t.style,e)??{}}}function D(e,t){let r=C(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:O(e,t),accessibleDatum:C(t.accessibleDatum,e),accessibility:C(t.accessibility,e),pointId:r,_transitionKey:r}}function q(e,t){let r=I(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:I(t.radius,e,r/2),style:W(e,t),...D(e,t)}}function B(e,t){let r=I(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,r/2)**2,symbolType:I(t.symbolType,e,"circle"),path:C(t.symbolPath,e),rotation:C(t.rotation,e),style:W(e,t),...D(e,t)}}function V(e,t,r){let n=W(e,r),o=I(r.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:o,glyph:t,color:(n.fill??vl)+"",accent:I(r.accent,e,"var(--semiotic-bg, #ffffff)"),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:I(r.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?C(r.ghostColor,e)??kl:void 0,rotation:C(r.rotation,e),style:n,...D(e,r)}}function G(e,t,r){if("dot"===r.tokenType)return q(e,t);let n=C(t.glyph,e)??P(r.icon);if(n)return V(e,n,t);let o=j(r.icon);return B(e,o&&null==t.symbolType?{...t,symbolType:o}:t)}function H({input:e,encoding:t,options:r={}}){if(!S(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");let n=S(e)?{...e,encoding:m(e.encoding)}:b(e,t),o=T(n,r).filter(e=>!r.include||r.include(e));return{tokenSet:n,positionedTokens:o,nodes:o.map(e=>G(e,r,n.encoding))}}function Y(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function _(e,t){let r=Y(e,t);return"string"==typeof r&&r.length>0?r:void 0}function X(e){return zl.has(e)?e:void 0}function K(e,t){let r=Y(e,t),n=X("string"==typeof r?r:Y(r,"kind"));if(!n)return;if("string"==typeof r)return{kind:n};let o=Y(r,"coverage"),i="number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0,a=_(r,"fill");return{kind:n,...null==i?{}:{coverage:i},...a?{fill:a}:{}}}function U(e){return _(Nl,e)??Nl.land}function Q(e){return _(Fl,e)??Fl.land}function Z(e,t){if(El.has(t))return _(e,t)}function J(e,t){if("function"==typeof e)return e;let r=e??t;return e=>e[r]}function ee(e,t,r){return[111.32*(e-r.lon)*Math.cos((t+r.lat)/2*(Math.PI/180)),110.574*(t-r.lat)]}function te(e){let t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function re(e){return El.has(e)?e:"monument"}function ne(e,t){let r=te(t.gridSize),n=Math.max(1,t.gridRadiusKm??75),o=2*n/r,i=Math.floor(r/2),a=J(t.idAccessor,"id"),l=J(t.nameAccessor,"name"),s=J(t.longitudeAccessor,"lon"),c=J(t.latitudeAccessor,"lat"),u=J(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?J(t.candidatePriorityAccessor,"priority"):()=>0,h=/* @__PURE__ */new Map,f=null;for(let m of e){let e=Number(s(m)),p=Number(c(m));if(!Number.isFinite(e)||!Number.isFinite(p))continue;let g=(a(m)??`${e},${p}`)+"",y=(l(m)??g)+"",x=re(u(m)),[b,w]=ee(e,p,t.center);if(Math.abs(b)>n||Math.abs(w)>n)continue;let M=Math.min(r-1,Math.max(0,Math.floor((b+n)/o))),v=Math.min(r-1,Math.max(0,Math.floor((n-w)/o))),k=(M+.5)*o-n,$=n-(v+.5)*o,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);let S=`${v}:${M}`,I=h.get(S)??[];I.push(A),h.set(S,I)}let m=/* @__PURE__ */new Map;f&&m.set("city",1);let p=[];for(let e=0;r>e;e++)for(let t=0;r>t;t++){let r,a,l=`tile-${e}-${t}`,s=(t+.5)*o-n,c=n-(e+.5)*o;if(e===i&&t===i&&f){r=f;let 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));a=[f,...n]}else{let n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{let r=e.candidatePriority-t.candidatePriority;if(0!==r)return r;let n=m.get(e.kind)??0,i=m.get(t.kind)??0,a=o*o*.35;return e.cellDistanceSq+n*a-(t.cellDistanceSq+i*a)||e.name.localeCompare(t.name)}),r=n[0]??null,a=n}r&&m.set(r.kind,(m.get(r.kind)??0)+1),p.push({id:l,row:e,column:t,centerXKm:s,centerYKm:c,terrainIndex:Math.abs((17*e+31*t)%Cl.length),landmark:r,landmarks:a})}return p}function oe(e,t,r,n){return`M${e},${t-n/2}L${e+r/2},${t}L${e},${t+n/2}L${e-r/2},${t}Z`}function ie({tiles:e,tileWidth:t,tileHeight:r,sprites:n,resourceSize:o,citySize:i,showCityLabel:a}){let l=xa(),s=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */
|
|
2
2
|
return Sl("g",{"aria-hidden":"true",pointerEvents:"none",children:[s.map(e=>{let a=e.landmark,s="city"===a.kind?i:o,c=e.y+r/2,u=l.isActive&&!l.predicate(a)?.28:1;/* @__PURE__ */
|
|
3
3
|
return Sl("g",{opacity:u,children:[
|
|
4
4
|
/* @__PURE__ */Al("ellipse",{cx:e.x,cy:e.y+.15*r,rx:.28*s,ry:.1*s,fill:"#17251d",opacity:.32}),
|
|
@@ -12,10 +12,10 @@ return Sl("g",{transform:`translate(${e},${t})`,children:[
|
|
|
12
12
|
return Al("image",{href:t,x:r,y:n,width:o,height:o,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});let i=Tl[e];/* @__PURE__ */
|
|
13
13
|
return Al("svg",{x:r,y:n,width:o,height:o,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:Ll[e].flatMap((e,t)=>[...e].map((e,r)=>"."===e?null:/* @__PURE__ */Al("rect",{x:r,y:t,width:1,height:1,fill:i[e]},`${t}-${r}`)))})}function se(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function ce(e,t,r){return Math.max(t,Math.min(r,e))}function ue(e){let t=1/0,r=-1/0;for(let n of e)Number.isFinite(n)&&(t>n&&(t=n),n>r&&(r=n));return t===1/0?[0,0]:[t,r]}function de(e,t){let r=t[1]-t[0];return 0===r?.5:(e-t[0])/r}function he(e,t={}){let r=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===r.length)return[];let n=ce(Number.isFinite(t.occupancy)?Number(t.occupancy):.72,.2,1),o=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):1.8,i=se(t.columns)??Math.max(1,Math.ceil(Math.sqrt(r.length*o/n))),a=se(t.rows)??Math.max(1,Math.ceil(r.length/(i*n)));r.length>i*a&&(null!=t.columns&&null==t.rows?a=Math.ceil(r.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(r.length/a):a=Math.ceil(r.length/i));let l=ue(r.map(e=>e.x)),s=ue(r.map(e=>e.y)),c=r.map(e=>({...e,desiredColumn:de(e.x,l)*Math.max(0,i-1),desiredRow:de(e.y,s)*Math.max(0,a-1)})),u=(i-1)/2,d=(a-1)/2;c.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);let h=/* @__PURE__ */new Set;for(let e=0;a>e;e+=1)for(let t=0;i>t;t+=1)h.add(e*i+t);let f=[];for(let e of c){let t=-1,r=1/0;for(let n of h){let o=(n%i-e.desiredColumn)**2+(Math.floor(n/i)-e.desiredRow)**2;(r>o||o===r&&t>n)&&(t=n,r=o)}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 fe(e,t,r=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(let t of r)if(null!=e[t])return e[t]}function me(e,t){let r=e.properties&&"object"==typeof e.properties?e.properties:{},n=e.id??r.id??r.name??"area-"+t;return{...r,id:n+""}}function pe(e){return e.map(([e,t],r)=>`${0===r?"M":"L"}${e},${t}`).join("")+"Z"}function ge(e,t,r){return pe([[e-r,t-r],[e+r,t-r],[e+r,t+r],[e-r,t+r]])}function ye(e,t,r){let n=[];for(let o=0;6>o;o+=1){let i=-Math.PI/2+o*(Math.PI/3);n.push([e+Math.cos(i)*r,t+Math.sin(i)*r])}return pe(n)}function xe(e){return e.areas.map((t,r)=>{let n=me(t,r),o=e.scales.geoPath.centroid(t),i=Number.isFinite(o[0])&&Number.isFinite(o[1])?e.scales.invertedPoint(o[0],o[1]):null;return{datum:{...n,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:o[0],y:o[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function be(e){return e.points.map(t=>{let r=Number(fe(t,e.config.longitudeAccessor,["lon","longitude"])),n=Number(fe(t,e.config.latitudeAccessor,["lat","latitude"])),o=Number.isFinite(r)&&Number.isFinite(n)?e.scales.projectedPoint(r,n):null;return{datum:t,x:o?.[0]??NaN,y:o?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function we(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;let r=e.map(e=>({datum:e,x:Number(fe(e,t.columnAccessor)),y:Number(fe(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return r.length!==e.length?null:r.map(e=>({...e,row:e.y,column:e.x}))}function Me({marks:e,color:t,fontSize:r,fontFamily:n,fontWeight:o}){let i=xa();/* @__PURE__ */
|
|
14
14
|
return Pl("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{let a=!i.isActive||i.predicate(e.datum);/* @__PURE__ */
|
|
15
|
-
return Pl("text",{x:e.x,y:e.y,fill:t,fontFamily:n,fontSize:r,fontWeight:o,opacity:a?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function ve(e,t,r){return Math.max(t,Math.min(r,e))}function ke(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function $e(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function Ae(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function Se(e,t){let r=Ae(e);return(e.id??r.id??r.name??"feature-"+t)+""}function Ie(e,t){if(0===e.length)return null;let r=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(r[0][0])&&Number.isFinite(r[0][1])&&Number.isFinite(r[1][0])&&Number.isFinite(r[1][1])?r:null}function Ce(e,t,r,n){return[Math.ceil((e-r)/n-.5),Math.floor((t-r)/n-.5)]}function Ne(e){if(!e)return 0;let t=Vl.get(e);if(t)return t;let r=Gl;return Gl+=1,Vl.set(e,r),r}function Fe(e){return e.map((e,t)=>{if(Bl.has(e))return{feature:e,index:t,bounds:Bl.get(e)??null};try{let r=Ol(e);return Bl.set(e,r),{feature:e,index:t,bounds:r}}catch{return Bl.set(e,null),{feature:e,index:t,bounds:null}}})}function Ee(e,t,r){return t>r?e>=t||r>=e:e>=t&&r>=e}function ze(e,t){return!t||e[1]>=t[0][1]&&t[1][1]>=e[1]&&Ee(e[0],t[0][0],t[1][0])}function Re(e,t){for(let r of e){let{feature:e,index:n}=r;if(e.geometry&&ze(t,r.bounds))try{if(Wl(e,t))return{feature:e,index:n}}catch{}}return null}function Le(e,t,r,n={}){let o=e.filter((e,t)=>e.geometry&&(!n.featureFilter||n.featureFilter(e,t))),i=Ie(o,t.geoPath);if(!i)return{dots:[],cellSize:10,features:o};let a=Math.max(0,n.layoutPadding??0),l=[[ve(i[0][0],a,Math.max(a,r.width-a)),ve(i[0][1],a,Math.max(a,r.height-a))],[ve(i[1][0],a,Math.max(a,r.width-a)),ve(i[1][1],a,Math.max(a,r.height-a))]],s=Math.max(0,l[1][0]-l[0][0]),c=Math.max(0,l[1][1]-l[0][1]);if(0===s||0===c)return{dots:[],cellSize:10,features:o};let u=ke(n.columns),d=Math.max(2,u?s/u:ke(n.cellSize)??10),h=Math.max(100,Math.round(ke(n.maxSamples)??25e3)),f=Math.ceil(s/d)*Math.ceil(c/d);f>h&&(d*=Math.sqrt(f/h));let m=n.gridOrigin?.[0]??0,p=n.gridOrigin?.[1]??0,[g,y]=Ce(l[0][0],l[1][0],m,d),[x,b]=Ce(l[0][1],l[1][1],p,d),w=[],M=Fe(o);for(let e=x;b>=e;e+=1){let r=p+(e+.5)*d;for(let o=g;y>=o;o+=1){let i=t.invertedPoint(m+(o+.5)*d,r);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;let a=Re(M,i);if(!a)continue;let l={...Ae(a.feature),featureId:Se(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:o,longitude:i[0],latitude:i[1],dotIndex:w.length};n.dotFilter&&!n.dotFilter(l,w.length)||w.push(l)}}return{dots:w,cellSize:d,features:o}}function Te(e){return Math.round(1e4*e)/1e4}function Pe(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${Te(Number(e[0]))},${Te(Number(e[1]))}`:"null"}function je(e,t){let r=e[t];return"function"==typeof r?r.call(e):void 0}function Oe(e){return"number"==typeof e&&Number.isFinite(e)?Te(e)+"":null===e?"null":"unavailable"}function We(e){return Array.isArray(e)&&e.every(Number.isFinite)?e.map(e=>Te(Number(e))).join(","):"unavailable"}function De(e){let t=e.scales.projection;return[Oe(je(t,"scale")),Pe(je(t,"translate")),Pe(je(t,"center")),We(je(t,"rotate")),Oe(je(t,"clipAngle")),Oe(je(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,r])=>Pe(e.scales.projectedPoint(t,r)))].join("|")}function qe(e){let t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",Ne(t.featureFilter),Ne(t.dotFilter),De(e)].join("::")}function Be(e){let t=ql.get(e.areas);t||(t=/* @__PURE__ */new Map,ql.set(e.areas,t));let r=qe(e),n=t.get(r);if(n)return n;let o=Le(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){let e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(r,o),o}function Ve(e){return e.map(([e,t],r)=>`${0===r?"M":"L"}${e},${t}`).join("")+"Z"}function Ge(e,t,r){return Ve([[e-r,t-r],[e+r,t-r],[e+r,t+r],[e-r,t+r]])}function He(e,t,r){return Ve(Array.from({length:6},(n,o)=>{let i=-Math.PI/2+o*(Math.PI/3);return[e+Math.cos(i)*r,t+Math.sin(i)*r]}))}function Ye(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):ba(e.data,t.labelAccessor??"label",e.id)}function _e(e){return"string"==typeof e?e:e.id}function Xe(e){let 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"}]}function Ke(e,t){let r,n=t.lineAccessor;return r="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,Xe(r)}function Ue(e,t,r){let n=t.sourceColorAccessor,o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.color;return"string"==typeof o&&o?o:r(e.id)}function Qe(e,t,r,n){let o=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),a=new Map(e.map(e=>[e.id,[]]));for(let e of t)!o.has(e.source)||!o.has(e.target)||(i.set(e.target,(i.get(e.target)??0)+1),a.get(e.source)?.push(e));let l=e.filter(e=>0===(i.get(e.id)??0)),s=/* @__PURE__ */new Map,c=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(let e of l){let t={id:e.id,label:Ye(e,r)+"",color:Ue(e,r,n)},o=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){let e=i.shift();if(!o.has(e)){o.add(e),c.get(e)?.set(t.id,t);for(let r of a.get(e)??[]){let e=s.get(r);e||(e=/* @__PURE__ */new Map,s.set(r,e)),e.set(t.id,t),o.has(r.target)||i.push(r.target)}}}}let u=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(t.map(e=>[e,u(s.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(c.get(e.id)?.values()??[])]))}}function Ze(e,t,r,n){if(e.color)return e.color;let o=r.lineColors&&Object.prototype.hasOwnProperty.call(r.lineColors,e.id)?r.lineColors[e.id]:void 0;if("string"==typeof o&&o)return o;let i=r.lineColorAccessor,a="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof a?a:n(e.id)}function Je(e,t,r){let n=/* @__PURE__ */new Map;for(let o of e){let e=o.target>o.source?`${o.source}\0${o.target}`:`${o.target}\0${o.source}`,i=n.get(e);i||(i={key:e,source:o.source,target:o.target,lines:/* @__PURE__ */new Map},n.set(e,i));let a=o.data.lineOrder;Array.isArray(a)&&(i.authoredOrder=a.map(String));let l=r?.byEdge.get(o)??Ke(o,t);for(let e of l)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:o})}return[...n.values()].sort((e,t)=>e.key.localeCompare(t.key))}function et(e,t){let r=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(r.get(e)??1/0)-(r.get(t)??1/0)||e.localeCompare(t))}function tt(e,t){let r=new Map((e.authoredOrder??t.lineOrder??[]).map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(r.get(e.descriptor.id)??1/0)-(r.get(t.descriptor.id)??1/0)||e.descriptor.id.localeCompare(t.descriptor.id))}function rt(e,t,r,n){if("authored"!==t.mode)return null;let o=e.data[r.pointsAccessor??"points"];if(!Array.isArray(o))return null;let i=o.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:n?i.reverse():i}function nt(e,t){return Aa(r=>{for(let[t,n]of Object.entries(e.data))r(t,n);r("source",e.source),r("target",e.target),r("lineId",t.id),r("lineLabel",t.label??t.id)})}function ot(e,t){return t.right>e.left&&e.right>t.left&&t.bottom>e.top&&e.bottom>t.top}function it(e,t,r,n,o,i){if(!1===i.showLabels)return[];let a=i.labelFontSize??11,l=[],s=[],c=[...e].sort((e,t)=>(r.get(t.id)?.size??0)-(r.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(let e of c){let r=t.get(e.id);if(!r)continue;let c=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):ba(e.data,i.labelAccessor??"label",e.id)+"")||e.id,u=Math.max(2*a,c.length*a*.58),d=1.25*a,h=Math.max(i.interchangeRadius??7,n.get(e.id)??i.stationRadius??4)+5,f=[{x:r.x+h,y:r.y,anchor:"start",left:r.x+h},{x:r.x-h,y:r.y,anchor:"end",left:r.x-h-u},{x:r.x,y:r.y-h,anchor:"middle",left:r.x-u/2},{x:r.x,y:r.y+h,anchor:"middle",left:r.x-u/2}].map((e,t)=>{let r={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},n=l.filter(e=>ot(r,e)).length;return{candidate:e,box:r,score:1e4*n+10*(Math.max(0,-r.left)+Math.max(0,r.right-o.width)+Math.max(0,-r.top)+Math.max(0,r.bottom-o.height))+t}}).sort((e,t)=>e.score-t.score)[0];l.push(f.box),s.push({x:f.candidate.x,y:f.candidate.y,text:c,anchor:f.candidate.anchor,baseline:"middle",fontSize:a,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return s}function at(e,t,r){return(t.x-e.x)*(r.y-e.y)-(t.y-e.y)*(r.x-e.x)}function lt(e){let t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,r)=>0===t||e.x!==r[t-1].x||e.y!==r[t-1].y);if(2>=t.length)return t;let r=[];for(let e of t){for(;r.length>=2&&0>=at(r[r.length-2],r[r.length-1],e);)r.pop();r.push(e)}let n=[];for(let e=t.length-1;e>=0;e--){let r=t[e];for(;n.length>=2&&0>=at(n[n.length-2],n[n.length-1],r);)n.pop();n.push(r)}return r.pop(),n.pop(),r.concat(n)}function st(e,t){if(0===t||3>e.length)return e;let r=0>e.reduce((t,r,n)=>{let o=e[(n+1)%e.length];return t+r.x*o.y-o.x*r.y},0)?-1:1;return e.map((n,o)=>{let i=e[(o-1+e.length)%e.length],a=e[(o+1)%e.length],l=Math.hypot(n.x-i.x,n.y-i.y)||1,s=Math.hypot(a.x-n.x,a.y-n.y)||1,c=r>0?{x:(n.y-i.y)/l,y:-(n.x-i.x)/l}:{x:-(n.y-i.y)/l,y:(n.x-i.x)/l},u=r>0?{x:(a.y-n.y)/s,y:-(a.x-n.x)/s}:{x:-(a.y-n.y)/s,y:(a.x-n.x)/s},d={x:c.x+u.x,y:c.y+u.y},h=Math.hypot(d.x,d.y);if(1e-9>h)return{x:n.x+u.x*t,y:n.y+u.y*t};let f=d.x/h,m=d.y/h,p=t/Math.max(1e-6,f*u.x+m*u.y);return{x:n.x+f*p,y:n.y+m*p}})}function ct(e){return(1e-12>Math.abs(e)?0:e)+""}function ut(e,t){if(0===e.length)return"";if(3>e.length||0===t)return e.map((e,t)=>`${0===t?"M":"L"}${ct(e.x)},${ct(e.y)}`).join(" ")+" Z";let r=e.map((r,n)=>{let o=e[(n-1+e.length)%e.length],i=e[(n+1)%e.length],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=Math.hypot(i.x-r.x,i.y-r.y)||1,s=Math.min(t,a/2,l/2);return{point:r,incoming:{x:r.x+(o.x-r.x)/a*s,y:r.y+(o.y-r.y)/a*s},outgoing:{x:r.x+(i.x-r.x)/l*s,y:r.y+(i.y-r.y)/l*s}}}),n=r[0].outgoing,o=`M${ct(n.x)},${ct(n.y)}`;for(let e=1;r.length>e;e++){let t=r[e];o+=` L${ct(t.incoming.x)},${ct(t.incoming.y)}`,o+=` Q${ct(t.point.x)},${ct(t.point.y)} ${ct(t.outgoing.x)},${ct(t.outgoing.y)}`}let i=r[0];return o+=` L${ct(i.incoming.x)},${ct(i.incoming.y)}`,o+=` Q${ct(i.point.x)},${ct(i.point.y)} ${ct(i.outgoing.x)},${ct(i.outgoing.y)} Z`,o}function dt(e,t){let r=Array.from(e.entries()).sort(([e],[t])=>t>e?-1:e>t?1:0);/* @__PURE__ */
|
|
15
|
+
return Pl("text",{x:e.x,y:e.y,fill:t,fontFamily:n,fontSize:r,fontWeight:o,opacity:a?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function ve(e,t,r){return Math.max(t,Math.min(r,e))}function ke(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function $e(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function Ae(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function Se(e,t){let r=Ae(e);return(e.id??r.id??r.name??"feature-"+t)+""}function Ie(e,t){if(0===e.length)return null;let r=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(r[0][0])&&Number.isFinite(r[0][1])&&Number.isFinite(r[1][0])&&Number.isFinite(r[1][1])?r:null}function Ce(e,t,r,n){return[Math.ceil((e-r)/n-.5),Math.floor((t-r)/n-.5)]}function Ne(e){if(!e)return 0;let t=Vl.get(e);if(t)return t;let r=Gl;return Gl+=1,Vl.set(e,r),r}function Fe(e){return e.map((e,t)=>{if(Bl.has(e))return{feature:e,index:t,bounds:Bl.get(e)??null};try{let r=Ol(e);return Bl.set(e,r),{feature:e,index:t,bounds:r}}catch{return Bl.set(e,null),{feature:e,index:t,bounds:null}}})}function Ee(e,t,r){return t>r?e>=t||r>=e:e>=t&&r>=e}function ze(e,t){return!t||e[1]>=t[0][1]&&t[1][1]>=e[1]&&Ee(e[0],t[0][0],t[1][0])}function Re(e,t){for(let r of e){let{feature:e,index:n}=r;if(e.geometry&&ze(t,r.bounds))try{if(Wl(e,t))return{feature:e,index:n}}catch{}}return null}function Le(e,t,r,n={}){let o=e.filter((e,t)=>e.geometry&&(!n.featureFilter||n.featureFilter(e,t))),i=Ie(o,t.geoPath);if(!i)return{dots:[],cellSize:10,features:o};let a=Math.max(0,n.layoutPadding??0),l=[[ve(i[0][0],a,Math.max(a,r.width-a)),ve(i[0][1],a,Math.max(a,r.height-a))],[ve(i[1][0],a,Math.max(a,r.width-a)),ve(i[1][1],a,Math.max(a,r.height-a))]],s=Math.max(0,l[1][0]-l[0][0]),c=Math.max(0,l[1][1]-l[0][1]);if(0===s||0===c)return{dots:[],cellSize:10,features:o};let u=ke(n.columns),d=Math.max(2,u?s/u:ke(n.cellSize)??10),h=Math.max(100,Math.round(ke(n.maxSamples)??25e3)),f=Math.ceil(s/d)*Math.ceil(c/d);f>h&&(d*=Math.sqrt(f/h));let m=n.gridOrigin?.[0]??0,p=n.gridOrigin?.[1]??0,[g,y]=Ce(l[0][0],l[1][0],m,d),[x,b]=Ce(l[0][1],l[1][1],p,d),w=[],M=Fe(o);for(let e=x;b>=e;e+=1){let r=p+(e+.5)*d;for(let o=g;y>=o;o+=1){let i=t.invertedPoint(m+(o+.5)*d,r);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;let a=Re(M,i);if(!a)continue;let l={...Ae(a.feature),featureId:Se(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:o,longitude:i[0],latitude:i[1],dotIndex:w.length};n.dotFilter&&!n.dotFilter(l,w.length)||w.push(l)}}return{dots:w,cellSize:d,features:o}}function Te(e){return Math.round(1e4*e)/1e4}function Pe(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${Te(Number(e[0]))},${Te(Number(e[1]))}`:"null"}function je(e,t){let r=e[t];return"function"==typeof r?r.call(e):void 0}function Oe(e){return"number"==typeof e&&Number.isFinite(e)?Te(e)+"":null===e?"null":"unavailable"}function We(e){return Array.isArray(e)&&e.every(Number.isFinite)?e.map(e=>Te(Number(e))).join(","):"unavailable"}function De(e){let t=e.scales.projection;return[Oe(je(t,"scale")),Pe(je(t,"translate")),Pe(je(t,"center")),We(je(t,"rotate")),Oe(je(t,"clipAngle")),Oe(je(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,r])=>Pe(e.scales.projectedPoint(t,r)))].join("|")}function qe(e){let t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",Ne(t.featureFilter),Ne(t.dotFilter),De(e)].join("::")}function Be(e){let t=ql.get(e.areas);t||(t=/* @__PURE__ */new Map,ql.set(e.areas,t));let r=qe(e),n=t.get(r);if(n)return n;let o=Le(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){let e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(r,o),o}function Ve(e){return e.map(([e,t],r)=>`${0===r?"M":"L"}${e},${t}`).join("")+"Z"}function Ge(e,t,r){return Ve([[e-r,t-r],[e+r,t-r],[e+r,t+r],[e-r,t+r]])}function He(e,t,r){return Ve(Array.from({length:6},(n,o)=>{let i=-Math.PI/2+o*(Math.PI/3);return[e+Math.cos(i)*r,t+Math.sin(i)*r]}))}function Ye(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):_i(e.data,t.labelAccessor??"label",e.id)}function _e(e){return"string"==typeof e?e:e.id}function Xe(e){let 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"}]}function Ke(e,t){let r,n=t.lineAccessor;return r="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,Xe(r)}function Ue(e,t,r){let n=t.sourceColorAccessor,o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.color;return"string"==typeof o&&o?o:r(e.id)}function Qe(e,t,r,n){let o=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),a=new Map(e.map(e=>[e.id,[]]));for(let e of t)!o.has(e.source)||!o.has(e.target)||(i.set(e.target,(i.get(e.target)??0)+1),a.get(e.source)?.push(e));let l=e.filter(e=>0===(i.get(e.id)??0)),s=/* @__PURE__ */new Map,c=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(let e of l){let t={id:e.id,label:Ye(e,r)+"",color:Ue(e,r,n)},o=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){let e=i.shift();if(!o.has(e)){o.add(e),c.get(e)?.set(t.id,t);for(let r of a.get(e)??[]){let e=s.get(r);e||(e=/* @__PURE__ */new Map,s.set(r,e)),e.set(t.id,t),o.has(r.target)||i.push(r.target)}}}}let u=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(t.map(e=>[e,u(s.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(c.get(e.id)?.values()??[])]))}}function Ze(e,t,r,n){if(e.color)return e.color;let o=r.lineColors&&Object.prototype.hasOwnProperty.call(r.lineColors,e.id)?r.lineColors[e.id]:void 0;if("string"==typeof o&&o)return o;let i=r.lineColorAccessor,a="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof a?a:n(e.id)}function Je(e,t,r){let n=/* @__PURE__ */new Map;for(let o of e){let e=o.target>o.source?`${o.source}\0${o.target}`:`${o.target}\0${o.source}`,i=n.get(e);i||(i={key:e,source:o.source,target:o.target,lines:/* @__PURE__ */new Map},n.set(e,i));let a=o.data.lineOrder;Array.isArray(a)&&(i.authoredOrder=a.map(String));let l=r?.byEdge.get(o)??Ke(o,t);for(let e of l)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:o})}return[...n.values()].sort((e,t)=>e.key.localeCompare(t.key))}function et(e,t){let r=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(r.get(e)??1/0)-(r.get(t)??1/0)||e.localeCompare(t))}function tt(e,t){let r=new Map((e.authoredOrder??t.lineOrder??[]).map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(r.get(e.descriptor.id)??1/0)-(r.get(t.descriptor.id)??1/0)||e.descriptor.id.localeCompare(t.descriptor.id))}function rt(e,t,r,n){if("authored"!==t.mode)return null;let o=e.data[r.pointsAccessor??"points"];if(!Array.isArray(o))return null;let i=o.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:n?i.reverse():i}function nt(e,t){return Ji(r=>{for(let[t,n]of Object.entries(e.data))r(t,n);r("source",e.source),r("target",e.target),r("lineId",t.id),r("lineLabel",t.label??t.id)})}function ot(e,t){return t.right>e.left&&e.right>t.left&&t.bottom>e.top&&e.bottom>t.top}function it(e,t,r,n,o,i){if(!1===i.showLabels)return[];let a=i.labelFontSize??11,l=[],s=[],c=[...e].sort((e,t)=>(r.get(t.id)?.size??0)-(r.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(let e of c){let r=t.get(e.id);if(!r)continue;let c=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):_i(e.data,i.labelAccessor??"label",e.id)+"")||e.id,u=Math.max(2*a,c.length*a*.58),d=1.25*a,h=Math.max(i.interchangeRadius??7,n.get(e.id)??i.stationRadius??4)+5,f=[{x:r.x+h,y:r.y,anchor:"start",left:r.x+h},{x:r.x-h,y:r.y,anchor:"end",left:r.x-h-u},{x:r.x,y:r.y-h,anchor:"middle",left:r.x-u/2},{x:r.x,y:r.y+h,anchor:"middle",left:r.x-u/2}].map((e,t)=>{let r={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},n=l.filter(e=>ot(r,e)).length;return{candidate:e,box:r,score:1e4*n+10*(Math.max(0,-r.left)+Math.max(0,r.right-o.width)+Math.max(0,-r.top)+Math.max(0,r.bottom-o.height))+t}}).sort((e,t)=>e.score-t.score)[0];l.push(f.box),s.push({x:f.candidate.x,y:f.candidate.y,text:c,anchor:f.candidate.anchor,baseline:"middle",fontSize:a,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return s}function at(e,t,r){return(t.x-e.x)*(r.y-e.y)-(t.y-e.y)*(r.x-e.x)}function lt(e){let t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,r)=>0===t||e.x!==r[t-1].x||e.y!==r[t-1].y);if(2>=t.length)return t;let r=[];for(let e of t){for(;r.length>=2&&0>=at(r[r.length-2],r[r.length-1],e);)r.pop();r.push(e)}let n=[];for(let e=t.length-1;e>=0;e--){let r=t[e];for(;n.length>=2&&0>=at(n[n.length-2],n[n.length-1],r);)n.pop();n.push(r)}return r.pop(),n.pop(),r.concat(n)}function st(e,t){if(0===t||3>e.length)return e;let r=0>e.reduce((t,r,n)=>{let o=e[(n+1)%e.length];return t+r.x*o.y-o.x*r.y},0)?-1:1;return e.map((n,o)=>{let i=e[(o-1+e.length)%e.length],a=e[(o+1)%e.length],l=Math.hypot(n.x-i.x,n.y-i.y)||1,s=Math.hypot(a.x-n.x,a.y-n.y)||1,c=r>0?{x:(n.y-i.y)/l,y:-(n.x-i.x)/l}:{x:-(n.y-i.y)/l,y:(n.x-i.x)/l},u=r>0?{x:(a.y-n.y)/s,y:-(a.x-n.x)/s}:{x:-(a.y-n.y)/s,y:(a.x-n.x)/s},d={x:c.x+u.x,y:c.y+u.y},h=Math.hypot(d.x,d.y);if(1e-9>h)return{x:n.x+u.x*t,y:n.y+u.y*t};let f=d.x/h,m=d.y/h,p=t/Math.max(1e-6,f*u.x+m*u.y);return{x:n.x+f*p,y:n.y+m*p}})}function ct(e){return(1e-12>Math.abs(e)?0:e)+""}function ut(e,t){if(0===e.length)return"";if(3>e.length||0===t)return e.map((e,t)=>`${0===t?"M":"L"}${ct(e.x)},${ct(e.y)}`).join(" ")+" Z";let r=e.map((r,n)=>{let o=e[(n-1+e.length)%e.length],i=e[(n+1)%e.length],a=Math.hypot(o.x-r.x,o.y-r.y)||1,l=Math.hypot(i.x-r.x,i.y-r.y)||1,s=Math.min(t,a/2,l/2);return{point:r,incoming:{x:r.x+(o.x-r.x)/a*s,y:r.y+(o.y-r.y)/a*s},outgoing:{x:r.x+(i.x-r.x)/l*s,y:r.y+(i.y-r.y)/l*s}}}),n=r[0].outgoing,o=`M${ct(n.x)},${ct(n.y)}`;for(let e=1;r.length>e;e++){let t=r[e];o+=` L${ct(t.incoming.x)},${ct(t.incoming.y)}`,o+=` Q${ct(t.point.x)},${ct(t.point.y)} ${ct(t.outgoing.x)},${ct(t.outgoing.y)}`}let i=r[0];return o+=` L${ct(i.incoming.x)},${ct(i.incoming.y)}`,o+=` Q${ct(i.point.x)},${ct(i.point.y)} ${ct(i.outgoing.x)},${ct(i.outgoing.y)} Z`,o}function dt(e,t){let r=Array.from(e.entries()).sort(([e],[t])=>t>e?-1:e>t?1:0);/* @__PURE__ */
|
|
16
16
|
return Ul("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:r.map(([e,r])=>{let n=st(lt(r.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),o=ut(n,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),a=r.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),l=Math.min(...n.map(e=>e.x)),s=Math.min(...n.map(e=>e.y)),c=t.label?.(e);/* @__PURE__ */
|
|
17
17
|
return Ql("g",{"data-lineage-hull":e,opacity:a?t.dimOpacity:void 0,children:[
|
|
18
|
-
/* @__PURE__ */Ul("path",{className:"lineage-dag-hull",d:o,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}}),c?/* @__PURE__ */Ul("text",{className:"lineage-dag-hull-label",x:l+8,y:s+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:c}):null]},e)})})}function ht(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}function ft(e,t){return Number.isFinite(e)?
|
|
18
|
+
/* @__PURE__ */Ul("path",{className:"lineage-dag-hull",d:o,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}}),c?/* @__PURE__ */Ul("text",{className:"lineage-dag-hull-label",x:l+8,y:s+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:c}):null]},e)})})}function ht(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}function ft(e,t){return Number.isFinite(e)?sa(e,0,1):t}function mt(e,t){let{w:r,h:n,lod:o}=t,i="icon"===o?Math.min(r,n):Math.min(n-14,26),a=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",l="icon"===o?0:8+i+8,s=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:a,node:e.node}):pt(e.semantic,e.partition,i),c="full"===o,u="icon"!==o,d="full"===o&&t.showChips&&e.stores.length>0;/* @__PURE__ */
|
|
19
19
|
return Jl("g",{transform:`translate(${e.cx-r/2}, ${e.cy-n/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[
|
|
20
20
|
/* @__PURE__ */Zl("g",{transform:`translate(${"icon"===o?(r-i)/2:8}, ${(n-i)/2})`,children:s}),u&&
|
|
21
21
|
/* @__PURE__ */Zl("foreignObject",{x:l,y:c?n/2-12:n/2-9,width:Math.max(8,r-l-8),height:18,style:{pointerEvents:"none"},children:/* @__PURE__ */Zl("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===o?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),c&&/* @__PURE__ */Zl("text",{x:l,y:n/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,r)=>/* @__PURE__ */Zl("rect",{x:l+15*r,y:n-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:/* @__PURE__ */Zl("title",{children:e.storeName})},e.storeName+r))]},e.id)}function pt(e,t,r){let n=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";/* @__PURE__ */
|
|
@@ -33,7 +33,7 @@ return os("g",{children:[
|
|
|
33
33
|
/* @__PURE__ */ns("rect",{x:s,y:c,width:n,height:o,rx:3,...u}),
|
|
34
34
|
/* @__PURE__ */ns("line",{x1:s+e,y1:c,x2:s+e,y2:c+o,stroke:a,strokeWidth:l}),
|
|
35
35
|
/* @__PURE__ */ns("line",{x1:s+n-e,y1:c,x2:s+n-e,y2:c+o,stroke:a,strokeWidth:l})]})}default:/* @__PURE__ */
|
|
36
|
-
return ns("rect",{x:s,y:c,width:n,height:o,rx:4,...u})}}function wt(e,t){let r=[];for(let n of e){let e=n.directed?t.convergeColor:t.branchColor;if(r.push(
|
|
36
|
+
return ns("rect",{x:s,y:c,width:n,height:o,rx:4,...u})}}function wt(e,t){let r=[];for(let n of e){let e=n.directed?t.convergeColor:t.branchColor;if(r.push(ha({keyId:"band-"+n.motif,x:n.x-6,y:n.y-4,width:n.width+12,height:n.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&n.exemplar){let o=n.exemplar;r.push(
|
|
37
37
|
/* @__PURE__ */ss("g",{style:{pointerEvents:"none"},children:[o.edges.map((e,r)=>/* @__PURE__ */ls("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+r)),o.nodes.map(t=>/* @__PURE__ */ls("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+n.motif))}if(t.showBandLabels){let e=n.x+(t.showExemplars?48:4);r.push(
|
|
38
38
|
/* @__PURE__ */ls("text",{x:e,y:n.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:n.descriptor},"bl-"+n.motif)),r.push(
|
|
39
39
|
/* @__PURE__ */ls("text",{x:e,y:n.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${n.count} · ${n.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+n.motif))}}if(t.showLegend){let e=t.plot.x+t.plot.width-168,n=t.plot.y-2;r.push(
|
|
@@ -42,31 +42,31 @@ return ns("rect",{x:s,y:c,width:n,height:o,rx:4,...u})}}function wt(e,t){let r=[
|
|
|
42
42
|
/* @__PURE__ */ls("text",{x:e+10,y:n+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),
|
|
43
43
|
/* @__PURE__ */ls("path",{d:Mt(e,n+18,5),fill:t.branchColor}),
|
|
44
44
|
/* @__PURE__ */ls("text",{x:e+10,y:n+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}/* @__PURE__ */
|
|
45
|
-
return ls("g",{className:"net-ensemble-overlays",children:r})}function Mt(e,t,r){return`M${e},${t-r} L${e+r},${t} L${e},${t+r} L${e-r},${t} Z`}function vt(e,t,r={}){let n=r.fingerprintRounds??3,o=[],i=/* @__PURE__ */new Set;for(let t of e)null==t.id||i.has(t.id)||(i.add(t.id),o.push(t.id));let{outAdj:a,inAdj:l,undirected:s}=Nt(o,t),c=Ft(o,a,l,s,n).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Ct(e)})),u=/* @__PURE__ */new Map;for(let e of c){let 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:c,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:c.filter(e=>e.directed).length,branchingCount:c.filter(e=>!e.directed).length}}function kt(e){let t=2166136261;for(let r=0;e.length>r;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function $t(e){return"string"==typeof e?e:e?.id}function At(e,t,r,n,o){let i=new Set(e),a=/* @__PURE__ */new Map;for(let n of e){let e=0,o=0;for(let e of t.get(n)??[])i.has(e)&&(o+=1);for(let t of r.get(n)??[])i.has(t)&&(e+=1);a.set(n,`${e}:${o}`)}for(let n=0;o>n;n+=1){let n=/* @__PURE__ */new Map;for(let o of e){let e=[];for(let r of t.get(o)??[])i.has(r)&&e.push(a.get(r));let l=[];for(let e of r.get(o)??[])i.has(e)&&l.push(a.get(e));e.sort(),l.sort(),n.set(o,kt(`${a.get(o)}>${e.join(",")}<${l.join(",")}`))}a=n}let l=e.map(e=>a.get(e)).sort();return kt(`${e.length}#${n}#${l.join(";")}`)}function St(e,t){let r=new Set(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set,i=e=>{let a=n.get(e);if(void 0!==a)return a;if(o.has(e))return 0;o.add(e);let l=0;for(let n of t.get(e)??[])r.has(n)&&(l=Math.max(l,1+i(n)));return o.delete(e),n.set(e,l),l},a=0;for(let t of e)a=Math.max(a,i(t));let l=/* @__PURE__ */new Map;for(let t of e)l.set(t,a-n.get(t));return{layer:l,layerCount:a+1}}function It(e,t,r,n,o,i,a){function l(e){let t=0,r=0;for(let n of o.get(e)??[]){let e=m.get(n);p.has(n)&&e&&(t+=e.x,r+=1)}return r>0?t/r:i.x+h/2}let{layer:s,layerCount:c}=St(e.ids,n),u=Array.from({length:c},()=>[]);for(let t of e.ids)u[s.get(t)].push(t);let d=.14*Math.min(i.width,i.height),h=Math.max(1,i.width-2*d),f=Math.max(1,i.height-2*d),m=/* @__PURE__ */new Map,p=new Set(e.ids);for(let e=0;c>e;e+=1){let t=u[e];e>0&&(t=[...t].sort((e,t)=>l(e)-l(t)));let r=t.length,n=i.y+d+(1===c?.5:e/(c-1))*f;t.forEach((e,t)=>{m.set(e,{x:i.x+d+(1===r?.5:t/(r-1))*h,y:n})})}let g=u.reduce((e,t)=>Math.max(e,t.length),1),y=Ba(Math.min(a,h/(2.4*g),f/(2.4*c)),1.4,a),x=e.ids.map(e=>{let n=m.get(e);return{id:e,cx:n.x,cy:n.y,r:y,datum:t.get(e)??Wa({id:e}),category:r.get(e)??""}}),b=[];for(let t of e.ids){let e=m.get(t);for(let r of n.get(t)??[]){if(!p.has(r))continue;let t=m.get(r);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function Ct(e){let{nodeCount:t,edgeCount:r,sinkCount:n,sourceCount:o}=e;return 1===t?"isolate":2===t&&1===r?"pair":1===o&&1===n&&r===t-1?"chain of "+t:e.directed&&1===o&&r>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+n}function Nt(e,t){let r=new Set(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let t of e)n.set(t,/* @__PURE__ */new Set),o.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(let e of t){let t=e.source,a=e.target;!r.has(t)||!r.has(a)||t===a||n.get(t).has(a)||(n.get(t).add(a),o.get(a).add(t),i.get(t).add(a),i.get(a).add(t))}return{outAdj:n,inAdj:o,undirected:i}}function Ft(e,t,r,n,o){let i=/* @__PURE__ */new Set,a=[];for(let l of e){if(i.has(l))continue;let e=[l];i.add(l);let s=[];for(;e.length;){let t=e.pop();s.push(t);for(let r of n.get(t)??[])i.has(r)||(i.add(r),e.push(r))}let c=new Set(s),u=0,d=0,h=0;for(let e of s){let n=0,o=0;for(let r of t.get(e)??[])c.has(r)&&(n+=1);for(let t of r.get(e)??[])c.has(t)&&(o+=1);h+=n,0===n&&(u+=1),0===o&&(d+=1)}a.push({ids:s,nodeCount:s.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:At(s,t,r,h,o)})}return a}function Et(e,t){let{plot:r}=t,n=Math.max(40,r.width),{cell:o,cols:i}=(()=>{for(let o=t.maxCellSize;o>=t.minCellSize;o-=2){let i=Math.max(1,Math.floor((n+t.cellGap)/(o+t.cellGap))),a=0;for(let[,r]of e)a+=t.headerHeight+Math.ceil(r.length/i)*(o+t.cellGap)+t.bandGap;if(r.height>=a)return{cell:o,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((n+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),a=[],l=[],s=r.y;for(let[c,u]of e){let e=Math.ceil(u.length/i),d=s,h=d+t.headerHeight,f=o>=t.minCellForFull;u.forEach((e,n)=>{let l=r.x+n%i*(o+t.cellGap),s=h+Math.floor(n/i)*(o+t.cellGap);if(f){let r=It(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:l,y:s,width:o,height:o},t.nodeRadius);a.push({component:e,lod:"full",cx:l+o/2,cy:s+o/2,glyphR:0,nodes:r.nodes,edges:r.edges})}else a.push({component:e,lod:"glyph",cx:l+o/2,cy:s+o/2,glyphR:Math.max(2.5,.36*o),nodes:[],edges:[]})});let m=zt(u[0],t,{x:r.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});l.push({motif:c,descriptor:Ct(u[0]),count:u.length,directed:u[0].directed,x:r.x,y:d,width:n,height:t.headerHeight+e*(o+t.cellGap),exemplar:m}),s=h+e*(o+t.cellGap)+t.bandGap}return{cells:a,bands:l}}function zt(e,t,r){return e?It(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,r,3):null}function Rt(e){return Ma(e)??e}function Lt(e){return"string"==typeof e?e:e.id}function Tt(e,t){let r=Number(e);return Number.isFinite(r)&&r>0?r:t}function Pt(e){return Math.round(100*e)/100+""}function jt(e,t){if(2>e.length)return"";let r=`M${Pt(e[0][0])},${Pt(e[0][1])}`;for(let n=1;e.length-1>n;n+=1){let o=e[n-1],i=e[n],a=e[n+1],l=Math.hypot(i[0]-o[0],i[1]-o[1]),s=Math.hypot(a[0]-i[0],a[1]-i[1]),c=Math.min(t,l/2,s/2);if(0>=c){r+=`L${Pt(i[0])},${Pt(i[1])}`;continue}let u=[(i[0]-o[0])/l,(i[1]-o[1])/l],d=[(a[0]-i[0])/s,(a[1]-i[1])/s],h=[i[0]-u[0]*c,i[1]-u[1]*c],f=[i[0]+d[0]*c,i[1]+d[1]*c];r+=`L${Pt(h[0])},${Pt(h[1])}Q${Pt(i[0])},${Pt(i[1])} ${Pt(f[0])},${Pt(f[1])}`}let n=e[e.length-1];return`${r}L${Pt(n[0])},${Pt(n[1])}`}function Ot(e,t,r,n,o=.92*n){let i=Math.cos(r),a=Math.sin(r),l=-a,s=[e+i*n*.56,t+a*n*.56],c=e-i*n*.44,u=t-a*n*.44,d=[c+l*o*.5,u+i*o*.5],h=[c-l*o*.5,u-i*o*.5];return`M${Pt(s[0])},${Pt(s[1])}L${Pt(d[0])},${Pt(d[1])}L${Pt(h[0])},${Pt(h[1])}Z`}function Wt(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}function Dt(e,t){return`${t}\0${e}`}function qt(e,t,r){let n=/* @__PURE__ */new Map;for(let o of e){let e=Lt(o.source),i=Lt(o.target),a=t.get(e),l=t.get(i);if(null==a||null==l)continue;let s=Rt(o),c=Tt("function"==typeof r.valueAccessor?r.valueAccessor(s):ba(s,r.valueAccessor??"value",o.value??1),0);if(0>=c)continue;let u=n.get(e);u||(u=/* @__PURE__ */new Map,n.set(e,u));let d=u.get(i);d?(d.value+=c,d.edgeCount+=1,d.memberEdges.push(s)):u.set(i,{key:`${a}-${l}`,source:e,target:i,sourceIndex:a,targetIndex:l,value:c,edgeCount:1,memberEdges:[s],datum:s,width:1,color:""})}let o=[...n.values()].flatMap(e=>[...e.values()]);for(let e of o)e.datum=Aa(t=>{for(let[r,n]of Object.entries(e.memberEdges[0]??{}))t(r,n);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 o}function Bt(e,t,r){let n=/* @__PURE__ */new Map,o=(e,t)=>{let r=n.get(e);r?r.push(t):n.set(e,[t])};for(let t of e)o(Dt(t.source,t.sourceIndex>t.targetIndex?"out-left":"out-right"),t),o(Dt(t.target,t.targetIndex>t.sourceIndex?"in-top":"in-bottom"),t);for(let[e,t]of n){let r=e.startsWith("out-");t.sort((e,t)=>(r?e.targetIndex:e.sourceIndex)-(r?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}let i=Gt(t,r),a=null==r.flowScale?1/0:Math.max(0,r.flowScale);if(null==r.flowScale){for(let e of n.values()){let n=e.reduce((e,t)=>e+t.value,0),o=Ht(e.length,t,r);n>0&&(a=Math.min(a,Math.max(.1,i-o*Math.max(0,e.length-1))/n))}Number.isFinite(a)||(a=1)}let l=Math.max(0,r.minFlowWidth??1.25),s=Math.max(l,r.maxFlowWidth??1/0);for(let t of e)t.width=Math.min(s,Math.max(l,t.value*a));let c=1;for(let e of n.values()){let n=e.reduce((e,t)=>e+t.width,0),o=Ht(e.length,t,r);n>0&&(c=Math.min(c,Math.max(.1,i-o*Math.max(0,e.length-1))/n))}if(1>c)for(let t of e)t.width*=c;return n}function Vt(e,t,r,n){let o=/* @__PURE__ */new Map;for(let[i,a]of e){let e=i.slice(i.indexOf("\0")+1),l=t.get(e);if(!l)continue;let s=i.startsWith("out-")?l.cy:l.cx,c=Ht(a.length,r,n),u=s-(a.reduce((e,t)=>e+t.width,0)+c*Math.max(0,a.length-1))/2;for(let e of a){let t=u+e.width/2,r=i.startsWith("out-");o.set(`${e.key}:${r?"source":"target"}`,t),u+=e.width+c}}return o}function Gt(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function Ht(e,t,r){if(1>=e)return 0;let n=Math.max(0,r.flowGap??.75),o=Gt(t,r);return Math.min(n,Math.max(0,(o-Math.min(.1,o))/(e-1)))}function Yt(e,t,r){let n="function"==typeof t?t(e):ba(e,t,r);return null==n||""===n?r:n+""}function _t(e,t){let r="function"==typeof t?t(e):ba(e,t,void 0);if(null!=r){if("object"==typeof r){let e=r.id;return null==e?void 0:e+""}return r+""}}function Xt(e,t){let r="function"==typeof t?t(e):ba(e,t,1);return Number(r)}function Kt(e,t){if(!t.has(e))return t.add(e),e;let r=2;for(;t.has(`${e}-${r}`);)r+=1;let n=`${e}-${r}`;return t.add(n),n}function Ut(e,t,r={}){let n=r.nodeIdAccessor??"id",o=r.groupAccessor??"group",i=r.labelAccessor??"label",a=r.sourceAccessor??"source",l=r.targetAccessor??"target",s=r.valueAccessor??"value",c=new Set(r.expandedGroups??[]),u=r.includeInternalFlows??!0,d=[],h=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map;for(let t of e){let e=Yt(t,n,d.length+"");if(h.has(e))continue;let r=Yt(t,i,e),a=Yt(t,o,e),l={id:e,label:r,group:a,datum:t};d.push(l),h.set(e,l);let s=f.get(a);s?s.push(l):f.set(a,[l])}let m=new Set(d.map(e=>e.id)),p=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(let[e,t]of f){if(!c.has(e)&&(!0===r.collapseSingletons||t.length>1)){let n=Kt(`${r.groupIdPrefix??"group:"}${e}`,m),o={id:n,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};p.push(o),g.set(n,o);for(let e of t)y.set(e.id,n);x.push({group:e,nodeId:n,label:e,collapsed:!0,memberIds:[...o.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(let r of t){let t={...r.datum,id:r.id,label:r.label,group:e,aggregate:!1,memberIds:[r.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};p.push(t),g.set(t.id,t),y.set(r.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})}let b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map,M=0;for(let e of t){let t=_t(e,a),r=_t(e,l),n=Xt(e,s),o=null==t?void 0:y.get(t),i=null==r?void 0:y.get(r);if(!(o&&i&&Number.isFinite(n)&&n>0)){M+=1;continue}let c=h.get(t)?.group,u=h.get(r)?.group;if(c&&u&&c===u){let e=b.get(c);e&&(e.internalValue+=n)}else{if(c){let e=b.get(c);e&&(e.outgoingValue+=n)}if(u){let e=b.get(u);e&&(e.incomingValue+=n)}}let d=w.get(o);d||(d=/* @__PURE__ */new Map,w.set(o,d));let f=d.get(i);f?(f.value+=n,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:o,target:i,value:n,edgeCount:1,internal:o===i,memberEdges:[e]})}let v=[...w.values()].flatMap(e=>[...e.values()]);for(let e of v){let t=g.get(e.source),r=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),r&&(r.incomingValue+=e.value))}return{nodes:p,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function Qt(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();let t=e+"",r=Number(t);if(!Number.isNaN(r)&&""!==t.trim())return r;let n=Date.parse(t);return Number.isNaN(n)?NaN:n}function Zt(e,t,r){return t>e?t:e>r?r:e}function Jt(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function er(e,t){let r=/* @__PURE__ */new Map;for(let t of e){let e=r.get(t.col);e||(e=[],r.set(t.col,e)),e.push(t)}let n=t.columnOrder.filter(e=>r.has(e)),o=Math.max(1,t.innerW-t.columnGap*Math.max(0,n.length-1)),i=t.proportionExponent,a=n.map(e=>Math.pow(r.get(e).length,i)),l=a.reduce((e,t)=>e+t,0)||1,s=e=>"uniform"===t.cellSizing?o/n.length:a[e]/l*o,c=/* @__PURE__ */new Map,u=[],d=t.innerX;for(let e=0;n.length>e;e++)u.push({col:n[e],x:d,w:s(e)}),d+=s(e)+t.columnGap;let h=1,f=/* @__PURE__ */new Map,m=[],p=(e,t,r,n)=>{let o=f.get(e);o||(o={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,o)),o.minX>t-n&&(o.minX=t-n),t+n>o.maxX&&(o.maxX=t+n),o.minY>r-n&&(o.minY=r-n),r+n>o.maxY&&(o.maxY=r+n)},g=(e,r,n,o,i,a)=>{let l=e.map(e=>({id:e.id,r:e.packR})),s=tr(l,r,n,o,i,t.packPadding,t.iterations,h++),u=1/0,d=1/0,f=-1/0,m=-1/0;for(let e of l){let t=s.get(e.id);c.set(e.id,{px:t.px,py:t.py}),p(a,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>m&&(m=t.py+e.r)}return Number.isFinite(u)?{x:u-ys,y:d-ys,w:f-u+2*ys,h:m-d+2*ys}:null};if("banded"===t.rowMode){let o=/* @__PURE__ */new Map;for(let t of e)o.set(t.row,(o.get(t.row)??0)+1);let a=t.rowOrder.filter(e=>o.has(e)),l=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),s=a.map(e=>Math.pow(o.get(e),i)),d=s.reduce((e,t)=>e+t,0)||1,h=/* @__PURE__ */new Map,m=t.innerY+t.innerH;for(let e=0;a.length>e;e++){let r="uniform"===t.cellSizing?l/a.length:s[e]/d*l,n=m-r;h.set(a[e],{y:n,h:r}),m=n-t.rowGap}n.forEach((e,t)=>{let n=ka(r.get(e),e=>e.row);for(let e of a){let r=n.get(e),o=h.get(e);!r||!o||g(r,u[t].x,o.y,u[t].w,o.h,e)}});let p=[],y=/* @__PURE__ */new Map;for(let e of a){let t=h.get(e);y.set(e,t.y+t.h/2);let r=f.get(e);r&&Number.isFinite(r.minX)&&p.push({x:r.minX-ys,y:r.minY-ys,w:r.maxX-r.minX+2*ys,h:r.maxY-r.minY+2*ys})}return{positions:c,enclosures:p,colBands:u,rowLabelY:y}}let y=/* @__PURE__ */new Map;n.forEach((e,n)=>{let o=ka(r.get(e),e=>e.row),a=t.rowOrder.filter(e=>o.has(e)),l=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),s=a.map(e=>Math.pow(o.get(e).length,i)),c=s.reduce((e,t)=>e+t,0)||1,d=t.innerY+t.innerH;a.forEach((e,r)=>{let i="uniform"===t.cellSizing?l/a.length:s[r]/c*l,h=d-i,f=g(o.get(e),u[n].x,h,u[n].w,i,e);if(f){m.push(f);let 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})});let x=/* @__PURE__ */new Map;for(let[e,t]of y)x.set(e,t.sum/t.n);return{positions:c,enclosures:m,colBands:u,rowLabelY:x}}function tr(e,t,r,n,o,i,a,l){let s=t+n/2,c=r+o/2,u=/* @__PURE__ */new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:s,py:c}),u;let h=Jt(l),f=new Float64Array(d),m=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);let p=Math.max(1,Math.round(Math.sqrt(d*n/Math.max(1,o)))),g=new Float64Array(d),y=new Float64Array(d),x=n/p,b=o/Math.ceil(d/p);for(let e=0;d>e;e++){let n=e%p,o=Math.floor(e/p);g[e]=t+(n+.3+.4*h())*x,y[e]=r+(o+.3+.4*h())*b}let w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=/* @__PURE__ */new Map,k=Math.max(1,Math.ceil(n/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++){let n=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-r)/M)),o=v.get(n);o?o.push(e):v.set(n,[e])}for(let e=0;d>e;e++){let n=Math.floor((g[e]-t)/M),o=Math.floor((y[e]-r)/M);for(let t=-1;1>=t;t++)for(let r=-1;1>=r;r++){let i=v.get($(n+t,o+r));if(i)for(let t=0;i.length>t;t++){let r=i[t];if(e>=r)continue;let n=g[r]-g[e],o=y[r]-y[e],a=f[e]+f[r],l=n*n+o*o;if(a*a>l)if(l>1e-9){let t=Math.sqrt(l),i=(a-t)/2;n/=t,o/=t,g[e]-=n*i,y[e]-=o*i,g[r]+=n*i,y[r]+=o*i}else{let 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++){let i=f[e],a=t+i,l=t+n-i,u=r+i,d=r+o-i;g[e]=l>a?Zt(g[e],a,l):s,y[e]=d>u?Zt(y[e],u,d):c}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}function rr(e){let t=2166136261,r=e=>{for(let r=0;e.length>r;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619)};for(let n of e)r(n.id),r(n.col),r(n.row),t^=Math.round(8*n.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function nr(e,t){let r=t.columnLabel??(e=>e),n=t.rowLabel??(e=>e);/* @__PURE__ */
|
|
46
|
-
return ms("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,r)=>Ka({keyId:"enc-"+r,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&&/* @__PURE__ */fs("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,r)=>/* @__PURE__ */fs("path",{d:La(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+r))}),t.markerDots.length>0&&/* @__PURE__ */fs("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,r)=>/* @__PURE__ */fs("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+r))}),t.showColumnHeaders&&e.colBands.map((e,n)=>Ja({keyId:"col-"+n,text:r(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,r])=>Ja({keyId:"row-"+e,text:n(e),x:t.labelX,y:r,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>rl(e))]})}function or(e,t,r){let n=e.map((e,n)=>Ja({keyId:"marimekko-label-"+n,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:r}));return xs.createElement(xs.Fragment,null,...n)}function ir(e,t,r){let n=/* @__PURE__ */new Set,o=[];for(let t of e)r(t)&&!n.has(t)&&(n.add(t),o.push(t));for(let e of t)n.has(e)||o.push(e);return o}function ar(e,t,r){return Math.PI*r/3*(e*e+e*t+t*t)}function lr(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function sr(e,t){return ar(lr(e,t),e.bottomRadius,t)}function cr(e,t){let r=(e.topRadius+e.bottomRadius)/2,n=Math.PI*r*r,o=t/n,i=t-sr(e,o),a=0;for(;100>a&&Math.abs(i)>1e-4;)o+=i/n,i=t-sr(e,o),a++;return o}function ur(e,t){let r=43758.5453*Math.sin(12.9898*e+78.233);return 2*(r-Math.floor(r)-.5)*t}function dr(e,t){if(t>e||2*t>e)return[{x:0,y:0}];let r=[],n=e=>{let o=Math.floor(2*Math.PI*e/(2*t));1>o&&(o=1);let i=0*e;Math.hypot(1*e-e*Math.cos(2*Math.PI/o),i-e*Math.sin(2*Math.PI/o))<2*t&&o>1&&o--;for(let t=0;o>t;t++)r.push({x:e*Math.cos(2*t*Math.PI/o),y:e*Math.sin(2*t*Math.PI/o)});let a=e-2*t;t>a?e>2*t&&r.push({x:0,y:0}):n(a)};return n(e-t),r}function hr(e,t,r){let n=[],o=r,i=0;for(;o>0&&60>i;){let r=t*(1+2*i),a=dr(lr(e,r),t),l=a.length-o,s=l>1?a.slice(Math.floor(l/2),Math.floor(l/2)+o):a,c=e.height-r;if(s.forEach((e,t)=>{n.push({x:e.x+ur(97*i+t,.15),z:c+ur(31*i+t,.05)})}),o-=s.length,i++,0===s.length)break}return{pearls:n,layers:i}}function fr(e,t,r){let n=r,o=0;for(;n>0&&60>o;){let r=lr(e,t+$s/2*(1+2*o));n-=Math.max(1,Math.floor(2*r/$s)),o++}return o}function mr(e,t,r,n){if(0>=n)return[];let o=fr(e,t,n),i=Math.max(t,r-o*$s)+$s/2,a=[],l=0;for(let t=0;o>t&&n>l;t++){let r=i+$s*t,o=lr(e,r),s=Math.max(1,Math.floor(2*o/$s)),c=(2*o-s*$s)/(s+1),u=-o+c,d=e.height-r-$s/2-.1;for(let e=0;s>e&&n>l;e++)a.push({cx:u+(c+$s)*e+$s/2,cy:d+$s/2,rotation:ur(53*t+e,10)}),l++}return a}function pr(e,t){let r=Number(e);return Number.isFinite(r)?r:t}function gr(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function yr(e,t={}){let r=t.fuels??Cs,n=!0===t.includeZero,o=[];for(let t of e)if(t&&"number"==typeof t.t)for(let e of r){let r=gr(t.fuels?.[e]);!n&&0>=r||o.push({t:t.t,fuel:e,fuelLabel:Ns[e],mw:r,ba:t.ba})}return o}function xr(e){let t=[];for(let r of e){if(!r||"number"!=typeof r.t)continue;let e=gr(r.demandMw),n=r.forecastMw;"number"!=typeof n||!Number.isFinite(n)||t.push({t:r.t,a:e,b:n,demandMw:e,forecastMw:n,errorMw:e-n,ba:r.ba})}return t}function br(e){let t=gr(e.demand);if(0>=t)return 0;let r=gr(e.capacityOrNetGen),n=gr(e.interchange);return(r+(0>n?-n:0)-t)/t*100}function wr(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{let t=gr(e.demandMw),r=gr(e.netGenMw),n=br({demand:t,capacityOrNetGen:r,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:n,netLoadMw:t,demandMw:t,netGenMw:r}})}function Mr(e={},t={}){let{watch:r,comfortable:n}={...Fs,...e},o=t.field,i=o?{field:o}:{},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 (≥ ${n}%)`,when:{...i,gte:n},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${n}%, ≥ ${r}%)`,when:{...i,lt:n,gte:r},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${r}%)`,when:{...i,lt:r},style:{fill:a,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function vr(e={}){let{tight:t,watch:r,comfortable:n}={...Fs,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:r,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:r,y1:Math.max(n+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function kr(e,t){if(!e.length)return null;let r=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!r.length)return null;let n=r[r.length-1];if("number"==typeof t&&Number.isFinite(t)){let e=r.filter(e=>t>=e.t);n=e.length?e[e.length-1]:r[0]}let o=gr(n.demandMw),i=gr(n.netGenMw),a="number"==typeof n.forecastMw&&Number.isFinite(n.forecastMw)?n.forecastMw:null,l=br({demand:o,capacityOrNetGen:i,interchange:n.interchangeMw}),s={},c=null,u=0,d=0;for(let e of Cs){let t=gr(n.fuels?.[e]);0>=t||(d+=t,s[e]=t,t>u&&(u=t,c=e))}if(d>0)for(let e of Object.keys(s))s[e]=s[e]/d;return{t:n.t,ba:n.ba,demandMw:o,forecastMw:a,forecastErrorMw:null==a?null:o-a,netGenMw:i,reserveMarginPct:l,topFuel:c,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:s}}function $r(e,t={}){let r=t.now??Date.now(),n=t.author??"system",o=t.source??"authored-scenario";return e.map(e=>{let 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:n,authorKind:"system",source:o,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:r}})}function Ar(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 Sr(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function Ir(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function Cr(e,t){if("function"==typeof e)return e;let r=e??t;return e=>Number(e[r])}function Nr(e,t={}){let r=Cr(t.start,"start"),n=Cr(t.end,"end"),o=!1===t.sort?e.slice():e.slice().sort((e,t)=>r(e)-r(t)||n(t)-n(e)),i=new zs;return{packed:o.map(e=>({item:e,track:i.assign(r(e),n(e))})),trackCount:Math.max(1,i.count)}}function Fr(e,t){let r=Cr(t.start,"start"),n=Cr(t.end,"end"),[o,i]=t.domain,a=t.step??1,l="half-open"===t.bounds;if(o>i)return[];let s=(i-o)/a>Math.log2(e.length+1),c=[],u=[];if(s){for(let t of e){let e=r(t),o=n(t);o>=e&&(c.push(e),u.push(o))}c.sort((e,t)=>e-t),u.sort((e,t)=>e-t)}let d=0,h=0,f=[];for(let t=o;i>=t;t+=a){let o=0;if(s){for(;c.length>d&&t>=c[d];)d++;for(;u.length>h&&(l?t>=u[h]:t>u[h]);)h++;o=d-h}else for(let i of e){let e=r(i),a=n(i);t>=e&&(l?a>t:a>=t)&&o++}f.push({value:t,count:o})}return f}function Er(e){return"function"==typeof e?e:t=>t[e]}function zr(e,t,r){let n=r?.orientation??"vertical",o=r?.bend??0,i=r?.minAlong??18,a=(e,t)=>(e+t)/2;if("vertical"===n){if(i>Math.abs(t.y-e.y)){let r=e.x>t.x?-1:1,n=a(e.x,t.x)+r*(22+Math.abs(o));return`M${e.x},${e.y} Q${n},${a(e.y,t.y)} ${t.x},${t.y}`}let r=a(e.y,t.y)+o;return`M${e.x},${e.y} C${e.x},${r} ${t.x},${r} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){let r=e.y>t.y?-1:1,n=a(e.y,t.y)+r*(22+Math.abs(o));return`M${e.x},${e.y} Q${a(e.x,t.x)},${n} ${t.x},${t.y}`}let l=a(e.x,t.x)+o;return`M${e.x},${e.y} C${l},${e.y} ${l},${t.y} ${t.x},${t.y}`}function Rr(e,t,r){if("vertical"===(r?.orientation??"vertical")){let r=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${r} L${t.x},${r} L${t.x},${t.y}`}let n=(e.x+t.x)/2;return`M${e.x},${e.y} L${n},${e.y} L${n},${t.y} L${t.x},${t.y}`}function Lr(e,t,r){if("vertical"===(r?.orientation??"vertical")){let r=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(r?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(r?-t.height/2:t.height/2)}}}let n=t.cx>=e.cx;return{from:{x:e.cx+(n?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(n?-t.width/2:t.width/2),y:t.cy}}}function Tr(e,t){let r=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*r:(e-((t?.count??1)-1)/2)*r}function Pr(e,t){let r=1-t,n=r*r*r,o=3*r*r*t,i=3*r*t*t,a=t*t*t;return{x:n*e.p0.x+o*e.p1.x+i*e.p2.x+a*e.p3.x,y:n*e.p0.y+o*e.p1.y+i*e.p2.y+a*e.p3.y}}function jr(e,t){let r=1-t,n=3*r*r,o=6*r*t,i=3*t*t;return{x:n*(e.p1.x-e.p0.x)+o*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:n*(e.p1.y-e.p0.y)+o*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function Or(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 Wr(e,t){let r=t?.axis??"x",n=t?.padding??0,o=t?.strength??.5,i="x"===r?"y":"x",a="x"===r?"width":"height",l="x"===r?"height":"width",s=/* @__PURE__ */new Map;for(let t of e)s.set(t.id,0);for(let t=0;e.length>t;t++)for(let c=t+1;e.length>c;c++){let u=e[t],d=e[c];if(Math.abs(u[i]-d[i])>(u[l]+d[l])/2+n)continue;let h=d[r]-u[r]||(d.id>u.id?-.5:.5),f=(u[a]+d[a])/2+n-Math.abs(h);if(0>=f)continue;let m=f*o*Math.sign(h);s.set(u.id,(s.get(u.id)??0)-m),s.set(d.id,(s.get(d.id)??0)+m)}return s}function Dr(e){let t=2166136261;for(let r=0;e.length>r;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function qr(e,t){if("function"==typeof e)return e;let r=e??t;return e=>ba(e,r,void 0)}function Br(e,t,r,n){let o=n.fixedAxis??"y",i=e=>Number(qr(n.fixedAccessor,"fixed")(e)),a=e=>qr(n.idAccessor,"id")(e)+"",l=e=>qr(n.sourceAccessor,"source")(e)+"",s=e=>qr(n.targetAccessor,"target")(e)+"",c=n.size??(()=>Ls),u=n.iterations??180,d=n.attraction??.012,h=n.anchorStrength??.003,f=n.collisionStrength??.12,m=n.collisionPadding??15,p=n.edgePadding??42,g=n.fixedPadding??16,y=n.damping??.72,x=n.spread??1,[b,w]=n.fixedDomain,M=w-b||1,v=("y"===o?r.y:r.x)+g,k=("y"===o?r.y+r.height:r.x+r.width)-g,$=e=>v+(e-b)/M*(k-v),A=("y"===o?r.x:r.y)+p,S=("y"===o?r.x+r.width:r.y+r.height)-p,I=Math.max(1,S-A),C=e.map(e=>{let t=Ma(e)??e,r=a(e),{width:n,height:o}=c(t),l=i(e),s=A+Dr(r)*I;return{data:t,id:r,width:n,height:o,fixedValue:l,fixed:$(l),free:s,anchor:s}}),N=new Map(C.map(e=>[e.id,e])),F=e=>"y"===o?e.width:e.height;for(let e=0;u>e;e++){let e=/* @__PURE__ */new Map;for(let t of C)e.set(t.id,0);for(let r of t){let t=N.get(l(r)),n=N.get(s(r));if(!t||!n)continue;let o=(n.free-t.free)*d;e.set(t.id,(e.get(t.id)??0)+o),e.set(n.id,(e.get(n.id)??0)-o)}for(let t of C)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*h);let r=Wr(C.map(e=>({id:e.id,x:"y"===o?e.free:e.fixed,y:"y"===o?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===o?"x":"y",padding:m,strength:f});for(let t of C)e.set(t.id,(e.get(t.id)??0)+(r.get(t.id)??0));for(let t of C){t.free+=(e.get(t.id)??0)*y;let r=F(t)/2;t.free=Math.max(A+r,Math.min(S-r,t.free))}}if(1!==x){let e=(A+S)/2;for(let t of C){let r=F(t)/2;t.free=Math.max(A+r,Math.min(S-r,e+(t.free-e)*x))}}let E=C.map(e=>({data:e.data,id:e.id,x:"y"===o?e.free:e.fixed,y:"y"===o?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:E,byId:new Map(E.map(e=>[e.id,e]))}}function Vr(e){let t=Number(e.segmentDomain?.[0]),r=Number(e.segmentDomain?.[1]),n=Number.isFinite(t)?t:0,o=Number.isFinite(r)?r:n,i=n>o?-1:1,a=Math.abs(o-n),l=Number(e.currentSegment),s=Number.isFinite(l)?Ba((l-n)*i,0,a):0,c=(e,t)=>{let r=Number(e);return Number.isFinite(r)?Ba(r,0,1):t},u=c(e.oldestOpacity,.25),d=c(e.currentOpacity,1),h=c(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{let t=Number(e);if(!Number.isFinite(t))return h;let r=(t-n)*i;if(r>s)return h;if(0===s)return d;let o=Ba(r/s,0,1);return u+(d-u)*o}}}function Gr(e){let t=2166136261;for(let r=0;e.length>r;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function Hr(e){let t=0;for(let r of e)t+=Ws[r]??.6;return t}function Yr(e,t){return Math.max(8,Hr(e)*t*1.05+1)}function _r(e,t,r){for(let n of t)if((e.w+n.w)/2+r>Math.abs(e.x-n.x)&&(e.h+n.h)/2+r>Math.abs(e.y-n.y))return!0;return!1}function Xr(e){let t=[],r=e.segHi-e.segLo||1;for(let n=0;e.tickCount>n;n++)t.push(e.segLo+r*n/Math.max(1,e.tickCount-1));/* @__PURE__ */
|
|
45
|
+
return ls("g",{className:"net-ensemble-overlays",children:r})}function Mt(e,t,r){return`M${e},${t-r} L${e+r},${t} L${e},${t+r} L${e-r},${t} Z`}function vt(e,t,r={}){let n=r.fingerprintRounds??3,o=[],i=/* @__PURE__ */new Set;for(let t of e)null==t.id||i.has(t.id)||(i.add(t.id),o.push(t.id));let{outAdj:a,inAdj:l,undirected:s}=Nt(o,t),c=Ft(o,a,l,s,n).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Ct(e)})),u=/* @__PURE__ */new Map;for(let e of c){let 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:c,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:c.filter(e=>e.directed).length,branchingCount:c.filter(e=>!e.directed).length}}function kt(e){let t=2166136261;for(let r=0;e.length>r;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function $t(e){return"string"==typeof e?e:e?.id}function At(e,t,r,n,o){let i=new Set(e),a=/* @__PURE__ */new Map;for(let n of e){let e=0,o=0;for(let e of t.get(n)??[])i.has(e)&&(o+=1);for(let t of r.get(n)??[])i.has(t)&&(e+=1);a.set(n,`${e}:${o}`)}for(let n=0;o>n;n+=1){let n=/* @__PURE__ */new Map;for(let o of e){let e=[];for(let r of t.get(o)??[])i.has(r)&&e.push(a.get(r));let l=[];for(let e of r.get(o)??[])i.has(e)&&l.push(a.get(e));e.sort(),l.sort(),n.set(o,kt(`${a.get(o)}>${e.join(",")}<${l.join(",")}`))}a=n}let l=e.map(e=>a.get(e)).sort();return kt(`${e.length}#${n}#${l.join(";")}`)}function St(e,t){let r=new Set(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set,i=e=>{let a=n.get(e);if(void 0!==a)return a;if(o.has(e))return 0;o.add(e);let l=0;for(let n of t.get(e)??[])r.has(n)&&(l=Math.max(l,1+i(n)));return o.delete(e),n.set(e,l),l},a=0;for(let t of e)a=Math.max(a,i(t));let l=/* @__PURE__ */new Map;for(let t of e)l.set(t,a-n.get(t));return{layer:l,layerCount:a+1}}function It(e,t,r,n,o,i,a){function l(e){let t=0,r=0;for(let n of o.get(e)??[]){let e=m.get(n);p.has(n)&&e&&(t+=e.x,r+=1)}return r>0?t/r:i.x+h/2}let{layer:s,layerCount:c}=St(e.ids,n),u=Array.from({length:c},()=>[]);for(let t of e.ids)u[s.get(t)].push(t);let d=.14*Math.min(i.width,i.height),h=Math.max(1,i.width-2*d),f=Math.max(1,i.height-2*d),m=/* @__PURE__ */new Map,p=new Set(e.ids);for(let e=0;c>e;e+=1){let t=u[e];e>0&&(t=[...t].sort((e,t)=>l(e)-l(t)));let r=t.length,n=i.y+d+(1===c?.5:e/(c-1))*f;t.forEach((e,t)=>{m.set(e,{x:i.x+d+(1===r?.5:t/(r-1))*h,y:n})})}let g=u.reduce((e,t)=>Math.max(e,t.length),1),y=sa(Math.min(a,h/(2.4*g),f/(2.4*c)),1.4,a),x=e.ids.map(e=>{let n=m.get(e);return{id:e,cx:n.x,cy:n.y,r:y,datum:t.get(e)??aa({id:e}),category:r.get(e)??""}}),b=[];for(let t of e.ids){let e=m.get(t);for(let r of n.get(t)??[]){if(!p.has(r))continue;let t=m.get(r);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function Ct(e){let{nodeCount:t,edgeCount:r,sinkCount:n,sourceCount:o}=e;return 1===t?"isolate":2===t&&1===r?"pair":1===o&&1===n&&r===t-1?"chain of "+t:e.directed&&1===o&&r>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+n}function Nt(e,t){let r=new Set(e),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(let t of e)n.set(t,/* @__PURE__ */new Set),o.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(let e of t){let t=e.source,a=e.target;!r.has(t)||!r.has(a)||t===a||n.get(t).has(a)||(n.get(t).add(a),o.get(a).add(t),i.get(t).add(a),i.get(a).add(t))}return{outAdj:n,inAdj:o,undirected:i}}function Ft(e,t,r,n,o){let i=/* @__PURE__ */new Set,a=[];for(let l of e){if(i.has(l))continue;let e=[l];i.add(l);let s=[];for(;e.length;){let t=e.pop();s.push(t);for(let r of n.get(t)??[])i.has(r)||(i.add(r),e.push(r))}let c=new Set(s),u=0,d=0,h=0;for(let e of s){let n=0,o=0;for(let r of t.get(e)??[])c.has(r)&&(n+=1);for(let t of r.get(e)??[])c.has(t)&&(o+=1);h+=n,0===n&&(u+=1),0===o&&(d+=1)}a.push({ids:s,nodeCount:s.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:At(s,t,r,h,o)})}return a}function Et(e,t){let{plot:r}=t,n=Math.max(40,r.width),{cell:o,cols:i}=(()=>{for(let o=t.maxCellSize;o>=t.minCellSize;o-=2){let i=Math.max(1,Math.floor((n+t.cellGap)/(o+t.cellGap))),a=0;for(let[,r]of e)a+=t.headerHeight+Math.ceil(r.length/i)*(o+t.cellGap)+t.bandGap;if(r.height>=a)return{cell:o,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((n+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),a=[],l=[],s=r.y;for(let[c,u]of e){let e=Math.ceil(u.length/i),d=s,h=d+t.headerHeight,f=o>=t.minCellForFull;u.forEach((e,n)=>{let l=r.x+n%i*(o+t.cellGap),s=h+Math.floor(n/i)*(o+t.cellGap);if(f){let r=It(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:l,y:s,width:o,height:o},t.nodeRadius);a.push({component:e,lod:"full",cx:l+o/2,cy:s+o/2,glyphR:0,nodes:r.nodes,edges:r.edges})}else a.push({component:e,lod:"glyph",cx:l+o/2,cy:s+o/2,glyphR:Math.max(2.5,.36*o),nodes:[],edges:[]})});let m=zt(u[0],t,{x:r.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});l.push({motif:c,descriptor:Ct(u[0]),count:u.length,directed:u[0].directed,x:r.x,y:d,width:n,height:t.headerHeight+e*(o+t.cellGap),exemplar:m}),s=h+e*(o+t.cellGap)+t.bandGap}return{cells:a,bands:l}}function zt(e,t,r){return e?It(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,r,3):null}function Rt(e){return Ki(e)??e}function Lt(e){return"string"==typeof e?e:e.id}function Tt(e,t){let r=Number(e);return Number.isFinite(r)&&r>0?r:t}function Pt(e){return Math.round(100*e)/100+""}function jt(e,t){if(2>e.length)return"";let r=`M${Pt(e[0][0])},${Pt(e[0][1])}`;for(let n=1;e.length-1>n;n+=1){let o=e[n-1],i=e[n],a=e[n+1],l=Math.hypot(i[0]-o[0],i[1]-o[1]),s=Math.hypot(a[0]-i[0],a[1]-i[1]),c=Math.min(t,l/2,s/2);if(0>=c){r+=`L${Pt(i[0])},${Pt(i[1])}`;continue}let u=[(i[0]-o[0])/l,(i[1]-o[1])/l],d=[(a[0]-i[0])/s,(a[1]-i[1])/s],h=[i[0]-u[0]*c,i[1]-u[1]*c],f=[i[0]+d[0]*c,i[1]+d[1]*c];r+=`L${Pt(h[0])},${Pt(h[1])}Q${Pt(i[0])},${Pt(i[1])} ${Pt(f[0])},${Pt(f[1])}`}let n=e[e.length-1];return`${r}L${Pt(n[0])},${Pt(n[1])}`}function Ot(e,t,r,n,o=.92*n){let i=Math.cos(r),a=Math.sin(r),l=-a,s=[e+i*n*.56,t+a*n*.56],c=e-i*n*.44,u=t-a*n*.44,d=[c+l*o*.5,u+i*o*.5],h=[c-l*o*.5,u-i*o*.5];return`M${Pt(s[0])},${Pt(s[1])}L${Pt(d[0])},${Pt(d[1])}L${Pt(h[0])},${Pt(h[1])}Z`}function Wt(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}function Dt(e,t){return`${t}\0${e}`}function qt(e,t,r){let n=/* @__PURE__ */new Map;for(let o of e){let e=Lt(o.source),i=Lt(o.target),a=t.get(e),l=t.get(i);if(null==a||null==l)continue;let s=Rt(o),c=Tt("function"==typeof r.valueAccessor?r.valueAccessor(s):_i(s,r.valueAccessor??"value",o.value??1),0);if(0>=c)continue;let u=n.get(e);u||(u=/* @__PURE__ */new Map,n.set(e,u));let d=u.get(i);d?(d.value+=c,d.edgeCount+=1,d.memberEdges.push(s)):u.set(i,{key:`${a}-${l}`,source:e,target:i,sourceIndex:a,targetIndex:l,value:c,edgeCount:1,memberEdges:[s],datum:s,width:1,color:""})}let o=[...n.values()].flatMap(e=>[...e.values()]);for(let e of o)e.datum=Ji(t=>{for(let[r,n]of Object.entries(e.memberEdges[0]??{}))t(r,n);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 o}function Bt(e,t,r){let n=/* @__PURE__ */new Map,o=(e,t)=>{let r=n.get(e);r?r.push(t):n.set(e,[t])};for(let t of e)o(Dt(t.source,t.sourceIndex>t.targetIndex?"out-left":"out-right"),t),o(Dt(t.target,t.targetIndex>t.sourceIndex?"in-top":"in-bottom"),t);for(let[e,t]of n){let r=e.startsWith("out-");t.sort((e,t)=>(r?e.targetIndex:e.sourceIndex)-(r?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}let i=Gt(t,r),a=null==r.flowScale?1/0:Math.max(0,r.flowScale);if(null==r.flowScale){for(let e of n.values()){let n=e.reduce((e,t)=>e+t.value,0),o=Ht(e.length,t,r);n>0&&(a=Math.min(a,Math.max(.1,i-o*Math.max(0,e.length-1))/n))}Number.isFinite(a)||(a=1)}let l=Math.max(0,r.minFlowWidth??1.25),s=Math.max(l,r.maxFlowWidth??1/0);for(let t of e)t.width=Math.min(s,Math.max(l,t.value*a));let c=1;for(let e of n.values()){let n=e.reduce((e,t)=>e+t.width,0),o=Ht(e.length,t,r);n>0&&(c=Math.min(c,Math.max(.1,i-o*Math.max(0,e.length-1))/n))}if(1>c)for(let t of e)t.width*=c;return n}function Vt(e,t,r,n){let o=/* @__PURE__ */new Map;for(let[i,a]of e){let e=i.slice(i.indexOf("\0")+1),l=t.get(e);if(!l)continue;let s=i.startsWith("out-")?l.cy:l.cx,c=Ht(a.length,r,n),u=s-(a.reduce((e,t)=>e+t.width,0)+c*Math.max(0,a.length-1))/2;for(let e of a){let t=u+e.width/2,r=i.startsWith("out-");o.set(`${e.key}:${r?"source":"target"}`,t),u+=e.width+c}}return o}function Gt(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function Ht(e,t,r){if(1>=e)return 0;let n=Math.max(0,r.flowGap??.75),o=Gt(t,r);return Math.min(n,Math.max(0,(o-Math.min(.1,o))/(e-1)))}function Yt(e,t,r){let n="function"==typeof t?t(e):_i(e,t,r);return null==n||""===n?r:n+""}function _t(e,t){let r="function"==typeof t?t(e):_i(e,t,void 0);if(null!=r){if("object"==typeof r){let e=r.id;return null==e?void 0:e+""}return r+""}}function Xt(e,t){let r="function"==typeof t?t(e):_i(e,t,1);return Number(r)}function Kt(e,t){if(!t.has(e))return t.add(e),e;let r=2;for(;t.has(`${e}-${r}`);)r+=1;let n=`${e}-${r}`;return t.add(n),n}function Ut(e,t,r={}){let n=r.nodeIdAccessor??"id",o=r.groupAccessor??"group",i=r.labelAccessor??"label",a=r.sourceAccessor??"source",l=r.targetAccessor??"target",s=r.valueAccessor??"value",c=new Set(r.expandedGroups??[]),u=r.includeInternalFlows??!0,d=[],h=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map;for(let t of e){let e=Yt(t,n,d.length+"");if(h.has(e))continue;let r=Yt(t,i,e),a=Yt(t,o,e),l={id:e,label:r,group:a,datum:t};d.push(l),h.set(e,l);let s=f.get(a);s?s.push(l):f.set(a,[l])}let m=new Set(d.map(e=>e.id)),p=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(let[e,t]of f){if(!c.has(e)&&(!0===r.collapseSingletons||t.length>1)){let n=Kt(`${r.groupIdPrefix??"group:"}${e}`,m),o={id:n,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};p.push(o),g.set(n,o);for(let e of t)y.set(e.id,n);x.push({group:e,nodeId:n,label:e,collapsed:!0,memberIds:[...o.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(let r of t){let t={...r.datum,id:r.id,label:r.label,group:e,aggregate:!1,memberIds:[r.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};p.push(t),g.set(t.id,t),y.set(r.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})}let b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map,M=0;for(let e of t){let t=_t(e,a),r=_t(e,l),n=Xt(e,s),o=null==t?void 0:y.get(t),i=null==r?void 0:y.get(r);if(!(o&&i&&Number.isFinite(n)&&n>0)){M+=1;continue}let c=h.get(t)?.group,u=h.get(r)?.group;if(c&&u&&c===u){let e=b.get(c);e&&(e.internalValue+=n)}else{if(c){let e=b.get(c);e&&(e.outgoingValue+=n)}if(u){let e=b.get(u);e&&(e.incomingValue+=n)}}let d=w.get(o);d||(d=/* @__PURE__ */new Map,w.set(o,d));let f=d.get(i);f?(f.value+=n,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:o,target:i,value:n,edgeCount:1,internal:o===i,memberEdges:[e]})}let v=[...w.values()].flatMap(e=>[...e.values()]);for(let e of v){let t=g.get(e.source),r=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),r&&(r.incomingValue+=e.value))}return{nodes:p,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function Qt(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();let t=e+"",r=Number(t);if(!Number.isNaN(r)&&""!==t.trim())return r;let n=Date.parse(t);return Number.isNaN(n)?NaN:n}function Zt(e,t,r){return t>e?t:e>r?r:e}function Jt(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function er(e,t){let r=/* @__PURE__ */new Map;for(let t of e){let e=r.get(t.col);e||(e=[],r.set(t.col,e)),e.push(t)}let n=t.columnOrder.filter(e=>r.has(e)),o=Math.max(1,t.innerW-t.columnGap*Math.max(0,n.length-1)),i=t.proportionExponent,a=n.map(e=>Math.pow(r.get(e).length,i)),l=a.reduce((e,t)=>e+t,0)||1,s=e=>"uniform"===t.cellSizing?o/n.length:a[e]/l*o,c=/* @__PURE__ */new Map,u=[],d=t.innerX;for(let e=0;n.length>e;e++)u.push({col:n[e],x:d,w:s(e)}),d+=s(e)+t.columnGap;let h=1,f=/* @__PURE__ */new Map,m=[],p=(e,t,r,n)=>{let o=f.get(e);o||(o={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,o)),o.minX>t-n&&(o.minX=t-n),t+n>o.maxX&&(o.maxX=t+n),o.minY>r-n&&(o.minY=r-n),r+n>o.maxY&&(o.maxY=r+n)},g=(e,r,n,o,i,a)=>{let l=e.map(e=>({id:e.id,r:e.packR})),s=tr(l,r,n,o,i,t.packPadding,t.iterations,h++),u=1/0,d=1/0,f=-1/0,m=-1/0;for(let e of l){let t=s.get(e.id);c.set(e.id,{px:t.px,py:t.py}),p(a,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>m&&(m=t.py+e.r)}return Number.isFinite(u)?{x:u-ys,y:d-ys,w:f-u+2*ys,h:m-d+2*ys}:null};if("banded"===t.rowMode){let o=/* @__PURE__ */new Map;for(let t of e)o.set(t.row,(o.get(t.row)??0)+1);let a=t.rowOrder.filter(e=>o.has(e)),l=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),s=a.map(e=>Math.pow(o.get(e),i)),d=s.reduce((e,t)=>e+t,0)||1,h=/* @__PURE__ */new Map,m=t.innerY+t.innerH;for(let e=0;a.length>e;e++){let r="uniform"===t.cellSizing?l/a.length:s[e]/d*l,n=m-r;h.set(a[e],{y:n,h:r}),m=n-t.rowGap}n.forEach((e,t)=>{let n=Qi(r.get(e),e=>e.row);for(let e of a){let r=n.get(e),o=h.get(e);!r||!o||g(r,u[t].x,o.y,u[t].w,o.h,e)}});let p=[],y=/* @__PURE__ */new Map;for(let e of a){let t=h.get(e);y.set(e,t.y+t.h/2);let r=f.get(e);r&&Number.isFinite(r.minX)&&p.push({x:r.minX-ys,y:r.minY-ys,w:r.maxX-r.minX+2*ys,h:r.maxY-r.minY+2*ys})}return{positions:c,enclosures:p,colBands:u,rowLabelY:y}}let y=/* @__PURE__ */new Map;n.forEach((e,n)=>{let o=Qi(r.get(e),e=>e.row),a=t.rowOrder.filter(e=>o.has(e)),l=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),s=a.map(e=>Math.pow(o.get(e).length,i)),c=s.reduce((e,t)=>e+t,0)||1,d=t.innerY+t.innerH;a.forEach((e,r)=>{let i="uniform"===t.cellSizing?l/a.length:s[r]/c*l,h=d-i,f=g(o.get(e),u[n].x,h,u[n].w,i,e);if(f){m.push(f);let 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})});let x=/* @__PURE__ */new Map;for(let[e,t]of y)x.set(e,t.sum/t.n);return{positions:c,enclosures:m,colBands:u,rowLabelY:x}}function tr(e,t,r,n,o,i,a,l){let s=t+n/2,c=r+o/2,u=/* @__PURE__ */new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:s,py:c}),u;let h=Jt(l),f=new Float64Array(d),m=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);let p=Math.max(1,Math.round(Math.sqrt(d*n/Math.max(1,o)))),g=new Float64Array(d),y=new Float64Array(d),x=n/p,b=o/Math.ceil(d/p);for(let e=0;d>e;e++){let n=e%p,o=Math.floor(e/p);g[e]=t+(n+.3+.4*h())*x,y[e]=r+(o+.3+.4*h())*b}let w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=/* @__PURE__ */new Map,k=Math.max(1,Math.ceil(n/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++){let n=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-r)/M)),o=v.get(n);o?o.push(e):v.set(n,[e])}for(let e=0;d>e;e++){let n=Math.floor((g[e]-t)/M),o=Math.floor((y[e]-r)/M);for(let t=-1;1>=t;t++)for(let r=-1;1>=r;r++){let i=v.get($(n+t,o+r));if(i)for(let t=0;i.length>t;t++){let r=i[t];if(e>=r)continue;let n=g[r]-g[e],o=y[r]-y[e],a=f[e]+f[r],l=n*n+o*o;if(a*a>l)if(l>1e-9){let t=Math.sqrt(l),i=(a-t)/2;n/=t,o/=t,g[e]-=n*i,y[e]-=o*i,g[r]+=n*i,y[r]+=o*i}else{let 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++){let i=f[e],a=t+i,l=t+n-i,u=r+i,d=r+o-i;g[e]=l>a?Zt(g[e],a,l):s,y[e]=d>u?Zt(y[e],u,d):c}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}function rr(e){let t=2166136261,r=e=>{for(let r=0;e.length>r;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619)};for(let n of e)r(n.id),r(n.col),r(n.row),t^=Math.round(8*n.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function nr(e,t){let r=t.columnLabel??(e=>e),n=t.rowLabel??(e=>e);/* @__PURE__ */
|
|
46
|
+
return ms("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,r)=>ha({keyId:"enc-"+r,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&&/* @__PURE__ */fs("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,r)=>/* @__PURE__ */fs("path",{d:ka(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+r))}),t.markerDots.length>0&&/* @__PURE__ */fs("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,r)=>/* @__PURE__ */fs("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+r))}),t.showColumnHeaders&&e.colBands.map((e,n)=>pa({keyId:"col-"+n,text:r(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,r])=>pa({keyId:"row-"+e,text:n(e),x:t.labelX,y:r,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>Oi(e))]})}function or(e,t,r){let n=e.map((e,n)=>pa({keyId:"marimekko-label-"+n,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:r}));return xs.createElement(xs.Fragment,null,...n)}function ir(e,t,r){let n=/* @__PURE__ */new Set,o=[];for(let t of e)r(t)&&!n.has(t)&&(n.add(t),o.push(t));for(let e of t)n.has(e)||o.push(e);return o}function ar(e,t,r){return Math.PI*r/3*(e*e+e*t+t*t)}function lr(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function sr(e,t){return ar(lr(e,t),e.bottomRadius,t)}function cr(e,t){let r=(e.topRadius+e.bottomRadius)/2,n=Math.PI*r*r,o=t/n,i=t-sr(e,o),a=0;for(;100>a&&Math.abs(i)>1e-4;)o+=i/n,i=t-sr(e,o),a++;return o}function ur(e,t){let r=43758.5453*Math.sin(12.9898*e+78.233);return 2*(r-Math.floor(r)-.5)*t}function dr(e,t){if(t>e||2*t>e)return[{x:0,y:0}];let r=[],n=e=>{let o=Math.floor(2*Math.PI*e/(2*t));1>o&&(o=1);let i=0*e;Math.hypot(1*e-e*Math.cos(2*Math.PI/o),i-e*Math.sin(2*Math.PI/o))<2*t&&o>1&&o--;for(let t=0;o>t;t++)r.push({x:e*Math.cos(2*t*Math.PI/o),y:e*Math.sin(2*t*Math.PI/o)});let a=e-2*t;t>a?e>2*t&&r.push({x:0,y:0}):n(a)};return n(e-t),r}function hr(e,t,r){let n=[],o=r,i=0;for(;o>0&&60>i;){let r=t*(1+2*i),a=dr(lr(e,r),t),l=a.length-o,s=l>1?a.slice(Math.floor(l/2),Math.floor(l/2)+o):a,c=e.height-r;if(s.forEach((e,t)=>{n.push({x:e.x+ur(97*i+t,.15),z:c+ur(31*i+t,.05)})}),o-=s.length,i++,0===s.length)break}return{pearls:n,layers:i}}function fr(e,t,r){let n=r,o=0;for(;n>0&&60>o;){let r=lr(e,t+$s/2*(1+2*o));n-=Math.max(1,Math.floor(2*r/$s)),o++}return o}function mr(e,t,r,n){if(0>=n)return[];let o=fr(e,t,n),i=Math.max(t,r-o*$s)+$s/2,a=[],l=0;for(let t=0;o>t&&n>l;t++){let r=i+$s*t,o=lr(e,r),s=Math.max(1,Math.floor(2*o/$s)),c=(2*o-s*$s)/(s+1),u=-o+c,d=e.height-r-$s/2-.1;for(let e=0;s>e&&n>l;e++)a.push({cx:u+(c+$s)*e+$s/2,cy:d+$s/2,rotation:ur(53*t+e,10)}),l++}return a}function pr(e,t){let r=Number(e);return Number.isFinite(r)?r:t}function gr(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function yr(e,t={}){let r=t.fuels??Cs,n=!0===t.includeZero,o=[];for(let t of e)if(t&&"number"==typeof t.t)for(let e of r){let r=gr(t.fuels?.[e]);!n&&0>=r||o.push({t:t.t,fuel:e,fuelLabel:Ns[e],mw:r,ba:t.ba})}return o}function xr(e){let t=[];for(let r of e){if(!r||"number"!=typeof r.t)continue;let e=gr(r.demandMw),n=r.forecastMw;"number"!=typeof n||!Number.isFinite(n)||t.push({t:r.t,a:e,b:n,demandMw:e,forecastMw:n,errorMw:e-n,ba:r.ba})}return t}function br(e){let t=gr(e.demand);if(0>=t)return 0;let r=gr(e.capacityOrNetGen),n=gr(e.interchange);return(r+(0>n?-n:0)-t)/t*100}function wr(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{let t=gr(e.demandMw),r=gr(e.netGenMw),n=br({demand:t,capacityOrNetGen:r,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:n,netLoadMw:t,demandMw:t,netGenMw:r}})}function Mr(e={},t={}){let{watch:r,comfortable:n}={...Fs,...e},o=t.field,i=o?{field:o}:{},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 (≥ ${n}%)`,when:{...i,gte:n},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${n}%, ≥ ${r}%)`,when:{...i,lt:n,gte:r},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${r}%)`,when:{...i,lt:r},style:{fill:a,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function vr(e={}){let{tight:t,watch:r,comfortable:n}={...Fs,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:r,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:r,y1:Math.max(n+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function kr(e,t){if(!e.length)return null;let r=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!r.length)return null;let n=r[r.length-1];if("number"==typeof t&&Number.isFinite(t)){let e=r.filter(e=>t>=e.t);n=e.length?e[e.length-1]:r[0]}let o=gr(n.demandMw),i=gr(n.netGenMw),a="number"==typeof n.forecastMw&&Number.isFinite(n.forecastMw)?n.forecastMw:null,l=br({demand:o,capacityOrNetGen:i,interchange:n.interchangeMw}),s={},c=null,u=0,d=0;for(let e of Cs){let t=gr(n.fuels?.[e]);0>=t||(d+=t,s[e]=t,t>u&&(u=t,c=e))}if(d>0)for(let e of Object.keys(s))s[e]=s[e]/d;return{t:n.t,ba:n.ba,demandMw:o,forecastMw:a,forecastErrorMw:null==a?null:o-a,netGenMw:i,reserveMarginPct:l,topFuel:c,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:s}}function $r(e,t={}){let r=t.now??Date.now(),n=t.author??"system",o=t.source??"authored-scenario";return e.map(e=>{let 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:n,authorKind:"system",source:o,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:r}})}function Ar(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 Sr(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function Ir(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function Cr(e,t){if("function"==typeof e)return e;let r=e??t;return e=>Number(e[r])}function Nr(e,t={}){let r=Cr(t.start,"start"),n=Cr(t.end,"end"),o=!1===t.sort?e.slice():e.slice().sort((e,t)=>r(e)-r(t)||n(t)-n(e)),i=new zs;return{packed:o.map(e=>({item:e,track:i.assign(r(e),n(e))})),trackCount:Math.max(1,i.count)}}function Fr(e,t){let r=Cr(t.start,"start"),n=Cr(t.end,"end"),[o,i]=t.domain,a=t.step??1,l="half-open"===t.bounds;if(o>i)return[];let s=(i-o)/a>Math.log2(e.length+1),c=[],u=[];if(s){for(let t of e){let e=r(t),o=n(t);o>=e&&(c.push(e),u.push(o))}c.sort((e,t)=>e-t),u.sort((e,t)=>e-t)}let d=0,h=0,f=[];for(let t=o;i>=t;t+=a){let o=0;if(s){for(;c.length>d&&t>=c[d];)d++;for(;u.length>h&&(l?t>=u[h]:t>u[h]);)h++;o=d-h}else for(let i of e){let e=r(i),a=n(i);t>=e&&(l?a>t:a>=t)&&o++}f.push({value:t,count:o})}return f}function Er(e){return"function"==typeof e?e:t=>t[e]}function zr(e,t,r){let n=r?.orientation??"vertical",o=r?.bend??0,i=r?.minAlong??18,a=(e,t)=>(e+t)/2;if("vertical"===n){if(i>Math.abs(t.y-e.y)){let r=e.x>t.x?-1:1,n=a(e.x,t.x)+r*(22+Math.abs(o));return`M${e.x},${e.y} Q${n},${a(e.y,t.y)} ${t.x},${t.y}`}let r=a(e.y,t.y)+o;return`M${e.x},${e.y} C${e.x},${r} ${t.x},${r} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){let r=e.y>t.y?-1:1,n=a(e.y,t.y)+r*(22+Math.abs(o));return`M${e.x},${e.y} Q${a(e.x,t.x)},${n} ${t.x},${t.y}`}let l=a(e.x,t.x)+o;return`M${e.x},${e.y} C${l},${e.y} ${l},${t.y} ${t.x},${t.y}`}function Rr(e,t,r){if("vertical"===(r?.orientation??"vertical")){let r=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${r} L${t.x},${r} L${t.x},${t.y}`}let n=(e.x+t.x)/2;return`M${e.x},${e.y} L${n},${e.y} L${n},${t.y} L${t.x},${t.y}`}function Lr(e,t,r){if("vertical"===(r?.orientation??"vertical")){let r=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(r?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(r?-t.height/2:t.height/2)}}}let n=t.cx>=e.cx;return{from:{x:e.cx+(n?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(n?-t.width/2:t.width/2),y:t.cy}}}function Tr(e,t){let r=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*r:(e-((t?.count??1)-1)/2)*r}function Pr(e,t){let r=1-t,n=r*r*r,o=3*r*r*t,i=3*r*t*t,a=t*t*t;return{x:n*e.p0.x+o*e.p1.x+i*e.p2.x+a*e.p3.x,y:n*e.p0.y+o*e.p1.y+i*e.p2.y+a*e.p3.y}}function jr(e,t){let r=1-t,n=3*r*r,o=6*r*t,i=3*t*t;return{x:n*(e.p1.x-e.p0.x)+o*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:n*(e.p1.y-e.p0.y)+o*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function Or(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 Wr(e,t){let r=t?.axis??"x",n=t?.padding??0,o=t?.strength??.5,i="x"===r?"y":"x",a="x"===r?"width":"height",l="x"===r?"height":"width",s=/* @__PURE__ */new Map;for(let t of e)s.set(t.id,0);for(let t=0;e.length>t;t++)for(let c=t+1;e.length>c;c++){let u=e[t],d=e[c];if(Math.abs(u[i]-d[i])>(u[l]+d[l])/2+n)continue;let h=d[r]-u[r]||(d.id>u.id?-.5:.5),f=(u[a]+d[a])/2+n-Math.abs(h);if(0>=f)continue;let m=f*o*Math.sign(h);s.set(u.id,(s.get(u.id)??0)-m),s.set(d.id,(s.get(d.id)??0)+m)}return s}function Dr(e){let t=2166136261;for(let r=0;e.length>r;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function qr(e,t){if("function"==typeof e)return e;let r=e??t;return e=>_i(e,r,void 0)}function Br(e,t,r,n){let o=n.fixedAxis??"y",i=e=>Number(qr(n.fixedAccessor,"fixed")(e)),a=e=>qr(n.idAccessor,"id")(e)+"",l=e=>qr(n.sourceAccessor,"source")(e)+"",s=e=>qr(n.targetAccessor,"target")(e)+"",c=n.size??(()=>Ls),u=n.iterations??180,d=n.attraction??.012,h=n.anchorStrength??.003,f=n.collisionStrength??.12,m=n.collisionPadding??15,p=n.edgePadding??42,g=n.fixedPadding??16,y=n.damping??.72,x=n.spread??1,[b,w]=n.fixedDomain,M=w-b||1,v=("y"===o?r.y:r.x)+g,k=("y"===o?r.y+r.height:r.x+r.width)-g,$=e=>v+(e-b)/M*(k-v),A=("y"===o?r.x:r.y)+p,S=("y"===o?r.x+r.width:r.y+r.height)-p,I=Math.max(1,S-A),C=e.map(e=>{let t=Ki(e)??e,r=a(e),{width:n,height:o}=c(t),l=i(e),s=A+Dr(r)*I;return{data:t,id:r,width:n,height:o,fixedValue:l,fixed:$(l),free:s,anchor:s}}),N=new Map(C.map(e=>[e.id,e])),F=e=>"y"===o?e.width:e.height;for(let e=0;u>e;e++){let e=/* @__PURE__ */new Map;for(let t of C)e.set(t.id,0);for(let r of t){let t=N.get(l(r)),n=N.get(s(r));if(!t||!n)continue;let o=(n.free-t.free)*d;e.set(t.id,(e.get(t.id)??0)+o),e.set(n.id,(e.get(n.id)??0)-o)}for(let t of C)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*h);let r=Wr(C.map(e=>({id:e.id,x:"y"===o?e.free:e.fixed,y:"y"===o?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===o?"x":"y",padding:m,strength:f});for(let t of C)e.set(t.id,(e.get(t.id)??0)+(r.get(t.id)??0));for(let t of C){t.free+=(e.get(t.id)??0)*y;let r=F(t)/2;t.free=Math.max(A+r,Math.min(S-r,t.free))}}if(1!==x){let e=(A+S)/2;for(let t of C){let r=F(t)/2;t.free=Math.max(A+r,Math.min(S-r,e+(t.free-e)*x))}}let E=C.map(e=>({data:e.data,id:e.id,x:"y"===o?e.free:e.fixed,y:"y"===o?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:E,byId:new Map(E.map(e=>[e.id,e]))}}function Vr(e){let t=Number(e.segmentDomain?.[0]),r=Number(e.segmentDomain?.[1]),n=Number.isFinite(t)?t:0,o=Number.isFinite(r)?r:n,i=n>o?-1:1,a=Math.abs(o-n),l=Number(e.currentSegment),s=Number.isFinite(l)?sa((l-n)*i,0,a):0,c=(e,t)=>{let r=Number(e);return Number.isFinite(r)?sa(r,0,1):t},u=c(e.oldestOpacity,.25),d=c(e.currentOpacity,1),h=c(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{let t=Number(e);if(!Number.isFinite(t))return h;let r=(t-n)*i;if(r>s)return h;if(0===s)return d;let o=sa(r/s,0,1);return u+(d-u)*o}}}function Gr(e){let t=2166136261;for(let r=0;e.length>r;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0)/4294967295}function Hr(e){let t=0;for(let r of e)t+=Ws[r]??.6;return t}function Yr(e,t){return Math.max(8,Hr(e)*t*1.05+1)}function _r(e,t,r){for(let n of t)if((e.w+n.w)/2+r>Math.abs(e.x-n.x)&&(e.h+n.h)/2+r>Math.abs(e.y-n.y))return!0;return!1}function Xr(e){let t=[],r=e.segHi-e.segLo||1;for(let n=0;e.tickCount>n;n++)t.push(e.segLo+r*n/Math.max(1,e.tickCount-1));/* @__PURE__ */
|
|
47
47
|
return js("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[
|
|
48
48
|
/* @__PURE__ */Ps("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,r)=>{let n=e.segToY(t);/* @__PURE__ */
|
|
49
49
|
return js("g",{children:[
|
|
50
50
|
/* @__PURE__ */Ps("line",{x1:e.x-4,y1:n,x2:e.x,y2:n,stroke:e.color,strokeWidth:1,opacity:.6}),
|
|
51
|
-
/* @__PURE__ */Ps("text",{x:e.x-7,y:n,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+r)}),e.label&&/* @__PURE__ */Ps("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 Kr(e){return null==e?void 0:e+""}function Ur(e){let t=Kr(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??8,style:{...qs,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function Qr(e){return Ur(e)}function Zr(e){let[[t,r],[n,o]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((n-t)*(o-r)),style:{...qs,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function Jr(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...qs,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:Kr(e.id)}}function en(e){let t=Kr(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...qs,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??8,style:{...qs,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function tn(e){let t={style:{...qs,cursor:e.cursor},datum:e.datum,id:Kr(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 rn(e,t,r={}){let{coord:n,step:o=1,equals:i=Object.is,truthyOnly:a=!1}=r,l=[],s=t=>n?n(e[t],t):t,c=(e,t,r)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=n?null==r||s(r)-s(t)>o?s(t)+o:s(r):t+1,l.push(e)},u=null;for(let r=0;e.length>r;r++){let l=t(e[r],r);if(a&&!l){u&&(c(u,u.endIndex,r),u=null);continue}let d=!n||0>=r||s(r)-s(r-1)<=o;u&&d&&i(u.value,l)?u.endIndex=r:(u&&c(u,u.endIndex,r),u={value:l,start:s(r),end:s(r),count:1,startIndex:r,endIndex:r})}return u&&c(u,u.endIndex,null),l}function nn(e,t,r=0){return t>0?((e-r)%t+t)%t+r:e}function on(e,t,r){if(0>=r)return t-e;let n=(t-e)%r;return n>r/2?n-=r:-r/2>n&&(n+=r),n}function an(e,t,r){return t>r?e>=t||r>=e:e>=t&&r>=e}function ln(e,t,r,n){return r>n?[...e.filter(e=>t(e)>=r),...e.filter(e=>t(e)<=n)]:e.filter(e=>an(t(e),r,n))}function sn(e,t){let r=Math.max(0,t.width),n=t.y,o=Math.min(74,Math.max(34,.08*r)),i=t.paddingLeft??o,a=e.length>1?Math.max(0,r-i-(t.paddingRight??o))/(e.length-1):0,l=/* @__PURE__ */new Map;return e.forEach((e,t)=>{l.set(e.id,{id:e.id,x:i+a*t,y:n,index:t})}),l}function cn(e,t){let r=Math.max(0,t.width),n=t.y,o=Math.min(74,Math.max(34,.08*r)),i=t.paddingLeft??o,a=t.paddingRight??o,l=t.gap??8,s=!1!==t.distribute,c=t.estimateWidth??(e=>un(e.label??e.id)),u=e.map((e,t)=>Math.max(1,c(e,t))),d=u.reduce((e,t)=>e+t,0)+l*Math.max(0,e.length-1),h=Math.max(0,r-i-a),f=s&&e.length>1?Math.max(0,h-d)/(e.length-1):0,m=/* @__PURE__ */new Map,p=i;return!s&&1===e.length&&(p=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{let r=u[t];m.set(e.id,{id:e.id,x:p+r/2,y:n,index:t,width:r}),p+=r+l+f}),m}function un(e,t=38,r=7.4,n=20){return Math.max(t,((e??"")+"").length*r+n)}function dn(e){let t=e.map(e=>{let t=Math.min(e.a,e.b),r=Math.max(e.a,e.b);return{span:e,a:t,b:r,width:r-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),r=new zs,n=t.map(e=>{let t=r.assign(e.a,e.b);return{span:e.span,level:t}}),o=Math.max(0,r.count-1);return{packed:n,maxLevel:o,levelCount:n.length?o+1:1}}function hn(e){let t=e.labelRoom??18,r=Math.max(48,e.baselineY-e.ceilingY-28),n=Math.max(1,e.levelCount),o=Math.min(42,Math.max(26,.18*r)),i=Math.max(24,r-o-t);return{arcLift:o,levelStep:Math.min(72,Math.max(28,n>1?i/Math.max(1,n-1):i))}}function fn(e,t,r,n,o={}){let i=r-(o.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${n} ${t} ${i}`}function mn(e,t,r){return e-r.arcLift-t*r.levelStep}function pn(e,t=gn){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};let r=e.map(e=>new Set(e.map(e=>t(e)))),n=/* @__PURE__ */new Set;for(let e of r[0])r.every(t=>t.has(e))&&n.add(e);let o=[],i=/* @__PURE__ */new Set;for(let r of e[0]){let e=t(r);n.has(e)&&!i.has(e)&&(o.push(r),i.add(e))}return{shared:o,exclusive:e.map(e=>e.filter(e=>!n.has(t(e))))}}function gn(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 yn(e,t,r){let n=r?.center?.x??0,o=r?.center?.y??0;return{x:n+Math.sin(e)*t,y:o-Math.cos(e)*t}}function xn(e,t,r){return(Math.atan2(e-(r?.center?.x??0),-(t-(r?.center?.y??0)))+Gs)%Gs}function bn(e,t){let[r,n]=e,o=n-r||1,i=t?.startAngle??0,a=t?.endAngle??Gs;return e=>i+(e-r)/o*(a-i)}function wn(e,t){let[r,n]=e,[o,i]=t,a=n-r||1;return e=>o+(e-r)/a*(i-o)}function Mn(e,t,r,n,o){let i=o?.center,a=(e,t)=>{let{x:r,y:n}=yn(e,t,{center:i});return`${vn(r)},${vn(n)}`},l=Math.max(0,r),s=Math.max(l,n),c=Math.abs(t-e),u=e>t?0:1;if(c>=Gs-1e-6){let e=i?.x??0,t=i?.y??0,r=`${vn(e)},${vn(t-s)}`,n=`${vn(e)},${vn(t+s)}`,o=`M${r} A${vn(s)},${vn(s)} 0 1 1 ${n} A${vn(s)},${vn(s)} 0 1 1 ${r} Z`;if(l>0){let r=`${vn(e)},${vn(t-l)}`,n=`${vn(e)},${vn(t+l)}`;o+=` M${r} A${vn(l)},${vn(l)} 0 1 0 ${n} A${vn(l)},${vn(l)} 0 1 0 ${r} Z`}return o}let d=c>Math.PI?1:0,h=a(e,s),f=a(t,s);if(0>=l){let e=i?.x??0,t=i?.y??0;return`M${vn(e)},${vn(t)} L${h} A${vn(s)},${vn(s)} 0 ${d} ${u} ${f} Z`}let m=a(t,l),p=a(e,l);return`M${h} A${vn(s)},${vn(s)} 0 ${d} ${u} ${f} L${m} A${vn(l)},${vn(l)} 0 ${d} ${1===u?0:1} ${p} Z`}function vn(e){return Math.round(1e3*e)/1e3}function kn(e,t){return{x:e.x+t.x,y:e.y+t.y}}function $n(e,t){return{x:e.x-t.x,y:e.y-t.y}}function An(e,t){return{x:e.x*t,y:e.y*t}}function Sn(e){return Math.hypot(e.x,e.y)}function In(e){let t=Sn(e)||1;return{x:e.x/t,y:e.y/t}}function Cn(e,t){let r=
|
|
52
|
-
return Hs("path",{d:
|
|
51
|
+
/* @__PURE__ */Ps("text",{x:e.x-7,y:n,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+r)}),e.label&&/* @__PURE__ */Ps("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 Kr(e){return null==e?void 0:e+""}function Ur(e){let t=Kr(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??8,style:{...qs,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function Qr(e){return Ur(e)}function Zr(e){let[[t,r],[n,o]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((n-t)*(o-r)),style:{...qs,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function Jr(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...qs,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:Kr(e.id)}}function en(e){let t=Kr(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...qs,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??8,style:{...qs,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function tn(e){let t={style:{...qs,cursor:e.cursor},datum:e.datum,id:Kr(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 rn(e,t,r={}){let{coord:n,step:o=1,equals:i=Object.is,truthyOnly:a=!1}=r,l=[],s=t=>n?n(e[t],t):t,c=(e,t,r)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=n?null==r||s(r)-s(t)>o?s(t)+o:s(r):t+1,l.push(e)},u=null;for(let r=0;e.length>r;r++){let l=t(e[r],r);if(a&&!l){u&&(c(u,u.endIndex,r),u=null);continue}let d=!n||0>=r||s(r)-s(r-1)<=o;u&&d&&i(u.value,l)?u.endIndex=r:(u&&c(u,u.endIndex,r),u={value:l,start:s(r),end:s(r),count:1,startIndex:r,endIndex:r})}return u&&c(u,u.endIndex,null),l}function nn(e,t,r=0){return t>0?((e-r)%t+t)%t+r:e}function on(e,t,r){if(0>=r)return t-e;let n=(t-e)%r;return n>r/2?n-=r:-r/2>n&&(n+=r),n}function an(e,t,r){return t>r?e>=t||r>=e:e>=t&&r>=e}function ln(e,t,r,n){return r>n?[...e.filter(e=>t(e)>=r),...e.filter(e=>t(e)<=n)]:e.filter(e=>an(t(e),r,n))}function sn(e,t){let r=Math.max(0,t.width),n=t.y,o=Math.min(74,Math.max(34,.08*r)),i=t.paddingLeft??o,a=e.length>1?Math.max(0,r-i-(t.paddingRight??o))/(e.length-1):0,l=/* @__PURE__ */new Map;return e.forEach((e,t)=>{l.set(e.id,{id:e.id,x:i+a*t,y:n,index:t})}),l}function cn(e,t){let r=Math.max(0,t.width),n=t.y,o=Math.min(74,Math.max(34,.08*r)),i=t.paddingLeft??o,a=t.paddingRight??o,l=t.gap??8,s=!1!==t.distribute,c=t.estimateWidth??(e=>un(e.label??e.id)),u=e.map((e,t)=>Math.max(1,c(e,t))),d=u.reduce((e,t)=>e+t,0)+l*Math.max(0,e.length-1),h=Math.max(0,r-i-a),f=s&&e.length>1?Math.max(0,h-d)/(e.length-1):0,m=/* @__PURE__ */new Map,p=i;return!s&&1===e.length&&(p=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{let r=u[t];m.set(e.id,{id:e.id,x:p+r/2,y:n,index:t,width:r}),p+=r+l+f}),m}function un(e,t=38,r=7.4,n=20){return Math.max(t,((e??"")+"").length*r+n)}function dn(e){let t=e.map(e=>{let t=Math.min(e.a,e.b),r=Math.max(e.a,e.b);return{span:e,a:t,b:r,width:r-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),r=new zs,n=t.map(e=>{let t=r.assign(e.a,e.b);return{span:e.span,level:t}}),o=Math.max(0,r.count-1);return{packed:n,maxLevel:o,levelCount:n.length?o+1:1}}function hn(e){let t=e.labelRoom??18,r=Math.max(48,e.baselineY-e.ceilingY-28),n=Math.max(1,e.levelCount),o=Math.min(42,Math.max(26,.18*r)),i=Math.max(24,r-o-t);return{arcLift:o,levelStep:Math.min(72,Math.max(28,n>1?i/Math.max(1,n-1):i))}}function fn(e,t,r,n,o={}){let i=r-(o.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${n} ${t} ${i}`}function mn(e,t,r){return e-r.arcLift-t*r.levelStep}function pn(e,t=gn){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};let r=e.map(e=>new Set(e.map(e=>t(e)))),n=/* @__PURE__ */new Set;for(let e of r[0])r.every(t=>t.has(e))&&n.add(e);let o=[],i=/* @__PURE__ */new Set;for(let r of e[0]){let e=t(r);n.has(e)&&!i.has(e)&&(o.push(r),i.add(e))}return{shared:o,exclusive:e.map(e=>e.filter(e=>!n.has(t(e))))}}function gn(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 yn(e,t,r){let n=r?.center?.x??0,o=r?.center?.y??0;return{x:n+Math.sin(e)*t,y:o-Math.cos(e)*t}}function xn(e,t,r){return(Math.atan2(e-(r?.center?.x??0),-(t-(r?.center?.y??0)))+Gs)%Gs}function bn(e,t){let[r,n]=e,o=n-r||1,i=t?.startAngle??0,a=t?.endAngle??Gs;return e=>i+(e-r)/o*(a-i)}function wn(e,t){let[r,n]=e,[o,i]=t,a=n-r||1;return e=>o+(e-r)/a*(i-o)}function Mn(e,t,r,n,o){let i=o?.center,a=(e,t)=>{let{x:r,y:n}=yn(e,t,{center:i});return`${vn(r)},${vn(n)}`},l=Math.max(0,r),s=Math.max(l,n),c=Math.abs(t-e),u=e>t?0:1;if(c>=Gs-1e-6){let e=i?.x??0,t=i?.y??0,r=`${vn(e)},${vn(t-s)}`,n=`${vn(e)},${vn(t+s)}`,o=`M${r} A${vn(s)},${vn(s)} 0 1 1 ${n} A${vn(s)},${vn(s)} 0 1 1 ${r} Z`;if(l>0){let r=`${vn(e)},${vn(t-l)}`,n=`${vn(e)},${vn(t+l)}`;o+=` M${r} A${vn(l)},${vn(l)} 0 1 0 ${n} A${vn(l)},${vn(l)} 0 1 0 ${r} Z`}return o}let d=c>Math.PI?1:0,h=a(e,s),f=a(t,s);if(0>=l){let e=i?.x??0,t=i?.y??0;return`M${vn(e)},${vn(t)} L${h} A${vn(s)},${vn(s)} 0 ${d} ${u} ${f} Z`}let m=a(t,l),p=a(e,l);return`M${h} A${vn(s)},${vn(s)} 0 ${d} ${u} ${f} L${m} A${vn(l)},${vn(l)} 0 ${d} ${1===u?0:1} ${p} Z`}function vn(e){return Math.round(1e3*e)/1e3}function kn(e,t){return{x:e.x+t.x,y:e.y+t.y}}function $n(e,t){return{x:e.x-t.x,y:e.y-t.y}}function An(e,t){return{x:e.x*t,y:e.y*t}}function Sn(e){return Math.hypot(e.x,e.y)}function In(e){let t=Sn(e)||1;return{x:e.x/t,y:e.y/t}}function Cn(e,t){let r=Ia(e,100);return r>0?t/r*100*(t/r):Math.PI*t*t}function Nn(e){let t=[],r=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(r.length>0){let n=e.colorType??"fill",o=r.map(([e,t])=>({label:e,color:t}));t.push({type:n,label:e.colorLabel??"",items:o,styleFn:"line"===n?e=>({stroke:e.color??_s,strokeWidth:2,fill:"none"}):e=>({fill:e.color??_s,stroke:e.color??_s})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){let r=e.symbolColor??_s,n=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:r}));t.push({label:e.symbolLabel??"",items:n,styleFn:()=>({}),type:e=>{let t=e.shape;/* @__PURE__ */
|
|
52
|
+
return Hs("path",{d:ka(t,Cn(t,7)),transform:"translate(8,8)",fill:e.color??r})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){let r=e.sizeRadius,n=e.sizeFormat??(e=>e+""),o=e.sizeColor??_s,i=e.sizeStops.map(e=>({label:n(e),r:Math.max(.5,r(e)),color:o}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>/* @__PURE__ */Hs("circle",{cx:8,cy:8,r:e.r,fill:e.color??o})})}return t}function Fn(e){let t=e.orientation??"vertical",r=e.swatchSize??14,n=e.gap??8,o=e.labelGap??6,i=e.fontSize??12,a=e.color??"var(--semiotic-text-secondary, #888)",l=r+n,s=0,c=[];return e.entries.forEach((e,u)=>{c.push(
|
|
53
53
|
/* @__PURE__ */Ys("g",{transform:`translate(${"vertical"===t?0:s},${"vertical"===t?s:0})`,children:[En(e,r,e.color??e.line??a,a),
|
|
54
54
|
/* @__PURE__ */Hs("text",{x:r+o,y:r/2,dominantBaseline:"middle",fontSize:i,fill:a,children:e.label})]},"legend-"+u)),s+="vertical"===t?l:r+o+e.label.length*i*.58+n+8}),/* @__PURE__ */Hs("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:c},e.keyId)}function En(e,t,r,n){if(e.shape){let n=Cn(e.shape,t/2-1);/* @__PURE__ */
|
|
55
|
-
return Hs("path",{d:
|
|
55
|
+
return Hs("path",{d:ka(e.shape,n),transform:`translate(${t/2},${t/2})`,fill:r})}if(e.hatch){let r=e.color??n;/* @__PURE__ */
|
|
56
56
|
return Ys("g",{children:[
|
|
57
57
|
/* @__PURE__ */Hs("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,n)=>/* @__PURE__ */Hs("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:r,strokeWidth:1,opacity:.7},n))}),
|
|
58
58
|
/* @__PURE__ */Hs("rect",{width:t,height:t,fill:"none",stroke:r,strokeWidth:1,opacity:.5,rx:2})]})}/* @__PURE__ */
|
|
59
59
|
return Hs("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:r})}function zn(e){let t=e,r=[Pn(t,["datum","data"]),Pn(t,["datum"]),Pn(t,["data","data"]),Pn(t,["data"]),Pn(t,["node","datum","data"]),Pn(t,["node","datum"]),e];for(let e of r){if(!jn(e))continue;let t={};for(let[r,n]of Object.entries(e))r.startsWith("_")||"function"==typeof n||(t[r]=n);if(Object.keys(t).length>0)return t}return null}function Rn(e,t={}){let r=zn(e);if(!r)return[];let n=new Set(Xs);if(t.excludeKeys)for(let e of t.excludeKeys)n.add(e);let o=[];for(let[e,i]of Object.entries(r))if((t.includeInternal||!e.startsWith("_"))&&!n.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(o.push({key:e,label:Tn(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,r):Ln(i)}),o.length>=(t.maxEntries??8)))break;return o}function Ln(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 Tn(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){let r=t[e];if("string"==typeof r&&r.length>0)return r}return e}function Pn(e,t){let r=e;for(let e of t){if(!jn(r))return;r=r[e]}return r}function jn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function On(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Wn(e,t){return On(e,t)?e[t]:void 0}function Dn(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function qn(){/* @__PURE__ */
|
|
60
|
-
return Object.create(null)}function Bn(e,t){let r=/* @__PURE__ */new Map;for(let t of e)r.set(t.id,/* @__PURE__ */new Set);for(let e of t)r.has(e.source)||r.set(e.source,/* @__PURE__ */new Set),r.has(e.target)||r.set(e.target,/* @__PURE__ */new Set),r.get(e.source).add(e.target),r.get(e.target).add(e.source);return r}function Vn(e,t){let r={};for(let t of e)Dn(r,t.id,0);for(let e of t)Dn(r,e.source,(Wn(r,e.source)??0)+1),Dn(r,e.target,(Wn(r,e.target)??0)+1);return r}function Gn(e,t){let r={};Dn(r,t,0);let n=[t],o=0;for(;n.length>o;){let t=n[o];o+=1;for(let o of e.get(t)||[])On(r,o)||(Dn(r,o,r[t]+1),n.push(o))}return r}function Hn(e,t,r,n){if(r===n)return r?[r]:[];let o=Bn(e,t),i=qn();i[r]=null;let a=[r],l=0;for(;a.length>l;){let e=a[l];if(l+=1,e===n)break;for(let t of o.get(e)||[])On(i,t)||(i[t]=e,a.push(t))}if(!On(i,n))return[];let s=[],c=n;for(;null!=c;)s.unshift(c),c=i[c];return s}function Yn(e,t,r,n=1){let o=Bn(e,t);if(!o.has(r))/* @__PURE__ */return new Set;let i=Gn(o,r),a=/* @__PURE__ */new Set;for(let e of Object.keys(i))n>=i[e]&&a.add(e);return a}function _n(e,t){let r=Bn(e,t),n={};for(let t of e)Dn(n,t.id,0);for(let t of e.map(e=>e.id)){let o=[],i=qn(),a=qn(),l=qn();for(let t of e)i[t.id]=[],a[t.id]=0,l[t.id]=-1;a[t]=1,l[t]=0;let s=[t],c=0;for(;s.length>c;){let e=s[c];c+=1,o.push(e);for(let t of r.get(e)||[])0>l[t]&&(l[t]=l[e]+1,s.push(t)),l[t]===l[e]+1&&(a[t]+=a[e],i[t].push(e))}let u=qn();for(let t of e)u[t.id]=0;for(;o.length;){let e=o.pop();for(let t of i[e])u[t]+=a[t]/a[e]*(1+u[e]);e!==t&&Dn(n,e,(Wn(n,e)??0)+u[e])}}for(let e of Object.keys(n))Dn(n,e,n[e]/2);return n}function Xn(e,t){let r=Bn(e,t),n={};for(let t of e){let e=Gn(r,t.id),o=0,i=0;for(let t of Object.keys(e))o+=e[t],i+=1;Dn(n,t.id,o>0?(i-1)/o:0)}return n}function Kn(e,t){let r=Bn(e,t),n={};for(let t of e){let e=[...r.get(t.id)||[]],o=e.length;if(2>o){Dn(n,t.id,0);continue}let i=0;for(let t=0;e.length>t;t+=1)for(let n=t+1;e.length>n;n+=1)r.get(e[t])?.has(e[n])&&(i+=1);Dn(n,t.id,2*i/(o*(o-1)))}return n}function Un(e){let t=0;for(let r of Object.keys(e))e[r]>t&&(t=e[r]);let r={};for(let n of Object.keys(e))Dn(r,n,t>0?e[n]/t:0);return r}function Qn(e,t,r,n={}){let o=Bn(e,t),i=qn();for(let t of e)i[t.id]=Gn(o,t.id);let a=n.minHops??4,l=n.startThreshold??.08,s=n.maxThreshold??.2,c=/* @__PURE__ */new Set,u=0;for(;0===c.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let n=t+1;e.length>n;n+=1){let o=e[t].id,s=e[n].id,u=Wn(r,o),d=Wn(r,s);if(!u||!d)continue;let h=u.x-d.x,f=u.y-d.y;(void 0===i[o][s]?1/0:i[o][s])>=a&&l>Math.sqrt(h*h+f*f)&&(c.add(o),c.add(s))}0===c.size&&(l+=.02,l>s&&(l=n.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:c,threshold:l,minHops:a}}function Zn(e){if("u">typeof __filename){let t=__filename.replace(/\\/g,"/"),r=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+r)}throw Error("Cannot resolve module worker asset: "+e)}function Jn(e){if("u">typeof DOMException)return new DOMException(e+" aborted","AbortError");let t=Error(e+" aborted");return t.name="AbortError",t}function eo(e){let t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function to(e,t,r,n,o=4e4){return"sync"!==e&&("worker"===e||n*(t+r)>=o)}function ro(){return"u">typeof window&&"u">typeof Worker}function no(){let e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):Zn("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}function oo(e,t){return ro()?Qs.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}async function io(e,t,r={}){let{execution:n="auto",signal:o,workerThreshold:i,nodeRadius:a,...l}=r,c=l.iterations??260;if(!ro()||!to(n,e.length,t.length,c,i))return s(e,t,{...l,nodeRadius:a});let u={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:l,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{return(await oo(u,o)).positions}catch(r){if("AbortError"===r?.name)throw r;return s(e,t,{...l,nodeRadius:a})}}function ao(e,t,r){return Math.max(t,Math.min(r,e))}function lo(e,t,r={}){let n=r.random??Math.random,o=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=ao(r.along??.5,.05,.95),a=r.jitterX??0,l=r.padY??20,s=o.x0+(o.x1-o.x0)*i+(2*n()-1)*a,c=Math.min(1,o.width/2),u=ao(s,o.x0+c,o.x1-c),d=e.boundaryY(u,"top")+l,h=e.boundaryY(u,"bottom")-l;return{x:u,y:h>d?d+n()*Math.max(1,h-d):e.midY}}function so(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 co(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function uo(e,t){let r=e;for(let e of t.split(".")){if(null==r||"object"!=typeof r||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e]}return r}function ho(e,t,r,n,o){return"function"==typeof n?n(e,t,r):uo(e,n??o)}function fo(e){let t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function mo(e){let t=(e??Zs).map(e=>{let t=co(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return fo(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function po(e){if(Array.isArray(e)){if(e.length>Js)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Js} points`);return Array.from(new Set(e.map(co).filter(e=>null!=e).map(fo))).sort((e,t)=>e-t)}let t=e,r=co(t.start),n=co(t.end),o=co(t.step);if(null==r||null==n||null==o||0>=o||r>n)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");let i=Math.floor((n-r)/o)+1;if(i>Js)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Js} points`);let a=[],l=1e-10*Math.max(1,Math.abs(n),Math.abs(r));for(let e=0;i>e;e+=1){let t=r+e*o;if(t>n+l)break;a.push(fo(Math.min(t,n)))}if((!a.length||Math.abs(a[a.length-1]-n)>l)&&a.push(fo(n)),a.length>Js)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Js} points`);return Array.from(new Set(a)).sort((e,t)=>e-t)}function go(e,t,r,n){let o=e.flatMap((e,o)=>{let i=co(ho(e,o,t,r,"time")),a=co(ho(e,o,t,n,"value"));return null==i||null==a?[]:[{time:fo(i),value:a,index:o}]});o.sort((e,t)=>e.time-t.time||e.index-t.index);let i=[];for(let e of o){let t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function yo(e,t){let r=0,n=e.length;for(;n>r;){let o=r+n>>>1;t>e[o].time?r=o+1:n=o}return r}function xo(e,t,r,n){if(!e.length)return null;let o=e[0],i=e[e.length-1];if(o.time>t)return"clamp"===n?o.value:null;if(t>i.time)return"clamp"===n?i.value:null;let a=yo(e,t),l=e[a];if(l?.time===t)return l.value;let s=e[Math.max(0,a-1)];return"step"!==r&&l&&l.time!==s.time?s.value+(t-s.time)/(l.time-s.time)*(l.value-s.value):s.value}function bo(e,t){if(1===e.length)return e[0];let r=(e.length-1)*t,n=Math.floor(r),o=Math.ceil(r);return n===o?e[n]:e[n]+(e[o]-e[n])*(r-n)}function wo(e){let t=e.interpolation??"step",r=e.outsideDomain??"omit",n=mo(e.quantiles),o=po(e.sampleAt),i=e.runs.map(t=>go(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:o.map(e=>{let o=i.map(n=>xo(n,e,t,r)).filter(e=>null!=e).sort((e,t)=>e-t),a={};for(let e of n)a[e]=o.length?bo(o,e):null;return{time:e,count:o.length,min:o.length?o[0]:null,max:o.length?o[o.length-1]:null,median:o.length?bo(o,.5):null,quantiles:a}}),quantiles:n,interpolation:t,outsideDomain:r,runCount:e.runs.length}}function Mo(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function vo(e,t){if("min"===t||"median"===t||"max"===t)return e[t];let r=co(t);if(null==r||0>r||r>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);let n=fo(r);if(!Object.prototype.hasOwnProperty.call(e.quantiles,n))throw Error(`comparePhysicsTrace could not find quantile ${n} in the reference envelope`);return e.quantiles[n]??null}function ko(e,t,r){return t>e?"below":e>r?"above":"inside"}function $o(e,t){let r=Math.max(0,t.time-e.time);if(0>=r||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};let n=e.value-e.lower,o=t.value-t.lower,i=e.value-e.upper,a=t.value-t.upper,l=[0,1];for(let[e,t]of[[n,o],[i,a]])(0>e&&t>0||e>0&&0>t)&&l.push(-e/(t-e));l.sort((e,t)=>e-t);let s=0,c=0,u=0;for(let n=0;l.length-1>n;n+=1){let o=l[n],i=l[n+1];if(o>=i)continue;let a=(o+i)/2,d=(i-o)*r,h=ko(e.value+(t.value-e.value)*a,e.lower+(t.lower-e.lower)*a,e.upper+(t.upper-e.upper)*a);"below"===h?s+=d:"above"===h?u+=d:c+=d}return{below:s,inside:c,above:u,observed:r}}function Ao(e,t,r={}){let n=r.interpolation??t.interpolation,o=r.outsideDomain??t.outsideDomain,i=go(e,r.traceId??"trace",r.timeAccessor,r.valueAccessor),a=r.lower??Mo(t,"lower"),l=r.upper??Mo(t,"upper"),s=t.points.map(e=>{let t=xo(i,e.time,n,o),r=vo(e,a),s=vo(e,l);if(null!=r&&null!=s&&r>s)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:r,upper:s,status:null==t||null==r||null==s?"unobserved":ko(t,r,s)}}),c=0,u=0,d=0,h=0,f=null,m=0,p=null;for(let e of s){if("below"===e.status?c+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;let t=Math.max(0,e.value-e.upper),r=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),r>m&&(m=r,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;s.length-1>e;e+=1){let t=s[e],r=s[e+1],o=Math.max(0,r.time-t.time);if(o>0){if("linear"===n){let e=$o(t,r);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=o,"below"===t.status?g+=o:"above"===t.status?x+=o:y+=o)}}let w=s[0]?.time,M=s[s.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:s,sampleCount:s.length,observedSamples:c+u+d,belowSamples:c,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 So(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Io(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Co(e){return!!Io(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&Io(e.visitsByStage)&&Io(e.firstEnteredAt)&&Io(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function No(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function Fo(e,t){let r=t.stageId?.(e);if(r)return r;let n=e.region.metadata;if(n&&"object"==typeof n&&Object.prototype.hasOwnProperty.call(n,"stageId")){let e=n.stageId;if("string"==typeof e)return e}return e.region.id}function Eo(e){let t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,No(e)]))}}function zo(e,t,r={}){if("region-enter"!==t.type)return e;let n=Fo(t,r),o=e.stages.findIndex(e=>e.id===n);if(0>o)return e;let i=r.entityId?.(t)??t.bodyId;if(!i)return e;let a=So(e.entities,i),l=Co(a)?a:No(i),s=l.currentStageId?e.stages.findIndex(e=>e.id===l.currentStageId):-1,c=!l.visitedStageIds.includes(n),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=So(l.visitsByStage,n),f="number"==typeof h&&Number.isFinite(h)?h:0,m={...l,currentStageId:n,furthestStageId:o>l.furthestStageIndex?n:l.furthestStageId,furthestStageIndex:Math.max(l.furthestStageIndex,o),visitedStageIds:c?[...l.visitedStageIds,n]:l.visitedStageIds,visitsByStage:{...l.visitsByStage,[n]:f+1},firstEnteredAt:c?{...l.firstEnteredAt,[n]:d}:l.firstEnteredAt,lastEnteredAt:{...l.lastEnteredAt,[n]:d},regressionCount:s>=0&&s>o?l.regressionCount+1:l.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:m}}}function Ro(e){let t=e.bodyIds.map(t=>{let r=So(e.entities,t);return Co(r)?r:No(t)}),r=t.length,n=r;return e.stages.map((e,o)=>{let i=t.filter(e=>e.furthestStageIndex>=o).length,a=t.filter(t=>t.visitedStageIds.includes(e.id)).length,l=t.reduce((t,r)=>{let n=So(r.visitsByStage,e.id);return t+("number"==typeof n&&Number.isFinite(n)?n:0)},0),s={id:e.id,label:e.label??e.id,reached:i,entered:a,total:r,conversion:r>0?i/r:0,fromPrevious:n>0?i/n:0,dropoff:Math.max(0,n-i),visits:l,repeatVisits:Math.max(0,l-a)};return n=i,s})}function Lo(e,t){if("function"==typeof t){let r=t(e);return Number.isFinite(r)&&r>0?Number(r):1}let r=e.datum;if(t&&r&&"object"==typeof r){let e=Number(r[t]);if(Number.isFinite(e)&&e>0)return e}let n=Number(r?.work??r?.reviewWork??r?.value);return Number.isFinite(n)&&n>0?n:1}function To(e,t){if("function"==typeof t){let r=t(e);if(null!=r&&(r+"").length>0)return r+""}else if(t){let r=Di(e.datum,t),n=Di(e,t),o=r??n;if(null!=o&&(o+"").length>0)return o+""}return e.id}function Po(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];let r=Math.max(0,Math.min(1,t))*(e.length-1),n=Math.floor(r);return e[n]+(e[Math.ceil(r)]-e[n])*(r-n)}function jo(e){function t(e,t){let r=t(e);return!!r&&r.activeRegionIds.includes(f)}function r(){X+=1}function n(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:f,work:e.total,queuedAt:e.queuedAt}}function o(t,r,o){let i=n(r);e.onQueued?.(t,i),o.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:f,work:r.total,jobId:r.jobId,visitId:r.visitId,visit:r.visit,queuedAt:r.queuedAt,queueDepth:v.size})}function i(e,t,n,i){let a={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,a),C.delete(e.id),I.set(e.id,t.jobId),O+=1,W+=t.work,r(),o(e,a,n),a}function a(e){if(v.size>=x||0===k.size)return;let t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);for(let r of t){if(v.size>=x)break;let t=S.get(r.jobId);t&&$.has(r.jobId)?(k.delete(r.jobId),C.delete(r.bodyId),i(t,r,e,r.sequence)):k.delete(r.jobId)}}function l(){let e=0;for(let t of v.values())e+=t.remaining;return e}function s(){let e=0;for(let t of k.values())e+=t.work;return e}function c(){H=Math.max(H,v.size),Y=Math.max(Y,l())}function u(){let e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);E=new Map(e.map((e,t)=>[e.bodyId,t]));let t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);z=new Map(t.map((e,t)=>[e.bodyId,t])),R=e.length}function d(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&N.push(e);let t=T-b;for(;N.length>0&&t>N[0].end;)N.shift()}function h(){let e=T-b,t=Math.max(0,Math.min(b,T-(P??T))),r=0,n=0,o=0,i=0,a=0;for(let t of N){if(e>t.end)continue;r+=t.arrivals,n+=t.arrivalWork,o+=t.completions,i+=t.completedWork;let l=t.end-t.start;a+=l>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/l):t.processedWork}let l=t>0?n/t:0;return{seconds:t,arrivals:r,arrivalWork:n,completions:o,completedWork:i,processedWork:a,arrivalsPerSecond:t>0?r/t:0,throughputPerSecond:t>0?o/t:0,utilization:t>0&&m>0?Math.max(0,Math.min(1,a/(m*t))):0,pressure:m>0?l/m:0}}let f=e.regionId,m=Math.max(0,e.unitsPerSecond),p=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,N=[],F=0,E=/* @__PURE__ */new Map,z=/* @__PURE__ */new Map,R=0,L=0,T=0,P=null,j=0,O=0,W=0,D=0,q=0,B=0,V=0,G=0,H=0,Y=0,_=0,X=0,K=-1,U=!1;return{id:e.id??"capacity-queue:"+f,continuous:!1!==e.continuous,tick:o=>{let l=o.controls.readBodies(),s=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(let r of l){if(s.set(r.id,r),!t(r.id,o.getRegionState)||!Bi(r,e.bodyFilter))continue;let n=To(r,e.jobKey),i=h.get(n)??[];i.push(r),h.set(n,i)}let p=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!U){let e=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):p;T=Math.max(0,e-p),U=!0}let g=T,y=g+p;T=y,P=null==P?g:Math.min(P,g);let b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},N=/* @__PURE__ */new Map;for(let[e,t]of h){let r=$.get(e)?.bodyId,n=t.find(e=>e.id===r)??t[0];N.set(e,n),S.set(e,n)}for(let[t,i]of $){if(N.has(t))continue;let a=v.get(t),l=s.get(i.bodyId)??S.get(t);if(a){v.delete(t),I.delete(a.bodyId),V+=1,G+=a.remaining,r();let s={...n(a),abandonedAt:T,remainingWork:a.remaining,queueSeconds:Math.max(0,T-a.queuedAt)};l&&e.onAbandoned?.(l,s),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:l?.datum,x:l?.x,y:l?.y,regionId:f,work:a.total,remainingWork:a.remaining,jobId:t,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:T,queueSeconds:s.queueSeconds,queueDepth:v.size})}k.delete(t),C.delete(i.bodyId),$.delete(t),S.delete(t)}for(let[t,n]of N){if($.has(t))continue;let a=(A.get(t)??0)+1;A.set(t,a);let l=Lo(n,e.unitAccessor),s={bodyId:n.id,jobId:t,visitId:`${f}:${t}:${a}`,visit:a,regionId:f,work:l,queuedAt:T};$.set(t,s),j+=1,b.arrivals+=1,b.arrivalWork+=l;let c=F++;if(x>v.size)i(n,s,o,c);else{let i={...s,blockedAt:T,sequence:c};k.set(t,i),C.set(n.id,t),B+=1,r(),e.onBlocked?.(n,i),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:f,work:l,jobId:t,visitId:s.visitId,visit:a,queuedAt:T,blockedAt:T,queueDepth:v.size,blockedDepth:k.size})}}a(o),c();let E=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence),z=m*p;for(let t of E){if(0>=z)break;let i=Math.min(t.remaining,z);if(t.remaining-=i,z-=i,D+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),I.delete(t.bodyId),L+=1,q+=t.total,b.completions+=1,b.completedWork+=t.total;let a=Math.max(0,T-t.queuedAt);_+=a,r();let l=s.get(t.bodyId);if(!l)continue;o.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);let c={...n(t),completedAt:T,queueSeconds:a};e.onProcessed?.(l,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:l.datum,x:l.x,y:l.y,regionId:f,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:T,queueSeconds:a,queueDepth:v.size})}a(o),c(),u(),d(b);let R=Math.floor(T/w);R!==K&&(K=R,r())},getSnapshot:()=>{let e=l(),t=s(),r=v.size,n=Array.from(v.values()).map(e=>Math.max(0,T-e.queuedAt)).sort((e,t)=>e-t),o=n.reduce((e,t)=>e+t,0);return{regionId:f,queueDepth:r,processedCount:L,unitsPerSecond:m,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+t,blockedDepth:k.size,blockedWork:t,arrivalCount:j,admittedCount:O,admittedWork:W,processedWork:D,completedWork:q,blockedCount:B,abandonedCount:V,abandonedWork:G,peakQueueDepth:H,peakRemainingWork:Y,queueAge:{count:n.length,meanSeconds:n.length>0?o/n.length:0,p50Seconds:Po(n,.5),p95Seconds:Po(n,.95),oldestSeconds:n.at(-1)??0},meanCompletedQueueSeconds:L>0?_/L:0,window:h(),simulatedAt:T,metricRevision:X}},bodyForce:e=>{if("none"===p)return null;let t=I.get(e.body.id),r=C.get(e.body.id),n=t?v.get(t):void 0,o=r?k.get(r):void 0;if(!n&&!o)return null;let i=n?E.get(e.body.id):z.get(e.body.id);if(null==i)return null;let a,l=e.regions;if(l)for(let e=0;l.length>e;e+=1)if(l[e].id===f){let t=l[e].shape;t&&"aabb"===t.type&&(a=t);break}return a?{x:((o?a.x-.44*a.width:a.x-.22*a.width-i*(.15*g))-e.body.x)*y,y:(a.y-(i-((o?k.size:R)-1)/2)*g/Math.max(1,Math.sqrt(o?k.size:R))-e.body.y)*y*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Oo(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Wo(e){if(!e?.length)return null;let t=e.slice(),r=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:r,onTick:(e,r,n)=>{let o={result:e,controls:r,dt:n.dt,elapsed:n.elapsed,getRegionState:n.getRegionState};for(let e of t)e.tick(o)},bodyForce:e=>{let r=null;for(let n of t)n.bodyForce&&(r=Oo(r,n.bodyForce(e)));return r}}}function Do(e){let t=/* @__PURE__ */new Set,r=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:n=>{let o=n.controls.readBodies();for(let i of o)n.getRegionState(i.id)?.activeRegionIds.includes(e.fromRegionId)?t.has(i.id)||(t.add(i.id),n.controls.applyImpulse(i.id,r.x??0,r.y??0),e.onPortal?.(i)):t.delete(i.id)}}}function qo(e){let t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),r=new Map(t.map(e=>[e.bodyId,e])),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map,i=e.assignmentForce??.45,a=e.returnForce??.35,l=e.caseAttraction??.08,s=e.assignmentOffset??{x:0,y:0},c=/* @__PURE__ */new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{let r=n.get(e);if(r)return r;let i=t.find(e=>!o.has(e.id));if(!i)return null;let a={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return n.set(e,a),o.set(i.id,a),d+=1,a},release:e=>{let t=n.get(e);return!!t&&(n.delete(e),o.delete(t.resourceId),d+=1,!0)},getAssignment:e=>n.get(e),tick:e=>{u=Math.max(u,e.elapsed),c=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(let[e,t]of n)c.has(e)&&c.has(t.resourceBodyId)||(n.delete(e),o.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-o.size,assigned:o.size,assignments:Array.from(n.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{let t=r.get(e.body.id);if(t){let r=o.get(t.id),n=r?c.get(r.caseBodyId):void 0,l=r?i:a;return{x:((n?n.x+(s.x??0):t.home.x)-e.body.x)*l,y:((n?n.y+(s.y??0):t.home.y)-e.body.y)*l}}let u=n.get(e.body.id);if(!u||0>=l)return null;let d=c.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*l,y:(d.y-e.body.y)*l}:null}}}function Bo(e,t){let r="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):Di(e.datum,t.deadlineAccessor)??Di(e,t.deadlineAccessor);return Number.isFinite(Number(r))?Math.max(0,Number(r)):0}function Vo(e){function t(t){n.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function r(e){let r=n.get(e);return!(!r||null!=r.completedAt||(t({...r,completedAt:o,state:"unhappy"===r.state?"resolved-unhappy":"resolved"}),0))}let n=/* @__PURE__ */new Map,o=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{let r=n.get(e);return!(!r||null!=r.completedAt||"unhappy"===r.state||(t({...r,state:"protected",protectedAt:o}),0))},complete:r,getCase:e=>n.get(e),tick:i=>{o=Math.max(o,i.elapsed);for(let a of i.controls.readBodies()){if(!Bi(a,e.bodyFilter))continue;if(!n.has(a.id)){let r=Bo(a,e);t({bodyId:a.id,openedAt:o,deadlineAt:o+r,state:"waiting"})}let l=n.get(a.id);l&&null==l.completedAt&&(e.completionRegionId&&i.getRegionState(a.id)?.activeRegionIds.includes(e.completionRegionId)?r(a.id):"waiting"===l.state&&o>=l.deadlineAt&&t({...l,state:"unhappy"}))}},getSnapshot:()=>{let e=Array.from(n.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:o,metricRevision:i}}}}function Go(e){function t(t){return e.isOpen?e.isOpen(t):null!=e.opensAt&&t>=e.opensAt}let r=/* @__PURE__ */new Set,n=0,o=0,i=0,a=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:l=>{n=Math.max(n,l.elapsed);let s=a;a=t(n);let c=l.controls.readBodies(),u=new Map(c.map(e=>[e.id,e]));for(let t of c)!l.getRegionState(t.id)?.activeRegionIds.includes(e.regionId)||!Bi(t,e.bodyFilter)||!a&&!r.has(t.id)&&(r.add(t.id),i+=1,e.onHeld?.(t));if(a&&!s){for(let t of r){let r=u.get(t);r&&(l.controls.applyImpulse(t,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(r))}r.clear(),i+=1}for(let e of r)u.has(e)||(r.delete(e),i+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:a,blocked:r.size,released:o,simulatedAt:n,metricRevision:i}),bodyForce:t=>{if(a||!r.has(t.body.id))return null;let n=t.regions?.find(t=>t.id===e.regionId)?.shape;if(!n||"aabb"!==n.type)return{x:.8*-t.body.vx,y:.8*-t.body.vy};let o=e.holdForce??.4;return{x:(n.x-t.body.x)*o-.45*t.body.vx,y:(n.y-t.body.y)*o-.45*t.body.vy}}}}function Ho(e){return null==e?{top:tc,right:tc,bottom:tc,left:tc}:"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}}function Yo(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+""}))}function _o(e){let[t,r]=e.size,n=e.flow??ec,o=Ho(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??ic)),a={x:o.left,y:o.top,width:Math.max(1,t-o.left-o.right),height:Math.max(1,r-o.top-o.bottom)},l="down"===n?a.height:a.width,s=l*Math.max(0,e.chargeExtent??rc),c=l*Math.max(0,e.projectionExtent??oc),u=l*Math.max(0,e.destinationExtent??nc),d=Math.max(0,l-s-u-c),h=Yo(e.destinations),f=("down"===n?a.width:a.height)/h.length,m="down"===n?(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,s),g=m(s,d),y=s+d,x=m(y,u),b=m(y+u,c),w=h.map((e,t)=>{let r=t*f,o=f*i,l=(f-o)/2;return"down"===n?{id:e.id,label:e.label,order:t,x:a.x+r+l,y:x.y,width:o,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+r+l,width:x.width,height:o,centerX:x.x+x.width/2,centerY:a.y+(t+.5)*f}});return{width:t,height:r,flow:n,charge:p,apparatus:g,destinations:w,projection:b}}function Xo(e,t){return e.destinations.find(e=>e.id===t)}function Ko(e,t,r){let{charge:n,flow:o}=e,i=Math.max(1,r),a=(t%i+.5)/i;return"down"===o?{x:n.x+n.width*a,y:n.y+n.height/2}:{x:n.x+n.width/2,y:n.y+n.height*a}}function Uo(e,t={}){let r=t.thickness??4,n=t.idPrefix??"stage",{destinations:o,flow:i,width:a,height:l}=e,s=[];if(o.length>0){let t=o[0];if("down"===i){let i=t.y+t.height;s.push({id:n+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:r}});for(let e=1;o.length>e;e+=1){let a=o[e].centerX-(o[e].centerX-o[e-1].centerX)/2;s.push({id:`${n}-divider-${e}`,shape:{type:"segment",x1:a,y1:t.y,x2:a,y2:i,thickness:r}})}}else{let i=t.x+t.width;s.push({id:n+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:r}});for(let e=1;o.length>e;e+=1){let a=o[e].centerY-(o[e].centerY-o[e-1].centerY)/2;s.push({id:`${n}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:a,x2:i,y2:a,thickness:r}})}}}return!1!==t.walls&&s.push({id:n+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:l,thickness:r}},{id:n+"-wall-right",shape:{type:"segment",x1:a-1,y1:0,x2:a-1,y2:l,thickness:r}}),s}function Qo(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 Zo(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Jo(e,t,r,n){let o="function"==typeof e?e(t,r):e;return Number.isFinite(o)?Number(o):n}function ei(e,t,r){return Zo(e[t])??r}function ti(e,t){return"number"==typeof e?e:e?.[t]??0}function ri(e){let t=e.bandwidth??e.scale.bandwidth?.()??0,r=/* @__PURE__ */new Set;for(let n of e.values){let o=e.scale(n);Number.isFinite(o)&&(r.add(Number(o)),r.add(Number(o)+t))}return Array.from(r).sort((e,t)=>e-t)}function ni(e){let{band:t,idPrefix:r,plot:n,projection:o}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:l=4}=t,s=ri(t);if(2>s.length)return[];let c=i?s.length-1:s.length-2,u=[];for(let e=i?0:1;c>=e;e+=1){if(!a&&e>0&&s.length-1>e)continue;let t=s[e];u.push({id:`${r}-wall-${e}`,shape:"x"===o?{type:"aabb",x:t,y:n.y+n.height/2,width:l,height:n.height}:{type:"aabb",x:n.x+n.width/2,y:t,width:n.width,height:l}})}return u}function oi(e){let{plot:t,idPrefix:r="physics-scale",bounds:n={},xBins:o,xBands:i,yBands:a}=e,l=[];if(!1!==n&&l.push(...Yi(t,{idPrefix:r,...n})),o){let{idPrefix:e,yTop:n,yBottom:i,...a}=o;l.push(...Xi({...a,idPrefix:e??r+"-xbin",yTop:n??t.y,yBottom:i??t.y+t.height}))}return i&&l.push(...ni({band:i,idPrefix:i.idPrefix??r+"-xband",plot:t,projection:"x"})),a&&l.push(...ni({band:a,idPrefix:a.idPrefix??r+"-yband",plot:t,projection:"y"})),l}function ii(e){let{plot:t,rows:r,columns:n=r+1,pegRadius:o=3,idPrefix:i="galton-peg",yStart:a=t.y+.18*t.height,yEnd:l=t.y+.58*t.height,stagger:s=!0,restitution:c=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(r)),h=Math.max(1,Math.floor(n));if(0===d)return[];let f=d>1?(l-a)/(d-1):0,m=t.width/h,p=[];for(let e=0;d>e;e+=1){let r=s&&e%2==1?m/2:0;for(let n=0;h>n;n+=1){let l=t.x+m*(n+.5)+r;t.x+o>l||l>t.x+t.width-o||p.push({id:`${i}-${e}-${n}`,shape:{type:"aabb",x:l,y:a+e*f,width:2*o,height:2*o},restitution:c,friction:u})}}return p}function ai(e,t={}){let{idPrefix:r="physics-token",radius:n=5,shape:o,mass:i,vx:a,vy:l,spawnAt:s,seed:c=1,jitter:u,datum:d}=t,h=Wi(c),f=ti(u,"x"),m=ti(u,"y");return e.map((e,c)=>{let u=Jo(t.x,e,c,ei(e,"x",0)),p=Jo(t.y,e,c,ei(e,"y",0)),g=Jo(n,e,c,5),y="function"==typeof o?o(e,c):o??{type:"circle",radius:g};return{id:`${r}-${e.index??c}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:Jo(a,e,c,0),vy:Jo(l,e,c,0),mass:Jo(i,e,c,1),spawnAt:Jo(s,e,c,void 0),shape:y,datum:d?d(e,c):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;let{spawnAt:t,...r}=e;return r})}function li(e,t={}){let{idPrefix:r="sediment",collider:n=!0,colliderThickness:o=1,restitution:i=.05,friction:a=.2,...l}=t,s=Gi(e,l),c=n?s.filter(e=>e.height>0).map(e=>({id:`${r}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+o/2,width:e.width,height:o},restitution:i,friction:a})):[];return{columns:s,colliders:c}}function si(e,t,r){return Zo("function"==typeof r?r(e,t):e[r]??e.datum?.[r])}function ci(e,t={}){let{timeAccessor:r="arrivalTime",timeScale:n=1,startAt:o=0,rebase:i=!0,sort:a=!0}=t,l=e.map((e,t)=>({spawn:e,time:si(e,t,r)??e.spawnAt??t})),s=l.length?Math.min(...l.map(e=>e.time)):0;return{initialSpawns:l.map(({spawn:e,time:t})=>({...e,spawnAt:o+(i?t-s:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:o,timeAccessor:"spawnAt",timeScale:n}}}function ui(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function di(e,t,r="group"){let n=Vn(e,t),o=e=>"function"==typeof r?r(e):e[r]??0;return e.slice().sort((e,t)=>{let r=o(e),i=o(t);return i>r?-1:r>i?1:(n[t.id]||0)-(n[e.id]||0)}).map(e=>e.id)}function hi(e,t={}){let r=t.baseline??.62,n=t.inset??.06,o={},i=e.length;return e.forEach((e,t)=>{ui(o,e,{x:i>1?n+t/(i-1)*(1-2*n):.5,y:r})}),o}function fi(e,t,r=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*r} ${t.x},${t.y}`}function mi(e,t={}){let r=t.radius??.42,n=t.center?.x??.5,o=t.center?.y??.5,i=t.startAngle??0,a={},l=e.length;return e.forEach((e,t)=>{let s=i+t/l*Math.PI*2-Math.PI/2;ui(a,e,{x:n+Math.cos(s)*r,y:o+Math.sin(s)*r})}),a}function pi(e,t,r={}){let n=(r.order??di(e,t,r.groupAccessor??"group")).slice(),o=new Map(n.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(let e of t){if(!o.has(e.source)||!o.has(e.target)||e.source===e.target)continue;let 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))}let a=[],l=0;for(let[e,t]of i){let[r,n]=e.split("\0"),i=o.get(r),s=o.get(n);t>l&&(l=t),a.push({row:i,col:s,source:r,target:n,value:t}),a.push({row:s,col:i,source:n,target:r,value:t})}return{order:n,cells:a,size:n.length,maxValue:l}}function gi(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function yi(e){if("string"!=typeof e)return;let t=e.trim();return t.length?t:void 0}function xi(e,t){let r=gi(e.note)?e.note:void 0;return t?yi(e.mobileText)||yi(e.shortText)||yi(e.label)||yi(r?.mobileText)||yi(r?.shortText)||yi(r?.label)||yi(r?.title):yi(e.label)||yi(e.mobileText)||yi(e.shortText)||yi(r?.label)||yi(r?.title)}function bi(e,t,r){if(!r)return;let n="function"==typeof r?r(e,t):e[r];return"number"==typeof n&&Number.isFinite(n)?n:void 0}function wi(e,t,r){let n=bi(e,t,r.priorityAccessor);if(void 0!==n)return n;let o=1e3-t,i=((e.emphasis??"")+"").toLowerCase();("primary"===i||"critical"===i)&&(o+=1e4),"secondary"===i&&(o-=1e3),"high"===e.priority&&(o+=5e3),"low"===e.priority&&(o-=1500),"number"==typeof e.priority&&(o+=100*e.priority);let a=gi(e.provenance)?e.provenance:void 0;"number"==typeof a?.confidence&&(o+=100*a.confidence);let l=gi(e.lifecycle)?e.lifecycle:void 0,s=((l?.freshness??"")+"").toLowerCase();return("expired"===s||"stale"===s)&&(o-=3e3),o}function Mi(e,t){if(!t)return e;let r=xi(e,!0);return r&&"string"==typeof e.label?{...e,label:r}:e}function vi(e,t,r,n){let o=xi(e,n);if(!o)return null;let i=yi(e.id)||yi(e.key)||yi(e.pointId)||"annotation-"+(t+1),a=gi(e.provenance)?yi(e.provenance.source)||yi(e.provenance.authorKind):void 0;return{id:i,label:o,shortLabel:yi(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:a,priority:r,annotation:e}}function ki(e,t={}){let r=Array.isArray(e)?e.filter(gi):[],n=t.active??(null==t.width||(t.breakpoint??480)>=t.width),o=t.strategy??"hybrid",i=!1!==t.preferShortText,a=!1!==t.preservePrimary,l=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===o?1:2)),s=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!n||"plot"===o)return{active:n,strategy:o,budget:r.length,visible:i?r.map(e=>Mi(e,i)):r,deferred:[],calloutList:[],hidden:[]};let c=[],u=r.map((e,r)=>({annotation:e,index:r,priority:wi(e,r,t)})).filter(e=>!!qi(e.annotation)||(c.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(l,s)),p=new Set(m.map(e=>e.index)),g=u.filter(e=>!p.has(e.index)),y=[...c,...m.sort((e,t)=>e.index-t.index).map(e=>Mi(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=>vi(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:n,strategy:o,budget:l,visible:y,deferred:x,calloutList:w,hidden:v}}function $i(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function Ai(e,t){let r=t.targetSize??44,n=[],o=t.standardControls,i=e=>!0===o||"all"===o||o===e||Array.isArray(o)&&o.includes(e);return i("brush")&&n.push("range-inputs","clear-brush"),i("zoom")&&n.push("zoom-buttons","reset-view"),i("legend")&&n.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:r,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:r,...n.length>0&&{alternatives:n}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function Si(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function Ii(e,t){let r=!1!==t.keepAxes,n=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:n,bottom:r?44:12,left:r?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:n,bottom:r?42:14,left:r?44:14}}function Ci(e,t,r,n={}){let o={...r},i={mode:!1===t.mode?void 0:"mobile",...o,margin:Ii(e,t),...n},a=Object.fromEntries(Object.entries(o).filter(([,e])=>void 0!==e)),l=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),s=Ai(e,t),c=$i(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:{...l,mobileInteraction:c,mobileSemantics:s}}],mobileInteraction:c,mobileSemantics:s}}function Ni(e={}){let t=Si(e);return Ci("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 Fi(e={}){let t=Si(e);return Ci("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 Ei(e={}){return Ci("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function zi(e={}){let t=Si(e);return Ci("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 Ri(e={}){let t=Si(e);return Ci("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 Li(e={}){return Ci("geo",e,{showLegend:e.showLegend??!1})}function Ti(e={}){return Ci("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Pi(e,t={}){switch(e){case"line":return Ni(t);case"area":return Fi(t);case"ordinal":return Ei(t);case"scatter":return zi(t);case"network":return Ri(t);case"geo":return Li(t);case"small-multiple":return Ti(t)}}function ji(e={}){let 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}}import{$ as Oi,A as Wi,B as Di,Ba as qi,C as Bi,Ca as Vi,D as Gi,Da as Hi,E as Yi,Ea as _i,F as Xi,Fa as Ki,I as Ui,J as Qi,K as Zi,L as Ji,M as ea,N as ta,O as ra,P as na,Q as oa,R as ia,S as aa,T as la,U as sa,V as ca,W as ua,X as da,Y as ha,Z as fa,_ as ma,a as pa,aa as ga,b as ya,ba as xa,c as ba,ca as wa,d as Ma,da as va,e as ka,ea as $a,f as Aa,fa as Sa,g as Ia,ga as Ca,h as Na,ha as Fa,i as Ea,ia as za,j as Ra,ja as La,k as Ta,ka as Pa,l as ja,la as Oa,m as Wa,n as Da,na as qa,o as Ba,oa as Va,p as Ga,pa as Ha,q as Ya,qa as _a,r as Xa,s as Ka,sa as Ua,t as Qa,u as Za,v as Ja,w as el,x as tl,y as rl,z as nl}from"./c-KXH7LFIL.min.js";import"./c-3PFVJFBK.min.js";var ol=e=>{let n=e.config,o=n.rows??10,i=n.columns??10,a=n.gutter??2,l=o*i;if(0>=o||0>=i||0>=l)return{nodes:[]};let{plot:s}=e.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};let c=(s.width-a*(i-1))/i,u=(s.height-a*(o-1))/o;if(0>=c||0>=u)return{nodes:[]};let d=t(n.categoryAccessor)??(()=>"_default"),h=r(n.valueAccessor)??(()=>1),f=/* @__PURE__ */new Map,m=[];for(let t of e.data){let e=d(t)+"",r=Number(h(t)),n=Number.isFinite(r)?Math.max(0,r):0;f.has(e)||m.push(e),f.set(e,(f.get(e)??0)+n)}let p,g=Array.from(f.values()).reduce((e,t)=>e+t,0);if(0>=g)return{nodes:[]};if(n.categoryOrder&&n.categoryOrder.length>0){let e=/* @__PURE__ */new Set,t=[];for(let r of n.categoryOrder)f.has(r)&&!e.has(r)&&(e.add(r),t.push(r));p=[...t,...m.filter(t=>!e.has(t))]}else p=m;if(0===p.length)return{nodes:[]};let y=p.map(e=>({cat:e,exact:(f.get(e)??0)/g*l})).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;l-x>e;e++)y[b[e%b.length].i].count+=1;let w="string"==typeof n.categoryAccessor?n.categoryAccessor:"category",M="string"==typeof n.valueAccessor?n.valueAccessor:"value",v=(e,t,r)=>Aa(n=>{n("category",e),n("value",f.get(e)??0),n("share",(f.get(e)??0)/g),"category"!==w&&n(w,e),"value"!==M&&n(M,f.get(e)??0),n("cells",r),n("_waffleCategory",e),n("_waffleIndex",t)}),k=[],$=0;for(let t of y){let r=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)k.push({type:"rect",x:s.x+$%i*(c+a),y:s.y+(o-1-Math.floor($/i))*(u+a),w:c,h:u,style:{fill:r,stroke:"none"},datum:v(t.cat,$,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),$++}return{nodes:k}};import{forceCenter as il,forceCollide as al,forceLink as ll,forceManyBody as sl,forceSimulation as cl,forceX as ul,forceY as dl}from"d3-force";var hl="#334155",fl="#f8fafc",ml="#cbd5e1",pl={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"}]},gl={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}]},yl={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},xl={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"}]},bl="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",wl={viewBox:[18,40],anchor:[.5,1],parts:[{d:bl,fill:"color",stroke:"color",strokeWidth:1.4}]},Ml={server:pl,chip:gl,bolt:yl,bus:xl,person:wl},vl="var(--semiotic-primary, #4e79a7)",kl="var(--semiotic-border, #d1d5db)",$l=new Set(za);import{jsx as Al,jsxs as Sl}from"react/jsx-runtime";var Il={resource:32,city:64},Cl=["#739b58","#83a964","#668d52","#8baa68"],Nl={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},Fl={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"},El=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),zl=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),Rl=e=>{let t=te(e.config.gridSize),r=Math.max(20,e.config.tileWidth??80),n=Math.max(10,e.config.tileHeight??40),o=e.config.terrainColors?.length?e.config.terrainColors:Cl,i=e.dimensions.width/2,a=(e.dimensions.height-t*n)/2+n/2,l=ne(e.points,e.config).map(e=>({...e,x:i+r/2*(e.column-e.row),y:a+(e.column+e.row)*(n/2)}));return{nodes:l.map(t=>{let i=K(e.config.terrainByCell,t.id),a="city"===t.landmark?.kind?"urban":i?.kind??"land",l=i?.fill??_(e.config.terrainPalette,a)??U(a),s=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:Q(a),kind:"terrain",terrainKind:a,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};return{type:"geoarea",pathData:oe(t.x,t.y,r,n),centroid:[t.x,t.y],bounds:[[t.x-r/2,t.y-n/2],[t.x+r/2,t.y+n/2]],screenArea:r*n/2,style:{fill:i||"urban"===a?l:o[t.terrainIndex%o.length],stroke:"ocean"===a?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:s,group:t.landmark?.kind??a,interactive:!0}}),overlays:/* @__PURE__ */Al(ie,{tiles:l,tileWidth:r,tileHeight:n,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??32,citySize:e.config.citySpriteSize??64,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}}},Ll={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"]},Tl={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"}};import{jsx as Pl}from"react/jsx-runtime";var jl=e=>{let t=e.config,r=t.source??"auto",n="areas"===r||"auto"===r&&e.areas.length>0,o=(n?xe(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,r)=>!t.filter||t.filter(e.datum,r)),i=we(o.map(e=>e.datum),t),a=n?o:be({...e,points:o.map(e=>e.datum)}),l=i??he(a,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===l.length)return{nodes:[]};let s=ue(l.map(e=>e.row)),c=ue(l.map(e=>e.column)),u=Math.max(1,Math.round(s[1]-s[0])+1),d=Math.max(1,Math.round(c[1]-c[0])+1),h=Math.max(0,t.layoutPadding??8),f=Math.max(1,e.dimensions.width-2*h)/d,m=Math.max(1,e.dimensions.height-2*h)/u,p=(e.dimensions.width-f*d)/2,g=(e.dimensions.height-m*u)/2,y=ce(t.cellPadding??.12,0,.8),x=Math.max(1,.5*Math.min(f,m)*(1-y)),b=t.sizeAccessor?l.map(e=>Number(fe(e.datum,t.sizeAccessor))):[],w=t.sizeDomain??ue(b),M=t.sizeRange??[.36,1],v=ce(Math.min(M[0],M[1]),.05,1),k=ce(Math.max(M[0],M[1]),v,1),$=l.map((r,n)=>{let o={...r.datum,gridRow:r.row,gridColumn:r.column},i=(fe(o,t.idAccessor,["id","key","name"])??"grid-"+n)+"",a=(fe(o,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",l=Math.max(1,t.maxLabelLength??4),u=a.length>l?a.slice(0,l):a,d=fe(o,t.categoryAccessor),h=null==d?void 0:d+"",y=fe(o,t.fillAccessor),b=null!=y?y+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",M=t.sizeAccessor?Number(fe(o,t.sizeAccessor)):NaN,$=t.sizeAccessor&&Number.isFinite(M)?Math.sqrt(ce(de(M,w),0,1)):1,A=x*(v+$*(k-v)),S="function"==typeof t.markStyle?t.markStyle(o,n):t.markStyle;return{datum:o,id:i,label:u,category:h,row:r.row,column:r.column,x:p+(r.column-c[0]+.5)*f,y:g+(r.row-s[0]+.5)*m,radius:A,style:{fill:b,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...S}}}),A=t.shape??"circle";return{nodes:$.map(e=>"circle"===A?{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"===A?ye(e.x,e.y,e.radius):ge(e.x,e.y,e.radius),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===A?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}),overlays:!1===t.showLabels?null:/* @__PURE__ */Pl(Me,{marks:$,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??ce(.23*Math.min(f,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}}};import{geoBounds as Ol,geoContains as Wl}from"d3-geo";import{jsx as Dl}from"react/jsx-runtime";var ql=/* @__PURE__ */new WeakMap,Bl=/* @__PURE__ */new WeakMap,Vl=/* @__PURE__ */new WeakMap,Gl=1,Hl=e=>{let t=Be(e),r=e.config,n=r.shape??"circle",o=Math.max(.5,ke(r.dotRadius)??t.cellSize*ve(r.radiusRatio??.24,.05,.5)),i=r.gridOrigin?.[0]??0,a=r.gridOrigin?.[1]??0;return{nodes:t.dots.map((l,s)=>{let c=i+(l.gridColumn+.5)*t.cellSize,u=a+(l.gridRow+.5)*t.cellSize,d=$e(l,r.categoryAccessor),h=$e(l,r.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof r.markStyle?r.markStyle(l,s):r.markStyle},m=`dot-${l.gridRow}-${l.gridColumn}`;return"circle"===n?{type:"point",x:c,y:u,r:o,style:f,datum:l,interactive:!1,pointId:m,_transitionKey:m}:{type:"geoarea",pathData:"hexagon"===n?He(c,u,o):Ge(c,u,o),centroid:[c,u],bounds:[[c-o,u-o],[c+o,u+o]],screenArea:"hexagon"===n?3*Math.sqrt(3)*o*o/2:(2*o)**2,style:f,datum:l,group:l.featureId,interactive:!1}}),overlays:r.showOutline?/* @__PURE__ */Dl("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,n)=>{let o=e.scales.geoPath(t);return o?/* @__PURE__ */Dl("path",{d:o,fill:"none",stroke:r.outlineStyle?.stroke??"currentColor",strokeOpacity:r.outlineStyle?.opacity??r.outlineStyle?.fillOpacity??.22,strokeWidth:r.outlineStyle?.strokeWidth??.7,strokeDasharray:r.outlineStyle?.strokeDasharray,strokeLinecap:r.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},Se(t,n)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Yl=e=>{let t=e.config,r=t.nodeWidth??80,n=t.nodeHeight??30,o=t.orientation??"vertical",i=t.edgeCurve??"curved",a=!1!==t.showLabels,l=t.labelAccessor??"id",s="function"==typeof l?l:e=>ba(e,l,e.id??"")+"",c=/* @__PURE__ */new Map,u=[],d=[],h=e=>{let 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)??r,h:("number"==typeof t.height?t.height:e.height)??n}};for(let r of e.nodes){let{x:n,y:o,w:i,h:l}=h(r);null==n||null==o||(c.set(r.id,{x:n,y:o,w:i,h:l}),u.push({type:"rect",x:n-i/2,y:o-l/2,w:i,h:l,style:{fill:t.nodeFill??e.resolveColor(r.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:r,id:r.id,label:s(r)+""}),a&&d.push({x:n,y:o,text:s(r)+"",anchor:"middle",baseline:"middle",fontSize:11}))}let f=[];for(let t of e.edges){let r="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),a=c.get(r);if(!n||!a)continue;let l="vertical"===o?{x:n.x,y:n.y+n.h/2}:{x:n.x+n.w/2,y:n.y},s="vertical"===o?{x:a.x,y:a.y-a.h/2}:{x:a.x-a.w/2,y:a.y};if("line"===i)f.push({type:"line",x1:l.x,y1:l.y,x2:s.x,y2:s.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{let r=(l.y+s.y)/2,n=(l.x+s.x)/2;f.push({type:"curved",pathD:"vertical"===o?`M${l.x},${l.y} C${l.x},${r} ${s.x},${r} ${s.x},${s.y}`:`M${l.x},${l.y} C${n},${l.y} ${n},${s.y} ${s.x},${s.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:f,labels:d}},_l=e=>{let t=e.config,r=t.nodeWidth??100,n=t.nodeHeight??36,o=t.edgeStyle??"polyline",i=!1!==t.showLabels,a=t.labelAccessor??"label",l="function"==typeof a?a:e=>ba(e,a,e.id??"")+"",s=/* @__PURE__ */new Map,c=[],u=[],d=e=>{let 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)??r,h:("number"==typeof t.height?t.height:e.height)??n}};for(let r of e.nodes){let{x:n,y:o,w:a,h:h}=d(r);null==n||null==o||(s.set(r.id,{x:n,y:o,w:a,h:h}),c.push({type:"rect",x:n-a/2,y:o-h/2,w:a,h:h,style:{fill:t.nodeFill??e.resolveColor(r.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:r,id:r.id,label:l(r)+""}),i&&u.push({x:n,y:o,text:l(r)+"",anchor:"middle",baseline:"middle",fontSize:11}))}let h=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,f=[];for(let t of e.edges){let e="string"==typeof t.target?t.target:t.target.id,r=s.get("string"==typeof t.source?t.source:t.source.id),n=s.get(e);if(!r||!n)continue;let i=t.data??{},a=Array.isArray(i.points)?i.points:t.points;if(a&&a.length>=2)if("smooth"!==o||3>a.length){let e="M"+a.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${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}`;let r=a[a.length-1];e+=` T${r.x},${r.y}`,f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else f.push({type:"line",x1:r.x,y1:r.y,x2:n.x,y2:n.y,style:{stroke:h,strokeWidth:1},datum:t})}return{sceneNodes:c,sceneEdges:f,labels:u}};import{createElement as Xl}from"react";var Kl=e=>{let t=e.config??{},r=t.mode??"primary",n=t.dimOpacity??.14,o=(t,r=e.selection)=>r?.isActive&&!r.predicate(t)?n:1,i=e.nodes.map(e=>({id:e.id,data:Ma(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),a=e.edges.map(e=>({source:_e(e.source),target:_e(e.target),data:Ma(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),l=ha(i,a,e.dimensions.plot,t),s="source-rooted"===t.lineMode?Qe(i,a,t,e.resolveColor):void 0,c=Je(a,t,s),u=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),d=/* @__PURE__ */new Map;if(s)for(let[e,t]of s.byNode)for(let r of t)u.get(e)?.add(r.id),r.color&&d.set(r.id,r.color);let h=Math.max(1,t.lineWidth??("primary"===r?6:"compact"===r?3.5:2)),f=Math.max(0,t.lineGap??("primary"===r?2:"compact"===r?1:.5)),m=/* @__PURE__ */new Map,p=[];for(let r of c){let n=l.positions.get(r.source),i=l.positions.get(r.target);if(!n||!i)continue;let a=tt(r,t),s=(a.length-1)/2*(h+f)+h/2;for(let e of[r.source,r.target])m.set(e,Math.max(m.get(e)??0,s));a.forEach((s,c)=>{u.get(r.source)?.add(s.descriptor.id),u.get(r.target)?.add(s.descriptor.id);let m=rt(s.edge,l,t,s.edge.source!==r.source),g=m?[n,...m,i]:fa(n,i),y=ma(g,(c-(a.length-1)/2)*(h+f)),x=nt(s.edge,s.descriptor),b=Ze(s.descriptor,s.edge,t,e.resolveColor);d.has(s.descriptor.id)||d.set(s.descriptor.id,b),p.push({type:"curved",id:`${r.key}:${s.descriptor.id}`,label:`${s.descriptor.label??s.descriptor.id}: ${s.edge.source} to ${s.edge.target}`,pathD:Oi(y,t.cornerRadius??10),style:{fill:"none",stroke:b,strokeWidth:h,strokeLinecap:"round",opacity:o(x)},datum:x,accessibleDatum:x,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}}})})}let g=/* @__PURE__ */new Map,y=[],x=[],b=e=>(Ye(e,t)||e.id)+"";if("minimap"===r){let r=/* @__PURE__ */new Map;for(let e of i){let t=l.positions.get(e.id);if(!t)continue;let n=`${t.x}\0${t.y}`,o=r.get(n);o||(o={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},r.set(n,o)),o.nodes.push(e);for(let t of u.get(e.id)??[])o.lineIds.add(t);o.bundleRadius=Math.max(o.bundleRadius,m.get(e.id)??0)}let n=[...r.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(let r of n){let n=et(r.lineIds,t),i=n.length>1||r.nodes.length>1||r.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),a=i?t.interchangeRadius??Math.max(5,r.bundleRadius):t.stationRadius??Math.max(3.5,r.bundleRadius);for(let e of r.nodes)g.set(e.id,a);let l=r.nodes.map(b).join(" / "),s=r.nodes.map(e=>e.id).join("--"),c=1===r.nodes.length?r.nodes[0].data:Aa(e=>{e("id",s),e("label",l),e("stationIds",r.nodes.map(e=>e.id)),e("stations",r.nodes.map(e=>e.data)),e("lineIds",n),e("interchange",i)}),u={label:`${l}${i?", interchange":""}`,tableFields:{station:l,lines:n.join(", ")}};n.length>1?(n.forEach((t,i)=>{let l={type:"arc",cx:r.x,cy:r.y,innerR:0,outerR:a,startAngle:-Math.PI/2+i/n.length*Math.PI*2,endAngle:-Math.PI/2+(i+1)/n.length*Math.PI*2,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:o(c)},datum:null,id:`${s}:${t}`};y.push(l)}),y.push({type:"circle",cx:r.x,cy:r.y,r:a,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:o(c)},datum:c,accessibleDatum:c,accessibility:u,id:s,label:l})):y.push({type:"circle",cx:r.x,cy:r.y,r:a,style:{fill:(n[0]&&d.get(n[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:o(c)},datum:c,accessibleDatum:c,accessibility:u,id:s,label:l})}}else for(let e of i){let n=l.positions.get(e.id);if(!n)continue;let i=et(u.get(e.id)??[],t),a=i.length>1||!0===e.data.interchange||!0===e.data.transfer,s=a?t.interchangeRadius??Math.max("primary"===r?7:5,m.get(e.id)??0):t.stationRadius??("primary"===r?4:2.75);g.set(e.id,s);let c=b(e);if(y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:null!=t.renderStation?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:a?"primary"===r?3:2:1.5,opacity:o(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${c}${a?", interchange":""}`,tableFields:{station:c,lines:i.join(", ")}},id:e.id,label:c}),t.renderStation){let l=t.renderStation({station:e.data,x:n.x,y:n.y,radius:s,lineIds:i,interchange:a,mode:r});null!=l&&x.push(Xl("g",{key:e.id,opacity:o(e.data),style:{pointerEvents:"none"}},l))}}let w=x.length>0?Xl("g",{className:"transit-diagram-stations"},...x):void 0,M={sceneEdges:p,sceneNodes:y,overlays:w,labels:it(i,l.positions,u,g,e.dimensions.plot,"primary"===r?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===r)return M;let v=(e,t)=>({opacity:o(e.datum,t)});return{...M,restyle:v,restyleEdge:v}};import{jsx as Ul,jsxs as Ql}from"react/jsx-runtime";import{jsx as Zl,jsxs as Jl}from"react/jsx-runtime";var es={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},ts={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},rs=e=>{let t=e.config||{},r=e.dimensions.plot,n=t.layerAccessor??"x",o=t.rowAccessor??"y",i=t.partitionAccessor??"partition",a=t.semanticAccessor??"semantic",l=t.labelAccessor??"label",s=t.storesAccessor??"stores",c=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...es,...t.partitionColors},h={...ts,...t.edgeColors},f=t.accentColor??"var(--semiotic-focus, #ffcc33)",m=t.borderColor??"var(--semiotic-border, #555)",p=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,v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0,r=/* @__PURE__ */new Map;for(let o of e.nodes){let e=Math.round(Number(ba(o,n,0)));t=Math.max(t,e),r.set(e,(r.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...r.values())}let $=r.width/Math.max(1,v),A=r.height/Math.max(1,k),S=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),I=Math.min(t.nodeHeight??54,Math.max(8,A-(t.minGapY??18))),C=t.lod&&"auto"!==t.lod?t.lod:16>S?"dot":48>S?"icon":108>S?"compact":"full";if("dot"===C){let e=Math.min(S,I,11);S=e,I=e}let N=Math.max(1,r.width-S),F=Math.max(1,r.height-I),E=Math.max(1,k-1),z=e=>r.x+S/2+(v>1?e/(v-1):.5)*N,R=e=>r.y+I/2+(e+E/2)/E*F,L=t.reachableIds?new Set(t.reachableIds):null,T=t.selectedId??null,P=e.selection,j=/* @__PURE__ */new Map,O=/* @__PURE__ */new Map,W=[],D=null==M?null:/* @__PURE__ */new Map,q=[];for(let t of e.nodes){let e=t.id,r=Number(ba(t,n,0)),c=Number(ba(t,o,0)),u=ba(t,i,"processor")+"",h=ba(t,a,"processor")+"",g=ba(t,l,e)+"",y=ht(ba(t,s,[])),x=t.data??t,b=z(r),w=R(c);j.set(e,{cx:b,cy:w});let v=L?L.has(e):null,k=P?.isActive?P.predicate(x):null,$=null!==v?!v:null!==k&&!k;O.set(e,$);let A=null!=T&&e===T,N=$&&!A?p:1,F=Object.prototype.hasOwnProperty.call(d,u)?d[u]:d.unknown;if("dot"===C?W.push({type:"circle",cx:b,cy:w,r:S/2,style:{fill:F,opacity:N,stroke:A?f:"transparent",strokeWidth:A?2:0},datum:t,id:e,label:g}):(W.push({type:"rect",x:b-S/2,y:w-I/2,w:S,h:I,style:{fill:F,opacity:N,stroke:A?f:m,strokeWidth:A?3:1},datum:t,id:e,label:g}),q.push({id:e,cx:b,cy:w,partition:u,semantic:h,label:g,stores:y,opacity:N,selected:A,node:x})),D&&null!=M){let r=ba(t,M,null);if(null!=r){let t=r+"",n=D.get(t)??[];n.push({id:e,x:b-S/2,y:w-I/2,w:S,h:I}),D.set(t,n)}}}let B=[];for(let t of e.edges){let e="string"==typeof t.source?t.source:t.source.id,r="string"==typeof t.target?t.target:t.target.id,n=j.get(e),o=j.get(r);if(!n||!o)continue;let i,a=!!ba(t,c,!1),l=ba(t,u,"internal")+"",s=O.get(e)||O.get(r)?Math.min(g,1.4*p):g,d=a?h.back:Object.prototype.hasOwnProperty.call(h,l)?h[l]:h.internal;if(a){let e=n.cx,t=n.cy+I/2,r=o.cx,a=o.cy+I/2,l=Math.max(48,.28*Math.abs(e-r))+I;i=`M${e},${t} C${e},${t+l} ${r},${a+l} ${r},${a}`}else{let e=n.cx+S/2,t=n.cy,r=o.cx-S/2,a=o.cy,l=(e+r)/2;i=`M${e},${t} C${l},${t} ${l},${a} ${r},${a}`}let f={type:"curved",pathD:i,style:{stroke:d,strokeWidth:a?x:y,fill:"none",opacity:s,...a?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};B.push(f)}let V=0===q.length?null:/* @__PURE__ */Zl("g",{className:"lineage-dag-glyphs",children:q.map(e=>mt(e,{w:S,h:I,lod:C,partColors:d,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))}),G=D&&D.size>0?dt(D,{colors:t.hullColors,padding:null==t.hullPadding?16:Ga(t.hullPadding),radius:null==t.hullRadius?12:Ga(t.hullRadius),fillOpacity:ft(t.hullFillOpacity,.08),strokeOpacity:ft(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:O,selectedId:T,dimOpacity:p}):null;return G?{sceneNodes:W,sceneEdges:B,backgrounds:G,overlays:V}:{sceneNodes:W,sceneEdges:B,overlays:V}};import{jsx as ns,jsxs as os}from"react/jsx-runtime";var is={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},as=e=>{let t=e.config||{},r=e.dimensions.plot,n=t.direction??"TD",o="LR"===n||"RL"===n,i="BT"===n||"RL"===n,a=t.layerAccessor??"layer",l=t.rowAccessor??"row",s=t.labelAccessor??"label",c=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)",m=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",p=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};let g=/* @__PURE__ */new Map,y=0;for(let t of e.nodes){let e=Math.round(Number(ba(t,a,0)));y=Math.max(y,e);let r=g.get(e)||[];r.push(t),g.set(e,r)}let x=y+1,b=1;for(let e of g.values())e.sort((e,t)=>Number(ba(e,l,0))-Number(ba(t,l,0))),b=Math.max(b,e.length);let w=o?r.width:r.height,M=o?r.height:r.width,v=w/x,k=M/(b+1),$=Math.max(44,Math.min(t.nodeWidth??150,o?v-36:.92*k)),A=Math.max(26,Math.min(t.nodeHeight??46,o?.7*k:.5*v)),S=(o?$:A)/2+6,I=Math.max(1,w-2*S),C=e=>(o?r.x:r.y)+S+(x>1?(i?x-1-e:e)/(x-1)*I:I/2),N=(e,t)=>(o?r.y:r.x)+(e+1)/(t+1)*M,F=/* @__PURE__ */new Map,E=[],z=[];for(let[e,t]of g)t.forEach((r,n)=>{let i=C(e),a=N(n,t.length),l=o?i:a,u=o?a:i,m=ba(r,c,"rect")+"",g=ba(r,s,r.id)+"";F.set(r.id,{cx:l,cy:u,shape:m}),E.push({type:"rect",x:l-$/2,y:u-A/2,w:$,h:A,style:{fill:"transparent",stroke:"transparent"},datum:{id:r.id,name:g,type:is[m]??"process",shape:m},id:r.id,label:g}),z.push(
|
|
60
|
+
return Object.create(null)}function Bn(e,t){let r=/* @__PURE__ */new Map;for(let t of e)r.set(t.id,/* @__PURE__ */new Set);for(let e of t)r.has(e.source)||r.set(e.source,/* @__PURE__ */new Set),r.has(e.target)||r.set(e.target,/* @__PURE__ */new Set),r.get(e.source).add(e.target),r.get(e.target).add(e.source);return r}function Vn(e,t){let r={};for(let t of e)Dn(r,t.id,0);for(let e of t)Dn(r,e.source,(Wn(r,e.source)??0)+1),Dn(r,e.target,(Wn(r,e.target)??0)+1);return r}function Gn(e,t){let r={};Dn(r,t,0);let n=[t],o=0;for(;n.length>o;){let t=n[o];o+=1;for(let o of e.get(t)||[])On(r,o)||(Dn(r,o,r[t]+1),n.push(o))}return r}function Hn(e,t,r,n){if(r===n)return r?[r]:[];let o=Bn(e,t),i=qn();i[r]=null;let a=[r],l=0;for(;a.length>l;){let e=a[l];if(l+=1,e===n)break;for(let t of o.get(e)||[])On(i,t)||(i[t]=e,a.push(t))}if(!On(i,n))return[];let s=[],c=n;for(;null!=c;)s.unshift(c),c=i[c];return s}function Yn(e,t,r,n=1){let o=Bn(e,t);if(!o.has(r))/* @__PURE__ */return new Set;let i=Gn(o,r),a=/* @__PURE__ */new Set;for(let e of Object.keys(i))n>=i[e]&&a.add(e);return a}function _n(e,t){let r=Bn(e,t),n={};for(let t of e)Dn(n,t.id,0);for(let t of e.map(e=>e.id)){let o=[],i=qn(),a=qn(),l=qn();for(let t of e)i[t.id]=[],a[t.id]=0,l[t.id]=-1;a[t]=1,l[t]=0;let s=[t],c=0;for(;s.length>c;){let e=s[c];c+=1,o.push(e);for(let t of r.get(e)||[])0>l[t]&&(l[t]=l[e]+1,s.push(t)),l[t]===l[e]+1&&(a[t]+=a[e],i[t].push(e))}let u=qn();for(let t of e)u[t.id]=0;for(;o.length;){let e=o.pop();for(let t of i[e])u[t]+=a[t]/a[e]*(1+u[e]);e!==t&&Dn(n,e,(Wn(n,e)??0)+u[e])}}for(let e of Object.keys(n))Dn(n,e,n[e]/2);return n}function Xn(e,t){let r=Bn(e,t),n={};for(let t of e){let e=Gn(r,t.id),o=0,i=0;for(let t of Object.keys(e))o+=e[t],i+=1;Dn(n,t.id,o>0?(i-1)/o:0)}return n}function Kn(e,t){let r=Bn(e,t),n={};for(let t of e){let e=[...r.get(t.id)||[]],o=e.length;if(2>o){Dn(n,t.id,0);continue}let i=0;for(let t=0;e.length>t;t+=1)for(let n=t+1;e.length>n;n+=1)r.get(e[t])?.has(e[n])&&(i+=1);Dn(n,t.id,2*i/(o*(o-1)))}return n}function Un(e){let t=0;for(let r of Object.keys(e))e[r]>t&&(t=e[r]);let r={};for(let n of Object.keys(e))Dn(r,n,t>0?e[n]/t:0);return r}function Qn(e,t,r,n={}){let o=Bn(e,t),i=qn();for(let t of e)i[t.id]=Gn(o,t.id);let a=n.minHops??4,l=n.startThreshold??.08,s=n.maxThreshold??.2,c=/* @__PURE__ */new Set,u=0;for(;0===c.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let n=t+1;e.length>n;n+=1){let o=e[t].id,s=e[n].id,u=Wn(r,o),d=Wn(r,s);if(!u||!d)continue;let h=u.x-d.x,f=u.y-d.y;(void 0===i[o][s]?1/0:i[o][s])>=a&&l>Math.sqrt(h*h+f*f)&&(c.add(o),c.add(s))}0===c.size&&(l+=.02,l>s&&(l=n.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:c,threshold:l,minHops:a}}function Zn(e){throw Error("Cannot resolve module worker asset: "+e)}function Jn(e){if("u">typeof DOMException)return new DOMException(e+" aborted","AbortError");let t=Error(e+" aborted");return t.name="AbortError",t}function eo(e){let t=Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function to(e,t,r,n,o=4e4){return"sync"!==e&&("worker"===e||n*(t+r)>=o)}function ro(){return"u">typeof window&&"u">typeof Worker}function no(){return"string"==typeof import.meta.url&&import.meta.url?new Worker(new URL("./forceLayoutWorker.js",import.meta.url),{type:"module",name:"semiotic-force-layout"}):new Worker(Zn("forceLayoutWorker.js"),{type:"module",name:"semiotic-force-layout"})}function oo(e,t){return ro()?Qs.get().request(e,t):Promise.reject(Error("Web Workers are unavailable"))}async function io(e,t,r={}){let{execution:n="auto",signal:o,workerThreshold:i,nodeRadius:a,...l}=r,c=l.iterations??260;if(!ro()||!to(n,e.length,t.length,c,i))return s(e,t,{...l,nodeRadius:a});let u={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:l,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{return(await oo(u,o)).positions}catch(r){if("AbortError"===r?.name)throw r;return s(e,t,{...l,nodeRadius:a})}}function ao(e,t,r){return Math.max(t,Math.min(r,e))}function lo(e,t,r={}){let n=r.random??Math.random,o=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=ao(r.along??.5,.05,.95),a=r.jitterX??0,l=r.padY??20,s=o.x0+(o.x1-o.x0)*i+(2*n()-1)*a,c=Math.min(1,o.width/2),u=ao(s,o.x0+c,o.x1-c),d=e.boundaryY(u,"top")+l,h=e.boundaryY(u,"bottom")-l;return{x:u,y:h>d?d+n()*Math.max(1,h-d):e.midY}}function so(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 co(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function uo(e,t){let r=e;for(let e of t.split(".")){if(null==r||"object"!=typeof r||!Object.prototype.hasOwnProperty.call(r,e))return;r=r[e]}return r}function ho(e,t,r,n,o){return"function"==typeof n?n(e,t,r):uo(e,n??o)}function fo(e){let t=Number(e.toFixed(12));return Object.is(t,-0)?0:t}function mo(e){let t=(e??Zs).map(e=>{let t=co(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return fo(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function po(e){if(Array.isArray(e)){if(e.length>Js)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Js} points`);return Array.from(new Set(e.map(co).filter(e=>null!=e).map(fo))).sort((e,t)=>e-t)}let t=e,r=co(t.start),n=co(t.end),o=co(t.step);if(null==r||null==n||null==o||0>=o||r>n)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");let i=Math.floor((n-r)/o)+1;if(i>Js)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Js} points`);let a=[],l=1e-10*Math.max(1,Math.abs(n),Math.abs(r));for(let e=0;i>e;e+=1){let t=r+e*o;if(t>n+l)break;a.push(fo(Math.min(t,n)))}if((!a.length||Math.abs(a[a.length-1]-n)>l)&&a.push(fo(n)),a.length>Js)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Js} points`);return Array.from(new Set(a)).sort((e,t)=>e-t)}function go(e,t,r,n){let o=e.flatMap((e,o)=>{let i=co(ho(e,o,t,r,"time")),a=co(ho(e,o,t,n,"value"));return null==i||null==a?[]:[{time:fo(i),value:a,index:o}]});o.sort((e,t)=>e.time-t.time||e.index-t.index);let i=[];for(let e of o){let t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function yo(e,t){let r=0,n=e.length;for(;n>r;){let o=r+n>>>1;t>e[o].time?r=o+1:n=o}return r}function xo(e,t,r,n){if(!e.length)return null;let o=e[0],i=e[e.length-1];if(o.time>t)return"clamp"===n?o.value:null;if(t>i.time)return"clamp"===n?i.value:null;let a=yo(e,t),l=e[a];if(l?.time===t)return l.value;let s=e[Math.max(0,a-1)];return"step"!==r&&l&&l.time!==s.time?s.value+(t-s.time)/(l.time-s.time)*(l.value-s.value):s.value}function bo(e,t){if(1===e.length)return e[0];let r=(e.length-1)*t,n=Math.floor(r),o=Math.ceil(r);return n===o?e[n]:e[n]+(e[o]-e[n])*(r-n)}function wo(e){let t=e.interpolation??"step",r=e.outsideDomain??"omit",n=mo(e.quantiles),o=po(e.sampleAt),i=e.runs.map(t=>go(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:o.map(e=>{let o=i.map(n=>xo(n,e,t,r)).filter(e=>null!=e).sort((e,t)=>e-t),a={};for(let e of n)a[e]=o.length?bo(o,e):null;return{time:e,count:o.length,min:o.length?o[0]:null,max:o.length?o[o.length-1]:null,median:o.length?bo(o,.5):null,quantiles:a}}),quantiles:n,interpolation:t,outsideDomain:r,runCount:e.runs.length}}function Mo(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function vo(e,t){if("min"===t||"median"===t||"max"===t)return e[t];let r=co(t);if(null==r||0>r||r>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);let n=fo(r);if(!Object.prototype.hasOwnProperty.call(e.quantiles,n))throw Error(`comparePhysicsTrace could not find quantile ${n} in the reference envelope`);return e.quantiles[n]??null}function ko(e,t,r){return t>e?"below":e>r?"above":"inside"}function $o(e,t){let r=Math.max(0,t.time-e.time);if(0>=r||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};let n=e.value-e.lower,o=t.value-t.lower,i=e.value-e.upper,a=t.value-t.upper,l=[0,1];for(let[e,t]of[[n,o],[i,a]])(0>e&&t>0||e>0&&0>t)&&l.push(-e/(t-e));l.sort((e,t)=>e-t);let s=0,c=0,u=0;for(let n=0;l.length-1>n;n+=1){let o=l[n],i=l[n+1];if(o>=i)continue;let a=(o+i)/2,d=(i-o)*r,h=ko(e.value+(t.value-e.value)*a,e.lower+(t.lower-e.lower)*a,e.upper+(t.upper-e.upper)*a);"below"===h?s+=d:"above"===h?u+=d:c+=d}return{below:s,inside:c,above:u,observed:r}}function Ao(e,t,r={}){let n=r.interpolation??t.interpolation,o=r.outsideDomain??t.outsideDomain,i=go(e,r.traceId??"trace",r.timeAccessor,r.valueAccessor),a=r.lower??Mo(t,"lower"),l=r.upper??Mo(t,"upper"),s=t.points.map(e=>{let t=xo(i,e.time,n,o),r=vo(e,a),s=vo(e,l);if(null!=r&&null!=s&&r>s)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:r,upper:s,status:null==t||null==r||null==s?"unobserved":ko(t,r,s)}}),c=0,u=0,d=0,h=0,f=null,m=0,p=null;for(let e of s){if("below"===e.status?c+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;let t=Math.max(0,e.value-e.upper),r=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),r>m&&(m=r,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;s.length-1>e;e+=1){let t=s[e],r=s[e+1],o=Math.max(0,r.time-t.time);if(o>0){if("linear"===n){let e=$o(t,r);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=o,"below"===t.status?g+=o:"above"===t.status?x+=o:y+=o)}}let w=s[0]?.time,M=s[s.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:s,sampleCount:s.length,observedSamples:c+u+d,belowSamples:c,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 So(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Io(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Co(e){return!!Io(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&Io(e.visitsByStage)&&Io(e.firstEnteredAt)&&Io(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function No(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function Fo(e,t){let r=t.stageId?.(e);if(r)return r;let n=e.region.metadata;if(n&&"object"==typeof n&&Object.prototype.hasOwnProperty.call(n,"stageId")){let e=n.stageId;if("string"==typeof e)return e}return e.region.id}function Eo(e){let t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,No(e)]))}}function zo(e,t,r={}){if("region-enter"!==t.type)return e;let n=Fo(t,r),o=e.stages.findIndex(e=>e.id===n);if(0>o)return e;let i=r.entityId?.(t)??t.bodyId;if(!i)return e;let a=So(e.entities,i),l=Co(a)?a:No(i),s=l.currentStageId?e.stages.findIndex(e=>e.id===l.currentStageId):-1,c=!l.visitedStageIds.includes(n),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=So(l.visitsByStage,n),f="number"==typeof h&&Number.isFinite(h)?h:0,m={...l,currentStageId:n,furthestStageId:o>l.furthestStageIndex?n:l.furthestStageId,furthestStageIndex:Math.max(l.furthestStageIndex,o),visitedStageIds:c?[...l.visitedStageIds,n]:l.visitedStageIds,visitsByStage:{...l.visitsByStage,[n]:f+1},firstEnteredAt:c?{...l.firstEnteredAt,[n]:d}:l.firstEnteredAt,lastEnteredAt:{...l.lastEnteredAt,[n]:d},regressionCount:s>=0&&s>o?l.regressionCount+1:l.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:m}}}function Ro(e){let t=e.bodyIds.map(t=>{let r=So(e.entities,t);return Co(r)?r:No(t)}),r=t.length,n=r;return e.stages.map((e,o)=>{let i=t.filter(e=>e.furthestStageIndex>=o).length,a=t.filter(t=>t.visitedStageIds.includes(e.id)).length,l=t.reduce((t,r)=>{let n=So(r.visitsByStage,e.id);return t+("number"==typeof n&&Number.isFinite(n)?n:0)},0),s={id:e.id,label:e.label??e.id,reached:i,entered:a,total:r,conversion:r>0?i/r:0,fromPrevious:n>0?i/n:0,dropoff:Math.max(0,n-i),visits:l,repeatVisits:Math.max(0,l-a)};return n=i,s})}function Lo(e,t){if("function"==typeof t){let r=t(e);return Number.isFinite(r)&&r>0?Number(r):1}let r=e.datum;if(t&&r&&"object"==typeof r){let e=Number(r[t]);if(Number.isFinite(e)&&e>0)return e}let n=Number(r?.work??r?.reviewWork??r?.value);return Number.isFinite(n)&&n>0?n:1}function To(e,t){if("function"==typeof t){let r=t(e);if(null!=r&&(r+"").length>0)return r+""}else if(t){let r=va(e.datum,t),n=va(e,t),o=r??n;if(null!=o&&(o+"").length>0)return o+""}return e.id}function Po(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];let r=Math.max(0,Math.min(1,t))*(e.length-1),n=Math.floor(r);return e[n]+(e[Math.ceil(r)]-e[n])*(r-n)}function jo(e){function t(e,t){let r=t(e);return!!r&&r.activeRegionIds.includes(f)}function r(){X+=1}function n(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:f,work:e.total,queuedAt:e.queuedAt}}function o(t,r,o){let i=n(r);e.onQueued?.(t,i),o.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:f,work:r.total,jobId:r.jobId,visitId:r.visitId,visit:r.visit,queuedAt:r.queuedAt,queueDepth:v.size})}function i(e,t,n,i){let a={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,a),C.delete(e.id),I.set(e.id,t.jobId),O+=1,W+=t.work,r(),o(e,a,n),a}function a(e){if(v.size>=x||0===k.size)return;let t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);for(let r of t){if(v.size>=x)break;let t=S.get(r.jobId);t&&$.has(r.jobId)?(k.delete(r.jobId),C.delete(r.bodyId),i(t,r,e,r.sequence)):k.delete(r.jobId)}}function l(){let e=0;for(let t of v.values())e+=t.remaining;return e}function s(){let e=0;for(let t of k.values())e+=t.work;return e}function c(){H=Math.max(H,v.size),Y=Math.max(Y,l())}function u(){let e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);E=new Map(e.map((e,t)=>[e.bodyId,t]));let t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);z=new Map(t.map((e,t)=>[e.bodyId,t])),R=e.length}function d(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&N.push(e);let t=T-b;for(;N.length>0&&t>N[0].end;)N.shift()}function h(){let e=T-b,t=Math.max(0,Math.min(b,T-(P??T))),r=0,n=0,o=0,i=0,a=0;for(let t of N){if(e>t.end)continue;r+=t.arrivals,n+=t.arrivalWork,o+=t.completions,i+=t.completedWork;let l=t.end-t.start;a+=l>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/l):t.processedWork}let l=t>0?n/t:0;return{seconds:t,arrivals:r,arrivalWork:n,completions:o,completedWork:i,processedWork:a,arrivalsPerSecond:t>0?r/t:0,throughputPerSecond:t>0?o/t:0,utilization:t>0&&m>0?Math.max(0,Math.min(1,a/(m*t))):0,pressure:m>0?l/m:0}}let f=e.regionId,m=Math.max(0,e.unitsPerSecond),p=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,N=[],F=0,E=/* @__PURE__ */new Map,z=/* @__PURE__ */new Map,R=0,L=0,T=0,P=null,j=0,O=0,W=0,D=0,q=0,B=0,V=0,G=0,H=0,Y=0,_=0,X=0,K=-1,U=!1;return{id:e.id??"capacity-queue:"+f,continuous:!1!==e.continuous,tick:o=>{let l=o.controls.readBodies(),s=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(let r of l){if(s.set(r.id,r),!t(r.id,o.getRegionState)||!$a(r,e.bodyFilter))continue;let n=To(r,e.jobKey),i=h.get(n)??[];i.push(r),h.set(n,i)}let p=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!U){let e=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):p;T=Math.max(0,e-p),U=!0}let g=T,y=g+p;T=y,P=null==P?g:Math.min(P,g);let b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},N=/* @__PURE__ */new Map;for(let[e,t]of h){let r=$.get(e)?.bodyId,n=t.find(e=>e.id===r)??t[0];N.set(e,n),S.set(e,n)}for(let[t,i]of $){if(N.has(t))continue;let a=v.get(t),l=s.get(i.bodyId)??S.get(t);if(a){v.delete(t),I.delete(a.bodyId),V+=1,G+=a.remaining,r();let s={...n(a),abandonedAt:T,remainingWork:a.remaining,queueSeconds:Math.max(0,T-a.queuedAt)};l&&e.onAbandoned?.(l,s),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:l?.datum,x:l?.x,y:l?.y,regionId:f,work:a.total,remainingWork:a.remaining,jobId:t,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:T,queueSeconds:s.queueSeconds,queueDepth:v.size})}k.delete(t),C.delete(i.bodyId),$.delete(t),S.delete(t)}for(let[t,n]of N){if($.has(t))continue;let a=(A.get(t)??0)+1;A.set(t,a);let l=Lo(n,e.unitAccessor),s={bodyId:n.id,jobId:t,visitId:`${f}:${t}:${a}`,visit:a,regionId:f,work:l,queuedAt:T};$.set(t,s),j+=1,b.arrivals+=1,b.arrivalWork+=l;let c=F++;if(x>v.size)i(n,s,o,c);else{let i={...s,blockedAt:T,sequence:c};k.set(t,i),C.set(n.id,t),B+=1,r(),e.onBlocked?.(n,i),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:f,work:l,jobId:t,visitId:s.visitId,visit:a,queuedAt:T,blockedAt:T,queueDepth:v.size,blockedDepth:k.size})}}a(o),c();let E=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence),z=m*p;for(let t of E){if(0>=z)break;let i=Math.min(t.remaining,z);if(t.remaining-=i,z-=i,D+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),I.delete(t.bodyId),L+=1,q+=t.total,b.completions+=1,b.completedWork+=t.total;let a=Math.max(0,T-t.queuedAt);_+=a,r();let l=s.get(t.bodyId);if(!l)continue;o.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);let c={...n(t),completedAt:T,queueSeconds:a};e.onProcessed?.(l,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:l.datum,x:l.x,y:l.y,regionId:f,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:T,queueSeconds:a,queueDepth:v.size})}a(o),c(),u(),d(b);let R=Math.floor(T/w);R!==K&&(K=R,r())},getSnapshot:()=>{let e=l(),t=s(),r=v.size,n=Array.from(v.values()).map(e=>Math.max(0,T-e.queuedAt)).sort((e,t)=>e-t),o=n.reduce((e,t)=>e+t,0);return{regionId:f,queueDepth:r,processedCount:L,unitsPerSecond:m,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+t,blockedDepth:k.size,blockedWork:t,arrivalCount:j,admittedCount:O,admittedWork:W,processedWork:D,completedWork:q,blockedCount:B,abandonedCount:V,abandonedWork:G,peakQueueDepth:H,peakRemainingWork:Y,queueAge:{count:n.length,meanSeconds:n.length>0?o/n.length:0,p50Seconds:Po(n,.5),p95Seconds:Po(n,.95),oldestSeconds:n.at(-1)??0},meanCompletedQueueSeconds:L>0?_/L:0,window:h(),simulatedAt:T,metricRevision:X}},bodyForce:e=>{if("none"===p)return null;let t=I.get(e.body.id),r=C.get(e.body.id),n=t?v.get(t):void 0,o=r?k.get(r):void 0;if(!n&&!o)return null;let i=n?E.get(e.body.id):z.get(e.body.id);if(null==i)return null;let a,l=e.regions;if(l)for(let e=0;l.length>e;e+=1)if(l[e].id===f){let t=l[e].shape;t&&"aabb"===t.type&&(a=t);break}return a?{x:((o?a.x-.44*a.width:a.x-.22*a.width-i*(.15*g))-e.body.x)*y,y:(a.y-(i-((o?k.size:R)-1)/2)*g/Math.max(1,Math.sqrt(o?k.size:R))-e.body.y)*y*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Oo(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Wo(e){if(!e?.length)return null;let t=e.slice(),r=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:r,onTick:(e,r,n)=>{let o={result:e,controls:r,dt:n.dt,elapsed:n.elapsed,getRegionState:n.getRegionState};for(let e of t)e.tick(o)},bodyForce:e=>{let r=null;for(let n of t)n.bodyForce&&(r=Oo(r,n.bodyForce(e)));return r}}}function Do(e){let t=/* @__PURE__ */new Set,r=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:n=>{let o=n.controls.readBodies();for(let i of o)n.getRegionState(i.id)?.activeRegionIds.includes(e.fromRegionId)?t.has(i.id)||(t.add(i.id),n.controls.applyImpulse(i.id,r.x??0,r.y??0),e.onPortal?.(i)):t.delete(i.id)}}}function qo(e){let t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),r=new Map(t.map(e=>[e.bodyId,e])),n=/* @__PURE__ */new Map,o=/* @__PURE__ */new Map,i=e.assignmentForce??.45,a=e.returnForce??.35,l=e.caseAttraction??.08,s=e.assignmentOffset??{x:0,y:0},c=/* @__PURE__ */new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{let r=n.get(e);if(r)return r;let i=t.find(e=>!o.has(e.id));if(!i)return null;let a={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return n.set(e,a),o.set(i.id,a),d+=1,a},release:e=>{let t=n.get(e);return!!t&&(n.delete(e),o.delete(t.resourceId),d+=1,!0)},getAssignment:e=>n.get(e),tick:e=>{u=Math.max(u,e.elapsed),c=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(let[e,t]of n)c.has(e)&&c.has(t.resourceBodyId)||(n.delete(e),o.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-o.size,assigned:o.size,assignments:Array.from(n.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{let t=r.get(e.body.id);if(t){let r=o.get(t.id),n=r?c.get(r.caseBodyId):void 0,l=r?i:a;return{x:((n?n.x+(s.x??0):t.home.x)-e.body.x)*l,y:((n?n.y+(s.y??0):t.home.y)-e.body.y)*l}}let u=n.get(e.body.id);if(!u||0>=l)return null;let d=c.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*l,y:(d.y-e.body.y)*l}:null}}}function Bo(e,t){let r="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):va(e.datum,t.deadlineAccessor)??va(e,t.deadlineAccessor);return Number.isFinite(Number(r))?Math.max(0,Number(r)):0}function Vo(e){function t(t){n.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function r(e){let r=n.get(e);return!(!r||null!=r.completedAt||(t({...r,completedAt:o,state:"unhappy"===r.state?"resolved-unhappy":"resolved"}),0))}let n=/* @__PURE__ */new Map,o=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{let r=n.get(e);return!(!r||null!=r.completedAt||"unhappy"===r.state||(t({...r,state:"protected",protectedAt:o}),0))},complete:r,getCase:e=>n.get(e),tick:i=>{o=Math.max(o,i.elapsed);for(let a of i.controls.readBodies()){if(!$a(a,e.bodyFilter))continue;if(!n.has(a.id)){let r=Bo(a,e);t({bodyId:a.id,openedAt:o,deadlineAt:o+r,state:"waiting"})}let l=n.get(a.id);l&&null==l.completedAt&&(e.completionRegionId&&i.getRegionState(a.id)?.activeRegionIds.includes(e.completionRegionId)?r(a.id):"waiting"===l.state&&o>=l.deadlineAt&&t({...l,state:"unhappy"}))}},getSnapshot:()=>{let e=Array.from(n.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:o,metricRevision:i}}}}function Go(e){function t(t){return e.isOpen?e.isOpen(t):null!=e.opensAt&&t>=e.opensAt}let r=/* @__PURE__ */new Set,n=0,o=0,i=0,a=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:l=>{n=Math.max(n,l.elapsed);let s=a;a=t(n);let c=l.controls.readBodies(),u=new Map(c.map(e=>[e.id,e]));for(let t of c)!l.getRegionState(t.id)?.activeRegionIds.includes(e.regionId)||!$a(t,e.bodyFilter)||!a&&!r.has(t.id)&&(r.add(t.id),i+=1,e.onHeld?.(t));if(a&&!s){for(let t of r){let r=u.get(t);r&&(l.controls.applyImpulse(t,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(r))}r.clear(),i+=1}for(let e of r)u.has(e)||(r.delete(e),i+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:a,blocked:r.size,released:o,simulatedAt:n,metricRevision:i}),bodyForce:t=>{if(a||!r.has(t.body.id))return null;let n=t.regions?.find(t=>t.id===e.regionId)?.shape;if(!n||"aabb"!==n.type)return{x:.8*-t.body.vx,y:.8*-t.body.vy};let o=e.holdForce??.4;return{x:(n.x-t.body.x)*o-.45*t.body.vx,y:(n.y-t.body.y)*o-.45*t.body.vy}}}}function Ho(e){return null==e?{top:tc,right:tc,bottom:tc,left:tc}:"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}}function Yo(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+""}))}function _o(e){let[t,r]=e.size,n=e.flow??ec,o=Ho(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??ic)),a={x:o.left,y:o.top,width:Math.max(1,t-o.left-o.right),height:Math.max(1,r-o.top-o.bottom)},l="down"===n?a.height:a.width,s=l*Math.max(0,e.chargeExtent??rc),c=l*Math.max(0,e.projectionExtent??oc),u=l*Math.max(0,e.destinationExtent??nc),d=Math.max(0,l-s-u-c),h=Yo(e.destinations),f=("down"===n?a.width:a.height)/h.length,m="down"===n?(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,s),g=m(s,d),y=s+d,x=m(y,u),b=m(y+u,c),w=h.map((e,t)=>{let r=t*f,o=f*i,l=(f-o)/2;return"down"===n?{id:e.id,label:e.label,order:t,x:a.x+r+l,y:x.y,width:o,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+r+l,width:x.width,height:o,centerX:x.x+x.width/2,centerY:a.y+(t+.5)*f}});return{width:t,height:r,flow:n,charge:p,apparatus:g,destinations:w,projection:b}}function Xo(e,t){return e.destinations.find(e=>e.id===t)}function Ko(e,t,r){let{charge:n,flow:o}=e,i=Math.max(1,r),a=(t%i+.5)/i;return"down"===o?{x:n.x+n.width*a,y:n.y+n.height/2}:{x:n.x+n.width/2,y:n.y+n.height*a}}function Uo(e,t={}){let r=t.thickness??4,n=t.idPrefix??"stage",{destinations:o,flow:i,width:a,height:l}=e,s=[];if(o.length>0){let t=o[0];if("down"===i){let i=t.y+t.height;s.push({id:n+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:r}});for(let e=1;o.length>e;e+=1){let a=o[e].centerX-(o[e].centerX-o[e-1].centerX)/2;s.push({id:`${n}-divider-${e}`,shape:{type:"segment",x1:a,y1:t.y,x2:a,y2:i,thickness:r}})}}else{let i=t.x+t.width;s.push({id:n+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:r}});for(let e=1;o.length>e;e+=1){let a=o[e].centerY-(o[e].centerY-o[e-1].centerY)/2;s.push({id:`${n}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:a,x2:i,y2:a,thickness:r}})}}}return!1!==t.walls&&s.push({id:n+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:l,thickness:r}},{id:n+"-wall-right",shape:{type:"segment",x1:a-1,y1:0,x2:a-1,y2:l,thickness:r}}),s}function Qo(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 Zo(e){let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Jo(e,t,r,n){let o="function"==typeof e?e(t,r):e;return Number.isFinite(o)?Number(o):n}function ei(e,t,r){return Zo(e[t])??r}function ti(e,t){return"number"==typeof e?e:e?.[t]??0}function ri(e){let t=e.bandwidth??e.scale.bandwidth?.()??0,r=/* @__PURE__ */new Set;for(let n of e.values){let o=e.scale(n);Number.isFinite(o)&&(r.add(Number(o)),r.add(Number(o)+t))}return Array.from(r).sort((e,t)=>e-t)}function ni(e){let{band:t,idPrefix:r,plot:n,projection:o}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:l=4}=t,s=ri(t);if(2>s.length)return[];let c=i?s.length-1:s.length-2,u=[];for(let e=i?0:1;c>=e;e+=1){if(!a&&e>0&&s.length-1>e)continue;let t=s[e];u.push({id:`${r}-wall-${e}`,shape:"x"===o?{type:"aabb",x:t,y:n.y+n.height/2,width:l,height:n.height}:{type:"aabb",x:n.x+n.width/2,y:t,width:n.width,height:l}})}return u}function oi(e){let{plot:t,idPrefix:r="physics-scale",bounds:n={},xBins:o,xBands:i,yBands:a}=e,l=[];if(!1!==n&&l.push(...Ca(t,{idPrefix:r,...n})),o){let{idPrefix:e,yTop:n,yBottom:i,...a}=o;l.push(...Na({...a,idPrefix:e??r+"-xbin",yTop:n??t.y,yBottom:i??t.y+t.height}))}return i&&l.push(...ni({band:i,idPrefix:i.idPrefix??r+"-xband",plot:t,projection:"x"})),a&&l.push(...ni({band:a,idPrefix:a.idPrefix??r+"-yband",plot:t,projection:"y"})),l}function ii(e){let{plot:t,rows:r,columns:n=r+1,pegRadius:o=3,idPrefix:i="galton-peg",yStart:a=t.y+.18*t.height,yEnd:l=t.y+.58*t.height,stagger:s=!0,restitution:c=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(r)),h=Math.max(1,Math.floor(n));if(0===d)return[];let f=d>1?(l-a)/(d-1):0,m=t.width/h,p=[];for(let e=0;d>e;e+=1){let r=s&&e%2==1?m/2:0;for(let n=0;h>n;n+=1){let l=t.x+m*(n+.5)+r;t.x+o>l||l>t.x+t.width-o||p.push({id:`${i}-${e}-${n}`,shape:{type:"aabb",x:l,y:a+e*f,width:2*o,height:2*o},restitution:c,friction:u})}}return p}function ai(e,t={}){let{idPrefix:r="physics-token",radius:n=5,shape:o,mass:i,vx:a,vy:l,spawnAt:s,seed:c=1,jitter:u,datum:d}=t,h=wa(c),f=ti(u,"x"),m=ti(u,"y");return e.map((e,c)=>{let u=Jo(t.x,e,c,ei(e,"x",0)),p=Jo(t.y,e,c,ei(e,"y",0)),g=Jo(n,e,c,5),y="function"==typeof o?o(e,c):o??{type:"circle",radius:g};return{id:`${r}-${e.index??c}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:Jo(a,e,c,0),vy:Jo(l,e,c,0),mass:Jo(i,e,c,1),spawnAt:Jo(s,e,c,void 0),shape:y,datum:d?d(e,c):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;let{spawnAt:t,...r}=e;return r})}function li(e,t={}){let{idPrefix:r="sediment",collider:n=!0,colliderThickness:o=1,restitution:i=.05,friction:a=.2,...l}=t,s=Sa(e,l),c=n?s.filter(e=>e.height>0).map(e=>({id:`${r}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+o/2,width:e.width,height:o},restitution:i,friction:a})):[];return{columns:s,colliders:c}}function si(e,t,r){return Zo("function"==typeof r?r(e,t):e[r]??e.datum?.[r])}function ci(e,t={}){let{timeAccessor:r="arrivalTime",timeScale:n=1,startAt:o=0,rebase:i=!0,sort:a=!0}=t,l=e.map((e,t)=>({spawn:e,time:si(e,t,r)??e.spawnAt??t})),s=l.length?Math.min(...l.map(e=>e.time)):0;return{initialSpawns:l.map(({spawn:e,time:t})=>({...e,spawnAt:o+(i?t-s:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:o,timeAccessor:"spawnAt",timeScale:n}}}function ui(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function di(e,t,r="group"){let n=Vn(e,t),o=e=>"function"==typeof r?r(e):e[r]??0;return e.slice().sort((e,t)=>{let r=o(e),i=o(t);return i>r?-1:r>i?1:(n[t.id]||0)-(n[e.id]||0)}).map(e=>e.id)}function hi(e,t={}){let r=t.baseline??.62,n=t.inset??.06,o={},i=e.length;return e.forEach((e,t)=>{ui(o,e,{x:i>1?n+t/(i-1)*(1-2*n):.5,y:r})}),o}function fi(e,t,r=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*r} ${t.x},${t.y}`}function mi(e,t={}){let r=t.radius??.42,n=t.center?.x??.5,o=t.center?.y??.5,i=t.startAngle??0,a={},l=e.length;return e.forEach((e,t)=>{let s=i+t/l*Math.PI*2-Math.PI/2;ui(a,e,{x:n+Math.cos(s)*r,y:o+Math.sin(s)*r})}),a}function pi(e,t,r={}){let n=(r.order??di(e,t,r.groupAccessor??"group")).slice(),o=new Map(n.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(let e of t){if(!o.has(e.source)||!o.has(e.target)||e.source===e.target)continue;let 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))}let a=[],l=0;for(let[e,t]of i){let[r,n]=e.split("\0"),i=o.get(r),s=o.get(n);t>l&&(l=t),a.push({row:i,col:s,source:r,target:n,value:t}),a.push({row:s,col:i,source:n,target:r,value:t})}return{order:n,cells:a,size:n.length,maxValue:l}}function gi(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function yi(e){if("string"!=typeof e)return;let t=e.trim();return t.length?t:void 0}function xi(e,t){let r=gi(e.note)?e.note:void 0;return t?yi(e.mobileText)||yi(e.shortText)||yi(e.label)||yi(r?.mobileText)||yi(r?.shortText)||yi(r?.label)||yi(r?.title):yi(e.label)||yi(e.mobileText)||yi(e.shortText)||yi(r?.label)||yi(r?.title)}function bi(e,t,r){if(!r)return;let n="function"==typeof r?r(e,t):e[r];return"number"==typeof n&&Number.isFinite(n)?n:void 0}function wi(e,t,r){let n=bi(e,t,r.priorityAccessor);if(void 0!==n)return n;let o=1e3-t,i=((e.emphasis??"")+"").toLowerCase();("primary"===i||"critical"===i)&&(o+=1e4),"secondary"===i&&(o-=1e3),"high"===e.priority&&(o+=5e3),"low"===e.priority&&(o-=1500),"number"==typeof e.priority&&(o+=100*e.priority);let a=gi(e.provenance)?e.provenance:void 0;"number"==typeof a?.confidence&&(o+=100*a.confidence);let l=gi(e.lifecycle)?e.lifecycle:void 0,s=((l?.freshness??"")+"").toLowerCase();return("expired"===s||"stale"===s)&&(o-=3e3),o}function Mi(e,t){if(!t)return e;let r=xi(e,!0);return r&&"string"==typeof e.label?{...e,label:r}:e}function vi(e,t,r,n){let o=xi(e,n);if(!o)return null;let i=yi(e.id)||yi(e.key)||yi(e.pointId)||"annotation-"+(t+1),a=gi(e.provenance)?yi(e.provenance.source)||yi(e.provenance.authorKind):void 0;return{id:i,label:o,shortLabel:yi(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:a,priority:r,annotation:e}}function ki(e,t={}){let r=Array.isArray(e)?e.filter(gi):[],n=t.active??(null==t.width||(t.breakpoint??480)>=t.width),o=t.strategy??"hybrid",i=!1!==t.preferShortText,a=!1!==t.preservePrimary,l=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===o?1:2)),s=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!n||"plot"===o)return{active:n,strategy:o,budget:r.length,visible:i?r.map(e=>Mi(e,i)):r,deferred:[],calloutList:[],hidden:[]};let c=[],u=r.map((e,r)=>({annotation:e,index:r,priority:wi(e,r,t)})).filter(e=>!!Ua(e.annotation)||(c.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(l,s)),p=new Set(m.map(e=>e.index)),g=u.filter(e=>!p.has(e.index)),y=[...c,...m.sort((e,t)=>e.index-t.index).map(e=>Mi(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=>vi(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:n,strategy:o,budget:l,visible:y,deferred:x,calloutList:w,hidden:v}}function $i(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function Ai(e,t){let r=t.targetSize??44,n=[],o=t.standardControls,i=e=>!0===o||"all"===o||o===e||Array.isArray(o)&&o.includes(e);return i("brush")&&n.push("range-inputs","clear-brush"),i("zoom")&&n.push("zoom-buttons","reset-view"),i("legend")&&n.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:r,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:r,...n.length>0&&{alternatives:n}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function Si(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function Ii(e,t){let r=!1!==t.keepAxes,n=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:n,bottom:r?44:12,left:r?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:n,bottom:r?42:14,left:r?44:14}}function Ci(e,t,r,n={}){let o={...r},i={mode:!1===t.mode?void 0:"mobile",...o,margin:Ii(e,t),...n},a=Object.fromEntries(Object.entries(o).filter(([,e])=>void 0!==e)),l=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),s=Ai(e,t),c=$i(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:{...l,mobileInteraction:c,mobileSemantics:s}}],mobileInteraction:c,mobileSemantics:s}}function Ni(e={}){let t=Si(e);return Ci("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 Fi(e={}){let t=Si(e);return Ci("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 Ei(e={}){return Ci("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function zi(e={}){let t=Si(e);return Ci("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 Ri(e={}){let t=Si(e);return Ci("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 Li(e={}){return Ci("geo",e,{showLegend:e.showLegend??!1})}function Ti(e={}){return Ci("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function Pi(e,t={}){switch(e){case"line":return Ni(t);case"area":return Fi(t);case"ordinal":return Ei(t);case"scatter":return zi(t);case"network":return Ri(t);case"geo":return Li(t);case"small-multiple":return Ti(t)}}function ji(e={}){let 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}}import{$ as Oi,A as Wi,Aa as Di,Ba as qi,Ca as Bi,D as Vi,Da as Gi,E as Hi,Ea as Yi,F as _i,Fa as Xi,G as Ki,Ga as Ui,H as Qi,Ha as Zi,I as Ji,J as ea,K as ta,L as ra,M as na,N as oa,O as ia,P as aa,Q as la,R as sa,S as ca,T as ua,U as da,V as ha,W as fa,X as ma,Y as pa,Z as ga,_ as ya,a as xa,aa as ba,ba as wa,c as Ma,ca as va,d as ka,da as $a,e as Aa,ea as Sa,f as Ia,fa as Ca,ga as Na,h as Fa,i as Ea,ia as za,j as Ra,ja as La,k as Ta,ka as Pa,la as ja,m as Oa,ma as Wa,na as Da,o as qa,oa as Ba,pa as Va,qa as Ga,ra as Ha,sa as Ya,ta as _a,ua as Xa,va as Ka,w as Ua,wa as Qa,x as Za,xa as Ja,y as el,ya as tl,z as rl,za as nl}from"./c-EK6XI2U7.min.js";import"./c-3PFVJFBK.min.js";var ol=e=>{let n=e.config,o=n.rows??10,i=n.columns??10,a=n.gutter??2,l=o*i;if(0>=o||0>=i||0>=l)return{nodes:[]};let{plot:s}=e.dimensions;if(0>=s.width||0>=s.height)return{nodes:[]};let c=(s.width-a*(i-1))/i,u=(s.height-a*(o-1))/o;if(0>=c||0>=u)return{nodes:[]};let d=t(n.categoryAccessor)??(()=>"_default"),h=r(n.valueAccessor)??(()=>1),f=/* @__PURE__ */new Map,m=[];for(let t of e.data){let e=d(t)+"",r=Number(h(t)),n=Number.isFinite(r)?Math.max(0,r):0;f.has(e)||m.push(e),f.set(e,(f.get(e)??0)+n)}let p,g=Array.from(f.values()).reduce((e,t)=>e+t,0);if(0>=g)return{nodes:[]};if(n.categoryOrder&&n.categoryOrder.length>0){let e=/* @__PURE__ */new Set,t=[];for(let r of n.categoryOrder)f.has(r)&&!e.has(r)&&(e.add(r),t.push(r));p=[...t,...m.filter(t=>!e.has(t))]}else p=m;if(0===p.length)return{nodes:[]};let y=p.map(e=>({cat:e,exact:(f.get(e)??0)/g*l})).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;l-x>e;e++)y[b[e%b.length].i].count+=1;let w="string"==typeof n.categoryAccessor?n.categoryAccessor:"category",M="string"==typeof n.valueAccessor?n.valueAccessor:"value",v=(e,t,r)=>Ji(n=>{n("category",e),n("value",f.get(e)??0),n("share",(f.get(e)??0)/g),"category"!==w&&n(w,e),"value"!==M&&n(M,f.get(e)??0),n("cells",r),n("_waffleCategory",e),n("_waffleIndex",t)}),k=[],$=0;for(let t of y){let r=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)k.push({type:"rect",x:s.x+$%i*(c+a),y:s.y+(o-1-Math.floor($/i))*(u+a),w:c,h:u,style:{fill:r,stroke:"none"},datum:v(t.cat,$,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),$++}return{nodes:k}};import{forceCenter as il,forceCollide as al,forceLink as ll,forceManyBody as sl,forceSimulation as cl,forceX as ul,forceY as dl}from"d3-force";var hl="#334155",fl="#f8fafc",ml="#cbd5e1",pl={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"}]},gl={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}]},yl={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},xl={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"}]},bl="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",wl={viewBox:[18,40],anchor:[.5,1],parts:[{d:bl,fill:"color",stroke:"color",strokeWidth:1.4}]},Ml={server:pl,chip:gl,bolt:yl,bus:xl,person:wl},vl="var(--semiotic-primary, #4e79a7)",kl="var(--semiotic-border, #d1d5db)",$l=new Set(Ma);import{jsx as Al,jsxs as Sl}from"react/jsx-runtime";var Il={resource:32,city:64},Cl=["#739b58","#83a964","#668d52","#8baa68"],Nl={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},Fl={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"},El=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),zl=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),Rl=e=>{let t=te(e.config.gridSize),r=Math.max(20,e.config.tileWidth??80),n=Math.max(10,e.config.tileHeight??40),o=e.config.terrainColors?.length?e.config.terrainColors:Cl,i=e.dimensions.width/2,a=(e.dimensions.height-t*n)/2+n/2,l=ne(e.points,e.config).map(e=>({...e,x:i+r/2*(e.column-e.row),y:a+(e.column+e.row)*(n/2)}));return{nodes:l.map(t=>{let i=K(e.config.terrainByCell,t.id),a="city"===t.landmark?.kind?"urban":i?.kind??"land",l=i?.fill??_(e.config.terrainPalette,a)??U(a),s=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:Q(a),kind:"terrain",terrainKind:a,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};return{type:"geoarea",pathData:oe(t.x,t.y,r,n),centroid:[t.x,t.y],bounds:[[t.x-r/2,t.y-n/2],[t.x+r/2,t.y+n/2]],screenArea:r*n/2,style:{fill:i||"urban"===a?l:o[t.terrainIndex%o.length],stroke:"ocean"===a?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:s,group:t.landmark?.kind??a,interactive:!0}}),overlays:/* @__PURE__ */Al(ie,{tiles:l,tileWidth:r,tileHeight:n,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??32,citySize:e.config.citySpriteSize??64,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}}},Ll={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"]},Tl={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"}};import{jsx as Pl}from"react/jsx-runtime";var jl=e=>{let t=e.config,r=t.source??"auto",n="areas"===r||"auto"===r&&e.areas.length>0,o=(n?xe(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,r)=>!t.filter||t.filter(e.datum,r)),i=we(o.map(e=>e.datum),t),a=n?o:be({...e,points:o.map(e=>e.datum)}),l=i??he(a,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===l.length)return{nodes:[]};let s=ue(l.map(e=>e.row)),c=ue(l.map(e=>e.column)),u=Math.max(1,Math.round(s[1]-s[0])+1),d=Math.max(1,Math.round(c[1]-c[0])+1),h=Math.max(0,t.layoutPadding??8),f=Math.max(1,e.dimensions.width-2*h)/d,m=Math.max(1,e.dimensions.height-2*h)/u,p=(e.dimensions.width-f*d)/2,g=(e.dimensions.height-m*u)/2,y=ce(t.cellPadding??.12,0,.8),x=Math.max(1,.5*Math.min(f,m)*(1-y)),b=t.sizeAccessor?l.map(e=>Number(fe(e.datum,t.sizeAccessor))):[],w=t.sizeDomain??ue(b),M=t.sizeRange??[.36,1],v=ce(Math.min(M[0],M[1]),.05,1),k=ce(Math.max(M[0],M[1]),v,1),$=l.map((r,n)=>{let o={...r.datum,gridRow:r.row,gridColumn:r.column},i=(fe(o,t.idAccessor,["id","key","name"])??"grid-"+n)+"",a=(fe(o,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",l=Math.max(1,t.maxLabelLength??4),u=a.length>l?a.slice(0,l):a,d=fe(o,t.categoryAccessor),h=null==d?void 0:d+"",y=fe(o,t.fillAccessor),b=null!=y?y+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",M=t.sizeAccessor?Number(fe(o,t.sizeAccessor)):NaN,$=t.sizeAccessor&&Number.isFinite(M)?Math.sqrt(ce(de(M,w),0,1)):1,A=x*(v+$*(k-v)),S="function"==typeof t.markStyle?t.markStyle(o,n):t.markStyle;return{datum:o,id:i,label:u,category:h,row:r.row,column:r.column,x:p+(r.column-c[0]+.5)*f,y:g+(r.row-s[0]+.5)*m,radius:A,style:{fill:b,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...S}}}),A=t.shape??"circle";return{nodes:$.map(e=>"circle"===A?{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"===A?ye(e.x,e.y,e.radius):ge(e.x,e.y,e.radius),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===A?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}),overlays:!1===t.showLabels?null:/* @__PURE__ */Pl(Me,{marks:$,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??ce(.23*Math.min(f,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}}};import{geoBounds as Ol,geoContains as Wl}from"d3-geo";import{jsx as Dl}from"react/jsx-runtime";var ql=/* @__PURE__ */new WeakMap,Bl=/* @__PURE__ */new WeakMap,Vl=/* @__PURE__ */new WeakMap,Gl=1,Hl=e=>{let t=Be(e),r=e.config,n=r.shape??"circle",o=Math.max(.5,ke(r.dotRadius)??t.cellSize*ve(r.radiusRatio??.24,.05,.5)),i=r.gridOrigin?.[0]??0,a=r.gridOrigin?.[1]??0;return{nodes:t.dots.map((l,s)=>{let c=i+(l.gridColumn+.5)*t.cellSize,u=a+(l.gridRow+.5)*t.cellSize,d=$e(l,r.categoryAccessor),h=$e(l,r.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof r.markStyle?r.markStyle(l,s):r.markStyle},m=`dot-${l.gridRow}-${l.gridColumn}`;return"circle"===n?{type:"point",x:c,y:u,r:o,style:f,datum:l,interactive:!1,pointId:m,_transitionKey:m}:{type:"geoarea",pathData:"hexagon"===n?He(c,u,o):Ge(c,u,o),centroid:[c,u],bounds:[[c-o,u-o],[c+o,u+o]],screenArea:"hexagon"===n?3*Math.sqrt(3)*o*o/2:(2*o)**2,style:f,datum:l,group:l.featureId,interactive:!1}}),overlays:r.showOutline?/* @__PURE__ */Dl("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,n)=>{let o=e.scales.geoPath(t);return o?/* @__PURE__ */Dl("path",{d:o,fill:"none",stroke:r.outlineStyle?.stroke??"currentColor",strokeOpacity:r.outlineStyle?.opacity??r.outlineStyle?.fillOpacity??.22,strokeWidth:r.outlineStyle?.strokeWidth??.7,strokeDasharray:r.outlineStyle?.strokeDasharray,strokeLinecap:r.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},Se(t,n)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Yl=e=>{let t=e.config,r=t.nodeWidth??80,n=t.nodeHeight??30,o=t.orientation??"vertical",i=t.edgeCurve??"curved",a=!1!==t.showLabels,l=t.labelAccessor??"id",s="function"==typeof l?l:e=>_i(e,l,e.id??"")+"",c=/* @__PURE__ */new Map,u=[],d=[],h=e=>{let 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)??r,h:("number"==typeof t.height?t.height:e.height)??n}};for(let r of e.nodes){let{x:n,y:o,w:i,h:l}=h(r);null==n||null==o||(c.set(r.id,{x:n,y:o,w:i,h:l}),u.push({type:"rect",x:n-i/2,y:o-l/2,w:i,h:l,style:{fill:t.nodeFill??e.resolveColor(r.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:r,id:r.id,label:s(r)+""}),a&&d.push({x:n,y:o,text:s(r)+"",anchor:"middle",baseline:"middle",fontSize:11}))}let f=[];for(let t of e.edges){let r="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),a=c.get(r);if(!n||!a)continue;let l="vertical"===o?{x:n.x,y:n.y+n.h/2}:{x:n.x+n.w/2,y:n.y},s="vertical"===o?{x:a.x,y:a.y-a.h/2}:{x:a.x-a.w/2,y:a.y};if("line"===i)f.push({type:"line",x1:l.x,y1:l.y,x2:s.x,y2:s.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{let r=(l.y+s.y)/2,n=(l.x+s.x)/2;f.push({type:"curved",pathD:"vertical"===o?`M${l.x},${l.y} C${l.x},${r} ${s.x},${r} ${s.x},${s.y}`:`M${l.x},${l.y} C${n},${l.y} ${n},${s.y} ${s.x},${s.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:f,labels:d}},_l=e=>{let t=e.config,r=t.nodeWidth??100,n=t.nodeHeight??36,o=t.edgeStyle??"polyline",i=!1!==t.showLabels,a=t.labelAccessor??"label",l="function"==typeof a?a:e=>_i(e,a,e.id??"")+"",s=/* @__PURE__ */new Map,c=[],u=[],d=e=>{let 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)??r,h:("number"==typeof t.height?t.height:e.height)??n}};for(let r of e.nodes){let{x:n,y:o,w:a,h:h}=d(r);null==n||null==o||(s.set(r.id,{x:n,y:o,w:a,h:h}),c.push({type:"rect",x:n-a/2,y:o-h/2,w:a,h:h,style:{fill:t.nodeFill??e.resolveColor(r.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:r,id:r.id,label:l(r)+""}),i&&u.push({x:n,y:o,text:l(r)+"",anchor:"middle",baseline:"middle",fontSize:11}))}let h=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,f=[];for(let t of e.edges){let e="string"==typeof t.target?t.target:t.target.id,r=s.get("string"==typeof t.source?t.source:t.source.id),n=s.get(e);if(!r||!n)continue;let i=t.data??{},a=Array.isArray(i.points)?i.points:t.points;if(a&&a.length>=2)if("smooth"!==o||3>a.length){let e="M"+a.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${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}`;let r=a[a.length-1];e+=` T${r.x},${r.y}`,f.push({type:"curved",pathD:e,style:{stroke:h,strokeWidth:1,fill:"none"},datum:t})}else f.push({type:"line",x1:r.x,y1:r.y,x2:n.x,y2:n.y,style:{stroke:h,strokeWidth:1},datum:t})}return{sceneNodes:c,sceneEdges:f,labels:u}};import{createElement as Xl}from"react";var Kl=e=>{let t=e.config??{},r=t.mode??"primary",n=t.dimOpacity??.14,o=(t,r=e.selection)=>r?.isActive&&!r.predicate(t)?n:1,i=e.nodes.map(e=>({id:e.id,data:Ki(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),a=e.edges.map(e=>({source:_e(e.source),target:_e(e.target),data:Ki(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),l=tl(i,a,e.dimensions.plot,t),s="source-rooted"===t.lineMode?Qe(i,a,t,e.resolveColor):void 0,c=Je(a,t,s),u=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),d=/* @__PURE__ */new Map;if(s)for(let[e,t]of s.byNode)for(let r of t)u.get(e)?.add(r.id),r.color&&d.set(r.id,r.color);let h=Math.max(1,t.lineWidth??("primary"===r?6:"compact"===r?3.5:2)),f=Math.max(0,t.lineGap??("primary"===r?2:"compact"===r?1:.5)),m=/* @__PURE__ */new Map,p=[];for(let r of c){let n=l.positions.get(r.source),i=l.positions.get(r.target);if(!n||!i)continue;let a=tt(r,t),s=(a.length-1)/2*(h+f)+h/2;for(let e of[r.source,r.target])m.set(e,Math.max(m.get(e)??0,s));a.forEach((s,c)=>{u.get(r.source)?.add(s.descriptor.id),u.get(r.target)?.add(s.descriptor.id);let m=rt(s.edge,l,t,s.edge.source!==r.source),g=m?[n,...m,i]:nl(n,i),y=Di(g,(c-(a.length-1)/2)*(h+f)),x=nt(s.edge,s.descriptor),b=Ze(s.descriptor,s.edge,t,e.resolveColor);d.has(s.descriptor.id)||d.set(s.descriptor.id,b),p.push({type:"curved",id:`${r.key}:${s.descriptor.id}`,label:`${s.descriptor.label??s.descriptor.id}: ${s.edge.source} to ${s.edge.target}`,pathD:qi(y,t.cornerRadius??10),style:{fill:"none",stroke:b,strokeWidth:h,strokeLinecap:"round",opacity:o(x)},datum:x,accessibleDatum:x,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}}})})}let g=/* @__PURE__ */new Map,y=[],x=[],b=e=>(Ye(e,t)||e.id)+"";if("minimap"===r){let r=/* @__PURE__ */new Map;for(let e of i){let t=l.positions.get(e.id);if(!t)continue;let n=`${t.x}\0${t.y}`,o=r.get(n);o||(o={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},r.set(n,o)),o.nodes.push(e);for(let t of u.get(e.id)??[])o.lineIds.add(t);o.bundleRadius=Math.max(o.bundleRadius,m.get(e.id)??0)}let n=[...r.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(let r of n){let n=et(r.lineIds,t),i=n.length>1||r.nodes.length>1||r.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),a=i?t.interchangeRadius??Math.max(5,r.bundleRadius):t.stationRadius??Math.max(3.5,r.bundleRadius);for(let e of r.nodes)g.set(e.id,a);let l=r.nodes.map(b).join(" / "),s=r.nodes.map(e=>e.id).join("--"),c=1===r.nodes.length?r.nodes[0].data:Ji(e=>{e("id",s),e("label",l),e("stationIds",r.nodes.map(e=>e.id)),e("stations",r.nodes.map(e=>e.data)),e("lineIds",n),e("interchange",i)}),u={label:`${l}${i?", interchange":""}`,tableFields:{station:l,lines:n.join(", ")}};n.length>1?(n.forEach((t,i)=>{let l={type:"arc",cx:r.x,cy:r.y,innerR:0,outerR:a,startAngle:-Math.PI/2+i/n.length*Math.PI*2,endAngle:-Math.PI/2+(i+1)/n.length*Math.PI*2,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:o(c)},datum:null,id:`${s}:${t}`};y.push(l)}),y.push({type:"circle",cx:r.x,cy:r.y,r:a,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:o(c)},datum:c,accessibleDatum:c,accessibility:u,id:s,label:l})):y.push({type:"circle",cx:r.x,cy:r.y,r:a,style:{fill:(n[0]&&d.get(n[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:o(c)},datum:c,accessibleDatum:c,accessibility:u,id:s,label:l})}}else for(let e of i){let n=l.positions.get(e.id);if(!n)continue;let i=et(u.get(e.id)??[],t),a=i.length>1||!0===e.data.interchange||!0===e.data.transfer,s=a?t.interchangeRadius??Math.max("primary"===r?7:5,m.get(e.id)??0):t.stationRadius??("primary"===r?4:2.75);g.set(e.id,s);let c=b(e);if(y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:null!=t.renderStation?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:a?"primary"===r?3:2:1.5,opacity:o(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${c}${a?", interchange":""}`,tableFields:{station:c,lines:i.join(", ")}},id:e.id,label:c}),t.renderStation){let l=t.renderStation({station:e.data,x:n.x,y:n.y,radius:s,lineIds:i,interchange:a,mode:r});null!=l&&x.push(Xl("g",{key:e.id,opacity:o(e.data),style:{pointerEvents:"none"}},l))}}let w=x.length>0?Xl("g",{className:"transit-diagram-stations"},...x):void 0,M={sceneEdges:p,sceneNodes:y,overlays:w,labels:it(i,l.positions,u,g,e.dimensions.plot,"primary"===r?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===r)return M;let v=(e,t)=>({opacity:o(e.datum,t)});return{...M,restyle:v,restyleEdge:v}};import{jsx as Ul,jsxs as Ql}from"react/jsx-runtime";import{jsx as Zl,jsxs as Jl}from"react/jsx-runtime";var es={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},ts={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},rs=e=>{let t=e.config||{},r=e.dimensions.plot,n=t.layerAccessor??"x",o=t.rowAccessor??"y",i=t.partitionAccessor??"partition",a=t.semanticAccessor??"semantic",l=t.labelAccessor??"label",s=t.storesAccessor??"stores",c=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...es,...t.partitionColors},h={...ts,...t.edgeColors},f=t.accentColor??"var(--semiotic-focus, #ffcc33)",m=t.borderColor??"var(--semiotic-border, #555)",p=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,v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0,r=/* @__PURE__ */new Map;for(let o of e.nodes){let e=Math.round(Number(_i(o,n,0)));t=Math.max(t,e),r.set(e,(r.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...r.values())}let $=r.width/Math.max(1,v),A=r.height/Math.max(1,k),S=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),I=Math.min(t.nodeHeight??54,Math.max(8,A-(t.minGapY??18))),C=t.lod&&"auto"!==t.lod?t.lod:16>S?"dot":48>S?"icon":108>S?"compact":"full";if("dot"===C){let e=Math.min(S,I,11);S=e,I=e}let N=Math.max(1,r.width-S),F=Math.max(1,r.height-I),E=Math.max(1,k-1),z=e=>r.x+S/2+(v>1?e/(v-1):.5)*N,R=e=>r.y+I/2+(e+E/2)/E*F,L=t.reachableIds?new Set(t.reachableIds):null,T=t.selectedId??null,P=e.selection,j=/* @__PURE__ */new Map,O=/* @__PURE__ */new Map,W=[],D=null==M?null:/* @__PURE__ */new Map,q=[];for(let t of e.nodes){let e=t.id,r=Number(_i(t,n,0)),c=Number(_i(t,o,0)),u=_i(t,i,"processor")+"",h=_i(t,a,"processor")+"",g=_i(t,l,e)+"",y=ht(_i(t,s,[])),x=t.data??t,b=z(r),w=R(c);j.set(e,{cx:b,cy:w});let v=L?L.has(e):null,k=P?.isActive?P.predicate(x):null,$=null!==v?!v:null!==k&&!k;O.set(e,$);let A=null!=T&&e===T,N=$&&!A?p:1,F=Object.prototype.hasOwnProperty.call(d,u)?d[u]:d.unknown;if("dot"===C?W.push({type:"circle",cx:b,cy:w,r:S/2,style:{fill:F,opacity:N,stroke:A?f:"transparent",strokeWidth:A?2:0},datum:t,id:e,label:g}):(W.push({type:"rect",x:b-S/2,y:w-I/2,w:S,h:I,style:{fill:F,opacity:N,stroke:A?f:m,strokeWidth:A?3:1},datum:t,id:e,label:g}),q.push({id:e,cx:b,cy:w,partition:u,semantic:h,label:g,stores:y,opacity:N,selected:A,node:x})),D&&null!=M){let r=_i(t,M,null);if(null!=r){let t=r+"",n=D.get(t)??[];n.push({id:e,x:b-S/2,y:w-I/2,w:S,h:I}),D.set(t,n)}}}let B=[];for(let t of e.edges){let e="string"==typeof t.source?t.source:t.source.id,r="string"==typeof t.target?t.target:t.target.id,n=j.get(e),o=j.get(r);if(!n||!o)continue;let i,a=!!_i(t,c,!1),l=_i(t,u,"internal")+"",s=O.get(e)||O.get(r)?Math.min(g,1.4*p):g,d=a?h.back:Object.prototype.hasOwnProperty.call(h,l)?h[l]:h.internal;if(a){let e=n.cx,t=n.cy+I/2,r=o.cx,a=o.cy+I/2,l=Math.max(48,.28*Math.abs(e-r))+I;i=`M${e},${t} C${e},${t+l} ${r},${a+l} ${r},${a}`}else{let e=n.cx+S/2,t=n.cy,r=o.cx-S/2,a=o.cy,l=(e+r)/2;i=`M${e},${t} C${l},${t} ${l},${a} ${r},${a}`}let f={type:"curved",pathD:i,style:{stroke:d,strokeWidth:a?x:y,fill:"none",opacity:s,...a?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};B.push(f)}let V=0===q.length?null:/* @__PURE__ */Zl("g",{className:"lineage-dag-glyphs",children:q.map(e=>mt(e,{w:S,h:I,lod:C,partColors:d,chipColor:w,showChips:b,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))}),G=D&&D.size>0?dt(D,{colors:t.hullColors,padding:null==t.hullPadding?16:ca(t.hullPadding),radius:null==t.hullRadius?12:ca(t.hullRadius),fillOpacity:ft(t.hullFillOpacity,.08),strokeOpacity:ft(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:O,selectedId:T,dimOpacity:p}):null;return G?{sceneNodes:W,sceneEdges:B,backgrounds:G,overlays:V}:{sceneNodes:W,sceneEdges:B,overlays:V}};import{jsx as ns,jsxs as os}from"react/jsx-runtime";var is={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},as=e=>{let t=e.config||{},r=e.dimensions.plot,n=t.direction??"TD",o="LR"===n||"RL"===n,i="BT"===n||"RL"===n,a=t.layerAccessor??"layer",l=t.rowAccessor??"row",s=t.labelAccessor??"label",c=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)",m=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",p=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};let g=/* @__PURE__ */new Map,y=0;for(let t of e.nodes){let e=Math.round(Number(_i(t,a,0)));y=Math.max(y,e);let r=g.get(e)||[];r.push(t),g.set(e,r)}let x=y+1,b=1;for(let e of g.values())e.sort((e,t)=>Number(_i(e,l,0))-Number(_i(t,l,0))),b=Math.max(b,e.length);let w=o?r.width:r.height,M=o?r.height:r.width,v=w/x,k=M/(b+1),$=Math.max(44,Math.min(t.nodeWidth??150,o?v-36:.92*k)),A=Math.max(26,Math.min(t.nodeHeight??46,o?.7*k:.5*v)),S=(o?$:A)/2+6,I=Math.max(1,w-2*S),C=e=>(o?r.x:r.y)+S+(x>1?(i?x-1-e:e)/(x-1)*I:I/2),N=(e,t)=>(o?r.y:r.x)+(e+1)/(t+1)*M,F=/* @__PURE__ */new Map,E=[],z=[];for(let[e,t]of g)t.forEach((r,n)=>{let i=C(e),a=N(n,t.length),l=o?i:a,u=o?a:i,m=_i(r,c,"rect")+"",g=_i(r,s,r.id)+"";F.set(r.id,{cx:l,cy:u,shape:m}),E.push({type:"rect",x:l-$/2,y:u-A/2,w:$,h:A,style:{fill:"transparent",stroke:"transparent"},datum:{id:r.id,name:g,type:is[m]??"process",shape:m},id:r.id,label:g}),z.push(
|
|
61
61
|
/* @__PURE__ */os("g",{children:[bt(m,l,u,$,A,d,"diamond"===m?p:h,1.5),
|
|
62
|
-
/* @__PURE__ */ns("text",{x:l,y:u,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:f,style:{pointerEvents:"none"},children:xt(g,Math.max(4,Math.floor(($-12)/7)))})]},"n-"+r.id))});let R=[];return e.edges.forEach((e,t)=>{let r="string"==typeof e.target?e.target:e.target.id,n=F.get("string"==typeof e.source?e.source:e.source.id),i=F.get(r);if(!n||!i)return;let a=o?n.cx+$/2:n.cx,l=o?n.cy:n.cy+A/2,s=o?i.cx-$/2:i.cx,c=o?i.cy:i.cy-A/2,d=o?`M${a},${l} C${(a+s)/2},${l} ${(a+s)/2},${c} ${s},${c}`:`M${a},${l} C${a},${(l+c)/2} ${s},${(l+c)/2} ${s},${c}`,p=Math.atan2(c-l,s-a),g=s-9*Math.cos(p),y=c-9*Math.sin(p),x=4.5*-Math.sin(p),b=4.5*Math.cos(p),w=`${s},${c} ${g+x},${y+b} ${g-x},${y-b}`,M=
|
|
62
|
+
/* @__PURE__ */ns("text",{x:l,y:u,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:f,style:{pointerEvents:"none"},children:xt(g,Math.max(4,Math.floor(($-12)/7)))})]},"n-"+r.id))});let R=[];return e.edges.forEach((e,t)=>{let r="string"==typeof e.target?e.target:e.target.id,n=F.get("string"==typeof e.source?e.source:e.source.id),i=F.get(r);if(!n||!i)return;let a=o?n.cx+$/2:n.cx,l=o?n.cy:n.cy+A/2,s=o?i.cx-$/2:i.cx,c=o?i.cy:i.cy-A/2,d=o?`M${a},${l} C${(a+s)/2},${l} ${(a+s)/2},${c} ${s},${c}`:`M${a},${l} C${a},${(l+c)/2} ${s},${(l+c)/2} ${s},${c}`,p=Math.atan2(c-l,s-a),g=s-9*Math.cos(p),y=c-9*Math.sin(p),x=4.5*-Math.sin(p),b=4.5*Math.cos(p),w=`${s},${c} ${g+x},${y+b} ${g-x},${y-b}`,M=_i(e,u,void 0),v=(a+s)/2,k=(l+c)/2;R.push(
|
|
63
63
|
/* @__PURE__ */os("g",{children:[
|
|
64
64
|
/* @__PURE__ */ns("path",{d:d,fill:"none",stroke:m,strokeWidth:1.4}),
|
|
65
65
|
/* @__PURE__ */ns("polygon",{points:w,fill:m}),"string"==typeof M&&M.length>0&&/* @__PURE__ */os("g",{children:[
|
|
66
66
|
/* @__PURE__ */ns("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}),
|
|
67
|
-
/* @__PURE__ */ns("text",{x:v,y:k,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:M})]})]},"e-"+t))}),{sceneNodes:E,overlays:/* @__PURE__ */os("g",{className:"mermaid-dag",children:[R,z]})}};import{jsx as ls,jsxs as ss}from"react/jsx-runtime";var cs=new Ra(8),us=e=>{let t=e.config||{},r=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};let n=t.sourceAccessor??"source",o=t.targetAccessor??"target",i=t.labelAccessor??"label",a=t.categoryAccessor??"category",l=t.nodeRadius??4,s=t.cellGap??16,c=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,m=t.fingerprintRounds??3,p=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(let t of e.nodes){let e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,ba(t,a,"")+""))}let w=[];for(let t of e.edges){let e=$t(t.source??ba(t,n,void 0)),r=$t(t.target??ba(t,o,void 0));null==e||null==r||w.push({source:e,target:r})}let{outAdj:M,inAdj:v,undirected:k}=Nt(b,w),$=Ft(b,M,v,k,m),A=/* @__PURE__ */new Map;if(p)for(let e of $){let t=A.get(e.motif);t?t.push(e):A.set(e.motif,[e])}else A.set("all",[...$].sort((e,t)=>t.nodeCount-e.nodeCount));let S=[...A.entries()];S.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);let I=kt(b.join(",")+"|"+[...M.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),C=Ea([Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height),s,c,u,d,h,f,m,p,g,l,S.map(([e,t])=>e+":"+t.length).join(","),I]),N=cs.getOrCompute(C,()=>Et(S,{plot:r,cellGap:s,bandGap:c,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:l,nodeDatum:y,nodeCategory:x,outAdj:M,inAdj:v})),F=e.theme.semantic||{},E=t.convergeColor??F.info??"#4c78a8",z=t.branchColor??F.warning??"#e8853a",R=t.edgeColor??F.border??"#9aa0aa",L=t.colorMode??"directedness",T={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},P=t=>"motif"===L?e.resolveColor(t.motif):"category"===L||t.directed?E:z,j=[],O=[];for(let t of N.cells){let r=t.component,n=P(r);if("full"===t.lod){for(let e of t.edges)O.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:R,strokeWidth:1,opacity:.5},datum:null});for(let r of t.nodes){let t="category"===L&&r.category?e.resolveColor(r.category):n,o={type:"symbol",cx:r.cx,cy:r.cy,size:Math.PI*r.r*r.r,symbolType:"circle",style:{fill:t,opacity:Na(r.datum,T)},datum:r.datum,id:r.id,label:ba(r.datum,i,r.id)+""};j.push(o)}}else{let e=Wa({id:`motif-${r.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:r.motif,shape:Ct(r),nodes:r.nodeCount,edges:r.edgeCount,sinks:r.sinkCount,sources:r.sourceCount,directedness:r.directed?"converging":"branching"}),o={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:r.directed?"circle":"diamond",style:{fill:n,opacity:Na(e,T),stroke:R,strokeWidth:.75},datum:e,id:e.id+"",label:Ct(r)};j.push(o)}}return{sceneNodes:j,sceneEdges:O,overlays:wt(N.bands,{convergeColor:E,branchColor:z,edgeColor:R,plot:r,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===L,textColor:F.text??"var(--semiotic-text, #1a1a1a)",subText:F.textSecondary??"var(--semiotic-text-secondary, #888)"})}};import*as ds from"react";var hs=e=>{let t=e.config??{},r=e.dimensions.plot,n=e.nodes.map((e,t)=>({id:e.id,datum:Rt(e),inputIndex:t})),o=new Map(n.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[e+"",t]));if(n.sort((e,t)=>{let r=i.get(e.id),n=i.get(t.id);return null!=r&&null!=n?r-n:null!=r?-1:null!=n?1:(o.get(e.id)??0)-(o.get(t.id)??0)}),0===n.length)return{sceneNodes:[],sceneEdges:[],labels:[]};let a=Math.max(0,t.padding??18),l=Math.max(1,Math.min(r.width,r.height)-2*a),s=Math.min(Math.max(1,t.maxCellSize??120),l/n.length),c=s*n.length,u=r.x+(r.width-c)/2,d=r.y+(r.height-c)/2,h=Math.max(4,Math.min(.76*s,t.nodeSize??.56*s)),f=h/2,m=n.map((e,r)=>{let n="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):ba(e.datum,t.labelAccessor??"label",e.id)+"";return{id:e.id,label:n,datum:e.datum,index:r,cx:u+(r+.5)*s,cy:d+(r+.5)*s}}),p=new Map(m.map(e=>[e.id,e])),g=new Map(m.map(e=>[e.id,e.index])),y=qt(e.edges,g,t),x=Vt(Bt(y,h,t),p,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",k=e.theme.semantic.grid??v,$=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),A=t.valueFormat??(e=>Math.round(100*e)/100+""),S=Math.max(0,Math.min(t.cornerRadius??10,.22*s)),I=new Map(m.map(e=>[e.id,0])),C=new Map(m.map(e=>[e.id,0])),N=[],F=[],E=[];for(let r of y){let n=p.get(r.source),o=p.get(r.target);if(!n||!o)continue;I.set(n.id,(I.get(n.id)??0)+r.value),C.set(o.id,(C.get(o.id)??0)+r.value);let i=t.colorMode??"single",a="function"==typeof t.edgeColor?t.edgeColor(r.datum):void 0;r.color=a??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(r.source):"target"===i?e.resolveColor(r.target):"edge"===i?e.resolveColor(`${r.source}→${r.target}`):b);let l,c,h,m,g,y,v,k=x.get(r.key+":source")??n.cy,$=x.get(r.key+":target")??o.cx;if(r.targetIndex>r.sourceIndex){let e=[n.cx+f,k],t=[$,o.cy-f];l=[e,[t[0],e[1]],t],c=t[0],h=e[1]+.68*(t[1]-e[1]),m=Math.PI/2,g=t[0]-S-4,y=e[1]-r.width/2-3,v="end"}else if(r.sourceIndex>r.targetIndex){let e=[n.cx-f,k],i=[$,o.cy+f];l=[e,[i[0],e[1]],i],c=i[0],h=e[1]+.68*(i[1]-e[1]),m=-Math.PI/2,g=i[0]+S+4,y=e[1]+r.width/2+(t.valueFontSize??10),v="start"}else{let e=u+(n.index+1)*s,t=d+(n.index+1)*s,i=Math.max(2,Math.min(6,.07*s)),a=Math.max(n.cx+f+2,e-i),p=Math.max(n.cy+f+2,t-i),x=[n.cx+f,k],b=[$,o.cy+f];l=[x,[a,x[1]],[a,p],[b[0],p],b],c=(a+b[0])/2,h=p,m=Math.PI,g=a-3,y=p-r.width/2-3,v="end"}let z=jt(l,S);if(E.push({type:"curved",id:"adjacency-flow-"+r.key,label:`${n.label} to ${o.label}: ${A(r.value,r.datum)}`,pathD:z,style:{fill:"none",stroke:r.color,strokeWidth:r.width,opacity:.82,cursor:"pointer"},datum:r.datum,accessibleDatum:r.datum,accessibility:{label:`${n.label} to ${o.label}, ${A(r.value,r.datum)}`,tableFields:{source:n.label,target:o.label,value:r.value,edges:r.edgeCount}}}),(t.showValues??!0)&&F.push({x:g,y:y,text:A(r.value,r.datum),anchor:v,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*s)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){let e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,r.width-2));if(2>=e)continue;N.push(ds.createElement("path",{key:"arrow-"+r.key,className:"semiotic-adjacency-flow-arrow",d:Ot(c,h,m,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":r.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}let z=m.map(r=>{let n=("function"==typeof t.nodeColor?t.nodeColor(r.datum,r.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(r.id):$);return{type:"rect",id:r.id,label:r.label,x:r.cx-f,y:r.cy-f,w:h,h:h,style:{fill:n,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:r.datum,accessibleDatum:r.datum,accessibility:{label:`${r.label}, step ${r.index+1}`,tableFields:{step:r.index+1,node:r.label,incoming:C.get(r.id)??0,outgoing:I.get(r.id)??0}}}}),R=Math.max(2,t.maxLabelLength??14),L=m.map(e=>({x:e.cx,y:e.cy,text:Wt(e.label,R),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??M})),T=null;if(t.showGrid??!0){let e=[];for(let t=0;m.length>=t;t+=1){let r=u+t*s,n=d+t*s;e.push(ds.createElement("line",{key:"grid-v-"+t,x1:r,y1:d,x2:r,y2:d+c,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),ds.createElement("line",{key:"grid-h-"+t,x1:u,y1:n,x2:u+c,y2:n,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}T=ds.createElement(ds.Fragment,null,...e)}return{sceneEdges:E,sceneNodes:z,labels:[...F,...L],backgrounds:T,overlays:ds.createElement(ds.Fragment,null,...N)}};import{jsx as fs,jsxs as ms}from"react/jsx-runtime";var ps=new Ra(12),gs=e=>{let t=e.config||{},r=e.dimensions.plot,n=t.columnAccessor??"column",o=t.rowAccessor??"row",i=t.sizeAccessor,a=t.colorAccessor,l=t.symbolAccessor,s=t.shadeAccessor,c=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],m=t.shadeStrength??.72,p=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,A=!1!==t.showRowLabels,S=$?t.headerHeight??26:0,I=A?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,N=r.x+I,F=r.y+S,E=Math.max(1,r.width-I),z=Math.max(1,r.height-S-C),R=[];for(let t of e.nodes){let e=t.data??t;R.push({id:t.id,col:ba(t,n,"—")+"",row:ba(t,o,"—")+"",sizeVal:i?Number(ba(t,i,1)):1,colorKey:a?ba(t,a,"")+"":"",symVal:l?ba(t,l,"")+"":"",shadeVal:s?Qt(ba(t,s,null)):NaN,marker:!!c&&!!ba(t,c,!1),iconVal:u?ba(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===R.length)return{sceneNodes:[]};let L=1/0,T=-1/0;if(i)for(let e of R)Number.isFinite(e.sizeVal)&&(L>e.sizeVal&&(L=e.sizeVal),e.sizeVal>T&&(T=e.sizeVal));t.sizeDomain&&([L,T]=t.sizeDomain),(!Number.isFinite(L)||!Number.isFinite(T))&&(L=0,T=1);let P=e=>{if(L>=T)return(h+f)/2;let t=Math.sqrt(Zt((e-L)/(T-L),0,1));return h+t*(f-h)},j=1/0,O=-1/0;if(s)for(let e of R)Number.isFinite(e.shadeVal)&&(j>e.shadeVal&&(j=e.shadeVal),e.shadeVal>O&&(O=e.shadeVal));t.shadeDomain&&([j,O]=t.shadeDomain);let W=e=>{if(!s||!Number.isFinite(e)||j>=O)return.5;let t=Zt((e-j)/(O-j),0,1);return p?1-t:t},D=t.colorMap,q=/* @__PURE__ */new Map,B=(t,r)=>{let n=q.get(t);if(!n){let r=D&&Object.prototype.hasOwnProperty.call(D,t)&&"string"==typeof D[t]&&D[t]?D[t]:e.resolveColor(t);n=Ta(r,m),q.set(t,n)}return n(r)},V=/* @__PURE__ */new Map;if(t.symbolMap)for(let[e,r]of Object.entries(t.symbolMap))V.set(e,r);let G=0,H=e=>{if(!l)return d;let t=V.get(e);return t||(t=za[G%za.length],G++,V.set(e,t)),t},Y=t.iconMap,_=e=>u&&Y&&Object.prototype.hasOwnProperty.call(Y,e)?Y[e]??null:null,X=e=>u?"circle":H(e.symVal),K=t.maxAreaFraction??.4,U=0,Q=Array(R.length),Z=Array(R.length);for(let e=0;R.length>e;e++){let t=R[e],r=P(t.sizeVal);Q[e]=r,t.baseShape=X(t),t.iconShape=_(t.iconVal);let n=Oa(t.baseShape,Math.PI*r*r);Z[e]=n,U+=Math.PI*n*n}let J=K*E*z,ee=U>J?Math.sqrt(J/U):1;for(let e=0;R.length>e;e++){let t=R[e],r=Q[e]*ee;t.size=Math.PI*r*r,t.packR=Z[e]*ee}let te=/* @__PURE__ */new Map,re=/* @__PURE__ */new Map;for(let e of R)te.set(e.col,(te.get(e.col)??0)+1),re.set(e.row,(re.get(e.row)??0)+1);let ne=t.columnOrder?.filter(e=>te.has(e))??[...te.keys()].sort((e,t)=>(te.get(t)??0)-(te.get(e)??0)),oe=t.rowOrder?.filter(e=>re.has(e))??[...re.keys()].sort((e,t)=>(re.get(t)??0)-(re.get(e)??0)),ie=Ea([Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height),S,I,C,g,y,x,b,w,M,v,h,f,L,T,K,ne.join(","),oe.join(","),R.length,rr(R)]),ae=ps.getOrCompute(ie,()=>er(R,{columnOrder:ne,rowOrder:oe,innerX:N,innerY:F,innerW:E,innerH:z,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),le=e.selection,se=le?.isActive?le.predicate:null,ce=t.highlight??null,ue=t.dimOpacity??.16,de=t.markStroke,he=t.markStrokeWidth??0,fe=t.markerColor??"#ffffff",me=t.iconColor??"rgba(255,255,255,0.92)",pe=t.iconStrokeWidth??1,ge=t.iconScale??.72,ye=[],xe=[],be=[];for(let e of R){let t=ae.positions.get(e.id);if(!t)continue;let r=Na(e.datum,{highlight:ce,predicate:se,dimOpacity:ue}),n={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:B(e.colorKey,W(e.shadeVal)),opacity:r,...de?{stroke:de,strokeWidth:he}:{}},datum:e.datum,id:e.id,label:e.id+""};if(ye.push(n),e.iconShape){let n=Math.sqrt(e.size/Math.PI)*ge,o=Oa(e.iconShape,100);be.push({x:t.px,y:t.py,size:o>0?n/o*100*(n/o):Math.PI*n*n,shape:e.iconShape,opacity:r})}e.marker&&r>ue+.001&&xe.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}let we=[];if(t.callouts&&t.callouts.length>0){let e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",n=r.y+r.height-(C>0?.45*C:9),o=[];for(let e=0;t.callouts.length>e;e++){let r=t.callouts[e],n=R.find(e=>e.datum[r.field]+""==r.value+"");if(!n)continue;let i=ae.positions.get(n.id);i&&o.push({c:r,ci:e,px:i.px,py:i.py,markR:Math.sqrt(n.size/Math.PI)})}let i=o.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),a=/* @__PURE__ */new Map;i.forEach((e,t)=>{a.set(e.ci,N+(t+.5)/i.length*E)});for(let t of o){let o=t.c,i=a.get(t.ci)??t.px,l=n,s=o.connector??(a.has(t.ci)?"elbow":"straight");"object"==typeof o.at&&o.at?(i=o.at.x,l=o.at.y):"number"==typeof o.at&&(l=r.y+o.at*r.height),we.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:l,label:o.label,connector:s,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}return{sceneNodes:ye,overlays:nr(ae,{markerDots:xe,markerColor:fe,iconMarks:be,iconColor:me,iconStrokeWidth:pe,callouts:we,plot:r,showEnclosures:k,showColumnHeaders:$,showRowLabels:A,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:r.y+.62*S,labelX:r.x+I-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel})}},ys=4;import*as xs from"react";var bs=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height)return{nodes:[]};let n=ya(t.categoryAccessor),o=ya(t.stackBy),i=e=>{let r="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],n=Number(r);return Number.isFinite(n)&&n>0?n:0},a=t.gutter??2,l="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",s="string"==typeof t.stackBy?t.stackBy:"stack",c="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,r)=>Aa(n=>{n("category",e),n("stack",t),n("value",r),"category"!==l&&n(l,e),"stack"!==s&&n(s,t),"value"!==c&&n(c,r)}),d=!1!==t.showCategoryLabels,h=Math.max(0,r.height-(t.labelPadding??(d?22:0))),f=[],m=/* @__PURE__ */new Map,p=[],g=/* @__PURE__ */new Set,y=/* @__PURE__ */new Map;for(let t of e.data){let e=n(t)+"",r=o(t)+"",a=i(t);m.has(e)||(f.push(e),m.set(e,0),y.set(e,/* @__PURE__ */new Map)),g.has(r)||(g.add(r),p.push(r)),m.set(e,(m.get(e)??0)+a);let l=y.get(e);l.set(r,(l.get(r)??0)+a)}let x=t.categoryOrder?ir(t.categoryOrder,f,e=>m.has(e)):f,b=t.stackOrder?ir(t.stackOrder,p,()=>!0):p,w=x.reduce((e,t)=>e+(m.get(t)??0),0);if(0>=w)return{nodes:[]};let M=Math.max(0,r.width-a*Math.max(0,x.length-1)),v=[],k=[],$=r.x;for(let t of x){let n=m.get(t)??0,o=n/w*M;if(0>=o)continue;k.push({cat:t,x:$,w:o});let i=y.get(t),l=r.y;for(let r of b){let a=i.get(r)??0;if(0>=a)continue;let s=a/n*h;v.push({type:"rect",x:$,y:l,w:o,h:s,style:{fill:e.resolveColor(r),stroke:"none"},datum:u(t,r,a),group:r}),l+=s}$+=o+a}return{nodes:v,overlays:d&&k.length>0?or(k,r.y+h+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}};import*as ws from"react";var Ms=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height||0===e.data.length)return{nodes:[]};let n=t.rowHeight??28,o=t.rowGap??12,i=!1!==t.showLabels,a=i?t.labelWidth??120:0,l=!1!==t.showTicks,s=l?14:0,c=t.tickFormat??(e=>e.toLocaleString()),u=r.x+a,d=Math.max(0,r.width-a);if(0>=d)return{nodes:[]};let h=ya(t.categoryAccessor),f=e=>{let t=Number(e);return Number.isFinite(t)&&t>0?t:0},m=e=>f("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),p=e=>f("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),g=e=>{let r="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(r)?r.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})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,S=[],I=[];for(let t=0;e.data.length>t;t++){let i=e.data[t],a=g(i),l=m(i),c=p(i),f=Math.max(l,c,...a.length?a:[0]);if(0>=f)continue;let M=r.y+t*(n+o+s);if(M+n+s>r.y+r.height)break;I.push({yTop:M,label:h(i),actual:l,target:c,maxVal:f});let $=e=>u+e/f*d,A=h(i),C=e=>Aa(t=>{t("metric",A),"metric"!==y&&t(y,A),e(t)}),N=u;for(let e=0;a.length>e;e++){let t=$(a[e]),r=t-N;r>0&&S.push({type:"rect",x:N,y:M,w:r,h:n,style:{fill:k[Math.min(e,k.length-1)],stroke:"none"},datum:C(t=>{t("range",e),t("rangeValue",a[e]),t("kind","range")}),group:"range-"+e}),N=t}let F=Math.max(6,Math.floor(.45*n));S.push({type:"rect",x:u,y:M+(n-F)/2,w:$(l)-u,h:F,style:{fill:w,stroke:"none"},datum:C(e=>{e("value",l),e("kind","actual"),"value"!==x&&e(x,l)}),group:"actual"});let E=3,z=Math.floor(.8*n);S.push({type:"rect",x:$(c)-E/2,y:M+(n-z)/2,w:E,h:z,style:{fill:v,stroke:"none"},datum:C(e=>{e("target",c),e("kind","target"),"target"!==b&&e(b,c)}),group:"target"})}let C=[];for(let e=0;I.length>e;e++){let t=I[e];if(i&&C.push(Ja({keyId:"bullet-label-"+e,text:t.label,x:r.x+a-8,y:t.yTop+n/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:$})),l){let r=t.yTop+n+2;for(let n=0;5>n;n++){let o=t.maxVal*n/4,i=u+o/t.maxVal*d;C.push(ws.createElement("line",{key:`bullet-tick-${e}-${n}`,x1:i,x2:i,y1:r,y2:r+3,stroke:A,strokeWidth:1}),Ja({keyId:`bullet-ticktext-${e}-${n}`,text:c(o),x:i,y:r+12,anchor:0===n?"start":4===n?"end":"middle",baseline:"auto",fontSize:10,color:A}))}}}return{nodes:S,overlays:C.length>0?ws.createElement(ws.Fragment,null,...C):null}};import{jsx as vs,jsxs as ks}from"react/jsx-runtime";var $s=1.75,As=.635,Ss="#222222",Is=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height)return{nodes:[]};let n=ya(t.categoryAccessor??"name"),o=ya(t.teaVolumeAccessor??"teaVolume"),i=ya(t.bobaVolumeAccessor??"bobaVolume"),a=ya(t.iceVolumeAccessor??"iceVolume"),l=ya(t.cupHeightAccessor??"cupHeight"),s=ya(t.cupTopRadiusAccessor??"cupTopRadius"),c=ya(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=ya(t.bobaRadiusAccessor??"bobaRadius"),d=t.cupWidthRatio??.82,h=e.scales.o,f=h.bandwidth(),m=Math.max(1,r.height-26-8),p=r.y+8,g=[],y=[];for(let t of e.data){let r=n(t)+"",x=h(r);if(null==x)continue;let b={height:pr(l(t),15.5),topRadius:pr(s(t),4.75),bottomRadius:pr(c(t),3.75)},w=pr(u(t),.6),M=Math.max(0,pr(o(t),450)),v=Math.max(0,pr(i(t),110)),k=Math.max(0,pr(a(t),135)),$=Math.PI*w*w,A=Math.floor(v/$),S=A*$,I=Math.floor(k/5.359375),C=I*$s*$s*$s,N=M+S+C,F=cr(b,N),E=Math.min(b.height,Math.max(0,F)),z=lr(b,E),{pearls:R,layers:L}=hr(b,w,A),T=E,P=mr(b,L*w*2,T,I),j=b.height-20.32,O=Math.min(0,j),W=Math.min(f*d/(2*(b.topRadius+1)),m/(b.height-O)),D=x+f/2,q=e=>D+e*W,B=e=>p+(e-O)*W,V=q(-(b.topRadius+1)),G=q(b.topRadius+1),H=B(O),Y=B(b.height),_=Wa({name:r,teaVolume:M,bobaVolume:Math.round(S),iceVolume:Math.round(C),totalVolume:Math.round(N),numBobas:A,numIce:I,kind:"boba cup"});g.push({type:"rect",x:V,y:H,w:Math.max(1,G-V),h:Math.max(1,Y-H),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:_,group:r,_transitionKey:"boba-"+Da(r)});let X=b.height-T,K=Da(r),U=e.resolveColor(r);y.push(
|
|
67
|
+
/* @__PURE__ */ns("text",{x:v,y:k,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:M})]})]},"e-"+t))}),{sceneNodes:E,overlays:/* @__PURE__ */os("g",{className:"mermaid-dag",children:[R,z]})}};import{jsx as ls,jsxs as ss}from"react/jsx-runtime";var cs=new na(8),us=e=>{let t=e.config||{},r=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};let n=t.sourceAccessor??"source",o=t.targetAccessor??"target",i=t.labelAccessor??"label",a=t.categoryAccessor??"category",l=t.nodeRadius??4,s=t.cellGap??16,c=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,m=t.fingerprintRounds??3,p=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(let t of e.nodes){let e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,_i(t,a,"")+""))}let w=[];for(let t of e.edges){let e=$t(t.source??_i(t,n,void 0)),r=$t(t.target??_i(t,o,void 0));null==e||null==r||w.push({source:e,target:r})}let{outAdj:M,inAdj:v,undirected:k}=Nt(b,w),$=Ft(b,M,v,k,m),A=/* @__PURE__ */new Map;if(p)for(let e of $){let t=A.get(e.motif);t?t.push(e):A.set(e.motif,[e])}else A.set("all",[...$].sort((e,t)=>t.nodeCount-e.nodeCount));let S=[...A.entries()];S.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);let I=kt(b.join(",")+"|"+[...M.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),C=ra([Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height),s,c,u,d,h,f,m,p,g,l,S.map(([e,t])=>e+":"+t.length).join(","),I]),N=cs.getOrCompute(C,()=>Et(S,{plot:r,cellGap:s,bandGap:c,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:l,nodeDatum:y,nodeCategory:x,outAdj:M,inAdj:v})),F=e.theme.semantic||{},E=t.convergeColor??F.info??"#4c78a8",z=t.branchColor??F.warning??"#e8853a",R=t.edgeColor??F.border??"#9aa0aa",L=t.colorMode??"directedness",T={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},P=t=>"motif"===L?e.resolveColor(t.motif):"category"===L||t.directed?E:z,j=[],O=[];for(let t of N.cells){let r=t.component,n=P(r);if("full"===t.lod){for(let e of t.edges)O.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:R,strokeWidth:1,opacity:.5},datum:null});for(let r of t.nodes){let t="category"===L&&r.category?e.resolveColor(r.category):n,o={type:"symbol",cx:r.cx,cy:r.cy,size:Math.PI*r.r*r.r,symbolType:"circle",style:{fill:t,opacity:ta(r.datum,T)},datum:r.datum,id:r.id,label:_i(r.datum,i,r.id)+""};j.push(o)}}else{let e=aa({id:`motif-${r.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:r.motif,shape:Ct(r),nodes:r.nodeCount,edges:r.edgeCount,sinks:r.sinkCount,sources:r.sourceCount,directedness:r.directed?"converging":"branching"}),o={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:r.directed?"circle":"diamond",style:{fill:n,opacity:ta(e,T),stroke:R,strokeWidth:.75},datum:e,id:e.id+"",label:Ct(r)};j.push(o)}}return{sceneNodes:j,sceneEdges:O,overlays:wt(N.bands,{convergeColor:E,branchColor:z,edgeColor:R,plot:r,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===L,textColor:F.text??"var(--semiotic-text, #1a1a1a)",subText:F.textSecondary??"var(--semiotic-text-secondary, #888)"})}};import*as ds from"react";var hs=e=>{let t=e.config??{},r=e.dimensions.plot,n=e.nodes.map((e,t)=>({id:e.id,datum:Rt(e),inputIndex:t})),o=new Map(n.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[e+"",t]));if(n.sort((e,t)=>{let r=i.get(e.id),n=i.get(t.id);return null!=r&&null!=n?r-n:null!=r?-1:null!=n?1:(o.get(e.id)??0)-(o.get(t.id)??0)}),0===n.length)return{sceneNodes:[],sceneEdges:[],labels:[]};let a=Math.max(0,t.padding??18),l=Math.max(1,Math.min(r.width,r.height)-2*a),s=Math.min(Math.max(1,t.maxCellSize??120),l/n.length),c=s*n.length,u=r.x+(r.width-c)/2,d=r.y+(r.height-c)/2,h=Math.max(4,Math.min(.76*s,t.nodeSize??.56*s)),f=h/2,m=n.map((e,r)=>{let n="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):_i(e.datum,t.labelAccessor??"label",e.id)+"";return{id:e.id,label:n,datum:e.datum,index:r,cx:u+(r+.5)*s,cy:d+(r+.5)*s}}),p=new Map(m.map(e=>[e.id,e])),g=new Map(m.map(e=>[e.id,e.index])),y=qt(e.edges,g,t),x=Vt(Bt(y,h,t),p,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",k=e.theme.semantic.grid??v,$=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),A=t.valueFormat??(e=>Math.round(100*e)/100+""),S=Math.max(0,Math.min(t.cornerRadius??10,.22*s)),I=new Map(m.map(e=>[e.id,0])),C=new Map(m.map(e=>[e.id,0])),N=[],F=[],E=[];for(let r of y){let n=p.get(r.source),o=p.get(r.target);if(!n||!o)continue;I.set(n.id,(I.get(n.id)??0)+r.value),C.set(o.id,(C.get(o.id)??0)+r.value);let i=t.colorMode??"single",a="function"==typeof t.edgeColor?t.edgeColor(r.datum):void 0;r.color=a??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(r.source):"target"===i?e.resolveColor(r.target):"edge"===i?e.resolveColor(`${r.source}→${r.target}`):b);let l,c,h,m,g,y,v,k=x.get(r.key+":source")??n.cy,$=x.get(r.key+":target")??o.cx;if(r.targetIndex>r.sourceIndex){let e=[n.cx+f,k],t=[$,o.cy-f];l=[e,[t[0],e[1]],t],c=t[0],h=e[1]+.68*(t[1]-e[1]),m=Math.PI/2,g=t[0]-S-4,y=e[1]-r.width/2-3,v="end"}else if(r.sourceIndex>r.targetIndex){let e=[n.cx-f,k],i=[$,o.cy+f];l=[e,[i[0],e[1]],i],c=i[0],h=e[1]+.68*(i[1]-e[1]),m=-Math.PI/2,g=i[0]+S+4,y=e[1]+r.width/2+(t.valueFontSize??10),v="start"}else{let e=u+(n.index+1)*s,t=d+(n.index+1)*s,i=Math.max(2,Math.min(6,.07*s)),a=Math.max(n.cx+f+2,e-i),p=Math.max(n.cy+f+2,t-i),x=[n.cx+f,k],b=[$,o.cy+f];l=[x,[a,x[1]],[a,p],[b[0],p],b],c=(a+b[0])/2,h=p,m=Math.PI,g=a-3,y=p-r.width/2-3,v="end"}let z=jt(l,S);if(E.push({type:"curved",id:"adjacency-flow-"+r.key,label:`${n.label} to ${o.label}: ${A(r.value,r.datum)}`,pathD:z,style:{fill:"none",stroke:r.color,strokeWidth:r.width,opacity:.82,cursor:"pointer"},datum:r.datum,accessibleDatum:r.datum,accessibility:{label:`${n.label} to ${o.label}, ${A(r.value,r.datum)}`,tableFields:{source:n.label,target:o.label,value:r.value,edges:r.edgeCount}}}),(t.showValues??!0)&&F.push({x:g,y:y,text:A(r.value,r.datum),anchor:v,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*s)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){let e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,r.width-2));if(2>=e)continue;N.push(ds.createElement("path",{key:"arrow-"+r.key,className:"semiotic-adjacency-flow-arrow",d:Ot(c,h,m,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":r.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}let z=m.map(r=>{let n=("function"==typeof t.nodeColor?t.nodeColor(r.datum,r.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(r.id):$);return{type:"rect",id:r.id,label:r.label,x:r.cx-f,y:r.cy-f,w:h,h:h,style:{fill:n,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:r.datum,accessibleDatum:r.datum,accessibility:{label:`${r.label}, step ${r.index+1}`,tableFields:{step:r.index+1,node:r.label,incoming:C.get(r.id)??0,outgoing:I.get(r.id)??0}}}}),R=Math.max(2,t.maxLabelLength??14),L=m.map(e=>({x:e.cx,y:e.cy,text:Wt(e.label,R),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??M})),T=null;if(t.showGrid??!0){let e=[];for(let t=0;m.length>=t;t+=1){let r=u+t*s,n=d+t*s;e.push(ds.createElement("line",{key:"grid-v-"+t,x1:r,y1:d,x2:r,y2:d+c,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),ds.createElement("line",{key:"grid-h-"+t,x1:u,y1:n,x2:u+c,y2:n,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}T=ds.createElement(ds.Fragment,null,...e)}return{sceneEdges:E,sceneNodes:z,labels:[...F,...L],backgrounds:T,overlays:ds.createElement(ds.Fragment,null,...N)}};import{jsx as fs,jsxs as ms}from"react/jsx-runtime";var ps=new na(12),gs=e=>{let t=e.config||{},r=e.dimensions.plot,n=t.columnAccessor??"column",o=t.rowAccessor??"row",i=t.sizeAccessor,a=t.colorAccessor,l=t.symbolAccessor,s=t.shadeAccessor,c=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],m=t.shadeStrength??.72,p=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,A=!1!==t.showRowLabels,S=$?t.headerHeight??26:0,I=A?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,N=r.x+I,F=r.y+S,E=Math.max(1,r.width-I),z=Math.max(1,r.height-S-C),R=[];for(let t of e.nodes){let e=t.data??t;R.push({id:t.id,col:_i(t,n,"—")+"",row:_i(t,o,"—")+"",sizeVal:i?Number(_i(t,i,1)):1,colorKey:a?_i(t,a,"")+"":"",symVal:l?_i(t,l,"")+"":"",shadeVal:s?Qt(_i(t,s,null)):NaN,marker:!!c&&!!_i(t,c,!1),iconVal:u?_i(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===R.length)return{sceneNodes:[]};let L=1/0,T=-1/0;if(i)for(let e of R)Number.isFinite(e.sizeVal)&&(L>e.sizeVal&&(L=e.sizeVal),e.sizeVal>T&&(T=e.sizeVal));t.sizeDomain&&([L,T]=t.sizeDomain),(!Number.isFinite(L)||!Number.isFinite(T))&&(L=0,T=1);let P=e=>{if(L>=T)return(h+f)/2;let t=Math.sqrt(Zt((e-L)/(T-L),0,1));return h+t*(f-h)},j=1/0,O=-1/0;if(s)for(let e of R)Number.isFinite(e.shadeVal)&&(j>e.shadeVal&&(j=e.shadeVal),e.shadeVal>O&&(O=e.shadeVal));t.shadeDomain&&([j,O]=t.shadeDomain);let W=e=>{if(!s||!Number.isFinite(e)||j>=O)return.5;let t=Zt((e-j)/(O-j),0,1);return p?1-t:t},D=t.colorMap,q=/* @__PURE__ */new Map,B=(t,r)=>{let n=q.get(t);if(!n){let r=D&&Object.prototype.hasOwnProperty.call(D,t)&&"string"==typeof D[t]&&D[t]?D[t]:e.resolveColor(t);n=oa(r,m),q.set(t,n)}return n(r)},V=/* @__PURE__ */new Map;if(t.symbolMap)for(let[e,r]of Object.entries(t.symbolMap))V.set(e,r);let G=0,H=e=>{if(!l)return d;let t=V.get(e);return t||(t=Ma[G%Ma.length],G++,V.set(e,t)),t},Y=t.iconMap,_=e=>u&&Y&&Object.prototype.hasOwnProperty.call(Y,e)?Y[e]??null:null,X=e=>u?"circle":H(e.symVal),K=t.maxAreaFraction??.4,U=0,Q=Array(R.length),Z=Array(R.length);for(let e=0;R.length>e;e++){let t=R[e],r=P(t.sizeVal);Q[e]=r,t.baseShape=X(t),t.iconShape=_(t.iconVal);let n=Ia(t.baseShape,Math.PI*r*r);Z[e]=n,U+=Math.PI*n*n}let J=K*E*z,ee=U>J?Math.sqrt(J/U):1;for(let e=0;R.length>e;e++){let t=R[e],r=Q[e]*ee;t.size=Math.PI*r*r,t.packR=Z[e]*ee}let te=/* @__PURE__ */new Map,re=/* @__PURE__ */new Map;for(let e of R)te.set(e.col,(te.get(e.col)??0)+1),re.set(e.row,(re.get(e.row)??0)+1);let ne=t.columnOrder?.filter(e=>te.has(e))??[...te.keys()].sort((e,t)=>(te.get(t)??0)-(te.get(e)??0)),oe=t.rowOrder?.filter(e=>re.has(e))??[...re.keys()].sort((e,t)=>(re.get(t)??0)-(re.get(e)??0)),ie=ra([Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height),S,I,C,g,y,x,b,w,M,v,h,f,L,T,K,ne.join(","),oe.join(","),R.length,rr(R)]),ae=ps.getOrCompute(ie,()=>er(R,{columnOrder:ne,rowOrder:oe,innerX:N,innerY:F,innerW:E,innerH:z,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),le=e.selection,se=le?.isActive?le.predicate:null,ce=t.highlight??null,ue=t.dimOpacity??.16,de=t.markStroke,he=t.markStrokeWidth??0,fe=t.markerColor??"#ffffff",me=t.iconColor??"rgba(255,255,255,0.92)",pe=t.iconStrokeWidth??1,ge=t.iconScale??.72,ye=[],xe=[],be=[];for(let e of R){let t=ae.positions.get(e.id);if(!t)continue;let r=ta(e.datum,{highlight:ce,predicate:se,dimOpacity:ue}),n={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:B(e.colorKey,W(e.shadeVal)),opacity:r,...de?{stroke:de,strokeWidth:he}:{}},datum:e.datum,id:e.id,label:e.id+""};if(ye.push(n),e.iconShape){let n=Math.sqrt(e.size/Math.PI)*ge,o=Ia(e.iconShape,100);be.push({x:t.px,y:t.py,size:o>0?n/o*100*(n/o):Math.PI*n*n,shape:e.iconShape,opacity:r})}e.marker&&r>ue+.001&&xe.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}let we=[];if(t.callouts&&t.callouts.length>0){let e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",n=r.y+r.height-(C>0?.45*C:9),o=[];for(let e=0;t.callouts.length>e;e++){let r=t.callouts[e],n=R.find(e=>e.datum[r.field]+""==r.value+"");if(!n)continue;let i=ae.positions.get(n.id);i&&o.push({c:r,ci:e,px:i.px,py:i.py,markR:Math.sqrt(n.size/Math.PI)})}let i=o.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),a=/* @__PURE__ */new Map;i.forEach((e,t)=>{a.set(e.ci,N+(t+.5)/i.length*E)});for(let t of o){let o=t.c,i=a.get(t.ci)??t.px,l=n,s=o.connector??(a.has(t.ci)?"elbow":"straight");"object"==typeof o.at&&o.at?(i=o.at.x,l=o.at.y):"number"==typeof o.at&&(l=r.y+o.at*r.height),we.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:l,label:o.label,connector:s,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}return{sceneNodes:ye,overlays:nr(ae,{markerDots:xe,markerColor:fe,iconMarks:be,iconColor:me,iconStrokeWidth:pe,callouts:we,plot:r,showEnclosures:k,showColumnHeaders:$,showRowLabels:A,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:r.y+.62*S,labelX:r.x+I-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel})}},ys=4;import*as xs from"react";var bs=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height)return{nodes:[]};let n=Hi(t.categoryAccessor),o=Hi(t.stackBy),i=e=>{let r="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],n=Number(r);return Number.isFinite(n)&&n>0?n:0},a=t.gutter??2,l="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",s="string"==typeof t.stackBy?t.stackBy:"stack",c="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,r)=>Ji(n=>{n("category",e),n("stack",t),n("value",r),"category"!==l&&n(l,e),"stack"!==s&&n(s,t),"value"!==c&&n(c,r)}),d=!1!==t.showCategoryLabels,h=Math.max(0,r.height-(t.labelPadding??(d?22:0))),f=[],m=/* @__PURE__ */new Map,p=[],g=/* @__PURE__ */new Set,y=/* @__PURE__ */new Map;for(let t of e.data){let e=n(t)+"",r=o(t)+"",a=i(t);m.has(e)||(f.push(e),m.set(e,0),y.set(e,/* @__PURE__ */new Map)),g.has(r)||(g.add(r),p.push(r)),m.set(e,(m.get(e)??0)+a);let l=y.get(e);l.set(r,(l.get(r)??0)+a)}let x=t.categoryOrder?ir(t.categoryOrder,f,e=>m.has(e)):f,b=t.stackOrder?ir(t.stackOrder,p,()=>!0):p,w=x.reduce((e,t)=>e+(m.get(t)??0),0);if(0>=w)return{nodes:[]};let M=Math.max(0,r.width-a*Math.max(0,x.length-1)),v=[],k=[],$=r.x;for(let t of x){let n=m.get(t)??0,o=n/w*M;if(0>=o)continue;k.push({cat:t,x:$,w:o});let i=y.get(t),l=r.y;for(let r of b){let a=i.get(r)??0;if(0>=a)continue;let s=a/n*h;v.push({type:"rect",x:$,y:l,w:o,h:s,style:{fill:e.resolveColor(r),stroke:"none"},datum:u(t,r,a),group:r}),l+=s}$+=o+a}return{nodes:v,overlays:d&&k.length>0?or(k,r.y+h+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}};import*as ws from"react";var Ms=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height||0===e.data.length)return{nodes:[]};let n=t.rowHeight??28,o=t.rowGap??12,i=!1!==t.showLabels,a=i?t.labelWidth??120:0,l=!1!==t.showTicks,s=l?14:0,c=t.tickFormat??(e=>e.toLocaleString()),u=r.x+a,d=Math.max(0,r.width-a);if(0>=d)return{nodes:[]};let h=Hi(t.categoryAccessor),f=e=>{let t=Number(e);return Number.isFinite(t)&&t>0?t:0},m=e=>f("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),p=e=>f("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),g=e=>{let r="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(r)?r.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})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,S=[],I=[];for(let t=0;e.data.length>t;t++){let i=e.data[t],a=g(i),l=m(i),c=p(i),f=Math.max(l,c,...a.length?a:[0]);if(0>=f)continue;let M=r.y+t*(n+o+s);if(M+n+s>r.y+r.height)break;I.push({yTop:M,label:h(i),actual:l,target:c,maxVal:f});let $=e=>u+e/f*d,A=h(i),C=e=>Ji(t=>{t("metric",A),"metric"!==y&&t(y,A),e(t)}),N=u;for(let e=0;a.length>e;e++){let t=$(a[e]),r=t-N;r>0&&S.push({type:"rect",x:N,y:M,w:r,h:n,style:{fill:k[Math.min(e,k.length-1)],stroke:"none"},datum:C(t=>{t("range",e),t("rangeValue",a[e]),t("kind","range")}),group:"range-"+e}),N=t}let F=Math.max(6,Math.floor(.45*n));S.push({type:"rect",x:u,y:M+(n-F)/2,w:$(l)-u,h:F,style:{fill:w,stroke:"none"},datum:C(e=>{e("value",l),e("kind","actual"),"value"!==x&&e(x,l)}),group:"actual"});let E=3,z=Math.floor(.8*n);S.push({type:"rect",x:$(c)-E/2,y:M+(n-z)/2,w:E,h:z,style:{fill:v,stroke:"none"},datum:C(e=>{e("target",c),e("kind","target"),"target"!==b&&e(b,c)}),group:"target"})}let C=[];for(let e=0;I.length>e;e++){let t=I[e];if(i&&C.push(pa({keyId:"bullet-label-"+e,text:t.label,x:r.x+a-8,y:t.yTop+n/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:$})),l){let r=t.yTop+n+2;for(let n=0;5>n;n++){let o=t.maxVal*n/4,i=u+o/t.maxVal*d;C.push(ws.createElement("line",{key:`bullet-tick-${e}-${n}`,x1:i,x2:i,y1:r,y2:r+3,stroke:A,strokeWidth:1}),pa({keyId:`bullet-ticktext-${e}-${n}`,text:c(o),x:i,y:r+12,anchor:0===n?"start":4===n?"end":"middle",baseline:"auto",fontSize:10,color:A}))}}}return{nodes:S,overlays:C.length>0?ws.createElement(ws.Fragment,null,...C):null}};import{jsx as vs,jsxs as ks}from"react/jsx-runtime";var $s=1.75,As=.635,Ss="#222222",Is=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height)return{nodes:[]};let n=Hi(t.categoryAccessor??"name"),o=Hi(t.teaVolumeAccessor??"teaVolume"),i=Hi(t.bobaVolumeAccessor??"bobaVolume"),a=Hi(t.iceVolumeAccessor??"iceVolume"),l=Hi(t.cupHeightAccessor??"cupHeight"),s=Hi(t.cupTopRadiusAccessor??"cupTopRadius"),c=Hi(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=Hi(t.bobaRadiusAccessor??"bobaRadius"),d=t.cupWidthRatio??.82,h=e.scales.o,f=h.bandwidth(),m=Math.max(1,r.height-26-8),p=r.y+8,g=[],y=[];for(let t of e.data){let r=n(t)+"",x=h(r);if(null==x)continue;let b={height:pr(l(t),15.5),topRadius:pr(s(t),4.75),bottomRadius:pr(c(t),3.75)},w=pr(u(t),.6),M=Math.max(0,pr(o(t),450)),v=Math.max(0,pr(i(t),110)),k=Math.max(0,pr(a(t),135)),$=Math.PI*w*w,A=Math.floor(v/$),S=A*$,I=Math.floor(k/5.359375),C=I*$s*$s*$s,N=M+S+C,F=cr(b,N),E=Math.min(b.height,Math.max(0,F)),z=lr(b,E),{pearls:R,layers:L}=hr(b,w,A),T=E,P=mr(b,L*w*2,T,I),j=b.height-20.32,O=Math.min(0,j),W=Math.min(f*d/(2*(b.topRadius+1)),m/(b.height-O)),D=x+f/2,q=e=>D+e*W,B=e=>p+(e-O)*W,V=q(-(b.topRadius+1)),G=q(b.topRadius+1),H=B(O),Y=B(b.height),_=aa({name:r,teaVolume:M,bobaVolume:Math.round(S),iceVolume:Math.round(C),totalVolume:Math.round(N),numBobas:A,numIce:I,kind:"boba cup"});g.push({type:"rect",x:V,y:H,w:Math.max(1,G-V),h:Math.max(1,Y-H),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:_,group:r,_transitionKey:"boba-"+la(r)});let X=b.height-T,K=la(r),U=e.resolveColor(r);y.push(
|
|
68
68
|
/* @__PURE__ */ks("g",{children:[M>0?/* @__PURE__ */vs("path",{d:`M${q(-z)},${B(X)} L${q(-b.bottomRadius)},${B(b.height)} L${q(b.bottomRadius)},${B(b.height)} L${q(z)},${B(X)} z`,fill:"#D2B799"}):null,R.map((e,t)=>/* @__PURE__ */vs("circle",{cx:q(e.x),cy:B(e.z),r:w*W,fill:"#222222",opacity:.5},"p-"+t)),P.map((e,t)=>/* @__PURE__ */vs("rect",{x:q(e.cx)-.95*$s*W/2,y:B(e.cy)-.95*$s*W/2,width:.95*$s*W,height:.95*$s*W,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${q(e.cx)} ${B(e.cy)})`},"i-"+t)),
|
|
69
69
|
/* @__PURE__ */vs("path",{d:`M${q(-b.topRadius)},${B(0)} L${q(-b.bottomRadius)},${B(b.height)} L${q(b.bottomRadius)},${B(b.height)} L${q(b.topRadius)},${B(0)}`,fill:"none",stroke:Ss,strokeWidth:2.5}),
|
|
70
70
|
/* @__PURE__ */vs("line",{x1:q(-(b.topRadius+1)),y1:B(0),x2:q(b.topRadius+1),y2:B(0),stroke:Ss,strokeWidth:3,strokeLinecap:"round"}),M>0?/* @__PURE__ */vs("path",{d:`M${q(-As)},${B(j)} L${q(-As)},${B(b.height-.4)} L${q(As)},${B(b.height-1.27-.4)} L${q(As)},${B(j)} z`,fill:"#4F91CB",stroke:Ss,strokeWidth:1,opacity:.78}):null,
|
|
71
71
|
/* @__PURE__ */vs("text",{x:D,y:Y+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:r}),
|
|
72
|
-
/* @__PURE__ */vs("text",{x:D,y:Y+30,textAnchor:"middle",fontSize:10,fill:U,children:`${A} pearls · ${Math.round(N)} cm³`})]},"boba-"+K))}return{nodes:g,overlays:/* @__PURE__ */vs("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},Cs=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Ns={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},Fs={tight:5,watch:12,comfortable:20};import*as Es from"react";var zs=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let r;if(this.tree[1]>e)r=this.count++,r===this.capacity&&this.grow();else{let t=1;for(;this.capacity>t;)t*=2,e>=this.tree[t]||t++;r=t-this.capacity}let n=this.capacity+r;for(this.tree[n]=t;n>1;){n=Math.floor(n/2);let e=this.minimum(n);if(this.tree[n]===e)break;this.tree[n]=e}return r}minimum(e){let t=this.tree[2*e],r=this.tree[2*e+1];return r>=t||Number.isNaN(r)?t:r}grow(){let 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)}},Rs=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height||0===e.data.length||!t?.domain)return{nodes:[]};let n=Er(t.laneAccessor),o=Er(t.startAccessor),i=Er(t.endAccessor),a=t.idAccessor?Er(t.idAccessor):null,l=t.unit??0,s=t.barGap??1.5,c=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,r)=>e.resolveColor(r)),[g,y]=t.domain,x=y-g||1,b=e=>r.x+(e-g)/x*r.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(n))]),v=Math.max(0,r.height-m)/Math.max(1,M.length),k=e=>b(o(e)),$=e=>Math.max(k(e)+c,b(i(e)+l)),A=[];M.forEach((t,o)=>{let i=r.y+o*v,l=e.data.filter(e=>n(e)===t);if(0===l.length)return;let{packed:c,trackCount:m}=Nr(l,{start:k,end:$}),g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map;for(let{item:e,track:t}of c){let r=y.get(t);r?r.push(e):y.set(t,[e])}for(let 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]))}let x=(v-2*h)/m,b=Math.min(d,Math.max(Math.min(u,x),x-s));for(let{item:e,track:r}of c){let n=k(e),o=g.get(e),l=$(e)-n;A.push({type:"rect",x:n,y:i+h+r*x,w:void 0!==o&&n+l>o-1?Math.max(1,o-1-n):l,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})}});let 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"})`,N=[];(t.periods??[]).forEach((e,t)=>{let n=b(e.start),o=Math.max(1,b(e.end+l)-n);N.push(Es.createElement("rect",{key:"period-"+t,x:n,y:r.y,width:o,height:r.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&N.push(Ja({keyId:"period-label-"+t,text:e.name,x:n+4,y:r.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:I}))});let F=!1!==t.showLaneLabels,E=t.laneLabelGap??12;if(M.forEach((e,t)=>{let n=r.y+t*v;N.push(Es.createElement("line",{key:"lane-sep-"+t,x1:r.x,x2:r.x+r.width,y1:n,y2:n,stroke:C,opacity:.45})),F&&N.push(Ja({keyId:"lane-label-"+t,text:e,x:r.x-E,y:n+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==t.showAxis){let e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));N.push(tl({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:r.y,tickLength:0,gridLength:r.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:I}))}return{nodes:A,overlays:Es.createElement(Es.Fragment,null,...N)}},Ls={width:60,height:34},Ts=e=>{let{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};let r=e.config.fixedAxis??"y",{positioned:n,byId:o}=Br(e.nodes,e.edges,t,e.config),i=n.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})),a=[],l=t=>("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(t):ba(t,e.config.sourceAccessor??"source",void 0))+"",s=t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):ba(t,e.config.targetAccessor??"target",void 0))+"";e.edges.forEach((e,t)=>{let n=o.get(l(e)),i=o.get(s(e));if(!n||!i)return;let{from:c,to:u}=Lr({cx:n.x,cy:n.y,width:n.width,height:n.height},{cx:i.x,cy:i.y,width:i.width,height:i.height},{orientation:"y"===r?"vertical":"horizontal"});a.push({type:"curved",pathD:zr(c,u,{orientation:"y"===r?"vertical":"horizontal",bend:Tr(t,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:Ma(e)??e})});let c=n.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:a,labels:c}};import{jsx as Ps,jsxs as js}from"react/jsx-runtime";var Os=1.15,Ws={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},Ds=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height||0===e.data.length)return{nodes:[]};let n=ya(t.textAccessor),o=e=>{let r=Number(ya(t.weightAccessor)(e));return Number.isFinite(r)&&r>0?r:0},i=ya(t.columnAccessor),a=e=>Number(ya(t.segmentAccessor)(e)),l=t.minFontSize??11,s=t.maxFontSize??42,c=t.columnGutter??18,u=t.collisionPadding??2,d=!1!==t.showColumnLabels,h=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,m=t.segmentTickFormat??(e=>Math.round(e)+""),p=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=[],$=/* @__PURE__ */new Map,A=1/0,S=-1/0;for(let t=0;e.data.length>t;t++){let r=e.data[t],l=i(r)+"",s=n(r)+"",c=o(r),u=a(r);!s||!Number.isFinite(u)||($.has(l)||(k.push(l),$.set(l,[])),$.get(l).push({col:l,text:s,weight:c,segment:u,datum:r,dataIndex:t}),A>u&&(A=u),u>S&&(S=u))}if(0===k.length)return{nodes:[]};if(!g)for(let[e,t]of $){let r=/* @__PURE__ */new Map;for(let e of t){let t=r.get(e.text);(!t||e.weight>t.weight)&&r.set(e.text,e)}$.set(e,[...r.values()])}let I=1/0,C=-1/0;for(let e of $.values())for(let t of e)I>t.weight&&(I=t.weight),t.weight>C&&(C=t.weight);if(!Number.isFinite(I))return{nodes:[]};let N=t.columnOrder?[...t.columnOrder.filter(e=>$.has(e)),...k.filter(e=>!t.columnOrder.includes(e))]:k,F=new Map(N.map(r=>[r,t.columnColor?.(r)||e.resolveColor(r)])),[E,z]=t.segmentDomain??[A,S],R=z-E||1,L=C-I||1,T=e=>l+Math.sqrt((e-I)/L)*(s-l),P=d?22:0,j=h?52:0,O=r.x+j,W=r.y+P,D=Math.max(0,r.width-j),q=Math.max(0,r.height-P),B=N.length,V=B>0?Math.max(0,D-c*Math.max(0,B-1))/B:0,G=W+14,H=W+q-14,Y=e=>G+(e-E)/R*(H-G),_=V*q,X=1/0,K=1/0,U=N.map((e,r)=>{let n=F.get(e),o=($.get(e)??[]).map(e=>{let o={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:r,resolvedColumnColor:n},i=t.wordOpacity?Number(t.wordOpacity(o)):1,a=t.wordColor?.(o);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:T(e.weight),opacity:Number.isFinite(i)?Ba(i,0,1):0,color:a||n,info:o}});if(0===o.length)return null;let i=0;for(let e of o){let t=1.05*Hr(e.text);i+=t*Os*e.baseFont*e.baseFont,K=Math.min(K,(V-8-1)/(t*e.baseFont))}return i>0&&(X=Math.min(X,Math.sqrt(x*_/i))),{col:e,colLeft:O+r*(V+c),center:O+r*(V+c)+V/2,rows:o}}).filter(e=>null!==e),Q=e=>{let t=[],r=0;for(let n of U){if(0>=V)continue;let o=n.colLeft+4,i=n.colLeft+V-4,a=n.rows.map((t,r)=>{let o=Math.max(5,e*t.baseFont),i=`${n.col}::${t.text}::${r}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:o,w:Yr(t.text,o),h:o*Os+2,anchorY:Y(t.segment),seed:(Gr(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)),l=[];for(let e of a){let a=e.w/2,s=e.h/2,c=Ba(n.center+e.seed,o+a,i-a),d=e.anchorY,h=c,f=Ba(d,G+s,H-s),m=!1;for(let t=0;2600>t;t++){let r=3.2*Math.sqrt(t),n=2.399963229728653*t,p={x:Ba(c+r*Math.cos(n),o+a,i-a),y:Ba(d+r*Math.sin(n),G+s,H-s),w:e.w,h:e.h};if(!_r(p,l,u)){h=p.x,f=p.y,m=!0;break}}m||r++,l.push({x:h,y:f,w:e.w,h:e.h});let g=Math.sqrt((e.weight-I)/L),y=p>0?2*(Gr(e.id+"r")-.5)*p: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:Aa(t=>{for(let r of Object.keys(e.info.datum))t(r,e.info.datum[r]);t("word",e.text),t("weight",e.weight),t("column",n.col),t("segment",e.segment),"word"!==b&&t(b,e.text),"weight"!==w&&t(w,e.weight),"column"!==M&&t(M,n.col),"segment"!==v&&t(v,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:r}},Z=y?Math.min(1,X,K):Math.min(1,K),J=Q(Z);if(y)for(let e=0;6>e&&J.unplaced>0&&Z>.1;e++)Z*=.88,J=Q(Z);let ee=J.placed.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{let t=Yr(e.text,e.fontSize)/2,r=e.fontSize*Os/2;return{type:"rect",x:e.x-t,y:e.y-r,w:2*t,h:2*r,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:/* @__PURE__ */js("g",{className:"semiotic-word-trails",children:[h&&Xr({x:r.x+j-10,yTop:G,yBot:H,segLo:E,segHi:z,segToY:Y,tickCount:f,tickFormat:m,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:r.x}),d&&N.map((e,t)=>V>0?/* @__PURE__ */Ps("text",{x:O+t*(V+c)+V/2,y:r.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:F.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ee.map(e=>/* @__PURE__ */Ps("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))]})}},qs={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Bs=8,Vs=rn,Gs=2*Math.PI;import{jsx as Hs,jsxs as Ys}from"react/jsx-runtime";var _s="var(--semiotic-text, currentColor)",Xs=/* @__PURE__ */new Set(["rows"]),Ks=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{let t=this.options.parseMessage(e.data),r=t.requestId,n=null!=r?this.pending.get(r):this.pending.values().next().value;if(n){if(null!=r)this.pending.delete(r);else{for(let e of this.pending.values())e!==n&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}if(n.cleanup(),!t.ok)return void n.reject(t.error);n.resolve(t.payload)}},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(Jn(this.options.name));let r=this.nextRequestId;this.nextRequestId+=1;let n=this.options.encodeRequest?.(r,e)??{requestId:r,request:e};return new Promise((e,o)=>{let i=()=>{let e=1===this.pending.size;this.pending.delete(r),t?.removeEventListener("abort",i),o(Jn(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},a=()=>t?.removeEventListener("abort",i);this.pending.set(r,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(n)}catch(e){this.pending.delete(r),a(),o(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(let t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Us=class{constructor(e=no()){this.session=new Ks({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{let t=e,{requestId:r,error:n}=(o=t)&&"object"==typeof o?{requestId:o.requestId,error:o.error}:{};var o;return n?{requestId:r,ok:!1,error:eo(n)}:{requestId:r,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()}},Qs=function(){let e=null;return{get:()=>((!e||e.isDead)&&(e=new Us),e),resetForTest:()=>{if(e){try{e.terminate()}catch{}e=null}}}}(),Zs=[.1,.5,.9],Js=1e6,ec="down",tc=24,rc=.12,nc=.55,oc=0,ic=1;export{Vi as DEFAULT_AREA_PER_ANNOTATION,Va as DEFAULT_GLYPH_ANCHOR,qa as DEFAULT_GLYPH_VIEWBOX,Bs as DEFAULT_HIT_RADIUS,Il as DEFAULT_ISOMETRIC_SPRITE_SIZES,Cs as GRID_FUEL_KEYS,Ns as GRID_FUEL_LABELS,Ra as LayoutCache,za as SYMBOL_SEQUENCE,Gs as TAU,la as absorbRegion,Fr as activeCountOverDomain,kn as addPoints,hs as adjacencyFlowLayout,pi as adjacencyMatrix,Ut as aggregateAdjacencyFlow,Ui as aggregateRegionCounts,e as allocateCells,vt as analyzeNetEnsemble,bn as angleScale,Hi as annotationBudget,_i as annotationDensity,Ki as annotationLayout,hi as arcLayout,fi as arcPath,ci as arrivalReplay,Ts as axisFixedForceLayout,Br as axisFixedForcePositions,o as balanceSnapshotsToFlows,Ja as bandLabel,_n as betweenness,Gn as bfsDistances,Is as bobaLayout,ca as bodyGroupSpec,Qa as boundsOf,Lr as boxEdgeAnchors,Bn as buildAdjacency,Rn as buildTooltipEntries,Ms as bulletLayout,pa as calendarLayout,ia as capacitatedRegion,ra as chargeGateRegion,mi as circularLayout,Ba as clamp,Xn as closeness,Kn as clustering,oi as collidersFromScales,Ao as comparePhysicsTrace,Wo as composePhysicsControllers,ha as computeTransitDiagramPositions,Fa as countPairwiseCrossings,jo as createCapacityQueueController,Go as createDependencyGateController,Do as createPortalController,Eo as createProcessJourneyLedger,Vo as createServiceLevelController,qo as createServiceResourcePoolController,Or as cubicPath,Pr as cubicPoint,jr as cubicTangent,zr as curvedEdgePath,an as cyclicRangeContains,_l as dagreLayout,Vn as degree,xr as demandForecastRows,Qo as describePhysicsStageGeography,M as diagnoseTokenEncoding,Na as dimFor,Yn as egoNetwork,un as estimateLabelWidth,zn as extractTooltipDatum,Tr as fanOutBend,Yl as flextreeLayout,sa as forceFieldRegion,s as forceLayout,io as forceLayoutAsync,Sr as formatMw,Ir as formatReservePct,Ln as formatTooltipValue,ii as galtonPegs,b as generateTokens,Zr as geoAreaHitTarget,Qr as geoHitTarget,Hl as geographicDotGridLayout,jl as geographicGridLayout,_a as glyphExtent,Ua as glyphFractionClipRect,Ha as glyphPlacement,$r as gridEventAnnotations,he as gridifyGeographicPoints,ka as groupBy,Zi as groupCompletionRows,el as hatchFill,Ur as hitTargetPoint,Jr as hitTargetRect,Za as hullFromBoxes,Rs as intervalLanesLayout,Rl as isometricLandmarkLayout,yl as isotypeBoltGlyph,xl as isotypeBusGlyph,gl as isotypeChipGlyph,ml as isotypeGhost,hl as isotypeInk,Ml as isotypeNetworkGlyphs,fl as isotypePaper,wl as isotypePersonGlyph,bl as isotypePersonPath,pl as isotypeServerGlyph,cn as layoutChipStrip,sn as layoutSequence,w as layoutTokenGrid,Nn as legendGroupsFrom,Fn as legendSwatches,rs as lineageDagLayout,tl as linearAxis,Ta as makeShade,bs as marimekkoLayout,rl as markCallout,Ia as matchesHighlight,Ya as mean,ta as membraneRegion,as as mermaidDagLayout,ki as mobileAnnotationStrategy,Fi as mobileAreaChartRecipe,ji as mobileBrushAlternatives,Pi as mobileChartFamilyRecipe,Li as mobileGeoChartRecipe,Ni as mobileLineChartRecipe,Ri as mobileNetworkChartRecipe,Ei as mobileOrdinalChartRecipe,zi as mobileScatterplotRecipe,Ti as mobileSmallMultipleRecipe,ga as motifBraidLayout,Wi as mulberry32,us as netEnsembleLayout,tn as networkEdgeHitTarget,en as networkHitTarget,Ga as nonNegativeFinite,In as normalizePoint,Un as normalizeScores,m as normalizeTokenEncoding,fa as octilinearRoute,ma as offsetTransitPath,$a as orderByBarycenter,di as orderByGroupDegree,Ca as orderExactSmall,Rr as orthogonalEdgePath,va as packBandsBySilhouette,Nr as packIntervals,dn as packSpanLevels,gs as packedClusterMatrix,nl as parallelCoordinatesLayout,pn as partitionSharedEdges,Ko as physicsChargePoint,Xo as physicsDestination,wo as physicsReferenceEnvelope,Uo as physicsStageColliders,_o as physicsStageGeography,wa as placeWithMinGap,Sn as pointMagnitude,yn as polarToXY,aa as portalRegion,yt as prepareMotifBraid,gt as prepareNetworkAtlasAsync,oa as pressureFieldRegion,da as processChrome,Ro as processJourneyRows,ua as processLaneWalls,Ji as processStageLayout,ea as processStageRegions,so as processVolumePolygons,Qn as proximityProblem,wn as radiusScale,ba as readField,Wr as rectCollide,Sa as refineByAdjacentSwaps,Qi as regionCountsToProjectionRows,vr as reserveAnnotationBands,br as reserveMarginPct,wr as reserveSeries,Mn as ringArcPath,Ka as roundedEnclosure,Oi as roundedTransitPath,na as routeSurfaceRegion,Vs as runLengthEncode,rn as runs,Le as sampleGeographicDotGrid,hn as scaleArcBand,An as scalePoint,li as sedimentBake,ln as selectCyclicRange,ne as selectIsometricLandmarks,ja as shade,on as shortestArcDelta,Hn as shortestPath,Ea as signatureKey,fn as spanArcPath,mn as spanArcPeakY,ai as spawnFromTokens,yr as stackFuelSeries,lo as stageTargetInVolume,$n as subtractPoints,A as suggestTokenEncoding,kr as summarizeOperatingPoint,Oa as symbolExtent,La as symbolPathString,Pa as symbolRadius,Mr as thresholdBandsForReserve,Ar as tightestHours,H as tokenLayer,$ as tokenTaskIntentToCapabilityIntents,Kl as transitDiagramLayout,a as unitize,l as unitizeRange,Ma as unwrapDatum,zo as updateProcessJourney,ol as waffleLayout,Xa as withAlpha,Ds as wordTrailsLayout,Vr as wordTrailsProgressiveReveal,nn as wrapValue,xn as xyToAngle};
|
|
72
|
+
/* @__PURE__ */vs("text",{x:D,y:Y+30,textAnchor:"middle",fontSize:10,fill:U,children:`${A} pearls · ${Math.round(N)} cm³`})]},"boba-"+K))}return{nodes:g,overlays:/* @__PURE__ */vs("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},Cs=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Ns={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},Fs={tight:5,watch:12,comfortable:20};import*as Es from"react";var zs=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let r;if(this.tree[1]>e)r=this.count++,r===this.capacity&&this.grow();else{let t=1;for(;this.capacity>t;)t*=2,e>=this.tree[t]||t++;r=t-this.capacity}let n=this.capacity+r;for(this.tree[n]=t;n>1;){n=Math.floor(n/2);let e=this.minimum(n);if(this.tree[n]===e)break;this.tree[n]=e}return r}minimum(e){let t=this.tree[2*e],r=this.tree[2*e+1];return r>=t||Number.isNaN(r)?t:r}grow(){let 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)}},Rs=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height||0===e.data.length||!t?.domain)return{nodes:[]};let n=Er(t.laneAccessor),o=Er(t.startAccessor),i=Er(t.endAccessor),a=t.idAccessor?Er(t.idAccessor):null,l=t.unit??0,s=t.barGap??1.5,c=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,r)=>e.resolveColor(r)),[g,y]=t.domain,x=y-g||1,b=e=>r.x+(e-g)/x*r.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(n))]),v=Math.max(0,r.height-m)/Math.max(1,M.length),k=e=>b(o(e)),$=e=>Math.max(k(e)+c,b(i(e)+l)),A=[];M.forEach((t,o)=>{let i=r.y+o*v,l=e.data.filter(e=>n(e)===t);if(0===l.length)return;let{packed:c,trackCount:m}=Nr(l,{start:k,end:$}),g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map;for(let{item:e,track:t}of c){let r=y.get(t);r?r.push(e):y.set(t,[e])}for(let 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]))}let x=(v-2*h)/m,b=Math.min(d,Math.max(Math.min(u,x),x-s));for(let{item:e,track:r}of c){let n=k(e),o=g.get(e),l=$(e)-n;A.push({type:"rect",x:n,y:i+h+r*x,w:void 0!==o&&n+l>o-1?Math.max(1,o-1-n):l,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})}});let 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"})`,N=[];(t.periods??[]).forEach((e,t)=>{let n=b(e.start),o=Math.max(1,b(e.end+l)-n);N.push(Es.createElement("rect",{key:"period-"+t,x:n,y:r.y,width:o,height:r.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&N.push(pa({keyId:"period-label-"+t,text:e.name,x:n+4,y:r.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:I}))});let F=!1!==t.showLaneLabels,E=t.laneLabelGap??12;if(M.forEach((e,t)=>{let n=r.y+t*v;N.push(Es.createElement("line",{key:"lane-sep-"+t,x1:r.x,x2:r.x+r.width,y1:n,y2:n,stroke:C,opacity:.45})),F&&N.push(pa({keyId:"lane-label-"+t,text:e,x:r.x-E,y:n+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==t.showAxis){let e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));N.push(ya({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:r.y,tickLength:0,gridLength:r.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:I}))}return{nodes:A,overlays:Es.createElement(Es.Fragment,null,...N)}},Ls={width:60,height:34},Ts=e=>{let{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};let r=e.config.fixedAxis??"y",{positioned:n,byId:o}=Br(e.nodes,e.edges,t,e.config),i=n.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})),a=[],l=t=>("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(t):_i(t,e.config.sourceAccessor??"source",void 0))+"",s=t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):_i(t,e.config.targetAccessor??"target",void 0))+"";e.edges.forEach((e,t)=>{let n=o.get(l(e)),i=o.get(s(e));if(!n||!i)return;let{from:c,to:u}=Lr({cx:n.x,cy:n.y,width:n.width,height:n.height},{cx:i.x,cy:i.y,width:i.width,height:i.height},{orientation:"y"===r?"vertical":"horizontal"});a.push({type:"curved",pathD:zr(c,u,{orientation:"y"===r?"vertical":"horizontal",bend:Tr(t,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:Ki(e)??e})});let c=n.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:a,labels:c}};import{jsx as Ps,jsxs as js}from"react/jsx-runtime";var Os=1.15,Ws={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},Ds=e=>{let t=e.config,{plot:r}=e.dimensions;if(0>=r.width||0>=r.height||0===e.data.length)return{nodes:[]};let n=Hi(t.textAccessor),o=e=>{let r=Number(Hi(t.weightAccessor)(e));return Number.isFinite(r)&&r>0?r:0},i=Hi(t.columnAccessor),a=e=>Number(Hi(t.segmentAccessor)(e)),l=t.minFontSize??11,s=t.maxFontSize??42,c=t.columnGutter??18,u=t.collisionPadding??2,d=!1!==t.showColumnLabels,h=!1!==t.showSegmentAxis,f=t.segmentTickCount??6,m=t.segmentTickFormat??(e=>Math.round(e)+""),p=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=[],$=/* @__PURE__ */new Map,A=1/0,S=-1/0;for(let t=0;e.data.length>t;t++){let r=e.data[t],l=i(r)+"",s=n(r)+"",c=o(r),u=a(r);!s||!Number.isFinite(u)||($.has(l)||(k.push(l),$.set(l,[])),$.get(l).push({col:l,text:s,weight:c,segment:u,datum:r,dataIndex:t}),A>u&&(A=u),u>S&&(S=u))}if(0===k.length)return{nodes:[]};if(!g)for(let[e,t]of $){let r=/* @__PURE__ */new Map;for(let e of t){let t=r.get(e.text);(!t||e.weight>t.weight)&&r.set(e.text,e)}$.set(e,[...r.values()])}let I=1/0,C=-1/0;for(let e of $.values())for(let t of e)I>t.weight&&(I=t.weight),t.weight>C&&(C=t.weight);if(!Number.isFinite(I))return{nodes:[]};let N=t.columnOrder?[...t.columnOrder.filter(e=>$.has(e)),...k.filter(e=>!t.columnOrder.includes(e))]:k,F=new Map(N.map(r=>[r,t.columnColor?.(r)||e.resolveColor(r)])),[E,z]=t.segmentDomain??[A,S],R=z-E||1,L=C-I||1,T=e=>l+Math.sqrt((e-I)/L)*(s-l),P=d?22:0,j=h?52:0,O=r.x+j,W=r.y+P,D=Math.max(0,r.width-j),q=Math.max(0,r.height-P),B=N.length,V=B>0?Math.max(0,D-c*Math.max(0,B-1))/B:0,G=W+14,H=W+q-14,Y=e=>G+(e-E)/R*(H-G),_=V*q,X=1/0,K=1/0,U=N.map((e,r)=>{let n=F.get(e),o=($.get(e)??[]).map(e=>{let o={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:r,resolvedColumnColor:n},i=t.wordOpacity?Number(t.wordOpacity(o)):1,a=t.wordColor?.(o);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:T(e.weight),opacity:Number.isFinite(i)?sa(i,0,1):0,color:a||n,info:o}});if(0===o.length)return null;let i=0;for(let e of o){let t=1.05*Hr(e.text);i+=t*Os*e.baseFont*e.baseFont,K=Math.min(K,(V-8-1)/(t*e.baseFont))}return i>0&&(X=Math.min(X,Math.sqrt(x*_/i))),{col:e,colLeft:O+r*(V+c),center:O+r*(V+c)+V/2,rows:o}}).filter(e=>null!==e),Q=e=>{let t=[],r=0;for(let n of U){if(0>=V)continue;let o=n.colLeft+4,i=n.colLeft+V-4,a=n.rows.map((t,r)=>{let o=Math.max(5,e*t.baseFont),i=`${n.col}::${t.text}::${r}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:o,w:Yr(t.text,o),h:o*Os+2,anchorY:Y(t.segment),seed:(Gr(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)),l=[];for(let e of a){let a=e.w/2,s=e.h/2,c=sa(n.center+e.seed,o+a,i-a),d=e.anchorY,h=c,f=sa(d,G+s,H-s),m=!1;for(let t=0;2600>t;t++){let r=3.2*Math.sqrt(t),n=2.399963229728653*t,p={x:sa(c+r*Math.cos(n),o+a,i-a),y:sa(d+r*Math.sin(n),G+s,H-s),w:e.w,h:e.h};if(!_r(p,l,u)){h=p.x,f=p.y,m=!0;break}}m||r++,l.push({x:h,y:f,w:e.w,h:e.h});let g=Math.sqrt((e.weight-I)/L),y=p>0?2*(Gr(e.id+"r")-.5)*p: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:Ji(t=>{for(let r of Object.keys(e.info.datum))t(r,e.info.datum[r]);t("word",e.text),t("weight",e.weight),t("column",n.col),t("segment",e.segment),"word"!==b&&t(b,e.text),"weight"!==w&&t(w,e.weight),"column"!==M&&t(M,n.col),"segment"!==v&&t(v,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:r}},Z=y?Math.min(1,X,K):Math.min(1,K),J=Q(Z);if(y)for(let e=0;6>e&&J.unplaced>0&&Z>.1;e++)Z*=.88,J=Q(Z);let ee=J.placed.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{let t=Yr(e.text,e.fontSize)/2,r=e.fontSize*Os/2;return{type:"rect",x:e.x-t,y:e.y-r,w:2*t,h:2*r,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:/* @__PURE__ */js("g",{className:"semiotic-word-trails",children:[h&&Xr({x:r.x+j-10,yTop:G,yBot:H,segLo:E,segHi:z,segToY:Y,tickCount:f,tickFormat:m,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:r.x}),d&&N.map((e,t)=>V>0?/* @__PURE__ */Ps("text",{x:O+t*(V+c)+V/2,y:r.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:F.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ee.map(e=>/* @__PURE__ */Ps("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))]})}},qs={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Bs=8,Vs=rn,Gs=2*Math.PI;import{jsx as Hs,jsxs as Ys}from"react/jsx-runtime";var _s="var(--semiotic-text, currentColor)",Xs=/* @__PURE__ */new Set(["rows"]),Ks=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{let t=this.options.parseMessage(e.data),r=t.requestId,n=null!=r?this.pending.get(r):this.pending.values().next().value;if(n){if(null!=r)this.pending.delete(r);else{for(let e of this.pending.values())e!==n&&(e.cleanup(),e.reject(Error(this.options.name+" worker response missing requestId")));this.pending.clear()}if(n.cleanup(),!t.ok)return void n.reject(t.error);n.resolve(t.payload)}},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(Jn(this.options.name));let r=this.nextRequestId;this.nextRequestId+=1;let n=this.options.encodeRequest?.(r,e)??{requestId:r,request:e};return new Promise((e,o)=>{let i=()=>{let e=1===this.pending.size;this.pending.delete(r),t?.removeEventListener("abort",i),o(Jn(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},a=()=>t?.removeEventListener("abort",i);this.pending.set(r,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(n)}catch(e){this.pending.delete(r),a(),o(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(let t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Us=class{constructor(e=no()){this.session=new Ks({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{let t=e,{requestId:r,error:n}=(o=t)&&"object"==typeof o?{requestId:o.requestId,error:o.error}:{};var o;return n?{requestId:r,ok:!1,error:eo(n)}:{requestId:r,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()}},Qs=function(){let e=null;return{get:()=>((!e||e.isDead)&&(e=new Us),e),resetForTest:()=>{if(e){try{e.terminate()}catch{}e=null}}}}(),Zs=[.1,.5,.9],Js=1e6,ec="down",tc=24,rc=.12,nc=.55,oc=0,ic=1;export{Za as DEFAULT_AREA_PER_ANNOTATION,Ea as DEFAULT_GLYPH_ANCHOR,Fa as DEFAULT_GLYPH_VIEWBOX,Bs as DEFAULT_HIT_RADIUS,Il as DEFAULT_ISOMETRIC_SPRITE_SIZES,Cs as GRID_FUEL_KEYS,Ns as GRID_FUEL_LABELS,na as LayoutCache,Ma as SYMBOL_SEQUENCE,Gs as TAU,_a as absorbRegion,Fr as activeCountOverDomain,kn as addPoints,hs as adjacencyFlowLayout,pi as adjacencyMatrix,Ut as aggregateAdjacencyFlow,za as aggregateRegionCounts,e as allocateCells,vt as analyzeNetEnsemble,bn as angleScale,el as annotationBudget,rl as annotationDensity,Wi as annotationLayout,hi as arcLayout,fi as arcPath,ci as arrivalReplay,Ts as axisFixedForceLayout,Br as axisFixedForcePositions,o as balanceSnapshotsToFlows,pa as bandLabel,_n as betweenness,Gn as bfsDistances,Is as bobaLayout,Ka as bodyGroupSpec,fa as boundsOf,Lr as boxEdgeAnchors,Bn as buildAdjacency,Rn as buildTooltipEntries,Ms as bulletLayout,Vi as calendarLayout,Ha as capacitatedRegion,Ba as chargeGateRegion,mi as circularLayout,sa as clamp,Xn as closeness,Kn as clustering,oi as collidersFromScales,Ao as comparePhysicsTrace,Wo as composePhysicsControllers,tl as computeTransitDiagramPositions,Zi as countPairwiseCrossings,jo as createCapacityQueueController,Go as createDependencyGateController,Do as createPortalController,Eo as createProcessJourneyLedger,Vo as createServiceLevelController,qo as createServiceResourcePoolController,Or as cubicPath,Pr as cubicPoint,jr as cubicTangent,zr as curvedEdgePath,an as cyclicRangeContains,_l as dagreLayout,Vn as degree,xr as demandForecastRows,Qo as describePhysicsStageGeography,M as diagnoseTokenEncoding,ta as dimFor,Yn as egoNetwork,un as estimateLabelWidth,zn as extractTooltipDatum,Tr as fanOutBend,Yl as flextreeLayout,Xa as forceFieldRegion,s as forceLayout,io as forceLayoutAsync,Sr as formatMw,Ir as formatReservePct,Ln as formatTooltipValue,ii as galtonPegs,b as generateTokens,Zr as geoAreaHitTarget,Qr as geoHitTarget,Hl as geographicDotGridLayout,jl as geographicGridLayout,Ta as glyphExtent,Oa as glyphFractionClipRect,Ra as glyphPlacement,$r as gridEventAnnotations,he as gridifyGeographicPoints,Qi as groupBy,Pa as groupCompletionRows,ga as hatchFill,Ur as hitTargetPoint,Jr as hitTargetRect,ma as hullFromBoxes,Rs as intervalLanesLayout,Rl as isometricLandmarkLayout,yl as isotypeBoltGlyph,xl as isotypeBusGlyph,gl as isotypeChipGlyph,ml as isotypeGhost,hl as isotypeInk,Ml as isotypeNetworkGlyphs,fl as isotypePaper,wl as isotypePersonGlyph,bl as isotypePersonPath,pl as isotypeServerGlyph,cn as layoutChipStrip,sn as layoutSequence,w as layoutTokenGrid,Nn as legendGroupsFrom,Fn as legendSwatches,rs as lineageDagLayout,ya as linearAxis,oa as makeShade,bs as marimekkoLayout,Oi as markCallout,ea as matchesHighlight,ua as mean,Da as membraneRegion,as as mermaidDagLayout,ki as mobileAnnotationStrategy,Fi as mobileAreaChartRecipe,ji as mobileBrushAlternatives,Pi as mobileChartFamilyRecipe,Li as mobileGeoChartRecipe,Ni as mobileLineChartRecipe,Ri as mobileNetworkChartRecipe,Ei as mobileOrdinalChartRecipe,zi as mobileScatterplotRecipe,Ti as mobileSmallMultipleRecipe,Bi as motifBraidLayout,wa as mulberry32,us as netEnsembleLayout,tn as networkEdgeHitTarget,en as networkHitTarget,ca as nonNegativeFinite,In as normalizePoint,Un as normalizeScores,m as normalizeTokenEncoding,nl as octilinearRoute,Di as offsetTransitPath,Yi as orderByBarycenter,di as orderByGroupDegree,Ui as orderExactSmall,Rr as orthogonalEdgePath,Gi as packBandsBySilhouette,Nr as packIntervals,dn as packSpanLevels,gs as packedClusterMatrix,ba as parallelCoordinatesLayout,pn as partitionSharedEdges,Ko as physicsChargePoint,Xo as physicsDestination,wo as physicsReferenceEnvelope,Uo as physicsStageColliders,_o as physicsStageGeography,qa as placeWithMinGap,Sn as pointMagnitude,yn as polarToXY,Ya as portalRegion,yt as prepareMotifBraid,gt as prepareNetworkAtlasAsync,Ga as pressureFieldRegion,Ja as processChrome,Ro as processJourneyRows,Qa as processLaneWalls,ja as processStageLayout,Wa as processStageRegions,so as processVolumePolygons,Qn as proximityProblem,wn as radiusScale,_i as readField,Wr as rectCollide,Xi as refineByAdjacentSwaps,La as regionCountsToProjectionRows,vr as reserveAnnotationBands,br as reserveMarginPct,wr as reserveSeries,Mn as ringArcPath,ha as roundedEnclosure,qi as roundedTransitPath,Va as routeSurfaceRegion,Vs as runLengthEncode,rn as runs,Le as sampleGeographicDotGrid,hn as scaleArcBand,An as scalePoint,li as sedimentBake,ln as selectCyclicRange,ne as selectIsometricLandmarks,ia as shade,on as shortestArcDelta,Hn as shortestPath,ra as signatureKey,fn as spanArcPath,mn as spanArcPeakY,ai as spawnFromTokens,yr as stackFuelSeries,lo as stageTargetInVolume,$n as subtractPoints,A as suggestTokenEncoding,kr as summarizeOperatingPoint,Ia as symbolExtent,ka as symbolPathString,Aa as symbolRadius,Mr as thresholdBandsForReserve,Ar as tightestHours,H as tokenLayer,$ as tokenTaskIntentToCapabilityIntents,Kl as transitDiagramLayout,a as unitize,l as unitizeRange,Ki as unwrapDatum,zo as updateProcessJourney,ol as waffleLayout,da as withAlpha,Ds as wordTrailsLayout,Vr as wordTrailsProgressiveReveal,nn as wrapValue,xn as xyToAngle};
|