mascot-vis 1.11.2 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- /* version: 1.11.2 */
2
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","d3","pixi.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msc={},t.d3,t.PIXI)}(this,(function(t,e,i){"use strict";function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var n=s(e),r=s(i);class a{constructor(t,e,i,s){this.left=t,this.top=e,this.width=i,this.height=s}toJSON(){let t={};return t.left=this.left,t.top=this.top,t.width=this.width,t.height=this.height,t}union(t){let e=Math.min(this.left,t.left),i=Math.min(this.top,t.top),s=Math.max(this.right,t.right),n=Math.max(this.bottom,t.bottom);return new a(e,i,s-e,n-i)}clone(){return new a(this.left,this.top,this.width,this.height)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get x(){return(this.left+this.right)/2}get y(){return(this.top+this.bottom)/2}get center(){return(this.left+this.right)/2}get middle(){return(this.top+this.bottom)/2}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}overlap(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}const o="id",h="atlas_rowId",l=["linear","power","log","sqrt","symlog","identity","time","ordinal","band","point","ordinalColor","sequentialColor","divergingColor"],c="natural",d="basis",u="bumpX",f="bumpY",p="linear",g="step",_="CatmullRom",m="cardinal",y={Grid:"grid",Circular:"circular",Stack:"stack",Treemap:"treemap",Packing:"packing",Force:"force",TidyTree:"tidytree",Sugiyama:"sugiyama",Strata:"strata"},v="vertical",b="horizontal",x="angular",w="radial",k={Up:"up",Down:"down",Left:"left",Right:"right",Inward:"inward",Outward:"outward",Clockwise:"clockwise",Anticlockwise:"anticlockwise"},C={Top:"top",Left:"left",Bottom:"bottom",Right:"right",Center:"center",Middle:"middle"},S="alignment",E="affixation",T={Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"pointText",Collection:"collection",Group:"group",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable"},A={Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"},I="max",O="min",R="avg",M="median",N="sum",P="count",F="mean",B="percentile 25",L="percentile 75",D={fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",strokeDash:"stroke-dasharray",opacity:"opacity",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",visibility:"visibility"},j="Cannot find relevant information to create an axis for ",V="Cannot change scale type to ",G={FIELD_NONEXISTENT:"Data field does not exist in the data table",INCOMPLETE_REPEAT_INFO:"Incomplete information to do repeat. You must specify an item, a categorical data field and a data table",REPEAT_BY_NONCAT:"Repeat only works on a string or date field",PARTITION_BY_NONCAT:"Divide only works on a string or date field",DENSIFY_BY_NONCAT:"Densify only works on a string or date field",INCOMPLETE_REPOPULATE_INFO:"Incomplete information to re-populate. You must specify an item, a categorical data field and a data table",REPOPULATE_BY_NONCAT:"Repopulate only works on a string or date field",REPOPULATE_DT_MISMATCH:"Cannot repopulate with a data table that is different from the item's parent's data table",COMPNT_NON_REPEATABLE:"Item not repeatable",REPEAT_NODE_LINK:"To repeat with a tree or a network, you need to provide two marks, one for node and one for link",INCOMPLETE_PARTITION_INFO:"Incomplete information to divide. You must specify an item, a categorical data field and a data table",COMPNT_NON_PARTITIONABLE:"Item cannot be divided",INCOMPLETE_DENSIFY_INFO:"Incomplete information to densify. You must specify an item, a categorical data field and a data table",COMPNT_NON_DENSIFIABLE:"Item cannot be densified",STRATIFY_WITHOUT_TREE:"Stratify only works on a tree dataset",STRATIFY_WRONG_ITEM:"Stratify only works on a circle or a rectangle",BIND_WITHOUT_DATASCOPE:"Item must be repeated or divided by data first before applyng binding",UNKNOWN_ALIGNMENT:"Unkown alignment",UNKNOWN_Orientation:"Unkown orientation",UNKNOWN_DIRECTION:"Unkown direction",UNKOWNN_SCALE_TYPE:"Unknown scale type",UNKNOWN_ANCHOR:"Unknown anchor",INCOMPLETE_BINDING_INFO:"Incomplete binding information. You must specify an item, a data field and a visual channel",MULTIPLE_VALUES_PER_FIELD:"Multiple distinct field values exist",DIFFERENT_SCALE_TYPE:"Cannot merge different types of scale",INSUFFICIENT_DATA_SCOPES:"Insufficient data to divide or densify a mark",INCORRECT_CONSTRAINT_INFO:"Constrain information is incorreclty passed",FEATURE_NOT_IMPLEMENTED:"This feature has not been implemented yet",LAYOUT_WITHOUT_TREE:"The layout can only be applied to a tree",UNSUPPORTED_FIELDTYPE:"Unsupported field type for encoding ",CANNOT_CLASSIFY:"Cannot classify items in "},z=["schemeCategory10","schemeAccent","schemeDark2","schemePaired","schemePastel1","schemePastel2","schemeSet1","schemeSet2","schemeSet3","schemeTableau10"],W=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],U=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class q{constructor(t){this.group=void 0}run(){}clone(){}}class Y extends q{constructor(t){super(),this.type="grid",this._numCols=t.numCols,this._numRows=t.numRows,this._dir="dir"in t?t.dir:[Y.direction.Left2Right,Y.direction.Top2Bottom],this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&this._validateCellAlignment("h",t.horzCellAlignment)?t.horzCellAlignment:C.Left,this._cellVertAlignment="vertCellAlignment"in t&&this._validateCellAlignment("v",t.vertCellAlignment)?t.vertCellAlignment:C.Bottom,this._numCols||this._numRows||(this._numRows=1)}_validateCellAlignment(t,e){return"h"===t&&[C.Left,C.Center,C.Right].indexOf(e)>=0||("v"===t&&[C.Top,C.Middle,C.Bottom].indexOf(e)>=0||(console.warn("Invalid alignment:",e),!1))}toJSON(){let t={args:{}};return t.type=this.type,t.args.numCols=this._numCols,t.args.numRows=this._numRows,t.args.colGap=this._colGap,t.args.rowGap=this._rowGap,t.args.horzCellAlignment=this._cellHorzAlignment,t.args.vertCellAlignment=this._cellVertAlignment,t.left=this._left,t.top=this._top,t.args.dir=this._dir,t}clone(){return new Y({numCols:this._numCols,numRows:this._numRows,dir:this._dir,colGap:this._colGap,rowGap:this._rowGap})}get cellBounds(){let t,e,i=this.group,s=this._colGap,n=this._rowGap;this._numRows?(e=this._numRows,t=Math.ceil(this.group.children.length/this._numRows)):this._numCols&&(t=this._numCols,e=Math.ceil(this.group.children.length/this._numCols));let r=i.children.map((t=>t.bounds));if(void 0===this._left){let t=r.map((t=>t.left)),e=r.map((t=>t.top));this._left=Math.min(...t),this._top=Math.min(...e)}let o=r.map((t=>t.width)),h=r.map((t=>t.height)),l=Math.max(...o),c=Math.max(...h),d=i.getInternalEncodings("x"),u=i.getInternalEncodings("y"),f=i.getInternalEncodings("width"),p=i.getInternalEncodings("height"),g=0;if(d.length>0){let t=d[d.length-1];l=t.scale.rangeExtent,g=t.scale.range[0],"point"===t.scale.type&&(l+=t.anyItem.bounds.width)}else f.length>0&&f[f.length-1]._rectNegativeValues&&(l=f[f.length-1].scale.rangeExtent,g=f[f.length-1].scale.range[0]);if(u.length>0){let t=u[u.length-1];c=t.scale.rangeExtent,"point"===t.scale.type&&(c+=t.anyItem.bounds.height)}else p.length>0&&p[p.length-1]._rectNegativeValues&&(c=p[p.length-1].scale.rangeExtent);let _=[],m=e*t;switch(this._dir[0]){case Y.direction.Left2Right:switch(this._dir[1]){case Y.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(this._left+(l+s)*(e%t)+g,this._top+(c+n)*Math.floor(e/t),l,c));break;case Y.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(this._left+(l+s)*(e%t)+g,this._top+(this.numRows-1-Math.floor(e/t))*(c+n),l,c))}break;case Y.direction.Right2Left:switch(this._dir[1]){case Y.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(g+this._left+(t-1)*(l+s)-(l+s)*(e%t),this._top+(c+n)*Math.floor(e/t),l,c));break;case Y.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(g+this._left+(t-1-e%t)*(l+s),this._top+(this.numRows-1-Math.floor(e/t))*(c+n),l,c))}break;case Y.direction.Top2Bottom:switch(this._dir[1]){case Y.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),l,c));break;case Y.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*(this.numCols-1)-(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),l,c))}break;case Y.direction.Bottom2Top:switch(this._dir[1]){case Y.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),l,c));break;case Y.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*(this.numCols-1)-(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),l,c))}}return _}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.cellBounds,e=this.group.getInternalEncodings("x"),i=this.group.getInternalEncodings("y"),s=this.group.getInternalEncodings("width"),n=this.group.getInternalEncodings("height");for(let s=0;s<this.group.children.length;s++){let n=this.group.children[s],r=t[s],a=r.x-n.bounds.x,o=r.y-n.bounds.y;n._doTranslate(a,o);let h=0,l=0;if(0==e.length)switch(this._cellHorzAlignment){case C.Left:h=r.left-n.bounds.left;break;case C.Center:h=r.x-n.bounds.x;break;case C.Right:h=r.right-n.bounds.right}if(0==i.length)switch(this._cellVertAlignment){case C.Top:l=r.top-n.bounds.top;break;case C.Middle:l=r.y-n.bounds.y;break;case C.Bottom:l=r.bottom-n.bounds.bottom}n._doTranslate(h,l)}if(e.length>0)for(let t of e)t._apply();else if(s.length>0){let t=s[s.length-1];t._rectNegativeValues&&t._apply()}if(i.length>0)for(let t of i)t._apply();else if(n.length>0){let t=n[n.length-1];t._rectNegativeValues&&t._apply()}this.group._updateBounds()}set rowGap(t){this._rowGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get rowGap(){return this._rowGap}set colGap(t){this._colGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get colGap(){return this._colGap}set numCols(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"columns for",this.group.children.length,"items in grid"):(this._numCols=t,this._numRows=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numRows(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"rows for",this.group.children.length,"items in grid"):(this._numRows=t,this._numCols=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}set vertCellAlignment(t){if(t!=C.Top&&t!=C.Bottom&&t!=C.Middle)throw G.UNKOWN_ALIGNMENT;this._cellVertAlignment=t,this.run()}get vertCellAlignment(){return this._cellVertAlignment}set horzCellAlignment(t){if(t!=C.Left&&t!=C.Center&&t!=C.Right)throw G.UNKOWN_ALIGNMENT;this._cellHorzAlignment=t,this.run()}get horzCellAlignment(){return this._cellHorzAlignment}set direction(t){Array.isArray(t)&&2===t.length?this._dir=t:this._dir=t.split("_"),this.run()}get direction(){return this._dir.join("_")}}Y.direction={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"};class J{constructor(t){this._stops=[],this.type=T.LinearGradient,this.id=this.type+mt[this.type]++,this.x1="x1"in t?t.x1:0,this.x2="x2"in t?t.x2:100,this.y1="y1"in t?t.y1:0,this.y2="y2"in t?t.y2:0}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,i){this._stops.push({offset:t,color:e,opacity:i})}get stops(){return this._stops}}class H{constructor(t){if(this._dataScope=void 0,this._id=void 0,this.attrs={},this.styles={},this.staticProperties={},void 0!==t)for(let e in D)e in t&&(this.styles[e]=t[e])}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){if(!this._bounds)return!1;if(!this._bounds.contains(t,e))return!1;switch(this.type){case T.Rect:case T.PointText:return!0;case T.Circle:return Math.sqrt(Math.pow(t-this.x,2)+Math.pow(e-this.y,2))<=this.radius+this.strokeWidth;case T.Path:{let i=bt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),this.closed?i.isPointInPath(s,t,e):i.isPointInStroke(s,t,e)}case T.Line:{let i=bt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),i.isPointInStroke(s,t,e)}default:{let i=bt.getContext(),s=new Path2D(this.getSVGPathData());return i.isPointInPath(s,t,e)}}}toJSON(){let t={};t.type=this.type,t.id=this.id,this.classId&&(t.classId=this.classId),this._dataScope&&(t.dataScope=this._dataScope.toJSON()),t.args={};for(let e in this.attrs)t.args[e]=this.attrs[e];for(let e in this.styles)e.indexOf("Color")>0&&this.styles[e]instanceof J?t.args[e]=this.styles[e].toJSON():t.args[e]=this.styles[e];return t}getScene(){let t=this;for(;t;){if(t.type==T.Scene)return t;t=t.parent}}set dataScope(t){this._dataScope=t}get dataScope(){return this._dataScope}duplicate(){let t=this.getScene().mark(this.type);return this.copyPropertiesTo(t),t.classId=this.classId,this._dataScope&&(t._dataScope=this._dataScope.clone()),t}_doTranslate(t,e){}set visibility(t){this.styles.visibility=t}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity=t}}function $(t){return t>=-1e-12&&t<=1e-12}class Z{constructor(t,e){this.x=t,this.y=e}transform(t){return t?t._transformPoint(this):this}negate(){return new Z(-this.x,-this.y)}subtract(t){return new Z(this.x-t.x,this.y-t.y)}isZero(){return $(this.x)&&$(this.y)}isCollinear(t){let e=this.x,i=this.y,s=t.x,n=t.y;return Math.abs(e*n-i*s)<=1e-8*Math.sqrt((e*e+i*i)*(s*s+n*n))}}class K{constructor(t,e,i){this.type="vertex",this._id=i,this.x=t.x,this.y=t.y,this.dataScope=void 0,this.parent=e,this.shape=void 0,this.width=0,this.height=0,this.radius=0,this.fillColor="#555",this.opacity=1,this.strokeWidth=0,this.strokeColor="#aaa",this._polarAngle=void 0}get bounds(){switch(this.shape){case"rect":return new a(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new a(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new a(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}toJSON(){let t={};return t.type=this.type,t.id=this._id,t.x=this.x,t.y=this.y,this.dataScope&&(t.dataScope=this.dataScope.toJSON()),void 0!==this._polarAngle&&(t.polarAngle=this._polarAngle),t.shape=this.shape,t.width=this.width,t.height=this.height,t.radius=this.radius,t.fillColor=this.fillColor,t.opacity=this.opacity,t.strokeWidth=this.strokeWidth,t.strokeColor=this.strokeColor,t}static fromJSON(t,e){let i=new K(t,e,t.id);return t.dataScope&&(i.dataScope=t.dataScope),"polarAngle"in t&&(i.polarAngle=t.polarAngle),i.shape=t.shape,i.width=t.width,i.height=t.height,i.radius=t.radius,i.fillColor=t.fillColor,i.opacity=t.opacity,i.strokeWidth=t.strokeWidth,i.strokeColor=t.strokeColor,i}_doTranslate(t,e){this.x+=t,this.y+=e}_clone(t){let e=new K(new Z(this.x,this.y),t,this._id);return this.dataScope&&(e.dataScope=this.dataScope.clone()),e.shape=this.shape,e.width=this.width,e.height=this.height,e.radius=this.radius,e.fillColor=this.fillColor,e.opacity=this.opacity,e.strokeWidth=this.strokeWidth,e.strokeColor=this.strokeColor,e}set polarAngle(t){this._polarAngle=t}get polarAngle(){return this._polarAngle}}K.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class X{constructor(t,e,i,s){this.type="segment",this._id=s,this.vertex1=t,this.vertex2=e,this.dataScope=void 0,this.parent=i}get id(){return this.parent.id+"_s_"+this._id}_doTranslate(t,e){this.vertex1._doTranslate(t,e),this.vertex2._doTranslate(t,e)}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}}class Q extends H{constructor(t){if(super(t),this.type="type"in t?t.type:T.Path,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none"),this.vertices=[],this.vertexCounter=0,this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed=!1,this.curveMode="linear",this.boundsOffsets={top:0,bottom:0,left:0,right:0},this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1,void 0!==t){for(let e of K.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&this._setVertices(t.vertices)}}toJSON(){let t=super.toJSON();switch(t.type=this.type,t.id=this.id,this.type){case T.Rect:t.args.width=this.width,t.args.height=this.height,t.args.top=this.top,t.args.left=this.left;break;case T.Circle:t.args.x=this.x,t.args.y=this.y,t.args.radius=this.radius;break;case T.Arc:case T.Pie:t.args.x=this._x,t.args.y=this._y,t.args.innerRadius=this._innerRadius,t.args.outerRadius=this._outerRadius,t.args.startAngle=this._startAngle,t.args.endAngle=this._endAngle;break;default:t.vertices=[];for(let e of this.vertices)t.vertices.push(e.toJSON());this.type===T.Polygon?(t.args.x=this._x,t.args.y=this._y,t.args.radius=this._radius):this.type===T.Area&&(t.args.baseline=this._baseline,t.args.orientation=this._orientation)}t.vertexCounter=this.vertexCounter,t.segmentCounter=this.segmentCounter,t.curveMode=this.curveMode,this._bounds&&(t.bounds=this._bounds.toJSON()),t.boundsOffsets=this.boundsOffsets;for(let e of K.styles)t.args[e]=this[e];return t}_setVertices(t){let e,i;this.vertices=[],this.segments=[];for(let s=0;s<t.length;s++)if(s!=t.length-1||t[s][0]!==t[0][0]||t[s][1]!==t[0][1]||this.type!==T.Path){i=new Z(t[s][0],t[s][1]),e=new K(i,this,this.vertexCounter++);for(let t of K.styles)if(this[t]){let i=t.replace("vx","");e[i[0].toLowerCase()+i.slice(1)]=this[t]}this.vertices.push(e),s>0&&this.segments.push(new X(this.vertices[s-1],this.vertices[s],this,this.segmentCounter++))}let s=t[0],n=t[t.length-1];(s[0]===n[0]&&s[1]===n[1]||this.type===T.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new X(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of K.styles)this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScope&&(t._dataScope=this._dataScope.clone()),t.closed=this.closed,t.curveMode=this.curveMode,t.vertices=[],t.segments=[];for(let e of this.vertices)t.vertices.push(e._clone(t));t.segmentCounter=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new X(t.vertices[e-1],t.vertices[e],t,t.segmentCounter++));t.closed&&t.segments.push(new X(t.vertices[t.vertices.length-1],t.vertices[0],t,t.segmentCounter++))}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){this._bounds||this._updateBounds();let t=this._bounds.bottom+this.boundsOffsets.bottom-(this._bounds.top-this.boundsOffsets.top),e=this._bounds.right+this.boundsOffsets.right-(this._bounds.left-this.boundsOffsets.left);return new a(this._bounds.left-this.boundsOffsets.left,this._bounds.top-this.boundsOffsets.top,e,t)}get x(){return this.bounds.x}get y(){return this.bounds.y}get strokeColor(){return this.styles.strokeColor}set strokeColor(t){this.styles.strokeColor=t}get strokeWidth(){return this.styles.strokeWidth}set strokeWidth(t){this.styles.strokeWidth=t}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash=t}_doTranslate(t,e){for(let i of this.vertices)i._doTranslate(t,e);this._updateBounds()}resize(t,e,i,s){let n=this.bounds,r=0===n.width?1:n.width,a=0===n.height?1:n.height;if("right"===i)for(let e of this.vertices)e.x=n.right-t/r*(n.right-e.x);else for(let e of this.vertices)e.x=n.left+t/r*(e.x-n.left);if("top"===s)for(let t of this.vertices)t.y=n.top+e/a*(t.y-n.top);else for(let t of this.vertices)t.y=n.bottom-e/a*(n.bottom-t.y);this._updateBounds()}_updateBounds(){let t=this.vertices.map((t=>t.x)),e=this.vertices.map((t=>t.y)),i=Math.min(...t),s=Math.min(...e),n=Math.max(...t),r=Math.max(...e);this._bounds=new a(i,s,n-i,r-s)}addVertex(t,e,i){let s=new K(new Z(t,e),this,this.vertexCounter++);this.vertices.splice(i,0,s)}sortVertices(t,e){this.vertices.sort(((e,i)=>e[t]-i[t])),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}sortVerticesByData(t,e,i){let s;s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1,this.vertices.sort(s),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}getSVGPathData(){let t=n.path(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t of this.vertices)e.point(t.x,t.y);return this.closed&&e.point(this.vertices[0].x,this.vertices[0].y),e.lineEnd(),t._}get firstVertex(){return this.vertices[0]}get firstSegment(){return this.segments[0]}get lastVertex(){return this.vertices[this.vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_getD3CurveFunction(t){switch(t){case c:return n.curveNatural;case d:return n.curveBasis;case u:return n.curveBumpX;case f:return n.curveBumpY;case p:return n.curveLinear;case g:return n.curveStep;case _:return n.curveCatmullRom;case m:return n.curveCardinal;default:return n.curveLinear}}get vxShape(){return this._vxShape}set vxShape(t){this._vxShape=t;for(let e of this.vertices)e.shape=t}get vxWidth(){return this._vxWidth}set vxWidth(t){this._vxWidth=t;for(let e of this.vertices)e.width=t}get vxHeight(){return this._vxHeight}set vxHeight(t){this._vxHeight=t;for(let e of this.vertices)e.height=t}get vxRadius(){return this._vxRadius}set vxRadius(t){this._vxRadius=t;for(let e of this.vertices)e.radius=t}get vxFillColor(){return this._vxFillColor}set vxFillColor(t){this._vxFillColor=t;for(let e of this.vertices)e.fillColor=t}get vxStrokeColor(){return this._vxStrokeColor}set vxStrokeColor(t){this._vxStrokeColor=t;for(let e of this.vertices)e.strokeColor=t}get vxStrokeWidth(){return this._vxStrokeWidth}set vxStrokeWidth(t){this._vxStrokeWidth=t;for(let e of this.vertices)e.strokeWidth=t}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}}function tt(t,e){if("field"in e){if(!t.dataScope)return!1;let i=e.field;if("value"in e)return t.dataScope.getFieldValue(i)===e.value;if("interval"in e){let s=t.dataScope.getFieldValue(i);return s>=e.interval[0]&&s<=e.interval[1]}return"values"in e?e.values.indexOf(t.dataScope.getFieldValue(i))>=0:t.dataScope.hasField(i)}if("channel"in e){let i=e.channel;if("value"in e)return t[i]===e.value;if("interval"in e)return t[i]>=e.interval[0]&&t[i]<=e.interval[1];if("values"in e)return e.values.indexOf(t[i])>=0}else{if("type"in e)return t.type===e.type;if("id"in e)return t.id===e.id;if("classId"in e)return t.classId===e.classId;if("fields"in e){if(!t.dataScope)return!1;let i=e.fields[0],s=e.fields[1],n=t.dataScope.getFieldValue(i),r=t.dataScope.getFieldValue(s);switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}}}return!1}function et(t,e){let i=[];return it(t,e,i),i}function it(t,e,i){if(t&&"axis"!=t.type&&"legend"!=t.type&&"gridlines"!=t.type)if(st(t,e)&&i.push(t),t.vertices)for(let s of t.vertices.concat(t.segments))st(s,e)&&i.push(s);else if(t.children&&t.children.length>0)for(let s of t.children)it(s,e,i)}function st(t,e){for(let i of e)if(!tt(t,i))return!1;return!0}function nt(t,e){return"vertex"==t.type?function(t,e){if(!t.classId){if(t.dataScope){let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=et(e,[{classId:i.classId}]),n=[];if(i.type===T.Area){let e=i.vertices.indexOf(t)<i.vertices.length/2;for(let t of s){let i=e?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);n=n.concat(i.filter((t=>t.dataScope)))}}else for(let t of s)n=n.concat(t.vertices.filter((t=>t.dataScope)));return n}{let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=i.vertices.indexOf(t),n=et(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.vertices[s]);return r}}}(t,e):"segment"==t.type?function(t,e){if(t.dataScope){let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=et(e,[{classId:i.classId}]),n=[];for(let t of s)n=n.concat(t.segments);return n}{let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=i.segments.indexOf(t),n=et(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.segments[s]);return r}}(t,e):t.classId?et(e,[{classId:t.classId}]):[]}function rt(t,e){let i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout&&(!e||e&&i.layout.type===e))return i.layout;i=i.parent}}function at(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function ot(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout&&i.layout.type==y.Grid){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function ht(t,e){let i,s=t.parent;for(;s&&s.type!==T.Scene;)s.layout&&(!e||e&&s.layout.type===e)&&(i=s.layout),s=s.parent;return i}function lt(t){if(t.classId)return t.classId;if("vertex"==t.type&&t.dataScope){if(t.parent.type===T.Area){let e=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;return t.parent.classId+"_v_"+(e?0:t.parent.vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v_"+t.parent.vertices.indexOf(t):"segment"==t.type&&t.dataScope?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s_"+t.parent.segments.indexOf(t):null}function ct(t){let e=[];for(let i of t)i.parent&&e.indexOf(i.parent)<0&&e.push(i.parent);return e}function dt(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e.push(i),e=e.concat(dt(i));return e}function ut(t){let e=[];if(gt(t))e.push(t);else if(t.children&&t.children.length>0&&!pt(t))for(let i of t.children)e=e.concat(ut(i));return e}function ft(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e=e.concat(ft(i));else e.push(t);return e}function pt(t){return t.type===T.Axis||t.type===T.Legend||t.type===T.Gridlines}function gt(t){return t instanceof H}function _t(t){return t instanceof Q}const mt={area:0,rect:0,circle:0,pie:0,line:0,path:0,ring:0,arc:0,image:0,pointText:0,collection:0,group:0,scene:0,axis:0,glyph:0,legend:0,polygon:0,gridlines:0,LinearGradient:0,link:0,scale:0,datatable:0};function yt(t,e){if(e.getEncodingByItem(t,"x"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==y.Grid&&e.numCols>1)return!1}return!t.parent||t.parent.type==T.Scene||yt(t.parent,e)}function vt(t,e){if(e.getEncodingByItem(t,"y"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==y.Grid&&e.numRows>1)return!1}return!t.parent||t.parent.type==T.Scene||vt(t.parent,e)}var bt={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var t=this.getCanvas();return t?t.getContext("2d"):null}},xt={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}};function wt(t){let e=t.parent;return e.type==T.Scene?t:wt(e)}function kt(t){let e=t.parent;return t.type==T.Collection?e.type==T.Collection?kt(e):t:e.type!=T.Scene?kt(e):void 0}function Ct(t,e,i,s){return[i*Math.cos(Et(s))+t,e-i*Math.sin(Et(s))]}function St(t,e,i,s){let n=function(t){return 180*t/Math.PI}(Math.atan2(s-e,t-i));n=Math.round(10*n+Number.EPSILON)/10,n<0&&(n+=360);let r=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-s,2));return r=Math.round(10*r+Number.EPSILON)/10,[n,r]}function Et(t){return t*Math.PI/180}function Tt(t){let e=t.vertices.length;for(let i=0;i<t.vertices.length/2;i++){let s=i,n=e-i-1,r=t.vertices[s],a=t.vertices[n];if(r.x!=a.x||r.y!=a.y)return r.x==a.x?"horizontal":"vertical"}}class At{constructor(){this.children=[],this._dataScope=void 0,this._layout=void 0,this.type=T.Group,this._id=this.type+mt[this.type]++}get id(){return this._id}set id(t){this.type!==T.Scene&&this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}toJSON(){let t={};if(t.type=this.type,t.id=this.id,this._dataScope&&(t.dataScope=this._dataScope.toJSON()),this.classId&&(t.classId=this.classId),this._layout&&(t.layout=this._layout.toJSON()),this._bounds&&(t.bounds=this._bounds.toJSON()),t.children=[],this.children.length>0&&this.type!=T.Axis)for(let e of this.children)t.children.push(e.toJSON());return this.childrenOrder&&(t.childrenOrder=this.childrenOrder),t}addChild(t){this.children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this.children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this.children=[]}getScene(){let t=this;for(;t;){if(t.type==T.Scene)return t;t=t.parent}}get dataScope(){return this._dataScope}set dataScope(t){if(this._dataScope=t,void 0===t)for(let e of this.children)e.dataScope=t;else for(let e of this.children)e.dataScope?e.dataScope=e.dataScope.merge(t):e.dataScope=t}_doTranslate(t,e){for(let i of this.children)i._doTranslate(t,e);this._updateBounds(),this._layout&&(void 0!==this._layout._left&&(this._layout._left+=t),void 0!==this._layout._top&&(this._layout._top+=e),void 0!==this._layout.x&&(this._layout.x+=t),void 0!==this._layout.y&&(this._layout.y+=e)),this._updateBounds()}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],i=this.getScene(),s=Object.keys(i.encodings),n=[];for(;e;){if(e.classId&&n.indexOf(e.classId)<0&&n.push(e.classId),e.type===T.Glyph){e.children.forEach((t=>n.push(t.classId)));break}if(!e.children)break;e=e.children[0]}let r=[];for(let e of s){let s=e.split("_");for(let a of n)s[0]==a&&i.encodings[e][t]&&r.push(i.encodings[e][t])}return r}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t)t.group=this,this._layout.run();else{let t=this.getInternalEncodings("x"),e=this.getInternalEncodings("y");for(let e of t)e._map(),e._apply();for(let t of e)t._map(),t._apply()}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let t=this.children.map((t=>t.refBounds)),e=Math.min(...t.map((t=>t.left))),i=Math.min(...t.map((t=>t.top))),s=Math.max(...t.map((t=>t.right))),n=Math.max(...t.map((t=>t.bottom)));return new a(e,i,s-e,n-i)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){if(this.children.length>0){this._bounds=this.children[0].bounds.clone();for(let t=1;t<this.children.length;t++)"hidden"!=this.children[t].visibility&&(this._bounds=this._bounds.union(this.children[t].bounds));if(this._layout&&"grid"==this._layout.type){let t=this._layout.cellBounds;for(let e=0;e<t.length;e++)this._bounds=this._bounds.union(t[e])}}else this._bounds=new a(0,0,0,0)}sortChildrenByData(t,e,i){let s;switch(this.children[0].dataScope.getFieldType(t)){case A.Date:break;case A.Number:case A.Integer:s=(e,i)=>e.dataScope.aggregateNumericalField(t)-i.dataScope.aggregateNumericalField(t);break;case A.String:s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1}this.children.sort(s),e&&this.children.reverse(),this.layout&&this.layout.run(),this._childrenOrder={field:t,direction:e?"desc":"asc",ranking:i}}sortChildren(t,e){let i;switch(t){case"x":case"y":case"width":case"height":i=(e,i)=>e.bounds[t]-i.bounds[t];break;default:i=(e,i)=>e[t]-i[t]}this.children.sort(i),e&&this.children.reverse(),this.layout&&this.layout.run(),this.childrenOrder={channel:t,reverse:e}}set visibility(t){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}get visibility(){return this._visibility?this._visibility:"visible"}}function It(t){return[...new Set(t)]}function Ot(t,e){if(e.hasField(t))return!0;if(e.tree&&e.tree.nodeTable.hasField(t.split(".")[1]))return!0;throw new Error(G.FIELD_NONEXISTENT+", field: "+t+", data table: "+e.name)}function Rt(t){return t<0?t+360:t>360?t-360:t}class Mt{constructor(t){this._field2value={},this._dt=t,this._tuples=this._dt.data}toJSON(){let t={};return t.dt=this._dt.id,t.f2v=Object.assign({},this._field2value),t}isFullTable(){return 0===Object.keys(this._field2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get fields(){return Object.keys(this._field2value)}get dataTable(){return this._dt}get filters(){return this._field2value}merge(t){let e=new Mt(this._dt);for(let i in t._field2value)e=e.cross(i,t._field2value[i]);for(let t in this._field2value)e=e.cross(t,this._field2value[t]);return e}cross(t,e){let i=this.clone();return i._field2value[t]=e,i._updateTuples(t,e),i}clone(){let t=new Mt(this._dt);return t._field2value=Object.assign({},this._field2value),t._tuples=this._tuples.map((t=>t)),t}getFieldValue(t){let e=this._tuples.map((e=>e[t]));return e=[...new Set(e)],e.length,e[0]}getUniqueFieldValues(t){let e=this._tuples.map((e=>e[t]));return[...new Set(e)]}hasField(t){return t in this._field2value}getFieldType(t){return this._dt.getFieldType(t)}aggregateNumericalField(t,e){let i=this._tuples.map((e=>e[t]));switch(e){case I:return Math.max(...i);case O:return Math.min(...i);case R:case F:return n.mean(i);case M:return n.median(i);case P:return i.length;case B:return n.quantile(i,.25);case L:return n.quantile(i,.75);case N:default:return n.sum(i)}}_updateTuples(t,e){this._tuples=this._tuples.filter((i=>i[t]==e))}}function Nt(t,e,i,s,n){let r=n?s.transformField(i,n):i,a=s.getFieldType(r);if(a!=A.String&&a!=A.Date&&a!=A.Integer)throw new Error(G.REPEAT_BY_NONCAT+": "+r+" is "+a);if(!ed(e))throw new Error(G.COMPNT_NON_REPEATABLE);return function(t,e,i,s){let n=s.getFieldSummary(i).unique.map((t=>e.dataScope?e.dataScope.cross(i,t):new Mt(s).cross(i,t)));n=n.filter((t=>!t.isEmpty()));let r=t.collection();r.dataScope=e.dataScope?e.dataScope.clone():new Mt(s),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}return r.children.forEach(((t,e)=>t.dataScope=n[e])),t._reapplySizeBindings(e),r}(t,e,r,s)}class Pt extends q{constructor(t){super(t),this.type=y.Stack,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:C.Left,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:C.Bottom,this._gap="gap"in t?t.gap:0}toJSON(){let t={args:{}};return t.type=this.type,t.args.orientation=this._orientation,t.args.direction=this._direction,t.args.left=this._left,t.args.top=this._top,t.args.gap=this._gap,t.args.horzCellAlignment=this._horzCellAlignment,t.args.vertCellAlignment=this._vertCellAlignment,t}clone(){let t=new Pt({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}_stackAreasVert(){let t=this.group.children,e=this.group.bounds,i=this._vertCellAlignment===C.Top?e.top:e.bottom,s=this._vertCellAlignment===C.Top?1:-1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],h=Math.abs(a.y-o.y),l=i+r[t]*s,c=i+(r[t]+h)*s;a._doTranslate(0,l-a.y),o._doTranslate(0,c-o.y),r[t]+=h}e._updateBounds()}if(this.vertCellAlignment===C.Middle)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.middle+r[t]/2;s._doTranslate(0,o-e.bottom),a._doTranslate(0,o-e.bottom)}i._updateBounds()}this.group._updateBounds()}_stackAreasHorz(){let t=this.group.children,e=this.group.bounds,i=this._horzCellAlignment===C.Right?e.right:e.left,s=this._horzCellAlignment===C.Right?-1:1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],h=Math.abs(a.x-o.x),l=i+r[t]*s,c=i+(r[t]+h)*s;a._doTranslate(0,l-a.y),o._doTranslate(0,c-o.y),r[t]+=h}e._updateBounds()}if(this._horzCellAlignment===C.Center)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.center-r[t]/2;s._doTranslate(0,o-e.left),a._doTranslate(0,o-e.left)}i._updateBounds()}this.group._updateBounds()}_stackAreas(){this.group.children[0].orientation===b?this._stackAreasVert():this._stackAreasHorz()}_stackArcs(){let t=this.group,e=this.startAngle?this.startAngle:90;if((this._direction?this._direction:k.Clockwise)===k.Clockwise)for(let i of t.children){let t=Rt(e-i.angle);i.adjustAngle(t,e),e=t}else for(let i of t.children){let t=Rt(e+i.angle);i.adjustAngle(e,t),e=t}}_stackRects(){let t=this.group.getScene(),e=this.group,i=this._orientation,s=e.children.map((t=>t.bounds)),n=s.map((t=>t.left)),r=s.map((t=>t.top)),a=s.map((t=>t.width)),o=s.map((t=>t.height)),h=null==this._left?Math.min(...n):this._left,l=null==this._top?Math.min(...r):this._top,c=Math.max(...a),d=Math.max(...o);if(i==v){let i=h+c/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=i-n.bounds.x,a=l+n.bounds.height/2-n.bounds.y;l+=n.bounds.height+this._gap,n._doTranslate(r,a);let o=0,d=0;if(!t.getEncodingByItem(n,"x"))switch(this._horzCellAlignment){case C.Left:o=h-n.bounds.left;break;case C.Center:o=h+c/2-n.bounds.x;break;case C.Right:o=h+c-n.bounds.right}n._doTranslate(o,d)}}else{let i=l+d/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=h+n.bounds.width/2-n.bounds.x,a=i-n.bounds.y;h+=n.bounds.width+this._gap,n._doTranslate(r,a);let o=0,c=0;if(!t.getEncodingByItem(n,"y"))switch(this._vertCellAlignment){case C.Top:c=l-n.bounds.top;break;case C.Middle:c=l+d/2-n.bounds.y;break;case C.Bottom:c=l+d-n.bounds.bottom}n._doTranslate(o,c)}}this.group._updateBounds()}run(){null!=this.group&&this.group.children&&0!==this.group.children.length&&("area"==this.group.children[0].type?this._stackAreas():this.group.children[0].type==T.Arc||this.group.children[0].type==T.Pie?this._stackArcs():this._stackRects())}set vertCellAlignment(t){if(t!=C.Top&&t!=C.Bottom&&t!=C.Middle)throw G.UNKOWN_ALIGNMENT;this._vertCellAlignment=t,this.run()}get vertCellAlignment(){return this._vertCellAlignment}set horzCellAlignment(t){if(t!=C.Left&&t!=C.Center&&t!=C.Right)throw G.UNKOWN_ALIGNMENT;this._horzCellAlignment=t,this.run()}get horzCellAlignment(){return this._horzCellAlignment}get cellBounds(){return this.group.children.map((t=>t.bounds))}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}}function Ft(t,e,i,s,n,r){let a=r?n.transformField(s,r):s,o=n.getFieldType(a);if(o!=A.String&&o!=A.Date)throw new Error(G.PARTITION_BY_NONCAT+": "+a+" is "+o);if(!id(e))throw new Error(G.COMPNT_NON_PARTITIONABLE);switch(e.type){case T.Line:return function(t,e,i,s){let n,r,a=nt(e,t),o=s.getFieldSummary(i).unique.map((t=>new Mt(s).cross(i,t))),h={},l=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>l&&(l=e.length),h[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope;let a=i.parent;a.addChild(s);let o=h[i.id],c=i.vertices[0].x,d=i.vertices[0].y,u=i.vertices[1].x,f=i.vertices[1].y;for(let t=0;t<o.length;t++){let n=i.duplicate();n.classId=e.id,n.vertices[0].x=c+(u-c)*t/l,n.vertices[0].y=d+(f-d)*t/l,n.vertices[1].x=c+(u-c)*(t+1)/l,n.vertices[1].y=d+(f-d)*(t+1)/l,n.dataScope=o[t],s.addChild(n)}a.removeChild(i),i==e&&(n=s)}return n}(t,e,a,n);case T.Circle:return function(t,e,i,s,n){let r,a,o=i||x,h=nt(e,t);if(o==x)h.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/l,f=90;for(let s=0;s<l;s++){let n=t.mark("pie",{innerRadius:0,outerRadius:i.radius,x:i.x,y:i.y,startAngle:Rt(f-u*(s+1)),endAngle:Rt(f-u*s),strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}c.layout=Kc("stack",{orientation:x,direction:k.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)}));else{if(o!=w)throw G.UNKNOWN_Orientation+": "+o;h.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=i.radius/l;for(let s=0;s<l;s++){let n=t.mark("ring",{x:i.x,y:i.y,innerRadius:s*u,outerRadius:(s+1)*u,strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)}))}return r}(t,e,i,a,n);case T.Rect:return function(t,e,i,s,n){let r,a=nt(e,t),o=i||b;if(o!=b&&o!=v)throw G.UNKNOWN_Orientation+": "+o;let h,l=n.getFieldSummary(s).unique.map((t=>new Mt(n).cross(s,t))),c={},d=0;for(let t of a){let e=l;t.dataScope&&(e=l.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>d&&(d=e.length),c[t.id]=e}for(let i of a){let s=t.collection();null==h&&(h=s.id),s.classId=h,s.dataScope=i.dataScope?i.dataScope:new Mt(n);let a=i.parent;a.addChild(s);let l=c[i.id],u=i.bounds,f=u.left,p=u.top,g=o==b?u.width/d:u.width,_=o==b?u.height:u.height/d;for(let t=0;t<l.length;t++){let n=i.duplicate();n.classId=e.id,n.resize(g,_),n.dataScope=l[t],s.addChild(n)}s.layout=new Pt({orientation:o,left:f,top:p}),a.removeChild(i),i==e&&(r=s)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case T.Area:return function(t,e,i,s,n){let r,a=nt(e,t),o=a[0];if(4==o.vertices.length&&i==b&&o.vertices[0].x!==o.vertices[1].x)for(let t of a){let e=t.vertices[1];t.vertices[1]=t.vertices[3],t.vertices[3]=e}let h,l=n.getFieldSummary(s).unique.map((t=>new Mt(n).cross(s,t)));for(let s of a){let a=t.collection();null==h&&(h=a.id),a.classId=h,a.dataScope=s.dataScope?s.dataScope:new Mt(n);let o=s.parent;o.addChild(a);let c=s.left,d=s.top,u=i==b?s.width/l.length:s.width,f=i==b?s.height:s.height/l.length;for(let t=0;t<l.length;t++){let t=s.duplicate();t.classId=e.id,t.resizeArea(u,f),a.addChild(t)}o.removeChild(s);for(let t=0;t<a.children.length;t++){let e=a.children[t];e.dataScope?e.dataScope=e.dataScope.merge(l[t]):e.dataScope=l[t];for(let t of e.vertices)t.dataScope?t.dataScope=e.dataScope.merge(t.dataScope):t.dataScope=e.dataScope}a.layout=new Pt({orientation:i,left:c,top:d}),s==e&&(r=a)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case T.Ring:return function(t,e,i,s,n){let r,a,o=i||x,h=nt(e,t);if(o==x)return h.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/l,f=90;for(let s=0;s<l;s++){let n=t.mark("arc",{innerRadius:i.innerRadius,outerRadius:i.outerRadius,x:i.x,y:i.y,startAngle:Rt(f-u*(s+1)),endAngle:Rt(f-u*s),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}c.layout=Kc("stack",{direction:k.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw G.UNKNOWN_Orientation+": "+o}(t,e,i,a,n);case T.Pie:case T.Arc:return function(t,e,i,s,n){let r,a,o=i||w,h=nt(e,t);if(o==w)return h.forEach((i=>{let o=i.dataScope?i.dataScope:new Mt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent;for(let s=0;s<l;s++){let n=t.mark("arc",{innerRadius:s*i.outerRadius/l,outerRadius:(s+1)*i.outerRadius/l,x:i.x,y:i.y,startAngle:i.startAngle,endAngle:i.endAngle,strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw G.UNKNOWN_Orientation+": "+o}(t,e,i,a,n)}}function Bt(t,e,i,s,n,r,a,o){let h=r?n.transformField(s,r):s,l=n.getFieldType(h);if(l!=A.String&&l!=A.Date&&l!=A.Number)throw new Error(G.DENSIFY_BY_NONCAT+": "+h+" is "+l);if(!sd(e))throw new Error(G.COMPNT_NON_DENSIFIABLE);switch(e.type){case T.Line:return function(t,e,i,s){let n,r=nt(e,t);for(let a of r){let r=a.dataScope?a.dataScope:new Mt(s),o=s.getFieldSummary(i).unique.map((t=>r.cross(i,t)));o=o.filter((t=>!t.isEmpty())),1===o.length&&o.push(o[0].clone());let h=Object.assign({},a.styles);for(let t of K.styles)a[t]&&(h[t]=a[t]);let l=a.vertices[0].x,c=a.vertices[0].y,d=[],u=a.vertices[1].x-l,f=a.vertices[1].y-c;for(let t=0;t<o.length;t++)d.push([l+t*u/(o.length-1),c+t*f/(o.length-1)]);h.vertices=d;let p=t.mark("path",h);p.classId=e.id,p.dataScope=r;let g=a.parent;g.addChild(p),g.removeChild(a);for(let[t,e]of p.vertices.entries())e.dataScope?e.dataScope=e.dataScope.merge(o[t]):e.dataScope=o[t];a==e&&(n=p)}return n}(t,e,h,n);case T.Circle:return function(t,e,i,s,n,r){let a;return nt(e,t).forEach((o=>{let h=o.dataScope?o.dataScope:new Mt(s),l=s.getFieldSummary(i).unique.map((t=>h.cross(i,t)));l=l.filter((t=>!t.isEmpty()));let c=l.length;if(c<3)throw Error(G.INSUFFICIENT_DATA_SCOPES);let d=360/c,u=[],f=[],p="clockwise"==r?-1:1;for(let t=0;t<l.length;t++){let e=n+p*t*d;f[t]=e;let i=Ct(o.x,o.y,o.radius,f[t]);u.push(i)}let g=t.mark("polygon",{x:o.x,y:o.y,radius:o.radius,vertices:u});g.dataScope=h,g.styles=Object.assign({},o.styles);for(let t of K.styles)o[t]&&(g[t]=o[t]);let _=o.parent;_.addChild(g),_.removeChild(o);for(let[t,e]of g.vertices.entries())e.polarAngle=f[t],e.dataScope?e.dataScope=e.dataScope.merge(l[t]):e.dataScope=l[t];o==e&&(a=g)})),a}(t,e,h,n,a,o);case T.Rect:case T.Area:return function(t,e,i,s,n){let r,a=nt(e,t);for(let o of a){let a=n.getFieldType(s),h=o.dataScope?o.dataScope:new Mt(n),l=n.getFieldSummary(s).unique.map((t=>h.cross(s,t)));l=a==A.Number?l:l.filter((t=>!t.isEmpty())),1===l.length&&l.push(l[0].clone()),a!=A.Number&&a!=A.Date||l.sort(((t,e)=>t._field2value[s]>e._field2value[s]?1:-1));let c=Object.assign({},o.styles),d=o.vertices[0].x,u=o.vertices[0].y,f=o.vertices[o.vertices.length-2].x,p=o.vertices[o.vertices.length-2].y,g=[],_=f-d,m=p-u;for(let t=0;t<l.length;t++)g.push(i==v?[f,u+(l.length-1-t)*m/(l.length-1)]:[d+t*_/(l.length-1),u]);for(let t=0;t<l.length;t++)g.push(i==v?[d,u+t*m/(l.length-1)]:[d+(l.length-1-t)*_/(l.length-1),p]);c.vertices=g;let y=t.mark("area",c);y.classId="area"==o.type?o.classId:"area"+o.classId.substring(9),y.dataScope=h,y.orientation=i,y.baseline=i===b?C.Bottom:C.Left;let x=o.parent;x.addChild(y),x.removeChild(o);for(let[t,e]of y.vertices.entries())t>=l.length?e.dataScope=h.merge(l[2*l.length-1-t]):e.dataScope=h.merge(l[t]);o==e&&(r=y)}return r}(t,e,i,h,n)}}class Lt extends Q{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}set height(t){this.resize(this.width,t)}set width(t){this.resize(t,this.height)}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}resize(t,e,i,s){"right"===i?(this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x),"top"===s?(this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y),this._updateBounds()}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class Dt extends Q{constructor(t){super(t),this.attrs.x="x"in t?t.x:0,this.attrs.y="y"in t?t.y:0,this.attrs.radius="radius"in t?t.radius:100}get radius(){return this.attrs.radius}get x(){return this.attrs.x}get y(){return this.attrs.y}get area(){return Math.PI*Math.pow(this.radius,2)}set x(t){this.attrs.x=t,this._updateBounds()}set y(t){this.attrs.y=t,this._updateBounds()}set radius(t){this.attrs.radius=t,this._updateBounds()}set area(t){this.attrs.radius=Math.sqrt(t),this._updateBounds()}resize(t,e,i,s){let n=Math.min(t,e)/2,r=n-this.attrs.radius;this.attrs.radius=n,"right"==i?this.attrs.x-=r:this.attrs.x+=r,"top"==s?this.attrs.y+=r:this.attrs.y-=r,this._updateBounds()}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this.attrs.x-this.attrs.radius,this.attrs.y-this.attrs.radius,2*this.attrs.radius,2*this.attrs.radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t.attrs.x=this.attrs.x,t.attrs.y=this.attrs.y,t.attrs.radius=this.attrs.radius}getSVGPathData(){return["M",this.x,this.y,"m",-this.radius,", 0 a",this.radius,",",this.radius,"0 1,0",2*this.radius,",0 a",this.radius,",",this.radius,"0 1,0",-2*this.radius,",0"].join(" ")}}function jt(t){return t._query=function(){this.data=[];let t=this.field,e=this.items,i=this.aggregator;switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case A.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,i)))}},t._map=function(){let t,e=this.items,i=this.data,s=this.channel;if(t=Zc(this.scaleType),null==this.data.find((t=>t<0))||"width"!=s&&"height"!=s||0!=e[0].type.indexOf("rect")){let n,r;t.domain=[0,Math.max(...i)],"radius"==s||"outerRadius"==s||"innerRadius"==s?(n=0,r=Math.max(...e.map((t=>t[s]))),r<20&&(r=20)):"area"==s?(n=0,r=Math.max(...e.map((t=>t.bounds.width*t.bounds.height))),r<400&&(r=400)):"fontSize"==s?(n=2,r=Math.max(...e.map((t=>parseFloat(t.styles.fontSize))))):"strokeWidth"==s?(n=1,r=Math.max(...e.map((t=>parseFloat(t.styles.strokeWidth)))),r==n&&(r=n+5)):(n=0,r=Math.max(...e.map((t=>t.bounds[s])))),this.rangeExtent&&(r=n+this.rangeExtent),this.range&&(n=this.range[0],r=this.range[1]),t._setRange([n,r])}else this._rectNegativeValues=!0,t.domain=[Math.min(...i),Math.max(...i)],"width"==s?t._setRange([0,this.rangeExtent?this.rangeExtent:Math.max(...e.map((t=>t.width)))]):t._setRange([0,this.rangeExtent?this.rangeExtent:Math.max(...e.map((t=>t.height)))]);this.scale||(this.scale=t),this.scale._addEncoding(this)},t._apply=function(){if("radius"==this.channel||"outerRadius"==this.channel||"innerRadius"==this.channel){for(let t=0;t<this.items.length;t++){this.items[t][this.channel]=this.scale.map(this.data[t])}this.scene._relayoutAncestors(this.anyItem,this.items)}else if(this._rectNegativeValues){let t=Math.max(...this.data),e=Math.min(...this.data),i="width"===this.channel?Math.min(...this.items.map((t=>t.bounds.left))):Math.min(...this.items.map((t=>t.bounds.top)))+this.scale.rangeExtent,s="width"===this.channel?"right":"top",n="width"===this.channel?"left":"bottom";for(let r=0;r<this.items.length;r++){let a,o=this.items[r];if(o.parent&&o.parent.type===T.Collection){let t=o.parent.parent;if(t.type===T.Collection&&t.layout&&t.layout.type===y.Grid){let e=t.children.indexOf(o.parent);a=t.layout.cellBounds[e][n]}else a=o.parent.refBounds[n]}else a=i;"width"===this.channel?(o.leftSegment._doTranslate(a+this.scale.map(0)-o.leftSegment.vertex1.x,0),o.rightSegment._doTranslate(a+this.scale.map(this.data[r])-o.rightSegment.vertex1.x,0)):(o.topSegment._doTranslate(0,a-this.scale.map(this.data[r])-o.topSegment.vertex1.y),o.bottomSegment._doTranslate(0,a-this.scale.map(0)-o.bottomSegment.vertex1.y)),o._updateBounds(),this.data[r]>0?(o.boundsOffsets[s]=this.scale.map(t)-this.scale.map(this.data[r]),o.boundsOffsets[n]=this.scale.map(0)-this.scale.map(e)):(o.boundsOffsets[n]=this.scale.map(this.data[r])-this.scale.map(e),o.boundsOffsets[s]=this.scale.map(t)-this.scale.map(0))}}else if("area"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=Math.sqrt(this.scale.map(this.data[t]));e.resize(i,i)}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("fontSize"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.fontSize=i+"px"}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("strokeWidth"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.strokeWidth=i}this.scene._relayoutAncestors(this.anyItem,this.items)}else{let t="left",e="bottom";if(this.anyItem.parent&&this.anyItem.parent.type==T.Glyph){let i=this.anyItem.parent.children;1==It(i.map((t=>t.bounds.right))).length&&(t="right"),1==It(i.map((t=>t.bounds.top))).length&&(e="top")}if(this.anyItem.type===T.Collection&&this.anyItem.layout&&this.anyItem.layout[this.channel])for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.layout[this.channel]=i}else for(let i=0;i<this.items.length;i++){let s=this.items[i],n=this.scale.map(this.data[i]),r="width"==this.channel?n:s.bounds.width,a="height"==this.channel?n:s.bounds.height;s.resize(r,a,t,e)}this.scene._relayoutAncestors(this.anyItem,this.items)}},t.run(),t}function Vt(t){return t._query=function(){this.data=[],this.areas=nt(this.items[0],this.scene);let t=this.areas.length;this.areaNum=t,this._vertices=[],this.indicator=[];for(let t of this.areas)for(let e=0;e<t.vertices.length;e++)this._vertices.push(t.vertices[e]),e<t.vertices.length/2?this.indicator.push(1):this.indicator.push(0);let e=this.field,i=this._vertices.map((t=>t.dataScope));switch(this.datatable.getFieldType(e)){case A.Boolean:break;case A.Date:this.data=i.map((t=>t.getFieldValue(e)));break;case A.String:this.data=i.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)));break;default:"x"==this.channel||"y"==this.channel?this.data=i.map((t=>t._field2value[e])):this.data=i.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)))}},t._map=function(){"fillGradient"===this.channel?this._mapToGradient():"width"!=this.channel&&"height"!=this.channel||this._mapToSize()},t._mapToGradient=function(){if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=Zc("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=Zc("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=Zc("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}this.scale._addEncoding(this)},t._mapToSize=function(){let t,e,i;switch(this.datatable.getFieldType(this.field)){case A.Boolean:break;case A.Date:t=Zc("time"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=[e,i];break;case A.String:t=Zc("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=this._includeZero||e<0?[0,i]:[e,i];break;default:t=Zc("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=e<0?[0,i]:[e,i]}let s,n=Tt(this.areas[0]),r=rt(this.anyItem);if(r){let t=r.cellBounds;s="width"==this.channel||"height"==this.channel?n==v?t[0].width:t[0].height:n==v?t[0].height:t[0].width}else s="width"==this.channel?Math.max(...this.areas.map((t=>t.bounds.width))):Math.max(...this.areas.map((t=>t.bounds.height)));this.rangeExtent&&(s=this.rangeExtent),e<0?(t._scale.domain([e,i]),t._setRange([0,s])):t._setRange([0,s]),this.scale?this.scale._merge(t):this.scale=t,this.scale._addEncoding(this)},t._apply=function(){"fillGradient"===this.channel?this._applyToGradient():"width"!=this.channel&&"height"!=this.channel||this._applyToSize()},t._applyToGradient=function(){let t=0;for(let e of this.areas){let i=this.data.slice(t,t+e.vertices.length),s=Math.min(...i),n=Math.max(...i),r="horizontal"===e.orientation?Xc({x1:0,y1:100,x2:0,y2:0}):Xc({x1:0,y1:0,x2:100,y2:0});if(r.addStop(0,this.scale.map(s),1),this._mapping){let t=Object.keys(this._mapping).map((t=>parseFloat(t))).sort();for(let e of t)e>s&&e<n&&r.addStop(100*(e-s)/(n-s),this.scale.map(e),1)}else"divergingColor"===this.scale.type&&r.addStop(100*-s/(n-s),this.scale.map(0),1);r.addStop(100,this.scale.map(n),1),e.fillColor=r,t+=e.vertices.length}},t._applyToSize=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);let i=this.areas[0].orientation;if("width"===e||"height"===e){if(rt(this.areas[0])){let t=0,e=this.areas.map((t=>at(t))),s=this.areas.map((t=>rt(t)));for(let[n,r]of this.areas.entries()){let a=e[n],o=s[n];for(let e=0;e<r.vertices.length;e++){let s,n,h=this._vertices[e+t];if(i===b)if(s=0,o.type===y.Stack)n=a.bottom-this.scale.map(this.data[e+t])-h.y;else if(o.type===y.Grid){switch(r.baseline){case"top":n=a.top+this.scale.map(this.data[e+t])-h.y;break;case"bottom":n=a.bottom-this.scale.map(this.data[e+t])-h.y;break;case"middle":{let i=r.vertices.length-1-e,s=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));n=this.indicator[e+t]?a.middle-s/2-h.y:a.middle+s/2-h.y;break}}}else n=0;else if(n=0,o.type===y.Stack)s=a.left+this.scale.map(this.data[e+t])-h.x;else if(o.type===y.Grid){switch(r.baseline){case"left":s=a.left+this.scale.map(this.data[e+t])-h.x;break;case"right":s=a.right-this.scale.map(this.data[e+t])-h.x;break;case"center":{let i=r.vertices.length-1-e,n=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));s=this.indicator[e+t]?a.center-n/2-h.x:a.center+n/2-h.x;break}}}else s=0;h._doTranslate(s,n)}t+=r.vertices.length}}else{let t="center"==this.areas[0].baseline||"middle"==this.areas[0].baseline,e=0,s=i==v?"left":"bottom",n=i==i==v?"right":"top";for(let t of this.areas){for(let s=e;s<e+t.vertices.length;s++){let e=this._vertices[s],n=i==v?t.baseline!==C.Right?t.bounds.left-t.boundsOffsets.left:t.bounds.right+t.boundsOffsets.right:t.baseline!=C.Top?t.bounds.bottom+t.boundsOffsets.bottom:t.bounds.top-t.boundsOffsets.top,r=i==v?t.baseline!==C.Right?n+this.scale.map(this.data[s])-e.x:n-this.scale.map(this.data[s])-e.x:0,a=i==v?0:t.baseline!=C.Top?n-this.scale.map(this.data[s])-e.y:n+this.scale.map(this.data[s])-e.y;e._doTranslate(r,a)}let r=this.data.slice(e,e+t.vertices.length),a=Math.min(...r),o=Math.max(...r);t.boundsOffsets[n]=this.scale.map(Math.max(...this.data))-this.scale.map(o),t.boundsOffsets[s]=this.scale.map(a)-this.scale.map(Math.min(...this.data)),e+=t.vertices.length}if(1==t){let t=this._vertices.length/this.areaNum,e=ct(this._vertices),s=i==v?Math.min(...e.map((t=>t.bounds.x))):Math.max(...e.map((t=>t.bounds.y)));for(let e=0;e<this.areaNum;e++)for(let n=0;n<t/2;n++){let r=e*t+n,a=(e+1)*t-n-1,o=this._vertices[r],h=this._vertices[a],l=i==v?o.x-h.x:h.y-o.y,c=i==v?s+l/2-o.x:0,d=i==v?0:s+l/2-o.y,u=i==v?s-l/2-h.x:0,f=i==v?0:s-l/2-h.y;o._doTranslate(c,d),h._doTranslate(u,f)}}}}for(let t of this.areas)t._updateBounds();"width"!=e&&"height"!=e||this.scene._relayoutAncestors(this.areas[0],this.areas)},t.run(),t}class Gt{constructor(t,e,i,s,n){this.items=t,this.anyItem=this.items[0],this.scene=e,this.channel=i,this.field=s,this._aggregator=n.aggregator,this.datatable=n.datatable,this.scale=n.scale,this.scale?(this._flipScale=this.scale.isFlipped,this.scaleType=this.scale.type,this._includeZero=this.scale.includeZero):(this._flipScale=n.flipScale,this.scaleType=n.scaleType,this._includeZero=n.includeZero),this._mapping=n.mapping,this.rangeExtent=n.rangeExtent,this._scheme=n.scheme,this.range=n.range,"angle"==this.channel&&(this.startAngle="startAngle"in n?n.startAngle:90),this._query=void 0,this._map=void 0,this._apply=void 0}get id(){return["enc",lt(this.anyItem),this.channel,this.field].join("-")}set aggregator(t){this._aggregator=t,this.run()}get aggregator(){return this._aggregator}toJSON(){let t={};return t.anyItem=this.anyItem.id,t.items=this.items.map((t=>t.id)),this.data&&(t.data=this.data),this._rectNegativeValues&&(t._rectNegativeValues=!0),t.args={},t.args.channel=this.channel,t.args.field=this.field,t.args.aggregator=this.aggregator,t.args.datatable=this.datatable.id,t.args.scale=this.scale.id,t.args.mapping=this._mapping,t.args.rangeExtent=this.rangeExtent,t.args.scheme=this._scheme,t.args.scaleType=this.scaleType,t.args.range=this.range,"angle"==this.channel&&(t.args.startAngle=this.startAngle),t}run(){this._query(),this._map(),this._apply()}get dataTable(){return this.datatable}_inferTickValues(){let t,e=this,i=e.scale.domain,s=e.scale.range;switch(e.scale.type){case"linear":case"log":{let r=Math.abs(s[0]-s[1]);if("width"==e.channel||"height"==e.channel){let t=ht(e.anyItem,"stack");if(t){let s=nt(t.group,e.scene);r=Math.max(...s.map((t=>t.refBounds[e.channel]))),i[1]=e.scale.invert(r)}}t="width"==e.channel||"x"==e.channel?45:30;let a,o=Math.max(2,Math.floor(r/t));if("log"===e.scale.type){a=[];let t=e.scale._scale.ticks();for(let e of t){let i=Math.log(e)/Math.log(10)+1e-6;Math.abs(i-Math.floor(i))<o/t.length&&a.push(e)}}else a=n.ticks(i[0],i[1],o);return a}case"point":{t="width"==e.channel||"x"==e.channel?80:30;let s=Math.floor(e.scale.rangeExtent/i.length),n=Math.ceil(t/s);return"x"==e.channel?i.filter(((t,e)=>e%n==0)):i}case"time":{t="width"==e.channel||"x"==e.channel?80:30;let r,a,o=Math.floor((s[1]-s[0])/t),h=Math.ceil((i[1]-i[0])/o)/1e3,l=[1,60,3600,86400,2628003,31536e3],c=[n.timeSeconds,n.timeMinutes,n.timeHours,n.timeDays,n.timeMonths,n.timeYears];for(let t=0;t<l.length-1;t++)if(h>=l[t]&&h<l[t+1])return r=Math.floor(h/l[t]),a=c[t],a(i[0],i[1],r);return h>l[l.length-1]?(r=Math.floor(h/l[l.length-1]),a=c[l.length-1],a(i[0],i[1],r)):[]}default:return[]}}getScaleRange(t){let e=t||this.anyItem;if(e.type!=T.Area&&("vertex"!=e.type||e.parent.type!=T.Area)){if("x"==this.channel){let t=rt(e);if(t&&t.type==y.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].left+this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}{let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}}if("y"==this.channel){let t=rt(e);if(t&&t.type==y.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].bottom,i[s].bottom-this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}{let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}}if("width"==this.channel){let t=ht(e);if("grid"===t.type){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].right]}if("stack"===t.type&&"horizontal"==t.orientation)return[t.group.bounds.left,t.group.bounds.right];{let t=nt(e,this.scene),i=Math.min(...t.map((t=>t.bounds.left)));return[i,i+this.scale.rangeExtent]}}if("height"==this.channel){let t=kt(e);if(t&&t.layout&&["grid","stack"].indexOf(t.layout.type)>=0){let i=t.layout.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent===t||e.parent.parent===t));return[i[s].bottom,i[s].bottom-i[s].height]}{let t=nt(e,this.scene),i=Math.max(...t.map((t=>t.refBounds.bottom)));return[i,i-this.scale.rangeExtent]}}if("radialDistance"==this.channel){let t=e.parent;return[t.x,t.x+this.scale.rangeExtent]}return this.scale.range}{let t,i=e.type==T.Area?e:e.parent,s=Tt(i),n=rt(i);t=n?s==v?n.horzCellAlignment===C.Left:n.vertCellAlignment===C.Bottom:s==v?i.baseline==C.Left:i.baseline==C.Bottom;let r=ot(i);if(r)switch(this.channel){case"x":return[r.left,r.left+this.scale.rangeExtent];case"width":return t?[r.left,r.left+this.scale.rangeExtent]:[r.right,r.right-this.scale.rangeExtent];case"y":return[r.bottom,r.bottom-this.scale.rangeExtent];case"height":return t?[r.bottom,r.bottom-this.scale.rangeExtent]:[r.top+this.scale.rangeExtent,r.top]}else if(n&&"stack"===n.type)switch(r=n.group.bounds,this.channel){case"x":return[r.left,r.left+this.scale.rangeExtent];case"width":return t?[r.left,r.left+this.scale.rangeExtent]:[r.right,r.right-this.scale.rangeExtent];case"y":return[r.bottom,r.bottom-this.scale.rangeExtent];case"height":return t?[r.bottom,r.bottom-this.scale.rangeExtent]:[r.top+this.scale.rangeExtent,r.top]}if(s==b)switch(this.channel){case"width":case"height":{let e=this._vertices,i=t?Math.max(...e.map((t=>t.y))):Math.min(...e.map((t=>t.y)));return t?[i,i-this.scale.rangeExtent]:[i+this.scale.rangeExtent,i]}case"x":case"y":{let t=nt(i.firstVertex,this.scene),e=Math.min(...t.map((t=>t.x)));return[e,e+this.scale.rangeExtent]}}else if(s==v)switch(this.channel){case"x":case"y":{let t=nt(i.firstVertex,this.scene),e=Math.max(...t.map((t=>t.y)));return[e,e-this.scale.rangeExtent]}case"height":case"width":{let e=nt(i.firstVertex,this.scene),s=t?Math.min(...e.map((t=>t.x))):Math.max(...e.map((t=>t.x)));return t?[s,s+this.scale.rangeExtent]:[s-this.scale.rangeExtent,s]}}}}}function zt(t,e,i){return e.map((e=>[e,n.mean(i,(i=>t(e-i)))]))}function Wt(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}function Ut(t,e){if("field"in e){let i=e.field;if("value"in e)return t[i]==e.value;if("range"in e)return t[i]>=e.range[0]&&t[i]<=e.range[1];if("values"in e)return e.values.indexOf(t[i])>=0}else if("fields"in e){let i=e.fields[0],s=e.fields[1],n=t[i],r=t[s];switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}return!1}}class qt{constructor(t,e,i){if(this.url=e,this.id=T.DataTable+mt[T.DataTable]++,this.data=t,this.rawData=JSON.parse(JSON.stringify(t)),this._dateMap=new Map,this._fields=Object.keys(this.data[0]),this._newField=0,i)this._fieldTypes=i;else{this._fieldTypes={};for(let t of this._fields)this._fieldTypes[t]=Ht(this.data.map((e=>e[t]))),"year"==t.toLowerCase()&&this._fieldTypes[t]==A.Integer&&(this._fieldTypes[t]=A.Date)}this._validate(this.data,this._fieldTypes),this._fieldSummaries={};for(let t of this._fields)this._fieldSummaries[t]=Yt(this.data.map((e=>e[t])),this._fieldTypes[t]);this._fields.indexOf(h)<0&&this._addField(h,A.String,this.data.map(((t,e)=>"r"+e)))}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),i=t.substring(e);0!==i.indexOf("\\")&&0!==i.indexOf("/")||(i=i.substring(1));return i}(this.url):this.id}set sourceDataTable(t){this._sourceDataTable=t}get sourceDataTable(){return this._sourceDataTable}getEncodableFields(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.numericFields.concat(this.nonNumericFields);case"area":case"strokeWidth":default:return this.numericFields}}toJSON(){let t={};return t.data=this.rawData,t.fieldTypes=this._fieldTypes,t.url=this.url,t.id=this.id,t.sourceDataTable=this._sourceDataTable,t.transform=this._transform,t.dateMap={},t}transformField(t,e,i){let s=this.data.map((i=>e(i[t]))),n=Ht(s),r=i||Date.now()+"_field"+this._newField++;return this._addField(r,n,s),r}setValueOrder(t,e){this._fieldSummaries[t].unique=e}_addField(t,e,i){this.data.forEach(((e,s)=>e[t]=i[s])),this._fieldTypes[t]=e,this._fields.push(t),this._fieldSummaries[t]=Yt(i,e)}getFieldType(t){return this._fieldTypes[t]}get fields(){return this._fields}getFieldSummary(t){return this._fieldSummaries[t]}getFieldValues(t){return this.data.map((e=>e[t]))}getUniqueFieldValues(t){return this._fieldSummaries[t].unique}getRowCount(){return this.data.length}hasField(t){return this._fields.indexOf(t)>=0}parseFieldAsDate(t,e){let i=n.timeParse(e);for(let e of this.data){let s=e[t];null==s||null==s?(s="",e[t]=new Date(1899,11,31).getTime()):e[t]=i(s).getTime(),this._dateMap.set(e[t],s)}this._fieldTypes[t]=A.Date,this._fieldSummaries[t]=Yt(this.data.map((e=>e[t])),A.Date)}getRawValue(t,e){return this.getFieldType(t)===A.Date?this._dateMap.get(e).toString():e}static get RowID(){return h}get nonNumericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!=A.Number&&this._fieldTypes[e]!=A.Integer&&e!=qt.RowID&&t.push(e);return t.sort(((t,e)=>this.getUniqueFieldValues(t).length-this.getUniqueFieldValues(e).length)),t}get numericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!==A.Number&&this._fieldTypes[e]!==A.Integer||e==qt.RowID||t.push(e);return t}getFieldsByType(t){let e=[];for(let i in this._fieldTypes)this._fieldTypes[i]===t&&i!=qt.RowID&&e.push(i);return e}transform(t,e,i){let s=i||{};switch(t){case"kde":return function(t,e,i){let s=e[0],n=t.nonNumericFields,r={};for(let e of t.data){let t=n.map((t=>String(e[t]))).join("_");t in r||(r[t]=n.map((t=>e[t])),r[t].push([])),r[t][r[t].length-1].push(e[s])}let a="min"in i?i.min:t.getFieldSummary(s).min,o="max"in i?i.max:t.getFieldSummary(s).max,h=a,l=[];for(;h<o;)l.push(h),h+=i.interval;l.push(h);let c=[];for(let t in r){let e=r[t].pop(),a=zt(Wt(i.bandwidth),l,e);for(let e of a){let i={};r[t].forEach(((t,e)=>i[n[e]]=t)),i[s]=e[0],i[s+"_density"]=e[1],c.push(i)}}let d={};return n.forEach((e=>d[e]=t.getFieldType(e))),d[s]=A.Number,d[s+"_density"]=A.Number,new qt(c,t.url,d)}(this,e,s);case"bin":return function(t,e,i){let s=e[0],r=t.nonNumericFields,a={};for(let e of t.data){let t=r.map((t=>String(e[t]))).join("_");a.hasOwnProperty(t)||(a[t]=r.map((t=>e[t])),a[t].push([])),a[t][a[t].length-1].push(e[s])}let o=[];for(let t in a){let e=a[t].pop(),i=n.bin()(e);for(let e of i){let i={};a[t].forEach(((t,e)=>i[r[e]]=t)),i.x0=e.x0,i.x1=e.x1,i[s+"_count"]=e.length,o.push(i)}}let h={};r.forEach((e=>h[e]=t.getFieldType(e))),h.x0=A.Number,h.x1=A.Number,h[s+"_count"]=A.Number;let l=new qt(o,t.url,h);return l.sourceDataTable=t,l.transform={type:"bin",args:e},l}(this,e);case"sort":return function(t,e,i){t.data.sort(((t,i)=>function(t,e,i,s){for(let s of i){if(t[s]<e[s])return-1;if(t[s]>e[s])return 1}return 0}(t,i,e))),t.summarize()}(this,e);case"filter":return function(t,e){let i=[];for(let s of t.data){let t=!0;for(let i of e)if(!Ut(s,i)){t=!1;break}t&&i.push(s)}let s=new qt(i,t.url);return s.sourceDataTable=t,s.transform={type:"filter",args:e},s}(this,e)}}summarize(){for(let t of this._fields)this._fieldSummaries[t]=Yt(this.data.map((e=>e[t])),this._fieldTypes[t])}_validate(t,e){for(let i of t)for(let t in e){let s,n=e[t],r=i[t];if(null==i[t]||null==i[t])switch(n){case A.Boolean:s=!1;break;case A.Date:s=new Date(1899,11,31).getTime();break;case A.String:s="";break;default:s=0}else switch(n){case A.Boolean:s=r;break;case A.Date:s=Number.isInteger(r)?new Date(r,0).getTime():new Date(r+"").getTime(),this._dateMap.set(s,r);break;case A.String:s=r.toString();break;default:s=r}i[t]=s}}}function Yt(t,e){var i={};switch(e){case A.Boolean:i.trueCount=t.filter((t=>t)).length,i.falseCount=t.filter((t=>!t)).length;break;case A.Date:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.unique=[...new Set(t)];break;case A.String:i.unique=[...new Set(t)];break;default:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.mean=n.mean(t),i.median=n.median(t),i.unique=[...new Set(t)]}return i}var Jt={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return Jt.number(t)&&(t=+t)==~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function Ht(t){var e=Object.values(A);for(let i=0;i<t.length;i++){let s=t[i];if(null!=s){for(let t=0;t<e.length;t++)Jt[e[t]](s)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}class $t extends H{constructor(t){super(t),this.type=T.PointText,this.attrs.x=0,this.attrs.y=0,"fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),void 0!==t&&("x"in t&&(this.attrs.x=t.x),"y"in t&&(this.attrs.y=t.y),this.attrs.text="text"in t?t.text:"",this.attrs.anchor="anchor"in t?t.anchor:["center","middle"]),this._updateBounds()}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this.attrs.x,t.y=this.attrs.y,t.text=this.text,t.anchor=[this.anchor[0],this.anchor[1]]}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this.bounds}set text(t){this.attrs.text=t,this._updateBounds()}get text(){return this.attrs.text}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){let t,e,i=function(t,e,i){let s=bt.getContext();s.font=e;let n=s.measureText(t);return n.fontBoundingBoxAscent?{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}:n.actualBoundingBoxAscent?{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}:{width:n.width,height:i}}(this.attrs.text,[this.fontWeight,this.styles.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),s=i.width,n=i.height;switch(this.attrs.anchor[0]){case"left":t=this.attrs.x;break;case"right":t=this.attrs.x-s;break;case"center":t=this.attrs.x-s/2;break;default:t=this.attrs.x}switch(this.attrs.anchor[1]){case"top":e=this.attrs.y;break;case"bottom":e=this.attrs.y-n;break;case"middle":e=this.attrs.y-n/2}this._bounds=new a(t,e,s,n)}get center(){return{x:this.bounds.left+this.bounds.width/2,y:this.bounds.top+this.bounds.height/2}}get x(){return this.attrs.x}set x(t){this.attrs.x=t,this._updateBounds()}get y(){return this.attrs.y}set y(t){this.attrs.y=t,this._updateBounds()}get anchor(){return this.attrs.anchor}set anchor(t){this.attrs.anchor=t,this._updateBounds()}get horzAnchor(){return this.attrs.anchor[0]}get vertAnchor(){return this.attrs.anchor[1]}set horzAnchor(t){this.attrs.anchor[0]=t,this._updateBounds()}set vertAnchor(t){this.attrs.anchor[1]=t,this._updateBounds()}get fontSize(){return parseFloat(this.styles.fontSize)}set fontSize(t){this.styles.fontSize="number"==typeof t?t+"px":t,this._updateBounds()}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._updateBounds()}get fontFamily(){return this.styles.fontFamily}set fontFamily(t){this.styles.fontFamily=t,this._updateBounds()}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}}class Zt extends At{constructor(t){super(),this.type=T.Axis,this.id=this.type+mt[this.type]++,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor?t.tickAnchor:"middle",this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelOffset="labelOffset"in t?t.labelOffset:15,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,"titleAnchor"in t?this._titleAnchor=t.titleAnchor:"x"==this.channel||"width"==this.channel?this._titleAnchor="top"==this._orientation?["center","bottom"]:["center","top"]:this._titleAnchor="left"==this._orientation?["right","middle"]:["left","middle"],this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._titlePosition=t.titlePosition,this._labelRotation="labelRotation"in t?t.labelRotation:0}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.field=this._field,t.channel=this._channel,"args"in t||(t.args={}),t.args.orientation=this._orientation,t.args.strokeColor=this._strokeColor,t.args.textColor=this._textColor,t.args.tickOffset=this._tickOffset,t.args.tickSize=this._tickSize,t.args.tickAnchor=this._tickAnchor,t.args.tickVisible=this._tickVisible,t.args.pathVisible=this._pathVisible,t.args.labelOffset=this._labelOffset,t.args.labelFormat=this._labelFormat,this._labelRotation&&(t.args.labelRotation=this._labelRotation),t.args.showTitle=this._showTitle,t.args.tickValues=this._tickValues,t.args.titleAnchor=this._titleAnchor,t.args.titleOffset=this._titleOffset,t.args.titlePosition=this._titlePosition,t.args.rotateTitle=this._rotateYTitle,t}get field(){return this._field}get channel(){return this._channel}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.reposition()}get pathX(){if("y"==this.channel||"height"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].x;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].x}}set pathX(t){"y"!=this.channel&&"height"!=this.channel||(this._posArg=t),this.reposition()}get pathPosition(){return"x"==this.channel||"width"==this.channel?this.pathY:this.pathX}set pathPosition(t){"x"==this.channel||"width"==this.channel?this.pathY=t:"y"!=this.channel&&"height"!=this.channel||(this.pathX=t)}get pathY(){if("x"==this.channel||"width"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].y;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].y}}set pathY(t){"x"!=this.channel&&"width"!=this.channel||(this._posArg=t),this.reposition()}get tickOffset(){return this._tickOffset}set tickOffset(t){this._tickOffset=t,this._positionTicks()}get titleOffset(){return this._titleOffset}set titleOffset(t){this._titleOffset=t}get tickSize(){return this._tickSize}set tickSize(t){this._tickSize=t,this._positionTicks()}set tickValues(t){this._tickValues=t,this._generateTicks(),this._positionTicks()}get tickValues(){return this._tickValues}set labelValues(t){this._labelValues=t,this._generateLabels(),this._positionLabels()}get labelValues(){return this._labelValues}get tickAnchor(){return this._tickAnchor}set tickAnchor(t){this._tickAnchor=t}get tickVisible(){return this._tickVisible}set tickVisible(t){this._tickVisible=t;for(let e of this._ticks.children)e.visibility=t?"visible":"hidden"}get pathVisible(){return this._pathVisible}set pathVisible(t){this._pathVisible=t;let e=[];this._path&&e.push(this._path),this._rules&&this._rules.children.forEach((t=>e.push(t)));for(let i of e)i.visibility=t?"visible":"hidden"}get labelOffset(){return this._labelOffset}set labelOffset(t){this._labelOffset=t,this._positionLabels()}get labelFormat(){return this._labelFormat}set labelFormat(t){this._labelFormat=t,this._generateLabels(),this._positionLabels()}get labelRotation(){return this._labelRotation}set labelRotation(t){if(this._labelRotation=t,this._labels&&this._labels.children){let e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(t)for(let t of this._labels.children)t._rotate=[this._labelRotation,t.x,t.y],t.anchor=["right",e[1]];else for(let t of this._labels.children)t._rotate=void 0}}get showTitle(){return this._showTitle}set showTitle(t){this._showTitle=t,this._title||(this._generateTitle(),this._positionTitle()),this._title.visibility=t?"visible":"hidden"}get titleAnchor(){return this._titleAnchor}set titleAnchor(t){this._titleAnchor=t}get titlePosition(){return this._titlePosition}set titlePosition(t){this._titlePosition=t}get rotateTitle(){return this._rotateYTitle}set rotateTitle(t){this._rotateYTitle=t}get title(){return this._titleText}set title(t){this._titleText=t}get includeZero(){return!!this.encoding&&this.encoding.scale.includeZero}set includeZero(t){this.encoding&&(this.encoding.scale.includeZero=t)}_generatePath(){}_generateTicks(){}_generateLabels(){}_generateTitle(){this._title=new $t({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title.id=this.id+"-title",this.addChild(this._title)}_positionPath(){}_positionTicks(){}_positionLabels(){}_positionTitle(){}matches(t){}reposition(){this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle(),"radialDistance"===this._channel&&this._rotate&&(this._rotate=[this._rotate[0],this._item.parent.x,this._item.parent.y]),this._updateBounds()}}class Kt extends Zt{constructor(t,e,i){super(i),this.encoding=t,this._field=this.encoding.field,this._channel=this.encoding.channel,this._orientation="orientation"in i?i.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?i.pathY:i.pathX,this._position=this._posArg,this._titleText="title"in i?i.title:this.encoding.field,this._item=e,this._ticks=new At,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new At,this._labels.id=this.id+"labels",this.addChild(this._labels),"radialDistance"===this._channel&&"rotation"in i&&(this._rotate=[-i.rotation,this._item.parent.x,this._item.parent.y]),this._showTitle=!("showTitle"in i)||i.showTitle,this._determineAxisFlip(),this._generatePath(),this._positionPath(),this._showTitle&&this._generateTitle(),this._showTitle&&this._positionTitle()}autoUpdateTicks(){let t=this.encoding._inferTickValues();this.tickValues=t,this.labelValues=t}_updateBounds(){this._bounds=this._path.bounds,this._ticks.children.length>0&&(this._bounds=this._bounds.union(this._ticks.bounds)),this._labels.children.length>0&&(this._bounds=this._bounds.union(this._labels.bounds)),this._title&&(this._bounds=this._bounds.union(this._title.bounds))}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"time"===this.encoding.scale.type&&(t.args.isDate=!0),this._rotate&&(t.args.rotation=this._rotate[0]),"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,t}get ticks(){return this._ticks}get labels(){return this._labels}get path(){return this._path}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;this._path.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_generatePath(){this._path=new Q({strokeColor:this._strokeColor}),this._pathVisible||(this._path.visibility="hidden"),this._path.type=T.Line,this._path.id=this.id+"path",this.addChild(this._path)}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new Q({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=T.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this.encoding.datatable.getFieldType(this.encoding.field)){case A.Date:t=n.timeFormat(this._labelFormat);break;case A.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let s=new $t({text:t(i),fontSize:this._fontSize,fillColor:this._textColor});s.id=this.id+"label"+e,this._labels.addChild(s)}}_positionPath(){this._range=this.encoding.getScaleRange(this._item),void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg;let t=[];if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].x));t.push([Math.min(...e.concat(this._range)),this._position]),t.push([Math.max(...e.concat(this._range)),this._position])}else if("y"==this._channel||"height"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].y));t.push([this._position,Math.min(...e.concat(this._range))]),t.push([this._position,Math.max(...e.concat(this._range))])}this._path._setVertices(t),this._path._updateBounds(),this._showTitle&&this._title&&this._positionTitle(),this._updateBounds()}_isAlignedLeft(t){switch(t.type){case y.Stack:case y.Grid:return t.horzCellAlignment===C.Left;default:return!0}}_isAlignedBottom(t){switch(t.type){case y.Stack:case y.Grid:return t.vertCellAlignment===C.Bottom;default:return!0}}_determineAxisFlip(){if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){if("width"==this._channel){let t=kt(this._item)?kt(this._item).layout:rt(this._item);if(t)this._flip=!this._isAlignedLeft(t);else if("area"==this._item.type){let t=this._item.baseline==C.Left||this._item.baseline==C.Center||this._item.baseline==C.Middle||null==this._item.baseline;this._flip=!t}}}else if(("y"==this._channel||"height"==this._channel)&&"height"==this._channel){let t=kt(this._item)?kt(this._item).layout:rt(this._item);if(t)this._flip=!this._isAlignedBottom(t);else if("area"==this._item.type){let t=this._item.baseline==C.Bottom||this._item.baseline==C.Center||this._item.baseline==C.Middle||null==this._item.baseline;this._flip=!t}}}_positionLabels(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize,e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._range[1]-this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i])-this.encoding.scale.range[0],s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]])}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize,e="left"==this._orientation?["right","middle"]:["left","middle"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]+this.encoding.scale.map(this._labelValues[i]),s.anchor=e;else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[1],s.anchor=e;else for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[0]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[0],s.anchor=e}this._labels._updateBounds(),this._updateBounds()}_computePosition(){let t;if("vertex"===this._item.type&&!this._item.parent.closed){let t=nt(this._item,this._item.parent.getScene());if("x"===this._channel&&1==It(t.map((t=>t.bounds.middle))).length)return this._item.bounds.middle;if("y"===this._channel&&1==It(t.map((t=>t.bounds.center))).length)return this._item.bounds.center;if("radialDistance"===this._channel)return this._item.parent.y}if(this._item.type!==T.Area&&this._item.parent.type!==T.Area||(t=ot(this._item)),void 0===t){let e=kt(this._item);void 0===e&&(e=wt(this._item)),t=e.bounds}return"x"===this._channel||"width"===this._channel?"top"==this._orientation?t.top-this._tickSize:t.bottom+this._tickSize:"y"===this._channel||"height"===this._channel?"left"==this._orientation?t.left-this._tickSize:t.right+this._tickSize:"radialDistance"===this._channel?this._item.parent.y:void 0}_positionTicks(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,this._range=this.encoding.getScaleRange(this._item),"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position+t]]),i._updateBounds()}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[1]+this.encoding.scale.map(this._tickValues[e])],[this._position,this._range[1]+this.encoding.scale.map(this._tickValues[e])]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries()){let s=this._range[1]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[1];i._setVertices([[this._position+t,s],[this._position,s]]),i._updateBounds()}else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]],[this._position,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]]]),i._updateBounds()}this._positionPath(),this._ticks._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._path.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel||"width"==this._channel?(this._title.x=t.x,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){let e=lt(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(lt(t.anyItem).split("_")[0]===e)return!0}return!1}get isFlipped(){return!!this._flip||!!this.encoding.scale.isFlipped}}class Xt extends Zt{constructor(t,e,i,s,n){super(n),this._channel=i,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._item=t[0],this._items=t,this._mlayout=e,this._field=s,this._titleText="title"in n?n.title:this._field,this._showTitle="showTitle"in n&&n.showTitle,this._ticks=new At,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new At,this._labels.id=this.id+"labels",this.addChild(this._labels),this._rules=new At,this._rules.id=this.id+"paths",this.addChild(this._rules),this._generatePath(),this._generateTicks(),this._generateLabels(),this._showTitle&&this._generateTitle(),this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle()}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,this.classId&&(t.classId=this.classId),t}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;for(let e of this._rules.children)e.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_updateBounds(){this._bounds=this._rules.bounds.clone(),this._bounds=this._bounds.union(this._ticks.bounds),this._bounds=this._bounds.union(this._labels.bounds),this._showTitle&&(this._bounds=this._bounds.union(this._title.bounds))}_generatePath(){if(this._rules.removeAll(),this._mlayout.type==y.Grid){let t="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;for(let e=0;e<t;e++){let t=new Q({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=T.Line,t.id=this.id+"rule"+e,this._rules.addChild(t)}}else if(this._mlayout.type===y.Stack){let t=new Q({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=T.Line,t.id=this.id+"rule",this._rules.addChild(t)}}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._mlayout.group.children.length;t++){let e=new Q({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=T.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this._item.dataScope.getFieldType(this._field)){case A.Date:t=n.timeFormat(this._labelFormat);break;case A.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}let e=this._mlayout.cellBounds;for(let i=0;i<e.length&&!(i>=this._mlayout.group.children.length);i++){let e=this._mlayout.group.children[i],s=new $t({fillColor:this._textColor,fontSize:this._fontSize,text:t(e.dataScope.getFieldValue(this._field))});s.id=this.id+"label"+i,this._labels.addChild(s)}}_positionPath(){if(this._mlayout.type==y.Grid){let t=this._mlayout.cellBounds,e="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;if("x"==this._channel){let i=t[0].left,s=this._mlayout.numCols;for(let n=0;n<e;n++)this._rules.children[n]._setVertices([[i,this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:t[n*s][this._orientation]],[i+t[0].width*s+this._mlayout.colGap*(s-1),this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:t[n*s][this._orientation]]])}else{let i=t[0].top,s=this._mlayout.numRows;for(let n=0;n<e;n++)this._rules.children[n]._setVertices([[this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation],i],[this._posArg?t[n*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation],i+t[0].height*s+this._mlayout.rowGap*(s-1)]])}}else if(this._mlayout.type===y.Stack){let t=this._mlayout.group.bounds;"x"==this._channel?this._rules.children[0]._setVertices([[t.left,this._posArg?this._posArg:t[this._orientation]],[t.right,this._posArg?this._posArg:t[this._orientation]]]):this._rules.children[0]._setVertices([[this._posArg?this._posArg:t[this._orientation],t.top],[this._posArg?this._posArg:t[this._orientation],t.bottom]])}this._rules.children.forEach((t=>t._updateBounds())),this._rules._updateBounds(),this._updateBounds()}_positionTicks(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?1:-1;for(let[i,s]of this._ticks.children.entries()){let n=this._posArg?t[i][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:t[i][this._orientation]+this._tickOffset*e;s._setVertices([[t[i].x,n],[t[i].x,n+e*this._tickSize]]),s._updateBounds()}}else if("y"==this._channel){let e="left"==this._orientation?-1:1;for(let[i,s]of this._ticks.children.entries()){let n=this._posArg?t[i][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:this._mlayout.group.bounds[this._orientation]+this._tickOffset*e,r="middle"==this._tickAnchor?t[i].y:t[i][this._tickAnchor];s._setVertices([[n,r],[n+e*this._tickSize,r]]),s._updateBounds()}}this._ticks._updateBounds(),this._updateBounds()}_positionLabels(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?["center","top"]:["center","bottom"],i="bottom"==this._orientation?this._labelOffset:-this._labelOffset;for(let[s,n]of this._labels.children.entries())n.x=t[s].x,n.y=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+i:t[s][this._orientation]+i,n.anchor=e,this._labelRotation&&(n._rotate=[this._labelRotation,n.x,n.y],n.anchor=["right",e[1]])}else if("y"==this._channel){let e="left"==this._orientation?["right","middle"]:["left","middle"],i="left"==this._orientation?-this._labelOffset:this._labelOffset;for(let[s,n]of this._labels.children.entries())n.x=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+i:this._mlayout.group.bounds[this._orientation]+i,n.y="middle"==this._tickAnchor?t[s].y:t[s][this._tickAnchor],n.anchor=e,this._labelRotation&&(n._rotate=[this._labelRotation,n.x,n.y])}this._labels._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._rules.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel?(this._title.x=t.x,this._titleOffset=this._labels.bounds.height+this._labelOffset+15,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._titleOffset=this._labels.bounds.width+this._labelOffset+15,this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){return lt(this._item).split("_")[0]===lt(t).split("_")[0]}}class Qt extends At{constructor(t,e){super(),this.type=T.Legend,this.id=this.type+mt[this.type]++,this.encoding=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._showTitle=!("showTitle"in e)||e.showTitle,"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._numCols=1,this._orientation="orientation"in e?e.orientation:v,this._initialize()}toJSON(){let t=super.toJSON();return"args"in t||(t.args={}),t.args.textColor=this._textColor,t.channel=this.encoding.channel,t.field=this.encoding.field,t.args.strokeColor=this._strokeColor,t.args.x=this._x,t.args.y=this._y,t.args.orientation=this._orientation,t}get field(){return this.encoding.field}get channel(){return this.encoding.channel}get fieldType(){return this.encoding.datatable.getFieldType(this.field)}_initialize(){let t=this.encoding.scene,e=this.encoding.field;switch(this.encoding.datatable.getFieldType(e)){case A.String:this._createCategoricalColorLegend(t,e);break;case A.Date:case A.Number:case A.Integer:this._createNumericalColorLegend(t,e)}this._updateBounds()}_createNumericalColorLegend(t,e){let i,s,n;if(this._orientation==v?(i=15,s=300):(i=300,s=15),this._showTitle){let s=t.mark("text",{fillColor:this._textColor,text:e,x:this._x+i/2,y:this._y,anchor:["center","middle"]});this.addChild(s),n=20}else n=0;let r,a=t.mark("rect",{top:this._y+n,left:this._x,width:i,height:s,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),o=[Math.min(...this.encoding.data),Math.max(...this.encoding.data)],h=this.encoding.scale.mapping,l=[],c=[];if(h){let e=Object.keys(h).map((t=>parseFloat(t))).sort(((t,e)=>t-e));this._orientation==v?(r=new J({x1:0,y1:100,x2:0,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,h[e],1);let d=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-a*s+n,y2:this._y+s-a*s+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+i+5+5,y:this._y+s-a*s+n,anchor:["left","middle"]});l.push(u)}))):(r=new J({x1:0,y1:0,x2:100,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,h[e],1);let d=t.mark("line",{x1:this._x+a*i,x2:this._x+a*i,y1:this._y+20-5+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+a*i,y:this._y+s+5+n,anchor:["center","top"]});l.push(u)})))}else{let a=this.encoding.scale.domain,o=this.encoding.datatable,h=o.getFieldType(e),d=[],u=h===A.Date?o.getUniqueFieldValues(e):It(this.encoding.data);if(u.length<=10)d=u,d.sort(((t,e)=>t-e));else if(h===A.Date){u.sort(((t,e)=>t-e));for(let t=0;t<u.length;t+=Math.ceil(u.length/10))d.push(u[t])}else{let t=(a[1]-a[0])/9;for(let e=0;e<10;e++)d.push(a[0]+e*t);let e=0;for(;t<1;)t*=10,e++;d=d.map((t=>t.toFixed(e)))}this._orientation==v?(r=new J({x1:0,y1:100,x2:0,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-u*s+n,y2:this._y+s-u*s+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:h===A.Date?o.getRawValue(e,d):d,x:this._x+i+5+5,y:this._y+s-u*s+n,anchor:["left","middle"]});l.push(p)}))):(r=new J({x1:0,y1:0,x2:100,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+u*i,x2:this._x+u*i,y1:this._y+s+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:h===A.Date?o.getRawValue(e,d):d,x:this._x+u*i,y:this._y+s+5+n,anchor:["center","top"]});l.push(p)})))}a.styles.fillColor=r,this.addChild(a);for(let t of l)this.addChild(t);for(let t of c)this.addChild(t)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.setTextColor(this)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.removeAll(),this._initialize()}setTextColor(t){if(t.children&&0!==t.children.length)for(let e of t.children)e.type===T.PointText?e.fillColor=this._textColor:e.children&&e.children.length>0&&this.setTextColor(e)}_createCategoricalColorLegend(t,e){let i=0;this._showTitle&&(this.addChild(new $t({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),i=parseFloat(this._fontSize)+5);let s=t.mark("rect",{top:this._y+2+i,left:this._x,width:10,height:10,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),n=t.mark("text",{fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+i,anchor:["left","top"]}),r=t.glyph(s,n),a=this.encoding.scale,o=new qt(a.domain.map((t=>({category:t,value:a.map(t)})))),h=t.repeat(r,o);t.encode(n,{channel:"text",field:"category",_remember:!1}),t.encode(s,{channel:"fillColor",field:"category",_remember:!1,scale:a}),h.layout=Kc("grid",{numCols:this._numCols,numRows:this._numRows}),this.addChild(h)}pathHitTest(t,e){let i=ft(this);for(let s=i.length-1;s>=0;s--){let n=i[s];if(_t(n)&&n.contains(t,e))return n}return null}matches(t){let e=lt(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(lt(t.anyItem).split("_")[0]===e)return!0}return!1}_doTranslate(t,e){super._doTranslate(t,e),this._x+=t,this._y+=e}}class te extends At{constructor(t){if(super(),this.type=T.Glyph,this._id=this.type+mt[this.type]++,t)for(let e of t)this.addChild(e)}duplicate(){let t=this.getScene().glyph();for(let e of this.children)t.addChild(e.duplicate());return t.classId=this.classId,this._dataScope&&(t.dataScope=this._dataScope.clone()),t}}class ee extends Q{constructor(t){super(t),this.type=T.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new X(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get baseline(){return this._baseline}set baseline(t){this._baseline=t}get orientation(){return this._orientation}set orientation(t){this._orientation=t}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(t){super.copyPropertiesTo(t),t._baseline=this._baseline,t._orientation=this._orientation}resizeArea(t,e){let i=this.vertices[this.vertices.length/2].x,s=this.vertices[this.vertices.length/2].y,n=this.width,r=this.height;for(let a of this.vertices)a.x=i+t/n*(a.x-i),a.y=s+e/r*(a.y-s);this._updateBounds()}getSVGPathData(){return super.getSVGPathData()+" z"}}class ie extends Q{constructor(t){super(t),this.type=T.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t}get outerRadius(){return this._outerRadius}set outerRadius(t){this._outerRadius=t,this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new Z(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}get thickness(){return this._outerRadius-this._innerRadius}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}class se extends Q{constructor(t){super(t),this.type=T.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}get center(){return new Z(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}set radius(t){this._radius=t,this._updateBounds()}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}_doTranslate(t,e){this._x+=t,this._y+=e,super._doTranslate(t,e)}}class ne{constructor(t,e){this.direction=e,this.items=t,this.type=S,this._orientation=[C.Top,C.Middle,C.Bottom].indexOf(e)>=0?v:b,this._itemIds=this.items.map((t=>t.classId)).sort().join("_"),this.id=this.type+"_"+this._itemIds+"_"+this._orientation}get orientation(){return this._orientation}apply(){let t,e=this.direction;this.direction==C.Top||this.direction==C.Left?t=Math.min(...this.items.map((t=>t.bounds[e]))):this.direction==C.Bottom||this.direction==C.Right?t=Math.max(...this.items.map((t=>t.bounds[e]))):this.direction!=C.Center&&this.direction!=C.Middle||(t=n.mean(this.items.map((t=>t.bounds[e]))));let i=this.items.map((i=>t-i.bounds[e])),s=e==C.Top||e==C.Middle||e==C.Bottom?"y":"x";this.items.forEach(((t,e)=>{if(t.parent&&t.parent.layout&&t.parent.layout.type==y.Stack){let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t.parent._doTranslate(n,r)}else{let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t._doTranslate(n,r)}}));let r={};this.items.forEach((t=>r[t.classId]=t)),Object.values(r).forEach((t=>t.getScene()._updateAncestorBounds(t)))}toJSON(){let t={};return t.items=this.items.map((t=>t.id)),t.direction=this.direction,t.type=this.type,t.id=this.id,t}}class re{constructor(t,e,i,s,n,r,a){this.item=t,this.baseItem=e,this.scene=i,this.channel=s,this.itemAnchor=n,this.baseAnchor=r,this.offset=a,this.type=E,this.id=this.type+"_"+this.item.classId+"_"+this.baseItem.classId+"_"+s}apply(){let t=nt(this.item,this.scene),e=nt(this.baseItem,this.scene),i=this.itemAnchor,s=this.baseAnchor,n=this.item.type==T.PointText;if("radialDistance"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];a.type==T.Arc||a.type==T.Ring?r="top"==s?a.outerRadius+this.offset:"bottom"==s?a.innerRadius+this.offset:(a.outerRadius+a.innerRadius)/2+this.offset:a.type==T.Circle&&(r="top"==s?a.radius+this.offset:"bottom"==s?this.offset:a.radius/2+this.offset),o._doTranslate(a.x-o.x,a.y-r-o.bounds[i]),o._rotate?o._rotate=[o._rotate[0],a.x,a.y]:o._rotate=[0,a.x,a.y]}else if("angle"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];r=a.type==T.Arc?"left"==s?a.endAngle+this.offset:"center"==s?a.startAngle+a.angle/2+this.offset:a.startAngle+this.offset:90,o._rotate?o._rotate[0]=90-r:(o._doTranslate(a.x-o.bounds[i],a.y-t[n].y),o._rotate=[90-r,e[n].x,e[n].y])}else{let r;if(this.baseItem.type==T.Link)switch(s){case"left":case"top":r=0;break;case"center":case"middle":r=.5;break;case"right":case"bottom":r=1}for(let a=0;a<t.length;a++){let o=this.baseItem.type==T.Link?e[a].getPointAt(r)[this.channel]:e[a].bounds[s]+this.offset;n?(t[a].anchor["x"==this.channel?0:1]=this.itemAnchor,t[a][this.channel]=o):"x"==this.channel?t[a]._doTranslate(o-t[a].bounds[i],0):t[a]._doTranslate(0,o-t[a].bounds[i])}}this.item.getScene()._updateAncestorBounds(this.item),this.baseItem.getScene()._updateAncestorBounds(this.baseItem)}toJSON(){let t={};return t.item=this.item.id,t.baseItem=this.baseItem.id,t.channel=this.channel,t.itemAnchor=this.itemAnchor,t.baseAnchor=this.baseAnchor,t.offset=this.offset,t.type="affixation",t.id=this.id,t}}class ae extends At{constructor(t,e,i){super(),this.type=T.Gridlines,this.id=this.type+mt[this.type]++,this.encoding=t,this.channel=this.encoding.channel,this._item=e,this._strokeColor="strokeColor"in i?i.strokeColor:"#ddd",this._strokeWidth="strokeWidth"in i?i.strokeWidth:1,"radialDistance"==this.channel&&"angle"in i&&(this._rotate=[-i.angle,this.encoding.x,this.encoding.y])}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.args.item=this._item.id,t.args.strokeColor=this._strokeColor,t.args.strokeWidth=this._strokeWidth,t.args.values=this._values,"time"===this.encoding.scale.type&&(t.args.isDate=!0),t.channel=this.encoding.channel,t.field=this.encoding.field,this._rotate&&(t.args.angle=this._rotate[0]),t}get values(){return this._values}set values(t){this._values=t,this.updateLines(),this.updateLinePositions()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t;for(let e of this.children)e.strokeColor=t}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t;for(let e of this.children)e.strokeWidth=t}matches(t){let e=lt(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(lt(t.anyItem).split("_")[0]===e)return!0}return!1}updateLinePositions(){let t=kt(this._item)?kt(this._item):wt(this._item);if("x"==this.channel||"width"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);for(let[t,s]of this.children.entries()){let n=i[0]+this.encoding.scale.map(this._values[t])-this.encoding.scale.range[0];s._setVertices([[n,e.top],[n,e.bottom]])}}else if("y"==this.channel||"height"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);if(this.encoding.flip)for(let[t,s]of this.children.entries()){let n=i[1]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}else for(let[t,s]of this.children.entries()){let n=i[0]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}}else if("radialDistance"==this.channel)for(let[t,e]of this.children.entries())e.x=this._item.parent.x,e.y=this._item.parent.y,e.radius=this.encoding.scale.map(this._values[t]);for(let t of this.children)t._updateBounds();this._updateBounds()}updateLines(){if(this.children=[],"x"==this.channel||"y"==this.channel||"width"==this.channel||"height"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Q({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=T.Line,e.id=this.id+"line"+t,this.addChild(e)}else if("radialDistance"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Dt({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=T.Circle,e.id=this.id+"line"+t,this.addChild(e)}}}class oe extends At{constructor(){super(),this.type=T.Collection,this._id=this.type+mt[this.type]++,this.classId=this.id,this._childrenOrder=void 0}get childrenOrder(){return this._childrenOrder?this._childrenOrder:{field:"atlas_rowId",direction:"asc"}}set childrenOrder(t){if(!("field"in t)&&!("direction"in t))return;let e,i=t.field;if(this.dataScope.dataTable.hasField(i)){if(this._childrenOrder=t,i===h)e=(t,e)=>parseInt(t.dataScope.getFieldValue(i).substring(1))-parseInt(e.dataScope.getFieldValue(i).substring(1));else{switch(this.children[0].dataScope.getFieldType(i)){case A.Date:break;case A.Number:case A.Integer:e=(t,e)=>t.dataScope.aggregateNumericalField(i)-e.dataScope.aggregateNumericalField(i);break;case A.String:e=t.ranking?(e,s)=>t.ranking.indexOf(e.dataScope.getFieldValue(i))-t.ranking.indexOf(s.dataScope.getFieldValue(i)):(t,e)=>t.dataScope.getFieldValue(i)<e.dataScope.getFieldValue(i)?-1:1}}this.children.sort(e),"desc"==t.direction&&this.children.reverse(),this.layout&&this.layout.run()}else console.warn("Cannot order collection children by an non-existent field",t.field)}duplicate(){let t=this.getScene().collection();for(let e=0;e<this.children.length;e++){let i=this.children[e];t.addChild(i.duplicate())}if(t.classId=this.classId,this.parent.addChild(t),this._layout){let e=this._layout.clone();t.layout=e}return t}contains(t,e){if([T.Arc,T.Pie,T.Polygon,T.Area].indexOf(this.firstChild.type)>=0){let i=this.getSVGPathData();if(""!==i){let s=bt.getContext(),n=new Path2D(i);return s.lineWidth=Math.max(this.strokeWidth,2.5),s.stroke(n),s.isPointInPath(n,t,e)}}return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}getSVGPathData(){let t="";for(let e of this.children)if(e.getSVGPathData)t+=e.getSVGPathData();else if(e.bounds){let i=e.bounds;t+=["M",i.left,i.top].join(" "),t+=["L",i.right,i.top].join(" "),t+=["L",i.right,i.bottom].join(" "),t+=["L",i.left,i.bottom,"Z"].join(" ")}return t}}class he extends Q{constructor(t){super(t),this._type=T.Arc,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=Et(this._startAngle),this._er=Et(this._endAngle);let e=this._x+this._innerRadius*Math.cos(this._sr),i=this._y-this._innerRadius*Math.sin(this._sr),s=this._x+this._innerRadius*Math.cos(this._er),n=this._y-this._innerRadius*Math.sin(this._er),r=this._x+this._outerRadius*Math.cos(this._sr),a=this._y-this._outerRadius*Math.sin(this._sr),o=this._x+this._outerRadius*Math.cos(this._er),h=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[e,i],[r,a],[o,h],[s,n]])}get type(){return 0===this._innerRadius?T.Pie:T.Arc}set type(t){this._type=t}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}set outerRadius(t){this._outerRadius=t,this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new Z(this._x,this._y)}set x(t){this._x=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this._updateBounds()}set y(t){this._y=t,this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}sweepOver(t){let e=this.startAngle,i=this.endAngle;i<e&&(i+=360);let s=t.startAngle,n=t.endAngle;return n<s&&(n+=360),s>=e&&s<=i&&n>=e&&n<=i}_doTranslate(t,e){this._x+=t,this._y+=e,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}adjustAngle(t,e){this._startAngle=t,this._endAngle=e,this._sr=Et(this._startAngle),this._er=Et(this._endAngle),this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er)}}class le extends H{constructor(t){super(t),this.type=T.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}toJSON(){let t=super.toJSON();return t.src=this._src,t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}get src(){return this._src}set src(t){this._src=t}get width(){return this._width}set width(t){this._width=t,this._updateBounds()}get height(){return this._height}set height(t){this._height=t,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new a(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}}class ce extends Q{constructor(t){super(t),this.type=T.Link,this.mode="mode"in t?t.mode:"linear",this.source=void 0,this.target=void 0,this.sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this.targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this.sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this.targetOffset="targetOffset"in t?t.targetOffset:[0,0]}radialvalue(t,e){let i=t-Math.PI/2;return[t=e*Math.cos(i),e*=Math.sin(t)]}bezierCurveHorizontal(t,e,i,s){return`M ${t} ${e} C ${(t+i)/2} ${e} ${t} ${s} ${i} ${s}`}bezierCurveVertical(t,e,i,s){return`M ${t} ${e} C ${t} ${(e+s)/2} ${i} ${e} ${i} ${s}`}bezierCurveRadial(t,e,i,s){let n=this.radialvalue(t,e),r=this.radialvalue(t,(e+s)/2),a=this.radialvalue(i,e),o=this.radialvalue(i,s);return`M ${n[0]} ${n[1]} C ${r[0]} ${r[1]} ${a[0]} ${a[1]} ${o[0]} ${o[1]}`}_updateBounds(){if(null!=this.source&&null!=this.target){let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];this._bounds=new a(Math.min(t,i),Math.min(e,s),Math.abs(t-i),Math.abs(e-s))}else this._bounds=new a(0,0,0,0)}getSVGPathData(){if(void 0===this.source||void 0===this.target)return"";let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];switch(this.mode){case"curveHorizontal":return this.bezierCurveHorizontal(t,e,i,s);case"curveVertical":return this.bezierCurveVertical(t,e,i,s);case"linear":default:return`M ${t} ${e} L ${i} ${s}`}}copyPropertiesTo(t){super.copyPropertiesTo(t),t.sourceAnchor=this.sourceAnchor.slice(),t.targetAnchor=this.targetAnchor.slice(),t.sourceOffset=this.sourceOffset.slice(),t.targetOffset=this.targetOffset.slice(),t.mode=this.mode}getPointAt(t){const e=xt.getSVG();let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",this.getSVGPathData()),e.appendChild(i);let s=i.getTotalLength();return i.getPointAtLength(s*t)}}const de=function(t,e,i){let s=t.getScene();pt(t)||s._reapplyConstraints(t),s.getRelatedAxes(t).forEach((t=>{t.encoding&&void 0!==t.encoding.scale.offset&&(t.encoding.scale.offset+="x"===t.channel||"width"===t.channel?e:i),0===i||"x"!==t.channel&&"width"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+i),0===e||"y"!==t.channel&&"height"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+e),t.reposition()})),s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},ue=function(t,e,i){let s=t.getScene();s._relayoutAncestors(t,e);let n=[t],r=t.firstChild;for(;r;)n.push(r),r=r.firstChild;for(let t of n)t.getScene()._reapplyConstraints(t);let a=!1;for(let t of i)if(["numRows","numCols","layout","childrenOrder"].indexOf(t)>=0){a=!0;break}let o,h=!1;if(t.layout&&(t.layout.type!==y.Grid||1!==t.layout.numRows&&1!==t.layout.numCols?t.layout.type===y.Stack&&i.indexOf("orientation")>=0&&(h=!0,o=t.layout.orientation===b?"x":"y"):(h=!0,o=1===t.layout.numRows?"x":"y")),h){let e=s.getRelatedAxes(t).filter((e=>e instanceof Xt&&e._item.parent.classId===t.classId));for(let i of e){s.removeItem(i);let e=i.toJSON().args;delete e.orientation,e.item=t.firstChild,s.axis(o,i.field,e)}}if(a)s.reCreateRelatedAxes(t);else{s.getRelatedAxes(t).forEach((t=>t.reposition()))}s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},fe=function(t){for(let e of t.encodings)e._map(),e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let i=e.anyItem,s=e.scene.getRelatedAxes(i);for(let i of s)i.encoding&&i.encoding.scale===t&&(i.tickValues=e._inferTickValues(e),i.labelValues=e._inferTickValues(e),i._positionPath(),i._showTitle&&i._positionTitle(),"radialDistance"===i._channel&&i._rotate&&(i._rotate=[i._rotate[0],i._item.parent.x,i._item.parent.y]),i._updateBounds());e.scene.getRelatedGridlines(i).forEach((t=>t.updateLinePositions()))}},pe=function(t){for(let e of t.encodings)e._apply();for(let e of t.encodings)e.scene._relayoutAncestors(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let t=e.anyItem;e.scene.getRelatedAxes(t).forEach((t=>t.reposition())),e.scene.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))}},ge=function(t,e){let i=t.getScene();i._relayoutAncestors(t,e),i._reapplyConstraints(t),i.getRelatedAxes(t).forEach((t=>t.reposition())),i.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},_e=function(t,e){let i=e.getScene(),s=i.getRelatedAxes(t);for(let n of s)n._item.classId===t.classId&&(n._item=e,n._items=nt(e,i));let n=i.encodings[lt(t)];if(n){i.encodings[lt(e)]={};for(let s of["x","y"]){const r=n[s];r&&(r.anyItem=e,r.items=nt(e,i),i.encodings[lt(e)][s]=r,delete i.encodings[lt(t)][s])}0===Object.keys(n).length&&delete i.encodings[lt(t)]}},me=function(t,e){let i=e.getScene(),s=i.encodings[lt(t)];if(s){i.encodings[lt(e)]={};for(let n of["x","y"]){const r=s[n];r&&(r.anyItem=e,r.items=nt(e,i),i.encodings[lt(e)][n]=r,delete i.encodings[lt(t)][n])}0===Object.keys(s)&&delete i.encodings[lt(t)]}let n=i.getRelatedAxes(t);for(let s of n)s._item.classId===t.classId&&(s._item=e,s._items=nt(e,i))},ye=function(t){let e=t.getScene(),i=e.encodings[lt(t)];for(let t in i)i[t]._apply();e.getRelatedAxes(t).forEach((t=>t.reposition())),e.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))};function ve(t,e,i,s){let n=s.getFieldType(i);if(n!=A.String&&n!=A.Date&&n!=A.Integer)throw new Error(G.REPOPULATE_BY_NONCAT+": "+i+" is "+n);if(e.parent&&e.parent.dataScope&&!e.parent.dataScope.isFullTable()&&e.parent.dataScope.dataTable!=s)throw new Error(G.REPOPULATE_DT_MISMATCH);return function(t,e,i,s){let n=nt(e.parent,t);1===n.length&&(e.parent.dataScope=void 0);for(let t of n){let e=s.getFieldSummary(i).unique.map((e=>t.dataScope?t.dataScope.cross(i,e):new Mt(s).cross(i,e)));e=e.filter((t=>!t.isEmpty()));const n=e.length-t.children.length,r=t.children.length-e.length;for(let e=0;e<r;e++)t.removeChildAt(t.children.length-1);const a=t.children.length;for(let e=0;e<n;e++){let e=t.children[Math.floor(Math.random()*a)].duplicate();t.addChild(e)}t.children.forEach(((t,i)=>t.dataScope=e[i]))}t._relayoutAncestors(e)}(t,e,i,s)}function be(t,e){let i=t.item;if(e.innerRadius===i.outerRadius&&i.sweepOver(e))t.children.push({item:e,children:[]});else if(t.children&&t.children.length>0&&e.innerRadius>i.outerRadius&&i.sweepOver(e))for(let i of t.children)be(i,e)}function xe(t,e,i,s){let n=t.item;if(n.innerRadius=e,n.outerRadius=e+s.map(i[n.id]),t.children&&t.children.length>0)for(let e of t.children)xe(e,n.outerRadius,i,s)}class we{constructor(t,e){this._type="tree";let i=[],s=[];this._nodeHash={},this._traverse(t,i,s),this._nodeTable=new qt(i,"nodes"),this._linkTable=new qt(s,"links"),this._nodeTable.tree=this,this._linkTable.tree=this,this._data=t,this.aggregateFromLeaves("value","average")}get type(){return this._type}_traverse(t,e,i,s=0){let n={};o in t||(t.id="n"+e.length),e.push(n),t._depth=s;for(let r in t)if("children"==r&&t[r]&&t[r].length>0)for(let n of t[r]){let r=this._traverse(n,e,i,s+1);i.push({parent:t.id,child:r})}else n[r]=t[r];return this._nodeHash[n.id]=n,n.id}getParent(t){let e,i=t.id,s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].child==i){e=s[t].parent;let i=n.findIndex((t=>t.id==e));return n[i]}}getChildren(t){let e=t.id,i=[],s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].parent==e){let e=s[t].child,r=n.findIndex((t=>t.id==e));i.push(n[r])}return i}getNodeDataScope(t){return new Mt(this._nodeTable).cross(h,t.atlas_rowId)}getMaxDepth(){return this._nodeTable._fieldSummaries._depth.max}getRoot(){return this._nodeTable.data[0]}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}getNode(t){return this._nodeTable.data.filter((e=>e.id==t))[0]}sumLeaves(t,e){if(!t)return 0;let i=t.id,s=[];if(s=this.getChildren(t),s&&s.length>0){let t=0;for(let i of s)t+=this.sumLeaves(i,e);this.getNode(i)["sum"+e]=t}else this.getNode(i)["sum"+e]=t[e];return t["sum"+e]}countLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0)for(let t of s)n+=this.countLeaves(t,e);else n=1;return this.getNode(i)["count"+e]=n,t["count"+e]}averageLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0){for(let t of s)n+=this.averageLeaves(t,e);n/=s.length,this.getNode(i)["average"+e]=n}else this.getNode(i)["average"+e]=t[e];return t["average"+e]}medianLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.medianLeaves(t,e));n.sort((function(t,e){return t-e}));let t=Math.floor(n.length/2);n.length%2?this.getNode(i)["median"+e]=n[t]:this.getNode(i)["median"+e]=(n[t-1]+n[t])/2}else this.getNode(i)["median"+e]=t[e];return t["median"+e]}maxLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.maxLeaves(t,e));this.getNode(i)["max"+e]=Math.max(...n)}else this.getNode(i)["max"+e]=t[e];return t["max"+e]}minLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.minLeaves(t,e));this.getNode(i)["min"+e]=Math.min(...n)}else this.getNode(i)["min"+e]=t[e];return t["min"+e]}aggregateFromLeaves(t,e){let i=this.getRoot();switch(e){case"sum":this.sumLeaves(i,t);break;case"count":this.countLeaves(i,t);break;case"average":this.averageLeaves(i,t);break;case"median":this.medianLeaves(i,t);break;case"max":this.maxLeaves(i,t);break;case"min":this.minLeaves(i,t)}}}function ke(t,e,i,s,n){switch(e.type){case T.Circle:return function(t,e,i,s,n){let r,a,o=i||k.Outward,h=s||50;if(o!==k.Inward&&o!==k.Outward)throw G.UNKNOWN_DIRECTION+" "+o;return nt(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let l=i.parent;Ce(i,e.id,o,h,n,n.getRoot(),s,t,!0),s.layout=Kc("strata",{direction:o,rootMark:i}),l.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n);case T.Rect:return function(t,e,i,s,n){let r,a,o=i||k.Down,h=s||50;if([k.Up,k.Down,k.Left,k.Right].indexOf(o)<0)throw G.UNKNOWN_DIRECTION+" "+o;return nt(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let l=i.parent;Se(i,e.id,o,h,n,n.getRoot(),s,t,!0),s.layout=Kc("strata",{direction:o,rootMark:i}),l.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n)}}function Ce(t,e,i,s,n,r,a,o,h){h&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let l=n.getChildren(r);if(0===l.length)return;let c=t.type===T.Circle||t.type===T.Ring?90:t.startAngle,d=(t.type===T.Circle||t.type===T.Ring?360:t.angle)/l.length;for(let r=0;r<l.length;r++){let h,u=t.type===T.Circle?t.radius:t.outerRadius;h=360===d?o.mark("ring",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}):o.mark("arc",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,startAngle:Rt(c+d*r),endAngle:Rt(c+d*(r+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),h.dataScope=n.getNodeDataScope(l[r]),h.classId=e,a.addChild(h),Ce(h,e,i,s,n,l[r],a,o)}}function Se(t,e,i,s,n,r,a,o,h){h&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let l,c,d,u=n.getChildren(r);if(0!==u.length){switch(i){case k.Up:case k.Down:case k.Left:case k.Right:default:l=t.left,c=t.bottom,d=t.width/u.length}for(let r=0;r<u.length;r++){let h=o.mark("rect",{left:l,top:c,width:d,height:s,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});l+=d,h.dataScope=n.getNodeDataScope(u[r]),h.classId=e,a.addChild(h),Se(h,e,i,s,n,u[r],a,o)}}}class Ee{constructor(t,e,i,s){this._listener=t,this._eventType=e,this._selDef=i,this._targetDef=s}getCallbackFunction(t,e){let i=this;return function(s){s.stopPropagation();let r,a=e._getSelection(s,i.selectionDef,i._listener,t.getItem(n.select(this).attr("id"))),o=nt(i.targetDef.item,t);i.selectionDef.remember?(e.addGlobalPredicate(t,a.predicate),r=e.getGlobalPredicates(t)):r=e.getGlobalPredicates(t).concat([a.predicate]);for(let t of o){let e=!0;for(let i of r)if(!tt(t,i)){e=!1;break}for(let s in i.targetDef.effect)s in t.staticProperties||(t.staticProperties[s]=t[s]),e?t[s]=i.targetDef.effect[s].selected:"unselected"in i.targetDef.effect[s]?t[s]=i.targetDef.effect[s].unselected:s in t.staticProperties&&(t[s]=t.staticProperties[s])}e._renderer.render(t,{visualOnly:!0})}}getRestoreFunction(t,e,i){let s=this;return function(){let n=nt(s.targetDef.item,t);if(s.targetDef.effect)for(let t of n)for(let e in s.targetDef.effect)t[e]=t.staticProperties[e];else for(let t of n)for(let e in t.staticProperties)t[e]=t.staticProperties[e];i&&(e._globalPredicates={}),e._renderer.render(t,{visualOnly:!0})}}get listener(){return this._listener}get selectionDef(){return this._selDef}get targetDef(){return this._targetDef}get eventType(){return this._eventType}}class Te extends At{constructor(t){super(),t&&t.fillColor&&(this.fillColor=t.fillColor),this.type=T.Scene,this._id=this.type+mt[this.type]++,this.encodings={},this.constraints={},this._itemMap={},this._interactions=[]}clear(){this.removeAll(),this.encodings={},this.constraints={},this._itemMap={}}group(t){let e=new At;if(e.classId=e.id,this.addChild(e),t&&t.length>0)for(let i of t)e.addChild(i);return this._itemMap[e.id]=e,e}mark(t,e){let i=void 0===e?{}:e,s=null;switch(i.type=t,t){case T.Rect:{"top"in i||(i.top=0),"left"in i||(i.left=0),"width"in i||(i.width=100),"height"in i||(i.height=100);let t=i.top,e=i.left,n=i.width,r=i.height;i.vertices=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]],delete i.top,delete i.left,delete i.width,delete i.height,"fillColor"in i||(i.fillColor="none"),s=new Lt(i);break}case T.Area:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,e],[s,n],[t,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new ee(i);break;case T.Line:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new Q(i),s.type=T.Line;break;case T.Path:s=new Q(i);break;case T.Circle:s=new Dt(i);break;case T.Ring:s=new ie(i);break;case T.Arc:case T.Pie:s=new he(i);break;case T.Polygon:s=new se(i);break;case"text":case T.PointText:"anchor"in i||(i.anchor=["center","middle"]),s=new $t(i);break;case T.Image:s=new le(i);break;case T.Link:s=new ce(i)}return null!==s&&(s.id="id"in i?i.id:s.type+mt[s.type]++,s.classId=s.id,this.addChild(s),this._itemMap[s.id]=s),s}glyph(...t){let e=new te(t);return e.classId=e.id,this.addChild(e),this._itemMap[e.id]=e,e}collection(){let t=new oe;return this.addChild(t),this._itemMap[t.id]=t,t}attach(t,e){t.dataScope=new Mt(e)}repeat(t,e,i){if(!t||void 0===e)throw G.INCOMPLETE_REPEAT_INFO;if(e.nodeTable&&e.linkTable){if(!Array.isArray(t)||2!==t.length)throw G.REPEAT_NODE_LINK;return function(t,e,i,s){let n=s.nodeTable.getFieldSummary(o).unique.map((t=>e.dataScope?e.dataScope.cross(o,t):new Mt(s.nodeTable).cross(o,t))),r=t.collection(),a={};r.dataScope=e.dataScope?e.dataScope.clone():new Mt(s.nodeTable),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}r.children.forEach(((t,e)=>{t.dataScope=n[e],a[t.dataScope.getFieldValue(o)]=t}));let l=s.linkTable.getFieldSummary(h).unique.map((t=>i.dataScope?i.dataScope.cross(h,t):new Mt(s.linkTable).cross(h,t))),c=t.collection();c.dataScope=i.dataScope?i.dataScope.clone():new Mt(s.linkTable),c.addChild(i);for(let t=1;t<l.length;t++){let t=i.duplicate();c.addChild(t)}c.children.forEach(((t,e)=>t.dataScope=l[e]));let d="tree"===s.type?"parent":"source",u="tree"===s.type?"child":"target";for(let t of c.children){let e=t.dataScope.getFieldValue(d),i=t.dataScope.getFieldValue(u);t.source=a[e],t.target=a[i],t._updateBounds()}return t.addChild(c),t.addChild(r),[r,c]}(this,t[0],t[1],e)}{let s=i||{},n=s.field?s.field:qt.RowID,r=s.callback;Ot(n,e);let a=Nt(this,t,n,e,r);return s.layout&&(a.layout=s.layout),a}}repopulate(t,e,i){if(!t||void 0===e)throw G.INCOMPLETE_REPEAT_INFO;let s=i||{},n=s.field?s.field:qt.RowID;Ot(n,e),ve(this,t,n,e)}densify(t,e,i){if(!t||void 0===e)throw G.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:qt.RowID,a="startAngle"in s?s.startAngle:90,o="direction"in s?s.direction:"clockwise",h=s.callback;Ot(r,e);let l=Bt(this,t,n,r,e,h,a,o);return me(t,l),l}stratify(t,e,i){if(!(e instanceof we))throw G.STRATIFY_WITHOUT_TREE;if(t.type!==T.Circle&&t.type!==T.Rect)throw G.STRATIFY_WRONG_ITEM;let s=i||{};return ke(this,t,s.direction,s.size,e)}divide(t,e,i){if(!t||null==e)throw G.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:qt.RowID,a=s.callback;Ot(r,e);let o=Ft(this,t,n,r,e,a);return s.layout&&(o.layout=s.layout),_e(t,o),o}classify(t,e){if(!nd(t))throw G.CANNOT_CLASSIFY+t.type;let i=e||{},s=i.field?i.field:qt.RowID,n=t.firstChild.dataScope.dataTable,r=i.layout;return Ot(s,n),function(t,e,i,s){let n=nt(e,t);for(let e of n){let s,n={},r=e.children;for(let t of r){let e=t.dataScope.getFieldValue(i);e in n||(n[e]=[]),n[e].push(t)}let a=r[0].dataScope._dt;for(let r in n){let o=t.collection();e.addChild(o),void 0===s&&(s=o.id),o.classId=s,o.dataScope=e.dataScope?e.dataScope.cross(i,r):new Mt(a).cross(i,r);for(let t of n[r])o.addChild(t)}}s&&t.setProperties(e.firstChild,{layout:s})}(this,t,s,r),t}_validateEncodeArgs(t,e){if(!t||!("channel"in e)||!("field"in e))throw G.INCOMPLETE_BINDING_INFO;let i=e.field;if("vertex"==t.type||"segment"==t.type){if(!t.parent.dataScope&&!t.dataScope)throw G.BIND_WITHOUT_DATASCOPE}else if(!t.dataScope)throw G.BIND_WITHOUT_DATASCOPE;let s=e.table?e.table:t.dataScope?t.dataScope._dt:t.parent.dataScope._dt,n=s.getFieldType(i);if("fillGradient"===e.channel&&[A.String,A.Boolean,A.Date].indexOf(n)>=0)throw G.UNSUPPORTED_FIELDTYPE+e.channel+": "+n;Ot(i,s)}encode(t,e){let i,s=Array.isArray(t)?t:[t],n=[];for(let r of s){let s;if([T.Pie,T.Arc].indexOf(t.type)>=0&&"angle"===e.channel){let i=t.parent;if(i.type===T.Collection&&i.layout&&i.layout.orientation===x){n.push(this._encodeWithinCollection(r,e));continue}}if(this._validateEncodeArgs(r,e),"vertex"==r.type&&r.parent.type==T.Area){let t=nt(r.parent,this);s=[];let e=r.parent.vertices.indexOf(r)<r.parent.vertices.length/2;for(let i of t)s=e?s.concat(i.vertices.slice(0,i.vertices.length/2)):s.concat(i.vertices.slice(i.vertices.length/2))}else s=nt(r,this);if(1===s.length&&s[0].type===T.Area&&("x"===e.channel||"y"===e.channel))return void console.warn("Only 1 "+r.type+" found, cannot encode "+e.field);!e.scale&&i&&(e.scale=i);let a=this._doEncode(s,e);i||(i=a.scale),n.push(a)}return n.length>1?n:n[0]}_doEncode(t,e){let i=t[0],s=e.channel,n=e.field;"datatable"in e||(e.datatable=i.dataScope?i.dataScope.dataTable:i.parent.dataScope.dataTable),"aggregator"in e||(e.aggregator="mean"),"flipScale"in e||(e.flipScale=!1),"includeZero"in e||(e.includeZero=!1),"scaleType"in e||(e.scaleType="linear");let r=new Gt(t,this,s,n,e);switch(s){case"width":case"height":case"radius":case"outerRadius":case"innerRadius":case"area":case"fontSize":i.type==T.Area?Vt(r):jt(r);break;case"strokeWidth":i.type==T.Link?function(t){t._query=function(){let t=this.field,e=this.channel,i=this.items.map((t=>t.dataScope));if("strokeWidth"==e)if(this.datatable.hasField(t))this.data=i.map((e=>e.getFieldValue(t)));else if(t.startsWith("parent.")||t.startsWith("child.")){let e=this.datatable.tree.nodeTable,s=t.split(".")[0],n=t.split(".")[1],r=i.map((t=>t.getFieldValue(s)));this.data=r.map((t=>new Mt(e).cross(o,t).getFieldValue(n)))}},t._map=function(){let t,e=this.channel,i=this.items;if("strokeWidth"==e){let e,s;t=Zc(this.scaleType),t.domain=[0,Math.max(...this.data)],e=1,s=Math.max(...i.map((t=>parseFloat(t.styles.strokeWidth)))),s==e&&(s=e+5),this.rangeExtent&&(s=e+this.rangeExtent),this.range&&(e=this.range[0],s=this.range[1]),t._setRange([e,s]),this.scale||(this.scale=t),this.scale._addEncoding(this)}},t._apply=function(){if("strokeWidth"==this.channel)for(let t=0;t<this.data.length;t++)this.items[t].styles.strokeWidth=this.scale.map(this.data[t])},t.run()}(r):jt(r);break;case"x":case"y":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t,e,i,s,n,r=this.channel,a=this.datatable.getFieldType(this.field),o=rt(this.anyItem);if(o&&o.type==y.Grid){let e=o.cellBounds;t="x"==r?e[0].width:e[0].height}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===T.Area)t="x"==r?this.anyItem.parent.bounds.width:this.anyItem.parent.bounds.height;else{let e=this.items.map((t=>t[r]));t=Math.max(...e)-Math.min(...e),t<100?t=100:t>500&&(t=500)}switch(this.rangeExtent&&(t=this.rangeExtent),a){case A.Boolean:break;case A.Date:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=this.data;for(let e of this.scale.encodings)t=t.concat(e.data);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=Zc("time"),this.scale.isFlipped=this._flipScale,n=[0,t];break;case A.String:if(s=Array.from(new Set(this.data)),n=[0,t],this.scale){let t=this.scale.domain;for(let e of s)t.indexOf(e)<0&&t.push(e);s=t,n=this.scale.range}else this.scale=Zc("point"),this.scale.isFlipped=this._flipScale,n=[0,t];break;default:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=this.data;for(let e of this.scale.encodings)t=t.concat(e.data);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=Zc(this.scaleType),this.scale.isFlipped=this._flipScale,this.scale.includeZero=this._includeZero,n=[0,t];s[0]==s[1]&&(s[1]=1.1*s[0])}this.scale._scale.domain(s),this.scale._setRange(n),this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);if("x"==e){let i=rt(this.anyItem,"grid");if(i&&i.type==y.Grid)for(let t=0;t<this.items.length;t++){let i=this.items[t],s=at(i).left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===T.Area){let t=ct(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=i.parent.bounds.left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){let t=ct(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t[e])))),this.items[0].type===T.PointText&&this.items.forEach((t=>t.horzAnchor="center"));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n)}}}else{let i=rt(this.anyItem,"grid");if(i&&i.type==y.Grid){let t=this.items.map((t=>at(t)));for(let i=0;i<this.items.length;i++){let s=this.items[i],n=0,r=t[i].bottom-this.scale.map(this.data[i])-s[e];s._doTranslate(n,r),"vertex"!=s.type&&"segment"!=s.type||s.parent._updateBounds()}}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===T.Area){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=i.parent.bounds.top+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.y)))),this.items[0].type===T.PointText&&this.items.forEach((t=>t.vertAnchor="middle"));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i.refBounds[e];i._doTranslate(s,n)}}}},t.run()}(r);break;case"fillColor":case"strokeColor":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:this.data=[!0,!1];break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){switch(this.datatable.getFieldType(this.field)){case A.Boolean:if(!this.scale&&(this.scale=Zc("ordinalColor"),this.scale.domain=this.data,this._mapping)){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;case A.String:if(this.scale)this.scale.domain=Array.from(new Set(this.scale.domain.concat(this.data)));else{let t={scheme:"schemeCategory10"};if(this._scheme&&(z.indexOf(this._scheme)>=0?t.scheme=this._scheme:(W.indexOf(this._scheme)>=0||U.indexOf(this._scheme)>=0)&&(t.scheme=this._scheme,t.size=this.data.length)),this.scale=Zc("ordinalColor",t),this.scale.domain=this.data,this._mapping){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}}break;default:if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=Zc("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=Zc("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=Zc("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}}this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);"vertex"==e.type||"segment"==e.type?e[this.channel]=i:e.styles[this.channel]=i,e.vertices&&"strokeColor"==this.channel&&e.vertices.forEach((t=>t.fillColor=i))}},t.run()}(r);break;case"fillGradient":i.type===T.Area&&Vt(r);break;case"angle":!function(t){t._query=function(){this.data=[],this.id2data={};let t=this.field,e=this.items;switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case A.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator)))}for(let t=0;t<this.data.length;t++)this.id2data[e[t].id]=this.data[t]},t._map=function(){this.scale||(this.scale=Zc("linear"),this.scale.domain=this.datatable.tree?[0,Math.max(...this.data)]:[0,this.data.reduce(((t,e)=>t+e),0)],this.scale._setRange([0,360]),this.scale._addEncoding(this))},t._apply=function(){let t;for(let e=0;e<this.items.length;e++)t=this.items[e],t.type!==T.Arc&&t.type!==T.Pie||t.adjustAngle(t.startAngle,Rt(t.startAngle+this.scale.map(this.data[e])));this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"text":!function(t){t._query=function(){this.data=[];let t,e,i=this.items;if(this.field.startsWith("parent.")||this.field.startsWith("child.")){e=this.datatable.tree.nodeTable,t=this.field.split(".")[1];let s=this.field.split(".")[0],n=i.map((t=>t.dataScope)).map((t=>t.getFieldValue(s)));e.getFieldType(t)==A.Integer||e.getFieldType(t)==A.Number?this.data=n.map((i=>new Mt(e).cross(o,i).aggregateNumericalField(t))):this.data=n.map((i=>new Mt(e).cross(o,i).getFieldValue(t)))}else e=this.datatable,t=this.field,e.getFieldType(t)==A.Integer||e.getFieldType(t)==A.Number?this.data=i.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator))):this.data=i.map((e=>e.dataScope.getFieldValue(t)))},t._map=function(){if(this.scale);else switch(this.datatable.getFieldType(this.field)){case A.Boolean:case A.Date:break;case A.String:default:this.scale=Zc("ordinal"),this.scale.domain=[...new Set(this.data)],this.scale._scale.range(this.scale.domain.map((t=>t+"")))}},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.text=i}},t.run()}(r);break;case"radialDistance":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t=this.data;this.scale||(this.scale=Zc("linear"),this.scale.domain=[0,Math.max(...t)],this.scale._setRange([0,this.anyItem.parent.radius])),this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]),s=Ct(this.anyItem.parent.x,this.anyItem.parent.y,i,e.polarAngle);e.x=s[0],e.y=s[1]}this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"thickness":!function(t){t._query=function(){this.data={};let t=this.field,e=this.items,i=e.map((t=>t.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t);break;case A.String:try{for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].aggregateNumericalField(t,this.aggregator)}},t._map=function(){let t=this.data;if(!this.scale){this.scale=Zc(this.scaleType),this.scale.domain=[0,Math.max(...Object.values(t))];let e=1,i=this.rangeExtent?e+this.rangeExtent:Math.max(...this.items.map((t=>t.outerRadius)));this.scale._setRange([e,i])}this.scale._addEncoding(this)},t._apply=function(){this.items.sort(((t,e)=>(t.innerRadius+t.outerRadius)/2-(e.innerRadius+e.outerRadius)/2));let t=Math.min(...this.items.map((t=>t.innerRadius))),e={item:new he({outerRadius:t,startAngle:0,endAngle:360}),children:[]};for(let t of this.items)be(e,t);for(let t of e.children)xe(t,t.item.innerRadius,this.data,this.scale)},t.run()}(r)}return"_remember"in e&&1!=e._remember||this._registerBinding(r),s.indexOf("Color")<0&&this._updateAncestorBounds(i,r.items),r}_encodeWithinCollection(t,e){this._validateEncodeArgs(t,e);let i=function(t,e){let i={},s=nt(t,e);for(let t of s){let e=t.parent.id;e in i||(i[e]=[]),i[e].push(t)}return Object.keys(i).map((t=>i[t]))}(t,this),s=[];for(let t of i){let i=this._doEncode(t,e);s.push(i)}return s}getPeers(t){return nt(t,this)}find(t){return et(this,t)}align(t,e){if(!function(t,e,i){if(e==C.Top||e==C.Bottom||e==C.Middle){for(let e of t)if(!vt(e,i))return!1;return!0}if(e==C.Left||e==C.Right||e==C.Center){for(let e of t)if(!yt(e,i))return!1;return!0}}(t,e,this))return!1;let i=new ne(t,e);if(i.id in this.constraints)return console.warn("constraint has been added"),!1;this.constraints[i.id]=i,i.apply(),this._updateAncestorBounds(t[0])}removeAllConstraints(){this.constraints={}}removeConstraint(t){delete this.constraints[t.id]}getRelatedConstraints(t){let e=[];for(let i in this.constraints){let s=this.constraints[i];switch(s.type){case S:s._itemIds===t.map((t=>t.classId)).sort().join("_")&&e.push(s)}}return e}affix(t,e,i,s){let n=s||{},r="offset"in n?n.offset:0,a="itemAnchor"in n?n.itemAnchor:"x"==i||"angle"==i?"center":"middle",o="baseAnchor"in n?n.baseAnchor:"x"==i||"angle"==i?"center":"middle",h=new re(t,e,this,i,a,o,r);h.id,this.constraints,this.constraints[h.id]=h,h.apply()}axis(t,e,i){let s=i||{},n=s.item?this.getEncodingByItem(s.item,t):this.getEncodingByField(e,t);if(n&&n.field===e){if(n.datatable.getFieldType(e)!==A.Date||"labelFormat"in s||(s.labelFormat="%m/%d/%y"),"width"===n.channel){let t=this.children.filter((t=>t.type===T.Axis)).map((t=>t.channel));"orientation"in s||(s.orientation=t.indexOf("x")>=0?"top":"bottom")}else if("height"===n.channel){let t=this.children.filter((t=>t.type===T.Axis)).map((t=>t.channel));"orientation"in s||(s.orientation=t.indexOf("y")>=0?"right":"left")}let t=new Kt(n,s.item?s.item:n.anyItem,s);return"tickValues"in s?(t.tickValues=s.tickValues,t.labelValues=s.tickValues):(t.tickValues=n._inferTickValues(),t.labelValues=n._inferTickValues()),this.addChildAt(t,0),this._itemMap[t.id]=t,this._updateBounds(),t}let r=s.item?s.item:et(this,[{field:e}])[0];if(void 0===r)return void console.warn(j+e);let a=rt(r);if(a&&(a.type===y.Grid||a.type===y.Stack)){if(a&&("x"==t||"y"==t)){let i,n,r=nt(a.group,this);for(let a of r){let r=et(a,[{field:e}])[0],o=nt(r,a);r.dataScope.dataTable.getFieldType(e)!==A.Date||"labelFormat"in s||(s.labelFormat="%m/%d/%y"),i=new Xt(o,a.layout,t,e,s),null==n&&(n=i.id),i.classId=n,this.addChildAt(i,0),this._itemMap[i.id]=i}return this._updateBounds(),i}console.warn(j+e)}}getRelatedAxes(t){let e=[];if(pt(t))return e;for(let i of this.children){if(i.type!==T.Axis)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===lt(t).split("_")[0]){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=dt(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}removeItem(t){if(!pt(t)){let e=this.getRelatedEncodings(t);for(let t of e)this.removeEncoding(t);let i=this.getRelatedAxes(t);for(let t of i)this.removeItem(t);for(let e of this.getRelatedGridlines(t))this.removeItem(e)}delete this._itemMap[t.id],this.removeChild(t),this._updateBounds()}getRelatedEncodings(t){let e=[],i=t;for(;i;)if(e.push(lt(i)),i.type==T.Collection)i=i.firstChild;else if(i.type==T.Glyph){for(let t of i.children)e.push(lt(t));i=void 0}else i=void 0;let s=Object.keys(this.encodings),n=[];for(let t of s){let i=t.split("_")[0];if(e.indexOf(i)>=0)for(let e in this.encodings[t])n.push(this.encodings[t][e])}return n}removeAllEncodings(){this.encodings={},this.removeAllItemsByType(T.Axis),this.removeAllItemsByType(T.Legend),this.removeAllItemsByType(T.Gridlines)}removeEncoding(t){let e=lt(t.anyItem);delete this.encodings[e][t.channel],0===Object.keys(this.encodings[e]).length&&delete this.encodings[e];let i=[];for(let e of this.children)pt(e)&&e.encoding&&e.encoding===t&&i.push(e);for(let t of i)this.removeItem(t);this._updateBounds()}removeAllItemsByType(t){let e=[];for(let i of this.children)i.type===t&&e.push(i);for(let t of e)this.removeItem(t);this._updateBounds()}reCreateRelatedAxes(t){let e=this.getRelatedAxes(t),i=[];e.forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),delete e.tickValues,delete e.labelValues,this.removeItem(t),t instanceof Xt?i.indexOf(t.classId)<0&&(this.axis(t.channel,t.field,e),i.push(t.classId)):this.axis(t.channel,t.field,e)})),this._updateBounds()}reCreateRelatedLegends(t){this.getRelatedLegends(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),this.removeItem(t),this.legend(t.channel,t.field,e)})),this._updateBounds()}legend(t,e,i){let s=i||{},n=this.getEncodingByField(e,t);if(!n)throw G.INCORRECT_LEGEND_INFO+e;"x"in s||(s.x=100),"y"in s||(s.y=100);let r=new Qt(n,s);return this.addChild(r),this._itemMap[r.id]=r,this._updateBounds(),r}gridlines(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(!s)return!1;let r=new ae(s,n.item?n.item:s.anyItem,n);return r.values="values"in n?n.values:s._inferTickValues(),this.addChildAt(r,0),this._itemMap[r.id]=r,this._updateBounds(),r}getRelatedLegends(t){let e=[];if(pt(t))return e;for(let i of this.children)i.type===T.Legend&&i.matches(t)&&e.push(i);return e}getRelatedGridlines(t){let e=[];if(pt(t))return e;for(let i of this.children){if(i.type!==T.Gridlines)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=dt(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}propagate(t,e,...i){let s=nt(t,this);for(let t of s)t[e](...i)}getEncodingByItem(t,e){let i=this.encodings[lt(t)];return i&&i[e]?i[e]:null}getEncodingByField(t,e){for(let i in this.encodings){let s=this.encodings[i];if(s[e]&&s[e].field==t)return s[e]}return null}positionBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(!_t(t))return null;for(let i in this.encodings){if(i.split("_")[0]===t.classId&&e in this.encodings[i])return this.encodings[i][e]}}sizeBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(_t(t)){let i="width"===e||"height"===e||"radius"===e?["area"]:["width","height"],s="width"===e?["x"]:"height"===e?["y"]:["x","y"];for(let e in this.encodings){let n=e.split("_")[0];if(e.indexOf("_")<0){for(let s of i)if(n===t.classId&&s in this.encodings[e])return this.encodings[e][s]}else for(let i of s)if(n===t.classId&&i in this.encodings[e])return this.encodings[e][i]}}return null}setProperties(t,e){let i,s={};for(let t in e)s[t]=!0;if(Object.values(y).indexOf(t.type)>-1&&t.group){i=nt(t.group,this);for(let t of i)for(let i in e)t.layout[i]=e[i]}else if(i=nt(t,this),"vertex"===t.type)for(let t of i)for(let i in e)t[i]=e[i];else if(t instanceof H)for(let n in e)if("x"!==n&&"y"!==n||!this.positionBound(t,n))if("width"!==n&&"height"!==n&&"radius"!==n||!this.sizeBound(t,n))t.type!==T.Rect&&t.type!==T.Line||"width"!==n&&"height"!==n?t.type==T.Circle&&"radius"==n?i.forEach((t=>t.resize(2*e[n],2*e[n],e.xRef,e.yRef))):i.forEach((t=>t[n]=e[n])):"width"===n?i.forEach((t=>t.resize(e[n],t.bounds.height,e.xRef))):i.forEach((t=>t.resize(t.bounds.width,e[n],void 0,e.yRef)));else{let i=this.getEncodingByItem(t,n);i||"radius"!=n||(i=this.getEncodingByItem(t,"area"));let s=i.scale.rangeExtent*e[n]/t[n];i.scale.rangeExtent=s}else s[n]=!1;else if("collection"==t.type||"group"==t.type)for(let t of i)for(let i in e)t[i]="layout"===i&&void 0!==e[i]?e[i].clone():e[i];let n=Object.keys(s).filter((t=>s[t])),r=["width","height","fontSize","area","radius"];for(let e of r)if(n.indexOf(e)>=0&&gt(t)){ge(t,i);break}n.indexOf("baseline")>=0&&t.type===T.Area&&ye(t,i);let a=["layout","rowGap","colGap","numRows","numCols","orientation","vertCellAlignment","horzCellAlignment","direction","childrenOrder"],o=n.filter((t=>a.indexOf(t)>=0));return o.length>0&&ue(i[0],i,o),s}_canTranslate(t){let e={x:!0,y:!0};return t.type==T.Axis?("x"===t.channel||"width"===t.channel?e.x=!1:"y"!==t.channel&&"height"!==t.channel||(e.y=!1),e):(t.parent.type===T.Collection&&t.parent.layout&&(e.x=!1,e.y=!1),this.positionBound(t,"x")&&(e.x=!1),this.positionBound(t,"y")&&(e.y=!1),e)}translate(t,e,i){let s=this._canTranslate(t);if(!s.x&&!s.y)return s;const n=s.x?e:0,r=s.y?i:0;return t._doTranslate(n,r),this._updateAncestorBounds(t),de(t,n,r),s}_updateAncestorBounds(t,e){let i=ct(e||nt(t,this));for(;i.length>0;){for(let t of i)(t.children&&t.children.length>0||t.vertices)&&t._updateBounds();i=ct(i)}}_reapplyConstraints(t){let e=t,i=[t];for(;e.children;)e.type==T.Collection?i.push(e.firstChild):i=i.concat(e.children),e=e.firstChild;for(e=t.parent;e&&e.type!==T.Scene;)i.push(e),e=e.parent;const s=i.map((t=>t.classId));for(let t in this.constraints){const e=this.constraints[t];switch(e.type){case E:(s.indexOf(e.item.classId)>=0||s.indexOf(e.baseItem.classId)>=0)&&e.apply();break;case S:for(let t of e.items)if(s.indexOf(t.classId)>=0){e.apply();break}}}}_relayoutAncestors(t,e){let i=ct(e||nt(t,this));for(;i.length>0;){for(let t of i)t.layout&&t.layout.run(),t.children&&t.children.length>0&&t._updateBounds(),t.vertices&&t._updateBounds();i=ct(i)}}_reapplySizeBindings(t){let e=["width","height"];for(let i in this.encodings){if(t.classId!=i)continue;let s=this.encodings[i],n=et(this,[{classId:i}]);for(let t of e){let e=s[t];e&&e.run()}this._relayoutAncestors(n[0],n)}}_registerBinding(t){let e=this.encodings,i=lt(t.anyItem);return i in e||(e[i]={}),e[i][t.channel]=t,!0}toJSON(){let t=super.toJSON();this.fillColor&&(t.fillColor=this.fillColor);let e={};t.encodings=[],t.itemCounter=mt;for(let i in this.encodings)for(let s in this.encodings[i]){let n=this.encodings[i][s];t.encodings.push(n.toJSON()),n.scale&&!(n.scale.id in e)&&(e[n.scale.id]=n.scale.toJSON())}t.scales=e,t.constraints={};for(let e in this.constraints)t.constraints[e]=this.constraints[e].toJSON();t.tables={};let i=this.getDataTables();for(let e in i)t.tables[e]=i[e].toJSON();return t}getDataTables(){let t={};for(let e in this.encodings)for(let i in this.encodings[e]){let s=this.encodings[e][i];s.datatable.id in t||(t[s.datatable.id]=s.datatable)}for(let e of this.children)if(!pt(e)){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}if(e.children&&e.children.length>0){let i=e.firstChild;for(;i;){if(i.dataScope){t[i.dataScope.dataTable.id]=i.dataScope.dataTable;break}i=i.children&&i.children.length>0?i.firstChild:void 0}}}return t}getItem(t){let e=t.split("_")[0];if(t.indexOf("_v_")>0){let i=parseInt(t.split("_v_")[1]);return this._itemMap[e].vertices.find((t=>t._id===i))}if(t.indexOf("_s_")>0){let i=parseInt(t.split("_s_")[1]);return this._itemMap[e].segments.find((t=>t._id===i))}return this._itemMap[t]}addInteraction(t,e,i,s){let n=new Ee(t,e,i,s);this._interactions.push(n)}}class Ae{constructor(t){this._renderer=t,this._globalPredicates={}}processInteraction(t,e){let i=t.listener;if(gt(i)){let s=i.classId?"."+i.classId:"#"+i.id;switch(t.eventType){case"hover":n.selectAll(s).on("mouseover",t.getCallbackFunction(e,this)),n.selectAll(s).on("mouseleave",t.getRestoreFunction(e,this));break;case"click":n.selectAll(s).on("mousedown",t.getCallbackFunction(e,this))}}else if(i.type==T.Scene){if(!t.targetDef||!t.targetDef.item)return;t.selectionDef.item||n.select("#"+this._renderer._svgId).on("mousedown",t.getRestoreFunction(e,this,!0))}}_getSelection(t,e,i,s){let n={};s?n.item=s:e.item;let r=e.field?e.field:h;return n.item&&(n.predicate={field:r,value:n.item.dataScope.getFieldValue(r)}),n}addGlobalPredicate(t,e){t.id in this._globalPredicates||(this._globalPredicates[t.id]={}),this._globalPredicates[t.id][e.field]=e}getGlobalPredicates(t){return t.id in this._globalPredicates?Object.values(this._globalPredicates[t.id]):[]}}class Ie{constructor(t){this._svgId=t,this._compMap={},this._decoMap={},this._interactionHandler=new Ae(this)}render(t,e){let i=e||{};for(let t in this._decoMap)this._decoMap[t].remove(),delete this._decoMap[t];this._removed={};for(let t in this._compMap)this._removed[t]=1;this._renderItem(t,i);for(let t in this._removed)this._compMap[t].remove(),delete this._compMap[t];if(!("visualOnly"in i))for(let e of t._interactions)this._interactionHandler.processInteraction(e,t)}clear(){let t=document.getElementById(this._svgId);for(;t.firstChild;)t.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(t,e){let i,s=t.id,r=t.parent;i=r&&r.id&&r.id in this._compMap?n.select("#"+this._svgId).select("#"+r.id):n.select("#"+this._svgId),s in this._compMap?delete this._removed[s]:this._compMap[s]=i.append(this._getSVGElementType(t)),t.type==T.Gridlines&&this._compMap[s].lower();let a=this._compMap[s];if(a.attr("id",s),t.classId&&a.attr("class",t.classId),t.type==T.Scene&&n.select("#"+this._svgId).style("background",t.fillColor?t.fillColor:"#fff"),"vertex"!=t.type){if(t.type==T.Path||t.type==T.Polygon||t.type==T.Link)a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==T.Line)a.attr("x1",t.vertices[0].x),a.attr("y1",t.vertices[0].y),a.attr("x2",t.vertices[1].x),a.attr("y2",t.vertices[1].y),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==T.Circle)a.attr("cx",t.x),a.attr("cy",t.y),a.attr("r",t.radius);else if(t.type==T.Rect){let e=t.bounds;a.attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height)}else t.type==T.PointText?a.attr("text-anchor",this._getTextAnchor(t.anchor[0])).attr("alignment-baseline",this._getTextAnchor(t.anchor[1])).attr("dominant-baseline",this._getTextAnchor(t.anchor[1])).text(t.text).attr("x",t.x).attr("y",t.y):t.type==T.Pie||t.type==T.Area?(a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges")):t.type==T.Ring||t.type==T.Arc?a.attr("d",t.getSVGPathData()):t.type==T.Image&&a.attr("href",t.src).attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height);for(let e in t.styles)if(void 0!==t.styles[e])if(e.indexOf("Color")>0&&t.styles[e].type==T.LinearGradient){n.select("#"+this._svgId).select("defs").empty()&&n.select("#"+this._svgId).append("defs");let i=n.select("defs"),s=t.styles[e];if(i.select("#"+s.id).empty()){let t=i.append("linearGradient").attr("id",s.id);t.attr("x1",s.x1+"%").attr("x2",s.x2+"%").attr("y1",s.y1+"%").attr("y2",s.y2+"%");for(let e of s.stops)t.append("stop").attr("offset",e.offset+"%").style("stop-color",e.color).style("stop-opacity",e.opacity)}a.style(D[e],"url(#"+s.id+")")}else a.style(D[e],t.styles[e]);if(t._rotate&&a.attr("transform","rotate("+t._rotate.join(" ")+")"),t.vertices&&this._renderVertices(t),t.type==T.Collection&&e&&e.collectionBounds){let e=t.bounds;t.layout&&"grid"==t.layout.type?this._renderLayout(t):(t.id in this._decoMap||(this._decoMap[t.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[t.id].attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("fill","none").attr("stroke","#1ecb40").attr("stroke-width","2px").attr("stroke-dasharray","5,5"))}if(t.children)for(let i of t.children)this._renderItem(i,e)}}_renderVertices(t){let e=t.id+"-vertices";if(e in this._compMap)delete this._removed[e];else{let i=t.parent,s=i?i.id:this._svgId;this._compMap[e]=n.select("#"+s).append("g").attr("id",e)}if(0===t.vertices.map((t=>t.shape)).filter((t=>void 0!==t)).length)return void this._compMap[e].style("visible","hidden");this._compMap[e].style("visible","visible");let i=t.vertices.filter((t=>void 0!==t.shape));for(let t of i){let i=e+"-"+t.id;i in this._compMap?t.shape!==this._compMap[i].node().tagName?(this._compMap[i].remove(),this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),delete this._removed[i]):delete this._removed[i]:this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),"rect"==t.shape?n.select("#"+i).attr("x",t.x-t.width/2).attr("y",t.y-t.height/2).attr("width",t.width).attr("height",t.height):"circle"==t.shape&&n.select("#"+i).attr("cx",t.x).attr("cy",t.y).attr("r",t.radius),n.select("#"+i).style("fill",t.fillColor).style("opacity",t.opacity).style("stroke-width",t.strokeWidth).style("stroke",t.strokeColor)}}_renderLayout(t){let e=t.id+"-grid";e in this._decoMap||(this._decoMap[e]=n.select("#"+this._svgId).append("g").attr("id",e).attr("class","deco"));let i=t.layout.cellBounds,s=t.layout.rowGap;this._decoMap[e].selectAll("rect").remove(),this._decoMap[e].selectAll("rect").data(i.slice(0,i.length-1)).enter().append("rect").attr("x",(t=>t.left)).attr("y",(t=>t.bottom)).attr("width",(t=>t.width)).attr("height",s).style("fill","pink").style("opacity",.5);let r=Math.min(...i.map((t=>t.left))),a=Math.min(...i.map((t=>t.top)));this._decoMap[e].append("rect").attr("x",r).attr("y",a).attr("width",t.bounds.width).attr("height",t.bounds.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getTextAnchor(t){switch(t){case"top":return"text-before-edge";case"bottom":return"text-after-edge";case"left":return"start";case"right":return"end";case"center":case"middle":return"middle";default:return t}}_getSVGElementType(t){switch(t.type){case T.Rect:return"rect";case T.Collection:case T.Group:case T.Glyph:case T.Scene:case T.Axis:case T.Legend:case T.Gridlines:return"g";case T.Area:case T.Path:case T.Polygon:case T.Ring:case T.Pie:case T.Arc:case T.Link:return"path";case T.Circle:return"circle";case T.Line:return"line";case T.PointText:return"text";case"vertex":if("circle"==t.shape)return"circle";if("rect"==t.shape)return"rect";throw"argument exception";case"image":return"image"}}}class Oe{constructor(t,e){switch(this._type=t,this._offset=void 0,this.id="scale"+mt.scale++,this._flipped=!1,this._includeZero=!1,t){case"linear":if(e){let t=Object.keys(e).map((t=>parseFloat(t))).sort(((t,e)=>t-e)),i=t.map((t=>e[t]));this._scale=n.scaleLinear(t,i),"clamp"in e&&this._scale.clamp(e.clamp),this._mapping=e}else this._scale=n.scaleLinear();break;case"point":this._scale=n.scalePoint();break;case"ordinal":this._scale=n.scaleOrdinal();break;case"ordinalColor":this._scale=n.scaleOrdinal(e?e.size?n[e.scheme][e.size]:n[e.scheme]:n.schemeCategory10);break;case"power":this._scale=n.scalePow().exponent(2);break;case"sqrt":this._scale=n.scalePow().exponent(.5);break;case"log":this._scale=n.scaleLog();break;case"identity":case"time":this._scale=n.scaleTime();break;case"sequentialColor":case"divergingColor":e&&"string"==typeof e?(this._scale=n.scaleSequential(n[e]),this._scheme=e):this._scale=n.scaleSequential()}this.encodings=[]}set scheme(t){if(this._type.indexOf("Color")<0&&"linear"!==this._type)return;let e=n.scaleSequential(n[t]),i=this._scale.domain();if(Math.min(...i)*Math.max(...i)<0){let t=Math.max(Math.abs(Math.min(...i)),Math.abs(Math.max(...i)));i=[-t,t]}e.domain(i),this._scheme=t,this._scale=e,"linear"===this._type&&(this._type=this._scale.domain()[0]*this._scale.domain()[1]<0?"divergingColor":"sequentialColor",this._mapping&&(this._mapping=void 0));for(let e of this.encodings)e._mapping&&(e._mapping=void 0),e._scheme=t,e._apply()}get scheme(){return this._scheme}get type(){return this._type}set type(t){let e;switch(t){case"linear":e=n.scaleLinear();break;case"power":e=n.scalePow().exponent(2);break;case"sqrt":e=n.scalePow().exponent(.5);break;case"log":e=n.scaleLog()}if(e){this._type=t,e.domain(this._scale.domain()).range(this._scale.range()),this._scale=e;for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}else console.warn(V+t)}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.offset=this._offset,this._scheme&&(t.scheme=this._scheme),t.domain=this._scale.domain(),t.range=this.range,t.clamp=this.clamp,t.isFlipped=this.isFlipped,t.includeZero=this.includeZero,this._mapping&&(t.mapping=this._mapping),t}_merge(t){if(this.type!=t.type)throw G.DIFFERENT_SCALE_TYPE;let e,i;switch(this.type){case"linear":case"time":e=[Math.min(this.domain[0],t.domain[0]),Math.max(this.domain[1],t.domain[1])],i=[0,this.map(e[1])-this.map(e[0])];break;case"point":case"ordinalColor":e=[...new Set(this.domain.concat(t.domain))],i=[];break;default:console.log("TODO: merge scale type",this.type)}this._scale.domain(e),this._scale.range(i)}get domain(){if(this._includeZero){return[0,this._scale.domain()[1]]}return this._scale.domain()}set domain(t){this._scale.domain(t);for(let t of this.encodings)t._apply()}get range(){return this._scale.range()}
1
+ /* version: 1.12.0 */
2
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","d3","pixi.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msc={},t.d3,t.PIXI)}(this,(function(t,e,i){"use strict";function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var n=s(e),r=s(i);class a{constructor(t,e,i,s){this.left=t,this.top=e,this.width=i,this.height=s}toJSON(){let t={};return t.left=this.left,t.top=this.top,t.width=this.width,t.height=this.height,t}union(t){let e=Math.min(this.left,t.left),i=Math.min(this.top,t.top),s=Math.max(this.right,t.right),n=Math.max(this.bottom,t.bottom);return new a(e,i,s-e,n-i)}clone(){return new a(this.left,this.top,this.width,this.height)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get x(){return(this.left+this.right)/2}get y(){return(this.top+this.bottom)/2}get center(){return(this.left+this.right)/2}get middle(){return(this.top+this.bottom)/2}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}overlap(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}const o="id",h="atlas_rowId",l=["linear","power","log","sqrt","symlog","identity","time","ordinal","band","point","ordinalColor","sequentialColor","divergingColor"],c="natural",d="basis",u="bumpX",f="bumpY",p="linear",g="step",_="CatmullRom",m="cardinal",y={Grid:"grid",Circular:"circular",Stack:"stack",Treemap:"treemap",Packing:"packing",Force:"force",TidyTree:"tidytree",Sugiyama:"sugiyama",Strata:"strata"},v="vertical",b="horizontal",x="angular",w="radial",k={Up:"up",Down:"down",Left:"left",Right:"right",Inward:"inward",Outward:"outward",Clockwise:"clockwise",Anticlockwise:"anticlockwise"},C={Top:"top",Left:"left",Bottom:"bottom",Right:"right",Center:"center",Middle:"middle"},S="alignment",E="affixation",T={Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"pointText",Collection:"collection",Group:"group",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable"},A={Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"},I="max",O="min",R="avg",M="median",N="sum",P="count",F="mean",B="percentile 25",L="percentile 75",D={fillColor:"fill",strokeColor:"stroke",strokeWidth:"stroke-width",fillOpacity:"fill-opacity",strokeOpacity:"stroke-opacity",strokeDash:"stroke-dasharray",opacity:"opacity",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",visibility:"visibility"},j="Cannot find relevant information to create an axis for ",V="Cannot change scale type to ",G={FIELD_NONEXISTENT:"Data field does not exist in the data table",INCOMPLETE_REPEAT_INFO:"Incomplete information to do repeat. You must specify an item, a categorical data field and a data table",REPEAT_BY_NONCAT:"Repeat only works on a string or date field",PARTITION_BY_NONCAT:"Divide only works on a string or date field",DENSIFY_BY_NONCAT:"Densify only works on a string or date field",INCOMPLETE_REPOPULATE_INFO:"Incomplete information to re-populate. You must specify an item, a categorical data field and a data table",REPOPULATE_BY_NONCAT:"Repopulate only works on a string or date field",REPOPULATE_DT_MISMATCH:"Cannot repopulate with a data table that is different from the item's parent's data table",COMPNT_NON_REPEATABLE:"Item not repeatable",REPEAT_NODE_LINK:"To repeat with a tree or a network, you need to provide two marks, one for node and one for link",INCOMPLETE_PARTITION_INFO:"Incomplete information to divide. You must specify an item, a categorical data field and a data table",COMPNT_NON_PARTITIONABLE:"Item cannot be divided",INCOMPLETE_DENSIFY_INFO:"Incomplete information to densify. You must specify an item, a categorical data field and a data table",COMPNT_NON_DENSIFIABLE:"Item cannot be densified",STRATIFY_WITHOUT_TREE:"Stratify only works on a tree dataset",STRATIFY_WRONG_ITEM:"Stratify only works on a circle or a rectangle",BIND_WITHOUT_DATASCOPE:"Item must be repeated or divided by data first before applyng binding",UNKNOWN_ALIGNMENT:"Unkown alignment",UNKNOWN_Orientation:"Unkown orientation",UNKNOWN_DIRECTION:"Unkown direction",UNKOWNN_SCALE_TYPE:"Unknown scale type",UNKNOWN_ANCHOR:"Unknown anchor",INCOMPLETE_BINDING_INFO:"Incomplete binding information. You must specify an item, a data field and a visual channel",MULTIPLE_VALUES_PER_FIELD:"Multiple distinct field values exist",DIFFERENT_SCALE_TYPE:"Cannot merge different types of scale",INSUFFICIENT_DATA_SCOPES:"Insufficient data to divide or densify a mark",INCORRECT_CONSTRAINT_INFO:"Constrain information is incorreclty passed",FEATURE_NOT_IMPLEMENTED:"This feature has not been implemented yet",LAYOUT_WITHOUT_TREE:"The layout can only be applied to a tree",UNSUPPORTED_FIELDTYPE:"Unsupported field type for encoding ",CANNOT_CLASSIFY:"Cannot classify items in "},z=["schemeCategory10","schemeAccent","schemeDark2","schemePaired","schemePastel1","schemePastel2","schemeSet1","schemeSet2","schemeSet3","schemeTableau10"],W=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],U=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class q{constructor(t){this.group=void 0}run(){}clone(){}}class Y extends q{constructor(t){super(),this.type="grid",this._numCols=t.numCols,this._numRows=t.numRows,this._dir="dir"in t?t.dir:[Y.direction.Left2Right,Y.direction.Top2Bottom],this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&this._validateCellAlignment("h",t.horzCellAlignment)?t.horzCellAlignment:C.Left,this._cellVertAlignment="vertCellAlignment"in t&&this._validateCellAlignment("v",t.vertCellAlignment)?t.vertCellAlignment:C.Bottom,this._numCols||this._numRows||(this._numRows=1)}_validateCellAlignment(t,e){return"h"===t&&[C.Left,C.Center,C.Right].indexOf(e)>=0||("v"===t&&[C.Top,C.Middle,C.Bottom].indexOf(e)>=0||(console.warn("Invalid alignment:",e),!1))}toJSON(){let t={args:{}};return t.type=this.type,t.args.numCols=this._numCols,t.args.numRows=this._numRows,t.args.colGap=this._colGap,t.args.rowGap=this._rowGap,t.args.horzCellAlignment=this._cellHorzAlignment,t.args.vertCellAlignment=this._cellVertAlignment,t.left=this._left,t.top=this._top,t.args.dir=this._dir,t}clone(){return new Y({numCols:this._numCols,numRows:this._numRows,dir:this._dir,colGap:this._colGap,rowGap:this._rowGap})}get cellBounds(){let t,e,i=this.group,s=this._colGap,n=this._rowGap;this._numRows?(e=this._numRows,t=Math.ceil(this.group.children.length/this._numRows)):this._numCols&&(t=this._numCols,e=Math.ceil(this.group.children.length/this._numCols));let r=i.children.map((t=>t.bounds));if(void 0===this._left){let t=r.map((t=>t.left)),e=r.map((t=>t.top));this._left=Math.min(...t),this._top=Math.min(...e)}let o=r.map((t=>t.width)),h=r.map((t=>t.height)),l=Math.max(...o),c=Math.max(...h),d=i.getInternalEncodings("x"),u=i.getInternalEncodings("y"),f=i.getInternalEncodings("width"),p=i.getInternalEncodings("height"),g=0;if(d.length>0){let t=d[d.length-1];l=t.scale.rangeExtent,g=t.scale.range[0],"point"===t.scale.type&&(l+=t.anyItem.bounds.width)}else f.length>0&&f[f.length-1]._rectNegativeValues&&(l=f[f.length-1].scale.rangeExtent,g=f[f.length-1].scale.range[0]);if(u.length>0){let t=u[u.length-1];c=t.scale.rangeExtent,"point"===t.scale.type&&(c+=t.anyItem.bounds.height)}else p.length>0&&p[p.length-1]._rectNegativeValues&&(c=p[p.length-1].scale.rangeExtent);let _=[],m=e*t;switch(this._dir[0]){case Y.direction.Left2Right:switch(this._dir[1]){case Y.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(this._left+(l+s)*(e%t)+g,this._top+(c+n)*Math.floor(e/t),l,c));break;case Y.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(this._left+(l+s)*(e%t)+g,this._top+(this.numRows-1-Math.floor(e/t))*(c+n),l,c))}break;case Y.direction.Right2Left:switch(this._dir[1]){case Y.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(g+this._left+(t-1)*(l+s)-(l+s)*(e%t),this._top+(c+n)*Math.floor(e/t),l,c));break;case Y.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(g+this._left+(t-1-e%t)*(l+s),this._top+(this.numRows-1-Math.floor(e/t))*(c+n),l,c))}break;case Y.direction.Top2Bottom:switch(this._dir[1]){case Y.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),l,c));break;case Y.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*(this.numCols-1)-(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),l,c))}break;case Y.direction.Bottom2Top:switch(this._dir[1]){case Y.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),l,c));break;case Y.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(g+this._left+(l+s)*(this.numCols-1)-(l+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),l,c))}}return _}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.cellBounds,e=this.group.getInternalEncodings("x"),i=this.group.getInternalEncodings("y"),s=this.group.getInternalEncodings("width"),n=this.group.getInternalEncodings("height");for(let s=0;s<this.group.children.length;s++){let n=this.group.children[s],r=t[s],a=r.x-n.bounds.x,o=r.y-n.bounds.y;n._doTranslate(a,o);let h=0,l=0;if(0==e.length)switch(this._cellHorzAlignment){case C.Left:h=r.left-n.bounds.left;break;case C.Center:h=r.x-n.bounds.x;break;case C.Right:h=r.right-n.bounds.right}if(0==i.length)switch(this._cellVertAlignment){case C.Top:l=r.top-n.bounds.top;break;case C.Middle:l=r.y-n.bounds.y;break;case C.Bottom:l=r.bottom-n.bounds.bottom}n._doTranslate(h,l)}if(e.length>0)for(let t of e)t._apply();else if(s.length>0){let t=s[s.length-1];t._rectNegativeValues&&t._apply()}if(i.length>0)for(let t of i)t._apply();else if(n.length>0){let t=n[n.length-1];t._rectNegativeValues&&t._apply()}this.group._updateBounds()}set rowGap(t){this._rowGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get rowGap(){return this._rowGap}set colGap(t){this._colGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get colGap(){return this._colGap}set numCols(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"columns for",this.group.children.length,"items in grid"):(this._numCols=t,this._numRows=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numRows(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"rows for",this.group.children.length,"items in grid"):(this._numRows=t,this._numCols=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}set vertCellAlignment(t){if(t!=C.Top&&t!=C.Bottom&&t!=C.Middle)throw G.UNKOWN_ALIGNMENT;this._cellVertAlignment=t,this.run()}get vertCellAlignment(){return this._cellVertAlignment}set horzCellAlignment(t){if(t!=C.Left&&t!=C.Center&&t!=C.Right)throw G.UNKOWN_ALIGNMENT;this._cellHorzAlignment=t,this.run()}get horzCellAlignment(){return this._cellHorzAlignment}set direction(t){Array.isArray(t)&&2===t.length?this._dir=t:this._dir=t.split("_"),this.run()}get direction(){return this._dir.join("_")}}Y.direction={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"};class J{constructor(t){this._stops=[],this.type=T.LinearGradient,this.id=this.type+vt[this.type]++,this.x1="x1"in t?t.x1:0,this.x2="x2"in t?t.x2:100,this.y1="y1"in t?t.y1:0,this.y2="y2"in t?t.y2:0}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,i){this._stops.push({offset:t,color:e,opacity:i})}get stops(){return this._stops}}class H{constructor(t){if(this._dataScope=void 0,this._id=void 0,this.attrs={},this.styles={},this.staticProperties={},void 0!==t)for(let e in D)e in t&&(this.styles[e]=t[e])}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){if(!this._bounds)return!1;if(!this._bounds.contains(t,e))return!1;switch(this.type){case T.Rect:case T.PointText:return!0;case T.Circle:return Math.sqrt(Math.pow(t-this.x,2)+Math.pow(e-this.y,2))<=this.radius+this.strokeWidth;case T.Path:{let i=wt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),this.closed?i.isPointInPath(s,t,e):i.isPointInStroke(s,t,e)}case T.Line:{let i=wt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),i.isPointInStroke(s,t,e)}default:{let i=wt.getContext(),s=new Path2D(this.getSVGPathData());return i.isPointInPath(s,t,e)}}}toJSON(){let t={};t.type=this.type,t.id=this.id,this.classId&&(t.classId=this.classId),this._dataScope&&(t.dataScope=this._dataScope.toJSON()),t.args={};for(let e in this.attrs)t.args[e]=this.attrs[e];for(let e in this.styles)e.indexOf("Color")>0&&this.styles[e]instanceof J?t.args[e]=this.styles[e].toJSON():t.args[e]=this.styles[e];return t}getScene(){let t=this;for(;t;){if(t.type==T.Scene)return t;t=t.parent}}set dataScope(t){this._dataScope=t}get dataScope(){return this._dataScope}duplicate(){let t=this.getScene().mark(this.type);return this.copyPropertiesTo(t),t.classId=this.classId,this._dataScope&&(t._dataScope=this._dataScope.clone()),t}_doTranslate(t,e){}set visibility(t){this.styles.visibility=t}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity=t}}function $(t){return t>=-1e-12&&t<=1e-12}class Z{constructor(t,e){this.x=t,this.y=e}transform(t){return t?t._transformPoint(this):this}negate(){return new Z(-this.x,-this.y)}subtract(t){return new Z(this.x-t.x,this.y-t.y)}isZero(){return $(this.x)&&$(this.y)}isCollinear(t){let e=this.x,i=this.y,s=t.x,n=t.y;return Math.abs(e*n-i*s)<=1e-8*Math.sqrt((e*e+i*i)*(s*s+n*n))}}class K{constructor(t,e,i){this.type="vertex",this._id=i,this.x=t.x,this.y=t.y,this.dataScope=void 0,this.parent=e,this.shape=void 0,this.width=0,this.height=0,this.radius=0,this.fillColor="#555",this.opacity=1,this.strokeWidth=0,this.strokeColor="#aaa",this._polarAngle=void 0}get bounds(){switch(this.shape){case"rect":return new a(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new a(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new a(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}toJSON(){let t={};return t.type=this.type,t.id=this._id,t.x=this.x,t.y=this.y,this.dataScope&&(t.dataScope=this.dataScope.toJSON()),void 0!==this._polarAngle&&(t.polarAngle=this._polarAngle),t.shape=this.shape,t.width=this.width,t.height=this.height,t.radius=this.radius,t.fillColor=this.fillColor,t.opacity=this.opacity,t.strokeWidth=this.strokeWidth,t.strokeColor=this.strokeColor,t}static fromJSON(t,e){let i=new K(t,e,t.id);return t.dataScope&&(i.dataScope=t.dataScope),"polarAngle"in t&&(i.polarAngle=t.polarAngle),i.shape=t.shape,i.width=t.width,i.height=t.height,i.radius=t.radius,i.fillColor=t.fillColor,i.opacity=t.opacity,i.strokeWidth=t.strokeWidth,i.strokeColor=t.strokeColor,i}_doTranslate(t,e){this.x+=t,this.y+=e}_clone(t){let e=new K(new Z(this.x,this.y),t,this._id);return this.dataScope&&(e.dataScope=this.dataScope.clone()),e.shape=this.shape,e.width=this.width,e.height=this.height,e.radius=this.radius,e.fillColor=this.fillColor,e.opacity=this.opacity,e.strokeWidth=this.strokeWidth,e.strokeColor=this.strokeColor,e}set polarAngle(t){this._polarAngle=t}get polarAngle(){return this._polarAngle}}K.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class X{constructor(t,e,i,s){this.type="segment",this._id=s,this.vertex1=t,this.vertex2=e,this.dataScope=void 0,this.parent=i}get id(){return this.parent.id+"_s_"+this._id}_doTranslate(t,e){this.vertex1._doTranslate(t,e),this.vertex2._doTranslate(t,e)}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}}class Q extends H{constructor(t){if(super(t),this.type="type"in t?t.type:T.Path,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none"),this.vertices=[],this.vertexCounter=0,this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed=!1,this.curveMode="linear",this.boundsOffsets={top:0,bottom:0,left:0,right:0},this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1,void 0!==t){for(let e of K.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&this._setVertices(t.vertices)}}toJSON(){let t=super.toJSON();switch(t.type=this.type,t.id=this.id,this.type){case T.Rect:t.args.width=this.width,t.args.height=this.height,t.args.top=this.top,t.args.left=this.left;break;case T.Circle:t.args.x=this.x,t.args.y=this.y,t.args.radius=this.radius;break;case T.Arc:case T.Pie:t.args.x=this._x,t.args.y=this._y,t.args.innerRadius=this._innerRadius,t.args.outerRadius=this._outerRadius,t.args.startAngle=this._startAngle,t.args.endAngle=this._endAngle;break;default:t.vertices=[];for(let e of this.vertices)t.vertices.push(e.toJSON());this.type===T.Polygon?(t.args.x=this._x,t.args.y=this._y,t.args.radius=this._radius):this.type===T.Area&&(t.args.baseline=this._baseline,t.args.orientation=this._orientation)}t.vertexCounter=this.vertexCounter,t.segmentCounter=this.segmentCounter,t.curveMode=this.curveMode,this._bounds&&(t.bounds=this._bounds.toJSON()),t.boundsOffsets=this.boundsOffsets;for(let e of K.styles)t.args[e]=this[e];return t}_setVertices(t){let e,i;this.vertices=[],this.segments=[];for(let s=0;s<t.length;s++)if(s!=t.length-1||t[s][0]!==t[0][0]||t[s][1]!==t[0][1]||this.type!==T.Path){i=new Z(t[s][0],t[s][1]),e=new K(i,this,this.vertexCounter++);for(let t of K.styles)if(this[t]){let i=t.replace("vx","");e[i[0].toLowerCase()+i.slice(1)]=this[t]}this.vertices.push(e),s>0&&this.segments.push(new X(this.vertices[s-1],this.vertices[s],this,this.segmentCounter++))}let s=t[0],n=t[t.length-1];(s[0]===n[0]&&s[1]===n[1]||this.type===T.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new X(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of K.styles)this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScope&&(t._dataScope=this._dataScope.clone()),t.closed=this.closed,t.curveMode=this.curveMode,t.vertices=[],t.segments=[];for(let e of this.vertices)t.vertices.push(e._clone(t));t.segmentCounter=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new X(t.vertices[e-1],t.vertices[e],t,t.segmentCounter++));t.closed&&t.segments.push(new X(t.vertices[t.vertices.length-1],t.vertices[0],t,t.segmentCounter++))}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){this._bounds||this._updateBounds();let t=this._bounds.bottom+this.boundsOffsets.bottom-(this._bounds.top-this.boundsOffsets.top),e=this._bounds.right+this.boundsOffsets.right-(this._bounds.left-this.boundsOffsets.left);return new a(this._bounds.left-this.boundsOffsets.left,this._bounds.top-this.boundsOffsets.top,e,t)}get x(){return this.bounds.x}get y(){return this.bounds.y}get strokeColor(){return this.styles.strokeColor}set strokeColor(t){this.styles.strokeColor=t}get strokeWidth(){return this.styles.strokeWidth}set strokeWidth(t){this.styles.strokeWidth=t}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash=t}_doTranslate(t,e){for(let i of this.vertices)i._doTranslate(t,e);this._updateBounds()}resize(t,e,i,s){let n=this.bounds,r=0===n.width?1:n.width,a=0===n.height?1:n.height;if("right"===i)for(let e of this.vertices)e.x=n.right-t/r*(n.right-e.x);else for(let e of this.vertices)e.x=n.left+t/r*(e.x-n.left);if("top"===s)for(let t of this.vertices)t.y=n.top+e/a*(t.y-n.top);else for(let t of this.vertices)t.y=n.bottom-e/a*(n.bottom-t.y);this._updateBounds()}_updateBounds(){let t=this.vertices.map((t=>t.x)),e=this.vertices.map((t=>t.y)),i=Math.min(...t),s=Math.min(...e),n=Math.max(...t),r=Math.max(...e);if(this._bounds=new a(i,s,n-i,r-s),this.type===T.Line||this.type===T.Path){let t=this.styles.strokeWidth?this.styles.strokeWidth:1;i===n?this._bounds=new a(i-t/2,s,n-i+t,r-s):s===r&&(this._bounds=new a(i,s-t/2,n-i,r-s+t))}}addVertex(t,e,i){let s=new K(new Z(t,e),this,this.vertexCounter++);this.vertices.splice(i,0,s)}sortVertices(t,e){this.vertices.sort(((e,i)=>e[t]-i[t])),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}sortVerticesByData(t,e,i){let s;s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1,this.vertices.sort(s),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}getSVGPathData(){let t=n.path(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t of this.vertices)e.point(t.x,t.y);return this.closed&&e.point(this.vertices[0].x,this.vertices[0].y),e.lineEnd(),t._}get firstVertex(){return this.vertices[0]}get firstSegment(){return this.segments[0]}get lastVertex(){return this.vertices[this.vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_getD3CurveFunction(t){switch(t){case c:return n.curveNatural;case d:return n.curveBasis;case u:return n.curveBumpX;case f:return n.curveBumpY;case p:return n.curveLinear;case g:return n.curveStep;case _:return n.curveCatmullRom;case m:return n.curveCardinal;default:return n.curveLinear}}get vxShape(){return this._vxShape}set vxShape(t){this._vxShape=t;for(let e of this.vertices)e.shape=t}get vxWidth(){return this._vxWidth}set vxWidth(t){this._vxWidth=t;for(let e of this.vertices)e.width=t}get vxHeight(){return this._vxHeight}set vxHeight(t){this._vxHeight=t;for(let e of this.vertices)e.height=t}get vxRadius(){return this._vxRadius}set vxRadius(t){this._vxRadius=t;for(let e of this.vertices)e.radius=t}get vxFillColor(){return this._vxFillColor}set vxFillColor(t){this._vxFillColor=t;for(let e of this.vertices)e.fillColor=t}get vxStrokeColor(){return this._vxStrokeColor}set vxStrokeColor(t){this._vxStrokeColor=t;for(let e of this.vertices)e.strokeColor=t}get vxStrokeWidth(){return this._vxStrokeWidth}set vxStrokeWidth(t){this._vxStrokeWidth=t;for(let e of this.vertices)e.strokeWidth=t}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}}function tt(t,e){if("field"in e){if(!t.dataScope)return!1;let i=e.field;if("value"in e)return t.dataScope.getFieldValue(i)===e.value;if("interval"in e){let s=t.dataScope.getFieldValue(i);return s>=e.interval[0]&&s<=e.interval[1]}return"values"in e?e.values.indexOf(t.dataScope.getFieldValue(i))>=0:t.dataScope.hasField(i)}if("channel"in e){let i=e.channel;if("value"in e)return t[i]===e.value;if("interval"in e)return t[i]>=e.interval[0]&&t[i]<=e.interval[1];if("values"in e)return e.values.indexOf(t[i])>=0}else{if("type"in e)return t.type===e.type;if("id"in e)return t.id===e.id;if("classId"in e)return t.classId===e.classId;if("fields"in e){if(!t.dataScope)return!1;let i=e.fields[0],s=e.fields[1],n=t.dataScope.getFieldValue(i),r=t.dataScope.getFieldValue(s);switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}}}return!1}function et(t,e){let i=[];return it(t,e,i),i}function it(t,e,i){if(t&&"axis"!=t.type&&"legend"!=t.type&&"gridlines"!=t.type)if(st(t,e)&&i.push(t),t.vertices)for(let s of t.vertices.concat(t.segments))st(s,e)&&i.push(s);else if(t.children&&t.children.length>0)for(let s of t.children)it(s,e,i)}function st(t,e){for(let i of e)if(!tt(t,i))return!1;return!0}function nt(t,e){return"vertex"==t.type?function(t,e){if(!t.classId){if(t.dataScope){let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=et(e,[{classId:i.classId}]),n=[];if(i.type===T.Area){let e=i.vertices.indexOf(t)<i.vertices.length/2;for(let t of s){let i=e?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);n=n.concat(i.filter((t=>t.dataScope)))}}else for(let t of s)n=n.concat(t.vertices.filter((t=>t.dataScope)));return n}{let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=i.vertices.indexOf(t),n=et(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.vertices[s]);return r}}}(t,e):"segment"==t.type?function(t,e){if(t.dataScope){let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=et(e,[{classId:i.classId}]),n=[];for(let t of s)n=n.concat(t.segments);return n}{let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=i.segments.indexOf(t),n=et(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.segments[s]);return r}}(t,e):t.classId?et(e,[{classId:t.classId}]):[]}function rt(t,e){let i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout&&(!e||e&&i.layout.type===e))return i.layout;i=i.parent}}function at(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function ot(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout)return i.children.findIndex((t=>t==e));e=e.parent,i=e.parent}}function ht(t){let e=t,i=t.parent;for(;i&&i.type!=T.Scene;){if(i.layout&&i.layout.type==y.Grid){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function lt(t,e){let i,s=t.parent;for(;s&&s.type!==T.Scene;)s.layout&&(!e||e&&s.layout.type===e)&&(i=s.layout),s=s.parent;return i}function ct(t){if(t.classId)return t.classId;if("vertex"==t.type&&t.dataScope){if(t.parent.type===T.Area){let e=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;return t.parent.classId+"_v_"+(e?0:t.parent.vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v_"+t.parent.vertices.indexOf(t):"segment"==t.type&&t.dataScope?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s_"+t.parent.segments.indexOf(t):null}function dt(t,e){return ct(t).split("_")[0]===ct(e).split("_")[0]}function ut(t){let e=[];for(let i of t)i.parent&&e.indexOf(i.parent)<0&&e.push(i.parent);return e}function ft(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e.push(i),e=e.concat(ft(i));return e}function pt(t){let e=[];if(mt(t))e.push(t);else if(t.children&&t.children.length>0&&!_t(t))for(let i of t.children)e=e.concat(pt(i));return e}function gt(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e=e.concat(gt(i));else e.push(t);return e}function _t(t){return t.type===T.Axis||t.type===T.Legend||t.type===T.Gridlines}function mt(t){return t instanceof H}function yt(t){return t instanceof Q}const vt={area:0,rect:0,circle:0,pie:0,line:0,path:0,ring:0,arc:0,image:0,pointText:0,collection:0,group:0,scene:0,axis:0,glyph:0,legend:0,polygon:0,gridlines:0,LinearGradient:0,link:0,scale:0,datatable:0};function bt(t,e){if(e.getEncodingByItem(t,"x"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==y.Grid&&e.numCols>1)return!1}return!t.parent||t.parent.type==T.Scene||bt(t.parent,e)}function xt(t,e){if(e.getEncodingByItem(t,"y"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==y.Grid&&e.numRows>1)return!1}return!t.parent||t.parent.type==T.Scene||xt(t.parent,e)}var wt={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var t=this.getCanvas();return t?t.getContext("2d"):null}},kt={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}};function Ct(t){let e=t.parent;return e.type==T.Scene?t:Ct(e)}function St(t){let e=t.parent;return t.type==T.Collection?e.type==T.Collection?St(e):t:e.type!=T.Scene?St(e):void 0}function Et(t,e,i,s){return[i*Math.cos(At(s))+t,e-i*Math.sin(At(s))]}function Tt(t,e,i,s){let n=function(t){return 180*t/Math.PI}(Math.atan2(s-e,t-i));n=Math.round(10*n+Number.EPSILON)/10,n<0&&(n+=360);let r=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-s,2));return r=Math.round(10*r+Number.EPSILON)/10,[n,r]}function At(t){return t*Math.PI/180}function It(t){let e=t.vertices.length;for(let i=0;i<t.vertices.length/2;i++){let s=i,n=e-i-1,r=t.vertices[s],a=t.vertices[n];if(r.x!=a.x||r.y!=a.y)return r.x==a.x?"horizontal":"vertical"}}class Ot{constructor(){this.children=[],this._dataScope=void 0,this._layout=void 0,this.type=T.Group,this._id=this.type+vt[this.type]++}get id(){return this._id}set id(t){this.type!==T.Scene&&this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}toJSON(){let t={};if(t.type=this.type,t.id=this.id,this._dataScope&&(t.dataScope=this._dataScope.toJSON()),this.classId&&(t.classId=this.classId),this._layout&&(t.layout=this._layout.toJSON()),this._bounds&&(t.bounds=this._bounds.toJSON()),t.children=[],this.children.length>0&&this.type!=T.Axis)for(let e of this.children)t.children.push(e.toJSON());return this.childrenOrder&&(t.childrenOrder=this.childrenOrder),t}addChild(t){this.children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this.children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this.children=[]}getScene(){let t=this;for(;t;){if(t.type==T.Scene)return t;t=t.parent}}get dataScope(){return this._dataScope}set dataScope(t){if(this._dataScope=t,void 0===t)for(let e of this.children)e.dataScope=t;else for(let e of this.children)e.dataScope?e.dataScope=e.dataScope.merge(t):e.dataScope=t}_doTranslate(t,e){for(let i of this.children)i._doTranslate(t,e);this._updateBounds(),this._layout&&(void 0!==this._layout._left&&(this._layout._left+=t),void 0!==this._layout._top&&(this._layout._top+=e),void 0!==this._layout.x&&(this._layout.x+=t),void 0!==this._layout.y&&(this._layout.y+=e)),this._updateBounds()}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],i=this.getScene(),s=Object.keys(i.encodings),n=[];for(;e;){if(e.classId&&n.indexOf(e.classId)<0&&n.push(e.classId),e.type===T.Glyph){e.children.forEach((t=>n.push(t.classId)));break}if(!e.children)break;e=e.children[0]}let r=[];for(let e of s){let s=e.split("_");for(let a of n)s[0]==a&&i.encodings[e][t]&&r.push(i.encodings[e][t])}return r}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t)t.group=this,this._layout.run();else{let t=this.getInternalEncodings("x"),e=this.getInternalEncodings("y");for(let e of t)e._map(),e._apply();for(let t of e)t._map(),t._apply()}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let t=this.children.map((t=>t.refBounds)),e=Math.min(...t.map((t=>t.left))),i=Math.min(...t.map((t=>t.top))),s=Math.max(...t.map((t=>t.right))),n=Math.max(...t.map((t=>t.bottom)));return new a(e,i,s-e,n-i)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){if(this.children.length>0){this._bounds=this.children[0].bounds.clone();for(let t=1;t<this.children.length;t++)"hidden"!=this.children[t].visibility&&(this._bounds=this._bounds.union(this.children[t].bounds));if(this._layout&&"grid"==this._layout.type){let t=this._layout.cellBounds;for(let e=0;e<t.length;e++)this._bounds=this._bounds.union(t[e])}}else this._bounds=new a(0,0,0,0)}sortChildrenByData(t,e,i){let s;switch(this.children[0].dataScope.getFieldType(t)){case A.Date:break;case A.Number:case A.Integer:s=(e,i)=>e.dataScope.aggregateNumericalField(t)-i.dataScope.aggregateNumericalField(t);break;case A.String:s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1}this.children.sort(s),e&&this.children.reverse(),this.layout&&this.layout.run(),this._childrenOrder={field:t,direction:e?"desc":"asc",ranking:i}}sortChildren(t,e){let i;switch(t){case"x":case"y":case"width":case"height":i=(e,i)=>e.bounds[t]-i.bounds[t];break;default:i=(e,i)=>e[t]-i[t]}this.children.sort(i),e&&this.children.reverse(),this.layout&&this.layout.run(),this.childrenOrder={channel:t,reverse:e}}set visibility(t){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}get visibility(){return this._visibility?this._visibility:"visible"}}function Rt(t){return[...new Set(t)]}function Mt(t,e){if(e.hasField(t))return!0;if(e.tree&&e.tree.nodeTable.hasField(t.split(".")[1]))return!0;throw new Error(G.FIELD_NONEXISTENT+", field: "+t+", data table: "+e.name)}function Nt(t){return t<0?t+360:t>360?t-360:t}class Pt{constructor(t){this._field2value={},this._dt=t,this._tuples=this._dt.data}toJSON(){let t={};return t.dt=this._dt.id,t.f2v=Object.assign({},this._field2value),t}isFullTable(){return 0===Object.keys(this._field2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get fields(){return Object.keys(this._field2value)}get dataTable(){return this._dt}get filters(){return this._field2value}merge(t){let e=new Pt(this._dt);for(let i in t._field2value)e=e.cross(i,t._field2value[i]);for(let t in this._field2value)e=e.cross(t,this._field2value[t]);return e}cross(t,e){let i=this.clone();return i._field2value[t]=e,i._updateTuples(t,e),i}clone(){let t=new Pt(this._dt);return t._field2value=Object.assign({},this._field2value),t._tuples=this._tuples.map((t=>t)),t}getFieldValue(t){let e=this._tuples.map((e=>e[t]));return e=[...new Set(e)],e.length,e[0]}getUniqueFieldValues(t){let e=this._tuples.map((e=>e[t]));return[...new Set(e)]}hasField(t){return t in this._field2value}getFieldType(t){return this._dt.getFieldType(t)}aggregateNumericalField(t,e){let i=this._tuples.map((e=>e[t]));switch(e){case I:return Math.max(...i);case O:return Math.min(...i);case R:case F:return n.mean(i);case M:return n.median(i);case P:return i.length;case B:return n.quantile(i,.25);case L:return n.quantile(i,.75);case N:default:return n.sum(i)}}_updateTuples(t,e){this._tuples=this._tuples.filter((i=>i[t]==e))}get tuples(){return this._tuples}}function Ft(t,e,i,s,n){let r=n?s.transformField(i,n):i,a=s.getFieldType(r);if(a!=A.String&&a!=A.Date&&a!=A.Integer)throw new Error(G.REPEAT_BY_NONCAT+": "+r+" is "+a);if(!sd(e))throw new Error(G.COMPNT_NON_REPEATABLE);return function(t,e,i,s){let n=s.getFieldSummary(i).unique.map((t=>e.dataScope?e.dataScope.cross(i,t):new Pt(s).cross(i,t)));n=n.filter((t=>!t.isEmpty()));let r=t.collection();r.dataScope=e.dataScope?e.dataScope.clone():new Pt(s),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}return r.children.forEach(((t,e)=>t.dataScope=n[e])),t._reapplySizeBindings(e),r}(t,e,r,s)}class Bt extends q{constructor(t){super(t),this.type=y.Stack,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:C.Left,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:C.Bottom,this._gap="gap"in t?t.gap:0}toJSON(){let t={args:{}};return t.type=this.type,t.args.orientation=this._orientation,t.args.direction=this._direction,t.args.left=this._left,t.args.top=this._top,t.args.gap=this._gap,t.args.horzCellAlignment=this._horzCellAlignment,t.args.vertCellAlignment=this._vertCellAlignment,t}clone(){let t=new Bt({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}_stackAreasVert(){let t=this.group.children,e=this.group.bounds,i=this._vertCellAlignment===C.Top?e.top:e.bottom,s=this._vertCellAlignment===C.Top?1:-1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],h=Math.abs(a.y-o.y),l=i+r[t]*s,c=i+(r[t]+h)*s;a._doTranslate(0,l-a.y),o._doTranslate(0,c-o.y),r[t]+=h}e._updateBounds()}if(this.vertCellAlignment===C.Middle)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.middle+r[t]/2;s._doTranslate(0,o-e.bottom),a._doTranslate(0,o-e.bottom)}i._updateBounds()}this.group._updateBounds()}_stackAreasHorz(){let t=this.group.children,e=this.group.bounds,i=this._horzCellAlignment===C.Right?e.right:e.left,s=this._horzCellAlignment===C.Right?-1:1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],h=Math.abs(a.x-o.x),l=i+r[t]*s,c=i+(r[t]+h)*s;a._doTranslate(0,l-a.y),o._doTranslate(0,c-o.y),r[t]+=h}e._updateBounds()}if(this._horzCellAlignment===C.Center)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.center-r[t]/2;s._doTranslate(0,o-e.left),a._doTranslate(0,o-e.left)}i._updateBounds()}this.group._updateBounds()}_stackAreas(){this.group.children[0].orientation===b?this._stackAreasVert():this._stackAreasHorz()}_stackArcs(){let t=this.group,e=this.startAngle?this.startAngle:90;if((this._direction?this._direction:k.Clockwise)===k.Clockwise)for(let i of t.children){let t=Nt(e-i.angle);i.adjustAngle(t,e),e=t}else for(let i of t.children){let t=Nt(e+i.angle);i.adjustAngle(e,t),e=t}}_stackRects(){let t=this.group.getScene(),e=this.group,i=this._orientation,s=e.children.map((t=>t.bounds)),n=s.map((t=>t.left)),r=s.map((t=>t.top)),a=s.map((t=>t.width)),o=s.map((t=>t.height)),h=null==this._left?Math.min(...n):this._left,l=null==this._top?Math.min(...r):this._top,c=Math.max(...a),d=Math.max(...o);if(i==v){let i=h+c/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=i-n.bounds.x,a=l+n.bounds.height/2-n.bounds.y;l+=n.bounds.height+this._gap,n._doTranslate(r,a);let o=0,d=0;if(!t.getEncodingByItem(n,"x"))switch(this._horzCellAlignment){case C.Left:o=h-n.bounds.left;break;case C.Center:o=h+c/2-n.bounds.x;break;case C.Right:o=h+c-n.bounds.right}n._doTranslate(o,d)}}else{let i=l+d/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=h+n.bounds.width/2-n.bounds.x,a=i-n.bounds.y;h+=n.bounds.width+this._gap,n._doTranslate(r,a);let o=0,c=0;if(!t.getEncodingByItem(n,"y"))switch(this._vertCellAlignment){case C.Top:c=l-n.bounds.top;break;case C.Middle:c=l+d/2-n.bounds.y;break;case C.Bottom:c=l+d-n.bounds.bottom}n._doTranslate(o,c)}}this.group._updateBounds()}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=pt(this.group)[0];switch(t.type){case T.Area:this._stackAreas();break;case T.Arc:case T.Pie:t.parent===this.group&&this._stackArcs();break;case T.Rect:case T.Image:case T.Circle:this._stackRects()}}set vertCellAlignment(t){if(t!=C.Top&&t!=C.Bottom&&t!=C.Middle)throw G.UNKOWN_ALIGNMENT;this._vertCellAlignment=t,this.run()}get vertCellAlignment(){return this._vertCellAlignment}set horzCellAlignment(t){if(t!=C.Left&&t!=C.Center&&t!=C.Right)throw G.UNKOWN_ALIGNMENT;this._horzCellAlignment=t,this.run()}get horzCellAlignment(){return this._horzCellAlignment}get cellBounds(){return this.group.children.map((t=>t.bounds))}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}}function Lt(t,e,i,s,n,r){let a=r?n.transformField(s,r):s,o=n.getFieldType(a);if(o!=A.String&&o!=A.Date)throw new Error(G.PARTITION_BY_NONCAT+": "+a+" is "+o);if(!nd(e))throw new Error(G.COMPNT_NON_PARTITIONABLE);switch(e.type){case T.Line:return function(t,e,i,s){let n,r,a=nt(e,t),o=s.getFieldSummary(i).unique.map((t=>new Pt(s).cross(i,t))),h={},l=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>l&&(l=e.length),h[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope;let a=i.parent;a.addChild(s);let o=h[i.id],c=i.vertices[0].x,d=i.vertices[0].y,u=i.vertices[1].x,f=i.vertices[1].y;for(let t=0;t<o.length;t++){let n=i.duplicate();n.classId=e.id,n.vertices[0].x=c+(u-c)*t/l,n.vertices[0].y=d+(f-d)*t/l,n.vertices[1].x=c+(u-c)*(t+1)/l,n.vertices[1].y=d+(f-d)*(t+1)/l,n.dataScope=o[t],s.addChild(n)}a.removeChild(i),i==e&&(n=s)}return n}(t,e,a,n);case T.Path:return function(t,e,i,s){let n,r,a=nt(e,t),o=s.getFieldSummary(i).unique.map((t=>new Pt(s).cross(i,t))),h={},l=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>l&&(l=e.length),h[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope;let a=i.parent;a.addChild(s);let o=h[i.id],c=i.bounds.left,d=i.bounds.top,u=i.bounds.right,f=i.bounds.bottom;for(let i=0;i<o.length;i++){let n=t.mark("line",{x1:c+(u-c)*i/l,x2:c+(u-c)*(i+1)/l,y1:d+(f-d)*i/l,y2:d+(f-d)*(i+1)/l});n.classId=e.id,n.dataScope=o[i],s.addChild(n)}a.removeChild(i),i==e&&(n=s)}let c=e.firstVertex.dataScope.fields[0];return t.densify(n.firstChild,s,{field:c}),n}(t,e,a,n);case T.Circle:return function(t,e,i,s,n){let r,a,o=i||x,h=nt(e,t);if(o==x)h.forEach((i=>{let o=i.dataScope?i.dataScope:new Pt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/l,f=90;for(let s=0;s<l;s++){let n=t.mark("pie",{innerRadius:0,outerRadius:i.radius,x:i.x,y:i.y,startAngle:Nt(f-u*(s+1)),endAngle:Nt(f-u*s),strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}c.layout=Qc("stack",{orientation:x,direction:k.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)}));else{if(o!=w)throw G.UNKNOWN_Orientation+": "+o;h.forEach((i=>{let o=i.dataScope?i.dataScope:new Pt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=i.radius/l;for(let s=0;s<l;s++){let n=t.mark("ring",{x:i.x,y:i.y,innerRadius:s*u,outerRadius:(s+1)*u,strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)}))}return r}(t,e,i,a,n);case T.Rect:return function(t,e,i,s,n){let r,a=nt(e,t),o=i||b;if(o!=b&&o!=v)throw G.UNKNOWN_Orientation+": "+o;let h,l=n.getFieldSummary(s).unique.map((t=>new Pt(n).cross(s,t))),c={},d=0;for(let t of a){let e=l;t.dataScope&&(e=l.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>d&&(d=e.length),c[t.id]=e}for(let i of a){let s=t.collection();null==h&&(h=s.id),s.classId=h,s.dataScope=i.dataScope?i.dataScope:new Pt(n);let a=i.parent;a.addChild(s);let l=c[i.id],u=i.bounds,f=u.left,p=u.top,g=o==b?u.width/d:u.width,_=o==b?u.height:u.height/d;for(let t=0;t<l.length;t++){let n=i.duplicate();n.classId=e.id,n.resize(g,_),n.dataScope=l[t],s.addChild(n)}s.layout=new Bt({orientation:o,left:f,top:p}),a.removeChild(i),i==e&&(r=s)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case T.Area:return function(t,e,i,s,n){let r,a=nt(e,t),o=a[0];if(4==o.vertices.length&&i==b&&o.vertices[0].x!==o.vertices[1].x)for(let t of a){let e=t.vertices[1];t.vertices[1]=t.vertices[3],t.vertices[3]=e}let h,l=n.getFieldSummary(s).unique.map((t=>new Pt(n).cross(s,t)));for(let s of a){let a=t.collection();null==h&&(h=a.id),a.classId=h,a.dataScope=s.dataScope?s.dataScope:new Pt(n);let o=s.parent;o.addChild(a);let c=s.left,d=s.top,u=i==b?s.width/l.length:s.width,f=i==b?s.height:s.height/l.length;for(let t=0;t<l.length;t++){let t=s.duplicate();t.classId=e.id,t.resizeArea(u,f),a.addChild(t)}o.removeChild(s);for(let t=0;t<a.children.length;t++){let e=a.children[t];e.dataScope?e.dataScope=e.dataScope.merge(l[t]):e.dataScope=l[t];for(let t of e.vertices)t.dataScope?t.dataScope=e.dataScope.merge(t.dataScope):t.dataScope=e.dataScope}a.layout=new Bt({orientation:i,left:c,top:d}),s==e&&(r=a)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case T.Ring:return function(t,e,i,s,n){let r,a,o=i||x,h=nt(e,t);if(o==x)return h.forEach((i=>{let o=i.dataScope?i.dataScope:new Pt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/l,f=90;for(let s=0;s<l;s++){let n=t.mark("arc",{innerRadius:i.innerRadius,outerRadius:i.outerRadius,x:i.x,y:i.y,startAngle:Nt(f-u*(s+1)),endAngle:Nt(f-u*s),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}c.layout=Qc("stack",{direction:k.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw G.UNKNOWN_Orientation+": "+o}(t,e,i,a,n);case T.Pie:case T.Arc:return function(t,e,i,s,n){let r,a,o=i||w,h=nt(e,t);if(o==w)return h.forEach((i=>{let o=i.dataScope?i.dataScope:new Pt(n),h=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));h=h.filter((t=>!t.isEmpty()));let l=h.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent;for(let s=0;s<l;s++){let n=t.mark("arc",{innerRadius:s*i.outerRadius/l,outerRadius:(s+1)*i.outerRadius/l,x:i.x,y:i.y,startAngle:i.startAngle,endAngle:i.endAngle,strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=h[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw G.UNKNOWN_Orientation+": "+o}(t,e,i,a,n)}}function Dt(t,e,i,s,n,r,a,o){let h=r?n.transformField(s,r):s,l=n.getFieldType(h);if(l!=A.String&&l!=A.Date&&l!=A.Number)throw new Error(G.DENSIFY_BY_NONCAT+": "+h+" is "+l);if(!rd(e))throw new Error(G.COMPNT_NON_DENSIFIABLE);switch(e.type){case T.Line:return function(t,e,i,s){let n,r=nt(e,t);for(let a of r){let r=a.dataScope?a.dataScope:new Pt(s),o=s.getFieldSummary(i).unique.map((t=>r.cross(i,t)));o=o.filter((t=>!t.isEmpty())),1===o.length&&o.push(o[0].clone());let h=Object.assign({},a.styles);for(let t of K.styles)a[t]&&(h[t]=a[t]);let l=a.vertices[0].x,c=a.vertices[0].y,d=[],u=a.vertices[1].x-l,f=a.vertices[1].y-c;for(let t=0;t<o.length;t++)d.push([l+t*u/(o.length-1),c+t*f/(o.length-1)]);h.vertices=d;let p=t.mark("path",h);p.classId=e.id,p.dataScope=r;let g=a.parent;g.addChild(p),g.removeChild(a);for(let[t,e]of p.vertices.entries())e.dataScope?e.dataScope=e.dataScope.merge(o[t]):e.dataScope=o[t];a==e&&(n=p)}return n}(t,e,h,n);case T.Circle:return function(t,e,i,s,n,r){let a;return nt(e,t).forEach((o=>{let h=o.dataScope?o.dataScope:new Pt(s),l=s.getFieldSummary(i).unique.map((t=>h.cross(i,t)));l=l.filter((t=>!t.isEmpty()));let c=l.length;if(c<3)throw Error(G.INSUFFICIENT_DATA_SCOPES);let d=360/c,u=[],f=[],p="clockwise"==r?-1:1;for(let t=0;t<l.length;t++){let e=n+p*t*d;f[t]=e;let i=Et(o.x,o.y,o.radius,f[t]);u.push(i)}let g=t.mark("polygon",{x:o.x,y:o.y,radius:o.radius,vertices:u});g.dataScope=h,g.styles=Object.assign({},o.styles);for(let t of K.styles)o[t]&&(g[t]=o[t]);let _=o.parent;_.addChild(g),_.removeChild(o);for(let[t,e]of g.vertices.entries())e.polarAngle=f[t],e.dataScope?e.dataScope=e.dataScope.merge(l[t]):e.dataScope=l[t];o==e&&(a=g)})),a}(t,e,h,n,a,o);case T.Rect:case T.Area:return function(t,e,i,s,n){let r,a=nt(e,t);for(let o of a){let a=n.getFieldType(s),h=o.dataScope?o.dataScope:new Pt(n),l=n.getFieldSummary(s).unique.map((t=>h.cross(s,t)));l=a==A.Number?l:l.filter((t=>!t.isEmpty())),1===l.length&&l.push(l[0].clone()),a!=A.Number&&a!=A.Date||l.sort(((t,e)=>t._field2value[s]>e._field2value[s]?1:-1));let c=Object.assign({},o.styles),d=o.vertices[0].x,u=o.vertices[0].y,f=o.vertices[o.vertices.length-2].x,p=o.vertices[o.vertices.length-2].y,g=[],_=f-d,m=p-u;for(let t=0;t<l.length;t++)g.push(i==v?[f,u+(l.length-1-t)*m/(l.length-1)]:[d+t*_/(l.length-1),u]);for(let t=0;t<l.length;t++)g.push(i==v?[d,u+t*m/(l.length-1)]:[d+(l.length-1-t)*_/(l.length-1),p]);c.vertices=g;let y=t.mark("area",c);y.classId="area"==o.type?o.classId:"area"+o.classId.substring(9),y.dataScope=h,y.orientation=i,y.baseline=i===b?C.Bottom:C.Left;let x=o.parent;x.addChild(y),x.removeChild(o);for(let[t,e]of y.vertices.entries())t>=l.length?e.dataScope=h.merge(l[2*l.length-1-t]):e.dataScope=h.merge(l[t]);o==e&&(r=y)}return r}(t,e,i,h,n)}}class jt extends Q{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}set height(t){this.resize(this.width,t)}set width(t){this.resize(t,this.height)}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}resize(t,e,i,s){"right"===i?(this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x),"top"===s?(this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y),this._updateBounds()}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class Vt extends Q{constructor(t){super(t),this.attrs.x="x"in t?t.x:0,this.attrs.y="y"in t?t.y:0,this.attrs.radius="radius"in t?t.radius:100}get radius(){return this.attrs.radius}get x(){return this.attrs.x}get y(){return this.attrs.y}get area(){return Math.PI*Math.pow(this.radius,2)}set x(t){this.attrs.x=t,this._updateBounds()}set y(t){this.attrs.y=t,this._updateBounds()}set radius(t){this.attrs.radius=t,this._updateBounds()}set area(t){this.attrs.radius=Math.sqrt(t),this._updateBounds()}resize(t,e,i,s){let n=Math.min(t,e)/2,r=n-this.attrs.radius;this.attrs.radius=n,"right"==i?this.attrs.x-=r:this.attrs.x+=r,"top"==s?this.attrs.y+=r:this.attrs.y-=r,this._updateBounds()}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this.attrs.x-this.attrs.radius,this.attrs.y-this.attrs.radius,2*this.attrs.radius,2*this.attrs.radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t.attrs.x=this.attrs.x,t.attrs.y=this.attrs.y,t.attrs.radius=this.attrs.radius}getSVGPathData(){return["M",this.x,this.y,"m",-this.radius,", 0 a",this.radius,",",this.radius,"0 1,0",2*this.radius,",0 a",this.radius,",",this.radius,"0 1,0",-2*this.radius,",0"].join(" ")}}function Gt(t){return t._query=function(){this.data=[];let t=this.field,e=this.items,i=this.aggregator;switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case A.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,i)))}},t._map=function(){let t,e=this.items,i=this.data,s=this.channel;if(t=Xc(this.scaleType),null==this.data.find((t=>t<0))||"width"!=s&&"height"!=s||0!=e[0].type.indexOf("rect")){let n,r;t.domain=[0,Math.max(...i)],"radius"==s||"outerRadius"==s||"innerRadius"==s?(n=0,r=Math.max(...e.map((t=>t[s]))),r<20&&(r=20)):"area"==s?(n=0,r=Math.max(...e.map((t=>t.bounds.width*t.bounds.height))),r<400&&(r=400)):"fontSize"==s?(n=2,r=Math.max(...e.map((t=>parseFloat(t.styles.fontSize))))):"strokeWidth"==s?(n=1,r=Math.max(...e.map((t=>parseFloat(t.styles.strokeWidth)))),r==n&&(r=n+5)):(n=0,r=Math.max(...e.map((t=>t.bounds[s])))),this.rangeExtent&&(r=n+this.rangeExtent),this.range&&(n=this.range[0],r=this.range[1]),t._setRange([n,r])}else this._rectNegativeValues=!0,t.domain=[Math.min(...i),Math.max(...i)],"width"==s?t._setRange([0,this.rangeExtent?this.rangeExtent:Math.max(...e.map((t=>t.width)))]):t._setRange([0,this.rangeExtent?this.rangeExtent:Math.max(...e.map((t=>t.height)))]);this.scale||(this.scale=t),this.scale._addEncoding(this)},t._apply=function(){if("radius"==this.channel||"outerRadius"==this.channel||"innerRadius"==this.channel){for(let t=0;t<this.items.length;t++){this.items[t][this.channel]=this.scale.map(this.data[t])}this.scene._relayoutAncestors(this.anyItem,this.items)}else if(this._rectNegativeValues){let t=Math.max(...this.data),e=Math.min(...this.data),i="width"===this.channel?Math.min(...this.items.map((t=>t.bounds.left))):Math.min(...this.items.map((t=>t.bounds.top)))+this.scale.rangeExtent,s="width"===this.channel?"right":"top",n="width"===this.channel?"left":"bottom";for(let r=0;r<this.items.length;r++){let a,o=this.items[r];if(o.parent&&o.parent.type===T.Collection){let t=o.parent.parent;if(t.type===T.Collection&&t.layout&&t.layout.type===y.Grid){let e=t.children.indexOf(o.parent);a=t.layout.cellBounds[e][n]}else a=o.parent.refBounds[n]}else a=i;"width"===this.channel?(o.leftSegment._doTranslate(a+this.scale.map(0)-o.leftSegment.vertex1.x,0),o.rightSegment._doTranslate(a+this.scale.map(this.data[r])-o.rightSegment.vertex1.x,0)):(o.topSegment._doTranslate(0,a-this.scale.map(this.data[r])-o.topSegment.vertex1.y),o.bottomSegment._doTranslate(0,a-this.scale.map(0)-o.bottomSegment.vertex1.y)),o._updateBounds(),this.data[r]>0?(o.boundsOffsets[s]=this.scale.map(t)-this.scale.map(this.data[r]),o.boundsOffsets[n]=this.scale.map(0)-this.scale.map(e)):(o.boundsOffsets[n]=this.scale.map(this.data[r])-this.scale.map(e),o.boundsOffsets[s]=this.scale.map(t)-this.scale.map(0))}}else if("area"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=Math.sqrt(this.scale.map(this.data[t]));e.resize(i,i)}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("fontSize"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.fontSize=i+"px"}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("strokeWidth"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.strokeWidth=i}this.scene._relayoutAncestors(this.anyItem,this.items)}else{let t="left",e="bottom";if(this.anyItem.parent&&this.anyItem.parent.type==T.Glyph){let i=this.anyItem.parent.children;1==Rt(i.map((t=>t.bounds.right))).length&&(t="right"),1==Rt(i.map((t=>t.bounds.top))).length&&(e="top")}if(this.anyItem.type===T.Collection&&this.anyItem.layout&&this.anyItem.layout[this.channel])for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.layout[this.channel]=i}else for(let i=0;i<this.items.length;i++){let s=this.items[i],n=this.scale.map(this.data[i]),r="width"==this.channel?n:s.bounds.width,a="height"==this.channel?n:s.bounds.height;s.resize(r,a,t,e)}this.scene._relayoutAncestors(this.anyItem,this.items)}},t.run(),t}function zt(t){return t._query=function(){this.data=[],this.areas=nt(this.items[0],this.scene);let t=this.areas.length;this.areaNum=t,this._vertices=[],this.indicator=[];for(let t of this.areas)for(let e=0;e<t.vertices.length;e++)this._vertices.push(t.vertices[e]),e<t.vertices.length/2?this.indicator.push(1):this.indicator.push(0);let e=this.field,i=this._vertices.map((t=>t.dataScope));switch(this.datatable.getFieldType(e)){case A.Boolean:break;case A.Date:this.data=i.map((t=>t.getFieldValue(e)));break;case A.String:this.data=i.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)));break;default:"x"==this.channel||"y"==this.channel?this.data=i.map((t=>t._field2value[e])):this.data=i.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)))}},t._map=function(){"fillGradient"===this.channel?this._mapToGradient():"width"!=this.channel&&"height"!=this.channel||this._mapToSize()},t._mapToGradient=function(){if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=Xc("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=Xc("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=Xc("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}this.scale._addEncoding(this)},t._mapToSize=function(){let t,e,i;switch(this.datatable.getFieldType(this.field)){case A.Boolean:break;case A.Date:t=Xc("time"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=[e,i];break;case A.String:t=Xc("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=this._includeZero||e<0?[0,i]:[e,i];break;default:t=Xc("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=e<0?[0,i]:[e,i]}let s,n=It(this.areas[0]),r=rt(this.anyItem);if(r){let t=r.cellBounds;s="width"==this.channel||"height"==this.channel?n==v?t[0].width:t[0].height:n==v?t[0].height:t[0].width}else s="width"==this.channel?Math.max(...this.areas.map((t=>t.bounds.width))):Math.max(...this.areas.map((t=>t.bounds.height)));this.rangeExtent&&(s=this.rangeExtent),e<0?(t._scale.domain([e,i]),t._setRange([0,s])):t._setRange([0,s]),this.scale?this.scale._merge(t):this.scale=t,this.scale._addEncoding(this)},t._apply=function(){"fillGradient"===this.channel?this._applyToGradient():"width"!=this.channel&&"height"!=this.channel||this._applyToSize()},t._applyToGradient=function(){let t=0;for(let e of this.areas){let i=this.data.slice(t,t+e.vertices.length),s=Math.min(...i),n=Math.max(...i),r="horizontal"===e.orientation?td({x1:0,y1:100,x2:0,y2:0}):td({x1:0,y1:0,x2:100,y2:0});if(r.addStop(0,this.scale.map(s),1),this._mapping){let t=Object.keys(this._mapping).map((t=>parseFloat(t))).sort();for(let e of t)e>s&&e<n&&r.addStop(100*(e-s)/(n-s),this.scale.map(e),1)}else"divergingColor"===this.scale.type&&r.addStop(100*-s/(n-s),this.scale.map(0),1);r.addStop(100,this.scale.map(n),1),e.fillColor=r,t+=e.vertices.length}},t._applyToSize=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);let i=this.areas[0].orientation;if("width"===e||"height"===e){if(rt(this.areas[0])){let t=0,e=this.areas.map((t=>at(t))),s=this.areas.map((t=>rt(t)));for(let[n,r]of this.areas.entries()){let a=e[n],o=s[n];for(let e=0;e<r.vertices.length;e++){let s,n,h=this._vertices[e+t];if(i===b)if(s=0,o.type===y.Stack)n=a.bottom-this.scale.map(this.data[e+t])-h.y;else if(o.type===y.Grid){switch(r.baseline){case"top":n=a.top+this.scale.map(this.data[e+t])-h.y;break;case"bottom":n=a.bottom-this.scale.map(this.data[e+t])-h.y;break;case"middle":{let i=r.vertices.length-1-e,s=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));n=this.indicator[e+t]?a.middle-s/2-h.y:a.middle+s/2-h.y;break}}}else n=0;else if(n=0,o.type===y.Stack)s=a.left+this.scale.map(this.data[e+t])-h.x;else if(o.type===y.Grid){switch(r.baseline){case"left":s=a.left+this.scale.map(this.data[e+t])-h.x;break;case"right":s=a.right-this.scale.map(this.data[e+t])-h.x;break;case"center":{let i=r.vertices.length-1-e,n=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));s=this.indicator[e+t]?a.center-n/2-h.x:a.center+n/2-h.x;break}}}else s=0;h._doTranslate(s,n)}t+=r.vertices.length}}else{let t="center"==this.areas[0].baseline||"middle"==this.areas[0].baseline,e=0,s=i==v?"left":"bottom",n=i==i==v?"right":"top";for(let t of this.areas){for(let s=e;s<e+t.vertices.length;s++){let e=this._vertices[s],n=i==v?t.baseline!==C.Right?t.bounds.left-t.boundsOffsets.left:t.bounds.right+t.boundsOffsets.right:t.baseline!=C.Top?t.bounds.bottom+t.boundsOffsets.bottom:t.bounds.top-t.boundsOffsets.top,r=i==v?t.baseline!==C.Right?n+this.scale.map(this.data[s])-e.x:n-this.scale.map(this.data[s])-e.x:0,a=i==v?0:t.baseline!=C.Top?n-this.scale.map(this.data[s])-e.y:n+this.scale.map(this.data[s])-e.y;e._doTranslate(r,a)}let r=this.data.slice(e,e+t.vertices.length),a=Math.min(...r),o=Math.max(...r);t.boundsOffsets[n]=this.scale.map(Math.max(...this.data))-this.scale.map(o),t.boundsOffsets[s]=this.scale.map(a)-this.scale.map(Math.min(...this.data)),e+=t.vertices.length}if(1==t){let t=this._vertices.length/this.areaNum,e=ut(this._vertices),s=i==v?Math.min(...e.map((t=>t.bounds.x))):Math.max(...e.map((t=>t.bounds.y)));for(let e=0;e<this.areaNum;e++)for(let n=0;n<t/2;n++){let r=e*t+n,a=(e+1)*t-n-1,o=this._vertices[r],h=this._vertices[a],l=i==v?o.x-h.x:h.y-o.y,c=i==v?s+l/2-o.x:0,d=i==v?0:s+l/2-o.y,u=i==v?s-l/2-h.x:0,f=i==v?0:s-l/2-h.y;o._doTranslate(c,d),h._doTranslate(u,f)}}}}for(let t of this.areas)t._updateBounds();"width"!=e&&"height"!=e||this.scene._relayoutAncestors(this.areas[0],this.areas)},t.run(),t}class Wt{constructor(t,e,i,s,n){this.items=t,this.anyItem=this.items[0],this.scene=e,this.channel=i,this.field=s,this._aggregator=n.aggregator,this.datatable=n.datatable,this.scale=n.scale,this.scale?(this._flipScale=this.scale.isFlipped,this.scaleType=this.scale.type,this._includeZero=this.scale.includeZero):(this._flipScale=n.flipScale,this.scaleType=n.scaleType,this._includeZero=n.includeZero),this._mapping=n.mapping,this.rangeExtent=n.rangeExtent,this._scheme=n.scheme,this.range=n.range,"angle"==this.channel&&(this.startAngle="startAngle"in n?n.startAngle:90),this._query=void 0,this._map=void 0,this._apply=void 0}get id(){return["enc",ct(this.anyItem),this.channel,this.field].join("-")}set aggregator(t){this._aggregator=t,this.run()}get aggregator(){return this._aggregator}toJSON(){let t={};return t.anyItem=this.anyItem.id,t.items=this.items.map((t=>t.id)),this.data&&(t.data=this.data),this._rectNegativeValues&&(t._rectNegativeValues=!0),t.args={},t.args.channel=this.channel,t.args.field=this.field,t.args.aggregator=this.aggregator,t.args.datatable=this.datatable.id,t.args.scale=this.scale.id,t.args.mapping=this._mapping,t.args.rangeExtent=this.rangeExtent,t.args.scheme=this._scheme,t.args.scaleType=this.scaleType,t.args.range=this.range,"angle"==this.channel&&(t.args.startAngle=this.startAngle),t}run(){this._query(),this._map(),this._apply()}get dataTable(){return this.datatable}_inferTickValues(){let t,e=this,i=e.scale.domain,s=e.scale.range;switch(e.scale.type){case"linear":case"log":{let r=Math.abs(s[0]-s[1]);if("width"==e.channel||"height"==e.channel){let t=lt(e.anyItem,"stack");if(t){let s=nt(t.group,e.scene);r=Math.max(...s.map((t=>t.refBounds[e.channel]))),i[1]=e.scale.invert(r)}}t="width"==e.channel||"x"==e.channel?45:30;let a,o=Math.max(2,Math.floor(r/t));if("log"===e.scale.type){a=[];let t=e.scale._scale.ticks();for(let e of t){let i=Math.log(e)/Math.log(10)+1e-6;Math.abs(i-Math.floor(i))<o/t.length&&a.push(e)}}else a=n.ticks(i[0],i[1],o);return a}case"point":{t="width"==e.channel||"x"==e.channel?80:30;let s=Math.floor(e.scale.rangeExtent/i.length),n=Math.ceil(t/s);return"x"==e.channel?i.filter(((t,e)=>e%n==0)):i}case"time":{t="width"==e.channel||"x"==e.channel?80:30;let r,a,o=Math.floor((s[1]-s[0])/t),h=Math.ceil((i[1]-i[0])/o)/1e3,l=[1,60,3600,86400,2628003,31536e3],c=[n.timeSeconds,n.timeMinutes,n.timeHours,n.timeDays,n.timeMonths,n.timeYears];for(let t=0;t<l.length-1;t++)if(h>=l[t]&&h<l[t+1])return r=Math.floor(h/l[t]),a=c[t],a(i[0],i[1],r);return h>l[l.length-1]?(r=Math.floor(h/l[l.length-1]),a=c[l.length-1],a(i[0],i[1],r)):[]}default:return[]}}getScaleRange(t){let e=t||this.anyItem;if(e.type!=T.Area&&("vertex"!=e.type||e.parent.type!=T.Area)){if("x"==this.channel){let t=rt(e);if(t&&t.type==y.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].left+this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}{let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}}if("y"==this.channel){let t=rt(e);if(t&&t.type==y.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].bottom,i[s].bottom-this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}{let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}}if("width"==this.channel){let t=lt(e);if("grid"===t.type){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].right]}if("stack"===t.type&&"horizontal"==t.orientation)return[t.group.bounds.left,t.group.bounds.right];{let t=nt(e,this.scene),i=Math.min(...t.map((t=>t.bounds.left)));return[i,i+this.scale.rangeExtent]}}if("height"==this.channel){let t=St(e);if(t&&t.layout&&["grid","stack"].indexOf(t.layout.type)>=0){let i=t.layout.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent===t||e.parent.parent===t));return[i[s].bottom,i[s].bottom-i[s].height]}{let t=nt(e,this.scene),i=Math.max(...t.map((t=>t.refBounds.bottom)));return[i,i-this.scale.rangeExtent]}}if("radialDistance"==this.channel){let t=e.parent;return[t.x,t.x+this.scale.rangeExtent]}return this.scale.range}{let t,i=e.type==T.Area?e:e.parent,s=It(i),n=rt(i);t=n?s==v?n.horzCellAlignment===C.Left:n.vertCellAlignment===C.Bottom:s==v?i.baseline==C.Left:i.baseline==C.Bottom;let r=ht(i);if(r)switch(this.channel){case"x":return[r.left,r.left+this.scale.rangeExtent];case"width":return t?[r.left,r.left+this.scale.rangeExtent]:[r.right,r.right-this.scale.rangeExtent];case"y":return[r.bottom,r.bottom-this.scale.rangeExtent];case"height":return t?[r.bottom,r.bottom-this.scale.rangeExtent]:[r.top+this.scale.rangeExtent,r.top]}else if(n&&"stack"===n.type)switch(r=n.group.bounds,this.channel){case"x":return[r.left,r.left+this.scale.rangeExtent];case"width":return t?[r.left,r.left+this.scale.rangeExtent]:[r.right,r.right-this.scale.rangeExtent];case"y":return[r.bottom,r.bottom-this.scale.rangeExtent];case"height":return t?[r.bottom,r.bottom-this.scale.rangeExtent]:[r.top+this.scale.rangeExtent,r.top]}if(s==b)switch(this.channel){case"width":case"height":{let e=this._vertices,i=t?Math.max(...e.map((t=>t.y))):Math.min(...e.map((t=>t.y)));return t?[i,i-this.scale.rangeExtent]:[i+this.scale.rangeExtent,i]}case"x":case"y":{let t=nt(i.firstVertex,this.scene),e=Math.min(...t.map((t=>t.x)));return[e,e+this.scale.rangeExtent]}}else if(s==v)switch(this.channel){case"x":case"y":{let t=nt(i.firstVertex,this.scene),e=Math.max(...t.map((t=>t.y)));return[e,e-this.scale.rangeExtent]}case"height":case"width":{let e=nt(i.firstVertex,this.scene),s=t?Math.min(...e.map((t=>t.x))):Math.max(...e.map((t=>t.x)));return t?[s,s+this.scale.rangeExtent]:[s-this.scale.rangeExtent,s]}}}}}function Ut(t,e,i){return e.map((e=>[e,n.mean(i,(i=>t(e-i)))]))}function qt(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}function Yt(t,e){if("field"in e){let i=e.field;if("value"in e)return t[i]==e.value;if("range"in e)return t[i]>=e.range[0]&&t[i]<=e.range[1];if("values"in e)return e.values.indexOf(t[i])>=0}else if("fields"in e){let i=e.fields[0],s=e.fields[1],n=t[i],r=t[s];switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}return!1}}class Jt{constructor(t,e,i){if(this.url=e,this.id=T.DataTable+vt[T.DataTable]++,this.data=t,this.rawData=JSON.parse(JSON.stringify(t)),this._dateMap=new Map,this._fields=Object.keys(this.data[0]),this._newField=0,i)this._fieldTypes=i;else{this._fieldTypes={};for(let t of this._fields)this._fieldTypes[t]=Zt(this.data.map((e=>e[t]))),"year"==t.toLowerCase()&&this._fieldTypes[t]==A.Integer&&(this._fieldTypes[t]=A.Date)}this._validate(this.data,this._fieldTypes),this._fieldSummaries={};for(let t of this._fields)this._fieldSummaries[t]=Ht(this.data.map((e=>e[t])),this._fieldTypes[t]);this._fields.indexOf(h)<0&&this._addField(h,A.String,this.data.map(((t,e)=>"r"+e)))}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),i=t.substring(e);0!==i.indexOf("\\")&&0!==i.indexOf("/")||(i=i.substring(1));return i}(this.url):this.id}set sourceDataTable(t){this._sourceDataTable=t}get sourceDataTable(){return this._sourceDataTable}getEncodableFields(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.numericFields.concat(this.nonNumericFields);case"area":case"strokeWidth":default:return this.numericFields}}toJSON(){let t={};return t.data=this.rawData,t.fieldTypes=this._fieldTypes,t.url=this.url,t.id=this.id,t.sourceDataTable=this._sourceDataTable,t.transform=this._transform,t.dateMap={},t}transformField(t,e,i){let s=this.data.map((i=>e(i[t]))),n=Zt(s),r=i||Date.now()+"_field"+this._newField++;return this._addField(r,n,s),r}setValueOrder(t,e){this._fieldSummaries[t].unique=e}_addField(t,e,i){this.data.forEach(((e,s)=>e[t]=i[s])),this._fieldTypes[t]=e,this._fields.push(t),this._fieldSummaries[t]=Ht(i,e)}getFieldType(t){return this._fieldTypes[t]}get fields(){return this._fields}getFieldSummary(t){return this._fieldSummaries[t]}getFieldValues(t){return this.data.map((e=>e[t]))}getUniqueFieldValues(t){return this._fieldSummaries[t].unique}getRowCount(){return this.data.length}hasField(t){return this._fields.indexOf(t)>=0}parseFieldAsDate(t,e){let i=n.timeParse(e);for(let e of this.data){let s=e[t];null==s||null==s?(s="",e[t]=new Date(1899,11,31).getTime()):e[t]=i(s).getTime(),this._dateMap.set(e[t],s)}this._fieldTypes[t]=A.Date,this._fieldSummaries[t]=Ht(this.data.map((e=>e[t])),A.Date)}getRawValue(t,e){return this.getFieldType(t)===A.Date?this._dateMap.get(e).toString():e}static get RowID(){return h}get nonNumericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!=A.Number&&this._fieldTypes[e]!=A.Integer&&e!=Jt.RowID&&t.push(e);return t.sort(((t,e)=>this.getUniqueFieldValues(t).length-this.getUniqueFieldValues(e).length)),t}get numericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!==A.Number&&this._fieldTypes[e]!==A.Integer||e==Jt.RowID||t.push(e);return t}getFieldsByType(t){let e=[];for(let i in this._fieldTypes)this._fieldTypes[i]===t&&i!=Jt.RowID&&e.push(i);return e}transform(t,e,i){let s=i||{};switch(t){case"kde":return function(t,e,i){let s=e[0],n=t.nonNumericFields,r={};for(let e of t.data){let t=n.map((t=>String(e[t]))).join("_");t in r||(r[t]=n.map((t=>e[t])),r[t].push([])),r[t][r[t].length-1].push(e[s])}let a="min"in i?i.min:t.getFieldSummary(s).min,o="max"in i?i.max:t.getFieldSummary(s).max,h=a,l=[];for(;h<o;)l.push(h),h+=i.interval;l.push(h);let c=[];for(let t in r){let e=r[t].pop(),a=Ut(qt(i.bandwidth),l,e);for(let e of a){let i={};r[t].forEach(((t,e)=>i[n[e]]=t)),i[s]=e[0],i[s+"_density"]=e[1],c.push(i)}}let d={};return n.forEach((e=>d[e]=t.getFieldType(e))),d[s]=A.Number,d[s+"_density"]=A.Number,new Jt(c,t.url,d)}(this,e,s);case"bin":return function(t,e,i){let s=e[0],r=t.nonNumericFields,a={};for(let e of t.data){let t=r.map((t=>String(e[t]))).join("_");a.hasOwnProperty(t)||(a[t]=r.map((t=>e[t])),a[t].push([])),a[t][a[t].length-1].push(e[s])}let o=[];for(let t in a){let e=a[t].pop(),i=n.bin()(e);for(let e of i){let i={};a[t].forEach(((t,e)=>i[r[e]]=t)),i.x0=e.x0,i.x1=e.x1,i[s+"_count"]=e.length,o.push(i)}}let h={};r.forEach((e=>h[e]=t.getFieldType(e))),h.x0=A.Number,h.x1=A.Number,h[s+"_count"]=A.Number;let l=new Jt(o,t.url,h);return l.sourceDataTable=t,l.transform={type:"bin",args:e},l}(this,e);case"sort":return function(t,e,i){t.data.sort(((t,i)=>function(t,e,i,s){for(let s of i){if(t[s]<e[s])return-1;if(t[s]>e[s])return 1}return 0}(t,i,e))),t.summarize()}(this,e);case"filter":return function(t,e){let i=[];for(let s of t.data){let t=!0;for(let i of e)if(!Yt(s,i)){t=!1;break}t&&i.push(s)}let s=new Jt(i,t.url);return s.sourceDataTable=t,s.transform={type:"filter",args:e},s}(this,e)}}summarize(){for(let t of this._fields)this._fieldSummaries[t]=Ht(this.data.map((e=>e[t])),this._fieldTypes[t])}_validate(t,e){for(let i of t)for(let t in e){let s,n=e[t],r=i[t];if(null==i[t]||null==i[t])switch(n){case A.Boolean:s=!1;break;case A.Date:s=new Date(1899,11,31).getTime();break;case A.String:s="";break;default:s=0}else switch(n){case A.Boolean:s=r;break;case A.Date:s=Number.isInteger(r)?new Date(r,0).getTime():new Date(r+"").getTime(),this._dateMap.set(s,r);break;case A.String:s=r.toString();break;default:s=r}i[t]=s}}}function Ht(t,e){var i={};switch(e){case A.Boolean:i.trueCount=t.filter((t=>t)).length,i.falseCount=t.filter((t=>!t)).length;break;case A.Date:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.unique=[...new Set(t)];break;case A.String:i.unique=[...new Set(t)];break;default:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.mean=n.mean(t),i.median=n.median(t),i.unique=[...new Set(t)]}return i}var $t={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return $t.number(t)&&(t=+t)==~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function Zt(t){var e=Object.values(A);for(let i=0;i<t.length;i++){let s=t[i];if(null!=s){for(let t=0;t<e.length;t++)$t[e[t]](s)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}class Kt extends H{constructor(t){super(t),this.type=T.PointText,this.attrs.x=0,this.attrs.y=0,"fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),void 0!==t&&("x"in t&&(this.attrs.x=t.x),"y"in t&&(this.attrs.y=t.y),this.attrs.text="text"in t?t.text:"",this.attrs.anchor="anchor"in t?t.anchor:["center","middle"]),this._updateBounds()}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this.attrs.x,t.y=this.attrs.y,t.text=this.text,t.anchor=[this.anchor[0],this.anchor[1]]}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this.bounds}set text(t){this.attrs.text=t,this._updateBounds()}get text(){return this.attrs.text}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){let t,e,i=function(t,e,i){let s=wt.getContext();s.font=e;let n=s.measureText(t);return n.fontBoundingBoxAscent?{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}:n.actualBoundingBoxAscent?{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}:{width:n.width,height:i}}(this.attrs.text,[this.fontWeight,this.styles.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),s=i.width,n=i.height;switch(this.attrs.anchor[0]){case"left":t=this.attrs.x;break;case"right":t=this.attrs.x-s;break;case"center":t=this.attrs.x-s/2;break;default:t=this.attrs.x}switch(this.attrs.anchor[1]){case"top":e=this.attrs.y;break;case"bottom":e=this.attrs.y-n;break;case"middle":e=this.attrs.y-n/2}this._bounds=new a(t,e,s,n)}get center(){return{x:this.bounds.left+this.bounds.width/2,y:this.bounds.top+this.bounds.height/2}}get x(){return this.attrs.x}set x(t){this.attrs.x=t,this._updateBounds()}get y(){return this.attrs.y}set y(t){this.attrs.y=t,this._updateBounds()}get anchor(){return this.attrs.anchor}set anchor(t){this.attrs.anchor=t,this._updateBounds()}get horzAnchor(){return this.attrs.anchor[0]}get vertAnchor(){return this.attrs.anchor[1]}set horzAnchor(t){this.attrs.anchor[0]=t,this._updateBounds()}set vertAnchor(t){this.attrs.anchor[1]=t,this._updateBounds()}get fontSize(){return parseFloat(this.styles.fontSize)}set fontSize(t){this.styles.fontSize="number"==typeof t?t+"px":t,this._updateBounds()}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._updateBounds()}get fontFamily(){return this.styles.fontFamily}set fontFamily(t){this.styles.fontFamily=t,this._updateBounds()}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}}class Xt extends Ot{constructor(t){super(),this.type=T.Axis,this.id=this.type+vt[this.type]++,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor?t.tickAnchor:"middle",this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelOffset="labelOffset"in t?t.labelOffset:15,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,"titleAnchor"in t?this._titleAnchor=t.titleAnchor:"x"==this.channel||"width"==this.channel?this._titleAnchor="top"==this._orientation?["center","bottom"]:["center","top"]:this._titleAnchor="left"==this._orientation?["right","middle"]:["left","middle"],this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._titlePosition=t.titlePosition,this._labelRotation="labelRotation"in t?t.labelRotation:0}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.field=this._field,t.channel=this._channel,"args"in t||(t.args={}),t.args.orientation=this._orientation,t.args.strokeColor=this._strokeColor,t.args.textColor=this._textColor,t.args.tickOffset=this._tickOffset,t.args.tickSize=this._tickSize,t.args.tickAnchor=this._tickAnchor,t.args.tickVisible=this._tickVisible,t.args.pathVisible=this._pathVisible,t.args.labelOffset=this._labelOffset,t.args.labelFormat=this._labelFormat,this._labelRotation&&(t.args.labelRotation=this._labelRotation),t.args.showTitle=this._showTitle,t.args.tickValues=this._tickValues,t.args.titleAnchor=this._titleAnchor,t.args.titleOffset=this._titleOffset,t.args.titlePosition=this._titlePosition,t.args.rotateTitle=this._rotateYTitle,t}get field(){return this._field}get channel(){return this._channel}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.reposition()}get pathX(){if("y"==this.channel||"height"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].x;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].x}}set pathX(t){"y"!=this.channel&&"height"!=this.channel||(this._posArg=t),this.reposition()}get pathPosition(){return"x"==this.channel||"width"==this.channel?this.pathY:this.pathX}set pathPosition(t){"x"==this.channel||"width"==this.channel?this.pathY=t:"y"!=this.channel&&"height"!=this.channel||(this.pathX=t)}get pathY(){if("x"==this.channel||"width"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].y;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].y}}set pathY(t){"x"!=this.channel&&"width"!=this.channel||(this._posArg=t),this.reposition()}get tickOffset(){return this._tickOffset}set tickOffset(t){this._tickOffset=t,this._positionTicks()}get titleOffset(){return this._titleOffset}set titleOffset(t){this._titleOffset=t}get tickSize(){return this._tickSize}set tickSize(t){this._tickSize=t,this._positionTicks()}set tickValues(t){this._tickValues=t,this._generateTicks(),this._positionTicks()}get tickValues(){return this._tickValues}set labelValues(t){this._labelValues=t,this._generateLabels(),this._positionLabels()}get labelValues(){return this._labelValues}get tickAnchor(){return this._tickAnchor}set tickAnchor(t){this._tickAnchor=t}get tickVisible(){return this._tickVisible}set tickVisible(t){this._tickVisible=t;for(let e of this._ticks.children)e.visibility=t?"visible":"hidden"}get pathVisible(){return this._pathVisible}set pathVisible(t){this._pathVisible=t;let e=[];this._path&&e.push(this._path),this._rules&&this._rules.children.forEach((t=>e.push(t)));for(let i of e)i.visibility=t?"visible":"hidden"}get labelOffset(){return this._labelOffset}set labelOffset(t){this._labelOffset=t,this._positionLabels()}get labelFormat(){return this._labelFormat}set labelFormat(t){this._labelFormat=t,this._generateLabels(),this._positionLabels()}get labelRotation(){return this._labelRotation}set labelRotation(t){if(this._labelRotation=t,this._labels&&this._labels.children){let e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(t)for(let t of this._labels.children)t._rotate=[this._labelRotation,t.x,t.y],t.anchor=["right",e[1]];else for(let t of this._labels.children)t._rotate=void 0}}get showTitle(){return this._showTitle}set showTitle(t){this._showTitle=t,this._title||(this._generateTitle(),this._positionTitle()),this._title.visibility=t?"visible":"hidden"}get titleAnchor(){return this._titleAnchor}set titleAnchor(t){this._titleAnchor=t}get titlePosition(){return this._titlePosition}set titlePosition(t){this._titlePosition=t}get rotateTitle(){return this._rotateYTitle}set rotateTitle(t){this._rotateYTitle=t}get title(){return this._titleText}set title(t){this._titleText=t}get includeZero(){return!!this.encoding&&this.encoding.scale.includeZero}set includeZero(t){this.encoding&&(this.encoding.scale.includeZero=t)}_generatePath(){}_generateTicks(){}_generateLabels(){}_generateTitle(){this._title=new Kt({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title.id=this.id+"-title",this.addChild(this._title)}_positionPath(){}_positionTicks(){}_positionLabels(){}_positionTitle(){}matches(t){}reposition(){this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle(),"radialDistance"===this._channel&&this._rotate&&(this._rotate=[this._rotate[0],this._item.parent.x,this._item.parent.y]),this._updateBounds()}}class Qt extends Xt{constructor(t,e,i){super(i),this.encoding=t,this._field=this.encoding.field,this._channel=this.encoding.channel,this._orientation="orientation"in i?i.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?i.pathY:i.pathX,this._position=this._posArg,this._titleText="title"in i?i.title:this.encoding.field,this._item=e,this._ticks=new Ot,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new Ot,this._labels.id=this.id+"labels",this.addChild(this._labels),"radialDistance"===this._channel&&"rotation"in i&&(this._rotate=[-i.rotation,this._item.parent.x,this._item.parent.y]),this._showTitle=!("showTitle"in i)||i.showTitle,this._determineAxisFlip(),this._generatePath(),this._positionPath(),this._showTitle&&this._generateTitle(),this._showTitle&&this._positionTitle()}autoUpdateTicks(){let t=this.encoding._inferTickValues();this.tickValues=t,this.labelValues=t}_updateBounds(){this._bounds=this._path.bounds,this._ticks.children.length>0&&(this._bounds=this._bounds.union(this._ticks.bounds)),this._labels.children.length>0&&(this._bounds=this._bounds.union(this._labels.bounds)),this._title&&(this._bounds=this._bounds.union(this._title.bounds))}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"time"===this.encoding.scale.type&&(t.args.isDate=!0),this._rotate&&(t.args.rotation=this._rotate[0]),"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,t}get ticks(){return this._ticks}get labels(){return this._labels}get path(){return this._path}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;this._path.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_generatePath(){this._path=new Q({strokeColor:this._strokeColor}),this._pathVisible||(this._path.visibility="hidden"),this._path.type=T.Line,this._path.id=this.id+"path",this.addChild(this._path)}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new Q({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=T.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this.encoding.datatable.getFieldType(this.encoding.field)){case A.Date:t=n.timeFormat(this._labelFormat);break;case A.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let s=new Kt({text:t(i),fontSize:this._fontSize,fillColor:this._textColor});s.id=this.id+"label"+e,this._labels.addChild(s)}}_positionPath(){this._range=this.encoding.getScaleRange(this._item),void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg;let t=[];if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].x));t.push([Math.min(...e.concat(this._range)),this._position]),t.push([Math.max(...e.concat(this._range)),this._position])}else if("y"==this._channel||"height"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].y));t.push([this._position,Math.min(...e.concat(this._range))]),t.push([this._position,Math.max(...e.concat(this._range))])}this._path._setVertices(t),this._path._updateBounds(),this._showTitle&&this._title&&this._positionTitle(),this._updateBounds()}_isAlignedLeft(t){switch(t.type){case y.Stack:case y.Grid:return t.horzCellAlignment===C.Left;default:return!0}}_isAlignedBottom(t){switch(t.type){case y.Stack:case y.Grid:return t.vertCellAlignment===C.Bottom;default:return!0}}_determineAxisFlip(){if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){if("width"==this._channel){let t=St(this._item)?St(this._item).layout:rt(this._item);if(t)this._flip=!this._isAlignedLeft(t);else if("area"==this._item.type){let t=this._item.baseline==C.Left||this._item.baseline==C.Center||this._item.baseline==C.Middle||null==this._item.baseline;this._flip=!t}}}else if(("y"==this._channel||"height"==this._channel)&&"height"==this._channel){let t=St(this._item)?St(this._item).layout:rt(this._item);if(t)this._flip=!this._isAlignedBottom(t);else if("area"==this._item.type){let t=this._item.baseline==C.Bottom||this._item.baseline==C.Center||this._item.baseline==C.Middle||null==this._item.baseline;this._flip=!t}}}_positionLabels(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize,e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._range[1]-this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i])-this.encoding.scale.range[0],s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]])}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize,e="left"==this._orientation?["right","middle"]:["left","middle"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]+this.encoding.scale.map(this._labelValues[i]),s.anchor=e;else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[1],s.anchor=e;else for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[0]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[0],s.anchor=e}this._labels._updateBounds(),this._updateBounds()}_computePosition(){let t;if("vertex"===this._item.type&&!this._item.parent.closed){let t=nt(this._item,this._item.parent.getScene());if("x"===this._channel&&1==Rt(t.map((t=>t.bounds.middle))).length)return this._item.bounds.middle;if("y"===this._channel&&1==Rt(t.map((t=>t.bounds.center))).length)return this._item.bounds.center;if("radialDistance"===this._channel)return this._item.parent.y}if(this._item.type!==T.Area&&this._item.parent.type!==T.Area||(t=ht(this._item)),void 0===t){let e=St(this._item);void 0===e&&(e=Ct(this._item)),t=e.bounds}return"x"===this._channel||"width"===this._channel?"top"==this._orientation?t.top-this._tickSize:t.bottom+this._tickSize:"y"===this._channel||"height"===this._channel?"left"==this._orientation?t.left-this._tickSize:t.right+this._tickSize:"radialDistance"===this._channel?this._item.parent.y:void 0}_positionTicks(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,this._range=this.encoding.getScaleRange(this._item),"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position+t]]),i._updateBounds()}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[1]+this.encoding.scale.map(this._tickValues[e])],[this._position,this._range[1]+this.encoding.scale.map(this._tickValues[e])]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries()){let s=this._range[1]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[1];i._setVertices([[this._position+t,s],[this._position,s]]),i._updateBounds()}else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]],[this._position,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]]]),i._updateBounds()}this._positionPath(),this._ticks._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._path.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel||"width"==this._channel?(this._title.x=t.x,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){let e=ct(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(ct(t.anyItem).split("_")[0]===e)return!0}return!1}get isFlipped(){return!!this._flip||!!this.encoding.scale.isFlipped}}class te extends Xt{constructor(t,e,i,s,n){super(n),this._channel=i,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._padding=[T.Line,T.Path].indexOf(t[0].type)>=0?10:0,this._item=t[0],this._items=t,this._mlayout=e,this._field=s,this._titleText="title"in n?n.title:this._field,this._showTitle="showTitle"in n&&n.showTitle,this._ticks=new Ot,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new Ot,this._labels.id=this.id+"labels",this.addChild(this._labels),this._rules=new Ot,this._rules.id=this.id+"paths",this.addChild(this._rules),this._generatePath(),this._generateTicks(),this._generateLabels(),this._showTitle&&this._generateTitle(),this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle()}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,this.classId&&(t.classId=this.classId),t}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;for(let e of this._rules.children)e.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_updateBounds(){this._bounds=this._rules.bounds.clone(),this._bounds=this._bounds.union(this._ticks.bounds),this._bounds=this._bounds.union(this._labels.bounds),this._showTitle&&(this._bounds=this._bounds.union(this._title.bounds))}_generatePath(){if(this._rules.removeAll(),this._mlayout.type==y.Grid){let t="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;for(let e=0;e<t;e++){let t=new Q({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=T.Line,t.id=this.id+"rule"+e,this._rules.addChild(t)}}else if(this._mlayout.type===y.Stack){let t=new Q({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=T.Line,t.id=this.id+"rule",this._rules.addChild(t)}}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._mlayout.group.children.length;t++){let e=new Q({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=T.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this._item.dataScope.getFieldType(this._field)){case A.Date:t=n.timeFormat(this._labelFormat);break;case A.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}let e=this._mlayout.cellBounds;for(let i=0;i<e.length&&!(i>=this._mlayout.group.children.length);i++){let e=this._mlayout.group.children[i],s=new Kt({fillColor:this._textColor,fontSize:this._fontSize,text:t(e.dataScope.getFieldValue(this._field))});s.id=this.id+"label"+i,this._labels.addChild(s)}}_positionPath(){if(this._mlayout.type==y.Grid){let t=this._mlayout.cellBounds,e="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;if("x"==this._channel){let i=t[0].left,s=this._mlayout.numCols,n="bottom"===this._orientation?this._padding:-this._padding;for(let r=0;r<e;r++)this._rules.children[r]._setVertices([[i,this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:t[r*s][this._orientation]+n],[i+t[0].width*s+this._mlayout.colGap*(s-1),this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:t[r*s][this._orientation]+n]])}else{let i=t[0].top,s=this._mlayout.numRows,n="left"===this._orientation?this._padding:-this._padding;for(let r=0;r<e;r++)this._rules.children[r]._setVertices([[this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation]-n,i],[this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation]-n,i+t[0].height*s+this._mlayout.rowGap*(s-1)]])}}else if(this._mlayout.type===y.Stack){let t=this._mlayout.group.bounds;"x"==this._channel?this._rules.children[0]._setVertices([[t.left,this._posArg?this._posArg:t[this._orientation]],[t.right,this._posArg?this._posArg:t[this._orientation]]]):this._rules.children[0]._setVertices([[this._posArg?this._posArg:t[this._orientation],t.top],[this._posArg?this._posArg:t[this._orientation],t.bottom]])}this._rules.children.forEach((t=>t._updateBounds())),this._rules._updateBounds(),this._updateBounds()}_positionTicks(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?1:-1,i="bottom"===this._orientation?this._padding:-this._padding;for(let[s,n]of this._ticks.children.entries()){let r=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:t[s][this._orientation]+this._tickOffset*e+i;n._setVertices([[t[s].x,r],[t[s].x,r+e*this._tickSize]]),n._updateBounds()}}else if("y"==this._channel){let e="left"==this._orientation?-1:1,i="left"===this._orientation?this._padding:-this._padding;for(let[s,n]of this._ticks.children.entries()){let r=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:this._mlayout.group.bounds[this._orientation]+this._tickOffset*e-i,a="middle"==this._tickAnchor?t[s].y:t[s][this._tickAnchor];n._setVertices([[r,a],[r+e*this._tickSize,a]]),n._updateBounds()}}this._ticks._updateBounds(),this._updateBounds()}_positionLabels(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?["center","top"]:["center","bottom"],i="bottom"==this._orientation?this._labelOffset:-this._labelOffset,s="bottom"===this._orientation?this._padding:-this._padding;for(let[n,r]of this._labels.children.entries())r.x=t[n].x,r.y=this._posArg?t[n][this._orientation]+this._posArg-t[0][this._orientation]+i:t[n][this._orientation]+i+s,r.anchor=e,this._labelRotation&&(r._rotate=[this._labelRotation,r.x,r.y],r.anchor=["right",e[1]])}else if("y"==this._channel){let e="left"==this._orientation?["right","middle"]:["left","middle"],i="left"==this._orientation?-this._labelOffset:this._labelOffset,s="left"===this._orientation?this._padding:-this._padding;for(let[n,r]of this._labels.children.entries())r.x=this._posArg?t[n][this._orientation]+this._posArg-t[0][this._orientation]+i:this._mlayout.group.bounds[this._orientation]+i-s,r.y="middle"==this._tickAnchor?t[n].y:t[n][this._tickAnchor],r.anchor=e,this._labelRotation&&(r._rotate=[this._labelRotation,r.x,r.y])}this._labels._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._rules.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel?(this._title.x=t.x,this._titleOffset=this._labels.bounds.height+this._labelOffset+15,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._titleOffset=this._labels.bounds.width+this._labelOffset+15,this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){return dt(this._item,t)}}class ee extends Ot{constructor(t,e){super(),this.type=T.Legend,this.id=this.type+vt[this.type]++,this.encoding=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._showTitle=!("showTitle"in e)||e.showTitle,"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._numCols=1,this._orientation="orientation"in e?e.orientation:v,this._initialize()}toJSON(){let t=super.toJSON();return"args"in t||(t.args={}),t.args.textColor=this._textColor,t.channel=this.encoding.channel,t.field=this.encoding.field,t.args.strokeColor=this._strokeColor,t.args.x=this._x,t.args.y=this._y,t.args.orientation=this._orientation,t}get field(){return this.encoding.field}get channel(){return this.encoding.channel}get fieldType(){return this.encoding.datatable.getFieldType(this.field)}_initialize(){let t=this.encoding.scene,e=this.encoding.field;switch(this.encoding.datatable.getFieldType(e)){case A.String:this._createCategoricalColorLegend(t,e);break;case A.Date:case A.Number:case A.Integer:this._createNumericalColorLegend(t,e)}this._updateBounds()}_createNumericalColorLegend(t,e){let i,s,n;if(this._orientation==v?(i=15,s=300):(i=300,s=15),this._showTitle){let s=t.mark("text",{fillColor:this._textColor,text:e,x:this._x+i/2,y:this._y,anchor:["center","middle"]});this.addChild(s),n=20}else n=0;let r,a=t.mark("rect",{top:this._y+n,left:this._x,width:i,height:s,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),o=[Math.min(...this.encoding.data),Math.max(...this.encoding.data)],h=this.encoding.scale.mapping,l=[],c=[];if(h){let e=Object.keys(h).map((t=>parseFloat(t))).sort(((t,e)=>t-e));this._orientation==v?(r=new J({x1:0,y1:100,x2:0,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,h[e],1);let d=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-a*s+n,y2:this._y+s-a*s+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+i+5+5,y:this._y+s-a*s+n,anchor:["left","middle"]});l.push(u)}))):(r=new J({x1:0,y1:0,x2:100,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,h[e],1);let d=t.mark("line",{x1:this._x+a*i,x2:this._x+a*i,y1:this._y+20-5+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+a*i,y:this._y+s+5+n,anchor:["center","top"]});l.push(u)})))}else{let a=this.encoding.scale.domain,o=this.encoding.datatable,h=o.getFieldType(e),d=[],u=h===A.Date?o.getUniqueFieldValues(e):Rt(this.encoding.data);if(u.length<=10)d=u,d.sort(((t,e)=>t-e));else if(h===A.Date){u.sort(((t,e)=>t-e));for(let t=0;t<u.length;t+=Math.ceil(u.length/10))d.push(u[t])}else{let t=(a[1]-a[0])/9;for(let e=0;e<10;e++)d.push(a[0]+e*t)}let f=0,p=(d[d.length-1]-d[0])/d.length;for(;p<1;)p*=10,f++;d=d.map((t=>t.toFixed(f))),this._orientation==v?(r=new J({x1:0,y1:100,x2:0,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-u*s+n,y2:this._y+s-u*s+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:h===A.Date?o.getRawValue(e,d):d,x:this._x+i+5+5,y:this._y+s-u*s+n,anchor:["left","middle"]});l.push(p)}))):(r=new J({x1:0,y1:0,x2:100,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+u*i,x2:this._x+u*i,y1:this._y+s+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:h===A.Date?o.getRawValue(e,d):d,x:this._x+u*i,y:this._y+s+5+n,anchor:["center","top"]});l.push(p)})))}a.styles.fillColor=r,this.addChild(a);for(let t of l)this.addChild(t);for(let t of c)this.addChild(t)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.setTextColor(this)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.removeAll(),this._initialize()}setTextColor(t){if(t.children&&0!==t.children.length)for(let e of t.children)e.type===T.PointText?e.fillColor=this._textColor:e.children&&e.children.length>0&&this.setTextColor(e)}_createCategoricalColorLegend(t,e){let i=0;this._showTitle&&(this.addChild(new Kt({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),i=parseFloat(this._fontSize)+5);let s=t.mark("rect",{top:this._y+2+i,left:this._x,width:10,height:10,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),n=t.mark("text",{fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+i,anchor:["left","top"]}),r=t.glyph(s,n),a=this.encoding.scale,o=new Jt(a.domain.map((t=>({category:t,value:a.map(t)})))),h=t.repeat(r,o);t.encode(n,{channel:"text",field:"category",_remember:!1}),t.encode(s,{channel:"fillColor",field:"category",_remember:!1,scale:a}),h.layout=Qc("grid",{numCols:this._numCols,numRows:this._numRows}),this.addChild(h)}pathHitTest(t,e){let i=gt(this);for(let s=i.length-1;s>=0;s--){let n=i[s];if(yt(n)&&n.contains(t,e))return n}return null}matches(t){let e=ct(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(ct(t.anyItem).split("_")[0]===e)return!0}return!1}_doTranslate(t,e){super._doTranslate(t,e),this._x+=t,this._y+=e}}class ie extends Ot{constructor(t){if(super(),this.type=T.Glyph,this._id=this.type+vt[this.type]++,t)for(let e of t)this.addChild(e)}duplicate(){let t=this.getScene().glyph();for(let e of this.children)t.addChild(e.duplicate());return t.classId=this.classId,this._dataScope&&(t.dataScope=this._dataScope.clone()),t}}class se extends Q{constructor(t){super(t),this.type=T.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new X(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get baseline(){return this._baseline}set baseline(t){this._baseline=t}get orientation(){return this._orientation}set orientation(t){this._orientation=t}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(t){super.copyPropertiesTo(t),t._baseline=this._baseline,t._orientation=this._orientation}resizeArea(t,e){let i=this.vertices[this.vertices.length/2].x,s=this.vertices[this.vertices.length/2].y,n=this.width,r=this.height;for(let a of this.vertices)a.x=i+t/n*(a.x-i),a.y=s+e/r*(a.y-s);this._updateBounds()}getSVGPathData(){return super.getSVGPathData()+" z"}}class ne extends Q{constructor(t){super(t),this.type=T.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t}get outerRadius(){return this._outerRadius}set outerRadius(t){this._outerRadius=t,this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new Z(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}get thickness(){return this._outerRadius-this._innerRadius}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}class re extends Q{constructor(t){super(t),this.type=T.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}get center(){return new Z(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}set radius(t){this._radius=t,this._updateBounds()}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}_doTranslate(t,e){this._x+=t,this._y+=e,super._doTranslate(t,e)}}class ae{constructor(t,e){this.direction=e,this.items=t,this.type=S,this._orientation=[C.Top,C.Middle,C.Bottom].indexOf(e)>=0?v:b,this._itemIds=this.items.map((t=>t.classId)).sort().join("_"),this.id=this.type+"_"+this._itemIds+"_"+this._orientation}get orientation(){return this._orientation}apply(){let t,e=this.direction;this.direction==C.Top||this.direction==C.Left?t=Math.min(...this.items.map((t=>t.bounds[e]))):this.direction==C.Bottom||this.direction==C.Right?t=Math.max(...this.items.map((t=>t.bounds[e]))):this.direction!=C.Center&&this.direction!=C.Middle||(t=n.mean(this.items.map((t=>t.bounds[e]))));let i=this.items.map((i=>t-i.bounds[e])),s=e==C.Top||e==C.Middle||e==C.Bottom?"y":"x";this.items.forEach(((t,e)=>{if(t.parent&&t.parent.layout&&t.parent.layout.type==y.Stack){let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t.parent._doTranslate(n,r)}else{let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t._doTranslate(n,r)}}));let r={};this.items.forEach((t=>r[t.classId]=t)),Object.values(r).forEach((t=>t.getScene()._updateAncestorBounds(t)))}toJSON(){let t={};return t.items=this.items.map((t=>t.id)),t.direction=this.direction,t.type=this.type,t.id=this.id,t}}class oe{constructor(t,e,i,s,n,r,a){this.item=t,this.baseItem=e,this.scene=i,this.channel=s,this.itemAnchor=n,this.baseAnchor=r,this.offset=a,this.type=E,this.id=this.type+"_"+this.item.classId+"_"+this.baseItem.classId+"_"+s}apply(){let t=nt(this.item,this.scene),e=nt(this.baseItem,this.scene),i=this.itemAnchor,s=this.baseAnchor,n=this.item.type==T.PointText;if("radialDistance"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];a.type==T.Arc||a.type==T.Ring?r="top"==s?a.outerRadius+this.offset:"bottom"==s?a.innerRadius+this.offset:(a.outerRadius+a.innerRadius)/2+this.offset:a.type==T.Circle&&(r="top"==s?a.radius+this.offset:"bottom"==s?this.offset:a.radius/2+this.offset),o._doTranslate(a.x-o.x,a.y-r-o.bounds[i]),o._rotate?o._rotate=[o._rotate[0],a.x,a.y]:o._rotate=[0,a.x,a.y]}else if("angle"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];r=a.type==T.Arc?"left"==s?a.endAngle+this.offset:"center"==s?a.startAngle+a.angle/2+this.offset:a.startAngle+this.offset:90,o._rotate?o._rotate[0]=90-r:(o._doTranslate(a.x-o.bounds[i],a.y-t[n].y),o._rotate=[90-r,e[n].x,e[n].y])}else{let r;if(this.baseItem.type==T.Link)switch(s){case"left":case"top":r=0;break;case"center":case"middle":r=.5;break;case"right":case"bottom":r=1}for(let a=0;a<t.length;a++){let o=this.baseItem.type==T.Link?e[a].getPointAt(r)[this.channel]:e[a].bounds[s]+this.offset;n?(t[a].anchor["x"==this.channel?0:1]=this.itemAnchor,t[a][this.channel]=o):"x"==this.channel?t[a]._doTranslate(o-t[a].bounds[i],0):t[a]._doTranslate(0,o-t[a].bounds[i])}}this.item.getScene()._updateAncestorBounds(this.item),this.baseItem.getScene()._updateAncestorBounds(this.baseItem)}toJSON(){let t={};return t.item=this.item.id,t.baseItem=this.baseItem.id,t.channel=this.channel,t.itemAnchor=this.itemAnchor,t.baseAnchor=this.baseAnchor,t.offset=this.offset,t.type="affixation",t.id=this.id,t}}class he extends Ot{constructor(t,e,i){super(),this.type=T.Gridlines,this.id=this.type+vt[this.type]++,this.encoding=t,this.channel=this.encoding.channel,this._item=e,this._strokeColor="strokeColor"in i?i.strokeColor:"#ddd",this._strokeWidth="strokeWidth"in i?i.strokeWidth:1,"radialDistance"==this.channel&&"angle"in i&&(this._rotate=[-i.angle,this.encoding.x,this.encoding.y])}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.args.item=this._item.id,t.args.strokeColor=this._strokeColor,t.args.strokeWidth=this._strokeWidth,t.args.values=this._values,"time"===this.encoding.scale.type&&(t.args.isDate=!0),t.channel=this.encoding.channel,t.field=this.encoding.field,this._rotate&&(t.args.angle=this._rotate[0]),t}get values(){return this._values}set values(t){this._values=t,this.updateLines(),this.updateLinePositions()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t;for(let e of this.children)e.strokeColor=t}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t;for(let e of this.children)e.strokeWidth=t}matches(t){let e=ct(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(ct(t.anyItem).split("_")[0]===e)return!0}return!1}updateLinePositions(){let t=St(this._item)?St(this._item):Ct(this._item);if("x"==this.channel||"width"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);for(let[t,s]of this.children.entries()){let n=i[0]+this.encoding.scale.map(this._values[t])-this.encoding.scale.range[0];s._setVertices([[n,e.top],[n,e.bottom]])}}else if("y"==this.channel||"height"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);if(this.encoding.flip)for(let[t,s]of this.children.entries()){let n=i[1]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}else for(let[t,s]of this.children.entries()){let n=i[0]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}}else if("radialDistance"==this.channel)for(let[t,e]of this.children.entries())e.x=this._item.parent.x,e.y=this._item.parent.y,e.radius=this.encoding.scale.map(this._values[t]);for(let t of this.children)t._updateBounds();this._updateBounds()}updateLines(){if(this.children=[],"x"==this.channel||"y"==this.channel||"width"==this.channel||"height"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Q({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=T.Line,e.id=this.id+"line"+t,this.addChild(e)}else if("radialDistance"==this.channel)for(let t=0;t<this._values.length;t++){let e=new Vt({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=T.Circle,e.id=this.id+"line"+t,this.addChild(e)}}}class le extends Ot{constructor(){super(),this.type=T.Collection,this._id=this.type+vt[this.type]++,this.classId=this.id,this._childrenOrder=void 0}get childrenOrder(){return this._childrenOrder?this._childrenOrder:{field:"atlas_rowId",direction:"asc"}}set childrenOrder(t){if(!("field"in t)&&!("direction"in t))return;let e,i=t.field;if(this.dataScope.dataTable.hasField(i)){if(this._childrenOrder=t,i===h)e=(t,e)=>parseInt(t.dataScope.getFieldValue(i).substring(1))-parseInt(e.dataScope.getFieldValue(i).substring(1));else{switch(this.children[0].dataScope.getFieldType(i)){case A.Date:break;case A.Number:case A.Integer:e=(t,e)=>t.dataScope.aggregateNumericalField(i)-e.dataScope.aggregateNumericalField(i);break;case A.String:e=t.ranking?(e,s)=>t.ranking.indexOf(e.dataScope.getFieldValue(i))-t.ranking.indexOf(s.dataScope.getFieldValue(i)):(t,e)=>t.dataScope.getFieldValue(i)<e.dataScope.getFieldValue(i)?-1:1}}this.children.sort(e),"desc"==t.direction&&this.children.reverse(),this.layout&&this.layout.run()}else console.warn("Cannot order collection children by an non-existent field",t.field)}duplicate(){let t=this.getScene().collection();for(let e=0;e<this.children.length;e++){let i=this.children[e];t.addChild(i.duplicate())}if(t.classId=this.classId,this.parent.addChild(t),this._layout){let e=this._layout.clone();t.layout=e}return t}contains(t,e){if([T.Arc,T.Pie,T.Polygon,T.Area].indexOf(this.firstChild.type)>=0){let i=this.getSVGPathData();if(""!==i){let s=wt.getContext(),n=new Path2D(i);return s.lineWidth=Math.max(this.strokeWidth,2.5),s.stroke(n),s.isPointInPath(n,t,e)}}return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}getSVGPathData(){let t="";for(let e of this.children)if(e.getSVGPathData)t+=e.getSVGPathData();else if(e.bounds){let i=e.bounds;t+=["M",i.left,i.top].join(" "),t+=["L",i.right,i.top].join(" "),t+=["L",i.right,i.bottom].join(" "),t+=["L",i.left,i.bottom,"Z"].join(" ")}return t}}class ce extends Q{constructor(t){super(t),this._type=T.Arc,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=At(this._startAngle),this._er=At(this._endAngle);let e=this._x+this._innerRadius*Math.cos(this._sr),i=this._y-this._innerRadius*Math.sin(this._sr),s=this._x+this._innerRadius*Math.cos(this._er),n=this._y-this._innerRadius*Math.sin(this._er),r=this._x+this._outerRadius*Math.cos(this._sr),a=this._y-this._outerRadius*Math.sin(this._sr),o=this._x+this._outerRadius*Math.cos(this._er),h=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[e,i],[r,a],[o,h],[s,n]])}get type(){return 0===this._innerRadius?T.Pie:T.Arc}set type(t){this._type=t}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}set outerRadius(t){this._outerRadius=t,this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new Z(this._x,this._y)}set x(t){this._x=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this._updateBounds()}set y(t){this._y=t,this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}sweepOver(t){let e=this.startAngle,i=this.endAngle;i<e&&(i+=360);let s=t.startAngle,n=t.endAngle;return n<s&&(n+=360),s>=e&&s<=i&&n>=e&&n<=i}_doTranslate(t,e){this._x+=t,this._y+=e,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}adjustAngle(t,e){this._startAngle=t,this._endAngle=e,this._sr=At(this._startAngle),this._er=At(this._endAngle),this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er)}}class de extends H{constructor(t){super(t),this.type=T.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}toJSON(){let t=super.toJSON();return t.src=this._src,t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}get src(){return this._src}set src(t){this._src=t}get width(){return this._width}set width(t){this._width=t,this._updateBounds()}get height(){return this._height}set height(t){this._height=t,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new a(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}}class ue extends Q{constructor(t){super(t),this.type=T.Link,this.mode="mode"in t?t.mode:"linear",this.source=void 0,this.target=void 0,this.sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this.targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this.sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this.targetOffset="targetOffset"in t?t.targetOffset:[0,0]}radialvalue(t,e){let i=t-Math.PI/2;return[t=e*Math.cos(i),e*=Math.sin(t)]}bezierCurveHorizontal(t,e,i,s){return`M ${t} ${e} C ${(t+i)/2} ${e} ${t} ${s} ${i} ${s}`}bezierCurveVertical(t,e,i,s){return`M ${t} ${e} C ${t} ${(e+s)/2} ${i} ${e} ${i} ${s}`}bezierCurveRadial(t,e,i,s){let n=this.radialvalue(t,e),r=this.radialvalue(t,(e+s)/2),a=this.radialvalue(i,e),o=this.radialvalue(i,s);return`M ${n[0]} ${n[1]} C ${r[0]} ${r[1]} ${a[0]} ${a[1]} ${o[0]} ${o[1]}`}_updateBounds(){if(null!=this.source&&null!=this.target){let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];this._bounds=new a(Math.min(t,i),Math.min(e,s),Math.abs(t-i),Math.abs(e-s))}else this._bounds=new a(0,0,0,0)}getSVGPathData(){if(void 0===this.source||void 0===this.target)return"";let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];switch(this.mode){case"curveHorizontal":return this.bezierCurveHorizontal(t,e,i,s);case"curveVertical":return this.bezierCurveVertical(t,e,i,s);case"linear":default:return`M ${t} ${e} L ${i} ${s}`}}copyPropertiesTo(t){super.copyPropertiesTo(t),t.sourceAnchor=this.sourceAnchor.slice(),t.targetAnchor=this.targetAnchor.slice(),t.sourceOffset=this.sourceOffset.slice(),t.targetOffset=this.targetOffset.slice(),t.mode=this.mode}getPointAt(t){const e=kt.getSVG();let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",this.getSVGPathData()),e.appendChild(i);let s=i.getTotalLength();return i.getPointAtLength(s*t)}}const fe=function(t,e,i){let s=t.getScene();_t(t)||s._reapplyConstraints(t),s.getRelatedAxes(t).forEach((t=>{t.encoding&&void 0!==t.encoding.scale.offset&&(t.encoding.scale.offset+="x"===t.channel||"width"===t.channel?e:i),0===i||"x"!==t.channel&&"width"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+i),0===e||"y"!==t.channel&&"height"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+e),t.reposition()})),s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},pe=function(t,e,i){let s=t.getScene();s._relayoutAncestors(t,e);let n=[t],r=t.firstChild;for(;r;)n.push(r),r=r.firstChild;for(let t of n)t.getScene()._reapplyConstraints(t);let a=!1;for(let t of i)if(["numRows","numCols","layout","childrenOrder"].indexOf(t)>=0){a=!0;break}let o,h=!1;if(t.layout&&(t.layout.type!==y.Grid||1!==t.layout.numRows&&1!==t.layout.numCols?t.layout.type===y.Stack&&i.indexOf("orientation")>=0&&(h=!0,o=t.layout.orientation===b?"x":"y"):(h=!0,o=1===t.layout.numRows?"x":"y")),h){let e=s.getRelatedAxes(t).filter((e=>e instanceof te&&e._item.parent.classId===t.classId));for(let i of e){s.removeItem(i);let e=i.toJSON().args;delete e.orientation,e.item=t.firstChild,s.axis(o,i.field,e)}}if(a)s.reCreateRelatedAxes(t);else{s.getRelatedAxes(t).forEach((t=>t.reposition()))}s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},ge=function(t){for(let e of t.encodings)e._map(),e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let i=e.anyItem,s=e.scene.getRelatedAxes(i);for(let i of s)i.encoding&&i.encoding.scale===t&&(i.tickValues=e._inferTickValues(e),i.labelValues=e._inferTickValues(e),i._positionPath(),i._showTitle&&i._positionTitle(),"radialDistance"===i._channel&&i._rotate&&(i._rotate=[i._rotate[0],i._item.parent.x,i._item.parent.y]),i._updateBounds());e.scene.getRelatedGridlines(i).forEach((t=>t.updateLinePositions()))}},_e=function(t){for(let e of t.encodings)e._apply();for(let e of t.encodings)e.scene._relayoutAncestors(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let t=e.anyItem;e.scene.getRelatedAxes(t).forEach((t=>t.reposition())),e.scene.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))}},me=function(t,e){let i=t.getScene();i._relayoutAncestors(t,e),i._reapplyConstraints(t),i.getRelatedAxes(t).forEach((t=>t.reposition())),i.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},ye=function(t,e){let i=e.getScene(),s=i.getRelatedAxes(t);for(let n of s)n._item.classId===t.classId&&(n._item=e,n._items=nt(e,i));let n=i.encodings[ct(t)];if(n){i.encodings[ct(e)]={};for(let s of["x","y"]){const r=n[s];r&&(r.anyItem=e,r.items=nt(e,i),i.encodings[ct(e)][s]=r,delete i.encodings[ct(t)][s])}0===Object.keys(n).length&&delete i.encodings[ct(t)]}},ve=function(t,e){let i=e.getScene(),s=i.encodings[ct(t)];if(s){i.encodings[ct(e)]={};for(let n of["x","y"]){const r=s[n];r&&(r.anyItem=e,r.items=nt(e,i),i.encodings[ct(e)][n]=r,delete i.encodings[ct(t)][n])}0===Object.keys(s)&&delete i.encodings[ct(t)]}let n=i.getRelatedAxes(t);for(let s of n)s._item.classId===t.classId&&(s._item=e,s._items=nt(e,i))},be=function(t){let e=t.getScene(),i=e.encodings[ct(t)];for(let t in i)i[t]._apply();e.getRelatedAxes(t).forEach((t=>t.reposition())),e.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))};function xe(t,e,i,s){let n=s.getFieldType(i);if(n!=A.String&&n!=A.Date&&n!=A.Integer)throw new Error(G.REPOPULATE_BY_NONCAT+": "+i+" is "+n);if(e.parent&&e.parent.dataScope&&!e.parent.dataScope.isFullTable()&&e.parent.dataScope.dataTable!=s)throw new Error(G.REPOPULATE_DT_MISMATCH);return function(t,e,i,s){let n=nt(e.parent,t);1===n.length&&(e.parent.dataScope=void 0);for(let t of n){let e=s.getFieldSummary(i).unique.map((e=>t.dataScope?t.dataScope.cross(i,e):new Pt(s).cross(i,e)));e=e.filter((t=>!t.isEmpty()));const n=e.length-t.children.length,r=t.children.length-e.length;for(let e=0;e<r;e++)t.removeChildAt(t.children.length-1);const a=t.children.length;for(let e=0;e<n;e++){let e=t.children[Math.floor(Math.random()*a)].duplicate();t.addChild(e)}t.children.forEach(((t,i)=>t.dataScope=e[i]))}t._relayoutAncestors(e)}(t,e,i,s)}function we(t,e){let i=t.item;if(e.innerRadius===i.outerRadius&&i.sweepOver(e))t.children.push({item:e,children:[]});else if(t.children&&t.children.length>0&&e.innerRadius>i.outerRadius&&i.sweepOver(e))for(let i of t.children)we(i,e)}function ke(t,e,i,s){let n=t.item;if(n.innerRadius=e,n.outerRadius=e+s.map(i[n.id]),t.children&&t.children.length>0)for(let e of t.children)ke(e,n.outerRadius,i,s)}class Ce{constructor(t,e){this._type="tree";let i=[],s=[];this._nodeHash={},this._traverse(t,i,s),this._nodeTable=new Jt(i,"nodes"),this._linkTable=new Jt(s,"links"),this._nodeTable.tree=this,this._linkTable.tree=this,this._data=t,this.aggregateFromLeaves("value","average")}get type(){return this._type}_traverse(t,e,i,s=0){let n={};o in t||(t.id="n"+e.length),e.push(n),t._depth=s;for(let r in t)if("children"==r&&t[r]&&t[r].length>0)for(let n of t[r]){let r=this._traverse(n,e,i,s+1);i.push({parent:t.id,child:r})}else n[r]=t[r];return this._nodeHash[n.id]=n,n.id}getParent(t){let e,i=t.id,s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].child==i){e=s[t].parent;let i=n.findIndex((t=>t.id==e));return n[i]}}getChildren(t){let e=t.id,i=[],s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].parent==e){let e=s[t].child,r=n.findIndex((t=>t.id==e));i.push(n[r])}return i}getNodeDataScope(t){return new Pt(this._nodeTable).cross(h,t.atlas_rowId)}getMaxDepth(){return this._nodeTable._fieldSummaries._depth.max}getRoot(){return this._nodeTable.data[0]}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}getNode(t){return this._nodeTable.data.filter((e=>e.id==t))[0]}sumLeaves(t,e){if(!t)return 0;let i=t.id,s=[];if(s=this.getChildren(t),s&&s.length>0){let t=0;for(let i of s)t+=this.sumLeaves(i,e);this.getNode(i)["sum"+e]=t}else this.getNode(i)["sum"+e]=t[e];return t["sum"+e]}countLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0)for(let t of s)n+=this.countLeaves(t,e);else n=1;return this.getNode(i)["count"+e]=n,t["count"+e]}averageLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0){for(let t of s)n+=this.averageLeaves(t,e);n/=s.length,this.getNode(i)["average"+e]=n}else this.getNode(i)["average"+e]=t[e];return t["average"+e]}medianLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.medianLeaves(t,e));n.sort((function(t,e){return t-e}));let t=Math.floor(n.length/2);n.length%2?this.getNode(i)["median"+e]=n[t]:this.getNode(i)["median"+e]=(n[t-1]+n[t])/2}else this.getNode(i)["median"+e]=t[e];return t["median"+e]}maxLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.maxLeaves(t,e));this.getNode(i)["max"+e]=Math.max(...n)}else this.getNode(i)["max"+e]=t[e];return t["max"+e]}minLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.minLeaves(t,e));this.getNode(i)["min"+e]=Math.min(...n)}else this.getNode(i)["min"+e]=t[e];return t["min"+e]}aggregateFromLeaves(t,e){let i=this.getRoot();switch(e){case"sum":this.sumLeaves(i,t);break;case"count":this.countLeaves(i,t);break;case"average":this.averageLeaves(i,t);break;case"median":this.medianLeaves(i,t);break;case"max":this.maxLeaves(i,t);break;case"min":this.minLeaves(i,t)}}}function Se(t,e,i,s,n){switch(e.type){case T.Circle:return function(t,e,i,s,n){let r,a,o=i||k.Outward,h=s||50;if(o!==k.Inward&&o!==k.Outward)throw G.UNKNOWN_DIRECTION+" "+o;return nt(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let l=i.parent;Ee(i,e.id,o,h,n,n.getRoot(),s,t,!0),s.layout=Qc("strata",{direction:o,rootMark:i}),l.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n);case T.Rect:return function(t,e,i,s,n){let r,a,o=i||k.Down,h=s||50;if([k.Up,k.Down,k.Left,k.Right].indexOf(o)<0)throw G.UNKNOWN_DIRECTION+" "+o;return nt(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let l=i.parent;Te(i,e.id,o,h,n,n.getRoot(),s,t,!0),s.layout=Qc("strata",{direction:o,rootMark:i}),l.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n)}}function Ee(t,e,i,s,n,r,a,o,h){h&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let l=n.getChildren(r);if(0===l.length)return;let c=t.type===T.Circle||t.type===T.Ring?90:t.startAngle,d=(t.type===T.Circle||t.type===T.Ring?360:t.angle)/l.length;for(let r=0;r<l.length;r++){let h,u=t.type===T.Circle?t.radius:t.outerRadius;h=360===d?o.mark("ring",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}):o.mark("arc",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,startAngle:Nt(c+d*r),endAngle:Nt(c+d*(r+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),h.dataScope=n.getNodeDataScope(l[r]),h.classId=e,a.addChild(h),Ee(h,e,i,s,n,l[r],a,o)}}function Te(t,e,i,s,n,r,a,o,h){h&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let l,c,d,u=n.getChildren(r);if(0!==u.length){switch(i){case k.Up:case k.Down:case k.Left:case k.Right:default:l=t.left,c=t.bottom,d=t.width/u.length}for(let r=0;r<u.length;r++){let h=o.mark("rect",{left:l,top:c,width:d,height:s,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});l+=d,h.dataScope=n.getNodeDataScope(u[r]),h.classId=e,a.addChild(h),Te(h,e,i,s,n,u[r],a,o)}}}class Ae{constructor(t,e,i,s){this._listener=t,this._eventType=e,this._selDef=i,this._targetDef=s}getCallbackFunction(t,e){let i=this;return function(s){s.stopPropagation();let r,a=e._getSelection(s,i.selectionDef,i._listener,t.getItem(n.select(this).attr("id"))),o=nt(i.targetDef.item,t);i.selectionDef.remember?(e.addGlobalPredicate(t,a.predicate),r=e.getGlobalPredicates(t)):r=e.getGlobalPredicates(t).concat([a.predicate]);for(let t of o){let e=!0;for(let i of r)if(!tt(t,i)){e=!1;break}for(let s in i.targetDef.effect)s in t.staticProperties||(t.staticProperties[s]=t[s]),e?t[s]=i.targetDef.effect[s].selected:"unselected"in i.targetDef.effect[s]?t[s]=i.targetDef.effect[s].unselected:s in t.staticProperties&&(t[s]=t.staticProperties[s])}e._renderer.render(t,{visualOnly:!0})}}getRestoreFunction(t,e,i){let s=this;return function(){let n=nt(s.targetDef.item,t);if(s.targetDef.effect)for(let t of n)for(let e in s.targetDef.effect)t[e]=t.staticProperties[e];else for(let t of n)for(let e in t.staticProperties)t[e]=t.staticProperties[e];i&&(e._globalPredicates={}),e._renderer.render(t,{visualOnly:!0})}}get listener(){return this._listener}get selectionDef(){return this._selDef}get targetDef(){return this._targetDef}get eventType(){return this._eventType}}class Ie extends Ot{constructor(t){super(),t&&t.fillColor&&(this.fillColor=t.fillColor),this.type=T.Scene,this._id=this.type+vt[this.type]++,this.encodings={},this.constraints={},this._itemMap={},this._interactions=[]}clear(){this.removeAll(),this.encodings={},this.constraints={},this._itemMap={}}group(t){let e=new Ot;if(e.classId=e.id,this.addChild(e),t&&t.length>0)for(let i of t)e.addChild(i);return this._itemMap[e.id]=e,e}mark(t,e){let i=void 0===e?{}:e,s=null;switch(i.type=t,t){case T.Rect:{"top"in i||(i.top=0),"left"in i||(i.left=0),"width"in i||(i.width=100),"height"in i||(i.height=100);let t=i.top,e=i.left,n=i.width,r=i.height;i.vertices=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]],delete i.top,delete i.left,delete i.width,delete i.height,"fillColor"in i||(i.fillColor="none"),s=new jt(i);break}case T.Area:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,e],[s,n],[t,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new se(i);break;case T.Line:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new Q(i),s.type=T.Line;break;case T.Path:s=new Q(i);break;case T.Circle:s=new Vt(i);break;case T.Ring:s=new ne(i);break;case T.Arc:case T.Pie:s=new ce(i);break;case T.Polygon:s=new re(i);break;case"text":case T.PointText:"anchor"in i||(i.anchor=["center","middle"]),s=new Kt(i);break;case T.Image:s=new de(i);break;case T.Link:s=new ue(i)}return null!==s&&(s.id="id"in i?i.id:s.type+vt[s.type]++,s.classId=s.id,this.addChild(s),this._itemMap[s.id]=s),s}glyph(...t){let e=new ie(t);return e.classId=e.id,this.addChild(e),this._itemMap[e.id]=e,e}collection(){let t=new le;return this.addChild(t),this._itemMap[t.id]=t,t}attach(t,e){t.dataScope=new Pt(e)}repeat(t,e,i){if(!t||void 0===e)throw G.INCOMPLETE_REPEAT_INFO;if(e.nodeTable&&e.linkTable){if(!Array.isArray(t)||2!==t.length)throw G.REPEAT_NODE_LINK;return function(t,e,i,s){let n=s.nodeTable.getFieldSummary(o).unique.map((t=>e.dataScope?e.dataScope.cross(o,t):new Pt(s.nodeTable).cross(o,t))),r=t.collection(),a={};r.dataScope=e.dataScope?e.dataScope.clone():new Pt(s.nodeTable),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}r.children.forEach(((t,e)=>{t.dataScope=n[e],a[t.dataScope.getFieldValue(o)]=t}));let l=s.linkTable.getFieldSummary(h).unique.map((t=>i.dataScope?i.dataScope.cross(h,t):new Pt(s.linkTable).cross(h,t))),c=t.collection();c.dataScope=i.dataScope?i.dataScope.clone():new Pt(s.linkTable),c.addChild(i);for(let t=1;t<l.length;t++){let t=i.duplicate();c.addChild(t)}c.children.forEach(((t,e)=>t.dataScope=l[e]));let d="tree"===s.type?"parent":"source",u="tree"===s.type?"child":"target";for(let t of c.children){let e=t.dataScope.getFieldValue(d),i=t.dataScope.getFieldValue(u);t.source=a[e],t.target=a[i],t._updateBounds()}return t.addChild(c),t.addChild(r),[r,c]}(this,t[0],t[1],e)}{let s=i||{},n=s.field?s.field:Jt.RowID,r=s.callback;Mt(n,e);let a=Ft(this,t,n,e,r);return s.layout&&(a.layout=s.layout),a}}repopulate(t,e,i){if(!t||void 0===e)throw G.INCOMPLETE_REPEAT_INFO;let s=i||{},n=s.field?s.field:Jt.RowID;Mt(n,e),xe(this,t,n,e)}densify(t,e,i){if(!t||void 0===e)throw G.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:Jt.RowID,a="startAngle"in s?s.startAngle:90,o="direction"in s?s.direction:"clockwise",h=s.callback;Mt(r,e);let l=Dt(this,t,n,r,e,h,a,o);return ve(t,l),l}stratify(t,e,i){if(!(e instanceof Ce))throw G.STRATIFY_WITHOUT_TREE;if(t.type!==T.Circle&&t.type!==T.Rect)throw G.STRATIFY_WRONG_ITEM;let s=i||{};return Se(this,t,s.direction,s.size,e)}divide(t,e,i){if(!t||null==e)throw G.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:Jt.RowID,a=s.callback;Mt(r,e);let o=Lt(this,t,n,r,e,a);return s.layout&&(o.layout=s.layout),ye(t,o),o}classify(t,e){if(!ad(t))throw G.CANNOT_CLASSIFY+t.type;let i=e||{},s=i.field?i.field:Jt.RowID,n=t.firstChild.dataScope.dataTable,r=i.layout;return Mt(s,n),function(t,e,i,s){let n=nt(e,t);for(let e of n){let s,n={},r=e.children;for(let t of r){let e=t.dataScope.getFieldValue(i);e in n||(n[e]=[]),n[e].push(t)}let a=r[0].dataScope._dt;for(let r in n){let o=t.collection();e.addChild(o),void 0===s&&(s=o.id),o.classId=s,o.dataScope=e.dataScope?e.dataScope.cross(i,r):new Pt(a).cross(i,r);for(let t of n[r])o.addChild(t)}}s&&t.setProperties(e.firstChild,{layout:s})}(this,t,s,r),t}_validateEncodeArgs(t,e){if(!t||!("channel"in e)||!("field"in e))throw G.INCOMPLETE_BINDING_INFO;let i=e.field;if("vertex"==t.type||"segment"==t.type){if(!t.parent.dataScope&&!t.dataScope)throw G.BIND_WITHOUT_DATASCOPE}else if(!t.dataScope)throw G.BIND_WITHOUT_DATASCOPE;let s=e.table?e.table:t.dataScope?t.dataScope._dt:t.parent.dataScope._dt,n=s.getFieldType(i);if("fillGradient"===e.channel&&[A.String,A.Boolean,A.Date].indexOf(n)>=0)throw G.UNSUPPORTED_FIELDTYPE+e.channel+": "+n;Mt(i,s)}encode(t,e){let i,s=Array.isArray(t)?t:[t],n=[];for(let r of s){let s;if([T.Pie,T.Arc].indexOf(t.type)>=0&&"angle"===e.channel){let i=t.parent;if(i.type===T.Collection&&i.layout&&i.layout.orientation===x){n.push(this._encodeWithinCollection(r,e));continue}}if(this._validateEncodeArgs(r,e),"vertex"==r.type&&r.parent.type==T.Area){let t=nt(r.parent,this);s=[];let e=r.parent.vertices.indexOf(r)<r.parent.vertices.length/2;for(let i of t)s=e?s.concat(i.vertices.slice(0,i.vertices.length/2)):s.concat(i.vertices.slice(i.vertices.length/2))}else s=nt(r,this);if(1===s.length&&s[0].type===T.Area&&("x"===e.channel||"y"===e.channel))return void console.warn("Only 1 "+r.type+" found, cannot encode "+e.field);!e.scale&&i&&(e.scale=i);let a=this._doEncode(s,e);i||(i=a.scale),n.push(a)}return n.length>1?n:n[0]}_doEncode(t,e){let i=t[0],s=e.channel,n=e.field;"datatable"in e||(e.datatable=i.dataScope?i.dataScope.dataTable:i.parent.dataScope.dataTable),"aggregator"in e||(e.aggregator="mean"),"flipScale"in e||(e.flipScale=!1),"includeZero"in e||(e.includeZero=!1),"scaleType"in e||(e.scaleType="linear");let r=new Wt(t,this,s,n,e);switch(s){case"width":case"height":case"radius":case"outerRadius":case"innerRadius":case"area":case"fontSize":i.type==T.Area?zt(r):Gt(r);break;case"strokeWidth":i.type==T.Link?function(t){t._query=function(){let t=this.field,e=this.channel,i=this.items.map((t=>t.dataScope));if("strokeWidth"==e)if(this.datatable.hasField(t))this.data=i.map((e=>e.getFieldValue(t)));else if(t.startsWith("parent.")||t.startsWith("child.")){let e=this.datatable.tree.nodeTable,s=t.split(".")[0],n=t.split(".")[1],r=i.map((t=>t.getFieldValue(s)));this.data=r.map((t=>new Pt(e).cross(o,t).getFieldValue(n)))}},t._map=function(){let t,e=this.channel,i=this.items;if("strokeWidth"==e){let e,s;t=Xc(this.scaleType),t.domain=[0,Math.max(...this.data)],e=1,s=Math.max(...i.map((t=>parseFloat(t.styles.strokeWidth)))),s==e&&(s=e+5),this.rangeExtent&&(s=e+this.rangeExtent),this.range&&(e=this.range[0],s=this.range[1]),t._setRange([e,s]),this.scale||(this.scale=t),this.scale._addEncoding(this)}},t._apply=function(){if("strokeWidth"==this.channel)for(let t=0;t<this.data.length;t++)this.items[t].styles.strokeWidth=this.scale.map(this.data[t])},t.run()}(r):Gt(r);break;case"x":case"y":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t,e,i,s,n,r=this.channel,a=this.datatable.getFieldType(this.field),o=rt(this.anyItem);if(o&&o.type==y.Grid){let e=o.cellBounds;t="x"==r?e[0].width:e[0].height}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===T.Area)t="x"==r?this.anyItem.parent.bounds.width:this.anyItem.parent.bounds.height;else{let e=this.items.map((t=>t[r]));t=Math.max(...e)-Math.min(...e),t<100?t=100:t>500&&(t=500)}switch(this.rangeExtent&&(t=this.rangeExtent),a){case A.Boolean:break;case A.Date:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=this.data;for(let e of this.scale.encodings)t=t.concat(e.data);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=Xc("time"),this.scale.isFlipped=this._flipScale,n=[0,t];break;case A.String:if(s=Array.from(new Set(this.data)),n=[0,t],this.scale){let t=this.scale.domain;for(let e of s)t.indexOf(e)<0&&t.push(e);s=t,n=this.scale.range}else this.scale=Xc("point"),this.scale.isFlipped=this._flipScale,n=[0,t];break;default:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=this.data;for(let e of this.scale.encodings)t=t.concat(e.data);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=Xc(this.scaleType),this.scale.isFlipped=this._flipScale,this.scale.includeZero=this._includeZero,n=[0,t],this.scale._baseItem=this.anyItem;s[0]==s[1]&&(s[1]=1.1*s[0])}this.scale._scale.domain(s),this.scale._setRange(n),this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);if("x"==e){let i=rt(this.anyItem,"grid"),s=this.scale._baseItem?rt(this.scale._baseItem,"grid"):void 0;if(this.scale._baseItem&&!dt(this.anyItem,this.scale._baseItem)&&i&&s&&i.numRows===s.numRows&&i.numCols===s.numCols){let t=s.group.bounds.left-i.group.bounds.left,n=0;i.group.getScene().translate(i.group,t,n),i._colGap=s.colGap;let r=this.items.map((t=>ot(t))),a=s.cellBounds;for(let t=0;t<this.items.length;t++){let i=this.items[t],s=a[r[t]].left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}this.anyItem.parent.getScene()._updateAncestorBounds(this.anyItem,this.items)}else if(i&&i.type==y.Grid)for(let t=0;t<this.items.length;t++){let i=this.items[t],s=at(i).left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===T.Area){let t=ut(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=i.parent.bounds.left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){let t=ut(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t[e])))),this.items[0].type===T.PointText&&this.items.forEach((t=>t.horzAnchor="center"));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n)}}}else{let i=rt(this.anyItem,"grid"),s=this.scale._baseItem?rt(this.scale._baseItem,"grid"):void 0;if(this.scale._baseItem&&!dt(this.anyItem,this.scale._baseItem)&&i&&s&&i.numRows===s.numRows&&i.numCols===s.numCols){let t=0,n=s.group.bounds.top-i.group.bounds.top;i.group.getScene().translate(i.group,t,n),i._rowGap=s.rowGap;let r=this.items.map((t=>ot(t))),a=s.cellBounds;for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=a[r[t]].bottom-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}this.anyItem.parent.getScene()._updateAncestorBounds(this.anyItem,this.items)}else if(i&&i.type==y.Grid){let t=this.items.map((t=>at(t)));for(let i=0;i<this.items.length;i++){let s=this.items[i],n=0,r=t[i].bottom-this.scale.map(this.data[i])-s[e];s._doTranslate(n,r),"vertex"!=s.type&&"segment"!=s.type||s.parent._updateBounds()}}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===T.Area){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=i.parent.bounds.top+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.y)))),this.items[0].type===T.PointText&&this.items.forEach((t=>t.vertAnchor="middle"));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i.refBounds[e];i._doTranslate(s,n)}}}},t.run()}(r);break;case"fillColor":case"strokeColor":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:this.data=[!0,!1];break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){switch(this.datatable.getFieldType(this.field)){case A.Boolean:if(!this.scale&&(this.scale=Xc("ordinalColor"),this.scale.domain=this.data,this._mapping)){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;case A.String:if(this.scale)this.scale.domain=Array.from(new Set(this.scale.domain.concat(this.data)));else{let t={scheme:"schemeCategory10"};if(this._scheme&&(z.indexOf(this._scheme)>=0?t.scheme=this._scheme:(W.indexOf(this._scheme)>=0||U.indexOf(this._scheme)>=0)&&(t.scheme=this._scheme,t.size=this.data.length)),this.scale=Xc("ordinalColor",t),this.scale.domain=this.data,this._mapping){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}}break;default:if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=Xc("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=Xc("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=Xc("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}}this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);"vertex"==e.type||"segment"==e.type?e[this.channel]=i:e.styles[this.channel]=i,e.vertices&&"strokeColor"==this.channel&&e.vertices.forEach((t=>t.fillColor=i))}},t.run()}(r);break;case"fillGradient":i.type===T.Area&&zt(r);break;case"angle":!function(t){t._query=function(){this.data=[],this.id2data={};let t=this.field,e=this.items;switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case A.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator)))}for(let t=0;t<this.data.length;t++)this.id2data[e[t].id]=this.data[t]},t._map=function(){this.scale||(this.scale=Xc("linear"),this.scale.domain=this.datatable.tree?[0,Math.max(...this.data)]:[0,this.data.reduce(((t,e)=>t+e),0)],this.scale._setRange([0,360]),this.scale._addEncoding(this))},t._apply=function(){let t;for(let e=0;e<this.items.length;e++)t=this.items[e],t.type!==T.Arc&&t.type!==T.Pie||t.adjustAngle(t.startAngle,Nt(t.startAngle+this.scale.map(this.data[e])));this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"text":!function(t){t._query=function(){this.data=[];let t,e,i=this.items;if(this.field.startsWith("parent.")||this.field.startsWith("child.")){e=this.datatable.tree.nodeTable,t=this.field.split(".")[1];let s=this.field.split(".")[0],n=i.map((t=>t.dataScope)).map((t=>t.getFieldValue(s)));e.getFieldType(t)==A.Integer||e.getFieldType(t)==A.Number?this.data=n.map((i=>new Pt(e).cross(o,i).aggregateNumericalField(t))):this.data=n.map((i=>new Pt(e).cross(o,i).getFieldValue(t)))}else e=this.datatable,t=this.field,e.getFieldType(t)==A.Integer||e.getFieldType(t)==A.Number?this.data=i.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator))):this.data=i.map((e=>e.dataScope.getFieldValue(t)))},t._map=function(){if(this.scale);else switch(this.datatable.getFieldType(this.field)){case A.Boolean:case A.Date:break;case A.String:default:this.scale=Xc("ordinal"),this.scale.domain=[...new Set(this.data)],this.scale._scale.range(this.scale.domain.map((t=>t+"")))}},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.text=i}},t.run()}(r);break;case"radialDistance":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case A.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t=this.data;this.scale||(this.scale=Xc("linear"),this.scale.domain=[0,Math.max(...t)],this.scale._setRange([0,this.anyItem.parent.radius])),this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]),s=Et(this.anyItem.parent.x,this.anyItem.parent.y,i,e.polarAngle);e.x=s[0],e.y=s[1]}this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"thickness":!function(t){t._query=function(){this.data={};let t=this.field,e=this.items,i=e.map((t=>t.dataScope));switch(this.datatable.getFieldType(t)){case A.Boolean:break;case A.Date:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t);break;case A.String:try{for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].aggregateNumericalField(t,this.aggregator)}},t._map=function(){let t=this.data;if(!this.scale){this.scale=Xc(this.scaleType),this.scale.domain=[0,Math.max(...Object.values(t))];let e=1,i=this.rangeExtent?e+this.rangeExtent:Math.max(...this.items.map((t=>t.outerRadius)));this.scale._setRange([e,i])}this.scale._addEncoding(this)},t._apply=function(){this.items.sort(((t,e)=>(t.innerRadius+t.outerRadius)/2-(e.innerRadius+e.outerRadius)/2));let t=Math.min(...this.items.map((t=>t.innerRadius))),e={item:new ce({outerRadius:t,startAngle:0,endAngle:360}),children:[]};for(let t of this.items)we(e,t);for(let t of e.children)ke(t,t.item.innerRadius,this.data,this.scale)},t.run()}(r)}return"_remember"in e&&1!=e._remember||this._registerBinding(r),s.indexOf("Color")<0&&this._updateAncestorBounds(i,r.items),r}_encodeWithinCollection(t,e){this._validateEncodeArgs(t,e);let i=function(t,e){let i={},s=nt(t,e);for(let t of s){let e=t.parent.id;e in i||(i[e]=[]),i[e].push(t)}return Object.keys(i).map((t=>i[t]))}(t,this),s=[];for(let t of i){let i=this._doEncode(t,e);s.push(i)}return s}getPeers(t){return nt(t,this)}find(t){return et(this,t)}align(t,e){if(!function(t,e,i){if(e==C.Top||e==C.Bottom||e==C.Middle){for(let e of t)if(!xt(e,i))return!1;return!0}if(e==C.Left||e==C.Right||e==C.Center){for(let e of t)if(!bt(e,i))return!1;return!0}}(t,e,this))return!1;let i=new ae(t,e);if(i.id in this.constraints)return console.warn("constraint has been added"),!1;this.constraints[i.id]=i,i.apply(),this._updateAncestorBounds(t[0])}removeAllConstraints(){this.constraints={}}removeConstraint(t){delete this.constraints[t.id]}getRelatedConstraints(t){let e=[];for(let i in this.constraints){let s=this.constraints[i];switch(s.type){case S:s._itemIds===t.map((t=>t.classId)).sort().join("_")&&e.push(s)}}return e}affix(t,e,i,s){let n=s||{},r="offset"in n?n.offset:0,a="itemAnchor"in n?n.itemAnchor:"x"==i||"angle"==i?"center":"middle",o="baseAnchor"in n?n.baseAnchor:"x"==i||"angle"==i?"center":"middle",h=new oe(t,e,this,i,a,o,r);h.id,this.constraints,this.constraints[h.id]=h,h.apply()}axis(t,e,i){let s=i||{},n=s.item?this.getEncodingByItem(s.item,t):this.getEncodingByField(e,t);if(n&&n.field===e){if(n.datatable.getFieldType(e)!==A.Date||"labelFormat"in s||(s.labelFormat="%m/%d/%y"),"width"===n.channel){let t=this.children.filter((t=>t.type===T.Axis)).map((t=>t.channel));"orientation"in s||(s.orientation=t.indexOf("x")>=0?"top":"bottom")}else if("height"===n.channel){let t=this.children.filter((t=>t.type===T.Axis)).map((t=>t.channel));"orientation"in s||(s.orientation=t.indexOf("y")>=0?"right":"left")}let t=new Qt(n,s.item?s.item:n.anyItem,s);return"tickValues"in s?(t.tickValues=s.tickValues,t.labelValues=s.tickValues):(t.tickValues=n._inferTickValues(),t.labelValues=n._inferTickValues()),this.addChildAt(t,0),this._itemMap[t.id]=t,this._updateBounds(),t}let r=s.item?s.item:et(this,[{field:e}])[0];if(void 0===r)return void console.warn(j+e);let a=rt(r);if(a&&(a.type===y.Grid||a.type===y.Stack)){if(a&&("x"==t||"y"==t)){let i,n,r=nt(a.group,this);for(let a of r){let r=et(a,[{field:e}])[0],o=nt(r,a);r.dataScope.dataTable.getFieldType(e)!==A.Date||"labelFormat"in s||(s.labelFormat="%m/%d/%y"),i=new te(o,a.layout,t,e,s),null==n&&(n=i.id),i.classId=n,this.addChildAt(i,0),this._itemMap[i.id]=i}return this._updateBounds(),i}console.warn(j+e)}}getRelatedAxes(t){let e=[];if(_t(t))return e;for(let i of this.children){if(i.type!==T.Axis)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===ct(t).split("_")[0]){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ft(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}removeItem(t){if(!_t(t)){let e=this.getRelatedEncodings(t);for(let t of e)this.removeEncoding(t);let i=this.getRelatedAxes(t);for(let t of i)this.removeItem(t);for(let e of this.getRelatedGridlines(t))this.removeItem(e)}delete this._itemMap[t.id],this.removeChild(t),this._updateBounds()}getRelatedEncodings(t){let e=[],i=t;for(;i;)if(e.push(ct(i)),i.type==T.Collection)i=i.firstChild;else if(i.type==T.Glyph){for(let t of i.children)e.push(ct(t));i=void 0}else i=void 0;let s=Object.keys(this.encodings),n=[];for(let t of s){let i=t.split("_")[0];if(e.indexOf(i)>=0)for(let e in this.encodings[t])n.push(this.encodings[t][e])}return n}removeAllEncodings(){this.encodings={},this.removeAllItemsByType(T.Axis),this.removeAllItemsByType(T.Legend),this.removeAllItemsByType(T.Gridlines)}removeEncoding(t){let e=ct(t.anyItem);delete this.encodings[e][t.channel],0===Object.keys(this.encodings[e]).length&&delete this.encodings[e];let i=[];for(let e of this.children)_t(e)&&e.encoding&&e.encoding===t&&i.push(e);for(let t of i)this.removeItem(t);this._updateBounds()}removeAllItemsByType(t){let e=[];for(let i of this.children)i.type===t&&e.push(i);for(let t of e)this.removeItem(t);this._updateBounds()}reCreateRelatedAxes(t){let e=this.getRelatedAxes(t),i=[];e.forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),delete e.tickValues,delete e.labelValues,this.removeItem(t),t instanceof te?i.indexOf(t.classId)<0&&(this.axis(t.channel,t.field,e),i.push(t.classId)):this.axis(t.channel,t.field,e)})),this._updateBounds()}reCreateRelatedLegends(t){this.getRelatedLegends(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),this.removeItem(t),this.legend(t.channel,t.field,e)})),this._updateBounds()}legend(t,e,i){let s=i||{},n=this.getEncodingByField(e,t);if(!n)throw G.INCORRECT_LEGEND_INFO+e;"x"in s||(s.x=100),"y"in s||(s.y=100);let r=new ee(n,s);return this.addChild(r),this._itemMap[r.id]=r,this._updateBounds(),r}gridlines(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(!s)return!1;let r=new he(s,n.item?n.item:s.anyItem,n);return r.values="values"in n?n.values:s._inferTickValues(),this.addChildAt(r,0),this._itemMap[r.id]=r,this._updateBounds(),r}getRelatedLegends(t){let e=[];if(_t(t))return e;for(let i of this.children)i.type===T.Legend&&i.matches(t)&&e.push(i);return e}getRelatedGridlines(t){let e=[];if(_t(t))return e;for(let i of this.children){if(i.type!==T.Gridlines)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ft(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}propagate(t,e,...i){let s=nt(t,this);for(let t of s)t[e](...i)}getEncodingByItem(t,e){let i=this.encodings[ct(t)];return i&&i[e]?i[e]:null}getEncodingByField(t,e){for(let i in this.encodings){let s=this.encodings[i];if(s[e]&&s[e].field==t)return s[e]}return null}positionBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(!yt(t))return null;for(let i in this.encodings){if(i.split("_")[0]===t.classId&&e in this.encodings[i])return this.encodings[i][e]}}sizeBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(yt(t)){let i="width"===e||"height"===e||"radius"===e?["area"]:["width","height"],s="width"===e?["x"]:"height"===e?["y"]:["x","y"];for(let e in this.encodings){let n=e.split("_")[0];if(e.indexOf("_")<0){for(let s of i)if(n===t.classId&&s in this.encodings[e])return this.encodings[e][s]}else for(let i of s)if(n===t.classId&&i in this.encodings[e])return this.encodings[e][i]}}return null}setProperties(t,e){let i,s={};for(let t in e)s[t]=!0;if(Object.values(y).indexOf(t.type)>-1&&t.group){i=nt(t.group,this);for(let t of i)for(let i in e)t.layout[i]=e[i]}else if(i=nt(t,this),"vertex"===t.type)for(let t of i)for(let i in e)t[i]=e[i];else if(t instanceof H)for(let n in e)if("x"!==n&&"y"!==n||!this.positionBound(t,n))if("width"!==n&&"height"!==n&&"radius"!==n||!this.sizeBound(t,n))t.type!==T.Rect&&t.type!==T.Line||"width"!==n&&"height"!==n?t.type==T.Circle&&"radius"==n?i.forEach((t=>t.resize(2*e[n],2*e[n],e.xRef,e.yRef))):i.forEach((t=>t[n]=e[n])):"width"===n?i.forEach((t=>t.resize(e[n],t.bounds.height,e.xRef))):i.forEach((t=>t.resize(t.bounds.width,e[n],void 0,e.yRef)));else{let i=this.getEncodingByItem(t,n);i||"radius"!=n||(i=this.getEncodingByItem(t,"area"));let s=i.scale.rangeExtent*e[n]/t[n];i.scale.rangeExtent=s}else s[n]=!1;else if("collection"==t.type||"group"==t.type)for(let t of i)for(let i in e)t[i]="layout"===i&&void 0!==e[i]?e[i].clone():e[i];let n=Object.keys(s).filter((t=>s[t])),r=["width","height","fontSize","area","radius"];for(let e of r)if(n.indexOf(e)>=0&&mt(t)){me(t,i);break}n.indexOf("baseline")>=0&&t.type===T.Area&&be(t,i);let a=["layout","rowGap","colGap","numRows","numCols","orientation","vertCellAlignment","horzCellAlignment","direction","childrenOrder"],o=n.filter((t=>a.indexOf(t)>=0));return o.length>0&&pe(i[0],i,o),s}_canTranslate(t){let e={x:!0,y:!0};return t.type==T.Axis?("x"===t.channel||"width"===t.channel?e.x=!1:"y"!==t.channel&&"height"!==t.channel||(e.y=!1),e):(t.parent.type===T.Collection&&t.parent.layout&&(e.x=!1,e.y=!1),this.positionBound(t,"x")&&(e.x=!1),this.positionBound(t,"y")&&(e.y=!1),e)}translate(t,e,i){let s=this._canTranslate(t);if(!s.x&&!s.y)return s;const n=s.x?e:0,r=s.y?i:0;return t._doTranslate(n,r),this._updateAncestorBounds(t),fe(t,n,r),s}_updateAncestorBounds(t,e){let i=ut(e||nt(t,this));for(;i.length>0;){for(let t of i)(t.children&&t.children.length>0||t.vertices)&&t._updateBounds();i=ut(i)}}_reapplyConstraints(t){let e=t,i=[t];for(;e.children;)e.type==T.Collection?i.push(e.firstChild):i=i.concat(e.children),e=e.firstChild;for(e=t.parent;e&&e.type!==T.Scene;)i.push(e),e=e.parent;const s=i.map((t=>t.classId));for(let t in this.constraints){const e=this.constraints[t];switch(e.type){case E:(s.indexOf(e.item.classId)>=0||s.indexOf(e.baseItem.classId)>=0)&&e.apply();break;case S:for(let t of e.items)if(s.indexOf(t.classId)>=0){e.apply();break}}}}_relayoutAncestors(t,e){let i=ut(e||nt(t,this));for(;i.length>0;){for(let t of i)t.layout&&t.layout.run(),t.children&&t.children.length>0&&t._updateBounds(),t.vertices&&t._updateBounds();i=ut(i)}}_reapplySizeBindings(t){let e=["width","height"];for(let i in this.encodings){if(t.classId!=i)continue;let s=this.encodings[i],n=et(this,[{classId:i}]);for(let t of e){let e=s[t];e&&e.run()}this._relayoutAncestors(n[0],n)}}_registerBinding(t){let e=this.encodings,i=ct(t.anyItem);return i in e||(e[i]={}),e[i][t.channel]=t,!0}toJSON(){let t=super.toJSON();this.fillColor&&(t.fillColor=this.fillColor);let e={};t.encodings=[],t.itemCounter=vt;for(let i in this.encodings)for(let s in this.encodings[i]){let n=this.encodings[i][s];t.encodings.push(n.toJSON()),n.scale&&!(n.scale.id in e)&&(e[n.scale.id]=n.scale.toJSON())}t.scales=e,t.constraints={};for(let e in this.constraints)t.constraints[e]=this.constraints[e].toJSON();t.tables={};let i=this.getDataTables();for(let e in i)t.tables[e]=i[e].toJSON();return t}getDataTables(){let t={};for(let e in this.encodings)for(let i in this.encodings[e]){let s=this.encodings[e][i];s.datatable.id in t||(t[s.datatable.id]=s.datatable)}for(let e of this.children)if(!_t(e)){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}if(e.children&&e.children.length>0){let i=e.firstChild;for(;i;){if(i.dataScope){t[i.dataScope.dataTable.id]=i.dataScope.dataTable;break}i=i.children&&i.children.length>0?i.firstChild:void 0}}}return t}getItem(t){let e=t.split("_")[0];if(t.indexOf("_v_")>0){let i=parseInt(t.split("_v_")[1]);return this._itemMap[e].vertices.find((t=>t._id===i))}if(t.indexOf("_s_")>0){let i=parseInt(t.split("_s_")[1]);return this._itemMap[e].segments.find((t=>t._id===i))}return this._itemMap[t]}addInteraction(t,e,i,s){let n=new Ae(t,e,i,s);this._interactions.push(n)}}class Oe{constructor(t){this._renderer=t,this._globalPredicates={}}processInteraction(t,e){let i=t.listener;if(mt(i)){let s=i.classId?"."+i.classId:"#"+i.id;switch(t.eventType){case"hover":n.selectAll(s).on("mouseover",t.getCallbackFunction(e,this)),n.selectAll(s).on("mouseleave",t.getRestoreFunction(e,this));break;case"click":n.selectAll(s).on("mousedown",t.getCallbackFunction(e,this))}}else if(i.type==T.Scene){if(!t.targetDef||!t.targetDef.item)return;t.selectionDef.item||n.select("#"+this._renderer._svgId).on("mousedown",t.getRestoreFunction(e,this,!0))}}_getSelection(t,e,i,s){let n={};s?n.item=s:e.item;let r=e.field?e.field:h;return n.item&&(n.predicate={field:r,value:n.item.dataScope.getFieldValue(r)}),n}addGlobalPredicate(t,e){t.id in this._globalPredicates||(this._globalPredicates[t.id]={}),this._globalPredicates[t.id][e.field]=e}getGlobalPredicates(t){return t.id in this._globalPredicates?Object.values(this._globalPredicates[t.id]):[]}}class Re{constructor(t){this._svgId=t,this._compMap={},this._decoMap={},this._interactionHandler=new Oe(this)}render(t,e){let i=e||{};for(let t in this._decoMap)this._decoMap[t].remove(),delete this._decoMap[t];this._removed={};for(let t in this._compMap)this._removed[t]=1;this._renderItem(t,i);for(let t in this._removed)this._compMap[t].remove(),delete this._compMap[t];if(!("visualOnly"in i))for(let e of t._interactions)this._interactionHandler.processInteraction(e,t)}clear(){let t=document.getElementById(this._svgId);for(;t.firstChild;)t.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(t,e){let i,s=t.id,r=t.parent;i=r&&r.id&&r.id in this._compMap?n.select("#"+this._svgId).select("#"+r.id):n.select("#"+this._svgId),s in this._compMap?delete this._removed[s]:this._compMap[s]=i.append(this._getSVGElementType(t)),t.type==T.Gridlines&&this._compMap[s].lower();let a=this._compMap[s];if(a.attr("id",s),t.classId&&a.attr("class",t.classId),t.type==T.Scene&&n.select("#"+this._svgId).style("background",t.fillColor?t.fillColor:"#fff"),"vertex"!=t.type){if(t.type==T.Path||t.type==T.Polygon||t.type==T.Link)a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==T.Line)a.attr("x1",t.vertices[0].x),a.attr("y1",t.vertices[0].y),a.attr("x2",t.vertices[1].x),a.attr("y2",t.vertices[1].y),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==T.Circle)a.attr("cx",t.x),a.attr("cy",t.y),a.attr("r",t.radius);else if(t.type==T.Rect){let e=t.bounds;a.attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height)}else t.type==T.PointText?a.attr("text-anchor",this._getTextAnchor(t.anchor[0])).attr("alignment-baseline",this._getTextAnchor(t.anchor[1])).attr("dominant-baseline",this._getTextAnchor(t.anchor[1])).text(t.text).attr("x",t.x).attr("y",t.y):t.type==T.Pie||t.type==T.Area?(a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges")):t.type==T.Ring||t.type==T.Arc?a.attr("d",t.getSVGPathData()):t.type==T.Image&&a.attr("href",t.src).attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height);for(let e in t.styles)if(void 0!==t.styles[e])if(e.indexOf("Color")>0&&t.styles[e].type==T.LinearGradient){n.select("#"+this._svgId).select("defs").empty()&&n.select("#"+this._svgId).append("defs");let i=n.select("defs"),s=t.styles[e];if(i.select("#"+s.id).empty()){let t=i.append("linearGradient").attr("id",s.id);t.attr("x1",s.x1+"%").attr("x2",s.x2+"%").attr("y1",s.y1+"%").attr("y2",s.y2+"%");for(let e of s.stops)t.append("stop").attr("offset",e.offset+"%").style("stop-color",e.color).style("stop-opacity",e.opacity)}a.style(D[e],"url(#"+s.id+")")}else a.style(D[e],t.styles[e]);if(t._rotate&&a.attr("transform","rotate("+t._rotate.join(" ")+")"),t.vertices&&this._renderVertices(t),t.type==T.Collection&&e&&e.collectionBounds){let e=t.bounds;t.layout&&"grid"==t.layout.type?this._renderLayout(t):(t.id in this._decoMap||(this._decoMap[t.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[t.id].attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("fill","none").attr("stroke","#1ecb40").attr("stroke-width","2px").attr("stroke-dasharray","5,5"))}if(t.children)for(let i of t.children)this._renderItem(i,e)}}_renderVertices(t){let e=t.id+"-vertices";if(e in this._compMap)delete this._removed[e];else{let i=t.parent,s=i?i.id:this._svgId;this._compMap[e]=n.select("#"+s).append("g").attr("id",e)}if(0===t.vertices.map((t=>t.shape)).filter((t=>void 0!==t)).length)return void this._compMap[e].style("visible","hidden");this._compMap[e].style("visible","visible");let i=t.vertices.filter((t=>void 0!==t.shape));for(let t of i){let i=e+"-"+t.id;i in this._compMap?t.shape!==this._compMap[i].node().tagName?(this._compMap[i].remove(),this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),delete this._removed[i]):delete this._removed[i]:this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),"rect"==t.shape?n.select("#"+i).attr("x",t.x-t.width/2).attr("y",t.y-t.height/2).attr("width",t.width).attr("height",t.height):"circle"==t.shape&&n.select("#"+i).attr("cx",t.x).attr("cy",t.y).attr("r",t.radius),n.select("#"+i).style("fill",t.fillColor).style("opacity",t.opacity).style("stroke-width",t.strokeWidth).style("stroke",t.strokeColor)}}_renderLayout(t){let e=t.id+"-grid";e in this._decoMap||(this._decoMap[e]=n.select("#"+this._svgId).append("g").attr("id",e).attr("class","deco"));let i=t.layout.cellBounds,s=t.layout.rowGap;this._decoMap[e].selectAll("rect").remove(),this._decoMap[e].selectAll("rect").data(i.slice(0,i.length-1)).enter().append("rect").attr("x",(t=>t.left)).attr("y",(t=>t.bottom)).attr("width",(t=>t.width)).attr("height",s).style("fill","pink").style("opacity",.5);let r=Math.min(...i.map((t=>t.left))),a=Math.min(...i.map((t=>t.top)));this._decoMap[e].append("rect").attr("x",r).attr("y",a).attr("width",t.bounds.width).attr("height",t.bounds.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getTextAnchor(t){switch(t){case"top":return"text-before-edge";case"bottom":return"text-after-edge";case"left":return"start";case"right":return"end";case"center":case"middle":return"middle";default:return t}}_getSVGElementType(t){switch(t.type){case T.Rect:return"rect";case T.Collection:case T.Group:case T.Glyph:case T.Scene:case T.Axis:case T.Legend:case T.Gridlines:return"g";case T.Area:case T.Path:case T.Polygon:case T.Ring:case T.Pie:case T.Arc:case T.Link:return"path";case T.Circle:return"circle";case T.Line:return"line";case T.PointText:return"text";case"vertex":if("circle"==t.shape)return"circle";if("rect"==t.shape)return"rect";throw"argument exception";case"image":return"image"}}}class Me{constructor(t,e){switch(this._type=t,this._offset=void 0,this.id="scale"+vt.scale++,this._flipped=!1,this._includeZero=!1,t){case"linear":if(e){let t=Object.keys(e).map((t=>parseFloat(t))).sort(((t,e)=>t-e)),i=t.map((t=>e[t]));this._scale=n.scaleLinear(t,i),"clamp"in e&&this._scale.clamp(e.clamp),this._mapping=e}else this._scale=n.scaleLinear();break;case"point":this._scale=n.scalePoint();break;case"ordinal":this._scale=n.scaleOrdinal();break;case"ordinalColor":this._scale=n.scaleOrdinal(e?e.size?n[e.scheme][e.size]:n[e.scheme]:n.schemeCategory10);break;case"power":this._scale=n.scalePow().exponent(2);break;case"sqrt":this._scale=n.scalePow().exponent(.5);break;case"log":this._scale=n.scaleLog();break;case"identity":case"time":this._scale=n.scaleTime();break;case"sequentialColor":case"divergingColor":e&&"string"==typeof e?(this._scale=n.scaleSequential(n[e]),this._scheme=e):this._scale=n.scaleSequential()}this.encodings=[]}set scheme(t){if(this._type.indexOf("Color")<0&&"linear"!==this._type)return;let e=n.scaleSequential(n[t]),i=this._scale.domain();if(Math.min(...i)*Math.max(...i)<0){let t=Math.max(Math.abs(Math.min(...i)),Math.abs(Math.max(...i)));i=[-t,t]}e.domain(i),this._scheme=t,this._scale=e,"linear"===this._type&&(this._type=this._scale.domain()[0]*this._scale.domain()[1]<0?"divergingColor":"sequentialColor",this._mapping&&(this._mapping=void 0));for(let e of this.encodings)e._mapping&&(e._mapping=void 0),e._scheme=t,e._apply()}get scheme(){return this._scheme}get type(){return this._type}set type(t){let e;switch(t){case"linear":e=n.scaleLinear();break;case"power":e=n.scalePow().exponent(2);break;case"sqrt":e=n.scalePow().exponent(.5);break;case"log":e=n.scaleLog()}if(e){this._type=t,e.domain(this._scale.domain()).range(this._scale.range()),this._scale=e;for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}else console.warn(V+t)}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.offset=this._offset,this._scheme&&(t.scheme=this._scheme),t.domain=this._scale.domain(),t.range=this.range,t.clamp=this.clamp,t.isFlipped=this.isFlipped,t.includeZero=this.includeZero,this._mapping&&(t.mapping=this._mapping),this._baseItem&&(t.baseItem=this._baseItem.id),t}_merge(t){if(this.type!=t.type)throw G.DIFFERENT_SCALE_TYPE;let e,i;switch(this.type){case"linear":case"time":e=[Math.min(this.domain[0],t.domain[0]),Math.max(this.domain[1],t.domain[1])],i=[0,this.map(e[1])-this.map(e[0])];break;case"point":case"ordinalColor":e=[...new Set(this.domain.concat(t.domain))],i=[];break;default:console.log("TODO: merge scale type",this.type)}this._scale.domain(e),this._scale.range(i)}get domain(){if(this._includeZero){return[0,this._scale.domain()[1]]}return this._scale.domain()}set domain(t){this._scale.domain(t);for(let t of this.encodings)t._apply()}get range(){return this._scale.range()}
3
3
  //to support this, the argument should be in real screen coordinates and need to do internal conversion
4
- set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}_setRange(t){this._scale.range(t),pe(this)}get clamp(){return"linear"==this.type&&this._scale.clamp()}set clamp(t){"linear"==this.type&&this._scale.clamp(t)}set rangeExtent(t){let e=this._scale.range();this._setRange([e[0],e[0]+t])}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}_addEncoding(t){this.encodings.indexOf(t)<0&&this.encodings.push(t)}map(t){let e=this._scale.copy();return e.domain(this.domain),this._flipped?(e.range(this._scale.range().reverse()),e(t)):e(t)}invert(t){return this._scale.invert(t)}get offset(){return this._offset}set offset(t){this._offset=t;for(let t of this.encodings)t._apply()}get isFlipped(){return this._flipped}set isFlipped(t){this._flipped=t}get includeZero(){return this._includeZero}set includeZero(t){this._includeZero=t,fe(this)}get mapping(){return this._mapping}getEncodedChannels(){let t={};for(let e of this.encodings)t[e.channel]=!0;return Object.keys(t)}}class Re extends q{constructor(t){super(t),this.type="packing",this.x="x"in t?t.x:400,this.y="y"in t?t.y:400,this.width=t.width,this.height=t.height}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this.x,t.args.y=this.y,t.args.width=this.width,t.args.height=this.height,t}clone(){return new Re({x:this.x,y:this.y,width:this.width,height:this.height})}run(){if(null==this.group)return;let t=this.group.children.map((t=>({name:t.id,radius:t.radius,itm:t}))),e=t.reduce(((t,e)=>t+Math.pow(e.radius,2)),0),i=Math.sqrt(e);void 0===this.width&&(this.width=i),void 0===this.height&&(this.height=i);let s=n.hierarchy({name:"root",children:t}).sum((t=>t.radius?t.radius:0)).sort(((t,e)=>e.value-t.value));n.pack().size([this.width,this.height]).radius((t=>t.value))(s);for(let t of s.children){let e=t.data.itm,i=this.x-s.x+t.x-e.x,n=this.y-s.y+t.y-e.y;e._doTranslate(i,n)}this.group._updateBounds()}}class Me extends q{constructor(t){super(t),this.type="treemap",this._width=t.width,this._height=t.height,this._top=t.top,this._left=t.left}toJSON(){let t={args:{}};return t.type=this.type,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}clone(){return new Me({})}run(){if(null==this.group||!this.group.children||0==this.group.children.length)return;let t=this._width?this._width:this.group.bounds.width,e=this._height?this._height:this.group.bounds.height,i=void 0===this._top?this.group.bounds.top:this._top,s=void 0===this._left?this.group.bounds.left:this._left,r=n.hierarchy(this.group).sum((t=>"rect"==t.type?t.bounds.width*t.bounds.height:0));n.treemap().size([t,e])(r),this._apply(r,s,i),this.group.getScene()._updateAncestorBounds(r.leaves()[0].data)}_apply(t,e,i){if("collection"==t.data.type&&t.children)for(let s of t.children)this._apply(s,e,i);else"rect"==t.data.type&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),t.data._doTranslate(t.x0+e-t.data.bounds.left,t.y0+i-t.data.bounds.top))}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get top(){return this._top}set top(t){this._top=t,this.run()}get left(){return this._left}set left(t){this._left=t,this.run()}}function Ne(t,e){let i=[t[0]],s=[e[0]];for(let n=1;n<e.length;n++){let r=!1,a=e[n];for(let e=0;e<s.length;e++){let o=s[e],h=new Set(a);if(o.forEach((t=>h.add(t))),h.size<a.length+o.length){s[e]=[...h],i[e]=i[e].concat(t[n]),r=!0;break}}r||(s.push(a),i.push(t[n]))}return{grouping:i,subgraphs:s}}class Pe{constructor(t,e){this._type="network",this._nodeTable=new qt(t.nodes,"nodes"),this._linkTable=new qt(t.links,"links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._nodes=t.nodes,this._links=t.links,this._name=e,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e.id]=e}get type(){return this._type}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodes(){return this._nodes}get links(){return this._links}getNode(t){return this._nodeHash[t]}getSources(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].target==i){e=s[t].source;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}getTargets(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].source==i){e=s[t].target;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}transform(t,e,i){switch(t){case"partition":return function(t){let e=t.nodes,i=t.links,s=i.map(((t,e)=>[e])),n=i.map((t=>[t.source,t.target])),r=Ne(s,n);for(;r.grouping.length!=s.length;)s=r.grouping,n=r.subgraphs,r=Ne(s,n);let a=[];for(let[t,s]of r.grouping.entries()){let n={nodes:[],links:[]};n.links=s.map((t=>i[t]));const o=r.subgraphs[t];n.nodes=e.filter((t=>o.indexOf(t.id)>=0)),a.push(new Pe(n))}return a}(this)}}isLinear(){let t={},e={};for(let i of this._links)i.source in e||(e[i.source]=0),i.target in t||(t[i.target]=0),e[i.source]++,t[i.target]++;for(let e in t)if(t[e]>1)return!1;for(let t in e)if(e[t]>1)return!1;return!0}}class Fe extends q{constructor(t){super(t),this.type=y.TidyTree,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:b}toJSON(){let t={args:{}};return t.args.type=this.type,t.args.orientation=this._orientation,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt;if(!t.tree)throw G.LAYOUT_WITHOUT_TREE;{let e=n.hierarchy(t.tree._data),i=Math.max(...this.group.children.map((t=>t.bounds.width))),s=Math.max(...this.group.children.map((t=>t.bounds.height))),r=this._orientation==b?[this._height,this._width]:[this._width,this._height],a=n.tree().nodeSize([i,s]).size(r)(e);this._apply(a,this.group)}}_apply(t,e){let i,s,n=e.children.filter((e=>e.dataScope.getFieldValue(o)==t.data.id))[0];switch(this._orientation){case b:i=t.y+this._left,s=t.x+this._top;break;case v:i=t.x+this._left,s=this._top+t.y}if(n.x=i,n.y=s,t.children&&t.children.length>0)for(let i of t.children)this._apply(i,e)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get size(){return[this._width,this._height]}set size(t){this._width=t[0],this._height=t[1],this.run()}}class Be extends q{constructor(t){super(t),this.type=y.Force,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this._x,t.args.y=this._y,t.args.iterations=this._iterations,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt.graph;if(t){let e=t.links.map((e=>({source:t.getNode(e.source),target:t.getNode(e.target)}))),i=n.forceSimulation(t.nodes).force("charge",n.forceManyBody().strength(-this._repulsion)).force("link",n.forceLink(e).id((t=>t.id)).distance(this._linkDistance)).force("x",n.forceX()).force("y",n.forceY()).force("center",n.forceCenter(this._x,this._y).strength(this._attraction));i.stop(),i.tick(this._iterations);for(let e=0;e<this.group.children.length;e++)this.group.children[e].x=t.nodes[e].x,this.group.children[e].y=t.nodes[e].y}}}class Le{constructor(){this.axes={},this.guideCmds=[],this.collectionCmds=[],this.glyphCmds=[],this.spec=[]}run(t){for(let e of t.children)switch(e.type){case T.Axis:{let t=e.classId?e.classId:e.id;this.axes[t]=e;break}case T.Gridlines:case T.Legend:{let t=e.toJSON();this.guideCmds.push({cmd:e.type,channel:t.channel,field:t.field,args:t.args});break}case T.Collection:case T.Group:case T.Glyph:{let i=[];this._analyze(e,i);for(let t=i.length-1;t>0;t--)for(let e of i[t].fields)i[t-1].fields.delete(e);for(let[e,s]of i.entries()){if(s.item instanceof H){let e={cmd:"mark",type:s.item.type,output:s.item,args:s.item.toJSON().args};this._inferMarkArgs(e,t),this.collectionCmds.push(e)}else if(s.item instanceof te)this.collectionCmds.push({cmd:"glyph",output:s.item,input:i.slice(0,e).map((t=>t.item)),args:{}});else if(s.item instanceof oe){let t=[...i[e-1].fields][0],n={cmd:"join",input:i[e-1].item,output:s.item,data:i[e-1].item.dataScope.dataTable.id,args:{field:t}};t==h&&delete n.field,this.collectionCmds.push(n)}s.item.dataScope&&0==s.item.dataScope.fields.length&&!s.item.parent.dataScope&&this.collectionCmds.push({cmd:"attach",input:s.item,data:s.item.dataScope.dataTable.id})}break}default:if(e instanceof H){let i={cmd:"mark",type:e.type,output:e,args:e.toJSON().args};this._inferMarkArgs(i,t),this.glyphCmds.push(i)}}this._inferJoin(),this._inferArgs(t);for(let t in this.axes){let e=this.axes[t].toJSON();this.guideCmds.push({cmd:e.type,channel:e.channel,field:e.field,args:e.args})}return this._generateFullSpec(t),this.spec}_inferJoin(){for(let t of this.collectionCmds){if("join"!=t.cmd)continue;let e=t.input,i=e.parent;switch(e.type){case T.Rect:i.layout&&i.layout.type==y.Stack?t.cmd="divide":t.cmd="repeat";break;default:t.cmd="repeat"}}}_inferArgs(t){for(let e of this.collectionCmds)switch(e.cmd){case"mark":this._inferMarkArgs(e,t);break;case"divide":this._inferDivideArgs(e,t)}}_inferDivideArgs(t){t.args.orientation=t.output.layout.orientation}_inferMarkArgs(t,e){let i=t.output,s=i.parent,n=nt(i,e),r=nt(s,e);switch(i.type){case T.Rect:s.layout&&s.layout.type==y.Grid?(t.args.width=s.layout.cellBounds[0].width,t.args.height=s.layout.cellBounds[0].height):s.layout&&s.layout.type==y.Stack?(t.args.width=Math.max(...r.map((t=>t.bounds.width))),t.args.height=Math.max(...r.map((t=>t.bounds.height)))):(t.args.width=Math.max(...n.map((t=>t.bounds.width))),t.args.height=Math.max(...n.map((t=>t.bounds.height)))),t.args.left=Math.min(...n.map((t=>t.bounds.left))),t.args.top=Math.min(...n.map((t=>t.bounds.top)));break;case T.Line:t.args.x1=Math.min(...n.map((t=>t.vertices[0].x))),t.args.y1=Math.min(...n.map((t=>t.vertices[0].y))),t.args.x2=Math.min(...n.map((t=>t.vertices[1].x))),t.args.y2=Math.min(...n.map((t=>t.vertices[1].y)));break;case T.Arc:t.args.x=i.x,t.args.y=i.y,t.args.innerRadius=i.innerRadius,t.args.outerRadius=i.outerRadius}for(let e in i.styles)t.args[e]=i.styles[e]}_analyze(t,e){if(t instanceof te)for(let i of t.children)this._analyze(i,e);else t instanceof At&&this._analyze(t.firstChild,e);let i={type:t.type,item:t};t.dataScope?i.fields=new Set(t.dataScope.fields):i.fields=new Set,e.push(i)}_generateFullSpec(t){this.spec=[],this.spec.push({cmd:"scene",args:{fillColor:t.fillColor}});let e=t.getDataTables(),i={},s=[];for(let t in e){let n=e[t];if(n.sourceDataTable)for(;n.sourceDataTable;)s.push({cmd:"transform",type:n.transform.type,args:n.transform.args,input:n.sourceDataTable.id,output:n.id}),n=n.sourceDataTable;n.id in i||(i[n.id]={cmd:"data",url:n.url,output:n.id})}this.spec=this.spec.concat(Object.values(i)),this.spec=this.spec.concat(s);let n=[];for(let t of this.collectionCmds){let e;t.output&&t.output.layout&&(e={cmd:"layout",type:t.output.layout.type,input:t.output.id,args:t.output.layout.toJSON().args}),this.spec.push(t),t.output&&t.output.childrenOrder&&n.push({cmd:"sortChildren",args:t.output.childrenOrder,input:t.output.id}),e&&this.spec.push(e),t.input&&Array.isArray(t.input)?t.input=t.input.map((t=>t.classId?t.classId:t.id)):t.input&&(t.input=t.input.classId?t.input.classId:t.input.id),t.output&&(t.output=t.output.classId?t.output.classId:t.output.id)}let r={},a=[];for(let e in t.encodings)for(let i in t.encodings[e]){let s=t.encodings[e][i];s.scale&&!(s.scale.id in r)&&(r[s.scale.id]=s.scale.toJSON());let n=s.toJSON().args;n.field=s.field,n.channel=s.channel,delete n.datatable,a.push({cmd:"encode",input:lt(s.anyItem),scale:s.scale.id,args:n})}for(let t in r){let e=r[t];e.cmd="scale",this.spec.push(e)}this.spec=this.spec.concat(a),this.spec=this.spec.concat(n);for(let e in t.constraints){let i=t.constraints[e],s={cmd:"constraint",type:i.type,args:{}};switch(i.type){case E:s.item=i.item.classId?i.item.classId:i.item.id,s.baseItem=i.baseItem.classId?i.baseItem.classId:i.baseItem.id,s.channel=i.channel,s.args.itemAnchor=i.itemAnchor,s.args.baseAnchor=i.baseAnchor,s.args.offset=i.offset;break;case S:s.items=i.items.map((t=>t.classId?t.classId:t.id)),s.anchor=i.anchor}this.spec.push(s)}for(let t of this.guideCmds)this.spec.push(t);for(let t of this.glyphCmds)t.output&&(t.output=t.output.classId?t.output.classId:t.output.id),this.spec.push(t)}}class De{constructor(){this.axes={},this.legends=[],this.gridlines=[],this.scales={},this.tables={}}load(t){let e={};if(t.fillColor&&(e.fillColor=t.fillColor),t.itemCounter)for(let e in t.itemCounter)mt[e]=t.itemCounter[e];let i=$c(e);if(i.id=t.id,i.type=t.type,t.bounds&&(i._bounds=new a(t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height)),t.tables)for(let e in t.tables)this.tables[e]=new qt(t.tables[e].data,t.tables[e].url,t.tables[e].fieldTypes),this.tables[e].id=t.tables[e].id;for(let e of t.children)this._processItem(i,e,i);if(t.scales)for(let e in t.scales)this._loadScale(t.scales[e],i);if(t.encodings)for(let e of t.encodings)this._loadEncoding(e,i);if(t.constraints)for(let e in t.constraints)this._loadConstraint(t.constraints[e],i);for(let t in this.axes)this._createGuide(i,this.axes[t]);for(let t of this.legends)this._createGuide(i,t);for(let t of this.gridlines)this._createGuide(i,t);return i}_loadScale(t){let e;t.type.indexOf("Color")>0&&t.scheme?e=Zc(t.type,t.scheme):(e=Zc(t.type),e.range=t.range),e.domain="time"==t.type?t.domain.map((t=>new Date(t))):t.domain,e.id=t.id,"offset"in t&&(e.offset=t.offset),e.isFlipped=t.isFlipped,e.clamp=t.clamp,e._mapping=t.mapping,"includeZero"in t&&(e.includeZero=t.includeZero),this.scales[e.id]=e}_loadEncoding(t,e){t.args.datatable&&(t.args.datatable=this.tables[t.args.datatable]),t.args.scale&&(t.args.scale=this.scales[t.args.scale]);let i=t.items.map((t=>e.getItem(t)));e._doEncode(i,t.args),e._relayoutAncestors(i[0],i)}_createGuide(t,e){switch(e.type){case T.Axis:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.axis(e.channel,e.field,e.args);break;case T.Legend:t.legend(e.channel,e.field,e.args);break;case T.Gridlines:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.gridlines(e.channel,e.field,e.args)}}_processItem(t,e,i){switch(e.type){case T.Axis:{let t=e.classId?e.classId:e.id;e.args.tickValues&&e.args.isDate&&(e.args.tickValues=e.args.tickValues.map((t=>new Date(t)))),this.axes[t]=e;break}case T.Gridlines:e.args.values&&e.args.isDate&&(e.args.values=e.args.values.map((t=>new Date(t)))),this.gridlines.push(e);break;case T.Legend:this.legends.push(e);break;case T.Collection:{let s=i.collection();t.addChild(s),this._loadGroup(s,e,i);break}case T.Group:{let s=i.group();t.addChild(s),this._loadGroup(s,e,i);break}case T.Glyph:{let s=i.glyph();t.addChild(s),this._loadGroup(s,e,i);break}default:this._loadMark(t,e,i)}}_loadConstraint(t,e){switch(t.type){case"affixation":{let i=e.getItem(t.item),s=e.getItem(t.baseItem),n=new re(i,s,e,t.channel,t.itemAnchor,t.baseAnchor,t.offset);return n.id=t.id,e.constraints[t.id]=n,n.apply(),n}case"alignment":{let i=t.items.map((t=>e.getItem(t))),s=new ne(i,t.direction);return s.id=t.id,e.constraints[t.id]=s,s.apply(),s}}}_loadDataScope(t){let e=new Mt(this.tables[t.dt]);for(let i in t.f2v)e._field2value[i]=t.f2v[i],e._updateTuples(i,t.f2v[i]);return e}_loadGroup(t,e,i){if(t.id=e.id,e.classId&&(t.classId=e.classId),e.dataScope&&(t.dataScope=this._loadDataScope(e.dataScope)),e.children)for(let s of e.children)this._processItem(t,s,i);if(e.layout){let i=this._loadLayout(e.layout);i.group=t,t._layout=i}e.bounds&&(t._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height))}_loadMark(t,e,i){if(e.args.fillColor&&"LinearGradient"===e.args.fillColor.type){let t=e.args.fillColor;e.args.fillColor=Xc(t),e.args.fillColor.id=t.id,e.args.fillColor._stops=t.stops}"id"in e&&(e.args.id=e.id);let s=i.mark(e.type,e.args);if(e.classId&&(s.classId=e.classId),e.dataScope&&(s.dataScope=this._loadDataScope(e.dataScope)),e.vertices){const t=[];for(let i of e.vertices){const e=K.fromJSON(i,s);e.dataScope&&(e.dataScope=this._loadDataScope(e.dataScope)),t.push(e)}s.vertices=t,s.segments=[];for(let t=1;t<s.vertices.length;t++)s.segments.push(new X(s.vertices[t-1],s.vertices[t],s,s.segmentCounter++))}e.bounds&&(s._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height)),e.boundsOffsets&&(s.boundsOffsets=e.boundsOffsets),_t(s)?(s.vertexCounter=e.vertexCounter,s.segmentCounter=e.segmentCounter,s.curveMode=e.curveMode):e.type===T.Image&&(s.src=e.src,s.width=e.width,s.height=e.height,s.x=e.x,s.y=e.y),t.addChild(s)}_loadLayout(t){let e=Kc(t.type,t.args);switch(t.type){case y.Grid:e._left=t.left,e._top=t.top}return e}}class je{constructor(){}async run(t){let e,i,s={},n={},r={};for(let a of t)switch(a.cmd){case"scene":e=$c(a.args);break;case"data":i=await td(a.url),n[a.output]=i;break;case"transform":n[a.output]=n[a.input].transform(a.type,a.args);break;case"mark":s[a.output]=e.mark(a.type,a.args);break;case"glyph":s[a.output]=e.glyph(...a.input.map((t=>s[t])));break;case"attach":e.attach(s[a.input],n[a.data]);break;case"repeat":{let t=e.repeat(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"divide":{let t=e.divide(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"layout":s[a.input].layout=Kc(a.type,a.args);break;case"sortChildren":"field"in a.args?s[a.input].sortChildrenByData(a.args.field,a.args.reverse,a.args.order):"channel"in a.args&&s[a.input].sortChildren(a.args.channel,a.args.reverse);break;case"scale":{let t=Zc(a.type);t.id=a.id,t.domain="time"==a.type?a.domain.map((t=>new Date(t))):a.domain,t.range=a.range,t.clamp=a.clamp,t.isFlipped=a.isFlipped,"offset"in a&&(t.offset=a.offset),r[t.id]=t;break}case"encode":let t,o=a.input;if(o.indexOf("_v_")>0){let e=parseInt(o.split("_v_")[1]);t=s[o.split("_v_")[0]].vertices[e]}else if(o.indexOf("_v")>0);else if(o.indexOf("_s_")>0){let e=parseInt(o.split("_s_")[1]);t=s[o.split("_s_")[0]].segments[e]}else o.indexOf("_s")>0||(t=s[a.input]);a.scale&&r[a.scale]&&(a.args.scale=r[a.scale]),e.encode(t,a.args);break;case"constraint":switch(a.type){case E:e.affix(s[a.item],s[a.baseItem],a.channel,a.args)}break;case"axis":e.axis(a.channel,a.field,a.args);break;case"legend":e.legend(a.channel,a.field,a.args);break;case"gridlines":e.gridlines(a.channel,a.field,a.args)}return e}}let Ve=Math.PI/180;class Ge{constructor(t){this._canvasId=t,this._doesCollectionHaveBounds=!1,this._app=new r.Application({antialias:!0,width:1600,height:1e3,view:document.getElementById(this._canvasId)}),this._app.renderer.autoResize=!0}render(t,e){let i=e||{};this._app.renderer.backgroundColor=Ue(t.fillColor?t.fillColor:"#fff"),this._doesCollectionHaveBounds=!!i.collectionBounds,this._app.stage.removeChildren(),this._app.renderer.clear();let s=this._renderItem(t);this._app.stage.addChild(s)}_renderItem(t){switch(t.type){case T.Ellipse:case T.LinearGradient:Je("mark",t,G.FEATURE_NOT_IMPLEMENTED);break;case T.Circle:return this._renderCircle(t);case T.Pie:return this._renderArc(t);case T.Area:return this._renderArea(t);case T.Polygon:return this._renderPolygon(t);case T.Axis:return this._renderAxis(t);case T.Collection:return this._renderCollection(t);case T.Glyph:case T.Group:case T.Gridlines:case T.Legend:case T.Scene:return this._renderGroup(t);case T.Path:return this._renderPath(t);case T.Line:return this._renderLinearPath(t);case T.Rect:return this._renderRectangle(t);case T.PointText:return this._renderText(t);case T.Arc:return this._renderArc(t);case T.Image:return this._renderImage(t);case T.Link:return this._renderLink(t);case T.Ring:return this._renderRing(t);default:throw console.log(t.type),new Error(`Expect: itemType, Actual: ${t}\nWait that's illegal`)}}_renderRectangle(t){let e=new i.Graphics;return ze(e,t.styles),e.lineStyle(t.styles.strokeWidth,Ue(t.styles.strokeColor)),He(t.styles,e,t.height),e.drawRect(0,0,t.width,t.height),e.x=t.left,e.y=t.top,e.endFill(),e}_renderText(t){let e=new i.TextStyle({fontSize:t.styles.fontSize,fontFamily:t.styles.fontFamily,fontWeight:We(t.styles.fontWeight),fill:Ue(t.styles.fillColor)}),s=new r.Text(t.text,e),n=new i.Container;ze(s,t.styles),s.x=t.x,s.y=t.y,s.anchor.set(...function(t){let e,i;switch(t[0]){case"left":e=0;break;case"center":e=.5;break;case"right":e=1;break;default:Je("x anchor",t[0],G.UNKNOWN_ANCHOR)}switch(t[1]){case"hanging":case"top":i=0;break;case"central":case"middle":i=.5;break;case"bottom":i=1;break;default:Je("y anchor",t[1],G.UNKNOWN_ANCHOR)}return[e,i]}(t.anchor)),n.addChild(s);let a=Ye(t._rotate);return n.pivot.set(a[0],a[1]),n.angle=qe(t._rotate),n.position.set(a[0],a[1]),n}_renderGroup(t){let e=new i.Container;for(const i of t.children){let t=this._renderItem(i);if(null==t)throw new Error;e.addChild(t)}return e}_renderAxis(t){let e=this._renderGroup(t),i=Ye(t._rotate);return e.pivot.set(i[0],i[1]),e.angle=qe(t._rotate),e.position.set(i[0],i[1]),e}_renderCollection(t){let e=new i.Container,s=this._renderGroup(t);if(e.addChild(s),!this._doesCollectionHaveBounds)return e;let n=new i.Graphics,r=0,a=t.bounds,o=a.left,h=a.right,l=a.top,c=a.bottom,d={strokeWidth:1,color:2018112,dashLength:5,dashSpacing:5};return r=u(o,h,l,r,d,n),r=u(l,c,-h,r,d,n),r=u(h,o,c,r,d,n),u(c,l,-o,r,d,n),e.addChild(n),e;function u(t,e,i,s,n,r){let a=t<=e?1:-1,o=s>=0?{point:t+s*a}:{point:t},h=i>0?[o,{point:i}]:[{point:-i},o];r.lineStyle({width:n.strokeWidth,color:n.color}),r.moveTo(h[0].point,h[1].point),o.point=s*a+t+n.dashLength*a,r.lineTo(h[0].point,h[1].point);let l=!1;for(o.point+=n.dashLength*a;o.point*a<=e*a;)l?(r.lineTo(h[0].point,h[1].point),l=!1,o.point+=n.dashSpacing*a):(r.moveTo(h[0].point,h[1].point),l=!0,o.point+=n.dashLength*a);return l?(i>0?r.lineTo(e,i):r.lineTo(-i,e),(e-o.point)*a):(o.point-e)*a}}_renderArea(t){switch(t.curveMode){case"linear":return this._renderPolygon(t);case"basis":return this._renderBezierArea(t);default:return Je("areaPath",t,G.FEATURE_NOT_IMPLEMENTED)}}_renderBezierArea(t){let e=new i.Graphics;ze(e,t.styles),e.lineStyle({width:t.styles.strokeWidth,color:Ue(t.styles.strokeColor)});let s=Xe(t.getSVGPathData());return He(t.styles,e,t.bounds.height),Ze(e,s),e.endFill(),e}_renderPolygon(t){let e=new r.Container,i=this._renderLinearPath(t);i.getChildAt(0).lineTo(t.vertices[0].x,t.vertices[0].y);let s=new r.Graphics;ze(s,t.styles);let n=[];for(const e of t.vertices)n.push(e.x-t.bounds.left),n.push(e.y-t.bounds.top);return He(t.styles,s,t.bounds.height),s.drawPolygon(n),s.x+=t.bounds.left,s.y+=t.bounds.top,s.endFill(),e.addChild(s),e.addChild(i),e}_renderPath(t){switch(t.curveMode){case"linear":return this._renderLinearPath(t);case"bumpX":case"natural":return this._renderBezierPath(t);default:Je("path",t,G.FEATURE_NOT_IMPLEMENTED)}}_renderLinearPath(t){let e=new i.Container,s=new i.Graphics,n="none"==t.styles.strokeDash;ze(s,t.styles);let r=t.vertices[0];if(s.lineStyle({width:t.styles.strokeWidth,color:Ue(t.styles.strokeColor)}),s.moveTo(r.x,r.y),n)for(let e=1;e<t.vertices.length;e++){const i=t.vertices[e];s.lineTo(i.x,i.y)}else!function(t,e,i){let s,n,r,a=0,o=0,h=e.split(" "),l=Number(h[0]),c=Number(h[1]);for(s=0;s<t.length&&(n=t[s],s!=t.length-1);s++){r=t[s+1];let e=r.x-n.x,h=r.y-n.y,d=Math.sqrt(e*e+h*h),u={x:e/d,y:h/d},f=0;for(i.moveTo(n.x+o*u.x,n.y+o*u.y);f<=d;)f+=o,f+=a>0?a:l,f>d?(a=f-d,f=d):a=0,i.lineTo(n.x+f*u.x,n.y+f*u.y),f+=c,f>d&&0==a?o=f-d:(o=0,i.moveTo(n.x+f*u.x,n.y+f*u.y))}}(t.vertices,t.styles.strokeDash,s);e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderBezierPath(t){let e=new i.Container,s=new i.Graphics;ze(s,t.styles),s.lineStyle({width:t.styles.strokeWidth,color:Ue(t.styles.strokeColor)}),Ze(s,Xe(t.getSVGPathData())),e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderVertex(t){switch(t.shape){case"rect":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:Ue(t.strokeColor)}),e.beginFill(Ue(t.fillColor)),e.drawRect(t.x-t.width/2,t.y-t.height/2,t.width,t.height),e.endFill(),e}(t);case"circle":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:Ue(t.strokeColor)}),e.beginFill(Ue(t.fillColor)),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}(t);case void 0:return null;default:Je("vertex shape",t.shape,G.FEATURE_NOT_IMPLEMENTED)}}_renderCircle(t){let e=new i.Graphics;return ze(e,t.styles),e.lineStyle(t.styles.strokeWidth,Ue(t.styles.strokeColor)),He(t.styles,e,t.height),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}_renderRing(t){let e=new i.Graphics;return e.lineStyle(t.outerRadius-t.innerRadius,Ue(t.styles.fillColor)),e.drawCircle(t.x,t.y,(t.innerRadius+t.outerRadius)/2),e.endFill(),e}_renderArc(t){let e=new i.Graphics;return e.lineStyle({color:Ue(t.styles.strokeColor),width:t.styles.strokeWidth}),e.beginFill(Ue(t.styles.fillColor)),e.arc(t.x,t.y,t.outerRadius,-t.endAngle*Ve,-t.startAngle*Ve),e.arc(t.x,t.y,t.innerRadius,-t.startAngle*Ve,-t.endAngle*Ve,!0),e.endFill(),e}_renderImage(t){let e=r.Sprite.from(t.src);return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}_renderLink(t){switch(t.curveMode){case"linear":return function(t){let e=new i.Graphics;return ze(e,t.styles),e.lineStyle({color:Ue(t.styles.strokeColor),width:t.styles.strokeWidth}),Ze(e,Xe(t.getSVGPathData())),e}(t);default:Je("link",t.curveMode,"unexpected curvemode")}}}function ze(t,e){t.visible=function(t){switch(t){case"hidden":return!1;case null:case void 0:case"visible":default:return!0}}(e.visibility),t.alpha=function(t){switch(t){case void 0:case null:return 1;default:return t}}(e.opacity)}function We(t){switch(t){case"regular":case"normal":return"normal";case"bold":return"bold";default:console.log(t),Je("font weight",t,G.FEATURE_NOT_IMPLEMENTED)}}function Ue(t){let e=n.color(t);if(null==e)return null;{let t=e.formatHex();return r.utils.string2hex(t)}}function qe(t){return void 0===t||"number"!=typeof t[0]?0:t[0]}function Ye(t){return void 0===t||"number"!=typeof t[0]?[0,0]:t.slice(1)}function Je(t,e,i){throw console.log(e),new Error(`${i}. Source: ${t}, Actual: `)}function He(t,e,i){let s=t.fillColor;if("none"==s)return;let n=Ue(s);null!=n?e.beginFill(n):e.beginTextureFill({color:16777215,texture:$e(i,s.stops,s.y1>s.y2)})}function $e(t,e,i){const s=document.createElement("canvas");s.height=t,s.width=1;const n=s.getContext("2d"),a=n.createLinearGradient(0,0,0,t);for(let t=0;t<e.length;t++)i?a.addColorStop(1-e[t].offset/100,e[t].color):a.addColorStop(e[t].offset/100,e[t].color);return n.fillStyle=a,n.fillRect(0,0,1,t),r.Texture.from(s)}function Ze(t,e){let i=e.pop(),s=()=>{};"Z"==i.code.toUpperCase()?s=()=>t.lineTo(e[0].end.x,e[0].end.y):e.push(i);for(const i of e)Ke(i,t);s()}function Ke(t,e){switch(t.code.toUpperCase()){case"M":e.moveTo(t.end.x,t.end.y);break;case"L":e.lineTo(t.end.x,t.end.y);break;case"Q":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp1.x,t.cp1.y,t.end.x,t.end.y);break;case"C":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.end.x,t.end.y);break;case"Z":throw new Error('Unexpected "z" marker. There\'s something wrong, I can feel it');default:return Je("data",t,G.FEATURE_NOT_IMPLEMENTED)}}function Xe(t){let e={command:/\s*([achlmqstvz])/gi,number:/\s*([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/gi,comma:/\s*(?:(,)|\s)/g,flag:/\s*([01])/g},i={number:function(t){return+a("number",t)},"coordinate pair":function(t){let e=a("number",t);return null!==e||t?(a("comma"),{x:+e,y:+a("number",!0)}):null},"arc definition":function(t){let e=i["coordinate pair"](t);if(!e&&!t)return null;a("comma");let s=+a("number",!0);a("comma",!0);let n=!!+a("flag",!0);a("comma");let r=!!+a("flag",!0);return a("comma"),{radii:e,rotation:s,large:n,clockwise:r,end:i["coordinate pair"](!0)}}},s=0,n=[];for(;s<t.length;){let t,e=a("command"),i=e.toUpperCase(),h=e!==i;switch(i){case"M":t=o("coordinate pair").map((function(t,i){return 1===i&&(e=h?"l":"L"),r({end:t},e,h)}));break;case"L":case"T":t=o("coordinate pair").map((function(t){return r({end:t},e,h)}));break;case"C":if(t=o("coordinate pair"),t.length%3)throw Error("Expected coordinate pair triplet at position "+s);t=t.reduce((function(t,i,s){let n=s%3;if(n){t[t.length-1][1===n?"cp2":"end"]=i}else t.push(r({cp1:i},e,h));return t}),[]);break;case"Q":case"S":if(t=o("coordinate pair"),1&t.length)throw Error("Expected coordinate pair couple at position "+s);t=t.reduce((function(t,i,s){if(1&s){t[t.length-1].end=i}else t.push(r({cp:i},e,h));return t}),[]);break;case"H":case"V":t=o("number").map((function(t){return r({value:t},e,h)}));break;case"A":t=o("arc definition").map(r,e,h);break;case"Z":t=[{code:"Z"}]}n.push.apply(n,t)}return n;function r(t,e,i){return t.code=e,t.relative=i,t}function a(i,n){e[i].lastIndex=s;let r=e[i].exec(t);if(!r||r.index!==s){if(!n)return null;throw Error("Expected "+i+" at position "+s)}return s=e[i].lastIndex,r[1]}function o(t){let e,s=[],n=!0;for(;null!==(e=i[t](n));)s.push(e),n=!!a("comma");return s}}var Qe="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ti(t,e){return t(e={exports:{}},e.exports),e.exports}var ei=function(){this.__data__=[],this.size=0};var ii=function(t,e){return t===e||t!=t&&e!=e};var si=function(t,e){for(var i=t.length;i--;)if(ii(t[i][0],e))return i;return-1},ni=Array.prototype.splice;var ri=function(t){var e=this.__data__,i=si(e,t);return!(i<0)&&(i==e.length-1?e.pop():ni.call(e,i,1),--this.size,!0)};var ai=function(t){var e=this.__data__,i=si(e,t);return i<0?void 0:e[i][1]};var oi=function(t){return si(this.__data__,t)>-1};var hi=function(t,e){var i=this.__data__,s=si(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};function li(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}li.prototype.clear=ei,li.prototype.delete=ri,li.prototype.get=ai,li.prototype.has=oi,li.prototype.set=hi;var ci=li;var di=function(){this.__data__=new ci,this.size=0};var ui=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var fi=function(t){return this.__data__.get(t)};var pi=function(t){return this.__data__.has(t)},gi="object"==typeof Qe&&Qe&&Qe.Object===Object&&Qe,_i="object"==typeof self&&self&&self.Object===Object&&self,mi=gi||_i||Function("return this")(),yi=mi.Symbol,vi=Object.prototype,bi=vi.hasOwnProperty,xi=vi.toString,wi=yi?yi.toStringTag:void 0;var ki=
4
+ set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}_setRange(t){this._scale.range(t),_e(this)}get clamp(){return"linear"==this.type&&this._scale.clamp()}set clamp(t){"linear"==this.type&&this._scale.clamp(t)}set rangeExtent(t){let e=this._scale.range();this._setRange([e[0],e[0]+t])}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}_addEncoding(t){this.encodings.indexOf(t)<0&&this.encodings.push(t)}map(t){let e=this._scale.copy();return e.domain(this.domain),this._flipped?(e.range(this._scale.range().reverse()),e(t)):e(t)}invert(t){return this._scale.invert(t)}get offset(){return this._offset}set offset(t){this._offset=t;for(let t of this.encodings)t._apply()}get isFlipped(){return this._flipped}set isFlipped(t){this._flipped=t}get includeZero(){return this._includeZero}set includeZero(t){this._includeZero=t,ge(this)}get mapping(){return this._mapping}getEncodedChannels(){let t={};for(let e of this.encodings)t[e.channel]=!0;return Object.keys(t)}}class Ne extends q{constructor(t){super(t),this.type="packing",this.x="x"in t?t.x:400,this.y="y"in t?t.y:400,this.width=t.width,this.height=t.height}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this.x,t.args.y=this.y,t.args.width=this.width,t.args.height=this.height,t}clone(){return new Ne({x:this.x,y:this.y,width:this.width,height:this.height})}run(){if(null==this.group)return;let t=this.group.children.map((t=>({name:t.id,radius:t.radius,itm:t}))),e=t.reduce(((t,e)=>t+Math.pow(e.radius,2)),0),i=Math.sqrt(e);void 0===this.width&&(this.width=i),void 0===this.height&&(this.height=i);let s=n.hierarchy({name:"root",children:t}).sum((t=>t.radius?t.radius:0)).sort(((t,e)=>e.value-t.value));n.pack().size([this.width,this.height]).radius((t=>t.value))(s);for(let t of s.children){let e=t.data.itm,i=this.x-s.x+t.x-e.x,n=this.y-s.y+t.y-e.y;e._doTranslate(i,n)}this.group._updateBounds()}}class Pe extends q{constructor(t){super(t),this.type="treemap",this._width=t.width,this._height=t.height,this._top=t.top,this._left=t.left}toJSON(){let t={args:{}};return t.type=this.type,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}clone(){return new Pe({})}run(){if(null==this.group||!this.group.children||0==this.group.children.length)return;let t=this._width?this._width:this.group.bounds.width,e=this._height?this._height:this.group.bounds.height,i=void 0===this._top?this.group.bounds.top:this._top,s=void 0===this._left?this.group.bounds.left:this._left,r=n.hierarchy(this.group).sum((t=>"rect"==t.type?t.bounds.width*t.bounds.height:0));n.treemap().size([t,e])(r),this._apply(r,s,i),this.group.getScene()._updateAncestorBounds(r.leaves()[0].data)}_apply(t,e,i){if("collection"==t.data.type&&t.children)for(let s of t.children)this._apply(s,e,i);else"rect"==t.data.type&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),t.data._doTranslate(t.x0+e-t.data.bounds.left,t.y0+i-t.data.bounds.top))}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get top(){return this._top}set top(t){this._top=t,this.run()}get left(){return this._left}set left(t){this._left=t,this.run()}}function Fe(t,e){let i=[t[0]],s=[e[0]];for(let n=1;n<e.length;n++){let r=!1,a=e[n];for(let e=0;e<s.length;e++){let o=s[e],h=new Set(a);if(o.forEach((t=>h.add(t))),h.size<a.length+o.length){s[e]=[...h],i[e]=i[e].concat(t[n]),r=!0;break}}r||(s.push(a),i.push(t[n]))}return{grouping:i,subgraphs:s}}class Be{constructor(t,e){this._type="network",this._nodeTable=new Jt(t.nodes,"nodes"),this._linkTable=new Jt(t.links,"links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._nodes=t.nodes,this._links=t.links,this._name=e,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e.id]=e}get type(){return this._type}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodes(){return this._nodes}get links(){return this._links}getNode(t){return this._nodeHash[t]}getSources(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].target==i){e=s[t].source;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}getTargets(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].source==i){e=s[t].target;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}transform(t,e,i){switch(t){case"partition":return function(t){let e=t.nodes,i=t.links,s=i.map(((t,e)=>[e])),n=i.map((t=>[t.source,t.target])),r=Fe(s,n);for(;r.grouping.length!=s.length;)s=r.grouping,n=r.subgraphs,r=Fe(s,n);let a=[];for(let[t,s]of r.grouping.entries()){let n={nodes:[],links:[]};n.links=s.map((t=>i[t]));const o=r.subgraphs[t];n.nodes=e.filter((t=>o.indexOf(t.id)>=0)),a.push(new Be(n))}return a}(this)}}isLinear(){let t={},e={};for(let i of this._links)i.source in e||(e[i.source]=0),i.target in t||(t[i.target]=0),e[i.source]++,t[i.target]++;for(let e in t)if(t[e]>1)return!1;for(let t in e)if(e[t]>1)return!1;return!0}}class Le extends q{constructor(t){super(t),this.type=y.TidyTree,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:b}toJSON(){let t={args:{}};return t.args.type=this.type,t.args.orientation=this._orientation,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt;if(!t.tree)throw G.LAYOUT_WITHOUT_TREE;{let e=n.hierarchy(t.tree._data),i=Math.max(...this.group.children.map((t=>t.bounds.width))),s=Math.max(...this.group.children.map((t=>t.bounds.height))),r=this._orientation==b?[this._height,this._width]:[this._width,this._height],a=n.tree().nodeSize([i,s]).size(r)(e);this._apply(a,this.group)}}_apply(t,e){let i,s,n=e.children.filter((e=>e.dataScope.getFieldValue(o)==t.data.id))[0];switch(this._orientation){case b:i=t.y+this._left,s=t.x+this._top;break;case v:i=t.x+this._left,s=this._top+t.y}if(n.x=i,n.y=s,t.children&&t.children.length>0)for(let i of t.children)this._apply(i,e)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get size(){return[this._width,this._height]}set size(t){this._width=t[0],this._height=t[1],this.run()}}class De extends q{constructor(t){super(t),this.type=y.Force,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this._x,t.args.y=this._y,t.args.iterations=this._iterations,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt.graph;if(t){let e=t.links.map((e=>({source:t.getNode(e.source),target:t.getNode(e.target)}))),i=n.forceSimulation(t.nodes).force("charge",n.forceManyBody().strength(-this._repulsion)).force("link",n.forceLink(e).id((t=>t.id)).distance(this._linkDistance)).force("x",n.forceX()).force("y",n.forceY()).force("center",n.forceCenter(this._x,this._y).strength(this._attraction));i.stop(),i.tick(this._iterations);for(let e=0;e<this.group.children.length;e++)this.group.children[e].x=t.nodes[e].x,this.group.children[e].y=t.nodes[e].y}}}class je{constructor(){this.axes={},this.guideCmds=[],this.collectionCmds=[],this.glyphCmds=[],this.spec=[]}run(t){for(let e of t.children)switch(e.type){case T.Axis:{let t=e.classId?e.classId:e.id;this.axes[t]=e;break}case T.Gridlines:case T.Legend:{let t=e.toJSON();this.guideCmds.push({cmd:e.type,channel:t.channel,field:t.field,args:t.args});break}case T.Collection:case T.Group:case T.Glyph:{let i=[];this._analyze(e,i);for(let t=i.length-1;t>0;t--)for(let e of i[t].fields)i[t-1].fields.delete(e);for(let[e,s]of i.entries()){if(s.item instanceof H){let e={cmd:"mark",type:s.item.type,output:s.item,args:s.item.toJSON().args};this._inferMarkArgs(e,t),this.collectionCmds.push(e)}else if(s.item instanceof ie)this.collectionCmds.push({cmd:"glyph",output:s.item,input:i.slice(0,e).map((t=>t.item)),args:{}});else if(s.item instanceof le){let t=[...i[e-1].fields][0],n={cmd:"join",input:i[e-1].item,output:s.item,data:i[e-1].item.dataScope.dataTable.id,args:{field:t}};t==h&&delete n.field,this.collectionCmds.push(n)}s.item.dataScope&&0==s.item.dataScope.fields.length&&!s.item.parent.dataScope&&this.collectionCmds.push({cmd:"attach",input:s.item,data:s.item.dataScope.dataTable.id})}break}default:if(e instanceof H){let i={cmd:"mark",type:e.type,output:e,args:e.toJSON().args};this._inferMarkArgs(i,t),this.glyphCmds.push(i)}}this._inferJoin(),this._inferArgs(t);for(let t in this.axes){let e=this.axes[t].toJSON();this.guideCmds.push({cmd:e.type,channel:e.channel,field:e.field,args:e.args})}return this._generateFullSpec(t),this.spec}_inferJoin(){for(let t of this.collectionCmds){if("join"!=t.cmd)continue;let e=t.input,i=e.parent;switch(e.type){case T.Rect:i.layout&&i.layout.type==y.Stack?t.cmd="divide":t.cmd="repeat";break;default:t.cmd="repeat"}}}_inferArgs(t){for(let e of this.collectionCmds)switch(e.cmd){case"mark":this._inferMarkArgs(e,t);break;case"divide":this._inferDivideArgs(e,t)}}_inferDivideArgs(t){t.args.orientation=t.output.layout.orientation}_inferMarkArgs(t,e){let i=t.output,s=i.parent,n=nt(i,e),r=nt(s,e);switch(i.type){case T.Rect:s.layout&&s.layout.type==y.Grid?(t.args.width=s.layout.cellBounds[0].width,t.args.height=s.layout.cellBounds[0].height):s.layout&&s.layout.type==y.Stack?(t.args.width=Math.max(...r.map((t=>t.bounds.width))),t.args.height=Math.max(...r.map((t=>t.bounds.height)))):(t.args.width=Math.max(...n.map((t=>t.bounds.width))),t.args.height=Math.max(...n.map((t=>t.bounds.height)))),t.args.left=Math.min(...n.map((t=>t.bounds.left))),t.args.top=Math.min(...n.map((t=>t.bounds.top)));break;case T.Line:t.args.x1=Math.min(...n.map((t=>t.vertices[0].x))),t.args.y1=Math.min(...n.map((t=>t.vertices[0].y))),t.args.x2=Math.min(...n.map((t=>t.vertices[1].x))),t.args.y2=Math.min(...n.map((t=>t.vertices[1].y)));break;case T.Arc:t.args.x=i.x,t.args.y=i.y,t.args.innerRadius=i.innerRadius,t.args.outerRadius=i.outerRadius}for(let e in i.styles)t.args[e]=i.styles[e]}_analyze(t,e){if(t instanceof ie)for(let i of t.children)this._analyze(i,e);else t instanceof Ot&&this._analyze(t.firstChild,e);let i={type:t.type,item:t};t.dataScope?i.fields=new Set(t.dataScope.fields):i.fields=new Set,e.push(i)}_generateFullSpec(t){this.spec=[],this.spec.push({cmd:"scene",args:{fillColor:t.fillColor}});let e=t.getDataTables(),i={},s=[];for(let t in e){let n=e[t];if(n.sourceDataTable)for(;n.sourceDataTable;)s.push({cmd:"transform",type:n.transform.type,args:n.transform.args,input:n.sourceDataTable.id,output:n.id}),n=n.sourceDataTable;n.id in i||(i[n.id]={cmd:"data",url:n.url,output:n.id})}this.spec=this.spec.concat(Object.values(i)),this.spec=this.spec.concat(s);let n=[];for(let t of this.collectionCmds){let e;t.output&&t.output.layout&&(e={cmd:"layout",type:t.output.layout.type,input:t.output.id,args:t.output.layout.toJSON().args}),this.spec.push(t),t.output&&t.output.childrenOrder&&n.push({cmd:"sortChildren",args:t.output.childrenOrder,input:t.output.id}),e&&this.spec.push(e),t.input&&Array.isArray(t.input)?t.input=t.input.map((t=>t.classId?t.classId:t.id)):t.input&&(t.input=t.input.classId?t.input.classId:t.input.id),t.output&&(t.output=t.output.classId?t.output.classId:t.output.id)}let r={},a=[];for(let e in t.encodings)for(let i in t.encodings[e]){let s=t.encodings[e][i];s.scale&&!(s.scale.id in r)&&(r[s.scale.id]=s.scale.toJSON());let n=s.toJSON().args;n.field=s.field,n.channel=s.channel,delete n.datatable,a.push({cmd:"encode",input:ct(s.anyItem),scale:s.scale.id,args:n})}for(let t in r){let e=r[t];e.cmd="scale",this.spec.push(e)}this.spec=this.spec.concat(a),this.spec=this.spec.concat(n);for(let e in t.constraints){let i=t.constraints[e],s={cmd:"constraint",type:i.type,args:{}};switch(i.type){case E:s.item=i.item.classId?i.item.classId:i.item.id,s.baseItem=i.baseItem.classId?i.baseItem.classId:i.baseItem.id,s.channel=i.channel,s.args.itemAnchor=i.itemAnchor,s.args.baseAnchor=i.baseAnchor,s.args.offset=i.offset;break;case S:s.items=i.items.map((t=>t.classId?t.classId:t.id)),s.anchor=i.anchor}this.spec.push(s)}for(let t of this.guideCmds)this.spec.push(t);for(let t of this.glyphCmds)t.output&&(t.output=t.output.classId?t.output.classId:t.output.id),this.spec.push(t)}}class Ve{constructor(){this.axes={},this.legends=[],this.gridlines=[],this.scales={},this.tables={}}load(t){let e={};if(t.fillColor&&(e.fillColor=t.fillColor),t.itemCounter)for(let e in t.itemCounter)vt[e]=t.itemCounter[e];let i=Kc(e);if(i.id=t.id,i.type=t.type,t.bounds&&(i._bounds=new a(t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height)),t.tables)for(let e in t.tables)this.tables[e]=new Jt(t.tables[e].data,t.tables[e].url,t.tables[e].fieldTypes),this.tables[e].id=t.tables[e].id;for(let e of t.children)this._processItem(i,e,i);if(t.scales)for(let e in t.scales)this._loadScale(t.scales[e],i);if(t.encodings)for(let e of t.encodings)this._loadEncoding(e,i);if(t.constraints)for(let e in t.constraints)this._loadConstraint(t.constraints[e],i);for(let t in this.axes)this._createGuide(i,this.axes[t]);for(let t of this.legends)this._createGuide(i,t);for(let t of this.gridlines)this._createGuide(i,t);return i}_loadScale(t,e){let i;t.type.indexOf("Color")>0&&t.scheme?i=Xc(t.type,t.scheme):(i=Xc(t.type),i.range=t.range),i.domain="time"==t.type?t.domain.map((t=>new Date(t))):t.domain,i.id=t.id,"offset"in t&&(i.offset=t.offset),i.isFlipped=t.isFlipped,i.clamp=t.clamp,i._mapping=t.mapping,"includeZero"in t&&(i.includeZero=t.includeZero),"baseItem"in t&&(i._baseItem=e.getItem(t.baseItem)),this.scales[i.id]=i}_loadEncoding(t,e){t.args.datatable&&(t.args.datatable=this.tables[t.args.datatable]),t.args.scale&&(t.args.scale=this.scales[t.args.scale]);let i=t.items.map((t=>e.getItem(t)));e._doEncode(i,t.args),e._relayoutAncestors(i[0],i)}_createGuide(t,e){switch(e.type){case T.Axis:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.axis(e.channel,e.field,e.args);break;case T.Legend:t.legend(e.channel,e.field,e.args);break;case T.Gridlines:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.gridlines(e.channel,e.field,e.args)}}_processItem(t,e,i){switch(e.type){case T.Axis:{let t=e.classId?e.classId:e.id;e.args.tickValues&&e.args.isDate&&(e.args.tickValues=e.args.tickValues.map((t=>new Date(t)))),this.axes[t]=e;break}case T.Gridlines:e.args.values&&e.args.isDate&&(e.args.values=e.args.values.map((t=>new Date(t)))),this.gridlines.push(e);break;case T.Legend:this.legends.push(e);break;case T.Collection:{let s=i.collection();t.addChild(s),this._loadGroup(s,e,i);break}case T.Group:{let s=i.group();t.addChild(s),this._loadGroup(s,e,i);break}case T.Glyph:{let s=i.glyph();t.addChild(s),this._loadGroup(s,e,i);break}default:this._loadMark(t,e,i)}}_loadConstraint(t,e){switch(t.type){case"affixation":{let i=e.getItem(t.item),s=e.getItem(t.baseItem),n=new oe(i,s,e,t.channel,t.itemAnchor,t.baseAnchor,t.offset);return n.id=t.id,e.constraints[t.id]=n,n.apply(),n}case"alignment":{let i=t.items.map((t=>e.getItem(t))),s=new ae(i,t.direction);return s.id=t.id,e.constraints[t.id]=s,s.apply(),s}}}_loadDataScope(t){let e=new Pt(this.tables[t.dt]);for(let i in t.f2v)e._field2value[i]=t.f2v[i],e._updateTuples(i,t.f2v[i]);return e}_loadGroup(t,e,i){if(t.id=e.id,e.classId&&(t.classId=e.classId),e.dataScope&&(t.dataScope=this._loadDataScope(e.dataScope)),e.children)for(let s of e.children)this._processItem(t,s,i);if(e.layout){let i=this._loadLayout(e.layout);i.group=t,t._layout=i}e.bounds&&(t._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height))}_loadMark(t,e,i){if(e.args.fillColor&&"LinearGradient"===e.args.fillColor.type){let t=e.args.fillColor;e.args.fillColor=td(t),e.args.fillColor.id=t.id,e.args.fillColor._stops=t.stops}"id"in e&&(e.args.id=e.id);let s=i.mark(e.type,e.args);if(e.classId&&(s.classId=e.classId),e.dataScope&&(s.dataScope=this._loadDataScope(e.dataScope)),e.vertices){const t=[];for(let i of e.vertices){const e=K.fromJSON(i,s);e.dataScope&&(e.dataScope=this._loadDataScope(e.dataScope)),t.push(e)}s.vertices=t,s.segments=[];for(let t=1;t<s.vertices.length;t++)s.segments.push(new X(s.vertices[t-1],s.vertices[t],s,s.segmentCounter++))}e.bounds&&(s._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height)),e.boundsOffsets&&(s.boundsOffsets=e.boundsOffsets),yt(s)?(s.vertexCounter=e.vertexCounter,s.segmentCounter=e.segmentCounter,s.curveMode=e.curveMode):e.type===T.Image&&(s.src=e.src,s.width=e.width,s.height=e.height,s.x=e.x,s.y=e.y),t.addChild(s)}_loadLayout(t){let e=Qc(t.type,t.args);switch(t.type){case y.Grid:e._left=t.left,e._top=t.top}return e}}class Ge{constructor(){}async run(t){let e,i,s={},n={},r={};for(let a of t)switch(a.cmd){case"scene":e=Kc(a.args);break;case"data":i=await id(a.url),n[a.output]=i;break;case"transform":n[a.output]=n[a.input].transform(a.type,a.args);break;case"mark":s[a.output]=e.mark(a.type,a.args);break;case"glyph":s[a.output]=e.glyph(...a.input.map((t=>s[t])));break;case"attach":e.attach(s[a.input],n[a.data]);break;case"repeat":{let t=e.repeat(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"divide":{let t=e.divide(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"layout":s[a.input].layout=Qc(a.type,a.args);break;case"sortChildren":"field"in a.args?s[a.input].sortChildrenByData(a.args.field,a.args.reverse,a.args.order):"channel"in a.args&&s[a.input].sortChildren(a.args.channel,a.args.reverse);break;case"scale":{let t=Xc(a.type);t.id=a.id,t.domain="time"==a.type?a.domain.map((t=>new Date(t))):a.domain,t.range=a.range,t.clamp=a.clamp,t.isFlipped=a.isFlipped,"offset"in a&&(t.offset=a.offset),r[t.id]=t;break}case"encode":let t,o=a.input;if(o.indexOf("_v_")>0){let e=parseInt(o.split("_v_")[1]);t=s[o.split("_v_")[0]].vertices[e]}else if(o.indexOf("_v")>0);else if(o.indexOf("_s_")>0){let e=parseInt(o.split("_s_")[1]);t=s[o.split("_s_")[0]].segments[e]}else o.indexOf("_s")>0||(t=s[a.input]);a.scale&&r[a.scale]&&(a.args.scale=r[a.scale]),e.encode(t,a.args);break;case"constraint":switch(a.type){case E:e.affix(s[a.item],s[a.baseItem],a.channel,a.args)}break;case"axis":e.axis(a.channel,a.field,a.args);break;case"legend":e.legend(a.channel,a.field,a.args);break;case"gridlines":e.gridlines(a.channel,a.field,a.args)}return e}}let ze=Math.PI/180;class We{constructor(t){this._canvasId=t,this._doesCollectionHaveBounds=!1,this._app=new r.Application({antialias:!0,width:1600,height:1e3,view:document.getElementById(this._canvasId)}),this._app.renderer.autoResize=!0}render(t,e){let i=e||{};this._app.renderer.backgroundColor=Ye(t.fillColor?t.fillColor:"#fff"),this._doesCollectionHaveBounds=!!i.collectionBounds,this._app.stage.removeChildren(),this._app.renderer.clear();let s=this._renderItem(t);this._app.stage.addChild(s)}_renderItem(t){switch(t.type){case T.Ellipse:case T.LinearGradient:$e("mark",t,G.FEATURE_NOT_IMPLEMENTED);break;case T.Circle:return this._renderCircle(t);case T.Pie:return this._renderArc(t);case T.Area:return this._renderArea(t);case T.Polygon:return this._renderPolygon(t);case T.Axis:return this._renderAxis(t);case T.Collection:return this._renderCollection(t);case T.Glyph:case T.Group:case T.Gridlines:case T.Legend:case T.Scene:return this._renderGroup(t);case T.Path:return this._renderPath(t);case T.Line:return this._renderLinearPath(t);case T.Rect:return this._renderRectangle(t);case T.PointText:return this._renderText(t);case T.Arc:return this._renderArc(t);case T.Image:return this._renderImage(t);case T.Link:return this._renderLink(t);case T.Ring:return this._renderRing(t);default:throw console.log(t.type),new Error(`Expect: itemType, Actual: ${t}\nWait that's illegal`)}}_renderRectangle(t){let e=new i.Graphics;return Ue(e,t.styles),e.lineStyle(t.styles.strokeWidth,Ye(t.styles.strokeColor)),Ze(t.styles,e,t.height),e.drawRect(0,0,t.width,t.height),e.x=t.left,e.y=t.top,e.endFill(),e}_renderText(t){let e=new i.TextStyle({fontSize:t.styles.fontSize,fontFamily:t.styles.fontFamily,fontWeight:qe(t.styles.fontWeight),fill:Ye(t.styles.fillColor)}),s=new r.Text(t.text,e),n=new i.Container;Ue(s,t.styles),s.x=t.x,s.y=t.y,s.anchor.set(...function(t){let e,i;switch(t[0]){case"left":e=0;break;case"center":e=.5;break;case"right":e=1;break;default:$e("x anchor",t[0],G.UNKNOWN_ANCHOR)}switch(t[1]){case"hanging":case"top":i=0;break;case"central":case"middle":i=.5;break;case"bottom":i=1;break;default:$e("y anchor",t[1],G.UNKNOWN_ANCHOR)}return[e,i]}(t.anchor)),n.addChild(s);let a=He(t._rotate);return n.pivot.set(a[0],a[1]),n.angle=Je(t._rotate),n.position.set(a[0],a[1]),n}_renderGroup(t){let e=new i.Container;for(const i of t.children){let t=this._renderItem(i);if(null==t)throw new Error;e.addChild(t)}return e}_renderAxis(t){let e=this._renderGroup(t),i=He(t._rotate);return e.pivot.set(i[0],i[1]),e.angle=Je(t._rotate),e.position.set(i[0],i[1]),e}_renderCollection(t){let e=new i.Container,s=this._renderGroup(t);if(e.addChild(s),!this._doesCollectionHaveBounds)return e;let n=new i.Graphics,r=0,a=t.bounds,o=a.left,h=a.right,l=a.top,c=a.bottom,d={strokeWidth:1,color:2018112,dashLength:5,dashSpacing:5};return r=u(o,h,l,r,d,n),r=u(l,c,-h,r,d,n),r=u(h,o,c,r,d,n),u(c,l,-o,r,d,n),e.addChild(n),e;function u(t,e,i,s,n,r){let a=t<=e?1:-1,o=s>=0?{point:t+s*a}:{point:t},h=i>0?[o,{point:i}]:[{point:-i},o];r.lineStyle({width:n.strokeWidth,color:n.color}),r.moveTo(h[0].point,h[1].point),o.point=s*a+t+n.dashLength*a,r.lineTo(h[0].point,h[1].point);let l=!1;for(o.point+=n.dashLength*a;o.point*a<=e*a;)l?(r.lineTo(h[0].point,h[1].point),l=!1,o.point+=n.dashSpacing*a):(r.moveTo(h[0].point,h[1].point),l=!0,o.point+=n.dashLength*a);return l?(i>0?r.lineTo(e,i):r.lineTo(-i,e),(e-o.point)*a):(o.point-e)*a}}_renderArea(t){switch(t.curveMode){case"linear":return this._renderPolygon(t);case"basis":return this._renderBezierArea(t);default:return $e("areaPath",t,G.FEATURE_NOT_IMPLEMENTED)}}_renderBezierArea(t){let e=new i.Graphics;Ue(e,t.styles),e.lineStyle({width:t.styles.strokeWidth,color:Ye(t.styles.strokeColor)});let s=ti(t.getSVGPathData());return Ze(t.styles,e,t.bounds.height),Xe(e,s),e.endFill(),e}_renderPolygon(t){let e=new r.Container,i=this._renderLinearPath(t);i.getChildAt(0).lineTo(t.vertices[0].x,t.vertices[0].y);let s=new r.Graphics;Ue(s,t.styles);let n=[];for(const e of t.vertices)n.push(e.x-t.bounds.left),n.push(e.y-t.bounds.top);return Ze(t.styles,s,t.bounds.height),s.drawPolygon(n),s.x+=t.bounds.left,s.y+=t.bounds.top,s.endFill(),e.addChild(s),e.addChild(i),e}_renderPath(t){switch(t.curveMode){case"linear":return this._renderLinearPath(t);case"bumpX":case"natural":return this._renderBezierPath(t);default:$e("path",t,G.FEATURE_NOT_IMPLEMENTED)}}_renderLinearPath(t){let e=new i.Container,s=new i.Graphics,n="none"==t.styles.strokeDash;Ue(s,t.styles);let r=t.vertices[0];if(s.lineStyle({width:t.styles.strokeWidth,color:Ye(t.styles.strokeColor)}),s.moveTo(r.x,r.y),n)for(let e=1;e<t.vertices.length;e++){const i=t.vertices[e];s.lineTo(i.x,i.y)}else!function(t,e,i){let s,n,r,a=0,o=0,h=e.split(" "),l=Number(h[0]),c=Number(h[1]);for(s=0;s<t.length&&(n=t[s],s!=t.length-1);s++){r=t[s+1];let e=r.x-n.x,h=r.y-n.y,d=Math.sqrt(e*e+h*h),u={x:e/d,y:h/d},f=0;for(i.moveTo(n.x+o*u.x,n.y+o*u.y);f<=d;)f+=o,f+=a>0?a:l,f>d?(a=f-d,f=d):a=0,i.lineTo(n.x+f*u.x,n.y+f*u.y),f+=c,f>d&&0==a?o=f-d:(o=0,i.moveTo(n.x+f*u.x,n.y+f*u.y))}}(t.vertices,t.styles.strokeDash,s);e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderBezierPath(t){let e=new i.Container,s=new i.Graphics;Ue(s,t.styles),s.lineStyle({width:t.styles.strokeWidth,color:Ye(t.styles.strokeColor)}),Xe(s,ti(t.getSVGPathData())),e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderVertex(t){switch(t.shape){case"rect":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:Ye(t.strokeColor)}),e.beginFill(Ye(t.fillColor)),e.drawRect(t.x-t.width/2,t.y-t.height/2,t.width,t.height),e.endFill(),e}(t);case"circle":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:Ye(t.strokeColor)}),e.beginFill(Ye(t.fillColor)),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}(t);case void 0:return null;default:$e("vertex shape",t.shape,G.FEATURE_NOT_IMPLEMENTED)}}_renderCircle(t){let e=new i.Graphics;return Ue(e,t.styles),e.lineStyle(t.styles.strokeWidth,Ye(t.styles.strokeColor)),Ze(t.styles,e,t.height),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}_renderRing(t){let e=new i.Graphics;return e.lineStyle(t.outerRadius-t.innerRadius,Ye(t.styles.fillColor)),e.drawCircle(t.x,t.y,(t.innerRadius+t.outerRadius)/2),e.endFill(),e}_renderArc(t){let e=new i.Graphics;return e.lineStyle({color:Ye(t.styles.strokeColor),width:t.styles.strokeWidth}),e.beginFill(Ye(t.styles.fillColor)),e.arc(t.x,t.y,t.outerRadius,-t.endAngle*ze,-t.startAngle*ze),e.arc(t.x,t.y,t.innerRadius,-t.startAngle*ze,-t.endAngle*ze,!0),e.endFill(),e}_renderImage(t){let e=r.Sprite.from(t.src);return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}_renderLink(t){switch(t.curveMode){case"linear":return function(t){let e=new i.Graphics;return Ue(e,t.styles),e.lineStyle({color:Ye(t.styles.strokeColor),width:t.styles.strokeWidth}),Xe(e,ti(t.getSVGPathData())),e}(t);default:$e("link",t.curveMode,"unexpected curvemode")}}}function Ue(t,e){t.visible=function(t){switch(t){case"hidden":return!1;case null:case void 0:case"visible":default:return!0}}(e.visibility),t.alpha=function(t){switch(t){case void 0:case null:return 1;default:return t}}(e.opacity)}function qe(t){switch(t){case"regular":case"normal":return"normal";case"bold":return"bold";default:console.log(t),$e("font weight",t,G.FEATURE_NOT_IMPLEMENTED)}}function Ye(t){let e=n.color(t);if(null==e)return null;{let t=e.formatHex();return r.utils.string2hex(t)}}function Je(t){return void 0===t||"number"!=typeof t[0]?0:t[0]}function He(t){return void 0===t||"number"!=typeof t[0]?[0,0]:t.slice(1)}function $e(t,e,i){throw console.log(e),new Error(`${i}. Source: ${t}, Actual: `)}function Ze(t,e,i){let s=t.fillColor;if("none"==s)return;let n=Ye(s);null!=n?e.beginFill(n):e.beginTextureFill({color:16777215,texture:Ke(i,s.stops,s.y1>s.y2)})}function Ke(t,e,i){const s=document.createElement("canvas");s.height=t,s.width=1;const n=s.getContext("2d"),a=n.createLinearGradient(0,0,0,t);for(let t=0;t<e.length;t++)i?a.addColorStop(1-e[t].offset/100,e[t].color):a.addColorStop(e[t].offset/100,e[t].color);return n.fillStyle=a,n.fillRect(0,0,1,t),r.Texture.from(s)}function Xe(t,e){let i=e.pop(),s=()=>{};"Z"==i.code.toUpperCase()?s=()=>t.lineTo(e[0].end.x,e[0].end.y):e.push(i);for(const i of e)Qe(i,t);s()}function Qe(t,e){switch(t.code.toUpperCase()){case"M":e.moveTo(t.end.x,t.end.y);break;case"L":e.lineTo(t.end.x,t.end.y);break;case"Q":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp1.x,t.cp1.y,t.end.x,t.end.y);break;case"C":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.end.x,t.end.y);break;case"Z":throw new Error('Unexpected "z" marker. There\'s something wrong, I can feel it');default:return $e("data",t,G.FEATURE_NOT_IMPLEMENTED)}}function ti(t){let e={command:/\s*([achlmqstvz])/gi,number:/\s*([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/gi,comma:/\s*(?:(,)|\s)/g,flag:/\s*([01])/g},i={number:function(t){return+a("number",t)},"coordinate pair":function(t){let e=a("number",t);return null!==e||t?(a("comma"),{x:+e,y:+a("number",!0)}):null},"arc definition":function(t){let e=i["coordinate pair"](t);if(!e&&!t)return null;a("comma");let s=+a("number",!0);a("comma",!0);let n=!!+a("flag",!0);a("comma");let r=!!+a("flag",!0);return a("comma"),{radii:e,rotation:s,large:n,clockwise:r,end:i["coordinate pair"](!0)}}},s=0,n=[];for(;s<t.length;){let t,e=a("command"),i=e.toUpperCase(),h=e!==i;switch(i){case"M":t=o("coordinate pair").map((function(t,i){return 1===i&&(e=h?"l":"L"),r({end:t},e,h)}));break;case"L":case"T":t=o("coordinate pair").map((function(t){return r({end:t},e,h)}));break;case"C":if(t=o("coordinate pair"),t.length%3)throw Error("Expected coordinate pair triplet at position "+s);t=t.reduce((function(t,i,s){let n=s%3;if(n){t[t.length-1][1===n?"cp2":"end"]=i}else t.push(r({cp1:i},e,h));return t}),[]);break;case"Q":case"S":if(t=o("coordinate pair"),1&t.length)throw Error("Expected coordinate pair couple at position "+s);t=t.reduce((function(t,i,s){if(1&s){t[t.length-1].end=i}else t.push(r({cp:i},e,h));return t}),[]);break;case"H":case"V":t=o("number").map((function(t){return r({value:t},e,h)}));break;case"A":t=o("arc definition").map(r,e,h);break;case"Z":t=[{code:"Z"}]}n.push.apply(n,t)}return n;function r(t,e,i){return t.code=e,t.relative=i,t}function a(i,n){e[i].lastIndex=s;let r=e[i].exec(t);if(!r||r.index!==s){if(!n)return null;throw Error("Expected "+i+" at position "+s)}return s=e[i].lastIndex,r[1]}function o(t){let e,s=[],n=!0;for(;null!==(e=i[t](n));)s.push(e),n=!!a("comma");return s}}var ei="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function ii(t,e){return t(e={exports:{}},e.exports),e.exports}var si=function(){this.__data__=[],this.size=0};var ni=function(t,e){return t===e||t!=t&&e!=e};var ri=function(t,e){for(var i=t.length;i--;)if(ni(t[i][0],e))return i;return-1},ai=Array.prototype.splice;var oi=function(t){var e=this.__data__,i=ri(e,t);return!(i<0)&&(i==e.length-1?e.pop():ai.call(e,i,1),--this.size,!0)};var hi=function(t){var e=this.__data__,i=ri(e,t);return i<0?void 0:e[i][1]};var li=function(t){return ri(this.__data__,t)>-1};var ci=function(t,e){var i=this.__data__,s=ri(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};function di(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}di.prototype.clear=si,di.prototype.delete=oi,di.prototype.get=hi,di.prototype.has=li,di.prototype.set=ci;var ui=di;var fi=function(){this.__data__=new ui,this.size=0};var pi=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var gi=function(t){return this.__data__.get(t)};var _i=function(t){return this.__data__.has(t)},mi="object"==typeof ei&&ei&&ei.Object===Object&&ei,yi="object"==typeof self&&self&&self.Object===Object&&self,vi=mi||yi||Function("return this")(),bi=vi.Symbol,xi=Object.prototype,wi=xi.hasOwnProperty,ki=xi.toString,Ci=bi?bi.toStringTag:void 0;var Si=
5
5
  /**
6
6
  * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
7
7
  *
@@ -9,7 +9,7 @@ set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let
9
9
  * @param {*} value The value to query.
10
10
  * @returns {string} Returns the raw `toStringTag`.
11
11
  */
12
- function(t){var e=bi.call(t,wi),i=t[wi];try{t[wi]=void 0;var s=!0}catch(t){}var n=xi.call(t);return s&&(e?t[wi]=i:delete t[wi]),n},Ci=Object.prototype.toString;var Si=function(t){return Ci.call(t)},Ei=yi?yi.toStringTag:void 0;var Ti=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Ei&&Ei in Object(t)?ki(t):Si(t)};var Ai=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};var Ii,Oi=function(t){if(!Ai(t))return!1;var e=Ti(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Ri=mi["__core-js_shared__"],Mi=(Ii=/[^.]+$/.exec(Ri&&Ri.keys&&Ri.keys.IE_PROTO||""))?"Symbol(src)_1."+Ii:"";var Ni=function(t){return!!Mi&&Mi in t},Pi=Function.prototype.toString;var Fi=function(t){if(null!=t){try{return Pi.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Bi=/^\[object .+?Constructor\]$/,Li=Function.prototype,Di=Object.prototype,ji=Li.toString,Vi=Di.hasOwnProperty,Gi=RegExp("^"+ji.call(Vi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var zi=function(t){return!(!Ai(t)||Ni(t))&&(Oi(t)?Gi:Bi).test(Fi(t))};var Wi=function(t,e){return null==t?void 0:t[e]};var Ui=function(t,e){var i=Wi(t,e);return zi(i)?i:void 0},qi=Ui(mi,"Map"),Yi=Ui(Object,"create");var Ji=function(){this.__data__=Yi?Yi(null):{},this.size=0};var Hi=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},$i=Object.prototype.hasOwnProperty;var Zi=function(t){var e=this.__data__;if(Yi){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return $i.call(e,t)?e[t]:void 0},Ki=Object.prototype.hasOwnProperty;var Xi=function(t){var e=this.__data__;return Yi?void 0!==e[t]:Ki.call(e,t)};var Qi=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Yi&&void 0===e?"__lodash_hash_undefined__":e,this};function ts(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}ts.prototype.clear=Ji,ts.prototype.delete=Hi,ts.prototype.get=Zi,ts.prototype.has=Xi,ts.prototype.set=Qi;var es=ts;var is=function(){this.size=0,this.__data__={hash:new es,map:new(qi||ci),string:new es}};var ss=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var ns=function(t,e){var i=t.__data__;return ss(e)?i["string"==typeof e?"string":"hash"]:i.map};var rs=function(t){var e=ns(this,t).delete(t);return this.size-=e?1:0,e};var as=function(t){return ns(this,t).get(t)};var os=function(t){return ns(this,t).has(t)};var hs=function(t,e){var i=ns(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};function ls(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}ls.prototype.clear=is,ls.prototype.delete=rs,ls.prototype.get=as,ls.prototype.has=os,ls.prototype.set=hs;var cs=ls;var ds=function(t,e){var i=this.__data__;if(i instanceof ci){var s=i.__data__;if(!qi||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new cs(s)}return i.set(t,e),this.size=i.size,this};function us(t){var e=this.__data__=new ci(t);this.size=e.size}us.prototype.clear=di,us.prototype.delete=ui,us.prototype.get=fi,us.prototype.has=pi,us.prototype.set=ds;var fs=us;
12
+ function(t){var e=wi.call(t,Ci),i=t[Ci];try{t[Ci]=void 0;var s=!0}catch(t){}var n=ki.call(t);return s&&(e?t[Ci]=i:delete t[Ci]),n},Ei=Object.prototype.toString;var Ti=function(t){return Ei.call(t)},Ai=bi?bi.toStringTag:void 0;var Ii=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Ai&&Ai in Object(t)?Si(t):Ti(t)};var Oi=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};var Ri,Mi=function(t){if(!Oi(t))return!1;var e=Ii(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Ni=vi["__core-js_shared__"],Pi=(Ri=/[^.]+$/.exec(Ni&&Ni.keys&&Ni.keys.IE_PROTO||""))?"Symbol(src)_1."+Ri:"";var Fi=function(t){return!!Pi&&Pi in t},Bi=Function.prototype.toString;var Li=function(t){if(null!=t){try{return Bi.call(t)}catch(t){}try{return t+""}catch(t){}}return""},Di=/^\[object .+?Constructor\]$/,ji=Function.prototype,Vi=Object.prototype,Gi=ji.toString,zi=Vi.hasOwnProperty,Wi=RegExp("^"+Gi.call(zi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var Ui=function(t){return!(!Oi(t)||Fi(t))&&(Mi(t)?Wi:Di).test(Li(t))};var qi=function(t,e){return null==t?void 0:t[e]};var Yi=function(t,e){var i=qi(t,e);return Ui(i)?i:void 0},Ji=Yi(vi,"Map"),Hi=Yi(Object,"create");var $i=function(){this.__data__=Hi?Hi(null):{},this.size=0};var Zi=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ki=Object.prototype.hasOwnProperty;var Xi=function(t){var e=this.__data__;if(Hi){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Ki.call(e,t)?e[t]:void 0},Qi=Object.prototype.hasOwnProperty;var ts=function(t){var e=this.__data__;return Hi?void 0!==e[t]:Qi.call(e,t)};var es=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Hi&&void 0===e?"__lodash_hash_undefined__":e,this};function is(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}is.prototype.clear=$i,is.prototype.delete=Zi,is.prototype.get=Xi,is.prototype.has=ts,is.prototype.set=es;var ss=is;var ns=function(){this.size=0,this.__data__={hash:new ss,map:new(Ji||ui),string:new ss}};var rs=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var as=function(t,e){var i=t.__data__;return rs(e)?i["string"==typeof e?"string":"hash"]:i.map};var os=function(t){var e=as(this,t).delete(t);return this.size-=e?1:0,e};var hs=function(t){return as(this,t).get(t)};var ls=function(t){return as(this,t).has(t)};var cs=function(t,e){var i=as(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};function ds(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}ds.prototype.clear=ns,ds.prototype.delete=os,ds.prototype.get=hs,ds.prototype.has=ls,ds.prototype.set=cs;var us=ds;var fs=function(t,e){var i=this.__data__;if(i instanceof ui){var s=i.__data__;if(!Ji||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new us(s)}return i.set(t,e),this.size=i.size,this};function ps(t){var e=this.__data__=new ui(t);this.size=e.size}ps.prototype.clear=fi,ps.prototype.delete=pi,ps.prototype.get=gi,ps.prototype.has=_i,ps.prototype.set=fs;var gs=ps;
13
13
  /**
14
14
  * A specialized version of `_.forEach` for arrays without support for
15
15
  * iteratee shorthands.
@@ -18,7 +18,7 @@ function(t){var e=bi.call(t,wi),i=t[wi];try{t[wi]=void 0;var s=!0}catch(t){}var
18
18
  * @param {Array} [array] The array to iterate over.
19
19
  * @param {Function} iteratee The function invoked per iteration.
20
20
  * @returns {Array} Returns `array`.
21
- */var ps=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i,t););return t},gs=function(){try{var t=Ui(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var _s=function(t,e,i){"__proto__"==e&&gs?gs(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i},ms=Object.prototype.hasOwnProperty;var ys=function(t,e,i){var s=t[e];ms.call(t,e)&&ii(s,i)&&(void 0!==i||e in t)||_s(t,e,i)};var vs=function(t,e,i,s){var n=!i;i||(i={});for(var r=-1,a=e.length;++r<a;){var o=e[r],h=s?s(i[o],t[o],o,i,t):void 0;void 0===h&&(h=t[o]),n?_s(i,o,h):ys(i,o,h)}return i};var bs=function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s};var xs=function(t){return null!=t&&"object"==typeof t};var ws=function(t){return xs(t)&&"[object Arguments]"==Ti(t)},ks=Object.prototype,Cs=ks.hasOwnProperty,Ss=ks.propertyIsEnumerable,Es=ws(function(){return arguments}())?ws:function(t){return xs(t)&&Cs.call(t,"callee")&&!Ss.call(t,"callee")},Ts=Array.isArray;var As=function(){return!1},Is=ti((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?mi.Buffer:void 0,r=(n?n.isBuffer:void 0)||As;t.exports=r})),Os=/^(?:0|[1-9]\d*)$/;var Rs=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Os.test(t))&&t>-1&&t%1==0&&t<e};var Ms=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Ns={};Ns["[object Float32Array]"]=Ns["[object Float64Array]"]=Ns["[object Int8Array]"]=Ns["[object Int16Array]"]=Ns["[object Int32Array]"]=Ns["[object Uint8Array]"]=Ns["[object Uint8ClampedArray]"]=Ns["[object Uint16Array]"]=Ns["[object Uint32Array]"]=!0,Ns["[object Arguments]"]=Ns["[object Array]"]=Ns["[object ArrayBuffer]"]=Ns["[object Boolean]"]=Ns["[object DataView]"]=Ns["[object Date]"]=Ns["[object Error]"]=Ns["[object Function]"]=Ns["[object Map]"]=Ns["[object Number]"]=Ns["[object Object]"]=Ns["[object RegExp]"]=Ns["[object Set]"]=Ns["[object String]"]=Ns["[object WeakMap]"]=!1;var Ps=function(t){return xs(t)&&Ms(t.length)&&!!Ns[Ti(t)]};var Fs=function(t){return function(e){return t(e)}},Bs=ti((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i&&gi.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||n&&n.binding&&n.binding("util")}catch(t){}}();t.exports=r})),Ls=Bs&&Bs.isTypedArray,Ds=Ls?Fs(Ls):Ps,js=Object.prototype.hasOwnProperty;var Vs=function(t,e){var i=Ts(t),s=!i&&Es(t),n=!i&&!s&&Is(t),r=!i&&!s&&!n&&Ds(t),a=i||s||n||r,o=a?bs(t.length,String):[],h=o.length;for(var l in t)!e&&!js.call(t,l)||a&&("length"==l||n&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Rs(l,h))||o.push(l);return o},Gs=Object.prototype;var zs=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Gs)};var Ws=function(t,e){return function(i){return t(e(i))}},Us=Ws(Object.keys,Object),qs=Object.prototype.hasOwnProperty;var Ys=function(t){if(!zs(t))return Us(t);var e=[];for(var i in Object(t))qs.call(t,i)&&"constructor"!=i&&e.push(i);return e};var Js=function(t){return null!=t&&Ms(t.length)&&!Oi(t)};var Hs=function(t){return Js(t)?Vs(t):Ys(t)};var $s=function(t,e){return t&&vs(e,Hs(e),t)};var Zs=function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e},Ks=Object.prototype.hasOwnProperty;var Xs=function(t){if(!Ai(t))return Zs(t);var e=zs(t),i=[];for(var s in t)("constructor"!=s||!e&&Ks.call(t,s))&&i.push(s);return i};var Qs=function(t){return Js(t)?Vs(t,!0):Xs(t)};var tn=function(t,e){return t&&vs(e,Qs(e),t)},en=ti((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?mi.Buffer:void 0,r=n?n.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var i=t.length,s=r?r(i):new t.constructor(i);return t.copy(s),s}}));var sn=function(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e};
21
+ */var _s=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i,t););return t},ms=function(){try{var t=Yi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var ys=function(t,e,i){"__proto__"==e&&ms?ms(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i},vs=Object.prototype.hasOwnProperty;var bs=function(t,e,i){var s=t[e];vs.call(t,e)&&ni(s,i)&&(void 0!==i||e in t)||ys(t,e,i)};var xs=function(t,e,i,s){var n=!i;i||(i={});for(var r=-1,a=e.length;++r<a;){var o=e[r],h=s?s(i[o],t[o],o,i,t):void 0;void 0===h&&(h=t[o]),n?ys(i,o,h):bs(i,o,h)}return i};var ws=function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s};var ks=function(t){return null!=t&&"object"==typeof t};var Cs=function(t){return ks(t)&&"[object Arguments]"==Ii(t)},Ss=Object.prototype,Es=Ss.hasOwnProperty,Ts=Ss.propertyIsEnumerable,As=Cs(function(){return arguments}())?Cs:function(t){return ks(t)&&Es.call(t,"callee")&&!Ts.call(t,"callee")},Is=Array.isArray;var Os=function(){return!1},Rs=ii((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?vi.Buffer:void 0,r=(n?n.isBuffer:void 0)||Os;t.exports=r})),Ms=/^(?:0|[1-9]\d*)$/;var Ns=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ms.test(t))&&t>-1&&t%1==0&&t<e};var Ps=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},Fs={};Fs["[object Float32Array]"]=Fs["[object Float64Array]"]=Fs["[object Int8Array]"]=Fs["[object Int16Array]"]=Fs["[object Int32Array]"]=Fs["[object Uint8Array]"]=Fs["[object Uint8ClampedArray]"]=Fs["[object Uint16Array]"]=Fs["[object Uint32Array]"]=!0,Fs["[object Arguments]"]=Fs["[object Array]"]=Fs["[object ArrayBuffer]"]=Fs["[object Boolean]"]=Fs["[object DataView]"]=Fs["[object Date]"]=Fs["[object Error]"]=Fs["[object Function]"]=Fs["[object Map]"]=Fs["[object Number]"]=Fs["[object Object]"]=Fs["[object RegExp]"]=Fs["[object Set]"]=Fs["[object String]"]=Fs["[object WeakMap]"]=!1;var Bs=function(t){return ks(t)&&Ps(t.length)&&!!Fs[Ii(t)]};var Ls=function(t){return function(e){return t(e)}},Ds=ii((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i&&mi.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||n&&n.binding&&n.binding("util")}catch(t){}}();t.exports=r})),js=Ds&&Ds.isTypedArray,Vs=js?Ls(js):Bs,Gs=Object.prototype.hasOwnProperty;var zs=function(t,e){var i=Is(t),s=!i&&As(t),n=!i&&!s&&Rs(t),r=!i&&!s&&!n&&Vs(t),a=i||s||n||r,o=a?ws(t.length,String):[],h=o.length;for(var l in t)!e&&!Gs.call(t,l)||a&&("length"==l||n&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Ns(l,h))||o.push(l);return o},Ws=Object.prototype;var Us=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ws)};var qs=function(t,e){return function(i){return t(e(i))}},Ys=qs(Object.keys,Object),Js=Object.prototype.hasOwnProperty;var Hs=function(t){if(!Us(t))return Ys(t);var e=[];for(var i in Object(t))Js.call(t,i)&&"constructor"!=i&&e.push(i);return e};var $s=function(t){return null!=t&&Ps(t.length)&&!Mi(t)};var Zs=function(t){return $s(t)?zs(t):Hs(t)};var Ks=function(t,e){return t&&xs(e,Zs(e),t)};var Xs=function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e},Qs=Object.prototype.hasOwnProperty;var tn=function(t){if(!Oi(t))return Xs(t);var e=Us(t),i=[];for(var s in t)("constructor"!=s||!e&&Qs.call(t,s))&&i.push(s);return i};var en=function(t){return $s(t)?zs(t,!0):tn(t)};var sn=function(t,e){return t&&xs(e,en(e),t)},nn=ii((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?vi.Buffer:void 0,r=n?n.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var i=t.length,s=r?r(i):new t.constructor(i);return t.copy(s),s}}));var rn=function(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e};
22
22
  /**
23
23
  * A specialized version of `_.filter` for arrays without support for
24
24
  * iteratee shorthands.
@@ -27,7 +27,7 @@ function(t){var e=bi.call(t,wi),i=t[wi];try{t[wi]=void 0;var s=!0}catch(t){}var
27
27
  * @param {Array} [array] The array to iterate over.
28
28
  * @param {Function} predicate The function invoked per iteration.
29
29
  * @returns {Array} Returns the new filtered array.
30
- */var nn=function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var a=t[i];e(a,i,t)&&(r[n++]=a)}return r};var rn=function(){return[]},an=Object.prototype.propertyIsEnumerable,on=Object.getOwnPropertySymbols,hn=on?function(t){return null==t?[]:(t=Object(t),nn(on(t),(function(e){return an.call(t,e)})))}:rn;var ln=function(t,e){return vs(t,hn(t),e)};var cn=function(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t},dn=Ws(Object.getPrototypeOf,Object),un=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)cn(e,hn(t)),t=dn(t);return e}:rn;var fn=function(t,e){return vs(t,un(t),e)};var pn=function(t,e,i){var s=e(t);return Ts(t)?s:cn(s,i(t))};var gn=function(t){return pn(t,Hs,hn)};var _n=function(t){return pn(t,Qs,un)},mn=Ui(mi,"DataView"),yn=Ui(mi,"Promise"),vn=Ui(mi,"Set"),bn=Ui(mi,"WeakMap"),xn="[object Map]",wn="[object Promise]",kn="[object Set]",Cn="[object WeakMap]",Sn="[object DataView]",En=Fi(mn),Tn=Fi(qi),An=Fi(yn),In=Fi(vn),On=Fi(bn),Rn=Ti;(mn&&Rn(new mn(new ArrayBuffer(1)))!=Sn||qi&&Rn(new qi)!=xn||yn&&Rn(yn.resolve())!=wn||vn&&Rn(new vn)!=kn||bn&&Rn(new bn)!=Cn)&&(Rn=function(t){var e=Ti(t),i="[object Object]"==e?t.constructor:void 0,s=i?Fi(i):"";if(s)switch(s){case En:return Sn;case Tn:return xn;case An:return wn;case In:return kn;case On:return Cn}return e});var Mn=Rn,Nn=Object.prototype.hasOwnProperty;var Pn=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Nn.call(t,"index")&&(i.index=t.index,i.input=t.input),i},Fn=mi.Uint8Array;var Bn=function(t){var e=new t.constructor(t.byteLength);return new Fn(e).set(new Fn(t)),e};var Ln=function(t,e){var i=e?Bn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)},Dn=/\w*$/;var jn=function(t){var e=new t.constructor(t.source,Dn.exec(t));return e.lastIndex=t.lastIndex,e},Vn=yi?yi.prototype:void 0,Gn=Vn?Vn.valueOf:void 0;var zn=function(t){return Gn?Object(Gn.call(t)):{}};var Wn=function(t,e){var i=e?Bn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var Un=function(t,e,i){var s=t.constructor;switch(e){case"[object ArrayBuffer]":return Bn(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return Ln(t,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return Wn(t,i);case"[object Map]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return jn(t);case"[object Set]":return new s;case"[object Symbol]":return zn(t)}},qn=Object.create,Yn=function(){function t(){}return function(e){if(!Ai(e))return{};if(qn)return qn(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var Jn=function(t){return"function"!=typeof t.constructor||zs(t)?{}:Yn(dn(t))};var Hn=function(t){return xs(t)&&"[object Map]"==Mn(t)},$n=Bs&&Bs.isMap,Zn=$n?Fs($n):Hn;var Kn=function(t){return xs(t)&&"[object Set]"==Mn(t)},Xn=Bs&&Bs.isSet,Qn=Xn?Fs(Xn):Kn,tr="[object Arguments]",er="[object Function]",ir="[object Object]",sr={};sr[tr]=sr["[object Array]"]=sr["[object ArrayBuffer]"]=sr["[object DataView]"]=sr["[object Boolean]"]=sr["[object Date]"]=sr["[object Float32Array]"]=sr["[object Float64Array]"]=sr["[object Int8Array]"]=sr["[object Int16Array]"]=sr["[object Int32Array]"]=sr["[object Map]"]=sr["[object Number]"]=sr[ir]=sr["[object RegExp]"]=sr["[object Set]"]=sr["[object String]"]=sr["[object Symbol]"]=sr["[object Uint8Array]"]=sr["[object Uint8ClampedArray]"]=sr["[object Uint16Array]"]=sr["[object Uint32Array]"]=!0,sr["[object Error]"]=sr[er]=sr["[object WeakMap]"]=!1;var nr=function t(e,i,s,n,r,a){var o,h=1&i,l=2&i,c=4&i;if(s&&(o=r?s(e,n,r,a):s(e)),void 0!==o)return o;if(!Ai(e))return e;var d=Ts(e);if(d){if(o=Pn(e),!h)return sn(e,o)}else{var u=Mn(e),f=u==er||"[object GeneratorFunction]"==u;if(Is(e))return en(e,h);if(u==ir||u==tr||f&&!r){if(o=l||f?{}:Jn(e),!h)return l?fn(e,tn(o,e)):ln(e,$s(o,e))}else{if(!sr[u])return r?e:{};o=Un(e,u,h)}}a||(a=new fs);var p=a.get(e);if(p)return p;a.set(e,o),Qn(e)?e.forEach((function(n){o.add(t(n,i,s,n,e,a))})):Zn(e)&&e.forEach((function(n,r){o.set(r,t(n,i,s,r,e,a))}));var g=d?void 0:(c?l?_n:gn:l?Qs:Hs)(e);return ps(g||e,(function(n,r){g&&(n=e[r=n]),ys(o,r,t(n,i,s,r,e,a))})),o};var rr=function(t){return nr(t,4)};var ar=function(t){return function(){return t}};var or=function(t){return function(e,i,s){for(var n=-1,r=Object(e),a=s(e),o=a.length;o--;){var h=a[t?o:++n];if(!1===i(r[h],h,r))break}return e}}();var hr=function(t,e){return t&&or(t,e,Hs)};var lr=function(t,e){return function(i,s){if(null==i)return i;if(!Js(i))return t(i,s);for(var n=i.length,r=e?n:-1,a=Object(i);(e?r--:++r<n)&&!1!==s(a[r],r,a););return i}}(hr);var cr=function(t){return t};var dr=function(t){return"function"==typeof t?t:cr};var ur=function(t,e){return(Ts(t)?ps:lr)(t,dr(e))},fr=ur;var pr=function(t,e){var i=[];return lr(t,(function(t,s,n){e(t,s,n)&&i.push(t)})),i};var gr=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};var _r=function(t){return this.__data__.has(t)};function mr(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new cs;++e<i;)this.add(t[e])}mr.prototype.add=mr.prototype.push=gr,mr.prototype.has=_r;var yr=mr;
30
+ */var an=function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var a=t[i];e(a,i,t)&&(r[n++]=a)}return r};var on=function(){return[]},hn=Object.prototype.propertyIsEnumerable,ln=Object.getOwnPropertySymbols,cn=ln?function(t){return null==t?[]:(t=Object(t),an(ln(t),(function(e){return hn.call(t,e)})))}:on;var dn=function(t,e){return xs(t,cn(t),e)};var un=function(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t},fn=qs(Object.getPrototypeOf,Object),pn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)un(e,cn(t)),t=fn(t);return e}:on;var gn=function(t,e){return xs(t,pn(t),e)};var _n=function(t,e,i){var s=e(t);return Is(t)?s:un(s,i(t))};var mn=function(t){return _n(t,Zs,cn)};var yn=function(t){return _n(t,en,pn)},vn=Yi(vi,"DataView"),bn=Yi(vi,"Promise"),xn=Yi(vi,"Set"),wn=Yi(vi,"WeakMap"),kn="[object Map]",Cn="[object Promise]",Sn="[object Set]",En="[object WeakMap]",Tn="[object DataView]",An=Li(vn),In=Li(Ji),On=Li(bn),Rn=Li(xn),Mn=Li(wn),Nn=Ii;(vn&&Nn(new vn(new ArrayBuffer(1)))!=Tn||Ji&&Nn(new Ji)!=kn||bn&&Nn(bn.resolve())!=Cn||xn&&Nn(new xn)!=Sn||wn&&Nn(new wn)!=En)&&(Nn=function(t){var e=Ii(t),i="[object Object]"==e?t.constructor:void 0,s=i?Li(i):"";if(s)switch(s){case An:return Tn;case In:return kn;case On:return Cn;case Rn:return Sn;case Mn:return En}return e});var Pn=Nn,Fn=Object.prototype.hasOwnProperty;var Bn=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&Fn.call(t,"index")&&(i.index=t.index,i.input=t.input),i},Ln=vi.Uint8Array;var Dn=function(t){var e=new t.constructor(t.byteLength);return new Ln(e).set(new Ln(t)),e};var jn=function(t,e){var i=e?Dn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)},Vn=/\w*$/;var Gn=function(t){var e=new t.constructor(t.source,Vn.exec(t));return e.lastIndex=t.lastIndex,e},zn=bi?bi.prototype:void 0,Wn=zn?zn.valueOf:void 0;var Un=function(t){return Wn?Object(Wn.call(t)):{}};var qn=function(t,e){var i=e?Dn(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var Yn=function(t,e,i){var s=t.constructor;switch(e){case"[object ArrayBuffer]":return Dn(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return jn(t,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return qn(t,i);case"[object Map]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return Gn(t);case"[object Set]":return new s;case"[object Symbol]":return Un(t)}},Jn=Object.create,Hn=function(){function t(){}return function(e){if(!Oi(e))return{};if(Jn)return Jn(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var $n=function(t){return"function"!=typeof t.constructor||Us(t)?{}:Hn(fn(t))};var Zn=function(t){return ks(t)&&"[object Map]"==Pn(t)},Kn=Ds&&Ds.isMap,Xn=Kn?Ls(Kn):Zn;var Qn=function(t){return ks(t)&&"[object Set]"==Pn(t)},tr=Ds&&Ds.isSet,er=tr?Ls(tr):Qn,ir="[object Arguments]",sr="[object Function]",nr="[object Object]",rr={};rr[ir]=rr["[object Array]"]=rr["[object ArrayBuffer]"]=rr["[object DataView]"]=rr["[object Boolean]"]=rr["[object Date]"]=rr["[object Float32Array]"]=rr["[object Float64Array]"]=rr["[object Int8Array]"]=rr["[object Int16Array]"]=rr["[object Int32Array]"]=rr["[object Map]"]=rr["[object Number]"]=rr[nr]=rr["[object RegExp]"]=rr["[object Set]"]=rr["[object String]"]=rr["[object Symbol]"]=rr["[object Uint8Array]"]=rr["[object Uint8ClampedArray]"]=rr["[object Uint16Array]"]=rr["[object Uint32Array]"]=!0,rr["[object Error]"]=rr[sr]=rr["[object WeakMap]"]=!1;var ar=function t(e,i,s,n,r,a){var o,h=1&i,l=2&i,c=4&i;if(s&&(o=r?s(e,n,r,a):s(e)),void 0!==o)return o;if(!Oi(e))return e;var d=Is(e);if(d){if(o=Bn(e),!h)return rn(e,o)}else{var u=Pn(e),f=u==sr||"[object GeneratorFunction]"==u;if(Rs(e))return nn(e,h);if(u==nr||u==ir||f&&!r){if(o=l||f?{}:$n(e),!h)return l?gn(e,sn(o,e)):dn(e,Ks(o,e))}else{if(!rr[u])return r?e:{};o=Yn(e,u,h)}}a||(a=new gs);var p=a.get(e);if(p)return p;a.set(e,o),er(e)?e.forEach((function(n){o.add(t(n,i,s,n,e,a))})):Xn(e)&&e.forEach((function(n,r){o.set(r,t(n,i,s,r,e,a))}));var g=d?void 0:(c?l?yn:mn:l?en:Zs)(e);return _s(g||e,(function(n,r){g&&(n=e[r=n]),bs(o,r,t(n,i,s,r,e,a))})),o};var or=function(t){return ar(t,4)};var hr=function(t){return function(){return t}};var lr=function(t){return function(e,i,s){for(var n=-1,r=Object(e),a=s(e),o=a.length;o--;){var h=a[t?o:++n];if(!1===i(r[h],h,r))break}return e}}();var cr=function(t,e){return t&&lr(t,e,Zs)};var dr=function(t,e){return function(i,s){if(null==i)return i;if(!$s(i))return t(i,s);for(var n=i.length,r=e?n:-1,a=Object(i);(e?r--:++r<n)&&!1!==s(a[r],r,a););return i}}(cr);var ur=function(t){return t};var fr=function(t){return"function"==typeof t?t:ur};var pr=function(t,e){return(Is(t)?_s:dr)(t,fr(e))},gr=pr;var _r=function(t,e){var i=[];return dr(t,(function(t,s,n){e(t,s,n)&&i.push(t)})),i};var mr=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};var yr=function(t){return this.__data__.has(t)};function vr(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new us;++e<i;)this.add(t[e])}vr.prototype.add=vr.prototype.push=mr,vr.prototype.has=yr;var br=vr;
31
31
  /**
32
32
  * A specialized version of `_.some` for arrays without support for iteratee
33
33
  * shorthands.
@@ -37,7 +37,7 @@ function(t){var e=bi.call(t,wi),i=t[wi];try{t[wi]=void 0;var s=!0}catch(t){}var
37
37
  * @param {Function} predicate The function invoked per iteration.
38
38
  * @returns {boolean} Returns `true` if any element passes the predicate check,
39
39
  * else `false`.
40
- */var vr=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s;)if(e(t[i],i,t))return!0;return!1};var br=function(t,e){return t.has(e)};var xr=
40
+ */var xr=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s;)if(e(t[i],i,t))return!0;return!1};var wr=function(t,e){return t.has(e)};var kr=
41
41
  /**
42
42
  * A specialized version of `baseIsEqualDeep` for arrays with support for
43
43
  * partial deep comparisons.
@@ -51,7 +51,7 @@ function(t){var e=bi.call(t,wi),i=t[wi];try{t[wi]=void 0;var s=!0}catch(t){}var
51
51
  * @param {Object} stack Tracks traversed `array` and `other` objects.
52
52
  * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
53
53
  */
54
- function(t,e,i,s,n,r){var a=1&i,o=t.length,h=e.length;if(o!=h&&!(a&&h>o))return!1;var l=r.get(t),c=r.get(e);if(l&&c)return l==e&&c==t;var d=-1,u=!0,f=2&i?new yr:void 0;for(r.set(t,e),r.set(e,t);++d<o;){var p=t[d],g=e[d];if(s)var _=a?s(g,p,d,e,t,r):s(p,g,d,t,e,r);if(void 0!==_){if(_)continue;u=!1;break}if(f){if(!vr(e,(function(t,e){if(!br(f,e)&&(p===t||n(p,t,i,s,r)))return f.push(e)}))){u=!1;break}}else if(p!==g&&!n(p,g,i,s,r)){u=!1;break}}return r.delete(t),r.delete(e),u};var wr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,s){i[++e]=[s,t]})),i};var kr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},Cr=yi?yi.prototype:void 0,Sr=Cr?Cr.valueOf:void 0;var Er=
54
+ function(t,e,i,s,n,r){var a=1&i,o=t.length,h=e.length;if(o!=h&&!(a&&h>o))return!1;var l=r.get(t),c=r.get(e);if(l&&c)return l==e&&c==t;var d=-1,u=!0,f=2&i?new br:void 0;for(r.set(t,e),r.set(e,t);++d<o;){var p=t[d],g=e[d];if(s)var _=a?s(g,p,d,e,t,r):s(p,g,d,t,e,r);if(void 0!==_){if(_)continue;u=!1;break}if(f){if(!xr(e,(function(t,e){if(!wr(f,e)&&(p===t||n(p,t,i,s,r)))return f.push(e)}))){u=!1;break}}else if(p!==g&&!n(p,g,i,s,r)){u=!1;break}}return r.delete(t),r.delete(e),u};var Cr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,s){i[++e]=[s,t]})),i};var Sr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},Er=bi?bi.prototype:void 0,Tr=Er?Er.valueOf:void 0;var Ar=
55
55
  /**
56
56
  * A specialized version of `baseIsEqualDeep` for comparing objects of
57
57
  * the same `toStringTag`.
@@ -69,7 +69,7 @@ function(t,e,i,s,n,r){var a=1&i,o=t.length,h=e.length;if(o!=h&&!(a&&h>o))return!
69
69
  * @param {Object} stack Tracks traversed `object` and `other` objects.
70
70
  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
71
71
  */
72
- function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new Fn(t),new Fn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ii(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var o=wr;case"[object Set]":var h=1&s;if(o||(o=kr),t.size!=e.size&&!h)return!1;var l=a.get(t);if(l)return l==e;s|=2,a.set(t,e);var c=xr(o(t),o(e),s,n,r,a);return a.delete(t),c;case"[object Symbol]":if(Sr)return Sr.call(t)==Sr.call(e)}return!1},Tr=Object.prototype.hasOwnProperty;var Ar=
72
+ function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new Ln(t),new Ln(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ni(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var o=Cr;case"[object Set]":var h=1&s;if(o||(o=Sr),t.size!=e.size&&!h)return!1;var l=a.get(t);if(l)return l==e;s|=2,a.set(t,e);var c=kr(o(t),o(e),s,n,r,a);return a.delete(t),c;case"[object Symbol]":if(Tr)return Tr.call(t)==Tr.call(e)}return!1},Ir=Object.prototype.hasOwnProperty;var Or=
73
73
  /**
74
74
  * A specialized version of `baseIsEqualDeep` for objects with support for
75
75
  * partial deep comparisons.
@@ -83,7 +83,7 @@ function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byt
83
83
  * @param {Object} stack Tracks traversed `object` and `other` objects.
84
84
  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
85
85
  */
86
- function(t,e,i,s,n,r){var a=1&i,o=gn(t),h=o.length;if(h!=gn(e).length&&!a)return!1;for(var l=h;l--;){var c=o[l];if(!(a?c in e:Tr.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var f=!0;r.set(t,e),r.set(e,t);for(var p=a;++l<h;){var g=t[c=o[l]],_=e[c];if(s)var m=a?s(_,g,c,e,t,r):s(g,_,c,t,e,r);if(!(void 0===m?g===_||n(g,_,i,s,r):m)){f=!1;break}p||(p="constructor"==c)}if(f&&!p){var y=t.constructor,v=e.constructor;y==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v||(f=!1)}return r.delete(t),r.delete(e),f},Ir="[object Arguments]",Or="[object Array]",Rr="[object Object]",Mr=Object.prototype.hasOwnProperty;var Nr=
86
+ function(t,e,i,s,n,r){var a=1&i,o=mn(t),h=o.length;if(h!=mn(e).length&&!a)return!1;for(var l=h;l--;){var c=o[l];if(!(a?c in e:Ir.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var f=!0;r.set(t,e),r.set(e,t);for(var p=a;++l<h;){var g=t[c=o[l]],_=e[c];if(s)var m=a?s(_,g,c,e,t,r):s(g,_,c,t,e,r);if(!(void 0===m?g===_||n(g,_,i,s,r):m)){f=!1;break}p||(p="constructor"==c)}if(f&&!p){var y=t.constructor,v=e.constructor;y==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v||(f=!1)}return r.delete(t),r.delete(e),f},Rr="[object Arguments]",Mr="[object Array]",Nr="[object Object]",Pr=Object.prototype.hasOwnProperty;var Fr=
87
87
  /**
88
88
  * A specialized version of `baseIsEqual` for arrays and objects which performs
89
89
  * deep comparisons and tracks traversed objects enabling objects with circular
@@ -98,7 +98,7 @@ function(t,e,i,s,n,r){var a=1&i,o=gn(t),h=o.length;if(h!=gn(e).length&&!a)return
98
98
  * @param {Object} [stack] Tracks traversed `object` and `other` objects.
99
99
  * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
100
100
  */
101
- function(t,e,i,s,n,r){var a=Ts(t),o=Ts(e),h=a?Or:Mn(t),l=o?Or:Mn(e),c=(h=h==Ir?Rr:h)==Rr,d=(l=l==Ir?Rr:l)==Rr,u=h==l;if(u&&Is(t)){if(!Is(e))return!1;a=!0,c=!1}if(u&&!c)return r||(r=new fs),a||Ds(t)?xr(t,e,i,s,n,r):Er(t,e,h,i,s,n,r);if(!(1&i)){var f=c&&Mr.call(t,"__wrapped__"),p=d&&Mr.call(e,"__wrapped__");if(f||p){var g=f?t.value():t,_=p?e.value():e;return r||(r=new fs),n(g,_,i,s,r)}}return!!u&&(r||(r=new fs),Ar(t,e,i,s,n,r))};var Pr=function t(e,i,s,n,r){return e===i||(null==e||null==i||!xs(e)&&!xs(i)?e!=e&&i!=i:Nr(e,i,s,n,t,r))};var Fr=function(t,e,i,s){var n=i.length,r=n,a=!s;if(null==t)return!r;for(t=Object(t);n--;){var o=i[n];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<r;){var h=(o=i[n])[0],l=t[h],c=o[1];if(a&&o[2]){if(void 0===l&&!(h in t))return!1}else{var d=new fs;if(s)var u=s(l,c,h,t,e,d);if(!(void 0===u?Pr(c,l,3,s,d):u))return!1}}return!0};var Br=function(t){return t==t&&!Ai(t)};var Lr=function(t){for(var e=Hs(t),i=e.length;i--;){var s=e[i],n=t[s];e[i]=[s,n,Br(n)]}return e};
101
+ function(t,e,i,s,n,r){var a=Is(t),o=Is(e),h=a?Mr:Pn(t),l=o?Mr:Pn(e),c=(h=h==Rr?Nr:h)==Nr,d=(l=l==Rr?Nr:l)==Nr,u=h==l;if(u&&Rs(t)){if(!Rs(e))return!1;a=!0,c=!1}if(u&&!c)return r||(r=new gs),a||Vs(t)?kr(t,e,i,s,n,r):Ar(t,e,h,i,s,n,r);if(!(1&i)){var f=c&&Pr.call(t,"__wrapped__"),p=d&&Pr.call(e,"__wrapped__");if(f||p){var g=f?t.value():t,_=p?e.value():e;return r||(r=new gs),n(g,_,i,s,r)}}return!!u&&(r||(r=new gs),Or(t,e,i,s,n,r))};var Br=function t(e,i,s,n,r){return e===i||(null==e||null==i||!ks(e)&&!ks(i)?e!=e&&i!=i:Fr(e,i,s,n,t,r))};var Lr=function(t,e,i,s){var n=i.length,r=n,a=!s;if(null==t)return!r;for(t=Object(t);n--;){var o=i[n];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<r;){var h=(o=i[n])[0],l=t[h],c=o[1];if(a&&o[2]){if(void 0===l&&!(h in t))return!1}else{var d=new gs;if(s)var u=s(l,c,h,t,e,d);if(!(void 0===u?Br(c,l,3,s,d):u))return!1}}return!0};var Dr=function(t){return t==t&&!Oi(t)};var jr=function(t){for(var e=Zs(t),i=e.length;i--;){var s=e[i],n=t[s];e[i]=[s,n,Dr(n)]}return e};
102
102
  /**
103
103
  * A specialized version of `matchesProperty` for source values suitable
104
104
  * for strict equality comparisons, i.e. `===`.
@@ -107,7 +107,7 @@ function(t,e,i,s,n,r){var a=Ts(t),o=Ts(e),h=a?Or:Mn(t),l=o?Or:Mn(e),c=(h=h==Ir?R
107
107
  * @param {string} key The key of the property to get.
108
108
  * @param {*} srcValue The value to match.
109
109
  * @returns {Function} Returns the new spec function.
110
- */var Dr=function(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in Object(i)))}};var jr=function(t){var e=Lr(t);return 1==e.length&&e[0][2]?Dr(e[0][0],e[0][1]):function(i){return i===t||Fr(i,t,e)}};var Vr=function(t){return"symbol"==typeof t||xs(t)&&"[object Symbol]"==Ti(t)},Gr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zr=/^\w*$/;var Wr=function(t,e){if(Ts(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!Vr(t))||(zr.test(t)||!Gr.test(t)||null!=e&&t in Object(e))};function Ur(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var i=function(){var s=arguments,n=e?e.apply(this,s):s[0],r=i.cache;if(r.has(n))return r.get(n);var a=t.apply(this,s);return i.cache=r.set(n,a)||r,a};return i.cache=new(Ur.Cache||cs),i}Ur.Cache=cs;var qr=Ur;var Yr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Jr=/\\(\\)?/g,Hr=
110
+ */var Vr=function(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in Object(i)))}};var Gr=function(t){var e=jr(t);return 1==e.length&&e[0][2]?Vr(e[0][0],e[0][1]):function(i){return i===t||Lr(i,t,e)}};var zr=function(t){return"symbol"==typeof t||ks(t)&&"[object Symbol]"==Ii(t)},Wr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ur=/^\w*$/;var qr=function(t,e){if(Is(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!zr(t))||(Ur.test(t)||!Wr.test(t)||null!=e&&t in Object(e))};function Yr(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var i=function(){var s=arguments,n=e?e.apply(this,s):s[0],r=i.cache;if(r.has(n))return r.get(n);var a=t.apply(this,s);return i.cache=r.set(n,a)||r,a};return i.cache=new(Yr.Cache||us),i}Yr.Cache=us;var Jr=Yr;var Hr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$r=/\\(\\)?/g,Zr=
111
111
  /**
112
112
  * A specialized version of `_.memoize` which clears the memoized function's
113
113
  * cache when it exceeds `MAX_MEMOIZE_SIZE`.
@@ -116,7 +116,7 @@ function(t,e,i,s,n,r){var a=Ts(t),o=Ts(e),h=a?Or:Mn(t),l=o?Or:Mn(e),c=(h=h==Ir?R
116
116
  * @param {Function} func The function to have its output memoized.
117
117
  * @returns {Function} Returns the new memoized function.
118
118
  */
119
- function(t){var e=qr(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Yr,(function(t,i,s,n){e.push(s?n.replace(Jr,"$1"):i||t)})),e}));var $r=
119
+ function(t){var e=Jr(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Hr,(function(t,i,s,n){e.push(s?n.replace($r,"$1"):i||t)})),e}));var Kr=
120
120
  /**
121
121
  * A specialized version of `_.map` for arrays without support for iteratee
122
122
  * shorthands.
@@ -126,14 +126,14 @@ function(t){var e=qr(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cach
126
126
  * @param {Function} iteratee The function invoked per iteration.
127
127
  * @returns {Array} Returns the new mapped array.
128
128
  */
129
- function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,t);return n},Zr=yi?yi.prototype:void 0,Kr=Zr?Zr.toString:void 0;var Xr=function t(e){if("string"==typeof e)return e;if(Ts(e))return $r(e,t)+"";if(Vr(e))return Kr?Kr.call(e):"";var i=e+"";return"0"==i&&1/e==-Infinity?"-0":i};var Qr=function(t){return null==t?"":Xr(t)};var ta=function(t,e){return Ts(t)?t:Wr(t,e)?[t]:Hr(Qr(t))};var ea=function(t){if("string"==typeof t||Vr(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var ia=function(t,e){for(var i=0,s=(e=ta(e,t)).length;null!=t&&i<s;)t=t[ea(e[i++])];return i&&i==s?t:void 0};var sa=function(t,e,i){var s=null==t?void 0:ia(t,e);return void 0===s?i:s};var na=function(t,e){return null!=t&&e in Object(t)};var ra=function(t,e,i){for(var s=-1,n=(e=ta(e,t)).length,r=!1;++s<n;){var a=ea(e[s]);if(!(r=null!=t&&i(t,a)))break;t=t[a]}return r||++s!=n?r:!!(n=null==t?0:t.length)&&Ms(n)&&Rs(a,n)&&(Ts(t)||Es(t))};var aa=function(t,e){return null!=t&&ra(t,e,na)};var oa=function(t,e){return Wr(t)&&Br(e)?Dr(ea(t),e):function(i){var s=sa(i,t);return void 0===s&&s===e?aa(i,t):Pr(e,s,3)}};var ha=function(t){return function(e){return null==e?void 0:e[t]}};
129
+ function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,t);return n},Xr=bi?bi.prototype:void 0,Qr=Xr?Xr.toString:void 0;var ta=function t(e){if("string"==typeof e)return e;if(Is(e))return Kr(e,t)+"";if(zr(e))return Qr?Qr.call(e):"";var i=e+"";return"0"==i&&1/e==-Infinity?"-0":i};var ea=function(t){return null==t?"":ta(t)};var ia=function(t,e){return Is(t)?t:qr(t,e)?[t]:Zr(ea(t))};var sa=function(t){if("string"==typeof t||zr(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var na=function(t,e){for(var i=0,s=(e=ia(e,t)).length;null!=t&&i<s;)t=t[sa(e[i++])];return i&&i==s?t:void 0};var ra=function(t,e,i){var s=null==t?void 0:na(t,e);return void 0===s?i:s};var aa=function(t,e){return null!=t&&e in Object(t)};var oa=function(t,e,i){for(var s=-1,n=(e=ia(e,t)).length,r=!1;++s<n;){var a=sa(e[s]);if(!(r=null!=t&&i(t,a)))break;t=t[a]}return r||++s!=n?r:!!(n=null==t?0:t.length)&&Ps(n)&&Ns(a,n)&&(Is(t)||As(t))};var ha=function(t,e){return null!=t&&oa(t,e,aa)};var la=function(t,e){return qr(t)&&Dr(e)?Vr(sa(t),e):function(i){var s=ra(i,t);return void 0===s&&s===e?ha(i,t):Br(e,s,3)}};var ca=function(t){return function(e){return null==e?void 0:e[t]}};
130
130
  /**
131
131
  * A specialized version of `baseProperty` which supports deep paths.
132
132
  *
133
133
  * @private
134
134
  * @param {Array|string} path The path of the property to get.
135
135
  * @returns {Function} Returns the new accessor function.
136
- */var la=function(t){return function(e){return ia(e,t)}};var ca=function(t){return Wr(t)?ha(ea(t)):la(t)};var da=function(t){return"function"==typeof t?t:null==t?cr:"object"==typeof t?Ts(t)?oa(t[0],t[1]):jr(t):ca(t)};var ua=function(t,e){return(Ts(t)?nn:pr)(t,da(e))},fa=Object.prototype.hasOwnProperty;var pa=function(t,e){return null!=t&&fa.call(t,e)};var ga=function(t,e){return null!=t&&ra(t,e,pa)},_a=Object.prototype.hasOwnProperty;var ma=function(t){if(null==t)return!0;if(Js(t)&&(Ts(t)||"string"==typeof t||"function"==typeof t.splice||Is(t)||Ds(t)||Es(t)))return!t.length;var e=Mn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(zs(t))return!Ys(t).length;for(var i in t)if(_a.call(t,i))return!1;return!0};var ya=function(t){return void 0===t};var va=function(t,e){var i=-1,s=Js(t)?Array(t.length):[];return lr(t,(function(t,n,r){s[++i]=e(t,n,r)})),s};var ba=function(t,e){return(Ts(t)?$r:va)(t,da(e))};
136
+ */var da=function(t){return function(e){return na(e,t)}};var ua=function(t){return qr(t)?ca(sa(t)):da(t)};var fa=function(t){return"function"==typeof t?t:null==t?ur:"object"==typeof t?Is(t)?la(t[0],t[1]):Gr(t):ua(t)};var pa=function(t,e){return(Is(t)?an:_r)(t,fa(e))},ga=Object.prototype.hasOwnProperty;var _a=function(t,e){return null!=t&&ga.call(t,e)};var ma=function(t,e){return null!=t&&oa(t,e,_a)},ya=Object.prototype.hasOwnProperty;var va=function(t){if(null==t)return!0;if($s(t)&&(Is(t)||"string"==typeof t||"function"==typeof t.splice||Rs(t)||Vs(t)||As(t)))return!t.length;var e=Pn(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(Us(t))return!Hs(t).length;for(var i in t)if(ya.call(t,i))return!1;return!0};var ba=function(t){return void 0===t};var xa=function(t,e){var i=-1,s=$s(t)?Array(t.length):[];return dr(t,(function(t,n,r){s[++i]=e(t,n,r)})),s};var wa=function(t,e){return(Is(t)?Kr:xa)(t,fa(e))};
137
137
  /**
138
138
  * A specialized version of `_.reduce` for arrays without support for
139
139
  * iteratee shorthands.
@@ -145,7 +145,7 @@ function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,
145
145
  * @param {boolean} [initAccum] Specify using the first element of `array` as
146
146
  * the initial value.
147
147
  * @returns {*} Returns the accumulated value.
148
- */var xa=function(t,e,i,s){var n=-1,r=null==t?0:t.length;for(s&&r&&(i=t[++n]);++n<r;)i=e(i,t[n],n,t);return i};var wa=function(t,e,i,s,n){return n(t,(function(t,n,r){i=s?(s=!1,t):e(i,t,n,r)})),i};var ka=function(t,e,i){var s=Ts(t)?xa:wa,n=arguments.length<3;return s(t,da(e),i,n,lr)};var Ca=function(t){return"string"==typeof t||!Ts(t)&&xs(t)&&"[object String]"==Ti(t)},Sa=ha("length"),Ea=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Ta=function(t){return Ea.test(t)},Aa="[\\ud800-\\udfff]",Ia="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Oa="\\ud83c[\\udffb-\\udfff]",Ra="[^\\ud800-\\udfff]",Ma="(?:\\ud83c[\\udde6-\\uddff]){2}",Na="[\\ud800-\\udbff][\\udc00-\\udfff]",Pa="(?:"+Ia+"|"+Oa+")"+"?",Fa="[\\ufe0e\\ufe0f]?",Ba=Fa+Pa+("(?:\\u200d(?:"+[Ra,Ma,Na].join("|")+")"+Fa+Pa+")*"),La="(?:"+[Ra+Ia+"?",Ia,Ma,Na,Aa].join("|")+")",Da=RegExp(Oa+"(?="+Oa+")|"+La+Ba,"g");var ja=function(t){for(var e=Da.lastIndex=0;Da.test(t);)++e;return e};var Va=function(t){return Ta(t)?ja(t):Sa(t)};var Ga=function(t){if(null==t)return 0;if(Js(t))return Ca(t)?Va(t):t.length;var e=Mn(t);return"[object Map]"==e||"[object Set]"==e?t.size:Ys(t).length};var za=function(t,e,i){var s=Ts(t),n=s||Is(t)||Ds(t);if(e=da(e),null==i){var r=t&&t.constructor;i=n?s?new r:[]:Ai(t)&&Oi(r)?Yn(dn(t)):{}}return(n?ps:hr)(t,(function(t,s,n){return e(i,t,s,n)})),i},Wa=yi?yi.isConcatSpreadable:void 0;var Ua=function(t){return Ts(t)||Es(t)||!!(Wa&&t&&t[Wa])};var qa=function t(e,i,s,n,r){var a=-1,o=e.length;for(s||(s=Ua),r||(r=[]);++a<o;){var h=e[a];i>0&&s(h)?i>1?t(h,i-1,s,n,r):cn(r,h):n||(r[r.length]=h)}return r};var Ya=function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)},Ja=Math.max;var Ha=
148
+ */var ka=function(t,e,i,s){var n=-1,r=null==t?0:t.length;for(s&&r&&(i=t[++n]);++n<r;)i=e(i,t[n],n,t);return i};var Ca=function(t,e,i,s,n){return n(t,(function(t,n,r){i=s?(s=!1,t):e(i,t,n,r)})),i};var Sa=function(t,e,i){var s=Is(t)?ka:Ca,n=arguments.length<3;return s(t,fa(e),i,n,dr)};var Ea=function(t){return"string"==typeof t||!Is(t)&&ks(t)&&"[object String]"==Ii(t)},Ta=ca("length"),Aa=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Ia=function(t){return Aa.test(t)},Oa="[\\ud800-\\udfff]",Ra="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Ma="\\ud83c[\\udffb-\\udfff]",Na="[^\\ud800-\\udfff]",Pa="(?:\\ud83c[\\udde6-\\uddff]){2}",Fa="[\\ud800-\\udbff][\\udc00-\\udfff]",Ba="(?:"+Ra+"|"+Ma+")"+"?",La="[\\ufe0e\\ufe0f]?",Da=La+Ba+("(?:\\u200d(?:"+[Na,Pa,Fa].join("|")+")"+La+Ba+")*"),ja="(?:"+[Na+Ra+"?",Ra,Pa,Fa,Oa].join("|")+")",Va=RegExp(Ma+"(?="+Ma+")|"+ja+Da,"g");var Ga=function(t){for(var e=Va.lastIndex=0;Va.test(t);)++e;return e};var za=function(t){return Ia(t)?Ga(t):Ta(t)};var Wa=function(t){if(null==t)return 0;if($s(t))return Ea(t)?za(t):t.length;var e=Pn(t);return"[object Map]"==e||"[object Set]"==e?t.size:Hs(t).length};var Ua=function(t,e,i){var s=Is(t),n=s||Rs(t)||Vs(t);if(e=fa(e),null==i){var r=t&&t.constructor;i=n?s?new r:[]:Oi(t)&&Mi(r)?Hn(fn(t)):{}}return(n?_s:cr)(t,(function(t,s,n){return e(i,t,s,n)})),i},qa=bi?bi.isConcatSpreadable:void 0;var Ya=function(t){return Is(t)||As(t)||!!(qa&&t&&t[qa])};var Ja=function t(e,i,s,n,r){var a=-1,o=e.length;for(s||(s=Ya),r||(r=[]);++a<o;){var h=e[a];i>0&&s(h)?i>1?t(h,i-1,s,n,r):un(r,h):n||(r[r.length]=h)}return r};var Ha=function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)},$a=Math.max;var Za=
149
149
  /**
150
150
  * A specialized version of `baseRest` which transforms the rest array.
151
151
  *
@@ -155,7 +155,7 @@ function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,
155
155
  * @param {Function} transform The rest array transform.
156
156
  * @returns {Function} Returns the new function.
157
157
  */
158
- function(t,e,i){return e=Ja(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=Ja(s.length-e,0),a=Array(r);++n<r;)a[n]=s[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=s[n];return o[e]=i(a),Ya(t,this,o)}},$a=gs?function(t,e){return gs(t,"toString",{configurable:!0,enumerable:!1,value:ar(e),writable:!0})}:cr,Za=Date.now;var Ka=function(t){var e=0,i=0;return function(){var s=Za(),n=16-(s-i);if(i=s,n>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}($a);var Xa=function(t,e){return Ka(Ha(t,e,cr),t+"")};var Qa=function(t,e,i,s){for(var n=t.length,r=i+(s?1:-1);s?r--:++r<n;)if(e(t[r],r,t))return r;return-1};var to=function(t){return t!=t};
158
+ function(t,e,i){return e=$a(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=$a(s.length-e,0),a=Array(r);++n<r;)a[n]=s[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=s[n];return o[e]=i(a),Ha(t,this,o)}},Ka=ms?function(t,e){return ms(t,"toString",{configurable:!0,enumerable:!1,value:hr(e),writable:!0})}:ur,Xa=Date.now;var Qa=function(t){var e=0,i=0;return function(){var s=Xa(),n=16-(s-i);if(i=s,n>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(Ka);var to=function(t,e){return Qa(Za(t,e,ur),t+"")};var eo=function(t,e,i,s){for(var n=t.length,r=i+(s?1:-1);s?r--:++r<n;)if(e(t[r],r,t))return r;return-1};var io=function(t){return t!=t};
159
159
  /**
160
160
  * A specialized version of `_.indexOf` which performs strict equality
161
161
  * comparisons of values, i.e. `===`.
@@ -165,7 +165,7 @@ function(t,e,i){return e=Ja(void 0===e?t.length-1:e,0),function(){for(var s=argu
165
165
  * @param {*} value The value to search for.
166
166
  * @param {number} fromIndex The index to search from.
167
167
  * @returns {number} Returns the index of the matched value, else `-1`.
168
- */var eo=function(t,e,i){for(var s=i-1,n=t.length;++s<n;)if(t[s]===e)return s;return-1};var io=function(t,e,i){return e==e?eo(t,e,i):Qa(t,to,i)};
168
+ */var so=function(t,e,i){for(var s=i-1,n=t.length;++s<n;)if(t[s]===e)return s;return-1};var no=function(t,e,i){return e==e?so(t,e,i):eo(t,io,i)};
169
169
  /**
170
170
  * A specialized version of `_.includes` for arrays without support for
171
171
  * specifying an index to search from.
@@ -174,7 +174,7 @@ function(t,e,i){return e=Ja(void 0===e?t.length-1:e,0),function(){for(var s=argu
174
174
  * @param {Array} [array] The array to inspect.
175
175
  * @param {*} target The value to search for.
176
176
  * @returns {boolean} Returns `true` if `target` is found, else `false`.
177
- */var so=function(t,e){return!!(null==t?0:t.length)&&io(t,e,0)>-1};var no=function(t,e,i){for(var s=-1,n=null==t?0:t.length;++s<n;)if(i(e,t[s]))return!0;return!1};var ro=function(){},ao=vn&&1/kr(new vn([,-0]))[1]==1/0?function(t){return new vn(t)}:ro;var oo=function(t,e,i){var s=-1,n=so,r=t.length,a=!0,o=[],h=o;if(i)a=!1,n=no;else if(r>=200){var l=e?null:ao(t);if(l)return kr(l);a=!1,n=br,h=new yr}else h=e?[]:o;t:for(;++s<r;){var c=t[s],d=e?e(c):c;if(c=i||0!==c?c:0,a&&d==d){for(var u=h.length;u--;)if(h[u]===d)continue t;e&&h.push(d),o.push(c)}else n(h,d,i)||(h!==o&&h.push(d),o.push(c))}return o};var ho=function(t){return xs(t)&&Js(t)},lo=Xa((function(t){return oo(qa(t,1,ho,!0))}));var co=function(t,e){return $r(e,(function(e){return t[e]}))};var uo,fo=function(t){return null==t?[]:co(t,Hs(t))};try{uo={clone:rr,constant:ar,each:fr,filter:ua,has:ga,isArray:Ts,isEmpty:ma,isFunction:Oi,isUndefined:ya,keys:Hs,map:ba,reduce:ka,size:Ga,transform:za,union:lo,values:fo}}catch(t){}uo||(uo=window._);var po=uo,go=mo,_o="\0";function mo(t){this._isDirected=!po.has(t,"directed")||t.directed,this._isMultigraph=!!po.has(t,"multigraph")&&t.multigraph,this._isCompound=!!po.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=po.constant(void 0),this._defaultEdgeLabelFn=po.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function yo(t,e){t[e]?t[e]++:t[e]=1}function vo(t,e){--t[e]||delete t[e]}function bo(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}return n+""+r+""+(po.isUndefined(s)?"\0":s)}function xo(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}var o={v:n,w:r};return s&&(o.name=s),o}function wo(t,e){return bo(t,e.v,e.w,e.name)}mo.prototype._nodeCount=0,mo.prototype._edgeCount=0,mo.prototype.isDirected=function(){return this._isDirected},mo.prototype.isMultigraph=function(){return this._isMultigraph},mo.prototype.isCompound=function(){return this._isCompound},mo.prototype.setGraph=function(t){return this._label=t,this},mo.prototype.graph=function(){return this._label},mo.prototype.setDefaultNodeLabel=function(t){return po.isFunction(t)||(t=po.constant(t)),this._defaultNodeLabelFn=t,this},mo.prototype.nodeCount=function(){return this._nodeCount},mo.prototype.nodes=function(){return po.keys(this._nodes)},mo.prototype.sources=function(){var t=this;return po.filter(this.nodes(),(function(e){return po.isEmpty(t._in[e])}))},mo.prototype.sinks=function(){var t=this;return po.filter(this.nodes(),(function(e){return po.isEmpty(t._out[e])}))},mo.prototype.setNodes=function(t,e){var i=arguments,s=this;return po.each(t,(function(t){i.length>1?s.setNode(t,e):s.setNode(t)})),this},mo.prototype.setNode=function(t,e){return po.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=_o,this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},mo.prototype.node=function(t){return this._nodes[t]},mo.prototype.hasNode=function(t){return po.has(this._nodes,t)},mo.prototype.removeNode=function(t){var e=this;if(po.has(this._nodes,t)){var i=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],po.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),po.each(po.keys(this._in[t]),i),delete this._in[t],delete this._preds[t],po.each(po.keys(this._out[t]),i),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},mo.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(po.isUndefined(e))e=_o;else{for(var i=e+="";!po.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},mo.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},mo.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==_o)return e}},mo.prototype.children=function(t){if(po.isUndefined(t)&&(t=_o),this._isCompound){var e=this._children[t];if(e)return po.keys(e)}else{if(t===_o)return this.nodes();if(this.hasNode(t))return[]}},mo.prototype.predecessors=function(t){var e=this._preds[t];if(e)return po.keys(e)},mo.prototype.successors=function(t){var e=this._sucs[t];if(e)return po.keys(e)},mo.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return po.union(e,this.successors(t))},mo.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},mo.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var i=this;po.each(this._nodes,(function(i,s){t(s)&&e.setNode(s,i)})),po.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,i.edge(t))}));var s={};function n(t){var r=i.parent(t);return void 0===r||e.hasNode(r)?(s[t]=r,r):r in s?s[r]:n(r)}return this._isCompound&&po.each(e.nodes(),(function(t){e.setParent(t,n(t))})),e},mo.prototype.setDefaultEdgeLabel=function(t){return po.isFunction(t)||(t=po.constant(t)),this._defaultEdgeLabelFn=t,this},mo.prototype.edgeCount=function(){return this._edgeCount},mo.prototype.edges=function(){return po.values(this._edgeObjs)},mo.prototype.setPath=function(t,e){var i=this,s=arguments;return po.reduce(t,(function(t,n){return s.length>1?i.setEdge(t,n,e):i.setEdge(t,n),n})),this},mo.prototype.setEdge=function(){var t,e,i,s,n=!1,r=arguments[0];"object"==typeof r&&null!==r&&"v"in r?(t=r.v,e=r.w,i=r.name,2===arguments.length&&(s=arguments[1],n=!0)):(t=r,e=arguments[1],i=arguments[3],arguments.length>2&&(s=arguments[2],n=!0)),t=""+t,e=""+e,po.isUndefined(i)||(i=""+i);var a=bo(this._isDirected,t,e,i);if(po.has(this._edgeLabels,a))return n&&(this._edgeLabels[a]=s),this;if(!po.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[a]=n?s:this._defaultEdgeLabelFn(t,e,i);var o=xo(this._isDirected,t,e,i);return t=o.v,e=o.w,Object.freeze(o),this._edgeObjs[a]=o,yo(this._preds[e],t),yo(this._sucs[t],e),this._in[e][a]=o,this._out[t][a]=o,this._edgeCount++,this},mo.prototype.edge=function(t,e,i){var s=1===arguments.length?wo(this._isDirected,arguments[0]):bo(this._isDirected,t,e,i);return this._edgeLabels[s]},mo.prototype.hasEdge=function(t,e,i){var s=1===arguments.length?wo(this._isDirected,arguments[0]):bo(this._isDirected,t,e,i);return po.has(this._edgeLabels,s)},mo.prototype.removeEdge=function(t,e,i){var s=1===arguments.length?wo(this._isDirected,arguments[0]):bo(this._isDirected,t,e,i),n=this._edgeObjs[s];return n&&(t=n.v,e=n.w,delete this._edgeLabels[s],delete this._edgeObjs[s],vo(this._preds[e],t),vo(this._sucs[t],e),delete this._in[e][s],delete this._out[t][s],this._edgeCount--),this},mo.prototype.inEdges=function(t,e){var i=this._in[t];if(i){var s=po.values(i);return e?po.filter(s,(function(t){return t.v===e})):s}},mo.prototype.outEdges=function(t,e){var i=this._out[t];if(i){var s=po.values(i);return e?po.filter(s,(function(t){return t.w===e})):s}},mo.prototype.nodeEdges=function(t,e){var i=this.inEdges(t,e);if(i)return i.concat(this.outEdges(t,e))};var ko={Graph:go,version:"2.1.8"},Co={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:So(t),edges:Eo(t)};po.isUndefined(t.graph())||(e.value=po.clone(t.graph()));return e},read:function(t){var e=new go(t.options).setGraph(t.value);return po.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)})),po.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),e}};function So(t){return po.map(t.nodes(),(function(e){var i=t.node(e),s=t.parent(e),n={v:e};return po.isUndefined(i)||(n.value=i),po.isUndefined(s)||(n.parent=s),n}))}function Eo(t){return po.map(t.edges(),(function(e){var i=t.edge(e),s={v:e.v,w:e.w};return po.isUndefined(e.name)||(s.name=e.name),po.isUndefined(i)||(s.value=i),s}))}var To=function(t){var e,i={},s=[];function n(s){po.has(i,s)||(i[s]=!0,e.push(s),po.each(t.successors(s),n),po.each(t.predecessors(s),n))}return po.each(t.nodes(),(function(t){e=[],n(t),e.length&&s.push(e)})),s};var Ao=Io;function Io(){this._arr=[],this._keyIndices={}}Io.prototype.size=function(){return this._arr.length},Io.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},Io.prototype.has=function(t){return po.has(this._keyIndices,t)},Io.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},Io.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},Io.prototype.add=function(t,e){var i=this._keyIndices;if(t=String(t),!po.has(i,t)){var s=this._arr,n=s.length;return i[t]=n,s.push({key:t,priority:e}),this._decrease(n),!0}return!1},Io.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},Io.prototype.decrease=function(t,e){var i=this._keyIndices[t];if(e>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+e);this._arr[i].priority=e,this._decrease(i)},Io.prototype._heapify=function(t){var e=this._arr,i=2*t,s=i+1,n=t;i<e.length&&(n=e[i].priority<e[n].priority?i:n,s<e.length&&(n=e[s].priority<e[n].priority?s:n),n!==t&&(this._swap(t,n),this._heapify(n)))},Io.prototype._decrease=function(t){for(var e,i=this._arr,s=i[t].priority;0!==t&&!(i[e=t>>1].priority<s);)this._swap(t,e),t=e},Io.prototype._swap=function(t,e){var i=this._arr,s=this._keyIndices,n=i[t],r=i[e];i[t]=r,i[e]=n,s[r.key]=t,s[n.key]=e};var Oo=function(t,e,i,s){return function(t,e,i,s){var n,r,a={},o=new Ao,h=function(t){var e=t.v!==n?t.v:t.w,s=a[e],h=i(t),l=r.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+h);l<s.distance&&(s.distance=l,s.predecessor=n,o.decrease(e,l))};t.nodes().forEach((function(t){var i=t===e?0:Number.POSITIVE_INFINITY;a[t]={distance:i},o.add(t,i)}));for(;o.size()>0&&(n=o.removeMin(),(r=a[n]).distance!==Number.POSITIVE_INFINITY);)s(n).forEach(h);return a}(t,String(e),i||Ro,s||function(e){return t.outEdges(e)})},Ro=po.constant(1);var Mo=function(t,e,i){return po.transform(t.nodes(),(function(s,n){s[n]=Oo(t,n,e,i)}),{})};var No=function(t){var e=0,i=[],s={},n=[];function r(a){var o=s[a]={onStack:!0,lowlink:e,index:e++};if(i.push(a),t.successors(a).forEach((function(t){po.has(s,t)?s[t].onStack&&(o.lowlink=Math.min(o.lowlink,s[t].index)):(r(t),o.lowlink=Math.min(o.lowlink,s[t].lowlink))})),o.lowlink===o.index){var h,l=[];do{h=i.pop(),s[h].onStack=!1,l.push(h)}while(a!==h);n.push(l)}}return t.nodes().forEach((function(t){po.has(s,t)||r(t)})),n};var Po=function(t){return po.filter(No(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};var Fo=function(t,e,i){return function(t,e,i){var s={},n=t.nodes();return n.forEach((function(t){s[t]={},s[t][t]={distance:0},n.forEach((function(e){t!==e&&(s[t][e]={distance:Number.POSITIVE_INFINITY})})),i(t).forEach((function(i){var n=i.v===t?i.w:i.v,r=e(i);s[t][n]={distance:r,predecessor:t}}))})),n.forEach((function(t){var e=s[t];n.forEach((function(i){var r=s[i];n.forEach((function(i){var s=r[t],n=e[i],a=r[i],o=s.distance+n.distance;o<a.distance&&(a.distance=o,a.predecessor=n.predecessor)}))}))})),s}(t,e||Bo,i||function(e){return t.outEdges(e)})},Bo=po.constant(1);var Lo=Do;function Do(t){var e={},i={},s=[];if(po.each(t.sinks(),(function n(r){if(po.has(i,r))throw new jo;po.has(e,r)||(i[r]=!0,e[r]=!0,po.each(t.predecessors(r),n),delete i[r],s.push(r))})),po.size(e)!==t.nodeCount())throw new jo;return s}function jo(){}Do.CycleException=jo,jo.prototype=new Error;var Vo=function(t,e,i){po.isArray(e)||(e=[e]);var s=(t.isDirected()?t.successors:t.neighbors).bind(t),n=[],r={};return po.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);Go(t,e,"post"===i,r,s,n)})),n};function Go(t,e,i,s,n,r){po.has(s,e)||(s[e]=!0,i||r.push(e),po.each(n(e),(function(e){Go(t,e,i,s,n,r)})),i&&r.push(e))}var zo,Wo={components:To,dijkstra:Oo,dijkstraAll:Mo,findCycles:Po,floydWarshall:Fo,isAcyclic:function(t){try{Lo(t)}catch(t){if(t instanceof Lo.CycleException)return!1;throw t}return!0},postorder:function(t,e){return Vo(t,e,"post")},preorder:function(t,e){return Vo(t,e,"pre")},prim:function(t,e){var i,s=new go,n={},r=new Ao;function a(t){var s=t.v===i?t.w:t.v,a=r.priority(s);if(void 0!==a){var o=e(t);o<a&&(n[s]=i,r.decrease(s,o))}}if(0===t.nodeCount())return s;po.each(t.nodes(),(function(t){r.add(t,Number.POSITIVE_INFINITY),s.setNode(t)})),r.decrease(t.nodes()[0],0);var o=!1;for(;r.size()>0;){if(i=r.removeMin(),po.has(n,i))s.setEdge(i,n[i]);else{if(o)throw new Error("Input graph is not connected: "+t);o=!0}t.nodeEdges(i).forEach(a)}return s},tarjan:No,topsort:Lo},Uo={Graph:ko.Graph,json:Co,alg:Wo,version:ko.version};try{zo=Uo}catch(t){}zo||(zo=window.graphlib);var qo=zo;var Yo=function(t){return nr(t,5)};var Jo=function(t,e,i){if(!Ai(i))return!1;var s=typeof e;return!!("number"==s?Js(i)&&Rs(e,i.length):"string"==s&&e in i)&&ii(i[e],t)},Ho=Object.prototype,$o=Ho.hasOwnProperty,Zo=Xa((function(t,e){t=Object(t);var i=-1,s=e.length,n=s>2?e[2]:void 0;for(n&&Jo(e[0],e[1],n)&&(s=1);++i<s;)for(var r=e[i],a=Qs(r),o=-1,h=a.length;++o<h;){var l=a[o],c=t[l];(void 0===c||ii(c,Ho[l])&&!$o.call(t,l))&&(t[l]=r[l])}return t}));var Ko=function(t){return function(e,i,s){var n=Object(e);if(!Js(e)){var r=da(i);e=Hs(e),i=function(t){return r(n[t],t,n)}}var a=t(e,i,s);return a>-1?n[r?e[a]:a]:void 0}},Xo=/\s/;var Qo=function(t){for(var e=t.length;e--&&Xo.test(t.charAt(e)););return e},th=/^\s+/;var eh=function(t){return t?t.slice(0,Qo(t)+1).replace(th,""):t},ih=/^[-+]0x[0-9a-f]+$/i,sh=/^0b[01]+$/i,nh=/^0o[0-7]+$/i,rh=parseInt;var ah=function(t){if("number"==typeof t)return t;if(Vr(t))return NaN;if(Ai(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Ai(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=eh(t);var i=sh.test(t);return i||nh.test(t)?rh(t.slice(2),i?2:8):ih.test(t)?NaN:+t},oh=1/0;var hh=function(t){return t?(t=ah(t))===oh||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var lh=function(t){var e=hh(t),i=e%1;return e==e?i?e-i:e:0},ch=Math.max;var dh=Ko((function(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var n=null==i?0:lh(i);return n<0&&(n=ch(s+n,0)),Qa(t,da(e),n)}));var uh=function(t){return(null==t?0:t.length)?qa(t,1):[]};var fh=function(t,e){return null==t?t:or(t,dr(e),Qs)};var ph=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};var gh=function(t,e){var i={};return e=da(e),hr(t,(function(t,s,n){_s(i,s,e(t,s,n))})),i};var _h=function(t,e,i){for(var s=-1,n=t.length;++s<n;){var r=t[s],a=e(r);if(null!=a&&(void 0===o?a==a&&!Vr(a):i(a,o)))var o=a,h=r}return h};var mh=function(t,e){return t>e};var yh=function(t){return t&&t.length?_h(t,cr,mh):void 0};var vh=function(t,e,i){(void 0!==i&&!ii(t[e],i)||void 0===i&&!(e in t))&&_s(t,e,i)},bh=Function.prototype,xh=Object.prototype,wh=bh.toString,kh=xh.hasOwnProperty,Ch=wh.call(Object);var Sh=function(t){if(!xs(t)||"[object Object]"!=Ti(t))return!1;var e=dn(t);if(null===e)return!0;var i=kh.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&wh.call(i)==Ch};var Eh=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Th=function(t){return vs(t,Qs(t))};
177
+ */var ro=function(t,e){return!!(null==t?0:t.length)&&no(t,e,0)>-1};var ao=function(t,e,i){for(var s=-1,n=null==t?0:t.length;++s<n;)if(i(e,t[s]))return!0;return!1};var oo=function(){},ho=xn&&1/Sr(new xn([,-0]))[1]==1/0?function(t){return new xn(t)}:oo;var lo=function(t,e,i){var s=-1,n=ro,r=t.length,a=!0,o=[],h=o;if(i)a=!1,n=ao;else if(r>=200){var l=e?null:ho(t);if(l)return Sr(l);a=!1,n=wr,h=new br}else h=e?[]:o;t:for(;++s<r;){var c=t[s],d=e?e(c):c;if(c=i||0!==c?c:0,a&&d==d){for(var u=h.length;u--;)if(h[u]===d)continue t;e&&h.push(d),o.push(c)}else n(h,d,i)||(h!==o&&h.push(d),o.push(c))}return o};var co=function(t){return ks(t)&&$s(t)},uo=to((function(t){return lo(Ja(t,1,co,!0))}));var fo=function(t,e){return Kr(e,(function(e){return t[e]}))};var po,go=function(t){return null==t?[]:fo(t,Zs(t))};try{po={clone:or,constant:hr,each:gr,filter:pa,has:ma,isArray:Is,isEmpty:va,isFunction:Mi,isUndefined:ba,keys:Zs,map:wa,reduce:Sa,size:Wa,transform:Ua,union:uo,values:go}}catch(t){}po||(po=window._);var _o=po,mo=vo,yo="\0";function vo(t){this._isDirected=!_o.has(t,"directed")||t.directed,this._isMultigraph=!!_o.has(t,"multigraph")&&t.multigraph,this._isCompound=!!_o.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=_o.constant(void 0),this._defaultEdgeLabelFn=_o.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function bo(t,e){t[e]?t[e]++:t[e]=1}function xo(t,e){--t[e]||delete t[e]}function wo(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}return n+""+r+""+(_o.isUndefined(s)?"\0":s)}function ko(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}var o={v:n,w:r};return s&&(o.name=s),o}function Co(t,e){return wo(t,e.v,e.w,e.name)}vo.prototype._nodeCount=0,vo.prototype._edgeCount=0,vo.prototype.isDirected=function(){return this._isDirected},vo.prototype.isMultigraph=function(){return this._isMultigraph},vo.prototype.isCompound=function(){return this._isCompound},vo.prototype.setGraph=function(t){return this._label=t,this},vo.prototype.graph=function(){return this._label},vo.prototype.setDefaultNodeLabel=function(t){return _o.isFunction(t)||(t=_o.constant(t)),this._defaultNodeLabelFn=t,this},vo.prototype.nodeCount=function(){return this._nodeCount},vo.prototype.nodes=function(){return _o.keys(this._nodes)},vo.prototype.sources=function(){var t=this;return _o.filter(this.nodes(),(function(e){return _o.isEmpty(t._in[e])}))},vo.prototype.sinks=function(){var t=this;return _o.filter(this.nodes(),(function(e){return _o.isEmpty(t._out[e])}))},vo.prototype.setNodes=function(t,e){var i=arguments,s=this;return _o.each(t,(function(t){i.length>1?s.setNode(t,e):s.setNode(t)})),this},vo.prototype.setNode=function(t,e){return _o.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=yo,this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},vo.prototype.node=function(t){return this._nodes[t]},vo.prototype.hasNode=function(t){return _o.has(this._nodes,t)},vo.prototype.removeNode=function(t){var e=this;if(_o.has(this._nodes,t)){var i=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],_o.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),_o.each(_o.keys(this._in[t]),i),delete this._in[t],delete this._preds[t],_o.each(_o.keys(this._out[t]),i),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},vo.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(_o.isUndefined(e))e=yo;else{for(var i=e+="";!_o.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},vo.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},vo.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==yo)return e}},vo.prototype.children=function(t){if(_o.isUndefined(t)&&(t=yo),this._isCompound){var e=this._children[t];if(e)return _o.keys(e)}else{if(t===yo)return this.nodes();if(this.hasNode(t))return[]}},vo.prototype.predecessors=function(t){var e=this._preds[t];if(e)return _o.keys(e)},vo.prototype.successors=function(t){var e=this._sucs[t];if(e)return _o.keys(e)},vo.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return _o.union(e,this.successors(t))},vo.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},vo.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var i=this;_o.each(this._nodes,(function(i,s){t(s)&&e.setNode(s,i)})),_o.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,i.edge(t))}));var s={};function n(t){var r=i.parent(t);return void 0===r||e.hasNode(r)?(s[t]=r,r):r in s?s[r]:n(r)}return this._isCompound&&_o.each(e.nodes(),(function(t){e.setParent(t,n(t))})),e},vo.prototype.setDefaultEdgeLabel=function(t){return _o.isFunction(t)||(t=_o.constant(t)),this._defaultEdgeLabelFn=t,this},vo.prototype.edgeCount=function(){return this._edgeCount},vo.prototype.edges=function(){return _o.values(this._edgeObjs)},vo.prototype.setPath=function(t,e){var i=this,s=arguments;return _o.reduce(t,(function(t,n){return s.length>1?i.setEdge(t,n,e):i.setEdge(t,n),n})),this},vo.prototype.setEdge=function(){var t,e,i,s,n=!1,r=arguments[0];"object"==typeof r&&null!==r&&"v"in r?(t=r.v,e=r.w,i=r.name,2===arguments.length&&(s=arguments[1],n=!0)):(t=r,e=arguments[1],i=arguments[3],arguments.length>2&&(s=arguments[2],n=!0)),t=""+t,e=""+e,_o.isUndefined(i)||(i=""+i);var a=wo(this._isDirected,t,e,i);if(_o.has(this._edgeLabels,a))return n&&(this._edgeLabels[a]=s),this;if(!_o.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[a]=n?s:this._defaultEdgeLabelFn(t,e,i);var o=ko(this._isDirected,t,e,i);return t=o.v,e=o.w,Object.freeze(o),this._edgeObjs[a]=o,bo(this._preds[e],t),bo(this._sucs[t],e),this._in[e][a]=o,this._out[t][a]=o,this._edgeCount++,this},vo.prototype.edge=function(t,e,i){var s=1===arguments.length?Co(this._isDirected,arguments[0]):wo(this._isDirected,t,e,i);return this._edgeLabels[s]},vo.prototype.hasEdge=function(t,e,i){var s=1===arguments.length?Co(this._isDirected,arguments[0]):wo(this._isDirected,t,e,i);return _o.has(this._edgeLabels,s)},vo.prototype.removeEdge=function(t,e,i){var s=1===arguments.length?Co(this._isDirected,arguments[0]):wo(this._isDirected,t,e,i),n=this._edgeObjs[s];return n&&(t=n.v,e=n.w,delete this._edgeLabels[s],delete this._edgeObjs[s],xo(this._preds[e],t),xo(this._sucs[t],e),delete this._in[e][s],delete this._out[t][s],this._edgeCount--),this},vo.prototype.inEdges=function(t,e){var i=this._in[t];if(i){var s=_o.values(i);return e?_o.filter(s,(function(t){return t.v===e})):s}},vo.prototype.outEdges=function(t,e){var i=this._out[t];if(i){var s=_o.values(i);return e?_o.filter(s,(function(t){return t.w===e})):s}},vo.prototype.nodeEdges=function(t,e){var i=this.inEdges(t,e);if(i)return i.concat(this.outEdges(t,e))};var So={Graph:mo,version:"2.1.8"},Eo={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:To(t),edges:Ao(t)};_o.isUndefined(t.graph())||(e.value=_o.clone(t.graph()));return e},read:function(t){var e=new mo(t.options).setGraph(t.value);return _o.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)})),_o.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),e}};function To(t){return _o.map(t.nodes(),(function(e){var i=t.node(e),s=t.parent(e),n={v:e};return _o.isUndefined(i)||(n.value=i),_o.isUndefined(s)||(n.parent=s),n}))}function Ao(t){return _o.map(t.edges(),(function(e){var i=t.edge(e),s={v:e.v,w:e.w};return _o.isUndefined(e.name)||(s.name=e.name),_o.isUndefined(i)||(s.value=i),s}))}var Io=function(t){var e,i={},s=[];function n(s){_o.has(i,s)||(i[s]=!0,e.push(s),_o.each(t.successors(s),n),_o.each(t.predecessors(s),n))}return _o.each(t.nodes(),(function(t){e=[],n(t),e.length&&s.push(e)})),s};var Oo=Ro;function Ro(){this._arr=[],this._keyIndices={}}Ro.prototype.size=function(){return this._arr.length},Ro.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},Ro.prototype.has=function(t){return _o.has(this._keyIndices,t)},Ro.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},Ro.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},Ro.prototype.add=function(t,e){var i=this._keyIndices;if(t=String(t),!_o.has(i,t)){var s=this._arr,n=s.length;return i[t]=n,s.push({key:t,priority:e}),this._decrease(n),!0}return!1},Ro.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},Ro.prototype.decrease=function(t,e){var i=this._keyIndices[t];if(e>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+e);this._arr[i].priority=e,this._decrease(i)},Ro.prototype._heapify=function(t){var e=this._arr,i=2*t,s=i+1,n=t;i<e.length&&(n=e[i].priority<e[n].priority?i:n,s<e.length&&(n=e[s].priority<e[n].priority?s:n),n!==t&&(this._swap(t,n),this._heapify(n)))},Ro.prototype._decrease=function(t){for(var e,i=this._arr,s=i[t].priority;0!==t&&!(i[e=t>>1].priority<s);)this._swap(t,e),t=e},Ro.prototype._swap=function(t,e){var i=this._arr,s=this._keyIndices,n=i[t],r=i[e];i[t]=r,i[e]=n,s[r.key]=t,s[n.key]=e};var Mo=function(t,e,i,s){return function(t,e,i,s){var n,r,a={},o=new Oo,h=function(t){var e=t.v!==n?t.v:t.w,s=a[e],h=i(t),l=r.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+h);l<s.distance&&(s.distance=l,s.predecessor=n,o.decrease(e,l))};t.nodes().forEach((function(t){var i=t===e?0:Number.POSITIVE_INFINITY;a[t]={distance:i},o.add(t,i)}));for(;o.size()>0&&(n=o.removeMin(),(r=a[n]).distance!==Number.POSITIVE_INFINITY);)s(n).forEach(h);return a}(t,String(e),i||No,s||function(e){return t.outEdges(e)})},No=_o.constant(1);var Po=function(t,e,i){return _o.transform(t.nodes(),(function(s,n){s[n]=Mo(t,n,e,i)}),{})};var Fo=function(t){var e=0,i=[],s={},n=[];function r(a){var o=s[a]={onStack:!0,lowlink:e,index:e++};if(i.push(a),t.successors(a).forEach((function(t){_o.has(s,t)?s[t].onStack&&(o.lowlink=Math.min(o.lowlink,s[t].index)):(r(t),o.lowlink=Math.min(o.lowlink,s[t].lowlink))})),o.lowlink===o.index){var h,l=[];do{h=i.pop(),s[h].onStack=!1,l.push(h)}while(a!==h);n.push(l)}}return t.nodes().forEach((function(t){_o.has(s,t)||r(t)})),n};var Bo=function(t){return _o.filter(Fo(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};var Lo=function(t,e,i){return function(t,e,i){var s={},n=t.nodes();return n.forEach((function(t){s[t]={},s[t][t]={distance:0},n.forEach((function(e){t!==e&&(s[t][e]={distance:Number.POSITIVE_INFINITY})})),i(t).forEach((function(i){var n=i.v===t?i.w:i.v,r=e(i);s[t][n]={distance:r,predecessor:t}}))})),n.forEach((function(t){var e=s[t];n.forEach((function(i){var r=s[i];n.forEach((function(i){var s=r[t],n=e[i],a=r[i],o=s.distance+n.distance;o<a.distance&&(a.distance=o,a.predecessor=n.predecessor)}))}))})),s}(t,e||Do,i||function(e){return t.outEdges(e)})},Do=_o.constant(1);var jo=Vo;function Vo(t){var e={},i={},s=[];if(_o.each(t.sinks(),(function n(r){if(_o.has(i,r))throw new Go;_o.has(e,r)||(i[r]=!0,e[r]=!0,_o.each(t.predecessors(r),n),delete i[r],s.push(r))})),_o.size(e)!==t.nodeCount())throw new Go;return s}function Go(){}Vo.CycleException=Go,Go.prototype=new Error;var zo=function(t,e,i){_o.isArray(e)||(e=[e]);var s=(t.isDirected()?t.successors:t.neighbors).bind(t),n=[],r={};return _o.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);Wo(t,e,"post"===i,r,s,n)})),n};function Wo(t,e,i,s,n,r){_o.has(s,e)||(s[e]=!0,i||r.push(e),_o.each(n(e),(function(e){Wo(t,e,i,s,n,r)})),i&&r.push(e))}var Uo,qo={components:Io,dijkstra:Mo,dijkstraAll:Po,findCycles:Bo,floydWarshall:Lo,isAcyclic:function(t){try{jo(t)}catch(t){if(t instanceof jo.CycleException)return!1;throw t}return!0},postorder:function(t,e){return zo(t,e,"post")},preorder:function(t,e){return zo(t,e,"pre")},prim:function(t,e){var i,s=new mo,n={},r=new Oo;function a(t){var s=t.v===i?t.w:t.v,a=r.priority(s);if(void 0!==a){var o=e(t);o<a&&(n[s]=i,r.decrease(s,o))}}if(0===t.nodeCount())return s;_o.each(t.nodes(),(function(t){r.add(t,Number.POSITIVE_INFINITY),s.setNode(t)})),r.decrease(t.nodes()[0],0);var o=!1;for(;r.size()>0;){if(i=r.removeMin(),_o.has(n,i))s.setEdge(i,n[i]);else{if(o)throw new Error("Input graph is not connected: "+t);o=!0}t.nodeEdges(i).forEach(a)}return s},tarjan:Fo,topsort:jo},Yo={Graph:So.Graph,json:Eo,alg:qo,version:So.version};try{Uo=Yo}catch(t){}Uo||(Uo=window.graphlib);var Jo=Uo;var Ho=function(t){return ar(t,5)};var $o=function(t,e,i){if(!Oi(i))return!1;var s=typeof e;return!!("number"==s?$s(i)&&Ns(e,i.length):"string"==s&&e in i)&&ni(i[e],t)},Zo=Object.prototype,Ko=Zo.hasOwnProperty,Xo=to((function(t,e){t=Object(t);var i=-1,s=e.length,n=s>2?e[2]:void 0;for(n&&$o(e[0],e[1],n)&&(s=1);++i<s;)for(var r=e[i],a=en(r),o=-1,h=a.length;++o<h;){var l=a[o],c=t[l];(void 0===c||ni(c,Zo[l])&&!Ko.call(t,l))&&(t[l]=r[l])}return t}));var Qo=function(t){return function(e,i,s){var n=Object(e);if(!$s(e)){var r=fa(i);e=Zs(e),i=function(t){return r(n[t],t,n)}}var a=t(e,i,s);return a>-1?n[r?e[a]:a]:void 0}},th=/\s/;var eh=function(t){for(var e=t.length;e--&&th.test(t.charAt(e)););return e},ih=/^\s+/;var sh=function(t){return t?t.slice(0,eh(t)+1).replace(ih,""):t},nh=/^[-+]0x[0-9a-f]+$/i,rh=/^0b[01]+$/i,ah=/^0o[0-7]+$/i,oh=parseInt;var hh=function(t){if("number"==typeof t)return t;if(zr(t))return NaN;if(Oi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Oi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=sh(t);var i=rh.test(t);return i||ah.test(t)?oh(t.slice(2),i?2:8):nh.test(t)?NaN:+t},lh=1/0;var ch=function(t){return t?(t=hh(t))===lh||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var dh=function(t){var e=ch(t),i=e%1;return e==e?i?e-i:e:0},uh=Math.max;var fh=Qo((function(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var n=null==i?0:dh(i);return n<0&&(n=uh(s+n,0)),eo(t,fa(e),n)}));var ph=function(t){return(null==t?0:t.length)?Ja(t,1):[]};var gh=function(t,e){return null==t?t:lr(t,fr(e),en)};var _h=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};var mh=function(t,e){var i={};return e=fa(e),cr(t,(function(t,s,n){ys(i,s,e(t,s,n))})),i};var yh=function(t,e,i){for(var s=-1,n=t.length;++s<n;){var r=t[s],a=e(r);if(null!=a&&(void 0===o?a==a&&!zr(a):i(a,o)))var o=a,h=r}return h};var vh=function(t,e){return t>e};var bh=function(t){return t&&t.length?yh(t,ur,vh):void 0};var xh=function(t,e,i){(void 0!==i&&!ni(t[e],i)||void 0===i&&!(e in t))&&ys(t,e,i)},wh=Function.prototype,kh=Object.prototype,Ch=wh.toString,Sh=kh.hasOwnProperty,Eh=Ch.call(Object);var Th=function(t){if(!ks(t)||"[object Object]"!=Ii(t))return!1;var e=fn(t);if(null===e)return!0;var i=Sh.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Ch.call(i)==Eh};var Ah=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Ih=function(t){return xs(t,en(t))};
178
178
  /**
179
179
  * A specialized version of `baseMerge` for arrays and objects which performs
180
180
  * deep merges and tracks traversed objects enabling objects with circular
@@ -189,11 +189,11 @@ function(t,e,i){return e=Ja(void 0===e?t.length-1:e,0),function(){for(var s=argu
189
189
  * @param {Function} [customizer] The function to customize assigned values.
190
190
  * @param {Object} [stack] Tracks traversed source values and their merged
191
191
  * counterparts.
192
- */var Ah=function(t,e,i,s,n,r,a){var o=Eh(t,i),h=Eh(e,i),l=a.get(h);if(l)vh(t,i,l);else{var c=r?r(o,h,i+"",t,e,a):void 0,d=void 0===c;if(d){var u=Ts(h),f=!u&&Is(h),p=!u&&!f&&Ds(h);c=h,u||f||p?Ts(o)?c=o:ho(o)?c=sn(o):f?(d=!1,c=en(h,!0)):p?(d=!1,c=Wn(h,!0)):c=[]:Sh(h)||Es(h)?(c=o,Es(o)?c=Th(o):Ai(o)&&!Oi(o)||(c=Jn(h))):d=!1}d&&(a.set(h,c),n(c,h,s,r,a),a.delete(h)),vh(t,i,c)}};var Ih=function t(e,i,s,n,r){e!==i&&or(i,(function(a,o){if(r||(r=new fs),Ai(a))Ah(e,i,o,s,t,n,r);else{var h=n?n(Eh(e,o),a,o+"",e,i,r):void 0;void 0===h&&(h=a),vh(e,o,h)}}),Qs)};var Oh=function(t){return Xa((function(e,i){var s=-1,n=i.length,r=n>1?i[n-1]:void 0,a=n>2?i[2]:void 0;for(r=t.length>3&&"function"==typeof r?(n--,r):void 0,a&&Jo(i[0],i[1],a)&&(r=n<3?void 0:r,n=1),e=Object(e);++s<n;){var o=i[s];o&&t(e,o,s,r)}return e}))}((function(t,e,i){Ih(t,e,i)}));var Rh=function(t,e){return t<e};var Mh=function(t){return t&&t.length?_h(t,cr,Rh):void 0};var Nh=function(t,e){return t&&t.length?_h(t,da(e),Rh):void 0},Ph=function(){return mi.Date.now()};var Fh=function(t,e,i,s){if(!Ai(t))return t;for(var n=-1,r=(e=ta(e,t)).length,a=r-1,o=t;null!=o&&++n<r;){var h=ea(e[n]),l=i;if("__proto__"===h||"constructor"===h||"prototype"===h)return t;if(n!=a){var c=o[h];void 0===(l=s?s(c,h,o):void 0)&&(l=Ai(c)?c:Rs(e[n+1])?[]:{})}ys(o,h,l),o=o[h]}return t};var Bh=function(t,e,i){for(var s=-1,n=e.length,r={};++s<n;){var a=e[s],o=ia(t,a);i(o,a)&&Fh(r,ta(a,t),o)}return r};var Lh=function(t,e){return Bh(t,e,(function(e,i){return aa(t,i)}))};
192
+ */var Oh=function(t,e,i,s,n,r,a){var o=Ah(t,i),h=Ah(e,i),l=a.get(h);if(l)xh(t,i,l);else{var c=r?r(o,h,i+"",t,e,a):void 0,d=void 0===c;if(d){var u=Is(h),f=!u&&Rs(h),p=!u&&!f&&Vs(h);c=h,u||f||p?Is(o)?c=o:co(o)?c=rn(o):f?(d=!1,c=nn(h,!0)):p?(d=!1,c=qn(h,!0)):c=[]:Th(h)||As(h)?(c=o,As(o)?c=Ih(o):Oi(o)&&!Mi(o)||(c=$n(h))):d=!1}d&&(a.set(h,c),n(c,h,s,r,a),a.delete(h)),xh(t,i,c)}};var Rh=function t(e,i,s,n,r){e!==i&&lr(i,(function(a,o){if(r||(r=new gs),Oi(a))Oh(e,i,o,s,t,n,r);else{var h=n?n(Ah(e,o),a,o+"",e,i,r):void 0;void 0===h&&(h=a),xh(e,o,h)}}),en)};var Mh=function(t){return to((function(e,i){var s=-1,n=i.length,r=n>1?i[n-1]:void 0,a=n>2?i[2]:void 0;for(r=t.length>3&&"function"==typeof r?(n--,r):void 0,a&&$o(i[0],i[1],a)&&(r=n<3?void 0:r,n=1),e=Object(e);++s<n;){var o=i[s];o&&t(e,o,s,r)}return e}))}((function(t,e,i){Rh(t,e,i)}));var Nh=function(t,e){return t<e};var Ph=function(t){return t&&t.length?yh(t,ur,Nh):void 0};var Fh=function(t,e){return t&&t.length?yh(t,fa(e),Nh):void 0},Bh=function(){return vi.Date.now()};var Lh=function(t,e,i,s){if(!Oi(t))return t;for(var n=-1,r=(e=ia(e,t)).length,a=r-1,o=t;null!=o&&++n<r;){var h=sa(e[n]),l=i;if("__proto__"===h||"constructor"===h||"prototype"===h)return t;if(n!=a){var c=o[h];void 0===(l=s?s(c,h,o):void 0)&&(l=Oi(c)?c:Ns(e[n+1])?[]:{})}bs(o,h,l),o=o[h]}return t};var Dh=function(t,e,i){for(var s=-1,n=e.length,r={};++s<n;){var a=e[s],o=na(t,a);i(o,a)&&Lh(r,ia(a,t),o)}return r};var jh=function(t,e){return Dh(t,e,(function(e,i){return ha(t,i)}))};
193
193
  /**
194
194
  * A specialized version of `baseRest` which flattens the rest array.
195
195
  *
196
196
  * @private
197
197
  * @param {Function} func The function to apply a rest parameter to.
198
198
  * @returns {Function} Returns the new function.
199
- */var Dh=function(t){return Ka(Ha(t,void 0,uh),t+"")}((function(t,e){return null==t?{}:Lh(t,e)})),jh=Math.ceil,Vh=Math.max;var Gh=function(t,e,i,s){for(var n=-1,r=Vh(jh((e-t)/(i||1)),0),a=Array(r);r--;)a[s?r:++n]=t,t+=i;return a};var zh=function(t){return function(e,i,s){return s&&"number"!=typeof s&&Jo(e,i,s)&&(i=s=void 0),e=hh(e),void 0===i?(i=e,e=0):i=hh(i),s=void 0===s?e<i?1:-1:hh(s),Gh(e,i,s,t)}}();var Wh=function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t};var Uh=function(t,e){if(t!==e){var i=void 0!==t,s=null===t,n=t==t,r=Vr(t),a=void 0!==e,o=null===e,h=e==e,l=Vr(e);if(!o&&!l&&!r&&t>e||r&&a&&h&&!o&&!l||s&&a&&h||!i&&h||!n)return 1;if(!s&&!r&&!l&&t<e||l&&i&&n&&!s&&!r||o&&i&&n||!a&&n||!h)return-1}return 0};var qh=function(t,e,i){for(var s=-1,n=t.criteria,r=e.criteria,a=n.length,o=i.length;++s<a;){var h=Uh(n[s],r[s]);if(h)return s>=o?h:h*("desc"==i[s]?-1:1)}return t.index-e.index};var Yh=function(t,e,i){e=e.length?$r(e,(function(t){return Ts(t)?function(e){return ia(e,1===t.length?t[0]:t)}:t})):[cr];var s=-1;e=$r(e,Fs(da));var n=va(t,(function(t,i,n){return{criteria:$r(e,(function(e){return e(t)})),index:++s,value:t}}));return Wh(n,(function(t,e){return qh(t,e,i)}))},Jh=Xa((function(t,e){if(null==t)return[];var i=e.length;return i>1&&Jo(t,e[0],e[1])?e=[]:i>2&&Jo(e[0],e[1],e[2])&&(e=[e[0]]),Yh(t,qa(e,1),[])})),Hh=0;var $h=function(t){var e=++Hh;return Qr(t)+e};var Zh=function(t,e,i){for(var s=-1,n=t.length,r=e.length,a={};++s<n;){var o=s<r?e[s]:void 0;i(a,t[s],o)}return a};var Kh,Xh=function(t,e){return Zh(t||[],e||[],ys)};try{Kh={cloneDeep:Yo,constant:ar,defaults:Zo,each:fr,filter:ua,find:dh,flatten:uh,forEach:ur,forIn:fh,has:ga,isUndefined:ya,last:ph,map:ba,mapValues:gh,max:yh,merge:Oh,min:Mh,minBy:Nh,now:Ph,pick:Dh,range:zh,reduce:ka,sortBy:Jh,uniqueId:$h,values:fo,zipObject:Xh}}catch(t){}Kh||(Kh=window._);var Qh=Kh,tl=el;function el(){var t={};t._next=t._prev=t,this._sentinel=t}function il(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function sl(t,e){if("_next"!==t&&"_prev"!==t)return e}el.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return il(e),e},el.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&il(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},el.prototype.toString=function(){for(var t=[],e=this._sentinel,i=e._prev;i!==e;)t.push(JSON.stringify(i,sl)),i=i._prev;return"["+t.join(", ")+"]"};var nl=qo.Graph,rl=function(t,e){if(t.nodeCount()<=1)return[];var i=function(t,e){var i=new nl,s=0,n=0;Qh.forEach(t.nodes(),(function(t){i.setNode(t,{v:t,in:0,out:0})})),Qh.forEach(t.edges(),(function(t){var r=i.edge(t.v,t.w)||0,a=e(t),o=r+a;i.setEdge(t.v,t.w,o),n=Math.max(n,i.node(t.v).out+=a),s=Math.max(s,i.node(t.w).in+=a)}));var r=Qh.range(n+s+3).map((function(){return new tl})),a=s+1;return Qh.forEach(i.nodes(),(function(t){hl(r,a,i.node(t))})),{graph:i,buckets:r,zeroIdx:a}}(t,e||al),s=function(t,e,i){var s,n=[],r=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;s=a.dequeue();)ol(t,e,i,s);for(;s=r.dequeue();)ol(t,e,i,s);if(t.nodeCount())for(var o=e.length-2;o>0;--o)if(s=e[o].dequeue()){n=n.concat(ol(t,e,i,s,!0));break}}return n}(i.graph,i.buckets,i.zeroIdx);return Qh.flatten(Qh.map(s,(function(e){return t.outEdges(e.v,e.w)})),!0)},al=Qh.constant(1);function ol(t,e,i,s,n){var r=n?[]:void 0;return Qh.forEach(t.inEdges(s.v),(function(s){var a=t.edge(s),o=t.node(s.v);n&&r.push({v:s.v,w:s.w}),o.out-=a,hl(e,i,o)})),Qh.forEach(t.outEdges(s.v),(function(s){var n=t.edge(s),r=s.w,a=t.node(r);a.in-=n,hl(e,i,a)})),t.removeNode(s.v),r}function hl(t,e,i){i.out?i.in?t[i.out-i.in+e].enqueue(i):t[t.length-1].enqueue(i):t[0].enqueue(i)}var ll={run:function(t){var e="greedy"===t.graph().acyclicer?rl(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],i={},s={};function n(r){Qh.has(s,r)||(s[r]=!0,i[r]=!0,Qh.forEach(t.outEdges(r),(function(t){Qh.has(i,t.w)?e.push(t):n(t.w)})),delete i[r])}return Qh.forEach(t.nodes(),n),e}(t);Qh.forEach(e,(function(e){var i=t.edge(e);t.removeEdge(e),i.forwardName=e.name,i.reversed=!0,t.setEdge(e.w,e.v,i,Qh.uniqueId("rev"))}))},undo:function(t){Qh.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.reversed){t.removeEdge(e);var s=i.forwardName;delete i.reversed,delete i.forwardName,t.setEdge(e.w,e.v,i,s)}}))}};var cl=qo.Graph,dl={addDummyNode:ul,simplify:function(t){var e=(new cl).setGraph(t.graph());return Qh.forEach(t.nodes(),(function(i){e.setNode(i,t.node(i))})),Qh.forEach(t.edges(),(function(i){var s=e.edge(i.v,i.w)||{weight:0,minlen:1},n=t.edge(i);e.setEdge(i.v,i.w,{weight:s.weight+n.weight,minlen:Math.max(s.minlen,n.minlen)})})),e},asNonCompoundGraph:function(t){var e=new cl({multigraph:t.isMultigraph()}).setGraph(t.graph());return Qh.forEach(t.nodes(),(function(i){t.children(i).length||e.setNode(i,t.node(i))})),Qh.forEach(t.edges(),(function(i){e.setEdge(i,t.edge(i))})),e},successorWeights:function(t){var e=Qh.map(t.nodes(),(function(e){var i={};return Qh.forEach(t.outEdges(e),(function(e){i[e.w]=(i[e.w]||0)+t.edge(e).weight})),i}));return Qh.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=Qh.map(t.nodes(),(function(e){var i={};return Qh.forEach(t.inEdges(e),(function(e){i[e.v]=(i[e.v]||0)+t.edge(e).weight})),i}));return Qh.zipObject(t.nodes(),e)},intersectRect:function(t,e){var i,s,n=t.x,r=t.y,a=e.x-n,o=e.y-r,h=t.width/2,l=t.height/2;if(!a&&!o)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(o)*h>Math.abs(a)*l?(o<0&&(l=-l),i=l*a/o,s=l):(a<0&&(h=-h),i=h,s=h*o/a);return{x:n+i,y:r+s}},buildLayerMatrix:function(t){var e=Qh.map(Qh.range(fl(t)+1),(function(){return[]}));return Qh.forEach(t.nodes(),(function(i){var s=t.node(i),n=s.rank;Qh.isUndefined(n)||(e[n][s.order]=i)})),e},normalizeRanks:function(t){var e=Qh.min(Qh.map(t.nodes(),(function(e){return t.node(e).rank})));Qh.forEach(t.nodes(),(function(i){var s=t.node(i);Qh.has(s,"rank")&&(s.rank-=e)}))},removeEmptyRanks:function(t){var e=Qh.min(Qh.map(t.nodes(),(function(e){return t.node(e).rank}))),i=[];Qh.forEach(t.nodes(),(function(s){var n=t.node(s).rank-e;i[n]||(i[n]=[]),i[n].push(s)}));var s=0,n=t.graph().nodeRankFactor;Qh.forEach(i,(function(e,i){Qh.isUndefined(e)&&i%n!=0?--s:s&&Qh.forEach(e,(function(e){t.node(e).rank+=s}))}))},addBorderNode:function(t,e,i,s){var n={width:0,height:0};arguments.length>=4&&(n.rank=i,n.order=s);return ul(t,"border",n,e)},maxRank:fl,partition:function(t,e){var i={lhs:[],rhs:[]};return Qh.forEach(t,(function(t){e(t)?i.lhs.push(t):i.rhs.push(t)})),i},time:function(t,e){var i=Qh.now();try{return e()}finally{console.log(t+" time: "+(Qh.now()-i)+"ms")}},notime:function(t,e){return e()}};function ul(t,e,i,s){var n;do{n=Qh.uniqueId(s)}while(t.hasNode(n));return i.dummy=e,t.setNode(n,i),n}function fl(t){return Qh.max(Qh.map(t.nodes(),(function(e){var i=t.node(e).rank;if(!Qh.isUndefined(i))return i})))}var pl={run:function(t){t.graph().dummyChains=[],Qh.forEach(t.edges(),(function(e){!function(t,e){var i,s,n,r=e.v,a=t.node(r).rank,o=e.w,h=t.node(o).rank,l=e.name,c=t.edge(e),d=c.labelRank;if(h===a+1)return;for(t.removeEdge(e),n=0,++a;a<h;++n,++a)c.points=[],s={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},i=dl.addDummyNode(t,"edge",s,"_d"),a===d&&(s.width=c.width,s.height=c.height,s.dummy="edge-label",s.labelpos=c.labelpos),t.setEdge(r,i,{weight:c.weight},l),0===n&&t.graph().dummyChains.push(i),r=i;t.setEdge(r,o,{weight:c.weight},l)}(t,e)}))},undo:function(t){Qh.forEach(t.graph().dummyChains,(function(e){var i,s=t.node(e),n=s.edgeLabel;for(t.setEdge(s.edgeObj,n);s.dummy;)i=t.successors(e)[0],t.removeNode(e),n.points.push({x:s.x,y:s.y}),"edge-label"===s.dummy&&(n.x=s.x,n.y=s.y,n.width=s.width,n.height=s.height),e=i,s=t.node(e)}))}};var gl=function(t){var e={};Qh.forEach(t.sources(),(function i(s){var n=t.node(s);if(Qh.has(e,s))return n.rank;e[s]=!0;var r=Qh.min(Qh.map(t.outEdges(s),(function(e){return i(e.w)-t.edge(e).minlen})));return r!==Number.POSITIVE_INFINITY&&null!=r||(r=0),n.rank=r}))},_l=function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen};var ml=qo.Graph,yl=_l,vl=function(t){var e,i,s=new ml({directed:!1}),n=t.nodes()[0],r=t.nodeCount();s.setNode(n,{});for(;bl(s,t)<r;)e=xl(s,t),i=s.hasNode(e.v)?yl(t,e):-yl(t,e),wl(s,t,i);return s};function bl(t,e){return Qh.forEach(t.nodes(),(function i(s){Qh.forEach(e.nodeEdges(s),(function(n){var r=n.v,a=s===r?n.w:r;t.hasNode(a)||yl(e,n)||(t.setNode(a,{}),t.setEdge(s,a,{}),i(a))}))})),t.nodeCount()}function xl(t,e){return Qh.minBy(e.edges(),(function(i){if(t.hasNode(i.v)!==t.hasNode(i.w))return yl(e,i)}))}function wl(t,e,i){Qh.forEach(t.nodes(),(function(t){e.node(t).rank+=i}))}var kl=_l,Cl=gl,Sl=qo.alg.preorder,El=qo.alg.postorder,Tl=dl.simplify,Al=Il;function Il(t){t=Tl(t),Cl(t);var e,i=vl(t);for(Ml(i),Ol(i,t);e=Pl(i);)Bl(i,t,e,Fl(i,t,e))}function Ol(t,e){var i=El(t,t.nodes());i=i.slice(0,i.length-1),Qh.forEach(i,(function(i){!function(t,e,i){var s=t.node(i).parent;t.edge(i,s).cutvalue=Rl(t,e,i)}(t,e,i)}))}function Rl(t,e,i){var s=t.node(i).parent,n=!0,r=e.edge(i,s),a=0;return r||(n=!1,r=e.edge(s,i)),a=r.weight,Qh.forEach(e.nodeEdges(i),(function(r){var o,h,l=r.v===i,c=l?r.w:r.v;if(c!==s){var d=l===n,u=e.edge(r).weight;if(a+=d?u:-u,o=i,h=c,t.hasEdge(o,h)){var f=t.edge(i,c).cutvalue;a+=d?-f:f}}})),a}function Ml(t,e){arguments.length<2&&(e=t.nodes()[0]),Nl(t,{},1,e)}function Nl(t,e,i,s,n){var r=i,a=t.node(s);return e[s]=!0,Qh.forEach(t.neighbors(s),(function(n){Qh.has(e,n)||(i=Nl(t,e,i,n,s))})),a.low=r,a.lim=i++,n?a.parent=n:delete a.parent,i}function Pl(t){return Qh.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function Fl(t,e,i){var s=i.v,n=i.w;e.hasEdge(s,n)||(s=i.w,n=i.v);var r=t.node(s),a=t.node(n),o=r,h=!1;r.lim>a.lim&&(o=a,h=!0);var l=Qh.filter(e.edges(),(function(e){return h===Ll(t,t.node(e.v),o)&&h!==Ll(t,t.node(e.w),o)}));return Qh.minBy(l,(function(t){return kl(e,t)}))}function Bl(t,e,i,s){var n=i.v,r=i.w;t.removeEdge(n,r),t.setEdge(s.v,s.w,{}),Ml(t),Ol(t,e),function(t,e){var i=Qh.find(t.nodes(),(function(t){return!e.node(t).parent})),s=Sl(t,i);s=s.slice(1),Qh.forEach(s,(function(i){var s=t.node(i).parent,n=e.edge(i,s),r=!1;n||(n=e.edge(s,i),r=!0),e.node(i).rank=e.node(s).rank+(r?n.minlen:-n.minlen)}))}(t,e)}function Ll(t,e,i){return i.low<=e.lim&&e.lim<=i.lim}Il.initLowLimValues=Ml,Il.initCutValues=Ol,Il.calcCutValue=Rl,Il.leaveEdge=Pl,Il.enterEdge=Fl,Il.exchangeEdges=Bl;var Dl=gl,jl=function(t){switch(t.graph().ranker){case"network-simplex":Gl(t);break;case"tight-tree":!function(t){Dl(t),vl(t)}(t);break;case"longest-path":Vl(t);break;default:Gl(t)}};var Vl=Dl;function Gl(t){Al(t)}var zl=function(t){var e=function(t){var e={},i=0;function s(n){var r=i;Qh.forEach(t.children(n),s),e[n]={low:r,lim:i++}}return Qh.forEach(t.children(),s),e}(t);Qh.forEach(t.graph().dummyChains,(function(i){for(var s=t.node(i),n=s.edgeObj,r=function(t,e,i,s){var n,r,a=[],o=[],h=Math.min(e[i].low,e[s].low),l=Math.max(e[i].lim,e[s].lim);n=i;do{n=t.parent(n),a.push(n)}while(n&&(e[n].low>h||l>e[n].lim));r=n,n=s;for(;(n=t.parent(n))!==r;)o.push(n);return{path:a.concat(o.reverse()),lca:r}}(t,e,n.v,n.w),a=r.path,o=r.lca,h=0,l=a[h],c=!0;i!==n.w;){if(s=t.node(i),c){for(;(l=a[h])!==o&&t.node(l).maxRank<s.rank;)h++;l===o&&(c=!1)}if(!c){for(;h<a.length-1&&t.node(l=a[h+1]).minRank<=s.rank;)h++;l=a[h]}t.setParent(i,l),i=t.successors(i)[0]}}))};var Wl={run:function(t){var e=dl.addDummyNode(t,"root",{},"_root"),i=function(t){var e={};function i(s,n){var r=t.children(s);r&&r.length&&Qh.forEach(r,(function(t){i(t,n+1)})),e[s]=n}return Qh.forEach(t.children(),(function(t){i(t,1)})),e}(t),s=Qh.max(Qh.values(i))-1,n=2*s+1;t.graph().nestingRoot=e,Qh.forEach(t.edges(),(function(e){t.edge(e).minlen*=n}));var r=function(t){return Qh.reduce(t.edges(),(function(e,i){return e+t.edge(i).weight}),0)}(t)+1;Qh.forEach(t.children(),(function(a){Ul(t,e,n,r,s,i,a)})),t.graph().nodeRankFactor=n},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,Qh.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function Ul(t,e,i,s,n,r,a){var o=t.children(a);if(o.length){var h=dl.addBorderNode(t,"_bt"),l=dl.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(h,a),c.borderTop=h,t.setParent(l,a),c.borderBottom=l,Qh.forEach(o,(function(o){Ul(t,e,i,s,n,r,o);var c=t.node(o),d=c.borderTop?c.borderTop:o,u=c.borderBottom?c.borderBottom:o,f=c.borderTop?s:2*s,p=d!==u?1:n-r[a]+1;t.setEdge(h,d,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(u,l,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,h,{weight:0,minlen:n+r[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:i})}var ql=function(t){Qh.forEach(t.children(),(function e(i){var s=t.children(i),n=t.node(i);if(s.length&&Qh.forEach(s,e),Qh.has(n,"minRank")){n.borderLeft=[],n.borderRight=[];for(var r=n.minRank,a=n.maxRank+1;r<a;++r)Yl(t,"borderLeft","_bl",i,n,r),Yl(t,"borderRight","_br",i,n,r)}}))};function Yl(t,e,i,s,n,r){var a={width:0,height:0,rank:r,borderType:e},o=n[e][r-1],h=dl.addDummyNode(t,"border",a,i);n[e][r]=h,t.setParent(h,s),o&&t.setEdge(o,h,{weight:1})}var Jl={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||Hl(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){Qh.forEach(t.nodes(),(function(e){Zl(t.node(e))})),Qh.forEach(t.edges(),(function(e){var i=t.edge(e);Qh.forEach(i.points,Zl),Qh.has(i,"y")&&Zl(i)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){Qh.forEach(t.nodes(),(function(e){Kl(t.node(e))})),Qh.forEach(t.edges(),(function(e){var i=t.edge(e);Qh.forEach(i.points,Kl),Qh.has(i,"x")&&Kl(i)}))}(t),Hl(t))}};function Hl(t){Qh.forEach(t.nodes(),(function(e){$l(t.node(e))})),Qh.forEach(t.edges(),(function(e){$l(t.edge(e))}))}function $l(t){var e=t.width;t.width=t.height,t.height=e}function Zl(t){t.y=-t.y}function Kl(t){var e=t.x;t.x=t.y,t.y=e}var Xl=function(t){var e={},i=Qh.filter(t.nodes(),(function(e){return!t.children(e).length})),s=Qh.max(Qh.map(i,(function(e){return t.node(e).rank}))),n=Qh.map(Qh.range(s+1),(function(){return[]}));function r(i){if(!Qh.has(e,i)){e[i]=!0;var s=t.node(i);n[s.rank].push(i),Qh.forEach(t.successors(i),r)}}var a=Qh.sortBy(i,(function(e){return t.node(e).rank}));return Qh.forEach(a,r),n};var Ql=function(t,e){for(var i=0,s=1;s<e.length;++s)i+=tc(t,e[s-1],e[s]);return i};function tc(t,e,i){for(var s=Qh.zipObject(i,Qh.map(i,(function(t,e){return e}))),n=Qh.flatten(Qh.map(e,(function(e){return Qh.sortBy(Qh.map(t.outEdges(e),(function(e){return{pos:s[e.w],weight:t.edge(e).weight}})),"pos")})),!0),r=1;r<i.length;)r<<=1;var a=2*r-1;r-=1;var o=Qh.map(new Array(a),(function(){return 0})),h=0;return Qh.forEach(n.forEach((function(t){var e=t.pos+r;o[e]+=t.weight;for(var i=0;e>0;)e%2&&(i+=o[e+1]),o[e=e-1>>1]+=t.weight;h+=t.weight*i}))),h}var ec=function(t,e){return Qh.map(e,(function(e){var i=t.inEdges(e);if(i.length){var s=Qh.reduce(i,(function(e,i){var s=t.edge(i),n=t.node(i.v);return{sum:e.sum+s.weight*n.order,weight:e.weight+s.weight}}),{sum:0,weight:0});return{v:e,barycenter:s.sum/s.weight,weight:s.weight}}return{v:e}}))};var ic=function(t,e){var i={};return Qh.forEach(t,(function(t,e){var s=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};Qh.isUndefined(t.barycenter)||(s.barycenter=t.barycenter,s.weight=t.weight)})),Qh.forEach(e.edges(),(function(t){var e=i[t.v],s=i[t.w];Qh.isUndefined(e)||Qh.isUndefined(s)||(s.indegree++,e.out.push(i[t.w]))})),function(t){var e=[];function i(t){return function(e){e.merged||(Qh.isUndefined(e.barycenter)||Qh.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var i=0,s=0;t.weight&&(i+=t.barycenter*t.weight,s+=t.weight);e.weight&&(i+=e.barycenter*e.weight,s+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=i/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function s(e){return function(i){i.in.push(e),0==--i.indegree&&t.push(i)}}for(;t.length;){var n=t.pop();e.push(n),Qh.forEach(n.in.reverse(),i(n)),Qh.forEach(n.out,s(n))}return Qh.map(Qh.filter(e,(function(t){return!t.merged})),(function(t){return Qh.pick(t,["vs","i","barycenter","weight"])}))}(Qh.filter(i,(function(t){return!t.indegree})))};var sc=function(t,e){var i=dl.partition(t,(function(t){return Qh.has(t,"barycenter")})),s=i.lhs,n=Qh.sortBy(i.rhs,(function(t){return-t.i})),r=[],a=0,o=0,h=0;s.sort((l=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:l?e.i-t.i:t.i-e.i})),h=nc(r,n,h),Qh.forEach(s,(function(t){h+=t.vs.length,r.push(t.vs),a+=t.barycenter*t.weight,o+=t.weight,h=nc(r,n,h)}));var l;var c={vs:Qh.flatten(r,!0)};o&&(c.barycenter=a/o,c.weight=o);return c};function nc(t,e,i){for(var s;e.length&&(s=Qh.last(e)).i<=i;)e.pop(),t.push(s.vs),i++;return i}var rc=function t(e,i,s,n){var r=e.children(i),a=e.node(i),o=a?a.borderLeft:void 0,h=a?a.borderRight:void 0,l={};o&&(r=Qh.filter(r,(function(t){return t!==o&&t!==h})));var c=ec(e,r);Qh.forEach(c,(function(i){if(e.children(i.v).length){var r=t(e,i.v,s,n);l[i.v]=r,Qh.has(r,"barycenter")&&(a=i,o=r,Qh.isUndefined(a.barycenter)?(a.barycenter=o.barycenter,a.weight=o.weight):(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight))}var a,o}));var d=ic(c,s);!function(t,e){Qh.forEach(t,(function(t){t.vs=Qh.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(d,l);var u=sc(d,n);if(o&&(u.vs=Qh.flatten([o,u.vs,h],!0),e.predecessors(o).length)){var f=e.node(e.predecessors(o)[0]),p=e.node(e.predecessors(h)[0]);Qh.has(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+f.order+p.order)/(u.weight+2),u.weight+=2}return u};var ac=qo.Graph,oc=function(t,e,i){var s=function(t){var e;for(;t.hasNode(e=Qh.uniqueId("_root")););return e}(t),n=new ac({compound:!0}).setGraph({root:s}).setDefaultNodeLabel((function(e){return t.node(e)}));return Qh.forEach(t.nodes(),(function(r){var a=t.node(r),o=t.parent(r);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(n.setNode(r),n.setParent(r,o||s),Qh.forEach(t[i](r),(function(e){var i=e.v===r?e.w:e.v,s=n.edge(i,r),a=Qh.isUndefined(s)?0:s.weight;n.setEdge(i,r,{weight:t.edge(e).weight+a})})),Qh.has(a,"minRank")&&n.setNode(r,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),n};var hc=function(t,e,i){var s,n={};Qh.forEach(i,(function(i){for(var r,a,o=t.parent(i);o;){if((r=t.parent(o))?(a=n[r],n[r]=o):(a=s,s=o),a&&a!==o)return void e.setEdge(a,o);o=r}}))};var lc=qo.Graph,cc=function(t){var e=dl.maxRank(t),i=dc(t,Qh.range(1,e+1),"inEdges"),s=dc(t,Qh.range(e-1,-1,-1),"outEdges"),n=Xl(t);fc(t,n);for(var r,a=Number.POSITIVE_INFINITY,o=0,h=0;h<4;++o,++h){uc(o%2?i:s,o%4>=2),n=dl.buildLayerMatrix(t);var l=Ql(t,n);l<a&&(h=0,r=Qh.cloneDeep(n),a=l)}fc(t,r)};function dc(t,e,i){return Qh.map(e,(function(e){return oc(t,e,i)}))}function uc(t,e){var i=new lc;Qh.forEach(t,(function(t){var s=t.graph().root,n=rc(t,s,i,e);Qh.forEach(n.vs,(function(e,i){t.node(e).order=i})),hc(t,i,n.vs)}))}function fc(t,e){Qh.forEach(e,(function(e){Qh.forEach(e,(function(e,i){t.node(e).order=i}))}))}var pc=qo.Graph,gc=function(t){var e,i=dl.buildLayerMatrix(t),s=Qh.merge(_c(t,i),mc(t,i)),n={};Qh.forEach(["u","d"],(function(r){e="u"===r?i:Qh.values(i).reverse(),Qh.forEach(["l","r"],(function(i){"r"===i&&(e=Qh.map(e,(function(t){return Qh.values(t).reverse()})));var a=("u"===r?t.predecessors:t.successors).bind(t),o=bc(t,e,s,a),h=xc(t,e,o.root,o.align,"r"===i);"r"===i&&(h=Qh.mapValues(h,(function(t){return-t}))),n[r+i]=h}))}));var r=wc(t,n);return kc(n,r),Cc(n,t.graph().align)};function _c(t,e){var i={};return Qh.reduce(e,(function(e,s){var n=0,r=0,a=e.length,o=Qh.last(s);return Qh.forEach(s,(function(e,h){var l=function(t,e){if(t.node(e).dummy)return Qh.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=l?t.node(l).order:a;(l||e===o)&&(Qh.forEach(s.slice(r,h+1),(function(e){Qh.forEach(t.predecessors(e),(function(s){var r=t.node(s),a=r.order;!(a<n||c<a)||r.dummy&&t.node(e).dummy||yc(i,s,e)}))})),r=h+1,n=c)})),s})),i}function mc(t,e){var i={};function s(e,s,n,r,a){var o;Qh.forEach(Qh.range(s,n),(function(s){o=e[s],t.node(o).dummy&&Qh.forEach(t.predecessors(o),(function(e){var s=t.node(e);s.dummy&&(s.order<r||s.order>a)&&yc(i,e,o)}))}))}return Qh.reduce(e,(function(e,i){var n,r=-1,a=0;return Qh.forEach(i,(function(o,h){if("border"===t.node(o).dummy){var l=t.predecessors(o);l.length&&(n=t.node(l[0]).order,s(i,a,h,r,n),a=h,r=n)}s(i,a,i.length,n,e.length)})),i})),i}function yc(t,e,i){if(e>i){var s=e;e=i,i=s}var n=t[e];n||(t[e]=n={}),n[i]=!0}function vc(t,e,i){if(e>i){var s=e;e=i,i=s}return Qh.has(t[e],i)}function bc(t,e,i,s){var n={},r={},a={};return Qh.forEach(e,(function(t){Qh.forEach(t,(function(t,e){n[t]=t,r[t]=t,a[t]=e}))})),Qh.forEach(e,(function(t){var e=-1;Qh.forEach(t,(function(t){var o=s(t);if(o.length)for(var h=((o=Qh.sortBy(o,(function(t){return a[t]}))).length-1)/2,l=Math.floor(h),c=Math.ceil(h);l<=c;++l){var d=o[l];r[t]===t&&e<a[d]&&!vc(i,t,d)&&(r[d]=t,r[t]=n[t]=n[d],e=a[d])}}))})),{root:n,align:r}}function xc(t,e,i,s,n){var r={},a=function(t,e,i,s){var n=new pc,r=t.graph(),a=function(t,e,i){return function(s,n,r){var a,o=s.node(n),h=s.node(r),l=0;if(l+=o.width/2,Qh.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(l+=i?a:-a),a=0,l+=(o.dummy?e:t)/2,l+=(h.dummy?e:t)/2,l+=h.width/2,Qh.has(h,"labelpos"))switch(h.labelpos.toLowerCase()){case"l":a=h.width/2;break;case"r":a=-h.width/2}return a&&(l+=i?a:-a),a=0,l}}(r.nodesep,r.edgesep,s);return Qh.forEach(e,(function(e){var s;Qh.forEach(e,(function(e){var r=i[e];if(n.setNode(r),s){var o=i[s],h=n.edge(o,r);n.setEdge(o,r,Math.max(a(t,e,s),h||0))}s=e}))})),n}(t,e,i,n),o=n?"borderLeft":"borderRight";function h(t,e){for(var i=a.nodes(),s=i.pop(),n={};s;)n[s]?t(s):(n[s]=!0,i.push(s),i=i.concat(e(s))),s=i.pop()}return h((function(t){r[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,r[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),h((function(e){var i=a.outEdges(e).reduce((function(t,e){return Math.min(t,r[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),s=t.node(e);i!==Number.POSITIVE_INFINITY&&s.borderType!==o&&(r[e]=Math.max(r[e],i))}),a.successors.bind(a)),Qh.forEach(s,(function(t){r[t]=r[i[t]]})),r}function wc(t,e){return Qh.minBy(Qh.values(e),(function(e){var i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return Qh.forIn(e,(function(e,n){var r=function(t,e){return t.node(e).width}(t,n)/2;i=Math.max(e+r,i),s=Math.min(e-r,s)})),i-s}))}function kc(t,e){var i=Qh.values(e),s=Qh.min(i),n=Qh.max(i);Qh.forEach(["u","d"],(function(i){Qh.forEach(["l","r"],(function(r){var a,o=i+r,h=t[o];if(h!==e){var l=Qh.values(h);(a="l"===r?s-Qh.min(l):n-Qh.max(l))&&(t[o]=Qh.mapValues(h,(function(t){return t+a})))}}))}))}function Cc(t,e){return Qh.mapValues(t.ul,(function(i,s){if(e)return t[e.toLowerCase()][s];var n=Qh.sortBy(Qh.map(t,s));return(n[1]+n[2])/2}))}var Sc=gc,Ec=function(t){(function(t){var e=dl.buildLayerMatrix(t),i=t.graph().ranksep,s=0;Qh.forEach(e,(function(e){var n=Qh.max(Qh.map(e,(function(e){return t.node(e).height})));Qh.forEach(e,(function(e){t.node(e).y=s+n/2})),s+=n+i}))})(t=dl.asNonCompoundGraph(t)),Qh.forEach(Sc(t),(function(e,i){t.node(i).x=e}))};var Tc=dl.normalizeRanks,Ac=dl.removeEmptyRanks,Ic=dl,Oc=qo.Graph,Rc=function(t,e){var i=e&&e.debugTiming?Ic.time:Ic.notime;i("layout",(function(){var e=i(" buildLayoutGraph",(function(){return function(t){var e=new Oc({multigraph:!0,compound:!0}),i=Gc(t.graph());return e.setGraph(Qh.merge({},Nc,Vc(i,Mc),Qh.pick(i,Pc))),Qh.forEach(t.nodes(),(function(i){var s=Gc(t.node(i));e.setNode(i,Qh.defaults(Vc(s,Fc),Bc)),e.setParent(i,t.parent(i))})),Qh.forEach(t.edges(),(function(i){var s=Gc(t.edge(i));e.setEdge(i,Qh.merge({},Dc,Vc(s,Lc),Qh.pick(s,jc)))})),e}(t)}));i(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,Qh.forEach(t.edges(),(function(i){var s=t.edge(i);s.minlen*=2,"c"!==s.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?s.width+=s.labeloffset:s.height+=s.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){Qh.forEach(t.edges(),(function(e){if(e.v===e.w){var i=t.node(e.v);i.selfEdges||(i.selfEdges=[]),i.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){ll.run(t)})),e(" nestingGraph.run",(function(){Wl.run(t)})),e(" rank",(function(){jl(Ic.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){Qh.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.width&&i.height){var s=t.node(e.v),n={rank:(t.node(e.w).rank-s.rank)/2+s.rank,e:e};Ic.addDummyNode(t,"edge-proxy",n,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){Ac(t)})),e(" nestingGraph.cleanup",(function(){Wl.cleanup(t)})),e(" normalizeRanks",(function(){Tc(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;Qh.forEach(t.nodes(),(function(i){var s=t.node(i);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=Qh.max(e,s.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){Qh.forEach(t.nodes(),(function(e){var i=t.node(e);"edge-proxy"===i.dummy&&(t.edge(i.e).labelRank=i.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){pl.run(t)})),e(" parentDummyChains",(function(){zl(t)})),e(" addBorderSegments",(function(){ql(t)})),e(" order",(function(){cc(t)})),e(" insertSelfEdges",(function(){!function(t){var e=Ic.buildLayerMatrix(t);Qh.forEach(e,(function(e){var i=0;Qh.forEach(e,(function(e,s){var n=t.node(e);n.order=s+i,Qh.forEach(n.selfEdges,(function(e){Ic.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:n.rank,order:s+ ++i,e:e.e,label:e.label},"_se")})),delete n.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){Jl.adjust(t)})),e(" position",(function(){Ec(t)})),e(" positionSelfEdges",(function(){!function(t){Qh.forEach(t.nodes(),(function(e){var i=t.node(e);if("selfedge"===i.dummy){var s=t.node(i.e.v),n=s.x+s.width/2,r=s.y,a=i.x-n,o=s.height/2;t.setEdge(i.e,i.label),t.removeNode(e),i.label.points=[{x:n+2*a/3,y:r-o},{x:n+5*a/6,y:r-o},{x:n+a,y:r},{x:n+5*a/6,y:r+o},{x:n+2*a/3,y:r+o}],i.label.x=i.x,i.label.y=i.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){Qh.forEach(t.nodes(),(function(e){if(t.children(e).length){var i=t.node(e),s=t.node(i.borderTop),n=t.node(i.borderBottom),r=t.node(Qh.last(i.borderLeft)),a=t.node(Qh.last(i.borderRight));i.width=Math.abs(a.x-r.x),i.height=Math.abs(n.y-s.y),i.x=r.x+i.width/2,i.y=s.y+i.height/2}})),Qh.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){pl.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){Qh.forEach(t.edges(),(function(e){var i=t.edge(e);if(Qh.has(i,"x"))switch("l"!==i.labelpos&&"r"!==i.labelpos||(i.width-=i.labeloffset),i.labelpos){case"l":i.x-=i.width/2+i.labeloffset;break;case"r":i.x+=i.width/2+i.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){Jl.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,i=0,s=Number.POSITIVE_INFINITY,n=0,r=t.graph(),a=r.marginx||0,o=r.marginy||0;function h(t){var r=t.x,a=t.y,o=t.width,h=t.height;e=Math.min(e,r-o/2),i=Math.max(i,r+o/2),s=Math.min(s,a-h/2),n=Math.max(n,a+h/2)}Qh.forEach(t.nodes(),(function(e){h(t.node(e))})),Qh.forEach(t.edges(),(function(e){var i=t.edge(e);Qh.has(i,"x")&&h(i)})),e-=a,s-=o,Qh.forEach(t.nodes(),(function(i){var n=t.node(i);n.x-=e,n.y-=s})),Qh.forEach(t.edges(),(function(i){var n=t.edge(i);Qh.forEach(n.points,(function(t){t.x-=e,t.y-=s})),Qh.has(n,"x")&&(n.x-=e),Qh.has(n,"y")&&(n.y-=s)})),r.width=i-e+a,r.height=n-s+o}(t)})),e(" assignNodeIntersects",(function(){!function(t){Qh.forEach(t.edges(),(function(e){var i,s,n=t.edge(e),r=t.node(e.v),a=t.node(e.w);n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=a,s=r),n.points.unshift(Ic.intersectRect(r,i)),n.points.push(Ic.intersectRect(a,s))}))}(t)})),e(" reversePoints",(function(){!function(t){Qh.forEach(t.edges(),(function(e){var i=t.edge(e);i.reversed&&i.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){ll.undo(t)}))}(e,i)})),i(" updateInputGraph",(function(){!function(t,e){Qh.forEach(t.nodes(),(function(i){var s=t.node(i),n=e.node(i);s&&(s.x=n.x,s.y=n.y,e.children(i).length&&(s.width=n.width,s.height=n.height))})),Qh.forEach(t.edges(),(function(i){var s=t.edge(i),n=e.edge(i);s.points=n.points,Qh.has(n,"x")&&(s.x=n.x,s.y=n.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var Mc=["nodesep","edgesep","ranksep","marginx","marginy"],Nc={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Pc=["acyclicer","ranker","rankdir","align"],Fc=["width","height"],Bc={width:0,height:0},Lc=["minlen","weight","width","height","labeloffset"],Dc={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},jc=["labelpos"];function Vc(t,e){return Qh.mapValues(Qh.pick(t,e),Number)}function Gc(t){var e={};return Qh.forEach(t,(function(t,i){e[i.toLowerCase()]=t})),e}var zc=qo.Graph;var Wc={graphlib:qo,layout:Rc,debug:{debugOrdering:function(t){var e=dl.buildLayerMatrix(t),i=new zc({compound:!0,multigraph:!0}).setGraph({});return Qh.forEach(t.nodes(),(function(e){i.setNode(e,{label:e}),i.setParent(e,"layer"+t.node(e).rank)})),Qh.forEach(t.edges(),(function(t){i.setEdge(t.v,t.w,{},t.name)})),Qh.forEach(e,(function(t,e){var s="layer"+e;i.setNode(s,{rank:"same"}),Qh.reduce(t,(function(t,e){return i.setEdge(t,e,{style:"invis"}),e}))})),i}},util:{time:dl.time,notime:dl.notime},version:"0.8.5"},Uc=Wc.graphlib,qc=Wc.layout;class Yc extends q{constructor(t){super(t),this.type=y.Sugiyama,this._width="width"in t?t.width:500,this._height="height"in t?t.height:300,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0}toJSON(){let t={args:{}};return t.type=this.type,t}run(){let t=this.group.children[0].dataScope._dt.graph;if(!t)return;var e=new Uc.Graph;e.setGraph({edgesep:50}),e.setDefaultEdgeLabel((function(){return{}}));let i=new Map;for(let t of this.group.children){let s=t.dataScope.getFieldValue(o);i.set(s,s+""),e.setNode(s,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let i of t.links)e.setEdge(i.source,i.target);qc(e);const s={};let n=Math.min(...e.nodes().map((t=>e.node(t).y))),r=Math.min(...e.nodes().map((t=>e.node(t).x))),a=this._left-r,h=this._top-n;for(const t of e.nodes())s[t]={x:e.node(t).x+a,y:e.node(t).y+h};for(let t of this.group.children){let e=t.dataScope.getFieldValue(o);t.x=s[i.get(e)].x,t.y=s[i.get(e)].y}}}class Jc extends q{constructor(t){super(t),this.type=y.Strata,this._direction=t.direction,this._rootMark=t.rootMark,this._gap="gap"in t?t.gap:0}toJSON(){}clone(){}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.group.firstChild.dataScope.dataTable.tree;if(!t)return;let e={};for(let t of this.group.children)e[t.dataScope.getFieldValue(o)]=t;this._rootMark.type===T.Rect?this._layoutRects(t.getRoot(),t,e):this._rootMark.type===T.Circle&&this._layoutArcs(t.getRoot(),t,e)}_layoutArcs(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n=i[t.id],r=n.type==T.Arc||n.type==T.Pie?n.startAngle:90;for(let t=0;t<s.length;t++){let n=s[t],a=i[n.id];if(a.type===T.Arc){let t=Rt(r+a.angle);a.adjustAngle(r,t),r=t}this._layoutArcs(n,e,i)}}_layoutRects(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n,r,a=i[t.id];switch(this._direction){case k.Down:default:n=a.left,r=a.bottom}for(let t=0;t<s.length;t++){let a=s[t],o=i[a.id];o._doTranslate(n-o.left,r-o.top),n+=o.width,this._layoutRects(a,e,i)}}}var Hc={};function $c(t){return new Te(t)}function Zc(t,e){if(l.indexOf(t)<0)throw new Error(G.UNKOWNN_SCALE_TYPE+": "+t);return new Oe(t,e)}function Kc(t,e){let i=e||{};switch(t.toLowerCase()){case"grid":return new Y(i);case"packing":return new Re(i);case"treemap":return new Me(i);case"stack":return new Pt(i);case"tidytree":return new Fe(i);case"force":return new Be(i);case"sugiyama":return new Yc(i);case"strata":return new Jc(i)}}function Xc(t){return new J(t||{})}function Qc(t,e){return new Promise((function(i,s){let n=new XMLHttpRequest;n.open(t,e),n.onload=function(){this.status>=200&&this.status<300?i(n.response):s({status:this.status,statusText:n.statusText})},n.onerror=function(){s({status:this.status,statusText:n.statusText})},n.send()}))}async function td(t){let e=await Qc("GET",t),i=n.csvParse(e.trim(),n.autoType);return new qt(i,t)}function ed(t){if(Array.isArray(t)){for(let e of t)if(!gt(e)||e.dataScope)return!1;return!0}return!(!gt(t)&&t.type!=T.Glyph||t.dataScope)||t.type==T.Collection}function id(t){if([T.Line,T.Circle,T.Rect,T.Area,T.Ring,T.Pie].indexOf(t.type)<0)return!1;if(t.dataScope){let e=nt(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function sd(t){if([T.Line,T.Circle,T.Rect,T.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=nt(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function nd(t){return t.type===T.Collection&&!(t.children.length<2)}t.canClassify=nd,t.canDensify=sd,t.canDivide=id,t.canRepeat=ed,t.cartesianToPolar=function(t,e,i,s){return St(t,e,i,s)},t.createScale=Zc,t.csv=td,t.csvFromFile=async function(t){let e=n.csvParse(t.trim(),n.autoType);return new qt(e,"")},t.csvFromString=function(t,e){let i=n.csvParse(t.trim(),n.autoType);return new qt(i,e)},t.csvSync=function(t,e){let i=!!e;var s=new XMLHttpRequest;if(s.open("GET",t,i),s.send(),!i&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(s)){let e=n.csvParse(s.responseText.trim(),n.autoType);return new qt(e,t)}},t.getPeersInScene=function(t){return"vertex"==t.type||"segment"==t.type?nt(t,t.parent.getScene()):nt(t,t.getScene())},t.graphjson=async function(t){let e=await Qc("GET",t);return new Pe(JSON.parse(e),t)},t.hitTest=function(t,e,i){if(!t.children||0==t.children.length)return t.contains(e,i)&&t.type!==T.Scene?t:null;let s=t.children;t.type===T.Scene&&(s=s.slice(),s.sort(((t,e)=>pt(t)?1:pt(e)?-1:0)));for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.hitTestAll=function(t,e,i){let s=ft(t);for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.inMarkHitTest=function(t,e,i,s){let n,r=ut(t),o=s||2,h=bt.getContext();for(let t of r){if(!(t instanceof Q))continue;let s=new Path2D(t.getSVGPathData());if(h.lineWidth=Math.max(t.strokeWidth,2*o),h.stroke(s),h.isPointInStroke(s,e,i)){n=t;break}}if(!n)return null;let l=[];for(let t of n.vertices){let e=Math.max(o,t.width,2*t.radius),i=Math.max(o,t.height,2*t.radius);l.push({i:t,b:new a(t.x-e/2,t.y-i/2,e,i)})}for(let t of l)if(t.b.contains(e,i))return t.i;if(n.segments&&n.segments.length>0)for(let t of n.segments){let s=new Path2D;if(s.moveTo(t.vertex1.x,t.vertex1.y),s.lineTo(t.vertex2.x,t.vertex2.y),h.lineWidth=Math.max(n.strokeWidth,o),h.stroke(s),h.isPointInStroke(s,e,i))return t}return null},t.inMarkRectHitTest=function t(e,i,s){let n=s||2;if(gt(e)){let t=[];for(let i of e.vertices){let e=Math.max(n,i.width,2*i.radius),s=Math.max(n,i.height,2*i.radius);t.push({i:i,b:new a(i.x-e/2,i.y-s/2,e,s)})}if(e.type===T.Rect)for(let i of e.segments){let s=Math.max(e.strokeWidth,n);"v"===(i.vertex1.x===i.vertex2.x?"v":"h")?t.push({i:i,b:new a(i.vertex1.x-s/2,Math.min(i.vertex1.y,i.vertex2.y)-s/2,s,Math.abs(i.vertex1.y-i.vertex2.y))}):t.push({i:i,b:new a(Math.min(i.vertex1.x,i.vertex2.x)-s/2,i.vertex1.y-s/2,Math.abs(i.vertex1.x-i.vertex2.x),s)})}for(let e of t)if(e.b.overlap(i))return e.i;return null}if(!pt(e)&&e.children&&e.children.length>0){for(let s of e.children)if(s.bounds.overlap(i)){let e=t(s,i,n);if(e)return e}return null}return null},t.layout=Kc,t.linearGradient=Xc,t.polarToCartesian=function(t,e,i,s){return Ct(t,e,i,s)},t.rectHitTest=function(t,e){let i=[];if(!t.children||0==t.children.length)return t.bounds.overlap(e)&&t.type!==T.Scene?[t]:[];for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];n.bounds.overlap(e)&&i.push(n)}return i},t.renderer=function(t,e){switch(t){case"svg":return new Ie(e);case"webgl":return e in Hc||(Hc[e]=new Ge(e)),Hc[e]}},t.scene=$c,t.sceneLoader=function(){return new De},t.specExecutor=function(){return new je},t.specGenerator=function(){return new Le},t.treejson=async function(t){let e=await Qc("GET",t);return new we(JSON.parse(e),t)},Object.defineProperty(t,"__esModule",{value:!0})}));
199
+ */var Vh=function(t){return Qa(Za(t,void 0,ph),t+"")}((function(t,e){return null==t?{}:jh(t,e)})),Gh=Math.ceil,zh=Math.max;var Wh=function(t,e,i,s){for(var n=-1,r=zh(Gh((e-t)/(i||1)),0),a=Array(r);r--;)a[s?r:++n]=t,t+=i;return a};var Uh=function(t){return function(e,i,s){return s&&"number"!=typeof s&&$o(e,i,s)&&(i=s=void 0),e=ch(e),void 0===i?(i=e,e=0):i=ch(i),s=void 0===s?e<i?1:-1:ch(s),Wh(e,i,s,t)}}();var qh=function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t};var Yh=function(t,e){if(t!==e){var i=void 0!==t,s=null===t,n=t==t,r=zr(t),a=void 0!==e,o=null===e,h=e==e,l=zr(e);if(!o&&!l&&!r&&t>e||r&&a&&h&&!o&&!l||s&&a&&h||!i&&h||!n)return 1;if(!s&&!r&&!l&&t<e||l&&i&&n&&!s&&!r||o&&i&&n||!a&&n||!h)return-1}return 0};var Jh=function(t,e,i){for(var s=-1,n=t.criteria,r=e.criteria,a=n.length,o=i.length;++s<a;){var h=Yh(n[s],r[s]);if(h)return s>=o?h:h*("desc"==i[s]?-1:1)}return t.index-e.index};var Hh=function(t,e,i){e=e.length?Kr(e,(function(t){return Is(t)?function(e){return na(e,1===t.length?t[0]:t)}:t})):[ur];var s=-1;e=Kr(e,Ls(fa));var n=xa(t,(function(t,i,n){return{criteria:Kr(e,(function(e){return e(t)})),index:++s,value:t}}));return qh(n,(function(t,e){return Jh(t,e,i)}))},$h=to((function(t,e){if(null==t)return[];var i=e.length;return i>1&&$o(t,e[0],e[1])?e=[]:i>2&&$o(e[0],e[1],e[2])&&(e=[e[0]]),Hh(t,Ja(e,1),[])})),Zh=0;var Kh=function(t){var e=++Zh;return ea(t)+e};var Xh=function(t,e,i){for(var s=-1,n=t.length,r=e.length,a={};++s<n;){var o=s<r?e[s]:void 0;i(a,t[s],o)}return a};var Qh,tl=function(t,e){return Xh(t||[],e||[],bs)};try{Qh={cloneDeep:Ho,constant:hr,defaults:Xo,each:gr,filter:pa,find:fh,flatten:ph,forEach:pr,forIn:gh,has:ma,isUndefined:ba,last:_h,map:wa,mapValues:mh,max:bh,merge:Mh,min:Ph,minBy:Fh,now:Bh,pick:Vh,range:Uh,reduce:Sa,sortBy:$h,uniqueId:Kh,values:go,zipObject:tl}}catch(t){}Qh||(Qh=window._);var el=Qh,il=sl;function sl(){var t={};t._next=t._prev=t,this._sentinel=t}function nl(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function rl(t,e){if("_next"!==t&&"_prev"!==t)return e}sl.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return nl(e),e},sl.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&nl(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},sl.prototype.toString=function(){for(var t=[],e=this._sentinel,i=e._prev;i!==e;)t.push(JSON.stringify(i,rl)),i=i._prev;return"["+t.join(", ")+"]"};var al=Jo.Graph,ol=function(t,e){if(t.nodeCount()<=1)return[];var i=function(t,e){var i=new al,s=0,n=0;el.forEach(t.nodes(),(function(t){i.setNode(t,{v:t,in:0,out:0})})),el.forEach(t.edges(),(function(t){var r=i.edge(t.v,t.w)||0,a=e(t),o=r+a;i.setEdge(t.v,t.w,o),n=Math.max(n,i.node(t.v).out+=a),s=Math.max(s,i.node(t.w).in+=a)}));var r=el.range(n+s+3).map((function(){return new il})),a=s+1;return el.forEach(i.nodes(),(function(t){cl(r,a,i.node(t))})),{graph:i,buckets:r,zeroIdx:a}}(t,e||hl),s=function(t,e,i){var s,n=[],r=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;s=a.dequeue();)ll(t,e,i,s);for(;s=r.dequeue();)ll(t,e,i,s);if(t.nodeCount())for(var o=e.length-2;o>0;--o)if(s=e[o].dequeue()){n=n.concat(ll(t,e,i,s,!0));break}}return n}(i.graph,i.buckets,i.zeroIdx);return el.flatten(el.map(s,(function(e){return t.outEdges(e.v,e.w)})),!0)},hl=el.constant(1);function ll(t,e,i,s,n){var r=n?[]:void 0;return el.forEach(t.inEdges(s.v),(function(s){var a=t.edge(s),o=t.node(s.v);n&&r.push({v:s.v,w:s.w}),o.out-=a,cl(e,i,o)})),el.forEach(t.outEdges(s.v),(function(s){var n=t.edge(s),r=s.w,a=t.node(r);a.in-=n,cl(e,i,a)})),t.removeNode(s.v),r}function cl(t,e,i){i.out?i.in?t[i.out-i.in+e].enqueue(i):t[t.length-1].enqueue(i):t[0].enqueue(i)}var dl={run:function(t){var e="greedy"===t.graph().acyclicer?ol(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],i={},s={};function n(r){el.has(s,r)||(s[r]=!0,i[r]=!0,el.forEach(t.outEdges(r),(function(t){el.has(i,t.w)?e.push(t):n(t.w)})),delete i[r])}return el.forEach(t.nodes(),n),e}(t);el.forEach(e,(function(e){var i=t.edge(e);t.removeEdge(e),i.forwardName=e.name,i.reversed=!0,t.setEdge(e.w,e.v,i,el.uniqueId("rev"))}))},undo:function(t){el.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.reversed){t.removeEdge(e);var s=i.forwardName;delete i.reversed,delete i.forwardName,t.setEdge(e.w,e.v,i,s)}}))}};var ul=Jo.Graph,fl={addDummyNode:pl,simplify:function(t){var e=(new ul).setGraph(t.graph());return el.forEach(t.nodes(),(function(i){e.setNode(i,t.node(i))})),el.forEach(t.edges(),(function(i){var s=e.edge(i.v,i.w)||{weight:0,minlen:1},n=t.edge(i);e.setEdge(i.v,i.w,{weight:s.weight+n.weight,minlen:Math.max(s.minlen,n.minlen)})})),e},asNonCompoundGraph:function(t){var e=new ul({multigraph:t.isMultigraph()}).setGraph(t.graph());return el.forEach(t.nodes(),(function(i){t.children(i).length||e.setNode(i,t.node(i))})),el.forEach(t.edges(),(function(i){e.setEdge(i,t.edge(i))})),e},successorWeights:function(t){var e=el.map(t.nodes(),(function(e){var i={};return el.forEach(t.outEdges(e),(function(e){i[e.w]=(i[e.w]||0)+t.edge(e).weight})),i}));return el.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=el.map(t.nodes(),(function(e){var i={};return el.forEach(t.inEdges(e),(function(e){i[e.v]=(i[e.v]||0)+t.edge(e).weight})),i}));return el.zipObject(t.nodes(),e)},intersectRect:function(t,e){var i,s,n=t.x,r=t.y,a=e.x-n,o=e.y-r,h=t.width/2,l=t.height/2;if(!a&&!o)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(o)*h>Math.abs(a)*l?(o<0&&(l=-l),i=l*a/o,s=l):(a<0&&(h=-h),i=h,s=h*o/a);return{x:n+i,y:r+s}},buildLayerMatrix:function(t){var e=el.map(el.range(gl(t)+1),(function(){return[]}));return el.forEach(t.nodes(),(function(i){var s=t.node(i),n=s.rank;el.isUndefined(n)||(e[n][s.order]=i)})),e},normalizeRanks:function(t){var e=el.min(el.map(t.nodes(),(function(e){return t.node(e).rank})));el.forEach(t.nodes(),(function(i){var s=t.node(i);el.has(s,"rank")&&(s.rank-=e)}))},removeEmptyRanks:function(t){var e=el.min(el.map(t.nodes(),(function(e){return t.node(e).rank}))),i=[];el.forEach(t.nodes(),(function(s){var n=t.node(s).rank-e;i[n]||(i[n]=[]),i[n].push(s)}));var s=0,n=t.graph().nodeRankFactor;el.forEach(i,(function(e,i){el.isUndefined(e)&&i%n!=0?--s:s&&el.forEach(e,(function(e){t.node(e).rank+=s}))}))},addBorderNode:function(t,e,i,s){var n={width:0,height:0};arguments.length>=4&&(n.rank=i,n.order=s);return pl(t,"border",n,e)},maxRank:gl,partition:function(t,e){var i={lhs:[],rhs:[]};return el.forEach(t,(function(t){e(t)?i.lhs.push(t):i.rhs.push(t)})),i},time:function(t,e){var i=el.now();try{return e()}finally{console.log(t+" time: "+(el.now()-i)+"ms")}},notime:function(t,e){return e()}};function pl(t,e,i,s){var n;do{n=el.uniqueId(s)}while(t.hasNode(n));return i.dummy=e,t.setNode(n,i),n}function gl(t){return el.max(el.map(t.nodes(),(function(e){var i=t.node(e).rank;if(!el.isUndefined(i))return i})))}var _l={run:function(t){t.graph().dummyChains=[],el.forEach(t.edges(),(function(e){!function(t,e){var i,s,n,r=e.v,a=t.node(r).rank,o=e.w,h=t.node(o).rank,l=e.name,c=t.edge(e),d=c.labelRank;if(h===a+1)return;for(t.removeEdge(e),n=0,++a;a<h;++n,++a)c.points=[],s={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},i=fl.addDummyNode(t,"edge",s,"_d"),a===d&&(s.width=c.width,s.height=c.height,s.dummy="edge-label",s.labelpos=c.labelpos),t.setEdge(r,i,{weight:c.weight},l),0===n&&t.graph().dummyChains.push(i),r=i;t.setEdge(r,o,{weight:c.weight},l)}(t,e)}))},undo:function(t){el.forEach(t.graph().dummyChains,(function(e){var i,s=t.node(e),n=s.edgeLabel;for(t.setEdge(s.edgeObj,n);s.dummy;)i=t.successors(e)[0],t.removeNode(e),n.points.push({x:s.x,y:s.y}),"edge-label"===s.dummy&&(n.x=s.x,n.y=s.y,n.width=s.width,n.height=s.height),e=i,s=t.node(e)}))}};var ml=function(t){var e={};el.forEach(t.sources(),(function i(s){var n=t.node(s);if(el.has(e,s))return n.rank;e[s]=!0;var r=el.min(el.map(t.outEdges(s),(function(e){return i(e.w)-t.edge(e).minlen})));return r!==Number.POSITIVE_INFINITY&&null!=r||(r=0),n.rank=r}))},yl=function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen};var vl=Jo.Graph,bl=yl,xl=function(t){var e,i,s=new vl({directed:!1}),n=t.nodes()[0],r=t.nodeCount();s.setNode(n,{});for(;wl(s,t)<r;)e=kl(s,t),i=s.hasNode(e.v)?bl(t,e):-bl(t,e),Cl(s,t,i);return s};function wl(t,e){return el.forEach(t.nodes(),(function i(s){el.forEach(e.nodeEdges(s),(function(n){var r=n.v,a=s===r?n.w:r;t.hasNode(a)||bl(e,n)||(t.setNode(a,{}),t.setEdge(s,a,{}),i(a))}))})),t.nodeCount()}function kl(t,e){return el.minBy(e.edges(),(function(i){if(t.hasNode(i.v)!==t.hasNode(i.w))return bl(e,i)}))}function Cl(t,e,i){el.forEach(t.nodes(),(function(t){e.node(t).rank+=i}))}var Sl=yl,El=ml,Tl=Jo.alg.preorder,Al=Jo.alg.postorder,Il=fl.simplify,Ol=Rl;function Rl(t){t=Il(t),El(t);var e,i=xl(t);for(Pl(i),Ml(i,t);e=Bl(i);)Dl(i,t,e,Ll(i,t,e))}function Ml(t,e){var i=Al(t,t.nodes());i=i.slice(0,i.length-1),el.forEach(i,(function(i){!function(t,e,i){var s=t.node(i).parent;t.edge(i,s).cutvalue=Nl(t,e,i)}(t,e,i)}))}function Nl(t,e,i){var s=t.node(i).parent,n=!0,r=e.edge(i,s),a=0;return r||(n=!1,r=e.edge(s,i)),a=r.weight,el.forEach(e.nodeEdges(i),(function(r){var o,h,l=r.v===i,c=l?r.w:r.v;if(c!==s){var d=l===n,u=e.edge(r).weight;if(a+=d?u:-u,o=i,h=c,t.hasEdge(o,h)){var f=t.edge(i,c).cutvalue;a+=d?-f:f}}})),a}function Pl(t,e){arguments.length<2&&(e=t.nodes()[0]),Fl(t,{},1,e)}function Fl(t,e,i,s,n){var r=i,a=t.node(s);return e[s]=!0,el.forEach(t.neighbors(s),(function(n){el.has(e,n)||(i=Fl(t,e,i,n,s))})),a.low=r,a.lim=i++,n?a.parent=n:delete a.parent,i}function Bl(t){return el.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function Ll(t,e,i){var s=i.v,n=i.w;e.hasEdge(s,n)||(s=i.w,n=i.v);var r=t.node(s),a=t.node(n),o=r,h=!1;r.lim>a.lim&&(o=a,h=!0);var l=el.filter(e.edges(),(function(e){return h===jl(t,t.node(e.v),o)&&h!==jl(t,t.node(e.w),o)}));return el.minBy(l,(function(t){return Sl(e,t)}))}function Dl(t,e,i,s){var n=i.v,r=i.w;t.removeEdge(n,r),t.setEdge(s.v,s.w,{}),Pl(t),Ml(t,e),function(t,e){var i=el.find(t.nodes(),(function(t){return!e.node(t).parent})),s=Tl(t,i);s=s.slice(1),el.forEach(s,(function(i){var s=t.node(i).parent,n=e.edge(i,s),r=!1;n||(n=e.edge(s,i),r=!0),e.node(i).rank=e.node(s).rank+(r?n.minlen:-n.minlen)}))}(t,e)}function jl(t,e,i){return i.low<=e.lim&&e.lim<=i.lim}Rl.initLowLimValues=Pl,Rl.initCutValues=Ml,Rl.calcCutValue=Nl,Rl.leaveEdge=Bl,Rl.enterEdge=Ll,Rl.exchangeEdges=Dl;var Vl=ml,Gl=function(t){switch(t.graph().ranker){case"network-simplex":Wl(t);break;case"tight-tree":!function(t){Vl(t),xl(t)}(t);break;case"longest-path":zl(t);break;default:Wl(t)}};var zl=Vl;function Wl(t){Ol(t)}var Ul=function(t){var e=function(t){var e={},i=0;function s(n){var r=i;el.forEach(t.children(n),s),e[n]={low:r,lim:i++}}return el.forEach(t.children(),s),e}(t);el.forEach(t.graph().dummyChains,(function(i){for(var s=t.node(i),n=s.edgeObj,r=function(t,e,i,s){var n,r,a=[],o=[],h=Math.min(e[i].low,e[s].low),l=Math.max(e[i].lim,e[s].lim);n=i;do{n=t.parent(n),a.push(n)}while(n&&(e[n].low>h||l>e[n].lim));r=n,n=s;for(;(n=t.parent(n))!==r;)o.push(n);return{path:a.concat(o.reverse()),lca:r}}(t,e,n.v,n.w),a=r.path,o=r.lca,h=0,l=a[h],c=!0;i!==n.w;){if(s=t.node(i),c){for(;(l=a[h])!==o&&t.node(l).maxRank<s.rank;)h++;l===o&&(c=!1)}if(!c){for(;h<a.length-1&&t.node(l=a[h+1]).minRank<=s.rank;)h++;l=a[h]}t.setParent(i,l),i=t.successors(i)[0]}}))};var ql={run:function(t){var e=fl.addDummyNode(t,"root",{},"_root"),i=function(t){var e={};function i(s,n){var r=t.children(s);r&&r.length&&el.forEach(r,(function(t){i(t,n+1)})),e[s]=n}return el.forEach(t.children(),(function(t){i(t,1)})),e}(t),s=el.max(el.values(i))-1,n=2*s+1;t.graph().nestingRoot=e,el.forEach(t.edges(),(function(e){t.edge(e).minlen*=n}));var r=function(t){return el.reduce(t.edges(),(function(e,i){return e+t.edge(i).weight}),0)}(t)+1;el.forEach(t.children(),(function(a){Yl(t,e,n,r,s,i,a)})),t.graph().nodeRankFactor=n},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,el.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function Yl(t,e,i,s,n,r,a){var o=t.children(a);if(o.length){var h=fl.addBorderNode(t,"_bt"),l=fl.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(h,a),c.borderTop=h,t.setParent(l,a),c.borderBottom=l,el.forEach(o,(function(o){Yl(t,e,i,s,n,r,o);var c=t.node(o),d=c.borderTop?c.borderTop:o,u=c.borderBottom?c.borderBottom:o,f=c.borderTop?s:2*s,p=d!==u?1:n-r[a]+1;t.setEdge(h,d,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(u,l,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,h,{weight:0,minlen:n+r[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:i})}var Jl=function(t){el.forEach(t.children(),(function e(i){var s=t.children(i),n=t.node(i);if(s.length&&el.forEach(s,e),el.has(n,"minRank")){n.borderLeft=[],n.borderRight=[];for(var r=n.minRank,a=n.maxRank+1;r<a;++r)Hl(t,"borderLeft","_bl",i,n,r),Hl(t,"borderRight","_br",i,n,r)}}))};function Hl(t,e,i,s,n,r){var a={width:0,height:0,rank:r,borderType:e},o=n[e][r-1],h=fl.addDummyNode(t,"border",a,i);n[e][r]=h,t.setParent(h,s),o&&t.setEdge(o,h,{weight:1})}var $l={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||Zl(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){el.forEach(t.nodes(),(function(e){Xl(t.node(e))})),el.forEach(t.edges(),(function(e){var i=t.edge(e);el.forEach(i.points,Xl),el.has(i,"y")&&Xl(i)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){el.forEach(t.nodes(),(function(e){Ql(t.node(e))})),el.forEach(t.edges(),(function(e){var i=t.edge(e);el.forEach(i.points,Ql),el.has(i,"x")&&Ql(i)}))}(t),Zl(t))}};function Zl(t){el.forEach(t.nodes(),(function(e){Kl(t.node(e))})),el.forEach(t.edges(),(function(e){Kl(t.edge(e))}))}function Kl(t){var e=t.width;t.width=t.height,t.height=e}function Xl(t){t.y=-t.y}function Ql(t){var e=t.x;t.x=t.y,t.y=e}var tc=function(t){var e={},i=el.filter(t.nodes(),(function(e){return!t.children(e).length})),s=el.max(el.map(i,(function(e){return t.node(e).rank}))),n=el.map(el.range(s+1),(function(){return[]}));function r(i){if(!el.has(e,i)){e[i]=!0;var s=t.node(i);n[s.rank].push(i),el.forEach(t.successors(i),r)}}var a=el.sortBy(i,(function(e){return t.node(e).rank}));return el.forEach(a,r),n};var ec=function(t,e){for(var i=0,s=1;s<e.length;++s)i+=ic(t,e[s-1],e[s]);return i};function ic(t,e,i){for(var s=el.zipObject(i,el.map(i,(function(t,e){return e}))),n=el.flatten(el.map(e,(function(e){return el.sortBy(el.map(t.outEdges(e),(function(e){return{pos:s[e.w],weight:t.edge(e).weight}})),"pos")})),!0),r=1;r<i.length;)r<<=1;var a=2*r-1;r-=1;var o=el.map(new Array(a),(function(){return 0})),h=0;return el.forEach(n.forEach((function(t){var e=t.pos+r;o[e]+=t.weight;for(var i=0;e>0;)e%2&&(i+=o[e+1]),o[e=e-1>>1]+=t.weight;h+=t.weight*i}))),h}var sc=function(t,e){return el.map(e,(function(e){var i=t.inEdges(e);if(i.length){var s=el.reduce(i,(function(e,i){var s=t.edge(i),n=t.node(i.v);return{sum:e.sum+s.weight*n.order,weight:e.weight+s.weight}}),{sum:0,weight:0});return{v:e,barycenter:s.sum/s.weight,weight:s.weight}}return{v:e}}))};var nc=function(t,e){var i={};return el.forEach(t,(function(t,e){var s=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};el.isUndefined(t.barycenter)||(s.barycenter=t.barycenter,s.weight=t.weight)})),el.forEach(e.edges(),(function(t){var e=i[t.v],s=i[t.w];el.isUndefined(e)||el.isUndefined(s)||(s.indegree++,e.out.push(i[t.w]))})),function(t){var e=[];function i(t){return function(e){e.merged||(el.isUndefined(e.barycenter)||el.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var i=0,s=0;t.weight&&(i+=t.barycenter*t.weight,s+=t.weight);e.weight&&(i+=e.barycenter*e.weight,s+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=i/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function s(e){return function(i){i.in.push(e),0==--i.indegree&&t.push(i)}}for(;t.length;){var n=t.pop();e.push(n),el.forEach(n.in.reverse(),i(n)),el.forEach(n.out,s(n))}return el.map(el.filter(e,(function(t){return!t.merged})),(function(t){return el.pick(t,["vs","i","barycenter","weight"])}))}(el.filter(i,(function(t){return!t.indegree})))};var rc=function(t,e){var i=fl.partition(t,(function(t){return el.has(t,"barycenter")})),s=i.lhs,n=el.sortBy(i.rhs,(function(t){return-t.i})),r=[],a=0,o=0,h=0;s.sort((l=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:l?e.i-t.i:t.i-e.i})),h=ac(r,n,h),el.forEach(s,(function(t){h+=t.vs.length,r.push(t.vs),a+=t.barycenter*t.weight,o+=t.weight,h=ac(r,n,h)}));var l;var c={vs:el.flatten(r,!0)};o&&(c.barycenter=a/o,c.weight=o);return c};function ac(t,e,i){for(var s;e.length&&(s=el.last(e)).i<=i;)e.pop(),t.push(s.vs),i++;return i}var oc=function t(e,i,s,n){var r=e.children(i),a=e.node(i),o=a?a.borderLeft:void 0,h=a?a.borderRight:void 0,l={};o&&(r=el.filter(r,(function(t){return t!==o&&t!==h})));var c=sc(e,r);el.forEach(c,(function(i){if(e.children(i.v).length){var r=t(e,i.v,s,n);l[i.v]=r,el.has(r,"barycenter")&&(a=i,o=r,el.isUndefined(a.barycenter)?(a.barycenter=o.barycenter,a.weight=o.weight):(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight))}var a,o}));var d=nc(c,s);!function(t,e){el.forEach(t,(function(t){t.vs=el.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(d,l);var u=rc(d,n);if(o&&(u.vs=el.flatten([o,u.vs,h],!0),e.predecessors(o).length)){var f=e.node(e.predecessors(o)[0]),p=e.node(e.predecessors(h)[0]);el.has(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+f.order+p.order)/(u.weight+2),u.weight+=2}return u};var hc=Jo.Graph,lc=function(t,e,i){var s=function(t){var e;for(;t.hasNode(e=el.uniqueId("_root")););return e}(t),n=new hc({compound:!0}).setGraph({root:s}).setDefaultNodeLabel((function(e){return t.node(e)}));return el.forEach(t.nodes(),(function(r){var a=t.node(r),o=t.parent(r);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(n.setNode(r),n.setParent(r,o||s),el.forEach(t[i](r),(function(e){var i=e.v===r?e.w:e.v,s=n.edge(i,r),a=el.isUndefined(s)?0:s.weight;n.setEdge(i,r,{weight:t.edge(e).weight+a})})),el.has(a,"minRank")&&n.setNode(r,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),n};var cc=function(t,e,i){var s,n={};el.forEach(i,(function(i){for(var r,a,o=t.parent(i);o;){if((r=t.parent(o))?(a=n[r],n[r]=o):(a=s,s=o),a&&a!==o)return void e.setEdge(a,o);o=r}}))};var dc=Jo.Graph,uc=function(t){var e=fl.maxRank(t),i=fc(t,el.range(1,e+1),"inEdges"),s=fc(t,el.range(e-1,-1,-1),"outEdges"),n=tc(t);gc(t,n);for(var r,a=Number.POSITIVE_INFINITY,o=0,h=0;h<4;++o,++h){pc(o%2?i:s,o%4>=2),n=fl.buildLayerMatrix(t);var l=ec(t,n);l<a&&(h=0,r=el.cloneDeep(n),a=l)}gc(t,r)};function fc(t,e,i){return el.map(e,(function(e){return lc(t,e,i)}))}function pc(t,e){var i=new dc;el.forEach(t,(function(t){var s=t.graph().root,n=oc(t,s,i,e);el.forEach(n.vs,(function(e,i){t.node(e).order=i})),cc(t,i,n.vs)}))}function gc(t,e){el.forEach(e,(function(e){el.forEach(e,(function(e,i){t.node(e).order=i}))}))}var _c=Jo.Graph,mc=function(t){var e,i=fl.buildLayerMatrix(t),s=el.merge(yc(t,i),vc(t,i)),n={};el.forEach(["u","d"],(function(r){e="u"===r?i:el.values(i).reverse(),el.forEach(["l","r"],(function(i){"r"===i&&(e=el.map(e,(function(t){return el.values(t).reverse()})));var a=("u"===r?t.predecessors:t.successors).bind(t),o=wc(t,e,s,a),h=kc(t,e,o.root,o.align,"r"===i);"r"===i&&(h=el.mapValues(h,(function(t){return-t}))),n[r+i]=h}))}));var r=Cc(t,n);return Sc(n,r),Ec(n,t.graph().align)};function yc(t,e){var i={};return el.reduce(e,(function(e,s){var n=0,r=0,a=e.length,o=el.last(s);return el.forEach(s,(function(e,h){var l=function(t,e){if(t.node(e).dummy)return el.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=l?t.node(l).order:a;(l||e===o)&&(el.forEach(s.slice(r,h+1),(function(e){el.forEach(t.predecessors(e),(function(s){var r=t.node(s),a=r.order;!(a<n||c<a)||r.dummy&&t.node(e).dummy||bc(i,s,e)}))})),r=h+1,n=c)})),s})),i}function vc(t,e){var i={};function s(e,s,n,r,a){var o;el.forEach(el.range(s,n),(function(s){o=e[s],t.node(o).dummy&&el.forEach(t.predecessors(o),(function(e){var s=t.node(e);s.dummy&&(s.order<r||s.order>a)&&bc(i,e,o)}))}))}return el.reduce(e,(function(e,i){var n,r=-1,a=0;return el.forEach(i,(function(o,h){if("border"===t.node(o).dummy){var l=t.predecessors(o);l.length&&(n=t.node(l[0]).order,s(i,a,h,r,n),a=h,r=n)}s(i,a,i.length,n,e.length)})),i})),i}function bc(t,e,i){if(e>i){var s=e;e=i,i=s}var n=t[e];n||(t[e]=n={}),n[i]=!0}function xc(t,e,i){if(e>i){var s=e;e=i,i=s}return el.has(t[e],i)}function wc(t,e,i,s){var n={},r={},a={};return el.forEach(e,(function(t){el.forEach(t,(function(t,e){n[t]=t,r[t]=t,a[t]=e}))})),el.forEach(e,(function(t){var e=-1;el.forEach(t,(function(t){var o=s(t);if(o.length)for(var h=((o=el.sortBy(o,(function(t){return a[t]}))).length-1)/2,l=Math.floor(h),c=Math.ceil(h);l<=c;++l){var d=o[l];r[t]===t&&e<a[d]&&!xc(i,t,d)&&(r[d]=t,r[t]=n[t]=n[d],e=a[d])}}))})),{root:n,align:r}}function kc(t,e,i,s,n){var r={},a=function(t,e,i,s){var n=new _c,r=t.graph(),a=function(t,e,i){return function(s,n,r){var a,o=s.node(n),h=s.node(r),l=0;if(l+=o.width/2,el.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(l+=i?a:-a),a=0,l+=(o.dummy?e:t)/2,l+=(h.dummy?e:t)/2,l+=h.width/2,el.has(h,"labelpos"))switch(h.labelpos.toLowerCase()){case"l":a=h.width/2;break;case"r":a=-h.width/2}return a&&(l+=i?a:-a),a=0,l}}(r.nodesep,r.edgesep,s);return el.forEach(e,(function(e){var s;el.forEach(e,(function(e){var r=i[e];if(n.setNode(r),s){var o=i[s],h=n.edge(o,r);n.setEdge(o,r,Math.max(a(t,e,s),h||0))}s=e}))})),n}(t,e,i,n),o=n?"borderLeft":"borderRight";function h(t,e){for(var i=a.nodes(),s=i.pop(),n={};s;)n[s]?t(s):(n[s]=!0,i.push(s),i=i.concat(e(s))),s=i.pop()}return h((function(t){r[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,r[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),h((function(e){var i=a.outEdges(e).reduce((function(t,e){return Math.min(t,r[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),s=t.node(e);i!==Number.POSITIVE_INFINITY&&s.borderType!==o&&(r[e]=Math.max(r[e],i))}),a.successors.bind(a)),el.forEach(s,(function(t){r[t]=r[i[t]]})),r}function Cc(t,e){return el.minBy(el.values(e),(function(e){var i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return el.forIn(e,(function(e,n){var r=function(t,e){return t.node(e).width}(t,n)/2;i=Math.max(e+r,i),s=Math.min(e-r,s)})),i-s}))}function Sc(t,e){var i=el.values(e),s=el.min(i),n=el.max(i);el.forEach(["u","d"],(function(i){el.forEach(["l","r"],(function(r){var a,o=i+r,h=t[o];if(h!==e){var l=el.values(h);(a="l"===r?s-el.min(l):n-el.max(l))&&(t[o]=el.mapValues(h,(function(t){return t+a})))}}))}))}function Ec(t,e){return el.mapValues(t.ul,(function(i,s){if(e)return t[e.toLowerCase()][s];var n=el.sortBy(el.map(t,s));return(n[1]+n[2])/2}))}var Tc=mc,Ac=function(t){(function(t){var e=fl.buildLayerMatrix(t),i=t.graph().ranksep,s=0;el.forEach(e,(function(e){var n=el.max(el.map(e,(function(e){return t.node(e).height})));el.forEach(e,(function(e){t.node(e).y=s+n/2})),s+=n+i}))})(t=fl.asNonCompoundGraph(t)),el.forEach(Tc(t),(function(e,i){t.node(i).x=e}))};var Ic=fl.normalizeRanks,Oc=fl.removeEmptyRanks,Rc=fl,Mc=Jo.Graph,Nc=function(t,e){var i=e&&e.debugTiming?Rc.time:Rc.notime;i("layout",(function(){var e=i(" buildLayoutGraph",(function(){return function(t){var e=new Mc({multigraph:!0,compound:!0}),i=Wc(t.graph());return e.setGraph(el.merge({},Fc,zc(i,Pc),el.pick(i,Bc))),el.forEach(t.nodes(),(function(i){var s=Wc(t.node(i));e.setNode(i,el.defaults(zc(s,Lc),Dc)),e.setParent(i,t.parent(i))})),el.forEach(t.edges(),(function(i){var s=Wc(t.edge(i));e.setEdge(i,el.merge({},Vc,zc(s,jc),el.pick(s,Gc)))})),e}(t)}));i(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,el.forEach(t.edges(),(function(i){var s=t.edge(i);s.minlen*=2,"c"!==s.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?s.width+=s.labeloffset:s.height+=s.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){el.forEach(t.edges(),(function(e){if(e.v===e.w){var i=t.node(e.v);i.selfEdges||(i.selfEdges=[]),i.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){dl.run(t)})),e(" nestingGraph.run",(function(){ql.run(t)})),e(" rank",(function(){Gl(Rc.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){el.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.width&&i.height){var s=t.node(e.v),n={rank:(t.node(e.w).rank-s.rank)/2+s.rank,e:e};Rc.addDummyNode(t,"edge-proxy",n,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){Oc(t)})),e(" nestingGraph.cleanup",(function(){ql.cleanup(t)})),e(" normalizeRanks",(function(){Ic(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;el.forEach(t.nodes(),(function(i){var s=t.node(i);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=el.max(e,s.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){el.forEach(t.nodes(),(function(e){var i=t.node(e);"edge-proxy"===i.dummy&&(t.edge(i.e).labelRank=i.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){_l.run(t)})),e(" parentDummyChains",(function(){Ul(t)})),e(" addBorderSegments",(function(){Jl(t)})),e(" order",(function(){uc(t)})),e(" insertSelfEdges",(function(){!function(t){var e=Rc.buildLayerMatrix(t);el.forEach(e,(function(e){var i=0;el.forEach(e,(function(e,s){var n=t.node(e);n.order=s+i,el.forEach(n.selfEdges,(function(e){Rc.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:n.rank,order:s+ ++i,e:e.e,label:e.label},"_se")})),delete n.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){$l.adjust(t)})),e(" position",(function(){Ac(t)})),e(" positionSelfEdges",(function(){!function(t){el.forEach(t.nodes(),(function(e){var i=t.node(e);if("selfedge"===i.dummy){var s=t.node(i.e.v),n=s.x+s.width/2,r=s.y,a=i.x-n,o=s.height/2;t.setEdge(i.e,i.label),t.removeNode(e),i.label.points=[{x:n+2*a/3,y:r-o},{x:n+5*a/6,y:r-o},{x:n+a,y:r},{x:n+5*a/6,y:r+o},{x:n+2*a/3,y:r+o}],i.label.x=i.x,i.label.y=i.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){el.forEach(t.nodes(),(function(e){if(t.children(e).length){var i=t.node(e),s=t.node(i.borderTop),n=t.node(i.borderBottom),r=t.node(el.last(i.borderLeft)),a=t.node(el.last(i.borderRight));i.width=Math.abs(a.x-r.x),i.height=Math.abs(n.y-s.y),i.x=r.x+i.width/2,i.y=s.y+i.height/2}})),el.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){_l.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){el.forEach(t.edges(),(function(e){var i=t.edge(e);if(el.has(i,"x"))switch("l"!==i.labelpos&&"r"!==i.labelpos||(i.width-=i.labeloffset),i.labelpos){case"l":i.x-=i.width/2+i.labeloffset;break;case"r":i.x+=i.width/2+i.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){$l.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,i=0,s=Number.POSITIVE_INFINITY,n=0,r=t.graph(),a=r.marginx||0,o=r.marginy||0;function h(t){var r=t.x,a=t.y,o=t.width,h=t.height;e=Math.min(e,r-o/2),i=Math.max(i,r+o/2),s=Math.min(s,a-h/2),n=Math.max(n,a+h/2)}el.forEach(t.nodes(),(function(e){h(t.node(e))})),el.forEach(t.edges(),(function(e){var i=t.edge(e);el.has(i,"x")&&h(i)})),e-=a,s-=o,el.forEach(t.nodes(),(function(i){var n=t.node(i);n.x-=e,n.y-=s})),el.forEach(t.edges(),(function(i){var n=t.edge(i);el.forEach(n.points,(function(t){t.x-=e,t.y-=s})),el.has(n,"x")&&(n.x-=e),el.has(n,"y")&&(n.y-=s)})),r.width=i-e+a,r.height=n-s+o}(t)})),e(" assignNodeIntersects",(function(){!function(t){el.forEach(t.edges(),(function(e){var i,s,n=t.edge(e),r=t.node(e.v),a=t.node(e.w);n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=a,s=r),n.points.unshift(Rc.intersectRect(r,i)),n.points.push(Rc.intersectRect(a,s))}))}(t)})),e(" reversePoints",(function(){!function(t){el.forEach(t.edges(),(function(e){var i=t.edge(e);i.reversed&&i.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){dl.undo(t)}))}(e,i)})),i(" updateInputGraph",(function(){!function(t,e){el.forEach(t.nodes(),(function(i){var s=t.node(i),n=e.node(i);s&&(s.x=n.x,s.y=n.y,e.children(i).length&&(s.width=n.width,s.height=n.height))})),el.forEach(t.edges(),(function(i){var s=t.edge(i),n=e.edge(i);s.points=n.points,el.has(n,"x")&&(s.x=n.x,s.y=n.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var Pc=["nodesep","edgesep","ranksep","marginx","marginy"],Fc={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Bc=["acyclicer","ranker","rankdir","align"],Lc=["width","height"],Dc={width:0,height:0},jc=["minlen","weight","width","height","labeloffset"],Vc={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Gc=["labelpos"];function zc(t,e){return el.mapValues(el.pick(t,e),Number)}function Wc(t){var e={};return el.forEach(t,(function(t,i){e[i.toLowerCase()]=t})),e}var Uc=Jo.Graph;var qc={graphlib:Jo,layout:Nc,debug:{debugOrdering:function(t){var e=fl.buildLayerMatrix(t),i=new Uc({compound:!0,multigraph:!0}).setGraph({});return el.forEach(t.nodes(),(function(e){i.setNode(e,{label:e}),i.setParent(e,"layer"+t.node(e).rank)})),el.forEach(t.edges(),(function(t){i.setEdge(t.v,t.w,{},t.name)})),el.forEach(e,(function(t,e){var s="layer"+e;i.setNode(s,{rank:"same"}),el.reduce(t,(function(t,e){return i.setEdge(t,e,{style:"invis"}),e}))})),i}},util:{time:fl.time,notime:fl.notime},version:"0.8.5"},Yc=qc.graphlib,Jc=qc.layout;class Hc extends q{constructor(t){super(t),this.type=y.Sugiyama,this._width="width"in t?t.width:500,this._height="height"in t?t.height:300,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0}toJSON(){let t={args:{}};return t.type=this.type,t}run(){let t=this.group.children[0].dataScope._dt.graph;if(!t)return;var e=new Yc.Graph;e.setGraph({edgesep:50}),e.setDefaultEdgeLabel((function(){return{}}));let i=new Map;for(let t of this.group.children){let s=t.dataScope.getFieldValue(o);i.set(s,s+""),e.setNode(s,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let i of t.links)e.setEdge(i.source,i.target);Jc(e);const s={};let n=Math.min(...e.nodes().map((t=>e.node(t).y))),r=Math.min(...e.nodes().map((t=>e.node(t).x))),a=this._left-r,h=this._top-n;for(const t of e.nodes())s[t]={x:e.node(t).x+a,y:e.node(t).y+h};for(let t of this.group.children){let e=t.dataScope.getFieldValue(o);t.x=s[i.get(e)].x,t.y=s[i.get(e)].y}}}class $c extends q{constructor(t){super(t),this.type=y.Strata,this._direction=t.direction,this._rootMark=t.rootMark,this._gap="gap"in t?t.gap:0}toJSON(){}clone(){}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.group.firstChild.dataScope.dataTable.tree;if(!t)return;let e={};for(let t of this.group.children)e[t.dataScope.getFieldValue(o)]=t;this._rootMark.type===T.Rect?this._layoutRects(t.getRoot(),t,e):this._rootMark.type===T.Circle&&this._layoutArcs(t.getRoot(),t,e)}_layoutArcs(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n=i[t.id],r=n.type==T.Arc||n.type==T.Pie?n.startAngle:90;for(let t=0;t<s.length;t++){let n=s[t],a=i[n.id];if(a.type===T.Arc){let t=Nt(r+a.angle);a.adjustAngle(r,t),r=t}this._layoutArcs(n,e,i)}}_layoutRects(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n,r,a=i[t.id];switch(this._direction){case k.Down:default:n=a.left,r=a.bottom}for(let t=0;t<s.length;t++){let a=s[t],o=i[a.id];o._doTranslate(n-o.left,r-o.top),n+=o.width,this._layoutRects(a,e,i)}}}var Zc={};function Kc(t){return new Ie(t)}function Xc(t,e){if(l.indexOf(t)<0)throw new Error(G.UNKOWNN_SCALE_TYPE+": "+t);return new Me(t,e)}function Qc(t,e){let i=e||{};switch(t.toLowerCase()){case"grid":return new Y(i);case"packing":return new Ne(i);case"treemap":return new Pe(i);case"stack":return new Bt(i);case"tidytree":return new Le(i);case"force":return new De(i);case"sugiyama":return new Hc(i);case"strata":return new $c(i)}}function td(t){return new J(t||{})}function ed(t,e){return new Promise((function(i,s){let n=new XMLHttpRequest;n.open(t,e),n.onload=function(){this.status>=200&&this.status<300?i(n.response):s({status:this.status,statusText:n.statusText})},n.onerror=function(){s({status:this.status,statusText:n.statusText})},n.send()}))}async function id(t){let e=await ed("GET",t),i=n.csvParse(e.trim(),n.autoType);return new Jt(i,t)}function sd(t){if(Array.isArray(t)){for(let e of t)if(!mt(e)||e.dataScope)return!1;return!0}return!(!mt(t)&&t.type!=T.Glyph||t.dataScope)||t.type==T.Collection}function nd(t){if([T.Line,T.Circle,T.Rect,T.Area,T.Ring,T.Pie,T.Path].indexOf(t.type)<0)return!1;if(t.type===T.Path&&(t.closed||!t.firstVertex.dataScope))return!1;if(t.dataScope){let e=nt(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function rd(t){if([T.Line,T.Circle,T.Rect,T.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=nt(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function ad(t){return t.type===T.Collection&&!(t.children.length<2)}t.canClassify=ad,t.canDensify=rd,t.canDivide=nd,t.canRepeat=sd,t.cartesianToPolar=function(t,e,i,s){return Tt(t,e,i,s)},t.createScale=Xc,t.csv=id,t.csvFromFile=async function(t){let e=n.csvParse(t.trim(),n.autoType);return new Jt(e,"")},t.csvFromString=function(t,e){let i=n.csvParse(t.trim(),n.autoType);return new Jt(i,e)},t.csvSync=function(t,e){let i=!!e;var s=new XMLHttpRequest;if(s.open("GET",t,i),s.send(),!i&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(s)){let e=n.csvParse(s.responseText.trim(),n.autoType);return new Jt(e,t)}},t.getPeersInScene=function(t){return"vertex"==t.type||"segment"==t.type?nt(t,t.parent.getScene()):nt(t,t.getScene())},t.graphjson=async function(t){let e=await ed("GET",t);return new Be(JSON.parse(e),t)},t.hitTest=function(t,e,i){if(!t.children||0==t.children.length)return t.contains(e,i)&&t.type!==T.Scene?t:null;let s=t.children;t.type===T.Scene&&(s=s.slice(),s.sort(((t,e)=>_t(t)?1:_t(e)?-1:0)));for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.hitTestAll=function(t,e,i){let s=gt(t);for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.inMarkHitTest=function(t,e,i,s){let n,r=pt(t),o=s||2,h=wt.getContext();for(let t of r){if(!(t instanceof Q))continue;let s=new Path2D(t.getSVGPathData());if(h.lineWidth=Math.max(t.strokeWidth,2*o),h.stroke(s),h.isPointInStroke(s,e,i)){n=t;break}}if(!n)return null;let l=[];for(let t of n.vertices){let e=Math.max(o,t.width,2*t.radius),i=Math.max(o,t.height,2*t.radius);l.push({i:t,b:new a(t.x-e/2,t.y-i/2,e,i)})}for(let t of l)if(t.b.contains(e,i))return t.i;if(n.segments&&n.segments.length>0)for(let t of n.segments){let s=new Path2D;if(s.moveTo(t.vertex1.x,t.vertex1.y),s.lineTo(t.vertex2.x,t.vertex2.y),h.lineWidth=Math.max(n.strokeWidth,o),h.stroke(s),h.isPointInStroke(s,e,i))return t}return null},t.inMarkRectHitTest=function t(e,i,s){let n=s||2;if(mt(e)){let t=[];for(let i of e.vertices){let e=Math.max(n,i.width,2*i.radius),s=Math.max(n,i.height,2*i.radius);t.push({i:i,b:new a(i.x-e/2,i.y-s/2,e,s)})}if(e.type===T.Rect)for(let i of e.segments){let s=Math.max(e.strokeWidth,n);"v"===(i.vertex1.x===i.vertex2.x?"v":"h")?t.push({i:i,b:new a(i.vertex1.x-s/2,Math.min(i.vertex1.y,i.vertex2.y)-s/2,s,Math.abs(i.vertex1.y-i.vertex2.y))}):t.push({i:i,b:new a(Math.min(i.vertex1.x,i.vertex2.x)-s/2,i.vertex1.y-s/2,Math.abs(i.vertex1.x-i.vertex2.x),s)})}for(let e of t)if(e.b.overlap(i))return e.i;return null}if(!_t(e)&&e.children&&e.children.length>0){for(let s of e.children)if(s.bounds.overlap(i)){let e=t(s,i,n);if(e)return e}return null}return null},t.layout=Qc,t.linearGradient=td,t.polarToCartesian=function(t,e,i,s){return Et(t,e,i,s)},t.rectHitTest=function(t,e){let i=[];if(!t.children||0==t.children.length)return t.bounds.overlap(e)&&t.type!==T.Scene?[t]:[];for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];n.bounds.overlap(e)&&i.push(n)}return i},t.renderer=function(t,e){switch(t){case"svg":return new Re(e);case"webgl":return e in Zc||(Zc[e]=new We(e)),Zc[e]}},t.scene=Kc,t.sceneLoader=function(){return new Ve},t.specExecutor=function(){return new Ge},t.specGenerator=function(){return new je},t.treejson=async function(t){let e=await ed("GET",t);return new Ce(JSON.parse(e),t)},Object.defineProperty(t,"__esModule",{value:!0})}));