mascot-vis 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/README.md +4 -3
  2. package/dist/mascot-es.js +27745 -0
  3. package/dist/mascot-min.js +186 -199
  4. package/dist/mascot-umd.js +27781 -0
  5. package/js/depGraphVis.js +66 -0
  6. package/package.json +23 -15
  7. package/src-new-ts/action/createElement.ts +91 -0
  8. package/src-new-ts/action/encode.js +20 -0
  9. package/src-new-ts/action/repeat.js +128 -0
  10. package/src-new-ts/action/traverseScene.js +41 -0
  11. package/src-new-ts/data/Network.js +2 -0
  12. package/src-new-ts/data/Scope.js +135 -0
  13. package/src-new-ts/data/Table.js +263 -0
  14. package/src-new-ts/data/Tree.js +3 -0
  15. package/src-new-ts/data/field.ts +115 -0
  16. package/src-new-ts/data/import.ts +96 -0
  17. package/src-new-ts/data/predicate.ts +82 -0
  18. package/src-new-ts/depgraph/DepGraph.js +178 -0
  19. package/src-new-ts/depgraph/Edge.js +9 -0
  20. package/src-new-ts/depgraph/SceneGraph2DepGraph.js +110 -0
  21. package/src-new-ts/depgraph/Signal.js +12 -0
  22. package/src-new-ts/depgraph/operator/BoundsEvaluator.js +30 -0
  23. package/src-new-ts/depgraph/operator/Dataflow.js +41 -0
  24. package/src-new-ts/depgraph/operator/DomainBuilder.js +50 -0
  25. package/src-new-ts/depgraph/updateDepGraph.js +45 -0
  26. package/src-new-ts/depgraph/variable/BoundsVar.js +81 -0
  27. package/src-new-ts/depgraph/variable/ChannelVar.js +17 -0
  28. package/src-new-ts/depgraph/variable/DataScopeVar.js +12 -0
  29. package/src-new-ts/depgraph/variable/DomainVar.js +15 -0
  30. package/src-new-ts/depgraph/variable/FieldVar.js +17 -0
  31. package/src-new-ts/depgraph/variable/LayoutParameter.js +8 -0
  32. package/src-new-ts/depgraph/variable/ScaleVar.js +13 -0
  33. package/src-new-ts/depgraph/variable/Variable.js +39 -0
  34. package/src-new-ts/element/gradient/LinearGradient.js +37 -0
  35. package/src-new-ts/element/group/Collection.js +109 -0
  36. package/src-new-ts/element/group/Group.js +307 -0
  37. package/src-new-ts/element/group/Scene.js +98 -0
  38. package/src-new-ts/element/mark/CircleMark.ts +85 -0
  39. package/src-new-ts/element/mark/Mark.ts +233 -0
  40. package/src-new-ts/element/mark/PathMark.js +483 -0
  41. package/src-new-ts/element/mark/Segment.js +29 -0
  42. package/src-new-ts/element/mark/Vertex.js +118 -0
  43. package/src-new-ts/encode/Scale.ts +115 -0
  44. package/src-new-ts/index.ts +19 -0
  45. package/src-new-ts/layout/Layout.ts +3 -0
  46. package/src-new-ts/render/CanvasRenderer.ts +24 -0
  47. package/src-new-ts/render/SVGRenderer.js +316 -0
  48. package/src-new-ts/util.ts +3 -0
  49. package/src-old/action/Classify.js +53 -0
  50. package/src-old/action/Densify.js +199 -0
  51. package/src-old/action/Partition.js +531 -0
  52. package/src-old/action/Repeat.js +106 -0
  53. package/src-old/action/Repopulate.js +44 -0
  54. package/src-old/action/Stratify.js +156 -0
  55. package/src-old/basic/Gradient.js +37 -0
  56. package/src-old/basic/Point.js +51 -0
  57. package/src-old/basic/Rectangle.js +63 -0
  58. package/src-old/bind/bindToAngle.js +56 -0
  59. package/src-old/bind/bindToAreaMark.js +360 -0
  60. package/src-old/bind/bindToColor.js +114 -0
  61. package/src-old/bind/bindToLink.js +81 -0
  62. package/src-old/bind/bindToPosition.js +283 -0
  63. package/src-old/bind/bindToRadialDistance.js +62 -0
  64. package/src-old/bind/bindToSize.js +235 -0
  65. package/src-old/bind/bindToText.js +60 -0
  66. package/src-old/bind/bindToThickness.js +100 -0
  67. package/src-old/constraint/AffixConstraint.js +129 -0
  68. package/src-old/constraint/AlignConstraint.js +58 -0
  69. package/src-old/core/Encoding.js +336 -0
  70. package/src-old/core/Scale.js +322 -0
  71. package/src-old/core/SceneLoader.js +290 -0
  72. package/src-old/core/SceneValidator.js +232 -0
  73. package/src-old/core/SpecExecutor.js +113 -0
  74. package/src-old/core/SpecGenerator.js +350 -0
  75. package/src-old/data/DataImporter.js +64 -0
  76. package/src-old/data/DataScope.js +124 -0
  77. package/src-old/data/DataTable.js +338 -0
  78. package/src-old/data/Network.js +106 -0
  79. package/src-old/data/Tree.js +251 -0
  80. package/src-old/data/transform/Bin.js +46 -0
  81. package/src-old/data/transform/Filter.js +48 -0
  82. package/src-old/data/transform/Groupby.js +18 -0
  83. package/src-old/data/transform/KDE.js +58 -0
  84. package/src-old/data/transform/Sort.js +14 -0
  85. package/src-old/data/transform/Split.js +5 -0
  86. package/src-old/data/transform/partition.js +46 -0
  87. package/src-old/history/UndoRedoStack +0 -0
  88. package/src-old/index.js +271 -0
  89. package/src-old/indexSVG.js +259 -0
  90. package/src-old/interaction/Interaction.js +91 -0
  91. package/src-old/interaction/MouseEvent.js +8 -0
  92. package/src-old/interaction/Selection.js +9 -0
  93. package/src-old/interaction/brush.js +362 -0
  94. package/src-old/item/Segment.js +29 -0
  95. package/src-old/item/Vertex.js +118 -0
  96. package/src-old/item/composite/Collection.js +106 -0
  97. package/src-old/item/composite/Glyph.js +19 -0
  98. package/src-old/item/composite/Group.js +310 -0
  99. package/src-old/item/composite/Scene.js +1251 -0
  100. package/src-old/item/mark/ArcPath.js +181 -0
  101. package/src-old/item/mark/AreaPath.js +78 -0
  102. package/src-old/item/mark/CirclePath.js +102 -0
  103. package/src-old/item/mark/EllipsePath.js +5 -0
  104. package/src-old/item/mark/Image.js +101 -0
  105. package/src-old/item/mark/LinkPath.js +118 -0
  106. package/src-old/item/mark/Mark.js +163 -0
  107. package/src-old/item/mark/Path.js +494 -0
  108. package/src-old/item/mark/PointText.js +201 -0
  109. package/src-old/item/mark/PolygonPath.js +64 -0
  110. package/src-old/item/mark/RectPath.js +88 -0
  111. package/src-old/item/mark/RingPath.js +92 -0
  112. package/src-old/item/refs/Axis.js +362 -0
  113. package/src-old/item/refs/EncodingAxis.js +515 -0
  114. package/src-old/item/refs/Gridlines.js +144 -0
  115. package/src-old/item/refs/LayoutAxis.js +316 -0
  116. package/src-old/item/refs/Legend.js +273 -0
  117. package/src-old/layout/Circular.js +95 -0
  118. package/src-old/layout/Force.js +52 -0
  119. package/src-old/layout/Grid.js +423 -0
  120. package/src-old/layout/Layout.js +13 -0
  121. package/src-old/layout/Packing.js +56 -0
  122. package/src-old/layout/Stack.js +264 -0
  123. package/src-old/layout/Strata.js +88 -0
  124. package/src-old/layout/Sugiyama.js +59 -0
  125. package/src-old/layout/TidyTree.js +105 -0
  126. package/src-old/layout/Treemap.js +87 -0
  127. package/src-old/renderer/SVGInteractionHandler.js +241 -0
  128. package/src-old/renderer/SVGRenderer.js +325 -0
  129. package/src-old/renderer/WebGLRenderer.js +1097 -0
  130. package/src-old/renderer/WebGLRenderer2.js +249 -0
  131. package/src-old/renderer/threejs/Line2.js +18 -0
  132. package/src-old/renderer/threejs/LineGeometry.js +77 -0
  133. package/src-old/renderer/threejs/LineMaterial.js +605 -0
  134. package/src-old/renderer/threejs/LineSegments2.js +281 -0
  135. package/src-old/renderer/threejs/LineSegmentsGeometry.js +226 -0
  136. package/src-old/renderer/threejs/Wireframe.js +51 -0
  137. package/src-old/renderer/threejs/WireframeGeometry2.js +16 -0
  138. package/src-old/scale/areaSize.js +0 -0
  139. package/src-old/scale/domain.js +38 -0
  140. package/src-old/util/Constants.js +180 -0
  141. package/src-old/util/DataUtil.js +35 -0
  142. package/src-old/util/ItemUtil.js +586 -0
  143. package/src-old/util/Numerical.js +33 -0
  144. package/tests/demo-tests/README.md +80 -0
  145. package/tests/demo-tests/SVG2PNG.js +56 -0
  146. package/tests/demo-tests/demos2CanvasPNGs.js +69 -0
  147. package/tests/demo-tests/demos2ScenesSVGs.js +100 -0
  148. package/tests/demo-tests/pathElementWorker.js +91 -0
  149. package/tests/demo-tests/pixelTest.js +62 -0
  150. package/tests/demo-tests/renderDemos.html +132 -0
  151. package/tests/demo-tests/serializationTest.js +36 -0
  152. package/tests/demo-tests/serializeDemos.html +134 -0
  153. package/tests/unit-tests/README.md +4 -0
  154. package/tests/unit-tests/jasmine-browser.json +21 -0
  155. package/tests/unit-tests/jasmine.json +14 -0
  156. package/tests/unit-tests/testSpec.js +274 -0
  157. package/dist/mascot.js +0 -24920
  158. package/interactive.html +0 -592
@@ -1,199 +1,186 @@
1
- /* version: 2.1.0 */
2
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3"),require("pixi.js")):"function"==typeof define&&define.amd?define(["exports","d3","pixi.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).msc={},t.d3,t.PIXI)}(this,(function(t,e,i){"use strict";function s(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var n=s(e),r=s(i);class a{constructor(t,e,i,s){this.left=t,this.top=e,this.width=i,this.height=s}toJSON(){let t={};return t.left=this.left,t.top=this.top,t.width=this.width,t.height=this.height,t}union(t){let e=Math.min(this.left,t.left),i=Math.min(this.top,t.top),s=Math.max(this.right,t.right),n=Math.max(this.bottom,t.bottom);return new a(e,i,s-e,n-i)}clone(){return new a(this.left,this.top,this.width,this.height)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get x(){return(this.left+this.right)/2}get y(){return(this.top+this.bottom)/2}get center(){return(this.left+this.right)/2}get middle(){return(this.top+this.bottom)/2}contains(t,e){return this.left<=t&&this.right>=t&&this.top<=e&&this.bottom>=e}overlap(t){return!(this.right<t.left||this.bottom<t.top||this.left>t.right||this.top>t.bottom)}}const o="id",l="atlas_rowId",h=["linear","power","log","sqrt","symlog","identity","time","ordinal","band","point","ordinalColor","sequentialColor","divergingColor"],c="natural",d="basis",u="bumpX",f="bumpY",p="linear",g="step",m="CatmullRom",y="cardinal",v={Grid:"grid",Circular:"circular",Stack:"stack",Treemap:"treemap",Packing:"packing",Force:"force",TidyTree:"tidytree",Sugiyama:"sugiyama",Strata:"strata"},b="vertical",x="horizontal",w="angular",k="radial",C={Up:"up",Down:"down",Left:"left",Right:"right",Inward:"inward",Outward:"outward",Clockwise:"clockwise",Anticlockwise:"anticlockwise"},S={Top:"top",Left:"left",Bottom:"bottom",Right:"right",Center:"center",Middle:"middle"},E="alignment",T="affixation",A={Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",Line:"line",Path:"path",Image:"image",PointText:"pointText",Collection:"collection",Group:"group",Scene:"scene",Axis:"axis",Glyph:"glyph",Legend:"legend",Polygon:"polygon",Gridlines:"gridlines",LinearGradient:"LinearGradient",Link:"link",DataTable:"datatable"},I={Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"},O="max",R="min",M="avg",N="median",P="sum",F="count",B="mean",L="percentile 25",j="percentile 75",V={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"},D="Cannot find relevant information to create an axis for ",G="Cannot change scale type to ",z={FIELD_NONEXISTENT:"Data field does not exist in the data table",INCOMPLETE_REPEAT_INFO:"Incomplete information to do repeat. You must specify an item, a categorical data field and a data table",REPEAT_BY_NONCAT:"Repeat only works on a string or date field",PARTITION_BY_NONCAT:"Divide only works on a string or date field",DENSIFY_BY_NONCAT:"Densify only works on a string or date field",INCOMPLETE_REPOPULATE_INFO:"Incomplete information to re-populate. You must specify an item, a categorical data field and a data table",REPOPULATE_BY_NONCAT:"Repopulate only works on a string or date field",REPOPULATE_DT_MISMATCH:"Cannot repopulate with a data table that is different from the item's parent's data table",COMPNT_NON_REPEATABLE:"Item not repeatable",REPEAT_NODE_LINK:"To repeat with a tree or a network, you need to provide two marks, one for node and one for link",INCOMPLETE_PARTITION_INFO:"Incomplete information to divide. You must specify an item, a categorical data field and a data table",COMPNT_NON_PARTITIONABLE:"Item cannot be divided",INCOMPLETE_DENSIFY_INFO:"Incomplete information to densify. You must specify an item, a categorical data field and a data table",COMPNT_NON_DENSIFIABLE:"Item cannot be densified",STRATIFY_WITHOUT_TREE:"Stratify only works on a tree dataset",STRATIFY_WRONG_ITEM:"Stratify only works on a circle or a rectangle",BIND_WITHOUT_DATASCOPE:"Item must be repeated or divided by data first before applyng binding",UNKNOWN_ALIGNMENT:"Unkown alignment",UNKNOWN_Orientation:"Unkown orientation",UNKNOWN_DIRECTION:"Unkown direction",UNKOWNN_SCALE_TYPE:"Unknown scale type",UNKNOWN_ANCHOR:"Unknown anchor",INCOMPLETE_BINDING_INFO:"Incomplete binding information. You must specify an item, a data field and a visual channel",MULTIPLE_VALUES_PER_FIELD:"Multiple distinct field values exist",DIFFERENT_SCALE_TYPE:"Cannot merge different types of scale",INSUFFICIENT_DATA_SCOPES:"Insufficient data to divide or densify a mark",INCORRECT_CONSTRAINT_INFO:"Constrain information is incorreclty passed",FEATURE_NOT_IMPLEMENTED:"This feature has not been implemented yet",LAYOUT_WITHOUT_TREE:"The layout can only be applied to a tree",UNSUPPORTED_FIELDTYPE:"Unsupported field type for encoding ",CANNOT_CLASSIFY:"Cannot classify items in ",CANNOT_CREATE_GLYPH:"Cannot create glyph. A glyph must consist of only paths or only texts, not a mixture of paths and texts"},W=["schemeCategory10","schemeAccent","schemeDark2","schemePaired","schemePastel1","schemePastel2","schemeSet1","schemeSet2","schemeSet3","schemeTableau10"],Y=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],U=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class q{constructor(t){this._stops=[],this.type=A.LinearGradient,this.id=this.type+vt[this.type]++,this.x1="x1"in t?t.x1:0,this.x2="x2"in t?t.x2:100,this.y1="y1"in t?t.y1:0,this.y2="y2"in t?t.y2:0}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.x1=this.x1,t.x2=this.x2,t.y1=this.y1,t.y2=this.y2,t.stops=this._stops,t}addStop(t,e,i){this._stops.push({offset:t,color:e,opacity:i})}get stops(){return this._stops}}class J{constructor(t){if(this._dataScope=void 0,this._id=void 0,this.attrs={},this.styles={},this.staticProperties={},void 0!==t)for(let e in V)e in t&&(this.styles[e]=t[e])}get id(){return this._id}set id(t){this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){if(!this._bounds)return!1;if(!this._bounds.contains(t,e))return!1;switch(this.type){case A.Rect:case A.PointText:return!0;case A.Circle:return Math.sqrt(Math.pow(t-this.x,2)+Math.pow(e-this.y,2))<=this.radius+this.strokeWidth;case A.Path:{let i=wt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),this.closed?i.isPointInPath(s,t,e):i.isPointInStroke(s,t,e)}case A.Line:{let i=wt.getContext(),s=new Path2D(this.getSVGPathData());return i.lineWidth=Math.max(this.strokeWidth,2.5),i.stroke(s),i.isPointInStroke(s,t,e)}default:{let i=wt.getContext(),s=new Path2D(this.getSVGPathData());return i.isPointInPath(s,t,e)}}}toJSON(){let t={};t.type=this.type,t.id=this.id,this.classId&&(t.classId=this.classId),this._dataScope&&(t.dataScope=this._dataScope.toJSON()),t.args={};for(let e in this.attrs)t.args[e]=this.attrs[e];for(let e in this.styles)e.indexOf("Color")>0&&this.styles[e]instanceof q?t.args[e]=this.styles[e].toJSON():t.args[e]=this.styles[e];return t}getScene(){let t=this;for(;t;){if(t.type==A.Scene)return t;t=t.parent}}set dataScope(t){this._dataScope=t}get dataScope(){return this._dataScope}duplicate(){let t=this.getScene().mark(this.type);return this.copyPropertiesTo(t),t.classId=this.classId,this._dataScope&&(t._dataScope=this._dataScope.clone()),t}_doTranslate(t,e){}set visibility(t){this.styles.visibility=t}get visibility(){return this.styles.visibility?this.styles.visibility:"visible"}get opacity(){return"opacity"in this.styles?this.styles.opacity:1}set opacity(t){this.styles.opacity=t}}function X(t){return t>=-1e-12&&t<=1e-12}class ${constructor(t,e){this.x=t,this.y=e}transform(t){return t?t._transformPoint(this):this}negate(){return new $(-this.x,-this.y)}subtract(t){return new $(this.x-t.x,this.y-t.y)}isZero(){return X(this.x)&&X(this.y)}isCollinear(t){let e=this.x,i=this.y,s=t.x,n=t.y;return Math.abs(e*n-i*s)<=1e-8*Math.sqrt((e*e+i*i)*(s*s+n*n))}}class H{constructor(t,e,i){this.type="vertex",this._id=i,this.x=t.x,this.y=t.y,this.dataScope=void 0,this.parent=e,this.shape=void 0,this.width=0,this.height=0,this.radius=0,this.fillColor="#555",this.opacity=1,this.strokeWidth=0,this.strokeColor="#aaa",this._polarAngle=void 0}get bounds(){switch(this.shape){case"rect":return new a(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new a(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new a(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}toJSON(){let t={};return t.type=this.type,t.id=this._id,t.x=this.x,t.y=this.y,this.dataScope&&(t.dataScope=this.dataScope.toJSON()),void 0!==this._polarAngle&&(t.polarAngle=this._polarAngle),t.shape=this.shape,t.width=this.width,t.height=this.height,t.radius=this.radius,t.fillColor=this.fillColor,t.opacity=this.opacity,t.strokeWidth=this.strokeWidth,t.strokeColor=this.strokeColor,t}static fromJSON(t,e){let i=new H(t,e,t.id);return t.dataScope&&(i.dataScope=t.dataScope),"polarAngle"in t&&(i.polarAngle=t.polarAngle),i.shape=t.shape,i.width=t.width,i.height=t.height,i.radius=t.radius,i.fillColor=t.fillColor,i.opacity=t.opacity,i.strokeWidth=t.strokeWidth,i.strokeColor=t.strokeColor,i}_doTranslate(t,e){this.x+=t,this.y+=e}_clone(t){let e=new H(new $(this.x,this.y),t,this._id);return this.dataScope&&(e.dataScope=this.dataScope.clone()),e.shape=this.shape,e.width=this.width,e.height=this.height,e.radius=this.radius,e.fillColor=this.fillColor,e.opacity=this.opacity,e.strokeWidth=this.strokeWidth,e.strokeColor=this.strokeColor,e}set polarAngle(t){this._polarAngle=t}get polarAngle(){return this._polarAngle}}H.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class Z{constructor(t,e,i,s){this.type="segment",this._id=s,this.vertex1=t,this.vertex2=e,this.dataScope=void 0,this.parent=i}get id(){return this.parent.id+"_s_"+this._id}_doTranslate(t,e){this.vertex1._doTranslate(t,e),this.vertex2._doTranslate(t,e)}get x(){return(this.vertex1.x+this.vertex2.x)/2}get y(){return(this.vertex1.y+this.vertex2.y)/2}}class K extends J{constructor(t){if(super(t),this.type="type"in t?t.type:A.Path,"strokeColor"in this.styles||(this.styles.strokeColor="#ccc"),"strokeWidth"in this.styles||(this.styles.strokeWidth=1),"strokeDash"in this.styles||(this.styles.strokeDash="none"),this.vertices=[],this.vertexCounter=0,this.segmentCounter=0,this.segments=[],this.anchor=void 0,this.closed=!1,this.curveMode="linear",this.boundsOffsets={top:0,bottom:0,left:0,right:0},this._vxShape=void 0,this._vxWidth=0,this._vxHeight=0,this._vxRadius=0,this._vxFillColor="#555555",this._vxStrokeColor="#aaaaaa",this._vxStrokeWidth=0,this._vxOpacity=1,void 0!==t){for(let e of H.styles)e in t&&(this["_"+e]=t[e]);"vertices"in t&&this._setVertices(t.vertices)}}toJSON(){let t=super.toJSON();switch(t.type=this.type,t.id=this.id,this.type){case A.Rect:t.args.width=this.width,t.args.height=this.height,t.args.top=this.top,t.args.left=this.left;break;case A.Circle:t.args.x=this.x,t.args.y=this.y,t.args.radius=this.radius;break;case A.Arc:case A.Pie:t.args.x=this._x,t.args.y=this._y,t.args.innerRadius=this._innerRadius,t.args.outerRadius=this._outerRadius,t.args.startAngle=this._startAngle,t.args.endAngle=this._endAngle;break;default:t.vertices=[];for(let e of this.vertices)t.vertices.push(e.toJSON());this.type===A.Polygon?(t.args.x=this._x,t.args.y=this._y,t.args.radius=this._radius):this.type===A.Area&&(t.args.baseline=this._baseline,t.args.orientation=this._orientation)}t.vertexCounter=this.vertexCounter,t.segmentCounter=this.segmentCounter,t.curveMode=this.curveMode,this._bounds&&(t.bounds=this._bounds.toJSON()),t.boundsOffsets=this.boundsOffsets;for(let e of H.styles)t.args[e]=this[e];return t}_setVertices(t){let e,i;this.vertices=[],this.segments=[];for(let s=0;s<t.length;s++)if(s!=t.length-1||t[s][0]!==t[0][0]||t[s][1]!==t[0][1]||this.type!==A.Path){i=new $(t[s][0],t[s][1]),e=new H(i,this,this.vertexCounter++);for(let t of H.styles)if(this[t]){let i=t.replace("vx","");e[i[0].toLowerCase()+i.slice(1)]=this[t]}this.vertices.push(e),s>0&&this.segments.push(new Z(this.vertices[s-1],this.vertices[s],this,this.segmentCounter++))}let s=t[0],n=t[t.length-1];(s[0]===n[0]&&s[1]===n[1]||this.type===A.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new Z(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++)))}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles);for(let e of H.styles)this["_"+e]&&(t["_"+e]=this["_"+e]);this._dataScope&&(t._dataScope=this._dataScope.clone()),t.closed=this.closed,t.curveMode=this.curveMode,t.vertices=[],t.segments=[];for(let e of this.vertices)t.vertices.push(e._clone(t));t.segmentCounter=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new Z(t.vertices[e-1],t.vertices[e],t,t.segmentCounter++));t.closed&&t.segments.push(new Z(t.vertices[t.vertices.length-1],t.vertices[0],t,t.segmentCounter++))}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){this._bounds||this._updateBounds();let t=this._bounds.bottom+this.boundsOffsets.bottom-(this._bounds.top-this.boundsOffsets.top),e=this._bounds.right+this.boundsOffsets.right-(this._bounds.left-this.boundsOffsets.left);return new a(this._bounds.left-this.boundsOffsets.left,this._bounds.top-this.boundsOffsets.top,e,t)}get x(){return this.bounds.x}get y(){return this.bounds.y}get strokeColor(){return this.styles.strokeColor}set strokeColor(t){this.styles.strokeColor=t}get strokeWidth(){return this.styles.strokeWidth}set strokeWidth(t){this.styles.strokeWidth=t}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}get strokeDash(){return this.styles.strokeDash}set strokeDash(t){this.styles.strokeDash=t}_doTranslate(t,e){for(let i of this.vertices)i._doTranslate(t,e);this._updateBounds()}resize(t,e,i,s){let n=this.bounds,r=0===n.width?1:n.width,a=0===n.height?1:n.height;if("right"===i)for(let e of this.vertices)e.x=n.right-t/r*(n.right-e.x);else for(let e of this.vertices)e.x=n.left+t/r*(e.x-n.left);if("top"===s)for(let t of this.vertices)t.y=n.top+e/a*(t.y-n.top);else for(let t of this.vertices)t.y=n.bottom-e/a*(n.bottom-t.y);this._updateBounds()}_updateBounds(){let t=this.vertices.map((t=>t.x)),e=this.vertices.map((t=>t.y)),i=Math.min(...t),s=Math.min(...e),n=Math.max(...t),r=Math.max(...e);if(this._bounds=new a(i,s,n-i,r-s),this.type===A.Line||this.type===A.Path){let t=this.styles.strokeWidth?this.styles.strokeWidth:1;i===n?this._bounds=new a(i-t/2,s,n-i+t,r-s):s===r&&(this._bounds=new a(i,s-t/2,n-i,r-s+t))}}addVertex(t,e,i){let s=new H(new $(t,e),this,this.vertexCounter++);this.vertices.splice(i,0,s)}sortVertices(t,e){this.vertices.sort(((e,i)=>e[t]-i[t])),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}sortVerticesByData(t,e,i){let s;s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1,this.vertices.sort(s),e&&this.vertices.reverse();for(let t=0;t<this.segments.length;t++){let e=this.segments[t];e.vertex1=this.vertices[t],e.vertex2=this.vertices[(t+1)%this.vertices.length]}}getSVGPathData(){let t=n.path(),e=this._getD3CurveFunction(this.curveMode)(t);e.lineStart();for(let t of this.vertices)e.point(t.x,t.y);return this.closed&&e.point(this.vertices[0].x,this.vertices[0].y),e.lineEnd(),t._}get firstVertex(){return this.vertices[0]}get firstSegment(){return this.segments[0]}get lastVertex(){return this.vertices[this.vertices.length-1]}get lastSegment(){return this.segments[this.segments.length-1]}_getD3CurveFunction(t){switch(t){case c:return n.curveNatural;case d:return n.curveBasis;case u:return n.curveBumpX;case f:return n.curveBumpY;case p:return n.curveLinear;case g:return n.curveStep;case m:return n.curveCatmullRom;case y:return n.curveCardinal;default:return n.curveLinear}}get vxShape(){return this._vxShape}set vxShape(t){this._vxShape=t;for(let e of this.vertices)e.shape=t}get vxWidth(){return this._vxWidth}set vxWidth(t){this._vxWidth=t;for(let e of this.vertices)e.width=t}get vxHeight(){return this._vxHeight}set vxHeight(t){this._vxHeight=t;for(let e of this.vertices)e.height=t}get vxRadius(){return this._vxRadius}set vxRadius(t){this._vxRadius=t;for(let e of this.vertices)e.radius=t}get vxFillColor(){return this._vxFillColor}set vxFillColor(t){this._vxFillColor=t;for(let e of this.vertices)e.fillColor=t}get vxStrokeColor(){return this._vxStrokeColor}set vxStrokeColor(t){this._vxStrokeColor=t;for(let e of this.vertices)e.strokeColor=t}get vxStrokeWidth(){return this._vxStrokeWidth}set vxStrokeWidth(t){this._vxStrokeWidth=t;for(let e of this.vertices)e.strokeWidth=t}get vxOpacity(){return this._vxOpacity}set vxOpacity(t){this._vxOpacity=t;for(let e of this.vertices)e.opacity=t}}function Q(t,e){if("field"in e){if(!t.dataScope)return!1;let i=e.field;if("value"in e)return t.dataScope.getFieldValue(i)===e.value;if("interval"in e){let s=t.dataScope.getFieldValue(i);return s>=e.interval[0]&&s<=e.interval[1]}return"values"in e?e.values.indexOf(t.dataScope.getFieldValue(i))>=0:t.dataScope.hasField(i)}if("channel"in e){let i=e.channel;if("value"in e)return t[i]===e.value;if("interval"in e)return t[i]>=e.interval[0]&&t[i]<=e.interval[1];if("values"in e)return e.values.indexOf(t[i])>=0}else{if("type"in e)return t.type===e.type;if("id"in e)return t.id===e.id;if("classId"in e)return t.classId===e.classId;if("fields"in e){if(!t.dataScope)return!1;let i=e.fields[0],s=e.fields[1],n=t.dataScope.getFieldValue(i),r=t.dataScope.getFieldValue(s);switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}}}return!1}function tt(t,e){let i=[];return et(t,e,i),i}function et(t,e,i){if(t&&"axis"!=t.type&&"legend"!=t.type&&"gridlines"!=t.type)if(it(t,e)&&i.push(t),t.vertices)for(let s of t.vertices.concat(t.segments))it(s,e)&&i.push(s);else if(t.children&&t.children.length>0)for(let s of t.children)et(s,e,i)}function it(t,e){for(let i of e)if(!Q(t,i))return!1;return!0}function st(t,e){return"vertex"==t.type?function(t,e){if(!t.classId){if(t.dataScope){let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=tt(e,[{classId:i.classId}]),n=[];if(i.type===A.Area){let e=i.vertices.indexOf(t)<i.vertices.length/2;for(let t of s){let i=e?t.vertices.slice(0,t.vertices.length/2):t.vertices.slice(t.vertices.length/2);n=n.concat(i.filter((t=>t.dataScope)))}}else for(let t of s)n=n.concat(t.vertices.filter((t=>t.dataScope)));return n}{let i=t.parent;if(!i)throw new Error("vertex has no parent mark");let s=i.vertices.indexOf(t),n=tt(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.vertices[s]);return r}}}(t,e):"segment"==t.type?function(t,e){if(t.dataScope){let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=tt(e,[{classId:i.classId}]),n=[];for(let t of s)n=n.concat(t.segments);return n}{let i=t.parent;if(!i)throw new Error("segment has no parent mark");let s=i.segments.indexOf(t),n=tt(e,[{classId:i.classId}]),r=[];for(let t of n)r.push(t.segments[s]);return r}}(t,e):t.classId?tt(e,[{classId:t.classId}]):[]}function nt(t,e){let i=t.parent;for(;i&&i.type!=A.Scene;){if(i.layout&&(!e||e&&i.layout.type===e))return i.layout;i=i.parent}}function rt(t){let e=t,i=t.parent;for(;i&&i.type!=A.Scene;){if(i.layout){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function at(t){let e=t,i=t.parent;for(;i&&i.type!=A.Scene;){if(i.layout)return i.children.findIndex((t=>t==e));e=e.parent,i=e.parent}}function ot(t){let e=t,i=t.parent;for(;i&&i.type!=A.Scene;){if(i.layout&&i.layout.type==v.Grid){let t=i.children.findIndex((t=>t==e));return i.layout.cellBounds[t]}e=e.parent,i=e.parent}}function lt(t,e){let i,s=t.parent;for(;s&&s.type!==A.Scene;)s.layout&&(!e||e&&s.layout.type===e)&&(i=s.layout),s=s.parent;return i}function ht(t){if(t.classId)return t.classId;if("vertex"==t.type&&t.dataScope){if(t.parent.type===A.Area){let e=t.parent.vertices.indexOf(t)<t.parent.vertices.length/2;return t.parent.classId+"_v_"+(e?0:t.parent.vertices.length-1)}return t.parent.classId+"_v"}return"vertex"==t.type?t.parent.classId+"_v_"+t.parent.vertices.indexOf(t):"segment"==t.type&&t.dataScope?t.parent.classId+"_s":"segment"==t.type?t.parent.classId+"_s_"+t.parent.segments.indexOf(t):null}function ct(t,e){return ht(t).split("_")[0]===ht(e).split("_")[0]}function dt(t){let e=[];for(let i of t)i.parent&&e.indexOf(i.parent)<0&&e.push(i.parent);return e}function ut(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e.push(i),e=e.concat(ut(i));return e}function ft(t){let e=[];if(_t(t))e.push(t);else if(t.children&&t.children.length>0&&!gt(t))for(let i of t.children)e=e.concat(ft(i));return e}function pt(t){let e=[];if(t.children&&t.children.length>0)for(let i of t.children)e=e.concat(pt(i));else e.push(t);return e}function gt(t){return t.type===A.Axis||t.type===A.Legend||t.type===A.Gridlines}function _t(t){return t instanceof J}function mt(t){return t instanceof K}function yt(t){return!(!_t(t)&&t.type!=A.Glyph||t.dataScope)||t.type===A.Collection&&t.firstChild.dataScope.numTuples>1}const vt={area:0,rect:0,circle:0,pie:0,line:0,path:0,ring:0,arc:0,image:0,pointText:0,collection:0,group:0,scene:0,axis:0,glyph:0,legend:0,polygon:0,gridlines:0,LinearGradient:0,link:0,scale:0,datatable:0};function bt(t,e){if(e.getEncodingByItem(t,"x"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==v.Grid&&e.numCols>1)return!1}return!t.parent||t.parent.type==A.Scene||bt(t.parent,e)}function xt(t,e){if(e.getEncodingByItem(t,"y"))return!1;if(t.parent&&t.parent.layout){let e=t.parent.layout;if(e.type==v.Grid&&e.numRows>1)return!1}return!t.parent||t.parent.type==A.Scene||xt(t.parent,e)}var wt={canvas:void 0,getCanvas:function(){return window?(void 0===this.canvas&&(this.canvas=document.createElement("canvas")),this.canvas):null},getContext:function(){var t=this.getCanvas();return t?t.getContext("2d"):null}},kt={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}};function Ct(t){let e=t.parent;return e.type==A.Scene?t:Ct(e)}function St(t){let e=t.parent;return t.type==A.Collection?e.type==A.Collection?St(e):t:e.type!=A.Scene?St(e):void 0}function Et(t,e,i,s){return[i*Math.cos(At(s))+t,e-i*Math.sin(At(s))]}function Tt(t,e,i,s){let n=function(t){return 180*t/Math.PI}(Math.atan2(s-e,t-i));n=Math.round(10*n+Number.EPSILON)/10,n<0&&(n+=360);let r=Math.sqrt(Math.pow(t-i,2)+Math.pow(e-s,2));return r=Math.round(10*r+Number.EPSILON)/10,[n,r]}function At(t){return t*Math.PI/180}function It(t){let e=t.vertices.length;for(let i=0;i<t.vertices.length/2;i++){let s=i,n=e-i-1,r=t.vertices[s],a=t.vertices[n];if(r.x!=a.x||r.y!=a.y)return r.x==a.x?"horizontal":"vertical"}}class Ot{constructor(t){this.group=void 0}run(){}clone(){}}class Rt extends Ot{constructor(t){super(),this.type="grid",this._numCols=t.numCols,this._numRows=t.numRows,this._dir="dir"in t?t.dir:[Rt.direction.Left2Right,Rt.direction.Top2Bottom],this._rowGap="rowGap"in t&&void 0!==t.rowGap?t.rowGap:5,this._colGap="colGap"in t&&void 0!==t.colGap?t.colGap:5,this._cellHorzAlignment="horzCellAlignment"in t&&this._validateCellAlignment("h",t.horzCellAlignment)?t.horzCellAlignment:S.Left,this._cellVertAlignment="vertCellAlignment"in t&&this._validateCellAlignment("v",t.vertCellAlignment)?t.vertCellAlignment:S.Bottom,this._numCols||this._numRows||(this._numRows=1)}_validateCellAlignment(t,e){return"h"===t&&[S.Left,S.Center,S.Right].indexOf(e)>=0||("v"===t&&[S.Top,S.Middle,S.Bottom].indexOf(e)>=0||(console.warn("Invalid alignment:",e),!1))}toJSON(){let t={args:{}};return t.type=this.type,t.args.numCols=this._numCols,t.args.numRows=this._numRows,t.args.colGap=this._colGap,t.args.rowGap=this._rowGap,t.args.horzCellAlignment=this._cellHorzAlignment,t.args.vertCellAlignment=this._cellVertAlignment,t.left=this._left,t.top=this._top,t.args.dir=this._dir,t}clone(){return new Rt({numCols:this._numCols,numRows:this._numRows,dir:this._dir,colGap:this._colGap,rowGap:this._rowGap})}get cellBounds(){let t,e,i=this.group,s=this._colGap,n=this._rowGap;this._numRows?(e=this._numRows,t=Math.ceil(this.group.children.length/this._numRows)):this._numCols&&(t=this._numCols,e=Math.ceil(this.group.children.length/this._numCols));let r=i.children.map((t=>t.bounds));if(void 0===this._left){let t=r.map((t=>t.left)),e=r.map((t=>t.top));this._left=Math.min(...t),this._top=Math.min(...e)}let o=r.map((t=>t.width)),l=r.map((t=>t.height)),h=Math.max(...o),c=Math.max(...l),d=0,u=i.getInternalEncodings("x"),f=i.getInternalEncodings("y"),p=i.getInternalEncodings("width"),g=i.getInternalEncodings("height");if(u.length>0){let t=u[u.length-1],e=t.scale.rangeExtent;d=t.scale.range[0],h=Math.max(e,h)}else p.length>0&&p[p.length-1]._rectNegativeValues&&(h=p[p.length-1].scale.rangeExtent,d=p[p.length-1].scale.range[0]);if(f.length>0){let t=f[f.length-1].scale.rangeExtent;c=Math.max(t,c)}else g.length>0&&g[g.length-1]._rectNegativeValues&&(c=g[g.length-1].scale.rangeExtent);let _=[],m=e*t;switch(this._dir[0]){case Rt.direction.Left2Right:switch(this._dir[1]){case Rt.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(this._left+(h+s)*(e%t)+d,this._top+(c+n)*Math.floor(e/t),h,c));break;case Rt.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(this._left+(h+s)*(e%t)+d,this._top+(this.numRows-1-Math.floor(e/t))*(c+n),h,c))}break;case Rt.direction.Right2Left:switch(this._dir[1]){case Rt.direction.Top2Bottom:for(let e=0;e<m;e++)_.push(new a(d+this._left+(t-1)*(h+s)-(h+s)*(e%t),this._top+(c+n)*Math.floor(e/t),h,c));break;case Rt.direction.Bottom2Top:for(let e=0;e<m;e++)_.push(new a(d+this._left+(t-1-e%t)*(h+s),this._top+(this.numRows-1-Math.floor(e/t))*(c+n),h,c))}break;case Rt.direction.Top2Bottom:switch(this._dir[1]){case Rt.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(d+this._left+(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),h,c));break;case Rt.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(d+this._left+(h+s)*(this.numCols-1)-(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(t%this.numRows),h,c))}break;case Rt.direction.Bottom2Top:switch(this._dir[1]){case Rt.direction.Left2Right:for(let t=0;t<m;t++)_.push(new a(d+this._left+(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),h,c));break;case Rt.direction.Right2Left:for(let t=0;t<m;t++)_.push(new a(d+this._left+(h+s)*(this.numCols-1)-(h+s)*Math.floor(t/this.numRows),this._top+(c+n)*(this.numRows-1)-(c+n)*(t%this.numRows),h,c))}}return _}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.cellBounds,e=this.group.getInternalEncodings("x"),i=this.group.getInternalEncodings("y"),s=this.group.getInternalEncodings("width"),n=this.group.getInternalEncodings("height");for(let s=0;s<this.group.children.length;s++){let n=this.group.children[s],r=t[s],a=r.x-n.bounds.x,o=r.y-n.bounds.y;n._doTranslate(a,o);let l=0,h=0;if(0==e.length)switch(this._cellHorzAlignment){case S.Left:l=r.left-n.bounds.left;break;case S.Center:l=r.x-n.bounds.x;break;case S.Right:l=r.right-n.bounds.right}if(0==i.length)switch(this._cellVertAlignment){case S.Top:h=r.top-n.bounds.top;break;case S.Middle:h=r.y-n.bounds.y;break;case S.Bottom:h=r.bottom-n.bounds.bottom}n._doTranslate(l,h)}if(e.length>0)for(let t of e)t._apply();else if(s.length>0){let t=s[s.length-1];t._rectNegativeValues&&t._apply()}if(i.length>0)for(let t of i)t._apply();else if(n.length>0){let t=n[n.length-1];t._rectNegativeValues&&t._apply()}this.group._updateBounds()}set rowGap(t){this._rowGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get rowGap(){return this._rowGap}set colGap(t){this._colGap=t,this.run(),this.group.getScene()._relayoutAncestors(this.group)}get colGap(){return this._colGap}set numCols(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"columns for",this.group.children.length,"items in grid"):(this._numCols=t,this._numRows=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}set numRows(t){t<0||t>this.group.children.length?console.warn("Cannot set",t,"rows for",this.group.children.length,"items in grid"):(this._numRows=t,this._numCols=Math.ceil(this.group.children.length/t),this.run(),this.group.getScene()._relayoutAncestors(this.group))}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}set vertCellAlignment(t){if(t!=S.Top&&t!=S.Bottom&&t!=S.Middle)throw z.UNKOWN_ALIGNMENT;this._cellVertAlignment=t,this.run()}get vertCellAlignment(){return this._cellVertAlignment}set horzCellAlignment(t){if(t!=S.Left&&t!=S.Center&&t!=S.Right)throw z.UNKOWN_ALIGNMENT;this._cellHorzAlignment=t,this.run()}get horzCellAlignment(){return this._cellHorzAlignment}set direction(t){Array.isArray(t)&&2===t.length?this._dir=t:this._dir=t.split("_"),this.run()}get direction(){return this._dir.join("_")}}Rt.direction={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"};class Mt{constructor(){this.children=[],this._dataScope=void 0,this._layout=void 0,this.type=A.Group,this._id=this.type+vt[this.type]++}get id(){return this._id}set id(t){this.type!==A.Scene&&this.getScene()?(delete this.getScene()._itemMap[this._id],this._id=t,this.getScene()._itemMap[t]=this):this._id=t}contains(t,e){return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}toJSON(){let t={};if(t.type=this.type,t.id=this.id,this._dataScope&&(t.dataScope=this._dataScope.toJSON()),this.classId&&(t.classId=this.classId),this._layout&&(t.layout=this._layout.toJSON()),this._bounds&&(t.bounds=this._bounds.toJSON()),t.children=[],this.children.length>0&&this.type!=A.Axis)for(let e of this.children)t.children.push(e.toJSON());return this.childrenOrder&&(t.childrenOrder=this.childrenOrder),t}addChild(t){this.children.indexOf(t)>=0||(t.parent&&t.parent.removeChild(t),this.children.push(t),t.parent=this)}addChildAt(t,e){t.parent&&t.parent.removeChild(t),this.children.splice(e,0,t),t.parent=this}removeChild(t){let e=this.children.indexOf(t);e>=0&&(this.children.splice(e,1),t.parent=null)}removeChildAt(t){this.children[t].parent=null,this.children.splice(t,1)}removeAll(){for(let t of this.children)t.parent=null;this.children=[]}getScene(){let t=this;for(;t;){if(t.type==A.Scene)return t;t=t.parent}}get dataScope(){return this._dataScope}set dataScope(t){if(this._dataScope=t,void 0===t)for(let e of this.children)e.dataScope=t;else for(let e of this.children)e.dataScope?e.dataScope=e.dataScope.merge(t):e.dataScope=t}_doTranslate(t,e){for(let i of this.children)i._doTranslate(t,e);this._updateBounds(),this._layout&&(void 0!==this._layout._left&&(this._layout._left+=t),void 0!==this._layout._top&&(this._layout._top+=e),void 0!==this._layout.x&&(this._layout.x+=t),void 0!==this._layout.y&&(this._layout.y+=e)),this._updateBounds()}getInternalEncodings(t){if(0==this.children.length)return[];let e=this.children[0],i=this.getScene(),s=Object.keys(i.encodings),n=[];for(;e;){if(e.classId&&n.indexOf(e.classId)<0&&n.push(e.classId),e.type===A.Glyph){e.children.forEach((t=>n.push(t.classId)));break}if(!e.children)break;e=e.children[0]}let r=[];for(let e of s){let s=e.split("_");for(let a of n)s[0]==a&&i.encodings[e][t]&&r.push(i.encodings[e][t])}return r}get firstChild(){return this.children[0]}get lastChild(){return this.children[this.children.length-1]}set layout(t){if(this._layout=t,t)t.group=this,this._layout.run();else{let t=this.getInternalEncodings("x"),e=this.getInternalEncodings("y");for(let e of t)e._map(),e._apply();for(let t of e)t._map(),t._apply()}}get layout(){return this._layout}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){let t=this.children.map((t=>t.refBounds)),e=Math.min(...t.map((t=>t.left))),i=Math.min(...t.map((t=>t.top))),s=Math.max(...t.map((t=>t.right))),n=Math.max(...t.map((t=>t.bottom)));return new a(e,i,s-e,n-i)}get x(){return this.bounds.x}get y(){return this.bounds.y}_updateBounds(){if(this.children.length>0){this._bounds=this.children[0].bounds.clone();for(let t=1;t<this.children.length;t++)"hidden"!=this.children[t].visibility&&(this._bounds=this._bounds.union(this.children[t].bounds));if(this._layout&&"grid"==this._layout.type){let t=this._layout.cellBounds;for(let e=0;e<t.length;e++)this._bounds=this._bounds.union(t[e])}}else this._bounds=new a(0,0,0,0)}sortChildrenByData(t,e,i){let s;switch(this.children[0].dataScope.getFieldType(t)){case I.Date:break;case I.Number:case I.Integer:s=(e,i)=>e.dataScope.aggregateNumericalField(t)-i.dataScope.aggregateNumericalField(t);break;case I.String:s=i?(e,s)=>i.indexOf(e.dataScope.getFieldValue(t))-i.indexOf(s.dataScope.getFieldValue(t)):(e,i)=>e.dataScope.getFieldValue(t)<i.dataScope.getFieldValue(t)?-1:1}this.children.sort(s),e&&this.children.reverse(),this.layout&&this.layout.run(),this._childrenOrder={field:t,direction:e?"desc":"asc",ranking:i}}sortChildren(t,e){let i;switch(t){case"x":case"y":case"width":case"height":i=(e,i)=>e.bounds[t]-i.bounds[t];break;default:i=(e,i)=>e[t]-i[t]}this.children.sort(i),e&&this.children.reverse(),this.layout&&this.layout.run(),this.childrenOrder={channel:t,reverse:e}}set visibility(t){this._visibility="hidden"==t?t:"visible";for(let e of this.children)e.visibility=t}get visibility(){return this._visibility?this._visibility:"visible"}}function Nt(t){return[...new Set(t)]}function Pt(t,e){if(e.hasField(t))return!0;if(e.tree&&e.tree.nodeTable.hasField(t.split(".")[1]))return!0;throw new Error(z.FIELD_NONEXISTENT+", field: "+t+", data table: "+e.name)}function Ft(t){return t<0?t+360:t>360?t-360:t}class Bt{constructor(t){this._field2value={},this._dt=t,this._tuples=this._dt.data}toJSON(){let t={};return t.dt=this._dt.id,t.f2v=Object.assign({},this._field2value),t}isFullTable(){return 0===Object.keys(this._field2value).length}isEmpty(){return 0==this._tuples.length}get numTuples(){return this._tuples.length}get fields(){return Object.keys(this._field2value)}get dataTable(){return this._dt}get filters(){return this._field2value}merge(t){let e=new Bt(this._dt);for(let i in t._field2value)e=e.cross(i,t._field2value[i]);for(let t in this._field2value)e=e.cross(t,this._field2value[t]);return e}cross(t,e){let i=this.clone();return i._field2value[t]=e,i._updateTuples(t,e),i}clone(){let t=new Bt(this._dt);return t._field2value=Object.assign({},this._field2value),t._tuples=this._tuples.map((t=>t)),t}getFieldValue(t){let e=this._tuples.map((e=>e[t]));return e=[...new Set(e)],e.length,e[0]}getUniqueFieldValues(t){let e=this._tuples.map((e=>e[t]));return[...new Set(e)]}hasField(t){return t in this._field2value}getFieldType(t){return this._dt.getFieldType(t)}aggregateNumericalField(t,e){let i=this._tuples.map((e=>e[t]));switch(e){case O:return Math.max(...i);case R:return Math.min(...i);case M:case B:return n.mean(i);case N:return n.median(i);case F:return i.length;case L:return n.quantile(i,.25);case j:return n.quantile(i,.75);case P:default:return n.sum(i)}}_updateTuples(t,e){this._tuples=this._tuples.filter((i=>i[t]==e))}get tuples(){return this._tuples}}function Lt(t,e,i,s,n){let r=n?s.transformField(i,n):i,a=s.getFieldType(r);if(a!=I.String&&a!=I.Date&&a!=I.Integer)throw new Error(z.REPEAT_BY_NONCAT+": "+r+" is "+a);if(!pd(e))throw new Error(z.COMPNT_NON_REPEATABLE);return function(t,e,i,s){let n=s.getFieldSummary(i).unique.map((t=>e.dataScope?e.dataScope.cross(i,t):new Bt(s).cross(i,t)));n=n.filter((t=>!t.isEmpty()));let r=t.collection();r.dataScope=e.dataScope?e.dataScope.clone():new Bt(s),r.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();r.addChild(t)}return r.children.forEach(((t,e)=>t.dataScope=n[e])),t._reapplySizeBindings(e),r}(t,e,r,s)}class jt extends Ot{constructor(t){super(t),this.type=v.Stack,this._orientation=t.orientation,this._direction=t.direction,this._left=t.left,this._top=t.top,this._horzCellAlignment="horzCellAlignment"in t&&t.horzCellAlignment?t.horzCellAlignment:S.Left,this._vertCellAlignment="vertCellAlignment"in t&&t.vertCellAlignment?t.vertCellAlignment:S.Bottom,this._gap="gap"in t?t.gap:0}toJSON(){let t={args:{}};return t.type=this.type,t.args.orientation=this._orientation,t.args.direction=this._direction,t.args.left=this._left,t.args.top=this._top,t.args.gap=this._gap,t.args.horzCellAlignment=this._horzCellAlignment,t.args.vertCellAlignment=this._vertCellAlignment,t}clone(){let t=new jt({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return t._horzCellAlignment=this._horzCellAlignment,t._vertCellAlignment=this._vertCellAlignment,t}_stackAreasVert(){let t=this.group.children,e=this.group.bounds,i=this._vertCellAlignment===S.Top?e.top:e.bottom,s=this._vertCellAlignment===S.Top?1:-1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],l=Math.abs(a.y-o.y),h=i+r[t]*s,c=i+(r[t]+l)*s;a._doTranslate(0,h-a.y),o._doTranslate(0,c-o.y),r[t]+=l}e._updateBounds()}if(this.vertCellAlignment===S.Middle)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.middle+r[t]/2;s._doTranslate(0,o-e.bottom),a._doTranslate(0,o-e.bottom)}i._updateBounds()}this.group._updateBounds()}_stackAreasHorz(){let t=this.group.children,e=this.group.bounds,i=this._horzCellAlignment===S.Right?e.right:e.left,s=this._horzCellAlignment===S.Right?-1:1,n=t[0].vertices.length/2,r=new Array(n).fill(0);for(let e of t){for(let t=0;t<n;t++){let a=e.vertices[t],o=e.vertices[2*n-t-1],l=Math.abs(a.x-o.x),h=i+r[t]*s,c=i+(r[t]+l)*s;a._doTranslate(0,h-a.y),o._doTranslate(0,c-o.y),r[t]+=l}e._updateBounds()}if(this._horzCellAlignment===S.Center)for(let i of t){for(let t=0;t<n;t++){let s=i.vertices[t],a=i.vertices[2*n-t-1],o=e.center-r[t]/2;s._doTranslate(0,o-e.left),a._doTranslate(0,o-e.left)}i._updateBounds()}this.group._updateBounds()}_stackAreas(){this.group.children[0].orientation===x?this._stackAreasVert():this._stackAreasHorz()}_stackArcs(){let t=this.group,e=this.startAngle?this.startAngle:90;if((this._direction?this._direction:C.Clockwise)===C.Clockwise)for(let i of t.children){let t=Ft(e-i.angle);i.adjustAngle(t,e),e=t}else for(let i of t.children){let t=Ft(e+i.angle);i.adjustAngle(e,t),e=t}}_stackRects(){let t=this.group.getScene(),e=this.group,i=this._orientation,s=e.children.map((t=>t.bounds)),n=s.map((t=>t.left)),r=s.map((t=>t.top)),a=s.map((t=>t.width)),o=s.map((t=>t.height)),l=null==this._left?Math.min(...n):this._left,h=null==this._top?Math.min(...r):this._top,c=Math.max(...a),d=Math.max(...o);if(i==b){let i=l+c/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=i-n.bounds.x,a=h+n.bounds.height/2-n.bounds.y;h+=n.bounds.height+this._gap,n._doTranslate(r,a);let o=0,d=0;if(!t.getEncodingByItem(n,"x"))switch(this._horzCellAlignment){case S.Left:o=l-n.bounds.left;break;case S.Center:o=l+c/2-n.bounds.x;break;case S.Right:o=l+c-n.bounds.right}n._doTranslate(o,d)}}else{let i=h+d/2;for(let s=0;s<e.children.length;s++){let n=e.children[s],r=l+n.bounds.width/2-n.bounds.x,a=i-n.bounds.y;l+=n.bounds.width+this._gap,n._doTranslate(r,a);let o=0,c=0;if(!t.getEncodingByItem(n,"y"))switch(this._vertCellAlignment){case S.Top:c=h-n.bounds.top;break;case S.Middle:c=h+d/2-n.bounds.y;break;case S.Bottom:c=h+d-n.bounds.bottom}n._doTranslate(o,c)}}this.group._updateBounds()}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=ft(this.group)[0];switch(t.type){case A.Area:this._stackAreas();break;case A.Arc:case A.Pie:t.parent===this.group&&this._stackArcs();break;case A.Rect:case A.Image:case A.Circle:this._stackRects()}}set vertCellAlignment(t){if(t!=S.Top&&t!=S.Bottom&&t!=S.Middle)throw z.UNKOWN_ALIGNMENT;this._vertCellAlignment=t,this.run()}get vertCellAlignment(){return this._vertCellAlignment}set horzCellAlignment(t){if(t!=S.Left&&t!=S.Center&&t!=S.Right)throw z.UNKOWN_ALIGNMENT;this._horzCellAlignment=t,this.run()}get horzCellAlignment(){return this._horzCellAlignment}get cellBounds(){return this.group.children.map((t=>t.bounds))}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}}function Vt(t,e,i,s,n,r){let a=r?n.transformField(s,r):s,o=n.getFieldType(a);if(o!=I.String&&o!=I.Date)throw new Error(z.PARTITION_BY_NONCAT+": "+a+" is "+o);if(!gd(e))throw new Error(z.COMPNT_NON_PARTITIONABLE);switch(e.type){case A.Line:return function(t,e,i,s){let n,r,a=st(e,t),o=s.getFieldSummary(i).unique.map((t=>new Bt(s).cross(i,t))),l={},h=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>h&&(h=e.length),l[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope;let a=i.parent;a.addChild(s);let o=l[i.id],c=i.vertices[0].x,d=i.vertices[0].y,u=i.vertices[1].x,f=i.vertices[1].y;for(let t=0;t<o.length;t++){let n=i.duplicate();n.classId=e.id,n.vertices[0].x=c+(u-c)*t/h,n.vertices[0].y=d+(f-d)*t/h,n.vertices[1].x=c+(u-c)*(t+1)/h,n.vertices[1].y=d+(f-d)*(t+1)/h,n.dataScope=o[t],s.addChild(n)}a.removeChild(i),i==e&&(n=s)}return n}(t,e,a,n);case A.Path:return function(t,e,i,s){let n,r,a=st(e,t),o=s.getFieldSummary(i).unique.map((t=>new Bt(s).cross(i,t))),l={},h=0;for(let t of a){let e=o;t.dataScope&&(e=o.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>h&&(h=e.length),l[t.id]=e}for(let i of a){let s=t.collection();null==r&&(r=s.id),s.classId=r,s.dataScope=i.dataScope;let a=i.parent;a.addChild(s);let o=l[i.id],c=i.bounds.left,d=i.bounds.top,u=i.bounds.right,f=i.bounds.bottom;for(let i=0;i<o.length;i++){let n=t.mark("line",{x1:c+(u-c)*i/h,x2:c+(u-c)*(i+1)/h,y1:d+(f-d)*i/h,y2:d+(f-d)*(i+1)/h});n.classId=e.id,n.dataScope=o[i],s.addChild(n)}a.removeChild(i),i==e&&(n=s)}let c=e.firstVertex.dataScope.fields[0];return t.densify(n.firstChild,s,{field:c}),n}(t,e,a,n);case A.Circle:return function(t,e,i,s,n){let r,a,o=i||w,l=st(e,t);if(o==w)l.forEach((i=>{let o=i.dataScope?i.dataScope:new Bt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/h,f=90;for(let s=0;s<h;s++){let n=t.mark("pie",{innerRadius:0,outerRadius:i.radius,x:i.x,y:i.y,startAngle:Ft(f-u*(s+1)),endAngle:Ft(f-u*s),strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}c.layout=cd("stack",{orientation:w,direction:C.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)}));else{if(o!=k)throw z.UNKNOWN_Orientation+": "+o;l.forEach((i=>{let o=i.dataScope?i.dataScope:new Bt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=i.radius/h;for(let s=0;s<h;s++){let n=t.mark("ring",{x:i.x,y:i.y,innerRadius:s*u,outerRadius:(s+1)*u,strokeColor:i.strokeColor,fillColor:i.styles.fillColor});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)}))}return r}(t,e,i,a,n);case A.Rect:return function(t,e,i,s,n){let r,a=st(e,t),o=i||x;if(o!=x&&o!=b)throw z.UNKNOWN_Orientation+": "+o;let l,h=n.getFieldSummary(s).unique.map((t=>new Bt(n).cross(s,t))),c={},d=0;for(let t of a){let e=h;t.dataScope&&(e=h.map((e=>e.merge(t.dataScope))),e=e.filter((t=>!t.isEmpty()))),e.length>d&&(d=e.length),c[t.id]=e}for(let i of a){let s=t.collection();null==l&&(l=s.id),s.classId=l,s.dataScope=i.dataScope?i.dataScope:new Bt(n);let a=i.parent;a.addChild(s);let h=c[i.id],d=i.bounds,u=d.left,f=d.top,p=o==x?d.width/h.length:d.width,g=o==x?d.height:d.height/h.length;for(let t=0;t<h.length;t++){let n=i.duplicate();n.classId=e.id,n.resize(p,g),n.dataScope=h[t],s.addChild(n)}s.layout=new jt({orientation:o,left:u,top:f}),a.removeChild(i),i==e&&(r=s)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case A.Area:return function(t,e,i,s,n){let r,a=st(e,t),o=a[0];if(4==o.vertices.length&&i==x&&o.vertices[0].x!==o.vertices[1].x)for(let t of a){let e=t.vertices[1];t.vertices[1]=t.vertices[3],t.vertices[3]=e}let l,h=n.getFieldSummary(s).unique.map((t=>new Bt(n).cross(s,t)));for(let s of a){let a=t.collection();null==l&&(l=a.id),a.classId=l,a.dataScope=s.dataScope?s.dataScope:new Bt(n);let o=s.parent;o.addChild(a);let c=s.left,d=s.top,u=i==x?s.width/h.length:s.width,f=i==x?s.height:s.height/h.length;for(let t=0;t<h.length;t++){let t=s.duplicate();t.classId=e.id,t.resizeArea(u,f),a.addChild(t)}o.removeChild(s);for(let t=0;t<a.children.length;t++){let e=a.children[t];e.dataScope?e.dataScope=e.dataScope.merge(h[t]):e.dataScope=h[t];for(let t of e.vertices)t.dataScope?t.dataScope=e.dataScope.merge(t.dataScope):t.dataScope=e.dataScope}a.layout=new jt({orientation:i,left:c,top:d}),s==e&&(r=a)}return t._reapplySizeBindings(r),r}(t,e,i,a,n);case A.Ring:return function(t,e,i,s,n){let r,a,o=i||w,l=st(e,t);if(o==w)return l.forEach((i=>{let o=i.dataScope?i.dataScope:new Bt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent,u=360/h,f=90;for(let s=0;s<h;s++){let n=t.mark("arc",{innerRadius:i.innerRadius,outerRadius:i.outerRadius,x:i.x,y:i.y,startAngle:Ft(f-u*(s+1)),endAngle:Ft(f-u*s),strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}c.layout=cd("stack",{direction:C.Clockwise}),d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw z.UNKNOWN_Orientation+": "+o}(t,e,i,a,n);case A.Pie:case A.Arc:return function(t,e,i,s,n){let r,a,o=i||k,l=st(e,t);if(o==k)return l.forEach((i=>{let o=i.dataScope?i.dataScope:new Bt(n),l=n.getFieldSummary(s).unique.map((t=>o.cross(s,t)));l=l.filter((t=>!t.isEmpty()));let h=l.length,c=t.collection();c.dataScope=o,null==a&&(a=c.id),c.classId=a;let d=i.parent;for(let s=0;s<h;s++){let n=t.mark("arc",{innerRadius:s*i.outerRadius/h,outerRadius:(s+1)*i.outerRadius/h,x:i.x,y:i.y,startAngle:i.startAngle,endAngle:i.endAngle,strokeColor:i.strokeColor,fillColor:i.fillColor,strokeWidth:i.strokeWidth,opacity:i.opacity});n.dataScope=l[s],n.classId=e.id,c.addChild(n)}d.removeChild(i),d.addChild(c),i==e&&(r=c)})),r;throw z.UNKNOWN_Orientation+": "+o}(t,e,i,a,n)}}function Dt(t,e,i,s,n,r,a,o){let l=r?n.transformField(s,r):s,h=n.getFieldType(l);if(h!=I.String&&h!=I.Date&&h!=I.Number)throw new Error(z.DENSIFY_BY_NONCAT+": "+l+" is "+h);if(!_d(e))throw new Error(z.COMPNT_NON_DENSIFIABLE);switch(e.type){case A.Line:return function(t,e,i,s){let n,r=st(e,t);for(let a of r){let r=a.dataScope?a.dataScope:new Bt(s),o=s.getFieldSummary(i).unique.map((t=>r.cross(i,t)));o=o.filter((t=>!t.isEmpty())),1===o.length&&o.push(o[0].clone());let l=Object.assign({},a.styles);for(let t of H.styles)a[t]&&(l[t]=a[t]);let h=a.vertices[0].x,c=a.vertices[0].y,d=[],u=a.vertices[1].x-h,f=a.vertices[1].y-c;for(let t=0;t<o.length;t++)d.push([h+t*u/(o.length-1),c+t*f/(o.length-1)]);l.vertices=d;let p=t.mark("path",l);p.classId=e.id,p.dataScope=r;let g=a.parent;g.addChild(p),g.removeChild(a);for(let[t,e]of p.vertices.entries())e.dataScope?e.dataScope=e.dataScope.merge(o[t]):e.dataScope=o[t];a==e&&(n=p)}return n}(t,e,l,n);case A.Circle:return function(t,e,i,s,n,r){let a;return st(e,t).forEach((o=>{let l=o.dataScope?o.dataScope:new Bt(s),h=s.getFieldSummary(i).unique.map((t=>l.cross(i,t)));h=h.filter((t=>!t.isEmpty()));let c=h.length;if(c<3)throw Error(z.INSUFFICIENT_DATA_SCOPES);let d=360/c,u=[],f=[],p="clockwise"==r?-1:1;for(let t=0;t<h.length;t++){let e=n+p*t*d;f[t]=e;let i=Et(o.x,o.y,o.radius,f[t]);u.push(i)}let g=t.mark("polygon",{x:o.x,y:o.y,radius:o.radius,vertices:u});g.dataScope=l,g.styles=Object.assign({},o.styles);for(let t of H.styles)o[t]&&(g[t]=o[t]);let _=o.parent;_.addChild(g),_.removeChild(o);for(let[t,e]of g.vertices.entries())e.polarAngle=f[t],e.dataScope?e.dataScope=e.dataScope.merge(h[t]):e.dataScope=h[t];o==e&&(a=g)})),a}(t,e,l,n,a,o);case A.Rect:case A.Area:return function(t,e,i,s,n){let r,a=st(e,t);for(let o of a){let a=n.getFieldType(s),l=o.dataScope?o.dataScope:new Bt(n),h=n.getFieldSummary(s).unique.map((t=>l.cross(s,t)));h=a==I.Number?h:h.filter((t=>!t.isEmpty())),1===h.length&&h.push(h[0].clone()),a!=I.Number&&a!=I.Date||h.sort(((t,e)=>t._field2value[s]>e._field2value[s]?1:-1));let c=Object.assign({},o.styles),d=o.vertices[0].x,u=o.vertices[0].y,f=o.vertices[o.vertices.length-2].x,p=o.vertices[o.vertices.length-2].y,g=[],_=f-d,m=p-u;for(let t=0;t<h.length;t++)g.push(i==b?[f,u+(h.length-1-t)*m/(h.length-1)]:[d+t*_/(h.length-1),u]);for(let t=0;t<h.length;t++)g.push(i==b?[d,u+t*m/(h.length-1)]:[d+(h.length-1-t)*_/(h.length-1),p]);c.vertices=g;let y=t.mark("area",c);y.classId="area"==o.type?o.classId:"area"+o.classId.substring(9),y.dataScope=l,y.orientation=i,y.baseline=i===x?S.Bottom:S.Left;let v=o.parent;v.addChild(y),v.removeChild(o);for(let[t,e]of y.vertices.entries())t>=h.length?e.dataScope=l.merge(h[2*h.length-1-t]):e.dataScope=l.merge(h[t]);o==e&&(r=y)}return r}(t,e,i,l,n)}}class Gt extends K{constructor(t){super(t)}get width(){return this.vertices[1].x-this.vertices[0].x}get height(){return this.vertices[2].y-this.vertices[1].y}set height(t){this.resize(this.width,t)}set width(t){this.resize(t,this.height)}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}get right(){return this.vertices[1].x}get bottom(){return this.vertices[2].y}get area(){return this.width*this.height}resize(t,e,i,s){"right"===i?(this.vertices[0].x=this.vertices[1].x-t,this.vertices[3].x=this.vertices[0].x):(this.vertices[1].x=this.vertices[0].x+t,this.vertices[2].x=this.vertices[1].x),"top"===s?(this.vertices[3].y=this.vertices[0].y+e,this.vertices[2].y=this.vertices[3].y):(this.vertices[0].y=this.vertices[3].y-e,this.vertices[1].y=this.vertices[0].y),this._updateBounds()}get leftSegment(){return this.segments[3]}get rightSegment(){return this.segments[1]}get topSegment(){return this.segments[0]}get bottomSegment(){return this.segments[2]}}class zt extends K{constructor(t){super(t),this.attrs.x="x"in t?t.x:0,this.attrs.y="y"in t?t.y:0,this.attrs.radius="radius"in t?t.radius:100}get radius(){return this.attrs.radius}get x(){return this.attrs.x}get y(){return this.attrs.y}get area(){return Math.PI*Math.pow(this.radius,2)}set x(t){this.attrs.x=t,this._updateBounds()}set y(t){this.attrs.y=t,this._updateBounds()}set radius(t){this.attrs.radius=t,this._updateBounds()}set area(t){this.attrs.radius=Math.sqrt(t),this._updateBounds()}resize(t,e,i,s){let n=Math.min(t,e)/2,r=n-this.attrs.radius;this.attrs.radius=n,"right"==i?this.attrs.x-=r:this.attrs.x+=r,"top"==s?this.attrs.y+=r:this.attrs.y-=r,this._updateBounds()}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this.attrs.x-this.attrs.radius,this.attrs.y-this.attrs.radius,2*this.attrs.radius,2*this.attrs.radius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t.attrs.x=this.attrs.x,t.attrs.y=this.attrs.y,t.attrs.radius=this.attrs.radius}getSVGPathData(){return["M",this.x,this.y,"m",-this.radius,", 0 a",this.radius,",",this.radius,"0 1,0",2*this.radius,",0 a",this.radius,",",this.radius,"0 1,0",-2*this.radius,",0"].join(" ")}}function Wt(t){return t._query=function(){this.data=[];let t=this.field,e=this.items,i=this.aggregator;switch(this.datatable.getFieldType(t)){case I.Boolean:break;case I.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case I.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,i)))}},t._map=function(){let t,e=this.items,i=this.data,s=this.channel;if(t=hd(this.scaleType),null==this.data.find((t=>t<0))||"width"!=s&&"height"!=s||0!=e[0].type.indexOf("rect")){let n,r;t.domain=[0,Math.max(...i)],"radius"==s||"outerRadius"==s||"innerRadius"==s?(n=0,r=Math.max(...e.map((t=>t[s]))),r<20&&(r=20)):"area"==s?(n=0,r=Math.max(...e.map((t=>t.bounds.width*t.bounds.height))),r<400&&(r=400)):"fontSize"==s?(n=2,r=Math.max(...e.map((t=>parseFloat(t.styles.fontSize))))):"strokeWidth"==s?(n=1,r=Math.max(...e.map((t=>parseFloat(t.styles.strokeWidth)))),r==n&&(r=n+5)):(n=0,r=Math.max(...e.map((t=>t.bounds[s])))),this.rangeExtent&&(r=n+this.rangeExtent),this.range&&(n=this.range[0],r=this.range[1]),t._setRange([n,r])}else this._rectNegativeValues=!0,t.domain=[Math.min(...i),Math.max(...i)],"width"==s?t._setRange([0,this.rangeExtent?this.rangeExtent:Math.max(...e.map((t=>t.width)))]):t._setRange([0,this.rangeExtent?this.rangeExtent:Math.max(...e.map((t=>t.height)))]);this.scale||(this.scale=t),this.scale._addEncoding(this)},t._apply=function(){if("radius"==this.channel||"outerRadius"==this.channel||"innerRadius"==this.channel){for(let t=0;t<this.items.length;t++){this.items[t][this.channel]=this.scale.map(this.data[t])}this.scene._relayoutAncestors(this.anyItem,this.items)}else if(this._rectNegativeValues){let t=Math.max(...this.data),e=Math.min(...this.data),i="width"===this.channel?Math.min(...this.items.map((t=>t.bounds.left))):Math.min(...this.items.map((t=>t.bounds.top)))+this.scale.rangeExtent,s="width"===this.channel?"right":"top",n="width"===this.channel?"left":"bottom";for(let r=0;r<this.items.length;r++){let a,o=this.items[r];if(o.parent&&o.parent.type===A.Collection){let t=o.parent.parent;if(t.type===A.Collection&&t.layout&&t.layout.type===v.Grid){let e=t.children.indexOf(o.parent);a=t.layout.cellBounds[e][n]}else a=o.parent.refBounds[n]}else a=i;"width"===this.channel?(o.leftSegment._doTranslate(a+this.scale.map(0)-o.leftSegment.vertex1.x,0),o.rightSegment._doTranslate(a+this.scale.map(this.data[r])-o.rightSegment.vertex1.x,0)):(o.topSegment._doTranslate(0,a-this.scale.map(this.data[r])-o.topSegment.vertex1.y),o.bottomSegment._doTranslate(0,a-this.scale.map(0)-o.bottomSegment.vertex1.y)),o._updateBounds(),this.data[r]>0?(o.boundsOffsets[s]=this.scale.map(t)-this.scale.map(this.data[r]),o.boundsOffsets[n]=this.scale.map(0)-this.scale.map(e)):(o.boundsOffsets[n]=this.scale.map(this.data[r])-this.scale.map(e),o.boundsOffsets[s]=this.scale.map(t)-this.scale.map(0))}}else if("area"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=Math.sqrt(this.scale.map(this.data[t]));e.resize(i,i)}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("fontSize"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.fontSize=i+"px"}this.scene._relayoutAncestors(this.anyItem,this.items)}else if("strokeWidth"==this.channel){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.styles.strokeWidth=i}this.scene._relayoutAncestors(this.anyItem,this.items)}else{let t="left",e="bottom";if(this.anyItem.parent&&this.anyItem.parent.type==A.Glyph){let i=this.anyItem.parent.children;1==Nt(i.map((t=>t.bounds.right))).length&&(t="right"),1==Nt(i.map((t=>t.bounds.top))).length&&(e="top")}if(this.anyItem.type===A.Collection&&this.anyItem.layout&&this.anyItem.layout[this.channel])for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.layout[this.channel]=i}else for(let i=0;i<this.items.length;i++){let s=this.items[i],n=this.scale.map(this.data[i]),r="width"==this.channel?n:s.bounds.width,a="height"==this.channel?n:s.bounds.height;s.resize(r,a,t,e)}this.scene._relayoutAncestors(this.anyItem,this.items)}},t.run(),t}function Yt(t){return t._query=function(){this.data=[],this.areas=st(this.items[0],this.scene);let t=this.areas.length;this.areaNum=t,this._vertices=[],this.indicator=[];for(let t of this.areas)for(let e=0;e<t.vertices.length;e++)this._vertices.push(t.vertices[e]),e<t.vertices.length/2?this.indicator.push(1):this.indicator.push(0);let e=this.field,i=this._vertices.map((t=>t.dataScope));switch(this.datatable.getFieldType(e)){case I.Boolean:break;case I.Date:this.data=i.map((t=>t.getFieldValue(e)));break;case I.String:this.data=i.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)));break;default:"x"==this.channel||"y"==this.channel?this.data=i.map((t=>t._field2value[e])):this.data=i.map(((t,i)=>0==this.indicator[i]?0:t.aggregateNumericalField(e,this.aggregator)))}},t._map=function(){"fillGradient"===this.channel?this._mapToGradient():"width"!=this.channel&&"height"!=this.channel||this._mapToSize()},t._mapToGradient=function(){if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=hd("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=hd("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=hd("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}this.scale._addEncoding(this)},t._mapToSize=function(){let t,e,i;switch(this.datatable.getFieldType(this.field)){case I.Boolean:break;case I.Date:t=hd("time"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=[e,i];break;case I.String:t=hd("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=this._includeZero||e<0?[0,i]:[e,i];break;default:t=hd("linear"),e=Math.min(...this.data),i=Math.max(...this.data),t.domain=e<0?[0,i]:[e,i]}let s,n=It(this.areas[0]),r=nt(this.anyItem);if(r){let t=r.cellBounds;s="width"==this.channel||"height"==this.channel?n==b?t[0].width:t[0].height:n==b?t[0].height:t[0].width}else s="width"==this.channel?Math.max(...this.areas.map((t=>t.bounds.width))):Math.max(...this.areas.map((t=>t.bounds.height)));this.rangeExtent&&(s=this.rangeExtent),e<0?(t._scale.domain([e,i]),t._setRange([0,s])):t._setRange([0,s]),this.scale?this.scale._merge(t):this.scale=t,this.scale._addEncoding(this)},t._apply=function(){"fillGradient"===this.channel?this._applyToGradient():"width"!=this.channel&&"height"!=this.channel||this._applyToSize()},t._applyToGradient=function(){let t=0;for(let e of this.areas){let i=this.data.slice(t,t+e.vertices.length),s=Math.min(...i),n=Math.max(...i),r="horizontal"===e.orientation?dd({x1:0,y1:100,x2:0,y2:0}):dd({x1:0,y1:0,x2:100,y2:0});if(r.addStop(0,this.scale.map(s),1),this._mapping){let t=Object.keys(this._mapping).map((t=>parseFloat(t))).sort();for(let e of t)e>s&&e<n&&r.addStop(100*(e-s)/(n-s),this.scale.map(e),1)}else"divergingColor"===this.scale.type&&r.addStop(100*-s/(n-s),this.scale.map(0),1);r.addStop(100,this.scale.map(n),1),e.fillColor=r,t+=e.vertices.length}},t._applyToSize=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);let i=this.areas[0].orientation;if("width"===e||"height"===e){if(nt(this.areas[0])){let t=0,e=this.areas.map((t=>rt(t))),s=this.areas.map((t=>nt(t)));for(let[n,r]of this.areas.entries()){let a=e[n],o=s[n];for(let e=0;e<r.vertices.length;e++){let s,n,l=this._vertices[e+t];if(i===x)if(s=0,o.type===v.Stack)n=a.bottom-this.scale.map(this.data[e+t])-l.y;else if(o.type===v.Grid){switch(r.baseline){case"top":n=a.top+this.scale.map(this.data[e+t])-l.y;break;case"bottom":n=a.bottom-this.scale.map(this.data[e+t])-l.y;break;case"middle":{let i=r.vertices.length-1-e,s=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));n=this.indicator[e+t]?a.middle-s/2-l.y:a.middle+s/2-l.y;break}}}else n=0;else if(n=0,o.type===v.Stack)s=a.left+this.scale.map(this.data[e+t])-l.x;else if(o.type===v.Grid){switch(r.baseline){case"left":s=a.left+this.scale.map(this.data[e+t])-l.x;break;case"right":s=a.right-this.scale.map(this.data[e+t])-l.x;break;case"center":{let i=r.vertices.length-1-e,n=Math.abs(this.scale.map(this.data[e+t])-this.scale.map(this.data[i+t]));s=this.indicator[e+t]?a.center-n/2-l.x:a.center+n/2-l.x;break}}}else s=0;l._doTranslate(s,n)}t+=r.vertices.length}}else{let t="center"==this.areas[0].baseline||"middle"==this.areas[0].baseline,e=0,s=i==b?"left":"bottom",n=i==i==b?"right":"top";for(let t of this.areas){for(let s=e;s<e+t.vertices.length;s++){let e=this._vertices[s],n=i==b?t.baseline!==S.Right?t.bounds.left-t.boundsOffsets.left:t.bounds.right+t.boundsOffsets.right:t.baseline!=S.Top?t.bounds.bottom+t.boundsOffsets.bottom:t.bounds.top-t.boundsOffsets.top,r=i==b?t.baseline!==S.Right?n+this.scale.map(this.data[s])-e.x:n-this.scale.map(this.data[s])-e.x:0,a=i==b?0:t.baseline!=S.Top?n-this.scale.map(this.data[s])-e.y:n+this.scale.map(this.data[s])-e.y;e._doTranslate(r,a)}let r=this.data.slice(e,e+t.vertices.length),a=Math.min(...r),o=Math.max(...r);t.boundsOffsets[n]=this.scale.map(Math.max(...this.data))-this.scale.map(o),t.boundsOffsets[s]=this.scale.map(a)-this.scale.map(Math.min(...this.data)),e+=t.vertices.length}if(1==t){let t=this._vertices.length/this.areaNum,e=dt(this._vertices),s=i==b?Math.min(...e.map((t=>t.bounds.x))):Math.max(...e.map((t=>t.bounds.y)));for(let e=0;e<this.areaNum;e++)for(let n=0;n<t/2;n++){let r=e*t+n,a=(e+1)*t-n-1,o=this._vertices[r],l=this._vertices[a],h=i==b?o.x-l.x:l.y-o.y,c=i==b?s+h/2-o.x:0,d=i==b?0:s+h/2-o.y,u=i==b?s-h/2-l.x:0,f=i==b?0:s-h/2-l.y;o._doTranslate(c,d),l._doTranslate(u,f)}}}}for(let t of this.areas)t._updateBounds();"width"!=e&&"height"!=e||this.scene._relayoutAncestors(this.areas[0],this.areas)},t.run(),t}class Ut{constructor(t,e,i,s,n){this.items=t,this.anyItem=this.items[0],this.scene=e,this.channel=i,this.field=s,this._aggregator=n.aggregator,this.datatable=n.datatable,this.scale=n.scale,this.scale?(this._flipScale=this.scale.isFlipped,this.scaleType=this.scale.type,this._includeZero=this.scale.includeZero):(this._flipScale=n.flipScale,this.scaleType=n.scaleType,this._includeZero=n.includeZero),this._mapping=n.mapping,this.rangeExtent=n.rangeExtent,this._scheme=n.scheme,this.range=n.range,"angle"==this.channel&&(this.startAngle="startAngle"in n?n.startAngle:90),this._query=void 0,this._map=void 0,this._apply=void 0}get id(){return["enc",ht(this.anyItem),this.channel,this.field].join("-")}set aggregator(t){this._aggregator=t,this.run()}get aggregator(){return this._aggregator}toJSON(){let t={};return t.anyItem=this.anyItem.id,t.items=this.items.map((t=>t.id)),this.data&&(t.data=this.data),this._rectNegativeValues&&(t._rectNegativeValues=!0),t.args={},t.args.channel=this.channel,t.args.field=this.field,t.args.aggregator=this.aggregator,t.args.datatable=this.datatable.id,t.args.scale=this.scale.id,t.args.mapping=this._mapping,t.args.rangeExtent=this.rangeExtent,t.args.scheme=this._scheme,t.args.scaleType=this.scaleType,t.args.range=this.range,"angle"==this.channel&&(t.args.startAngle=this.startAngle),t}run(){this._query(),this._map(),this._apply()}get dataTable(){return this.datatable}_inferTickValues(){let t,e=this,i=e.scale.domain,s=e.scale.range;switch(e.scale.type){case"linear":case"log":{let r=Math.abs(s[0]-s[1]);if("width"==e.channel||"height"==e.channel){let t=lt(e.anyItem,"stack");if(t){let s=st(t.group,e.scene);r=Math.max(...s.map((t=>t.refBounds[e.channel]))),i[1]=e.scale.invert(r)}}t="width"==e.channel||"x"==e.channel?45:30;let a,o=Math.max(2,Math.floor(r/t));if("log"===e.scale.type){a=[];let t=e.scale._scale.ticks();for(let e of t){let i=Math.log(e)/Math.log(10)+1e-6;Math.abs(i-Math.floor(i))<o/t.length&&a.push(e)}}else a=n.ticks(i[0],i[1],o);return a}case"point":{t="width"==e.channel||"x"==e.channel?80:30;let s=Math.floor(e.scale.rangeExtent/i.length),n=Math.ceil(t/s);return"x"==e.channel?i.filter(((t,e)=>e%n==0)):i}case"time":{t="width"==e.channel||"x"==e.channel?80:30;let r,a,o=Math.floor((s[1]-s[0])/t),l=Math.ceil((i[1]-i[0])/o)/1e3,h=[1,60,3600,86400,2628003,31536e3],c=[n.timeSeconds,n.timeMinutes,n.timeHours,n.timeDays,n.timeMonths,n.timeYears];for(let t=0;t<h.length-1;t++)if(l>=h[t]&&l<h[t+1])return r=Math.floor(l/h[t]),a=c[t],a(i[0],i[1],r);return l>h[h.length-1]?(r=Math.floor(l/h[h.length-1]),a=c[h.length-1],a(i[0],i[1],r)):[]}default:return[]}}getScaleRange(t){let e=t||this.anyItem;if(e.type!=A.Area&&("vertex"!=e.type||e.parent.type!=A.Area)){if("x"==this.channel){let t=nt(e);if(t&&t.type==v.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].left+this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}{let t=this.scale.offset;return[t,t+this.scale.rangeExtent]}}if("y"==this.channel){let t=nt(e);if(t&&t.type==v.Grid){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].bottom,i[s].bottom-this.scale.rangeExtent]}if("vertex"==e.type||"segment"==e.type){let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}{let t=this.scale.offset;return[t+this.scale.rangeExtent,t]}}if("width"==this.channel){let t=lt(e);if("grid"===t.type){let i=t.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent==t||e.parent.parent==t));return[i[s].left,i[s].right]}if("stack"===t.type&&"horizontal"==t.orientation)return[t.group.bounds.left,t.group.bounds.right];{let t=st(e,this.scene),i=Math.min(...t.map((t=>t.bounds.left)));return[i,i+this.scale.rangeExtent]}}if("height"==this.channel){let t=St(e);if(t&&t.layout&&["grid","stack"].indexOf(t.layout.type)>=0){let i=t.layout.cellBounds,s=e.parent.parent.children.findIndex((t=>e.parent===t||e.parent.parent===t));return[i[s].bottom,i[s].bottom-i[s].height]}{let t=st(e,this.scene),i=Math.max(...t.map((t=>t.refBounds.bottom)));return[i,i-this.scale.rangeExtent]}}if("radialDistance"==this.channel){let t=e.parent;return[t.x,t.x+this.scale.rangeExtent]}return this.scale.range}{let t,i=e.type==A.Area?e:e.parent,s=It(i),n=nt(i);t=n?s==b?n.horzCellAlignment===S.Left:n.vertCellAlignment===S.Bottom:s==b?i.baseline==S.Left:i.baseline==S.Bottom;let r=ot(i);if(r)switch(this.channel){case"x":return[r.left,r.left+this.scale.rangeExtent];case"width":return t?[r.left,r.left+this.scale.rangeExtent]:[r.right,r.right-this.scale.rangeExtent];case"y":return[r.bottom,r.bottom-this.scale.rangeExtent];case"height":return t?[r.bottom,r.bottom-this.scale.rangeExtent]:[r.top+this.scale.rangeExtent,r.top]}else if(n&&"stack"===n.type)switch(r=n.group.bounds,this.channel){case"x":return[r.left,r.left+this.scale.rangeExtent];case"width":return t?[r.left,r.left+this.scale.rangeExtent]:[r.right,r.right-this.scale.rangeExtent];case"y":return[r.bottom,r.bottom-this.scale.rangeExtent];case"height":return t?[r.bottom,r.bottom-this.scale.rangeExtent]:[r.top+this.scale.rangeExtent,r.top]}if(s==x)switch(this.channel){case"width":case"height":{let e=this._vertices,i=t?Math.max(...e.map((t=>t.y))):Math.min(...e.map((t=>t.y)));return t?[i,i-this.scale.rangeExtent]:[i+this.scale.rangeExtent,i]}case"x":case"y":{let t=st(i.firstVertex,this.scene),e=Math.min(...t.map((t=>t.x)));return[e,e+this.scale.rangeExtent]}}else if(s==b)switch(this.channel){case"x":case"y":{let t=st(i.firstVertex,this.scene),e=Math.max(...t.map((t=>t.y)));return[e,e-this.scale.rangeExtent]}case"height":case"width":{let e=st(i.firstVertex,this.scene),s=t?Math.min(...e.map((t=>t.x))):Math.max(...e.map((t=>t.x)));return t?[s,s+this.scale.rangeExtent]:[s-this.scale.rangeExtent,s]}}}}}function qt(t,e,i){return e.map((e=>[e,n.mean(i,(i=>t(e-i)))]))}function Jt(t){return e=>Math.abs(e/=t)<=1?.75*(1-e*e)/t:0}function Xt(t,e){if("field"in e){let i=e.field;if("value"in e)return t[i]==e.value;if("range"in e)return t[i]>=e.range[0]&&t[i]<=e.range[1];if("values"in e)return e.values.indexOf(t[i])>=0}else if("fields"in e){let i=e.fields[0],s=e.fields[1],n=t[i],r=t[s];switch(e.operator){case"==":return n==r;case">":return n>r;case">=":return n>=r;case"<":return n<r;case"<=":return n<=r}return!1}}class $t{constructor(t,e,i){if(this.url=e,this.id=A.DataTable+vt[A.DataTable]++,this.data=t,this.rawData=JSON.parse(JSON.stringify(t)),this._dateMap=new Map,this._fields=Object.keys(this.data[0]),this._newField=0,i)this._fieldTypes=i;else{this._fieldTypes={};for(let t of this._fields)this._fieldTypes[t]=Kt(this.data.map((e=>e[t]))),"year"==t.toLowerCase()&&this._fieldTypes[t]==I.Integer&&(this._fieldTypes[t]=I.Date)}this._validate(this.data,this._fieldTypes),this._fieldSummaries={};for(let t of this._fields)this._fieldSummaries[t]=Ht(this.data.map((e=>e[t])),this._fieldTypes[t]);this._fields.indexOf(l)<0&&this._addField(l,I.String,this.data.map(((t,e)=>"r"+e)))}get name(){return this.url?function(t){var e=t.indexOf("\\")>=0?t.lastIndexOf("\\"):t.lastIndexOf("/"),i=t.substring(e);0!==i.indexOf("\\")&&0!==i.indexOf("/")||(i=i.substring(1));return i}(this.url):this.id}set sourceDataTable(t){this._sourceDataTable=t}get sourceDataTable(){return this._sourceDataTable}getEncodableFields(t){switch(t){case"x":case"y":case"width":case"height":case"radius":case"fillColor":case"strokeColor":case"text":return this.numericFields.concat(this.nonNumericFields);case"area":case"strokeWidth":default:return this.numericFields}}toJSON(){let t={};return t.data=this.rawData,t.fieldTypes=this._fieldTypes,t.url=this.url,t.id=this.id,t.sourceDataTable=this._sourceDataTable,t.transform=this._transform,t.dateMap={},t}transformField(t,e,i){let s=this.data.map((i=>e(i[t]))),n=Kt(s),r=i||Date.now()+"_field"+this._newField++;return this._addField(r,n,s),r}setValueOrder(t,e){this._fieldSummaries[t].unique=e}_addField(t,e,i){this.data.forEach(((e,s)=>e[t]=i[s])),this._fieldTypes[t]=e,this._fields.push(t),this._fieldSummaries[t]=Ht(i,e)}getFieldType(t){return this._fieldTypes[t]}get fields(){return this._fields}getFieldSummary(t){return this._fieldSummaries[t]}getFieldValues(t){return this.data.map((e=>e[t]))}getUniqueFieldValues(t){return this._fieldSummaries[t].unique}getRowCount(){return this.data.length}hasField(t){return this._fields.indexOf(t)>=0}parseFieldAsDate(t,e){let i=n.timeParse(e);for(let e of this.data){let s=e[t];null==s||null==s?(s="",e[t]=new Date(1899,11,31).getTime()):e[t]=i(s).getTime(),this._dateMap.set(e[t],s)}this._fieldTypes[t]=I.Date,this._fieldSummaries[t]=Ht(this.data.map((e=>e[t])),I.Date)}getRawValue(t,e){return this.getFieldType(t)===I.Date?this._dateMap.get(e).toString():e}static get RowID(){return l}get nonNumericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!=I.Number&&this._fieldTypes[e]!=I.Integer&&e!=$t.RowID&&t.push(e);return t.sort(((t,e)=>this.getUniqueFieldValues(t).length-this.getUniqueFieldValues(e).length)),t}get numericFields(){let t=[];for(let e in this._fieldTypes)this._fieldTypes[e]!==I.Number&&this._fieldTypes[e]!==I.Integer||e==$t.RowID||t.push(e);return t}getFieldsByType(t){let e=[];for(let i in this._fieldTypes)this._fieldTypes[i]===t&&i!=$t.RowID&&e.push(i);return e}transform(t,e,i){let s=i||{};switch(t){case"kde":return function(t,e,i){let s=e[0],n=t.nonNumericFields,r={};for(let e of t.data){let t=n.map((t=>String(e[t]))).join("_");t in r||(r[t]=n.map((t=>e[t])),r[t].push([])),r[t][r[t].length-1].push(e[s])}let a="min"in i?i.min:t.getFieldSummary(s).min,o="max"in i?i.max:t.getFieldSummary(s).max,l=a,h=[];for(;l<o;)h.push(l),l+=i.interval;h.push(l);let c=[];for(let t in r){let e=r[t].pop(),a=qt(Jt(i.bandwidth),h,e);for(let e of a){let i={};r[t].forEach(((t,e)=>i[n[e]]=t)),i[s]=e[0],i[s+"_density"]=e[1],c.push(i)}}let d={};return n.forEach((e=>d[e]=t.getFieldType(e))),d[s]=I.Number,d[s+"_density"]=I.Number,new $t(c,t.url,d)}(this,e,s);case"bin":return function(t,e,i){let s=e[0],r=t.nonNumericFields,a={};for(let e of t.data){let t=r.map((t=>String(e[t]))).join("_");a.hasOwnProperty(t)||(a[t]=r.map((t=>e[t])),a[t].push([])),a[t][a[t].length-1].push(e[s])}let o=[];for(let t in a){let e=a[t].pop(),i=n.bin()(e);for(let e of i){let i={};a[t].forEach(((t,e)=>i[r[e]]=t)),i.x0=e.x0,i.x1=e.x1,i[s+"_count"]=e.length,o.push(i)}}let l={};r.forEach((e=>l[e]=t.getFieldType(e))),l.x0=I.Number,l.x1=I.Number,l[s+"_count"]=I.Number;let h=new $t(o,t.url,l);return h.sourceDataTable=t,h.transform={type:"bin",args:e},h}(this,e);case"sort":return function(t,e,i){t.data.sort(((t,i)=>function(t,e,i,s){for(let s of i){if(t[s]<e[s])return-1;if(t[s]>e[s])return 1}return 0}(t,i,e))),t.summarize()}(this,e);case"filter":return function(t,e){let i=[];for(let s of t.data){let t=!0;for(let i of e)if(!Xt(s,i)){t=!1;break}t&&i.push(s)}let s=new $t(i,t.url);return s.sourceDataTable=t,s.transform={type:"filter",args:e},s}(this,e)}}summarize(){for(let t of this._fields)this._fieldSummaries[t]=Ht(this.data.map((e=>e[t])),this._fieldTypes[t])}_validate(t,e){for(let i of t)for(let t in e){let s,n=e[t],r=i[t];if(null==i[t]||null==i[t])switch(n){case I.Boolean:s=!1;break;case I.Date:s=new Date(1899,11,31).getTime();break;case I.String:s="";break;default:s=0}else switch(n){case I.Boolean:s=r;break;case I.Date:s=Number.isInteger(r)?new Date(r,0).getTime():new Date(r+"").getTime(),this._dateMap.set(s,r);break;case I.String:s=r.toString();break;default:s=r}i[t]=s}}}function Ht(t,e){var i={};switch(e){case I.Boolean:i.trueCount=t.filter((t=>t)).length,i.falseCount=t.filter((t=>!t)).length;break;case I.Date:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.unique=[...new Set(t)];break;case I.String:i.unique=[...new Set(t)];break;default:i.min=n.min(t),i.max=n.max(t),i.extent=[i.min,i.max],i.mean=n.mean(t),i.median=n.median(t),i.unique=[...new Set(t)]}return i}var Zt={boolean:function(t){return"true"===t||"false"===t||!0===t||!1===t||"[object Boolean]"==toString.call(t)},integer:function(t){return Zt.number(t)&&(t=+t)==~~t},number:function(t){return!isNaN(+t)&&"[object Date]"!=toString.call(t)},date:function(t){let e=new Date(t);return null!=e&&!isNaN(e)},string:function(t){return!0}};function Kt(t){var e=Object.values(I);for(let i=0;i<t.length;i++){let s=t[i];if(null!=s){for(let t=0;t<e.length;t++)Zt[e[t]](s)||(e.splice(t,1),t-=1);if(1==e.length)return e[0]}}return e[0]}class Qt extends J{constructor(t){super(t),this.type=A.PointText,this.attrs.x=0,this.attrs.y=0,"fontSize"in this.styles||(this.styles.fontSize="12px"),"fontFamily"in this.styles||(this.styles.fontFamily="Arial, sans-serif"),"fontWeight"in this.styles||(this.styles.fontWeight="normal"),"fillColor"in this.styles||(this.styles.fillColor="black"),void 0!==t&&("x"in t&&(this.attrs.x=t.x),"y"in t&&(this.attrs.y=t.y),this.attrs.text="text"in t?t.text:"",this.attrs.anchor="anchor"in t?t.anchor:["center","middle"]),this._updateBounds()}copyPropertiesTo(t){t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this.attrs.x,t.y=this.attrs.y,t.text=this.text,t.anchor=[this.anchor[0],this.anchor[1]]}get bounds(){return this._bounds||this._updateBounds(),this._bounds}get refBounds(){return this.bounds}set text(t){this.attrs.text=t,this._updateBounds()}get text(){return this.attrs.text}_doTranslate(t,e){this.attrs.x+=t,this.attrs.y+=e,this._updateBounds()}_updateBounds(){let t,e,i=function(t,e,i){let s=wt.getContext();s.font=e;let n=s.measureText(t);return n.fontBoundingBoxAscent?{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}:n.actualBoundingBoxAscent?{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}:{width:n.width,height:i}}(this.attrs.text,[this.fontWeight,this.styles.fontSize,this.fontFamily].join(" "),parseFloat(this.fontSize)),s=i.width,n=i.height;switch(this.attrs.anchor[0]){case"left":t=this.attrs.x;break;case"right":t=this.attrs.x-s;break;case"center":t=this.attrs.x-s/2;break;default:t=this.attrs.x}switch(this.attrs.anchor[1]){case"top":e=this.attrs.y;break;case"bottom":e=this.attrs.y-n;break;case"middle":e=this.attrs.y-n/2}this._bounds=new a(t,e,s,n)}get center(){return{x:this.bounds.left+this.bounds.width/2,y:this.bounds.top+this.bounds.height/2}}get x(){return this.attrs.x}set x(t){this.attrs.x=t,this._updateBounds()}get y(){return this.attrs.y}set y(t){this.attrs.y=t,this._updateBounds()}get anchor(){return this.attrs.anchor}set anchor(t){this.attrs.anchor=t,this._updateBounds()}get horzAnchor(){return this.attrs.anchor[0]}get vertAnchor(){return this.attrs.anchor[1]}set horzAnchor(t){this.attrs.anchor[0]=t,this._updateBounds()}set vertAnchor(t){this.attrs.anchor[1]=t,this._updateBounds()}get fontSize(){return parseFloat(this.styles.fontSize)}set fontSize(t){this.styles.fontSize="number"==typeof t?t+"px":t,this._updateBounds()}get fontWeight(){return this.styles.fontWeight}set fontWeight(t){this.styles.fontWeight=t,this._updateBounds()}get fontFamily(){return this.styles.fontFamily}set fontFamily(t){this.styles.fontFamily=t,this._updateBounds()}get fillColor(){return this.styles.fillColor}set fillColor(t){this.styles.fillColor=t}}class te extends Mt{constructor(t){super(),this.type=A.Axis,this.id=this.type+vt[this.type]++,this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._textColor="textColor"in t?t.textColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._tickOffset="tickOffset"in t?t.tickOffset:0,this._tickSize="tickSize"in t?t.tickSize:5,this._tickAnchor=t.tickAnchor?t.tickAnchor:"middle",this._tickVisible=!("tickVisible"in t)||t.tickVisible,this._pathVisible=!("pathVisible"in t)||t.pathVisible,this._labelOffset="labelOffset"in t?t.labelOffset:15,this._labelFormat="labelFormat"in t?t.labelFormat:"",this._titleOffset="titleOffset"in t?t.titleOffset:40,"titleAnchor"in t?this._titleAnchor=t.titleAnchor:"x"==this.channel||"width"==this.channel?this._titleAnchor="top"==this._orientation?["center","bottom"]:["center","top"]:this._titleAnchor="left"==this._orientation?["right","middle"]:["left","middle"],this._rotateYTitle=!("rotateTitle"in t&&!t.rotateTitle),this._titlePosition=t.titlePosition,this._labelRotation="labelRotation"in t?t.labelRotation:0}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.field=this._field,t.channel=this._channel,"args"in t||(t.args={}),t.args.orientation=this._orientation,t.args.strokeColor=this._strokeColor,t.args.textColor=this._textColor,t.args.tickOffset=this._tickOffset,t.args.tickSize=this._tickSize,t.args.tickAnchor=this._tickAnchor,t.args.tickVisible=this._tickVisible,t.args.pathVisible=this._pathVisible,t.args.labelOffset=this._labelOffset,t.args.labelFormat=this._labelFormat,this._labelRotation&&(t.args.labelRotation=this._labelRotation),t.args.showTitle=this._showTitle,t.args.tickValues=this._tickValues,t.args.titleAnchor=this._titleAnchor,t.args.titleOffset=this._titleOffset,t.args.titlePosition=this._titlePosition,t.args.rotateTitle=this._rotateYTitle,t}get field(){return this._field}get channel(){return this._channel}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.reposition()}get pathX(){if("y"==this.channel||"height"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].x;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].x}}set pathX(t){"y"!=this.channel&&"height"!=this.channel||(this._posArg=t),this.reposition()}get pathPosition(){return"x"==this.channel||"width"==this.channel?this.pathY:this.pathX}set pathPosition(t){"x"==this.channel||"width"==this.channel?this.pathY=t:"y"!=this.channel&&"height"!=this.channel||(this.pathX=t)}get pathY(){if("x"==this.channel||"width"==this.channel){if(void 0!==this._position)return this._position;if(this._path)return this._path.vertices[0].y;if(this._rules&&this._rules.firstChild)return this._rules.firstChild.vertices[0].y}}set pathY(t){"x"!=this.channel&&"width"!=this.channel||(this._posArg=t),this.reposition()}get tickOffset(){return this._tickOffset}set tickOffset(t){this._tickOffset=t,this._positionTicks()}get titleOffset(){return this._titleOffset}set titleOffset(t){this._titleOffset=t}get tickSize(){return this._tickSize}set tickSize(t){this._tickSize=t,this._positionTicks()}set tickValues(t){this._tickValues=t,this._generateTicks(),this._positionTicks()}get tickValues(){return this._tickValues}set labelValues(t){this._labelValues=t,this._generateLabels(),this._positionLabels()}get labelValues(){return this._labelValues}get tickAnchor(){return this._tickAnchor}set tickAnchor(t){this._tickAnchor=t}get tickVisible(){return this._tickVisible}set tickVisible(t){this._tickVisible=t;for(let e of this._ticks.children)e.visibility=t?"visible":"hidden"}get pathVisible(){return this._pathVisible}set pathVisible(t){this._pathVisible=t;let e=[];this._path&&e.push(this._path),this._rules&&this._rules.children.forEach((t=>e.push(t)));for(let i of e)i.visibility=t?"visible":"hidden"}get labelOffset(){return this._labelOffset}set labelOffset(t){this._labelOffset=t,this._positionLabels()}get labelFormat(){return this._labelFormat}set labelFormat(t){this._labelFormat=t,this._generateLabels(),this._positionLabels()}get labelRotation(){return this._labelRotation}set labelRotation(t){if(this._labelRotation=t,this._labels&&this._labels.children){let e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(t)for(let t of this._labels.children)t._rotate=[this._labelRotation,t.x,t.y],t.anchor=["right",e[1]];else for(let t of this._labels.children)t._rotate=void 0}}get showTitle(){return this._showTitle}set showTitle(t){this._showTitle=t,this._title||(this._generateTitle(),this._positionTitle()),this._title.visibility=t?"visible":"hidden"}get titleAnchor(){return this._titleAnchor}set titleAnchor(t){this._titleAnchor=t}get titlePosition(){return this._titlePosition}set titlePosition(t){this._titlePosition=t}get rotateTitle(){return this._rotateYTitle}set rotateTitle(t){this._rotateYTitle=t}get title(){return this._titleText}set title(t){this._titleText=t}get includeZero(){return!!this.encoding&&this.encoding.scale.includeZero}set includeZero(t){this.encoding&&(this.encoding.scale.includeZero=t)}_generatePath(){}_generateTicks(){}_generateLabels(){}_generateTitle(){this._title=new Qt({text:this._titleText,fillColor:this._textColor,fontWeight:"bold"}),this._title.id=this.id+"-title",this.addChild(this._title)}_positionPath(){}_positionTicks(){}_positionLabels(){}_positionTitle(){}matches(t){}reposition(){this instanceof ee&&this._determineAxisFlip(),this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle(),"radialDistance"===this._channel&&this._rotate&&(this._rotate=[this._rotate[0],this._item.parent.x,this._item.parent.y]),this._updateBounds()}}class ee extends te{constructor(t,e,i){super(i),this.encoding=t,this._field=this.encoding.field,this._channel=this.encoding.channel,this._orientation="orientation"in i?i.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?i.pathY:i.pathX,this._position=this._posArg,this._titleText="title"in i?i.title:this.encoding.field,this._item=e,this._ticks=new Mt,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new Mt,this._labels.id=this.id+"labels",this.addChild(this._labels),"radialDistance"===this._channel&&"rotation"in i&&(this._rotate=[-i.rotation,this._item.parent.x,this._item.parent.y]),this._showTitle=!("showTitle"in i)||i.showTitle,this._determineAxisFlip(),this._generatePath(),this._positionPath(),this._showTitle&&this._generateTitle(),this._showTitle&&this._positionTitle()}autoUpdateTicks(){let t=this.encoding._inferTickValues();this.tickValues=t,this.labelValues=t}_updateBounds(){this._bounds=this._path.bounds,this._ticks.children.length>0&&(this._bounds=this._bounds.union(this._ticks.bounds)),this._labels.children.length>0&&(this._bounds=this._bounds.union(this._labels.bounds)),this._title&&(this._bounds=this._bounds.union(this._title.bounds))}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"time"===this.encoding.scale.type&&(t.args.isDate=!0),this._rotate&&(t.args.rotation=this._rotate[0]),"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,t}get ticks(){return this._ticks}get labels(){return this._labels}get path(){return this._path}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;this._path.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_generatePath(){this._path=new K({strokeColor:this._strokeColor}),this._pathVisible||(this._path.visibility="hidden"),this._path.type=A.Line,this._path.id=this.id+"path",this.addChild(this._path)}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._tickValues.length;t++){let e=new K({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=A.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this.encoding.datatable.getFieldType(this.encoding.field)){case I.Date:t=n.timeFormat(this._labelFormat);break;case I.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}for(let[e,i]of this._labelValues.entries()){let s=new Qt({text:t(i),fontSize:this._fontSize,fillColor:this._textColor});s.id=this.id+"label"+e,this._labels.addChild(s)}}_positionPath(){this._range=this.encoding.getScaleRange(this._item),void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg;let t=[];if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].x));t.push([Math.min(...e.concat(this._range)),this._position]),t.push([Math.max(...e.concat(this._range)),this._position])}else if("y"==this._channel||"height"==this._channel){let e=this._ticks.children.map((t=>t.vertices[0].y));t.push([this._position,Math.min(...e.concat(this._range))]),t.push([this._position,Math.max(...e.concat(this._range))])}this._path._setVertices(t),this._path._updateBounds(),this._showTitle&&this._title&&this._positionTitle(),this._updateBounds()}_isAlignedLeft(t){switch(t.type){case v.Stack:case v.Grid:return t.horzCellAlignment===S.Left;default:return!0}}_isAlignedBottom(t){switch(t.type){case v.Stack:case v.Grid:return t.vertCellAlignment===S.Bottom;default:return!0}}_determineAxisFlip(){if("x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){if("width"==this._channel){let t=St(this._item)?St(this._item).layout:nt(this._item);if(t)this._flip=!this._isAlignedLeft(t);else if("area"==this._item.type){let t=this._item.baseline==S.Left||this._item.baseline==S.Center||this._item.baseline==S.Middle||null==this._item.baseline;this._flip=!t}}}else if(("y"==this._channel||"height"==this._channel)&&"height"==this._channel){let t=St(this._item)?St(this._item).layout:nt(this._item);if(t)this._flip=!this._isAlignedBottom(t);else if("area"==this._item.type){let t=this._item.baseline==S.Bottom||this._item.baseline==S.Center||this._item.baseline==S.Middle||null==this._item.baseline;this._flip=!t}}}_positionLabels(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize,e="bottom"==this._orientation?["center","top"]:["center","bottom"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._range[1]-this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i]),s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]]);else for(let[i,s]of this._labels.children.entries())s.x=this._range[0]+this.encoding.scale.map(this._labelValues[i])-this.encoding.scale.range[0],s.y=this._position+t,s.anchor=e,this._labelRotation&&(s._rotate=[this._labelRotation,s.x,s.y],s.anchor=["right",e[1]])}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize,e="left"==this._orientation?["right","middle"]:["left","middle"];if(this._flip)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]+this.encoding.scale.map(this._labelValues[i]),s.anchor=e;else if(this.encoding.scale.isFlipped)for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[1]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[1],s.anchor=e;else for(let[i,s]of this._labels.children.entries())s.x=this._position+t,s.y=this._range[0]-this.encoding.scale.map(this._labelValues[i])+this.encoding.scale.range[0],s.anchor=e}this._labels._updateBounds(),this._updateBounds()}_computePosition(){let t;if("vertex"===this._item.type&&!this._item.parent.closed){let t=st(this._item,this._item.parent.getScene());if("x"===this._channel&&1==Nt(t.map((t=>t.bounds.middle))).length)return this._item.bounds.middle;if("y"===this._channel&&1==Nt(t.map((t=>t.bounds.center))).length)return this._item.bounds.center;if("radialDistance"===this._channel)return this._item.parent.y}if(this._item.type!==A.Area&&this._item.parent.type!==A.Area||(t=ot(this._item)),void 0===t){let e=St(this._item);void 0===e&&(e=Ct(this._item)),t=e.bounds}return"x"===this._channel||"width"===this._channel?"top"==this._orientation?t.top-this._tickSize:t.bottom+this._tickSize:"y"===this._channel||"height"===this._channel?"left"==this._orientation?t.left-this._tickSize:t.right+this._tickSize:"radialDistance"===this._channel?this._item.parent.y:void 0}_positionTicks(){if(void 0===this._posArg?this._position=this._computePosition():this._position=this._posArg,this._range=this.encoding.getScaleRange(this._item),"x"==this._channel||"radialDistance"==this._channel||"width"==this._channel){let t="bottom"==this._orientation?this._tickSize:-this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[1]-this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e]),this._position+t]]),i._updateBounds();else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position],[this._range[0]+this.encoding.scale.map(this._tickValues[e])-this.encoding.scale.range[0],this._position+t]]),i._updateBounds()}else if("y"==this._channel||"height"==this._channel){let t="left"==this._orientation?-this._tickSize:this._tickSize;if(this._flip)for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[1]+this.encoding.scale.map(this._tickValues[e])],[this._position,this._range[1]+this.encoding.scale.map(this._tickValues[e])]]),i._updateBounds();else if(this.encoding.scale.isFlipped)for(let[e,i]of this._ticks.children.entries()){let s=this._range[1]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[1];i._setVertices([[this._position+t,s],[this._position,s]]),i._updateBounds()}else for(let[e,i]of this._ticks.children.entries())i._setVertices([[this._position+t,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]],[this._position,this._range[0]-this.encoding.scale.map(this._tickValues[e])+this.encoding.scale.range[0]]]),i._updateBounds()}this._positionPath(),this._ticks._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._path.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel||"width"==this._channel?(this._title.x=t.x,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){let e=ht(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(ht(t.anyItem).split("_")[0]===e)return!0}return!1}get isFlipped(){return!!this._flip||!!this.encoding.scale.isFlipped}}class ie extends te{constructor(t,e,i,s,n){super(n),this._channel=i,this._orientation="orientation"in n?n.orientation:"x"===this._channel||"width"==this._channel?"bottom":"left",this._posArg="x"==this._channel||"width"==this._channel?n.pathY:n.pathX,this._padding=[A.Line,A.Path].indexOf(t[0].type)>=0?10:0,this._item=t[0],this._items=t,this._mlayout=e,this._field=s,this._titleText="title"in n?n.title:this._field,this._showTitle="showTitle"in n&&n.showTitle,this._ticks=new Mt,this._ticks.id=this.id+"ticks",this.addChild(this._ticks),this._labels=new Mt,this._labels.id=this.id+"labels",this.addChild(this._labels),this._rules=new Mt,this._rules.id=this.id+"paths",this.addChild(this._rules),this._generatePath(),this._generateTicks(),this._generateLabels(),this._showTitle&&this._generateTitle(),this._positionPath(),this._positionTicks(),this._positionLabels(),this._showTitle&&this._positionTitle()}toJSON(){let t=super.toJSON();return t.args.item=this._item.id,"x"==this._channel||"width"==this._channel?t.args.pathY=this._posArg:t.args.pathX=this._posArg,this.classId&&(t.classId=this.classId),t}set strokeColor(t){this._strokeColor=t;for(let e of this._ticks.children)e.strokeColor=t;for(let e of this._rules.children)e.strokeColor=t}get strokeColor(){return this._strokeColor}set textColor(t){this._textColor=t;for(let e of this._labels.children)e.fillColor=t;this._title&&(this._title.fillColor=t)}get textColor(){return this._textColor}_updateBounds(){this._bounds=this._rules.bounds.clone(),this._bounds=this._bounds.union(this._ticks.bounds),this._bounds=this._bounds.union(this._labels.bounds),this._showTitle&&(this._bounds=this._bounds.union(this._title.bounds))}_generatePath(){if(this._rules.removeAll(),this._mlayout.type==v.Grid){let t="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;for(let e=0;e<t;e++){let t=new K({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=A.Line,t.id=this.id+"rule"+e,this._rules.addChild(t)}}else if(this._mlayout.type===v.Stack){let t=new K({strokeColor:this._strokeColor});this._pathVisible||(t.visibility="hidden"),t.type=A.Line,t.id=this.id+"rule",this._rules.addChild(t)}}_generateTicks(){this._ticks.removeAll();for(let t=0;t<this._mlayout.group.children.length;t++){let e=new K({strokeColor:this._strokeColor});this._tickVisible||(e.visibility="hidden"),e.type=A.Line,e.id=this.id+"tick"+t,this._ticks.addChild(e)}}_generateLabels(){let t;switch(this._labels.removeAll(),this._item.dataScope.getFieldType(this._field)){case I.Date:t=n.timeFormat(this._labelFormat);break;case I.String:t=function(t){return t};break;default:t=n.format(this._labelFormat)}let e=this._mlayout.cellBounds;for(let i=0;i<e.length&&!(i>=this._mlayout.group.children.length);i++){let e=this._mlayout.group.children[i],s=new Qt({fillColor:this._textColor,fontSize:this._fontSize,text:t(e.dataScope.getFieldValue(this._field))});s.id=this.id+"label"+i,this._labels.addChild(s)}}_positionPath(){if(this._mlayout.type==v.Grid){let t=this._mlayout.cellBounds,e="x"==this._channel?this._mlayout.numRows:this._mlayout.numCols;if("x"==this._channel){let i=t[0].left,s=this._mlayout.numCols,n="bottom"===this._orientation?this._padding:-this._padding;for(let r=0;r<e;r++)this._rules.children[r]._setVertices([[i,this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:t[r*s][this._orientation]+n],[i+t[0].width*s+this._mlayout.colGap*(s-1),this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:t[r*s][this._orientation]+n]])}else{let i=t[0].top,s=this._mlayout.numRows,n="left"===this._orientation?this._padding:-this._padding;for(let r=0;r<e;r++)this._rules.children[r]._setVertices([[this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation]-n,i],[this._posArg?t[r*s][this._orientation]+this._posArg-t[0][this._orientation]:this._mlayout.group.bounds[this._orientation]-n,i+t[0].height*s+this._mlayout.rowGap*(s-1)]])}}else if(this._mlayout.type===v.Stack){let t=this._mlayout.group.bounds;"x"==this._channel?this._rules.children[0]._setVertices([[t.left,this._posArg?this._posArg:t[this._orientation]],[t.right,this._posArg?this._posArg:t[this._orientation]]]):this._rules.children[0]._setVertices([[this._posArg?this._posArg:t[this._orientation],t.top],[this._posArg?this._posArg:t[this._orientation],t.bottom]])}this._rules.children.forEach((t=>t._updateBounds())),this._rules._updateBounds(),this._updateBounds()}_positionTicks(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?1:-1,i="bottom"===this._orientation?this._padding:-this._padding;for(let[s,n]of this._ticks.children.entries()){let r=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:t[s][this._orientation]+this._tickOffset*e+i;n._setVertices([[t[s].x,r],[t[s].x,r+e*this._tickSize]]),n._updateBounds()}}else if("y"==this._channel){let e="left"==this._orientation?-1:1,i="left"===this._orientation?this._padding:-this._padding;for(let[s,n]of this._ticks.children.entries()){let r=this._posArg?t[s][this._orientation]+this._posArg-t[0][this._orientation]+this._tickOffset*e:this._mlayout.group.bounds[this._orientation]+this._tickOffset*e-i,a="middle"==this._tickAnchor?t[s].y:t[s][this._tickAnchor];n._setVertices([[r,a],[r+e*this._tickSize,a]]),n._updateBounds()}}this._ticks._updateBounds(),this._updateBounds()}_positionLabels(){let t=this._mlayout.cellBounds;if("x"==this._channel){let e="bottom"==this._orientation?["center","top"]:["center","bottom"],i="bottom"==this._orientation?this._labelOffset:-this._labelOffset,s="bottom"===this._orientation?this._padding:-this._padding;for(let[n,r]of this._labels.children.entries())r.x=t[n].x,r.y=this._posArg?t[n][this._orientation]+this._posArg-t[0][this._orientation]+i:t[n][this._orientation]+i+s,r.anchor=e,this._labelRotation&&(r._rotate=[this._labelRotation,r.x,r.y],r.anchor=["right",e[1]])}else if("y"==this._channel){let e="left"==this._orientation?["right","middle"]:["left","middle"],i="left"==this._orientation?-this._labelOffset:this._labelOffset,s="left"===this._orientation?this._padding:-this._padding;for(let[n,r]of this._labels.children.entries())r.x=this._posArg?t[n][this._orientation]+this._posArg-t[0][this._orientation]+i:this._mlayout.group.bounds[this._orientation]+i-s,r.y="middle"==this._tickAnchor?t[n].y:t[n][this._tickAnchor],r.anchor=e,this._labelRotation&&(r._rotate=[this._labelRotation,r.x,r.y])}this._labels._updateBounds(),this._updateBounds()}_positionTitle(){let t=this._rules.bounds;this._title.achor=this._titleAnchor,this._titlePosition?(this._title.x=this._titlePosition[0],this._title.y=this._titlePosition[1],"y"!=this._channel&&"height"!=this._channel||this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])):"x"==this._channel?(this._title.x=t.x,this._titleOffset=this._labels.bounds.height+this._labelOffset+15,this._title.y="top"==this._orientation?t.top-this._titleOffset:t.bottom+this._titleOffset):(this._titleOffset=this._labels.bounds.width+this._labelOffset+15,this._title.x="left"==this._orientation?t.left-this._titleOffset:t.right+this._titleOffset,this._title.y=t.y,this._rotateYTitle&&(this._title._rotate="left"==this._orientation?[-90,this._title.bounds.x,this._title.bounds.y]:[90,this._title.bounds.x,this._title.bounds.y])),this._title._updateBounds(),this._updateBounds()}matches(t){return ct(this._item,t)}}class se extends Mt{constructor(t,e){super(),this.type=A.Legend,this.id=this.type+vt[this.type]++,this.encoding=t,this._textColor="textColor"in e?e.textColor:"#555",this._strokeColor="strokeColor"in e?e.strokeColor:"#555",this._fontSize="fontSize"in e?e.fontSize:"12px",this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._showTitle=!("showTitle"in e)||e.showTitle,this._orientation="orientation"in e?e.orientation:b,"numCols"in e||"numRows"in e?(this._numCols=e.numCols,this._numRows=e.numRows):this._orientation===b?this._numCols=1:this._numRows=1,this._initialize()}toJSON(){let t=super.toJSON();return"args"in t||(t.args={}),t.args.textColor=this._textColor,t.channel=this.encoding.channel,t.field=this.encoding.field,t.args.strokeColor=this._strokeColor,t.args.x=this._x,t.args.y=this._y,t.args.orientation=this._orientation,t}get field(){return this.encoding.field}get channel(){return this.encoding.channel}get fieldType(){return this.encoding.datatable.getFieldType(this.field)}_initialize(){let t=this.encoding.scene,e=this.encoding.field;switch(this.encoding.datatable.getFieldType(e)){case I.String:this._createCategoricalColorLegend(t,e);break;case I.Date:case I.Number:case I.Integer:this._createNumericalColorLegend(t,e)}this._updateBounds()}_createNumericalColorLegend(t,e){let i,s,n;if(this._orientation==b?(i=15,s=300):(i=300,s=15),this._showTitle){let s=t.mark("text",{fillColor:this._textColor,text:e,x:this._x+i/2,y:this._y,anchor:["center","middle"]});this.addChild(s),n=20}else n=0;let r,a=t.mark("rect",{top:this._y+n,left:this._x,width:i,height:s,strokeWidth:0,opacity:this.encoding.anyItem.opacity}),o=[Math.min(...this.encoding.data),Math.max(...this.encoding.data)],l=this.encoding.scale.mapping,h=[],c=[];if(l){let e=Object.keys(l).map((t=>parseFloat(t))).sort(((t,e)=>t-e));this._orientation==b?(r=new q({x1:0,y1:100,x2:0,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,l[e],1);let d=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-a*s+n,y2:this._y+s-a*s+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+i+5+5,y:this._y+s-a*s+n,anchor:["left","middle"]});h.push(u)}))):(r=new q({x1:0,y1:0,x2:100,y2:0}),e.forEach((e=>{let a=(e-o[0])/(o[1]-o[0]);r.addStop(100*a,l[e],1);let d=t.mark("line",{x1:this._x+a*i,x2:this._x+a*i,y1:this._y+20-5+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(d);let u=t.mark("text",{fillColor:this._textColor,text:e.toFixed(0),x:this._x+a*i,y:this._y+s+5+n,anchor:["center","top"]});h.push(u)})))}else{let a=this.encoding.scale.domain,o=this.encoding.datatable,l=o.getFieldType(e),d=[],u=l===I.Date?o.getUniqueFieldValues(e):Nt(this.encoding.data);if(u.length<=10)d=u,d.sort(((t,e)=>t-e));else if(l===I.Date){u.sort(((t,e)=>t-e));for(let t=0;t<u.length;t+=Math.ceil(u.length/10))d.push(u[t])}else{let t=(a[1]-a[0])/9;for(let e=0;e<10;e++)d.push(a[0]+e*t)}let f=0,p=(d[d.length-1]-d[0])/d.length;for(;p<1;)p*=10,f++;d=d.map((t=>t.toFixed(f))),this._orientation==b?(r=new q({x1:0,y1:100,x2:0,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+i,x2:this._x+i+5,y1:this._y+s-u*s+n,y2:this._y+s-u*s+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:l===I.Date?o.getRawValue(e,d):d,x:this._x+i+5+5,y:this._y+s-u*s+n,anchor:["left","middle"]});h.push(p)}))):(r=new q({x1:0,y1:0,x2:100,y2:0}),d.forEach((d=>{let u=(d-a[0])/(a[1]-a[0]);r.addStop(100*u,this.encoding.scale.map(d),1);let f=t.mark("line",{x1:this._x+u*i,x2:this._x+u*i,y1:this._y+s+n,y2:this._y+s+5+n,strokeColor:this._strokeColor});c.push(f);let p=t.mark("text",{fillColor:this._textColor,text:l===I.Date?o.getRawValue(e,d):d,x:this._x+u*i,y:this._y+s+5+n,anchor:["center","top"]});h.push(p)})))}a.styles.fillColor=r,this.addChild(a);for(let t of h)this.addChild(t);for(let t of c)this.addChild(t)}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.setTextColor(this)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.removeAll(),this._initialize()}setTextColor(t){if(t.children&&0!==t.children.length)for(let e of t.children)e.type===A.PointText?e.fillColor=this._textColor:e.children&&e.children.length>0&&this.setTextColor(e)}_createCategoricalColorLegend(t,e){let i=this.encoding.scale,s=new $t(i.domain.map((t=>({category:t,value:i.map(t)})))),n=s.getUniqueFieldValues("category").sort(((t,e)=>e.length-t.length))[0],r=this.encoding.anyItem,a=mt(r)&&r.closed?r.strokeWidth:0;if(this._orientation===b){let o=0;this._showTitle&&(this.addChild(new Qt({fillColor:this._textColor,fontSize:this._fontSize,text:e,x:this._x,y:this._y,anchor:["left","top"]})),o=parseFloat(this._fontSize)+5);let l=t.mark("rect",{top:this._y+2+o,left:this._x,width:10,height:10,strokeWidth:a,strokeColor:r.strokeColor,opacity:r.opacity}),h=t.mark("text",{text:n,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+o,anchor:["left","top"]}),c=t.glyph(l,h),d=t.repeat(c,s);t.encode(h,{channel:"text",field:"category",_remember:!1}),t.encode(l,{channel:"fillColor",field:"category",_remember:!1,scale:i}),d.layout=cd("grid",{numCols:this._numCols,numRows:this._numRows}),this.addChild(d)}else{let e=t.mark("rect",{top:this._y,left:this._x,width:10,height:10,strokeWidth:a,strokeColor:r.strokeColor,opacity:this.encoding.anyItem.opacity}),o=t.mark("text",{text:n,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+15,y:this._y,anchor:["left","top"]}),l=t.glyph(e,o),h=t.repeat(l,s);t.encode(o,{channel:"text",field:"category",_remember:!1}),t.encode(e,{channel:"fillColor",field:"category",_remember:!1,scale:i}),h.layout=cd("grid",{numCols:this._numCols,numRows:this._numRows,colGap:15}),this.addChild(h)}}pathHitTest(t,e){let i=pt(this);for(let s=i.length-1;s>=0;s--){let n=i[s];if(mt(n)&&n.contains(t,e))return n}return null}matches(t){let e=ht(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(ht(t.anyItem).split("_")[0]===e)return!0}return!1}_doTranslate(t,e){super._doTranslate(t,e),this._x+=t,this._y+=e}}class ne extends Mt{constructor(t){if(super(),this.type=A.Glyph,this._id=this.type+vt[this.type]++,t)for(let e of t)this.addChild(e)}duplicate(){let t=this.getScene().glyph();for(let e of this.children)t.addChild(e.duplicate());return t.classId=this.classId,this._dataScope&&(t.dataScope=this._dataScope.clone()),t}}class re extends K{constructor(t){super(t),this.type=A.Area,this.closed=!0,this._orientation="orientation"in t?t.orientation:void 0,this._baseline="baseline"in t?t.baseline:void 0,t&&"vertices"in t&&this.segments.push(new Z(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get baseline(){return this._baseline}set baseline(t){this._baseline=t}get orientation(){return this._orientation}set orientation(t){this._orientation=t}get firstVertexPair(){return[this.vertices[0],this.vertices[this.vertices.length-1]]}get width(){return this.vertices[this.vertices.length/2].x-this.vertices[0].x}get height(){return this.vertices[this.vertices.length/2].y-this.vertices[0].y}get left(){return this.vertices[0].x}get top(){return this.vertices[0].y}copyPropertiesTo(t){super.copyPropertiesTo(t),t._baseline=this._baseline,t._orientation=this._orientation}resizeArea(t,e){let i=this.vertices[this.vertices.length/2].x,s=this.vertices[this.vertices.length/2].y,n=this.width,r=this.height;for(let a of this.vertices)a.x=i+t/n*(a.x-i),a.y=s+e/r*(a.y-s);this._updateBounds()}getSVGPathData(){return super.getSVGPathData()+" z"}}class ae extends K{constructor(t){super(t),this.type=A.Ring,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t}get outerRadius(){return this._outerRadius}set outerRadius(t){this._outerRadius=t,this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new $(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}get thickness(){return this._outerRadius-this._innerRadius}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius}getSVGPathData(){return["M "+this._x+" "+this._y,"m 0, -"+this._outerRadius,"a "+this._outerRadius+","+this._outerRadius+", 0, 1, 0, 1, 0","Z","m 0 "+(this._outerRadius-this._innerRadius),"a "+this._innerRadius+", "+this._innerRadius+", 0, 1, 1, -1, 0","Z"].join(" ")}}class oe extends K{constructor(t){super(t),this.type=A.Polygon,this.closed=!0,"x"in t&&(this._x=t.x),"y"in t&&(this._y=t.y),"radius"in t&&(this._radius=t.radius)}get radius(){return this._radius}get x(){return this._x}get y(){return this._y}get center(){return new $(this._x,this._y)}set x(t){this._x=t,this._updateBounds()}set y(t){this._y=t,this._updateBounds()}set radius(t){this._radius=t,this._updateBounds()}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._radius=this._radius}_doTranslate(t,e){this._x+=t,this._y+=e,super._doTranslate(t,e)}}class le{constructor(t,e){this.direction=e,this.items=t,this.type=E,this._orientation=[S.Top,S.Middle,S.Bottom].indexOf(e)>=0?b:x,this._itemIds=this.items.map((t=>t.classId)).sort().join("_"),this.id=this.type+"_"+this._itemIds+"_"+this._orientation}get orientation(){return this._orientation}apply(){let t,e=this.direction;this.direction==S.Top||this.direction==S.Left?t=Math.min(...this.items.map((t=>t.bounds[e]))):this.direction==S.Bottom||this.direction==S.Right?t=Math.max(...this.items.map((t=>t.bounds[e]))):this.direction!=S.Center&&this.direction!=S.Middle||(t=n.mean(this.items.map((t=>t.bounds[e]))));let i=this.items.map((i=>t-i.bounds[e])),s=e==S.Top||e==S.Middle||e==S.Bottom?"y":"x";this.items.forEach(((t,e)=>{if(t.parent&&t.parent.layout&&t.parent.layout.type==v.Stack){let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t.parent._doTranslate(n,r)}else{let n="x"==s?i[e]:0,r="y"==s?i[e]:0;t._doTranslate(n,r)}}));let r={};this.items.forEach((t=>r[t.classId]=t)),Object.values(r).forEach((t=>t.getScene()._updateAncestorBounds(t)))}toJSON(){let t={};return t.items=this.items.map((t=>t.id)),t.direction=this.direction,t.type=this.type,t.id=this.id,t}}class he{constructor(t,e,i,s,n,r,a){this.item=t,this.baseItem=e,this.scene=i,this.channel=s,this.itemAnchor=n,this.baseAnchor=r,this.offset=a,this.type=T,this.id=this.type+"_"+this.item.classId+"_"+this.baseItem.classId+"_"+s}apply(){let t=st(this.item,this.scene),e=st(this.baseItem,this.scene),i=this.itemAnchor,s=this.baseAnchor,n=this.item.type==A.PointText;if("radialDistance"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];a.type==A.Arc||a.type==A.Ring?r="top"==s?a.outerRadius+this.offset:"bottom"==s?a.innerRadius+this.offset:(a.outerRadius+a.innerRadius)/2+this.offset:a.type==A.Circle&&(r="top"==s?a.radius+this.offset:"bottom"==s?this.offset:a.radius/2+this.offset),o._doTranslate(a.x-o.x,a.y-r-o.bounds[i]),o._rotate?o._rotate=[o._rotate[0],a.x,a.y]:o._rotate=[0,a.x,a.y]}else if("angle"==this.channel)for(let n=0;n<t.length;n++){let r,a=e[n],o=t[n];r=a.type==A.Arc?"left"==s?a.endAngle+this.offset:"center"==s?a.startAngle+a.angle/2+this.offset:a.startAngle+this.offset:90,o._rotate?o._rotate[0]=90-r:(o._doTranslate(a.x-o.bounds[i],a.y-t[n].y),o._rotate=[90-r,e[n].x,e[n].y])}else{let r;if(this.baseItem.type==A.Link)switch(s){case"left":case"top":r=0;break;case"center":case"middle":r=.5;break;case"right":case"bottom":r=1}for(let a=0;a<t.length;a++){let o=this.baseItem.type==A.Link?e[a].getPointAt(r)[this.channel]:e[a].bounds[s]+this.offset;n?(t[a].anchor["x"==this.channel?0:1]=this.itemAnchor,t[a][this.channel]=o):"x"==this.channel?t[a]._doTranslate(o-t[a].bounds[i],0):t[a]._doTranslate(0,o-t[a].bounds[i])}}this.item.getScene()._updateAncestorBounds(this.item),this.baseItem.getScene()._updateAncestorBounds(this.baseItem)}toJSON(){let t={};return t.item=this.item.id,t.baseItem=this.baseItem.id,t.channel=this.channel,t.itemAnchor=this.itemAnchor,t.baseAnchor=this.baseAnchor,t.offset=this.offset,t.type="affixation",t.id=this.id,t}}class ce extends Mt{constructor(t,e,i){super(),this.type=A.Gridlines,this.id=this.type+vt[this.type]++,this.encoding=t,this.channel=this.encoding.channel,this._item=e,this._strokeColor="strokeColor"in i?i.strokeColor:"#ddd",this._strokeWidth="strokeWidth"in i?i.strokeWidth:1,"radialDistance"==this.channel&&"angle"in i&&(this._rotate=[-i.angle,this.encoding.x,this.encoding.y])}toJSON(){let t={args:{}};return t.type=this.type,t.id=this.id,t.args.item=this._item.id,t.args.strokeColor=this._strokeColor,t.args.strokeWidth=this._strokeWidth,t.args.values=this._values,"time"===this.encoding.scale.type&&(t.args.isDate=!0),t.channel=this.encoding.channel,t.field=this.encoding.field,this._rotate&&(t.args.angle=this._rotate[0]),t}get values(){return this._values}set values(t){this._values=t,this.updateLines(),this.updateLinePositions()}get strokeColor(){return this._strokeColor}set strokeColor(t){this._strokeColor=t;for(let e of this.children)e.strokeColor=t}get strokeWidth(){return this._strokeWidth}set strokeWidth(t){this._strokeWidth=t;for(let e of this.children)e.strokeWidth=t}matches(t){let e=ht(t).split("_")[0],i=this.encoding.scale.encodings;for(let t of i){if(ht(t.anyItem).split("_")[0]===e)return!0}return!1}updateLinePositions(){let t=St(this._item)?St(this._item):Ct(this._item);if("x"==this.channel||"width"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);for(let[t,s]of this.children.entries()){let n=i[0]+this.encoding.scale.map(this._values[t])-this.encoding.scale.range[0];s._setVertices([[n,e.top],[n,e.bottom]])}}else if("y"==this.channel||"height"==this.channel){let e=t.bounds,i=this.encoding.getScaleRange(this._item);if(this.encoding.flip)for(let[t,s]of this.children.entries()){let n=i[1]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}else for(let[t,s]of this.children.entries()){let n=i[0]-this.encoding.scale.map(this._values[t])+this.encoding.scale.range[0];s._setVertices([[e.left,n],[e.right,n]])}}else if("radialDistance"==this.channel)for(let[t,e]of this.children.entries())e.x=this._item.parent.x,e.y=this._item.parent.y,e.radius=this.encoding.scale.map(this._values[t]);for(let t of this.children)t._updateBounds();this._updateBounds()}updateLines(){if(this.children=[],"x"==this.channel||"y"==this.channel||"width"==this.channel||"height"==this.channel)for(let t=0;t<this._values.length;t++){let e=new K({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=A.Line,e.id=this.id+"line"+t,this.addChild(e)}else if("radialDistance"==this.channel)for(let t=0;t<this._values.length;t++){let e=new zt({strokeColor:this._strokeColor,fillColor:"none",strokeWidth:this._strokeWidth});e.type=A.Circle,e.id=this.id+"line"+t,this.addChild(e)}}}class de extends Mt{constructor(){super(),this.type=A.Collection,this._id=this.type+vt[this.type]++,this.classId=this.id,this._childrenOrder=void 0}get childrenOrder(){return this._childrenOrder?this._childrenOrder:{field:"atlas_rowId",direction:"asc"}}set childrenOrder(t){if(!("field"in t)&&!("direction"in t))return;let e,i=t.field;if(this.dataScope.dataTable.hasField(i)){if(this._childrenOrder=t,i===l)e=(t,e)=>parseInt(t.dataScope.getFieldValue(i).substring(1))-parseInt(e.dataScope.getFieldValue(i).substring(1));else{switch(this.children[0].dataScope.getFieldType(i)){case I.Date:break;case I.Number:case I.Integer:e=(t,e)=>t.dataScope.aggregateNumericalField(i)-e.dataScope.aggregateNumericalField(i);break;case I.String:e=t.ranking?(e,s)=>t.ranking.indexOf(e.dataScope.getFieldValue(i))-t.ranking.indexOf(s.dataScope.getFieldValue(i)):(t,e)=>t.dataScope.getFieldValue(i)<e.dataScope.getFieldValue(i)?-1:1}}this.children.sort(e),"desc"==t.direction&&this.children.reverse(),this.layout&&this.layout.run()}else console.warn("Cannot order collection children by an non-existent field",t.field)}duplicate(){let t=this.getScene().collection();for(let e=0;e<this.children.length;e++){let i=this.children[e];t.addChild(i.duplicate())}if(t.classId=this.classId,this.parent.addChild(t),this._layout){let e=this._layout.clone();t.layout=e}return t}contains(t,e){if([A.Arc,A.Pie,A.Polygon,A.Area].indexOf(this.firstChild.type)>=0){let i=this.getSVGPathData();if(""!==i){let s=wt.getContext(),n=new Path2D(i);return s.lineWidth=Math.max(this.strokeWidth,2.5),s.stroke(n),s.isPointInPath(n,t,e)}}return this._bounds||this._updateBounds(),this._bounds.contains(t,e)}getSVGPathData(){let t="";for(let e of this.children)if(e.getSVGPathData)t+=e.getSVGPathData();else if(e.bounds){let i=e.bounds;t+=["M",i.left,i.top].join(" "),t+=["L",i.right,i.top].join(" "),t+=["L",i.right,i.bottom].join(" "),t+=["L",i.left,i.bottom,"Z"].join(" ")}return t}}class ue extends K{constructor(t){super(t),this._type=A.Arc,this.closed=!0,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._innerRadius="innerRadius"in t?t.innerRadius:100,this._outerRadius="outerRadius"in t?t.outerRadius:200,this._startAngle="startAngle"in t?t.startAngle:0,this._endAngle="endAngle"in t?t.endAngle:90,this._sr=At(this._startAngle),this._er=At(this._endAngle);let e=this._x+this._innerRadius*Math.cos(this._sr),i=this._y-this._innerRadius*Math.sin(this._sr),s=this._x+this._innerRadius*Math.cos(this._er),n=this._y-this._innerRadius*Math.sin(this._er),r=this._x+this._outerRadius*Math.cos(this._sr),a=this._y-this._outerRadius*Math.sin(this._sr),o=this._x+this._outerRadius*Math.cos(this._er),l=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[e,i],[r,a],[o,l],[s,n]])}get type(){return 0===this._innerRadius?A.Pie:A.Arc}set type(t){this._type=t}get innerRadius(){return this._innerRadius}set innerRadius(t){this._innerRadius=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get outerRadius(){return this._outerRadius}get thickness(){return this._outerRadius-this._innerRadius}set outerRadius(t){this._outerRadius=t,this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this._updateBounds()}get x(){return this._x}get y(){return this._y}get center(){return new $(this._x,this._y)}set x(t){this._x=t,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this._updateBounds()}set y(t){this._y=t,this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}get startAngle(){return this._startAngle}get endAngle(){return this._endAngle}get angle(){return this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle}sweepOver(t){let e=this.startAngle,i=this.endAngle;i<e&&(i+=360);let s=t.startAngle,n=t.endAngle;return n<s&&(n+=360),s>=e&&s<=i&&n>=e&&n<=i}_doTranslate(t,e){this._x+=t,this._y+=e,this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er),this._updateBounds()}_updateBounds(){this._bounds=new a(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}copyPropertiesTo(t){super.copyPropertiesTo(t),t._x=this._x,t._y=this._y,t._innerRadius=this._innerRadius,t._outerRadius=this._outerRadius,t._startAngle=this._startAngle,t._endAngle=this._endAngle,t._sr=this._sr,t._er=this._er}getSVGPathData(){let t=this._endAngle<this._startAngle?this._endAngle+360-this._startAngle:this._endAngle-this._startAngle,e=t>180?1:0;return["M "+this.vertices[0].x+", "+this.vertices[0].y,"L "+this.vertices[1].x+", "+this.vertices[1].y,"A "+[this._outerRadius,this._outerRadius,t,e,0,this.vertices[2].x,this.vertices[2].y].join(" "),"L "+this.vertices[3].x+", "+this.vertices[3].y,"A "+[this._innerRadius,this._innerRadius,t,e,1,this.vertices[0].x,this.vertices[0].y].join(" ")].join(" ")}adjustAngle(t,e){this._startAngle=t,this._endAngle=e,this._sr=At(this._startAngle),this._er=At(this._endAngle),this.vertices[0].x=this._x+this._innerRadius*Math.cos(this._sr),this.vertices[0].y=this._y-this._innerRadius*Math.sin(this._sr),this.vertices[1].x=this._x+this._outerRadius*Math.cos(this._sr),this.vertices[1].y=this._y-this._outerRadius*Math.sin(this._sr),this.vertices[2].x=this._x+this._outerRadius*Math.cos(this._er),this.vertices[2].y=this._y-this._outerRadius*Math.sin(this._er),this.vertices[3].x=this._x+this._innerRadius*Math.cos(this._er),this.vertices[3].y=this._y-this._innerRadius*Math.sin(this._er)}}class fe extends J{constructor(t){super(t),this.type=A.Image,this._src=t.src,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._width="width"in t?t.width:100,this._height="height"in t?t.height:100}toJSON(){let t=super.toJSON();return t.src=this._src,t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t}get src(){return this._src}set src(t){this._src=t}get width(){return this._width}set width(t){this._width=t,this._updateBounds()}get height(){return this._height}set height(t){this._height=t,this._updateBounds()}get x(){return this._x}set x(t){this._x=t,this._updateBounds()}get y(){return this._y}set y(t){this._y=t,this._updateBounds()}get bounds(){return this._bounds||this._updateBounds(),this._bounds}_updateBounds(){this._bounds=new a(this._x,this._y,this._width,this._height)}copyPropertiesTo(t){t.attrs=Object.assign({},this.attrs),t.styles=Object.assign({},this.styles),this._dataScope&&(t._dataScope=this._dataScope.clone()),t.x=this._x,t.y=this._y,t.width=this._width,t.height=this._height,t.src=this._src}_doTranslate(t,e){this._x+=t,this._y+=e,this._updateBounds()}}class pe extends K{constructor(t){super(t),this.type=A.Link,this.mode="mode"in t?t.mode:"linear",this.source=void 0,this.target=void 0,this.directed="directed"in t&&t.directed,this.sourceAnchor="sourceAnchor"in t?t.sourceAnchor:["center","middle"],this.targetAnchor="targetAnchor"in t?t.targetAnchor:["center","middle"],this.sourceOffset="sourceOffset"in t?t.sourceOffset:[0,0],this.targetOffset="targetOffset"in t?t.targetOffset:[0,0]}radialvalue(t,e){let i=t-Math.PI/2;return[t=e*Math.cos(i),e*=Math.sin(t)]}bezierCurveHorizontal(t,e,i,s){return`M ${t} ${e} C ${(t+i)/2} ${e} ${t} ${s} ${i} ${s}`}bezierCurveVertical(t,e,i,s){return`M ${t} ${e} C ${t} ${(e+s)/2} ${i} ${e} ${i} ${s}`}bezierCurveRadial(t,e,i,s){let n=this.radialvalue(t,e),r=this.radialvalue(t,(e+s)/2),a=this.radialvalue(i,e),o=this.radialvalue(i,s);return`M ${n[0]} ${n[1]} C ${r[0]} ${r[1]} ${a[0]} ${a[1]} ${o[0]} ${o[1]}`}arc(t,e,i,s,n){let r=t,a=i,o=e,l=s;!this.directed&&t>i&&(r=i,a=t,o=s,l=e);let h=Math.abs(r-a)/2,c=Math.abs(o-l)/2,d=Math.max(h,c);return`M ${r} ${o} A ${d} ${d} 0 0 ${n?1:0} ${a} ${l}`}_updateBounds(){if(null!=this.source&&null!=this.target){let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];this._bounds=new a(Math.min(t,i),Math.min(e,s),Math.abs(t-i),Math.abs(e-s))}else this._bounds=new a(0,0,0,0)}getSVGPathData(){if(void 0===this.source||void 0===this.target)return"";let t=this.source.bounds[this.sourceAnchor[0]]+this.sourceOffset[0],e=this.source.bounds[this.sourceAnchor[1]]+this.sourceOffset[1],i=this.target.bounds[this.targetAnchor[0]]+this.targetOffset[0],s=this.target.bounds[this.targetAnchor[1]]+this.targetOffset[1];switch(this.mode){case"curveHorizontal":return this.bezierCurveHorizontal(t,e,i,s);case"curveVertical":return this.bezierCurveVertical(t,e,i,s);case"arcClockwise":return this.arc(t,e,i,s,!0);case"arcAntiClockwise":return this.arc(t,e,i,s,!1);case"linear":default:return`M ${t} ${e} L ${i} ${s}`}}copyPropertiesTo(t){super.copyPropertiesTo(t),t.sourceAnchor=this.sourceAnchor.slice(),t.targetAnchor=this.targetAnchor.slice(),t.sourceOffset=this.sourceOffset.slice(),t.targetOffset=this.targetOffset.slice(),t.mode=this.mode}getPointAt(t){const e=kt.getSVG();let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",this.getSVGPathData()),e.appendChild(i);let s=i.getTotalLength();return i.getPointAtLength(s*t)}}const ge=function(t,e,i){let s=t.getScene();gt(t)||s._reapplyConstraints(t),s.getRelatedAxes(t).forEach((t=>{t.encoding&&void 0!==t.encoding.scale.offset&&(t.encoding.scale.offset+="x"===t.channel||"width"===t.channel?e:i),0===i||"x"!==t.channel&&"width"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+i),0===e||"y"!==t.channel&&"height"!==t.channel||void 0===t._posArg||(t._posArg=t._posArg+e),t.reposition()})),s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},_e=function(t,e,i){let s=t.getScene();s._relayoutAncestors(t,e);let n=[t],r=t.firstChild;for(;r;)n.push(r),r=r.firstChild;for(let t of n)t.getScene()._reapplyConstraints(t);let a=!1;for(let t of i)if(["numRows","numCols","layout","childrenOrder"].indexOf(t)>=0){a=!0;break}let o,l=!1;if(t.layout&&(t.layout.type!==v.Grid||1!==t.layout.numRows&&1!==t.layout.numCols?t.layout.type===v.Stack&&i.indexOf("orientation")>=0&&(l=!0,o=t.layout.orientation===x?"x":"y"):(l=!0,o=1===t.layout.numRows?"x":"y")),l){let e=s.getRelatedAxes(t).filter((e=>e instanceof ie&&e._item.parent.classId===t.classId));for(let i of e){s.removeItem(i);let e=i.toJSON().args;delete e.orientation,e.item=t.firstChild,s.axis(o,i.field,e)}}if(a)s.reCreateRelatedAxes(t);else{s.getRelatedAxes(t).forEach((t=>t.reposition()))}s.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},me=function(t){for(let e of t.encodings)e._map(),e._apply();for(let e of t.encodings)e.scene._updateAncestorBounds(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let i=e.anyItem,s=e.scene.getRelatedAxes(i);for(let i of s)i.encoding&&i.encoding.scale===t&&(i.tickValues=e._inferTickValues(e),i.labelValues=e._inferTickValues(e),i._positionPath(),i._showTitle&&i._positionTitle(),"radialDistance"===i._channel&&i._rotate&&(i._rotate=[i._rotate[0],i._item.parent.x,i._item.parent.y]),i._updateBounds());e.scene.getRelatedGridlines(i).forEach((t=>t.updateLinePositions()))}},ye=function(t){for(let e of t.encodings)e._apply();for(let e of t.encodings)e.scene._relayoutAncestors(e.item,e.items);let e=t.encodings.map((t=>t.anyItem)),i={};for(let t of e)"vertex"===t.type||"segment"===t.type?i[t.parent.classId]=t.parent:i[t.classId]=t;for(let t of Object.values(i))t.getScene()._reapplyConstraints(t);for(let e of t.encodings){let t=e.anyItem;e.scene.getRelatedAxes(t).forEach((t=>t.reposition())),e.scene.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))}},ve=function(t,e){let i=t.getScene();i._relayoutAncestors(t,e),i._reapplyConstraints(t),i.getRelatedAxes(t).forEach((t=>t.reposition())),i.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))},be=function(t,e){let i=e.getScene(),s=i.getRelatedAxes(t);for(let n of s)n._item.classId===t.classId&&(n._item=e,n._items=st(e,i));let n=i.encodings[ht(t)];if(n){i.encodings[ht(e)]={};for(let s of["x","y"]){const r=n[s];r&&(r.anyItem=e,r.items=st(e,i),i.encodings[ht(e)][s]=r,delete i.encodings[ht(t)][s])}0===Object.keys(n).length&&delete i.encodings[ht(t)]}},xe=function(t,e){let i=e.getScene(),s=i.encodings[ht(t)];if(s){i.encodings[ht(e)]={};for(let n of["x","y"]){const r=s[n];r&&(r.anyItem=e,r.items=st(e,i),i.encodings[ht(e)][n]=r,delete i.encodings[ht(t)][n])}0===Object.keys(s)&&delete i.encodings[ht(t)]}let n=i.getRelatedAxes(t);for(let s of n)s._item.classId===t.classId&&(s._item=e,s._items=st(e,i))},we=function(t){let e=t.getScene(),i=e.encodings[ht(t)];for(let t in i)i[t]._apply();e.getRelatedAxes(t).forEach((t=>t.reposition())),e.getRelatedGridlines(t).forEach((t=>t.updateLinePositions()))};function ke(t,e,i,s){let n=s.getFieldType(i);if(n!=I.String&&n!=I.Date&&n!=I.Integer)throw new Error(z.REPOPULATE_BY_NONCAT+": "+i+" is "+n);if(e.parent&&e.parent.dataScope&&!e.parent.dataScope.isFullTable()&&e.parent.dataScope.dataTable!=s)throw new Error(z.REPOPULATE_DT_MISMATCH);return function(t,e,i,s){let n=st(e.parent,t);1===n.length&&(e.parent.dataScope=void 0);for(let t of n){let e=s.getFieldSummary(i).unique.map((e=>t.dataScope?t.dataScope.cross(i,e):new Bt(s).cross(i,e)));e=e.filter((t=>!t.isEmpty()));const n=e.length-t.children.length,r=t.children.length-e.length;for(let e=0;e<r;e++)t.removeChildAt(t.children.length-1);const a=t.children.length;for(let e=0;e<n;e++){let e=t.children[Math.floor(Math.random()*a)].duplicate();t.addChild(e)}t.children.forEach(((t,i)=>t.dataScope=e[i]))}t._relayoutAncestors(e)}(t,e,i,s)}function Ce(t,e){let i=t.item;if(e.innerRadius===i.outerRadius&&i.sweepOver(e))t.children.push({item:e,children:[]});else if(t.children&&t.children.length>0&&e.innerRadius>i.outerRadius&&i.sweepOver(e))for(let i of t.children)Ce(i,e)}function Se(t,e,i,s){let n=t.item;if(n.innerRadius=e,n.outerRadius=e+s.map(i[n.id]),t.children&&t.children.length>0)for(let e of t.children)Se(e,n.outerRadius,i,s)}class Ee{constructor(t,e){this._type="tree";let i=[],s=[];this._nodeHash={},this._traverse(t,i,s),this._nodeTable=new $t(i,"nodes"),this._linkTable=new $t(s,"links"),this._nodeTable.tree=this,this._linkTable.tree=this,this._data=t}get type(){return this._type}_traverse(t,e,i,s=0){let n={};o in t||(t.id="n"+e.length),e.push(n),t._depth=s;for(let r in t)if("children"==r&&t[r]&&t[r].length>0)for(let n of t[r]){let r=this._traverse(n,e,i,s+1);i.push({parent:t.id,child:r})}else n[r]=t[r];return this._nodeHash[n.id]=n,n.id}getParent(t){let e,i=t.id,s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].child==i){e=s[t].parent;let i=n.findIndex((t=>t.id==e));return n[i]}}getChildren(t){let e=t.id,i=[],s=this._linkTable.data,n=this._nodeTable.data;for(let t in s)if(s[t].parent==e){let e=s[t].child,r=n.findIndex((t=>t.id==e));i.push(n[r])}return i}getNodeDataScope(t){return new Bt(this._nodeTable).cross(l,t.atlas_rowId)}getMaxDepth(){return this._nodeTable._fieldSummaries._depth.max}getRoot(){return this._nodeTable.data[0]}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}getNode(t){return this._nodeTable.data.filter((e=>e.id==t))[0]}sumLeaves(t,e){if(!t)return 0;let i=t.id,s=[];if(s=this.getChildren(t),s&&s.length>0){let t=0;for(let i of s)t+=this.sumLeaves(i,e);this.getNode(i)["sum"+e]=t}else this.getNode(i)["sum"+e]=t[e];return t["sum"+e]}countLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0)for(let t of s)n+=this.countLeaves(t,e);else n=1;return this.getNode(i)["count"+e]=n,t["count"+e]}averageLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=0;if(s&&s.length>0){for(let t of s)n+=this.averageLeaves(t,e);n/=s.length,this.getNode(i)["average"+e]=n}else this.getNode(i)["average"+e]=t[e];return t["average"+e]}medianLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.medianLeaves(t,e));n.sort((function(t,e){return t-e}));let t=Math.floor(n.length/2);n.length%2?this.getNode(i)["median"+e]=n[t]:this.getNode(i)["median"+e]=(n[t-1]+n[t])/2}else this.getNode(i)["median"+e]=t[e];return t["median"+e]}maxLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.maxLeaves(t,e));this.getNode(i)["max"+e]=Math.max(...n)}else this.getNode(i)["max"+e]=t[e];return t["max"+e]}minLeaves(t,e){if(!t)return 0;let i=t.id,s=[];s=this.getChildren(t);let n=[];if(s&&s.length>0){for(let t of s)n.push(this.minLeaves(t,e));this.getNode(i)["min"+e]=Math.min(...n)}else this.getNode(i)["min"+e]=t[e];return t["min"+e]}aggregateFromLeaves(t,e){let i=this.getRoot();switch(e){case"sum":this.sumLeaves(i,t);break;case"count":this.countLeaves(i,t);break;case"average":this.averageLeaves(i,t);break;case"median":this.medianLeaves(i,t);break;case"max":this.maxLeaves(i,t);break;case"min":this.minLeaves(i,t)}}}function Te(t,e,i,s,n){switch(e.type){case A.Circle:return function(t,e,i,s,n){let r,a,o=i||C.Outward,l=s||50;if(o!==C.Inward&&o!==C.Outward)throw z.UNKNOWN_DIRECTION+" "+o;return st(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let h=i.parent;Ae(i,e.id,o,l,n,n.getRoot(),s,t,!0),s.layout=cd("strata",{direction:o,rootMark:i}),h.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n);case A.Rect:return function(t,e,i,s,n){let r,a,o=i||C.Down,l=s||50;if([C.Up,C.Down,C.Left,C.Right].indexOf(o)<0)throw z.UNKNOWN_DIRECTION+" "+o;return st(e,t).forEach((i=>{let s=t.collection();s.dataScope=void 0,null==a&&(a=s.id),s.classId=a;let h=i.parent;Ie(i,e.id,o,l,n,n.getRoot(),s,t,!0),s.layout=cd("strata",{direction:o,rootMark:i}),h.addChild(s),i===e&&(r=s)})),r}(t,e,i,s,n)}}function Ae(t,e,i,s,n,r,a,o,l){l&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let h=n.getChildren(r);if(0===h.length)return;let c=t.type===A.Circle||t.type===A.Ring?90:t.startAngle,d=(t.type===A.Circle||t.type===A.Ring?360:t.angle)/h.length;for(let r=0;r<h.length;r++){let l,u=t.type===A.Circle?t.radius:t.outerRadius;l=360===d?o.mark("ring",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}):o.mark("arc",{innerRadius:u,outerRadius:u+s,x:t.x,y:t.y,startAngle:Ft(c+d*r),endAngle:Ft(c+d*(r+1)),strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity}),l.dataScope=n.getNodeDataScope(h[r]),l.classId=e,a.addChild(l),Ae(l,e,i,s,n,h[r],a,o)}}function Ie(t,e,i,s,n,r,a,o,l){l&&(t.dataScope=n.getNodeDataScope(r),t.classId=e,a.addChild(t));let h,c,d,u=n.getChildren(r);if(0!==u.length){switch(i){case C.Up:case C.Down:case C.Left:case C.Right:default:h=t.left,c=t.bottom,d=t.width/u.length}for(let r=0;r<u.length;r++){let l=o.mark("rect",{left:h,top:c,width:d,height:s,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});h+=d,l.dataScope=n.getNodeDataScope(u[r]),l.classId=e,a.addChild(l),Ie(l,e,i,s,n,u[r],a,o)}}}class Oe extends Mt{constructor(t){super(),t&&t.fillColor&&(this.fillColor=t.fillColor),this.type=A.Scene,this._id=this.type+vt[this.type]++,this.encodings={},this.constraints={},this._itemMap={},this._interactions=[],this._interactionsObj={}}clear(){this.removeAll(),this.encodings={},this.constraints={},this._itemMap={}}group(t){let e=new Mt;if(e.classId=e.id,this.addChild(e),t&&t.length>0)for(let i of t)e.addChild(i);return this._itemMap[e.id]=e,e}mark(t,e){let i=void 0===e?{}:e,s=null;switch(i.type=t,t){case A.Rect:{"top"in i||(i.top=0),"left"in i||(i.left=0),"width"in i||(i.width=100),"height"in i||(i.height=100);let t=i.top,e=i.left,n=i.width,r=i.height;i.vertices=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]],delete i.top,delete i.left,delete i.width,delete i.height,"fillColor"in i||(i.fillColor="none"),s=new Gt(i);break}case A.Area:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,e],[s,n],[t,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new re(i);break;case A.Line:if(void 0!==i&&"x1"in i&&"y1"in i&&"x2"in i&&"y2"in i){let t=i.x1,e=i.y1,s=i.x2,n=i.y2;i.vertices=[[t,e],[s,n]],delete i.x1,delete i.y1,delete i.x2,delete i.y2}s=new K(i),s.type=A.Line;break;case A.Path:s=new K(i);break;case A.Circle:s=new zt(i);break;case A.Ring:s=new ae(i);break;case A.Arc:case A.Pie:s=new ue(i);break;case A.Polygon:s=new oe(i);break;case"text":case A.PointText:"anchor"in i||(i.anchor=["center","middle"]),s=new Qt(i);break;case A.Image:s=new fe(i);break;case A.Link:s=new pe(i)}return null!==s&&(s.id="id"in i?i.id:s.type+vt[s.type]++,s.classId=s.id,this.addChild(s),this._itemMap[s.id]=s),s}glyph(...t){let e=new ne(t);return e.classId=e.id,this.addChild(e),this._itemMap[e.id]=e,e}collection(){let t=new de;return this.addChild(t),this._itemMap[t.id]=t,t}attach(t,e){t.dataScope=new Bt(e)}repeat(t,e,i){if(!t||void 0===e)throw z.INCOMPLETE_REPEAT_INFO;if(e.nodeTable&&e.linkTable){if(!Array.isArray(t)||2!==t.length)throw z.REPEAT_NODE_LINK;return function(t,e,i,s){let n=s.nodeTable.getFieldSummary(o).unique.map((t=>e.dataScope?e.dataScope.cross(o,t):new Bt(s.nodeTable).cross(o,t))),r=t.collection(),a=t.collection(),h={};a.dataScope=e.dataScope?e.dataScope.clone():new Bt(s.nodeTable),a.addChild(e);for(let t=1;t<n.length;t++){let t=e.duplicate();a.addChild(t)}a.children.forEach(((t,e)=>{t.dataScope=n[e],h[t.dataScope.getFieldValue(o)]=t}));let c=s.linkTable.getFieldSummary(l).unique.map((t=>i.dataScope?i.dataScope.cross(l,t):new Bt(s.linkTable).cross(l,t)));r.dataScope=i.dataScope?i.dataScope.clone():new Bt(s.linkTable),r.addChild(i);for(let t=1;t<c.length;t++){let t=i.duplicate();r.addChild(t)}r.children.forEach(((t,e)=>t.dataScope=c[e]));let d="tree"===s.type?"parent":"source",u="tree"===s.type?"child":"target";for(let t of r.children){let e=t.dataScope.getFieldValue(d),i=t.dataScope.getFieldValue(u);t.source=h[e],t.target=h[i],t._updateBounds()}return[a,r]}(this,t[0],t[1],e)}{let s=i||{},n=s.field?s.field:$t.RowID,r=s.callback;Pt(n,e);let a=Lt(this,t,n,e,r);return s.layout&&(a.layout=s.layout),a}}repopulate(t,e,i){if(!t||void 0===e)throw z.INCOMPLETE_REPEAT_INFO;let s=i||{},n=s.field?s.field:$t.RowID;Pt(n,e),ke(this,t,n,e)}densify(t,e,i){if(!t||void 0===e)throw z.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:$t.RowID,a="startAngle"in s?s.startAngle:90,o="direction"in s?s.direction:"clockwise",l=s.callback;Pt(r,e);let h=Dt(this,t,n,r,e,l,a,o);return xe(t,h),h}stratify(t,e,i){if(!(e instanceof Ee))throw z.STRATIFY_WITHOUT_TREE;if(t.type!==A.Circle&&t.type!==A.Rect)throw z.STRATIFY_WRONG_ITEM;let s=i||{};return Te(this,t,s.direction,s.size,e)}divide(t,e,i){if(!t||null==e)throw z.INCOMPLETE_PARTITION_INFO;let s=i||{},n=s.orientation,r=s.field?s.field:$t.RowID,a=s.callback;Pt(r,e);let o=Vt(this,t,n,r,e,a);return s.layout&&(o.layout=s.layout),be(t,o),o}classify(t,e){if(!md(t))throw z.CANNOT_CLASSIFY+t.type;let i=e||{},s=i.field?i.field:$t.RowID,n=t.firstChild.dataScope.dataTable,r=i.layout;return Pt(s,n),function(t,e,i,s){let n=st(e,t);for(let e of n){let s,n={},r=e.children;for(let t of r){let e=t.dataScope.getFieldValue(i);e in n||(n[e]=[]),n[e].push(t)}let a=r[0].dataScope._dt;for(let r in n){let o=t.collection();e.addChild(o),void 0===s&&(s=o.id),o.classId=s,o.dataScope=e.dataScope?e.dataScope.cross(i,r):new Bt(a).cross(i,r);for(let t of n[r])o.addChild(t)}}s&&t.setProperties(e.firstChild,{layout:s})}(this,t,s,r),t}_validateEncodeArgs(t,e){if(!t||!("channel"in e)||!("field"in e))throw z.INCOMPLETE_BINDING_INFO;let i=e.field;if("vertex"==t.type||"segment"==t.type){if(!t.parent.dataScope&&!t.dataScope)throw z.BIND_WITHOUT_DATASCOPE}else if(!t.dataScope)throw z.BIND_WITHOUT_DATASCOPE;let s=e.table?e.table:t.dataScope?t.dataScope._dt:t.parent.dataScope._dt,n=s.getFieldType(i);if("fillGradient"===e.channel&&[I.String,I.Boolean,I.Date].indexOf(n)>=0)throw z.UNSUPPORTED_FIELDTYPE+e.channel+": "+n;Pt(i,s)}encode(t,e){let i,s=Array.isArray(t)?t:[t],n=[];for(let r of s){let s;if([A.Pie,A.Arc].indexOf(t.type)>=0&&"angle"===e.channel){let i=t.parent;if(i.type===A.Collection&&i.layout&&i.layout.orientation===w){n.push(this._encodeWithinCollection(r,e));continue}}if(this._validateEncodeArgs(r,e),"vertex"==r.type&&r.parent.type==A.Area){let t=st(r.parent,this);s=[];let e=r.parent.vertices.indexOf(r)<r.parent.vertices.length/2;for(let i of t)s=e?s.concat(i.vertices.slice(0,i.vertices.length/2)):s.concat(i.vertices.slice(i.vertices.length/2))}else s=st(r,this);if(1===s.length&&s[0].type===A.Area&&("x"===e.channel||"y"===e.channel))return void console.warn("Only 1 "+r.type+" found, cannot encode "+e.field);!e.scale&&i&&(e.scale=i);let a=this._doEncode(s,e);i||(i=a.scale),n.push(a)}return n.length>1?n:n[0]}_doEncode(t,e){let i=t[0],s=e.channel,n=e.field;"datatable"in e||(e.datatable=i.dataScope?i.dataScope.dataTable:i.parent.dataScope.dataTable),"aggregator"in e||(e.aggregator="mean"),"flipScale"in e||(e.flipScale=!1),"includeZero"in e||(e.includeZero=!1),"scaleType"in e||(e.scaleType="linear");let r=new Ut(t,this,s,n,e);switch(s){case"width":case"height":case"radius":case"outerRadius":case"innerRadius":case"area":case"fontSize":i.type==A.Area?Yt(r):Wt(r);break;case"strokeWidth":i.type==A.Link?function(t){t._query=function(){let t=this.field,e=this.channel,i=this.items.map((t=>t.dataScope));if("strokeWidth"==e)if(this.datatable.hasField(t))this.data=i.map((e=>e.getFieldValue(t)));else if(t.startsWith("parent.")||t.startsWith("child.")){let e=this.datatable.tree.nodeTable,s=t.split(".")[0],n=t.split(".")[1],r=i.map((t=>t.getFieldValue(s)));this.data=r.map((t=>new Bt(e).cross(o,t).getFieldValue(n)))}},t._map=function(){let t,e=this.channel,i=this.items;if("strokeWidth"==e){let e,s;t=hd(this.scaleType),t.domain=[0,Math.max(...this.data)],e=1,s=Math.max(...i.map((t=>parseFloat(t.styles.strokeWidth)))),s==e&&(s=e+5),this.rangeExtent&&(s=e+this.rangeExtent),this.range&&(e=this.range[0],s=this.range[1]),t._setRange([e,s]),this.scale||(this.scale=t),this.scale._addEncoding(this)}},t._apply=function(){if("strokeWidth"==this.channel)for(let t=0;t<this.data.length;t++)this.items[t].styles.strokeWidth=this.scale.map(this.data[t])},t.run()}(r):Wt(r);break;case"x":case"y":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case I.Boolean:break;case I.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case I.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t,e,i,s,n,r=this.channel,a=this.datatable.getFieldType(this.field),o=nt(this.anyItem);if(o&&o.type==v.Grid){let e=o.cellBounds;t="x"==r?e[0].width:e[0].height}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===A.Area)t="x"==r?this.anyItem.parent.bounds.width:this.anyItem.parent.bounds.height;else{let e=this.items.map((t=>t[r]));t=Math.max(...e)-Math.min(...e),t<100?t=100:t>500&&(t=500)}switch(a){case I.Boolean:break;case I.Date:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=this.data;for(let e of this.scale.encodings)t=t.concat(e.data);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=hd("time"),this.scale.isFlipped=this._flipScale,n=[0,t],this.scale._baseItem=this.anyItem;break;case I.String:if(s=Array.from(new Set(this.data)),n=[0,t],this.scale){let t=this.scale.domain;for(let e of s)t.indexOf(e)<0&&t.push(e);s=t,n=this.scale.range}else this.scale=hd("point"),this.scale.isFlipped=this._flipScale,n=[0,t],this.scale._baseItem=this.anyItem;break;default:if(e=Math.min(...this.data),i=Math.max(...this.data),s=[e,i],this.scale){let t=this.data;for(let e of this.scale.encodings)t=t.concat(e.data);s=[Math.min(...t),Math.max(...t)],n=this.scale.range}else this.scale=hd(this.scaleType),this.scale.isFlipped=this._flipScale,this.scale.includeZero=this._includeZero,n=[0,t],this.scale._baseItem=this.anyItem;s[0]==s[1]&&(s[1]=1.1*s[0])}this.scale._scale.domain(s),this.scale._setRange(n),this.scale._addEncoding(this)},t._apply=function(){let t=[],e=this.channel;for(let e of this.scale.encodings)t=t.concat(e.items);if("x"==e){let i=nt(this.anyItem,"grid"),s=this.scale._baseItem?nt(this.scale._baseItem,"grid"):void 0;if(this.scale._baseItem&&!ct(this.anyItem,this.scale._baseItem)&&i&&s&&i.numRows===s.numRows&&i.numCols===s.numCols){let t=s.group.bounds.left-i.group.bounds.left,n=0;i.group.getScene().translate(i.group,t,n),i._colGap=s.colGap;let r=this.items.map((t=>at(t))),a=s.cellBounds;for(let t=0;t<this.items.length;t++){let i=this.items[t],s=a[r[t]].left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}this.anyItem.parent.getScene()._updateAncestorBounds(this.anyItem,this.items)}else if(i&&i.type==v.Grid)for(let t=0;t<this.items.length;t++){let i=this.items[t],s=rt(i).left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===A.Area){let t=dt(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=i.parent.bounds.left+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){let t=dt(this.items);void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.left))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t[e])))),this.items[0].type===A.PointText&&this.items.forEach((t=>t.horzAnchor="center"));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=this.scale.offset+this.scale.map(this.data[t])-i[e],n=0;i._doTranslate(s,n)}}}else{let i=nt(this.anyItem,"grid"),s=this.scale._baseItem?nt(this.scale._baseItem,"grid"):void 0;if(this.scale._baseItem&&!ct(this.anyItem,this.scale._baseItem)&&i&&s&&i.numRows===s.numRows&&i.numCols===s.numCols){let t=0,n=s.group.bounds.top-i.group.bounds.top;i.group.getScene().translate(i.group,t,n),i._rowGap=s.rowGap;let r=this.items.map((t=>at(t))),a=s.cellBounds;for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=a[r[t]].bottom-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),"vertex"!=i.type&&"segment"!=i.type||i.parent._updateBounds()}this.anyItem.parent.getScene()._updateAncestorBounds(this.anyItem,this.items)}else if(i&&i.type==v.Grid){let t=this.items.map((t=>rt(t)));for(let i=0;i<this.items.length;i++){let s=this.items[i],n=0,r=t[i].bottom-this.scale.map(this.data[i])-s[e];s._doTranslate(n,r),"vertex"!=s.type&&"segment"!=s.type||s.parent._updateBounds()}}else if("vertex"===this.anyItem.type&&this.anyItem.parent.type===A.Area){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=i.parent.bounds.top+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else if("vertex"==this.anyItem.type||"segment"==this.anyItem.type){void 0===this.scale.offset&&(this.scale.offset=Math.min(...this.items.map((t=>t.y))));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i[e];i._doTranslate(s,n),i.parent._updateBounds()}}else{void 0===this.scale.offset&&(this.scale.offset=Math.min(...t.map((t=>t.bounds.y)))),this.items[0].type===A.PointText&&this.items.forEach((t=>t.vertAnchor="middle"));for(let t=0;t<this.items.length;t++){let i=this.items[t],s=0,n=this.scale.offset+this.scale.rangeExtent-this.scale.map(this.data[t])-i.refBounds[e];i._doTranslate(s,n)}}}},t.run(),t.rangeExtent&&(t.scale.rangeExtent=t.rangeExtent)}(r);break;case"fillColor":case"strokeColor":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case I.Boolean:this.data=[!0,!1];break;case I.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case I.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){switch(this.datatable.getFieldType(this.field)){case I.Boolean:if(!this.scale&&(this.scale=hd("ordinalColor"),this.scale.domain=this.data,this._mapping)){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}break;case I.String:if(this.scale)this.scale.domain=Array.from(new Set(this.scale.domain.concat(this.data)));else{let t={scheme:"schemeCategory10"};if(this._scheme&&(W.indexOf(this._scheme)>=0?t.scheme=this._scheme:(Y.indexOf(this._scheme)>=0||U.indexOf(this._scheme)>=0)&&(t.scheme=this._scheme,t.size=this.data.length)),this.scale=hd("ordinalColor",t),this.scale.domain=this.data,this._mapping){let t=this.scale.domain.map((t=>t in this._mapping?this._mapping[t]:"black"));this.scale._scale.range(t)}}break;default:if(this.scale){if(!this._mapping){let t=this.scale.domain.concat(this.data);this.scale.domain=[Math.min(...t),Math.max(...t)]}}else if(this._mapping)this.scale=hd("linear",this._mapping);else{let t,e=Math.min(...this.data),i=Math.max(...this.data),s=Math.max(Math.abs(e),Math.abs(i));e<0&&i>0?(t="interpolatePuOr",e=-s,i=s,this.scale=hd("divergingColor",this._scheme?this._scheme:t)):(t="interpolateTurbo",this.scale=hd("sequentialColor",this._scheme?this._scheme:t)),this.scale.domain=[e,i]}}this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);"vertex"==e.type||"segment"==e.type?e[this.channel]=i:e.styles[this.channel]=i,e.vertices&&"strokeColor"==this.channel&&e.vertices.forEach((t=>t.fillColor=i))}},t.run()}(r);break;case"fillGradient":i.type===A.Area&&Yt(r);break;case"angle":!function(t){t._query=function(){this.data=[],this.id2data={};let t=this.field,e=this.items;switch(this.datatable.getFieldType(t)){case I.Boolean:break;case I.Date:this.data=e.map((e=>e.dataScope.getFieldValue(t)));break;case I.String:break;default:this.data=e.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator)))}for(let t=0;t<this.data.length;t++)this.id2data[e[t].id]=this.data[t]},t._map=function(){this.scale||(this.scale=hd("linear"),this.scale.domain=this.datatable.tree?[0,Math.max(...this.data)]:[0,this.data.reduce(((t,e)=>t+e),0)],this.scale._setRange([0,360]),this.scale._addEncoding(this))},t._apply=function(){let t;for(let e=0;e<this.items.length;e++)t=this.items[e],t.type!==A.Arc&&t.type!==A.Pie||t.adjustAngle(t.startAngle,Ft(t.startAngle+this.scale.map(this.data[e])));this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"text":!function(t){t._query=function(){this.data=[];let t,e,i=this.items;if(this.field.startsWith("parent.")||this.field.startsWith("child.")){e=this.datatable.tree.nodeTable,t=this.field.split(".")[1];let s=this.field.split(".")[0],n=i.map((t=>t.dataScope)).map((t=>t.getFieldValue(s)));e.getFieldType(t)==I.Integer||e.getFieldType(t)==I.Number?this.data=n.map((i=>new Bt(e).cross(o,i).aggregateNumericalField(t))):this.data=n.map((i=>new Bt(e).cross(o,i).getFieldValue(t)))}else e=this.datatable,t=this.field,e.getFieldType(t)==I.Integer||e.getFieldType(t)==I.Number?this.data=i.map((e=>e.dataScope.aggregateNumericalField(t,this.aggregator))):this.data=i.map((e=>e.dataScope.getFieldValue(t)))},t._map=function(){if(this.scale);else switch(this.datatable.getFieldType(this.field)){case I.Boolean:case I.Date:break;case I.String:default:this.scale=hd("ordinal"),this.scale.domain=[...new Set(this.data)],this.scale._scale.range(this.scale.domain.map((t=>t+"")))}},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]);e.text=i}},t.run()}(r);break;case"radialDistance":!function(t){t._query=function(){this.data=[];let t=this.field,e=this.items,i="vertex"!=this.anyItem.type&&"segment"!=this.anyItem.type||this.anyItem.dataScope?e.map((t=>t.dataScope)):e.map((t=>t.parent.dataScope));switch(this.datatable.getFieldType(t)){case I.Boolean:break;case I.Date:this.data=i.map((e=>e.getFieldValue(t)));break;case I.String:try{this.data=i.map((e=>e.getFieldValue(t)))}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:this.data=i.map((e=>e.aggregateNumericalField(t,this.aggregator)))}},t._map=function(){let t=this.data;this.scale||(this.scale=hd("linear"),this.scale.domain=[0,Math.max(...t)],this.scale._setRange([0,this.anyItem.parent.radius])),this.scale._addEncoding(this)},t._apply=function(){for(let t=0;t<this.items.length;t++){let e=this.items[t],i=this.scale.map(this.data[t]),s=Et(this.anyItem.parent.x,this.anyItem.parent.y,i,e.polarAngle);e.x=s[0],e.y=s[1]}this.scene._relayoutAncestors(this.anyItem,this.items)},t.run()}(r);break;case"thickness":!function(t){t._query=function(){this.data={};let t=this.field,e=this.items,i=e.map((t=>t.dataScope));switch(this.datatable.getFieldType(t)){case I.Boolean:break;case I.Date:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t);break;case I.String:try{for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].getFieldValue(t)}catch(e){throw new Error("Cannot bind "+this.channel+" to "+t+" : "+e)}break;default:for(let s=0;s<e.length;s++)this.data[e[s].id]=i[s].aggregateNumericalField(t,this.aggregator)}},t._map=function(){let t=this.data;if(!this.scale){this.scale=hd(this.scaleType),this.scale.domain=[0,Math.max(...Object.values(t))];let e=1,i=this.rangeExtent?e+this.rangeExtent:Math.max(...this.items.map((t=>t.outerRadius)));this.scale._setRange([e,i])}this.scale._addEncoding(this)},t._apply=function(){this.items.sort(((t,e)=>(t.innerRadius+t.outerRadius)/2-(e.innerRadius+e.outerRadius)/2));let t=Math.min(...this.items.map((t=>t.innerRadius))),e={item:new ue({outerRadius:t,startAngle:0,endAngle:360}),children:[]};for(let t of this.items)Ce(e,t);for(let t of e.children)Se(t,t.item.innerRadius,this.data,this.scale)},t.run()}(r)}return"_remember"in e&&1!=e._remember||this._registerBinding(r),s.indexOf("Color")<0&&this._updateAncestorBounds(i,r.items),r}_encodeWithinCollection(t,e){this._validateEncodeArgs(t,e);let i=function(t,e){let i={},s=st(t,e);for(let t of s){let e=t.parent.id;e in i||(i[e]=[]),i[e].push(t)}return Object.keys(i).map((t=>i[t]))}(t,this),s=[];for(let t of i){let i=this._doEncode(t,e);s.push(i)}return s}getPeers(t){return st(t,this)}find(t){return tt(this,t)}align(t,e){if(!function(t,e,i){if(e==S.Top||e==S.Bottom||e==S.Middle){for(let e of t)if(!xt(e,i))return!1;return!0}if(e==S.Left||e==S.Right||e==S.Center){for(let e of t)if(!bt(e,i))return!1;return!0}}(t,e,this))return!1;let i=new le(t,e);if(i.id in this.constraints)return console.warn("constraint has been added"),!1;this.constraints[i.id]=i,i.apply(),this._updateAncestorBounds(t[0])}removeAllConstraints(){this.constraints={}}removeConstraint(t){delete this.constraints[t.id]}getRelatedConstraints(t){let e=[];for(let i in this.constraints){let s=this.constraints[i];switch(s.type){case E:s._itemIds===t.map((t=>t.classId)).sort().join("_")&&e.push(s)}}return e}affix(t,e,i,s){let n=s||{},r="offset"in n?n.offset:0,a="itemAnchor"in n?n.itemAnchor:"x"==i||"angle"==i?"center":"middle",o="baseAnchor"in n?n.baseAnchor:"x"==i||"angle"==i?"center":"middle",l=new he(t,e,this,i,a,o,r);l.id,this.constraints,this.constraints[l.id]=l,l.apply()}axis(t,e,i){let s=i||{},n=s.item?this.getEncodingByItem(s.item,t):this.getEncodingByField(e,t);if(n&&n.field===e){if(n.datatable.getFieldType(e)!==I.Date||"labelFormat"in s||(s.labelFormat="%m/%d/%y"),"width"===n.channel){let t=this.children.filter((t=>t.type===A.Axis)).map((t=>t.channel));"orientation"in s||(s.orientation=t.indexOf("x")>=0?"top":"bottom")}else if("height"===n.channel){let t=this.children.filter((t=>t.type===A.Axis)).map((t=>t.channel));"orientation"in s||(s.orientation=t.indexOf("y")>=0?"right":"left")}let t=new ee(n,s.item?s.item:n.anyItem,s);return"tickValues"in s?(t.tickValues=s.tickValues,t.labelValues=s.tickValues):(t.tickValues=n._inferTickValues(),t.labelValues=n._inferTickValues()),this.addChildAt(t,0),this._itemMap[t.id]=t,this._updateBounds(),t}let r=s.item?s.item:tt(this,[{field:e}])[0];if(void 0===r)return void console.warn(D+e);let a=nt(r);if(a&&(a.type===v.Grid||a.type===v.Stack)){if(a&&("x"==t||"y"==t)){let i,n,r=st(a.group,this);for(let a of r){let r=tt(a,[{field:e}])[0],o=st(r,a);r.dataScope.dataTable.getFieldType(e)!==I.Date||"labelFormat"in s||(s.labelFormat="%m/%d/%y"),i=new ie(o,a.layout,t,e,s),null==n&&(n=i.id),i.classId=n,this.addChildAt(i,0),this._itemMap[i.id]=i}return this._updateBounds(),i}console.warn(D+e)}}getRelatedAxes(t){let e=[];if(gt(t))return e;for(let i of this.children){if(i.type!==A.Axis)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===ht(t).split("_")[0]){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ut(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}removeItem(t){if(!gt(t)){let e=this.getRelatedEncodings(t);for(let t of e)this.removeEncoding(t);let i=this.getRelatedAxes(t);for(let t of i)this.removeItem(t);for(let e of this.getRelatedGridlines(t))this.removeItem(e)}delete this._itemMap[t.id],this.removeChild(t),this._updateBounds()}getRelatedEncodings(t){let e=[],i=t;for(;i;)if(e.push(ht(i)),i.type==A.Collection)i=i.firstChild;else if(i.type==A.Glyph){for(let t of i.children)e.push(ht(t));i=void 0}else i=void 0;let s=Object.keys(this.encodings),n=[];for(let t of s){let i=t.split("_")[0];if(e.indexOf(i)>=0)for(let e in this.encodings[t])n.push(this.encodings[t][e])}return n}removeAllEncodings(){this.encodings={},this.removeAllItemsByType(A.Axis),this.removeAllItemsByType(A.Legend),this.removeAllItemsByType(A.Gridlines)}removeEncoding(t){let e=ht(t.anyItem);delete this.encodings[e][t.channel],0===Object.keys(this.encodings[e]).length&&delete this.encodings[e];let i=[];for(let e of this.children)gt(e)&&e.encoding&&e.encoding===t&&i.push(e);for(let t of i)this.removeItem(t);this._updateBounds()}removeAllItemsByType(t){let e=[];for(let i of this.children)i.type===t&&e.push(i);for(let t of e)this.removeItem(t);this._updateBounds()}reCreateRelatedAxes(t){let e=this.getRelatedAxes(t),i=[];e.forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),delete e.tickValues,delete e.labelValues,this.removeItem(t),t instanceof ie?i.indexOf(t.classId)<0&&(this.axis(t.channel,t.field,e),i.push(t.classId)):this.axis(t.channel,t.field,e)})),this._updateBounds()}reCreateRelatedLegends(t){this.getRelatedLegends(t).forEach((t=>{let e=t.toJSON().args;e.item&&(e.item=this.getItem(e.item)),this.removeItem(t),this.legend(t.channel,t.field,e)})),this._updateBounds()}legend(t,e,i){let s=i||{},n=this.getEncodingByField(e,t);if(!n)throw z.INCORRECT_LEGEND_INFO+e;"x"in s||(s.x=100),"y"in s||(s.y=100);let r=new se(n,s);return this.addChild(r),this._itemMap[r.id]=r,this._updateBounds(),r}gridlines(t,e,i){let s=this.getEncodingByField(e,t),n=i||{};if(!s)return!1;let r=new ce(s,n.item?n.item:s.anyItem,n);return r.values="values"in n?n.values:s._inferTickValues(),this.addChildAt(r,0),this._itemMap[r.id]=r,this._updateBounds(),r}getRelatedLegends(t){let e=[];if(gt(t))return e;for(let i of this.children)i.type===A.Legend&&i.matches(t)&&e.push(i);return e}getRelatedGridlines(t){let e=[];if(gt(t))return e;for(let i of this.children){if(i.type!==A.Gridlines)continue;if(i.matches(t)){e.push(i);continue}let s=i._item,n=!1;for(;s.children&&s.children.length>0;){for(let r of s.children)if(r.classId===t.classId){n=!0,e.push(i);break}if(n)break;s=s.children[0]}let r=ut(t),a={};for(let t of r)t.classId in a||(a[t.classId]=t);let o=Object.values(a);for(let t of o)if(i.matches(t)){e.push(i);break}}return e}propagate(t,e,...i){let s=st(t,this);for(let t of s)t[e](...i)}getEncodingByItem(t,e){let i=this.encodings[ht(t)];return i&&i[e]?i[e]:null}getEncodingByField(t,e){for(let i in this.encodings){let s=this.encodings[i];if(s[e]&&s[e].field==t)return s[e]}return null}positionBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(!mt(t))return null;for(let i in this.encodings){if(i.split("_")[0]===t.classId&&e in this.encodings[i])return this.encodings[i][e]}}sizeBound(t,e){let i=this.getEncodingByItem(t,e);if(i)return i;if(mt(t)){let i="width"===e||"height"===e||"radius"===e?["area"]:["width","height"],s="width"===e?["x"]:"height"===e?["y"]:["x","y"];for(let e in this.encodings){let n=e.split("_")[0];if(e.indexOf("_")<0){for(let s of i)if(n===t.classId&&s in this.encodings[e])return this.encodings[e][s]}else for(let i of s)if(n===t.classId&&i in this.encodings[e])return this.encodings[e][i]}}return null}setProperties(t,e){let i,s={};for(let t in e)s[t]=!0;if(Object.values(v).indexOf(t.type)>-1&&t.group){i=st(t.group,this);for(let t of i)for(let i in e)t.layout[i]=e[i]}else if(i=st(t,this),"vertex"===t.type)for(let t of i)for(let i in e)t[i]=e[i];else if(t instanceof J)for(let n in e)if("x"!==n&&"y"!==n||!this.positionBound(t,n))if("width"!==n&&"height"!==n&&"radius"!==n||!this.sizeBound(t,n))t.type!==A.Rect&&t.type!==A.Line||"width"!==n&&"height"!==n?t.type==A.Circle&&"radius"==n?i.forEach((t=>t.resize(2*e[n],2*e[n],e.xRef,e.yRef))):i.forEach((t=>t[n]=e[n])):"width"===n?i.forEach((t=>t.resize(e[n],t.bounds.height,e.xRef))):i.forEach((t=>t.resize(t.bounds.width,e[n],void 0,e.yRef)));else{let i=this.getEncodingByItem(t,n);i||"radius"!=n||(i=this.getEncodingByItem(t,"area"));let s=i.scale.rangeExtent*e[n]/t[n];i.scale.rangeExtent=s}else s[n]=!1;else if("collection"==t.type||"group"==t.type)for(let t of i)for(let i in e)t[i]="layout"===i&&void 0!==e[i]?e[i].clone():e[i];let n=Object.keys(s).filter((t=>s[t])),r=["width","height","fontSize","area","radius"];for(let e of r)if(n.indexOf(e)>=0&&_t(t)){ve(t,i);break}n.indexOf("baseline")>=0&&t.type===A.Area&&we(t,i);let a=["layout","rowGap","colGap","numRows","numCols","orientation","vertCellAlignment","horzCellAlignment","direction","childrenOrder"],o=n.filter((t=>a.indexOf(t)>=0));return o.length>0&&_e(i[0],i,o),s}_canTranslate(t){let e={x:!0,y:!0};return t.type==A.Axis?("x"===t.channel||"width"===t.channel?e.x=!1:"y"!==t.channel&&"height"!==t.channel||(e.y=!1),e):(t.parent.type===A.Collection&&t.parent.layout&&(e.x=!1,e.y=!1),this.positionBound(t,"x")&&(e.x=!1),this.positionBound(t,"y")&&(e.y=!1),e)}translate(t,e,i){let s=this._canTranslate(t);if(!s.x&&!s.y)return s;const n=s.x?e:0,r=s.y?i:0;return t._doTranslate(n,r),this._updateAncestorBounds(t),ge(t,n,r),s}_updateAncestorBounds(t,e){let i=dt(e||st(t,this));for(;i.length>0;){for(let t of i)(t.children&&t.children.length>0||t.vertices)&&t._updateBounds();i=dt(i)}}_reapplyConstraints(t){let e=t,i=[t];for(;e.children;)e.type==A.Collection?i.push(e.firstChild):i=i.concat(e.children),e=e.firstChild;for(e=t.parent;e&&e.type!==A.Scene;)i.push(e),e=e.parent;const s=i.map((t=>t.classId));for(let t in this.constraints){const e=this.constraints[t];switch(e.type){case T:(s.indexOf(e.item.classId)>=0||s.indexOf(e.baseItem.classId)>=0)&&e.apply();break;case E:for(let t of e.items)if(s.indexOf(t.classId)>=0){e.apply();break}}}}_relayoutAncestors(t,e){let i=dt(e||st(t,this));for(;i.length>0;){for(let t of i)t.layout&&t.layout.run(),t.children&&t.children.length>0&&t._updateBounds(),t.vertices&&t._updateBounds();i=dt(i)}}_reapplySizeBindings(t){let e=["width","height"];for(let i in this.encodings){if(t.classId!=i)continue;let s=this.encodings[i],n=tt(this,[{classId:i}]);for(let t of e){let e=s[t];e&&e.run()}this._relayoutAncestors(n[0],n)}}_registerBinding(t){let e=this.encodings,i=ht(t.anyItem);return i in e||(e[i]={}),e[i][t.channel]=t,!0}toJSON(){let t=super.toJSON();this.fillColor&&(t.fillColor=this.fillColor);let e={};t.encodings=[],t.itemCounter=vt;for(let i in this.encodings)for(let s in this.encodings[i]){let n=this.encodings[i][s];t.encodings.push(n.toJSON()),n.scale&&!(n.scale.id in e)&&(e[n.scale.id]=n.scale.toJSON())}t.scales=e,t.constraints={};for(let e in this.constraints)t.constraints[e]=this.constraints[e].toJSON();t.tables={};let i=this.getDataTables();for(let e in i)t.tables[e]=i[e].toJSON();return t}getDataTables(){let t={};for(let e in this.encodings)for(let i in this.encodings[e]){let s=this.encodings[e][i];s.datatable.id in t||(t[s.datatable.id]=s.datatable)}for(let e of this.children)if(!gt(e)){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}if(e.children&&e.children.length>0){let i=e.firstChild;for(;i;){if(i.dataScope){t[i.dataScope.dataTable.id]=i.dataScope.dataTable;break}i=i.children&&i.children.length>0?i.firstChild:void 0}}}return t}getItem(t){let e=t.split("_")[0];if(t.indexOf("_v_")>0){let i=parseInt(t.split("_v_")[1]);return this._itemMap[e].vertices.find((t=>t._id===i))}if(t.indexOf("_s_")>0){let i=parseInt(t.split("_s_")[1]);return this._itemMap[e].segments.find((t=>t._id===i))}return this._itemMap[t]}addInteraction(t){this._interactions.push(t),this._interactionsObj[t.event]=t}}const Re="N",Me="S",Ne="E",Pe="W",Fe="NE",Be="NW",Le="SE",je="SW",Ve="M";class De{SVG=null;drag=!1;selection=[];mouseDown=!1;rectSvg=null;bounds=null;brushColor="#9c3131";dir=null;bb=[];mouseDownEvent=null;constructor(t,e,i=null){this.SVG=d3.select("#"+t).style("cursor","crosshair"),this.brushColor=e,i&&(this.bounds=i)}brush(){return document.addEventListener("mousedown",(t=>{if(this.mouseDownEvent=t,this.rectSvg||this.appendRectangles(this.brushColor),this.bounds&&!(t.layerX>=this.bounds.left&&t.layerX<=this.bounds.left+this.bounds.width&&t.layerY>=this.bounds.top&&t.layerY<=this.bounds.top+this.bounds.height))return;this.drag=!1,this.mouseDown=!0,this.selection=[t.layerX,t.layerY];let e=this.bb[0],i=this.bb[1],s=this.bb[2],n=this.bb[3];this.selection[0]>e+3&&this.selection[0]<e+n-3&&this.selection[1]>=i+s-3&&this.selection[1]<=i+s+3?this.dir=Me:this.selection[0]>e+3&&this.selection[0]<e+n-3&&this.selection[1]>=i-3&&this.selection[1]<=i+3?this.dir=Re:this.selection[1]>i+3&&this.selection[1]<i+s-3&&this.selection[0]>=e+n-3&&this.selection[0]<=e+n+3?this.dir=Ne:this.selection[1]>i+3&&this.selection[1]<i+s-3&&this.selection[0]>=e-3&&this.selection[0]<=e+3?this.dir=Pe:this.selection[0]>=e-3&&this.selection[0]<=e+3&&this.selection[1]>=i-3&&this.selection[1]<=i+3?this.dir=Be:this.selection[0]>=e-3&&this.selection[0]<=e+3&&this.selection[1]>=i+s-3&&this.selection[1]<=i+s+3?this.dir=je:this.selection[0]>=e+n-3&&this.selection[0]<=e+n+3&&this.selection[1]>=i-3&&this.selection[1]<=i+3?this.dir=Fe:this.selection[0]>=e+n-3&&this.selection[0]<=e+n+3&&this.selection[1]>=i+s-3&&this.selection[1]<=i+s+3?this.dir=Le:this.selection[0]>e+3&&this.selection[0]<e+n-3&&this.selection[1]>i+3&&this.selection[1]<i+s-3?this.dir=Ve:(this.dir=null,this.updateRectangles(null,t.layerX,t.layerY,0,0))})),document.addEventListener("mousemove",(t=>{if(this.mouseDown)if(this.drag=!0,this.dir==Re)t.layerY>this.bb[1]?t.layerY<=this.bb[1]+this.bb[2]?this.updateRectangles(null,this.bb[0],t.layerY,this.bb[3],this.bb[2]+this.bb[1]-t.layerY):this.updateRectangles(null,this.bb[0],this.bb[1]+this.bb[2],this.bb[3],t.layerY-this.bb[1]-this.bb[2]):this.updateRectangles(null,this.bb[0],t.layerY,this.bb[3],this.bb[2]+this.bb[1]-t.layerY);else if(this.dir==Me)t.layerY>this.bb[1]?this.updateRectangles(null,this.bb[0],this.bb[1],this.bb[3],t.layerY-this.bb[1]):this.updateRectangles(null,this.bb[0],t.layerY,this.bb[3],this.bb[1]-t.layerY);else if(this.dir==Pe)t.layerX>this.bb[0]?t.layerX<=this.bb[0]+this.bb[3]?this.updateRectangles(null,t.layerX,this.bb[1],this.bb[3]-t.layerX+this.bb[0],this.bb[2]):this.updateRectangles(null,this.bb[0]+this.bb[3],this.bb[1],t.layerX-this.bb[0]-this.bb[3],this.bb[2]):this.updateRectangles(null,t.layerX,this.bb[1],this.bb[3]+this.bb[0]-t.layerX,this.bb[2]);else if(this.dir==Ne)t.layerX>this.bb[0]?this.updateRectangles(null,this.bb[0],this.bb[1],t.layerX-this.bb[0],this.bb[2]):this.updateRectangles(null,t.layerX,this.bb[1],this.bb[0]-t.layerX,this.bb[2]);else if(this.dir==Fe);else if(this.dir==Be);else if(this.dir==Le)t.layerX>this.bb[0]&&t.layerY>this.bb[1]?this.updateRectangles(null,this.bb[0],this.bb[1],t.layerX-this.bb[0],t.layerY-this.bb[1]):t.layerX>this.bb[0]&&t.layerY<this.bb[1]?this.updateRectangles(null,this.bb[0],t.layerY,t.layerX-this.bb[0],this.bb[1]-t.layerY):t.layerX<this.bb[0]&&t.layerY<this.bb[1]?this.updateRectangles(null,t.layerX,t.layerY,this.bb[0]-t.layerX,this.bb[1]-t.layerY):this.updateRectangles(null,t.layerX,this.bb[1],this.bb[0]-t.layerX,t.layerY-this.bb[1]);else if(this.dir==je);else if(this.dir==Ve)this.updateRectangles(null,this.bb[0]+t.layerX-this.selection[0],this.bb[1]+t.layerY-this.selection[1],this.bb[3],this.bb[2]),this.bb[0]=this.bb[0]+t.layerX-this.selection[0],this.bb[1]=this.bb[1]+t.layerY-this.selection[1],this.selection=[t.layerX,t.layerY];else{let{__x:e,__y:i,__height:s,__width:n}=this.getRectCoordinates(t,this.selection);this.updateRectangles(null,e,i,n,s)}})),document.addEventListener("mouseup",(t=>{if(this.mouseDown){if(this.drag){console.log("Brush");let t=this.rectSvg._groups[0][0].getBoundingClientRect();this.bb=[t.x-183,t.y,t.height,t.width],document.dispatchEvent(new CustomEvent("brush",{detail:{selection:[[t.x-183,t.y],[t.x-183+t.width,t.y+t.height]]}}))}else console.log("Click"),this.updateRectangles("none"),this.bb=[],this.removeRectangles(),document.dispatchEvent(new CustomEvent("brush",{detail:{e:this.mouseDownEvent}}));this.selection=[],this.dir=null,this.mouseDown=!1}})),1}removeRectangles(){this.rectSvg=null,d3.selectAll(".handle--selection").remove(),d3.selectAll(".handle--n").remove(),d3.selectAll(".handle--w").remove(),d3.selectAll(".handle--e").remove(),d3.selectAll(".handle--s").remove(),d3.selectAll(".handle--nw").remove(),d3.selectAll(".handle--ne").remove(),d3.selectAll(".handle--sw").remove(),d3.selectAll(".handle--se").remove(),d3.selectAll(".handle--overlay").remove()}appendRectangles(t){this.SVG.append("rect").attr("class","handle--overlay").attr("x","0").attr("x","0").attr("height",this.SVG._groups[0][0].clientHeight).attr("width",this.SVG._groups[0][0].clientWidth).style("cursor","crosshair").style("opacity","0"),this.rectSvg=this.SVG.append("rect").attr("class","handle--selection").style("fill",t).style("cursor","move").style("opacity","0.3").attr("display","none"),this.SVG.append("rect").attr("class","handle--n").style("cursor","ns-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--w").style("cursor","ew-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--e").style("cursor","ew-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--s").style("cursor","ns-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--nw").style("cursor","nwse-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--ne").style("cursor","nesw-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--sw").style("cursor","nesw-resize").attr("display","none").style("opacity","0"),this.SVG.append("rect").attr("class","handle--se").style("cursor","nwse-resize").attr("display","none").style("opacity","0")}updateRectangles(t=null,e=null,i=null,s=null,n=null){d3.selectAll(".handle--selection").attr("display",t).attr("x",e).attr("y",i).attr("height",n).attr("width",s),d3.selectAll(".handle--n").attr("display",t).attr("x",e?e-3:e).attr("y",i?i-3:i).attr("height",0==n||n?6:n).attr("width",0==s||s?s+6:s),d3.selectAll(".handle--w").attr("display",t).attr("x",e?e-3:e).attr("y",i?i-3:i).attr("height",0==n||n?n+6:n).attr("width",0==s||s?6:s),d3.selectAll(".handle--e").attr("display",t).attr("x",e?e+s-3:e).attr("y",i?i-3:i).attr("height",0==n||n?n+6:n).attr("width",0==s||s?6:s),d3.selectAll(".handle--s").attr("display",t).attr("x",e?e-3:e).attr("y",i?i+n-3:i).attr("height",0==n||n?6:n).attr("width",0==s||s?s+6:s),d3.selectAll(".handle--nw").attr("display",t).attr("x",e?e-3:e).attr("y",i?i-3:i).attr("height",0==n||n?6:n).attr("width",0==s||s?6:s),d3.selectAll(".handle--ne").attr("display",t).attr("x",e?e+s-3:e).attr("y",i?i-3:i).attr("height",0==n||n?6:n).attr("width",0==s||s?6:s),d3.selectAll(".handle--sw").attr("display",t).attr("x",e?e-3:e).attr("y",i?i+n-3:i).attr("height",0==n||n?6:n).attr("width",0==s||s?6:s),d3.selectAll(".handle--se").attr("display",t).attr("x",e?e+s-3:e).attr("y",i?i+n-3:i).attr("height",0==n||n?6:n).attr("width",0==s||s?6:s)}getRectCoordinates(t,e){let i,s,n,r=null;return t.layerY-e[1]<0?t.layerX-e[0]>0?(i=e[0],s=t.layerY,r=e[1]-t.layerY,n=t.layerX-e[0]):(i=t.layerX,s=t.layerY,r=e[1]-t.layerY,n=e[0]-t.layerX):t.layerX-e[0]>0?(i=e[0],s=e[1],r=t.layerY-e[1],n=t.layerX-e[0]):(i=t.layerX,s=e[1],r=t.layerY-e[1],n=e[0]-t.layerX),this.bounds&&(t.layerY-e[1]>0?s+r>this.bounds.top+this.bounds.height&&(r=this.bounds.top+this.bounds.height-e[1]):this.bounds.top+r>e[1]&&(s=this.bounds.top,r=e[1]-t.layerY-(this.bounds.top+r-e[1])),t.layerX-e[0]>0?i+n>this.bounds.left+this.bounds.width&&(n=this.bounds.left+this.bounds.width-e[0]):this.bounds.left+n>e[0]&&(i=this.bounds.left,n=e[0]-t.layerX-(this.bounds.left+n-e[0]))),{__x:i,__y:s,__height:r,__width:n}}}class Ge{constructor(t){this._renderer=t,this._globalPredicates={}}created=0;processInteraction(t,e){if(t.target&&t.targetEval&&t.targetEval.false&&t.listener.type==A.Scene){const i=[];st(t.target,e).forEach((e=>{const s={};Object.keys(t.targetEval.false).forEach((t=>{s[t]=e[t]})),i.push(s)})),"brush"!=t.event&&"click"!=t.event||0==this.created&&(this.created=new De(this._renderer._svgId,"#9c3131",t.hitObject._bounds).brush(),document.addEventListener("brush",(s=>{this._processBrush1(t,e,i,s.detail.selection?{selection:s.detail.selection}:null),null==s.detail.selection&&this._processClick(t,e,i,s.detail.e)})))}}_processBrush1(t,e,i,s){let r={};if("brush"==t.event){if(t.predicate.length<=0)return;t.predicate.forEach((e=>{if("range"!=e.type)throw new Error(`Event Type Brush should not have ${t.predicate.type} as Predicate Type`);{let i=[];"axis"==t.hitObject.type?t.hitObject._labels.children.forEach((t=>{i.push({axisCoordinate:t[e.channel],actualValue:t.text})})):"collection"==t.hitObject.type&&t.hitObject.children.forEach((t=>{i.push({axisCoordinate:t[e.channel],actualValue:t.dataScope.getFieldValue(e.field)})})),i.sort(((t,e)=>t.axisCoordinate-e.axisCoordinate)),r[e.channel]={_actualLabels:i.map((t=>t.actualValue)),_axisCoordinates:i.map((t=>t.axisCoordinate))},i=null}}))}if(s&&s.selection){let a={x:[s.selection[0][0],s.selection[1][0]],y:[s.selection[0][1],s.selection[1][1]]},o={x:null,y:null};Object.entries(r).forEach((t=>{const[e,i]=t;let s=i._actualLabels[n.bisect(i._axisCoordinates,a[e][0])],r=i._actualLabels[n.bisect(i._axisCoordinates,a[e][1])-1];o[e]={_high:s>=r?s:r,_low:s<r?s:r}}));let l,h=t.predicate.filter((t=>o.x&&"x"==t.channel))[0],c=t.predicate.filter((t=>o.y&&"y"==t.channel))[0],d=!1;st(t.target,e).forEach(((e,s)=>{h&&(l=o.x._high>=e.dataScope.getFieldValue(h.field)&&o.x._low<=e.dataScope.getFieldValue(h.field)),c&&(d=o.y._high>=e.dataScope.getFieldValue(c.field)&&o.y._low<=e.dataScope.getFieldValue(c.field)),null==h&&d||null==c&&l||l&&d?this.setTargetProperties(i[s],e):this.setTargetProperties(t.targetEval.false,e)}))}else st(t.target,e).forEach(((t,e)=>{this.setTargetProperties(i[e],t)}));this._renderer.render(e,{visualOnly:!0})}_processClick(t,e,i,s){t=e._interactionsObj.click;let n=new Set;if("point"==t.predicate[0].type)if(s.target.id.includes(t.target.type)){const n=st(t.target,e).filter((t=>t.id==s.target.id));n.length>0&&st(t.target,e).forEach(((e,s)=>{e.dataScope.getFieldValue(t.predicate[0].field)==n[0].dataScope.getFieldValue(t.predicate[0].field)?this.setTargetProperties(i[s],e):this.setTargetProperties(t.targetEval.false,e)}))}else"legend"==t.hitObject.type&&t.hitObject.encoding.datatable._fieldSummaries[t.predicate[0].field].unique.includes(s.target.innerHTML)?st(t.target,e).forEach(((e,n)=>{e.dataScope.getFieldValue(t.predicate[0].field)==s.target.innerHTML?this.setTargetProperties(i[n],e):this.setTargetProperties(t.targetEval.false,e)})):st(t.target,e).forEach(((t,e)=>{this.setTargetProperties(i[e],t)}));else if("list"==t.predicate[0].type)if(t.predicate[0].multiByField)if(s.target.id.includes(t.target.type)){const r=st(t.target,e).filter((t=>t.id==s.target.id));r.length>0&&(n.add(r[0].dataScope.getFieldValue(t.predicate[0].field)),st(t.target,e).forEach(((e,s)=>{n.has(e.dataScope.getFieldValue(t.predicate[0].field))?this.setTargetProperties(i[s],e):this.setTargetProperties(t.targetEval.false,e)})))}else n.clear(),st(t.target,e).forEach(((t,e)=>{this.setTargetProperties(i[e],t)}));else s.target.id.includes(t.target.type)?(n.has(s.target.id)?n.delete(s.target.id):n.add(s.target.id),st(t.target,e).forEach(((e,s)=>{n.has(e.id)?this.setTargetProperties(i[s],e):this.setTargetProperties(t.targetEval.false,e)}))):(n.clear(),st(t.target,e).forEach(((t,e)=>{this.setTargetProperties(i[e],t)})));this._renderer.render(e,{visualOnly:!0})}evaluatePredicate(t,e,i){if("range"==t.predicate.type)return e.dataScope.getFieldValue(t.predicate.field)<=_[0]&&e.dataScope.getFieldValue(t.predicate.field)>=_[1]}setTargetProperties(t,e){Object.keys(t).forEach((i=>{try{e[i]=t[i]}catch(t){console.log("Property not found")}}))}_getSelection(t,e,i,s){let n={};s?n.item=s:e.item;let r=e.field?e.field:l;return n.item&&(n.predicate={field:r,value:n.item.dataScope.getFieldValue(r)}),n}addGlobalPredicate(t,e){t.id in this._globalPredicates||(this._globalPredicates[t.id]={}),this._globalPredicates[t.id][e.field]=e}getGlobalPredicates(t){return t.id in this._globalPredicates?Object.values(this._globalPredicates[t.id]):[]}}class ze{constructor(t){this._svgId=t,this._compMap={},this._decoMap={},this._interactionHandler=new Ge(this)}render(t,e){let i=e||{};for(let t in this._decoMap)this._decoMap[t].remove(),delete this._decoMap[t];this._removed={};for(let t in this._compMap)this._removed[t]=1;this._renderItem(t,i);for(let t in this._removed)this._compMap[t].remove(),delete this._compMap[t];if(!("visualOnly"in i))for(let e of t._interactions)this._interactionHandler.processInteraction(e,t)}clear(){let t=document.getElementById(this._svgId);for(;t.firstChild;)t.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(t,e){let i,s=t.id,r=t.parent;i=r&&r.id&&r.id in this._compMap?n.select("#"+this._svgId).select("#"+r.id):n.select("#"+this._svgId),s in this._compMap?delete this._removed[s]:this._compMap[s]=i.append(this._getSVGElementType(t)),t.type==A.Gridlines&&this._compMap[s].lower();let a=this._compMap[s];if(a.attr("id",s),t.classId&&a.attr("class",t.classId),t.type==A.Scene&&n.select("#"+this._svgId).style("background",t.fillColor?t.fillColor:"#fff"),"vertex"!=t.type){if(t.type==A.Path||t.type==A.Polygon||t.type==A.Link)a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==A.Line)a.attr("x1",t.vertices[0].x),a.attr("y1",t.vertices[0].y),a.attr("x2",t.vertices[1].x),a.attr("y2",t.vertices[1].y),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges");else if(t.type==A.Circle)a.attr("cx",t.x),a.attr("cy",t.y),a.attr("r",t.radius);else if(t.type==A.Rect){let e=t.bounds;a.attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height)}else t.type==A.PointText?a.attr("text-anchor",this._getTextAnchor(t.anchor[0])).attr("alignment-baseline",this._getTextAnchor(t.anchor[1])).attr("dominant-baseline",this._getTextAnchor(t.anchor[1])).text(t.text).attr("x",t.x).attr("y",t.y):t.type==A.Pie||t.type==A.Area?(a.attr("d",t.getSVGPathData()),t.closed||a.style("fill","none"),0==s.indexOf("axis")&&a.style("shape-rendering","crispEdges")):t.type==A.Ring||t.type==A.Arc?a.attr("d",t.getSVGPathData()):t.type==A.Image&&a.attr("href",t.src).attr("x",t.x).attr("y",t.y).attr("width",t.width).attr("height",t.height);for(let e in t.styles)if(void 0!==t.styles[e])if(e.indexOf("Color")>0&&t.styles[e].type==A.LinearGradient){n.select("#"+this._svgId).select("defs").empty()&&n.select("#"+this._svgId).append("defs");let i=n.select("defs"),s=t.styles[e];if(i.select("#"+s.id).empty()){let t=i.append("linearGradient").attr("id",s.id);t.attr("x1",s.x1+"%").attr("x2",s.x2+"%").attr("y1",s.y1+"%").attr("y2",s.y2+"%");for(let e of s.stops)t.append("stop").attr("offset",e.offset+"%").style("stop-color",e.color).style("stop-opacity",e.opacity)}a.style(V[e],"url(#"+s.id+")")}else a.style(V[e],t.styles[e]);if(t._rotate&&a.attr("transform","rotate("+t._rotate.join(" ")+")"),t.vertices&&this._renderVertices(t),t.type==A.Collection&&e&&e.collectionBounds){let e=t.bounds;t.layout&&"grid"==t.layout.type?this._renderLayout(t):(t.id in this._decoMap||(this._decoMap[t.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[t.id].attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("fill","none").attr("stroke","#1ecb40").attr("stroke-width","2px").attr("stroke-dasharray","5,5"))}if(t.children)for(let i of t.children)this._renderItem(i,e)}}_renderVertices(t){let e=t.id+"-vertices";if(e in this._compMap)delete this._removed[e];else{let i=t.parent,s=i?i.id:this._svgId;this._compMap[e]=n.select("#"+s).append("g").attr("id",e)}if(0===t.vertices.map((t=>t.shape)).filter((t=>void 0!==t)).length)return void this._compMap[e].style("visible","hidden");this._compMap[e].style("visible","visible");let i=t.vertices.filter((t=>void 0!==t.shape));for(let t of i){let i=e+"-"+t.id;i in this._compMap?t.shape!==this._compMap[i].node().tagName?(this._compMap[i].remove(),this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),delete this._removed[i]):delete this._removed[i]:this._compMap[i]=n.select("#"+e).append(t.shape).attr("id",i),"rect"==t.shape?n.select("#"+i).attr("x",t.x-t.width/2).attr("y",t.y-t.height/2).attr("width",t.width).attr("height",t.height):"circle"==t.shape&&n.select("#"+i).attr("cx",t.x).attr("cy",t.y).attr("r",t.radius),n.select("#"+i).style("fill",t.fillColor).style("opacity",t.opacity).style("stroke-width",t.strokeWidth).style("stroke",t.strokeColor)}}_renderLayout(t){let e=t.id+"-grid";e in this._decoMap||(this._decoMap[e]=n.select("#"+this._svgId).append("g").attr("id",e).attr("class","deco"));let i=t.layout.cellBounds,s=t.layout.rowGap;this._decoMap[e].selectAll("rect").remove(),this._decoMap[e].selectAll("rect").data(i.slice(0,i.length-1)).enter().append("rect").attr("x",(t=>t.left)).attr("y",(t=>t.bottom)).attr("width",(t=>t.width)).attr("height",s).style("fill","pink").style("opacity",.5);for(let t of i)this._decoMap[e].append("rect").attr("x",t.left).attr("y",t.top).attr("width",t.width).attr("height",t.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getTextAnchor(t){switch(t){case"top":return"text-before-edge";case"bottom":return"text-after-edge";case"left":return"start";case"right":return"end";case"center":case"middle":return"middle";default:return t}}_getSVGElementType(t){switch(t.type){case A.Rect:return"rect";case A.Collection:case A.Group:case A.Glyph:case A.Scene:case A.Axis:case A.Legend:case A.Gridlines:return"g";case A.Area:case A.Path:case A.Polygon:case A.Ring:case A.Pie:case A.Arc:case A.Link:return"path";case A.Circle:return"circle";case A.Line:return"line";case A.PointText:return"text";case"vertex":if("circle"==t.shape)return"circle";if("rect"==t.shape)return"rect";throw"argument exception";case"image":return"image"}}}class We{constructor(t,e){switch(this._type=t,this._offset=void 0,this.id="scale"+vt.scale++,this._flipped=!1,this._includeZero=!1,t){case"linear":if(e){let t=Object.keys(e).map((t=>parseFloat(t))).sort(((t,e)=>t-e)),i=t.map((t=>e[t]));this._scale=n.scaleLinear(t,i),"clamp"in e&&this._scale.clamp(e.clamp),this._mapping=e}else this._scale=n.scaleLinear();break;case"point":this._scale=n.scalePoint();break;case"ordinal":this._scale=n.scaleOrdinal();break;case"ordinalColor":this._scale=n.scaleOrdinal(e?e.size?n[e.scheme][e.size]:n[e.scheme]:n.schemeCategory10);break;case"power":this._scale=n.scalePow().exponent(2);break;case"sqrt":this._scale=n.scalePow().exponent(.5);break;case"log":this._scale=n.scaleLog();break;case"identity":case"time":this._scale=n.scaleTime();break;case"sequentialColor":case"divergingColor":e&&"string"==typeof e?(this._scale=n.scaleSequential(n[e]),this._scheme=e):this._scale=n.scaleSequential()}this.encodings=[]}set scheme(t){if(this._type.indexOf("Color")<0&&"linear"!==this._type)return;let e=n.scaleSequential(n[t]),i=this._scale.domain();if(Math.min(...i)*Math.max(...i)<0){let t=Math.max(Math.abs(Math.min(...i)),Math.abs(Math.max(...i)));i=[-t,t]}e.domain(i),this._scheme=t,this._scale=e,"linear"===this._type&&(this._type=this._scale.domain()[0]*this._scale.domain()[1]<0?"divergingColor":"sequentialColor",this._mapping&&(this._mapping=void 0));for(let e of this.encodings)e._mapping&&(e._mapping=void 0),e._scheme=t,e._apply()}get scheme(){return this._scheme}get type(){return this._type}set type(t){let e;switch(t){case"linear":e=n.scaleLinear();break;case"power":e=n.scalePow().exponent(2);break;case"sqrt":e=n.scalePow().exponent(.5);break;case"log":e=n.scaleLog()}if(e){this._type=t,e.domain(this._scale.domain()).range(this._scale.range()),this._scale=e;for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}else console.warn(G+t)}toJSON(){let t={};return t.type=this.type,t.id=this.id,t.offset=this._offset,this._scheme&&(t.scheme=this._scheme),t.domain=this._scale.domain(),t.range=this.range,t.clamp=this.clamp,t.isFlipped=this.isFlipped,t.includeZero=this.includeZero,this._mapping&&(t.mapping=this._mapping),this._baseItem&&(t.baseItem=this._baseItem.id),t}_merge(t){if(this.type!=t.type)throw z.DIFFERENT_SCALE_TYPE;let e,i;switch(this.type){case"linear":case"time":e=[Math.min(this.domain[0],t.domain[0]),Math.max(this.domain[1],t.domain[1])],i=[0,this.map(e[1])-this.map(e[0])];break;case"point":case"ordinalColor":e=[...new Set(this.domain.concat(t.domain))],i=[];break;default:console.log("TODO: merge scale type",this.type)}this._scale.domain(e),this._scale.range(i)}get domain(){if(this._includeZero){return[0,this._scale.domain()[1]]}return this._scale.domain()}set domain(t){this._scale.domain(t);for(let t of this.encodings)t._apply()}get range(){return this._scale.range()}
3
- //to support this, the argument should be in real screen coordinates and need to do internal conversion
4
- set range(t){this._scale.range(t);for(let t of this.encodings)t._apply();for(let t of this.encodings)t.scene._updateAncestorBounds(t.item,t.items)}_setRange(t){this._scale.range(t),ye(this)}get clamp(){return"linear"==this.type&&this._scale.clamp()}set clamp(t){"linear"==this.type&&this._scale.clamp(t)}set rangeExtent(t){let e=this._scale.range();this._setRange([e[0],e[0]+t])}get rangeExtent(){let t=this._scale.range();return Math.abs(t[1]-t[0])}_addEncoding(t){this.encodings.indexOf(t)<0&&this.encodings.push(t)}map(t){let e=this._scale.copy();return e.domain(this.domain),this._flipped?(e.range(this._scale.range().reverse()),e(t)):e(t)}invert(t){return this._scale.invert(t)}get offset(){return this._offset}set offset(t){this._offset=t;for(let t of this.encodings)t._apply()}get isFlipped(){return this._flipped}set isFlipped(t){this._flipped=t}get includeZero(){return this._includeZero}set includeZero(t){this._includeZero=t,me(this)}get mapping(){return this._mapping}getEncodedChannels(){let t={};for(let e of this.encodings)t[e.channel]=!0;return Object.keys(t)}}class Ye extends Ot{constructor(t){super(t),this.type="packing",this.x="x"in t?t.x:400,this.y="y"in t?t.y:400,this.width=t.width,this.height=t.height}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this.x,t.args.y=this.y,t.args.width=this.width,t.args.height=this.height,t}clone(){return new Ye({x:this.x,y:this.y,width:this.width,height:this.height})}run(){if(null==this.group)return;let t=this.group.children.map((t=>({name:t.id,radius:t.radius,itm:t}))),e=t.reduce(((t,e)=>t+Math.pow(e.radius,2)),0),i=Math.sqrt(e);void 0===this.width&&(this.width=i),void 0===this.height&&(this.height=i);let s=n.hierarchy({name:"root",children:t}).sum((t=>t.radius?t.radius:0)).sort(((t,e)=>e.value-t.value));n.pack().size([this.width,this.height]).radius((t=>t.value))(s);for(let t of s.children){let e=t.data.itm,i=this.x-s.x+t.x-e.x,n=this.y-s.y+t.y-e.y;e._doTranslate(i,n)}this.group._updateBounds()}}class Ue extends Ot{constructor(t){super(t),this.type="treemap",this._width=t.width,this._height=t.height,this._top=t.top,this._left=t.left}toJSON(){let t={args:{}};return t.type=this.type,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}clone(){return new Ue({width:this._width,height:this._height,top:this._top,left:this._left})}run(){if(null==this.group||!this.group.children||0==this.group.children.length)return;let t=this._width?this._width:this.group.bounds.width,e=this._height?this._height:this.group.bounds.height,i=void 0===this._top?this.group.bounds.top:this._top,s=void 0===this._left?this.group.bounds.left:this._left,r=n.hierarchy(this.group).sum((t=>"rect"==t.type?t.bounds.width*t.bounds.height:0));n.treemap().size([t,e])(r),this._apply(r,s,i),this.group.getScene()._updateAncestorBounds(r.leaves()[0].data)}_apply(t,e,i){if("collection"==t.data.type&&t.children)for(let s of t.children)this._apply(s,e,i);else"rect"==t.data.type&&(t.data.resize(t.x1-t.x0,t.y1-t.y0),t.data._doTranslate(t.x0+e-t.data.bounds.left,t.y0+i-t.data.bounds.top))}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get top(){return this._top}set top(t){this._top=t,this.run()}get left(){return this._left}set left(t){this._left=t,this.run()}}function qe(t,e){let i=[t[0]],s=[e[0]];for(let n=1;n<e.length;n++){let r=!1,a=e[n];for(let e=0;e<s.length;e++){let o=s[e],l=new Set(a);if(o.forEach((t=>l.add(t))),l.size<a.length+o.length){s[e]=[...l],i[e]=i[e].concat(t[n]),r=!0;break}}r||(s.push(a),i.push(t[n]))}return{grouping:i,subgraphs:s}}class Je{constructor(t,e){this._type="network",this._nodeTable=new $t(t.nodes,"nodes"),this._linkTable=new $t(t.links,"links"),this._nodeTable.graph=this,this._linkTable.graph=this,this._nodes=t.nodes,this._links=t.links,this._name=e,this._nodeHash={};for(let e of t.nodes)this._nodeHash[e.id]=e}get type(){return this._type}get nodeTable(){return this._nodeTable}get linkTable(){return this._linkTable}get nodes(){return this._nodes}get links(){return this._links}getNode(t){return this._nodeHash[t]}getSources(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].target==i){e=s[t].source;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}getTargets(t){let e,i=t.id,s=this._links.data,n=this._nodes.data,r=[];for(let t in s)if(s[t].source==i){e=s[t].target;let i=n.findIndex((t=>t.id===e));r.push(n[i])}return r}transform(t,e,i){switch(t){case"partition":return function(t){let e=t.nodes,i=t.links,s=i.map(((t,e)=>[e])),n=i.map((t=>[t.source,t.target])),r=qe(s,n);for(;r.grouping.length!=s.length;)s=r.grouping,n=r.subgraphs,r=qe(s,n);let a=[];for(let[t,s]of r.grouping.entries()){let n={nodes:[],links:[]};n.links=s.map((t=>i[t]));const o=r.subgraphs[t];n.nodes=e.filter((t=>o.indexOf(t.id)>=0)),a.push(new Je(n))}return a}(this)}}isLinear(){let t={},e={};for(let i of this._links)i.source in e||(e[i.source]=0),i.target in t||(t[i.target]=0),e[i.source]++,t[i.target]++;for(let e in t)if(t[e]>1)return!1;for(let t in e)if(e[t]>1)return!1;return!0}}class Xe extends Ot{constructor(t){super(t),this.type=v.TidyTree,this._width="width"in t?t.width:500,this._height="height"in t?t.height:500,this._left="left"in t?t.left:100,this._top="top"in t?t.top:100,this._orientation="orientation"in t?t.orientation:x}toJSON(){let t={args:{}};return t.args.type=this.type,t.args.orientation=this._orientation,t.args.left=this._left,t.args.top=this._top,t.args.width=this._width,t.args.height=this._height,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt;if(!t.tree)throw z.LAYOUT_WITHOUT_TREE;{let e=n.hierarchy(t.tree._data),i=Math.max(...this.group.children.map((t=>t.bounds.width))),s=Math.max(...this.group.children.map((t=>t.bounds.height))),r=this._orientation==x?[this._height,this._width]:[this._width,this._height],a=n.tree().nodeSize([i,s]).size(r)(e);this._apply(a,this.group)}}_apply(t,e){let i,s,n=e.children.filter((e=>e.dataScope.getFieldValue(o)==t.data.id))[0];switch(this._orientation){case x:i=t.y+this._left,s=t.x+this._top;break;case b:i=t.x+this._left,s=this._top+t.y}if(n.x=i,n.y=s,t.children&&t.children.length>0)for(let i of t.children)this._apply(i,e)}get orientation(){return this._orientation}set orientation(t){this._orientation=t,this.run()}get width(){return this._width}set width(t){this._width=t,this.run()}get height(){return this._width}set height(t){this._height=t,this.run()}get size(){return[this._width,this._height]}set size(t){this._width=t[0],this._height=t[1],this.run()}}class $e extends Ot{constructor(t){super(t),this.type=v.Force,this._x="x"in t?t.x:0,this._y="y"in t?t.y:0,this._iterations="iterations"in t?t.iterations:1,this._repulsion="repulsion"in t?t.repulsion:30,this._attraction="attraction"in t?t.attraction:1,this._linkDistance="linkDistance"in t?t.linkDistance:30}toJSON(){let t={args:{}};return t.type=this.type,t.args.x=this._x,t.args.y=this._y,t.args.iterations=this._iterations,t}run(){if(null==this.group)return;let t=this.group.children[0].dataScope._dt.graph;if(t){let e=t.links.map((e=>({source:t.getNode(e.source),target:t.getNode(e.target)}))),i=n.forceSimulation(t.nodes).force("charge",n.forceManyBody().strength(-this._repulsion)).force("link",n.forceLink(e).id((t=>t.id)).distance(this._linkDistance)).force("x",n.forceX()).force("y",n.forceY()).force("center",n.forceCenter(this._x,this._y).strength(this._attraction));i.stop(),i.tick(this._iterations);for(let e=0;e<this.group.children.length;e++)this.group.children[e].x=t.nodes[e].x,this.group.children[e].y=t.nodes[e].y}}}class He{constructor(){this.axes={},this.guideCmds=[],this.collectionCmds=[],this.glyphCmds=[],this.spec=[]}run(t){for(let e of t.children)switch(e.type){case A.Axis:{let t=e.classId?e.classId:e.id;this.axes[t]=e;break}case A.Gridlines:case A.Legend:{let t=e.toJSON();this.guideCmds.push({cmd:e.type,channel:t.channel,field:t.field,args:t.args});break}case A.Collection:case A.Group:case A.Glyph:{let i=[];this._analyze(e,i);for(let t=i.length-1;t>0;t--)for(let e of i[t].fields)i[t-1].fields.delete(e);for(let[e,s]of i.entries()){if(s.item instanceof J){let e={cmd:"mark",type:s.item.type,output:s.item,args:s.item.toJSON().args};this._inferMarkArgs(e,t),this.collectionCmds.push(e)}else if(s.item instanceof ne)this.collectionCmds.push({cmd:"glyph",output:s.item,input:i.slice(0,e).map((t=>t.item)),args:{}});else if(s.item instanceof de){let t=[...i[e-1].fields][0],n={cmd:"join",input:i[e-1].item,output:s.item,data:i[e-1].item.dataScope.dataTable.id,args:{field:t}};t==l&&delete n.field,this.collectionCmds.push(n)}s.item.dataScope&&0==s.item.dataScope.fields.length&&!s.item.parent.dataScope&&this.collectionCmds.push({cmd:"attach",input:s.item,data:s.item.dataScope.dataTable.id})}break}default:if(e instanceof J){let i={cmd:"mark",type:e.type,output:e,args:e.toJSON().args};this._inferMarkArgs(i,t),this.glyphCmds.push(i)}}this._inferJoin(),this._inferArgs(t);for(let t in this.axes){let e=this.axes[t].toJSON();this.guideCmds.push({cmd:e.type,channel:e.channel,field:e.field,args:e.args})}return this._generateFullSpec(t),this.spec}_inferJoin(){for(let t of this.collectionCmds){if("join"!=t.cmd)continue;let e=t.input,i=e.parent;switch(e.type){case A.Rect:i.layout&&i.layout.type==v.Stack?t.cmd="divide":t.cmd="repeat";break;default:t.cmd="repeat"}}}_inferArgs(t){for(let e of this.collectionCmds)switch(e.cmd){case"mark":this._inferMarkArgs(e,t);break;case"divide":this._inferDivideArgs(e,t)}}_inferDivideArgs(t){t.args.orientation=t.output.layout.orientation}_inferMarkArgs(t,e){let i=t.output,s=i.parent,n=st(i,e),r=st(s,e);switch(i.type){case A.Rect:s.layout&&s.layout.type==v.Grid?(t.args.width=s.layout.cellBounds[0].width,t.args.height=s.layout.cellBounds[0].height):s.layout&&s.layout.type==v.Stack?(t.args.width=Math.max(...r.map((t=>t.bounds.width))),t.args.height=Math.max(...r.map((t=>t.bounds.height)))):(t.args.width=Math.max(...n.map((t=>t.bounds.width))),t.args.height=Math.max(...n.map((t=>t.bounds.height)))),t.args.left=Math.min(...n.map((t=>t.bounds.left))),t.args.top=Math.min(...n.map((t=>t.bounds.top)));break;case A.Line:t.args.x1=Math.min(...n.map((t=>t.vertices[0].x))),t.args.y1=Math.min(...n.map((t=>t.vertices[0].y))),t.args.x2=Math.min(...n.map((t=>t.vertices[1].x))),t.args.y2=Math.min(...n.map((t=>t.vertices[1].y)));break;case A.Arc:t.args.x=i.x,t.args.y=i.y,t.args.innerRadius=i.innerRadius,t.args.outerRadius=i.outerRadius}for(let e in i.styles)t.args[e]=i.styles[e]}_analyze(t,e){if(t instanceof ne)for(let i of t.children)this._analyze(i,e);else t instanceof Mt&&this._analyze(t.firstChild,e);let i={type:t.type,item:t};t.dataScope?i.fields=new Set(t.dataScope.fields):i.fields=new Set,e.push(i)}_generateFullSpec(t){this.spec=[],this.spec.push({cmd:"scene",args:{fillColor:t.fillColor}});let e=t.getDataTables(),i={},s=[];for(let t in e){let n=e[t];if(n.sourceDataTable)for(;n.sourceDataTable;)s.push({cmd:"transform",type:n.transform.type,args:n.transform.args,input:n.sourceDataTable.id,output:n.id}),n=n.sourceDataTable;n.id in i||(i[n.id]={cmd:"data",url:n.url,output:n.id})}this.spec=this.spec.concat(Object.values(i)),this.spec=this.spec.concat(s);let n=[];for(let t of this.collectionCmds){let e;t.output&&t.output.layout&&(e={cmd:"layout",type:t.output.layout.type,input:t.output.id,args:t.output.layout.toJSON().args}),this.spec.push(t),t.output&&t.output.childrenOrder&&n.push({cmd:"sortChildren",args:t.output.childrenOrder,input:t.output.id}),e&&this.spec.push(e),t.input&&Array.isArray(t.input)?t.input=t.input.map((t=>t.classId?t.classId:t.id)):t.input&&(t.input=t.input.classId?t.input.classId:t.input.id),t.output&&(t.output=t.output.classId?t.output.classId:t.output.id)}let r={},a=[];for(let e in t.encodings)for(let i in t.encodings[e]){let s=t.encodings[e][i];s.scale&&!(s.scale.id in r)&&(r[s.scale.id]=s.scale.toJSON());let n=s.toJSON().args;n.field=s.field,n.channel=s.channel,delete n.datatable,a.push({cmd:"encode",input:ht(s.anyItem),scale:s.scale.id,args:n})}for(let t in r){let e=r[t];e.cmd="scale",this.spec.push(e)}this.spec=this.spec.concat(a),this.spec=this.spec.concat(n);for(let e in t.constraints){let i=t.constraints[e],s={cmd:"constraint",type:i.type,args:{}};switch(i.type){case T:s.item=i.item.classId?i.item.classId:i.item.id,s.baseItem=i.baseItem.classId?i.baseItem.classId:i.baseItem.id,s.channel=i.channel,s.args.itemAnchor=i.itemAnchor,s.args.baseAnchor=i.baseAnchor,s.args.offset=i.offset;break;case E:s.items=i.items.map((t=>t.classId?t.classId:t.id)),s.anchor=i.anchor}this.spec.push(s)}for(let t of this.guideCmds)this.spec.push(t);for(let t of this.glyphCmds)t.output&&(t.output=t.output.classId?t.output.classId:t.output.id),this.spec.push(t)}}class Ze{constructor(){this.axes={},this.legends=[],this.gridlines=[],this.scales={},this.tables={}}load(t){let e={};if(t.fillColor&&(e.fillColor=t.fillColor),t.itemCounter)for(let e in t.itemCounter)vt[e]=t.itemCounter[e];let i=ld(e);if(i.id=t.id,i.type=t.type,t.bounds&&(i._bounds=new a(t.bounds.left,t.bounds.top,t.bounds.width,t.bounds.height)),t.tables)for(let e in t.tables)this.tables[e]=new $t(t.tables[e].data,t.tables[e].url,t.tables[e].fieldTypes),this.tables[e].id=t.tables[e].id;for(let e of t.children)this._processItem(i,e,i);if(t.scales)for(let e in t.scales)this._loadScale(t.scales[e],i);if(t.encodings)for(let e of t.encodings)this._loadEncoding(e,i);if(t.constraints)for(let e in t.constraints)this._loadConstraint(t.constraints[e],i);for(let t in this.axes)this._createGuide(i,this.axes[t]);for(let t of this.legends)this._createGuide(i,t);for(let t of this.gridlines)this._createGuide(i,t);return i}_loadScale(t,e){let i;t.type.indexOf("Color")>0&&t.scheme?i=hd(t.type,t.scheme):(i=hd(t.type),i.range=t.range),i.domain="time"==t.type?t.domain.map((t=>new Date(t))):t.domain,i.id=t.id,"offset"in t&&(i.offset=t.offset),i.isFlipped=t.isFlipped,i.clamp=t.clamp,i._mapping=t.mapping,"includeZero"in t&&(i.includeZero=t.includeZero),"baseItem"in t&&(i._baseItem=e.getItem(t.baseItem)),this.scales[i.id]=i}_loadEncoding(t,e){t.args.datatable&&(t.args.datatable=this.tables[t.args.datatable]),t.args.scale&&(t.args.scale=this.scales[t.args.scale]);let i=t.items.map((t=>e.getItem(t)));e._doEncode(i,t.args),e._relayoutAncestors(i[0],i)}_createGuide(t,e){switch(e.type){case A.Axis:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.axis(e.channel,e.field,e.args);break;case A.Legend:t.legend(e.channel,e.field,e.args);break;case A.Gridlines:e.args.item&&(e.args.item=t.getItem(e.args.item)),t.gridlines(e.channel,e.field,e.args)}}_processItem(t,e,i){switch(e.type){case A.Axis:{let t=e.classId?e.classId:e.id;e.args.tickValues&&e.args.isDate&&(e.args.tickValues=e.args.tickValues.map((t=>new Date(t)))),this.axes[t]=e;break}case A.Gridlines:e.args.values&&e.args.isDate&&(e.args.values=e.args.values.map((t=>new Date(t)))),this.gridlines.push(e);break;case A.Legend:this.legends.push(e);break;case A.Collection:{let s=i.collection();t.addChild(s),this._loadGroup(s,e,i);break}case A.Group:{let s=i.group();t.addChild(s),this._loadGroup(s,e,i);break}case A.Glyph:{let s=i.glyph();t.addChild(s),this._loadGroup(s,e,i);break}default:this._loadMark(t,e,i)}}_loadConstraint(t,e){switch(t.type){case"affixation":{let i=e.getItem(t.item),s=e.getItem(t.baseItem),n=new he(i,s,e,t.channel,t.itemAnchor,t.baseAnchor,t.offset);return n.id=t.id,e.constraints[t.id]=n,n.apply(),n}case"alignment":{let i=t.items.map((t=>e.getItem(t))),s=new le(i,t.direction);return s.id=t.id,e.constraints[t.id]=s,s.apply(),s}}}_loadDataScope(t){let e=new Bt(this.tables[t.dt]);for(let i in t.f2v)e._field2value[i]=t.f2v[i],e._updateTuples(i,t.f2v[i]);return e}_loadGroup(t,e,i){if(t.id=e.id,e.classId&&(t.classId=e.classId),e.dataScope&&(t.dataScope=this._loadDataScope(e.dataScope)),e.children)for(let s of e.children)this._processItem(t,s,i);if(e.layout){let i=this._loadLayout(e.layout);i.group=t,t._layout=i}e.bounds&&(t._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height))}_loadMark(t,e,i){if(e.args.fillColor&&"LinearGradient"===e.args.fillColor.type){let t=e.args.fillColor;e.args.fillColor=dd(t),e.args.fillColor.id=t.id,e.args.fillColor._stops=t.stops}"id"in e&&(e.args.id=e.id);let s=i.mark(e.type,e.args);if(e.classId&&(s.classId=e.classId),e.dataScope&&(s.dataScope=this._loadDataScope(e.dataScope)),e.vertices){const t=[];for(let i of e.vertices){const e=H.fromJSON(i,s);e.dataScope&&(e.dataScope=this._loadDataScope(e.dataScope)),t.push(e)}s.vertices=t,s.segments=[];for(let t=1;t<s.vertices.length;t++)s.segments.push(new Z(s.vertices[t-1],s.vertices[t],s,s.segmentCounter++))}e.bounds&&(s._bounds=new a(e.bounds.left,e.bounds.top,e.bounds.width,e.bounds.height)),e.boundsOffsets&&(s.boundsOffsets=e.boundsOffsets),mt(s)?(s.vertexCounter=e.vertexCounter,s.segmentCounter=e.segmentCounter,s.curveMode=e.curveMode):e.type===A.Image&&(s.src=e.src,s.width=e.width,s.height=e.height,s.x=e.x,s.y=e.y),t.addChild(s)}_loadLayout(t){let e=cd(t.type,t.args);switch(t.type){case v.Grid:e._left=t.left,e._top=t.top}return e}}class Ke{constructor(){}async run(t){let e,i,s={},n={},r={};for(let a of t)switch(a.cmd){case"scene":e=ld(a.args);break;case"data":i=await fd(a.url),n[a.output]=i;break;case"transform":n[a.output]=n[a.input].transform(a.type,a.args);break;case"mark":s[a.output]=e.mark(a.type,a.args);break;case"glyph":s[a.output]=e.glyph(...a.input.map((t=>s[t])));break;case"attach":e.attach(s[a.input],n[a.data]);break;case"repeat":{let t=e.repeat(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"divide":{let t=e.divide(s[a.input],n[a.data],a.args);s[a.output]=t;break}case"layout":s[a.input].layout=cd(a.type,a.args);break;case"sortChildren":"field"in a.args?s[a.input].sortChildrenByData(a.args.field,a.args.reverse,a.args.order):"channel"in a.args&&s[a.input].sortChildren(a.args.channel,a.args.reverse);break;case"scale":{let t=hd(a.type);t.id=a.id,t.domain="time"==a.type?a.domain.map((t=>new Date(t))):a.domain,t.range=a.range,t.clamp=a.clamp,t.isFlipped=a.isFlipped,"offset"in a&&(t.offset=a.offset),r[t.id]=t;break}case"encode":let t,o=a.input;if(o.indexOf("_v_")>0){let e=parseInt(o.split("_v_")[1]);t=s[o.split("_v_")[0]].vertices[e]}else if(o.indexOf("_v")>0);else if(o.indexOf("_s_")>0){let e=parseInt(o.split("_s_")[1]);t=s[o.split("_s_")[0]].segments[e]}else o.indexOf("_s")>0||(t=s[a.input]);a.scale&&r[a.scale]&&(a.args.scale=r[a.scale]),e.encode(t,a.args);break;case"constraint":switch(a.type){case T:e.affix(s[a.item],s[a.baseItem],a.channel,a.args)}break;case"axis":e.axis(a.channel,a.field,a.args);break;case"legend":e.legend(a.channel,a.field,a.args);break;case"gridlines":e.gridlines(a.channel,a.field,a.args)}return e}}let Qe=Math.PI/180;class ti{constructor(t){this._canvasId=t,this._doesCollectionHaveBounds=!1,this._app=new r.Application({antialias:!0,width:1600,height:1e3,view:document.getElementById(this._canvasId)}),this._app.renderer.autoResize=!0}render(t,e){let i=e||{};this._app.renderer.backgroundColor=si(t.fillColor?t.fillColor:"#fff"),this._doesCollectionHaveBounds=!!i.collectionBounds,this._app.stage.removeChildren(),this._app.renderer.clear();let s=this._renderItem(t);this._app.stage.addChild(s)}_renderItem(t){switch(t.type){case A.Ellipse:case A.LinearGradient:ai("mark",t,z.FEATURE_NOT_IMPLEMENTED);break;case A.Circle:return this._renderCircle(t);case A.Pie:return this._renderArc(t);case A.Area:return this._renderArea(t);case A.Polygon:return this._renderPolygon(t);case A.Axis:return this._renderAxis(t);case A.Collection:return this._renderCollection(t);case A.Glyph:case A.Group:case A.Gridlines:case A.Legend:case A.Scene:return this._renderGroup(t);case A.Path:return this._renderPath(t);case A.Line:return this._renderLinearPath(t);case A.Rect:return this._renderRectangle(t);case A.PointText:return this._renderText(t);case A.Arc:return this._renderArc(t);case A.Image:return this._renderImage(t);case A.Link:return this._renderLink(t);case A.Ring:return this._renderRing(t);default:throw console.log(t.type),new Error(`Expect: itemType, Actual: ${t}\nWait that's illegal`)}}_renderRectangle(t){let e=new i.Graphics;return ei(e,t.styles),e.lineStyle(t.styles.strokeWidth,si(t.styles.strokeColor)),oi(t.styles,e,t.height),e.drawRect(0,0,t.width,t.height),e.x=t.left,e.y=t.top,e.endFill(),e}_renderText(t){let e=new i.TextStyle({fontSize:t.styles.fontSize,fontFamily:t.styles.fontFamily,fontWeight:ii(t.styles.fontWeight),fill:si(t.styles.fillColor)}),s=new r.Text(t.text,e),n=new i.Container;ei(s,t.styles),s.x=t.x,s.y=t.y,s.anchor.set(...function(t){let e,i;switch(t[0]){case"left":e=0;break;case"center":e=.5;break;case"right":e=1;break;default:ai("x anchor",t[0],z.UNKNOWN_ANCHOR)}switch(t[1]){case"hanging":case"top":i=0;break;case"central":case"middle":i=.5;break;case"bottom":i=1;break;default:ai("y anchor",t[1],z.UNKNOWN_ANCHOR)}return[e,i]}(t.anchor)),n.addChild(s);let a=ri(t._rotate);return n.pivot.set(a[0],a[1]),n.angle=ni(t._rotate),n.position.set(a[0],a[1]),n}_renderGroup(t){let e=new i.Container;for(const i of t.children){let t=this._renderItem(i);if(null==t)throw new Error;e.addChild(t)}return e}_renderAxis(t){let e=this._renderGroup(t),i=ri(t._rotate);return e.pivot.set(i[0],i[1]),e.angle=ni(t._rotate),e.position.set(i[0],i[1]),e}_renderCollection(t){let e=new i.Container,s=this._renderGroup(t);if(e.addChild(s),!this._doesCollectionHaveBounds)return e;let n=new i.Graphics,r=0,a=t.bounds,o=a.left,l=a.right,h=a.top,c=a.bottom,d={strokeWidth:1,color:2018112,dashLength:5,dashSpacing:5};return r=u(o,l,h,r,d,n),r=u(h,c,-l,r,d,n),r=u(l,o,c,r,d,n),u(c,h,-o,r,d,n),e.addChild(n),e;function u(t,e,i,s,n,r){let a=t<=e?1:-1,o=s>=0?{point:t+s*a}:{point:t},l=i>0?[o,{point:i}]:[{point:-i},o];r.lineStyle({width:n.strokeWidth,color:n.color}),r.moveTo(l[0].point,l[1].point),o.point=s*a+t+n.dashLength*a,r.lineTo(l[0].point,l[1].point);let h=!1;for(o.point+=n.dashLength*a;o.point*a<=e*a;)h?(r.lineTo(l[0].point,l[1].point),h=!1,o.point+=n.dashSpacing*a):(r.moveTo(l[0].point,l[1].point),h=!0,o.point+=n.dashLength*a);return h?(i>0?r.lineTo(e,i):r.lineTo(-i,e),(e-o.point)*a):(o.point-e)*a}}_renderArea(t){switch(t.curveMode){case"linear":return this._renderPolygon(t);case"basis":return this._renderBezierArea(t);default:return ai("areaPath",t,z.FEATURE_NOT_IMPLEMENTED)}}_renderBezierArea(t){let e=new i.Graphics;ei(e,t.styles),e.lineStyle({width:t.styles.strokeWidth,color:si(t.styles.strokeColor)});let s=di(t.getSVGPathData());return oi(t.styles,e,t.bounds.height),hi(e,s),e.endFill(),e}_renderPolygon(t){let e=new r.Container,i=this._renderLinearPath(t);i.getChildAt(0).lineTo(t.vertices[0].x,t.vertices[0].y);let s=new r.Graphics;ei(s,t.styles);let n=[];for(const e of t.vertices)n.push(e.x-t.bounds.left),n.push(e.y-t.bounds.top);return oi(t.styles,s,t.bounds.height),s.drawPolygon(n),s.x+=t.bounds.left,s.y+=t.bounds.top,s.endFill(),e.addChild(s),e.addChild(i),e}_renderPath(t){switch(t.curveMode){case"linear":return this._renderLinearPath(t);case"bumpX":case"natural":return this._renderBezierPath(t);default:ai("path",t,z.FEATURE_NOT_IMPLEMENTED)}}_renderLinearPath(t){let e=new i.Container,s=new i.Graphics,n="none"==t.styles.strokeDash;ei(s,t.styles);let r=t.vertices[0];if(s.lineStyle({width:t.styles.strokeWidth,color:si(t.styles.strokeColor)}),s.moveTo(r.x,r.y),n)for(let e=1;e<t.vertices.length;e++){const i=t.vertices[e];s.lineTo(i.x,i.y)}else!function(t,e,i){let s,n,r,a=0,o=0,l=e.split(" "),h=Number(l[0]),c=Number(l[1]);for(s=0;s<t.length&&(n=t[s],s!=t.length-1);s++){r=t[s+1];let e=r.x-n.x,l=r.y-n.y,d=Math.sqrt(e*e+l*l),u={x:e/d,y:l/d},f=0;for(i.moveTo(n.x+o*u.x,n.y+o*u.y);f<=d;)f+=o,f+=a>0?a:h,f>d?(a=f-d,f=d):a=0,i.lineTo(n.x+f*u.x,n.y+f*u.y),f+=c,f>d&&0==a?o=f-d:(o=0,i.moveTo(n.x+f*u.x,n.y+f*u.y))}}(t.vertices,t.styles.strokeDash,s);e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderBezierPath(t){let e=new i.Container,s=new i.Graphics;ei(s,t.styles),s.lineStyle({width:t.styles.strokeWidth,color:si(t.styles.strokeColor)}),hi(s,di(t.getSVGPathData())),e.addChild(s);for(let i=0;i<t.vertices.length;i++){let s=t.vertices[i],n=this._renderVertex(s);null!=n&&e.addChild(n)}return e}_renderVertex(t){switch(t.shape){case"rect":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:si(t.strokeColor)}),e.beginFill(si(t.fillColor)),e.drawRect(t.x-t.width/2,t.y-t.height/2,t.width,t.height),e.endFill(),e}(t);case"circle":return function(t){let e=new r.Graphics;return e.lineStyle({width:t.strokeWidth,color:si(t.strokeColor)}),e.beginFill(si(t.fillColor)),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}(t);case void 0:return null;default:ai("vertex shape",t.shape,z.FEATURE_NOT_IMPLEMENTED)}}_renderCircle(t){let e=new i.Graphics;return ei(e,t.styles),e.lineStyle(t.styles.strokeWidth,si(t.styles.strokeColor)),oi(t.styles,e,t.height),e.drawCircle(t.x,t.y,t.radius),e.endFill(),e}_renderRing(t){let e=new i.Graphics;return e.lineStyle(t.outerRadius-t.innerRadius,si(t.styles.fillColor)),e.drawCircle(t.x,t.y,(t.innerRadius+t.outerRadius)/2),e.endFill(),e}_renderArc(t){let e=new i.Graphics;return e.lineStyle({color:si(t.styles.strokeColor),width:t.styles.strokeWidth}),e.beginFill(si(t.styles.fillColor)),e.arc(t.x,t.y,t.outerRadius,-t.endAngle*Qe,-t.startAngle*Qe),e.arc(t.x,t.y,t.innerRadius,-t.startAngle*Qe,-t.endAngle*Qe,!0),e.endFill(),e}_renderImage(t){let e=r.Sprite.from(t.src);return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}_renderLink(t){switch(t.curveMode){case"linear":return function(t){let e=new i.Graphics;return ei(e,t.styles),e.lineStyle({color:si(t.styles.strokeColor),width:t.styles.strokeWidth}),hi(e,di(t.getSVGPathData())),e}(t);default:ai("link",t.curveMode,"unexpected curvemode")}}}function ei(t,e){t.visible=function(t){switch(t){case"hidden":return!1;case null:case void 0:case"visible":default:return!0}}(e.visibility),t.alpha=function(t){switch(t){case void 0:case null:return 1;default:return t}}(e.opacity)}function ii(t){switch(t){case"regular":case"normal":return"normal";case"bold":return"bold";default:console.log(t),ai("font weight",t,z.FEATURE_NOT_IMPLEMENTED)}}function si(t){let e=n.color(t);if(null==e)return null;{let t=e.formatHex();return r.utils.string2hex(t)}}function ni(t){return void 0===t||"number"!=typeof t[0]?0:t[0]}function ri(t){return void 0===t||"number"!=typeof t[0]?[0,0]:t.slice(1)}function ai(t,e,i){throw console.log(e),new Error(`${i}. Source: ${t}, Actual: `)}function oi(t,e,i){let s=t.fillColor;if("none"==s)return;let n=si(s);null!=n?e.beginFill(n):e.beginTextureFill({color:16777215,texture:li(i,s.stops,s.y1>s.y2)})}function li(t,e,i){const s=document.createElement("canvas");s.height=t,s.width=1;const n=s.getContext("2d"),a=n.createLinearGradient(0,0,0,t);for(let t=0;t<e.length;t++)i?a.addColorStop(1-e[t].offset/100,e[t].color):a.addColorStop(e[t].offset/100,e[t].color);return n.fillStyle=a,n.fillRect(0,0,1,t),r.Texture.from(s)}function hi(t,e){let i=e.pop(),s=()=>{};"Z"==i.code.toUpperCase()?s=()=>t.lineTo(e[0].end.x,e[0].end.y):e.push(i);for(const i of e)ci(i,t);s()}function ci(t,e){switch(t.code.toUpperCase()){case"M":e.moveTo(t.end.x,t.end.y);break;case"L":e.lineTo(t.end.x,t.end.y);break;case"Q":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp1.x,t.cp1.y,t.end.x,t.end.y);break;case"C":e.bezierCurveTo(t.cp1.x,t.cp1.y,t.cp2.x,t.cp2.y,t.end.x,t.end.y);break;case"Z":throw new Error('Unexpected "z" marker. There\'s something wrong, I can feel it');default:return ai("data",t,z.FEATURE_NOT_IMPLEMENTED)}}function di(t){let e={command:/\s*([achlmqstvz])/gi,number:/\s*([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/gi,comma:/\s*(?:(,)|\s)/g,flag:/\s*([01])/g},i={number:function(t){return+a("number",t)},"coordinate pair":function(t){let e=a("number",t);return null!==e||t?(a("comma"),{x:+e,y:+a("number",!0)}):null},"arc definition":function(t){let e=i["coordinate pair"](t);if(!e&&!t)return null;a("comma");let s=+a("number",!0);a("comma",!0);let n=!!+a("flag",!0);a("comma");let r=!!+a("flag",!0);return a("comma"),{radii:e,rotation:s,large:n,clockwise:r,end:i["coordinate pair"](!0)}}},s=0,n=[];for(;s<t.length;){let t,e=a("command"),i=e.toUpperCase(),l=e!==i;switch(i){case"M":t=o("coordinate pair").map((function(t,i){return 1===i&&(e=l?"l":"L"),r({end:t},e,l)}));break;case"L":case"T":t=o("coordinate pair").map((function(t){return r({end:t},e,l)}));break;case"C":if(t=o("coordinate pair"),t.length%3)throw Error("Expected coordinate pair triplet at position "+s);t=t.reduce((function(t,i,s){let n=s%3;if(n){t[t.length-1][1===n?"cp2":"end"]=i}else t.push(r({cp1:i},e,l));return t}),[]);break;case"Q":case"S":if(t=o("coordinate pair"),1&t.length)throw Error("Expected coordinate pair couple at position "+s);t=t.reduce((function(t,i,s){if(1&s){t[t.length-1].end=i}else t.push(r({cp:i},e,l));return t}),[]);break;case"H":case"V":t=o("number").map((function(t){return r({value:t},e,l)}));break;case"A":t=o("arc definition").map(r,e,l);break;case"Z":t=[{code:"Z"}]}n.push.apply(n,t)}return n;function r(t,e,i){return t.code=e,t.relative=i,t}function a(i,n){e[i].lastIndex=s;let r=e[i].exec(t);if(!r||r.index!==s){if(!n)return null;throw Error("Expected "+i+" at position "+s)}return s=e[i].lastIndex,r[1]}function o(t){let e,s=[],n=!0;for(;null!==(e=i[t](n));)s.push(e),n=!!a("comma");return s}}var ui="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function fi(t,e){return t(e={exports:{}},e.exports),e.exports}var pi=function(){this.__data__=[],this.size=0};var gi=function(t,e){return t===e||t!=t&&e!=e};var _i=function(t,e){for(var i=t.length;i--;)if(gi(t[i][0],e))return i;return-1},mi=Array.prototype.splice;var yi=function(t){var e=this.__data__,i=_i(e,t);return!(i<0)&&(i==e.length-1?e.pop():mi.call(e,i,1),--this.size,!0)};var vi=function(t){var e=this.__data__,i=_i(e,t);return i<0?void 0:e[i][1]};var bi=function(t){return _i(this.__data__,t)>-1};var xi=function(t,e){var i=this.__data__,s=_i(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};function wi(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}wi.prototype.clear=pi,wi.prototype.delete=yi,wi.prototype.get=vi,wi.prototype.has=bi,wi.prototype.set=xi;var ki=wi;var Ci=function(){this.__data__=new ki,this.size=0};var Si=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Ei=function(t){return this.__data__.get(t)};var Ti=function(t){return this.__data__.has(t)},Ai="object"==typeof ui&&ui&&ui.Object===Object&&ui,Ii="object"==typeof self&&self&&self.Object===Object&&self,Oi=Ai||Ii||Function("return this")(),Ri=Oi.Symbol,Mi=Object.prototype,Ni=Mi.hasOwnProperty,Pi=Mi.toString,Fi=Ri?Ri.toStringTag:void 0;var Bi=
5
- /**
6
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
7
- *
8
- * @private
9
- * @param {*} value The value to query.
10
- * @returns {string} Returns the raw `toStringTag`.
11
- */
12
- function(t){var e=Ni.call(t,Fi),i=t[Fi];try{t[Fi]=void 0;var s=!0}catch(t){}var n=Pi.call(t);return s&&(e?t[Fi]=i:delete t[Fi]),n},Li=Object.prototype.toString;var ji=function(t){return Li.call(t)},Vi=Ri?Ri.toStringTag:void 0;var Di=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Vi&&Vi in Object(t)?Bi(t):ji(t)};var Gi=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};var zi,Wi=function(t){if(!Gi(t))return!1;var e=Di(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},Yi=Oi["__core-js_shared__"],Ui=(zi=/[^.]+$/.exec(Yi&&Yi.keys&&Yi.keys.IE_PROTO||""))?"Symbol(src)_1."+zi:"";var qi=function(t){return!!Ui&&Ui in t},Ji=Function.prototype.toString;var Xi=function(t){if(null!=t){try{return Ji.call(t)}catch(t){}try{return t+""}catch(t){}}return""},$i=/^\[object .+?Constructor\]$/,Hi=Function.prototype,Zi=Object.prototype,Ki=Hi.toString,Qi=Zi.hasOwnProperty,ts=RegExp("^"+Ki.call(Qi).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var es=function(t){return!(!Gi(t)||qi(t))&&(Wi(t)?ts:$i).test(Xi(t))};var is=function(t,e){return null==t?void 0:t[e]};var ss=function(t,e){var i=is(t,e);return es(i)?i:void 0},ns=ss(Oi,"Map"),rs=ss(Object,"create");var as=function(){this.__data__=rs?rs(null):{},this.size=0};var os=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},ls=Object.prototype.hasOwnProperty;var hs=function(t){var e=this.__data__;if(rs){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return ls.call(e,t)?e[t]:void 0},cs=Object.prototype.hasOwnProperty;var ds=function(t){var e=this.__data__;return rs?void 0!==e[t]:cs.call(e,t)};var us=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=rs&&void 0===e?"__lodash_hash_undefined__":e,this};function fs(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}fs.prototype.clear=as,fs.prototype.delete=os,fs.prototype.get=hs,fs.prototype.has=ds,fs.prototype.set=us;var ps=fs;var gs=function(){this.size=0,this.__data__={hash:new ps,map:new(ns||ki),string:new ps}};var _s=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var ms=function(t,e){var i=t.__data__;return _s(e)?i["string"==typeof e?"string":"hash"]:i.map};var ys=function(t){var e=ms(this,t).delete(t);return this.size-=e?1:0,e};var vs=function(t){return ms(this,t).get(t)};var bs=function(t){return ms(this,t).has(t)};var xs=function(t,e){var i=ms(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};function ws(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}ws.prototype.clear=gs,ws.prototype.delete=ys,ws.prototype.get=vs,ws.prototype.has=bs,ws.prototype.set=xs;var ks=ws;var Cs=function(t,e){var i=this.__data__;if(i instanceof ki){var s=i.__data__;if(!ns||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new ks(s)}return i.set(t,e),this.size=i.size,this};function Ss(t){var e=this.__data__=new ki(t);this.size=e.size}Ss.prototype.clear=Ci,Ss.prototype.delete=Si,Ss.prototype.get=Ei,Ss.prototype.has=Ti,Ss.prototype.set=Cs;var Es=Ss;
13
- /**
14
- * A specialized version of `_.forEach` for arrays without support for
15
- * iteratee shorthands.
16
- *
17
- * @private
18
- * @param {Array} [array] The array to iterate over.
19
- * @param {Function} iteratee The function invoked per iteration.
20
- * @returns {Array} Returns `array`.
21
- */var Ts=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s&&!1!==e(t[i],i,t););return t},As=function(){try{var t=ss(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();var Is=function(t,e,i){"__proto__"==e&&As?As(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i},Os=Object.prototype.hasOwnProperty;var Rs=function(t,e,i){var s=t[e];Os.call(t,e)&&gi(s,i)&&(void 0!==i||e in t)||Is(t,e,i)};var Ms=function(t,e,i,s){var n=!i;i||(i={});for(var r=-1,a=e.length;++r<a;){var o=e[r],l=s?s(i[o],t[o],o,i,t):void 0;void 0===l&&(l=t[o]),n?Is(i,o,l):Rs(i,o,l)}return i};var Ns=function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s};var Ps=function(t){return null!=t&&"object"==typeof t};var Fs=function(t){return Ps(t)&&"[object Arguments]"==Di(t)},Bs=Object.prototype,Ls=Bs.hasOwnProperty,js=Bs.propertyIsEnumerable,Vs=Fs(function(){return arguments}())?Fs:function(t){return Ps(t)&&Ls.call(t,"callee")&&!js.call(t,"callee")},Ds=Array.isArray;var Gs=function(){return!1},zs=fi((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?Oi.Buffer:void 0,r=(n?n.isBuffer:void 0)||Gs;t.exports=r})),Ws=/^(?:0|[1-9]\d*)$/;var Ys=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ws.test(t))&&t>-1&&t%1==0&&t<e};var Us=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},qs={};qs["[object Float32Array]"]=qs["[object Float64Array]"]=qs["[object Int8Array]"]=qs["[object Int16Array]"]=qs["[object Int32Array]"]=qs["[object Uint8Array]"]=qs["[object Uint8ClampedArray]"]=qs["[object Uint16Array]"]=qs["[object Uint32Array]"]=!0,qs["[object Arguments]"]=qs["[object Array]"]=qs["[object ArrayBuffer]"]=qs["[object Boolean]"]=qs["[object DataView]"]=qs["[object Date]"]=qs["[object Error]"]=qs["[object Function]"]=qs["[object Map]"]=qs["[object Number]"]=qs["[object Object]"]=qs["[object RegExp]"]=qs["[object Set]"]=qs["[object String]"]=qs["[object WeakMap]"]=!1;var Js=function(t){return Ps(t)&&Us(t.length)&&!!qs[Di(t)]};var Xs=function(t){return function(e){return t(e)}},$s=fi((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i&&Ai.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||n&&n.binding&&n.binding("util")}catch(t){}}();t.exports=r})),Hs=$s&&$s.isTypedArray,Zs=Hs?Xs(Hs):Js,Ks=Object.prototype.hasOwnProperty;var Qs=function(t,e){var i=Ds(t),s=!i&&Vs(t),n=!i&&!s&&zs(t),r=!i&&!s&&!n&&Zs(t),a=i||s||n||r,o=a?Ns(t.length,String):[],l=o.length;for(var h in t)!e&&!Ks.call(t,h)||a&&("length"==h||n&&("offset"==h||"parent"==h)||r&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||Ys(h,l))||o.push(h);return o},tn=Object.prototype;var en=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||tn)};var sn=function(t,e){return function(i){return t(e(i))}},nn=sn(Object.keys,Object),rn=Object.prototype.hasOwnProperty;var an=function(t){if(!en(t))return nn(t);var e=[];for(var i in Object(t))rn.call(t,i)&&"constructor"!=i&&e.push(i);return e};var on=function(t){return null!=t&&Us(t.length)&&!Wi(t)};var ln=function(t){return on(t)?Qs(t):an(t)};var hn=function(t,e){return t&&Ms(e,ln(e),t)};var cn=function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e},dn=Object.prototype.hasOwnProperty;var un=function(t){if(!Gi(t))return cn(t);var e=en(t),i=[];for(var s in t)("constructor"!=s||!e&&dn.call(t,s))&&i.push(s);return i};var fn=function(t){return on(t)?Qs(t,!0):un(t)};var pn=function(t,e){return t&&Ms(e,fn(e),t)},gn=fi((function(t,e){var i=e&&!e.nodeType&&e,s=i&&t&&!t.nodeType&&t,n=s&&s.exports===i?Oi.Buffer:void 0,r=n?n.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var i=t.length,s=r?r(i):new t.constructor(i);return t.copy(s),s}}));var _n=function(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e};
22
- /**
23
- * A specialized version of `_.filter` for arrays without support for
24
- * iteratee shorthands.
25
- *
26
- * @private
27
- * @param {Array} [array] The array to iterate over.
28
- * @param {Function} predicate The function invoked per iteration.
29
- * @returns {Array} Returns the new filtered array.
30
- */var mn=function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var a=t[i];e(a,i,t)&&(r[n++]=a)}return r};var yn=function(){return[]},vn=Object.prototype.propertyIsEnumerable,bn=Object.getOwnPropertySymbols,xn=bn?function(t){return null==t?[]:(t=Object(t),mn(bn(t),(function(e){return vn.call(t,e)})))}:yn;var wn=function(t,e){return Ms(t,xn(t),e)};var kn=function(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t},Cn=sn(Object.getPrototypeOf,Object),Sn=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)kn(e,xn(t)),t=Cn(t);return e}:yn;var En=function(t,e){return Ms(t,Sn(t),e)};var Tn=function(t,e,i){var s=e(t);return Ds(t)?s:kn(s,i(t))};var An=function(t){return Tn(t,ln,xn)};var In=function(t){return Tn(t,fn,Sn)},On=ss(Oi,"DataView"),Rn=ss(Oi,"Promise"),Mn=ss(Oi,"Set"),Nn=ss(Oi,"WeakMap"),Pn="[object Map]",Fn="[object Promise]",Bn="[object Set]",Ln="[object WeakMap]",jn="[object DataView]",Vn=Xi(On),Dn=Xi(ns),Gn=Xi(Rn),zn=Xi(Mn),Wn=Xi(Nn),Yn=Di;(On&&Yn(new On(new ArrayBuffer(1)))!=jn||ns&&Yn(new ns)!=Pn||Rn&&Yn(Rn.resolve())!=Fn||Mn&&Yn(new Mn)!=Bn||Nn&&Yn(new Nn)!=Ln)&&(Yn=function(t){var e=Di(t),i="[object Object]"==e?t.constructor:void 0,s=i?Xi(i):"";if(s)switch(s){case Vn:return jn;case Dn:return Pn;case Gn:return Fn;case zn:return Bn;case Wn:return Ln}return e});var Un=Yn,qn=Object.prototype.hasOwnProperty;var Jn=function(t){var e=t.length,i=new t.constructor(e);return e&&"string"==typeof t[0]&&qn.call(t,"index")&&(i.index=t.index,i.input=t.input),i},Xn=Oi.Uint8Array;var $n=function(t){var e=new t.constructor(t.byteLength);return new Xn(e).set(new Xn(t)),e};var Hn=function(t,e){var i=e?$n(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.byteLength)},Zn=/\w*$/;var Kn=function(t){var e=new t.constructor(t.source,Zn.exec(t));return e.lastIndex=t.lastIndex,e},Qn=Ri?Ri.prototype:void 0,tr=Qn?Qn.valueOf:void 0;var er=function(t){return tr?Object(tr.call(t)):{}};var ir=function(t,e){var i=e?$n(t.buffer):t.buffer;return new t.constructor(i,t.byteOffset,t.length)};var sr=function(t,e,i){var s=t.constructor;switch(e){case"[object ArrayBuffer]":return $n(t);case"[object Boolean]":case"[object Date]":return new s(+t);case"[object DataView]":return Hn(t,i);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return ir(t,i);case"[object Map]":return new s;case"[object Number]":case"[object String]":return new s(t);case"[object RegExp]":return Kn(t);case"[object Set]":return new s;case"[object Symbol]":return er(t)}},nr=Object.create,rr=function(){function t(){}return function(e){if(!Gi(e))return{};if(nr)return nr(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}();var ar=function(t){return"function"!=typeof t.constructor||en(t)?{}:rr(Cn(t))};var or=function(t){return Ps(t)&&"[object Map]"==Un(t)},lr=$s&&$s.isMap,hr=lr?Xs(lr):or;var cr=function(t){return Ps(t)&&"[object Set]"==Un(t)},dr=$s&&$s.isSet,ur=dr?Xs(dr):cr,fr="[object Arguments]",pr="[object Function]",gr="[object Object]",_r={};_r[fr]=_r["[object Array]"]=_r["[object ArrayBuffer]"]=_r["[object DataView]"]=_r["[object Boolean]"]=_r["[object Date]"]=_r["[object Float32Array]"]=_r["[object Float64Array]"]=_r["[object Int8Array]"]=_r["[object Int16Array]"]=_r["[object Int32Array]"]=_r["[object Map]"]=_r["[object Number]"]=_r[gr]=_r["[object RegExp]"]=_r["[object Set]"]=_r["[object String]"]=_r["[object Symbol]"]=_r["[object Uint8Array]"]=_r["[object Uint8ClampedArray]"]=_r["[object Uint16Array]"]=_r["[object Uint32Array]"]=!0,_r["[object Error]"]=_r[pr]=_r["[object WeakMap]"]=!1;var mr=function t(e,i,s,n,r,a){var o,l=1&i,h=2&i,c=4&i;if(s&&(o=r?s(e,n,r,a):s(e)),void 0!==o)return o;if(!Gi(e))return e;var d=Ds(e);if(d){if(o=Jn(e),!l)return _n(e,o)}else{var u=Un(e),f=u==pr||"[object GeneratorFunction]"==u;if(zs(e))return gn(e,l);if(u==gr||u==fr||f&&!r){if(o=h||f?{}:ar(e),!l)return h?En(e,pn(o,e)):wn(e,hn(o,e))}else{if(!_r[u])return r?e:{};o=sr(e,u,l)}}a||(a=new Es);var p=a.get(e);if(p)return p;a.set(e,o),ur(e)?e.forEach((function(n){o.add(t(n,i,s,n,e,a))})):hr(e)&&e.forEach((function(n,r){o.set(r,t(n,i,s,r,e,a))}));var g=d?void 0:(c?h?In:An:h?fn:ln)(e);return Ts(g||e,(function(n,r){g&&(n=e[r=n]),Rs(o,r,t(n,i,s,r,e,a))})),o};var yr=function(t){return mr(t,4)};var vr=function(t){return function(){return t}};var br=function(t){return function(e,i,s){for(var n=-1,r=Object(e),a=s(e),o=a.length;o--;){var l=a[t?o:++n];if(!1===i(r[l],l,r))break}return e}}();var xr=function(t,e){return t&&br(t,e,ln)};var wr=function(t,e){return function(i,s){if(null==i)return i;if(!on(i))return t(i,s);for(var n=i.length,r=e?n:-1,a=Object(i);(e?r--:++r<n)&&!1!==s(a[r],r,a););return i}}(xr);var kr=function(t){return t};var Cr=function(t){return"function"==typeof t?t:kr};var Sr=function(t,e){return(Ds(t)?Ts:wr)(t,Cr(e))},Er=Sr;var Tr=function(t,e){var i=[];return wr(t,(function(t,s,n){e(t,s,n)&&i.push(t)})),i};var Ar=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};var Ir=function(t){return this.__data__.has(t)};function Or(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new ks;++e<i;)this.add(t[e])}Or.prototype.add=Or.prototype.push=Ar,Or.prototype.has=Ir;var Rr=Or;
31
- /**
32
- * A specialized version of `_.some` for arrays without support for iteratee
33
- * shorthands.
34
- *
35
- * @private
36
- * @param {Array} [array] The array to iterate over.
37
- * @param {Function} predicate The function invoked per iteration.
38
- * @returns {boolean} Returns `true` if any element passes the predicate check,
39
- * else `false`.
40
- */var Mr=function(t,e){for(var i=-1,s=null==t?0:t.length;++i<s;)if(e(t[i],i,t))return!0;return!1};var Nr=function(t,e){return t.has(e)};var Pr=
41
- /**
42
- * A specialized version of `baseIsEqualDeep` for arrays with support for
43
- * partial deep comparisons.
44
- *
45
- * @private
46
- * @param {Array} array The array to compare.
47
- * @param {Array} other The other array to compare.
48
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
49
- * @param {Function} customizer The function to customize comparisons.
50
- * @param {Function} equalFunc The function to determine equivalents of values.
51
- * @param {Object} stack Tracks traversed `array` and `other` objects.
52
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
53
- */
54
- function(t,e,i,s,n,r){var a=1&i,o=t.length,l=e.length;if(o!=l&&!(a&&l>o))return!1;var h=r.get(t),c=r.get(e);if(h&&c)return h==e&&c==t;var d=-1,u=!0,f=2&i?new Rr:void 0;for(r.set(t,e),r.set(e,t);++d<o;){var p=t[d],g=e[d];if(s)var _=a?s(g,p,d,e,t,r):s(p,g,d,t,e,r);if(void 0!==_){if(_)continue;u=!1;break}if(f){if(!Mr(e,(function(t,e){if(!Nr(f,e)&&(p===t||n(p,t,i,s,r)))return f.push(e)}))){u=!1;break}}else if(p!==g&&!n(p,g,i,s,r)){u=!1;break}}return r.delete(t),r.delete(e),u};var Fr=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,s){i[++e]=[s,t]})),i};var Br=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},Lr=Ri?Ri.prototype:void 0,jr=Lr?Lr.valueOf:void 0;var Vr=
55
- /**
56
- * A specialized version of `baseIsEqualDeep` for comparing objects of
57
- * the same `toStringTag`.
58
- *
59
- * **Note:** This function only supports comparing values with tags of
60
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
61
- *
62
- * @private
63
- * @param {Object} object The object to compare.
64
- * @param {Object} other The other object to compare.
65
- * @param {string} tag The `toStringTag` of the objects to compare.
66
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
67
- * @param {Function} customizer The function to customize comparisons.
68
- * @param {Function} equalFunc The function to determine equivalents of values.
69
- * @param {Object} stack Tracks traversed `object` and `other` objects.
70
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
71
- */
72
- function(t,e,i,s,n,r,a){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new Xn(t),new Xn(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return gi(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var o=Fr;case"[object Set]":var l=1&s;if(o||(o=Br),t.size!=e.size&&!l)return!1;var h=a.get(t);if(h)return h==e;s|=2,a.set(t,e);var c=Pr(o(t),o(e),s,n,r,a);return a.delete(t),c;case"[object Symbol]":if(jr)return jr.call(t)==jr.call(e)}return!1},Dr=Object.prototype.hasOwnProperty;var Gr=
73
- /**
74
- * A specialized version of `baseIsEqualDeep` for objects with support for
75
- * partial deep comparisons.
76
- *
77
- * @private
78
- * @param {Object} object The object to compare.
79
- * @param {Object} other The other object to compare.
80
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
81
- * @param {Function} customizer The function to customize comparisons.
82
- * @param {Function} equalFunc The function to determine equivalents of values.
83
- * @param {Object} stack Tracks traversed `object` and `other` objects.
84
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
85
- */
86
- function(t,e,i,s,n,r){var a=1&i,o=An(t),l=o.length;if(l!=An(e).length&&!a)return!1;for(var h=l;h--;){var c=o[h];if(!(a?c in e:Dr.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var f=!0;r.set(t,e),r.set(e,t);for(var p=a;++h<l;){var g=t[c=o[h]],_=e[c];if(s)var m=a?s(_,g,c,e,t,r):s(g,_,c,t,e,r);if(!(void 0===m?g===_||n(g,_,i,s,r):m)){f=!1;break}p||(p="constructor"==c)}if(f&&!p){var y=t.constructor,v=e.constructor;y==v||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof v&&v instanceof v||(f=!1)}return r.delete(t),r.delete(e),f},zr="[object Arguments]",Wr="[object Array]",Yr="[object Object]",Ur=Object.prototype.hasOwnProperty;var qr=
87
- /**
88
- * A specialized version of `baseIsEqual` for arrays and objects which performs
89
- * deep comparisons and tracks traversed objects enabling objects with circular
90
- * references to be compared.
91
- *
92
- * @private
93
- * @param {Object} object The object to compare.
94
- * @param {Object} other The other object to compare.
95
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
96
- * @param {Function} customizer The function to customize comparisons.
97
- * @param {Function} equalFunc The function to determine equivalents of values.
98
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
99
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
100
- */
101
- function(t,e,i,s,n,r){var a=Ds(t),o=Ds(e),l=a?Wr:Un(t),h=o?Wr:Un(e),c=(l=l==zr?Yr:l)==Yr,d=(h=h==zr?Yr:h)==Yr,u=l==h;if(u&&zs(t)){if(!zs(e))return!1;a=!0,c=!1}if(u&&!c)return r||(r=new Es),a||Zs(t)?Pr(t,e,i,s,n,r):Vr(t,e,l,i,s,n,r);if(!(1&i)){var f=c&&Ur.call(t,"__wrapped__"),p=d&&Ur.call(e,"__wrapped__");if(f||p){var g=f?t.value():t,_=p?e.value():e;return r||(r=new Es),n(g,_,i,s,r)}}return!!u&&(r||(r=new Es),Gr(t,e,i,s,n,r))};var Jr=function t(e,i,s,n,r){return e===i||(null==e||null==i||!Ps(e)&&!Ps(i)?e!=e&&i!=i:qr(e,i,s,n,t,r))};var Xr=function(t,e,i,s){var n=i.length,r=n,a=!s;if(null==t)return!r;for(t=Object(t);n--;){var o=i[n];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++n<r;){var l=(o=i[n])[0],h=t[l],c=o[1];if(a&&o[2]){if(void 0===h&&!(l in t))return!1}else{var d=new Es;if(s)var u=s(h,c,l,t,e,d);if(!(void 0===u?Jr(c,h,3,s,d):u))return!1}}return!0};var $r=function(t){return t==t&&!Gi(t)};var Hr=function(t){for(var e=ln(t),i=e.length;i--;){var s=e[i],n=t[s];e[i]=[s,n,$r(n)]}return e};
102
- /**
103
- * A specialized version of `matchesProperty` for source values suitable
104
- * for strict equality comparisons, i.e. `===`.
105
- *
106
- * @private
107
- * @param {string} key The key of the property to get.
108
- * @param {*} srcValue The value to match.
109
- * @returns {Function} Returns the new spec function.
110
- */var Zr=function(t,e){return function(i){return null!=i&&(i[t]===e&&(void 0!==e||t in Object(i)))}};var Kr=function(t){var e=Hr(t);return 1==e.length&&e[0][2]?Zr(e[0][0],e[0][1]):function(i){return i===t||Xr(i,t,e)}};var Qr=function(t){return"symbol"==typeof t||Ps(t)&&"[object Symbol]"==Di(t)},ta=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ea=/^\w*$/;var ia=function(t,e){if(Ds(t))return!1;var i=typeof t;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=t&&!Qr(t))||(ea.test(t)||!ta.test(t)||null!=e&&t in Object(e))};function sa(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var i=function(){var s=arguments,n=e?e.apply(this,s):s[0],r=i.cache;if(r.has(n))return r.get(n);var a=t.apply(this,s);return i.cache=r.set(n,a)||r,a};return i.cache=new(sa.Cache||ks),i}sa.Cache=ks;var na=sa;var ra=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,aa=/\\(\\)?/g,oa=
111
- /**
112
- * A specialized version of `_.memoize` which clears the memoized function's
113
- * cache when it exceeds `MAX_MEMOIZE_SIZE`.
114
- *
115
- * @private
116
- * @param {Function} func The function to have its output memoized.
117
- * @returns {Function} Returns the new memoized function.
118
- */
119
- function(t){var e=na(t,(function(t){return 500===i.size&&i.clear(),t})),i=e.cache;return e}((function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ra,(function(t,i,s,n){e.push(s?n.replace(aa,"$1"):i||t)})),e}));var la=
120
- /**
121
- * A specialized version of `_.map` for arrays without support for iteratee
122
- * shorthands.
123
- *
124
- * @private
125
- * @param {Array} [array] The array to iterate over.
126
- * @param {Function} iteratee The function invoked per iteration.
127
- * @returns {Array} Returns the new mapped array.
128
- */
129
- function(t,e){for(var i=-1,s=null==t?0:t.length,n=Array(s);++i<s;)n[i]=e(t[i],i,t);return n},ha=Ri?Ri.prototype:void 0,ca=ha?ha.toString:void 0;var da=function t(e){if("string"==typeof e)return e;if(Ds(e))return la(e,t)+"";if(Qr(e))return ca?ca.call(e):"";var i=e+"";return"0"==i&&1/e==-Infinity?"-0":i};var ua=function(t){return null==t?"":da(t)};var fa=function(t,e){return Ds(t)?t:ia(t,e)?[t]:oa(ua(t))};var pa=function(t){if("string"==typeof t||Qr(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e};var ga=function(t,e){for(var i=0,s=(e=fa(e,t)).length;null!=t&&i<s;)t=t[pa(e[i++])];return i&&i==s?t:void 0};var _a=function(t,e,i){var s=null==t?void 0:ga(t,e);return void 0===s?i:s};var ma=function(t,e){return null!=t&&e in Object(t)};var ya=function(t,e,i){for(var s=-1,n=(e=fa(e,t)).length,r=!1;++s<n;){var a=pa(e[s]);if(!(r=null!=t&&i(t,a)))break;t=t[a]}return r||++s!=n?r:!!(n=null==t?0:t.length)&&Us(n)&&Ys(a,n)&&(Ds(t)||Vs(t))};var va=function(t,e){return null!=t&&ya(t,e,ma)};var ba=function(t,e){return ia(t)&&$r(e)?Zr(pa(t),e):function(i){var s=_a(i,t);return void 0===s&&s===e?va(i,t):Jr(e,s,3)}};var xa=function(t){return function(e){return null==e?void 0:e[t]}};
130
- /**
131
- * A specialized version of `baseProperty` which supports deep paths.
132
- *
133
- * @private
134
- * @param {Array|string} path The path of the property to get.
135
- * @returns {Function} Returns the new accessor function.
136
- */var wa=function(t){return function(e){return ga(e,t)}};var ka=function(t){return ia(t)?xa(pa(t)):wa(t)};var Ca=function(t){return"function"==typeof t?t:null==t?kr:"object"==typeof t?Ds(t)?ba(t[0],t[1]):Kr(t):ka(t)};var Sa=function(t,e){return(Ds(t)?mn:Tr)(t,Ca(e))},Ea=Object.prototype.hasOwnProperty;var Ta=function(t,e){return null!=t&&Ea.call(t,e)};var Aa=function(t,e){return null!=t&&ya(t,e,Ta)},Ia=Object.prototype.hasOwnProperty;var Oa=function(t){if(null==t)return!0;if(on(t)&&(Ds(t)||"string"==typeof t||"function"==typeof t.splice||zs(t)||Zs(t)||Vs(t)))return!t.length;var e=Un(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(en(t))return!an(t).length;for(var i in t)if(Ia.call(t,i))return!1;return!0};var Ra=function(t){return void 0===t};var Ma=function(t,e){var i=-1,s=on(t)?Array(t.length):[];return wr(t,(function(t,n,r){s[++i]=e(t,n,r)})),s};var Na=function(t,e){return(Ds(t)?la:Ma)(t,Ca(e))};
137
- /**
138
- * A specialized version of `_.reduce` for arrays without support for
139
- * iteratee shorthands.
140
- *
141
- * @private
142
- * @param {Array} [array] The array to iterate over.
143
- * @param {Function} iteratee The function invoked per iteration.
144
- * @param {*} [accumulator] The initial value.
145
- * @param {boolean} [initAccum] Specify using the first element of `array` as
146
- * the initial value.
147
- * @returns {*} Returns the accumulated value.
148
- */var Pa=function(t,e,i,s){var n=-1,r=null==t?0:t.length;for(s&&r&&(i=t[++n]);++n<r;)i=e(i,t[n],n,t);return i};var Fa=function(t,e,i,s,n){return n(t,(function(t,n,r){i=s?(s=!1,t):e(i,t,n,r)})),i};var Ba=function(t,e,i){var s=Ds(t)?Pa:Fa,n=arguments.length<3;return s(t,Ca(e),i,n,wr)};var La=function(t){return"string"==typeof t||!Ds(t)&&Ps(t)&&"[object String]"==Di(t)},ja=xa("length"),Va=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var Da=function(t){return Va.test(t)},Ga="[\\ud800-\\udfff]",za="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Wa="\\ud83c[\\udffb-\\udfff]",Ya="[^\\ud800-\\udfff]",Ua="(?:\\ud83c[\\udde6-\\uddff]){2}",qa="[\\ud800-\\udbff][\\udc00-\\udfff]",Ja="(?:"+za+"|"+Wa+")"+"?",Xa="[\\ufe0e\\ufe0f]?",$a=Xa+Ja+("(?:\\u200d(?:"+[Ya,Ua,qa].join("|")+")"+Xa+Ja+")*"),Ha="(?:"+[Ya+za+"?",za,Ua,qa,Ga].join("|")+")",Za=RegExp(Wa+"(?="+Wa+")|"+Ha+$a,"g");var Ka=function(t){for(var e=Za.lastIndex=0;Za.test(t);)++e;return e};var Qa=function(t){return Da(t)?Ka(t):ja(t)};var to=function(t){if(null==t)return 0;if(on(t))return La(t)?Qa(t):t.length;var e=Un(t);return"[object Map]"==e||"[object Set]"==e?t.size:an(t).length};var eo=function(t,e,i){var s=Ds(t),n=s||zs(t)||Zs(t);if(e=Ca(e),null==i){var r=t&&t.constructor;i=n?s?new r:[]:Gi(t)&&Wi(r)?rr(Cn(t)):{}}return(n?Ts:xr)(t,(function(t,s,n){return e(i,t,s,n)})),i},io=Ri?Ri.isConcatSpreadable:void 0;var so=function(t){return Ds(t)||Vs(t)||!!(io&&t&&t[io])};var no=function t(e,i,s,n,r){var a=-1,o=e.length;for(s||(s=so),r||(r=[]);++a<o;){var l=e[a];i>0&&s(l)?i>1?t(l,i-1,s,n,r):kn(r,l):n||(r[r.length]=l)}return r};var ro=function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)},ao=Math.max;var oo=
149
- /**
150
- * A specialized version of `baseRest` which transforms the rest array.
151
- *
152
- * @private
153
- * @param {Function} func The function to apply a rest parameter to.
154
- * @param {number} [start=func.length-1] The start position of the rest parameter.
155
- * @param {Function} transform The rest array transform.
156
- * @returns {Function} Returns the new function.
157
- */
158
- function(t,e,i){return e=ao(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=ao(s.length-e,0),a=Array(r);++n<r;)a[n]=s[e+n];n=-1;for(var o=Array(e+1);++n<e;)o[n]=s[n];return o[e]=i(a),ro(t,this,o)}},lo=As?function(t,e){return As(t,"toString",{configurable:!0,enumerable:!1,value:vr(e),writable:!0})}:kr,ho=Date.now;var co=function(t){var e=0,i=0;return function(){var s=ho(),n=16-(s-i);if(i=s,n>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(lo);var uo=function(t,e){return co(oo(t,e,kr),t+"")};var fo=function(t,e,i,s){for(var n=t.length,r=i+(s?1:-1);s?r--:++r<n;)if(e(t[r],r,t))return r;return-1};var po=function(t){return t!=t};
159
- /**
160
- * A specialized version of `_.indexOf` which performs strict equality
161
- * comparisons of values, i.e. `===`.
162
- *
163
- * @private
164
- * @param {Array} array The array to inspect.
165
- * @param {*} value The value to search for.
166
- * @param {number} fromIndex The index to search from.
167
- * @returns {number} Returns the index of the matched value, else `-1`.
168
- */var go=function(t,e,i){for(var s=i-1,n=t.length;++s<n;)if(t[s]===e)return s;return-1};var _o=function(t,e,i){return e==e?go(t,e,i):fo(t,po,i)};
169
- /**
170
- * A specialized version of `_.includes` for arrays without support for
171
- * specifying an index to search from.
172
- *
173
- * @private
174
- * @param {Array} [array] The array to inspect.
175
- * @param {*} target The value to search for.
176
- * @returns {boolean} Returns `true` if `target` is found, else `false`.
177
- */var mo=function(t,e){return!!(null==t?0:t.length)&&_o(t,e,0)>-1};var yo=function(t,e,i){for(var s=-1,n=null==t?0:t.length;++s<n;)if(i(e,t[s]))return!0;return!1};var vo=function(){},bo=Mn&&1/Br(new Mn([,-0]))[1]==1/0?function(t){return new Mn(t)}:vo;var xo=function(t,e,i){var s=-1,n=mo,r=t.length,a=!0,o=[],l=o;if(i)a=!1,n=yo;else if(r>=200){var h=e?null:bo(t);if(h)return Br(h);a=!1,n=Nr,l=new Rr}else l=e?[]:o;t:for(;++s<r;){var c=t[s],d=e?e(c):c;if(c=i||0!==c?c:0,a&&d==d){for(var u=l.length;u--;)if(l[u]===d)continue t;e&&l.push(d),o.push(c)}else n(l,d,i)||(l!==o&&l.push(d),o.push(c))}return o};var wo=function(t){return Ps(t)&&on(t)},ko=uo((function(t){return xo(no(t,1,wo,!0))}));var Co=function(t,e){return la(e,(function(e){return t[e]}))};var So,Eo=function(t){return null==t?[]:Co(t,ln(t))};try{So={clone:yr,constant:vr,each:Er,filter:Sa,has:Aa,isArray:Ds,isEmpty:Oa,isFunction:Wi,isUndefined:Ra,keys:ln,map:Na,reduce:Ba,size:to,transform:eo,union:ko,values:Eo}}catch(t){}So||(So=window._);var To=So,Ao=Oo,Io="\0";function Oo(t){this._isDirected=!To.has(t,"directed")||t.directed,this._isMultigraph=!!To.has(t,"multigraph")&&t.multigraph,this._isCompound=!!To.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=To.constant(void 0),this._defaultEdgeLabelFn=To.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function Ro(t,e){t[e]?t[e]++:t[e]=1}function Mo(t,e){--t[e]||delete t[e]}function No(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}return n+""+r+""+(To.isUndefined(s)?"\0":s)}function Po(t,e,i,s){var n=""+e,r=""+i;if(!t&&n>r){var a=n;n=r,r=a}var o={v:n,w:r};return s&&(o.name=s),o}function Fo(t,e){return No(t,e.v,e.w,e.name)}Oo.prototype._nodeCount=0,Oo.prototype._edgeCount=0,Oo.prototype.isDirected=function(){return this._isDirected},Oo.prototype.isMultigraph=function(){return this._isMultigraph},Oo.prototype.isCompound=function(){return this._isCompound},Oo.prototype.setGraph=function(t){return this._label=t,this},Oo.prototype.graph=function(){return this._label},Oo.prototype.setDefaultNodeLabel=function(t){return To.isFunction(t)||(t=To.constant(t)),this._defaultNodeLabelFn=t,this},Oo.prototype.nodeCount=function(){return this._nodeCount},Oo.prototype.nodes=function(){return To.keys(this._nodes)},Oo.prototype.sources=function(){var t=this;return To.filter(this.nodes(),(function(e){return To.isEmpty(t._in[e])}))},Oo.prototype.sinks=function(){var t=this;return To.filter(this.nodes(),(function(e){return To.isEmpty(t._out[e])}))},Oo.prototype.setNodes=function(t,e){var i=arguments,s=this;return To.each(t,(function(t){i.length>1?s.setNode(t,e):s.setNode(t)})),this},Oo.prototype.setNode=function(t,e){return To.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=e),this):(this._nodes[t]=arguments.length>1?e:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=Io,this._children[t]={},this._children["\0"][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},Oo.prototype.node=function(t){return this._nodes[t]},Oo.prototype.hasNode=function(t){return To.has(this._nodes,t)},Oo.prototype.removeNode=function(t){var e=this;if(To.has(this._nodes,t)){var i=function(t){e.removeEdge(e._edgeObjs[t])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],To.each(this.children(t),(function(t){e.setParent(t)})),delete this._children[t]),To.each(To.keys(this._in[t]),i),delete this._in[t],delete this._preds[t],To.each(To.keys(this._out[t]),i),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},Oo.prototype.setParent=function(t,e){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(To.isUndefined(e))e=Io;else{for(var i=e+="";!To.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+e+" as parent of "+t+" would create a cycle");this.setNode(e)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=e,this._children[e][t]=!0,this},Oo.prototype._removeFromParentsChildList=function(t){delete this._children[this._parent[t]][t]},Oo.prototype.parent=function(t){if(this._isCompound){var e=this._parent[t];if(e!==Io)return e}},Oo.prototype.children=function(t){if(To.isUndefined(t)&&(t=Io),this._isCompound){var e=this._children[t];if(e)return To.keys(e)}else{if(t===Io)return this.nodes();if(this.hasNode(t))return[]}},Oo.prototype.predecessors=function(t){var e=this._preds[t];if(e)return To.keys(e)},Oo.prototype.successors=function(t){var e=this._sucs[t];if(e)return To.keys(e)},Oo.prototype.neighbors=function(t){var e=this.predecessors(t);if(e)return To.union(e,this.successors(t))},Oo.prototype.isLeaf=function(t){return 0===(this.isDirected()?this.successors(t):this.neighbors(t)).length},Oo.prototype.filterNodes=function(t){var e=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});e.setGraph(this.graph());var i=this;To.each(this._nodes,(function(i,s){t(s)&&e.setNode(s,i)})),To.each(this._edgeObjs,(function(t){e.hasNode(t.v)&&e.hasNode(t.w)&&e.setEdge(t,i.edge(t))}));var s={};function n(t){var r=i.parent(t);return void 0===r||e.hasNode(r)?(s[t]=r,r):r in s?s[r]:n(r)}return this._isCompound&&To.each(e.nodes(),(function(t){e.setParent(t,n(t))})),e},Oo.prototype.setDefaultEdgeLabel=function(t){return To.isFunction(t)||(t=To.constant(t)),this._defaultEdgeLabelFn=t,this},Oo.prototype.edgeCount=function(){return this._edgeCount},Oo.prototype.edges=function(){return To.values(this._edgeObjs)},Oo.prototype.setPath=function(t,e){var i=this,s=arguments;return To.reduce(t,(function(t,n){return s.length>1?i.setEdge(t,n,e):i.setEdge(t,n),n})),this},Oo.prototype.setEdge=function(){var t,e,i,s,n=!1,r=arguments[0];"object"==typeof r&&null!==r&&"v"in r?(t=r.v,e=r.w,i=r.name,2===arguments.length&&(s=arguments[1],n=!0)):(t=r,e=arguments[1],i=arguments[3],arguments.length>2&&(s=arguments[2],n=!0)),t=""+t,e=""+e,To.isUndefined(i)||(i=""+i);var a=No(this._isDirected,t,e,i);if(To.has(this._edgeLabels,a))return n&&(this._edgeLabels[a]=s),this;if(!To.isUndefined(i)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(e),this._edgeLabels[a]=n?s:this._defaultEdgeLabelFn(t,e,i);var o=Po(this._isDirected,t,e,i);return t=o.v,e=o.w,Object.freeze(o),this._edgeObjs[a]=o,Ro(this._preds[e],t),Ro(this._sucs[t],e),this._in[e][a]=o,this._out[t][a]=o,this._edgeCount++,this},Oo.prototype.edge=function(t,e,i){var s=1===arguments.length?Fo(this._isDirected,arguments[0]):No(this._isDirected,t,e,i);return this._edgeLabels[s]},Oo.prototype.hasEdge=function(t,e,i){var s=1===arguments.length?Fo(this._isDirected,arguments[0]):No(this._isDirected,t,e,i);return To.has(this._edgeLabels,s)},Oo.prototype.removeEdge=function(t,e,i){var s=1===arguments.length?Fo(this._isDirected,arguments[0]):No(this._isDirected,t,e,i),n=this._edgeObjs[s];return n&&(t=n.v,e=n.w,delete this._edgeLabels[s],delete this._edgeObjs[s],Mo(this._preds[e],t),Mo(this._sucs[t],e),delete this._in[e][s],delete this._out[t][s],this._edgeCount--),this},Oo.prototype.inEdges=function(t,e){var i=this._in[t];if(i){var s=To.values(i);return e?To.filter(s,(function(t){return t.v===e})):s}},Oo.prototype.outEdges=function(t,e){var i=this._out[t];if(i){var s=To.values(i);return e?To.filter(s,(function(t){return t.w===e})):s}},Oo.prototype.nodeEdges=function(t,e){var i=this.inEdges(t,e);if(i)return i.concat(this.outEdges(t,e))};var Bo={Graph:Ao,version:"2.1.8"},Lo={write:function(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:jo(t),edges:Vo(t)};To.isUndefined(t.graph())||(e.value=To.clone(t.graph()));return e},read:function(t){var e=new Ao(t.options).setGraph(t.value);return To.each(t.nodes,(function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)})),To.each(t.edges,(function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)})),e}};function jo(t){return To.map(t.nodes(),(function(e){var i=t.node(e),s=t.parent(e),n={v:e};return To.isUndefined(i)||(n.value=i),To.isUndefined(s)||(n.parent=s),n}))}function Vo(t){return To.map(t.edges(),(function(e){var i=t.edge(e),s={v:e.v,w:e.w};return To.isUndefined(e.name)||(s.name=e.name),To.isUndefined(i)||(s.value=i),s}))}var Do=function(t){var e,i={},s=[];function n(s){To.has(i,s)||(i[s]=!0,e.push(s),To.each(t.successors(s),n),To.each(t.predecessors(s),n))}return To.each(t.nodes(),(function(t){e=[],n(t),e.length&&s.push(e)})),s};var Go=zo;function zo(){this._arr=[],this._keyIndices={}}zo.prototype.size=function(){return this._arr.length},zo.prototype.keys=function(){return this._arr.map((function(t){return t.key}))},zo.prototype.has=function(t){return To.has(this._keyIndices,t)},zo.prototype.priority=function(t){var e=this._keyIndices[t];if(void 0!==e)return this._arr[e].priority},zo.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},zo.prototype.add=function(t,e){var i=this._keyIndices;if(t=String(t),!To.has(i,t)){var s=this._arr,n=s.length;return i[t]=n,s.push({key:t,priority:e}),this._decrease(n),!0}return!1},zo.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},zo.prototype.decrease=function(t,e){var i=this._keyIndices[t];if(e>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[i].priority+" New: "+e);this._arr[i].priority=e,this._decrease(i)},zo.prototype._heapify=function(t){var e=this._arr,i=2*t,s=i+1,n=t;i<e.length&&(n=e[i].priority<e[n].priority?i:n,s<e.length&&(n=e[s].priority<e[n].priority?s:n),n!==t&&(this._swap(t,n),this._heapify(n)))},zo.prototype._decrease=function(t){for(var e,i=this._arr,s=i[t].priority;0!==t&&!(i[e=t>>1].priority<s);)this._swap(t,e),t=e},zo.prototype._swap=function(t,e){var i=this._arr,s=this._keyIndices,n=i[t],r=i[e];i[t]=r,i[e]=n,s[r.key]=t,s[n.key]=e};var Wo=function(t,e,i,s){return function(t,e,i,s){var n,r,a={},o=new Go,l=function(t){var e=t.v!==n?t.v:t.w,s=a[e],l=i(t),h=r.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+t+" Weight: "+l);h<s.distance&&(s.distance=h,s.predecessor=n,o.decrease(e,h))};t.nodes().forEach((function(t){var i=t===e?0:Number.POSITIVE_INFINITY;a[t]={distance:i},o.add(t,i)}));for(;o.size()>0&&(n=o.removeMin(),(r=a[n]).distance!==Number.POSITIVE_INFINITY);)s(n).forEach(l);return a}(t,String(e),i||Yo,s||function(e){return t.outEdges(e)})},Yo=To.constant(1);var Uo=function(t,e,i){return To.transform(t.nodes(),(function(s,n){s[n]=Wo(t,n,e,i)}),{})};var qo=function(t){var e=0,i=[],s={},n=[];function r(a){var o=s[a]={onStack:!0,lowlink:e,index:e++};if(i.push(a),t.successors(a).forEach((function(t){To.has(s,t)?s[t].onStack&&(o.lowlink=Math.min(o.lowlink,s[t].index)):(r(t),o.lowlink=Math.min(o.lowlink,s[t].lowlink))})),o.lowlink===o.index){var l,h=[];do{l=i.pop(),s[l].onStack=!1,h.push(l)}while(a!==l);n.push(h)}}return t.nodes().forEach((function(t){To.has(s,t)||r(t)})),n};var Jo=function(t){return To.filter(qo(t),(function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))};var Xo=function(t,e,i){return function(t,e,i){var s={},n=t.nodes();return n.forEach((function(t){s[t]={},s[t][t]={distance:0},n.forEach((function(e){t!==e&&(s[t][e]={distance:Number.POSITIVE_INFINITY})})),i(t).forEach((function(i){var n=i.v===t?i.w:i.v,r=e(i);s[t][n]={distance:r,predecessor:t}}))})),n.forEach((function(t){var e=s[t];n.forEach((function(i){var r=s[i];n.forEach((function(i){var s=r[t],n=e[i],a=r[i],o=s.distance+n.distance;o<a.distance&&(a.distance=o,a.predecessor=n.predecessor)}))}))})),s}(t,e||$o,i||function(e){return t.outEdges(e)})},$o=To.constant(1);var Ho=Zo;function Zo(t){var e={},i={},s=[];if(To.each(t.sinks(),(function n(r){if(To.has(i,r))throw new Ko;To.has(e,r)||(i[r]=!0,e[r]=!0,To.each(t.predecessors(r),n),delete i[r],s.push(r))})),To.size(e)!==t.nodeCount())throw new Ko;return s}function Ko(){}Zo.CycleException=Ko,Ko.prototype=new Error;var Qo=function(t,e,i){To.isArray(e)||(e=[e]);var s=(t.isDirected()?t.successors:t.neighbors).bind(t),n=[],r={};return To.each(e,(function(e){if(!t.hasNode(e))throw new Error("Graph does not have node: "+e);tl(t,e,"post"===i,r,s,n)})),n};function tl(t,e,i,s,n,r){To.has(s,e)||(s[e]=!0,i||r.push(e),To.each(n(e),(function(e){tl(t,e,i,s,n,r)})),i&&r.push(e))}var el,il={components:Do,dijkstra:Wo,dijkstraAll:Uo,findCycles:Jo,floydWarshall:Xo,isAcyclic:function(t){try{Ho(t)}catch(t){if(t instanceof Ho.CycleException)return!1;throw t}return!0},postorder:function(t,e){return Qo(t,e,"post")},preorder:function(t,e){return Qo(t,e,"pre")},prim:function(t,e){var i,s=new Ao,n={},r=new Go;function a(t){var s=t.v===i?t.w:t.v,a=r.priority(s);if(void 0!==a){var o=e(t);o<a&&(n[s]=i,r.decrease(s,o))}}if(0===t.nodeCount())return s;To.each(t.nodes(),(function(t){r.add(t,Number.POSITIVE_INFINITY),s.setNode(t)})),r.decrease(t.nodes()[0],0);var o=!1;for(;r.size()>0;){if(i=r.removeMin(),To.has(n,i))s.setEdge(i,n[i]);else{if(o)throw new Error("Input graph is not connected: "+t);o=!0}t.nodeEdges(i).forEach(a)}return s},tarjan:qo,topsort:Ho},sl={Graph:Bo.Graph,json:Lo,alg:il,version:Bo.version};try{el=sl}catch(t){}el||(el=window.graphlib);var nl=el;var rl=function(t){return mr(t,5)};var al=function(t,e,i){if(!Gi(i))return!1;var s=typeof e;return!!("number"==s?on(i)&&Ys(e,i.length):"string"==s&&e in i)&&gi(i[e],t)},ol=Object.prototype,ll=ol.hasOwnProperty,hl=uo((function(t,e){t=Object(t);var i=-1,s=e.length,n=s>2?e[2]:void 0;for(n&&al(e[0],e[1],n)&&(s=1);++i<s;)for(var r=e[i],a=fn(r),o=-1,l=a.length;++o<l;){var h=a[o],c=t[h];(void 0===c||gi(c,ol[h])&&!ll.call(t,h))&&(t[h]=r[h])}return t}));var cl=function(t){return function(e,i,s){var n=Object(e);if(!on(e)){var r=Ca(i);e=ln(e),i=function(t){return r(n[t],t,n)}}var a=t(e,i,s);return a>-1?n[r?e[a]:a]:void 0}},dl=/\s/;var ul=function(t){for(var e=t.length;e--&&dl.test(t.charAt(e)););return e},fl=/^\s+/;var pl=function(t){return t?t.slice(0,ul(t)+1).replace(fl,""):t},gl=/^[-+]0x[0-9a-f]+$/i,_l=/^0b[01]+$/i,ml=/^0o[0-7]+$/i,yl=parseInt;var vl=function(t){if("number"==typeof t)return t;if(Qr(t))return NaN;if(Gi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Gi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=pl(t);var i=_l.test(t);return i||ml.test(t)?yl(t.slice(2),i?2:8):gl.test(t)?NaN:+t},bl=1/0;var xl=function(t){return t?(t=vl(t))===bl||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0};var wl=function(t){var e=xl(t),i=e%1;return e==e?i?e-i:e:0},kl=Math.max;var Cl=cl((function(t,e,i){var s=null==t?0:t.length;if(!s)return-1;var n=null==i?0:wl(i);return n<0&&(n=kl(s+n,0)),fo(t,Ca(e),n)}));var Sl=function(t){return(null==t?0:t.length)?no(t,1):[]};var El=function(t,e){return null==t?t:br(t,Cr(e),fn)};var Tl=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0};var Al=function(t,e){var i={};return e=Ca(e),xr(t,(function(t,s,n){Is(i,s,e(t,s,n))})),i};var Il=function(t,e,i){for(var s=-1,n=t.length;++s<n;){var r=t[s],a=e(r);if(null!=a&&(void 0===o?a==a&&!Qr(a):i(a,o)))var o=a,l=r}return l};var Ol=function(t,e){return t>e};var Rl=function(t){return t&&t.length?Il(t,kr,Ol):void 0};var Ml=function(t,e,i){(void 0!==i&&!gi(t[e],i)||void 0===i&&!(e in t))&&Is(t,e,i)},Nl=Function.prototype,Pl=Object.prototype,Fl=Nl.toString,Bl=Pl.hasOwnProperty,Ll=Fl.call(Object);var jl=function(t){if(!Ps(t)||"[object Object]"!=Di(t))return!1;var e=Cn(t);if(null===e)return!0;var i=Bl.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Fl.call(i)==Ll};var Vl=function(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]};var Dl=function(t){return Ms(t,fn(t))};
178
- /**
179
- * A specialized version of `baseMerge` for arrays and objects which performs
180
- * deep merges and tracks traversed objects enabling objects with circular
181
- * references to be merged.
182
- *
183
- * @private
184
- * @param {Object} object The destination object.
185
- * @param {Object} source The source object.
186
- * @param {string} key The key of the value to merge.
187
- * @param {number} srcIndex The index of `source`.
188
- * @param {Function} mergeFunc The function to merge values.
189
- * @param {Function} [customizer] The function to customize assigned values.
190
- * @param {Object} [stack] Tracks traversed source values and their merged
191
- * counterparts.
192
- */var Gl=function(t,e,i,s,n,r,a){var o=Vl(t,i),l=Vl(e,i),h=a.get(l);if(h)Ml(t,i,h);else{var c=r?r(o,l,i+"",t,e,a):void 0,d=void 0===c;if(d){var u=Ds(l),f=!u&&zs(l),p=!u&&!f&&Zs(l);c=l,u||f||p?Ds(o)?c=o:wo(o)?c=_n(o):f?(d=!1,c=gn(l,!0)):p?(d=!1,c=ir(l,!0)):c=[]:jl(l)||Vs(l)?(c=o,Vs(o)?c=Dl(o):Gi(o)&&!Wi(o)||(c=ar(l))):d=!1}d&&(a.set(l,c),n(c,l,s,r,a),a.delete(l)),Ml(t,i,c)}};var zl=function t(e,i,s,n,r){e!==i&&br(i,(function(a,o){if(r||(r=new Es),Gi(a))Gl(e,i,o,s,t,n,r);else{var l=n?n(Vl(e,o),a,o+"",e,i,r):void 0;void 0===l&&(l=a),Ml(e,o,l)}}),fn)};var Wl=function(t){return uo((function(e,i){var s=-1,n=i.length,r=n>1?i[n-1]:void 0,a=n>2?i[2]:void 0;for(r=t.length>3&&"function"==typeof r?(n--,r):void 0,a&&al(i[0],i[1],a)&&(r=n<3?void 0:r,n=1),e=Object(e);++s<n;){var o=i[s];o&&t(e,o,s,r)}return e}))}((function(t,e,i){zl(t,e,i)}));var Yl=function(t,e){return t<e};var Ul=function(t){return t&&t.length?Il(t,kr,Yl):void 0};var ql=function(t,e){return t&&t.length?Il(t,Ca(e),Yl):void 0},Jl=function(){return Oi.Date.now()};var Xl=function(t,e,i,s){if(!Gi(t))return t;for(var n=-1,r=(e=fa(e,t)).length,a=r-1,o=t;null!=o&&++n<r;){var l=pa(e[n]),h=i;if("__proto__"===l||"constructor"===l||"prototype"===l)return t;if(n!=a){var c=o[l];void 0===(h=s?s(c,l,o):void 0)&&(h=Gi(c)?c:Ys(e[n+1])?[]:{})}Rs(o,l,h),o=o[l]}return t};var $l=function(t,e,i){for(var s=-1,n=e.length,r={};++s<n;){var a=e[s],o=ga(t,a);i(o,a)&&Xl(r,fa(a,t),o)}return r};var Hl=function(t,e){return $l(t,e,(function(e,i){return va(t,i)}))};
193
- /**
194
- * A specialized version of `baseRest` which flattens the rest array.
195
- *
196
- * @private
197
- * @param {Function} func The function to apply a rest parameter to.
198
- * @returns {Function} Returns the new function.
199
- */var Zl=function(t){return co(oo(t,void 0,Sl),t+"")}((function(t,e){return null==t?{}:Hl(t,e)})),Kl=Math.ceil,Ql=Math.max;var th=function(t,e,i,s){for(var n=-1,r=Ql(Kl((e-t)/(i||1)),0),a=Array(r);r--;)a[s?r:++n]=t,t+=i;return a};var eh=function(t){return function(e,i,s){return s&&"number"!=typeof s&&al(e,i,s)&&(i=s=void 0),e=xl(e),void 0===i?(i=e,e=0):i=xl(i),s=void 0===s?e<i?1:-1:xl(s),th(e,i,s,t)}}();var ih=function(t,e){var i=t.length;for(t.sort(e);i--;)t[i]=t[i].value;return t};var sh=function(t,e){if(t!==e){var i=void 0!==t,s=null===t,n=t==t,r=Qr(t),a=void 0!==e,o=null===e,l=e==e,h=Qr(e);if(!o&&!h&&!r&&t>e||r&&a&&l&&!o&&!h||s&&a&&l||!i&&l||!n)return 1;if(!s&&!r&&!h&&t<e||h&&i&&n&&!s&&!r||o&&i&&n||!a&&n||!l)return-1}return 0};var nh=function(t,e,i){for(var s=-1,n=t.criteria,r=e.criteria,a=n.length,o=i.length;++s<a;){var l=sh(n[s],r[s]);if(l)return s>=o?l:l*("desc"==i[s]?-1:1)}return t.index-e.index};var rh=function(t,e,i){e=e.length?la(e,(function(t){return Ds(t)?function(e){return ga(e,1===t.length?t[0]:t)}:t})):[kr];var s=-1;e=la(e,Xs(Ca));var n=Ma(t,(function(t,i,n){return{criteria:la(e,(function(e){return e(t)})),index:++s,value:t}}));return ih(n,(function(t,e){return nh(t,e,i)}))},ah=uo((function(t,e){if(null==t)return[];var i=e.length;return i>1&&al(t,e[0],e[1])?e=[]:i>2&&al(e[0],e[1],e[2])&&(e=[e[0]]),rh(t,no(e,1),[])})),oh=0;var lh=function(t){var e=++oh;return ua(t)+e};var hh=function(t,e,i){for(var s=-1,n=t.length,r=e.length,a={};++s<n;){var o=s<r?e[s]:void 0;i(a,t[s],o)}return a};var ch,dh=function(t,e){return hh(t||[],e||[],Rs)};try{ch={cloneDeep:rl,constant:vr,defaults:hl,each:Er,filter:Sa,find:Cl,flatten:Sl,forEach:Sr,forIn:El,has:Aa,isUndefined:Ra,last:Tl,map:Na,mapValues:Al,max:Rl,merge:Wl,min:Ul,minBy:ql,now:Jl,pick:Zl,range:eh,reduce:Ba,sortBy:ah,uniqueId:lh,values:Eo,zipObject:dh}}catch(t){}ch||(ch=window._);var uh=ch,fh=ph;function ph(){var t={};t._next=t._prev=t,this._sentinel=t}function gh(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function _h(t,e){if("_next"!==t&&"_prev"!==t)return e}ph.prototype.dequeue=function(){var t=this._sentinel,e=t._prev;if(e!==t)return gh(e),e},ph.prototype.enqueue=function(t){var e=this._sentinel;t._prev&&t._next&&gh(t),t._next=e._next,e._next._prev=t,e._next=t,t._prev=e},ph.prototype.toString=function(){for(var t=[],e=this._sentinel,i=e._prev;i!==e;)t.push(JSON.stringify(i,_h)),i=i._prev;return"["+t.join(", ")+"]"};var mh=nl.Graph,yh=function(t,e){if(t.nodeCount()<=1)return[];var i=function(t,e){var i=new mh,s=0,n=0;uh.forEach(t.nodes(),(function(t){i.setNode(t,{v:t,in:0,out:0})})),uh.forEach(t.edges(),(function(t){var r=i.edge(t.v,t.w)||0,a=e(t),o=r+a;i.setEdge(t.v,t.w,o),n=Math.max(n,i.node(t.v).out+=a),s=Math.max(s,i.node(t.w).in+=a)}));var r=uh.range(n+s+3).map((function(){return new fh})),a=s+1;return uh.forEach(i.nodes(),(function(t){xh(r,a,i.node(t))})),{graph:i,buckets:r,zeroIdx:a}}(t,e||vh),s=function(t,e,i){var s,n=[],r=e[e.length-1],a=e[0];for(;t.nodeCount();){for(;s=a.dequeue();)bh(t,e,i,s);for(;s=r.dequeue();)bh(t,e,i,s);if(t.nodeCount())for(var o=e.length-2;o>0;--o)if(s=e[o].dequeue()){n=n.concat(bh(t,e,i,s,!0));break}}return n}(i.graph,i.buckets,i.zeroIdx);return uh.flatten(uh.map(s,(function(e){return t.outEdges(e.v,e.w)})),!0)},vh=uh.constant(1);function bh(t,e,i,s,n){var r=n?[]:void 0;return uh.forEach(t.inEdges(s.v),(function(s){var a=t.edge(s),o=t.node(s.v);n&&r.push({v:s.v,w:s.w}),o.out-=a,xh(e,i,o)})),uh.forEach(t.outEdges(s.v),(function(s){var n=t.edge(s),r=s.w,a=t.node(r);a.in-=n,xh(e,i,a)})),t.removeNode(s.v),r}function xh(t,e,i){i.out?i.in?t[i.out-i.in+e].enqueue(i):t[t.length-1].enqueue(i):t[0].enqueue(i)}var wh={run:function(t){var e="greedy"===t.graph().acyclicer?yh(t,function(t){return function(e){return t.edge(e).weight}}(t)):function(t){var e=[],i={},s={};function n(r){uh.has(s,r)||(s[r]=!0,i[r]=!0,uh.forEach(t.outEdges(r),(function(t){uh.has(i,t.w)?e.push(t):n(t.w)})),delete i[r])}return uh.forEach(t.nodes(),n),e}(t);uh.forEach(e,(function(e){var i=t.edge(e);t.removeEdge(e),i.forwardName=e.name,i.reversed=!0,t.setEdge(e.w,e.v,i,uh.uniqueId("rev"))}))},undo:function(t){uh.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.reversed){t.removeEdge(e);var s=i.forwardName;delete i.reversed,delete i.forwardName,t.setEdge(e.w,e.v,i,s)}}))}};var kh=nl.Graph,Ch={addDummyNode:Sh,simplify:function(t){var e=(new kh).setGraph(t.graph());return uh.forEach(t.nodes(),(function(i){e.setNode(i,t.node(i))})),uh.forEach(t.edges(),(function(i){var s=e.edge(i.v,i.w)||{weight:0,minlen:1},n=t.edge(i);e.setEdge(i.v,i.w,{weight:s.weight+n.weight,minlen:Math.max(s.minlen,n.minlen)})})),e},asNonCompoundGraph:function(t){var e=new kh({multigraph:t.isMultigraph()}).setGraph(t.graph());return uh.forEach(t.nodes(),(function(i){t.children(i).length||e.setNode(i,t.node(i))})),uh.forEach(t.edges(),(function(i){e.setEdge(i,t.edge(i))})),e},successorWeights:function(t){var e=uh.map(t.nodes(),(function(e){var i={};return uh.forEach(t.outEdges(e),(function(e){i[e.w]=(i[e.w]||0)+t.edge(e).weight})),i}));return uh.zipObject(t.nodes(),e)},predecessorWeights:function(t){var e=uh.map(t.nodes(),(function(e){var i={};return uh.forEach(t.inEdges(e),(function(e){i[e.v]=(i[e.v]||0)+t.edge(e).weight})),i}));return uh.zipObject(t.nodes(),e)},intersectRect:function(t,e){var i,s,n=t.x,r=t.y,a=e.x-n,o=e.y-r,l=t.width/2,h=t.height/2;if(!a&&!o)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(o)*l>Math.abs(a)*h?(o<0&&(h=-h),i=h*a/o,s=h):(a<0&&(l=-l),i=l,s=l*o/a);return{x:n+i,y:r+s}},buildLayerMatrix:function(t){var e=uh.map(uh.range(Eh(t)+1),(function(){return[]}));return uh.forEach(t.nodes(),(function(i){var s=t.node(i),n=s.rank;uh.isUndefined(n)||(e[n][s.order]=i)})),e},normalizeRanks:function(t){var e=uh.min(uh.map(t.nodes(),(function(e){return t.node(e).rank})));uh.forEach(t.nodes(),(function(i){var s=t.node(i);uh.has(s,"rank")&&(s.rank-=e)}))},removeEmptyRanks:function(t){var e=uh.min(uh.map(t.nodes(),(function(e){return t.node(e).rank}))),i=[];uh.forEach(t.nodes(),(function(s){var n=t.node(s).rank-e;i[n]||(i[n]=[]),i[n].push(s)}));var s=0,n=t.graph().nodeRankFactor;uh.forEach(i,(function(e,i){uh.isUndefined(e)&&i%n!=0?--s:s&&uh.forEach(e,(function(e){t.node(e).rank+=s}))}))},addBorderNode:function(t,e,i,s){var n={width:0,height:0};arguments.length>=4&&(n.rank=i,n.order=s);return Sh(t,"border",n,e)},maxRank:Eh,partition:function(t,e){var i={lhs:[],rhs:[]};return uh.forEach(t,(function(t){e(t)?i.lhs.push(t):i.rhs.push(t)})),i},time:function(t,e){var i=uh.now();try{return e()}finally{console.log(t+" time: "+(uh.now()-i)+"ms")}},notime:function(t,e){return e()}};function Sh(t,e,i,s){var n;do{n=uh.uniqueId(s)}while(t.hasNode(n));return i.dummy=e,t.setNode(n,i),n}function Eh(t){return uh.max(uh.map(t.nodes(),(function(e){var i=t.node(e).rank;if(!uh.isUndefined(i))return i})))}var Th={run:function(t){t.graph().dummyChains=[],uh.forEach(t.edges(),(function(e){!function(t,e){var i,s,n,r=e.v,a=t.node(r).rank,o=e.w,l=t.node(o).rank,h=e.name,c=t.edge(e),d=c.labelRank;if(l===a+1)return;for(t.removeEdge(e),n=0,++a;a<l;++n,++a)c.points=[],s={width:0,height:0,edgeLabel:c,edgeObj:e,rank:a},i=Ch.addDummyNode(t,"edge",s,"_d"),a===d&&(s.width=c.width,s.height=c.height,s.dummy="edge-label",s.labelpos=c.labelpos),t.setEdge(r,i,{weight:c.weight},h),0===n&&t.graph().dummyChains.push(i),r=i;t.setEdge(r,o,{weight:c.weight},h)}(t,e)}))},undo:function(t){uh.forEach(t.graph().dummyChains,(function(e){var i,s=t.node(e),n=s.edgeLabel;for(t.setEdge(s.edgeObj,n);s.dummy;)i=t.successors(e)[0],t.removeNode(e),n.points.push({x:s.x,y:s.y}),"edge-label"===s.dummy&&(n.x=s.x,n.y=s.y,n.width=s.width,n.height=s.height),e=i,s=t.node(e)}))}};var Ah=function(t){var e={};uh.forEach(t.sources(),(function i(s){var n=t.node(s);if(uh.has(e,s))return n.rank;e[s]=!0;var r=uh.min(uh.map(t.outEdges(s),(function(e){return i(e.w)-t.edge(e).minlen})));return r!==Number.POSITIVE_INFINITY&&null!=r||(r=0),n.rank=r}))},Ih=function(t,e){return t.node(e.w).rank-t.node(e.v).rank-t.edge(e).minlen};var Oh=nl.Graph,Rh=Ih,Mh=function(t){var e,i,s=new Oh({directed:!1}),n=t.nodes()[0],r=t.nodeCount();s.setNode(n,{});for(;Nh(s,t)<r;)e=Ph(s,t),i=s.hasNode(e.v)?Rh(t,e):-Rh(t,e),Fh(s,t,i);return s};function Nh(t,e){return uh.forEach(t.nodes(),(function i(s){uh.forEach(e.nodeEdges(s),(function(n){var r=n.v,a=s===r?n.w:r;t.hasNode(a)||Rh(e,n)||(t.setNode(a,{}),t.setEdge(s,a,{}),i(a))}))})),t.nodeCount()}function Ph(t,e){return uh.minBy(e.edges(),(function(i){if(t.hasNode(i.v)!==t.hasNode(i.w))return Rh(e,i)}))}function Fh(t,e,i){uh.forEach(t.nodes(),(function(t){e.node(t).rank+=i}))}var Bh=Ih,Lh=Ah,jh=nl.alg.preorder,Vh=nl.alg.postorder,Dh=Ch.simplify,Gh=zh;function zh(t){t=Dh(t),Lh(t);var e,i=Mh(t);for(Uh(i),Wh(i,t);e=Jh(i);)$h(i,t,e,Xh(i,t,e))}function Wh(t,e){var i=Vh(t,t.nodes());i=i.slice(0,i.length-1),uh.forEach(i,(function(i){!function(t,e,i){var s=t.node(i).parent;t.edge(i,s).cutvalue=Yh(t,e,i)}(t,e,i)}))}function Yh(t,e,i){var s=t.node(i).parent,n=!0,r=e.edge(i,s),a=0;return r||(n=!1,r=e.edge(s,i)),a=r.weight,uh.forEach(e.nodeEdges(i),(function(r){var o,l,h=r.v===i,c=h?r.w:r.v;if(c!==s){var d=h===n,u=e.edge(r).weight;if(a+=d?u:-u,o=i,l=c,t.hasEdge(o,l)){var f=t.edge(i,c).cutvalue;a+=d?-f:f}}})),a}function Uh(t,e){arguments.length<2&&(e=t.nodes()[0]),qh(t,{},1,e)}function qh(t,e,i,s,n){var r=i,a=t.node(s);return e[s]=!0,uh.forEach(t.neighbors(s),(function(n){uh.has(e,n)||(i=qh(t,e,i,n,s))})),a.low=r,a.lim=i++,n?a.parent=n:delete a.parent,i}function Jh(t){return uh.find(t.edges(),(function(e){return t.edge(e).cutvalue<0}))}function Xh(t,e,i){var s=i.v,n=i.w;e.hasEdge(s,n)||(s=i.w,n=i.v);var r=t.node(s),a=t.node(n),o=r,l=!1;r.lim>a.lim&&(o=a,l=!0);var h=uh.filter(e.edges(),(function(e){return l===Hh(t,t.node(e.v),o)&&l!==Hh(t,t.node(e.w),o)}));return uh.minBy(h,(function(t){return Bh(e,t)}))}function $h(t,e,i,s){var n=i.v,r=i.w;t.removeEdge(n,r),t.setEdge(s.v,s.w,{}),Uh(t),Wh(t,e),function(t,e){var i=uh.find(t.nodes(),(function(t){return!e.node(t).parent})),s=jh(t,i);s=s.slice(1),uh.forEach(s,(function(i){var s=t.node(i).parent,n=e.edge(i,s),r=!1;n||(n=e.edge(s,i),r=!0),e.node(i).rank=e.node(s).rank+(r?n.minlen:-n.minlen)}))}(t,e)}function Hh(t,e,i){return i.low<=e.lim&&e.lim<=i.lim}zh.initLowLimValues=Uh,zh.initCutValues=Wh,zh.calcCutValue=Yh,zh.leaveEdge=Jh,zh.enterEdge=Xh,zh.exchangeEdges=$h;var Zh=Ah,Kh=function(t){switch(t.graph().ranker){case"network-simplex":tc(t);break;case"tight-tree":!function(t){Zh(t),Mh(t)}(t);break;case"longest-path":Qh(t);break;default:tc(t)}};var Qh=Zh;function tc(t){Gh(t)}var ec=function(t){var e=function(t){var e={},i=0;function s(n){var r=i;uh.forEach(t.children(n),s),e[n]={low:r,lim:i++}}return uh.forEach(t.children(),s),e}(t);uh.forEach(t.graph().dummyChains,(function(i){for(var s=t.node(i),n=s.edgeObj,r=function(t,e,i,s){var n,r,a=[],o=[],l=Math.min(e[i].low,e[s].low),h=Math.max(e[i].lim,e[s].lim);n=i;do{n=t.parent(n),a.push(n)}while(n&&(e[n].low>l||h>e[n].lim));r=n,n=s;for(;(n=t.parent(n))!==r;)o.push(n);return{path:a.concat(o.reverse()),lca:r}}(t,e,n.v,n.w),a=r.path,o=r.lca,l=0,h=a[l],c=!0;i!==n.w;){if(s=t.node(i),c){for(;(h=a[l])!==o&&t.node(h).maxRank<s.rank;)l++;h===o&&(c=!1)}if(!c){for(;l<a.length-1&&t.node(h=a[l+1]).minRank<=s.rank;)l++;h=a[l]}t.setParent(i,h),i=t.successors(i)[0]}}))};var ic={run:function(t){var e=Ch.addDummyNode(t,"root",{},"_root"),i=function(t){var e={};function i(s,n){var r=t.children(s);r&&r.length&&uh.forEach(r,(function(t){i(t,n+1)})),e[s]=n}return uh.forEach(t.children(),(function(t){i(t,1)})),e}(t),s=uh.max(uh.values(i))-1,n=2*s+1;t.graph().nestingRoot=e,uh.forEach(t.edges(),(function(e){t.edge(e).minlen*=n}));var r=function(t){return uh.reduce(t.edges(),(function(e,i){return e+t.edge(i).weight}),0)}(t)+1;uh.forEach(t.children(),(function(a){sc(t,e,n,r,s,i,a)})),t.graph().nodeRankFactor=n},cleanup:function(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,uh.forEach(t.edges(),(function(e){t.edge(e).nestingEdge&&t.removeEdge(e)}))}};function sc(t,e,i,s,n,r,a){var o=t.children(a);if(o.length){var l=Ch.addBorderNode(t,"_bt"),h=Ch.addBorderNode(t,"_bb"),c=t.node(a);t.setParent(l,a),c.borderTop=l,t.setParent(h,a),c.borderBottom=h,uh.forEach(o,(function(o){sc(t,e,i,s,n,r,o);var c=t.node(o),d=c.borderTop?c.borderTop:o,u=c.borderBottom?c.borderBottom:o,f=c.borderTop?s:2*s,p=d!==u?1:n-r[a]+1;t.setEdge(l,d,{weight:f,minlen:p,nestingEdge:!0}),t.setEdge(u,h,{weight:f,minlen:p,nestingEdge:!0})})),t.parent(a)||t.setEdge(e,l,{weight:0,minlen:n+r[a]})}else a!==e&&t.setEdge(e,a,{weight:0,minlen:i})}var nc=function(t){uh.forEach(t.children(),(function e(i){var s=t.children(i),n=t.node(i);if(s.length&&uh.forEach(s,e),uh.has(n,"minRank")){n.borderLeft=[],n.borderRight=[];for(var r=n.minRank,a=n.maxRank+1;r<a;++r)rc(t,"borderLeft","_bl",i,n,r),rc(t,"borderRight","_br",i,n,r)}}))};function rc(t,e,i,s,n,r){var a={width:0,height:0,rank:r,borderType:e},o=n[e][r-1],l=Ch.addDummyNode(t,"border",a,i);n[e][r]=l,t.setParent(l,s),o&&t.setEdge(o,l,{weight:1})}var ac={adjust:function(t){var e=t.graph().rankdir.toLowerCase();"lr"!==e&&"rl"!==e||oc(t)},undo:function(t){var e=t.graph().rankdir.toLowerCase();"bt"!==e&&"rl"!==e||function(t){uh.forEach(t.nodes(),(function(e){hc(t.node(e))})),uh.forEach(t.edges(),(function(e){var i=t.edge(e);uh.forEach(i.points,hc),uh.has(i,"y")&&hc(i)}))}(t);"lr"!==e&&"rl"!==e||(!function(t){uh.forEach(t.nodes(),(function(e){cc(t.node(e))})),uh.forEach(t.edges(),(function(e){var i=t.edge(e);uh.forEach(i.points,cc),uh.has(i,"x")&&cc(i)}))}(t),oc(t))}};function oc(t){uh.forEach(t.nodes(),(function(e){lc(t.node(e))})),uh.forEach(t.edges(),(function(e){lc(t.edge(e))}))}function lc(t){var e=t.width;t.width=t.height,t.height=e}function hc(t){t.y=-t.y}function cc(t){var e=t.x;t.x=t.y,t.y=e}var dc=function(t){var e={},i=uh.filter(t.nodes(),(function(e){return!t.children(e).length})),s=uh.max(uh.map(i,(function(e){return t.node(e).rank}))),n=uh.map(uh.range(s+1),(function(){return[]}));function r(i){if(!uh.has(e,i)){e[i]=!0;var s=t.node(i);n[s.rank].push(i),uh.forEach(t.successors(i),r)}}var a=uh.sortBy(i,(function(e){return t.node(e).rank}));return uh.forEach(a,r),n};var uc=function(t,e){for(var i=0,s=1;s<e.length;++s)i+=fc(t,e[s-1],e[s]);return i};function fc(t,e,i){for(var s=uh.zipObject(i,uh.map(i,(function(t,e){return e}))),n=uh.flatten(uh.map(e,(function(e){return uh.sortBy(uh.map(t.outEdges(e),(function(e){return{pos:s[e.w],weight:t.edge(e).weight}})),"pos")})),!0),r=1;r<i.length;)r<<=1;var a=2*r-1;r-=1;var o=uh.map(new Array(a),(function(){return 0})),l=0;return uh.forEach(n.forEach((function(t){var e=t.pos+r;o[e]+=t.weight;for(var i=0;e>0;)e%2&&(i+=o[e+1]),o[e=e-1>>1]+=t.weight;l+=t.weight*i}))),l}var pc=function(t,e){return uh.map(e,(function(e){var i=t.inEdges(e);if(i.length){var s=uh.reduce(i,(function(e,i){var s=t.edge(i),n=t.node(i.v);return{sum:e.sum+s.weight*n.order,weight:e.weight+s.weight}}),{sum:0,weight:0});return{v:e,barycenter:s.sum/s.weight,weight:s.weight}}return{v:e}}))};var gc=function(t,e){var i={};return uh.forEach(t,(function(t,e){var s=i[t.v]={indegree:0,in:[],out:[],vs:[t.v],i:e};uh.isUndefined(t.barycenter)||(s.barycenter=t.barycenter,s.weight=t.weight)})),uh.forEach(e.edges(),(function(t){var e=i[t.v],s=i[t.w];uh.isUndefined(e)||uh.isUndefined(s)||(s.indegree++,e.out.push(i[t.w]))})),function(t){var e=[];function i(t){return function(e){e.merged||(uh.isUndefined(e.barycenter)||uh.isUndefined(t.barycenter)||e.barycenter>=t.barycenter)&&function(t,e){var i=0,s=0;t.weight&&(i+=t.barycenter*t.weight,s+=t.weight);e.weight&&(i+=e.barycenter*e.weight,s+=e.weight);t.vs=e.vs.concat(t.vs),t.barycenter=i/s,t.weight=s,t.i=Math.min(e.i,t.i),e.merged=!0}(t,e)}}function s(e){return function(i){i.in.push(e),0==--i.indegree&&t.push(i)}}for(;t.length;){var n=t.pop();e.push(n),uh.forEach(n.in.reverse(),i(n)),uh.forEach(n.out,s(n))}return uh.map(uh.filter(e,(function(t){return!t.merged})),(function(t){return uh.pick(t,["vs","i","barycenter","weight"])}))}(uh.filter(i,(function(t){return!t.indegree})))};var _c=function(t,e){var i=Ch.partition(t,(function(t){return uh.has(t,"barycenter")})),s=i.lhs,n=uh.sortBy(i.rhs,(function(t){return-t.i})),r=[],a=0,o=0,l=0;s.sort((h=!!e,function(t,e){return t.barycenter<e.barycenter?-1:t.barycenter>e.barycenter?1:h?e.i-t.i:t.i-e.i})),l=mc(r,n,l),uh.forEach(s,(function(t){l+=t.vs.length,r.push(t.vs),a+=t.barycenter*t.weight,o+=t.weight,l=mc(r,n,l)}));var h;var c={vs:uh.flatten(r,!0)};o&&(c.barycenter=a/o,c.weight=o);return c};function mc(t,e,i){for(var s;e.length&&(s=uh.last(e)).i<=i;)e.pop(),t.push(s.vs),i++;return i}var yc=function t(e,i,s,n){var r=e.children(i),a=e.node(i),o=a?a.borderLeft:void 0,l=a?a.borderRight:void 0,h={};o&&(r=uh.filter(r,(function(t){return t!==o&&t!==l})));var c=pc(e,r);uh.forEach(c,(function(i){if(e.children(i.v).length){var r=t(e,i.v,s,n);h[i.v]=r,uh.has(r,"barycenter")&&(a=i,o=r,uh.isUndefined(a.barycenter)?(a.barycenter=o.barycenter,a.weight=o.weight):(a.barycenter=(a.barycenter*a.weight+o.barycenter*o.weight)/(a.weight+o.weight),a.weight+=o.weight))}var a,o}));var d=gc(c,s);!function(t,e){uh.forEach(t,(function(t){t.vs=uh.flatten(t.vs.map((function(t){return e[t]?e[t].vs:t})),!0)}))}(d,h);var u=_c(d,n);if(o&&(u.vs=uh.flatten([o,u.vs,l],!0),e.predecessors(o).length)){var f=e.node(e.predecessors(o)[0]),p=e.node(e.predecessors(l)[0]);uh.has(u,"barycenter")||(u.barycenter=0,u.weight=0),u.barycenter=(u.barycenter*u.weight+f.order+p.order)/(u.weight+2),u.weight+=2}return u};var vc=nl.Graph,bc=function(t,e,i){var s=function(t){var e;for(;t.hasNode(e=uh.uniqueId("_root")););return e}(t),n=new vc({compound:!0}).setGraph({root:s}).setDefaultNodeLabel((function(e){return t.node(e)}));return uh.forEach(t.nodes(),(function(r){var a=t.node(r),o=t.parent(r);(a.rank===e||a.minRank<=e&&e<=a.maxRank)&&(n.setNode(r),n.setParent(r,o||s),uh.forEach(t[i](r),(function(e){var i=e.v===r?e.w:e.v,s=n.edge(i,r),a=uh.isUndefined(s)?0:s.weight;n.setEdge(i,r,{weight:t.edge(e).weight+a})})),uh.has(a,"minRank")&&n.setNode(r,{borderLeft:a.borderLeft[e],borderRight:a.borderRight[e]}))})),n};var xc=function(t,e,i){var s,n={};uh.forEach(i,(function(i){for(var r,a,o=t.parent(i);o;){if((r=t.parent(o))?(a=n[r],n[r]=o):(a=s,s=o),a&&a!==o)return void e.setEdge(a,o);o=r}}))};var wc=nl.Graph,kc=function(t){var e=Ch.maxRank(t),i=Cc(t,uh.range(1,e+1),"inEdges"),s=Cc(t,uh.range(e-1,-1,-1),"outEdges"),n=dc(t);Ec(t,n);for(var r,a=Number.POSITIVE_INFINITY,o=0,l=0;l<4;++o,++l){Sc(o%2?i:s,o%4>=2),n=Ch.buildLayerMatrix(t);var h=uc(t,n);h<a&&(l=0,r=uh.cloneDeep(n),a=h)}Ec(t,r)};function Cc(t,e,i){return uh.map(e,(function(e){return bc(t,e,i)}))}function Sc(t,e){var i=new wc;uh.forEach(t,(function(t){var s=t.graph().root,n=yc(t,s,i,e);uh.forEach(n.vs,(function(e,i){t.node(e).order=i})),xc(t,i,n.vs)}))}function Ec(t,e){uh.forEach(e,(function(e){uh.forEach(e,(function(e,i){t.node(e).order=i}))}))}var Tc=nl.Graph,Ac=function(t){var e,i=Ch.buildLayerMatrix(t),s=uh.merge(Ic(t,i),Oc(t,i)),n={};uh.forEach(["u","d"],(function(r){e="u"===r?i:uh.values(i).reverse(),uh.forEach(["l","r"],(function(i){"r"===i&&(e=uh.map(e,(function(t){return uh.values(t).reverse()})));var a=("u"===r?t.predecessors:t.successors).bind(t),o=Nc(t,e,s,a),l=Pc(t,e,o.root,o.align,"r"===i);"r"===i&&(l=uh.mapValues(l,(function(t){return-t}))),n[r+i]=l}))}));var r=Fc(t,n);return Bc(n,r),Lc(n,t.graph().align)};function Ic(t,e){var i={};return uh.reduce(e,(function(e,s){var n=0,r=0,a=e.length,o=uh.last(s);return uh.forEach(s,(function(e,l){var h=function(t,e){if(t.node(e).dummy)return uh.find(t.predecessors(e),(function(e){return t.node(e).dummy}))}(t,e),c=h?t.node(h).order:a;(h||e===o)&&(uh.forEach(s.slice(r,l+1),(function(e){uh.forEach(t.predecessors(e),(function(s){var r=t.node(s),a=r.order;!(a<n||c<a)||r.dummy&&t.node(e).dummy||Rc(i,s,e)}))})),r=l+1,n=c)})),s})),i}function Oc(t,e){var i={};function s(e,s,n,r,a){var o;uh.forEach(uh.range(s,n),(function(s){o=e[s],t.node(o).dummy&&uh.forEach(t.predecessors(o),(function(e){var s=t.node(e);s.dummy&&(s.order<r||s.order>a)&&Rc(i,e,o)}))}))}return uh.reduce(e,(function(e,i){var n,r=-1,a=0;return uh.forEach(i,(function(o,l){if("border"===t.node(o).dummy){var h=t.predecessors(o);h.length&&(n=t.node(h[0]).order,s(i,a,l,r,n),a=l,r=n)}s(i,a,i.length,n,e.length)})),i})),i}function Rc(t,e,i){if(e>i){var s=e;e=i,i=s}var n=t[e];n||(t[e]=n={}),n[i]=!0}function Mc(t,e,i){if(e>i){var s=e;e=i,i=s}return uh.has(t[e],i)}function Nc(t,e,i,s){var n={},r={},a={};return uh.forEach(e,(function(t){uh.forEach(t,(function(t,e){n[t]=t,r[t]=t,a[t]=e}))})),uh.forEach(e,(function(t){var e=-1;uh.forEach(t,(function(t){var o=s(t);if(o.length)for(var l=((o=uh.sortBy(o,(function(t){return a[t]}))).length-1)/2,h=Math.floor(l),c=Math.ceil(l);h<=c;++h){var d=o[h];r[t]===t&&e<a[d]&&!Mc(i,t,d)&&(r[d]=t,r[t]=n[t]=n[d],e=a[d])}}))})),{root:n,align:r}}function Pc(t,e,i,s,n){var r={},a=function(t,e,i,s){var n=new Tc,r=t.graph(),a=function(t,e,i){return function(s,n,r){var a,o=s.node(n),l=s.node(r),h=0;if(h+=o.width/2,uh.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":a=-o.width/2;break;case"r":a=o.width/2}if(a&&(h+=i?a:-a),a=0,h+=(o.dummy?e:t)/2,h+=(l.dummy?e:t)/2,h+=l.width/2,uh.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2}return a&&(h+=i?a:-a),a=0,h}}(r.nodesep,r.edgesep,s);return uh.forEach(e,(function(e){var s;uh.forEach(e,(function(e){var r=i[e];if(n.setNode(r),s){var o=i[s],l=n.edge(o,r);n.setEdge(o,r,Math.max(a(t,e,s),l||0))}s=e}))})),n}(t,e,i,n),o=n?"borderLeft":"borderRight";function l(t,e){for(var i=a.nodes(),s=i.pop(),n={};s;)n[s]?t(s):(n[s]=!0,i.push(s),i=i.concat(e(s))),s=i.pop()}return l((function(t){r[t]=a.inEdges(t).reduce((function(t,e){return Math.max(t,r[e.v]+a.edge(e))}),0)}),a.predecessors.bind(a)),l((function(e){var i=a.outEdges(e).reduce((function(t,e){return Math.min(t,r[e.w]-a.edge(e))}),Number.POSITIVE_INFINITY),s=t.node(e);i!==Number.POSITIVE_INFINITY&&s.borderType!==o&&(r[e]=Math.max(r[e],i))}),a.successors.bind(a)),uh.forEach(s,(function(t){r[t]=r[i[t]]})),r}function Fc(t,e){return uh.minBy(uh.values(e),(function(e){var i=Number.NEGATIVE_INFINITY,s=Number.POSITIVE_INFINITY;return uh.forIn(e,(function(e,n){var r=function(t,e){return t.node(e).width}(t,n)/2;i=Math.max(e+r,i),s=Math.min(e-r,s)})),i-s}))}function Bc(t,e){var i=uh.values(e),s=uh.min(i),n=uh.max(i);uh.forEach(["u","d"],(function(i){uh.forEach(["l","r"],(function(r){var a,o=i+r,l=t[o];if(l!==e){var h=uh.values(l);(a="l"===r?s-uh.min(h):n-uh.max(h))&&(t[o]=uh.mapValues(l,(function(t){return t+a})))}}))}))}function Lc(t,e){return uh.mapValues(t.ul,(function(i,s){if(e)return t[e.toLowerCase()][s];var n=uh.sortBy(uh.map(t,s));return(n[1]+n[2])/2}))}var jc=Ac,Vc=function(t){(function(t){var e=Ch.buildLayerMatrix(t),i=t.graph().ranksep,s=0;uh.forEach(e,(function(e){var n=uh.max(uh.map(e,(function(e){return t.node(e).height})));uh.forEach(e,(function(e){t.node(e).y=s+n/2})),s+=n+i}))})(t=Ch.asNonCompoundGraph(t)),uh.forEach(jc(t),(function(e,i){t.node(i).x=e}))};var Dc=Ch.normalizeRanks,Gc=Ch.removeEmptyRanks,zc=Ch,Wc=nl.Graph,Yc=function(t,e){var i=e&&e.debugTiming?zc.time:zc.notime;i("layout",(function(){var e=i(" buildLayoutGraph",(function(){return function(t){var e=new Wc({multigraph:!0,compound:!0}),i=td(t.graph());return e.setGraph(uh.merge({},qc,Qc(i,Uc),uh.pick(i,Jc))),uh.forEach(t.nodes(),(function(i){var s=td(t.node(i));e.setNode(i,uh.defaults(Qc(s,Xc),$c)),e.setParent(i,t.parent(i))})),uh.forEach(t.edges(),(function(i){var s=td(t.edge(i));e.setEdge(i,uh.merge({},Zc,Qc(s,Hc),uh.pick(s,Kc)))})),e}(t)}));i(" runLayout",(function(){!function(t,e){e(" makeSpaceForEdgeLabels",(function(){!function(t){var e=t.graph();e.ranksep/=2,uh.forEach(t.edges(),(function(i){var s=t.edge(i);s.minlen*=2,"c"!==s.labelpos.toLowerCase()&&("TB"===e.rankdir||"BT"===e.rankdir?s.width+=s.labeloffset:s.height+=s.labeloffset)}))}(t)})),e(" removeSelfEdges",(function(){!function(t){uh.forEach(t.edges(),(function(e){if(e.v===e.w){var i=t.node(e.v);i.selfEdges||(i.selfEdges=[]),i.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}}))}(t)})),e(" acyclic",(function(){wh.run(t)})),e(" nestingGraph.run",(function(){ic.run(t)})),e(" rank",(function(){Kh(zc.asNonCompoundGraph(t))})),e(" injectEdgeLabelProxies",(function(){!function(t){uh.forEach(t.edges(),(function(e){var i=t.edge(e);if(i.width&&i.height){var s=t.node(e.v),n={rank:(t.node(e.w).rank-s.rank)/2+s.rank,e:e};zc.addDummyNode(t,"edge-proxy",n,"_ep")}}))}(t)})),e(" removeEmptyRanks",(function(){Gc(t)})),e(" nestingGraph.cleanup",(function(){ic.cleanup(t)})),e(" normalizeRanks",(function(){Dc(t)})),e(" assignRankMinMax",(function(){!function(t){var e=0;uh.forEach(t.nodes(),(function(i){var s=t.node(i);s.borderTop&&(s.minRank=t.node(s.borderTop).rank,s.maxRank=t.node(s.borderBottom).rank,e=uh.max(e,s.maxRank))})),t.graph().maxRank=e}(t)})),e(" removeEdgeLabelProxies",(function(){!function(t){uh.forEach(t.nodes(),(function(e){var i=t.node(e);"edge-proxy"===i.dummy&&(t.edge(i.e).labelRank=i.rank,t.removeNode(e))}))}(t)})),e(" normalize.run",(function(){Th.run(t)})),e(" parentDummyChains",(function(){ec(t)})),e(" addBorderSegments",(function(){nc(t)})),e(" order",(function(){kc(t)})),e(" insertSelfEdges",(function(){!function(t){var e=zc.buildLayerMatrix(t);uh.forEach(e,(function(e){var i=0;uh.forEach(e,(function(e,s){var n=t.node(e);n.order=s+i,uh.forEach(n.selfEdges,(function(e){zc.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:n.rank,order:s+ ++i,e:e.e,label:e.label},"_se")})),delete n.selfEdges}))}))}(t)})),e(" adjustCoordinateSystem",(function(){ac.adjust(t)})),e(" position",(function(){Vc(t)})),e(" positionSelfEdges",(function(){!function(t){uh.forEach(t.nodes(),(function(e){var i=t.node(e);if("selfedge"===i.dummy){var s=t.node(i.e.v),n=s.x+s.width/2,r=s.y,a=i.x-n,o=s.height/2;t.setEdge(i.e,i.label),t.removeNode(e),i.label.points=[{x:n+2*a/3,y:r-o},{x:n+5*a/6,y:r-o},{x:n+a,y:r},{x:n+5*a/6,y:r+o},{x:n+2*a/3,y:r+o}],i.label.x=i.x,i.label.y=i.y}}))}(t)})),e(" removeBorderNodes",(function(){!function(t){uh.forEach(t.nodes(),(function(e){if(t.children(e).length){var i=t.node(e),s=t.node(i.borderTop),n=t.node(i.borderBottom),r=t.node(uh.last(i.borderLeft)),a=t.node(uh.last(i.borderRight));i.width=Math.abs(a.x-r.x),i.height=Math.abs(n.y-s.y),i.x=r.x+i.width/2,i.y=s.y+i.height/2}})),uh.forEach(t.nodes(),(function(e){"border"===t.node(e).dummy&&t.removeNode(e)}))}(t)})),e(" normalize.undo",(function(){Th.undo(t)})),e(" fixupEdgeLabelCoords",(function(){!function(t){uh.forEach(t.edges(),(function(e){var i=t.edge(e);if(uh.has(i,"x"))switch("l"!==i.labelpos&&"r"!==i.labelpos||(i.width-=i.labeloffset),i.labelpos){case"l":i.x-=i.width/2+i.labeloffset;break;case"r":i.x+=i.width/2+i.labeloffset}}))}(t)})),e(" undoCoordinateSystem",(function(){ac.undo(t)})),e(" translateGraph",(function(){!function(t){var e=Number.POSITIVE_INFINITY,i=0,s=Number.POSITIVE_INFINITY,n=0,r=t.graph(),a=r.marginx||0,o=r.marginy||0;function l(t){var r=t.x,a=t.y,o=t.width,l=t.height;e=Math.min(e,r-o/2),i=Math.max(i,r+o/2),s=Math.min(s,a-l/2),n=Math.max(n,a+l/2)}uh.forEach(t.nodes(),(function(e){l(t.node(e))})),uh.forEach(t.edges(),(function(e){var i=t.edge(e);uh.has(i,"x")&&l(i)})),e-=a,s-=o,uh.forEach(t.nodes(),(function(i){var n=t.node(i);n.x-=e,n.y-=s})),uh.forEach(t.edges(),(function(i){var n=t.edge(i);uh.forEach(n.points,(function(t){t.x-=e,t.y-=s})),uh.has(n,"x")&&(n.x-=e),uh.has(n,"y")&&(n.y-=s)})),r.width=i-e+a,r.height=n-s+o}(t)})),e(" assignNodeIntersects",(function(){!function(t){uh.forEach(t.edges(),(function(e){var i,s,n=t.edge(e),r=t.node(e.v),a=t.node(e.w);n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=a,s=r),n.points.unshift(zc.intersectRect(r,i)),n.points.push(zc.intersectRect(a,s))}))}(t)})),e(" reversePoints",(function(){!function(t){uh.forEach(t.edges(),(function(e){var i=t.edge(e);i.reversed&&i.points.reverse()}))}(t)})),e(" acyclic.undo",(function(){wh.undo(t)}))}(e,i)})),i(" updateInputGraph",(function(){!function(t,e){uh.forEach(t.nodes(),(function(i){var s=t.node(i),n=e.node(i);s&&(s.x=n.x,s.y=n.y,e.children(i).length&&(s.width=n.width,s.height=n.height))})),uh.forEach(t.edges(),(function(i){var s=t.edge(i),n=e.edge(i);s.points=n.points,uh.has(n,"x")&&(s.x=n.x,s.y=n.y)})),t.graph().width=e.graph().width,t.graph().height=e.graph().height}(t,e)}))}))};var Uc=["nodesep","edgesep","ranksep","marginx","marginy"],qc={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},Jc=["acyclicer","ranker","rankdir","align"],Xc=["width","height"],$c={width:0,height:0},Hc=["minlen","weight","width","height","labeloffset"],Zc={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Kc=["labelpos"];function Qc(t,e){return uh.mapValues(uh.pick(t,e),Number)}function td(t){var e={};return uh.forEach(t,(function(t,i){e[i.toLowerCase()]=t})),e}var ed=nl.Graph;var id={graphlib:nl,layout:Yc,debug:{debugOrdering:function(t){var e=Ch.buildLayerMatrix(t),i=new ed({compound:!0,multigraph:!0}).setGraph({});return uh.forEach(t.nodes(),(function(e){i.setNode(e,{label:e}),i.setParent(e,"layer"+t.node(e).rank)})),uh.forEach(t.edges(),(function(t){i.setEdge(t.v,t.w,{},t.name)})),uh.forEach(e,(function(t,e){var s="layer"+e;i.setNode(s,{rank:"same"}),uh.reduce(t,(function(t,e){return i.setEdge(t,e,{style:"invis"}),e}))})),i}},util:{time:Ch.time,notime:Ch.notime},version:"0.8.5"},sd=id.graphlib,nd=id.layout;class rd extends Ot{constructor(t){super(t),this.type=v.Sugiyama,this._width="width"in t?t.width:500,this._height="height"in t?t.height:300,this._top="top"in t?t.top:0,this._left="left"in t?t.left:0,this._edgeSep="edgeSep"in t?t.edgeSep:50}toJSON(){let t={args:{}};return t.type=this.type,t}run(){let t=this.group.children[0].dataScope._dt.graph;if(!t)return;var e=new sd.Graph;e.setGraph({edgesep:this._edgeSep}),e.setDefaultEdgeLabel((function(){return{}}));let i=new Map;for(let t of this.group.children){let s=t.dataScope.getFieldValue(o);i.set(s,s+""),e.setNode(s,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let i of t.links)e.setEdge(i.source,i.target);nd(e);const s={};let n=Math.min(...e.nodes().map((t=>e.node(t).y))),r=Math.min(...e.nodes().map((t=>e.node(t).x))),a=this._left-r,l=this._top-n;for(const t of e.nodes())s[t]={x:e.node(t).x+a,y:e.node(t).y+l};for(let t of this.group.children){let e=t.dataScope.getFieldValue(o);t.x=s[i.get(e)].x,t.y=s[i.get(e)].y}}}class ad extends Ot{constructor(t){super(t),this.type=v.Strata,this._direction=t.direction,this._rootMark=t.rootMark,this._gap="gap"in t?t.gap:0}toJSON(){}clone(){}run(){if(null==this.group||!this.group.children||0===this.group.children.length)return;let t=this.group.firstChild.dataScope.dataTable.tree;if(!t)return;let e={};for(let t of this.group.children)e[t.dataScope.getFieldValue(o)]=t;this._rootMark.type===A.Rect?this._layoutRects(t.getRoot(),t,e):this._rootMark.type===A.Circle&&this._layoutArcs(t.getRoot(),t,e)}_layoutArcs(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n=i[t.id],r=n.type==A.Arc||n.type==A.Pie?n.startAngle:90;for(let t=0;t<s.length;t++){let n=s[t],a=i[n.id];if(a.type===A.Arc){let t=Ft(r+a.angle);a.adjustAngle(r,t),r=t}this._layoutArcs(n,e,i)}}_layoutRects(t,e,i){let s=e.getChildren(t);if(0===s.length)return;let n,r,a=i[t.id];switch(this._direction){case C.Down:default:n=a.left,r=a.bottom}for(let t=0;t<s.length;t++){let a=s[t],o=i[a.id];o._doTranslate(n-o.left,r-o.top),n+=o.width,this._layoutRects(a,e,i)}}}var od={};function ld(t){return new Oe(t)}function hd(t,e){if(h.indexOf(t)<0)throw new Error(z.UNKOWNN_SCALE_TYPE+": "+t);return new We(t,e)}function cd(t,e){let i=e||{};switch(t.toLowerCase()){case"grid":return new Rt(i);case"packing":return new Ye(i);case"treemap":return new Ue(i);case"stack":return new jt(i);case"tidytree":return new Xe(i);case"force":return new $e(i);case"sugiyama":return new rd(i);case"strata":return new ad(i)}}function dd(t){return new q(t||{})}function ud(t,e){return new Promise((function(i,s){let n=new XMLHttpRequest;n.open(t,e),n.onload=function(){this.status>=200&&this.status<300?i(n.response):s({status:this.status,statusText:n.statusText})},n.onerror=function(){s({status:this.status,statusText:n.statusText})},n.send()}))}async function fd(t){let e=await ud("GET",t),i=n.csvParse(e.trim(),n.autoType);return new $t(i,t)}function pd(t){if(Array.isArray(t)){if(1===t.length)return yt(t[0]);for(let e of t)if(!_t(e)||e.dataScope)return!1;return!0}return yt(t)}function gd(t){if([A.Line,A.Circle,A.Rect,A.Area,A.Ring,A.Pie,A.Path].indexOf(t.type)<0)return!1;if(t.type===A.Path&&(t.closed||!t.firstVertex.dataScope))return!1;if(t.dataScope){let e=st(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function _d(t){if([A.Line,A.Circle,A.Rect,A.Area].indexOf(t.type)<0)return!1;if(t.dataScope){let e=st(t,t.getScene());for(let t of e)if(t.dataScope.numTuples>1)return!0;return!1}return!0}function md(t){return t.type===A.Collection&&!(t.children.length<2)}t.canClassify=md,t.canDensify=_d,t.canDivide=gd,t.canFormGlyph=function(t){for(let e of t)if(!_t(e))return!1;return!0},t.canRepeat=pd,t.cartesianToPolar=function(t,e,i,s){return Tt(t,e,i,s)},t.createScale=hd,t.csv=fd,t.csvFromFile=async function(t){let e=n.csvParse(t.trim(),n.autoType);return new $t(e,"")},t.csvFromString=function(t,e){let i=n.csvParse(t.trim(),n.autoType);return new $t(i,e)},t.csvSync=function(t,e){let i=!!e;var s=new XMLHttpRequest;if(s.open("GET",t,i),s.send(),!i&&function(t){var e=t.responseType;return e&&"text"!==e?t.response:t.responseText}(s)){let e=n.csvParse(s.responseText.trim(),n.autoType);return new $t(e,t)}},t.getPeersInScene=function(t){return"vertex"==t.type||"segment"==t.type?st(t,t.parent.getScene()):st(t,t.getScene())},t.graphjson=async function(t){let e=await ud("GET",t);return new Je(JSON.parse(e),t)},t.hitTest=function(t,e,i){if(!t.children||0==t.children.length)return t.contains(e,i)&&t.type!==A.Scene?t:null;let s=t.children;t.type===A.Scene&&(s=s.slice(),s.sort(((t,e)=>gt(t)?1:gt(e)?-1:0)));for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.hitTestAll=function(t,e,i){let s=pt(t);for(let t=s.length-1;t>=0;t--){let n=s[t];if(n.contains(e,i))return n}return null},t.inMarkHitTest=function(t,e,i,s){let n,r=ft(t),o=s||2,l=wt.getContext();for(let t of r){if(!(t instanceof K))continue;let s=new Path2D(t.getSVGPathData());if(l.lineWidth=Math.max(t.strokeWidth,2*o),l.stroke(s),l.isPointInStroke(s,e,i)){n=t;break}}if(!n)return null;let h=[];for(let t of n.vertices){let e=Math.max(o,t.width,2*t.radius),i=Math.max(o,t.height,2*t.radius);h.push({i:t,b:new a(t.x-e/2,t.y-i/2,e,i)})}for(let t of h)if(t.b.contains(e,i))return t.i;if(n.segments&&n.segments.length>0)for(let t of n.segments){let s=new Path2D;if(s.moveTo(t.vertex1.x,t.vertex1.y),s.lineTo(t.vertex2.x,t.vertex2.y),l.lineWidth=Math.max(n.strokeWidth,o),l.stroke(s),l.isPointInStroke(s,e,i))return t}return null},t.inMarkRectHitTest=function t(e,i,s){let n=s||2;if(_t(e)){let t=[];for(let i of e.vertices){let e=Math.max(n,i.width,2*i.radius),s=Math.max(n,i.height,2*i.radius);t.push({i:i,b:new a(i.x-e/2,i.y-s/2,e,s)})}if(e.type===A.Rect)for(let i of e.segments){let s=Math.max(e.strokeWidth,n);"v"===(i.vertex1.x===i.vertex2.x?"v":"h")?t.push({i:i,b:new a(i.vertex1.x-s/2,Math.min(i.vertex1.y,i.vertex2.y)-s/2,s,Math.abs(i.vertex1.y-i.vertex2.y))}):t.push({i:i,b:new a(Math.min(i.vertex1.x,i.vertex2.x)-s/2,i.vertex1.y-s/2,Math.abs(i.vertex1.x-i.vertex2.x),s)})}for(let e of t)if(e.b.overlap(i))return e.i;return null}if(!gt(e)&&e.children&&e.children.length>0){for(let s of e.children)if(s.bounds.overlap(i)){let e=t(s,i,n);if(e)return e}return null}return null},t.layout=cd,t.linearGradient=dd,t.polarToCartesian=function(t,e,i,s){return Et(t,e,i,s)},t.rectHitTest=function(t,e){let i=[];if(!t.children||0==t.children.length)return t.bounds.overlap(e)&&t.type!==A.Scene?[t]:[];for(let s=t.children.length-1;s>=0;s--){let n=t.children[s];n.bounds.overlap(e)&&i.push(n)}return i},t.renderer=function(t,e){switch(t){case"svg":return new ze(e);case"webgl":return e in od||(od[e]=new ti(e)),od[e]}},t.scene=ld,t.sceneLoader=function(){return new Ze},t.specExecutor=function(){return new Ke},t.specGenerator=function(){return new He},t.treejson=async function(t){let e=await ud("GET",t);return new Ee(JSON.parse(e),t)},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ /* version: 3.0.0 */
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_"+Pt(),this._type=e||o.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 o=Object.freeze({POINT:"point",INTERVAL:"interval",LIST:"list"});class a 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 o.LIST:t=new l(e.type,r,n);break;case o.INTERVAL:t=new a(e.type,r,n);break;case o.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){this._id=e+"_"+Pt(),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 f=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 p{constructor(e){this._id="v_"+Pt(),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 d)return e.fromNode;return null}isIsolated(){return 0==this._incomings.length&&0==this._outgoings.length}}const _=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 g{constructor(e,t){this._event=t,this._type=e}get event(){return this._event}get type(){return this._type}}const y=Object.freeze({ELEMENT:"element",MOUSE:"mouse",ATTRIBUTE:"attribute",WIDGET:"widget",KEYBOARD:"keyboard"});function m(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 b(e,t,r,n,i){const s=i*Math.PI/180,o=e-r,a=t-n;return{x:o*Math.cos(s)-a*Math.sin(s)+r,y:o*Math.sin(s)+a*Math.cos(s)+n}}Object.freeze({INPUT:"input",HOVER:"hover",BRUSH:"brush",BRUSH_X:"brushX",BRUSH_Y:"brushY",CLICK:"click"});const v={svg:void 0,getSVG:function(){return window?(void 0===this.svg&&(this.svg=document.createElement("svg")),this.svg):null}},x={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 E(e,t,r,i,s){for(let o of e){let e=o.listener?o.listener:r,a=e.type===Lt.Axis?e.boundsWithoutTitle:e.bounds,l=[[a.left,a.top],[a.right,a.bottom]],u="brushX"===o.event?n.brushX():"brushY"===o.event?n.brushY():n.brush();u.extent(l).on("brush end",(e=>{let t,n;if(e&&e.selection)switch(o.event){case"brushX":t=[e.selection[0],e.selection[1]],n=void 0;break;case"brushY":t=void 0,n=[e.selection[0],e.selection[1]];break;default:t=[e.selection[0][0],e.selection[1][0]],n=[e.selection[0][1],e.selection[1][1]]}else t=void 0,n=void 0;o.mouseEvent={xInterval:t,yInterval:n},r.onChange(_.TRIGGER,o),i._render(r,s)})),t.append("g").attr("class","brush").call(u)}}function w(e,t,r,n,i){t.on("mousemove",(s=>{for(let n of e){let[e,i]=m(t.attr("id"),s.clientX,s.clientY),o=q(r,n.element.type,e,i);o?n.isCumulative&&!n.elements.includes(o)?n.elements.push(o):n.elements=[o]:n.elements=[],n.mouseEvent={x:e,y:i},r.onChange(_.TRIGGER,n)}n._render(r,i)}))}function A(e,t,r,i,s){for(let t of e)if(t.type===y.WIDGET){console.log(t.id),document.getElementById(t.id).addEventListener("input",(function(){C(t,r,i,s)}))}else t.type===y.KEYBOARD&&n.select("body").on("keydown",(e=>{e.key===t.key&&C(t,r,i,s)}))}function C(e,t,r,n){if(Array.isArray(e.callback))for(let i=0;i<e.callback.length;i++)e.callback[i](),r._render(t,n,e.animation[i]);else e.callback(),r._render(t,n,e.animation)}function R(e,t,r,n,i){t.on("click",(s=>{for(let n of e){let[e,i]=m(t.attr("id"),s.clientX,s.clientY),o=q(r,n.element.type,e,i);o?n.isCumulative&&!n.elements.includes(o)?n.elements.push(o):n.elements=[o]:n.elements=[],n.mouseEvent={x:e,y:i},r.onChange(_.TRIGGER,n)}n._render(r,i)}))}class k{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 k(t,r,n-t,i-r)}clone(){return new k(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 N.RIGHT:this._x=this.right-e/2;break;case N.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 N.TOP:this._y=this.top+e/2;break;case N.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 T(e){let t=e[0].clone();for(let r=1;r<e.length;r++)t=t.union(e[r]);return t}function S(e){return T(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.refBounds?e.refBounds:e.bounds)))}function O(e){return T(("vertex"==e[0].type||"segment"==e[0].type?e.map((e=>e.parent)):e).map((e=>e.bounds)))}function I(e){let t=G(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)I(e)}const N=Object.freeze({TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",CENTER:"center",MIDDLE:"middle"});class L{constructor(e){this._svgId=e,this._compMap={},this._decoMap={},this._brushCreated=0}render(e,t){let r=t||{};this._render(e,r),this._registerEvents(e,r)}_render(e,t,r){for(let e in this._decoMap)this._decoMap[e].remove(),delete this._decoMap[e];this._removed={};for(let e in this._compMap)this._removed[e]=1;this._renderItem(e,t,r);for(let e in this._removed)this._compMap[e].remove(),delete this._compMap[e]}_registerEvents(e,t){let r=n.select("#"+this._svgId);for(let n in e.interactionTriggers){let i=Object.values(e.interactionTriggers[n]);switch(n){case"click":r.on("click",null),R(i,r,e,this,t);break;case"brush":case"brushX":case"brushY":E(i,r,e,this,t);break;case"hover":w(i,r,e,this,t);break;case"input":A(i,0,e,this,t)}}}clear(){let e=document.getElementById(this._svgId);for(;e.firstChild;)e.firstChild.remove();this._compMap={},this._decoMap={}}_renderItem(e,t,r){let i,s=e.id,o=e.parent;i=o&&o.id&&o.id in this._compMap?n.select("#"+this._svgId).select("#"+o.id):n.select("#"+this._svgId),s in this._compMap?(delete this._removed[s],delete this._removed[s+"-bg"]):(e.type===Lt.PointText&&e.hasBackground()&&(this._compMap[s+"-bg"]=i.append("rect")),this._compMap[s]=i.append(this._getSVGElementType(e))),e.type==Lt.Gridlines&&this._compMap[s].lower();let a=this._compMap[s];if(a.attr("id",s),e.classId&&a.attr("class",e.classId),e.type==Lt.Scene&&n.select("#"+this._svgId).style("background",e.fillColor?e.fillColor:"#fff"),"vertex"!=e.type){if(r&&(a=a.transition().delay(r.delay?r.delay:0).duration(r.duration?r.duration:0)),[Lt.Path,Lt.BezierCurve,Lt.BundledPath,Lt.Polygon,Lt.Link,Lt.Pie,Lt.Line,Lt.Area,Lt.Ring,Lt.Arc,Lt.Gridlines].indexOf(e.type)>=0)a.attr("d",e.getSVGPathData()),e.closed||a.style("fill","none"),(s.includes("axis")||s.includes("gridlines"))&&a.style("shape-rendering","crispEdges"),e.type===Lt.BundledPath&&a.style("mix-blend-mode","multiply");else if(e.type==Lt.Circle)a.attr("cx",e.x),a.attr("cy",e.y),a.attr("r",e.radius);else if(e.type==Lt.Rect){let t=e.bounds;a.attr("x",t.left).attr("y",t.top).attr("width",t.width).attr("height",t.height)}else if(e.type==Lt.PointText){if(a.attr("text-anchor",this._getTextAnchor(e.anchor[0])).attr("alignment-baseline",this._getTextAnchor(e.anchor[1])).attr("dominant-baseline",this._getTextAnchor(e.anchor[1])).text(e.text).attr("x",e.x).attr("y",e.y),e.hasBackground()){let t=this._compMap[s+"-bg"],r=e.bounds;t.attr("x",r.left-5).attr("y",r.top-5).attr("width",r.width+10).attr("height",r.height+10).attr("rx",5).attr("ry",5).style("fill",e.backgroundColor).style("stroke",e.borderColor).style("strokeWidth",e.borderWidth)}}else e.type==Lt.Image&&a.attr("href",e.src).attr("x",e.x).attr("y",e.y).attr("width",e.width).attr("height",e.height);for(let t in e.styles)if(void 0!==e.styles[t])if(t.indexOf("Color")>0&&e.styles[t].type==Lt.LinearGradient){n.select("#"+this._svgId).select("defs").empty()&&n.select("#"+this._svgId).append("defs");let r=n.select("defs"),i=e.styles[t];if(r.select("#"+i.id).empty()){let e=r.append("linearGradient").attr("id",i.id);e.attr("x1",i.x1+"%").attr("x2",i.x2+"%").attr("y1",i.y1+"%").attr("y2",i.y2+"%");for(let t of i.stops)e.append("stop").attr("offset",t.offset+"%").style("stop-color",t.color).style("stop-opacity",t.opacity)}a.style(V[t],"url(#"+i.id+")")}else if(a.style(V[t],e.styles[t]),"visibility"===t&&e.type===Lt.PointText&&e.hasBackground()){this._compMap[s+"-bg"].style(V[t],e.styles[t])}if(e._rotate&&a.attr("transform","rotate("+e._rotate.join(" ")+")"),e.vertices&&this._renderVertices(e),[Lt.Circle].includes(e.type)&&t&&t.bounds){let t=e.bounds;e.layout&&"grid"==e.layout.type&&this._renderLayout(e),e.id in this._decoMap||(this._decoMap[e.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[e.id].attr("x",t.left).attr("y",t.top).attr("width",t.width).attr("height",t.height).attr("fill","none").attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5")}else if(B(e)&&t&&t.refBounds){let t=e.refBounds;t&&(e.id in this._decoMap||(this._decoMap[e.id]=n.select("#"+this._svgId).append("rect").attr("class","deco")),this._decoMap[e.id].attr("x",t.left).attr("y",t.top).attr("width",t.width).attr("height",t.height).attr("fill","none").attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5"))}if(e.children)for(let n of e.children)this._renderItem(n,t,r)}}_renderVertices(e){let t=e.id+"-vertices";if(t in this._compMap)delete this._removed[t];else{let r=e.parent,i=r?r.id:this._svgId;this._compMap[t]=n.select("#"+i).append("g").attr("id",t)}if(0===e.vertices.map((e=>e.shape)).filter((e=>void 0!==e)).length)return void this._compMap[t].style("visible","hidden");this._compMap[t].style("visible","visible");let r=e.vertices.filter((e=>void 0!==e.shape));for(let e of r){let r=t+"-"+e.id;r in this._compMap?e.shape!==this._compMap[r].node().tagName?(this._compMap[r].remove(),this._compMap[r]=n.select("#"+t).append(e.shape).attr("id",r),delete this._removed[r]):delete this._removed[r]:this._compMap[r]=n.select("#"+t).append(e.shape).attr("id",r),"rect"==e.shape?n.select("#"+r).attr("x",e.x-e.width/2).attr("y",e.y-e.height/2).attr("width",e.width).attr("height",e.height):"circle"==e.shape&&n.select("#"+r).attr("cx",e.x).attr("cy",e.y).attr("r",e.radius),n.select("#"+r).style("fill",e.fillColor).style("opacity",e.opacity).style("stroke-width",e.strokeWidth).style("stroke",e.strokeColor)}}_renderLayout(e){let t=e.id+"-grid";t in this._decoMap||(this._decoMap[t]=n.select("#"+this._svgId).append("g").attr("id",t).attr("class","deco"));let r=e.layout.cellBounds;e.layout.rowGap,this._decoMap[t].selectAll("rect").remove();for(let e of r)this._decoMap[t].append("rect").attr("x",e.left).attr("y",e.top).attr("width",e.width).attr("height",e.height).attr("stroke","blue").attr("stroke-width","1px").attr("stroke-dasharray","5,5").attr("fill","none")}_getTextAnchor(e){switch(e){case N.TOP:return"text-before-edge";case N.BOTTOM:return"auto";case N.LEFT:return"start";case N.RIGHT:return"end";case N.CENTER:case N.MIDDLE:return"middle";default:return e}}_getSVGElementType(e){switch(e.type){case Lt.Rect:return"rect";case Lt.Collection:case Lt.Group:case Lt.Glyph:case Lt.Scene:case Lt.Axis:case Lt.Legend:case Lt.Composite:return"g";case Lt.Area:case Lt.Path:case Lt.Polygon:case Lt.Ring:case Lt.Pie:case Lt.Arc:case Lt.BezierCurve:case Lt.BundledPath:case Lt.Line:case Lt.Gridlines:return"path";case Lt.Circle:return"circle";case Lt.PointText:return"text";case"vertex":if("circle"==e.shape)return"circle";if("rect"==e.shape)return"rect";throw"argument exception";case"image":return"image"}}}const V=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 P{constructor(e){let t=e||{};this._stops=[],this.type=Lt.LinearGradient,this.id=this.type+Pt(),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 D{constructor(e){if(this._dataScope=void 0,this._type="type"in e?e.type:Lt.Mark,this._id=e.id?e.id:this._type+"_"+Pt(),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 V)t in e&&(this.styles[t]=e[t])}get scene(){return Y(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 Lt.Rect:case Lt.PointText:return!0;case Lt.Circle:return Math.sqrt(Math.pow(e-this.x,2)+Math.pow(t-this.y,2))<=this.radius+this.strokeWidth;case Lt.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 Lt.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 B(e){return e instanceof D&&e.type!==Lt.Gridlines}const M=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 G(e,t){let r=Y(e),n=t||r;if("vertex"===e.type){return j(e,F(n,[{property:"classId",value:e.parent.classId}]))}if("segment"===e.type){return z(e,F(n,[{property:"classId",value:e.parent.classId}]))}return e.classId?F(n,[{property:"classId",value:e.classId}]):[e]}function j(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===Lt.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 z(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 F(e,t){let r=[];return W(e,t,r),r}function U(e,t){let r=e.children.filter((e=>e.type==Lt.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 H(e){return e.type==Lt.Collection?e:e.parent?H(e.parent):void 0}function W(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)W(n,t,r)}function Y(e){let t=e;for(;t;){if(t.type==Lt.Scene)return t;t=t.parent}}function X(e){let t=e;for("vertex"!=t.type&&"segment"!=t.type||(t=t.parent);t.parent&&[Lt.Collection,Lt.Glyph].includes(t.parent.type);)t=t.parent;return t}function q(e,t,r,n){let i=F(e,[{property:"type",value:t}]);for(let e of i)if(K(e,r,n))return e}function K(e,t,r){switch(e.type){case Lt.Path:case Lt.BezierCurve:case Lt.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 Lt.Circle:{let n=e.x,i=e.y;if(e.rotation){let t=b(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 Z(e,t){let r=[];if($(e,r),t){let e={};for(let t of r)e[t.classId]=t;return Object.values(e)}return r}function $(e,t){if(B(e))t.push(e);else if(e.type==Lt.Collection&&e.children)for(let r of e.children)$(r,t);else if(e.type==Lt.Glyph&&e.children)for(let r of e.children)$(r,t);else if(e.type==Lt.Composite&&e.children)for(let r of e.children)$(r,t)}class J{constructor(){this._refElements=[]}addRefElement(e){this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}const Q=Object.freeze({GRID:"grid",STACK:"stack",PACKING:"packing",FORCE:"force",DIRECTED:"directedgraph",TIDYTREE:"tidytree",TREEMAP:"treemap",STRATA:"strata",CIRCULAR:"circular",CLUSTER:"cluster"});function ee(e,t){return!!(e.startsWith("h")&&[N.LEFT,N.CENTER,N.RIGHT].indexOf(t)>=0)||(!!(e.startsWith("v")&&[N.TOP,N.MIDDLE,N.BOTTOM].indexOf(t)>=0)||(console.warn("Invalid alignment:",t),!1))}class te extends p{constructor(e,t){super(e),this._condEnc=t}get condEncoding(){return this._condEnc}}const re=Object.freeze({RowFirst:"rowFirst",ColumnFirst:"columnFirst"}),ne=Object.freeze({TopLeft:"topLeft",TopRight:"topRight",BottomLeft:"bottomLeft",BottomRight:"bottomRight"}),ie={HORIZONTAL:"horizontal",VERTICAL:"vertical",ANGULAR:"angular",RADIAL:"radial"},se={Left2Right:"l2r",Right2Left:"r2l",Top2Bottom:"t2b",Bottom2Top:"b2t"},oe=Object.freeze({CLOCKWISE:"clockwise",ANTI_CLOCKWISE:"anti-clockwise"}),ae=Object.freeze({INWARD:"inward",OUTWARD:"outward"});class le{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 k(this.x-this.width/2,this.y-this.height/2,this.width,this.height);case"circle":return new k(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius);default:return new k(this.x-.5,this.y-.5,1,1)}}get id(){return this.parent.id+"_v_"+this._id}_clone(e){let t=new le(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}}le.styles=["vxShape","vxWidth","vxHeight","vxRadius","vxFillColor","vxStrokeColor","vxStrokeWidth","vxOpacity"];class ue{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 ce extends D{constructor(e){super(e),this._type="type"in e?e.type:Lt.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 le.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!==Lt.Path){t=new le(e[r][0],e[r][1],this,this.vertexCounter++);for(let e of le.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 ue(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===Lt.Rect)&&(this.closed=!0,"fillColor"in this.styles||(this.styles.fillColor="#fff"),this.segments.push(new ue(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 le.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 ue(e.vertices[t-1],e.vertices[t],e,e.segmentCounter++));e.closed&&e.segments.push(new ue(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,o=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/o*(e.y-i.top);else for(let e of this.vertices)e._y=i.bottom-t/o*(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),o=i-r,a=s-n;if(this._bounds=new k(r,n,o,a),this.type===Lt.Line||this.type===Lt.Path){let e=this.styles.strokeWidth?this.styles.strokeWidth:1;r===i?this._bounds=new k(r-e/2,n,i-r+e,s-n):n===s&&(this._bounds=new k(r,n-e/2,i-r,s-n+e))}}addVertex(e,t,r){let n=new le(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 fe.Natural:return n.curveNatural;case fe.Basis:return n.curveBasis;case fe.BumpX:return n.curveBumpX;case fe.BumpY:return n.curveBumpY;case fe.Linear:return n.curveLinear;case fe.Step:return n.curveStep;case fe.CatmullRom:return n.curveCatmullRom;case fe.Cardinal:return n.curveCardinal;case fe.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 he(e,t){const r=v.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 de(e){return e instanceof ce&&e.source&&e.target}const fe={Natural:"natural",Basis:"basis",BumpX:"bumpX",BumpY:"bumpY",Bundle:"bundle",Linear:"linear",Step:"step",CatmullRom:"CatmullRom",Cardinal:"cardinal"};function pe(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,o]=s.split(i).map(Number);return`${n}${e+t} ${o+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 _e extends ce{constructor(e){super(e),this._type=Lt.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=ge(this._startAngle),this._er=ge(this._endAngle),this._direction="direction"in e?e.direction:oe.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),o=this._y-this._outerRadius*Math.sin(this._sr),a=this._x+this._outerRadius*Math.cos(this._er),l=this._y-this._outerRadius*Math.sin(this._er);this._setVertices([[t,r],[s,o],[a,l],[n,i]])}get type(){return 0===this._innerRadius?Lt.Pie:Lt.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=ge(this._startAngle),this._er=ge(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(){this._bounds=new k(this._x-this._outerRadius,this._y-this._outerRadius,2*this._outerRadius,2*this._outerRadius)}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 ge(e){return e*Math.PI/180}function ye(e){return 180*e/Math.PI}function me(e){return e<0?e+360:e>360?e-360:e}function be(e,t,r,n){let i=e-r,s=t-n;return Math.atan2(s,i)*(180/Math.PI)}class ve{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 ve(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 ve(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 Ee.Max:return Math.max(...r);case Ee.Min:return Math.min(...r);case Ee.Avg:case Ee.Mean:return n.mean(r);case Ee.Median:return n.median(r);case Ee.Count:return r.length;case Ee.Percentile25:return n.quantile(r,.25);case Ee.Percentile75:return n.quantile(r,.75);case Ee.Sum:default:return n.sum(r)}}_updateTuples(e,t){this._tuples=this._tuples.filter((r=>r[e]==t))}get tuples(){return this._tuples}}function xe(e){return"vertex"==e.type||"segment"==e.type?e.dataScope?e.dataScope:e.parent.dataScope:e.dataScope}const Ee={Max:"max",Min:"min",Avg:"avg",Median:"median",Sum:"sum",Count:"count",Mean:"mean",Percentile25:"percentile 25",Percentile75:"percentile 75"};class we{constructor(e,t){this._id=Lt.TreeData+Pt(),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 Dt(this._nodeList,"nodes"),this._linkTable=new Dt(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={};Te in e||(e[Te]="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[Te],child:s})}else i[s]=e[s];return this._nodeHash[i[Te]]=i,i[Te]}getNodeDataScope(e){return new ve(this._nodeTable).cross(Mt,e[Mt])}getRoot(){return this._nodeTable.data[0]}getChildren(e){let t=e[Te],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[Te]==t));r.push(i[s])}return r}}function Ae(e){return e.dataScope._dt.tree}class Ce{constructor(e,t){this._id=Lt.NetworkData+Pt(),this.initialize(e,t)}initialize(e,t){this.url=t,this._nodeTable=new Dt(e.nodes,this._id+"_nodes"),this._linkTable=new Dt(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[Te]]=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[Te],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[Te]="root",ke(t,this._rawNodes,e),new we(t,this.url)}}function Re(e){return e.dataScope._dt.graph}function ke(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[Te]=t,e.children.push(r)}else for(let t in n){let i={};i[Te]=t,e.children.push(i),ke(i,n[t],r.slice(1))}}const Te="id";function Se(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 Oe=Object.freeze({Boolean:"boolean",Integer:"integer",Number:"number",Date:"date",String:"string"});function Ie(e){var t=Object.values(Oe);for(let r=0;r<e.length;r++){let n=e[r];if(null!=n){for(let e=0;e<t.length;e++)Ne[t[e]](n)||(t.splice(e,1),e-=1);if(1==t.length)return t[0]}}return t[0]}const Ne={boolean:function(e){return"true"===e||"false"===e||!0===e||!1===e||"[object Boolean]"==toString.call(e)},integer:function(e){return Ne.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 Le(e,t){let r={};switch(t){case Oe.Boolean:r.trueCount=e.filter((e=>e)).length,r.falseCount=e.filter((e=>!e)).length;break;case Oe.Date:r.min=n.min(e),r.max=n.max(e),r.extent=[r.min,r.max],r.unique=[...new Set(e)];break;case Oe.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 Ve(e,t,r,n,i){let s=i.getAttributeType(r);if(s!=Oe.String&&s!=Oe.Date&&s!=Oe.Number&&s!=Oe.Integer)throw new Error("Densify only works on a string or date attribute: "+r+" is "+s);if(!function(e){if([Lt.Line,Lt.Circle,Lt.Rect,Lt.Area].indexOf(e.type)<0)return!1;if(e.dataScope){let t=G(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 Lt.Line:return function(e,t,r){let n,i,s=G(e);for(let o of s){let s=o.dataScope?o.dataScope:new ve(r),a=r.getUniqueAttributeValues(t).map((e=>s.cross(t,e)));a=a.filter((e=>!e.isEmpty())),1===a.length&&a.push(a[0].clone());let l=Object.assign({},o.styles);for(let e of le.styles)o[e]&&(l[e]=o[e]);let u=o.vertices[0].x,c=o.vertices[0].y,h=[],d=o.vertices[1].x-u,f=o.vertices[1].y-c;for(let e=0;e<a.length;e++)h.push([u+e*d/(a.length-1),c+e*f/(a.length-1)]);l.vertices=h,l.type="path";let p=Tt(l);i||(i=p.id),p._classId=i,p.dataScope=s,p._updateBounds(),p._refBounds=p.bounds.clone();let _=o.parent;_.addChild(p),_.removeChild(o);for(let[e,t]of p.vertices.entries())t.dataScope?t.dataScope=t.dataScope.merge(a[e]):t.dataScope=a[e];o==e&&(n=p)}return n}(t,r,i);case Lt.Circle:return function(e,t,r,n,i){let s,o,a=G(e),l=r.getAttributeType(t);for(let u of a){let a=u.dataScope?u.dataScope:new ve(r),c=r.getUniqueAttributeValues(t).map((e=>a.cross(t,e)));c=l==Oe.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=Pe(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=Tt(y);o||(o=m.id),m._classId=o,m.dataScope=a;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=a.merge(c[2*c.length-1-e]):t.dataScope=a.merge(c[e]);u===e&&(s=m)}return s}(t,r,i);case Lt.Rect:return function(e,t,r,n){let i,s,o=G(e),a=t||ie.HORIZONTAL;if(a!=ie.HORIZONTAL&&a!=ie.VERTICAL)throw new Error("Unknown orientation: "+a);for(let t of o){let o=n.getAttributeType(r),l=t.dataScope?t.dataScope:new ve(n),u=n.getUniqueAttributeValues(r).map((e=>l.cross(r,e)));u=o==Oe.Number?u:u.filter((e=>!e.isEmpty())),1===u.length&&u.push(u[0].clone()),o!=Oe.Number&&o!=Oe.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,y=p-d;for(let e=0;e<u.length;e++)_.push(a==ie.VERTICAL?[f,d+e*y/(u.length-1)]:[h+e*g/(u.length-1),d]);for(let e=0;e<u.length;e++)_.push(a==ie.VERTICAL?[h,d+(u.length-1-e)*y/(u.length-1)]:[h+(u.length-1-e)*g/(u.length-1),p]);c.vertices=_,c.type="area";let m=Tt(c);s||(s=m.id),m._classId=s,m.dataScope=l,m.orientation=a,m.baseline=a===ie.HORIZONTAL?N.BOTTOM:N.LEFT;let b=t.parent;b.addChild(m),b.removeChild(t);for(let[e,t]of m.vertices.entries())e>=u.length?t.dataScope=l.merge(u[2*u.length-1-e]):t.dataScope=l.merge(u[e]);t===e&&(i=m)}return i}(t,n,r,i)}}function Pe(e,t,r,n){return[r*Math.cos(ge(n))+e,t-r*Math.sin(ge(n))]}class De extends p{constructor(e,t,r){super(e),this._channel=t,this._elem=r}get channel(){return this._channel}get element(){return this._elem}}const Be=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 Me(e,t){delete t._encodings[Fe(e.element)][e.channel]}function Ge(e,t){let r=e.scene._encodings[Fe(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 je(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 ze(e,t){let r=e.scene._encodings[Fe(e)];return r&&r[t]?r[t]:null}function Fe(e){if(e.classId)return e.classId;if("vertex"==e.type&&e.dataScope){if(e.parent.type===Lt.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 Ue(e,t){if(0==e.children.length)return[];let r=Y(e),n=e.type===Lt.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===Lt.Glyph){t.children.forEach((e=>s.push(e.classId)));break}if(!t.children)break;t=t.children[0]}}let o=[];for(let e of i)for(let n of s)0===e.indexOf(n)&&r._encodings[e][t]&&o.push(r._encodings[e][t]);return o}function He(e){let t=ze(e,"y"),r=ze(e,"height");return t||r&&r.scales[0].domain[0]<0}function We(e){let t=ze(e,"x"),r=ze(e,"width");return t||r&&r.scales[0].domain[0]<0}function Ye(e,t){let r=function(e){let t=e.parent,r=[];for(;t.type!==Lt.Scene;)r.push(t),t=t.parent;return r}(e);for(let e of r)if(ze(e,t))return!1;return r.length>=2?r[r.length-2]:e}function Xe(e,t,r){switch(e.type){case Lt.Rect:case Lt.Path:case Lt.Line:case Lt.Area:!function(e,t,r){for(let n of e.vertices)qe(n,t,r);e._updateBounds(),e._refBounds&&e._refBounds.translate(t,r)}(e,t,r);break;case Lt.Group:case Lt.Collection:case Lt.Glyph:!function(e,t,r){for(let n of e.children)Xe(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){qe(e.vertex1,t,r),qe(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 qe(e,t,r){e._x+=t,e._y+=r}function Ke(e,t,r){switch(t){case"x":$e(e,r);break;case"y":Je(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===Lt.Circle?e.radius=Math.sqrt(r/Math.PI):e.type===Lt.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":[Lt.Arc,Lt.Pie].includes(e.type)&&function(e,t){e._endAngle=me(e._startAngle+t),e._sr=ge(e._startAngle),e._er=ge(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=me(e._startAngle+r),e._sr=ge(e._startAngle),e._er=ge(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){Ze(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":Ze(e,r);break;case"radialDistance":{let t=Pe(e.parent.x,e.parent.y,r,e.polarAngle);$e(e,t[0]),Je(e,t[1]);break}case"visibility":e.visibility=r;break;default:if("vertex"===e.type)e[t]=r;else if(e instanceof mt)for(let n of e.children)Ke(n,t,r);else e.styles[t]=r}}function Ze(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 $e(e,t){"vertex"==e.type?e._x=t:Xe(e,t-e.x,0)}function Je(e,t){"vertex"==e.type?e._y=t:Xe(e,0,t-e.y)}class Qe extends ce{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 et extends ce{constructor(e){super(e),this._type=Lt.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 ue(this.vertices[this.vertices.length-1],this.vertices[0],this,this.segmentCounter++))}get topLeftVertex(){return this._orientation===ie.HORIZONTAL?this.vertices[0]:this.vertices[this.vertices.length-1]}get bottomLeftVertex(){return this._orientation===ie.HORIZONTAL?this.vertices[this.vertices.length-1]:this.vertices[this.vertices.length/2]}get topRightVertex(){return this._orientation===ie.HORIZONTAL?this.vertices[this.vertices.length/2-1]:this.vertices[0]}get bottomRightVertex(){return this._orientation===ie.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 tt extends p{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 rt extends d{constructor(e){super(e)}storeValues(e,t){this._storedValues={};let r=G(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 tt)),t=this.outputVar,r=G(t.element);if(e){let r=e.encodings.find((e=>e.channel==t.channel&&Fe(e.element)==Fe(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))),I(["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,N.CENTER),e._refBounds.setHeight(2*t.rangeExtent,N.MIDDLE)}));break;case"x":"vertex"!=e[0].type&&"segment"!=e[0].type||e.forEach((e=>{let n=e.parent._refBounds;e.parent._refBounds=new k(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 k(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 Qe?function(e,t,r){for(let n=0;n<e.length;n++){let i=e[n],s=i.refBounds.left+t.map(0),o=i.refBounds.left+t.map(r[i.id]);Xe(i.leftSegment,s-i.leftSegment.x,0),Xe(i.rightSegment,o-i.rightSegment.x,0)}}(e,t,r):t.domain[0]<0&&e[0]instanceof et||(e[0].type===Lt.Area?function(e,t,r){let n=e[0].baseline;if(e[0].orientation===ie.VERTICAL)switch(n){case"left":for(let n of e)G(n.topLeftVertex,n).forEach((e=>Ke(e,"x",n.refBounds.left))),G(n.topRightVertex,n).forEach((e=>Ke(e,"x",n.refBounds.left+t.map(r[e.id]))));break;case"right":for(let n of e)G(n.topLeftVertex,n).forEach((e=>Ke(e,"x",n.refBounds.right-t.map(r[e.id])))),G(n.topRightVertex,n).forEach((e=>Ke(e,"x",n.refBounds.right)));break;case"center":console.log("center");for(let n of e)G(n.topLeftVertex,n).forEach((e=>Ke(e,"x",n.refBounds.center-t.map(r[e.id])/2))),G(n.topRightVertex,n).forEach((e=>Ke(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 Qe?function(e,t,r){for(let n=0;n<e.length;n++){let i=e[n],s=i.refBounds.bottom-t.map(0),o=i.refBounds.bottom-t.map(r[i.id]);Xe(i.bottomSegment,0,s-i.bottomSegment.y),Xe(i.topSegment,0,o-i.topSegment.y)}}(e,t,r):t.domain[0]<0&&e[0]instanceof et?function(e,t,r){for(let n of e){let e=j(n.topLeftVertex,[n]);for(let i of e)Ke(i,"y",n.refBounds.bottom-t.map(r[i.id]));j(n.bottomLeftVertex,[n]).forEach((e=>Ke(e,"y",n.refBounds.bottom-t.map(0))))}}(e,t,r):e[0].type===Lt.Area?function(e,t,r){let n=e[0].baseline;if(e[0].orientation===ie.HORIZONTAL)switch(n){case"bottom":for(let n of e)G(n.topLeftVertex,n).forEach((e=>Ke(e,"y",n.refBounds.bottom-t.map(r[e.id])))),G(n.bottomLeftVertex,n).forEach((e=>Ke(e,"y",n.refBounds.bottom)));break;case"top":for(let n of e)G(n.bottomLeftVertex,n).forEach((e=>Ke(e,"y",n.refBounds.top+t.map(r[e.id])))),G(n.topLeftVertex,n).forEach((e=>Ke(e,"y",n.refBounds.top)));break;case"middle":for(let n of e)G(n.topLeftVertex,n).forEach((e=>Ke(e,"y",n.refBounds.middle-t.map(r[e.id])/2))),G(n.bottomLeftVertex,n).forEach((e=>Ke(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),o=Math.max(...e),a="horizontal"===i.orientation?new P({x1:0,y1:100,x2:0,y2:0}):new P({x1:0,y1:0,x2:100,y2:0});if(a.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<o&&a.addStop(100*(r-s)/(o-s),t.map(r),1)}else"divergingColor"===t.type&&a.addStop(100*-s/(o-s),t.map(0),1);"sequentialColor"===t.type&&a.addStop(100*-s/(o-s),t.map(0),1),a.addStop(100,t.map(o),1),i.fillColor=a}}(e,t,r,n);break;default:this._doStandardMapping(e,t,r)}}_doTextMapping(e,t){let r=this.outputVar.channel;e.forEach((e=>{Ke(e,r,t[e.id])}))}_doStandardMapping(e,t,r){let n=this.outputVar.channel;e.forEach((e=>{let i=t.map(r[e.id]);Ke(e,n,i),e instanceof ce&&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),Ke(t,r,i)}_getUsableCondEncodings(){return this.inputVars.filter((e=>e instanceof te))}}class nt extends p{constructor(e,t,r){super(e),this._property=t,this._elem=r}get property(){return this._property}get element(){return this._elem}}const it=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 st(e,t){let r=t.getVariable(_.BOUNDS,e),n=t.createOneWayDependency(f.EVAL_BBOX);switch(t.connect(n,r),e.type){case Lt.Circle:case Lt.Polygon:{let r=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"radius",e),o=t.getVariable(_.CHANNEL,"area",e);t.connect(s,n),t.connect(r,n),t.connect(i,n),t.connect(o,n);break}case Lt.Area:case Lt.Line:case Lt.BezierCurve:case Lt.Path:case Lt.Image:{let r=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"width",e),o=t.getVariable(_.CHANNEL,"height",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(o,n);break}case Lt.Rect:{let r=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"width",e),o=t.getVariable(_.CHANNEL,"height",e),a=t.getVariable(_.CHANNEL,"area",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(o,n),t.connect(a,n);break}case Lt.PointText:{let r=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"text",e);t.connect(r,n),t.connect(i,n),t.connect(s,n);break}case Lt.Ring:{let r=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"innerRadius",e),o=t.getVariable(_.CHANNEL,"outerRadius",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(o,n);break}case Lt.Pie:case Lt.Arc:{let r=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"innerRadius",e),o=t.getVariable(_.CHANNEL,"outerRadius",e),a=t.getVariable(_.CHANNEL,"startAngle",e),l=t.getVariable(_.CHANNEL,"endAngle",e),u=t.getVariable(_.CHANNEL,"angle",e),c=t.getVariable(_.CHANNEL,"thickness",e);t.connect(r,n),t.connect(i,n),t.connect(s,n),t.connect(o,n),t.connect(a,n),t.connect(l,n),t.connect(u,n),t.connect(c,n);break}}n.run()}function ot(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 at(e,t){let r=t.findVariable(_.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 lt(e,t){if(e.type===Lt.Axis){let r=t.findVariable(_.PROPERTY,[it.AXIS_PATH_POSITION,e]).incomingDataflow;t.deleteOperator(r),r=t.findVariable(_.PROPERTY,[it.AXIS_TICKS_POSITION,e]).incomingDataflow,t.deleteOperator(r),r=t.findVariable(_.PROPERTY,[it.AXIS_LABELS_POSITION,e]).incomingDataflow,t.deleteOperator(r)}else if(e.type===Lt.Gridlines){let r=t.findVariable(_.PROPERTY,[it.GRIDLINES_POSITION,e]).incomingDataflow;t.deleteOperator(r)}}function ut(e,t){let r=t.getVariable(_.BOUNDS,e),n=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"width",e),o=t.getVariable(_.CHANNEL,"height",e),a=t.createOneWayDependency(f.EVAL_BBOX);t.connect(n,a),t.connect(i,a),t.connect(s,a),t.connect(o,a),t.connect(a,r),a.run()}function ct(e,t,r){let n=r.getVariable(_.BOUNDS,e),i=r.getVariable(_.BOUNDS,t),s=r.getIncomingDataflowOperator(f.EVAL_BBOX,n),o=i.outgoingEdges.find((e=>e.fromNode===i&&e.toNode===s));if(o&&r.disconnect(i,s,o),e.layout){let n=r.getVariable(_.CHANNEL,"x",t),i=r.getIncomingDataflowOperator(dt(e.layout.type),n);i&&r.deleteOperator(i)}}function ht(e,t,r){let n=r.getVariable(_.BOUNDS,e),i=r.getVariable(_.BOUNDS,t),s=r.getIncomingDataflowOperator(f.EVAL_BBOX,n);r.connect(i,s),r.connect(s,n),e.layout&&pt(e,e.layout,r)}function dt(e){switch(e){case Q.GRID:return f.GRID_LAYOUT;case Q.STACK:return f.STACK_LAYOUT;case Q.PACKING:return f.PACK_LAYOUT;case Q.FORCE:return f.FORCE_LAYOUT;case Q.DIRECTED:return f.DIRECTED_LAYOUT;case Q.TIDYTREE:return f.TIDY_TREE_LAYOUT;case Q.TREEMAP:return f.TREEMAP_LAYOUT;case Q.STRATA:return f.STRATA_LAYOUT;case Q.CIRCULAR:return f.CIRCULAR_LAYOUT;case Q.CLUSTER:return f.CLUSTER_LAYOUT}}function ft(e,t,r){let n=r.getVariable(_.ORDER,e),i=r.getOutgoingDataflowOperator(dt(t.type),n);r.deleteOperator(i)}function pt(e,t,r){let n=t?t.type:"none",i=n===Q.TREEMAP?Z(e)[0]:Q.STRATA?e.children[1]:e.children[0];if(!i)return;let s=r.getVariable(_.CHANNEL,"width",i),o=r.getVariable(_.CHANNEL,"height",i),a=r.getVariable(_.ORDER,e),l=r.getVariable(_.CHANNEL,"x",i),u=r.getVariable(_.CHANNEL,"y",i),c=r.getOutgoingDataflowOperator(dt(n),a);if(r.connect(s,c),r.connect(o,c),r.connect(a,c),r.connect(c,l),r.connect(c,u),r.disconnectChannelVarFromBBoxOperator(s),r.disconnectChannelVarFromBBoxOperator(o),i.type===Lt.Arc||i.type===Lt.Pie){let e=r.getVariable(_.CHANNEL,"angle",i),t=r.getVariable(_.CHANNEL,"thickness",i);r.connect(e,c),r.connect(t,c)}else if(i.type===Lt.Circle){let e=r.getVariable(_.CHANNEL,"area",i),t=r.getVariable(_.CHANNEL,"radius",i);r.connect(e,c),r.connect(t,c),r.disconnectChannelVarFromBBoxOperator(e),r.disconnectChannelVarFromBBoxOperator(t)}else if(i.type===Lt.Rect){let e=r.getVariable(_.CHANNEL,"area",i);r.connect(e,c),r.disconnectChannelVarFromBBoxOperator(e)}if(c.run(),i.links){let e=i.links[0],t=r.getVariable(_.CHANNEL,"x",e),n=r.getVariable(_.CHANNEL,"strokeWidth",e),s=r.getVariable(_.CHANNEL,"strength",e),o=r.createOneWayDependency(f.LINK_PLACER);r.connect(l,o),r.connect(n,o),r.connect(s,o),r.connect(o,t)}if(i.children&&i.children[0]){let e=r.getVariable(_.BOUNDS,i.children[0]),t=r.getVariable(_.CHANNEL,"x",i).incomingDataflow;t&&r.connect(e,t),r.disconnectChannelVarFromBBoxOperator(e)}}function _t(e,t){let r=t.getVariable(_.PROPERTY,it.AXIS_ORIENTATION,e),n=t.getVariable(_.BOUNDS,e.elements[0].parent),i=t.getVariable(_.PROPERTY,it.AXIS_PATH_POSITION,e),s=t.createOneWayDependency(f.AXIS_PATH_PLACER);t.connect(r,s),t.connect(n,s),t.connect(s,i),s.run();let o=t.getVariable(_.PROPERTY,it.AXIS_TICK_OFFSET,e),a=t.getVariable(_.PROPERTY,it.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(f.AXIS_TICKS_PLACER),u=t.getVariable(_.PROPERTY,it.AXIS_TICKS_POSITION,e);t.connect(i,l),t.connect(o,l),t.connect(a,l),t.connect(l,u),l.run();let c=t.getVariable(_.PROPERTY,it.AXIS_LABEL_OFFSET,e),h=t.getVariable(_.PROPERTY,it.AXIS_LABEL_FORMAT,e),d=t.getVariable(_.PROPERTY,it.AXIS_FONT_SIZE,e),p=t.createOneWayDependency(f.AXIS_LABELS_PLACER),g=t.getVariable(_.PROPERTY,it.AXIS_LABELS_POSITION,e);t.connect(i,p),t.connect(c,p),t.connect(h,p),t.connect(d,p),t.connect(p,g),p.run();let y=t.getVariable(_.PROPERTY,it.AXIS_TITLE_POSITION,e),m=t.createOneWayDependency(f.AXIS_TITLE_PLACER);t.connect(i,m),t.connect(m,y),m.run();let b=t.getVariable(_.BOUNDS,e),v=t.getIncomingDataflowOperator(f.EVAL_BBOX,b);t.connect(u,v),t.connect(g,v),t.connect(v,b)}function gt(e,t){let r=t.getVariable(_.PROPERTY,it.AXIS_ORIENTATION,e),n=t.getVariable(_.BOUNDS,X(e.elements[0])),i=t.getVariable(_.PROPERTY,it.AXIS_PATH_POSITION,e),s=t.createOneWayDependency(f.AXIS_PATH_PLACER);t.connect(r,s),t.connect(n,s),t.connect(s,i),s.run();let o=t.getVariable(_.PROPERTY,it.AXIS_TICK_OFFSET,e),a=t.getVariable(_.PROPERTY,it.AXIS_TICK_SIZE,e),l=t.createOneWayDependency(f.AXIS_TICKS_PLACER),u=t.getVariable(_.PROPERTY,it.AXIS_TICKS_POSITION,e);t.connect(i,l),t.connect(o,l),t.connect(a,l),t.connect(l,u),l.run();let c=t.getVariable(_.PROPERTY,it.AXIS_LABEL_OFFSET,e),h=t.getVariable(_.PROPERTY,it.AXIS_LABEL_FORMAT,e),d=t.getVariable(_.PROPERTY,it.AXIS_FONT_SIZE,e),p=t.createOneWayDependency(f.AXIS_LABELS_PLACER),g=t.getVariable(_.PROPERTY,it.AXIS_LABELS_POSITION,e);t.connect(i,p),t.connect(c,p),t.connect(h,p),t.connect(d,p),t.connect(p,g),p.run();let y=t.getVariable(_.PROPERTY,it.AXIS_TITLE_POSITION,e),m=t.createOneWayDependency(f.AXIS_TITLE_PLACER);t.connect(i,m),t.connect(m,y),m.run();let b=t.getVariable(_.BOUNDS,e),v=t.getIncomingDataflowOperator(f.EVAL_BBOX,b);t.connect(u,v),t.connect(g,v),t.connect(v,b)}function yt(e,t){let r=t.getVariable(_.BOUNDS,X(e.elements[0])),n=t.getVariable(_.PROPERTY,it.GRIDLINES_POSITION,e),i=t.createOneWayDependency(f.GRIDLINES_PLACER);t.connect(r,i),t.connect(i,n),i.run();let s=t.getVariable(_.BOUNDS,e),o=t.getIncomingDataflowOperator(f.EVAL_BBOX,s);t.connect(n,o),t.connect(o,s)}class mt{constructor(){this._id=this.type+Pt(),this._type=Lt.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===Lt.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 o of i)n[0]==o&&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),pt(this,e,this.scene._depGraph),this.children&&this.children.length>0){let e=Z(this,!0);for(let t of e)this.scene.onChange(_.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 k(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 k(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 Y(this)}}class bt extends mt{constructor(){super(),this._type=Lt.Collection,this._id=this.type+"_"+Pt(),this._classId=this.id,this._childrenOrder=void 0}get classId(){return this._classId}contains(e,t){if([Lt.Arc,Lt.Pie,Lt.Polygon,Lt.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 vt extends mt{constructor(e){if(super(),this._type=Lt.Glyph,this._id=this.type+"_"+Pt(),this._classId=this._id,e)for(let t of e)this.addChild(t)}get classId(){return this._classId}}class xt extends ce{constructor(e){super(e),this._type=Lt.BezierCurve,this._orientation="orientation"in e?e.orientation:ie.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 Et extends D{constructor(e){super(e),this._type=Lt.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=b(this._x,this._y,this._rotate[1],this._rotate[2],this._rotate[0]);this._bounds=new k(e.x-this._radius,e.y-this._radius,2*this._radius,2*this._radius)}else this._bounds=new k(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 wt extends D{constructor(e){super(e),this._type=Lt.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 k(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 At extends ce{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 Ct extends D{constructor(e){super(e),this._type=Lt.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:[N.CENTER,N.MIDDLE],"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=x.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 N.LEFT:e=this._x;break;case N.RIGHT:e=this._x-n;break;case N.CENTER:e=this._x-n/2;break;default:e=this._x}switch(this._anchor[1]){case N.TOP:t=this._y;break;case N.BOTTOM:t=this._y-i;break;case N.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=>b(e.x,e.y,this._rotate[1],this._rotate[2],this._rotate[0]))),s=Math.min(...r.map((e=>e.x))),o=Math.max(...r.map((e=>e.x))),a=Math.min(...r.map((e=>e.y))),l=Math.max(...r.map((e=>e.y)));this._bounds=new k(s,a,o-s,l-a)}else this._bounds=new k(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 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 Rt extends ce{constructor(e){super(e),this._type=Lt.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 kt extends ce{constructor(e){super(e),this._type=Lt.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 Tt(e){let t=null;switch(e.type){case Lt.Circle:t=new Et(e);break;case Lt.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 At(e);break;case Lt.Rect:var o="top"in e?e.top:0,a="left"in e?e.left:0,l="width"in e?e.width:50,u="height"in e?e.height:30;e.vertices=[[a,o],[a+l,o],[a+l,o+u],[a,o+u]],t=new Qe(e);break;case Lt.PointText:t=new Ct(e);break;case Lt.Image:t=new wt(e);break;case Lt.BundledPath:case Lt.Path:t=new ce(e);break;case Lt.Area:t=new et(e);break;case Lt.Ring:t=new kt(e);break;case Lt.Arc:t=new _e(e);break;case Lt.BezierCurve:"vertices"in e||(e.vertices=[[0,100],[20,120],[80,180],[100,200]]),t=new xt(e);break;case Lt.Polygon:t=new Rt(e)}return t&&t._updateBounds(),t}function St(e){let t=new bt;return e.addChild(t),e._itemMap[t.id]=t,t}function Ot(e){return new vt(e)}function It(e){switch(e.type){case Lt.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(It(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 Lt.Glyph:return function(e){let t=new vt;for(let r of e.children)t.addChild(It(r));t._classId=e.classId,e._dataScope&&(t.dataScope=e._dataScope.clone());return t}(e);default:return function(e){let t=Tt({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 Nt=Object.freeze({Rect:"rect",Circle:"circle",Line:"line",Ring:"ring",Path:"path",Image:"image",PointText:"text",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath"}),Lt=Object.freeze({Area:"area",Rect:"rect",Ellipse:"ellipse",Circle:"circle",Pie:"pie",Ring:"ring",Arc:"arc",BezierCurve:"bezierCurve",BundledPath:"bundledPath",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"}),Vt=Object.freeze({Axis:"axis",Legend:"legend",Gridlines:"gridlines"});function Pt(){return Date.now().toString(36)+"_"+Math.random().toString(36).slice(2)}class Dt{constructor(e,t,r){this._id=Lt.DataTable+Pt(),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=Object.keys(this.data[0]),this._newAttribute=0,r)this._attrTypes=r;else{this._attrTypes={};for(let e of this._attributes)this._attrTypes[e]=Ie(this.data.map((t=>t[e]))),"year"==e.toLowerCase()&&this._attrTypes[e]==Oe.Integer&&(this._attrTypes[e]=Oe.Date)}this._validate(this.data,this._attrTypes),this._attrSummaries={};for(let e of this._attributes)this._attrSummaries[e]=Le(this.data.map((t=>t[e])),this._attrTypes[e]);this._attributes.indexOf(Mt)<0&&this._addAttribute(Mt,Oe.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 Dt(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!==Mt&&this._rawData.forEach(((t,n)=>t[e]=r[n])),this._attrTypes[e]=t,this._attributes.push(e),this._attrSummaries[e]=Le(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]=Oe.Date,this._attrSummaries[e]=Le(this.data.map((t=>t[e])),Oe.Date)}getRawValue(e,t){return this.getAttributeType(e)===Oe.Date?this._dateMap.get(t).toString():t}get nonNumericAttributes(){let e=[];for(let t in this._attrTypes)this._attrTypes[t]!=Oe.Number&&this._attrTypes[t]!=Oe.Integer&&t!=Dt.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]!==Oe.Number&&this._attrTypes[t]!==Oe.Integer||t==Dt.RowID||e.push(t);return e}getAttributesByType(e){let t=[];for(let r in this._attrTypes)this._attrTypes[r]===e&&r!=Dt.RowID&&t.push(r);return t}summarize(){for(let e of this._attributes)this._attrSummaries[e]=Le(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 Oe.Boolean:n=!1;break;case Oe.Date:n=new Date(1899,11,31).getTime();break;case Oe.String:n="";break;default:n=0}else switch(i){case Oe.Boolean:n=s;break;case Oe.Date:n=Number.isInteger(s)?new Date(s,0).getTime():new Date(s+"").getTime(),this._dateMap.set(n,s);break;case Oe.String:n=s.toString();break;default:n=s}r[e]=n}}}function Bt(e){let t=xe(e);if(t)return t.dataTable}const Mt="mascot_rowId";function Gt(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 jt extends p{constructor(e,t){super(e),this._elem=t}get element(){return this._elem}}class zt extends p{constructor(e,t){super(e),this._item=t}get element(){return this._item}}class Ft{constructor(e){this._id=e+"_"+Pt(),this._type=e,this._vars=[],this._edges=[]}get vars(){return this._vars}get edges(){return this._edges}run(){console.log("-",this._type)}}class Ut{constructor(e,t,r=!0){this._id="e_"+Pt(),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 d||this._fromNode instanceof Ft?this._fromNode:this._toNode}}class Ht extends p{constructor(e,t,r){super(e),this._attribute=t,this._dataset=r}get attribute(){return this._attribute}get dataset(){return this._dataset}}class Wt extends p{constructor(e,t){super(e),this._encs=[t]}addLinkedEncoding(e){this._encs.push(e)}get encodings(){return this._encs}}class Yt extends d{constructor(e){super(e)}run(){super.run();let e=this.outputVar,t=e.encodings[0],r=this.inputVars.find((e=>e instanceof Ht)).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&&[Lt.Arc,Lt.Pie].indexOf(t.element.type))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,Math.max(...i)]:this._getDomainForNumbers(i),console.log("domain for",r,e.domain)}else{let s;s=n==Oe.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=G(e.element),n={};if(e.element.type===Lt.Area&&["width","height","fillGradient"].indexOf(e.channel)>=0)for(let t of r)for(let r of t.vertices)n[r.id]=xe(r).aggregateNumericalAttribute(e.attribute,e.aggregator);else switch(t){case Oe.Boolean:break;case Oe.Date:for(let t of r)n[t.id]=xe(t).getAttributeValue(e.attribute);break;case Oe.String:try{if("count"==e.aggregator)for(let t of r)n[t.id]=xe(t).getAttributeValues(e.attribute).length;else for(let t of r)n[t.id]=xe(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=xe(e).getAttributeValue(i);n[e.id]=new ve(t).cross(Te,r).getAttributeValue(s)}}else for(let t of r)n[t.id]=xe(t).aggregateNumericalAttribute(e.attribute,e.aggregator)}return e.attrValues=n,Object.values(n)}}class Xt{constructor(e,t){switch(this._id="scale_"+Pt(),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 qt=["schemeBrBG","schemePRGn","schemePiYG","schemePuOr","schemeRdBu","schemeRdGy","schemeRdYlBu","schemeRdYlGn","schemeSpectral"],Kt=["schemeBlues","schemeGreens","schemeGreys","schemeOranges","schemePurples","schemeReds","schemeBuGn","schemeBuPu","schemeGnBu","schemeOrRd","schemePuBuGn","schemePuBu","schemePuRd","schemeRdPu","schemeYlGnBu","schemeYlGn","schemeYlOrBr","schemeYlOrRd"];class Zt extends d{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],o=r.getElements(s),a=this._buildRange(n,o,r,e);if(a)for(let e of t)e.scales[i].range=a;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((qt.indexOf(t.colorScheme)>=0||Kt.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===Lt.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]):X(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]):X(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 $t extends d{constructor(e){super(e)}run(){super.run()}}class Jt extends mt{constructor(e){super(),this._type=Lt.Axis,this._id=this._type+Pt(),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 mt,this._ticks._id=this._id+"_ticks",this.addChild(this._ticks),this._labels=new mt,this._labels._id=this._id+"_labels",this.addChild(this._labels),this._title=new Ct({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!==Lt.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 Qt="top",er="bottom",tr="left";function rr(e,t,r,i){let s,o=e.domain,a=e.range;switch(e.type){case"linear":case"log":{let l=Math.abs(a[0]-a[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==Q.STACK);o[1]=e._scale.invert(n?O(r)[t]:S(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(o[0],o[1],c);return u}case"point":{s="width"==t||"x"==t?80:30;let r=Math.floor(e.rangeExtent/o.length),n=Math.ceil(s/r);return"x"==t?o.filter(((e,t)=>t%n==0)):o}case"time":{s="width"==t||"x"==t?80:30;let e,r,i=Math.floor((a[1]-a[0])/s),l=Math.ceil((o[1]-o[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(o[0],o[1],e);return l>u[u.length-1]?(e=Math.floor(l/u[u.length-1]),r=c[u.length-1],r(o[0],o[1],e)):[]}default:return[]}}function nr(e,t){t.removeChild(e)}class ir extends Jt{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?er:tr,this._titleText="title"in n?n.title:this._encoding.attribute,this._path="angle"===this._channel?new Et({strokeColor:this._strokeColor,id:this._id+"_path"}):new ce({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)!==Oe.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=rr(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 ce({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 Oe.Date:t=n.timeFormat(this._labelFormat);break;case Oe.String:t=function(e){return e};break;default:t=n.format(this._labelFormat)}for(let[e,r]of this._labelValues.entries()){let n=new Ct({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 Jt{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?er:tr,this._titleText="title"in n?n.title:this._attribute,this._path="angle"===this._channel?new Et({strokeColor:this._strokeColor,id:this._id+"_path"}):new ce({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)!==Oe.Date||"labelFormat"in n||(this._labelFormat="%m/%d/%y")}get elements(){if(this.layout.type===Q.CLUSTER){const e=new Map(this._elems.map((e=>[e.dataScope.getAttributeValue(Te),e])));return this.layout._d3Root.leaves().map((t=>e.get(t.data[Te])))}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 ce({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 Oe.Date:t=n.timeFormat(this._labelFormat);break;case Oe.String:t=function(e){return e};break;default:t=n.format(this._labelFormat)}for(let[e,r]of this._labelValues.entries()){let n=new Ct({text:t(r),fontSize:this._fontSize,fillColor:this._textColor,id:this._id+"_label"+e});this._labels.addChild(n)}this._title._text=this._titleText}}class or extends d{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof nt&&e.property==it.AXIS_ORIENTATION)).element;e instanceof ir?this._runForEncoding(e):e instanceof sr&&this._runForLayout(e),I(e._path)}_runForLayout(e){let t=e.channel,r=e.elements[0].parent.layout&&e.elements[0].parent.layout.type==Q.STACK?O(e.elements):S(e.elements),n=[];if("x"===t){let t=e.orientation===Qt?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===tr?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===Q.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==Q.STACK?O(e.elements):S(e.elements),n=[];if("x"===t){let t=e.orientation===Qt?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===Qt?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===tr?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===tr?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 d{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof nt&&e.property==it.AXIS_PATH_POSITION)).element;e instanceof ir?this._runForEncoding(e):e instanceof sr&&this._runForLayout(e);for(let t of e._ticks.children)t._updateBounds();I(e._ticks)}_runForLayout(e){let t=e.channel;if("x"==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([[s,t],[s,t+r]])}}else if("y"===t){let t=e.orientation==tr?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==tr?-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===Q.CLUSTER){let r=t._d3Root.leaves();const n=new Map(r.map((e=>[e.data[Te],[e.x,e.y]])));for(let[r,i]of e._ticks.children.entries()){let s=e.elements[r].dataScope.getAttributeValue(Te),o=ye(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=[o,t.x,t.y]}}}}_runForEncoding(e){let t=e.channel,r=S(e.elements);if("x"==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([[e.scale.map(e._tickValues[n]),t],[e.scale.map(e._tickValues[n]),t+r]])}else if("width"==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===Lt.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==tr?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,r=e.orientation==tr?-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==tr?e.pathPos-e.tickOffset:e.pathPos+e.tickOffset,n=e.orientation==tr?-e.tickSize:e.tickSize;if(!!(e.isFlipped()||e.elements[0].type===Lt.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 o=r.bottom-e.scale.map(e._tickValues[i]);s._setVertices([[t,o],[t+n,o]])}}else if("radialDistance"===t){let t=e.orientation==er?e.pathPos+e.tickOffset:e.pathPos-e.tickOffset,r=e.orientation==er?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 lr extends d{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof nt&&e.property==it.AXIS_PATH_POSITION)).element;e instanceof ir?this._runForEncoding(e):e instanceof sr&&this._runForLayout(e);for(let t of e._labels.children)t._updateBounds();I(e._labels)}_runForLayout(e){let t=e.channel;if("x"==t){let t=e.orientation==er?e.labelOffset:-e.labelOffset,r=e.orientation==er?[N.CENTER,N.TOP]:[N.CENTER,N.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=[N.RIGHT,N.MIDDLE])}}else if("y"===t){let t=e.orientation==tr?-e.labelOffset:e.labelOffset,r=e.orientation==tr?[N.RIGHT,N.MIDDLE]:[N.LEFT,N.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==N.MIDDLE?s.y:s[e.tickAnchor],i._anchor=r,e._labelRotation&&(i._rotate=[e._labelRotation,i.x,i.y],i._anchor=[N.RIGHT,r[1]])}}else if("angle"===t){let t=e.elements[0].parent.layout;if(t.type===Q.CLUSTER){let r=t._d3Root.leaves();const n=new Map(r.map((e=>[e.data[Te],[e.x,e.y]])));let i=5;for(let[r,s]of e._labels.children.entries()){let o=e.elements[r].dataScope.getAttributeValue(Te);if(n.get(o)[0]<Math.PI){let a=ye(n.get(o)[0])-90;s._anchor=[N.LEFT,N.MIDDLE],s._x=t.x+n.get(o)[1]+e.elements[r].bounds.width/2+i,s._y=t.y,s._rotate=[a,t.x,t.y]}else{let a=ye(n.get(o)[0])+90;s._anchor=[N.RIGHT,N.MIDDLE],s._x=t.x-n.get(o)[1]-e.elements[r].bounds.width/2-i,s._y=t.y,s._rotate=[a,t.x,t.y]}}}}}_runForEncoding(e){let t=e.channel,r=S(e.elements);if("x"==t){let t=e.orientation==er?e.labelOffset:-e.labelOffset,r=e.orientation==er?[N.CENTER,N.TOP]:[N.CENTER,N.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=[N.RIGHT,r[1]])}else if("width"===t){let t=e.orientation==er?e.labelOffset:-e.labelOffset,n=e.orientation==er?[N.CENTER,N.TOP]:[N.CENTER,N.BOTTOM],i=!!(e.isFlipped()||e.elements[0].type===Lt.Area&&"right"===e.elements[0].baseline);for(let[s,o]of e._labels.children.entries())o._x=i?r.left+e.scale.rangeExtent-e.scale.map(e.labelValues[s]):e.scale.map(e.labelValues[s])+r.left,o._y=e.pathPos+t,o._anchor=n,e._labelRotation&&(o._rotate=[e._labelRotation,o.x,o.y],o._anchor=[N.RIGHT,n[1]])}else if("y"===t){let t=e.orientation==tr?-e.labelOffset:e.labelOffset,r=e.orientation==tr?[N.RIGHT,N.MIDDLE]:[N.LEFT,N.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=[N.RIGHT,r[1]])}else if("height"===t){let t=e.orientation==tr?-e.labelOffset:e.labelOffset,n=e.orientation==tr?[N.RIGHT,N.MIDDLE]:[N.LEFT,N.MIDDLE],i=e.elements[0].type===Lt.Area&&"top"===e.elements[0].baseline;for(let[s,o]of e._labels.children.entries())o._x=e.pathPos+t,o._y=i?r.top+e.scale.map(e.labelValues[s]):r.bottom-e.scale.map(e.labelValues[s]),o._anchor=n,e._labelRotation&&(o._rotate=[e._labelRotation,o.x,o.y],o._anchor=[N.RIGHT,n[1]])}else if("radialDistance"==t){let t=e.orientation==er?e.labelOffset:-e.labelOffset,r=e.orientation==er?[N.CENTER,N.TOP]:[N.CENTER,N.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=[N.RIGHT,r[1]])}}}class ur extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(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=Z(e,!0);for(let e of r)I(e)}placeElements(e,t){let r=Ue(e,"x"),n=Ue(e,"y");for(let r=0;r<e.children.length;r++){let n=e.children[r],i=t.cellBounds[r],s=0,o=0;switch(t._cellHorzAlignment){case N.LEFT:s=i.left-n.refBounds.left;break;case N.CENTER:s=i.x-n.refBounds.x;break;case N.RIGHT:s=i.right-n.refBounds.right}switch(t._cellVertAlignment){case N.TOP:o=i.top-n.refBounds.top;break;case N.MIDDLE:o=i.y-n.refBounds.y;break;case N.BOTTOM:o=i.bottom-n.refBounds.bottom}Xe(n,s,o)}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,o=s+r.rangeExtent;r.range=r.range[0]<r.range[1]?[s,o]:[o,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,o=s+r.rangeExtent;r.range=r.range[0]<r.range[1]?[s,o]:[o,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)),o=r.map((e=>e.height)),a=Math.max(...s),l=Math.max(...o);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 o=t._grid[r][s];o>=e.children.length||(t._cellBounds[o]=new k(t._left+(a+n)*s+0,t._top+(l+i)*r,a,l))}}}class cr extends d{constructor(e){super(e)}run(){let e=this.outputVar.element;e.scale?this._runForEncoding(e):this._runForLayout(e),I(e)}_runForLayout(e){let t=e.channel,r=S(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=S(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 hr extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=Z(e)[0],r=G(e.parent);for(let e of r){let r=e.layout;if(!r)return;switch(t.type){case Lt.Rect:case Lt.Circle:case Lt.Image:this._stackRects(e,r);break;case Lt.Area:e.children[0].orientation===ie.HORIZONTAL?this._stackAreasVert(e,r):this._stackAreasHorz(e,r);break;case Lt.Arc:case Lt.Pie:t.parent.classId===e.classId&&this._stackArcs(e,r)}}I(t)}_stackArcs(e,t){if(t.orientation===ie.ANGULAR){let t=90;if((this._direction?this._direction:oe.Clockwise)===oe.Clockwise)for(let r of e.children){let e=me(t-r.angle);Ke(r,"startAngle",e),t=e}else for(let r of e.children){let e=me(t+r.angle);Ke(r,"startAngle",e),t=e}}else if(t.orientation===ie.RADIAL){let t=Math.min(...e.children.map((e=>e.innerRadius)));for(let r of e.children){let e=r.outerRadius-r.innerRadius;Ke(r,"innerRadius",t),Ke(r,"outerRadius",t+e),t=r._outerRadius}}}_stackAreasVert(e,t){let r=e.children,n=e.bounds,i=t.vertCellAlignment===N.TOP?n.top:n.bottom,s=t.vertCellAlignment===N.TOP?1:-1,o=r[0].vertices.length/2,a=new Array(o).fill(0);for(let e of r){for(let t=0;t<o;t++){let r=e.vertices[t],n=e.vertices[2*o-t-1],l=Math.abs(r.y-n.y),u=i+a[t]*s,c=i+(a[t]+l)*s;Xe(r,0,u-r.y),Xe(n,0,c-n.y),a[t]+=l}let t=e.bounds.bottom;e._updateBounds(),e._refBounds.translate(0,e.bounds.bottom-t)}if(t.vertCellAlignment===N.MIDDLE)for(let e of r){for(let t=0;t<o;t++){let r=e.vertices[t],i=e.vertices[2*o-t-1],s=n.middle+a[t]/2;Xe(r,0,s-n.bottom),Xe(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)),o=n.map((e=>e.width)),a=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(...o),h=Math.max(...a);if(r==ie.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,Xe(n,i,s),n._updateBounds();let o=0,a=0;if(!We(n))switch(t._horzCellAlignment){case N.LEFT:o=l-n.bounds.left;break;case N.CENTER:o=l+c/2-n.bounds.x;break;case N.RIGHT:o=l+c-n.bounds.right}Xe(n,o,a)}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,Xe(n,i,s),n._updateBounds();let o=0,a=0;if(!He(n))switch(t._vertCellAlignment){case N.TOP:a=u-n.bounds.top;break;case N.MIDDLE:a=u+h/2-n.bounds.y;break;case N.BOTTOM:a=u+h-n.bounds.bottom}Xe(n,o,a)}}}class dr extends d{constructor(e){super(e)}run(){super.run()}}class fr extends d{constructor(e){super(e)}run(){let e=this.inputVars[0],t=this.outputVar,r=e.attribute,i=t.attribute,s=e.dataset,o=t.dataset,a=s.getAttributeValues(r),l=n.bin()(a),u=this._findBin,c=a.map((e=>{let t=u(e,l);return(t.x0+t.x1)/2+""})),h=l.map((e=>(e.x0+e.x1)/2+""));o._addAttribute(i,Oe.String,c),o.orderAttributeValues(i,h)}_findBin(e,t){for(let r of t)if(r.indexOf(e)>=0)return r}}class pr extends d{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]=Le(t.data.map((t=>t[e])),t._attrTypes[e])}}class _r extends p{constructor(e,t,r){super(e),this._dataset=r,this._predicate=t}get dataset(){return this._dataset}get predicate(){return this._predicate}}class gr extends p{constructor(e,t){super(e),this._group=t}get element(){return this._group}}class yr extends d{constructor(e){super(e)}run(){super.run();let e=this.inputVars.find((e=>e.type===_.AFFIXATION)).affixation,t=e.base,r=e.element,n=e.elementAnchor,i=e.baseAnchor,s=e.channel,o=e.offset,a=G(t),l=G(r);"radialDistance"===s?this._handleRadialDistance(l,a,n,i,o):"angle"===s?this._handleAngle(l,a,n,i,o):this._handleXY(s,l,a,n,i,o);let u=Z(r,!0);for(let e of u)I(e)}_handleAngle(e,t,r,n,i){for(let s=0;s<e.length;s++){let o,a=t[s],l=e[s];o=a.type==Lt.Arc?"left"==n?a.endAngle+i:"center"==n?a.startAngle+a.angle/2+i:a.startAngle+i:90,l._rotate?l._rotate[0]=90-o:(Xe(l,a.x-l.bounds[r],a.y-e[s].y),l._rotate=[90-o,t[s].x,t[s].y])}}_handleRadialDistance(e,t,r,n,i){for(let s=0;s<e.length;s++){let o,a=t[s],l=e[s];a.type==Lt.Arc||a.type==Lt.Ring?o="top"==n?a.outerRadius+i:"bottom"==n?a.innerRadius+i:(a.outerRadius+a.innerRadius)/2+i:a.type==Lt.Circle&&(o="top"==n?a.radius+i:"bottom"==n?i:a.radius/2+i),Xe(l,a.x-l.x,a.y-o-l.bounds[r]),l._rotate?l._rotate=[l._rotate[0],a.x,a.y]:l._rotate=[0,a.x,a.y]}}_handleXY(e,t,r,n,i,s){for(let o=0;o<t.length;o++){let a,l=r[o],u=t[o];if(de(l)){a=he(l,[N.LEFT,N.TOP].includes(i)?0:[N.CENTER,N.MIDDLE].includes(i)?.5:1)[e]}else a=l.bounds[i]+s;t[0].type===Lt.PointText?(u.anchor["x"==e?0:1]=n,Ke(u,e,a)):"x"==e?Xe(u,a-u.bounds[n],0):Xe(u,0,a-u.bounds[n])}}}class mr extends p{constructor(e,t){super(e),this._affx=t}get affixation(){return this._affx}}class br extends d{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,o=this.args,a="min"in o?o.min:i.getAttributeSummary(r).min,l="max"in o?o.max:i.getAttributeSummary(r).max,u=a,c=[];for(;u<l;)c.push(u),u+=o.interval;c.push(u);let h={},d={};if(o.groupBy)for(let e of i.data){let t=o.groupBy.map((t=>e[t])).join("-");t in h||(h[t]=[],d[t]=o.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=vr(xr(o.bandwidth),c,h[e]);for(let i of t){let t={};""!==e&&o.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]=Oe.Number,o.groupBy)for(let e of o.groupBy)p[e]=i.getAttributeType(e);s.initialize(f,s.url,p)}}function vr(e,t,r){return t.map((t=>[t,n.mean(r,(r=>e(t-r)))]))}function xr(e){return t=>Math.abs(t/=e)<=1?.75*(1-t*t)/e:0}class Er extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(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 o=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))(o);for(let e of o.children){let r=e.data.itm;Xe(r,t._x-o.x+e.x-r.x,t._y-o.y+e.y-r.y)}}let r=Z(e,!0);for(let e of r)I(e)}}class wr extends d{constructor(e){super(e)}run(){let e=this.inputVars.find((e=>e instanceof nt&&e.property==it.AXIS_PATH_POSITION)).element;e instanceof ir?this._runForEncoding(e):e instanceof sr&&this._runForLayout(e),I(e._title)}_runForEncoding(e){let t=e.channel,r=S(e.elements);if("x"==t)e._title._x=(e.scale.range[0]+e.scale.range[1])/2,e._title._y=e.orientation==er?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==er?e.pathPos+e.titleOffset:e.pathPos-e.titleOffset;else if("y"===t)e._rotateYTitle?(e._title._x=e.orientation==tr?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==tr?[-90,e._title._x,e._title._y]:[90,e._title._x,e._title._y]):(e._title._x=e.orientation==tr?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==tr?[-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==er?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==Q.STACK?O(e.elements):S(e.elements);if("x"==t)e._title._x=r.center,e._title._y=e.orientation==er?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==tr?[-90,r.center,r.middle]:[90,r.center,r.middle];else if("angle"===t){let t=e.elements[0].parent.layout;t.type===Q.CLUSTER&&(e._title._x=t.x,e._title._y=t.y)}}}class Ar extends Ft{constructor(e){super(e)}run(){super.run();let e,t=this.vars.find((e=>e.type===_.ALIGNMENT)).alignment,r=t.anchor,i=t.elements;r==N.Top||r==N.LEFT?e=Math.min(...i.map((e=>e.bounds[r]))):r==N.BOTTOM||r==N.RIGHT?e=Math.max(...i.map((e=>e.bounds[r]))):r!=N.CENTER&&r!=N.MIDDLE||(e=n.mean(i.map((e=>e.bounds[r]))));for(let n of i){let i=Ye(n,t.channel);if(i){let s=e-n.bounds[r];Xe(i,"x"===t.channel?s:0,"x"===t.channel?0:s)}}for(let e of i)I(e)}}class Cr extends p{constructor(e,t){super(e),this._aln=t}get alignment(){return this._aln}}class Rr extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=Re(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];Xe(n,i.x-n.x,i.y-n.y)}}let r=Z(e,!0);for(let e of r)I(e)}}class kr extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e);switch(e.type){case Lt.Arc:this._updateArcLinks(t);break;case Lt.BezierCurve:this._updateBezierLinks(t);break;case Lt.BundledPath:this._updateBundledLinks(t);break;case Lt.Line:default:this._updateLineLinks(t)}I(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=be(e.x,e.y,t._x,t._y),i=be(r.x,r.y,t._x,t._y);t.direction===oe.CLOCKWISE&&([n,i]=[i,n]),Ke(t,"startAngle",n),Ke(t,"angle",Math.abs(i-n))}}_updateBezierLinks(e){let t=this._inputVars[0].element,r=G(t),n=t.parent.layout;n.type===Q.DIRECTED||n.type===Q.TIDYTREE?this._updateBezierLinksForDirectedGraph(r,e,n):n.type===Q.CLUSTER&&this._updateBezierLinksForClusteredGraph(r,e,n)}_updateBezierLinksForClusteredGraph(e,t,r){const i=r._d3Root.descendants(),s=new Map(i.map((e=>[Tr(e),e]))),o=new Map(i.map((e=>[e.data[Te],Tr(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,a=t.dataScope.getAttributeValue(Te),l=i.dataScope.getAttributeValue(Te),u=s.get(o.get(a)),c=s.get(o.get(l));n._d=pe(e({source:u,target:c}),r.x,r.y)}}else if(r.orientation===ie.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,a=t.dataScope.getAttributeValue(Te),l=i.dataScope.getAttributeValue(Te),u=s.get(o.get(a)),c=s.get(o.get(l));n._d=pe(e({source:u,target:c}),r.left-r._x0,r.top)}}else if(r.orientation===ie.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,a=t.dataScope.getAttributeValue(Te),l=i.dataScope.getAttributeValue(Te),u=s.get(o.get(a)),c=s.get(o.get(l));n._d=pe(e({source:u,target:c}),r.left,r.top-r._x0)}}}_updateBezierLinksForDirectedGraph(e,t,r){let n={},i={},s={},o={};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));o[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)=>be(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y)-be(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y))):t.sort(((e,t)=>be(t.target.bounds.x,t.target.bounds.y,t.source.bounds.x,t.source.bounds.y)-be(e.target.bounds.x,e.target.bounds.y,e.source.bounds.x,e.source.bounds.y))));for(let e of t){let t,a,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],a=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]-o[h.id]/2+i[h.id]+e.strokeWidth/2,n[c.id]+=e.strokeWidth,i[h.id]+=e.strokeWidth):(a=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]-o[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],a=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===ie.HORIZONTAL?e._setVertices([[t,a],[(t+l)/2,a],[t,u],[l,u]]):e.orientation===ie.VERTICAL&&e._setVertices([[t,a],[t,(a+u)/2],[l,a],[l,u]])}}_updateBundledLinks(e){let t=this._inputVars[0].element.parent.layout;if(t.type!==Q.CLUSTER)throw"Bundled links must work on a cluster layout";let r=t._d3Root.leaves();const i=new Map(r.map((e=>[Tr(e),e]))),s=new Map(r.map((e=>[e.data[Te],Tr(e)]))),o=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(Te),n=r.target.dataScope.getAttributeValue(Te),a=i.get(s.get(e)),l=i.get(s.get(n));(a.outgoing??=[]).push([a,l]),l.incoming??=[];let u=a.path(l);r._d=pe(o(u),t.x,t.y)}}_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 Tr(e){return`${e.parent?Tr(e.parent)+".":""}${e.data[Te]}`}var Sr,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,on,an,ln,un,cn,hn,dn,fn,pn,_n,gn,yn,mn,bn,vn,xn,En,wn,An,Cn,Rn,kn,Tn,Sn,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,oi,ai,li,ui,ci,hi,di,fi,pi,_i,gi,yi,mi,bi,vi,xi,Ei,wi,Ai,Ci,Ri,ki,Ti,Si,Oi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ii(){if(Nr)return Ir;return Nr=1,Ir=function(e,t){return e===t||e!=e&&t!=t}}function Ni(){if(Vr)return Lr;Vr=1;var e=Ii();return Lr=function(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function Li(){if(Hr)return Ur;Hr=1;var e=Or?Sr:(Or=1,Sr=function(){this.__data__=[],this.size=0}),t=function(){if(Dr)return Pr;Dr=1;var e=Ni(),t=Array.prototype.splice;return Pr=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(Mr)return Br;Mr=1;var e=Ni();return Br=function(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function(){if(jr)return Gr;jr=1;var e=Ni();return Gr=function(t){return e(this.__data__,t)>-1}}(),i=function(){if(Fr)return zr;Fr=1;var e=Ni();return zr=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,Ur=s}function Vi(){if(en)return Qr;en=1;var e="object"==typeof Oi&&Oi&&Oi.Object===Object&&Oi;return Qr=e}function Pi(){if(rn)return tn;rn=1;var e=Vi(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return tn=r}function Di(){if(sn)return nn;sn=1;var e=Pi().Symbol;return nn=e}function Bi(){if(hn)return cn;hn=1;var e=Di(),t=function(){if(an)return on;an=1;var e=Di(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return on=
3
+ /**
4
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
5
+ *
6
+ * @private
7
+ * @param {*} value The value to query.
8
+ * @returns {string} Returns the raw `toStringTag`.
9
+ */
10
+ function(e){var t=r.call(e,i),s=e[i];try{e[i]=void 0;var o=!0}catch(e){}var a=n.call(e);return o&&(t?e[i]=s:delete e[i]),a}}(),r=function(){if(un)return ln;un=1;var e=Object.prototype.toString;return ln=function(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return cn=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function Mi(){if(fn)return dn;return fn=1,dn=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Gi(){if(_n)return pn;_n=1;var e=Bi(),t=Mi();return pn=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function ji(){if(bn)return mn;bn=1;var e,t=function(){if(yn)return gn;yn=1;var e=Pi()["__core-js_shared__"];return gn=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return mn=function(e){return!!r&&r in e}}function zi(){if(xn)return vn;xn=1;var e=Function.prototype.toString;return vn=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function Fi(){if(kn)return Rn;kn=1;var e=function(){if(wn)return En;wn=1;var e=Gi(),t=ji(),r=Mi(),n=zi(),i=/^\[object .+?Constructor\]$/,s=Function.prototype,o=Object.prototype,a=s.toString,l=o.hasOwnProperty,u=RegExp("^"+a.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return En=function(s){return!(!r(s)||t(s))&&(e(s)?u:i).test(n(s))}}(),t=Cn?An:(Cn=1,An=function(e,t){return null==e?void 0:e[t]});return Rn=function(r,n){var i=t(r,n);return e(i)?i:void 0}}function Ui(){if(Sn)return Tn;Sn=1;var e=Fi()(Pi(),"Map");return Tn=e}function Hi(){if(In)return On;In=1;var e=Fi()(Object,"create");return On=e}function Wi(){if(Un)return Fn;Un=1;var e=function(){if(Ln)return Nn;Ln=1;var e=Hi();return Nn=function(){this.__data__=e?e(null):{},this.size=0}}(),t=Pn?Vn:(Pn=1,Vn=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}),r=function(){if(Bn)return Dn;Bn=1;var e=Hi(),t=Object.prototype.hasOwnProperty;return Dn=function(r){var n=this.__data__;if(e){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(n,r)?n[r]:void 0}}(),n=function(){if(Gn)return Mn;Gn=1;var e=Hi(),t=Object.prototype.hasOwnProperty;return Mn=function(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}(),i=function(){if(zn)return jn;zn=1;var e=Hi();return jn=function(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":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,Fn=s}function Yi(){if(Kn)return qn;Kn=1;var e=Xn?Yn:(Xn=1,Yn=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e});return qn=function(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function Xi(){if(si)return ii;si=1;var e=function(){if(Wn)return Hn;Wn=1;var e=Wi(),t=Li(),r=Ui();return Hn=function(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}(),t=function(){if($n)return Zn;$n=1;var e=Yi();return Zn=function(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}(),r=function(){if(Qn)return Jn;Qn=1;var e=Yi();return Jn=function(t){return e(this,t).get(t)}}(),n=function(){if(ti)return ei;ti=1;var e=Yi();return ei=function(t){return e(this,t).has(t)}}(),i=function(){if(ni)return ri;ni=1;var e=Yi();return ri=function(t,r){var n=e(this,t),i=n.size;return n.set(t,r),this.size+=n.size==i?0:1,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,ii=s}function qi(){if(ui)return li;ui=1;var e=Li(),t=function(){if(Yr)return Wr;Yr=1;var e=Li();return Wr=function(){this.__data__=new e,this.size=0}}(),r=qr?Xr:(qr=1,Xr=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}),n=Zr?Kr:(Zr=1,Kr=function(e){return this.__data__.get(e)}),i=Jr?$r:(Jr=1,$r=function(e){return this.__data__.has(e)}),s=function(){if(ai)return oi;ai=1;var e=Li(),t=Ui(),r=Xi();return oi=function(n,i){var s=this.__data__;if(s instanceof e){var o=s.__data__;if(!t||o.length<199)return o.push([n,i]),this.size=++s.size,this;s=this.__data__=new r(o)}return s.set(n,i),this.size=s.size,this}}();function o(t){var r=this.__data__=new e(t);this.size=r.size}return o.prototype.clear=t,o.prototype.delete=r,o.prototype.get=n,o.prototype.has=i,o.prototype.set=s,li=o}
11
+ /**
12
+ * A specialized version of `_.forEach` for arrays without support for
13
+ * iteratee shorthands.
14
+ *
15
+ * @private
16
+ * @param {Array} [array] The array to iterate over.
17
+ * @param {Function} iteratee The function invoked per iteration.
18
+ * @returns {Array} Returns `array`.
19
+ */function Ki(){if(hi)return ci;return hi=1,ci=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}}function Zi(){if(fi)return di;fi=1;var e=Fi(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return di=t}function $i(){if(_i)return pi;_i=1;var e=Zi();return pi=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function Ji(){if(yi)return gi;yi=1;var e=$i(),t=Ii(),r=Object.prototype.hasOwnProperty;return gi=function(n,i,s){var o=n[i];r.call(n,i)&&t(o,s)&&(void 0!==s||i in n)||e(n,i,s)}}function Qi(){if(bi)return mi;bi=1;var e=Ji(),t=$i();return mi=function(r,n,i,s){var o=!i;i||(i={});for(var a=-1,l=n.length;++a<l;){var u=n[a],c=s?s(i[u],r[u],u,i,r):void 0;void 0===c&&(c=r[u]),o?t(i,u,c):e(i,u,c)}return i}}function es(){if(wi)return Ei;return wi=1,Ei=function(e){return null!=e&&"object"==typeof e}}function ts(){if(ki)return Ri;ki=1;var e=function(){if(Ci)return Ai;Ci=1;var e=Bi(),t=es();return Ai=function(r){return t(r)&&"[object Arguments]"==e(r)}}(),t=es(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,s=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!i.call(e,"callee")};return Ri=s}function rs(){if(Si)return Ti;Si=1;var e=Array.isArray;return Ti=e}var ns,is,ss,os,as,ls,us,cs,hs,ds,fs,ps={exports:{}};function _s(){return ss||(ss=1,function(e,t){var r=Pi(),n=is?ns:(is=1,ns=function(){return!1}),i=t&&!t.nodeType&&t,s=i&&e&&!e.nodeType&&e,o=s&&s.exports===i?r.Buffer:void 0,a=(o?o.isBuffer:void 0)||n;e.exports=a}(ps,ps.exports)),ps.exports}function gs(){if(as)return os;as=1;var e=/^(?:0|[1-9]\d*)$/;return os=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function ys(){if(us)return ls;us=1;return ls=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function ms(){if(fs)return ds;return fs=1,ds=function(e){return function(t){return e(t)}}}ps.exports;var bs,vs,xs,Es,ws,As,Cs,Rs,ks,Ts,Ss,Os,Is,Ns,Ls,Vs,Ps,Ds,Bs,Ms,Gs,js,zs,Fs,Us,Hs,Ws,Ys={exports:{}};function Xs(){return bs||(bs=1,function(e,t){var r=Vi(),n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,s=i&&i.exports===n&&r.process,o=function(){try{var e=i&&i.require&&i.require("util").types;return e||s&&s.binding&&s.binding("util")}catch(e){}}();e.exports=o}(Ys,Ys.exports)),Ys.exports}function qs(){if(xs)return vs;xs=1;var e=function(){if(hs)return cs;hs=1;var e=Bi(),t=ys(),r=es(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,cs=function(i){return r(i)&&t(i.length)&&!!n[e(i)]}}(),t=ms(),r=Xs(),n=r&&r.isTypedArray,i=n?t(n):e;return vs=i}function Ks(){if(ws)return Es;ws=1;var e=xi?vi:(xi=1,vi=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}),t=ts(),r=rs(),n=_s(),i=gs(),s=qs(),o=Object.prototype.hasOwnProperty;return Es=function(a,l){var u=r(a),c=!u&&t(a),h=!u&&!c&&n(a),d=!u&&!c&&!h&&s(a),f=u||c||h||d,p=f?e(a.length,String):[],_=p.length;for(var g in a)!l&&!o.call(a,g)||f&&("length"==g||h&&("offset"==g||"parent"==g)||d&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||i(g,_))||p.push(g);return p}}function Zs(){if(Cs)return As;Cs=1;var e=Object.prototype;return As=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function $s(){if(ks)return Rs;return ks=1,Rs=function(e,t){return function(r){return e(t(r))}}}function Js(){if(Is)return Os;Is=1;var e=Zs(),t=function(){if(Ss)return Ts;Ss=1;var e=$s()(Object.keys,Object);return Ts=e}(),r=Object.prototype.hasOwnProperty;return Os=function(n){if(!e(n))return t(n);var i=[];for(var s in Object(n))r.call(n,s)&&"constructor"!=s&&i.push(s);return i}}function Qs(){if(Ls)return Ns;Ls=1;var e=Gi(),t=ys();return Ns=function(r){return null!=r&&t(r.length)&&!e(r)}}function eo(){if(Ps)return Vs;Ps=1;var e=Ks(),t=Js(),r=Qs();return Vs=function(n){return r(n)?e(n):t(n)}}function to(){if(zs)return js;zs=1;var e=Mi(),t=Zs(),r=Gs?Ms:(Gs=1,Ms=function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}),n=Object.prototype.hasOwnProperty;return js=function(i){if(!e(i))return r(i);var s=t(i),o=[];for(var a in i)("constructor"!=a||!s&&n.call(i,a))&&o.push(a);return o}}function ro(){if(Us)return Fs;Us=1;var e=Ks(),t=to(),r=Qs();return Fs=function(n){return r(n)?e(n,!0):t(n)}}Ys.exports;var no,io,so,oo,ao,lo,uo,co,ho,fo,po,_o,go,yo,mo,bo,vo,xo,Eo,wo,Ao,Co,Ro,ko,To,So,Oo,Io,No,Lo,Vo,Po,Do,Bo,Mo,Go,jo,zo,Fo,Uo,Ho,Wo,Yo,Xo,qo,Ko,Zo,$o,Jo,Qo,ea,ta,ra,na,ia,sa,oa,aa,la,ua,ca,ha,da,fa,pa,_a,ga,ya,ma,ba,va,xa,Ea,wa,Aa,Ca,Ra,ka,Ta,Sa,Oa,Ia,Na,La,Va,Pa,Da,Ba,Ma,Ga,ja,za,Fa,Ua,Ha,Wa,Ya,Xa,qa,Ka,Za,$a,Ja,Qa,el,tl,rl,nl,il,sl,ol,al,ll,ul,cl,hl,dl,fl,pl,_l,gl,yl,ml,bl,vl,xl,El,wl,Al,Cl,Rl,kl,Tl,Sl,Ol,Il,Nl,Ll,Vl,Pl,Dl,Bl,Ml,Gl,jl,zl,Fl,Ul,Hl,Wl,Yl,Xl,ql,Kl,Zl,$l,Jl,Ql,eu,tu,ru,nu,iu,su,ou,au,lu,uu,cu,hu,du,fu,pu,_u,gu,yu,mu,bu,vu,xu,Eu,wu,Au,Cu,Ru,ku,Tu,Su,Ou,Iu,Nu,Lu,Vu,Pu,Du,Bu,Mu,Gu,ju,zu,Fu,Uu,Hu,Wu,Yu,Xu,qu,Ku,Zu,$u,Ju,Qu,ec,tc,rc,nc,ic,sc,oc,ac,lc,uc,cc,hc,dc,fc,pc,_c,gc,yc,mc,bc,vc,xc,Ec,wc,Ac,Cc,Rc,kc,Tc,Sc,Oc,Ic,Nc,Lc,Vc,Pc,Dc,Bc,Mc,Gc,jc,zc,Fc,Uc,Hc,Wc,Yc,Xc,qc,Kc,Zc,$c,Jc,Qc,eh,th,rh,nh,ih,sh,oh,ah,lh,uh,ch,hh,dh,fh,ph={exports:{}};function _h(){return no||(no=1,function(e,t){var r=Pi(),n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,s=i&&i.exports===n?r.Buffer:void 0,o=s?s.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var r=e.length,n=o?o(r):new e.constructor(r);return e.copy(n),n}}(ph,ph.exports)),ph.exports}function gh(){if(so)return io;return so=1,io=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}}
20
+ /**
21
+ * A specialized version of `_.filter` for arrays without support for
22
+ * iteratee shorthands.
23
+ *
24
+ * @private
25
+ * @param {Array} [array] The array to iterate over.
26
+ * @param {Function} predicate The function invoked per iteration.
27
+ * @returns {Array} Returns the new filtered array.
28
+ */function yh(){if(ao)return oo;return ao=1,oo=function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}}function mh(){if(uo)return lo;return uo=1,lo=function(){return[]}}function bh(){if(ho)return co;ho=1;var e=yh(),t=mh(),r=Object.prototype.propertyIsEnumerable,n=Object.getOwnPropertySymbols;return co=n?function(t){return null==t?[]:(t=Object(t),e(n(t),(function(e){return r.call(t,e)})))}:t}function vh(){if(go)return _o;return go=1,_o=function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}}function xh(){if(mo)return yo;mo=1;var e=$s()(Object.getPrototypeOf,Object);return yo=e}function Eh(){if(vo)return bo;vo=1;var e=vh(),t=xh(),r=bh(),n=mh(),i=Object.getOwnPropertySymbols;return bo=i?function(n){for(var i=[];n;)e(i,r(n)),n=t(n);return i}:n}function wh(){if(Ao)return wo;Ao=1;var e=vh(),t=rs();return wo=function(r,n,i){var s=n(r);return t(r)?s:e(s,i(r))}}function Ah(){if(Ro)return Co;Ro=1;var e=wh(),t=bh(),r=eo();return Co=function(n){return e(n,r,t)}}function Ch(){if(Vo)return Lo;Vo=1;var e=Fi()(Pi(),"Set");return Lo=e}function Rh(){if(Mo)return Bo;Mo=1;var e=function(){if(Oo)return So;Oo=1;var e=Fi()(Pi(),"DataView");return So=e}(),t=Ui(),r=function(){if(No)return Io;No=1;var e=Fi()(Pi(),"Promise");return Io=e}(),n=Ch(),i=function(){if(Do)return Po;Do=1;var e=Fi()(Pi(),"WeakMap");return Po=e}(),s=Bi(),o=zi(),a="[object Map]",l="[object Promise]",u="[object Set]",c="[object WeakMap]",h="[object DataView]",d=o(e),f=o(t),p=o(r),_=o(n),g=o(i),y=s;return(e&&y(new e(new ArrayBuffer(1)))!=h||t&&y(new t)!=a||r&&y(r.resolve())!=l||n&&y(new n)!=u||i&&y(new i)!=c)&&(y=function(e){var t=s(e),r="[object Object]"==t?e.constructor:void 0,n=r?o(r):"";if(n)switch(n){case d:return h;case f:return a;case p:return l;case _:return u;case g:return c}return t}),Bo=y}function kh(){if(Fo)return zo;Fo=1;var e=Pi().Uint8Array;return zo=e}function Th(){if(Ho)return Uo;Ho=1;var e=kh();return Uo=function(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function Sh(){if(Jo)return $o;Jo=1;var e=Th();return $o=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}function Oh(){if(ea)return Qo;ea=1;var e=Th(),t=function(){if(Yo)return Wo;Yo=1;var e=Th();return Wo=function(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}}(),r=function(){if(qo)return Xo;qo=1;var e=/\w*$/;return Xo=function(t){var r=new t.constructor(t.source,e.exec(t));return r.lastIndex=t.lastIndex,r}}(),n=function(){if(Zo)return Ko;Zo=1;var e=Di(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;return Ko=function(e){return r?Object(r.call(e)):{}}}(),i=Sh();return Qo=function(s,o,a){var l=s.constructor;switch(o){case"[object ArrayBuffer]":return e(s);case"[object Boolean]":case"[object Date]":return new l(+s);case"[object DataView]":return t(s,a);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return i(s,a);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(s);case"[object RegExp]":return r(s);case"[object Symbol]":return n(s)}}}function Ih(){if(ra)return ta;ra=1;var e=Mi(),t=Object.create,r=function(){function r(){}return function(n){if(!e(n))return{};if(t)return t(n);r.prototype=n;var i=new r;return r.prototype=void 0,i}}();return ta=r}function Nh(){if(ia)return na;ia=1;var e=Ih(),t=xh(),r=Zs();return na=function(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function Lh(){if(la)return aa;la=1;var e=function(){if(oa)return sa;oa=1;var e=Rh(),t=es();return sa=function(r){return t(r)&&"[object Map]"==e(r)}}(),t=ms(),r=Xs(),n=r&&r.isMap,i=n?t(n):e;return aa=i}function Vh(){if(da)return ha;da=1;var e=function(){if(ca)return ua;ca=1;var e=Rh(),t=es();return ua=function(r){return t(r)&&"[object Set]"==e(r)}}(),t=ms(),r=Xs(),n=r&&r.isSet,i=n?t(n):e;return ha=i}function Ph(){if(pa)return fa;pa=1;var e=qi(),t=Ki(),r=Ji(),n=function(){if(Bs)return Ds;Bs=1;var e=Qi(),t=eo();return Ds=function(r,n){return r&&e(n,t(n),r)}}(),i=function(){if(Ws)return Hs;Ws=1;var e=Qi(),t=ro();return Hs=function(r,n){return r&&e(n,t(n),r)}}(),s=_h(),o=gh(),a=function(){if(po)return fo;po=1;var e=Qi(),t=bh();return fo=function(r,n){return e(r,t(r),n)}}(),l=function(){if(Eo)return xo;Eo=1;var e=Qi(),t=Eh();return xo=function(r,n){return e(r,t(r),n)}}(),u=Ah(),c=function(){if(To)return ko;To=1;var e=wh(),t=Eh(),r=ro();return ko=function(n){return e(n,r,t)}}(),h=Rh(),d=function(){if(jo)return Go;jo=1;var e=Object.prototype.hasOwnProperty;return Go=function(t){var r=t.length,n=new t.constructor(r);return r&&"string"==typeof t[0]&&e.call(t,"index")&&(n.index=t.index,n.input=t.input),n}}(),f=Oh(),p=Nh(),_=rs(),g=_s(),y=Lh(),m=Mi(),b=Vh(),v=eo(),x=ro(),E="[object Arguments]",w="[object Function]",A="[object Object]",C={};return C[E]=C["[object Array]"]=C["[object ArrayBuffer]"]=C["[object DataView]"]=C["[object Boolean]"]=C["[object Date]"]=C["[object Float32Array]"]=C["[object Float64Array]"]=C["[object Int8Array]"]=C["[object Int16Array]"]=C["[object Int32Array]"]=C["[object Map]"]=C["[object Number]"]=C[A]=C["[object RegExp]"]=C["[object Set]"]=C["[object String]"]=C["[object Symbol]"]=C["[object Uint8Array]"]=C["[object Uint8ClampedArray]"]=C["[object Uint16Array]"]=C["[object Uint32Array]"]=!0,C["[object Error]"]=C[w]=C["[object WeakMap]"]=!1,fa=function R(k,T,S,O,I,N){var L,V=1&T,P=2&T,D=4&T;if(S&&(L=I?S(k,O,I,N):S(k)),void 0!==L)return L;if(!m(k))return k;var B=_(k);if(B){if(L=d(k),!V)return o(k,L)}else{var M=h(k),G=M==w||"[object GeneratorFunction]"==M;if(g(k))return s(k,V);if(M==A||M==E||G&&!I){if(L=P||G?{}:p(k),!V)return P?l(k,i(L,k)):a(k,n(L,k))}else{if(!C[M])return I?k:{};L=f(k,M,V)}}N||(N=new e);var j=N.get(k);if(j)return j;N.set(k,L),b(k)?k.forEach((function(e){L.add(R(e,T,S,e,k,N))})):y(k)&&k.forEach((function(e,t){L.set(t,R(e,T,S,t,k,N))}));var z=B?void 0:(D?P?c:u:P?x:v)(k);return t(z||k,(function(e,t){z&&(e=k[t=e]),r(L,t,R(e,T,S,t,k,N))})),L},fa}function Dh(){if(ga)return _a;ga=1;var e=Ph();return _a=function(t){return e(t,4)}}function Bh(){if(ma)return ya;return ma=1,ya=function(e){return function(){return e}}}function Mh(){if(Ea)return xa;Ea=1;var e=(va?ba:(va=1,ba=function(e){return function(t,r,n){for(var i=-1,s=Object(t),o=n(t),a=o.length;a--;){var l=o[e?a:++i];if(!1===r(s[l],l,s))break}return t}}))();return xa=e}function Gh(){if(Aa)return wa;Aa=1;var e=Mh(),t=eo();return wa=function(r,n){return r&&e(r,n,t)}}function jh(){if(Ta)return ka;Ta=1;var e=Gh(),t=function(){if(Ra)return Ca;Ra=1;var e=Qs();return Ca=function(t,r){return function(n,i){if(null==n)return n;if(!e(n))return t(n,i);for(var s=n.length,o=r?s:-1,a=Object(n);(r?o--:++o<s)&&!1!==i(a[o],o,a););return n}}}()(e);return ka=t}function zh(){if(Oa)return Sa;return Oa=1,Sa=function(e){return e}}function Fh(){if(Na)return Ia;Na=1;var e=zh();return Ia=function(t){return"function"==typeof t?t:e}}function Uh(){if(Va)return La;Va=1;var e=Ki(),t=jh(),r=Fh(),n=rs();return La=function(i,s){return(n(i)?e:t)(i,r(s))}}function Hh(){return Da?Pa:(Da=1,Pa=Uh())}function Wh(){if(Ha)return Ua;Ha=1;var e=Xi(),t=ja?Ga:(ja=1,Ga=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this}),r=Fa?za:(Fa=1,za=function(e){return this.__data__.has(e)});function n(t){var r=-1,n=null==t?0:t.length;for(this.__data__=new e;++r<n;)this.add(t[r])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Ua=n}
29
+ /**
30
+ * A specialized version of `_.some` for arrays without support for iteratee
31
+ * shorthands.
32
+ *
33
+ * @private
34
+ * @param {Array} [array] The array to iterate over.
35
+ * @param {Function} predicate The function invoked per iteration.
36
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
37
+ * else `false`.
38
+ */function Yh(){if(qa)return Xa;return qa=1,Xa=function(e,t){return e.has(t)}}function Xh(){if(Za)return Ka;Za=1;var e=Wh(),t=Ya?Wa:(Ya=1,Wa=function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}),r=Yh();return Ka=
39
+ /**
40
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
41
+ * partial deep comparisons.
42
+ *
43
+ * @private
44
+ * @param {Array} array The array to compare.
45
+ * @param {Array} other The other array to compare.
46
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
47
+ * @param {Function} customizer The function to customize comparisons.
48
+ * @param {Function} equalFunc The function to determine equivalents of values.
49
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
50
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
51
+ */
52
+ function(n,i,s,o,a,l){var u=1&s,c=n.length,h=i.length;if(c!=h&&!(u&&h>c))return!1;var d=l.get(n),f=l.get(i);if(d&&f)return d==i&&f==n;var p=-1,_=!0,g=2&s?new e:void 0;for(l.set(n,i),l.set(i,n);++p<c;){var y=n[p],m=i[p];if(o)var b=u?o(m,y,p,i,n,l):o(y,m,p,n,i,l);if(void 0!==b){if(b)continue;_=!1;break}if(g){if(!t(i,(function(e,t){if(!r(g,t)&&(y===e||a(y,e,s,o,l)))return g.push(t)}))){_=!1;break}}else if(y!==m&&!a(y,m,s,o,l)){_=!1;break}}return l.delete(n),l.delete(i),_}}function qh(){if(el)return Qa;return el=1,Qa=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}}function Kh(){if(rl)return tl;rl=1;var e=Di(),t=kh(),r=Ii(),n=Xh(),i=Ja?$a:(Ja=1,$a=function(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}),s=qh(),o=e?e.prototype:void 0,a=o?o.valueOf:void 0;return tl=
53
+ /**
54
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
55
+ * the same `toStringTag`.
56
+ *
57
+ * **Note:** This function only supports comparing values with tags of
58
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
59
+ *
60
+ * @private
61
+ * @param {Object} object The object to compare.
62
+ * @param {Object} other The other object to compare.
63
+ * @param {string} tag The `toStringTag` of the objects to compare.
64
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
65
+ * @param {Function} customizer The function to customize comparisons.
66
+ * @param {Function} equalFunc The function to determine equivalents of values.
67
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
68
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
69
+ */
70
+ function(e,o,l,u,c,h,d){switch(l){case"[object DataView]":if(e.byteLength!=o.byteLength||e.byteOffset!=o.byteOffset)return!1;e=e.buffer,o=o.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=o.byteLength||!h(new t(e),new t(o)));case"[object Boolean]":case"[object Date]":case"[object Number]":return r(+e,+o);case"[object Error]":return e.name==o.name&&e.message==o.message;case"[object RegExp]":case"[object String]":return e==o+"";case"[object Map]":var f=i;case"[object Set]":var p=1&u;if(f||(f=s),e.size!=o.size&&!p)return!1;var _=d.get(e);if(_)return _==o;u|=2,d.set(e,o);var g=n(f(e),f(o),u,c,h,d);return d.delete(e),g;case"[object Symbol]":if(a)return a.call(e)==a.call(o)}return!1}}function Zh(){if(ol)return sl;ol=1;var e=qi(),t=Xh(),r=Kh(),n=function(){if(il)return nl;il=1;var e=Ah(),t=Object.prototype.hasOwnProperty;return nl=
71
+ /**
72
+ * A specialized version of `baseIsEqualDeep` for objects with support for
73
+ * partial deep comparisons.
74
+ *
75
+ * @private
76
+ * @param {Object} object The object to compare.
77
+ * @param {Object} other The other object to compare.
78
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
79
+ * @param {Function} customizer The function to customize comparisons.
80
+ * @param {Function} equalFunc The function to determine equivalents of values.
81
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
82
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
83
+ */
84
+ function(r,n,i,s,o,a){var l=1&i,u=e(r),c=u.length;if(c!=e(n).length&&!l)return!1;for(var h=c;h--;){var d=u[h];if(!(l?d in n:t.call(n,d)))return!1}var f=a.get(r),p=a.get(n);if(f&&p)return f==n&&p==r;var _=!0;a.set(r,n),a.set(n,r);for(var g=l;++h<c;){var y=r[d=u[h]],m=n[d];if(s)var b=l?s(m,y,d,n,r,a):s(y,m,d,r,n,a);if(!(void 0===b?y===m||o(y,m,i,s,a):b)){_=!1;break}g||(g="constructor"==d)}if(_&&!g){var v=r.constructor,x=n.constructor;v==x||!("constructor"in r)||!("constructor"in n)||"function"==typeof v&&v instanceof v&&"function"==typeof x&&x instanceof x||(_=!1)}return a.delete(r),a.delete(n),_}}(),i=Rh(),s=rs(),o=_s(),a=qs(),l="[object Arguments]",u="[object Array]",c="[object Object]",h=Object.prototype.hasOwnProperty;return sl=
85
+ /**
86
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
87
+ * deep comparisons and tracks traversed objects enabling objects with circular
88
+ * references to be compared.
89
+ *
90
+ * @private
91
+ * @param {Object} object The object to compare.
92
+ * @param {Object} other The other object to compare.
93
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
94
+ * @param {Function} customizer The function to customize comparisons.
95
+ * @param {Function} equalFunc The function to determine equivalents of values.
96
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
97
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
98
+ */
99
+ function(d,f,p,_,g,y){var m=s(d),b=s(f),v=m?u:i(d),x=b?u:i(f),E=(v=v==l?c:v)==c,w=(x=x==l?c:x)==c,A=v==x;if(A&&o(d)){if(!o(f))return!1;m=!0,E=!1}if(A&&!E)return y||(y=new e),m||a(d)?t(d,f,p,_,g,y):r(d,f,v,p,_,g,y);if(!(1&p)){var C=E&&h.call(d,"__wrapped__"),R=w&&h.call(f,"__wrapped__");if(C||R){var k=C?d.value():d,T=R?f.value():f;return y||(y=new e),g(k,T,p,_,y)}}return!!A&&(y||(y=new e),n(d,f,p,_,g,y))}}function $h(){if(ll)return al;ll=1;var e=Zh(),t=es();return al=function r(n,i,s,o,a){return n===i||(null==n||null==i||!t(n)&&!t(i)?n!=n&&i!=i:e(n,i,s,o,r,a))},al}function Jh(){if(dl)return hl;dl=1;var e=Mi();return hl=function(t){return t==t&&!e(t)}}function Qh(){if(gl)return _l;return gl=1,_l=function(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}}function ed(){if(ml)return yl;ml=1;var e=function(){if(cl)return ul;cl=1;var e=qi(),t=$h();return ul=function(r,n,i,s){var o=i.length,a=o,l=!s;if(null==r)return!a;for(r=Object(r);o--;){var u=i[o];if(l&&u[2]?u[1]!==r[u[0]]:!(u[0]in r))return!1}for(;++o<a;){var c=(u=i[o])[0],h=r[c],d=u[1];if(l&&u[2]){if(void 0===h&&!(c in r))return!1}else{var f=new e;if(s)var p=s(h,d,c,r,n,f);if(!(void 0===p?t(d,h,3,s,f):p))return!1}}return!0}}(),t=function(){if(pl)return fl;pl=1;var e=Jh(),t=eo();return fl=function(r){for(var n=t(r),i=n.length;i--;){var s=n[i],o=r[s];n[i]=[s,o,e(o)]}return n}}
100
+ /**
101
+ * A specialized version of `matchesProperty` for source values suitable
102
+ * for strict equality comparisons, i.e. `===`.
103
+ *
104
+ * @private
105
+ * @param {string} key The key of the property to get.
106
+ * @param {*} srcValue The value to match.
107
+ * @returns {Function} Returns the new spec function.
108
+ */(),r=Qh();return yl=function(n){var i=t(n);return 1==i.length&&i[0][2]?r(i[0][0],i[0][1]):function(t){return t===n||e(t,n,i)}}}function td(){if(vl)return bl;vl=1;var e=Bi(),t=es();return bl=function(r){return"symbol"==typeof r||t(r)&&"[object Symbol]"==e(r)}}function rd(){if(El)return xl;El=1;var e=rs(),t=td(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;return xl=function(i,s){if(e(i))return!1;var o=typeof i;return!("number"!=o&&"symbol"!=o&&"boolean"!=o&&null!=i&&!t(i))||(n.test(i)||!r.test(i)||null!=s&&i in Object(s))}}function nd(){if(Rl)return Cl;Rl=1;var e=function(){if(Al)return wl;Al=1;var e=Xi();function t(r,n){if("function"!=typeof r||null!=n&&"function"!=typeof n)throw new TypeError("Expected a function");var i=function(){var e=arguments,t=n?n.apply(this,e):e[0],s=i.cache;if(s.has(t))return s.get(t);var o=r.apply(this,e);return i.cache=s.set(t,o)||s,o};return i.cache=new(t.Cache||e),i}return t.Cache=e,wl=t}();return Cl=
109
+ /**
110
+ * A specialized version of `_.memoize` which clears the memoized function's
111
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
112
+ *
113
+ * @private
114
+ * @param {Function} func The function to have its output memoized.
115
+ * @returns {Function} Returns the new memoized function.
116
+ */
117
+ function(t){var r=e(t,(function(e){return 500===n.size&&n.clear(),e})),n=r.cache;return r}}function id(){if(Ol)return Sl;return Ol=1,Sl=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}}function sd(){if(Vl)return Ll;Vl=1;var e=function(){if(Nl)return Il;Nl=1;var e=Di(),t=id(),r=rs(),n=td(),i=e?e.prototype:void 0,s=i?i.toString:void 0;return Il=function e(i){if("string"==typeof i)return i;if(r(i))return t(i,e)+"";if(n(i))return s?s.call(i):"";var o=i+"";return"0"==o&&1/i==-1/0?"-0":o},Il}();return Ll=function(t){return null==t?"":e(t)}}function od(){if(Dl)return Pl;Dl=1;var e=rs(),t=rd(),r=function(){if(Tl)return kl;Tl=1;var e=nd(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e((function(e){var n=[];return 46===e.charCodeAt(0)&&n.push(""),e.replace(t,(function(e,t,i,s){n.push(i?s.replace(r,"$1"):t||e)})),n}));return kl=n}
118
+ /**
119
+ * A specialized version of `_.map` for arrays without support for iteratee
120
+ * shorthands.
121
+ *
122
+ * @private
123
+ * @param {Array} [array] The array to iterate over.
124
+ * @param {Function} iteratee The function invoked per iteration.
125
+ * @returns {Array} Returns the new mapped array.
126
+ */(),n=sd();return Pl=function(i,s){return e(i)?i:t(i,s)?[i]:r(n(i))}}function ad(){if(Ml)return Bl;Ml=1;var e=td();return Bl=function(t){if("string"==typeof t||e(t))return t;var r=t+"";return"0"==r&&1/t==-Infinity?"-0":r}}function ld(){if(jl)return Gl;jl=1;var e=od(),t=ad();return Gl=function(r,n){for(var i=0,s=(n=e(n,r)).length;null!=r&&i<s;)r=r[t(n[i++])];return i&&i==s?r:void 0}}function ud(){if(Yl)return Wl;Yl=1;var e=od(),t=ts(),r=rs(),n=gs(),i=ys(),s=ad();return Wl=function(o,a,l){for(var u=-1,c=(a=e(a,o)).length,h=!1;++u<c;){var d=s(a[u]);if(!(h=null!=o&&l(o,d)))break;o=o[d]}return h||++u!=c?h:!!(c=null==o?0:o.length)&&i(c)&&n(d,c)&&(r(o)||t(o))}}function cd(){if(ql)return Xl;ql=1;var e=Hl?Ul:(Hl=1,Ul=function(e,t){return null!=e&&t in Object(e)}),t=ud();return Xl=function(r,n){return null!=r&&t(r,n,e)}}function hd(){if(Zl)return Kl;Zl=1;var e=$h(),t=function(){if(Fl)return zl;Fl=1;var e=ld();return zl=function(t,r,n){var i=null==t?void 0:e(t,r);return void 0===i?n:i}}(),r=cd(),n=rd(),i=Jh(),s=Qh(),o=ad();return Kl=function(a,l){return n(a)&&i(l)?s(o(a),l):function(n){var i=t(n,a);return void 0===i&&i===l?r(n,a):e(l,i,3)}}}function dd(){if(Jl)return $l;return Jl=1,$l=function(e){return function(t){return null==t?void 0:t[e]}}}function fd(){if(ru)return tu;ru=1;var e=dd(),t=function(){if(eu)return Ql;eu=1;var e=ld();
127
+ /**
128
+ * A specialized version of `baseProperty` which supports deep paths.
129
+ *
130
+ * @private
131
+ * @param {Array|string} path The path of the property to get.
132
+ * @returns {Function} Returns the new accessor function.
133
+ */return Ql=function(t){return function(r){return e(r,t)}}}(),r=rd(),n=ad();return tu=function(i){return r(i)?e(n(i)):t(i)}}function pd(){if(iu)return nu;iu=1;var e=ed(),t=hd(),r=zh(),n=rs(),i=fd();return nu=function(s){return"function"==typeof s?s:null==s?r:"object"==typeof s?n(s)?t(s[0],s[1]):e(s):i(s)}}function _d(){if(ou)return su;ou=1;var e=yh(),t=function(){if(Ma)return Ba;Ma=1;var e=jh();return Ba=function(t,r){var n=[];return e(t,(function(e,t,i){r(e,t,i)&&n.push(e)})),n}}(),r=pd(),n=rs();return su=function(i,s){return(n(i)?e:t)(i,r(s,3))}}function gd(){if(cu)return uu;cu=1;var e=function(){if(lu)return au;lu=1;var e=Object.prototype.hasOwnProperty;return au=function(t,r){return null!=t&&e.call(t,r)}}(),t=ud();return uu=function(r,n){return null!=r&&t(r,n,e)}}function yd(){if(du)return hu;du=1;var e=Js(),t=Rh(),r=ts(),n=rs(),i=Qs(),s=_s(),o=Zs(),a=qs(),l=Object.prototype.hasOwnProperty;return hu=function(u){if(null==u)return!0;if(i(u)&&(n(u)||"string"==typeof u||"function"==typeof u.splice||s(u)||a(u)||r(u)))return!u.length;var c=t(u);if("[object Map]"==c||"[object Set]"==c)return!u.size;if(o(u))return!e(u).length;for(var h in u)if(l.call(u,h))return!1;return!0}}function md(){if(pu)return fu;return pu=1,fu=function(e){return void 0===e}}function bd(){if(gu)return _u;gu=1;var e=jh(),t=Qs();return _u=function(r,n){var i=-1,s=t(r)?Array(r.length):[];return e(r,(function(e,t,r){s[++i]=n(e,t,r)})),s}}function vd(){if(mu)return yu;mu=1;var e=id(),t=pd(),r=bd(),n=rs();return yu=function(i,s){return(n(i)?e:r)(i,t(s,3))}}
134
+ /**
135
+ * A specialized version of `_.reduce` for arrays without support for
136
+ * iteratee shorthands.
137
+ *
138
+ * @private
139
+ * @param {Array} [array] The array to iterate over.
140
+ * @param {Function} iteratee The function invoked per iteration.
141
+ * @param {*} [accumulator] The initial value.
142
+ * @param {boolean} [initAccum] Specify using the first element of `array` as
143
+ * the initial value.
144
+ * @returns {*} Returns the accumulated value.
145
+ */function xd(){if(Au)return wu;Au=1;var e=vu?bu:(vu=1,bu=function(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}),t=jh(),r=pd(),n=Eu?xu:(Eu=1,xu=function(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}),i=rs();return wu=function(s,o,a){var l=i(s)?e:n,u=arguments.length<3;return l(s,r(o,4),a,u,t)},wu}function Ed(){if(Vu)return Lu;Vu=1;var e=function(){if(Tu)return ku;Tu=1;var e=dd()("length");return ku=e}(),t=function(){if(Ou)return Su;Ou=1;var e=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");return Su=function(t){return e.test(t)}}(),r=function(){if(Nu)return Iu;Nu=1;var e="\\ud800-\\udfff",t="["+e+"]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",n="\\ud83c[\\udffb-\\udfff]",i="[^"+e+"]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",o="[\\ud800-\\udbff][\\udc00-\\udfff]",a="(?:"+r+"|"+n+")?",l="[\\ufe0e\\ufe0f]?",u=l+a+"(?:\\u200d(?:"+[i,s,o].join("|")+")"+l+a+")*",c="(?:"+[i+r+"?",r,s,o,t].join("|")+")",h=RegExp(n+"(?="+n+")|"+c+u,"g");return Iu=function(e){for(var t=h.lastIndex=0;h.test(e);)++t;return t}}();return Lu=function(n){return t(n)?r(n):e(n)}}function wd(){if(Du)return Pu;Du=1;var e=Js(),t=Rh(),r=Qs(),n=function(){if(Ru)return Cu;Ru=1;var e=Bi(),t=rs(),r=es();return Cu=function(n){return"string"==typeof n||!t(n)&&r(n)&&"[object String]"==e(n)}}(),i=Ed();return Pu=function(s){if(null==s)return 0;if(r(s))return n(s)?i(s):s.length;var o=t(s);return"[object Map]"==o||"[object Set]"==o?s.size:e(s).length}}function Ad(){if(Mu)return Bu;Mu=1;var e=Ki(),t=Ih(),r=Gh(),n=pd(),i=xh(),s=rs(),o=_s(),a=Gi(),l=Mi(),u=qs();return Bu=function(c,h,d){var f=s(c),p=f||o(c)||u(c);if(h=n(h,4),null==d){var _=c&&c.constructor;d=p?f?new _:[]:l(c)&&a(_)?t(i(c)):{}}return(p?e:r)(c,(function(e,t,r){return h(d,e,t,r)})),d}}function Cd(){if(Fu)return zu;Fu=1;var e=vh(),t=function(){if(ju)return Gu;ju=1;var e=Di(),t=ts(),r=rs(),n=e?e.isConcatSpreadable:void 0;return Gu=function(e){return r(e)||t(e)||!!(n&&e&&e[n])}}();return zu=function r(n,i,s,o,a){var l=-1,u=n.length;for(s||(s=t),a||(a=[]);++l<u;){var c=n[l];i>0&&s(c)?i>1?r(c,i-1,s,o,a):e(a,c):o||(a[a.length]=c)}return a},zu}function Rd(){if(Yu)return Wu;Yu=1;var e=Hu?Uu:(Hu=1,Uu=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}),t=Math.max;return Wu=
146
+ /**
147
+ * A specialized version of `baseRest` which transforms the rest array.
148
+ *
149
+ * @private
150
+ * @param {Function} func The function to apply a rest parameter to.
151
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
152
+ * @param {Function} transform The rest array transform.
153
+ * @returns {Function} Returns the new function.
154
+ */
155
+ function(r,n,i){return n=t(void 0===n?r.length-1:n,0),function(){for(var s=arguments,o=-1,a=t(s.length-n,0),l=Array(a);++o<a;)l[o]=s[n+o];o=-1;for(var u=Array(n+1);++o<n;)u[o]=s[o];return u[n]=i(l),e(r,this,u)}},Wu}function kd(){if(Ju)return $u;Ju=1;var e=function(){if(qu)return Xu;qu=1;var e=Bh(),t=Zi(),r=zh();return Xu=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:r}(),t=function(){if(Zu)return Ku;Zu=1;var e=Date.now;return Ku=function(t){var r=0,n=0;return function(){var i=e(),s=16-(i-n);if(n=i,s>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Ku}(),r=t(e);return $u=r}function Td(){if(ec)return Qu;ec=1;var e=zh(),t=Rd(),r=kd();return Qu=function(n,i){return r(t(n,i,e),n+"")}}function Sd(){if(rc)return tc;return rc=1,tc=function(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}}function Od(){if(lc)return ac;lc=1;var e=Sd(),t=ic?nc:(ic=1,nc=function(e){return e!=e}),r=oc?sc:(oc=1,sc=function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1});return ac=function(n,i,s){return i==i?r(n,i,s):e(n,t,s)}}function Id(){if(gc)return _c;gc=1;var e=Ch(),t=pc?fc:(pc=1,fc=function(){}),r=qh(),n=e&&1/r(new e([,-0]))[1]==1/0?function(t){return new e(t)}:t;return _c=n}function Nd(){if(mc)return yc;mc=1;var e=Wh(),t=function(){if(cc)return uc;cc=1;var e=Od();
156
+ /**
157
+ * A specialized version of `_.includes` for arrays without support for
158
+ * specifying an index to search from.
159
+ *
160
+ * @private
161
+ * @param {Array} [array] The array to inspect.
162
+ * @param {*} target The value to search for.
163
+ * @returns {boolean} Returns `true` if `target` is found, else `false`.
164
+ */return uc=function(t,r){return!(null==t||!t.length)&&e(t,r,0)>-1}}(),r=dc?hc:(dc=1,hc=function(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}),n=Yh(),i=Id(),s=qh();return yc=function(o,a,l){var u=-1,c=t,h=o.length,d=!0,f=[],p=f;if(l)d=!1,c=r;else if(h>=200){var _=a?null:i(o);if(_)return s(_);d=!1,c=n,p=new e}else p=a?[]:f;e:for(;++u<h;){var g=o[u],y=a?a(g):g;if(g=l||0!==g?g:0,d&&y==y){for(var m=p.length;m--;)if(p[m]===y)continue e;a&&p.push(y),f.push(g)}else c(p,y,l)||(p!==f&&p.push(y),f.push(g))}return f}}function Ld(){if(vc)return bc;vc=1;var e=Qs(),t=es();return bc=function(r){return t(r)&&e(r)}}function Vd(){if(Ec)return xc;Ec=1;var e=Cd(),t=Td(),r=Nd(),n=Ld(),i=t((function(t){return r(e(t,1,n,!0))}));return xc=i}function Pd(){if(Rc)return Cc;Rc=1;var e=function(){if(Ac)return wc;Ac=1;var e=id();return wc=function(t,r){return e(r,(function(e){return t[e]}))}}(),t=eo();return Cc=function(r){return null==r?[]:e(r,t(r))}}function Dd(){if(Tc)return kc;var e;Tc=1;try{e={clone:Dh(),constant:Bh(),each:Hh(),filter:_d(),has:gd(),isArray:rs(),isEmpty:yd(),isFunction:Gi(),isUndefined:md(),keys:eo(),map:vd(),reduce:xd(),size:wd(),transform:Ad(),union:Vd(),values:Pd()}}catch(e){}return e||(e=window._),kc=e}function Bd(){if(Oc)return Sc;Oc=1;var e=Dd();Sc=i;var t="\0",r="\0",n="";function i(t){this._isDirected=!e.has(t,"directed")||t.directed,this._isMultigraph=!!e.has(t,"multigraph")&&t.multigraph,this._isCompound=!!e.has(t,"compound")&&t.compound,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function s(e,t){e[t]?e[t]++:e[t]=1}function o(e,t){--e[t]||delete e[t]}function a(r,i,s,o){var a=""+i,l=""+s;if(!r&&a>l){var u=a;a=l,l=u}return a+n+l+n+(e.isUndefined(o)?t:o)}function l(e,t){return a(e,t.v,t.w,t.name)}return i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(e){return this._label=e,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultNodeLabelFn=t,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var t=this;return e.filter(this.nodes(),(function(r){return e.isEmpty(t._in[r])}))},i.prototype.sinks=function(){var t=this;return e.filter(this.nodes(),(function(r){return e.isEmpty(t._out[r])}))},i.prototype.setNodes=function(t,r){var n=arguments,i=this;return e.each(t,(function(e){n.length>1?i.setNode(e,r):i.setNode(e)})),this},i.prototype.setNode=function(t,n){return e.has(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=r,this._children[t]={},this._children[r][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)},i.prototype.node=function(e){return this._nodes[e]},i.prototype.hasNode=function(t){return e.has(this._nodes,t)},i.prototype.removeNode=function(t){var r=this;if(e.has(this._nodes,t)){var n=function(e){r.removeEdge(r._edgeObjs[e])};delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],e.each(this.children(t),(function(e){r.setParent(e)})),delete this._children[t]),e.each(e.keys(this._in[t]),n),delete this._in[t],delete this._preds[t],e.each(e.keys(this._out[t]),n),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this},i.prototype.setParent=function(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(n))n=r;else{for(var i=n+="";!e.isUndefined(i);i=this.parent(i))if(i===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this},i.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},i.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==r)return t}},i.prototype.children=function(t){if(e.isUndefined(t)&&(t=r),this._isCompound){var n=this._children[t];if(n)return e.keys(n)}else{if(t===r)return this.nodes();if(this.hasNode(t))return[]}},i.prototype.predecessors=function(t){var r=this._preds[t];if(r)return e.keys(r)},i.prototype.successors=function(t){var r=this._sucs[t];if(r)return e.keys(r)},i.prototype.neighbors=function(t){var r=this.predecessors(t);if(r)return e.union(r,this.successors(t))},i.prototype.isLeaf=function(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length},i.prototype.filterNodes=function(t){var r=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});r.setGraph(this.graph());var n=this;e.each(this._nodes,(function(e,n){t(n)&&r.setNode(n,e)})),e.each(this._edgeObjs,(function(e){r.hasNode(e.v)&&r.hasNode(e.w)&&r.setEdge(e,n.edge(e))}));var i={};function s(e){var t=n.parent(e);return void 0===t||r.hasNode(t)?(i[e]=t,t):t in i?i[t]:s(t)}return this._isCompound&&e.each(r.nodes(),(function(e){r.setParent(e,s(e))})),r},i.prototype.setDefaultEdgeLabel=function(t){return e.isFunction(t)||(t=e.constant(t)),this._defaultEdgeLabelFn=t,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(t,r){var n=this,i=arguments;return e.reduce(t,(function(e,t){return i.length>1?n.setEdge(e,t,r):n.setEdge(e,t),t})),this},i.prototype.setEdge=function(){var t,r,n,i,o=!1,l=arguments[0];"object"==typeof l&&null!==l&&"v"in l?(t=l.v,r=l.w,n=l.name,2===arguments.length&&(i=arguments[1],o=!0)):(t=l,r=arguments[1],n=arguments[3],arguments.length>2&&(i=arguments[2],o=!0)),t=""+t,r=""+r,e.isUndefined(n)||(n=""+n);var u=a(this._isDirected,t,r,n);if(e.has(this._edgeLabels,u))return o&&(this._edgeLabels[u]=i),this;if(!e.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(r),this._edgeLabels[u]=o?i:this._defaultEdgeLabelFn(t,r,n);var c=function(e,t,r,n){var i=""+t,s=""+r;if(!e&&i>s){var o=i;i=s,s=o}var a={v:i,w:s};n&&(a.name=n);return a}(this._isDirected,t,r,n);return t=c.v,r=c.w,Object.freeze(c),this._edgeObjs[u]=c,s(this._preds[r],t),s(this._sucs[t],r),this._in[r][u]=c,this._out[t][u]=c,this._edgeCount++,this},i.prototype.edge=function(e,t,r){var n=1===arguments.length?l(this._isDirected,arguments[0]):a(this._isDirected,e,t,r);return this._edgeLabels[n]},i.prototype.hasEdge=function(t,r,n){var i=1===arguments.length?l(this._isDirected,arguments[0]):a(this._isDirected,t,r,n);return e.has(this._edgeLabels,i)},i.prototype.removeEdge=function(e,t,r){var n=1===arguments.length?l(this._isDirected,arguments[0]):a(this._isDirected,e,t,r),i=this._edgeObjs[n];return i&&(e=i.v,t=i.w,delete this._edgeLabels[n],delete this._edgeObjs[n],o(this._preds[t],e),o(this._sucs[e],t),delete this._in[t][n],delete this._out[e][n],this._edgeCount--),this},i.prototype.inEdges=function(t,r){var n=this._in[t];if(n){var i=e.values(n);return r?e.filter(i,(function(e){return e.v===r})):i}},i.prototype.outEdges=function(t,r){var n=this._out[t];if(n){var i=e.values(n);return r?e.filter(i,(function(e){return e.w===r})):i}},i.prototype.nodeEdges=function(e,t){var r=this.inEdges(e,t);if(r)return r.concat(this.outEdges(e,t))},Sc}function Md(){return Vc?Lc:(Vc=1,Lc={Graph:Bd(),version:Nc?Ic:(Nc=1,Ic="2.1.8")})}function Gd(){if(Dc)return Pc;Dc=1;var e=Dd(),t=Bd();function r(t){return e.map(t.nodes(),(function(r){var n=t.node(r),i=t.parent(r),s={v:r};return e.isUndefined(n)||(s.value=n),e.isUndefined(i)||(s.parent=i),s}))}function n(t){return e.map(t.edges(),(function(r){var n=t.edge(r),i={v:r.v,w:r.w};return e.isUndefined(r.name)||(i.name=r.name),e.isUndefined(n)||(i.value=n),i}))}return Pc={write:function(t){var i={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:r(t),edges:n(t)};e.isUndefined(t.graph())||(i.value=e.clone(t.graph()));return i},read:function(r){var n=new t(r.options).setGraph(r.value);return e.each(r.nodes,(function(e){n.setNode(e.v,e.value),e.parent&&n.setParent(e.v,e.parent)})),e.each(r.edges,(function(e){n.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),n}}}function jd(){if(Mc)return Bc;Mc=1;var e=Dd();return Bc=function(t){var r,n={},i=[];function s(i){e.has(n,i)||(n[i]=!0,r.push(i),e.each(t.successors(i),s),e.each(t.predecessors(i),s))}return e.each(t.nodes(),(function(e){r=[],s(e),r.length&&i.push(r)})),i},Bc}function zd(){if(jc)return Gc;jc=1;var e=Dd();function t(){this._arr=[],this._keyIndices={}}return Gc=t,t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map((function(e){return e.key}))},t.prototype.has=function(t){return e.has(this._keyIndices,t)},t.prototype.priority=function(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority},t.prototype.min=function(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(t,r){var n=this._keyIndices;if(t=String(t),!e.has(n,t)){var i=this._arr,s=i.length;return n[t]=s,i.push({key:t,priority:r}),this._decrease(s),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},t.prototype.decrease=function(e,t){var r=this._keyIndices[e];if(t>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)},t.prototype._heapify=function(e){var t=this._arr,r=2*e,n=r+1,i=e;r<t.length&&(i=t[r].priority<t[i].priority?r:i,n<t.length&&(i=t[n].priority<t[i].priority?n:i),i!==e&&(this._swap(e,i),this._heapify(i)))},t.prototype._decrease=function(e){for(var t,r=this._arr,n=r[e].priority;0!==e&&!(r[t=e>>1].priority<n);)this._swap(e,t),e=t},t.prototype._swap=function(e,t){var r=this._arr,n=this._keyIndices,i=r[e],s=r[t];r[e]=s,r[t]=i,n[s.key]=e,n[i.key]=t},Gc}function Fd(){if(Fc)return zc;Fc=1;var e=Dd(),t=zd();zc=function(e,n,i,s){return function(e,r,n,i){var s,o,a={},l=new t,u=function(e){var t=e.v!==s?e.v:e.w,r=a[t],i=n(e),u=o.distance+i;if(i<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+i);u<r.distance&&(r.distance=u,r.predecessor=s,l.decrease(t,u))};e.nodes().forEach((function(e){var t=e===r?0:Number.POSITIVE_INFINITY;a[e]={distance:t},l.add(e,t)}));for(;l.size()>0&&(s=l.removeMin(),(o=a[s]).distance!==Number.POSITIVE_INFINITY);)i(s).forEach(u);return a}(e,String(n),i||r,s||function(t){return e.outEdges(t)})};var r=e.constant(1);return zc}function Ud(){if(Hc)return Uc;Hc=1;var e=Fd(),t=Dd();return Uc=function(r,n,i){return t.transform(r.nodes(),(function(t,s){t[s]=e(r,s,n,i)}),{})}}function Hd(){if(Yc)return Wc;Yc=1;var e=Dd();return Wc=function(t){var r=0,n=[],i={},s=[];function o(a){var l=i[a]={onStack:!0,lowlink:r,index:r++};if(n.push(a),t.successors(a).forEach((function(t){e.has(i,t)?i[t].onStack&&(l.lowlink=Math.min(l.lowlink,i[t].index)):(o(t),l.lowlink=Math.min(l.lowlink,i[t].lowlink))})),l.lowlink===l.index){var u,c=[];do{u=n.pop(),i[u].onStack=!1,c.push(u)}while(a!==u);s.push(c)}}return t.nodes().forEach((function(t){e.has(i,t)||o(t)})),s},Wc}function Wd(){if(qc)return Xc;qc=1;var e=Dd(),t=Hd();return Xc=function(r){return e.filter(t(r),(function(e){return e.length>1||1===e.length&&r.hasEdge(e[0],e[0])}))}}function Yd(){if(Zc)return Kc;Zc=1;var e=Dd();Kc=function(e,r,n){return function(e,t,r){var n={},i=e.nodes();return i.forEach((function(e){n[e]={},n[e][e]={distance:0},i.forEach((function(t){e!==t&&(n[e][t]={distance:Number.POSITIVE_INFINITY})})),r(e).forEach((function(r){var i=r.v===e?r.w:r.v,s=t(r);n[e][i]={distance:s,predecessor:e}}))})),i.forEach((function(e){var t=n[e];i.forEach((function(r){var s=n[r];i.forEach((function(r){var n=s[e],i=t[r],o=s[r],a=n.distance+i.distance;a<o.distance&&(o.distance=a,o.predecessor=i.predecessor)}))}))})),n}(e,r||t,n||function(t){return e.outEdges(t)})};var t=e.constant(1);return Kc}function Xd(){if(Jc)return $c;Jc=1;var e=Dd();function t(t){var n={},i={},s=[];if(e.each(t.sinks(),(function o(a){if(e.has(i,a))throw new r;e.has(n,a)||(i[a]=!0,n[a]=!0,e.each(t.predecessors(a),o),delete i[a],s.push(a))})),e.size(n)!==t.nodeCount())throw new r;return s}function r(){}return $c=t,t.CycleException=r,r.prototype=new Error,$c}function qd(){if(eh)return Qc;eh=1;var e=Xd();return Qc=function(t){try{e(t)}catch(t){if(t instanceof e.CycleException)return!1;throw t}return!0}}function Kd(){if(rh)return th;rh=1;var e=Dd();function t(r,n,i,s,o,a){e.has(s,n)||(s[n]=!0,i||a.push(n),e.each(o(n),(function(e){t(r,e,i,s,o,a)})),i&&a.push(n))}return th=function(r,n,i){e.isArray(n)||(n=[n]);var s=(r.isDirected()?r.successors:r.neighbors).bind(r),o=[],a={};return e.each(n,(function(e){if(!r.hasNode(e))throw new Error("Graph does not have node: "+e);t(r,e,"post"===i,a,s,o)})),o},th}function Zd(){if(ih)return nh;ih=1;var e=Kd();return nh=function(t,r){return e(t,r,"post")}}function $d(){if(oh)return sh;oh=1;var e=Kd();return sh=function(t,r){return e(t,r,"pre")}}function Jd(){if(lh)return ah;lh=1;var e=Dd(),t=Bd(),r=zd();return ah=function(n,i){var s,o=new t,a={},l=new r;function u(e){var t=e.v===s?e.w:e.v,r=l.priority(t);if(void 0!==r){var n=i(e);n<r&&(a[t]=s,l.decrease(t,n))}}if(0===n.nodeCount())return o;e.each(n.nodes(),(function(e){l.add(e,Number.POSITIVE_INFINITY),o.setNode(e)})),l.decrease(n.nodes()[0],0);var c=!1;for(;l.size()>0;){if(s=l.removeMin(),e.has(a,s))o.setEdge(s,a[s]);else{if(c)throw new Error("Input graph is not connected: "+n);c=!0}n.nodeEdges(s).forEach(u)}return o}}ph.exports;try{fh=function(){if(dh)return hh;dh=1;var e=Md();return hh={Graph:e.Graph,json:Gd(),alg:ch?uh:(ch=1,uh={components:jd(),dijkstra:Fd(),dijkstraAll:Ud(),findCycles:Wd(),floydWarshall:Yd(),isAcyclic:qd(),postorder:Zd(),preorder:$d(),prim:Jd(),tarjan:Hd(),topsort:Xd()}),version:e.version}}()}catch(e){}fh||(fh=window.graphlib);var Qd,ef,tf,rf,nf,sf,of,af,lf,uf,cf,hf,df,ff,pf,_f,gf,yf,mf,bf,vf,xf,Ef,wf,Af,Cf,Rf,kf,Tf,Sf,Of,If,Nf,Lf,Vf,Pf,Df,Bf,Mf,Gf,jf,zf,Ff,Uf,Hf,Wf,Yf,Xf,qf,Kf,Zf,$f,Jf,Qf,ep,tp,rp,np,ip,sp,op,ap,lp,up,cp,hp,dp,fp,pp,_p,gp,yp,mp,bp,vp,xp,Ep,wp,Ap,Cp,Rp,kp,Tp,Sp,Op,Ip,Np,Lp,Vp,Pp,Dp,Bp,Mp,Gp=fh;function jp(){if(rf)return tf;rf=1;var e=Ii(),t=Qs(),r=gs(),n=Mi();return tf=function(i,s,o){if(!n(o))return!1;var a=typeof s;return!!("number"==a?t(o)&&r(s,o.length):"string"==a&&s in o)&&e(o[s],i)}}function zp(){if(hf)return cf;hf=1;var e=function(){if(uf)return lf;uf=1;var e=/\s/;return lf=function(t){for(var r=t.length;r--&&e.test(t.charAt(r)););return r}}(),t=/^\s+/;return cf=function(r){return r?r.slice(0,e(r)+1).replace(t,""):r}}function Fp(){if(_f)return pf;_f=1;var e=function(){if(ff)return df;ff=1;var e=zp(),t=Mi(),r=td(),n=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,o=parseInt;return df=function(a){if("number"==typeof a)return a;if(r(a))return NaN;if(t(a)){var l="function"==typeof a.valueOf?a.valueOf():a;a=t(l)?l+"":l}if("string"!=typeof a)return 0===a?a:+a;a=e(a);var u=i.test(a);return u||s.test(a)?o(a.slice(2),u?2:8):n.test(a)?NaN:+a}}(),t=1/0;return pf=function(r){return r?(r=e(r))===t||r===-1/0?17976931348623157e292*(r<0?-1:1):r==r?r:0:0===r?r:0}}function Up(){if(bf)return mf;bf=1;var e=Sd(),t=pd(),r=function(){if(yf)return gf;yf=1;var e=Fp();return gf=function(t){var r=e(t),n=r%1;return r==r?n?r-n:r:0}}(),n=Math.max;return mf=function(i,s,o){var a=null==i?0:i.length;if(!a)return-1;var l=null==o?0:r(o);return l<0&&(l=n(a+l,0)),e(i,t(s,3),l)}}function Hp(){if(wf)return Ef;wf=1;var e=Cd();return Ef=function(t){return(null==t?0:t.length)?e(t,1):[]}}function Wp(){if(If)return Of;If=1;var e=td();return Of=function(t,r,n){for(var i=-1,s=t.length;++i<s;){var o=t[i],a=r(o);if(null!=a&&(void 0===l?a==a&&!e(a):n(a,l)))var l=a,u=o}return u}}function Yp(){if(Bf)return Df;Bf=1;var e=$i(),t=Ii();return Df=function(r,n,i){(void 0!==i&&!t(r[n],i)||void 0===i&&!(n in r))&&e(r,n,i)}}function Xp(){if(zf)return jf;return zf=1,jf=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function qp(){if(Wf)return Hf;Wf=1;var e=Yp(),t=_h(),r=Sh(),n=gh(),i=Nh(),s=ts(),o=rs(),a=Ld(),l=_s(),u=Gi(),c=Mi(),h=function(){if(Gf)return Mf;Gf=1;var e=Bi(),t=xh(),r=es(),n=Function.prototype,i=Object.prototype,s=n.toString,o=i.hasOwnProperty,a=s.call(Object);return Mf=function(n){if(!r(n)||"[object Object]"!=e(n))return!1;var i=t(n);if(null===i)return!0;var l=o.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&s.call(l)==a}}(),d=qs(),f=Xp(),p=function(){if(Uf)return Ff;Uf=1;var e=Qi(),t=ro();return Ff=function(r){return e(r,t(r))}}();
165
+ /**
166
+ * A specialized version of `baseMerge` for arrays and objects which performs
167
+ * deep merges and tracks traversed objects enabling objects with circular
168
+ * references to be merged.
169
+ *
170
+ * @private
171
+ * @param {Object} object The destination object.
172
+ * @param {Object} source The source object.
173
+ * @param {string} key The key of the value to merge.
174
+ * @param {number} srcIndex The index of `source`.
175
+ * @param {Function} mergeFunc The function to merge values.
176
+ * @param {Function} [customizer] The function to customize assigned values.
177
+ * @param {Object} [stack] Tracks traversed source values and their merged
178
+ * counterparts.
179
+ */return Hf=function(_,g,y,m,b,v,x){var E=f(_,y),w=f(g,y),A=x.get(w);if(A)e(_,y,A);else{var C=v?v(E,w,y+"",_,g,x):void 0,R=void 0===C;if(R){var k=o(w),T=!k&&l(w),S=!k&&!T&&d(w);C=w,k||T||S?o(E)?C=E:a(E)?C=n(E):T?(R=!1,C=t(w,!0)):S?(R=!1,C=r(w,!0)):C=[]:h(w)||s(w)?(C=E,s(E)?C=p(E):c(E)&&!u(E)||(C=i(w))):R=!1}R&&(x.set(w,C),b(C,w,m,v,x),x.delete(w)),e(_,y,C)}}}function Kp(){if(Qf)return Jf;return Qf=1,Jf=function(e,t){return e<t}}function Zp(){if(up)return lp;up=1;var e=ld(),t=function(){if(ap)return op;ap=1;var e=Ji(),t=od(),r=gs(),n=Mi(),i=ad();return op=function(s,o,a,l){if(!n(s))return s;for(var u=-1,c=(o=t(o,s)).length,h=c-1,d=s;null!=d&&++u<c;){var f=i(o[u]),p=a;if("__proto__"===f||"constructor"===f||"prototype"===f)return s;if(u!=h){var _=d[f];void 0===(p=l?l(_,f,d):void 0)&&(p=n(_)?_:r(o[u+1])?[]:{})}e(d,f,p),d=d[f]}return s}}(),r=od();return lp=function(n,i,s){for(var o=-1,a=i.length,l={};++o<a;){var u=i[o],c=e(n,u);s(c,u)&&t(l,r(u,n),c)}return l}}function $p(){if(bp)return mp;bp=1;var e=function(){if(yp)return gp;yp=1;var e=Math.ceil,t=Math.max;return gp=function(r,n,i,s){for(var o=-1,a=t(e((n-r)/(i||1)),0),l=Array(a);a--;)l[s?a:++o]=r,r+=i;return l}}(),t=jp(),r=Fp();return mp=function(n){return function(i,s,o){return o&&"number"!=typeof o&&t(i,s,o)&&(s=o=void 0),i=r(i),void 0===s?(s=i,i=0):s=r(s),o=void 0===o?i<s?1:-1:r(o),e(i,s,o,n)}}}function Jp(){if(kp)return Rp;kp=1;var e=function(){if(Cp)return Ap;Cp=1;var e=td();return Ap=function(t,r){if(t!==r){var n=void 0!==t,i=null===t,s=t==t,o=e(t),a=void 0!==r,l=null===r,u=r==r,c=e(r);if(!l&&!c&&!o&&t>r||o&&a&&u&&!l&&!c||i&&a&&u||!n&&u||!s)return 1;if(!i&&!o&&!c&&t<r||c&&n&&s&&!i&&!o||l&&n&&s||!a&&s||!u)return-1}return 0}}();return Rp=function(t,r,n){for(var i=-1,s=t.criteria,o=r.criteria,a=s.length,l=n.length;++i<a;){var u=e(s[i],o[i]);if(u)return i>=l?u:u*("desc"==n[i]?-1:1)}return t.index-r.index}}function Qp(){if(Sp)return Tp;Sp=1;var e=id(),t=ld(),r=pd(),n=bd(),i=wp?Ep:(wp=1,Ep=function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}),s=ms(),o=Jp(),a=zh(),l=rs();return Tp=function(u,c,h){c=c.length?e(c,(function(e){return l(e)?function(r){return t(r,1===e.length?e[0]:e)}:e})):[a];var d=-1;c=e(c,s(r));var f=n(u,(function(t,r,n){return{criteria:e(c,(function(e){return e(t)})),index:++d,value:t}}));return i(f,(function(e,t){return o(e,t,h)}))}}try{Mp={cloneDeep:function(){if(ef)return Qd;ef=1;var e=Ph();return Qd=function(t){return e(t,5)}}(),constant:Bh(),defaults:function(){if(sf)return nf;sf=1;var e=Td(),t=Ii(),r=jp(),n=ro(),i=Object.prototype,s=i.hasOwnProperty,o=e((function(e,o){e=Object(e);var a=-1,l=o.length,u=l>2?o[2]:void 0;for(u&&r(o[0],o[1],u)&&(l=1);++a<l;)for(var c=o[a],h=n(c),d=-1,f=h.length;++d<f;){var p=h[d],_=e[p];(void 0===_||t(_,i[p])&&!s.call(e,p))&&(e[p]=c[p])}return e}));return nf=o}(),each:Hh(),filter:_d(),find:function(){if(xf)return vf;xf=1;var e=function(){if(af)return of;af=1;var e=pd(),t=Qs(),r=eo();return of=function(n){return function(i,s,o){var a=Object(i);if(!t(i)){var l=e(s,3);i=r(i),s=function(e){return l(a[e],e,a)}}var u=n(i,s,o);return u>-1?a[l?i[u]:u]:void 0}}}()(Up());return vf=e}(),flatten:Hp(),forEach:Uh(),forIn:function(){if(Cf)return Af;Cf=1;var e=Mh(),t=Fh(),r=ro();return Af=function(n,i){return null==n?n:e(n,t(i),r)}}(),has:gd(),isUndefined:md(),last:kf?Rf:(kf=1,Rf=function(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}),map:vd(),mapValues:function(){if(Sf)return Tf;Sf=1;var e=$i(),t=Gh(),r=pd();return Tf=function(n,i){var s={};return i=r(i,3),t(n,(function(t,r,n){e(s,r,i(t,r,n))})),s}}(),max:function(){if(Pf)return Vf;Pf=1;var e=Wp(),t=Lf?Nf:(Lf=1,Nf=function(e,t){return e>t}),r=zh();return Vf=function(n){return n&&n.length?e(n,r,t):void 0}}(),merge:function(){if($f)return Zf;$f=1;var e=function(){if(Xf)return Yf;Xf=1;var e=qi(),t=Yp(),r=Mh(),n=qp(),i=Mi(),s=ro(),o=Xp();return Yf=function a(l,u,c,h,d){l!==u&&r(u,(function(r,s){if(d||(d=new e),i(r))n(l,u,s,c,a,h,d);else{var f=h?h(o(l,s),r,s+"",l,u,d):void 0;void 0===f&&(f=r),t(l,s,f)}}),s)},Yf}(),t=function(){if(Kf)return qf;Kf=1;var e=Td(),t=jp();return qf=function(r){return e((function(e,n){var i=-1,s=n.length,o=s>1?n[s-1]:void 0,a=s>2?n[2]:void 0;for(o=r.length>3&&"function"==typeof o?(s--,o):void 0,a&&t(n[0],n[1],a)&&(o=s<3?void 0:o,s=1),e=Object(e);++i<s;){var l=n[i];l&&r(e,l,i,o)}return e}))}}()((function(t,r,n){e(t,r,n)}));return Zf=t}(),min:function(){if(tp)return ep;tp=1;var e=Wp(),t=Kp(),r=zh();return ep=function(n){return n&&n.length?e(n,r,t):void 0}}(),minBy:function(){if(np)return rp;np=1;var e=Wp(),t=pd(),r=Kp();return rp=function(n,i){return n&&n.length?e(n,t(i,2),r):void 0}}(),now:function(){if(sp)return ip;sp=1;var e=Pi();return ip=function(){return e.Date.now()}}(),pick:function(){if(_p)return pp;_p=1;var e=function(){if(hp)return cp;hp=1;var e=Zp(),t=cd();return cp=function(r,n){return e(r,n,(function(e,n){return t(r,n)}))}}(),t=function(){if(fp)return dp;fp=1;var e=Hp(),t=Rd(),r=kd();
180
+ /**
181
+ * A specialized version of `baseRest` which flattens the rest array.
182
+ *
183
+ * @private
184
+ * @param {Function} func The function to apply a rest parameter to.
185
+ * @returns {Function} Returns the new function.
186
+ */return dp=function(n){return r(t(n,void 0,e),n+"")}}()((function(t,r){return null==t?{}:e(t,r)}));return pp=t}(),range:function(){if(xp)return vp;xp=1;var e=$p()();return vp=e}(),reduce:xd(),sortBy:function(){if(Ip)return Op;Ip=1;var e=Cd(),t=Qp(),r=Td(),n=jp(),i=r((function(r,i){if(null==r)return[];var s=i.length;return s>1&&n(r,i[0],i[1])?i=[]:s>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(r,e(i,1),[])}));return Op=i}(),uniqueId:function(){if(Lp)return Np;Lp=1;var e=sd(),t=0;return Np=function(r){var n=++t;return e(r)+n},Np}(),values:Pd(),zipObject:function(){if(Bp)return Dp;Bp=1;var e=Ji(),t=Pp?Vp:(Pp=1,Vp=function(e,t,r){for(var n=-1,i=e.length,s=t.length,o={};++n<i;){var a=n<s?t[n]:void 0;r(o,e[n],a)}return o});return Dp=function(r,n){return t(r||[],n||[],e)}}()}}catch(e){}Mp||(Mp=window._);var e_=Mp,t_=r_;function r_(){var e={};e._next=e._prev=e,this._sentinel=e}function n_(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function i_(e,t){if("_next"!==e&&"_prev"!==e)return t}r_.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return n_(t),t},r_.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&n_(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t},r_.prototype.toString=function(){for(var e=[],t=this._sentinel,r=t._prev;r!==t;)e.push(JSON.stringify(r,i_)),r=r._prev;return"["+e.join(", ")+"]"};var s_=e_,o_=Gp.Graph,a_=t_,l_=function(e,t){if(e.nodeCount()<=1)return[];var r=function(e,t){var r=new o_,n=0,i=0;s_.forEach(e.nodes(),(function(e){r.setNode(e,{v:e,in:0,out:0})})),s_.forEach(e.edges(),(function(e){var s=r.edge(e.v,e.w)||0,o=t(e),a=s+o;r.setEdge(e.v,e.w,a),i=Math.max(i,r.node(e.v).out+=o),n=Math.max(n,r.node(e.w).in+=o)}));var s=s_.range(i+n+3).map((function(){return new a_})),o=n+1;return s_.forEach(r.nodes(),(function(e){h_(s,o,r.node(e))})),{graph:r,buckets:s,zeroIdx:o}}(e,t||u_),n=function(e,t,r){var n,i=[],s=t[t.length-1],o=t[0];for(;e.nodeCount();){for(;n=o.dequeue();)c_(e,t,r,n);for(;n=s.dequeue();)c_(e,t,r,n);if(e.nodeCount())for(var a=t.length-2;a>0;--a)if(n=t[a].dequeue()){i=i.concat(c_(e,t,r,n,!0));break}}return i}(r.graph,r.buckets,r.zeroIdx);return s_.flatten(s_.map(n,(function(t){return e.outEdges(t.v,t.w)})),!0)},u_=s_.constant(1);function c_(e,t,r,n,i){var s=i?[]:void 0;return s_.forEach(e.inEdges(n.v),(function(n){var o=e.edge(n),a=e.node(n.v);i&&s.push({v:n.v,w:n.w}),a.out-=o,h_(t,r,a)})),s_.forEach(e.outEdges(n.v),(function(n){var i=e.edge(n),s=n.w,o=e.node(s);o.in-=i,h_(t,r,o)})),e.removeNode(n.v),s}function h_(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}var d_=e_,f_=l_,p_={run:function(e){var t="greedy"===e.graph().acyclicer?f_(e,function(e){return function(t){return e.edge(t).weight}}(e)):function(e){var t=[],r={},n={};function i(s){d_.has(n,s)||(n[s]=!0,r[s]=!0,d_.forEach(e.outEdges(s),(function(e){d_.has(r,e.w)?t.push(e):i(e.w)})),delete r[s])}return d_.forEach(e.nodes(),i),t}(e);d_.forEach(t,(function(t){var r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,d_.uniqueId("rev"))}))},undo:function(e){d_.forEach(e.edges(),(function(t){var r=e.edge(t);if(r.reversed){e.removeEdge(t);var n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}}))}};var __=e_,g_=Gp.Graph,y_={addDummyNode:m_,simplify:function(e){var t=(new g_).setGraph(e.graph());return __.forEach(e.nodes(),(function(r){t.setNode(r,e.node(r))})),__.forEach(e.edges(),(function(r){var n=t.edge(r.v,r.w)||{weight:0,minlen:1},i=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+i.weight,minlen:Math.max(n.minlen,i.minlen)})})),t},asNonCompoundGraph:function(e){var t=new g_({multigraph:e.isMultigraph()}).setGraph(e.graph());return __.forEach(e.nodes(),(function(r){e.children(r).length||t.setNode(r,e.node(r))})),__.forEach(e.edges(),(function(r){t.setEdge(r,e.edge(r))})),t},successorWeights:function(e){var t=__.map(e.nodes(),(function(t){var r={};return __.forEach(e.outEdges(t),(function(t){r[t.w]=(r[t.w]||0)+e.edge(t).weight})),r}));return __.zipObject(e.nodes(),t)},predecessorWeights:function(e){var t=__.map(e.nodes(),(function(t){var r={};return __.forEach(e.inEdges(t),(function(t){r[t.v]=(r[t.v]||0)+e.edge(t).weight})),r}));return __.zipObject(e.nodes(),t)},intersectRect:function(e,t){var r,n,i=e.x,s=e.y,o=t.x-i,a=t.y-s,l=e.width/2,u=e.height/2;if(!o&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*l>Math.abs(o)*u?(a<0&&(u=-u),r=u*o/a,n=u):(o<0&&(l=-l),r=l,n=l*a/o);return{x:i+r,y:s+n}},buildLayerMatrix:function(e){var t=__.map(__.range(b_(e)+1),(function(){return[]}));return __.forEach(e.nodes(),(function(r){var n=e.node(r),i=n.rank;__.isUndefined(i)||(t[i][n.order]=r)})),t},normalizeRanks:function(e){var t=__.min(__.map(e.nodes(),(function(t){return e.node(t).rank})));__.forEach(e.nodes(),(function(r){var n=e.node(r);__.has(n,"rank")&&(n.rank-=t)}))},removeEmptyRanks:function(e){var t=__.min(__.map(e.nodes(),(function(t){return e.node(t).rank}))),r=[];__.forEach(e.nodes(),(function(n){var i=e.node(n).rank-t;r[i]||(r[i]=[]),r[i].push(n)}));var n=0,i=e.graph().nodeRankFactor;__.forEach(r,(function(t,r){__.isUndefined(t)&&r%i!=0?--n:n&&__.forEach(t,(function(t){e.node(t).rank+=n}))}))},addBorderNode:function(e,t,r,n){var i={width:0,height:0};arguments.length>=4&&(i.rank=r,i.order=n);return m_(e,"border",i,t)},maxRank:b_,partition:function(e,t){var r={lhs:[],rhs:[]};return __.forEach(e,(function(e){t(e)?r.lhs.push(e):r.rhs.push(e)})),r},time:function(e,t){var r=__.now();try{return t()}finally{console.log(e+" time: "+(__.now()-r)+"ms")}},notime:function(e,t){return t()}};function m_(e,t,r,n){var i;do{i=__.uniqueId(n)}while(e.hasNode(i));return r.dummy=t,e.setNode(i,r),i}function b_(e){return __.max(__.map(e.nodes(),(function(t){var r=e.node(t).rank;if(!__.isUndefined(r))return r})))}var v_=e_,x_=y_,E_={run:function(e){e.graph().dummyChains=[],v_.forEach(e.edges(),(function(t){!function(e,t){var r,n,i,s=t.v,o=e.node(s).rank,a=t.w,l=e.node(a).rank,u=t.name,c=e.edge(t),h=c.labelRank;if(l===o+1)return;for(e.removeEdge(t),i=0,++o;o<l;++i,++o)c.points=[],n={width:0,height:0,edgeLabel:c,edgeObj:t,rank:o},r=x_.addDummyNode(e,"edge",n,"_d"),o===h&&(n.width=c.width,n.height=c.height,n.dummy="edge-label",n.labelpos=c.labelpos),e.setEdge(s,r,{weight:c.weight},u),0===i&&e.graph().dummyChains.push(r),s=r;e.setEdge(s,a,{weight:c.weight},u)}(e,t)}))},undo:function(e){v_.forEach(e.graph().dummyChains,(function(t){var r,n=e.node(t),i=n.edgeLabel;for(e.setEdge(n.edgeObj,i);n.dummy;)r=e.successors(t)[0],e.removeNode(t),i.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height),t=r,n=e.node(t)}))}};var w_=e_,A_={longestPath:function(e){var t={};w_.forEach(e.sources(),(function r(n){var i=e.node(n);if(w_.has(t,n))return i.rank;t[n]=!0;var s=w_.min(w_.map(e.outEdges(n),(function(t){return r(t.w)-e.edge(t).minlen})));return s!==Number.POSITIVE_INFINITY&&null!=s||(s=0),i.rank=s}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var C_=e_,R_=Gp.Graph,k_=A_.slack,T_=function(e){var t,r,n=new R_({directed:!1}),i=e.nodes()[0],s=e.nodeCount();n.setNode(i,{});for(;S_(n,e)<s;)t=O_(n,e),r=n.hasNode(t.v)?k_(e,t):-k_(e,t),I_(n,e,r);return n};function S_(e,t){return C_.forEach(e.nodes(),(function r(n){C_.forEach(t.nodeEdges(n),(function(i){var s=i.v,o=n===s?i.w:s;e.hasNode(o)||k_(t,i)||(e.setNode(o,{}),e.setEdge(n,o,{}),r(o))}))})),e.nodeCount()}function O_(e,t){return C_.minBy(t.edges(),(function(r){if(e.hasNode(r.v)!==e.hasNode(r.w))return k_(t,r)}))}function I_(e,t,r){C_.forEach(e.nodes(),(function(e){t.node(e).rank+=r}))}var N_=e_,L_=T_,V_=A_.slack,P_=A_.longestPath,D_=Gp.alg.preorder,B_=Gp.alg.postorder,M_=y_.simplify,G_=j_;function j_(e){e=M_(e),P_(e);var t,r=L_(e);for(U_(r),z_(r,e);t=W_(r);)X_(r,e,t,Y_(r,e,t))}function z_(e,t){var r=B_(e,e.nodes());r=r.slice(0,r.length-1),N_.forEach(r,(function(r){!function(e,t,r){var n=e.node(r),i=n.parent;e.edge(r,i).cutvalue=F_(e,t,r)}(e,t,r)}))}function F_(e,t,r){var n=e.node(r).parent,i=!0,s=t.edge(r,n),o=0;return s||(i=!1,s=t.edge(n,r)),o=s.weight,N_.forEach(t.nodeEdges(r),(function(s){var a,l,u=s.v===r,c=u?s.w:s.v;if(c!==n){var h=u===i,d=t.edge(s).weight;if(o+=h?d:-d,a=r,l=c,e.hasEdge(a,l)){var f=e.edge(r,c).cutvalue;o+=h?-f:f}}})),o}function U_(e,t){arguments.length<2&&(t=e.nodes()[0]),H_(e,{},1,t)}function H_(e,t,r,n,i){var s=r,o=e.node(n);return t[n]=!0,N_.forEach(e.neighbors(n),(function(i){N_.has(t,i)||(r=H_(e,t,r,i,n))})),o.low=s,o.lim=r++,i?o.parent=i:delete o.parent,r}function W_(e){return N_.find(e.edges(),(function(t){return e.edge(t).cutvalue<0}))}function Y_(e,t,r){var n=r.v,i=r.w;t.hasEdge(n,i)||(n=r.w,i=r.v);var s=e.node(n),o=e.node(i),a=s,l=!1;s.lim>o.lim&&(a=o,l=!0);var u=N_.filter(t.edges(),(function(t){return l===q_(e,e.node(t.v),a)&&l!==q_(e,e.node(t.w),a)}));return N_.minBy(u,(function(e){return V_(t,e)}))}function X_(e,t,r,n){var i=r.v,s=r.w;e.removeEdge(i,s),e.setEdge(n.v,n.w,{}),U_(e),z_(e,t),function(e,t){var r=N_.find(e.nodes(),(function(e){return!t.node(e).parent})),n=D_(e,r);n=n.slice(1),N_.forEach(n,(function(r){var n=e.node(r).parent,i=t.edge(r,n),s=!1;i||(i=t.edge(n,r),s=!0),t.node(r).rank=t.node(n).rank+(s?i.minlen:-i.minlen)}))}(e,t)}function q_(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}j_.initLowLimValues=U_,j_.initCutValues=z_,j_.calcCutValue=F_,j_.leaveEdge=W_,j_.enterEdge=Y_,j_.exchangeEdges=X_;var K_=A_.longestPath,Z_=T_,$_=G_,J_=function(e){switch(e.graph().ranker){case"network-simplex":default:eg(e);break;case"tight-tree":!function(e){K_(e),Z_(e)}(e);break;case"longest-path":Q_(e)}};var Q_=K_;function eg(e){$_(e)}var tg=e_,rg=function(e){var t=function(e){var t={},r=0;function n(i){var s=r;tg.forEach(e.children(i),n),t[i]={low:s,lim:r++}}return tg.forEach(e.children(),n),t}(e);tg.forEach(e.graph().dummyChains,(function(r){for(var n=e.node(r),i=n.edgeObj,s=function(e,t,r,n){var i,s,o=[],a=[],l=Math.min(t[r].low,t[n].low),u=Math.max(t[r].lim,t[n].lim);i=r;do{i=e.parent(i),o.push(i)}while(i&&(t[i].low>l||u>t[i].lim));s=i,i=n;for(;(i=e.parent(i))!==s;)a.push(i);return{path:o.concat(a.reverse()),lca:s}}(e,t,i.v,i.w),o=s.path,a=s.lca,l=0,u=o[l],c=!0;r!==i.w;){if(n=e.node(r),c){for(;(u=o[l])!==a&&e.node(u).maxRank<n.rank;)l++;u===a&&(c=!1)}if(!c){for(;l<o.length-1&&e.node(u=o[l+1]).minRank<=n.rank;)l++;u=o[l]}e.setParent(r,u),r=e.successors(r)[0]}}))};var ng=e_,ig=y_,sg={run:function(e){var t=ig.addDummyNode(e,"root",{},"_root"),r=function(e){var t={};function r(n,i){var s=e.children(n);s&&s.length&&ng.forEach(s,(function(e){r(e,i+1)})),t[n]=i}return ng.forEach(e.children(),(function(e){r(e,1)})),t}(e),n=ng.max(ng.values(r))-1,i=2*n+1;e.graph().nestingRoot=t,ng.forEach(e.edges(),(function(t){e.edge(t).minlen*=i}));var s=function(e){return ng.reduce(e.edges(),(function(t,r){return t+e.edge(r).weight}),0)}(e)+1;ng.forEach(e.children(),(function(o){og(e,t,i,s,n,r,o)})),e.graph().nodeRankFactor=i},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,ng.forEach(e.edges(),(function(t){e.edge(t).nestingEdge&&e.removeEdge(t)}))}};function og(e,t,r,n,i,s,o){var a=e.children(o);if(a.length){var l=ig.addBorderNode(e,"_bt"),u=ig.addBorderNode(e,"_bb"),c=e.node(o);e.setParent(l,o),c.borderTop=l,e.setParent(u,o),c.borderBottom=u,ng.forEach(a,(function(a){og(e,t,r,n,i,s,a);var c=e.node(a),h=c.borderTop?c.borderTop:a,d=c.borderBottom?c.borderBottom:a,f=c.borderTop?n:2*n,p=h!==d?1:i-s[o]+1;e.setEdge(l,h,{weight:f,minlen:p,nestingEdge:!0}),e.setEdge(d,u,{weight:f,minlen:p,nestingEdge:!0})})),e.parent(o)||e.setEdge(t,l,{weight:0,minlen:i+s[o]})}else o!==t&&e.setEdge(t,o,{weight:0,minlen:r})}var ag=e_,lg=y_,ug=function(e){ag.forEach(e.children(),(function t(r){var n=e.children(r),i=e.node(r);if(n.length&&ag.forEach(n,t),ag.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var s=i.minRank,o=i.maxRank+1;s<o;++s)cg(e,"borderLeft","_bl",r,i,s),cg(e,"borderRight","_br",r,i,s)}}))};function cg(e,t,r,n,i,s){var o={width:0,height:0,rank:s,borderType:t},a=i[t][s-1],l=lg.addDummyNode(e,"border",o,r);i[t][s]=l,e.setParent(l,n),a&&e.setEdge(a,l,{weight:1})}var hg=e_,dg={adjust:function(e){var t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||fg(e)},undo:function(e){var t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){hg.forEach(e.nodes(),(function(t){_g(e.node(t))})),hg.forEach(e.edges(),(function(t){var r=e.edge(t);hg.forEach(r.points,_g),hg.has(r,"y")&&_g(r)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){hg.forEach(e.nodes(),(function(t){gg(e.node(t))})),hg.forEach(e.edges(),(function(t){var r=e.edge(t);hg.forEach(r.points,gg),hg.has(r,"x")&&gg(r)}))}(e),fg(e))}};function fg(e){hg.forEach(e.nodes(),(function(t){pg(e.node(t))})),hg.forEach(e.edges(),(function(t){pg(e.edge(t))}))}function pg(e){var t=e.width;e.width=e.height,e.height=t}function _g(e){e.y=-e.y}function gg(e){var t=e.x;e.x=e.y,e.y=t}var yg=e_,mg=function(e){var t={},r=yg.filter(e.nodes(),(function(t){return!e.children(t).length})),n=yg.max(yg.map(r,(function(t){return e.node(t).rank}))),i=yg.map(yg.range(n+1),(function(){return[]}));function s(r){if(!yg.has(t,r)){t[r]=!0;var n=e.node(r);i[n.rank].push(r),yg.forEach(e.successors(r),s)}}var o=yg.sortBy(r,(function(t){return e.node(t).rank}));return yg.forEach(o,s),i};var bg=e_,vg=function(e,t){for(var r=0,n=1;n<t.length;++n)r+=xg(e,t[n-1],t[n]);return r};function xg(e,t,r){for(var n=bg.zipObject(r,bg.map(r,(function(e,t){return t}))),i=bg.flatten(bg.map(t,(function(t){return bg.sortBy(bg.map(e.outEdges(t),(function(t){return{pos:n[t.w],weight:e.edge(t).weight}})),"pos")})),!0),s=1;s<r.length;)s<<=1;var o=2*s-1;s-=1;var a=bg.map(new Array(o),(function(){return 0})),l=0;return bg.forEach(i.forEach((function(e){var t=e.pos+s;a[t]+=e.weight;for(var r=0;t>0;)t%2&&(r+=a[t+1]),a[t=t-1>>1]+=e.weight;l+=e.weight*r}))),l}var Eg=e_;var wg=e_;var Ag=e_,Cg=y_;function Rg(e,t,r){for(var n;t.length&&(n=Ag.last(t)).i<=r;)t.pop(),e.push(n.vs),r++;return r}var kg=e_,Tg=function(e,t){return Eg.map(t,(function(t){var r=e.inEdges(t);if(r.length){var n=Eg.reduce(r,(function(t,r){var n=e.edge(r),i=e.node(r.v);return{sum:t.sum+n.weight*i.order,weight:t.weight+n.weight}}),{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}return{v:t}}))},Sg=function(e,t){var r={};return wg.forEach(e,(function(e,t){var n=r[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};wg.isUndefined(e.barycenter)||(n.barycenter=e.barycenter,n.weight=e.weight)})),wg.forEach(t.edges(),(function(e){var t=r[e.v],n=r[e.w];wg.isUndefined(t)||wg.isUndefined(n)||(n.indegree++,t.out.push(r[e.w]))})),function(e){var t=[];function r(e){return function(t){t.merged||(wg.isUndefined(t.barycenter)||wg.isUndefined(e.barycenter)||t.barycenter>=e.barycenter)&&function(e,t){var r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight);t.weight&&(r+=t.barycenter*t.weight,n+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function n(t){return function(r){r.in.push(t),0==--r.indegree&&e.push(r)}}for(;e.length;){var i=e.pop();t.push(i),wg.forEach(i.in.reverse(),r(i)),wg.forEach(i.out,n(i))}return wg.map(wg.filter(t,(function(e){return!e.merged})),(function(e){return wg.pick(e,["vs","i","barycenter","weight"])}))}(wg.filter(r,(function(e){return!e.indegree})))},Og=function(e,t){var r=Cg.partition(e,(function(e){return Ag.has(e,"barycenter")})),n=r.lhs,i=Ag.sortBy(r.rhs,(function(e){return-e.i})),s=[],o=0,a=0,l=0;n.sort((u=!!t,function(e,t){return e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:u?t.i-e.i:e.i-t.i})),l=Rg(s,i,l),Ag.forEach(n,(function(e){l+=e.vs.length,s.push(e.vs),o+=e.barycenter*e.weight,a+=e.weight,l=Rg(s,i,l)}));var u;var c={vs:Ag.flatten(s,!0)};a&&(c.barycenter=o/a,c.weight=a);return c},Ig=function e(t,r,n,i){var s=t.children(r),o=t.node(r),a=o?o.borderLeft:void 0,l=o?o.borderRight:void 0,u={};a&&(s=kg.filter(s,(function(e){return e!==a&&e!==l})));var c=Tg(t,s);kg.forEach(c,(function(r){if(t.children(r.v).length){var s=e(t,r.v,n,i);u[r.v]=s,kg.has(s,"barycenter")&&(o=r,a=s,kg.isUndefined(o.barycenter)?(o.barycenter=a.barycenter,o.weight=a.weight):(o.barycenter=(o.barycenter*o.weight+a.barycenter*a.weight)/(o.weight+a.weight),o.weight+=a.weight))}var o,a}));var h=Sg(c,n);!function(e,t){kg.forEach(e,(function(e){e.vs=kg.flatten(e.vs.map((function(e){return t[e]?t[e].vs:e})),!0)}))}(h,u);var d=Og(h,i);if(a&&(d.vs=kg.flatten([a,d.vs,l],!0),t.predecessors(a).length)){var f=t.node(t.predecessors(a)[0]),p=t.node(t.predecessors(l)[0]);kg.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+p.order)/(d.weight+2),d.weight+=2}return d};var Ng=e_,Lg=Gp.Graph,Vg=function(e,t,r){var n=function(e){var t;for(;e.hasNode(t=Ng.uniqueId("_root")););return t}(e),i=new Lg({compound:!0}).setGraph({root:n}).setDefaultNodeLabel((function(t){return e.node(t)}));return Ng.forEach(e.nodes(),(function(s){var o=e.node(s),a=e.parent(s);(o.rank===t||o.minRank<=t&&t<=o.maxRank)&&(i.setNode(s),i.setParent(s,a||n),Ng.forEach(e[r](s),(function(t){var r=t.v===s?t.w:t.v,n=i.edge(r,s),o=Ng.isUndefined(n)?0:n.weight;i.setEdge(r,s,{weight:e.edge(t).weight+o})})),Ng.has(o,"minRank")&&i.setNode(s,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]}))})),i};var Pg=e_;var Dg=e_,Bg=mg,Mg=vg,Gg=Ig,jg=Vg,zg=function(e,t,r){var n,i={};Pg.forEach(r,(function(r){for(var s,o,a=e.parent(r);a;){if((s=e.parent(a))?(o=i[s],i[s]=a):(o=n,n=a),o&&o!==a)return void t.setEdge(o,a);a=s}}))},Fg=Gp.Graph,Ug=y_,Hg=function(e){var t=Ug.maxRank(e),r=Wg(e,Dg.range(1,t+1),"inEdges"),n=Wg(e,Dg.range(t-1,-1,-1),"outEdges"),i=Bg(e);Xg(e,i);for(var s,o=Number.POSITIVE_INFINITY,a=0,l=0;l<4;++a,++l){Yg(a%2?r:n,a%4>=2),i=Ug.buildLayerMatrix(e);var u=Mg(e,i);u<o&&(l=0,s=Dg.cloneDeep(i),o=u)}Xg(e,s)};function Wg(e,t,r){return Dg.map(t,(function(t){return jg(e,t,r)}))}function Yg(e,t){var r=new Fg;Dg.forEach(e,(function(e){var n=e.graph().root,i=Gg(e,n,r,t);Dg.forEach(i.vs,(function(t,r){e.node(t).order=r})),zg(e,r,i.vs)}))}function Xg(e,t){Dg.forEach(t,(function(t){Dg.forEach(t,(function(t,r){e.node(t).order=r}))}))}var qg=e_,Kg=Gp.Graph,Zg=y_,$g=function(e){var t,r=Zg.buildLayerMatrix(e),n=qg.merge(Jg(e,r),Qg(e,r)),i={};qg.forEach(["u","d"],(function(s){t="u"===s?r:qg.values(r).reverse(),qg.forEach(["l","r"],(function(r){"r"===r&&(t=qg.map(t,(function(e){return qg.values(e).reverse()})));var o=("u"===s?e.predecessors:e.successors).bind(e),a=ry(e,t,n,o),l=ny(e,t,a.root,a.align,"r"===r);"r"===r&&(l=qg.mapValues(l,(function(e){return-e}))),i[s+r]=l}))}));var s=iy(e,i);return sy(i,s),oy(i,e.graph().align)};function Jg(e,t){var r={};return qg.reduce(t,(function(t,n){var i=0,s=0,o=t.length,a=qg.last(n);return qg.forEach(n,(function(t,l){var u=function(e,t){if(e.node(t).dummy)return qg.find(e.predecessors(t),(function(t){return e.node(t).dummy}))}(e,t),c=u?e.node(u).order:o;(u||t===a)&&(qg.forEach(n.slice(s,l+1),(function(t){qg.forEach(e.predecessors(t),(function(n){var s=e.node(n),o=s.order;!(o<i||c<o)||s.dummy&&e.node(t).dummy||ey(r,n,t)}))})),s=l+1,i=c)})),n})),r}function Qg(e,t){var r={};function n(t,n,i,s,o){var a;qg.forEach(qg.range(n,i),(function(n){a=t[n],e.node(a).dummy&&qg.forEach(e.predecessors(a),(function(t){var n=e.node(t);n.dummy&&(n.order<s||n.order>o)&&ey(r,t,a)}))}))}return qg.reduce(t,(function(t,r){var i,s=-1,o=0;return qg.forEach(r,(function(a,l){if("border"===e.node(a).dummy){var u=e.predecessors(a);u.length&&(i=e.node(u[0]).order,n(r,o,l,s,i),o=l,s=i)}n(r,o,r.length,i,t.length)})),r})),r}function ey(e,t,r){if(t>r){var n=t;t=r,r=n}var i=e[t];i||(e[t]=i={}),i[r]=!0}function ty(e,t,r){if(t>r){var n=t;t=r,r=n}return qg.has(e[t],r)}function ry(e,t,r,n){var i={},s={},o={};return qg.forEach(t,(function(e){qg.forEach(e,(function(e,t){i[e]=e,s[e]=e,o[e]=t}))})),qg.forEach(t,(function(e){var t=-1;qg.forEach(e,(function(e){var a=n(e);if(a.length){a=qg.sortBy(a,(function(e){return o[e]}));for(var l=(a.length-1)/2,u=Math.floor(l),c=Math.ceil(l);u<=c;++u){var h=a[u];s[e]===e&&t<o[h]&&!ty(r,e,h)&&(s[h]=e,s[e]=i[e]=i[h],t=o[h])}}}))})),{root:i,align:s}}function ny(e,t,r,n,i){var s={},o=function(e,t,r,n){var i=new Kg,s=e.graph(),o=function(e,t,r){return function(n,i,s){var o,a=n.node(i),l=n.node(s),u=0;if(u+=a.width/2,qg.has(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":o=-a.width/2;break;case"r":o=a.width/2}if(o&&(u+=r?o:-o),o=0,u+=(a.dummy?t:e)/2,u+=(l.dummy?t:e)/2,u+=l.width/2,qg.has(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":o=l.width/2;break;case"r":o=-l.width/2}return o&&(u+=r?o:-o),o=0,u}}(s.nodesep,s.edgesep,n);return qg.forEach(t,(function(t){var n;qg.forEach(t,(function(t){var s=r[t];if(i.setNode(s),n){var a=r[n],l=i.edge(a,s);i.setEdge(a,s,Math.max(o(e,t,n),l||0))}n=t}))})),i}(e,t,r,i),a=i?"borderLeft":"borderRight";function l(e,t){for(var r=o.nodes(),n=r.pop(),i={};n;)i[n]?e(n):(i[n]=!0,r.push(n),r=r.concat(t(n))),n=r.pop()}return l((function(e){s[e]=o.inEdges(e).reduce((function(e,t){return Math.max(e,s[t.v]+o.edge(t))}),0)}),o.predecessors.bind(o)),l((function(t){var r=o.outEdges(t).reduce((function(e,t){return Math.min(e,s[t.w]-o.edge(t))}),Number.POSITIVE_INFINITY),n=e.node(t);r!==Number.POSITIVE_INFINITY&&n.borderType!==a&&(s[t]=Math.max(s[t],r))}),o.successors.bind(o)),qg.forEach(n,(function(e){s[e]=s[r[e]]})),s}function iy(e,t){return qg.minBy(qg.values(t),(function(t){var r=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY;return qg.forIn(t,(function(t,i){var s=function(e,t){return e.node(t).width}(e,i)/2;r=Math.max(t+s,r),n=Math.min(t-s,n)})),r-n}))}function sy(e,t){var r=qg.values(t),n=qg.min(r),i=qg.max(r);qg.forEach(["u","d"],(function(r){qg.forEach(["l","r"],(function(s){var o,a=r+s,l=e[a];if(l!==t){var u=qg.values(l);(o="l"===s?n-qg.min(u):i-qg.max(u))&&(e[a]=qg.mapValues(l,(function(e){return e+o})))}}))}))}function oy(e,t){return qg.mapValues(e.ul,(function(r,n){if(t)return e[t.toLowerCase()][n];var i=qg.sortBy(qg.map(e,n));return(i[1]+i[2])/2}))}var ay=e_,ly=y_,uy=$g;var cy=e_,hy=p_,dy=E_,fy=J_,py=y_.normalizeRanks,_y=rg,gy=y_.removeEmptyRanks,yy=sg,my=ug,by=dg,vy=Hg,xy=function(e){(function(e){var t=ly.buildLayerMatrix(e),r=e.graph().ranksep,n=0;ay.forEach(t,(function(t){var i=ay.max(ay.map(t,(function(t){return e.node(t).height})));ay.forEach(t,(function(t){e.node(t).y=n+i/2})),n+=i+r}))})(e=ly.asNonCompoundGraph(e)),ay.forEach(uy(e),(function(t,r){e.node(r).x=t}))},Ey=y_,wy=Gp.Graph,Ay=function(e,t){var r=t&&t.debugTiming?Ey.time:Ey.notime;r("layout",(function(){var t=r(" buildLayoutGraph",(function(){return function(e){var t=new wy({multigraph:!0,compound:!0}),r=Vy(e.graph());return t.setGraph(cy.merge({},Ry,Ly(r,Cy),cy.pick(r,ky))),cy.forEach(e.nodes(),(function(r){var n=Vy(e.node(r));t.setNode(r,cy.defaults(Ly(n,Ty),Sy)),t.setParent(r,e.parent(r))})),cy.forEach(e.edges(),(function(r){var n=Vy(e.edge(r));t.setEdge(r,cy.merge({},Iy,Ly(n,Oy),cy.pick(n,Ny)))})),t}(e)}));r(" runLayout",(function(){!function(e,t){t(" makeSpaceForEdgeLabels",(function(){!function(e){var t=e.graph();t.ranksep/=2,cy.forEach(e.edges(),(function(r){var n=e.edge(r);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}(e)})),t(" removeSelfEdges",(function(){!function(e){cy.forEach(e.edges(),(function(t){if(t.v===t.w){var r=e.node(t.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e)})),t(" acyclic",(function(){hy.run(e)})),t(" nestingGraph.run",(function(){yy.run(e)})),t(" rank",(function(){fy(Ey.asNonCompoundGraph(e))})),t(" injectEdgeLabelProxies",(function(){!function(e){cy.forEach(e.edges(),(function(t){var r=e.edge(t);if(r.width&&r.height){var n=e.node(t.v),i={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};Ey.addDummyNode(e,"edge-proxy",i,"_ep")}}))}(e)})),t(" removeEmptyRanks",(function(){gy(e)})),t(" nestingGraph.cleanup",(function(){yy.cleanup(e)})),t(" normalizeRanks",(function(){py(e)})),t(" assignRankMinMax",(function(){!function(e){var t=0;cy.forEach(e.nodes(),(function(r){var n=e.node(r);n.borderTop&&(n.minRank=e.node(n.borderTop).rank,n.maxRank=e.node(n.borderBottom).rank,t=cy.max(t,n.maxRank))})),e.graph().maxRank=t}(e)})),t(" removeEdgeLabelProxies",(function(){!function(e){cy.forEach(e.nodes(),(function(t){var r=e.node(t);"edge-proxy"===r.dummy&&(e.edge(r.e).labelRank=r.rank,e.removeNode(t))}))}(e)})),t(" normalize.run",(function(){dy.run(e)})),t(" parentDummyChains",(function(){_y(e)})),t(" addBorderSegments",(function(){my(e)})),t(" order",(function(){vy(e)})),t(" insertSelfEdges",(function(){!function(e){var t=Ey.buildLayerMatrix(e);cy.forEach(t,(function(t){var r=0;cy.forEach(t,(function(t,n){var i=e.node(t);i.order=n+r,cy.forEach(i.selfEdges,(function(t){Ey.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:i.rank,order:n+ ++r,e:t.e,label:t.label},"_se")})),delete i.selfEdges}))}))}(e)})),t(" adjustCoordinateSystem",(function(){by.adjust(e)})),t(" position",(function(){xy(e)})),t(" positionSelfEdges",(function(){!function(e){cy.forEach(e.nodes(),(function(t){var r=e.node(t);if("selfedge"===r.dummy){var n=e.node(r.e.v),i=n.x+n.width/2,s=n.y,o=r.x-i,a=n.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*o/3,y:s-a},{x:i+5*o/6,y:s-a},{x:i+o,y:s},{x:i+5*o/6,y:s+a},{x:i+2*o/3,y:s+a}],r.label.x=r.x,r.label.y=r.y}}))}(e)})),t(" removeBorderNodes",(function(){!function(e){cy.forEach(e.nodes(),(function(t){if(e.children(t).length){var r=e.node(t),n=e.node(r.borderTop),i=e.node(r.borderBottom),s=e.node(cy.last(r.borderLeft)),o=e.node(cy.last(r.borderRight));r.width=Math.abs(o.x-s.x),r.height=Math.abs(i.y-n.y),r.x=s.x+r.width/2,r.y=n.y+r.height/2}})),cy.forEach(e.nodes(),(function(t){"border"===e.node(t).dummy&&e.removeNode(t)}))}(e)})),t(" normalize.undo",(function(){dy.undo(e)})),t(" fixupEdgeLabelCoords",(function(){!function(e){cy.forEach(e.edges(),(function(t){var r=e.edge(t);if(cy.has(r,"x"))switch("l"!==r.labelpos&&"r"!==r.labelpos||(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}}))}(e)})),t(" undoCoordinateSystem",(function(){by.undo(e)})),t(" translateGraph",(function(){!function(e){var t=Number.POSITIVE_INFINITY,r=0,n=Number.POSITIVE_INFINITY,i=0,s=e.graph(),o=s.marginx||0,a=s.marginy||0;function l(e){var s=e.x,o=e.y,a=e.width,l=e.height;t=Math.min(t,s-a/2),r=Math.max(r,s+a/2),n=Math.min(n,o-l/2),i=Math.max(i,o+l/2)}cy.forEach(e.nodes(),(function(t){l(e.node(t))})),cy.forEach(e.edges(),(function(t){var r=e.edge(t);cy.has(r,"x")&&l(r)})),t-=o,n-=a,cy.forEach(e.nodes(),(function(r){var i=e.node(r);i.x-=t,i.y-=n})),cy.forEach(e.edges(),(function(r){var i=e.edge(r);cy.forEach(i.points,(function(e){e.x-=t,e.y-=n})),cy.has(i,"x")&&(i.x-=t),cy.has(i,"y")&&(i.y-=n)})),s.width=r-t+o,s.height=i-n+a}(e)})),t(" assignNodeIntersects",(function(){!function(e){cy.forEach(e.edges(),(function(t){var r,n,i=e.edge(t),s=e.node(t.v),o=e.node(t.w);i.points?(r=i.points[0],n=i.points[i.points.length-1]):(i.points=[],r=o,n=s),i.points.unshift(Ey.intersectRect(s,r)),i.points.push(Ey.intersectRect(o,n))}))}(e)})),t(" reversePoints",(function(){!function(e){cy.forEach(e.edges(),(function(t){var r=e.edge(t);r.reversed&&r.points.reverse()}))}(e)})),t(" acyclic.undo",(function(){hy.undo(e)}))}(t,r)})),r(" updateInputGraph",(function(){!function(e,t){cy.forEach(e.nodes(),(function(r){var n=e.node(r),i=t.node(r);n&&(n.x=i.x,n.y=i.y,t.children(r).length&&(n.width=i.width,n.height=i.height))})),cy.forEach(e.edges(),(function(r){var n=e.edge(r),i=t.edge(r);n.points=i.points,cy.has(i,"x")&&(n.x=i.x,n.y=i.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,t)}))}))};var Cy=["nodesep","edgesep","ranksep","marginx","marginy"],Ry={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},ky=["acyclicer","ranker","rankdir","align"],Ty=["width","height"],Sy={width:0,height:0},Oy=["minlen","weight","width","height","labeloffset"],Iy={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Ny=["labelpos"];function Ly(e,t){return cy.mapValues(cy.pick(e,t),Number)}function Vy(e){var t={};return cy.forEach(e,(function(e,r){t[r.toLowerCase()]=e})),t}var Py=e_,Dy=y_,By=Gp.Graph;var My={graphlib:Gp,layout:Ay,debug:{debugOrdering:function(e){var t=Dy.buildLayerMatrix(e),r=new By({compound:!0,multigraph:!0}).setGraph({});return Py.forEach(e.nodes(),(function(t){r.setNode(t,{label:t}),r.setParent(t,"layer"+e.node(t).rank)})),Py.forEach(e.edges(),(function(e){r.setEdge(e.v,e.w,{},e.name)})),Py.forEach(t,(function(e,t){var n="layer"+t;r.setNode(n,{rank:"same"}),Py.reduce(e,(function(e,t){return r.setEdge(e,t,{style:"invis"}),t}))})),r}},util:{time:y_.time,notime:y_.notime},version:"0.8.5"};class Gy extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let n=Re(e.children[0]);if(!n)continue;var r=new My.graphlib.Graph;r.setGraph({edgesep:t._edgeSep}),r.setDefaultEdgeLabel((function(){return{}})),r.graph().rankdir=this._getDagreDirection(t.direction);let i=new Map;for(let t of e.children){let e=t.dataScope.getAttributeValue(Te);i.set(e,e+""),r.setNode(e,{label:t.text?t.text:"",width:t.bounds.width,height:t.bounds.height})}for(let e of n.linkList)r.setEdge(e.source,e.target);My.layout(r);const s={};let o=Math.min(...r.nodes().map((e=>r.node(e).y))),a=Math.min(...r.nodes().map((e=>r.node(e).x))),l=t.left-a,u=t.top-o;for(const e of r.nodes())s[e]={x:r.node(e).x+l,y:r.node(e).y+u};for(let t of e.children){let e=t.dataScope.getAttributeValue(Te);Xe(t,s[i.get(e)].x-t.x,s[i.get(e)].y-t.y)}}let n=Z(e,!0);for(let e of n)I(e)}_getDagreDirection(e){switch(e){case se.Left2Right:return"LR";case se.Right2Left:return"RL";case se.Top2Bottom:return"TB";case se.Bottom2Top:return"BT"}}}class jy extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=Ae(e.children[0]);if(!r)continue;let i=n.hierarchy(r._data),s=Math.max(...e.children.map((e=>e.bounds.width))),o=Math.max(...e.children.map((e=>e.bounds.height))),a=t.orientation==ie.HORIZONTAL?[t.height,t.width]:[t.width,t.height],l=n.tree().nodeSize([s,o]).size(a)(i);this._apply(l,t,e)}I(e)}_apply(e,t,r){let n,i,s=r.children.filter((t=>t.dataScope.getAttributeValue(Te)==e.data[Te]))[0];switch(t.orientation){case ie.HORIZONTAL:n=e.y+t.left,i=e.x+t.top;break;case ie.VERTICAL:n=e.x+t.left,i=t.top+e.y}if(Xe(s,n-s.x,i-s.y),e.children&&e.children.length>0)for(let n of e.children)this._apply(n,t,r)}}class zy extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=this._inputVars.filter((e=>e.type===_.ORDER))[0].element,r=t.layout,i=r.width?r.width:t.bounds.width,s=r.height?r.height:t.bounds.height,o=void 0===r.top?t.bounds.top:r.top,a=void 0===r.left?t.bounds.left:r.left,l=n.hierarchy(t).sum((e=>e.type===Lt.Rect?e.width*e.height:0));n.treemap().size([i,s])(l),this._apply(l,a,o);let u=Z(e,!0);for(let e of u)I(e)}_apply(e,t,r){if(e.data.type==Lt.Collection&&e.children)for(let n of e.children)this._apply(n,t,r);else e.data.type==Lt.Rect&&(e.data.resize(e.x1-e.x0,e.y1-e.y0),Xe(e.data,e.x0+t-e.data.left,e.y0+r-e.data.top))}}class Fy extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e.parent);for(let e of t){if(!e.layout)continue;let t=Ae(e.children[0]);if(!t)continue;let r={};for(let t of e.children)r[t.dataScope.getAttributeValue(Te)]=t;let n=e.children[0];n.type===Lt.Rect?this._layoutRects(t.getRoot(),t,r):n.type===Lt.Circle&&this._layoutArcs(t.getRoot(),t,r)}I(e)}_layoutArcs(e,t,r){let n=t.getChildren(e);if(0===n.length)return;let i=r[e[Te]],s=i.type==Lt.Arc||i.type==Lt.Pie?i.startAngle:90;for(let e=0;e<n.length;e++){let i=n[e],o=r[i[Te]];if(o.type===Lt.Arc){let e=me(s+o.angle);o.setAngles(s,e),s=e}this._layoutArcs(i,t,r)}}_layoutRects(e,t,r){let n=t.getChildren(e);if(0===n.length)return;let i,s,o=r[e[Te]];this._direction,se.Top2Bottom,i=o.left,s=o.bottom;for(let e=0;e<n.length;e++){let o=n[e],a=r[o[Te]];Xe(a,i-a.left,s-a.top),i+=a.width,this._layoutRects(o,t,r)}}}class Uy extends p{constructor(e,t){super(e),this._trigger=t}get trigger(){return this._trigger}}class Hy extends d{constructor(e){super(e)}run(){super.run();let e=this.outputVar.condEncoding,t=e.trigger,r=G(e.target),n={};if(t.type===y.ELEMENT){let i=t.elements.length>0?t.elements:[void 0];r.forEach((t=>n[t.id]=i.map((r=>e._targetEval(r,t))).some((e=>e))))}t.type===y.MOUSE&&r.forEach((r=>n[r.id]=e._targetEval(t.mouseEvent,r))),e.evalResult=n}}class Wy extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e.parent);for(let e of t){let t=e.layout;if(!t)continue;let r=360/e.children.length;for(let[n,i]of e.children.entries())Xe(i,t.x+t.radius-i.bounds.x,t.y-i.bounds.y),i._rotate=[n*r,t.x,t.y]}let r=Z(e,!0);for(let e of r)I(e)}}class Yy extends d{constructor(e){super(e)}run(){super.run();let e=this._outputVars[0].element,t=G(e.parent);for(let r of t){let t=r.layout;if(!t)continue;let i=t._tree?t._tree._data:Ae(r.children[0])._data,s=n.hierarchy(i);if(t.isRadial()){s=n.cluster().size([ge(t.angleExtent),t.radius])(s),t._d3Root=s;const e=new Map(s.descendants().map((e=>[e.data[Te],[e.x,e.y]])));for(let n of r.children){let r=n.dataScope.getAttributeValue(Te);Xe(n,t.x-n.bounds.x,t.y-e.get(r)[1]-n.bounds.y),n._rotate=[ye(e.get(r)[0]),t.x,t.y]}}else if(t.orientation===ie.VERTICAL){!t.width||t.width;let i=t.height?t.height:600;s=n.cluster().nodeSize([e.bounds.width+1,i/(s.height+1)])(s),t._d3Root=s;const o=new Map(s.descendants().map((e=>[e.data[Te],[e.x,e.y]])));let a=1/0,l=-a;s.each((e=>{e.x>l&&(l=e.x),e.x<a&&(a=e.x)})),t._x0=a;for(let e of r.children){let r=e.dataScope.getAttributeValue(Te);Xe(e,o.get(r)[0]-a+t.left-e.bounds.x,o.get(r)[1]+t.top-e.bounds.y)}}else if(t.orientation===ie.HORIZONTAL){!t.width||t.width;let i=t.height?t.height:600;s=n.cluster().nodeSize([e.bounds.height,i/(s.height+1)])(s),t._d3Root=s;const o=new Map(s.descendants().map((e=>[e.data[Te],[e.x,e.y]])));let a=1/0,l=-a;s.each((e=>{e.x>l&&(l=e.x),e.x<a&&(a=e.x)})),t._x0=a;for(let e of r.children){let r=e.dataScope.getAttributeValue(Te);Xe(e,o.get(r)[1]+t.left-e.bounds.x,o.get(r)[0]-a+t.top-e.bounds.y)}}}let r=Z(e,!0);for(let e of r)I(e)}}class Xy{constructor(){this._variables={},this._operators={},this._edges=[]}toJSON(){const e=this._edges.map((e=>({from:e.fromNode.id,to:e.toNode.id,isDirected:e.isDirected}))),t={};for(const e in this._variables)t[e]=Object.values(this._variables[e]).map((e=>{let t={id:e.id,type:e.type,incoming:e.incomingEdges.map((e=>e.id)),outgoing:e.outgoingEdges.map((e=>e.id)),undirected:e.undirectedEdges.map((e=>e.id))};return"ChannelVar"===e.type?(t.channel=e.channel,t.element=e.element):"BoundsVar"===e.type||"DataScopeVar"===e.type?t.element=e.element:"DomainVar"===e.type?(t.scale=e.scale,t.attrValues=e.attrValues):"FieldVar"===e.type?(t.field=e.field,t.dataset=e.dataset):"PropertyVar"===e.type?(t.property=e.property,t.element=e.element):t.scale=e.scale,t}));const r={};for(const e in this._operators)r[e]=Object.values(this._operators[e]).map((e=>{let t={id:e.id,type:e.type,inputVars:e.inputVars.map((e=>e.id)),outputVar:e.outputVar?e.outputVar.id:null};return e.type===f.DOMAIN_BUILDER?t.aggregator=e.aggregator:e.type===f.SCALE_BUILDER&&(t.channel=e.channel),t}));return{edges:e,variables:t,operators:r}}getVariable(e,...t){if(Object.values(_).indexOf(e)<0)throw new Error("Variable Type Not Known");let r=this.findVariable(e,t);if(r)return r;switch(e){case _.CHANNEL:r=new De(e,t[0],t[1]),"vertex"!=t[1].type&&"segment"!=t[1].type||this._connectPathElement2Size(t[1],r);break;case _.PROPERTY:r=new nt(e,t[0],t[1]);break;case _.ATTRIBUTE:r=new Ht(e,t[0],t[1]);break;case _.ITEMS:r=new _r(e,t[0],t[1]);break;case _.DOMAIN:r=new Wt(e,t[0]);break;case _.DATASCOPE:r=new zt(e,t[0]);break;case _.BOUNDS:r=new jt(e,t[0]);break;case _.ORDER:r=new gr(e,t[0]);break;case _.SCALE:r=new tt(e,t[0]);break;case _.COND_ENCODING:r=new te(e,t[0]);break;case _.AFFIXATION:r=new mr(e,t[0]);break;case _.ALIGNMENT:r=new Cr(e,t[0]);break;case _.TRIGGER:r=new Uy(e,t[0])}return e in this._variables||(this._variables[e]={}),this._variables[e][r.id]=r,r}_connectPathElement2Size(e,t){let r=e.parent,n=t.channel,i=this.findVariable(_.CHANNEL,["x"===n?"width":"height",r]);if(i){let e=i.incomingDataflow;e||(e=this.createOneWayDependency(f.CONDUIT)),this.connect(t,e),this.connect(e,i)}}findIncomingDataflowOperator(e,t){return t.incomingDataflow&&t.incomingDataflow.type===e?t.incomingDataflow:void 0}getIncomingDataflowOperator(e,t){let r=this.findIncomingDataflowOperator(e,t);return r||this.createOneWayDependency(e)}getOutgoingDataflowOperator(e,t){for(let r of t.outgoingEdges)if(r.toNode instanceof d&&r.toNode.type===e)return r.toNode;return this.createOneWayDependency(e)}createOneWayDependency(e,...t){if(Object.values(f).indexOf(e)<0)throw new Error("Dependency Type Not Known");let r;switch(e){case f.EVAL_BBOX:r=new $t(e);break;case f.AFFIXER:r=new yr(e);break;case f.DOMAIN_BUILDER:r=new Yt(e,t[0]);break;case f.SCALE_BUILDER:r=new Zt(e,t[0]);break;case f.ENCODER:r=new rt(e,t[0]);break;case f.AXIS_PATH_PLACER:r=new or(e);break;case f.AXIS_TICKS_PLACER:r=new ar(e);break;case f.AXIS_LABELS_PLACER:r=new lr(e);break;case f.AXIS_TITLE_PLACER:r=new wr(e);break;case f.LINK_PLACER:r=new kr(e);break;case f.GRID_LAYOUT:r=new ur(e);break;case f.STACK_LAYOUT:r=new hr(e);break;case f.PACK_LAYOUT:r=new Er(e);break;case f.FORCE_LAYOUT:r=new Rr(e);break;case f.DIRECTED_LAYOUT:r=new Gy(e);break;case f.TIDY_TREE_LAYOUT:r=new jy(e);break;case f.TREEMAP_LAYOUT:r=new zy(e);break;case f.STRATA_LAYOUT:r=new Fy(e);break;case f.CIRCULAR_LAYOUT:r=new Wy(e);break;case f.CLUSTER_LAYOUT:r=new Yy(e);break;case f.GRIDLINES_PLACER:r=new cr(e);break;case f.BIN_TRANSFORMER:r=new fr(e);break;case f.FILTER_TRANSFORMER:r=new pr(e);break;case f.KDE_TRANSFORMER:r=new br(e);break;case f.TARGET_EVALUATOR:r=new Hy(e);break;case f.CONDUIT:default:r=new dr(e)}return e in this._operators||(this._operators[e]={}),this._operators[e][r.id]=r,r}createMultiWayDependency(e){if(Object.values(f).indexOf(e)<0)throw new Error("Dependency Type Not Known");let t;return f.ALIGNER,t=new Ar(e),e in this._operators||(this._operators[e]={}),this._operators[e][t.id]=t,t}connect(e,t,r=!0){if(e instanceof p&&t instanceof d){if(!t.inputVars.includes(e)){const n=new Ut(e,t,r);this._edges.push(n),e.outgoingEdges.push(n),t.inputVars.push(e)}}else if(e instanceof d&&t instanceof p){if(!e.outputVars.includes(t)){const n=new Ut(e,t,r);this._edges.push(n),e.outputVars.push(t),t.incomingEdges.push(n)}}else if(e instanceof p&&t instanceof Ft){if(!t.vars.includes(e)){const r=new Ut(e,t,!1);this._edges.push(r),t.vars.push(e),t.edges.push(e),e.undirectedEdges.push(r)}}else{if(!(e instanceof Ft&&t instanceof p))throw new Error("An edge must connect a variable and an operator.");if(!e.vars.includes(t)){const r=new Ut(t,e,!1);this._edges.push(r),e.vars.push(t),e.edges.push(t),t.undirectedEdges.push(r)}}}disconnectChannelVarFromBBoxOperator(e){let t=this.getOutgoingDataflowOperator(f.EVAL_BBOX,e),r=e.outgoingEdges.find((r=>r.fromNode===e&&r.toNode===t));r&&this.disconnect(e,t,r)}disconnect(e,t,r){if(e instanceof p&&t instanceof d){let n=e.outgoingEdges.findIndex((e=>e===r));n>=0&&(this._edges.splice(this._edges.indexOf(r),1),e.outgoingEdges.splice(n,1));let i=t.inputVars.findIndex((t=>t==e));i>=0&&t.inputVars.splice(i,1)}else if(e instanceof d&&t instanceof p){let n=t.incomingEdges.findIndex((e=>e===r));n>=0&&(this._edges.splice(this._edges.indexOf(r),1),t.incomingEdges.splice(n,1));let i=e.outputVars.findIndex((e=>e===t));i>=0&&e.outputVars.splice(i,1)}}deleteVariable(e){for(let t=e.incomingEdges.length-1;t>=0;t--){let r=e.incomingEdges[t],n=r.fromNode;this.disconnect(n,e,r),n.isIsolated()&&delete this._operators[n.type][n.id]}for(let t=e.outgoingEdges.length-1;t>=0;t--){let r=e.outgoingEdges[t],n=r.toNode;this.disconnect(e,n,r),n.isIsolated()&&delete this._operators[n.type][n.id]}delete this._variables[e.type][e.id]}deleteOperator(e){for(let t=e.outputVars.length-1;t>=0;t--){let r=e.outputVars[t],n=r.incomingEdges.find((t=>t.fromNode===e&&t.toNode===r));this.disconnect(e,r,n),r.isIsolated()&&delete this._variables[r.type][r.id]}for(let t=e.inputVars.length-1;t>=0;t--){let r=e.inputVars[t],n=r.outgoingEdges.find((t=>t.fromNode===r&&t.toNode===e));this.disconnect(r,e,n),r.isIsolated()&&delete this._variables[r.type][r.id]}delete this._operators[e.type][e.id]}addInteraction(e){}_dfs(e,t,r){if(e&&0!==e.outgoingEdges.length)for(let n of e.outgoingEdges)n.isDirected&&(t.push(n.toNode),this._dfs(n.toNode.outputVars[0],t.slice(),r));else r.push(t)}processChange(e,t,...r){let n=this.findVariable(e,r);if(n){for(let e of n.outgoingEdges)if(e.isDirected){let r=e.toNode;r.run();let n=r.outputVars;if(n.length>0){let e=n[0];switch(e.type){case _.ITEMS:this.processChange(e.type,t,e.predicate,e.dataset);break;case _.ATTRIBUTE:this.processChange(e.type,t,e.attribute,e.dataset);break;case _.BOUNDS:case _.ORDER:this.processChange(e.type,t,e.element);break;case _.CHANNEL:this.processChange(e.type,t,e.channel,e.element);break;case _.PROPERTY:this.processChange(e.type,t,e.property,e.element);break;case _.SCALE:case _.DOMAIN:this.processChange(e.type,t,e.encodings[0]);break;case _.COND_ENCODING:this.processChange(e.type,t,e.condEncoding)}}}for(let e of n.undirectedEdges)t.push(e.operator)}else console.warn("Unable to find variables matching the described change: ",e,r)}findVariable(e,t){if(!(e in this._variables))return null;let r=Object.values(this._variables[e]);switch(e){case _.CHANNEL:return r.find((e=>e.channel==t[0]&&Fe(e.element)==Fe(t[1])));case _.PROPERTY:return r.find((e=>e.property==t[0]&&e.element==t[1]));case _.COND_ENCODING:return r.find((e=>e.condEncoding==t[0]));case _.AFFIXATION:return r.find((e=>e.affixation==t[0]));case _.ATTRIBUTE:return r.find((e=>e.attribute==t[0]&&e.dataset==t[1]));case _.ITEMS:return r.find((e=>e.dataset==t[1]));case _.DOMAIN:case _.SCALE:return r.find((e=>e.encodings.includes(t[0])));case _.TRIGGER:return r.find((e=>e.trigger===t[0]));case _.DATASCOPE:default:return t[0].classId?r.find((e=>Fe(e.element)==Fe(t[0]))):r.find((e=>e.element.id==t[0].id))}}findVariablesByElement(e){let t={};for(let r in this._variables){let n=Object.values(this._variables[r]).filter((t=>t.element&&Fe(t.element)==Fe(e)));n.length>0&&(t[r]=n)}return t}}function qy(e){return!(!B(e)&&e.type!=Lt.Glyph||e.dataScope)||e.type===Lt.Collection&&e.firstChild.dataScope.numTuples>1}function Ky(e,t,r,n){let i=n.getAttributeType(r);if(i!=Oe.String&&i!=Oe.Date&&i!=Oe.Integer)throw new Error("Repeat only works on a string or date attribute: "+r+" is "+i);if(!function(e){if(Array.isArray(e)){if(1===e.length)return qy(e[0]);for(let t of e)if(!B(t)||t.dataScope)return!1;return!0}return qy(e)}(t))throw new Error("The "+t.type+" is not repeatable");return function(e,t,r,n){let i=n.getAttributeSummary(r).unique.map((e=>t.dataScope?t.dataScope.cross(r,e):new ve(n).cross(r,e)));i=i.filter((e=>!e.isEmpty()));let s=St(e);s.dataScope=t.dataScope?t.dataScope.clone():new ve(n),s.addChild(t);for(let e=1;e<i.length;e++){let e=It(t);s.addChild(e)}return s.children.forEach(((e,t)=>e.dataScope=i[t])),s}(e,t,r,n)}class Zy{constructor(e,t,r,n,i){this._elem=e,this._channel=t,this._attribute=r,this._aggregator=n,this._includeZero=i.includeZero,this._flipScale=i.flipScale,this._mapping=i.mapping,this._preferredRangeExtent=i.rangeExtent,this._preferredDomain=void 0,this._scaleType=i.scaleType,this._colorScheme=i.scheme,this._forLegend=i.forLegend,this._scales=[],this._elemGroups=[],this._elem2scale={},this._refElements=[],["width","height","radius","angle","thickness","radialDistance","strokeWidth","area"].indexOf(this._channel)>=0&&(this._includeZero=!0),this.initialize()}initialize(){this._scales=[];let e=G(this._elem);if(this._elemGroups=[],"x"===this._channel||"y"===this._channel){let t=this._elem,r=X(t);if(r.layout&&r.layout.type==Q.GRID){let e="x"===this._channel?r.layout.getElementsByCol(!0,t):r.layout.getElementsByRow(!0,t);for(let t of e)this._createScaleForElems(t)}else if("vertex"===this._elem.type&&(We(this._elem.parent)||He(this._elem.parent))){let e=G(this._elem.parent).map((e=>j(this._elem,[e])));for(let t of e)this._createScaleForElems(t)}else this._createScaleForElems(e)}else if("angle"===this._channel){let t=e.reduce(((e,t)=>{const r=t.parent.id;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),r=Object.values(t);for(let e of r)this._createScaleForElems(e)}else this._createScaleForElems(e)}_createScaleForElems(e){this._elemGroups.push(e);var t=function(e){if(e.scaleType)return new Xt(e.scaleType);if("text"===e.channel)return new Xt("ordinal");switch(Bt(e.element).getAttributeType(e.attribute)){case Oe.Boolean:break;case Oe.Date:return new Xt("time");case Oe.String:if("count"==e.aggregator)return new Xt("linear");if(e.channel.indexOf("Color")>=0){let t={};return t.scheme=e.colorScheme?e.colorScheme:"schemeCategory10",new Xt("ordinalColor",t)}return new Xt("point");default:return["strokeColor","fillColor","fillGradient"].indexOf(e.channel)>=0?e.mapping?new Xt("linear"):new Xt("sequentialColor",{scheme:e.colorScheme}):new Xt("linear")}}(this);this._scales.push(t);for(let r of e)this._elem2scale[r.id]=t}getScale(e){return this._elem2scale[e.id]}getElements(e){let t=this._scales.indexOf(e);return this._elemGroups[t]}get element(){return this._elem}get channel(){return this._channel}get attribute(){return this._attribute}get dataTable(){return Bt(this._elem)}get aggregator(){return this._aggregator}hasMultipleScales(){return this._scales.length>0}get scales(){return this._scales}getRangeStart(e){let t=this.getScale(e);return Math.min(...t.range)}getRangeExtent(e){return this.getScale(e).rangeExtent}get scaleType(){return this._scaleType}set scaleType(e){this._scaleType=e}set domain(e){this._preferredDomain=e;for(let t of this._scales)t._scale.domain(e);for(let e of this._refElements)e instanceof ir&&e.createTicksLabels({});this._elem.scene.onChange(_.DOMAIN,this)}set rangeExtent(e){for(let t of this._scales)t.rangeExtent=e;for(let e of this._refElements)e instanceof ir&&e.createTicksLabels({});this._elem.scene.onChange(_.PROPERTY,it.RANGE_EXTENT,this)}set includeZero(e){this._includeZero=e;for(let e of this._refElements)e instanceof ir&&e.createTicksLabels({});this._elem.scene.onChange(_.PROPERTY,it.INCLUDE_ZERO,this)}get includeZero(){return this._includeZero}set flipScale(e){this._flipScale=e,this._elem.scene.onChange(_.PROPERTY,it.FLIP_SCALE,this)}get flipScale(){return this._flipScale}set mapping(e){this._mapping=e}get mapping(){return this._mapping}set colorScheme(e){this._colorScheme=e}get colorScheme(){return this._colorScheme}addRefElement(e){this._refElements.indexOf(e)<0&&this._refElements.push(e)}get refElements(){return this._refElements}clearRefElements(){this._refElements=[]}}class $y{constructor(e,t,r,n){this._trigger=e,this._target=t.target,this._targetEval=r,this._efxFn=n,this._evalResult={}}get trigger(){return this._trigger}get target(){return this._target}get channels(){return Object.keys(this._rules)}get evalResult(){return this._evalResult}set evalResult(e){this._evalResult=e}}class Jy extends ce{constructor(e,t,r,n,i){super(i),this._type=Lt.Gridlines,this._id=this._type+Pt(),this._attribute=t,this._channel=e,this._scale=r,this._elems=n,"strokeColor"in i||(this.styles.strokeColor="#ddd"),"opacity"in i||(this.styles.opacity=.5),"values"in i?this._values=i.values:this._scale?this._values=rr(this._scale,this._channel,this._elems):this._values=this._elems.map((e=>e.dataScope.getAttributeValue(this._attribute))),this._lines=[]}get type(){return this._type}get id(){return this._id}getSVGPathData(){let e="";if("radialDistance"===this._channel)for(let t of this._lines)e+="M "+t.x+" "+t.y+" m -"+t.r+" 0 a "+t.r+" "+t.r+" 0 1 0 "+2*t.r+" 0 a "+t.r+" "+t.r+" 0 1 0 -"+2*t.r+" 0 ";else for(let t of this._lines)e+=["M",t.x1,t.y1].join(" ")+[" L",t.x2,t.y2].join(" ")+" ";return e}_updateBounds(){if("radialDistance"===this._channel){let e=this._lines.map((e=>new k(e.x-e.r,e.y-e.y,2*e.r,2*e.r)));this._bounds=T(e)}else{let e=this._lines.map((e=>e.x1)).concat(this._lines.map((e=>e.x2))),t=this._lines.map((e=>e.y1)).concat(this._lines.map((e=>e.y2))),r=Math.min(...e),n=Math.max(...e),i=Math.min(...t),s=Math.max(...t);this._bounds=new k(r,i,n-r,s-i)}}get elements(){return this._elems}get values(){return this._values}get channel(){return this._channel}get attribute(){return this._attribute}get scale(){return this._scale}get lines(){return this._lines}set lines(e){this._lines=e}}class Qy extends J{constructor(e){super(),this.type=Q.STACK,this._orientation=e.orientation,this._direction=e.direction,this._left=e.left,this._top=e.top,this._horzCellAlignment="horzCellAlignment"in e&&e.horzCellAlignment?e.horzCellAlignment:N.LEFT,this._vertCellAlignment="vertCellAlignment"in e&&e.vertCellAlignment?e.vertCellAlignment:N.BOTTOM,this._gap="gap"in e?e.gap:0}clone(){let e=new Qy({orientation:this._orientation,direction:this._direction,left:this._left,top:this._top});return e._horzCellAlignment=this._horzCellAlignment,e._vertCellAlignment=this._vertCellAlignment,e}get horzCellAlignment(){return this._horzCellAlignment}get vertCellAlignment(){return this._vertCellAlignment}get orientation(){return this._orientation}set horzCellAlignment(e){this._horzCellAlignment=e}set vertCellAlignment(e){this._vertCellAlignment=e}set orientation(e){this._orientation=e}}function em(e,t,r,n,i){let s=i.getAttributeType(r);if(s!=Oe.String&&s!=Oe.Date&&s!=Oe.Integer)throw new Error("Divide only works on a string or date attribute: "+r+" is "+s);if(!function(e){if([Lt.Line,Lt.Circle,Lt.Rect,Lt.Area,Lt.Ring,Lt.Pie,Lt.Path].indexOf(e.type)<0)return!1;if(e.type===Lt.Path&&(e.closed||!e.firstVertex.dataScope))return!1;if(e.dataScope){let t=G(e);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 Lt.Line:case Lt.Path:return;case Lt.Circle:return function(e,t,r,n,i){let s,o,a,l=G(t),u=r||ie.ANGULAR;if(u!=ie.ANGULAR&&u!=ie.RADIAL)throw new Error("Unknown orientation: "+u);u===ie.ANGULAR&&l.forEach((r=>{let l=r.dataScope?r.dataScope:new ve(i),u=i.getUniqueAttributeValues(n).map((e=>l.cross(n,e)));u=u.filter((e=>!e.isEmpty()));let c=St(e);null==o&&(o=c.id),c._classId=o,c.dataScope=r.dataScope?r.dataScope:new ve(i);let h=r.parent;h.removeChild(r),delete e._itemMap[r.id];let d=360/u.length,f=90;for(let e=0;e<u.length;e++){let n=Tt({type:"arc",innerRadius:0,outerRadius:r.radius,x:r.x,y:r.y,startAngle:me(f-d*(e+1)),endAngle:me(f-d*e),strokeColor:r.strokeColor,fillColor:r.fillColor,strokeWidth:r.strokeWidth,opacity:r.opacity});a||(a=n.id),n.classId=a,n.dataScope=u[e],n._updateBounds(),n._refBounds=n.bounds.clone(),c.addChild(n),c._layout=new Qy({orientation:ie.ANGULAR,direction:oe.CLOCKWISE}),c._layout.group=c,h.removeChild(r),h.addChild(c),r===t&&(s=c)}}));return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Lt.Rect:return function(e,t,r,n,i){let s,o=G(t),a=r||ie.HORIZONTAL;if(a!=ie.HORIZONTAL&&a!=ie.VERTICAL)throw new Error("Unknown orientation: "+a);let l=i.getUniqueAttributeValues(n).map((e=>new ve(i).cross(n,e))),u={},c=0;for(let e of o){let t=l;e.dataScope&&(t=l.map((t=>t.merge(e.dataScope))),t=t.filter((e=>!e.isEmpty()))),t.length>c&&(c=t.length),u[e.id]=t}let h,d=Tt({type:"rect",left:t.bounds.left,top:t.bounds.top,width:t.bounds.width,height:t.bounds.height,strokeColor:t.strokeColor,fillColor:t.fillColor,strokeWidth:t.strokeWidth,opacity:t.opacity});d._classId=d.id;for(let r of o){let n=St(e);null==h&&(h=n.id),n._classId=h,n.dataScope=r.dataScope?r.dataScope:new ve(i);let o=r.parent;o.removeChild(r),delete e._itemMap[r.id];let l=u[r.id],c=r.bounds,f=c.left,p=c.top,_=a==ie.HORIZONTAL?c.width/l.length:c.width,g=a==ie.HORIZONTAL?c.height:c.height/l.length;for(let e=0;e<l.length;e++){let t=It(d);t.dataScope=l[e],t.resize(_,g),t._updateBounds(),t._refBounds=t.bounds.clone(),n.addChild(t)}o.addChild(n),n._layout=new Qy({orientation:a,left:f,top:p}),n._layout.group=n,r==t&&(s=n)}return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Lt.Area:return function(e,t,r,n,i){let s,o=G(t),a=r||ie.HORIZONTAL;if(a!=ie.HORIZONTAL&&a!=ie.VERTICAL)throw new Error("Unknown orientation: "+a);let l,u=i.getUniqueAttributeValues(n).map((e=>new ve(i).cross(n,e))),c={},h=0;for(let e of o){let t=u;e.dataScope&&(t=u.map((t=>t.merge(e.dataScope))),t=t.filter((e=>!e.isEmpty()))),t.length>h&&(h=t.length),c[e.id]=t}let d=Object.assign({},t.styles);d.vertices=t.vertices.map((e=>[e.x,e.y])),d.type="area",d.orientation=t.orientation,d.baseline=t.baseline;let f=Tt(d);if(f._classId=f.id,t.vertices)for(let e=0;e<t.vertices.length;e++)t.vertices[e].dataScope&&(f.vertices[e]._dataScope=t.vertices[e].dataScope.clone());for(let r of o){let n=St(e);null==l&&(l=n.id),n._classId=l,n.dataScope=r.dataScope?r.dataScope:new ve(i);let o=r.parent;o.removeChild(r),delete e._itemMap[r.id];let u=c[r.id],h=r.bounds,d=h.left,p=h.top,_=a==ie.HORIZONTAL?h.width/u.length:h.width,g=a==ie.HORIZONTAL?h.height:h.height/u.length;for(let e=0;e<u.length;e++){let t=It(f);t.dataScope=u[e],console.log(t.dataScope),t.resize(_,g),t._updateBounds(),t._refBounds=t.bounds.clone(),n.addChild(t);for(let e of t.vertices)e.dataScope?e.dataScope=t.dataScope.merge(e.dataScope):e.dataScope=t.dataScope}o.addChild(n),n._layout=new Qy({orientation:a,left:d,top:p}),n._layout.group=n,r==t&&(s=n)}return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Lt.Ring:return function(e,t,r,n,i){let s,o,a,l=G(t),u=r||ie.ANGULAR;if(u!=ie.ANGULAR&&u!=ie.RADIAL)throw new Error("Unknown orientation: "+u);u===ie.ANGULAR&&l.forEach((r=>{let l=r.dataScope?r.dataScope:new ve(i),u=i.getUniqueAttributeValues(n).map((e=>l.cross(n,e)));u=u.filter((e=>!e.isEmpty()));let c=St(e);null==o&&(o=c.id),c._classId=o,c.dataScope=r.dataScope?r.dataScope:new ve(i);let h=r.parent;h.removeChild(r),delete e._itemMap[r.id];let d=360/u.length,f=90;for(let e=0;e<u.length;e++){let n=Tt({type:"arc",innerRadius:r.innerRadius,outerRadius:r.outerRadius,x:r.x,y:r.y,startAngle:me(f-d*(e+1)),endAngle:me(f-d*e),strokeColor:r.strokeColor,fillColor:r.fillColor,strokeWidth:r.strokeWidth,opacity:r.opacity});a||(a=n.id),n.classId=a,n.dataScope=u[e],n._updateBounds(),n._refBounds=n.bounds.clone(),c.addChild(n),c._layout=new Qy({orientation:ie.ANGULAR,direction:oe.CLOCKWISE}),c._layout.group=c,h.removeChild(r),h.addChild(c),r===t&&(s=c)}}));return{newMark:s.children[0],collection:s}}(e,t,n,r,i);case Lt.Pie:case Lt.Arc:return function(e,t,r,n,i){let s,o,a,l=G(t),u=r||ie.ANGULAR;if(u!=ie.ANGULAR&&u!=ie.RADIAL)throw new Error("Unknown orientation: "+u);u===ie.ANGULAR||l.forEach((r=>{let l=r.dataScope?r.dataScope:new ve(i),u=i.getUniqueAttributeValues(n).map((e=>l.cross(n,e)));u=u.filter((e=>!e.isEmpty()));let c=St(e);null==o&&(o=c.id),c._classId=o,c.dataScope=r.dataScope?r.dataScope:new ve(i);let h=r.parent;h.removeChild(r),delete e._itemMap[r.id];for(let e=0;e<u.length;e++){let n=Tt({type:"arc",innerRadius:r.innerRadius+e*(r.outerRadius-r.innerRadius)/u.length,outerRadius:r.innerRadius+(e+1)*(r.outerRadius-r.innerRadius)/u.length,x:r.x,y:r.y,startAngle:r.startAngle,endAngle:r.endAngle,strokeColor:r.strokeColor,fillColor:r.fillColor,strokeWidth:r.strokeWidth,opacity:r.opacity});a||(a=n.id),n.classId=a,n.dataScope=u[e],n._updateBounds(),n._refBounds=n.bounds.clone(),c.addChild(n),c._layout=new Qy({orientation:ie.RADIAL}),c._layout.group=c,h.removeChild(r),h.addChild(c),r===t&&(s=c)}}));return{newMark:s.children[0],collection:s}}(e,t,n,r,i)}}function tm(e,t,r,n){let i=n.getAttributeType(r);if(i!=Oe.String&&i!=Oe.Date&&i!=Oe.Integer)throw new Error("Repopulate only works on a string or date attribute: "+r+" is "+i);let s=G(t);for(let e of s){let t=n.getAttributeSummary(r).unique.map((t=>e.dataScope?e.dataScope.cross(r,t):new ve(n).cross(r,t)));t=t.filter((e=>!e.isEmpty()));let i=e.children.length-t.length,s=t.length-e.children.length;for(let t=0;t<i;t++)e.removeChildAt(e.children.length-1);let o=e._children.length;for(let t=0;t<s;t++){let r=It(e._children[t%o]);e.addChild(r)}e.children.forEach(((e,r)=>e.dataScope=t[r]))}}class rm{constructor(e,t,r,n){this._elem=e,this._base=t,this._channel=r,this._elemAnchor="elementAnchor"in n?n.elementAnchor:"x"==r||"angle"==r?N.CENTER:N.MIDDLE,this._baseAnchor="baseAnchor"in n?n.baseAnchor:"x"==r||"angle"==r?N.CENTER:N.MIDDLE,this._offset="offset"in n?n.offset:0}get element(){return this._elem}get base(){return this._base}get channel(){return this._channel}get elementAnchor(){return this._elemAnchor}get baseAnchor(){return this._baseAnchor}get offset(){return this._offset}}function nm(e,t,r,n){e.dataScope&&e.dataScope.dataTable.hasAttribute(t)?function(e,t,r,n){if(!e.dataScope.dataTable.hasAttribute(t))return void console.warn("Cannot order collection children by an non-existent attribute",t);let i;if(t===Mt)i=(e,r)=>parseInt(e.dataScope.getAttributeValue(t).substring(1))-parseInt(r.dataScope.getAttributeValue(t).substring(1));else{switch(e.children[0].dataScope.getAttributeType(t)){case Oe.Date:break;case Oe.Number:case Oe.Integer:i=(e,r)=>e.dataScope.aggregateNumericalAttribute(t)-r.dataScope.aggregateNumericalAttribute(t);break;case Oe.String:i=n?(e,r)=>n.indexOf(e.dataScope.getAttributeValue(t))-n.indexOf(r.dataScope.getAttributeValue(t)):(e,r)=>e.dataScope.getAttributeValue(t)<r.dataScope.getAttributeValue(t)?-1:1}}e.children.sort(i),r&&e.children.reverse()}(e,t,r,n):function(e,t,r){let n;switch(t){case"x":case"y":case"width":case"height":n=(e,r)=>e.bounds[t]-r.bounds[t];break;default:n=(e,r)=>e[t]-r[t]}e._children.sort(n),r&&e.children.reverse()}(e,t,r),e._sortBy={property:t,descending:r,vals:n}}function im(e,t,r,n){e.vertices[0].dataScope&&e.vertices[0].dataScope.dataTable.hasAttribute(t)?function(e,t,r,n){let i;if(t===Mt)i=(e,r)=>parseInt(e.dataScope.getAttributeValue(t).substring(1))-parseInt(r.dataScope.getAttributeValue(t).substring(1));else{switch(e.vertices[0].dataScope.getAttributeType(t)){case Oe.Date:break;case Oe.Number:case Oe.Integer:i=(e,r)=>e.dataScope.aggregateNumericalAttribute(t)-r.dataScope.aggregateNumericalAttribute(t);break;case Oe.String:i=n?(e,r)=>n.indexOf(e.dataScope.getAttributeValue(t))-n.indexOf(r.dataScope.getAttributeValue(t)):(e,r)=>e.dataScope.getAttributeValue(t)<r.dataScope.getAttributeValue(t)?-1:1}}e.vertices.sort(i),r&&e.vertices.reverse()}(e,t,r,n):function(e,t,r){let n=(e,r)=>e[t]-r[t];e.vertices.sort(n),r&&e.vertices.reverse()}(e,t,r),e._sortBy={property:t,descending:r,vals:n}}class sm extends J{constructor(e){super(),this.type=Q.GRID,this._numCols=e.numCols,this._numRows=e.numRows,this._start="start"in e?e.start:ne.TopLeft,this._direction="direction"in e?e.direction:re.RowFirst,this._rowGap="rowGap"in e&&void 0!==e.rowGap?e.rowGap:5,this._colGap="colGap"in e&&void 0!==e.colGap?e.colGap:5,this._cellHorzAlignment="horzCellAlignment"in e&&ee("h",e.horzCellAlignment)?e.horzCellAlignment:N.LEFT,this._cellVertAlignment="vertCellAlignment"in e&&ee("v",e.vertCellAlignment)?e.vertCellAlignment:N.BOTTOM,this._numCols||this._numRows||(this._numRows=1),this._left=void 0,this._top=void 0,this._cellBounds=void 0,this._grid=void 0}get cellBounds(){return this._cellBounds}get numCols(){return this._numCols?this._numCols:this._numRows?Math.ceil(this.group.children.length/this._numRows):0}get numRows(){return this._numRows?this._numRows:this._numCols?Math.ceil(this.group.children.length/this._numCols):0}clone(){let e=new sm({numCols:this._numCols,numRows:this._numRows,start:this._start,direction:this._direction,colGap:this._colGap,rowGap:this._rowGap,horzCellAlignment:this._cellHorzAlignment,vertCellAlignment:this._cellVertAlignment});return e._left=this._left,e._top=this._top,this._cellBounds&&(e._cellBounds=this._cellBounds.map((e=>e.clone()))),e}getElementsByRow(e,t){let r=[],n=this.group.children;for(let t=0;t<this.numRows;t++){let i=this._grid[t].filter((e=>null!=e)).map((e=>n[e]));if(e){let e=[];for(let t of i)e=e.concat(Z(t));r.push(e)}else r.push(i)}return t&&(r=this._filterElementsByExample(r,t)),r}getElementsByCol(e,t){let r=[],n=this.group.children,i=this._grid;for(let t=0;t<this.numCols;t++){let s=i.map((e=>e[t])).filter((e=>null!=e)).map((e=>n[e]));if(e){let e=[];for(let t of s)e=e.concat(Z(t));r.push(e)}else r.push(s)}return t&&(r=this._filterElementsByExample(r,t)),r}getElementsByCell(e,t){let r=[],n=this.group.children;for(let t=0;t<n.length;t++)if(e){let e=Z(n[t]);r.push(e)}else r.push(n[t]);return t&&(r=this._filterElementsByExample(r,t)),r}_filterElementsByExample(e,t){let r;return"vertex"===t.type?(r=e.map((e=>e.filter((e=>e.classId===t.parent.classId)))),r=r.map((e=>j(t,e)))):"segment"===t.type?(r=e.map((e=>e.filter((e=>e.classId===t.parent.classId)))),r=r.map((e=>z(t,e)))):r=e.map((e=>e.filter((e=>e.classId===t.classId)))),r}getIndex(e){let t=e;for(;t&&t.parent!==this.group;)t=t.parent;return this.group.children.indexOf(t)}getRowCol(e){let t,r;switch(this._direction){case re.RowFirst:t=Math.floor(e/this.numCols),r=e%this.numCols;break;case re.ColumnFirst:t=e%this.numRows,r=Math.floor(e/this.numRows);break;default:throw new Error("Invalid fill direction. Use 'row_first' or 'column_first'.")}return this._start.toLowerCase().includes("bottom")&&(t=this.numRows-1-t),this._start.toLowerCase().includes("right")&&(r=this.numCols-1-r),{row:t,col:r}}}class om extends mt{constructor(e,t){super(),this._type=Lt.Axis,this._id=this._type+Pt(),this._enc=e,this._textColor="textColor"in t?t.textColor:"#555",this._strokeColor="strokeColor"in t?t.strokeColor:"#555",this._fontSize="fontSize"in t?t.fontSize:"12px",this._x="x"in t?t.x:100,this._y="y"in t?t.y:100,this._showTitle=!("showTitle"in t)||t.showTitle,this._orientation="orientation"in t?t.orientation:ie.VERTICAL,this._numberFormat=t.numberFormat?t.numberFormat:""}get attribute(){return this._enc.attribute}get channel(){return this._enc.channel}get attributeType(){return Bt(this._enc.element).getFieldType(this.attribute)}get orientation(){return this._orientation}get textColor(){return this._textColor}}class am extends om{constructor(e,t){super(e,t),"numCols"in t||"numRows"in t?(this._numCols=t.numCols,this._numRows=t.numRows):this._orientation===ie.VERTICAL?this._numCols=1:this._numRows=1,this._initialize()}_initialize(){let e=this._enc.element.scene,t=this._enc.attribute,r=this._enc.scales[0],n=new Dt(r.domain.map((e=>({category:e,value:r.map(e)})))),i=n.getUniqueAttributeValues("category").sort(((e,t)=>t.length-e.length))[0],s=this._enc.element,o=s instanceof ce&&s.closed?s.strokeWidth:0;if(this._orientation===ie.VERTICAL){let r=0;this._showTitle&&(this.addChild(new Ct({fillColor:this._textColor,fontSize:this._fontSize,text:t,x:this._x,y:this._y,anchor:["left","top"]})),r=parseFloat(this._fontSize)+5);let a=e.mark("rect",{top:this._y+2+r,left:this._x,width:10,height:10,strokeWidth:o,strokeColor:s.strokeColor,opacity:s.opacity}),l=e.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+20,y:this._y+r+12+o,anchor:["left","bottom"]}),u=e.glyph(a,l),c=e.repeat(u,n);e.encode(l,{channel:"text",attribute:"category",forLegend:!0}),e.encode(a,{channel:"fillColor",attribute:"category",shareScale:this._enc,forLegend:!0}),c.layout=new sm({numCols:this._numCols,numRows:this._numRows}),this.addChild(c)}else{let t=e.mark("rect",{top:this._y,left:this._x,width:10,height:10,strokeWidth:o,strokeColor:s.strokeColor,opacity:s.opacity}),r=e.mark("text",{text:i,fillColor:this._textColor,fontSize:this._fontSize,x:this._x+15,y:this._y,anchor:["left","top"]}),a=e.glyph(t,r),l=e.repeat(a,n);e.encode(r,{channel:"text",attribute:"category",forLegend:!0}),e.encode(t,{channel:"fillColor",attribute:"category",shareScale:this._enc,forLegend:!0}),l.layout=new sm({numCols:this._numCols,numRows:this._numRows,colGap:15}),this.addChild(l)}}}class lm extends om{constructor(e,t){super(e,t),this._initialize()}_initialize(){let e,t,r,i=this._enc.element.scene,s=this._enc.attribute;if(this._orientation==ie.VERTICAL?(e=15,t=300):(e=300,t=15),this._showTitle){let t=i.mark("text",{fillColor:this._textColor,text:s,x:this._x+e/2,y:this._y,anchor:["center","middle"]});this.addChild(t),r=20}else r=0;let o,a=i.mark("rect",{top:this._y+r,left:this._x,width:e,height:t,strokeWidth:0,opacity:this._enc.element.opacity}),l=Object.values(this._enc.attrValues),u=[Math.min(...l),Math.max(...l)],c=this._enc.mapping,h=[],d=[],f=n.format(this._numberFormat);if(c){let n=Object.keys(c).map((e=>parseFloat(e))).sort(((e,t)=>e-t));this._orientation==ie.VERTICAL?(o=new P({x1:0,y1:100,x2:0,y2:0}),n.forEach((n=>{let s=(n-u[0])/(u[1]-u[0]);o.addStop(100*s,c[n],1);let a=i.mark("line",{x1:this._x+e,x2:this._x+e+5,y1:this._y+t-s*t+r,y2:this._y+t-s*t+r,strokeColor:this._strokeColor});d.push(a);let l=i.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(n):n.toFixed(0),x:this._x+e+5+5,y:this._y+t-s*t+r,anchor:["left","middle"]});h.push(l)}))):(o=new P({x1:0,y1:0,x2:100,y2:0}),n.forEach((n=>{let s=(n-u[0])/(u[1]-u[0]);o.addStop(100*s,c[n],1);let a=i.mark("line",{x1:this._x+s*e,x2:this._x+s*e,y1:this._y+20-5+r,y2:this._y+t+5+r,strokeColor:this._strokeColor});d.push(a);let l=i.mark("text",{fillColor:this._textColor,text:this._numberFormat?f(n):n.toFixed(0),x:this._x+s*e,y:this._y+t+5+r,anchor:["center","top"]});h.push(l)})))}else{let n=this._enc.scales[0].domain,a=Bt(this._enc.element),l=a.getAttributeType(s),u=[],c=l===Oe.Date?a.getUniqueFieldValues(s):[...new Set(Object.values(this._enc.attrValues))];if(c.length<=10)u=c,u.sort(((e,t)=>e-t));else if(l===Oe.Date){c.sort(((e,t)=>e-t));for(let e=0;e<c.length;e+=Math.ceil(c.length/10))u.push(c[e])}else{let e=(n[1]-n[0])/9;for(let t=0;t<10;t++)u.push(n[0]+t*e)}let p=0,_=(u[u.length-1]-u[0])/u.length;for(;_<1;)_*=10,p++;u=u.map((e=>e.toFixed(p))),this._orientation==ie.VERTICAL?(o=new P({x1:0,y1:100,x2:0,y2:0}),u.forEach((u=>{let c=(u-n[0])/(n[1]-n[0]);o.addStop(100*c,this._enc.scales[0].map(u),1);let p=i.mark("line",{x1:this._x+e,x2:this._x+e+5,y1:this._y+t-c*t+r,y2:this._y+t-c*t+r,strokeColor:this._strokeColor});d.push(p);let _=i.mark("text",{fillColor:this._textColor,text:l===Oe.Date?a.getRawValue(s,u):this._numberFormat?f(u):u,x:this._x+e+5+5,y:this._y+t-c*t+r,anchor:["left","middle"]});h.push(_)}))):(o=new P({x1:0,y1:0,x2:100,y2:0}),u.forEach((u=>{let c=(u-n[0])/(n[1]-n[0]);o.addStop(100*c,this._enc.scale.map(u),1);let f=i.mark("line",{x1:this._x+c*e,x2:this._x+c*e,y1:this._y+t+r,y2:this._y+t+5+r,strokeColor:this._strokeColor});d.push(f);let p=i.mark("text",{fillColor:this._textColor,text:l===Oe.Date?a.getRawValue(s,u):u,x:this._x+c*e,y:this._y+t+5+r,anchor:["center","top"]});h.push(p)})))}a.styles.fillColor=o,this.addChild(a);for(let e of h)this.addChild(e);for(let e of d)this.addChild(e)}}class um extends mt{constructor(e){super(),this._type=Lt.Composite,this._id=e&&e.id?e.id:this._type+Pt()}addChild(e){let t=e.parent;super.addChild(e);let r=Y(e)._depGraph;t&&ct(t,e,r),ht(this,e,r)}}class cm{constructor(e,t,r){this._elems=e,this._channel=t,this._anchor=r}get elements(){return this._elems}get channel(){return this._channel}get anchor(){return this._anchor}}class hm extends J{constructor(e){super(),this.type=Q.STRATA,this._direction=e.direction,this._gap="gap"in e?e.gap:0}clone(){return new hm({direction:this._direction,gap:this._gap})}}function dm(e,t,r,n,i){switch(t.type){case Lt.Circle:return function(e,t,r,n,i){let s,o=r||ae.OUTWARD,a=n||50;if(o!==ae.INWARD&&o!==ae.OUTWARD)throw"Unknown direction to stratify";let l,u=G(t,e);return u.forEach((r=>{let n=St(e);n.dataScope=void 0,null==l&&(l=n.id),n._classId=l;let u=r.parent;fm(r,t.id,o,a,i,i.getRoot(),n,e,!0),n._layout=new hm({direction:o}),n._layout.group=n,u.addChild(n),r===t&&(s=n)})),s}(e,t,r,n,i);case Lt.Rect:return function(e,t,r,n,i){let s,o,a=r||se.Top2Bottom,l=n||50;if(!Object.values(se).includes(a))throw"Unknown direction to stratify";return G(t).forEach((r=>{let n=St(e);n.dataScope=void 0,null==o&&(o=n.id),n._classId=o;let u=r.parent;pm(r,t.id,a,l,i,i.getRoot(),n,e,!0),n._layout=new hm({direction:a}),n._layout.group=n,u.addChild(n),r===t&&(s=n)})),s}(e,t,r,n,i)}}function fm(e,t,r,n,i,s,o,a,l){l&&(e.dataScope=i.getNodeDataScope(s),e._classId=t,o.addChild(e));let u=i.getChildren(s);if(0===u.length)return;let c=e.type===Lt.Circle||e.type===Lt.Ring?90:e.startAngle,h=(e.type===Lt.Circle||e.type===Lt.Ring?360:e.angle)/u.length;for(let s=0;s<u.length;s++){let a,l=e.type===Lt.Circle?e.radius:e.outerRadius;a=Tt(360===h?{type:"ring",innerRadius:l,outerRadius:l+n,x:e.x,y:e.y,strokeColor:e.strokeColor,fillColor:e.fillColor,strokeWidth:e.strokeWidth,opacity:e.opacity}:{type:"arc",innerRadius:l,outerRadius:l+n,x:e.x,y:e.y,startAngle:me(c+h*s),endAngle:me(c+h*(s+1)),strokeColor:e.strokeColor,fillColor:e.fillColor,strokeWidth:e.strokeWidth,opacity:e.opacity}),a.dataScope=i.getNodeDataScope(u[s]),a._classId=t,o.addChild(a),fm(a,t,r,n,i,u[s],o)}}function pm(e,t,r,n,i,s,o,a,l){l&&(e.dataScope=i.getNodeDataScope(s),e._classId=t,o.addChild(e));let u,c,h,d=i.getChildren(s);if(0!==d.length){switch(r){case se.Top2Bottom:case se.Bottom2Top:case se.Left2Right:case se.Right2Left:}u=e.left,c=e.bottom,h=e.width/d.length;for(let s=0;s<d.length;s++){let a=It(e);Xe(a,u-a.left,c-a.top),a.resize(h,n),a._updateBounds(),u+=h,a.dataScope=i.getNodeDataScope(d[s]),a._classId=t,o.addChild(a),pm(a,t,r,n,i,d[s],o)}}}class _m extends g{constructor(e,t,r,n){super(e,t),this._elem=r,this._cumulative=n,this._elements=[]}get element(){return this._elem}isCumulative(){return this._cumulative}get elements(){return this._elements}set elements(e){this._elements=e}}class gm extends g{constructor(e,t,r){super(e,t),this._key=r}get key(){return this._key}}class ym extends g{constructor(e,t,r){super(e,t),this._listener=r,this._elements=[]}get mouseEvent(){return this._mouseEvent}set mouseEvent(e){this._mouseEvent=e}get listener(){return this._listener}get elements(){return this._elements}set elements(e){this._elements=e}}class mm extends g{constructor(e,t,r){super(e,t),this._ctrlId=r}get id(){return this._ctrlId}}class bm extends mt{constructor(e){super(),this._itemMap={},this._type=Lt.Scene,this._id=e&&e.id?e.id:this._type+Pt(),e&&e.fillColor&&(this.fillColor=e.fillColor),this._encodings={},this._relations=[],this._triggers={},this._depGraph=new Xy}get depGraph(){return this._depGraph}get interactionTriggers(){return this._triggers}mark(e,t){if(Object.values(Nt).indexOf(e)<0)throw new Error("Mascot does not allow directly creating a "+e);let r=void 0===t?{}:t;r.type=e;let n=Tt(r);return null!==n&&(n._classId=n.id,this.addChild(n),this._itemMap[n.id]=n,st(n,this._depGraph),ht(this,n,this._depGraph)),n}glyph(...e){let t=[];for(let r of e)t.push([r.parent,r]);let r=Ot(e);if(null!==r){r._classId=r.id,this.addChild(r),this._itemMap[r.id]=r;for(let e of t)ct(e[0],e[1],this._depGraph);!function(e,t){let r=t.getVariable(_.BOUNDS,e),n=t.getIncomingDataflowOperator(f.EVAL_BBOX,r);for(let r of e.children)t.connect(t.getVariable(_.BOUNDS,r),n);t.connect(n,r),n.run()}(r,this._depGraph),ht(this,r,this._depGraph)}return r}composite(){let e=new um;return null!==e&&(e._classId=e.id,this.addChild(e),this._itemMap[e.id]=e,function(e,t){let r=t.getVariable(_.BOUNDS,e),n=t.getVariable(_.CHANNEL,"x",e),i=t.getVariable(_.CHANNEL,"y",e),s=t.getVariable(_.CHANNEL,"width",e),o=t.getVariable(_.CHANNEL,"height",e),a=t.createOneWayDependency(f.EVAL_BBOX);t.connect(n,a),t.connect(i,a),t.connect(s,a),t.connect(o,a),t.connect(a,r),a.run()}(e,this._depGraph),ht(this,e,this._depGraph)),e}attach(e,t){if(e.type==Lt.Glyph)for(let t of e.children)t._refBounds||(t._refBounds=t.bounds.clone());e.dataScope=new ve(t)}repeat(e,t,r){let n=r||{};if(n.attribute=n.attribute||Mt,console.log("------ repeat by",n.attribute," ----"),function(e,t,r){if(!e||void 0===t)throw new Error("Incomplete information to do repeat. You must specify an element, a categorical data attribute and a data table");if(t instanceof we||t instanceof Ce){if(!Array.isArray(e)||2!==e.length)throw new Error("To repeat with a tree or a network, you need to provide two marks, one for node and one for link")}else t instanceof Dt&&Se(r.attribute,t);if(r.layout&&!(r.layout instanceof J))throw new Error("Invalid layout: "+r.layout)}(e,t,n),t instanceof we||t instanceof Ce){let r=e[0].parent,n=e[1].parent,[i,s]=function(e,t,r,n){let i=n.nodeTable.getAttributeSummary(Te).unique.map((e=>t.dataScope?t.dataScope.cross(Te,e):new ve(n.nodeTable).cross(Te,e))),s=St(e),o=St(e),a={};o.dataScope=t.dataScope?t.dataScope.clone():new ve(n.nodeTable),o.addChild(t);for(let e=1;e<i.length;e++){let e=It(t);o.addChild(e)}o.children.forEach(((e,t)=>{e.dataScope=i[t],e.links=[],a[e.dataScope.getAttributeValue(Te)]=e}));let l=n.linkTable.getAttributeSummary(Mt).unique.map((e=>r.dataScope?r.dataScope.cross(Mt,e):new ve(n.linkTable).cross(Mt,e)));s.dataScope=r.dataScope?r.dataScope.clone():new ve(n.linkTable),s.addChild(r);for(let e=1;e<l.length;e++){let e=It(r);s.addChild(e)}s.children.forEach(((e,t)=>e.dataScope=l[t]));let u=n instanceof we?"parent":"source",c=n instanceof we?"child":"target";for(let e of s.children){let t=e.dataScope.getAttributeValue(u),r=e.dataScope.getAttributeValue(c),n=a[t],i=a[r];e.source=n,e.target=i,n.links.push(e),i.links.push(e)}return[o,s]}(this,e[0],e[1],t);return ct(r,e[0],this._depGraph),ct(n,e[1],this._depGraph),ut(i,this._depGraph),ut(s,this._depGraph),ht(i,e[0],this._depGraph),ht(i.parent,i,this._depGraph),ht(s,e[1],this._depGraph),ht(s.parent,s,this._depGraph),[i,s]}if(t instanceof Dt){let r=e.parent,i=Ky(this,e,n.attribute,t);return ct(r,e,this._depGraph),ut(i,this._depGraph),ht(i,e,this._depGraph),ht(i.parent,i,this._depGraph),n.layout&&(i.layout=n.layout),i}}divide(e,t,r){let n=r||{};if(n.attribute=n.attribute||Mt,console.log("------ divide by",n.attribute," ----"),function(e,t,r){if(!e||void 0===t)throw new Error("Incomplete information to do divide. You must specify an element, a categorical data attribute and a data table");if(t instanceof Dt&&Se(r.attribute,t),r.layout&&!(r.layout instanceof J))throw new Error("Invalid layout: "+r.layout)}(e,t,n),t instanceof we||t instanceof Ce)throw"Not implemented";if(t instanceof Dt){let{newMark:r,collection:i}=em(this,e,n.attribute,n.orientation,t);return ot(e,this._depGraph),st(r,this._depGraph),ut(i,this._depGraph),ht(i,r,this._depGraph),i.parent.type!==Lt.Scene&&ht(i.parent,i,this._depGraph),this.onChange(_.CHANNEL,"width",r),{newMark:r,collection:i}}}densify(e,t,r){let n=r||{};if(n.attribute=n.attribute||Mt,console.log("------ densify by",n.attribute," ----"),function(e,t,r){if(!e||void 0===t)throw new Error("Incomplete information to do densification. You must specify an element, a categorical data attribute and a data table");t instanceof Dt&&Se(r.attribute,t)}(e,t,n),t instanceof we||t instanceof Ce)throw"Not implemented";if(t instanceof Dt){let r=Ve(0,e,n.attribute,n.orientation,t);return ot(e,this._depGraph),st(r,this._depGraph),r.parent.type!==Lt.Scene&&ht(r.parent,r,this._depGraph),this.onChange(_.CHANNEL,"width",r),r}}stratify(e,t,r){if(!(t instanceof we))throw"Cannot stratify on a non-tree dataset";if(![Lt.Circle,Lt.Rect].includes(e.type))throw"Cannot stratify elements that are not rects or circles";let n=r||{},i=n.direction,s=n.size,o=e.parent,a=dm(this,e,i,s,t);return ct(o,e,this._depGraph),ut(a,this._depGraph),ht(a,e,this._depGraph),ht(a.parent,a,this._depGraph),a}repopulate(e,t,r){e.dataScope=void 0;let n=e;for(let e in r){tm(0,n,r[e],t);let i=Ge(n.children[0],!0);for(let e of i){Me(e,this),at(e,this._depGraph);for(let t of e.refElements)nr(t,this),lt(t,this._depGraph);e.clearRefElements()}let s=G(n);for(let e of s)if(e.layout){for(let t of e.layout.refElements)nr(t,this),lt(t,this._depGraph);e.layout.clearRefElements()}n=n.children[0]}e.dataScope=new ve(t),this.onChange(_.CHANNEL,"width",e.children[0])}classify(e,t){let r=t||{};console.log("------ classify by",r.attribute," ----"),function(e,t,r,n){let i=G(t);for(let t of i){let i,s={},o=t.children;for(let e of o){let t=e.dataScope.getAttributeValue(r);t in s||(s[t]=[]),s[t].push(e)}let a=Bt(o[0]);for(let o in s){let l=St(e);t.addChild(l),void 0===i&&(i=l.id),l._classId=i,l.dataScope=t.dataScope?t.dataScope.cross(r,o):new ve(a).cross(r,o);for(let e of s[o])l.addChild(e);n&&(l._layout=n.clone(),l._layout.group=l)}}}(this,e,r.attribute,r.layout),ct(e,e.firstChild.firstChild,this._depGraph),ut(e.firstChild,this._depGraph),ht(e.firstChild,e.firstChild.firstChild,this._depGraph),ht(e,e.firstChild,this._depGraph),this.onChange(_.CHANNEL,"width",e.firstChild.firstChild)}affix(e,t,r,n){let i=new rm(e,t,r,n||{});!function(e,t){let r=t.getVariable(_.CHANNEL,e.channel,e.element),n=t.getVariable(_.CHANNEL,e.channel,e.base),i=t.getVariable(_.AFFIXATION,e),s=t.createOneWayDependency(f.AFFIXER);t.connect(n,s),t.connect(i,s),t.connect(s,r),s.run()}(i,this._depGraph),this._relations.push(i)}align(e,t,r){let n=new cm(e,t,r);!function(e,t){let r=t.createMultiWayDependency(f.ALIGNER),n=t.getVariable(_.ALIGNMENT,e);t.connect(n,r);for(let n of e.elements){let i=t.getVariable(_.CHANNEL,e.channel,n);t.connect(i,r)}r.run()}(n,this._depGraph),this._relations.push(n)}encode(e,t){if("rowId"===t.attribute&&(t.attribute=Mt),function(e,t){if(!e||!("channel"in t)||!("attribute"in t))throw new Error("Incomplete information to do encoding. You must specify an item, a categorical data attribute and a data table");let r=Bt(e);if(r.tree){let e=t.attribute;if(e.indexOf(".")>0&&!r.tree.nodeTable.hasAttribute(e.split(".")[1]))throw new Error("Data attribute does not exist in the data table")}else if(!r||!r.hasAttribute(t.attribute))throw new Error("Data attribute does not exist in the data table");if(!Object.values(Be).includes(t.channel))throw new Error("Channel Not Supported")}(e,t),t.shareScale){let e=t.shareScale;if(e.channel!=t.channel&&e.channel.indexOf("Color")<0&&t.channel.indexOf("Color")<0)throw new Error("Cannot share scales between "+e.channel+" and "+t.channel+" encodings");t.scheme=t.shareScale.colorScheme}!function(e){let t;"vertex"===e.type&&e.parent.type===Lt.Area?t=e.parent:e.type===Lt.Area&&(t=e),t&&!t._refBounds&&G(t).forEach((e=>e._refBounds=e.bounds.clone()))}(e);let r=t.aggregator?t.aggregator:"sum";console.log("------ encode",t.channel,t.attribute," --");let n=ze(e,t.channel);if(n&&t.attribute!==n.attribute){Me(n,this),at(n,this._depGraph);for(let e of n.refElements)nr(e,this),lt(e,this._depGraph);n.clearRefElements()}let i=new Zy(e,t.channel,t.attribute,r,t);return this._addAttributeEncoding(i),function(e,t,r){let n=e.attribute,i=e.channel,s=e.element,o=t.createOneWayDependency(f.ENCODER);if(["width","height"].includes(e.channel)&&s.type===Lt.Area){let e=t.getVariable(_.PROPERTY,it.BASE_LINE,s);t.connect(e,o)}if(r){let n=t.getVariable(_.DOMAIN,r),a=t.getVariable(_.SCALE,r),l=t.getVariable(_.CHANNEL,i,s);t.connect(a,o),t.connect(o,l),n.addLinkedEncoding(e),a.addLinkedEncoding(e),n.incomingDataflow.run()}else{let r=t.getVariable(_.ATTRIBUTE,n,Bt(s)),a=t.getVariable(_.PROPERTY,it.INCLUDE_ZERO,e),l=t.getVariable(_.DOMAIN,e),u=t.getVariable(_.DATASCOPE,s),c=t.createOneWayDependency(f.DOMAIN_BUILDER);t.connect(r,c),t.connect(a,c),t.connect(u,c),t.connect(c,l),c.run();let h=t.getVariable(_.PROPERTY,it.RANGE_START,e),d=t.getVariable(_.PROPERTY,it.RANGE_EXTENT,e),p=t.getVariable(_.PROPERTY,it.FLIP_SCALE,e),g=t.getVariable(_.SCALE,e),y=t.createOneWayDependency(f.SCALE_BUILDER);t.connect(h,y),t.connect(d,y),t.connect(p,y),t.connect(l,y),t.connect(y,g),y.run();let m=t.getVariable(_.CHANNEL,i,s);t.connect(g,o),t.connect(o,m),o.run()}}(i,this._depGraph,t.shareScale),t.shareScale?this.onChange(_.DOMAIN,i):this.onChange(_.CHANNEL,t.channel,e),i}_addAttributeEncoding(e){let t=Fe(e.element);t in this._encodings||(this._encodings[t]={}),this._encodings[t][e.channel]=e}activate(e,t,r,n,i){!function(e,t,r,n,i){if(!("event"in e)||!("type"in e))throw"Event and trigger must be specified";if(![y.WIDGET,y.KEYBOARD].includes(e.type)){if(!("target"in t)||!("targetChannels"in t))throw"Target must be specified";if("function"!=typeof r)throw"Target evaluator must be a function"}if(e.type===y.ELEMENT&&!("element"in e))throw"Element must be specified for trigger";if(Array.isArray(n)){if(!n.every((e=>"function"==typeof e)))throw"Effect setter must be a function";if(i&&!Array.isArray(i))throw"An array of effect setters must be accompanied by an array of animation effects";if(i&&Array.isArray(i)&&i.length!==n.length)throw"the length of effect setters is not equal to the length of animation effects"}else if("function"!=typeof n)throw"Effect setter must be a function"}(e,t,r,n,i);let s=e.event,o=function(e){switch(e.type){case y.ELEMENT:return[e.type,e.element.classId?e.element.classId:e.element.id].join("-");case y.ATTRIBUTE:return[e.type].join("-");case y.WIDGET:return[e.type,e.event,e.listener?e.listener.id:"scene",e.id?e.id:""].join("-");case y.MOUSE:return[e.type,e.event,e.listener?e.listener.id:"scene"].join("-");case y.KEYBOARD:return[e.type,e.event,e.key].join("-");default:return[e.type,e.event].join("-")}}(e);if(s=0===s.indexOf("brush")?"brush":s,s in this._triggers||(this._triggers[s]={}),o in this._triggers[s]||(this._triggers[s][o]=function(e){switch(e.type){case y.ELEMENT:return new _m(e.type,e.event,e.element,"cumulative"in e&&e.cumulative);case y.MOUSE:return new ym(e.type,e.event,e.listener);case y.KEYBOARD:return new gm(e.type,e.event,e.key);case y.WIDGET:return new mm(e.type,e.event,e.id)}}(e)),this._triggers[s][o].animation=i,![y.WIDGET,y.KEYBOARD].includes(e.type)){let e=this._triggers[s][o],i=new $y(e,t,r,n);return function(e,t,r){let n=e.target,i=r.getVariable(_.COND_ENCODING,e);for(let s of t){let t=r.getVariable(_.TRIGGER,e.trigger),o=r.findIncomingDataflowOperator(f.TARGET_EVALUATOR,i);o||(o=r.createOneWayDependency(f.TARGET_EVALUATOR,e._targetEval)),r.connect(t,o),r.connect(o,i);let a=r.getVariable(_.CHANNEL,s,n),l=a.incomingDataflow;if(l&&l instanceof rt&&l.outputVar.channel===s)r.connect(i,l);else if(!l){let e=r.createOneWayDependency(f.ENCODER);r.connect(i,e),r.connect(e,a),e.storeValues(n,s)}}}(i,t.targetChannels,this._depGraph),i}this._triggers[s][o].callback=n}onChange(e,...t){if(Object.values(_).indexOf(e)<0)throw new Error("Unknown Variable Type: "+e);let r=[];this._depGraph.processChange(e,r,...t);for(let e of r)e.run()}gridlines(e,t,r){let n=r||{},i=n.element?ze(n.element,e):je(t,e,this);if(i){i.attribute!==t&&console.warn("Cannot create a "+e+" axis for "+t);let r=[];if("x"==e)for(let e of i.scales)r.push({scale:e,elems:i.getElements(e)});else if("width"==e){let e=X(i.element),t=i.scales[0];if(e.layout&&e.layout.type==Q.GRID&&e.layout.numCols>1){let n=e.layout.getElementsByCol(!0);for(let e of n)r.push({scale:t,elems:e})}else r.push({scale:i.scales[0],elems:i.getElements(i.scales[0])})}else if("y"==e){let e=X(i.element);if(e.layout&&e.layout.type==Q.GRID&&e.layout.numRows>1){let t=e.layout.getElementsByRow(!0,i.element);for(let e of t)r.push({scale:i.getScale(e[0]),elems:e})}else r.push({scale:i.scales[0],elems:i.getElements(i.scales[0])})}else if("height"==e){let e=X(i.element),t=i.scales[0];if(e.layout&&e.layout.type==Q.GRID&&e.layout.numRows>1){let n=e.layout.getElementsByRow(!0,i.element);for(let e of n)r.push({scale:t,elems:e})}else r.push({scale:t,elems:i.getElements(t)})}else"radialDistance"==e&&r.push({scale:i.scales[0],elems:G(i.element)});for(let e of r){let t=new Jy(i.channel,i.attribute,e.scale,e.elems,n);this.addChild(t),i.addRefElement(t),yt(t,this._depGraph),ht(this,t,this._depGraph)}}else{let r=n.element?n.element:U(this,t);if(!r)return void console.warn("Cannot create "+e+" gridlines for "+t);let i=H(r.parent);if(!i.layout)return void console.warn("Cannot create "+e+" gridlines for "+t);let s=G(i);for(let r of s){let i=[];r.layout.type==Q.GRID&&r.layout.numRows>1&&"x"==e?i=r.layout.getElementsByRow():r.layout.type==Q.GRID&&r.layout.numCols>1&&"y"==e?i=r.layout.getElementsByCol():i.push(r.children);for(let s of i){let i=new Jy(e,t,null,s,n);this.addChild(i),r.layout.addRefElement(i),yt(i,this._depGraph),ht(this,i,this._depGraph)}}}}axis(e,t,r){let n=r||{},i="rowId"==t?Mt:t,s=[],o=n.element?ze(n.element,e):je(i,e,this);if(o){o.attribute!==i&&console.warn("Cannot create a "+e+" axis for "+i);let t=[];if("x"==e||"width"==e){let e=X(o.element);if(e.layout&&e.layout.type==Q.GRID&&e.layout.numCols>1){let r=e.layout.getElementsByCell(!0,o.element);for(let e of r)t.push({scale:o.getScale(e[0]),elems:e})}else t.push({scale:o.scales[0],elems:o.getElements(o.scales[0])})}else if("y"==e||"height"==e){let e=X(o.element);if(e.layout&&e.layout.type==Q.GRID&&e.layout.numRows>1){let r=e.layout.getElementsByCell(!0,o.element);for(let e of r)t.push({scale:o.getScale(e[0]),elems:e})}else t.push({scale:o.scales[0],elems:o.getElements(o.scales[0])})}else"radialDistance"==e&&t.push({scale:o.scales[0],elems:G(o.element)});for(let e of t){let t=new ir(o,e.scale,e.elems,n);this.addChild(t),s.push(t),o.addRefElement(t),gt(t,this._depGraph),ht(this,t,this._depGraph),this.onChange(_.PROPERTY,it.AXIS_PATH_POSITION,t)}}else{let t=n.element?n.element:U(this,i);if(!t)return void console.warn("Cannot create a "+e+" axis for "+i);let r=H(t.parent);if(!r.layout)return void console.warn("Cannot create a "+e+" axis for "+i);let o=G(r);for(let t of o){let r=[];t.layout.type==Q.GRID&&t.layout.numRows>1&&"x"==e?r=t.layout.getElementsByRow():t.layout.type==Q.GRID&&t.layout.numCols>1&&"y"==e?r=t.layout.getElementsByCol():r.push(t.children);for(let o of r){let r=new sr(o,e,i,n);this.addChild(r),s.push(r),t.layout.addRefElement(r),_t(r,this._depGraph),ht(this,r,this._depGraph),this.onChange(_.PROPERTY,it.AXIS_PATH_POSITION,r)}}}return s}legend(e,t,r){let n=r||{},i="rowId"==t?Mt:t,s=n.element?ze(n.element,e):je(i,e,this);if(s){s.attribute!==t&&console.warn("Cannot create a "+e+" legend for "+t);let r="string"===Bt(s.element).getAttributeType(t)?new am(s,n):new lm(s,n);this.addChild(r),function(e,t){let r=t.getVariable(_.BOUNDS,e),n=t.getVariable(_.PROPERTY,it.LEGEND_POSITION,e),i=t.getIncomingDataflowOperator(f.EVAL_BBOX,r);t.connect(n,i),t.connect(i,r)}(r,this._depGraph),ht(this,r,this._depGraph),I(r),this.onChange(_.PROPERTY,it.LEGEND_POSITION,r)}else console.warn("Cannot create a "+e+" legend for "+i)}setLayout(e,t){if(e.layout&&(ft(e,e.layout,this._depGraph),t.type===Q.TREEMAP)){let t=e.firstChild;for(;t&&t.type===Lt.Collection&&t.layout;)ft(t,t.layout,this._depGraph),t=t.firstChild}if(G(e).forEach((e=>{let r=t?t.clone():t;e._layout=r,r&&(r.group=e)})),pt(e,t,this._depGraph),e.children&&e.children.length>0){let t=Z(e,!0);for(let e of t)this.onChange(_.CHANNEL,"x",e)}}setProperties(e,t,r){let n=r?[e]:G(e);n.forEach((e=>{for(const[r,n]of Object.entries(t))Ke(e,r,n)})),"width"in t&&n.forEach((e=>e._refBounds.setWidth(t.width))),"height"in t&&n.forEach((e=>e._refBounds.setHeight(t.height)));for(let r in t)["vertex","segment"].includes(e.type)&&!["x","y"].includes(r)||(Object.values(Be).includes(r)?this.onChange(_.CHANNEL,r,e):this.onChange(_.PROPERTY,r,e))}setLayoutParameters(e,t){let r=G(e);for(let e of r)for(let r in t)e.layout[r]=t[r];this.onChange(_.CHANNEL,"width",e.firstChild)}sortChildren(e,t,r,n){if(e instanceof mt)nm(e,t,r,n),this.onChange(_.ORDER,e);else if(e instanceof ce){let i=G(e);for(let e of i)im(e,t,r,n)}}findElements(e){return F(this,e)}translate(e,t,r){Xe(e,t,r);let n=Z(e,!0);for(let e of n)I(e);for(let e of n)this.onChange(_.CHANNEL,"x",e)}transform(e,t,r){let n=t.clone();switch(e){case"bin":!function(e,t,r,n,i){let s=i.getVariable(_.ATTRIBUTE,e,r),o=i.getVariable(_.ATTRIBUTE,t,n),a=i.createOneWayDependency(f.BIN_TRANSFORMER);i.connect(s,a),i.connect(a,o),a.run()}(r.attribute,r.newAttribute,t,n,this._depGraph);break;case"filter":!function(e,t,r,n){let i=n.getVariable(_.ITEMS,void 0,t),s=n.getVariable(_.ITEMS,e,r),o=n.createOneWayDependency(f.FILTER_TRANSFORMER);n.connect(i,o),n.connect(o,s),o.run()}(c(r),t,n,this._depGraph);break;case"kde":!function(e,t,r,n,i,s){let o=s.getVariable(_.ATTRIBUTE,e,r),a=s.getVariable(_.ATTRIBUTE,t,n),l=s.createOneWayDependency(f.KDE_TRANSFORMER);l.args=i,s.connect(o,l),s.connect(l,a),l.run()}(r.attribute,r.newAttribute,t,n,r,this._depGraph)}return n}}function vm(e,t){let r=new ve(t.tables[e.dt]);for(let t in e.attr2value)r._attr2value[t]=e.attr2value[t],r._updateTuples(t,e.attr2value[t]);return r}class xm extends J{constructor(e){super(),this.type=Q.DIRECTED,this._width="width"in e?e.width:500,this._height="height"in e?e.height:300,this._top="top"in e?e.top:0,this._left="left"in e?e.left:0,this._edgeSep="edgeSep"in e?e.edgeSep:50,this._spreadLinks=!("spreadLinks"in e)||e.spreadLinks,this._direction="direction"in e?e.direction:se.Top2Bottom}clone(){return new xm({width:this._width,height:this._height,top:this._top,left:this._left,edgeSep:this._edgeSep,spreadLinks:this._spreadLinks,direction:this._direction})}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get edgeSep(){return this._edgeSep}get spreadLinks(){return this._spreadLinks}get direction(){return this._direction}}class Em extends J{constructor(e){super(),this.type=Q.FORCE,this._x="x"in e?e.x:0,this._y="y"in e?e.y:0,this._iterations="iterations"in e?e.iterations:1,this._repulsion="repulsion"in e?e.repulsion:30,this._attraction="attraction"in e?e.attraction:1,this._linkDistance="linkDistance"in e?e.linkDistance:30}clone(){return new Em({x:this._x,y:this._y,iterations:this._iterations,repulsion:this._repulsion,attraction:this._attraction,linkDistance:this._linkDistance})}}class wm extends J{constructor(e){super(),this.type=Q.PACKING,this._x="x"in e?e.x:400,this._y="y"in e?e.y:400,this._width=e.width,this._height=e.height}clone(){return new wm({x:this._x,y:this._y,width:this._width,height:this._height})}}class Am extends J{constructor(e){super(),this.type=Q.TIDYTREE,this._width="width"in e?e.width:500,this._height="height"in e?e.height:500,this._left="left"in e?e.left:100,this._top="top"in e?e.top:100,this._orientation="orientation"in e?e.orientation:ie.HORIZONTAL}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}get orientation(){return this._orientation}clone(){return new Am({width:this._width,height:this._height,top:this._top,left:this._left,orientation:this._orientation})}}class Cm extends J{constructor(e){super(),this.type=Q.TREEMAP,this._width=e.width,this._height=e.height,this._left=e.left,this._top=e.top}get width(){return this._width}get height(){return this._height}get top(){return this._top}get left(){return this._left}clone(){return new Cm({width:this._width,height:this._height,top:this._top,left:this._left})}}function Rm(e){switch(e.type){case Q.GRID:return function(e){let t=new sm(e.args);return t._left=e.left,t._top=e.top,t._cellBounds=e.cellBounds.map((e=>km(e))),t._grid=e.grid,t}(e);case Q.STACK:return function(e){let t=new Qy(e.args);return t}(e);case Q.PACKING:return function(e){let t=new wm(e.args);return t}(e);case Q.FORCE:return function(e){return new Em(e.args)}(e);case Q.DIRECTED:return function(e){return new xm(e.args)}(e);case Q.TIDYTREE:return function(e){return new Am(e.args)}(e);case Q.TREEMAP:return function(e){return new Cm(e.args)}(e);case Q.STRATA:return function(e){return new hm(e.args)}(e);default:return void console.warn("unsupported layout type for deserialization:",e.type)}}function km(e){return new k(e.x-e.width/2,e.y-e.height/2,e.width,e.height)}function Tm(e,t){e.type===Lt.Pie&&(e.type=Lt.Arc),e.args.type=e.type;let r=Tt(e.args);return e.id&&(r._id=e.id),e.classId&&(r._classId=e.classId),e.dataScope&&(r._dataScope=vm(e.dataScope,t)),e.bounds&&(r._bounds=km(e.bounds)),e.refBounds&&(r._refBounds=km(e.refBounds)),function(e,t,r){if(e.vertices){const n=[];for(let i of e.vertices){const e=Sm(i,t,r);n.push(e)}t.vertices=n,t.segments=[];let i=0;for(let e=1;e<t.vertices.length;e++)t.segments.push(new ue(t.vertices[e-1],t.vertices[e],t,i++));t.type===Lt.Rect&&t.segments.push(new ue(t.vertices[t.vertices.length-1],t.vertices[0],t,i++))}t.vertexCounter=e.vertexCounter,t.segmentCounter=e.segmentCounter,t.curveMode=e.curveMode}(e,r,t),r}function Sm(e,t,r){let n=new le(e.x,e.y,t,e.id);return e.dataScope&&(n._dataScope=vm(e.dataScope,r)),"polarAngle"in e&&(n._polarAngle=e.polarAngle),n.shape=e.shape,n.width=e.width,n.height=e.height,n.radius=e.radius,n.fillColor=e.fillColor,n.opacity=e.opacity,n.strokeWidth=e.strokeWidth,n.strokeColor=e.strokeColor,n}function Om(e){let t={};t.fillColor=e.fillColor;let r=new bm(t),n={};if(e.tables)for(let t in e.tables){let r=e.tables[t];n[t]=new Dt(r.data,r.url,r.attributeTypes),n[t]._id=r.id}r.tables=n;let i={};if(e.scales)for(let t in e.scales)i[t]=Vm(e.scales[t]);if(r.scales=i,Lm(e,r,r),Nm(e,r),e.encodings)for(let t of e.encodings)r._addAttributeEncoding(Pm(t,r));return delete r.tables,delete r.scales,r._bounds=km(e.bounds),r}function Im(e,t,r){if(e.type===Lt.Collection){let n=St(r);t.addChild(n),Lm(e,n,r),r._itemMap[n.id]=n}else if(e.type===Lt.Glyph){let n=Ot();t.addChild(n),Lm(e,n,r),r._itemMap[n.id]=n}else if(e.type===Lt.Composite){let n=new um;t.addChild(n),Lm(e,n,r),r._itemMap[n.id]=n,n._bounds=km(e.bounds)}else if(Object.values(M).includes(e.type)){let n=Tm(e,r);r._itemMap[n.id]=n,t.addChild(n)}}function Nm(e,t){if(e.children)for(let r of e.children)Nm(r,t);else if(Object.values(M).includes(e.type)){let r=t._itemMap[e.id];e.links&&(r.links=e.links.map((e=>t._itemMap[e]))),e.source&&(r.source=t._itemMap[e.source]),e.target&&(r.target=t._itemMap[e.target])}}function Lm(e,t,r){if(e.id&&(t._id=e.id),e.classId&&(t._classId=e.classId),e.dataScope&&(t._dataScope=vm(e.dataScope,r)),t._bounds=km(e.bounds),e.layout&&(t._layout=Rm(e.layout),t._layout.group=t),t._sortBy=e.sortBy,e.children)for(let n of e.children)Im(n,t,r)}function Vm(e){let t=new Xt(e.type,e.args);return t._id=e.id,t.domain=e.domain,t.range=e.range,t}function Pm(e,t){let r=function(e,t,r){if("vertex"===t){let t=e.split("_v_");return r._itemMap[t[0]].vertices.find((e=>e._id===parseInt(t[1])))}if("segment"===t){let t=e.split("_s_");return r._itemMap[t[0]].segments.find((e=>e._id===parseInt(t[1])))}return r._itemMap[e]}(e.element,e.elementType,t);r||console.warn("element not created:",e.element,e.elementType);let n=new Zy(r,e.channel,e.attr,e.aggregator,e.args);if(e.scales&&(n._scales=e.scales.map((e=>t.scales[e]))),e.elemGroups&&(n._elemGroups=e.elemGroups.map((e=>e.map((e=>t._itemMap[e]))))),e.elem2scale){n._elem2scale={};for(let r in e.elem2scale)n._elem2scale[r]=t.scales[e.elem2scale[r]]}return e.args.startAngle&&(n.startAngle=e.args.startAngle),n}function Dm(e){let t={};return t.id=e._id,t.data=e._rawData,t.attributeTypes=e._attrTypes,t.url=e.url,t}function Bm(e){let t={};return t.dt=e._dt.id,t.attr2value=Object.assign({},e._attr2value),t}function Mm(e,t){t.vertices=[];for(let r of e.vertices)t.vertices.push(Gm(r));t.vertexCounter=e.vertexCounter,t.segmentCounter=e.segmentCounter,t.curveMode=e.curveMode}function Gm(e){let t={};return t.type=e.type,t.id=e._id,t.x=e.x,t.y=e.y,e._dataScope&&(t.dataScope=Bm(e._dataScope)),void 0!==e._polarAngle&&(t.polarAngle=e._polarAngle),t.shape=e.shape,t.width=e.width,t.height=e.height,t.radius=e.radius,t.fillColor=e.fillColor,t.opacity=e.opacity,t.strokeWidth=e.strokeWidth,t.strokeColor=e.strokeColor,t}function jm(e){return e.type===Lt.Scene?function(e){let t=Um(e,{});t.fillColor=e.fillColor,t.scales={},t.encodings=[];for(let r in e._encodings)for(let n in e._encodings[r]){let i=e._encodings[r][n];i._forLegend||t.encodings.push(Fm(i));for(let e of i._scales)e.id in t.scales||(t.scales[e.id]=zm(e))}t.tables={};let r=function(e){let t={};for(let r in e._encodings)for(let n in e._encodings[r]){let i=e._encodings[r][n];i.dataTable.id in t||i._forLegend||(t[i.dataTable.id]=i.dataTable)}for(let r of e.children)if(![Lt.Axis,Lt.Legend,Lt.Gridlines].includes(r.type)){if(r.dataScope){t[r.dataScope.dataTable.id]=r.dataScope.dataTable;break}if(r.children&&r.children.length>0){let e=r.firstChild;for(;e;){if(e.dataScope){t[e.dataScope.dataTable.id]=e.dataScope.dataTable;break}e=e.children&&e.children.length>0?e.firstChild:void 0}}}return t}(e);for(let e in r)t.tables[e]=Dm(r[e]);return console.log(t.tables),t}(e):e instanceof mt?Um(e,{}):e instanceof D?function(e){let t={args:{}};t.type=e.type,t.id=e.id,e.classId&&(t.classId=e.classId),e._dataScope&&(t.dataScope=Bm(e._dataScope)),e.bounds&&(t.bounds=e.bounds.toJSON()),e.refBounds&&(t.refBounds=e.refBounds.toJSON()),e.links&&(t.links=e.links.map((e=>e.id))),e.source&&(t.source=e.source.id),e.target&&(t.target=e.target.id);for(let r in e.styles)r.indexOf("Color")>0&&e.styles[r]instanceof P?t.args[r]=e.styles[r].toJSON():t.args[r]=e.styles[r];switch(e.type){case Lt.Arc:case Lt.Pie:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.innerRadius=e._innerRadius,t.args.outerRadius=e._outerRadius,t.args.startAngle=e._startAngle,t.args.endAngle=e._endAngle,t.args.direction=e._direction,t.args.thickness=e._thickness}(e,t),Mm(e,t);break;case Lt.Area:!function(e,t){t.args.baseline=e._baseline,t.args.orientation=e._orientation}(e,t),Mm(e,t);break;case Lt.Circle:!function(e,t){t.args.x=e.x,t.args.y=e.y,t.args.radius=e.radius}(e,t);break;case Lt.Image:break;case Lt.Line:case Lt.Path:case Lt.BezierCurve:Mm(e,t);break;case Lt.PointText:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.text=e._text,t.args.anchor=e._anchor}(e,t);break;case Lt.Polygon:!function(e,t){t.args.x=e._x,t.args.y=e._y,t.args.radius=e._radius}(e,t),Mm(e,t);break;case Lt.Rect:!function(e,t){t.args.width=e.width,t.args.height=e.height,t.args.top=e.top,t.args.left=e.left}(e,t),Mm(e,t);case Lt.Ring:}return t}(e):(console.warn("unsupported serialization",e.type),{type:e.type})}function zm(e){let t={};return t.type=e.type,t.id=e.id,e._args&&(t.args=e._args),t.domain=e.domain,t.range=e.range,t}function Fm(e){let t={};t.element=e._elem.id,t.elementType=e._elem.type,e.attrValues&&(t.attrValues=e.attrValues),t.channel=e._channel,t.attr=e._attribute,t.aggregator=e._aggregator,t.args={},t.args.includeZero=e._includeZero,t.args.flipScale=e._flipScale,t.args.mapping=e._mapping,t.args.rangeExtent=e._preferredRangeExtent,t.args.domain=e._preferredDomain,t.args.scaleType=e._scaleType,t.args.scheme=e._colorScheme,t.scales=e._scales.map((e=>e.id)),t.elemGroups=e._elemGroups.map((e=>e.map((e=>e.id)))),t.elem2scale={};for(let r in e._elem2scale)t.elem2scale[r]=e._elem2scale[r].id;return t.refElements=e._refElements.map((e=>e.id)),"angle"==e.channel&&(t.args.startAngle=e.startAngle),t}function Um(e,t){if(t.id=e.id,t.type=e.type,e.classId&&(t.classId=e.classId),e._dataScope&&(t.dataScope=Bm(e._dataScope)),t.bounds=e.bounds.toJSON(),e._layout&&(t.layout=function(e){switch(e.type){case Q.GRID:return function(e){let t={args:{}};return t.type=e.type,t.args.numCols=e._numCols,t.args.numRows=e._numRows,t.args.start=e._start,t.args.direction=e._direction,t.args.colGap=e._colGap,t.args.rowGap=e._rowGap,t.args.horzCellAlignment=e._cellHorzAlignment,t.args.vertCellAlignment=e._cellVertAlignment,t.left=e._left,t.top=e._top,t.cellBounds=e._cellBounds.map((e=>e.toJSON())),t.group=e.group.id,t.grid=e._grid,t}(e);case Q.STACK:return function(e){let t={args:{}};return t.type=e.type,t.args.orientation=e._orientation,t.args.direction=e._direction,t.args.left=e._left,t.args.top=e._top,t.args.horzCellAlignment=e._horzCellAlignment,t.args.vertCellAlignment=e._vertCellAlignment,t.args.gap=e._gap,t.group=e.group.id,t}(e);case Q.PACKING:return function(e){let t={args:{}};return t.type=e.type,t.args.x=e._x,t.args.y=e._y,t.args.width=e._width,t.args.height=e._height,t.group=e.group.id,t}(e);case Q.FORCE:return function(e){let t={args:{}};return t.type=e.type,t.args.x=e._x,t.args.y=e._y,t.args.iterations=e._iterations,t.args.repulsion=e._repulsion,t.args.attraction=e._attraction,t.args.linkDistance=e._linkDistance,t.group=e.group.id,t}(e);case Q.CLUSTER:return function(e){let t={args:{}};return t.type=e.type,t.args.size=e._size,t.args.rootX=e._rootX,t.args.rootY=e._rootY,t}(e);case Q.DIRECTED:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t.args.edgeSep=e._edgeSep,t.args.spreadLinks=e._spreadLinks,t.args.direction=e._direction,t}(e);case Q.TIDYTREE:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t.args.orientation=e._orientation,t}(e);case Q.TREEMAP:return function(e){let t={args:{}};return t.type=e.type,t.args.left=e._left,t.args.top=e._top,t.args.width=e._width,t.args.height=e._height,t}(e);case Q.STRATA:return function(e){let t={args:{}};return t.type=e.type,t.args.direction=e._direction,t.args.gap=e._gap,t}(e);default:throw new Error("unknow layout type "+e.type)}}(e._layout)),t.children=[],e.children.length>0)for(let r of e.children)t.children.push(jm(r));return t.sortBy=e._sortBy,t}function Hm(e,t){return void 0===e&&void 0===t||void 0!==e&&void 0!==t}function Wm(e,t){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&(0===r.length||r.every((e=>n.includes(e))))}function Ym(e,t){if(!Hm(e.layout,t.layout))return console.log("Not both defined or undefined:",e.bounds,t.bounds),!1;let r=e.layout,n=t.layout;if(!r&&!n)return!0;if(r.type!==n.type)return console.log("layout types are different:",r,n),!1;switch(r.type){case Q.GRID:return function(e,t){e._cellBounds.length!==t._cellBounds.length&&console.log("cell bounds length different:",e,t);for(let r=0;r<e._cellBounds;r++)if(!qm(e._cellBounds[r],t._cellBounds[r]))return console.log("cell bounds not equal:",e,t),!1;for(let r=0;r<e._grid.length;r++)for(let n=0;n<e._grid[r].length;n++)if(e._grid[r][n]!==t._grid[r][n])return console.log("grid not equal",e,t),!1;return e._numCols===t._numCols&&e._numRows===t._numRows&&e._start===t._start&&e._direction===t._direction&&e._rowGap===t._rowGap&&e._colGap===t._colGap&&e._cellHorzAlignment===t._cellHorzAlignment&&e._cellVertAlignment===t._cellVertAlignment&&e._left===t._left&&e._top===t._top}(r,n);case Q.STACK:return function(e,t){return e._orientation===t._orientation&&e._direction===t._direction&&e._left===t._left&&e._top===t._top&&e._horzCellAlignment===t._horzCellAlignment&&e._vertCellAlignment===t._vertCellAlignment&&e._gap===t._gap}(r,n);case Q.PACKING:return function(e,t){return e._x===t._x&&e._y===t._y&&e._width===t._width&&e._height===t._height}(r,n);case Q.FORCE:return function(e,t){return e._x===t._x&&e._y===t._y&&e._iterations===t._iterations&&e._repulsion===t._repulsion&&e._attraction===t._attraction&&e._linkDistance===t._linkDistance}(r,n);case Q.DIRECTED:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left&&e._edgeSep===t._edgeSep&&e._spreadLinks===t._spreadLinks&&e._direction===t._direction}(r,n);case Q.TIDYTREE:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left&&e._orientation===t._orientation}(r,n);case Q.STRATA:return function(e,t){return e._direction===t._direction&&e._gap===t._gap}(r,n);case Q.TREEMAP:return function(e,t){return e._width===t._width&&e._height===t._height&&e._top===t._top&&e._left===t._left}(r,n);default:return!1}}function Xm(e,t){if(!Hm(e.bounds,t.bounds))return console.log("Not both defined or undefined:",e.bounds,t.bounds),!1;let r=e.bounds,n=t.bounds;return!r&&!n||qm(r,n)}function qm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Km(e,t){if(!Hm(e,t))return console.log("Not both defined or undefined:",e,t),!1;if(e.type!==t.type)return console.log("Different mark types:",e,t),!1;if(e.id!==t.id)return console.log("id not equal:",e,t),!1;if(e.classId!==t.classId)return console.log("class id not equal:",e,t),!1;if(!$m(e,t))return console.log("DataScopes not equal",e,t),!1;if(!Xm(e,t))return console.log("Bounds not equal",e,t),!1;if(!Hm(e.links,t.links))return console.log("Not both defined or undefined: links ",e.links,t.links),!1;if(!Hm(e.source,t.source))return console.log("Not both defined or undefined: source ",e.source,t.source),!1;if(!Hm(e.target,t.target))return console.log("Not both defined or undefined: links ",e.target,t.target),!1;if(e.links&&t.links&&e.links.length!==t.links.length)return console.log("unequal number of links",e,t),!1;if(e.source&&t.source&&!Km(e.source,t.source))return console.log("different sources",e.source,t.source),!1;if(e.target&&t.target&&!Km(e.target,t.target))return console.log("different targets",e.target,t.target),!1;switch(e.type){case Lt.Arc:case Lt.Pie:return Zm(e,t)?e.x===t.x&&e.y===t.y&&e.innerRadius===t.innerRadius&&e.outerRadius===t.outerRadius&&e.startAngle===t.startAngle&&e.endAngle===t.endAngle&&e.direction===t.direction&&e.thickness===t.thickness:(console.log("vertices not equal:",e,t),!1);case Lt.Area:return Zm(e,t)?e.baseline===t.baseline&&e.orientation===t.orientation:(console.log("vertices not equal:",e,t),!1);case Lt.Circle:return e.x===t.x&&e.y===t.y&&e.radius===t.radius;case Lt.Image:return console.warn("not implemented"),!0;case Lt.Line:case Lt.Path:case Lt.BezierCurve:return!!Zm(e,t)||(console.log("vertices not equal:",e,t),!1);case Lt.PointText:return e.x===t.x&&e.y===t.y&&e.text===t.text&&e.anchor[0]===t.anchor[0]&&e.anchor[1]===t.anchor[1];case Lt.Polygon:return Zm(e,t)?e.x===t.x&&e.y===t.y&&e.radius===t.radius:(console.log("vertices not equal:",e,t),!1);case Lt.Rect:return Zm(e,t)?e.width===t.width&&e.height===t.height&&e.top===t.top&&e.left===t.left:(console.log("vertices not equal:",e,t),!1);case Lt.Ring:default:return console.warn("not implemented"),!0}}function Zm(e,t){if(e.vertices.length!==t.vertices.length)return console.log("unequal number of vertices:",e,t),!1;for(let r=0;r<e.vertices.length;r++){let n=e.vertices[r],i=t.vertices[r];return n.id!==i.id?(console.log("vertex id not equal:",n,i),!1):n.x!==i.x||n.y!==i.y?(console.log("vertex position not equal:",n,i),!1):$m(n,i)?n._polarAngle===i._polarAngle&&n.shape===i.shape&&n.width===i.width&&n.height==i.height&&n.radius==i.radius&&n.fillColor==i.fillColor&&n.opacity==i.opacity&&n.strokeWidth==i.strokeWidth&&n.strokeColor==i.strokeColor:(console.log("vertex data scopes not equal:",n.dataScope,i.dataScope),!1)}}function $m(e,t){if(!Hm(e.dataScope,t.dataScope))return console.log("Not both defined or undefined:",e.dataScope,t.dataScope),!1;if(!e.dataScope&&!t.dataScope)return!0;let r=e.dataScope,n=t.dataScope;if(!Wm(r._attr2value,n._attr2value))return!1;for(let e in r._attr2value)if(r._attr2value[e]!==n._attr2value[e])return!1;return r._dt.id===n._dt.id&&r._tuples.length===n._tuples.length}function Jm(e,t){return e.type!==t.type&&console.log("Different types:",e.type,t.type),[Lt.Collection,Lt.Glyph,Lt.Composite].includes(e.type)?Qm(e,t):e instanceof D?Km(e,t):void 0}function Qm(e,t){let r=e.children.filter((e=>!Object.values(Vt).includes(e.type))),n=t.children.filter((e=>!Object.values(Vt).includes(e.type)));if(r.length!==n.length)return console.log("children length not equal:",r,n),!1;if(e.id!==t.id)return console.log("id not equal:",e,t),!1;if(e.classId!==t.classId)return console.log("class id not equal:",e,t),!1;if(!$m(e,t))return console.log("DataScopes not equal",e.dataScope,t.dataScope),!1;if(!Xm(e,t))return console.log("Bounds not equal",e,t),!1;if(!Ym(e,t))return console.log("Layouts not equal",e,t),!1;if(!function(e,t){if(!Wm(e,t))return console.log("different keys",e,t),!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}(e._sortBy,t._sortBy))return console.log("SortBy not equal",e,t),!1;for(let e=0;e<r.length;e++)if(!Jm(r[e],n[e]))return console.log("Not equal",r[e],n[e]),!1;return!0}class eb extends J{constructor(e){super(),this.type=Q.CIRCULAR,this._x="x"in e?e.x:100,this._y="y"in e?e.y:100,this._radius="radius"in e?e.radius:100}get x(){return this._x}get y(){return this._y}get radius(){return this._radius}clone(){return new eb({x:this._x,y:this._y,radius:this._radius})}}class tb extends J{constructor(e){super(),this.type=Q.CLUSTER,this._isRadial="radial"in e&&e.radial,this._angleExtent="angleExtent"in e?e.angleExtent:360,this._radius="radius"in e?e.radius:300,this._rootX="x"in e?e.x:300,this._rootY="y"in e?e.y:300,this._orientation="orientation"in e?e.orientation:ie.HORIZONTAL,this._width="width"in e?e.width:800,this._height="height"in e?e.height:600,this._left="left"in e?e.left:60,this._top="top"in e?e.top:100,this._tree="tree"in e?e.tree:void 0}get radius(){return this._radius}get angleExtent(){return this._angleExtent}get x(){return this._rootX}get y(){return this._rootY}get width(){return this._width}get height(){return this._height}get left(){return this._left}get top(){return this._top}isRadial(){return this._isRadial}get orientation(){return this._orientation}clone(){return new tb({radius:this._radius,angleExtent:this._angleExtent,x:this._rootX,y:this._rootY,radial:this._isRadial,orientation:this._orientation,left:this._left,top:this._top,width:this._width,height:this._height,tree:this._tree})}}e.csv=async function(e){return async function(e){let t=await Gt("GET",e),r=n.csvParse(t.trim(),n.autoType);return new Dt(r,e)}(e)},e.deserialize=function(e){return Om(e)},e.graphJSON=async function(e){return async function(e){let t=await Gt("GET",e);return new Ce(JSON.parse(t),e)}(e)},e.isEqual=function(e,t){return function(e,t){return e.fillColor!==t.fillColor?(console.log("fillColor not equal:",e,t),!1):Qm(e,t)}(e,t)},e.layout=function(e,t){let r=t||{};switch(e.toLowerCase()){case Q.STACK:return new Qy(r);case Q.PACKING:return new wm(r);case Q.FORCE:return new Em(r);case Q.DIRECTED:return new xm(r);case Q.TIDYTREE:return new Am(r);case Q.TREEMAP:return new Cm(r);case Q.CIRCULAR:return new eb(r);case Q.CLUSTER:return new tb(r);case Q.GRID:default:return new sm(r)}},e.renderer=function(e,t){return new L(t)},e.scene=function(e){return new bm(e)},e.serialize=function(e){return jm(e)},e.treeJSON=async function(e){return async function(e){let t=await Gt("GET",e);return new we(JSON.parse(t),e)}(e)},Object.defineProperty(e,"__esModule",{value:!0})}));