forked from kartograph/kartograph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkartograph-0.8.3.min.js
2 lines (2 loc) · 46.6 KB
/
kartograph-0.8.3.min.js
1
2
!function(){function t(){var t={},e=[],n=1,o=1;return t.size=function(r){return arguments.length?(o=r,t):o},t.iterations=function(r){return arguments.length?(n=r,t):n},t.add=function(r){return e.push(r),t},t.means=function(){for(var t=[],a={},i=Math.min(o,e.length),l=0,s=2*i;s>l;l++){var u=e[~~(Math.random()*e.length)],p=u.x+"/"+u.y;if(!(p in a)&&(a[p]=1,t.push({x:u.x,y:u.y})>=i))break}i=t.length;for(var h=0;n>h;h++){for(var c=r().points(t),l=0;i>l;l++){var f=t[l];f.sumX=0,f.sumY=0,f.size=0,f.points=[],f.indices=[]}for(var l=0;l<e.length;l++){var d=e[l],f=c.find(d);f.sumX+=d.x,f.sumY+=d.y,f.size++,f.points.push(d),f.indices.push(l)}for(var l=0;i>l;l++){var f=t[l];f.size&&(f.x=f.sumX/f.size,f.y=f.sumY/f.size)}}return t},t}function r(){function t(r,n){if(r.length){var o=i[n%i.length],a=r.length>>1;return r.sort(e(o)),{axis:o,point:r[a],left:t(r.slice(0,a),n+1),right:t(r.slice(a+1),n+1)}}}function r(t,r){for(var e=0,n=0;n<i.length;n++){var o=i[n],a=t[o]-r[o];e+=a*a}return e}function e(t){return function(r,e){return r=r[t],e=e[t],e>r?-1:r>e?1:0}}function n(t,e,o){if(r(t.point,e)<r(o.point,e)&&(o=t),t.left&&(o=n(t.left,e,o)),t.right){var a=t.point[t.axis]-e[t.axis];a*a<r(o.point,e)&&(o=n(t.right,e,o))}return o}var o,a={},i=["x","y"],l=[];return a.axes=function(t){return arguments.length?(i=t,a):i},a.points=function(t){return arguments.length?(l=t,o=null,a):l},a.find=function(t){return n(a.root(),t,o).point},a.root=function(){return o||(o=t(l,0))},a}var e,n,o,a,i,l,u,p,h,c,f,d,y,g,v,b,x,_,w,M,S,k,B,C,L,P,G,A,N,j,z,I,T,V,O,F,E,R,D,X,q,U,Z,H,W,$,Y,K,Q,J,tr,rr,er,nr,or,ar,ir,lr,sr,ur,pr,hr,cr,fr,dr,yr,gr={}.hasOwnProperty,vr=function(t,r){function e(){this.constructor=t}for(var n in r)gr.call(r,n)&&(t[n]=r[n]);return e.prototype=r.prototype,t.prototype=new e,t.__super__=r.prototype,t},mr=function(t,r){return function(){return t.apply(r,arguments)}},br=[].indexOf||function(t){for(var r=0,e=this.length;e>r;r++)if(r in this&&this[r]===t)return r;return-1};$="undefined"!=typeof exports&&null!==exports?exports:this,R=$.$K=null!=(or=$.kartograph)?or:$.kartograph={},R.version="0.8.3",e=$.jQuery,R.__verbose=!1,K=function(){var t;try{return console.warn.apply(console,arguments)}catch(r){t=r;try{return opera.postError.apply(opera,arguments)}catch(r){return t=r,alert(Array.prototype.join.call(arguments," "))}}},D=function(){var t;if(R.__verbose)try{return console.debug.apply(console,arguments)}catch(r){t=r;try{return opera.postError.apply(opera,arguments)}catch(r){return t=r,alert(Array.prototype.join.call(arguments," "))}}},null==(ar=(er=String.prototype).trim)&&(er.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(t){"use strict";if(null==this)throw new TypeError;var r=Object(this),e=r.length>>>0;if(0===e)return-1;var n=0;if(arguments.length>0&&(n=Number(arguments[1]),n!=n?n=0:0!=n&&1/0!=n&&n!=-1/0&&(n=(n>0||-1)*Math.floor(Math.abs(n)))),n>=e)return-1;for(var o=n>=0?n:Math.max(e-Math.abs(n),0);e>o;o++)if(o in r&&r[o]===t)return o;return-1}),rr=function(){var t,r,e,n,o;for(t={},o="Boolean Number String Function Array Date RegExp Undefined Null".split(" "),e=0,n=o.length;n>e;e++)r=o[e],t["[object "+r+"]"]=r.toLowerCase();return function(r){var e;return e=Object.prototype.toString.call(r),t[e]||"object"}}(),n=function(){function t(t,r,e,n){var o;null==t&&(t=0),null==r&&(r=0),null==e&&(e=null),null==n&&(n=null),o=this,null===e?(o.xmin=Number.MAX_VALUE,o.xmax=-1*Number.MAX_VALUE):(o.xmin=o.left=t,o.xmax=o.right=t+e,o.width=e),null===n?(o.ymin=Number.MAX_VALUE,o.ymax=-1*Number.MAX_VALUE):(o.ymin=o.top=r,o.ymax=o.bottom=n+r,o.height=n)}return t.prototype.update=function(t,r){var e;return null==r&&(r=t[1],t=t[0]),e=this,e.xmin=Math.min(e.xmin,t),e.ymin=Math.min(e.ymin,r),e.xmax=Math.max(e.xmax,t),e.ymax=Math.max(e.ymax,r),e.left=e.xmin,e.top=e.ymin,e.right=e.xmax,e.bottom=e.ymax,e.width=e.xmax-e.xmin,e.height=e.ymax-e.ymin,this},t.prototype.intersects=function(t){return t.left<s.right&&t.right>s.left&&t.top<s.bottom&&t.bottom>s.top},t.prototype.inside=function(t,r){var e;return e=this,t>=e.left&&t<=e.right&&r>=e.top&&r<=e.bottom},t.prototype.join=function(t){var r;return r=this,r.update(t.left,t.top),r.update(t.right,t.bottom),this},t}(),n.fromXML=function(t){var r,e,n,o;return n=Number(t.getAttribute("x")),o=Number(t.getAttribute("y")),e=Number(t.getAttribute("w")),r=Number(t.getAttribute("h")),new R.BBox(n,o,e,r)},R.BBox=n,null==(sr=R.geom)&&(R.geom={}),null==(ur=(nr=R.geom).clipping)&&(nr.clipping={}),l=function(){function t(){}var r,e,n,o,a;return e=0,n=1,o=2,r=4,a=8,t.prototype.compute_out_code=function(t,r,e){var n,o;return o=this,n=o.INSIDE,r<t.left?n|=o.LEFT:r>t.right&&(n|=o.RIGHT),e<t.top?n|=o.TOP:e>t.bottom&&(n|=o.BOTTOM),n},t.prototype.clip=function(t,r,e,n,o){var a,i,l,s,u,p,h;for(u=this,i=u.compute_out_code(t,r,e),l=u.compute_out_code(t,n,o),a=False;True;){if(!(i|l)){a=True;break}if(i&l)break;s=0===code?l:i,s&u.TOP?(p=r+(n-r)*(t.top-e)/(o-e),h=t.top):s&u.BOTTOM?(p=r+(n-r)*(t.bottom-e)/(o-e),h=t.bottom):s&u.RIGHT?(h=e+(o-e)*(t.right-r)/(n-r),p=t.right):s&u.LEFT&&(h=e+(o-e)*(t.left-r)/(n-r),p=t.left),s===i?(r=p,e=h,i=u.compute_out_code(t,r,e)):(n=p,o=h,l=u.compute_out_code(t,n,o))}return a?[r,e,n,o]:null},t}(),R.geom.clipping.CohenSutherland=l,d=function(){function t(t,r,n){var o,a;a=this,a.container=o=e(t),null==r&&(r=o.width()),null==n&&(n=o.height()),0===n&&(n="auto"),a.size={h:n,w:r},a.markers=[],a.pathById={},a.container.addClass("kartograph")}return t.prototype.createSVGLayer=function(t){var r,n,o,a,i,l,s,u;return a=this,null==(u=a._layerCnt)&&(a._layerCnt=0),o=a._layerCnt++,s=a.viewport,n=a.container,i=Raphael(n[0],s.width,s.height),l=e(i.canvas),l.css({position:"absolute",top:"0px",left:"0px","z-index":o+5}),"static"===n.css("position")&&n.css({position:"relative",height:s.height+"px"}),l.addClass(t),r=e("desc",i.canvas).text(),e("desc",i.canvas).text(r.replace("with ","with kartograph "+R.version+" and ")),i},t.prototype.createHTMLLayer=function(t){var r,n,o,a,i,l;return a=this,i=a.viewport,r=a.container,null==(l=a._layerCnt)&&(a._layerCnt=0),o=a._layerCnt++,n=e('<div class="layer '+t+'" />'),n.css({position:"absolute",top:"0px",left:"0px",width:i.width+"px",height:i.height+"px","z-index":o+5}),r.append(n),n},t.prototype.load=function(t,r,n){var o,a,i,l;return a=this,o=e.Deferred(),a.clear(),a.opts=null!=n?n:{},null==(l=(i=a.opts).zoom)&&(i.zoom=1),a.mapLoadCallback=r,a._loadMapDeferred=o,a._lastMapUrl=t,a.cacheMaps&&null!=R.__mapCache[t]?a._mapLoaded(R.__mapCache[t]):e.ajax({url:t,dataType:"text",success:a._mapLoaded,context:a,error:function(t,r,e){return K(t,r,e)}}),o.promise()},t.prototype.loadMap=function(){return this.load.apply(this,arguments)},t.prototype.setMap=function(t,r){var e,n,o;e=this,e.opts=null!=r?r:{},null==(o=(n=e.opts).zoom)&&(n.zoom=1),e._lastMapUrl="string",e._mapLoaded(t)},t.prototype._mapLoaded=function(t){var r,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b;s=this,s.cacheMaps&&(null==(y=R.__mapCache)&&(R.__mapCache={}),R.__mapCache[s._lastMapUrl]=t);try{t=e(t)}catch(x){return a=x,K("something went horribly wrong while parsing svg"),s._loadMapDeferred.reject("could not parse svg"),void 0}s.svgSrc=t,r=e("view",t),null==s.paper&&(f=s.size.w,i=s.size.h,"auto"===i&&(p=r.attr("w")/r.attr("h"),i=f/p),s.viewport=new n(0,0,f,i)),c=s.viewport,s.viewAB=o=R.View.fromXML(r[0]),u=null!=(g=s.opts.padding)?g:0,l=null!=(v=s.opts.halign)?v:"center",h=null!=(m=s.opts.valign)?m:"center",d=null!=(b=s.opts.zoom)?b:1,s.viewBC=new R.View(s.viewAB.asBBox(),c.width*d,c.height*d,u,l,h),s.proj=R.Proj.fromXML(e("proj",r)[0]),null!=s.mapLoadCallback&&s.mapLoadCallback(s),null!=s._loadMapDeferred&&s._loadMapDeferred.resolve(s)},t.prototype.addLayer=function(t,r){var n,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b;return null==r&&(r={}),u=this,null==(v=u.layerIds)&&(u.layerIds=[]),null==(m=u.layers)&&(u.layers={}),null==u.paper&&(u.paper=u.createSVGLayer()),d=t,"object"===rr(r)?(l=r.name,c=r.key,g=r.title):r={},s=u.paper,r.add_svg_layer&&(s=u.createSVGLayer()),null==l&&(l=d),y=e("#"+d,u.svgSrc),0!==y.length?(i=new w(l,c,u,r.filter,s),n=e("*",y[0]),f=n.length,o=null!=(b=r.chunks)?b:f,a=0,h=function(){var t,e,l,s,u,c;for(t=o*a,e=u=0;o>=0?o>u:u>o;e=o>=0?++u:--u)f>t+e&&i.addPath(n.get(t+e),g);if(null!=r.styles){c=r.styles;for(l in c)s=c[l],i.style(l,s)}return a++,f>a*o?setTimeout(h,0):p()},p=function(){var t,e,n,o;for(i.paths.length>0&&(u.layers[l]=i,u.layerIds.push(l)),t=["click","mouseenter","mouseleave","dblclick","mousedown","mouseup","mouseover","mouseout"],n=0,o=t.length;o>n;n++)e=t[n],"function"===rr(r[e])&&i.on(e,r[e]);return null!=r.tooltips&&i.tooltips(r.tooltips),null!=r.done?r.done():void 0},null!=r.chunks?setTimeout(h,0):h(),u):void 0},t.prototype.getLayer=function(t){var r;return r=this,null==r.layers[t]?(K("could not find layer "+t),null):r.layers[t]},t.prototype.getLayerPath=function(t,r){var e,n;return n=this,e=n.getLayer(t),null!=e?"object"===rr(r)?e.getPaths(r)[0]:e.getPath(r):null},t.prototype.onLayerEvent=function(t,r,e){var n;return n=this,n.getLayer(e).on(t,r),n},t.prototype.addMarker=function(t){var r,e;return r=this,r.markers.push(t),e=r.viewBC.project(r.viewAB.project(r.proj.project(t.lonlat.lon,t.lonlat.lat))),t.render(e[0],e[1],r.container,r.paper)},t.prototype.clearMarkers=function(){var t,r,e,n,o;for(r=this,o=r.markers,e=0,n=o.length;n>e;e++)t=o[e],t.clear();return r.markers=[]},t.prototype.fadeIn=function(t){var r,e,n,o,a,i,l,s,u,p,h;null==t&&(t={}),a=this,o=null!=(s=t.layer)?s:a.layerIds[a.layerIds.length-1],e=null!=(u=t.duration)?u:500,p=a.layers[o].pathsById,h=[];for(n in p)l=p[n],h.push(function(){var t,n,o;for(o=[],t=0,n=l.length;n>t;t++)i=l[t],r="function"===rr(e)?e(i.data):e,i.svgPath.attr("opacity",0),o.push(i.svgPath.animate({opacity:1},r));return o}());return h},t.prototype.loadCoastline=function(){var t;return t=this,e.ajax({url:"coastline.json",success:t.renderCoastline,context:t})},t.prototype.resize=function(t,r){var e,n,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m;i=this,e=i.container,null==t&&(t=e.width()),null==r&&(r=e.height()),i.viewport=p=new R.BBox(0,0,t,r),null!=i.paper&&i.paper.setSize(p.width,p.height),p=i.viewport,l=null!=(d=i.opts.padding)?d:0,n=null!=(y=i.opts.halign)?y:"center",u=null!=(g=i.opts.valign)?g:"center",h=i.opts.zoom,i.viewBC=new R.View(i.viewAB.asBBox(),p.width*h,p.height*h,l,n,u),v=i.layers;for(o in v)a=v[o],a.setView(i.viewBC);if(null!=i.symbolGroups)for(m=i.symbolGroups,c=0,f=m.length;f>c;c++)s=m[c],s.onResize()},t.prototype.lonlat2xy=function(t){var r,e;return e=this,2===t.length&&(t=new R.LonLat(t[0],t[1])),3===t.length&&(t=new R.LonLat(t[0],t[1],t[2])),r=e.proj.project(t.lon,t.lat,t.alt),e.viewBC.project(e.viewAB.project(r))},t.prototype.addSymbolGroup=function(t){var r,e;return r=this,null==(e=r.symbolGroups)&&(r.symbolGroups=[]),r.symbolGroups.push(t)},t.prototype.removeSymbols=function(t){var r,e,n,o,a,i;if(r=this,null!=t)return r.symbolGroups[t].remove();for(a=r.symbolGroups,i=[],n=0,o=a.length;o>n;n++)e=a[n],i.push(e.remove());return i},t.prototype.clear=function(){var t,r,n,o,a,i;if(r=this,null!=r.layers){for(t in r.layers)r.layers[t].remove();r.layers={},r.layerIds=[]}if(null!=r.symbolGroups){for(i=r.symbolGroups,o=0,a=i.length;a>o;o++)n=i[o],n.remove();r.symbolGroups=[]}return null!=r.paper?(e(r.paper.canvas).remove(),r.paper=void 0):void 0},t.prototype.loadCSS=function(t,r){var n;return n=this,Raphael.svg?(e("body").append('<link rel="stylesheet" href="'+t+'" />'),r()):e.ajax({url:t,dataType:"text",success:function(t){return n.styles=R.parsecss(t),r()},error:function(r,e,n){return K("error while loading "+t,r,e,n)}})},t.prototype.applyCSS=function(t,r){var e,n,o,a,i,l,s,u,p,h,c,f,d,y,g;if(o=this,null==o.styles)return t;null==(f=o._pathTypes)&&(o._pathTypes=["path","circle","rectangle","ellipse"]),null==(d=o._regardStyles)&&(o._regardStyles=["fill","stroke","fill-opacity","stroke-width","stroke-opacity"]);for(l in o.styles)for(a=l,y=a.split(","),u=0,h=y.length;h>u;u++)if(s=y[u],a=s.split(" "),a=a[a.length-1],a=a.split(":"),!(a.length>1||(a=a[0].split("."),e=a.slice(1),e.length>0&&e.indexOf(r)<0||(a=a[0],o._pathTypes.indexOf(a)>=0&&a!==t.type))))for(i=o.styles[l],g=o._regardStyles,p=0,c=g.length;c>p;p++)n=g[p],null!=i[n]&&t.attr(n,i[n]);return t},t.prototype.style=function(t,r,e,n,o){var a;return a=this,t=a.getLayer(t),null!=t?t.style(r,e,n,o):void 0},t}(),f=R,$.kartograph=function(t,r,e){return new d(t,r,e)},R.map=function(t,r,e){return new d(t,r,e)},R.__mapCache={},e.extend($.kartograph,f),_=function(){function t(t,r,e){null==e&&(e=0),this.lon=Number(t),this.lat=Number(r),this.alt=Number(e)}return t.prototype.distance=function(t){var r,e,n,o,a,i,l,s,u;return u=this,r=6371,i=Math.PI/180,o=(t.lat-u.lat)*i,a=(t.lon-u.lon)*i,l=u.lat*i,s=t.lat*i,e=Math.sin(o/2)*Math.sin(o/2)+Math.sin(a/2)*Math.sin(a/2)*Math.cos(l)*Math.cos(s),n=2*Math.atan2(Math.sqrt(e),Math.sqrt(1-e)),r*n},t}(),g=function(t){function r(t,e,n){null==n&&(n=0),r.__super__.constructor.call(this,e,t,n)}return vr(r,t),r}(_),R.LonLat=_,R.LatLon=g,w=function(){function t(t,r,e,n,o){var a;a=this,a.id=t,a.path_id=r,a.paper=null!=o?o:e.paper,a.view=e.viewBC,a.map=e,a.filter=n}return t.prototype.addPath=function(t,r){var e,n,o,a,i,l,s;return n=this,null==(i=n.paths)&&(n.paths=[]),e=new M(t,n.id,n,r),"function"===rr(n.filter)&&n.filter(e.data)===!1?(e.remove(),void 0):(n.paths.push(e),null!=n.path_id?(null==(l=n.pathsById)&&(n.pathsById={}),null==(s=(o=n.pathsById)[a=e.data[n.path_id]])&&(o[a]=[]),n.pathsById[e.data[n.path_id]].push(e)):void 0)},t.prototype.hasPath=function(t){var r;return r=this,null!=r.pathsById&&null!=r.pathsById[t]},t.prototype.getPathsData=function(){var t,r,e,n,o,a;for(t=this,e=[],a=t.paths,n=0,o=a.length;o>n;n++)r=a[n],e.push(r.data);return e},t.prototype.getPath=function(t){var r;return r=this,r.hasPath(t)?r.pathsById[t][0]:null},t.prototype.getPaths=function(t){var r,e,n,o,a,i,l,s;if(o=this,n=[],"object"===rr(t))for(s=o.paths,i=0,l=s.length;l>i;i++){a=s[i],e=!0;for(r in t)e=e&&a.data[r]===t[r];e&&n.push(a)}return n},t.prototype.setView=function(t){var r,e,n,o,a;for(r=this,a=r.paths,n=0,o=a.length;o>n;n++)e=a[n],e.setView(t);return r},t.prototype.remove=function(){var t,r,e,n,o,a;for(t=this,o=t.paths,a=[],e=0,n=o.length;n>e;e++)r=o[e],a.push(r.remove());return a},t.prototype.style=function(t,r,n,o){var a,i;return i=this,"string"===rr(t)?(a=t,t={},t[a]=r):"object"===rr(t)&&(o=n,n=r),null==n&&(n=0),e.each(i.paths,function(r,e){var a,i,l,s,u,p;i={};for(u in t)p=t[u],i[u]=H(p,e.data);return s=H(n,e.data),l=H(o,e.data),null==l&&(l=0),s>0?(a=Raphael.animation(i,1e3*s),e.svgPath.animate(a.delay(1e3*l))):0===o?setTimeout(function(){return e.svgPath.attr(i)},0):e.svgPath.attr(i)}),i},t.prototype.on=function(t,r){var n,o,a,i,l,s,u;for(a=this,n=function(){function t(t,r,e){this.type=t,this.cb=r,this.layer=e,this.handle=mr(this.handle,this)}return t.prototype.handle=function(t){var r;return a=this,r=a.layer.map.pathById[t.target.getAttribute("id")],a.cb(r.data,r.svgPath,t)},t}(),o=new n(t,r,a),u=a.paths,l=0,s=u.length;s>l;l++)i=u[l],e(i.svgPath.node).bind(t,o.handle);return a},t.prototype.tooltips=function(t,r){var n,o,a,i,l,s,u;for(n=this,a=function(t,n){var o;return o={position:{target:"mouse",viewport:e(window),adjust:{x:7,y:7}},show:{delay:null!=r?r:20},events:{show:function(t,r){return e(".qtip").filter(function(){return this!==r.elements.tooltip.get(0)}).hide()}},content:{}},null!=n?"string"==typeof n?o.content.text=n:e.isArray(n)&&(o.content.title=n[0],o.content.text=n[1]):o.content.text="n/a",e(t.svgPath.node).qtip(o)},u=n.paths,l=0,s=u.length;s>l;l++)o=u[l],i=H(t,o.data),a(o,i);return n},t.prototype.sort=function(t){var r,e,n,o,a,i;for(e=this,e.paths.sort(function(r,e){var n,o,a;return n=t(r.data),o=t(e.data),n===o?0:null!=(a=n>o)?a:{1:-1}}),r=!1,i=e.paths,o=0,a=i.length;a>o;o++)n=i[o],r&&n.svgPath.insertAfter(r.svgPath),r=n;return e},t}(),H=function(t,r){return"function"===rr(t)?t(r):t},X=0,M=function(){function t(t,r,e,n){var o,a,i,l,s,u,p,h,c,f,d,y,g,v;for(s=this,u=e.paper,l=e.map,d=l.viewBC,s.path=p=R.geom.Path.fromSVG(t),s.vpath=d.projectPath(p),s.svgPath=s.vpath.toSVG(u),s.svgPath.data("path",s),null==l.styles?Raphael.svg&&s.svgPath.node.setAttribute("class",r):l.applyCSS(s.svgPath,r),c="path_"+X++,s.svgPath.node.setAttribute("id",c),l.pathById[c]=s,a={},i=g=0,v=t.attributes.length-1;v>=0?v>=g:g>=v;i=v>=0?++g:--g)o=t.attributes[i],"data-"===o.name.substr(0,5)&&(f=o.value,y=Number(f),""===f.trim()||y!==f||isNaN(y)||(f=y),a[o.name.substr(5)]=f);s.data=a,"string"===rr(n)?h=n:"function"===rr(n)&&(h=n(a)),null!=h&&s.svgPath.attr("title",h)}return t.prototype.setView=function(t){var r,e,n;return r=this,e=t.projectPath(r.path),r.vpath=e,"path"===r.path.type?(n=e.svgString(),r.svgPath.attr({path:n})):"circle"===r.path.type?r.svgPath.attr({cx:e.x,cy:e.y,r:e.r}):void 0},t.prototype.remove=function(){var t;return t=this,t.svgPath.remove()},t}(),R.parsecss=function(t,r){var e,n,o,a,i,l,s,u;for(a={},t=q(t),u=t.split("`b%"),l=0,s=u.length;s>l;l++)if(e=u[l],e=e.split("%b`"),!(e.length<2))if(e[0]=W(e[0]),o=Z(e[1]),null!=a[e[0]])for(n in o)i=o[n],a[e[0]][n]=i;else a[e[0]]=o;return"function"!==rr(r)?a:(r(a),void 0)},U={},Z=function(t){var r,e,n,o,a,i;for(n=U[t].replace(/^{|}$/g,""),n=q(n),e={},i=n.split(";"),o=0,a=i.length;a>o;o++)r=i[o],r=r.split(":"),r.length<2||(e[W(r[0])]=W(r.slice(1).join(":")));return e},C=/{[^{}]*}/,P=/\[[^\[\]]*\]|{[^{}]*}|\([^()]*\)|function(\s+\w+)?(\s*%b`\d+`b%){2}/,L=/(?:\/\*(?:[^\*]|\*[^\/])*\*\/)|(\\.|"(?:[^\\\"]|\\.|\\\n)*"|'(?:[^\\\']|\\.|\\\n)*')/g,G=/%\w`(\d+)`\w%/,Y=0,q=function(t,r){var e,n,o;for(t=t.replace(L,function(t,r){var e;return r?(e="%s`"+ ++Y+"`s%",U[Y]=r.replace(/^\\/,""),e):""}),e=r?P:C;n=e.exec(t);)o="%b`"+ ++Y+"`b%",U[Y]=n[0],t=t.replace(e,o);return t},W=function(t){var r;if(null==t)return t;for(;r=G.exec(t);)t=t.replace(G,U[r[1]]);return t.trim()},null==(pr=R.geom)&&(R.geom={}),S=function(){function t(t,r,e){var n,o,a,i;for(null==e&&(e=!0),o=this,o.type=t,o.contours=[],a=0,i=r.length;i>a;a++)n=r[a],J(n)||n.reverse(),o.contours.push(n);o.closed=e}return t.prototype.clipToBBox=function(){throw"path clipping is not implemented yet"},t.prototype.toSVG=function(t){var r;return r=this.svgString(),t.path(r)},t.prototype.svgString=function(){var t,r,e,n,o,a,i,l,s,u,p,h,c;for(n=this,o="",e=n.closed?"Z M":"M",h=n.contours,l=0,u=h.length;u>l;l++)for(t=h[l],r=!0,o+=""===o?"M":e,s=0,p=t.length;p>s;s++)c=t[s],a=c[0],i=c[1],r||(o+="L"),o+=a+","+i,r=!1;return n.closed&&(o+="Z"),o},t.prototype.area=function(){var t,r,e,n,o,a;if(e=this,null!=e.areas)return e._area;for(e.areas=[],e._area=0,a=e.contours,n=0,o=a.length;o>n;n++)r=a[n],t=Q(r),e.areas.push(t),e._area+=t;return e._area},t.prototype.centroid=function(){var t,r,e,n,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b,x,_,w,M,S,k,B,C,L,P,G,A,N,j,z,I,T;if(y=this,null!=y._centroid)return y._centroid;for(e=y.area(),a=i=0,p=B=0,N=y.contours.length-1;N>=0?N>=B:B>=N;p=N>=0?++B:--B)if(o=y.contours[p],n=[],f=o.length,r=y.areas[p],c=r/e,0!==c){for(h=C=0,j=f-1;j>=0?j>=C:C>=j;h=j>=0?++C:--C)if(g=o[h],v=o[(h+1)%f],l=0,n.push(g),g[0]===v[0]&&(l=Math.abs(g[1]-v[1])),g[1]===v[1]&&(l=Math.abs(g[0]-v[0])),l>10)for(t=Math.floor(2*l),m=L=1,z=t-1;z>=1?z>=L:L>=z;m=z>=1?++L:--L)b=[g[0]+m/t*(v[0]-g[0]),g[1]+m/t*(v[1]-g[1])],n.push(b);for(w=S=M=k=0,f=n.length,G=[],x=0,h=P=0,I=f-1;I>=0?I>=P:P>=I;h=I>=0?++P:--P)g=n[h],v=n[(h+1)%f],s=v[0]-g[0],u=v[1]-g[1],d=Math.sqrt(s*s+u*u),G.push(d),x+=d;for(h=A=0,T=f-1;T>=0?T>=A:A>=T;h=T>=0?++A:--A)g=n[h],_=G[h]/x,w+=_*g[0],S+=_*g[1];a+=w*c,i+=S*c}return y._centroid=[a,i],y._centroid},t.prototype.isInside=function(t,r){var e,n,o,a,i,l;if(a=this,e=a._bbox,t<e[0]||t>e[2]||r<e[1]||r>e[3])return!1;for(o=i=0,l=a.contours.length-1;l>=0?l>=i:i>=l;o=l>=0?++i:--i)if(n=a.contours[o],tr(n,[t,r]))return!0;return!1},t}(),R.geom.Path=S,i=function(t){function r(t,e,n){this.x=t,this.y=e,this.r=n,r.__super__.constructor.call(this,"circle",null,!0)}return vr(r,t),r.prototype.toSVG=function(t){var r;return r=this,t.circle(r.x,r.y,r.r)},r.prototype.centroid=function(){var t;return t=this,[t.x,t.y]},r.prototype.area=function(){var t;return t=this,Math.PI*t.r*m.r},r}(S),R.geom.Circle=i,S.fromSVG=function(t){var r,e,n,o,a,i,l,s,u,p,h,c,f,d;if(o=[],c=t.nodeName,p=null,"path"===c){for(s=t.getAttribute("d").trim(),l=Raphael.parsePathString(s),r="Z"===l[l.length-1],h=r?"Z M":"M",n=[],f=0,d=l.length;d>f;f++)e=l[f],0!==e.length&&("M"===e[0]?(n.length>2&&(o.push(n),n=[]),n.push([e[1],e[2]])):"L"===e[0]?n.push([e[1],e[2]]):"Z"===e[0]&&n.length>2&&(o.push(n),n=[]));n.length>=2&&(o.push(n),n=[]),p=new R.geom.Path(c,o,r)}else"circle"===c&&(a=t.getAttribute("cx"),i=t.getAttribute("cy"),u=t.getAttribute("r"),p=new R.geom.Circle(a,i,u));return p},v=function(){function t(t){this.points=t}return t.prototype.clipToBBox=function(r){var e,n,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b,x,_;for(c=this,e=(new R.geom.clipping.CohenSutherland).clip,h=[],i=[],a=!1,o=v=0,m=c.points.length-2;m>=0?m>=v:v>=m;o=m>=0?++v:--v){b=c.points[o],l=b[0],s=b[1],x=c.points[o+1],u=x[0],p=x[1];try{_=e(r,l,s,u,p),f=_[0],y=_[1],d=_[2],g=_[3],a=!0,h.push([f,y]),(u!==d||p!==y||o===len(c.points)-2)&&h.push([d,g])}catch(w){n=w,a&&h.length>1&&(i.push(new t(h)),h=[]),a=!1}}return h.length>1&&i.push(new t(h)),i},t.prototype.toSVG=function(){var t,r,e,n,o,a,i,l;for(r=this,t=[],i=r.points,o=0,a=i.length;a>o;o++)l=i[o],e=l[0],n=l[1],t.push(e+","+n);return"M"+t.join("L")},t}(),R.geom.Line=v,tr=function(t,r){var e,n,o,a,i,l,s,u,p,h,c,f,d,y,g;for(l=Math.PI,n=Math.atan2,p=2*l,i=t.length,e=0,a=y=0,g=i-1;g>=0?g>=y:y>=g;a=g>=0?++y:--y){for(h=t[a][0]-r[0],f=t[a][1]-r[1],c=t[(a+1)%i][0]-r[0],d=t[(a+1)%i][1]-r[1],s=n(f,h),u=n(d,c),o=u-s;o>l;)o-=p;for(;-l>o;)o+=p;e+=o}return Math.abs(e)>=l},J=function(t){return Q(t)>0},Q=function(t){var r,e,n,o,a,i,l,s;for(n=0,e=t.length,r=s=0;e>=0?e>s:s>e;r=e>=0?++s:--s)o=t[r][0],i=t[r][1],a=t[(r+1)%e][0],l=t[(r+1)%e][1],n+=o*l-a*i;return n*=.5},V=function(){function t(t,r,e,n,o,a){var i;i=this,i.bbox=t,i.width=r,i.padding=null!=n?n:0,i.halign=null!=o?o:"center",i.valign=null!=a?a:"center",i.height=e,i.scale=Math.min((r-2*n)/t.width,(e-2*n)/t.height)}return t.prototype.project=function(t,r){var e,n,o,a,i,l,s;return null==r&&(r=t[1],t=t[0]),o=this,a=o.scale,e=o.bbox,n=o.height,i=o.width,l="center"===o.halign?.5*(i-e.width*a):"left"===o.halign?o.padding*a:i-(e.width-o.padding)*a,s="center"===o.valign?.5*(n-e.height*a):"top"===o.valign?o.padding*a:0,t=(t-e.left)*a+l,r=(r-e.top)*a+s,[t,r]},t.prototype.projectPath=function(t){var r,e,n,o,a,i,l,s,u,p,h,c,f,d,y,g,v;if(o=this,"path"===t.type){for(n=[],r=[99999,99999,-99999,-99999],d=t.contours,p=0,c=d.length;c>p;p++){for(i=d[p],e=[],h=0,f=i.length;f>h;h++)y=i[h],s=y[0],u=y[1],g=o.project(s,u),s=g[0],u=g[1],e.push([s,u]),r[0]=Math.min(r[0],s),r[1]=Math.min(r[1],u),r[2]=Math.max(r[2],s),r[3]=Math.max(r[3],u);n.push(e)}return a=new R.geom.Path(t.type,n,t.closed),a._bbox=r,a}return"circle"===t.type?(v=o.project(t.x,t.y),s=v[0],u=v[1],l=t.r*o.scale,new R.geom.Circle(s,u,l)):void 0},t.prototype.asBBox=function(){var t;return t=this,new R.BBox(0,0,t.width,t.height)},t}(),V.fromXML=function(t){var r,e,o,a,i;return i=Number(t.getAttribute("w")),o=Number(t.getAttribute("h")),a=Number(t.getAttribute("padding")),e=t.getElementsByTagName("bbox")[0],r=n.fromXML(e),new R.View(r,i,o,a)},R.View=V,d.prototype.dotgrid=function(t){var r,e,n,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b,x,_,w,M,S,k,B,C,L,P,G,A,N,j,z,I,T,V,O,F,E,R,D,X,q,U,Z,H,W,$;if(v=this,g=null!=(U=t.layer)?U:v.layerIds[v.layerIds.length-1],!v.layers.hasOwnProperty(g))return K('dotgrid error: layer "'+g+'" not found'),void 0;if(y=v.layers[g],e=t.data,n=t.value,o=t.key,b={},null!=o&&"array"===rr(e))for(C=0,A=e.length;A>C;C++)w=e[C],d=w[o],b[String(d)]=w;else for(d in e)w=e[d],b[String(d)]=w;if(s=null!=(Z=t.style)?Z:{fill:"black",stroke:"none"},S=t.size,f=null!=(H=t.gridsize)?H:15,l=null!=(W=y.dotgrid)?W:y.dotgrid={gridsize:f,grid:[]},l.gridsize!==f)for($=l.grid,L=0,N=$.length;N>L;L++)c=$[L],null!=c.shape&&(c.shape.remove(),c.shape=null);if(f>0){if(0===l.grid.length)for(k=P=0,V=v.viewport.width;f>0?V>=P:P>=V;k=P+=f)for(B=G=0,O=v.viewport.height;f>0?O>=G:G>=O;B=G+=f){c={x:k+.2*(Math.random()-.5)*f,y:B+.2*(Math.random()-.5)*f,pathid:!1},h=!1,F=y.pathsById;for(d in F){for(x=F[d],I=0,j=x.length;j>I;I++)if(m=x[I],m.vpath.isInside(c.x,c.y)){h=!0,_=null!=(E=b[d])?E:null,M=S(_),c.pathid=d,c.shape=y.paper.circle(c.x,c.y,1);break}if(h)break}l.grid.push(c)}for(R=l.grid,T=0,z=R.length;z>T;T++)c=R[T],c.pathid&&(_=null!=(D=b[c.pathid])?D:null,M=S(_),p=null!=(X=t.duration)?X:0,a=null!=(q=t.delay)?q:0,i="function"===rr(a)?a(_):a,p>0&&Raphael.svg?(r=Raphael.animation({r:.5*M},p),c.shape.animate(r.delay(i))):c.shape.attr({r:.5*M}),u="function"===rr(s)?s(_):s,c.shape.attr(u))}},F=null!=(hr=R.filter)?hr:R.filter={},F.__knownFilter={},F.__patternFills=0,w.prototype.SVG=function(t,r){var e,n;if("string"==typeof t&&(t=window.document.createElementNS("http://www.w3.org/2000/svg",t)),r)for(e in r)n=r[e],t.setAttribute(e,n);return t},d.prototype.addFilter=function(t,r,e){var n,o,a;if(null==e&&(e={}),a=this,n=window.document,null==R.filter[r])throw"unknown filter type "+r;return o=new R.filter[r](e).getFilter(t),a.paper.defs.appendChild(o)},w.prototype.applyFilter=function(t){var r;return r=this,e("."+r.id,r.paper.canvas).attr({filter:"url(#"+t+")"})},w.prototype.applyTexture=function(t,r,e){var n,o,a,i,l,s;for(null==r&&(r=!1),null==e&&(e="#000"),o=this,F.__patternFills+=1,l=o.paths,s=[],a=0,i=l.length;i>a;a++)n=l[a],!r||r(n.data)?s.push(n.svgPath.attr({fill:"url("+t+")"})):s.push(n.svgPath.attr("fill",e));return s},u=function(){function t(t){this.params=null!=t?t:{}}return t.prototype.getFilter=function(t){var r,e;return e=this,r=e.SVG("filter",{id:t}),e.buildFilter(r),r},t.prototype._getFilter=function(){throw"not implemented"},t.prototype.SVG=function(t,r){var e,n;if("string"==typeof t&&(t=window.document.createElementNS("http://www.w3.org/2000/svg",t)),r)for(e in r)n=r[e],t.setAttribute(e,n);return t},t}(),o=function(t){function r(){return cr=r.__super__.constructor.apply(this,arguments)}return vr(r,t),r.prototype.buildFilter=function(t){var r,e,n;return n=this,r=n.SVG,e=r("feGaussianBlur",{stdDeviation:n.params.size||4,result:"blur"}),t.appendChild(e)},r}(u),F.blur=o,E=function(t){var r,e,n,o;if(t.trim().match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/))return(4===t.length||7===t.length)&&(t=t.substr(1)),3===t.length&&(t=t.split(""),t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),o=parseInt(t,16),n=o>>16,e=255&o>>8,r=255&o,[n,e,r];throw'unknown color format: "'+t+'"'},p=function(t){function r(){return fr=r.__super__.constructor.apply(this,arguments)}return vr(r,t),r.prototype.buildFilter=function(t){var r,e,n,o,a,i,l,s,u,p,h,c,f;a=this,e=null!=(c=a.params.blur)?c:4,l=null!=(f=a.params.strength)?f:1,i=null!=(s=a.params.color)?s:"#D1BEB0","string"===rr(i)&&(i=E(i)),n=null!=(u=a.params.inner)?u:!1,o=null!=(p=a.params.knockout)?p:!1,r=null!=(h=a.params.alpha)?h:1,n?a.innerGlow(t,e,l,i,r,o):a.outerGlow(t,e,l,i,r,o)},r.prototype.outerGlow=function(t,r,e,n,o,a){var i,l,s,u,p,h,c;return p=this,i=p.SVG,u=i("feColorMatrix",{"in":"SourceGraphic",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0",result:"mask"}),t.appendChild(u),e>0&&(c=i("feMorphology",{"in":"mask",radius:e,operator:"dilate",result:"mask"}),t.appendChild(c)),u=i("feColorMatrix",{"in":"mask",type:"matrix",values:"0 0 0 0 "+n[0]/255+" 0 0 0 0 "+n[1]/255+" 0 0 0 0 "+n[2]/255+" 0 0 0 1 0",result:"r0"}),t.appendChild(u),l=i("feGaussianBlur",{"in":"r0",stdDeviation:r,result:"r1"}),t.appendChild(l),s=i("feComposite",{operator:"out","in":"r1",in2:"mask",result:"comp"}),t.appendChild(s),h=i("feMerge"),a||h.appendChild(i("feMergeNode",{"in":"SourceGraphic"})),h.appendChild(i("feMergeNode",{"in":"r1"})),t.appendChild(h)},r.prototype.innerGlow=function(t,r,e,n,o,a){var i,l,s,u,p,h,c;return p=this,i=p.SVG,D("innerglow"),u=i("feColorMatrix",{"in":"SourceGraphic",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 500 0",result:"mask"}),t.appendChild(u),c=i("feMorphology",{"in":"mask",radius:e,operator:"erode",result:"r1"}),t.appendChild(c),l=i("feGaussianBlur",{"in":"r1",stdDeviation:r,result:"r2"}),t.appendChild(l),u=i("feColorMatrix",{type:"matrix","in":"r2",values:"1 0 0 0 "+n[0]/255+" 0 1 0 0 "+n[1]/255+" 0 0 1 0 "+n[2]/255+" 0 0 0 -1 1",result:"r3"}),t.appendChild(u),s=i("feComposite",{operator:"in","in":"r3",in2:"mask",result:"comp"}),t.appendChild(s),h=i("feMerge"),a||h.appendChild(i("feMergeNode",{"in":"SourceGraphic"})),h.appendChild(i("feMergeNode",{"in":"comp"})),t.appendChild(h)},r}(u),F.glow=p,d.prototype.addGeoPath=function(t,r,e){var n,o,a;return null==r&&(r=[]),null==e&&(e=""),n=this,a=n.getGeoPathStr(t,r),o=n.paper.path(a),""!==e&&o.node.setAttribute("class",e),o},d.prototype.getGeoPathStr=function(t,r){var e,n,o,a,i,l,s;null==r&&(r=[]),o=this,"string"===rr(r)&&(r=r.split("")),0===r.length&&r.push("M"),a="";for(n in t)i=t[n],e=null!=(s=r[n])?s:"L",l=o.lonlat2xy(i),isNaN(l[0])||isNaN(l[1])||(a+=e+l[0]+","+l[1]);return a},d.prototype.addGeoPolygon=function(t,r){var e,n,o;o=this,e=["M"];for(n in t)e.push("L");return e.push("Z"),o.addGeoPath(t,e,r)},A=function(){function t(t,r,e){var n,o,a,i;null==t&&(t=[0,1]),null==r&&(r=null),null==e&&(e=null),this.rangedScale=mr(this.rangedScale,this),this.scale=mr(this.scale,this),o=this,i=[];for(n in t)("function"!==rr(e)||e(t[n])!==!1)&&(a=null!=r?"function"===rr(r)?r(t[n]):t[n][r]:t[n],isNaN(a)||i.push(a));i=i.sort(function(t,r){return t-r}),o.values=i,o._range=[0,1],o.rangedScale.range=function(t){return o._range=t,o.rangedScale}}return t.prototype.scale=function(t){return t},t.prototype.rangedScale=function(t){var r,e;return r=this,t=r.scale(t),e=r._range,t*(e[1]-e[0])+e[0]},t}(),b=function(t){function r(){return this.scale=mr(this.scale,this),dr=r.__super__.constructor.apply(this,arguments)}return vr(r,t),r.prototype.scale=function(t){var r,e;return r=this,e=r.values,(t-e[0])/(e[e.length-1]-e[0])},r}(A),x=function(t){function r(){return this.scale=mr(this.scale,this),yr=r.__super__.constructor.apply(this,arguments)}return vr(r,t),r.prototype.scale=function(t){var r,e;return r=this,e=r.values,D=Math.log,(D(t)-D(e[0]))/(D(e[e.length-1])-D(e[0]))},r}(A),N=function(t){function r(){return this.scale=mr(this.scale,this),ir=r.__super__.constructor.apply(this,arguments)}return vr(r,t),r.prototype.scale=function(t){var r,e;return r=this,e=r.values,Math.sqrt((t-e[0])/(e[e.length-1]-e[0]))},r}(A),B=function(t){function r(){return this.scale=mr(this.scale,this),lr=r.__super__.constructor.apply(this,arguments)}return vr(r,t),r.prototype.scale=function(t){var r,e,n,o,a,i;n=this,i=n.values,e=i.length-1;for(r in i){if(a=i[Number(r)],o=i[Number(r)+1],t===a)return r/e;if(e>r&&t>a&&o>t)return r/e+(t-a)/(o-a)}},r}(A),R.scale={},R.scale.identity=function(){return new A(domain,prop,F).rangedScale},R.scale.linear=function(t,r,e){return new b(t,r,e).rangedScale},R.scale.log=function(t,r,e){return new x(t,r,e).rangedScale},R.scale.sqrt=function(t,r,e){return new N(t,r,e).rangedScale},R.scale.quantile=function(t,r,e){return new B(t,r,e).rangedScale},I=function(){function t(t){r=this,r.location=t.location,r.data=t.data,r.map=t.map,r.layers=t.layers,r.key=t.key,r.x=t.x,r.y=t.y}var r;return r=null,t.prototype.init=function(){return r},t.prototype.overlaps=function(){return!1},t.prototype.update=function(){return r},t.prototype.nodes=function(){return[]},t.prototype.clear=function(){return r},t}(),R.Symbol=I,T=function(){function r(t){this._initTooltips=mr(this._initTooltips,this),this._noverlap=mr(this._noverlap,this),this._kMeans=mr(this._kMeans,this);var e,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b,x,_,w;for(n=this,c=["data","location","type","map"],p=["filter","tooltip","click","delay","sortBy","clustering","aggregate","clusteringOpts","mouseenter","mouseleave"],f=0,v=c.length;v>f;f++){if(h=c[f],null==t[h])throw"SymbolGroup: missing argument '"+h+"'";n[h]=t[h]}for(d=0,m=p.length;m>d;d++)h=p[d],null!=t[h]&&(n[h]=t[h]);
if(e=n.type,null==e)return K("could not resolve symbol type",n.type),void 0;for(_=e.props,y=0,b=_.length;b>y;y++)h=_[y],null!=t[h]&&(n[h]=t[h]);for(n.layers={mapcanvas:n.map.paper},w=e.layers,g=0,x=w.length;x>g;g++)l=w[g],u=r._layerid++,i="sl_"+u,"svg"===l.type?s=n.map.createSVGLayer(i):"html"===l.type&&(s=n.map.createHTMLLayer(i)),n.layers[l.id]=s;n.symbols=[];for(a in n.data)o=n.data[a],"function"===rr(n.filter)?n.filter(o,a)&&n.add(o,a):n.add(o,a);n.layout(),n.render(),n.map.addSymbolGroup(n)}var n;return n=null,r.prototype.add=function(t,r){var e,o,a,i,l,s,u,p;for(n=this,e=n.type,o=n._evaluate(n.location,t,r),"array"===rr(o)&&(o=new R.LonLat(o[0],o[1])),i={layers:n.layers,location:o,data:t,key:null!=r?r:n.symbols.length,map:n.map},p=e.props,s=0,u=p.length;u>s;s++)a=p[s],null!=n[a]&&(i[a]=n._evaluate(n[a],t,r));return l=new e(i),n.symbols.push(l),l},r.prototype.layout=function(){var t,r,e,o,a,i,l,s,u,p;for(u=n.symbols,l=0,s=u.length;s>l;l++){if(a=u[l],r=a.location,"string"===rr(r)){if(p=r.split("."),t=p[0],o=p[1],e=n.map.getLayerPath(t,o),null==e){K("could not find layer path "+t+"."+o);continue}i=n.map.viewBC.project(e.path.centroid())}else i=n.map.lonlat2xy(r);a.x=i[0],a.y=i[1]}return"k-means"===n.clustering?n._kMeans():"noverlap"===n.clustering&&n._noverlap(),n},r.prototype.render=function(){var t,r,o,a,i,l,s,u,p,h,c;for(n=this,n.sortBy&&(a="asc","string"===rr(n.sortBy)&&(n.sortBy=n.sortBy.split(" ",2),o=n.sortBy[0],a=null!=(p=n.sortBy[1])?p:"asc"),n.symbols=n.symbols.sort(function(t,r){var e,i,l;return"function"===rr(n.sortBy)?(i=n.sortBy(t.data,t),l=n.sortBy(r.data,r)):(i=t[o],l=r[o]),i===l?0:(e="asc"===a?1:-1,i>l?1*e:-1*e)})),h=n.symbols,i=0,s=h.length;s>i;i++)for(r=h[i],r.render(),c=r.nodes(),l=0,u=c.length;u>l;l++)t=c[l],t.symbol=r;return"function"===rr(n.tooltip)&&n._initTooltips(),e.each(["click","mouseenter","mouseleave"],function(o,a){var i,l,s,u;if("function"===rr(n[a])){for(s=n.symbols,u=[],i=0,l=s.length;l>i;i++)r=s[i],u.push(function(){var o,i,l,s;for(l=r.nodes(),s=[],o=0,i=l.length;i>o;o++)t=l[o],s.push(e(t)[a](function(t){var r;for(r=t.target;!r.symbol;)r=e(r).parent().get(0);return t.stopPropagation(),n[a](r.symbol.data,r.symbol,t)}));return s}.call(this));return u}}),n},r.prototype.tooltips=function(t){return n=this,n.tooltips=t,n._initTooltips(),n},r.prototype.remove=function(t){var r,e,o,a,i,l,s,u,p,h;for(n=this,o=[],u=n.symbols,l=0,s=u.length;s>l;l++)if(i=u[l],null==t||t(i.data))try{i.clear()}catch(c){r=c,K("error: symbolgroup.remove")}else o.push(i);if(null==t){p=n.layers,h=[];for(e in p)a=p[e],"mapcanvas"!==e?h.push(a.remove()):h.push(void 0);return h}return n.symbols=o},r.prototype._evaluate=function(t,r,e){var n;return n="function"===rr(t)?t(r,e):t},r.prototype._kMeans=function(){var r,e,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b,x,_,w,M,S;for(n=this,null==(_=n.osymbols)&&(n.osymbols=n.symbols),r=n.type,null!=n.clusteringOpts&&(h=n.clusteringOpts.size),null==h&&(h=64),e=t().iterations(16).size(h),w=n.osymbols,f=0,v=w.length;v>f;f++)p=w[f],e.add({x:p.x,y:p.y});for(l=e.means(),s=[],d=0,m=l.length;m>d;d++)if(i=l[d],0!==i.size){for(o=[],M=i.indices,y=0,b=M.length;b>y;y++)a=M[y],o.push(n.osymbols[a].data);for(o=n.aggregate(o),c={layers:n.layers,location:!1,data:o,map:n.map},S=r.props,g=0,x=S.length;x>g;g++)u=S[g],null!=n[u]&&(c[u]=n._evaluate(n[u],o));p=new r(c),p.x=i.x,p.y=i.y,s.push(p)}return n.symbols=s},r.prototype._noverlap=function(){var t,r,e,o,a,i,l,s,u,p,h,c,f,d,y,g,v,m,b,x,_,w,M,S,k,B,C,L,P,G,A,N,j,z,I,T,V,O,F,E,R,D,X,q,U,Z,H;if(n=this,null==(D=n.osymbols)&&(n.osymbols=n.symbols),u=3,t=n.type,br.call(t.props,"radius")<0)return K('noverlap layout only available for symbols with property "radius"'),void 0;for(B=n.osymbols.slice(),null!=n.clusteringOpts&&(P=n.clusteringOpts.tolerance,f=n.clusteringOpts.maxRatio),null==P&&(P=.05),null==f&&(f=.8),l=j=0,X=u-1;X>=0?X>=j:j>=X;l=X>=0?++j:--j){for(B.sort(function(t,r){return r.radius-t.radius}),p=B.length,d=[],y=z=0,q=p-3;q>=0?q>=z:z>=q;y=q>=0?++z:--z)if(M=B[y]){for(x=M.radius*(1-P),h=M.x-x,m=M.x+x,C=M.y-x,r=M.y+x,s=[],g=I=U=y+1,Z=p-2;Z>=U?Z>=I:I>=Z;g=Z>=U?++I:--I)S=B[g],S&&(_=S.radius,c=S.x-_,b=S.x+_,L=S.y-_,e=S.y+_,_/M.radius<f&&(c>m||h>b||L>r||C>e||(a=S.x-M.x,i=S.y-M.y,(x+_)*(x+_)>a*a+i*i&&s.push(g))));if(s.length>0){for(o=[M.data],v=M.radius*M.radius,T=0,V=s.length;V>T;T++)l=s[T],o.push(B[l].data),v+=B[l].radius*B[l].radius;for(o=n.aggregate(o),k={layers:n.layers,location:!1,data:o,map:n.map},H=t.props,E=0,O=H.length;O>E;E++)y=H[E],null!=n[y]&&(k[y]=n._evaluate(n[y],o));for(w=new t(k),G=M.radius*M.radius/v,A=M.x*G,N=M.y*G,R=0,F=s.length;F>R;R++)l=s[R],S=B[l],G=S.radius*S.radius/v,A+=S.x*G,N+=S.y*G,B[l]=void 0;w.x=A,w.y=N,B[y]=void 0,d.push(w)}else d.push(M)}B=d}return n.symbols=B},r.prototype._initTooltips=function(){var t,r,o,a,i,l,s,u,p,h,c;for(n=this,a=n.tooltip,h=n.symbols,l=0,u=h.length;u>l;l++)for(o=h[l],t={position:{target:"mouse",viewport:e(window),adjust:{x:7,y:7}},show:{delay:20},content:{},events:{show:function(t,r){return e(".qtip").filter(function(){return this!==r.elements.tooltip.get(0)}).hide()}}},i=a(o.data,o.key),"string"===rr(i)?t.content.text=i:"array"===rr(i)&&(t.content.title=i[0],t.content.text=i[1]),c=o.nodes(),s=0,p=c.length;p>s;s++)r=c[s],e(r).qtip(t)},r.prototype.onResize=function(){var t,r,e,o;for(n=this,n.layout(),o=n.symbols,r=0,e=o.length;e>r;r++)t=o[r],t.update()},r.prototype.update=function(t,r,e){var o,a,i,l,s,u,p,h;for(n=this,null==t&&(t={}),p=n.symbols,i=0,s=p.length;s>i;i++){for(a=p[i],h=n.type.props,l=0,u=h.length;u>l;l++)o=h[l],null!=t[o]?a[o]=n._evaluate(t[o],a.data):null!=n[o]&&(a[o]=n._evaluate(n[o],a.data));a.update(r,e)}return n},r}(),T._layerid=0,R.SymbolGroup=T,d.prototype.addSymbols=function(t){return t.map=this,new T(t)},R.dorlingLayout=function(t,r){var n,o,a,i,l,s,u,p,h,c,f,d,y,g,v;for(null==r&&(r=40),f=[],e.each(t.symbols,function(t,r){return f.push({i:t,x:r.path.attrs.cx,y:r.path.attrs.cy,r:r.path.attrs.r})}),f.sort(function(t,r){return r.r-t.r}),a=function(){var r,e,n;for(e=0,n=f.length;n>e;e++)r=f[e],t.symbols[r.i].path.attr({cx:r.x,cy:r.y})},d=v=1;r>=1?r>=v:v>=r;d=r>=1?++v:--v)for(h in f)for(c in f)if(c>h){if(n=f[h],o=f[c],n.x+n.r<o.x-o.r||n.x-n.r>o.x+o.r)continue;if(n.y+n.r<o.y-o.r||n.y-n.r>o.y+o.r)continue;s=n.x-o.x,u=n.y-o.y,l=s*s+u*u,y=n.r+o.r,g=y*y,g>l&&(i=Math.sqrt(l),p=10/i,n.x+=s*p*(1-n.r/y),n.y+=u*p*(1-n.r/y),o.x-=s*p*(1-o.r/y),o.y-=u*p*(1-o.r/y))}return a()},a=function(t){function r(t){this.nodes=mr(this.nodes,this),this.clear=mr(this.clear,this),this.update=mr(this.update,this),this.render=mr(this.render,this),this.overlaps=mr(this.overlaps,this);var e,n,o;e=this,r.__super__.constructor.call(this,t),e.radius=null!=(n=t.radius)?n:4,e.style=t.style,e.attrs=t.attrs,e.title=t.title,e["class"]=null!=(o=t["class"])?o:"bubble"}return vr(r,t),r.prototype.overlaps=function(t){var r,e,n,o,a,i,l,s,u,p,h;return n=this,p=[n.x,n.y,n.radius],i=p[0],s=p[1],o=p[2],h=[t.x,t.y,t.radius],l=h[0],u=h[1],a=h[2],i-o>l+a||l-a>i+o||s-o>u+a||u-a>s+o?!1:(r=i-l,e=s-u,r*r+e*e>(o+a)*(o+a)?!1:!0)},r.prototype.render=function(){var t;return t=this,null==t.path&&(t.path=t.layers.mapcanvas.circle(t.x,t.y,t.radius)),t.update(),t.map.applyCSS(t.path),t},r.prototype.update=function(t,r){var n,o,a;return null==t&&(t=!1),null==r&&(r="expo-out"),o=this,a=o.path,n={cx:o.x,cy:o.y,r:o.radius},null!=o.attrs&&(n=e.extend(n,o.attrs)),t?a.animate(n,t,r):a.attr(n),null!=a.node&&(null!=o.style&&a.node.setAttribute("style",o.style),null!=o["class"]&&a.node.setAttribute("class",o["class"])),null!=o.title&&a.attr("title",o.title),o},r.prototype.clear=function(){var t;return t=this,t.path.remove(),t},r.prototype.nodes=function(){var t;return t=this,[t.path.node]},r}(I),a.props=["radius","style","class","title","attrs"],a.layers=[],R.Bubble=a,c=function(t){function r(t){var e,n,o,a,i,l;e=this,r.__super__.constructor.call(this,t),e.icon=null!=(n=t.icon)?n:"",e.offset=null!=(o=t.offset)?o:[0,0],e.iconsize=null!=(a=t.iconsize)?a:[10,10],e["class"]=null!=(i=t["class"])?i:"",e.title=null!=(l=t.title)?l:""}return vr(r,t),r.prototype.render=function(){var t,r;return r=this,t=r.map.container,r.img=e("<img />"),r.img.attr({src:r.icon,title:r.title,alt:r.title,width:r.iconsize[0],height:r.iconsize[1]}),r.img.addClass(r["class"]),r.img.css({position:"absolute","z-index":1e3,cursor:"pointer"}),r.img[0].symbol=r,t.append(r.img),r.update()},r.prototype.update=function(){var t;return t=this,t.img.css({left:t.x+t.offset[0]+"px",top:t.y+t.offset[1]+"px"})},r.prototype.clear=function(){var t;return t=this,t.img.remove(),t},r.prototype.nodes=function(){var t;return t=this,[t.img]},r}(R.Symbol),c.props=["icon","offset","class","title","iconsize"],c.layers=[],R.Icon=c,z=function(t){function r(t){var e,n,o,a,i;e=this,r.__super__.constructor.call(this,t),e.text=null!=(n=t.text)?n:"",e.style=null!=(o=t.style)?o:"",e["class"]=null!=(a=t["class"])?a:"",e.offset=null!=(i=t.offset)?i:[0,0]}return vr(r,t),r.prototype.render=function(){var t,r;return r=this,r.lbl=t=r.layers.mapcanvas.text(r.x,r.y,r.text),r.update(),r},r.prototype.update=function(){var t;return t=this,t.lbl.attr({x:t.x+t.offset[0],y:t.y+t.offset[1]}),t.lbl.node.setAttribute("style",t.style),t.lbl.node.setAttribute("class",t["class"])},r.prototype.clear=function(){var t;return t=this,t.lbl.remove(),t},r.prototype.nodes=function(){var t;return t=this,[t.lbl.node]},r}(R.Symbol),z.props=["text","style","class","offset"],z.layers=[],R.Label=z,h=function(t){function r(t){var e,n,o,a;e=this,r.__super__.constructor.call(this,t),e.text=null!=(n=t.text)?n:"",e.css=null!=(o=t.css)?o:"",e["class"]=null!=(a=t["class"])?a:""}return vr(r,t),r.prototype.render=function(){var t,r,n;return n=this,t=e("<div>"+n.text+"</div>"),t.css({width:"80px",position:"absolute",left:"-40px","text-align":"center"}),n.lbl=r=e('<div class="label" />'),r.append(t),n.layers.lbl.append(r),t.css({height:t.height()+"px",top:t.height()*-.4+"px"}),n.update(),n},r.prototype.update=function(){var t;return t=this,t.lbl.css({position:"absolute",left:t.x+"px",top:t.y+"px"}),t.lbl.css(t.css)},r.prototype.clear=function(){var t;return t=this,t.lbl.remove(),t},r.prototype.nodes=function(){var t;return t=this,[t.lbl[0]]},r}(R.Symbol),h.props=["text","css","class"],h.layers=[{id:"lbl",type:"html"}],R.HtmlLabel=h,y=function(t){function r(t){this.nodes=mr(this.nodes,this),this.clear=mr(this.clear,this),this.update=mr(this.update,this),this.render=mr(this.render,this);var e,n,o;e=this,r.__super__.constructor.call(this,t),e.labelattrs=null!=(n=t.labelattrs)?n:{},e.buffer=t.buffer,e.center=null!=(o=t.center)?o:!0}return vr(r,t),r.prototype.render=function(t){var e;return e=this,null!=e.title&&""!==String(e.title).trim()&&(e.buffer&&(e.bufferlabel=e.layers.mapcanvas.text(e.x,e.y,e.title)),e.label=e.layers.mapcanvas.text(e.x,e.y,e.title)),r.__super__.render.call(this,t),e},r.prototype.update=function(t,n){var o,a,i,l,s;return null==t&&(t=!1),null==n&&(n="expo-out"),a=this,r.__super__.update.call(this,t,n),null!=a.label&&(i=a.map.viewport,o=e.extend({},a.labelattrs),l=a.x,s=a.y,a.center?s-=0:l>.5*i.width?(o["text-anchor"]="end",l-=a.radius+5):l<.5*i.width&&(o["text-anchor"]="start",l+=a.radius+5),o.x=l,o.y=s,a.buffer&&(a.bufferlabel.attr(o),a.bufferlabel.attr({stroke:"#fff",fill:"#fff","stroke-linejoin":"round","stroke-linecap":"round","stroke-width":6})),a.label.attr(o),a.label.toFront()),a},r.prototype.clear=function(){var t;return t=this,r.__super__.clear.apply(this,arguments)},r.prototype.nodes=function(){var t,e;return t=this,e=r.__super__.nodes.apply(this,arguments),t.label&&e.push(t.label.node),t.bufferlabel&&e.push(t.bufferlabel.node),e},r}(a),y.props=["radius","style","class","title","labelattrs","buffer","center","attrs"],y.layers=[],R.LabeledBubble=y,k=function(t){function r(t){var n,o,a,i,l,s,u,p,h,c;e=this,r.__super__.constructor.call(this,t),e.radius=null!=(o=t.radius)?o:4,e.styles=null!=(a=t.styles)?a:"",e.colors=null!=(i=t.colors)?i:["#3cc","#c3c","#33c","#cc3"],e.titles=null!=(l=t.titles)?l:["","","","",""],e.values=null!=(s=t.values)?s:[],e.border=null!=(u=t.border)?u:!1,e.borderWidth=null!=(p=t.borderWidth)?p:2,e["class"]=null!=(h=t["class"])?h:"piechart",null==(c=(n=Raphael.fn).pieChart)&&(n.pieChart=O)}var e;return vr(r,t),e=null,r.prototype.overlaps=function(t){var r,n,o,a,i,l,s,u,p,h;return p=[e.x,e.y,e.radius],i=p[0],s=p[1],o=p[2],h=[t.x,t.y,t.radius],l=h[0],u=h[1],a=h[2],i-o>l+a||l-a>i+o||s-o>u+a||u-a>s+o?!1:(r=i-l,n=s-u,r*r+n*n>(o+a)*(o+a)?!1:!0)},r.prototype.render=function(){var t;return e=this,null!=e.border&&(t=e.layers.mapcanvas.circle(e.x,e.y,e.radius+e.borderWidth).attr({stroke:"none",fill:e.border})),e.chart=e.layers.mapcanvas.pieChart(e.x,e.y,e.radius,e.values,e.titles,e.colors,"none"),e.chart.push(t),e},r.prototype.update=function(){},r.prototype.clear=function(){var t,r,n,o;for(e=this,o=e.chart,r=0,n=o.length;n>r;r++)t=o[r],t.remove();return e},r.prototype.nodes=function(){var t,r,n,o,a;for(o=e.chart,a=[],r=0,n=o.length;n>r;r++)t=o[r],a.push(t.node);return a},r}(I),k.props=["radius","values","styles","class","titles","colors","border","borderWidth"],k.layers=[],R.PieChart=k,O=function(t,r,e,n,o,a,i){var l,s,u,p,h,c,f,d,y,g,v;if(isNaN(t)||isNaN(r)||isNaN(e))return[];for(p=this,c=Math.PI/180,s=p.set(),f=function(t,r,e,n,o,a){var i,l,s,u;return i=t+e*Math.cos(-n*c),l=t+e*Math.cos(-o*c),s=r+e*Math.sin(-n*c),u=r+e*Math.sin(-o*c),p.path(["M",t,r,"L",i,s,"A",e,e,0,+(o-n>180),0,l,u,"z"]).attr(a)},l=-270,d=0,h=function(o){var u,p,h,c,y,g,v;v=n[o],u=360*v/d,g=l+.5*u,p=a[o],c=500,h=30,y=f(t,r,e,l,l+u,{fill:p,stroke:i,"stroke-width":1}),y.mouseover(function(){y.stop().animate({transform:"s1.1 1.1 "+t+" "+r},c,"elastic")}),y.mouseout(function(){y.stop().animate({transform:""},c,"elastic")}),l+=u,s.push(y)},g=0,v=n.length;v>g;g++)y=n[g],d+=y;for(u in n)h(u);return s},drawStackedBars=function(t,r,e,n,o,a,i,l){function s(t,r,e,n,o){return u.rect(t,r,e,n).attr(o)}for(var u=this,p=this.set(),h=0,c=0,f=function(a){var u=o[a],f=n*u/c,d=t-.5*e,y=r+.5*n-h,g=e,v=i[a],m=500,b=s(d,y-f,g,f,{fill:v,stroke:l,"stroke-width":1});h+=f,b.mouseover(function(){b.stop().animate({transform:"s1.1 1.1 "+t+" "+r},m,"elastic")}).mouseout(function(){b.stop().animate({transform:""},m,"elastic")}),p.push(b)},d=0,y=o.length;y>d;d++)c+=o[d];for(d=0;y>d;d++)f(d);return p},j=function(t){function r(t){var e,n,o,a,i,l,s,u,p,h;e=this,r.__super__.constructor.call(this,t),e.styles=null!=(o=t.styles)?o:"",e.colors=null!=(a=t.colors)?a:[],e.titles=null!=(i=t.titles)?i:["","","","",""],e.values=null!=(l=t.values)?l:[],e.width=null!=(s=t.width)?s:17,e.height=null!=(u=t.height)?u:30,e["class"]=null!=(p=t["class"])?p:"barchart",null==(h=(n=Raphael.fn).drawStackedBarChart)&&(n.drawStackedBarChart=drawStackedBars)}return vr(r,t),r.prototype.overlaps=function(t){var r,e,n,o,a,i,l,s,u,p,h;return n=this,p=[n.x,n.y,n.radius],i=p[0],s=p[1],o=p[2],h=[t.x,t.y,t.radius],l=h[0],u=h[1],a=h[2],i-o>l+a||l-a>i+o||s-o>u+a||u-a>s+o?!1:(r=i-l,e=s-u,r*r+e*e>(o+a)*(o+a)?!1:!0)},r.prototype.render=function(){var t,r,e,n,o,a;return e=this,n=e.width,r=e.height,o=e.x,a=e.y,t=e.layers.mapcanvas.rect(o-.5*n-2,a-.5*r-2,n+4,r+4).attr({stroke:"none",fill:"#fff"}),e.chart=e.layers.mapcanvas.drawStackedBarChart(e.x,e.y,e.width,e.height,e.values,e.titles,e.colors,"none"),e.chart.push(t),e},r.prototype.update=function(){var t;t=this},r.prototype.clear=function(){var t,r,e,n,o;for(t=this,o=t.chart,e=0,n=o.length;n>e;e++)r=o[e],r.remove();return t.chart=[],t},r.prototype.nodes=function(){var t,r,e,n,o,a;for(r=this,o=r.chart,a=[],e=0,n=o.length;n>e;e++)t=o[e],a.push(t.node);return a},r}(R.Symbol),j.props=["values","styles","class","titles","colors","width","height"],j.layers=[],R.StackedBarChart=j}.call(this);