Newer
Older
www-root / lib / Leaflet.MapboxVectorTile.min.js
@hayashi hayashi on 5 Nov 2017 50 KB leaflet Vector Tile (tileFuel)
!function t(e,r,i){function n(o,a){if(!r[o]){if(!e[o]){var h="function"==typeof require&&require;if(!a&&h)return h(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[o]={exports:{}};e[o][0].call(l.exports,function(t){var r=e[o][1][t];return n(r?r:t)},l,l.exports,t,e,r,i)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o<i.length;o++)n(i[o]);return n}({1:[function(t,e,r){(function(r){"use strict";function i(t){this.buf=t,this.pos=0}var n=t("ieee754");e.exports=i,i.prototype={get length(){return this.buf.length}},i.Varint=0,i.Int64=1,i.Message=2,i.String=2,i.Packed=2,i.Int32=5,i.prototype.destroy=function(){this.buf=null},i.prototype.readUInt32=function(){var t=this.buf.readUInt32LE(this.pos);return this.pos+=4,t},i.prototype.readUInt64=function(){var t=this.buf.readUInt64LE(this.pos);return this.pos+=8,t},i.prototype.readDouble=function(){var t=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},i.prototype.readVarint=function(){var t=this.pos;return this.buf[t]<=127?(this.pos++,this.buf[t]):this.buf[t+1]<=127?(this.pos+=2,127&this.buf[t]|this.buf[t+1]<<7):this.buf[t+2]<=127?(this.pos+=3,127&this.buf[t]|(127&this.buf[t+1])<<7|this.buf[t+2]<<14):this.buf[t+3]<=127?(this.pos+=4,127&this.buf[t]|(127&this.buf[t+1])<<7|(127&this.buf[t+2])<<14|this.buf[t+3]<<21):this.buf[t+4]<=127?(this.pos+=5,(127&this.buf[t]|(127&this.buf[t+1])<<7|(127&this.buf[t+2])<<14|this.buf[t+3]<<21)+268435456*this.buf[t+4]):(this.skip(i.Varint),0)},i.prototype.readSVarint=function(){var t=this.readVarint();if(t>2147483647)throw new Error("TODO: Handle numbers >= 2^30");return t>>1^-(1&t)},i.prototype.readString=function(){for(var t=this.readVarint(),e=String.fromCharCode,r=this.buf,i=this.pos,n=this.pos+t,s="";n>i;)if(r[i]<=127)s+=e(r[i++]);else{if(r[i]<=191)throw new Error("Invalid UTF-8 codepoint: "+r[i]);if(r[i]<=223)s+=e((31&r[i++])<<6|63&r[i++]);else if(r[i]<=239)s+=e((31&r[i++])<<12|(63&r[i++])<<6|63&r[i++]);else if(r[i]<=247)i+=4;else if(r[i]<=251)i+=5;else{if(!(r[i]<=253))throw new Error("Invalid UTF-8 codepoint: "+r[i]);i+=6}}return this.pos+=t,s},i.prototype.readBuffer=function(){var t=this.readVarint(),e=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,e},i.prototype.readPacked=function(t){for(var e=this.readVarint(),r=this.pos+e,i=[];this.pos<r;)i.push(this["read"+t]());return i},i.prototype.skip=function(t){var e=7&t;switch(e){case i.Varint:for(;this.buf[this.pos++]>127;);break;case i.Int64:this.pos+=8;break;case i.Message:var r=this.readVarint();this.pos+=r;break;case i.Int32:this.pos+=4;break;default:throw new Error("Unimplemented type: "+e)}},i.prototype.writeTag=function(t,e){this.writeVarint(t<<3|e)},i.prototype.realloc=function(t){for(var e=this.buf.length;e<this.pos+t;)e*=2;if(e!=this.buf.length){var i=new r(e);this.buf.copy(i),this.buf=i}},i.prototype.finish=function(){return this.buf.slice(0,this.pos)},i.prototype.writePacked=function(t,e,r){if(r.length){for(var n=new i,s=0;s<r.length;s++)n["write"+t](r[s]);var o=n.finish();this.writeTag(e,i.Packed),this.writeBuffer(o)}},i.prototype.writeUInt32=function(t){this.realloc(4),this.buf.writeUInt32LE(t,this.pos),this.pos+=4},i.prototype.writeTaggedUInt32=function(t,e){this.writeTag(t,i.Int32),this.writeUInt32(e)},i.prototype.writeVarint=function(t){if(t=Number(t),isNaN(t)&&(t=0),127>=t)this.realloc(1),this.buf[this.pos++]=t;else if(16383>=t)this.realloc(2),this.buf[this.pos++]=128|t>>>0&127,this.buf[this.pos++]=0|t>>>7&127;else if(33554431>=t)this.realloc(3),this.buf[this.pos++]=128|t>>>0&127,this.buf[this.pos++]=128|t>>>7&127,this.buf[this.pos++]=0|t>>>14&127;else if(268435455>=t)this.realloc(4),this.buf[this.pos++]=128|t>>>0&127,this.buf[this.pos++]=128|t>>>7&127,this.buf[this.pos++]=128|t>>>14&127,this.buf[this.pos++]=0|t>>>21&127;else for(;t>0;){var e=127&t;t=Math.floor(t/128),t>0&&(e|=128),this.realloc(1),this.buf[this.pos++]=e}},i.prototype.writeTaggedVarint=function(t,e){this.writeTag(t,i.Varint),this.writeVarint(e)},i.prototype.writeSVarint=function(t){t>=0?this.writeVarint(2*t):this.writeVarint(-2*t-1)},i.prototype.writeTaggedSVarint=function(t,e){this.writeTag(t,i.Varint),this.writeSVarint(e)},i.prototype.writeBoolean=function(t){this.writeVarint(Boolean(t))},i.prototype.writeTaggedBoolean=function(t,e){this.writeTaggedVarint(t,Boolean(e))},i.prototype.writeString=function(t){t=String(t);var e=r.byteLength(t);this.writeVarint(e),this.realloc(e),this.buf.write(t,this.pos),this.pos+=e},i.prototype.writeTaggedString=function(t,e){this.writeTag(t,i.String),this.writeString(e)},i.prototype.writeFloat=function(t){this.realloc(4),this.buf.writeFloatLE(t,this.pos),this.pos+=4},i.prototype.writeTaggedFloat=function(t,e){this.writeTag(t,i.Int32),this.writeFloat(e)},i.prototype.writeDouble=function(t){this.realloc(8),this.buf.writeDoubleLE(t,this.pos),this.pos+=8},i.prototype.writeTaggedDouble=function(t,e){this.writeTag(t,i.Int64),this.writeDouble(e)},i.prototype.writeBuffer=function(t){var e=t.length;this.writeVarint(e),this.realloc(e),t.copy(this.buf,this.pos),this.pos+=e},i.prototype.writeTaggedBuffer=function(t,e){this.writeTag(t,i.String),this.writeBuffer(e)},i.prototype.writeMessage=function(t,e){var r=e.finish();this.writeTag(t,i.Message),this.writeBuffer(r)}}).call(this,t("buffer").Buffer)},{buffer:14,ieee754:2}],2:[function(t,e,r){r.read=function(t,e,r,i,n){var s,o,a=8*n-i-1,h=(1<<a)-1,u=h>>1,l=-7,f=r?n-1:0,c=r?-1:1,p=t[e+f];for(f+=c,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=256*s+t[e+f],f+=c,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=i;l>0;o=256*o+t[e+f],f+=c,l-=8);if(0===s)s=1-u;else{if(s===h)return o?NaN:(p?-1:1)*(1/0);o+=Math.pow(2,i),s-=u}return(p?-1:1)*o*Math.pow(2,s-i)},r.write=function(t,e,r,i,n,s){var o,a,h,u=8*s-n-1,l=(1<<u)-1,f=l>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:s-1,d=i?1:-1,y=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),e+=o+f>=1?c/h:c*Math.pow(2,1-f),e*h>=2&&(o++,h/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*h-1)*Math.pow(2,n),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,n),o=0));n>=8;t[r+p]=255&a,p+=d,a/=256,n-=8);for(o=o<<n|a,u+=n;u>0;t[r+p]=255&o,p+=d,o/=256,u-=8);t[r+p-d]|=128*y}},{}],3:[function(t,e,r){"use strict";function i(t,e){this.x=t,this.y=e}e.exports=i,i.prototype={clone:function(){return new i(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,r=t.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,r=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=r,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),r=Math.sin(t),i=e*this.x-r*this.y,n=r*this.x+e*this.y;return this.x=i,this.y=n,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},i.convert=function(t){return t instanceof i?t:Array.isArray(t)?new i(t[0],t[1]):t}},{}],4:[function(t,e,r){e.exports.VectorTile=t("./lib/vectortile.js"),e.exports.VectorTileFeature=t("./lib/vectortilefeature.js"),e.exports.VectorTileLayer=t("./lib/vectortilelayer.js")},{"./lib/vectortile.js":5,"./lib/vectortilefeature.js":6,"./lib/vectortilelayer.js":7}],5:[function(t,e,r){"use strict";function i(t,e){for(this.layers={},this._buffer=t,e=e||t.length;t.pos<e;){var r=t.readVarint(),i=r>>3;if(3==i){var n=this.readLayer();n.length&&(this.layers[n.name]=n)}else t.skip(r)}}var n=t("./vectortilelayer");e.exports=i,i.prototype.readLayer=function(){var t=this._buffer,e=t.readVarint(),r=t.pos+e,i=new n(t,r);return t.pos=r,i}},{"./vectortilelayer":7}],6:[function(t,e,r){"use strict";function i(t,e,r,i,n){for(this.properties={},this.extent=r,this.type=0,this._buffer=t,this._geometry=-1,e=e||t.length;t.pos<e;){var s=t.readVarint(),o=s>>3;if(1==o)this._id=t.readVarint();else if(2==o)for(var a=t.readVarint(),h=t.pos+a;t.pos<h;){var u=i[t.readVarint()],l=n[t.readVarint()];this.properties[u]=l}else 3==o?this.type=t.readVarint():4==o?(this._geometry=t.pos,t.skip(s)):t.skip(s)}}var n=t("point-geometry");e.exports=i,i.types=["Unknown","Point","LineString","Polygon"],i.prototype.loadGeometry=function(){var t=this._buffer;t.pos=this._geometry;for(var e,r=t.readVarint(),i=t.pos+r,s=1,o=0,a=0,h=0,u=[];t.pos<i;){if(!o){var l=t.readVarint();s=7&l,o=l>>3}if(o--,1===s||2===s)a+=t.readSVarint(),h+=t.readSVarint(),1===s&&(e&&u.push(e),e=[]),e.push(new n(a,h));else{if(7!==s)throw new Error("unknown command "+s);e.push(e[0].clone())}}return e&&u.push(e),u},i.prototype.bbox=function(){var t=this._buffer;t.pos=this._geometry;for(var e=t.readVarint(),r=t.pos+e,i=1,n=0,s=0,o=0,a=1/0,h=-(1/0),u=1/0,l=-(1/0);t.pos<r;){if(!n){var f=t.readVarint();i=7&f,n=f>>3}if(n--,1===i||2===i)s+=t.readSVarint(),o+=t.readSVarint(),a>s&&(a=s),s>h&&(h=s),u>o&&(u=o),o>l&&(l=o);else if(7!==i)throw new Error("unknown command "+i)}return[a,u,h,l]}},{"point-geometry":3}],7:[function(t,e,r){"use strict";function i(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._buffer=t,this._keys=[],this._values=[],this._features=[];var r,i;for(e=e||t.length;t.pos<e;)r=t.readVarint(),i=r>>3,15===i?this.version=t.readVarint():1===i?this.name=t.readString():5===i?this.extent=t.readVarint():2===i?(this.length++,this._features.push(t.pos),t.skip(r)):3===i?this._keys.push(t.readString()):4===i?this._values.push(this.readFeatureValue()):t.skip(r)}var n=t("./vectortilefeature.js");e.exports=i,i.prototype.readFeatureValue=function(){for(var t,e,r=this._buffer,i=null,n=r.readVarint(),s=r.pos+n;r.pos<s;)if(t=r.readVarint(),e=t>>3,1==e)i=r.readString();else{if(2==e)throw new Error("read float");if(3==e)i=r.readDouble();else if(4==e)i=r.readVarint();else{if(5==e)throw new Error("read uint");6==e?i=r.readSVarint():7==e?i=Boolean(r.readVarint()):r.skip(t)}}return i},i.prototype.feature=function(t){if(0>t||t>=this._features.length)throw new Error("feature index out of bounds");this._buffer.pos=this._features[t];var e=this._buffer.readVarint()+this._buffer.pos;return new n(this._buffer,e,this.extent,this._keys,this._values)}},{"./vectortilefeature.js":6}],8:[function(t,e,r){function n(t,e,r,i,n){if(!e)return null;for(var o in e)this[o]=e[o];this.mvtLayer=t,this.mvtSource=t.mvtSource,this.map=t.mvtSource.map,this.id=i,this.layerLink=this.mvtSource.layerLink,this.toggleEnabled=!0,this.selected=!1,this.divisor=e.extent/r.tileSize,this.extent=e.extent,this.tileSize=r.tileSize,this.tiles={},this.style=n,this.addTileFeature(e,r);var a=this;this.map.on("zoomend",function(){a.staticLabel=null}),n&&n.dynamicLabel&&"function"==typeof n.dynamicLabel&&(this.dynamicLabel=this.mvtSource.dynamicLabel.createFeature(this)),s(a)}function s(t){var e=t.style;if(e&&e.ajaxSource&&"function"==typeof e.ajaxSource){var r=e.ajaxSource(t);r&&h.getJSON(r,function(e,r,i){if(e)throw["ajaxSource AJAX Error",e];return o(t,r),!0})}return!1}function o(t,e){t.ajaxData=e,"function"==typeof t.ajaxDataReceived&&t.ajaxDataReceived(t,e),t._setStyle(t.mvtLayer.style),a(t)}function a(t){var e=t.tiles,r=t.mvtLayer;for(var i in e){var n=parseInt(i.split(":")[0]),s=t.map.getZoom();n===s&&r.redrawTile(i)}}var h=t("./MVTUtil"),u=t("./StaticLabel/StaticLabel.js");e.exports=n,n.prototype._setStyle=function(t){this.style=t(this,this.ajaxData),this.removeLabel()},n.prototype.setStyle=function(t){this.ajaxData=null,this.style=t(this,null);var e=s(this);e||this.removeLabel()},n.prototype.draw=function(t){var e=this.tiles[t],r=e.vtf,i=e.ctx,n=t.split(":").slice(1,3).join(":");if(i.canvas=this.mvtLayer._tiles[n],this.selected)var s=this.style.selected||this.style;else var s=this.style;switch(r.type){case 1:if(this._drawPoint(i,r.coordinates,s),!this.staticLabel&&"function"==typeof this.style.staticLabel){if(this.style.ajaxSource&&!this.ajaxData)break;this._drawStaticLabel(i,r.coordinates,s)}break;case 2:this._drawLineString(i,r.coordinates,s);break;case 3:this._drawPolygon(i,r.coordinates,s);break;default:throw new Error("Unmanaged type: "+r.type)}},n.prototype.getPathsForTile=function(t){return this.tiles[t].paths},n.prototype.addTileFeature=function(t,e){var r=this.map.getZoom();e.zoom==r&&(this.clearTileFeatures(r),this.tiles[e.id]={ctx:e,vtf:t,paths:[]})},n.prototype.clearTileFeatures=function(t){for(var e in this.tiles)e.split(":")[0]!=t&&delete this.tiles[e]},n.prototype.toggle=function(){this.selected?this.deselect():this.select()},n.prototype.select=function(){this.selected=!0,this.mvtSource.featureSelected(this),a(this);var t=this.linkedFeature();t&&t.staticLabel&&!t.staticLabel.selected&&t.staticLabel.select()},n.prototype.deselect=function(){this.selected=!1,this.mvtSource.featureDeselected(this),a(this);var t=this.linkedFeature();t&&t.staticLabel&&t.staticLabel.selected&&t.staticLabel.deselect()},n.prototype.on=function(t,e){this._eventHandlers[t]=e},n.prototype._drawPoint=function(t,e,r){if(r&&t&&t.canvas){var i=this.tiles[t.id],n=1;n="function"==typeof r.radius?r.radius(t.zoom):r.radius;var s,o=this._tilePoint(e[0][0]),a=t.canvas;try{s=a.getContext("2d")}catch(h){return void console.log("_drawPoint error: "+h)}s.beginPath(),s.fillStyle=r.color,s.arc(o.x,o.y,n,0,2*Math.PI),s.closePath(),s.fill(),r.lineWidth&&r.strokeStyle&&(s.lineWidth=r.lineWidth,s.strokeStyle=r.strokeStyle,s.stroke()),s.restore(),i.paths.push([o])}},n.prototype._drawLineString=function(t,e,r){if(r&&t&&t.canvas){var n=t.canvas.getContext("2d");n.strokeStyle=r.color,n.lineWidth=r.size,n.beginPath();var s=[],o=this.tiles[t.id];for(var a in e){var h=e[a];for(i=0;i<h.length;i++){var u=(0===i?"move":"line")+"To",l=this._tilePoint(h[i]);s.push(l),n[u](l.x,l.y)}}n.stroke(),n.restore(),o.paths.push(s)}},n.prototype._drawPolygon=function(t,e,r){if(r&&t&&t.canvas){var i=t.canvas.getContext("2d"),n=r.outline;"function"==typeof r.color?i.fillStyle=r.color(i):i.fillStyle=r.color,n&&(i.strokeStyle=n.color,i.lineWidth=n.size),i.beginPath();var s=[],o=this.tiles[t.id],a=this.dynamicLabel;a&&a.addTilePolys(t,e);for(var h=0,u=e.length;u>h;h++)for(var l=e[h],f=0;f<l.length;f++){var c=(l[f],(0===f?"move":"line")+"To"),p=this._tilePoint(l[f]);s.push(p),i[c](p.x,p.y)}i.closePath(),i.fill(),n&&i.stroke(),o.paths.push(s)}},n.prototype._drawStaticLabel=function(t,e,r){if(r&&t&&this.mvtLayer._map){var i=this._tilePoint(e[0][0]),n=this._project(i,t.tile.x,t.tile.y,this.extent,this.tileSize),s=L.point(n.x,n.y),o=this.map.unproject(s);this.staticLabel=new u(this,t,o,r),this.mvtLayer.featureWithLabelAdded(this)}},n.prototype.removeLabel=function(){this.staticLabel&&(this.staticLabel.remove(),this.staticLabel=null)},n.prototype._project=function(t,e,r,i,n){var s=e*n,o=r*n;return{x:Math.floor(t.x+s),y:Math.floor(t.y+o)}},n.prototype._tilePoint=function(t){return new L.Point(t.x/this.divisor,t.y/this.divisor)},n.prototype.linkedFeature=function(){var t=this.mvtLayer.linkedLayer();if(t){var e=t.features[this.id];return e}return null}},{"./MVTUtil":11,"./StaticLabel/StaticLabel.js":12}],9:[function(require,module,exports){function removeLabels(t){for(var e=t.featuresWithLabels,r=0,i=e.length;i>r;r++){var n=e[r];n.removeLabel()}t.featuresWithLabels=[]}function in_circle(t,e,r,i,n){var s=Math.pow(t-i,2)+Math.pow(e-n,2);return s<=Math.pow(r,2)}function waitFor(testFx,onReady,timeOutMillis){var maxtimeOutMillis=timeOutMillis?timeOutMillis:3e3,start=(new Date).getTime(),condition="string"==typeof testFx?eval(testFx):testFx(),interval=setInterval(function(){(new Date).getTime()-start<maxtimeOutMillis&&!condition?condition="string"==typeof testFx?eval(testFx):testFx():condition?(console.log("'waitFor()' finished in "+((new Date).getTime()-start)+"ms."),clearInterval(interval),"string"==typeof onReady?eval(onReady):onReady("success")):(console.log("'waitFor()' timeout"),clearInterval(interval),"string"==typeof onReady?eval(onReady):onReady("timeout"))},50)}var MVTFeature=require("./MVTFeature"),Util=require("./MVTUtil");module.exports=L.TileLayer.Canvas.extend({options:{debug:!1,isHiddenLayer:!1,getIDForLayerFeature:function(){},tileSize:256,lineClickTolerance:2},_featureIsClicked:{},_isPointInPoly:function(t,e){if(e&&e.length){for(var r=!1,i=-1,n=e.length,s=n-1;++i<n;s=i)(e[i].y<=t.y&&t.y<e[s].y||e[s].y<=t.y&&t.y<e[i].y)&&t.x<(e[s].x-e[i].x)*(t.y-e[i].y)/(e[s].y-e[i].y)+e[i].x&&(r=!r);return r}},_getDistanceFromLine:function(t,e){var r=Number.POSITIVE_INFINITY;if(e&&e.length>1){t=L.point(t.x,t.y);for(var i=0,n=e.length-1;n>i;i++){var s=this._projectPointOnLineSegment(t,e[i],e[i+1]);s.distance<=r&&(r=s.distance)}}return r},_projectPointOnLineSegment:function(t,e,r){var i=e.distanceTo(r);if(1>i)return{distance:t.distanceTo(e),coordinate:e};var n=((t.x-e.x)*(r.x-e.x)+(t.y-e.y)*(r.y-e.y))/Math.pow(i,2);if(1e-7>n)return{distance:t.distanceTo(e),coordinate:e};if(n>.9999999)return{distance:t.distanceTo(r),coordinate:r};var s=L.point(e.x+n*(r.x-e.x),e.y+n*(r.y-e.y));return{distance:t.distanceTo(s),point:s}},initialize:function(t,e){var r=this;r.mvtSource=t,L.Util.setOptions(this,e),this.style=e.style,this.name=e.name,this._canvasIDToFeatures={},this.features={},this.featuresWithLabels=[],this._highestCount=0},onAdd:function(t){var e=this;e.map=t,L.TileLayer.Canvas.prototype.onAdd.call(this,t),t.on("layerremove",function(t){t.layer._leaflet_id===e._leaflet_id&&removeLabels(e)})},drawTile:function(t,e,r){var i={canvas:t,tile:e,zoom:r,tileSize:this.options.tileSize};i.id=Util.getContextID(i),this._canvasIDToFeatures[i.id]||this._initializeFeaturesHash(i),this.features||(this.features={})},_initializeFeaturesHash:function(t){this._canvasIDToFeatures[t.id]={},this._canvasIDToFeatures[t.id].features=[],this._canvasIDToFeatures[t.id].canvas=t.canvas},_draw:function(t){},getCanvas:function(t){var e=t.tile,r=this._tiles[e.x+":"+e.y];if(r)return t.canvas=r,void this.redrawTile(t.id);var i=this;waitFor(function(){return r=i._tiles[e.x+":"+e.y],r?!0:void 0},function(){r=i._tiles[e.x+":"+e.y],t.canvas=r,i.redrawTile(t.id)},2e3)},parseVectorTileLayer:function(t,e){var r=this,i=e.tile,n={canvas:null,id:e.id,tile:e.tile,zoom:e.zoom,tileSize:e.tileSize};n.canvas=r._tiles[i.x+":"+i.y],this._canvasIDToFeatures[n.id]?this.clearTileFeatureHash(n.id):this._initializeFeaturesHash(n);for(var s=t.parsedFeatures,o=0,a=s.length;a>o;o++){var h=s[o];h.layer=t;var u=r.options.filter;if("function"!=typeof u||u(h,n)!==!1){var l;l="function"==typeof r.options.getIDForLayerFeature?r.options.getIDForLayerFeature:Util.getIDForLayerFeature;var f=r.options.getIDForLayerFeature(h)||o,c=r.features[f],p=r.options.layerOrdering;if("function"==typeof p&&p(h,n),c)c.addTileFeature(h,n);else{var d=r.style(h);r.features[f]=c=new MVTFeature(r,h,n,f,d),d&&d.dynamicLabel&&"function"==typeof d.dynamicLabel&&r.featuresWithLabels.push(c)}n&&n.id&&r._canvasIDToFeatures[n.id].features.push(c)}}var p=r.options.layerOrdering;p&&(r._canvasIDToFeatures[n.id].features=r._canvasIDToFeatures[n.id].features.sort(function(t,e){return-(e.properties.zIndex-t.properties.zIndex)})),r.redrawTile(n.id)},setStyle:function(t){this._highestCount=0,this._lowestCount=null,this.style=t;for(var e in this.features){var r=this.features[e];r.setStyle(t)}var i=this.map.getZoom();for(var e in this._tiles){var n=i+":"+e;this.redrawTile(n)}},setHighestCount:function(t){t>this._highestCount&&(this._highestCount=t)},getHighestCount:function(){return this._highestCount},setLowestCount:function(t){(!this._lowestCount||t<this._lowestCount)&&(this._lowestCount=t)},getLowestCount:function(){return this._lowestCount},setCountRange:function(t){this.setHighestCount(t),this.setLowestCount(t)},handleClickEvent:function(t,e){var r=t.tileID.split(":").slice(1,3).join(":"),i=t.tileID.split(":")[0],n=this._tiles[r];n||e(t);for(var s,o,a,h=t.layerPoint.x-n._leaflet_pos.x,u=t.layerPoint.y-n._leaflet_pos.y,l={x:h,y:u},f=this._canvasIDToFeatures[t.tileID].features,c=Number.POSITIVE_INFINITY,p=null,d=0;d<f.length;d++){var y=f[d];switch(y.type){case 1:var v=3;for(v="function"==typeof y.style.radius?y.style.radius(i):y.style.radius,o=y.getPathsForTile(t.tileID),s=0;s<o.length;s++)in_circle(o[s][0].x,o[s][0].y,v,h,u)&&(p=y,c=0);break;case 2:for(o=y.getPathsForTile(t.tileID),s=0;s<o.length;s++)if(y.style){var a=this._getDistanceFromLine(l,o[s]),g=y.selected&&y.style.selected?y.style.selected.size:y.style.size;a<g/2+this.options.lineClickTolerance&&c>a&&(p=y,c=a)}break;case 3:for(o=y.getPathsForTile(t.tileID),s=0;s<o.length;s++)this._isPointInPoly(l,o[s])&&(p=y,c=0)}if(0==c)break}p&&p.toggleEnabled&&p.toggle(),t.feature=p,e(t)},clearTile:function(t){var e=t.split(":"),r=e[1]+":"+e[2];if("undefined"==typeof this._tiles[r])return void console.error("typeof this._tiles[canvasId] === 'undefined'");var i=this._tiles[r],n=i.getContext("2d");n.clearRect(0,0,i.width,i.height)},clearTileFeatureHash:function(t){this._canvasIDToFeatures[t]={features:[]}},clearLayerFeatureHash:function(){this.features={}},redrawTile:function(t){this.clearTile(t);var e=this._canvasIDToFeatures[t];if(e){for(var r=e.features,i=[],n=0;n<r.length;n++){var s=r[n];s.selected?i.push(s):s.draw(t)}for(var o=0,a=i.length;a>o;o++){var h=i[o];h.draw(t)}}},_resetCanvasIDToFeatures:function(t,e){this._canvasIDToFeatures[t]={},this._canvasIDToFeatures[t].features=[],this._canvasIDToFeatures[t].canvas=e},linkedLayer:function(){if(this.mvtSource.layerLink){var t=this.mvtSource.layerLink(this.name);return this.mvtSource.layers[t]}return null},featureWithLabelAdded:function(t){this.featuresWithLabels.push(t)}})},{"./MVTFeature":8,"./MVTUtil":11}],10:[function(t,e,r){function i(t,e,r){var i=parseInt(Math.floor((e+180)/360*(1<<r))),n=parseInt(Math.floor((1-Math.log(Math.tan(t.toRad())+1/Math.cos(t.toRad()))/Math.PI)/2*(1<<r)));return""+r+":"+i+":"+n}function n(t,e){t.loadedTiles[e.id]=e}function s(t){for(var e in t.layers){var r=t.layers[e];o(r)}return t}function o(t){t.parsedFeatures=[];for(var e=t._features,r=0,i=e.length;i>r;r++){var n=t.feature(r);n.coordinates=n.loadGeometry(),t.parsedFeatures.push(n)}return t}var a=t("vector-tile").VectorTile,h=t("pbf"),u=(t("point-geometry"),t("./MVTUtil")),l=t("./MVTLayer");e.exports=L.TileLayer.MVTSource=L.TileLayer.Canvas.extend({options:{debug:!1,url:"",getIDForLayerFeature:function(){},tileSize:256,visibleLayers:[],xhrHeaders:{}},layers:{},processedTiles:{},_eventHandlers:{},_triggerOnTilesLoadedEvent:!0,_url:"",style:function(t){var e={},r=t.type;switch(r){case 1:e.color="rgba(49,79,79,1)",e.radius=5,e.selected={color:"rgba(255,255,0,0.5)",radius:6};break;case 2:e.color="rgba(161,217,155,0.8)",e.size=3,e.selected={color:"rgba(255,25,0,0.5)",size:4};break;case 3:e.color="rgba(49,79,79,1)",e.outline={color:"rgba(161,217,155,0.8)",size:1},e.selected={color:"rgba(255,140,0,0.3)",outline:{color:"rgba(255,140,0,1)",size:2}}}return e},initialize:function(t){L.Util.setOptions(this,t),this.layers={},this.activeTiles={},this.loadedTiles={},this._url=this.options.url,this.zIndex=t.zIndex,"function"==typeof t.style&&(this.style=t.style),"function"==typeof t.ajaxSource&&(this.ajaxSource=t.ajaxSource),this.layerLink=t.layerLink,this._eventHandlers={},this._tilesToProcess=0},redraw:function(t){t===!1&&(this._triggerOnTilesLoadedEvent=!1),L.TileLayer.Canvas.prototype.redraw.call(this)},onAdd:function(t){var e=this;e.map=t,L.TileLayer.Canvas.prototype.onAdd.call(this,t);var r=function(t){e._onClick(t)};t.on("click",r),t.on("layerremove",function(i){i.layer._leaflet_id===e._leaflet_id&&i.layer.removeChildLayers&&(i.layer.removeChildLayers(t),t.off("click",r))}),e.addChildLayers(t),"function"==typeof DynamicLabel&&(this.dynamicLabel=new DynamicLabel(t,this,{}))},drawTile:function(t,e,r){var i={id:[r,e.x,e.y].join(":"),canvas:t,tile:e,zoom:r,tileSize:this.options.tileSize};this._tilesToProcess<this._tilesToLoad&&(this._tilesToProcess=this._tilesToLoad);var n=i.id=u.getContextID(i);this.activeTiles[n]=i,this.processedTiles[i.zoom]||(this.processedTiles[i.zoom]={}),this.options.debug&&this._drawDebugInfo(i),this._draw(i)},setOpacity:function(t){this._setVisibleLayersStyle("opacity",t)},setZIndex:function(t){this._setVisibleLayersStyle("zIndex",t)},_setVisibleLayersStyle:function(t,e){for(var r in this.layers)this.layers[r]._tileContainer.style[t]=e},_drawDebugInfo:function(t){var e=this.options.tileSize,r=t.canvas.getContext("2d");r.strokeStyle="#000000",r.fillStyle="#FFFF00",r.strokeRect(0,0,e,e),r.font="12px Arial",r.fillRect(0,0,5,5),r.fillRect(0,e-5,5,5),r.fillRect(e-5,0,5,5),r.fillRect(e-5,e-5,5,5),r.fillRect(e/2-5,e/2-5,10,10),r.strokeText(t.zoom+" "+t.tile.x+" "+t.tile.y,e/2-30,e/2-10)},_draw:function(t){var e=this;if(this._url){var r=this.getTileUrl({x:t.tile.x,y:t.tile.y,z:t.zoom}),i=new XMLHttpRequest;i.onload=function(){if("200"==i.status){if(!i.response)return;var r=new Uint8Array(i.response),o=new h(r),u=new a(o);if(e.map&&e.map.getZoom()!=t.zoom)return void console.log("Fetched tile for zoom level "+t.zoom+". Map is at zoom level "+e._map.getZoom());e.checkVectorTileLayers(s(u),t),n(e,t)}e.reduceTilesToProcessCount()},i.onerror=function(){console.log("xhr error: "+i.status)},i.open("GET",r,!0);var o=e.options.xhrHeaders;for(var u in o)i.setRequestHeader(u,o[u]);i.responseType="arraybuffer",i.send()}},reduceTilesToProcessCount:function(){this._tilesToProcess--,this._tilesToProcess||(this._eventHandlers.PBFLoad&&this._eventHandlers.PBFLoad(),this._pbfLoaded())},checkVectorTileLayers:function(t,e,r){var i=this;if(i.options.visibleLayers&&i.options.visibleLayers.length>0)for(var n=0;n<i.options.visibleLayers.length;n++){var s=i.options.visibleLayers[n];t.layers[s]&&i.prepareMVTLayers(t.layers[s],s,e,r)}else for(var o in t.layers)i.prepareMVTLayers(t.layers[o],o,e,r)},prepareMVTLayers:function(t,e,r,i){var n=this;n.layers[e]||(n.layers[e]=n.createMVTLayer(e,t.parsedFeatures[0].type||null)),i?n.layers[e].getCanvas(r,t):n.layers[e].parseVectorTileLayer(t,r)},createMVTLayer:function(t,e){var r,i=this;r="function"==typeof i.options.getIDForLayerFeature?i.options.getIDForLayerFeature:u.getIDForLayerFeature;var n={getIDForLayerFeature:r,filter:i.options.filter,layerOrdering:i.options.layerOrdering,style:i.style,name:t,asynch:!0};i.options.zIndex&&(n.zIndex=i.zIndex);var s=new l(i,n).addTo(i.map);return s},getLayers:function(){return this.layers},hideLayer:function(t){this.layers[t]&&(this._map.removeLayer(this.layers[t]),this.options.visibleLayers.indexOf("id")>-1&&this.visibleLayers.splice(this.options.visibleLayers.indexOf("id"),1))},showLayer:function(t){this.layers[t]&&(this._map.addLayer(this.layers[t]),-1==this.options.visibleLayers.indexOf("id")&&this.visibleLayers.push(t)),this.bringToFront()},removeChildLayers:function(t){for(var e in this.layers){var r=this.layers[e];t.removeLayer(r)}},addChildLayers:function(t){var e=this;if(e.options.visibleLayers.length>0)for(var r=0;r<e.options.visibleLayers.length;r++){var i=e.options.visibleLayers[r],n=this.layers[i];n&&t.addLayer(n)}else for(var s in this.layers){var n=this.layers[s];n._map||t.addLayer(n)}},bind:function(t,e){this._eventHandlers[t]=e},_onClick:function(t){var e=this,r=e.options.onClick,n=e.options.clickableLayers,s=e.layers;if(t.tileID=i(t.latlng.lat,t.latlng.lng,this.map.getZoom()),n||(n=Object.keys(e.layers)),n&&n.length>0)for(var o=0,a=n.length;a>o;o++){var h=n[o],u=s[h];u&&u.handleClickEvent(t,function(t){"function"==typeof r&&r(t)})}else"function"==typeof r&&r(t)},setFilter:function(t,e){for(var r in this.layers){var i=this.layers[r];e?r.toLowerCase()==e.toLowerCase()&&(i.options.filter=t,i.clearLayerFeatureHash()):(i.options.filter=t,i.clearLayerFeatureHash())}},setStyle:function(t,e){for(var r in this.layers){var i=this.layers[r];e?r.toLowerCase()==e.toLowerCase()&&i.setStyle(t):i.setStyle(t)}},featureSelected:function(t){this.options.mutexToggle&&(this._selectedFeature&&this._selectedFeature.deselect(),this._selectedFeature=t),this.options.onSelect&&this.options.onSelect(t)},featureDeselected:function(t){this.options.mutexToggle&&this._selectedFeature&&(this._selectedFeature=null),this.options.onDeselect&&this.options.onDeselect(t)},_pbfLoaded:function(){this.bringToFront();var t=this,e=t.options.onTilesLoaded;e&&"function"==typeof e&&this._triggerOnTilesLoadedEvent===!0&&e(this),t._triggerOnTilesLoadedEvent=!0}}),"undefined"==typeof Number.prototype.toRad&&(Number.prototype.toRad=function(){return this*Math.PI/180})},{"./MVTLayer":9,"./MVTUtil":11,pbf:1,"point-geometry":3,"vector-tile":4}],11:[function(t,e,r){var i=e.exports={};i.getContextID=function(t){return[t.zoom,t.tile.x,t.tile.y].join(":")},i.getIDForLayerFeature=function(t){return t.properties.id},i.getJSON=function(t,e){var r="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");r.onreadystatechange=function(){var t=r.status;if(4===r.readyState&&t>=200&&300>t){var i=JSON.parse(r.responseText);e(null,i)}else e({error:!0,status:t})},r.open("GET",t,!0),r.send()}},{}],12:[function(t,e,r){function i(t,e,r,i){var s=this;if(this.mvtFeature=t,this.map=t.map,this.zoom=e.zoom,this.latLng=r,this.selected=!1,t.linkedFeature){var o=t.linkedFeature();o&&o.selected&&(s.selected=!0)}n(s,t,e,r,i)}function n(t,e,r,i,n){var s=e.ajaxData,o=t.style=n.staticLabel(e,s),a=t.icon=L.divIcon({className:o.cssClass||"label-icon-text",html:o.html,iconSize:o.iconSize||[50,50]});t.marker=L.marker(i,{icon:a}).addTo(t.map),t.selected&&t.marker._icon.classList.add(t.style.cssSelectedClass||"label-icon-text-selected"),t.marker.on("click",function(e){t.toggle()}),t.map.on("zoomend",function(e){var r=e.target.getZoom();t.zoom!==r&&t.map.removeLayer(t.marker)})}t("../MVTUtil");e.exports=i,i.prototype.toggle=function(){this.selected?this.deselect():this.select()},i.prototype.select=function(){this.selected=!0,this.marker._icon.classList.add(this.style.cssSelectedClass||"label-icon-text-selected");var t=this.mvtFeature.linkedFeature();t.selected||t.select()},i.prototype.deselect=function(){this.selected=!1,this.marker._icon.classList.remove(this.style.cssSelectedClass||"label-icon-text-selected");var t=this.mvtFeature.linkedFeature();t.selected&&t.deselect()},i.prototype.remove=function(){this.map&&this.marker&&this.map.removeLayer(this.marker)}},{"../MVTUtil":11}],13:[function(t,e,r){/**
 * Copyright (c) 2014, Spatial Development International
 * All rights reserved.
 *
 * Source code can be found at:
 * https://github.com/SpatialServer/Leaflet.MapboxVectorTile
 *
 * @license ISC
 */
e.exports=t("./MVTSource")},{"./MVTSource":10}],14:[function(t,e,r){(function(e){function i(){function t(){}try{var e=new Uint8Array(1);return e.foo=function(){return 42},e.constructor=t,42===e.foo()&&e.constructor===t&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(r){return!1}}function n(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t){return this instanceof s?(this.length=0,this.parent=void 0,"number"==typeof t?o(this,t):"string"==typeof t?a(this,t,arguments.length>1?arguments[1]:"utf8"):h(this,t)):arguments.length>1?new s(t,arguments[1]):new s(t)}function o(t,e){if(t=y(t,0>e?0:0|v(e)),!s.TYPED_ARRAY_SUPPORT)for(var r=0;e>r;r++)t[r]=0;return t}function a(t,e,r){("string"!=typeof r||""===r)&&(r="utf8");var i=0|w(e,r);return t=y(t,i),t.write(e,r),t}function h(t,e){if(s.isBuffer(e))return u(t,e);if(G(e))return l(t,e);if(null==e)throw new TypeError("must start with number, buffer, array or string");if("undefined"!=typeof ArrayBuffer){if(e.buffer instanceof ArrayBuffer)return f(t,e);if(e instanceof ArrayBuffer)return c(t,e)}return e.length?p(t,e):d(t,e)}function u(t,e){var r=0|v(e.length);return t=y(t,r),e.copy(t,0,0,r),t}function l(t,e){var r=0|v(e.length);t=y(t,r);for(var i=0;r>i;i+=1)t[i]=255&e[i];return t}function f(t,e){var r=0|v(e.length);t=y(t,r);for(var i=0;r>i;i+=1)t[i]=255&e[i];return t}function c(t,e){return s.TYPED_ARRAY_SUPPORT?(e.byteLength,t=s._augment(new Uint8Array(e))):t=f(t,new Uint8Array(e)),t}function p(t,e){var r=0|v(e.length);t=y(t,r);for(var i=0;r>i;i+=1)t[i]=255&e[i];return t}function d(t,e){var r,i=0;"Buffer"===e.type&&G(e.data)&&(r=e.data,i=0|v(r.length)),t=y(t,i);for(var n=0;i>n;n+=1)t[n]=255&r[n];return t}function y(t,e){s.TYPED_ARRAY_SUPPORT?(t=s._augment(new Uint8Array(e)),t.__proto__=s.prototype):(t.length=e,t._isBuffer=!0);var r=0!==e&&e<=s.poolSize>>>1;return r&&(t.parent=K),t}function v(t){if(t>=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|t}function g(t,e){if(!(this instanceof g))return new g(t,e);var r=new s(t,e);return delete r.parent,r}function w(t,e){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return N(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return W(t).length;default:if(i)return N(t).length;e=(""+e).toLowerCase(),i=!0}}function b(t,e,r){var i=!1;if(e=0|e,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return A(this,e,r);case"binary":return P(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function _(t,e,r,i){r=Number(r)||0;var n=t.length-r;i?(i=Number(i),i>n&&(i=n)):i=n;var s=e.length;if(s%2!==0)throw new Error("Invalid hex string");i>s/2&&(i=s/2);for(var o=0;i>o;o++){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+o]=a}return o}function m(t,e,r,i){return Z(N(e,t.length-r),t,r,i)}function L(t,e,r,i){return Z(H(e),t,r,i)}function T(t,e,r,i){return L(t,e,r,i)}function E(t,e,r,i){return Z(W(e),t,r,i)}function I(t,e,r,i){return Z(q(e,t.length-r),t,r,i)}function x(t,e,r){return 0===e&&r===t.length?X.fromByteArray(t):X.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;r>n;){var s=t[n],o=null,a=s>239?4:s>223?3:s>191?2:1;if(r>=n+a){var h,u,l,f;switch(a){case 1:128>s&&(o=s);break;case 2:h=t[n+1],128===(192&h)&&(f=(31&s)<<6|63&h,f>127&&(o=f));break;case 3:h=t[n+1],u=t[n+2],128===(192&h)&&128===(192&u)&&(f=(15&s)<<12|(63&h)<<6|63&u,f>2047&&(55296>f||f>57343)&&(o=f));break;case 4:h=t[n+1],u=t[n+2],l=t[n+3],128===(192&h)&&128===(192&u)&&128===(192&l)&&(f=(15&s)<<18|(63&h)<<12|(63&u)<<6|63&l,f>65535&&1114112>f&&(o=f))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),n+=a}return F(i)}function F(t){var e=t.length;if(Q>=e)return String.fromCharCode.apply(String,t);for(var r="",i=0;e>i;)r+=String.fromCharCode.apply(String,t.slice(i,i+=Q));return r}function A(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;r>n;n++)i+=String.fromCharCode(127&t[n]);return i}function P(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;r>n;n++)i+=String.fromCharCode(t[n]);return i}function U(t,e,r){var i=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>i)&&(r=i);for(var n="",s=e;r>s;s++)n+=j(t[s]);return n}function R(t,e,r){for(var i=t.slice(e,r),n="",s=0;s<i.length;s+=2)n+=String.fromCharCode(i[s]+256*i[s+1]);return n}function B(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function D(t,e,r,i,n,o){if(!s.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>n||o>e)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range")}function M(t,e,r,i){0>e&&(e=65535+e+1);for(var n=0,s=Math.min(t.length-r,2);s>n;n++)t[r+n]=(e&255<<8*(i?n:1-n))>>>8*(i?n:1-n)}function k(t,e,r,i){0>e&&(e=4294967295+e+1);for(var n=0,s=Math.min(t.length-r,4);s>n;n++)t[r+n]=e>>>8*(i?n:3-n)&255}function C(t,e,r,i,n,s){if(e>n||s>e)throw new RangeError("value is out of bounds");if(r+i>t.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function V(t,e,r,i,n){return n||C(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),J.write(t,e,r,i,23,4),r+4}function O(t,e,r,i,n){return n||C(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),J.write(t,e,r,i,52,8),r+8}function z(t){if(t=Y(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function Y(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function j(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t,e){e=e||1/0;for(var r,i=t.length,n=null,s=[],o=0;i>o;o++){if(r=t.charCodeAt(o),r>55295&&57344>r){if(!n){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=r;continue}if(56320>r){(e-=3)>-1&&s.push(239,191,189),n=r;continue}r=n-55296<<10|r-56320|65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,128>r){if((e-=1)<0)break;s.push(r)}else if(2048>r){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(65536>r){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(1114112>r))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function H(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function q(t,e){for(var r,i,n,s=[],o=0;o<t.length&&!((e-=2)<0);o++)r=t.charCodeAt(o),i=r>>8,n=r%256,s.push(n),s.push(i);return s}function W(t){return X.toByteArray(z(t))}function Z(t,e,r,i){for(var n=0;i>n&&!(n+r>=e.length||n>=t.length);n++)e[n+r]=t[n];return n}/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
 * @license  MIT
 */
var X=t("base64-js"),J=t("ieee754"),G=t("is-array");r.Buffer=s,r.SlowBuffer=g,r.INSPECT_MAX_BYTES=50,s.poolSize=8192;var K={};s.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:i(),s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array),s.isBuffer=function(t){return!(null==t||!t._isBuffer)},s.compare=function(t,e){if(!s.isBuffer(t)||!s.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);o>n&&t[n]===e[n];)++n;return n!==o&&(r=t[n],i=e[n]),i>r?-1:r>i?1:0},s.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},s.concat=function(t,e){if(!G(t))throw new TypeError("list argument must be an Array of Buffers.");if(0===t.length)return new s(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;r++)e+=t[r].length;var i=new s(e),n=0;for(r=0;r<t.length;r++){var o=t[r];o.copy(i,n),n+=o.length}return i},s.byteLength=w,s.prototype.length=void 0,s.prototype.parent=void 0,s.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?S(this,0,t):b.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:0===s.compare(this,t)},s.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},s.prototype.compare=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?0:s.compare(this,t)},s.prototype.indexOf=function(t,e){function r(t,e,r){for(var i=-1,n=0;r+n<t.length;n++)if(t[r+n]===e[-1===i?0:n-i]){if(-1===i&&(i=n),n-i+1===e.length)return r+i}else i=-1;return-1}if(e>2147483647?e=2147483647:-2147483648>e&&(e=-2147483648),e>>=0,0===this.length)return-1;if(e>=this.length)return-1;if(0>e&&(e=Math.max(this.length+e,0)),"string"==typeof t)return 0===t.length?-1:String.prototype.indexOf.call(this,t,e);if(s.isBuffer(t))return r(this,t,e);if("number"==typeof t)return s.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,t,e):r(this,[t],e);throw new TypeError("val must be string, number or Buffer")},s.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},s.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},s.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else if(isFinite(e))e=0|e,isFinite(r)?(r=0|r,void 0===i&&(i="utf8")):(i=r,r=void 0);else{var n=i;i=e,e=0|r,r=n}var s=this.length-e;if((void 0===r||r>s)&&(r=s),t.length>0&&(0>r||0>e)||e>this.length)throw new RangeError("attempt to write outside buffer bounds");i||(i="utf8");for(var o=!1;;)switch(i){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return m(this,t,e,r);case"ascii":return L(this,t,e,r);case"binary":return T(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;s.prototype.slice=function(t,e){var r=this.length;t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t);var i;if(s.TYPED_ARRAY_SUPPORT)i=s._augment(this.subarray(t,e));else{var n=e-t;i=new s(n,void 0);for(var o=0;n>o;o++)i[o]=this[o+t]}return i.length&&(i.parent=this.parent||this),i},s.prototype.readUIntLE=function(t,e,r){t=0|t,e=0|e,r||B(t,e,this.length);for(var i=this[t],n=1,s=0;++s<e&&(n*=256);)i+=this[t+s]*n;return i},s.prototype.readUIntBE=function(t,e,r){t=0|t,e=0|e,r||B(t,e,this.length);for(var i=this[t+--e],n=1;e>0&&(n*=256);)i+=this[t+--e]*n;return i},s.prototype.readUInt8=function(t,e){return e||B(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||B(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||B(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t=0|t,e=0|e,r||B(t,e,this.length);for(var i=this[t],n=1,s=0;++s<e&&(n*=256);)i+=this[t+s]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*e)),i},s.prototype.readIntBE=function(t,e,r){t=0|t,e=0|e,r||B(t,e,this.length);for(var i=e,n=1,s=this[t+--i];i>0&&(n*=256);)s+=this[t+--i]*n;return n*=128,s>=n&&(s-=Math.pow(2,8*e)),s},s.prototype.readInt8=function(t,e){return e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||B(t,4,this.length),J.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||B(t,4,this.length),J.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||B(t,8,this.length),J.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||B(t,8,this.length),J.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,i){t=+t,e=0|e,r=0|r,i||D(this,t,e,r,Math.pow(2,8*r),0);var n=1,s=0;for(this[e]=255&t;++s<r&&(n*=256);)this[e+s]=t/n&255;return e+r},s.prototype.writeUIntBE=function(t,e,r,i){t=+t,e=0|e,r=0|r,i||D(this,t,e,r,Math.pow(2,8*r),0);var n=r-1,s=1;for(this[e+n]=255&t;--n>=0&&(s*=256);)this[e+n]=t/s&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):k(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):k(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=0|e,!i){var n=Math.pow(2,8*r-1);D(this,t,e,r,n-1,-n)}var s=0,o=1,a=0>t?1:0;for(this[e]=255&t;++s<r&&(o*=256);)this[e+s]=(t/o>>0)-a&255;return e+r},s.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=0|e,!i){var n=Math.pow(2,8*r-1);D(this,t,e,r,n-1,-n)}var s=r-1,o=1,a=0>t?1:0;for(this[e+s]=255&t;--s>=0&&(o*=256);)this[e+s]=(t/o>>0)-a&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):M(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):M(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):k(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e=0|e,r||D(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):k(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return V(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return V(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return O(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return O(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,i){if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(0>e)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var n,o=i-r;if(this===t&&e>r&&i>e)for(n=o-1;n>=0;n--)t[n+e]=this[n+r];else if(1e3>o||!s.TYPED_ARRAY_SUPPORT)for(n=0;o>n;n++)t[n+e]=this[n+r];else t._set(this.subarray(r,r+o),e);return o},s.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new RangeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var i;if("number"==typeof t)for(i=e;r>i;i++)this[i]=t;else{var n=N(t.toString()),s=n.length;for(i=e;r>i;i++)this[i]=n[i%s]}return this}},s.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(s.TYPED_ARRAY_SUPPORT)return new s(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var $=s.prototype;s._augment=function(t){return t.constructor=s,t._isBuffer=!0,t._set=t.set,t.get=$.get,t.set=$.set,t.write=$.write,t.toString=$.toString,t.toLocaleString=$.toString,t.toJSON=$.toJSON,t.equals=$.equals,t.compare=$.compare,t.indexOf=$.indexOf,t.copy=$.copy,t.slice=$.slice,t.readUIntLE=$.readUIntLE,t.readUIntBE=$.readUIntBE,t.readUInt8=$.readUInt8,t.readUInt16LE=$.readUInt16LE,t.readUInt16BE=$.readUInt16BE,t.readUInt32LE=$.readUInt32LE,t.readUInt32BE=$.readUInt32BE,t.readIntLE=$.readIntLE,t.readIntBE=$.readIntBE,t.readInt8=$.readInt8,t.readInt16LE=$.readInt16LE,t.readInt16BE=$.readInt16BE,t.readInt32LE=$.readInt32LE,t.readInt32BE=$.readInt32BE,t.readFloatLE=$.readFloatLE,t.readFloatBE=$.readFloatBE,t.readDoubleLE=$.readDoubleLE,t.readDoubleBE=$.readDoubleBE,t.writeUInt8=$.writeUInt8,t.writeUIntLE=$.writeUIntLE,t.writeUIntBE=$.writeUIntBE,t.writeUInt16LE=$.writeUInt16LE,t.writeUInt16BE=$.writeUInt16BE,t.writeUInt32LE=$.writeUInt32LE,t.writeUInt32BE=$.writeUInt32BE,t.writeIntLE=$.writeIntLE,t.writeIntBE=$.writeIntBE,t.writeInt8=$.writeInt8,t.writeInt16LE=$.writeInt16LE,t.writeInt16BE=$.writeInt16BE,t.writeInt32LE=$.writeInt32LE,t.writeInt32BE=$.writeInt32BE,t.writeFloatLE=$.writeFloatLE,t.writeFloatBE=$.writeFloatBE,t.writeDoubleLE=$.writeDoubleLE,t.writeDoubleBE=$.writeDoubleBE,t.fill=$.fill,t.inspect=$.inspect,t.toArrayBuffer=$.toArrayBuffer,t};var tt=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":15,ieee754:16,"is-array":17}],15:[function(t,e,r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===o||e===f?62:e===a||e===c?63:h>e?-1:h+10>e?e-h+26+26:l+26>e?e-l:u+26>e?e-u+26:void 0}function r(t){function r(t){u[f++]=t}var i,n,o,a,h,u;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=t.length;h="="===t.charAt(l-2)?2:"="===t.charAt(l-1)?1:0,u=new s(3*t.length/4-h),o=h>0?t.length-4:t.length;var f=0;for(i=0,n=0;o>i;i+=4,n+=3)a=e(t.charAt(i))<<18|e(t.charAt(i+1))<<12|e(t.charAt(i+2))<<6|e(t.charAt(i+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===h?(a=e(t.charAt(i))<<2|e(t.charAt(i+1))>>4,r(255&a)):1===h&&(a=e(t.charAt(i))<<10|e(t.charAt(i+1))<<4|e(t.charAt(i+2))>>2,r(a>>8&255),r(255&a)),u}function n(t){function e(t){return i.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var n,s,o,a=t.length%3,h="";for(n=0,o=t.length-a;o>n;n+=3)s=(t[n]<<16)+(t[n+1]<<8)+t[n+2],h+=r(s);switch(a){case 1:s=t[t.length-1],h+=e(s>>2),h+=e(s<<4&63),h+="==";break;case 2:s=(t[t.length-2]<<8)+t[t.length-1],h+=e(s>>10),h+=e(s>>4&63),h+=e(s<<2&63),h+="="}return h}var s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="+".charCodeAt(0),a="/".charCodeAt(0),h="0".charCodeAt(0),u="a".charCodeAt(0),l="A".charCodeAt(0),f="-".charCodeAt(0),c="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=n}("undefined"==typeof r?this.base64js={}:r)},{}],16:[function(t,e,r){arguments[4][2][0].apply(r,arguments)},{dup:2}],17:[function(t,e,r){var i=Array.isArray,n=Object.prototype.toString;e.exports=i||function(t){return!!t&&"[object Array]"==n.call(t)}},{}]},{},[13]);