mascot-vis 3.0.3 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mascot-cjs.js +186 -0
- package/dist/mascot-esm.js +1 -1
- package/dist/mascot-umd.js +1 -1
- package/package.json +3 -2
package/dist/mascot-umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* version: 3.0.
|
|
1
|
+
/* version: 3.0.4 */
|
|
2
2
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3")):"function"==typeof define&&define.amd?define(["exports","d3"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).msc={},e.d3)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);const i={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var e=this.getCanvas();return e?e.getContext("2d"):null}};class s{constructor(e,t,r){this._id="predicate_"+Vt(),this._type=e||a.POINT,this._variableType=t,this._variableName=r,this._value=void 0}get type(){return this._type}get value(){return this._value}set value(e){this._value=e}get id(){return this._id}get variableType(){return this._variableType}get variableName(){return this._variableName}}const a=Object.freeze({POINT:"point",INTERVAL:"interval",LIST:"list"});class o extends s{constructor(e,t,r){super(e,t,r)}testElement(e){let t;if("attribute"==this._variableType){if(!e.dataScope)return!1;t=e.dataScope.getAttributeValue(this._variableName)}else t=e[this._variableName];return this._value[0]<=t&&this._value[1]>=t}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value[0]<=t&&this._value[1]>=t}return!1}}class l extends s{constructor(e,t,r){super(e,t,r)}addValue(e){this._value||(this._value=[]),this._value.push(e)}resetValue(){this._value=void 0}testElement(e){if("attribute"==this._variableType){if(!e.dataScope)return!1;let t=e.dataScope.getAttributeValue(this._variableName);return this._value.indexOf(t)>=0}return this._value.indexOf(e[this._variableName])>=0}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value.indexOf(t)>=0}return!1}}class u extends s{constructor(e,t,r){super(e,t,r)}testElement(e){if("attribute"==this._variableType){if(!e.dataScope)return!1;return e.dataScope.getAttributeValue(this._variableName)==this._value}return e[this._variableName]==this._value}testTuple(e){if("attribute"==this._variableType){let t=e[this._variableName];return this._value===t}return!1}}function c(e){let t,r="attribute"in e?"attribute":"property",n=e[r];switch(e.type){case a.LIST:t=new l(e.type,r,n);break;case a.INTERVAL:t=new o(e.type,r,n);break;case a.POINT:default:t=new u(e.type,r,n)}return e.value&&(t.value=e.value),t}function h(e,t){for(let r of t){if(!c(r).testElement(e))return!1}return!0}class d{constructor(e,t,r,n){this._x=e+r/2,this._y=t+n/2,this._width=r,this._height=n}translate(e,t){this._x+=e,this._y+=t}toJSON(){let e={};return e.x=this._x,e.y=this._y,e.width=this._width,e.height=this._height,e}union(e){let t=Math.min(this.left,e.left),r=Math.min(this.top,e.top),n=Math.max(this.right,e.right),i=Math.max(this.bottom,e.bottom);return new d(t,r,n-t,i-r)}clone(){return new d(this.left,this.top,this._width,this._height)}get left(){return this._x-this._width/2}set left(e){this._x=e+this._width/2}get right(){return this._x+this._width/2}set right(e){this._x=e-this._width/2}get top(){return this._y-this._height/2}set top(e){this._y=e+this._height/2}get bottom(){return this._y+this._height/2}set bottom(e){this._y=e-this._height/2}get x(){return this._x}get y(){return this._y}get center(){return this.x}get middle(){return this.y}get width(){return this._width}setWidth(e,t){switch(t){case y.RIGHT:this._x=this.right-e/2;break;case y.CENTER:this._width=2*e;break;default:this._x=this.left+e/2}this._width=e}get height(){return this._height}setHeight(e,t){switch(t){case y.TOP:this._y=this.top+e/2;break;case y.MIDDLE:this._height=2*e;break;default:this._y=this.bottom-e/2}this._height=e}contains(e,t){return this.left<=e&&this.right>=e&&this.top<=t&&this.bottom>=t}overlap(e){return!(this.right<e.left||this.bottom<e.top||this.left>e.right||this.top>e.bottom)}}function f(e){let t=e[0].clone();for(let r=1;r<e.length;r++)t=t.union(e[r]);return t}function p(e){return f(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.refBounds?e.refBounds:e.bounds)))}function _(e){return f(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.bounds)))}function g(e){let t=I(e);for(let e of t)e._updateBounds();let r=[];for(let e of t)e.parent&&!r.includes(e.parent)&&r.push(e.parent);for(let e of r)g(e)}const y=Object.freeze({TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",CENTER:"center",MIDDLE:"middle"});function m(e){return e.id+"-bg"}function b(e){return e.id+"-path"}function v(e){switch(e){case y.TOP:return"text-before-edge";case y.BOTTOM:return"auto";case y.LEFT:return"start";case y.RIGHT:return"end";case y.CENTER:case y.MIDDLE:return"middle";default:return e}}const x=Object.freeze({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"});class E{constructor(e){let t=e||{};this._stops=[],this.type=Nt.LinearGradient,this.id=this.type+Vt(),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 e={};return e.type=this.type,e.id=this.id,e.x1=this.x1,e.x2=this.x2,e.y1=this.y1,e.y2=this.y2,e.stops=this._stops,e}addStop(e,t,r){this._stops.push({offset:e,color:t,opacity:r})}get stops(){return this._stops}}class w{constructor(e){if(this._dataScope=void 0,this._type="type"in e?e.type:Nt.Mark,this._id=e.id?e.id:this._type+"_"+Vt(),this._classId=void 0,this._bounds=void 0,this._rotate=void 0,this._refBounds=void 0,this._styles={},void 0!==e)for(let t in x)t in e&&(this.styles[t]=e[t])}get scene(){return M(this)}set strokeColor(e){this.styles.strokeColor=e}get strokeColor(){return this.styles.strokeColor}set strokeWidth(e){this.styles.strokeWidth=e}get strokeWidth(){return this.styles.strokeWidth}set strokeDash(e){this.styles.strokeDash=e}get strokeDash(){return this.styles.strokeDash}set fillColor(e){this.styles.fillColor=e}get fillColor(){return this.styles.fillColor}get rotation(){return this._rotate}get id(){return this._id}set id(e){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=e,this.getScene()._itemMap[e]=this):this._id=e}get classId(){return this._classId?this._classId:this._id}set classId(e){this._classId=e}get type(){return this._type}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this._refBounds?this._refBounds:this.bounds}contains(e,t){if(!this.bounds)return!1;if(!this.bounds.contains(e,t))return!1;switch(this.type){case Nt.Rect:case Nt.PointText:return!0;case Nt.Circle:return Math.sqrt(Math.pow(e-this.x,2)+Math.pow(t-this.y,2))<=this.radius+this.strokeWidth;case Nt.Path:{let r=i.getContext(),n=new Path2D(this.getSVGPathData());return r.lineWidth=Math.max(this.strokeWidth,2.5),r.stroke(n),this.closed?r.isPointInPath(n,e,t):r.isPointInStroke(n,e,t)}case Nt.Line:{let r=i.getContext(),n=new Path2D(this.getSVGPathData());return r.lineWidth=Math.max(this.strokeWidth,2.5),r.stroke(n),r.isPointInStroke(n,e,t)}default:{let r=i.getContext(),n=new Path2D(this.getSVGPathData());return r.isPointInPath(n,e,t)}}}set dataScope(e){this._dataScope=e}get dataScope(){return this._dataScope}get styles(){return this._styles}set styles(e){this._styles=e}set visibility(e){this.styles.visibility=e}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(e){this.styles.opacity=e}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone())}}function A(e){return e instanceof w&&e.type!==Nt.Gridlines}const C=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"text",Polygon:"polygon",BezierCurve:"bezierCurve"});function R(e,t,r){const n=document.getElementById(e),i=n.createSVGPoint();i.x=t,i.y=r;const s=i.matrixTransform(n.getScreenCTM().inverse());return[s.x,s.y]}function k(e,t,r,n){return Math.sqrt(Math.pow(e-r,2)+Math.pow(t-n,2))}function S(e,t,r,n,i){const s=i*Math.PI/180,a=e-r,o=t-n;return{x:a*Math.cos(s)-o*Math.sin(s)+r,y:a*Math.sin(s)+o*Math.cos(s)+n}}const T={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}},O={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var e=this.getCanvas();return e?e.getContext("2d"):null}};function I(e,t){let r=M(e),n=t||r;if("vertex"===e.type){return N(e,V(n,[{property:"classId",value:e.parent.classId}]))}if("segment"===e.type){return L(e,V(n,[{property:"classId",value:e.parent.classId}]))}return e.classId?V(n,[{property:"classId",value:e.classId}]):[e]}function N(e,t){if(!e.classId){if(e.dataScope){let r=e.parent;if(!r)throw new Error("vertex has no parent mark");let n=[];if(r.type===Nt.Area){let i=r.vertices.indexOf(e)<r.vertices.length/2;for(let e of t){let t=i?e.vertices.slice(0,e.vertices.length/2):e.vertices.slice(e.vertices.length/2);n=n.concat(t.filter((e=>e.dataScope)))}}else for(let e of t)n=n.concat(e.vertices.filter((e=>e.dataScope)));return n}{let r=e.parent;if(!r)throw new Error("vertex has no parent mark");let n=r.vertices.indexOf(e),i=[];for(let e of t)i.push(e.vertices[n]);return i}}}function L(e,t){if(e.dataScope){if(!e.parent)throw new Error("segment has no parent mark");let r=[];for(let e of t)r=r.concat(e.segments);return r}{let r=e.parent;if(!r)throw new Error("segment has no parent mark");let n=r.segments.indexOf(e),i=[];for(let e of t)i.push(e.segments[n]);return i}}function V(e,t){let r=[];return B(e,t,r),r}function P(e,t){let r=e.children.filter((e=>e.type==Nt.Collection));if(0!==r.length)for(let e of r){let r=e;for(;r&&r.dataScope;){if(r.dataScope.hasAttribute(t))return r;r=r.children?r.children[0]:void 0}}}function D(e){return e.type==Nt.Collection?e:e.parent?D(e.parent):void 0}function B(e,t,r){if(e&&"axis"!=e.type&&"legend"!=e.type&&"gridlines"!=e.type)if(h(e,t)&&r.push(e),e.vertices)for(let n of e.vertices.concat(e.segments))h(n,t)&&r.push(n);else if(e.children&&e.children.length>0)for(let n of e.children)B(n,t,r)}function M(e){let t=e;for(;t;){if(t.type==Nt.Scene)return t;t=t.parent}}function G(e){let t=e;for("vertex"!=t.type&&"segment"!=t.type||(t=t.parent);t.parent&&[Nt.Collection,Nt.Glyph].includes(t.parent.type);)t=t.parent;return t}function j(e,t,r,n){let i=V(e,[{property:"type",value:t}]);for(let e of i)if(z(e,r,n))return e}function z(e,t,r){switch(e.type){case Nt.Path:case Nt.Arc:case Nt.BezierCurve:case Nt.Line:{let n=i.getContext(),s=new Path2D(e.getSVGPathData());return n.lineWidth=Math.max(e.strokeWidth,2.5),n.stroke(s),e.closed?n.isPointInPath(s,t,r):n.isPointInStroke(s,t,r)}case Nt.Circle:{let n=e.x,i=e.y;if(e.rotation){let t=S(n,i,e.rotation[1],e.rotation[2],e.rotation[0]);n=t.x,i=t.y}return Math.sqrt(Math.pow(t-n,2)+Math.pow(r-i,2))<=e.radius+e.strokeWidth}default:return e.bounds.contains(t,r)}}function F(e,t){let r=[];if(U(e,r),t){let e={};for(let t of r)e[t.classId]=t;return Object.values(e)}return r}function U(e,t){if(A(e))t.push(e);else if(e.type==Nt.Collection&&e.children)for(let r of e.children)U(r,t);else if(e.type==Nt.Glyph&&e.children)for(let r of e.children)U(r,t);else if(e.type==Nt.Composite&&e.children)for(let r of e.children)U(r,t)}class H{constructor(){this._refElements=[]}addRefElement(e){this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}const W=Object.freeze({GRID:"grid",STACK:"stack",PACKING:"packing",FORCE:"force",DIRECTED:"directedgraph",TIDYTREE:"tidytree",TREEMAP:"treemap",STRATA:"strata",CIRCULAR:"circular",CLUSTER:"cluster"});function Y(e,t){return!!(e.startsWith("h")&&[y.LEFT,y.CENTER,y.RIGHT].indexOf(t)>=0)||(!!(e.startsWith("v")&&[y.TOP,y.MIDDLE,y.BOTTOM].indexOf(t)>=0)||(console.warn("Invalid alignment:",t),!1))}class X{constructor(e){this._id=e+"_"+Vt(),this._type=e,this._inputVars=[],this._outputVars=[]}run(){console.log("-",this._type,this.outputVar.element?this.outputVar.element.type:"",this.outputVar.channel?this.outputVar.channel:"")}get id(){return this._id}get type(){return this._type}get inputVars(){return this._inputVars}get outputVars(){return this._outputVars}get outputVar(){return this._outputVars[0]}isIsolated(){return 0==this._inputVars.length&&0==this._outputVars.length}}const q=Object.freeze({CONDUIT:"conduit",ENCODER:"encoder",LAYOUT:"layout",LINK_PLACER:"linkRouter",CONSTRAINT:"constraint",EVAL_BBOX:"evalBBox",EVAL_REFBOUNDS:"evalRefBounds",AFFIXER:"affixer",ALIGNER:"aligner",DOMAIN_BUILDER:"domainBuilder",SCALE_BUILDER:"scaleBuilder",AXIS_PATH_PLACER:"axisPathPlacer",AXIS_TICKS_PLACER:"axisTicksPlacer",AXIS_LABELS_PLACER:"axisLabelsPlacer",AXIS_TITLE_PLACER:"axisTitlePlacer",GRIDLINES_PLACER:"gridlinesPlacer",GRID_LAYOUT:"gridLayout",STACK_LAYOUT:"stackLayout",PACK_LAYOUT:"packLayout",FORCE_LAYOUT:"forceLayout",DIRECTED_LAYOUT:"directedLayout",TIDY_TREE_LAYOUT:"tidyTreeLayout",TREEMAP_LAYOUT:"treemapLayout",STRATA_LAYOUT:"strataLayout",CIRCULAR_LAYOUT:"circularLayout",CLUSTER_LAYOUT:"clusterLayout",BIN_TRANSFORMER:"binTransformer",FILTER_TRANSFORMER:"filterTransformer",KDE_TRANSFORMER:"kdeTransformer",TARGET_EVALUATOR:"targetEvaluator"});class K{constructor(e){this._id="v_"+Vt(),this._type=e,this._incomings=[],this._outgoings=[],this._undirected=[]}get id(){return this._id}get incomingEdges(){return this._incomings}get outgoingEdges(){return this._outgoings}get undirectedEdges(){return this._undirected}get type(){return this._type}get incomingDataflow(){for(let e of this._incomings)if(e.fromNode&&e.fromNode instanceof X)return e.fromNode;return null}isIsolated(){return 0==this._incomings.length&&0==this._outgoings.length}}const Z=Object.freeze({CHANNEL:"channel",PROPERTY:"property",ATTRIBUTE:"attribute",ITEMS:"items",DATASCOPE:"datascope",DOMAIN:"domain",BOUNDS:"bounds",ORDER:"order",SCALE:"scale",COND_ENCODING:"condEncoding",AFFIXATION:"affixation",ALIGNMENT:"alignment",TRIGGER:"trigger"});class $ extends K{constructor(e,t){super(e),this._condEnc=t}get condEncoding(){return this._condEnc}}const J=Object.freeze({RowFirst:"rowFirst",ColumnFirst:"columnFirst"}),Q=Object.freeze({TopLeft:"topLeft",TopRight:"topRight",BottomLeft:"bottomLeft",BottomRight:"bottomRight"}),ee={HORIZONTAL:"horizontal",VERTICAL:"vertical",ANGULAR:"angular",RADIAL:"radial"},te={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"},re=Object.freeze({CLOCKWISE:"clockwise",ANTI_CLOCKWISE:"anti-clockwise"}),ne=Object.freeze({INWARD:"inward",OUTWARD:"outward"});class ie{constructor(e,t,r,n){this.type="vertex",this._id=n,this._x=e,this._y=t,this._dataScope=void 0,this.parent=r,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 dataScope(){return this._dataScope}set dataScope(e){this._dataScope=e}get bounds(){switch(this.shape){case"rect":return new d(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new d(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new d(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}_clone(e){let t=new ie(this.x,this.y,e,this._id);return this._dataScope&&(t._dataScope=this._dataScope.clone()),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}get polarAngle(){return this._polarAngle}get scene(){return this.parent.scene}get x(){return this._x}get y(){return this._y}}ie.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class se{constructor(e,t,r,n){this.type="segment",this._id=n,this.vertex1=e,this.vertex2=t,this.dataScope=void 0,this.parent=r}get id(){return this.parent.id+"_s_"+this._id}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}get scene(){return this.parent.scene}}class ae extends w{constructor(e){super(e),this._type="type"in e?e.type:Nt.Path,this.vertices=[],this.vertexCounter=0,this._sortBy={},this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed=!1,this.curveMode="linear",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;for(let t of ie.styles)t in e&&(this["_"+t]=e[t]);"vertices"in e&&this._setVertices(e.vertices),this._sourceAnchor="sourceAnchor"in e?e.sourceAnchor:["center","middle"],this._targetAnchor="targetAnchor"in e?e.targetAnchor:["center","middle"],this._sourceOffset="sourceOffset"in e?e.sourceOffset:[0,0],this._targetOffset="targetOffset"in e?e.targetOffset:[0,0],this._strength="strength"in e?e.strength:.85,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}_setVertices(e){let t;this.vertices=[],this.segments=[],this.vertexCounter=0,this.segmentCounter=0;for(let r=0;r<e.length;r++)if(r!=e.length-1||e[r][0]!==e[0][0]||e[r][1]!==e[0][1]||this.type!==Nt.Path){t=new ie(e[r][0],e[r][1],this,this.vertexCounter++);for(let e of ie.styles)if(this[e]){let r=e.replace("vx","");t[r[0].toLowerCase()+r.slice(1)]=this[e]}this.vertices.push(t),r>0&&this.segments.push(new se(this.vertices[r-1],this.vertices[r],this,this.segmentCounter++))}let r=e[0],n=e[e.length-1];(r[0]===n[0]&&r[1]===n[1]||this.type===Nt.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new se(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(e){e.attrs=Object.assign({},this.attrs),e.styles=Object.assign({},this.styles);for(let t of ie.styles)this["_"+t]&&(e["_"+t]=this["_"+t]);this._dataScope&&(e._dataScope=this._dataScope.clone()),e.closed=this.closed,e.curveMode=this.curveMode,e.vertices=[],e.segments=[];for(let t of this.vertices)e.vertices.push(t._clone(e));e.segmentCounter=0;for(let t=1;t<e.vertices.length;t++)e.segments.push(new se(e.vertices[t-1],e.vertices[t],e,e.segmentCounter++));e.closed&&e.segments.push(new se(e.vertices[e.vertices.length-1],e.vertices[0],e,e.segmentCounter++)),e._sourceAnchor=this._sourceAnchor.slice(),e._targetAnchor=this._targetAnchor.slice(),e._sourceOffset=this._sourceOffset.slice(),e._targetOffset=this._targetOffset.slice(),e._beta=this._beta}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get x(){return this.bounds.x}get y(){return this.bounds.y}get strokeColor(){return this.styles.strokeColor}get strokeWidth(){return this.styles.strokeWidth}get fillColor(){return this.styles.fillColor}set fillColor(e){this.styles.fillColor=e}get strokeDash(){return this.styles.strokeDash}set strokeDash(e){this.styles.strokeDash=e}resize(e,t,r,n){let i=this.bounds,s=0===i.width?1:i.width,a=0===i.height?1:i.height;if("right"===r)for(let t of this.vertices)t._x=i.right-e/s*(i.right-t.x);else for(let t of this.vertices)t._x=i.left+e/s*(t.x-i.left);if("top"===n)for(let e of this.vertices)e._y=i.top+t/a*(e.y-i.top);else for(let e of this.vertices)e._y=i.bottom-t/a*(i.bottom-e.y);this._updateBounds()}_updateBounds(){let e=[],t=[];if(this._d){const r=this._d.match(/[a-zA-Z][^a-zA-Z]*/g),n=" ";r.forEach((r=>{let i=r.slice(1).trim().split(n).map(Number);for(let[r,n]of i.entries())r%2==0?e.push(n):t.push(n)}))}else e=this.vertices.map((e=>e.x)),t=this.vertices.map((e=>e.y));let r=Math.min(...e),n=Math.min(...t),i=Math.max(...e),s=Math.max(...t),a=i-r,o=s-n;if(this._bounds=new d(r,n,a,o),this.type===Nt.Line||this.type===Nt.Path){let e=this.styles.strokeWidth?this.styles.strokeWidth:1;r===i?this._bounds=new d(r-e/2,n,i-r+e,s-n):n===s&&(this._bounds=new d(r,n-e/2,i-r,s-n+e))}}addVertex(e,t,r){let n=new ie(e,t,this,this.vertexCounter++);this.vertices.splice(r,0,n)}sortVertices(e,t){this.vertices.sort(((t,r)=>t[e]-r[e])),t&&this.vertices.reverse();for(let e=0;e<this.segments.length;e++){let t=this.segments[e];t.vertex1=this.vertices[e],t.vertex2=this.vertices[(e+1)%this.vertices.length]}}sortVerticesByData(e,t,r){let n;n=r?(t,n)=>r.indexOf(t.dataScope.getValue(e))-r.indexOf(n.dataScope.getAttributeValue(e)):(t,r)=>t.dataScope.getAttributeValue(e)<r.dataScope.getAttributeValue(e)?-1:1,this.vertices.sort(n),t&&this.vertices.reverse();for(let e=0;e<this.segments.length;e++){let t=this.segments[e];t.vertex1=this.vertices[e],t.vertex2=this.vertices[(e+1)%this.vertices.length]}}getSVGPathData(){if(this._d)return this._d;let e=n.path(),t=this._getD3CurveFunction(this.curveMode)(e);t.lineStart();for(let e of this.vertices)t.point(e.x,e.y);return this.closed&&t.point(this.vertices[0].x,this.vertices[0].y),t.lineEnd(),e._}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(e){switch(e){case ue.Natural:return n.curveNatural;case ue.Basis:return n.curveBasis;case ue.BumpX:return n.curveBumpX;case ue.BumpY:return n.curveBumpY;case ue.Linear:return n.curveLinear;case ue.Step:return n.curveStep;case ue.CatmullRom:return n.curveCatmullRom;case ue.Cardinal:return n.curveCardinal;case ue.Bundle:return n.curveBundle.beta(.5);default:return n.curveLinear}}get vxShape(){return this._vxShape}get vxWidth(){return this._vxWidth}get vxHeight(){return this._vxHeight}get vxRadius(){return this._vxRadius}get vxFillColor(){return this._vxFillColor}get vxStrokeColor(){return this._vxStrokeColor}get vxStrokeWidth(){return this._vxStrokeWidth}get vxOpacity(){return this._vxOpacity}get sourceAnchor(){return this._sourceAnchor}get targetAnchor(){return this._targetAnchor}get sourceOffset(){return this._sourceOffset}get targetOffset(){return this._targetOffset}}function oe(e,t){const r=T.getSVG();let n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d",e.getSVGPathData()),r.appendChild(n);let i=n.getTotalLength();return n.getPointAtLength(i*t)}function le(e){return e instanceof ae&&e.source&&e.target}const ue={Natural:"natural",Basis:"basis",BumpX:"bumpX",BumpY:"bumpY",Bundle:"bundle",Linear:"linear",Step:"step",CatmullRom:"CatmullRom",Cardinal:"cardinal"};function ce(e,t,r){const n=e.match(/[a-zA-Z][^a-zA-Z]*/g),i=",";return n.map((e=>{const n=e[0],s=e.slice(1).trim();if("M"===n||"L"===n||"T"===n){const[e,a]=s.split(i).map(Number);return`${n}${e+t} ${a+r}`}if("C"===n){const e=s.split(i).map(Number);return`${n}${e[0]+t} ${e[1]+r} ${e[2]+t} ${e[3]+r} ${e[4]+t} ${e[5]+r}`}if("Q"===n){const e=s.split(i).map(Number);return`${n}${e[0]+t} ${e[1]+r} ${e[2]+t} ${e[3]+r}`}if("A"===n){const e=s.split(i).map(Number);return`${n}${e[0]} ${e[1]} ${e[2]} ${e[3]} ${e[4]} ${e[5]+t} ${e[6]+r}`}return"Z"===n||"z"===n?n:e})).join(" ")}class he extends ae{constructor(e){super(e),this._type=Nt.Arc,this.closed=!0,this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._innerRadius="innerRadius"in e?e.innerRadius:100,this._outerRadius="outerRadius"in e?e.outerRadius:200,this._thickness="thickness"in e?e.thickness:this._outerRadius-this._innerRadius,this._startAngle="startAngle"in e?e.startAngle:0,this._endAngle="endAngle"in e?e.endAngle:90,this._sr=de(this._startAngle),this._er=de(this._endAngle),this._direction="direction"in e?e.direction:re.ANTI_CLOCKWISE;let t=this._x+this._innerRadius*Math.cos(this._sr),r=this._y-this._innerRadius*Math.sin(this._sr),n=this._x+this._innerRadius*Math.cos(this._er),i=this._y-this._innerRadius*Math.sin(this._er),s=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),l=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[t,r],[s,a],[o,l],[n,i]])}get type(){return 0===this._innerRadius?Nt.Pie:Nt.Arc}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}get direction(){return this._direction}get x(){return this._x}get y(){return this._y}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}setAngles(e,t){this._startAngle=e,this._endAngle=t,this._sr=de(this._startAngle),this._er=de(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)}_updateBounds(){let e=this.vertices.map((e=>e.x)),t=this.vertices.map((e=>e.y)),r=Math.min(...e),n=Math.min(...t),i=Math.max(...e)-r,s=Math.max(...t)-n;this._bounds=new d(r,n,i,s)}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._innerRadius=this._innerRadius,e._outerRadius=this._outerRadius,e._startAngle=this._startAngle,e._endAngle=this._endAngle,e._thickness=this._thickness,e._direction=this._direction,e._sr=this._sr,e._er=this._er}getSVGPathData(){let e=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,t=e>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,e,t,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,e,t,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}}function de(e){return e*Math.PI/180}function fe(e){return 180*e/Math.PI}function pe(e){return(e%360+360)%360}function _e(e,t,r,n){let i=e-r,s=n-t;return Math.atan2(s,i)*(180/Math.PI)}class ge{constructor(e){this._attr2value={},this._dt=e,this._tuples=this._dt.data}isFullTable(){return 0===Object.keys(this._attr2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get attributes(){return Object.keys(this._attr2value)}get dataTable(){return this._dt}get filters(){return this._attr2value}merge(e){let t=new ge(this._dt);for(let e in this._attr2value)t=t.cross(e,this._attr2value[e]);for(let r in e._attr2value)t=t.cross(r,e._attr2value[r]);return t}cross(e,t){if(e in this._attr2value&&this._attr2value[e]!==t)return console.warn("Conflict in attribute values when merging dataScope:",e,this._attr2value[e],t),this;let r=this.clone();return r._attr2value[e]=t,r._updateTuples(e,t),r}clone(){let e=new ge(this._dt);return e._attr2value=Object.assign({},this._attr2value),e._tuples=this._tuples.map((e=>e)),e}getAttributeValue(e){let t=this.getAttributeValues(e);return t.length,t[0]}getAttributeValues(e){let t=this._tuples.map((t=>t[e]));return t=[...new Set(t)],t}getUniqueAttributeValues(e){let t=this._tuples.map((t=>t[e]));return[...new Set(t)]}hasAttribute(e){return e in this._attr2value}getAttributeType(e){return this._dt.getAttributeType(e)}aggregateNumericalAttribute(e,t){let r=this._tuples.map((t=>t[e]));switch(t){case me.Max:return Math.max(...r);case me.Min:return Math.min(...r);case me.Avg:case me.Mean:return n.mean(r);case me.Median:return n.median(r);case me.Count:return r.length;case me.Percentile25:return n.quantile(r,.25);case me.Percentile75:return n.quantile(r,.75);case me.Sum:default:return n.sum(r)}}_updateTuples(e,t){this._tuples=this._tuples.filter((r=>r[e]==t))}get tuples(){return this._tuples}}function ye(e){return"vertex"==e.type||"segment"==e.type?e.dataScope?e.dataScope:e.parent.dataScope:e.dataScope}const me={Max:"max",Min:"min",Avg:"avg",Median:"median",Sum:"sum",Count:"count",Mean:"mean",Percentile25:"percentile 25",Percentile75:"percentile 75"};class be{constructor(e,t){this._id=Nt.TreeData+Vt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._data=e,this._nodeList=[],this._linkList=[],this._nodeHash={},this._traverse(e,this._nodeList,this._linkList),this._nodeTable=new Pt(this._nodeList,"nodes"),this._linkTable=new Pt(this._linkList,"links"),this._nodeTable.tree=this,this._linkTable.tree=this}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}_traverse(e,t,r,n=0){let i={};Ae in e||(e[Ae]="n"+t.length),t.push(i),e._depth=n;for(let s in e)if("children"==s&&e[s]&&e[s].length>0)for(let i of e[s]){let s=this._traverse(i,t,r,n+1);r.push({parent:e[Ae],child:s})}else i[s]=e[s];return this._nodeHash[i[Ae]]=i,i[Ae]}getNodeDataScope(e){return new ge(this._nodeTable).cross(Bt,e[Bt])}getNode(e){return this._nodeHash[e]}getRoot(){return this._nodeTable.data[0]}getChildren(e){let t=e[Ae],r=[],n=this._linkTable.data,i=this._nodeTable.data;for(let e in n)if(n[e].parent==t){let t=n[e].child,s=i.findIndex((e=>e[Ae]==t));r.push(i[s])}return r}getParent(e){let t=e[Ae],r=this._linkTable.data,n=this._nodeTable.data;for(let e in r)if(r[e].child==t){let t=r[e].parent,i=n.findIndex((e=>e[Ae]==t));return n[i]}}}function ve(e){return e.dataScope._dt.tree}class xe{constructor(e,t){this._id=Nt.NetworkData+Vt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._nodeTable=new Pt(e.nodes,this._id+"_nodes"),this._linkTable=new Pt(e.links,this._id+"_links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._rawNodes=e.nodes,this._rawLinks=e.links,this._nodeHash={};for(let t of e.nodes)this._nodeHash[t[Ae]]=t}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodeList(){return this._rawNodes}get linkList(){return this._rawLinks}getNode(e){return this._nodeHash[e]}getLinks(e){let t=e[Ae],r=this._rawLinks,n=[];for(let e in r)r[e].target!==t&&r[e].source!==t||n.push(r[e]);return n}buildNodeHierarchy(e){let t={};return t[Ae]="root",we(t,this._rawNodes,e),new be(t,this.url)}}function Ee(e){return e.dataScope._dt.graph}function we(e,t,r){if(0===t.length||0===r.length)return;"children"in e||(e.children=[]);let n={};for(let e of t){let t=e[r[0]];t in n||(n[t]=[]),n[t].push(e)}if(1===r.length)for(let t in n){let r={children:n[t]};r[Ae]=t,e.children.push(r)}else for(let t in n){let i={};i[Ae]=t,e.children.push(i),we(i,n[t],r.slice(1))}}const Ae="id";function Ce(e,t){if(t.hasAttribute(e))return!0;if(t.tree&&t.tree.nodeTable.hasAttribute(e.split(".")[1]))return!0;throw new Error(["Attribute",e,"does not exist in the table",t.name].join(" "))}const Re=Object.freeze({Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"});function ke(e){var t=Object.values(Re);for(let r=0;r<e.length;r++){let n=e[r];if(null!=n){for(let e=0;e<t.length;e++)Se[t[e]](n)||(t.splice(e,1),e-=1);if(1==t.length)return t[0]}}return t[0]}const Se={boolean:function(e){return"true"===e||"false"===e||!0===e||!1===e||"[object Boolean]"==toString.call(e)},integer:function(e){return Se.number(e)&&(e=+e)==~~e},number:function(e){return!isNaN(+e)&&"[object Date]"!=toString.call(e)},date:function(e){let t=new Date(e);return null!=t&&!isNaN(t)},string:function(e){return!0}};function Te(e,t){let r={};switch(t){case Re.Boolean:r.trueCount=e.filter((e=>e)).length,r.falseCount=e.filter((e=>!e)).length;break;case Re.Date:r.min=n.min(e),r.max=n.max(e),r.extent=[r.min,r.max],r.unique=[...new Set(e)];break;case Re.String:r.unique=[...new Set(e)];break;default:r.min=n.min(e),r.max=n.max(e),r.extent=[r.min,r.max],r.mean=n.mean(e),r.median=n.median(e),r.unique=[...new Set(e)]}return r}function Oe(e,t,r,n,i){let s=i.getAttributeType(r);if(s!=Re.String&&s!=Re.Date&&s!=Re.Number&&s!=Re.Integer)throw new Error("Densify only works on a string or date attribute: "+r+" is "+s);if(!function(e){if([Nt.Line,Nt.Circle,Nt.Rect,Nt.Area].indexOf(e.type)<0)return!1;if(e.dataScope){let t=I(e,e.scene);for(let e of t)if(e.dataScope.numTuples>1)return!0;return!1}return!0}(t))throw new Error("The "+t.type+" is not dividable");switch(t.type){case Nt.Line:return function(e,t,r){let n,i,s=I(e);for(let a of s){let s=a.dataScope?a.dataScope:new ge(r),o=r.getUniqueAttributeValues(t).map((e=>s.cross(t,e)));o=o.filter((e=>!e.isEmpty())),1===o.length&&o.push(o[0].clone());let l=Object.assign({},a.styles);for(let e of ie.styles)a[e]&&(l[e]=a[e]);let u=a.vertices[0].x,c=a.vertices[0].y,h=[],d=a.vertices[1].x-u,f=a.vertices[1].y-c;for(let e=0;e<o.length;e++)h.push([u+e*d/(o.length-1),c+e*f/(o.length-1)]);l.vertices=h,l.type="path";let p=kt(l);i||(i=p.id),p._classId=i,p.dataScope=s,p._updateBounds(),p._refBounds=p.bounds.clone();let _=a.parent;_.addChild(p),_.removeChild(a);for(let[e,t]of p.vertices.entries())t.dataScope?t.dataScope=t.dataScope.merge(o[e]):t.dataScope=o[e];a==e&&(n=p)}return n}(t,r,i);case Nt.Circle:return function(e,t,r,n,i){let s,a,o=I(e),l=r.getAttributeType(t);for(let u of o){let o=u.dataScope?u.dataScope:new ge(r),c=r.getUniqueAttributeValues(t).map((e=>o.cross(t,e)));c=l==Re.Number?c:c.filter((e=>!e.isEmpty()));let h=c.length;if(h<3)throw new Error("INSUFFICIENT_DATA_SCOPES");let d=n||90,f=360/h,p=[],_=[],g="clockwise"==(i||"clockwise")?-1:1;for(let e=0;e<c.length;e++){let t=d+g*e*f;_[e]=t;let r=Ie(u.x,u.y,u.radius,_[e]);p.push(r)}let y=Object.assign({},u.styles);y.vertices=p,y.type="polygon",y.x=u.x,y.y=u.y,y.radius=u.radius;let m=kt(y);a||(a=m.id),m._classId=a,m.dataScope=o;let b=u.parent;b.addChild(m),b.removeChild(u);for(let[e,t]of m.vertices.entries())t._polarAngle=_[e],e>=c.length?t.dataScope=o.merge(c[2*c.length-1-e]):t.dataScope=o.merge(c[e]);u===e&&(s=m)}return s}(t,r,i);case Nt.Rect:return function(e,t,r,n){let i,s,a=I(e),o=t||ee.HORIZONTAL;if(o!=ee.HORIZONTAL&&o!=ee.VERTICAL)throw new Error("Unknown orientation: "+o);for(let t of a){let a=n.getAttributeType(r),l=t.dataScope?t.dataScope:new ge(n),u=n.getUniqueAttributeValues(r).map((e=>l.cross(r,e)));u=a==Re.Number?u:u.filter((e=>!e.isEmpty())),1===u.length&&u.push(u[0].clone()),a!=Re.Number&&a!=Re.Date||u.sort(((e,t)=>e._attr2value[r]>t._attr2value[r]?1:-1));let c=Object.assign({},t.styles),h=t.vertices[0].x,d=t.vertices[0].y,f=t.vertices[t.vertices.length-2].x,p=t.vertices[t.vertices.length-2].y,_=[],g=f-h,m=p-d;for(let e=0;e<u.length;e++)_.push(o==ee.VERTICAL?[f,d+e*m/(u.length-1)]:[h+e*g/(u.length-1),d]);for(let e=0;e<u.length;e++)_.push(o==ee.VERTICAL?[h,d+(u.length-1-e)*m/(u.length-1)]:[h+(u.length-1-e)*g/(u.length-1),p]);c.vertices=_,c.type="area";let b=kt(c);s||(s=b.id),b._classId=s,b.dataScope=l,b.orientation=o,b.baseline=o===ee.HORIZONTAL?y.BOTTOM:y.LEFT;let v=t.parent;v.addChild(b),v.removeChild(t);for(let[e,t]of b.vertices.entries())e>=u.length?t.dataScope=l.merge(u[2*u.length-1-e]):t.dataScope=l.merge(u[e]);t===e&&(i=b)}return i}(t,n,r,i)}}function Ie(e,t,r,n){return[r*Math.cos(de(n))+e,t-r*Math.sin(de(n))]}class Ne extends K{constructor(e,t,r){super(e),this._channel=t,this._elem=r}get channel(){return this._channel}get element(){return this._elem}}const Le=Object.freeze({X:"x",Y:"y",WIDTH:"width",HEIGHT:"height",RADIUS:"radius",FILLCOLOR:"fillColor",STROKECOLOR:"strokeColor",FILLGRADIENT:"fillGradient",TEXT:"text",ANGLE:"angle",THICKNESS:"thickness",AREA:"area",FONTSIZE:"fontSize",RADIALDISTANCE:"radialDistance",STROKEWIDTH:"strokeWidth",OPACITY:"opacity",VISIBILITY:"visibility",STRENGTH:"strength"});function Ve(e,t){delete t._encodings[Me(e.element)][e.channel]}function Pe(e,t){let r=e.scene._encodings[Me(e)],n=[];if(r&&(n=n.concat(Object.values(r))),t){let t=e.scene;for(let r in t._encodings){let i=r.split("_");i.pop(),i.join("_")===e.classId&&(n=n.concat(Object.values(t._encodings[r])))}}return n}function De(e,t,r){for(let n in r._encodings){let i=r._encodings[n];if(i[t]&&i[t].attribute==e)return i[t]}return null}function Be(e,t){let r=e.scene._encodings[Me(e)];return r&&r[t]?r[t]:null}function Me(e){if(e.classId)return e.classId;if("vertex"==e.type&&e.dataScope){if(e.parent.type===Nt.Area){let t=e.parent.vertices.indexOf(e)<e.parent.vertices.length/2;return e.parent.classId+"_v"+(t?0:e.parent.vertices.length-1)}return e.parent.classId+"_v"}return"vertex"==e.type?e.parent.classId+"_v"+e.parent.vertices.indexOf(e):"segment"==e.type&&e.dataScope?e.parent.classId+"_s":"segment"==e.type?e.parent.classId+"_s"+e.parent.segments.indexOf(e):null}function Ge(e,t){if(0==e.children.length)return[];let r=M(e),n=e.type===Nt.Composite?e.children:[e.children[0]],i=Object.keys(r._encodings),s=[];for(let e of n){let t=e;for(;t;){if(t.classId&&s.indexOf(t.classId)<0&&s.push(t.classId),t.type===Nt.Glyph){t.children.forEach((e=>s.push(e.classId)));break}if(!t.children)break;t=t.children[0]}}let a=[];for(let e of i)for(let n of s)0===e.indexOf(n)&&r._encodings[e][t]&&a.push(r._encodings[e][t]);return a}function je(e){let t=Be(e,"y"),r=Be(e,"height");return t||r&&r.scales[0].domain[0]<0}function ze(e){let t=Be(e,"x"),r=Be(e,"width");return t||r&&r.scales[0].domain[0]<0}function Fe(e,t){let r=function(e){let t=e.parent,r=[];for(;t.type!==Nt.Scene;)r.push(t),t=t.parent;return r}(e);for(let e of r)if(Be(e,t))return!1;return r.length>=2?r[r.length-2]:e}function Ue(e,t,r){switch(e.type){case Nt.Rect:case Nt.Path:case Nt.Line:case Nt.Area:!function(e,t,r){for(let n of e.vertices)He(n,t,r);e._updateBounds(),e._refBounds&&e._refBounds.translate(t,r)}(e,t,r);break;case Nt.Group:case Nt.Collection:case Nt.Glyph:!function(e,t,r){for(let n of e.children)Ue(n,t,r);e._layout&&(void 0!==e._layout._left&&(e._layout._left+=t),void 0!==e._layout._top&&(e._layout._top+=r),e._layout._cellBounds&&e._layout._cellBounds.forEach((e=>e.translate(t,r))))}(e,t,r);break;case"segment":!function(e,t,r){He(e.vertex1,t,r),He(e.vertex2,t,r)}(e,t,r);break;default:!function(e,t,r){e._x+=t,e._y+=r,e._refBounds&&e._refBounds.translate(t,r)}(e,t,r)}}function He(e,t,r){e._x+=t,e._y+=r}function We(e,t,r){switch(t){case"x":Xe(e,r);break;case"y":qe(e,r);break;case"width":!function(e,t){e.resize(t,e.height)}(e,r);break;case"height":!function(e,t){e.resize(e.width,t)}(e,r);break;case"radius":e.radius=r;break;case"strength":e._strength=r;break;case"area":e.type===Nt.Circle?e.radius=Math.sqrt(r/Math.PI):e.type===Nt.Rect&&e.resize(Math.sqrt(r),Math.sqrt(r)),e._updateBounds();break;case"text":e._text=r;break;case"curveMode":e.curveMode=r;break;case"baseline":e.baseline=r;break;case"angle":[Nt.Arc,Nt.Pie].includes(e.type)&&function(e,t){e._endAngle=pe(e._startAngle+t),e._sr=de(e._startAngle),e._er=de(e._endAngle),e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,r);break;case"startAngle":!function(e,t){let r=e.angle;e._startAngle=t,e._endAngle=pe(e._startAngle+r),e._sr=de(e._startAngle),e._er=de(e._endAngle),e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,r);break;case"thickness":!function(e,t){Ye(e,e._innerRadius+t)}(e,r);break;case"innerRadius":!function(e,t){e._innerRadius=t,e.vertices[0]._x=e._x+e._innerRadius*Math.cos(e._sr),e.vertices[0]._y=e._y-e._innerRadius*Math.sin(e._sr),e.vertices[3]._x=e._x+e._innerRadius*Math.cos(e._er),e.vertices[3]._y=e._y-e._innerRadius*Math.sin(e._er)}(e,r);break;case"outerRadius":Ye(e,r);break;case"radialDistance":{let t=Ie(e.parent.x,e.parent.y,r,e.polarAngle);Xe(e,t[0]),qe(e,t[1]);break}case"visibility":e.visibility=r;break;default:if("vertex"===e.type)e[t]=r;else if(e instanceof yt)for(let n of e.children)We(n,t,r);else e.styles[t]=r}}function Ye(e,t){e._outerRadius=t,e.vertices[1]._x=e._x+e._outerRadius*Math.cos(e._sr),e.vertices[1]._y=e._y-e._outerRadius*Math.sin(e._sr),e.vertices[2]._x=e._x+e._outerRadius*Math.cos(e._er),e.vertices[2]._y=e._y-e._outerRadius*Math.sin(e._er)}function Xe(e,t){"vertex"==e.type?e._x=t:Ue(e,t-e.x,0)}function qe(e,t){"vertex"==e.type?e._y=t:Ue(e,0,t-e.y)}class Ke extends ae{constructor(e){super(e)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}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(e,t,r,n){e!==this.width&&("right"===r?(this.vertices[1]._x=this.refBounds.right,this.vertices[2]._x=this.refBounds.right,this.vertices[0]._x=this.vertices[1]._x-e,this.vertices[3]._x=this.vertices[0]._x):(this.vertices[0]._x=this.refBounds.left,this.vertices[3]._x=this.refBounds.left,this.vertices[1]._x=this.vertices[0]._x+e,this.vertices[2]._x=this.vertices[1]._x)),t!==this.height&&("top"===n?(this.vertices[0]._y=this.refBounds.top,this.vertices[1]._y=this.refBounds.top,this.vertices[3]._y=this.vertices[0]._y+t,this.vertices[2]._y=this.vertices[3]._y):(this.vertices[2]._y=this.refBounds.bottom,this.vertices[3]._y=this.refBounds.bottom,this.vertices[0]._y=this.vertices[3]._y-t,this.vertices[1]._y=this.vertices[0]._y))}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 Ze extends ae{constructor(e){super(e),this._type=Nt.Area,this.closed=!0,this._orientation="orientation"in e?e.orientation:void 0,this._baseline="baseline"in e?e.baseline:void 0,e&&"vertices"in e&&this.segments.push(new se(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get topLeftVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[0]:this.vertices[this.vertices.length-1]}get bottomLeftVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[this.vertices.length-1]:this.vertices[this.vertices.length/2]}get topRightVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[this.vertices.length/2-1]:this.vertices[0]}get bottomRightVertex(){return this._orientation===ee.HORIZONTAL?this.vertices[this.vertices.length/2]:this.vertices[this.vertices.length/2-1]}get baseline(){return this._baseline}set baseline(e){this._baseline=e}get orientation(){return this._orientation}set orientation(e){this._orientation=e}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(e){super.copyPropertiesTo(e),e._baseline=this._baseline,e._orientation=this._orientation}getSVGPathData(){return super.getSVGPathData()+" z"}}class $e extends K{constructor(e,t){super(e),this._encs=[t],this._initialized=!1}addLinkedEncoding(e){this._encs.push(e)}get encodings(){return this._encs}get initialized(){return this._initialized}set initialized(e){this._initialized=e}}class Je{constructor(e,t){this._event=t,this._type=e}get event(){return this._event}get type(){return this._type}}const Qe=Object.freeze({ELEMENT:"element",MOUSE:"mouse",ATTRIBUTE:"attribute",WIDGET:"widget",KEYBOARD:"keyboard"});Object.freeze({INPUT:"input",HOVER:"hover",BRUSH:"brush",BRUSH_X:"brushX",BRUSH_Y:"brushY",CLICK:"click"});class et extends X{constructor(e){super(e)}storeValues(e,t){this._storedValues={};let r=I(e);for(let e of r)this._storedValues[e.id]=e[t]}_restoreValues(e){let t=this.outputVar.channel;e.forEach((e=>{e.styles[t]=this._storedValues[e.id]}))}run(){super.run();let e=this.inputVars.find((e=>e instanceof $e)),t=this.outputVar,r=I(t.element);if(e){let r=e.encodings.find((e=>e.channel==t.channel&&Me(e.element)==Me(t.element)));for(let e of r.scales){let t=r.getElements(e);this._doMapping(t,e,r.attrValues,r),this._updateRefBounds(t,e,r)}}else this._restoreValues(r);let n=this._getUsableCondEncodings();n.length>0&&this._doCondEncoding(r,n.map((e=>e.condEncoding))),g(["vertex","segment"].includes(t.element.type)?t.element.parent:t.element)}_updateRefBounds(e,t,r){switch(this.outputVar.channel){case"width":e.forEach((e=>{e._refBounds.setWidth(t.rangeExtent)}));break;case"height":e.forEach((e=>{e._refBounds.setHeight(t.rangeExtent)}));break;case"radius":e.forEach((e=>{e._refBounds.setWidth(2*t.rangeExtent,y.CENTER),e._refBounds.setHeight(2*t.rangeExtent,y.MIDDLE)}));break;case"x":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let n=e.parent._refBounds;e.parent._refBounds=new d(r.flipScale?t.range[1]:t.range[0],n.top,t.rangeExtent,n.height)}));break;case"y":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let n=e.parent._refBounds;e.parent._refBounds=new d(n.left,r.flipScale?t.range[0]:t.range[1],n.width,t.rangeExtent)}))}}_doMapping(e,t,r,n){switch(this.outputVar.channel){case"width":t.domain[0]<0&&e[0]instanceof Ke?function(e,t,r){for(let n=0;n<e.length;n++){let i=e[n],s=i.refBounds.left+t.map(0),a=i.refBounds.left+t.map(r[i.id]);Ue(i.leftSegment,s-i.leftSegment.x,0),Ue(i.rightSegment,a-i.rightSegment.x,0)}}(e,t,r):t.domain[0]<0&&e[0]instanceof Ze||(e[0].type===Nt.Area?function(e,t,r){let n=e[0].baseline;if(e[0].orientation===ee.VERTICAL)switch(n){case"left":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"x",n.refBounds.left))),I(n.topRightVertex,n).forEach((e=>We(e,"x",n.refBounds.left+t.map(r[e.id]))));break;case"right":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"x",n.refBounds.right-t.map(r[e.id])))),I(n.topRightVertex,n).forEach((e=>We(e,"x",n.refBounds.right)));break;case"center":console.log("center");for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"x",n.refBounds.center-t.map(r[e.id])/2))),I(n.topRightVertex,n).forEach((e=>We(e,"x",n.refBounds.center+t.map(r[e.id])/2)))}}(e,t,r):this._doStandardMapping(e,t,r));break;case"height":t.domain[0]<0&&e[0]instanceof Ke?function(e,t,r){for(let n=0;n<e.length;n++){let i=e[n],s=i.refBounds.bottom-t.map(0),a=i.refBounds.bottom-t.map(r[i.id]);Ue(i.bottomSegment,0,s-i.bottomSegment.y),Ue(i.topSegment,0,a-i.topSegment.y)}}(e,t,r):t.domain[0]<0&&e[0]instanceof Ze?function(e,t,r){for(let n of e){let e=N(n.topLeftVertex,[n]);for(let i of e)We(i,"y",n.refBounds.bottom-t.map(r[i.id]));N(n.bottomLeftVertex,[n]).forEach((e=>We(e,"y",n.refBounds.bottom-t.map(0))))}}(e,t,r):e[0].type===Nt.Area?function(e,t,r){let n=e[0].baseline;if(e[0].orientation===ee.HORIZONTAL)switch(n){case"bottom":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.bottom-t.map(r[e.id])))),I(n.bottomLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.bottom)));break;case"top":for(let n of e)I(n.bottomLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.top+t.map(r[e.id])))),I(n.topLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.top)));break;case"middle":for(let n of e)I(n.topLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.middle-t.map(r[e.id])/2))),I(n.bottomLeftVertex,n).forEach((e=>We(e,"y",n.refBounds.middle+t.map(r[e.id])/2)))}}(e,t,r):this._doStandardMapping(e,t,r);break;case"text":this._doTextMapping(e,r);break;case"fillGradient":!function(e,t,r,n){for(let i of e){let e=i.vertices.map((e=>r[e.id])),s=Math.min(...e),a=Math.max(...e),o="horizontal"===i.orientation?new E({x1:0,y1:100,x2:0,y2:0}):new E({x1:0,y1:0,x2:100,y2:0});if(o.addStop(0,t.map(s),1),n._mapping){let e=Object.keys(n._mapping).map((e=>parseFloat(e))).sort();for(let r of e)r>s&&r<a&&o.addStop(100*(r-s)/(a-s),t.map(r),1)}else"divergingColor"===t.type&&o.addStop(100*-s/(a-s),t.map(0),1);"sequentialColor"===t.type&&o.addStop(100*-s/(a-s),t.map(0),1),o.addStop(100,t.map(a),1),i.fillColor=o}}(e,t,r,n);break;default:this._doStandardMapping(e,t,r)}}_doTextMapping(e,t){let r=this.outputVar.channel;e.forEach((e=>{We(e,r,t[e.id])}))}_doStandardMapping(e,t,r){let n=this.outputVar.channel;e.forEach((e=>{let i=t.map(r[e.id]);We(e,n,i),e instanceof ae&&e.firstVertex&&e.firstVertex.shape&&"strokeColor"===n&&e.vertices.forEach((e=>e.fillColor=i))}))}_doCondEncoding(e,t){for(let r of e){let e=t.map((e=>e.evalResult[r.id])).every((e=>e||void 0===e));t[0]._efxFn(e,t[0].trigger.elements[0],r,t[0].trigger.mouseEvent)}}_updateElement(e,t,r,n){let i;"object"==typeof n&&e.triggerElement?"property"in n?i=e.triggerElement[n.property]:"attribute"in n&&(i=e.triggerElement.dataScope.getAttributeValue(n.attribute)):i=n,["x","y"].includes(r)&&"offset"in n&&(i+=n.offset),We(t,r,i)}_getUsableCondEncodings(){return this.inputVars.filter((e=>e instanceof $))}}class tt extends K{constructor(e,t,r){super(e),this._property=t,this._elem=r}get property(){return this._property}get element(){return this._elem}}const rt=Object.freeze({AXIS_ORIENTATION:"axisOrientation",AXIS_PATH_POSITION:"axisPathPosition",AXIS_TICK_SIZE:"axisTickSize",AXIS_TICK_OFFSET:"axisTickOffset",AXIS_TICKS_POSITION:"axisTicksPosition",AXIS_LABELS_POSITION:"axisLabelsPosition",AXIS_TITLE_POSITION:"axisTitlePosition",AXIS_LABEL_OFFSET:"axisLabelOffset",AXIS_LABEL_FORMAT:"axisLabelFormat",AXIS_FONT_SIZE:"axisFontSize",LEGEND_POSITION:"legendPosition",GRIDLINES_POSITION:"gridlinesPosition",INCLUDE_ZERO:"includeZero",FLIP_SCALE:"flipScale",RANGE_START:"rangeStart",RANGE_EXTENT:"rangeExtent",BASE_LINE:"baseline"});function nt(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.createOneWayDependency(q.EVAL_BBOX);switch(t.connect(n,r),e.type){case Nt.Circle:case Nt.Polygon:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"radius",e),a=t.getVariable(Z.CHANNEL,"area",e);t.connect(s,n),t.connect(r,n),t.connect(i,n),t.connect(a,n);break}case Nt.Area:case Nt.Line:case Nt.BezierCurve:case Nt.Path:case Nt.Image:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n);break}case Nt.Rect:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e),o=t.getVariable(Z.CHANNEL,"area",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n),t.connect(o,n);break}case Nt.PointText:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"text",e);t.connect(r,n),t.connect(i,n),t.connect(s,n);break}case Nt.Ring:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"innerRadius",e),a=t.getVariable(Z.CHANNEL,"outerRadius",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n);break}case Nt.Pie:case Nt.Arc:{let r=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"innerRadius",e),a=t.getVariable(Z.CHANNEL,"outerRadius",e),o=t.getVariable(Z.CHANNEL,"startAngle",e),l=t.getVariable(Z.CHANNEL,"endAngle",e),u=t.getVariable(Z.CHANNEL,"angle",e),c=t.getVariable(Z.CHANNEL,"thickness",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(a,n),t.connect(o,n),t.connect(l,n),t.connect(u,n),t.connect(c,n);break}}n.run()}function it(e,t){let r=t.findVariablesByElement(e);for(let e in r){let n=r[e];for(let e of n)t.deleteVariable(e)}}function st(e,t){let r=t.findVariable(Z.CHANNEL,[e.channel,e.element]);r||console.warn("cannot find encoding to remove from the dep graph");let n=r.incomingDataflow;t.deleteOperator(n)}function at(e,t){if(e.type===Nt.Axis){let r=t.findVariable(Z.PROPERTY,[rt.AXIS_PATH_POSITION,e]).incomingDataflow;t.deleteOperator(r),r=t.findVariable(Z.PROPERTY,[rt.AXIS_TICKS_POSITION,e]).incomingDataflow,t.deleteOperator(r),r=t.findVariable(Z.PROPERTY,[rt.AXIS_LABELS_POSITION,e]).incomingDataflow,t.deleteOperator(r)}else if(e.type===Nt.Gridlines){let r=t.findVariable(Z.PROPERTY,[rt.GRIDLINES_POSITION,e]).incomingDataflow;t.deleteOperator(r)}}function ot(e,t){let r=t.getVariable(Z.BOUNDS,e),n=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"y",e),s=t.getVariable(Z.CHANNEL,"width",e),a=t.getVariable(Z.CHANNEL,"height",e),o=t.createOneWayDependency(q.EVAL_BBOX);t.connect(n,o),t.connect(i,o),t.connect(s,o),t.connect(a,o),t.connect(o,r),o.run()}function lt(e,t,r){let n=r.getVariable(Z.BOUNDS,e),i=r.getVariable(Z.BOUNDS,t),s=r.getIncomingDataflowOperator(q.EVAL_BBOX,n),a=i.outgoingEdges.find((e=>e.fromNode===i&&e.toNode===s));if(a&&r.disconnect(i,s,a),e.layout){let n=r.getVariable(Z.CHANNEL,"x",t),i=r.getIncomingDataflowOperator(ct(e.layout.type),n);i&&r.deleteOperator(i)}}function ut(e,t,r){let n=r.getVariable(Z.BOUNDS,e),i=r.getVariable(Z.BOUNDS,t),s=r.getIncomingDataflowOperator(q.EVAL_BBOX,n);r.connect(i,s),r.connect(s,n),e.layout&&dt(e,e.layout,r)}function ct(e){switch(e){case W.GRID:return q.GRID_LAYOUT;case W.STACK:return q.STACK_LAYOUT;case W.PACKING:return q.PACK_LAYOUT;case W.FORCE:return q.FORCE_LAYOUT;case W.DIRECTED:return q.DIRECTED_LAYOUT;case W.TIDYTREE:return q.TIDY_TREE_LAYOUT;case W.TREEMAP:return q.TREEMAP_LAYOUT;case W.STRATA:return q.STRATA_LAYOUT;case W.CIRCULAR:return q.CIRCULAR_LAYOUT;case W.CLUSTER:return q.CLUSTER_LAYOUT}}function ht(e,t,r){let n=r.getVariable(Z.ORDER,e),i=r.getOutgoingDataflowOperator(ct(t.type),n);r.deleteOperator(i)}function dt(e,t,r){let n=t?t.type:"none",i=n===W.TREEMAP?F(e)[0]:e.children[0];if(!i)return;let s=r.getVariable(Z.CHANNEL,"width",i),a=r.getVariable(Z.CHANNEL,"height",i),o=r.getVariable(Z.ORDER,e),l=r.getVariable(Z.CHANNEL,"x",i),u=r.getVariable(Z.CHANNEL,"y",i),c=r.getOutgoingDataflowOperator(ct(n),o);if(r.connect(s,c),r.connect(a,c),r.connect(o,c),r.connect(c,l),r.connect(c,u),r.disconnectChannelVarFromBBoxOperator(s),r.disconnectChannelVarFromBBoxOperator(a),i.type===Nt.Arc||i.type===Nt.Pie){let e=r.getVariable(Z.CHANNEL,"angle",i),t=r.getVariable(Z.CHANNEL,"thickness",i);r.connect(e,c),r.connect(t,c)}else if(i.type===Nt.Circle){let e=r.getVariable(Z.CHANNEL,"area",i),t=r.getVariable(Z.CHANNEL,"radius",i);r.connect(e,c),r.connect(t,c),r.disconnectChannelVarFromBBoxOperator(e),r.disconnectChannelVarFromBBoxOperator(t)}else if(i.type===Nt.Rect){let e=r.getVariable(Z.CHANNEL,"area",i);r.connect(e,c),r.disconnectChannelVarFromBBoxOperator(e)}if(c.run(),i.links&&ft(i,r),i.children&&i.children[0]){let e=r.getVariable(Z.BOUNDS,i.children[0]),t=r.getVariable(Z.CHANNEL,"x",i).incomingDataflow;t&&r.connect(e,t),r.disconnectChannelVarFromBBoxOperator(e)}}function ft(e,t){let r=e.links[0],n=t.getVariable(Z.CHANNEL,"x",e),i=t.getVariable(Z.CHANNEL,"x",r),s=t.getVariable(Z.CHANNEL,"strokeWidth",r),a=t.getVariable(Z.CHANNEL,"strength",r),o=t.createOneWayDependency(q.LINK_PLACER);t.connect(n,o),t.connect(s,o),t.connect(a,o),t.connect(o,i)}function pt(e,t){let r=t.getVariable(Z.PROPERTY,rt.AXIS_ORIENTATION,e),n=t.getVariable(Z.BOUNDS,e.elements[0].parent),i=t.getVariable(Z.PROPERTY,rt.AXIS_PATH_POSITION,e),s=t.createOneWayDependency(q.AXIS_PATH_PLACER);t.connect(r,s),t.connect(n,s),t.connect(s,i),s.run();let a=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_OFFSET,e),o=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(q.AXIS_TICKS_PLACER),u=t.getVariable(Z.PROPERTY,rt.AXIS_TICKS_POSITION,e);t.connect(i,l),t.connect(a,l),t.connect(o,l),t.connect(l,u),l.run();let c=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_OFFSET,e),h=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_FORMAT,e),d=t.getVariable(Z.PROPERTY,rt.AXIS_FONT_SIZE,e),f=t.createOneWayDependency(q.AXIS_LABELS_PLACER),p=t.getVariable(Z.PROPERTY,rt.AXIS_LABELS_POSITION,e);t.connect(i,f),t.connect(c,f),t.connect(h,f),t.connect(d,f),t.connect(f,p),f.run();let _=t.getVariable(Z.PROPERTY,rt.AXIS_TITLE_POSITION,e),g=t.createOneWayDependency(q.AXIS_TITLE_PLACER);t.connect(i,g),t.connect(g,_),g.run();let y=t.getVariable(Z.BOUNDS,e),m=t.getIncomingDataflowOperator(q.EVAL_BBOX,y);t.connect(u,m),t.connect(p,m),t.connect(m,y)}function _t(e,t){let r=t.getVariable(Z.PROPERTY,rt.AXIS_ORIENTATION,e),n=t.getVariable(Z.BOUNDS,G(e.elements[0])),i=t.getVariable(Z.PROPERTY,rt.AXIS_PATH_POSITION,e),s=t.createOneWayDependency(q.AXIS_PATH_PLACER);t.connect(r,s),t.connect(n,s),t.connect(s,i),s.run();let a=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_OFFSET,e),o=t.getVariable(Z.PROPERTY,rt.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(q.AXIS_TICKS_PLACER),u=t.getVariable(Z.PROPERTY,rt.AXIS_TICKS_POSITION,e);t.connect(i,l),t.connect(a,l),t.connect(o,l),t.connect(l,u),l.run();let c=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_OFFSET,e),h=t.getVariable(Z.PROPERTY,rt.AXIS_LABEL_FORMAT,e),d=t.getVariable(Z.PROPERTY,rt.AXIS_FONT_SIZE,e),f=t.createOneWayDependency(q.AXIS_LABELS_PLACER),p=t.getVariable(Z.PROPERTY,rt.AXIS_LABELS_POSITION,e);t.connect(i,f),t.connect(c,f),t.connect(h,f),t.connect(d,f),t.connect(f,p),f.run();let _=t.getVariable(Z.PROPERTY,rt.AXIS_TITLE_POSITION,e),g=t.createOneWayDependency(q.AXIS_TITLE_PLACER);t.connect(i,g),t.connect(g,_),g.run();let y=t.getVariable(Z.BOUNDS,e),m=t.getIncomingDataflowOperator(q.EVAL_BBOX,y);t.connect(u,m),t.connect(p,m),t.connect(m,y)}function gt(e,t){let r=t.getVariable(Z.BOUNDS,G(e.elements[0])),n=t.getVariable(Z.PROPERTY,rt.GRIDLINES_POSITION,e),i=t.createOneWayDependency(q.GRIDLINES_PLACER);t.connect(r,i),t.connect(i,n),i.run();let s=t.getVariable(Z.BOUNDS,e),a=t.getIncomingDataflowOperator(q.EVAL_BBOX,s);t.connect(n,a),t.connect(a,s)}class yt{constructor(){this._id=this.type+Vt(),this._type=Nt.Group,this._dataScope=void 0,this._bounds=void 0,this._layout=void 0,this._children=[],this._sortBy={}}get id(){return this._id}get type(){return this._type}contains(e,t){return this.bounds.contains(e,t)}get children(){return this._children}addChild(e){this.children.indexOf(e)>=0||(e.parent&&e.parent.removeChild(e),this.children.push(e),e.parent=this)}addChildAt(e,t){e.parent&&e.parent.removeChild(e),this.children.splice(t,0,e),e.parent=this}removeChild(e){let t=this.children.indexOf(e);t>=0&&(this.children.splice(t,1),e.parent=null)}removeChildAt(e){this.children[e].parent=null,this.children.splice(e,1)}removeAll(){for(let e of this.children)e.parent=null;this._children=[]}get dataScope(){return this._dataScope}set dataScope(e){if(this._dataScope=e,void 0===e)for(let t of this.children)t.dataScope=e;else for(let t of this.children)t.dataScope?t.dataScope=t.dataScope.merge(e):t.dataScope=e}getInternalEncodings(e){if(0==this.children.length)return[];let t=this.children[0],r=this.getScene(),n=Object.keys(r.encodings),i=[];for(;t;){if(t.classId&&i.indexOf(t.classId)<0&&i.push(t.classId),t.type===Nt.Glyph){t.children.forEach((e=>i.push(e.classId)));break}if(!t.children)break;t=t.children[0]}let s=[];for(let t of n){let n=t.split("_");for(let a of i)n[0]==a&&r.encodings[t][e]&&s.push(r.encodings[t][e])}return s}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(e){if(this._layout=e,e&&(e.group=this),dt(this,e,this.scene._depGraph),this.children&&this.children.length>0){let e=F(this,!0);for(let t of e)this.scene.onChange(Z.CHANNEL,"x",t)}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let e=this.children.map((e=>e.refBounds)),t=Math.min(...e.map((e=>e.left))),r=Math.min(...e.map((e=>e.top))),n=Math.max(...e.map((e=>e.right))),i=Math.max(...e.map((e=>e.bottom)));return new d(t,r,n-t,i-r)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){let e=this.children;if(e.length>0){this._bounds=e[0].bounds.clone();for(let t=1;t<e.length;t++)"hidden"!=e[t].visibility&&(this._bounds=this._bounds.union(e[t].bounds))}else this._bounds=new d(0,0,0,0)}set visibility(e){this._visibility="hidden"==e?e:"visible";for(let t of this.children)t.visibility=e}get visibility(){return this._visibility?this._visibility:"visible"}get scene(){return M(this)}}class mt extends yt{constructor(){super(),this._type=Nt.Collection,this._id=this.type+"_"+Vt(),this._classId=this.id,this._childrenOrder=void 0}get classId(){return this._classId}contains(e,t){if([Nt.Arc,Nt.Pie,Nt.Polygon,Nt.Area].indexOf(this.firstChild.type)>=0){let r=this.getSVGPathData();if(""!==r){let n=i.getContext(),s=new Path2D(r);return n.lineWidth=Math.max(this.strokeWidth,2.5),n.stroke(s),n.isPointInPath(s,e,t)}}return this._bounds.contains(e,t)}getSVGPathData(){let e="";for(let t of this.children)if(t.getSVGPathData)e+=t.getSVGPathData();else if(t.bounds){let r=t.bounds;e+=["M",r.left,r.top].join(" "),e+=["L",r.right,r.top].join(" "),e+=["L",r.right,r.bottom].join(" "),e+=["L",r.left,r.bottom,"Z"].join(" ")}return e}}class bt extends yt{constructor(e){if(super(),this._type=Nt.Glyph,this._id=this.type+"_"+Vt(),this._classId=this._id,e)for(let t of e)this.addChild(t)}get classId(){return this._classId}}class vt extends ae{constructor(e){super(e),this._type=Nt.BezierCurve,this._orientation="orientation"in e?e.orientation:ee.HORIZONTAL}get type(){return this._type}get orientation(){return this._orientation}copyPropertiesTo(e){super.copyPropertiesTo(e),e._orientation=this._orientation}getSVGPathData(){if(this._d)return this._d;let e="M ";return e+=this.vertices[0].x+" "+this.vertices[0].y+" ",e+="C "+this.vertices[1].x+" "+this.vertices[1].y+" ",e+=this.vertices[2].x+" "+this.vertices[2].y+" ",e+=this.vertices[3].x+" "+this.vertices[3].y,e}}class xt extends w{constructor(e){super(e),this._type=Nt.Circle,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._radius="radius"in e?e.radius:100,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"fillColor"in this.styles||(this.styles.fillColor="none"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none")}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}set radius(e){this._radius=e}get area(){return Math.PI*Math.pow(this._radius,2)}_updateBounds(){if(this._rotate){let e=S(this._x,this._y,this._rotate[1],this._rotate[2],this._rotate[0]);this._bounds=new d(e.x-this._radius,e.y-this._radius,2*this._radius,2*this._radius)}else this._bounds=new d(this._x-this._radius,this._y-this._radius,2*this._radius,2*this._radius)}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._radius=this._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(" ")}}class Et extends w{constructor(e){super(e),this._type=Nt.Image,this._src=e.src,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._width="width"in e?e.width:100,this._height="height"in e?e.height:100}get src(){return this._src}set src(e){this._src=e}get width(){return this._width}set width(e){this._width=e,this._updateBounds()}get height(){return this._height}set height(e){this._height=e,this._updateBounds()}get x(){return this._x}set x(e){this._x=e,this._updateBounds()}get y(){return this._y}set y(e){this._y=e,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new d(this._x,this._y,this._width,this._height)}copyPropertiesTo(e){e.attrs=Object.assign({},this.attrs),e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e.x=this._x,e.y=this._y,e.width=this._width,e.height=this._height,e.src=this._src}}class wt extends ae{constructor(e){super(e)}get x1(){return this.vertices[0].x}get y1(){return this.vertices[0].y}get x2(){return this.vertices[1].x}get y2(){return this.vertices[1].y}get x(){return(this.vertices[0].x+this.vertices[1].x)/2}get y(){return(this.vertices[0].y+this.vertices[1].y)/2}set x(e){let t=e-this.x;this.vertices[0]._x+=t,this.vertices[1]._x+=t}set y(e){let t=e-this.y;this.vertices[0]._y+=t,this.vertices[1]._y+=t}set x1(e){this.vertices[0]._x=e}set x2(e){this.vertices[1]._x=e}set y1(e){this.vertices[0]._y=e}set y2(e){this.vertices[1]._y=e}}class At extends w{constructor(e){super(e),this._type=Nt.PointText,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._text="text"in e?e.text:"",this._anchor="anchor"in e?e.anchor:[y.CENTER,y.MIDDLE],this._textPath=void 0,this._textPathOffset="50%","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"),"backgroundColor"in e&&(this._backgroundColor=e.backgroundColor),"borderWidth"in e&&(this._borderWidth=e.borderWidth),"borderColor"in e&&(this._borderColor=e.borderColor),this._rotate="rotate"in e?e.rotate:void 0}hasBackground(){return this._backgroundColor||this._borderStroke||this._borderColor}_updateBounds(){let e,t,r=function(e,t,r){let n=O.getContext();n.font=t;let i=n.measureText(e);return i.fontBoundingBoxAscent?{width:i.width,height:i.fontBoundingBoxAscent+i.fontBoundingBoxDescent}:i.actualBoundingBoxAscent?{width:i.width,height:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent}:{width:i.width,height:r}}(this._text,[this.fontWeight,this.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),n=r.width,i=r.height;switch(this._anchor[0]){case y.LEFT:e=this._x;break;case y.RIGHT:e=this._x-n;break;case y.CENTER:e=this._x-n/2;break;default:e=this._x}switch(this._anchor[1]){case y.TOP:t=this._y;break;case y.BOTTOM:t=this._y-i;break;case y.MIDDLE:default:t=this._y-i/2}if(this._rotate&&3===this._rotate.length){let r=[{x:e,y:t},{x:e+n,y:t},{x:e,y:t+i},{x:e+n,y:t+i}].map((e=>S(e.x,e.y,this._rotate[1],this._rotate[2],this._rotate[0]))),s=Math.min(...r.map((e=>e.x))),a=Math.max(...r.map((e=>e.x))),o=Math.min(...r.map((e=>e.y))),l=Math.max(...r.map((e=>e.y)));this._bounds=new d(s,o,a-s,l-o)}else this._bounds=new d(e,t,n,i)}get x(){return this._x}get y(){return this._y}get text(){return this._text}get anchor(){return this._anchor}get fontFamily(){return this.styles.fontFamily}get fontSize(){return this.styles.fontSize}get fontWeight(){return this.styles.fontWeight}get textPath(){return this._textPath}get textPathOffset(){return this._textPathOffset}get backgroundColor(){return this._backgroundColor?this._backgroundColor:"#fff"}get borderColor(){return this._borderColor?this._borderColor:"#ccc"}get borderWidth(){return this._borderWidth?this._borderWidth:1}copyPropertiesTo(e){e.styles=Object.assign({},this.styles),this._dataScope&&(e._dataScope=this._dataScope.clone()),e._x=this._x,e._y=this._y,e._text=this._text,e._anchor=[this._anchor[0],this._anchor[1]],e._backgroundColor=this._backgroundColor,e._borderColor=this._borderColor,e._borderStroke=this._borderStroke}}class Ct extends ae{constructor(e){super(e),this._type=Nt.Polygon,this.closed=!0,"x"in e&&(this._x=e.x),"y"in e&&(this._y=e.y),"radius"in e&&(this._radius=e.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._radius=this._radius}}class Rt extends ae{constructor(e){super(e),this._type=Nt.Ring,this.closed=!0,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._innerRadius="innerRadius"in e?e.innerRadius:100,this._outerRadius="outerRadius"in e?e.outerRadius:200}get innerRadius(){return this._innerRadius}get outerRadius(){return this._outerRadius}get x(){return this._x}get y(){return this._y}get thickness(){return this._outerRadius-this._innerRadius}copyPropertiesTo(e){super.copyPropertiesTo(e),e._x=this._x,e._y=this._y,e._innerRadius=this._innerRadius,e._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(" ")}}function kt(e){let t=null;switch(e.type){case Nt.Circle:t=new xt(e);break;case Nt.Line:var r="x1"in e?e.x1:0,n="y1"in e?e.y1:0,i="x2"in e?e.x2:100,s="y2"in e?e.y2:100;e.vertices=[[r,n],[i,s]],t=new wt(e);break;case Nt.Rect:var a="top"in e?e.top:0,o="left"in e?e.left:0,l="width"in e?e.width:50,u="height"in e?e.height:30;e.vertices=[[o,a],[o+l,a],[o+l,a+u],[o,a+u]],t=new Ke(e);break;case Nt.PointText:t=new At(e);break;case Nt.Image:t=new Et(e);break;case Nt.BundledPath:case Nt.Chord:case Nt.Path:t=new ae(e);break;case Nt.Area:t=new Ze(e);break;case Nt.Ring:t=new Rt(e);break;case Nt.Arc:t=new he(e);break;case Nt.BezierCurve:"vertices"in e||(e.vertices=[[0,100],[20,120],[80,180],[100,200]]),t=new vt(e);break;case Nt.Polygon:t=new Ct(e)}return t&&t._updateBounds(),t}function St(e){let t=new mt;return e.addChild(t),e._itemMap[t.id]=t,t}function Tt(e){return new bt(e)}function Ot(e){switch(e.type){case Nt.Collection:return function(e){let t=St(e.scene);for(let r=0;r<e.children.length;r++){let n=e.children[r];t.addChild(Ot(n))}if(t._classId=e.classId,e._layout){let r=e._layout.clone();t._layout=r,r.group=t}return t._updateBounds(),t}(e);case Nt.Glyph:return function(e){let t=new bt;for(let r of e.children)t.addChild(Ot(r));t._classId=e.classId,e._dataScope&&(t.dataScope=e._dataScope.clone());return t}(e);default:return function(e){let t=kt({type:e.type});e.copyPropertiesTo(t),t._classId=e.classId,t._bounds=e.bounds.clone(),e._refBounds||(e._refBounds=e.bounds.clone());t._refBounds=e._refBounds.clone(),e.dataScope&&(t._dataScope=e.dataScope.clone());if(e.vertices)for(let r=0;r<e.vertices.length;r++)e.vertices[r].dataScope&&(t.vertices[r]._dataScope=e.vertices[r].dataScope.clone());return t}(e)}}const It=Object.freeze({Rect:"rect",Circle:"circle",Line:"line",Ring:"ring",Path:"path",Image:"image",PointText:"text",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord"}),Nt=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",Chord:"chord",Line:"line",Path:"path",Image:"image",PointText:"text",Collection:"collection",Group:"group",Composite:"composite",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable",Layout:"layout",NetworkData:"networkdata",TreeData:"treedata"}),Lt=Object.freeze({Axis:"axis",Legend:"legend",Gridlines:"gridlines"});function Vt(){return Date.now().toString(36)+"_"+Math.random().toString(36).slice(2)}class Pt{constructor(e,t,r){this._id=Nt.DataTable+Vt(),this.initialize(e,t,r)}initialize(e,t,r){if(this.url=t,this._rawData=JSON.parse(JSON.stringify(e)),this._data=e,this._dateMap=new Map,this._attributes=0===this._data.length?[]:Object.keys(this._data[0]),this._newAttribute=0,r)this._attrTypes=r;else{this._attrTypes={};for(let e of this._attributes)this._attrTypes[e]=ke(this.data.map((t=>t[e]))),"year"==e.toLowerCase()&&this._attrTypes[e]==Re.Integer&&(this._attrTypes[e]=Re.Date)}this._validate(this.data,this._attrTypes),this._attrSummaries={};for(let e of this._attributes)this._attrSummaries[e]=Te(this.data.map((t=>t[e])),this._attrTypes[e]);this._attributes.indexOf(Bt)<0&&this._addAttribute(Bt,Re.String,this.data.map(((e,t)=>"r"+t)))}clone(){let e=[];for(let t of this._data)e.push(Object.assign({},t));let t=new Pt(e,this.url,Object.assign({},this._attrTypes));return t.sourceDataTable=this,t}get id(){return this._id}get name(){return this.url?function(e){var t=e.indexOf("\\")>=0?e.lastIndexOf("\\"):e.lastIndexOf("/"),r=e.substring(t);0!==r.indexOf("\\")&&0!==r.indexOf("/")||(r=r.substring(1));return r}(this.url):this.id}get data(){return this._data}getEncodableAttributes(e){switch(e){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.numericAttributes.concat(this.nonNumericAttributes);default:return this.numericAttributes}}_addAttribute(e,t,r){this._data.forEach(((t,n)=>t[e]=r[n])),e!==Bt&&this._rawData.forEach(((t,n)=>t[e]=r[n])),this._attrTypes[e]=t,this._attributes.push(e),this._attrSummaries[e]=Te(r,t)}getAttributeType(e){return this._attrTypes[e]}get attributes(){return this._attributes}getAttributeSummary(e){return this._attrSummaries[e]}getAttributeValues(e){return this.data.map((t=>t[e]))}getUniqueAttributeValues(e){return this._attrSummaries[e].unique}orderAttributeValues(e,t){this._attrSummaries[e].unique=t}getRowCount(){return this.data.length}hasAttribute(e){return this._attributes.indexOf(e)>=0}parseAttributeAsDate(e,t){let r=n.timeParse(t);for(let t of this.data){let n=t[e];null==n||null==n?(n="",t[e]=new Date(1899,11,31).getTime()):t[e]=r(n).getTime(),this._dateMap.set(t[e],n)}this._attrTypes[e]=Re.Date,this._attrSummaries[e]=Te(this.data.map((t=>t[e])),Re.Date)}getRawValue(e,t){return this.getAttributeType(e)===Re.Date?this._dateMap.get(t).toString():t}get nonNumericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!=Re.Number&&this._attrTypes[t]!=Re.Integer&&t!=Pt.RowID&&e.push(t);return e.sort(((e,t)=>this.getUniqueAttributeValues(e).length-this.getUniqueAttributeValues(t).length)),e}get numericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!==Re.Number&&this._attrTypes[t]!==Re.Integer||t==Pt.RowID||e.push(t);return e}getAttributesByType(e){let t=[];for(let r in this._attrTypes)this._attrTypes[r]===e&&r!=Pt.RowID&&t.push(r);return t}summarize(){for(let e of this._attributes)this._attrSummaries[e]=Te(this.data.map((t=>t[e])),this._attrTypes[e])}_validate(e,t){for(let r of e)for(let e in t){let n,i=t[e],s=r[e];if(null==r[e]||null==r[e])switch(i){case Re.Boolean:n=!1;break;case Re.Date:n=new Date(1899,11,31).getTime();break;case Re.String:n="";break;default:n=0}else switch(i){case Re.Boolean:n=s;break;case Re.Date:n=Number.isInteger(s)?new Date(s,0).getTime():new Date(s+"").getTime(),this._dateMap.set(n,s);break;case Re.String:n=s.toString();break;default:n=s}r[e]=n}}}function Dt(e){let t=ye(e);if(t)return t.dataTable}const Bt="mascot_rowId";function Mt(e,t){return fetch(t,{method:e}).then((e=>e.ok?e.text():(console.log(e.status),Promise.reject({status:e.status,statusText:e.statusText})))).catch((e=>(console.log(e),Promise.reject({status:e.status,statusText:e.statusText}))))}class Gt extends K{constructor(e,t){super(e),this._elem=t}get element(){return this._elem}}class jt extends K{constructor(e,t){super(e),this._item=t}get element(){return this._item}}class zt{constructor(e){this._id=e+"_"+Vt(),this._type=e,this._vars=[],this._edges=[]}get vars(){return this._vars}get edges(){return this._edges}run(){console.log("-",this._type)}}class Ft{constructor(e,t,r=!0){this._id="e_"+Vt(),this._fromNode=e,this._toNode=t,this._isDirected=r}get id(){return this._id}get fromNode(){return this._fromNode}get toNode(){return this._toNode}get isDirected(){return this._isDirected}get operator(){return this._fromNode instanceof X||this._fromNode instanceof zt?this._fromNode:this._toNode}}class Ut extends K{constructor(e,t,r){super(e),this._attribute=t,this._dataset=r}get attribute(){return this._attribute}get dataset(){return this._dataset}}class Ht extends K{constructor(e,t){super(e),this._encs=[t]}addLinkedEncoding(e){this._encs.push(e)}get encodings(){return this._encs}}class Wt extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=e.encodings[0],r=this.inputVars.find((e=>e instanceof Ut)).attribute,n=e.encodings[0].dataTable.getAttributeType(e.encodings[0].attribute),i=[];for(let t of e.encodings){let e=this._computeAttrValues(t,n);i=i.concat(e)}if("angle"===t.channel&&[Nt.Arc,Nt.Pie].indexOf(t.element.type)>=0)for(let n of e.encodings)for(let e of n.scales){let i=n.getElements(e).map((e=>n.attrValues[e.id]));e.domain=t._preferredDomain?t._preferredDomain:n.dataTable.tree?[0,n.dataTable.tree.getRoot()[r]]:this._getDomainForNumbers(i),console.log("domain for",r,e.domain)}else{let s;s=n==Re.String||"text"===e.encodings[0].channel?this._getDomainForStrings(i):this._getDomainForNumbers(i);for(let r of e.encodings)for(let e of r.scales)e.domain=t._preferredDomain?t._preferredDomain:s.slice();console.log("domain for",r,s)}}_getDomainForNumbers(e){let t=this.outputVar.encodings[0],r=[Math.min(...e),Math.max(...e)];if(t.includeZero&&r[0]>0&&(r=[0,Math.max(...e)]),t.mapping)r=Object.keys(t.mapping),r=r.map((e=>parseFloat(e))),r.sort(((e,t)=>e-t));else if("sequentialColor"===t.scales[0].type){if(r[0]<0&&r[1]>0){let e=Math.max(Math.abs(r[0]),Math.abs(r[1]));r=[-e,e]}}else if("angle"===t.channel){r=[0,Object.values(e).reduce(((e,t)=>e+t),0)]}return r}_getDomainForStrings(e){let t,r=this.outputVar,n=r.encodings[0];return t="count"==r.encodings[0].aggregator?[0,Math.max(...e)]:Array.from(new Set(e)),n.mapping&&(t=Object.keys(n.mapping)),t}_computeAttrValues(e,t){let r=I(e.element),n={};if(e.element.type===Nt.Area&&["width","height","fillGradient"].indexOf(e.channel)>=0)for(let t of r)for(let r of t.vertices)n[r.id]=ye(r).aggregateNumericalAttribute(e.attribute,e.aggregator);else switch(t){case Re.Boolean:break;case Re.Date:for(let t of r)n[t.id]=ye(t).getAttributeValue(e.attribute);break;case Re.String:try{if("count"==e.aggregator)for(let t of r)n[t.id]=ye(t).getAttributeValues(e.attribute).length;else for(let t of r)n[t.id]=ye(t).getAttributeValue(e.attribute)}catch(t){throw new Error("Cannot bind "+this.channel+" to "+e.attribute+" : "+t)}break;default:if(e.attribute.startsWith("parent.")||e.attribute.startsWith("child.")){let t=e.dataTable.tree.nodeTable,i=e.attribute.split(".")[0],s=e.attribute.split(".")[1];for(let e of r){let r=ye(e).getAttributeValue(i);n[e.id]=new ge(t).cross(Ae,r).getAttributeValue(s)}}else for(let t of r)n[t.id]=ye(t).aggregateNumericalAttribute(e.attribute,e.aggregator)}return e.attrValues=n,Object.values(n)}}class Yt{constructor(e,t){switch(this._id="scale_"+Vt(),this._type=e,t&&(this._args=t),e){case"linear":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(n[t.scheme]);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":t.scheme?this._scale=n.scaleSequential(n[t.scheme]):this._scale=n.scaleSequential()}}get id(){return this._id}get domain(){return this._scale.domain()}set domain(e){this._scale.domain(e)}get range(){return this._scale.range()}set range(e){this._scale.range(e)}get rangeExtent(){let e=this._scale.range();return Math.abs(e[1]-e[0])}set rangeExtent(e){let t=this._scale.range();t[0]<t[1]?this._scale.range([t[0],t[0]+e]):this._scale.range([t[1]+e,t[1]])}get type(){return this._type}map(e){return this._scale(e)}}const Xt=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],qt=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class Kt extends X{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=e.encodings,r=t[0],n=r.channel;for(let i=0;i<r.scales.length;i++){let s=r.scales[i],a=r.getElements(s),o=this._buildRange(n,a,r,e);if(o)for(let e of t)e.scales[i].range=o;console.log("range",r.scales[i].range)}e.initialized=!0}_buildRange(e,t,r,n){return"x"===e?this._buildXRange(t,r,n):"y"===e?this._buildYRange(t,r,n):["width","height","radius","area","fontSize","radialDistance","strokeWidth"].includes(e)?this._buildSizeRange(t,r,n):e.indexOf("Color")>0||"fillGradient"===e?this._buildColorRange(t,r):"angle"===e?this._buildAngleRange(t,r):"thickness"===e?this._buildThicknessRange(t,r,n):void 0}_buildThicknessRange(e,t,r){let n=e.map((e=>e.outerRadius-e.innerRadius));return[0,r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(...n)]}_buildAngleRange(e,t){return[0,360]}_buildColorRange(e,t){if(t.mapping){return t.scales[0].domain.map((e=>t.mapping[e+""]))}if("sequentialColor"===t.scales[0].type){let e=this.outputVar,r=t.scales[0].domain;for(let i of e.encodings)if(!t.colorScheme)for(let e of i.scales){let t=e.domain;e._scale=n.scaleSequential(r[0]<0&&r[1]>0?n.interpolatePuOr:n.interpolateTurbo),e._scale.domain(t)}}if((Xt.indexOf(t.colorScheme)>=0||qt.indexOf(t.colorScheme)>=0)&&"ordinalColor"===t.scales[0].type){let e=this.outputVar,r=t.scales[0].domain;for(let i of e.encodings)for(let e of i.scales){let i=e.domain;e._scale=n.scaleOrdinal(n[t.colorScheme][r.length]),e._scale.domain(i)}}}_buildSizeRange(e,t,r){let n,i;return n=0,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:Math.max(...e.map((e=>"radius"===t.channel?e.refBounds.width/2:"strokeWidth"===t.channel?e.strokeWidth:"radialDistance"===t.channel?e.parent.radius:"area"===t.channel?e.type===Nt.Circle?Math.PI*Math.pow(e.radius,2):e.width*e.height:"fontSize"===t.channel?parseFloat(e.fontSize):e.refBounds[t.channel]))),[0,0+i]}_buildXRange(e,t,r){let n,i;switch(t.scales[0].type,e[0].type){case"vertex":case"segment":var s=e[0].parent.refBounds?e[0].parent.refBounds:e[0].parent.bounds;n=r.initialized?t.getRangeStart(e[0]):s.left,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:s.width;break;default:n=r.initialized?t.getRangeStart(e[0]):G(e[0]).bounds.left+e[0].bounds.width/2,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:450}return t.flipScale?[n+i,n]:[n,n+i]}_buildYRange(e,t,r){let n,i;switch(t.scales[0].type,e[0].type){case"vertex":case"segment":var s=e[0].parent.refBounds?e[0].parent.refBounds:e[0].parent.bounds;n=r.initialized?t.getRangeStart(e[0]):s.top,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:s.height;break;default:n=r.initialized?t.getRangeStart(e[0]):G(e[0]).bounds.top+e[0].bounds.height/2,i=r.initialized?t.getRangeExtent(e[0]):t._preferredRangeExtent?t._preferredRangeExtent:450}return t.flipScale?[n,n+i]:[n+i,n]}}class Zt extends X{constructor(e){super(e)}run(){super.run()}}class $t extends yt{constructor(e){super(),this._type=Nt.Axis,this._id=this._type+Vt(),this._attribute=void 0,this._channel=void 0,this._orientation=void 0,this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._textColor="textColor"in e?e.textColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._tickOffset="tickOffset"in e?e.tickOffset:0,this._tickSize="tickSize"in e?e.tickSize:5,this._tickAnchor=e.tickAnchor,this._tickVisible=!("tickVisible"in e)||e.tickVisible,this._pathVisible=!("pathVisible"in e)||e.pathVisible,this._labelOffset="labelOffset"in e?e.labelOffset:this._tickSize+this._tickOffset+3,this._labelFormat="labelFormat"in e?e.labelFormat:"",this._titleOffset="titleOffset"in e?e.titleOffset:40,this._rotateYTitle=!("rotateTitle"in e&&!e.rotateTitle),this._showTitle=!("titleVisible"in e)||e.titleVisible,this._labelRotation="labelRotation"in e?e.labelRotation:0,this._ticks=new yt,this._ticks._id=this._id+"_ticks",this.addChild(this._ticks),this._labels=new yt,this._labels._id=this._id+"_labels",this.addChild(this._labels),this._title=new At({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title._id=this.id+"_title",this.addChild(this._title),this._showTitle||(this._title.visibility="hidden"),this._pathPos=void 0}get pathPos(){return this._pathPos}get attribute(){return this._attribute}get channel(){return this._channel}get orientation(){return this._orientation}get tickSize(){return this._tickSize}get tickOffset(){return this._tickOffset}get tickAnchor(){return this._tickAnchor?this._tickAnchor:"x"===this._channel||"width"===this._channel?"center":"middle"}get labelOffset(){return this._labelOffset}get tickValues(){return this._tickValues}get labelValues(){return this._labelValues}get titleOffset(){return this._titleOffset}get boundsWithoutTitle(){let e=this.children.filter((e=>e.type!==Nt.PointText)),t=e[0].bounds.clone();for(let r=1;r<e.length;r++)"hidden"!=e[r].visibility&&(t=t.union(e[r].bounds));return t}}const Jt="top",Qt="bottom",er="left";function tr(e,t,r,i){let s,a=e.domain,o=e.range;switch(e.type){case"linear":case"log":{let l=Math.abs(o[0]-o[1]);s="width"==t||"x"==t?45:30;let u,c=Math.max(2,Math.floor(l/s));if("width"==t||"height"==t){let n=!!i&&(i.elements[0].parent.layout&&i.elements[0].parent.layout.type==W.STACK);a[1]=e._scale.invert(n?_(r)[t]:p(r)[t])}if("log"===e.type){u=[];let t=e._scale.ticks();for(let e of t){let r=Math.log(e)/Math.log(10)+1e-6;Math.abs(r-Math.floor(r))<c/t.length&&u.push(e)}}else u=n.ticks(a[0],a[1],c);return u}case"point":{s="width"==t||"x"==t?80:30;let r=Math.floor(e.rangeExtent/a.length),n=Math.ceil(s/r);return"x"==t?a.filter(((e,t)=>t%n==0)):a}case"time":{s="width"==t||"x"==t?80:30;let e,r,i=Math.floor((o[1]-o[0])/s),l=Math.ceil((a[1]-a[0])/i)/1e3,u=[1,60,3600,86400,2628003,31536e3],c=[n.timeSeconds,n.timeMinutes,n.timeHours,n.timeDays,n.timeMonths,n.timeYears];for(let t=0;t<u.length-1;t++)if(l>=u[t]&&l<u[t+1])return e=Math.floor(l/u[t]),r=c[t],r(a[0],a[1],e);return l>u[u.length-1]?(e=Math.floor(l/u[u.length-1]),r=c[u.length-1],r(a[0],a[1],e)):[]}default:return[]}}function rr(e,t){t.removeChild(e)}class nr extends $t{constructor(e,t,r,n){super(n),this._encoding=e,this._attribute=this._encoding.attribute,this._channel=this._encoding.channel,this._scale=t,this._elems=r,this._flip="flip"in n&&n.flip,this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?Qt:er,this._titleText="title"in n?n.title:this._encoding.attribute,this._path="angle"===this._channel?new xt({strokeColor:this._strokeColor,id:this._id+"_path"}):new ae({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(n),e.dataTable.getAttributeType(this._attribute)!==Re.Date||"labelFormat"in n||(this._labelFormat="%m/%d/%y"),"radialDistance"===this._channel&&"rotation"in n&&(this._rotate=[-n.rotation,this._elems[0].parent.x,this._elems[0].parent.y])}isFlipped(){return this._flip}get elements(){return this._elems}get scale(){return this._scale}createTicksLabels(e){"tickValues"in e?(this._tickValues=e.tickValues,this._labelValues=e.tickValues):(this._tickValues=tr(this._scale,this._channel,this._elems,this),this._labelValues=this._tickValues),this._ticks.removeAll();for(let e=0;e<this._tickValues.length;e++){let t=new ae({strokeColor:this._strokeColor,id:this._id+"_tick"+e});this._tickVisible||(t.visibility="hidden"),this._ticks.addChild(t)}let t;switch(this._labels.removeAll(),this._encoding.dataTable.getAttributeType(this._attribute)){case Re.Date:t=n.timeFormat(this._labelFormat);break;case Re.String:t=function(e){return e};break;default:t=n.format(this._labelFormat)}for(let[e,r]of this._labelValues.entries()){let n=new At({text:t(r),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labels.addChild(n)}this._title._text=this._titleText}}class ir extends $t{constructor(e,t,r,n){super(n),this._elems=e,this._attribute=r,this._channel=t,this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._labelAttribute=n.labelAttribute,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?Qt:er,this._titleText="title"in n?n.title:this._attribute,this._path="angle"===this._channel?new xt({strokeColor:this._strokeColor,id:this._id+"_path"}):new ae({strokeColor:this._strokeColor,id:this._id+"_path"}),this._pathVisible||(this._path.visibility="hidden"),this.addChild(this._path),this.createTicksLabels(n),this._elems[0].dataScope.dataTable.getAttributeType(this._attribute)!==Re.Date||"labelFormat"in n||(this._labelFormat="%m/%d/%y")}get elements(){if(this.layout.type===W.CLUSTER){const e=new Map(this._elems.map((e=>[e.dataScope.getAttributeValue(Ae),e])));return this.layout._d3Root.leaves().map((t=>e.get(t.data[Ae])))}return this._elems}get layout(){return this._elems[0].parent.layout}createTicksLabels(e){"tickValues"in e?(this._tickValues=e.tickValues,this._labelValues=e.tickValues):(this._tickValues=this.elements.map((e=>e.dataScope.getAttributeValue(this._labelAttribute?this._labelAttribute:this._attribute))),this._labelValues=this._tickValues),this._ticks.removeAll();for(let e=0;e<this._tickValues.length;e++){let t=new ae({strokeColor:this._strokeColor,id:this._id+"_tick"+e});this._tickVisible||(t.visibility="hidden"),this._ticks.addChild(t)}let t;switch(this._labels.removeAll(),this._elems[0].dataScope.dataTable.getAttributeType(this._labelAttribute?this._labelAttribute:this._attribute)){case Re.Date:t=n.timeFormat(this._labelFormat);break;case Re.String:t=function(e){return e};break;default:t=n.format(this._labelFormat)}for(let[e,r]of this._labelValues.entries()){let n=new At({text:t(r),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labels.addChild(n)}this._title._text=this._titleText}}class sr extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_ORIENTATION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e),g(e._path)}_runForLayout(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?_(e.elements):p(e.elements),n=[];if("x"===t){let t=e.orientation===Jt?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,n.push([r.left,e._pathPos]),n.push([r.right,e._pathPos]),e._path._setVertices(n)}else if("y"===t){let t=e.orientation===er?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,n.push([e._pathPos,r.top]),n.push([e._pathPos,r.bottom]),e._path._setVertices(n)}else if("angle"===t){let t=e.elements[0].parent.layout;t.type===W.CLUSTER&&(e._path._x=t.x,e._path._y=t.y,e._path._radius=t.radius)}}_runForEncoding(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?_(e.elements):p(e.elements),n=[];if("x"===t){let t=e.orientation===Jt?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,n.push([e.scale.range[0],e._pathPos]),n.push([e.scale.range[1],e._pathPos])}else if("width"===t){let t=e.orientation===Jt?r.top-2:r.bottom+2;e._pathPos=e._posArg?e._posArg:t,n.push([r.left,e._pathPos]),n.push([r.right,e._pathPos])}else if("radialDistance"===t){let t=e.elements[0].parent,r=t.y;e._pathPos=e._posArg?e._posArg:r,n.push([e.scale.range[0]+t.x,e._pathPos]),n.push([e.scale.range[1]+t.x,e._pathPos])}else if("y"===t){let t=e.orientation===er?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,n.push([e._pathPos,e.scale.range[0]]),n.push([e._pathPos,e.scale.range[1]])}else if("height"===t){let t=e.orientation===er?r.left-2:r.right+2;e._pathPos=e._posArg?e._posArg:t,n.push([e._pathPos,r.bottom]),n.push([e._pathPos,r.top])}e._path._setVertices(n)}}class ar extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e);for(let t of e._ticks.children)t._updateBounds();g(e._ticks)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==Qt?e.tickSize:-e.tickSize;for(let[n,i]of e._ticks.children.entries()){let s=e.elements[n].bounds[e.tickAnchor];i._setVertices([[s,t],[s,t+r]])}}else if("y"===t){let t=e.orientation==er?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==er?-e.tickSize:e.tickSize;for(let[n,i]of e._ticks.children.entries()){let s=e.elements[n].bounds[e.tickAnchor];i._setVertices([[t,s],[t+r,s]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===W.CLUSTER){let r=t._d3Root.leaves();const n=new Map(r.map((e=>[e.data[Ae],[e.x,e.y]])));for(let[r,i]of e._ticks.children.entries()){let s=e.elements[r].dataScope.getAttributeValue(Ae),a=fe(n.get(s)[0])-90;i._setVertices([[t.x+n.get(s)[1]+e.elements[r].bounds.width/2,t.y],[t.x+n.get(s)[1]+e.elements[r].bounds.width/2+e.tickSize,t.y]]),i._rotate=[a,t.x,t.y]}}}}_runForEncoding(e){let t=e.channel,r=p(e.elements);if("x"==t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==Qt?e.tickSize:-e.tickSize;for(let[n,i]of e._ticks.children.entries())i._setVertices([[e.scale.map(e._tickValues[n]),t],[e.scale.map(e._tickValues[n]),t+r]])}else if("width"==t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,n=e.orientation==Qt?e.tickSize:-e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Nt.Area&&"right"===e.elements[0].baseline))for(let[i,s]of e._ticks.children.entries())s._setVertices([[r.left+e.scale.rangeExtent-e.scale.map(e._tickValues[i]),t],[r.left+e.scale.rangeExtent-e.scale.map(e._tickValues[i]),t+n]]);else for(let[i,s]of e._ticks.children.entries())s._setVertices([[e.scale.map(e._tickValues[i])+r.left,t],[e.scale.map(e._tickValues[i])+r.left,t+n]])}else if("y"===t){let t=e.orientation==er?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==er?-e.tickSize:e.tickSize;for(let[n,i]of e._ticks.children.entries())i._setVertices([[t,e.scale.map(e._tickValues[n])],[t+r,e.scale.map(e._tickValues[n])]])}else if("height"===t){let t=e.orientation==er?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,n=e.orientation==er?-e.tickSize:e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Nt.Area&&"top"===e.elements[0].baseline))for(let[i,s]of e._ticks.children.entries())s._setVertices([[t,r.top+e.scale.map(e._tickValues[i])],[t+n,r.top+e.scale.map(e._tickValues[i])]]);else for(let[i,s]of e._ticks.children.entries()){let a=r.bottom-e.scale.map(e._tickValues[i]);s._setVertices([[t,a],[t+n,a]])}}else if("radialDistance"===t){let t=e.orientation==Qt?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==Qt?e.tickSize:-e.tickSize,n=e.elements[0].parent;for(let[i,s]of e._ticks.children.entries())s._setVertices([[n.x+e.scale.map(e._tickValues[i]),t],[n.x+e.scale.map(e._tickValues[i]),t+r]])}}}class or extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e);for(let t of e._labels.children)t._updateBounds();g(e._labels)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,r=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM];for(let[n,i]of e._labels.children.entries()){let s=e.elements[n].bounds;i._x=s[e.tickAnchor],i._y=e.pathPos+t,i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,y.MIDDLE])}}else if("y"===t){let t=e.orientation==er?-e.labelOffset:e.labelOffset,r=e.orientation==er?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE];for(let[n,i]of e._labels.children.entries()){let s=e.elements[n].bounds;i._x=e.pathPos+t,i._y=e.tickAnchor==y.MIDDLE?s.y:s[e.tickAnchor],i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,r[1]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===W.CLUSTER){let r=t._d3Root.leaves();const n=new Map(r.map((e=>[e.data[Ae],[e.x,e.y]])));let i=5;for(let[r,s]of e._labels.children.entries()){let a=e.elements[r].dataScope.getAttributeValue(Ae);if(n.get(a)[0]<Math.PI){let o=fe(n.get(a)[0])-90;s._anchor=[y.LEFT,y.MIDDLE],s._x=t.x+n.get(a)[1]+e.elements[r].bounds.width/2+i,s._y=t.y,s._rotate=[o,t.x,t.y]}else{let o=fe(n.get(a)[0])+90;s._anchor=[y.RIGHT,y.MIDDLE],s._x=t.x-n.get(a)[1]-e.elements[r].bounds.width/2-i,s._y=t.y,s._rotate=[o,t.x,t.y]}}}}}_runForEncoding(e){let t=e.channel,r=p(e.elements);if("x"==t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,r=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM];for(let[n,i]of e._labels.children.entries())i._x=e.scale.map(e.labelValues[n]),i._y=e.pathPos+t,i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,r[1]])}else if("width"===t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,n=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM],i=!!(e.isFlipped()||e.elements[0].type===Nt.Area&&"right"===e.elements[0].baseline);for(let[s,a]of e._labels.children.entries())a._x=i?r.left+e.scale.rangeExtent-e.scale.map(e.labelValues[s]):e.scale.map(e.labelValues[s])+r.left,a._y=e.pathPos+t,a._anchor=n,e._labelRotation&&(a._rotate=[e._labelRotation,a.x,a.y],a._anchor=[y.RIGHT,n[1]])}else if("y"===t){let t=e.orientation==er?-e.labelOffset:e.labelOffset,r=e.orientation==er?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE];for(let[n,i]of e._labels.children.entries())i._x=e.pathPos+t,i._y=e.scale.map(e.labelValues[n]),i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[y.RIGHT,r[1]])}else if("height"===t){let t=e.orientation==er?-e.labelOffset:e.labelOffset,n=e.orientation==er?[y.RIGHT,y.MIDDLE]:[y.LEFT,y.MIDDLE],i=e.elements[0].type===Nt.Area&&"top"===e.elements[0].baseline;for(let[s,a]of e._labels.children.entries())a._x=e.pathPos+t,a._y=i?r.top+e.scale.map(e.labelValues[s]):r.bottom-e.scale.map(e.labelValues[s]),a._anchor=n,e._labelRotation&&(a._rotate=[e._labelRotation,a.x,a.y],a._anchor=[y.RIGHT,n[1]])}else if("radialDistance"==t){let t=e.orientation==Qt?e.labelOffset:-e.labelOffset,r=e.orientation==Qt?[y.CENTER,y.TOP]:[y.CENTER,y.BOTTOM],n=e.elements[0].parent;for(let[i,s]of e._labels.children.entries())s._x=n.x+e.scale.map(e.labelValues[i]),s._y=e.pathPos+t,s._anchor=r,e._labelRotation&&(s._rotate=[e._labelRotation,s.x,s.y],s._anchor=[y.RIGHT,r[1]])}}}class lr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)return;this.fillGrid(e,t),this.computeCellBounds(e,t),this.placeElements(e,t)}let r=F(e,!0);for(let e of r)g(e)}placeElements(e,t){let r=Ge(e,"x"),n=Ge(e,"y");for(let r=0;r<e.children.length;r++){let n=e.children[r],i=t.cellBounds[r],s=0,a=0;switch(t._cellHorzAlignment){case y.LEFT:s=i.left-n.refBounds.left;break;case y.CENTER:s=i.x-n.refBounds.x;break;case y.RIGHT:s=i.right-n.refBounds.right}switch(t._cellVertAlignment){case y.TOP:a=i.top-n.refBounds.top;break;case y.MIDDLE:a=i.y-n.refBounds.y;break;case y.BOTTOM:a=i.bottom-n.refBounds.bottom}Ue(n,s,a)}if(r.length>0)for(let e of r)for(let r of e.scales){let n=e.getElements(r)[0],i=t.getIndex(n);if(i<0)continue;let s="point"===r.type?t.cellBounds[i].left+n.bounds.width/2:t.cellBounds[i].left,a=s+r.rangeExtent;r.range=r.range[0]<r.range[1]?[s,a]:[a,s]}if(n.length>0)for(let e of n)for(let r of e.scales){let n=e.getElements(r)[0],i=t.getIndex(n);if(i<0)continue;let s="point"===r.type?t.cellBounds[i].top+e.getElements(r)[0].bounds.height/2:t.cellBounds[i].top,a=s+r.rangeExtent;r.range=r.range[0]<r.range[1]?[s,a]:[a,s]}}fillGrid(e,t){t._grid=new Array(t.numRows).fill(null).map((()=>new Array(t.numCols).fill(null)));for(let r=0;r<e.children.length;r++){let e=t.getRowCol(r);t._grid[e.row][e.col]=r}}computeCellBounds(e,t){let r=e.children.map((e=>e.refBounds?e.refBounds:e.bounds)),n=t._colGap,i=t._rowGap;if(void 0===t._left){let e=r.map((e=>e.left)),n=r.map((e=>e.top));t._left=Math.min(...e),t._top=Math.min(...n)}let s=r.map((e=>e.width)),a=r.map((e=>e.height)),o=Math.max(...s),l=Math.max(...a);t._cellBounds=new Array(e.children.length).fill(null);for(let r=0;r<t.numRows;r++)for(let s=0;s<t.numCols;s++){let a=t._grid[r][s];a>=e.children.length||(t._cellBounds[a]=new d(t._left+(o+n)*s+0,t._top+(l+i)*r,o,l))}}}class ur extends X{constructor(e){super(e)}run(){let e=this.outputVar.element;e.scale?this._runForEncoding(e):this._runForLayout(e),g(e)}_runForLayout(e){let t=e.channel,r=p(e.elements),n=[];if("x"===t)for(let t=0;t<e.values.length;t++){let i=e.elements[t].refBounds;n.push({x1:i.x,y1:r.bottom,x2:i.x,y2:r.top})}else if("y"===t)for(let t=0;t<e.values.length;t++){let i=e.elements[t].refBounds;n.push({x1:r.left,y1:i.y,x2:r.right,y2:i.y})}e.lines=n}_runForEncoding(e){let t=e.channel,r=p(e.elements),n=[];if("x"===t)for(let t of e.values)n.push({x1:e.scale.map(t),y1:r.bottom,x2:e.scale.map(t),y2:r.top});else if("width"===t)for(let t of e.values)n.push({x1:e.scale.map(t)+r.left,y1:r.bottom,x2:e.scale.map(t)+r.left,y2:r.top});else if("y"===t)for(let t of e.values)n.push({x1:r.left,y1:e.scale.map(t),x2:r.right,y2:e.scale.map(t)});else if("height"===t)for(let t of e.values)n.push({x1:r.left,y1:r.bottom-e.scale.map(t),x2:r.right,y2:r.bottom-e.scale.map(t)});else if("radialDistance"===t){let t=e.elements[0].parent;for(let r=0;r<e.values.length;r++)n.push({x:t.x,y:t.y,r:e.scale.map(e.values[r])})}e.lines=n}}class cr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=F(e)[0],r=I(e.parent);for(let e of r){let r=e.layout;if(!r)return;switch(t.type){case Nt.Rect:case Nt.Circle:case Nt.Image:this._stackRects(e,r);break;case Nt.Area:e.children[0].orientation===ee.HORIZONTAL?this._stackAreasVert(e,r):this._stackAreasHorz(e,r);break;case Nt.Arc:case Nt.Pie:t.parent.classId===e.classId&&this._stackArcs(e,r)}}g(t)}_stackArcs(e,t){if(t.orientation===ee.ANGULAR){let t=90;if((this._direction?this._direction:re.Clockwise)===re.Clockwise)for(let r of e.children){let e=pe(t-r.angle);We(r,"startAngle",e),t=e}else for(let r of e.children){let e=pe(t+r.angle);We(r,"startAngle",e),t=e}}else if(t.orientation===ee.RADIAL){let t=Math.min(...e.children.map((e=>e.innerRadius)));for(let r of e.children){let e=r.outerRadius-r.innerRadius;We(r,"innerRadius",t),We(r,"outerRadius",t+e),t=r._outerRadius}}}_stackAreasVert(e,t){let r=e.children,n=e.bounds,i=t.vertCellAlignment===y.TOP?n.top:n.bottom,s=t.vertCellAlignment===y.TOP?1:-1,a=r[0].vertices.length/2,o=new Array(a).fill(0);for(let e of r){for(let t=0;t<a;t++){let r=e.vertices[t],n=e.vertices[2*a-t-1],l=Math.abs(r.y-n.y),u=i+o[t]*s,c=i+(o[t]+l)*s;Ue(r,0,u-r.y),Ue(n,0,c-n.y),o[t]+=l}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}if(t.vertCellAlignment===y.MIDDLE)for(let e of r){for(let t=0;t<a;t++){let r=e.vertices[t],i=e.vertices[2*a-t-1],s=n.middle+o[t]/2;Ue(r,0,s-n.bottom),Ue(i,0,s-n.bottom)}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}}_stackAreasHorz(e,t){}_stackRects(e,t){e.scene;let r=t._orientation,n=e.children.map((e=>e.bounds)),i=n.map((e=>e.left)),s=n.map((e=>e.top)),a=n.map((e=>e.width)),o=n.map((e=>e.height)),l=null==t._left?Math.min(...i):t._left,u=null==t._top?Math.min(...s):t._top,c=Math.max(...a),h=Math.max(...o);if(r==ee.VERTICAL)for(let r=0;r<e.children.length;r++){let n=e.children[r],i=0,s=u+n.bounds.height/2-n.bounds.y;u+=n.bounds.height+t._gap,Ue(n,i,s),n._updateBounds();let a=0,o=0;if(!ze(n))switch(t._horzCellAlignment){case y.LEFT:a=l-n.bounds.left;break;case y.CENTER:a=l+c/2-n.bounds.x;break;case y.RIGHT:a=l+c-n.bounds.right}Ue(n,a,o)}else for(let r=0;r<e.children.length;r++){let n=e.children[r],i=l+n.bounds.width/2-n.bounds.x,s=0;l+=n.bounds.width+t._gap,Ue(n,i,s),n._updateBounds();let a=0,o=0;if(!je(n))switch(t._vertCellAlignment){case y.TOP:o=u-n.bounds.top;break;case y.MIDDLE:o=u+h/2-n.bounds.y;break;case y.BOTTOM:o=u+h-n.bounds.bottom}Ue(n,a,o)}}}class hr extends X{constructor(e){super(e)}run(){super.run()}}class dr extends X{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,r=e.attribute,i=t.attribute,s=e.dataset,a=t.dataset,o=s.getAttributeValues(r),l=n.bin()(o),u=this._findBin,c=o.map((e=>{let t=u(e,l);return(t.x0+t.x1)/2+""})),h=l.map((e=>(e.x0+e.x1)/2+""));a._addAttribute(i,Re.String,c),a.orderAttributeValues(i,h)}_findBin(e,t){for(let r of t)if(r.indexOf(e)>=0)return r}}class fr extends X{constructor(e){super(e)}run(){let e=this.outputVar,t=e.dataset,r=e.predicate,n=[];for(let[e,i]of t.data.entries())r.testTuple(i)||n.push(e);n.sort(((e,t)=>t-e)),n.forEach((e=>{e>=0&&e<t.data.length&&(t._data.splice(e,1),t._rawData.splice(e,1))}));for(let e of t._attributes)t._attrSummaries[e]=Te(t.data.map((t=>t[e])),t._attrTypes[e])}}class pr extends K{constructor(e,t,r){super(e),this._dataset=r,this._predicate=t}get dataset(){return this._dataset}get predicate(){return this._predicate}}class _r extends K{constructor(e,t){super(e),this._group=t}get element(){return this._group}}class gr extends X{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e.type===Z.AFFIXATION)).affixation,t=e.base,r=e.element,n=I(t),i=I(r),s=e.channels,a=e.attribute;if(A(r)&&A(t)){let e=n.map((e=>e.dataScope.getAttributeValue(a)));i=i.filter((t=>e.includes(t.dataScope.getAttributeValue(a))));let t=(e,t)=>e.dataScope.getAttributeValue(a)<t.dataScope.getAttributeValue(a)?-1:e.dataScope.getAttributeValue(a)>t.dataScope.getAttributeValue(a)?1:0;i.sort(t),n.sort(t)}if(s.includes("x")||s.includes("y"))for(let t of s)this._handleXY(t,i,n,e.getElementAnchor(t),e.getBaseAnchor(t),e.getOffset(t));(s.includes("radialDistance")||s.includes("angle"))&&this._handlePolar(i,n,e);let o=F(r,!0);for(let e of o)g(e)}_handlePolar(e,t,r){let n=r.hasChannel("radialDistance")?r.getBaseAnchor("radialDistance"):y.MIDDLE,i=r.hasChannel("radialDistance")?r.getElementAnchor("radialDistance"):y.MIDDLE,s=r.hasChannel("angle")?r.getBaseAnchor("angle"):y.CENTER;r.hasChannel("angle")?r.getElementAnchor("angle"):y.CENTER;let a=r.hasChannel("radialDistance")?r.getOffset("radialDistance"):0,o=r.hasChannel("angle")?r.getOffset("angle"):0;if([Nt.Arc,Nt.Ring].indexOf(t[0].type)>=0&&e[0].type==Nt.PointText)for(let r=0;r<e.length;r++){let i=t[r],o=e[r],l=n===y.MIDDLE?(i.outerRadius+i.innerRadius)/2:n===y.TOP?i.outerRadius-5:i.innerRadius+5;if(l+=a,i.type===Nt.Arc){let e=Ie(i.x,i.y,l,i.startAngle),t=Ie(i.x,i.y,l,i.endAngle);i.endAngle>=180&&i.endAngle<=360?o._textPath=["M",e[0],e[1],"A",l,l,i.angle,i.angle>=180?1:0,0,t[0],t[1]].join(" "):o._textPath=["M",t[0],t[1],"A",l,l,i.angle,i.angle>=180?1:0,1,e[0],e[1]].join(" ")}else if(i.type===Nt.Ring){let e=275,t=265,r=350,n=Ie(i.x,i.y,l,e),s=Ie(i.x,i.y,l,t);o._textPath=["M",s[0],s[1],"A",l,l,r,1,1,n[0],n[1]].join(" ")}o._textPathOffset=s===y.LEFT?"0%":"50%"}else for(let r=0;r<e.length;r++){let l,u,c=t[r],h=e[r];c.type==Nt.Arc||c.type==Nt.Ring?(u="left"==s?c.endAngle+o:"center"==s?c.startAngle+c.angle/2+o:c.startAngle+o,l="top"==n?c.outerRadius+a:"bottom"==n?c.innerRadius+a:(c.outerRadius+c.innerRadius)/2+a):c.type==Nt.Circle&&(u=90,l="top"==n?c.radius+a:"bottom"==n?a:c.radius/2+a),Ue(h,c.x-h.x,c.y-l-h.bounds[i]),h._rotate=[90-u,c.x,c.y]}}_handleXY(e,t,r,n,i,s){for(let a=0;a<t.length;a++){let o,l=r[a],u=t[a];if(le(l)){o=oe(l,[y.LEFT,y.TOP].includes(i)?0:[y.CENTER,y.MIDDLE].includes(i)?.5:1)[e]}else o=l.bounds[i]+s;t[0].type===Nt.PointText?(u.anchor["x"==e?0:1]=n,We(u,e,o)):"x"==e?Ue(u,o-u.bounds[n],0):Ue(u,0,o-u.bounds[n])}}}class yr extends K{constructor(e,t){super(e),this._affx=t}get affixation(){return this._affx}}class mr extends X{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,r=e.attribute,n=t.attribute,i=e.dataset,s=t.dataset,a=this.args,o="min"in a?a.min:i.getAttributeSummary(r).min,l="max"in a?a.max:i.getAttributeSummary(r).max,u=o,c=[];for(;u<l;)c.push(u),u+=a.interval;c.push(u);let h={},d={};if(a.groupBy)for(let e of i.data){let t=a.groupBy.map((t=>e[t])).join("-");t in h||(h[t]=[],d[t]=a.groupBy.map((t=>e[t]))),h[t].push(e[r])}else h[""]=i.data.map((e=>e[r])),d[""]="";let f=[];for(let e in d){let t=br(vr(a.bandwidth),c,h[e]);for(let i of t){let t={};""!==e&&a.groupBy.forEach(((r,n)=>t[r]=d[e][n])),t[r]=i[0],t[n]=i[1],f.push(t)}}let p={};if(p[r]=i.getAttributeType(r),p[n]=Re.Number,a.groupBy)for(let e of a.groupBy)p[e]=i.getAttributeType(e);s.initialize(f,s.url,p)}}function br(e,t,r){return t.map((t=>[t,n.mean(r,(r=>e(t-r)))]))}function vr(e){return t=>Math.abs(t/=e)<=1?.75*(1-t*t)/e:0}class xr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)return;let r=e.children.map((e=>({name:e.id,radius:e.radius,itm:e}))),i=r.reduce(((e,t)=>e+Math.pow(t.radius,2)),0),s=Math.sqrt(i);void 0===t._width&&(t._width=s),void 0===t._height&&(t._height=s);let a=n.hierarchy({name:"root",children:r}).sum((e=>e.radius?e.radius:0)).sort(((e,t)=>t.value-e.value));n.pack().size([t._width,t._height]).radius((e=>e.value))(a);for(let e of a.children){let r=e.data.itm;Ue(r,t._x-a.x+e.x-r.x,t._y-a.y+e.y-r.y)}}let r=F(e,!0);for(let e of r)g(e)}}class Er extends X{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof tt&&e.property==rt.AXIS_PATH_POSITION)).element;e instanceof nr?this._runForEncoding(e):e instanceof ir&&this._runForLayout(e),g(e._title)}_runForEncoding(e){let t=e.channel,r=p(e.elements);if("x"==t)e._title._x=(e.scale.range[0]+e.scale.range[1])/2,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("width"==t)e._title._x=r.left+e.scale.rangeExtent/2,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._rotateYTitle?(e._title._x=e.orientation==er?e.pathPos-e.titleOffset:e.pathPos+e.titleOffset,e._title._y=(e.scale.range[0]+e.scale.range[1])/2,e._title._rotate=e.orientation==er?[-90,e._title._x,e._title._y]:[90,e._title._x,e._title._y]):(e._title._x=e.orientation==er?e.pathPos-e.titleOffset:e.pathPos+e.titleOffset,e._title._y=Math.min(e.scale.range[0],e.scale.range[1])-25,e._title._rotate=void 0);else if("height"===t)e._title._x=r.center,e._title._y=(r.top+r.bottom)/2-r.width/2-e.titleOffset,e._title._rotate=e.orientation==er?[-90,r.center,r.middle]:[90,r.center,r.middle];else if("radialDistance"===t){let t=e.elements[0].parent;e._title._x=t.x+e.scale.rangeExtent/2,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset,e._rotate&&(e._title._rotate=e._rotate.slice())}}_runForLayout(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==W.STACK?_(e.elements):p(e.elements);if("x"==t)e._title._x=r.center,e._title._y=e.orientation==Qt?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._title._x=r.center,e._title._y=r.middle-r.width/2-e.titleOffset,e._title._rotate=e.orientation==er?[-90,r.center,r.middle]:[90,r.center,r.middle];else if("angle"===t){let t=e.elements[0].parent.layout;t.type===W.CLUSTER&&(e._title._x=t.x,e._title._y=t.y)}}}class wr extends zt{constructor(e){super(e)}run(){super.run();let e,t=this.vars.find((e=>e.type===Z.ALIGNMENT)).alignment,r=t.anchor,i=t.elements;r==y.Top||r==y.LEFT?e=Math.min(...i.map((e=>e.bounds[r]))):r==y.BOTTOM||r==y.RIGHT?e=Math.max(...i.map((e=>e.bounds[r]))):r!=y.CENTER&&r!=y.MIDDLE||(e=n.mean(i.map((e=>e.bounds[r]))));for(let n of i){let i=Fe(n,t.channel);if(i){let s=e-n.bounds[r];Ue(i,"x"===t.channel?s:0,"x"===t.channel?0:s)}}for(let e of i)g(e)}}class Ar extends K{constructor(e,t){super(e),this._aln=t}get alignment(){return this._aln}}class Cr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=Ee(e.children[0]);if(!r)continue;let i=r.linkList.map((e=>({source:r.getNode(e.source),target:r.getNode(e.target)}))),s=n.forceSimulation(r.nodeList).force("charge",n.forceManyBody().strength(-t._repulsion)).force("link",n.forceLink(i).id((e=>e.id)).distance(t._linkDistance)).force("x",n.forceX()).force("y",n.forceY()).force("center",n.forceCenter(t._x,t._y).strength(t._attraction));s.stop(),s.tick(t._iterations);for(let t=0;t<e.children.length;t++){let n=e.children[t],i=r.nodeList[t];Ue(n,i.x-n.x,i.y-n.y)}}let r=F(e,!0);for(let e of r)g(e)}}class Rr extends X{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=I(e);switch(e.type){case Nt.Arc:this._updateArcLinks(t);break;case Nt.BezierCurve:this._updateBezierLinks(t);break;case Nt.BundledPath:this._updateBundledLinks(t);break;case Nt.Chord:this._updateChordLinks(t);break;case Nt.Line:default:this._updateLineLinks(t)}g(e)}_updateArcLinks(e){for(let t of e){let e=t.source.x<t.target.x?t.source:t.target,r=t.source.x<t.target.x?t.target:t.source;t._x=(e.x+r.x)/2,t._y=(e.y+r.y)/2,t._innerRadius=Math.sqrt(Math.pow(e.x-r.x,2)+Math.pow(e.y-r.y,2))/2,t._outerRadius=t._innerRadius+t._thickness;let n=_e(e.x,e.y,t._x,t._y),i=_e(r.x,r.y,t._x,t._y);t.direction===re.CLOCKWISE&&([n,i]=[i,n]),We(t,"startAngle",n),We(t,"angle",Math.abs(i-n))}}_updateBezierLinks(e){let t=this._inputVars[0].element,r=I(t),n=t.parent.layout;n.type===W.DIRECTED||n.type===W.TIDYTREE?this._updateBezierLinksForDirectedGraph(r,e,n):n.type===W.CLUSTER&&this._updateBezierLinksForClusteredGraph(r,e,n)}_updateBezierLinksForClusteredGraph(e,t,r){const i=r._d3Root.descendants(),s=new Map(i.map((e=>[kr(e),e]))),a=new Map(i.map((e=>[e.data[Ae],kr(e)])));if(r.isRadial()){const e=n.linkRadial().angle((e=>e.x)).radius((e=>e.y));for(let n of t){let t=n.source,i=n.target,o=t.dataScope.getAttributeValue(Ae),l=i.dataScope.getAttributeValue(Ae),u=s.get(a.get(o)),c=s.get(a.get(l));n._d=ce(e({source:u,target:c}),r.x,r.y)}}else if(r.orientation===ee.VERTICAL){const e=n.linkVertical().x((e=>e.x)).y((e=>e.y));for(let n of t){let t=n.source,i=n.target,o=t.dataScope.getAttributeValue(Ae),l=i.dataScope.getAttributeValue(Ae),u=s.get(a.get(o)),c=s.get(a.get(l));n._d=ce(e({source:u,target:c}),r.left-r._x0,r.top)}}else if(r.orientation===ee.HORIZONTAL){const e=n.linkHorizontal().x((e=>e.y)).y((e=>e.x));for(let n of t){let t=n.source,i=n.target,o=t.dataScope.getAttributeValue(Ae),l=i.dataScope.getAttributeValue(Ae),u=s.get(a.get(o)),c=s.get(a.get(l));n._d=ce(e({source:u,target:c}),r.left,r.top-r._x0)}}}_updateBezierLinksForDirectedGraph(e,t,r){let n={},i={},s={},a={};for(let t of e){i[t.id]=0,n[t.id]=0;let e=t.links.filter((e=>e.source===t)),r=t.links.filter((e=>e.target===t));a[t.id]=r.map((e=>e.strokeWidth)).reduce(((e,t)=>e+t),0),s[t.id]=e.map((e=>e.strokeWidth)).reduce(((e,t)=>e+t),0)}r.spreadLinks&&("LR"===r.direction||"RL"===r.direction?t.sort(((e,t)=>_e(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y)-_e(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y))):t.sort(((e,t)=>_e(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y)-_e(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y))));for(let e of t){let t,o,l,u,c=e.source,h=e.target;r.spreadLinks?"LR"===r.direction||"RL"===r.direction?(t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0],l=h.bounds[e.targetAnchor[0]]+e.targetOffset[0],o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1]-s[c.id]/2+n[c.id]+e.strokeWidth/2,u=h.bounds[e.targetAnchor[1]]+e.targetOffset[1]-a[h.id]/2+i[h.id]+e.strokeWidth/2,n[c.id]+=e.strokeWidth,i[h.id]+=e.strokeWidth):(o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1],u=h.bounds[e.targetAnchor[1]]+e.targetOffset[1],t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0]-s[c.id]/2+n[c.id]+e.strokeWidth/2,l=h.bounds[e.targetAnchor[0]]+e.targetOffset[0]-a[h.id]/2+i[h.id]+e.strokeWidth/2,n[c.id]+=e.strokeWidth,i[h.id]+=e.strokeWidth):(t=c.bounds[e.sourceAnchor[0]]+e.sourceOffset[0],o=c.bounds[e.sourceAnchor[1]]+e.sourceOffset[1],l=h.bounds[e.targetAnchor[0]]+e.targetOffset[0],u=h.bounds[e.targetAnchor[1]]+e.targetOffset[1]),e.orientation===ee.HORIZONTAL?e._setVertices([[t,o],[(t+l)/2,o],[t,u],[l,u]]):e.orientation===ee.VERTICAL&&e._setVertices([[t,o],[t,(o+u)/2],[l,o],[l,u]])}}_updateBundledLinks(e){let t=this._inputVars[0].element.parent.layout;if(t.type!==W.CLUSTER)throw"Bundled links must work on a cluster layout";let r=t._d3Root.leaves();const i=new Map(r.map((e=>[kr(e),e]))),s=new Map(r.map((e=>[e.data[Ae],kr(e)]))),a=n.lineRadial().curve(n.curveBundle.beta(e[0]._strength)).radius((e=>e.y)).angle((e=>e.x));for(let r of e){let e=r.source.dataScope.getAttributeValue(Ae),n=r.target.dataScope.getAttributeValue(Ae),o=i.get(s.get(e)),l=i.get(s.get(n));(o.outgoing??=[]).push([o,l]),l.incoming??=[];let u=o.path(l);r._d=ce(a(u),t.x,t.y)}}_updateChordLinks(e){for(let t of e){let e=t.source,r=t.target,n=Ie(e.x,e.y,e.innerRadius,e.startAngle),i=Ie(e.x,e.y,e.innerRadius,e.endAngle),s=Ie(r.x,r.y,r.innerRadius,r.startAngle),a=Ie(r.x,r.y,r.innerRadius,r.endAngle);t._d=["M",n[0],n[1],"Q",e.x,e.y,a[0],a[1],"A",e.x,e.y,r.angle,r.angle>180?1:0,1,s[0],s[1],"Q",e.x,e.y,i[0],i[1],"A",e.x,e.y,e.angle,e.angle>180?1:0,1,n[0],n[1]].join(" ")}}_updateLineLinks(e){for(let t of e){let e=t.source,r=t.target;t.vertices[0]._x=e.bounds.x,t.vertices[0]._y=e.bounds.y,t.vertices[1]._x=r.bounds.x,t.vertices[1]._y=r.bounds.y}}}function kr(e){return`${e.parent?kr(e.parent)+".":""}${e.data[Ae]}`}var Sr,Tr,Or,Ir,Nr,Lr,Vr,Pr,Dr,Br,Mr,Gr,jr,zr,Fr,Ur,Hr,Wr,Yr,Xr,qr,Kr,Zr,$r,Jr,Qr,en,tn,rn,nn,sn,an,on,ln,un,cn,hn,dn,fn,pn,_n,gn,yn,mn,bn,vn,xn,En,wn,An,Cn,Rn,kn,Sn,Tn,On,In,Nn,Ln,Vn,Pn,Dn,Bn,Mn,Gn,jn,zn,Fn,Un,Hn,Wn,Yn,Xn,qn,Kn,Zn,$n,Jn,Qn,ei,ti,ri,ni,ii,si,ai,oi,li,ui,ci,hi,di,fi,pi,_i,gi,yi,mi,bi,vi,xi,Ei,wi,Ai,Ci,Ri,ki,Si,Ti="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Oi(){if(Ir)return Or;return Ir=1,Or=function(e,t){return e===t||e!=e&&t!=t}}function Ii(){if(Lr)return Nr;Lr=1;var e=Oi();return Nr=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function Ni(){if(Ur)return Fr;Ur=1;var e=Tr?Sr:(Tr=1,Sr=function(){this.__data__=[],this.size=0}),t=function(){if(Pr)return Vr;Pr=1;var e=Ii(),t=Array.prototype.splice;return Vr=function(r){var n=this.__data__,i=e(n,r);return!(i<0||(i==n.length-1?n.pop():t.call(n,i,1),--this.size,0))}}(),r=function(){if(Br)return Dr;Br=1;var e=Ii();return Dr=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function(){if(Gr)return Mr;Gr=1;var e=Ii();return Mr=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(zr)return jr;zr=1;var e=Ii();return jr=function(t,r){var n=this.__data__,i=e(n,t);return i<0?(++this.size,n.push([t,r])):n[i][1]=r,this}}();function s(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return s.prototype.clear=e,s.prototype.delete=t,s.prototype.get=r,s.prototype.has=n,s.prototype.set=i,Fr=s}function Li(){if(Qr)return Jr;Qr=1;var e="object"==typeof Ti&&Ti&&Ti.Object===Object&&Ti;return Jr=e}function Vi(){if(tn)return en;tn=1;var e=Li(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return en=r}function Pi(){if(nn)return rn;nn=1;var e=Vi().Symbol;return rn=e}function Di(){if(cn)return un;cn=1;var e=Pi(),t=function(){if(an)return sn;an=1;var e=Pi(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return sn=
|
|
3
3
|
/**
|
|
4
4
|
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mascot-vis",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Manipulable Semantic Components in Data Visualization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"exports": {
|
|
33
33
|
"import": "./dist/mascot-esm.js",
|
|
34
|
-
"
|
|
34
|
+
"browser": "./dist/mascot-umd.js",
|
|
35
|
+
"default": "./dist/mascot-umd.js"
|
|
35
36
|
},
|
|
36
37
|
"bugs": {
|
|
37
38
|
"url": "https://github.com/hdi-umd/Mascot/issues"
|