!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).jsVectorMap=e()}(this,(function(){"use strict";Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),i=e.length;--i>=0&&e.item(i)!==this;);return i>-1}),Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(null==t)throw new TypeError("Cannot convert first argument to object");for(var e=Object(t),i=1;it.length)&&(e=t.length);for(var i=0,s=new Array(e);i=t.length?{done:!0}:{done:!1,value:t[s++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var x=function(){function t(){}return t.prototype.dispose=function(){this._tooltip?c(this._tooltip):this.shape.remove();for(var t,e=k(Object.getOwnPropertyNames(this));!(t=e()).done;){this[t.value]=null}},t}(),M={getLabelText:function(t,e){if(e){if("function"==typeof e.render){var i=[];return this.config&&this.config.marker&&i.push(this.config.marker),i.push(t),e.render.apply(this,i)}return t}},getLabelOffsets:function(t,e){return"function"==typeof e.offsets?e.offsets(t):Array.isArray(e.offsets)?e.offsets[t]:[0,0]},setStyle:function(t,e){this.shape.setStyle(t,e)},remove:function(){this.shape.remove(),this.label&&this.label.remove()},hover:function(t){this._setStatus("isHovered",t)},select:function(t){this._setStatus("isSelected",t)},_setStatus:function(t,e){this.shape[t]=e,this.shape.updateStyle(),this[t]=e,this.label&&(this.label[t]=e,this.label.updateStyle())}},j=function(t){function e(e){var i,s=e.map,a=e.code,n=e.path,r=e.style,o=e.label,h=e.labelStyle,l=e.labelsGroup;(i=t.call(this)||this)._map=s,i.shape=i._createRegion(n,a,r);var c=i.shape.getBBox(),u=i.getLabelText(a,o);if(o&&u){var p=i.getLabelOffsets(a,o);i.labelX=c.x+c.width/2+p[0],i.labelY=c.y+c.height/2+p[1],i.label=i._map.canvas.createText({text:u,textAnchor:"middle",alignmentBaseline:"central",dataCode:a,x:i.labelX,y:i.labelY},h,l),i.label.addClass("jvm-region jvm-element")}return i}b(e,t);var i=e.prototype;return i._createRegion=function(t,e,i){return(t=this._map.canvas.createPath({d:t,dataCode:e},i)).addClass("jvm-region jvm-element"),t},i.updateLabelPosition=function(){this.label&&this.label.set({x:this.labelX*this._map.scale+this._map.transX*this._map.scale,y:this.labelY*this._map.scale+this._map.transY*this._map.scale})},e}(x);d(j,M);var C=function(t){function e(e){var i,s=e.index,a=e.map,n=e.style,r=e.x1,o=e.y1,h=e.x2,l=e.y2,c=e.group,u=e.config;return(i=t.call(this)||this).config=u,i.shape=a.canvas.createLine({x1:r,y1:o,x2:h,y2:l,dataIndex:s},n,c),i.shape.addClass("jvm-line"),i}return b(e,t),e.prototype.setStyle=function(t,e){this.shape.setStyle(t,e)},e}(x);var L=function(t){function e(e){var i,s=e.index,a=e.style,n=e.label,r=e.cx,o=e.cy,h=e.map,l=e.group;return(i=t.call(this)||this)._map=h,i._isImage=!!a.initial.image,i.config=arguments[0],i.shape=h.canvas[i._isImage?"createImage":"createCircle"]({dataIndex:s,cx:r,cy:o},a,l),i.shape.addClass("jvm-marker jvm-element"),i._isImage&&i.updateLabelPosition(),n&&i._createLabel(i.config),i}b(e,t);var i=e.prototype;return i.updateLabelPosition=function(){this.label&&this.label.set({x:this._labelX*this._map.scale+this._offsets[0]+this._map.transX*this._map.scale+5+(this._isImage?(this.shape.width||0)/2:this.shape.node.r.baseVal.value),y:this._labelY*this._map.scale+this._map.transY*this._map.scale+this._offsets[1]})},i._createLabel=function(t){var e=t.index,i=t.map,s=t.label,a=t.labelsGroup,n=t.cx,r=t.cy,o=t.marker,h=t.isRecentlyCreated,l=this.getLabelText(e,s);this._labelX=n/i.scale-i.transX,this._labelY=r/i.scale-i.transY,this._offsets=h&&o.offsets?o.offsets:this.getLabelOffsets(e,s),this.label=i.canvas.createText({text:l,dataIndex:e,x:this._labelX,y:this._labelY,dy:"0.6ex"},i.params.markerLabelStyle,a),this.label.addClass("jvm-marker jvm-element"),h&&this.updateLabelPosition()},e}(x);d(L,M);var O=function(){function t(t){void 0===t&&(t={}),this._options=t,this._map=this._options.map,this._series=this._options.series,this._body=l("div","jvm-legend"),this._options.cssClass&&this._body.setAttribute("class",this._options.cssClass),t.vertical?this._map.legendVertical.appendChild(this._body):this._map.legendHorizontal.appendChild(this._body),this.render()}return t.prototype.render=function(){var t,e,i,s,a=this._series.scale.getTicks(),n=l("div","jvm-legend-inner");if(this._body.innderHTML="",this._options.title){var r=l("div","jvm-legend-title",this._options.title);this._body.appendChild(r)}this._body.appendChild(n);for(var o=0;o>10||1,e*=75;var s=i.container.getBoundingClientRect(),n=t.pageX-s.left-window.pageXOffset,r=t.pageY-s.top-window.pageYOffset,o=Math.pow(1+a.params.zoomOnScrollSpeed/1e3,-1.5*e);a.tooltip&&a.tooltip.hide(),a._setScale(a.scale*o,n,r),t.preventDefault()}))},_setupElementEvents:function(){var t,e,i,s=this,a=this.container;g.on(a,"mousemove",(function(s){Math.abs(t-s.pageX)+Math.abs(e-s.pageY)>2&&(i=!0)})),g.delegate(a,"mousedown",".jvm-element",(function(s){t=s.pageX,e=s.pageY,i=!1})),g.delegate(a,"mouseover mouseout",".jvm-element",(function(t){var e=y(s,this,!0),i=s.params.showTooltip;"mouseover"===t.type?(e.element.hover(!0),s.tooltip.text(e.tooltipText),s._emit(e.event,[t,s.tooltip,e.code]),t.defaultPrevented||i&&s.tooltip.show()):(e.element.hover(!1),i&&s.tooltip.hide())})),g.delegate(a,"mouseup",".jvm-element",(function(t){var e=y(s,this);if(!i&&("region"===e.type&&s.params.regionsSelectable||"marker"===e.type&&s.params.markersSelectable)){var a=e.element;s.params[e.type+"sSelectableOne"]&&s._clearSelected(e.type+"s"),e.element.isSelected?a.select(!1):a.select(!0),s._emit(e.event,[e.code,a.isSelected,s._getSelected(e.type+"s")])}})),g.delegate(a,"click",".jvm-element",(function(t){var e=y(s,this),i=e.type,a=e.code;s._emit("region"===i?v.onRegionClick:v.onMarkerClick,[t,a])}))},_setupZoomButtons:function(){var t=this,e=this,i=l("div","jvm-zoom-btn jvm-zoomin","+",!0),s=l("div","jvm-zoom-btn jvm-zoomout","−",!0);this.container.appendChild(i),this.container.appendChild(s),g.on(i,"click",(function(){t._setScale(e.scale*e.params.zoomStep,e.width/2,e.height/2,!1,e.params.zoomAnimate)})),g.on(s,"click",(function(){t._setScale(e.scale/e.params.zoomStep,e.width/2,e.height/2,!1,e.params.zoomAnimate)}))},_setupContainerTouchEvents:function(){var t,e,i,s,a,n,r,o=this,h=function(h){var l,c,u,p,d=h.touches;if("touchstart"==h.type&&(r=0),1==d.length)1==r&&(u=o.transX,p=o.transY,o.transX-=(i-d[0].pageX)/o.scale,o.transY-=(s-d[0].pageY)/o.scale,o.tooltip.hide(),o._applyTransform(),u==o.transX&&p==o.transY||h.preventDefault()),i=d[0].pageX,s=d[0].pageY;else if(2==d.length)if(2==r)c=Math.sqrt(Math.pow(d[0].pageX-d[1].pageX,2)+Math.pow(d[0].pageY-d[1].pageY,2))/e,o._setScale(t*c,a,n),o.tooltip.hide(),h.preventDefault();else{var f=o.container.selector.getBoundingClientRect();l={top:f.top+window.scrollY,left:f.left+window.scrollX},a=d[0].pageX>d[1].pageX?d[1].pageX+(d[0].pageX-d[1].pageX)/2:d[0].pageX+(d[1].pageX-d[0].pageX)/2,n=d[0].pageY>d[1].pageY?d[1].pageY+(d[0].pageY-d[1].pageY)/2:d[0].pageY+(d[1].pageY-d[0].pageY)/2,a-=l.left,n-=l.top,t=o.scale,e=Math.sqrt(Math.pow(d[0].pageX-d[1].pageX,2)+Math.pow(d[0].pageY-d[1].pageY,2))}r=d.length};g.on(o.container,"touchstart",h),g.on(o.container,"touchmove",h)},_createRegions:function(){var t,e;for(t in this._regionLabelsGroup=this._regionLabelsGroup||this.canvas.createGroup("jvm-regions-labels-group"),this.mapData.paths)e=new j({map:this,code:t,path:this.mapData.paths[t].path,style:u({},this.params.regionStyle),labelStyle:this.params.regionLabelStyle,labelsGroup:this._regionLabelsGroup,label:this.params.labels&&this.params.labels.regions}),this.regions[t]={config:this.mapData.paths[t],element:e}},_createLines:function(t,e,i){void 0===i&&(i=!1);var s=!1,a=!1;for(var n in this.linesGroup=this.linesGroup||this.canvas.createGroup("jvm-lines-group"),t){var r=t[n];for(var o in e){var h=i?e[o].config:e[o];h.name===r.from&&(s=this.getMarkerPosition(h)),h.name===r.to&&(a=this.getMarkerPosition(h))}!1!==s&&!1!==a&&(this.lines[p(r.from,r.to)]=new C({index:n,map:this,style:u({initial:this.params.lineStyle},{initial:r.style||{}},!0),x1:s.x,y1:s.y,x2:a.x,y2:a.y,group:this.linesGroup,config:r}))}},_createMarkers:function(t,e){var i,s,a,n,r=this;for(var o in void 0===t&&(t={}),void 0===e&&(e=!1),this._markersGroup=this._markersGroup||this.canvas.createGroup("jvm-markers-group"),this._markerLabelsGroup=this._markerLabelsGroup||this.canvas.createGroup("jvm-markers-labels-group"),t)if(i=t[o],a=this.getMarkerPosition(i),n=i.coords.join(":"),a){if(e){if(Object.keys(this.markers).filter((function(t){return r.markers[t]._uid===n})).length)continue;o=Object.keys(this.markers).length}s=new L({index:o,map:this,style:u(this.params.markerStyle,{initial:i.style||{}},!0),label:this.params.labels&&this.params.labels.markers,labelsGroup:this._markerLabelsGroup,cx:a.x,cy:a.y,group:this._markersGroup,marker:i,isRecentlyCreated:e}),this.markers[o]&&this.removeMarkers([o]),this.markers[o]={_uid:n,config:i,element:s}}},_createSeries:function(){for(var t in this.series={markers:[],regions:[]},this.params.series)for(var e=0;ee?this.transY=e:this.transYt?this.transX=t:this.transXthis.defaultWidth/this.defaultHeight?(this.baseScale=this.height/this.defaultHeight,this.baseTransX=Math.abs(this.width-this.defaultWidth*this.baseScale)/(2*this.baseScale)):(this.baseScale=this.width/this.defaultWidth,this.baseTransY=Math.abs(this.height-this.defaultHeight*this.baseScale)/(2*this.baseScale)),this.scale*=this.baseScale/t,this.transX*=this.baseScale/t,this.transY*=this.baseScale/t},_setScale:function(t,e,i,s,a){var n,r,o,h,l,c,u,p,d,f,m=this,g=0,y=Math.abs(Math.round(60*(t-this.scale)/Math.max(t,this.scale)));t>this.params.zoomMax*this.baseScale?t=this.params.zoomMax*this.baseScale:t0?(o=this.scale,h=(t-o)/y,l=this.transX*this.scale,u=this.transY*this.scale,c=(d*t-l)/y,p=(f*t-u)/y,r=setInterval((function(){g+=1,m.scale=o+h*g,m.transX=(l+c*g)/m.scale,m.transY=(u+p*g)/m.scale,m._applyTransform(),g==y&&(clearInterval(r),m._emit(v.onViewportChange,[m.scale,m.transX,m.transY]))}),10)):(this.transX=d,this.transY=f,this.scale=t,this._applyTransform(),this._emit(v.onViewportChange,[this.scale,this.transX,this.transY]))},setFocus:function(t){var e=this;void 0===t&&(t={});var i,s=[];if(t.region?s.push(t.region):t.regions&&(s=t.regions),s.length)return s.forEach((function(t){if(e.regions[t]){var s=e.regions[t].element.shape.getBBox();s&&(i=void 0===i?s:{x:Math.min(i.x,s.x),y:Math.min(i.y,s.y),width:Math.max(i.x+i.width,s.x+s.width)-Math.min(i.x,s.x),height:Math.max(i.y+i.height,s.y+s.height)-Math.min(i.y,s.y)})}})),this._setScale(Math.min(this.width/i.width,this.height/i.height),-(i.x+i.width/2),-(i.y+i.height/2),!0,t.animate);if(t.coords){var a=this.coordsToPoint(t.coords[0],t.coords[1]),n=this.transX-a.x/this.scale,r=this.transY-a.y/this.scale;return this._setScale(t.scale*this.baseScale,n,r,!0,t.animate)}},updateSize:function(){this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this._resize(),this.canvas.setSize(this.width,this.height),this._applyTransform()},coordsToPoint:function(t,e){var i,s,a,n=V.maps[this.params.map].projection,r=n.centralMeridian;return i=Y[n.type](t,e,r),!!(s=this.getInsetForPoint(i.x,i.y))&&(a=s.bbox,i.x=(i.x-a[0].x)/(a[1].x-a[0].x)*s.width*this.scale,i.y=(i.y-a[0].y)/(a[1].y-a[0].y)*s.height*this.scale,{x:i.x+this.transX*this.scale+s.left*this.scale,y:i.y+this.transY*this.scale+s.top*this.scale})},getInsetForPoint:function(t,e){var i,s,a=V.maps[this.params.map].insets;for(i=0;i(s=a[i].bbox)[0].x&&ts[0].y&&ethis.max&&(this.max=e),e-1)})),this.markers,!0)},e.removeLines=function(t){var e=this;(t=Array.isArray(t)?t.map((function(t){return p(t.from,t.to)})):this._getLinesAsUids()).forEach((function(t){e.lines[t].dispose(),delete e.lines[t]}))},e._getLinesAsUids=function(){return Object.keys(this.lines)},e.removeLine=function(t,e){console.warn("`removeLine` method is deprecated, please use `removeLines` instead.");var i=p(t,e);this.lines.hasOwnProperty(i)&&(this.lines[i].element.remove(),delete this.lines[i])},e.reset=function(){for(var t in this.series)for(var e=0;e