UNPKG

basb-cli

Version:
2 lines (1 loc) 31.9 kB
import{J as e,bP as t,G as o,R as n,a3 as i,cc as r,b6 as a,as as s,cd as l,am as p,ak as u,a8 as c,ce as g,aV as h,cf as d,$ as f,e as m,m as v,cg as y,ch as _,ci as b,bF as S,bE as w,bG as x,b8 as M,Z as G,b1 as F,cj as A,ck as C,cl as T,X as R,cm as N,u as D,ad as I,ac as O,h as k,ab as L,k as P,j,g as V,cn as B,o as z,co as J,cp as U,_ as X,w as Y,U as E,A as H,bt as Z,b4 as W,aY as q,E as K,ap as $,cq as Q,cr as ee,ao as te,cs as oe,aJ as ne,I as ie,bV as re,ct as ae,bU as se}from"./index.js";import{u as le,a as pe,V as ue,b as ce}from"./roamHelper.js";import{R as ge}from"./RoamController.js";import{o as he}from"./cursorHelper.js";function de(t){e(t)&&(t=(new DOMParser).parseFromString(t,"text/xml"));var o=t;for(9===o.nodeType&&(o=o.firstChild);"svg"!==o.nodeName.toLowerCase()||1!==o.nodeType;)o=o.nextSibling;return o}var fe,me={fill:"fill",stroke:"stroke","stroke-width":"lineWidth",opacity:"opacity","fill-opacity":"fillOpacity","stroke-opacity":"strokeOpacity","stroke-dasharray":"lineDash","stroke-dashoffset":"lineDashOffset","stroke-linecap":"lineCap","stroke-linejoin":"lineJoin","stroke-miterlimit":"miterLimit","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","text-anchor":"textAlign",visibility:"visibility",display:"display"},ve=t(me),ye={"alignment-baseline":"textBaseline","stop-color":"stopColor"},_e=t(ye),be=function(){function e(){this._defs={},this._root=null}return e.prototype.parse=function(e,t){t=t||{};var i=de(e);if(!i)throw new Error("Illegal svg");this._defsUsePending=[];var r=new o;this._root=r;var a=[],s=i.getAttribute("viewBox")||"",l=parseFloat(i.getAttribute("width")||t.width),p=parseFloat(i.getAttribute("height")||t.height);isNaN(l)&&(l=null),isNaN(p)&&(p=null),Fe(i,r,null,!0,!1);for(var u,c,g=i.firstChild;g;)this._parseNode(g,r,a,null,!1,!1),g=g.nextSibling;if(function(e,t){for(var o=0;o<t.length;o++){var n=t[o];n[0].style[n[1]]=e[n[2]]}}(this._defs,this._defsUsePending),this._defsUsePending=[],s){var h=Re(s);h.length>=4&&(u={x:parseFloat(h[0]||0),y:parseFloat(h[1]||0),width:parseFloat(h[2]),height:parseFloat(h[3])})}if(u&&null!=l&&null!=p&&(c=ke(u,{x:0,y:0,width:l,height:p}),!t.ignoreViewBox)){var d=r;(r=new o).add(d),d.scaleX=d.scaleY=c.scale,d.x=c.x,d.y=c.y}return t.ignoreRootClip||null==l||null==p||r.setClipPath(new n({shape:{x:0,y:0,width:l,height:p}})),{root:r,width:l,height:p,viewBoxRect:u,viewBoxTransform:c,named:a}},e.prototype._parseNode=function(e,t,o,n,r,a){var s,l=e.nodeName.toLowerCase(),p=n;if("defs"===l&&(r=!0),"text"===l&&(a=!0),"defs"===l||"switch"===l)s=t;else{if(!r){var u=fe[l];if(u&&i(fe,l)){s=u.call(this,e,t);var c=e.getAttribute("name");if(c){var g={name:c,namedFrom:null,svgNodeTagLower:l,el:s};o.push(g),"g"===l&&(p=g)}else n&&o.push({name:n.name,namedFrom:n,svgNodeTagLower:l,el:s});t.add(s)}}var h=Se[l];if(h&&i(Se,l)){var d=h.call(this,e),f=e.getAttribute("id");f&&(this._defs[f]=d)}}if(s&&s.isGroup)for(var m=e.firstChild;m;)1===m.nodeType?this._parseNode(m,s,o,p,r,a):3===m.nodeType&&a&&this._parseText(m,s),m=m.nextSibling},e.prototype._parseText=function(e,t){var o=new r({style:{text:e.textContent},silent:!0,x:this._textX||0,y:this._textY||0});Me(t,o),Fe(e,o,this._defsUsePending,!1,!1),function(e,t){var o=t.__selfStyle;if(o){var n=o.textBaseline,i=n;n&&"auto"!==n?"baseline"===n?i="alphabetic":"before-edge"===n||"text-before-edge"===n?i="top":"after-edge"===n||"text-after-edge"===n?i="bottom":"central"!==n&&"mathematical"!==n||(i="middle"):i="alphabetic",e.style.textBaseline=i}var r=t.__inheritedStyle;if(r){var a=r.textAlign,s=a;a&&("middle"===a&&(s="center"),e.style.textAlign=s)}}(o,t);var n=o.style,i=n.fontSize;i&&i<9&&(n.fontSize=9,o.scaleX*=i/9,o.scaleY*=i/9);var a=(n.fontSize||n.fontFamily)&&[n.fontStyle,n.fontWeight,(n.fontSize||12)+"px",n.fontFamily||"sans-serif"].join(" ");n.font=a;var s=o.getBoundingRect();return this._textX+=s.width,t.add(o),o},e.internalField=void(fe={g:function(e,t){var n=new o;return Me(t,n),Fe(e,n,this._defsUsePending,!1,!1),n},rect:function(e,t){var o=new n;return Me(t,o),Fe(e,o,this._defsUsePending,!1,!1),o.setShape({x:parseFloat(e.getAttribute("x")||"0"),y:parseFloat(e.getAttribute("y")||"0"),width:parseFloat(e.getAttribute("width")||"0"),height:parseFloat(e.getAttribute("height")||"0")}),o.silent=!0,o},circle:function(e,t){var o=new a;return Me(t,o),Fe(e,o,this._defsUsePending,!1,!1),o.setShape({cx:parseFloat(e.getAttribute("cx")||"0"),cy:parseFloat(e.getAttribute("cy")||"0"),r:parseFloat(e.getAttribute("r")||"0")}),o.silent=!0,o},line:function(e,t){var o=new s;return Me(t,o),Fe(e,o,this._defsUsePending,!1,!1),o.setShape({x1:parseFloat(e.getAttribute("x1")||"0"),y1:parseFloat(e.getAttribute("y1")||"0"),x2:parseFloat(e.getAttribute("x2")||"0"),y2:parseFloat(e.getAttribute("y2")||"0")}),o.silent=!0,o},ellipse:function(e,t){var o=new l;return Me(t,o),Fe(e,o,this._defsUsePending,!1,!1),o.setShape({cx:parseFloat(e.getAttribute("cx")||"0"),cy:parseFloat(e.getAttribute("cy")||"0"),rx:parseFloat(e.getAttribute("rx")||"0"),ry:parseFloat(e.getAttribute("ry")||"0")}),o.silent=!0,o},polygon:function(e,t){var o,n=e.getAttribute("points");n&&(o=Ge(n));var i=new p({shape:{points:o||[]},silent:!0});return Me(t,i),Fe(e,i,this._defsUsePending,!1,!1),i},polyline:function(e,t){var o,n=e.getAttribute("points");n&&(o=Ge(n));var i=new u({shape:{points:o||[]},silent:!0});return Me(t,i),Fe(e,i,this._defsUsePending,!1,!1),i},image:function(e,t){var o=new c;return Me(t,o),Fe(e,o,this._defsUsePending,!1,!1),o.setStyle({image:e.getAttribute("xlink:href")||e.getAttribute("href"),x:+e.getAttribute("x"),y:+e.getAttribute("y"),width:+e.getAttribute("width"),height:+e.getAttribute("height")}),o.silent=!0,o},text:function(e,t){var n=e.getAttribute("x")||"0",i=e.getAttribute("y")||"0",r=e.getAttribute("dx")||"0",a=e.getAttribute("dy")||"0";this._textX=parseFloat(n)+parseFloat(r),this._textY=parseFloat(i)+parseFloat(a);var s=new o;return Me(t,s),Fe(e,s,this._defsUsePending,!1,!0),s},tspan:function(e,t){var n=e.getAttribute("x"),i=e.getAttribute("y");null!=n&&(this._textX=parseFloat(n)),null!=i&&(this._textY=parseFloat(i));var r=e.getAttribute("dx")||"0",a=e.getAttribute("dy")||"0",s=new o;return Me(t,s),Fe(e,s,this._defsUsePending,!1,!0),this._textX+=parseFloat(r),this._textY+=parseFloat(a),s},path:function(e,t){var o=e.getAttribute("d")||"",n=g(o);return Me(t,n),Fe(e,n,this._defsUsePending,!1,!1),n.silent=!0,n}}),e}(),Se={lineargradient:function(e){var t=parseInt(e.getAttribute("x1")||"0",10),o=parseInt(e.getAttribute("y1")||"0",10),n=parseInt(e.getAttribute("x2")||"10",10),i=parseInt(e.getAttribute("y2")||"0",10),r=new h(t,o,n,i);return we(e,r),xe(e,r),r},radialgradient:function(e){var t=parseInt(e.getAttribute("cx")||"0",10),o=parseInt(e.getAttribute("cy")||"0",10),n=parseInt(e.getAttribute("r")||"0",10),i=new d(t,o,n);return we(e,i),xe(e,i),i}};function we(e,t){"userSpaceOnUse"===e.getAttribute("gradientUnits")&&(t.global=!0)}function xe(e,t){for(var o=e.firstChild;o;){if(1===o.nodeType&&"stop"===o.nodeName.toLocaleLowerCase()){var n=o.getAttribute("offset"),i=void 0;i=n&&n.indexOf("%")>0?parseInt(n,10)/100:n?parseFloat(n):0;var r={};Oe(o,r,r);var a=r.stopColor||o.getAttribute("stop-color")||"#000000";t.colorStops.push({offset:i,color:a})}o=o.nextSibling}}function Me(e,t){e&&e.__inheritedStyle&&(t.__inheritedStyle||(t.__inheritedStyle={}),f(t.__inheritedStyle,e.__inheritedStyle))}function Ge(e){for(var t=Re(e),o=[],n=0;n<t.length;n+=2){var i=parseFloat(t[n]),r=parseFloat(t[n+1]);o.push([i,r])}return o}function Fe(e,t,o,n,i){var r=t,a=r.__inheritedStyle=r.__inheritedStyle||{},s={};1===e.nodeType&&(function(e,t){var o=e.getAttribute("transform");if(o){o=o.replace(/,/g," ");var n=[],i=null;o.replace(Ne,(function(e,t,o){return n.push(t,o),""}));for(var r=n.length-1;r>0;r-=2){var a=n[r],s=n[r-1],l=Re(a);switch(i=i||x(),s){case"translate":w(i,i,[parseFloat(l[0]),parseFloat(l[1]||"0")]);break;case"scale":S(i,i,[parseFloat(l[0]),parseFloat(l[1]||l[0])]);break;case"rotate":b(i,i,-parseFloat(l[0])*De,[parseFloat(l[1]||"0"),parseFloat(l[2]||"0")]);break;case"skewX":var p=Math.tan(parseFloat(l[0])*De);_(i,[1,0,p,1,0,0],i);break;case"skewY":var u=Math.tan(parseFloat(l[0])*De);_(i,[1,u,0,1,0,0],i);break;case"matrix":i[0]=parseFloat(l[0]),i[1]=parseFloat(l[1]),i[2]=parseFloat(l[2]),i[3]=parseFloat(l[3]),i[4]=parseFloat(l[4]),i[5]=parseFloat(l[5])}}t.setLocalTransform(i)}}(e,t),Oe(e,a,s),n||function(e,t,o){for(var n=0;n<ve.length;n++){var i=ve[n];null!=(r=e.getAttribute(i))&&(t[me[i]]=r)}for(n=0;n<_e.length;n++){var r;i=_e[n];null!=(r=e.getAttribute(i))&&(o[ye[i]]=r)}}(e,a,s)),r.style=r.style||{},null!=a.fill&&(r.style.fill=Ce(r,"fill",a.fill,o)),null!=a.stroke&&(r.style.stroke=Ce(r,"stroke",a.stroke,o)),m(["lineWidth","opacity","fillOpacity","strokeOpacity","miterLimit","fontSize"],(function(e){null!=a[e]&&(r.style[e]=parseFloat(a[e]))})),m(["lineDashOffset","lineCap","lineJoin","fontWeight","fontFamily","fontStyle","textAlign"],(function(e){null!=a[e]&&(r.style[e]=a[e])})),i&&(r.__selfStyle=s),a.lineDash&&(r.style.lineDash=v(Re(a.lineDash),(function(e){return parseFloat(e)}))),"hidden"!==a.visibility&&"collapse"!==a.visibility||(r.invisible=!0),"none"===a.display&&(r.ignore=!0)}var Ae=/^url\(\s*#(.*?)\)/;function Ce(e,t,o,n){var i=o&&o.match(Ae);if(!i)return"none"===o&&(o=null),o;var r=y(i[1]);n.push([e,t,r])}var Te=/-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;function Re(e){return e.match(Te)||[]}var Ne=/(translate|scale|rotate|skewX|skewY|matrix)\(([\-\s0-9\.eE,]*)\)/g,De=Math.PI/180;var Ie=/([^\s:;]+)\s*:\s*([^:;]+)/g;function Oe(e,t,o){var n,r=e.getAttribute("style");if(r)for(Ie.lastIndex=0;null!=(n=Ie.exec(r));){var a=n[1],s=i(me,a)?me[a]:null;s&&(t[s]=n[2]);var l=i(ye,a)?ye[a]:null;l&&(o[l]=n[2])}}function ke(e,t){var o=t.width/e.width,n=t.height/e.height,i=Math.min(o,n);return{scale:i,x:-(e.x+e.width/2)*i+(t.x+t.width/2),y:-(e.y+e.height/2)*i+(t.y+t.height/2)}}var Le=M(["rect","circle","line","ellipse","polygon","polyline","path","text","tspan","g"]),Pe=function(){function e(e,t){this.type="geoSVG",this._usedGraphicMap=M(),this._freedGraphics=[],this._mapName=e,this._parsedXML=de(t)}return e.prototype.load=function(){var e=this._firstGraphic;if(!e){e=this._firstGraphic=this._buildGraphic(this._parsedXML),this._freedGraphics.push(e),this._boundingRect=this._firstGraphic.boundingRect.clone();var t=function(e){var t=[],o=M();return m(e,(function(e){if(null==e.namedFrom){var n=new A(e.name,e.el);t.push(n),o.set(e.name,n)}})),{regions:t,regionsMap:o}}(e.named),o=t.regions,n=t.regionsMap;this._regions=o,this._regionsMap=n}return{boundingRect:this._boundingRect,regions:this._regions,regionsMap:this._regionsMap}},e.prototype._buildGraphic=function(e){var t,i,r,a;try{i=(t=e&&(r=e,a={ignoreViewBox:!0,ignoreRootClip:!0},(new be).parse(r,a))||{}).root,G(null!=i)}catch(e){throw new Error("Invalid svg format\n"+e.message)}var s=new o;s.add(i),s.isGeoSVGGraphicRoot=!0;var l=t.width,p=t.height,u=t.viewBoxRect,c=this._boundingRect;if(!c){var g=void 0,h=void 0,d=void 0,f=void 0;if(null!=l?(g=0,d=l):u&&(g=u.x,d=u.width),null!=p?(h=0,f=p):u&&(h=u.y,f=u.height),null==g||null==h){var v=i.getBoundingRect();null==g&&(g=v.x,d=v.width),null==h&&(h=v.y,f=v.height)}c=this._boundingRect=new F(g,h,d,f)}if(u){var y=ke(u,c);i.scaleX=i.scaleY=y.scale,i.x=y.x,i.y=y.y}s.setClipPath(new n({shape:c.plain()}));var _=[];return m(t.named,(function(e){var t;null!=Le.get(e.svgNodeTagLower)&&(_.push(e),(t=e.el).silent=!1,t.isGroup&&t.traverse((function(e){e.silent=!1})))})),{root:s,boundingRect:c,named:_}},e.prototype.useGraphic=function(e){var t=this._usedGraphicMap,o=t.get(e);return o||(o=this._freedGraphics.pop()||this._buildGraphic(this._parsedXML),t.set(e,o),o)},e.prototype.freeGraphic=function(e){var t=this._usedGraphicMap,o=t.get(e);o&&(t.removeKey(e),this._freedGraphics.push(o))},e}();for(var je=[126,25],Ve="南海诸岛",Be=[[[0,3.5],[7,11.2],[15,11.9],[30,7],[42,.7],[52,.7],[56,7.7],[59,.7],[64,.7],[64,0],[5,0],[0,3.5]],[[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]],[[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]],[[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]],[[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]],[[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]],[[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]],[[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]],[[51,35],[51,28.7],[53,28.7],[53,35],[51,35]],[[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]],[[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]],[[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4],[1,92.4],[1,3.5],[0,3.5]]],ze=0;ze<Be.length;ze++)for(var Je=0;Je<Be[ze].length;Je++)Be[ze][Je][0]/=10.5,Be[ze][Je][1]/=-14,Be[ze][Je][0]+=je[0],Be[ze][Je][1]+=je[1];var Ue={"南海诸岛":[32,80],"广东":[0,-10],"香港":[10,5],"澳门":[-10,10],"天津":[5,5]};var Xe=[[[123.45165252685547,25.73527164402261],[123.49731445312499,25.73527164402261],[123.49731445312499,25.750734064600884],[123.45165252685547,25.750734064600884],[123.45165252685547,25.73527164402261]]];var Ye=function(){function t(t,o,n){var i;this.type="geoJSON",this._parsedMap=M(),this._mapName=t,this._specialAreas=n,this._geoJSON=e(i=o)?"undefined"!=typeof JSON&&JSON.parse?JSON.parse(i):new Function("return ("+i+");")():i}return t.prototype.load=function(e,t){t=t||"name";var o=this._parsedMap.get(t);if(!o){var n=this._parseToRegions(t);o=this._parsedMap.set(t,{regions:n,boundingRect:Ee(n)})}var r=M(),a=[];return m(o.regions,(function(t){var o=t.name;e&&i(e,o)&&(t=t.cloneShallow(o=e[o])),a.push(t),r.set(o,t)})),{regions:a,boundingRect:o.boundingRect||new F(0,0,0,0),regionsMap:r}},t.prototype._parseToRegions=function(e){var t,o=this._mapName,n=this._geoJSON;try{t=n?T(n,e):[]}catch(e){throw new Error("Invalid geoJson format\n"+e.message)}return function(e,t){if("china"===e){for(var o=0;o<t.length;o++)if(t[o].name===Ve)return;t.push(new C(Ve,v(Be,(function(e){return{type:"polygon",exterior:e}})),je))}}(o,t),m(t,(function(e){var t=e.name;!function(e,t){if("china"===e){var o=Ue[t.name];if(o){var n=t.getCenter();n[0]+=o[0]/10.5,n[1]+=-o[1]/14,t.setCenter(n)}}}(o,e),function(e,t){"china"===e&&"台湾"===t.name&&t.geometries.push({type:"polygon",exterior:Xe[0]})}(o,e);var n=this._specialAreas&&this._specialAreas[t];n&&e.transformTo(n.left,n.top,n.width,n.height)}),this),t},t.prototype.getMapForUser=function(){return{geoJson:this._geoJSON,geoJSON:this._geoJSON,specialAreas:this._specialAreas}},t}();function Ee(e){for(var t,o=0;o<e.length;o++){var n=e[o].getBoundingRect();(t=t||n.clone()).union(n)}return t}var He=M(),Ze={registerMap:function(e,t,o){if(t.svg){var n=new Pe(e,t.svg);He.set(e,n)}else{var i=t.geoJson||t.geoJSON;i&&!t.features?o=t.specialAreas:i=t;n=new Ye(e,i,o);He.set(e,n)}},getGeoResource:function(e){return He.get(e)},getMapForUser:function(e){var t=He.get(e);return t&&"geoJSON"===t.type&&t.getMapForUser()},load:function(e,t,o){var n=He.get(e);if(n)return n.load(t,o);console.error("Map "+e+" not exists. The GeoJSON of the map must be provided.")}},We=["rect","circle","line","ellipse","polygon","polyline","path"],qe=M(We),Ke=M(We.concat(["g"])),$e=M(We.concat(["g"])),Qe=R();function et(e){var t=e.getItemStyle(),o=e.get("areaColor");return null!=o&&(t.fill=o),t}function tt(e){var t=e.style;t&&(t.stroke=t.stroke||t.fill,t.fill=null)}var ot=function(){function e(e){var t=new o;this.uid=N("ec_map_draw"),this._controller=new ge(e.getZr()),this._controllerHost={target:t},this.group=t,t.add(this._regionsGroup=new o),t.add(this._svgGroup=new o)}return e.prototype.draw=function(e,t,o,n,i){var r="geo"===e.mainType,a=e.getData&&e.getData();r&&t.eachComponent({mainType:"series",subType:"map"},(function(t){a||t.getHostGeoModel()!==e||(a=t.getData())}));var s=e.coordinateSystem,l=this._regionsGroup,p=this.group,u=s.getTransformInfo(),c=u.raw,g=u.roam;!l.childAt(0)||i?(p.x=g.x,p.y=g.y,p.scaleX=g.scaleX,p.scaleY=g.scaleY,p.dirty()):D(p,g,e);var h=a&&a.getVisual("visualMeta")&&a.getVisual("visualMeta").length>0,d={api:o,geo:s,mapOrGeoModel:e,data:a,isVisualEncodedByVisualMap:h,isGeo:r,transformInfoRaw:c};"geoJSON"===s.resourceType?this._buildGeoJSON(d):"geoSVG"===s.resourceType&&this._buildSVG(d),this._updateController(e,t,o),this._updateMapSelectHandler(e,l,o,n)},e.prototype._buildGeoJSON=function(e){var t=this._regionsGroupByName=M(),n=M(),i=this._regionsGroup,r=e.transformInfoRaw,a=e.mapOrGeoModel,s=e.data,l=e.geo.projection,c=l&&l.stream;function g(e,t){return t&&(e=t(e)),e&&[e[0]*r.scaleX+r.x,e[1]*r.scaleY+r.y]}function h(e){for(var t=[],o=!c&&l&&l.project,n=0;n<e.length;++n){var i=g(e[n],o);i&&t.push(i)}return t}function d(e){return{shape:{points:h(e)}}}i.removeAll(),m(e.geo.regions,(function(r){var h=r.name,f=t.get(h),v=n.get(h)||{},y=v.dataIdx,_=v.regionModel;f||(f=t.set(h,new o),i.add(f),y=s?s.indexOfName(h):null,_=e.isGeo?a.getRegionModel(h):s?s.getItemModel(y):null,n.set(h,{dataIdx:y,regionModel:_}));var b=[],S=[];m(r.geometries,(function(e){if("polygon"===e.type){var t=[e.exterior].concat(e.interiors||[]);c&&(t=lt(t,c)),m(t,(function(e){b.push(new p(d(e)))}))}else{var o=e.points;c&&(o=lt(o,c,!0)),m(o,(function(e){S.push(new u(d(e)))}))}}));var w=g(r.getCenter(),l&&l.project);function x(t,o){if(t.length){var n=new U({culling:!0,segmentIgnoreThreshold:1,shape:{paths:t}});f.add(n),nt(e,n,y,_),it(e,n,h,_,a,y,w),o&&(tt(n),m(n.states,tt))}}x(b),x(S,!0)})),t.each((function(t,o){var i=n.get(o),r=i.dataIdx,s=i.regionModel;rt(e,t,o,s,a,r),at(e,t,o,s,a),st(e,t,o,s,a)}),this)},e.prototype._buildSVG=function(e){var t=e.geo.map,o=e.transformInfoRaw;this._svgGroup.x=o.x,this._svgGroup.y=o.y,this._svgGroup.scaleX=o.scaleX,this._svgGroup.scaleY=o.scaleY,this._svgResourceChanged(t)&&(this._freeSVG(),this._useSVG(t));var n=this._svgDispatcherMap=M(),i=!1;m(this._svgGraphicRecord.named,(function(t){var o=t.name,r=e.mapOrGeoModel,a=e.data,s=t.svgNodeTagLower,l=t.el,p=a?a.indexOfName(o):null,u=r.getRegionModel(o);(null!=qe.get(s)&&l instanceof I&&nt(e,l,p,u),l instanceof I&&(l.culling=!0),l.z2EmphasisLift=0,t.namedFrom)||(null!=$e.get(s)&&it(e,l,o,u,r,p,null),rt(e,l,o,u,r,p),at(e,l,o,u,r),null!=Ke.get(s)&&("self"===st(e,l,o,u,r)&&(i=!0),(n.get(o)||n.set(o,[])).push(l)))}),this),this._enableBlurEntireSVG(i,e)},e.prototype._enableBlurEntireSVG=function(e,t){if(e&&t.isGeo){var o=t.mapOrGeoModel.getModel(["blur","itemStyle"]).getItemStyle().opacity;this._svgGraphicRecord.root.traverse((function(e){if(!e.isGroup){O(e);var t=e.ensureState("blur").style||{};null==t.opacity&&null!=o&&(t.opacity=o),e.ensureState("emphasis")}}))}},e.prototype.remove=function(){this._regionsGroup.removeAll(),this._regionsGroupByName=null,this._svgGroup.removeAll(),this._freeSVG(),this._controller.dispose(),this._controllerHost=null},e.prototype.findHighDownDispatchers=function(e,t){if(null==e)return[];var o=t.coordinateSystem;if("geoJSON"===o.resourceType){var n=this._regionsGroupByName;if(n){var i=n.get(e);return i?[i]:[]}}else if("geoSVG"===o.resourceType)return this._svgDispatcherMap&&this._svgDispatcherMap.get(e)||[]},e.prototype._svgResourceChanged=function(e){return this._svgMapName!==e},e.prototype._useSVG=function(e){var t=Ze.getGeoResource(e);if(t&&"geoSVG"===t.type){var o=t.useGraphic(this.uid);this._svgGroup.add(o.root),this._svgGraphicRecord=o,this._svgMapName=e}},e.prototype._freeSVG=function(){var e=this._svgMapName;if(null!=e){var t=Ze.getGeoResource(e);t&&"geoSVG"===t.type&&t.freeGraphic(this.uid),this._svgGraphicRecord=null,this._svgDispatcherMap=null,this._svgGroup.removeAll(),this._svgMapName=null}},e.prototype._updateController=function(e,t,o){var n=e.coordinateSystem,i=this._controller,r=this._controllerHost;r.zoomLimit=e.get("scaleLimit"),r.zoom=n.getZoom(),i.enable(e.get("roam")||!1);var a=e.mainType;function s(){var t={type:"geoRoam",componentType:a};return t[a+"Id"]=e.id,t}i.off("pan").on("pan",(function(e){this._mouseDownFlag=!1,le(r,e.dx,e.dy),o.dispatchAction(k(s(),{dx:e.dx,dy:e.dy,animation:{duration:0}}))}),this),i.off("zoom").on("zoom",(function(e){this._mouseDownFlag=!1,pe(r,e.scale,e.originX,e.originY),o.dispatchAction(k(s(),{zoom:e.scale,originX:e.originX,originY:e.originY,animation:{duration:0}}))}),this),i.setPointerChecker((function(t,i,r){return n.containPoint([i,r])&&!he(t,o,e)}))},e.prototype.resetForLabelLayout=function(){this.group.traverse((function(e){var t=e.getTextContent();t&&(t.ignore=Qe(t).ignore)}))},e.prototype._updateMapSelectHandler=function(e,t,o,n){var i=this;t.off("mousedown"),t.off("click"),e.get("selectedMode")&&(t.on("mousedown",(function(){i._mouseDownFlag=!0})),t.on("click",(function(e){i._mouseDownFlag&&(i._mouseDownFlag=!1)})))},e}();function nt(e,t,o,n){var i=n.getModel("itemStyle"),r=n.getModel(["emphasis","itemStyle"]),a=n.getModel(["blur","itemStyle"]),s=n.getModel(["select","itemStyle"]),l=et(i),p=et(r),u=et(s),c=et(a),g=e.data;if(g){var h=g.getItemVisual(o,"style"),d=g.getItemVisual(o,"decal");e.isVisualEncodedByVisualMap&&h.fill&&(l.fill=h.fill),d&&(l.decal=L(d,e.api))}t.setStyle(l),t.style.strokeNoScale=!0,t.ensureState("emphasis").style=p,t.ensureState("select").style=u,t.ensureState("blur").style=c,O(t)}function it(e,t,o,n,i,r,a){var s=e.data,l=e.isGeo,p=s&&isNaN(s.get(s.mapDimension("value"),r)),u=s&&s.getItemLayout(r);if(l||p||u&&u.showLabel){var c=l?o:r,g=void 0;(!s||r>=0)&&(g=i);var h=a?{normal:{align:"center",verticalAlign:"middle"}}:null;P(t,j(n),{labelFetcher:g,labelDataIndex:c,defaultText:o},h);var d=t.getTextContent();if(d&&(Qe(d).ignore=d.ignore,t.textConfig&&a)){var f=t.getBoundingRect().clone();t.textConfig.layoutRect=f,t.textConfig.position=[(a[0]-f.x)/f.width*100+"%",(a[1]-f.y)/f.height*100+"%"]}t.disableLabelAnimation=!0}else t.removeTextContent(),t.removeTextConfig(),t.disableLabelAnimation=null}function rt(e,t,o,n,i,r){e.data?e.data.setItemGraphicEl(r,t):V(t).eventData={componentType:"geo",componentIndex:i.componentIndex,geoIndex:i.componentIndex,name:o,region:n&&n.option||{}}}function at(e,t,o,n,i){e.data||B({el:t,componentModel:i,itemName:o,itemTooltipOption:n.get("tooltip")})}function st(e,t,o,n,i){t.highDownSilentOnTouch=!!i.get("selectedMode");var r=n.getModel("emphasis"),a=r.get("focus");return z(t,a,r.get("blurScope"),r.get("disabled")),e.isGeo&&J(t,i,o),a}function lt(e,t,o){var n,i=[];function r(){n=[]}function a(){n.length&&(i.push(n),n=[])}var s=t({polygonStart:r,polygonEnd:a,lineStart:r,lineEnd:a,point:function(e,t){isFinite(e)&&isFinite(t)&&n.push([e,t])},sphere:function(){}});return!o&&s.polygonStart(),m(e,(function(e){s.lineStart();for(var t=0;t<e.length;t++)s.point(e[t][0],e[t][1]);s.lineEnd()})),!o&&s.polygonEnd(),i}var pt=ot,ut={geoJSON:{aspectScale:.75,invertLongitute:!0},geoSVG:{aspectScale:1,invertLongitute:!1}},ct=["lng","lat"],gt=function(t){function o(e,o,n){var i=t.call(this,e)||this;i.dimensions=ct,i.type="geo",i._nameCoordMap=M(),i.map=o;var r,a=n.projection,s=Ze.load(o,n.nameMap,n.nameProperty),l=Ze.getGeoResource(o),p=i.resourceType=l?l.type:null,u=i.regions=s.regions,c=ut[l.type];if(i._regionsMap=s.regionsMap,i.regions=s.regions,a&&("geoSVG"===p&&(Y("Map "+o+" with SVG source can't use projection. Only GeoJSON source supports projection."),a=null),a.project&&a.unproject||(Y("project and unproject must be both provided in the projeciton."),a=null)),i.projection=a,a)for(var g=0;g<u.length;g++){var h=u[g].getBoundingRect(a);(r=r||h.clone()).union(h)}else r=s.boundingRect;return i.setBoundingRect(r.x,r.y,r.width,r.height),i.aspectScale=a?1:E(n.aspectScale,c.aspectScale),i._invertLongitute=!a&&c.invertLongitute,i}return X(o,t),o.prototype._transformTo=function(e,t,o,n){var i=this.getBoundingRect(),r=this._invertLongitute;i=i.clone(),r&&(i.y=-i.y-i.height);var a=this._rawTransformable;a.transform=i.calculateTransform(new F(e,t,o,n));var s=a.parent;a.parent=null,a.decomposeTransform(),a.parent=s,r&&(a.scaleY=-a.scaleY),this._updateTransform()},o.prototype.getRegion=function(e){return this._regionsMap.get(e)},o.prototype.getRegionByCoord=function(e){for(var t=this.regions,o=0;o<t.length;o++){var n=t[o];if("geoJSON"===n.type&&n.contain(e))return t[o]}},o.prototype.addGeoCoord=function(e,t){this._nameCoordMap.set(e,t)},o.prototype.getGeoCoord=function(e){var t=this._regionsMap.get(e);return this._nameCoordMap.get(e)||t&&t.getCenter()},o.prototype.dataToPoint=function(t,o,n){if(e(t)&&(t=this.getGeoCoord(t)),t){var i=this.projection;return i&&(t=i.project(t)),t&&this.projectedToPoint(t,o,n)}},o.prototype.pointToData=function(e){var t=this.projection;return t&&(e=t.unproject(e)),e&&this.pointToProjected(e)},o.prototype.pointToProjected=function(e){return t.prototype.pointToData.call(this,e)},o.prototype.projectedToPoint=function(e,o,n){return t.prototype.dataToPoint.call(this,e,o,n)},o.prototype.convertToPixel=function(e,t,o){var n=ht(t);return n===this?n.dataToPoint(o):null},o.prototype.convertFromPixel=function(e,t,o){var n=ht(t);return n===this?n.pointToData(o):null},o}(ue);function ht(e){var t=e.geoModel,o=e.seriesModel;return t?t.coordinateSystem:o?o.coordinateSystem||(o.getReferringComponents("geo",Z).models[0]||{}).coordinateSystem:null}H(gt,ue);var dt=gt;function ft(e,t){var o=e.get("boundingCoords");if(null!=o){var n=o[0],i=o[1];if(isFinite(n[0])&&isFinite(n[1])&&isFinite(i[0])&&isFinite(i[1])){var r=this.projection;if(r){var a=n[0],s=n[1],l=i[0],p=i[1];n=[1/0,1/0],i=[-1/0,-1/0];var u=function(e,t,o,a){for(var s=o-e,l=a-t,p=0;p<=100;p++){var u=p/100,c=r.project([e+s*u,t+l*u]);Q(n,n,c),ee(i,i,c)}};u(a,s,l,s),u(l,s,l,p),u(l,p,a,p),u(a,p,l,s)}this.setBoundingRect(n[0],n[1],i[0]-n[0],i[1]-n[1])}else console.error("Invalid boundingCoords")}var c,g,h,d=this.getBoundingRect(),f=e.get("layoutCenter"),m=e.get("layoutSize"),v=t.getWidth(),y=t.getHeight(),_=d.width/d.height*this.aspectScale,b=!1;if(f&&m&&(c=[K(f[0],v),K(f[1],y)],g=K(m,Math.min(v,y)),isNaN(c[0])||isNaN(c[1])||isNaN(g)?console.warn("Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead."):b=!0),b)h={},_>1?(h.width=g,h.height=g/_):(h.height=g,h.width=g*_),h.y=c[1]-h.height/2,h.x=c[0]-h.width/2;else{var S=e.getBoxLayoutParams();S.aspect=_,h=$(S,{width:v,height:y})}this.setViewRect(h.x,h.y,h.width,h.height),this.setCenter(e.get("center"),t),this.setZoom(e.get("zoom"))}var mt=function(){function e(){this.dimensions=ct}return e.prototype.create=function(e,t){var o=[];function n(e){return{nameProperty:e.get("nameProperty"),aspectScale:e.get("aspectScale"),projection:e.get("projection")}}e.eachComponent("geo",(function(e,i){var r=e.get("map"),a=new dt(r+i,r,k({nameMap:e.get("nameMap")},n(e)));a.zoomLimit=e.get("scaleLimit"),o.push(a),e.coordinateSystem=a,a.model=e,a.resize=ft,a.resize(e,t)})),e.eachSeries((function(e){if("geo"===e.get("coordinateSystem")){var t=e.get("geoIndex")||0;e.coordinateSystem=o[t]}}));var i={};return e.eachSeriesByType("map",(function(e){if(!e.getHostGeoModel()){var t=e.getMapType();i[t]=i[t]||[],i[t].push(e)}})),m(i,(function(e,i){var r=v(e,(function(e){return e.get("nameMap")})),a=new dt(i,i,k({nameMap:W(r)},n(e[0])));a.zoomLimit=q.apply(null,v(e,(function(e){return e.get("scaleLimit")}))),o.push(a),a.resize=ft,a.resize(e[0],t),m(e,(function(e){e.coordinateSystem=a,function(e,t){m(t.get("geoCoord"),(function(t,o){e.addGeoCoord(o,t)}))}(a,e)}))})),o},e.prototype.getFilledRegions=function(e,t,o,n){for(var i=(e||[]).slice(),r=M(),a=0;a<i.length;a++)r.set(i[a].name,i[a]);var s=Ze.load(t,o,n);return m(s.regions,(function(e){var t=e.name;!r.get(t)&&i.push({name:t})})),i},e}(),vt=new mt,yt=function(t){function o(){var e=null!==t&&t.apply(this,arguments)||this;return e.type=o.type,e}return X(o,t),o.prototype.init=function(e,t,o){var n=Ze.getGeoResource(e.map);if(n&&"geoJSON"===n.type){var i=e.itemStyle=e.itemStyle||{};"color"in i||(i.color="#eee")}this.mergeDefaultAndTheme(e,o),te(e,"label",["show"])},o.prototype.optionUpdated=function(){var e=this,t=this.option;t.regions=vt.getFilledRegions(t.regions,t.map,t.nameMap,t.nameProperty);var o={};this._optionModelMap=oe(t.regions||[],(function(t,n){var i=n.name;return i&&(t.set(i,new ne(n,e,e.ecModel)),n.selected&&(o[i]=!0)),t}),M()),t.selectedMap||(t.selectedMap=o)},o.prototype.getRegionModel=function(e){return this._optionModelMap.get(e)||new ne(null,this,this.ecModel)},o.prototype.getFormattedLabel=function(t,o){var n=this.getRegionModel(t),i="normal"===o?n.get(["label","formatter"]):n.get(["emphasis","label","formatter"]),r={name:t};return ie(i)?(r.status=o,i(r)):e(i)?i.replace("{a}",null!=t?t:""):void 0},o.prototype.setZoom=function(e){this.option.zoom=e},o.prototype.setCenter=function(e){this.option.center=e},o.prototype.select=function(e){var t=this.option,o=t.selectedMode;o&&("multiple"!==o&&(t.selectedMap=null),(t.selectedMap||(t.selectedMap={}))[e]=!0)},o.prototype.unSelect=function(e){var t=this.option.selectedMap;t&&(t[e]=!1)},o.prototype.toggleSelected=function(e){this[this.isSelected(e)?"unSelect":"select"](e)},o.prototype.isSelected=function(e){var t=this.option.selectedMap;return!(!t||!t[e])},o.type="geo",o.layoutMode="box",o.defaultOption={z:0,show:!0,left:"center",top:"center",aspectScale:null,silent:!1,map:"",boundingCoords:null,center:null,zoom:1,scaleLimit:null,label:{show:!1,color:"#000"},itemStyle:{borderWidth:.5,borderColor:"#444"},emphasis:{label:{show:!0,color:"rgb(100,0,0)"},itemStyle:{color:"rgba(255,215,0,0.8)"}},select:{label:{show:!0,color:"rgb(100,0,0)"},itemStyle:{color:"rgba(255,215,0,0.8)"}},regions:[]},o}(re),_t=function(e){function t(){var o=null!==e&&e.apply(this,arguments)||this;return o.type=t.type,o.focusBlurEnabled=!0,o}return X(t,e),t.prototype.init=function(e,t){this._api=t},t.prototype.render=function(e,t,o,n){if(this._model=e,!e.get("show"))return this._mapDraw&&this._mapDraw.remove(),void(this._mapDraw=null);this._mapDraw||(this._mapDraw=new pt(o));var i=this._mapDraw;i.draw(e,t,o,this,n),i.group.on("click",this._handleRegionClick,this),i.group.silent=e.get("silent"),this.group.add(i.group),this.updateSelectStatus(e,t,o)},t.prototype._handleRegionClick=function(e){var t;ae(e.target,(function(e){return null!=(t=V(e).eventData)}),!0),t&&this._api.dispatchAction({type:"geoToggleSelect",geoId:this._model.id,name:t.name})},t.prototype.updateSelectStatus=function(e,t,o){var n=this;this._mapDraw.group.traverse((function(e){var t=V(e).eventData;if(t)return n._model.isSelected(t.name)?o.enterSelect(e):o.leaveSelect(e),!0}))},t.prototype.findHighDownDispatchers=function(e){return this._mapDraw&&this._mapDraw.findHighDownDispatchers(e,this._model)},t.prototype.dispose=function(){this._mapDraw&&this._mapDraw.remove()},t.type="geo",t}(se);function bt(e,t,o){Ze.registerMap(e,t,o)}function St(e){function t(t,o){o.update="geo:updateSelectStatus",e.registerAction(o,(function(e,o){var n={},i=[];return o.eachComponent({mainType:"geo",query:e},(function(o){o[t](e.name);var r=o.coordinateSystem;m(r.regions,(function(e){n[e.name]=o.isSelected(e.name)||!1}));var a=[];m(n,(function(e,t){n[t]&&a.push(t)})),i.push({geoIndex:o.componentIndex,name:a})})),{selected:n,allSelected:i,name:e.name}}))}e.registerCoordinateSystem("geo",vt),e.registerComponentModel(yt),e.registerComponentView(_t),e.registerImpl("registerMap",bt),e.registerImpl("getMap",(function(e){return Ze.getMapForUser(e)})),t("toggleSelected",{type:"geoToggleSelect",event:"geoselectchanged"}),t("select",{type:"geoSelect",event:"geoselected"}),t("unSelect",{type:"geoUnSelect",event:"geounselected"}),e.registerAction({type:"geoRoam",event:"geoRoam",update:"updateTransform"},(function(e,t,o){var n=e.componentType||"series";t.eachComponent({mainType:n,query:e},(function(t){var i=t.coordinateSystem;if("geo"===i.type){var r=ce(i,e,t.get("scaleLimit"),o);t.setCenter&&t.setCenter(r.center),t.setZoom&&t.setZoom(r.zoom),"series"===n&&m(t.seriesGroup,(function(e){e.setCenter(r.center),e.setZoom(r.zoom)}))}}))}))}var wt=Object.freeze({__proto__:null,install:St});export{pt as M,wt as a,Ze as g,St as i};