@graphysdk/viz-engine 1.9.0-beta.1789732501098 → 1.9.0-beta.1789737596195
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/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var im=Object.create,Ro=Object.defineProperty,om=Object.getOwnPropertyDescriptor,sm=Object.getOwnPropertyNames,lm=Object.getPrototypeOf,cm=Object.prototype.hasOwnProperty,um=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=sm(t),i=0,o=a.length,s;i<o;i++)s=a[i],!cm.call(e,s)&&s!==r&&Ro(e,s,{get:(c=>t[c]).bind(null,s),enumerable:!(n=om(t,s))||n.enumerable});return e},sr=(e,t,r)=>(r=e!=null?im(lm(e)):{},um(t||!e||!e.__esModule?Ro(r,"default",{value:e,enumerable:!0}):r,e));const l=require("./config.types-Ca10IwFf.cjs");let Se=require("color2k"),Co=require("date-fns"),tt=require("lodash-es"),it=require("d3-time"),dm=require("date-fns/differenceInDays"),Ee=require("d3-regression"),ie=require("d3-scale"),ze=require("d3-interpolate"),N=require("d3-scale-chromatic"),Ye=require("lodash-es/clamp");Ye=sr(Ye,1);let qt=require("lodash-es/merge");qt=sr(qt,1);let zr=require("humanize-duration");zr=sr(zr,1);let je=require("d3-shape"),mm=require("d3-delaunay"),Xt=require("lodash-es/isEqual");Xt=sr(Xt,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1789732501098");var pm=1e6;function Z(e){return String(Math.round(e*pm))}var ka="#FFFFFF",Mr="#1A1A1A",hm=4.5,Vo=e=>{try{return(0,Se.getContrast)(e,ka)>(0,Se.getContrast)(e,Mr)?ka:Mr}catch{return Mr}},fm=(e,t)=>{try{const r=Mo(void 0,t);return r===void 0||(0,Se.getContrast)(r,e)>=hm?e:Vo(r)}catch{return e}},Mo=(e,t)=>{try{if(e===void 0){const[,,,n]=(0,Se.parseToRgba)(t);return n>=1?t:void 0}const[,,,r]=(0,Se.parseToRgba)(e);return r>=1?e:(0,Se.parseToRgba)(t)[3]<1?void 0:(0,Se.mix)(t,(0,Se.opacify)(e,1),r)}catch{return}},oe=Math.PI*2,gm=8,ym=1e-9,vm=[0,Math.PI/2,Math.PI,oe*3/4],ut=(e,t)=>Math.abs(t-e)>=oe-ym,Ve=e=>(e%oe+oe)%oe,Zt=(e,t,r)=>{if(ut(t,r))return!0;const n=Ve(r-t);return Ve(e-t)<=n},qe=(e,t)=>{const r=Math.abs(Ve(e)-Ve(t));return Math.min(r,oe-r)},Na=(e,t)=>{const r=Ve(t-e);return r>Math.PI?r-oe:r},Do=(e,t,r)=>e*oe+t+r,se=(e,t)=>({x:t*Math.sin(e),y:t*Math.cos(e)}),we=(e,t)=>{const r=se(e,t);return{x:.5+r.x/2,y:.5+r.y/2}},bm=(e,t,r,n)=>{const a=[we(e,r),we(e,n),we(t,r),we(t,n)],i=Math.max(r,n),o=vm.filter(c=>Zt(c,e,t)).map(c=>we(c,i)),s=[...a,...o];return{xMin:Math.min(...s.map(c=>c.x)),xMax:Math.max(...s.map(c=>c.x)),yMin:Math.min(...s.map(c=>c.y)),yMax:Math.max(...s.map(c=>c.y))}},lr=(e,t)=>({angle:Ve(Math.atan2(e,t)),radius:Math.hypot(e,t)}),cr=(e,t)=>{const r=e.x-.5,n=e.y-.5;return{x:t>=1?r*2*t:r*2,y:t>=1?n*2:n*2/t}},pn=(e,t)=>{const{x:r,y:n}=cr(e,t);return lr(r,n)};function V(e){return e[l.POSITION_VARIABLES.x]}function R(e){return e[l.POSITION_VARIABLES.y]}function z(e){return e[l.POSITION_VARIABLES.xMin]}function W(e){return e[l.POSITION_VARIABLES.xMax]}function B(e){return e[l.POSITION_VARIABLES.yMin]}function _(e){return e[l.POSITION_VARIABLES.yMax]}function hn(e){return e[l.POSITION_VARIABLES.yRaw]}function Sm(e,t){return e[l.resolveScaledAestheticVariable(t)]}var Am={xMin:0,xMax:1,yMin:0,yMax:1},fn=(e,t)=>{const r=z(e)??V(e),n=W(e)??V(e),a=B(e)??R(e),i=_(e)??R(e);return!l.isStrictNumericDataValue(r)||!l.isStrictNumericDataValue(n)||!l.isStrictNumericDataValue(a)||!l.isStrictNumericDataValue(i)?null:t.type!=="polar"?{xMin:r,xMax:n,yMin:a,yMax:i}:{...bm(r,n,a,i),space:"disk"}},yt=(e,t)=>{const r=(e.xMin+e.xMax)/2,n=(e.yMin+e.yMax)/2;switch(t){case"top":return{x:r,y:e.yMax};case"bottom":return{x:r,y:e.yMin};case"left":return{x:e.xMin,y:n};case"right":return{x:e.xMax,y:n};case"top-left":return{x:e.xMin,y:e.yMax};case"top-right":return{x:e.xMax,y:e.yMax};case"bottom-left":return{x:e.xMin,y:e.yMin};case"bottom-right":return{x:e.xMax,y:e.yMin};default:return{x:r,y:n}}},Po=e=>yt(Am,e),j=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return()=>r;const n=l.readVariableName(t);return l.isDefined(n)?a=>{const i=a[n];return i===void 0?null:_o(i,e.getType(n))}:()=>null},xm=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return()=>r;const n=l.readVariableName(t);if(!l.isDefined(n)||!e.hasVariable(n))return()=>null;const a=e.getValues(n),i=e.getType(n);return o=>{const s=a[o];return s===void 0?null:_o(s,i)}},rt=(e,t)=>j(e,t.x),gn=(e,t)=>j(e,t.y),Im=(e,t)=>j(e,t.label),Oo=(e,t)=>j(e,t.color),Tm=(e,t)=>j(e,t.size),Lm=(e,t)=>j(e,t.alpha),Em=(e,t)=>j(e,t.group),wm=(e,t)=>j(e,t.strokeWidth),_o=(e,t)=>{switch(t){case"numeric":return l.isStrictNumericDataValue(e)?e:null;case"categorical":return l.isStrictCategoricalDataValue(e)?e:null;case"temporal":return l.isStrictTemporalDataValue(e)?e:null;default:return null}},Ba={variable:l.POSITION_VARIABLES.yRaw};function vt(e,t){return l.isStackedPosition(e)?Ba:t.y??Ba}function bt(e){return j(e.data,vt(e.position,e.mapping))}function Rm(e){return xm(e.data,vt(e.position,e.mapping))}var Pe=e=>{const t=l.readVariableName(e.mapping.x);return t!==null&&t!==l.CONSTANT_VARIABLES.x?t:l.GROUP_VARIABLES.group},yn=e=>Cm(e)?l.readVariableName(e.mapping.y):null,ko=e=>yn(e)===null?null:bt(e),vn=e=>e.spatialKind!=="cells",Cm=e=>e.spatialKind==="points"||e.spatialKind==="cells",No=(e,t)=>e.yScaleType===t.yScaleType&&Kr(e.valueFormat)===Kr(t.valueFormat),Wr=e=>`${e.yScaleType} y axis, ${Kr(e.valueFormat)}`,Kr=e=>e.type==="currency"?`${e.type}:${e.iso}`:e.type,Bo=(e,t)=>{const r=l.toExplicitValueFormat(e.data.getValueFormat(Pe(e))),n=yn(e);return a=>({...a,anchorValue:l.parseAddressingValue(a.anchorValue,r,t),...a.groupValue!==void 0&&{groupValue:l.parseAddressingValue(a.groupValue,l.toExplicitValueFormat(e.data.getValueFormat(l.GROUP_VARIABLES.group)),t)},...a.crossValue!==void 0&&n!==null&&{crossValue:l.parseAddressingValue(a.crossValue,l.toExplicitValueFormat(e.data.getValueFormat(n)),t)}})};function Fo(e){return e instanceof l.VizError?{severity:"error",kind:e.kind,code:e.code,message:e.message,...e.context!==void 0?{context:e.context}:{},...e.suggestion!==void 0?{suggestion:e.suggestion}:{}}:{severity:"error",kind:"internal",code:"INTERNAL_INVARIANT",message:e instanceof Error?e.message:String(e)}}function C(e,t){return $o(e,t)}function w(e,t){for(const r of Object.keys(t)){const n=t[r];if(n!==void 0&&n!==e[r])return{...e,...t}}return e}function Go(e,t,r){if(e[t]===r)return e;const n=[...e];return n[t]=r,n}function Oe(e,t){let r=null;for(const[n,a]of e.entries()){const i=t(a,n);if(i===a){r?.push(i);continue}r??=e.slice(0,n),r.push(i)}return r??e}function $o(e,t){let r=!1;const n={...e};for(const[a,i]of Object.entries(t)){const o=e[a];if(l.isPlainObject(i)&&l.isPlainObject(o)){const s=$o(o,i);s!==o&&(n[a]=s,r=!0)}else i!==void 0&&i!==o&&(n[a]=i,r=!0)}return r?n:e}function ur(e){return{pipe:t=>{const r=t(e);return ur({...e,...r})},result:()=>e}}var Vm=(e,t)=>{if(!l.isLookupValueFormat(e))return e;const r=t[e.byVariable];return r===void 0?e.fallback:e.cases[l.getStableKey(r)]??e.fallback},bn=e=>e.type==="polar"?"disk":"panel",dr=(e,t)=>{if(e!=="disk")return{x:0,y:0,width:t.width,height:t.height};const r=Math.min(t.width,t.height);return{x:(t.width-r)/2,y:(t.height-r)/2,width:r,height:r}},Fa=(e,t)=>{if(e.space!=="disk")return{x:e.x,y:e.y};if(t.width<=0||t.height<=0)return{x:0,y:0};const r=dr(e.space,t),n=r.y+(1-e.y)*r.height;return{x:(r.x+e.x*r.width)/t.width,y:1-n/t.height}};function K(e,t){return e==="x"?t.x:t.y}function ye(e,t){return e==="x"?t.y:t.x}function Xe(e,t){return{main:K(e,t),cross:ye(e,t)}}function Ga(e,t){return e==="x"?{x:t.main,y:t.cross}:{x:t.cross,y:t.main}}function Mm(e){return e.type==="cartesian"}var J=e=>e[l.GROUP_VARIABLES.group],St=e=>{const t=Pe(e),r=ko(e),n=vn(e)&&t!==l.GROUP_VARIABLES.group;return a=>{const i=a[t]??null;if(i===null)return null;const o=r===null?null:r(a);if(r!==null&&o===null)return null;const s=n?J(a)??null:null;return{layerId:e.id,anchorValue:i,...o!==null&&{crossValue:o},...s!==null&&{groupValue:s}}}},Ze=(e,t)=>e>=0&&e<=1&&t>=0&&t<=1,Dm={type:"decimal"};function Uo(e){return e.length>0&&e.every(t=>t.data.size()===0)}function Sn(e,t){return t!==null&&e.data.hasVariable(t)?e.data.getValueFormat(t):Dm}function Pm(e){return Sn(e,l.readVariableName(e.mapping.y))}function Ho({geom:e,position:t,mapping:r,purpose:n}){return e.resolveValueSource?.(r,n)??vt(t,r)}function zo(e,t){const r=Ho({geom:t,position:e.position,mapping:e.mapping,purpose:"measurement"}),n=l.readVariableName(r),a=n===l.POSITION_VARIABLES.yRaw?l.readVariableName(e.mapping.y):n;return{read:j(e.data,r),valueFormat:Sn(e,a)}}var Wo=e=>{const t=Pe(e),r=ko(e),n=vn(e);return(a,i)=>!l.areDataValuesEqual(a[t]??null,i.anchorValue)||!(r===null||i.crossValue===void 0||l.areDataValuesEqual(r(a),i.crossValue))?!1:!n||i.groupValue===void 0?!0:l.areDataValuesEqual(J(a),i.groupValue)},Ko=e=>{const t=l.readVariableName(e.mapping.y),r=bt(e);return(n,a)=>t!==null&&a===t?r(n):n[a]??null},Om=e=>t=>{if(t===l.readVariableName(e.mapping.y))return Rm(e);const r=e.data.hasVariable(t)?e.data.getValues(t):null;return n=>r?.[n]??null};var _m=["lt","lte","gt","gte","range"],km={highlight:{subject:"Highlight predicate",effect:"dropping this highlight"},"selection-anchor":{subject:"Selection anchor predicate",effect:"dropping this annotation"},"style-rule":{subject:"Style rule predicate",effect:"dropping this rule"}},ge=()=>!1,Be=()=>!0;function nt(e,t){const r=Ko(e);return{...Yo(e,t),createValueReader:n=>a=>r(a,n)}}function Nm(e,t){return{...Yo(e,t),createValueReader:Om(e)}}function le(e,t){if("and"in e){const r=e.and.map(n=>le(n,t)).filter(n=>n!==Be);return r.includes(ge)?ge:r.length===0?Be:n=>{for(const a of r)if(!a(n))return!1;return!0}}if("or"in e){const r=e.or.map(n=>le(n,t)).filter(n=>n!==ge);return r.includes(Be)?Be:r.length===0?ge:n=>{for(const a of r)if(a(n))return!0;return!1}}if("not"in e){const r=le(e.not,t);return r===ge?Be:r===Be?ge:n=>!r(n)}return Fm(e,t)}function ce(e,t,r="highlight"){return"and"in e?e.and.flatMap(n=>ce(n,t,r)):"or"in e?e.or.flatMap(n=>ce(n,t,r)):"not"in e?ce(e.not,t,r):Bm(e,t,r)}function Yo(e,t){return{hasVariable:r=>e.data.hasVariable(r),getType:r=>e.data.getType(r),getValueFormat:r=>e.data.getValueFormat(r),parsingLocale:t}}function Bm(e,t,r){const{subject:n,effect:a}=km[r];if(!t.hasVariable(e.variable))return[{code:"UNKNOWN_VARIABLE",message:`${n} references unknown variable '${e.variable}' — ${a}.`,context:{variableName:e.variable},suggestion:`Map '${e.variable}' in the layer or correct the variable name in the predicate.`}];const i=Gm(e);return i!==null&&t.getType(e.variable)==="categorical"?[{code:"INVALID_PREDICATE_OPERATOR",message:`${n} uses ordering operator '${i}' on categorical variable '${e.variable}' — ${a}. Use 'eq' or 'oneOf' instead.`,context:{variableName:e.variable},suggestion:"Use 'eq' or 'oneOf' for categorical variables."}]:[]}function Fm(e,t){if(!t.hasVariable(e.variable))return ge;const r=t.createValueReader(e.variable),n=l.toExplicitValueFormat(t.getValueFormat(e.variable)),a=i=>l.parseAddressingValue(i,n,t.parsingLocale);if("eq"in e){const i=a(e.eq);return o=>l.areDataValuesEqual(r(o),i)}if("oneOf"in e){const i=e.oneOf.map(a);if(i.length>=32){const o=new Set,s=new Set;for(const c of i)l.isStrictTemporalDataValue(c)?s.add(c.getTime()):o.add(c);return c=>{const u=r(c);return l.isStrictTemporalDataValue(u)?s.has(u.getTime()):!Number.isNaN(u)&&o.has(u)}}return o=>{const s=r(o);for(const c of i)if(l.areDataValuesEqual(s,c))return!0;return!1}}if("lt"in e){const i=a(e.lt);return o=>Fe(r(o),i)==="less"}if("lte"in e){const i=a(e.lte);return o=>{const s=Fe(r(o),i);return s==="less"||s==="equal"}}if("gt"in e){const i=a(e.gt);return o=>Fe(r(o),i)==="greater"}if("gte"in e){const i=a(e.gte);return o=>{const s=Fe(r(o),i);return s==="greater"||s==="equal"}}if("range"in e){const[i,o]=e.range,s=a(i),c=a(o);return u=>{const d=r(u),m=Fe(d,s),p=Fe(d,c);return m==="incomparable"||p==="incomparable"?!1:(m==="greater"||m==="equal")&&(p==="less"||p==="equal")}}return ge}function Gm(e){for(const t of _m)if(t in e)return t;return null}function Fe(e,t){if(e===null||t===null)return"incomparable";if(l.isStrictTemporalDataValue(e)&&l.isStrictTemporalDataValue(t)){const r=e.getTime(),n=t.getTime();return r<n?"less":r>n?"greater":"equal"}return l.isStrictNumericDataValue(e)&&l.isStrictNumericDataValue(t)?e<t?"less":e>t?"greater":"equal":"incomparable"}var $m=(e,t,r,n,a,i)=>{const o=qo(e,t,r.predicate,n,a,i);if(o===null)return null;const s=jo(r.padding),c=s===null?zm(o,r.padding):o,u={x:c.xMin,y:c.yMin,width:Math.max(0,c.xMax-c.xMin),height:Math.max(0,c.yMax-c.yMin),space:c.space};return s===null?u:{...u,defer:s}},Um=(e,t,r,n,a,i)=>{const o=qo(e,t,r.predicate,n,a,i);return o===null?null:{...yt(o,r.align),space:o.space}},jo=e=>e===void 0||typeof e=="number"||e.unit!=="px"?null:{type:"px-offset",x:e.x??0,y:e.y??0},qo=(e,t,r,n,a,i)=>{if(t.has(r))return t.get(r)??null;let o=null,s=!1;const c=new Map;for(const u of n){if(!u.interactive)continue;const d=ce(r,u.data,"selection-anchor");if(d.length>0){for(const p of d)c.set(`${p.code}:${p.message}`,p);continue}s=!0;const m=le(r,nt(u,i));if(m!==ge)for(const p of u.data){if(!m(p))continue;const h=fn(p,a);h!==null&&(o=o===null?h:Hm(o,h))}}if(!s)for(const u of c.values())e.diagnostics.addWarning(u);return t.set(r,o),o},Hm=(e,t)=>({space:e.space,xMin:Math.min(e.xMin,t.xMin),xMax:Math.max(e.xMax,t.xMax),yMin:Math.min(e.yMin,t.yMin),yMax:Math.max(e.yMax,t.yMax)}),zm=(e,t)=>{if(t===void 0)return e;const{x:r=0,y:n=0}=typeof t=="number"?{x:t,y:t}:t;return{...e,xMin:e.xMin-r,xMax:e.xMax+r,yMin:e.yMin-n,yMax:e.yMax+n}},Jt=(e,t,r)=>{const n=Km(e,t,r);return n===null?null:n.defer?.type==="annotation-ref"?n:Ym(n,t.offset,e.coordSystem)},Xo=(e,t)=>t.anchorType==="selection"?$m(e.container,e.selectionBoxCache,t,e.layers,e.coordSystem,e.parsingLocale):t.anchorType==="annotation"?{x:0,y:0,width:0,height:0,defer:{type:"annotation-ref",ref:t.ref,align:"center"}}:{x:t.x,y:1-t.y-t.height,width:t.width,height:t.height},An=(e,t,r)=>Yr(e,t,r)?.point??null,Yr=({container:e,layers:t,coordSystem:r,parsingLocale:n},a,i)=>{for(const o of t){const s=e.geomRegistry.get(o.geom),{resolveAnchorPosition:c}=s;if(c===void 0||a.layerId!==void 0&&o.id!==a.layerId||a.layerId===void 0&&!o.interactive)continue;const u=zo(o,s),d=Wo(o),m=St(o),p=Bo(o,n)(a);let h=-1;for(const f of o.data){if(h+=1,!d(f,p))continue;const g=c(f,{coordSystem:r,position:o.position,purpose:i,align:a.align});if(g===null)continue;const v=Zo(o,f,u);if(v===null)continue;const y=m(f);if(y!==null)return{point:{...g,...v,space:bn(r),observationIndex:h,anchor:a.align===void 0?y:{...y,align:a.align}},layerId:o.id}}}return null},Wm=(e,t)=>{const{layers:r,coordSystem:n,scales:a,parsingLocale:i}=e;if(n.type!=="cartesian")return null;const o=a.x,s=a.y;if(o===void 0||s===void 0||o.kind!=="position"||s.kind!=="position")return null;const c=Ua(t.x,"x",r,i),u=Ua(t.y,"y",r,i);if(c===null||u===null)return null;const d=o.map(c),m=s.map(u);if(!Ze(d,m))return null;const p=$a(d,o,jm(e)),h=$a(m,s),f=Ga(n.mainAxis,{main:p.min,cross:h.min}),g=Ga(n.mainAxis,{main:p.max,cross:h.max});return yt({xMin:f.x,xMax:g.x,yMin:f.y,yMax:g.y},t.align??"center")},Zo=(e,t,r)=>{const n=r.read(t);return l.isStrictNumericDataValue(n)?{geom:e.geom,measurementValue:n,valueFormat:Vm(r.valueFormat,t),yScaleType:e.yScaleType}:null},Km=(e,t,r)=>{switch(t.anchorType){case"panel":return{x:t.x,y:1-t.y};case"axis":return Wm(e,t);case"selection":return Um(e.container,e.selectionBoxCache,t,e.layers,e.coordSystem,e.parsingLocale);case"annotation":return{x:0,y:0,defer:{type:"annotation-ref",ref:t.ref,align:t.align??"center",offset:t.offset}};case"observation":return An(e,qm(t),r)}},Ym=(e,t,r)=>{if(t===void 0||r.type==="polar")return e;const n=jo(t);return n!==null?{...e,defer:n}:{...e,x:e.x+(t.x??0),y:e.y-(t.y??0)}},$a=(e,t,r=1)=>{const{bandwidth:n}=t;if(n===null||n<=0)return{min:e,max:e};const a=n*r/2;return{min:e-a,max:e+a}},jm=({container:e,layers:t,coordSystem:r})=>{let n=0;for(const a of t){const i=e.geomRegistry.get(a.geom).resolveBandFraction?.(a.params,r);i!==void 0&&(n=Math.max(n,i))}return n>0?n:1},qm=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),Ua=(e,t,r,n)=>{for(const a of r){const i=l.readVariableName(a.mapping[t]);if(!(i===null||i===l.CONSTANT_VARIABLES.x))return l.parseAddressingValue(e,l.toExplicitValueFormat(a.data.getValueFormat(i)),n)}return e},Xm=class extends l.Stage{constructor(e){super(),this.container=e}dependencies(e){return[e.annotations,e.layers,e.coordSystem,e.scales.x,e.scales.y,e.config.parsingLocale]}run(e){const{annotations:t,layers:r,coordSystem:n,scales:a,config:i}=e,o={container:this.container,layers:r,coordSystem:n,scales:a,selectionBoxCache:new Map,parsingLocale:i.parsingLocale},s={differenceArrows:sp(o,t.differenceArrows),shapes:ep(o,t.shapes),arrows:rp(o,t.arrows),textAnnotations:np(o,t.textAnnotations),images:tp(o,t.images),stickers:ap(o,t.stickers),pinnedNumbers:ip(o,t.pinnedNumbers),comments:op(o,t.comments)};return Zm(this.container,s),Jm(this.container,s),s}},ue=(e,t,r,n)=>{e.diagnostics.addWarning({code:"ANNOTATION_ANCHOR_UNRESOLVED",message:`Annotation "${r}" (${t}) ${n} — dropping this annotation.`,context:{annotationId:r,kind:t},suggestion:"Check that the anchor points at data, an axis value or a panel position that exists."})},Zm=(e,t)=>{const r=new Set;for(const n of Object.values(t))for(const{id:a}of n){if(r.has(a)){e.diagnostics.addWarning({code:"ANNOTATION_DUPLICATE_ID",message:`More than one annotation carries id "${a}" — references to it resolve to the first, and the rest cannot be addressed.`,context:{annotationId:a},suggestion:"Give each annotation its own id."});continue}r.add(a)}},Jm=(e,t)=>{const r=new Set;for(const n of Object.values(t))for(const a of n)r.add(a.id);for(const{id:n,ref:a}of Qm(t))r.has(a)||e.diagnostics.addWarning({code:"ANNOTATION_REF_NOT_FOUND",message:`Annotation "${n}" references id "${a}", whose annotation could not be anchored and was dropped.`,context:{annotationId:n,ref:a},suggestion:"Fix the anchor on the target annotation or point this reference at one that resolves."})},Qm=e=>{const t=[],r=(n,a)=>{a.defer?.type==="annotation-ref"&&t.push({id:n,ref:a.defer.ref})};for(const n of e.shapes)r(n.id,n.region);for(const n of e.images)r(n.id,n.region);for(const n of e.arrows)r(n.id,n.start),r(n.id,n.end);for(const n of e.textAnnotations)r(n.id,n.at);for(const n of e.stickers)r(n.id,n.at);return t},ep=(e,t)=>{const r=[];for(const n of t){const a=Xo(e,n.region);if(a===null){ue(e.container,"shape",n.id,"has a region anchor that resolves to nothing");continue}r.push({id:n.id,kind:n.kind,zOrder:n.zOrder,region:a})}return r},tp=(e,t)=>{const r=[];for(const n of t){const a=Xo(e,n.region);if(a===null){ue(e.container,"image",n.id,"has a region anchor that resolves to nothing");continue}r.push({id:n.id,src:n.src,zOrder:n.zOrder,region:a,fit:n.fit})}return r},rp=(e,t)=>{const r=[];for(const n of t){const a=Jt(e,n.start,"pin"),i=Jt(e,n.end,"pin");if(a===null||i===null){ue(e.container,"arrow",n.id,`has ${Jo(a,i)} resolving to nothing`);continue}r.push({id:n.id,start:a,end:i,startArrowheadStyle:n.startArrowheadStyle,endArrowheadStyle:n.endArrowheadStyle})}return r},np=(e,t)=>{const r=[];for(const n of t){const a=Jt(e,n.at,"pin");if(a===null){ue(e.container,"text",n.id,"has a point anchor that resolves to nothing");continue}r.push({id:n.id,content:n.content,at:a,width:n.width,align:n.align})}return r},ap=(e,t)=>{const r=[];for(const n of t){const a=Jt(e,n.at,"pin");if(a===null){ue(e.container,"sticker",n.id,"has a point anchor that resolves to nothing");continue}r.push({id:n.id,at:a,sticker:n.sticker})}return r},ip=(e,t)=>{const r=[];for(const n of t){const a=An(e,n.at,"pin");if(a===null){ue(e.container,"pinnedNumber",n.id,"matches no observation");continue}r.push({id:n.id,at:a})}return r},op=(e,t)=>{const r=[];for(const n of t){const a=An(e,n.at,"pin");if(a===null){ue(e.container,"comment",n.id,"matches no observation");continue}r.push({id:n.id,at:a,content:n.content})}return r},sp=(e,t)=>{if(e.coordSystem.type!=="cartesian"){for(const n of t)ue(e.container,"differenceArrow",n.id,"needs a cartesian coord system");return[]}const r=[];for(const n of t){const a=Yr(e,n.start,"value"),i=Yr(e,n.end,"value");if(a===null||i===null){ue(e.container,"differenceArrow",n.id,`has ${Jo(a,i)} matching no observation`);continue}if(a.layerId===i.layerId&&a.point.observationIndex===i.point.observationIndex){ue(e.container,"differenceArrow",n.id,"has both ends on the same observation");continue}lp(e,n,a.point,i.point),r.push({id:n.id,start:a.point,end:i.point,label:n.label,labelCrossPosition:n.labelCrossPosition})}return r},Jo=(e,t)=>e===null&&t===null?"start and end anchors":e===null?"a start anchor":"an end anchor",lp=(e,t,r,n)=>{No(r,n)||e.container.diagnostics.addWarning({code:"INCOMPARABLE_ARROW_ENDPOINTS",message:`Difference arrow "${t.id}" measures between endpoints on different bases, so its label reports a quantity that does not exist.`,context:{annotationId:t.id,expected:Wr(r),actual:Wr(n)},suggestion:"Point both ends at observations sharing one y scale and one unit, or label the arrow as a proportion."})};function cp(e,t="kind"){const r=new Map;r.set(t,[]);for(const a of e)for(const i of a.observations)for(const o of Object.keys(i))r.has(o)||r.set(o,[]);for(const a of e)for(const i of a.observations)for(const[o,s]of r)s.push(o===t?a.kind:i[o]??null);const n={};for(const[a,i]of r)n[a]={type:Qo(i),values:i};return new l.Dataset(n)}function Qo(e){const t=Array.isArray(e)?e:[e];for(const r of t)if(r!==null)return typeof r=="number"?"numeric":r instanceof Date?"temporal":"categorical";return"categorical"}var up=class extends l.Stage{dependencies(e){return[e.data,e.mapping]}run(e){let t=e.data,r=e.mapping;r.x===""&&(t=t.addConstantVariable(l.CONSTANT_VARIABLES.x,"categorical",""),r={...r,x:l.CONSTANT_VARIABLES.x});for(const n of Object.keys(r)){const a=l.readConstantValue(r[n]);if(a===void 0)continue;const i=l.prefixInternalVariable(`const_${n}`);t=t.addConstantVariable(i,Qo(a),a),r={...r,[n]:i}}return{data:t,mapping:r}}},_e=class{constructor(){this.perLayerMemo=l.createPerKeyMemo(),this.listMemo=l.createSingleSlotMemo()}get stats(){return l.sumMemoStats(this.perLayerMemo.stats,this.listMemo.stats)}compile(e){const t=this.dependencies(e),r=e.layers.map(n=>this.perLayerMemo(n,t,()=>this.compileLayer(n,e)));return this.listMemo(r,()=>r)}},dp=class extends l.Stage{constructor(e){super(),this.registry=e}dependencies(e){return[e.coordSpec,e.scales,e.layers]}run(e){return this.registry.get(e.coordSpec.coordType).setup(e)}},mp=class extends _e{constructor(e){super(),this.registry=e}dependencies(e){return[e.coordSpec,e.coordSystem]}compileLayer(e,t){const[r]=this.registry.get(t.coordSpec.coordType).transform({coordSpec:t.coordSpec,coordSystem:t.coordSystem,layers:[e]});if(!r)throw new l.InternalError({message:`CoordCompiler: strategy '${t.coordSpec.coordType}' did not return a transformed layer`});return r}},pp=class{constructor(e){this.setupStage=new dp(e),this.transformStage=new mp(e)}get setupStats(){return this.setupStage.stats}get transformStats(){return this.transformStage.stats}setup(e){return this.setupStage.compile(e)}transform(e){return this.transformStage.compile(e)}},hp=class{constructor(){this.coordType="cartesian"}setup(e){if(e.coordSpec.coordType!=="cartesian")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});return{coordSystem:{type:"cartesian",mainAxis:"x",axisMapping:{x:{position:"bottom",geometry:"linear"},y:{position:"right",geometry:"linear"}}},scales:e.scales}}transform(e){return e.layers}},fp=class{constructor(){this.coordType="flip"}setup(e){if(e.coordSpec.coordType!=="flip")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});return{coordSystem:{type:"cartesian",mainAxis:"y",axisMapping:{x:{position:"left",geometry:"linear"},y:{position:"bottom",geometry:"linear"}}},scales:yp(e.scales,e.layers)}}transform(e){return e.layers.map(t=>bp(t))}},gp=[[l.POSITION_VARIABLES.x,l.POSITION_VARIABLES.y],[l.POSITION_VARIABLES.xMin,l.POSITION_VARIABLES.yMin],[l.POSITION_VARIABLES.xMax,l.POSITION_VARIABLES.yMax]],Ha=l.prefixInternalVariable("flipSwap"),yp=(e,t)=>vp(t)?e.map(r=>r.scaledAesthetic!=="x"||r.scaleType!=="continuous"&&r.scaleType!=="datetime"&&r.scaleType!=="discrete"?r:{...r,reverse:!r.reverse}):e,vp=e=>{for(const t of e){const r=l.readVariableName(t.mapping.x);if(!r||!t.data.hasVariable(r))continue;const n=t.data.getType(r);if(n==="categorical"||n==="temporal")return!0}return!1},bp=e=>{let t=e.data;for(const[r,n]of gp){const a=t.hasVariable(r),i=t.hasVariable(n);a&&i?t=t.renameVariable(r,Ha).renameVariable(n,r).renameVariable(Ha,n):a?t=t.renameVariable(r,n):i&&(t=t.renameVariable(n,r))}return{...e,data:t}};function es(e){const t=new Set,r=[];for(const n of e){const a=n instanceof Date?n.getTime():String(n);t.has(a)||(t.add(a),r.push(n))}return r}var ts=(e,t)=>es(t.domain!==null&&t.domain.length>0?t.domain:e),Sp=class{constructor(){this.coordType="polar"}setup(e){if(e.coordSpec.coordType!=="polar")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});const{params:t}=e.coordSpec,r=t.startAngle*(Math.PI/180),n=Ip(t,e.scales,e.layers),a=Lp(t,e.scales,e.layers);return{coordSystem:{type:"polar",axisMapping:t.theta==="x"?{x:{position:"bottom",geometry:"circular"},y:{position:"left",geometry:"radial"}}:{x:{position:"left",geometry:"radial"},y:{position:"bottom",geometry:"circular"}},innerRadius:t.innerRadius,startAngle:r,spokeRotation:n,bandAxis:a},scales:e.scales}}transform(e){if(e.coordSpec.coordType!=="polar")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});if(e.coordSystem.type!=="polar")throw new l.InternalError({message:"PolarCoord.transform received a non-polar coord system"});const{params:t}=e.coordSpec,{startAngle:r,spokeRotation:n}=e.coordSystem,a=xp(r,n),i=Ep(t);return e.layers.map(o=>wp(t.theta==="y"?Rp(o):o,a,i))}},Ap=[[l.POSITION_VARIABLES.x,l.POSITION_VARIABLES.y],[l.POSITION_VARIABLES.xMin,l.POSITION_VARIABLES.yMin],[l.POSITION_VARIABLES.xMax,l.POSITION_VARIABLES.yMax]];function xp(e,t){return r=>Do(r,e,t)}function Ip(e,t,r){const n=t.find(i=>i.scaledAesthetic===e.theta);if(n===void 0||n.scaleType!=="discrete")return 0;const a=Tp(n,e,r);return a===0?0:-Math.PI/a}function Tp(e,t,r){const n=[];for(const a of r){const i=l.readVariableName(a.mapping[t.theta]);if(!(i===null||!a.data.hasVariable(i)))for(const o of a.data.getValues(i))n.push(o)}return ts(n,e).length}function Lp(e,t,r){if(e.theta==="x")return"x";const n=t.find(i=>i.scaledAesthetic==="x")?.scaleType==="discrete",a=r.some(i=>i.position==="fill");return n&&!a?"y":null}function Ep(e){const{innerRadius:t}=e;return r=>t+r*(1-t)}function wp(e,t,r){let n=e.data;return n=Ge(n,l.POSITION_VARIABLES.x,t),n=Ge(n,l.POSITION_VARIABLES.xMin,t),n=Ge(n,l.POSITION_VARIABLES.xMax,t),n=Ge(n,l.POSITION_VARIABLES.y,r),n=Ge(n,l.POSITION_VARIABLES.yMin,r),n=Ge(n,l.POSITION_VARIABLES.yMax,r),{...e,data:n}}function Ge(e,t,r){if(!e.hasVariable(t))return e;const n=e.getValues(t,{type:"numeric"}).map(a=>a===null?null:r(a));return e.addVariable(t,"numeric",n)}function Rp(e){let t=e.data;for(const[r,n]of Ap){const a=t.hasVariable(r),i=t.hasVariable(n);if(!a&&!i)continue;const o=a?t.getValues(r):null,s=i?t.getValues(n):null;o&&(t=t.addVariable(n,"numeric",o)),s&&(t=t.addVariable(r,"numeric",s))}return{...e,data:t}}var Cp=class extends l.Registry{constructor(){super("coord"),this.register("cartesian",new hp),this.register("flip",new fp),this.register("polar",new Sp)}},rs=new Set(["min","max","scalar"]),Vp={x:{min:l.POSITION_VARIABLES.xMin,max:l.POSITION_VARIABLES.xMax},y:{min:l.POSITION_VARIABLES.yMin,max:l.POSITION_VARIABLES.yMax}};function Mp(e){const t=new Set;for(const r of e)r.role==="point"?t.add(r.axis):(r.role==="min"||r.role==="max")&&l.isDefined(r.aes)&&t.add(r.aes);return[...t]}function Dp(e){const t=new Set;for(const r of e)r.role==="point"&&t.add(r.axis),l.isDefined(r.aes)&&t.add(r.aes);return[...t]}function Pp(e,t,r){let n=e;for(const a of t){if(a.role!=="min"&&a.role!=="max"||!l.isDefined(a.aes))continue;const i=Vp[a.axis][a.role];if(n.hasVariable(i))continue;const o=l.readVariableName(r[a.aes]);!l.isDefined(o)||!n.hasVariable(o)||(n=n.addVariable(i,"numeric",n.getValues(o,{type:"numeric"})))}return n}var Op=class{constructor(e){this.container=e}compile(e,t){const r=this.container.geomRegistry.get(e),n=r.compile(t),a={...t.mapping,...n.mapping};return{...n,data:Pp(n.data,r.positionRoles,a)}}},_p=["x","y"],xn=new Set(["x","y","ySecondary"]),At=new Set(["color","size","alpha","strokeWidth","lineType"]),Ae=e=>xn.has(e),In=e=>At.has(e),ns=e=>Ae(e)||In(e);function xe(e){return e==="secondary"?"ySecondary":"y"}function as(e,t){return e==="y"?xe(t):"x"}function F(e){return e==="ySecondary"?"y":e}var pe=(e,t)=>{if(l.isDefined(t.group)){const a=l.readVariableName(t.group);if(a!==null)return[a]}const r=new Set([l.readVariableName(t.x),l.readVariableName(t.y)].filter(l.isDefined)),n=new Set;for(const a of At){const i=l.readVariableName(t[a]);l.isDefined(i)&&(r.has(i)||e.hasVariable(i)&&e.getType(i)==="categorical"&&n.add(i))}return[...n]},mr=(e,t)=>e.hasVariable(l.GROUP_VARIABLES.group)?e.getValues(l.GROUP_VARIABLES.group,{distinct:!0,skipNulls:!0}).length>1:pe(e,t).some(r=>e.getValues(r,{distinct:!0,skipNulls:!0}).length>1),kp=class{compute({data:e,mapping:t}){const r=pe(e,t);if(r.length===0)return{data:e.addConstantVariable(l.GROUP_VARIABLES.group,"categorical",null)};const n=e.size(),a=r.map(o=>e.getValues(o)),i=new Array(n);for(let o=0;o<n;o++)i[o]=l.getStableKey(a.map(s=>s[o]));return{data:e.addVariable(l.GROUP_VARIABLES.group,"categorical",i)}}},Np=e=>{if(e===void 0)return{};const t={};for(const r of e.columns)r.label!==void 0&&(t[r.key]=r.label);return t},Bp=(e,t,r)=>{const n=Me(t,"color");return n===null?{}:(e?.columns??[]).some(a=>a.key===n)?{}:r};function Me(e,t){const r=F(t);for(const n of is(t,e)){const a=l.readVariableName(n.mapping[r]);if(l.isDefined(a))return a}return null}var pr=(e,t)=>e===null?null:t[e]??e,Fp=(e,t)=>e===null?null:t[String(e)]??null,De=({layers:e,scaleType:t,variableName:r})=>{if(r===null)return Dr(t);for(const n of e){if(!n.data.hasVariable(r))continue;const a=n.data.getValueFormat(r),i=a.type==="lookup"?a.fallback:a;return $p(i,t)?i:Dr(t)}return Dr(t)},Gp=(e,t)=>t!=="y"&&t!=="ySecondary"?!1:is(t,e).some(r=>r.position==="fill");function is(e,t){return e==="ySecondary"?t.filter(r=>r.yScaleType==="secondary"):e==="y"?t.filter(r=>r.yScaleType==="primary"):t}var Dr=e=>{switch(e){case"continuous":return{type:"decimal"};case"datetime":return{type:"date"};case"discrete":case"palette":case"identity":return{type:"text"}}},$p=(e,t)=>{switch(t){case"continuous":return l.isNumericValueFormat(e);case"datetime":return l.isTemporalValueFormat(e);case"discrete":case"palette":case"identity":return!0}},Up=[{unit:"year",step:1e3},{unit:"year",step:100},{unit:"year",step:50},{unit:"year",step:20},{unit:"year",step:10},{unit:"year",step:5},{unit:"year",step:2},{unit:"year",step:1},{unit:"month",step:6},{unit:"month",step:3},{unit:"month",step:2},{unit:"month",step:1},{unit:"week",step:2},{unit:"week",step:1},{unit:"day",step:2},{unit:"day",step:1},{unit:"hour",step:12},{unit:"hour",step:6},{unit:"hour",step:3}],za={year:0,quarter:1,month:2,week:3,day:4,hour:5},$e=40,Hp=(e,t,r)=>{const n=r.unit==="quarter"?r.step*3:r.step;return Yp(r.unit).range(e,new Date(t.valueOf()+1),n)},zp=({unit:e,step:t,start:r,stop:n})=>{const a=(0,dm.differenceInDays)(n,r);switch(e){case"hour":return 24*a/t>$e;case"day":return a/t>$e;case"week":return a/(7*t)>$e;case"month":return a/(30*t)>$e;case"quarter":return a/(90*t)>$e;case"year":return a/(365*t)>$e}},Wp=(e,t)=>{const r=!l.isDateWithoutYearValueFormat(t);switch(e.unit){case"year":return r?{type:"year"}:{type:"month"};case"quarter":return{type:"quarter"};case"month":return r?{type:"month_year"}:{type:"month"};case"week":return r?{type:"weekly_date_range_with_year"}:{type:"weekly_date_range"};case"day":return r?{type:"date"}:{type:"day_month"};case"hour":return r?{type:"datetime"}:{type:"time"}}},Kp=(e,t)=>{const r=jp(t);return r===null?!1:za[e]>za[r]},Yp=e=>{switch(e){case"hour":return it.utcHour;case"day":return it.utcDay;case"week":return it.utcMonday;case"month":case"quarter":return it.utcMonth;case"year":return it.utcYear}},jp=e=>{switch(e.type){case"year":return"year";case"quarter":return"quarter";case"month_year":case"month":return"month";case"weekly_date_range":case"weekly_date_range_with_year":return"week";case"date":case"day_month":case"datetime":return"day";case"time":return"hour";default:return null}},os={left:"right",right:"left",top:"bottom",bottom:"top"},qp={x:!0,y:!0,ySecondary:!1},Xp=20,Wa=new Set(["top","bottom"]),Zp={type:"percentage"};function Jp(e,t){const{scales:r,config:n,layers:a,coordSystem:i,variableLabels:o,geomRegistry:s}=e;if(Uo(a))return[];if(i.type==="polar"&&i.bandAxis===null)return[];const c=th(s,a,i.type,n),u=new Set(t.map(p=>p.position)),d=nh(ss(n.axes.y.position,i.axisMapping.y.position),u),m=[];for(const p of xn){const h=r[p];if(!l.isDefined(h)||h.kind!=="position")continue;const f=Qp({scaleAestheticKey:p,scale:h,config:n,layers:a,axisMapping:i.axisMapping,resolvedYPosition:d,gridOverrides:c,variableLabels:o});m.push(f)}return m}function Qp(e){const{scaleAestheticKey:t,scale:r,config:n,layers:a,axisMapping:i,resolvedYPosition:o,gridOverrides:s,variableLabels:c}=e,{axisConfig:u,position:d,geometry:m}=rh(t,n,i,o),p=Me(a,t),h=Gp(a,t)?Zp:De({layers:a,scaleType:r.spec.scaleType,variableName:p});return{scaleAestheticKey:t,position:d,geometry:m,label:eh(u,p,c),isVisible:u.isVisible,tickCandidates:ih(r,h,u.ticks.mode),valueFormat:h,tickMode:u.ticks.mode,ticksVisible:u.ticks.isVisible,gridVisible:ah(u,s,t),scaleType:r.spec.scaleType,bandwidth:r.bandwidth??void 0}}function eh(e,t,r){return e.label?e.label:t?r[t]??null:null}function th(e,t,r,n){const a=t.flatMap(s=>{const c=e.get(s.geom).grid[r];return c?[c]:[]}),i=a.some(s=>s.hideGridX),o=a.some(s=>s.hideGridY);return{x:{gridVisible:Ka(i,n.axes.x.grid.isVisible)},y:{gridVisible:Ka(o,n.axes.y.grid.isVisible)}}}function Ka(e,t){if(e&&t===null)return!1}function rh(e,t,r,n){switch(e){case"x":return{axisConfig:t.axes[e],position:ss(t.axes[e].position,r[e].position),geometry:r.x.geometry};case"y":return{axisConfig:t.axes[e],position:n,geometry:r.y.geometry};case"ySecondary":{const a=os[n],i=(0,tt.merge)({isVisible:t.axes.y.isVisible,label:null,position:a,grid:t.axes.y.grid,ticks:t.axes.y.ticks},t.axes.ySecondary);return{axisConfig:i,position:i.position,geometry:r.y.geometry}}}}function ss(e,t){return Wa.has(e)===Wa.has(t)?e:t}function nh(e,t){return t.has(e)?os[e]:e}function ah(e,t,r){const{gridVisible:n}=r==="x"?t.x:t.y;return n??e.grid.isVisible??qp[r]}var ih=(e,t,r)=>{const n=e.spec.scaleType==="continuous"||e.spec.scaleType==="datetime";if(r==="edges"&&n){const a=sh(e);if(a)return[a]}if(e.spec.scaleType==="continuous"){const a=new Set,i=[];for(let o=1;o<=Xp;o++){const s=e.generateTicks({count:o}),c=l.getStableKey(s);a.has(c)||(a.add(c),i.push({ticks:s.map(u=>Je(e,u))}))}return i}return e.spec.scaleType==="datetime"?oh(e,t):[{ticks:e.generateTicks().map(a=>Je(e,a))}]},oh=(e,t)=>{const[r,n]=e.domain;if(!l.isStrictTemporalDataValue(r)||!l.isStrictTemporalDataValue(n))return[{ticks:e.generateTicks().map(s=>Je(e,s))}];const a=new Set,i=[],o=(s,c)=>{if(s.length===0)return;const u=l.getStableKey(s);a.has(u)||(a.add(u),i.push({ticks:s.map(d=>Je(e,d)),valueFormat:c}))};for(const s of Up)zp({...s,start:r,stop:n})||Kp(s.unit,t)||o(e.generateTicks({interval:s}),Wp(s,t));return o(e.generateTicks({atInputs:!0})),i.sort((s,c)=>s.ticks.length-c.ticks.length),i},sh=e=>{const{domain:t}=e,r=t[0],n=t.at(-1);return!l.isDefined(r)||!l.isDefined(n)||l.getStableKey([r])===l.getStableKey([n])?null:{ticks:[Je(e,r),Je(e,n)]}},Je=(e,t)=>({value:t,position:e.map(t)});function ls({scale:e,aesthetics:t,layers:r}){const n=lh({layers:r,aesthetics:t}),a=cs({layers:r,aesthetics:t});return e.domain.map(i=>({value:i,geom:n(i),owner:a(i)}))}function lh({layers:e,aesthetics:t}){const r=cs({layers:e,aesthetics:t}),n=e.find(i=>t.some(o=>l.isDefined(i.mapping[o]))),a=n?n.geom:"bar";return i=>{const o=r(i);return o?o.layer.geom:a}}function cs({layers:e,aesthetics:t,layerFilter:r}){const n=new Map;for(const[a,i]of e.entries()){if(r&&!r(i))continue;const o=t.find(c=>l.isDefined(i.mapping[c]));if(o===void 0)continue;const s=l.readVariableName(i.mapping[o]);if(!(s===null||!i.data.hasVariable(s)))for(const c of i.data.getValues(s,{distinct:!0})){const u=l.getStableKey(c);n.has(u)||n.set(u,{layer:i,layerIndex:a})}}return a=>n.get(l.getStableKey(a))}var Tn=e=>{if(e.kind==="identity")return!1;const t=e.spec.scaleType;return t!=="continuous"&&t!=="datetime"};function ch({scales:e,layers:t,valueLabels:r}){const n=e.color;if(n===void 0||!Tn(n))return[];if(!t.some(s=>l.isDefined(s.mapping.color)))return[];const a=Me(t,"color");if(us({colorVariableName:a,xVariableName:Me(t,"x"),mapsColorAcrossMultipleLayers:dh(t)>1,isMergedWithAnotherAesthetic:uh(e,t,a)}))return[];const i=n.spec.scaleType,o=t.findIndex(s=>l.isDefined(s.mapping.color));return ls({scale:n,aesthetics:["color"],layers:t}).map(({value:s,geom:c,owner:u})=>{const d=u?.layerIndex??o,m=t[d],p=m?l.readVariableName(m.mapping.color):null;return{value:s,color:String(n.map(s)),geom:c,layerIndex:d,valueFormat:De({layers:m?[m]:t,scaleType:i,variableName:p}),label:Fp(s,r)}})}var us=({colorVariableName:e,xVariableName:t,mapsColorAcrossMultipleLayers:r,isMergedWithAnotherAesthetic:n})=>n?!1:e===null||l.isInternalVariable(e)?!r:t!==null&&e===t;function uh(e,t,r){if(r===null)return!1;for(const n of At){if(n==="color")continue;const a=e[n];if(!(a===void 0||!Tn(a))&&Me(t,n)===r)return!0}return!1}var dh=e=>e.filter(t=>l.isDefined(t.mapping.color)).length;function ds(e,t){return e.get(t.geom).summaries.perGroupHeadline===!0}function mh(e,t,r,n){const a=r.findIndex(i=>ds(e,i));return a===-1?[]:t.length<2?[{value:null,swatch:null,layerIndex:a,groupLabelFormat:{type:"text"},label:pr(l.readVariableName(r[a]?.mapping.y),n)}]:t.map(i=>({value:i.value,swatch:{color:i.color,geom:i.geom,layerId:r[i.layerIndex]?.id,value:i.value},layerIndex:i.layerIndex,groupLabelFormat:i.valueFormat,label:i.label}))}function Ya(e,t,r){if(r===null||t===null)return[...e];const n=l.getStableKey(r);return e.filter((a,i)=>l.getStableKey(t[i]??null)===n)}var ms=e=>e==="none"?"first":e,ph=(e,t)=>{switch(t){case"total":{const{sum:r,count:n}=ja(e);return n===0?null:r}case"average":{const{sum:r,count:n}=ja(e);return n===0?null:r/n}case"current":return e.at(-1)??null}},hh=(e,t)=>{if(e.length<2)return null;const r=e.at(-1),n=t==="previous"?e.at(-2):e.at(0);return r===void 0||n===void 0||r.cross===null||n.cross===null||n.cross===0?null:{variation:(r.cross-n.cross)/n.cross,against:n.main}},ja=e=>e.reduce((t,r)=>r===null?t:{sum:t.sum+r,count:t.count+1},{sum:0,count:0});function fh(e){const{config:t,coordSystem:r}=e,n=t.headline.show;return n==="none"||n==="conversion"?null:r.type==="polar"?gh(e,n):yh(e,n)}function gh(e,t){if(t!=="total")return null;const{scales:r,layers:n}=e,a=n.find(s=>s.summary.grandTotal!==void 0);if(a===void 0)return null;const i=a.summary.grandTotal;if(i===void 0)return null;const o=l.readVariableName(a.mapping.y);return o===null?null:{kind:"grandTotal",value:i,valueFormat:De({layers:[a],scaleType:r.y?.spec.scaleType??"continuous",variableName:o})}}function yh(e,t){const{config:r,scales:n,layers:a,variableLabels:i,colorGroups:o,geomRegistry:s}=e;if(!a.some(d=>ds(s,d)))return null;const c=mh(s,o,a,i);if(c.length===0)return null;const u=c.map(d=>vh({group:d,show:t,compareWith:r.headline.compareWith,layers:a,scales:n})).filter(d=>d!==null);return u.length===0?null:{kind:"perGroup",items:u}}function vh({group:e,show:t,compareWith:r,layers:n,scales:a}){const i=n[e.layerIndex];if(i===void 0)return null;const o=l.readVariableName(i.mapping.y);if(o===null||t==="total"&&i.position==="fill")return null;const s=l.readVariableName(i.mapping.x),c=l.readVariableName(i.mapping.color),u=i.yScaleType==="secondary"?a.ySecondary:a.y,d=De({layers:[i],scaleType:u?.spec.scaleType??"continuous",variableName:o}),m=Ah(i.data,s),p=De({layers:[i],scaleType:m?"datetime":a.x?.spec.scaleType??"discrete",variableName:s}),h=xh(i.data,s),f=h.getValues(o,{type:"numeric"}),g=s!==null?h.getValues(s):[],v=c!==null?h.getValues(c):null,y=Ya(f,v,e.value),A=Ya(g,v,e.value);return{value:e.value,swatch:e.swatch,aggregate:ph(y,t),valueFormat:d,groupLabelFormat:e.groupLabelFormat,mainValueFormat:p,label:e.label,caption:bh(t,m,A),comparison:Sh(t,r,m,A,y)}}function bh(e,t,r){if(e==="current"){const i=r.at(-1);return i===void 0?null:{kind:"point",value:i}}if(!t)return null;const n=r.at(0),a=r.at(-1);return n===void 0||a===void 0?null:{kind:"range",from:n,to:a}}function Sh(e,t,r,n,a){return e!=="current"||!r?null:hh(n.map((i,o)=>({main:i,cross:a[o]??null})),ms(t))}function Ah(e,t){return t!==null&&e.hasVariable(t)&&e.getType(t)==="temporal"}function xh(e,t){return t===null||!["numeric","temporal"].includes(e.getType(t))?e:e.orderBy(t)}function ee(e,...t){return e?t.includes(e.geom):!1}function O(e,t){return e.find(r=>r.id===t)}function Ie(e,...t){return e.find(r=>t.includes(r.geom))}function Ih(e,...t){return e.filter(r=>t.includes(r.geom))}function Ln(e,t){return e.interactive?!1:t.some(r=>r!==e&&l.areMappingsEquivalent(r.mapping,e.mapping))}function Th(e,t){return t.filter(r=>r!==e&&!r.interactive&&l.areMappingsEquivalent(e.mapping,r.mapping))}function En(e){const t=e.filter(r=>!Ln(r,e));return t.length>0?t:e}function ps({legendPosition:e,coordSystem:t,layers:r}){if(e!=="right"||t.type!=="cartesian"||t.mainAxis!=="x")return!1;const n=En(r);return n.length===1&&n[0]?.supportsDirectLabels===!0}var Lh=3;function Eh({scales:e,config:t,layers:r,coordSystem:n,variableLabels:a,colorGroups:i,geomRegistry:o}){if(t.legend.position==="none")return{drawn:[],position:"none"};const s=new Map(i.map(v=>[l.getStableKey(v.value),v])),c=Oh(Vh({scales:e,layers:r})),u=Me(r,"x"),d=c.map(v=>{if(Dh(v,u,r))return null;const y=kh({group:v,variableLabels:a,layers:r,colorGroupsByValue:s});return y.items.length===0?null:{group:v,built:y}}).filter(l.isDefined),m=wh(d),p=En(r),h=Uh(o,t.legend.position,m,p,n);if(d.length===0)return{drawn:[],position:h};if(t.legend.position==="auto"&&$h(o,m,p,n))return{drawn:[],position:h};const f=Hh(t.legend.display,{legendPosition:h,coordSystem:n,layers:r}),g=f==="direct"?Yh(p[0]):null;return{drawn:d.map(({built:v})=>Rh(v,{position:h,display:f,align:t.legend.align},g)),position:h}}function wh(e){return e.reduce((t,{group:r,built:n})=>t+(r.some(a=>a.guideType!=="discrete")?1:n.items.length),0)}function Rh(e,t,r){const{position:n,display:a}=t,i=Ch(t.align,n);return a!=="direct"||r===null?{...e,position:n,display:a,align:i}:{...e,position:n,display:a,align:i,items:e.items.map(o=>({...o,normalizedY:r.get(String(o.value))??null}))}}function Ch(e,t){return e!=="auto"?e:t==="top"||t==="bottom"?"start":"center"}function Vh(e){const{scales:t,layers:r}=e,n=[];for(const a of At){const i=t[a];if(i===void 0||i.kind==="identity"||!Mh(a,r))continue;const o=Me(r,a),s=Kh(a,i);n.push({scaleAestheticKey:a,scale:i,variableName:o,guideType:s})}return n}function Mh(e,t){const r=F(e);return t.some(n=>l.isDefined(n.mapping[r]))}function Dh(e,t,r){const[n]=e;return n.scaleAestheticKey!=="color"?!1:us({colorVariableName:n.variableName,xVariableName:t,mapsColorAcrossMultipleLayers:Ph(n.scaleAestheticKey,r),isMergedWithAnotherAesthetic:e.length>1})}function Ph(e,t){const r=F(e);return t.filter(n=>l.isDefined(n.mapping[r])).length>1}function Oh(e){const t=new Map;for(const r of e){const n=Wh(r),a=t.get(n);a?a.push(r):t.set(n,[r])}return[...t.values()]}function _h(e,t,r){if(t==="lineType"){e.lineType=r;return}if(t==="color"){e.color=String(r);return}e[t]=r}function kh({group:e,variableLabels:t,layers:r,colorGroupsByValue:n}){const a=e[0],i=e.map(u=>F(u.scaleAestheticKey)),o=ls({scale:a.scale,aesthetics:i,layers:r}),s=De({layers:r,scaleType:a.scale.spec.scaleType,variableName:a.variableName}),c=r.find(u=>i.some(d=>l.isDefined(u.mapping[d])))?.id;return{aesthetics:e.map(u=>u.scaleAestheticKey),title:pr(a.variableName,t),items:o.map(u=>Nh(u,e,i,s,n,c))}}function Nh(e,t,r,n,a,i){const o={};for(const c of t)_h(o,c.scaleAestheticKey,c.scale.map(e.value));if(o.color===void 0&&r.includes("size")&&(o.color=l.DEFAULT_GEOM_COLOR),o.lineType===void 0){const c=l.readConstantValue(e.owner?.layer.mapping.lineType);l.isLineType(c)&&(o.lineType=c)}const s=Fh(e,t,r,n,a);return{value:e.value,label:Bh(t,e,a),visual:o,normalizedY:null,geom:e.geom,valueFormat:s,layerId:e.owner?.layer.id??i}}function Bh(e,t,r){return e[0].scaleAestheticKey!=="color"?null:r.get(l.getStableKey(t.value))?.label??null}function Fh(e,t,r,n,a){if(t[0].scaleAestheticKey==="color")return a.get(l.getStableKey(e.value))?.valueFormat??n;const i=e.owner?.layer,o=Gh(i,r);return i===void 0||o===null?n:De({layers:[i],scaleType:t[0].scale.spec.scaleType,variableName:o})}function Gh(e,t){if(e===void 0)return null;for(const r of t){const n=e.mapping[r];if(n===void 0)continue;const a=l.readVariableName(n);if(a!==null)return a}return null}function $h(e,t,r,n){if(t>1)return!1;const a=n.type==="polar";return r.some(i=>e.get(i.geom).legend.suppressWhenSingleItem||a)}function Uh(e,t,r,n,a){if(t!=="auto")return t;if(a.type==="polar")return"top";let i=!1,o=!1,s=!1;for(const u of n){const{sidePlacement:d}=e.get(u.geom).legend;d==="whenCrowded"&&(i=!0),d==="whenStackedVertical"&&(o=!0,l.isStackedPosition(u.position)&&(s=!0))}const c=r>=Lh;return i&&o?"top":i?c?"right":"top":s?zh(a)?"top":c?"right":"top":"top"}function Hh(e,t){return e==="pill"?"pill":ps(t)?"direct":"pill"}function zh(e){return e.type==="cartesian"&&e.mainAxis==="y"}function Wh(e){const t=e.scale.domain.map(l.getStableKey);return JSON.stringify([e.variableName,e.guideType,...t])}function Kh(e,t){return Tn(t)?"discrete":`continuous:${e}`}function Yh(e){if(!e)return new Map;const t=new Map;return e.data.groupBy(l.GROUP_VARIABLES.group).forEach(r=>{const n=r.findLast(c=>l.isDefined(_(c))||l.isDefined(R(c)));if(!n)return;const a=J(n);if(!l.isDefined(a))return;const i=B(n),o=_(n)??R(n);if(!l.isDefined(o))return;const s=l.isDefined(i)?(i+o)/2:o;t.set(String(a),s)}),t}var jh=class extends l.Stage{constructor(e){super(),this.container=e}dependencies(e){return[e.scales,e.config.axes,e.config.legend,e.config.headline,e.layers,e.coordSystem,e.originalData]}run(e){const t=Np(e.originalData),r=ch({scales:e.scales,layers:e.layers,valueLabels:Bp(e.originalData,e.layers,t)}),n={scales:e.scales,config:e.config,layers:e.layers,coordSystem:e.coordSystem,variableLabels:t,colorGroups:r,geomRegistry:this.container.geomRegistry},a=fh(n),i=Eh(n),o={...i,drawn:qh(a,i.drawn)};return{axes:Jp(n,o.drawn),legends:o,headline:a,colorGroups:r,variableLabels:t}}},qh=(e,t)=>e?.kind!=="perGroup"||t.some(r=>r.display==="direct")?t:[],Qt=(e,t,r)=>{switch(e){case"series":return Xh(t);case"x-value":return wn(t,r)}},xt=e=>{const t=l.readMainAxisVariable(e);return t===""?null:t},Xh=e=>l.getStableKey([J(e)]),wn=(e,t)=>l.getStableKey([t!==null?e[t]??null:null]),Zh={bar:"observation-rerender",rule:null,line:"overlay-anchor",area:"overlay-anchor",point:"overlay-anchor",tile:"observation-rerender"};function hs(e){const t=Zh[e]??null;return t===null?null:{strategy:t,composition:fs()}}function fs(){return{isDimmed:!1,matchedLayer:null,overlayCandidates:[]}}var Jh=class extends _e{constructor(e){super(),this.container=e}dependencies(e){return[e.highlights,e.config.parsingLocale]}compileLayer(e,t){const r=e.highlight;if(r===null)return e;const n=t.highlights.filter(({layerId:i})=>i===void 0||i===e.id);if(n.length===0)return e;const a=Qh({layer:e,highlights:n,parsingLocale:t.config.parsingLocale,strategy:r.strategy,container:this.container});return{...e,highlight:{...r,composition:a}}}};function Qh({layer:e,highlights:t,parsingLocale:r,strategy:n,container:a}){const i=t.filter(L=>{const P=ce(L.predicate,e.data);for(const k of P)a.diagnostics.addWarning({...k,message:`${k.message} Dropping this highlight.`});return P.length===0}),o=xt(e.mapping),s=nt(e,r),c=i.map(L=>({predicate:le(L.predicate,s),scope:L.scope})),u=c.some(({scope:L})=>L==="series"),d=c.some(({scope:L})=>L==="x-value"),m=n==="overlay-anchor",p=e.data.size(),h=u?new Array(p):null,f=d?new Array(p):null,g=m?new Array(p):null,v=new Uint8Array(p),y=new Set,A=new Set;let I=!1,x=0;for(const L of e.data){let P,k;h!==null&&(P=Qt("series",L,o),h[x]=P),f!==null&&(k=Qt("x-value",L,o),f[x]=k),g!==null&&(g[x]=L);for(const{predicate:re,scope:Bt}of c)if(re(L))switch(Bt){case"series":P!==void 0&&y.add(P);break;case"x-value":k!==void 0&&A.add(k);break;case"data-point":v[x]=1,I=!0;break}x++}if(y.size===0&&A.size===0&&!I)return fs();const T=new Uint8Array(p),E=[];let te=0;for(let L=0;L<p;L++){const P=h?.[L],k=f?.[L],re=P!==void 0&&y.has(P),Bt=k!==void 0&&A.has(k),Oa=v[L]===1;if(n==="observation-rerender")(re||Oa||Bt)&&(T[L]=1,te++);else if(re)T[L]=1,te++;else if(Oa||Bt){const _a=g?.[L];_a!==void 0&&E.push({observation:_a,observationIndex:L})}}const Le=te>0?{...e,data:e.data.filterByMask(T)}:null;return{isDimmed:(n==="observation-rerender"||y.size>0)&&Le!==null,matchedLayer:Le,overlayCandidates:E}}var ef=l.prefixInternalVariable("__ungrouped__");function tf(e){const t=e.getVariableNames().filter(a=>e.getType(a)==="temporal"&&l.isDateWithoutYearValueFormat(e.getValueFormat(a)));if(t.length===0)return e;const r=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical"});let n=e;for(const a of t){const i=n.getValues(a,{type:"temporal"}),o=new Map,s=i.map((c,u)=>{if(c===null)return null;const d=r[u]??ef;let m=o.get(d);return m||(m=new l.ChronologicalDateManager,o.set(d,m)),m.incrementYearIfNeeded(c)});n=n.addVariable(a,"temporal",s)}return n}var rf=()=>({defaults:[],overrides:[],warnings:[]}),nf=class extends _e{constructor(e,t,r,n,a,i){super(),this.container=e,this.transformCompiler=t,this.statCompiler=r,this.groupCompiler=n,this.geomCompiler=a,this.positionAdjusterCompiler=i}dependencies(e){return[e.data,e.mapping,qa(e),e.coords.coordType]}compileLayer(e,t){return this.runLayerPipeline({layer:e,data:this.transformCompiler.compile({data:t.data,transforms:e.transforms}),effectiveMapping:{...t.mapping,...e.mapping},xScaleIsDiscrete:qa(t),coordType:t.coords.coordType})}runLayerPipeline({layer:e,data:t,effectiveMapping:r,xScaleIsDiscrete:n,coordType:a}){const i=ur({data:t,mapping:r}).pipe(({data:s,mapping:c})=>{const u=this.statCompiler.compute(e.stat,{data:s,mapping:c,xScaleIsDiscrete:n});return{data:u.data,mapping:{...c,...u.mapping}}}).pipe(({data:s,mapping:c})=>({data:this.groupCompiler.compute({data:s,mapping:c}).data,mapping:c})).pipe(({data:s,mapping:c})=>({data:tf(s),mapping:c})).pipe(({data:s,mapping:c})=>{const u=this.geomCompiler.compile(e.geom,{data:s,mapping:c,params:e.params,coordType:a});return{data:u.data,mapping:{...c,...u.mapping}}}).pipe(({data:s,mapping:c})=>{const u=this.positionAdjusterCompiler.adjust(e.position,{data:s,mapping:c});return{data:u.data,mapping:{...c,...u.mapping}}}).result(),o=this.container.geomRegistry.get(e.geom);return{...i,id:e.id,geom:e.geom,position:e.position,yScaleType:e.yScaleType,params:e.params,interactive:e.interactive,dataLabels:e.dataLabels,summary:{},spatialKind:o.spatialKind,identityKey:o.identityKey,tooltip:o.tooltip,supportsDirectLabels:o.legend.directLabelSupport?.[e.position]===!0,highlight:hs(e.geom),styles:rf()}}};function qa(e){return e.scales.some(t=>t.scaledAesthetic==="x"&&t.scaleType==="discrete")}function gs(e,t){const[r]=t;if(r){for(const n of t)e.addError(n);throw new l.UserInputError(r)}}function af(e,t){return t.some(r=>l.isStackedPosition(r.position)||e.get(r.geom).scaleConstraints?.bandPadding===0)}function jr(e,t){const r=ys(e,t),n={};for(const{layer:i,scaleConstraints:o,crossAxis:s}of r)o.zeroBaseline===!0&&(n[s]={nice:(n[s]?.nice??!0)&&i.position!=="fill"});const a=r.find(({scaleConstraints:i})=>i.discreteCrossAxis===!0);return{discreteAxis:r.some(({scaleConstraints:i})=>i.discreteMainAxis===!0)?"x":null,discreteCrossAxis:a?.crossAxis??null,bandedAxes:sf(r),zeroAxes:n,bandPadding:lf(r),inferredColor:r.some(({scaleConstraints:i})=>i.inferredColor===!0)}}function of(e,t){const r=ys(e,t);for(const n of r){if(n.scaleConstraints.discreteCrossAxis!==!0)continue;const a=r.find(i=>i.scaleConstraints.zeroBaseline===!0&&i.crossAxis===n.crossAxis);if(a!==void 0)return{crossAxis:n.crossAxis,banded:Xa(n),zeroAnchored:Xa(a)}}return null}var Xa=({layer:e,index:t})=>({layerId:e.id,layerIndex:t,geom:e.geom});function ys(e,t){const r=[];return t.forEach((n,a)=>{if(!e.has(n.geom))return;const{scaleConstraints:i}=e.get(n.geom);i!==void 0&&r.push({layer:n,index:a,scaleConstraints:i,crossAxis:xe(n.yScaleType)})}),r}function sf(e){const t=new Set;for(const{scaleConstraints:r,crossAxis:n}of e)r.discreteMainAxis===!0&&t.add("x"),r.discreteCrossAxis===!0&&t.add(n);return[...t]}function lf(e){const t={};for(const r of e){const n=r.scaleConstraints.bandPadding;if(n!==void 0)for(const a of cf(r)){const i=t[a];t[a]=i===void 0?n:Math.min(i,n)}}return t}function cf({scaleConstraints:e,crossAxis:t}){return e.discreteCrossAxis!==!0?["x"]:e.discreteMainAxis===!0?["x",t]:[t]}var uf=new Set(["label","group"]),df=class{constructor(e,t,r,n){this.container=e,this.transformCompiler=t,this.statRegistry=r,this.layerCompiler=n}get stats(){return this.layerCompiler.stats}compile(e){this.checkPreCompile(e);const t=this.layerCompiler.compile(e);return this.checkPostCompile(t),t}checkPreCompile(e){const t=[];e.layers.forEach((r,n)=>{const a=this.transformCompiler.compile({data:e.data,transforms:r.transforms}),i={...e.mapping,...r.mapping},o={layerId:r.id,layerIndex:n,geom:r.geom,position:r.position,stat:r.stat,effectiveMapping:i,data:a,coordType:e.coords.coordType,dataLabels:r.dataLabels};t.push(...this.validateLayer(o));const s=[...this.collectUndeclaredAesthetics(o),...this.collectPanelJustifyWarnings(o)];for(const c of s)this.container.diagnostics.addWarning(c)}),t.push(...this.validateSharedScaleDemands(e.layers)),gs(this.container.diagnostics,t)}checkPostCompile(e){Uo(e)&&this.container.diagnostics.addWarning({code:"EMPTY_DATASET",message:"No data to plot — every layer resolved to zero observations.",suggestion:"Check the dataset has rows and that transforms (filters, joins) are not removing them all."})}validateLayer(e){return[...this.validateRequiredAesthetics(e),...this.validateVariableExistence(e),...this.validatePositionalAestheticTypes(e),...this.validateGeomMapping(e),...this.validateCoordSupport(e),...this.validateSupportedPosition(e)]}collectPanelJustifyWarnings({geom:e,effectiveMapping:t,data:r,layerIndex:n,coordType:a,dataLabels:i}){const{justify:o,showDataLabels:s}=i;if(!s||o!=="panel-start"&&o!=="panel-end")return[];if(a==="polar"||!this.container.geomRegistry.get(e).isComposite)return[];if(!mr(r,t))return[];const c=o==="panel-end"?"end":"start";return[{code:"DATA_LABEL_PLACEMENT_COERCED",message:`Multiple ${e} groups would all pin their labels to the same panel edge; justify '${o}' will render as '${c}'.`,context:{layerIndex:n,expected:c,actual:o},suggestion:`Use justify '${c}' for this layer.`}]}validateRequiredAesthetics({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const i=[],{positionRoles:o,aesthetics:s}=this.container.geomRegistry.get(r),c=[...Mp(o),...s.filter(m=>m.required).map(m=>m.name)],{computedVariables:u}=this.statRegistry.get(n.type),d=u;for(const m of c)d.has(m)||l.isDefined(a[m])||i.push({code:"MISSING_AESTHETIC",message:`Layer '${e}': geom '${r}' requires aesthetic '${m}'`,context:{layerIndex:t,aesthetic:m}});return i}validateVariableExistence({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a,data:i}){const o=[],{computedVariables:s}=this.statRegistry.get(n.type),{derivedVariables:c}=this.container.geomRegistry.get(r),u=s,d=new Set(c);for(const[m,p]of Object.entries(a)){if(u.has(m))continue;const h=l.readVariableName(p);h===null||h===""||d.has(h)||i.hasVariable(h)||o.push({code:"UNKNOWN_VARIABLE",message:`Layer '${e}': aesthetic '${m}' references variable '${h}' which does not exist in the dataset`,context:{layerIndex:t,aesthetic:m,variableName:h}})}return o}validatePositionalAestheticTypes({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a,data:i}){const{positionRoles:o}=this.container.geomRegistry.get(r),{computedVariables:s}=this.statRegistry.get(n.type),c=s,u=[];for(const d of o){if(!rs.has(d.role)||!l.isDefined(d.aes)||c.has(d.aes)||d.role==="scalar"&&d.aes===d.axis)continue;const m=l.readVariableName(a[d.aes]);if(m===null||!i.hasVariable(m)||i.size()===0)continue;const p=i.getType(m);p!=="numeric"&&u.push({code:"INCOMPATIBLE_TYPE",message:`Layer '${e}': aesthetic '${d.aes}' must be numeric, but variable '${m}' is ${p}`,context:{layerIndex:t,aesthetic:d.aes,variableName:m,variableType:p},suggestion:this.suggestNumericAestheticFix(d.aes,d.axis,a,i)})}return u}suggestNumericAestheticFix(e,t,r,n){const a=t==="y"?"x":"y";if(e===t){const i=l.readVariableName(r[a]);if(i!==null&&n.hasVariable(i)&&n.getType(i)==="numeric")return`Swap the '${a}' and '${t}' mappings so the numeric variable is on '${t}'. Add coord.flip() to orient the graph horizontally.`}return`Map '${e}' to a numeric variable.`}validateGeomMapping({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const{validateMapping:i}=this.container.geomRegistry.get(r);if(i===void 0)return[];const{computedVariables:o}=this.statRegistry.get(n.type);return i({mapping:a,computedVariables:o}).map(s=>({...s,message:`Layer '${e}': ${s.message}`,context:{...s.context,layerIndex:t}}))}validateSharedScaleDemands(e){const t=of(this.container.geomRegistry,e);if(t===null)return[];const{crossAxis:r,banded:n,zeroAnchored:a}=t;return[{code:"CONFLICTING_SCALE_DEMANDS",message:`Layer '${n.layerId}' (geom '${n.geom}') needs '${r}' to be a band scale, but layer '${a.layerId}' (geom '${a.geom}') needs it to be a value axis anchored at zero. One scale cannot be both.`,context:{aesthetic:r,layerId:n.layerId,layerIndex:n.layerIndex},suggestion:"Drop one of the layers, or move one onto the secondary y axis with 'yScaleType'."}]}validateCoordSupport({layerId:e,layerIndex:t,geom:r,coordType:n}){const{supportedCoordTypes:a}=this.container.geomRegistry.get(r);return a.includes(n)?[]:[{code:"UNSUPPORTED_COORD",message:`Layer '${e}': geom '${r}' is not supported under ${n} coords`,context:{layerIndex:t}}]}validateSupportedPosition({layerId:e,layerIndex:t,geom:r,position:n}){const{supportedPositions:a}=this.container.geomRegistry.get(r);return a.includes(n)?[]:[{code:"UNSUPPORTED_POSITION",message:`Layer '${e}': geom '${r}' does not support the '${n}' position`,context:{layerIndex:t},suggestion:`Use one of: ${a.join(", ")}.`}]}collectUndeclaredAesthetics({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const{positionRoles:i,aesthetics:o}=this.container.geomRegistry.get(r),{computedVariables:s}=this.statRegistry.get(n.type),c=new Set([...Dp(i),...o.map(p=>p.name)]),u=uf,d=s,m=[];for(const p of Object.keys(a))l.isDefined(a[p])&&(c.has(p)||u.has(p)||d.has(p)||m.push({code:"UNDECLARED_AESTHETIC",message:`Layer '${e}': geom '${r}' does not declare aesthetic '${p}'; the mapping is ignored`,context:{layerIndex:t,aesthetic:p}}));return m}},ve=class{constructor(){this.positionRoles=[],this.identityKey="x-group",this.defaultPosition="identity",this.supportedPositions=l.POSITION_ADJUSTMENTS,this.defaultInteractive=!0,this.aesthetics=[],this.derivedVariables=[],this.highlightStrategy="overlay-anchor",this.supportedCoordTypes=["cartesian","flip"],this.spatialKind="points",this.grid={},this.legend={},this.dataLabelCoordTypes=[],this.isComposite=!1,this.tooltip=[],this.summaries={}}resolveParams(e){return(0,tt.merge)({},this.defaultParams,e.params)}},Rn=(e,t)=>{const r=l.readVariableName(t.x);return!r||!["numeric","temporal"].includes(e.getType(r))?e:e.orderBy(r,"asc")},Cn=(e,{coordSystem:t})=>{const r=V(e),n=R(e);return!l.isStrictNumericDataValue(r)||!l.isStrictNumericDataValue(n)?null:t.type==="polar"?we(r,n):{x:r,y:n}},mf=class extends ve{constructor(...e){super(...e),this.type="area",this.supportedCoordTypes=["cartesian","polar","flip"],this.defaultParams={curve:"linear",missingValues:"zero"},this.defaultPosition="stack",this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value",aes:"y"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"strokeWidth"},{kind:"visual",name:"lineType"},{kind:"visual",name:"alpha"}],this.summaries={perGroupHeadline:!0},this.dataLabels={cartesian:{offset:8},flip:{offset:8}},this.dataLabelCoordTypes=["cartesian","flip"],this.isComposite=!0,this.legend={suppressWhenSingleItem:!0,sidePlacement:"whenCrowded",directLabelSupport:{stack:!0,dodge:!0,identity:!0,fill:!0}},this.spatialKind="filled-buckets",this.resolveAnchorPosition=Cn}resolveParams(e){const t=super.resolveParams(e);return t.missingValues==="gap"?{...t,missingValues:"zero"}:t}compile({data:e,mapping:t}){return e=Rn(e,t),e.hasVariable(l.POSITION_VARIABLES.yMin)||(e=e.addConstantVariable(l.POSITION_VARIABLES.yMin,"numeric",0)),{data:e,mapping:{}}}},pf=.7,hf=.1,ff=.03,gf=.05,vs=e=>{const t=e[l.STACK_VARIABLES.role];return t??"solo"},yf=class extends ve{constructor(...e){super(...e),this.type="bar",this.defaultParams={},this.defaultPosition="dodge",this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value",aes:"y"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"alpha"}],this.summaries={grandTotal:!0,stackTotals:!0,perGroupHeadline:!0},this.grid={cartesian:{hideGridX:!0},flip:{hideGridX:!0}},this.legend={suppressWhenSingleItem:!0,sidePlacement:"whenStackedVertical",directLabelSupport:{stack:!0,fill:!0}},this.scaleConstraints={discreteMainAxis:!0,zeroBaseline:!0},this.dataLabels={polar:{format:"percentage"}},this.dataLabelCoordTypes=["cartesian","flip","polar"],this.highlightStrategy="observation-rerender",this.supportedCoordTypes=["cartesian","polar","flip"],this.spatialKind="rects",this.resolveDataLabelDefaults=t=>l.isStackedPosition(t)?{justify:"center"}:{},this.resolveBandFraction=(t,r)=>qr(t,r.type),this.resolveAnchorPosition=(t,{coordSystem:r,position:n,purpose:a,align:i})=>{if(i!==void 0){const m=fn(t,r);return m===null?null:yt(m,i)}if(r.type==="polar")return vf(t);const o=l.isStackedPosition(n),s={isSolo:!o||vs(t)==="solo",isNegative:o&&bf(t),purpose:a};if(r.mainAxis==="x"){const m=z(t),p=W(t),h=Za({lowerBound:B(t),upperBound:_(t)??R(t),options:s});return m===null||p===null||h===null?null:{x:(m+p)/2,y:h}}const c=B(t),u=_(t),d=Za({lowerBound:z(t),upperBound:W(t)??V(t),options:s});return c===null||u===null||d===null?null:{x:d,y:(c+u)/2}}}resolveParams(e){const{width:t,...r}=super.resolveParams(e),n=this.resolveWidthParam(t,e.diagnostics);return{...r,...n!==void 0&&{width:n}}}compile({data:e,mapping:t,params:r,coordType:n}){const a=qr(r,n);e=Rn(e,t),e.hasVariable(l.POSITION_VARIABLES.yMin)||(e=e.addConstantVariable(l.POSITION_VARIABLES.yMin,"numeric",0));const i=a/2;return e=e.addConstantVariable(l.POSITION_VARIABLES.xMin,"numeric",-i).addConstantVariable(l.POSITION_VARIABLES.xMax,"numeric",i),{data:e,mapping:{}}}resolveWidthParam(e,t){if(e===void 0)return;const r=typeof e=="number"&&Number.isFinite(e)?e:null;if(r!==null&&r>0&&r<=1)return r;const n=r!==null&&r>1?1:void 0;return t?.addWarning({code:"INVALID_GEOM_PARAM",message:`Bar width must be a fraction in (0, 1], got ${String(e)}; falling back to ${n??"the default band"}.`,context:{geom:this.type,param:"width",expected:"0 < width <= 1",actual:r??String(e)},suggestion:"Set params.width to a fraction of the category band in (0, 1]."}),n}},qr=({width:e},t)=>e!==void 0?e:t==="polar"?1:pf,vf=e=>{const t=z(e),r=W(e),n=B(e),a=_(e);return t===null||r===null||n===null||a===null?null:we((t+r)/2,(n+a)/2)},bf=e=>{const t=hn(e);return l.isStrictNumericDataValue(t)&&t<0},Za=e=>{const{lowerBound:t,upperBound:r,options:n}=e,a=n.isNegative?t:r;if(a===null)return null;if(n.purpose==="value"||n.isSolo)return a;const i=n.isNegative?r:t;return i===null?null:(i+a)/2},Sf=class extends ve{constructor(...e){super(...e),this.type="line",this.supportedCoordTypes=["cartesian","polar","flip"],this.defaultParams={curve:"linear",missingValues:"gap"},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"point",valueKind:"value"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"strokeWidth"},{kind:"visual",name:"lineType"},{kind:"visual",name:"alpha"}],this.summaries={perGroupHeadline:!0},this.dataLabels={cartesian:{offset:8},flip:{offset:8}},this.dataLabelCoordTypes=["cartesian","flip"],this.isComposite=!0,this.legend={suppressWhenSingleItem:!0,sidePlacement:"whenCrowded",directLabelSupport:{stack:!0,dodge:!0,identity:!0,fill:!0}},this.spatialKind="buckets",this.resolveAnchorPosition=Cn}compile(e){return{data:Rn(e.data,e.mapping),mapping:{}}}},Af=class extends ve{constructor(...e){super(...e),this.type="point",this.supportedCoordTypes=["cartesian","polar","flip"],this.defaultParams={},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"point",valueKind:"value"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"size"},{kind:"visual",name:"alpha"}],this.summaries={perGroupHeadline:!0},this.dataLabelCoordTypes=["cartesian","flip"],this.resolveAnchorPosition=Cn,this.resolveValueSource=(t,r)=>{if(r!=="label")return null;const n=l.readVariableName(t.size);return n!==null?{variable:n}:null}}compile({data:e}){return{data:e,mapping:{}}}},xf=class extends ve{constructor(...e){super(...e),this.type="rule",this.defaultParams={labelPosition:"start"},this.defaultInteractive=!1,this.positionRoles=[{axis:"y",role:"scalar",valueKind:"value",aes:"y"},{axis:"x",role:"scalar",valueKind:"value",aes:"x"}],this.highlightStrategy=null,this.spatialKind="noop",this.validateMapping=({mapping:t,computedVariables:r})=>{const n=r.has("x")||l.isStrictNumericDataValue(l.readConstantValue(t.x)),a=r.has("y")||l.isStrictNumericDataValue(l.readConstantValue(t.y));return n&&a?[{code:"INVALID_RULE_MAPPING",message:"rule geom requires exactly one of 'x' or 'y', both were provided"}]:!n&&!a?[{code:"INVALID_RULE_MAPPING",message:"rule geom requires a numeric value on 'x' or 'y'"}]:[]}}compile({data:e,mapping:t}){const r=Ja(t.y,e);if(r!==null)return{data:new l.Dataset({[l.RULE_VARIABLES.y]:{type:"numeric",values:[r.value],valueFormat:r.sourceFormat}}),mapping:{y:l.RULE_VARIABLES.y,x:void 0}};const n=Ja(t.x,e);return n!==null?{data:new l.Dataset({[l.RULE_VARIABLES.x]:{type:"numeric",values:[n.value],valueFormat:n.sourceFormat}}),mapping:{x:l.RULE_VARIABLES.x,y:void 0}}:{data:new l.Dataset,mapping:{x:void 0,y:void 0}}}},Ja=(e,t)=>{const r=l.readConstantValue(e);if(l.isStrictNumericDataValue(r))return{value:r,sourceFormat:void 0};const n=l.readVariableName(e);if(n===null||!l.isStatVariable(n)||!t.hasVariable(n))return null;const[a]=t.getValues(n);return l.isStrictNumericDataValue(a)?{value:a,sourceFormat:t.getValueFormat(n)}:null},If=e=>{const t=l.readVariableName(e.color);return t!==null?{variable:t}:null},Tf=class extends ve{constructor(...e){super(...e),this.type="tile",this.defaultParams={},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"x",role:"min",valueKind:"value"},{axis:"x",role:"max",valueKind:"value"},{axis:"y",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value"}],this.supportedPositions=["identity"],this.supportedCoordTypes=["cartesian"],this.aesthetics=[{kind:"visual",name:"color",required:!0}],this.scaleConstraints={discreteMainAxis:!0,discreteCrossAxis:!0,bandPadding:0,inferredColor:!0},this.grid={cartesian:{hideGridX:!0,hideGridY:!0}},this.legend={suppressWhenSingleItem:!1},this.dataLabels={cartesian:{showDataLabels:!0}},this.dataLabelCoordTypes=["cartesian"],this.highlightStrategy="observation-rerender",this.spatialKind="cells",this.identityKey="x-y",this.tooltip=[{aes:"color"}],this.resolveValueSource=If,this.resolveAnchorPosition=t=>{const r=z(t),n=W(t),a=B(t),i=_(t);return r===null||n===null||a===null||i===null?null:{x:(r+n)/2,y:(a+i)/2}}}compile({data:e}){return{data:e.addConstantVariable(l.POSITION_VARIABLES.xMin,"numeric",-.5).addConstantVariable(l.POSITION_VARIABLES.xMax,"numeric",.5).addConstantVariable(l.POSITION_VARIABLES.yMin,"numeric",-.5).addConstantVariable(l.POSITION_VARIABLES.yMax,"numeric",.5),mapping:{}}}},Lf=[new yf,new Af,new Sf,new mf,new xf,new Tf],hr=class extends l.Registry{constructor(){super("geom");for(const e of Lf)this.register(e.type,e)}},ke=class{compute(e){return e.data.size()===0?{data:e.data,mapping:{}}:this.computeStat(e)}},Ef=class extends ke{constructor(...e){super(...e),this.type="count",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=l.readVariableName(t.x);if(!l.isDefined(r))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'x' variable is required for 'count' stat",context:{aesthetic:"x"},suggestion:"Map a variable to 'x' when using the 'count' stat."});if(l.readVariableName(t.y)!==null)throw new l.UserInputError({code:"CONFLICTING_STAT_MAPPING",message:"Cannot map 'y' variable together with 'count' stat",context:{aesthetic:"y"},suggestion:"Remove the 'y' mapping; the 'count' stat computes it."});const n=[...new Set([r,...pe(e,t)])];return{data:e.groupBy(...n).rollup({[l.STAT_VARIABLES.count]:{variableName:r,aggregation:"count"}}),mapping:{y:l.STAT_VARIABLES.count}}}},wf=class extends ke{constructor(...e){super(...e),this.type="identity",this.computedVariables=new Set}computeStat({data:e}){return{data:e,mapping:{}}}},Rf=class extends ke{constructor(...e){super(...e),this.type="mean",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=l.readVariableName(t.y);if(!l.isDefined(r))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'mean' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'mean' stat."});return{data:e.rollup({[l.STAT_VARIABLES.mean]:{variableName:r,aggregation:"mean"}}),mapping:{y:l.STAT_VARIABLES.mean}}}},Cf=2,bs=1440*60*1e3,Vf=class extends ke{constructor(...e){super(...e),this.type="smooth",this.computedVariables=new Set}computeStat({data:e,mapping:t,spec:r,xScaleIsDiscrete:n}){if(r.type!=="smooth")throw new l.InternalError({message:`SmoothStat received a spec of type '${r.type}'`});const a=l.readVariableName(t.x),i=l.readVariableName(t.y);if(!l.isDefined(a))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'x' variable is required for 'smooth' stat",context:{aesthetic:"x"},suggestion:"Map a variable to 'x' when using the 'smooth' stat."});if(!l.isDefined(i))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'smooth' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'smooth' stat."});const o=e.getType(a),s=e.getType(i);if(s!=="numeric")throw new l.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'smooth' stat requires a numeric 'y' (got '${s}' for variable '${i}')`,context:{aesthetic:"y",variableName:i,variableType:s}});const c=pe(e,t),u=Nf(a,o,i,c,e);return c.length===0?Qa({data:e,xVariable:a,xType:o,yVariable:i,spec:r,output:u,groupObservation:{},xScaleIsDiscrete:n}):e.groupBy(...c).forEach(d=>{const m=Bf(d,c);Qa({data:d,xVariable:a,xType:o,yVariable:i,spec:r,output:u,groupObservation:m,xScaleIsDiscrete:n})}),{data:u.build(),mapping:{}}}},Qa=({data:e,xVariable:t,xType:r,yVariable:n,spec:a,output:i,groupObservation:o,xScaleIsDiscrete:s})=>{const{observations:c,temporalOrigin:u}=Mf({data:e,xVariable:t,yVariable:n,xType:r});c.length<Cf||(s?kf({observations:c,spec:a,output:i,groupObservation:o}):Of({observations:c,xType:r,temporalOrigin:u,spec:a,output:i,groupObservation:o}))},Mf=({data:e,xVariable:t,yVariable:r,xType:n})=>{const a=e.getValues(t),i=e.getValues(r,{type:"numeric"}),o=n==="temporal"?Df(a):null,s=[],c=new Map;for(let u=0;u<a.length;u++){const d=a[u],m=i[u];if(!l.isDefined(d)||!l.isDefined(m)||!Number.isFinite(m))continue;const p=Pf({xValue:d,xType:n,categoryRank:c,temporalOrigin:o});p!==null&&s.push({x:p,y:m,originalX:d})}return{observations:s,temporalOrigin:o}},Df=e=>{let t=null;for(const r of e){if(!l.isStrictTemporalDataValue(r))continue;const n=r.getTime();(t===null||n<t)&&(t=n)}return t},Pf=({xValue:e,xType:t,categoryRank:r,temporalOrigin:n})=>{switch(t){case"numeric":return!l.isStrictNumericDataValue(e)||!Number.isFinite(e)?null:e;case"temporal":{if(!l.isStrictTemporalDataValue(e))return null;const a=e.getTime();return n===null?a:(a-n)/bs+1}case"categorical":{if(!l.isStrictCategoricalDataValue(e))return null;const a=r.get(e);if(a!==void 0)return a;const i=r.size+1;return r.set(e,i),i}default:throw new l.InternalError({message:`Unexpected xType: ${t}`})}},Of=({observations:e,xType:t,temporalOrigin:r,spec:n,output:a,groupObservation:i})=>{const o=Ss(n,e);for(const[s,c]of o){if(!Number.isFinite(s)||!Number.isFinite(c))continue;const u=t==="temporal"?_f(s,r):s;a.push({x:u,y:c,groupObservation:i})}},_f=(e,t)=>t===null?new Date(e):new Date((e-1)*bs+t),kf=({observations:e,spec:t,output:r,groupObservation:n})=>{const a=new Map;for(const s of e)a.has(s.x)||a.set(s.x,s.originalX);const i=[...a.keys()].sort((s,c)=>s-c);if(t.method==="loess"){const s=Ss(t,e),c=new Map;for(const[u,d]of s)Number.isFinite(d)&&(c.has(u)||c.set(u,d));for(const u of i){const d=c.get(u),m=a.get(u);d===void 0||m===void 0||r.push({x:m,y:d,groupObservation:n})}return}const o=As(t,e);for(const s of i){const c=a.get(s),u=o.predict(s);c===void 0||!Number.isFinite(u)||r.push({x:c,y:u,groupObservation:n})}},Ss=(e,t)=>e.method==="loess"?(0,Ee.regressionLoess)().x(r=>r.x).y(r=>r.y).bandwidth(e.bandwidth)(t):As(e,t),As=(e,t)=>{const r=a=>a.x,n=a=>a.y;switch(e.method){case"linear":return(0,Ee.regressionLinear)().x(r).y(n)(t);case"exponential":return(0,Ee.regressionExp)().x(r).y(n)(t);case"logarithmic":return(0,Ee.regressionLog)().x(r).y(n)(t);case"quadratic":return(0,Ee.regressionQuad)().x(r).y(n)(t);case"power":return(0,Ee.regressionPow)().x(r).y(n)(t);case"polynomial":return(0,Ee.regressionPoly)().x(r).y(n).order(e.order)(t);case"loess":throw new l.InternalError({message:"'loess' does not expose a 'predict' function"})}},Nf=(e,t,r,n,a)=>{const i=[],o=[],s=Object.fromEntries(n.map(c=>[c,[]]));return{push:({x:c,y:u,groupObservation:d})=>{i.push(c),o.push(u);for(const m of n)s[m]?.push(d[m]??null)},build:()=>{const c={[e]:{type:t,values:i,valueFormat:a.getValueFormat(e)},[r]:{type:"numeric",values:o,valueFormat:a.getValueFormat(r)}};for(const u of n)c[u]={type:a.getType(u),values:s[u]??[],valueFormat:a.getValueFormat(u)};return new l.Dataset(c)}}},Bf=(e,t)=>{const r={};for(const n of t)r[n]=e.getValues(n)[0]??null;return r},Ff=class extends ke{constructor(...e){super(...e),this.type="sum",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=l.readVariableName(t.y);if(!l.isDefined(r))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'sum' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'sum' stat."});const n=l.readVariableName(t.x),a=[...new Set([...n===null?[]:[n],...pe(e,t)])];return{data:e.groupBy(...a).rollup({[l.STAT_VARIABLES.sum]:{variableName:r,aggregation:"sum"}}),mapping:{y:l.STAT_VARIABLES.sum}}}},Gf=[new wf,new Ef,new Vf,new Rf,new Ff],$f=class extends l.Registry{constructor(){super("stat");for(const e of Gf)this.register(e.type,e)}};function Uf({geoms:e,stats:t,transforms:r}){const n=new hr,a=new $f,i=new l.TransformRegistry;for(const o of e)n.register(o.type,o);for(const o of t)a.register(o.type,o);for(const o of r)i.register(o.transformType,o);return{geomRegistry:n,statRegistry:a,transformRegistry:i}}function Vn(e){if("definition"in e)return e.definition;if(Is(e)||Ts(e)||Ls(e))return e}function xs(e){const t=[],r=[],n=[];for(const a of e){const i=Vn(a);i&&(Is(i)?t.push(i):Ts(i)?r.push(i):Ls(i)&&n.push(i))}return{geoms:t,stats:r,transforms:n,warnings:[...Pr("geom",t,a=>a.type),...Pr("stat",r,a=>a.type),...Pr("transform",n,a=>a.transformType),...Hf(t),...zf(t)]}}function Hf(e){const t=[];for(const r of e)r.spatialKind==="render-hit-test"&&(r.identityKey!=="x-group"&&r.identityKey!=="x-y"||t.push({code:"RENDER_HIT_TEST_IDENTITY",message:`The render-hit-test geom '${r.type}' uses the position-derived '${r.identityKey}' identity, which has no meaning for render-owned geometry; its hover lookup will be empty.`,context:{kind:"geom",requested:r.type},suggestion:"Declare 'identityKey' as a column the geom owns (`{ variable: '<column>' }`) or 'index', so a hit-test result resolves to an observation."}));return t}function zf(e){const t=[];for(const r of e)r.spatialKind!=="cells"||!r.supportedCoordTypes.includes("polar")||t.push({code:"SPATIAL_KIND_COORD_UNSUPPORTED",message:`The geom '${r.type}' declares polar support, but its 'cells' hit-test shape has no polar projection; its observations will not respond to hover under polar coords.`,context:{kind:"geom",requested:r.type},suggestion:"Drop 'polar' from 'supportedCoordTypes', or declare 'rects' as the spatial kind so a bandless polar layer hit-tests as an enclosure."});return t}function Pr(e,t,r){const n=new Map;for(const i of t){const o=r(i),s=n.get(o);s?s.add(i):n.set(o,new Set([i]))}const a=[];for(const[i,o]of n)o.size<2||a.push({code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple plugins register the ${e} '${i}' (${o.size} definitions); the last in the array wins.`,context:{kind:e,requested:i},suggestion:`Remove the duplicate ${e} plugin(s) named '${i}', or rename them so each registers a distinct ${e}.`});return a}var Is=e=>e instanceof ve,Ts=e=>e instanceof ke,Ls=e=>"transformType"in e&&typeof e.apply=="function",Wf=class{constructor(e){this.registry=e}adjust(e,t){return this.registry.get(e).adjust(t)}},fr=class{},Kf=class extends fr{constructor(...e){super(...e),this.type="dodge"}adjust({data:e,mapping:t}){if(!l.readVariableName(t.x))return{data:e,mapping:{}};const r=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical",distinct:!0,skipNulls:!0});if(r.length===0)return{data:e,mapping:{}};const n=e.size(),a=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}),i=Yf(e)??[-.7/2,.7/2],o=r.length>1?hf:0,s=(0,ie.scaleBand)().domain(r.map(String)).range(i).paddingInner(o).paddingOuter(0),c=s.bandwidth(),u=new Array(n).fill(null),d=new Array(n).fill(null);for(let m=0;m<n;m++){const p=a[m];if(!l.isDefined(p))continue;const h=s(String(p));l.isDefined(h)&&(u[m]=h,d[m]=h+c)}return{data:e.addVariable(l.POSITION_VARIABLES.xMin,"numeric",u).addVariable(l.POSITION_VARIABLES.xMax,"numeric",d),mapping:{}}}},Yf=e=>{const t=e.getConstant(l.POSITION_VARIABLES.xMin)?.value,r=e.getConstant(l.POSITION_VARIABLES.xMax)?.value;return typeof t!="number"||typeof r!="number"?null:[t,r]},ei=l.prefixInternalVariable("__ungrouped__"),Es=(e,t)=>{const r=l.readVariableName(t.x),n=l.readVariableName(t.y);if(!r||!n)return null;const a=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical",distinct:!0,skipNulls:!0}),i=a.length===0,o=i?[ei]:a,s=e.getValues(r),c=e.getValues(n,{type:"numeric"}),u=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}),d=e.size(),m=new Map;for(let p=0;p<d;p++){const h=l.getStableKey(s[p]??null),f=u[p],g=i?ei:f;if(!l.isDefined(g))continue;let v=m.get(h);v||(v=new Map,m.set(h,v));let y=v.get(g);y||(y=[],v.set(g,y)),y.push(p)}return{yValues:c,observationIndicesByXAndGroup:m,uniqueGroupKeys:o,observationCount:d}},ws=(e,t,r,n)=>{const a=new Array(n).fill(null);for(const[,i]of r){const o=[];let s=-1,c=1/0,u=-1/0,d=-1,m=1/0,p=-1/0;for(const h of i.values())for(const f of h){const g=e[f],v=t[f];!l.isDefined(g)||!l.isDefined(v)||(o.push(f),(g<c||g===c&&v>u)&&(s=f,c=g,u=v),(v>p||v===p&&g<m)&&(d=f,m=g,p=v))}for(const h of o)a[h]=jf(h===s,h===d)}return a},jf=(e,t)=>e&&t?"solo":e?"floor":t?"ceiling":"middle",qf=class extends fr{constructor(...e){super(...e),this.type="fill"}adjust({data:e,mapping:t}){const r=Es(e,t);if(r===null)return{data:e,mapping:{}};const{yValues:n,observationIndicesByXAndGroup:a,uniqueGroupKeys:i,observationCount:o}=r,s=[...n],c=new Array(o).fill(0);for(const[,d]of a){let m=0,p=0;for(const g of i){const v=d.get(g);if(v!==void 0)for(const y of v){const A=n[y];A!=null&&(A>=0?m+=A:p-=A)}}let h=0,f=0;for(const g of i){const v=d.get(g);if(v!==void 0)for(const y of v){const A=n[y];if(A===void 0)continue;if(A===null){c[y]=null,s[y]=null;continue}const I=A>=0?m:p;if(I===0){c[y]=0,s[y]=0;continue}const x=A/I;A>=0?(c[y]=h,s[y]=h+=x):(s[y]=f,c[y]=f+=x)}}}const u=ws(c,s,a,o);return{data:e.addVariable(l.POSITION_VARIABLES.yMin,"numeric",c).addVariable(l.POSITION_VARIABLES.yMax,"numeric",s).addVariable(l.POSITION_VARIABLES.yRaw,"numeric",n).addVariable(l.STACK_VARIABLES.role,"categorical",u),mapping:{}}}},Xf=class extends fr{constructor(...e){super(...e),this.type="identity"}adjust({data:e}){return{data:e,mapping:{}}}},Zf=class extends fr{constructor(...e){super(...e),this.type="stack"}adjust({data:e,mapping:t}){const r=Es(e,t);if(r===null)return{data:e,mapping:{}};const{yValues:n,observationIndicesByXAndGroup:a,uniqueGroupKeys:i,observationCount:o}=r,s=[...n],c=new Array(o).fill(0);for(const[,p]of a){let h=0,f=0;for(const g of i){const v=p.get(g);if(v!==void 0)for(const y of v){const A=n[y];if(A!==void 0){if(A===null){c[y]=null,s[y]=null;continue}A>=0?(c[y]=h,s[y]=h+=A):(s[y]=f,c[y]=f+=A)}}}}const u=ws(c,s,a,o);let d=e.addVariable(l.POSITION_VARIABLES.yMin,"numeric",c).addVariable(l.POSITION_VARIABLES.yMax,"numeric",s).addVariable(l.POSITION_VARIABLES.yRaw,"numeric",n).addVariable(l.STACK_VARIABLES.role,"categorical",u);const m=l.readVariableName(t.y);return m!==null&&(d=d.addVariable(m,"numeric",s)),{data:d,mapping:{}}}},Jf=class extends l.Registry{constructor(){super("position"),this.register("identity",new Xf),this.register("stack",new Zf),this.register("fill",new qf),this.register("dodge",new Kf)}},Qf=class{map({data:e,layer:t,getPositionScale:r,geomRegistry:n}){let a=e;const i=n.get(t.geom);for(const o of i.positionRoles){if(o.role!=="scalar"||!l.isDefined(o.aes)||In(o.aes))continue;const s=l.readVariableName(t.mapping[o.aes]);if(!l.isDefined(s)||!a.hasVariable(s))continue;const c=r(as(o.axis,t.yScaleType));if(!c)continue;const u=a.getValues(s,{type:"numeric"}).map(d=>l.isDefined(d)?c.map(d):null);a=a.addVariable(l.resolveScaledAestheticVariable(o.aes),"numeric",u)}return a}},eg=class{map({data:e,layer:t,getPositionScale:r}){const n=l.readVariableName(t.mapping.x),a=r("x");if(!n||!a)return e;const i=e.getValues(n).map(o=>l.isDefined(o)?a.map(o):null);return e.addVariable(l.POSITION_VARIABLES.x,"numeric",i)}},tg=class{map({data:e,getPositionScale:t}){const r=t("x");if(!r||!e.hasVariable(l.POSITION_VARIABLES.xMin)||!e.hasVariable(l.POSITION_VARIABLES.xMax))return e;const n=r.bandwidth,a=l.isDefined(n)&&e.hasVariable(l.POSITION_VARIABLES.x)?rg(e,r,n):ng(e,r);return e.addVariable(l.POSITION_VARIABLES.xMin,"numeric",a.min).addVariable(l.POSITION_VARIABLES.xMax,"numeric",a.max)}};function rg(e,t,r){const n=e.getValues(l.POSITION_VARIABLES.x,{type:"numeric"}),a=e.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),i=e.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),o="reverse"in t.spec&&t.spec.reverse===!0,s=e.size(),c=Rs(s);for(let u=0;u<s;u++){const d=n[u],m=a[u],p=i[u];!l.isDefined(d)||!l.isDefined(m)||!l.isDefined(p)||(c.min[u]=d+(o?-p:m)*r,c.max[u]=d+(o?-m:p)*r)}return c}function ng(e,t){const r=e.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),n=e.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),a=e.size(),i=Rs(a);for(let o=0;o<a;o++){const s=r[o],c=n[o];!l.isDefined(s)||!l.isDefined(c)||(i.min[o]=t.map(s),i.max[o]=t.map(c))}return i}function Rs(e){return{min:new Array(e).fill(null),max:new Array(e).fill(null)}}var ag=class{map({data:e,layer:t,getPositionScale:r}){const n=l.readVariableName(t.mapping.y),a=r(xe(t.yScaleType));if(!n||!a)return e;const i=e.getValues(n).map(o=>l.isDefined(o)?a.map(o):null);return e.addVariable(l.POSITION_VARIABLES.y,"numeric",i)}},ig=class{map({data:e,layer:t,getPositionScale:r}){const n=r(xe(t.yScaleType));if(!n||!e.hasVariable(l.POSITION_VARIABLES.yMin)||!e.hasVariable(l.POSITION_VARIABLES.yMax))return e;const a=n.bandwidth,i=l.isDefined(a)&&e.hasVariable(l.POSITION_VARIABLES.y)?og(e,n,a):sg(e,n);return e.addVariable(l.POSITION_VARIABLES.yMin,"numeric",i.min).addVariable(l.POSITION_VARIABLES.yMax,"numeric",i.max)}};function og(e,t,r){const n=e.getValues(l.POSITION_VARIABLES.y,{type:"numeric"}),a=e.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),i=e.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),o="reverse"in t.spec&&t.spec.reverse===!0,s=e.size(),c=Cs(s);for(let u=0;u<s;u++){const d=n[u],m=a[u],p=i[u];!l.isDefined(d)||!l.isDefined(m)||!l.isDefined(p)||(c.min[u]=d+(o?-p:m)*r,c.max[u]=d+(o?-m:p)*r)}return c}function sg(e,t){const r=e.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),n=e.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),a=e.size(),i=Cs(a);for(let o=0;o<a;o++){const s=r[o],c=n[o];!l.isDefined(s)||!l.isDefined(c)||(i.min[o]=t.map(s),i.max[o]=t.map(c))}return i}function Cs(e){return{min:new Array(e).fill(null),max:new Array(e).fill(null)}}var lg=[new eg,new ag,new tg,new ig,new Qf];function cg(e,t){const r=e[t];return r?.kind==="position"?r:null}var ug=class extends _e{constructor(e,t=lg){super(),this.container=e,this.mappers=t}dependencies(e){return[e.scales.x,e.scales.y,e.scales.ySecondary]}compileLayer(e,t){const r=a=>cg(t.scales,a);let n=e.data;for(const a of this.mappers)n=a.map({data:n,layer:e,getPositionScale:r,geomRegistry:this.container.geomRegistry});return{...e,data:n}}},dg=class extends l.Stage{constructor(e,t){super(),this.container=e,this.registry=t}dependencies(e){return[e.layers,e.scales,e.colorScheme]}run(e){this.validateScaleTypeCompatibility(e);const t=new Map;for(const i of e.scales)t.set(i.scaledAesthetic,i);const r=this.collectValues(e.layers,t),n={colorScheme:e.colorScheme,hasTouchingGeoms:af(this.container.geomRegistry,e.layers)},a={};for(const[i,o]of t){const s=r.get(i)??[];a[i]=this.registry.get(o.scaleType).compile(o,s,n)}return a}validateScaleTypeCompatibility(e){const t=[];for(const r of e.scales){const{compatibleDataTypes:n}=this.registry.get(r.scaleType),a=F(r.scaledAesthetic),i=e.layers.find(c=>l.isDefined(c.mapping[a]));if(!i)continue;const o=l.readVariableName(i.mapping[a]);if(!l.isDefined(o)||!i.data.hasVariable(o)||i.data.size()===0)continue;const s=i.data.getType(o);if(!n.includes(s)){const c=r.scaleType==="continuous"&&s==="temporal"?`Use scale.${r.scaledAesthetic}.datetime() for a time axis or declare the column's valueFormat in data.columns to read it as a number.`:void 0;t.push({code:"INCOMPATIBLE_TYPE",message:`Scale '${r.scaledAesthetic}' (${r.scaleType}) is incompatible with variable '${o}' (${s})`,context:{aesthetic:a,variableName:o,scaleType:r.scaleType,variableType:s},suggestion:c})}if(r.scaledAesthetic==="lineType"&&s!=="categorical"){const c=s==="temporal"?"Bucket the variable into categorical periods (e.g. quarter, year) first.":"Bin the variable into categorical buckets first.";t.push({code:"INCOMPATIBLE_TYPE",message:`Scale 'lineType' is discrete-only and cannot be mapped to ${s} variable '${o}'. ${c}`,context:{aesthetic:a,variableName:o,scaleType:r.scaleType,variableType:s},suggestion:c})}}gs(this.container.diagnostics,t)}collectValues(e,t){const r=new Map;for(const n of e){const a=this.resolveCustomPositionalAxes(n);for(const[i,o]of Object.entries(n.mapping)){if(!l.isDefined(o))continue;const s=i==="y"?xe(n.yScaleType):i,c=a.get(i)??(ns(s)?s:void 0);if(!l.isDefined(c)||!t.has(c))continue;const u=t.get(c)?.scaleType,d=this.resolveVariables(i,o,n.data,u);this.collectFromVariables(n.data,d,c,r)}}return r}resolveCustomPositionalAxes(e){const t=new Map,r=this.container.geomRegistry.get(e.geom);for(const n of r.positionRoles)n.role!=="scalar"||!l.isDefined(n.aes)||In(n.aes)||t.set(n.aes,as(n.axis,e.yScaleType));return t}resolveVariables(e,t,r,n){if(e==="y"&&n!=="discrete"&&this.hasPositionAdjustedY(r))return[l.POSITION_VARIABLES.yMin,l.POSITION_VARIABLES.yMax];const a=l.readVariableName(t);return!a||!r.hasVariable(a)?[]:[a]}hasPositionAdjustedY(e){return e.hasVariable(l.POSITION_VARIABLES.yMin)&&e.hasVariable(l.POSITION_VARIABLES.yMax)}collectFromVariables(e,t,r,n){if(t.length===0)return;let a=[];for(const o of t)a=a.concat(e.getValues(o));const i=n.get(r);n.set(r,i?i.concat(a):a)}},mg=["rgb","lab","hcl","hsl"],pg=["viridis","magma","inferno","plasma","cividis","turbo","Blues","Greens","Greys","Oranges","Purples","Reds"],Vs=["RdBu","BrBG","PuOr","Spectral"],Ms={"red-blue":"RdBu","brown-teal":"BrBG","purple-orange":"PuOr",spectral:"Spectral"},hg=new Set(Vs.map(e=>e.toLowerCase()));function Ds(e){const t=e.toLowerCase(),r=Ms[t];return r?r.toLowerCase():t}function fg(e){return hg.has(Ds(e))}var gg={rgb:ze.interpolateRgb,lab:ze.interpolateLab,hcl:ze.interpolateHcl,hsl:ze.interpolateHsl},yg={viridis:N.interpolateViridis,magma:N.interpolateMagma,inferno:N.interpolateInferno,plasma:N.interpolatePlasma,cividis:N.interpolateCividis,turbo:N.interpolateTurbo,blues:N.interpolateBlues,greens:N.interpolateGreens,greys:N.interpolateGreys,oranges:N.interpolateOranges,purples:N.interpolatePurples,reds:N.interpolateReds,rdbu:N.interpolateRdBu,brbg:N.interpolateBrBG,puor:N.interpolatePuOr,spectral:N.interpolateSpectral};function Mn(e){const t=bg(e);return e.reverse?r=>t(1-r):t}function vg(e={},t=2){const r=Mn({range:e.range??null,scheme:e.scheme??null,interpolate:e.interpolate??l.CONTINUOUS_SCALE_DEFAULTS.interpolate,reverse:e.reverse??!1});return t<2?t===1?[r(0)]:[]:Array.from({length:t},(n,a)=>r(a/(t-1)))}function bg(e){const t=gg[e.interpolate];if(e.range&&e.range.length>=2)return(0,ze.piecewise)(t,e.range.map(r=>String(r)));if(e.scheme){const r=yg[Ds(e.scheme)];if(r)return r}return(0,ze.piecewise)(t,[...l.DEFAULT_SEQUENTIAL_RAMP])}var It=class{createPositionScale(e,t){return{kind:"position",aesthetic:F(e.scaledAesthetic),spec:e,...t}}createVisualScale(e,t){return{kind:"visual",aesthetic:F(e.scaledAesthetic),spec:e,...t}}},Sg=class extends It{constructor(e){super(),this.container=e,this.compatibleDataTypes=["numeric"]}compile(e,t){if(e.scaleType!=="continuous")throw new l.InternalError({message:"ContinuousScale.compile received non-continuous spec"});const r=Ae(e.scaledAesthetic),n=e.scaledAesthetic==="color",a=this.computeDataDomain(t,e);return n?this.buildColorScale(a,e):r?this.buildPositionScale(a,e):this.buildVisualScale(a,e)}computeDataDomain(e,t){let r=1/0,n=-1/0;for(const a of e)typeof a=="number"&&(a<r&&(r=a),a>n&&(n=a));return r===1/0?[0,0]:(t.zero&&(r>0&&(r=0),n<0&&(n=0)),[r,n])}createD3Scale(e,t,r){let n=[r.domainMin??e[0],r.domainMax??e[1]];const a=r.transform==="log"&&Ag(n);r.transform==="log"&&!a&&this.container.diagnostics.addWarning({code:"INCOMPATIBLE_SCALE_DOMAIN",message:`Log scale on '${r.scaledAesthetic}' needs a strictly positive or negative domain, but the domain is [${e[0]}, ${e[1]}] — rendering a linear scale instead.`,context:{aesthetic:F(r.scaledAesthetic),scaleType:r.scaleType,actual:e},suggestion:"Filter out non-positive values or set a positive domainMin so the log scale can apply."});const i=a?(0,ie.scaleLog)():r.transform==="sqrt"?(0,ie.scaleSqrt)():(0,ie.scaleLinear)();r.nice&&!a&&(n=i.copy().domain(n).nice().domain());const o=r.domainMin??n[0],s=r.domainMax??n[1];return i.domain([o,s]).range(t).clamp(r.clamp)}buildPositionScale(e,t){const r=t.reverse?[1,0]:[0,1],n=this.createD3Scale(e,r,t);return this.createPositionScale(t,{map:n,domain:n.domain(),bandwidth:null,generateTicks:a=>a&&"count"in a?n.ticks(a.count):n.ticks()})}buildVisualScale(e,t){const r=xg(t.range)??[0,1],n=t.reverse?[r[1],r[0]]:r,a=this.createD3Scale(e,n,t);return this.createVisualScale(t,{map:a,domain:a.domain(),generateTicks:i=>i&&"count"in i?a.ticks(i.count):a.ticks()})}buildColorScale(e,t){const r=Mn(t),n=t.domainMid;if(n!==null){const[a,i]=this.resolveColorDomain(e,t);if(n>a&&n<i){const[o,s]=this.symmetrizeDomain([a,i],t,n);return this.buildDivergingColorScale([o,n,s],t,r)}}return this.buildSequentialColorScale(e,t,r)}buildSequentialColorScale(e,t,r){const n=this.createD3Scale(e,[0,1],t),a=i=>typeof i!="number"||!Number.isFinite(i)?null:r(n(i));return this.createVisualScale(t,{map:a,domain:n.domain(),generateTicks:i=>i&&"count"in i?n.ticks(i.count):n.ticks()})}buildDivergingColorScale(e,t,r){const n=(0,ie.scaleLinear)().domain(e).range([0,.5,1]).clamp(t.clamp),a=i=>typeof i!="number"||!Number.isFinite(i)?null:r(n(i));return this.createVisualScale(t,{map:a,domain:e,generateTicks:i=>i&&"count"in i?n.ticks(i.count):n.ticks()})}resolveColorDomain(e,t){let r=t.domainMin??e[0],n=t.domainMax??e[1];if(t.nice){const a=(0,ie.scaleLinear)().domain([r,n]).nice().domain();r=t.domainMin??a[0],n=t.domainMax??a[1]}return[r,n]}symmetrizeDomain(e,t,r){if(!t.symmetric)return e;const n=Math.max(Math.abs(e[0]-r),Math.abs(e[1]-r));return[t.domainMin??r-n,t.domainMax??r+n]}},Ag=e=>{const[t,r]=e;return t>0&&r>0||t<0&&r<0};function xg(e){if(!e)return null;const[t,r]=e;return typeof t=="number"&&typeof r=="number"?[t,r]:null}var Ig=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["temporal"]}compile(e,t){if(e.scaleType!=="datetime")throw new l.InternalError({message:"DatetimeScale.compile received non-datetime spec"});const r=Ae(e.scaledAesthetic),n=this.computeDataDomain(t);if(!r)throw new l.UserInputError({code:"INCOMPATIBLE_TYPE",message:"Datetime scale is not supported for non-position aesthetics",context:{aesthetic:e.scaledAesthetic},suggestion:"Use a continuous or discrete scale for non-position aesthetics (color, size, alpha, strokeWidth)."});return this.buildScale(n,e,this.collectInputDates(t))}collectInputDates(e){const t=new Set,r=[];for(const n of e){if(!(n instanceof Date))continue;const a=n.getTime();t.has(a)||(t.add(a),r.push(n))}return r.sort((n,a)=>n.getTime()-a.getTime()),r}computeDataDomain(e){let t=1/0,r=-1/0;for(const n of e){if(!(n instanceof Date))continue;const a=n.getTime();a<t&&(t=a),a>r&&(r=a)}return t===1/0?[]:[new Date(t),new Date(r)]}createD3Scale(e,t,r){const n=Tg(e)?e:[],a=(0,ie.scaleUtc)().domain(n).range(t).clamp(r.clamp);if(r.nice&&a.nice(),l.isDefined(r.domainMin)||l.isDefined(r.domainMax)){const[i,o]=a.domain();i!==void 0&&o!==void 0&&a.domain([r.domainMin??i,r.domainMax??o])}return a}buildScale(e,t,r){const n=t.reverse?[1,0]:[0,1],a=this.createD3Scale(e,n,t),[i,o]=a.domain(),s=i&&o?r.filter(c=>c>=i&&c<=o):[];return this.createPositionScale(t,{map:a,domain:a.domain(),bandwidth:null,generateTicks:c=>c&&"atInputs"in c?s:c&&"interval"in c?i&&o?Hp(i,o,c.interval):[]:a.ticks(c?.count)})}},Tg=e=>e.length===2&&l.isStrictTemporalDataValue(e[0])&&l.isStrictTemporalDataValue(e[1]),Lg=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["categorical","numeric","temporal"]}compile(e,t){if(e.scaleType!=="discrete")throw new l.InternalError({message:"DiscreteScale.compile received non-discrete spec"});const r=Ae(e.scaledAesthetic),n=ts(t,e);return r?this.buildPositionScale(n,e):this.buildVisualScale(n,e)}buildPositionScale(e,t){const r=e.map(String),n=t.padding??l.DISCRETE_SCALE_DEFAULTS.padding,a=t.reverse?[1,0]:[0,1],i=(0,ie.scaleBand)().domain(r).range(a).paddingInner(n).paddingOuter(n/2),o=i.bandwidth()/2;return this.createPositionScale(t,{map:s=>(i(String(s))??NaN)+o,domain:e,bandwidth:i.bandwidth(),generateTicks:()=>[...e]})}buildVisualScale(e,t){const r=e.map(String),n=t.range&&t.range.length>0?(0,ie.scaleOrdinal)().domain(r).range(t.range).unknown(t.range[0]):null;return this.createVisualScale(t,{map:a=>{const i=String(a);return n?n(i):i},domain:e,generateTicks:()=>e})}},Eg=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["numeric","categorical","temporal"]}compile(e){if(e.scaleType!=="identity")throw new l.InternalError({message:"IdentityScale.compile received non-identity spec"});return{kind:"identity",aesthetic:F(e.scaledAesthetic),spec:e,map:t=>t,domain:[],generateTicks:()=>[]}}},wg=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["categorical","temporal","numeric"]}compile(e,t,r){if(e.scaleType!=="palette")throw new l.InternalError({message:"PaletteScale.compile received non-palette spec"});const n=es(t),a=l.resolvePaletteRange(e.palette,{groupCount:n.length,...r}),i=l.applyOverrides(a.length>0?a:[...l.DEFAULT_COLOR_PALETTE],e.overrides),o=(0,ie.scaleOrdinal)().domain(n.map(String)).range(i).unknown(i[0]);return this.createVisualScale(e,{map:s=>o(String(s)),domain:n,generateTicks:()=>n})}},Rg=class extends l.Registry{constructor(e){super("scale"),this.register("continuous",new Sg(e)),this.register("discrete",new Lg),this.register("datetime",new Ig),this.register("identity",new Eg),this.register("palette",new wg)}},Ps={x:"position",y:"position",ySecondary:"position",color:"color-range",size:"continuous-range",alpha:"continuous-range",strokeWidth:"continuous-range",lineType:"discrete-only"},Cg={numeric:{position:"continuous","color-range":"continuous","continuous-range":"continuous","discrete-only":"discrete"},categorical:{position:"discrete","color-range":"palette","continuous-range":"discrete","discrete-only":"discrete"},temporal:{position:"datetime","color-range":"continuous","continuous-range":"continuous","discrete-only":"discrete"}};function Dn(e,t){const{data:r,layers:n,mapping:a,customPalettes:i}=t;return{container:e,data:r,layers:n,mapping:a,customPalettes:i,demands:jr(e.geomRegistry,n)}}function gr(e,t){switch(t.scaleType){case"inferred":return{...gr(e,Pg(e,t)),inferredFrom:t};case"continuous":{const r=Ps[t.scaledAesthetic],n=r==="continuous-range"&&t.scaledAesthetic in l.NON_POSITION_RANGE_DEFAULTS?l.NON_POSITION_RANGE_DEFAULTS[t.scaledAesthetic]:null,a=t.scaledAesthetic==="size"&&r==="continuous-range"?"sqrt":l.CONTINUOUS_SCALE_DEFAULTS.transform;return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,transform:t.transform??a,reverse:t.reverse??l.CONTINUOUS_SCALE_DEFAULTS.reverse,nice:t.nice??l.CONTINUOUS_SCALE_DEFAULTS.nice,zero:t.zero??l.CONTINUOUS_SCALE_DEFAULTS.zero,clamp:t.clamp??r!=="position",domainMin:t.domainMin??l.CONTINUOUS_SCALE_DEFAULTS.domainMin,domainMax:t.domainMax??l.CONTINUOUS_SCALE_DEFAULTS.domainMax,range:t.range??n??null,scheme:Og(e.container,t),interpolate:t.interpolate??l.CONTINUOUS_SCALE_DEFAULTS.interpolate,domainMid:t.domainMid??l.CONTINUOUS_SCALE_DEFAULTS.domainMid,symmetric:t.symmetric??l.isDefined(t.domainMid)}}case"datetime":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,domainMin:t.domainMin??l.DATETIME_SCALE_DEFAULTS.domainMin,domainMax:t.domainMax??l.DATETIME_SCALE_DEFAULTS.domainMax,nice:t.nice??l.DATETIME_SCALE_DEFAULTS.nice,reverse:t.reverse??l.DATETIME_SCALE_DEFAULTS.reverse,clamp:t.clamp??!1};case"discrete":return Xr(t,e.demands);case"palette":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,palette:l.resolvePaletteConfig(e.container,t.palette,e.customPalettes),overrides:l.resolvePaletteOverrides(e.container,t.overrides,t.palette,e.customPalettes)};case"identity":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType};default:throw new l.InternalError({message:`Unknown scale type: ${t.scaleType}`})}}function Vg(e,t){const{scales:r,layers:n,coords:a}=t,i=Dn(e,t),o=Ng(kg(r,n),i.demands),s=new Map;for(const u of o)s.set(u.scaledAesthetic,u);const c=[...s.values()].map(u=>{const d=Mg(i,u);return gr(i,d)});return a.coordType==="polar"?c.map(Pn):c}function Xr(e,t){const r=t?.bandPadding[e.scaledAesthetic];return{type:e.type,scaledAesthetic:e.scaledAesthetic,scaleType:e.scaleType,range:e.range??l.DISCRETE_SCALE_DEFAULTS.range,domain:e.domain??l.DISCRETE_SCALE_DEFAULTS.domain,padding:e.padding??r??l.DISCRETE_SCALE_DEFAULTS.padding,reverse:e.reverse??Dg(e.scaledAesthetic,t)}}var Pn=e=>e.scaleType==="discrete"?{...e,padding:0}:e;function Mg(e,t){return t.scaleType==="inferred"||t.scaleType==="discrete"||!e.demands.bandedAxes.includes(t.scaledAesthetic)?t:(e.container.diagnostics.addWarning({code:"UNSUPPORTED_SCALE_TYPE",message:`A geom drawn on '${t.scaledAesthetic}' needs it to be a band scale, but the spec declares a '${t.scaleType}' one; the band wins.`,context:{aesthetic:F(t.scaledAesthetic),scaleType:t.scaleType},suggestion:`Declare '${t.scaledAesthetic}' as a discrete scale, or omit it and let the geom's band be inferred.`}),l.discrete(t.scaledAesthetic,{..."reverse"in t&&t.reverse!==void 0&&{reverse:t.reverse}}))}function Dg(e,t){return e===t?.discreteCrossAxis?!0:l.DISCRETE_SCALE_DEFAULTS.reverse}function Pg({data:e,layers:t,mapping:r,demands:n},a){const i=F(a.scaledAesthetic),o=a.scaledAesthetic==="ySecondary"?_g(t,r):r[i];if(a.scaledAesthetic===n.discreteAxis||a.scaledAesthetic===n.discreteCrossAxis)return l.discrete(a.scaledAesthetic,a.options);const s=n.zeroAxes[a.scaledAesthetic];if(s!==void 0){const m=a.options;return l.continuous(a.scaledAesthetic,{...m,zero:!0,...!s.nice&&{nice:!1}})}const c=l.readVariableName(o);if(!l.isDefined(c)||!e.hasVariable(c)||e.size()===0)return l.continuous(a.scaledAesthetic,a.options);const u=e.getType(c),d=Ps[a.scaledAesthetic];switch(Cg[u][d]){case"discrete":return l.discrete(a.scaledAesthetic,a.options);case"palette":return l.palette(a.scaledAesthetic);case"datetime":return l.datetime(a.scaledAesthetic,a.options);case"continuous":return l.continuous(a.scaledAesthetic,a.options);default:return l.identity(a.scaledAesthetic)}}function Og(e,t){const r=t.scheme??l.CONTINUOUS_SCALE_DEFAULTS.scheme;return r===null?null:l.isDefined(t.range)?(e.diagnostics.addWarning({code:"CONFLICTING_COLOR_RAMP",message:`The color scale sets both a 'scheme' ('${r}') and an explicit 'range'; the range wins and the scheme is ignored.`,context:{aesthetic:F(t.scaledAesthetic),scaleType:t.scaleType},suggestion:"Set either a scheme or a range, not both."}),null):(!l.isDefined(t.domainMid)&&fg(r)&&e.diagnostics.addWarning({code:"DIVERGING_SCHEME_WITHOUT_MIDPOINT",message:`The color scale uses a diverging scheme ('${r}') without 'domainMid', so its neutral colour lands at the data midpoint rather than a meaningful centre.`,context:{aesthetic:F(t.scaledAesthetic),scaleType:t.scaleType,actual:r},suggestion:"Set 'domainMid' (e.g. 0) to centre the neutral colour."}),r)}function _g(e,t){const r=e.find(n=>n.yScaleType==="secondary");return r?r.mapping.y??t.y:t.y}function kg(e,t){return!t.some(r=>r.yScaleType==="secondary")||e.some(r=>r.scaledAesthetic==="ySecondary")?e:[...e,l.inferred("ySecondary")]}function Ng(e,t){return e.some(r=>r.scaledAesthetic==="color")?e:[...e,t.inferredColor?l.inferred("color"):l.palette("color")]}var ti=0;function $(){return ti+=1,`${Math.random().toString(36).slice(2,6)}${ti.toString(36)}`}var Bg={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0},"top-left":{x:-1,y:-1},"top-right":{x:1,y:-1},"bottom-left":{x:-1,y:1},"bottom-right":{x:1,y:1}},Fg=(e,t,r)=>{const n=Gg(e,t),a=Hg(n);return{differenceArrows:(n.differenceArrows??[]).map(i=>Wg(e,i,r)).filter(l.isDefined),shapes:(n.shapes??[]).map(i=>qg(e,i,a)).filter(l.isDefined),arrows:(n.arrows??[]).map(i=>Jg(e,i,r,a)).filter(l.isDefined),textAnnotations:(n.textAnnotations??[]).map(i=>zg(e,i,r,a)).filter(l.isDefined),stickers:(n.stickers??[]).map(i=>Kg(e,i,r,a)).filter(l.isDefined),images:(n.images??[]).map(i=>Xg(e,i,a)).filter(l.isDefined),pinnedNumbers:(n.pinnedNumbers??[]).map(i=>Yg(e,i,r)).filter(l.isDefined),comments:(n.comments??[]).map(i=>jg(e,i,r)).filter(l.isDefined)}},Gg=(e,t)=>{if(t===void 0)return{};if(!$g(t))return t;const r=new Set,n=a=>a.id===void 0?a:r.has(a.id)?(e.diagnostics.addWarning({code:"ANNOTATION_DUPLICATE_ID",message:`More than one annotation declares id "${a.id}" — giving this one a generated id, so references to "${a.id}" point at the first.`,context:{annotationId:a.id},suggestion:"Give each annotation its own id."}),{...a,id:$()}):(r.add(a.id),a);return{differenceArrows:t.differenceArrows?.map(a=>n(a)),shapes:t.shapes?.map(a=>n(a)),arrows:t.arrows?.map(a=>n(a)),textAnnotations:t.textAnnotations?.map(a=>n(a)),images:t.images?.map(a=>n(a)),stickers:t.stickers?.map(a=>n(a)),pinnedNumbers:t.pinnedNumbers?.map(a=>n(a)),comments:t.comments?.map(a=>n(a))}},$g=e=>{const t=new Set;for(const r of Ug(e))if(r.id!==void 0){if(t.has(r.id))return!0;t.add(r.id)}return!1},Ug=e=>[...e.differenceArrows??[],...e.shapes??[],...e.arrows??[],...e.textAnnotations??[],...e.images??[],...e.stickers??[],...e.pinnedNumbers??[],...e.comments??[]],Hg=e=>{const t=new Set,r=[e.differenceArrows,e.shapes,e.arrows,e.textAnnotations,e.images,e.stickers,e.pinnedNumbers,e.comments];for(const n of r)for(const a of n??[])a.id!==void 0&&t.add(a.id);return t},On=(e,t,r,n)=>{if(r.has(t))return!0;const a=n===void 0?"An annotation":`Annotation "${n}"`;return e.diagnostics.addWarning({code:"ANNOTATION_REF_NOT_FOUND",message:`${a} references id "${t}" but no annotation declares that id — dropping this annotation.`,context:{ref:t,...n!==void 0?{annotationId:n}:{}},suggestion:"Reference the explicit id of another annotation in the same spec, or set an id on the target."}),!1},zg=(e,t,r,n)=>{const a=er(e,t.at,r,n,t.id);return a===null?null:{id:t.id??$(),content:t.content,at:a,width:t.width,align:t.align??l.TEXT_ANNOTATION_DEFAULTS.align}},Wg=(e,t,r)=>{const n=dt(e,t.start,r),a=dt(e,t.end,r);return n===null||a===null?null:{id:t.id??$(),start:n,end:a,label:t.label,labelCrossPosition:t.labelCrossPosition??l.DIFFERENCE_ARROW_DEFAULTS.labelCrossPosition}},dt=(e,t,r)=>{const n=t.align!==void 0?{align:t.align}:{};return t.layerId===void 0?{anchorValue:t.anchorValue,groupValue:t.groupValue,crossValue:t.crossValue,...n}:r.some(a=>a.id===t.layerId)?{layerId:t.layerId,anchorValue:t.anchorValue,groupValue:t.groupValue,crossValue:t.crossValue,...n}:(e.diagnostics.addWarning({code:"UNKNOWN_LAYER_ID",message:`Annotation references layerId "${t.layerId}", which no layer carries — dropping this annotation.`,context:{layerId:t.layerId,available:r.map(a=>a.id)},suggestion:"Reference an existing layer id, or omit layerId to anchor against the data directly."}),null)},er=(e,t,r,n,a)=>{if(t.anchorType==="annotation")return On(e,t.ref,n,a)?t:null;if(t.anchorType==="panel"||t.anchorType==="axis"||t.anchorType==="selection")return t;const i=dt(e,t,r);return i===null?null:{anchorType:"observation",...i,...t.offset!==void 0?{offset:t.offset}:{}}},Kg=(e,t,r,n)=>{const a=er(e,t.at,r,n,t.id);return a===null?null:{id:t.id??$(),at:a,sticker:t.sticker}},Yg=(e,t,r)=>{const n=dt(e,t.at,r);return n===null?null:{id:t.id??$(),at:n}},jg=(e,t,r)=>{const n=dt(e,t.at,r);return n===null?null:{id:t.id??$(),at:n,content:t.content}},qg=(e,t,r)=>t.region.anchorType==="annotation"&&!On(e,t.region.ref,r,t.id)?null:{id:t.id??$(),kind:t.kind??l.SHAPE_DEFAULTS.kind,zOrder:t.zOrder??l.SHAPE_DEFAULTS.zOrder,region:Zg(t.region)},Xg=(e,t,r)=>t.region.anchorType==="annotation"&&!On(e,t.region.ref,r,t.id)?null:{id:t.id??$(),src:t.src,zOrder:t.zOrder??l.IMAGE_ANNOTATION_DEFAULTS.zOrder,region:t.region,fit:t.fit??l.IMAGE_ANNOTATION_DEFAULTS.fit},Zg=e=>e.anchorType!=="selection"||e.padding!==void 0?e:{...e,padding:l.SELECTION_PADDING_DEFAULT},ri=e=>{if(e.anchorType==="panel"||e.anchorType==="axis"||e.offset!==void 0||e.align===void 0)return e;const t=Bg[e.align];return t===void 0?e:{...e,offset:{x:t.x*4,y:t.y*4,unit:"px"}}},Jg=(e,t,r,n)=>{const a=er(e,t.start,r,n,t.id),i=er(e,t.end,r,n,t.id);return a===null||i===null?null:{id:t.id??$(),start:ri(a),end:ri(i),startArrowheadStyle:t.startArrowheadStyle??l.ARROW_DEFAULTS.startArrowheadStyle,endArrowheadStyle:t.endArrowheadStyle??l.ARROW_DEFAULTS.endArrowheadStyle}},Qg={parsingLocale:"en-US",legend:{position:"auto",display:"auto",align:"auto"},axes:{x:{isVisible:!0,label:null,position:"bottom",grid:{isVisible:null},ticks:{isVisible:!0,mode:"auto"}},y:{isVisible:!0,label:null,position:"right",grid:{isVisible:null},ticks:{isVisible:!1,mode:"auto"}}},panel:{overflow:{dataLabels:{x:"inside",y:"inside"},differenceArrows:{x:"outside",y:"outside"}}},headline:{show:"none",compareWith:"none",size:"auto",position:"above"},numberFormat:{decimals:"auto",abbreviation:"auto"},content:{title:null,isTitleVisible:!0,subtitle:null,isSubtitleVisible:!0,caption:null,isCaptionVisible:!1,source:null,isSourceVisible:!1,brandMark:{enabled:!1,placement:"footer",variant:"full"},isBrandMarkVisible:!1}};function ey(e){const t=(0,tt.merge)({},Qg,e);return t.content=ty(t.content,e?.content),t}var ty=(e,t)=>{const r=t?.brandMark?.enabled??t?.isBrandMarkVisible??e.brandMark.enabled,n={...e.brandMark,enabled:r};return{...e,brandMark:n,isBrandMarkVisible:r}},ry={xLimits:null,yLimits:null},Wt={theta:"x",startAngle:0,innerRadius:0};function Zr(e){const t=e??{type:"coord",coordType:"cartesian"},r=(0,qt.default)({},ry,t.params??{});switch(t.coordType){case"cartesian":case"flip":return{...t,params:r};case"polar":return{...t,params:{...r,theta:t.params?.theta??Wt.theta,startAngle:t.params?.startAngle??Wt.startAngle,innerRadius:(0,Ye.default)(t.params?.innerRadius??Wt.innerRadius,0,1)}}}}function ny(e,t,r){const n=[];for(const a of t){if(a.layerId!==void 0&&!r.some(i=>i.id===a.layerId)){e.diagnostics.addWarning({code:"UNKNOWN_LAYER_ID",message:`Highlight references layerId "${a.layerId}", which no layer carries — dropping this highlight.`,context:{layerId:a.layerId,available:r.map(i=>i.id)},suggestion:"Reference an existing layer id, or omit layerId to apply the highlight across all layers."});continue}n.push({type:"highlight",id:a.id??$(),predicate:a.predicate,scope:a.scope??"data-point",...a.layerId!==void 0?{layerId:a.layerId}:{}})}return n}var ay=class{constructor(){this.diagnostics=[],this.persistent=[]}addWarning(e,t={}){const r={...e,severity:"warning",kind:"user-input"};t.persistent?this.persistent.push(r):this.diagnostics.push(r)}addError(e){this.diagnostics.push({...e,severity:"error",kind:"user-input"})}reset(){this.diagnostics=[]}drain(){const e=this.persistent.length===0?this.diagnostics:[...this.persistent,...this.diagnostics];if(e.length===0)return{errors:[],warnings:[]};const t=ni(e.filter(n=>n.severity==="error")),r=ni(e.filter(n=>n.severity==="warning"));return this.diagnostics=[],{errors:t,warnings:r}}},iy=class{constructor(e,t){this.sink=e,this.baseContext=t}addWarning(e,t){this.sink.addWarning(this.stampBaseContext(e),t)}addError(e){this.sink.addError(this.stampBaseContext(e))}stampBaseContext(e){const t=e.context??{};return{...e,context:{...t,...this.baseContext}}}};function ni(e){const t=new Set;return e.filter(r=>{const n=JSON.stringify(r);return t.has(n)?!1:(t.add(n),!0)})}var oy={showDataLabels:!1,format:"absolute",showStackTotals:!1,showCategoryLabels:!1,labelSource:{variable:l.POSITION_VARIABLES.yRaw},position:"auto",justify:"end",align:"center",offset:4,categoryPosition:"inside",categoryJustify:"start",categoryAlign:"center",categoryOffset:4};function Os(e,t){const r=e??t,n=typeof r=="string"?r:r.type;if(n==="smooth"){const a=typeof r=="string"?void 0:r;return{type:"smooth",method:a?.method??"linear",order:a?.order??3,bandwidth:a?.bandwidth??.3}}return{type:n}}function Ne(e,t,r,n,a,i){const o=a!==void 0&&i!==void 0?new iy(a,{layerIndex:i}):a,s=e.get(n.geom),c=n.position??s.defaultPosition,u=cy({dataLabels:dy(e,t,n,c,r),geom:s,position:c,coordType:r,diagnostics:o});return ly({diagnostics:o,coordType:r,geom:s,position:c,dataLabels:u}),{id:n.id??$(),type:n.type,geom:n.geom,mapping:n.mapping??{},stat:Os(n.stat,"identity"),position:c,yScaleType:n.yScaleType??"primary",params:s.resolveParams({params:n.params,diagnostics:o}),transforms:n.transforms??[],interactive:n.interactive??s.defaultInteractive,dataLabels:u}}function sy(e,t,r,n,a){const i=n.map((o,s)=>Ne(e,t,r,o,a,s));return ks(e,i)}var _s=(e,t,r,n)=>n.label!==void 0?n.label:Ho({geom:e.get(t),position:r,mapping:n,purpose:"label"}),ks=(e,t)=>{const r=new Set;for(const n of t)n.position==="fill"&&r.add(n.yScaleType);return r.size===0?t:Oe(t,n=>{if(!r.has(n.yScaleType)||!e.has(n.geom)||!e.get(n.geom).positionRoles.some(o=>o.axis==="y"&&o.role==="scalar"))return n;const a=l.readConstantValue(n.mapping.y);if(!l.isStrictNumericDataValue(a))return n;const i=(0,tt.clamp)(a,0,1);return i===a?n:{...n,mapping:{...n.mapping,y:{value:i}}}})},ly=({diagnostics:e,coordType:t,geom:r,position:n,dataLabels:a})=>{if(e===void 0)return;const i=r.type==="bar"&&t!=="polar";if(a.showDataLabels&&!r.dataLabelCoordTypes.includes(t)){e.addWarning({code:"DATA_LABELS_UNSUPPORTED",message:`Data labels are not supported for geom '${r.type}' under '${t}' coords; none will render.`,suggestion:"Turn off showDataLabels for this layer."});return}a.showDataLabels&&a.position==="outside"&&i&&l.isStackedPosition(n)&&e.addWarning({code:"DATA_LABEL_PLACEMENT_COERCED",message:"Stacked bar segments only place data labels inside; position 'outside' will render as 'inside'.",context:{expected:"inside",actual:"outside"},suggestion:"Use position 'inside' or 'auto', or enable showStackTotals for a label above the stack."}),a.showStackTotals&&!(i&&n==="stack")&&e.addWarning({code:"DATA_LABEL_SETTING_IGNORED",message:"showStackTotals only applies to stacked cartesian bars; it will be ignored.",suggestion:"Turn off showStackTotals, or use a bar geom with position 'stack'."})},cy=({dataLabels:e,geom:t,position:r,coordType:n,diagnostics:a})=>{const{justify:i,showDataLabels:o}=e;if(i!=="panel-start"&&i!=="panel-end")return e;const s=uy(t,r,n);if(s===null)return e;const c=i==="panel-end"?"end":"start";return o&&a?.addWarning({code:"DATA_LABEL_PLACEMENT_COERCED",message:`${s}; justify '${i}' will render as '${c}'.`,context:{expected:c,actual:i},suggestion:`Use justify '${c}' for this layer.`}),{...e,justify:c}},uy=(e,t,r)=>r==="polar"?"Panel-edge anchors do not apply under polar coords":e.type==="bar"&&l.isStackedPosition(t)?"Stacked bar segments would all pin their labels to the same panel edge":null,dy=(e,t,r,n,a)=>{const i={...t,...r.mapping},o=_s(e,r.geom,n,i),s=e.get(r.geom);return{...(0,tt.merge)({},oy,s.resolveDataLabelDefaults?.(n)??{},s.dataLabels?.[a]??{},r.dataLabels??{}),labelSource:o}},my=e=>{const t={tokens:{},defaults:[],overrides:[]};for(const r of py(e))Object.assign(t.tokens,r.tokens),t.defaults.push(...r.defaults??[]),t.overrides.push(...r.overrides??[]);return t},py=e=>{const t=[],r=new Set,n=e===void 0?[]:[e];for(;n.length>0;){const a=n.pop();if(!(a===void 0||r.has(a))){r.add(a),t.push(a);for(const i of a.extends??[])n.push(i)}}return t.reverse()};function hy(e,t,r){const n=Zr(t.coords),a=sy(e.geomRegistry,t.mapping,n.coordType,t.layers,e.diagnostics),i=Vg(e,{data:t.data,scales:t.scales,layers:a,mapping:t.mapping,coords:n,customPalettes:r}),o=ey(t.config),s=ny(e,t.highlights,a),c=Fg(e,t.annotations,a),u=my(t.styles);return{data:t.data,mapping:t.mapping,layers:a,scales:i,transforms:t.transforms,highlights:s,styles:u,annotations:c,coords:n,config:o}}var Ns=class{constructor(e){this.container=e}compile({spec:e,dataset:t,customPalettes:r}){return hy(this.container,{...e,data:t},r)}},fy=()=>{let e={},t=null;return{reset:()=>{e={}},getDuration:r=>e[r]??0,wrap:(r,n)=>a=>{const i=t,o={childrenMs:0};t=o;const s=performance.now();try{return n(a)}finally{const c=performance.now()-s;e[r]=(e[r]??0)+c-o.childrenMs,i&&(i.childrenMs+=c),t=i}}}},gy=class{constructor(e){this.registry=e}compute(e,t){return this.registry.get(e.type).compute({data:t.data,mapping:t.mapping,spec:e,xScaleIsDiscrete:t.xScaleIsDiscrete})}},Tt={differenceArrow:"differenceArrows",shape:"shapes",arrow:"arrows",text:"textAnnotations",image:"images",sticker:"stickers",pinnedNumber:"pinnedNumbers",comment:"comments"},yy={differenceArrow(e){return{type:"annotation",kind:"differenceArrow",annotation:e}},shape(e){return{type:"annotation",kind:"shape",annotation:e}},arrow(e){return{type:"annotation",kind:"arrow",annotation:e}},text(e){return{type:"annotation",kind:"text",annotation:e}},image(e){return{type:"annotation",kind:"image",annotation:e}},sticker(e){return{type:"annotation",kind:"sticker",annotation:e}},pinnedNumber(e){return{type:"annotation",kind:"pinnedNumber",annotation:e}},comment(e){return{type:"annotation",kind:"comment",annotation:e}}},Bs=Object.keys(Tt),vy=e=>Object.hasOwn(Tt,e),Lt=(e,t)=>{for(const r of Bs){const n=by(e,r,t);if(n)return n}return null},Et=(e,t)=>e[Tt[t]],_n=(e,t,r)=>({...e,[Tt[t]]:r}),Fs=(e,t)=>{const r=Et(e,t.kind);return _n(e,t.kind,[...r.slice(0,t.index),...r.slice(t.index+1)])},by=(e,t,r)=>{const n=Et(e,t),a=n.findIndex(o=>o.id===r),i=n[a];return i===void 0?null:{kind:t,index:a,annotation:i}},ai=Object.freeze({light:"#898373",dark:"#9F9886"}),Sy={graphBackground:l.DEFAULT_GRAPH_BACKGROUND,graphBorder:Object.freeze({light:"rgba(58, 56, 51, 0.15)",dark:"rgba(237, 231, 218, 0.15)"}),geom:l.DEFAULT_GEOM_COLOR,geomBorder:Object.freeze({light:"rgba(58, 56, 51, 0.55)",dark:"rgba(237, 231, 218, 0.55)"}),textPrimary:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),textSecondary:ai,ruleLine:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),gridLine:Object.freeze({light:"#E1DAC9",dark:"#373531"}),hoverAffordance:l.DEFAULT_HOVER_AFFORDANCE_COLOR,hoverGuideFill:Object.freeze({light:"#E7E1D2",dark:"#2B2A27"}),hoverGuideLine:Object.freeze({light:"#D5CDBA",dark:"#3B3934"}),editOutlineHover:Object.freeze({light:"#C4C4C4",dark:"rgba(255, 255, 255, 0.5)"}),editOutlineSelected:Object.freeze({light:"#3D70FF",dark:"#3D70FF"}),tooltipBackground:Object.freeze({light:"#FCFCF9",dark:"#262522"}),tooltipBorder:Object.freeze({light:"rgba(58, 56, 51, 0.15)",dark:"rgba(237, 231, 218, 0.15)"}),tooltipPrimaryRow:Object.freeze({light:"#F5F1E9",dark:"#2E2C29"}),annotationShape:Object.freeze({light:"#3b82f6",dark:"#60a5fa"}),annotationArrow:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),differenceLabelBackground:l.DEFAULT_GRAPH_BACKGROUND,trendPositive:{light:"#06B299",dark:"#0AC600"},trendNegative:{light:"#E14B49",dark:"#CB3333"},trendNeutral:ai},Gs=l.walkStyleTargets();for(const e of Gs){Object.freeze(e.select);for(const t of Object.values(e.declarations))typeof t=="object"&&Object.freeze(t);Object.freeze(e.declarations),e.when!==void 0&&Object.freeze(e.when),Object.freeze(e)}var mt=Object.freeze({tokens:Object.freeze(Sy),defaults:Object.freeze(Gs),overrides:Object.freeze([])}),Ay=class extends _e{constructor(e){super(),this.container=e}compile(e){const t=super.compile(e);for(const r of Oy(e.styles,t))this.container.diagnostics.addWarning(r);for(const r of ky(e.styles))this.container.diagnostics.addWarning(r);for(const r of Ny(e.styles))this.container.diagnostics.addWarning(r);for(const r of t)for(const n of r.styles.warnings)this.container.diagnostics.addWarning(n);return t}dependencies(e){return[e.styles,e.config.parsingLocale]}compileLayer(e,t){const r=Ws({layer:e,layerIndex:t.layers.indexOf(e),styles:t.styles,parsingLocale:t.config.parsingLocale});return{...e,styles:r}}},xy=class extends l.Stage{constructor(e){super(),this.container=e}compile(e){const t=super.compile(e);for(const r of _y(e.styles,e.annotations))this.container.diagnostics.addWarning(r);for(const r of t.warnings)this.container.diagnostics.addWarning(r);return t}dependencies(e){return[e.styles]}run(e){return $s(e.styles)}},Iy=new Set(l.STYLE_PROPERTY_NAMES),Ty=(e,t,r="en-US")=>Ws({layer:e,layerIndex:0,styles:{tokens:t.tokens??{},defaults:t.defaults??[],overrides:t.overrides??[]},parsingLocale:r}),$s=e=>{const t=[],r={...mt.tokens,...e.tokens},n={...Ey(),warnings:t},a=(i,o,s,c)=>{if(yr(i))return;const u=i.id===void 0?{}:{styleEntryId:i.id},d=i.select.target,m=wy(i.select);if(m.status==="unknown-target"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} targets unknown '${String(d)}'.`,context:{param:"target",actual:String(d),...u},suggestion:`Set 'target' to one of ${[...kn].map(y=>`'${y}'`).join(", ")}.`});return}if(m.status==="unknown-partition"){const{key:y,value:A,node:I}=m,x=ii(I,y);t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} addresses unknown ${y} '${A}'.`,context:{param:y,actual:A,...u},suggestion:x.length===0?`Remove '${y}' — this target has none.`:`Set '${y}' to one of ${x.map(T=>`'${T}'`).join(", ")}, or omit it.`});return}if(m.status==="namespace"){const y=ii(m.node,"part");t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} ignored: ${i.select.target} entries need a part.`,context:{param:"part",actual:String(i.select.part),...u},suggestion:`Set 'part' to one of ${y.map(A=>`'${A}'`).join(", ")}.`});return}const p=m.node;if(i.when!==void 0&&!Ry(p)){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} ignored: chrome entries take no conditions.`,context:{param:"when",...u},suggestion:"Remove the 'when' clause — chrome is chart-scoped, with no observations or states."});return}const h=p.options??[],f=i.select;if(f.layer!==void 0){if(!h.includes("layer")){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} does not take a layer.`,context:{param:"layer",actual:ae(f.layer),...u},suggestion:"Remove 'layer' — this target is not layer-scoped."});return}if(typeof f.layer!="string"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} addresses an invalid layer ${ae(f.layer)}.`,context:{param:"layer",actual:ae(f.layer),...u},suggestion:"Set 'layer' to the id of a rule layer in the spec, or omit it to address every rule label."});return}}if(f.annotation!==void 0){if(!h.includes("annotation")){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} does not take an annotation.`,context:{param:"annotation",actual:ae(f.annotation),...u},suggestion:"Remove 'annotation' — this target is not annotation-scoped."});return}if(typeof f.annotation!="string"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} addresses an invalid annotation ${ae(f.annotation)}.`,context:{param:"annotation",actual:ae(f.annotation),...u},suggestion:"Set 'annotation' to the id of an annotation in the spec, or omit it to address every one of the kind."});return}}const g=Ks({declarations:i.declarations,vocabulary:p.vocabulary,tokens:r,location:s,origin:c,warnings:t,entryTarget:i.select.target});if(Object.keys(g).length===0)return;const v=p.select.target;Us(v)&&n[v][o].push({select:i.select,declarations:g,origin:c})};return mt.defaults.forEach((i,o)=>{a(i,"defaults",`builtin[${o}]`,{list:"builtin"})}),e.defaults.forEach((i,o)=>{a(i,"defaults",`defaults[${o}]`,{list:"defaults",index:o,...i.id===void 0?{}:{id:i.id}})}),e.overrides.forEach((i,o)=>{a(i,"overrides",`overrides[${o}]`,{list:"overrides",index:o,...i.id===void 0?{}:{id:i.id}})}),n},Ly=()=>{const e=new Set,t=r=>{if(e.add(r.select.target),r.children!==void 0)for(const n of Object.values(r.children))t(n)};for(const r of Object.values(l.STYLE_TARGETS))t(r);return e},kn=Ly(),Us=e=>e!=="geom"&&kn.has(e),Ey=()=>{const e={};for(const t of kn)Us(t)&&(e[t]={defaults:[],overrides:[]});return e},ii=(e,t)=>{if(e.children===void 0)return[];const r=[];for(const n of Object.values(e.children)){const a=n.select[t];a!==void 0&&r.push(a)}return r},oi=e=>Object.keys(e.vocabulary).length===0&&e.children!==void 0,wy=e=>{const t=l.findStyleTarget(e);if(t!==void 0)return oi(t)?{status:"namespace",node:t}:{status:"found",node:t};const r=l.findStyleTarget({target:e.target});if(r===void 0)return{status:"unknown-target"};let n=r;for(const a of l.STYLE_SELECT_KEYS){const i=e[a];if(i===void 0)continue;const o=n.children===void 0?void 0:Object.values(n.children).find(s=>s.select[a]===i);if(o===void 0)return{status:"unknown-partition",key:a,value:i,node:n};n=o}return oi(n)?{status:"namespace",node:n}:{status:"found",node:n}},Ry=e=>{const t=e.options??[];return t.includes("where")||t.includes("state")},Cy=(e,t)=>{const r=e==="geom"||e==="annotation"?l.STYLE_TARGETS[e]:void 0;if(r?.children===void 0)return;const n=Object.entries(r.children).find(([,a])=>a.vocabulary[t]!==void 0)?.[0];return n===void 0?void 0:`style.${e}.${n}`},yr=e=>e.select.target==="geom",Vy=e=>e.kind===void 0?l.STYLE_TARGETS.geom.vocabulary:l.findStyleTarget({target:"geom",kind:e.kind})?.vocabulary??l.STYLE_TARGETS.geom.vocabulary,My=e=>l.findStyleTarget({target:"geom",kind:e})?.vocabulary??l.STYLE_TARGETS.geom.vocabulary,Dy=(e,t)=>{const r={};for(const n of Object.keys(e)){const a=e[n];a===void 0||t[n]===void 0||(r[n]=a)}return r},Hs=(e,t,r,n,a,i)=>{const o=Ks({declarations:e.declarations,vocabulary:Vy(e.select),tokens:r,location:n,origin:a,warnings:i,entryTarget:"geom"});return Dy(o,My(t))},Py=(e,t,r)=>{const n=[];return mt.defaults.forEach((a,i)=>{if(!yr(a))return;const o=a.select.kind;if(o!==void 0&&o!==e)return;const s={list:"builtin"},c=Hs(a,e,t,`builtin[${i}]`,s,r);Object.keys(c).length!==0&&n.push({declarations:c,...a.when?.state===void 0?{}:{state:a.when.state},origin:s})}),n},Nn=(e,t)=>{e.defaults.forEach((r,n)=>t(r,"defaults",n)),e.overrides.forEach((r,n)=>t(r,"overrides",n))},Oy=(e,t)=>{const r=new Set(t.map(a=>a.id)),n=[];return Nn(e,(a,i,o)=>{const s=a.select;if(s.target!=="geom"&&s.target!=="ruleLabel")return;const c=s.layer;c===void 0||typeof c!="string"||r.has(c)||n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets unknown layer '${c}'.`,context:{param:"layer",actual:c,...a.id===void 0?{}:{styleEntryId:a.id}},suggestion:"Set 'layer' to the id of a layer in the spec."})}),n},_y=(e,t)=>{const r=new Map(Bs.flatMap(a=>t[Tt[a]].map(i=>[i.id,a]))),n=[];return Nn(e,(a,i,o)=>{const s=a.select;if(s.target!=="annotation")return;const c=s.annotation;if(c===void 0||typeof c!="string")return;const u={param:"annotation",actual:c,...a.id===void 0?{}:{styleEntryId:a.id}},d=r.get(c);if(d===void 0){n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets unknown annotation '${c}'.`,context:u,suggestion:"Set 'annotation' to the id of an annotation in the spec."});return}if(d==="sticker"){n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets sticker '${c}', which has no style vocabulary.`,context:u,suggestion:"Remove the entry — stickers take no style declarations."});return}const m=s.kind;m!==void 0&&m!==d&&n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets ${d} '${c}' with an entry addressing kind '${String(m)}'.`,context:u,suggestion:`Set 'kind' to '${d}', or omit it to address the annotation with the shared vocabulary.`})}),n},ky=e=>{const t=[];return Nn(e,(r,n,a)=>{if(!yr(r))return;const i=r.when?.state;i===void 0||zs(i)||t.push({code:"INVALID_STYLE_RULE",message:`Style ${n}[${a}] scopes to unknown state '${i}'.`,context:{param:"state",actual:String(i),...r.id===void 0?{}:{styleEntryId:r.id}},suggestion:`Set 'state' to one of ${l.STYLE_STATES.map(o=>`'${o}'`).join(", ")}.`})}),t},zs=e=>l.STYLE_STATES.includes(e),Ny=e=>{const t=[];for(const[r,n]of Object.entries(e.tokens))l.isUsableTokenValue(n)||t.push({code:"INVALID_STYLE_RULE",message:`Style token '${r}' has an invalid value: ${ae(n)}.`,context:{param:"tokens",actual:ae(n)},suggestion:`Set '${r}' to a non-empty color string or a { light, dark } pair of colors.`});return t},ae=e=>typeof e=="object"&&e!==null?JSON.stringify(e):String(e),Ws=e=>{const{layer:t,layerIndex:r,styles:n,parsingLocale:a}=e,i=nt(t,a),o=[],s={...mt.tokens,...n.tokens},c=(u,d)=>{const m=[];return u.forEach((p,h)=>{if(!yr(p))return;const f=p.select.kind;if(f!==void 0&&f!==t.geom||p.select.layer!==void 0&&p.select.layer!==t.id)return;const g=p.when?.state;if(g!==void 0&&!zs(g))return;const v={list:d,index:h,...p.id===void 0?{}:{id:p.id}},y=p.when?.where;if(y!==void 0){const I=ce(y,t.data,"style-rule");if(I.length>0){for(const x of I)o.push({...x,code:"INVALID_STYLE_RULE",message:`Style ${d}[${h}]: ${x.message}`,context:{...x.context,layerIndex:r,...p.id===void 0?{}:{styleEntryId:p.id}}});return}}const A=Hs(p,t.geom,s,`${d}[${h}]`,v,o);Object.keys(A).length!==0&&m.push({declarations:A,...y===void 0?{}:{matches:le(y,i)},...g===void 0?{}:{state:g},origin:v})}),m};return{defaults:[...Py(t.geom,s,o),...c(n.defaults,"defaults")],overrides:c(n.overrides,"overrides"),warnings:o}},Ks=e=>{const{declarations:t,vocabulary:r,tokens:n,location:a,origin:i,warnings:o,entryTarget:s}=e,c={},u=i.list==="builtin"||i.id===void 0?{}:{styleEntryId:i.id},d=(f,g)=>{c[f]=g},m=(f,g,v)=>{o.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: expected ${g}, got ${ae(v)}.`,context:{param:f,expected:g,actual:ae(v),...u},suggestion:`Set '${f}' to ${g}.`})},p=(f,g)=>{o.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: unknown token '${g}'.`,context:{param:f,actual:g,...u},suggestion:`Declare '${g}' in the stylesheet's tokens.`})},h=f=>{const g=Iy.has(f),v=Cy(s,f),y=v===void 0?`Declare '${f}' on a target whose vocabulary carries it.`:`Declare '${f}' on an entry whose kind supports it (e.g. ${v}).`;o.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: ${g?"not in this entry's vocabulary":"not a style property"}.`,context:{param:f,...u},suggestion:g?y:`Remove the unknown declaration '${f}'.`})};for(const f of Object.keys(t)){const g=t[f];if(g===void 0)continue;const v=r[f];if(v===void 0){h(f);continue}const y=l.STYLE_DOMAINS[v](g,n);switch(y.status){case"accepted":d(f,y.value);break;case"rejected":m(f,y.expected,y.actual);break;case"unknownToken":p(f,y.token);break;case"dropped":break;default:break}}return c},By=({layer:e})=>{if(e.position==="stack")return;const t=l.readVariableName(e.mapping.y);if(t===null)return;let r=0,n=0;for(const a of e.data){const i=a[t];l.isStrictNumericDataValue(i)&&(r+=i,n+=Math.abs(i))}return{grandTotal:r,absoluteGrandTotal:n}},Fy=({layer:e,mainAxis:t})=>{if(e.position!=="stack")return;const r=l.readVariableName(e.mapping.x);if(r===null||!e.data.hasVariable(l.POSITION_VARIABLES.yMin)||!e.data.hasVariable(l.POSITION_VARIABLES.yMax))return;const n=s=>t==="y"?s.xMax:s.yMax,a=s=>t==="y"?s.xMin:s.yMin,i=new Map;for(const s of e.data){const c=s[r],u=B(s),d=_(s),m=z(s),p=W(s),h=hn(s);if(!l.isDefined(c)||!l.isDefined(u)||!l.isDefined(d)||!l.isDefined(m)||!l.isDefined(p)||!l.isDefined(h))continue;const f=h>=0;if(Math.abs(h)===0)continue;const g=wn(s,r),v={xMin:m,xMax:p,yMin:u,yMax:d},y=i.get(g);if(y===void 0){i.set(g,{total:h,topPositive:f?v:null,bottomNegative:f?null:v});continue}y.total+=h,f?(y.topPositive===null||n(v)>n(y.topPositive))&&(y.topPositive=v):(y.bottomNegative===null||a(v)<a(y.bottomNegative))&&(y.bottomNegative=v)}const o=[];for(const[s,c]of i){const u=c.topPositive??c.bottomNegative;u!==null&&o.push({xKey:s,total:c.total,anchor:{xMin:u.xMin,xMax:u.xMax,yMin:u.yMin,yMax:u.yMax,direction:c.topPositive!==null?"positive":"negative"}})}return o},Gy=class extends _e{constructor(e){super(),this.container=e}dependencies(e){return[e.coordSystem]}compileLayer(e,t){const r=this.container.geomRegistry.get(e.geom),n={},a=t.coordSystem.type==="cartesian"?t.coordSystem.mainAxis:"x";if(r.summaries.stackTotals){const i=Fy({layer:e,mainAxis:a});i!==void 0&&(n.stackTotals=i)}if(r.summaries.grandTotal){const i=By({layer:e});i!==void 0&&(n.grandTotal=i.grandTotal,n.absoluteGrandTotal=i.absoluteGrandTotal)}return{...e,summary:n}}},Ys=class extends l.Stage{constructor(e){super(),this.registry=e}key(e){return e.data}dependencies(e){return[e.transforms]}run(e){return e.transforms.reduce((t,r)=>this.registry.get(r.transformType).apply(t,r),e.data)}},si={color:"categorical",size:"numeric",alpha:"numeric",strokeWidth:"numeric",lineType:"categorical"},$y=["color","size","alpha","strokeWidth","lineType"],Uy=class extends _e{dependencies(e){return $y.map(t=>e.scales[t])}compileLayer(e,t){let r=e.data;const n=Object.entries(l.VISUAL_VARIABLES);for(const[a,i]of n){const o=l.readConstantValue(e.mapping[a]);if(o!==void 0){r=r.addConstantVariable(i,si[a],o);continue}const s=l.readVariableName(e.mapping[a]),c=t.scales[a];!s||!c||c.kind!=="visual"||(r=r.deriveVariableFrom(s,i,si[a],Hy(c)))}return{...e,data:r}}},Hy=e=>t=>l.isDefined(t)?e.map(t):null;function js(e=new hr){return{diagnostics:new ay,geomRegistry:e}}var qs=class{constructor(e,t,r,n,a,i,o,s,c,u,d,m,p,h,f,g){this.container=e,this.dataCompiler=t,this.specCompiler=r,this.transformCompiler=n,this.constantMappingCompiler=a,this.layerPhasedCompiler=i,this.scaleCompiler=o,this.coordCompiler=s,this.positionMapperCompiler=c,this.visualMapperCompiler=u,this.guideCompiler=d,this.summarizeCompiler=m,this.stylesCompiler=p,this.chromeStylesCompiler=h,this.highlightsCompiler=f,this.annotationsCompiler=g,this.stageTimer=l.IS_DEV?fy():null,this.lastCompile=null,this.lastDiagnostics=null,this.lastData=void 0,this.lastCustomPalettes={},this.stages=[{name:"data",getStats:()=>this.dataCompiler.stats},{name:"transform",getStats:()=>this.transformCompiler.stats},{name:"constantMapping",getStats:()=>this.constantMappingCompiler.stats},{name:"layer",getStats:()=>this.layerPhasedCompiler.stats},{name:"coordSetup",getStats:()=>this.coordCompiler.setupStats},{name:"scale",getStats:()=>this.scaleCompiler.stats},{name:"positionMapper",getStats:()=>this.positionMapperCompiler.stats},{name:"visualMapper",getStats:()=>this.visualMapperCompiler.stats},{name:"coordTransform",getStats:()=>this.coordCompiler.transformStats},{name:"summarize",getStats:()=>this.summarizeCompiler.stats},{name:"guide",getStats:()=>this.guideCompiler.stats},{name:"styles",getStats:()=>this.stylesCompiler.stats},{name:"chromeStyles",getStats:()=>this.chromeStylesCompiler.stats},{name:"highlights",getStats:()=>this.highlightsCompiler.stats},{name:"annotations",getStats:()=>this.annotationsCompiler.stats}],l.IS_DEV&&this.setupStageTiming()}compile(e){try{const t=this.runCompile(()=>(this.lastData=e.data,this.lastCustomPalettes=e.customPalettes??{},this.runPipeline({spec:this.specCompiler.compile({spec:e.spec,customPalettes:this.lastCustomPalettes,dataset:this.dataCompiler.compile(e.data)}),colorScheme:e.colorScheme??li})));return this.toOkResult(t)}catch(t){return this.toErrorResult(t)}}recompile(e){try{const t=this.runCompile(()=>{const r=e.colorScheme??li;if(e.data===void 0)return this.runPipeline({spec:e.spec,colorScheme:r});this.lastData=e.data;const n=this.dataCompiler.compile(e.data),a=this.reResolveInferredScalesIfNeeded(e.spec.data,w(e.spec,{data:n}));return this.runPipeline({spec:a,colorScheme:r})});return this.toOkResult(t)}catch(t){return this.toErrorResult(t)}}getCacheStats(){const e={};for(const{name:t,getStats:r}of this.stages)e[t]={...r()};return e}getLastCompile(){return this.lastCompile}getDiagnostics(){return this.lastDiagnostics}reResolveInferredScalesIfNeeded(e,t){if(e.size()!==0||t.data.size()===0||t.scales.filter(n=>n.inferredFrom!==void 0).length===0)return t;const r=Dn(this.container,{data:t.data,layers:t.layers,mapping:t.mapping,customPalettes:this.lastCustomPalettes});return w(t,{scales:Oe(t.scales,n=>{const a=n.inferredFrom;if(a===void 0)return n;const i=gr(r,a);return t.coords.coordType==="polar"?Pn(i):i})})}runCompile(e){this.container.diagnostics.reset();const t=this.trackCompile(e);return this.lastDiagnostics=this.container.diagnostics.drain(),t}toOkResult(e){return{ok:!0,scene:e,warnings:this.lastDiagnostics?.warnings??[]}}toErrorResult(e){const t=this.container.diagnostics.drain();return this.lastDiagnostics=t,{ok:!1,errors:t.errors.length>0?t.errors:[Fo(e)],warnings:t.warnings}}setupStageTiming(){this.stageTimer&&(this.dataCompiler.compile=this.stageTimer.wrap("data",this.dataCompiler.compile.bind(this.dataCompiler)),this.transformCompiler.compile=this.stageTimer.wrap("transform",this.transformCompiler.compile.bind(this.transformCompiler)),this.constantMappingCompiler.compile=this.stageTimer.wrap("constantMapping",this.constantMappingCompiler.compile.bind(this.constantMappingCompiler)),this.layerPhasedCompiler.compile=this.stageTimer.wrap("layer",this.layerPhasedCompiler.compile.bind(this.layerPhasedCompiler)),this.coordCompiler.setup=this.stageTimer.wrap("coordSetup",this.coordCompiler.setup.bind(this.coordCompiler)),this.scaleCompiler.compile=this.stageTimer.wrap("scale",this.scaleCompiler.compile.bind(this.scaleCompiler)),this.positionMapperCompiler.compile=this.stageTimer.wrap("positionMapper",this.positionMapperCompiler.compile.bind(this.positionMapperCompiler)),this.visualMapperCompiler.compile=this.stageTimer.wrap("visualMapper",this.visualMapperCompiler.compile.bind(this.visualMapperCompiler)),this.coordCompiler.transform=this.stageTimer.wrap("coordTransform",this.coordCompiler.transform.bind(this.coordCompiler)),this.summarizeCompiler.compile=this.stageTimer.wrap("summarize",this.summarizeCompiler.compile.bind(this.summarizeCompiler)),this.guideCompiler.compile=this.stageTimer.wrap("guide",this.guideCompiler.compile.bind(this.guideCompiler)),this.stylesCompiler.compile=this.stageTimer.wrap("styles",this.stylesCompiler.compile.bind(this.stylesCompiler)),this.chromeStylesCompiler.compile=this.stageTimer.wrap("chromeStyles",this.chromeStylesCompiler.compile.bind(this.chromeStylesCompiler)),this.highlightsCompiler.compile=this.stageTimer.wrap("highlights",this.highlightsCompiler.compile.bind(this.highlightsCompiler)),this.annotationsCompiler.compile=this.stageTimer.wrap("annotations",this.annotationsCompiler.compile.bind(this.annotationsCompiler)))}trackCompile(e){if(!l.IS_DEV)return e();this.stageTimer?.reset();const t=this.getCacheStats(),r=performance.now();try{return e()}finally{const n=performance.now()-r,a={},i={};for(const{name:o,getStats:s}of this.stages){const c=s();a[o]={hits:c.hits-t[o].hits,misses:c.misses-t[o].misses},i[o]=this.stageTimer?.getDuration(o)??0}this.lastCompile={stages:a,durationMs:n,stageDurationsMs:i}}}runPipeline({spec:e,colorScheme:t}){return{...ur({spec:e}).pipe(({spec:r})=>({spec:w(r,{data:this.transformCompiler.compile({data:r.data,transforms:r.transforms})})})).pipe(({spec:r})=>{const n=this.constantMappingCompiler.compile({data:r.data,mapping:r.mapping});return{spec:w(r,{data:n.data,mapping:n.mapping})}}).pipe(({spec:r})=>({layers:this.layerPhasedCompiler.compile({data:r.data,layers:r.layers,mapping:r.mapping,coords:r.coords,scales:r.scales})})).pipe(({spec:r,layers:n})=>this.coordCompiler.setup({coordSpec:r.coords,scales:r.scales,layers:n})).pipe(({layers:r,scales:n})=>({scales:this.scaleCompiler.compile({layers:r,scales:n,colorScheme:t})})).pipe(({spec:r})=>({config:r.config})).pipe(({layers:r,scales:n})=>({layers:this.positionMapperCompiler.compile({layers:r,scales:n})})).pipe(({layers:r,scales:n})=>({layers:this.visualMapperCompiler.compile({layers:r,scales:n})})).pipe(({spec:r,layers:n,coordSystem:a})=>({layers:this.coordCompiler.transform({coordSpec:r.coords,coordSystem:a,layers:n})})).pipe(({layers:r,coordSystem:n})=>({layers:this.summarizeCompiler.compile({layers:r,coordSystem:n})})).pipe(({spec:r,scales:n,layers:a,coordSystem:i})=>({guides:this.guideCompiler.compile({scales:n,config:r.config,layers:a,coordSystem:i,originalData:this.lastData})})).pipe(({spec:r,layers:n})=>({layers:this.stylesCompiler.compile({layers:n,styles:r.styles,config:r.config})})).pipe(({spec:r})=>({chrome:this.chromeStylesCompiler.compile({styles:r.styles,annotations:r.annotations})})).pipe(({spec:r,layers:n})=>({layers:this.highlightsCompiler.compile({layers:n,highlights:r.highlights,config:r.config})})).pipe(({spec:r,layers:n,coordSystem:a,scales:i})=>({annotations:this.annotationsCompiler.compile({annotations:r.annotations,layers:n,coordSystem:a,scales:i,config:r.config})})).result(),spec:e}}},zy=["data","transform","constantMapping","layer","coordSetup","scale","positionMapper","visualMapper","coordTransform","summarize","guide","styles","chromeStyles","highlights","annotations"],li="light",Wy=({plugins:e=[]}={})=>{const t=xs(e),{geomRegistry:r,statRegistry:n,transformRegistry:a}=Uf(t),i=js(r),o=new Rg(i),s=new Ys(a);for(const c of t.warnings)i.diagnostics.addWarning(c,{persistent:!0});return new qs(i,new l.DataCompiler,new Ns(i),s,new up,new df(i,s,n,new nf(i,s,new gy(n),new kp,new Op(i),new Wf(new Jf))),new dg(i,o),new pp(new Cp),new ug(i),new Uy,new jh(i),new Gy(i),new Ay(i),new xy(i),new Jh(i),new Xm(i))};function Xs(e,t){return e.geom===t}function Zs(...e){let t={},r;const[n,...a]=e;l.isDefined(n)&&!Ky(n)?(t=n,r=a):r=e;const i={mapping:t,layers:[],scales:[],transforms:[],highlights:[],config:{}};return r.reduce((o,s)=>Qs(o,s),i)}function Js(e,...t){return t.reduce((r,n)=>Qs(r,n),e)}function Ky(e){return typeof e=="object"&&e!==null&&"type"in e}function Qs(e,t){switch(t.type){case"scale":return{...e,scales:[...e.scales,t]};case"coord":return{...e,coords:t};case"config":return{...e,config:(0,qt.default)({},e.config,t.config)};case"layer":return{...e,layers:[...e.layers,t]};case"transform":return{...e,transforms:[...e.transforms,t]};case"mapping":return{...e,mapping:{...e.mapping,...t.mapping}};case"highlight":return{...e,highlights:[...e.highlights,t]};case"styles":return{...e,styles:e.styles===void 0?t:{...t,extends:[e.styles,...t.extends??[]]}};case"annotation":return Yy(e,t);default:throw new l.InternalError({message:`Unknown spec item type: ${t.type}`})}}function Yy(e,t){const r={...e.annotations};switch(t.kind){case"differenceArrow":r.differenceArrows=[...r.differenceArrows??[],t.annotation];break;case"shape":r.shapes=[...r.shapes??[],t.annotation];break;case"arrow":r.arrows=[...r.arrows??[],t.annotation];break;case"text":r.textAnnotations=[...r.textAnnotations??[],t.annotation];break;case"image":r.images=[...r.images??[],t.annotation];break;case"sticker":r.stickers=[...r.stickers??[],t.annotation];break;case"pinnedNumber":r.pinnedNumbers=[...r.pinnedNumbers??[],t.annotation];break;case"comment":r.comments=[...r.comments??[],t.annotation];break;default:throw new Error(`Unknown annotation kind: ${t.kind}`)}return{...e,annotations:r}}function jy(e){const t=e?.plugins??[],r=Xy(t);return{geom:{...l.geom,...r.geom},stat:{...l.stat,...r.stat},transform:{...l.transform,...r.transform},scale:l.scale,coord:l.coord,createSpec:Zs,pipe:Js,plugins:t}}var qy=e=>(t={})=>l.buildLayerSpec(e,t);function Xy(e){const{geoms:t,stats:r,transforms:n}=xs(e),a={};for(const s of t)a[s.type]=qy(s.type);const i={};for(const s of r)i[s.type]=()=>({type:s.type});const o={};for(const s of n)o[s.transformType]=c=>({type:"transform",transformType:s.transformType,options:c?.options});return{geom:a,stat:i,transform:o}}var Or="…",el=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Or)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Or)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Or};var U={timeZone:"UTC"},G=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},Te=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",Bn=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",Zy=zr.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),tl=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>Te(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=$n(a,i),{base:s,suffix:c}=Gn(a,r.abbreviation),u={...o,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return`${Intl.NumberFormat(t,u).format(s)}${c}`}),rl=({locale:e,numberFormat:t,intlOptions:r})=>Te(n=>{const{base:a,suffix:i}=Gn(n,t.abbreviation),o={...$n(a,t.decimals),...r};return`${Intl.NumberFormat(e,o).format(a)}${i}`}),Fn=e=>Te(t=>Zy(t)),nl=({locale:e,intlOptions:t})=>Te(r=>Intl.NumberFormat(e,{maximumFractionDigits:0,...t}).format(r)),al=({locale:e,numberFormat:t,intlOptions:r})=>Te(n=>{const a=$n(n,t.decimals);return Intl.NumberFormat(e,{...a,...r,style:"percent"}).format(n)}),Gn=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Jy(e);return Gn(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},$n=(e,t)=>{if(typeof t=="number")return{minimumFractionDigits:t,maximumFractionDigits:t};const r=Math.ceil(Math.log10(Math.abs(e))),n=r>=3?0:r===2?1:2;return{minimumFractionDigits:t==="auto"?0:n,maximumFractionDigits:n}},Jy=e=>{const t=Math.abs(e);return t>=l.SUFFIX_MULTIPLIERS.b?"b":t>=l.SUFFIX_MULTIPLIERS.m?"m":t>=l.SUFFIX_MULTIPLIERS.k?"k":"none"},Qy=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{dateStyle:"medium",...U,...t}).format(r)),ev=({locale:e,intlOptions:t})=>G(r=>{const n=Intl.DateTimeFormat(e,{dateStyle:"medium",timeStyle:"medium",...U,...t}).formatToParts(r);return tv(n.map(rv))}),il=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{day:"numeric",month:"long",...U,...t}).format(r)),ol=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{month:"long",...U,...t}).format(r)),Un=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{month:"short",year:"numeric",...U,...t}).format(r)),Hn=e=>G(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),sl=({locale:e,intlOptions:t})=>G(r=>{const n=(0,Co.addDays)(r,6);return Intl.DateTimeFormat(e,{day:"numeric",month:"long",...U,...t,year:void 0}).formatRange(r,n)}),ll=({locale:e,intlOptions:t})=>G(r=>{const n=(0,Co.addDays)(r,6);return Intl.DateTimeFormat(e,{dateStyle:"medium",...U,...t}).formatRange(r,n)}),zn=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{year:"numeric",...U,...t}).format(r)),cl=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{timeStyle:"short",...U,...t}).format(r)),tv=e=>e.map(t=>t.value).join(""),rv=e=>e.type!=="literal"||e.value!==", "?e:{type:"literal",value:" • "},ci=1e3,nv=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>Te(a=>{const i={...Kn(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Wn(a,t,i)}),av=({locale:e,tickValues:t,intlOptions:r})=>Te(n=>{const a={...Kn(n,t),notation:"compact",...r};return Wn(n,e,a)}),iv=({locale:e,tickValues:t,intlOptions:r})=>Te(n=>{const a={...Kn(n,t),notation:"compact",...r,style:"percent"};return Wn(n,e,a)}),Wn=(e,t,r)=>Intl.NumberFormat(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),ul=e=>Math.abs(e)>ci?ul(e/ci):Number.isInteger(e),ov=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},Kn=(e,t)=>ul(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:ov(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:1},sv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{day:"numeric",month:"short",...U,...t}).format(r)),lv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{month:"short",...U,...t}).format(r)),cv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{day:"numeric",month:"short",...U,...t}).format(r)),uv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{timeStyle:"short",...U,...t}).format(r)),Yn=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return nv(e);case"date":case"datetime":return sv(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return cv(e);case"decimal":case"integer":return av(e);case"duration":return Fn(e);case"month":return lv(e);case"month_year":return Un(e);case"percentage":return iv(e);case"quarter":return Hn(e);case"text":return Bn(e);case"time":return uv(e);case"year":return zn(e);case"lookup":return Yn({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},dv=.9,mv=1/3,pv=1/4,hv=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?fv(e):gv(e),fv=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=dl(e.ticks,n),s=yv(e.ticks,r.width),c=s*dv;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const d=Qr(c);return{...e,ticks:Jr(e.ticks,a,d,n),labelRotation:0,labelMaxWidthPx:d}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=Qr(r.height*mv);return{...e,ticks:Jr(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},gv=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=dl(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=Qr(r.width*pv);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:Jr(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},yv=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},dl=(e,t)=>{const r=[];let n=0,a=0;for(const i of e){const{width:o,height:s}=t(i.formattedLabel);r.push(o),o>n&&(n=o),s>a&&(a=s)}return{widths:r,maxWidth:n,maxHeight:a}},Jr=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:el(i.formattedLabel,r,a)})},Qr=e=>Math.max(0,Math.floor(e)),vv=(e,t,r,n)=>{if(e.length===0)return!0;const a=t==="top"||t==="bottom",i=a?60:40;let o=r-(e.length-1)*i;for(const s of e){const{width:c,height:u}=n(s);if(o-=a?c:u,o<0)return!1}return!0},bv=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=m=>{const p=o.get(m);if(p)return p;const h=a[m],f=h?Sv(h.ticks,n(h)):[];return o.set(m,f),f};let c=0,u=a.length-1,d=-1;for(;c<=u;){const m=c+u>>>1;vv(s(m).map(p=>p.formattedLabel),i,t,r)?(d=m,c=m+1):u=m-1}return d>=0?s(d):s(0)},Sv=(e,t)=>e.map(r=>({...r,formattedLabel:t(r.value)})),ui=.5,wt=e=>({x:0,y:0,width:e.width,height:e.height}),jn=e=>e==="panel-end"?"end":e==="panel-start"?"start":e,Rt=({box:e,panel:t,orientation:r,placement:n,justify:a,align:i,offset:o,alignOffset:s,labelWidth:c,labelHeight:u})=>{const d=a==="panel-start"||a==="panel-end",m=(r.valueAxis==="x"?e.height:e.width)===0,p={anchor:xv(a,r.valueDirectionSign),placement:d?"inside":n,offset:o},h={anchor:Iv(i),placement:m?n:"inside",offset:m?s??o:0},f=d?t:e,g=r.valueAxis==="x"?f:e,v=r.valueAxis==="y"?f:e,y=r.valueAxis==="x"?p:h,A=r.valueAxis==="x"?h:p,I=mi(y,{min:g.x,max:g.x+g.width,halfExtent:c/2}),x=mi(A,{min:v.y,max:v.y+v.height,halfExtent:u/2});return{x:I,y:x,position:Av(e,I,x,c,u)}},di=(e,t,r,n)=>r-n>=e-ui&&r+n<=t+ui,Av=(e,t,r,n,a)=>{if(e.width===0&&e.height===0)return"outside";const i=e.width===0||di(e.x,e.x+e.width,t,n/2),o=e.height===0||di(e.y,e.y+e.height,r,a/2);return i&&o?"inside":"outside"},xv=(e,t)=>e==="center"?"center":(e==="end"||e==="panel-end")==(t===1)?"max":"min",Iv=e=>e==="center"?"center":e==="start"?"min":"max",mi=({anchor:e,placement:t,offset:r},{min:n,max:a,halfExtent:i})=>{if(e==="center")return(n+a)/2;if(t==="inside"&&n===a)return n;const o=r+i;return e==="min"?t==="inside"?n+o:n-o:t==="inside"?a-o:a+o},Tv=(e,t,r,n,a)=>{const i=t??e,o=1-Math.max(e,i);return{box:{x:r*n,y:o*a,width:0,height:Math.abs(e-i)*a},orientation:{valueAxis:"y",valueDirectionSign:e>=i?-1:1}}},Lv=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{offset:r}=e.layer.dataLabels,n=wv(e.layer);for(const a of e.layer.data){const i=V(a),o=_(a)??R(a);if(i===null||o===null||!Ze(i,o))continue;const s=e.formatLabel(a);if(s==="")continue;const{width:c,height:u}=e.measureDataLabel("observation","outside",s),{box:d,orientation:m}=Tv(o,B(a),i,e.panelRect.width,e.panelRect.height),p=Rt({box:d,panel:wt(e.panelRect),orientation:m,...n,offset:r,labelWidth:c,labelHeight:u});t.push({layerId:e.layer.id,x:p.x,y:p.y,text:s,width:c,height:u,isRotated:!1,role:"observation",position:"outside"})}return{labels:t,droppedCount:0}},Ev={place:Lv,getPercentageValueStrategy:e=>e.position==="fill"?"fill":l.isStackedPosition(e.position)?"stack":"none"},wv=e=>{const{position:t,justify:r,align:n}=e.dataLabels;return t==="auto"?{placement:"outside",justify:"end",align:"center"}:{placement:t,justify:mr(e.data,e.mapping)?jn(r):r,align:n}};function vr(e){return e[l.VISUAL_VARIABLES.color]}function ml(e){return e[l.VISUAL_VARIABLES.alpha]}function qn(e){return e[l.VISUAL_VARIABLES.size]}function en(e){return e[l.VISUAL_VARIABLES.strokeWidth]}function pl(e){return e[l.VISUAL_VARIABLES.lineType]}var pi=new WeakMap,Rv=(e,t,r)=>{const n=gi(e.graph,hi(l.STYLE_TARGETS.graph,{}),r),a=yi(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:yi(gi(e[s.select.target],hi(s,c),r),a,s.vocabulary),o=s=>{const c=Object.fromEntries(Object.entries(s.children??{}).map(([d,m])=>[d,o(m)]));if(s.select.target==="geom")return Object.assign(d=>t(d),c);if((s.options??[]).includes("annotation"))return Object.assign(vi(d=>i(s,{annotation:d})),c);if((s.options??[]).includes("layer")){const d=vi(m=>i(s,{layer:m}));return Object.assign(m=>d(m.id),c)}if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Vv(s)){const d=new Map;return Object.assign(m=>{const p=d.get(m);if(p!==void 0)return p;const h=i(s,{axis:m});return d.set(m,h),h},c)}const u=i(s,{});return Object.assign(()=>u,c)};return Object.fromEntries(Object.entries(l.STYLE_TARGETS).map(([s,c])=>[s,o(c)]))},Cv=e=>{const t=i=>i===void 0?e.panelBorder():e.panelBorder[i](),r=Object.assign(i=>i===void 0?e.legend():e.legend[i](),{popover:e.legend.popover()}),n=(i,o)=>i==="aggregate"?e.dataLabel.aggregate():e.dataLabel[i][o](),a=(i,o,s)=>s===void 0?i[o]():i[s](o);return{panelBorder:t,gridLine:i=>e.gridLine[i](),tickLine:i=>e.tickLine[i](),axisLabel:(i,o)=>a(e.axisLabel,i,o),tickLabel:(i,o)=>a(e.tickLabel,i,o),ruleLabel:i=>e.geom.rule.label({id:i}),dataLabel:n,graph:e.graph(),heading:{h1:e.heading.h1(),h2:e.heading.h2()},caption:e.caption(),source:{label:e.source(),link:e.source.link()},header:e.header(),footer:e.footer(),hoverGuide:e.hoverGuide(),editOutline:i=>e.editOutline[i](),tooltip:{box:e.tooltip(),heading:e.tooltip.heading(),label:e.tooltip.label(),value:e.tooltip.value(),primaryRow:e.tooltip.primaryRow()},headline:e.headline(),headlineItem:{number:e.headlineItem.number(),numberCenter:e.headlineItem.number.center(),caption:e.headlineItem.caption(),label:e.headlineItem.label(),swatch:e.headlineItem.swatch(),trend:e.headlineItem.trend(),trendUp:e.headlineItem.trend.up(),trendDown:e.headlineItem.trend.down(),trendFlat:e.headlineItem.trend.flat()},legend:r,legendItem:{item:e.legendItem(),swatch:e.legendItem.swatch()},directLabel:e.directLabel(),annotation:{shape:i=>e.annotation.shape(i),arrow:i=>e.annotation.arrow(i),differenceArrow:Object.assign(i=>e.annotation.differenceArrow(i),{label:i=>e.annotation.differenceArrow.label(i)}),text:i=>e.annotation.text(i),image:i=>e.annotation.image(i),pinnedNumber:Object.assign(i=>e.annotation.pinnedNumber(i),{label:i=>e.annotation.pinnedNumber.label(i)}),comment:Object.assign(i=>e.annotation.comment(i),{label:i=>e.annotation.comment.label(i)})}}},Vv=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},hi=(e,t)=>{const r=l.findStyleTarget({target:e.select.target})??e,n=t.axis!==void 0?{...e.select,axis:t.axis}:e.select,a=r.partWildcard!==!0;return i=>{const o=i.select;if(o.target!==n.target)return!1;for(const s of l.STYLE_SELECT_KEYS){const c=n[s],u=o[s];if(s==="part"&&a){if(u!==c)return!1;continue}if(c===void 0){if(u!==void 0)return!1}else if(u!==void 0&&u!==c)return!1}if(t.annotation!==void 0){const s="annotation"in i.select?i.select.annotation:void 0;if(s!==void 0&&s!==t.annotation)return!1}if(t.layer!==void 0){const s="layer"in i.select?i.select.layer:void 0;if(s!==void 0&&s!==t.layer)return!1}return!0}},fi=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){const a=e[n];if(!(a===void 0||!r(a))&&a.declarations[t]!==void 0)return a}},gi=(e,t,r)=>{const n=c=>fi(e.overrides,c,t)??fi(e.defaults,c,t);return{get:c=>{const u=n(c)?.declarations[c];if(u!==void 0)return l.resolveColorScheme(u,r)},getSource:c=>{const u=n(c);return u===void 0?"unresolved":u.origin.list==="builtin"?"builtin":"authored"},explain:c=>{const u=n(c),d=u?.declarations[c];return u===void 0||d===void 0?{value:void 0,source:"unresolved"}:{value:l.resolveColorScheme(d,r),source:u.origin.list==="builtin"?"builtin":"authored",origin:u.origin,select:u.select}},collectAll:c=>{const u=[];for(const d of[e.defaults,e.overrides])for(const m of d){if(!t(m))continue;const p=m.declarations[c];p!==void 0&&u.push(l.resolveColorScheme(p,r))}return u}}},Mv=(e,t,r)=>{e.fontSize!==void 0&&(e.fontSize*=t.get("textScale")),"fontFamily"in r&&(e.fontFamily??=t.get("fontFamily"))},yi=(e,t,r)=>({...e,resolve:()=>{const n=pi.get(e);if(n!==void 0)return n;const a={};for(const i of Object.keys(r)){const o=e.get(i);o!==void 0&&Object.assign(a,{[i]:o})}return Mv(a,t,r),pi.set(e,a),a}}),vi=e=>{const t=new Map;return r=>{const n=t.get(r);if(n!==void 0)return n;const a=e(r);return t.set(r,a),a}},Dv={color:vr,alpha:ml,strokeWidth:en,lineType:pl,size:qn,borderWidth:en},bi=new WeakMap,at=(e={})=>{const t=e.colorScheme??"light",r=new WeakMap,n=new WeakMap,a=new WeakMap,i=c=>{const u=r.get(c);if(u!==void 0)return u;const d=Ov(Pv(c.styles),t,_v(c.geom));return r.set(c,d),d},o=c=>{const u=n.get(c);if(u!==void 0)return u;const d=Cv(s({chrome:c}));return n.set(c,d),d},s=c=>{const u=a.get(c.chrome);if(u!==void 0)return u;const d=Rv(c.chrome,i,t);return a.set(c.chrome,d),d};return{readers:s,geomReaders:i,chromeReaders:o}},Pv=e=>{const t=bi.get(e);if(t!==void 0)return t;const r={defaults:Si(e.defaults),overrides:Si(e.overrides)};return bi.set(e,r),r},Si=e=>{const t={};for(const r of e)for(const n of Object.keys(r.declarations)){if(r.declarations[n]===void 0)continue;const a=t[n]??={};(a[r.state??"stateless"]??=[]).push(r)}return t},Ov=(e,t,r)=>{const n=(s,c,u)=>{if(u!==void 0){const h=lt(e.overrides,s,c,u);if(h!==void 0)return{value:st(h,s,t),tier:"override",origin:h.origin,state:u};const f=lt(e.defaults,s,c,u);if(f!==void 0)return{value:st(f,s,t),tier:"default",origin:f.origin,state:u}}const d=lt(e.overrides,s,c,void 0);if(d!==void 0)return{value:st(d,s,t),tier:"override",origin:d.origin};const m=Ai(s,c);if(m!==void 0)return{value:m,tier:"data"};const p=lt(e.defaults,s,c,void 0);return p!==void 0?{value:st(p,s,t),tier:"default",origin:p.origin}:{value:void 0,tier:"unresolved"}},a=(s,c,u)=>{if(u!==void 0){const p=Ft(e.overrides,s,c,u,t);if(p!==void 0)return p;const h=Ft(e.defaults,s,c,u,t);if(h!==void 0)return h}const d=Ft(e.overrides,s,c,void 0,t);if(d!==void 0)return d;const m=Ai(s,c);return m!==void 0?m:Ft(e.defaults,s,c,void 0,t)};return{get:a,getSource:(s,c,u)=>n(s,c,u).tier,explain:n,collectAll:(s,c,u)=>{const d=[];for(const m of[e.defaults,e.overrides]){const p=m[s]?.[u??"stateless"];if(p!==void 0)for(const h of p){const f=h.declarations[s];f!==void 0&&hl(h,c)&&d.push(l.resolveColorScheme(f,t))}}return d},resolve:(s,c)=>{const u={};for(const d of Object.keys(r)){const m=a(d,s,c);m!==void 0&&Object.assign(u,{[d]:m})}return u}}},_v=e=>{const t=l.STYLE_TARGETS.geom.children;return Object.hasOwn(t,e)?t[e].vocabulary:l.STYLE_TARGETS.geom.vocabulary},Ft=(e,t,r,n,a)=>st(lt(e,t,r,n),t,a),st=(e,t,r)=>{const n=e?.declarations[t];return n===void 0?void 0:l.resolveColorScheme(n,r)},lt=(e,t,r,n)=>{const a=e[t]?.[n??"stateless"];if(a!==void 0)for(let i=a.length-1;i>=0;i--){const o=a[i];if(o!==void 0&&hl(o,r))return o}},hl=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),Ai=(e,t)=>{const r=Dv[e];if(!(r===void 0||t===void 0))return r(t)??void 0},Xn=(e,t,r)=>{const n={},a=i=>{const o=n[i];if(o!==void 0)return o;const{width:s,height:c}=e(t,i,r),u={width:s,height:c};return n[i]=u,u};return{get inside(){return a("inside")},get outside(){return a("outside")}}},Gt=6,kv=.5,Nv=e=>{const t=[];let r=0;const n=l.isStackedPosition(e.layer.position),a=e.coordSystem.mainAxis==="y";if(e.layer.dataLabels.showDataLabels){const{entries:i,shouldRotate:o}=Fv({layer:e.layer,mainAxis:e.coordSystem.mainAxis,panelRect:e.panelRect,measureDataLabel:e.measureDataLabel,formatLabel:e.formatLabel,isFlipped:a});for(const s of i){const c=e.layer.dataLabels.position==="auto"?Uv({mainAxis:e.coordSystem.mainAxis,isStacked:n,isNegativeBar:s.isNegative,shouldRotate:o,bounds:s.bounds,boxes:s.boxes,panelWidth:e.panelRect.width,panelHeight:e.panelRect.height,offset:e.layer.dataLabels.offset}):zv(e.layer.dataLabels,e.coordSystem.mainAxis,n,s,wt(e.panelRect));if(c===null){r+=1;continue}const u=s.boxes[c.position];t.push({layerId:e.layer.id,x:c.x,y:c.y,text:s.text,width:u.width,height:u.height,isRotated:c.isRotated,role:"observation",position:c.position,...c.position==="inside"?{backdropColor:s.backdropColor}:{}})}}if(e.layer.dataLabels.showCategoryLabels)for(const i of Wv(e,n))t.push(i);if(e.layer.dataLabels.showStackTotals){const i=qv({layer:e.layer,mainAxis:e.coordSystem.mainAxis,panelRect:e.panelRect,measureDataLabel:e.measureDataLabel,formatAbsolute:e.formatAbsolute});for(const o of i)t.push(o)}return{labels:t,droppedCount:r}},Bv={place:Nv,getPercentageValueStrategy:e=>e.position==="fill"?"fill":l.isStackedPosition(e.position)?"stack":"absoluteGrandTotal"},Fv=({layer:e,mainAxis:t,panelRect:r,measureDataLabel:n,formatLabel:a,isFlipped:i})=>{const o=[];let s=!1;const c=e.dataLabels.position==="auto",u=l.readVariableName(e.mapping.y),d=at().geomReaders(e);for(const m of e.data){const p=gl(t,m);if(p===null)continue;const h=a(m);if(h==="")continue;const f=Xn(n,"observation",h),g=Zn(p,r);c&&f.inside.width>g.width&&(s=!0);const v=u===null?null:m[u],y=l.isStrictNumericDataValue(v)&&v<0;o.push({isNegative:y,text:h,boxes:f,bounds:g,backdropColor:d.get("color",m)})}return{entries:o,shouldRotate:!i&&s}},Zn=(e,t)=>({x:e.x*t.width,y:e.y*t.height,width:e.width*t.width,height:e.height*t.height}),fl=(e,t,r,n,a)=>{if(e==="x"){let s=1-a,c=a-n;return c<0&&(s+=c,c=-c),{x:t,y:s,width:r-t,height:c}}let i=t,o=r-t;return o<0&&(i+=o,o=-o),{x:i,y:1-a,width:o,height:a-n}},gl=(e,t)=>{const r=z(t),n=W(t),a=B(t),i=_(t)??R(t);return r===null||n===null||a===null||i===null?null:fl(e,r,n,a,i)},Gv=(e,t)=>{const{xMin:r,xMax:n,yMin:a,yMax:i}=t.anchor;return fl(e,r,n,a,i)},$v=(e,t)=>e==="x"?t?"bottom":"top":t?"left":"right",tn=(e,t,r)=>r?{width:t,height:e}:{width:e,height:t},Uv=e=>e.isStacked?Kv({bounds:e.bounds,box:e.boxes.inside,isRotated:e.shouldRotate}):jv({edge:$v(e.mainAxis,e.isNegativeBar),bounds:e.bounds,boxes:e.boxes,isRotated:e.shouldRotate,panelWidth:e.panelWidth,panelHeight:e.panelHeight,offset:e.offset}),yl=(e,t)=>e==="x"?{valueAxis:"y",valueDirectionSign:t?1:-1}:{valueAxis:"x",valueDirectionSign:t?-1:1},Hv=e=>e==="panel-start"||e==="panel-end",zv=(e,t,r,n,a)=>{if(e.position==="auto")return null;const i=r&&e.position==="outside"?"inside":e.position,o=n.boxes[i],s=Rt({box:n.bounds,panel:a,orientation:yl(t,n.isNegative),placement:i,justify:e.justify,align:e.align,offset:e.offset,labelWidth:o.width,labelHeight:o.height});if(i==="inside"&&!Hv(e.justify)){const c=t==="y",u=c?n.bounds.width:n.bounds.height;return(c?o.width:o.height)>u+kv?null:{x:s.x,y:s.y,isRotated:!1,position:"inside"}}return{x:s.x,y:s.y,isRotated:!1,position:s.position}},Wv=(e,t)=>{const r=[],{categoryPosition:n,categoryJustify:a,categoryAlign:i,categoryOffset:o}=e.layer.dataLabels,s=t&&n==="outside"?"inside":n,c=e.coordSystem.mainAxis,u=wt(e.panelRect),d=l.readVariableName(e.layer.mapping.y);for(const m of e.layer.data){const p=gl(c,m);if(p===null)continue;const h=e.formatCategory(m);if(h===null||h==="")continue;const f=Xn(e.measureDataLabel,"category",h),g=f[s],v=Zn(p,e.panelRect),y=d===null?null:m[d],A=l.isStrictNumericDataValue(y)&&y<0,I=Rt({box:v,panel:u,orientation:yl(c,A),placement:s,justify:a,align:i,offset:o,labelWidth:g.width,labelHeight:g.height}),x=f[I.position];r.push({layerId:e.layer.id,x:I.x,y:I.y,text:h,width:x.width,height:x.height,isRotated:!1,role:"category",position:I.position})}return r},Kv=({bounds:e,box:t,isRotated:r})=>{const n=tn(t.width,t.height,r);return n.width>e.width||n.height>e.height?null:{x:e.x+e.width/2,y:e.y+e.height/2,isRotated:r,position:"inside"}},Yv=(e,t,r,n)=>{switch(e){case"top":return{edgeCoord:t.y,outwardSign:-1,panelExtent:n};case"bottom":return{edgeCoord:t.y+t.height,outwardSign:1,panelExtent:n};case"left":return{edgeCoord:t.x,outwardSign:-1,panelExtent:r};case"right":return{edgeCoord:t.x+t.width,outwardSign:1,panelExtent:r}}},jv=({edge:e,bounds:t,boxes:r,isRotated:n,panelWidth:a,panelHeight:i,offset:o})=>{const s=e==="top"||e==="bottom",c=t.x+t.width/2,u=t.y+t.height/2,d=s?t.height:t.width,m=s?t.width:t.height,{edgeCoord:p,outwardSign:h,panelExtent:f}=Yv(e,t,a,i),g=tn(r.inside.width,r.inside.height,n),v=s?g.height:g.width,y=s?g.width:g.height,A=v+o<d,I=y<=m;if(s?A:A&&I){if(s&&!I)return null;if(n)return{x:c,y:u,isRotated:!0,position:"inside"};const te=p-h*(v/2+o);return{...s?{x:c,y:te}:{x:te,y:u},isRotated:!1,position:"inside"}}const x=tn(r.outside.width,r.outside.height,n),T=(s?x.height:x.width)/2,E=p+h*(T+o);return E-T<0||E+T>f?null:{...s?{x:c,y:E}:{x:E,y:u},isRotated:n,position:"outside"}},qv=({layer:e,mainAxis:t,panelRect:r,measureDataLabel:n,formatAbsolute:a})=>{const i=[],o=e.summary.stackTotals;if(o===void 0||o.length===0)return i;const s=t==="y";for(const c of o){const u=Zn(Gv(t,c),r),d=a(c.total),{width:m,height:p}=n("aggregate","outside",d),h=c.anchor.direction==="positive";let f,g;s?(f=h?u.x+u.width+Gt+m/2:u.x-Gt-m/2,g=u.y+u.height/2):(f=u.x+u.width/2,g=h?u.y-Gt-p/2:u.y+u.height+Gt+p/2),i.push({layerId:e.id,x:f,y:g,text:d,width:m,height:p,isRotated:!1,role:"aggregate",position:"outside"})}return i},Xv=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{offset:r}=e.layer.dataLabels,n=Jv(e.layer);for(const a of e.layer.data){const i=V(a),o=R(a);if(i===null||o===null||!Ze(i,o))continue;const s=e.formatLabel(a);if(s==="")continue;const{width:c,height:u}=e.measureDataLabel("observation","outside",s),d=Rt({box:{x:i*e.panelRect.width,y:(1-o)*e.panelRect.height,width:0,height:0},panel:wt(e.panelRect),orientation:{valueAxis:"y",valueDirectionSign:-1},...n,offset:r,labelWidth:c,labelHeight:u});t.push({layerId:e.layer.id,x:d.x,y:d.y,text:s,width:c,height:u,isRotated:!1,role:"observation",position:d.position})}return{labels:t,droppedCount:0}},Zv={place:Xv,getPercentageValueStrategy:()=>"none"},Jv=e=>{const{position:t,justify:r,align:n}=e.dataLabels;return t==="auto"?{placement:"outside",justify:"end",align:"center"}:{placement:t,justify:mr(e.data,e.mapping)?jn(r):r,align:n}},Qv=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{offset:r}=e.layer.dataLabels,n=tb(e.layer),a=n.justify==="panel-start"||n.justify==="panel-end",i=at().geomReaders(e.layer);for(const o of e.layer.data){const s=V(o),c=R(o);if(s===null||c===null||!Ze(s,c))continue;const u=e.formatLabel(o);if(u==="")continue;const{width:d,height:m}=e.measureDataLabel("observation","outside",u),p=i.get("size",o)/2,h=Rt({box:{x:s*e.panelRect.width,y:(1-c)*e.panelRect.height,width:0,height:0},panel:wt(e.panelRect),orientation:{valueAxis:"y",valueDirectionSign:-1},...n,offset:a?r:r+p,alignOffset:r+p,labelWidth:d,labelHeight:m});t.push({layerId:e.layer.id,x:h.x,y:h.y,text:u,width:d,height:m,isRotated:!1,role:"observation",position:h.position})}return{labels:t,droppedCount:0}},eb={place:Qv,getPercentageValueStrategy:()=>"none"},tb=e=>{const{position:t,justify:r,align:n}=e.dataLabels;return t==="auto"?{placement:"outside",justify:"end",align:"center"}:{placement:t,justify:r,align:n}},vl=e=>{const t=z(e),r=W(e),n=B(e),a=_(e);if(t===null||r===null||n===null||a===null)return null;const i=Math.min(t,r),o=Math.abs(r-t),s=Math.max(n,a),c=Math.abs(a-n);return{x:i,y:1-s,width:o,height:c}},bl=e=>{const t=vl(e);if(!t)return null;const r=t.width*ff,n=t.height*gf;return{x:t.x+r,y:t.y+n,width:t.width-r*2,height:t.height-n*2}},Sl=e=>!!vr(e),Al=e=>Sl(e)?bl(e):null,xi=4,rb=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const r=at().geomReaders(e.layer);for(const n of e.layer.data){const a=Al(n);if(a===null)continue;const i=e.formatLabel(n);if(i==="")continue;const{width:o,height:s}=e.measureDataLabel("observation","inside",i),c=a.width*e.panelRect.width,u=a.height*e.panelRect.height;o+xi>c||s+xi>u||t.push({layerId:e.layer.id,x:(a.x+a.width/2)*e.panelRect.width,y:(a.y+a.height/2)*e.panelRect.height,text:i,width:o,height:s,isRotated:!1,role:"observation",position:"inside",backdropColor:r.get("color",n)})}return{labels:t,droppedCount:0}},nb={place:rb,getPercentageValueStrategy:()=>"none"};function Jn(e){return{startAngle:e[l.POSITION_VARIABLES.xMin],endAngle:e[l.POSITION_VARIABLES.xMax]}}function Qn(e){return{innerRadius:e[l.POSITION_VARIABLES.yMin],outerRadius:e[l.POSITION_VARIABLES.yMax]??e[l.POSITION_VARIABLES.y]}}var ab=" · ",_r=2,pt=(e,t,r,n)=>{const a=Math.abs(e==="radial"?Math.sin(t):Math.cos(t)),i=Math.abs(e==="radial"?Math.cos(t):Math.sin(t));return a*(r/2)+i*(n/2)},ib=({wedge:e,labelRadius:t,labelAngle:r,labelWidth:n,labelHeight:a})=>{const i=pt("radial",r,n,a);if(!(t-i>=e.innerRadiusPx-_r&&t+i<=e.outerRadiusPx+_r)||t<=0)return!1;const o=Math.abs(e.endAngle-e.startAngle)/2,s=pt("tangential",r,n,a)/t,c=_r/t;return Math.abs(r-e.midAngle)+s<=o+c},ob=({x:e,y:t,labelWidth:r,labelHeight:n,panelRect:a})=>e-r/2>=0&&e+r/2<=a.width&&t-n/2>=0&&t+n/2<=a.height,Ii=({wedge:e,position:t,offset:r,labelWidth:n,labelHeight:a})=>t==="inside"?{labelRadius:(e.innerRadiusPx+e.outerRadiusPx)/2,labelAngle:e.midAngle,position:"inside"}:{labelRadius:e.outerRadiusPx+r+pt("radial",e.midAngle,n,a),labelAngle:e.midAngle,position:"outside"},sb=({wedge:e,placement:t,justify:r,align:n,offset:a,labelWidth:i,labelHeight:o})=>{const s=n==="start"?e.startAngle:n==="end"?e.endAngle:e.midAngle,c=a+pt("radial",s,i,o);let u;if(r==="center")u=(e.innerRadiusPx+e.outerRadiusPx)/2;else if(r==="end")u=t==="inside"?e.outerRadiusPx-c:e.outerRadiusPx+c;else if(t==="inside")u=e.innerRadiusPx+c;else{const m=e.innerRadiusPx-c;u=m>=0?m:e.innerRadiusPx+c}let d=s;if(n!=="center"&&u>0){const m=pt("tangential",s,i,o)/u;d=s+(n==="start"?1:-1)*m}return{labelRadius:u,labelAngle:d,position:ib({wedge:e,labelRadius:u,labelAngle:d,labelWidth:i,labelHeight:o})?"inside":"outside"}},lb=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{position:r,justify:n,align:a,offset:i,showCategoryLabels:o}=e.layer.dataLabels,s=e.coordSystem.bandAxis==="y"?"inside":"outside",c=e.panelRect.width/2,u=e.panelRect.height/2,d=Math.min(e.panelRect.width,e.panelRect.height)/2,m=at().geomReaders(e.layer);for(const p of e.layer.data){const{startAngle:h,endAngle:f}=Jn(p),{innerRadius:g,outerRadius:v}=Qn(p);if(h===null||f===null||v===null)continue;const y=e.formatLabel(p);if(y==="")continue;const A=o?e.formatCategory(p):null,I=A===null?y:`${A}${ab}${y}`,x={startAngle:h,endAngle:f,midAngle:(h+f)/2,innerRadiusPx:(g??0)*d,outerRadiusPx:v*d};let T,E;if(r==="auto"){const L=e.measureDataLabel("observation",s,I);E={width:L.width,height:L.height},T=Ii({wedge:x,position:s,offset:i,labelWidth:E.width,labelHeight:E.height});const P=c+Math.sin(T.labelAngle)*T.labelRadius,k=u-Math.cos(T.labelAngle)*T.labelRadius;if(T.position==="outside"&&!ob({x:P,y:k,labelWidth:E.width,labelHeight:E.height,panelRect:e.panelRect})){const re=e.measureDataLabel("observation","inside",I);E={width:re.width,height:re.height},T=Ii({wedge:x,position:"inside",offset:i,labelWidth:E.width,labelHeight:E.height})}}else{const L=Xn(e.measureDataLabel,"observation",I),P=L[r];T=sb({wedge:x,placement:r,justify:jn(n),align:a,offset:i,labelWidth:P.width,labelHeight:P.height}),E=L[T.position]}const te=c+Math.sin(T.labelAngle)*T.labelRadius,Le=u-Math.cos(T.labelAngle)*T.labelRadius;t.push({layerId:e.layer.id,x:te,y:Le,text:I,width:E.width,height:E.height,isRotated:!1,role:"observation",position:T.position,...T.position==="inside"?{backdropColor:m.get("color",p)}:{}})}return{labels:t,droppedCount:0}},cb={place:lb,getPercentageValueStrategy:()=>"absoluteGrandTotal"},ub=e=>{const t=M({...e,valueFormat:e.valueFormat.fallback}),r={};for(const[a,i]of Object.entries(e.valueFormat.cases))r[a]=M({...e,valueFormat:i});const n=e.valueFormat.byVariable;return(a,i)=>{if(i===void 0||i[n]===void 0)return t(a);const o=l.getStableKey(i[n]),s=r[o];return s!==void 0?s(a,i):t(a)}},M=e=>{switch(e.valueFormat.type){case"currency":return tl(e);case"date":return Qy(e);case"datetime":return ev(e);case"day_month":return il(e);case"decimal":return rl(e);case"duration":return Fn(e);case"integer":return nl(e);case"month":return ol(e);case"month_year":return Un(e);case"percentage":return al(e);case"quarter":return Hn(e);case"text":return Bn(e);case"weekly_date_range":return sl(e);case"weekly_date_range_with_year":return ll(e);case"year":return zn(e);case"time":return cl(e);case"lookup":return ub({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function ea({layer:e,numberFormat:t,locale:r}){return M({valueFormat:Pm(e),locale:r,numberFormat:t})}var db=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:rt(e,t),variable:r}:{read:J,variable:l.GROUP_VARIABLES.group}},xl=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,formattingLocale:o,percentageValueStrategy:s})=>{const c=ea({layer:e,numberFormat:n,locale:o}),u=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,formatLabel:gb({layer:e,numberFormat:n,axes:r,locale:o,absoluteFormatter:c,percentageValueStrategy:s,isFlipped:u}),formatAbsolute:c,formatCategory:mb({layer:e,numberFormat:n,locale:o})}},mb=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=db(e.data,e.mapping),i=M({valueFormat:e.data.hasVariable(a)?e.data.getValueFormat(a):{type:"text"},locale:r,numberFormat:t});return o=>{const s=n(o);return s===null?null:i(s,o)}},pb=(e,t,r)=>{switch(t){case"stack":return hb(e);case"fill":return fb(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},hb=e=>{const t=l.readVariableName(e.mapping.x);let r=null,n=!1;return a=>{const i=e.summary.stackTotals;if(i===void 0||i.length===0||t===null)return null;if(!n){r=new Map;for(const c of i)r.set(c.xKey,c);n=!0}const o=a[t];if(o==null)return null;const s=r?.get(wn(a,t));return s===void 0?null:s.total}},fb=(e,t)=>{const r=t?z:B,n=t?W:_,a=bt(e);return i=>{const o=r(i),s=n(i);if(!l.isStrictNumericDataValue(o)||!l.isStrictNumericDataValue(s))return null;const c=Math.abs(s-o);if(c===0)return null;const u=a(i);return l.isStrictNumericDataValue(u)?u/c:null}},gb=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=j(e.data,e.dataLabels.labelSource),c=pb(e,i,o),u=yb({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),d=M({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),m=e.dataLabels.format==="percentage"&&Il(e);return p=>{const h=s(p);if(h===null)return"";if(!m||!l.isStrictNumericDataValue(h))return u(h,p);const f=c(p);return f===null||f===0?u(h,p):d(h/f)}},yb=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Il(e))return a;const s=vb(e,r,t,n,o);if(s!==null)return s}return M({valueFormat:bb(e.data,i),locale:n,numberFormat:t})},Il=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(vt(e.position,e.mapping))},vb=(e,t,r,n,a)=>{const i=l.readVariableName(e.mapping.x);if(i===null||i!==a)return null;const o=t.find(s=>s.scaleAestheticKey==="x");return o===void 0?null:M({valueFormat:o.valueFormat,locale:n,numberFormat:r})},bb=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return l.isNumericDataValue(r)?{type:"decimal"}:l.isTemporalDataValue(r)?{type:"date"}:{type:"text"};const n=l.readVariableName(t);return n===null||!e.hasVariable(n)?{type:"text"}:e.getValueFormat(n)},ta={bar:{cartesian:Bv,polar:cb},line:{cartesian:Zv},point:{cartesian:eb},area:{cartesian:Ev},tile:{cartesian:nb}},Sb=(e,t)=>ta[e]?.[t]!==void 0,Ab=({layers:e,coordSystem:t,axes:r,numberFormat:n,parsingLocale:a,panelRect:i,measureDataLabel:o,formattingLocale:s,plotBottomY:c,isFooterChromeReserved:u})=>{const d=[],m=s??a,p=t.type;let h=0;for(const f of e){if(!f.dataLabels.showDataLabels&&!f.dataLabels.showStackTotals&&!f.dataLabels.showCategoryLabels)continue;const g=f.geom,v=ta[g]?.[p];if(v===void 0)continue;const y=xl({layer:f,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,formattingLocale:m,percentageValueStrategy:v.getPercentageValueStrategy(f)}),A=v.place(y);h+=A.droppedCount;for(const I of A.labels)Ib(I,p,c,u)||d.push(I)}return{labels:d,warnings:h>0?[xb(h)]:[]}},xb=e=>({code:"DATA_LABELS_DROPPED",severity:"warning",kind:"user-input",message:e===1?"Dropped 1 data label that did not fit under position 'auto'.":`Dropped ${e} data labels that did not fit under position 'auto'.`,suggestion:"Set dataLabels.position to 'outside' to keep labels that do not fit inside the bars.",context:{actual:e}}),Ib=(e,t,r,n)=>t==="polar"&&n&&e.position==="outside"&&e.y+e.height/2>r;function*Tb({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,locale:o}){if(!(t.type!=="cartesian"||a.width<=0||a.height<=0))for(const s of e){if(!s.dataLabels.showDataLabels&&!s.dataLabels.showStackTotals)continue;const c=ta[s.geom]?.cartesian;if(c===void 0)continue;const u=xl({layer:s,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,formattingLocale:o,percentageValueStrategy:c.getPercentageValueStrategy(s)});for(const d of c.place(u).labels)yield{x:a.x+d.x-d.width/2,y:a.y+d.y-d.height/2,width:d.width,height:d.height}}}var kr={abbreviation:"none",decimals:"auto"},Tl=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":return M({valueFormat:a,locale:e,numberFormat:kr,intlOptions:{signDisplay:"always"}})(n-r);case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/r;return o===Number.POSITIVE_INFINITY?"∞":o===Number.NEGATIVE_INFINITY?"-∞":M({valueFormat:{type:"percentage"},locale:e,numberFormat:kr,intlOptions:{signDisplay:"always"}})(o)}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${M({valueFormat:{type:"decimal"},locale:e,numberFormat:kr,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Lb=2,Eb=6,wb=6,Rb=15,Cb=15,Vb=2.5,Mb=.5,Db=.25,Ll=e=>{const t=e-Lb,r=1+Mb*t,n=1+Db*t;return{arrowStartGap:Eb*r,arrowEndGap:wb*r,offsetFromHigherObservation:Rb*n,arrowheadSize:Vb*e,curveRadius:Cb*n,strokeWidth:e}},Pb=(e,t,r,n)=>{const a=n.offsetFromHigherObservation+n.arrowheadSize+n.arrowEndGap;return e?Math.max(t.x,r.x)+a:Math.min(t.y,r.y)-a},Ob=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x,y:e.y-n},s={x:e.x,y:r},c={x:t.x,y:r},u={x:t.x,y:t.y-a},d=t.x>e.x?1:-1;return`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var im=Object.create,Ro=Object.defineProperty,om=Object.getOwnPropertyDescriptor,sm=Object.getOwnPropertyNames,lm=Object.getPrototypeOf,cm=Object.prototype.hasOwnProperty,um=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=sm(t),i=0,o=a.length,s;i<o;i++)s=a[i],!cm.call(e,s)&&s!==r&&Ro(e,s,{get:(c=>t[c]).bind(null,s),enumerable:!(n=om(t,s))||n.enumerable});return e},sr=(e,t,r)=>(r=e!=null?im(lm(e)):{},um(t||!e||!e.__esModule?Ro(r,"default",{value:e,enumerable:!0}):r,e));const l=require("./config.types-Ca10IwFf.cjs");let Se=require("color2k"),Co=require("date-fns"),tt=require("lodash-es"),it=require("d3-time"),dm=require("date-fns/differenceInDays"),Ee=require("d3-regression"),ie=require("d3-scale"),ze=require("d3-interpolate"),N=require("d3-scale-chromatic"),Ye=require("lodash-es/clamp");Ye=sr(Ye,1);let qt=require("lodash-es/merge");qt=sr(qt,1);let zr=require("humanize-duration");zr=sr(zr,1);let je=require("d3-shape"),mm=require("d3-delaunay"),Xt=require("lodash-es/isEqual");Xt=sr(Xt,1);typeof window<"u"&&(window.__GRAPHY_SDK__??={},window.__GRAPHY_SDK__.vizEngine="1.9.0-beta.1789737596195");var pm=1e6;function Z(e){return String(Math.round(e*pm))}var ka="#FFFFFF",Mr="#1A1A1A",hm=4.5,Vo=e=>{try{return(0,Se.getContrast)(e,ka)>(0,Se.getContrast)(e,Mr)?ka:Mr}catch{return Mr}},fm=(e,t)=>{try{const r=Mo(void 0,t);return r===void 0||(0,Se.getContrast)(r,e)>=hm?e:Vo(r)}catch{return e}},Mo=(e,t)=>{try{if(e===void 0){const[,,,n]=(0,Se.parseToRgba)(t);return n>=1?t:void 0}const[,,,r]=(0,Se.parseToRgba)(e);return r>=1?e:(0,Se.parseToRgba)(t)[3]<1?void 0:(0,Se.mix)(t,(0,Se.opacify)(e,1),r)}catch{return}},oe=Math.PI*2,gm=8,ym=1e-9,vm=[0,Math.PI/2,Math.PI,oe*3/4],ut=(e,t)=>Math.abs(t-e)>=oe-ym,Ve=e=>(e%oe+oe)%oe,Zt=(e,t,r)=>{if(ut(t,r))return!0;const n=Ve(r-t);return Ve(e-t)<=n},qe=(e,t)=>{const r=Math.abs(Ve(e)-Ve(t));return Math.min(r,oe-r)},Na=(e,t)=>{const r=Ve(t-e);return r>Math.PI?r-oe:r},Do=(e,t,r)=>e*oe+t+r,se=(e,t)=>({x:t*Math.sin(e),y:t*Math.cos(e)}),we=(e,t)=>{const r=se(e,t);return{x:.5+r.x/2,y:.5+r.y/2}},bm=(e,t,r,n)=>{const a=[we(e,r),we(e,n),we(t,r),we(t,n)],i=Math.max(r,n),o=vm.filter(c=>Zt(c,e,t)).map(c=>we(c,i)),s=[...a,...o];return{xMin:Math.min(...s.map(c=>c.x)),xMax:Math.max(...s.map(c=>c.x)),yMin:Math.min(...s.map(c=>c.y)),yMax:Math.max(...s.map(c=>c.y))}},lr=(e,t)=>({angle:Ve(Math.atan2(e,t)),radius:Math.hypot(e,t)}),cr=(e,t)=>{const r=e.x-.5,n=e.y-.5;return{x:t>=1?r*2*t:r*2,y:t>=1?n*2:n*2/t}},pn=(e,t)=>{const{x:r,y:n}=cr(e,t);return lr(r,n)};function V(e){return e[l.POSITION_VARIABLES.x]}function R(e){return e[l.POSITION_VARIABLES.y]}function z(e){return e[l.POSITION_VARIABLES.xMin]}function W(e){return e[l.POSITION_VARIABLES.xMax]}function B(e){return e[l.POSITION_VARIABLES.yMin]}function _(e){return e[l.POSITION_VARIABLES.yMax]}function hn(e){return e[l.POSITION_VARIABLES.yRaw]}function Sm(e,t){return e[l.resolveScaledAestheticVariable(t)]}var Am={xMin:0,xMax:1,yMin:0,yMax:1},fn=(e,t)=>{const r=z(e)??V(e),n=W(e)??V(e),a=B(e)??R(e),i=_(e)??R(e);return!l.isStrictNumericDataValue(r)||!l.isStrictNumericDataValue(n)||!l.isStrictNumericDataValue(a)||!l.isStrictNumericDataValue(i)?null:t.type!=="polar"?{xMin:r,xMax:n,yMin:a,yMax:i}:{...bm(r,n,a,i),space:"disk"}},yt=(e,t)=>{const r=(e.xMin+e.xMax)/2,n=(e.yMin+e.yMax)/2;switch(t){case"top":return{x:r,y:e.yMax};case"bottom":return{x:r,y:e.yMin};case"left":return{x:e.xMin,y:n};case"right":return{x:e.xMax,y:n};case"top-left":return{x:e.xMin,y:e.yMax};case"top-right":return{x:e.xMax,y:e.yMax};case"bottom-left":return{x:e.xMin,y:e.yMin};case"bottom-right":return{x:e.xMax,y:e.yMin};default:return{x:r,y:n}}},Po=e=>yt(Am,e),j=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return()=>r;const n=l.readVariableName(t);return l.isDefined(n)?a=>{const i=a[n];return i===void 0?null:_o(i,e.getType(n))}:()=>null},xm=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return()=>r;const n=l.readVariableName(t);if(!l.isDefined(n)||!e.hasVariable(n))return()=>null;const a=e.getValues(n),i=e.getType(n);return o=>{const s=a[o];return s===void 0?null:_o(s,i)}},rt=(e,t)=>j(e,t.x),gn=(e,t)=>j(e,t.y),Im=(e,t)=>j(e,t.label),Oo=(e,t)=>j(e,t.color),Tm=(e,t)=>j(e,t.size),Lm=(e,t)=>j(e,t.alpha),Em=(e,t)=>j(e,t.group),wm=(e,t)=>j(e,t.strokeWidth),_o=(e,t)=>{switch(t){case"numeric":return l.isStrictNumericDataValue(e)?e:null;case"categorical":return l.isStrictCategoricalDataValue(e)?e:null;case"temporal":return l.isStrictTemporalDataValue(e)?e:null;default:return null}},Ba={variable:l.POSITION_VARIABLES.yRaw};function vt(e,t){return l.isStackedPosition(e)?Ba:t.y??Ba}function bt(e){return j(e.data,vt(e.position,e.mapping))}function Rm(e){return xm(e.data,vt(e.position,e.mapping))}var Pe=e=>{const t=l.readVariableName(e.mapping.x);return t!==null&&t!==l.CONSTANT_VARIABLES.x?t:l.GROUP_VARIABLES.group},yn=e=>Cm(e)?l.readVariableName(e.mapping.y):null,ko=e=>yn(e)===null?null:bt(e),vn=e=>e.spatialKind!=="cells",Cm=e=>e.spatialKind==="points"||e.spatialKind==="cells",No=(e,t)=>e.yScaleType===t.yScaleType&&Kr(e.valueFormat)===Kr(t.valueFormat),Wr=e=>`${e.yScaleType} y axis, ${Kr(e.valueFormat)}`,Kr=e=>e.type==="currency"?`${e.type}:${e.iso}`:e.type,Bo=(e,t)=>{const r=l.toExplicitValueFormat(e.data.getValueFormat(Pe(e))),n=yn(e);return a=>({...a,anchorValue:l.parseAddressingValue(a.anchorValue,r,t),...a.groupValue!==void 0&&{groupValue:l.parseAddressingValue(a.groupValue,l.toExplicitValueFormat(e.data.getValueFormat(l.GROUP_VARIABLES.group)),t)},...a.crossValue!==void 0&&n!==null&&{crossValue:l.parseAddressingValue(a.crossValue,l.toExplicitValueFormat(e.data.getValueFormat(n)),t)}})};function Fo(e){return e instanceof l.VizError?{severity:"error",kind:e.kind,code:e.code,message:e.message,...e.context!==void 0?{context:e.context}:{},...e.suggestion!==void 0?{suggestion:e.suggestion}:{}}:{severity:"error",kind:"internal",code:"INTERNAL_INVARIANT",message:e instanceof Error?e.message:String(e)}}function C(e,t){return $o(e,t)}function w(e,t){for(const r of Object.keys(t)){const n=t[r];if(n!==void 0&&n!==e[r])return{...e,...t}}return e}function Go(e,t,r){if(e[t]===r)return e;const n=[...e];return n[t]=r,n}function Oe(e,t){let r=null;for(const[n,a]of e.entries()){const i=t(a,n);if(i===a){r?.push(i);continue}r??=e.slice(0,n),r.push(i)}return r??e}function $o(e,t){let r=!1;const n={...e};for(const[a,i]of Object.entries(t)){const o=e[a];if(l.isPlainObject(i)&&l.isPlainObject(o)){const s=$o(o,i);s!==o&&(n[a]=s,r=!0)}else i!==void 0&&i!==o&&(n[a]=i,r=!0)}return r?n:e}function ur(e){return{pipe:t=>{const r=t(e);return ur({...e,...r})},result:()=>e}}var Vm=(e,t)=>{if(!l.isLookupValueFormat(e))return e;const r=t[e.byVariable];return r===void 0?e.fallback:e.cases[l.getStableKey(r)]??e.fallback},bn=e=>e.type==="polar"?"disk":"panel",dr=(e,t)=>{if(e!=="disk")return{x:0,y:0,width:t.width,height:t.height};const r=Math.min(t.width,t.height);return{x:(t.width-r)/2,y:(t.height-r)/2,width:r,height:r}},Fa=(e,t)=>{if(e.space!=="disk")return{x:e.x,y:e.y};if(t.width<=0||t.height<=0)return{x:0,y:0};const r=dr(e.space,t),n=r.y+(1-e.y)*r.height;return{x:(r.x+e.x*r.width)/t.width,y:1-n/t.height}};function K(e,t){return e==="x"?t.x:t.y}function ye(e,t){return e==="x"?t.y:t.x}function Xe(e,t){return{main:K(e,t),cross:ye(e,t)}}function Ga(e,t){return e==="x"?{x:t.main,y:t.cross}:{x:t.cross,y:t.main}}function Mm(e){return e.type==="cartesian"}var J=e=>e[l.GROUP_VARIABLES.group],St=e=>{const t=Pe(e),r=ko(e),n=vn(e)&&t!==l.GROUP_VARIABLES.group;return a=>{const i=a[t]??null;if(i===null)return null;const o=r===null?null:r(a);if(r!==null&&o===null)return null;const s=n?J(a)??null:null;return{layerId:e.id,anchorValue:i,...o!==null&&{crossValue:o},...s!==null&&{groupValue:s}}}},Ze=(e,t)=>e>=0&&e<=1&&t>=0&&t<=1,Dm={type:"decimal"};function Uo(e){return e.length>0&&e.every(t=>t.data.size()===0)}function Sn(e,t){return t!==null&&e.data.hasVariable(t)?e.data.getValueFormat(t):Dm}function Pm(e){return Sn(e,l.readVariableName(e.mapping.y))}function Ho({geom:e,position:t,mapping:r,purpose:n}){return e.resolveValueSource?.(r,n)??vt(t,r)}function zo(e,t){const r=Ho({geom:t,position:e.position,mapping:e.mapping,purpose:"measurement"}),n=l.readVariableName(r),a=n===l.POSITION_VARIABLES.yRaw?l.readVariableName(e.mapping.y):n;return{read:j(e.data,r),valueFormat:Sn(e,a)}}var Wo=e=>{const t=Pe(e),r=ko(e),n=vn(e);return(a,i)=>!l.areDataValuesEqual(a[t]??null,i.anchorValue)||!(r===null||i.crossValue===void 0||l.areDataValuesEqual(r(a),i.crossValue))?!1:!n||i.groupValue===void 0?!0:l.areDataValuesEqual(J(a),i.groupValue)},Ko=e=>{const t=l.readVariableName(e.mapping.y),r=bt(e);return(n,a)=>t!==null&&a===t?r(n):n[a]??null},Om=e=>t=>{if(t===l.readVariableName(e.mapping.y))return Rm(e);const r=e.data.hasVariable(t)?e.data.getValues(t):null;return n=>r?.[n]??null};var _m=["lt","lte","gt","gte","range"],km={highlight:{subject:"Highlight predicate",effect:"dropping this highlight"},"selection-anchor":{subject:"Selection anchor predicate",effect:"dropping this annotation"},"style-rule":{subject:"Style rule predicate",effect:"dropping this rule"}},ge=()=>!1,Be=()=>!0;function nt(e,t){const r=Ko(e);return{...Yo(e,t),createValueReader:n=>a=>r(a,n)}}function Nm(e,t){return{...Yo(e,t),createValueReader:Om(e)}}function le(e,t){if("and"in e){const r=e.and.map(n=>le(n,t)).filter(n=>n!==Be);return r.includes(ge)?ge:r.length===0?Be:n=>{for(const a of r)if(!a(n))return!1;return!0}}if("or"in e){const r=e.or.map(n=>le(n,t)).filter(n=>n!==ge);return r.includes(Be)?Be:r.length===0?ge:n=>{for(const a of r)if(a(n))return!0;return!1}}if("not"in e){const r=le(e.not,t);return r===ge?Be:r===Be?ge:n=>!r(n)}return Fm(e,t)}function ce(e,t,r="highlight"){return"and"in e?e.and.flatMap(n=>ce(n,t,r)):"or"in e?e.or.flatMap(n=>ce(n,t,r)):"not"in e?ce(e.not,t,r):Bm(e,t,r)}function Yo(e,t){return{hasVariable:r=>e.data.hasVariable(r),getType:r=>e.data.getType(r),getValueFormat:r=>e.data.getValueFormat(r),parsingLocale:t}}function Bm(e,t,r){const{subject:n,effect:a}=km[r];if(!t.hasVariable(e.variable))return[{code:"UNKNOWN_VARIABLE",message:`${n} references unknown variable '${e.variable}' — ${a}.`,context:{variableName:e.variable},suggestion:`Map '${e.variable}' in the layer or correct the variable name in the predicate.`}];const i=Gm(e);return i!==null&&t.getType(e.variable)==="categorical"?[{code:"INVALID_PREDICATE_OPERATOR",message:`${n} uses ordering operator '${i}' on categorical variable '${e.variable}' — ${a}. Use 'eq' or 'oneOf' instead.`,context:{variableName:e.variable},suggestion:"Use 'eq' or 'oneOf' for categorical variables."}]:[]}function Fm(e,t){if(!t.hasVariable(e.variable))return ge;const r=t.createValueReader(e.variable),n=l.toExplicitValueFormat(t.getValueFormat(e.variable)),a=i=>l.parseAddressingValue(i,n,t.parsingLocale);if("eq"in e){const i=a(e.eq);return o=>l.areDataValuesEqual(r(o),i)}if("oneOf"in e){const i=e.oneOf.map(a);if(i.length>=32){const o=new Set,s=new Set;for(const c of i)l.isStrictTemporalDataValue(c)?s.add(c.getTime()):o.add(c);return c=>{const u=r(c);return l.isStrictTemporalDataValue(u)?s.has(u.getTime()):!Number.isNaN(u)&&o.has(u)}}return o=>{const s=r(o);for(const c of i)if(l.areDataValuesEqual(s,c))return!0;return!1}}if("lt"in e){const i=a(e.lt);return o=>Fe(r(o),i)==="less"}if("lte"in e){const i=a(e.lte);return o=>{const s=Fe(r(o),i);return s==="less"||s==="equal"}}if("gt"in e){const i=a(e.gt);return o=>Fe(r(o),i)==="greater"}if("gte"in e){const i=a(e.gte);return o=>{const s=Fe(r(o),i);return s==="greater"||s==="equal"}}if("range"in e){const[i,o]=e.range,s=a(i),c=a(o);return u=>{const d=r(u),m=Fe(d,s),p=Fe(d,c);return m==="incomparable"||p==="incomparable"?!1:(m==="greater"||m==="equal")&&(p==="less"||p==="equal")}}return ge}function Gm(e){for(const t of _m)if(t in e)return t;return null}function Fe(e,t){if(e===null||t===null)return"incomparable";if(l.isStrictTemporalDataValue(e)&&l.isStrictTemporalDataValue(t)){const r=e.getTime(),n=t.getTime();return r<n?"less":r>n?"greater":"equal"}return l.isStrictNumericDataValue(e)&&l.isStrictNumericDataValue(t)?e<t?"less":e>t?"greater":"equal":"incomparable"}var $m=(e,t,r,n,a,i)=>{const o=qo(e,t,r.predicate,n,a,i);if(o===null)return null;const s=jo(r.padding),c=s===null?zm(o,r.padding):o,u={x:c.xMin,y:c.yMin,width:Math.max(0,c.xMax-c.xMin),height:Math.max(0,c.yMax-c.yMin),space:c.space};return s===null?u:{...u,defer:s}},Um=(e,t,r,n,a,i)=>{const o=qo(e,t,r.predicate,n,a,i);return o===null?null:{...yt(o,r.align),space:o.space}},jo=e=>e===void 0||typeof e=="number"||e.unit!=="px"?null:{type:"px-offset",x:e.x??0,y:e.y??0},qo=(e,t,r,n,a,i)=>{if(t.has(r))return t.get(r)??null;let o=null,s=!1;const c=new Map;for(const u of n){if(!u.interactive)continue;const d=ce(r,u.data,"selection-anchor");if(d.length>0){for(const p of d)c.set(`${p.code}:${p.message}`,p);continue}s=!0;const m=le(r,nt(u,i));if(m!==ge)for(const p of u.data){if(!m(p))continue;const h=fn(p,a);h!==null&&(o=o===null?h:Hm(o,h))}}if(!s)for(const u of c.values())e.diagnostics.addWarning(u);return t.set(r,o),o},Hm=(e,t)=>({space:e.space,xMin:Math.min(e.xMin,t.xMin),xMax:Math.max(e.xMax,t.xMax),yMin:Math.min(e.yMin,t.yMin),yMax:Math.max(e.yMax,t.yMax)}),zm=(e,t)=>{if(t===void 0)return e;const{x:r=0,y:n=0}=typeof t=="number"?{x:t,y:t}:t;return{...e,xMin:e.xMin-r,xMax:e.xMax+r,yMin:e.yMin-n,yMax:e.yMax+n}},Jt=(e,t,r)=>{const n=Km(e,t,r);return n===null?null:n.defer?.type==="annotation-ref"?n:Ym(n,t.offset,e.coordSystem)},Xo=(e,t)=>t.anchorType==="selection"?$m(e.container,e.selectionBoxCache,t,e.layers,e.coordSystem,e.parsingLocale):t.anchorType==="annotation"?{x:0,y:0,width:0,height:0,defer:{type:"annotation-ref",ref:t.ref,align:"center"}}:{x:t.x,y:1-t.y-t.height,width:t.width,height:t.height},An=(e,t,r)=>Yr(e,t,r)?.point??null,Yr=({container:e,layers:t,coordSystem:r,parsingLocale:n},a,i)=>{for(const o of t){const s=e.geomRegistry.get(o.geom),{resolveAnchorPosition:c}=s;if(c===void 0||a.layerId!==void 0&&o.id!==a.layerId||a.layerId===void 0&&!o.interactive)continue;const u=zo(o,s),d=Wo(o),m=St(o),p=Bo(o,n)(a);let h=-1;for(const f of o.data){if(h+=1,!d(f,p))continue;const g=c(f,{coordSystem:r,position:o.position,purpose:i,align:a.align});if(g===null)continue;const v=Zo(o,f,u);if(v===null)continue;const y=m(f);if(y!==null)return{point:{...g,...v,space:bn(r),observationIndex:h,anchor:a.align===void 0?y:{...y,align:a.align}},layerId:o.id}}}return null},Wm=(e,t)=>{const{layers:r,coordSystem:n,scales:a,parsingLocale:i}=e;if(n.type!=="cartesian")return null;const o=a.x,s=a.y;if(o===void 0||s===void 0||o.kind!=="position"||s.kind!=="position")return null;const c=Ua(t.x,"x",r,i),u=Ua(t.y,"y",r,i);if(c===null||u===null)return null;const d=o.map(c),m=s.map(u);if(!Ze(d,m))return null;const p=$a(d,o,jm(e)),h=$a(m,s),f=Ga(n.mainAxis,{main:p.min,cross:h.min}),g=Ga(n.mainAxis,{main:p.max,cross:h.max});return yt({xMin:f.x,xMax:g.x,yMin:f.y,yMax:g.y},t.align??"center")},Zo=(e,t,r)=>{const n=r.read(t);return l.isStrictNumericDataValue(n)?{geom:e.geom,measurementValue:n,valueFormat:Vm(r.valueFormat,t),yScaleType:e.yScaleType}:null},Km=(e,t,r)=>{switch(t.anchorType){case"panel":return{x:t.x,y:1-t.y};case"axis":return Wm(e,t);case"selection":return Um(e.container,e.selectionBoxCache,t,e.layers,e.coordSystem,e.parsingLocale);case"annotation":return{x:0,y:0,defer:{type:"annotation-ref",ref:t.ref,align:t.align??"center",offset:t.offset}};case"observation":return An(e,qm(t),r)}},Ym=(e,t,r)=>{if(t===void 0||r.type==="polar")return e;const n=jo(t);return n!==null?{...e,defer:n}:{...e,x:e.x+(t.x??0),y:e.y-(t.y??0)}},$a=(e,t,r=1)=>{const{bandwidth:n}=t;if(n===null||n<=0)return{min:e,max:e};const a=n*r/2;return{min:e-a,max:e+a}},jm=({container:e,layers:t,coordSystem:r})=>{let n=0;for(const a of t){const i=e.geomRegistry.get(a.geom).resolveBandFraction?.(a.params,r);i!==void 0&&(n=Math.max(n,i))}return n>0?n:1},qm=e=>({layerId:e.layerId,anchorValue:e.anchorValue,groupValue:e.groupValue,crossValue:e.crossValue,align:e.align}),Ua=(e,t,r,n)=>{for(const a of r){const i=l.readVariableName(a.mapping[t]);if(!(i===null||i===l.CONSTANT_VARIABLES.x))return l.parseAddressingValue(e,l.toExplicitValueFormat(a.data.getValueFormat(i)),n)}return e},Xm=class extends l.Stage{constructor(e){super(),this.container=e}dependencies(e){return[e.annotations,e.layers,e.coordSystem,e.scales.x,e.scales.y,e.config.parsingLocale]}run(e){const{annotations:t,layers:r,coordSystem:n,scales:a,config:i}=e,o={container:this.container,layers:r,coordSystem:n,scales:a,selectionBoxCache:new Map,parsingLocale:i.parsingLocale},s={differenceArrows:sp(o,t.differenceArrows),shapes:ep(o,t.shapes),arrows:rp(o,t.arrows),textAnnotations:np(o,t.textAnnotations),images:tp(o,t.images),stickers:ap(o,t.stickers),pinnedNumbers:ip(o,t.pinnedNumbers),comments:op(o,t.comments)};return Zm(this.container,s),Jm(this.container,s),s}},ue=(e,t,r,n)=>{e.diagnostics.addWarning({code:"ANNOTATION_ANCHOR_UNRESOLVED",message:`Annotation "${r}" (${t}) ${n} — dropping this annotation.`,context:{annotationId:r,kind:t},suggestion:"Check that the anchor points at data, an axis value or a panel position that exists."})},Zm=(e,t)=>{const r=new Set;for(const n of Object.values(t))for(const{id:a}of n){if(r.has(a)){e.diagnostics.addWarning({code:"ANNOTATION_DUPLICATE_ID",message:`More than one annotation carries id "${a}" — references to it resolve to the first, and the rest cannot be addressed.`,context:{annotationId:a},suggestion:"Give each annotation its own id."});continue}r.add(a)}},Jm=(e,t)=>{const r=new Set;for(const n of Object.values(t))for(const a of n)r.add(a.id);for(const{id:n,ref:a}of Qm(t))r.has(a)||e.diagnostics.addWarning({code:"ANNOTATION_REF_NOT_FOUND",message:`Annotation "${n}" references id "${a}", whose annotation could not be anchored and was dropped.`,context:{annotationId:n,ref:a},suggestion:"Fix the anchor on the target annotation or point this reference at one that resolves."})},Qm=e=>{const t=[],r=(n,a)=>{a.defer?.type==="annotation-ref"&&t.push({id:n,ref:a.defer.ref})};for(const n of e.shapes)r(n.id,n.region);for(const n of e.images)r(n.id,n.region);for(const n of e.arrows)r(n.id,n.start),r(n.id,n.end);for(const n of e.textAnnotations)r(n.id,n.at);for(const n of e.stickers)r(n.id,n.at);return t},ep=(e,t)=>{const r=[];for(const n of t){const a=Xo(e,n.region);if(a===null){ue(e.container,"shape",n.id,"has a region anchor that resolves to nothing");continue}r.push({id:n.id,kind:n.kind,zOrder:n.zOrder,region:a})}return r},tp=(e,t)=>{const r=[];for(const n of t){const a=Xo(e,n.region);if(a===null){ue(e.container,"image",n.id,"has a region anchor that resolves to nothing");continue}r.push({id:n.id,src:n.src,zOrder:n.zOrder,region:a,fit:n.fit})}return r},rp=(e,t)=>{const r=[];for(const n of t){const a=Jt(e,n.start,"pin"),i=Jt(e,n.end,"pin");if(a===null||i===null){ue(e.container,"arrow",n.id,`has ${Jo(a,i)} resolving to nothing`);continue}r.push({id:n.id,start:a,end:i,startArrowheadStyle:n.startArrowheadStyle,endArrowheadStyle:n.endArrowheadStyle})}return r},np=(e,t)=>{const r=[];for(const n of t){const a=Jt(e,n.at,"pin");if(a===null){ue(e.container,"text",n.id,"has a point anchor that resolves to nothing");continue}r.push({id:n.id,content:n.content,at:a,width:n.width,align:n.align})}return r},ap=(e,t)=>{const r=[];for(const n of t){const a=Jt(e,n.at,"pin");if(a===null){ue(e.container,"sticker",n.id,"has a point anchor that resolves to nothing");continue}r.push({id:n.id,at:a,sticker:n.sticker})}return r},ip=(e,t)=>{const r=[];for(const n of t){const a=An(e,n.at,"pin");if(a===null){ue(e.container,"pinnedNumber",n.id,"matches no observation");continue}r.push({id:n.id,at:a})}return r},op=(e,t)=>{const r=[];for(const n of t){const a=An(e,n.at,"pin");if(a===null){ue(e.container,"comment",n.id,"matches no observation");continue}r.push({id:n.id,at:a,content:n.content})}return r},sp=(e,t)=>{if(e.coordSystem.type!=="cartesian"){for(const n of t)ue(e.container,"differenceArrow",n.id,"needs a cartesian coord system");return[]}const r=[];for(const n of t){const a=Yr(e,n.start,"value"),i=Yr(e,n.end,"value");if(a===null||i===null){ue(e.container,"differenceArrow",n.id,`has ${Jo(a,i)} matching no observation`);continue}if(a.layerId===i.layerId&&a.point.observationIndex===i.point.observationIndex){ue(e.container,"differenceArrow",n.id,"has both ends on the same observation");continue}lp(e,n,a.point,i.point),r.push({id:n.id,start:a.point,end:i.point,label:n.label,labelCrossPosition:n.labelCrossPosition})}return r},Jo=(e,t)=>e===null&&t===null?"start and end anchors":e===null?"a start anchor":"an end anchor",lp=(e,t,r,n)=>{No(r,n)||e.container.diagnostics.addWarning({code:"INCOMPARABLE_ARROW_ENDPOINTS",message:`Difference arrow "${t.id}" measures between endpoints on different bases, so its label reports a quantity that does not exist.`,context:{annotationId:t.id,expected:Wr(r),actual:Wr(n)},suggestion:"Point both ends at observations sharing one y scale and one unit, or label the arrow as a proportion."})};function cp(e,t="kind"){const r=new Map;r.set(t,[]);for(const a of e)for(const i of a.observations)for(const o of Object.keys(i))r.has(o)||r.set(o,[]);for(const a of e)for(const i of a.observations)for(const[o,s]of r)s.push(o===t?a.kind:i[o]??null);const n={};for(const[a,i]of r)n[a]={type:Qo(i),values:i};return new l.Dataset(n)}function Qo(e){const t=Array.isArray(e)?e:[e];for(const r of t)if(r!==null)return typeof r=="number"?"numeric":r instanceof Date?"temporal":"categorical";return"categorical"}var up=class extends l.Stage{dependencies(e){return[e.data,e.mapping]}run(e){let t=e.data,r=e.mapping;r.x===""&&(t=t.addConstantVariable(l.CONSTANT_VARIABLES.x,"categorical",""),r={...r,x:l.CONSTANT_VARIABLES.x});for(const n of Object.keys(r)){const a=l.readConstantValue(r[n]);if(a===void 0)continue;const i=l.prefixInternalVariable(`const_${n}`);t=t.addConstantVariable(i,Qo(a),a),r={...r,[n]:i}}return{data:t,mapping:r}}},_e=class{constructor(){this.perLayerMemo=l.createPerKeyMemo(),this.listMemo=l.createSingleSlotMemo()}get stats(){return l.sumMemoStats(this.perLayerMemo.stats,this.listMemo.stats)}compile(e){const t=this.dependencies(e),r=e.layers.map(n=>this.perLayerMemo(n,t,()=>this.compileLayer(n,e)));return this.listMemo(r,()=>r)}},dp=class extends l.Stage{constructor(e){super(),this.registry=e}dependencies(e){return[e.coordSpec,e.scales,e.layers]}run(e){return this.registry.get(e.coordSpec.coordType).setup(e)}},mp=class extends _e{constructor(e){super(),this.registry=e}dependencies(e){return[e.coordSpec,e.coordSystem]}compileLayer(e,t){const[r]=this.registry.get(t.coordSpec.coordType).transform({coordSpec:t.coordSpec,coordSystem:t.coordSystem,layers:[e]});if(!r)throw new l.InternalError({message:`CoordCompiler: strategy '${t.coordSpec.coordType}' did not return a transformed layer`});return r}},pp=class{constructor(e){this.setupStage=new dp(e),this.transformStage=new mp(e)}get setupStats(){return this.setupStage.stats}get transformStats(){return this.transformStage.stats}setup(e){return this.setupStage.compile(e)}transform(e){return this.transformStage.compile(e)}},hp=class{constructor(){this.coordType="cartesian"}setup(e){if(e.coordSpec.coordType!=="cartesian")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});return{coordSystem:{type:"cartesian",mainAxis:"x",axisMapping:{x:{position:"bottom",geometry:"linear"},y:{position:"right",geometry:"linear"}}},scales:e.scales}}transform(e){return e.layers}},fp=class{constructor(){this.coordType="flip"}setup(e){if(e.coordSpec.coordType!=="flip")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});return{coordSystem:{type:"cartesian",mainAxis:"y",axisMapping:{x:{position:"left",geometry:"linear"},y:{position:"bottom",geometry:"linear"}}},scales:yp(e.scales,e.layers)}}transform(e){return e.layers.map(t=>bp(t))}},gp=[[l.POSITION_VARIABLES.x,l.POSITION_VARIABLES.y],[l.POSITION_VARIABLES.xMin,l.POSITION_VARIABLES.yMin],[l.POSITION_VARIABLES.xMax,l.POSITION_VARIABLES.yMax]],Ha=l.prefixInternalVariable("flipSwap"),yp=(e,t)=>vp(t)?e.map(r=>r.scaledAesthetic!=="x"||r.scaleType!=="continuous"&&r.scaleType!=="datetime"&&r.scaleType!=="discrete"?r:{...r,reverse:!r.reverse}):e,vp=e=>{for(const t of e){const r=l.readVariableName(t.mapping.x);if(!r||!t.data.hasVariable(r))continue;const n=t.data.getType(r);if(n==="categorical"||n==="temporal")return!0}return!1},bp=e=>{let t=e.data;for(const[r,n]of gp){const a=t.hasVariable(r),i=t.hasVariable(n);a&&i?t=t.renameVariable(r,Ha).renameVariable(n,r).renameVariable(Ha,n):a?t=t.renameVariable(r,n):i&&(t=t.renameVariable(n,r))}return{...e,data:t}};function es(e){const t=new Set,r=[];for(const n of e){const a=n instanceof Date?n.getTime():String(n);t.has(a)||(t.add(a),r.push(n))}return r}var ts=(e,t)=>es(t.domain!==null&&t.domain.length>0?t.domain:e),Sp=class{constructor(){this.coordType="polar"}setup(e){if(e.coordSpec.coordType!=="polar")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});const{params:t}=e.coordSpec,r=t.startAngle*(Math.PI/180),n=Ip(t,e.scales,e.layers),a=Lp(t,e.scales,e.layers);return{coordSystem:{type:"polar",axisMapping:t.theta==="x"?{x:{position:"bottom",geometry:"circular"},y:{position:"left",geometry:"radial"}}:{x:{position:"left",geometry:"radial"},y:{position:"bottom",geometry:"circular"}},innerRadius:t.innerRadius,startAngle:r,spokeRotation:n,bandAxis:a},scales:e.scales}}transform(e){if(e.coordSpec.coordType!=="polar")throw new l.InternalError({message:`Invalid coordinate type: ${e.coordSpec.coordType}`});if(e.coordSystem.type!=="polar")throw new l.InternalError({message:"PolarCoord.transform received a non-polar coord system"});const{params:t}=e.coordSpec,{startAngle:r,spokeRotation:n}=e.coordSystem,a=xp(r,n),i=Ep(t);return e.layers.map(o=>wp(t.theta==="y"?Rp(o):o,a,i))}},Ap=[[l.POSITION_VARIABLES.x,l.POSITION_VARIABLES.y],[l.POSITION_VARIABLES.xMin,l.POSITION_VARIABLES.yMin],[l.POSITION_VARIABLES.xMax,l.POSITION_VARIABLES.yMax]];function xp(e,t){return r=>Do(r,e,t)}function Ip(e,t,r){const n=t.find(i=>i.scaledAesthetic===e.theta);if(n===void 0||n.scaleType!=="discrete")return 0;const a=Tp(n,e,r);return a===0?0:-Math.PI/a}function Tp(e,t,r){const n=[];for(const a of r){const i=l.readVariableName(a.mapping[t.theta]);if(!(i===null||!a.data.hasVariable(i)))for(const o of a.data.getValues(i))n.push(o)}return ts(n,e).length}function Lp(e,t,r){if(e.theta==="x")return"x";const n=t.find(i=>i.scaledAesthetic==="x")?.scaleType==="discrete",a=r.some(i=>i.position==="fill");return n&&!a?"y":null}function Ep(e){const{innerRadius:t}=e;return r=>t+r*(1-t)}function wp(e,t,r){let n=e.data;return n=Ge(n,l.POSITION_VARIABLES.x,t),n=Ge(n,l.POSITION_VARIABLES.xMin,t),n=Ge(n,l.POSITION_VARIABLES.xMax,t),n=Ge(n,l.POSITION_VARIABLES.y,r),n=Ge(n,l.POSITION_VARIABLES.yMin,r),n=Ge(n,l.POSITION_VARIABLES.yMax,r),{...e,data:n}}function Ge(e,t,r){if(!e.hasVariable(t))return e;const n=e.getValues(t,{type:"numeric"}).map(a=>a===null?null:r(a));return e.addVariable(t,"numeric",n)}function Rp(e){let t=e.data;for(const[r,n]of Ap){const a=t.hasVariable(r),i=t.hasVariable(n);if(!a&&!i)continue;const o=a?t.getValues(r):null,s=i?t.getValues(n):null;o&&(t=t.addVariable(n,"numeric",o)),s&&(t=t.addVariable(r,"numeric",s))}return{...e,data:t}}var Cp=class extends l.Registry{constructor(){super("coord"),this.register("cartesian",new hp),this.register("flip",new fp),this.register("polar",new Sp)}},rs=new Set(["min","max","scalar"]),Vp={x:{min:l.POSITION_VARIABLES.xMin,max:l.POSITION_VARIABLES.xMax},y:{min:l.POSITION_VARIABLES.yMin,max:l.POSITION_VARIABLES.yMax}};function Mp(e){const t=new Set;for(const r of e)r.role==="point"?t.add(r.axis):(r.role==="min"||r.role==="max")&&l.isDefined(r.aes)&&t.add(r.aes);return[...t]}function Dp(e){const t=new Set;for(const r of e)r.role==="point"&&t.add(r.axis),l.isDefined(r.aes)&&t.add(r.aes);return[...t]}function Pp(e,t,r){let n=e;for(const a of t){if(a.role!=="min"&&a.role!=="max"||!l.isDefined(a.aes))continue;const i=Vp[a.axis][a.role];if(n.hasVariable(i))continue;const o=l.readVariableName(r[a.aes]);!l.isDefined(o)||!n.hasVariable(o)||(n=n.addVariable(i,"numeric",n.getValues(o,{type:"numeric"})))}return n}var Op=class{constructor(e){this.container=e}compile(e,t){const r=this.container.geomRegistry.get(e),n=r.compile(t),a={...t.mapping,...n.mapping};return{...n,data:Pp(n.data,r.positionRoles,a)}}},_p=["x","y"],xn=new Set(["x","y","ySecondary"]),At=new Set(["color","size","alpha","strokeWidth","lineType"]),Ae=e=>xn.has(e),In=e=>At.has(e),ns=e=>Ae(e)||In(e);function xe(e){return e==="secondary"?"ySecondary":"y"}function as(e,t){return e==="y"?xe(t):"x"}function F(e){return e==="ySecondary"?"y":e}var pe=(e,t)=>{if(l.isDefined(t.group)){const a=l.readVariableName(t.group);if(a!==null)return[a]}const r=new Set([l.readVariableName(t.x),l.readVariableName(t.y)].filter(l.isDefined)),n=new Set;for(const a of At){const i=l.readVariableName(t[a]);l.isDefined(i)&&(r.has(i)||e.hasVariable(i)&&e.getType(i)==="categorical"&&n.add(i))}return[...n]},mr=(e,t)=>e.hasVariable(l.GROUP_VARIABLES.group)?e.getValues(l.GROUP_VARIABLES.group,{distinct:!0,skipNulls:!0}).length>1:pe(e,t).some(r=>e.getValues(r,{distinct:!0,skipNulls:!0}).length>1),kp=class{compute({data:e,mapping:t}){const r=pe(e,t);if(r.length===0)return{data:e.addConstantVariable(l.GROUP_VARIABLES.group,"categorical",null)};const n=e.size(),a=r.map(o=>e.getValues(o)),i=new Array(n);for(let o=0;o<n;o++)i[o]=l.getStableKey(a.map(s=>s[o]));return{data:e.addVariable(l.GROUP_VARIABLES.group,"categorical",i)}}},Np=e=>{if(e===void 0)return{};const t={};for(const r of e.columns)r.label!==void 0&&(t[r.key]=r.label);return t},Bp=(e,t,r)=>{const n=Me(t,"color");return n===null?{}:(e?.columns??[]).some(a=>a.key===n)?{}:r};function Me(e,t){const r=F(t);for(const n of is(t,e)){const a=l.readVariableName(n.mapping[r]);if(l.isDefined(a))return a}return null}var pr=(e,t)=>e===null?null:t[e]??e,Fp=(e,t)=>e===null?null:t[String(e)]??null,De=({layers:e,scaleType:t,variableName:r})=>{if(r===null)return Dr(t);for(const n of e){if(!n.data.hasVariable(r))continue;const a=n.data.getValueFormat(r),i=a.type==="lookup"?a.fallback:a;return $p(i,t)?i:Dr(t)}return Dr(t)},Gp=(e,t)=>t!=="y"&&t!=="ySecondary"?!1:is(t,e).some(r=>r.position==="fill");function is(e,t){return e==="ySecondary"?t.filter(r=>r.yScaleType==="secondary"):e==="y"?t.filter(r=>r.yScaleType==="primary"):t}var Dr=e=>{switch(e){case"continuous":return{type:"decimal"};case"datetime":return{type:"date"};case"discrete":case"palette":case"identity":return{type:"text"}}},$p=(e,t)=>{switch(t){case"continuous":return l.isNumericValueFormat(e);case"datetime":return l.isTemporalValueFormat(e);case"discrete":case"palette":case"identity":return!0}},Up=[{unit:"year",step:1e3},{unit:"year",step:100},{unit:"year",step:50},{unit:"year",step:20},{unit:"year",step:10},{unit:"year",step:5},{unit:"year",step:2},{unit:"year",step:1},{unit:"month",step:6},{unit:"month",step:3},{unit:"month",step:2},{unit:"month",step:1},{unit:"week",step:2},{unit:"week",step:1},{unit:"day",step:2},{unit:"day",step:1},{unit:"hour",step:12},{unit:"hour",step:6},{unit:"hour",step:3}],za={year:0,quarter:1,month:2,week:3,day:4,hour:5},$e=40,Hp=(e,t,r)=>{const n=r.unit==="quarter"?r.step*3:r.step;return Yp(r.unit).range(e,new Date(t.valueOf()+1),n)},zp=({unit:e,step:t,start:r,stop:n})=>{const a=(0,dm.differenceInDays)(n,r);switch(e){case"hour":return 24*a/t>$e;case"day":return a/t>$e;case"week":return a/(7*t)>$e;case"month":return a/(30*t)>$e;case"quarter":return a/(90*t)>$e;case"year":return a/(365*t)>$e}},Wp=(e,t)=>{const r=!l.isDateWithoutYearValueFormat(t);switch(e.unit){case"year":return r?{type:"year"}:{type:"month"};case"quarter":return{type:"quarter"};case"month":return r?{type:"month_year"}:{type:"month"};case"week":return r?{type:"weekly_date_range_with_year"}:{type:"weekly_date_range"};case"day":return r?{type:"date"}:{type:"day_month"};case"hour":return r?{type:"datetime"}:{type:"time"}}},Kp=(e,t)=>{const r=jp(t);return r===null?!1:za[e]>za[r]},Yp=e=>{switch(e){case"hour":return it.utcHour;case"day":return it.utcDay;case"week":return it.utcMonday;case"month":case"quarter":return it.utcMonth;case"year":return it.utcYear}},jp=e=>{switch(e.type){case"year":return"year";case"quarter":return"quarter";case"month_year":case"month":return"month";case"weekly_date_range":case"weekly_date_range_with_year":return"week";case"date":case"day_month":case"datetime":return"day";case"time":return"hour";default:return null}},os={left:"right",right:"left",top:"bottom",bottom:"top"},qp={x:!0,y:!0,ySecondary:!1},Xp=20,Wa=new Set(["top","bottom"]),Zp={type:"percentage"};function Jp(e,t){const{scales:r,config:n,layers:a,coordSystem:i,variableLabels:o,geomRegistry:s}=e;if(Uo(a))return[];if(i.type==="polar"&&i.bandAxis===null)return[];const c=th(s,a,i.type,n),u=new Set(t.map(p=>p.position)),d=nh(ss(n.axes.y.position,i.axisMapping.y.position),u),m=[];for(const p of xn){const h=r[p];if(!l.isDefined(h)||h.kind!=="position")continue;const f=Qp({scaleAestheticKey:p,scale:h,config:n,layers:a,axisMapping:i.axisMapping,resolvedYPosition:d,gridOverrides:c,variableLabels:o});m.push(f)}return m}function Qp(e){const{scaleAestheticKey:t,scale:r,config:n,layers:a,axisMapping:i,resolvedYPosition:o,gridOverrides:s,variableLabels:c}=e,{axisConfig:u,position:d,geometry:m}=rh(t,n,i,o),p=Me(a,t),h=Gp(a,t)?Zp:De({layers:a,scaleType:r.spec.scaleType,variableName:p});return{scaleAestheticKey:t,position:d,geometry:m,label:eh(u,p,c),isVisible:u.isVisible,tickCandidates:ih(r,h,u.ticks.mode),valueFormat:h,tickMode:u.ticks.mode,ticksVisible:u.ticks.isVisible,gridVisible:ah(u,s,t),scaleType:r.spec.scaleType,bandwidth:r.bandwidth??void 0}}function eh(e,t,r){return e.label?e.label:t?r[t]??null:null}function th(e,t,r,n){const a=t.flatMap(s=>{const c=e.get(s.geom).grid[r];return c?[c]:[]}),i=a.some(s=>s.hideGridX),o=a.some(s=>s.hideGridY);return{x:{gridVisible:Ka(i,n.axes.x.grid.isVisible)},y:{gridVisible:Ka(o,n.axes.y.grid.isVisible)}}}function Ka(e,t){if(e&&t===null)return!1}function rh(e,t,r,n){switch(e){case"x":return{axisConfig:t.axes[e],position:ss(t.axes[e].position,r[e].position),geometry:r.x.geometry};case"y":return{axisConfig:t.axes[e],position:n,geometry:r.y.geometry};case"ySecondary":{const a=os[n],i=(0,tt.merge)({isVisible:t.axes.y.isVisible,label:null,position:a,grid:t.axes.y.grid,ticks:t.axes.y.ticks},t.axes.ySecondary);return{axisConfig:i,position:i.position,geometry:r.y.geometry}}}}function ss(e,t){return Wa.has(e)===Wa.has(t)?e:t}function nh(e,t){return t.has(e)?os[e]:e}function ah(e,t,r){const{gridVisible:n}=r==="x"?t.x:t.y;return n??e.grid.isVisible??qp[r]}var ih=(e,t,r)=>{const n=e.spec.scaleType==="continuous"||e.spec.scaleType==="datetime";if(r==="edges"&&n){const a=sh(e);if(a)return[a]}if(e.spec.scaleType==="continuous"){const a=new Set,i=[];for(let o=1;o<=Xp;o++){const s=e.generateTicks({count:o}),c=l.getStableKey(s);a.has(c)||(a.add(c),i.push({ticks:s.map(u=>Je(e,u))}))}return i}return e.spec.scaleType==="datetime"?oh(e,t):[{ticks:e.generateTicks().map(a=>Je(e,a))}]},oh=(e,t)=>{const[r,n]=e.domain;if(!l.isStrictTemporalDataValue(r)||!l.isStrictTemporalDataValue(n))return[{ticks:e.generateTicks().map(s=>Je(e,s))}];const a=new Set,i=[],o=(s,c)=>{if(s.length===0)return;const u=l.getStableKey(s);a.has(u)||(a.add(u),i.push({ticks:s.map(d=>Je(e,d)),valueFormat:c}))};for(const s of Up)zp({...s,start:r,stop:n})||Kp(s.unit,t)||o(e.generateTicks({interval:s}),Wp(s,t));return o(e.generateTicks({atInputs:!0})),i.sort((s,c)=>s.ticks.length-c.ticks.length),i},sh=e=>{const{domain:t}=e,r=t[0],n=t.at(-1);return!l.isDefined(r)||!l.isDefined(n)||l.getStableKey([r])===l.getStableKey([n])?null:{ticks:[Je(e,r),Je(e,n)]}},Je=(e,t)=>({value:t,position:e.map(t)});function ls({scale:e,aesthetics:t,layers:r}){const n=lh({layers:r,aesthetics:t}),a=cs({layers:r,aesthetics:t});return e.domain.map(i=>({value:i,geom:n(i),owner:a(i)}))}function lh({layers:e,aesthetics:t}){const r=cs({layers:e,aesthetics:t}),n=e.find(i=>t.some(o=>l.isDefined(i.mapping[o]))),a=n?n.geom:"bar";return i=>{const o=r(i);return o?o.layer.geom:a}}function cs({layers:e,aesthetics:t,layerFilter:r}){const n=new Map;for(const[a,i]of e.entries()){if(r&&!r(i))continue;const o=t.find(c=>l.isDefined(i.mapping[c]));if(o===void 0)continue;const s=l.readVariableName(i.mapping[o]);if(!(s===null||!i.data.hasVariable(s)))for(const c of i.data.getValues(s,{distinct:!0})){const u=l.getStableKey(c);n.has(u)||n.set(u,{layer:i,layerIndex:a})}}return a=>n.get(l.getStableKey(a))}var Tn=e=>{if(e.kind==="identity")return!1;const t=e.spec.scaleType;return t!=="continuous"&&t!=="datetime"};function ch({scales:e,layers:t,valueLabels:r}){const n=e.color;if(n===void 0||!Tn(n))return[];if(!t.some(s=>l.isDefined(s.mapping.color)))return[];const a=Me(t,"color");if(us({colorVariableName:a,xVariableName:Me(t,"x"),mapsColorAcrossMultipleLayers:dh(t)>1,isMergedWithAnotherAesthetic:uh(e,t,a)}))return[];const i=n.spec.scaleType,o=t.findIndex(s=>l.isDefined(s.mapping.color));return ls({scale:n,aesthetics:["color"],layers:t}).map(({value:s,geom:c,owner:u})=>{const d=u?.layerIndex??o,m=t[d],p=m?l.readVariableName(m.mapping.color):null;return{value:s,color:String(n.map(s)),geom:c,layerIndex:d,valueFormat:De({layers:m?[m]:t,scaleType:i,variableName:p}),label:Fp(s,r)}})}var us=({colorVariableName:e,xVariableName:t,mapsColorAcrossMultipleLayers:r,isMergedWithAnotherAesthetic:n})=>n?!1:e===null||l.isInternalVariable(e)?!r:t!==null&&e===t;function uh(e,t,r){if(r===null)return!1;for(const n of At){if(n==="color")continue;const a=e[n];if(!(a===void 0||!Tn(a))&&Me(t,n)===r)return!0}return!1}var dh=e=>e.filter(t=>l.isDefined(t.mapping.color)).length;function ds(e,t){return e.get(t.geom).summaries.perGroupHeadline===!0}function mh(e,t,r,n){const a=r.findIndex(i=>ds(e,i));return a===-1?[]:t.length<2?[{value:null,swatch:null,layerIndex:a,groupLabelFormat:{type:"text"},label:pr(l.readVariableName(r[a]?.mapping.y),n)}]:t.map(i=>({value:i.value,swatch:{color:i.color,geom:i.geom,layerId:r[i.layerIndex]?.id,value:i.value},layerIndex:i.layerIndex,groupLabelFormat:i.valueFormat,label:i.label}))}function Ya(e,t,r){if(r===null||t===null)return[...e];const n=l.getStableKey(r);return e.filter((a,i)=>l.getStableKey(t[i]??null)===n)}var ms=e=>e==="none"?"first":e,ph=(e,t)=>{switch(t){case"total":{const{sum:r,count:n}=ja(e);return n===0?null:r}case"average":{const{sum:r,count:n}=ja(e);return n===0?null:r/n}case"current":return e.at(-1)??null}},hh=(e,t)=>{if(e.length<2)return null;const r=e.at(-1),n=t==="previous"?e.at(-2):e.at(0);return r===void 0||n===void 0||r.cross===null||n.cross===null||n.cross===0?null:{variation:(r.cross-n.cross)/n.cross,against:n.main}},ja=e=>e.reduce((t,r)=>r===null?t:{sum:t.sum+r,count:t.count+1},{sum:0,count:0});function fh(e){const{config:t,coordSystem:r}=e,n=t.headline.show;return n==="none"||n==="conversion"?null:r.type==="polar"?gh(e,n):yh(e,n)}function gh(e,t){if(t!=="total")return null;const{scales:r,layers:n}=e,a=n.find(s=>s.summary.grandTotal!==void 0);if(a===void 0)return null;const i=a.summary.grandTotal;if(i===void 0)return null;const o=l.readVariableName(a.mapping.y);return o===null?null:{kind:"grandTotal",value:i,valueFormat:De({layers:[a],scaleType:r.y?.spec.scaleType??"continuous",variableName:o})}}function yh(e,t){const{config:r,scales:n,layers:a,variableLabels:i,colorGroups:o,geomRegistry:s}=e;if(!a.some(d=>ds(s,d)))return null;const c=mh(s,o,a,i);if(c.length===0)return null;const u=c.map(d=>vh({group:d,show:t,compareWith:r.headline.compareWith,layers:a,scales:n})).filter(d=>d!==null);return u.length===0?null:{kind:"perGroup",items:u}}function vh({group:e,show:t,compareWith:r,layers:n,scales:a}){const i=n[e.layerIndex];if(i===void 0)return null;const o=l.readVariableName(i.mapping.y);if(o===null||t==="total"&&i.position==="fill")return null;const s=l.readVariableName(i.mapping.x),c=l.readVariableName(i.mapping.color),u=i.yScaleType==="secondary"?a.ySecondary:a.y,d=De({layers:[i],scaleType:u?.spec.scaleType??"continuous",variableName:o}),m=Ah(i.data,s),p=De({layers:[i],scaleType:m?"datetime":a.x?.spec.scaleType??"discrete",variableName:s}),h=xh(i.data,s),f=h.getValues(o,{type:"numeric"}),g=s!==null?h.getValues(s):[],v=c!==null?h.getValues(c):null,y=Ya(f,v,e.value),A=Ya(g,v,e.value);return{value:e.value,swatch:e.swatch,aggregate:ph(y,t),valueFormat:d,groupLabelFormat:e.groupLabelFormat,mainValueFormat:p,label:e.label,caption:bh(t,m,A),comparison:Sh(t,r,m,A,y)}}function bh(e,t,r){if(e==="current"){const i=r.at(-1);return i===void 0?null:{kind:"point",value:i}}if(!t)return null;const n=r.at(0),a=r.at(-1);return n===void 0||a===void 0?null:{kind:"range",from:n,to:a}}function Sh(e,t,r,n,a){return e!=="current"||!r?null:hh(n.map((i,o)=>({main:i,cross:a[o]??null})),ms(t))}function Ah(e,t){return t!==null&&e.hasVariable(t)&&e.getType(t)==="temporal"}function xh(e,t){return t===null||!["numeric","temporal"].includes(e.getType(t))?e:e.orderBy(t)}function ee(e,...t){return e?t.includes(e.geom):!1}function O(e,t){return e.find(r=>r.id===t)}function Ie(e,...t){return e.find(r=>t.includes(r.geom))}function Ih(e,...t){return e.filter(r=>t.includes(r.geom))}function Ln(e,t){return e.interactive?!1:t.some(r=>r!==e&&l.areMappingsEquivalent(r.mapping,e.mapping))}function Th(e,t){return t.filter(r=>r!==e&&!r.interactive&&l.areMappingsEquivalent(e.mapping,r.mapping))}function En(e){const t=e.filter(r=>!Ln(r,e));return t.length>0?t:e}function ps({legendPosition:e,coordSystem:t,layers:r}){if(e!=="right"||t.type!=="cartesian"||t.mainAxis!=="x")return!1;const n=En(r);return n.length===1&&n[0]?.supportsDirectLabels===!0}var Lh=3;function Eh({scales:e,config:t,layers:r,coordSystem:n,variableLabels:a,colorGroups:i,geomRegistry:o}){if(t.legend.position==="none")return{drawn:[],position:"none"};const s=new Map(i.map(v=>[l.getStableKey(v.value),v])),c=Oh(Vh({scales:e,layers:r})),u=Me(r,"x"),d=c.map(v=>{if(Dh(v,u,r))return null;const y=kh({group:v,variableLabels:a,layers:r,colorGroupsByValue:s});return y.items.length===0?null:{group:v,built:y}}).filter(l.isDefined),m=wh(d),p=En(r),h=Uh(o,t.legend.position,m,p,n);if(d.length===0)return{drawn:[],position:h};if(t.legend.position==="auto"&&$h(o,m,p,n))return{drawn:[],position:h};const f=Hh(t.legend.display,{legendPosition:h,coordSystem:n,layers:r}),g=f==="direct"?Yh(p[0]):null;return{drawn:d.map(({built:v})=>Rh(v,{position:h,display:f,align:t.legend.align},g)),position:h}}function wh(e){return e.reduce((t,{group:r,built:n})=>t+(r.some(a=>a.guideType!=="discrete")?1:n.items.length),0)}function Rh(e,t,r){const{position:n,display:a}=t,i=Ch(t.align,n);return a!=="direct"||r===null?{...e,position:n,display:a,align:i}:{...e,position:n,display:a,align:i,items:e.items.map(o=>({...o,normalizedY:r.get(String(o.value))??null}))}}function Ch(e,t){return e!=="auto"?e:t==="top"||t==="bottom"?"start":"center"}function Vh(e){const{scales:t,layers:r}=e,n=[];for(const a of At){const i=t[a];if(i===void 0||i.kind==="identity"||!Mh(a,r))continue;const o=Me(r,a),s=Kh(a,i);n.push({scaleAestheticKey:a,scale:i,variableName:o,guideType:s})}return n}function Mh(e,t){const r=F(e);return t.some(n=>l.isDefined(n.mapping[r]))}function Dh(e,t,r){const[n]=e;return n.scaleAestheticKey!=="color"?!1:us({colorVariableName:n.variableName,xVariableName:t,mapsColorAcrossMultipleLayers:Ph(n.scaleAestheticKey,r),isMergedWithAnotherAesthetic:e.length>1})}function Ph(e,t){const r=F(e);return t.filter(n=>l.isDefined(n.mapping[r])).length>1}function Oh(e){const t=new Map;for(const r of e){const n=Wh(r),a=t.get(n);a?a.push(r):t.set(n,[r])}return[...t.values()]}function _h(e,t,r){if(t==="lineType"){e.lineType=r;return}if(t==="color"){e.color=String(r);return}e[t]=r}function kh({group:e,variableLabels:t,layers:r,colorGroupsByValue:n}){const a=e[0],i=e.map(u=>F(u.scaleAestheticKey)),o=ls({scale:a.scale,aesthetics:i,layers:r}),s=De({layers:r,scaleType:a.scale.spec.scaleType,variableName:a.variableName}),c=r.find(u=>i.some(d=>l.isDefined(u.mapping[d])))?.id;return{aesthetics:e.map(u=>u.scaleAestheticKey),title:pr(a.variableName,t),items:o.map(u=>Nh(u,e,i,s,n,c))}}function Nh(e,t,r,n,a,i){const o={};for(const c of t)_h(o,c.scaleAestheticKey,c.scale.map(e.value));if(o.color===void 0&&r.includes("size")&&(o.color=l.DEFAULT_GEOM_COLOR),o.lineType===void 0){const c=l.readConstantValue(e.owner?.layer.mapping.lineType);l.isLineType(c)&&(o.lineType=c)}const s=Fh(e,t,r,n,a);return{value:e.value,label:Bh(t,e,a),visual:o,normalizedY:null,geom:e.geom,valueFormat:s,layerId:e.owner?.layer.id??i}}function Bh(e,t,r){return e[0].scaleAestheticKey!=="color"?null:r.get(l.getStableKey(t.value))?.label??null}function Fh(e,t,r,n,a){if(t[0].scaleAestheticKey==="color")return a.get(l.getStableKey(e.value))?.valueFormat??n;const i=e.owner?.layer,o=Gh(i,r);return i===void 0||o===null?n:De({layers:[i],scaleType:t[0].scale.spec.scaleType,variableName:o})}function Gh(e,t){if(e===void 0)return null;for(const r of t){const n=e.mapping[r];if(n===void 0)continue;const a=l.readVariableName(n);if(a!==null)return a}return null}function $h(e,t,r,n){if(t>1)return!1;const a=n.type==="polar";return r.some(i=>e.get(i.geom).legend.suppressWhenSingleItem||a)}function Uh(e,t,r,n,a){if(t!=="auto")return t;if(a.type==="polar")return"top";let i=!1,o=!1,s=!1;for(const u of n){const{sidePlacement:d}=e.get(u.geom).legend;d==="whenCrowded"&&(i=!0),d==="whenStackedVertical"&&(o=!0,l.isStackedPosition(u.position)&&(s=!0))}const c=r>=Lh;return i&&o?"top":i?c?"right":"top":s?zh(a)?"top":c?"right":"top":"top"}function Hh(e,t){return e==="pill"?"pill":ps(t)?"direct":"pill"}function zh(e){return e.type==="cartesian"&&e.mainAxis==="y"}function Wh(e){const t=e.scale.domain.map(l.getStableKey);return JSON.stringify([e.variableName,e.guideType,...t])}function Kh(e,t){return Tn(t)?"discrete":`continuous:${e}`}function Yh(e){if(!e)return new Map;const t=new Map;return e.data.groupBy(l.GROUP_VARIABLES.group).forEach(r=>{const n=r.findLast(c=>l.isDefined(_(c))||l.isDefined(R(c)));if(!n)return;const a=J(n);if(!l.isDefined(a))return;const i=B(n),o=_(n)??R(n);if(!l.isDefined(o))return;const s=l.isDefined(i)?(i+o)/2:o;t.set(String(a),s)}),t}var jh=class extends l.Stage{constructor(e){super(),this.container=e}dependencies(e){return[e.scales,e.config.axes,e.config.legend,e.config.headline,e.layers,e.coordSystem,e.originalData]}run(e){const t=Np(e.originalData),r=ch({scales:e.scales,layers:e.layers,valueLabels:Bp(e.originalData,e.layers,t)}),n={scales:e.scales,config:e.config,layers:e.layers,coordSystem:e.coordSystem,variableLabels:t,colorGroups:r,geomRegistry:this.container.geomRegistry},a=fh(n),i=Eh(n),o={...i,drawn:qh(a,i.drawn)};return{axes:Jp(n,o.drawn),legends:o,headline:a,colorGroups:r,variableLabels:t}}},qh=(e,t)=>e?.kind!=="perGroup"||t.some(r=>r.display==="direct")?t:[],Qt=(e,t,r)=>{switch(e){case"series":return Xh(t);case"x-value":return wn(t,r)}},xt=e=>{const t=l.readMainAxisVariable(e);return t===""?null:t},Xh=e=>l.getStableKey([J(e)]),wn=(e,t)=>l.getStableKey([t!==null?e[t]??null:null]),Zh={bar:"observation-rerender",rule:null,line:"overlay-anchor",area:"overlay-anchor",point:"overlay-anchor",tile:"observation-rerender"};function hs(e){const t=Zh[e]??null;return t===null?null:{strategy:t,composition:fs()}}function fs(){return{isDimmed:!1,matchedLayer:null,overlayCandidates:[]}}var Jh=class extends _e{constructor(e){super(),this.container=e}dependencies(e){return[e.highlights,e.config.parsingLocale]}compileLayer(e,t){const r=e.highlight;if(r===null)return e;const n=t.highlights.filter(({layerId:i})=>i===void 0||i===e.id);if(n.length===0)return e;const a=Qh({layer:e,highlights:n,parsingLocale:t.config.parsingLocale,strategy:r.strategy,container:this.container});return{...e,highlight:{...r,composition:a}}}};function Qh({layer:e,highlights:t,parsingLocale:r,strategy:n,container:a}){const i=t.filter(L=>{const P=ce(L.predicate,e.data);for(const k of P)a.diagnostics.addWarning({...k,message:`${k.message} Dropping this highlight.`});return P.length===0}),o=xt(e.mapping),s=nt(e,r),c=i.map(L=>({predicate:le(L.predicate,s),scope:L.scope})),u=c.some(({scope:L})=>L==="series"),d=c.some(({scope:L})=>L==="x-value"),m=n==="overlay-anchor",p=e.data.size(),h=u?new Array(p):null,f=d?new Array(p):null,g=m?new Array(p):null,v=new Uint8Array(p),y=new Set,A=new Set;let I=!1,x=0;for(const L of e.data){let P,k;h!==null&&(P=Qt("series",L,o),h[x]=P),f!==null&&(k=Qt("x-value",L,o),f[x]=k),g!==null&&(g[x]=L);for(const{predicate:re,scope:Bt}of c)if(re(L))switch(Bt){case"series":P!==void 0&&y.add(P);break;case"x-value":k!==void 0&&A.add(k);break;case"data-point":v[x]=1,I=!0;break}x++}if(y.size===0&&A.size===0&&!I)return fs();const T=new Uint8Array(p),E=[];let te=0;for(let L=0;L<p;L++){const P=h?.[L],k=f?.[L],re=P!==void 0&&y.has(P),Bt=k!==void 0&&A.has(k),Oa=v[L]===1;if(n==="observation-rerender")(re||Oa||Bt)&&(T[L]=1,te++);else if(re)T[L]=1,te++;else if(Oa||Bt){const _a=g?.[L];_a!==void 0&&E.push({observation:_a,observationIndex:L})}}const Le=te>0?{...e,data:e.data.filterByMask(T)}:null;return{isDimmed:(n==="observation-rerender"||y.size>0)&&Le!==null,matchedLayer:Le,overlayCandidates:E}}var ef=l.prefixInternalVariable("__ungrouped__");function tf(e){const t=e.getVariableNames().filter(a=>e.getType(a)==="temporal"&&l.isDateWithoutYearValueFormat(e.getValueFormat(a)));if(t.length===0)return e;const r=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical"});let n=e;for(const a of t){const i=n.getValues(a,{type:"temporal"}),o=new Map,s=i.map((c,u)=>{if(c===null)return null;const d=r[u]??ef;let m=o.get(d);return m||(m=new l.ChronologicalDateManager,o.set(d,m)),m.incrementYearIfNeeded(c)});n=n.addVariable(a,"temporal",s)}return n}var rf=()=>({defaults:[],overrides:[],warnings:[]}),nf=class extends _e{constructor(e,t,r,n,a,i){super(),this.container=e,this.transformCompiler=t,this.statCompiler=r,this.groupCompiler=n,this.geomCompiler=a,this.positionAdjusterCompiler=i}dependencies(e){return[e.data,e.mapping,qa(e),e.coords.coordType]}compileLayer(e,t){return this.runLayerPipeline({layer:e,data:this.transformCompiler.compile({data:t.data,transforms:e.transforms}),effectiveMapping:{...t.mapping,...e.mapping},xScaleIsDiscrete:qa(t),coordType:t.coords.coordType})}runLayerPipeline({layer:e,data:t,effectiveMapping:r,xScaleIsDiscrete:n,coordType:a}){const i=ur({data:t,mapping:r}).pipe(({data:s,mapping:c})=>{const u=this.statCompiler.compute(e.stat,{data:s,mapping:c,xScaleIsDiscrete:n});return{data:u.data,mapping:{...c,...u.mapping}}}).pipe(({data:s,mapping:c})=>({data:this.groupCompiler.compute({data:s,mapping:c}).data,mapping:c})).pipe(({data:s,mapping:c})=>({data:tf(s),mapping:c})).pipe(({data:s,mapping:c})=>{const u=this.geomCompiler.compile(e.geom,{data:s,mapping:c,params:e.params,coordType:a});return{data:u.data,mapping:{...c,...u.mapping}}}).pipe(({data:s,mapping:c})=>{const u=this.positionAdjusterCompiler.adjust(e.position,{data:s,mapping:c});return{data:u.data,mapping:{...c,...u.mapping}}}).result(),o=this.container.geomRegistry.get(e.geom);return{...i,id:e.id,geom:e.geom,position:e.position,yScaleType:e.yScaleType,params:e.params,interactive:e.interactive,dataLabels:e.dataLabels,summary:{},spatialKind:o.spatialKind,identityKey:o.identityKey,tooltip:o.tooltip,supportsDirectLabels:o.legend.directLabelSupport?.[e.position]===!0,highlight:hs(e.geom),styles:rf()}}};function qa(e){return e.scales.some(t=>t.scaledAesthetic==="x"&&t.scaleType==="discrete")}function gs(e,t){const[r]=t;if(r){for(const n of t)e.addError(n);throw new l.UserInputError(r)}}function af(e,t){return t.some(r=>l.isStackedPosition(r.position)||e.get(r.geom).scaleConstraints?.bandPadding===0)}function jr(e,t){const r=ys(e,t),n={};for(const{layer:i,scaleConstraints:o,crossAxis:s}of r)o.zeroBaseline===!0&&(n[s]={nice:(n[s]?.nice??!0)&&i.position!=="fill"});const a=r.find(({scaleConstraints:i})=>i.discreteCrossAxis===!0);return{discreteAxis:r.some(({scaleConstraints:i})=>i.discreteMainAxis===!0)?"x":null,discreteCrossAxis:a?.crossAxis??null,bandedAxes:sf(r),zeroAxes:n,bandPadding:lf(r),inferredColor:r.some(({scaleConstraints:i})=>i.inferredColor===!0)}}function of(e,t){const r=ys(e,t);for(const n of r){if(n.scaleConstraints.discreteCrossAxis!==!0)continue;const a=r.find(i=>i.scaleConstraints.zeroBaseline===!0&&i.crossAxis===n.crossAxis);if(a!==void 0)return{crossAxis:n.crossAxis,banded:Xa(n),zeroAnchored:Xa(a)}}return null}var Xa=({layer:e,index:t})=>({layerId:e.id,layerIndex:t,geom:e.geom});function ys(e,t){const r=[];return t.forEach((n,a)=>{if(!e.has(n.geom))return;const{scaleConstraints:i}=e.get(n.geom);i!==void 0&&r.push({layer:n,index:a,scaleConstraints:i,crossAxis:xe(n.yScaleType)})}),r}function sf(e){const t=new Set;for(const{scaleConstraints:r,crossAxis:n}of e)r.discreteMainAxis===!0&&t.add("x"),r.discreteCrossAxis===!0&&t.add(n);return[...t]}function lf(e){const t={};for(const r of e){const n=r.scaleConstraints.bandPadding;if(n!==void 0)for(const a of cf(r)){const i=t[a];t[a]=i===void 0?n:Math.min(i,n)}}return t}function cf({scaleConstraints:e,crossAxis:t}){return e.discreteCrossAxis!==!0?["x"]:e.discreteMainAxis===!0?["x",t]:[t]}var uf=new Set(["label","group"]),df=class{constructor(e,t,r,n){this.container=e,this.transformCompiler=t,this.statRegistry=r,this.layerCompiler=n}get stats(){return this.layerCompiler.stats}compile(e){this.checkPreCompile(e);const t=this.layerCompiler.compile(e);return this.checkPostCompile(t),t}checkPreCompile(e){const t=[];e.layers.forEach((r,n)=>{const a=this.transformCompiler.compile({data:e.data,transforms:r.transforms}),i={...e.mapping,...r.mapping},o={layerId:r.id,layerIndex:n,geom:r.geom,position:r.position,stat:r.stat,effectiveMapping:i,data:a,coordType:e.coords.coordType,dataLabels:r.dataLabels};t.push(...this.validateLayer(o));const s=[...this.collectUndeclaredAesthetics(o),...this.collectPanelJustifyWarnings(o)];for(const c of s)this.container.diagnostics.addWarning(c)}),t.push(...this.validateSharedScaleDemands(e.layers)),gs(this.container.diagnostics,t)}checkPostCompile(e){Uo(e)&&this.container.diagnostics.addWarning({code:"EMPTY_DATASET",message:"No data to plot — every layer resolved to zero observations.",suggestion:"Check the dataset has rows and that transforms (filters, joins) are not removing them all."})}validateLayer(e){return[...this.validateRequiredAesthetics(e),...this.validateVariableExistence(e),...this.validatePositionalAestheticTypes(e),...this.validateGeomMapping(e),...this.validateCoordSupport(e),...this.validateSupportedPosition(e)]}collectPanelJustifyWarnings({geom:e,effectiveMapping:t,data:r,layerIndex:n,coordType:a,dataLabels:i}){const{justify:o,showDataLabels:s}=i;if(!s||o!=="panel-start"&&o!=="panel-end")return[];if(a==="polar"||!this.container.geomRegistry.get(e).isComposite)return[];if(!mr(r,t))return[];const c=o==="panel-end"?"end":"start";return[{code:"DATA_LABEL_PLACEMENT_COERCED",message:`Multiple ${e} groups would all pin their labels to the same panel edge; justify '${o}' will render as '${c}'.`,context:{layerIndex:n,expected:c,actual:o},suggestion:`Use justify '${c}' for this layer.`}]}validateRequiredAesthetics({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const i=[],{positionRoles:o,aesthetics:s}=this.container.geomRegistry.get(r),c=[...Mp(o),...s.filter(m=>m.required).map(m=>m.name)],{computedVariables:u}=this.statRegistry.get(n.type),d=u;for(const m of c)d.has(m)||l.isDefined(a[m])||i.push({code:"MISSING_AESTHETIC",message:`Layer '${e}': geom '${r}' requires aesthetic '${m}'`,context:{layerIndex:t,aesthetic:m}});return i}validateVariableExistence({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a,data:i}){const o=[],{computedVariables:s}=this.statRegistry.get(n.type),{derivedVariables:c}=this.container.geomRegistry.get(r),u=s,d=new Set(c);for(const[m,p]of Object.entries(a)){if(u.has(m))continue;const h=l.readVariableName(p);h===null||h===""||d.has(h)||i.hasVariable(h)||o.push({code:"UNKNOWN_VARIABLE",message:`Layer '${e}': aesthetic '${m}' references variable '${h}' which does not exist in the dataset`,context:{layerIndex:t,aesthetic:m,variableName:h}})}return o}validatePositionalAestheticTypes({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a,data:i}){const{positionRoles:o}=this.container.geomRegistry.get(r),{computedVariables:s}=this.statRegistry.get(n.type),c=s,u=[];for(const d of o){if(!rs.has(d.role)||!l.isDefined(d.aes)||c.has(d.aes)||d.role==="scalar"&&d.aes===d.axis)continue;const m=l.readVariableName(a[d.aes]);if(m===null||!i.hasVariable(m)||i.size()===0)continue;const p=i.getType(m);p!=="numeric"&&u.push({code:"INCOMPATIBLE_TYPE",message:`Layer '${e}': aesthetic '${d.aes}' must be numeric, but variable '${m}' is ${p}`,context:{layerIndex:t,aesthetic:d.aes,variableName:m,variableType:p},suggestion:this.suggestNumericAestheticFix(d.aes,d.axis,a,i)})}return u}suggestNumericAestheticFix(e,t,r,n){const a=t==="y"?"x":"y";if(e===t){const i=l.readVariableName(r[a]);if(i!==null&&n.hasVariable(i)&&n.getType(i)==="numeric")return`Swap the '${a}' and '${t}' mappings so the numeric variable is on '${t}'. Add coord.flip() to orient the graph horizontally.`}return`Map '${e}' to a numeric variable.`}validateGeomMapping({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const{validateMapping:i}=this.container.geomRegistry.get(r);if(i===void 0)return[];const{computedVariables:o}=this.statRegistry.get(n.type);return i({mapping:a,computedVariables:o}).map(s=>({...s,message:`Layer '${e}': ${s.message}`,context:{...s.context,layerIndex:t}}))}validateSharedScaleDemands(e){const t=of(this.container.geomRegistry,e);if(t===null)return[];const{crossAxis:r,banded:n,zeroAnchored:a}=t;return[{code:"CONFLICTING_SCALE_DEMANDS",message:`Layer '${n.layerId}' (geom '${n.geom}') needs '${r}' to be a band scale, but layer '${a.layerId}' (geom '${a.geom}') needs it to be a value axis anchored at zero. One scale cannot be both.`,context:{aesthetic:r,layerId:n.layerId,layerIndex:n.layerIndex},suggestion:"Drop one of the layers, or move one onto the secondary y axis with 'yScaleType'."}]}validateCoordSupport({layerId:e,layerIndex:t,geom:r,coordType:n}){const{supportedCoordTypes:a}=this.container.geomRegistry.get(r);return a.includes(n)?[]:[{code:"UNSUPPORTED_COORD",message:`Layer '${e}': geom '${r}' is not supported under ${n} coords`,context:{layerIndex:t}}]}validateSupportedPosition({layerId:e,layerIndex:t,geom:r,position:n}){const{supportedPositions:a}=this.container.geomRegistry.get(r);return a.includes(n)?[]:[{code:"UNSUPPORTED_POSITION",message:`Layer '${e}': geom '${r}' does not support the '${n}' position`,context:{layerIndex:t},suggestion:`Use one of: ${a.join(", ")}.`}]}collectUndeclaredAesthetics({layerId:e,layerIndex:t,geom:r,stat:n,effectiveMapping:a}){const{positionRoles:i,aesthetics:o}=this.container.geomRegistry.get(r),{computedVariables:s}=this.statRegistry.get(n.type),c=new Set([...Dp(i),...o.map(p=>p.name)]),u=uf,d=s,m=[];for(const p of Object.keys(a))l.isDefined(a[p])&&(c.has(p)||u.has(p)||d.has(p)||m.push({code:"UNDECLARED_AESTHETIC",message:`Layer '${e}': geom '${r}' does not declare aesthetic '${p}'; the mapping is ignored`,context:{layerIndex:t,aesthetic:p}}));return m}},ve=class{constructor(){this.positionRoles=[],this.identityKey="x-group",this.defaultPosition="identity",this.supportedPositions=l.POSITION_ADJUSTMENTS,this.defaultInteractive=!0,this.aesthetics=[],this.derivedVariables=[],this.highlightStrategy="overlay-anchor",this.supportedCoordTypes=["cartesian","flip"],this.spatialKind="points",this.grid={},this.legend={},this.dataLabelCoordTypes=[],this.isComposite=!1,this.tooltip=[],this.summaries={}}resolveParams(e){return(0,tt.merge)({},this.defaultParams,e.params)}},Rn=(e,t)=>{const r=l.readVariableName(t.x);return!r||!["numeric","temporal"].includes(e.getType(r))?e:e.orderBy(r,"asc")},Cn=(e,{coordSystem:t})=>{const r=V(e),n=R(e);return!l.isStrictNumericDataValue(r)||!l.isStrictNumericDataValue(n)?null:t.type==="polar"?we(r,n):{x:r,y:n}},mf=class extends ve{constructor(...e){super(...e),this.type="area",this.supportedCoordTypes=["cartesian","polar","flip"],this.defaultParams={curve:"linear",missingValues:"zero"},this.defaultPosition="stack",this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value",aes:"y"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"strokeWidth"},{kind:"visual",name:"lineType"},{kind:"visual",name:"alpha"}],this.summaries={perGroupHeadline:!0},this.dataLabels={cartesian:{offset:8},flip:{offset:8}},this.dataLabelCoordTypes=["cartesian","flip"],this.isComposite=!0,this.legend={suppressWhenSingleItem:!0,sidePlacement:"whenCrowded",directLabelSupport:{stack:!0,dodge:!0,identity:!0,fill:!0}},this.spatialKind="filled-buckets",this.resolveAnchorPosition=Cn}resolveParams(e){const t=super.resolveParams(e);return t.missingValues==="gap"?{...t,missingValues:"zero"}:t}compile({data:e,mapping:t}){return e=Rn(e,t),e.hasVariable(l.POSITION_VARIABLES.yMin)||(e=e.addConstantVariable(l.POSITION_VARIABLES.yMin,"numeric",0)),{data:e,mapping:{}}}},pf=.7,hf=.1,ff=.03,gf=.05,vs=e=>{const t=e[l.STACK_VARIABLES.role];return t??"solo"},yf=class extends ve{constructor(...e){super(...e),this.type="bar",this.defaultParams={},this.defaultPosition="dodge",this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value",aes:"y"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"alpha"}],this.summaries={grandTotal:!0,stackTotals:!0,perGroupHeadline:!0},this.grid={cartesian:{hideGridX:!0},flip:{hideGridX:!0}},this.legend={suppressWhenSingleItem:!0,sidePlacement:"whenStackedVertical",directLabelSupport:{stack:!0,fill:!0}},this.scaleConstraints={discreteMainAxis:!0,zeroBaseline:!0},this.dataLabels={polar:{format:"percentage"}},this.dataLabelCoordTypes=["cartesian","flip","polar"],this.highlightStrategy="observation-rerender",this.supportedCoordTypes=["cartesian","polar","flip"],this.spatialKind="rects",this.resolveDataLabelDefaults=t=>l.isStackedPosition(t)?{justify:"center"}:{},this.resolveBandFraction=(t,r)=>qr(t,r.type),this.resolveAnchorPosition=(t,{coordSystem:r,position:n,purpose:a,align:i})=>{if(i!==void 0){const m=fn(t,r);return m===null?null:yt(m,i)}if(r.type==="polar")return vf(t);const o=l.isStackedPosition(n),s={isSolo:!o||vs(t)==="solo",isNegative:o&&bf(t),purpose:a};if(r.mainAxis==="x"){const m=z(t),p=W(t),h=Za({lowerBound:B(t),upperBound:_(t)??R(t),options:s});return m===null||p===null||h===null?null:{x:(m+p)/2,y:h}}const c=B(t),u=_(t),d=Za({lowerBound:z(t),upperBound:W(t)??V(t),options:s});return c===null||u===null||d===null?null:{x:d,y:(c+u)/2}}}resolveParams(e){const{width:t,...r}=super.resolveParams(e),n=this.resolveWidthParam(t,e.diagnostics);return{...r,...n!==void 0&&{width:n}}}compile({data:e,mapping:t,params:r,coordType:n}){const a=qr(r,n);e=Rn(e,t),e.hasVariable(l.POSITION_VARIABLES.yMin)||(e=e.addConstantVariable(l.POSITION_VARIABLES.yMin,"numeric",0));const i=a/2;return e=e.addConstantVariable(l.POSITION_VARIABLES.xMin,"numeric",-i).addConstantVariable(l.POSITION_VARIABLES.xMax,"numeric",i),{data:e,mapping:{}}}resolveWidthParam(e,t){if(e===void 0)return;const r=typeof e=="number"&&Number.isFinite(e)?e:null;if(r!==null&&r>0&&r<=1)return r;const n=r!==null&&r>1?1:void 0;return t?.addWarning({code:"INVALID_GEOM_PARAM",message:`Bar width must be a fraction in (0, 1], got ${String(e)}; falling back to ${n??"the default band"}.`,context:{geom:this.type,param:"width",expected:"0 < width <= 1",actual:r??String(e)},suggestion:"Set params.width to a fraction of the category band in (0, 1]."}),n}},qr=({width:e},t)=>e!==void 0?e:t==="polar"?1:pf,vf=e=>{const t=z(e),r=W(e),n=B(e),a=_(e);return t===null||r===null||n===null||a===null?null:we((t+r)/2,(n+a)/2)},bf=e=>{const t=hn(e);return l.isStrictNumericDataValue(t)&&t<0},Za=e=>{const{lowerBound:t,upperBound:r,options:n}=e,a=n.isNegative?t:r;if(a===null)return null;if(n.purpose==="value"||n.isSolo)return a;const i=n.isNegative?r:t;return i===null?null:(i+a)/2},Sf=class extends ve{constructor(...e){super(...e),this.type="line",this.supportedCoordTypes=["cartesian","polar","flip"],this.defaultParams={curve:"linear",missingValues:"gap"},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"point",valueKind:"value"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"strokeWidth"},{kind:"visual",name:"lineType"},{kind:"visual",name:"alpha"}],this.summaries={perGroupHeadline:!0},this.dataLabels={cartesian:{offset:8},flip:{offset:8}},this.dataLabelCoordTypes=["cartesian","flip"],this.isComposite=!0,this.legend={suppressWhenSingleItem:!0,sidePlacement:"whenCrowded",directLabelSupport:{stack:!0,dodge:!0,identity:!0,fill:!0}},this.spatialKind="buckets",this.resolveAnchorPosition=Cn}compile(e){return{data:Rn(e.data,e.mapping),mapping:{}}}},Af=class extends ve{constructor(...e){super(...e),this.type="point",this.supportedCoordTypes=["cartesian","polar","flip"],this.defaultParams={},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"y",role:"point",valueKind:"value"}],this.aesthetics=[{kind:"visual",name:"color"},{kind:"visual",name:"size"},{kind:"visual",name:"alpha"}],this.summaries={perGroupHeadline:!0},this.dataLabelCoordTypes=["cartesian","flip"],this.resolveAnchorPosition=Cn,this.resolveValueSource=(t,r)=>{if(r!=="label")return null;const n=l.readVariableName(t.size);return n!==null?{variable:n}:null}}compile({data:e}){return{data:e,mapping:{}}}},xf=class extends ve{constructor(...e){super(...e),this.type="rule",this.defaultParams={labelPosition:"start"},this.defaultInteractive=!1,this.positionRoles=[{axis:"y",role:"scalar",valueKind:"value",aes:"y"},{axis:"x",role:"scalar",valueKind:"value",aes:"x"}],this.highlightStrategy=null,this.spatialKind="noop",this.validateMapping=({mapping:t,computedVariables:r})=>{const n=r.has("x")||l.isStrictNumericDataValue(l.readConstantValue(t.x)),a=r.has("y")||l.isStrictNumericDataValue(l.readConstantValue(t.y));return n&&a?[{code:"INVALID_RULE_MAPPING",message:"rule geom requires exactly one of 'x' or 'y', both were provided"}]:!n&&!a?[{code:"INVALID_RULE_MAPPING",message:"rule geom requires a numeric value on 'x' or 'y'"}]:[]}}compile({data:e,mapping:t}){const r=Ja(t.y,e);if(r!==null)return{data:new l.Dataset({[l.RULE_VARIABLES.y]:{type:"numeric",values:[r.value],valueFormat:r.sourceFormat}}),mapping:{y:l.RULE_VARIABLES.y,x:void 0}};const n=Ja(t.x,e);return n!==null?{data:new l.Dataset({[l.RULE_VARIABLES.x]:{type:"numeric",values:[n.value],valueFormat:n.sourceFormat}}),mapping:{x:l.RULE_VARIABLES.x,y:void 0}}:{data:new l.Dataset,mapping:{x:void 0,y:void 0}}}},Ja=(e,t)=>{const r=l.readConstantValue(e);if(l.isStrictNumericDataValue(r))return{value:r,sourceFormat:void 0};const n=l.readVariableName(e);if(n===null||!l.isStatVariable(n)||!t.hasVariable(n))return null;const[a]=t.getValues(n);return l.isStrictNumericDataValue(a)?{value:a,sourceFormat:t.getValueFormat(n)}:null},If=e=>{const t=l.readVariableName(e.color);return t!==null?{variable:t}:null},Tf=class extends ve{constructor(...e){super(...e),this.type="tile",this.defaultParams={},this.positionRoles=[{axis:"x",role:"point",valueKind:"value"},{axis:"x",role:"min",valueKind:"value"},{axis:"x",role:"max",valueKind:"value"},{axis:"y",role:"point",valueKind:"value"},{axis:"y",role:"min",valueKind:"value"},{axis:"y",role:"max",valueKind:"value"}],this.supportedPositions=["identity"],this.supportedCoordTypes=["cartesian"],this.aesthetics=[{kind:"visual",name:"color",required:!0}],this.scaleConstraints={discreteMainAxis:!0,discreteCrossAxis:!0,bandPadding:0,inferredColor:!0},this.grid={cartesian:{hideGridX:!0,hideGridY:!0}},this.legend={suppressWhenSingleItem:!1},this.dataLabels={cartesian:{showDataLabels:!0}},this.dataLabelCoordTypes=["cartesian"],this.highlightStrategy="observation-rerender",this.spatialKind="cells",this.identityKey="x-y",this.tooltip=[{aes:"color"}],this.resolveValueSource=If,this.resolveAnchorPosition=t=>{const r=z(t),n=W(t),a=B(t),i=_(t);return r===null||n===null||a===null||i===null?null:{x:(r+n)/2,y:(a+i)/2}}}compile({data:e}){return{data:e.addConstantVariable(l.POSITION_VARIABLES.xMin,"numeric",-.5).addConstantVariable(l.POSITION_VARIABLES.xMax,"numeric",.5).addConstantVariable(l.POSITION_VARIABLES.yMin,"numeric",-.5).addConstantVariable(l.POSITION_VARIABLES.yMax,"numeric",.5),mapping:{}}}},Lf=[new yf,new Af,new Sf,new mf,new xf,new Tf],hr=class extends l.Registry{constructor(){super("geom");for(const e of Lf)this.register(e.type,e)}},ke=class{compute(e){return e.data.size()===0?{data:e.data,mapping:{}}:this.computeStat(e)}},Ef=class extends ke{constructor(...e){super(...e),this.type="count",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=l.readVariableName(t.x);if(!l.isDefined(r))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'x' variable is required for 'count' stat",context:{aesthetic:"x"},suggestion:"Map a variable to 'x' when using the 'count' stat."});if(l.readVariableName(t.y)!==null)throw new l.UserInputError({code:"CONFLICTING_STAT_MAPPING",message:"Cannot map 'y' variable together with 'count' stat",context:{aesthetic:"y"},suggestion:"Remove the 'y' mapping; the 'count' stat computes it."});const n=[...new Set([r,...pe(e,t)])];return{data:e.groupBy(...n).rollup({[l.STAT_VARIABLES.count]:{variableName:r,aggregation:"count"}}),mapping:{y:l.STAT_VARIABLES.count}}}},wf=class extends ke{constructor(...e){super(...e),this.type="identity",this.computedVariables=new Set}computeStat({data:e}){return{data:e,mapping:{}}}},Rf=class extends ke{constructor(...e){super(...e),this.type="mean",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=l.readVariableName(t.y);if(!l.isDefined(r))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'mean' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'mean' stat."});return{data:e.rollup({[l.STAT_VARIABLES.mean]:{variableName:r,aggregation:"mean"}}),mapping:{y:l.STAT_VARIABLES.mean}}}},Cf=2,bs=1440*60*1e3,Vf=class extends ke{constructor(...e){super(...e),this.type="smooth",this.computedVariables=new Set}computeStat({data:e,mapping:t,spec:r,xScaleIsDiscrete:n}){if(r.type!=="smooth")throw new l.InternalError({message:`SmoothStat received a spec of type '${r.type}'`});const a=l.readVariableName(t.x),i=l.readVariableName(t.y);if(!l.isDefined(a))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'x' variable is required for 'smooth' stat",context:{aesthetic:"x"},suggestion:"Map a variable to 'x' when using the 'smooth' stat."});if(!l.isDefined(i))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'smooth' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'smooth' stat."});const o=e.getType(a),s=e.getType(i);if(s!=="numeric")throw new l.UserInputError({code:"INCOMPATIBLE_TYPE",message:`'smooth' stat requires a numeric 'y' (got '${s}' for variable '${i}')`,context:{aesthetic:"y",variableName:i,variableType:s}});const c=pe(e,t),u=Nf(a,o,i,c,e);return c.length===0?Qa({data:e,xVariable:a,xType:o,yVariable:i,spec:r,output:u,groupObservation:{},xScaleIsDiscrete:n}):e.groupBy(...c).forEach(d=>{const m=Bf(d,c);Qa({data:d,xVariable:a,xType:o,yVariable:i,spec:r,output:u,groupObservation:m,xScaleIsDiscrete:n})}),{data:u.build(),mapping:{}}}},Qa=({data:e,xVariable:t,xType:r,yVariable:n,spec:a,output:i,groupObservation:o,xScaleIsDiscrete:s})=>{const{observations:c,temporalOrigin:u}=Mf({data:e,xVariable:t,yVariable:n,xType:r});c.length<Cf||(s?kf({observations:c,spec:a,output:i,groupObservation:o}):Of({observations:c,xType:r,temporalOrigin:u,spec:a,output:i,groupObservation:o}))},Mf=({data:e,xVariable:t,yVariable:r,xType:n})=>{const a=e.getValues(t),i=e.getValues(r,{type:"numeric"}),o=n==="temporal"?Df(a):null,s=[],c=new Map;for(let u=0;u<a.length;u++){const d=a[u],m=i[u];if(!l.isDefined(d)||!l.isDefined(m)||!Number.isFinite(m))continue;const p=Pf({xValue:d,xType:n,categoryRank:c,temporalOrigin:o});p!==null&&s.push({x:p,y:m,originalX:d})}return{observations:s,temporalOrigin:o}},Df=e=>{let t=null;for(const r of e){if(!l.isStrictTemporalDataValue(r))continue;const n=r.getTime();(t===null||n<t)&&(t=n)}return t},Pf=({xValue:e,xType:t,categoryRank:r,temporalOrigin:n})=>{switch(t){case"numeric":return!l.isStrictNumericDataValue(e)||!Number.isFinite(e)?null:e;case"temporal":{if(!l.isStrictTemporalDataValue(e))return null;const a=e.getTime();return n===null?a:(a-n)/bs+1}case"categorical":{if(!l.isStrictCategoricalDataValue(e))return null;const a=r.get(e);if(a!==void 0)return a;const i=r.size+1;return r.set(e,i),i}default:throw new l.InternalError({message:`Unexpected xType: ${t}`})}},Of=({observations:e,xType:t,temporalOrigin:r,spec:n,output:a,groupObservation:i})=>{const o=Ss(n,e);for(const[s,c]of o){if(!Number.isFinite(s)||!Number.isFinite(c))continue;const u=t==="temporal"?_f(s,r):s;a.push({x:u,y:c,groupObservation:i})}},_f=(e,t)=>t===null?new Date(e):new Date((e-1)*bs+t),kf=({observations:e,spec:t,output:r,groupObservation:n})=>{const a=new Map;for(const s of e)a.has(s.x)||a.set(s.x,s.originalX);const i=[...a.keys()].sort((s,c)=>s-c);if(t.method==="loess"){const s=Ss(t,e),c=new Map;for(const[u,d]of s)Number.isFinite(d)&&(c.has(u)||c.set(u,d));for(const u of i){const d=c.get(u),m=a.get(u);d===void 0||m===void 0||r.push({x:m,y:d,groupObservation:n})}return}const o=As(t,e);for(const s of i){const c=a.get(s),u=o.predict(s);c===void 0||!Number.isFinite(u)||r.push({x:c,y:u,groupObservation:n})}},Ss=(e,t)=>e.method==="loess"?(0,Ee.regressionLoess)().x(r=>r.x).y(r=>r.y).bandwidth(e.bandwidth)(t):As(e,t),As=(e,t)=>{const r=a=>a.x,n=a=>a.y;switch(e.method){case"linear":return(0,Ee.regressionLinear)().x(r).y(n)(t);case"exponential":return(0,Ee.regressionExp)().x(r).y(n)(t);case"logarithmic":return(0,Ee.regressionLog)().x(r).y(n)(t);case"quadratic":return(0,Ee.regressionQuad)().x(r).y(n)(t);case"power":return(0,Ee.regressionPow)().x(r).y(n)(t);case"polynomial":return(0,Ee.regressionPoly)().x(r).y(n).order(e.order)(t);case"loess":throw new l.InternalError({message:"'loess' does not expose a 'predict' function"})}},Nf=(e,t,r,n,a)=>{const i=[],o=[],s=Object.fromEntries(n.map(c=>[c,[]]));return{push:({x:c,y:u,groupObservation:d})=>{i.push(c),o.push(u);for(const m of n)s[m]?.push(d[m]??null)},build:()=>{const c={[e]:{type:t,values:i,valueFormat:a.getValueFormat(e)},[r]:{type:"numeric",values:o,valueFormat:a.getValueFormat(r)}};for(const u of n)c[u]={type:a.getType(u),values:s[u]??[],valueFormat:a.getValueFormat(u)};return new l.Dataset(c)}}},Bf=(e,t)=>{const r={};for(const n of t)r[n]=e.getValues(n)[0]??null;return r},Ff=class extends ke{constructor(...e){super(...e),this.type="sum",this.computedVariables=new Set(["y"])}computeStat({data:e,mapping:t}){const r=l.readVariableName(t.y);if(!l.isDefined(r))throw new l.UserInputError({code:"MISSING_STAT_VARIABLE",message:"'y' variable is required for 'sum' stat",context:{aesthetic:"y"},suggestion:"Map a numeric variable to 'y' when using the 'sum' stat."});const n=l.readVariableName(t.x),a=[...new Set([...n===null?[]:[n],...pe(e,t)])];return{data:e.groupBy(...a).rollup({[l.STAT_VARIABLES.sum]:{variableName:r,aggregation:"sum"}}),mapping:{y:l.STAT_VARIABLES.sum}}}},Gf=[new wf,new Ef,new Vf,new Rf,new Ff],$f=class extends l.Registry{constructor(){super("stat");for(const e of Gf)this.register(e.type,e)}};function Uf({geoms:e,stats:t,transforms:r}){const n=new hr,a=new $f,i=new l.TransformRegistry;for(const o of e)n.register(o.type,o);for(const o of t)a.register(o.type,o);for(const o of r)i.register(o.transformType,o);return{geomRegistry:n,statRegistry:a,transformRegistry:i}}function Vn(e){if("definition"in e)return e.definition;if(Is(e)||Ts(e)||Ls(e))return e}function xs(e){const t=[],r=[],n=[];for(const a of e){const i=Vn(a);i&&(Is(i)?t.push(i):Ts(i)?r.push(i):Ls(i)&&n.push(i))}return{geoms:t,stats:r,transforms:n,warnings:[...Pr("geom",t,a=>a.type),...Pr("stat",r,a=>a.type),...Pr("transform",n,a=>a.transformType),...Hf(t),...zf(t)]}}function Hf(e){const t=[];for(const r of e)r.spatialKind==="render-hit-test"&&(r.identityKey!=="x-group"&&r.identityKey!=="x-y"||t.push({code:"RENDER_HIT_TEST_IDENTITY",message:`The render-hit-test geom '${r.type}' uses the position-derived '${r.identityKey}' identity, which has no meaning for render-owned geometry; its hover lookup will be empty.`,context:{kind:"geom",requested:r.type},suggestion:"Declare 'identityKey' as a column the geom owns (`{ variable: '<column>' }`) or 'index', so a hit-test result resolves to an observation."}));return t}function zf(e){const t=[];for(const r of e)r.spatialKind!=="cells"||!r.supportedCoordTypes.includes("polar")||t.push({code:"SPATIAL_KIND_COORD_UNSUPPORTED",message:`The geom '${r.type}' declares polar support, but its 'cells' hit-test shape has no polar projection; its observations will not respond to hover under polar coords.`,context:{kind:"geom",requested:r.type},suggestion:"Drop 'polar' from 'supportedCoordTypes', or declare 'rects' as the spatial kind so a bandless polar layer hit-tests as an enclosure."});return t}function Pr(e,t,r){const n=new Map;for(const i of t){const o=r(i),s=n.get(o);s?s.add(i):n.set(o,new Set([i]))}const a=[];for(const[i,o]of n)o.size<2||a.push({code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple plugins register the ${e} '${i}' (${o.size} definitions); the last in the array wins.`,context:{kind:e,requested:i},suggestion:`Remove the duplicate ${e} plugin(s) named '${i}', or rename them so each registers a distinct ${e}.`});return a}var Is=e=>e instanceof ve,Ts=e=>e instanceof ke,Ls=e=>"transformType"in e&&typeof e.apply=="function",Wf=class{constructor(e){this.registry=e}adjust(e,t){return this.registry.get(e).adjust(t)}},fr=class{},Kf=class extends fr{constructor(...e){super(...e),this.type="dodge"}adjust({data:e,mapping:t}){if(!l.readVariableName(t.x))return{data:e,mapping:{}};const r=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical",distinct:!0,skipNulls:!0});if(r.length===0)return{data:e,mapping:{}};const n=e.size(),a=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}),i=Yf(e)??[-.7/2,.7/2],o=r.length>1?hf:0,s=(0,ie.scaleBand)().domain(r.map(String)).range(i).paddingInner(o).paddingOuter(0),c=s.bandwidth(),u=new Array(n).fill(null),d=new Array(n).fill(null);for(let m=0;m<n;m++){const p=a[m];if(!l.isDefined(p))continue;const h=s(String(p));l.isDefined(h)&&(u[m]=h,d[m]=h+c)}return{data:e.addVariable(l.POSITION_VARIABLES.xMin,"numeric",u).addVariable(l.POSITION_VARIABLES.xMax,"numeric",d),mapping:{}}}},Yf=e=>{const t=e.getConstant(l.POSITION_VARIABLES.xMin)?.value,r=e.getConstant(l.POSITION_VARIABLES.xMax)?.value;return typeof t!="number"||typeof r!="number"?null:[t,r]},ei=l.prefixInternalVariable("__ungrouped__"),Es=(e,t)=>{const r=l.readVariableName(t.x),n=l.readVariableName(t.y);if(!r||!n)return null;const a=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical",distinct:!0,skipNulls:!0}),i=a.length===0,o=i?[ei]:a,s=e.getValues(r),c=e.getValues(n,{type:"numeric"}),u=e.getValues(l.GROUP_VARIABLES.group,{type:"categorical"}),d=e.size(),m=new Map;for(let p=0;p<d;p++){const h=l.getStableKey(s[p]??null),f=u[p],g=i?ei:f;if(!l.isDefined(g))continue;let v=m.get(h);v||(v=new Map,m.set(h,v));let y=v.get(g);y||(y=[],v.set(g,y)),y.push(p)}return{yValues:c,observationIndicesByXAndGroup:m,uniqueGroupKeys:o,observationCount:d}},ws=(e,t,r,n)=>{const a=new Array(n).fill(null);for(const[,i]of r){const o=[];let s=-1,c=1/0,u=-1/0,d=-1,m=1/0,p=-1/0;for(const h of i.values())for(const f of h){const g=e[f],v=t[f];!l.isDefined(g)||!l.isDefined(v)||(o.push(f),(g<c||g===c&&v>u)&&(s=f,c=g,u=v),(v>p||v===p&&g<m)&&(d=f,m=g,p=v))}for(const h of o)a[h]=jf(h===s,h===d)}return a},jf=(e,t)=>e&&t?"solo":e?"floor":t?"ceiling":"middle",qf=class extends fr{constructor(...e){super(...e),this.type="fill"}adjust({data:e,mapping:t}){const r=Es(e,t);if(r===null)return{data:e,mapping:{}};const{yValues:n,observationIndicesByXAndGroup:a,uniqueGroupKeys:i,observationCount:o}=r,s=[...n],c=new Array(o).fill(0);for(const[,d]of a){let m=0,p=0;for(const g of i){const v=d.get(g);if(v!==void 0)for(const y of v){const A=n[y];A!=null&&(A>=0?m+=A:p-=A)}}let h=0,f=0;for(const g of i){const v=d.get(g);if(v!==void 0)for(const y of v){const A=n[y];if(A===void 0)continue;if(A===null){c[y]=null,s[y]=null;continue}const I=A>=0?m:p;if(I===0){c[y]=0,s[y]=0;continue}const x=A/I;A>=0?(c[y]=h,s[y]=h+=x):(s[y]=f,c[y]=f+=x)}}}const u=ws(c,s,a,o);return{data:e.addVariable(l.POSITION_VARIABLES.yMin,"numeric",c).addVariable(l.POSITION_VARIABLES.yMax,"numeric",s).addVariable(l.POSITION_VARIABLES.yRaw,"numeric",n).addVariable(l.STACK_VARIABLES.role,"categorical",u),mapping:{}}}},Xf=class extends fr{constructor(...e){super(...e),this.type="identity"}adjust({data:e}){return{data:e,mapping:{}}}},Zf=class extends fr{constructor(...e){super(...e),this.type="stack"}adjust({data:e,mapping:t}){const r=Es(e,t);if(r===null)return{data:e,mapping:{}};const{yValues:n,observationIndicesByXAndGroup:a,uniqueGroupKeys:i,observationCount:o}=r,s=[...n],c=new Array(o).fill(0);for(const[,p]of a){let h=0,f=0;for(const g of i){const v=p.get(g);if(v!==void 0)for(const y of v){const A=n[y];if(A!==void 0){if(A===null){c[y]=null,s[y]=null;continue}A>=0?(c[y]=h,s[y]=h+=A):(s[y]=f,c[y]=f+=A)}}}}const u=ws(c,s,a,o);let d=e.addVariable(l.POSITION_VARIABLES.yMin,"numeric",c).addVariable(l.POSITION_VARIABLES.yMax,"numeric",s).addVariable(l.POSITION_VARIABLES.yRaw,"numeric",n).addVariable(l.STACK_VARIABLES.role,"categorical",u);const m=l.readVariableName(t.y);return m!==null&&(d=d.addVariable(m,"numeric",s)),{data:d,mapping:{}}}},Jf=class extends l.Registry{constructor(){super("position"),this.register("identity",new Xf),this.register("stack",new Zf),this.register("fill",new qf),this.register("dodge",new Kf)}},Qf=class{map({data:e,layer:t,getPositionScale:r,geomRegistry:n}){let a=e;const i=n.get(t.geom);for(const o of i.positionRoles){if(o.role!=="scalar"||!l.isDefined(o.aes)||In(o.aes))continue;const s=l.readVariableName(t.mapping[o.aes]);if(!l.isDefined(s)||!a.hasVariable(s))continue;const c=r(as(o.axis,t.yScaleType));if(!c)continue;const u=a.getValues(s,{type:"numeric"}).map(d=>l.isDefined(d)?c.map(d):null);a=a.addVariable(l.resolveScaledAestheticVariable(o.aes),"numeric",u)}return a}},eg=class{map({data:e,layer:t,getPositionScale:r}){const n=l.readVariableName(t.mapping.x),a=r("x");if(!n||!a)return e;const i=e.getValues(n).map(o=>l.isDefined(o)?a.map(o):null);return e.addVariable(l.POSITION_VARIABLES.x,"numeric",i)}},tg=class{map({data:e,getPositionScale:t}){const r=t("x");if(!r||!e.hasVariable(l.POSITION_VARIABLES.xMin)||!e.hasVariable(l.POSITION_VARIABLES.xMax))return e;const n=r.bandwidth,a=l.isDefined(n)&&e.hasVariable(l.POSITION_VARIABLES.x)?rg(e,r,n):ng(e,r);return e.addVariable(l.POSITION_VARIABLES.xMin,"numeric",a.min).addVariable(l.POSITION_VARIABLES.xMax,"numeric",a.max)}};function rg(e,t,r){const n=e.getValues(l.POSITION_VARIABLES.x,{type:"numeric"}),a=e.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),i=e.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),o="reverse"in t.spec&&t.spec.reverse===!0,s=e.size(),c=Rs(s);for(let u=0;u<s;u++){const d=n[u],m=a[u],p=i[u];!l.isDefined(d)||!l.isDefined(m)||!l.isDefined(p)||(c.min[u]=d+(o?-p:m)*r,c.max[u]=d+(o?-m:p)*r)}return c}function ng(e,t){const r=e.getValues(l.POSITION_VARIABLES.xMin,{type:"numeric"}),n=e.getValues(l.POSITION_VARIABLES.xMax,{type:"numeric"}),a=e.size(),i=Rs(a);for(let o=0;o<a;o++){const s=r[o],c=n[o];!l.isDefined(s)||!l.isDefined(c)||(i.min[o]=t.map(s),i.max[o]=t.map(c))}return i}function Rs(e){return{min:new Array(e).fill(null),max:new Array(e).fill(null)}}var ag=class{map({data:e,layer:t,getPositionScale:r}){const n=l.readVariableName(t.mapping.y),a=r(xe(t.yScaleType));if(!n||!a)return e;const i=e.getValues(n).map(o=>l.isDefined(o)?a.map(o):null);return e.addVariable(l.POSITION_VARIABLES.y,"numeric",i)}},ig=class{map({data:e,layer:t,getPositionScale:r}){const n=r(xe(t.yScaleType));if(!n||!e.hasVariable(l.POSITION_VARIABLES.yMin)||!e.hasVariable(l.POSITION_VARIABLES.yMax))return e;const a=n.bandwidth,i=l.isDefined(a)&&e.hasVariable(l.POSITION_VARIABLES.y)?og(e,n,a):sg(e,n);return e.addVariable(l.POSITION_VARIABLES.yMin,"numeric",i.min).addVariable(l.POSITION_VARIABLES.yMax,"numeric",i.max)}};function og(e,t,r){const n=e.getValues(l.POSITION_VARIABLES.y,{type:"numeric"}),a=e.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),i=e.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),o="reverse"in t.spec&&t.spec.reverse===!0,s=e.size(),c=Cs(s);for(let u=0;u<s;u++){const d=n[u],m=a[u],p=i[u];!l.isDefined(d)||!l.isDefined(m)||!l.isDefined(p)||(c.min[u]=d+(o?-p:m)*r,c.max[u]=d+(o?-m:p)*r)}return c}function sg(e,t){const r=e.getValues(l.POSITION_VARIABLES.yMin,{type:"numeric"}),n=e.getValues(l.POSITION_VARIABLES.yMax,{type:"numeric"}),a=e.size(),i=Cs(a);for(let o=0;o<a;o++){const s=r[o],c=n[o];!l.isDefined(s)||!l.isDefined(c)||(i.min[o]=t.map(s),i.max[o]=t.map(c))}return i}function Cs(e){return{min:new Array(e).fill(null),max:new Array(e).fill(null)}}var lg=[new eg,new ag,new tg,new ig,new Qf];function cg(e,t){const r=e[t];return r?.kind==="position"?r:null}var ug=class extends _e{constructor(e,t=lg){super(),this.container=e,this.mappers=t}dependencies(e){return[e.scales.x,e.scales.y,e.scales.ySecondary]}compileLayer(e,t){const r=a=>cg(t.scales,a);let n=e.data;for(const a of this.mappers)n=a.map({data:n,layer:e,getPositionScale:r,geomRegistry:this.container.geomRegistry});return{...e,data:n}}},dg=class extends l.Stage{constructor(e,t){super(),this.container=e,this.registry=t}dependencies(e){return[e.layers,e.scales,e.colorScheme]}run(e){this.validateScaleTypeCompatibility(e);const t=new Map;for(const i of e.scales)t.set(i.scaledAesthetic,i);const r=this.collectValues(e.layers,t),n={colorScheme:e.colorScheme,hasTouchingGeoms:af(this.container.geomRegistry,e.layers)},a={};for(const[i,o]of t){const s=r.get(i)??[];a[i]=this.registry.get(o.scaleType).compile(o,s,n)}return a}validateScaleTypeCompatibility(e){const t=[];for(const r of e.scales){const{compatibleDataTypes:n}=this.registry.get(r.scaleType),a=F(r.scaledAesthetic),i=e.layers.find(c=>l.isDefined(c.mapping[a]));if(!i)continue;const o=l.readVariableName(i.mapping[a]);if(!l.isDefined(o)||!i.data.hasVariable(o)||i.data.size()===0)continue;const s=i.data.getType(o);if(!n.includes(s)){const c=r.scaleType==="continuous"&&s==="temporal"?`Use scale.${r.scaledAesthetic}.datetime() for a time axis or declare the column's valueFormat in data.columns to read it as a number.`:void 0;t.push({code:"INCOMPATIBLE_TYPE",message:`Scale '${r.scaledAesthetic}' (${r.scaleType}) is incompatible with variable '${o}' (${s})`,context:{aesthetic:a,variableName:o,scaleType:r.scaleType,variableType:s},suggestion:c})}if(r.scaledAesthetic==="lineType"&&s!=="categorical"){const c=s==="temporal"?"Bucket the variable into categorical periods (e.g. quarter, year) first.":"Bin the variable into categorical buckets first.";t.push({code:"INCOMPATIBLE_TYPE",message:`Scale 'lineType' is discrete-only and cannot be mapped to ${s} variable '${o}'. ${c}`,context:{aesthetic:a,variableName:o,scaleType:r.scaleType,variableType:s},suggestion:c})}}gs(this.container.diagnostics,t)}collectValues(e,t){const r=new Map;for(const n of e){const a=this.resolveCustomPositionalAxes(n);for(const[i,o]of Object.entries(n.mapping)){if(!l.isDefined(o))continue;const s=i==="y"?xe(n.yScaleType):i,c=a.get(i)??(ns(s)?s:void 0);if(!l.isDefined(c)||!t.has(c))continue;const u=t.get(c)?.scaleType,d=this.resolveVariables(i,o,n.data,u);this.collectFromVariables(n.data,d,c,r)}}return r}resolveCustomPositionalAxes(e){const t=new Map,r=this.container.geomRegistry.get(e.geom);for(const n of r.positionRoles)n.role!=="scalar"||!l.isDefined(n.aes)||In(n.aes)||t.set(n.aes,as(n.axis,e.yScaleType));return t}resolveVariables(e,t,r,n){if(e==="y"&&n!=="discrete"&&this.hasPositionAdjustedY(r))return[l.POSITION_VARIABLES.yMin,l.POSITION_VARIABLES.yMax];const a=l.readVariableName(t);return!a||!r.hasVariable(a)?[]:[a]}hasPositionAdjustedY(e){return e.hasVariable(l.POSITION_VARIABLES.yMin)&&e.hasVariable(l.POSITION_VARIABLES.yMax)}collectFromVariables(e,t,r,n){if(t.length===0)return;let a=[];for(const o of t)a=a.concat(e.getValues(o));const i=n.get(r);n.set(r,i?i.concat(a):a)}},mg=["rgb","lab","hcl","hsl"],pg=["viridis","magma","inferno","plasma","cividis","turbo","Blues","Greens","Greys","Oranges","Purples","Reds"],Vs=["RdBu","BrBG","PuOr","Spectral"],Ms={"red-blue":"RdBu","brown-teal":"BrBG","purple-orange":"PuOr",spectral:"Spectral"},hg=new Set(Vs.map(e=>e.toLowerCase()));function Ds(e){const t=e.toLowerCase(),r=Ms[t];return r?r.toLowerCase():t}function fg(e){return hg.has(Ds(e))}var gg={rgb:ze.interpolateRgb,lab:ze.interpolateLab,hcl:ze.interpolateHcl,hsl:ze.interpolateHsl},yg={viridis:N.interpolateViridis,magma:N.interpolateMagma,inferno:N.interpolateInferno,plasma:N.interpolatePlasma,cividis:N.interpolateCividis,turbo:N.interpolateTurbo,blues:N.interpolateBlues,greens:N.interpolateGreens,greys:N.interpolateGreys,oranges:N.interpolateOranges,purples:N.interpolatePurples,reds:N.interpolateReds,rdbu:N.interpolateRdBu,brbg:N.interpolateBrBG,puor:N.interpolatePuOr,spectral:N.interpolateSpectral};function Mn(e){const t=bg(e);return e.reverse?r=>t(1-r):t}function vg(e={},t=2){const r=Mn({range:e.range??null,scheme:e.scheme??null,interpolate:e.interpolate??l.CONTINUOUS_SCALE_DEFAULTS.interpolate,reverse:e.reverse??!1});return t<2?t===1?[r(0)]:[]:Array.from({length:t},(n,a)=>r(a/(t-1)))}function bg(e){const t=gg[e.interpolate];if(e.range&&e.range.length>=2)return(0,ze.piecewise)(t,e.range.map(r=>String(r)));if(e.scheme){const r=yg[Ds(e.scheme)];if(r)return r}return(0,ze.piecewise)(t,[...l.DEFAULT_SEQUENTIAL_RAMP])}var It=class{createPositionScale(e,t){return{kind:"position",aesthetic:F(e.scaledAesthetic),spec:e,...t}}createVisualScale(e,t){return{kind:"visual",aesthetic:F(e.scaledAesthetic),spec:e,...t}}},Sg=class extends It{constructor(e){super(),this.container=e,this.compatibleDataTypes=["numeric"]}compile(e,t){if(e.scaleType!=="continuous")throw new l.InternalError({message:"ContinuousScale.compile received non-continuous spec"});const r=Ae(e.scaledAesthetic),n=e.scaledAesthetic==="color",a=this.computeDataDomain(t,e);return n?this.buildColorScale(a,e):r?this.buildPositionScale(a,e):this.buildVisualScale(a,e)}computeDataDomain(e,t){let r=1/0,n=-1/0;for(const a of e)typeof a=="number"&&(a<r&&(r=a),a>n&&(n=a));return r===1/0?[0,0]:(t.zero&&(r>0&&(r=0),n<0&&(n=0)),[r,n])}createD3Scale(e,t,r){let n=[r.domainMin??e[0],r.domainMax??e[1]];const a=r.transform==="log"&&Ag(n);r.transform==="log"&&!a&&this.container.diagnostics.addWarning({code:"INCOMPATIBLE_SCALE_DOMAIN",message:`Log scale on '${r.scaledAesthetic}' needs a strictly positive or negative domain, but the domain is [${e[0]}, ${e[1]}] — rendering a linear scale instead.`,context:{aesthetic:F(r.scaledAesthetic),scaleType:r.scaleType,actual:e},suggestion:"Filter out non-positive values or set a positive domainMin so the log scale can apply."});const i=a?(0,ie.scaleLog)():r.transform==="sqrt"?(0,ie.scaleSqrt)():(0,ie.scaleLinear)();r.nice&&!a&&(n=i.copy().domain(n).nice().domain());const o=r.domainMin??n[0],s=r.domainMax??n[1];return i.domain([o,s]).range(t).clamp(r.clamp)}buildPositionScale(e,t){const r=t.reverse?[1,0]:[0,1],n=this.createD3Scale(e,r,t);return this.createPositionScale(t,{map:n,domain:n.domain(),bandwidth:null,generateTicks:a=>a&&"count"in a?n.ticks(a.count):n.ticks()})}buildVisualScale(e,t){const r=xg(t.range)??[0,1],n=t.reverse?[r[1],r[0]]:r,a=this.createD3Scale(e,n,t);return this.createVisualScale(t,{map:a,domain:a.domain(),generateTicks:i=>i&&"count"in i?a.ticks(i.count):a.ticks()})}buildColorScale(e,t){const r=Mn(t),n=t.domainMid;if(n!==null){const[a,i]=this.resolveColorDomain(e,t);if(n>a&&n<i){const[o,s]=this.symmetrizeDomain([a,i],t,n);return this.buildDivergingColorScale([o,n,s],t,r)}}return this.buildSequentialColorScale(e,t,r)}buildSequentialColorScale(e,t,r){const n=this.createD3Scale(e,[0,1],t),a=i=>typeof i!="number"||!Number.isFinite(i)?null:r(n(i));return this.createVisualScale(t,{map:a,domain:n.domain(),generateTicks:i=>i&&"count"in i?n.ticks(i.count):n.ticks()})}buildDivergingColorScale(e,t,r){const n=(0,ie.scaleLinear)().domain(e).range([0,.5,1]).clamp(t.clamp),a=i=>typeof i!="number"||!Number.isFinite(i)?null:r(n(i));return this.createVisualScale(t,{map:a,domain:e,generateTicks:i=>i&&"count"in i?n.ticks(i.count):n.ticks()})}resolveColorDomain(e,t){let r=t.domainMin??e[0],n=t.domainMax??e[1];if(t.nice){const a=(0,ie.scaleLinear)().domain([r,n]).nice().domain();r=t.domainMin??a[0],n=t.domainMax??a[1]}return[r,n]}symmetrizeDomain(e,t,r){if(!t.symmetric)return e;const n=Math.max(Math.abs(e[0]-r),Math.abs(e[1]-r));return[t.domainMin??r-n,t.domainMax??r+n]}},Ag=e=>{const[t,r]=e;return t>0&&r>0||t<0&&r<0};function xg(e){if(!e)return null;const[t,r]=e;return typeof t=="number"&&typeof r=="number"?[t,r]:null}var Ig=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["temporal"]}compile(e,t){if(e.scaleType!=="datetime")throw new l.InternalError({message:"DatetimeScale.compile received non-datetime spec"});const r=Ae(e.scaledAesthetic),n=this.computeDataDomain(t);if(!r)throw new l.UserInputError({code:"INCOMPATIBLE_TYPE",message:"Datetime scale is not supported for non-position aesthetics",context:{aesthetic:e.scaledAesthetic},suggestion:"Use a continuous or discrete scale for non-position aesthetics (color, size, alpha, strokeWidth)."});return this.buildScale(n,e,this.collectInputDates(t))}collectInputDates(e){const t=new Set,r=[];for(const n of e){if(!(n instanceof Date))continue;const a=n.getTime();t.has(a)||(t.add(a),r.push(n))}return r.sort((n,a)=>n.getTime()-a.getTime()),r}computeDataDomain(e){let t=1/0,r=-1/0;for(const n of e){if(!(n instanceof Date))continue;const a=n.getTime();a<t&&(t=a),a>r&&(r=a)}return t===1/0?[]:[new Date(t),new Date(r)]}createD3Scale(e,t,r){const n=Tg(e)?e:[],a=(0,ie.scaleUtc)().domain(n).range(t).clamp(r.clamp);if(r.nice&&a.nice(),l.isDefined(r.domainMin)||l.isDefined(r.domainMax)){const[i,o]=a.domain();i!==void 0&&o!==void 0&&a.domain([r.domainMin??i,r.domainMax??o])}return a}buildScale(e,t,r){const n=t.reverse?[1,0]:[0,1],a=this.createD3Scale(e,n,t),[i,o]=a.domain(),s=i&&o?r.filter(c=>c>=i&&c<=o):[];return this.createPositionScale(t,{map:a,domain:a.domain(),bandwidth:null,generateTicks:c=>c&&"atInputs"in c?s:c&&"interval"in c?i&&o?Hp(i,o,c.interval):[]:a.ticks(c?.count)})}},Tg=e=>e.length===2&&l.isStrictTemporalDataValue(e[0])&&l.isStrictTemporalDataValue(e[1]),Lg=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["categorical","numeric","temporal"]}compile(e,t){if(e.scaleType!=="discrete")throw new l.InternalError({message:"DiscreteScale.compile received non-discrete spec"});const r=Ae(e.scaledAesthetic),n=ts(t,e);return r?this.buildPositionScale(n,e):this.buildVisualScale(n,e)}buildPositionScale(e,t){const r=e.map(String),n=t.padding??l.DISCRETE_SCALE_DEFAULTS.padding,a=t.reverse?[1,0]:[0,1],i=(0,ie.scaleBand)().domain(r).range(a).paddingInner(n).paddingOuter(n/2),o=i.bandwidth()/2;return this.createPositionScale(t,{map:s=>(i(String(s))??NaN)+o,domain:e,bandwidth:i.bandwidth(),generateTicks:()=>[...e]})}buildVisualScale(e,t){const r=e.map(String),n=t.range&&t.range.length>0?(0,ie.scaleOrdinal)().domain(r).range(t.range).unknown(t.range[0]):null;return this.createVisualScale(t,{map:a=>{const i=String(a);return n?n(i):i},domain:e,generateTicks:()=>e})}},Eg=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["numeric","categorical","temporal"]}compile(e){if(e.scaleType!=="identity")throw new l.InternalError({message:"IdentityScale.compile received non-identity spec"});return{kind:"identity",aesthetic:F(e.scaledAesthetic),spec:e,map:t=>t,domain:[],generateTicks:()=>[]}}},wg=class extends It{constructor(...e){super(...e),this.compatibleDataTypes=["categorical","temporal","numeric"]}compile(e,t,r){if(e.scaleType!=="palette")throw new l.InternalError({message:"PaletteScale.compile received non-palette spec"});const n=es(t),a=l.resolvePaletteRange(e.palette,{groupCount:n.length,...r}),i=l.applyOverrides(a.length>0?a:[...l.DEFAULT_COLOR_PALETTE],e.overrides),o=(0,ie.scaleOrdinal)().domain(n.map(String)).range(i).unknown(i[0]);return this.createVisualScale(e,{map:s=>o(String(s)),domain:n,generateTicks:()=>n})}},Rg=class extends l.Registry{constructor(e){super("scale"),this.register("continuous",new Sg(e)),this.register("discrete",new Lg),this.register("datetime",new Ig),this.register("identity",new Eg),this.register("palette",new wg)}},Ps={x:"position",y:"position",ySecondary:"position",color:"color-range",size:"continuous-range",alpha:"continuous-range",strokeWidth:"continuous-range",lineType:"discrete-only"},Cg={numeric:{position:"continuous","color-range":"continuous","continuous-range":"continuous","discrete-only":"discrete"},categorical:{position:"discrete","color-range":"palette","continuous-range":"discrete","discrete-only":"discrete"},temporal:{position:"datetime","color-range":"continuous","continuous-range":"continuous","discrete-only":"discrete"}};function Dn(e,t){const{data:r,layers:n,mapping:a,customPalettes:i}=t;return{container:e,data:r,layers:n,mapping:a,customPalettes:i,demands:jr(e.geomRegistry,n)}}function gr(e,t){switch(t.scaleType){case"inferred":return{...gr(e,Pg(e,t)),inferredFrom:t};case"continuous":{const r=Ps[t.scaledAesthetic],n=r==="continuous-range"&&t.scaledAesthetic in l.NON_POSITION_RANGE_DEFAULTS?l.NON_POSITION_RANGE_DEFAULTS[t.scaledAesthetic]:null,a=t.scaledAesthetic==="size"&&r==="continuous-range"?"sqrt":l.CONTINUOUS_SCALE_DEFAULTS.transform;return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,transform:t.transform??a,reverse:t.reverse??l.CONTINUOUS_SCALE_DEFAULTS.reverse,nice:t.nice??l.CONTINUOUS_SCALE_DEFAULTS.nice,zero:t.zero??l.CONTINUOUS_SCALE_DEFAULTS.zero,clamp:t.clamp??r!=="position",domainMin:t.domainMin??l.CONTINUOUS_SCALE_DEFAULTS.domainMin,domainMax:t.domainMax??l.CONTINUOUS_SCALE_DEFAULTS.domainMax,range:t.range??n??null,scheme:Og(e.container,t),interpolate:t.interpolate??l.CONTINUOUS_SCALE_DEFAULTS.interpolate,domainMid:t.domainMid??l.CONTINUOUS_SCALE_DEFAULTS.domainMid,symmetric:t.symmetric??l.isDefined(t.domainMid)}}case"datetime":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,domainMin:t.domainMin??l.DATETIME_SCALE_DEFAULTS.domainMin,domainMax:t.domainMax??l.DATETIME_SCALE_DEFAULTS.domainMax,nice:t.nice??l.DATETIME_SCALE_DEFAULTS.nice,reverse:t.reverse??l.DATETIME_SCALE_DEFAULTS.reverse,clamp:t.clamp??!1};case"discrete":return Xr(t,e.demands);case"palette":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType,palette:l.resolvePaletteConfig(e.container,t.palette,e.customPalettes),overrides:l.resolvePaletteOverrides(e.container,t.overrides,t.palette,e.customPalettes)};case"identity":return{type:t.type,scaledAesthetic:t.scaledAesthetic,scaleType:t.scaleType};default:throw new l.InternalError({message:`Unknown scale type: ${t.scaleType}`})}}function Vg(e,t){const{scales:r,layers:n,coords:a}=t,i=Dn(e,t),o=Ng(kg(r,n),i.demands),s=new Map;for(const u of o)s.set(u.scaledAesthetic,u);const c=[...s.values()].map(u=>{const d=Mg(i,u);return gr(i,d)});return a.coordType==="polar"?c.map(Pn):c}function Xr(e,t){const r=t?.bandPadding[e.scaledAesthetic];return{type:e.type,scaledAesthetic:e.scaledAesthetic,scaleType:e.scaleType,range:e.range??l.DISCRETE_SCALE_DEFAULTS.range,domain:e.domain??l.DISCRETE_SCALE_DEFAULTS.domain,padding:e.padding??r??l.DISCRETE_SCALE_DEFAULTS.padding,reverse:e.reverse??Dg(e.scaledAesthetic,t)}}var Pn=e=>e.scaleType==="discrete"?{...e,padding:0}:e;function Mg(e,t){return t.scaleType==="inferred"||t.scaleType==="discrete"||!e.demands.bandedAxes.includes(t.scaledAesthetic)?t:(e.container.diagnostics.addWarning({code:"UNSUPPORTED_SCALE_TYPE",message:`A geom drawn on '${t.scaledAesthetic}' needs it to be a band scale, but the spec declares a '${t.scaleType}' one; the band wins.`,context:{aesthetic:F(t.scaledAesthetic),scaleType:t.scaleType},suggestion:`Declare '${t.scaledAesthetic}' as a discrete scale, or omit it and let the geom's band be inferred.`}),l.discrete(t.scaledAesthetic,{..."reverse"in t&&t.reverse!==void 0&&{reverse:t.reverse}}))}function Dg(e,t){return e===t?.discreteCrossAxis?!0:l.DISCRETE_SCALE_DEFAULTS.reverse}function Pg({data:e,layers:t,mapping:r,demands:n},a){const i=F(a.scaledAesthetic),o=a.scaledAesthetic==="ySecondary"?_g(t,r):r[i];if(a.scaledAesthetic===n.discreteAxis||a.scaledAesthetic===n.discreteCrossAxis)return l.discrete(a.scaledAesthetic,a.options);const s=n.zeroAxes[a.scaledAesthetic];if(s!==void 0){const m=a.options;return l.continuous(a.scaledAesthetic,{...m,zero:!0,...!s.nice&&{nice:!1}})}const c=l.readVariableName(o);if(!l.isDefined(c)||!e.hasVariable(c)||e.size()===0)return l.continuous(a.scaledAesthetic,a.options);const u=e.getType(c),d=Ps[a.scaledAesthetic];switch(Cg[u][d]){case"discrete":return l.discrete(a.scaledAesthetic,a.options);case"palette":return l.palette(a.scaledAesthetic);case"datetime":return l.datetime(a.scaledAesthetic,a.options);case"continuous":return l.continuous(a.scaledAesthetic,a.options);default:return l.identity(a.scaledAesthetic)}}function Og(e,t){const r=t.scheme??l.CONTINUOUS_SCALE_DEFAULTS.scheme;return r===null?null:l.isDefined(t.range)?(e.diagnostics.addWarning({code:"CONFLICTING_COLOR_RAMP",message:`The color scale sets both a 'scheme' ('${r}') and an explicit 'range'; the range wins and the scheme is ignored.`,context:{aesthetic:F(t.scaledAesthetic),scaleType:t.scaleType},suggestion:"Set either a scheme or a range, not both."}),null):(!l.isDefined(t.domainMid)&&fg(r)&&e.diagnostics.addWarning({code:"DIVERGING_SCHEME_WITHOUT_MIDPOINT",message:`The color scale uses a diverging scheme ('${r}') without 'domainMid', so its neutral colour lands at the data midpoint rather than a meaningful centre.`,context:{aesthetic:F(t.scaledAesthetic),scaleType:t.scaleType,actual:r},suggestion:"Set 'domainMid' (e.g. 0) to centre the neutral colour."}),r)}function _g(e,t){const r=e.find(n=>n.yScaleType==="secondary");return r?r.mapping.y??t.y:t.y}function kg(e,t){return!t.some(r=>r.yScaleType==="secondary")||e.some(r=>r.scaledAesthetic==="ySecondary")?e:[...e,l.inferred("ySecondary")]}function Ng(e,t){return e.some(r=>r.scaledAesthetic==="color")?e:[...e,t.inferredColor?l.inferred("color"):l.palette("color")]}var ti=0;function $(){return ti+=1,`${Math.random().toString(36).slice(2,6)}${ti.toString(36)}`}var Bg={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0},"top-left":{x:-1,y:-1},"top-right":{x:1,y:-1},"bottom-left":{x:-1,y:1},"bottom-right":{x:1,y:1}},Fg=(e,t,r)=>{const n=Gg(e,t),a=Hg(n);return{differenceArrows:(n.differenceArrows??[]).map(i=>Wg(e,i,r)).filter(l.isDefined),shapes:(n.shapes??[]).map(i=>qg(e,i,a)).filter(l.isDefined),arrows:(n.arrows??[]).map(i=>Jg(e,i,r,a)).filter(l.isDefined),textAnnotations:(n.textAnnotations??[]).map(i=>zg(e,i,r,a)).filter(l.isDefined),stickers:(n.stickers??[]).map(i=>Kg(e,i,r,a)).filter(l.isDefined),images:(n.images??[]).map(i=>Xg(e,i,a)).filter(l.isDefined),pinnedNumbers:(n.pinnedNumbers??[]).map(i=>Yg(e,i,r)).filter(l.isDefined),comments:(n.comments??[]).map(i=>jg(e,i,r)).filter(l.isDefined)}},Gg=(e,t)=>{if(t===void 0)return{};if(!$g(t))return t;const r=new Set,n=a=>a.id===void 0?a:r.has(a.id)?(e.diagnostics.addWarning({code:"ANNOTATION_DUPLICATE_ID",message:`More than one annotation declares id "${a.id}" — giving this one a generated id, so references to "${a.id}" point at the first.`,context:{annotationId:a.id},suggestion:"Give each annotation its own id."}),{...a,id:$()}):(r.add(a.id),a);return{differenceArrows:t.differenceArrows?.map(a=>n(a)),shapes:t.shapes?.map(a=>n(a)),arrows:t.arrows?.map(a=>n(a)),textAnnotations:t.textAnnotations?.map(a=>n(a)),images:t.images?.map(a=>n(a)),stickers:t.stickers?.map(a=>n(a)),pinnedNumbers:t.pinnedNumbers?.map(a=>n(a)),comments:t.comments?.map(a=>n(a))}},$g=e=>{const t=new Set;for(const r of Ug(e))if(r.id!==void 0){if(t.has(r.id))return!0;t.add(r.id)}return!1},Ug=e=>[...e.differenceArrows??[],...e.shapes??[],...e.arrows??[],...e.textAnnotations??[],...e.images??[],...e.stickers??[],...e.pinnedNumbers??[],...e.comments??[]],Hg=e=>{const t=new Set,r=[e.differenceArrows,e.shapes,e.arrows,e.textAnnotations,e.images,e.stickers,e.pinnedNumbers,e.comments];for(const n of r)for(const a of n??[])a.id!==void 0&&t.add(a.id);return t},On=(e,t,r,n)=>{if(r.has(t))return!0;const a=n===void 0?"An annotation":`Annotation "${n}"`;return e.diagnostics.addWarning({code:"ANNOTATION_REF_NOT_FOUND",message:`${a} references id "${t}" but no annotation declares that id — dropping this annotation.`,context:{ref:t,...n!==void 0?{annotationId:n}:{}},suggestion:"Reference the explicit id of another annotation in the same spec, or set an id on the target."}),!1},zg=(e,t,r,n)=>{const a=er(e,t.at,r,n,t.id);return a===null?null:{id:t.id??$(),content:t.content,at:a,width:t.width,align:t.align??l.TEXT_ANNOTATION_DEFAULTS.align}},Wg=(e,t,r)=>{const n=dt(e,t.start,r),a=dt(e,t.end,r);return n===null||a===null?null:{id:t.id??$(),start:n,end:a,label:t.label,labelCrossPosition:t.labelCrossPosition??l.DIFFERENCE_ARROW_DEFAULTS.labelCrossPosition}},dt=(e,t,r)=>{const n=t.align!==void 0?{align:t.align}:{};return t.layerId===void 0?{anchorValue:t.anchorValue,groupValue:t.groupValue,crossValue:t.crossValue,...n}:r.some(a=>a.id===t.layerId)?{layerId:t.layerId,anchorValue:t.anchorValue,groupValue:t.groupValue,crossValue:t.crossValue,...n}:(e.diagnostics.addWarning({code:"UNKNOWN_LAYER_ID",message:`Annotation references layerId "${t.layerId}", which no layer carries — dropping this annotation.`,context:{layerId:t.layerId,available:r.map(a=>a.id)},suggestion:"Reference an existing layer id, or omit layerId to anchor against the data directly."}),null)},er=(e,t,r,n,a)=>{if(t.anchorType==="annotation")return On(e,t.ref,n,a)?t:null;if(t.anchorType==="panel"||t.anchorType==="axis"||t.anchorType==="selection")return t;const i=dt(e,t,r);return i===null?null:{anchorType:"observation",...i,...t.offset!==void 0?{offset:t.offset}:{}}},Kg=(e,t,r,n)=>{const a=er(e,t.at,r,n,t.id);return a===null?null:{id:t.id??$(),at:a,sticker:t.sticker}},Yg=(e,t,r)=>{const n=dt(e,t.at,r);return n===null?null:{id:t.id??$(),at:n}},jg=(e,t,r)=>{const n=dt(e,t.at,r);return n===null?null:{id:t.id??$(),at:n,content:t.content}},qg=(e,t,r)=>t.region.anchorType==="annotation"&&!On(e,t.region.ref,r,t.id)?null:{id:t.id??$(),kind:t.kind??l.SHAPE_DEFAULTS.kind,zOrder:t.zOrder??l.SHAPE_DEFAULTS.zOrder,region:Zg(t.region)},Xg=(e,t,r)=>t.region.anchorType==="annotation"&&!On(e,t.region.ref,r,t.id)?null:{id:t.id??$(),src:t.src,zOrder:t.zOrder??l.IMAGE_ANNOTATION_DEFAULTS.zOrder,region:t.region,fit:t.fit??l.IMAGE_ANNOTATION_DEFAULTS.fit},Zg=e=>e.anchorType!=="selection"||e.padding!==void 0?e:{...e,padding:l.SELECTION_PADDING_DEFAULT},ri=e=>{if(e.anchorType==="panel"||e.anchorType==="axis"||e.offset!==void 0||e.align===void 0)return e;const t=Bg[e.align];return t===void 0?e:{...e,offset:{x:t.x*4,y:t.y*4,unit:"px"}}},Jg=(e,t,r,n)=>{const a=er(e,t.start,r,n,t.id),i=er(e,t.end,r,n,t.id);return a===null||i===null?null:{id:t.id??$(),start:ri(a),end:ri(i),startArrowheadStyle:t.startArrowheadStyle??l.ARROW_DEFAULTS.startArrowheadStyle,endArrowheadStyle:t.endArrowheadStyle??l.ARROW_DEFAULTS.endArrowheadStyle}},Qg={parsingLocale:"en-US",legend:{position:"auto",display:"auto",align:"auto"},axes:{x:{isVisible:!0,label:null,position:"bottom",grid:{isVisible:null},ticks:{isVisible:!0,mode:"auto"}},y:{isVisible:!0,label:null,position:"right",grid:{isVisible:null},ticks:{isVisible:!1,mode:"auto"}}},panel:{overflow:{dataLabels:{x:"inside",y:"inside"},differenceArrows:{x:"outside",y:"outside"}}},headline:{show:"none",compareWith:"none",size:"auto",position:"above"},numberFormat:{decimals:"auto",abbreviation:"auto"},content:{title:null,isTitleVisible:!0,subtitle:null,isSubtitleVisible:!0,caption:null,isCaptionVisible:!1,source:null,isSourceVisible:!1,brandMark:{enabled:!1,placement:"footer",variant:"full"},isBrandMarkVisible:!1}};function ey(e){const t=(0,tt.merge)({},Qg,e);return t.content=ty(t.content,e?.content),t}var ty=(e,t)=>{const r=t?.brandMark?.enabled??t?.isBrandMarkVisible??e.brandMark.enabled,n={...e.brandMark,enabled:r};return{...e,brandMark:n,isBrandMarkVisible:r}},ry={xLimits:null,yLimits:null},Wt={theta:"x",startAngle:0,innerRadius:0};function Zr(e){const t=e??{type:"coord",coordType:"cartesian"},r=(0,qt.default)({},ry,t.params??{});switch(t.coordType){case"cartesian":case"flip":return{...t,params:r};case"polar":return{...t,params:{...r,theta:t.params?.theta??Wt.theta,startAngle:t.params?.startAngle??Wt.startAngle,innerRadius:(0,Ye.default)(t.params?.innerRadius??Wt.innerRadius,0,1)}}}}function ny(e,t,r){const n=[];for(const a of t){if(a.layerId!==void 0&&!r.some(i=>i.id===a.layerId)){e.diagnostics.addWarning({code:"UNKNOWN_LAYER_ID",message:`Highlight references layerId "${a.layerId}", which no layer carries — dropping this highlight.`,context:{layerId:a.layerId,available:r.map(i=>i.id)},suggestion:"Reference an existing layer id, or omit layerId to apply the highlight across all layers."});continue}n.push({type:"highlight",id:a.id??$(),predicate:a.predicate,scope:a.scope??"data-point",...a.layerId!==void 0?{layerId:a.layerId}:{}})}return n}var ay=class{constructor(){this.diagnostics=[],this.persistent=[]}addWarning(e,t={}){const r={...e,severity:"warning",kind:"user-input"};t.persistent?this.persistent.push(r):this.diagnostics.push(r)}addError(e){this.diagnostics.push({...e,severity:"error",kind:"user-input"})}reset(){this.diagnostics=[]}drain(){const e=this.persistent.length===0?this.diagnostics:[...this.persistent,...this.diagnostics];if(e.length===0)return{errors:[],warnings:[]};const t=ni(e.filter(n=>n.severity==="error")),r=ni(e.filter(n=>n.severity==="warning"));return this.diagnostics=[],{errors:t,warnings:r}}},iy=class{constructor(e,t){this.sink=e,this.baseContext=t}addWarning(e,t){this.sink.addWarning(this.stampBaseContext(e),t)}addError(e){this.sink.addError(this.stampBaseContext(e))}stampBaseContext(e){const t=e.context??{};return{...e,context:{...t,...this.baseContext}}}};function ni(e){const t=new Set;return e.filter(r=>{const n=JSON.stringify(r);return t.has(n)?!1:(t.add(n),!0)})}var oy={showDataLabels:!1,format:"absolute",showStackTotals:!1,showCategoryLabels:!1,labelSource:{variable:l.POSITION_VARIABLES.yRaw},position:"auto",justify:"end",align:"center",offset:4,categoryPosition:"inside",categoryJustify:"start",categoryAlign:"center",categoryOffset:4};function Os(e,t){const r=e??t,n=typeof r=="string"?r:r.type;if(n==="smooth"){const a=typeof r=="string"?void 0:r;return{type:"smooth",method:a?.method??"linear",order:a?.order??3,bandwidth:a?.bandwidth??.3}}return{type:n}}function Ne(e,t,r,n,a,i){const o=a!==void 0&&i!==void 0?new iy(a,{layerIndex:i}):a,s=e.get(n.geom),c=n.position??s.defaultPosition,u=cy({dataLabels:dy(e,t,n,c,r),geom:s,position:c,coordType:r,diagnostics:o});return ly({diagnostics:o,coordType:r,geom:s,position:c,dataLabels:u}),{id:n.id??$(),type:n.type,geom:n.geom,mapping:n.mapping??{},stat:Os(n.stat,"identity"),position:c,yScaleType:n.yScaleType??"primary",params:s.resolveParams({params:n.params,diagnostics:o}),transforms:n.transforms??[],interactive:n.interactive??s.defaultInteractive,dataLabels:u}}function sy(e,t,r,n,a){const i=n.map((o,s)=>Ne(e,t,r,o,a,s));return ks(e,i)}var _s=(e,t,r,n)=>n.label!==void 0?n.label:Ho({geom:e.get(t),position:r,mapping:n,purpose:"label"}),ks=(e,t)=>{const r=new Set;for(const n of t)n.position==="fill"&&r.add(n.yScaleType);return r.size===0?t:Oe(t,n=>{if(!r.has(n.yScaleType)||!e.has(n.geom)||!e.get(n.geom).positionRoles.some(o=>o.axis==="y"&&o.role==="scalar"))return n;const a=l.readConstantValue(n.mapping.y);if(!l.isStrictNumericDataValue(a))return n;const i=(0,tt.clamp)(a,0,1);return i===a?n:{...n,mapping:{...n.mapping,y:{value:i}}}})},ly=({diagnostics:e,coordType:t,geom:r,position:n,dataLabels:a})=>{if(e===void 0)return;const i=r.type==="bar"&&t!=="polar";if(a.showDataLabels&&!r.dataLabelCoordTypes.includes(t)){e.addWarning({code:"DATA_LABELS_UNSUPPORTED",message:`Data labels are not supported for geom '${r.type}' under '${t}' coords; none will render.`,suggestion:"Turn off showDataLabels for this layer."});return}a.showDataLabels&&a.position==="outside"&&i&&l.isStackedPosition(n)&&e.addWarning({code:"DATA_LABEL_PLACEMENT_COERCED",message:"Stacked bar segments only place data labels inside; position 'outside' will render as 'inside'.",context:{expected:"inside",actual:"outside"},suggestion:"Use position 'inside' or 'auto', or enable showStackTotals for a label above the stack."}),a.showStackTotals&&!(i&&n==="stack")&&e.addWarning({code:"DATA_LABEL_SETTING_IGNORED",message:"showStackTotals only applies to stacked cartesian bars; it will be ignored.",suggestion:"Turn off showStackTotals, or use a bar geom with position 'stack'."})},cy=({dataLabels:e,geom:t,position:r,coordType:n,diagnostics:a})=>{const{justify:i,showDataLabels:o}=e;if(i!=="panel-start"&&i!=="panel-end")return e;const s=uy(t,r,n);if(s===null)return e;const c=i==="panel-end"?"end":"start";return o&&a?.addWarning({code:"DATA_LABEL_PLACEMENT_COERCED",message:`${s}; justify '${i}' will render as '${c}'.`,context:{expected:c,actual:i},suggestion:`Use justify '${c}' for this layer.`}),{...e,justify:c}},uy=(e,t,r)=>r==="polar"?"Panel-edge anchors do not apply under polar coords":e.type==="bar"&&l.isStackedPosition(t)?"Stacked bar segments would all pin their labels to the same panel edge":null,dy=(e,t,r,n,a)=>{const i={...t,...r.mapping},o=_s(e,r.geom,n,i),s=e.get(r.geom);return{...(0,tt.merge)({},oy,s.resolveDataLabelDefaults?.(n)??{},s.dataLabels?.[a]??{},r.dataLabels??{}),labelSource:o}},my=e=>{const t={tokens:{},defaults:[],overrides:[]};for(const r of py(e))Object.assign(t.tokens,r.tokens),t.defaults.push(...r.defaults??[]),t.overrides.push(...r.overrides??[]);return t},py=e=>{const t=[],r=new Set,n=e===void 0?[]:[e];for(;n.length>0;){const a=n.pop();if(!(a===void 0||r.has(a))){r.add(a),t.push(a);for(const i of a.extends??[])n.push(i)}}return t.reverse()};function hy(e,t,r){const n=Zr(t.coords),a=sy(e.geomRegistry,t.mapping,n.coordType,t.layers,e.diagnostics),i=Vg(e,{data:t.data,scales:t.scales,layers:a,mapping:t.mapping,coords:n,customPalettes:r}),o=ey(t.config),s=ny(e,t.highlights,a),c=Fg(e,t.annotations,a),u=my(t.styles);return{data:t.data,mapping:t.mapping,layers:a,scales:i,transforms:t.transforms,highlights:s,styles:u,annotations:c,coords:n,config:o}}var Ns=class{constructor(e){this.container=e}compile({spec:e,dataset:t,customPalettes:r}){return hy(this.container,{...e,data:t},r)}},fy=()=>{let e={},t=null;return{reset:()=>{e={}},getDuration:r=>e[r]??0,wrap:(r,n)=>a=>{const i=t,o={childrenMs:0};t=o;const s=performance.now();try{return n(a)}finally{const c=performance.now()-s;e[r]=(e[r]??0)+c-o.childrenMs,i&&(i.childrenMs+=c),t=i}}}},gy=class{constructor(e){this.registry=e}compute(e,t){return this.registry.get(e.type).compute({data:t.data,mapping:t.mapping,spec:e,xScaleIsDiscrete:t.xScaleIsDiscrete})}},Tt={differenceArrow:"differenceArrows",shape:"shapes",arrow:"arrows",text:"textAnnotations",image:"images",sticker:"stickers",pinnedNumber:"pinnedNumbers",comment:"comments"},yy={differenceArrow(e){return{type:"annotation",kind:"differenceArrow",annotation:e}},shape(e){return{type:"annotation",kind:"shape",annotation:e}},arrow(e){return{type:"annotation",kind:"arrow",annotation:e}},text(e){return{type:"annotation",kind:"text",annotation:e}},image(e){return{type:"annotation",kind:"image",annotation:e}},sticker(e){return{type:"annotation",kind:"sticker",annotation:e}},pinnedNumber(e){return{type:"annotation",kind:"pinnedNumber",annotation:e}},comment(e){return{type:"annotation",kind:"comment",annotation:e}}},Bs=Object.keys(Tt),vy=e=>Object.hasOwn(Tt,e),Lt=(e,t)=>{for(const r of Bs){const n=by(e,r,t);if(n)return n}return null},Et=(e,t)=>e[Tt[t]],_n=(e,t,r)=>({...e,[Tt[t]]:r}),Fs=(e,t)=>{const r=Et(e,t.kind);return _n(e,t.kind,[...r.slice(0,t.index),...r.slice(t.index+1)])},by=(e,t,r)=>{const n=Et(e,t),a=n.findIndex(o=>o.id===r),i=n[a];return i===void 0?null:{kind:t,index:a,annotation:i}},ai=Object.freeze({light:"#898373",dark:"#9F9886"}),Sy={graphBackground:l.DEFAULT_GRAPH_BACKGROUND,graphBorder:Object.freeze({light:"rgba(58, 56, 51, 0.15)",dark:"rgba(237, 231, 218, 0.15)"}),geom:l.DEFAULT_GEOM_COLOR,geomBorder:Object.freeze({light:"rgba(58, 56, 51, 0.55)",dark:"rgba(237, 231, 218, 0.55)"}),textPrimary:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),textSecondary:ai,ruleLine:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),gridLine:Object.freeze({light:"#E1DAC9",dark:"#373531"}),hoverAffordance:l.DEFAULT_HOVER_AFFORDANCE_COLOR,hoverGuideFill:Object.freeze({light:"#E7E1D2",dark:"#2B2A27"}),hoverGuideLine:Object.freeze({light:"#D5CDBA",dark:"#3B3934"}),editOutlineHover:Object.freeze({light:"#C4C4C4",dark:"rgba(255, 255, 255, 0.5)"}),editOutlineSelected:Object.freeze({light:"#3D70FF",dark:"#3D70FF"}),tooltipBackground:Object.freeze({light:"#FCFCF9",dark:"#262522"}),tooltipBorder:Object.freeze({light:"rgba(58, 56, 51, 0.15)",dark:"rgba(237, 231, 218, 0.15)"}),tooltipPrimaryRow:Object.freeze({light:"#F5F1E9",dark:"#2E2C29"}),annotationShape:Object.freeze({light:"#3b82f6",dark:"#60a5fa"}),annotationArrow:Object.freeze({light:"#3A3833",dark:"#EDE7DA"}),differenceLabelBackground:l.DEFAULT_GRAPH_BACKGROUND,trendPositive:{light:"#06B299",dark:"#0AC600"},trendNegative:{light:"#E14B49",dark:"#CB3333"},trendNeutral:ai},Gs=l.walkStyleTargets();for(const e of Gs){Object.freeze(e.select);for(const t of Object.values(e.declarations))typeof t=="object"&&Object.freeze(t);Object.freeze(e.declarations),e.when!==void 0&&Object.freeze(e.when),Object.freeze(e)}var mt=Object.freeze({tokens:Object.freeze(Sy),defaults:Object.freeze(Gs),overrides:Object.freeze([])}),Ay=class extends _e{constructor(e){super(),this.container=e}compile(e){const t=super.compile(e);for(const r of Oy(e.styles,t))this.container.diagnostics.addWarning(r);for(const r of ky(e.styles))this.container.diagnostics.addWarning(r);for(const r of Ny(e.styles))this.container.diagnostics.addWarning(r);for(const r of t)for(const n of r.styles.warnings)this.container.diagnostics.addWarning(n);return t}dependencies(e){return[e.styles,e.config.parsingLocale]}compileLayer(e,t){const r=Ws({layer:e,layerIndex:t.layers.indexOf(e),styles:t.styles,parsingLocale:t.config.parsingLocale});return{...e,styles:r}}},xy=class extends l.Stage{constructor(e){super(),this.container=e}compile(e){const t=super.compile(e);for(const r of _y(e.styles,e.annotations))this.container.diagnostics.addWarning(r);for(const r of t.warnings)this.container.diagnostics.addWarning(r);return t}dependencies(e){return[e.styles]}run(e){return $s(e.styles)}},Iy=new Set(l.STYLE_PROPERTY_NAMES),Ty=(e,t,r="en-US")=>Ws({layer:e,layerIndex:0,styles:{tokens:t.tokens??{},defaults:t.defaults??[],overrides:t.overrides??[]},parsingLocale:r}),$s=e=>{const t=[],r={...mt.tokens,...e.tokens},n={...Ey(),warnings:t},a=(i,o,s,c)=>{if(yr(i))return;const u=i.id===void 0?{}:{styleEntryId:i.id},d=i.select.target,m=wy(i.select);if(m.status==="unknown-target"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} targets unknown '${String(d)}'.`,context:{param:"target",actual:String(d),...u},suggestion:`Set 'target' to one of ${[...kn].map(y=>`'${y}'`).join(", ")}.`});return}if(m.status==="unknown-partition"){const{key:y,value:A,node:I}=m,x=ii(I,y);t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} addresses unknown ${y} '${A}'.`,context:{param:y,actual:A,...u},suggestion:x.length===0?`Remove '${y}' — this target has none.`:`Set '${y}' to one of ${x.map(T=>`'${T}'`).join(", ")}, or omit it.`});return}if(m.status==="namespace"){const y=ii(m.node,"part");t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} ignored: ${i.select.target} entries need a part.`,context:{param:"part",actual:String(i.select.part),...u},suggestion:`Set 'part' to one of ${y.map(A=>`'${A}'`).join(", ")}.`});return}const p=m.node;if(i.when!==void 0&&!Ry(p)){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} ignored: chrome entries take no conditions.`,context:{param:"when",...u},suggestion:"Remove the 'when' clause — chrome is chart-scoped, with no observations or states."});return}const h=p.options??[],f=i.select;if(f.layer!==void 0){if(!h.includes("layer")){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} does not take a layer.`,context:{param:"layer",actual:ae(f.layer),...u},suggestion:"Remove 'layer' — this target is not layer-scoped."});return}if(typeof f.layer!="string"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} addresses an invalid layer ${ae(f.layer)}.`,context:{param:"layer",actual:ae(f.layer),...u},suggestion:"Set 'layer' to the id of a rule layer in the spec, or omit it to address every rule label."});return}}if(f.annotation!==void 0){if(!h.includes("annotation")){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} does not take an annotation.`,context:{param:"annotation",actual:ae(f.annotation),...u},suggestion:"Remove 'annotation' — this target is not annotation-scoped."});return}if(typeof f.annotation!="string"){t.push({code:"INVALID_STYLE_RULE",message:`Style ${s} addresses an invalid annotation ${ae(f.annotation)}.`,context:{param:"annotation",actual:ae(f.annotation),...u},suggestion:"Set 'annotation' to the id of an annotation in the spec, or omit it to address every one of the kind."});return}}const g=Ks({declarations:i.declarations,vocabulary:p.vocabulary,tokens:r,location:s,origin:c,warnings:t,entryTarget:i.select.target});if(Object.keys(g).length===0)return;const v=p.select.target;Us(v)&&n[v][o].push({select:i.select,declarations:g,origin:c})};return mt.defaults.forEach((i,o)=>{a(i,"defaults",`builtin[${o}]`,{list:"builtin"})}),e.defaults.forEach((i,o)=>{a(i,"defaults",`defaults[${o}]`,{list:"defaults",index:o,...i.id===void 0?{}:{id:i.id}})}),e.overrides.forEach((i,o)=>{a(i,"overrides",`overrides[${o}]`,{list:"overrides",index:o,...i.id===void 0?{}:{id:i.id}})}),n},Ly=()=>{const e=new Set,t=r=>{if(e.add(r.select.target),r.children!==void 0)for(const n of Object.values(r.children))t(n)};for(const r of Object.values(l.STYLE_TARGETS))t(r);return e},kn=Ly(),Us=e=>e!=="geom"&&kn.has(e),Ey=()=>{const e={};for(const t of kn)Us(t)&&(e[t]={defaults:[],overrides:[]});return e},ii=(e,t)=>{if(e.children===void 0)return[];const r=[];for(const n of Object.values(e.children)){const a=n.select[t];a!==void 0&&r.push(a)}return r},oi=e=>Object.keys(e.vocabulary).length===0&&e.children!==void 0,wy=e=>{const t=l.findStyleTarget(e);if(t!==void 0)return oi(t)?{status:"namespace",node:t}:{status:"found",node:t};const r=l.findStyleTarget({target:e.target});if(r===void 0)return{status:"unknown-target"};let n=r;for(const a of l.STYLE_SELECT_KEYS){const i=e[a];if(i===void 0)continue;const o=n.children===void 0?void 0:Object.values(n.children).find(s=>s.select[a]===i);if(o===void 0)return{status:"unknown-partition",key:a,value:i,node:n};n=o}return oi(n)?{status:"namespace",node:n}:{status:"found",node:n}},Ry=e=>{const t=e.options??[];return t.includes("where")||t.includes("state")},Cy=(e,t)=>{const r=e==="geom"||e==="annotation"?l.STYLE_TARGETS[e]:void 0;if(r?.children===void 0)return;const n=Object.entries(r.children).find(([,a])=>a.vocabulary[t]!==void 0)?.[0];return n===void 0?void 0:`style.${e}.${n}`},yr=e=>e.select.target==="geom",Vy=e=>e.kind===void 0?l.STYLE_TARGETS.geom.vocabulary:l.findStyleTarget({target:"geom",kind:e.kind})?.vocabulary??l.STYLE_TARGETS.geom.vocabulary,My=e=>l.findStyleTarget({target:"geom",kind:e})?.vocabulary??l.STYLE_TARGETS.geom.vocabulary,Dy=(e,t)=>{const r={};for(const n of Object.keys(e)){const a=e[n];a===void 0||t[n]===void 0||(r[n]=a)}return r},Hs=(e,t,r,n,a,i)=>{const o=Ks({declarations:e.declarations,vocabulary:Vy(e.select),tokens:r,location:n,origin:a,warnings:i,entryTarget:"geom"});return Dy(o,My(t))},Py=(e,t,r)=>{const n=[];return mt.defaults.forEach((a,i)=>{if(!yr(a))return;const o=a.select.kind;if(o!==void 0&&o!==e)return;const s={list:"builtin"},c=Hs(a,e,t,`builtin[${i}]`,s,r);Object.keys(c).length!==0&&n.push({declarations:c,...a.when?.state===void 0?{}:{state:a.when.state},origin:s})}),n},Nn=(e,t)=>{e.defaults.forEach((r,n)=>t(r,"defaults",n)),e.overrides.forEach((r,n)=>t(r,"overrides",n))},Oy=(e,t)=>{const r=new Set(t.map(a=>a.id)),n=[];return Nn(e,(a,i,o)=>{const s=a.select;if(s.target!=="geom"&&s.target!=="ruleLabel")return;const c=s.layer;c===void 0||typeof c!="string"||r.has(c)||n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets unknown layer '${c}'.`,context:{param:"layer",actual:c,...a.id===void 0?{}:{styleEntryId:a.id}},suggestion:"Set 'layer' to the id of a layer in the spec."})}),n},_y=(e,t)=>{const r=new Map(Bs.flatMap(a=>t[Tt[a]].map(i=>[i.id,a]))),n=[];return Nn(e,(a,i,o)=>{const s=a.select;if(s.target!=="annotation")return;const c=s.annotation;if(c===void 0||typeof c!="string")return;const u={param:"annotation",actual:c,...a.id===void 0?{}:{styleEntryId:a.id}},d=r.get(c);if(d===void 0){n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets unknown annotation '${c}'.`,context:u,suggestion:"Set 'annotation' to the id of an annotation in the spec."});return}if(d==="sticker"){n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets sticker '${c}', which has no style vocabulary.`,context:u,suggestion:"Remove the entry — stickers take no style declarations."});return}const m=s.kind;m!==void 0&&m!==d&&n.push({code:"INVALID_STYLE_RULE",message:`Style ${i}[${o}] targets ${d} '${c}' with an entry addressing kind '${String(m)}'.`,context:u,suggestion:`Set 'kind' to '${d}', or omit it to address the annotation with the shared vocabulary.`})}),n},ky=e=>{const t=[];return Nn(e,(r,n,a)=>{if(!yr(r))return;const i=r.when?.state;i===void 0||zs(i)||t.push({code:"INVALID_STYLE_RULE",message:`Style ${n}[${a}] scopes to unknown state '${i}'.`,context:{param:"state",actual:String(i),...r.id===void 0?{}:{styleEntryId:r.id}},suggestion:`Set 'state' to one of ${l.STYLE_STATES.map(o=>`'${o}'`).join(", ")}.`})}),t},zs=e=>l.STYLE_STATES.includes(e),Ny=e=>{const t=[];for(const[r,n]of Object.entries(e.tokens))l.isUsableTokenValue(n)||t.push({code:"INVALID_STYLE_RULE",message:`Style token '${r}' has an invalid value: ${ae(n)}.`,context:{param:"tokens",actual:ae(n)},suggestion:`Set '${r}' to a non-empty color string or a { light, dark } pair of colors.`});return t},ae=e=>typeof e=="object"&&e!==null?JSON.stringify(e):String(e),Ws=e=>{const{layer:t,layerIndex:r,styles:n,parsingLocale:a}=e,i=nt(t,a),o=[],s={...mt.tokens,...n.tokens},c=(u,d)=>{const m=[];return u.forEach((p,h)=>{if(!yr(p))return;const f=p.select.kind;if(f!==void 0&&f!==t.geom||p.select.layer!==void 0&&p.select.layer!==t.id)return;const g=p.when?.state;if(g!==void 0&&!zs(g))return;const v={list:d,index:h,...p.id===void 0?{}:{id:p.id}},y=p.when?.where;if(y!==void 0){const I=ce(y,t.data,"style-rule");if(I.length>0){for(const x of I)o.push({...x,code:"INVALID_STYLE_RULE",message:`Style ${d}[${h}]: ${x.message}`,context:{...x.context,layerIndex:r,...p.id===void 0?{}:{styleEntryId:p.id}}});return}}const A=Hs(p,t.geom,s,`${d}[${h}]`,v,o);Object.keys(A).length!==0&&m.push({declarations:A,...y===void 0?{}:{matches:le(y,i)},...g===void 0?{}:{state:g},origin:v})}),m};return{defaults:[...Py(t.geom,s,o),...c(n.defaults,"defaults")],overrides:c(n.overrides,"overrides"),warnings:o}},Ks=e=>{const{declarations:t,vocabulary:r,tokens:n,location:a,origin:i,warnings:o,entryTarget:s}=e,c={},u=i.list==="builtin"||i.id===void 0?{}:{styleEntryId:i.id},d=(f,g)=>{c[f]=g},m=(f,g,v)=>{o.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: expected ${g}, got ${ae(v)}.`,context:{param:f,expected:g,actual:ae(v),...u},suggestion:`Set '${f}' to ${g}.`})},p=(f,g)=>{o.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: unknown token '${g}'.`,context:{param:f,actual:g,...u},suggestion:`Declare '${g}' in the stylesheet's tokens.`})},h=f=>{const g=Iy.has(f),v=Cy(s,f),y=v===void 0?`Declare '${f}' on a target whose vocabulary carries it.`:`Declare '${f}' on an entry whose kind supports it (e.g. ${v}).`;o.push({code:"INVALID_STYLE_RULE",message:`Style ${a} declaration '${f}' ignored: ${g?"not in this entry's vocabulary":"not a style property"}.`,context:{param:f,...u},suggestion:g?y:`Remove the unknown declaration '${f}'.`})};for(const f of Object.keys(t)){const g=t[f];if(g===void 0)continue;const v=r[f];if(v===void 0){h(f);continue}const y=l.STYLE_DOMAINS[v](g,n);switch(y.status){case"accepted":d(f,y.value);break;case"rejected":m(f,y.expected,y.actual);break;case"unknownToken":p(f,y.token);break;case"dropped":break;default:break}}return c},By=({layer:e})=>{if(e.position==="stack")return;const t=l.readVariableName(e.mapping.y);if(t===null)return;let r=0,n=0;for(const a of e.data){const i=a[t];l.isStrictNumericDataValue(i)&&(r+=i,n+=Math.abs(i))}return{grandTotal:r,absoluteGrandTotal:n}},Fy=({layer:e,mainAxis:t})=>{if(e.position!=="stack")return;const r=l.readVariableName(e.mapping.x);if(r===null||!e.data.hasVariable(l.POSITION_VARIABLES.yMin)||!e.data.hasVariable(l.POSITION_VARIABLES.yMax))return;const n=s=>t==="y"?s.xMax:s.yMax,a=s=>t==="y"?s.xMin:s.yMin,i=new Map;for(const s of e.data){const c=s[r],u=B(s),d=_(s),m=z(s),p=W(s),h=hn(s);if(!l.isDefined(c)||!l.isDefined(u)||!l.isDefined(d)||!l.isDefined(m)||!l.isDefined(p)||!l.isDefined(h))continue;const f=h>=0;if(Math.abs(h)===0)continue;const g=wn(s,r),v={xMin:m,xMax:p,yMin:u,yMax:d},y=i.get(g);if(y===void 0){i.set(g,{total:h,topPositive:f?v:null,bottomNegative:f?null:v});continue}y.total+=h,f?(y.topPositive===null||n(v)>n(y.topPositive))&&(y.topPositive=v):(y.bottomNegative===null||a(v)<a(y.bottomNegative))&&(y.bottomNegative=v)}const o=[];for(const[s,c]of i){const u=c.topPositive??c.bottomNegative;u!==null&&o.push({xKey:s,total:c.total,anchor:{xMin:u.xMin,xMax:u.xMax,yMin:u.yMin,yMax:u.yMax,direction:c.topPositive!==null?"positive":"negative"}})}return o},Gy=class extends _e{constructor(e){super(),this.container=e}dependencies(e){return[e.coordSystem]}compileLayer(e,t){const r=this.container.geomRegistry.get(e.geom),n={},a=t.coordSystem.type==="cartesian"?t.coordSystem.mainAxis:"x";if(r.summaries.stackTotals){const i=Fy({layer:e,mainAxis:a});i!==void 0&&(n.stackTotals=i)}if(r.summaries.grandTotal){const i=By({layer:e});i!==void 0&&(n.grandTotal=i.grandTotal,n.absoluteGrandTotal=i.absoluteGrandTotal)}return{...e,summary:n}}},Ys=class extends l.Stage{constructor(e){super(),this.registry=e}key(e){return e.data}dependencies(e){return[e.transforms]}run(e){return e.transforms.reduce((t,r)=>this.registry.get(r.transformType).apply(t,r),e.data)}},si={color:"categorical",size:"numeric",alpha:"numeric",strokeWidth:"numeric",lineType:"categorical"},$y=["color","size","alpha","strokeWidth","lineType"],Uy=class extends _e{dependencies(e){return $y.map(t=>e.scales[t])}compileLayer(e,t){let r=e.data;const n=Object.entries(l.VISUAL_VARIABLES);for(const[a,i]of n){const o=l.readConstantValue(e.mapping[a]);if(o!==void 0){r=r.addConstantVariable(i,si[a],o);continue}const s=l.readVariableName(e.mapping[a]),c=t.scales[a];!s||!c||c.kind!=="visual"||(r=r.deriveVariableFrom(s,i,si[a],Hy(c)))}return{...e,data:r}}},Hy=e=>t=>l.isDefined(t)?e.map(t):null;function js(e=new hr){return{diagnostics:new ay,geomRegistry:e}}var qs=class{constructor(e,t,r,n,a,i,o,s,c,u,d,m,p,h,f,g){this.container=e,this.dataCompiler=t,this.specCompiler=r,this.transformCompiler=n,this.constantMappingCompiler=a,this.layerPhasedCompiler=i,this.scaleCompiler=o,this.coordCompiler=s,this.positionMapperCompiler=c,this.visualMapperCompiler=u,this.guideCompiler=d,this.summarizeCompiler=m,this.stylesCompiler=p,this.chromeStylesCompiler=h,this.highlightsCompiler=f,this.annotationsCompiler=g,this.stageTimer=l.IS_DEV?fy():null,this.lastCompile=null,this.lastDiagnostics=null,this.lastData=void 0,this.lastCustomPalettes={},this.stages=[{name:"data",getStats:()=>this.dataCompiler.stats},{name:"transform",getStats:()=>this.transformCompiler.stats},{name:"constantMapping",getStats:()=>this.constantMappingCompiler.stats},{name:"layer",getStats:()=>this.layerPhasedCompiler.stats},{name:"coordSetup",getStats:()=>this.coordCompiler.setupStats},{name:"scale",getStats:()=>this.scaleCompiler.stats},{name:"positionMapper",getStats:()=>this.positionMapperCompiler.stats},{name:"visualMapper",getStats:()=>this.visualMapperCompiler.stats},{name:"coordTransform",getStats:()=>this.coordCompiler.transformStats},{name:"summarize",getStats:()=>this.summarizeCompiler.stats},{name:"guide",getStats:()=>this.guideCompiler.stats},{name:"styles",getStats:()=>this.stylesCompiler.stats},{name:"chromeStyles",getStats:()=>this.chromeStylesCompiler.stats},{name:"highlights",getStats:()=>this.highlightsCompiler.stats},{name:"annotations",getStats:()=>this.annotationsCompiler.stats}],l.IS_DEV&&this.setupStageTiming()}compile(e){try{const t=this.runCompile(()=>(this.lastData=e.data,this.lastCustomPalettes=e.customPalettes??{},this.runPipeline({spec:this.specCompiler.compile({spec:e.spec,customPalettes:this.lastCustomPalettes,dataset:this.dataCompiler.compile(e.data)}),colorScheme:e.colorScheme??li})));return this.toOkResult(t)}catch(t){return this.toErrorResult(t)}}recompile(e){try{const t=this.runCompile(()=>{const r=e.colorScheme??li;if(e.data===void 0)return this.runPipeline({spec:e.spec,colorScheme:r});this.lastData=e.data;const n=this.dataCompiler.compile(e.data),a=this.reResolveInferredScalesIfNeeded(e.spec.data,w(e.spec,{data:n}));return this.runPipeline({spec:a,colorScheme:r})});return this.toOkResult(t)}catch(t){return this.toErrorResult(t)}}getCacheStats(){const e={};for(const{name:t,getStats:r}of this.stages)e[t]={...r()};return e}getLastCompile(){return this.lastCompile}getDiagnostics(){return this.lastDiagnostics}reResolveInferredScalesIfNeeded(e,t){if(e.size()!==0||t.data.size()===0||t.scales.filter(n=>n.inferredFrom!==void 0).length===0)return t;const r=Dn(this.container,{data:t.data,layers:t.layers,mapping:t.mapping,customPalettes:this.lastCustomPalettes});return w(t,{scales:Oe(t.scales,n=>{const a=n.inferredFrom;if(a===void 0)return n;const i=gr(r,a);return t.coords.coordType==="polar"?Pn(i):i})})}runCompile(e){this.container.diagnostics.reset();const t=this.trackCompile(e);return this.lastDiagnostics=this.container.diagnostics.drain(),t}toOkResult(e){return{ok:!0,scene:e,warnings:this.lastDiagnostics?.warnings??[]}}toErrorResult(e){const t=this.container.diagnostics.drain();return this.lastDiagnostics=t,{ok:!1,errors:t.errors.length>0?t.errors:[Fo(e)],warnings:t.warnings}}setupStageTiming(){this.stageTimer&&(this.dataCompiler.compile=this.stageTimer.wrap("data",this.dataCompiler.compile.bind(this.dataCompiler)),this.transformCompiler.compile=this.stageTimer.wrap("transform",this.transformCompiler.compile.bind(this.transformCompiler)),this.constantMappingCompiler.compile=this.stageTimer.wrap("constantMapping",this.constantMappingCompiler.compile.bind(this.constantMappingCompiler)),this.layerPhasedCompiler.compile=this.stageTimer.wrap("layer",this.layerPhasedCompiler.compile.bind(this.layerPhasedCompiler)),this.coordCompiler.setup=this.stageTimer.wrap("coordSetup",this.coordCompiler.setup.bind(this.coordCompiler)),this.scaleCompiler.compile=this.stageTimer.wrap("scale",this.scaleCompiler.compile.bind(this.scaleCompiler)),this.positionMapperCompiler.compile=this.stageTimer.wrap("positionMapper",this.positionMapperCompiler.compile.bind(this.positionMapperCompiler)),this.visualMapperCompiler.compile=this.stageTimer.wrap("visualMapper",this.visualMapperCompiler.compile.bind(this.visualMapperCompiler)),this.coordCompiler.transform=this.stageTimer.wrap("coordTransform",this.coordCompiler.transform.bind(this.coordCompiler)),this.summarizeCompiler.compile=this.stageTimer.wrap("summarize",this.summarizeCompiler.compile.bind(this.summarizeCompiler)),this.guideCompiler.compile=this.stageTimer.wrap("guide",this.guideCompiler.compile.bind(this.guideCompiler)),this.stylesCompiler.compile=this.stageTimer.wrap("styles",this.stylesCompiler.compile.bind(this.stylesCompiler)),this.chromeStylesCompiler.compile=this.stageTimer.wrap("chromeStyles",this.chromeStylesCompiler.compile.bind(this.chromeStylesCompiler)),this.highlightsCompiler.compile=this.stageTimer.wrap("highlights",this.highlightsCompiler.compile.bind(this.highlightsCompiler)),this.annotationsCompiler.compile=this.stageTimer.wrap("annotations",this.annotationsCompiler.compile.bind(this.annotationsCompiler)))}trackCompile(e){if(!l.IS_DEV)return e();this.stageTimer?.reset();const t=this.getCacheStats(),r=performance.now();try{return e()}finally{const n=performance.now()-r,a={},i={};for(const{name:o,getStats:s}of this.stages){const c=s();a[o]={hits:c.hits-t[o].hits,misses:c.misses-t[o].misses},i[o]=this.stageTimer?.getDuration(o)??0}this.lastCompile={stages:a,durationMs:n,stageDurationsMs:i}}}runPipeline({spec:e,colorScheme:t}){return{...ur({spec:e}).pipe(({spec:r})=>({spec:w(r,{data:this.transformCompiler.compile({data:r.data,transforms:r.transforms})})})).pipe(({spec:r})=>{const n=this.constantMappingCompiler.compile({data:r.data,mapping:r.mapping});return{spec:w(r,{data:n.data,mapping:n.mapping})}}).pipe(({spec:r})=>({layers:this.layerPhasedCompiler.compile({data:r.data,layers:r.layers,mapping:r.mapping,coords:r.coords,scales:r.scales})})).pipe(({spec:r,layers:n})=>this.coordCompiler.setup({coordSpec:r.coords,scales:r.scales,layers:n})).pipe(({layers:r,scales:n})=>({scales:this.scaleCompiler.compile({layers:r,scales:n,colorScheme:t})})).pipe(({spec:r})=>({config:r.config})).pipe(({layers:r,scales:n})=>({layers:this.positionMapperCompiler.compile({layers:r,scales:n})})).pipe(({layers:r,scales:n})=>({layers:this.visualMapperCompiler.compile({layers:r,scales:n})})).pipe(({spec:r,layers:n,coordSystem:a})=>({layers:this.coordCompiler.transform({coordSpec:r.coords,coordSystem:a,layers:n})})).pipe(({layers:r,coordSystem:n})=>({layers:this.summarizeCompiler.compile({layers:r,coordSystem:n})})).pipe(({spec:r,scales:n,layers:a,coordSystem:i})=>({guides:this.guideCompiler.compile({scales:n,config:r.config,layers:a,coordSystem:i,originalData:this.lastData})})).pipe(({spec:r,layers:n})=>({layers:this.stylesCompiler.compile({layers:n,styles:r.styles,config:r.config})})).pipe(({spec:r})=>({chrome:this.chromeStylesCompiler.compile({styles:r.styles,annotations:r.annotations})})).pipe(({spec:r,layers:n})=>({layers:this.highlightsCompiler.compile({layers:n,highlights:r.highlights,config:r.config})})).pipe(({spec:r,layers:n,coordSystem:a,scales:i})=>({annotations:this.annotationsCompiler.compile({annotations:r.annotations,layers:n,coordSystem:a,scales:i,config:r.config})})).result(),spec:e}}},zy=["data","transform","constantMapping","layer","coordSetup","scale","positionMapper","visualMapper","coordTransform","summarize","guide","styles","chromeStyles","highlights","annotations"],li="light",Wy=({plugins:e=[]}={})=>{const t=xs(e),{geomRegistry:r,statRegistry:n,transformRegistry:a}=Uf(t),i=js(r),o=new Rg(i),s=new Ys(a);for(const c of t.warnings)i.diagnostics.addWarning(c,{persistent:!0});return new qs(i,new l.DataCompiler,new Ns(i),s,new up,new df(i,s,n,new nf(i,s,new gy(n),new kp,new Op(i),new Wf(new Jf))),new dg(i,o),new pp(new Cp),new ug(i),new Uy,new jh(i),new Gy(i),new Ay(i),new xy(i),new Jh(i),new Xm(i))};function Xs(e,t){return e.geom===t}function Zs(...e){let t={},r;const[n,...a]=e;l.isDefined(n)&&!Ky(n)?(t=n,r=a):r=e;const i={mapping:t,layers:[],scales:[],transforms:[],highlights:[],config:{}};return r.reduce((o,s)=>Qs(o,s),i)}function Js(e,...t){return t.reduce((r,n)=>Qs(r,n),e)}function Ky(e){return typeof e=="object"&&e!==null&&"type"in e}function Qs(e,t){switch(t.type){case"scale":return{...e,scales:[...e.scales,t]};case"coord":return{...e,coords:t};case"config":return{...e,config:(0,qt.default)({},e.config,t.config)};case"layer":return{...e,layers:[...e.layers,t]};case"transform":return{...e,transforms:[...e.transforms,t]};case"mapping":return{...e,mapping:{...e.mapping,...t.mapping}};case"highlight":return{...e,highlights:[...e.highlights,t]};case"styles":return{...e,styles:e.styles===void 0?t:{...t,extends:[e.styles,...t.extends??[]]}};case"annotation":return Yy(e,t);default:throw new l.InternalError({message:`Unknown spec item type: ${t.type}`})}}function Yy(e,t){const r={...e.annotations};switch(t.kind){case"differenceArrow":r.differenceArrows=[...r.differenceArrows??[],t.annotation];break;case"shape":r.shapes=[...r.shapes??[],t.annotation];break;case"arrow":r.arrows=[...r.arrows??[],t.annotation];break;case"text":r.textAnnotations=[...r.textAnnotations??[],t.annotation];break;case"image":r.images=[...r.images??[],t.annotation];break;case"sticker":r.stickers=[...r.stickers??[],t.annotation];break;case"pinnedNumber":r.pinnedNumbers=[...r.pinnedNumbers??[],t.annotation];break;case"comment":r.comments=[...r.comments??[],t.annotation];break;default:throw new Error(`Unknown annotation kind: ${t.kind}`)}return{...e,annotations:r}}function jy(e){const t=e?.plugins??[],r=Xy(t);return{geom:{...l.geom,...r.geom},stat:{...l.stat,...r.stat},transform:{...l.transform,...r.transform},scale:l.scale,coord:l.coord,createSpec:Zs,pipe:Js,plugins:t}}var qy=e=>(t={})=>l.buildLayerSpec(e,t);function Xy(e){const{geoms:t,stats:r,transforms:n}=xs(e),a={};for(const s of t)a[s.type]=qy(s.type);const i={};for(const s of r)i[s.type]=()=>({type:s.type});const o={};for(const s of n)o[s.transformType]=c=>({type:"transform",transformType:s.transformType,options:c?.options});return{geom:a,stat:i,transform:o}}var Or="…",el=(e,t,r)=>{if(t<=0||e.length===0)return"";if(r(e)<=t)return e;if(r(Or)>t)return"";let n=0,a=e.length-1,i=0;for(;n<=a;){const o=n+a>>>1;r(e.slice(0,o)+Or)<=t?(i=o,n=o+1):a=o-1}return e.slice(0,i)+Or};var U={timeZone:"UTC"},G=e=>t=>{if(!l.isStrictTemporalDataValue(t))return"–";try{return e(t)}catch{return"n/a"}},Te=e=>t=>l.isStrictNumericDataValue(t)?e(t):"–",Bn=e=>t=>l.isStrictCategoricalDataValue(t)?t:"–",Zy=zr.default.humanizer({language:"en",spacer:"",delimiter:" ",languages:{en:{y:()=>"y",mo:()=>"mo",w:()=>"w",d:()=>"d",h:()=>"h",m:()=>"m",s:()=>"s",ms:()=>"ms"}}}),tl=({valueFormat:e,locale:t,numberFormat:r,intlOptions:n})=>Te(a=>{const i=typeof r.decimals=="number"?r.decimals:2,o=$n(a,i),{base:s,suffix:c}=Gn(a,r.abbreviation),u={...o,...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return`${Intl.NumberFormat(t,u).format(s)}${c}`}),rl=({locale:e,numberFormat:t,intlOptions:r})=>Te(n=>{const{base:a,suffix:i}=Gn(n,t.abbreviation),o={...$n(a,t.decimals),...r};return`${Intl.NumberFormat(e,o).format(a)}${i}`}),Fn=e=>Te(t=>Zy(t)),nl=({locale:e,intlOptions:t})=>Te(r=>Intl.NumberFormat(e,{maximumFractionDigits:0,...t}).format(r)),al=({locale:e,numberFormat:t,intlOptions:r})=>Te(n=>{const a=$n(n,t.decimals);return Intl.NumberFormat(e,{...a,...r,style:"percent"}).format(n)}),Gn=(e,t="none")=>{switch(t){case"none":return{base:e,suffix:""};case"auto":{const r=Jy(e);return Gn(e,r)}default:return{base:e/l.SUFFIX_MULTIPLIERS[t],suffix:t}}},$n=(e,t)=>{if(typeof t=="number")return{minimumFractionDigits:t,maximumFractionDigits:t};const r=Math.ceil(Math.log10(Math.abs(e))),n=r>=3?0:r===2?1:2;return{minimumFractionDigits:t==="auto"?0:n,maximumFractionDigits:n}},Jy=e=>{const t=Math.abs(e);return t>=l.SUFFIX_MULTIPLIERS.b?"b":t>=l.SUFFIX_MULTIPLIERS.m?"m":t>=l.SUFFIX_MULTIPLIERS.k?"k":"none"},Qy=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{dateStyle:"medium",...U,...t}).format(r)),ev=({locale:e,intlOptions:t})=>G(r=>{const n=Intl.DateTimeFormat(e,{dateStyle:"medium",timeStyle:"medium",...U,...t}).formatToParts(r);return tv(n.map(rv))}),il=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{day:"numeric",month:"long",...U,...t}).format(r)),ol=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{month:"long",...U,...t}).format(r)),Un=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{month:"short",year:"numeric",...U,...t}).format(r)),Hn=e=>G(t=>`Q${Math.floor(t.getUTCMonth()/3)+1} ${t.getUTCFullYear()}`),sl=({locale:e,intlOptions:t})=>G(r=>{const n=(0,Co.addDays)(r,6);return Intl.DateTimeFormat(e,{day:"numeric",month:"long",...U,...t,year:void 0}).formatRange(r,n)}),ll=({locale:e,intlOptions:t})=>G(r=>{const n=(0,Co.addDays)(r,6);return Intl.DateTimeFormat(e,{dateStyle:"medium",...U,...t}).formatRange(r,n)}),zn=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{year:"numeric",...U,...t}).format(r)),cl=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{timeStyle:"short",...U,...t}).format(r)),tv=e=>e.map(t=>t.value).join(""),rv=e=>e.type!=="literal"||e.value!==", "?e:{type:"literal",value:" • "},ci=1e3,nv=({valueFormat:e,locale:t,tickValues:r,intlOptions:n})=>Te(a=>{const i={...Kn(a,r),notation:"compact",...l.isCurrencyValueFormat(e)?{style:"currency",currencyDisplay:"narrowSymbol",currency:e.iso}:{},...n};return Wn(a,t,i)}),av=({locale:e,tickValues:t,intlOptions:r})=>Te(n=>{const a={...Kn(n,t),notation:"compact",...r};return Wn(n,e,a)}),iv=({locale:e,tickValues:t,intlOptions:r})=>Te(n=>{const a={...Kn(n,t),notation:"compact",...r,style:"percent"};return Wn(n,e,a)}),Wn=(e,t,r)=>Intl.NumberFormat(t,r).formatToParts(e).map(n=>n.type==="compact"?n.value.toLowerCase():n.value).join(""),ul=e=>Math.abs(e)>ci?ul(e/ci):Number.isInteger(e),ov=e=>{if(e.length<2)return!1;const[t,r]=e;return typeof t!="number"||typeof r!="number"?!1:Math.abs(r-t)<1},Kn=(e,t)=>ul(e)?{minimumFractionDigits:0,maximumFractionDigits:0}:ov(t)?{minimumFractionDigits:0,maximumFractionDigits:4}:{minimumFractionDigits:0,maximumFractionDigits:1},sv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{day:"numeric",month:"short",...U,...t}).format(r)),lv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{month:"short",...U,...t}).format(r)),cv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{day:"numeric",month:"short",...U,...t}).format(r)),uv=({locale:e,intlOptions:t})=>G(r=>Intl.DateTimeFormat(e,{timeStyle:"short",...U,...t}).format(r)),Yn=e=>{const{valueFormat:t}=e;switch(t.type){case"currency":return nv(e);case"date":case"datetime":return sv(e);case"day_month":case"weekly_date_range":case"weekly_date_range_with_year":return cv(e);case"decimal":case"integer":return av(e);case"duration":return Fn(e);case"month":return lv(e);case"month_year":return Un(e);case"percentage":return iv(e);case"quarter":return Hn(e);case"text":return Bn(e);case"time":return uv(e);case"year":return zn(e);case"lookup":return Yn({...e,valueFormat:t.fallback});default:throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}},dv=.9,mv=1/3,pv=1/4,hv=e=>e.formattedAxis.position==="top"||e.formattedAxis.position==="bottom"?fv(e):gv(e),fv=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=dl(e.ticks,n),s=yv(e.ticks,r.width),c=s*dv;if(i<=c)return{...e,labelRotation:0,labelMaxWidthPx:null};if(s>=50){const d=Qr(c);return{...e,ticks:Jr(e.ticks,a,d,n),labelRotation:0,labelMaxWidthPx:d}}if(o+8>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const u=Qr(r.height*mv);return{...e,ticks:Jr(e.ticks,a,u,n),labelRotation:-90,labelMaxWidthPx:u}},gv=({formattedAxis:e,bandwidthPx:t,panelRect:r,measureLabel:n})=>{const{widths:a,maxWidth:i,maxHeight:o}=dl(e.ticks,n);if(o>t)return{...e,ticks:[],labelRotation:0,labelMaxWidthPx:null};const s=Qr(r.width*pv);return i<=s?{...e,labelRotation:0,labelMaxWidthPx:null}:{...e,ticks:Jr(e.ticks,a,s,n),labelRotation:0,labelMaxWidthPx:s}},yv=(e,t)=>{const r=e[0],n=e[1];return r===void 0||n===void 0?t:Math.abs(n.position-r.position)*t},dl=(e,t)=>{const r=[];let n=0,a=0;for(const i of e){const{width:o,height:s}=t(i.formattedLabel);r.push(o),o>n&&(n=o),s>a&&(a=s)}return{widths:r,maxWidth:n,maxHeight:a}},Jr=(e,t,r,n)=>{const a=i=>n(i).width;return e.map((i,o)=>(t[o]??0)<=r?i:{...i,formattedLabel:el(i.formattedLabel,r,a)})},Qr=e=>Math.max(0,Math.floor(e)),vv=(e,t,r,n)=>{if(e.length===0)return!0;const a=t==="top"||t==="bottom",i=a?60:40;let o=r-(e.length-1)*i;for(const s of e){const{width:c,height:u}=n(s);if(o-=a?c:u,o<0)return!1}return!0},bv=({axis:e,availableSpacePx:t,measureLabel:r,resolveFormatter:n})=>{const{tickCandidates:a,position:i}=e;if(a.length===0)return[];const o=new Map,s=m=>{const p=o.get(m);if(p)return p;const h=a[m],f=h?Sv(h.ticks,n(h)):[];return o.set(m,f),f};let c=0,u=a.length-1,d=-1;for(;c<=u;){const m=c+u>>>1;vv(s(m).map(p=>p.formattedLabel),i,t,r)?(d=m,c=m+1):u=m-1}return d>=0?s(d):s(0)},Sv=(e,t)=>e.map(r=>({...r,formattedLabel:t(r.value)})),ui=.5,wt=e=>({x:0,y:0,width:e.width,height:e.height}),jn=e=>e==="panel-end"?"end":e==="panel-start"?"start":e,Rt=({box:e,panel:t,orientation:r,placement:n,justify:a,align:i,offset:o,alignOffset:s,labelWidth:c,labelHeight:u})=>{const d=a==="panel-start"||a==="panel-end",m=(r.valueAxis==="x"?e.height:e.width)===0,p={anchor:xv(a,r.valueDirectionSign),placement:d?"inside":n,offset:o},h={anchor:Iv(i),placement:m?n:"inside",offset:m?s??o:0},f=d?t:e,g=r.valueAxis==="x"?f:e,v=r.valueAxis==="y"?f:e,y=r.valueAxis==="x"?p:h,A=r.valueAxis==="x"?h:p,I=mi(y,{min:g.x,max:g.x+g.width,halfExtent:c/2}),x=mi(A,{min:v.y,max:v.y+v.height,halfExtent:u/2});return{x:I,y:x,position:Av(e,I,x,c,u)}},di=(e,t,r,n)=>r-n>=e-ui&&r+n<=t+ui,Av=(e,t,r,n,a)=>{if(e.width===0&&e.height===0)return"outside";const i=e.width===0||di(e.x,e.x+e.width,t,n/2),o=e.height===0||di(e.y,e.y+e.height,r,a/2);return i&&o?"inside":"outside"},xv=(e,t)=>e==="center"?"center":(e==="end"||e==="panel-end")==(t===1)?"max":"min",Iv=e=>e==="center"?"center":e==="start"?"min":"max",mi=({anchor:e,placement:t,offset:r},{min:n,max:a,halfExtent:i})=>{if(e==="center")return(n+a)/2;if(t==="inside"&&n===a)return n;const o=r+i;return e==="min"?t==="inside"?n+o:n-o:t==="inside"?a-o:a+o},Tv=(e,t,r,n,a)=>{const i=t??e,o=1-Math.max(e,i);return{box:{x:r*n,y:o*a,width:0,height:Math.abs(e-i)*a},orientation:{valueAxis:"y",valueDirectionSign:e>=i?-1:1}}},Lv=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{offset:r}=e.layer.dataLabels,n=wv(e.layer);for(const a of e.layer.data){const i=V(a),o=_(a)??R(a);if(i===null||o===null||!Ze(i,o))continue;const s=e.formatLabel(a);if(s==="")continue;const{width:c,height:u}=e.measureDataLabel("observation","outside",s),{box:d,orientation:m}=Tv(o,B(a),i,e.panelRect.width,e.panelRect.height),p=Rt({box:d,panel:wt(e.panelRect),orientation:m,...n,offset:r,labelWidth:c,labelHeight:u});t.push({layerId:e.layer.id,x:p.x,y:p.y,text:s,width:c,height:u,isRotated:!1,role:"observation",position:"outside"})}return{labels:t,droppedCount:0}},Ev={place:Lv,getPercentageValueStrategy:e=>e.position==="fill"?"fill":l.isStackedPosition(e.position)?"stack":"none"},wv=e=>{const{position:t,justify:r,align:n}=e.dataLabels;return t==="auto"?{placement:"outside",justify:"end",align:"center"}:{placement:t,justify:mr(e.data,e.mapping)?jn(r):r,align:n}};function vr(e){return e[l.VISUAL_VARIABLES.color]}function ml(e){return e[l.VISUAL_VARIABLES.alpha]}function qn(e){return e[l.VISUAL_VARIABLES.size]}function en(e){return e[l.VISUAL_VARIABLES.strokeWidth]}function pl(e){return e[l.VISUAL_VARIABLES.lineType]}var pi=new WeakMap,Rv=(e,t,r)=>{const n=gi(e.graph,hi(l.STYLE_TARGETS.graph,{}),r),a=yi(n,n,l.STYLE_TARGETS.graph.vocabulary),i=(s,c)=>s===l.STYLE_TARGETS.graph?a:yi(gi(e[s.select.target],hi(s,c),r),a,s.vocabulary),o=s=>{const c=Object.fromEntries(Object.entries(s.children??{}).map(([d,m])=>[d,o(m)]));if(s.select.target==="geom")return Object.assign(d=>t(d),c);if((s.options??[]).includes("annotation"))return Object.assign(vi(d=>i(s,{annotation:d})),c);if((s.options??[]).includes("layer")){const d=vi(m=>i(s,{layer:m}));return Object.assign(m=>d(m.id),c)}if(Object.keys(s.vocabulary).length===0)return c;if(s.select.edge!==void 0&&Vv(s)){const d=new Map;return Object.assign(m=>{const p=d.get(m);if(p!==void 0)return p;const h=i(s,{axis:m});return d.set(m,h),h},c)}const u=i(s,{});return Object.assign(()=>u,c)};return Object.fromEntries(Object.entries(l.STYLE_TARGETS).map(([s,c])=>[s,o(c)]))},Cv=e=>{const t=i=>i===void 0?e.panelBorder():e.panelBorder[i](),r=Object.assign(i=>i===void 0?e.legend():e.legend[i](),{popover:e.legend.popover()}),n=(i,o)=>i==="aggregate"?e.dataLabel.aggregate():e.dataLabel[i][o](),a=(i,o,s)=>s===void 0?i[o]():i[s](o);return{panelBorder:t,gridLine:i=>e.gridLine[i](),tickLine:i=>e.tickLine[i](),axisLabel:(i,o)=>a(e.axisLabel,i,o),tickLabel:(i,o)=>a(e.tickLabel,i,o),ruleLabel:i=>e.geom.rule.label({id:i}),dataLabel:n,graph:e.graph(),heading:{h1:e.heading.h1(),h2:e.heading.h2()},caption:e.caption(),source:{label:e.source(),link:e.source.link()},header:e.header(),footer:e.footer(),hoverGuide:e.hoverGuide(),editOutline:i=>e.editOutline[i](),tooltip:{box:e.tooltip(),heading:e.tooltip.heading(),label:e.tooltip.label(),value:e.tooltip.value(),primaryRow:e.tooltip.primaryRow()},headline:e.headline(),headlineItem:{number:e.headlineItem.number(),numberCenter:e.headlineItem.number.center(),caption:e.headlineItem.caption(),label:e.headlineItem.label(),swatch:e.headlineItem.swatch(),trend:e.headlineItem.trend(),trendUp:e.headlineItem.trend.up(),trendDown:e.headlineItem.trend.down(),trendFlat:e.headlineItem.trend.flat()},legend:r,legendItem:{item:e.legendItem(),swatch:e.legendItem.swatch()},directLabel:e.directLabel(),annotation:{shape:i=>e.annotation.shape(i),arrow:i=>e.annotation.arrow(i),differenceArrow:Object.assign(i=>e.annotation.differenceArrow(i),{label:i=>e.annotation.differenceArrow.label(i)}),text:i=>e.annotation.text(i),image:i=>e.annotation.image(i),pinnedNumber:Object.assign(i=>e.annotation.pinnedNumber(i),{label:i=>e.annotation.pinnedNumber.label(i)}),comment:Object.assign(i=>e.annotation.comment(i),{label:i=>e.annotation.comment.label(i)})}}},Vv=e=>{const t=l.findStyleTarget({target:e.select.target})??e;return Object.values(t.children??{}).some(r=>r.select.axis!==void 0)},hi=(e,t)=>{const r=l.findStyleTarget({target:e.select.target})??e,n=t.axis!==void 0?{...e.select,axis:t.axis}:e.select,a=r.partWildcard!==!0;return i=>{const o=i.select;if(o.target!==n.target)return!1;for(const s of l.STYLE_SELECT_KEYS){const c=n[s],u=o[s];if(s==="part"&&a){if(u!==c)return!1;continue}if(c===void 0){if(u!==void 0)return!1}else if(u!==void 0&&u!==c)return!1}if(t.annotation!==void 0){const s="annotation"in i.select?i.select.annotation:void 0;if(s!==void 0&&s!==t.annotation)return!1}if(t.layer!==void 0){const s="layer"in i.select?i.select.layer:void 0;if(s!==void 0&&s!==t.layer)return!1}return!0}},fi=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){const a=e[n];if(!(a===void 0||!r(a))&&a.declarations[t]!==void 0)return a}},gi=(e,t,r)=>{const n=c=>fi(e.overrides,c,t)??fi(e.defaults,c,t);return{get:c=>{const u=n(c)?.declarations[c];if(u!==void 0)return l.resolveColorScheme(u,r)},getSource:c=>{const u=n(c);return u===void 0?"unresolved":u.origin.list==="builtin"?"builtin":"authored"},explain:c=>{const u=n(c),d=u?.declarations[c];return u===void 0||d===void 0?{value:void 0,source:"unresolved"}:{value:l.resolveColorScheme(d,r),source:u.origin.list==="builtin"?"builtin":"authored",origin:u.origin,select:u.select}},collectAll:c=>{const u=[];for(const d of[e.defaults,e.overrides])for(const m of d){if(!t(m))continue;const p=m.declarations[c];p!==void 0&&u.push(l.resolveColorScheme(p,r))}return u}}},Mv=(e,t,r)=>{e.fontSize!==void 0&&(e.fontSize*=t.get("textScale")),"fontFamily"in r&&(e.fontFamily??=t.get("fontFamily"))},yi=(e,t,r)=>({...e,resolve:()=>{const n=pi.get(e);if(n!==void 0)return n;const a={};for(const i of Object.keys(r)){const o=e.get(i);o!==void 0&&Object.assign(a,{[i]:o})}return Mv(a,t,r),pi.set(e,a),a}}),vi=e=>{const t=new Map;return r=>{const n=t.get(r);if(n!==void 0)return n;const a=e(r);return t.set(r,a),a}},Dv={color:vr,alpha:ml,strokeWidth:en,lineType:pl,size:qn,borderWidth:en},bi=new WeakMap,at=(e={})=>{const t=e.colorScheme??"light",r=new WeakMap,n=new WeakMap,a=new WeakMap,i=c=>{const u=r.get(c);if(u!==void 0)return u;const d=Ov(Pv(c.styles),t,_v(c.geom));return r.set(c,d),d},o=c=>{const u=n.get(c);if(u!==void 0)return u;const d=Cv(s({chrome:c}));return n.set(c,d),d},s=c=>{const u=a.get(c.chrome);if(u!==void 0)return u;const d=Rv(c.chrome,i,t);return a.set(c.chrome,d),d};return{readers:s,geomReaders:i,chromeReaders:o}},Pv=e=>{const t=bi.get(e);if(t!==void 0)return t;const r={defaults:Si(e.defaults),overrides:Si(e.overrides)};return bi.set(e,r),r},Si=e=>{const t={};for(const r of e)for(const n of Object.keys(r.declarations)){if(r.declarations[n]===void 0)continue;const a=t[n]??={};(a[r.state??"stateless"]??=[]).push(r)}return t},Ov=(e,t,r)=>{const n=(s,c,u)=>{if(u!==void 0){const h=lt(e.overrides,s,c,u);if(h!==void 0)return{value:st(h,s,t),tier:"override",origin:h.origin,state:u};const f=lt(e.defaults,s,c,u);if(f!==void 0)return{value:st(f,s,t),tier:"default",origin:f.origin,state:u}}const d=lt(e.overrides,s,c,void 0);if(d!==void 0)return{value:st(d,s,t),tier:"override",origin:d.origin};const m=Ai(s,c);if(m!==void 0)return{value:m,tier:"data"};const p=lt(e.defaults,s,c,void 0);return p!==void 0?{value:st(p,s,t),tier:"default",origin:p.origin}:{value:void 0,tier:"unresolved"}},a=(s,c,u)=>{if(u!==void 0){const p=Ft(e.overrides,s,c,u,t);if(p!==void 0)return p;const h=Ft(e.defaults,s,c,u,t);if(h!==void 0)return h}const d=Ft(e.overrides,s,c,void 0,t);if(d!==void 0)return d;const m=Ai(s,c);return m!==void 0?m:Ft(e.defaults,s,c,void 0,t)};return{get:a,getSource:(s,c,u)=>n(s,c,u).tier,explain:n,collectAll:(s,c,u)=>{const d=[];for(const m of[e.defaults,e.overrides]){const p=m[s]?.[u??"stateless"];if(p!==void 0)for(const h of p){const f=h.declarations[s];f!==void 0&&hl(h,c)&&d.push(l.resolveColorScheme(f,t))}}return d},resolve:(s,c)=>{const u={};for(const d of Object.keys(r)){const m=a(d,s,c);m!==void 0&&Object.assign(u,{[d]:m})}return u}}},_v=e=>{const t=l.STYLE_TARGETS.geom.children;return Object.hasOwn(t,e)?t[e].vocabulary:l.STYLE_TARGETS.geom.vocabulary},Ft=(e,t,r,n,a)=>st(lt(e,t,r,n),t,a),st=(e,t,r)=>{const n=e?.declarations[t];return n===void 0?void 0:l.resolveColorScheme(n,r)},lt=(e,t,r,n)=>{const a=e[t]?.[n??"stateless"];if(a!==void 0)for(let i=a.length-1;i>=0;i--){const o=a[i];if(o!==void 0&&hl(o,r))return o}},hl=(e,t)=>e.matches===void 0?!0:t!==void 0&&e.matches(t),Ai=(e,t)=>{const r=Dv[e];if(!(r===void 0||t===void 0))return r(t)??void 0},Xn=(e,t,r)=>{const n={},a=i=>{const o=n[i];if(o!==void 0)return o;const{width:s,height:c}=e(t,i,r),u={width:s,height:c};return n[i]=u,u};return{get inside(){return a("inside")},get outside(){return a("outside")}}},Gt=6,kv=.5,Nv=e=>{const t=[];let r=0;const n=l.isStackedPosition(e.layer.position),a=e.coordSystem.mainAxis==="y";if(e.layer.dataLabels.showDataLabels){const{entries:i,shouldRotate:o}=Fv({layer:e.layer,mainAxis:e.coordSystem.mainAxis,panelRect:e.panelRect,measureDataLabel:e.measureDataLabel,formatLabel:e.formatLabel,isFlipped:a});for(const s of i){const c=e.layer.dataLabels.position==="auto"?Uv({mainAxis:e.coordSystem.mainAxis,isStacked:n,isNegativeBar:s.isNegative,shouldRotate:o,bounds:s.bounds,boxes:s.boxes,panelWidth:e.panelRect.width,panelHeight:e.panelRect.height,offset:e.layer.dataLabels.offset}):zv(e.layer.dataLabels,e.coordSystem.mainAxis,n,s,wt(e.panelRect));if(c===null){r+=1;continue}const u=s.boxes[c.position];t.push({layerId:e.layer.id,x:c.x,y:c.y,text:s.text,width:u.width,height:u.height,isRotated:c.isRotated,role:"observation",position:c.position,...c.position==="inside"?{backdropColor:s.backdropColor}:{}})}}if(e.layer.dataLabels.showCategoryLabels)for(const i of Wv(e,n))t.push(i);if(e.layer.dataLabels.showStackTotals){const i=qv({layer:e.layer,mainAxis:e.coordSystem.mainAxis,panelRect:e.panelRect,measureDataLabel:e.measureDataLabel,formatAbsolute:e.formatAbsolute});for(const o of i)t.push(o)}return{labels:t,droppedCount:r}},Bv={place:Nv,getPercentageValueStrategy:e=>e.position==="fill"?"fill":l.isStackedPosition(e.position)?"stack":"absoluteGrandTotal"},Fv=({layer:e,mainAxis:t,panelRect:r,measureDataLabel:n,formatLabel:a,isFlipped:i})=>{const o=[];let s=!1;const c=e.dataLabels.position==="auto",u=l.readVariableName(e.mapping.y),d=at().geomReaders(e);for(const m of e.data){const p=gl(t,m);if(p===null)continue;const h=a(m);if(h==="")continue;const f=Xn(n,"observation",h),g=Zn(p,r);c&&f.inside.width>g.width&&(s=!0);const v=u===null?null:m[u],y=l.isStrictNumericDataValue(v)&&v<0;o.push({isNegative:y,text:h,boxes:f,bounds:g,backdropColor:d.get("color",m)})}return{entries:o,shouldRotate:!i&&s}},Zn=(e,t)=>({x:e.x*t.width,y:e.y*t.height,width:e.width*t.width,height:e.height*t.height}),fl=(e,t,r,n,a)=>{if(e==="x"){let s=1-a,c=a-n;return c<0&&(s+=c,c=-c),{x:t,y:s,width:r-t,height:c}}let i=t,o=r-t;return o<0&&(i+=o,o=-o),{x:i,y:1-a,width:o,height:a-n}},gl=(e,t)=>{const r=z(t),n=W(t),a=B(t),i=_(t)??R(t);return r===null||n===null||a===null||i===null?null:fl(e,r,n,a,i)},Gv=(e,t)=>{const{xMin:r,xMax:n,yMin:a,yMax:i}=t.anchor;return fl(e,r,n,a,i)},$v=(e,t)=>e==="x"?t?"bottom":"top":t?"left":"right",tn=(e,t,r)=>r?{width:t,height:e}:{width:e,height:t},Uv=e=>e.isStacked?Kv({bounds:e.bounds,box:e.boxes.inside,isRotated:e.shouldRotate}):jv({edge:$v(e.mainAxis,e.isNegativeBar),bounds:e.bounds,boxes:e.boxes,isRotated:e.shouldRotate,panelWidth:e.panelWidth,panelHeight:e.panelHeight,offset:e.offset}),yl=(e,t)=>e==="x"?{valueAxis:"y",valueDirectionSign:t?1:-1}:{valueAxis:"x",valueDirectionSign:t?-1:1},Hv=e=>e==="panel-start"||e==="panel-end",zv=(e,t,r,n,a)=>{if(e.position==="auto")return null;const i=r&&e.position==="outside"?"inside":e.position,o=n.boxes[i],s=Rt({box:n.bounds,panel:a,orientation:yl(t,n.isNegative),placement:i,justify:e.justify,align:e.align,offset:e.offset,labelWidth:o.width,labelHeight:o.height});if(i==="inside"&&!Hv(e.justify)){const c=t==="y",u=c?n.bounds.width:n.bounds.height;return(c?o.width:o.height)>u+kv?null:{x:s.x,y:s.y,isRotated:!1,position:"inside"}}return{x:s.x,y:s.y,isRotated:!1,position:s.position}},Wv=(e,t)=>{const r=[],{categoryPosition:n,categoryJustify:a,categoryAlign:i,categoryOffset:o}=e.layer.dataLabels,s=t&&n==="outside"?"inside":n,c=e.coordSystem.mainAxis,u=wt(e.panelRect),d=l.readVariableName(e.layer.mapping.y);for(const m of e.layer.data){const p=gl(c,m);if(p===null)continue;const h=e.formatCategory(m);if(h===null||h==="")continue;const f=Xn(e.measureDataLabel,"category",h),g=f[s],v=Zn(p,e.panelRect),y=d===null?null:m[d],A=l.isStrictNumericDataValue(y)&&y<0,I=Rt({box:v,panel:u,orientation:yl(c,A),placement:s,justify:a,align:i,offset:o,labelWidth:g.width,labelHeight:g.height}),x=f[I.position];r.push({layerId:e.layer.id,x:I.x,y:I.y,text:h,width:x.width,height:x.height,isRotated:!1,role:"category",position:I.position})}return r},Kv=({bounds:e,box:t,isRotated:r})=>{const n=tn(t.width,t.height,r);return n.width>e.width||n.height>e.height?null:{x:e.x+e.width/2,y:e.y+e.height/2,isRotated:r,position:"inside"}},Yv=(e,t,r,n)=>{switch(e){case"top":return{edgeCoord:t.y,outwardSign:-1,panelExtent:n};case"bottom":return{edgeCoord:t.y+t.height,outwardSign:1,panelExtent:n};case"left":return{edgeCoord:t.x,outwardSign:-1,panelExtent:r};case"right":return{edgeCoord:t.x+t.width,outwardSign:1,panelExtent:r}}},jv=({edge:e,bounds:t,boxes:r,isRotated:n,panelWidth:a,panelHeight:i,offset:o})=>{const s=e==="top"||e==="bottom",c=t.x+t.width/2,u=t.y+t.height/2,d=s?t.height:t.width,m=s?t.width:t.height,{edgeCoord:p,outwardSign:h,panelExtent:f}=Yv(e,t,a,i),g=tn(r.inside.width,r.inside.height,n),v=s?g.height:g.width,y=s?g.width:g.height,A=v+o<d,I=y<=m;if(s?A:A&&I){if(s&&!I)return null;if(n)return{x:c,y:u,isRotated:!0,position:"inside"};const te=p-h*(v/2+o);return{...s?{x:c,y:te}:{x:te,y:u},isRotated:!1,position:"inside"}}const x=tn(r.outside.width,r.outside.height,n),T=(s?x.height:x.width)/2,E=p+h*(T+o);return E-T<0||E+T>f?null:{...s?{x:c,y:E}:{x:E,y:u},isRotated:n,position:"outside"}},qv=({layer:e,mainAxis:t,panelRect:r,measureDataLabel:n,formatAbsolute:a})=>{const i=[],o=e.summary.stackTotals;if(o===void 0||o.length===0)return i;const s=t==="y";for(const c of o){const u=Zn(Gv(t,c),r),d=a(c.total),{width:m,height:p}=n("aggregate","outside",d),h=c.anchor.direction==="positive";let f,g;s?(f=h?u.x+u.width+Gt+m/2:u.x-Gt-m/2,g=u.y+u.height/2):(f=u.x+u.width/2,g=h?u.y-Gt-p/2:u.y+u.height+Gt+p/2),i.push({layerId:e.id,x:f,y:g,text:d,width:m,height:p,isRotated:!1,role:"aggregate",position:"outside"})}return i},Xv=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{offset:r}=e.layer.dataLabels,n=Jv(e.layer);for(const a of e.layer.data){const i=V(a),o=R(a);if(i===null||o===null||!Ze(i,o))continue;const s=e.formatLabel(a);if(s==="")continue;const{width:c,height:u}=e.measureDataLabel("observation","outside",s),d=Rt({box:{x:i*e.panelRect.width,y:(1-o)*e.panelRect.height,width:0,height:0},panel:wt(e.panelRect),orientation:{valueAxis:"y",valueDirectionSign:-1},...n,offset:r,labelWidth:c,labelHeight:u});t.push({layerId:e.layer.id,x:d.x,y:d.y,text:s,width:c,height:u,isRotated:!1,role:"observation",position:d.position})}return{labels:t,droppedCount:0}},Zv={place:Xv,getPercentageValueStrategy:()=>"none"},Jv=e=>{const{position:t,justify:r,align:n}=e.dataLabels;return t==="auto"?{placement:"outside",justify:"end",align:"center"}:{placement:t,justify:mr(e.data,e.mapping)?jn(r):r,align:n}},Qv=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{offset:r}=e.layer.dataLabels,n=tb(e.layer),a=n.justify==="panel-start"||n.justify==="panel-end",i=at().geomReaders(e.layer);for(const o of e.layer.data){const s=V(o),c=R(o);if(s===null||c===null||!Ze(s,c))continue;const u=e.formatLabel(o);if(u==="")continue;const{width:d,height:m}=e.measureDataLabel("observation","outside",u),p=i.get("size",o)/2,h=Rt({box:{x:s*e.panelRect.width,y:(1-c)*e.panelRect.height,width:0,height:0},panel:wt(e.panelRect),orientation:{valueAxis:"y",valueDirectionSign:-1},...n,offset:a?r:r+p,alignOffset:r+p,labelWidth:d,labelHeight:m});t.push({layerId:e.layer.id,x:h.x,y:h.y,text:u,width:d,height:m,isRotated:!1,role:"observation",position:h.position})}return{labels:t,droppedCount:0}},eb={place:Qv,getPercentageValueStrategy:()=>"none"},tb=e=>{const{position:t,justify:r,align:n}=e.dataLabels;return t==="auto"?{placement:"outside",justify:"end",align:"center"}:{placement:t,justify:r,align:n}},vl=e=>{const t=z(e),r=W(e),n=B(e),a=_(e);if(t===null||r===null||n===null||a===null)return null;const i=Math.min(t,r),o=Math.abs(r-t),s=Math.max(n,a),c=Math.abs(a-n);return{x:i,y:1-s,width:o,height:c}},bl=e=>{const t=vl(e);if(!t)return null;const r=t.width*ff,n=t.height*gf;return{x:t.x+r,y:t.y+n,width:t.width-r*2,height:t.height-n*2}},Sl=e=>!!vr(e),Al=e=>Sl(e)?bl(e):null,xi=4,rb=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const r=at().geomReaders(e.layer);for(const n of e.layer.data){const a=Al(n);if(a===null)continue;const i=e.formatLabel(n);if(i==="")continue;const{width:o,height:s}=e.measureDataLabel("observation","inside",i),c=a.width*e.panelRect.width,u=a.height*e.panelRect.height;o+xi>c||s+xi>u||t.push({layerId:e.layer.id,x:(a.x+a.width/2)*e.panelRect.width,y:(a.y+a.height/2)*e.panelRect.height,text:i,width:o,height:s,isRotated:!1,role:"observation",position:"inside",backdropColor:r.get("color",n)})}return{labels:t,droppedCount:0}},nb={place:rb,getPercentageValueStrategy:()=>"none"};function Jn(e){return{startAngle:e[l.POSITION_VARIABLES.xMin],endAngle:e[l.POSITION_VARIABLES.xMax]}}function Qn(e){return{innerRadius:e[l.POSITION_VARIABLES.yMin],outerRadius:e[l.POSITION_VARIABLES.yMax]??e[l.POSITION_VARIABLES.y]}}var ab=" · ",_r=2,pt=(e,t,r,n)=>{const a=Math.abs(e==="radial"?Math.sin(t):Math.cos(t)),i=Math.abs(e==="radial"?Math.cos(t):Math.sin(t));return a*(r/2)+i*(n/2)},ib=({wedge:e,labelRadius:t,labelAngle:r,labelWidth:n,labelHeight:a})=>{const i=pt("radial",r,n,a);if(!(t-i>=e.innerRadiusPx-_r&&t+i<=e.outerRadiusPx+_r)||t<=0)return!1;const o=Math.abs(e.endAngle-e.startAngle)/2,s=pt("tangential",r,n,a)/t,c=_r/t;return Math.abs(r-e.midAngle)+s<=o+c},ob=({x:e,y:t,labelWidth:r,labelHeight:n,panelRect:a})=>e-r/2>=0&&e+r/2<=a.width&&t-n/2>=0&&t+n/2<=a.height,Ii=({wedge:e,position:t,offset:r,labelWidth:n,labelHeight:a})=>t==="inside"?{labelRadius:(e.innerRadiusPx+e.outerRadiusPx)/2,labelAngle:e.midAngle,position:"inside"}:{labelRadius:e.outerRadiusPx+r+pt("radial",e.midAngle,n,a),labelAngle:e.midAngle,position:"outside"},sb=({wedge:e,placement:t,justify:r,align:n,offset:a,labelWidth:i,labelHeight:o})=>{const s=n==="start"?e.startAngle:n==="end"?e.endAngle:e.midAngle,c=a+pt("radial",s,i,o);let u;if(r==="center")u=(e.innerRadiusPx+e.outerRadiusPx)/2;else if(r==="end")u=t==="inside"?e.outerRadiusPx-c:e.outerRadiusPx+c;else if(t==="inside")u=e.innerRadiusPx+c;else{const m=e.innerRadiusPx-c;u=m>=0?m:e.innerRadiusPx+c}let d=s;if(n!=="center"&&u>0){const m=pt("tangential",s,i,o)/u;d=s+(n==="start"?1:-1)*m}return{labelRadius:u,labelAngle:d,position:ib({wedge:e,labelRadius:u,labelAngle:d,labelWidth:i,labelHeight:o})?"inside":"outside"}},lb=e=>{const t=[];if(!e.layer.dataLabels.showDataLabels)return{labels:t,droppedCount:0};const{position:r,justify:n,align:a,offset:i,showCategoryLabels:o}=e.layer.dataLabels,s=e.coordSystem.bandAxis==="y"?"inside":"outside",c=e.panelRect.width/2,u=e.panelRect.height/2,d=Math.min(e.panelRect.width,e.panelRect.height)/2,m=at().geomReaders(e.layer);for(const p of e.layer.data){const{startAngle:h,endAngle:f}=Jn(p),{innerRadius:g,outerRadius:v}=Qn(p);if(h===null||f===null||v===null)continue;const y=e.formatLabel(p);if(y==="")continue;const A=o?e.formatCategory(p):null,I=A===null?y:`${A}${ab}${y}`,x={startAngle:h,endAngle:f,midAngle:(h+f)/2,innerRadiusPx:(g??0)*d,outerRadiusPx:v*d};let T,E;if(r==="auto"){const L=e.measureDataLabel("observation",s,I);E={width:L.width,height:L.height},T=Ii({wedge:x,position:s,offset:i,labelWidth:E.width,labelHeight:E.height});const P=c+Math.sin(T.labelAngle)*T.labelRadius,k=u-Math.cos(T.labelAngle)*T.labelRadius;if(T.position==="outside"&&!ob({x:P,y:k,labelWidth:E.width,labelHeight:E.height,panelRect:e.panelRect})){const re=e.measureDataLabel("observation","inside",I);E={width:re.width,height:re.height},T=Ii({wedge:x,position:"inside",offset:i,labelWidth:E.width,labelHeight:E.height})}}else{const L=Xn(e.measureDataLabel,"observation",I),P=L[r];T=sb({wedge:x,placement:r,justify:jn(n),align:a,offset:i,labelWidth:P.width,labelHeight:P.height}),E=L[T.position]}const te=c+Math.sin(T.labelAngle)*T.labelRadius,Le=u-Math.cos(T.labelAngle)*T.labelRadius;t.push({layerId:e.layer.id,x:te,y:Le,text:I,width:E.width,height:E.height,isRotated:!1,role:"observation",position:T.position,...T.position==="inside"?{backdropColor:m.get("color",p)}:{}})}return{labels:t,droppedCount:0}},cb={place:lb,getPercentageValueStrategy:()=>"absoluteGrandTotal"},ub=e=>{const t=M({...e,valueFormat:e.valueFormat.fallback}),r={};for(const[a,i]of Object.entries(e.valueFormat.cases))r[a]=M({...e,valueFormat:i});const n=e.valueFormat.byVariable;return(a,i)=>{if(i===void 0||i[n]===void 0)return t(a);const o=l.getStableKey(i[n]),s=r[o];return s!==void 0?s(a,i):t(a)}},M=e=>{switch(e.valueFormat.type){case"currency":return tl(e);case"date":return Qy(e);case"datetime":return ev(e);case"day_month":return il(e);case"decimal":return rl(e);case"duration":return Fn(e);case"integer":return nl(e);case"month":return ol(e);case"month_year":return Un(e);case"percentage":return al(e);case"quarter":return Hn(e);case"text":return Bn(e);case"weekly_date_range":return sl(e);case"weekly_date_range_with_year":return ll(e);case"year":return zn(e);case"time":return cl(e);case"lookup":return ub({...e,valueFormat:e.valueFormat});default:{const t=e.valueFormat;throw new l.InternalError({message:`Unhandled value format: ${t.type}`})}}};function ea({layer:e,numberFormat:t,locale:r}){return M({valueFormat:Pm(e),locale:r,numberFormat:t})}var db=(e,t)=>{const r=l.readVariableName(t.x);return r!==null&&r!==l.CONSTANT_VARIABLES.x?{read:rt(e,t),variable:r}:{read:J,variable:l.GROUP_VARIABLES.group}},xl=({layer:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,formattingLocale:o,percentageValueStrategy:s})=>{const c=ea({layer:e,numberFormat:n,locale:o}),u=t.type==="cartesian"&&t.mainAxis==="y";return{layer:e,coordSystem:t,panelRect:a,measureDataLabel:i,formatLabel:gb({layer:e,numberFormat:n,axes:r,locale:o,absoluteFormatter:c,percentageValueStrategy:s,isFlipped:u}),formatAbsolute:c,formatCategory:mb({layer:e,numberFormat:n,locale:o})}},mb=({layer:e,numberFormat:t,locale:r})=>{const{read:n,variable:a}=db(e.data,e.mapping),i=M({valueFormat:e.data.hasVariable(a)?e.data.getValueFormat(a):{type:"text"},locale:r,numberFormat:t});return o=>{const s=n(o);return s===null?null:i(s,o)}},pb=(e,t,r)=>{switch(t){case"stack":return hb(e);case"fill":return fb(e,r);case"absoluteGrandTotal":return()=>e.summary.absoluteGrandTotal??null;case"none":return()=>null}},hb=e=>{const t=l.readVariableName(e.mapping.x);let r=null,n=!1;return a=>{const i=e.summary.stackTotals;if(i===void 0||i.length===0||t===null)return null;if(!n){r=new Map;for(const c of i)r.set(c.xKey,c);n=!0}const o=a[t];if(o==null)return null;const s=r?.get(wn(a,t));return s===void 0?null:s.total}},fb=(e,t)=>{const r=t?z:B,n=t?W:_,a=bt(e);return i=>{const o=r(i),s=n(i);if(!l.isStrictNumericDataValue(o)||!l.isStrictNumericDataValue(s))return null;const c=Math.abs(s-o);if(c===0)return null;const u=a(i);return l.isStrictNumericDataValue(u)?u/c:null}},gb=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a,percentageValueStrategy:i,isFlipped:o})=>{const s=j(e.data,e.dataLabels.labelSource),c=pb(e,i,o),u=yb({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a}),d=M({valueFormat:{type:"percentage"},locale:n,numberFormat:t}),m=e.dataLabels.format==="percentage"&&Il(e);return p=>{const h=s(p);if(h===null)return"";if(!m||!l.isStrictNumericDataValue(h))return u(h,p);const f=c(p);return f===null||f===0?u(h,p):d(h/f)}},yb=({layer:e,numberFormat:t,axes:r,locale:n,absoluteFormatter:a})=>{const i=e.dataLabels.labelSource,o=l.readVariableName(i);if(o!==null){if(Il(e))return a;const s=vb(e,r,t,n,o);if(s!==null)return s}return M({valueFormat:bb(e.data,i),locale:n,numberFormat:t})},Il=e=>{const t=l.readVariableName(e.dataLabels.labelSource);return t===null?!1:t===l.readVariableName(vt(e.position,e.mapping))},vb=(e,t,r,n,a)=>{const i=l.readVariableName(e.mapping.x);if(i===null||i!==a)return null;const o=t.find(s=>s.scaleAestheticKey==="x");return o===void 0?null:M({valueFormat:o.valueFormat,locale:n,numberFormat:r})},bb=(e,t)=>{const r=l.readConstantValue(t);if(r!==void 0)return l.isNumericDataValue(r)?{type:"decimal"}:l.isTemporalDataValue(r)?{type:"date"}:{type:"text"};const n=l.readVariableName(t);return n===null||!e.hasVariable(n)?{type:"text"}:e.getValueFormat(n)},ta={bar:{cartesian:Bv,polar:cb},line:{cartesian:Zv},point:{cartesian:eb},area:{cartesian:Ev},tile:{cartesian:nb}},Sb=(e,t)=>ta[e]?.[t]!==void 0,Ab=({layers:e,coordSystem:t,axes:r,numberFormat:n,parsingLocale:a,panelRect:i,measureDataLabel:o,formattingLocale:s,plotBottomY:c,isFooterChromeReserved:u})=>{const d=[],m=s??a,p=t.type;let h=0;for(const f of e){if(!f.dataLabels.showDataLabels&&!f.dataLabels.showStackTotals&&!f.dataLabels.showCategoryLabels)continue;const g=f.geom,v=ta[g]?.[p];if(v===void 0)continue;const y=xl({layer:f,coordSystem:t,axes:r,numberFormat:n,panelRect:i,measureDataLabel:o,formattingLocale:m,percentageValueStrategy:v.getPercentageValueStrategy(f)}),A=v.place(y);h+=A.droppedCount;for(const I of A.labels)Ib(I,p,c,u)||d.push(I)}return{labels:d,warnings:h>0?[xb(h)]:[]}},xb=e=>({code:"DATA_LABELS_DROPPED",severity:"warning",kind:"user-input",message:e===1?"Dropped 1 data label that did not fit under position 'auto'.":`Dropped ${e} data labels that did not fit under position 'auto'.`,suggestion:"Set dataLabels.position to 'outside' to keep labels that do not fit inside the bars.",context:{actual:e}}),Ib=(e,t,r,n)=>t==="polar"&&n&&e.position==="outside"&&e.y+e.height/2>r;function*Tb({layers:e,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,locale:o}){if(!(t.type!=="cartesian"||a.width<=0||a.height<=0))for(const s of e){if(!s.dataLabels.showDataLabels&&!s.dataLabels.showStackTotals)continue;const c=ta[s.geom]?.cartesian;if(c===void 0)continue;const u=xl({layer:s,coordSystem:t,axes:r,numberFormat:n,panelRect:a,measureDataLabel:i,formattingLocale:o,percentageValueStrategy:c.getPercentageValueStrategy(s)});for(const d of c.place(u).labels)yield{x:a.x+d.x-d.width/2,y:a.y+d.y-d.height/2,width:d.width,height:d.height}}}var kr={abbreviation:"none",decimals:"auto"},Tl=({locale:e,kind:t,startValue:r,endValue:n,valueFormat:a})=>{if(r===null||n===null)return"n/a";switch(t){case"absolute-difference":return M({valueFormat:a,locale:e,numberFormat:kr,intlOptions:{signDisplay:"always"}})(n-r);case"relative-difference":{const i=n-r;if(i===0)return"0%";const o=i/r;return o===Number.POSITIVE_INFINITY?"∞":o===Number.NEGATIVE_INFINITY?"-∞":M({valueFormat:{type:"percentage"},locale:e,numberFormat:kr,intlOptions:{signDisplay:"always"}})(o)}case"proportion":{if(n-r===0)return"=";const i=n/r;return i===Number.POSITIVE_INFINITY?"∞":i===Number.NEGATIVE_INFINITY?"-∞":`${M({valueFormat:{type:"decimal"},locale:e,numberFormat:kr,intlOptions:{maximumFractionDigits:1}})(i)}x`}}},Lb=2,Eb=6,wb=6,Rb=15,Cb=15,Vb=2.5,Mb=.5,Db=.25,Ll=e=>{const t=e-Lb,r=1+Mb*t,n=1+Db*t;return{arrowStartGap:Eb*r,arrowEndGap:wb*r,offsetFromHigherObservation:Rb*n,arrowheadSize:Vb*e,curveRadius:Cb*n,strokeWidth:e}},Pb=(e,t,r,n)=>{const a=n.offsetFromHigherObservation+n.arrowheadSize+n.arrowEndGap;return e?Math.max(t.x,r.x)+a:Math.min(t.y,r.y)-a},Ob=(e,t,r,{arrowStartGap:n,arrowEndGap:a,curveRadius:i})=>{const o={x:e.x,y:e.y-n},s={x:e.x,y:r},c={x:t.x,y:r},u={x:t.x,y:t.y-a},d=t.x>e.x?1:-1;return`
|
|
2
2
|
M ${o.x} ${o.y}
|
|
3
3
|
L ${s.x} ${s.y+i}
|
|
4
4
|
Q ${s.x} ${s.y} ${s.x+d*i} ${s.y}
|
package/dist/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import Oh from "humanize-duration";
|
|
|
14
14
|
import { area as no, curveCatmullRom as _h, curveLinear as Nh, line as ro } from "d3-shape";
|
|
15
15
|
import { Delaunay as Fh } from "d3-delaunay";
|
|
16
16
|
import ao from "lodash-es/isEqual";
|
|
17
|
-
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.vizEngine = "1.9.0-beta.
|
|
17
|
+
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.vizEngine = "1.9.0-beta.1789737596195");
|
|
18
18
|
var $h = 1e6;
|
|
19
19
|
function he(e) {
|
|
20
20
|
return String(Math.round(e * $h));
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"grammar-of-graphics",
|
|
12
12
|
"compiler"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.9.0-beta.
|
|
14
|
+
"version": "1.9.0-beta.1789737596195",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"sideEffects": [
|
|
17
17
|
"**/version.ts"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"tslib": "^2.8.1",
|
|
66
66
|
"vite": "^8.1.5",
|
|
67
67
|
"vite-plugin-dts": "^4.5.4",
|
|
68
|
-
"vitest": "^4.1.
|
|
68
|
+
"vitest": "^4.1.11",
|
|
69
69
|
"@graphytools/eslint-config": "0.0.1",
|
|
70
70
|
"@graphytools/eslint-plugin-graphy": "1.0.0",
|
|
71
71
|
"@graphytools/typescript-config": "0.0.1",
|