-
Notifications
You must be signed in to change notification settings - Fork 4
/
api.js
172 lines (172 loc) · 102 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
function h(a){throw a;}var j=void 0,k=!0,n=null,p=!1;function aa(a){return function(b){this[a]=b}}function r(a){return function(){return this[a]}}function ba(a){return function(){return a}}var s,u=this;function ca(){}
function da(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if("function"==b&&"undefined"==typeof a.call)return"object";return b}function w(a){return a!==j}function x(a){return a===n}function y(a){return a!=n}function ea(a){return"array"==da(a)}function z(a){var b=da(a);return"array"==b||"object"==b&&"number"==typeof a.length}function A(a){return"string"==typeof a}function fa(a){return"number"==typeof a}function ga(a){return"function"==da(a)}function ia(a){var b=typeof a;return"object"==b&&a!=n||"function"==b}
function C(a){return a[ja]||(a[ja]=++ka)}var ja="closure_uid_"+Math.floor(2147483648*Math.random()).toString(36),ka=0;function la(a,b,c){return a.call.apply(a.bind,arguments)}function ma(a,b,c){a||h(Error());if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}
function D(a,b,c){D=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?la:ma;return D.apply(n,arguments)}var E=Date.now||function(){return+new Date};function F(a,b){var c=a.split("."),d=u;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&w(b)?d[e]=b:d=d[e]?d[e]:d[e]={}}function G(a,b){function c(){}c.prototype=b.prototype;a.va=b.prototype;a.prototype=new c};function na(a){if(!oa.test(a))return a;-1!=a.indexOf("&")&&(a=a.replace(pa,"&"));-1!=a.indexOf("<")&&(a=a.replace(qa,"<"));-1!=a.indexOf(">")&&(a=a.replace(ra,">"));-1!=a.indexOf('"')&&(a=a.replace(sa,"""));return a}var pa=/&/g,qa=/</g,ra=/>/g,sa=/\"/g,oa=/[&<>\"]/;function ta(){return Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^E()).toString(36)};var H=Array.prototype,ua=H.indexOf?function(a,b,c){return H.indexOf.call(a,b,c)}:function(a,b,c){c=c==n?0:0>c?Math.max(0,a.length+c):c;if(A(a))return!A(b)||1!=b.length?-1:a.indexOf(b,c);for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},I=H.forEach?function(a,b,c){H.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=A(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)},va=H.filter?function(a,b,c){return H.filter.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=[],f=0,g=A(a)?a.split(""):
a,i=0;i<d;i++)if(i in g){var l=g[i];b.call(c,l,i,a)&&(e[f++]=l)}return e},wa=H.every?function(a,b,c){return H.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=A(a)?a.split(""):a,f=0;f<d;f++)if(f in e&&!b.call(c,e[f],f,a))return p;return k};function xa(a,b){var c=ua(a,b),d;(d=0<=c)&&H.splice.call(a,c,1);return d}function ya(a){return H.concat.apply(H,arguments)}function za(a){if(ea(a))return ya(a);for(var b=[],c=0,d=a.length;c<d;c++)b[c]=a[c];return b}
function Aa(a,b,c){return 2>=arguments.length?H.slice.call(a,b):H.slice.call(a,b,c)}function Ba(a,b){H.sort.call(a,b||Ca)}function Ca(a,b){return a>b?1:a<b?-1:0}function Da(a){for(var b=[],c=0;c<arguments.length;c++){var d=arguments[c];ea(d)?b.push.apply(b,Da.apply(n,d)):b.push(d)}return b};function J(a,b,c){return Math.min(Math.max(a,b),c)}function K(a,b){var c=a%b;return 0>c*b?c+b:c}function L(a){return a*Math.PI/180}function M(a){return 180*a/Math.PI};(function(a){function b(a){for(var b=a.length,c=new Uint8Array(3*(b/4)|0),i=0,l=0,m=[0,0],q=0,o=0;b--;){var v=a.charCodeAt(i++),t=d[v-43];255!==t&&t!==j&&(m[1]=m[0],m[0]=v,o=o<<6|t,q++,4===q&&(c[l++]=o>>>16,61!==m[1]&&(c[l++]=o>>>8),61!==m[0]&&(c[l++]=o),q=0))}return c.buffer}var c=/\s*;\s*base64\s*(?:;|$)/i,d=new Uint8Array([62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,0,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,
34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]);HTMLCanvasElement&&!HTMLCanvasElement.prototype.hd&&(HTMLCanvasElement.prototype.hd=function(d,f){f||(f="image/png");if(this.mozGetAsFile)d(this.mozGetAsFile("canvas",f));else{var g=this.toDataURL.apply(this,Array.prototype.slice.call(arguments,1)),i=g.indexOf(","),l=g.substring(i+1),g=c.test(g.substring(0,i)),i=new (a.BlobBuilder||a.WebKitBlobBuilder||a.MozBlobBuilder);g?i.append(b(l)):i.append(decodeURIComponent(l));d(i.getBlob(f))}})})(self);
var Ea,Fa=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder,Ga=window.URL||window.webkitURL||window.mozURL,Ha=navigator.saveBlob||navigator.mozSaveBlob||navigator.webkitSaveBlob,Ia=window.saveAs||window.webkitSaveAs||window.mozSaveAs;
Fa&&(Ia||Ha)?Ea=function(a,b,c){var d=new Fa;d.append(a);a=d.getBlob(c||"application/octet-stream");b||(b="Download.bin");Ia?Ia(a,b):Ha(a,b)}:Fa&&Ga&&(Ea=function(a,b,c){var d,e=new Fa;e.append(a);c||(c="application/octet-stream");"download"in document.createElement("a")?(a=e.getBlob(c),d=Ga.createObjectURL(a),a=document.createElement("a"),a.setAttribute("href",d),a.setAttribute("download",b||"Download.bin"),b=document.createEvent("MouseEvents"),b.initMouseEvent("click",k,k,window,1,0,0,0,0,p,p,p,
p,0,n),a.dispatchEvent(b)):({"image/jpeg":k,"image/png":k,"image/gif":k,"image/svg+xml":k,"image/bmp":k,"image/x-windows-bmp":k,"image/webp":k,"audio/wav":k,"audio/mpeg":k,"audio/webm":k,"audio/ogg":k,"video/mpeg":k,"video/webm":k,"video/ogg":k,"text/plain":k,"text/html":k,"text/xml":k,"application/xhtml+xml":k,"application/json":k}[c.split(";")[0]]===k&&(c="application/octet-stream"),a=e.getBlob(c),d=Ga.createObjectURL(a),window.open(d,"_blank",""));setTimeout(function(){Ga.revokeObjectURL(d)},250)});
function Ja(a,b,c,d){var e=a;if(c||d){e=document.createElement("canvas");e.width=a.width;e.height=a.height;var f=e.getContext("2d");f.drawImage(a,0,0);c&&c.forEach(function(a){a.xd(f)});d&&Ka(d,f)}Ea&&e.hd?e.hd(function(a){Ea(a,b,"image/png")},"image/png"):a.toDataURL&&(a=a.toDataURL(),document.location.href=a.replace("image/png","image/octet-stream"))};function La(a,b,c){for(var d in a)b.call(c,a[d],d,a)}function Ma(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function Na(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b}function Oa(){var a=Pa,b;for(b in a)return p;return k}var Qa="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",");
function Ra(a,b){for(var c,d,e=1;e<arguments.length;e++){d=arguments[e];for(c in d)a[c]=d[c];for(var f=0;f<Qa.length;f++)c=Qa[f],Object.prototype.hasOwnProperty.call(d,c)&&(a[c]=d[c])}};function Sa(a){if("function"==typeof a.pa)a=a.pa();else if(z(a)||A(a))a=a.length;else{var b=0,c;for(c in a)b++;a=b}return a}function Ta(a){if("function"==typeof a.Ga)return a.Ga();if(A(a))return a.split("");if(z(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return Ma(a)}function Ua(a){if("function"==typeof a.xb)return a.xb();if("function"!=typeof a.Ga){if(z(a)||A(a)){for(var b=[],a=a.length,c=0;c<a;c++)b.push(c);return b}return Na(a)}}
function Va(a,b){if("function"==typeof a.forEach)a.forEach(b,j);else if(z(a)||A(a))I(a,b,j);else for(var c=Ua(a),d=Ta(a),e=d.length,f=0;f<e;f++)b.call(j,d[f],c&&c[f],a)}function Wa(a,b){if("function"==typeof a.every)return a.every(b,j);if(z(a)||A(a))return wa(a,b,j);for(var c=Ua(a),d=Ta(a),e=d.length,f=0;f<e;f++)if(!b.call(j,d[f],c&&c[f],a))return p;return k};function Xa(a,b){this.A={};this.z=[];var c=arguments.length;if(1<c){c%2&&h(Error("Uneven number of arguments"));for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else a&&this.uc(a)}s=Xa.prototype;s.s=0;s.pa=r("s");s.Ga=function(){Ya(this);for(var a=[],b=0;b<this.z.length;b++)a.push(this.A[this.z[b]]);return a};s.xb=function(){Ya(this);return this.z.concat()};s.rd=function(a){for(var b=0;b<this.z.length;b++){var c=this.z[b];if(Za(this.A,c)&&this.A[c]==a)return k}return p};
s.equals=function(a,b){if(this===a)return k;if(this.s!=a.pa())return p;var c=b||$a;Ya(this);for(var d,e=0;d=this.z[e];e++)if(!c(this.get(d),a.get(d)))return p;return k};function $a(a,b){return a===b}s.clear=function(){this.A={};this.s=this.z.length=0};s.remove=function(a){return Za(this.A,a)?(delete this.A[a],this.s--,this.z.length>2*this.s&&Ya(this),k):p};
function Ya(a){if(a.s!=a.z.length){for(var b=0,c=0;b<a.z.length;){var d=a.z[b];Za(a.A,d)&&(a.z[c++]=d);b++}a.z.length=c}if(a.s!=a.z.length){for(var e={},c=b=0;b<a.z.length;)d=a.z[b],Za(e,d)||(a.z[c++]=d,e[d]=1),b++;a.z.length=c}}s.get=function(a,b){return Za(this.A,a)?this.A[a]:b};s.set=function(a,b){Za(this.A,a)||(this.s++,this.z.push(a));this.A[a]=b};s.uc=function(a){var b;a instanceof Xa?(b=a.xb(),a=a.Ga()):(b=Na(a),a=Ma(a));for(var c=0;c<b.length;c++)this.set(b[c],a[c])};s.gb=function(){return new Xa(this)};
function Za(a,b){return Object.prototype.hasOwnProperty.call(a,b)};function ab(a){this.A=new Xa;a&&this.uc(a)}function bb(a){var b=typeof a;return"object"==b&&a||"function"==b?"o"+C(a):b.substr(0,1)+a}s=ab.prototype;s.pa=function(){return this.A.pa()};s.add=function(a){this.A.set(bb(a),a)};s.uc=function(a){for(var a=Ta(a),b=a.length,c=0;c<b;c++)this.add(a[c])};s.remove=function(a){return this.A.remove(bb(a))};s.clear=function(){this.A.clear()};s.contains=function(a){a=bb(a);return Za(this.A.A,a)};s.Ga=function(){return this.A.Ga()};s.gb=function(){return new ab(this)};
s.equals=function(a){return this.pa()==Sa(a)&&cb(this,a)};function cb(a,b){var c=Sa(b);if(a.pa()>c)return p;!(b instanceof ab)&&5<c&&(b=new ab(b));return Wa(a,function(a){if("function"==typeof b.contains)a=b.contains(a);else if("function"==typeof b.rd)a=b.rd(a);else if(z(b)||A(b))a=0<=ua(b,a);else a:{for(var c in b)if(b[c]==a){a=k;break a}a=p}return a})};var db,eb,fb,gb,hb;function ib(){return u.navigator?u.navigator.userAgent:n}gb=fb=eb=db=p;var jb;if(jb=ib()){var kb=u.navigator;db=0==jb.indexOf("Opera");eb=!db&&-1!=jb.indexOf("MSIE");fb=!db&&-1!=jb.indexOf("WebKit");gb=!db&&!fb&&"Gecko"==kb.product}var lb=db,N=eb,mb=gb,O=fb,nb,ob=u.navigator;nb=ob&&ob.platform||"";hb=-1!=nb.indexOf("Mac");var pb=-1!=nb.indexOf("Win"),qb;
a:{var rb="",sb;if(lb&&u.opera)var tb=u.opera.version,rb="function"==typeof tb?tb():tb;else if(mb?sb=/rv\:([^\);]+)(\)|;)/:N?sb=/MSIE\s+([^\);]+)(\)|;)/:O&&(sb=/WebKit\/(\S+)/),sb)var ub=sb.exec(ib()),rb=ub?ub[1]:"";if(N){var vb,xb=u.document;vb=xb?xb.documentMode:j;if(vb>parseFloat(rb)){qb=""+vb;break a}}qb=rb}var yb={};
function P(a){var b;if(!(b=yb[a])){b=0;for(var c=(""+qb).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=(""+a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=Math.max(c.length,d.length),f=0;0==b&&f<e;f++){var g=c[f]||"",i=d[f]||"",l=RegExp("(\\d*)(\\D*)","g"),m=RegExp("(\\d*)(\\D*)","g");do{var q=l.exec(g)||["","",""],o=m.exec(i)||["","",""];if(0==q[0].length&&0==o[0].length)break;b=((0==q[1].length?0:parseInt(q[1],10))<(0==o[1].length?0:parseInt(o[1],10))?-1:(0==q[1].length?0:parseInt(q[1],
10))>(0==o[1].length?0:parseInt(o[1],10))?1:0)||((0==q[2].length)<(0==o[2].length)?-1:(0==q[2].length)>(0==o[2].length)?1:0)||(q[2]<o[2]?-1:q[2]>o[2]?1:0)}while(0==b)}b=yb[a]=0<=b}return b}var zb={};function Ab(){return zb[9]||(zb[9]=N&&!!document.documentMode&&9<=document.documentMode)};var Bb=!N||Ab();!mb&&!N||N&&Ab()||mb&&P("1.9.1");N&&P("9");function Cb(a,b){var c;c=(c=a.className)&&"function"==typeof c.split?c.split(/\s+/):[];var d=Aa(arguments,1),e;e=c;for(var f=0,g=0;g<d.length;g++)0<=ua(e,d[g])||(e.push(d[g]),f++);e=f==d.length;a.className=c.join(" ");return e};function Db(a,b){this.width=a;this.height=b}function Eb(a,b){return a==b?k:!a||!b?p:a.width==b.width&&a.height==b.height}s=Db.prototype;s.gb=function(){return new Db(this.width,this.height)};s.fb=function(){return this.width/this.height};s.ceil=function(){this.width=Math.ceil(this.width);this.height=Math.ceil(this.height);return this};s.floor=function(){this.width=Math.floor(this.width);this.height=Math.floor(this.height);return this};
s.round=function(){this.width=Math.round(this.width);this.height=Math.round(this.height);return this};s.scale=function(a){this.width*=a;this.height*=a;return this};function Fb(){var a=document;return a.querySelectorAll&&a.querySelector&&(!O||"CSS1Compat"==document.compatMode||P("528"))?a.querySelectorAll("HEAD"):a.getElementsByTagName("HEAD")}function Gb(a,b){La(b,function(b,d){"style"==d?a.style.cssText=b:"class"==d?a.className=b:"for"==d?a.htmlFor=b:d in Hb?a.setAttribute(Hb[d],b):0==d.lastIndexOf("aria-",0)?a.setAttribute(d,b):a[d]=b})}
var Hb={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",height:"height",width:"width",usemap:"useMap",frameborder:"frameBorder",maxlength:"maxLength",type:"type"};
function Q(a,b,c){var d=arguments,e=document,f=d[0],g=d[1];if(!Bb&&g&&(g.name||g.type)){f=["<",f];g.name&&f.push(' name="',na(g.name),'"');if(g.type){f.push(' type="',na(g.type),'"');var i={};Ra(i,g);g=i;delete g.type}f.push(">");f=f.join("")}f=e.createElement(f);g&&(A(g)?f.className=g:ea(g)?Cb.apply(n,[f].concat(g)):Gb(f,g));2<d.length&&Ib(e,f,d,2);return f}
function Ib(a,b,c,d){function e(c){c&&b.appendChild(A(c)?a.createTextNode(c):c)}for(;d<c.length;d++){var f=c[d];z(f)&&!(ia(f)&&0<f.nodeType)?I(Jb(f)?za(f):f,e):e(f)}}function R(a,b){Ib(Kb(a),a,arguments,1)}function Kb(a){return 9==a.nodeType?a:a.ownerDocument||a.document}function Jb(a){if(a&&"number"==typeof a.length){if(ia(a))return"function"==typeof a.item||"string"==typeof a.item;if(ga(a))return"function"==typeof a.item}return p};var Lb=!N||Ab(),Mb=!N||Ab(),Nb=N&&!P("8");!O||P("528");mb&&P("1.9b")||N&&P("8")||lb&&P("9.5")||O&&P("528");!mb||P("8");function Ob(){}Ob.prototype.wd=p;Ob.prototype.F=function(){this.wd||(this.wd=k,this.G())};Ob.prototype.G=function(){this.te&&Pb.apply(n,this.te)};function Pb(a){for(var b=0,c=arguments.length;b<c;++b){var d=arguments[b];z(d)?Pb.apply(n,d):d&&"function"==typeof d.F&&d.F()}};function S(a,b){this.type=a;this.currentTarget=this.target=b}G(S,Ob);S.prototype.G=function(){delete this.type;delete this.target;delete this.currentTarget};S.prototype.ob=p;S.prototype.Jb=k;S.prototype.preventDefault=function(){this.Jb=p};function Qb(a){Qb[" "](a);return a}Qb[" "]=ca;function Rb(a,b){a&&this.yb(a,b)}G(Rb,S);var Sb=[1,4,2];s=Rb.prototype;s.target=n;s.relatedTarget=n;s.offsetX=0;s.offsetY=0;s.clientX=0;s.clientY=0;s.screenX=0;s.screenY=0;s.button=0;s.keyCode=0;s.charCode=0;s.ctrlKey=p;s.altKey=p;s.shiftKey=p;s.metaKey=p;s.kb=n;
s.yb=function(a,b){var c=this.type=a.type;S.call(this,c);this.target=a.target||a.srcElement;this.currentTarget=b;var d=a.relatedTarget;if(d){if(mb){var e;a:{try{Qb(d.nodeName);e=k;break a}catch(f){}e=p}e||(d=n)}}else"mouseover"==c?d=a.fromElement:"mouseout"==c&&(d=a.toElement);this.relatedTarget=d;this.offsetX=O||a.offsetX!==j?a.offsetX:a.layerX;this.offsetY=O||a.offsetY!==j?a.offsetY:a.layerY;this.clientX=a.clientX!==j?a.clientX:a.pageX;this.clientY=a.clientY!==j?a.clientY:a.pageY;this.screenX=a.screenX||
0;this.screenY=a.screenY||0;this.button=a.button;this.keyCode=a.keyCode||0;this.charCode=a.charCode||("keypress"==c?a.keyCode:0);this.ctrlKey=a.ctrlKey;this.altKey=a.altKey;this.shiftKey=a.shiftKey;this.metaKey=a.metaKey;this.state=a.state;this.kb=a;delete this.Jb;delete this.ob};function Tb(a,b){return Lb?a.kb.button==b:"click"==a.type?0==b:!!(a.kb.button&Sb[b])}
s.preventDefault=function(){Rb.va.preventDefault.call(this);var a=this.kb;if(a.preventDefault)a.preventDefault();else if(a.returnValue=p,Nb)try{if(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)a.keyCode=-1}catch(b){}};s.G=function(){Rb.va.G.call(this);this.relatedTarget=this.currentTarget=this.target=this.kb=n};function Ub(){}var Vb=0;s=Ub.prototype;s.key=0;s.qb=p;s.wc=p;s.yb=function(a,b,c,d,e,f){ga(a)?this.Dd=k:a&&a.handleEvent&&ga(a.handleEvent)?this.Dd=p:h(Error("Invalid listener argument"));this.Bb=a;this.Vd=b;this.src=c;this.type=d;this.capture=!!e;this.Ic=f;this.wc=p;this.key=++Vb;this.qb=p};s.handleEvent=function(a){return this.Dd?this.Bb.call(this.Ic||this.src,a):this.Bb.handleEvent.call(this.Bb,a)};var Wb={},T={},Xb={},Yb={};
function U(a,b,c,d,e){if(b){if(ea(b)){for(var f=0;f<b.length;f++)U(a,b[f],c,d,e);return n}var d=!!d,g=T;b in g||(g[b]={s:0,Z:0});g=g[b];d in g||(g[d]={s:0,Z:0},g.s++);var g=g[d],i=C(a),l;g.Z++;if(g[i]){l=g[i];for(f=0;f<l.length;f++)if(g=l[f],g.Bb==c&&g.Ic==e){if(g.qb)break;return l[f].key}}else l=g[i]=[],g.s++;f=Zb();f.src=a;g=new Ub;g.yb(c,f,a,b,d,e);c=g.key;f.key=c;l.push(g);Wb[c]=g;Xb[i]||(Xb[i]=[]);Xb[i].push(g);a.addEventListener?(a==u||!a.td)&&a.addEventListener(b,f,d):a.attachEvent(b in Yb?
Yb[b]:Yb[b]="on"+b,f);return c}h(Error("Invalid event type"))}function Zb(){var a=$b,b=Mb?function(c){return a.call(b.src,b.key,c)}:function(c){c=a.call(b.src,b.key,c);if(!c)return c};return b}function ac(a,b,c,d,e){if(ea(b))for(var f=0;f<b.length;f++)ac(a,b[f],c,d,e);else a=U(a,b,c,d,e),Wb[a].wc=k}
function bc(a,b,c,d,e){if(ea(b))for(var f=0;f<b.length;f++)bc(a,b[f],c,d,e);else{d=!!d;a:{f=T;if(b in f&&(f=f[b],d in f&&(f=f[d],a=C(a),f[a]))){a=f[a];break a}a=n}if(a)for(f=0;f<a.length;f++)if(a[f].Bb==c&&a[f].capture==d&&a[f].Ic==e){V(a[f].key);break}}}
function V(a){if(Wb[a]){var b=Wb[a];if(!b.qb){var c=b.src,d=b.type,e=b.Vd,f=b.capture;c.removeEventListener?(c==u||!c.td)&&c.removeEventListener(d,e,f):c.detachEvent&&c.detachEvent(d in Yb?Yb[d]:Yb[d]="on"+d,e);c=C(c);e=T[d][f][c];if(Xb[c]){var g=Xb[c];xa(g,b);0==g.length&&delete Xb[c]}b.qb=k;e.Pd=k;cc(d,f,c,e);delete Wb[a]}}}
function cc(a,b,c,d){if(!d.Zb&&d.Pd){for(var e=0,f=0;e<d.length;e++)d[e].qb?d[e].Vd.src=n:(e!=f&&(d[f]=d[e]),f++);d.length=f;d.Pd=p;0==f&&(delete T[a][b][c],T[a][b].s--,0==T[a][b].s&&(delete T[a][b],T[a].s--),0==T[a].s&&delete T[a])}}
function dc(a,b){var c,d=0,e=b==n,f=c==n;c=!!c;if(a==n)La(Xb,function(a){for(var g=a.length-1;0<=g;g--){var i=a[g];if((e||b==i.type)&&(f||c==i.capture))V(i.key),d++}});else{var g=C(a);if(Xb[g])for(var g=Xb[g],i=g.length-1;0<=i;i--){var l=g[i];if((e||b==l.type)&&(f||c==l.capture))V(l.key),d++}}}function ec(a,b,c,d,e){var f=1,b=C(b);if(a[b]){a.Z--;a=a[b];a.Zb?a.Zb++:a.Zb=1;try{for(var g=a.length,i=0;i<g;i++){var l=a[i];l&&!l.qb&&(f&=fc(l,e)!==p)}}finally{a.Zb--,cc(c,d,b,a)}}return Boolean(f)}
function fc(a,b){var c=a.handleEvent(b);a.wc&&V(a.key);return c}
function $b(a,b){if(!Wb[a])return k;var c=Wb[a],d=c.type,e=T;if(!(d in e))return k;var e=e[d],f,g;if(!Mb){var i;if(!(i=b))a:{i=["window","event"];for(var l=u;f=i.shift();)if(y(l[f]))l=l[f];else{i=n;break a}i=l}f=i;i=k in e;l=p in e;if(i){if(0>f.keyCode||f.returnValue!=j)return k;a:{var m=p;if(0==f.keyCode)try{f.keyCode=-1;break a}catch(q){m=k}if(m||f.returnValue==j)f.returnValue=k}}m=new Rb;m.yb(f,this);f=k;try{if(i){for(var o=[],v=m.currentTarget;v;v=v.parentNode)o.push(v);g=e[k];g.Z=g.s;for(var t=
o.length-1;!m.ob&&0<=t&&g.Z;t--)m.currentTarget=o[t],f&=ec(g,o[t],d,k,m);if(l){g=e[p];g.Z=g.s;for(t=0;!m.ob&&t<o.length&&g.Z;t++)m.currentTarget=o[t],f&=ec(g,o[t],d,p,m)}}else f=fc(c,m)}finally{o&&(o.length=0),m.F()}return f}d=new Rb(b,this);try{f=fc(c,d)}finally{d.F()}return f};function gc(a,b,c){this.x=w(a)?a:0;this.y=w(b)?b:0;this.k=w(c)?c:0}gc.prototype.gb=function(){return new gc(this.x,this.y,this.k)};gc.prototype.Ma=function(){return[this.x,this.y,this.k]};function hc(a,b,c){this.x=a;this.y=b;this.k=c}G(hc,gc);s=hc.prototype;s.gb=function(){return new hc(this.x,this.y,this.k)};s.scale=function(a){this.x*=a;this.y*=a;this.k*=a;return this};s.normalize=function(){return this.scale(1/Math.sqrt(this.x*this.x+this.y*this.y+this.k*this.k))};s.add=function(a){this.x+=a.x;this.y+=a.y;this.k+=a.k;return this};s.fd=function(a){this.x-=a.x;this.y-=a.y;this.k-=a.k;return this};s.equals=function(a){return this==a||!!a&&this.x==a.x&&this.y==a.y&&this.k==a.k};
function ic(a,b){var c=a.x-b.x,d=a.y-b.y,e=a.k-b.k;return Math.sqrt(c*c+d*d+e*e)};function W(a,b){if(a instanceof W)this.j=a.Ma();else{var c;if(c=z(a))a:{for(var d=c=0;d<a.length;d++){if(!z(a[d])||0<c&&a[d].length!=c){c=p;break a}for(var e=0;e<a[d].length;e++)if(!fa(a[d][e])){c=p;break a}0==c&&(c=a[d].length)}c=0!=c}c?this.j=za(a):a instanceof Db?this.j=jc(a.height,a.width):fa(a)&&fa(b)&&0<a&&0<b?this.j=jc(a,b):h(Error("Invalid argument(s) for Matrix contructor"))}this.e=new Db(this.j[0].length,this.j.length)}
function kc(a){for(var b=[],c=0;c<a;c++){b[c]=[];for(var d=0;d<a;d++)b[c][d]=c==d?1:0}return new W(b)}function lc(a,b,c){for(var d=0;d<a.e.height;d++)for(var e=0;e<a.e.width;e++)b.call(c,a.j[d][e],d,e,a)}function mc(a,b){var c=new W(a.e);lc(a,function(d,e,f){c.j[e][f]=b.call(j,d,e,f,a)});return c}function jc(a,b){for(var c=[],d=0;d<a;d++){c[d]=[];for(var e=0;e<b;e++)c[d][e]=0}return c}s=W.prototype;
s.add=function(a){Eb(this.e,a.e)||h(Error("Matrix summation is only supported on arrays of equal size"));return mc(this,function(b,c,d){return b+a.j[c][d]})};function nc(a,b){a.e.height!=b.e.height&&h(Error("The given matrix has height "+b.e.height+", but needs to have height "+a.e.height+"."));var c=new W(a.e.height,a.e.width+b.e.width);lc(a,function(a,b,f){c.j[b][f]=a});lc(b,function(a,b,f){c.j[b][this.e.width+f]=a},a);return c}
s.equals=function(a,b){if(this.e.width!=a.e.width||this.e.height!=a.e.height)return p;for(var c=b||0,d=0;d<this.e.height;d++)for(var e=0;e<this.e.width;e++)if(!(Math.abs(this.j[d][e]-a.j[d][e])<=(c||1.0E-6)))return p;return k};function oc(a){var b=new W(a.e.width,a.e.height);lc(a,function(a,d,e){b.j[e][d]=a});return b}function X(a,b,c){return!(0<=b&&b<a.e.height&&0<=c&&c<a.e.width)?n:a.j[b][c]}
function pc(a,b,c,d){0<=b&&b<a.e.height&&0<=c&&c<a.e.width||h(Error("Index out of bounds when setting matrix value, ("+b+","+c+") in size ("+a.e.height+","+a.e.width+")"));a.j[b][c]=d}s.multiply=function(a){if(a instanceof W)return this.e.width!=a.e.height&&h(Error("Invalid matrices for multiplication. Second matrix should have the same number of rows as the first has columns.")),qc(this,a);if(fa(a))return rc(this,a);h(Error("A matrix can only be multiplied by a number or another matrix."))};
s.fd=function(a){Eb(this.e,a.e)||h(Error("Matrix subtraction is only supported on arrays of equal size."));return mc(this,function(b,c,d){return b-a.j[c][d]})};s.Ma=r("j");function sc(a,b,c,d){var e=new W((c?c:a.e.height-1)-0+1,(d?d:a.e.width-1)-b+1);lc(e,function(a,c,d){e.j[c][d]=this.j[0+c][b+d]},a);return e}function qc(a,b){var c=new W(a.e.height,b.e.width);lc(c,function(a,e,f){for(var g=a=0;g<this.e.width;g++)a+=X(this,e,g)*X(b,g,f);pc(c,e,f,a)},a);return c}
function rc(a,b){return mc(a,function(a){return a*b})};function tc(a,b,c,d,e,f){if(x(d))return n;a=d.multiply(new W([[2*(a/e)-1],[1-2*b/f],[2*c-1],[1]]));if(0==X(a,3,0))return n;a=a.multiply(1/X(a,3,0));return new hc(X(a,0,0),X(a,1,0),X(a,2,0))};function uc(){}G(uc,Ob);s=uc.prototype;s.td=k;s.$c=n;s.addEventListener=function(a,b,c,d){U(this,a,b,c,d)};s.removeEventListener=function(a,b,c,d){bc(this,a,b,c,d)};
s.dispatchEvent=function(a){var b=a.type||a,c=T;if(b in c){if(A(a))a=new S(a,this);else if(a instanceof S)a.target=a.target||this;else{var d=a,a=new S(b,this);Ra(a,d)}var d=1,e,c=c[b],b=k in c,f;if(b){e=[];for(f=this;f;f=f.$c)e.push(f);f=c[k];f.Z=f.s;for(var g=e.length-1;!a.ob&&0<=g&&f.Z;g--)a.currentTarget=e[g],d&=ec(f,e[g],a.type,k,a)&&a.Jb!=p}if(p in c)if(f=c[p],f.Z=f.s,b)for(g=0;!a.ob&&g<e.length&&f.Z;g++)a.currentTarget=e[g],d&=ec(f,e[g],a.type,p,a)&&a.Jb!=p;else for(e=this;!a.ob&&e&&f.Z;e=e.$c)a.currentTarget=
e,d&=ec(f,e,a.type,p,a)&&a.Jb!=p;a=Boolean(d)}else a=k;return a};s.G=function(){uc.va.G.call(this);dc(this);this.$c=n};function vc(a){var b=w(j),c=new XMLHttpRequest;b&&(c.onreadystatechange=function(){4==c.readyState&&j(c.responseText)});c.open("GET",a,b);c.send(n);return b?"":c.responseText}function wc(a){a=K(a,2*Math.PI);return a>Math.PI?a-2*Math.PI:a}function xc(a){var b=document.createElement("style");b.type="text/css";b.styleSheet?b.styleSheet.cssText=a:b.appendChild(document.createTextNode(a));Fb()[0].appendChild(b)};function yc(a){this.f=a;this.ea=this.V=0;this.I=1E7;this.ic=this.xa=this.Ra=0}G(yc,uc);s=yc.prototype;s.setPosition=function(a,b){this.V=J(a,-1.57,1.57);this.ea=wc(b);this.dispatchEvent(new zc(Ac))};function Bc(a,b,c){function d(a){var d=c;c=d*Math.cos(a)-2*b*Math.sin(a);b=d*Math.sin(a)/2+b*Math.cos(a)}d(a.ic);b/=Math.max(Math.abs(Math.cos(a.xa)),0.1);d(a.Ra);a.setPosition(a.V+b,a.ea+c)}s.getPosition=function(){return[this.V,this.ea]};
function Cc(a,b){a.I=J(b,250,1E7);a.dispatchEvent(new zc(Dc))}function Ec(a){return Fc(a.f,a.f.a.ia/2,a.f.a.ha/2,k)}s.setHeading=aa("Ra");s.setTilt=aa("xa");s.getHeading=r("Ra");s.getTilt=r("xa");var Ac="poschanged",Dc="altchanged";function zc(a){S.call(this,a)}G(zc,S);function Gc(a,b,c,d,e){function f(a,b,c,d){a?a=b:(a=b/Math.max(1,Math.sqrt(c*c+d*d)),a=Math.max(1,Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))));return a}a=a.d;this.p=[];this.hb=[];this.i=[];for(var g=-b/2;g<b/2;++g)for(var i=-c/2;i<c/2;++i){var l=f(e,d,g,i),m=[i+1<c/2&&f(e,d,g,i+1)>l,g+1<b/2&&f(e,d,g+1,i)>l,i-1>-c/2&&f(e,d,g,i-1)>l,g-1>-b/2&&f(e,d,g-1,i)>l];Hc(this,g,i,l,m)}this.rc=a.createBuffer();this.oc=a.createBuffer();this.Bd=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,this.rc);a.bufferData(a.ARRAY_BUFFER,
new Float32Array(this.p),a.STATIC_DRAW);this.rc.Ia=2;a.bindBuffer(a.ARRAY_BUFFER,this.oc);a.bufferData(a.ARRAY_BUFFER,new Float32Array(this.hb),a.STATIC_DRAW);this.oc.Ia=2;a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.Bd);a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.i),a.STATIC_DRAW);this.Ze=this.i.length}
function Hc(a,b,c,d,e){for(var f=a.p.length/2,g=0;g<=d;++g)for(var i=0;i<=d;++i)a.p.push(b+i/d,c+g/d),a.hb.push(i/d,1-g/d);var l=[0,0,0,0];if(e[0]){l[0]=a.p.length/2;for(i=0;i<d;++i)a.p.push(b+(i+0.5)/d,c+1),a.hb.push((i+0.5)/d,0)}if(e[1]){l[1]=a.p.length/2;for(g=0;g<d;++g)a.p.push(b+1,c+(g+0.5)/d),a.hb.push(1,1-(g+0.5)/d)}if(e[2]){l[2]=a.p.length/2;for(i=0;i<d;++i)a.p.push(b+(i+0.5)/d,c),a.hb.push((i+0.5)/d,1)}if(e[3]){l[3]=a.p.length/2;for(g=0;g<d;++g)a.p.push(b,c+(g+0.5)/d),a.hb.push(0,1-(g+0.5)/
d)}b=D(function(){},a);c=d+1;for(g=0;g<d;++g)for(i=0;i<d;++i){var m=f+g*c+i;a.i.push(m);var q=0==g&&e[2],o=0==i&&e[3];q&&!o?(a.i.push(l[2]+i),a.i.push(m+c),b(),a.i.push(l[2]+i)):o&&!q?(a.i.push(m+1),a.i.push(l[3]+g),b(),a.i.push(l[3]+g)):o&&q&&(a.i.push(l[2]+i),a.i.push(l[3]+g),b(),a.i.push(l[3]+g),a.i.push(l[2]+i),a.i.push(m+c),b(),a.i.push(l[2]+i));a.i.push(m+1);a.i.push(m+c);b();a.i.push(m+c+1);q=g==d-1&&e[0];o=i==d-1&&e[1];q&&!o?(a.i.push(l[0]+i),a.i.push(m+1),b(),a.i.push(l[0]+i)):o&&!q?(a.i.push(m+
c),a.i.push(l[1]+g),b(),a.i.push(l[1]+g)):q&&o&&(a.i.push(l[0]+i),a.i.push(l[1]+g),b(),a.i.push(l[1]+g),a.i.push(l[0]+i),a.i.push(m+1),b(),a.i.push(l[0]+i));a.i.push(m+c);a.i.push(m+1);b()}};function Ic(){this.K=kc(4)}Ic.prototype.translate=function(a,b,c){this.K=this.K.multiply(new W([[1,0,0,a],[0,1,0,b],[0,0,1,c],[0,0,0,1]]))};Ic.prototype.scale=function(a,b,c){this.K=this.K.multiply(new W([[a,0,0,0],[0,b,0,0],[0,0,c,0],[0,0,0,1]]))};function Jc(a,b){var c=Math.cos(b),d=Math.sin(b);a.K=a.K.multiply(new W([[c,0,d,0],[0,1,0,0],[-d,0,c,0],[0,0,0,1]]))}function Kc(a,b){var c=Math.cos(b),d=Math.sin(b);a.K=a.K.multiply(new W([[1,0,0,0],[0,c,-d,0],[0,d,c,0],[0,0,0,1]]))}
function Lc(a,b){var c=Math.cos(b),d=Math.sin(b);a.K=a.K.multiply(new W([[c,-d,0,0],[d,c,0,0],[0,0,1,0],[0,0,0,1]]))};function Mc(a,b,c){for(var d=n,e=["webgl","experimental-webgl"],f=0;x(d)&&f<e.length;++f)if(!d)a:{try{var g=a.getContext(e[f],{premultipliedAlpha:p});if(y(g)){d=g;break a}}catch(i){}d=n}x(d)&&(w(c)?c():h(Error("unable to get a valid WebGL context")));d.enable(d.CULL_FACE);d.cullFace(d.BACK);d.clearColor(0,0,0,0);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);this.canvas=a;this.Fc=b||n;this.d=d;this.ia=a.width;this.ha=a.height;d.viewport(0,
0,this.ia,this.ha);this.Ob=this.Da=0;this.Nb=1;this.fb=this.ia/this.ha;this.Ka=kc(4);this.O=new Ic;this.Fb=this.Eb=this.Ka;this.Vb=this.Wb=this.Lc=this.pd=this.Ec=0;U(window,"resize",this.Ib,p,this);this.Qb=n}function Nc(a){a.Da=L(50);a.Ob=1.0E-6;a.Nb=5;a.fb=a.ia/a.ha;Oc(a)}function Oc(a){var b=1/Math.tan(a.Da/2);a.Ka=new W([[b/a.fb,0,0,0],[0,b,0,0],[0,0,0,0],[0,0,-1,0]]);Pc(a)}function Qc(a,b,c){a.Ob=b;a.Nb=c;Pc(a)}
function Pc(a){var b=a.Ob-a.Nb;pc(a.Ka,2,2,(a.Nb+a.Ob)/b);pc(a.Ka,2,3,2*a.Nb*a.Ob/b)}Mc.prototype.Ib=function(){this.ia=this.canvas.width=this.canvas.clientWidth;this.ha=this.canvas.height=this.canvas.clientHeight;this.d.viewport(0,0,this.ia,this.ha);this.fb=this.ia/this.ha;Oc(this);Rc(this.c)};Mc.prototype.c=n;
function Sc(a){a.Eb=a.Ka.multiply(a.O.K);var b,c=a.Eb;c.e.width!=c.e.height&&h(Error("An inverse can only be taken on a square matrix."));b=kc(c.e.height);a:{for(var c=nc(c,b),d=new W(c),e=0,f=0;f<d.e.height&&!(e>=d.e.width);f++){for(var g=f;0==d.j[g][e];)if(g++,g==d.e.height&&(g=f,e++,e==d.e.width)){c=d;break a}var i=c,l=f,m=i.j[g];i.j[g]=i.j[l];i.j[l]=m;g=d.j[f][e];for(i=e;i<d.e.width;i++)d.j[f][i]/=g;for(g=0;g<d.e.height;g++)if(g!=f){l=d.j[g][e];for(i=e;i<d.e.width;i++)d.j[g][i]-=l*d.j[f][i]}e++}c=
d}b=!sc(c,0,b.e.width-1,b.e.height-1).equals(b)?n:sc(c,b.e.width);a.Fb=b;return a.Eb}Mc.prototype.Td=ca;Mc.prototype.Hb="";function Tc(a,b,c){a=a.d||a;c=a.createShader(c);a.shaderSource(c,b);a.compileShader(c);a.getShaderParameter(c,a.COMPILE_STATUS)?x(c)&&h(Error("Unknown")):h(Error("Shader err: "+a.getShaderInfoLog(c)));return c};function Uc(a,b,c){a=this.qa=a.d;this.tb=b;this.ka=c;this.$=a.createTexture();Vc(this)}Uc.prototype.Ib=function(a,b){this.tb==a&&this.ka==b||(this.tb=a,this.ka=b,this.qa.deleteTexture(this.$),this.$=this.qa.createTexture(),Vc(this))};
function Vc(a){var b=a.qa;b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,a.$);b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,1);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,a.tb,a.ka,0,b.RGBA,b.UNSIGNED_BYTE,n);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);b.generateMipmap(b.TEXTURE_2D)}Uc.prototype.clear=function(){this.qa.deleteTexture(this.$);this.$=this.qa.createTexture();Vc(this)};function Wc(a){return function(){return a}}var Xc=Wc(k),Yc=Wc(n);function Zc(a){var b=arguments,c=b.length;return function(){for(var a,e=0;e<c;e++)a=b[e].apply(this,arguments);return a}};function $c(a,b,c,d){this.zoom=a||0;this.x=b||0;this.y=c||0;this.Cc=0;this.La=d||0;this.ib=this.n=n;this.state=ad}G($c,Ob);s=$c.prototype;s.getKey=function(){return this.zoom+"_"+this.x+"_"+this.y};s.setData=aa("ib");s.ud=Yc;s.cd=aa("n");function bd(a){return a.ib?a.ud(a.ib):a.n}s.sd=ca;s.G=function(){this.n=n;this.ib&&(this.sd(this.ib),this.ib=n)};var ad=0;function cd(a,b){this.Yb=a||1;this.Mb=b||dd;this.vc=D(this.qf,this);this.Nc=E()}G(cd,uc);cd.prototype.enabled=p;var dd=u.window;s=cd.prototype;s.ab=n;s.qf=function(){if(this.enabled){var a=E()-this.Nc;0<a&&a<0.8*this.Yb?this.ab=this.Mb.setTimeout(this.vc,this.Yb-a):(this.dispatchEvent(ed),this.enabled&&(this.ab=this.Mb.setTimeout(this.vc,this.Yb),this.Nc=E()))}};s.start=function(){this.enabled=k;this.ab||(this.ab=this.Mb.setTimeout(this.vc,this.Yb),this.Nc=E())};
s.stop=function(){this.enabled=p;this.ab&&(this.Mb.clearTimeout(this.ab),this.ab=n)};s.G=function(){cd.va.G.call(this);this.stop();delete this.Mb};var ed="tick";function fd(a){ga(a)||(a&&"function"==typeof a.handleEvent?a=D(a.handleEvent,a):h(Error("Invalid listener argument")));return dd.setTimeout(a,20)};function gd(a,b,c,d){this.top=a;this.right=b;this.bottom=c;this.left=d}gd.prototype.gb=function(){return new gd(this.top,this.right,this.bottom,this.left)};gd.prototype.contains=function(a){return!this||!a?p:a instanceof gd?a.left>=this.left&&a.right<=this.right&&a.top>=this.top&&a.bottom<=this.bottom:a.x>=this.left&&a.x<=this.right&&a.y>=this.top&&a.y<=this.bottom};function hd(a){this.name=a;this.da=0;this.zc=[];this.Md=-1.4844222297453324;this.Jd=1.4844222297453324;this.Nd=-Math.PI;this.Kd=Math.PI;this.Rb=[];this.opacity=1}s=hd.prototype;s.bd=function(a,b,c,d){this.Md=L(a);this.Jd=L(b);this.Nd=L(c);this.Kd=L(d);this.Rb=[]};
function id(a,b){if(!y(a.Rb[b])){var c=1<<b,d=Math.floor((a.Nd/(2*Math.PI)+0.5)*c),e=Math.floor((a.Kd/(2*Math.PI)+0.5)*c),f=Math.floor((0.5-jd(a.Jd)/(2*Math.PI))*c),c=Math.floor((0.5-jd(a.Md)/(2*Math.PI))*c);a.Rb[b]=new gd(f,e,c,d)}return a.Rb[b]}s.Qa=ba(0);s.xc=ba(p);s.dd=ba(p);s.Kc=ba(k);function kd(a){I(a.zc,function(a){this.da--;this.Cb(a.rf,a.onload,a.ef)},a);a.zc=[]}function ld(a,b,c,d){a.Kc()?a.Cb(b,c,d):(a.zc.push(new md(b,c,d)),a.da++)}s.Na=function(){};s.Xb=ba(n);s.Wd=ca;s.yc=ca;
function nd(a,b,c,d,e){this.oe=a;this.pe=b;this.nf=c;this.of=d;this.yf=e}function md(a,b,c){this.rf=a;this.onload=b;this.ef=c};function od(a){this.wa=new Xa;this.Ta=[];this.pf=512;this.qd=new cd(2E4);U(this.qd,ed,this.qe,p,this);this.qd.start();pd(this,a)}function pd(a,b){a.ae=E();a.T=b;Va(a.wa,function(a){a.F()});a.wa.clear();a.Ta=[]}s=od.prototype;s.T=n;s.ae=0;s.sf=ca;s.qe=function(){var a=va(this.wa.Ga(),function(a){return 20==a.state||a.state==ad||-10==a.state});for(Ba(a,function(a,b){return a.La-b.La});this.wa.pa()>this.pf&&0<a.length;){var b=a.shift();b.state==ad&&xa(this.Ta,b);this.wa.remove(b.getKey());b.F()}};
s.uf=function(a){a.La<this.ae?(a.state=-10,this.wa.remove(a.getKey()),a.F()):this.sf(a)};function qd(a){Ba(a.Ta,function(a,b){return a.La-b.La});for(var b=Math.min(a.Ta.length,5-a.T.da),c=0;c<b;c++)ld(a.T,a.Ta.pop(),D(a.uf,a))};function rd(a,b,c,d){this.U=b;this.za=[];this.h=c;this.T=a;this.gd=new od(a);this.N=d;this.S=1<<this.N;this.jb=this.h>=this.S;this.ta=this.Va=0;this.buffer=n;this.M=[];sd(this)}function sd(a){a.M=[];for(var b=0;b<a.h;++b)a.M.push(Array(a.h));a.buffer&&a.buffer.clear()}rd.prototype.disable=function(){this.za=[];sd(this);this.buffer=n};rd.prototype.oa=function(a){this.T=a;pd(this.gd,a);this.za=[];sd(this)};
function td(a){a.za=[];for(var b=D(function(a,b){var c=(this.jb?this.S:this.h)/2,a=a+c,b=b+c;1!==this.M[b][a]&&ud(this,this.Va+a,this.ta+b,d)},a),c=D(function(a,c){for(var d=-c;d<c;++d)b(d,-c),b(d,c-1);for(d=-c;d<c;++d)b(-c,d),b(c-1,d)},a),d=E(),a=Math.min(a.h,a.S)/2;0<a;--a)c(d+a,a)}
function ud(a,b,c,d){var b=K(b,a.S),c=K(c,a.S),e;a:{e=a.gd;var f=a.N,g=b,i=c,c=f+"_"+g+"_"+i,b=e.wa.get(c);if(y(b))-10==b.state?7E3<d-b.La&&(b.F(),b=new $c(f,g,i,d),e.wa.set(c,b),e.Ta.push(b)):b.La=d;else{d=b=new $c(f,g,i,d);f=id(e.T,d.zoom);if(!(d.x>=f.left&&d.x<=f.right&&d.y>=f.top&&d.y<=f.bottom)){e=n;break a}e.wa.set(c,b);e.Ta.push(b)}e=b}!x(e)&&20==e.state&&a.za.push(e)};function vd(a,b,c){function d(b){f.isTexture(g)&&(3<=b.Cc||ld(a,b,e,d))}function e(c){if(f.isTexture(g)){f.activeTexture(f.TEXTURE0);f.bindTexture(f.TEXTURE_2D,g);try{f.texSubImage2D(f.TEXTURE_2D,0,c.x*l,(i-c.y-1)*l,f.RGBA,f.UNSIGNED_BYTE,bd(c))}catch(m){a.xc()&&(a.dd(b.Hb)||!(c.n&&0==c.n.src.lastIndexOf(b.Hb,0)))?ld(a,c,e,d):b.Td()}}}var f=this.qa=b.d,g=f.createTexture();this.$=g;var i=1<<c,l=a.Fa();f.activeTexture(f.TEXTURE0);f.bindTexture(f.TEXTURE_2D,g);f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,1);
f.texImage2D(f.TEXTURE_2D,0,f.RGBA,l*i,l*i,0,f.RGBA,f.UNSIGNED_BYTE,n);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.LINEAR);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.LINEAR);for(var m=0;m<i;++m)for(var q=0;q<i;++q)ld(a,new $c(c,m,q),e,d)}G(vd,Ob);vd.prototype.G=function(){this.qa.deleteTexture(this.$)};function wd(a,b,c,d,e,f,g){this.U=b;this.h=c;this.X=e;this.ac=f;this.T=a;var i=a.Fa();this.na=[];for(var l=0;l<d;++l)this.na.push(new Uc(b,this.h*i,this.h*i));for(this.C=[];e<=f;++e)this.C.push(new rd(a,b,c,e));for(l=0;l<d;++l)this.C[l].buffer=this.na[l];this.ba=0;this.Ab=g?n:new vd(a,b,2)}wd.prototype.oa=function(a){x(this.Ab)||(this.Ab.F(),this.Ab=new vd(a,this.U,2));this.T=a;var b=this.h*a.Fa();I(this.na,function(a){a.Ib(b,b)});I(this.C,function(b){b.oa(a)});xd(this)};
function yd(a,b,c,d,e,f){for(var f=J(f,a.X,a.ac),g=f-(a.X+a.ba+a.na.length-1);0<g;){var i=a.C[a.ba].buffer;a.C[a.ba].disable();a.C[++a.ba+a.na.length-1].buffer=i;g--}for(;0>g&&0<a.ba;)i=a.C[a.ba+a.na.length-1].buffer,a.C[a.ba+a.na.length-1].disable(),a.C[--a.ba].buffer=i,g++;for(var g=1<<f,l=p,c=(c/(2*Math.PI)+0.5)*g,b=(0.5-jd(b)/(2*Math.PI))*g,e=(e/(2*Math.PI)+0.5)*g,i=(0.5-jd(d)/(2*Math.PI))*g,d=f-a.X;d>=a.ba;d--){var m=J(c-a.h/2,e-a.h,e),q=J(b-a.h/2,i-a.h,i),o=id(a.T,a.X+d),m=J(m,o.left,o.right+
1-a.h),q=J(q,o.top,o.bottom+1-a.h),m=K(Math.round(m),g),q=Math.round(q),o=a.C[d],v=q,q=p;if(!o.jb){var t=m-o.Va,B=v-o.ta;Math.abs(t)>o.S/2&&(t=(t-(0==t?0:0>t?-1:1)*o.S)%o.S);o.Va=m;o.ta=v;if(Math.abs(t)>=o.h||Math.abs(B)>=o.h)sd(o),q=k;else{q=0!=t||0!=B;if(0<t)for(m=0;m<o.h;++m)o.M[m].splice(0,t),o.M[m].push.apply(o.M[m],Array(t));if(0>t)for(m=0;m<o.h;++m)o.M[m].splice(o.h+t,-t),o.M[m].unshift.apply(o.M[m],Array(-t));if(0<B)for(m=0;m<B;++m)o.M.shift(),o.M.push(Array(o.h));if(0>B)for(m=0;m<-B;++m)o.M.pop(),
o.M.unshift(Array(o.h))}}td(o);l|=q;c/=2;b/=2;e/=2;i/=2}l&&xd(a);e=1;for(d=a.ba;0<e&&d<=f-a.X;d++){g=e;c=a.C[d];b=0;if(0<c.za.length){e=Math.min(c.za.length,0<=e?1:0);for(i=0;i<e;i++){m=c;l=c.za.pop();if(!x(m.buffer)&&l.zoom==m.N&&(o=l.x-m.Va,q=l.y-m.ta,t=1<<m.N,o=K(o,t),q=K(q,t),!(0>o||o>=m.h||0>q||q>=m.h))){t=m.U.d;v=m.T.Fa();t.bindTexture(t.TEXTURE_2D,m.buffer.$);B=K(o+m.Va,m.h)*v;v*=m.h-K(q+m.ta,m.h)-1;try{t.texSubImage2D(t.TEXTURE_2D,0,B,v,t.RGBA,t.UNSIGNED_BYTE,bd(l)),m.M[q][o]=1}catch(ha){m.T.xc()&&
(m.T.dd(m.U.Hb)||!(l.n&&0==l.n.src.lastIndexOf(m.U.Hb,0)))?ud(m,l.x,l.y,l.La):m.U.Td()}}b++}}qd(c.gd);0<b&&(c.U.d.activeTexture(c.U.d.TEXTURE0),c.U.d.bindTexture(c.U.d.TEXTURE_2D,c.buffer.$),c.U.d.generateMipmap(c.U.d.TEXTURE_2D));e=g-b}}function zd(a,b,c){return b>a.ac||b-c<a.X?Array(a.h*a.h):Da(a.C[b-a.X-c].M)}function Ad(a,b,c){return b>a.ac||b-c<a.X?n:a.C[b-a.X-c].buffer.$}
function Bd(a,b,c){if(b>a.ac)return Array(2*c);for(var d=[],e=b-a.X;e>b-a.X-c;--e)d.push(Math.round(a.C[Math.max(0,e)].Va),Math.round(a.C[Math.max(0,e)].ta));return d}function xd(a){for(var b=Array(a.na.length),c=0;c<a.na.length;c++){var d=a.C[a.ba+c],e=Cd(2*(0.5-d.ta/d.S)*Math.PI),f=Cd(2*(0.5-(d.ta+d.h)/d.S)*Math.PI);b[c]=new nd(d.jb?0:Cd(2*(0.5-(d.ta+d.h/2)/d.S)*Math.PI),d.jb?0:2*((d.Va+d.h/2)/d.S-0.5)*Math.PI,d.jb?Math.PI/2:Math.abs(e-f),d.jb?Math.PI:2*(d.h/d.S)*Math.PI,d.N)}a.T.Wd(b)};function Dd(a,b,c,d){b=b.d;this.l=a;this.ga=b.getAttribLocation(this.l,"aVertexPosition");this.Za=b.getAttribLocation(this.l,"aTextureCoord");this.Xe=Y(b,this.l,"uMVPMatrix");this.Oe=Y(b,this.l,"uMetaL0A");this.Re=Y(b,this.l,"uMetaL1A");this.Ue=Y(b,this.l,"uMetaL2A");this.Ie=Y(b,this.l,"uOffLA");this.ee=Y(b,this.l,"uBufferL0A");this.he=Y(b,this.l,"uBufferL1A");this.ke=Y(b,this.l,"uBufferL2A");this.me=Y(b,this.l,"uBufferLnA");c&&(this.Pe=Y(b,this.l,"uMetaL0B"),this.Se=Y(b,this.l,"uMetaL1B"),this.Ve=
Y(b,this.l,"uMetaL2B"),this.Je=Y(b,this.l,"uOffLB"),this.fe=Y(b,this.l,"uBufferL0B"),this.ie=Y(b,this.l,"uBufferL1B"),this.le=Y(b,this.l,"uBufferL2B"),this.We=Y(b,this.l,"uMixFactor"));d&&(this.se=Y(b,this.l,"uDegradationT"),this.Qe=Y(b,this.l,"uMetaL0T"),this.Te=Y(b,this.l,"uMetaL1T"),this.Ke=Y(b,this.l,"uOffLT"),this.ge=Y(b,this.l,"uBufferL0T"),this.je=Y(b,this.l,"uBufferL1T"),this.ne=Y(b,this.l,"uBufferLnT"));this.tf=Y(b,this.l,"uTileCount");this.af=Y(b,this.l,"uOffset")}
function Y(a,b,c){a=a.getUniformLocation(b,c);x(a)&&h(Error("Invalid name "+c));return a};var Ed={"earth-fs-overlay.glsl":"precision mediump float;uniform sampler2D uBufferL0A;uniform sampler2D uBufferL1A;uniform sampler2D uBufferL2A;uniform sampler2D uBufferLnA;varying float vFallbackA;varying vec2 vTCA;uniform sampler2D uBufferL0B;uniform sampler2D uBufferL1B;uniform sampler2D uBufferL2B;varying float vFallbackB;varying vec2 vTCB;uniform float uMixFactor;void main(){float fallbackA=floor(vFallbackA+0.5);vec4 colorA;if(fallbackA==0.0){colorA=texture2D(uBufferL0A,vTCA);}else if(fallbackA==1.0){colorA=texture2D(uBufferL1A,vTCA);}else if(fallbackA==2.0){colorA=texture2D(uBufferL2A,vTCA);}else if(fallbackA==-1.0){colorA=texture2D(uBufferLnA,vTCA);}else{discard;}float fallbackB=floor(vFallbackB+0.5);vec4 colorB=vec4(0.0);if(fallbackB==0.0){colorB=texture2D(uBufferL0B,vTCB);}else if(fallbackB==1.0){colorB=texture2D(uBufferL1B,vTCB);}else if(fallbackB==2.0){colorB=texture2D(uBufferL2B,vTCB);}gl_FragColor=mix(colorA,colorB,uMixFactor*colorB.a);}",
"earth-fs.glsl":"precision mediump float;uniform sampler2D uBufferL0A;uniform sampler2D uBufferL1A;uniform sampler2D uBufferL2A;uniform sampler2D uBufferLnA;varying float vFallbackA;varying vec2 vTCA;void main(){float fallback=floor(vFallbackA+0.5);if(fallback==0.0){gl_FragColor=texture2D(uBufferL0A,vTCA);}else if(fallback==1.0){gl_FragColor=texture2D(uBufferL1A,vTCA);}else if(fallback==2.0){gl_FragColor=texture2D(uBufferL2A,vTCA);}else if(fallback==-1.0){gl_FragColor=texture2D(uBufferLnA,vTCA);}else{discard;}}",
"earth-vs-overlay.glsl":"#define BUFF_SIDE 4.0\n#define BUFF_SIZE 16\n#define TERRAIN %TERRAIN_BOOL%\n#define BUFF_SIDE_T %BUFFER_SIDE_T_FLOAT%\n#define BUFF_SIZE_T int(BUFF_SIDE_T*BUFF_SIDE_T)\nprecision highp float;const float PI=3.1415927;const float PI2=6.2831855;const float EARTH_RADIUS=6378137.0;const float TERRAIN_MIN=-10000.0;const float TERRAIN_MAX=12000.0;attribute vec2 aVertexPosition;attribute vec2 aTextureCoord;uniform mat4 uMVPMatrix;uniform float uTileCount;uniform vec2 uOffset;uniform float uMetaL0A[BUFF_SIZE];uniform float uMetaL1A[BUFF_SIZE];uniform float uMetaL2A[BUFF_SIZE];uniform vec2 uOffLA[3];varying float vFallbackA;varying vec2 vTCA;uniform float uMetaL0B[BUFF_SIZE];uniform float uMetaL1B[BUFF_SIZE];uniform float uMetaL2B[BUFF_SIZE];uniform vec2 uOffLB[3];varying float vFallbackB;varying vec2 vTCB;\n#if TERRAIN\nuniform float uMetaL0T[BUFF_SIZE_T];uniform float uMetaL1T[BUFF_SIZE_T];uniform vec2 uOffLT[2];uniform sampler2D uBufferL0T;uniform sampler2D uBufferL1T;uniform sampler2D uBufferLnT;uniform float uDegradationT;bool validateOffsetT(vec2 off){return off.x>=0.0&&off.y>=0.0&&off.x<BUFF_SIDE_T&&off.y<BUFF_SIDE_T;}\n#endif\nbool validateOffset(vec2 off){return off.x>=0.0&&off.y>=0.0&&off.x<BUFF_SIDE&&off.y<BUFF_SIDE;}vec2 modFirst(vec2 x,float y){return vec2(x.x-y*floor(x.x/y),x.y);}void main(){vec2 phi=PI2*(aVertexPosition+uOffset)/uTileCount;vec2 tileCoords=vec2(mod(aVertexPosition.x-aTextureCoord.x+uOffset.x+uTileCount*0.5,uTileCount),-aTextureCoord.y-aVertexPosition.y-uOffset.y+uTileCount*0.5);float elev=0.0;\n#if TERRAIN\nvec2 TCT;float fallbackT=-1.0;float degradationModifier=exp2(uDegradationT);vec2 offT=modFirst(tileCoords/degradationModifier-uOffLT[0],uTileCount/degradationModifier);vec2 rawElev;if(validateOffsetT(offT)&&uMetaL0T[int(floor(offT.y)*BUFF_SIDE_T+offT.x)]==1.0){fallbackT=0.0;}else{offT=modFirst((tileCoords/(2.0*degradationModifier))-uOffLT[1],uTileCount/(2.0*degradationModifier));if(validateOffsetT(offT)&&uMetaL1T[int(floor(offT.y)*BUFF_SIDE_T+offT.x)]==1.0){fallbackT=1.0;}else{TCT=(tileCoords+aTextureCoord)/uTileCount;}}if(fallbackT>=0.0){TCT=(offT+aTextureCoord/(exp2(fallbackT)*degradationModifier)+mod(uOffLT[int(fallbackT)],BUFF_SIDE_T))/BUFF_SIDE_T;}TCT.y=1.0-TCT.y;if(fallbackT==0.0){rawElev=texture2D(uBufferL0T,TCT).rg;}else if(fallbackT==1.0){rawElev=texture2D(uBufferL1T,TCT).rg;}else{rawElev=texture2D(uBufferLnT,TCT).rg;}elev=((TERRAIN_MAX-TERRAIN_MIN)*(rawElev.r+rawElev.g/256.0)-TERRAIN_MAX)/EARTH_RADIUS;\n#endif\nfloat exp_2y=exp(2.0*phi.y);float tanh=((exp_2y-1.0)/(exp_2y+1.0));float cosy=sqrt(1.0-tanh*tanh);vec3 pos=vec3(sin(phi.x)*cosy,tanh,cos(phi.x)*cosy);gl_Position=uMVPMatrix*vec4(pos*(1.0+elev),1.0);if(abs(phi.y)>PI){vFallbackA=-1.0e3;return;}vFallbackA=-1.0;vec2 off=modFirst(tileCoords-uOffLA[0],uTileCount);if(validateOffset(off)&&uMetaL0A[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackA=0.0;}else{off=modFirst((tileCoords/2.0)-uOffLA[1],uTileCount/2.0);if(validateOffset(off)&&uMetaL1A[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackA=1.0;}else{off=modFirst((tileCoords/4.0)-uOffLA[2],uTileCount/4.0);if(validateOffset(off)&&uMetaL2A[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackA=2.0;}}}if(vFallbackA>=0.0){vTCA=(off+aTextureCoord/exp2(vFallbackA)+mod(uOffLA[int(vFallbackA)],BUFF_SIDE))/BUFF_SIDE;}else{vTCA=(tileCoords+aTextureCoord)/uTileCount;}vTCA.y=1.0-vTCA.y;vFallbackB=-1.0;off=modFirst(tileCoords-uOffLB[0],uTileCount);if(validateOffset(off)&&uMetaL0B[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackB=0.0;}else{off=modFirst((tileCoords/2.0)-uOffLB[1],uTileCount/2.0);if(validateOffset(off)&&uMetaL1B[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackB=1.0;}else{off=modFirst((tileCoords/4.0)-uOffLB[2],uTileCount/4.0);if(validateOffset(off)&&uMetaL2B[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackB=2.0;}}}if(vFallbackB>=0.0){vTCB=(off+aTextureCoord/exp2(vFallbackB)+mod(uOffLB[int(vFallbackB)],BUFF_SIDE))/BUFF_SIDE;}else{vTCB=(tileCoords+aTextureCoord)/uTileCount;}vTCB.y=1.0-vTCB.y;}",
"earth-vs.glsl":"#define BUFF_SIDE 8.0\n#define BUFF_SIZE 64\n#define TERRAIN %TERRAIN_BOOL%\n#define BUFF_SIDE_T %BUFFER_SIDE_T_FLOAT%\n#define BUFF_SIZE_T int(BUFF_SIDE_T*BUFF_SIDE_T)\nprecision highp float;const float PI=3.1415927;const float PI2=6.2831855;const float EARTH_RADIUS=6378137.0;const float TERRAIN_MIN=-10000.0;const float TERRAIN_MAX=12000.0;attribute vec2 aVertexPosition;attribute vec2 aTextureCoord;uniform mat4 uMVPMatrix;uniform float uTileCount;uniform vec2 uOffset;uniform float uMetaL0A[BUFF_SIZE];uniform float uMetaL1A[BUFF_SIZE];uniform float uMetaL2A[BUFF_SIZE];uniform vec2 uOffLA[3];varying float vFallbackA;varying vec2 vTCA;\n#if TERRAIN\nuniform float uMetaL0T[BUFF_SIZE_T];uniform float uMetaL1T[BUFF_SIZE_T];uniform vec2 uOffLT[2];uniform sampler2D uBufferL0T;uniform sampler2D uBufferL1T;uniform sampler2D uBufferLnT;uniform float uDegradationT;bool validateOffsetT(vec2 off){return off.x>=0.0&&off.y>=0.0&&off.x<BUFF_SIDE_T&&off.y<BUFF_SIDE_T;}\n#endif\nbool validateOffset(vec2 off){return off.x>=0.0&&off.y>=0.0&&off.x<BUFF_SIDE&&off.y<BUFF_SIDE;}vec2 modFirst(vec2 x,float y){return vec2(x.x-y*floor(x.x/y),x.y);}void main(){vec2 phi=PI2*(aVertexPosition+uOffset)/uTileCount;vec2 tileCoords=vec2(mod(aVertexPosition.x-aTextureCoord.x+uOffset.x+uTileCount*0.5,uTileCount),-aTextureCoord.y-aVertexPosition.y-uOffset.y+uTileCount*0.5);float elev=0.0;\n#if TERRAIN\nvec2 TCT;float fallbackT=-1.0;float degradationModifier=exp2(uDegradationT);vec2 offT=modFirst(tileCoords/degradationModifier-uOffLT[0],uTileCount/degradationModifier);vec2 rawElev;if(validateOffsetT(offT)&&uMetaL0T[int(floor(offT.y)*BUFF_SIDE_T+offT.x)]==1.0){fallbackT=0.0;}else{offT=modFirst((tileCoords/(2.0*degradationModifier))-uOffLT[1],uTileCount/(2.0*degradationModifier));if(validateOffsetT(offT)&&uMetaL1T[int(floor(offT.y)*BUFF_SIDE_T+offT.x)]==1.0){fallbackT=1.0;}else{TCT=(tileCoords+aTextureCoord)/uTileCount;}}if(fallbackT>=0.0){TCT=(offT+aTextureCoord/(exp2(fallbackT)*degradationModifier)+mod(uOffLT[int(fallbackT)],BUFF_SIDE_T))/BUFF_SIDE_T;}TCT.y=1.0-TCT.y;if(fallbackT==0.0){rawElev=texture2D(uBufferL0T,TCT).rg;}else if(fallbackT==1.0){rawElev=texture2D(uBufferL1T,TCT).rg;}else{rawElev=texture2D(uBufferLnT,TCT).rg;}elev=((TERRAIN_MAX-TERRAIN_MIN)*(rawElev.r+rawElev.g/256.0)-TERRAIN_MAX)/EARTH_RADIUS;\n#endif\nfloat exp_2y=exp(2.0*phi.y);float tanh=((exp_2y-1.0)/(exp_2y+1.0));float cosy=sqrt(1.0-tanh*tanh);vec3 pos=vec3(sin(phi.x)*cosy,tanh,cos(phi.x)*cosy);gl_Position=uMVPMatrix*vec4(pos*(1.0+elev),1.0);if(abs(phi.y)>PI){vFallbackA=-1.0e3;return;}vFallbackA=-1.0;vec2 off=modFirst(tileCoords-uOffLA[0],uTileCount);if(validateOffset(off)&&uMetaL0A[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackA=0.0;}else{off=modFirst((tileCoords/2.0)-uOffLA[1],uTileCount/2.0);if(validateOffset(off)&&uMetaL1A[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackA=1.0;}else{off=modFirst((tileCoords/4.0)-uOffLA[2],uTileCount/4.0);if(validateOffset(off)&&uMetaL2A[int(floor(off.y)*BUFF_SIDE+off.x)]==1.0){vFallbackA=2.0;}}}if(vFallbackA>=0.0){vTCA=(off+aTextureCoord/exp2(vFallbackA)+mod(uOffLA[int(vFallbackA)],BUFF_SIDE))/BUFF_SIDE;}else{vTCA=(tileCoords+aTextureCoord)/uTileCount;}vTCA.y=1.0-vTCA.y;}",
"halo-fs.glsl":"precision lowp float;uniform sampler2D uGradient;varying vec2 vCoords;void main(){float distance=vCoords.x*vCoords.x+vCoords.y*vCoords.y;if(distance<0.98){discard;}else{gl_FragColor=texture2D(uGradient,vec2((sqrt(distance)-1.0)/0.1,0.5));}}","halo-vs.glsl":"precision lowp float;attribute vec2 aVertexPosition;uniform mat4 uMVMatrix;uniform mat4 uPMatrix;varying vec2 vCoords;void main(){gl_Position=uPMatrix*(uMVMatrix[3]+uMVMatrix[0]*aVertexPosition.x+uMVMatrix[1]*aVertexPosition.y);gl_Position.z=0.0;vCoords=aVertexPosition;}",
"miniglobe-fs.glsl":"precision lowp float;varying vec2 vTextureCoord;uniform sampler2D uSampler;void main(){gl_FragColor=texture2D(uSampler,vTextureCoord);}","miniglobe-vs.glsl":"precision mediump float;attribute vec3 aVertexPosition;attribute vec2 aTextureCoord;uniform mat4 uMVMatrix;uniform mat4 uPMatrix;uniform float uAspect;varying vec2 vTextureCoord;void main(){gl_Position=uPMatrix*uMVMatrix*vec4(aVertexPosition,1.0);gl_Position.x*=uAspect;gl_Position.z=0.0;vTextureCoord=aTextureCoord;}","polygon-fs.glsl":"precision lowp float;uniform vec4 uColor;void main(){gl_FragColor=uColor;}",
"polygon-vs.glsl":"precision highp float;attribute vec3 aVertexCoords;uniform mat4 uMVPMatrix;void main(){gl_Position=uMVPMatrix*vec4(aVertexCoords,1.0);}"};function Fd(a){return a in Ed?Ed[a]:vc("../we/shaders/"+a)};function Gd(a){hd.call(this,a);this.ad=""}G(Gd,hd);Gd.prototype.xc=ba(k);Gd.prototype.dd=function(a){var b=this.ad!=a;this.ad=a;return b};Gd.prototype.Cb=function(a,b,c){var d=new Image;d.onload=D(function(){a.state=20;this.da--;b(a)},this);d.onerror=D(function(){a.Cc++;a.state=-10;this.da--;c&&c(a)},this);a.state=10;a.cd(d);d.crossOrigin="";var e=this.Hc(a.zoom,a.x,a.y);d.src=this.ad+e;this.da++};function Hd(a,b,c,d,e,f,g,i){Gd.call(this,a);this.url=b;this.minZoom=c;this.maxZoom=d;this.tileSize=e;this.ze=f===k;this.ed=g||[];this.copyright=i||""}G(Hd,Gd);s=Hd.prototype;s.Qa=r("minZoom");s.Ea=r("maxZoom");s.Fa=r("tileSize");s.Hc=function(a,b,c){var d=this.url.replace("{z}",a.toFixed(0)),d=d.replace("{x}",b.toFixed(0)),d=d.replace("{y}",(this.ze?(1<<a)-c-1:c).toFixed(0));0<this.ed.length&&(d=d.replace("{sub}",this.ed[K(b+c+a,this.ed.length)]));return d};
s.Na=function(a){0<this.copyright.length&&R(a,this.copyright)};function Id(a){Hd.call(this,a||"MapQuest OSM","http://otile{sub}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png",0,18,256,p,["1","2","3","4"])}G(Id,Hd);Id.prototype.Na=function(a){R(a,"Map data \u00a9 ",Q("a",{href:"http://www.openstreetmap.org/"},"OpenStreetMap")," contributors, CC-BY-SA",Q("br"));R(a,"Tiles Courtesy of ",Q("a",{href:"http://open.mapquest.co.uk/"},"MapQuest")," ",Q("img",{src:"http://developer.mapquest.com/content/osm/mq_logo.png",border:0}))};function Jd(a,b){this.a=a.a;this.c=a;this.L=b||new Id;this.P=new wd(this.L,this.a,8,3,1,19);this.J=this.Oa=n;if(this.Ya=p)this.nc=new Hd("Terrain","http://srtm.webglearth.com/srtm/{z}/{x}/{y}.png",0,10,256),this.Ba=new wd(this.nc,this.a,2,3,this.nc.Qa(),this.nc.Ea());this.oa(this.L,k);this.$a=1;this.Sc=[0,0];this.Yd=[new Gc(this.a,1,1,1),new Gc(this.a,4,4,16,k),new Gc(this.a,6,6,8,k),new Gc(this.a,8,8,8,k),new Gc(this.a,10,10,8),new Gc(this.a,64,64,this.Ya?8:4)];this.Le=Kd(this,p);this.Me=Kd(this,
k);this.N=n;U(this.c.b,Dc,this.xf,p,this)}function Ld(a){for(var b=a.P,c="",d=0;d<b.C.length;++d)c+=d+b.X+":"+b.C[d].za.length+" ";b="BufferQueue size: "+c+"; Loading tiles: "+a.L.da;a.Oa&&(b+=" + "+a.Oa.da);return b}s=Jd.prototype;
s.oa=function(a,b,c){a&&(a.yc=D(this.c.kd,this.c));if(c)(this.Oa=a)?y(this.J)?this.J.oa(a):(this.P=new wd(this.L,this.a,4,3,1,19),this.J=new wd(this.Oa,this.a,4,3,0,15)):y(this.J)&&(this.P=new wd(this.L,this.a,8,3,1,19),this.J=n);else{if(!a)return;this.P.oa(a);this.L=a}b!==k&&(Rc(this.c),this.c.kd(),this.setZoom(this.getZoom()))};
s.draw=function(){var a=this.a.d;this.$a=1<<this.getZoom();var b=this.c.b.getPosition(),c=Ec(this.c.b)||b;this.Sc[0]=Math.floor(b[1]/(2*Math.PI)*this.$a);this.Sc[1]=J(Math.floor(jd(b[0])/(2*Math.PI)*this.$a),-this.$a/2,this.$a/2);yd(this.P,c[0],c[1],b[0],b[1],Math.floor(this.getZoom()));this.J&&yd(this.J,c[0],c[1],b[0],b[1],Math.floor(this.getZoom()));this.Ya&&yd(this.Ba,c[0],c[1],b[0],b[1],Math.floor(this.getZoom())-5);c=Math.floor(this.getZoom());this.$a=1<<c;b=this.J?this.Me:this.Le;a.useProgram(b.l);
a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,Ad(this.P,c,0));a.uniform1i(b.ee,0);a.activeTexture(a.TEXTURE1);a.bindTexture(a.TEXTURE_2D,Ad(this.P,c,1));a.uniform1i(b.he,1);a.activeTexture(a.TEXTURE2);a.bindTexture(a.TEXTURE_2D,Ad(this.P,c,2));a.uniform1i(b.ke,2);a.activeTexture(a.TEXTURE3);a.bindTexture(a.TEXTURE_2D,this.P.Ab.$);a.uniform1i(b.me,3);a.uniform1fv(b.Oe,new Float32Array(zd(this.P,c,0)));a.uniform1fv(b.Re,new Float32Array(zd(this.P,c,1)));a.uniform1fv(b.Ue,new Float32Array(zd(this.P,
c,2)));a.uniform2fv(b.Ie,new Float32Array(Bd(this.P,c,3)));this.J&&(a.activeTexture(a.TEXTURE4),a.bindTexture(a.TEXTURE_2D,Ad(this.J,c,0)),a.uniform1i(b.fe,4),a.activeTexture(a.TEXTURE5),a.bindTexture(a.TEXTURE_2D,Ad(this.J,c,1)),a.uniform1i(b.ie,5),a.activeTexture(a.TEXTURE6),a.bindTexture(a.TEXTURE_2D,Ad(this.J,c,2)),a.uniform1i(b.le,6),a.uniform1fv(b.Pe,new Float32Array(zd(this.J,c,0))),a.uniform1fv(b.Se,new Float32Array(zd(this.J,c,1))),a.uniform1fv(b.Ve,new Float32Array(zd(this.J,c,2))),a.uniform2fv(b.Je,
new Float32Array(Bd(this.J,c,3))),a.uniform1f(b.We,this.Oa.opacity));if(this.Ya){var d=J(c-5,2,this.nc.Ea());a.uniform1f(b.se,c-d);a.activeTexture(a.TEXTURE7);a.bindTexture(a.TEXTURE_2D,Ad(this.Ba,d,0));a.uniform1i(b.ge,7);a.activeTexture(a.TEXTURE8);a.bindTexture(a.TEXTURE_2D,Ad(this.Ba,d,1));a.uniform1i(b.je,8);a.activeTexture(a.TEXTURE9);a.bindTexture(a.TEXTURE_2D,this.Ba.Ab.$);a.uniform1i(b.ne,9);a.uniform1fv(b.Qe,new Float32Array(zd(this.Ba,d,0)));a.uniform1fv(b.Te,new Float32Array(zd(this.Ba,
d,1)));a.uniform2fv(b.Ke,new Float32Array(Bd(this.Ba,d,2)))}d=new Float32Array(Da(oc(Sc(this.a)).Ma()));c=this.Yd[Math.min(c,this.Yd.length-1)];a.bindBuffer(a.ARRAY_BUFFER,c.rc);a.vertexAttribPointer(b.ga,c.rc.Ia,a.FLOAT,p,0,0);a.enableVertexAttribArray(b.ga);a.bindBuffer(a.ARRAY_BUFFER,c.oc);a.vertexAttribPointer(b.Za,c.oc.Ia,a.FLOAT,p,0,0);a.enableVertexAttribArray(b.Za);a.uniformMatrix4fv(b.Xe,p,d);a.uniform1f(b.tf,this.$a);a.uniform2fv(b.af,new Float32Array(this.Sc));a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,
c.Bd);a.drawElements(a.TRIANGLES,c.Ze,a.UNSIGNED_SHORT,0);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,n);a.disableVertexAttribArray(b.ga);a.disableVertexAttribArray(b.Za)};
function Kd(a,b){var c=a.a.d,d=Fd("earth-fs"+(b?"-overlay":"")+".glsl"),e=Fd("earth-vs"+(b?"-overlay":"")+".glsl"),e=e.replace("%TERRAIN_BOOL%",a.Ya?"1":"0");a.Ya&&(e=e.replace("%BUFFER_SIDE_T_FLOAT%",a.Ba.h.toFixed(1)));var d=Tc(a.a,d,c.FRAGMENT_SHADER),e=Tc(a.a,e,c.VERTEX_SHADER),f=c.createProgram();x(f)&&h(Error("Unknown"));c.attachShader(f,e);c.attachShader(f,d);c.bindAttribLocation(f,0,"aVertexPosition");c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||h(Error("Shader program err: "+
c.getProgramInfoLog(f)));return new Dd(f,a.a,b,a.Ya)}s.setZoom=function(a){this.N=J(a,this.L.Qa(),this.L.Ea());Cc(this.c.b,Md(this,this.N,this.c.b.V))};s.xf=function(){this.N=n};s.getZoom=function(){x(this.N)&&Nd(this);return this.N};function Nd(a,b){var c=a.c.b,d=2*(c.I/6378137)*Math.tan(a.a.Da/2)/a.c.qc,c=Math.log(2*Math.cos(Math.abs(c.V))*Math.PI/d)/Math.LN2;if(b)return c;a.N=J(c,a.L.Qa(),a.L.Ea());return a.N}
function Md(a,b,c){b=2*Math.cos(Math.abs(c))*Math.PI/Math.pow(2,b)*a.c.qc;return 6378137*1/Math.tan(a.a.Da/2)*(b/2)}function Od(a,b,c,d){var e=Math.sin((c-a)/2),b=Math.sin((d-b)/2);return 6378137*2*Math.asin(Math.sqrt(e*e+Math.cos(a)*Math.cos(c)*b*b))};function Pd(a){this.a=a.a;a=this.d=a.a.d;this.aa=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,this.aa);a.bufferData(a.ARRAY_BUFFER,new Float32Array([1.1,1.1,-1.1,1.1,1.1,-1.1,-1.1,-1.1]),a.STATIC_DRAW);this.zd=a.createTexture();var b=new Uint8Array([224,224,255,255,207,218,250,220,179,194,245,180,137,166,237,145,84,123,221,110,51,94,198,75,25,67,178,30,13,53,161,0]);a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,this.zd);a.texImage2D(a.TEXTURE_2D,0,a.RGBA,8,1,0,a.RGBA,a.UNSIGNED_BYTE,b);a.texParameteri(a.TEXTURE_2D,
a.TEXTURE_MAG_FILTER,a.LINEAR);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE);a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);b=Fd("halo-fs.glsl");a=Fd("halo-vs.glsl");b=Tc(this.a,b,this.d.FRAGMENT_SHADER);a=Tc(this.a,a,this.d.VERTEX_SHADER);this.g=this.d.createProgram();x(this.g)&&h(Error("Unknown"));this.d.attachShader(this.g,a);this.d.attachShader(this.g,b);this.d.bindAttribLocation(this.g,0,"aVertexPosition");
this.d.linkProgram(this.g);this.d.getProgramParameter(this.g,this.d.LINK_STATUS)||h(Error("Shader program err: "+this.d.getProgramInfoLog(this.g)));this.ga=this.d.getAttribLocation(this.g,"aVertexPosition");this.Qc=this.d.getUniformLocation(this.g,"uMVMatrix");this.Yc=this.d.getUniformLocation(this.g,"uPMatrix");this.De=this.d.getUniformLocation(this.g,"uGradient")}
Pd.prototype.draw=function(){this.d.useProgram(this.g);this.d.activeTexture(this.d.TEXTURE0);this.d.bindTexture(this.d.TEXTURE_2D,this.zd);this.d.uniform1i(this.De,0);var a=new Float32Array(Da(oc(this.a.O.K).Ma())),b=new Float32Array(Da(oc(this.a.Ka).Ma()));this.d.uniformMatrix4fv(this.Qc,p,a);this.d.uniformMatrix4fv(this.Yc,p,b);this.d.bindBuffer(this.d.ARRAY_BUFFER,this.aa);this.d.bindBuffer(this.d.ELEMENT_ARRAY_BUFFER,n);this.d.vertexAttribPointer(this.ga,2,this.d.FLOAT,p,0,0);this.d.enableVertexAttribArray(this.ga);
this.d.drawArrays(this.d.TRIANGLE_STRIP,0,4);this.d.disableVertexAttribArray(this.ga)};function Qd(a,b,c,d){this.f=a;this.canvas=document.createElement("canvas");R(this.f.a.canvas.parentElement||window.document,this.canvas);var a={depth:p},e=this.d=this.canvas.getContext("webgl",a)||this.canvas.getContext("experimental-webgl",a);e.enable(e.CULL_FACE);e.cullFace(e.BACK);e.clearColor(0,0,0,0);this.aa=e.createBuffer();for(var a=[],f=[],g=[],i=0;i<=b;i++)for(var l=i*Math.PI/b,m=Math.sin(l),q=Math.cos(l),l=0;l<=c;l++){var o=2*l*Math.PI/c,o=o-Math.PI/2,v=Math.cos(o)*m,t=q,o=Math.sin(o)*m,
B=1-i/b;f.push(1-l/c);f.push(B);a.push(1*v);a.push(1*t);a.push(1*o)}for(i=0;i<b;i++)for(l=0;l<c;l++)m=i*(c+1)+l,q=m+c+1,g.push(m+1),g.push(q),g.push(m),g.push(m+1),g.push(q+1),g.push(q);this.aa=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,this.aa);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);this.aa.Ia=3;this.aa.Rc=a.length/3;this.Lb=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,this.Lb);e.bufferData(e.ARRAY_BUFFER,new Float32Array(f),e.STATIC_DRAW);this.Lb.Ia=2;this.Lb.Rc=f.length/
2;this.Ha=e.createBuffer();e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this.Ha);e.bufferData(e.ELEMENT_ARRAY_BUFFER,new Uint16Array(g),e.STATIC_DRAW);this.Ha.Ia=1;this.Ha.Rc=g.length;this.pc=n;var ha=new Image;ha.onload=D(function(){this.pc=e.createTexture();e.activeTexture(e.TEXTURE0);e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,k);e.bindTexture(e.TEXTURE_2D,this.pc);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,ha);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_2D,
e.TEXTURE_MIN_FILTER,e.LINEAR)},this);ha.src=d;c=Fd("miniglobe-fs.glsl");b=Fd("miniglobe-vs.glsl");c=Tc(e,c,e.FRAGMENT_SHADER);b=Tc(e,b,e.VERTEX_SHADER);this.g=e.createProgram();x(this.g)&&h(Error("Unknown"));e.attachShader(this.g,b);e.attachShader(this.g,c);e.bindAttribLocation(this.g,0,"aVertexPosition");e.linkProgram(this.g);e.getProgramParameter(this.g,e.LINK_STATUS)||h(Error("Shader program err: "+e.getProgramInfoLog(this.g)));e.useProgram(this.g);this.ga=e.getAttribLocation(this.g,"aVertexPosition");
this.Za=e.getAttribLocation(this.g,"aTextureCoord");this.de=e.getUniformLocation(this.g,"uAspect");this.Yc=e.getUniformLocation(this.g,"uPMatrix");this.Qc=e.getUniformLocation(this.g,"uMVMatrix");this.gf=e.getUniformLocation(this.g,"uSampler");this.e=128;this.Zc=0.1}function Ka(a,b){var c=a.e*(1+a.Zc);b.drawImage(a.canvas,a.f.a.canvas.width-c,a.f.a.canvas.height-c)}
Qd.prototype.draw=function(){if(y(this.pc)){var a=this.d;a.useProgram(this.g);a.activeTexture(a.TEXTURE0);a.bindTexture(a.TEXTURE_2D,this.pc);a.uniform1i(this.gf,0);var b=new Ic;b.translate(0,0,-1.1/Math.tan(this.f.a.Da/2));Kc(b,this.f.b.V);Jc(b,-this.f.b.ea);var c=new Float32Array(Da(oc(this.f.a.Ka).Ma()));a.uniformMatrix4fv(this.Qc,p,new Float32Array(Da(oc(b.K).Ma())));a.uniformMatrix4fv(this.Yc,p,c);a.uniform1f(this.de,this.f.a.fb);a.bindBuffer(a.ARRAY_BUFFER,this.aa);a.vertexAttribPointer(this.ga,
this.aa.Ia,a.FLOAT,p,0,0);a.bindBuffer(a.ARRAY_BUFFER,this.Lb);a.vertexAttribPointer(this.Za,this.Lb.Ia,a.FLOAT,p,0,0);a.enableVertexAttribArray(this.ga);a.enableVertexAttribArray(this.Za);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.Ha);a.drawElements(a.TRIANGLES,this.Ha.Rc,a.UNSIGNED_SHORT,0);a.disableVertexAttribArray(this.ga);a.disableVertexAttribArray(this.Za)}};function Rd(a,b,c,d,e,f,g){this.a=a;this.Cd=b||n;this.ma=c||document.createElement("div");w(c)||(a=this.a.canvas,a.parentNode&&a.parentNode.insertBefore(this.ma,a.nextSibling));this.sb=d||document.createElement("img");w(d)||(d=this.ma,d.parentNode&&d.parentNode.insertBefore(this.sb,d.nextSibling));this.ce=f||n;this.b=new yc(this);this.w=new Jd(this,e);this.mb=n;this.Ad=g===k?n:new Pd(this);this.nd=[];this.qc=0;Rc(this);this.kd()}
Rd.prototype.kd=function(){if(!x(this.ma)){for(var a=this.ma,b;b=a.firstChild;)a.removeChild(b);R(this.ma,this.ce);this.w.L.Na(this.ma);this.w.Oa&&(R(this.ma,Q("br"),Q("strong",{},"Overlay data:"),Q("br")),this.w.Oa.Na(this.ma));this.ma.style.Ud="none";a=this.ma.getElementsByTagName("a");for(b=0;b<a.length;++b)a[b].style.Ud="auto"}x(this.sb)||(x(this.w.L.Xb())?this.sb.style.visibility="hidden":(this.sb.src=this.w.L.Xb(),this.sb.style.visibility="visible"),this.sb.style.Ud="none")};
function Rc(a){a.qc=0.7*a.a.canvas.height/a.w.L.Fa()}
Rd.prototype.draw=function(){var a=this.a.d;x(this.Cd)||(this.Cd.innerHTML=M(this.b.V).toFixed(4)+"; "+M(this.b.ea).toFixed(4)+" @ "+this.b.I.toFixed(0)+"m -> z="+this.w.getZoom().toFixed(3)+"; "+Ld(this.w));var b=this.b.I/6378137;Qc(this.a,0.25*b,1+b);if(this.Ad){a.enable(a.BLEND);a.disable(a.DEPTH_TEST);var b=Math.sin((Math.PI-this.a.Da)/2),c=Math.sin(this.a.Da/2);this.a.O.K=kc(4);Kc(this.a.O,-this.b.getTilt());this.a.O.translate(0,0,c-1-this.b.I/6378137);this.a.O.scale(b,b,b);this.Ad.draw();a.disable(a.BLEND);
a.enable(a.DEPTH_TEST)}this.a.O.K=kc(4);Lc(this.a.O,-this.b.ic);Kc(this.a.O,-this.b.getTilt());Lc(this.a.O,-this.b.getHeading());this.a.O.translate(0,0,-1-this.b.I/6378137);Kc(this.a.O,this.b.V);Jc(this.a.O,-this.b.ea);this.w.draw();I(this.nd,function(a){a.draw()});this.mb&&this.mb.draw()};
function Sd(a,b){var c=a.gb();c.x=-c.x;c.y=-c.y;c.k=-c.k;var d=b.x*c.x+b.y*c.y+b.k*c.k,e=d*d-(c.x*c.x+c.y*c.y+c.k*c.k)+1;if(0>e)return n;c=Math.min(d+Math.sqrt(e),d-Math.sqrt(e));d=Math.max(d+Math.sqrt(e),d-Math.sqrt(e));return[c,d]}
function Fc(a,b,c,d){var e=tc(b,c,0,a.a.Fb,a.a.ia,a.a.ha),a=tc(b,c,1,a.a.Fb,a.a.ia,a.a.ha);if(x(e)||x(a))return n;a.fd(e);a.normalize();b=Sd(e,a);if(x(b))return n;a=a.scale(b[0]);e=new hc(e.x+a.x,e.y+a.y,e.k+a.k);a=Math.asin(e.x/Math.sqrt(1-e.y*e.y));0>e.k&&(a=Math.PI-a);return d==k?[Math.asin(e.y),wc(a)]:[M(Math.asin(e.y)),M(wc(a))]}function jd(a){return Math.log(Math.tan(a/2+Math.PI/4))}function Cd(a){return 2*Math.atan(Math.exp(a))-Math.PI/2};function Td(a,b,c){var d=Q("div",{"class":"we-pp-content"});d.innerHTML=a;a=Q("div",{"class":"we-pp-wrapper"},d);d=Q("div",{"class":"we-pp-tip-cont"},Q("div",{"class":"we-pp-tip"}));this.B=Q("div",{"class":"we-pp"});c!==p&&(c=Q("a",{"class":"we-pp-close",href:"#"}),c.onclick=D(this.show,this,p),this.B.appendChild(c));this.B.appendChild(a);this.B.appendChild(d);b=b||300;this.B.style.width=b.toFixed(0)+"px";this.B.style.left=(-b/2).toFixed(0)+"px";this.show(p)}
Td.prototype.show=function(a){a?(this.B.style.opacity=1,this.B.style.visibility="visible"):(this.B.style.opacity=0,this.B.style.visibility="hidden")};xc('.we-pp-content p{margin:18px 0;text-align:justify;}.we-pp-wrapper{padding:1px;text-align:left;border-radius:20px;}.we-pp{z-index:100;-webkit-transition:opacity 0.2s linear;-moz-transition:opacity 0.2s linear;-o-transition:opacity 0.2s linear;transition:opacity 0.2s linear;position:absolute;}.we-pp-wrapper,.we-pp-tip{background:white;box-shadow:0 1px 10px #888;-moz-box-shadow:0 1px 10px #888;-webkit-box-shadow:0 1px 14px #999;}.we-pp-close{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAk1BMVEX////Ny8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8vNy8sw0horAAAAMHRSTlMA/bGBFK1LgjellwUx2+VZo73SE6z5fQYOtzLRpxI22CC4g6ieV+yAEc8/ZocEHTzU+GNbAAAAV0lEQVQI1wXBBQKDMADAwLRl7szdgCks/3/d7hh0ehl0W21IwZgNR44nTNVZribmC1WXqzVstmpIALu9Gg5HOJ1VNV64arjd1YKy8sEz+nrD51tD0//xB/w6CnrIHetcAAAAAElFTkSuQmCC);position:absolute;top:9px;right:9px;width:10px;height:10px;overflow:hidden;}.we-pp-content{display:inline-block;margin:19px;font:12px/1.4 "Helvetica Neue",Arial,Helvetica,sans-serif;}.we-pp-tip-cont{margin:0 auto;width:40px;height:16px;position:relative;overflow:hidden;}.we-pp-tip{width:15px;height:15px;padding:1px;margin:-8px auto 0;-moz-transform:rotate(45deg);-webkit-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg);}');function Ud(a,b,c){this.lat=a;this.W=b;this.element=c;this.parentElement=n;this.enabled=k;this.visible=p}s=Ud.prototype;s.detach=function(){if(this.parentElement){var a=this.element;a&&a.parentNode&&a.parentNode.removeChild(a);this.parentElement=n}};s.enable=function(a){(this.enabled=a||p)||this.show(p)};s.isEnabled=r("enabled");s.show=function(a){this.visible=a==k;this.element.style.display=this.visible?"block":"none"};
s.kc=function(a,b){this.element.style.left=a.toFixed()+"px";this.element.style.top=b.toFixed()+"px";this.enabled&&this.show(k)};s.xd=ca;function Vd(a,b,c,d,e){var f=Q("div",{"class":"we-pm-icon"});A(c)&&(f.style.backgroundImage="url("+c+")");this.tb=d||25;this.ka=e||41;f.style.width=this.tb.toFixed(0)+"px";f.style.height=this.ka.toFixed(0)+"px";f.style.marginLeft=(-this.tb/2).toFixed(0)+"px";f.style.marginTop=(-this.ka).toFixed(0)+"px";c=Q("div",{style:"position:absolute;"},f);Ud.call(this,a,b,c);this.B=n;this.show(p);this.lc(p);f.onclick=D(this.lc,this,k)}G(Vd,Ud);Vd.prototype.lc=function(a){this.B&&this.B.show(a)};xc(".we-pm-icon{position:absolute;z-index:64;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFtklEQVR42p3Wa0xTZxgH8CYkS5aQLGFxcXNZNNu4FIFCK9eCWOQm3lDizLYP+zTnxLk5wQpICxRaLuWi3FpQFMU55xDkjiBTFMeA9Zy2JzMxWUZisoS4TyRuQvG/pydQKb3Q2uSXw3nf93n+5z2nLRVIiga88RERL/MlAgDrosJ+d/zISTJMEFt2B9LyEV5kySBo7G+iI9vdhyj7nfEhcjKfUvcAma0z+Pwa5+BwuxG7myaRUH4XtHaAhLgI6VvLjwwn14zj0CUWn13lkHXZhPQWBml6e3svGq3zvIyGX0F1z0mWQ4hY0buaH3mcUvsAn17hcKDNhFQdsy4K5Nfv108jsXIM1OOoqxAfMppMAYepIF3PIrmZ8cqhy2ZkXjBYQyxE9iqksGeFXKa9h0PtHF0di6Qmxhk+fKeLOcLX72r8DdRvjvjxIRGFt638yPz+Vha7W0zY0cDYydAbkXWJ4+1rYWx/H2gzO6wl/JysehzUUw0+5Oxtq+zEyns42MYhsZ6xQ2N0C0yQae9DouhFZt1dOvYgnt5RGU3T/Dw1tqtJ1xn5Gur7D/ERRBR0W43vapzhd5FwnrHZ02Kmt+jvkBTeRsOdPzD/7wJWXkPGp0hSD2BnzUMcuMjZ1RF+LFY1BOotFYQXdPkSy/5WDvF1DKSr8GOau7g1/RecvWafzSOuuBf79CYkNxodandox0G9VYLw/FvCSGUf9rZQci1js6PeiPRGAw7WjTgNePnyJa9mgJ5h1QPsWVOf0kTBdZOg/p0CUV6nNKp4ALv1HKJrGJu0Znqo1RNQds64DLBYLBjjniK6ZMihXtZgRPK5KVD/UYHozM+R1p1k6DhEaRmblAYK0U4g/8aUy4DFxUUMMLOIUQ071CfVm5BUOwnq30shNzeJC7qwq5nDtirGJq6GRWoDixR1HxYsS3YhS0tLWFhY4OVdf4TEqgmkNprt6ukiafwhqL9OECb/yYfMpzaaEKllIa5kbNKa6D6XjqK632i3C9oBH3DPPIttyn5+XUy1Y22cegzUO18QdvqGVWdC5SNK5xBezqyg3dB9pW1Hl4wgu20cM3/O4b+FRTx++gwNgywkeTfhrE5cwfBj4oJuUG+hIDT3RyuZpLAXO+s5hGkYOzHVRn5cWv4Q4rM91iJE5HchpnQMsjrWWY1tPfUd5j/xoTnXV0zEV05Cds6MUDVjR6RhkXSecxBTbXJYG0ZojnbRA+opXQ75YUWmpLCfro7D1lLmdfH1Us0EqN+o7Vs45NS1FT7kSXzVDGK1ZghVzGtJpJAI2gX1Sn4V8n3HakcliiEk1HIILGG8FldtRqxmEtRn2u6f1taTHau9SebitCzCNUb4FzNekdZwCC/oA/XIsg/57upaKrFiBHFaDh8rGY9FVZgRrZ4C1T8mPnYhwd9eWWsDeR5TaUKwyogPFYxHYqo4iPL7QbVf8M3tQ9qd0UUoxhBdyWFLIbOucLUJkeoZUN0secMx5MRlZwKIhW4BXSWLzWcZt6IqrLsYBNWccPq7S/jNJVe6wxX3sU1jxgf5BpeExUZIygyg9XPE13nI8TZXtm89dRNiCnk/z+AKPx+aNwhaX+jyZ2pQ9kV3JkTKRxCVmrDpjMGBv4JFRBkLWjdP3nITcsGdT4JzuiAqM+NduWEtfjzkzBBoXQXf0GXIsVZ3fMiTsKIpBBYZsfG0wWZzAQuRygSaf0E2ug0J/LplPdnBOT0IVZnxTq5hBX8eLB8Gzev4Zu5D9OvxJXMhRQZsoavfkEPPQ84gpMQEGreQLeuGBBzVe0IVlDuA4GIz3j5l4I9B8hHQeIfbAFvIVzpPbCQvhEoT3pOzEBaZEZh9BTQW4mFIs6d0gbl3EKSkAPkY6LyXCDwLOdLsKWHAsXYEKswIOH4NdC4lnoX4H2nyRnfA6THQ8Zflcw9Dvmz0xnb/7A7QMW353OMQb7USgTch/wNGSWfRl/HE1wAAAABJRU5ErkJggg==);}");function Wd(){this.m=Z;this.Ca=this.startTime=n}G(Wd,uc);var Z=0;function Xd(a){a.v("end")}Wd.prototype.v=function(a){this.dispatchEvent(a)};var Pa={},Yd=n;function Zd(a){a=C(a);delete Pa[a];Oa()&&Yd&&(dd.clearTimeout(Yd),Yd=n)}function $d(){Yd||(Yd=fd(function(){Yd=n;ae()}))}function ae(){var a=E();La(Pa,function(b){be(b,a)});Oa()||$d()};function ce(a,b,c,d){Wd.call(this);(!ea(a)||!ea(b))&&h(Error("Start and end parameters must be arrays"));a.length!=b.length&&h(Error("Start and end points must be the same length"));this.Kb=a;this.we=b;this.duration=c;this.md=d;this.coords=[]}G(ce,Wd);s=ce.prototype;s.yd=0;s.Y=0;s.Mc=n;
s.play=function(a){if(a||this.m==Z)this.Y=0,this.coords=this.Kb;else if(1==this.m)return p;Zd(this);this.startTime=a=E();-1==this.m&&(this.startTime-=this.duration*this.Y);this.Ca=this.startTime+this.duration;this.Mc=this.startTime;this.Y||this.v("begin");this.v("play");-1==this.m&&this.v("resume");this.m=1;var b=C(this);b in Pa||(Pa[b]=this);$d();be(this,a);return k};s.stop=function(a){Zd(this);this.m=Z;a&&(this.Y=1);de(this,this.Y);this.v("stop");Xd(this)};
s.G=function(){this.m==Z||this.stop(p);this.v("destroy");ce.va.G.call(this)};function be(a,b){a.Y=(b-a.startTime)/(a.Ca-a.startTime);1<=a.Y&&(a.Y=1);a.yd=1E3/(b-a.Mc);a.Mc=b;de(a,a.Y);1==a.Y?(a.m=Z,Zd(a),a.v("finish"),Xd(a)):1==a.m&&a.v("animate")}function de(a,b){ga(a.md)&&(b=a.md(b));a.coords=Array(a.Kb.length);for(var c=0;c<a.Kb.length;c++)a.coords[c]=(a.we[c]-a.Kb[c])*b+a.Kb[c]}s.v=function(a){this.dispatchEvent(new ee(a,this))};
function ee(a,b){S.call(this,a);this.coords=b.coords;this.x=b.coords[0];this.y=b.coords[1];this.k=b.coords[2];this.duration=b.duration;this.Y=b.Y;this.Ec=b.yd;this.state=b.m}G(ee,S);function fe(){Wd.call(this);this.u=[]}G(fe,Wd);fe.prototype.add=function(a){0<=ua(this.u,a)||(this.u.push(a),U(a,"finish",this.Tc,p,this))};fe.prototype.remove=function(a){xa(this.u,a)&&bc(a,"finish",this.Tc,p,this)};fe.prototype.G=function(){I(this.u,function(a){a.F()});this.u.length=0;fe.va.G.call(this)};function ge(){fe.call(this);this.Dc=0}G(ge,fe);
ge.prototype.play=function(a){if(0==this.u.length)return p;if(a||this.m==Z)this.Dc=0,this.v("begin");else if(1==this.m)return p;this.v("play");-1==this.m&&this.v("resume");var b=-1==this.m&&!a;this.startTime=E();this.Ca=n;this.m=1;I(this.u,function(c){(!b||-1==c.m)&&c.play(a)});return k};ge.prototype.stop=function(a){I(this.u,function(b){b.m==Z||b.stop(a)});this.m=Z;this.Ca=E();this.v("stop");Xd(this)};
ge.prototype.Tc=function(){this.Dc++;this.Dc==this.u.length&&(this.Ca=E(),this.m=Z,this.v("finish"),Xd(this))};function he(){fe.call(this);this.ca=0}G(he,fe);he.prototype.play=function(a){if(0==this.u.length)return p;if(a||this.m==Z)this.ca<this.u.length&&this.u[this.ca].m!=Z&&this.u[this.ca].stop(p),this.ca=0,this.v("begin");else if(1==this.m)return p;this.v("play");-1==this.m&&this.v("resume");this.startTime=E();this.Ca=n;this.m=1;this.u[this.ca].play(a);return k};
he.prototype.stop=function(a){this.m=Z;this.Ca=E();if(a)for(a=this.ca;a<this.u.length;++a){var b=this.u[a];b.m==Z&&b.play();b.m==Z||b.stop(k)}else this.ca<this.u.length&&this.u[this.ca].stop(p);this.v("stop");Xd(this)};he.prototype.Tc=function(){1==this.m&&(this.ca++,this.ca<this.u.length?this.u[this.ca].play():(this.Ca=E(),this.m=Z,this.v("finish"),Xd(this)))};function ie(a){this.Aa=a;this.q=n;this.mc=[];this.Tb=[]}
function je(a,b,c,d,e,f){function g(a){var b=a*a,a=a*a*a;return 6*a*b+-15*b*b+10*a}y(a.q)&&a.Uc();a.q=new ge;var i=a.Aa.getPosition();a.mc=[0,0,a.Aa.getHeading(),a.Aa.getTilt()];a.Tb=[0,0,e||0,f||0];ke(a,i[0],i[1],b,c);e=["begin","animate","end"];f=new ce(a.mc,a.Tb,3E3,g);U(f,e,a.cf,p,a);a.q.add(f);d&&(c=Od(i[0],i[1],b,c),b=a.Aa.I,c=Math.min(b,d)+0.2*c,c=Math.max(Math.max(b,d),c),b=new ce([b],[c],1500,g),d=new ce([c],[d],1500,g),U(b,e,a.Sd,p,a),U(d,e,a.Sd,p,a),e=new he,e.add(b),e.add(d),a.q.add(e));
U(a.q,"end",a.Uc,p,a);a.q.play()}function ke(a,b,c,d,e){var c=K(c,2*Math.PI),e=K(e,2*Math.PI),f=c-e;f<-Math.PI?c+=2*Math.PI:f>Math.PI&&(e+=2*Math.PI);a.mc[0]=b;a.mc[1]=c;a.Tb[0]=d;a.Tb[1]=e}ie.prototype.cf=function(a){this.Aa.setPosition(a.coords[0],a.coords[1]);this.Aa.setHeading(a.coords[2]);this.Aa.setTilt(a.coords[3])};ie.prototype.Sd=function(a){Cc(this.Aa,a.coords[0])};ie.prototype.Uc=function(){y(this.q)&&(this.q.F(),this.q=n)};ie.prototype.cancel=function(){this.Uc()};function le(a){this.Bc=a;this.t=U(this.Bc,mb?"DOMMouseScroll":"mousewheel",this)}G(le,uc);
le.prototype.handleEvent=function(a){var b=0,c=0,d=0,a=a.kb;if("mousewheel"==a.type){c=1;if(N||O&&(pb||P("532.0")))c=40;d=O&&hb&&0!=-a.wheelDelta%c?-a.wheelDelta:-a.wheelDelta/c;w(a.wheelDeltaX)?(b=O&&hb&&0!=-a.wheelDeltaX%c?-a.wheelDeltaX:-a.wheelDeltaX/c,c=O&&hb&&0!=-a.wheelDeltaY%c?-a.wheelDeltaY:-a.wheelDeltaY/c):c=d}else d=a.detail,100<d?d=3:-100>d&&(d=-3),w(a.axis)&&a.axis===a.HORIZONTAL_AXIS?b=d:c=d;fa(this.Gd)&&J(b,-this.Gd,this.Gd);fa(this.Hd)&&(c=J(c,-this.Hd,this.Hd));b=new me(d,a,0,c);
try{this.dispatchEvent(b)}finally{b.F()}};le.prototype.G=function(){le.va.G.call(this);V(this.t);delete this.t};function me(a,b,c,d){b&&this.yb(b,j);this.type="mousewheel";this.detail=a;this.vd=d}G(me,Rb);function ne(a){this.f=a;this.Od=new le(a.a.canvas);this.t=U(this.Od,"mousewheel",function(a){this.N(-(0==a.vd?0:0>a.vd?-1:1));a.preventDefault()},p,this);this.re=U(a.a.canvas,"dblclick",D(function(a){Cc(this.b,this.b.I/2);var c=Fc(this,a.offsetX,a.offsetY,k)||Ec(this.b);if(c){var d=(this.b.ea+c[1])/2;Math.abs(this.b.ea-c[1])>Math.PI&&(d+=Math.PI);this.b.setPosition((this.b.V+c[0])/2,d)}a.preventDefault()},a));this.ff=U(a.a.canvas,"mouseup",D(function(a){if(Tb(a,2)){Cc(this.b,2*this.b.I);var c=Fc(this,
a.offsetX,a.offsetY,k)||Ec(this.b);c&&this.b.setPosition(2*this.b.V-c[0],2*this.b.ea-c[1]);a.preventDefault()}},a));this.Ye=U(a.a.canvas,"contextmenu",function(a){a.preventDefault()});this.q=n;this.Xa=this.Wa=0}G(ne,Ob);
ne.prototype.N=function(a){var b=120,a=-1*a;if(this.q){if(this.Xa>this.Wa==0<a)return;this.q.F();this.q=n;b*=(this.f.b.I-this.Wa)/(this.Xa-this.Wa);a=this.Xa;this.Xa=this.Wa;this.Wa=a}else this.Wa=this.f.b.I,this.Xa=J(this.Wa*Math.pow(2,a),250,1E7);if(!(isNaN(b)||0>=b)){var a=this.f.b.getPosition(),c=Ec(this.f.b)||a,d=this.Xa/this.f.b.I;a.push(this.f.b.I);this.q=new ce(a,[c[0]+d*(a[0]-c[0]),c[1]+d*(a[1]-c[1]),this.Xa],b);U(this.q,["animate","finish"],function(a){this.f.b.setPosition(a.x,a.y);Cc(this.f.b,
a.k)},p,this);U(this.q,["finish"],this.xe,p,this);this.q.play(p)}};ne.prototype.xe=function(){this.q&&(this.q.F(),this.q=n)};ne.prototype.G=function(){V(this.t);V(this.re);V(this.ff);V(this.Ye);this.Od.F();this.q.F()};function oe(a){return 1-Math.pow(1-a,3)};function pe(a,b){this.f=a;this.Ac=p;this.cc=this.bc=this.R=this.Q=0;this.Sa=this.t=n;U(this.f.a.canvas,"mousedown",D(this.Vc,this));U(Kb(this.f.a.canvas),"mouseup",D(this.Xc,this));this.D=b||n}s=pe.prototype;s.Vc=function(a){Tb(a,0)&&!a.ctrlKey&&!a.altKey&&(y(this.D)&&this.D.cancel(),this.Sa&&(this.Sa.stop(p),this.Sa.F(),this.Sa=n),this.Ac=k,this.bc=this.Q=a.screenX,this.cc=this.R=a.screenY,x(this.t)||(V(this.t),this.t=n),this.t=U(Kb(this.f.a.canvas),"mousemove",D(this.Wc,this)),a.preventDefault())};
s.Xc=function(a){if(this.Ac&&(a.preventDefault(),this.Ac=p,x(this.t)||(V(this.t),this.t=n),Tb(a,0))){var b=a.screenX-this.bc,c=a.screenY-this.cc,a=Math.sqrt(Math.pow(b,2)+Math.pow(c,2)),b=b/a,c=c/a;this.Q==this.bc&&this.R==this.cc&&(a*=2);6<a&&(a=6*Math.max(15,a),this.Sa=new ce([this.Q,this.R],[this.Q+a*b,this.R+a*c],1300,oe),U(this.Sa,["animate"],this.Ee,p,this),this.Sa.play(p))}};
s.jc=function(a,b){var c=Math.PI*(1/this.f.a.canvas.height)*(this.f.qc/Math.pow(2,Nd(this.f.w,k)));Bc(this.f.b,b*c,-2*a*c)};s.Wc=function(a){this.jc(a.screenX-this.Q,a.screenY-this.R);this.bc=this.Q;this.cc=this.R;this.Q=a.screenX;this.R=a.screenY;a.preventDefault()};s.Ee=function(a){this.jc(a.x-this.Q,a.y-this.R);this.Q=a.x;this.R=a.y};function qe(a,b){this.f=a;this.ua=j;this.R=this.Q=this.Xd=0;this.t=n;U(this.f.a.canvas,"mousedown",D(this.Vc,this));U(Kb(this.f.a.canvas),"mouseup",D(this.Xc,this));this.D=b||n}
qe.prototype.Vc=function(a){if(!Tb(a,2)&&!a.ctrlKey&&!a.altKey){y(this.D)&&this.D.cancel();this.Q=a.screenX;this.R=a.screenY;if(Tb(a,1)||Tb(a,0)&&a.shiftKey)this.ua=Ec(this.f.b),y(this.ua)&&(window.wb&&(window.wb.lat=M(this.ua[0]),window.wb.W=M(this.ua[1]),window.wb.enable(k)),this.Xd=0==this.f.b.getTilt()?this.f.b.I:6378137*(Math.sin(Math.PI-this.f.b.getTilt()-(Math.PI-Math.asin((1+this.f.b.I/6378137)*Math.sin(this.f.b.getTilt()))))/Math.sin(this.f.b.getTilt())));x(this.t)||(V(this.t),this.t=n);
this.t=U(Kb(this.f.a.canvas),"mousemove",D(this.Wc,this));a.preventDefault()}};qe.prototype.Xc=function(a){a.preventDefault();this.ua=j;window.wb&&window.wb.enable(p);x(this.t)||(V(this.t),this.t=n)};
qe.prototype.jc=function(a,b){if(w(this.ua)){var c=-2*a/this.f.a.canvas.width*Math.PI,d=b/this.f.a.canvas.height*Math.PI/2;if(x(this.ua))this.f.b.setHeading(this.f.b.getHeading()+c),this.f.b.setTilt(this.f.b.getTilt()+d);else{var e=this.f.b,f=this.ua[0],g=this.ua[1],i=this.Xd;e.Ra+=c;c=Math.asin(6378137/Math.sqrt(i*i+40680631590769));e.xa=J(e.xa+d,-c,c);d=Math.asin(i/6378137*Math.sin(e.xa));1.0E-4>Math.abs(e.xa)?Cc(e,i):Cc(e,6378137*(Math.sin(Math.PI-e.xa-d)/Math.sin(e.xa)-1));f-=Math.cos(e.Ra)*d;
e.setPosition(f,g+Math.sin(e.Ra)*d/Math.cos(f))}}};qe.prototype.Wc=function(a){this.jc(a.screenX-this.Q,a.screenY-this.R);this.Q=a.screenX;this.R=a.screenY;a.preventDefault()};function re(a,b){this.f=a;this.Bc=b;this.ra=new Xa}function se(a,b){var c=ta(),d=a.Bc;b.parentElement&&b.detach();b.parentElement=d;b.parentElement.appendChild(b.element);a.ra.set(c,b);return c}function te(a,b){var c=a.ra.get(b);w(c)&&(c.detach(),a.ra.remove(b))}
re.prototype.wf=function(a){a=this.ra.get(a);if(a.isEnabled()){var b;a:{var c=this.f;b=a.lat;var d=a.W;b=L(b);var d=L(d),e=Math.cos(b),e=new hc(Math.sin(d)*e,Math.sin(b),Math.cos(d)*e),d=c.a.Eb.multiply(new W([[e.x],[e.y],[e.k],[1]]));if(0==X(d,3,0))b=n;else{d=d.multiply(1/X(d,3,0));b=(X(d,0,0)+1)/2*c.a.ia;var d=(X(d,1,0)-1)/-2*c.a.ha,f=1;if(0>b||b>c.a.ia||0>d||d>c.a.ha)f=0;else{f=tc(0.5,0.5,0,c.a.Fb,1,1);if(x(f)){b=n;break a}c=ic(e,f);e=e.fd(f).normalize();e=Sd(f,e);f=x(e)?0:Math.abs(c-e[0])<Math.abs(c-
e[1])?1:0}b=[b,d,f]}}y(b)?(a.kc(b[0],b[1]),a.show(0<b[2])):a.show(p)}};re.prototype.forEach=function(a){I(this.ra.xb(),function(b){(b=this.ra.get(b))&&a(b)},this)};function ue(a,b){Gd.call(this,"Bing Maps - "+a);var c="bingsCallback_"+a,d="http://dev.virtualearth.net/REST/V1/Imagery/Metadata/"+a+"?key="+b+"&jsonp="+c;u[c]=w(u[c])?Zc(D(this.Zd,this),u[c]):D(this.Zd,this);c=document.createElement("script");c.src=d;c.type="text/javascript";Fb()[0].appendChild(c)}G(ue,Gd);s=ue.prototype;s.Kc=function(){return!x(this.fa)};s.Zd=function(a){this.Db=a;0<a.resourceSets.length&&(this.fa=a.resourceSets[0].resources[0],kd(this));this.yc()};
s.Qa=function(){return x(this.fa)?0:this.fa.zoomMin};s.Ea=function(){return x(this.fa)?18:this.fa.zoomMax};s.Fa=ba(256);function ve(a,b,c){for(var d="",e=1;e<=a;e++)d+=(c>>a-e&1)<<1|b>>a-e&1;return d}s.Hc=function(a,b,c){return x(this.fa)?"":this.fa.imageUrl.replace("{subdomain}",this.fa.imageUrlSubdomains[Math.floor(Math.random()*this.fa.imageUrlSubdomains.length)]).replace("{quadkey}",ve(a,b,c))};s.Cb=function(a,b,c){return x(this.fa)?p:ue.va.Cb.call(this,a,b,c)};
s.Na=function(a){x(this.Db)||R(a,this.Db.copyright)};s.Xb=function(){return!x(this.Db)?this.Db.brandLogoUri:n};s.Db=n;s.fa=n;function we(a,b,c){function d(){x(xe)&&(xe=new google.maps.Map(document.createElement("div")));ye?e():google.maps.event.addListenerOnce(xe,"idle",function(){ye=k;e()})}hd.call(this,"Google Maps - "+a);this.la=n;this.Ne=a;this.Ge=b||0;this.df=c||ca;this.Sb=new ab;this.Oc=0;this.Pc=[];var e=D(function(){this.la=xe.mapTypes[ze(a)];kd(this);this.df()},this);y(u.google)&&google.maps&&google.maps.Map?d():x(Ae)?(Ae="googleMapsCallback"+ta(),u[Ae]=D(d,this),b=document.createElement("script"),Fb()[0].appendChild(b),
b.type="text/javascript",b.src="http://maps.google.com/maps/api/js?v=3.5&sensor=false&callback="+Ae):u[Ae]=Zc(u[Ae],D(d,this))}G(we,hd);we.prototype.Kc=function(){return!x(this.la)};var Ae=n,xe=n,ye=p;s=we.prototype;s.Qa=function(){return x(this.la)?0:this.la.minZoom||0};s.Ea=function(){return x(this.la)?18:this.la.maxZoom};s.Fa=function(){return x(this.la)?256:this.la.tileSize.width};
s.Cb=function(a,b,c){var d=D(function(a){a=a.getElementsByTagName("img");return a[this.Ge]||a[0]},this);a.ud=d;a.sd=D(function(a){this.la.releaseTile(a)},this);var e=this.la.getTile(new google.maps.Point(a.x,a.y),a.zoom,document),d=d(e);d.onload=D(function(){bd(a).src==bd(a).__src__&&(a.state=20,this.da--,b(a))},this);d.onerror=D(function(){a.Cc++;a.state=-10;this.da--;c&&c(a)},this);a.setData(e);a.state=10;this.da++};
s.Na=function(a){0<this.Sb.pa()&&R(a,"Map Data \u00a9 "+(new Date).getFullYear()+" "+this.Sb.Ga().join(", ")+" \u2013 ");R(a,Q("a",{href:"http://www.google.com/intl/en-US_US/help/terms_maps.html",target:"_blank"},"Terms of Use"))};s.Xb=ba("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAYCAMAAACV6r5dAAABI1BMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABxcXEAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQkLCwsRERESEhIZGRkjIyMsLCw6OjpNTU1WVlZhYWFvb28AAABycnJ5eXl8fHzc3NyFhYWGhoaHiIeLi4uSkpKWlpaYmJiampqenp6mpqahoaGlpaWhoaGpqampqamrq6uqqqqur66vr6+usK6ysrK4uLi9vb3CwsLExMTJycnNzc3Q0NDT09PU1NTV1dXX19fZ2dmDg4Pg4ODi4uLj4+Pj4+Pl5eXk5OTl5eXk5OTl5eXk5OTo6Ojq6urv7+/x8fH5+fn9/f3////54OudAAAAYHRSTlNgXlpSTUY/Pjs5NTMwLSsoJiQiIB4cGhcUEgoBAAYXJy43QElWWV1SFRwQQp2LiaQyqYmwRIi1hwi5hyiEWrxsfwW/xMTJycW3qA2ajweNi4+YAdios7vFy5/g6vD2/P7aB358AAADLElEQVR4XpWUe3OiSBTFOxpMfDsqKt2dZGeiBBlx8zABx3EiZBJk8phsMyb4wvv9P8VexCpnq7aym/PX6Uv/qpt7uBDOuRB8IzRva2AYxinbbkNcrKvTqdGrMvtt2hoG4Es63+JIa9PAM03PX81GNf1NXPAR3O5av+GCn858kvlQLe+bcJfRORORYuB3G/sHuJXsbZ1wZbYgaU23bPrxcqd4wGMygsQ/bKynCN/WCTegsxtfWa8dHVhxe3oNigTaZ+OzorPIDofD62EtOv0H14a4RUGKKLOwWUAIxWxLcPr8apo+jDOHXJlGduXldT6YeuNwdWeWI5wNgnusf61YnJyu5uSQb4THTBckV8m44GaVl3kiV0n54JTkmZvKmeCT6PTUYPFtv7q3AFURZAgLUuds0xw+hG+7skVPQlCv4UzSbNqFkDxAK23lfThb49MVyQ8e/JtWXZDeKmy1t0n8BRd7GH47gL4LHQyCF2fwJ9q8YPfQLyGenC3V+8moKRUOOTlewFX+ERP9YaA+T8DZwxX7BTe3cJG1GVde4MqBm/QjN0CN8J0ZdLrpUlU/YJxQD+Y7mhDYZRNv7MFd0sJMnuHiNo6Y/oJOawnn5ePASTSe8HkAV/uyrq+DYydL+J7BmChNz8NPXVg265jZBMg5duUI669LkjlxfXfhJGSOuPSAe5Q4eSKULytw/6C4qmAz02NwU4z3wn4i/QLfs4wPw7NdrZ5NzKGTstafTdqHebfUGAyYIPyx3fVhOXm6vr5f+M1q1gn9kRH0E8d0zw1dtJdJ2eY058KyW8M3mTvNlg8wCzyZIs7tuqQ6ruuNTJVkNL3YMs2vrYxMLZpXTfNLMyMzakw8x4fVebmnqt3jekq96v+U2jpfz7teK2SzxUq7qumM2Uq7UqtpDOt2o12N7OHr/GczlezDItmoVeqKjkC+dKQzxONxsi1LtzaTiH7juLB0EcWgSkeaVRiDWheWiAE7nrj/EuP0BdRcNKGjJanheqP/iUdD7n/EpOSgL2mcvwtHRbdevk5x/qRP7P24oAX1YuxctnIy5e/HMZrGh0Kx3MY43o1vo/mX3/jfzoX94Q7k9zgAAAAASUVORK5CYII=");
s.Wd=function(a){this.Sb=new ab;var b=u.GAddCopyright,c=u.GVerify,d=u.GAppFeatures;u.GAddCopyright=D(function(){7<arguments.length&&0<arguments[7].length&&this.Sb.add(arguments[7])},this);u.GVerify=Xc;u.GAppFeatures=D(function(){this.Oc--;0>=this.Oc&&(u.GAddCopyright=b,u.GVerify=c,u.GAppFeatures=d,I(this.Pc,function(a){a.parentNode.removeChild(a)}),this.Pc=[],this.yc())},this);I(a,function(a){var b=document.createElement("script");Fb()[0].appendChild(b);b.type="text/javascript";this.Pc.push(b);b.src=
"http://maps.google.com/maps?vp="+(M(a.oe)+","+M(a.pe))+"&z="+a.yf+"&spn="+(M(a.nf)+","+M(a.of))+"&t="+Be(this.Ne);this.Oc++},this)};function ze(a){switch(a){case "Terrain":return google.maps.MapTypeId.TERRAIN;case "Hybrid":return google.maps.MapTypeId.HYBRID;case "Roadmap":return google.maps.MapTypeId.ROADMAP;default:case "Satellite":return google.maps.MapTypeId.SATELLITE}}
function Be(a){switch(a){case "Terrain":return"p";case "Hybrid":return"h";case "Roadmap":return"m";default:case "Satellite":return"k"}}var Ce=D(document.createElement,document);document.createElement=function(a){var b=Ce(a);"img"==a&&(b.crossOrigin="");return b};function De(a){Hd.call(this,a||"OpenStreetMaps","http://{sub}.tile.openstreetmap.org/{z}/{x}/{y}.png",0,18,256,p,["a","b","c"])}G(De,Hd);De.prototype.Na=function(a){R(a,"\u00a9 ",Q("a",{href:"http://www.openstreetmap.org/"},"OpenStreetMap")," contributors, CC-BY-SA")};function Ee(a,b,c,d,e,f,g,i,l,m){Gd.call(this,a);"?"!=b.charAt(b.length-1)&&(b+="?");this.tc=0;0<b.length&&(this.url=b,this.tc=1);this.version=c;this.He=d;this.format=f;this.minZoom=l;this.maxZoom=m;this.tileSize=256;"EPSG:900913"==e||"EPSG:3857"==e?this.$d=e:(this.tc=0,h(Error(e+" is an unsupported CRS, please use either EPSG:900913 or EPSG:3857. WMS Server must support one of these.")));this.styles=g;0<i.length&&"&"!=i.charAt(0)&&(i="&"+i);this.ye=i}G(Ee,Gd);Ee.prototype.Qa=r("minZoom");
Ee.prototype.Ea=r("maxZoom");Ee.prototype.Fa=ba(256);
Ee.prototype.Hc=function(a,b,c){function d(a,b){var c=Math.PI-2*Math.PI*a/Math.pow(2,b);return 180/Math.PI*Math.atan(0.5*(Math.exp(c)-Math.exp(-c)))}function e(a){89.5<a&&(a=89.5);-89.5>a&&(a=-89.5);a=Math.tan(0.5*(0.5*Math.PI-a*(Math.PI/180)));return 0-6378137*Math.log(a)}var f="";if(1==this.tc){var f=e(d(c,a)),g=e(d(c+1,a)),c=6378137*(360*(b/Math.pow(2,a))-180)*(Math.PI/180),i=6378137*(360*((b+1)/Math.pow(2,a))-180)*(Math.PI/180),a=Math.max(f,g),b=Math.max(c,i),g=Math.min(f,g),c=Math.min(c,i),f=
this.url+"service=WMS&request=GetMap&version="+this.version,f=f+"&Width="+this.tileSize+"&Height="+this.tileSize,f=f+"&Layers="+this.He+"&Format="+this.format;"1.0"==this.version.substr(0,3)||"1.1"==this.version.substr(0,3)?f=f+"&SRS="+this.$d:"1.3"==this.version.substr(0,3)&&(f=f+"&CRS="+this.$d);f=f+"&STYLES="+this.styles;f=f+"&BBOX="+c+","+g+","+b+","+a+this.ye}return f};function Fe(a){this.cb=a}Fe.prototype.bd=function(a,b,c,d){this.cb.bd(a,b,c,d)};Fe.prototype.kf=function(a){this.cb.opacity=a};Fe.prototype.Be=function(){return this.cb.opacity};var Ge=new Xa;function He(a,b){var c=a;y(b)&&0<b.length&&(c+=b[0]);var d;switch(a){case "mapquest":d=Id;break;case "osm":d=De;break;case "bing":d=ue;break;case "wms":d=Ee;break;case "gooogle":d=we;break;case "custom":d=Hd;break;default:return alert("Unknown MapType '"+a+"' !"),n}d=function(a,b){function c(b){a.apply(this,b)}c.prototype=a.prototype;return new c(b)}(d,b);d=new Fe(d);Ge.set(c,d);return d}function Ie(a,b){var c=a;y(b)&&(c+=b);return Ge.get(c)};function Je(a,b){var c=b||{},d=A(a)?document.getElementById(a):a;if(!x(d)){var e=Q("canvas",{style:"width:100%;height:100%;"});this.a=new Mc(e,n,function(){var a=Q("a",{style:"font-size:110%;display:block;width:100%;top:50%;position:relative;text-align:center;color:#800000;text-shadow:rgba(0,0,0,0.4) 0 0 6px;",href:"http://www.webglearth.com/upgrade.html"},"You need a WebGL-enabled browser to run this application.");R(d,a)});if(y(this.a)){Nc(this.a);var f=Q("div",{style:"width:100%;height:100%;position:relative;"});
R(d,f);R(f,e);He("mapquest");He("osm");this.Fd=new cd(15);U(this.Fd,ed,D(function(){var a=this.a,b=a.d;if(!x(a.Fc)){var c=E();a.Lc<E()-2E3&&(a.Ec=1E3*a.Wb/(E()-a.Lc),a.pd=a.Vb/a.Wb,a.Lc=E(),a.Wb=0,a.Vb=0,a.Fc.innerHTML=a.pd.toFixed(2)+" ms / fps: "+a.Ec.toFixed(2));a.Wb++}b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);a.O.K=kc(4);a.c.draw();x(a.Fc)||(a.Vb+=E()-c);a.Qb&&(a.Qb(),a.Qb=n);a=this.$b;I(a.ra.xb(),a.wf,a)},this));var e=Q("img",{style:"position:absolute;bottom:0;right:0"}),g=Q("div",{style:"position:absolute;bottom:5px;left:5px;width:75%;font-size:8px;text-align:justify;color:#fff;font-family:Verdana,Arial;text-shadow:rgba(0,0,0,0.8) 0 0 4px;"});
R(f,e);R(f,g);this.a.c=new Rd(this.a,j,g,e,y(c.map)?Ie(c.map).cb:j,Q("p",n,"Powered by ",Q("a",{href:"http://www.webglearth.org/",style:"color:#00f"},"WebGL Earth"),"."),c.atmosphere===p);this.$b=new re(this.a.c,f);f=c.position;e=c.center;y(f)&&1<f.length?this.a.c.b.setPosition(L(f[0]),L(f[1])):y(e)&&1<e.length&&this.a.c.b.setPosition(L(e[0]),L(e[1]));f=c.zoom;y(f)&&this.a.c.w.setZoom(f);f=c.altitude;y(f)&&Cc(this.a.c.b,f);f=c.proxyHost;A(f)&&(this.a.Hb=f);this.D=new ie(this.a.c.b);c.panning!==p&&
new pe(this.a.c,this.D);c.tilting!==p&&new qe(this.a.c,this.D);c.zooming!==p&&new ne(this.a.c);this.a.Ib();this.Fd.start()}}}s=Je.prototype;s.setMap=function(a,b){var c=Ie(a,b);y(c)&&this.a.c.w.oa(c.cb)};s.hf=function(a){this.a.c.w.oa(a.cb)};s.lf=function(a){this.a.c.w.oa(y(a)?a.cb:n,p,k)};s.ld=function(a){return D(function(b){var c=Fc(this.a.c,b.offsetX,b.offsetY);b.target=this;b.latitude=y(c)?c[0]:n;b.longitude=y(c)?c[1]:n;a(b)},this)};
s.bf=function(a,b){var c=U(this.a.canvas,a,this.ld(b));return b[C(this)+"___eventKey_"+a]=c};s.Rd=function(a,b){if(y(b)){var c=b[C(this)+"___eventKey_"+a];y(c)&&V(c)}else A(a)||V(a)};s.$e=function(a){dc(this.a.canvas,a)};s.Fe=function(a,b,c,d,e){a=new Vd(a,b,c,d,e);se(this.$b,a);return a};F("WebGLEarth",Je);F("WebGLEarth.prototype.setCenter",function(a){this.D.cancel();this.a.c.b.setPosition(L(a[0]),L(a[1]));this.a.c.b.setTilt(0)});F("WebGLEarth.prototype.getCenter",function(){return[M(this.a.c.b.V),M(this.a.c.b.ea)]});F("WebGLEarth.prototype.setPosition",function(a,b,c){this.D.cancel();this.a.c.b.setPosition(L(a),L(b));y(c)&&this.a.c.w.setZoom(c)});F("WebGLEarth.prototype.getPosition",function(){return[M(this.a.c.b.V),M(this.a.c.b.ea)]});
F("WebGLEarth.prototype.setAltitude",function(a){this.D.cancel();Cc(this.a.c.b,a)});F("WebGLEarth.prototype.getAltitude",function(){return this.a.c.b.I});F("WebGLEarth.prototype.setHeading",function(a){this.D.cancel();this.a.c.b.setHeading(L(a))});F("WebGLEarth.prototype.getHeading",function(){return M(this.a.c.b.getHeading())});F("WebGLEarth.prototype.setTilt",function(a){this.D.cancel();this.a.c.b.setTilt(L(a))});F("WebGLEarth.prototype.getTilt",function(){return M(this.a.c.b.getTilt())});
F("WebGLEarth.prototype.setRoll",function(a){this.D.cancel();this.a.c.b.ic=L(a)});F("WebGLEarth.prototype.getRoll",function(){return M(this.a.c.b.ic)});F("WebGLEarth.prototype.setZoom",function(a){this.D.cancel();this.a.c.w.setZoom(a)});F("WebGLEarth.prototype.getZoom",function(){return this.a.c.w.getZoom()});F("WebGLEarth.prototype.flyTo",function(a,b,c,d,e){je(this.D,L(a),L(b),c,d,e)});
F("WebGLEarth.prototype.flyToFitBounds",function(a,b,c,d){var a=L(a),b=L(b),c=L(c),d=L(d),e;e=this.a.Da;var f=(a+b)/2,f=Od(f,c,f,d),g=Od(a,0,b,0),i=Math.min(Math.max(this.a.fb,f/g),1);e=L(M(e)/(i+0.4)-2);f=Math.max(g,f);f=Math.min(Math.PI/2,e+f/12756274);e=9567205.5*(Math.sin(f)*Math.sqrt(1+1/Math.pow(Math.tan(e),2))-1);c=K(c,2*Math.PI);d=K(d,2*Math.PI);f=c-d;f<-Math.PI?c+=2*Math.PI:f>Math.PI&&(d+=2*Math.PI);a=[(a+b)/2,(c+d)/2];b=Md(this.a.c.w,this.a.c.w.L.Ea()+0.1,a[0]);je(this.D,a[0],a[1],Math.max(e,
b))});F("WebGLEarth.prototype.handleResize",function(){return this.a.Ib()});F("WebGLEarth.prototype.saveScreenshot",function(a){this.a.Qb=D(function(){Ja(this.a.canvas,a,this.$b,this.a.c.mb)},this)});
F("WebGLEarth.prototype.showMiniGlobe",function(a,b){if(y(a)){this.a.c.mb=new Qd(this.a.c,32,32,a);var c=this.a.c.mb;c.e=b;y(j)&&(c.Zc=j);c.canvas.width=c.e;c.canvas.height=c.e;c.d.viewport(0,0,c.canvas.width,c.canvas.height);var d=c.Zc*c.e;c.canvas.style.cssText="position:absolute;z-index:10000;pointer-events:none;right:"+d+"px;bottom:"+d+"px;"}else this.a.c.mb=n});F("WebGLEarth.Maps",{MAPQUEST:"mapquest",OSM:"osm",BING:"bing",WMS:"wms",GOOGLE:"gooogle",CUSTOM:"custom"});
F("WebGLEarth.prototype.initMap",He);F("WebGLEarth.prototype.setMap",Je.prototype.setMap);F("WebGLEarth.prototype.setBaseMap",Je.prototype.hf);F("WebGLEarth.prototype.setOverlayMap",Je.prototype.lf);F("WebGLEarth.prototype.on",Je.prototype.bf);F("WebGLEarth.prototype.off",Je.prototype.Rd);F("WebGLEarth.prototype.offAll",Je.prototype.$e);F("WebGLEarth.prototype.initMarker",Je.prototype.Fe);F("WebGLEarth.Map",Fe);F("WebGLEarth.Map.prototype.setBoundingBox",Fe.prototype.bd);
F("WebGLEarth.Map.prototype.setOpacity",Fe.prototype.kf);F("WebGLEarth.Map.prototype.getOpacity",Fe.prototype.Be);F("WebGLEarth.Marker",Vd);F("WebGLEarth.Marker.prototype.setPosition",function(a,b){this.lat=a;this.W=b});F("WebGLEarth.Marker.prototype.bindPopup",function(a,b,c){a=new Td(a,b,c);this.B&&(b=this.B.B)&&b.parentNode&&b.parentNode.removeChild(b);this.B=a;this.element.appendChild(this.B.B);a.B.style.bottom=this.ka.toFixed(0)+"px";return this});F("WebGLEarth.Marker.prototype.openPopup",function(){this.lc(k)});
F("WebGLEarth.Marker.prototype.closePopup",function(){this.lc(p)});Vd.prototype.ld=function(a){return D(function(b){b.target=this;b.latitude=this.lat;b.longitude=this.W;a(b)},this)};F("WebGLEarth.Marker.prototype.on",function(a,b){var c=U(this.element,a,this.ld(b));return b[C(this)+"___eventKey_"+a]=c});F("WebGLEarth.Marker.prototype.off",Je.prototype.Rd);F("WebGLEarth.Marker.prototype.offAll",function(a){dc(this.element,a)});var Ke=/#(.)(.)(.)/;function Le(a){Me.test(a)||h(Error("'"+a+"' is not a valid hex color"));4==a.length&&(a=a.replace(Ke,"#$1$1$2$2$3$3"));return a.toLowerCase()}var Me=/^#(?:[0-9a-f]{3}){1,2}$/i;function Ne(a){this.a=a;a=this.d=a.d;this.o=n;this.p=[];this.Gb=0;this.aa=a.createBuffer();this.Ha=a.createBuffer();this.Qd=0;var b=Fd("polygon-fs.glsl"),c=Fd("polygon-vs.glsl"),b=Tc(this.a,b,a.FRAGMENT_SHADER),c=Tc(this.a,c,a.VERTEX_SHADER);this.g=a.createProgram();x(this.g)&&h(Error("Unknown"));a.attachShader(this.g,c);a.attachShader(this.g,b);a.bindAttribLocation(this.g,0,"aVertexCoords");a.linkProgram(this.g);a.getProgramParameter(this.g,a.LINK_STATUS)||h(Error("Shader program err: "+a.getProgramInfoLog(this.g)));
this.sc=a.getAttribLocation(this.g,"aVertexCoords");this.vf=a.getUniformLocation(this.g,"uMVPMatrix");this.be=a.getUniformLocation(this.g,"uColor");this.fillColor=[1,0,0,0.8];this.strokeColor=[0,0,0,1];this.rb=0;this.ec=this.ya=p;this.jd=[]}s=Ne.prototype;s.zb=r("ya");function Oe(a){var b=a.ec;a.ec=p;return b}s.Gc=r("rb");
s.ub=function(a,b,c){a=new Pe(a,b);0==this.Gb?(this.o=a,a.next=a,a.H=a):(c=this.p[J(y(c)?c:Number.MAX_VALUE,0,this.p.length-1)],c||(c=this.o.H),a.next=c.next,c.next=a,a.H=c,a.next.H=a);this.p.push(a);a.Ub=this.p.length-1;this.Gb++;Qe(this);Re(this);return a.Ub};function Se(a,b){var c=a.p[b];return!c?[]:[c.H.Ub,c.next.Ub]}function Te(a,b){var c=a.p[b];if(!c)return[];var d=180/Math.PI;return[c.x*d,c.y*d]}s.nb=function(a,b,c){if(a=this.p[a])Ue(a,b,c),Qe(this),Re(this)};
s.pb=function(a){var b=this.p[a];b&&(this.o==b&&(this.o=b==b.next?n:b.next),b.next.H=b.H,b.H.next=b.next,delete this.p[a],this.Gb--,Qe(this),Re(this))};function Ve(a){if(!a.zb())return n;var b=0,c=0,d=0,e=a.o;do var f=e,g=e.next,i=f.x*g.y-g.x*f.y,b=b+(f.x+g.x)*i,c=c+(f.y+g.y)*i,d=d+i,e=e.next;while(e!=a.o);i=6*(d/2)/(180/Math.PI);return[b/i,c/i]}
s.Jc=function(a,b){function c(a,b){return(d-b.x)*(a.y-b.y)-(a.x-b.x)*(e-b.y)}var d=b/180*Math.PI,e=a/180*Math.PI,f=p;I(this.jd,function(a){var b=0>c(a[1],a[2]),d=0>c(a[2],a[0]);0>c(a[0],a[1])==b&&b==d&&(f=k)});return f};function Qe(a){var b=[];if(a.o){var c=a.o,d=0;do c.bb=d++,c=c.next;while(c!=a.o);I(a.p,function(a){a&&(b[3*a.bb+0]=a.fc,b[3*a.bb+1]=a.gc,b[3*a.bb+2]=a.hc)});c=a.d;c.bindBuffer(c.ARRAY_BUFFER,a.aa);c.bufferData(c.ARRAY_BUFFER,new Float32Array(b),c.STATIC_DRAW)}}
function Re(a){var b=a.Gb;a.rb=0;a.jd=[];a.ya=p;if(2<b){var c=n;a.ya=k;var d=a.o;do{var e=k,f=d.next,g=a.o;do{var i=g.next,l=(i.y-g.y)*(f.x-d.x)-(i.x-g.x)*(f.y-d.y),m=((i.x-g.x)*(d.y-g.y)-(i.y-g.y)*(d.x-g.x))/l,g=((f.x-d.x)*(d.y-g.y)-(f.y-d.y)*(d.x-g.x))/l;0<m&&1>m&&0<g&&1>g&&(e=p);g=i}while(e&&g!=a.o);e&&(c=d);a.ya=a.ya&&e;d=f}while(d!=a.o);!a.ya&&4==b&&(c&&function(a,b){var c=a.H,d=b.next;a.H=b;b.next=a;a.next=d;b.H=c;d.H=a;c.next=b}(c,c.next),Qe(a),a.ya=k,a.ec=k)}if(a.ya){c=0;if(0<b){d=a.o;do f=
d.next,c+=d.x*f.y-d.y*f.x,d=f;while(d!=a.o)}if(0<c){a.ec=k;for(d=0;d<a.p.length;++d)if(f=a.p[d])c=f.next,f.next=f.H,f.H=c;Qe(a)}var q=[],d=D(function(a,b,c){function d(a,b){var c=a.fc-b.fc,e=a.gc-b.gc,f=a.hc-b.hc;return Math.sqrt(c*c+e*e+f*f)}q.push([a.bb,b.bb,c.bb]);this.jd.push([a,b,c]);var e=d(a,b),b=d(b,c),a=d(c,a),c=(e+b+a)/2;this.rb+=Math.sqrt(c*(c-e)*(c-b)*(c-a))},a);if(!(3>b))if(3==b)d(a.o,a.o.H,a.o.next);else{var o=a.o,v=function(a,b,c){return-((b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y))},t=
function(a,b){var c=a.eb,d=a.ja;return 0<=v(a,d,c)?0<v(a,b,c)&&0<v(b,a,d):!(0<=v(a,b,d)&&0<=v(b,a,c))},f=function(a,b){var c;if(c=t(a,b))if(c=t(b,a))a:{c=o;var d;do{d=c.ja;if(c!=a&&d!=a&&c!=b&&d!=b&&(0==v(a,b,c)||0==v(a,b,d)||0==v(c,d,a)||0==v(c,d,b)?0:(0<v(a,b,c)||0<v(a,b,d))&&!(0<v(a,b,c)&&0<v(a,b,d))&&(0<v(c,d,a)||0<v(c,d,b))&&!(0<v(c,d,a)&&0<v(c,d,b)))){c=p;break a}c=c.ja}while(c!=o);c=k}return c},B,ha;I(a.p,function(a){a&&(a.ja=a.next,a.eb=a.H)});c=a.o;do e=c.ja,g=c.eb,c.Pb=f(g,e),c=c.ja;while(c!=
a.o);for(i=99;0<i&&3<b;){i--;e=o;m=99;do g=p,e.Pb&&(B=e.ja,ha=B.ja,c=e.eb,g=c.eb,d(B,e,c),c.Pb=f(g,B),B.Pb=f(c,ha),c.ja=B,B.eb=c,o=B,b--,g=k),e=e.ja,m--;while(0<m&&!g&&e!=o)}c&&B&&ha&&d(ha,B,c)}b=Da(q);a.Qd=b.length;B=a.d;B.bindBuffer(B.ELEMENT_ARRAY_BUFFER,a.Ha);B.bufferData(B.ELEMENT_ARRAY_BUFFER,new Uint16Array(b),B.STATIC_DRAW);a.rb*=40680631590769}}
s.draw=function(){var a=this.d;a.enable(a.BLEND);a.disable(a.DEPTH_TEST);a.useProgram(this.g);var b=new Float32Array(Da(oc(this.a.Eb).Ma()));a.uniformMatrix4fv(this.vf,p,b);a.bindBuffer(a.ARRAY_BUFFER,this.aa);a.vertexAttribPointer(this.sc,3,a.FLOAT,p,0,0);a.enableVertexAttribArray(this.sc);this.ya&&(a.uniform4fv(this.be,this.fillColor),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.Ha),a.drawElements(a.TRIANGLES,this.Qd,a.UNSIGNED_SHORT,0));a.uniform4fv(this.be,this.strokeColor);a.drawArrays(a.LINE_LOOP,
0,this.Gb);a.disableVertexAttribArray(this.sc);a.disable(a.BLEND);a.enable(a.DEPTH_TEST)};function Pe(a,b){this.hc=this.gc=this.fc=this.y=this.x=0;Ue(this,a,b);this.H=this.next=n;this.bb=this.Ub=-1;this.Pb=p;this.ja=this.next;this.eb=this.H}function Ue(a,b,c){a.x=c/180*Math.PI;a.y=b/180*Math.PI;b=Math.cos(a.y);a.fc=Math.sin(a.x)*b;a.gc=Math.sin(a.y);a.hc=Math.cos(a.x)*b};function We(a,b,c,d,e,f,g){var i=Q("div",{"class":"we-polydragger-"+(y(d)?"a":"b")});Ud.call(this,a,b,i);this.show(p);U(i,"mousedown",function(a){0==a.button&&(U(c.a.canvas,"mousemove",function(a){var b=Fc(c,a.offsetX,a.offsetY);b&&(this.lat=b[0],this.W=b[1],this.kc(a.offsetX,a.offsetY),y(d)?e(d,this.lat,this.W):g&&(d=g(this.lat,this.W),i.className="we-polydragger-a"),a.preventDefault())},p,this),a.preventDefault())},p,this);U(i,"click",function(a){a.altKey&&y(d)&&(f(d),a.preventDefault())},p,this);
U(i,"mouseup",function(){dc(c.a.canvas,"mousemove")},p,this)}G(We,Ud);xc(".we-polydragger-a{position:absolute;width:8px;height:8px;z-index:100;margin-left:-4px;margin-top:-4px;background-color:#36f;cursor:pointer;border:1px solid blue;}");xc(".we-polydragger-b{position:absolute;width:6px;height:6px;z-index:99;margin-left:-3px;margin-top:-3px;background-color:rgba(180,220,250,0.9);cursor:pointer;border:1px solid blue;}");function Xe(a,b,c){this.n=Q("img",{style:"position:absolute;pointer-events:none;z-index:101;",crossOrigin:n});this.Ld=this.ka=0;this.Id=n;this.od=1;this.f=c;Ud.call(this,a,b,this.n);this.show(p)}G(Xe,Ud);
Xe.prototype.kc=function(a,b){Xe.va.kc.call(this,a,b);var c=1E3*this.ka,d;d=this.lat;var e=this.W,f=this.f.a.Fb,f=(new hc(X(f,0,3),X(f,1,3),X(f,2,3))).scale(1/X(f,3,3));d=L(d);var e=L(e),g=Math.cos(d);d=ic(f,new hc(Math.sin(e)*g,Math.sin(d),Math.cos(e)*g));c=J(c/(6378137*d),this.Ld,this.Id||Number.MAX_VALUE);this.n.height=c;this.n.width=c*this.od;this.n.style.marginLeft="-"+this.n.width/2+"px";this.n.style.marginTop="-"+this.n.height/2+"px";this.n.style.display="block"};
Xe.prototype.cd=function(a,b,c,d){this.n.onload=D(function(){this.od=this.n.naturalWidth/this.n.naturalHeight},this);this.n.style.display="none";this.n.src=a;this.ka=b;this.Ld=c||0;this.Id=d||n};Xe.prototype.xd=function(a){this.visible&&a.drawImage(this.n,parseInt(this.n.style.left,10)-this.n.width/2,parseInt(this.n.style.top,10)-this.n.height/2,this.n.width,this.n.height)};function Ye(a,b){this.c=a;this.Ja=b;this.r=new Ne(a.a);a.nd.push(this.r);this.Pa={};this.sa={};this.Ua={};this.vb=n;this.lb=new Xe(0,0,a);se(this.Ja,this.lb);this.lb.enable(p);this.dc=ca;this.Ed=0}s=Ye.prototype;
s.ve=function(){y(this.vb)||(this.vb=U(this.c.a.canvas,"mousedown",function(a){ac(this.c.a.canvas,"mouseup",function(b){if(0==b.button&&!x(this.vb)&&3>=Math.max(Math.abs(a.offsetX-b.offsetX),Math.abs(a.offsetY-b.offsetY))){var c=Fc(this.c,b.offsetX,b.offsetY);c&&(this.ub(c[0],c[1]),b.preventDefault(),this.Ed=E())}},p,this)},p,this))};s.ue=function(){V(this.vb);this.vb=n};
s.setFillColor=function(a,b){a=Le(a);this.r.fillColor=[parseInt(a.substr(1,2),16)/255,parseInt(a.substr(3,2),16)/255,parseInt(a.substr(5,2),16)/255,y(b)?b:1]};s.setStrokeColor=function(a,b){a=Le(a);this.r.strokeColor=[parseInt(a.substr(1,2),16)/255,parseInt(a.substr(3,2),16)/255,parseInt(a.substr(5,2),16)/255,y(b)?b:1]};s.setIcon=function(a,b,c,d){this.lb.cd(a,b,c,d)};s.jf=aa("dc");s.zb=function(){return this.r.zb()};s.Gc=function(){return this.r.Gc()};
s.Ae=function(){var a=Ve(this.r);return{lat:a[1],lng:a[0]}};s.Jc=function(a,b){return 100>E()-this.Ed?p:this.r.Jc(a,b)};function Ze(a){var b;if(!(b=Ve(a.r)))if(b=a.r,b.o){var c=0,d=0,e=0,f=b.o;do c+=f.x,d+=f.y,e++,f=f.next;while(f!=b.o);e=e/180*Math.PI;b=[c/e,d/e]}else b=[0,0];a.lb.lat=b[1];a.lb.W=b[0];a.lb.enable(a.r.zb())}s.mf=function(a,b){La(this.sa,function(b){b.enable(a)},this);b!==k&&La(this.Pa,function(b){this.Ja.ra.get(b).enable(a)},this)};
s.Ce=function(){var a=this.r,b=180/Math.PI,c=[],d=a.o;do c.push({lat:d.y*b,lng:d.x*b}),d=d.next;while(d!=a.o);return c};function $e(a,b){var c=Se(a.r,b);if(0<c.length){var d=Te(a.r,c[0]),e=Te(a.r,b),f=Te(a.r,c[1]);a.sa[b].lat=(e[1]+f[1])/2;a.sa[b].W=(e[0]+f[0])/2;a.sa[c[0]].lat=(d[1]+e[1])/2;a.sa[c[0]].W=(d[0]+e[0])/2}}function af(a){Oe(a.r)&&La(a.sa,function(a,c){$e(this,c)},a)}
s.ub=function(a,b,c,d){var e=this.r.ub(a,b,c);d&&y(c)?(this.Pa[e]=this.Ua[c],delete this.Ua[c]):(c=new We(a,b,this.c,e,D(this.nb,this),D(this.pb,this)),this.Pa[e]=se(this.Ja,c));Ze(this);c=Se(this.r,e);if(0<c.length){var f=D(function(a){return D(function(b,c){return this.ub(b,c,a,k)},this)},this),g=new We(a,b,this.c,n,D(this.nb,this),D(this.pb,this),f(e));this.sa[e]=g;this.Ua[e]=se(this.Ja,g);d&&(a=new We(a,b,this.c,n,D(this.nb,this),D(this.pb,this),f(c[0])),this.sa[c[0]]=a,this.Ua[c[0]]=se(this.Ja,
a));$e(this,c[0]);$e(this,e);$e(this,c[1])}af(this);this.dc();return e};s.nb=function(a,b,c){this.r.nb(a,b,c);var d=this.Ja.ra.get(this.Pa[a]);d.lat=b;d.W=c;af(this);$e(this,a);Ze(this);this.dc()};s.pb=function(a){var b=Se(this.r,a);this.r.pb(a);Ze(this);y(this.Pa[a])&&(te(this.Ja,this.Pa[a]),delete this.Pa[a],delete this.sa[a],y(this.Ua[a])&&(te(this.Ja,this.Ua[a]),delete this.Ua[a]));af(this);0<b.length&&($e(this,b[0]),$e(this,a),$e(this,b[1]));this.dc()};function $(a){Ye.call(this,a.a.c,a.$b)}G($,Ye);F("WebGLEarth.Polygon",$);F("WebGLEarth.Polygon.prototype.enableClickToAdd",$.prototype.ve);F("WebGLEarth.Polygon.prototype.disableClickToAdd",$.prototype.ue);F("WebGLEarth.Polygon.prototype.setFillColor",$.prototype.setFillColor);F("WebGLEarth.Polygon.prototype.setStrokeColor",$.prototype.setStrokeColor);F("WebGLEarth.Polygon.prototype.setOnChange",$.prototype.jf);F("WebGLEarth.Polygon.prototype.isValid",$.prototype.zb);
F("WebGLEarth.Polygon.prototype.getRoughArea",$.prototype.Gc);F("WebGLEarth.Polygon.prototype.setIcon",$.prototype.setIcon);F("WebGLEarth.Polygon.prototype.showDraggers",$.prototype.mf);F("WebGLEarth.Polygon.prototype.addPoint",$.prototype.ub);F("WebGLEarth.Polygon.prototype.movePoint",$.prototype.nb);F("WebGLEarth.Polygon.prototype.removePoint",$.prototype.pb);F("WebGLEarth.Polygon.prototype.getPoints",$.prototype.Ce);F("WebGLEarth.Polygon.prototype.getCentroid",$.prototype.Ae);
F("WebGLEarth.Polygon.prototype.onClick",function(a){U(this.c.a.canvas,"click",function(b){(b=Fc(this.c,b.offsetX,b.offsetY))&&this.Jc(b[0],b[1])&&a(this)},p,this)});