All Downloads are FREE. Search and download functionalities are using the official Maven repository.

[email protected] Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega")):"function"==typeof define&&define.amd?define(["exports","vega"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vegaLite={},e.vega)}(this,(function(e,t){"use strict";var n="5.6.1",i={};!function(e){var t=function(){function e(e,t){return null!=t&&e instanceof t}var t,n,i;try{t=Map}catch(e){t=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function r(o,s,l,c,u){"object"==typeof s&&(l=s.depth,c=s.prototype,u=s.includeNonEnumerable,s=s.circular);var f=[],d=[],p="undefined"!=typeof Buffer;return void 0===s&&(s=!0),void 0===l&&(l=1/0),function o(l,m){if(null===l)return null;if(0===m)return l;var g,h;if("object"!=typeof l)return l;if(e(l,t))g=new t;else if(e(l,n))g=new n;else if(e(l,i))g=new i((function(e,t){l.then((function(t){e(o(t,m-1))}),(function(e){t(o(e,m-1))}))}));else if(r.__isArray(l))g=[];else if(r.__isRegExp(l))g=new RegExp(l.source,a(l)),l.lastIndex&&(g.lastIndex=l.lastIndex);else if(r.__isDate(l))g=new Date(l.getTime());else{if(p&&Buffer.isBuffer(l))return g=Buffer.allocUnsafe?Buffer.allocUnsafe(l.length):new Buffer(l.length),l.copy(g),g;e(l,Error)?g=Object.create(l):void 0===c?(h=Object.getPrototypeOf(l),g=Object.create(h)):(g=Object.create(c),h=c)}if(s){var y=f.indexOf(l);if(-1!=y)return d[y];f.push(l),d.push(g)}for(var v in e(l,t)&&l.forEach((function(e,t){var n=o(t,m-1),i=o(e,m-1);g.set(n,i)})),e(l,n)&&l.forEach((function(e){var t=o(e,m-1);g.add(t)})),l){var b;h&&(b=Object.getOwnPropertyDescriptor(h,v)),b&&null==b.set||(g[v]=o(l[v],m-1))}if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(l);for(v=0;vc(e,t)))}:o(e)?{or:e.or.map((e=>c(e,t)))}:t(e)}const u=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var i,r,o;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;0!=r--;){var a=o[r];if(!e(t[a],n[a]))return!1}return!0}return t!=t&&n!=n},f=i;function d(e){throw new Error(e)}function p(e,n){const i={};for(const r of n)t.hasOwnProperty(e,r)&&(i[r]=e[r]);return i}function m(e,t){const n={...e};for(const e of t)delete n[e];return n}Set.prototype.toJSON=function(){return`Set(${[...this].map((e=>r(e))).join(",")})`};const g=r;function h(e){if(t.isNumber(e))return e;const n=t.isString(e)?e:r(e);if(n.length<250)return n;let i=0;for(let e=0;e1?t-1:0),i=1;i0===t?e:`[${e}]`)),r=e.map(((t,n)=>e.slice(0,n+1).join("")));for(const e of r)n.add(e)}return n}function O(e,t){return void 0===e||void 0===t||D(F(e),F(t))}function z(e){return 0===_(e).length}const _=Object.keys,C=Object.values,N=Object.entries;function P(e){return!0===e||!1===e}function A(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function j(e,t){return s(e)?`!(${j(e.not,t)})`:a(e)?`(${e.and.map((e=>j(e,t))).join(") && (")})`:o(e)?`(${e.or.map((e=>j(e,t))).join(") || (")})`:t(e)}function E(e,t){if(0===t.length)return!0;const n=t.shift();return n in e&&E(e[n],t)&&delete e[n],z(e)}function T(e){return e.charAt(0).toUpperCase()+e.substr(1)}function M(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"datum";const i=t.splitAccessPath(e),r=[];for(let e=1;e<=i.length;e++){const o=`[${i.slice(0,e).map(t.stringValue).join("][")}]`;r.push(`${n}${o}`)}return r.join(" && ")}function L(e){return`${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"datum"}[${t.stringValue(t.splitAccessPath(e).join("."))}]`}function q(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function R(e){return`${t.splitAccessPath(e).map(q).join("\\.")}`}function W(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function U(e){return`${t.splitAccessPath(e).join(".")}`}function I(e){return e?t.splitAccessPath(e).length:0}function B(){for(var e=arguments.length,t=new Array(e),n=0;ncn(e[t])?A(`_${t}_${N(e[t])}`):A(`_${t}_${e[t]}`))).join("")}function an(e){return!0===e||ln(e)&&!e.binned}function sn(e){return"binned"===e||ln(e)&&!0===e.binned}function ln(e){return t.isObject(e)}function cn(e){return e?.param}function un(e){switch(e){case J:case K:case ve:case me:case ge:case he:case ke:case xe:case we:case $e:case ye:return 6;case Se:return 4;default:return 10}}function fn(e){return!!e?.expr}function dn(e){const t=_(e||{}),n={};for(const i of t)n[i]=$n(e[i]);return n}function pn(e){const{anchor:t,frame:n,offset:i,orient:r,angle:o,limit:a,color:s,subtitleColor:l,subtitleFont:c,subtitleFontSize:u,subtitleFontStyle:f,subtitleFontWeight:d,subtitleLineHeight:m,subtitlePadding:g,...h}=e,y={...t?{anchor:t}:{},...n?{frame:n}:{},...i?{offset:i}:{},...r?{orient:r}:{},...void 0!==o?{angle:o}:{},...void 0!==a?{limit:a}:{}},v={...l?{subtitleColor:l}:{},...c?{subtitleFont:c}:{},...u?{subtitleFontSize:u}:{},...f?{subtitleFontStyle:f}:{},...d?{subtitleFontWeight:d}:{},...m?{subtitleLineHeight:m}:{},...g?{subtitlePadding:g}:{}};return{titleMarkConfig:{...h,...s?{fill:s}:{}},subtitleMarkConfig:p(e,["align","baseline","dx","dy","limit"]),nonMarkTitleProperties:y,subtitle:v}}function mn(e){return t.isString(e)||t.isArray(e)&&t.isString(e[0])}function gn(e){return!!e?.signal}function hn(e){return!!e.step}function yn(e){return!t.isArray(e)&&("field"in e&&"data"in e)}const vn=_({aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1}),bn={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},xn=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function wn(e){const n=t.isArray(e.condition)?e.condition.map(kn):kn(e.condition);return{...$n(e),condition:n}}function $n(e){if(fn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function kn(e){if(fn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function Sn(e){if(fn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return gn(e)?e:void 0!==e?{value:e}:void 0}function Dn(e){return gn(e)?e.signal:t.stringValue(e.value)}function Fn(e){return gn(e)?e.signal:null==e?null:t.stringValue(e)}function On(e,t,n){for(const i of n){const n=Cn(i,t.markDef,t.config);void 0!==n&&(e[i]=Sn(n))}return e}function zn(e){return[].concat(e.type,e.style??[])}function _n(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const{vgChannel:r,ignoreVgConfig:o}=i;return r&&void 0!==t[r]?t[r]:void 0!==t[e]?t[e]:!o||r&&r!==e?Cn(e,t,n,i):void 0}function Cn(e,t,n){let{vgChannel:i}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return B(i?Nn(e,t,n.style):void 0,Nn(e,t,n.style),i?n[t.type][i]:void 0,n[t.type][e],i?n.mark[i]:n.mark[e])}function Nn(e,t,n){return Pn(e,zn(t),n)}function Pn(e,n,i){let r;n=t.array(n);for(const t of n){const n=i[t];n&&void 0!==n[e]&&(r=n[e])}return r}function An(e,n){return t.array(e).reduce(((e,t)=>(e.field.push(na(t,n)),e.order.push(t.sort??"ascending"),e)),{field:[],order:[]})}function jn(e,t){const n=[...e];return t.forEach((e=>{for(const t of n)if(u(t,e))return;n.push(e)})),n}function En(e,n){return u(e,n)||!n?e:e?[...t.array(e),...t.array(n)].join(", "):n}function Tn(e,t){const n=e.value,i=t.value;if(null==n||null===i)return{explicit:e.explicit,value:null};if((mn(n)||gn(n))&&(mn(i)||gn(i)))return{explicit:e.explicit,value:En(n,i)};if(mn(n)||gn(n))return{explicit:e.explicit,value:n};if(mn(i)||gn(i))return{explicit:e.explicit,value:i};if(!(mn(n)||gn(n)||mn(i)||gn(i)))return{explicit:e.explicit,value:jn(n,i)};throw new Error("It should never reach here")}function Mn(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ln(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,qn(e,t,"set"),n),n}function qn(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function Rn(e,t,n){!function(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}(e,t),t.set(e,n)}function Wn(e){return`Invalid specification ${g(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const Un='Autosize "fit" only works for single views and layered views.';function In(e){return`${"width"==e?"Width":"Height"} "container" only works for single views and layered views.`}function Bn(e){return`${"width"==e?"Width":"Height"} "container" only works well with autosize "fit" or "fit-${"width"==e?"x":"y"}".`}function Hn(e){return e?`Dropping "fit-${e}" because spec has discrete ${it(e)}.`:'Dropping "fit" because spec has discrete size.'}function Vn(e){return`Unknown field for ${e}. Cannot calculate view size.`}function Gn(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function Yn(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function Xn(e){return`Selection not supported for ${e} yet.`}const Qn="The same selection must be used to override scale domains in a layered view.";function Jn(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}function Kn(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}function Zn(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}const ei="Arc marks uses theta channel rather than angle, replacing angle with theta.";function ti(e){return`${e}Offset dropped because ${e} is continuous`}function ni(e){return`There is no ${e} encoding. Replacing ${e}Offset encoding as ${e}.`}function ii(e){return`Invalid field type "${e}".`}function ri(e,t){const{fill:n,stroke:i}=t;return`Dropping color ${e} as the plot also has ${n&&i?"fill and stroke":n?"fill":"stroke"}.`}function oi(e,t){return`Dropping ${g(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}const ai="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function si(e,t,n){return`${e} dropped as it is incompatible with "${t}"${n?` when ${n}`:""}.`}function li(e){return`${e} encoding has no scale, so specified scale is ignored.`}function ci(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function ui(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function fi(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${"ordinal"===t?"order":"magnitude"}.`}function di(e){return`Using unaggregated domain with raw field has no effect (${g(e)}).`}function pi(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function mi(e){return`Unaggregated domain is currently unsupported for log scale (${g(e)}).`}function gi(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function hi(e){return`The step for "${e}" is dropped because the ${"width"===e?"x":"y"} is continuous.`}const yi="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",vi="Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.",bi="Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.",xi="Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.";function wi(e,t){return`Invalid ${e}: ${g(t)}.`}function $i(e){return`1D error band does not support ${e}.`}function ki(e){return`Channel ${e} is required for "binned" bin.`}const Si=t.logger(t.Warn);let Di=Si;function Fi(){Di.warn(...arguments)}function Oi(e){if(e&&t.isObject(e))for(const t of Ei)if(t in e)return!0;return!1}const zi=["january","february","march","april","may","june","july","august","september","october","november","december"],_i=zi.map((e=>e.substr(0,3))),Ci=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Ni=Ci.map((e=>e.substr(0,3)));function Pi(e,n){const i=[];if(n&&void 0!==e.day&&_(e).length>1&&(Fi(function(e){return`Dropping day from datetime ${g(e)} as day cannot be combined with other units.`}(e)),delete(e=f(e)).day),void 0!==e.year?i.push(e.year):i.push(2012),void 0!==e.month){const r=n?function(e){if(Q(e)&&(e=+e),t.isNumber(e))return e-1;{const t=e.toLowerCase(),n=zi.indexOf(t);if(-1!==n)return n;const i=t.substr(0,3),r=_i.indexOf(i);if(-1!==r)return r;throw new Error(wi("month",e))}}(e.month):e.month;i.push(r)}else if(void 0!==e.quarter){const r=n?function(e){if(Q(e)&&(e=+e),t.isNumber(e))return e>4&&Fi(wi("quarter",e)),e-1;throw new Error(wi("quarter",e))}(e.quarter):e.quarter;i.push(t.isNumber(r)?3*r:`${r}*3`)}else i.push(0);if(void 0!==e.date)i.push(e.date);else if(void 0!==e.day){const r=n?function(e){if(Q(e)&&(e=+e),t.isNumber(e))return e%7;{const t=e.toLowerCase(),n=Ci.indexOf(t);if(-1!==n)return n;const i=t.substr(0,3),r=Ni.indexOf(i);if(-1!==r)return r;throw new Error(wi("day",e))}}(e.day):e.day;i.push(t.isNumber(r)?r+1:`${r}+1`)}else i.push(1);for(const t of["hours","minutes","seconds","milliseconds"]){const n=e[t];i.push(void 0===n?0:n)}return i}function Ai(e){const t=Pi(e,!0).join(", ");return e.utc?`utc(${t})`:`datetime(${t})`}const ji={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Ei=_(ji);function Ti(e){return e.startsWith("utc")}const Mi={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function Li(e){return Ei.filter((t=>qi(e,t)))}function qi(e,t){const n=e.indexOf(t);return!(n<0)&&(!(n>0&&"seconds"===t&&"i"===e.charAt(n-1))&&(!(e.length>n+3&&"day"===t&&"o"===e.charAt(n+3))&&!(n>0&&"year"===t&&"f"===e.charAt(n-1))))}function Ri(e,t){let{end:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{end:!1};const i=M(t),r=Ti(e)?"utc":"";let o;const a={};for(const t of Ei)qi(e,t)&&(a[t]="quarter"===(s=t)?`(${r}quarter(${i})-1)`:`${r}${s}(${i})`,o=t);var s;return n&&(a[o]+="+1"),function(e){const t=Pi(e,!1).join(", ");return e.utc?`utc(${t})`:`datetime(${t})`}(a)}function Wi(e){if(!e)return;const t=Li(e);return`timeUnitSpecifier(${g(t)}, ${g(Mi)})`}function Ui(e){if(!e)return;let n;return t.isString(e)?n={unit:e}:t.isObject(e)&&(n={...e,...e.unit?{unit:e.unit}:{}}),Ti(n.unit)&&(n.utc=!0,n.unit=n.unit.substr(3)),n}function Ii(e){return!!e?.field&&void 0!==e.equal}function Bi(e){return!!e?.field&&void 0!==e.lt}function Hi(e){return!!e?.field&&void 0!==e.lte}function Vi(e){return!!e?.field&&void 0!==e.gt}function Gi(e){return!!e?.field&&void 0!==e.gte}function Yi(e){if(e?.field){if(t.isArray(e.range)&&2===e.range.length)return!0;if(gn(e.range))return!0}return!1}function Xi(e){return!!e?.field&&(t.isArray(e.oneOf)||t.isArray(e.in))}function Qi(e){return Xi(e)||Ii(e)||Yi(e)||Bi(e)||Vi(e)||Hi(e)||Gi(e)}function Ji(e,t){return ba(e,{timeUnit:t,wrapTime:!0})}function Ki(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{field:n}=e,i=Ui(e.timeUnit)?.unit,r=i?`time(${Ri(i,n)})`:na(e,{expr:"datum"});if(Ii(e))return`${r}===${Ji(e.equal,i)}`;if(Bi(e)){return`${r}<${Ji(e.lt,i)}`}if(Vi(e)){return`${r}>${Ji(e.gt,i)}`}if(Hi(e)){return`${r}<=${Ji(e.lte,i)}`}if(Gi(e)){return`${r}>=${Ji(e.gte,i)}`}if(Xi(e))return`indexof([${function(e,t){return e.map((e=>Ji(e,t)))}(e.oneOf,i).join(",")}], ${r}) !== -1`;if(function(e){return!!e?.field&&void 0!==e.valid}(e))return Zi(r,e.valid);if(Yi(e)){const{range:n}=e,o=gn(n)?{signal:`${n.signal}[0]`}:n[0],a=gn(n)?{signal:`${n.signal}[1]`}:n[1];if(null!==o&&null!==a&&t)return"inrange("+r+", ["+Ji(o,i)+", "+Ji(a,i)+"])";const s=[];return null!==o&&s.push(`${r} >= ${Ji(o,i)}`),null!==a&&s.push(`${r} <= ${Ji(a,i)}`),s.length>0?s.join(" && "):"true"}throw new Error(`Invalid field predicate: ${g(e)}`)}function Zi(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function er(e){return Qi(e)&&e.timeUnit?{...e,timeUnit:Ui(e.timeUnit)?.unit}:e}function tr(e){return"quantitative"===e||"temporal"===e}function nr(e){return"ordinal"===e||"nominal"===e}const ir="quantitative",rr="ordinal",or="temporal",ar="nominal",sr="geojson";const lr={LINEAR:"linear",LOG:"log",POW:"pow",SQRT:"sqrt",SYMLOG:"symlog",IDENTITY:"identity",SEQUENTIAL:"sequential",TIME:"time",UTC:"utc",QUANTILE:"quantile",QUANTIZE:"quantize",THRESHOLD:"threshold",BIN_ORDINAL:"bin-ordinal",ORDINAL:"ordinal",POINT:"point",BAND:"band"},cr={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",identity:"numeric",sequential:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"};function ur(e,t){const n=cr[e],i=cr[t];return n===i||"ordinal-position"===n&&"time"===i||"ordinal-position"===i&&"time"===n}const fr={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function dr(e){return fr[e]}const pr=new Set(["linear","log","pow","sqrt","symlog"]),mr=new Set([...pr,"time","utc"]);function gr(e){return pr.has(e)}const hr=new Set(["quantile","quantize","threshold"]),yr=new Set([...mr,...hr,"sequential","identity"]),vr=new Set(["ordinal","bin-ordinal","point","band"]);function br(e){return vr.has(e)}function xr(e){return yr.has(e)}function wr(e){return mr.has(e)}function $r(e){return hr.has(e)}function kr(e){return e?.param}const{type:Sr,domain:Dr,range:Fr,rangeMax:Or,rangeMin:zr,scheme:_r,...Cr}={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},Nr=_(Cr);function Pr(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(e);case"bins":return!["point","band","identity","ordinal"].includes(e);case"round":return wr(e)||"band"===e||"point"===e;case"padding":case"rangeMin":case"rangeMax":return wr(e)||["point","band"].includes(e);case"paddingOuter":case"align":return["point","band"].includes(e);case"paddingInner":return"band"===e;case"domainMax":case"domainMid":case"domainMin":case"clamp":return wr(e);case"nice":return wr(e)||"quantize"===e||"threshold"===e;case"exponent":return"pow"===e;case"base":return"log"===e;case"constant":return"symlog"===e;case"zero":return xr(e)&&!v(["log","time","utc","threshold","quantile"],e)}}function Ar(e,t){switch(t){case"interpolate":case"scheme":case"domainMid":return Le(e)?void 0:`Cannot use the scale property "${t}" with non-color channel.`;case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeMax":case"rangeMin":case"reverse":case"round":case"clamp":case"zero":return}}const jr={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"},Er=jr.arc,Tr=jr.area,Mr=jr.bar,Lr=jr.image,qr=jr.line,Rr=jr.point,Wr=jr.rect,Ur=jr.rule,Ir=jr.text,Br=jr.tick,Hr=jr.trail,Vr=jr.circle,Gr=jr.square,Yr=jr.geoshape;function Xr(e){return["line","area","trail"].includes(e)}function Qr(e){return["rect","bar","image","arc"].includes(e)}const Jr=new Set(_(jr));function Kr(e){return e.type}const Zr=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit","fill","fillOpacity"],eo=_({color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1}),to=_({mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1});function no(e){return e&&null!=e.band}const io={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},ro={binSpacing:1,continuousBandSize:5,timeUnitBandPosition:.5},oo={binSpacing:0,continuousBandSize:5,timeUnitBandPosition:.5};function ao(e){const{channel:t,channelDef:n,markDef:i,scale:r,config:o}=e,a=fo(e);return Io(n)&&!tn(n.aggregate)&&r&&wr(r.get("type"))?function(e){let{fieldDef:t,channel:n,markDef:i,ref:r,config:o}=e;if(Xr(i.type))return r;const a=_n("invalid",i,o);if(null===a)return[so(t,n),r];return r}({fieldDef:n,channel:t,markDef:i,ref:a,config:o}):a}function so(e,t){return{test:lo(e,!0),..."y"===et(t)?{field:{group:"height"}}:{value:0}}}function lo(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Zi(t.isString(e)?e:na(e,{expr:"datum"}),!n)}function co(e,t,n,i){const r={};if(t&&(r.scale=t),Ho(e)){const{datum:t}=e;Oi(t)?r.signal=Ai(t):gn(t)?r.signal=t.signal:fn(t)?r.signal=t.expr:r.value=t}else r.field=na(e,n);if(i){const{offset:e,band:t}=i;e&&(r.offset=e),t&&(r.band=t)}return r}function uo(e){let{scaleName:t,fieldOrDatumDef:n,fieldOrDatumDef2:i,offset:r,startSuffix:o,bandPosition:a=.5}=e;const s=01&&void 0!==arguments[1]?arguments[1]:{},n=e.field;const i=t.prefix;let r=t.suffix,o="";if(function(e){return"count"===e.aggregate}(e))n=G("count");else{let i;if(!t.nofn)if(function(e){return"op"in e}(e))i=e.op;else{const{bin:a,aggregate:s,timeUnit:l}=e;an(a)?(i=on(a),r=(t.binSuffix??"")+(t.suffix??"")):s?Kt(s)?(o=`["${n}"]`,n=`argmax_${s.argmax}`):Jt(s)?(o=`["${n}"]`,n=`argmin_${s.argmin}`):i=String(s):l&&(i=function(e){const{utc:t,...n}=Ui(e);return n.unit?(t?"utc":"")+_(n).map((e=>A(`${"unit"===e?"":`_${e}_`}${n[e]}`))).join(""):(t?"utc":"")+"timeunit"+_(n).map((e=>A(`_${e}_${n[e]}`))).join("")}(l),r=(!["range","mid"].includes(t.binSuffix)&&t.binSuffix||"")+(t.suffix??""))}i&&(n=n?`${i}_${n}`:i)}return r&&(n=`${n}_${r}`),i&&(n=`${i}_${n}`),t.forAs?U(n):t.expr?L(n,t.expr)+o:R(n)+o}function ia(e){switch(e.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return Io(e)&&!!e.bin;case"temporal":return!1}throw new Error(ii(e.type))}const ra=(e,t)=>{switch(t.fieldTitle){case"plain":return e.field;case"functional":return function(e){const{aggregate:t,bin:n,timeUnit:i,field:r}=e;if(Kt(t))return`${r} for argmax(${t.argmax})`;if(Jt(t))return`${r} for argmin(${t.argmin})`;const o=Ui(i),a=t||o?.unit||o?.maxbins&&"timeunit"||an(n)&&"bin";return a?`${a.toUpperCase()}(${r})`:r}(e);default:return function(e,t){const{field:n,bin:i,timeUnit:r,aggregate:o}=e;if("count"===o)return t.countTitle;if(an(i))return`${n} (binned)`;if(r){const e=Ui(r)?.unit;if(e)return`${n} (${Li(e).join("-")})`}else if(o)return Kt(o)?`${n} for max ${o.argmax}`:Jt(o)?`${n} for min ${o.argmin}`:`${T(o)} of ${n}`;return n}(e,t)}};let oa=ra;function aa(e){oa=e}function sa(e,t,n){let{allowDisabling:i,includeDefault:r=!0}=n;const o=la(e)?.title;if(!Io(e))return o??e.title;const a=e,s=r?ca(a,t):void 0;return i?B(o,a.title,s):o??a.title??s}function la(e){return Ko(e)&&e.axis?e.axis:Zo(e)&&e.legend?e.legend:Ao(e)&&e.header?e.header:void 0}function ca(e,t){return oa(e,t)}function ua(e){if(ea(e)){const{format:t,formatType:n}=e;return{format:t,formatType:n}}{const t=la(e)??{},{format:n,formatType:i}=t;return{format:n,formatType:i}}}function fa(e){return Io(e)?e:Wo(e)?e.condition:void 0}function da(e){return Yo(e)?e:Uo(e)?e.condition:void 0}function pa(e,n,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t.isString(e)||t.isNumber(e)||t.isBoolean(e)){return Fi(function(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${g(n)}}.`}(n,t.isString(e)?"string":t.isNumber(e)?"number":"boolean",e)),{value:e}}return Yo(e)?ma(e,n,i,r):Uo(e)?{...e,condition:ma(e.condition,n,i,r)}:e}function ma(e,n,i,r){if(ea(e)){const{format:t,formatType:o,...a}=e;if(mo(o)&&!i.customFormatTypes)return Fi(Zn(n)),ma(a,n,i,r)}else{const t=Ko(e)?"axis":Zo(e)?"legend":Ao(e)?"header":null;if(t&&e[t]){const{format:o,formatType:a,...s}=e[t];if(mo(a)&&!i.customFormatTypes)return Fi(Zn(n)),ma({...e,[t]:s},n,i,r)}}return Io(e)?ga(e,n,r):function(e){let n=e.type;if(n)return e;const{datum:i}=e;return n=t.isNumber(i)?"quantitative":t.isString(i)?"nominal":Oi(i)?"temporal":void 0,{...e,type:n}}(e)}function ga(e,n){let{compositeMark:i=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{aggregate:r,timeUnit:o,bin:a,field:s}=e,l={...e};if(i||!r||Zt(r)||Kt(r)||Jt(r)||(Fi(function(e){return`Invalid aggregation operator "${e}".`}(r)),delete l.aggregate),o&&(l.timeUnit=Ui(o)),s&&(l.field=`${s}`),an(a)&&(l.bin=ha(a,n)),sn(a)&&!Dt(n)&&Fi(function(e){return`Channel ${e} should not be used with "binned" bin.`}(n)),Xo(l)){const{type:e}=l,t=function(e){if(e)switch(e=e.toLowerCase()){case"q":case ir:return"quantitative";case"t":case or:return"temporal";case"o":case rr:return"ordinal";case"n":case ar:return"nominal";case sr:return"geojson"}}(e);e!==t&&(l.type=t),"quantitative"!==e&&tn(r)&&(Fi(function(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}(e,r)),l.type="quantitative")}else if(!Ze(n)){const e=function(e,n){switch(n){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(To(e)&&t.isArray(e.sort))return"ordinal";const{aggregate:i,bin:r,timeUnit:o}=e;if(o)return"temporal";if(r||i&&!Kt(i)&&!Jt(i))return"quantitative";if(Jo(e)&&e.scale?.type)switch(cr[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}(l,n);l.type=e}if(Xo(l)){const{compatible:e,warning:t}=function(e,t){const n=e.type;if("geojson"===n&&"shape"!==t)return{compatible:!1,warning:`Channel ${t} should not be used with a geojson data.`};switch(t){case J:case K:case Z:return ia(e)?ya:{compatible:!1,warning:ci(t)};case ee:case te:case re:case oe:case me:case ge:case he:case De:case Oe:case ze:case _e:case Ce:case Ne:case be:case le:case ae:case Pe:return ya;case fe:case pe:case ue:case de:return n!==ir?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:ya;case xe:case we:case $e:case ke:case ve:case ce:case se:case ne:case ie:return"nominal"!==n||e.sort?ya:{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`};case ye:case Se:return ia(e)||Jo(i=e)&&$r(i.scale?.type)?ya:{compatible:!1,warning:ui(t)};case Fe:return"nominal"!==e.type||"sort"in e?ya:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}}var i}(l,n)||{};!1===e&&Fi(t)}if(To(l)&&t.isString(l.sort)){const{sort:e}=l;if(zo(e))return{...l,sort:{encoding:e}};const t=e.substr(1);if("-"===e.charAt(0)&&zo(t))return{...l,sort:{encoding:t,order:"descending"}}}if(Ao(l)){const{header:e}=l;if(e){const{orient:t,...n}=e;if(t)return{...l,header:{...n,labelOrient:e.labelOrient||t,titleOrient:e.titleOrient||t}}}}return l}function ha(e,n){return t.isBoolean(e)?{maxbins:un(n)}:"binned"===e?{binned:!0}:e.maxbins||e.step?e:{...e,maxbins:un(n)}}const ya={compatible:!0};function va(e){const{formatType:t}=ua(e);return"time"===t||!t&&((n=e)&&("temporal"===n.type||Io(n)&&!!n.timeUnit));var n}function ba(e,n){let{timeUnit:i,type:r,wrapTime:o,undefinedIfExprNotRequired:a}=n;const s=i&&Ui(i)?.unit;let l,c=s||"temporal"===r;return fn(e)?l=e.expr:gn(e)?l=e.signal:Oi(e)?(c=!0,l=Ai(e)):(t.isString(e)||t.isNumber(e))&&c&&(l=`datetime(${g(e)})`,function(e){return!!ji[e]}(s)&&(t.isNumber(e)&&e<1e4||t.isString(e)&&isNaN(Date.parse(e)))&&(l=Ai({[s]:e}))),l?o&&c?`time(${l})`:l:a?void 0:g(e)}function xa(e,t){const{type:n}=e;return t.map((t=>{const i=ba(t,{timeUnit:Io(e)?e.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return void 0!==i?{signal:i}:t}))}function wa(e,t){return an(e.bin)?It(t)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const $a={labelAlign:{part:"labels",vgProp:"align"},labelBaseline:{part:"labels",vgProp:"baseline"},labelColor:{part:"labels",vgProp:"fill"},labelFont:{part:"labels",vgProp:"font"},labelFontSize:{part:"labels",vgProp:"fontSize"},labelFontStyle:{part:"labels",vgProp:"fontStyle"},labelFontWeight:{part:"labels",vgProp:"fontWeight"},labelOpacity:{part:"labels",vgProp:"opacity"},labelOffset:null,labelPadding:null,gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDashOffset"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDashOffset"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickSize:null,tickWidth:{part:"ticks",vgProp:"strokeWidth"}};function ka(e){return e?.condition}const Sa=["domain","grid","labels","ticks","title"],Da={grid:"grid",gridCap:"grid",gridColor:"grid",gridDash:"grid",gridDashOffset:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",aria:"main",description:"main",domain:"main",domainCap:"main",domainColor:"main",domainDash:"main",domainDashOffset:"main",domainOpacity:"main",domainWidth:"main",format:"main",formatType:"main",labelAlign:"main",labelAngle:"main",labelBaseline:"main",labelBound:"main",labelColor:"main",labelFlush:"main",labelFlushOffset:"main",labelFont:"main",labelFontSize:"main",labelFontStyle:"main",labelFontWeight:"main",labelLimit:"main",labelLineHeight:"main",labelOffset:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",labelSeparation:"main",maxExtent:"main",minExtent:"main",offset:"both",position:"main",tickCap:"main",tickColor:"main",tickDash:"main",tickDashOffset:"main",tickMinStep:"both",tickOffset:"both",tickOpacity:"main",tickRound:"both",ticks:"main",tickSize:"main",tickWidth:"both",title:"main",titleAlign:"main",titleAnchor:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontStyle:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",encode:"both",scale:"both",tickBand:"both",tickCount:"both",tickExtra:"both",translate:"both",values:"both",zindex:"both"},Fa={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},Oa={...Fa,style:1,labelExpr:1,encoding:1};function za(e){return!!Oa[e]}const _a=_({axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1});function Ca(e){return"mark"in e}class Na{constructor(e,t){this.name=e,this.run=t}hasMatchingType(e){return!!Ca(e)&&(Kr(t=e.mark)?t.type:t)===this.name;var t}}function Pa(e,n){const i=e&&e[n];return!!i&&(t.isArray(i)?b(i,(e=>!!e.field)):Io(i)||Wo(i))}function Aa(e,n){const i=e&&e[n];return!!i&&(t.isArray(i)?b(i,(e=>!!e.field)):Io(i)||Ho(i)||Uo(i))}function ja(e,t){if(Dt(t)){const n=e[t];if((Io(n)||Ho(n))&&nr(n.type)){return Aa(e,rt(t))}}return!1}function Ea(e){return b(Ue,(n=>{if(Pa(e,n)){const i=e[n];if(t.isArray(i))return b(i,(e=>!!e.aggregate));{const e=fa(i);return e&&!!e.aggregate}}return!1}))}function Ta(e,t){const n=[],i=[],r=[],o=[],a={};return qa(e,((s,l)=>{if(Io(s)){const{field:c,aggregate:u,bin:f,timeUnit:d,...p}=s;if(u||d||f){const e=la(s)?.title;let m=na(s,{forAs:!0});const g={...e?[]:{title:sa(s,t,{allowDisabling:!0})},...p,field:m};if(u){let e;if(Kt(u)?(e="argmax",m=na({op:"argmax",field:u.argmax},{forAs:!0}),g.field=`${m}.${c}`):Jt(u)?(e="argmin",m=na({op:"argmin",field:u.argmin},{forAs:!0}),g.field=`${m}.${c}`):"boxplot"!==u&&"errorbar"!==u&&"errorband"!==u&&(e=u),e){const t={op:e,as:m};c&&(t.field=c),o.push(t)}}else if(n.push(m),Xo(s)&&an(f)){if(i.push({bin:f,field:c,as:m}),n.push(na(s,{binSuffix:"end"})),wa(s,l)&&n.push(na(s,{binSuffix:"range"})),Dt(l)){const e={field:`${m}_end`};a[`${l}2`]=e}g.bin="binned",Ze(l)||(g.type=ir)}else if(d){r.push({timeUnit:d,field:c,as:m});const e=Xo(s)&&s.type!==or&&"time";e&&(l===De||l===_e?g.formatType=e:!function(e){return!!wt[e]}(l)?Dt(l)&&(g.axis={formatType:e,...g.axis}):g.legend={formatType:e,...g.legend})}a[l]=g}else n.push(c),a[l]=e[l]}else a[l]=e[l]})),{bins:i,timeUnits:r,aggregate:o,groupby:n,encoding:a}}function Ma(e,t,n){const i=Bt(t,n);if(!i)return!1;if("binned"===i){const n=e[t===ne?ee:te];return!!(Io(n)&&Io(e[t])&&sn(n.bin))}return!0}function La(e,t){const n={};for(const i of _(e)){const r=pa(e[i],i,t,{compositeMark:!0});n[i]=r}return n}function qa(e,n,i){if(e)for(const r of _(e)){const o=e[r];if(t.isArray(o))for(const e of o)n.call(i,e,r);else n.call(i,o,r)}}function Ra(e,n){return _(n).reduce(((i,r)=>{switch(r){case ee:case te:case Ce:case Pe:case Ne:case ne:case ie:case re:case oe:case le:case ce:case ae:case se:case ue:case fe:case de:case pe:case De:case ye:case be:case _e:return i;case Fe:if("line"===e||"trail"===e)return i;case Oe:case ze:{const e=n[r];if(t.isArray(e)||Io(e))for(const n of t.array(e))n.aggregate||i.push(na(n,{}));return i}case ve:if("trail"===e)return i;case me:case ge:case he:case xe:case we:case $e:case Se:case ke:{const e=fa(n[r]);return e&&!e.aggregate&&i.push(na(e,{})),i}}}),[])}function Wa(e,n,i){let r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if("tooltip"in i)return{tooltip:i.tooltip};return{tooltip:[...e.map((e=>{let{fieldPrefix:t,titlePrefix:i}=e;const o=r?` of ${Ua(n)}`:"";return{field:t+n.field,type:n.type,title:gn(i)?{signal:`${i}"${escape(o)}"`}:i+o}})),...k(function(e){const n=[];for(const i of _(e))if(Pa(e,i)){const r=e[i],o=t.array(r);for(const e of o)Io(e)?n.push(e):Wo(e)&&n.push(e.condition)}return n}(i).map(ta),h)]}}function Ua(e){const{title:t,field:n}=e;return B(t,n)}function Ia(e,n,i,r,o){const{scale:a,axis:s}=i;return l=>{let{partName:c,mark:u,positionPrefix:f,endPositionPrefix:d,extraEncoding:p={}}=l;const m=Ua(i);return Ba(e,c,o,{mark:u,encoding:{[n]:{field:`${f}_${i.field}`,type:i.type,...void 0!==m?{title:m}:{},...void 0!==a?{scale:a}:{},...void 0!==s?{axis:s}:{}},...t.isString(d)?{[`${n}2`]:{field:`${d}_${i.field}`}}:{},...r,...p}})}}function Ba(e,n,i,r){const{clip:o,color:a,opacity:s}=e,l=e.type;return e[n]||void 0===e[n]&&i[n]?[{...r,mark:{...i[n],...o?{clip:o}:{},...a?{color:a}:{},...s?{opacity:s}:{},...Kr(r.mark)?r.mark:{type:r.mark},style:`${l}-${String(n)}`,...t.isBoolean(e[n])?{}:e[n]}}]:[]}function Ha(e,t,n){const{encoding:i}=e,r="vertical"===t?"y":"x",o=i[r],a=i[`${r}2`],s=i[`${r}Error`],l=i[`${r}Error2`];return{continuousAxisChannelDef:Va(o,n),continuousAxisChannelDef2:Va(a,n),continuousAxisChannelDefError:Va(s,n),continuousAxisChannelDefError2:Va(l,n),continuousAxis:r}}function Va(e,t){if(e?.aggregate){const{aggregate:n,...i}=e;return n!==t&&Fi(function(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}(n,t)),i}return e}function Ga(e,t){const{mark:n,encoding:i}=e,{x:r,y:o}=i;if(Kr(n)&&n.orient)return n.orient;if(Vo(r)){if(Vo(o)){const e=Io(r)&&r.aggregate,n=Io(o)&&o.aggregate;if(e||n!==t){if(n||e!==t){if(e===t&&n===t)throw new Error("Both x and y cannot have aggregate");return va(o)&&!va(r)?"horizontal":"vertical"}return"horizontal"}return"vertical"}return"horizontal"}if(Vo(o))return"vertical";throw new Error(`Need a valid continuous axis for ${t}s`)}const Ya="boxplot",Xa=new Na(Ya,Ja);function Qa(e){return t.isNumber(e)?"tukey":e}function Ja(e,n){let{config:i}=n;e={...e,encoding:La(e.encoding,i)};const{mark:r,encoding:o,params:a,projection:s,...l}=e,c=Kr(r)?r:{type:r};a&&Fi(Xn("boxplot"));const u=c.extent??i.boxplot.extent,f=_n("size",c,i),d=c.invalid,p=Qa(u),{bins:g,timeUnits:h,transform:y,continuousAxisChannelDef:v,continuousAxis:b,groupby:x,aggregate:w,encodingWithoutContinuousAxis:$,ticksOrient:k,boxOrient:S,customTooltipWithoutAggregatedField:D}=function(e,n,i){const r=Ga(e,Ya),{continuousAxisChannelDef:o,continuousAxis:a}=Ha(e,r,Ya),s=o.field,l=Qa(n),c=[...Ka(s),{op:"median",field:s,as:`mid_box_${s}`},{op:"min",field:s,as:("min-max"===l?"lower_whisker_":"min_")+s},{op:"max",field:s,as:("min-max"===l?"upper_whisker_":"max_")+s}],u="min-max"===l||"tukey"===l?[]:[{calculate:`datum["upper_box_${s}"] - datum["lower_box_${s}"]`,as:`iqr_${s}`},{calculate:`min(datum["upper_box_${s}"] + datum["iqr_${s}"] * ${n}, datum["max_${s}"])`,as:`upper_whisker_${s}`},{calculate:`max(datum["lower_box_${s}"] - datum["iqr_${s}"] * ${n}, datum["min_${s}"])`,as:`lower_whisker_${s}`}],{[a]:f,...d}=e.encoding,{customTooltipWithoutAggregatedField:p,filteredEncoding:m}=function(e){const{tooltip:n,...i}=e;if(!n)return{filteredEncoding:i};let r,o;if(t.isArray(n)){for(const e of n)e.aggregate?(r||(r=[]),r.push(e)):(o||(o=[]),o.push(e));r&&(i.tooltip=r)}else n.aggregate?i.tooltip=n:o=n;return t.isArray(o)&&1===o.length&&(o=o[0]),{customTooltipWithoutAggregatedField:o,filteredEncoding:i}}(d),{bins:g,timeUnits:h,aggregate:y,groupby:v,encoding:b}=Ta(m,i),x="vertical"===r?"horizontal":"vertical",w=r,$=[...g,...h,{aggregate:[...y,...c],groupby:v},...u];return{bins:g,timeUnits:h,transform:$,groupby:v,aggregate:y,continuousAxisChannelDef:o,continuousAxis:a,encodingWithoutContinuousAxis:b,ticksOrient:x,boxOrient:w,customTooltipWithoutAggregatedField:p}}(e,u,i),{color:F,size:O,..._}=$,C=e=>Ia(c,b,v,e,i.boxplot),N=C(_),P=C($),A=C({..._,...O?{size:O}:{}}),j=Wa([{fieldPrefix:"min-max"===p?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:"min-max"===p?"lower_whisker_":"min_",titlePrefix:"Min"}],v,$),E={type:"tick",color:"black",opacity:1,orient:k,invalid:d,aria:!1},T="min-max"===p?j:Wa([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],v,$),M=[...N({partName:"rule",mark:{type:"rule",invalid:d,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:T}),...N({partName:"rule",mark:{type:"rule",invalid:d,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:T}),...N({partName:"ticks",mark:E,positionPrefix:"lower_whisker",extraEncoding:T}),...N({partName:"ticks",mark:E,positionPrefix:"upper_whisker",extraEncoding:T})],L=[..."tukey"!==p?M:[],...P({partName:"box",mark:{type:"bar",...f?{size:f}:{},orient:S,invalid:d,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:j}),...A({partName:"median",mark:{type:"tick",invalid:d,...t.isObject(i.boxplot.median)&&i.boxplot.median.color?{color:i.boxplot.median.color}:{},...f?{size:f}:{},orient:k,aria:!1},positionPrefix:"mid_box",extraEncoding:j})];if("min-max"===p)return{...l,transform:(l.transform??[]).concat(y),layer:L};const q=`datum["lower_box_${v.field}"]`,R=`datum["upper_box_${v.field}"]`,W=`(${R} - ${q})`,U=`${q} - ${u} * ${W}`,I=`${R} + ${u} * ${W}`,B=`datum["${v.field}"]`,H={joinaggregate:Ka(v.field),groupby:x},V={transform:[{filter:`(${U} <= ${B}) && (${B} <= ${I})`},{aggregate:[{op:"min",field:v.field,as:`lower_whisker_${v.field}`},{op:"max",field:v.field,as:`upper_whisker_${v.field}`},{op:"min",field:`lower_box_${v.field}`,as:`lower_box_${v.field}`},{op:"max",field:`upper_box_${v.field}`,as:`upper_box_${v.field}`},...w],groupby:x}],layer:M},{tooltip:G,...Y}=_,{scale:X,axis:Q}=v,J=Ua(v),K=m(Q,["title"]),Z=Ba(c,"outliers",i.boxplot,{transform:[{filter:`(${B} < ${U}) || (${B} > ${I})`}],mark:"point",encoding:{[b]:{field:v.field,type:v.type,...void 0!==J?{title:J}:{},...void 0!==X?{scale:X}:{},...z(K)?{}:{axis:K}},...Y,...F?{color:F}:{},...D?{tooltip:D}:{}}})[0];let ee;const te=[...g,...h,H];return Z?ee={transform:te,layer:[Z,V]}:(ee=V,ee.transform.unshift(...te)),{...l,layer:[ee,{transform:y,layer:L}]}}function Ka(e){return[{op:"q1",field:e,as:`lower_box_${e}`},{op:"q3",field:e,as:`upper_box_${e}`}]}const Za="errorbar",es=new Na(Za,ts);function ts(e,t){let{config:n}=t;e={...e,encoding:La(e.encoding,n)};const{transform:i,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:a,ticksOrient:s,markDef:l,outerSpec:c,tooltipEncoding:u}=is(e,Za,n);delete a.size;const f=Ia(l,o,r,a,n.errorbar),d=l.thickness,p=l.size,m={type:"tick",orient:s,aria:!1,...void 0!==d?{thickness:d}:{},...void 0!==p?{size:p}:{}},g=[...f({partName:"ticks",mark:m,positionPrefix:"lower",extraEncoding:u}),...f({partName:"ticks",mark:m,positionPrefix:"upper",extraEncoding:u}),...f({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...void 0!==d?{size:d}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u})];return{...c,transform:i,...g.length>1?{layer:g}:{...g[0]}}}function ns(e,t){const{encoding:n}=e;if(function(e){return(Yo(e.x)||Yo(e.y))&&!Yo(e.x2)&&!Yo(e.y2)&&!Yo(e.xError)&&!Yo(e.xError2)&&!Yo(e.yError)&&!Yo(e.yError2)}(n))return{orient:Ga(e,t),inputType:"raw"};const i=function(e){return Yo(e.x2)||Yo(e.y2)}(n),r=function(e){return Yo(e.xError)||Yo(e.xError2)||Yo(e.yError)||Yo(e.yError2)}(n),o=n.x,a=n.y;if(i){if(r)throw new Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`);const e=n.x2,i=n.y2;if(Yo(e)&&Yo(i))throw new Error(`${t} cannot have both x2 and y2`);if(Yo(e)){if(Vo(o))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${t}`)}if(Yo(i)){if(Vo(a))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error(`Both y and y2 have to be quantitative in ${t}`)}throw new Error("No ranged axis")}{const e=n.xError,i=n.xError2,r=n.yError,s=n.yError2;if(Yo(i)&&!Yo(e))throw new Error(`${t} cannot have xError2 without xError`);if(Yo(s)&&!Yo(r))throw new Error(`${t} cannot have yError2 without yError`);if(Yo(e)&&Yo(r))throw new Error(`${t} cannot have both xError and yError with both are quantiative`);if(Yo(e)){if(Vo(o))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}if(Yo(r)){if(Vo(a))return{orient:"vertical",inputType:"aggregated-error"};throw new Error("All y, yError, and yError2 (if exist) have to be quantitative")}throw new Error("No ranged axis")}}function is(e,t,n){const{mark:i,encoding:r,params:o,projection:a,...s}=e,l=Kr(i)?i:{type:i};o&&Fi(Xn(t));const{orient:c,inputType:u}=ns(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:d,continuousAxisChannelDefError:p,continuousAxisChannelDefError2:m,continuousAxis:g}=Ha(e,c,t),{errorBarSpecificAggregate:h,postAggregateCalculates:y,tooltipSummary:v,tooltipTitleWithFieldName:b}=function(e,t,n,i,r,o,a,s){let l=[],c=[];const u=t.field;let f,d=!1;if("raw"===o){const t=e.center?e.center:e.extent?"iqr"===e.extent?"median":"mean":s.errorbar.center,n=e.extent?e.extent:"mean"===t?"stderr":"iqr";if("median"===t!=("iqr"===n)&&Fi(function(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}(t,n,a)),"stderr"===n||"stdev"===n)l=[{op:n,field:u,as:`extent_${u}`},{op:t,field:u,as:`center_${u}`}],c=[{calculate:`datum["center_${u}"] + datum["extent_${u}"]`,as:`upper_${u}`},{calculate:`datum["center_${u}"] - datum["extent_${u}"]`,as:`lower_${u}`}],f=[{fieldPrefix:"center_",titlePrefix:T(t)},{fieldPrefix:"upper_",titlePrefix:rs(t,n,"+")},{fieldPrefix:"lower_",titlePrefix:rs(t,n,"-")}],d=!0;else{let e,t,i;"ci"===n?(e="mean",t="ci0",i="ci1"):(e="median",t="q1",i="q3"),l=[{op:t,field:u,as:`lower_${u}`},{op:i,field:u,as:`upper_${u}`},{op:e,field:u,as:`center_${u}`}],f=[{fieldPrefix:"upper_",titlePrefix:sa({field:u,aggregate:i,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:sa({field:u,aggregate:t,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:sa({field:u,aggregate:e,type:"quantitative"},s,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&Fi((p=e.center,`${(m=e.extent)?"extent ":""}${m&&p?"and ":""}${p?"center ":""}${m&&p?"are ":"is "}not needed when data are aggregated.`)),"aggregated-upper-lower"===o?(f=[],c=[{calculate:`datum["${n.field}"]`,as:`upper_${u}`},{calculate:`datum["${u}"]`,as:`lower_${u}`}]):"aggregated-error"===o&&(f=[{fieldPrefix:"",titlePrefix:u}],c=[{calculate:`datum["${u}"] + datum["${i.field}"]`,as:`upper_${u}`}],r?c.push({calculate:`datum["${u}"] + datum["${r.field}"]`,as:`lower_${u}`}):c.push({calculate:`datum["${u}"] - datum["${i.field}"]`,as:`lower_${u}`}));for(const e of c)f.push({fieldPrefix:e.as.substring(0,6),titlePrefix:W(W(e.calculate,'datum["',""),'"]',"")})}var p,m;return{postAggregateCalculates:c,errorBarSpecificAggregate:l,tooltipSummary:f,tooltipTitleWithFieldName:d}}(l,f,d,p,m,u,t,n),{[g]:x,["x"===g?"x2":"y2"]:w,["x"===g?"xError":"yError"]:$,["x"===g?"xError2":"yError2"]:k,...S}=r,{bins:D,timeUnits:F,aggregate:O,groupby:z,encoding:_}=Ta(S,n),C=[...O,...h],N="raw"!==u?[]:z,P=Wa(v,f,_,b);return{transform:[...s.transform??[],...D,...F,...0===C.length?[]:[{aggregate:C,groupby:N}],...y],groupby:N,continuousAxisChannelDef:f,continuousAxis:g,encodingWithoutContinuousAxis:_,ticksOrient:"vertical"===c?"horizontal":"vertical",markDef:l,outerSpec:s,tooltipEncoding:P}}function rs(e,t,n){return`${T(e)} ${n} ${t}`}const os="errorband",as=new Na(os,ss);function ss(e,t){let{config:n}=t;e={...e,encoding:La(e.encoding,n)};const{transform:i,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:a,markDef:s,outerSpec:l,tooltipEncoding:c}=is(e,os,n),u=s,f=Ia(u,o,r,a,n.errorband),d=void 0!==e.encoding.x&&void 0!==e.encoding.y;let p={type:d?"area":"rect"},m={type:d?"line":"rule"};const g={...u.interpolate?{interpolate:u.interpolate}:{},...u.tension&&u.interpolate?{tension:u.tension}:{}};return d?(p={...p,...g,ariaRoleDescription:"errorband"},m={...m,...g,aria:!1}):u.interpolate?Fi($i("interpolate")):u.tension&&Fi($i("tension")),{...l,transform:i,layer:[...f({partName:"band",mark:p,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:c}),...f({partName:"borders",mark:m,positionPrefix:"lower",extraEncoding:c}),...f({partName:"borders",mark:m,positionPrefix:"upper",extraEncoding:c})]}}const ls={};function cs(e,t,n){const i=new Na(e,t);ls[e]={normalizer:i,parts:n}}cs(Ya,Ja,["box","median","outliers","rule","ticks"]),cs(Za,ts,["ticks","rule"]),cs(os,ss,["band","borders"]);const us=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],fs={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},ds={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelBaseline:"baseline",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelFontWeight:"fontWeight",labelLimit:"limit",labelLineHeight:"lineHeight",labelOrient:"orient",labelPadding:"offset"},ps=_(fs),ms=_(ds),gs=_({header:1,headerRow:1,headerColumn:1,headerFacet:1}),hs=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],ys="_vgsid_",vs={point:{on:"click",fields:[ys],toggle:"event.shiftKey",resolve:"global",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function bs(e){return"legend"===e||!!e?.legend}function xs(e){return bs(e)&&t.isObject(e)}function ws(e){return!!e?.select}function $s(e){const t=[];for(const n of e||[]){if(ws(n))continue;const{expr:e,bind:i,...r}=n;if(i&&e){const n={...r,bind:i,init:e};t.push(n)}else{const n={...r,...e?{update:e}:{},...i?{bind:i}:{}};t.push(n)}}return t}function ks(e){return"concat"in e}function Ss(e){return"vconcat"in e}function Ds(e){return"hconcat"in e}function Fs(e){let{step:t,offsetIsDiscrete:n}=e;return n?t.for??"offset":"position"}function Os(e){return t.isObject(e)&&void 0!==e.step}function zs(e){return e.view||e.width||e.height}const _s=_({align:1,bounds:1,center:1,columns:1,spacing:1});function Cs(e,t){return e[t]??e["width"===t?"continuousWidth":"continuousHeight"]}function Ns(e,t){const n=Ps(e,t);return Os(n)?n.step:As}function Ps(e,t){return B(e[t]??e["width"===t?"discreteWidth":"discreteHeight"],{step:e.step})}const As=20,js={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:{continuousWidth:200,continuousHeight:200,step:As},mark:{color:"#4c78a8",invalid:"filter",timeUnitBandSize:1},arc:{},area:{},bar:ro,circle:{},geoshape:{},image:{},line:{},point:{},rect:oo,rule:{color:"black"},square:{},text:{color:"black"},tick:{thickness:1},trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:{pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0},projection:{},legend:{gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:vs,style:{},title:{},facet:{spacing:20},concat:{spacing:20},normalizedNumberFormat:".0%"},Es=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],Ts={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},Ms={blue:Es[0],orange:Es[1],red:Es[2],teal:Es[3],green:Es[4],yellow:Es[5],purple:Es[6],pink:Es[7],brown:Es[8],gray0:"#000",gray1:"#111",gray2:"#222",gray3:"#333",gray4:"#444",gray5:"#555",gray6:"#666",gray7:"#777",gray8:"#888",gray9:"#999",gray10:"#aaa",gray11:"#bbb",gray12:"#ccc",gray13:"#ddd",gray14:"#eee",gray15:"#fff"};function Ls(e){const t=_(e||{}),n={};for(const i of t){const t=e[i];n[i]=ka(t)?wn(t):$n(t)}return n}const qs=[...to,..._a,...gs,"background","padding","legend","lineBreak","scale","style","title","view"];function Rs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:n,font:i,fontSize:r,selection:o,...a}=e,s=t.mergeConfig({},f(js),i?function(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}(i):{},n?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{signals:[{name:"color",value:t.isObject(e)?{...Ms,...e}:Ms}],mark:{color:{signal:"color.blue"}},rule:{color:{signal:"color.gray0"}},text:{color:{signal:"color.gray0"}},style:{"guide-label":{fill:{signal:"color.gray0"}},"guide-title":{fill:{signal:"color.gray0"}},"group-title":{fill:{signal:"color.gray0"}},"group-subtitle":{fill:{signal:"color.gray0"}},cell:{stroke:{signal:"color.gray8"}}},axis:{domainColor:{signal:"color.gray13"},gridColor:{signal:"color.gray8"},tickColor:{signal:"color.gray13"}},range:{category:[{signal:"color.blue"},{signal:"color.orange"},{signal:"color.red"},{signal:"color.teal"},{signal:"color.green"},{signal:"color.yellow"},{signal:"color.purple"},{signal:"color.pink"},{signal:"color.brown"},{signal:"color.grey8"}]}}}(n):{},r?function(e){return{signals:[{name:"fontSize",value:t.isObject(e)?{...Ts,...e}:Ts}],text:{fontSize:{signal:"fontSize.text"}},style:{"guide-label":{fontSize:{signal:"fontSize.guideLabel"}},"guide-title":{fontSize:{signal:"fontSize.guideTitle"}},"group-title":{fontSize:{signal:"fontSize.groupTitle"}},"group-subtitle":{fontSize:{signal:"fontSize.groupSubtitle"}}}}}(r):{},a||{});o&&t.writeConfig(s,"selection",o,!0);const l=m(s,qs);for(const e of["background","lineBreak","padding"])s[e]&&(l[e]=$n(s[e]));for(const e of to)s[e]&&(l[e]=dn(s[e]));for(const e of _a)s[e]&&(l[e]=Ls(s[e]));for(const e of gs)s[e]&&(l[e]=dn(s[e]));return s.legend&&(l.legend=dn(s.legend)),s.scale&&(l.scale=dn(s.scale)),s.style&&(l.style=function(e){const t=_(e),n={};for(const i of t)n[i]=Ls(e[i]);return n}(s.style)),s.title&&(l.title=dn(s.title)),s.view&&(l.view=dn(s.view)),l}const Ws=new Set(["view",...Jr]),Us=["color","fontSize","background","padding","facet","concat","numberFormat","numberFormatType","normalizedNumberFormat","normalizedNumberFormatType","timeFormat","countTitle","header","axisQuantitative","axisTemporal","axisDiscrete","axisPoint","axisXBand","axisXPoint","axisXDiscrete","axisXQuantitative","axisXTemporal","axisYBand","axisYPoint","axisYDiscrete","axisYQuantitative","axisYTemporal","scale","selection","overlay"],Is={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],tick:["bandSize","thickness"]};function Bs(e){e=f(e);for(const t of Us)delete e[t];if(e.axis)for(const t in e.axis)ka(e.axis[t])&&delete e.axis[t];if(e.legend)for(const t of us)delete e.legend[t];if(e.mark){for(const t of eo)delete e.mark[t];e.mark.tooltip&&t.isObject(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat($s(e.params)),delete e.params);for(const t of Ws){for(const n of eo)delete e[t][n];const n=Is[t];if(n)for(const i of n)delete e[t][i];Hs(e,t)}for(const t of _(ls))delete e[t];!function(e){const{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:i}=pn(e.title);z(t)||(e.style["group-title"]={...e.style["group-title"],...t});z(n)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...n});z(i)?delete e.title:e.title=i}(e);for(const n in e)t.isObject(e[n])&&z(e[n])&&delete e[n];return z(e)?void 0:e}function Hs(e,t,n,i){"view"===t&&(n="cell");const r={...i?e[t][i]:e[t],...e.style[n??t]};z(r)||(e.style[n??t]=r),i||delete e[t]}function Vs(e){return"layer"in e}class Gs{map(e,t){return jo(e)?this.mapFacet(e,t):function(e){return"repeat"in e}(e)?this.mapRepeat(e,t):Ds(e)?this.mapHConcat(e,t):Ss(e)?this.mapVConcat(e,t):ks(e)?this.mapConcat(e,t):this.mapLayerOrUnit(e,t)}mapLayerOrUnit(e,t){if(Vs(e))return this.mapLayer(e,t);if(Ca(e))return this.mapUnit(e,t);throw new Error(Wn(e))}mapLayer(e,t){return{...e,layer:e.layer.map((e=>this.mapLayerOrUnit(e,t)))}}mapHConcat(e,t){return{...e,hconcat:e.hconcat.map((e=>this.map(e,t)))}}mapVConcat(e,t){return{...e,vconcat:e.vconcat.map((e=>this.map(e,t)))}}mapConcat(e,t){const{concat:n,...i}=e;return{...i,concat:n.map((e=>this.map(e,t)))}}mapFacet(e,t){return{...e,spec:this.map(e.spec,t)}}mapRepeat(e,t){return{...e,spec:this.map(e.spec,t)}}}const Ys={zero:1,center:1,normalize:1};const Xs=new Set([Er,Mr,Tr,Ur,Rr,Vr,Gr,qr,Ir,Br]),Qs=new Set([Mr,Tr,Er]);function Js(e){return Io(e)&&"quantitative"===Bo(e)&&!e.bin}function Ks(e,t){const n="x"===t?"y":"radius",i=e[t],r=e[n];if(Io(i)&&Io(r))if(Js(i)&&Js(r)){if(i.stack)return t;if(r.stack)return n;const e=Io(i)&&!!i.aggregate;if(e!==(Io(r)&&!!r.aggregate))return e?t:n;{const e=i.scale?.type,o=r.scale?.type;if(e&&"linear"!==e)return n;if(o&&"linear"!==o)return t}}else{if(Js(i))return t;if(Js(r))return n}else{if(Js(i))return t;if(Js(r))return n}}function Zs(e,n){const i=Kr(e)?e.type:e;if(!Xs.has(i))return null;const r=Ks(n,"x")||Ks(n,"theta");if(!r)return null;const o=n[r],a=Io(o)?na(o,{}):void 0,s=function(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}(r),l=[],c=new Set;if(n[s]){const e=n[s],t=Io(e)?na(e,{}):void 0;t&&t!==a&&(l.push(s),c.add(t));const i="x"===s?"xOffset":"yOffset",r=n[i],o=Io(r)?na(r,{}):void 0;o&&o!==a&&(l.push(i),c.add(o))}const u=$t.reduce(((e,i)=>{if("tooltip"!==i&&Pa(n,i)){const r=n[i];for(const n of t.array(r)){const t=fa(n);if(t.aggregate)continue;const r=na(t,{});r&&c.has(r)||e.push({channel:i,fieldDef:t})}}return e}),[]);let f;return void 0!==o.stack?f=t.isBoolean(o.stack)?o.stack?"zero":null:o.stack:Qs.has(i)&&(f="zero"),f&&f in Ys?Ea(n)&&0===u.length?null:o?.scale?.type&&o?.scale?.type!==lr.LINEAR?(Fi(function(e){return`Cannot stack non-linear scale (${e}).`}(o.scale.type)),null):Yo(n[nt(r)])?(void 0!==o.stack&&Fi(`Cannot stack "${d=r}" if there is already "${d}2".`),null):(Io(o)&&o.aggregate&&!nn.has(o.aggregate)&&Fi(`Stacking is applied even though the aggregate function is non-summative ("${o.aggregate}").`),{groupbyChannels:l,groupbyFields:c,fieldChannel:r,impute:null!==o.impute&&Xr(i),stackBy:u,offset:f}):null;var d}function el(e){const{point:t,line:n,...i}=e;return _(i).length>1?i:i.type}function tl(e){for(const t of["line","area","rule","trail"])e[t]&&(e={...e,[t]:m(e[t],["point","line"])});return e}function nl(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return"transparent"===e.point?{opacity:0}:e.point?t.isObject(e.point)?e.point:{}:void 0!==e.point?null:n.point||i.shape?t.isObject(n.point)?n.point:{}:void 0}function il(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.line?!0===e.line?{}:e.line:void 0!==e.line?null:t.line?!0===t.line?{}:t.line:void 0}class rl{constructor(){Mn(this,"name","path-overlay")}hasMatchingType(e,t){if(Ca(e)){const{mark:n,encoding:i}=e,r=Kr(n)?n:{type:n};switch(r.type){case"line":case"rule":case"trail":return!!nl(r,t[r.type],i);case"area":return!!nl(r,t[r.type],i)||!!il(r,t[r.type])}}return!1}run(e,t,n){const{config:i}=t,{params:r,projection:o,mark:a,encoding:s,...l}=e,c=La(s,i),u=Kr(a)?a:{type:a},f=nl(u,i[u.type],c),d="area"===u.type&&il(u,i[u.type]),g=[{...r?{params:r}:{},mark:el({..."area"===u.type&&void 0===u.opacity&&void 0===u.fillOpacity?{opacity:.7}:{},...u}),encoding:m(c,["shape"])}],h=Zs(u,c);let y=c;if(h){const{fieldChannel:e,offset:t}=h;y={...c,[e]:{...c[e],...t?{stack:t}:{}}}}return y=m(y,["y2","x2"]),d&&g.push({...o?{projection:o}:{},mark:{type:"line",...p(u,["clip","interpolate","tension","tooltip"]),...d},encoding:y}),f&&g.push({...o?{projection:o}:{},mark:{type:"point",opacity:1,filled:!0,...p(u,["clip","tooltip"]),...f},encoding:y}),n({...l,layer:g},{...t,config:tl(i)})}}function ol(e,t){return t?Po(e)?fl(e,t):ll(e,t):e}function al(e,t){return t?fl(e,t):e}function sl(e,n,i){const r=n[e];return(o=r)&&!t.isString(o)&&"repeat"in o?r.repeat in i?{...n,[e]:i[r.repeat]}:void Fi(function(e){return`Unknown repeated value "${e}".`}(r.repeat)):n;var o}function ll(e,t){if(void 0!==(e=sl("field",e,t))){if(null===e)return null;if(To(e)&&Co(e.sort)){const n=sl("field",e.sort,t);e={...e,...n?{sort:n}:{}}}return e}}function cl(e,t){if(Io(e))return ll(e,t);{const n=sl("datum",e,t);return n===e||n.type||(n.type="nominal"),n}}function ul(e,t){if(!Yo(e)){if(Uo(e)){const n=cl(e.condition,t);if(n)return{...e,condition:n};{const{condition:t,...n}=e;return n}}return e}{const n=cl(e,t);if(n)return n;if(Ro(e))return{condition:e.condition}}}function fl(e,n){const i={};for(const r in e)if(t.hasOwnProperty(e,r)){const o=e[r];if(t.isArray(o))i[r]=o.map((e=>ul(e,n))).filter((e=>e));else{const e=ul(o,n);void 0!==e&&(i[r]=e)}}return i}class dl{constructor(){Mn(this,"name","RuleForRangedLine")}hasMatchingType(e){if(Ca(e)){const{encoding:t,mark:n}=e;if("line"===n||Kr(n)&&"line"===n.type)for(const e of Ke){const n=t[et(e)];if(t[e]&&(Io(n)&&!sn(n.bin)||Ho(n)))return!0}}return!1}run(e,n,i){const{encoding:r,mark:o}=e;var a,s;return Fi((a=!!r.x2,s=!!r.y2,`Line mark is for continuous lines and thus cannot be used with ${a&&s?"x2 and y2":a?"x2":"y2"}. We will use the rule mark (line segments) instead.`)),i({...e,mark:t.isObject(o)?{...o,type:"rule"}:"rule"},n)}}function pl(e){let{parentEncoding:n,encoding:i={},layer:r}=e,o={};if(n){const e=new Set([..._(n),..._(i)]);for(const a of e){const e=i[a],s=n[a];if(Yo(e)){const t={...s,...e};o[a]=t}else Uo(e)?o[a]={...e,condition:{...s,...e.condition}}:e||null===e?o[a]=e:(r||Qo(s)||gn(s)||Yo(s)||t.isArray(s))&&(o[a]=s)}}else o=i;return!o||z(o)?void 0:o}function ml(e){const{parentProjection:t,projection:n}=e;return t&&n&&Fi(function(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${g(t)} is overridden by a child projection ${g(n)}.`}({parentProjection:t,projection:n})),n??t}function gl(e){return"filter"in e}function hl(e){return"lookup"in e}function yl(e){return"pivot"in e}function vl(e){return"density"in e}function bl(e){return"quantile"in e}function xl(e){return"regression"in e}function wl(e){return"loess"in e}function $l(e){return"sample"in e}function kl(e){return"window"in e}function Sl(e){return"joinaggregate"in e}function Dl(e){return"flatten"in e}function Fl(e){return"calculate"in e}function Ol(e){return"bin"in e}function zl(e){return"impute"in e}function _l(e){return"timeUnit"in e}function Cl(e){return"aggregate"in e}function Nl(e){return"stack"in e}function Pl(e){return"fold"in e}function Al(e,t){const{transform:n,...i}=e;if(n){return{...i,transform:n.map((e=>{if(gl(e))return{filter:Tl(e,t)};if(Ol(e)&&ln(e.bin))return{...e,bin:El(e.bin)};if(hl(e)){const{selection:t,...n}=e.from;return t?{...e,from:{param:t,...n}}:e}return e}))}}return e}function jl(e,n){const i=f(e);if(Io(i)&&ln(i.bin)&&(i.bin=El(i.bin)),Jo(i)&&i.scale?.domain?.selection){const{selection:e,...t}=i.scale.domain;i.scale.domain={...t,...e?{param:e}:{}}}if(Ro(i))if(t.isArray(i.condition))i.condition=i.condition.map((e=>{const{selection:t,param:i,test:r,...o}=e;return i?e:{...o,test:Tl(e,n)}}));else{const{selection:e,param:t,test:r,...o}=jl(i.condition,n);i.condition=t?i.condition:{...o,test:Tl(i.condition,n)}}return i}function El(e){const t=e.extent;if(t?.selection){const{selection:n,...i}=t;return{...e,extent:{...i,param:n}}}return e}function Tl(e,t){const n=e=>c(e,(e=>{const n={param:e,empty:t.emptySelections[e]??!0};return t.selectionPredicates[e]??=[],t.selectionPredicates[e].push(n),n}));return e.selection?n(e.selection):c(e.test||e.filter,(e=>e.selection?n(e.selection):e))}class Ml extends Gs{map(e,t){const n=t.selections??[];if(e.params&&!Ca(e)){const t=[];for(const i of e.params)ws(i)?n.push(i):t.push(i);e.params=t}return t.selections=n,super.map(e,Ll(e,t))}mapUnit(e,n){const i=n.selections;if(!i||!i.length)return e;const r=(n.path??[]).concat(e.name),o=[];for(const n of i)if(n.views&&n.views.length)for(const i of n.views)(t.isString(i)&&(i===e.name||r.indexOf(i)>=0)||t.isArray(i)&&i.map((e=>r.indexOf(e))).every(((e,t,n)=>-1!==e&&(0===t||e>n[t-1]))))&&o.push(n);else o.push(n);return o.length&&(e.params=o),e}}for(const e of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const t=Ml.prototype[e];Ml.prototype[e]=function(e,n){return t.call(this,e,Ll(e,n))}}function Ll(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function ql(e,t){void 0===t&&(t=Rs(e.config));const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={config:t};return Ul.map(Rl.map(Wl.map(e,n),n),n)}(e,t),{width:i,height:r}=e,o=function(e,t,n){let{width:i,height:r}=t;const o=Ca(e)||Vs(e),a={};o?"container"==i&&"container"==r?(a.type="fit",a.contains="padding"):"container"==i?(a.type="fit-x",a.contains="padding"):"container"==r&&(a.type="fit-y",a.contains="padding"):("container"==i&&(Fi(In("width")),i=void 0),"container"==r&&(Fi(In("height")),r=void 0));const s={type:"pad",...a,...n?Il(n.autosize):{},...Il(e.autosize)};"fit"!==s.type||o||(Fi(Un),s.type="pad");"container"==i&&"fit"!=s.type&&"fit-x"!=s.type&&Fi(Bn("width"));"container"==r&&"fit"!=s.type&&"fit-y"!=s.type&&Fi(Bn("height"));if(u(s,{type:"pad"}))return;return s}(n,{width:i,height:r,autosize:e.autosize},t);return{...n,...o?{autosize:o}:{}}}const Rl=new class extends Gs{constructor(){super(...arguments),Mn(this,"nonFacetUnitNormalizers",[Xa,es,as,new rl,new dl])}map(e,t){if(Ca(e)){const n=Pa(e.encoding,J),i=Pa(e.encoding,K),r=Pa(e.encoding,Z);if(n||i||r)return this.mapFacetedUnit(e,t)}return super.map(e,t)}mapUnit(e,t){const{parentEncoding:n,parentProjection:i}=t,r=al(e.encoding,t.repeater),o={...e,...r?{encoding:r}:{}};if(n||i)return this.mapUnitWithParentEncodingOrProjection(o,t);const a=this.mapLayerOrUnit.bind(this);for(const e of this.nonFacetUnitNormalizers)if(e.hasMatchingType(o,t.config))return e.run(o,t,a);return o}mapRepeat(e,n){return function(e){return!t.isArray(e.repeat)&&e.repeat.layer}(e)?this.mapLayerRepeat(e,n):this.mapNonLayerRepeat(e,n)}mapLayerRepeat(e,t){const{repeat:n,spec:i,...r}=e,{row:o,column:a,layer:s}=n,{repeater:l={},repeaterPrefix:c=""}=t;return o||a?this.mapRepeat({...e,repeat:{...o?{row:o}:{},...a?{column:a}:{}},spec:{repeat:{layer:s},spec:i}},t):{...r,layer:s.map((e=>{const n={...l,layer:e},r=`${(i.name||"")+c}child__layer_${A(e)}`,o=this.mapLayerOrUnit(i,{...t,repeater:n,repeaterPrefix:r});return o.name=r,o}))}}mapNonLayerRepeat(e,n){const{repeat:i,spec:r,data:o,...a}=e;!t.isArray(i)&&e.columns&&(e=m(e,["columns"]),Fi(Jn("repeat")));const s=[],{repeater:l={},repeaterPrefix:c=""}=n,u=!t.isArray(i)&&i.row||[l?l.row:null],f=!t.isArray(i)&&i.column||[l?l.column:null],d=t.isArray(i)&&i||[l?l.repeat:null];for(const e of d)for(const o of u)for(const a of f){const u={repeat:e,row:o,column:a,layer:l.layer},f=(r.name||"")+c+"child__"+(t.isArray(i)?`${A(e)}`:(i.row?`row_${A(o)}`:"")+(i.column?`column_${A(a)}`:"")),d=this.map(r,{...n,repeater:u,repeaterPrefix:f});d.name=f,s.push(m(d,["data"]))}const p=t.isArray(i)?e.columns:i.column?i.column.length:1;return{data:r.data??o,align:"all",...a,columns:p,concat:s}}mapFacet(e,t){const{facet:n}=e;return Po(n)&&e.columns&&(e=m(e,["columns"]),Fi(Jn("facet"))),super.mapFacet(e,t)}mapUnitWithParentEncodingOrProjection(e,t){const{encoding:n,projection:i}=e,{parentEncoding:r,parentProjection:o,config:a}=t,s=ml({parentProjection:o,projection:i}),l=pl({parentEncoding:r,encoding:al(n,t.repeater)});return this.mapUnit({...e,...s?{projection:s}:{},...l?{encoding:l}:{}},{config:a})}mapFacetedUnit(e,t){const{row:n,column:i,facet:r,...o}=e.encoding,{mark:a,width:s,projection:l,height:c,view:u,params:f,encoding:d,...p}=e,{facetMapping:m,layout:g}=this.getFacetMappingAndLayout({row:n,column:i,facet:r},t),h=al(o,t.repeater);return this.mapFacet({...p,...g,facet:m,spec:{...s?{width:s}:{},...c?{height:c}:{},...u?{view:u}:{},...l?{projection:l}:{},mark:a,encoding:h,...f?{params:f}:{}}},t)}getFacetMappingAndLayout(e,t){const{row:n,column:i,facet:r}=e;if(n||i){r&&Fi(`Facet encoding dropped as ${(o=[...n?[J]:[],...i?[K]:[]]).join(" and ")} ${o.length>1?"are":"is"} also specified.`);const t={},a={};for(const n of[J,K]){const i=e[n];if(i){const{align:e,center:r,spacing:o,columns:s,...l}=i;t[n]=l;for(const e of["align","center","spacing"])void 0!==i[e]&&(a[e]??={},a[e][n]=i[e])}}return{facetMapping:t,layout:a}}{const{align:e,center:n,spacing:i,columns:o,...a}=r;return{facetMapping:ol(a,t.repeater),layout:{...e?{align:e}:{},...n?{center:n}:{},...i?{spacing:i}:{},...o?{columns:o}:{}}}}var o}mapLayer(e,t){let{parentEncoding:n,parentProjection:i,...r}=t;const{encoding:o,projection:a,...s}=e,l={...r,parentEncoding:pl({parentEncoding:n,encoding:o,layer:!0}),parentProjection:ml({parentProjection:i,projection:a})};return super.mapLayer(s,l)}},Wl=new class extends Gs{map(e,t){return t.emptySelections??={},t.selectionPredicates??={},e=Al(e,t),super.map(e,t)}mapLayerOrUnit(e,t){if((e=Al(e,t)).encoding){const n={};for(const[i,r]of N(e.encoding))n[i]=jl(r,t);e={...e,encoding:n}}return super.mapLayerOrUnit(e,t)}mapUnit(e,t){const{selection:n,...i}=e;return n?{...i,params:N(n).map((e=>{let[n,i]=e;const{init:r,bind:o,empty:a,...s}=i;"single"===s.type?(s.type="point",s.toggle=!1):"multi"===s.type&&(s.type="point"),t.emptySelections[n]="none"!==a;for(const e of C(t.selectionPredicates[n]??{}))e.empty="none"!==a;return{name:n,value:r,select:s,bind:o}}))}:e}},Ul=new Ml;function Il(e){return t.isString(e)?{type:e}:e??{}}const Bl=["background","padding"];function Hl(e,t){const n={};for(const t of Bl)e&&void 0!==e[t]&&(n[t]=$n(e[t]));return t&&(n.params=e.params),n}class Vl{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.explicit=e,this.implicit=t}clone(){return new Vl(f(this.explicit),f(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(e){return B(this.explicit[e],this.implicit[e])}getWithExplicit(e){return void 0!==this.explicit[e]?{explicit:!0,value:this.explicit[e]}:void 0!==this.implicit[e]?{explicit:!1,value:this.implicit[e]}:{explicit:!1,value:void 0}}setWithExplicit(e,t){let{value:n,explicit:i}=t;void 0!==n&&this.set(e,n,i)}set(e,t,n){return delete this[n?"implicit":"explicit"][e],this[n?"explicit":"implicit"][e]=t,this}copyKeyFromSplit(e,t){let{explicit:n,implicit:i}=t;void 0!==n[e]?this.set(e,n[e],!0):void 0!==i[e]&&this.set(e,i[e],!1)}copyKeyFromObject(e,t){void 0!==t[e]&&this.set(e,t[e],!0)}copyAll(e){for(const t of _(e.combine())){const n=e.getWithExplicit(t);this.setWithExplicit(t,n)}}}function Gl(e){return{explicit:!0,value:e}}function Yl(e){return{explicit:!1,value:e}}function Xl(e){return(t,n,i,r)=>{const o=e(t.value,n.value);return o>0?t:o<0?n:Ql(t,n,i,r)}}function Ql(e,t,n,i){return e.explicit&&t.explicit&&Fi(function(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${g(n)} and ${g(i)}). Using ${g(n)}.`}(n,i,e.value,t.value)),e}function Jl(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ql;return void 0===e||void 0===e.value?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:u(e.value,t.value)?e:r(e,t,n,i)}class Kl extends Vl{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];super(e,t),this.explicit=e,this.implicit=t,this.parseNothing=n}clone(){const e=super.clone();return e.parseNothing=this.parseNothing,e}}function Zl(e){return"url"in e}function ec(e){return"values"in e}function tc(e){return"name"in e&&!Zl(e)&&!ec(e)&&!nc(e)}function nc(e){return e&&(ic(e)||rc(e)||oc(e))}function ic(e){return"sequence"in e}function rc(e){return"sphere"in e}function oc(e){return"graticule"in e}let ac;function sc(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.identity;if(t.isArray(e)){const t=e.map((e=>sc(e,n,i)));return n?`[${t.join(", ")}]`:t}return Oi(e)?i(n?Ai(e):function(e){const t=Pi(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}(e)):n?i(g(e)):e}function lc(e,n){for(const i of C(e.component.selection??{})){const r=i.name;let o=`${r}${bu}, ${"global"===i.resolve?"true":`{unit: ${ku(e)}}`}`;for(const t of $u)t.defined(i)&&(t.signals&&(n=t.signals(e,i,n)),t.modifyExpr&&(o=t.modifyExpr(e,i,o)));n.push({name:r+xu,on:[{events:{signal:i.name+bu},update:`modify(${t.stringValue(i.name+vu)}, ${o})`}]})}return fc(n)}function cc(e,n){if(e.component.selection&&_(e.component.selection).length){const i=t.stringValue(e.getName("cell"));n.unshift({name:"facet",value:{},on:[{events:t.parseSelector("mousemove","scope"),update:`isTuple(facet) ? facet : group(${i}).datum`}]})}return fc(n)}function uc(e,t){for(const n of C(e.component.selection??{}))for(const i of $u)i.defined(n)&&i.marks&&(t=i.marks(e,n,t));return t}function fc(e){return e.map((e=>(e.on&&!e.on.length&&delete e.on,e)))}!function(e){e[e.Raw=0]="Raw",e[e.Main=1]="Main",e[e.Row=2]="Row",e[e.Column=3]="Column",e[e.Lookup=4]="Lookup"}(ac||(ac={}));class dc{constructor(e,t){this.debugName=t,Mn(this,"_children",[]),Mn(this,"_parent",null),Mn(this,"_hash",void 0),e&&(this.parent=e)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(e){this._parent=e,e&&e.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(e,t){this._children.includes(e)?Fi("Attempt to add the same child twice."):void 0!==t?this._children.splice(t,0,e):this._children.push(e)}removeChild(e){const t=this._children.indexOf(e);return this._children.splice(t,1),t}remove(){let e=this._parent.removeChild(this);for(const t of this._children)t._parent=this._parent,this._parent.addChild(t,e++)}insertAsParentOf(e){const t=e.parent;t.removeChild(this),this.parent=t,e.parent=this}swapWithParent(){const e=this._parent,t=e.parent;for(const t of this._children)t.parent=e;this._children=[],e.removeChild(this);const n=e.parent.removeChild(e);this._parent=t,t.addChild(this,n),e.parent=this}}class pc extends dc{clone(){const e=new this.constructor;return e.debugName=`clone_${this.debugName}`,e._source=this._source,e._name=`clone_${this._name}`,e.type=this.type,e.refCounts=this.refCounts,e.refCounts[e._name]=0,e}constructor(e,t,n,i){super(e,t),this.type=n,this.refCounts=i,Mn(this,"_source",void 0),Mn(this,"_name",void 0),this._source=this._name=t,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return void 0===this._hash&&(this._hash=`Output ${V()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(e){this._source=e}}class mc extends dc{clone(){return new mc(null,f(this.formula))}constructor(e,t){super(e),this.formula=t}static makeFromEncoding(e,t){const n=t.reduceFieldDef(((e,t)=>{const{field:n,timeUnit:i}=t;if(i){const r=na(t,{forAs:!0});e[h({as:r,field:n,timeUnit:i})]={as:r,field:n,timeUnit:i}}return e}),{});return z(n)?null:new mc(e,n)}static makeFromTransform(e,t){const{timeUnit:n,...i}={...t},r={...i,timeUnit:Ui(n)};return new mc(e,{[h(r)]:r})}merge(e){this.formula={...this.formula};for(const t in e.formula)this.formula[t]||(this.formula[t]=e.formula[t]);for(const t of e.children)e.removeChild(t),t.parent=this;e.remove()}removeFormulas(e){const t={};for(const[n,i]of N(this.formula))e.has(i.as)||(t[n]=i);this.formula=t}producedFields(){return new Set(C(this.formula).map((e=>e.as)))}dependentFields(){return new Set(C(this.formula).map((e=>e.field)))}hash(){return`TimeUnit ${h(this.formula)}`}assemble(){const e=[];for(const t of C(this.formula)){const{field:n,as:i,timeUnit:r}=t,{unit:o,utc:a,...s}=Ui(r);e.push({field:R(n),type:"timeunit",...o?{units:Li(o)}:{},...a?{timezone:"utc"}:{},...s,as:[i,`${i}_end`]})}return e}}const gc="_tuple_fields";class hc{constructor(){Mn(this,"hasChannel",void 0),Mn(this,"hasField",void 0),Mn(this,"hasSelectionId",void 0),Mn(this,"timeUnit",void 0),Mn(this,"items",void 0);for(var e=arguments.length,t=new Array(e),n=0;n!0,parse:(e,n,i)=>{const r=n.name,o=n.project??=new hc,a={},s={},l=new Set,c=(e,t)=>{const n="visual"===t?e.channel:e.field;let i=A(`${r}_${n}`);for(let e=1;l.has(i);e++)i=A(`${r}_${n}_${e}`);return l.add(i),{[t]:i}},u=n.type,f=e.config.selection[u],d=void 0!==i.value?t.array(i.value):null;let{fields:p,encodings:m}=t.isObject(i.select)?i.select:{};if(!p&&!m&&d)for(const e of d)if(t.isObject(e))for(const t of _(e))Qe[t]?(m||(m=[])).push(t):"interval"===u?(Fi('Interval selections should be initialized using "x" and/or "y" keys.'),m=f.encodings):(p||(p=[])).push(t);p||m||(m=f.encodings,"fields"in f&&(p=f.fields));for(const t of m??[]){const n=e.fieldDef(t);if(n){let i=n.field;if(n.aggregate){Fi(Yn(t,n.aggregate));continue}if(!i){Fi(Gn(t));continue}if(n.timeUnit){i=e.vgField(t);const r={timeUnit:n.timeUnit,as:i,field:n.field};s[h(r)]=r}if(!a[i]){let r="E";if("interval"===u){xr(e.getScaleComponent(t).get("type"))&&(r="R")}else n.bin&&(r="R-RE");const s={field:i,channel:t,type:r};s.signals={...c(s,"data"),...c(s,"visual")},o.items.push(a[i]=s),o.hasField[i]=o.hasChannel[t]=a[i],o.hasSelectionId=o.hasSelectionId||i===ys}}else Fi(Gn(t))}for(const e of p??[]){if(o.hasField[e])continue;const t={type:"E",field:e};t.signals={...c(t,"data")},o.items.push(t),o.hasField[e]=t,o.hasSelectionId=o.hasSelectionId||e===ys}d&&(n.init=d.map((e=>o.items.map((n=>t.isObject(e)?void 0!==e[n.channel]?e[n.channel]:e[n.field]:e))))),z(s)||(o.timeUnit=new mc(null,s))},signals:(e,t,n)=>{const i=t.name+gc;return n.filter((e=>e.name===i)).length>0||t.project.hasSelectionId?n:n.concat({name:i,value:t.project.items.map((e=>{const{signals:t,hasLegend:n,...i}=e;return i.field=R(i.field),i}))})}},vc={defined:e=>"interval"===e.type&&"global"===e.resolve&&e.bind&&"scales"===e.bind,parse:(e,t)=>{const n=t.scales=[];for(const i of t.project.items){const r=i.channel;if(!It(r))continue;const o=e.getScaleComponent(r),a=o?o.get("type"):void 0;o&&xr(a)?(o.set("selectionExtent",{param:t.name,field:i.field},!0),n.push(i)):Fi("Scale bindings are currently only supported for scales with unbinned, continuous domains.")}},topLevelSignals:(e,n,i)=>{const r=n.scales.filter((e=>0===i.filter((t=>t.name===e.signals.data)).length));if(!e.parent||xc(e)||0===r.length)return i;const o=i.filter((e=>e.name===n.name))[0];let a=o.update;if(a.indexOf(wu)>=0)o.update=`{${r.map((e=>`${t.stringValue(R(e.field))}: ${e.signals.data}`)).join(", ")}}`;else{for(const e of r){const n=`${t.stringValue(R(e.field))}: ${e.signals.data}`;a.includes(n)||(a=`${a.substring(0,a.length-1)}, ${n}}`)}o.update=a}return i.concat(r.map((e=>({name:e.signals.data}))))},signals:(e,t,n)=>{if(e.parent&&!xc(e))for(const e of t.scales){const t=n.filter((t=>t.name===e.signals.data))[0];t.push="outer",delete t.value,delete t.update}return n}};function bc(e,n){return`domain(${t.stringValue(e.scaleName(n))})`}function xc(e){return e.parent&&lp(e.parent)&&(!e.parent.parent??xc(e.parent.parent))}const wc="_brush",$c="_scale_trigger",kc={defined:e=>"interval"===e.type,signals:(e,n,i)=>{const r=n.name,o=r+gc,a=vc.defined(n),s=n.init?n.init[0]:null,l=[],c=[];if(n.translate&&!a){const e=`!event.item || event.item.mark.name !== ${t.stringValue(r+wc)}`;Sc(n,((n,i)=>{const r=t.array(i.between[0].filter??=[]);return r.includes(e)||r.push(e),n}))}n.project.items.forEach(((r,o)=>{const a=r.channel;if(a!==ee&&a!==te)return void Fi("Interval selections only support x and y encoding channels.");const u=s?s[o]:null,f=function(e,n,i,r){const o=i.channel,a=i.signals.visual,s=i.signals.data,l=vc.defined(n),c=t.stringValue(e.scaleName(o)),u=e.getScaleComponent(o),f=u?u.get("type"):void 0,d=e=>`scale(${c}, ${e})`,p=e.getSizeSignalRef(o===ee?"width":"height").signal,m=`${o}(unit)`,g=Sc(n,((e,t)=>[...e,{events:t.between[0],update:`[${m}, ${m}]`},{events:t,update:`[${a}[0], clamp(${m}, 0, ${p})]`}]));return g.push({events:{signal:n.name+$c},update:xr(f)?`[${d(`${s}[0]`)}, ${d(`${s}[1]`)}]`:"[0, 0]"}),l?[{name:s,on:[]}]:[{name:a,...r?{init:sc(r,!0,d)}:{value:[]},on:g},{name:s,...r?{init:sc(r)}:{},on:[{events:{signal:a},update:`${a}[0] === ${a}[1] ? null : invert(${c}, ${a})`}]}]}(e,n,r,u),d=r.signals.data,p=r.signals.visual,m=t.stringValue(e.scaleName(a)),g=xr(e.getScaleComponent(a).get("type"))?"+":"";i.push(...f),l.push(d),c.push({scaleName:e.scaleName(a),expr:`(!isArray(${d}) || (${g}invert(${m}, ${p})[0] === ${g}${d}[0] && ${g}invert(${m}, ${p})[1] === ${g}${d}[1]))`})})),!a&&c.length&&i.push({name:r+$c,value:{},on:[{events:c.map((e=>({scale:e.scaleName}))),update:`${c.map((e=>e.expr)).join(" && ")} ? ${r+$c} : {}`}]});const u=`unit: ${ku(e)}, fields: ${o}, values`;return i.concat({name:r+bu,...s?{init:`{${u}: ${sc(s)}}`}:{},...l.length?{on:[{events:[{signal:l.join(" || ")}],update:`${l.join(" && ")} ? {${u}: [${l}]} : null`}]}:{}})},marks:(e,n,i)=>{const r=n.name,{x:o,y:a}=n.project.hasChannel,s=o?.signals.visual,l=a?.signals.visual,c=`data(${t.stringValue(n.name+vu)})`;if(vc.defined(n)||!o&&!a)return i;const u={x:void 0!==o?{signal:`${s}[0]`}:{value:0},y:void 0!==a?{signal:`${l}[0]`}:{value:0},x2:void 0!==o?{signal:`${s}[1]`}:{field:{group:"width"}},y2:void 0!==a?{signal:`${l}[1]`}:{field:{group:"height"}}};if("global"===n.resolve)for(const t of _(u))u[t]=[{test:`${c}.length && ${c}[0].unit === ${ku(e)}`,...u[t]},{value:0}];const{fill:f,fillOpacity:d,cursor:p,...m}=n.mark,g=_(m).reduce(((e,t)=>(e[t]=[{test:[void 0!==o&&`${s}[0] !== ${s}[1]`,void 0!==a&&`${l}[0] !== ${l}[1]`].filter((e=>e)).join(" && "),value:m[t]},{value:null}],e)),{});return[{name:`${r+wc}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:f},fillOpacity:{value:d}},update:u}},...i,{name:r+wc,type:"rect",clip:!0,encode:{enter:{...p?{cursor:{value:p}}:{},fill:{value:"transparent"}},update:{...u,...g}}}]}};function Sc(e,t){return e.events.reduce(((e,n)=>n.between?t(e,n):(Fi(`${n} is not an ordered event stream for interval selections.`),e)),[])}const Dc={defined:e=>"point"===e.type,signals:(e,n,i)=>{const r=n.name,o=r+gc,a=n.project,s="(item().isVoronoi ? datum.datum : datum)",l=C(e.component.selection??{}).reduce(((e,t)=>"interval"===t.type?e.concat(t.name+wc):e),[]).map((e=>`indexof(item().mark.name, '${e}') < 0`)).join(" && "),c="datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0"+(l?` && ${l}`:"");let u=`unit: ${ku(e)}, `;if(n.project.hasSelectionId)u+=`${ys}: ${s}[${t.stringValue(ys)}]`;else{u+=`fields: ${o}, values: [${a.items.map((n=>e.fieldDef(n.channel)?.bin?`[${s}[${t.stringValue(e.vgField(n.channel,{}))}], ${s}[${t.stringValue(e.vgField(n.channel,{binSuffix:"end"}))}]]`:`${s}[${t.stringValue(n.field)}]`)).join(", ")}]`}const f=n.events;return i.concat([{name:r+bu,on:f?[{events:f,update:`${c} ? {${u}} : null`,force:!0}]:[]}])}};function Fc(e,n,i,r){const o=Ro(n)&&n.condition,a=r(n);if(o){return{[i]:[...t.array(o).map((t=>{const n=r(t);if(function(e){return e.param}(t)){const{param:i,empty:r}=t;return{test:Cu(e,{param:i,empty:r}),...n}}return{test:Pu(e,t.test),...n}})),...void 0!==a?[a]:[]]}}return void 0!==a?{[i]:a}:{}}function Oc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";const n=e.encoding[t];return Fc(e,n,t,(t=>zc(t,e.config)))}function zc(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"datum";if(e){if(Qo(e))return Sn(e.value);if(Yo(e)){const{format:i,formatType:r}=ua(e);return yo({fieldOrDatumDef:e,format:i,formatType:r,expr:n,config:t})}}}function _c(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{encoding:i,markDef:r,config:o,stack:a}=e,s=i.tooltip;if(t.isArray(s))return{tooltip:Nc({tooltip:s},a,o,n)};{const l=n.reactiveGeom?"datum.datum":"datum";return Fc(e,s,"tooltip",(e=>{const s=zc(e,o,l);if(s)return s;if(null===e)return;let c=_n("tooltip",r,o);return!0===c&&(c={content:"encoding"}),t.isString(c)?{value:c}:t.isObject(c)?gn(c)?c:"encoding"===c.content?Nc(i,a,o,n):{signal:l}:void 0}))}}function Cc(e,n,i){let{reactiveGeom:r}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={},a=r?"datum.datum":"datum",s=[];function l(r,l){const c=et(l),u=Xo(r)?r:{...r,type:e[c].type},f=u.title||ca(u,i),d=t.array(f).join(", ");let p;if(Dt(l)){const t="x"===l?"x2":"y2",n=fa(e[t]);if(sn(u.bin)&&n){const e=na(u,{expr:a}),r=na(n,{expr:a}),{format:s,formatType:l}=ua(u);p=Do(e,r,s,l,i),o[t]=!0}}if((Dt(l)||l===le||l===ae)&&n&&n.fieldChannel===l&&"normalize"===n.offset){const{format:e,formatType:t}=ua(u);p=yo({fieldOrDatumDef:u,format:e,formatType:t,expr:a,config:i,normalizeStack:!0}).signal}p??=zc(u,i,a).signal,s.push({channel:l,key:d,value:p})}qa(e,((e,t)=>{Io(e)?l(e,t):Wo(e)&&l(e.condition,t)}));const c={};for(const{channel:e,key:t,value:n}of s)o[e]||c[t]||(c[t]=n);return c}function Nc(e,t,n){let{reactiveGeom:i}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=Cc(e,t,n,{reactiveGeom:i}),o=N(r).map((e=>{let[t,n]=e;return`"${t}": ${n}`}));return o.length>0?{signal:`{${o.join(", ")}}`}:void 0}function Pc(e){const{markDef:t,config:n}=e,i=_n("aria",t,n);return!1===i?{}:{...i?{aria:i}:{},...Ac(e),...jc(e)}}function Ac(e){const{mark:t,markDef:n,config:i}=e;if(!1===i.aria)return{};const r=_n("ariaRoleDescription",n,i);return null!=r?{ariaRoleDescription:{value:r}}:t in bn?{}:{ariaRoleDescription:{value:t}}}function jc(e){const{encoding:t,markDef:n,config:i,stack:r}=e,o=t.description;if(o)return Fc(e,o,"description",(t=>zc(t,e.config)));const a=_n("description",n,i);if(null!=a)return{description:Sn(a)};if(!1===i.aria)return{};const s=Cc(t,r,i);return z(s)?void 0:{description:{signal:N(s).map(((e,t)=>{let[n,i]=e;return`"${t>0?"; ":""}${n}: " + (${i})`})).join(" + ")}}}function Ec(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{markDef:i,encoding:r,config:o}=t,{vgChannel:a}=n;let{defaultRef:s,defaultValue:l}=n;void 0===s&&(l??=_n(e,i,o,{vgChannel:a,ignoreVgConfig:!0}),void 0!==l&&(s=Sn(l)));const c=r[e];return Fc(t,c,a??e,(n=>fo({channel:e,channelDef:n,markDef:i,config:o,scaleName:t.scaleName(e),scale:t.getScaleComponent(e),stack:null,defaultRef:s})))}function Tc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{filled:void 0};const{markDef:n,encoding:i,config:r}=e,{type:o}=n,a=t.filled??_n("filled",n,r),s=v(["bar","point","circle","square","geoshape"],o)?"transparent":void 0,l=_n(!0===a?"color":void 0,n,r,{vgChannel:"fill"})??r.mark[!0===a&&"color"]??s,c=_n(!1===a?"color":void 0,n,r,{vgChannel:"stroke"})??r.mark[!1===a&&"color"],u=a?"fill":"stroke",f={...l?{fill:Sn(l)}:{},...c?{stroke:Sn(c)}:{}};return n.color&&(a?n.fill:n.stroke)&&Fi(ri("property",{fill:"fill"in n,stroke:"stroke"in n})),{...f,...Ec("color",e,{vgChannel:u,defaultValue:a?l:c}),...Ec("fill",e,{defaultValue:i.fill?l:void 0}),...Ec("stroke",e,{defaultValue:i.stroke?c:void 0})}}function Mc(e){const{encoding:t,mark:n}=e,i=t.order;return!Xr(n)&&Qo(i)?Fc(e,i,"zindex",(e=>Sn(e.value))):{}}function Lc(e){let{channel:t,markDef:n,encoding:i={},model:r,bandPosition:o}=e;const a=`${t}Offset`,s=n[a],l=i[a];if(("xOffset"===a||"yOffset"===a)&&l){return{offsetType:"encoding",offset:fo({channel:a,channelDef:l,markDef:n,config:r?.config,scaleName:r.scaleName(a),scale:r.getScaleComponent(a),stack:null,defaultRef:Sn(s),bandPosition:o})}}const c=n[a];return c?{offsetType:"visual",offset:c}:{}}function qc(e,t,n){let{defaultPos:i,vgChannel:r}=n;const{encoding:o,markDef:a,config:s,stack:l}=t,c=o[e],u=o[nt(e)],f=t.scaleName(e),d=t.getScaleComponent(e),{offset:p,offsetType:m}=Lc({channel:e,markDef:a,encoding:o,model:t,bandPosition:.5}),g=Rc({model:t,defaultPos:i,channel:e,scaleName:f,scale:d}),h=!c&&Dt(e)&&(o.latitude||o.longitude)?{field:t.getName(e)}:function(e){const{channel:t,channelDef:n,scaleName:i,stack:r,offset:o,markDef:a}=e;if(Yo(n)&&r&&t===r.fieldChannel){if(Io(n)){let e=n.bandPosition;if(void 0!==e||"text"!==a.type||"radius"!==t&&"theta"!==t||(e=.5),void 0!==e)return uo({scaleName:i,fieldOrDatumDef:n,startSuffix:"start",bandPosition:e,offset:o})}return co(n,i,{suffix:"end"},{offset:o})}return ao(e)}({channel:e,channelDef:c,channel2Def:u,markDef:a,config:s,scaleName:f,scale:d,stack:l,offset:p,defaultRef:g,bandPosition:"encoding"===m?0:void 0});return h?{[r||e]:h}:void 0}function Rc(e){let{model:t,defaultPos:n,channel:i,scaleName:r,scale:o}=e;const{markDef:a,config:s}=t;return()=>{const e=et(i),l=tt(i),c=_n(i,a,s,{vgChannel:l});if(void 0!==c)return po(i,c);switch(n){case"zeroOrMin":case"zeroOrMax":if(r){const e=o.get("type");if(v([lr.LOG,lr.TIME,lr.UTC],e));else if(o.domainDefinitelyIncludesZero())return{scale:r,value:0}}if("zeroOrMin"===n)return"y"===e?{field:{group:"height"}}:{value:0};switch(e){case"radius":return{signal:`min(${t.width.signal},${t.height.signal})/2`};case"theta":return{signal:"2*PI"};case"x":return{field:{group:"width"}};case"y":return{value:0}}break;case"mid":return{...t[it(i)],mult:.5}}}}const Wc={left:"x",center:"xc",right:"x2"},Uc={top:"y",middle:"yc",bottom:"y2"};function Ic(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"middle";if("radius"===e||"theta"===e)return tt(e);const r="x"===e?"align":"baseline",o=_n(r,t,n);let a;return gn(o)?(Fi(function(e){return`The ${e} for range marks cannot be an expression`}(r)),a=void 0):a=o,"x"===e?Wc[a||("top"===i?"left":"center")]:Uc[a||i]}function Bc(e,t,n){let{defaultPos:i,defaultPos2:r,range:o}=n;return o?Hc(e,t,{defaultPos:i,defaultPos2:r}):qc(e,t,{defaultPos:i})}function Hc(e,t,n){let{defaultPos:i,defaultPos2:r}=n;const{markDef:o,config:a}=t,s=nt(e),l=it(e),c=function(e,t,n){const{encoding:i,mark:r,markDef:o,stack:a,config:s}=e,l=et(n),c=it(n),u=tt(n),f=i[l],d=e.scaleName(l),p=e.getScaleComponent(l),{offset:m}=Lc(n in i||n in o?{channel:n,markDef:o,encoding:i,model:e}:{channel:l,markDef:o,encoding:i,model:e});if(!f&&("x2"===n||"y2"===n)&&(i.latitude||i.longitude)){const t=it(n),i=e.markDef[t];return null!=i?{[t]:{value:i}}:{[u]:{field:e.getName(n)}}}const g=function(e){let{channel:t,channelDef:n,channel2Def:i,markDef:r,config:o,scaleName:a,scale:s,stack:l,offset:c,defaultRef:u}=e;if(Yo(n)&&l&&t.charAt(0)===l.fieldChannel.charAt(0))return co(n,a,{suffix:"start"},{offset:c});return ao({channel:t,channelDef:i,scaleName:a,scale:s,stack:l,markDef:r,config:o,offset:c,defaultRef:u})}({channel:n,channelDef:f,channel2Def:i[n],markDef:o,config:s,scaleName:d,scale:p,stack:a,offset:m,defaultRef:void 0});if(void 0!==g)return{[u]:g};return Vc(n,o)||Vc(n,{[n]:Nn(n,o,s.style),[c]:Nn(c,o,s.style)})||Vc(n,s[r])||Vc(n,s.mark)||{[u]:Rc({model:e,defaultPos:t,channel:n,scaleName:d,scale:p})()}}(t,r,s);return{...qc(e,t,{defaultPos:i,vgChannel:c[l]?Ic(e,o,a):tt(e)}),...c}}function Vc(e,t){const n=it(e),i=tt(e);if(void 0!==t[i])return{[i]:po(e,t[i])};if(void 0!==t[e])return{[i]:po(e,t[e])};if(t[n]){const i=t[n];if(!no(i))return{[n]:po(e,i)};Fi(function(e){return`Position range does not support relative band size for ${e}.`}(n))}}function Gc(e,n){const{config:i,encoding:r,markDef:o}=e,a=o.type,s=nt(n),l=it(n),c=r[n],u=r[s],f=e.getScaleComponent(n),d=f?f.get("type"):void 0,p=o.orient,m=r[l]??r.size??_n("size",o,i,{vgChannel:l}),g="bar"===a&&("x"===n?"vertical"===p:"horizontal"===p);return!Io(c)||!(an(c.bin)||sn(c.bin)||c.timeUnit&&!u)||m&&!no(m)||br(d)?(Yo(c)&&br(d)||g)&&!u?function(e,n,i){const{markDef:r,encoding:o,config:a,stack:s}=i,l=r.orient,c=i.scaleName(n),u=i.getScaleComponent(n),f=it(n),d=nt(n),p=function(e){switch(e){case ee:return"xOffset";case te:return"yOffset";case ne:return"x2Offset";case ie:return"y2Offset";case le:return"thetaOffset";case ae:return"radiusOffset";case ce:return"theta2Offset";case se:return"radius2Offset"}}(n),m=i.scaleName(p),g="horizontal"===l&&"y"===n||"vertical"===l&&"x"===n;let h;(o.size||r.size)&&(g?h=Ec("size",i,{vgChannel:f,defaultRef:Sn(r.size)}):Fi(function(e){return`Cannot apply size to non-oriented mark "${e}".`}(r.type)));const y=!!h,v=Lo({channel:n,fieldDef:e,markDef:r,config:a,scaleType:u?.get("type"),useVlSizeChannel:g});h=h||{[f]:Yc(f,m||c,u,a,v)};const b="band"===u?.get("type")&&no(v)&&!y?"top":"middle",x=Ic(n,r,a,b),w="xc"===x||"yc"===x,{offset:$,offsetType:k}=Lc({channel:n,markDef:r,encoding:o,model:i,bandPosition:w?.5:0}),S=ao({channel:n,channelDef:e,markDef:r,config:a,scaleName:c,scale:u,stack:s,offset:$,defaultRef:Rc({model:i,defaultPos:"mid",channel:n,scaleName:c,scale:u}),bandPosition:w?"encoding"===k?0:.5:gn(v)?{signal:`(1-${v})/2`}:no(v)?(1-v.band)/2:0});if(f)return{[x]:S,...h};{const e=tt(d),n=h[f],i=$?{...n,offset:$}:n;return{[x]:S,[e]:t.isArray(S)?[S[0],{...S[1],offset:i}]:{...S,offset:i}}}}(c,n,e):Hc(n,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"}):function(e){let{fieldDef:t,fieldDef2:n,channel:i,model:r}=e;const{config:o,markDef:a,encoding:s}=r,l=r.getScaleComponent(i),c=r.scaleName(i),u=l?l.get("type"):void 0,f=l.get("reverse"),d=Lo({channel:i,fieldDef:t,markDef:a,config:o,scaleType:u}),p=r.component.axes[i]?.[0],m=p?.get("translate")??.5,g=Dt(i)?_n("binSpacing",a,o)??0:0,h=nt(i),y=tt(i),v=tt(h),{offset:b}=Lc({channel:i,markDef:a,encoding:s,model:r,bandPosition:0}),x=gn(d)?{signal:`(1-${d.signal})/2`}:no(d)?(1-d.band)/2:.5;if(an(t.bin)||t.timeUnit)return{[v]:Qc({fieldDef:t,scaleName:c,bandPosition:x,offset:Xc(h,g,f,m,b)}),[y]:Qc({fieldDef:t,scaleName:c,bandPosition:gn(x)?{signal:`1-${x.signal}`}:1-x,offset:Xc(i,g,f,m,b)})};if(sn(t.bin)){const e=co(t,c,{},{offset:Xc(h,g,f,m,b)});if(Io(n))return{[v]:e,[y]:co(n,c,{},{offset:Xc(i,g,f,m,b)})};if(ln(t.bin)&&t.bin.step)return{[v]:e,[y]:{signal:`scale("${c}", ${na(t,{expr:"datum"})} + ${t.bin.step})`,offset:Xc(i,g,f,m,b)}}}return void Fi(ki(h))}({fieldDef:c,fieldDef2:u,channel:n,model:e})}function Yc(e,n,i,r,o){if(no(o)){if(!i)return{mult:o.band,field:{group:e}};{const e=i.get("type");if("band"===e){let e=`bandwidth('${n}')`;return 1!==o.band&&(e=`${o.band} * ${e}`),{signal:`max(0.25, ${e})`}}1!==o.band&&(Fi(function(e){return`Cannot use the relative band size with ${e} scale.`}(e)),o=void 0)}}else{if(gn(o))return o;if(o)return{value:o}}if(i){const e=i.get("range");if(hn(e)&&t.isNumber(e.step))return{value:e.step-2}}return{value:Ns(r.view,e)-2}}function Xc(e,t,n,i,r){if(je(e))return 0;const o="x"===e||"y2"===e?-t/2:t/2;if(gn(n)||gn(r)||gn(i)){const e=Fn(n),t=Fn(r),a=Fn(i);return{signal:(a?`${a} + `:"")+(e?`(${e} ? -1 : 1) * `:"")+(t?`(${t} + ${o})`:o)}}return r=r||0,i+(n?-r-o:+r+o)}function Qc(e){let{fieldDef:t,scaleName:n,bandPosition:i,offset:r}=e;return uo({scaleName:n,fieldOrDatumDef:t,bandPosition:i,offset:r})}const Jc=new Set(["aria","width","height"]);function Kc(e,t){const{fill:n,stroke:i}="include"===t.color?Tc(e):{};return{...eu(e.markDef,t),...Zc(e,"fill",n),...Zc(e,"stroke",i),...Ec("opacity",e),...Ec("fillOpacity",e),...Ec("strokeOpacity",e),...Ec("strokeWidth",e),...Ec("strokeDash",e),...Mc(e),..._c(e),...Oc(e,"href"),...Pc(e)}}function Zc(e,n,i){const{config:r,mark:o,markDef:a}=e;if("hide"===_n("invalid",a,r)&&i&&!Xr(o)){const r=function(e,t){let{invalid:n=!1,channels:i}=t;const r=i.reduce(((t,n)=>{const i=e.getScaleComponent(n);if(i){const r=i.get("type"),o=e.vgField(n,{expr:"datum"});o&&xr(r)&&(t[o]=!0)}return t}),{}),o=_(r);if(o.length>0){const e=n?"||":"&&";return o.map((e=>lo(e,n))).join(` ${e} `)}return}(e,{invalid:!0,channels:Ut});if(r)return{[n]:[{test:r,value:null},...t.array(i)]}}return i?{[n]:i}:{}}function eu(e,t){return vn.reduce(((n,i)=>(Jc.has(i)||void 0===e[i]||"ignore"===t[i]||(n[i]=Sn(e[i])),n)),{})}function tu(e){const{config:t,markDef:n}=e;if(_n("invalid",n,t)){const t=function(e,t){let{invalid:n=!1,channels:i}=t;const r=i.reduce(((t,n)=>{const i=e.getScaleComponent(n);if(i){const r=i.get("type"),o=e.vgField(n,{expr:"datum",binSuffix:e.stack?.impute?"mid":void 0});o&&xr(r)&&(t[o]=!0)}return t}),{}),o=_(r);if(o.length>0){const e=n?"||":"&&";return o.map((e=>lo(e,n))).join(` ${e} `)}return}(e,{channels:St});if(t)return{defined:{signal:t}}}return{}}function nu(e,t){if(void 0!==t)return{[e]:Sn(t)}}const iu="voronoi",ru={defined:e=>"point"===e.type&&e.nearest,parse:(e,t)=>{if(t.events)for(const n of t.events)n.markname=e.getName(iu)},marks:(e,t,n)=>{const{x:i,y:r}=t.project.hasChannel,o=e.mark;if(Xr(o))return Fi(`The "nearest" transform is not supported for ${o} marks.`),n;const a={name:e.getName(iu),type:"path",interactive:!0,from:{data:e.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},..._c(e,{reactiveGeom:!0})}},transform:[{type:"voronoi",x:{expr:i||!r?"datum.datum.x || 0":"0"},y:{expr:r||!i?"datum.datum.y || 0":"0"},size:[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]}]};let s=0,l=!1;return n.forEach(((t,n)=>{const i=t.name??"";i===e.component.mark[0].name?s=n:i.indexOf(iu)>=0&&(l=!0)})),l||n.splice(s+1,0,a),n}},ou={defined:e=>"point"===e.type&&"global"===e.resolve&&e.bind&&"scales"!==e.bind&&!bs(e.bind),parse:(e,t,n)=>Du(t,n),topLevelSignals:(e,n,i)=>{const r=n.name,o=n.project,a=n.bind,s=n.init&&n.init[0],l=ru.defined(n)?"(item().isVoronoi ? datum.datum : datum)":"datum";return o.items.forEach(((e,o)=>{const c=A(`${r}_${e.field}`);i.filter((e=>e.name===c)).length||i.unshift({name:c,...s?{init:sc(s[o])}:{value:null},on:n.events?[{events:n.events,update:`datum && item().mark.marktype !== 'group' ? ${l}[${t.stringValue(e.field)}] : null`}]:[],bind:a[e.field]??a[e.channel]??a})})),i},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.filter((e=>e.name===i+bu))[0],a=i+gc,s=r.items.map((e=>A(`${i}_${e.field}`))),l=s.map((e=>`${e} !== null`)).join(" && ");return s.length&&(o.update=`${l} ? {fields: ${a}, values: [${s.join(", ")}]} : null`),delete o.value,delete o.on,n}},au="_toggle",su={defined:e=>"point"===e.type&&!!e.toggle,signals:(e,t,n)=>n.concat({name:t.name+au,value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{const n=t.name+bu,i=t.name+au;return`${i} ? null : ${n}, `+("global"===t.resolve?`${i} ? null : true, `:`${i} ? null : {unit: ${ku(e)}}, `)+`${i} ? ${n} : null`}},lu={defined:e=>void 0!==e.clear&&!1!==e.clear,parse:(e,n)=>{n.clear&&(n.clear=t.isString(n.clear)?t.parseSelector(n.clear,"view"):n.clear)},topLevelSignals:(e,t,n)=>{if(ou.defined(t))for(const e of t.project.items){const i=n.findIndex((n=>n.name===A(`${t.name}_${e.field}`)));-1!==i&&n[i].on.push({events:t.clear,update:"null"})}return n},signals:(e,t,n)=>{function i(e,i){-1!==e&&n[e].on&&n[e].on.push({events:t.clear,update:i})}if("interval"===t.type)for(const e of t.project.items){const t=n.findIndex((t=>t.name===e.signals.visual));if(i(t,"[0, 0]"),-1===t){i(n.findIndex((t=>t.name===e.signals.data)),"null")}}else{let e=n.findIndex((e=>e.name===t.name+bu));i(e,"null"),su.defined(t)&&(e=n.findIndex((e=>e.name===t.name+au)),i(e,"false"))}return n}},cu={defined:e=>{const t="global"===e.resolve&&e.bind&&bs(e.bind),n=1===e.project.items.length&&e.project.items[0].field!==ys;return t&&!n&&Fi("Legend bindings are only supported for selections over an individual field or encoding channel."),t&&n},parse:(e,n,i)=>{const r=f(i);if(r.select=t.isString(r.select)?{type:r.select,toggle:n.toggle}:{...r.select,toggle:n.toggle},Du(n,r),t.isObject(i.select)&&(i.select.on||i.select.clear)){const e='event.item && indexof(event.item.mark.role, "legend") < 0';for(const i of n.events)i.filter=t.array(i.filter??[]),i.filter.includes(e)||i.filter.push(e)}const o=xs(n.bind)?n.bind.legend:"click",a=t.isString(o)?t.parseSelector(o,"view"):t.array(o);n.bind={legend:{merge:a}}},topLevelSignals:(e,t,n)=>{const i=t.name,r=xs(t.bind)&&t.bind.legend,o=e=>t=>{const n=f(t);return n.markname=e,n};for(const e of t.project.items){if(!e.hasLegend)continue;const a=`${A(e.field)}_legend`,s=`${i}_${a}`;if(0===n.filter((e=>e.name===s)).length){const e=r.merge.map(o(`${a}_symbols`)).concat(r.merge.map(o(`${a}_labels`))).concat(r.merge.map(o(`${a}_entries`)));n.unshift({name:s,...t.init?{}:{value:null},on:[{events:e,update:"datum.value || item().items[0].items[0].datum.value",force:!0},{events:r.merge,update:`!event.item || !datum ? null : ${s}`,force:!0}]})}}return n},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.find((e=>e.name===i+bu)),a=i+gc,s=r.items.filter((e=>e.hasLegend)).map((e=>A(`${i}_${A(e.field)}_legend`))),l=`${s.map((e=>`${e} !== null`)).join(" && ")} ? {fields: ${a}, values: [${s.join(", ")}]} : null`;t.events&&s.length>0?o.on.push({events:s.map((e=>({signal:e}))),update:l}):s.length>0&&(o.update=l,delete o.value,delete o.on);const c=n.find((e=>e.name===i+au)),u=xs(t.bind)&&t.bind.legend;return c&&(t.events?c.on.push({...c.on[0],events:u}):c.on[0].events=u),n}};const uu="_translate_anchor",fu="_translate_delta",du={defined:e=>"interval"===e.type&&e.translate,signals:(e,n,i)=>{const r=n.name,o=vc.defined(n),a=r+uu,{x:s,y:l}=n.project.hasChannel;let c=t.parseSelector(n.translate,"scope");return o||(c=c.map((e=>(e.between[0].markname=r+wc,e)))),i.push({name:a,value:{},on:[{events:c.map((e=>e.between[0])),update:"{x: x(unit), y: y(unit)"+(void 0!==s?`, extent_x: ${o?bc(e,ee):`slice(${s.signals.visual})`}`:"")+(void 0!==l?`, extent_y: ${o?bc(e,te):`slice(${l.signals.visual})`}`:"")+"}"}]},{name:r+fu,value:{},on:[{events:c,update:`{x: ${a}.x - x(unit), y: ${a}.y - y(unit)}`}]}),void 0!==s&&pu(e,n,s,"width",i),void 0!==l&&pu(e,n,l,"height",i),i}};function pu(e,t,n,i,r){const o=t.name,a=o+uu,s=o+fu,l=n.channel,c=vc.defined(t),u=r.filter((e=>e.name===n.signals[c?"data":"visual"]))[0],f=e.getSizeSignalRef(i).signal,d=e.getScaleComponent(l),p=d.get("type"),m=d.get("reverse"),g=`${a}.extent_${l}`,h=`${c?"log"===p?"panLog":"symlog"===p?"panSymlog":"pow"===p?"panPow":"panLinear":"panLinear"}(${g}, ${`${c?l===ee?m?"":"-":m?"-":"":""}${s}.${l} / ${c?`${f}`:`span(${g})`}`}${c?"pow"===p?`, ${d.get("exponent")??1}`:"symlog"===p?`, ${d.get("constant")??1}`:"":""})`;u.on.push({events:{signal:s},update:c?h:`clampRange(${h}, 0, ${f})`})}const mu="_zoom_anchor",gu="_zoom_delta",hu={defined:e=>"interval"===e.type&&e.zoom,signals:(e,n,i)=>{const r=n.name,o=vc.defined(n),a=r+gu,{x:s,y:l}=n.project.hasChannel,c=t.stringValue(e.scaleName(ee)),u=t.stringValue(e.scaleName(te));let f=t.parseSelector(n.zoom,"scope");return o||(f=f.map((e=>(e.markname=r+wc,e)))),i.push({name:r+mu,on:[{events:f,update:o?"{"+[c?`x: invert(${c}, x(unit))`:"",u?`y: invert(${u}, y(unit))`:""].filter((e=>!!e)).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:a,on:[{events:f,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),void 0!==s&&yu(e,n,s,"width",i),void 0!==l&&yu(e,n,l,"height",i),i}};function yu(e,t,n,i,r){const o=t.name,a=n.channel,s=vc.defined(t),l=r.filter((e=>e.name===n.signals[s?"data":"visual"]))[0],c=e.getSizeSignalRef(i).signal,u=e.getScaleComponent(a),f=u.get("type"),d=s?bc(e,a):l.name,p=o+gu,m=`${s?"log"===f?"zoomLog":"symlog"===f?"zoomSymlog":"pow"===f?"zoomPow":"zoomLinear":"zoomLinear"}(${d}, ${`${o}${mu}.${a}`}, ${p}${s?"pow"===f?`, ${u.get("exponent")??1}`:"symlog"===f?`, ${u.get("constant")??1}`:"":""})`;l.on.push({events:{signal:p},update:s?m:`clampRange(${m}, 0, ${c})`})}const vu="_store",bu="_tuple",xu="_modify",wu="vlSelectionResolve",$u=[Dc,kc,yc,su,ou,vc,cu,lu,du,hu,ru];function ku(e){let{escape:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{escape:!0},i=n?t.stringValue(e.name):e.name;const r=function(e){let t=e.parent;for(;t&&!ap(t);)t=t.parent;return t}(e);if(r){const{facet:e}=r;for(const n of Re)e[n]&&(i+=` + '__facet_${n}_' + (facet[${t.stringValue(r.vgField(n))}])`)}return i}function Su(e){return C(e.component.selection??{}).reduce(((e,t)=>e||t.project.hasSelectionId),!1)}function Du(e,n){!t.isString(n.select)&&n.select.on||delete e.events,!t.isString(n.select)&&n.select.clear||delete e.clear,!t.isString(n.select)&&n.select.toggle||delete e.toggle}function Fu(e){const t=[];return"Identifier"===e.type?[e.name]:"Literal"===e.type?[e.value]:("MemberExpression"===e.type&&(t.push(...Fu(e.object)),t.push(...Fu(e.property))),t)}function Ou(e){return"MemberExpression"===e.object.type?Ou(e.object):"datum"===e.object.name}function zu(e){const n=t.parseExpression(e),i=new Set;return n.visit((e=>{"MemberExpression"===e.type&&Ou(e)&&i.add(Fu(e).slice(1).join("."))})),i}class _u extends dc{clone(){return new _u(null,this.model,f(this.filter))}constructor(e,t,n){super(e),this.model=t,this.filter=n,Mn(this,"expr",void 0),Mn(this,"_dependentFields",void 0),this.expr=Pu(this.model,this.filter,this),this._dependentFields=zu(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function Cu(e,n,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"datum";const o=t.isString(n)?n:n.param,a=A(o),s=t.stringValue(a+vu);let l;try{l=e.getSelectionComponent(a,o)}catch(e){return`!!${a}`}if(l.project.timeUnit){const t=i??e.component.data.raw,n=l.project.timeUnit.clone();t.parent?n.insertAsParentOf(t):t.parent=n}const c=`${l.project.hasSelectionId?"vlSelectionIdTest(":"vlSelectionTest("}${s}, ${r}${"global"===l.resolve?")":`, ${t.stringValue(l.resolve)})`}`,u=`length(data(${s}))`;return!1===n.empty?`${u} && ${c}`:`!${u} || ${c}`}function Nu(e,n,i){const r=A(n),o=i.encoding;let a,s=i.field;try{a=e.getSelectionComponent(r,n)}catch(e){return r}if(o||s){if(o&&!s){const e=a.project.items.filter((e=>e.channel===o));!e.length||e.length>1?(s=a.project.items[0].field,Fi((e.length?"Multiple ":"No ")+`matching ${t.stringValue(o)} encoding found for selection ${t.stringValue(i.param)}. `+`Using "field": ${t.stringValue(s)}.`)):s=e[0].field}}else s=a.project.items[0].field,a.project.items.length>1&&Fi(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${t.stringValue(s)}.`);return`${a.name}[${t.stringValue(R(s))}]`}function Pu(e,n,i){return j(n,(n=>t.isString(n)?n:function(e){return e?.param}(n)?Cu(e,n,i):Ki(n)))}function Au(e,t,n,i){e.encode??={},e.encode[t]??={},e.encode[t].update??={},e.encode[t].update[n]=i}function ju(e,n,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{header:!1};const{disable:o,orient:a,scale:s,labelExpr:l,title:c,zindex:u,...f}=e.combine();if(!o){for(const e in f){const i=Da[e],r=f[e];if(i&&i!==n&&"both"!==i)delete f[e];else if(ka(r)){const{condition:n,...i}=r,o=t.array(n),a=$a[e];if(a){const{vgProp:t,part:n}=a;Au(f,n,t,[...o.map((e=>{const{test:t,...n}=e;return{test:Pu(null,t),...n}})),i]),delete f[e]}else if(null===a){const t={signal:o.map((e=>{const{test:t,...n}=e;return`${Pu(null,t)} ? ${Dn(n)} : `})).join("")+Dn(i)};f[e]=t}}else if(gn(r)){const t=$a[e];if(t){const{vgProp:n,part:i}=t;Au(f,i,n,r),delete f[e]}}v(["labelAlign","labelBaseline"],e)&&null===f[e]&&delete f[e]}if("grid"===n){if(!f.grid)return;if(f.encode){const{grid:e}=f.encode;f.encode={...e?{grid:e}:{}},z(f.encode)&&delete f.encode}return{scale:s,orient:a,...f,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:B(u,0)}}{if(!r.header&&e.mainExtracted)return;if(void 0!==l){let e=l;f.encode?.labels?.update&&gn(f.encode.labels.update.text)&&(e=W(l,"datum.label",f.encode.labels.update.text.signal)),Au(f,"labels","text",{signal:e})}if(null===f.labelAlign&&delete f.labelAlign,f.encode){for(const t of Sa)e.hasAxisPart(t)||delete f.encode[t];z(f.encode)&&delete f.encode}const n=function(e,n){if(e)return t.isArray(e)&&!mn(e)?e.map((e=>ca(e,n))).join(", "):e}(c,i);return{scale:s,orient:a,grid:!1,...n?{title:n}:{},...f,...!1===i.aria?{aria:!1}:{},zindex:B(u,0)}}}}function Eu(e){const{axes:t}=e.component,n=[];for(const i of St)if(t[i])for(const r of t[i])if(!r.get("disable")&&!r.get("gridScale")){const t="x"===i?"height":"width",r=e.getSizeSignalRef(t).signal;t!==r&&n.push({name:t,update:r})}return n}function Tu(e,t,n,i){return Object.assign.apply(null,[{},...e.map((e=>{if("axisOrient"===e){const e="x"===n?"bottom":"left",r=t["x"===n?"axisBottom":"axisLeft"]||{},o=t["x"===n?"axisTop":"axisRight"]||{},a=new Set([..._(r),..._(o)]),s={};for(const t of a.values())s[t]={signal:`${i.signal} === "${e}" ? ${Fn(r[t])} : ${Fn(o[t])}`};return s}return t[e]}))])}function Mu(e,n){const i=[{}];for(const r of e){let e=n[r]?.style;if(e){e=t.array(e);for(const t of e)i.push(n.style[t])}}return Object.assign.apply(null,i)}function Lu(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=Pn(e,n,t);if(void 0!==r)return{configFrom:"style",configValue:r};for(const t of["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"])if(void 0!==i[t]?.[e])return{configFrom:t,configValue:i[t][e]};return{}}const qu={scale:e=>{let{model:t,channel:n}=e;return t.scaleName(n)},format:e=>{let{fieldOrDatumDef:t,config:n,axis:i}=e;const{format:r,formatType:o}=i;return xo(t,t.type,r,o,n,!0)},formatType:e=>{let{axis:t,fieldOrDatumDef:n,scaleType:i}=e;const{formatType:r}=t;return wo(r,n,i)},grid:e=>{let{fieldOrDatumDef:t,axis:n,scaleType:i}=e;return n.grid??function(e,t){return!br(e)&&Io(t)&&!an(t?.bin)&&!sn(t?.bin)}(i,t)},gridScale:e=>{let{model:t,channel:n}=e;return function(e,t){const n="x"===t?"y":"x";if(e.getScaleComponent(n))return e.scaleName(n);return}(t,n)},labelAlign:e=>{let{axis:t,labelAngle:n,orient:i,channel:r}=e;return t.labelAlign||Uu(n,i,r)},labelAngle:e=>{let{labelAngle:t}=e;return t},labelBaseline:e=>{let{axis:t,labelAngle:n,orient:i,channel:r}=e;return t.labelBaseline||Wu(n,i,r)},labelFlush:e=>{let{axis:t,fieldOrDatumDef:n,channel:i}=e;return t.labelFlush??function(e,t){if("x"===t&&v(["quantitative","temporal"],e))return!0;return}(n.type,i)},labelOverlap:e=>{let{axis:n,fieldOrDatumDef:i,scaleType:r}=e;return n.labelOverlap??function(e,n,i,r){if(i&&!t.isObject(r)||"nominal"!==e&&"ordinal"!==e)return"log"!==n&&"symlog"!==n||"greedy";return}(i.type,r,Io(i)&&!!i.timeUnit,Io(i)?i.sort:void 0)},orient:e=>{let{orient:t}=e;return t},tickCount:e=>{let{channel:t,model:n,axis:i,fieldOrDatumDef:r,scaleType:o}=e;const a="x"===t?"width":"y"===t?"height":void 0,s=a?n.getSizeSignalRef(a):void 0;return i.tickCount??function(e){let{fieldOrDatumDef:t,scaleType:n,size:i,values:r}=e;if(!r&&!br(n)&&"log"!==n){if(Io(t)){if(an(t.bin))return{signal:`ceil(${i.signal}/10)`};if(t.timeUnit&&v(["month","hours","day","quarter"],Ui(t.timeUnit)?.unit))return}return{signal:`ceil(${i.signal}/40)`}}return}({fieldOrDatumDef:r,scaleType:o,size:s,values:i.values})},title:e=>{let{axis:t,model:n,channel:i}=e;if(void 0!==t.title)return t.title;const r=Iu(n,i);if(void 0!==r)return r;const o=n.typedFieldDef(i),a="x"===i?"x2":"y2",s=n.fieldDef(a);return jn(o?[Eo(o)]:[],Io(s)?[Eo(s)]:[])},values:e=>{let{axis:n,fieldOrDatumDef:i}=e;return function(e,n){const i=e.values;if(t.isArray(i))return xa(n,i);if(gn(i))return i;return}(n,i)},zindex:e=>{let{axis:t,fieldOrDatumDef:n,mark:i}=e;return t.zindex??function(e,t){if("rect"===e&&ia(t))return 1;return 0}(i,n)}};function Ru(e){return`(((${e.signal} % 360) + 360) % 360)`}function Wu(e,t,n,i){if(void 0!==e){if("x"===n){if(gn(e)){const n=Ru(e);return{signal:`(45 < ${n} && ${n} < 135) || (225 < ${n} && ${n} < 315) ? "middle" :(${n} <= 45 || 315 <= ${n}) === ${gn(t)?`(${t.signal} === "top")`:"top"===t} ? "bottom" : "top"`}}if(45{if(Jo(t)&&No(t.sort)){const{field:i,timeUnit:r}=t,o=t.sort,a=o.map(((e,t)=>`${Ki({field:i,timeUnit:r,equal:e})} ? ${t} : `)).join("")+o.length;e=new Bu(e,{calculate:a,as:Hu(t,n,{forAs:!0})})}})),e}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:"formula",expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${h(this.transform)}`}}function Hu(e,t,n){return na(e,{prefix:t,suffix:"sort_index",...n??{}})}function Vu(e,t){return v(["top","bottom"],t)?"column":v(["left","right"],t)||"row"===e?"row":"column"}function Gu(e,t,n,i){const r="row"===i?n.headerRow:"column"===i?n.headerColumn:n.headerFacet;return B((t||{})[e],r[e],n.header[e])}function Yu(e,t,n,i){const r={};for(const o of e){const e=Gu(o,t||{},n,i);void 0!==e&&(r[o]=e)}return r}const Xu=["row","column"],Qu=["header","footer"];function Ju(e,t){const n=e.component.layoutHeaders[t].title,i=e.config?e.config:void 0,r=e.component.layoutHeaders[t].facetFieldDef?e.component.layoutHeaders[t].facetFieldDef:void 0,{titleAnchor:o,titleAngle:a,titleOrient:s}=Yu(["titleAnchor","titleAngle","titleOrient"],r.header,i,t),l=Vu(t,s),c=X(a);return{name:`${t}-title`,type:"group",role:`${l}-title`,title:{text:n,..."row"===t?{orient:"left"}:{},style:"guide-title",...Zu(c,l),...Ku(l,c,o),...sf(i,r,t,ps,fs)}}}function Ku(e,t){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"middle"){case"start":return{align:"left"};case"end":return{align:"right"}}const n=Uu(t,"row"===e?"left":"top","row"===e?"y":"x");return n?{align:n}:{}}function Zu(e,t){const n=Wu(e,"row"===t?"left":"top","row"===t?"y":"x",!0);return n?{baseline:n}:{}}function ef(e,t){const n=e.component.layoutHeaders[t],i=[];for(const r of Qu)if(n[r])for(const o of n[r]){const a=rf(e,t,r,n,o);null!=a&&i.push(a)}return i}function tf(e,n){const{sort:i}=e;return Co(i)?{field:na(i,{expr:"datum"}),order:i.order??"ascending"}:t.isArray(i)?{field:Hu(e,n,{expr:"datum"}),order:"ascending"}:{field:na(e,{expr:"datum"}),order:i??"ascending"}}function nf(e,t,n){const{format:i,formatType:r,labelAngle:o,labelAnchor:a,labelOrient:s,labelExpr:l}=Yu(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],e.header,n,t),c=yo({fieldOrDatumDef:e,format:i,formatType:r,expr:"parent",config:n}).signal,u=Vu(t,s);return{text:{signal:l?W(W(l,"datum.label",c),"datum.value",na(e,{expr:"parent"})):c},..."row"===t?{orient:"left"}:{},style:"guide-label",frame:"group",...Zu(o,u),...Ku(u,o,a),...sf(n,e,t,ms,ds)}}function rf(e,t,n,i,r){if(r){let o=null;const{facetFieldDef:a}=i,s=e.config?e.config:void 0;if(a&&r.labels){const{labelOrient:e}=Yu(["labelOrient"],a.header,s,t);("row"===t&&!v(["top","bottom"],e)||"column"===t&&!v(["left","right"],e))&&(o=nf(a,t,s))}const l=ap(e)&&!Po(e.facet),c=r.axes,u=c?.length>0;if(o||u){const s="row"===t?"height":"width";return{name:e.getName(`${t}_${n}`),type:"group",role:`${t}-${n}`,...i.facetFieldDef?{from:{data:e.getName(`${t}_domain`)},sort:tf(a,t)}:{},...u&&l?{from:{data:e.getName(`facet_domain_${t}`)}}:{},...o?{title:o}:{},...r.sizeSignal?{encode:{update:{[s]:r.sizeSignal}}}:{},...u?{axes:c}:{}}}}return null}const of={column:{start:0,end:1},row:{start:1,end:0}};function af(e,t){return of[t][e]}function sf(e,t,n,i,r){const o={};for(const a of i){if(!r[a])continue;const i=Gu(a,t?.header,e,n);void 0!==i&&(o[r[a]]=i)}return o}function lf(e){return[...cf(e,"width"),...cf(e,"height"),...cf(e,"childWidth"),...cf(e,"childHeight")]}function cf(e,t){const n="width"===t?"x":"y",i=e.component.layoutSize.get(t);if(!i||"merged"===i)return[];const r=e.getSizeSignalRef(t).signal;if("step"===i){const t=e.getScaleComponent(n);if(t){const i=t.get("type"),o=t.get("range");if(br(i)&&hn(o)){const i=e.scaleName(n);if(ap(e.parent)){if("independent"===e.parent.component.resolve.scale[n])return[uf(i,o)]}return[uf(i,o),{name:r,update:ff(i,t,`domain('${i}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}if("container"==i){const t=r.endsWith("width"),n=t?"containerSize()[0]":"containerSize()[1]",i=`isFinite(${n}) ? ${n} : ${Cs(e.config.view,t?"width":"height")}`;return[{name:r,init:i,on:[{update:i,events:"window:resize"}]}]}return[{name:r,value:i}]}function uf(e,t){const n=`${e}_step`;return gn(t.step)?{name:n,update:t.step.signal}:{name:n,value:t.step}}function ff(e,t,n){const i=t.get("type"),r=t.get("padding"),o=B(t.get("paddingOuter"),r);let a=t.get("paddingInner");return a="band"===i?void 0!==a?a:r:1,`bandspace(${n}, ${Fn(a)}, ${Fn(o)}) * ${e}_step`}function df(e){return"childWidth"===e?"width":"childHeight"===e?"height":e}function pf(e,t){return _(e).reduce(((n,i)=>{const r=e[i];return{...n,...Fc(t,r,i,(e=>Sn(e.value)))}}),{})}function mf(e,t){if(ap(t))return"theta"===e?"independent":"shared";if(lp(t))return"shared";if(sp(t))return Dt(e)||"theta"===e||"radius"===e?"independent":"shared";throw new Error("invalid model type for resolve")}function gf(e,t){const n=e.scale[t],i=Dt(t)?"axis":"legend";return"independent"===n?("shared"===e[i][t]&&Fi(function(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}(t)),"independent"):e[i][t]||"shared"}const hf=_({aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1});class yf extends Vl{}const vf={symbols:function(e,n){let{fieldOrDatumDef:i,model:r,channel:o,legendCmpt:a,legendType:s}=n;if("symbol"!==s)return;const{markDef:l,encoding:c,config:u,mark:f}=r,d=l.filled&&"trail"!==f;let p={...On({},r,Zr),...Tc(r,{filled:d})};const m=a.get("symbolOpacity")??u.legend.symbolOpacity,g=a.get("symbolFillColor")??u.legend.symbolFillColor,h=a.get("symbolStrokeColor")??u.legend.symbolStrokeColor,y=void 0===m?bf(c.opacity)??l.opacity:void 0;if(p.fill)if("fill"===o||d&&o===me)delete p.fill;else if(p.fill.field)g?delete p.fill:(p.fill=Sn(u.legend.symbolBaseFillColor??"black"),p.fillOpacity=Sn(y??1));else if(t.isArray(p.fill)){const e=xf(c.fill??c.color)??l.fill??(d&&l.color);e&&(p.fill=Sn(e))}if(p.stroke)if("stroke"===o||!d&&o===me)delete p.stroke;else if(p.stroke.field||h)delete p.stroke;else if(t.isArray(p.stroke)){const e=B(xf(c.stroke||c.color),l.stroke,d?l.color:void 0);e&&(p.stroke={value:e})}if(o!==xe){const e=Io(i)&&$f(r,a,i);e?p.opacity=[{test:e,...Sn(y??1)},Sn(u.legend.unselectedOpacity)]:y&&(p.opacity=Sn(y))}return p={...p,...e},z(p)?void 0:p},gradient:function(e,t){let{model:n,legendType:i,legendCmpt:r}=t;if("gradient"!==i)return;const{config:o,markDef:a,encoding:s}=n;let l={};const c=void 0===(r.get("gradientOpacity")??o.legend.gradientOpacity)?bf(s.opacity)||a.opacity:void 0;c&&(l.opacity=Sn(c));return l={...l,...e},z(l)?void 0:l},labels:function(e,t){let{fieldOrDatumDef:n,model:i,channel:r,legendCmpt:o}=t;const a=i.legend(r)||{},s=i.config,l=Io(n)?$f(i,o,n):void 0,c=l?[{test:l,value:1},{value:s.legend.unselectedOpacity}]:void 0,{format:u,formatType:f}=a;let d;mo(f)?d=bo({fieldOrDatumDef:n,field:"datum.value",format:u,formatType:f,config:s}):void 0===u&&void 0===f&&s.customFormatTypes&&("quantitative"===n.type&&s.numberFormatType?d=bo({fieldOrDatumDef:n,field:"datum.value",format:s.numberFormat,formatType:s.numberFormatType,config:s}):"temporal"===n.type&&s.timeFormatType&&Io(n)&&void 0===n.timeUnit&&(d=bo({fieldOrDatumDef:n,field:"datum.value",format:s.timeFormat,formatType:s.timeFormatType,config:s})));const p={...c?{opacity:c}:{},...d?{text:d}:{},...e};return z(p)?void 0:p},entries:function(e,t){let{legendCmpt:n}=t;return n.get("selections")?.length?{...e,fill:{value:"transparent"}}:e}};function bf(e){return wf(e,((e,t)=>Math.max(e,t.value)))}function xf(e){return wf(e,((e,t)=>B(e,t.value)))}function wf(e,n){return function(e){const n=e?.condition;return!!n&&(t.isArray(n)||Qo(n))}(e)?t.array(e.condition).reduce(n,e.value):Qo(e)?e.value:void 0}function $f(e,n,i){const r=n.get("selections");if(!r?.length)return;const o=t.stringValue(i.field);return r.map((e=>`(!length(data(${t.stringValue(A(e)+vu)})) || (${e}[${o}] && indexof(${e}[${o}], datum.value) >= 0))`)).join(" || ")}const kf={direction:e=>{let{direction:t}=e;return t},format:e=>{let{fieldOrDatumDef:t,legend:n,config:i}=e;const{format:r,formatType:o}=n;return xo(t,t.type,r,o,i,!1)},formatType:e=>{let{legend:t,fieldOrDatumDef:n,scaleType:i}=e;const{formatType:r}=t;return wo(r,n,i)},gradientLength:e=>{const{legend:t,legendConfig:n}=e;return t.gradientLength??n.gradientLength??function(e){let{legendConfig:t,model:n,direction:i,orient:r,scaleType:o}=e;const{gradientHorizontalMaxLength:a,gradientHorizontalMinLength:s,gradientVerticalMaxLength:l,gradientVerticalMinLength:c}=t;if(wr(o))return"horizontal"===i?"top"===r||"bottom"===r?Ff(n,"width",s,a):s:Ff(n,"height",c,l);return}(e)},labelOverlap:e=>{let{legend:t,legendConfig:n,scaleType:i}=e;return t.labelOverlap??n.labelOverlap??function(e){if(v(["quantile","threshold","log","symlog"],e))return"greedy";return}(i)},symbolType:e=>{let{legend:t,markDef:n,channel:i,encoding:r}=e;return t.symbolType??function(e,t,n,i){if("shape"!==t){const e=xf(n)??i;if(e)return e}switch(e){case"bar":case"rect":case"image":case"square":return"square";case"line":case"trail":case"rule":return"stroke";case"arc":case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return"circle"}}(n.type,i,r.shape,n.shape)},title:e=>{let{fieldOrDatumDef:t,config:n}=e;return sa(t,n,{allowDisabling:!0})},type:e=>{let{legendType:t,scaleType:n,channel:i}=e;if(Le(i)&&wr(n)){if("gradient"===t)return}else if("symbol"===t)return;return t},values:e=>{let{fieldOrDatumDef:n,legend:i}=e;return function(e,n){const i=e.values;if(t.isArray(i))return xa(n,i);if(gn(i))return i;return}(i,n)}};function Sf(e){const{legend:t}=e;return B(t.type,function(e){let{channel:t,timeUnit:n,scaleType:i}=e;if(Le(t)){if(v(["quarter","month","day"],n))return"symbol";if(wr(i))return"gradient"}return"symbol"}(e))}function Df(e){let{legendConfig:t,legendType:n,orient:i,legend:r}=e;return r.direction??t[n?"gradientDirection":"symbolDirection"]??function(e,t){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return"gradient"===t?"horizontal":void 0}}(i,n)}function Ff(e,t,n,i){return{signal:`clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${i})`}}function Of(e){const t=op(e)?function(e){const{encoding:t}=e,n={};for(const i of[me,...hs]){const r=da(t[i]);r&&e.getScaleComponent(i)&&(i===ye&&Io(r)&&r.type===sr||(n[i]=_f(e,i)))}return n}(e):function(e){const{legends:t,resolve:n}=e.component;for(const i of e.children){Of(i);for(const r of _(i.component.legends))n.legend[r]=gf(e.component.resolve,r),"shared"===n.legend[r]&&(t[r]=Cf(t[r],i.component.legends[r]),t[r]||(n.legend[r]="independent",delete t[r]))}for(const i of _(t))for(const t of e.children)t.component.legends[i]&&"shared"===n.legend[i]&&delete t.component.legends[i];return t}(e);return e.component.legends=t,t}function zf(e,t,n,i){switch(t){case"disable":return void 0!==n;case"values":return!!n?.values;case"title":if("title"===t&&e===i?.title)return!0}return e===(n||{})[t]}function _f(e,t){let n=e.legend(t);const{markDef:i,encoding:r,config:o}=e,a=o.legend,s=new yf({},function(e,t){const n=e.scaleName(t);if("trail"===e.mark){if("color"===t)return{stroke:n};if("size"===t)return{strokeWidth:n}}return"color"===t?e.markDef.filled?{fill:n}:{stroke:n}:{[t]:n}}(e,t));!function(e,t,n){const i=e.fieldDef(t)?.field;for(const r of C(e.component.selection??{})){const e=r.project.hasField[i]??r.project.hasChannel[t];if(e&&cu.defined(r)){const t=n.get("selections")??[];t.push(r.name),n.set("selections",t,!1),e.hasLegend=!0}}}(e,t,s);const l=void 0!==n?!n:a.disable;if(s.set("disable",l,void 0!==n),l)return s;n=n||{};const c=e.getScaleComponent(t).get("type"),u=da(r[t]),f=Io(u)?Ui(u.timeUnit)?.unit:void 0,d=n.orient||o.legend.orient||"right",p=Sf({legend:n,channel:t,timeUnit:f,scaleType:c}),m={legend:n,channel:t,model:e,markDef:i,encoding:r,fieldOrDatumDef:u,legendConfig:a,config:o,scaleType:c,orient:d,legendType:p,direction:Df({legend:n,legendType:p,orient:d,legendConfig:a})};for(const i of hf){if("gradient"===p&&i.startsWith("symbol")||"symbol"===p&&i.startsWith("gradient"))continue;const r=i in kf?kf[i](m):n[i];if(void 0!==r){const a=zf(r,i,n,e.fieldDef(t));(a||void 0===o.legend[i])&&s.set(i,r,a)}}const g=n?.encoding??{},h=s.get("selections"),y={},v={fieldOrDatumDef:u,model:e,channel:t,legendCmpt:s,legendType:p};for(const t of["labels","legend","title","symbols","gradient","entries"]){const n=pf(g[t]??{},e),i=t in vf?vf[t](n,v):n;void 0===i||z(i)||(y[t]={...h?.length&&Io(u)?{name:`${A(u.field)}_legend_${t}`}:{},...h?.length?{interactive:!!h}:{},update:i})}return z(y)||s.set("encode",y,!!n?.encoding),s}function Cf(e,t){if(!e)return t.clone();const n=e.getWithExplicit("orient"),i=t.getWithExplicit("orient");if(n.explicit&&i.explicit&&n.value!==i.value)return;let r=!1;for(const n of hf){const i=Jl(e.getWithExplicit(n),t.getWithExplicit(n),n,"legend",((e,t)=>{switch(n){case"symbolType":return Nf(e,t);case"title":return Tn(e,t);case"type":return r=!0,Yl("symbol")}return Ql(e,t,n,"legend")}));e.setWithExplicit(n,i)}return r&&(e.implicit?.encode?.gradient&&E(e.implicit,["encode","gradient"]),e.explicit?.encode?.gradient&&E(e.explicit,["encode","gradient"])),e}function Nf(e,t){return"circle"===t.value?t:e}function Pf(e){const t=e.component.legends,n={};for(const i of _(t)){const r=e.getScaleComponent(i),o=g(r.get("domains"));if(n[o])for(const e of n[o]){Cf(e,t[i])||n[o].push(t[i])}else n[o]=[t[i].clone()]}return C(n).flat().map((t=>function(e,t){const{disable:n,labelExpr:i,selections:r,...o}=e.combine();if(n)return;!1===t.aria&&null==o.aria&&(o.aria=!1);if(o.encode?.symbols){const e=o.encode.symbols.update;!e.fill||"transparent"===e.fill.value||e.stroke||o.stroke||(e.stroke={value:"transparent"});for(const t of hs)o[t]&&delete e[t]}o.title||delete o.title;if(void 0!==i){let e=i;o.encode?.labels?.update&&gn(o.encode.labels.update.text)&&(e=W(i,"datum.label",o.encode.labels.update.text.signal)),function(e,t,n,i){e.encode??={},e.encode[t]??={},e.encode[t].update??={},e.encode[t].update[n]=i}(o,"labels","text",{signal:e})}return o}(t,e.config))).filter((e=>void 0!==e))}function Af(e){return lp(e)||sp(e)?function(e){return e.children.reduce(((e,t)=>e.concat(t.assembleProjections())),jf(e))}(e):jf(e)}function jf(e){const t=e.component.projection;if(!t||t.merged)return[];const n=t.combine(),{name:i}=n;if(t.data){const r={signal:`[${t.size.map((e=>e.signal)).join(", ")}]`},o=t.data.reduce(((t,n)=>{const i=gn(n)?n.signal:`data('${e.lookupDataSource(n)}')`;return v(t,i)||t.push(i),t}),[]);if(o.length<=0)throw new Error("Projection's fit didn't find any data sources");return[{name:i,size:r,fit:{signal:o.length>1?`[${o.join(", ")}]`:o[0]},...n}]}return[{name:i,translate:{signal:"[width / 2, height / 2]"},...n}]}const Ef=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class Tf extends Vl{constructor(e,t,n,i){super({...t},{name:e}),this.specifiedProjection=t,this.size=n,this.data=i,Mn(this,"merged",!1)}get isFit(){return!!this.data}}function Mf(e){e.component.projection=op(e)?function(e){if(e.hasProjection){const t=dn(e.specifiedProjection),n=!(t&&(null!=t.scale||null!=t.translate)),i=n?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,r=n?function(e){const t=[],{encoding:n}=e;for(const i of[[fe,ue],[pe,de]])(da(n[i[0]])||da(n[i[1]]))&&t.push({signal:e.getName(`geojson_${t.length}`)});e.channelHasField(ye)&&e.typedFieldDef(ye).type===sr&&t.push({signal:e.getName(`geojson_${t.length}`)});0===t.length&&t.push(e.requestDataName(ac.Main));return t}(e):void 0,o=new Tf(e.projectionName(!0),{...dn(e.config.projection)??{},...t??{}},i,r);return o.get("type")||o.set("type","equalEarth",!1),o}return}(e):function(e){if(0===e.children.length)return;let n;for(const t of e.children)Mf(t);const i=x(e.children,(e=>{const i=e.component.projection;if(i){if(n){const e=function(e,n){const i=x(Ef,(i=>!t.hasOwnProperty(e.explicit,i)&&!t.hasOwnProperty(n.explicit,i)||!!(t.hasOwnProperty(e.explicit,i)&&t.hasOwnProperty(n.explicit,i)&&u(e.get(i),n.get(i)))));if(u(e.size,n.size)){if(i)return e;if(u(e.explicit,{}))return n;if(u(n.explicit,{}))return e}return null}(n,i);return e&&(n=e),!!e}return n=i,!0}return!0}));if(n&&i){const t=e.projectionName(!0),i=new Tf(t,n.specifiedProjection,n.size,f(n.data));for(const n of e.children){const e=n.component.projection;e&&(e.isFit&&i.data.push(...n.component.projection.data),n.renameProjection(e.get("name"),t),e.merged=!0)}return i}return}(e)}function Lf(e,t,n,i){if(wa(t,n)){const r=op(e)?e.axis(n)??e.legend(n)??{}:{},o=na(t,{expr:"datum"}),a=na(t,{expr:"datum",binSuffix:"end"});return{formulaAs:na(t,{binSuffix:"range",forAs:!0}),formula:Do(o,a,r.format,r.formatType,i)}}return{}}function qf(e,t){return`${on(e)}_${t}`}function Rf(e,t,n){const i=qf(ha(n,void 0)??{},t);return e.getName(`${i}_bins`)}function Wf(e,n,i){let r,o;r=function(e){return"as"in e}(e)?t.isString(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:[na(e,{forAs:!0}),na(e,{binSuffix:"end",forAs:!0})];const a={...ha(n,void 0)},s=qf(a,e.field),{signal:l,extentSignal:c}=function(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}(i,s);if(cn(a.extent)){const e=a.extent;o=Nu(i,e.param,e),delete a.extent}return{key:s,binComponent:{bin:a,field:e.field,as:[r],...l?{signal:l}:{},...c?{extentSignal:c}:{},...o?{span:o}:{}}}}class Uf extends dc{clone(){return new Uf(null,f(this.bins))}constructor(e,t){super(e),this.bins=t}static makeFromEncoding(e,t){const n=t.reduceFieldDef(((e,n,i)=>{if(Xo(n)&&an(n.bin)){const{key:r,binComponent:o}=Wf(n,n.bin,t);e[r]={...o,...e[r],...Lf(t,n,i,t.config)}}return e}),{});return z(n)?null:new Uf(e,n)}static makeFromTransform(e,t,n){const{key:i,binComponent:r}=Wf(t,t.bin,n);return new Uf(e,{[i]:r})}merge(e,t){for(const n of _(e.bins))n in this.bins?(t(e.bins[n].signal,this.bins[n].signal),this.bins[n].as=k([...this.bins[n].as,...e.bins[n].as],h)):this.bins[n]=e.bins[n];for(const t of e.children)e.removeChild(t),t.parent=this;e.remove()}producedFields(){return new Set(C(this.bins).map((e=>e.as)).flat(2))}dependentFields(){return new Set(C(this.bins).map((e=>e.field)))}hash(){return`Bin ${h(this.bins)}`}assemble(){return C(this.bins).flatMap((e=>{const t=[],[n,...i]=e.as,{extent:r,...o}=e.bin,a={type:"bin",field:R(e.field),as:n,signal:e.signal,...cn(r)?{extent:null}:{extent:r},...e.span?{span:{signal:`span(${e.span})`}}:{},...o};!r&&e.extentSignal&&(t.push({type:"extent",field:R(e.field),signal:e.extentSignal}),a.extent={signal:e.extentSignal}),t.push(a);for(const e of i)for(let i=0;i<2;i++)t.push({type:"formula",expr:na({field:n[i]},{expr:"datum"}),as:e[i]});return e.formula&&t.push({type:"formula",expr:e.formula,as:e.formulaAs}),t}))}}function If(e,n,i,r){const o=op(r)?r.encoding[nt(n)]:void 0;if(Xo(i)&&op(r)&&qo(i,o,r.markDef,r.config))e.add(na(i,{})),e.add(na(i,{suffix:"end"})),i.bin&&wa(i,n)&&e.add(na(i,{binSuffix:"range"}));else if(n in Ee){const t=function(e){switch(e){case ue:return"y";case de:return"y2";case fe:return"x";case pe:return"x2"}}(n);e.add(r.getName(t))}else e.add(na(i));return Jo(i)&&function(e){return t.isObject(e)&&"field"in e}(i.scale?.range)&&e.add(i.scale.range.field),e}class Bf extends dc{clone(){return new Bf(null,new Set(this.dimensions),f(this.measures))}constructor(e,t,n){super(e),this.dimensions=t,this.measures=n}get groupBy(){return this.dimensions}static makeFromEncoding(e,t){let n=!1;t.forEachFieldDef((e=>{e.aggregate&&(n=!0)}));const i={},r=new Set;return n?(t.forEachFieldDef(((e,n)=>{const{aggregate:o,field:a}=e;if(o)if("count"===o)i["*"]??={},i["*"].count=new Set([na(e,{forAs:!0})]);else{if(Jt(o)||Kt(o)){const e=Jt(o)?"argmin":"argmax",t=o[e];i[t]??={},i[t][e]=new Set([na({op:e,field:t},{forAs:!0})])}else i[a]??={},i[a][o]=new Set([na(e,{forAs:!0})]);It(n)&&"unaggregated"===t.scaleDomain(n)&&(i[a]??={},i[a].min=new Set([na({field:a,aggregate:"min"},{forAs:!0})]),i[a].max=new Set([na({field:a,aggregate:"max"},{forAs:!0})]))}else If(r,n,e,t)})),r.size+_(i).length===0?null:new Bf(e,r,i)):null}static makeFromTransform(e,t){const n=new Set,i={};for(const e of t.aggregate){const{op:t,field:n,as:r}=e;t&&("count"===t?(i["*"]??={},i["*"].count=new Set([r||na(e,{forAs:!0})])):(i[n]??={},i[n][t]=new Set([r||na(e,{forAs:!0})])))}for(const e of t.groupby??[])n.add(e);return n.size+_(i).length===0?null:new Bf(e,n,i)}merge(e){return S(this.dimensions,e.dimensions)?(function(e,t){for(const n of _(t)){const i=t[n];for(const t of _(i))n in e?e[n][t]=new Set([...e[n][t]??[],...i[t]]):e[n]={[t]:i[t]}}}(this.measures,e.measures),!0):(function(){Di.debug(...arguments)}("different dimensions, cannot merge"),!1)}addDimensions(e){e.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,..._(this.measures)])}producedFields(){const e=new Set;for(const t of _(this.measures))for(const n of _(this.measures[t])){const i=this.measures[t][n];0===i.size?e.add(`${n}_${t}`):i.forEach(e.add,e)}return e}hash(){return`Aggregate ${h({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const e=[],t=[],n=[];for(const i of _(this.measures))for(const r of _(this.measures[i]))for(const o of this.measures[i][r])n.push(o),e.push(r),t.push("*"===i?null:R(i));return{type:"aggregate",groupby:[...this.dimensions].map(R),ops:e,fields:t,as:n}}}class Hf extends dc{constructor(e,n,i,r){super(e),this.model=n,this.name=i,this.data=r,Mn(this,"column",void 0),Mn(this,"row",void 0),Mn(this,"facet",void 0),Mn(this,"childModel",void 0);for(const e of Re){const i=n.facet[e];if(i){const{bin:r,sort:o}=i;this[e]={name:n.getName(`${e}_domain`),fields:[na(i),...an(r)?[na(i,{binSuffix:"end"})]:[]],...Co(o)?{sortField:o}:t.isArray(o)?{sortIndexField:Hu(i,e)}:{}}}}this.childModel=n.child}hash(){let e="Facet";for(const t of Re)this[t]&&(e+=` ${t.charAt(0)}:${h(this[t])}`);return e}get fields(){const e=[];for(const t of Re)this[t]?.fields&&e.push(...this[t].fields);return e}dependentFields(){const e=new Set(this.fields);for(const t of Re)this[t]&&(this[t].sortField&&e.add(this[t].sortField.field),this[t].sortIndexField&&e.add(this[t].sortIndexField));return e}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const e={};for(const t of St){const n=this.childModel.component.scales[t];if(n&&!n.merged){const i=n.get("type"),r=n.get("range");if(br(i)&&hn(r)){const n=Td(Md(this.childModel,t));n?e[t]=n:Fi(Vn(t))}}}return e}assembleRowColumnHeaderData(e,t,n){const i={row:"y",column:"x",facet:void 0}[e],r=[],o=[],a=[];i&&n&&n[i]&&(t?(r.push(`distinct_${n[i]}`),o.push("max")):(r.push(n[i]),o.push("distinct")),a.push(`distinct_${n[i]}`));const{sortField:s,sortIndexField:l}=this[e];if(s){const{op:e=Fo,field:t}=s;r.push(t),o.push(e),a.push(na(s,{forAs:!0}))}else l&&(r.push(l),o.push("max"),a.push(l));return{name:this[e].name,source:t??this.data,transform:[{type:"aggregate",groupby:this[e].fields,...r.length?{fields:r,ops:o,as:a}:{}}]}}assembleFacetHeaderData(e){const{columns:t}=this.model.layout,{layoutHeaders:n}=this.model.component,i=[],r={};for(const e of Xu){for(const t of Qu){const i=(n[e]&&n[e][t])??[];for(const t of i)if(t.axes?.length>0){r[e]=!0;break}}if(r[e]){const n=`length(data("${this.facet.name}"))`,r="row"===e?t?{signal:`ceil(${n} / ${t})`}:1:t?{signal:`min(${n}, ${t})`}:{signal:n};i.push({name:`${this.facet.name}_${e}`,transform:[{type:"sequence",start:0,stop:r}]})}}const{row:o,column:a}=r;return(o||a)&&i.unshift(this.assembleRowColumnHeaderData("facet",null,e)),i}assemble(){const e=[];let t=null;const n=this.getChildIndependentFieldsWithStep(),{column:i,row:r,facet:o}=this;if(i&&r&&(n.x||n.y)){t=`cross_${this.column.name}_${this.row.name}`;const i=[].concat(n.x??[],n.y??[]),r=i.map((()=>"distinct"));e.push({name:t,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:i,ops:r}]})}for(const i of[K,J])this[i]&&e.push(this.assembleRowColumnHeaderData(i,t,n));if(o){const t=this.assembleFacetHeaderData(n);t&&e.push(...t)}return e}}function Vf(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Gf(e){const n={};return l(e.filter,(e=>{if(Qi(e)){let i=null;Ii(e)?i=$n(e.equal):Hi(e)?i=$n(e.lte):Bi(e)?i=$n(e.lt):Vi(e)?i=$n(e.gt):Gi(e)?i=$n(e.gte):Yi(e)?i=e.range[0]:Xi(e)&&(i=(e.oneOf??e.in)[0]),i&&(Oi(i)?n[e.field]="date":t.isNumber(i)?n[e.field]="number":t.isString(i)&&(n[e.field]="string")),e.timeUnit&&(n[e.field]="date")}})),n}function Yf(e){const n={};function i(e){var i;va(e)?n[e.field]="date":"quantitative"===e.type&&(i=e.aggregate,t.isString(i)&&v(["min","max"],i))?n[e.field]="number":I(e.field)>1?e.field in n||(n[e.field]="flatten"):Jo(e)&&Co(e.sort)&&I(e.sort.field)>1&&(e.sort.field in n||(n[e.sort.field]="flatten"))}if((op(e)||ap(e))&&e.forEachFieldDef(((t,n)=>{if(Xo(t))i(t);else{const r=et(n),o=e.fieldDef(r);i({...t,type:o.type})}})),op(e)){const{mark:t,markDef:i,encoding:r}=e;if(Xr(t)&&!e.encoding.order){const e=r["horizontal"===i.orient?"y":"x"];Io(e)&&"quantitative"===e.type&&!(e.field in n)&&(n[e.field]="number")}}return n}class Xf extends dc{clone(){return new Xf(null,f(this._parse))}constructor(e,t){super(e),Mn(this,"_parse",void 0),this._parse=t}hash(){return`Parse ${h(this._parse)}`}static makeExplicit(e,t,n){let i={};const r=t.data;return!nc(r)&&r?.format?.parse&&(i=r.format.parse),this.makeWithAncestors(e,i,{},n)}static makeWithAncestors(e,t,n,i){for(const e of _(n)){const t=i.getWithExplicit(e);void 0!==t.value&&(t.explicit||t.value===n[e]||"derived"===t.value||"flatten"===n[e]?delete n[e]:Fi(Kn(e,n[e],t.value)))}for(const e of _(t)){const n=i.get(e);void 0!==n&&(n===t[e]?delete t[e]:Fi(Kn(e,t[e],n)))}const r=new Vl(t,n);i.copyAll(r);const o={};for(const e of _(r.combine())){const t=r.get(e);null!==t&&(o[e]=t)}return 0===_(o).length||i.parseNothing?null:new Xf(e,o)}get parse(){return this._parse}merge(e){this._parse={...this._parse,...e.parse},e.remove()}assembleFormatParse(){const e={};for(const t of _(this._parse)){const n=this._parse[t];1===I(t)&&(e[t]=n)}return e}producedFields(){return new Set(_(this._parse))}dependentFields(){return new Set(_(this._parse))}assembleTransforms(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return _(this._parse).filter((t=>!e||I(t)>1)).map((e=>{const t=function(e,t){const n=M(e);if("number"===t)return`toNumber(${n})`;if("boolean"===t)return`toBoolean(${n})`;if("string"===t)return`toString(${n})`;if("date"===t)return`toDate(${n})`;if("flatten"===t)return n;if(t.startsWith("date:"))return`timeParse(${n},'${Vf(t.slice(5,t.length))}')`;if(t.startsWith("utc:"))return`utcParse(${n},'${Vf(t.slice(4,t.length))}')`;return Fi(`Unrecognized parse "${t}".`),null}(e,this._parse[e]);if(!t)return null;return{type:"formula",expr:t,as:U(e)}})).filter((e=>null!==e))}}class Qf extends dc{clone(){return new Qf(null)}constructor(e){super(e)}dependentFields(){return new Set}producedFields(){return new Set([ys])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:ys}}}class Jf extends dc{clone(){return new Jf(null,this.params)}constructor(e,t){super(e),this.params=t}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${h(this.params)}`}assemble(){return{type:"graticule",...!0===this.params?{}:this.params}}}class Kf extends dc{clone(){return new Kf(null,this.params)}constructor(e,t){super(e),this.params=t}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??"data"])}hash(){return`Hash ${h(this.params)}`}assemble(){return{type:"sequence",...this.params}}}class Zf extends dc{constructor(e){let t;if(super(null),Mn(this,"_data",void 0),Mn(this,"_name",void 0),Mn(this,"_generator",void 0),e??={name:"source"},nc(e)||(t=e.format?{...m(e.format,["parse"])}:{}),ec(e))this._data={values:e.values};else if(Zl(e)){if(this._data={url:e.url},!t.type){let n=/(?:\.([^.]+))?$/.exec(e.url)[1];v(["json","csv","tsv","dsv","topojson"],n)||(n="json"),t.type=n}}else rc(e)?this._data={values:[{type:"Sphere"}]}:(tc(e)||nc(e))&&(this._data={});this._generator=nc(e),e.name&&(this._name=e.name),t&&!z(t)&&(this._data.format=t)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(e){this._name=e}set parent(e){throw new Error("Source nodes have to be roots.")}remove(){throw new Error("Source nodes are roots and cannot be removed.")}hash(){throw new Error("Cannot hash sources")}assemble(){return{name:this._name,...this._data,transform:[]}}}function ed(e){return e instanceof Zf||e instanceof Jf||e instanceof Kf}var td=new WeakMap;class nd{constructor(){Rn(this,td,{writable:!0,value:void 0}),Ln(this,td,!1)}setModified(){Ln(this,td,!0)}get modifiedFlag(){return function(e,t){return t.get?t.get.call(e):t.value}(e=this,qn(e,td,"get"));var e}}class id extends nd{getNodeDepths(e,t,n){n.set(e,t);for(const i of e.children)this.getNodeDepths(i,t+1,n);return n}optimize(e){const t=[...this.getNodeDepths(e,0,new Map).entries()].sort(((e,t)=>t[1]-e[1]));for(const e of t)this.run(e[0]);return this.modifiedFlag}}class rd extends nd{optimize(e){this.run(e);for(const t of e.children)this.optimize(t);return this.modifiedFlag}}class od extends rd{mergeNodes(e,t){const n=t.shift();for(const i of t)e.removeChild(i),i.parent=n,i.remove()}run(e){const t=e.children.map((e=>e.hash())),n={};for(let i=0;i1&&(this.setModified(),this.mergeNodes(e,n[t]))}}class ad extends rd{constructor(e){super(),Mn(this,"requiresSelectionId",void 0),this.requiresSelectionId=e&&Su(e)}run(e){e instanceof Qf&&(this.requiresSelectionId&&(ed(e.parent)||e.parent instanceof Bf||e.parent instanceof Xf)||(this.setModified(),e.remove()))}}class sd extends nd{optimize(e){return this.run(e,new Set),this.modifiedFlag}run(e,t){let n=new Set;e instanceof mc&&(n=e.producedFields(),D(n,t)&&(this.setModified(),e.removeFormulas(t),0===e.producedFields.length&&e.remove()));for(const i of e.children)this.run(i,new Set([...t,...n]))}}class ld extends rd{constructor(){super()}run(e){e instanceof pc&&!e.isRequired()&&(this.setModified(),e.remove())}}class cd extends id{run(e){if(!(ed(e)||e.numChildren()>1))for(const t of e.children)if(t instanceof Xf)if(e instanceof Xf)this.setModified(),e.merge(t);else{if(O(e.producedFields(),t.dependentFields()))continue;this.setModified(),t.swapWithParent()}}}class ud extends id{run(e){const t=[...e.children],n=e.children.filter((e=>e instanceof Xf));if(e.numChildren()>1&&n.length>=1){const i={},r=new Set;for(const e of n){const t=e.parse;for(const e of _(t))e in i?i[e]!==t[e]&&r.add(e):i[e]=t[e]}for(const e of r)delete i[e];if(!z(i)){this.setModified();const n=new Xf(e,i);for(const r of t){if(r instanceof Xf)for(const e of _(i))delete r.parse[e];e.removeChild(r),r.parent=n,r instanceof Xf&&0===_(r.parse).length&&r.remove()}}}}}class fd extends id{run(e){e instanceof pc||e.numChildren()>0||e instanceof Hf||e instanceof Zf||(this.setModified(),e.remove())}}class dd extends id{run(e){const t=e.children.filter((e=>e instanceof mc)),n=t.pop();for(const e of t)this.setModified(),n.merge(e)}}class pd extends id{run(e){const t=e.children.filter((e=>e instanceof Bf)),n={};for(const e of t){const t=h(e.groupBy);t in n||(n[t]=[]),n[t].push(e)}for(const t of _(n)){const i=n[t];if(i.length>1){const t=i.pop();for(const n of i)t.merge(n)&&(e.removeChild(n),n.parent=t,n.remove(),this.setModified())}}}}class md extends id{constructor(e){super(),this.model=e}run(e){const t=!(ed(e)||e instanceof _u||e instanceof Xf||e instanceof Qf),n=[],i=[];for(const r of e.children)r instanceof Uf&&(t&&!O(e.producedFields(),r.dependentFields())?n.push(r):i.push(r));if(n.length>0){const t=n.pop();for(const e of n)t.merge(e,this.model.renameSignal.bind(this.model));this.setModified(),e instanceof Uf?e.merge(t,this.model.renameSignal.bind(this.model)):t.swapWithParent()}if(i.length>1){const e=i.pop();for(const t of i)e.merge(t,this.model.renameSignal.bind(this.model));this.setModified()}}}class gd extends id{run(e){const t=[...e.children];if(!b(t,(e=>e instanceof pc))||e.numChildren()<=1)return;const n=[];let i;for(const r of t)if(r instanceof pc){let t=r;for(;1===t.numChildren();){const[e]=t.children;if(!(e instanceof pc))break;t=e}n.push(...t.children),i?(e.removeChild(r),r.parent=i.parent,i.parent.removeChild(i),i.parent=t,this.setModified()):i=t}else n.push(r);if(n.length){this.setModified();for(const e of n)e.parent.removeChild(e),e.parent=i}}}class hd extends dc{clone(){return new hd(null,f(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=k(this.transform.groupby.concat(e),(e=>e))}dependentFields(){const e=new Set;return this.transform.groupby&&this.transform.groupby.forEach(e.add,e),this.transform.joinaggregate.map((e=>e.field)).filter((e=>void 0!==e)).forEach(e.add,e),e}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(e){return e.as??na(e)}hash(){return`JoinAggregateTransform ${h(this.transform)}`}assemble(){const e=[],t=[],n=[];for(const i of this.transform.joinaggregate)t.push(i.op),n.push(this.getDefaultName(i)),e.push(void 0===i.field?null:i.field);const i=this.transform.groupby;return{type:"joinaggregate",as:n,ops:t,fields:e,...void 0!==i?{groupby:i}:{}}}}class yd extends dc{clone(){return new yd(null,f(this._stack))}constructor(e,t){super(e),Mn(this,"_stack",void 0),this._stack=t}static makeFromTransform(e,n){const{stack:i,groupby:r,as:o,offset:a="zero"}=n,s=[],l=[];if(void 0!==n.sort)for(const e of n.sort)s.push(e.field),l.push(B(e.order,"ascending"));const c={field:s,order:l};let u;return u=function(e){return t.isArray(e)&&e.every((e=>t.isString(e)))&&e.length>1}(o)?o:t.isString(o)?[o,`${o}_end`]:[`${n.stack}_start`,`${n.stack}_end`],new yd(e,{dimensionFieldDefs:[],stackField:i,groupby:r,offset:a,sort:c,facetby:[],as:u})}static makeFromEncoding(e,n){const i=n.stack,{encoding:r}=n;if(!i)return null;const{groupbyChannels:o,fieldChannel:a,offset:s,impute:l}=i,c=o.map((e=>fa(r[e]))).filter((e=>!!e)),u=function(e){return e.stack.stackBy.reduce(((e,t)=>{const n=na(t.fieldDef);return n&&e.push(n),e}),[])}(n),f=n.encoding.order;let d;return d=t.isArray(f)||Io(f)?An(f):u.reduce(((e,t)=>(e.field.push(t),e.order.push("y"===a?"descending":"ascending"),e)),{field:[],order:[]}),new yd(e,{dimensionFieldDefs:c,stackField:n.vgField(a),facetby:[],stackby:u,sort:d,offset:s,impute:l,as:[n.vgField(a,{suffix:"start",forAs:!0}),n.vgField(a,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(e){this._stack.facetby.push(...e)}dependentFields(){const e=new Set;return e.add(this._stack.stackField),this.getGroupbyFields().forEach(e.add,e),this._stack.facetby.forEach(e.add,e),this._stack.sort.field.forEach(e.add,e),e}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${h(this._stack)}`}getGroupbyFields(){const{dimensionFieldDefs:e,impute:t,groupby:n}=this._stack;return e.length>0?e.map((e=>e.bin?t?[na(e,{binSuffix:"mid"})]:[na(e,{}),na(e,{binSuffix:"end"})]:[na(e)])).flat():n??[]}assemble(){const e=[],{facetby:t,dimensionFieldDefs:n,stackField:i,stackby:r,sort:o,offset:a,impute:s,as:l}=this._stack;if(s)for(const o of n){const{bandPosition:n=.5,bin:a}=o;if(a){const t=na(o,{expr:"datum"}),i=na(o,{expr:"datum",binSuffix:"end"});e.push({type:"formula",expr:`${n}*${t}+${1-n}*${i}`,as:na(o,{binSuffix:"mid",forAs:!0})})}e.push({type:"impute",field:i,groupby:[...r,...t],key:na(o,{binSuffix:"mid"}),method:"value",value:0})}return e.push({type:"stack",groupby:[...this.getGroupbyFields(),...t],field:i,sort:o,as:l,offset:a}),e}}class vd extends dc{clone(){return new vd(null,f(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=k(this.transform.groupby.concat(e),(e=>e))}dependentFields(){const e=new Set;return(this.transform.groupby??[]).forEach(e.add,e),(this.transform.sort??[]).forEach((t=>e.add(t.field))),this.transform.window.map((e=>e.field)).filter((e=>void 0!==e)).forEach(e.add,e),e}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(e){return e.as??na(e)}hash(){return`WindowTransform ${h(this.transform)}`}assemble(){const e=[],t=[],n=[],i=[];for(const r of this.transform.window)t.push(r.op),n.push(this.getDefaultName(r)),i.push(void 0===r.param?null:r.param),e.push(void 0===r.field?null:r.field);const r=this.transform.frame,o=this.transform.groupby;if(r&&null===r[0]&&null===r[1]&&t.every((e=>Zt(e))))return{type:"joinaggregate",as:n,ops:t,fields:e,...void 0!==o?{groupby:o}:{}};const a=[],s=[];if(void 0!==this.transform.sort)for(const e of this.transform.sort)a.push(e.field),s.push(e.order??"ascending");const l={field:a,order:s},c=this.transform.ignorePeers;return{type:"window",params:i,as:n,ops:t,fields:e,sort:l,...void 0!==c?{ignorePeers:c}:{},...void 0!==o?{groupby:o}:{},...void 0!==r?{frame:r}:{}}}}function bd(e){if(e instanceof Hf)if(1!==e.numChildren()||e.children[0]instanceof pc){const n=e.model.component.data.main;xd(n);const i=(t=e,function e(n){if(!(n instanceof Hf)){const i=n.clone();if(i instanceof pc){const e=wd+i.getSource();i.setSource(e),t.model.component.data.outputNodes[e]=i}else(i instanceof Bf||i instanceof yd||i instanceof vd||i instanceof hd)&&i.addDimensions(t.fields);for(const t of n.children.flatMap(e))t.parent=i;return[i]}return n.children.flatMap(e)}),r=e.children.map(i).flat();for(const e of r)e.parent=n}else{const t=e.children[0];(t instanceof Bf||t instanceof yd||t instanceof vd||t instanceof hd)&&t.addDimensions(e.fields),t.swapWithParent(),bd(e)}else e.children.map(bd);var t}function xd(e){if(e instanceof pc&&e.type===ac.Main&&1===e.numChildren()){const t=e.children[0];t instanceof Hf||(t.swapWithParent(),xd(e))}}const wd="scale_",$d=5;function kd(e){for(const t of e){for(const e of t.children)if(e.parent!==t)return!1;if(!kd(t.children))return!1}return!0}function Sd(e,t){let n=!1;for(const i of t)n=e.optimize(i)||n;return n}function Dd(e,t,n){let i=e.sources,r=!1;return r=Sd(new ld,i)||r,r=Sd(new ad(t),i)||r,i=i.filter((e=>e.numChildren()>0)),r=Sd(new fd,i)||r,i=i.filter((e=>e.numChildren()>0)),n||(r=Sd(new cd,i)||r,r=Sd(new md(t),i)||r,r=Sd(new sd,i)||r,r=Sd(new ud,i)||r,r=Sd(new pd,i)||r,r=Sd(new dd,i)||r,r=Sd(new od,i)||r,r=Sd(new gd,i)||r),e.sources=i,r}class Fd{constructor(e){Mn(this,"signal",void 0),Object.defineProperty(this,"signal",{enumerable:!0,get:e})}static fromName(e,t){return new Fd((()=>e(t)))}}function Od(e){op(e)?function(e){const t=e.component.scales;for(const n of _(t)){const i=zd(e,n);if(t[n].setWithExplicit("domains",i),Pd(e,n),e.component.data.isFaceted){let t=e;for(;!ap(t)&&t.parent;)t=t.parent;if("shared"===t.component.resolve.scale[n])for(const e of i.value)yn(e)&&(e.data=wd+e.data.replace(wd,""))}}}(e):function(e){for(const t of e.children)Od(t);const t=e.component.scales;for(const n of _(t)){let i,r=null;for(const t of e.children){const e=t.component.scales[n];if(e){i=void 0===i?e.getWithExplicit("domains"):Jl(i,e.getWithExplicit("domains"),"domains","scale",jd);const t=e.get("selectionExtent");r&&t&&r.param!==t.param&&Fi(Qn),r=t}}t[n].setWithExplicit("domains",i),r&&t[n].set("selectionExtent",r,!0)}}(e)}function zd(e,t){const n=e.getScaleComponent(t).get("type"),{encoding:i}=e,r=function(e,t,n,i){if("unaggregated"===e){const{valid:e,reason:i}=Ad(t,n);if(!e)return void Fi(i)}else if(void 0===e&&i.useUnaggregatedDomain){const{valid:e}=Ad(t,n);if(e)return"unaggregated"}return e}(e.scaleDomain(t),e.typedFieldDef(t),n,e.config.scale);return r!==e.scaleDomain(t)&&(e.specifiedScales[t]={...e.specifiedScales[t],domain:r}),"x"===t&&da(i.x2)?da(i.x)?Jl(Cd(n,r,e,"x"),Cd(n,r,e,"x2"),"domain","scale",jd):Cd(n,r,e,"x2"):"y"===t&&da(i.y2)?da(i.y)?Jl(Cd(n,r,e,"y"),Cd(n,r,e,"y2"),"domain","scale",jd):Cd(n,r,e,"y2"):Cd(n,r,e,t)}function _d(e,t,n){const i=Ui(n)?.unit;return"temporal"===t||i?function(e,t,n){return e.map((e=>({signal:`{data: ${ba(e,{timeUnit:n,type:t})}}`})))}(e,t,i):[e]}function Cd(e,n,i,r){const{encoding:o}=i,a=da(o[r]),{type:s}=a,l=a.timeUnit;if(function(e){return e?.unionWith}(n)){const t=Cd(e,void 0,i,r);return Gl([..._d(n.unionWith,s,l),...t.value])}if(gn(n))return Gl([n]);if(n&&"unaggregated"!==n&&!kr(n))return Gl(_d(n,s,l));const c=i.stack;if(c&&r===c.fieldChannel){if("normalize"===c.offset)return Yl([[0,1]]);const e=i.requestDataName(ac.Main);return Yl([{data:e,field:i.vgField(r,{suffix:"start"})},{data:e,field:i.vgField(r,{suffix:"end"})}])}const u=It(r)&&Io(a)?function(e,t,n){if(!br(n))return;const i=e.fieldDef(t),r=i.sort;if(No(r))return{op:"min",field:Hu(i,t),order:"ascending"};const{stack:o}=e,a=o?new Set([...o.groupbyFields,...o.stackBy.map((e=>e.fieldDef.field))]):void 0;if(Co(r)){return Nd(r,o&&!a.has(r.field))}if(_o(r)){const{encoding:t,order:n}=r,i=e.fieldDef(t),{aggregate:s,field:l}=i,c=o&&!a.has(l);if(Jt(s)||Kt(s))return Nd({field:na(i),order:n},c);if(Zt(s)||!s)return Nd({op:s,field:l,order:n},c)}else{if("descending"===r)return{op:"min",field:e.vgField(t),order:"descending"};if(v(["ascending",void 0],r))return!0}return}(i,r,e):void 0;if(Ho(a)){return Yl(_d([a.datum],s,l))}const f=a;if("unaggregated"===n){const e=i.requestDataName(ac.Main),{field:t}=a;return Yl([{data:e,field:na({field:t,aggregate:"min"})},{data:e,field:na({field:t,aggregate:"max"})}])}if(an(f.bin)){if(br(e))return Yl("bin-ordinal"===e?[]:[{data:P(u)?i.requestDataName(ac.Main):i.requestDataName(ac.Raw),field:i.vgField(r,wa(f,r)?{binSuffix:"range"}:{}),sort:!0!==u&&t.isObject(u)?u:{field:i.vgField(r,{}),op:"min"}}]);{const{bin:e}=f;if(an(e)){const t=Rf(i,f.field,e);return Yl([new Fd((()=>{const e=i.getSignalName(t);return`[${e}.start, ${e}.stop]`}))])}return Yl([{data:i.requestDataName(ac.Main),field:i.vgField(r,{})}])}}if(f.timeUnit&&v(["time","utc"],e)&&qo(f,op(i)?i.encoding[nt(r)]:void 0,i.markDef,i.config)){const e=i.requestDataName(ac.Main);return Yl([{data:e,field:i.vgField(r)},{data:e,field:i.vgField(r,{suffix:"end"})}])}return Yl(u?[{data:P(u)?i.requestDataName(ac.Main):i.requestDataName(ac.Raw),field:i.vgField(r),sort:u}]:[{data:i.requestDataName(ac.Main),field:i.vgField(r)}])}function Nd(e,t){const{op:n,field:i,order:r}=e;return{op:n??(t?"sum":Fo),...i?{field:R(i)}:{},...r?{order:r}:{}}}function Pd(e,t){const n=e.component.scales[t],i=e.specifiedScales[t].domain,r=e.fieldDef(t)?.bin,o=kr(i)&&i,a=ln(r)&&cn(r.extent)&&r.extent;(o||a)&&n.set("selectionExtent",o??a,!0)}function Ad(e,n){const{aggregate:i,type:r}=e;return i?t.isString(i)&&!rn.has(i)?{valid:!1,reason:pi(i)}:"quantitative"===r&&"log"===n?{valid:!1,reason:mi(e)}:{valid:!0}:{valid:!1,reason:di(e)}}function jd(e,t,n,i){return e.explicit&&t.explicit&&Fi(function(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${g(n)} and ${g(i)}). Using the union of the two domains.`}(n,i,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function Ed(e){const n=k(e.map((e=>{if(yn(e)){const{sort:t,...n}=e;return n}return e})),h),i=k(e.map((e=>{if(yn(e)){const t=e.sort;return void 0===t||P(t)||("op"in t&&"count"===t.op&&delete t.field,"ascending"===t.order&&delete t.order),t}})).filter((e=>void 0!==e)),h);if(0===n.length)return;if(1===n.length){const n=e[0];if(yn(n)&&i.length>0){let e=i[0];if(i.length>1)Fi(yi),e=!0;else if(t.isObject(e)&&"field"in e){const t=e.field;n.field===t&&(e=!e.order||{order:e.order})}return{...n,sort:e}}return n}const r=k(i.map((e=>P(e)||!("op"in e)||t.isString(e.op)&&e.op in Qt?e:(Fi(function(e){return`Dropping sort property ${g(e)} as unioned domains only support boolean or op "count", "min", and "max".`}(e)),!0))),h);let o;1===r.length?o=r[0]:r.length>1&&(Fi(yi),o=!0);const a=k(e.map((e=>yn(e)?e.data:null)),(e=>e));if(1===a.length&&null!==a[0]){return{data:a[0],fields:n.map((e=>e.field)),...o?{sort:o}:{}}}return{fields:n,...o?{sort:o}:{}}}function Td(e){if(yn(e)&&t.isString(e.field))return e.field;if(function(e){return!t.isArray(e)&&"fields"in e&&!("data"in e)}(e)){let n;for(const i of e.fields)if(yn(i)&&t.isString(i.field))if(n){if(n!==i.field)return Fi(vi),n}else n=i.field;return Fi(bi),n}if(function(e){return!t.isArray(e)&&"fields"in e&&"data"in e}(e)){Fi(xi);const n=e.fields[0];return t.isString(n)?n:void 0}}function Md(e,t){const n=e.component.scales[t].get("domains").map((t=>(yn(t)&&(t.data=e.lookupDataSource(t.data)),t)));return Ed(n)}function Ld(e){return lp(e)||sp(e)?e.children.reduce(((e,t)=>e.concat(Ld(t))),qd(e)):qd(e)}function qd(e){return _(e.component.scales).reduce(((n,i)=>{const r=e.component.scales[i];if(r.merged)return n;const o=r.combine(),{name:a,type:s,selectionExtent:l,domains:c,range:u,reverse:f,...d}=o,p=function(e,n,i,r){if(Dt(i)){if(hn(e))return{step:{signal:`${n}_step`}}}else if(t.isObject(e)&&yn(e))return{...e,data:r.lookupDataSource(e.data)};return e}(o.range,a,i,e),m=Md(e,i),g=l?function(e,n,i,r){const o=Nu(e,n.param,n);return{signal:xr(i.get("type"))&&t.isArray(r)&&r[0]>r[1]?`isValid(${o}) && reverse(${o})`:o}}(e,l,r,m):null;return n.push({name:a,type:s,...m?{domain:m}:{},...g?{domainRaw:g}:{},range:p,...void 0!==f?{reverse:f}:{},...d}),n}),[])}class Rd extends Vl{constructor(e,t){super({},{name:e}),Mn(this,"merged",!1),this.setWithExplicit("type",t)}domainDefinitelyIncludesZero(){return!1!==this.get("zero")||b(this.get("domains"),(e=>t.isArray(e)&&2===e.length&&e[0]<=0&&e[1]>=0))}}const Wd=["range","scheme"];function Ud(e,n){const i=e.fieldDef(n);if(i?.bin){const{bin:r,field:o}=i,a=it(n),s=e.getName(a);if(t.isObject(r)&&r.binned&&void 0!==r.step)return new Fd((()=>{const t=e.scaleName(n),i=`(domain("${t}")[1] - domain("${t}")[0]) / ${r.step}`;return`${e.getSignalName(s)} / (${i})`}));if(an(r)){const t=Rf(e,o,r);return new Fd((()=>{const n=e.getSignalName(t),i=`(${n}.stop - ${n}.start) / ${n}.step`;return`${e.getSignalName(s)} / (${i})`}))}}}function Id(e,n){const i=n.specifiedScales[e],{size:r}=n,o=n.getScaleComponent(e).get("type");for(const r of Wd)if(void 0!==i[r]){const a=Pr(o,r),s=Ar(e,r);if(a)if(s)Fi(s);else switch(r){case"range":{const r=i.range;if(t.isArray(r)){if(Dt(e))return Gl(r.map((e=>{if("width"===e||"height"===e){const t=n.getName(e),i=n.getSignalName.bind(n);return Fd.fromName(i,t)}return e})))}else if(t.isObject(r))return Gl({data:n.requestDataName(ac.Main),field:r.field,sort:{op:"min",field:n.vgField(e)}});return Gl(r)}case"scheme":return Gl(Bd(i[r]))}else Fi(gi(o,r,e))}const a=e===ee||"xOffset"===e?"width":"height",s=r[a];if(Os(s))if(Dt(e))if(br(o)){const t=Hd(s,n,e);if(t)return Gl({step:t})}else Fi(hi(a));else if(Ct(e)){const t=e===re?"x":"y";if("band"===n.getScaleComponent(t).get("type")){const e=Vd(s,o);if(e)return Gl(e)}}const{rangeMin:l,rangeMax:c}=i,u=function(e,n){const{size:i,config:r,mark:o,encoding:a}=n,s=n.getSignalName.bind(n),{type:l}=da(a[e]),c=n.getScaleComponent(e),u=c.get("type"),{domain:f,domainMid:p}=n.specifiedScales[e];switch(e){case ee:case te:{if(v(["point","band"],u)){const t=Gd(e,i,r.view);if(Os(t)){return{step:Hd(t,n,e)}}}const t=it(e),o=n.getName(t);return e===te&&xr(u)?[Fd.fromName(s,o),0]:[0,Fd.fromName(s,o)]}case re:case oe:return function(e,t,n){const i=e===re?"x":"y",r=t.getScaleComponent(i),o=r.get("type"),a=t.scaleName(i);if("band"===o){const e=Gd(i,t.size,t.config.view);if(Os(e)){const t=Vd(e,n);if(t)return t}return[0,{signal:`bandwidth('${a}')`}]}return d(`Cannot use ${e} scale if ${i} scale is not discrete.`)}(e,n,u);case ve:{const a=Yd(o,n.component.scales[e].get("zero"),r),s=function(e,n,i,r){const o={x:Ud(i,"x"),y:Ud(i,"y")};switch(e){case"bar":case"tick":{if(void 0!==r.scale.maxBandSize)return r.scale.maxBandSize;const e=Qd(n,o,r.view);return t.isNumber(e)?e-1:new Fd((()=>`${e.signal} - 1`))}case"line":case"trail":case"rule":return r.scale.maxStrokeWidth;case"text":return r.scale.maxFontSize;case"point":case"square":case"circle":{if(r.scale.maxSize)return r.scale.maxSize;const e=Qd(n,o,r.view);return t.isNumber(e)?Math.pow(Xd*e,2):new Fd((()=>`pow(${Xd} * ${e.signal}, 2)`))}}throw new Error(si("size",e))}(o,i,n,r);return $r(u)?function(e,t,n){const i=()=>{const i=Fn(t),r=Fn(e),o=`(${i} - ${r}) / (${n} - 1)`;return`sequence(${r}, ${i} + ${o}, ${o})`};return gn(t)?new Fd(i):{signal:i()}}(a,s,function(e,n,i,r){switch(e){case"quantile":return n.scale.quantileCount;case"quantize":return n.scale.quantizeCount;case"threshold":return void 0!==i&&t.isArray(i)?i.length+1:(Fi(function(e){return`Domain for ${e} is required for threshold scale.`}(r)),3)}}(u,r,f,e)):[a,s]}case le:return[0,2*Math.PI];case be:return[0,360];case ae:return[0,new Fd((()=>`min(${n.getSignalName("width")},${n.getSignalName("height")})/2`))];case ke:return[r.scale.minStrokeWidth,r.scale.maxStrokeWidth];case Se:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case ye:return"symbol";case me:case ge:case he:return"ordinal"===u?"nominal"===l?"category":"ordinal":void 0!==p?"diverging":"rect"===o||"geoshape"===o?"heatmap":"ramp";case xe:case we:case $e:return[r.scale.minOpacity,r.scale.maxOpacity]}}(e,n);return(void 0!==l||void 0!==c)&&Pr(o,"rangeMin")&&t.isArray(u)&&2===u.length?Gl([l??u[0],c??u[1]]):Yl(u)}function Bd(e){return function(e){return!t.isString(e)&&!!e.name}(e)?{scheme:e.name,...m(e,["name"])}:{scheme:e}}function Hd(e,n,i){const{encoding:r}=n,o=n.getScaleComponent(i),a=rt(i),s=r[a];if("offset"===Fs({step:e,offsetIsDiscrete:Yo(s)&&nr(s.type)})&&Aa(r,a)){const i=n.getScaleComponent(a);let r=`domain('${n.scaleName(a)}').length`;if("band"===i.get("type")){r=`bandspace(${r}, ${i.get("paddingInner")??i.get("padding")??0}, ${i.get("paddingOuter")??i.get("padding")??0})`}const s=o.get("paddingInner")??o.get("padding");return{signal:`${e.step} * ${r} / (1-${l=s,gn(l)?l.signal:t.stringValue(l)})`}}return e.step;var l}function Vd(e,t){if("offset"===Fs({step:e,offsetIsDiscrete:br(t)}))return{step:e.step}}function Gd(e,t,n){const i=e===ee?"width":"height",r=t[i];return r||Ps(n,i)}function Yd(e,t,n){if(t)return gn(t)?{signal:`${t.signal} ? 0 : ${Yd(e,!1,n)}`}:0;switch(e){case"bar":case"tick":return n.scale.minBandSize;case"line":case"trail":case"rule":return n.scale.minStrokeWidth;case"text":return n.scale.minFontSize;case"point":case"square":case"circle":return n.scale.minSize}throw new Error(si("size",e))}const Xd=.95;function Qd(e,t,n){const i=Os(e.width)?e.width.step:Ns(n,"width"),r=Os(e.height)?e.height.step:Ns(n,"height");return t.x||t.y?new Fd((()=>`min(${[t.x?t.x.signal:i,t.y?t.y.signal:r].join(", ")})`)):Math.min(i,r)}function Jd(e,t){op(e)?function(e,t){const n=e.component.scales,{config:i,encoding:r,markDef:o,specifiedScales:a}=e;for(const s of _(n)){const l=a[s],c=n[s],u=e.getScaleComponent(s),f=da(r[s]),d=l[t],p=u.get("type"),m=u.get("padding"),g=u.get("paddingInner"),h=Pr(p,t),y=Ar(s,t);if(void 0!==d&&(h?y&&Fi(y):Fi(gi(p,t,s))),h&&void 0===y)if(void 0!==d){const e=f.timeUnit,n=f.type;switch(t){case"domainMax":case"domainMin":Oi(l[t])||"temporal"===n||e?c.set(t,{signal:ba(l[t],{type:n,timeUnit:e})},!0):c.set(t,l[t],!0);break;default:c.copyKeyFromObject(t,l)}}else{const n=t in Kd?Kd[t]({model:e,channel:s,fieldOrDatumDef:f,scaleType:p,scalePadding:m,scalePaddingInner:g,domain:l.domain,domainMin:l.domainMin,domainMax:l.domainMax,markDef:o,config:i,hasNestedOffsetScale:ja(r,s),hasSecondaryRangeChannel:!!r[nt(s)]}):i.scale[t];void 0!==n&&c.set(t,n,!1)}}}(e,t):ep(e,t)}const Kd={bins:e=>{let{model:t,fieldOrDatumDef:n}=e;return Io(n)?function(e,t){const n=t.bin;if(an(n)){const i=Rf(e,t.field,n);return new Fd((()=>e.getSignalName(i)))}if(sn(n)&&ln(n)&&void 0!==n.step)return{step:n.step};return}(t,n):void 0},interpolate:e=>{let{channel:t,fieldOrDatumDef:n}=e;return function(e,t){if(v([me,ge,he],e)&&"nominal"!==t)return"hcl";return}(t,n.type)},nice:e=>{let{scaleType:n,channel:i,domain:r,domainMin:o,domainMax:a,fieldOrDatumDef:s}=e;return function(e,n,i,r,o,a){if(fa(a)?.bin||t.isArray(i)||null!=o||null!=r||v([lr.TIME,lr.UTC],e))return;return!!Dt(n)||void 0}(n,i,r,o,a,s)},padding:e=>{let{channel:t,scaleType:n,fieldOrDatumDef:i,markDef:r,config:o}=e;return function(e,t,n,i,r,o){if(Dt(e)){if(wr(t)){if(void 0!==n.continuousPadding)return n.continuousPadding;const{type:t,orient:a}=r;if("bar"===t&&(!Io(i)||!i.bin&&!i.timeUnit)&&("vertical"===a&&"x"===e||"horizontal"===a&&"y"===e))return o.continuousBandSize}if(t===lr.POINT)return n.pointPadding}return}(t,n,o.scale,i,r,o.bar)},paddingInner:e=>{let{scalePadding:t,channel:n,markDef:i,scaleType:r,config:o,hasNestedOffsetScale:a}=e;return function(e,t,n,i,r){let o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(void 0!==e)return;if(Dt(t)){const{bandPaddingInner:e,barBandPaddingInner:t,rectBandPaddingInner:i,bandWithNestedOffsetPaddingInner:a}=r;return o?a:B(e,"bar"===n?t:i)}if(Ct(t)&&i===lr.BAND)return r.offsetBandPaddingInner;return}(t,n,i.type,r,o.scale,a)},paddingOuter:e=>{let{scalePadding:t,channel:n,scaleType:i,scalePaddingInner:r,config:o,hasNestedOffsetScale:a}=e;return function(e,t,n,i,r){let o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(void 0!==e)return;if(Dt(t)){const{bandPaddingOuter:e,bandWithNestedOffsetPaddingOuter:t}=r;if(o)return t;if(n===lr.BAND)return B(e,gn(i)?{signal:`${i.signal}/2`}:i/2)}else if(Ct(t)){if(n===lr.POINT)return.5;if(n===lr.BAND)return r.offsetBandPaddingOuter}return}(t,n,i,r,o.scale,a)},reverse:e=>{let{fieldOrDatumDef:t,scaleType:n,channel:i,config:r}=e;return function(e,t,n,i){if("x"===n&&void 0!==i.xReverse)return xr(e)&&"descending"===t?gn(i.xReverse)?{signal:`!${i.xReverse.signal}`}:!i.xReverse:i.xReverse;if(xr(e)&&"descending"===t)return!0;return}(n,Io(t)?t.sort:void 0,i,r.scale)},zero:e=>{let{channel:n,fieldOrDatumDef:i,domain:r,markDef:o,scaleType:a,config:s,hasSecondaryRangeChannel:l}=e;return function(e,n,i,r,o,a,s){if(i&&"unaggregated"!==i&&xr(o)){if(t.isArray(i)){const e=i[0],t=i[i.length-1];if(e<=0&&t>=0)return!0}return!1}if("size"===e&&"quantitative"===n.type&&!$r(o))return!0;if((!Io(n)||!n.bin)&&v([...St,...Ot],e)){const{orient:t,type:n}=r;return(!v(["bar","area","line","trail"],n)||!("horizontal"===t&&"y"===e||"vertical"===t&&"x"===e))&&(!(!v(["bar","area"],n)||s)||a?.zero)}return!1}(n,i,r,o,a,s.scale,l)}};function Zd(e){op(e)?function(e){const t=e.component.scales;for(const n of Ut){const i=t[n];if(!i)continue;const r=Id(n,e);i.setWithExplicit("range",r)}}(e):ep(e,"range")}function ep(e,t){const n=e.component.scales;for(const n of e.children)"range"===t?Zd(n):Jd(n,t);for(const i of _(n)){let r;for(const n of e.children){const e=n.component.scales[i];if(e){r=Jl(r,e.getWithExplicit(t),t,"scale",Xl(((e,n)=>"range"===t&&e.step&&n.step?e.step-n.step:0)))}}n[i].setWithExplicit(t,r)}}function tp(e,t,n,i){const r=function(e,t,n,i){switch(t.type){case"nominal":case"ordinal":if(Le(e)||"discrete"===Yt(e))return"shape"===e&&"ordinal"===t.type&&Fi(fi(e,"ordinal")),"ordinal";if(Dt(e)||Ct(e)){if(v(["rect","bar","image","rule"],n.type))return"band";if(i)return"band"}else if("arc"===n.type&&e in Ft)return"band";return no(n[it(e)])||Ko(t)&&t.axis?.tickBand?"band":"point";case"temporal":return Le(e)?"time":"discrete"===Yt(e)?(Fi(fi(e,"temporal")),"ordinal"):Io(t)&&t.timeUnit&&Ui(t.timeUnit).utc?"utc":"time";case"quantitative":return Le(e)?Io(t)&&an(t.bin)?"bin-ordinal":"linear":"discrete"===Yt(e)?(Fi(fi(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(ii(t.type))}(t,n,i,arguments.length>4&&void 0!==arguments[4]&&arguments[4]),{type:o}=e;return It(t)?void 0!==o?function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!It(e))return!1;switch(e){case ee:case te:case re:case oe:case le:case ae:return!!wr(t)||"band"===t||"point"===t&&!n;case ve:case ke:case xe:case we:case $e:case be:return wr(t)||$r(t)||v(["band","point","ordinal"],t);case me:case ge:case he:return"band"!==t;case Se:case ye:return"ordinal"===t||$r(t)}}(t,o)?Io(n)&&(a=o,s=n.type,!(v([rr,ar],s)?void 0===a||br(a):s===or?v([lr.TIME,lr.UTC,void 0],a):s!==ir||gr(a)||$r(a)||void 0===a))?(Fi(function(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`}(o,r)),r):o:(Fi(function(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`}(t,o,r)),r):r:null;var a,s}function np(e){op(e)?e.component.scales=function(e){const{encoding:t,mark:n,markDef:i}=e,r={};for(const o of Ut){const a=da(t[o]);if(a&&n===Yr&&o===ye&&a.type===sr)continue;let s=a&&a.scale;if(Ct(o)){if(!ja(t,ot(o))){s&&Fi(li(o));continue}}if(a&&null!==s&&!1!==s){s??={};const n=tp(s,o,a,i,ja(t,o));r[o]=new Rd(e.scaleName(`${o}`,!0),{value:n,explicit:s.type===n})}}return r}(e):e.component.scales=function(e){const t=e.component.scales={},n={},i=e.component.resolve;for(const t of e.children){np(t);for(const r of _(t.component.scales))if(i.scale[r]??=mf(r,e),"shared"===i.scale[r]){const e=n[r],o=t.component.scales[r].getWithExplicit("type");e?ur(e.value,o.value)?n[r]=Jl(e,o,"type","scale",ip):(i.scale[r]="independent",delete n[r]):n[r]=o}}for(const i of _(n)){const r=e.scaleName(i,!0),o=n[i];t[i]=new Rd(r,o);for(const t of e.children){const e=t.component.scales[i];e&&(t.renameScale(e.get("name"),r),e.merged=!0)}}return t}(e)}const ip=Xl(((e,t)=>dr(e)-dr(t)));class rp{constructor(){Mn(this,"nameMap",void 0),this.nameMap={}}rename(e,t){this.nameMap[e]=t}has(e){return void 0!==this.nameMap[e]}get(e){for(;this.nameMap[e]&&e!==this.nameMap[e];)e=this.nameMap[e];return e}}function op(e){return"unit"===e?.type}function ap(e){return"facet"===e?.type}function sp(e){return"concat"===e?.type}function lp(e){return"layer"===e?.type}class cp{constructor(e,n,i,r,o,a,s){this.type=n,this.parent=i,this.config=o,Mn(this,"name",void 0),Mn(this,"size",void 0),Mn(this,"title",void 0),Mn(this,"description",void 0),Mn(this,"data",void 0),Mn(this,"transforms",void 0),Mn(this,"layout",void 0),Mn(this,"scaleNameMap",void 0),Mn(this,"projectionNameMap",void 0),Mn(this,"signalNameMap",void 0),Mn(this,"component",void 0),Mn(this,"view",void 0),Mn(this,"children",void 0),Mn(this,"correctDataNames",(e=>(e.from?.data&&(e.from.data=this.lookupDataSource(e.from.data)),e.from?.facet?.data&&(e.from.facet.data=this.lookupDataSource(e.from.facet.data)),e))),this.parent=i,this.config=o,this.view=dn(s),this.name=e.name??r,this.title=mn(e.title)?{text:e.title}:e.title?dn(e.title):void 0,this.scaleNameMap=i?i.scaleNameMap:new rp,this.projectionNameMap=i?i.projectionNameMap:new rp,this.signalNameMap=i?i.signalNameMap:new rp,this.data=e.data,this.description=e.description,this.transforms=(e.transform??[]).map((e=>gl(e)?{filter:c(e.filter,er)}:e)),this.layout="layer"===n||"unit"===n?{}:function(e,n,i){const r=i[n],o={},{spacing:a,columns:s}=r;void 0!==a&&(o.spacing=a),void 0!==s&&(jo(e)&&!Po(e.facet)||ks(e))&&(o.columns=s),Ss(e)&&(o.columns=1);for(const n of _s)if(void 0!==e[n])if("spacing"===n){const i=e[n];o[n]=t.isNumber(i)?i:{row:i.row??a,column:i.column??a}}else o[n]=e[n];return o}(e,n,o),this.component={data:{sources:i?i.component.data.sources:[],outputNodes:i?i.component.data.outputNodes:{},outputNodeRefCounts:i?i.component.data.outputNodeRefCounts:{},isFaceted:jo(e)||i?.component.data.isFaceted&&void 0===e.data},layoutSize:new Vl,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...a?f(a):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){!function(e){let{ignoreRange:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};np(e),Od(e);for(const t of Nr)Jd(e,t);t||Zd(e)}(this)}parseProjection(){Mf(this)}renameTopLevelLayoutSizeSignal(){"width"!==this.getName("width")&&this.renameSignal(this.getName("width"),"width"),"height"!==this.getName("height")&&this.renameSignal(this.getName("height"),"height")}parseLegends(){Of(this)}assembleEncodeFromView(e){const{style:t,...n}=e,i={};for(const e of _(n)){const t=n[e];void 0!==t&&(i[e]=Sn(t))}return i}assembleGroupEncodeEntry(e){let t={};return this.view&&(t=this.assembleEncodeFromView(this.view)),e||(this.description&&(t.description=Sn(this.description)),"unit"!==this.type&&"layer"!==this.type)?z(t)?void 0:t:{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),...t??{}}}assembleLayout(){if(!this.layout)return;const{spacing:e,...t}=this.layout,{component:n,config:i}=this,r=function(e,t){const n={};for(const i of Re){const r=e[i];if(r?.facetFieldDef){const{titleAnchor:e,titleOrient:o}=Yu(["titleAnchor","titleOrient"],r.facetFieldDef.header,t,i),a=Vu(i,o),s=af(e,a);void 0!==s&&(n[a]=s)}}return z(n)?void 0:n}(n.layoutHeaders,i);return{padding:e,...this.assembleDefaultLayout(),...t,...r?{titleBand:r}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:e}=this.component;let t=[];for(const n of Re)e[n].title&&t.push(Ju(this,n));for(const e of Xu)t=t.concat(ef(this,e));return t}assembleAxes(){return function(e,t){const{x:n=[],y:i=[]}=e;return[...n.map((e=>ju(e,"grid",t))),...i.map((e=>ju(e,"grid",t))),...n.map((e=>ju(e,"main",t))),...i.map((e=>ju(e,"main",t)))].filter((e=>e))}(this.component.axes,this.config)}assembleLegends(){return Pf(this)}assembleProjections(){return Af(this)}assembleTitle(){const{encoding:e,...t}=this.title??{},n={...pn(this.config.title).nonMarkTitleProperties,...t,...e?{encode:{update:e}}:{}};if(n.text)return v(["unit","layer"],this.type)?v(["middle",void 0],n.anchor)&&(n.frame??="group"):n.anchor??="start",z(n)?void 0:n}assembleGroup(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t={};e=e.concat(this.assembleSignals()),e.length>0&&(t.signals=e);const n=this.assembleLayout();n&&(t.layout=n),t.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const i=!this.parent||ap(this.parent)?Ld(this):[];i.length>0&&(t.scales=i);const r=this.assembleAxes();r.length>0&&(t.axes=r);const o=this.assembleLegends();return o.length>0&&(t.legends=o),t}getName(e){return A((this.name?`${this.name}_`:"")+e)}getDataName(e){return this.getName(ac[e].toLowerCase())}requestDataName(e){const t=this.getDataName(e),n=this.component.data.outputNodeRefCounts;return n[t]=(n[t]||0)+1,t}getSizeSignalRef(e){if(ap(this.parent)){const t=zt(df(e)),n=this.component.scales[t];if(n&&!n.merged){const e=n.get("type"),i=n.get("range");if(br(e)&&hn(i)){const e=n.get("name"),i=Td(Md(this,t));if(i){return{signal:ff(e,n,na({aggregate:"distinct",field:i},{expr:"datum"}))}}return Fi(Vn(t)),null}}}return{signal:this.signalNameMap.get(this.getName(e))}}lookupDataSource(e){const t=this.component.data.outputNodes[e];return t?t.getSource():e}getSignalName(e){return this.signalNameMap.get(e)}renameSignal(e,t){this.signalNameMap.rename(e,t)}renameScale(e,t){this.scaleNameMap.rename(e,t)}renameProjection(e,t){this.projectionNameMap.rename(e,t)}scaleName(e,t){return t?this.getName(e):Je(e)&&It(e)&&this.component.scales[e]||this.scaleNameMap.has(this.getName(e))?this.scaleNameMap.get(this.getName(e)):void 0}projectionName(e){return e?this.getName("projection"):this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName("projection"))?this.projectionNameMap.get(this.getName("projection")):void 0}getScaleComponent(e){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const t=this.component.scales[e];return t&&!t.merged?t:this.parent?this.parent.getScaleComponent(e):void 0}getSelectionComponent(e,t){let n=this.component.selection[e];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(e,t)),!n)throw new Error(function(e){return`Cannot find a selection named "${e}".`}(t));return n}hasAxisOrientSignalRef(){return this.component.axes.x?.some((e=>e.hasOrientSignalRef()))||this.component.axes.y?.some((e=>e.hasOrientSignalRef()))}}class up extends cp{vgField(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.fieldDef(e);if(n)return na(n,t)}reduceFieldDef(e,n){return function(e,n,i,r){return e?_(e).reduce(((i,o)=>{const a=e[o];return t.isArray(a)?a.reduce(((e,t)=>n.call(r,e,t,o)),i):n.call(r,i,a,o)}),i):i}(this.getMapping(),((t,n,i)=>{const r=fa(n);return r?e(t,r,i):t}),n)}forEachFieldDef(e,t){qa(this.getMapping(),((t,n)=>{const i=fa(t);i&&e(i,n)}),t)}}class fp extends dc{clone(){return new fp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=f(t);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??"value",n[1]??"density"],t.groupby&&null==t.minsteps&&null==t.maxsteps&&null==t.steps&&(this.transform.steps=200)}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${h(this.transform)}`}assemble(){const{density:e,...t}=this.transform;return{type:"kde",field:e,...t}}}class dp extends dc{clone(){return new dp(null,{...this.filter})}constructor(e,t){super(e),this.filter=t}static make(e,t){const{config:n,mark:i,markDef:r}=t;if("filter"!==_n("invalid",r,n))return null;const o=t.reduceFieldDef(((e,n,r)=>{const o=It(r)&&t.getScaleComponent(r);if(o){xr(o.get("type"))&&"count"!==n.aggregate&&!Xr(i)&&(e[n.field]=n)}return e}),{});return _(o).length?new dp(e,o):null}dependentFields(){return new Set(_(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${h(this.filter)}`}assemble(){const e=_(this.filter).reduce(((e,t)=>{const n=this.filter[t],i=na(n,{expr:"datum"});return null!==n&&("temporal"===n.type?e.push(`(isDate(${i}) || (isValid(${i}) && isFinite(+${i})))`):"quantitative"===n.type&&(e.push(`isValid(${i})`),e.push(`isFinite(+${i})`))),e}),[]);return e.length>0?{type:"filter",expr:e.join(" && ")}:null}}class pp extends dc{clone(){return new pp(this.parent,f(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=f(t);const{flatten:n,as:i=[]}=this.transform;this.transform.as=n.map(((e,t)=>i[t]??e))}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${h(this.transform)}`}assemble(){const{flatten:e,as:t}=this.transform;return{type:"flatten",fields:e,as:t}}}class mp extends dc{clone(){return new mp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=f(t);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??"key",n[1]??"value"]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${h(this.transform)}`}assemble(){const{fold:e,as:t}=this.transform;return{type:"fold",fields:e,as:t}}}class gp extends dc{clone(){return new gp(null,f(this.fields),this.geojson,this.signal)}static parseAll(e,t){if(t.component.projection&&!t.component.projection.isFit)return e;let n=0;for(const i of[[fe,ue],[pe,de]]){const r=i.map((e=>{const n=da(t.encoding[e]);return Io(n)?n.field:Ho(n)?{expr:`${n.datum}`}:Qo(n)?{expr:`${n.value}`}:void 0}));(r[0]||r[1])&&(e=new gp(e,r,null,t.getName("geojson_"+n++)))}if(t.channelHasField(ye)){const i=t.typedFieldDef(ye);i.type===sr&&(e=new gp(e,null,i.field,t.getName("geojson_"+n++)))}return e}constructor(e,t,n,i){super(e),this.fields=t,this.geojson=n,this.signal=i}dependentFields(){const e=(this.fields??[]).filter(t.isString);return new Set([...this.geojson?[this.geojson]:[],...e])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${h(this.fields)}`}assemble(){return[...this.geojson?[{type:"filter",expr:`isValid(datum["${this.geojson}"])`}]:[],{type:"geojson",...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}}class hp extends dc{clone(){return new hp(null,this.projection,f(this.fields),f(this.as))}constructor(e,t,n,i){super(e),this.projection=t,this.fields=n,this.as=i}static parseAll(e,t){if(!t.projectionName())return e;for(const n of[[fe,ue],[pe,de]]){const i=n.map((e=>{const n=da(t.encoding[e]);return Io(n)?n.field:Ho(n)?{expr:`${n.datum}`}:Qo(n)?{expr:`${n.value}`}:void 0})),r=n[0]===pe?"2":"";(i[0]||i[1])&&(e=new hp(e,t.projectionName(),i,[t.getName(`x${r}`),t.getName(`y${r}`)]))}return e}dependentFields(){return new Set(this.fields.filter(t.isString))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${h(this.fields)} ${h(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class yp extends dc{clone(){return new yp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(e){const{start:t=0,stop:n,step:i}=e;return{signal:`sequence(${[t,n,...i?[i]:[]].join(",")})`}}static makeFromTransform(e,t){return new yp(e,t)}static makeFromEncoding(e,t){const n=t.encoding,i=n.x,r=n.y;if(Io(i)&&Io(r)){const o=i.impute?i:r.impute?r:void 0;if(void 0===o)return;const a=i.impute?r:r.impute?i:void 0,{method:s,value:l,frame:c,keyvals:u}=o.impute,f=Ra(t.mark,n);return new yp(e,{impute:o.field,key:a.field,...s?{method:s}:{},...void 0!==l?{value:l}:{},...c?{frame:c}:{},...void 0!==u?{keyvals:u}:{},...f.length?{groupby:f}:{}})}return null}hash(){return`Impute ${h(this.transform)}`}assemble(){const{impute:e,key:t,keyvals:n,method:i,groupby:r,value:o,frame:a=[null,null]}=this.transform,s={type:"impute",field:e,key:t,...n?{keyvals:(l=n,void 0!==l?.stop?this.processSequence(n):n)}:{},method:"value",...r?{groupby:r}:{},value:i&&"value"!==i?null:o};var l;if(i&&"value"!==i){return[s,{type:"window",as:[`imputed_${e}_value`],ops:[i],fields:[e],frame:a,ignorePeers:!1,...r?{groupby:r}:{}},{type:"formula",expr:`datum.${e} === null ? datum.imputed_${e}_value : datum.${e}`,as:e}]}return[s]}}class vp extends dc{clone(){return new vp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=f(t);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??t.on,n[1]??t.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${h(this.transform)}`}assemble(){const{loess:e,on:t,...n}=this.transform;return{type:"loess",x:t,y:e,...n}}}class bp extends dc{clone(){return new bp(null,f(this.transform),this.secondary)}constructor(e,t,n){super(e),this.transform=t,this.secondary=n}static make(e,t,n,i){const r=t.component.data.sources,{from:o}=n;let a=null;if(function(e){return"data"in e}(o)){let e=jp(o.data,r);e||(e=new Zf(o.data),r.push(e));const n=t.getName(`lookup_${i}`);a=new pc(e,n,ac.Lookup,t.component.data.outputNodeRefCounts),t.component.data.outputNodes[n]=a}else if(function(e){return"param"in e}(o)){const e=o.param;let i;n={as:e,...n};try{i=t.getSelectionComponent(A(e),e)}catch(t){throw new Error(function(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}(e))}if(a=i.materialized,!a)throw new Error(function(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}(e))}return new bp(e,n,a.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?t.array(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${h({transform:this.transform,secondary:this.secondary})}`}assemble(){let e;if(this.transform.from.fields)e={values:this.transform.from.fields,...this.transform.as?{as:t.array(this.transform.as)}:{}};else{let n=this.transform.as;t.isString(n)||(Fi('If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.'),n="_lookup"),e={as:[n]}}return{type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...e,...this.transform.default?{default:this.transform.default}:{}}}}class xp extends dc{clone(){return new xp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=f(t);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??"prob",n[1]??"value"]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${h(this.transform)}`}assemble(){const{quantile:e,...t}=this.transform;return{type:"quantile",field:e,...t}}}class wp extends dc{clone(){return new wp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t,this.transform=f(t);const n=this.transform.as??[void 0,void 0];this.transform.as=[n[0]??t.on,n[1]??t.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${h(this.transform)}`}assemble(){const{regression:e,on:t,...n}=this.transform;return{type:"regression",x:t,y:e,...n}}}class $p extends dc{clone(){return new $p(null,f(this.transform))}constructor(e,t){super(e),this.transform=t}addDimensions(e){this.transform.groupby=k((this.transform.groupby??[]).concat(e),(e=>e))}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${h(this.transform)}`}assemble(){const{pivot:e,value:t,groupby:n,limit:i,op:r}=this.transform;return{type:"pivot",field:e,value:t,...void 0!==i?{limit:i}:{},...void 0!==r?{op:r}:{},...void 0!==n?{groupby:n}:{}}}}class kp extends dc{clone(){return new kp(null,f(this.transform))}constructor(e,t){super(e),this.transform=t}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${h(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function Sp(e){let t=0;return function n(i,r){if(i instanceof Zf&&!i.isGenerator&&!Zl(i.data)){e.push(r);r={name:null,source:r.name,transform:[]}}if(i instanceof Xf&&(i.parent instanceof Zf&&!r.source?(r.format={...r.format??{},parse:i.assembleFormatParse()},r.transform.push(...i.assembleTransforms(!0))):r.transform.push(...i.assembleTransforms())),i instanceof Hf)return r.name||(r.name="data_"+t++),!r.source||r.transform.length>0?(e.push(r),i.data=r.name):i.data=r.source,void e.push(...i.assemble());if((i instanceof Jf||i instanceof Kf||i instanceof dp||i instanceof _u||i instanceof Bu||i instanceof hp||i instanceof Bf||i instanceof bp||i instanceof vd||i instanceof hd||i instanceof mp||i instanceof pp||i instanceof fp||i instanceof vp||i instanceof xp||i instanceof wp||i instanceof Qf||i instanceof kp||i instanceof $p)&&r.transform.push(i.assemble()),(i instanceof Uf||i instanceof mc||i instanceof yp||i instanceof yd||i instanceof gp)&&r.transform.push(...i.assemble()),i instanceof pc)if(r.source&&0===r.transform.length)i.setSource(r.source);else if(i.parent instanceof pc)i.setSource(r.name);else if(r.name||(r.name="data_"+t++),i.setSource(r.name),1===i.numChildren()){e.push(r);r={name:null,source:r.name,transform:[]}}switch(i.numChildren()){case 0:i instanceof pc&&(!r.source||r.transform.length>0)&&e.push(r);break;case 1:n(i.children[0],r);break;default:{r.name||(r.name="data_"+t++);let o=r.name;!r.source||r.transform.length>0?e.push(r):o=r.source;for(const e of i.children){n(e,{name:null,source:o,transform:[]})}break}}}}function Dp(e){return"top"===e||"left"===e||gn(e)?"header":"footer"}function Fp(e,n){const{facet:i,config:r,child:o,component:a}=e;if(e.channelHasField(n)){const s=i[n],l=Gu("title",null,r,n);let c=sa(s,r,{allowDisabling:!0,includeDefault:void 0===l||!!l});o.component.layoutHeaders[n].title&&(c=t.isArray(c)?c.join(", "):c,c+=` / ${o.component.layoutHeaders[n].title}`,o.component.layoutHeaders[n].title=null);const u=Gu("labelOrient",s.header,r,n),f=null!==s.header&&B(s.header?.labels,r.header.labels,!0),d=v(["bottom","right"],u)?"footer":"header";a.layoutHeaders[n]={title:null!==s.header?c:null,facetFieldDef:s,[d]:"facet"===n?[]:[Op(e,n,f)]}}}function Op(e,t,n){const i="row"===t?"height":"width";return{labels:n,sizeSignal:e.child.component.layoutSize.get(i)?e.child.getSizeSignalRef(i):void 0,axes:[]}}function zp(e,t){const{child:n}=e;if(n.component.axes[t]){const{layoutHeaders:i,resolve:r}=e.component;if(r.axis[t]=gf(r,t),"shared"===r.axis[t]){const r="x"===t?"column":"row",o=i[r];for(const i of n.component.axes[t]){const t=Dp(i.get("orient"));o[t]??=[Op(e,r,!1)];const n=ju(i,"main",e.config,{header:!0});n&&o[t][0].axes.push(n),i.mainExtracted=!0}}}}function _p(e){for(const t of e.children)t.parseLayoutSize()}function Cp(e,t){const n=df(t),i=zt(n),r=e.component.resolve,o=e.component.layoutSize;let a;for(const t of e.children){const o=t.component.layoutSize.getWithExplicit(n),s=r.scale[i]??mf(i,e);if("independent"===s&&"step"===o.value){a=void 0;break}if(a){if("independent"===s&&a.value!==o.value){a=void 0;break}a=Jl(a,o,n,"")}else a=o}if(a){for(const i of e.children)e.renameSignal(i.getName(n),e.getName(t)),i.component.layoutSize.set(n,"merged",!1);o.setWithExplicit(t,a)}else o.setWithExplicit(t,{explicit:!1,value:void 0})}function Np(e,t){const n="width"===t?"x":"y",i=e.config,r=e.getScaleComponent(n);if(r){const e=r.get("type"),n=r.get("range");if(br(e)){const e=Ps(i.view,t);return hn(n)||Os(e)?"step":e}return Cs(i.view,t)}if(e.hasProjection||"arc"===e.mark)return Cs(i.view,t);{const e=Ps(i.view,t);return Os(e)?e.step:e}}function Pp(e,t,n){return na(t,{suffix:`by_${na(e)}`,...n??{}})}class Ap extends up{constructor(e,t,n,i){super(e,"facet",t,n,i,e.resolve),Mn(this,"facet",void 0),Mn(this,"child",void 0),Mn(this,"children",void 0),this.child=sm(e.spec,this,this.getName("child"),void 0,i),this.children=[this.child],this.facet=this.initFacet(e.facet)}initFacet(e){if(!Po(e))return{facet:this.initFacetFieldDef(e,"facet")};const t=_(e),n={};for(const i of t){if(![J,K].includes(i)){Fi(si(i,"facet"));break}const t=e[i];if(void 0===t.field){Fi(oi(t,i));break}n[i]=this.initFacetFieldDef(t,i)}return n}initFacetFieldDef(e,t){const n=ga(e,t);return n.header?n.header=dn(n.header):null===n.header&&(n.header=null),n}channelHasField(e){return!!this.facet[e]}fieldDef(e){return this.facet[e]}parseData(){this.component.data=Ep(this),this.child.parseData()}parseLayoutSize(){_p(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),function(e){for(const t of Re)Fp(e,t);zp(e,"x"),zp(e,"y")}(this)}assembleSelectionTopLevelSignals(e){return this.child.assembleSelectionTopLevelSignals(e)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(e){return this.child.assembleSelectionData(e)}getHeaderLayoutMixins(){const e={};for(const t of Re)for(const n of Qu){const i=this.component.layoutHeaders[t],r=i[n],{facetFieldDef:o}=i;if(o){const n=Gu("titleOrient",o.header,this.config,t);if(["right","bottom"].includes(n)){const i=Vu(t,n);e.titleAnchor??={},e.titleAnchor[i]="end"}}if(r?.[0]){const r="row"===t?"height":"width",o="header"===n?"headerBand":"footerBand";"facet"===t||this.child.component.layoutSize.get(r)||(e[o]??={},e[o][t]=.5),i.title&&(e.offset??={},e.offset["row"===t?"rowTitle":"columnTitle"]=10)}}return e}assembleDefaultLayout(){const{column:e,row:t}=this.facet,n=e?this.columnDistinctSignal():t?1:void 0;let i="all";return(t||"independent"!==this.component.resolve.scale.x)&&(e||"independent"!==this.component.resolve.scale.y)||(i="none"),{...this.getHeaderLayoutMixins(),...n?{columns:n}:{},bounds:"full",align:i}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof Ap)){return{signal:`length(data('${this.getName("column_domain")}'))`}}}assembleGroupStyle(){}assembleGroup(e){return this.parent&&this.parent instanceof Ap?{...this.channelHasField("column")?{encode:{update:{columns:{field:na(this.facet.column,{prefix:"distinct"})}}}}:{},...super.assembleGroup(e)}:super.assembleGroup(e)}getCardinalityAggregateForChild(){const e=[],t=[],n=[];if(this.child instanceof Ap){if(this.child.channelHasField("column")){const i=na(this.child.facet.column);e.push(i),t.push("distinct"),n.push(`distinct_${i}`)}}else for(const i of St){const r=this.child.component.scales[i];if(r&&!r.merged){const o=r.get("type"),a=r.get("range");if(br(o)&&hn(a)){const r=Td(Md(this.child,i));r?(e.push(r),t.push("distinct"),n.push(`distinct_${r}`)):Fi(Vn(i))}}}return{fields:e,ops:t,as:n}}assembleFacet(){const{name:e,data:n}=this.component.data.facetRoot,{row:i,column:r}=this.facet,{fields:o,ops:a,as:s}=this.getCardinalityAggregateForChild(),l=[];for(const e of Re){const n=this.facet[e];if(n){l.push(na(n));const{bin:c,sort:u}=n;if(an(c)&&l.push(na(n,{binSuffix:"end"})),Co(u)){const{field:e,op:t=Fo}=u,l=Pp(n,u);i&&r?(o.push(l),a.push("max"),s.push(l)):(o.push(e),a.push(t),s.push(l))}else if(t.isArray(u)){const t=Hu(n,e);o.push(t),a.push("max"),s.push(t)}}}const c=!!i&&!!r;return{name:e,data:n,groupby:l,...c||o.length>0?{aggregate:{...c?{cross:c}:{},...o.length?{fields:o,ops:a,as:s}:{}}}:{}}}facetSortFields(e){const{facet:n}=this,i=n[e];return i?Co(i.sort)?[Pp(i,i.sort,{expr:"datum"})]:t.isArray(i.sort)?[Hu(i,e,{expr:"datum"})]:[na(i,{expr:"datum"})]:[]}facetSortOrder(e){const{facet:n}=this,i=n[e];if(i){const{sort:e}=i;return[(Co(e)?e.order:!t.isArray(e)&&e)||"ascending"]}return[]}assembleLabelTitle(){const{facet:e,config:t}=this;if(e.facet)return nf(e.facet,"facet",t);const n={row:["top","bottom"],column:["left","right"]};for(const i of Xu)if(e[i]){const r=Gu("labelOrient",e[i]?.header,t,i);if(n[i].includes(r))return nf(e[i],i,t)}}assembleMarks(){const{child:e}=this,t=function(e){const t=[],n=Sp(t);for(const t of e.children)n(t,{source:e.name,name:null,transform:[]});return t}(this.component.data.facetRoot),n=e.assembleGroupEncodeEntry(!1),i=this.assembleLabelTitle()||e.assembleTitle(),r=e.assembleGroupStyle();return[{name:this.getName("cell"),type:"group",...i?{title:i}:{},...r?{style:r}:{},from:{facet:this.assembleFacet()},sort:{field:Re.map((e=>this.facetSortFields(e))).flat(),order:Re.map((e=>this.facetSortOrder(e))).flat()},...t.length>0?{data:t}:{},...n?{encode:{update:n}}:{},...e.assembleGroup(cc(this,[]))}]}getMapping(){return this.facet}}function jp(e,t){for(const n of t){const t=n.data;if(e.name&&n.hasName()&&e.name!==n.dataName)continue;const i=e.format?.mesh,r=t.format?.feature;if(i&&r)continue;const o=e.format?.feature;if((o||r)&&o!==r)continue;const a=t.format?.mesh;if(!i&&!a||i===a)if(ec(e)&&ec(t)){if(u(e.values,t.values))return n}else if(Zl(e)&&Zl(t)){if(e.url===t.url)return n}else if(tc(e)&&e.name===n.dataName)return n}return null}function Ep(e){let t=function(e,t){if(e.data||!e.parent){if(null===e.data){const e=new Zf({values:[]});return t.push(e),e}const n=jp(e.data,t);if(n)return nc(e.data)||(n.data.format=w({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const n=new Zf(e.data);return t.push(n),n}}return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}(e,e.component.data.sources);const{outputNodes:n,outputNodeRefCounts:i}=e.component.data,r=e.data,o=!(r&&(nc(r)||Zl(r)||ec(r)))&&e.parent?e.parent.component.data.ancestorParse.clone():new Kl;nc(r)?(ic(r)?t=new Kf(t,r.sequence):oc(r)&&(t=new Jf(t,r.graticule)),o.parseNothing=!0):null===r?.format?.parse&&(o.parseNothing=!0),t=Xf.makeExplicit(t,e,o)??t,t=new Qf(t);const a=e.parent&&lp(e.parent);(op(e)||ap(e))&&a&&(t=Uf.makeFromEncoding(t,e)??t),e.transforms.length>0&&(t=function(e,t,n){let i=0;for(const r of t.transforms){let o,a;if(Fl(r))a=e=new Bu(e,r),o="derived";else if(gl(r)){const i=Gf(r);a=e=Xf.makeWithAncestors(e,{},i,n)??e,e=new _u(e,t,r.filter)}else if(Ol(r))a=e=Uf.makeFromTransform(e,r,t),o="number";else if(_l(r))o="date",void 0===n.getWithExplicit(r.field).value&&(e=new Xf(e,{[r.field]:o}),n.set(r.field,o,!1)),a=e=mc.makeFromTransform(e,r);else if(Cl(r))a=e=Bf.makeFromTransform(e,r),o="number",Su(t)&&(e=new Qf(e));else if(hl(r))a=e=bp.make(e,t,r,i++),o="derived";else if(kl(r))a=e=new vd(e,r),o="number";else if(Sl(r))a=e=new hd(e,r),o="number";else if(Nl(r))a=e=yd.makeFromTransform(e,r),o="derived";else if(Pl(r))a=e=new mp(e,r),o="derived";else if(Dl(r))a=e=new pp(e,r),o="derived";else if(yl(r))a=e=new $p(e,r),o="derived";else if($l(r))e=new kp(e,r);else if(zl(r))a=e=yp.makeFromTransform(e,r),o="derived";else if(vl(r))a=e=new fp(e,r),o="derived";else if(bl(r))a=e=new xp(e,r),o="derived";else if(xl(r))a=e=new wp(e,r),o="derived";else{if(!wl(r)){Fi(`Ignoring an invalid transform: ${g(r)}.`);continue}a=e=new vp(e,r),o="derived"}if(a&&void 0!==o)for(const e of a.producedFields()??[])n.set(e,o,!1)}return e}(t,e,o));const s=function(e){const t={};if(op(e)&&e.component.selection)for(const n of _(e.component.selection)){const i=e.component.selection[n];for(const e of i.project.items)!e.channel&&I(e.field)>1&&(t[e.field]="flatten")}return t}(e),l=Yf(e);t=Xf.makeWithAncestors(t,{},{...s,...l},o)??t,op(e)&&(t=gp.parseAll(t,e),t=hp.parseAll(t,e)),(op(e)||ap(e))&&(a||(t=Uf.makeFromEncoding(t,e)??t),t=mc.makeFromEncoding(t,e)??t,t=Bu.parseAllForSortIndex(t,e));const c=e.getDataName(ac.Raw),u=new pc(t,c,ac.Raw,i);if(n[c]=u,t=u,op(e)){const n=Bf.makeFromEncoding(t,e);n&&(t=n,Su(e)&&(t=new Qf(t))),t=yp.makeFromEncoding(t,e)??t,t=yd.makeFromEncoding(t,e)??t}op(e)&&(t=dp.make(t,e)??t);const f=e.getDataName(ac.Main),d=new pc(t,f,ac.Main,i);n[f]=d,t=d,op(e)&&function(e,t){for(const[n,i]of N(e.component.selection??{})){const r=e.getName(`lookup_${n}`);e.component.data.outputNodes[r]=i.materialized=new pc(new _u(t,e,{param:n}),r,ac.Lookup,e.component.data.outputNodeRefCounts)}}(e,d);let p=null;if(ap(e)){const i=e.getName("facet");t=function(e,t){const{row:n,column:i}=t;if(n&&i){let t=null;for(const r of[n,i])if(Co(r.sort)){const{field:n,op:i=Fo}=r.sort;e=t=new hd(e,{joinaggregate:[{op:i,field:n,as:Pp(r,r.sort,{forAs:!0})}],groupby:[na(r)]})}return t}return null}(t,e.facet)??t,p=new Hf(t,e,i,d.getSource()),n[i]=p}return{...e.component.data,outputNodes:n,outputNodeRefCounts:i,raw:u,main:d,facetRoot:p,ancestorParse:o}}class Tp extends cp{constructor(e,t,n,i){super(e,"concat",t,n,i,e.resolve),Mn(this,"children",void 0),"shared"!==e.resolve?.axis?.x&&"shared"!==e.resolve?.axis?.y||Fi("Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415)."),this.children=this.getChildren(e).map(((e,t)=>sm(e,this,this.getName(`concat_${t}`),void 0,i)))}parseData(){this.component.data=Ep(this);for(const e of this.children)e.parseData()}parseSelections(){this.component.selection={};for(const e of this.children){e.parseSelections();for(const t of _(e.component.selection))this.component.selection[t]=e.component.selection[t]}}parseMarkGroup(){for(const e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){for(const e of this.children)e.parseAxesAndHeaders()}getChildren(e){return Ss(e)?e.vconcat:Ds(e)?e.hconcat:e.concat}parseLayoutSize(){!function(e){_p(e);const t=1===e.layout.columns?"width":"childWidth",n=void 0===e.layout.columns?"height":"childHeight";Cp(e,t),Cp(e,n)}(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(e){return this.children.reduce(((e,t)=>t.assembleSelectionTopLevelSignals(e)),e)}assembleSignals(){return this.children.forEach((e=>e.assembleSignals())),[]}assembleLayoutSignals(){const e=lf(this);for(const t of this.children)e.push(...t.assembleLayoutSignals());return e}assembleSelectionData(e){return this.children.reduce(((e,t)=>t.assembleSelectionData(e)),e)}assembleMarks(){return this.children.map((e=>{const t=e.assembleTitle(),n=e.assembleGroupStyle(),i=e.assembleGroupEncodeEntry(!1);return{type:"group",name:e.getName("group"),...t?{title:t}:{},...n?{style:n}:{},...i?{encode:{update:i}}:{},...e.assembleGroup()}}))}assembleGroupStyle(){}assembleDefaultLayout(){const e=this.layout.columns;return{...null!=e?{columns:e}:{},bounds:"full",align:"each"}}}const Mp={disable:1,gridScale:1,scale:1,...Fa,labelExpr:1,encode:1},Lp=_(Mp);class qp extends Vl{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];super(),this.explicit=e,this.implicit=t,this.mainExtracted=n}clone(){return new qp(f(this.explicit),f(this.implicit),this.mainExtracted)}hasAxisPart(e){return"axis"===e||("grid"===e||"title"===e?!!this.get(e):!(!1===(t=this.get(e))||null===t));var t}hasOrientSignalRef(){return gn(this.explicit.orient)}}const Rp={bottom:"top",top:"bottom",left:"right",right:"left"};function Wp(e,t){if(!e)return t.map((e=>e.clone()));{if(e.length!==t.length)return;const n=e.length;for(let i=0;i{switch(n){case"title":return Tn(e,t);case"gridScale":return{explicit:e.explicit,value:B(e.value,t.value)}}return Ql(e,t,n,"axis")}));e.setWithExplicit(n,i)}return e}function Ip(e,t,n,i,r){if("disable"===t)return void 0!==n;switch(n=n||{},t){case"titleAngle":case"labelAngle":return e===(gn(n.labelAngle)?n.labelAngle:X(n.labelAngle));case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===Iu(i,r))return!0}return e===n[t]}const Bp=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function Hp(e,t){let n=t.axis(e);const i=new qp,r=da(t.encoding[e]),{mark:o,config:a}=t,s=n?.orient||a["x"===e?"axisX":"axisY"]?.orient||a.axis?.orient||function(e){return"x"===e?"bottom":"left"}(e),l=t.getScaleComponent(e).get("type"),c=function(e,t,n,i){const r="band"===t?["axisDiscrete","axisBand"]:"point"===t?["axisDiscrete","axisPoint"]:gr(t)?["axisQuantitative"]:"time"===t||"utc"===t?["axisTemporal"]:[],o="x"===e?"axisX":"axisY",a=gn(n)?"axisOrient":`axis${T(n)}`,s=[...r,...r.map((e=>o+e.substr(4)))],l=["axis",a,o];return{vlOnlyAxisConfig:Tu(s,i,e,n),vgAxisConfig:Tu(l,i,e,n),axisConfigStyle:Mu([...l,...s],i)}}(e,l,s,t.config),u=void 0!==n?!n:Lu("disable",a.style,n?.style,c).configValue;if(i.set("disable",u,void 0!==n),u)return i;n=n||{};const f=function(e,t,n,i,r){const o=t?.labelAngle;if(void 0!==o)return gn(o)?o:X(o);{const{configValue:o}=Lu("labelAngle",i,t?.style,r);return void 0!==o?X(o):n!==ee||!v([ar,rr],e.type)||Io(e)&&e.timeUnit?void 0:270}}(r,n,e,a.style,c),d={fieldOrDatumDef:r,axis:n,channel:e,model:t,scaleType:l,orient:s,labelAngle:f,mark:o,config:a};for(const r of Lp){const o=r in qu?qu[r](d):za(r)?n[r]:void 0,s=void 0!==o,l=Ip(o,r,n,t,e);if(s&&l)i.set(r,o,l);else{const{configValue:e,configFrom:t}=za(r)&&"values"!==r?Lu(r,a.style,n.style,c):{},u=void 0!==e;s&&!u?i.set(r,o,l):("vgAxisConfig"!==t||Bp.has(r)&&u||ka(e)||gn(e))&&i.set(r,e,!1)}}const p=n.encoding??{},m=Sa.reduce(((n,r)=>{if(!i.hasAxisPart(r))return n;const o=pf(p[r]??{},t),a="labels"===r?function(e,t,n){const{encoding:i,config:r}=e,o=da(i[t])??da(i[nt(t)]),a=e.axis(t)||{},{format:s,formatType:l}=a;if(mo(l))return{text:bo({fieldOrDatumDef:o,field:"datum.value",format:s,formatType:l,config:r}),...n};if(void 0===s&&void 0===l&&r.customFormatTypes){if("quantitative"===Bo(o)){if(Ko(o)&&"normalize"===o.stack&&r.normalizedNumberFormatType)return{text:bo({fieldOrDatumDef:o,field:"datum.value",format:r.normalizedNumberFormat,formatType:r.normalizedNumberFormatType,config:r}),...n};if(r.numberFormatType)return{text:bo({fieldOrDatumDef:o,field:"datum.value",format:r.numberFormat,formatType:r.numberFormatType,config:r}),...n}}if("temporal"===Bo(o)&&r.timeFormatType&&Io(o)&&!o.timeUnit)return{text:bo({fieldOrDatumDef:o,field:"datum.value",format:r.timeFormat,formatType:r.timeFormatType,config:r}),...n}}return n}(t,e,o):o;return void 0===a||z(a)||(n[r]={update:a}),n}),{});return z(m)||i.set("encode",m,!!n.encoding||void 0!==n.labelAngle),i}function Vp(e,t,n){const i=dn(e),r=_n("orient",i,n);if(i.orient=function(e,t,n){switch(e){case Rr:case Vr:case Gr:case Ir:case Wr:case Lr:return}const{x:i,y:r,x2:o,y2:a}=t;switch(e){case Mr:if(Io(i)&&(sn(i.bin)||Io(r)&&r.aggregate&&!i.aggregate))return"vertical";if(Io(r)&&(sn(r.bin)||Io(i)&&i.aggregate&&!r.aggregate))return"horizontal";if(a||o){if(n)return n;if(!o)return(Io(i)&&i.type===ir&&!an(i.bin)||Go(i))&&Io(r)&&sn(r.bin)?"horizontal":"vertical";if(!a)return(Io(r)&&r.type===ir&&!an(r.bin)||Go(r))&&Io(i)&&sn(i.bin)?"vertical":"horizontal"}case Ur:if(o&&(!Io(i)||!sn(i.bin))&&a&&(!Io(r)||!sn(r.bin)))return;case Tr:if(a)return Io(r)&&sn(r.bin)?"horizontal":"vertical";if(o)return Io(i)&&sn(i.bin)?"vertical":"horizontal";if(e===Ur){if(i&&!r)return"vertical";if(r&&!i)return"horizontal"}case qr:case Br:{const t=Vo(i),o=Vo(r);if(n)return n;if(t&&!o)return"tick"!==e?"horizontal":"vertical";if(!t&&o)return"tick"!==e?"vertical":"horizontal";if(t&&o){const t=i,n=r,o=t.type===or,a=n.type===or;return o&&!a?"tick"!==e?"vertical":"horizontal":!o&&a?"tick"!==e?"horizontal":"vertical":!t.aggregate&&n.aggregate?"tick"!==e?"vertical":"horizontal":t.aggregate&&!n.aggregate&&"tick"!==e?"horizontal":"vertical"}return}}return"vertical"}(i.type,t,r),void 0!==r&&r!==i.orient&&Fi(`Specified orient "${i.orient}" overridden with "${r}".`),"bar"===i.type&&i.orient){const e=_n("cornerRadiusEnd",i,n);if(void 0!==e){const n="horizontal"===i.orient&&t.x2||"vertical"===i.orient&&t.y2?["cornerRadius"]:io[i.orient];for(const t of n)i[t]=e;void 0!==i.cornerRadiusEnd&&delete i.cornerRadiusEnd}}void 0===_n("opacity",i,n)&&(i.opacity=function(e,t){if(v([Rr,Br,Vr,Gr],e)&&!Ea(t))return.7;return}(i.type,t));return void 0===_n("cursor",i,n)&&(i.cursor=function(e,t,n){if(t.href||e.href||_n("href",e,n))return"pointer";return e.cursor}(i,t,n)),i}function Gp(e,t){const{config:n}=e;return{...Kc(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...qc("x",e,{defaultPos:"mid"}),...qc("y",e,{defaultPos:"mid"}),...Ec("size",e),...Ec("angle",e),...Yp(e,n,t)}}function Yp(e,t,n){return n?{shape:{value:n}}:Ec("shape",e)}const Xp={vgMark:"rule",encodeEntry:e=>{const{markDef:t}=e,n=t.orient;return e.encoding.x||e.encoding.y||e.encoding.latitude||e.encoding.longitude?{...Kc(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Bc("x",e,{defaultPos:"horizontal"===n?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:"vertical"!==n}),...Bc("y",e,{defaultPos:"vertical"===n?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:"horizontal"!==n}),...Ec("size",e,{vgChannel:"strokeWidth"})}:{}}};function Qp(e,t,n){if(void 0===_n("align",e,n))return"center"}function Jp(e,t,n){if(void 0===_n("baseline",e,n))return"middle"}const Kp={vgMark:"rect",encodeEntry:e=>{const{config:t,markDef:n}=e,i=n.orient,r="horizontal"===i?"width":"height",o="horizontal"===i?"height":"width";return{...Kc(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...qc("x",e,{defaultPos:"mid",vgChannel:"xc"}),...qc("y",e,{defaultPos:"mid",vgChannel:"yc"}),...Ec("size",e,{defaultValue:Zp(e),vgChannel:r}),[o]:Sn(_n("thickness",n,t))}}};function Zp(e){const{config:n,markDef:i}=e,{orient:r}=i,o="horizontal"===r?"width":"height",a=e.getScaleComponent("horizontal"===r?"x":"y"),s=_n("size",i,n,{vgChannel:o})??n.tick.bandSize;if(void 0!==s)return s;{const e=a?a.get("range"):void 0;if(e&&hn(e)&&t.isNumber(e.step))return 3*e.step/4;return 3*Ns(n.view,o)/4}}const em={arc:{vgMark:"arc",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...qc("x",e,{defaultPos:"mid"}),...qc("y",e,{defaultPos:"mid"}),...Gc(e,"radius"),...Gc(e,"theta")})},area:{vgMark:"area",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"}),...Bc("x",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"horizontal"===e.markDef.orient}),...Bc("y",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"vertical"===e.markDef.orient}),...tu(e)})},bar:{vgMark:"rect",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Gc(e,"x"),...Gc(e,"y")})},circle:{vgMark:"symbol",encodeEntry:e=>Gp(e,"circle")},geoshape:{vgMark:"shape",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})}),postEncodingTransform:e=>{const{encoding:t}=e,n=t.shape;return[{type:"geoshape",projection:e.projectionName(),...n&&Io(n)&&n.type===sr?{field:na(n,{expr:"datum"})}:{}}]}},image:{vgMark:"image",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...Gc(e,"x"),...Gc(e,"y"),...Oc(e,"url")})},line:{vgMark:"line",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...qc("x",e,{defaultPos:"mid"}),...qc("y",e,{defaultPos:"mid"}),...Ec("size",e,{vgChannel:"strokeWidth"}),...tu(e)})},point:{vgMark:"symbol",encodeEntry:e=>Gp(e)},rect:{vgMark:"rect",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Gc(e,"x"),...Gc(e,"y")})},rule:Xp,square:{vgMark:"symbol",encodeEntry:e=>Gp(e,"square")},text:{vgMark:"text",encodeEntry:e=>{const{config:t,encoding:n}=e;return{...Kc(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...qc("x",e,{defaultPos:"mid"}),...qc("y",e,{defaultPos:"mid"}),...Oc(e),...Ec("size",e,{vgChannel:"fontSize"}),...Ec("angle",e),...nu("align",Qp(e.markDef,n,t)),...nu("baseline",Jp(e.markDef,n,t)),...qc("radius",e,{defaultPos:null}),...qc("theta",e,{defaultPos:null})}}},tick:Kp,trail:{vgMark:"trail",encodeEntry:e=>({...Kc(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...qc("x",e,{defaultPos:"mid"}),...qc("y",e,{defaultPos:"mid"}),...Ec("size",e),...tu(e)})}};function tm(e){if(v([qr,Tr,Hr],e.mark)){const t=Ra(e.mark,e.encoding);if(t.length>0)return function(e,t){return[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:nm+e.requestDataName(ac.Main),data:e.requestDataName(ac.Main),groupby:t}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:rm(e,{fromPrefix:nm})}]}(e,t)}else if(e.mark===Mr){const t=xn.some((t=>_n(t,e.markDef,e.config)));if(e.stack&&!e.fieldDef("size")&&t)return function(e){const[t]=rm(e,{fromPrefix:im}),n=e.scaleName(e.stack.fieldChannel),i=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.vgField(e.stack.fieldChannel,t)},r=(e,t)=>`${e}(${[i({prefix:"min",suffix:"start",expr:t}),i({prefix:"max",suffix:"start",expr:t}),i({prefix:"min",suffix:"end",expr:t}),i({prefix:"max",suffix:"end",expr:t})].map((e=>`scale('${n}',${e})`)).join(",")})`;let o,a;"x"===e.stack.fieldChannel?(o={...p(t.encode.update,["y","yc","y2","height",...xn]),x:{signal:r("min","datum")},x2:{signal:r("max","datum")},clip:{value:!0}},a={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},t.encode.update={...m(t.encode.update,["y","yc","y2"]),height:{field:{group:"height"}}}):(o={...p(t.encode.update,["x","xc","x2","width"]),y:{signal:r("min","datum")},y2:{signal:r("max","datum")},clip:{value:!0}},a={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},t.encode.update={...m(t.encode.update,["x","xc","x2"]),width:{field:{group:"width"}}});for(const n of xn){const i=Cn(n,e.markDef,e.config);t.encode.update[n]?(o[n]=t.encode.update[n],delete t.encode.update[n]):i&&(o[n]=Sn(i)),i&&(t.encode.update[n]={value:0})}const s=[];if(e.stack.groupbyChannels?.length>0)for(const t of e.stack.groupbyChannels){const n=e.fieldDef(t),i=na(n);i&&s.push(i),(n?.bin||n?.timeUnit)&&s.push(na(n,{binSuffix:"end"}))}o=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"].reduce(((n,i)=>{if(t.encode.update[i])return{...n,[i]:t.encode.update[i]};{const t=Cn(i,e.markDef,e.config);return void 0!==t?{...n,[i]:Sn(t)}:n}}),o),o.stroke&&(o.strokeForeground={value:!0},o.strokeOffset={value:0});return[{type:"group",from:{facet:{data:e.requestDataName(ac.Main),name:im+e.requestDataName(ac.Main),groupby:s,aggregate:{fields:[i({suffix:"start"}),i({suffix:"start"}),i({suffix:"end"}),i({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:o},marks:[{type:"group",encode:{update:a},marks:[t]}]}]}(e)}return rm(e)}const nm="faceted_path_";const im="stack_group_";function rm(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fromPrefix:""};const{mark:i,markDef:r,encoding:o,config:a}=e,s=B(r.clip,function(e){const t=e.getScaleComponent("x"),n=e.getScaleComponent("y");return!(!t?.get("selectionExtent")&&!n?.get("selectionExtent"))||void 0}(e),function(e){const t=e.component.projection;return!(!t||t.isFit)||void 0}(e)),l=zn(r),c=o.key,u=function(e){const{encoding:n,stack:i,mark:r,markDef:o,config:a}=e,s=n.order;if(!(!t.isArray(s)&&Qo(s)&&y(s.value)||!s&&y(_n("order",o,a)))){if((t.isArray(s)||Io(s))&&!i)return An(s,{expr:"datum"});if(Xr(r)){const i="horizontal"===o.orient?"y":"x",r=n[i];if(Io(r)){const n=r.sort;return t.isArray(n)?{field:na(r,{prefix:i,suffix:"sort_index",expr:"datum"})}:Co(n)?{field:na({aggregate:Ea(e.encoding)?n.op:void 0,field:n.field},{expr:"datum"})}:_o(n)?{field:na(e.fieldDef(n.encoding),{expr:"datum"}),order:n.order}:null===n?void 0:{field:na(r,{binSuffix:e.stack?.impute?"mid":void 0,expr:"datum"})}}}}}(e),f=function(e){if(!e.component.selection)return null;const t=_(e.component.selection).length;let n=t,i=e.parent;for(;i&&0===n;)n=_(i.component.selection).length,i=i.parent;return n?{interactive:t>0||!!e.encoding.tooltip}:null}(e),d=_n("aria",r,a),p=em[i].postEncodingTransform?em[i].postEncodingTransform(e):null;return[{name:e.getName("marks"),type:em[i].vgMark,...s?{clip:!0}:{},...l?{style:l}:{},...c?{key:c.field}:{},...u?{sort:u}:{},...f||{},...!1===d?{aria:d}:{},from:{data:n.fromPrefix+e.requestDataName(ac.Main)},encode:{update:em[i].encodeEntry(e)},...p?{transform:p}:{}}]}class om extends up{constructor(e,n,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;super(e,"unit",n,i,o,void 0,zs(e)?e.view:void 0),Mn(this,"markDef",void 0),Mn(this,"encoding",void 0),Mn(this,"specifiedScales",{}),Mn(this,"stack",void 0),Mn(this,"specifiedAxes",{}),Mn(this,"specifiedLegends",{}),Mn(this,"specifiedProjection",{}),Mn(this,"selection",[]),Mn(this,"children",[]);const a=Kr(e.mark)?{...e.mark}:{type:e.mark},s=a.type;void 0===a.filled&&(a.filled=function(e,t,n){let{graticule:i}=n;if(i)return!1;const r=Cn("filled",e,t),o=e.type;return B(r,o!==Rr&&o!==qr&&o!==Ur)}(a,o,{graticule:e.data&&oc(e.data)}));const l=this.encoding=function(e,n,i,r){const o={};for(const t of _(e))Je(t)||Fi(`${a=t}-encoding is dropped as ${a} is not a valid encoding channel.`);var a;for(let a of at){if(!e[a])continue;const s=e[a];if(Ct(a)){const e=ot(a),t=o[e];if(Io(t)){if(tr(t.type)&&Io(s)){Fi(ti(e));continue}}else a=e,Fi(ni(e))}if("angle"!==a||"arc"!==n||e.theta||(Fi(ei),a=le),Ma(e,a,n)){if(a===ve&&"line"===n&&fa(e[a])?.aggregate){Fi(ai);continue}if(a===me&&(i?"fill"in e:"stroke"in e))Fi(ri("encoding",{fill:"fill"in e,stroke:"stroke"in e}));else if(a===Oe||a===Fe&&!t.isArray(s)&&!Qo(s)||a===_e&&t.isArray(s))s&&(o[a]=t.array(s).reduce(((e,t)=>(Io(t)?e.push(ga(t,a)):Fi(oi(t,a)),e)),[]));else{if(a===_e&&null===s)o[a]=null;else if(!(Io(s)||Ho(s)||Qo(s)||Ro(s)||gn(s))){Fi(oi(s,a));continue}o[a]=pa(s,a,r)}}else Fi(si(a,n))}return o}(e.encoding||{},s,a.filled,o);this.markDef=Vp(a,l,o),this.size=function(e){let{encoding:t,size:n}=e;for(const e of St){const i=it(e);Os(n[i])&&Vo(t[e])&&(delete n[i],Fi(hi(i)))}return n}({encoding:l,size:zs(e)?{...r,...e.width?{width:e.width}:{},...e.height?{height:e.height}:{}}:r}),this.stack=Zs(s,l),this.specifiedScales=this.initScales(s,l),this.specifiedAxes=this.initAxes(l),this.specifiedLegends=this.initLegends(l),this.specifiedProjection=e.projection,this.selection=(e.params??[]).filter((e=>ws(e)))}get hasProjection(){const{encoding:e}=this,t=this.mark===Yr,n=e&&Te.some((t=>Yo(e[t])));return t||n}scaleDomain(e){const t=this.specifiedScales[e];return t?t.domain:void 0}axis(e){return this.specifiedAxes[e]}legend(e){return this.specifiedLegends[e]}initScales(e,t){return Ut.reduce(((e,n)=>{const i=da(t[n]);return i&&(e[n]=this.initScale(i.scale??{})),e}),{})}initScale(e){const{domain:n,range:i}=e,r=dn(e);return t.isArray(n)&&(r.domain=n.map($n)),t.isArray(i)&&(r.range=i.map($n)),r}initAxes(e){return St.reduce(((t,n)=>{const i=e[n];if(Yo(i)||n===ee&&Yo(e.x2)||n===te&&Yo(e.y2)){const e=Yo(i)?i.axis:void 0;t[n]=e?this.initAxis({...e}):e}return t}),{})}initAxis(e){const t=_(e),n={};for(const i of t){const t=e[i];n[i]=ka(t)?wn(t):$n(t)}return n}initLegends(e){return Rt.reduce(((t,n)=>{const i=da(e[n]);if(i&&function(e){switch(e){case me:case ge:case he:case ve:case ye:case xe:case ke:case Se:return!0;case we:case $e:case be:return!1}}(n)){const e=i.legend;t[n]=e?dn(e):e}return t}),{})}parseData(){this.component.data=Ep(this)}parseLayoutSize(){!function(e){const{size:t,component:n}=e;for(const i of St){const r=it(i);if(t[r]){const e=t[r];n.layoutSize.set(r,Os(e)?"step":e,!0)}else{const t=Np(e,r);n.layoutSize.set(r,t,!1)}}}(this)}parseSelections(){this.component.selection=function(e,n){const i={},r=e.config.selection;if(!n||!n.length)return i;for(const o of n){const n=A(o.name),a=o.select,s=t.isString(a)?a:a.type,l=t.isObject(a)?f(a):{type:s},c=r[s];for(const e in c)"fields"!==e&&"encodings"!==e&&("mark"===e&&(l[e]={...c[e],...l[e]}),void 0!==l[e]&&!0!==l[e]||(l[e]=c[e]??l[e]));const u=i[n]={...l,name:n,type:s,init:o.value,bind:o.bind,events:t.isString(l.on)?t.parseSelector(l.on,"scope"):t.array(f(l.on))};for(const t of $u)t.defined(u)&&t.parse&&t.parse(e,u,o)}return i}(this,this.selection)}parseMarkGroup(){this.component.mark=tm(this)}parseAxesAndHeaders(){var e;this.component.axes=(e=this,St.reduce(((t,n)=>(e.component.scales[n]&&(t[n]=[Hp(n,e)]),t)),{}))}assembleSelectionTopLevelSignals(e){return function(e,n){let i=!1;for(const r of C(e.component.selection??{})){const o=r.name,a=t.stringValue(o+vu);if(0===n.filter((e=>e.name===o)).length){const e="global"===r.resolve?"union":r.resolve,i="point"===r.type?", true, true)":")";n.push({name:r.name,update:`${wu}(${a}, ${t.stringValue(e)}${i}`})}i=!0;for(const t of $u)t.defined(r)&&t.topLevelSignals&&(n=t.topLevelSignals(e,r,n))}i&&0===n.filter((e=>"unit"===e.name)).length&&n.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]});return fc(n)}(this,e)}assembleSignals(){return[...Eu(this),...lc(this,[])]}assembleSelectionData(e){return function(e,t){const n=[...t],i=ku(e,{escape:!1});for(const t of C(e.component.selection??{})){const e={name:t.name+vu};if(t.project.hasSelectionId&&(e.transform=[{type:"collect",sort:{field:ys}}]),t.init){const n=t.project.items.map((e=>{const{signals:t,...n}=e;return n}));e.values=t.project.hasSelectionId?t.init.map((e=>({unit:i,[ys]:sc(e,!1)[0]}))):t.init.map((e=>({unit:i,fields:n,values:sc(e,!1)})))}n.filter((e=>e.name===t.name+vu)).length||n.push(e)}return n}(this,e)}assembleLayout(){return null}assembleLayoutSignals(){return lf(this)}assembleMarks(){let e=this.component.mark??[];return this.parent&&lp(this.parent)||(e=uc(this,e)),e.map(this.correctDataNames)}assembleGroupStyle(){const{style:e}=this.view||{};return void 0!==e?e:this.encoding.x||this.encoding.y?"cell":void 0}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(e){return Pa(this.encoding,e)}fieldDef(e){return fa(this.encoding[e])}typedFieldDef(e){const t=this.fieldDef(e);return Xo(t)?t:null}}class am extends cp{constructor(e,t,n,i,r){super(e,"layer",t,n,r,e.resolve,e.view),Mn(this,"children",void 0);const o={...i,...e.width?{width:e.width}:{},...e.height?{height:e.height}:{}};this.children=e.layer.map(((e,t)=>{if(Vs(e))return new am(e,this,this.getName(`layer_${t}`),o,r);if(Ca(e))return new om(e,this,this.getName(`layer_${t}`),o,r);throw new Error(Wn(e))}))}parseData(){this.component.data=Ep(this);for(const e of this.children)e.parseData()}parseLayoutSize(){var e;_p(e=this),Cp(e,"width"),Cp(e,"height")}parseSelections(){this.component.selection={};for(const e of this.children){e.parseSelections();for(const t of _(e.component.selection))this.component.selection[t]=e.component.selection[t]}}parseMarkGroup(){for(const e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){!function(e){const{axes:t,resolve:n}=e.component,i={top:0,bottom:0,right:0,left:0};for(const i of e.children){i.parseAxesAndHeaders();for(const r of _(i.component.axes))n.axis[r]=gf(e.component.resolve,r),"shared"===n.axis[r]&&(t[r]=Wp(t[r],i.component.axes[r]),t[r]||(n.axis[r]="independent",delete t[r]))}for(const r of St){for(const o of e.children)if(o.component.axes[r]){if("independent"===n.axis[r]){t[r]=(t[r]??[]).concat(o.component.axes[r]);for(const e of o.component.axes[r]){const{value:t,explicit:n}=e.getWithExplicit("orient");if(!gn(t)){if(i[t]>0&&!n){const n=Rp[t];i[t]>i[n]&&e.set("orient",n,!1)}i[t]++}}}delete o.component.axes[r]}if("independent"===n.axis[r]&&t[r]&&t[r].length>1)for(const e of t[r])e.get("grid")&&!e.explicit.grid&&(e.implicit.grid=!1)}}(this)}assembleSelectionTopLevelSignals(e){return this.children.reduce(((e,t)=>t.assembleSelectionTopLevelSignals(e)),e)}assembleSignals(){return this.children.reduce(((e,t)=>e.concat(t.assembleSignals())),Eu(this))}assembleLayoutSignals(){return this.children.reduce(((e,t)=>e.concat(t.assembleLayoutSignals())),lf(this))}assembleSelectionData(e){return this.children.reduce(((e,t)=>t.assembleSelectionData(e)),e)}assembleGroupStyle(){const e=new Set;for(const n of this.children)for(const i of t.array(n.assembleGroupStyle()))e.add(i);const n=Array.from(e);return n.length>1?n:1===n.length?n[0]:void 0}assembleTitle(){let e=super.assembleTitle();if(e)return e;for(const t of this.children)if(e=t.assembleTitle(),e)return e}assembleLayout(){return null}assembleMarks(){return function(e,t){for(const n of e.children)op(n)&&(t=uc(n,t));return t}(this,this.children.flatMap((e=>e.assembleMarks())))}assembleLegends(){return this.children.reduce(((e,t)=>e.concat(t.assembleLegends())),Pf(this))}}function sm(e,t,n,i,r){if(jo(e))return new Ap(e,t,n,r);if(Vs(e))return new am(e,t,n,i,r);if(Ca(e))return new om(e,t,n,i,r);if(function(e){return Ss(e)||Ds(e)||ks(e)}(e))return new Tp(e,t,n,r);throw new Error(Wn(e))}const lm=n;e.accessPathDepth=I,e.accessPathWithDatum=M,e.compile=function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var i;n.logger&&(i=n.logger,Di=i),n.fieldTitle&&aa(n.fieldTitle);try{const i=Rs(t.mergeConfig(n.config,e.config)),r=ql(e,i),o=sm(r,null,"",void 0,i);o.parse(),function(e,t){kd(e.sources);let n=0,i=0;for(let i=0;i<$d&&Dd(e,t,!0);i++)n++;e.sources.map(bd);for(let n=0;n<$d&&Dd(e,t,!1);n++)i++;kd(e.sources),Math.max(n,i)===$d&&Fi(`Maximum optimization runs(${$d}) reached.`)}(o.component.data,o);const a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;const r=e.config?Bs(e.config):void 0,o=[].concat(e.assembleSelectionData([]),function(e,t){const n=[],i=Sp(n);let r=0;for(const t of e.sources){t.hasName()||(t.dataName="source_"+r++);const e=t.assemble();i(t,e)}for(const e of n)0===e.transform.length&&delete e.transform;let o=0;for(const[e,t]of n.entries())0!==(t.transform??[]).length||t.source||n.splice(o++,0,n.splice(e,1)[0]);for(const t of n)for(const n of t.transform??[])"lookup"===n.type&&(n.from=e.outputNodes[n.from].getSource());for(const e of n)e.name in t&&(e.values=t[e.name]);return n}(e.component.data,n)),a=e.assembleProjections(),s=e.assembleTitle(),l=e.assembleGroupStyle(),c=e.assembleGroupEncodeEntry(!0);let u=e.assembleLayoutSignals();u=u.filter((e=>"width"!==e.name&&"height"!==e.name||void 0===e.value||(t[e.name]=+e.value,!1)));const{params:f,...d}=t;return{$schema:"https://vega.github.io/schema/vega/v5.json",...e.description?{description:e.description}:{},...d,...s?{title:s}:{},...l?{style:l}:{},...c?{encode:{update:c}}:{},data:o,...a.length>0?{projections:a}:{},...e.assembleGroup([...u,...e.assembleSelectionTopLevelSignals([]),...$s(f)]),...r?{config:r}:{},...i?{usermeta:i}:{}}}(o,function(e,n,i,r){const o=r.component.layoutSize.get("width"),a=r.component.layoutSize.get("height");void 0===n?(n={type:"pad"},r.hasAxisOrientSignalRef()&&(n.resize=!0)):t.isString(n)&&(n={type:n});if(o&&a&&(s=n.type,"fit"===s||"fit-x"===s||"fit-y"===s))if("step"===o&&"step"===a)Fi(Hn()),n.type="pad";else if("step"===o||"step"===a){const e="step"===o?"width":"height";Fi(Hn(zt(e)));const t="width"===e?"height":"width";n.type=function(e){return e?`fit-${zt(e)}`:"fit"}(t)}var s;return{...1===_(n).length&&n.type?"pad"===n.type?{}:{autosize:n.type}:{autosize:n},...Hl(i,!1),...Hl(e,!0)}}(e,r.autosize,i,o),e.datasets,e.usermeta);return{spec:a,normalized:r}}finally{n.logger&&(Di=Si),n.fieldTitle&&aa(ra)}},e.contains=v,e.deepEqual=u,e.deleteNestedProperty=E,e.duplicate=f,e.entries=N,e.every=x,e.fieldIntersection=O,e.flatAccessWithDatum=L,e.getFirstDefined=B,e.hasIntersection=D,e.hash=h,e.internalField=G,e.isBoolean=P,e.isEmpty=z,e.isEqual=function(e,t){const n=_(e),i=_(t);if(n.length!==i.length)return!1;for(const i of n)if(e[i]!==t[i])return!1;return!0},e.isInternalField=Y,e.isNullOrFalse=y,e.isNumeric=Q,e.keys=_,e.logicalExpr=j,e.mergeDeep=w,e.never=d,e.normalize=ql,e.normalizeAngle=X,e.omit=m,e.pick=p,e.prefixGenerator=F,e.removePathFromField=U,e.replaceAll=W,e.replacePathInField=R,e.resetIdCounter=function(){H=42},e.setEqual=S,e.some=b,e.stringify=g,e.titleCase=T,e.unique=k,e.uniqueId=V,e.vals=C,e.varName=A,e.version=lm}));
//# sourceMappingURL=vega-lite.min.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy